keepmind 1.2.2 → 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/.codex-plugin/plugin.json +1 -1
- package/dist/npx-cli/index.js +145 -145
- package/dist/opencode-plugin/index.js +7 -7
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/.codex-plugin/plugin.json +1 -1
- package/plugin/hooks/hooks.json +9 -9
- package/plugin/package.json +1 -1
- package/plugin/scripts/context-generator.cjs +1 -1
- package/plugin/scripts/hook-client.cjs +9 -9
- package/plugin/scripts/mcp-server.cjs +2 -2
- package/plugin/scripts/transcript-watcher.cjs +4 -4
- package/plugin/scripts/worker-service.cjs +214 -247
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
var __filename = __filename || require("node:path").resolve(process.argv[1] || "");
|
|
3
3
|
var __dirname = __dirname || require("node:path").dirname(__filename);
|
|
4
4
|
var __IMPORT_META_URL__ = require("node:url").pathToFileURL(__filename).href;
|
|
5
|
-
"use strict";var Iv=Object.create;var li=Object.defineProperty;var Cv=Object.getOwnPropertyDescriptor;var Av=Object.getOwnPropertyNames;var Mv=Object.getPrototypeOf,Nv=Object.prototype.hasOwnProperty;var E=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},Rl=(t,e)=>{for(var r in e)li(t,r,{get:e[r],enumerable:!0})},Dv=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Av(e))!Nv.call(t,o)&&o!==r&&li(t,o,{get:()=>e[o],enumerable:!(n=Cv(e,o))||n.enumerable});return t};var we=(t,e,r)=>(r=t!=null?Iv(Mv(t)):{},Dv(e||!t||!t.__esModule?li(r,"default",{value:t,enumerable:!0}):r,t));var Cd=E((DC,Id)=>{"use strict";var HE=["||","&&",";;","|&","<(","<<<",">>",">&","<&","&",";","(",")","|","<",">"],Rd=/[\n\r\u2028\u2029]/,WE=/[\s#!"$&'():;<=>@\\^`|]/g;Id.exports=function(e){return e.map(function(r){if(r==="")return"''";if(r&&typeof r=="object"){if("op"in r&&r.op==="glob"){if(typeof r.pattern!="string")throw new TypeError("glob token requires a string `pattern`");if(Rd.test(r.pattern))throw new TypeError("glob `pattern` must not contain line terminators");return r.pattern.replace(WE,"\\$&")}if("op"in r&&typeof r.op=="string"){if(HE.indexOf(r.op)<0)throw new TypeError("invalid `op` value: "+JSON.stringify(r.op));return r.op.replace(/[\s\S]/g,"\\$&")}if("comment"in r&&typeof r.comment=="string"){if(Rd.test(r.comment))throw new TypeError("`comment` must not contain line terminators");return"#"+r.comment}throw new TypeError("unrecognized object token shape")}return/["\s\\]/.test(r)&&!/'/.test(r)?"'"+r.replace(/(['])/g,"\\$1")+"'":/["'\s]/.test(r)?'"'+r.replace(/(["\\$`!])/g,"\\$1")+'"':String(r).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}~])/g,"$1\\$2")}).join(" ")}});var Ud=E((LC,jd)=>{"use strict";var Ld="(?:"+["\\|\\|","\\&\\&",";;","\\|\\&","\\<\\(","\\<\\<\\<",">>",">\\&","<\\&","[&;()|<>]"].join("|")+")",Ad=new RegExp("^"+Ld+"$"),Md="|&;()<> \\t",KE='"((\\\\"|[^"])*?)"',VE="'((\\\\'|[^'])*?)'",JE=/^#$/,Nd="'",Dd='"',Ui="$",er="",GE=4294967296;for(Fi=0;Fi<4;Fi++)er+=(GE*Math.random()).toString(16);var Fi,BE=new RegExp("^"+er);function YE(t,e){for(var r=e.lastIndex,n=[],o;o=e.exec(t);)n[n.length]=o,e.lastIndex===o.index&&(e.lastIndex+=1);return e.lastIndex=r,n}function XE(t,e,r){var n=typeof t=="function"?t(r):t[r];return typeof n>"u"&&r!=""?n="":typeof n>"u"&&(n="$"),typeof n=="object"?e+er+JSON.stringify(n)+er:e+n}function QE(t,e,r){r||(r={});var n=r.escape||"\\",o="(\\"+n+`['"`+Md+`]|[^\\s'"`+Md+"])+",s=new RegExp(["("+Ld+")","("+o+"|"+KE+"|"+VE+")+"].join("|"),"g"),i=YE(t,s);if(i.length===0)return[];e||(e={});var a=!1;return i.map(function(c){var u=c[0];if(!u||a)return;if(Ad.test(u))return{op:u};var l=!1,d=!1,p="",m=!1,h;function y(){h+=1;var b,w,$=u.charAt(h);if($==="{"){if(h+=1,u.charAt(h)==="}")throw new Error("Bad substitution: "+u.slice(h-2,h+1));if(b=u.indexOf("}",h),b<0)throw new Error("Bad substitution: "+u.slice(h));w=u.slice(h,b),h=b}else if(/[*@#?$!_-]/.test($))w=$,h+=1;else{var x=u.slice(h);b=x.match(/[^\w\d_]/),b?(w=x.slice(0,b.index),h+=b.index-1):(w=x,h=u.length)}return XE(e,"",w)}for(h=0;h<u.length;h++){var g=u.charAt(h);if(m=m||!l&&(g==="*"||g==="?"),d)p+=g,d=!1;else if(l)g===l?l=!1:l==Nd?p+=g:g===n?(h+=1,g=u.charAt(h),g===Dd||g===n||g===Ui?p+=g:p+=n+g):g===Ui?p+=y():p+=g;else if(g===Dd||g===Nd)l=g;else{if(Ad.test(g))return{op:u};if(JE.test(g)){a=!0;var v={comment:t.slice(c.index+h+1)};return p.length?[p,v]:[v]}else g===n?d=!0:g===Ui?p+=y():p+=g}}return m?{op:"glob",pattern:p}:p}).reduce(function(c,u){return typeof u>"u"||[].concat(u).forEach(function(l){c[c.length]=l}),c},[])}jd.exports=function(e,r,n){var o=QE(e,r,n);return typeof r!="function"?o:o.reduce(function(s,i){if(typeof i=="object")return s[s.length]=i,s;var a=i.split(RegExp("("+er+".*?"+er+")","g"));return a.length===1?(s[s.length]=a[0],s):(a.filter(Boolean).forEach(function(c){s[s.length]=BE.test(c)?JSON.parse(c.split(er)[1]):c}),s)},[])}});var Fd=E(Zi=>{"use strict";Zi.quote=Cd();Zi.parse=Ud()});var Zn=E(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});H.regexpCode=H.getEsmExportName=H.getProperty=H.safeStringify=H.stringify=H.strConcat=H.addCodeArg=H.str=H._=H.nil=H._Code=H.Name=H.IDENTIFIER=H._CodeOrName=void 0;var Un=class{};H._CodeOrName=Un;H.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var ir=class extends Un{constructor(e){if(super(),!H.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};H.Name=ir;var Ye=class extends Un{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof ir&&(r[n.str]=(r[n.str]||0)+1),r),{})}};H._Code=Ye;H.nil=new Ye("");function zg(t,...e){let r=[t[0]],n=0;for(;n<e.length;)fc(r,e[n]),r.push(t[++n]);return new Ye(r)}H._=zg;var pc=new Ye("+");function Rg(t,...e){let r=[Fn(t[0])],n=0;for(;n<e.length;)r.push(pc),fc(r,e[n]),r.push(pc,Fn(t[++n]));return Cx(r),new Ye(r)}H.str=Rg;function fc(t,e){e instanceof Ye?t.push(...e._items):e instanceof ir?t.push(e):t.push(Nx(e))}H.addCodeArg=fc;function Cx(t){let e=1;for(;e<t.length-1;){if(t[e]===pc){let r=Ax(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function Ax(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof ir||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof ir))return`"${t}${e.slice(1)}`}function Mx(t,e){return e.emptyStr()?t:t.emptyStr()?e:Rg`${t}${e}`}H.strConcat=Mx;function Nx(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:Fn(Array.isArray(t)?t.join(","):t)}function Dx(t){return new Ye(Fn(t))}H.stringify=Dx;function Fn(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}H.safeStringify=Fn;function Lx(t){return typeof t=="string"&&H.IDENTIFIER.test(t)?new Ye(`.${t}`):zg`[${t}]`}H.getProperty=Lx;function jx(t){if(typeof t=="string"&&H.IDENTIFIER.test(t))return new Ye(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}H.getEsmExportName=jx;function Ux(t){return new Ye(t.toString())}H.regexpCode=Ux});var gc=E(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});Ne.ValueScope=Ne.ValueScopeName=Ne.Scope=Ne.varKinds=Ne.UsedValueState=void 0;var Me=Zn(),mc=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},gs;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(gs||(Ne.UsedValueState=gs={}));Ne.varKinds={const:new Me.Name("const"),let:new Me.Name("let"),var:new Me.Name("var")};var _s=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof Me.Name?e:this.name(e)}name(e){return new Me.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Ne.Scope=_s;var ys=class extends Me.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,Me._)`.${new Me.Name(r)}[${n}]`}};Ne.ValueScopeName=ys;var Fx=(0,Me._)`\n`,hc=class extends _s{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?Fx:Me.nil}}get(){return this._scope}name(e){return new ys(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(e),{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(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Me._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(e,r,n={},o){let s=Me.nil;for(let i in e){let a=e[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,gs.Started);let l=r(u);if(l){let d=this.opts.es5?Ne.varKinds.var:Ne.varKinds.const;s=(0,Me._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,Me._)`${s}${l}${this.opts._n}`;else throw new mc(u);c.set(u,gs.Completed)})}return s}};Ne.ValueScope=hc});var M=E(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.or=N.and=N.not=N.CodeGen=N.operators=N.varKinds=N.ValueScopeName=N.ValueScope=N.Scope=N.Name=N.regexpCode=N.stringify=N.getProperty=N.nil=N.strConcat=N.str=N._=void 0;var U=Zn(),st=gc(),Ut=Zn();Object.defineProperty(N,"_",{enumerable:!0,get:function(){return Ut._}});Object.defineProperty(N,"str",{enumerable:!0,get:function(){return Ut.str}});Object.defineProperty(N,"strConcat",{enumerable:!0,get:function(){return Ut.strConcat}});Object.defineProperty(N,"nil",{enumerable:!0,get:function(){return Ut.nil}});Object.defineProperty(N,"getProperty",{enumerable:!0,get:function(){return Ut.getProperty}});Object.defineProperty(N,"stringify",{enumerable:!0,get:function(){return Ut.stringify}});Object.defineProperty(N,"regexpCode",{enumerable:!0,get:function(){return Ut.regexpCode}});Object.defineProperty(N,"Name",{enumerable:!0,get:function(){return Ut.Name}});var ws=gc();Object.defineProperty(N,"Scope",{enumerable:!0,get:function(){return ws.Scope}});Object.defineProperty(N,"ValueScope",{enumerable:!0,get:function(){return ws.ValueScope}});Object.defineProperty(N,"ValueScopeName",{enumerable:!0,get:function(){return ws.ValueScopeName}});Object.defineProperty(N,"varKinds",{enumerable:!0,get:function(){return ws.varKinds}});N.operators={GT:new U._Code(">"),GTE:new U._Code(">="),LT:new U._Code("<"),LTE:new U._Code("<="),EQ:new U._Code("==="),NEQ:new U._Code("!=="),NOT:new U._Code("!"),OR:new U._Code("||"),AND:new U._Code("&&"),ADD:new U._Code("+")};var $t=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},_c=class extends $t{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?st.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=Nr(this.rhs,e,r)),this}get names(){return this.rhs instanceof U._CodeOrName?this.rhs.names:{}}},Ss=class extends $t{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof U.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=Nr(this.rhs,e,r),this}get names(){let e=this.lhs instanceof U.Name?{}:{...this.lhs.names};return Es(e,this.rhs)}},yc=class extends Ss{constructor(e,r,n,o){super(e,n,o),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},Sc=class extends $t{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},vc=class extends $t{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Ec=class extends $t{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},wc=class extends $t{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=Nr(this.code,e,r),this}get names(){return this.code instanceof U._CodeOrName?this.code.names:{}}},qn=class extends $t{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(e,r)||(Zx(e,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>ur(e,r.names),{})}},Pt=class extends qn{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},bc=class extends qn{},Mr=class extends Pt{};Mr.kind="else";var ar=class t extends Pt{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Mr(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(Ig(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=Nr(this.condition,e,r),this}get names(){let e=super.names;return Es(e,this.condition),this.else&&ur(e,this.else.names),e}};ar.kind="if";var cr=class extends Pt{};cr.kind="for";var kc=class extends cr{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=Nr(this.iteration,e,r),this}get names(){return ur(super.names,this.iteration.names)}},xc=class extends cr{constructor(e,r,n,o){super(),this.varKind=e,this.name=r,this.from=n,this.to=o}render(e){let r=e.es5?st.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){let e=Es(super.names,this.from);return Es(e,this.to)}},vs=class extends cr{constructor(e,r,n,o){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=o}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=Nr(this.iterable,e,r),this}get names(){return ur(super.names,this.iterable.names)}},Hn=class extends Pt{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};Hn.kind="func";var Wn=class extends qn{render(e){return"return "+super.render(e)}};Wn.kind="return";var $c=class extends Pt{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,o;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(o=this.finally)===null||o===void 0||o.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&ur(e,this.catch.names),this.finally&&ur(e,this.finally.names),e}},Kn=class extends Pt{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};Kn.kind="catch";var Vn=class extends Pt{render(e){return"finally"+super.render(e)}};Vn.kind="finally";var Pc=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
6
|
-
`:""},this._extScope=e,this._scope=new st.Scope({parent:e}),this._nodes=[new bc]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new _c(e,s,n)),s}const(e,r,n){return this._def(st.varKinds.const,e,r,n)}let(e,r,n){return this._def(st.varKinds.let,e,r,n)}var(e,r,n){return this._def(st.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new Ss(e,r,n))}add(e,r){return this._leafNode(new yc(e,N.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==U.nil&&this._leafNode(new wc(e)),this}object(...e){let r=["{"];for(let[n,o]of e)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,U.addCodeArg)(r,o));return r.push("}"),new U._Code(r)}if(e,r,n){if(this._blockNode(new ar(e)),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(e){return this._elseNode(new ar(e))}else(){return this._elseNode(new Mr)}endIf(){return this._endBlockNode(ar,Mr)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new kc(e),r)}forRange(e,r,n,o,s=this.opts.es5?st.varKinds.var:st.varKinds.let){let i=this._scope.toName(e);return this._for(new xc(s,i,r,n),()=>o(i))}forOf(e,r,n,o=st.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let i=r instanceof U.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,U._)`${i}.length`,a=>{this.var(s,(0,U._)`${i}[${a}]`),n(s)})}return this._for(new vs("of",o,s,r),()=>n(s))}forIn(e,r,n,o=this.opts.es5?st.varKinds.var:st.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,U._)`Object.keys(${r})`,n);let s=this._scope.toName(e);return this._for(new vs("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(cr)}label(e){return this._leafNode(new Sc(e))}break(e){return this._leafNode(new vc(e))}return(e){let r=new Wn;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Wn)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new $c;if(this._blockNode(o),this.code(e),r){let s=this.name("e");this._currNode=o.catch=new Kn(s),r(s)}return n&&(this._currNode=o.finally=new Vn,this.code(n)),this._endBlockNode(Kn,Vn)}throw(e){return this._leafNode(new Ec(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){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||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=U.nil,n,o){return this._blockNode(new Hn(e,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(Hn)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof ar))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};N.CodeGen=Pc;function ur(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function Es(t,e){return e instanceof U._CodeOrName?ur(t,e.names):t}function Nr(t,e,r){if(t instanceof U.Name)return n(t);if(!o(t))return t;return new U._Code(t._items.reduce((s,i)=>(i instanceof U.Name&&(i=n(i)),i instanceof U._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||e[s.str]!==1?s:(delete e[s.str],i)}function o(s){return s instanceof U._Code&&s._items.some(i=>i instanceof U.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function Zx(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function Ig(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,U._)`!${Tc(t)}`}N.not=Ig;var qx=Cg(N.operators.AND);function Hx(...t){return t.reduce(qx)}N.and=Hx;var Wx=Cg(N.operators.OR);function Kx(...t){return t.reduce(Wx)}N.or=Kx;function Cg(t){return(e,r)=>e===U.nil?r:r===U.nil?e:(0,U._)`${Tc(e)} ${t} ${Tc(r)}`}function Tc(t){return t instanceof U.Name?t:(0,U._)`(${t})`}});var Z=E(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.checkStrictMode=D.getErrorPath=D.Type=D.useFunc=D.setEvaluated=D.evaluatedPropsToName=D.mergeEvaluated=D.eachItem=D.unescapeJsonPointer=D.escapeJsonPointer=D.escapeFragment=D.unescapeFragment=D.schemaRefOrVal=D.schemaHasRulesButRef=D.schemaHasRules=D.checkUnknownRules=D.alwaysValidSchema=D.toHash=void 0;var G=M(),Vx=Zn();function Jx(t){let e={};for(let r of t)e[r]=!0;return e}D.toHash=Jx;function Gx(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(Ng(t,e),!Dg(e,t.self.RULES.all))}D.alwaysValidSchema=Gx;function Ng(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let o=n.RULES.keywords;for(let s in e)o[s]||Ug(t,`unknown keyword: "${s}"`)}D.checkUnknownRules=Ng;function Dg(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}D.schemaHasRules=Dg;function Bx(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}D.schemaHasRulesButRef=Bx;function Yx({topSchemaRef:t,schemaPath:e},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,G._)`${r}`}return(0,G._)`${t}${e}${(0,G.getProperty)(n)}`}D.schemaRefOrVal=Yx;function Xx(t){return Lg(decodeURIComponent(t))}D.unescapeFragment=Xx;function Qx(t){return encodeURIComponent(zc(t))}D.escapeFragment=Qx;function zc(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}D.escapeJsonPointer=zc;function Lg(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}D.unescapeJsonPointer=Lg;function e0(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}D.eachItem=e0;function Ag({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof G.Name?(s instanceof G.Name?t(o,s,i):e(o,s,i),i):s instanceof G.Name?(e(o,i,s),s):r(s,i);return a===G.Name&&!(c instanceof G.Name)?n(o,c):c}}D.mergeEvaluated={props:Ag({mergeNames:(t,e,r)=>t.if((0,G._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,G._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,G._)`${r} || {}`).code((0,G._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,G._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,G._)`${r} || {}`),Rc(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:jg}),items:Ag({mergeNames:(t,e,r)=>t.if((0,G._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,G._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,G._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,G._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function jg(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,G._)`{}`);return e!==void 0&&Rc(t,r,e),r}D.evaluatedPropsToName=jg;function Rc(t,e,r){Object.keys(r).forEach(n=>t.assign((0,G._)`${e}${(0,G.getProperty)(n)}`,!0))}D.setEvaluated=Rc;var Mg={};function t0(t,e){return t.scopeValue("func",{ref:e,code:Mg[e.code]||(Mg[e.code]=new Vx._Code(e.code))})}D.useFunc=t0;var Oc;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Oc||(D.Type=Oc={}));function r0(t,e,r){if(t instanceof G.Name){let n=e===Oc.Num;return r?n?(0,G._)`"[" + ${t} + "]"`:(0,G._)`"['" + ${t} + "']"`:n?(0,G._)`"/" + ${t}`:(0,G._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,G.getProperty)(t).toString():"/"+zc(t)}D.getErrorPath=r0;function Ug(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}D.checkStrictMode=Ug});var Tt=E(Ic=>{"use strict";Object.defineProperty(Ic,"__esModule",{value:!0});var ke=M(),n0={data:new ke.Name("data"),valCxt:new ke.Name("valCxt"),instancePath:new ke.Name("instancePath"),parentData:new ke.Name("parentData"),parentDataProperty:new ke.Name("parentDataProperty"),rootData:new ke.Name("rootData"),dynamicAnchors:new ke.Name("dynamicAnchors"),vErrors:new ke.Name("vErrors"),errors:new ke.Name("errors"),this:new ke.Name("this"),self:new ke.Name("self"),scope:new ke.Name("scope"),json:new ke.Name("json"),jsonPos:new ke.Name("jsonPos"),jsonLen:new ke.Name("jsonLen"),jsonPart:new ke.Name("jsonPart")};Ic.default=n0});var Jn=E(xe=>{"use strict";Object.defineProperty(xe,"__esModule",{value:!0});xe.extendErrors=xe.resetErrorsCount=xe.reportExtraError=xe.reportError=xe.keyword$DataError=xe.keywordError=void 0;var q=M(),bs=Z(),ze=Tt();xe.keywordError={message:({keyword:t})=>(0,q.str)`must pass "${t}" keyword validation`};xe.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,q.str)`"${t}" keyword must be ${e} ($data)`:(0,q.str)`"${t}" keyword is invalid ($data)`};function o0(t,e=xe.keywordError,r,n){let{it:o}=t,{gen:s,compositeRule:i,allErrors:a}=o,c=qg(t,e,r);n??(i||a)?Fg(s,c):Zg(o,(0,q._)`[${c}]`)}xe.reportError=o0;function s0(t,e=xe.keywordError,r){let{it:n}=t,{gen:o,compositeRule:s,allErrors:i}=n,a=qg(t,e,r);Fg(o,a),s||i||Zg(n,ze.default.vErrors)}xe.reportExtraError=s0;function i0(t,e){t.assign(ze.default.errors,e),t.if((0,q._)`${ze.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,q._)`${ze.default.vErrors}.length`,e),()=>t.assign(ze.default.vErrors,null)))}xe.resetErrorsCount=i0;function a0({gen:t,keyword:e,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",o,ze.default.errors,a=>{t.const(i,(0,q._)`${ze.default.vErrors}[${a}]`),t.if((0,q._)`${i}.instancePath === undefined`,()=>t.assign((0,q._)`${i}.instancePath`,(0,q.strConcat)(ze.default.instancePath,s.errorPath))),t.assign((0,q._)`${i}.schemaPath`,(0,q.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(t.assign((0,q._)`${i}.schema`,r),t.assign((0,q._)`${i}.data`,n))})}xe.extendErrors=a0;function Fg(t,e){let r=t.const("err",e);t.if((0,q._)`${ze.default.vErrors} === null`,()=>t.assign(ze.default.vErrors,(0,q._)`[${r}]`),(0,q._)`${ze.default.vErrors}.push(${r})`),t.code((0,q._)`${ze.default.errors}++`)}function Zg(t,e){let{gen:r,validateName:n,schemaEnv:o}=t;o.$async?r.throw((0,q._)`new ${t.ValidationError}(${e})`):(r.assign((0,q._)`${n}.errors`,e),r.return(!1))}var lr={keyword:new q.Name("keyword"),schemaPath:new q.Name("schemaPath"),params:new q.Name("params"),propertyName:new q.Name("propertyName"),message:new q.Name("message"),schema:new q.Name("schema"),parentSchema:new q.Name("parentSchema")};function qg(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,q._)`{}`:c0(t,e,r)}function c0(t,e,r={}){let{gen:n,it:o}=t,s=[u0(o,r),l0(t,r)];return d0(t,e,s),n.object(...s)}function u0({errorPath:t},{instancePath:e}){let r=e?(0,q.str)`${t}${(0,bs.getErrorPath)(e,bs.Type.Str)}`:t;return[ze.default.instancePath,(0,q.strConcat)(ze.default.instancePath,r)]}function l0({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let o=n?e:(0,q.str)`${e}/${t}`;return r&&(o=(0,q.str)`${o}${(0,bs.getErrorPath)(r,bs.Type.Str)}`),[lr.schemaPath,o]}function d0(t,{params:e,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([lr.keyword,o],[lr.params,typeof e=="function"?e(t):e||(0,q._)`{}`]),c.messages&&n.push([lr.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([lr.schema,i],[lr.parentSchema,(0,q._)`${l}${d}`],[ze.default.data,s]),u&&n.push([lr.propertyName,u])}});var Wg=E(Dr=>{"use strict";Object.defineProperty(Dr,"__esModule",{value:!0});Dr.boolOrEmptySchema=Dr.topBoolOrEmptySchema=void 0;var p0=Jn(),f0=M(),m0=Tt(),h0={message:"boolean schema is false"};function g0(t){let{gen:e,schema:r,validateName:n}=t;r===!1?Hg(t,!1):typeof r=="object"&&r.$async===!0?e.return(m0.default.data):(e.assign((0,f0._)`${n}.errors`,null),e.return(!0))}Dr.topBoolOrEmptySchema=g0;function _0(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),Hg(t)):r.var(e,!0)}Dr.boolOrEmptySchema=_0;function Hg(t,e){let{gen:r,data:n}=t,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,p0.reportError)(o,h0,void 0,e)}});var Cc=E(Lr=>{"use strict";Object.defineProperty(Lr,"__esModule",{value:!0});Lr.getRules=Lr.isJSONType=void 0;var y0=["string","number","integer","boolean","null","object","array"],S0=new Set(y0);function v0(t){return typeof t=="string"&&S0.has(t)}Lr.isJSONType=v0;function E0(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}Lr.getRules=E0});var Ac=E(Ft=>{"use strict";Object.defineProperty(Ft,"__esModule",{value:!0});Ft.shouldUseRule=Ft.shouldUseGroup=Ft.schemaHasRulesForType=void 0;function w0({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&Kg(t,n)}Ft.schemaHasRulesForType=w0;function Kg(t,e){return e.rules.some(r=>Vg(t,r))}Ft.shouldUseGroup=Kg;function Vg(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}Ft.shouldUseRule=Vg});var Gn=E($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 b0=Cc(),k0=Ac(),x0=Jn(),A=M(),Jg=Z(),jr;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(jr||($e.DataType=jr={}));function $0(t){let e=Gg(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}$e.getSchemaTypes=$0;function Gg(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(b0.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}$e.getJSONTypes=Gg;function P0(t,e){let{gen:r,data:n,opts:o}=t,s=T0(e,o.coerceTypes),i=e.length>0&&!(s.length===0&&e.length===1&&(0,k0.schemaHasRulesForType)(t,e[0]));if(i){let a=Nc(e,n,o.strictNumbers,jr.Wrong);r.if(a,()=>{s.length?O0(t,e,s):Dc(t)})}return i}$e.coerceAndCheckDataType=P0;var Bg=new Set(["string","number","integer","boolean","null"]);function T0(t,e){return e?t.filter(r=>Bg.has(r)||e==="array"&&r==="array"):[]}function O0(t,e,r){let{gen:n,data:o,opts:s}=t,i=n.let("dataType",(0,A._)`typeof ${o}`),a=n.let("coerced",(0,A._)`undefined`);s.coerceTypes==="array"&&n.if((0,A._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,A._)`${o}[0]`).assign(i,(0,A._)`typeof ${o}`).if(Nc(e,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,A._)`${a} !== undefined`);for(let u of r)(Bg.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),Dc(t),n.endIf(),n.if((0,A._)`${a} !== undefined`,()=>{n.assign(o,a),z0(t,a)});function c(u){switch(u){case"string":n.elseIf((0,A._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,A._)`"" + ${o}`).elseIf((0,A._)`${o} === null`).assign(a,(0,A._)`""`);return;case"number":n.elseIf((0,A._)`${i} == "boolean" || ${o} === null
|
|
5
|
+
"use strict";var Iv=Object.create;var li=Object.defineProperty;var Cv=Object.getOwnPropertyDescriptor;var Av=Object.getOwnPropertyNames;var Mv=Object.getPrototypeOf,Nv=Object.prototype.hasOwnProperty;var E=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},Rl=(t,e)=>{for(var r in e)li(t,r,{get:e[r],enumerable:!0})},Dv=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Av(e))!Nv.call(t,o)&&o!==r&&li(t,o,{get:()=>e[o],enumerable:!(n=Cv(e,o))||n.enumerable});return t};var we=(t,e,r)=>(r=t!=null?Iv(Mv(t)):{},Dv(e||!t||!t.__esModule?li(r,"default",{value:t,enumerable:!0}):r,t));var Cd=E((DC,Id)=>{"use strict";var HE=["||","&&",";;","|&","<(","<<<",">>",">&","<&","&",";","(",")","|","<",">"],Rd=/[\n\r\u2028\u2029]/,WE=/[\s#!"$&'():;<=>@\\^`|]/g;Id.exports=function(e){return e.map(function(r){if(r==="")return"''";if(r&&typeof r=="object"){if("op"in r&&r.op==="glob"){if(typeof r.pattern!="string")throw new TypeError("glob token requires a string `pattern`");if(Rd.test(r.pattern))throw new TypeError("glob `pattern` must not contain line terminators");return r.pattern.replace(WE,"\\$&")}if("op"in r&&typeof r.op=="string"){if(HE.indexOf(r.op)<0)throw new TypeError("invalid `op` value: "+JSON.stringify(r.op));return r.op.replace(/[\s\S]/g,"\\$&")}if("comment"in r&&typeof r.comment=="string"){if(Rd.test(r.comment))throw new TypeError("`comment` must not contain line terminators");return"#"+r.comment}throw new TypeError("unrecognized object token shape")}return/["\s\\]/.test(r)&&!/'/.test(r)?"'"+r.replace(/(['])/g,"\\$1")+"'":/["'\s]/.test(r)?'"'+r.replace(/(["\\$`!])/g,"\\$1")+'"':String(r).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}~])/g,"$1\\$2")}).join(" ")}});var Ud=E((LC,jd)=>{"use strict";var Ld="(?:"+["\\|\\|","\\&\\&",";;","\\|\\&","\\<\\(","\\<\\<\\<",">>",">\\&","<\\&","[&;()|<>]"].join("|")+")",Ad=new RegExp("^"+Ld+"$"),Md="|&;()<> \\t",VE='"((\\\\"|[^"])*?)"',KE="'((\\\\'|[^'])*?)'",JE=/^#$/,Nd="'",Dd='"',Ui="$",er="",GE=4294967296;for(Fi=0;Fi<4;Fi++)er+=(GE*Math.random()).toString(16);var Fi,BE=new RegExp("^"+er);function YE(t,e){for(var r=e.lastIndex,n=[],o;o=e.exec(t);)n[n.length]=o,e.lastIndex===o.index&&(e.lastIndex+=1);return e.lastIndex=r,n}function XE(t,e,r){var n=typeof t=="function"?t(r):t[r];return typeof n>"u"&&r!=""?n="":typeof n>"u"&&(n="$"),typeof n=="object"?e+er+JSON.stringify(n)+er:e+n}function QE(t,e,r){r||(r={});var n=r.escape||"\\",o="(\\"+n+`['"`+Md+`]|[^\\s'"`+Md+"])+",s=new RegExp(["("+Ld+")","("+o+"|"+VE+"|"+KE+")+"].join("|"),"g"),i=YE(t,s);if(i.length===0)return[];e||(e={});var a=!1;return i.map(function(c){var u=c[0];if(!u||a)return;if(Ad.test(u))return{op:u};var l=!1,d=!1,p="",m=!1,h;function y(){h+=1;var b,w,$=u.charAt(h);if($==="{"){if(h+=1,u.charAt(h)==="}")throw new Error("Bad substitution: "+u.slice(h-2,h+1));if(b=u.indexOf("}",h),b<0)throw new Error("Bad substitution: "+u.slice(h));w=u.slice(h,b),h=b}else if(/[*@#?$!_-]/.test($))w=$,h+=1;else{var x=u.slice(h);b=x.match(/[^\w\d_]/),b?(w=x.slice(0,b.index),h+=b.index-1):(w=x,h=u.length)}return XE(e,"",w)}for(h=0;h<u.length;h++){var g=u.charAt(h);if(m=m||!l&&(g==="*"||g==="?"),d)p+=g,d=!1;else if(l)g===l?l=!1:l==Nd?p+=g:g===n?(h+=1,g=u.charAt(h),g===Dd||g===n||g===Ui?p+=g:p+=n+g):g===Ui?p+=y():p+=g;else if(g===Dd||g===Nd)l=g;else{if(Ad.test(g))return{op:u};if(JE.test(g)){a=!0;var v={comment:t.slice(c.index+h+1)};return p.length?[p,v]:[v]}else g===n?d=!0:g===Ui?p+=y():p+=g}}return m?{op:"glob",pattern:p}:p}).reduce(function(c,u){return typeof u>"u"||[].concat(u).forEach(function(l){c[c.length]=l}),c},[])}jd.exports=function(e,r,n){var o=QE(e,r,n);return typeof r!="function"?o:o.reduce(function(s,i){if(typeof i=="object")return s[s.length]=i,s;var a=i.split(RegExp("("+er+".*?"+er+")","g"));return a.length===1?(s[s.length]=a[0],s):(a.filter(Boolean).forEach(function(c){s[s.length]=BE.test(c)?JSON.parse(c.split(er)[1]):c}),s)},[])}});var Fd=E(Zi=>{"use strict";Zi.quote=Cd();Zi.parse=Ud()});var Zn=E(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});H.regexpCode=H.getEsmExportName=H.getProperty=H.safeStringify=H.stringify=H.strConcat=H.addCodeArg=H.str=H._=H.nil=H._Code=H.Name=H.IDENTIFIER=H._CodeOrName=void 0;var Un=class{};H._CodeOrName=Un;H.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var ir=class extends Un{constructor(e){if(super(),!H.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};H.Name=ir;var Ye=class extends Un{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof ir&&(r[n.str]=(r[n.str]||0)+1),r),{})}};H._Code=Ye;H.nil=new Ye("");function zg(t,...e){let r=[t[0]],n=0;for(;n<e.length;)fc(r,e[n]),r.push(t[++n]);return new Ye(r)}H._=zg;var pc=new Ye("+");function Rg(t,...e){let r=[Fn(t[0])],n=0;for(;n<e.length;)r.push(pc),fc(r,e[n]),r.push(pc,Fn(t[++n]));return Cx(r),new Ye(r)}H.str=Rg;function fc(t,e){e instanceof Ye?t.push(...e._items):e instanceof ir?t.push(e):t.push(Nx(e))}H.addCodeArg=fc;function Cx(t){let e=1;for(;e<t.length-1;){if(t[e]===pc){let r=Ax(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function Ax(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof ir||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof ir))return`"${t}${e.slice(1)}`}function Mx(t,e){return e.emptyStr()?t:t.emptyStr()?e:Rg`${t}${e}`}H.strConcat=Mx;function Nx(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:Fn(Array.isArray(t)?t.join(","):t)}function Dx(t){return new Ye(Fn(t))}H.stringify=Dx;function Fn(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}H.safeStringify=Fn;function Lx(t){return typeof t=="string"&&H.IDENTIFIER.test(t)?new Ye(`.${t}`):zg`[${t}]`}H.getProperty=Lx;function jx(t){if(typeof t=="string"&&H.IDENTIFIER.test(t))return new Ye(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}H.getEsmExportName=jx;function Ux(t){return new Ye(t.toString())}H.regexpCode=Ux});var gc=E(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});Ne.ValueScope=Ne.ValueScopeName=Ne.Scope=Ne.varKinds=Ne.UsedValueState=void 0;var Me=Zn(),mc=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},gs;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(gs||(Ne.UsedValueState=gs={}));Ne.varKinds={const:new Me.Name("const"),let:new Me.Name("let"),var:new Me.Name("var")};var _s=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof Me.Name?e:this.name(e)}name(e){return new Me.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Ne.Scope=_s;var ys=class extends Me.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,Me._)`.${new Me.Name(r)}[${n}]`}};Ne.ValueScopeName=ys;var Fx=(0,Me._)`\n`,hc=class extends _s{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?Fx:Me.nil}}get(){return this._scope}name(e){return new ys(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(e),{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(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Me._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(e,r,n={},o){let s=Me.nil;for(let i in e){let a=e[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,gs.Started);let l=r(u);if(l){let d=this.opts.es5?Ne.varKinds.var:Ne.varKinds.const;s=(0,Me._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,Me._)`${s}${l}${this.opts._n}`;else throw new mc(u);c.set(u,gs.Completed)})}return s}};Ne.ValueScope=hc});var M=E(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.or=N.and=N.not=N.CodeGen=N.operators=N.varKinds=N.ValueScopeName=N.ValueScope=N.Scope=N.Name=N.regexpCode=N.stringify=N.getProperty=N.nil=N.strConcat=N.str=N._=void 0;var U=Zn(),st=gc(),Ut=Zn();Object.defineProperty(N,"_",{enumerable:!0,get:function(){return Ut._}});Object.defineProperty(N,"str",{enumerable:!0,get:function(){return Ut.str}});Object.defineProperty(N,"strConcat",{enumerable:!0,get:function(){return Ut.strConcat}});Object.defineProperty(N,"nil",{enumerable:!0,get:function(){return Ut.nil}});Object.defineProperty(N,"getProperty",{enumerable:!0,get:function(){return Ut.getProperty}});Object.defineProperty(N,"stringify",{enumerable:!0,get:function(){return Ut.stringify}});Object.defineProperty(N,"regexpCode",{enumerable:!0,get:function(){return Ut.regexpCode}});Object.defineProperty(N,"Name",{enumerable:!0,get:function(){return Ut.Name}});var ws=gc();Object.defineProperty(N,"Scope",{enumerable:!0,get:function(){return ws.Scope}});Object.defineProperty(N,"ValueScope",{enumerable:!0,get:function(){return ws.ValueScope}});Object.defineProperty(N,"ValueScopeName",{enumerable:!0,get:function(){return ws.ValueScopeName}});Object.defineProperty(N,"varKinds",{enumerable:!0,get:function(){return ws.varKinds}});N.operators={GT:new U._Code(">"),GTE:new U._Code(">="),LT:new U._Code("<"),LTE:new U._Code("<="),EQ:new U._Code("==="),NEQ:new U._Code("!=="),NOT:new U._Code("!"),OR:new U._Code("||"),AND:new U._Code("&&"),ADD:new U._Code("+")};var $t=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},_c=class extends $t{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?st.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=Nr(this.rhs,e,r)),this}get names(){return this.rhs instanceof U._CodeOrName?this.rhs.names:{}}},Ss=class extends $t{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof U.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=Nr(this.rhs,e,r),this}get names(){let e=this.lhs instanceof U.Name?{}:{...this.lhs.names};return Es(e,this.rhs)}},yc=class extends Ss{constructor(e,r,n,o){super(e,n,o),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},Sc=class extends $t{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},vc=class extends $t{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Ec=class extends $t{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},wc=class extends $t{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=Nr(this.code,e,r),this}get names(){return this.code instanceof U._CodeOrName?this.code.names:{}}},qn=class extends $t{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(e,r)||(Zx(e,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>ur(e,r.names),{})}},Pt=class extends qn{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},bc=class extends qn{},Mr=class extends Pt{};Mr.kind="else";var ar=class t extends Pt{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Mr(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(Ig(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=Nr(this.condition,e,r),this}get names(){let e=super.names;return Es(e,this.condition),this.else&&ur(e,this.else.names),e}};ar.kind="if";var cr=class extends Pt{};cr.kind="for";var kc=class extends cr{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=Nr(this.iteration,e,r),this}get names(){return ur(super.names,this.iteration.names)}},xc=class extends cr{constructor(e,r,n,o){super(),this.varKind=e,this.name=r,this.from=n,this.to=o}render(e){let r=e.es5?st.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){let e=Es(super.names,this.from);return Es(e,this.to)}},vs=class extends cr{constructor(e,r,n,o){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=o}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=Nr(this.iterable,e,r),this}get names(){return ur(super.names,this.iterable.names)}},Hn=class extends Pt{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};Hn.kind="func";var Wn=class extends qn{render(e){return"return "+super.render(e)}};Wn.kind="return";var $c=class extends Pt{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,o;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(o=this.finally)===null||o===void 0||o.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&ur(e,this.catch.names),this.finally&&ur(e,this.finally.names),e}},Vn=class extends Pt{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};Vn.kind="catch";var Kn=class extends Pt{render(e){return"finally"+super.render(e)}};Kn.kind="finally";var Pc=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
6
|
+
`:""},this._extScope=e,this._scope=new st.Scope({parent:e}),this._nodes=[new bc]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new _c(e,s,n)),s}const(e,r,n){return this._def(st.varKinds.const,e,r,n)}let(e,r,n){return this._def(st.varKinds.let,e,r,n)}var(e,r,n){return this._def(st.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new Ss(e,r,n))}add(e,r){return this._leafNode(new yc(e,N.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==U.nil&&this._leafNode(new wc(e)),this}object(...e){let r=["{"];for(let[n,o]of e)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,U.addCodeArg)(r,o));return r.push("}"),new U._Code(r)}if(e,r,n){if(this._blockNode(new ar(e)),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(e){return this._elseNode(new ar(e))}else(){return this._elseNode(new Mr)}endIf(){return this._endBlockNode(ar,Mr)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new kc(e),r)}forRange(e,r,n,o,s=this.opts.es5?st.varKinds.var:st.varKinds.let){let i=this._scope.toName(e);return this._for(new xc(s,i,r,n),()=>o(i))}forOf(e,r,n,o=st.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let i=r instanceof U.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,U._)`${i}.length`,a=>{this.var(s,(0,U._)`${i}[${a}]`),n(s)})}return this._for(new vs("of",o,s,r),()=>n(s))}forIn(e,r,n,o=this.opts.es5?st.varKinds.var:st.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,U._)`Object.keys(${r})`,n);let s=this._scope.toName(e);return this._for(new vs("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(cr)}label(e){return this._leafNode(new Sc(e))}break(e){return this._leafNode(new vc(e))}return(e){let r=new Wn;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Wn)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new $c;if(this._blockNode(o),this.code(e),r){let s=this.name("e");this._currNode=o.catch=new Vn(s),r(s)}return n&&(this._currNode=o.finally=new Kn,this.code(n)),this._endBlockNode(Vn,Kn)}throw(e){return this._leafNode(new Ec(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){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||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=U.nil,n,o){return this._blockNode(new Hn(e,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(Hn)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof ar))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};N.CodeGen=Pc;function ur(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function Es(t,e){return e instanceof U._CodeOrName?ur(t,e.names):t}function Nr(t,e,r){if(t instanceof U.Name)return n(t);if(!o(t))return t;return new U._Code(t._items.reduce((s,i)=>(i instanceof U.Name&&(i=n(i)),i instanceof U._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||e[s.str]!==1?s:(delete e[s.str],i)}function o(s){return s instanceof U._Code&&s._items.some(i=>i instanceof U.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function Zx(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function Ig(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,U._)`!${Tc(t)}`}N.not=Ig;var qx=Cg(N.operators.AND);function Hx(...t){return t.reduce(qx)}N.and=Hx;var Wx=Cg(N.operators.OR);function Vx(...t){return t.reduce(Wx)}N.or=Vx;function Cg(t){return(e,r)=>e===U.nil?r:r===U.nil?e:(0,U._)`${Tc(e)} ${t} ${Tc(r)}`}function Tc(t){return t instanceof U.Name?t:(0,U._)`(${t})`}});var Z=E(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.checkStrictMode=D.getErrorPath=D.Type=D.useFunc=D.setEvaluated=D.evaluatedPropsToName=D.mergeEvaluated=D.eachItem=D.unescapeJsonPointer=D.escapeJsonPointer=D.escapeFragment=D.unescapeFragment=D.schemaRefOrVal=D.schemaHasRulesButRef=D.schemaHasRules=D.checkUnknownRules=D.alwaysValidSchema=D.toHash=void 0;var G=M(),Kx=Zn();function Jx(t){let e={};for(let r of t)e[r]=!0;return e}D.toHash=Jx;function Gx(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(Ng(t,e),!Dg(e,t.self.RULES.all))}D.alwaysValidSchema=Gx;function Ng(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let o=n.RULES.keywords;for(let s in e)o[s]||Ug(t,`unknown keyword: "${s}"`)}D.checkUnknownRules=Ng;function Dg(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}D.schemaHasRules=Dg;function Bx(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}D.schemaHasRulesButRef=Bx;function Yx({topSchemaRef:t,schemaPath:e},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,G._)`${r}`}return(0,G._)`${t}${e}${(0,G.getProperty)(n)}`}D.schemaRefOrVal=Yx;function Xx(t){return Lg(decodeURIComponent(t))}D.unescapeFragment=Xx;function Qx(t){return encodeURIComponent(zc(t))}D.escapeFragment=Qx;function zc(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}D.escapeJsonPointer=zc;function Lg(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}D.unescapeJsonPointer=Lg;function e0(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}D.eachItem=e0;function Ag({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof G.Name?(s instanceof G.Name?t(o,s,i):e(o,s,i),i):s instanceof G.Name?(e(o,i,s),s):r(s,i);return a===G.Name&&!(c instanceof G.Name)?n(o,c):c}}D.mergeEvaluated={props:Ag({mergeNames:(t,e,r)=>t.if((0,G._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,G._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,G._)`${r} || {}`).code((0,G._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,G._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,G._)`${r} || {}`),Rc(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:jg}),items:Ag({mergeNames:(t,e,r)=>t.if((0,G._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,G._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,G._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,G._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function jg(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,G._)`{}`);return e!==void 0&&Rc(t,r,e),r}D.evaluatedPropsToName=jg;function Rc(t,e,r){Object.keys(r).forEach(n=>t.assign((0,G._)`${e}${(0,G.getProperty)(n)}`,!0))}D.setEvaluated=Rc;var Mg={};function t0(t,e){return t.scopeValue("func",{ref:e,code:Mg[e.code]||(Mg[e.code]=new Kx._Code(e.code))})}D.useFunc=t0;var Oc;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Oc||(D.Type=Oc={}));function r0(t,e,r){if(t instanceof G.Name){let n=e===Oc.Num;return r?n?(0,G._)`"[" + ${t} + "]"`:(0,G._)`"['" + ${t} + "']"`:n?(0,G._)`"/" + ${t}`:(0,G._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,G.getProperty)(t).toString():"/"+zc(t)}D.getErrorPath=r0;function Ug(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}D.checkStrictMode=Ug});var Tt=E(Ic=>{"use strict";Object.defineProperty(Ic,"__esModule",{value:!0});var ke=M(),n0={data:new ke.Name("data"),valCxt:new ke.Name("valCxt"),instancePath:new ke.Name("instancePath"),parentData:new ke.Name("parentData"),parentDataProperty:new ke.Name("parentDataProperty"),rootData:new ke.Name("rootData"),dynamicAnchors:new ke.Name("dynamicAnchors"),vErrors:new ke.Name("vErrors"),errors:new ke.Name("errors"),this:new ke.Name("this"),self:new ke.Name("self"),scope:new ke.Name("scope"),json:new ke.Name("json"),jsonPos:new ke.Name("jsonPos"),jsonLen:new ke.Name("jsonLen"),jsonPart:new ke.Name("jsonPart")};Ic.default=n0});var Jn=E(xe=>{"use strict";Object.defineProperty(xe,"__esModule",{value:!0});xe.extendErrors=xe.resetErrorsCount=xe.reportExtraError=xe.reportError=xe.keyword$DataError=xe.keywordError=void 0;var q=M(),bs=Z(),ze=Tt();xe.keywordError={message:({keyword:t})=>(0,q.str)`must pass "${t}" keyword validation`};xe.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,q.str)`"${t}" keyword must be ${e} ($data)`:(0,q.str)`"${t}" keyword is invalid ($data)`};function o0(t,e=xe.keywordError,r,n){let{it:o}=t,{gen:s,compositeRule:i,allErrors:a}=o,c=qg(t,e,r);n??(i||a)?Fg(s,c):Zg(o,(0,q._)`[${c}]`)}xe.reportError=o0;function s0(t,e=xe.keywordError,r){let{it:n}=t,{gen:o,compositeRule:s,allErrors:i}=n,a=qg(t,e,r);Fg(o,a),s||i||Zg(n,ze.default.vErrors)}xe.reportExtraError=s0;function i0(t,e){t.assign(ze.default.errors,e),t.if((0,q._)`${ze.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,q._)`${ze.default.vErrors}.length`,e),()=>t.assign(ze.default.vErrors,null)))}xe.resetErrorsCount=i0;function a0({gen:t,keyword:e,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",o,ze.default.errors,a=>{t.const(i,(0,q._)`${ze.default.vErrors}[${a}]`),t.if((0,q._)`${i}.instancePath === undefined`,()=>t.assign((0,q._)`${i}.instancePath`,(0,q.strConcat)(ze.default.instancePath,s.errorPath))),t.assign((0,q._)`${i}.schemaPath`,(0,q.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(t.assign((0,q._)`${i}.schema`,r),t.assign((0,q._)`${i}.data`,n))})}xe.extendErrors=a0;function Fg(t,e){let r=t.const("err",e);t.if((0,q._)`${ze.default.vErrors} === null`,()=>t.assign(ze.default.vErrors,(0,q._)`[${r}]`),(0,q._)`${ze.default.vErrors}.push(${r})`),t.code((0,q._)`${ze.default.errors}++`)}function Zg(t,e){let{gen:r,validateName:n,schemaEnv:o}=t;o.$async?r.throw((0,q._)`new ${t.ValidationError}(${e})`):(r.assign((0,q._)`${n}.errors`,e),r.return(!1))}var lr={keyword:new q.Name("keyword"),schemaPath:new q.Name("schemaPath"),params:new q.Name("params"),propertyName:new q.Name("propertyName"),message:new q.Name("message"),schema:new q.Name("schema"),parentSchema:new q.Name("parentSchema")};function qg(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,q._)`{}`:c0(t,e,r)}function c0(t,e,r={}){let{gen:n,it:o}=t,s=[u0(o,r),l0(t,r)];return d0(t,e,s),n.object(...s)}function u0({errorPath:t},{instancePath:e}){let r=e?(0,q.str)`${t}${(0,bs.getErrorPath)(e,bs.Type.Str)}`:t;return[ze.default.instancePath,(0,q.strConcat)(ze.default.instancePath,r)]}function l0({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let o=n?e:(0,q.str)`${e}/${t}`;return r&&(o=(0,q.str)`${o}${(0,bs.getErrorPath)(r,bs.Type.Str)}`),[lr.schemaPath,o]}function d0(t,{params:e,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([lr.keyword,o],[lr.params,typeof e=="function"?e(t):e||(0,q._)`{}`]),c.messages&&n.push([lr.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([lr.schema,i],[lr.parentSchema,(0,q._)`${l}${d}`],[ze.default.data,s]),u&&n.push([lr.propertyName,u])}});var Wg=E(Dr=>{"use strict";Object.defineProperty(Dr,"__esModule",{value:!0});Dr.boolOrEmptySchema=Dr.topBoolOrEmptySchema=void 0;var p0=Jn(),f0=M(),m0=Tt(),h0={message:"boolean schema is false"};function g0(t){let{gen:e,schema:r,validateName:n}=t;r===!1?Hg(t,!1):typeof r=="object"&&r.$async===!0?e.return(m0.default.data):(e.assign((0,f0._)`${n}.errors`,null),e.return(!0))}Dr.topBoolOrEmptySchema=g0;function _0(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),Hg(t)):r.var(e,!0)}Dr.boolOrEmptySchema=_0;function Hg(t,e){let{gen:r,data:n}=t,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,p0.reportError)(o,h0,void 0,e)}});var Cc=E(Lr=>{"use strict";Object.defineProperty(Lr,"__esModule",{value:!0});Lr.getRules=Lr.isJSONType=void 0;var y0=["string","number","integer","boolean","null","object","array"],S0=new Set(y0);function v0(t){return typeof t=="string"&&S0.has(t)}Lr.isJSONType=v0;function E0(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}Lr.getRules=E0});var Ac=E(Ft=>{"use strict";Object.defineProperty(Ft,"__esModule",{value:!0});Ft.shouldUseRule=Ft.shouldUseGroup=Ft.schemaHasRulesForType=void 0;function w0({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&Vg(t,n)}Ft.schemaHasRulesForType=w0;function Vg(t,e){return e.rules.some(r=>Kg(t,r))}Ft.shouldUseGroup=Vg;function Kg(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}Ft.shouldUseRule=Kg});var Gn=E($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 b0=Cc(),k0=Ac(),x0=Jn(),A=M(),Jg=Z(),jr;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(jr||($e.DataType=jr={}));function $0(t){let e=Gg(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}$e.getSchemaTypes=$0;function Gg(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(b0.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}$e.getJSONTypes=Gg;function P0(t,e){let{gen:r,data:n,opts:o}=t,s=T0(e,o.coerceTypes),i=e.length>0&&!(s.length===0&&e.length===1&&(0,k0.schemaHasRulesForType)(t,e[0]));if(i){let a=Nc(e,n,o.strictNumbers,jr.Wrong);r.if(a,()=>{s.length?O0(t,e,s):Dc(t)})}return i}$e.coerceAndCheckDataType=P0;var Bg=new Set(["string","number","integer","boolean","null"]);function T0(t,e){return e?t.filter(r=>Bg.has(r)||e==="array"&&r==="array"):[]}function O0(t,e,r){let{gen:n,data:o,opts:s}=t,i=n.let("dataType",(0,A._)`typeof ${o}`),a=n.let("coerced",(0,A._)`undefined`);s.coerceTypes==="array"&&n.if((0,A._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,A._)`${o}[0]`).assign(i,(0,A._)`typeof ${o}`).if(Nc(e,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,A._)`${a} !== undefined`);for(let u of r)(Bg.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),Dc(t),n.endIf(),n.if((0,A._)`${a} !== undefined`,()=>{n.assign(o,a),z0(t,a)});function c(u){switch(u){case"string":n.elseIf((0,A._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,A._)`"" + ${o}`).elseIf((0,A._)`${o} === null`).assign(a,(0,A._)`""`);return;case"number":n.elseIf((0,A._)`${i} == "boolean" || ${o} === null
|
|
7
7
|
|| (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,A._)`+${o}`);return;case"integer":n.elseIf((0,A._)`${i} === "boolean" || ${o} === null
|
|
8
8
|
|| (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,A._)`+${o}`);return;case"boolean":n.elseIf((0,A._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf((0,A._)`${o} === "true" || ${o} === 1`).assign(a,!0);return;case"null":n.elseIf((0,A._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(a,null);return;case"array":n.elseIf((0,A._)`${i} === "string" || ${i} === "number"
|
|
9
|
-
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,A._)`[${o}]`)}}}function z0({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,A._)`${e} !== undefined`,()=>t.assign((0,A._)`${e}[${r}]`,n))}function Mc(t,e,r,n=jr.Correct){let o=n===jr.Correct?A.operators.EQ:A.operators.NEQ,s;switch(t){case"null":return(0,A._)`${e} ${o} null`;case"array":s=(0,A._)`Array.isArray(${e})`;break;case"object":s=(0,A._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":s=i((0,A._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":s=i();break;default:return(0,A._)`typeof ${e} ${o} ${t}`}return n===jr.Correct?s:(0,A.not)(s);function i(a=A.nil){return(0,A.and)((0,A._)`typeof ${e} == "number"`,a,r?(0,A._)`isFinite(${e})`:A.nil)}}$e.checkDataType=Mc;function Nc(t,e,r,n){if(t.length===1)return Mc(t[0],e,r,n);let o,s=(0,Jg.toHash)(t);if(s.array&&s.object){let i=(0,A._)`typeof ${e} != "object"`;o=s.null?i:(0,A._)`!${e} || ${i}`,delete s.null,delete s.array,delete s.object}else o=A.nil;s.number&&delete s.integer;for(let i in s)o=(0,A.and)(o,Mc(i,e,r,n));return o}$e.checkDataTypes=Nc;var R0={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,A._)`{type: ${t}}`:(0,A._)`{type: ${e}}`};function Dc(t){let e=I0(t);(0,x0.reportError)(e,R0)}$e.reportTypeError=Dc;function I0(t){let{gen:e,data:r,schema:n}=t,o=(0,Jg.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:t}}});var Xg=E(ks=>{"use strict";Object.defineProperty(ks,"__esModule",{value:!0});ks.assignDefaults=void 0;var Ur=M(),C0=Z();function A0(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let o in r)Yg(t,o,r[o].default);else e==="array"&&Array.isArray(n)&&n.forEach((o,s)=>Yg(t,s,o.default))}ks.assignDefaults=A0;function Yg(t,e,r){let{gen:n,compositeRule:o,data:s,opts:i}=t;if(r===void 0)return;let a=(0,Ur._)`${s}${(0,Ur.getProperty)(e)}`;if(o){(0,C0.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,Ur._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,Ur._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Ur._)`${a} = ${(0,Ur.stringify)(r)}`)}});var Xe=E(J=>{"use strict";Object.defineProperty(J,"__esModule",{value:!0});J.validateUnion=J.validateArray=J.usePattern=J.callValidateCode=J.schemaProperties=J.allSchemaProperties=J.noPropertyInData=J.propertyInData=J.isOwnProperty=J.hasPropFunc=J.reportMissingProp=J.checkMissingProp=J.checkReportMissingProp=void 0;var te=M(),Lc=Z(),Zt=Tt(),M0=Z();function N0(t,e){let{gen:r,data:n,it:o}=t;r.if(Uc(r,n,e,o.opts.ownProperties),()=>{t.setParams({missingProperty:(0,te._)`${e}`},!0),t.error()})}J.checkReportMissingProp=N0;function D0({gen:t,data:e,it:{opts:r}},n,o){return(0,te.or)(...n.map(s=>(0,te.and)(Uc(t,e,s,r.ownProperties),(0,te._)`${o} = ${s}`)))}J.checkMissingProp=D0;function L0(t,e){t.setParams({missingProperty:e},!0),t.error()}J.reportMissingProp=L0;function Qg(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,te._)`Object.prototype.hasOwnProperty`})}J.hasPropFunc=Qg;function jc(t,e,r){return(0,te._)`${Qg(t)}.call(${e}, ${r})`}J.isOwnProperty=jc;function j0(t,e,r,n){let o=(0,te._)`${e}${(0,te.getProperty)(r)} !== undefined`;return n?(0,te._)`${o} && ${jc(t,e,r)}`:o}J.propertyInData=j0;function Uc(t,e,r,n){let o=(0,te._)`${e}${(0,te.getProperty)(r)} === undefined`;return n?(0,te.or)(o,(0,te.not)(jc(t,e,r))):o}J.noPropertyInData=Uc;function e_(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}J.allSchemaProperties=e_;function U0(t,e){return e_(e).filter(r=>!(0,Lc.alwaysValidSchema)(t,e[r]))}J.schemaProperties=U0;function F0({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,te._)`${t}, ${e}, ${n}${o}`:e,d=[[Zt.default.instancePath,(0,te.strConcat)(Zt.default.instancePath,s)],[Zt.default.parentData,i.parentData],[Zt.default.parentDataProperty,i.parentDataProperty],[Zt.default.rootData,Zt.default.rootData]];i.opts.dynamicRef&&d.push([Zt.default.dynamicAnchors,Zt.default.dynamicAnchors]);let p=(0,te._)`${l}, ${r.object(...d)}`;return c!==te.nil?(0,te._)`${a}.call(${c}, ${p})`:(0,te._)`${a}(${p})`}J.callValidateCode=F0;var Z0=(0,te._)`new RegExp`;function q0({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:o}=e.code,s=o(r,n);return t.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,te._)`${o.code==="new RegExp"?Z0:(0,M0.useFunc)(t,o)}(${r}, ${n})`})}J.usePattern=q0;function H0(t){let{gen:e,data:r,keyword:n,it:o}=t,s=e.name("valid");if(o.allErrors){let a=e.let("valid",!0);return i(()=>e.assign(a,!1)),a}return e.var(s,!0),i(()=>e.break()),s;function i(a){let c=e.const("len",(0,te._)`${r}.length`);e.forRange("i",0,c,u=>{t.subschema({keyword:n,dataProp:u,dataPropType:Lc.Type.Num},s),e.if((0,te.not)(s),a)})}}J.validateArray=H0;function W0(t){let{gen:e,schema:r,keyword:n,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,Lc.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,u)=>{let l=t.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);e.assign(i,(0,te._)`${i} || ${a}`),t.mergeValidEvaluated(l,a)||e.if((0,te.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}J.validateUnion=W0});var n_=E(ht=>{"use strict";Object.defineProperty(ht,"__esModule",{value:!0});ht.validateKeywordUsage=ht.validSchemaType=ht.funcKeywordCode=ht.macroKeywordCode=void 0;var Re=M(),dr=Tt(),K0=Xe(),V0=Jn();function J0(t,e){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=t,a=e.macro.call(i.self,o,s,i),c=r_(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");t.subschema({schema:a,schemaPath:Re.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}ht.macroKeywordCode=J0;function G0(t,e){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=t;Y0(c,e);let u=!a&&e.compile?e.compile.call(c.self,s,i,c):e.validate,l=r_(n,o,u),d=n.let("valid");t.block$data(d,p),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function p(){if(e.errors===!1)y(),e.modifying&&t_(t),g(()=>t.error());else{let v=e.async?m():h();e.modifying&&t_(t),g(()=>B0(t,v))}}function m(){let v=n.let("ruleErrs",null);return n.try(()=>y((0,Re._)`await `),b=>n.assign(d,!1).if((0,Re._)`${b} instanceof ${c.ValidationError}`,()=>n.assign(v,(0,Re._)`${b}.errors`),()=>n.throw(b))),v}function h(){let v=(0,Re._)`${l}.errors`;return n.assign(v,null),y(Re.nil),v}function y(v=e.async?(0,Re._)`await `:Re.nil){let b=c.opts.passContext?dr.default.this:dr.default.self,w=!("compile"in e&&!a||e.schema===!1);n.assign(d,(0,Re._)`${v}${(0,K0.callValidateCode)(t,l,b,w)}`,e.modifying)}function g(v){var b;n.if((0,Re.not)((b=e.valid)!==null&&b!==void 0?b:d),v)}}ht.funcKeywordCode=G0;function t_(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,Re._)`${n.parentData}[${n.parentDataProperty}]`))}function B0(t,e){let{gen:r}=t;r.if((0,Re._)`Array.isArray(${e})`,()=>{r.assign(dr.default.vErrors,(0,Re._)`${dr.default.vErrors} === null ? ${e} : ${dr.default.vErrors}.concat(${e})`).assign(dr.default.errors,(0,Re._)`${dr.default.vErrors}.length`),(0,V0.extendErrors)(t)},()=>t.error())}function Y0({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function r_(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Re.stringify)(r)})}function X0(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}ht.validSchemaType=X0;function Q0({schema:t,opts:e,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(t,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(t[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}ht.validateKeywordUsage=Q0});var s_=E(qt=>{"use strict";Object.defineProperty(qt,"__esModule",{value:!0});qt.extendSubschemaMode=qt.extendSubschemaData=qt.getSubschema=void 0;var gt=M(),o_=Z();function e$(t,{keyword:e,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,gt._)`${t.schemaPath}${(0,gt.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,gt._)`${t.schemaPath}${(0,gt.getProperty)(e)}${(0,gt.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,o_.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')}qt.getSubschema=e$;function t$(t,e,{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}=e;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=e,p=a.let("data",(0,gt._)`${e.data}${(0,gt.getProperty)(r)}`,!0);c(p),t.errorPath=(0,gt.str)`${u}${(0,o_.getErrorPath)(r,n,d.jsPropertySyntax)}`,t.parentDataProperty=(0,gt._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(o!==void 0){let u=o instanceof gt.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(t.propertyName=i)}s&&(t.dataTypes=s);function c(u){t.data=u,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,u]}}qt.extendSubschemaData=t$;function r$(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(t.compositeRule=n),o!==void 0&&(t.createErrors=o),s!==void 0&&(t.allErrors=s),t.jtdDiscriminator=e,t.jtdMetadata=r}qt.extendSubschemaMode=r$});var Fc=E((M1,i_)=>{"use strict";i_.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!t(e[o],r[o]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(s=Object.keys(e),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(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r}});var c_=E((N1,a_)=>{"use strict";var Ht=a_.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};xs(e,n,o,t,"",t)};Ht.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Ht.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Ht.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Ht.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 xs(t,e,r,n,o,s,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,o,s,i,a,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in Ht.arrayKeywords)for(var p=0;p<d.length;p++)xs(t,e,r,d[p],o+"/"+l+"/"+p,s,o,l,n,p)}else if(l in Ht.propsKeywords){if(d&&typeof d=="object")for(var m in d)xs(t,e,r,d[m],o+"/"+l+"/"+n$(m),s,o,l,n,m)}else(l in Ht.keywords||t.allKeys&&!(l in Ht.skipKeywords))&&xs(t,e,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function n$(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var Bn=E(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});De.getSchemaRefs=De.resolveUrl=De.normalizeId=De._getFullPath=De.getFullPath=De.inlineRef=void 0;var o$=Z(),s$=Fc(),i$=c_(),a$=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function c$(t,e=!0){return typeof t=="boolean"?!0:e===!0?!Zc(t):e?u_(t)<=e:!1}De.inlineRef=c$;var u$=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Zc(t){for(let e in t){if(u$.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(Zc)||typeof r=="object"&&Zc(r))return!0}return!1}function u_(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!a$.has(r)&&(typeof t[r]=="object"&&(0,o$.eachItem)(t[r],n=>e+=u_(n)),e===1/0))return 1/0}return e}function l_(t,e="",r){r!==!1&&(e=Fr(e));let n=t.parse(e);return d_(t,n)}De.getFullPath=l_;function d_(t,e){return t.serialize(e).split("#")[0]+"#"}De._getFullPath=d_;var l$=/#\/?$/;function Fr(t){return t?t.replace(l$,""):""}De.normalizeId=Fr;function d$(t,e,r){return r=Fr(r),t.resolve(e,r)}De.resolveUrl=d$;var p$=/^[a-z_][-a-z0-9._]*$/i;function f$(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=Fr(t[r]||e),s={"":o},i=l_(n,o,!1),a={},c=new Set;return i$(t,{allKeys:!0},(d,p,m,h)=>{if(h===void 0)return;let y=i+p,g=s[h];typeof d[r]=="string"&&(g=v.call(this,d[r])),b.call(this,d.$anchor),b.call(this,d.$dynamicAnchor),s[p]=g;function v(w){let $=this.opts.uriResolver.resolve;if(w=Fr(g?$(g,w):w),c.has(w))throw l(w);c.add(w);let x=this.refs[w];return typeof x=="string"&&(x=this.refs[x]),typeof x=="object"?u(d,x.schema,w):w!==Fr(y)&&(w[0]==="#"?(u(d,a[w],w),a[w]=d):this.refs[w]=y),w}function b(w){if(typeof w=="string"){if(!p$.test(w))throw new Error(`invalid anchor "${w}"`);v.call(this,`#${w}`)}}}),a;function u(d,p,m){if(p!==void 0&&!s$(d,p))throw l(m)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}De.getSchemaRefs=f$});var Qn=E(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});Wt.getData=Wt.KeywordCxt=Wt.validateFunctionCode=void 0;var g_=Wg(),p_=Gn(),Hc=Ac(),$s=Gn(),m$=Xg(),Xn=n_(),qc=s_(),T=M(),I=Tt(),h$=Bn(),Ot=Z(),Yn=Jn();function g$(t){if(S_(t)&&(v_(t),y_(t))){S$(t);return}__(t,()=>(0,g_.topBoolOrEmptySchema)(t))}Wt.validateFunctionCode=g$;function __({gen:t,validateName:e,schema:r,schemaEnv:n,opts:o},s){o.code.es5?t.func(e,(0,T._)`${I.default.data}, ${I.default.valCxt}`,n.$async,()=>{t.code((0,T._)`"use strict"; ${f_(r,o)}`),y$(t,o),t.code(s)}):t.func(e,(0,T._)`${I.default.data}, ${_$(o)}`,n.$async,()=>t.code(f_(r,o)).code(s))}function _$(t){return(0,T._)`{${I.default.instancePath}="", ${I.default.parentData}, ${I.default.parentDataProperty}, ${I.default.rootData}=${I.default.data}${t.dynamicRef?(0,T._)`, ${I.default.dynamicAnchors}={}`:T.nil}}={}`}function y$(t,e){t.if(I.default.valCxt,()=>{t.var(I.default.instancePath,(0,T._)`${I.default.valCxt}.${I.default.instancePath}`),t.var(I.default.parentData,(0,T._)`${I.default.valCxt}.${I.default.parentData}`),t.var(I.default.parentDataProperty,(0,T._)`${I.default.valCxt}.${I.default.parentDataProperty}`),t.var(I.default.rootData,(0,T._)`${I.default.valCxt}.${I.default.rootData}`),e.dynamicRef&&t.var(I.default.dynamicAnchors,(0,T._)`${I.default.valCxt}.${I.default.dynamicAnchors}`)},()=>{t.var(I.default.instancePath,(0,T._)`""`),t.var(I.default.parentData,(0,T._)`undefined`),t.var(I.default.parentDataProperty,(0,T._)`undefined`),t.var(I.default.rootData,I.default.data),e.dynamicRef&&t.var(I.default.dynamicAnchors,(0,T._)`{}`)})}function S$(t){let{schema:e,opts:r,gen:n}=t;__(t,()=>{r.$comment&&e.$comment&&w_(t),k$(t),n.let(I.default.vErrors,null),n.let(I.default.errors,0),r.unevaluated&&v$(t),E_(t),P$(t)})}function v$(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,T._)`${r}.evaluated`),e.if((0,T._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,T._)`${t.evaluated}.props`,(0,T._)`undefined`)),e.if((0,T._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,T._)`${t.evaluated}.items`,(0,T._)`undefined`))}function f_(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,T._)`/*# sourceURL=${r} */`:T.nil}function E$(t,e){if(S_(t)&&(v_(t),y_(t))){w$(t,e);return}(0,g_.boolOrEmptySchema)(t,e)}function y_({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function S_(t){return typeof t.schema!="boolean"}function w$(t,e){let{schema:r,gen:n,opts:o}=t;o.$comment&&r.$comment&&w_(t),x$(t),$$(t);let s=n.const("_errs",I.default.errors);E_(t,s),n.var(e,(0,T._)`${s} === ${I.default.errors}`)}function v_(t){(0,Ot.checkUnknownRules)(t),b$(t)}function E_(t,e){if(t.opts.jtd)return m_(t,[],!1,e);let r=(0,p_.getSchemaTypes)(t.schema),n=(0,p_.coerceAndCheckDataType)(t,r);m_(t,r,!n,e)}function b$(t){let{schema:e,errSchemaPath:r,opts:n,self:o}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,Ot.schemaHasRulesButRef)(e,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function k$(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Ot.checkStrictMode)(t,"default is ignored in the schema root")}function x$(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,h$.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function $$(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function w_({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)t.code((0,T._)`${I.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,T.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,T._)`${I.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function P$(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=t;r.$async?e.if((0,T._)`${I.default.errors} === 0`,()=>e.return(I.default.data),()=>e.throw((0,T._)`new ${o}(${I.default.vErrors})`)):(e.assign((0,T._)`${n}.errors`,I.default.vErrors),s.unevaluated&&T$(t),e.return((0,T._)`${I.default.errors} === 0`))}function T$({gen:t,evaluated:e,props:r,items:n}){r instanceof T.Name&&t.assign((0,T._)`${e}.props`,r),n instanceof T.Name&&t.assign((0,T._)`${e}.items`,n)}function m_(t,e,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:u}=t,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,Ot.schemaHasRulesButRef)(s,l))){o.block(()=>k_(t,"$ref",l.all.$ref.definition));return}c.jtd||O$(t,e),o.block(()=>{for(let p of l.rules)d(p);d(l.post)});function d(p){(0,Hc.shouldUseGroup)(s,p)&&(p.type?(o.if((0,$s.checkDataType)(p.type,i,c.strictNumbers)),h_(t,p),e.length===1&&e[0]===p.type&&r&&(o.else(),(0,$s.reportTypeError)(t)),o.endIf()):h_(t,p),a||o.if((0,T._)`${I.default.errors} === ${n||0}`))}}function h_(t,e){let{gen:r,schema:n,opts:{useDefaults:o}}=t;o&&(0,m$.assignDefaults)(t,e.type),r.block(()=>{for(let s of e.rules)(0,Hc.shouldUseRule)(n,s)&&k_(t,s.keyword,s.definition,e.type)})}function O$(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(z$(t,e),t.opts.allowUnionTypes||R$(t,e),I$(t,t.dataTypes))}function z$(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{b_(t.dataTypes,r)||Wc(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),A$(t,e)}}function R$(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&Wc(t,"use allowUnionTypes to allow union type keyword")}function I$(t,e){let r=t.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,Hc.shouldUseRule)(t.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>C$(e,i))&&Wc(t,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function C$(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function b_(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function A$(t,e){let r=[];for(let n of t.dataTypes)b_(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function Wc(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Ot.checkStrictMode)(t,e,t.opts.strictTypes)}var Ps=class{constructor(e,r,n){if((0,Xn.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Ot.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",x_(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,Xn.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=e.gen.const("_errs",I.default.errors))}result(e,r,n){this.failResult((0,T.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,T.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,T._)`${r} !== undefined && (${(0,T.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?Yn.reportExtraError:Yn.reportError)(this,this.def.error,r)}$dataError(){(0,Yn.reportError)(this,this.def.$dataError||Yn.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Yn.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=T.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=T.nil,r=T.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,T.or)((0,T._)`${o} === undefined`,r)),e!==T.nil&&n.assign(e,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==T.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,T.or)(i(),a());function i(){if(n.length){if(!(r instanceof T.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,T._)`${(0,$s.checkDataTypes)(c,r,s.opts.strictNumbers,$s.DataType.Wrong)}`}return T.nil}function a(){if(o.validateSchema){let c=e.scopeValue("validate$data",{ref:o.validateSchema});return(0,T._)`!${c}(${r})`}return T.nil}}subschema(e,r){let n=(0,qc.getSubschema)(this.it,e);(0,qc.extendSubschemaData)(n,this.it,e),(0,qc.extendSubschemaMode)(n,e);let o={...this.it,...n,items:void 0,props:void 0};return E$(o,r),o}mergeEvaluated(e,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Ot.mergeEvaluated.props(o,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=Ot.mergeEvaluated.items(o,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(e,T.Name)),!0}};Wt.KeywordCxt=Ps;function k_(t,e,r,n){let o=new Ps(t,r,e);"code"in r?r.code(o,n):o.$data&&r.validate?(0,Xn.funcKeywordCode)(o,r):"macro"in r?(0,Xn.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,Xn.funcKeywordCode)(o,r)}var M$=/^\/(?:[^~]|~0|~1)*$/,N$=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function x_(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let o,s;if(t==="")return I.default.rootData;if(t[0]==="/"){if(!M$.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);o=t,s=I.default.rootData}else{let u=N$.exec(t);if(!u)throw new Error(`Invalid JSON-pointer: ${t}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=e)throw new Error(c("property/index",l));return n[e-l]}if(l>e)throw new Error(c("data",l));if(s=r[e-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,T._)`${s}${(0,T.getProperty)((0,Ot.unescapeJsonPointer)(u))}`,i=(0,T._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${e}`}}Wt.getData=x_});var Ts=E(Vc=>{"use strict";Object.defineProperty(Vc,"__esModule",{value:!0});var Kc=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};Vc.default=Kc});var eo=E(Bc=>{"use strict";Object.defineProperty(Bc,"__esModule",{value:!0});var Jc=Bn(),Gc=class extends Error{constructor(e,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Jc.resolveUrl)(e,r,n),this.missingSchema=(0,Jc.normalizeId)((0,Jc.getFullPath)(e,this.missingRef))}};Bc.default=Gc});var zs=E(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.resolveSchema=Qe.getCompilingSchema=Qe.resolveRef=Qe.compileSchema=Qe.SchemaEnv=void 0;var it=M(),D$=Ts(),pr=Tt(),at=Bn(),$_=Z(),L$=Qn(),Zr=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,at.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};Qe.SchemaEnv=Zr;function Xc(t){let e=P_.call(this,t);if(e)return e;let r=(0,at.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new it.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;t.$async&&(a=i.scopeValue("Error",{ref:D$.default,code:(0,it._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:pr.default.data,parentData:pr.default.parentData,parentDataProperty:pr.default.parentDataProperty,dataNames:[pr.default.data],dataPathArr:[it.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,it.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:it.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,it._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,L$.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(pr.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let m=new Function(`${pr.default.self}`,`${pr.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:m}),m.errors=null,m.schema=t.schema,m.schemaEnv=t,t.$async&&(m.$async=!0),this.opts.code.source===!0&&(m.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:h,items:y}=u;m.evaluated={props:h instanceof it.Name?void 0:h,items:y instanceof it.Name?void 0:y,dynamicProps:h instanceof it.Name,dynamicItems:y instanceof it.Name},m.source&&(m.source.evaluated=(0,it.stringify)(m.evaluated))}return t.validate=m,t}catch(d){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(t)}}Qe.compileSchema=Xc;function j$(t,e,r){var n;r=(0,at.resolveUrl)(this.opts.uriResolver,e,r);let o=t.refs[r];if(o)return o;let s=Z$.call(this,t,r);if(s===void 0){let i=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new Zr({schema:i,schemaId:a,root:t,baseId:e}))}if(s!==void 0)return t.refs[r]=U$.call(this,s)}Qe.resolveRef=j$;function U$(t){return(0,at.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:Xc.call(this,t)}function P_(t){for(let e of this._compilations)if(F$(e,t))return e}Qe.getCompilingSchema=P_;function F$(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function Z$(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||Os.call(this,t,e)}function Os(t,e){let r=this.opts.uriResolver.parse(e),n=(0,at._getFullPath)(this.opts.uriResolver,r),o=(0,at.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===o)return Yc.call(this,r,t);let s=(0,at.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=Os.call(this,t,i);return typeof a?.schema!="object"?void 0:Yc.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Xc.call(this,i),s===(0,at.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,at.resolveUrl)(this.opts.uriResolver,o,u)),new Zr({schema:a,schemaId:c,root:t,baseId:o})}return Yc.call(this,r,i)}}Qe.resolveSchema=Os;var q$=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Yc(t,{baseId:e,schema:r,root:n}){var o;if(((o=t.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,$_.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!q$.has(a)&&u&&(e=(0,at.resolveUrl)(this.opts.uriResolver,e,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,$_.schemaHasRulesButRef)(r,this.RULES)){let a=(0,at.resolveUrl)(this.opts.uriResolver,e,r.$ref);s=Os.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new Zr({schema:r,schemaId:i,root:n,baseId:e}),s.schema!==s.root.schema)return s}});var T_=E((Z1,H$)=>{H$.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 tu=E((q1,A_)=>{"use strict";var W$=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),z_=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),Qc=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),R_=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),K$=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function eu(t){let e="",r=0,n=0;for(n=0;n<t.length;n++)if(r=t[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n];break}for(n+=1;n<t.length;n++){if(r=t[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n]}return e}var V$=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function O_(t){return t.length=0,!0}function J$(t,e,r){if(t.length){let n=eu(t);if(n!=="")e.push(n);else return r.error=!0,!1;t.length=0}return!0}function G$(t){let e=0,r={error:!1,address:"",zone:""},n=[],o=[],s=!1,i=!1,a=J$;for(let c=0;c<t.length;c++){let u=t[c];if(!(u==="["||u==="]"))if(u===":"){if(s===!0&&(i=!0),!a(o,n,r))break;if(++e>7){r.error=!0;break}c>0&&t[c-1]===":"&&(s=!0),n.push(":");continue}else if(u==="%"){if(!a(o,n,r))break;a=O_}else{o.push(u);continue}}return o.length&&(a===O_?r.zone=o.join(""):i?n.push(o.join("")):n.push(eu(o))),r.address=n.join(""),r}function I_(t){if(B$(t,":")<2)return{host:t,isIPV6:!1};let e=G$(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,isIPV6:!0,escapedHost:n}}}function B$(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function Y$(t){let e=t,r=[],n=-1,o=0;for(;o=e.length;){if(o===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(o===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(o===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((n=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,n)),e=e.slice(n)}return r.join("")}var X$={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},Q$=/[@/?#:]/g,eP=/[@/?#]/g;function C_(t,e){let r=e?eP:Q$;return r.lastIndex=0,t.replace(r,n=>X$[n])}function tP(t,e=!1){if(t.indexOf("%")===-1)return t;let r="";for(let n=0;n<t.length;n++){if(t[n]==="%"&&n+2<t.length){let o=t.slice(n+1,n+3);if(Qc(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));e&&R_(i)?r+=i:r+="%"+s,n+=2;continue}}r+=t[n]}return r}function rP(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(Qc(n)){let o=n.toUpperCase(),s=String.fromCharCode(parseInt(o,16));s!=="."&&R_(s)?e+=s:e+="%"+o,r+=2;continue}}K$(t[r])?e+=t[r]:e+=escape(t[r])}return e}function nP(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(Qc(n)){e+="%"+n.toUpperCase(),r+=2;continue}}e+=escape(t[r])}return e}function oP(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!z_(r)){let n=I_(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=C_(r,!1)}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}A_.exports={nonSimpleDomain:V$,recomposeAuthority:oP,reescapeHostDelimiters:C_,normalizePercentEncoding:tP,normalizePathEncoding:rP,escapePreservingEscapes:nP,removeDotSegments:Y$,isIPv4:z_,isUUID:W$,normalizeIPv6:I_,stringArrayToHexStripped:eu}});var j_=E((H1,L_)=>{"use strict";var{isUUID:sP}=tu(),iP=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,aP=["http","https","ws","wss","urn","urn:uuid"];function cP(t){return aP.indexOf(t)!==-1}function ru(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function M_(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function N_(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function uP(t){return t.secure=ru(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function lP(t){if((t.port===(ru(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function dP(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(iP);if(r){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let o=`${n}:${e.nid||t.nid}`,s=nu(o);t.path=void 0,s&&(t=s.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function pP(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),o=`${r}:${e.nid||n}`,s=nu(o);s&&(t=s.serialize(t,e));let i=t,a=t.nss;return i.path=`${n||e.nid}:${a}`,e.skipEscape=!0,i}function fP(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!sP(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function mP(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var D_={scheme:"http",domainHost:!0,parse:M_,serialize:N_},hP={scheme:"https",domainHost:D_.domainHost,parse:M_,serialize:N_},Rs={scheme:"ws",domainHost:!0,parse:uP,serialize:lP},gP={scheme:"wss",domainHost:Rs.domainHost,parse:Rs.parse,serialize:Rs.serialize},_P={scheme:"urn",parse:dP,serialize:pP,skipNormalize:!0},yP={scheme:"urn:uuid",parse:fP,serialize:mP,skipNormalize:!0},Is={http:D_,https:hP,ws:Rs,wss:gP,urn:_P,"urn:uuid":yP};Object.setPrototypeOf(Is,null);function nu(t){return t&&(Is[t]||Is[t.toLowerCase()])||void 0}L_.exports={wsIsSecure:ru,SCHEMES:Is,isValidSchemeName:cP,getSchemeHandler:nu}});var W_=E((W1,Cs)=>{"use strict";var{normalizeIPv6:SP,removeDotSegments:to,recomposeAuthority:vP,normalizePercentEncoding:EP,normalizePathEncoding:wP,escapePreservingEscapes:bP,reescapeHostDelimiters:kP,isIPv4:xP,nonSimpleDomain:$P}=tu(),{SCHEMES:PP,getSchemeHandler:F_}=j_();function TP(t,e){return typeof t=="string"?t=CP(t,e):typeof t=="object"&&(t=qr(fr(t,e),e)),t}function OP(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=Z_(qr(t,n),qr(e,n),n,!0);return n.skipEscape=!0,fr(o,n)}function Z_(t,e,r,n){let o={};return n||(t=qr(fr(t,r),r),e=qr(fr(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(o.scheme=e.scheme,o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=to(e.path||""),o.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=to(e.path||""),o.query=e.query):(e.path?(e.path[0]==="/"?o.path=to(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?o.path="/"+e.path:t.path?o.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:o.path=e.path,o.path=to(o.path)),o.query=e.query):(o.path=t.path,e.query!==void 0?o.query=e.query:o.query=t.query),o.userinfo=t.userinfo,o.host=t.host,o.port=t.port),o.scheme=t.scheme),o.fragment=e.fragment,o}function zP(t,e,r){let n=U_(t,r),o=U_(e,r);return n!==void 0&&o!==void 0&&n.toLowerCase()===o.toLowerCase()}function fr(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},e),o=[],s=F_(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=EP(r.path):(r.path=bP(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&o.push(r.scheme,":");let i=vP(r);if(i!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(i),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(a=to(a)),i===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),o.push(a)}return r.query!==void 0&&o.push("?",r.query),r.fragment!==void 0&&o.push("#",r.fragment),o.join("")}var RP=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function IP(t,e){if(e[2]!==void 0&&t.path&&t.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof t.port=="number"&&(t.port<0||t.port>65535))return"URI port is malformed."}function q_(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1,s=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let i=t.match(RP);if(i){n.scheme=i[1],n.userinfo=i[3],n.host=i[4],n.port=parseInt(i[5],10),n.path=i[6]||"",n.query=i[7],n.fragment=i[8],isNaN(n.port)&&(n.port=i[5]);let a=IP(n,i);if(a!==void 0&&(n.error=n.error||a,o=!0),n.host)if(xP(n.host)===!1){let l=SP(n.host);n.host=l.host.toLowerCase(),s=l.isIPV6}else s=!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 c=F_(r.scheme||n.scheme);if(!r.unicodeSupport&&(!c||!c.unicodeSupport)&&n.host&&(r.domainHost||c&&c.domainHost)&&s===!1&&$P(n.host))try{n.host=new URL("http://"+n.host).hostname}catch(u){n.error=n.error||"Host's domain name can not be converted to ASCII: "+u}if((!c||c&&!c.skipNormalize)&&(t.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=kP(unescape(n.host),s))),n.path&&(n.path=wP(n.path)),n.fragment))try{n.fragment=encodeURI(decodeURIComponent(n.fragment))}catch{n.error=n.error||"URI malformed"}c&&c.parse&&c.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o}}function qr(t,e){return q_(t,e).parsed}function CP(t,e){return H_(t,e).normalized}function H_(t,e){let{parsed:r,malformedAuthorityOrPort:n}=q_(t,e);return{normalized:n?t:fr(r,e),malformedAuthorityOrPort:n}}function U_(t,e){if(typeof t=="string"){let{normalized:r,malformedAuthorityOrPort:n}=H_(t,e);return n?void 0:r}if(typeof t=="object")return fr(t,e)}var ou={SCHEMES:PP,normalize:TP,resolve:OP,resolveComponent:Z_,equal:zP,serialize:fr,parse:qr};Cs.exports=ou;Cs.exports.default=ou;Cs.exports.fastUri=ou});var V_=E(su=>{"use strict";Object.defineProperty(su,"__esModule",{value:!0});var K_=W_();K_.code='require("ajv/dist/runtime/uri").default';su.default=K_});var ty=E(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});ve.CodeGen=ve.Name=ve.nil=ve.stringify=ve.str=ve._=ve.KeywordCxt=void 0;var AP=Qn();Object.defineProperty(ve,"KeywordCxt",{enumerable:!0,get:function(){return AP.KeywordCxt}});var Hr=M();Object.defineProperty(ve,"_",{enumerable:!0,get:function(){return Hr._}});Object.defineProperty(ve,"str",{enumerable:!0,get:function(){return Hr.str}});Object.defineProperty(ve,"stringify",{enumerable:!0,get:function(){return Hr.stringify}});Object.defineProperty(ve,"nil",{enumerable:!0,get:function(){return Hr.nil}});Object.defineProperty(ve,"Name",{enumerable:!0,get:function(){return Hr.Name}});Object.defineProperty(ve,"CodeGen",{enumerable:!0,get:function(){return Hr.CodeGen}});var MP=Ts(),X_=eo(),NP=Cc(),ro=zs(),DP=M(),no=Bn(),As=Gn(),au=Z(),J_=T_(),LP=V_(),Q_=(t,e)=>new RegExp(t,e);Q_.code="new RegExp";var jP=["removeAdditional","useDefaults","coerceTypes"],UP=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),FP={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."},ZP={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},G_=200;function qP(t){var e,r,n,o,s,i,a,c,u,l,d,p,m,h,y,g,v,b,w,$,x,je,We,sn,ci;let an=t.strict,ui=(e=t.code)===null||e===void 0?void 0:e.optimize,Ol=ui===!0||ui===void 0?1:ui||0,zl=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:Q_,Rv=(o=t.uriResolver)!==null&&o!==void 0?o:LP.default;return{strictSchema:(i=(s=t.strictSchema)!==null&&s!==void 0?s:an)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:an)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=t.strictTypes)!==null&&u!==void 0?u:an)!==null&&l!==void 0?l:"log",strictTuples:(p=(d=t.strictTuples)!==null&&d!==void 0?d:an)!==null&&p!==void 0?p:"log",strictRequired:(h=(m=t.strictRequired)!==null&&m!==void 0?m:an)!==null&&h!==void 0?h:!1,code:t.code?{...t.code,optimize:Ol,regExp:zl}:{optimize:Ol,regExp:zl},loopRequired:(y=t.loopRequired)!==null&&y!==void 0?y:G_,loopEnum:(g=t.loopEnum)!==null&&g!==void 0?g:G_,meta:(v=t.meta)!==null&&v!==void 0?v:!0,messages:(b=t.messages)!==null&&b!==void 0?b:!0,inlineRefs:(w=t.inlineRefs)!==null&&w!==void 0?w:!0,schemaId:($=t.schemaId)!==null&&$!==void 0?$:"$id",addUsedSchema:(x=t.addUsedSchema)!==null&&x!==void 0?x:!0,validateSchema:(je=t.validateSchema)!==null&&je!==void 0?je:!0,validateFormats:(We=t.validateFormats)!==null&&We!==void 0?We:!0,unicodeRegExp:(sn=t.unicodeRegExp)!==null&&sn!==void 0?sn:!0,int32range:(ci=t.int32range)!==null&&ci!==void 0?ci:!0,uriResolver:Rv}}var oo=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...qP(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new DP.ValueScope({scope:{},prefixes:UP,es5:r,lines:n}),this.logger=GP(e.logger);let o=e.validateFormats;e.validateFormats=!1,this.RULES=(0,NP.getRules)(),B_.call(this,FP,e,"NOT SUPPORTED"),B_.call(this,ZP,e,"DEPRECATED","warn"),this._metaOpts=VP.call(this),e.formats&&WP.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&KP.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),HP.call(this),e.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,o=J_;n==="id"&&(o={...J_},o.id=o.$id,delete o.$id),r&&e&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,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,e,r);async function o(l,d){await s.call(this,l.$schema);let p=this._addSchema(l,d);return p.validate||i.call(this,p)}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 X_.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(e,r,n,o=this.opts.validateSchema){if(Array.isArray(e)){for(let i of e)this.addSchema(i,void 0,n,o);return this}let s;if(typeof e=="object"){let{schemaId:i}=this.opts;if(s=e[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,no.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,o,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$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,e);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(e){let r;for(;typeof(r=Y_.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,o=new ro.SchemaEnv({schema:{},schemaId:n});if(r=ro.resolveSchema.call(this,o,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=Y_.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,no.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,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(YP.call(this,n,r),!r)return(0,au.eachItem)(n,s=>iu.call(this,s)),this;QP.call(this,r);let o={...r,type:(0,As.getJSONTypes)(r.type),schemaType:(0,As.getJSONTypes)(r.schemaType)};return(0,au.eachItem)(n,o.type.length===0?s=>iu.call(this,s,o):s=>o.type.forEach(i=>iu.call(this,s,o,i))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===e);o>=0&&n.rules.splice(o,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let o of r){let s=o.split("/").slice(1),i=e;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]=ey(l))}}return e}_removeAllSchemas(e,r){for(let n in e){let o=e[n];(!r||r.test(n))&&(typeof o=="string"?delete e[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete e[n]))}}_addSchema(e,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof e=="object")i=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;n=(0,no.normalizeId)(i||n);let u=no.getSchemaRefs.call(this,e,n);return c=new ro.SchemaEnv({schema:e,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(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):ro.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{ro.compileSchema.call(this,e)}finally{this.opts=r}}};oo.ValidationError=MP.default;oo.MissingRefError=X_.default;ve.default=oo;function B_(t,e,r,n="error"){for(let o in t){let s=o;s in e&&this.logger[n](`${r}: option ${o}. ${t[s]}`)}}function Y_(t){return t=(0,no.normalizeId)(t),this.schemas[t]||this.refs[t]}function HP(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function WP(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function KP(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function VP(){let t={...this.opts};for(let e of jP)delete t[e];return t}var JP={log(){},warn(){},error(){}};function GP(t){if(t===!1)return JP;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var BP=/^[a-z_$][a-z0-9_$:-]*$/i;function YP(t,e){let{RULES:r}=this;if((0,au.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!BP.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function iu(t,e,r){var n;let o=e?.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[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,As.getJSONTypes)(e.type),schemaType:(0,As.getJSONTypes)(e.schemaType)}};e.before?XP.call(this,i,a,e.before):i.rules.push(a),s.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function XP(t,e,r){let n=t.rules.findIndex(o=>o.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function QP(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=ey(e)),t.validateSchema=this.compile(e,!0))}var eT={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function ey(t){return{anyOf:[t,eT]}}});var ry=E(cu=>{"use strict";Object.defineProperty(cu,"__esModule",{value:!0});var tT={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};cu.default=tT});var iy=E(mr=>{"use strict";Object.defineProperty(mr,"__esModule",{value:!0});mr.callRef=mr.getValidate=void 0;var rT=eo(),ny=Xe(),Le=M(),Wr=Tt(),oy=zs(),Ms=Z(),nT={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=oy.resolveRef.call(c,u,o,r);if(l===void 0)throw new rT.default(n.opts.uriResolver,o,r);if(l instanceof oy.SchemaEnv)return p(l);return m(l);function d(){if(s===u)return Ns(t,i,s,s.$async);let h=e.scopeValue("root",{ref:u});return Ns(t,(0,Le._)`${h}.validate`,u,u.$async)}function p(h){let y=sy(t,h);Ns(t,y,h,h.$async)}function m(h){let y=e.scopeValue("schema",a.code.source===!0?{ref:h,code:(0,Le.stringify)(h)}:{ref:h}),g=e.name("valid"),v=t.subschema({schema:h,dataTypes:[],schemaPath:Le.nil,topSchemaRef:y,errSchemaPath:r},g);t.mergeEvaluated(v),t.ok(g)}}};function sy(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Le._)`${r.scopeValue("wrapper",{ref:e})}.validate`}mr.getValidate=sy;function Ns(t,e,r,n){let{gen:o,it:s}=t,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?Wr.default.this:Le.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let h=o.let("valid");o.try(()=>{o.code((0,Le._)`await ${(0,ny.callValidateCode)(t,e,u)}`),m(e),i||o.assign(h,!0)},y=>{o.if((0,Le._)`!(${y} instanceof ${s.ValidationError})`,()=>o.throw(y)),p(y),i||o.assign(h,!1)}),t.ok(h)}function d(){t.result((0,ny.callValidateCode)(t,e,u),()=>m(e),()=>p(e))}function p(h){let y=(0,Le._)`${h}.errors`;o.assign(Wr.default.vErrors,(0,Le._)`${Wr.default.vErrors} === null ? ${y} : ${Wr.default.vErrors}.concat(${y})`),o.assign(Wr.default.errors,(0,Le._)`${Wr.default.vErrors}.length`)}function m(h){var y;if(!s.opts.unevaluated)return;let g=(y=r?.validate)===null||y===void 0?void 0:y.evaluated;if(s.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(s.props=Ms.mergeEvaluated.props(o,g.props,s.props));else{let v=o.var("props",(0,Le._)`${h}.evaluated.props`);s.props=Ms.mergeEvaluated.props(o,v,s.props,Le.Name)}if(s.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(s.items=Ms.mergeEvaluated.items(o,g.items,s.items));else{let v=o.var("items",(0,Le._)`${h}.evaluated.items`);s.items=Ms.mergeEvaluated.items(o,v,s.items,Le.Name)}}}mr.callRef=Ns;mr.default=nT});var ay=E(uu=>{"use strict";Object.defineProperty(uu,"__esModule",{value:!0});var oT=ry(),sT=iy(),iT=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",oT.default,sT.default];uu.default=iT});var cy=E(lu=>{"use strict";Object.defineProperty(lu,"__esModule",{value:!0});var Ds=M(),Kt=Ds.operators,Ls={maximum:{okStr:"<=",ok:Kt.LTE,fail:Kt.GT},minimum:{okStr:">=",ok:Kt.GTE,fail:Kt.LT},exclusiveMaximum:{okStr:"<",ok:Kt.LT,fail:Kt.GTE},exclusiveMinimum:{okStr:">",ok:Kt.GT,fail:Kt.LTE}},aT={message:({keyword:t,schemaCode:e})=>(0,Ds.str)`must be ${Ls[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,Ds._)`{comparison: ${Ls[t].okStr}, limit: ${e}}`},cT={keyword:Object.keys(Ls),type:"number",schemaType:"number",$data:!0,error:aT,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,Ds._)`${r} ${Ls[e].fail} ${n} || isNaN(${r})`)}};lu.default=cT});var uy=E(du=>{"use strict";Object.defineProperty(du,"__esModule",{value:!0});var so=M(),uT={message:({schemaCode:t})=>(0,so.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,so._)`{multipleOf: ${t}}`},lT={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:uT,code(t){let{gen:e,data:r,schemaCode:n,it:o}=t,s=o.opts.multipleOfPrecision,i=e.let("res"),a=s?(0,so._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,so._)`${i} !== parseInt(${i})`;t.fail$data((0,so._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};du.default=lT});var dy=E(pu=>{"use strict";Object.defineProperty(pu,"__esModule",{value:!0});function ly(t){let e=t.length,r=0,n=0,o;for(;n<e;)r++,o=t.charCodeAt(n++),o>=55296&&o<=56319&&n<e&&(o=t.charCodeAt(n),(o&64512)===56320&&n++);return r}pu.default=ly;ly.code='require("ajv/dist/runtime/ucs2length").default'});var py=E(fu=>{"use strict";Object.defineProperty(fu,"__esModule",{value:!0});var hr=M(),dT=Z(),pT=dy(),fT={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,hr.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,hr._)`{limit: ${t}}`},mT={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:fT,code(t){let{keyword:e,data:r,schemaCode:n,it:o}=t,s=e==="maxLength"?hr.operators.GT:hr.operators.LT,i=o.opts.unicode===!1?(0,hr._)`${r}.length`:(0,hr._)`${(0,dT.useFunc)(t.gen,pT.default)}(${r})`;t.fail$data((0,hr._)`${i} ${s} ${n}`)}};fu.default=mT});var fy=E(mu=>{"use strict";Object.defineProperty(mu,"__esModule",{value:!0});var hT=Xe(),gT=Z(),Kr=M(),_T={message:({schemaCode:t})=>(0,Kr.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,Kr._)`{pattern: ${t}}`},yT={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:_T,code(t){let{gen:e,data:r,$data:n,schema:o,schemaCode:s,it:i}=t,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,Kr._)`new RegExp`:(0,gT.useFunc)(e,c),l=e.let("valid");e.try(()=>e.assign(l,(0,Kr._)`${u}(${s}, ${a}).test(${r})`),()=>e.assign(l,!1)),t.fail$data((0,Kr._)`!${l}`)}else{let c=(0,hT.usePattern)(t,o);t.fail$data((0,Kr._)`!${c}.test(${r})`)}}};mu.default=yT});var my=E(hu=>{"use strict";Object.defineProperty(hu,"__esModule",{value:!0});var io=M(),ST={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,io.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,io._)`{limit: ${t}}`},vT={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:ST,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxProperties"?io.operators.GT:io.operators.LT;t.fail$data((0,io._)`Object.keys(${r}).length ${o} ${n}`)}};hu.default=vT});var hy=E(gu=>{"use strict";Object.defineProperty(gu,"__esModule",{value:!0});var ao=Xe(),co=M(),ET=Z(),wT={message:({params:{missingProperty:t}})=>(0,co.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,co._)`{missingProperty: ${t}}`},bT={keyword:"required",type:"object",schemaType:"array",$data:!0,error:wT,code(t){let{gen:e,schema:r,schemaCode:n,data:o,$data:s,it:i}=t,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let m=t.parentSchema.properties,{definedProperties:h}=t.it;for(let y of r)if(m?.[y]===void 0&&!h.has(y)){let g=i.schemaEnv.baseId+i.errSchemaPath,v=`required property "${y}" is not defined at "${g}" (strictRequired)`;(0,ET.checkStrictMode)(i,v,i.opts.strictRequired)}}function u(){if(c||s)t.block$data(co.nil,d);else for(let m of r)(0,ao.checkReportMissingProp)(t,m)}function l(){let m=e.let("missing");if(c||s){let h=e.let("valid",!0);t.block$data(h,()=>p(m,h)),t.ok(h)}else e.if((0,ao.checkMissingProp)(t,r,m)),(0,ao.reportMissingProp)(t,m),e.else()}function d(){e.forOf("prop",n,m=>{t.setParams({missingProperty:m}),e.if((0,ao.noPropertyInData)(e,o,m,a.ownProperties),()=>t.error())})}function p(m,h){t.setParams({missingProperty:m}),e.forOf(m,n,()=>{e.assign(h,(0,ao.propertyInData)(e,o,m,a.ownProperties)),e.if((0,co.not)(h),()=>{t.error(),e.break()})},co.nil)}}};gu.default=bT});var gy=E(_u=>{"use strict";Object.defineProperty(_u,"__esModule",{value:!0});var uo=M(),kT={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,uo.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,uo._)`{limit: ${t}}`},xT={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:kT,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxItems"?uo.operators.GT:uo.operators.LT;t.fail$data((0,uo._)`${r}.length ${o} ${n}`)}};_u.default=xT});var js=E(yu=>{"use strict";Object.defineProperty(yu,"__esModule",{value:!0});var _y=Fc();_y.code='require("ajv/dist/runtime/equal").default';yu.default=_y});var yy=E(vu=>{"use strict";Object.defineProperty(vu,"__esModule",{value:!0});var Su=Gn(),Ee=M(),$T=Z(),PT=js(),TT={message:({params:{i:t,j:e}})=>(0,Ee.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,Ee._)`{i: ${t}, j: ${e}}`},OT={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:TT,code(t){let{gen:e,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=t;if(!n&&!o)return;let c=e.let("valid"),u=s.items?(0,Su.getSchemaTypes)(s.items):[];t.block$data(c,l,(0,Ee._)`${i} === false`),t.ok(c);function l(){let h=e.let("i",(0,Ee._)`${r}.length`),y=e.let("j");t.setParams({i:h,j:y}),e.assign(c,!0),e.if((0,Ee._)`${h} > 1`,()=>(d()?p:m)(h,y))}function d(){return u.length>0&&!u.some(h=>h==="object"||h==="array")}function p(h,y){let g=e.name("item"),v=(0,Su.checkDataTypes)(u,g,a.opts.strictNumbers,Su.DataType.Wrong),b=e.const("indices",(0,Ee._)`{}`);e.for((0,Ee._)`;${h}--;`,()=>{e.let(g,(0,Ee._)`${r}[${h}]`),e.if(v,(0,Ee._)`continue`),u.length>1&&e.if((0,Ee._)`typeof ${g} == "string"`,(0,Ee._)`${g} += "_"`),e.if((0,Ee._)`typeof ${b}[${g}] == "number"`,()=>{e.assign(y,(0,Ee._)`${b}[${g}]`),t.error(),e.assign(c,!1).break()}).code((0,Ee._)`${b}[${g}] = ${h}`)})}function m(h,y){let g=(0,$T.useFunc)(e,PT.default),v=e.name("outer");e.label(v).for((0,Ee._)`;${h}--;`,()=>e.for((0,Ee._)`${y} = ${h}; ${y}--;`,()=>e.if((0,Ee._)`${g}(${r}[${h}], ${r}[${y}])`,()=>{t.error(),e.assign(c,!1).break(v)})))}}};vu.default=OT});var Sy=E(wu=>{"use strict";Object.defineProperty(wu,"__esModule",{value:!0});var Eu=M(),zT=Z(),RT=js(),IT={message:"must be equal to constant",params:({schemaCode:t})=>(0,Eu._)`{allowedValue: ${t}}`},CT={keyword:"const",$data:!0,error:IT,code(t){let{gen:e,data:r,$data:n,schemaCode:o,schema:s}=t;n||s&&typeof s=="object"?t.fail$data((0,Eu._)`!${(0,zT.useFunc)(e,RT.default)}(${r}, ${o})`):t.fail((0,Eu._)`${s} !== ${r}`)}};wu.default=CT});var vy=E(bu=>{"use strict";Object.defineProperty(bu,"__esModule",{value:!0});var lo=M(),AT=Z(),MT=js(),NT={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,lo._)`{allowedValues: ${t}}`},DT={keyword:"enum",schemaType:"array",$data:!0,error:NT,code(t){let{gen:e,data:r,$data:n,schema:o,schemaCode:s,it:i}=t;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,AT.useFunc)(e,MT.default)),l;if(a||n)l=e.let("valid"),t.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let m=e.const("vSchema",s);l=(0,lo.or)(...o.map((h,y)=>p(m,y)))}t.pass(l);function d(){e.assign(l,!1),e.forOf("v",s,m=>e.if((0,lo._)`${u()}(${r}, ${m})`,()=>e.assign(l,!0).break()))}function p(m,h){let y=o[h];return typeof y=="object"&&y!==null?(0,lo._)`${u()}(${r}, ${m}[${h}])`:(0,lo._)`${r} === ${y}`}}};bu.default=DT});var Ey=E(ku=>{"use strict";Object.defineProperty(ku,"__esModule",{value:!0});var LT=cy(),jT=uy(),UT=py(),FT=fy(),ZT=my(),qT=hy(),HT=gy(),WT=yy(),KT=Sy(),VT=vy(),JT=[LT.default,jT.default,UT.default,FT.default,ZT.default,qT.default,HT.default,WT.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},KT.default,VT.default];ku.default=JT});var $u=E(po=>{"use strict";Object.defineProperty(po,"__esModule",{value:!0});po.validateAdditionalItems=void 0;var gr=M(),xu=Z(),GT={message:({params:{len:t}})=>(0,gr.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,gr._)`{limit: ${t}}`},BT={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:GT,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,xu.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}wy(t,n)}};function wy(t,e){let{gen:r,schema:n,data:o,keyword:s,it:i}=t;i.items=!0;let a=r.const("len",(0,gr._)`${o}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,gr._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,xu.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,gr._)`${a} <= ${e.length}`);r.if((0,gr.not)(u),()=>c(u)),t.ok(u)}function c(u){r.forRange("i",e.length,a,l=>{t.subschema({keyword:s,dataProp:l,dataPropType:xu.Type.Num},u),i.allErrors||r.if((0,gr.not)(u),()=>r.break())})}}po.validateAdditionalItems=wy;po.default=BT});var Pu=E(fo=>{"use strict";Object.defineProperty(fo,"__esModule",{value:!0});fo.validateTuple=void 0;var by=M(),Us=Z(),YT=Xe(),XT={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return ky(t,"additionalItems",e);r.items=!0,!(0,Us.alwaysValidSchema)(r,e)&&t.ok((0,YT.validateArray)(t))}};function ky(t,e,r=t.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=t;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=Us.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,by._)`${s}.length`);r.forEach((d,p)=>{(0,Us.alwaysValidSchema)(a,d)||(n.if((0,by._)`${u} > ${p}`,()=>t.subschema({keyword:i,schemaProp:p,dataProp:p},c)),t.ok(c))});function l(d){let{opts:p,errSchemaPath:m}=a,h=r.length,y=h===d.minItems&&(h===d.maxItems||d[e]===!1);if(p.strictTuples&&!y){let g=`"${i}" is ${h}-tuple, but minItems or maxItems/${e} are not specified or different at path "${m}"`;(0,Us.checkStrictMode)(a,g,p.strictTuples)}}}fo.validateTuple=ky;fo.default=XT});var xy=E(Tu=>{"use strict";Object.defineProperty(Tu,"__esModule",{value:!0});var QT=Pu(),eO={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,QT.validateTuple)(t,"items")};Tu.default=eO});var Py=E(Ou=>{"use strict";Object.defineProperty(Ou,"__esModule",{value:!0});var $y=M(),tO=Z(),rO=Xe(),nO=$u(),oO={message:({params:{len:t}})=>(0,$y.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,$y._)`{limit: ${t}}`},sO={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:oO,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:o}=r;n.items=!0,!(0,tO.alwaysValidSchema)(n,e)&&(o?(0,nO.validateAdditionalItems)(t,o):t.ok((0,rO.validateArray)(t)))}};Ou.default=sO});var Ty=E(zu=>{"use strict";Object.defineProperty(zu,"__esModule",{value:!0});var et=M(),Fs=Z(),iO={message:({params:{min:t,max:e}})=>e===void 0?(0,et.str)`must contain at least ${t} valid item(s)`:(0,et.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,et._)`{minContains: ${t}}`:(0,et._)`{minContains: ${t}, maxContains: ${e}}`},aO={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:iO,code(t){let{gen:e,schema:r,parentSchema:n,data:o,it:s}=t,i,a,{minContains:c,maxContains:u}=n;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=e.const("len",(0,et._)`${o}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,Fs.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,Fs.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,Fs.alwaysValidSchema)(s,r)){let y=(0,et._)`${l} >= ${i}`;a!==void 0&&(y=(0,et._)`${y} && ${l} <= ${a}`),t.pass(y);return}s.items=!0;let d=e.name("valid");a===void 0&&i===1?m(d,()=>e.if(d,()=>e.break())):i===0?(e.let(d,!0),a!==void 0&&e.if((0,et._)`${o}.length > 0`,p)):(e.let(d,!1),p()),t.result(d,()=>t.reset());function p(){let y=e.name("_valid"),g=e.let("count",0);m(y,()=>e.if(y,()=>h(g)))}function m(y,g){e.forRange("i",0,l,v=>{t.subschema({keyword:"contains",dataProp:v,dataPropType:Fs.Type.Num,compositeRule:!0},y),g()})}function h(y){e.code((0,et._)`${y}++`),a===void 0?e.if((0,et._)`${y} >= ${i}`,()=>e.assign(d,!0).break()):(e.if((0,et._)`${y} > ${a}`,()=>e.assign(d,!1).break()),i===1?e.assign(d,!0):e.if((0,et._)`${y} >= ${i}`,()=>e.assign(d,!0)))}}};zu.default=aO});var Ry=E(_t=>{"use strict";Object.defineProperty(_t,"__esModule",{value:!0});_t.validateSchemaDeps=_t.validatePropertyDeps=_t.error=void 0;var Ru=M(),cO=Z(),mo=Xe();_t.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,Ru.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,Ru._)`{property: ${t},
|
|
9
|
+
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,A._)`[${o}]`)}}}function z0({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,A._)`${e} !== undefined`,()=>t.assign((0,A._)`${e}[${r}]`,n))}function Mc(t,e,r,n=jr.Correct){let o=n===jr.Correct?A.operators.EQ:A.operators.NEQ,s;switch(t){case"null":return(0,A._)`${e} ${o} null`;case"array":s=(0,A._)`Array.isArray(${e})`;break;case"object":s=(0,A._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":s=i((0,A._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":s=i();break;default:return(0,A._)`typeof ${e} ${o} ${t}`}return n===jr.Correct?s:(0,A.not)(s);function i(a=A.nil){return(0,A.and)((0,A._)`typeof ${e} == "number"`,a,r?(0,A._)`isFinite(${e})`:A.nil)}}$e.checkDataType=Mc;function Nc(t,e,r,n){if(t.length===1)return Mc(t[0],e,r,n);let o,s=(0,Jg.toHash)(t);if(s.array&&s.object){let i=(0,A._)`typeof ${e} != "object"`;o=s.null?i:(0,A._)`!${e} || ${i}`,delete s.null,delete s.array,delete s.object}else o=A.nil;s.number&&delete s.integer;for(let i in s)o=(0,A.and)(o,Mc(i,e,r,n));return o}$e.checkDataTypes=Nc;var R0={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,A._)`{type: ${t}}`:(0,A._)`{type: ${e}}`};function Dc(t){let e=I0(t);(0,x0.reportError)(e,R0)}$e.reportTypeError=Dc;function I0(t){let{gen:e,data:r,schema:n}=t,o=(0,Jg.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:t}}});var Xg=E(ks=>{"use strict";Object.defineProperty(ks,"__esModule",{value:!0});ks.assignDefaults=void 0;var Ur=M(),C0=Z();function A0(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let o in r)Yg(t,o,r[o].default);else e==="array"&&Array.isArray(n)&&n.forEach((o,s)=>Yg(t,s,o.default))}ks.assignDefaults=A0;function Yg(t,e,r){let{gen:n,compositeRule:o,data:s,opts:i}=t;if(r===void 0)return;let a=(0,Ur._)`${s}${(0,Ur.getProperty)(e)}`;if(o){(0,C0.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,Ur._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,Ur._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Ur._)`${a} = ${(0,Ur.stringify)(r)}`)}});var Xe=E(J=>{"use strict";Object.defineProperty(J,"__esModule",{value:!0});J.validateUnion=J.validateArray=J.usePattern=J.callValidateCode=J.schemaProperties=J.allSchemaProperties=J.noPropertyInData=J.propertyInData=J.isOwnProperty=J.hasPropFunc=J.reportMissingProp=J.checkMissingProp=J.checkReportMissingProp=void 0;var te=M(),Lc=Z(),Zt=Tt(),M0=Z();function N0(t,e){let{gen:r,data:n,it:o}=t;r.if(Uc(r,n,e,o.opts.ownProperties),()=>{t.setParams({missingProperty:(0,te._)`${e}`},!0),t.error()})}J.checkReportMissingProp=N0;function D0({gen:t,data:e,it:{opts:r}},n,o){return(0,te.or)(...n.map(s=>(0,te.and)(Uc(t,e,s,r.ownProperties),(0,te._)`${o} = ${s}`)))}J.checkMissingProp=D0;function L0(t,e){t.setParams({missingProperty:e},!0),t.error()}J.reportMissingProp=L0;function Qg(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,te._)`Object.prototype.hasOwnProperty`})}J.hasPropFunc=Qg;function jc(t,e,r){return(0,te._)`${Qg(t)}.call(${e}, ${r})`}J.isOwnProperty=jc;function j0(t,e,r,n){let o=(0,te._)`${e}${(0,te.getProperty)(r)} !== undefined`;return n?(0,te._)`${o} && ${jc(t,e,r)}`:o}J.propertyInData=j0;function Uc(t,e,r,n){let o=(0,te._)`${e}${(0,te.getProperty)(r)} === undefined`;return n?(0,te.or)(o,(0,te.not)(jc(t,e,r))):o}J.noPropertyInData=Uc;function e_(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}J.allSchemaProperties=e_;function U0(t,e){return e_(e).filter(r=>!(0,Lc.alwaysValidSchema)(t,e[r]))}J.schemaProperties=U0;function F0({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,te._)`${t}, ${e}, ${n}${o}`:e,d=[[Zt.default.instancePath,(0,te.strConcat)(Zt.default.instancePath,s)],[Zt.default.parentData,i.parentData],[Zt.default.parentDataProperty,i.parentDataProperty],[Zt.default.rootData,Zt.default.rootData]];i.opts.dynamicRef&&d.push([Zt.default.dynamicAnchors,Zt.default.dynamicAnchors]);let p=(0,te._)`${l}, ${r.object(...d)}`;return c!==te.nil?(0,te._)`${a}.call(${c}, ${p})`:(0,te._)`${a}(${p})`}J.callValidateCode=F0;var Z0=(0,te._)`new RegExp`;function q0({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:o}=e.code,s=o(r,n);return t.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,te._)`${o.code==="new RegExp"?Z0:(0,M0.useFunc)(t,o)}(${r}, ${n})`})}J.usePattern=q0;function H0(t){let{gen:e,data:r,keyword:n,it:o}=t,s=e.name("valid");if(o.allErrors){let a=e.let("valid",!0);return i(()=>e.assign(a,!1)),a}return e.var(s,!0),i(()=>e.break()),s;function i(a){let c=e.const("len",(0,te._)`${r}.length`);e.forRange("i",0,c,u=>{t.subschema({keyword:n,dataProp:u,dataPropType:Lc.Type.Num},s),e.if((0,te.not)(s),a)})}}J.validateArray=H0;function W0(t){let{gen:e,schema:r,keyword:n,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,Lc.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,u)=>{let l=t.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);e.assign(i,(0,te._)`${i} || ${a}`),t.mergeValidEvaluated(l,a)||e.if((0,te.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}J.validateUnion=W0});var n_=E(ht=>{"use strict";Object.defineProperty(ht,"__esModule",{value:!0});ht.validateKeywordUsage=ht.validSchemaType=ht.funcKeywordCode=ht.macroKeywordCode=void 0;var Re=M(),dr=Tt(),V0=Xe(),K0=Jn();function J0(t,e){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=t,a=e.macro.call(i.self,o,s,i),c=r_(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");t.subschema({schema:a,schemaPath:Re.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}ht.macroKeywordCode=J0;function G0(t,e){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=t;Y0(c,e);let u=!a&&e.compile?e.compile.call(c.self,s,i,c):e.validate,l=r_(n,o,u),d=n.let("valid");t.block$data(d,p),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function p(){if(e.errors===!1)y(),e.modifying&&t_(t),g(()=>t.error());else{let v=e.async?m():h();e.modifying&&t_(t),g(()=>B0(t,v))}}function m(){let v=n.let("ruleErrs",null);return n.try(()=>y((0,Re._)`await `),b=>n.assign(d,!1).if((0,Re._)`${b} instanceof ${c.ValidationError}`,()=>n.assign(v,(0,Re._)`${b}.errors`),()=>n.throw(b))),v}function h(){let v=(0,Re._)`${l}.errors`;return n.assign(v,null),y(Re.nil),v}function y(v=e.async?(0,Re._)`await `:Re.nil){let b=c.opts.passContext?dr.default.this:dr.default.self,w=!("compile"in e&&!a||e.schema===!1);n.assign(d,(0,Re._)`${v}${(0,V0.callValidateCode)(t,l,b,w)}`,e.modifying)}function g(v){var b;n.if((0,Re.not)((b=e.valid)!==null&&b!==void 0?b:d),v)}}ht.funcKeywordCode=G0;function t_(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,Re._)`${n.parentData}[${n.parentDataProperty}]`))}function B0(t,e){let{gen:r}=t;r.if((0,Re._)`Array.isArray(${e})`,()=>{r.assign(dr.default.vErrors,(0,Re._)`${dr.default.vErrors} === null ? ${e} : ${dr.default.vErrors}.concat(${e})`).assign(dr.default.errors,(0,Re._)`${dr.default.vErrors}.length`),(0,K0.extendErrors)(t)},()=>t.error())}function Y0({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function r_(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Re.stringify)(r)})}function X0(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}ht.validSchemaType=X0;function Q0({schema:t,opts:e,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(t,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(t[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}ht.validateKeywordUsage=Q0});var s_=E(qt=>{"use strict";Object.defineProperty(qt,"__esModule",{value:!0});qt.extendSubschemaMode=qt.extendSubschemaData=qt.getSubschema=void 0;var gt=M(),o_=Z();function e$(t,{keyword:e,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,gt._)`${t.schemaPath}${(0,gt.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,gt._)`${t.schemaPath}${(0,gt.getProperty)(e)}${(0,gt.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,o_.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')}qt.getSubschema=e$;function t$(t,e,{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}=e;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=e,p=a.let("data",(0,gt._)`${e.data}${(0,gt.getProperty)(r)}`,!0);c(p),t.errorPath=(0,gt.str)`${u}${(0,o_.getErrorPath)(r,n,d.jsPropertySyntax)}`,t.parentDataProperty=(0,gt._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(o!==void 0){let u=o instanceof gt.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(t.propertyName=i)}s&&(t.dataTypes=s);function c(u){t.data=u,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,u]}}qt.extendSubschemaData=t$;function r$(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(t.compositeRule=n),o!==void 0&&(t.createErrors=o),s!==void 0&&(t.allErrors=s),t.jtdDiscriminator=e,t.jtdMetadata=r}qt.extendSubschemaMode=r$});var Fc=E((M1,i_)=>{"use strict";i_.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!t(e[o],r[o]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(s=Object.keys(e),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(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r}});var c_=E((N1,a_)=>{"use strict";var Ht=a_.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};xs(e,n,o,t,"",t)};Ht.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Ht.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Ht.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Ht.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 xs(t,e,r,n,o,s,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,o,s,i,a,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in Ht.arrayKeywords)for(var p=0;p<d.length;p++)xs(t,e,r,d[p],o+"/"+l+"/"+p,s,o,l,n,p)}else if(l in Ht.propsKeywords){if(d&&typeof d=="object")for(var m in d)xs(t,e,r,d[m],o+"/"+l+"/"+n$(m),s,o,l,n,m)}else(l in Ht.keywords||t.allKeys&&!(l in Ht.skipKeywords))&&xs(t,e,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function n$(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var Bn=E(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});De.getSchemaRefs=De.resolveUrl=De.normalizeId=De._getFullPath=De.getFullPath=De.inlineRef=void 0;var o$=Z(),s$=Fc(),i$=c_(),a$=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function c$(t,e=!0){return typeof t=="boolean"?!0:e===!0?!Zc(t):e?u_(t)<=e:!1}De.inlineRef=c$;var u$=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Zc(t){for(let e in t){if(u$.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(Zc)||typeof r=="object"&&Zc(r))return!0}return!1}function u_(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!a$.has(r)&&(typeof t[r]=="object"&&(0,o$.eachItem)(t[r],n=>e+=u_(n)),e===1/0))return 1/0}return e}function l_(t,e="",r){r!==!1&&(e=Fr(e));let n=t.parse(e);return d_(t,n)}De.getFullPath=l_;function d_(t,e){return t.serialize(e).split("#")[0]+"#"}De._getFullPath=d_;var l$=/#\/?$/;function Fr(t){return t?t.replace(l$,""):""}De.normalizeId=Fr;function d$(t,e,r){return r=Fr(r),t.resolve(e,r)}De.resolveUrl=d$;var p$=/^[a-z_][-a-z0-9._]*$/i;function f$(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=Fr(t[r]||e),s={"":o},i=l_(n,o,!1),a={},c=new Set;return i$(t,{allKeys:!0},(d,p,m,h)=>{if(h===void 0)return;let y=i+p,g=s[h];typeof d[r]=="string"&&(g=v.call(this,d[r])),b.call(this,d.$anchor),b.call(this,d.$dynamicAnchor),s[p]=g;function v(w){let $=this.opts.uriResolver.resolve;if(w=Fr(g?$(g,w):w),c.has(w))throw l(w);c.add(w);let x=this.refs[w];return typeof x=="string"&&(x=this.refs[x]),typeof x=="object"?u(d,x.schema,w):w!==Fr(y)&&(w[0]==="#"?(u(d,a[w],w),a[w]=d):this.refs[w]=y),w}function b(w){if(typeof w=="string"){if(!p$.test(w))throw new Error(`invalid anchor "${w}"`);v.call(this,`#${w}`)}}}),a;function u(d,p,m){if(p!==void 0&&!s$(d,p))throw l(m)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}De.getSchemaRefs=f$});var Qn=E(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});Wt.getData=Wt.KeywordCxt=Wt.validateFunctionCode=void 0;var g_=Wg(),p_=Gn(),Hc=Ac(),$s=Gn(),m$=Xg(),Xn=n_(),qc=s_(),T=M(),I=Tt(),h$=Bn(),Ot=Z(),Yn=Jn();function g$(t){if(S_(t)&&(v_(t),y_(t))){S$(t);return}__(t,()=>(0,g_.topBoolOrEmptySchema)(t))}Wt.validateFunctionCode=g$;function __({gen:t,validateName:e,schema:r,schemaEnv:n,opts:o},s){o.code.es5?t.func(e,(0,T._)`${I.default.data}, ${I.default.valCxt}`,n.$async,()=>{t.code((0,T._)`"use strict"; ${f_(r,o)}`),y$(t,o),t.code(s)}):t.func(e,(0,T._)`${I.default.data}, ${_$(o)}`,n.$async,()=>t.code(f_(r,o)).code(s))}function _$(t){return(0,T._)`{${I.default.instancePath}="", ${I.default.parentData}, ${I.default.parentDataProperty}, ${I.default.rootData}=${I.default.data}${t.dynamicRef?(0,T._)`, ${I.default.dynamicAnchors}={}`:T.nil}}={}`}function y$(t,e){t.if(I.default.valCxt,()=>{t.var(I.default.instancePath,(0,T._)`${I.default.valCxt}.${I.default.instancePath}`),t.var(I.default.parentData,(0,T._)`${I.default.valCxt}.${I.default.parentData}`),t.var(I.default.parentDataProperty,(0,T._)`${I.default.valCxt}.${I.default.parentDataProperty}`),t.var(I.default.rootData,(0,T._)`${I.default.valCxt}.${I.default.rootData}`),e.dynamicRef&&t.var(I.default.dynamicAnchors,(0,T._)`${I.default.valCxt}.${I.default.dynamicAnchors}`)},()=>{t.var(I.default.instancePath,(0,T._)`""`),t.var(I.default.parentData,(0,T._)`undefined`),t.var(I.default.parentDataProperty,(0,T._)`undefined`),t.var(I.default.rootData,I.default.data),e.dynamicRef&&t.var(I.default.dynamicAnchors,(0,T._)`{}`)})}function S$(t){let{schema:e,opts:r,gen:n}=t;__(t,()=>{r.$comment&&e.$comment&&w_(t),k$(t),n.let(I.default.vErrors,null),n.let(I.default.errors,0),r.unevaluated&&v$(t),E_(t),P$(t)})}function v$(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,T._)`${r}.evaluated`),e.if((0,T._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,T._)`${t.evaluated}.props`,(0,T._)`undefined`)),e.if((0,T._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,T._)`${t.evaluated}.items`,(0,T._)`undefined`))}function f_(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,T._)`/*# sourceURL=${r} */`:T.nil}function E$(t,e){if(S_(t)&&(v_(t),y_(t))){w$(t,e);return}(0,g_.boolOrEmptySchema)(t,e)}function y_({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function S_(t){return typeof t.schema!="boolean"}function w$(t,e){let{schema:r,gen:n,opts:o}=t;o.$comment&&r.$comment&&w_(t),x$(t),$$(t);let s=n.const("_errs",I.default.errors);E_(t,s),n.var(e,(0,T._)`${s} === ${I.default.errors}`)}function v_(t){(0,Ot.checkUnknownRules)(t),b$(t)}function E_(t,e){if(t.opts.jtd)return m_(t,[],!1,e);let r=(0,p_.getSchemaTypes)(t.schema),n=(0,p_.coerceAndCheckDataType)(t,r);m_(t,r,!n,e)}function b$(t){let{schema:e,errSchemaPath:r,opts:n,self:o}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,Ot.schemaHasRulesButRef)(e,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function k$(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Ot.checkStrictMode)(t,"default is ignored in the schema root")}function x$(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,h$.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function $$(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function w_({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)t.code((0,T._)`${I.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,T.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,T._)`${I.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function P$(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=t;r.$async?e.if((0,T._)`${I.default.errors} === 0`,()=>e.return(I.default.data),()=>e.throw((0,T._)`new ${o}(${I.default.vErrors})`)):(e.assign((0,T._)`${n}.errors`,I.default.vErrors),s.unevaluated&&T$(t),e.return((0,T._)`${I.default.errors} === 0`))}function T$({gen:t,evaluated:e,props:r,items:n}){r instanceof T.Name&&t.assign((0,T._)`${e}.props`,r),n instanceof T.Name&&t.assign((0,T._)`${e}.items`,n)}function m_(t,e,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:u}=t,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,Ot.schemaHasRulesButRef)(s,l))){o.block(()=>k_(t,"$ref",l.all.$ref.definition));return}c.jtd||O$(t,e),o.block(()=>{for(let p of l.rules)d(p);d(l.post)});function d(p){(0,Hc.shouldUseGroup)(s,p)&&(p.type?(o.if((0,$s.checkDataType)(p.type,i,c.strictNumbers)),h_(t,p),e.length===1&&e[0]===p.type&&r&&(o.else(),(0,$s.reportTypeError)(t)),o.endIf()):h_(t,p),a||o.if((0,T._)`${I.default.errors} === ${n||0}`))}}function h_(t,e){let{gen:r,schema:n,opts:{useDefaults:o}}=t;o&&(0,m$.assignDefaults)(t,e.type),r.block(()=>{for(let s of e.rules)(0,Hc.shouldUseRule)(n,s)&&k_(t,s.keyword,s.definition,e.type)})}function O$(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(z$(t,e),t.opts.allowUnionTypes||R$(t,e),I$(t,t.dataTypes))}function z$(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{b_(t.dataTypes,r)||Wc(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),A$(t,e)}}function R$(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&Wc(t,"use allowUnionTypes to allow union type keyword")}function I$(t,e){let r=t.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,Hc.shouldUseRule)(t.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>C$(e,i))&&Wc(t,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function C$(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function b_(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function A$(t,e){let r=[];for(let n of t.dataTypes)b_(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function Wc(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Ot.checkStrictMode)(t,e,t.opts.strictTypes)}var Ps=class{constructor(e,r,n){if((0,Xn.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Ot.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",x_(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,Xn.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=e.gen.const("_errs",I.default.errors))}result(e,r,n){this.failResult((0,T.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,T.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,T._)`${r} !== undefined && (${(0,T.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?Yn.reportExtraError:Yn.reportError)(this,this.def.error,r)}$dataError(){(0,Yn.reportError)(this,this.def.$dataError||Yn.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Yn.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=T.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=T.nil,r=T.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,T.or)((0,T._)`${o} === undefined`,r)),e!==T.nil&&n.assign(e,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==T.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,T.or)(i(),a());function i(){if(n.length){if(!(r instanceof T.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,T._)`${(0,$s.checkDataTypes)(c,r,s.opts.strictNumbers,$s.DataType.Wrong)}`}return T.nil}function a(){if(o.validateSchema){let c=e.scopeValue("validate$data",{ref:o.validateSchema});return(0,T._)`!${c}(${r})`}return T.nil}}subschema(e,r){let n=(0,qc.getSubschema)(this.it,e);(0,qc.extendSubschemaData)(n,this.it,e),(0,qc.extendSubschemaMode)(n,e);let o={...this.it,...n,items:void 0,props:void 0};return E$(o,r),o}mergeEvaluated(e,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Ot.mergeEvaluated.props(o,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=Ot.mergeEvaluated.items(o,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(e,T.Name)),!0}};Wt.KeywordCxt=Ps;function k_(t,e,r,n){let o=new Ps(t,r,e);"code"in r?r.code(o,n):o.$data&&r.validate?(0,Xn.funcKeywordCode)(o,r):"macro"in r?(0,Xn.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,Xn.funcKeywordCode)(o,r)}var M$=/^\/(?:[^~]|~0|~1)*$/,N$=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function x_(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let o,s;if(t==="")return I.default.rootData;if(t[0]==="/"){if(!M$.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);o=t,s=I.default.rootData}else{let u=N$.exec(t);if(!u)throw new Error(`Invalid JSON-pointer: ${t}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=e)throw new Error(c("property/index",l));return n[e-l]}if(l>e)throw new Error(c("data",l));if(s=r[e-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,T._)`${s}${(0,T.getProperty)((0,Ot.unescapeJsonPointer)(u))}`,i=(0,T._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${e}`}}Wt.getData=x_});var Ts=E(Kc=>{"use strict";Object.defineProperty(Kc,"__esModule",{value:!0});var Vc=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};Kc.default=Vc});var eo=E(Bc=>{"use strict";Object.defineProperty(Bc,"__esModule",{value:!0});var Jc=Bn(),Gc=class extends Error{constructor(e,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Jc.resolveUrl)(e,r,n),this.missingSchema=(0,Jc.normalizeId)((0,Jc.getFullPath)(e,this.missingRef))}};Bc.default=Gc});var zs=E(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.resolveSchema=Qe.getCompilingSchema=Qe.resolveRef=Qe.compileSchema=Qe.SchemaEnv=void 0;var it=M(),D$=Ts(),pr=Tt(),at=Bn(),$_=Z(),L$=Qn(),Zr=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,at.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};Qe.SchemaEnv=Zr;function Xc(t){let e=P_.call(this,t);if(e)return e;let r=(0,at.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new it.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;t.$async&&(a=i.scopeValue("Error",{ref:D$.default,code:(0,it._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:pr.default.data,parentData:pr.default.parentData,parentDataProperty:pr.default.parentDataProperty,dataNames:[pr.default.data],dataPathArr:[it.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,it.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:it.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,it._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,L$.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(pr.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let m=new Function(`${pr.default.self}`,`${pr.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:m}),m.errors=null,m.schema=t.schema,m.schemaEnv=t,t.$async&&(m.$async=!0),this.opts.code.source===!0&&(m.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:h,items:y}=u;m.evaluated={props:h instanceof it.Name?void 0:h,items:y instanceof it.Name?void 0:y,dynamicProps:h instanceof it.Name,dynamicItems:y instanceof it.Name},m.source&&(m.source.evaluated=(0,it.stringify)(m.evaluated))}return t.validate=m,t}catch(d){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(t)}}Qe.compileSchema=Xc;function j$(t,e,r){var n;r=(0,at.resolveUrl)(this.opts.uriResolver,e,r);let o=t.refs[r];if(o)return o;let s=Z$.call(this,t,r);if(s===void 0){let i=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new Zr({schema:i,schemaId:a,root:t,baseId:e}))}if(s!==void 0)return t.refs[r]=U$.call(this,s)}Qe.resolveRef=j$;function U$(t){return(0,at.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:Xc.call(this,t)}function P_(t){for(let e of this._compilations)if(F$(e,t))return e}Qe.getCompilingSchema=P_;function F$(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function Z$(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||Os.call(this,t,e)}function Os(t,e){let r=this.opts.uriResolver.parse(e),n=(0,at._getFullPath)(this.opts.uriResolver,r),o=(0,at.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===o)return Yc.call(this,r,t);let s=(0,at.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=Os.call(this,t,i);return typeof a?.schema!="object"?void 0:Yc.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Xc.call(this,i),s===(0,at.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,at.resolveUrl)(this.opts.uriResolver,o,u)),new Zr({schema:a,schemaId:c,root:t,baseId:o})}return Yc.call(this,r,i)}}Qe.resolveSchema=Os;var q$=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Yc(t,{baseId:e,schema:r,root:n}){var o;if(((o=t.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,$_.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!q$.has(a)&&u&&(e=(0,at.resolveUrl)(this.opts.uriResolver,e,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,$_.schemaHasRulesButRef)(r,this.RULES)){let a=(0,at.resolveUrl)(this.opts.uriResolver,e,r.$ref);s=Os.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new Zr({schema:r,schemaId:i,root:n,baseId:e}),s.schema!==s.root.schema)return s}});var T_=E((Z1,H$)=>{H$.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 tu=E((q1,A_)=>{"use strict";var W$=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),z_=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),Qc=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),R_=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),V$=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function eu(t){let e="",r=0,n=0;for(n=0;n<t.length;n++)if(r=t[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n];break}for(n+=1;n<t.length;n++){if(r=t[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n]}return e}var K$=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function O_(t){return t.length=0,!0}function J$(t,e,r){if(t.length){let n=eu(t);if(n!=="")e.push(n);else return r.error=!0,!1;t.length=0}return!0}function G$(t){let e=0,r={error:!1,address:"",zone:""},n=[],o=[],s=!1,i=!1,a=J$;for(let c=0;c<t.length;c++){let u=t[c];if(!(u==="["||u==="]"))if(u===":"){if(s===!0&&(i=!0),!a(o,n,r))break;if(++e>7){r.error=!0;break}c>0&&t[c-1]===":"&&(s=!0),n.push(":");continue}else if(u==="%"){if(!a(o,n,r))break;a=O_}else{o.push(u);continue}}return o.length&&(a===O_?r.zone=o.join(""):i?n.push(o.join("")):n.push(eu(o))),r.address=n.join(""),r}function I_(t){if(B$(t,":")<2)return{host:t,isIPV6:!1};let e=G$(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,isIPV6:!0,escapedHost:n}}}function B$(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function Y$(t){let e=t,r=[],n=-1,o=0;for(;o=e.length;){if(o===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(o===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(o===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((n=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,n)),e=e.slice(n)}return r.join("")}var X$={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},Q$=/[@/?#:]/g,eP=/[@/?#]/g;function C_(t,e){let r=e?eP:Q$;return r.lastIndex=0,t.replace(r,n=>X$[n])}function tP(t,e=!1){if(t.indexOf("%")===-1)return t;let r="";for(let n=0;n<t.length;n++){if(t[n]==="%"&&n+2<t.length){let o=t.slice(n+1,n+3);if(Qc(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));e&&R_(i)?r+=i:r+="%"+s,n+=2;continue}}r+=t[n]}return r}function rP(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(Qc(n)){let o=n.toUpperCase(),s=String.fromCharCode(parseInt(o,16));s!=="."&&R_(s)?e+=s:e+="%"+o,r+=2;continue}}V$(t[r])?e+=t[r]:e+=escape(t[r])}return e}function nP(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(Qc(n)){e+="%"+n.toUpperCase(),r+=2;continue}}e+=escape(t[r])}return e}function oP(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!z_(r)){let n=I_(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=C_(r,!1)}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}A_.exports={nonSimpleDomain:K$,recomposeAuthority:oP,reescapeHostDelimiters:C_,normalizePercentEncoding:tP,normalizePathEncoding:rP,escapePreservingEscapes:nP,removeDotSegments:Y$,isIPv4:z_,isUUID:W$,normalizeIPv6:I_,stringArrayToHexStripped:eu}});var j_=E((H1,L_)=>{"use strict";var{isUUID:sP}=tu(),iP=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,aP=["http","https","ws","wss","urn","urn:uuid"];function cP(t){return aP.indexOf(t)!==-1}function ru(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function M_(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function N_(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function uP(t){return t.secure=ru(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function lP(t){if((t.port===(ru(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function dP(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(iP);if(r){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let o=`${n}:${e.nid||t.nid}`,s=nu(o);t.path=void 0,s&&(t=s.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function pP(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),o=`${r}:${e.nid||n}`,s=nu(o);s&&(t=s.serialize(t,e));let i=t,a=t.nss;return i.path=`${n||e.nid}:${a}`,e.skipEscape=!0,i}function fP(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!sP(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function mP(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var D_={scheme:"http",domainHost:!0,parse:M_,serialize:N_},hP={scheme:"https",domainHost:D_.domainHost,parse:M_,serialize:N_},Rs={scheme:"ws",domainHost:!0,parse:uP,serialize:lP},gP={scheme:"wss",domainHost:Rs.domainHost,parse:Rs.parse,serialize:Rs.serialize},_P={scheme:"urn",parse:dP,serialize:pP,skipNormalize:!0},yP={scheme:"urn:uuid",parse:fP,serialize:mP,skipNormalize:!0},Is={http:D_,https:hP,ws:Rs,wss:gP,urn:_P,"urn:uuid":yP};Object.setPrototypeOf(Is,null);function nu(t){return t&&(Is[t]||Is[t.toLowerCase()])||void 0}L_.exports={wsIsSecure:ru,SCHEMES:Is,isValidSchemeName:cP,getSchemeHandler:nu}});var W_=E((W1,Cs)=>{"use strict";var{normalizeIPv6:SP,removeDotSegments:to,recomposeAuthority:vP,normalizePercentEncoding:EP,normalizePathEncoding:wP,escapePreservingEscapes:bP,reescapeHostDelimiters:kP,isIPv4:xP,nonSimpleDomain:$P}=tu(),{SCHEMES:PP,getSchemeHandler:F_}=j_();function TP(t,e){return typeof t=="string"?t=CP(t,e):typeof t=="object"&&(t=qr(fr(t,e),e)),t}function OP(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=Z_(qr(t,n),qr(e,n),n,!0);return n.skipEscape=!0,fr(o,n)}function Z_(t,e,r,n){let o={};return n||(t=qr(fr(t,r),r),e=qr(fr(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(o.scheme=e.scheme,o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=to(e.path||""),o.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=to(e.path||""),o.query=e.query):(e.path?(e.path[0]==="/"?o.path=to(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?o.path="/"+e.path:t.path?o.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:o.path=e.path,o.path=to(o.path)),o.query=e.query):(o.path=t.path,e.query!==void 0?o.query=e.query:o.query=t.query),o.userinfo=t.userinfo,o.host=t.host,o.port=t.port),o.scheme=t.scheme),o.fragment=e.fragment,o}function zP(t,e,r){let n=U_(t,r),o=U_(e,r);return n!==void 0&&o!==void 0&&n.toLowerCase()===o.toLowerCase()}function fr(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},e),o=[],s=F_(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=EP(r.path):(r.path=bP(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&o.push(r.scheme,":");let i=vP(r);if(i!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(i),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(a=to(a)),i===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),o.push(a)}return r.query!==void 0&&o.push("?",r.query),r.fragment!==void 0&&o.push("#",r.fragment),o.join("")}var RP=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function IP(t,e){if(e[2]!==void 0&&t.path&&t.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof t.port=="number"&&(t.port<0||t.port>65535))return"URI port is malformed."}function q_(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1,s=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let i=t.match(RP);if(i){n.scheme=i[1],n.userinfo=i[3],n.host=i[4],n.port=parseInt(i[5],10),n.path=i[6]||"",n.query=i[7],n.fragment=i[8],isNaN(n.port)&&(n.port=i[5]);let a=IP(n,i);if(a!==void 0&&(n.error=n.error||a,o=!0),n.host)if(xP(n.host)===!1){let l=SP(n.host);n.host=l.host.toLowerCase(),s=l.isIPV6}else s=!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 c=F_(r.scheme||n.scheme);if(!r.unicodeSupport&&(!c||!c.unicodeSupport)&&n.host&&(r.domainHost||c&&c.domainHost)&&s===!1&&$P(n.host))try{n.host=new URL("http://"+n.host).hostname}catch(u){n.error=n.error||"Host's domain name can not be converted to ASCII: "+u}if((!c||c&&!c.skipNormalize)&&(t.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=kP(unescape(n.host),s))),n.path&&(n.path=wP(n.path)),n.fragment))try{n.fragment=encodeURI(decodeURIComponent(n.fragment))}catch{n.error=n.error||"URI malformed"}c&&c.parse&&c.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o}}function qr(t,e){return q_(t,e).parsed}function CP(t,e){return H_(t,e).normalized}function H_(t,e){let{parsed:r,malformedAuthorityOrPort:n}=q_(t,e);return{normalized:n?t:fr(r,e),malformedAuthorityOrPort:n}}function U_(t,e){if(typeof t=="string"){let{normalized:r,malformedAuthorityOrPort:n}=H_(t,e);return n?void 0:r}if(typeof t=="object")return fr(t,e)}var ou={SCHEMES:PP,normalize:TP,resolve:OP,resolveComponent:Z_,equal:zP,serialize:fr,parse:qr};Cs.exports=ou;Cs.exports.default=ou;Cs.exports.fastUri=ou});var K_=E(su=>{"use strict";Object.defineProperty(su,"__esModule",{value:!0});var V_=W_();V_.code='require("ajv/dist/runtime/uri").default';su.default=V_});var ty=E(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});ve.CodeGen=ve.Name=ve.nil=ve.stringify=ve.str=ve._=ve.KeywordCxt=void 0;var AP=Qn();Object.defineProperty(ve,"KeywordCxt",{enumerable:!0,get:function(){return AP.KeywordCxt}});var Hr=M();Object.defineProperty(ve,"_",{enumerable:!0,get:function(){return Hr._}});Object.defineProperty(ve,"str",{enumerable:!0,get:function(){return Hr.str}});Object.defineProperty(ve,"stringify",{enumerable:!0,get:function(){return Hr.stringify}});Object.defineProperty(ve,"nil",{enumerable:!0,get:function(){return Hr.nil}});Object.defineProperty(ve,"Name",{enumerable:!0,get:function(){return Hr.Name}});Object.defineProperty(ve,"CodeGen",{enumerable:!0,get:function(){return Hr.CodeGen}});var MP=Ts(),X_=eo(),NP=Cc(),ro=zs(),DP=M(),no=Bn(),As=Gn(),au=Z(),J_=T_(),LP=K_(),Q_=(t,e)=>new RegExp(t,e);Q_.code="new RegExp";var jP=["removeAdditional","useDefaults","coerceTypes"],UP=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),FP={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."},ZP={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},G_=200;function qP(t){var e,r,n,o,s,i,a,c,u,l,d,p,m,h,y,g,v,b,w,$,x,je,We,sn,ci;let an=t.strict,ui=(e=t.code)===null||e===void 0?void 0:e.optimize,Ol=ui===!0||ui===void 0?1:ui||0,zl=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:Q_,Rv=(o=t.uriResolver)!==null&&o!==void 0?o:LP.default;return{strictSchema:(i=(s=t.strictSchema)!==null&&s!==void 0?s:an)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:an)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=t.strictTypes)!==null&&u!==void 0?u:an)!==null&&l!==void 0?l:"log",strictTuples:(p=(d=t.strictTuples)!==null&&d!==void 0?d:an)!==null&&p!==void 0?p:"log",strictRequired:(h=(m=t.strictRequired)!==null&&m!==void 0?m:an)!==null&&h!==void 0?h:!1,code:t.code?{...t.code,optimize:Ol,regExp:zl}:{optimize:Ol,regExp:zl},loopRequired:(y=t.loopRequired)!==null&&y!==void 0?y:G_,loopEnum:(g=t.loopEnum)!==null&&g!==void 0?g:G_,meta:(v=t.meta)!==null&&v!==void 0?v:!0,messages:(b=t.messages)!==null&&b!==void 0?b:!0,inlineRefs:(w=t.inlineRefs)!==null&&w!==void 0?w:!0,schemaId:($=t.schemaId)!==null&&$!==void 0?$:"$id",addUsedSchema:(x=t.addUsedSchema)!==null&&x!==void 0?x:!0,validateSchema:(je=t.validateSchema)!==null&&je!==void 0?je:!0,validateFormats:(We=t.validateFormats)!==null&&We!==void 0?We:!0,unicodeRegExp:(sn=t.unicodeRegExp)!==null&&sn!==void 0?sn:!0,int32range:(ci=t.int32range)!==null&&ci!==void 0?ci:!0,uriResolver:Rv}}var oo=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...qP(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new DP.ValueScope({scope:{},prefixes:UP,es5:r,lines:n}),this.logger=GP(e.logger);let o=e.validateFormats;e.validateFormats=!1,this.RULES=(0,NP.getRules)(),B_.call(this,FP,e,"NOT SUPPORTED"),B_.call(this,ZP,e,"DEPRECATED","warn"),this._metaOpts=KP.call(this),e.formats&&WP.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&VP.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),HP.call(this),e.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,o=J_;n==="id"&&(o={...J_},o.id=o.$id,delete o.$id),r&&e&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,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,e,r);async function o(l,d){await s.call(this,l.$schema);let p=this._addSchema(l,d);return p.validate||i.call(this,p)}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 X_.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(e,r,n,o=this.opts.validateSchema){if(Array.isArray(e)){for(let i of e)this.addSchema(i,void 0,n,o);return this}let s;if(typeof e=="object"){let{schemaId:i}=this.opts;if(s=e[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,no.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,o,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$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,e);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(e){let r;for(;typeof(r=Y_.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,o=new ro.SchemaEnv({schema:{},schemaId:n});if(r=ro.resolveSchema.call(this,o,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=Y_.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,no.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,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(YP.call(this,n,r),!r)return(0,au.eachItem)(n,s=>iu.call(this,s)),this;QP.call(this,r);let o={...r,type:(0,As.getJSONTypes)(r.type),schemaType:(0,As.getJSONTypes)(r.schemaType)};return(0,au.eachItem)(n,o.type.length===0?s=>iu.call(this,s,o):s=>o.type.forEach(i=>iu.call(this,s,o,i))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===e);o>=0&&n.rules.splice(o,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let o of r){let s=o.split("/").slice(1),i=e;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]=ey(l))}}return e}_removeAllSchemas(e,r){for(let n in e){let o=e[n];(!r||r.test(n))&&(typeof o=="string"?delete e[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete e[n]))}}_addSchema(e,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof e=="object")i=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;n=(0,no.normalizeId)(i||n);let u=no.getSchemaRefs.call(this,e,n);return c=new ro.SchemaEnv({schema:e,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(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):ro.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{ro.compileSchema.call(this,e)}finally{this.opts=r}}};oo.ValidationError=MP.default;oo.MissingRefError=X_.default;ve.default=oo;function B_(t,e,r,n="error"){for(let o in t){let s=o;s in e&&this.logger[n](`${r}: option ${o}. ${t[s]}`)}}function Y_(t){return t=(0,no.normalizeId)(t),this.schemas[t]||this.refs[t]}function HP(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function WP(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function VP(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function KP(){let t={...this.opts};for(let e of jP)delete t[e];return t}var JP={log(){},warn(){},error(){}};function GP(t){if(t===!1)return JP;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var BP=/^[a-z_$][a-z0-9_$:-]*$/i;function YP(t,e){let{RULES:r}=this;if((0,au.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!BP.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function iu(t,e,r){var n;let o=e?.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[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,As.getJSONTypes)(e.type),schemaType:(0,As.getJSONTypes)(e.schemaType)}};e.before?XP.call(this,i,a,e.before):i.rules.push(a),s.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function XP(t,e,r){let n=t.rules.findIndex(o=>o.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function QP(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=ey(e)),t.validateSchema=this.compile(e,!0))}var eT={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function ey(t){return{anyOf:[t,eT]}}});var ry=E(cu=>{"use strict";Object.defineProperty(cu,"__esModule",{value:!0});var tT={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};cu.default=tT});var iy=E(mr=>{"use strict";Object.defineProperty(mr,"__esModule",{value:!0});mr.callRef=mr.getValidate=void 0;var rT=eo(),ny=Xe(),Le=M(),Wr=Tt(),oy=zs(),Ms=Z(),nT={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=oy.resolveRef.call(c,u,o,r);if(l===void 0)throw new rT.default(n.opts.uriResolver,o,r);if(l instanceof oy.SchemaEnv)return p(l);return m(l);function d(){if(s===u)return Ns(t,i,s,s.$async);let h=e.scopeValue("root",{ref:u});return Ns(t,(0,Le._)`${h}.validate`,u,u.$async)}function p(h){let y=sy(t,h);Ns(t,y,h,h.$async)}function m(h){let y=e.scopeValue("schema",a.code.source===!0?{ref:h,code:(0,Le.stringify)(h)}:{ref:h}),g=e.name("valid"),v=t.subschema({schema:h,dataTypes:[],schemaPath:Le.nil,topSchemaRef:y,errSchemaPath:r},g);t.mergeEvaluated(v),t.ok(g)}}};function sy(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Le._)`${r.scopeValue("wrapper",{ref:e})}.validate`}mr.getValidate=sy;function Ns(t,e,r,n){let{gen:o,it:s}=t,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?Wr.default.this:Le.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let h=o.let("valid");o.try(()=>{o.code((0,Le._)`await ${(0,ny.callValidateCode)(t,e,u)}`),m(e),i||o.assign(h,!0)},y=>{o.if((0,Le._)`!(${y} instanceof ${s.ValidationError})`,()=>o.throw(y)),p(y),i||o.assign(h,!1)}),t.ok(h)}function d(){t.result((0,ny.callValidateCode)(t,e,u),()=>m(e),()=>p(e))}function p(h){let y=(0,Le._)`${h}.errors`;o.assign(Wr.default.vErrors,(0,Le._)`${Wr.default.vErrors} === null ? ${y} : ${Wr.default.vErrors}.concat(${y})`),o.assign(Wr.default.errors,(0,Le._)`${Wr.default.vErrors}.length`)}function m(h){var y;if(!s.opts.unevaluated)return;let g=(y=r?.validate)===null||y===void 0?void 0:y.evaluated;if(s.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(s.props=Ms.mergeEvaluated.props(o,g.props,s.props));else{let v=o.var("props",(0,Le._)`${h}.evaluated.props`);s.props=Ms.mergeEvaluated.props(o,v,s.props,Le.Name)}if(s.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(s.items=Ms.mergeEvaluated.items(o,g.items,s.items));else{let v=o.var("items",(0,Le._)`${h}.evaluated.items`);s.items=Ms.mergeEvaluated.items(o,v,s.items,Le.Name)}}}mr.callRef=Ns;mr.default=nT});var ay=E(uu=>{"use strict";Object.defineProperty(uu,"__esModule",{value:!0});var oT=ry(),sT=iy(),iT=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",oT.default,sT.default];uu.default=iT});var cy=E(lu=>{"use strict";Object.defineProperty(lu,"__esModule",{value:!0});var Ds=M(),Vt=Ds.operators,Ls={maximum:{okStr:"<=",ok:Vt.LTE,fail:Vt.GT},minimum:{okStr:">=",ok:Vt.GTE,fail:Vt.LT},exclusiveMaximum:{okStr:"<",ok:Vt.LT,fail:Vt.GTE},exclusiveMinimum:{okStr:">",ok:Vt.GT,fail:Vt.LTE}},aT={message:({keyword:t,schemaCode:e})=>(0,Ds.str)`must be ${Ls[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,Ds._)`{comparison: ${Ls[t].okStr}, limit: ${e}}`},cT={keyword:Object.keys(Ls),type:"number",schemaType:"number",$data:!0,error:aT,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,Ds._)`${r} ${Ls[e].fail} ${n} || isNaN(${r})`)}};lu.default=cT});var uy=E(du=>{"use strict";Object.defineProperty(du,"__esModule",{value:!0});var so=M(),uT={message:({schemaCode:t})=>(0,so.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,so._)`{multipleOf: ${t}}`},lT={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:uT,code(t){let{gen:e,data:r,schemaCode:n,it:o}=t,s=o.opts.multipleOfPrecision,i=e.let("res"),a=s?(0,so._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,so._)`${i} !== parseInt(${i})`;t.fail$data((0,so._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};du.default=lT});var dy=E(pu=>{"use strict";Object.defineProperty(pu,"__esModule",{value:!0});function ly(t){let e=t.length,r=0,n=0,o;for(;n<e;)r++,o=t.charCodeAt(n++),o>=55296&&o<=56319&&n<e&&(o=t.charCodeAt(n),(o&64512)===56320&&n++);return r}pu.default=ly;ly.code='require("ajv/dist/runtime/ucs2length").default'});var py=E(fu=>{"use strict";Object.defineProperty(fu,"__esModule",{value:!0});var hr=M(),dT=Z(),pT=dy(),fT={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,hr.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,hr._)`{limit: ${t}}`},mT={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:fT,code(t){let{keyword:e,data:r,schemaCode:n,it:o}=t,s=e==="maxLength"?hr.operators.GT:hr.operators.LT,i=o.opts.unicode===!1?(0,hr._)`${r}.length`:(0,hr._)`${(0,dT.useFunc)(t.gen,pT.default)}(${r})`;t.fail$data((0,hr._)`${i} ${s} ${n}`)}};fu.default=mT});var fy=E(mu=>{"use strict";Object.defineProperty(mu,"__esModule",{value:!0});var hT=Xe(),gT=Z(),Vr=M(),_T={message:({schemaCode:t})=>(0,Vr.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,Vr._)`{pattern: ${t}}`},yT={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:_T,code(t){let{gen:e,data:r,$data:n,schema:o,schemaCode:s,it:i}=t,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,Vr._)`new RegExp`:(0,gT.useFunc)(e,c),l=e.let("valid");e.try(()=>e.assign(l,(0,Vr._)`${u}(${s}, ${a}).test(${r})`),()=>e.assign(l,!1)),t.fail$data((0,Vr._)`!${l}`)}else{let c=(0,hT.usePattern)(t,o);t.fail$data((0,Vr._)`!${c}.test(${r})`)}}};mu.default=yT});var my=E(hu=>{"use strict";Object.defineProperty(hu,"__esModule",{value:!0});var io=M(),ST={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,io.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,io._)`{limit: ${t}}`},vT={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:ST,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxProperties"?io.operators.GT:io.operators.LT;t.fail$data((0,io._)`Object.keys(${r}).length ${o} ${n}`)}};hu.default=vT});var hy=E(gu=>{"use strict";Object.defineProperty(gu,"__esModule",{value:!0});var ao=Xe(),co=M(),ET=Z(),wT={message:({params:{missingProperty:t}})=>(0,co.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,co._)`{missingProperty: ${t}}`},bT={keyword:"required",type:"object",schemaType:"array",$data:!0,error:wT,code(t){let{gen:e,schema:r,schemaCode:n,data:o,$data:s,it:i}=t,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let m=t.parentSchema.properties,{definedProperties:h}=t.it;for(let y of r)if(m?.[y]===void 0&&!h.has(y)){let g=i.schemaEnv.baseId+i.errSchemaPath,v=`required property "${y}" is not defined at "${g}" (strictRequired)`;(0,ET.checkStrictMode)(i,v,i.opts.strictRequired)}}function u(){if(c||s)t.block$data(co.nil,d);else for(let m of r)(0,ao.checkReportMissingProp)(t,m)}function l(){let m=e.let("missing");if(c||s){let h=e.let("valid",!0);t.block$data(h,()=>p(m,h)),t.ok(h)}else e.if((0,ao.checkMissingProp)(t,r,m)),(0,ao.reportMissingProp)(t,m),e.else()}function d(){e.forOf("prop",n,m=>{t.setParams({missingProperty:m}),e.if((0,ao.noPropertyInData)(e,o,m,a.ownProperties),()=>t.error())})}function p(m,h){t.setParams({missingProperty:m}),e.forOf(m,n,()=>{e.assign(h,(0,ao.propertyInData)(e,o,m,a.ownProperties)),e.if((0,co.not)(h),()=>{t.error(),e.break()})},co.nil)}}};gu.default=bT});var gy=E(_u=>{"use strict";Object.defineProperty(_u,"__esModule",{value:!0});var uo=M(),kT={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,uo.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,uo._)`{limit: ${t}}`},xT={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:kT,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxItems"?uo.operators.GT:uo.operators.LT;t.fail$data((0,uo._)`${r}.length ${o} ${n}`)}};_u.default=xT});var js=E(yu=>{"use strict";Object.defineProperty(yu,"__esModule",{value:!0});var _y=Fc();_y.code='require("ajv/dist/runtime/equal").default';yu.default=_y});var yy=E(vu=>{"use strict";Object.defineProperty(vu,"__esModule",{value:!0});var Su=Gn(),Ee=M(),$T=Z(),PT=js(),TT={message:({params:{i:t,j:e}})=>(0,Ee.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,Ee._)`{i: ${t}, j: ${e}}`},OT={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:TT,code(t){let{gen:e,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=t;if(!n&&!o)return;let c=e.let("valid"),u=s.items?(0,Su.getSchemaTypes)(s.items):[];t.block$data(c,l,(0,Ee._)`${i} === false`),t.ok(c);function l(){let h=e.let("i",(0,Ee._)`${r}.length`),y=e.let("j");t.setParams({i:h,j:y}),e.assign(c,!0),e.if((0,Ee._)`${h} > 1`,()=>(d()?p:m)(h,y))}function d(){return u.length>0&&!u.some(h=>h==="object"||h==="array")}function p(h,y){let g=e.name("item"),v=(0,Su.checkDataTypes)(u,g,a.opts.strictNumbers,Su.DataType.Wrong),b=e.const("indices",(0,Ee._)`{}`);e.for((0,Ee._)`;${h}--;`,()=>{e.let(g,(0,Ee._)`${r}[${h}]`),e.if(v,(0,Ee._)`continue`),u.length>1&&e.if((0,Ee._)`typeof ${g} == "string"`,(0,Ee._)`${g} += "_"`),e.if((0,Ee._)`typeof ${b}[${g}] == "number"`,()=>{e.assign(y,(0,Ee._)`${b}[${g}]`),t.error(),e.assign(c,!1).break()}).code((0,Ee._)`${b}[${g}] = ${h}`)})}function m(h,y){let g=(0,$T.useFunc)(e,PT.default),v=e.name("outer");e.label(v).for((0,Ee._)`;${h}--;`,()=>e.for((0,Ee._)`${y} = ${h}; ${y}--;`,()=>e.if((0,Ee._)`${g}(${r}[${h}], ${r}[${y}])`,()=>{t.error(),e.assign(c,!1).break(v)})))}}};vu.default=OT});var Sy=E(wu=>{"use strict";Object.defineProperty(wu,"__esModule",{value:!0});var Eu=M(),zT=Z(),RT=js(),IT={message:"must be equal to constant",params:({schemaCode:t})=>(0,Eu._)`{allowedValue: ${t}}`},CT={keyword:"const",$data:!0,error:IT,code(t){let{gen:e,data:r,$data:n,schemaCode:o,schema:s}=t;n||s&&typeof s=="object"?t.fail$data((0,Eu._)`!${(0,zT.useFunc)(e,RT.default)}(${r}, ${o})`):t.fail((0,Eu._)`${s} !== ${r}`)}};wu.default=CT});var vy=E(bu=>{"use strict";Object.defineProperty(bu,"__esModule",{value:!0});var lo=M(),AT=Z(),MT=js(),NT={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,lo._)`{allowedValues: ${t}}`},DT={keyword:"enum",schemaType:"array",$data:!0,error:NT,code(t){let{gen:e,data:r,$data:n,schema:o,schemaCode:s,it:i}=t;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,AT.useFunc)(e,MT.default)),l;if(a||n)l=e.let("valid"),t.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let m=e.const("vSchema",s);l=(0,lo.or)(...o.map((h,y)=>p(m,y)))}t.pass(l);function d(){e.assign(l,!1),e.forOf("v",s,m=>e.if((0,lo._)`${u()}(${r}, ${m})`,()=>e.assign(l,!0).break()))}function p(m,h){let y=o[h];return typeof y=="object"&&y!==null?(0,lo._)`${u()}(${r}, ${m}[${h}])`:(0,lo._)`${r} === ${y}`}}};bu.default=DT});var Ey=E(ku=>{"use strict";Object.defineProperty(ku,"__esModule",{value:!0});var LT=cy(),jT=uy(),UT=py(),FT=fy(),ZT=my(),qT=hy(),HT=gy(),WT=yy(),VT=Sy(),KT=vy(),JT=[LT.default,jT.default,UT.default,FT.default,ZT.default,qT.default,HT.default,WT.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},VT.default,KT.default];ku.default=JT});var $u=E(po=>{"use strict";Object.defineProperty(po,"__esModule",{value:!0});po.validateAdditionalItems=void 0;var gr=M(),xu=Z(),GT={message:({params:{len:t}})=>(0,gr.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,gr._)`{limit: ${t}}`},BT={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:GT,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,xu.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}wy(t,n)}};function wy(t,e){let{gen:r,schema:n,data:o,keyword:s,it:i}=t;i.items=!0;let a=r.const("len",(0,gr._)`${o}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,gr._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,xu.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,gr._)`${a} <= ${e.length}`);r.if((0,gr.not)(u),()=>c(u)),t.ok(u)}function c(u){r.forRange("i",e.length,a,l=>{t.subschema({keyword:s,dataProp:l,dataPropType:xu.Type.Num},u),i.allErrors||r.if((0,gr.not)(u),()=>r.break())})}}po.validateAdditionalItems=wy;po.default=BT});var Pu=E(fo=>{"use strict";Object.defineProperty(fo,"__esModule",{value:!0});fo.validateTuple=void 0;var by=M(),Us=Z(),YT=Xe(),XT={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return ky(t,"additionalItems",e);r.items=!0,!(0,Us.alwaysValidSchema)(r,e)&&t.ok((0,YT.validateArray)(t))}};function ky(t,e,r=t.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=t;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=Us.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,by._)`${s}.length`);r.forEach((d,p)=>{(0,Us.alwaysValidSchema)(a,d)||(n.if((0,by._)`${u} > ${p}`,()=>t.subschema({keyword:i,schemaProp:p,dataProp:p},c)),t.ok(c))});function l(d){let{opts:p,errSchemaPath:m}=a,h=r.length,y=h===d.minItems&&(h===d.maxItems||d[e]===!1);if(p.strictTuples&&!y){let g=`"${i}" is ${h}-tuple, but minItems or maxItems/${e} are not specified or different at path "${m}"`;(0,Us.checkStrictMode)(a,g,p.strictTuples)}}}fo.validateTuple=ky;fo.default=XT});var xy=E(Tu=>{"use strict";Object.defineProperty(Tu,"__esModule",{value:!0});var QT=Pu(),eO={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,QT.validateTuple)(t,"items")};Tu.default=eO});var Py=E(Ou=>{"use strict";Object.defineProperty(Ou,"__esModule",{value:!0});var $y=M(),tO=Z(),rO=Xe(),nO=$u(),oO={message:({params:{len:t}})=>(0,$y.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,$y._)`{limit: ${t}}`},sO={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:oO,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:o}=r;n.items=!0,!(0,tO.alwaysValidSchema)(n,e)&&(o?(0,nO.validateAdditionalItems)(t,o):t.ok((0,rO.validateArray)(t)))}};Ou.default=sO});var Ty=E(zu=>{"use strict";Object.defineProperty(zu,"__esModule",{value:!0});var et=M(),Fs=Z(),iO={message:({params:{min:t,max:e}})=>e===void 0?(0,et.str)`must contain at least ${t} valid item(s)`:(0,et.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,et._)`{minContains: ${t}}`:(0,et._)`{minContains: ${t}, maxContains: ${e}}`},aO={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:iO,code(t){let{gen:e,schema:r,parentSchema:n,data:o,it:s}=t,i,a,{minContains:c,maxContains:u}=n;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=e.const("len",(0,et._)`${o}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,Fs.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,Fs.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,Fs.alwaysValidSchema)(s,r)){let y=(0,et._)`${l} >= ${i}`;a!==void 0&&(y=(0,et._)`${y} && ${l} <= ${a}`),t.pass(y);return}s.items=!0;let d=e.name("valid");a===void 0&&i===1?m(d,()=>e.if(d,()=>e.break())):i===0?(e.let(d,!0),a!==void 0&&e.if((0,et._)`${o}.length > 0`,p)):(e.let(d,!1),p()),t.result(d,()=>t.reset());function p(){let y=e.name("_valid"),g=e.let("count",0);m(y,()=>e.if(y,()=>h(g)))}function m(y,g){e.forRange("i",0,l,v=>{t.subschema({keyword:"contains",dataProp:v,dataPropType:Fs.Type.Num,compositeRule:!0},y),g()})}function h(y){e.code((0,et._)`${y}++`),a===void 0?e.if((0,et._)`${y} >= ${i}`,()=>e.assign(d,!0).break()):(e.if((0,et._)`${y} > ${a}`,()=>e.assign(d,!1).break()),i===1?e.assign(d,!0):e.if((0,et._)`${y} >= ${i}`,()=>e.assign(d,!0)))}}};zu.default=aO});var Ry=E(_t=>{"use strict";Object.defineProperty(_t,"__esModule",{value:!0});_t.validateSchemaDeps=_t.validatePropertyDeps=_t.error=void 0;var Ru=M(),cO=Z(),mo=Xe();_t.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,Ru.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,Ru._)`{property: ${t},
|
|
10
10
|
missingProperty: ${n},
|
|
11
11
|
depsCount: ${e},
|
|
12
|
-
deps: ${r}}`};var uO={keyword:"dependencies",type:"object",schemaType:"object",error:_t.error,code(t){let[e,r]=lO(t);Oy(t,e),zy(t,r)}};function lO({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let o=Array.isArray(t[n])?e:r;o[n]=t[n]}return[e,r]}function Oy(t,e=t.schema){let{gen:r,data:n,it:o}=t;if(Object.keys(e).length===0)return;let s=r.let("missing");for(let i in e){let a=e[i];if(a.length===0)continue;let c=(0,mo.propertyInData)(r,n,i,o.opts.ownProperties);t.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,mo.checkReportMissingProp)(t,u)}):(r.if((0,Ru._)`${c} && (${(0,mo.checkMissingProp)(t,a,s)})`),(0,mo.reportMissingProp)(t,s),r.else())}}_t.validatePropertyDeps=Oy;function zy(t,e=t.schema){let{gen:r,data:n,keyword:o,it:s}=t,i=r.name("valid");for(let a in e)(0,cO.alwaysValidSchema)(s,e[a])||(r.if((0,mo.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=t.subschema({keyword:o,schemaProp:a},i);t.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),t.ok(i))}_t.validateSchemaDeps=zy;_t.default=uO});var Cy=E(Iu=>{"use strict";Object.defineProperty(Iu,"__esModule",{value:!0});var Iy=M(),dO=Z(),pO={message:"property name must be valid",params:({params:t})=>(0,Iy._)`{propertyName: ${t.propertyName}}`},fO={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:pO,code(t){let{gen:e,schema:r,data:n,it:o}=t;if((0,dO.alwaysValidSchema)(o,r))return;let s=e.name("valid");e.forIn("key",n,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),e.if((0,Iy.not)(s),()=>{t.error(!0),o.allErrors||e.break()})}),t.ok(s)}};Iu.default=fO});var Au=E(Cu=>{"use strict";Object.defineProperty(Cu,"__esModule",{value:!0});var Zs=Xe(),ct=M(),mO=Tt(),qs=Z(),hO={message:"must NOT have additional properties",params:({params:t})=>(0,ct._)`{additionalProperty: ${t.additionalProperty}}`},gO={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:hO,code(t){let{gen:e,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=t;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,qs.alwaysValidSchema)(i,r))return;let u=(0,Zs.allSchemaProperties)(n.properties),l=(0,Zs.allSchemaProperties)(n.patternProperties);d(),t.ok((0,ct._)`${s} === ${mO.default.errors}`);function d(){e.forIn("key",o,g=>{!u.length&&!l.length?h(g):e.if(p(g),()=>h(g))})}function p(g){let v;if(u.length>8){let b=(0,qs.schemaRefOrVal)(i,n.properties,"properties");v=(0,Zs.isOwnProperty)(e,b,g)}else u.length?v=(0,ct.or)(...u.map(b=>(0,ct._)`${g} === ${b}`)):v=ct.nil;return l.length&&(v=(0,ct.or)(v,...l.map(b=>(0,ct._)`${(0,Zs.usePattern)(t,b)}.test(${g})`))),(0,ct.not)(v)}function m(g){e.code((0,ct._)`delete ${o}[${g}]`)}function h(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){m(g);return}if(r===!1){t.setParams({additionalProperty:g}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,qs.alwaysValidSchema)(i,r)){let v=e.name("valid");c.removeAdditional==="failing"?(y(g,v,!1),e.if((0,ct.not)(v),()=>{t.reset(),m(g)})):(y(g,v),a||e.if((0,ct.not)(v),()=>e.break()))}}function y(g,v,b){let w={keyword:"additionalProperties",dataProp:g,dataPropType:qs.Type.Str};b===!1&&Object.assign(w,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(w,v)}}};Cu.default=gO});var Ny=E(Nu=>{"use strict";Object.defineProperty(Nu,"__esModule",{value:!0});var _O=Qn(),Ay=Xe(),Mu=Z(),My=Au(),yO={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:o,it:s}=t;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&My.default.code(new _O.KeywordCxt(s,My.default,"additionalProperties"));let i=(0,Ay.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=Mu.mergeEvaluated.props(e,(0,Mu.toHash)(i),s.props));let a=i.filter(d=>!(0,Mu.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)u(d)?l(d):(e.if((0,Ay.propertyInData)(e,o,d,s.opts.ownProperties)),l(d),s.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};Nu.default=yO});var Uy=E(Du=>{"use strict";Object.defineProperty(Du,"__esModule",{value:!0});var Dy=Xe(),Hs=M(),Ly=Z(),jy=Z(),SO={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:o,it:s}=t,{opts:i}=s,a=(0,Dy.allSchemaProperties)(r),c=a.filter(y=>(0,Ly.alwaysValidSchema)(s,r[y]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=e.name("valid");s.props!==!0&&!(s.props instanceof Hs.Name)&&(s.props=(0,jy.evaluatedPropsToName)(e,s.props));let{props:d}=s;p();function p(){for(let y of a)u&&m(y),s.allErrors?h(y):(e.var(l,!0),h(y),e.if(l))}function m(y){for(let g in u)new RegExp(y).test(g)&&(0,Ly.checkStrictMode)(s,`property ${g} matches pattern ${y} (use allowMatchingProperties)`)}function h(y){e.forIn("key",n,g=>{e.if((0,Hs._)`${(0,Dy.usePattern)(t,y)}.test(${g})`,()=>{let v=c.includes(y);v||t.subschema({keyword:"patternProperties",schemaProp:y,dataProp:g,dataPropType:jy.Type.Str},l),s.opts.unevaluated&&d!==!0?e.assign((0,Hs._)`${d}[${g}]`,!0):!v&&!s.allErrors&&e.if((0,Hs.not)(l),()=>e.break())})})}}};Du.default=SO});var Fy=E(Lu=>{"use strict";Object.defineProperty(Lu,"__esModule",{value:!0});var vO=Z(),EO={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,vO.alwaysValidSchema)(n,r)){t.fail();return}let o=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),t.failResult(o,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};Lu.default=EO});var Zy=E(ju=>{"use strict";Object.defineProperty(ju,"__esModule",{value:!0});var wO=Xe(),bO={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:wO.validateUnion,error:{message:"must match a schema in anyOf"}};ju.default=bO});var qy=E(Uu=>{"use strict";Object.defineProperty(Uu,"__esModule",{value:!0});var Ws=M(),kO=Z(),xO={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,Ws._)`{passingSchemas: ${t.passing}}`},$O={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:xO,code(t){let{gen:e,schema:r,parentSchema:n,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(u),t.result(i,()=>t.reset(),()=>t.error(!0));function u(){s.forEach((l,d)=>{let p;(0,kO.alwaysValidSchema)(o,l)?e.var(c,!0):p=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,Ws._)`${c} && ${i}`).assign(i,!1).assign(a,(0,Ws._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,d),p&&t.mergeEvaluated(p,Ws.Name)})})}}};Uu.default=$O});var Hy=E(Fu=>{"use strict";Object.defineProperty(Fu,"__esModule",{value:!0});var PO=Z(),TO={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=e.name("valid");r.forEach((s,i)=>{if((0,PO.alwaysValidSchema)(n,s))return;let a=t.subschema({keyword:"allOf",schemaProp:i},o);t.ok(o),t.mergeEvaluated(a)})}};Fu.default=TO});var Vy=E(Zu=>{"use strict";Object.defineProperty(Zu,"__esModule",{value:!0});var Ks=M(),Ky=Z(),OO={message:({params:t})=>(0,Ks.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,Ks._)`{failingKeyword: ${t.ifClause}}`},zO={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:OO,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,Ky.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=Wy(n,"then"),s=Wy(n,"else");if(!o&&!s)return;let i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),o&&s){let l=e.let("ifClause");t.setParams({ifClause:l}),e.if(a,u("then",l),u("else",l))}else o?e.if(a,u("then")):e.if((0,Ks.not)(a),u("else"));t.pass(i,()=>t.error(!0));function c(){let l=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(l)}function u(l,d){return()=>{let p=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(p,i),d?e.assign(d,(0,Ks._)`${l}`):t.setParams({ifClause:l})}}}};function Wy(t,e){let r=t.schema[e];return r!==void 0&&!(0,Ky.alwaysValidSchema)(t,r)}Zu.default=zO});var Jy=E(qu=>{"use strict";Object.defineProperty(qu,"__esModule",{value:!0});var RO=Z(),IO={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,RO.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};qu.default=IO});var Gy=E(Hu=>{"use strict";Object.defineProperty(Hu,"__esModule",{value:!0});var CO=$u(),AO=xy(),MO=Pu(),NO=Py(),DO=Ty(),LO=Ry(),jO=Cy(),UO=Au(),FO=Ny(),ZO=Uy(),qO=Fy(),HO=Zy(),WO=qy(),KO=Hy(),VO=Vy(),JO=Jy();function GO(t=!1){let e=[qO.default,HO.default,WO.default,KO.default,VO.default,JO.default,jO.default,UO.default,LO.default,FO.default,ZO.default];return t?e.push(AO.default,NO.default):e.push(CO.default,MO.default),e.push(DO.default),e}Hu.default=GO});var By=E(Wu=>{"use strict";Object.defineProperty(Wu,"__esModule",{value:!0});var ce=M(),BO={message:({schemaCode:t})=>(0,ce.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,ce._)`{format: ${t}}`},YO={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:BO,code(t,e){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?p():m();function p(){let h=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),y=r.const("fDef",(0,ce._)`${h}[${i}]`),g=r.let("fType"),v=r.let("format");r.if((0,ce._)`typeof ${y} == "object" && !(${y} instanceof RegExp)`,()=>r.assign(g,(0,ce._)`${y}.type || "string"`).assign(v,(0,ce._)`${y}.validate`),()=>r.assign(g,(0,ce._)`"string"`).assign(v,y)),t.fail$data((0,ce.or)(b(),w()));function b(){return c.strictSchema===!1?ce.nil:(0,ce._)`${i} && !${v}`}function w(){let $=l.$async?(0,ce._)`(${y}.async ? await ${v}(${n}) : ${v}(${n}))`:(0,ce._)`${v}(${n})`,x=(0,ce._)`(typeof ${v} == "function" ? ${$} : ${v}.test(${n}))`;return(0,ce._)`${v} && ${v} !== true && ${g} === ${e} && !${x}`}}function m(){let h=d.formats[s];if(!h){b();return}if(h===!0)return;let[y,g,v]=w(h);y===e&&t.pass($());function b(){if(c.strictSchema===!1){d.logger.warn(x());return}throw new Error(x());function x(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function w(x){let je=x instanceof RegExp?(0,ce.regexpCode)(x):c.code.formats?(0,ce._)`${c.code.formats}${(0,ce.getProperty)(s)}`:void 0,We=r.scopeValue("formats",{key:s,ref:x,code:je});return typeof x=="object"&&!(x instanceof RegExp)?[x.type||"string",x.validate,(0,ce._)`${We}.validate`]:["string",x,We]}function $(){if(typeof h=="object"&&!(h instanceof RegExp)&&h.async){if(!l.$async)throw new Error("async format in sync schema");return(0,ce._)`await ${v}(${n})`}return typeof g=="function"?(0,ce._)`${v}(${n})`:(0,ce._)`${v}.test(${n})`}}}};Wu.default=YO});var Yy=E(Ku=>{"use strict";Object.defineProperty(Ku,"__esModule",{value:!0});var XO=By(),QO=[XO.default];Ku.default=QO});var Xy=E(Vr=>{"use strict";Object.defineProperty(Vr,"__esModule",{value:!0});Vr.contentVocabulary=Vr.metadataVocabulary=void 0;Vr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Vr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var eS=E(Vu=>{"use strict";Object.defineProperty(Vu,"__esModule",{value:!0});var ez=ay(),tz=Ey(),rz=Gy(),nz=Yy(),Qy=Xy(),oz=[ez.default,tz.default,(0,rz.default)(),nz.default,Qy.metadataVocabulary,Qy.contentVocabulary];Vu.default=oz});var rS=E(Vs=>{"use strict";Object.defineProperty(Vs,"__esModule",{value:!0});Vs.DiscrError=void 0;var tS;(function(t){t.Tag="tag",t.Mapping="mapping"})(tS||(Vs.DiscrError=tS={}))});var oS=E(Gu=>{"use strict";Object.defineProperty(Gu,"__esModule",{value:!0});var Jr=M(),Ju=rS(),nS=zs(),sz=eo(),iz=Z(),az={message:({params:{discrError:t,tagName:e}})=>t===Ju.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,Jr._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},cz={keyword:"discriminator",type:"object",schemaType:"object",error:az,code(t){let{gen:e,data:r,schema:n,parentSchema:o,it:s}=t,{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=e.let("valid",!1),u=e.const("tag",(0,Jr._)`${r}${(0,Jr.getProperty)(a)}`);e.if((0,Jr._)`typeof ${u} == "string"`,()=>l(),()=>t.error(!1,{discrError:Ju.DiscrError.Tag,tag:u,tagName:a})),t.ok(c);function l(){let m=p();e.if(!1);for(let h in m)e.elseIf((0,Jr._)`${u} === ${h}`),e.assign(c,d(m[h]));e.else(),t.error(!1,{discrError:Ju.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function d(m){let h=e.name("valid"),y=t.subschema({keyword:"oneOf",schemaProp:m},h);return t.mergeEvaluated(y,Jr.Name),h}function p(){var m;let h={},y=v(o),g=!0;for(let $=0;$<i.length;$++){let x=i[$];if(x?.$ref&&!(0,iz.schemaHasRulesButRef)(x,s.self.RULES)){let We=x.$ref;if(x=nS.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,We),x instanceof nS.SchemaEnv&&(x=x.schema),x===void 0)throw new sz.default(s.opts.uriResolver,s.baseId,We)}let je=(m=x?.properties)===null||m===void 0?void 0:m[a];if(typeof je!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(y||v(x)),b(je,$)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return h;function v({required:$}){return Array.isArray($)&&$.includes(a)}function b($,x){if($.const)w($.const,x);else if($.enum)for(let je of $.enum)w(je,x);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function w($,x){if(typeof $!="string"||$ in h)throw new Error(`discriminator: "${a}" values must be unique strings`);h[$]=x}}}};Gu.default=cz});var sS=E((CU,uz)=>{uz.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 Yu=E((re,Bu)=>{"use strict";Object.defineProperty(re,"__esModule",{value:!0});re.MissingRefError=re.ValidationError=re.CodeGen=re.Name=re.nil=re.stringify=re.str=re._=re.KeywordCxt=re.Ajv=void 0;var lz=ty(),dz=eS(),pz=oS(),iS=sS(),fz=["/properties"],Js="http://json-schema.org/draft-07/schema",Gr=class extends lz.default{_addVocabularies(){super._addVocabularies(),dz.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(pz.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(iS,fz):iS;this.addMetaSchema(e,Js,!1),this.refs["http://json-schema.org/schema"]=Js}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Js)?Js:void 0)}};re.Ajv=Gr;Bu.exports=re=Gr;Bu.exports.Ajv=Gr;Object.defineProperty(re,"__esModule",{value:!0});re.default=Gr;var mz=Qn();Object.defineProperty(re,"KeywordCxt",{enumerable:!0,get:function(){return mz.KeywordCxt}});var Br=M();Object.defineProperty(re,"_",{enumerable:!0,get:function(){return Br._}});Object.defineProperty(re,"str",{enumerable:!0,get:function(){return Br.str}});Object.defineProperty(re,"stringify",{enumerable:!0,get:function(){return Br.stringify}});Object.defineProperty(re,"nil",{enumerable:!0,get:function(){return Br.nil}});Object.defineProperty(re,"Name",{enumerable:!0,get:function(){return Br.Name}});Object.defineProperty(re,"CodeGen",{enumerable:!0,get:function(){return Br.CodeGen}});var hz=Ts();Object.defineProperty(re,"ValidationError",{enumerable:!0,get:function(){return hz.default}});var gz=eo();Object.defineProperty(re,"MissingRefError",{enumerable:!0,get:function(){return gz.default}})});var mS=E(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.formatNames=St.fastFormats=St.fullFormats=void 0;function yt(t,e){return{validate:t,compare:e}}St.fullFormats={date:yt(lS,tl),time:yt(Qu(!0),rl),"date-time":yt(aS(!0),pS),"iso-time":yt(Qu(),dS),"iso-date-time":yt(aS(),fS),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:wz,"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:Oz,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:bz,int32:{type:"number",validate:$z},int64:{type:"number",validate:Pz},float:{type:"number",validate:uS},double:{type:"number",validate:uS},password:!0,binary:!0};St.fastFormats={...St.fullFormats,date:yt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,tl),time:yt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,rl),"date-time":yt(/^\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,pS),"iso-time":yt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,dS),"iso-date-time":yt(/^\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,fS),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};St.formatNames=Object.keys(St.fullFormats);function _z(t){return t%4===0&&(t%100!==0||t%400===0)}var yz=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,Sz=[0,31,28,31,30,31,30,31,31,30,31,30,31];function lS(t){let e=yz.exec(t);if(!e)return!1;let r=+e[1],n=+e[2],o=+e[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&_z(r)?29:Sz[n])}function tl(t,e){if(t&&e)return t>e?1:t<e?-1:0}var Xu=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Qu(t){return function(r){let n=Xu.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||t&&!a)return!1;if(o<=23&&s<=59&&i<60)return!0;let d=s-l*c,p=o-u*c-(d<0?1:0);return(p===23||p===-1)&&(d===59||d===-1)&&i<61}}function rl(t,e){if(!(t&&e))return;let r=new Date("2020-01-01T"+t).valueOf(),n=new Date("2020-01-01T"+e).valueOf();if(r&&n)return r-n}function dS(t,e){if(!(t&&e))return;let r=Xu.exec(t),n=Xu.exec(e);if(r&&n)return t=r[1]+r[2]+r[3],e=n[1]+n[2]+n[3],t>e?1:t<e?-1:0}var el=/t|\s/i;function aS(t){let e=Qu(t);return function(n){let o=n.split(el);return o.length===2&&lS(o[0])&&e(o[1])}}function pS(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),n=new Date(e).valueOf();if(r&&n)return r-n}function fS(t,e){if(!(t&&e))return;let[r,n]=t.split(el),[o,s]=e.split(el),i=tl(r,o);if(i!==void 0)return i||rl(n,s)}var vz=/\/|:/,Ez=/^(?:[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 wz(t){return vz.test(t)&&Ez.test(t)}var cS=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function bz(t){return cS.lastIndex=0,cS.test(t)}var kz=-(2**31),xz=2**31-1;function $z(t){return Number.isInteger(t)&&t<=xz&&t>=kz}function Pz(t){return Number.isInteger(t)}function uS(){return!0}var Tz=/[^\\]\\Z/;function Oz(t){if(Tz.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var hS=E(Yr=>{"use strict";Object.defineProperty(Yr,"__esModule",{value:!0});Yr.formatLimitDefinition=void 0;var zz=Yu(),ut=M(),Vt=ut.operators,Gs={formatMaximum:{okStr:"<=",ok:Vt.LTE,fail:Vt.GT},formatMinimum:{okStr:">=",ok:Vt.GTE,fail:Vt.LT},formatExclusiveMaximum:{okStr:"<",ok:Vt.LT,fail:Vt.GTE},formatExclusiveMinimum:{okStr:">",ok:Vt.GT,fail:Vt.LTE}},Rz={message:({keyword:t,schemaCode:e})=>(0,ut.str)`should be ${Gs[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,ut._)`{comparison: ${Gs[t].okStr}, limit: ${e}}`};Yr.formatLimitDefinition={keyword:Object.keys(Gs),type:"string",schemaType:"string",$data:!0,error:Rz,code(t){let{gen:e,data:r,schemaCode:n,keyword:o,it:s}=t,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new zz.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let p=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),m=e.const("fmt",(0,ut._)`${p}[${c.schemaCode}]`);t.fail$data((0,ut.or)((0,ut._)`typeof ${m} != "object"`,(0,ut._)`${m} instanceof RegExp`,(0,ut._)`typeof ${m}.compare != "function"`,d(m)))}function l(){let p=c.schema,m=a.formats[p];if(!m||m===!0)return;if(typeof m!="object"||m instanceof RegExp||typeof m.compare!="function")throw new Error(`"${o}": format "${p}" does not define "compare" function`);let h=e.scopeValue("formats",{key:p,ref:m,code:i.code.formats?(0,ut._)`${i.code.formats}${(0,ut.getProperty)(p)}`:void 0});t.fail$data(d(h))}function d(p){return(0,ut._)`${p}.compare(${r}, ${n}) ${Gs[o].fail} 0`}},dependencies:["format"]};var Iz=t=>(t.addKeyword(Yr.formatLimitDefinition),t);Yr.default=Iz});var SS=E((ho,yS)=>{"use strict";Object.defineProperty(ho,"__esModule",{value:!0});var Xr=mS(),Cz=hS(),nl=M(),gS=new nl.Name("fullFormats"),Az=new nl.Name("fastFormats"),ol=(t,e={keywords:!0})=>{if(Array.isArray(e))return _S(t,e,Xr.fullFormats,gS),t;let[r,n]=e.mode==="fast"?[Xr.fastFormats,Az]:[Xr.fullFormats,gS],o=e.formats||Xr.formatNames;return _S(t,o,r,n),e.keywords&&(0,Cz.default)(t),t};ol.get=(t,e="full")=>{let n=(e==="fast"?Xr.fastFormats:Xr.fullFormats)[t];if(!n)throw new Error(`Unknown format "${t}"`);return n};function _S(t,e,r,n){var o,s;(o=(s=t.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,nl._)`require("ajv-formats/dist/formats").${n}`);for(let i of e)t.addFormat(i,r[i])}yS.exports=ho=ol;Object.defineProperty(ho,"__esModule",{value:!0});ho.default=ol});var TS=E((VU,PS)=>{PS.exports=$S;$S.sync=Lz;var kS=require("fs");function Dz(t,e){var r=e.pathExt!==void 0?e.pathExt:process.env.PATHEXT;if(!r||(r=r.split(";"),r.indexOf("")!==-1))return!0;for(var n=0;n<r.length;n++){var o=r[n].toLowerCase();if(o&&t.substr(-o.length).toLowerCase()===o)return!0}return!1}function xS(t,e,r){return!t.isSymbolicLink()&&!t.isFile()?!1:Dz(e,r)}function $S(t,e,r){kS.stat(t,function(n,o){r(n,n?!1:xS(o,t,e))})}function Lz(t,e){return xS(kS.statSync(t),t,e)}});var CS=E((JU,IS)=>{IS.exports=zS;zS.sync=jz;var OS=require("fs");function zS(t,e,r){OS.stat(t,function(n,o){r(n,n?!1:RS(o,e))})}function jz(t,e){return RS(OS.statSync(t),e)}function RS(t,e){return t.isFile()&&Uz(t,e)}function Uz(t,e){var r=t.mode,n=t.uid,o=t.gid,s=e.uid!==void 0?e.uid:process.getuid&&process.getuid(),i=e.gid!==void 0?e.gid:process.getgid&&process.getgid(),a=parseInt("100",8),c=parseInt("010",8),u=parseInt("001",8),l=a|c,d=r&u||r&c&&o===i||r&a&&n===s||r&l&&s===0;return d}});var MS=E((BU,AS)=>{var GU=require("fs"),ei;process.platform==="win32"||global.TESTING_WINDOWS?ei=TS():ei=CS();AS.exports=sl;sl.sync=Fz;function sl(t,e,r){if(typeof e=="function"&&(r=e,e={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(n,o){sl(t,e||{},function(s,i){s?o(s):n(i)})})}ei(t,e||{},function(n,o){n&&(n.code==="EACCES"||e&&e.ignoreErrors)&&(n=null,o=!1),r(n,o)})}function Fz(t,e){try{return ei.sync(t,e||{})}catch(r){if(e&&e.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var ZS=E((YU,FS)=>{var Qr=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",NS=require("path"),Zz=Qr?";":":",DS=MS(),LS=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),jS=(t,e)=>{let r=e.colon||Zz,n=t.match(/\//)||Qr&&t.match(/\\/)?[""]:[...Qr?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(r)],o=Qr?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=Qr?o.split(r):[""];return Qr&&t.indexOf(".")!==-1&&s[0]!==""&&s.unshift(""),{pathEnv:n,pathExt:s,pathExtExe:o}},US=(t,e,r)=>{typeof e=="function"&&(r=e,e={}),e||(e={});let{pathEnv:n,pathExt:o,pathExtExe:s}=jS(t,e),i=[],a=u=>new Promise((l,d)=>{if(u===n.length)return e.all&&i.length?l(i):d(LS(t));let p=n[u],m=/^".*"$/.test(p)?p.slice(1,-1):p,h=NS.join(m,t),y=!m&&/^\.[\\\/]/.test(t)?t.slice(0,2)+h:h;l(c(y,u,0))}),c=(u,l,d)=>new Promise((p,m)=>{if(d===o.length)return p(a(l+1));let h=o[d];DS(u+h,{pathExt:s},(y,g)=>{if(!y&&g)if(e.all)i.push(u+h);else return p(u+h);return p(c(u,l,d+1))})});return r?a(0).then(u=>r(null,u),r):a(0)},qz=(t,e)=>{e=e||{};let{pathEnv:r,pathExt:n,pathExtExe:o}=jS(t,e),s=[];for(let i=0;i<r.length;i++){let a=r[i],c=/^".*"$/.test(a)?a.slice(1,-1):a,u=NS.join(c,t),l=!c&&/^\.[\\\/]/.test(t)?t.slice(0,2)+u:u;for(let d=0;d<n.length;d++){let p=l+n[d];try{if(DS.sync(p,{pathExt:o}))if(e.all)s.push(p);else return p}catch{}}}if(e.all&&s.length)return s;if(e.nothrow)return null;throw LS(t)};FS.exports=US;US.sync=qz});var HS=E((XU,il)=>{"use strict";var qS=(t={})=>{let e=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};il.exports=qS;il.exports.default=qS});var JS=E((QU,VS)=>{"use strict";var WS=require("path"),Hz=ZS(),Wz=HS();function KS(t,e){let r=t.options.env||process.env,n=process.cwd(),o=t.options.cwd!=null,s=o&&process.chdir!==void 0&&!process.chdir.disabled;if(s)try{process.chdir(t.options.cwd)}catch{}let i;try{i=Hz.sync(t.command,{path:r[Wz({env:r})],pathExt:e?WS.delimiter:void 0})}catch{}finally{s&&process.chdir(n)}return i&&(i=WS.resolve(o?t.options.cwd:"",i)),i}function Kz(t){return KS(t)||KS(t,!0)}VS.exports=Kz});var GS=E((eF,cl)=>{"use strict";var al=/([()\][%!^"`<>&|;, *?])/g;function Vz(t){return t=t.replace(al,"^$1"),t}function Jz(t,e){return t=`${t}`,t=t.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),t=t.replace(/(?=(\\+?)?)\1$/,"$1$1"),t=`"${t}"`,t=t.replace(al,"^$1"),e&&(t=t.replace(al,"^$1")),t}cl.exports.command=Vz;cl.exports.argument=Jz});var YS=E((tF,BS)=>{"use strict";BS.exports=/^#!(.*)/});var QS=E((rF,XS)=>{"use strict";var Gz=YS();XS.exports=(t="")=>{let e=t.match(Gz);if(!e)return null;let[r,n]=e[0].replace(/#! ?/,"").split(" "),o=r.split("/").pop();return o==="env"?n:n?`${o} ${n}`:o}});var tv=E((nF,ev)=>{"use strict";var ul=require("fs"),Bz=QS();function Yz(t){let r=Buffer.alloc(150),n;try{n=ul.openSync(t,"r"),ul.readSync(n,r,0,150,0),ul.closeSync(n)}catch{}return Bz(r.toString())}ev.exports=Yz});var sv=E((oF,ov)=>{"use strict";var Xz=require("path"),rv=JS(),nv=GS(),Qz=tv(),eR=process.platform==="win32",tR=/\.(?:com|exe)$/i,rR=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function nR(t){t.file=rv(t);let e=t.file&&Qz(t.file);return e?(t.args.unshift(t.file),t.command=e,rv(t)):t.file}function oR(t){if(!eR)return t;let e=nR(t),r=!tR.test(e);if(t.options.forceShell||r){let n=rR.test(e);t.command=Xz.normalize(t.command),t.command=nv.command(t.command),t.args=t.args.map(s=>nv.argument(s,n));let o=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${o}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}function sR(t,e,r){e&&!Array.isArray(e)&&(r=e,e=null),e=e?e.slice(0):[],r=Object.assign({},r);let n={command:t,args:e,options:r,file:void 0,original:{command:t,args:e}};return r.shell?n:oR(n)}ov.exports=sR});var cv=E((sF,av)=>{"use strict";var ll=process.platform==="win32";function dl(t,e){return Object.assign(new Error(`${e} ${t.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${t.command}`,path:t.command,spawnargs:t.args})}function iR(t,e){if(!ll)return;let r=t.emit;t.emit=function(n,o){if(n==="exit"){let s=iv(o,e);if(s)return r.call(t,"error",s)}return r.apply(t,arguments)}}function iv(t,e){return ll&&t===1&&!e.file?dl(e.original,"spawn"):null}function aR(t,e){return ll&&t===1&&!e.file?dl(e.original,"spawnSync"):null}av.exports={hookChildProcess:iR,verifyENOENT:iv,verifyENOENTSync:aR,notFoundError:dl}});var dv=E((iF,en)=>{"use strict";var uv=require("child_process"),pl=sv(),fl=cv();function lv(t,e,r){let n=pl(t,e,r),o=uv.spawn(n.command,n.args,n.options);return fl.hookChildProcess(o,n),o}function cR(t,e,r){let n=pl(t,e,r),o=uv.spawnSync(n.command,n.args,n.options);return o.error=o.error||fl.verifyENOENTSync(o.status,n),o}en.exports=lv;en.exports.spawn=lv;en.exports.sync=cR;en.exports._parse=pl;en.exports._enoent=fl});var Ov=we(require("node:path"),1),zv=require("node:fs");var br=we(require("path"),1),Fe=require("fs");var Il=require("node:child_process");function yr(t,e,r){return(0,Il.spawn)(t,e??[],{windowsHide:!0,...r})}var Ue=require("fs"),yi=require("path");var L=require("path"),di=require("os"),Ie=require("fs");var Cl=require("url");function Lv(){return typeof __dirname<"u"?__dirname:(0,L.dirname)((0,Cl.fileURLToPath)(__IMPORT_META_URL__))}var nI=Lv();function pi(){let t=process.env.KEEPMIND_DATA_DIR??process.env.CLAUDE_MEM_DATA_DIR;if(t)return t;let e=(0,L.join)((0,di.homedir)(),".keepmind"),r=(0,L.join)(e,"settings.json");try{if((0,Ie.existsSync)(r)){let n=JSON.parse((0,Ie.readFileSync)(r,"utf-8")),o=n.env??n,s=o.KEEPMIND_DATA_DIR??o.CLAUDE_MEM_DATA_DIR;if(s)return s}}catch{}return e}var B=pi(),go=process.env.CLAUDE_CONFIG_DIR||(0,L.join)((0,di.homedir)(),".claude"),vr=(0,L.join)(go,"plugins","marketplaces","keepmind"),jv=(0,L.join)(B,"archives"),Uv=(0,L.join)(B,"logs"),Fv=(0,L.join)(B,"trash"),Zv=(0,L.join)(B,"backups"),qv=(0,L.join)(B,"modes"),Al=(0,L.join)(B,"settings.json"),Sr=(0,L.join)(B,"keepmind.db"),cn=(0,L.join)(B,"claude-mem.db"),Hv=(0,L.join)(B,"vector-db"),_o=(0,L.join)(B,"observer-sessions"),Wv=(0,L.basename)(_o),oI=(0,L.join)(go,"settings.json"),sI=(0,L.join)(go,"commands"),iI=(0,L.join)(go,"CLAUDE.md");function Kv(){try{if((0,Ie.existsSync)(Sr)||!(0,Ie.existsSync)(cn))return(0,Ie.existsSync)(Sr);for(let t of["","-wal","-shm"]){let e=cn+t,r=Sr+t;(0,Ie.existsSync)(e)&&!(0,Ie.existsSync)(r)&&(0,Ie.renameSync)(e,r)}return f.info("DB","Migrated legacy claude-mem.db to keepmind.db",{from:cn,to:Sr}),!0}catch(t){return f.warn("DB","Could not rename legacy claude-mem.db to keepmind.db (file may be locked) \u2014 falling back to legacy path",{},t instanceof Error?t:new Error(String(t))),!1}}function Vv(){return Kv(),!(0,Ie.existsSync)(Sr)&&(0,Ie.existsSync)(cn)?cn:Sr}var fe={dataDir:()=>B,workerPid:()=>(0,L.join)(B,"worker.pid"),workerPort:()=>(0,L.join)(B,"worker.port"),serverPid:()=>(0,L.join)(B,".server-beta.pid"),serverPort:()=>(0,L.join)(B,".server-beta.port"),serverRuntime:()=>(0,L.join)(B,".server-beta.runtime.json"),settings:()=>(0,L.join)(B,"settings.json"),database:()=>Vv(),chroma:()=>(0,L.join)(B,"chroma"),combinedCerts:()=>(0,L.join)(B,"combined_certs.pem"),transcriptsConfig:()=>(0,L.join)(B,"transcript-watch.json"),transcriptsState:()=>(0,L.join)(B,"transcript-watch-state.json"),corpora:()=>(0,L.join)(B,"corpora"),supervisorRegistry:()=>(0,L.join)(B,"supervisor.json"),envFile:()=>(0,L.join)(B,".env"),logsDir:()=>Uv,archives:()=>jv,trash:()=>Fv,backups:()=>Zv,modes:()=>qv,vectorDb:()=>Hv,observerSessions:()=>_o};var mi=null;function hi(t){return(mi??process.stderr.write.bind(process.stderr))(t)}var Pe=null,fi=!1;function Ml(){let t=process.stderr.write.bind(process.stderr);return mi=t,Pe=[],fi=!0,process.stderr.write=(e=>(Pe&&Pe.push(typeof e=="string"?e:Buffer.from(e).toString("utf-8")),!0)),{flush(){Pe&&Pe.length>0&&t(Pe.join("")),Pe=[]},drop(){Pe=[]},restore(){fi&&(process.stderr.write=t,fi=!1,Pe=null,mi=null)}}}function un(t){hi(t)}function yo(t,e){if(gi)throw new Error("emitModelContext called twice");gi=!0;let r=t.formatOutput(e);console.log(JSON.stringify(r))}var gi=!1;var Jv=2e3;async function Gv(){try{let t=globalThis[Symbol.for("undici.globalDispatcher.1")];t&&typeof t.destroy=="function"&&await t.destroy()}catch{}}function Nl(t){return process.exitCode=t,setTimeout(()=>process.exit(t),Jv).unref?.(),Gv(),new Promise(()=>{})}function Dl(t,e={}){return Pe&&Pe.length>0&&(hi(Pe.join("")),Pe=[]),hi(t.endsWith(`
|
|
12
|
+
deps: ${r}}`};var uO={keyword:"dependencies",type:"object",schemaType:"object",error:_t.error,code(t){let[e,r]=lO(t);Oy(t,e),zy(t,r)}};function lO({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let o=Array.isArray(t[n])?e:r;o[n]=t[n]}return[e,r]}function Oy(t,e=t.schema){let{gen:r,data:n,it:o}=t;if(Object.keys(e).length===0)return;let s=r.let("missing");for(let i in e){let a=e[i];if(a.length===0)continue;let c=(0,mo.propertyInData)(r,n,i,o.opts.ownProperties);t.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,mo.checkReportMissingProp)(t,u)}):(r.if((0,Ru._)`${c} && (${(0,mo.checkMissingProp)(t,a,s)})`),(0,mo.reportMissingProp)(t,s),r.else())}}_t.validatePropertyDeps=Oy;function zy(t,e=t.schema){let{gen:r,data:n,keyword:o,it:s}=t,i=r.name("valid");for(let a in e)(0,cO.alwaysValidSchema)(s,e[a])||(r.if((0,mo.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=t.subschema({keyword:o,schemaProp:a},i);t.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),t.ok(i))}_t.validateSchemaDeps=zy;_t.default=uO});var Cy=E(Iu=>{"use strict";Object.defineProperty(Iu,"__esModule",{value:!0});var Iy=M(),dO=Z(),pO={message:"property name must be valid",params:({params:t})=>(0,Iy._)`{propertyName: ${t.propertyName}}`},fO={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:pO,code(t){let{gen:e,schema:r,data:n,it:o}=t;if((0,dO.alwaysValidSchema)(o,r))return;let s=e.name("valid");e.forIn("key",n,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),e.if((0,Iy.not)(s),()=>{t.error(!0),o.allErrors||e.break()})}),t.ok(s)}};Iu.default=fO});var Au=E(Cu=>{"use strict";Object.defineProperty(Cu,"__esModule",{value:!0});var Zs=Xe(),ct=M(),mO=Tt(),qs=Z(),hO={message:"must NOT have additional properties",params:({params:t})=>(0,ct._)`{additionalProperty: ${t.additionalProperty}}`},gO={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:hO,code(t){let{gen:e,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=t;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,qs.alwaysValidSchema)(i,r))return;let u=(0,Zs.allSchemaProperties)(n.properties),l=(0,Zs.allSchemaProperties)(n.patternProperties);d(),t.ok((0,ct._)`${s} === ${mO.default.errors}`);function d(){e.forIn("key",o,g=>{!u.length&&!l.length?h(g):e.if(p(g),()=>h(g))})}function p(g){let v;if(u.length>8){let b=(0,qs.schemaRefOrVal)(i,n.properties,"properties");v=(0,Zs.isOwnProperty)(e,b,g)}else u.length?v=(0,ct.or)(...u.map(b=>(0,ct._)`${g} === ${b}`)):v=ct.nil;return l.length&&(v=(0,ct.or)(v,...l.map(b=>(0,ct._)`${(0,Zs.usePattern)(t,b)}.test(${g})`))),(0,ct.not)(v)}function m(g){e.code((0,ct._)`delete ${o}[${g}]`)}function h(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){m(g);return}if(r===!1){t.setParams({additionalProperty:g}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,qs.alwaysValidSchema)(i,r)){let v=e.name("valid");c.removeAdditional==="failing"?(y(g,v,!1),e.if((0,ct.not)(v),()=>{t.reset(),m(g)})):(y(g,v),a||e.if((0,ct.not)(v),()=>e.break()))}}function y(g,v,b){let w={keyword:"additionalProperties",dataProp:g,dataPropType:qs.Type.Str};b===!1&&Object.assign(w,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(w,v)}}};Cu.default=gO});var Ny=E(Nu=>{"use strict";Object.defineProperty(Nu,"__esModule",{value:!0});var _O=Qn(),Ay=Xe(),Mu=Z(),My=Au(),yO={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:o,it:s}=t;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&My.default.code(new _O.KeywordCxt(s,My.default,"additionalProperties"));let i=(0,Ay.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=Mu.mergeEvaluated.props(e,(0,Mu.toHash)(i),s.props));let a=i.filter(d=>!(0,Mu.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)u(d)?l(d):(e.if((0,Ay.propertyInData)(e,o,d,s.opts.ownProperties)),l(d),s.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};Nu.default=yO});var Uy=E(Du=>{"use strict";Object.defineProperty(Du,"__esModule",{value:!0});var Dy=Xe(),Hs=M(),Ly=Z(),jy=Z(),SO={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:o,it:s}=t,{opts:i}=s,a=(0,Dy.allSchemaProperties)(r),c=a.filter(y=>(0,Ly.alwaysValidSchema)(s,r[y]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=e.name("valid");s.props!==!0&&!(s.props instanceof Hs.Name)&&(s.props=(0,jy.evaluatedPropsToName)(e,s.props));let{props:d}=s;p();function p(){for(let y of a)u&&m(y),s.allErrors?h(y):(e.var(l,!0),h(y),e.if(l))}function m(y){for(let g in u)new RegExp(y).test(g)&&(0,Ly.checkStrictMode)(s,`property ${g} matches pattern ${y} (use allowMatchingProperties)`)}function h(y){e.forIn("key",n,g=>{e.if((0,Hs._)`${(0,Dy.usePattern)(t,y)}.test(${g})`,()=>{let v=c.includes(y);v||t.subschema({keyword:"patternProperties",schemaProp:y,dataProp:g,dataPropType:jy.Type.Str},l),s.opts.unevaluated&&d!==!0?e.assign((0,Hs._)`${d}[${g}]`,!0):!v&&!s.allErrors&&e.if((0,Hs.not)(l),()=>e.break())})})}}};Du.default=SO});var Fy=E(Lu=>{"use strict";Object.defineProperty(Lu,"__esModule",{value:!0});var vO=Z(),EO={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,vO.alwaysValidSchema)(n,r)){t.fail();return}let o=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),t.failResult(o,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};Lu.default=EO});var Zy=E(ju=>{"use strict";Object.defineProperty(ju,"__esModule",{value:!0});var wO=Xe(),bO={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:wO.validateUnion,error:{message:"must match a schema in anyOf"}};ju.default=bO});var qy=E(Uu=>{"use strict";Object.defineProperty(Uu,"__esModule",{value:!0});var Ws=M(),kO=Z(),xO={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,Ws._)`{passingSchemas: ${t.passing}}`},$O={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:xO,code(t){let{gen:e,schema:r,parentSchema:n,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(u),t.result(i,()=>t.reset(),()=>t.error(!0));function u(){s.forEach((l,d)=>{let p;(0,kO.alwaysValidSchema)(o,l)?e.var(c,!0):p=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,Ws._)`${c} && ${i}`).assign(i,!1).assign(a,(0,Ws._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,d),p&&t.mergeEvaluated(p,Ws.Name)})})}}};Uu.default=$O});var Hy=E(Fu=>{"use strict";Object.defineProperty(Fu,"__esModule",{value:!0});var PO=Z(),TO={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=e.name("valid");r.forEach((s,i)=>{if((0,PO.alwaysValidSchema)(n,s))return;let a=t.subschema({keyword:"allOf",schemaProp:i},o);t.ok(o),t.mergeEvaluated(a)})}};Fu.default=TO});var Ky=E(Zu=>{"use strict";Object.defineProperty(Zu,"__esModule",{value:!0});var Vs=M(),Vy=Z(),OO={message:({params:t})=>(0,Vs.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,Vs._)`{failingKeyword: ${t.ifClause}}`},zO={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:OO,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,Vy.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=Wy(n,"then"),s=Wy(n,"else");if(!o&&!s)return;let i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),o&&s){let l=e.let("ifClause");t.setParams({ifClause:l}),e.if(a,u("then",l),u("else",l))}else o?e.if(a,u("then")):e.if((0,Vs.not)(a),u("else"));t.pass(i,()=>t.error(!0));function c(){let l=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(l)}function u(l,d){return()=>{let p=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(p,i),d?e.assign(d,(0,Vs._)`${l}`):t.setParams({ifClause:l})}}}};function Wy(t,e){let r=t.schema[e];return r!==void 0&&!(0,Vy.alwaysValidSchema)(t,r)}Zu.default=zO});var Jy=E(qu=>{"use strict";Object.defineProperty(qu,"__esModule",{value:!0});var RO=Z(),IO={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,RO.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};qu.default=IO});var Gy=E(Hu=>{"use strict";Object.defineProperty(Hu,"__esModule",{value:!0});var CO=$u(),AO=xy(),MO=Pu(),NO=Py(),DO=Ty(),LO=Ry(),jO=Cy(),UO=Au(),FO=Ny(),ZO=Uy(),qO=Fy(),HO=Zy(),WO=qy(),VO=Hy(),KO=Ky(),JO=Jy();function GO(t=!1){let e=[qO.default,HO.default,WO.default,VO.default,KO.default,JO.default,jO.default,UO.default,LO.default,FO.default,ZO.default];return t?e.push(AO.default,NO.default):e.push(CO.default,MO.default),e.push(DO.default),e}Hu.default=GO});var By=E(Wu=>{"use strict";Object.defineProperty(Wu,"__esModule",{value:!0});var ce=M(),BO={message:({schemaCode:t})=>(0,ce.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,ce._)`{format: ${t}}`},YO={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:BO,code(t,e){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?p():m();function p(){let h=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),y=r.const("fDef",(0,ce._)`${h}[${i}]`),g=r.let("fType"),v=r.let("format");r.if((0,ce._)`typeof ${y} == "object" && !(${y} instanceof RegExp)`,()=>r.assign(g,(0,ce._)`${y}.type || "string"`).assign(v,(0,ce._)`${y}.validate`),()=>r.assign(g,(0,ce._)`"string"`).assign(v,y)),t.fail$data((0,ce.or)(b(),w()));function b(){return c.strictSchema===!1?ce.nil:(0,ce._)`${i} && !${v}`}function w(){let $=l.$async?(0,ce._)`(${y}.async ? await ${v}(${n}) : ${v}(${n}))`:(0,ce._)`${v}(${n})`,x=(0,ce._)`(typeof ${v} == "function" ? ${$} : ${v}.test(${n}))`;return(0,ce._)`${v} && ${v} !== true && ${g} === ${e} && !${x}`}}function m(){let h=d.formats[s];if(!h){b();return}if(h===!0)return;let[y,g,v]=w(h);y===e&&t.pass($());function b(){if(c.strictSchema===!1){d.logger.warn(x());return}throw new Error(x());function x(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function w(x){let je=x instanceof RegExp?(0,ce.regexpCode)(x):c.code.formats?(0,ce._)`${c.code.formats}${(0,ce.getProperty)(s)}`:void 0,We=r.scopeValue("formats",{key:s,ref:x,code:je});return typeof x=="object"&&!(x instanceof RegExp)?[x.type||"string",x.validate,(0,ce._)`${We}.validate`]:["string",x,We]}function $(){if(typeof h=="object"&&!(h instanceof RegExp)&&h.async){if(!l.$async)throw new Error("async format in sync schema");return(0,ce._)`await ${v}(${n})`}return typeof g=="function"?(0,ce._)`${v}(${n})`:(0,ce._)`${v}.test(${n})`}}}};Wu.default=YO});var Yy=E(Vu=>{"use strict";Object.defineProperty(Vu,"__esModule",{value:!0});var XO=By(),QO=[XO.default];Vu.default=QO});var Xy=E(Kr=>{"use strict";Object.defineProperty(Kr,"__esModule",{value:!0});Kr.contentVocabulary=Kr.metadataVocabulary=void 0;Kr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Kr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var eS=E(Ku=>{"use strict";Object.defineProperty(Ku,"__esModule",{value:!0});var ez=ay(),tz=Ey(),rz=Gy(),nz=Yy(),Qy=Xy(),oz=[ez.default,tz.default,(0,rz.default)(),nz.default,Qy.metadataVocabulary,Qy.contentVocabulary];Ku.default=oz});var rS=E(Ks=>{"use strict";Object.defineProperty(Ks,"__esModule",{value:!0});Ks.DiscrError=void 0;var tS;(function(t){t.Tag="tag",t.Mapping="mapping"})(tS||(Ks.DiscrError=tS={}))});var oS=E(Gu=>{"use strict";Object.defineProperty(Gu,"__esModule",{value:!0});var Jr=M(),Ju=rS(),nS=zs(),sz=eo(),iz=Z(),az={message:({params:{discrError:t,tagName:e}})=>t===Ju.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,Jr._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},cz={keyword:"discriminator",type:"object",schemaType:"object",error:az,code(t){let{gen:e,data:r,schema:n,parentSchema:o,it:s}=t,{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=e.let("valid",!1),u=e.const("tag",(0,Jr._)`${r}${(0,Jr.getProperty)(a)}`);e.if((0,Jr._)`typeof ${u} == "string"`,()=>l(),()=>t.error(!1,{discrError:Ju.DiscrError.Tag,tag:u,tagName:a})),t.ok(c);function l(){let m=p();e.if(!1);for(let h in m)e.elseIf((0,Jr._)`${u} === ${h}`),e.assign(c,d(m[h]));e.else(),t.error(!1,{discrError:Ju.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function d(m){let h=e.name("valid"),y=t.subschema({keyword:"oneOf",schemaProp:m},h);return t.mergeEvaluated(y,Jr.Name),h}function p(){var m;let h={},y=v(o),g=!0;for(let $=0;$<i.length;$++){let x=i[$];if(x?.$ref&&!(0,iz.schemaHasRulesButRef)(x,s.self.RULES)){let We=x.$ref;if(x=nS.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,We),x instanceof nS.SchemaEnv&&(x=x.schema),x===void 0)throw new sz.default(s.opts.uriResolver,s.baseId,We)}let je=(m=x?.properties)===null||m===void 0?void 0:m[a];if(typeof je!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(y||v(x)),b(je,$)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return h;function v({required:$}){return Array.isArray($)&&$.includes(a)}function b($,x){if($.const)w($.const,x);else if($.enum)for(let je of $.enum)w(je,x);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function w($,x){if(typeof $!="string"||$ in h)throw new Error(`discriminator: "${a}" values must be unique strings`);h[$]=x}}}};Gu.default=cz});var sS=E((CU,uz)=>{uz.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 Yu=E((re,Bu)=>{"use strict";Object.defineProperty(re,"__esModule",{value:!0});re.MissingRefError=re.ValidationError=re.CodeGen=re.Name=re.nil=re.stringify=re.str=re._=re.KeywordCxt=re.Ajv=void 0;var lz=ty(),dz=eS(),pz=oS(),iS=sS(),fz=["/properties"],Js="http://json-schema.org/draft-07/schema",Gr=class extends lz.default{_addVocabularies(){super._addVocabularies(),dz.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(pz.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(iS,fz):iS;this.addMetaSchema(e,Js,!1),this.refs["http://json-schema.org/schema"]=Js}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Js)?Js:void 0)}};re.Ajv=Gr;Bu.exports=re=Gr;Bu.exports.Ajv=Gr;Object.defineProperty(re,"__esModule",{value:!0});re.default=Gr;var mz=Qn();Object.defineProperty(re,"KeywordCxt",{enumerable:!0,get:function(){return mz.KeywordCxt}});var Br=M();Object.defineProperty(re,"_",{enumerable:!0,get:function(){return Br._}});Object.defineProperty(re,"str",{enumerable:!0,get:function(){return Br.str}});Object.defineProperty(re,"stringify",{enumerable:!0,get:function(){return Br.stringify}});Object.defineProperty(re,"nil",{enumerable:!0,get:function(){return Br.nil}});Object.defineProperty(re,"Name",{enumerable:!0,get:function(){return Br.Name}});Object.defineProperty(re,"CodeGen",{enumerable:!0,get:function(){return Br.CodeGen}});var hz=Ts();Object.defineProperty(re,"ValidationError",{enumerable:!0,get:function(){return hz.default}});var gz=eo();Object.defineProperty(re,"MissingRefError",{enumerable:!0,get:function(){return gz.default}})});var mS=E(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.formatNames=St.fastFormats=St.fullFormats=void 0;function yt(t,e){return{validate:t,compare:e}}St.fullFormats={date:yt(lS,tl),time:yt(Qu(!0),rl),"date-time":yt(aS(!0),pS),"iso-time":yt(Qu(),dS),"iso-date-time":yt(aS(),fS),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:wz,"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:Oz,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:bz,int32:{type:"number",validate:$z},int64:{type:"number",validate:Pz},float:{type:"number",validate:uS},double:{type:"number",validate:uS},password:!0,binary:!0};St.fastFormats={...St.fullFormats,date:yt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,tl),time:yt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,rl),"date-time":yt(/^\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,pS),"iso-time":yt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,dS),"iso-date-time":yt(/^\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,fS),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};St.formatNames=Object.keys(St.fullFormats);function _z(t){return t%4===0&&(t%100!==0||t%400===0)}var yz=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,Sz=[0,31,28,31,30,31,30,31,31,30,31,30,31];function lS(t){let e=yz.exec(t);if(!e)return!1;let r=+e[1],n=+e[2],o=+e[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&_z(r)?29:Sz[n])}function tl(t,e){if(t&&e)return t>e?1:t<e?-1:0}var Xu=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Qu(t){return function(r){let n=Xu.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||t&&!a)return!1;if(o<=23&&s<=59&&i<60)return!0;let d=s-l*c,p=o-u*c-(d<0?1:0);return(p===23||p===-1)&&(d===59||d===-1)&&i<61}}function rl(t,e){if(!(t&&e))return;let r=new Date("2020-01-01T"+t).valueOf(),n=new Date("2020-01-01T"+e).valueOf();if(r&&n)return r-n}function dS(t,e){if(!(t&&e))return;let r=Xu.exec(t),n=Xu.exec(e);if(r&&n)return t=r[1]+r[2]+r[3],e=n[1]+n[2]+n[3],t>e?1:t<e?-1:0}var el=/t|\s/i;function aS(t){let e=Qu(t);return function(n){let o=n.split(el);return o.length===2&&lS(o[0])&&e(o[1])}}function pS(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),n=new Date(e).valueOf();if(r&&n)return r-n}function fS(t,e){if(!(t&&e))return;let[r,n]=t.split(el),[o,s]=e.split(el),i=tl(r,o);if(i!==void 0)return i||rl(n,s)}var vz=/\/|:/,Ez=/^(?:[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 wz(t){return vz.test(t)&&Ez.test(t)}var cS=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function bz(t){return cS.lastIndex=0,cS.test(t)}var kz=-(2**31),xz=2**31-1;function $z(t){return Number.isInteger(t)&&t<=xz&&t>=kz}function Pz(t){return Number.isInteger(t)}function uS(){return!0}var Tz=/[^\\]\\Z/;function Oz(t){if(Tz.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var hS=E(Yr=>{"use strict";Object.defineProperty(Yr,"__esModule",{value:!0});Yr.formatLimitDefinition=void 0;var zz=Yu(),ut=M(),Kt=ut.operators,Gs={formatMaximum:{okStr:"<=",ok:Kt.LTE,fail:Kt.GT},formatMinimum:{okStr:">=",ok:Kt.GTE,fail:Kt.LT},formatExclusiveMaximum:{okStr:"<",ok:Kt.LT,fail:Kt.GTE},formatExclusiveMinimum:{okStr:">",ok:Kt.GT,fail:Kt.LTE}},Rz={message:({keyword:t,schemaCode:e})=>(0,ut.str)`should be ${Gs[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,ut._)`{comparison: ${Gs[t].okStr}, limit: ${e}}`};Yr.formatLimitDefinition={keyword:Object.keys(Gs),type:"string",schemaType:"string",$data:!0,error:Rz,code(t){let{gen:e,data:r,schemaCode:n,keyword:o,it:s}=t,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new zz.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let p=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),m=e.const("fmt",(0,ut._)`${p}[${c.schemaCode}]`);t.fail$data((0,ut.or)((0,ut._)`typeof ${m} != "object"`,(0,ut._)`${m} instanceof RegExp`,(0,ut._)`typeof ${m}.compare != "function"`,d(m)))}function l(){let p=c.schema,m=a.formats[p];if(!m||m===!0)return;if(typeof m!="object"||m instanceof RegExp||typeof m.compare!="function")throw new Error(`"${o}": format "${p}" does not define "compare" function`);let h=e.scopeValue("formats",{key:p,ref:m,code:i.code.formats?(0,ut._)`${i.code.formats}${(0,ut.getProperty)(p)}`:void 0});t.fail$data(d(h))}function d(p){return(0,ut._)`${p}.compare(${r}, ${n}) ${Gs[o].fail} 0`}},dependencies:["format"]};var Iz=t=>(t.addKeyword(Yr.formatLimitDefinition),t);Yr.default=Iz});var SS=E((ho,yS)=>{"use strict";Object.defineProperty(ho,"__esModule",{value:!0});var Xr=mS(),Cz=hS(),nl=M(),gS=new nl.Name("fullFormats"),Az=new nl.Name("fastFormats"),ol=(t,e={keywords:!0})=>{if(Array.isArray(e))return _S(t,e,Xr.fullFormats,gS),t;let[r,n]=e.mode==="fast"?[Xr.fastFormats,Az]:[Xr.fullFormats,gS],o=e.formats||Xr.formatNames;return _S(t,o,r,n),e.keywords&&(0,Cz.default)(t),t};ol.get=(t,e="full")=>{let n=(e==="fast"?Xr.fastFormats:Xr.fullFormats)[t];if(!n)throw new Error(`Unknown format "${t}"`);return n};function _S(t,e,r,n){var o,s;(o=(s=t.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,nl._)`require("ajv-formats/dist/formats").${n}`);for(let i of e)t.addFormat(i,r[i])}yS.exports=ho=ol;Object.defineProperty(ho,"__esModule",{value:!0});ho.default=ol});var TS=E((KU,PS)=>{PS.exports=$S;$S.sync=Lz;var kS=require("fs");function Dz(t,e){var r=e.pathExt!==void 0?e.pathExt:process.env.PATHEXT;if(!r||(r=r.split(";"),r.indexOf("")!==-1))return!0;for(var n=0;n<r.length;n++){var o=r[n].toLowerCase();if(o&&t.substr(-o.length).toLowerCase()===o)return!0}return!1}function xS(t,e,r){return!t.isSymbolicLink()&&!t.isFile()?!1:Dz(e,r)}function $S(t,e,r){kS.stat(t,function(n,o){r(n,n?!1:xS(o,t,e))})}function Lz(t,e){return xS(kS.statSync(t),t,e)}});var CS=E((JU,IS)=>{IS.exports=zS;zS.sync=jz;var OS=require("fs");function zS(t,e,r){OS.stat(t,function(n,o){r(n,n?!1:RS(o,e))})}function jz(t,e){return RS(OS.statSync(t),e)}function RS(t,e){return t.isFile()&&Uz(t,e)}function Uz(t,e){var r=t.mode,n=t.uid,o=t.gid,s=e.uid!==void 0?e.uid:process.getuid&&process.getuid(),i=e.gid!==void 0?e.gid:process.getgid&&process.getgid(),a=parseInt("100",8),c=parseInt("010",8),u=parseInt("001",8),l=a|c,d=r&u||r&c&&o===i||r&a&&n===s||r&l&&s===0;return d}});var MS=E((BU,AS)=>{var GU=require("fs"),ei;process.platform==="win32"||global.TESTING_WINDOWS?ei=TS():ei=CS();AS.exports=sl;sl.sync=Fz;function sl(t,e,r){if(typeof e=="function"&&(r=e,e={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(n,o){sl(t,e||{},function(s,i){s?o(s):n(i)})})}ei(t,e||{},function(n,o){n&&(n.code==="EACCES"||e&&e.ignoreErrors)&&(n=null,o=!1),r(n,o)})}function Fz(t,e){try{return ei.sync(t,e||{})}catch(r){if(e&&e.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var ZS=E((YU,FS)=>{var Qr=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",NS=require("path"),Zz=Qr?";":":",DS=MS(),LS=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),jS=(t,e)=>{let r=e.colon||Zz,n=t.match(/\//)||Qr&&t.match(/\\/)?[""]:[...Qr?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(r)],o=Qr?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=Qr?o.split(r):[""];return Qr&&t.indexOf(".")!==-1&&s[0]!==""&&s.unshift(""),{pathEnv:n,pathExt:s,pathExtExe:o}},US=(t,e,r)=>{typeof e=="function"&&(r=e,e={}),e||(e={});let{pathEnv:n,pathExt:o,pathExtExe:s}=jS(t,e),i=[],a=u=>new Promise((l,d)=>{if(u===n.length)return e.all&&i.length?l(i):d(LS(t));let p=n[u],m=/^".*"$/.test(p)?p.slice(1,-1):p,h=NS.join(m,t),y=!m&&/^\.[\\\/]/.test(t)?t.slice(0,2)+h:h;l(c(y,u,0))}),c=(u,l,d)=>new Promise((p,m)=>{if(d===o.length)return p(a(l+1));let h=o[d];DS(u+h,{pathExt:s},(y,g)=>{if(!y&&g)if(e.all)i.push(u+h);else return p(u+h);return p(c(u,l,d+1))})});return r?a(0).then(u=>r(null,u),r):a(0)},qz=(t,e)=>{e=e||{};let{pathEnv:r,pathExt:n,pathExtExe:o}=jS(t,e),s=[];for(let i=0;i<r.length;i++){let a=r[i],c=/^".*"$/.test(a)?a.slice(1,-1):a,u=NS.join(c,t),l=!c&&/^\.[\\\/]/.test(t)?t.slice(0,2)+u:u;for(let d=0;d<n.length;d++){let p=l+n[d];try{if(DS.sync(p,{pathExt:o}))if(e.all)s.push(p);else return p}catch{}}}if(e.all&&s.length)return s;if(e.nothrow)return null;throw LS(t)};FS.exports=US;US.sync=qz});var HS=E((XU,il)=>{"use strict";var qS=(t={})=>{let e=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};il.exports=qS;il.exports.default=qS});var JS=E((QU,KS)=>{"use strict";var WS=require("path"),Hz=ZS(),Wz=HS();function VS(t,e){let r=t.options.env||process.env,n=process.cwd(),o=t.options.cwd!=null,s=o&&process.chdir!==void 0&&!process.chdir.disabled;if(s)try{process.chdir(t.options.cwd)}catch{}let i;try{i=Hz.sync(t.command,{path:r[Wz({env:r})],pathExt:e?WS.delimiter:void 0})}catch{}finally{s&&process.chdir(n)}return i&&(i=WS.resolve(o?t.options.cwd:"",i)),i}function Vz(t){return VS(t)||VS(t,!0)}KS.exports=Vz});var GS=E((eF,cl)=>{"use strict";var al=/([()\][%!^"`<>&|;, *?])/g;function Kz(t){return t=t.replace(al,"^$1"),t}function Jz(t,e){return t=`${t}`,t=t.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),t=t.replace(/(?=(\\+?)?)\1$/,"$1$1"),t=`"${t}"`,t=t.replace(al,"^$1"),e&&(t=t.replace(al,"^$1")),t}cl.exports.command=Kz;cl.exports.argument=Jz});var YS=E((tF,BS)=>{"use strict";BS.exports=/^#!(.*)/});var QS=E((rF,XS)=>{"use strict";var Gz=YS();XS.exports=(t="")=>{let e=t.match(Gz);if(!e)return null;let[r,n]=e[0].replace(/#! ?/,"").split(" "),o=r.split("/").pop();return o==="env"?n:n?`${o} ${n}`:o}});var tv=E((nF,ev)=>{"use strict";var ul=require("fs"),Bz=QS();function Yz(t){let r=Buffer.alloc(150),n;try{n=ul.openSync(t,"r"),ul.readSync(n,r,0,150,0),ul.closeSync(n)}catch{}return Bz(r.toString())}ev.exports=Yz});var sv=E((oF,ov)=>{"use strict";var Xz=require("path"),rv=JS(),nv=GS(),Qz=tv(),eR=process.platform==="win32",tR=/\.(?:com|exe)$/i,rR=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function nR(t){t.file=rv(t);let e=t.file&&Qz(t.file);return e?(t.args.unshift(t.file),t.command=e,rv(t)):t.file}function oR(t){if(!eR)return t;let e=nR(t),r=!tR.test(e);if(t.options.forceShell||r){let n=rR.test(e);t.command=Xz.normalize(t.command),t.command=nv.command(t.command),t.args=t.args.map(s=>nv.argument(s,n));let o=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${o}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}function sR(t,e,r){e&&!Array.isArray(e)&&(r=e,e=null),e=e?e.slice(0):[],r=Object.assign({},r);let n={command:t,args:e,options:r,file:void 0,original:{command:t,args:e}};return r.shell?n:oR(n)}ov.exports=sR});var cv=E((sF,av)=>{"use strict";var ll=process.platform==="win32";function dl(t,e){return Object.assign(new Error(`${e} ${t.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${t.command}`,path:t.command,spawnargs:t.args})}function iR(t,e){if(!ll)return;let r=t.emit;t.emit=function(n,o){if(n==="exit"){let s=iv(o,e);if(s)return r.call(t,"error",s)}return r.apply(t,arguments)}}function iv(t,e){return ll&&t===1&&!e.file?dl(e.original,"spawn"):null}function aR(t,e){return ll&&t===1&&!e.file?dl(e.original,"spawnSync"):null}av.exports={hookChildProcess:iR,verifyENOENT:iv,verifyENOENTSync:aR,notFoundError:dl}});var dv=E((iF,en)=>{"use strict";var uv=require("child_process"),pl=sv(),fl=cv();function lv(t,e,r){let n=pl(t,e,r),o=uv.spawn(n.command,n.args,n.options);return fl.hookChildProcess(o,n),o}function cR(t,e,r){let n=pl(t,e,r),o=uv.spawnSync(n.command,n.args,n.options);return o.error=o.error||fl.verifyENOENTSync(o.status,n),o}en.exports=lv;en.exports.spawn=lv;en.exports.sync=cR;en.exports._parse=pl;en.exports._enoent=fl});var Ov=we(require("node:path"),1),zv=require("node:fs");var br=we(require("path"),1),Fe=require("fs");var Il=require("node:child_process");function yr(t,e,r){return(0,Il.spawn)(t,e??[],{windowsHide:!0,...r})}var Ue=require("fs"),yi=require("path");var L=require("path"),di=require("os"),Ie=require("fs");var Cl=require("url");function Lv(){return typeof __dirname<"u"?__dirname:(0,L.dirname)((0,Cl.fileURLToPath)(__IMPORT_META_URL__))}var nI=Lv();function pi(){let t=process.env.KEEPMIND_DATA_DIR??process.env.CLAUDE_MEM_DATA_DIR;if(t)return t;let e=(0,L.join)((0,di.homedir)(),".keepmind"),r=(0,L.join)(e,"settings.json");try{if((0,Ie.existsSync)(r)){let n=JSON.parse((0,Ie.readFileSync)(r,"utf-8")),o=n.env??n,s=o.KEEPMIND_DATA_DIR??o.CLAUDE_MEM_DATA_DIR;if(s)return s}}catch{}return e}var B=pi(),go=process.env.CLAUDE_CONFIG_DIR||(0,L.join)((0,di.homedir)(),".claude"),vr=(0,L.join)(go,"plugins","marketplaces","keepmind"),jv=(0,L.join)(B,"archives"),Uv=(0,L.join)(B,"logs"),Fv=(0,L.join)(B,"trash"),Zv=(0,L.join)(B,"backups"),qv=(0,L.join)(B,"modes"),Al=(0,L.join)(B,"settings.json"),Sr=(0,L.join)(B,"keepmind.db"),cn=(0,L.join)(B,"claude-mem.db"),Hv=(0,L.join)(B,"vector-db"),_o=(0,L.join)(B,"observer-sessions"),Wv=(0,L.basename)(_o),oI=(0,L.join)(go,"settings.json"),sI=(0,L.join)(go,"commands"),iI=(0,L.join)(go,"CLAUDE.md");function Vv(){try{if((0,Ie.existsSync)(Sr)||!(0,Ie.existsSync)(cn))return(0,Ie.existsSync)(Sr);for(let t of["","-wal","-shm"]){let e=cn+t,r=Sr+t;(0,Ie.existsSync)(e)&&!(0,Ie.existsSync)(r)&&(0,Ie.renameSync)(e,r)}return f.info("DB","Migrated legacy claude-mem.db to keepmind.db",{from:cn,to:Sr}),!0}catch(t){return f.warn("DB","Could not rename legacy claude-mem.db to keepmind.db (file may be locked) \u2014 falling back to legacy path",{},t instanceof Error?t:new Error(String(t))),!1}}function Kv(){return Vv(),!(0,Ie.existsSync)(Sr)&&(0,Ie.existsSync)(cn)?cn:Sr}var fe={dataDir:()=>B,workerPid:()=>(0,L.join)(B,"worker.pid"),workerPort:()=>(0,L.join)(B,"worker.port"),serverPid:()=>(0,L.join)(B,".server-beta.pid"),serverPort:()=>(0,L.join)(B,".server-beta.port"),serverRuntime:()=>(0,L.join)(B,".server-beta.runtime.json"),settings:()=>(0,L.join)(B,"settings.json"),database:()=>Kv(),chroma:()=>(0,L.join)(B,"chroma"),combinedCerts:()=>(0,L.join)(B,"combined_certs.pem"),transcriptsConfig:()=>(0,L.join)(B,"transcript-watch.json"),transcriptsState:()=>(0,L.join)(B,"transcript-watch-state.json"),corpora:()=>(0,L.join)(B,"corpora"),supervisorRegistry:()=>(0,L.join)(B,"supervisor.json"),envFile:()=>(0,L.join)(B,".env"),logsDir:()=>Uv,archives:()=>jv,trash:()=>Fv,backups:()=>Zv,modes:()=>qv,vectorDb:()=>Hv,observerSessions:()=>_o};var mi=null;function hi(t){return(mi??process.stderr.write.bind(process.stderr))(t)}var Pe=null,fi=!1;function Ml(){let t=process.stderr.write.bind(process.stderr);return mi=t,Pe=[],fi=!0,process.stderr.write=(e=>(Pe&&Pe.push(typeof e=="string"?e:Buffer.from(e).toString("utf-8")),!0)),{flush(){Pe&&Pe.length>0&&t(Pe.join("")),Pe=[]},drop(){Pe=[]},restore(){fi&&(process.stderr.write=t,fi=!1,Pe=null,mi=null)}}}function un(t){hi(t)}function yo(t,e){if(gi)throw new Error("emitModelContext called twice");gi=!0;let r=t.formatOutput(e);console.log(JSON.stringify(r))}var gi=!1;var Jv=2e3;async function Gv(){try{let t=globalThis[Symbol.for("undici.globalDispatcher.1")];t&&typeof t.destroy=="function"&&await t.destroy()}catch{}}function Nl(t){return process.exitCode=t,setTimeout(()=>process.exit(t),Jv).unref?.(),Gv(),new Promise(()=>{})}function Dl(t,e={}){return Pe&&Pe.length>0&&(hi(Pe.join("")),Pe=[]),hi(t.endsWith(`
|
|
13
13
|
`)?t:`${t}
|
|
14
14
|
`),e.skipExit?Promise.resolve():Nl(2)}function ln(t={}){return Pe&&(Pe=[]),t.skipExit?Promise.resolve():Nl(0)}function Ll(){gi=!1}var Bv=14,Si=(s=>(s[s.DEBUG=0]="DEBUG",s[s.INFO=1]="INFO",s[s.WARN=2]="WARN",s[s.ERROR=3]="ERROR",s[s.SILENT=4]="SILENT",s))(Si||{}),_i=null,vi=class{level=null;useColor;logFilePath=null;logFileInitialized=!1;constructor(){this.useColor=process.stdout.isTTY??!1}ensureLogFileInitialized(){if(!this.logFileInitialized){this.logFileInitialized=!0;try{let e=fe.logsDir();(0,Ue.existsSync)(e)||(0,Ue.mkdirSync)(e,{recursive:!0});let r=new Date().toISOString().split("T")[0];this.logFilePath=(0,yi.join)(e,`keepmind-${r}.log`),this.pruneOldLogs(e)}catch(e){console.error("[LOGGER] Failed to initialize log file:",e instanceof Error?e.message:String(e)),this.logFilePath=null}}}pruneOldLogs(e){try{let r=Date.now()-Bv*24*60*60*1e3;for(let n of(0,Ue.readdirSync)(e)){let o=/^keepmind-(\d{4}-\d{2}-\d{2})\.log$/.exec(n);if(!o)continue;let s=Date.parse(o[1]);if(Number.isFinite(s)&&s<r)try{(0,Ue.unlinkSync)((0,yi.join)(e,n))}catch{}}}catch{}}getLevel(){if(this.level===null)try{let e=fe.settings();if((0,Ue.existsSync)(e)){let r=(0,Ue.readFileSync)(e,"utf-8"),o=(JSON.parse(r).CLAUDE_MEM_LOG_LEVEL||"INFO").toUpperCase();this.level=Si[o]??1}else this.level=1}catch(e){console.error("[LOGGER] Failed to load log level from settings:",e instanceof Error?e.message:String(e)),this.level=1}return this.level}formatData(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return e.toString();if(typeof e=="object"){if(e instanceof Error)return this.getLevel()===0?`${e.message}
|
|
15
15
|
${e.stack}`:e.message;if(Array.isArray(e))return`[${e.length} items]`;let r=Object.keys(e);return r.length===0?"{}":r.length<=3?JSON.stringify(e):`{${r.length} keys: ${r.slice(0,3).join(", ")}...}`}return String(e)}formatTool(e,r){if(!r)return e;let n=r;if(typeof r=="string")try{n=JSON.parse(r)}catch{n=r}if(e==="Bash"&&n.command)return`${e}(${n.command})`;if(n.file_path)return`${e}(${n.file_path})`;if(n.notebook_path)return`${e}(${n.notebook_path})`;if(e==="Glob"&&n.pattern)return`${e}(${n.pattern})`;if(e==="Grep"&&n.pattern)return`${e}(${n.pattern})`;if(n.url)return`${e}(${n.url})`;if(n.query)return`${e}(${n.query})`;if(e==="Task"){if(n.subagent_type)return`${e}(${n.subagent_type})`;if(n.description)return`${e}(${n.description})`}return e==="Skill"&&n.skill?`${e}(${n.skill})`:e==="LSP"&&n.operation?`${e}(${n.operation})`:e}formatTimestamp(e){let r=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0"),s=String(e.getHours()).padStart(2,"0"),i=String(e.getMinutes()).padStart(2,"0"),a=String(e.getSeconds()).padStart(2,"0"),c=String(e.getMilliseconds()).padStart(3,"0");return`${r}-${n}-${o} ${s}:${i}:${a}.${c}`}log(e,r,n,o,s){if(e<this.getLevel())return;this.ensureLogFileInitialized();let i=this.formatTimestamp(new Date),a=Si[e].padEnd(5),c=r.padEnd(6),u="";o?.correlationId?u=`[${o.correlationId}] `:o?.sessionId&&(u=`[session-${o.sessionId}] `);let l="";if(s!=null)if(s instanceof Error)l=this.getLevel()===0?`
|
|
@@ -20,9 +20,9 @@ ${s.stack}`:` ${s.message}`;else if(this.getLevel()===0&&typeof s=="object")try{
|
|
|
20
20
|
`)}else un(p+`
|
|
21
21
|
`)}debug(e,r,n,o){this.log(0,e,r,n,o)}info(e,r,n,o){this.log(1,e,r,n,o)}warn(e,r,n,o){this.log(2,e,r,n,o)}setErrorSink(e){_i=e}error(e,r,n,o){this.log(3,e,r,n,o),this.routeErrorToSink(r,n,o)}routeErrorToSink(e,r,n){try{if(!_i||!(n instanceof Error))return;_i(n)}catch{}}dataIn(e,r,n,o){this.info(e,`\u2192 ${r}`,n,o)}dataOut(e,r,n,o){this.info(e,`\u2190 ${r}`,n,o)}success(e,r,n,o){this.info(e,`\u2713 ${r}`,n,o)}failure(e,r,n,o){this.error(e,`\u2717 ${r}`,n,o)}happyPathError(e,r,n,o,s=""){let u=((new Error().stack||"").split(`
|
|
22
22
|
`)[2]||"").match(/at\s+(?:.*\s+)?\(?([^:]+):(\d+):(\d+)\)?/),l=u?`${u[1].split("/").pop()}:${u[2]}`:"unknown",d={...n,location:l};return this.warn(e,`[HAPPY-PATH] ${r}`,d,o),s}},f=new vi;var ue={DEFAULT:3e5,HEALTH_CHECK:3e3,API_REQUEST:3e4,HOOK_READINESS_WAIT:1e4,POST_SPAWN_WAIT:15e3,READINESS_WAIT:3e4,PORT_IN_USE_WAIT:3e3,WORKER_STARTUP_WAIT:1e3,PRE_RESTART_SETTLE_DELAY:2e3,POWERSHELL_COMMAND:1e4,WINDOWS_MULTIPLIER:1.5},C={SUCCESS:0,FAILURE:1,BLOCKING_ERROR:2,USER_MESSAGE_ONLY:3};function vt(t){return process.platform==="win32"?Math.round(t*ue.WINDOWS_MULTIPLIER):t}var dt=require("fs"),dn=require("path"),Ei=require("os");var W=require("fs");var lt=require("path");var jl=require("crypto"),Yv=process.platform==="win32";function Xv(t){(0,W.existsSync)(t)||(0,W.mkdirSync)(t,{recursive:!0})}function So(t,e){let r=t;try{if((0,W.lstatSync)(t).isSymbolicLink())try{r=(0,W.realpathSync)(t)}catch{let u=(0,W.readlinkSync)(t);r=(0,lt.resolve)((0,lt.dirname)(t),u)}}catch(u){let l=u.code;if(l!=="ENOENT"&&l!=="ENOTDIR")throw u}Xv((0,lt.dirname)(r));let n=(0,lt.dirname)(r),o=(0,lt.basename)(r),s=(0,lt.join)(n,`.${o}.${process.pid}.${(0,jl.randomBytes)(6).toString("hex")}.tmp`),i=Buffer.from(JSON.stringify(e,null,2)+`
|
|
23
|
-
`,"utf-8"),a;try{a=(0,W.statSync)(r).mode&511}catch{}let c;try{c=a!==void 0?(0,W.openSync)(s,"w",a):(0,W.openSync)(s,"w");let u=0;for(;u<i.length;){let l=(0,W.writeSync)(c,i,u,i.length-u);if(l===0)throw new Error(`writeSync stalled at ${u}/${i.length} bytes`);u+=l}if((0,W.fsyncSync)(c),(0,W.closeSync)(c),c=void 0,(0,W.renameSync)(s,r),!Yv){let l;try{l=(0,W.openSync)(n,"r"),(0,W.fsyncSync)(l)}catch{}finally{if(l!==void 0)try{(0,W.closeSync)(l)}catch{}}}}catch(u){if(c!==void 0)try{(0,W.closeSync)(c)}catch{}try{(0,W.unlinkSync)(s)}catch{}throw u}}var Bt=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5-20251001",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:String(37700+(process.getuid?.()??77)%100),CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_API_TIMEOUT_MS:String(vt(ue.API_REQUEST)),CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_PROVIDER:"claude",CLAUDE_MEM_CLAUDE_AUTH_METHOD:"subscription",CLAUDE_MEM_GEMINI_API_KEY:"",CLAUDE_MEM_GEMINI_MODEL:"gemini-2.5-flash-lite",CLAUDE_MEM_GEMINI_RATE_LIMITING_ENABLED:"true",CLAUDE_MEM_GEMINI_MAX_CONTEXT_MESSAGES:"20",CLAUDE_MEM_GEMINI_MAX_TOKENS:"100000",CLAUDE_MEM_OPENROUTER_API_KEY:"",CLAUDE_MEM_OPENROUTER_MODEL:"xiaomi/mimo-v2-flash:free",CLAUDE_MEM_OPENROUTER_BASE_URL:"",CLAUDE_MEM_OPENROUTER_SITE_URL:"",CLAUDE_MEM_OPENROUTER_APP_NAME:"claude-mem",CLAUDE_MEM_OPENROUTER_MAX_CONTEXT_MESSAGES:"20",CLAUDE_MEM_OPENROUTER_MAX_TOKENS:"100000",CLAUDE_MEM_DATA_DIR:(0,dn.join)((0,Ei.homedir)(),".keepmind"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_MODE:"code",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"false",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"false",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"false",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_FULL_COUNT:"0",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"5",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false",CLAUDE_MEM_CONTEXT_SHOW_TERMINAL_OUTPUT:"true",CLAUDE_MEM_WELCOME_HINT_ENABLED:"true",CLAUDE_MEM_FOLDER_CLAUDEMD_ENABLED:"false",CLAUDE_MEM_FOLDER_USE_LOCAL_MD:"false",CLAUDE_MEM_TRANSCRIPTS_ENABLED:"true",CLAUDE_MEM_TRANSCRIPTS_CONFIG_PATH:(0,dn.join)((0,Ei.homedir)(),".keepmind","transcript-watch.json"),CLAUDE_MEM_CODEX_TRANSCRIPT_INGESTION:"false",CLAUDE_MEM_MAX_CONCURRENT_AGENTS:"2",CLAUDE_MEM_HOOK_FAIL_LOUD_THRESHOLD:"3",CLAUDE_MEM_EXCLUDED_PROJECTS:"",CLAUDE_MEM_FOLDER_MD_EXCLUDE:"[]",CLAUDE_MEM_FOLDER_MD_SKELETON_DENYLIST:"[]",CLAUDE_MEM_SEMANTIC_INJECT:"false",CLAUDE_MEM_SEMANTIC_INJECT_LIMIT:"5",CLAUDE_MEM_TIER_ROUTING_ENABLED:"true",CLAUDE_MEM_TIER_SIMPLE_MODEL:"haiku",CLAUDE_MEM_TIER_SUMMARY_MODEL:"",CLAUDE_MEM_TIER_FAST_MODEL:"haiku",CLAUDE_MEM_TIER_SMART_MODEL:"sonnet",CLAUDE_MEM_CHROMA_ENABLED:"true",CLAUDE_MEM_TELEGRAM_ENABLED:"true",CLAUDE_MEM_TELEGRAM_BOT_TOKEN:"",CLAUDE_MEM_TELEGRAM_CHAT_ID:"",CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES:"security_alert",CLAUDE_MEM_TELEGRAM_TRIGGER_CONCEPTS:"",CLAUDE_MEM_QUEUE_ENGINE:"sqlite",CLAUDE_MEM_REDIS_URL:"",CLAUDE_MEM_REDIS_HOST:"127.0.0.1",CLAUDE_MEM_REDIS_PORT:"6379",CLAUDE_MEM_REDIS_MODE:"external",CLAUDE_MEM_QUEUE_REDIS_PREFIX:`claude_mem_${process.env.CLAUDE_MEM_WORKER_PORT??String(37700+(process.getuid?.()??77)%100)}`,CLAUDE_MEM_AUTH_MODE:"api-key",CLAUDE_MEM_RUNTIME:"worker",CLAUDE_MEM_SERVER_URL:`http://127.0.0.1:${process.env.CLAUDE_MEM_SERVER_PORT??String(37877+(process.getuid?.()??77)%100)}`,CLAUDE_MEM_SERVER_API_KEY:"",CLAUDE_MEM_SERVER_PROJECT_ID:"",CLAUDE_MEM_SERVER_BETA_URL:`http://127.0.0.1:${process.env.CLAUDE_MEM_SERVER_PORT??String(37877+(process.getuid?.()??77)%100)}`,CLAUDE_MEM_SERVER_BETA_API_KEY:"",CLAUDE_MEM_SERVER_BETA_PROJECT_ID:""};static getAllDefaults(){return{...this.DEFAULTS}}static envOverride(e){let r=e.replace(/^CLAUDE_MEM_/,"KEEPMIND_");return process.env[r]??process.env[e]}static get(e){return this.envOverride(e)??this.DEFAULTS[e]}static getInt(e){let r=this.get(e);return parseInt(r,10)}static getBool(e){let r=this.get(e);return r==="true"||r===!0}static applyEnvOverrides(e){let r={...e};for(let n of Object.keys(this.DEFAULTS)){let o=this.envOverride(n);o!==void 0&&(r[n]=o)}return r}static loadFromFile(e,r=!0){try{if(!(0,dt.existsSync)(e)){let a=this.getAllDefaults();try{let c=(0,dn.dirname)(e);(0,dt.existsSync)(c)||(0,dt.mkdirSync)(c,{recursive:!0}),So(e,a),console.warn("[SETTINGS] Created settings file with defaults:",e)}catch(c){console.warn("[SETTINGS] Failed to create settings file, using in-memory defaults:",e,c instanceof Error?c.message:String(c))}return r?this.applyEnvOverrides(a):a}let n=(0,dt.readFileSync)(e,"utf-8"),o=JSON.parse(n.replace(/^\uFEFF/,"")),s=o;if(o.env&&typeof o.env=="object"){s=o.env;try{So(e,s),console.warn("[SETTINGS] Migrated settings file from nested to flat schema:",e)}catch(a){console.warn("[SETTINGS] Failed to auto-migrate settings file:",e,a instanceof Error?a.message:String(a))}}let i={...this.DEFAULTS};for(let a of Object.keys(this.DEFAULTS))s[a]!==void 0&&(i[a]=s[a]);return r?this.applyEnvOverrides(i):i}catch(n){console.warn("[SETTINGS] Failed to load settings, using defaults:",e,n instanceof Error?n.message:String(n));let o=this.getAllDefaults();try{if((0,dt.existsSync)(e)){let s=`${e}.corrupt-${Date.now()}`;(0,dt.renameSync)(e,s),console.warn("[SETTINGS] Backed up corrupt settings file to:",s)}So(e,o),console.warn("[SETTINGS] Recovered settings file with defaults:",e)}catch(s){console.warn("[SETTINGS] Failed to recover corrupt settings file:",e,s instanceof Error?s.message:String(s))}return r?this.applyEnvOverrides(o):o}}};var vo=null;function rt(){return vo!==null||(vo=Bt.loadFromFile(Al)),vo}var Xt=require("fs");var $i=require("child_process");var pt=require("fs"),ki=we(require("path"),1);var Qv=["CLAUDECODE_","CLAUDE_CODE_"],eE=new Set(["CLAUDECODE","CLAUDE_CODE_SESSION","CLAUDE_CODE_ENTRYPOINT","MCP_SESSION_ID","HTTP_PROXY","HTTPS_PROXY","ALL_PROXY","NO_PROXY","http_proxy","https_proxy","all_proxy","no_proxy","npm_config_proxy","npm_config_https_proxy"]),tE=new Set(["CLAUDE_CODE_OAUTH_TOKEN","CLAUDE_CODE_GIT_BASH_PATH","CLAUDE_CODE_USE_BEDROCK","CLAUDE_CODE_USE_VERTEX","ANTHROPIC_BEDROCK_BASE_URL","AWS_REGION","AWS_PROFILE","AWS_ACCESS_KEY_ID","AWS_SECRET_ACCESS_KEY","AWS_SESSION_TOKEN","ANTHROPIC_VERTEX_PROJECT_ID","CLOUD_ML_REGION","GOOGLE_APPLICATION_CREDENTIALS"]);function Yt(t=process.env){let e={};for(let[r,n]of Object.entries(t))if(n!==void 0){if(tE.has(r)){e[r]=n;continue}eE.has(r)||Qv.some(o=>r.startsWith(o))||(e[r]=n)}return e}var rE=5e3,nE=1e3,oE=fe.supervisorRegistry();function Et(t){if(!Number.isInteger(t)||t<0||t===0)return!1;try{return process.kill(t,0),!0}catch(e){if(e instanceof Error){let r=e.code;return r==="EPERM"?!0:(f.debug("SYSTEM","PID check failed",{pid:t,code:r}),!1)}return f.warn("SYSTEM","PID check threw non-Error",{pid:t,error:String(e)}),!1}}async function Eo(t,e){let r=Date.now()+e;for(;Date.now()<r;){if(t.every(n=>!Et(n.pid)))return;await new Promise(n=>setTimeout(n,100))}}var sE=5e3,Ul=new Map;function iE(t){let e=Ul.get(t);if(e&&Date.now()-e.capturedAtMs<sE)return e.token;let r=null;try{let n=(0,$i.spawnSync)("powershell.exe",["-NoProfile","-NonInteractive","-Command",`(Get-CimInstance Win32_Process -Filter "ProcessId=${t}").CreationDate.ToString('yyyyMMddHHmmss.ffffff')`],{encoding:"utf-8",timeout:5e3,windowsHide:!0,env:{...Yt(process.env),LC_ALL:"C",LANG:"C"}});if(n.status===0){let o=n.stdout.trim();r=o.length>0?o:null}}catch(n){f.debug("SYSTEM","captureProcessStartToken: powershell CIM lookup failed",{pid:t,error:n instanceof Error?n.message:String(n)}),r=null}return Ul.set(t,{token:r,capturedAtMs:Date.now()}),r}function Fl(t){if(!Number.isInteger(t)||t<=0)return null;if(process.platform==="linux")try{let e=(0,pt.readFileSync)(`/proc/${t}/stat`,"utf-8"),r=e.lastIndexOf(") ");if(r<0)return null;let o=e.slice(r+2).split(" ")[19];return o&&/^\d+$/.test(o)?o:null}catch(e){return f.debug("SYSTEM","captureProcessStartToken: /proc read failed",{pid:t,error:e instanceof Error?e.message:String(e)}),null}if(process.platform==="win32")return iE(t);try{let e=(0,$i.spawnSync)("ps",["-p",String(t),"-o","lstart="],{encoding:"utf-8",timeout:2e3,env:{...Yt(process.env),LC_ALL:"C",LANG:"C"}});if(e.status!==0)return null;let r=e.stdout.trim();return r.length>0?r:null}catch(e){return f.debug("SYSTEM","captureProcessStartToken: ps exec failed",{pid:t,error:e instanceof Error?e.message:String(e)}),null}}function Pi(t){if(!t||!Et(t.pid))return!1;if(!t.startToken)return!0;let e=Fl(t.pid);if(e===null)return!0;let r=e===t.startToken;return r||f.debug("SYSTEM","verifyPidFileOwnership: start-token mismatch (PID reused)",{pid:t.pid,stored:t.startToken,current:e}),r}var xi=class{registryPath;entries=new Map;runtimeProcesses=new Map;initialized=!1;constructor(e=oE){this.registryPath=e}initialize(){if(this.initialized)return;if(this.initialized=!0,(0,pt.mkdirSync)(ki.default.dirname(this.registryPath),{recursive:!0}),!(0,pt.existsSync)(this.registryPath)){this.persist();return}try{let n=JSON.parse((0,pt.readFileSync)(this.registryPath,"utf-8")).processes??{};for(let[o,s]of Object.entries(n))this.entries.set(o,s)}catch(r){r instanceof Error?f.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath},r):f.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath,error:String(r)}),this.entries.clear()}let e=this.pruneDeadEntries();e>0&&f.info("SYSTEM","Removed dead processes from supervisor registry",{removed:e}),this.persist()}register(e,r,n){this.initialize(),this.entries.set(e,r),n&&this.runtimeProcesses.set(e,n),this.persist()}unregister(e){this.initialize();let r=this.entries.get(e);this.entries.delete(e),this.runtimeProcesses.delete(e),this.persist(),r?.type==="sdk"&&bi()}clear(){this.entries.clear(),this.runtimeProcesses.clear(),this.persist()}getAll(){return this.initialize(),Array.from(this.entries.entries()).map(([e,r])=>({id:e,...r})).sort((e,r)=>{let n=Date.parse(e.startedAt),o=Date.parse(r.startedAt);return(Number.isNaN(n)?0:n)-(Number.isNaN(o)?0:o)})}getBySession(e){let r=String(e);return this.getAll().filter(n=>n.sessionId!==void 0&&String(n.sessionId)===r)}getRuntimeProcess(e){return this.runtimeProcesses.get(e)}getByPid(e){return this.getAll().filter(r=>r.pid===e)}pruneDeadEntries(){this.initialize();let e=0,r=0;for(let[n,o]of this.entries)Et(o.pid)||(this.entries.delete(n),this.runtimeProcesses.delete(n),e+=1,o.type==="sdk"&&(r+=1));e>0&&this.persist();for(let n=0;n<r;n+=1)bi();return e}async reapSession(e){this.initialize();let r=this.getBySession(e);if(r.length===0)return 0;let n=typeof e=="number"?e:Number(e)||void 0;f.info("SYSTEM",`Reaping ${r.length} process(es) for session ${e}`,{sessionId:n,pids:r.map(i=>i.pid)});let o=r.filter(i=>Et(i.pid));for(let i of o)try{typeof i.pgid=="number"&&process.platform!=="win32"?process.kill(-i.pgid,"SIGTERM"):process.kill(i.pid,"SIGTERM")}catch(a){a instanceof Error?a.code!=="ESRCH"&&f.debug("SYSTEM",`Failed to SIGTERM session process PID ${i.pid}`,{pid:i.pid,pgid:i.pgid},a):f.warn("SYSTEM",`Failed to SIGTERM session process PID ${i.pid} (non-Error)`,{pid:i.pid,pgid:i.pgid,error:String(a)})}await Eo(o,rE);let s=o.filter(i=>Et(i.pid));for(let i of s){f.warn("SYSTEM",`Session process PID ${i.pid} did not exit after SIGTERM, sending SIGKILL`,{pid:i.pid,pgid:i.pgid,sessionId:n});try{typeof i.pgid=="number"&&process.platform!=="win32"?process.kill(-i.pgid,"SIGKILL"):process.kill(i.pid,"SIGKILL")}catch(a){a instanceof Error?a.code!=="ESRCH"&&f.debug("SYSTEM",`Failed to SIGKILL session process PID ${i.pid}`,{pid:i.pid,pgid:i.pgid},a):f.warn("SYSTEM",`Failed to SIGKILL session process PID ${i.pid} (non-Error)`,{pid:i.pid,pgid:i.pgid,error:String(a)})}}if(s.length>0){let i=Date.now()+nE;for(;Date.now()<i&&s.filter(c=>Et(c.pid)).length!==0;)await new Promise(c=>setTimeout(c,100))}for(let i of r)this.entries.delete(i.id),this.runtimeProcesses.delete(i.id);this.persist();for(let i of r)i.type==="sdk"&&bi();return f.info("SYSTEM",`Reaped ${r.length} process(es) for session ${e}`,{sessionId:n,reaped:r.length}),r.length}persist(){let e={processes:Object.fromEntries(this.entries.entries())};(0,pt.mkdirSync)(ki.default.dirname(this.registryPath),{recursive:!0}),(0,pt.writeFileSync)(this.registryPath,JSON.stringify(e,null,2))}},wi=null;function wo(){return wi||(wi=new xi),wi}var aE=[];function bi(){let t=aE.shift();t&&t()}var ql=require("child_process"),Er=require("fs"),Hl=require("util");var cE=(0,Hl.promisify)(ql.execFile),uE=fe.workerPid();async function Wl(t){let e=t.currentPid??process.pid,r=t.pidFilePath??uE,n=t.registry.getAll(),o=[...n].filter(i=>i.pid!==e).sort((i,a)=>Date.parse(a.startedAt)-Date.parse(i.startedAt));for(let i of o){if(!Et(i.pid)){t.registry.unregister(i.id);continue}try{await Zl(i,"SIGTERM")}catch(a){a instanceof Error?f.debug("SYSTEM","Failed to send SIGTERM to child process",{pid:i.pid,pgid:i.pgid,type:i.type},a):f.warn("SYSTEM","Failed to send SIGTERM to child process (non-Error)",{pid:i.pid,pgid:i.pgid,type:i.type,error:String(a)})}}await Eo(o,5e3);let s=o.filter(i=>Et(i.pid));for(let i of s)try{await Zl(i,"SIGKILL")}catch(a){a instanceof Error?f.debug("SYSTEM","Failed to force kill child process",{pid:i.pid,pgid:i.pgid,type:i.type},a):f.warn("SYSTEM","Failed to force kill child process (non-Error)",{pid:i.pid,pgid:i.pgid,type:i.type,error:String(a)})}await Eo(s,1e3);for(let i of o)t.registry.unregister(i.id);for(let i of n.filter(a=>a.pid===e))t.registry.unregister(i.id);lE(r,e),t.registry.pruneDeadEntries()}function lE(t,e){if(!(0,Er.existsSync)(t))return;let r=null;try{let n=JSON.parse((0,Er.readFileSync)(t,"utf-8"));r=typeof n.pid=="number"?n.pid:null}catch(n){f.debug("SYSTEM","PID file unreadable during shutdown \u2014 leaving it (cannot prove ownership)",{pidFilePath:t,error:n instanceof Error?n.message:String(n)});return}if(r!==e){f.debug("SYSTEM","PID file not owned by this process \u2014 leaving it for its owner (restart successor?)",{pidFilePath:t,recordedPid:r,currentPid:e});return}try{(0,Er.rmSync)(t,{force:!0})}catch(n){n instanceof Error?f.debug("SYSTEM","Failed to remove PID file during shutdown",{pidFilePath:t},n):f.warn("SYSTEM","Failed to remove PID file during shutdown (non-Error)",{pidFilePath:t,error:String(n)})}}async function Zl(t,e){let{pid:r,pgid:n}=t;if(process.platform!=="win32"){if(typeof n=="number")try{process.kill(-n,e);return}catch(i){if((i instanceof Error?i.code:void 0)!=="ESRCH")throw i}try{process.kill(r,e)}catch(i){if((i instanceof Error?i.code:void 0)!=="ESRCH")throw i}return}if(e==="SIGTERM"){try{process.kill(r,e)}catch(i){if(i instanceof Error&&i.code==="ESRCH")return;throw i}return}let o=await dE();if(o){await new Promise((i,a)=>{o(r,e,c=>{if(!c){i();return}if(c.code==="ESRCH"){i();return}a(c)})});return}let s=["/PID",String(r),"/T"];e==="SIGKILL"&&s.push("/F"),await cE("taskkill",s,{timeout:ue.POWERSHELL_COMMAND,windowsHide:!0})}async function dE(){let t="tree-kill";try{let e=await import(t);return e.default??e}catch(e){return f.debug("SYSTEM","tree-kill module not available, using fallback",{},e instanceof Error?e:void 0),null}}var Kl=3e4,wr=null;function pE(){let e=wo().pruneDeadEntries();e>0&&f.info("SYSTEM",`Health check: pruned ${e} dead process(es) from registry`)}function Vl(){wr===null&&(wr=setInterval(pE,Kl),wr.unref(),f.debug("SYSTEM","Health checker started",{intervalMs:Kl}))}function Jl(){wr!==null&&(clearInterval(wr),wr=null,f.debug("SYSTEM","Health checker stopped"))}var fE=fe.workerPid(),Ti=class{registry;started=!1;stopPromise=null;signalHandlersRegistered=!1;shutdownInitiated=!1;shutdownHandler=null;constructor(e){this.registry=e}async start(){if(this.started)return;if(this.registry.initialize(),pn({logAlive:!1})==="alive")throw new Error("Worker already running");this.started=!0,Vl()}configureSignalHandlers(e){if(this.shutdownHandler=e,this.signalHandlersRegistered)return;this.signalHandlersRegistered=!0;let r=async n=>{if(this.shutdownInitiated){f.warn("SYSTEM",`Received ${n} but shutdown already in progress`);return}this.shutdownInitiated=!0,f.info("SYSTEM",`Received ${n}, shutting down...`);try{this.shutdownHandler?await this.shutdownHandler():await this.stop()}catch(o){o instanceof Error?f.error("SYSTEM","Error during shutdown",{},o):f.error("SYSTEM","Error during shutdown (non-Error)",{error:String(o)});try{await this.stop()}catch(s){s instanceof Error?f.debug("SYSTEM","Supervisor shutdown fallback failed",{},s):f.debug("SYSTEM","Supervisor shutdown fallback failed",{error:String(s)})}}process.exit(0)};process.on("SIGTERM",()=>{r("SIGTERM")}),process.on("SIGINT",()=>{r("SIGINT")}),process.platform!=="win32"&&(process.argv.includes("--daemon")?process.on("SIGHUP",()=>{f.debug("SYSTEM","Ignoring SIGHUP in daemon mode")}):process.on("SIGHUP",()=>{r("SIGHUP")}))}async stop(){if(this.stopPromise){await this.stopPromise;return}Jl(),this.stopPromise=Wl({registry:this.registry,currentPid:process.pid}).finally(()=>{this.started=!1,this.stopPromise=null}),await this.stopPromise}assertCanSpawn(e){if(this.stopPromise!==null)throw new Error(`Supervisor is shutting down, refusing to spawn ${e}`)}registerProcess(e,r,n){this.registry.register(e,r,n)}unregisterProcess(e){this.registry.unregister(e)}getRegistry(){return this.registry}},mE=new Ti(wo());function Oi(){return mE}function pn(t={}){let e=t.pidFilePath??fE;if(!(0,Xt.existsSync)(e))return"missing";let r=null;try{r=JSON.parse((0,Xt.readFileSync)(e,"utf-8"))}catch(o){return o instanceof Error?f.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:e},o):f.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:e,error:String(o)}),(0,Xt.rmSync)(e,{force:!0}),"invalid"}return Pi(r)&&r?((t.logAlive??!0)&&f.info("SYSTEM","Worker already running (PID alive)",{existingPid:r.pid,existingPort:r.port,startedAt:r.startedAt}),"alive"):(f.info("SYSTEM","Removing stale PID file (worker process is dead or PID has been reused)",{pid:r?.pid,port:r?.port,startedAt:r?.startedAt}),(0,Xt.rmSync)(e,{force:!0}),"stale")}var Yl=we(require("path"),1),Xl=require("os"),be=require("fs"),Ql=require("child_process");function Gl(t){return t instanceof Error?t:new Error(String(t))}var YI=fe.dataDir(),ft=fe.workerPid(),XI=fe.workerPort();function Bl(t){return t?/(^|[\\/])node(\.exe)?$/i.test(t.trim()):!1}function hE(t,e){let r=e==="win32"?`where ${t}`:`which ${t}`,n;try{n=(0,Ql.execSync)(r,{stdio:["ignore","pipe","ignore"],encoding:"utf-8",windowsHide:!0})}catch(s){return s instanceof Error?f.debug("SYSTEM",`Binary lookup failed for ${t}`,{command:r},s):f.debug("SYSTEM",`Binary lookup failed for ${t}`,{command:r},new Error(String(s))),null}return n.split(/\r?\n/).map(s=>s.trim()).find(s=>s.length>0)||null}var zi;function Ri(t={}){let e=Object.keys(t).length===0;if(e&&zi!==void 0)return zi;let r=gE(t);return e&&r!==null&&(zi=r),r}function gE(t){let e=t.platform??process.platform,r=t.execPath??process.execPath;if(Bl(r))return r;let n=t.env??process.env,o=t.homeDirectory??(0,Xl.homedir)(),s=t.pathExists??be.existsSync,i=t.lookupInPath??hE,a=e==="win32"?[n.NODE,Yl.default.join(o,".nvm","current","bin","node.exe"),"node"]:[n.NODE,"/usr/local/bin/node","/opt/homebrew/bin/node","/usr/bin/node","node"];for(let c of a){let u=c?.trim();if(u&&(Bl(u)&&s(u)||u.toLowerCase()==="node"))return u}return i("node",e)}function ed(){if(!(0,be.existsSync)(ft))return null;try{return JSON.parse((0,be.readFileSync)(ft,"utf-8"))}catch(t){return t instanceof Error?f.warn("SYSTEM","Failed to parse PID file",{path:ft},t):f.warn("SYSTEM","Failed to parse PID file",{path:ft},new Error(String(t))),null}}function td(){if((0,be.existsSync)(ft))try{(0,be.unlinkSync)(ft)}catch(t){t instanceof Error?f.warn("SYSTEM","Failed to remove PID file",{path:ft},t):f.warn("SYSTEM","Failed to remove PID file",{path:ft},new Error(String(t)))}}function Rt(t){return process.platform==="win32"?Math.round(t*2):t}function rd(t,e,r={}){Oi().assertCanSpawn("worker daemon");let n=Yt({...process.env,CLAUDE_MEM_WORKER_PORT:String(e),...r}),o=Ri();if(!o){f.error("SYSTEM","Node runtime not found \u2014 ensure node is on PATH or set the NODE env var. The worker daemon runs under Node (node:sqlite).");return}if(process.platform==="win32")try{let l=yr(o,[t,"--daemon"],{detached:!0,stdio:"ignore",windowsHide:!0,env:n});if(l.pid===void 0){f.error("SYSTEM","Worker daemon spawn produced no PID on Windows",{runtimePath:o});return}return l.unref(),l.pid}catch(l){f.error("SYSTEM","Failed to spawn worker daemon on Windows",{runtimePath:o},Gl(l));return}let s="/usr/bin/setsid",i=(0,be.existsSync)(s),u=yr(i?s:o,i?[o,t,"--daemon"]:[t,"--daemon"],{detached:!0,stdio:"ignore",env:n});if(u.pid!==void 0)return u.unref(),u.pid}function nd(t){if(t===0)return!0;if(!Number.isInteger(t)||t<0)return!1;try{return process.kill(t,0),!0}catch(e){if(e instanceof Error){let r=e.code;if(r==="EPERM")return!0;f.debug("SYSTEM","Process not alive",{pid:t,code:r})}else f.debug("SYSTEM","Process not alive (non-Error thrown)",{pid:t},new Error(String(e)));return!1}}function od(){try{if(!(0,be.existsSync)(ft))return;let t=new Date;(0,be.utimesSync)(ft,t,t)}catch{}}function sd(){return pn({logAlive:!1})}var id=we(require("path"),1),ad=we(require("net"),1),cd=require("fs");var _E=2500;async function ud(t,e,r="GET"){let n=await fetch(`http://127.0.0.1:${t}${e}`,{method:r,signal:AbortSignal.timeout(_E)}),o="";try{o=await n.text()}catch{}return{ok:n.ok,statusCode:n.status,body:o}}async function ld(t){return new Promise(e=>{let r=ad.default.createServer();r.once("error",n=>{n.code==="EADDRINUSE"||n.code==="EACCES"?e(!0):e(!1)}),r.once("listening",()=>{r.close(()=>e(!1))}),r.listen(t,"127.0.0.1")})}async function dd(t,e,r,n){let o=Date.now();for(;Date.now()-o<r;){try{if((await ud(t,e)).ok)return!0}catch(s){s instanceof Error?f.debug("SYSTEM",n,{},s):f.debug("SYSTEM",n,{error:String(s)})}await new Promise(s=>setTimeout(s,500))}return!1}function fn(t,e=3e4){return dd(t,"/api/health",e,"Service not ready yet, will retry")}function mn(t,e=3e4){return dd(t,"/api/readiness",e,"Worker not ready yet, will retry")}function yE(){try{let t=id.default.join(vr,"package.json");return JSON.parse((0,cd.readFileSync)(t,"utf-8")).version}catch(t){if(t instanceof Error){let e=t.code;if(e==="ENOENT"||e==="EBUSY")return f.debug("SYSTEM","Could not read plugin version (shutdown race)",{code:e}),"unknown";throw t}throw t}}async function SE(t){try{let e=await ud(t,"/api/version");return e.ok?JSON.parse(e.body).version:null}catch{return f.debug("SYSTEM","Could not fetch worker version",{}),null}}async function pd(t){let e=yE(),r=await SE(t);return!r||e==="unknown"?{matches:!0,pluginVersion:e,workerVersion:r}:{matches:e===r,pluginVersion:e,workerVersion:r}}var bo=require("path"),Ke=require("fs");var vE=6e4;function fd(){return(0,bo.join)(pi(),"spawn.lock")}function ko(){let t=fd(),e=JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()});for(let r=0;r<2;r++)try{return(0,Ke.mkdirSync)((0,bo.dirname)(t),{recursive:!0}),(0,Ke.writeFileSync)(t,e,{flag:"wx"}),!0}catch(n){if(n?.code!=="EEXIST")return!0;if(r>0)return!1;let s;try{s=(0,Ke.statSync)(t).mtimeMs}catch{continue}if(Date.now()-s<=vE)return!1;let i;try{i=(0,Ke.statSync)(t).mtimeMs}catch{continue}if(i!==s)return!1;try{(0,Ke.unlinkSync)(t)}catch{return!1}}return!1}function xo(){let t=fd();try{if(JSON.parse((0,Ke.readFileSync)(t,"utf-8")).pid!==process.pid)return;(0,Ke.unlinkSync)(t)}catch{}}function Mi(t,e,r){let n=process.env[t];if(n){let o=parseInt(n,10);if(Number.isFinite(o)&&o>=r.min&&o<=r.max)return o;f.warn("SYSTEM",`Invalid ${t}, using default`,{value:n,min:r.min,max:r.max})}return e}var Ro=Mi("CLAUDE_MEM_HEALTH_TIMEOUT_MS",vt(ue.HEALTH_CHECK),{min:500,max:3e5}),kC=Mi("CLAUDE_MEM_API_TIMEOUT_MS",vt(ue.API_REQUEST),{min:500,max:3e5}),_d=Mi("CLAUDE_MEM_HOOK_READINESS_TIMEOUT_MS",vt(ue.HOOK_READINESS_WAIT),{min:0,max:3e5}),EE={min:500,max:3e5};async function Ni(t,e={},r){try{return await fetch(t,{...e,signal:AbortSignal.timeout(r)})}catch(n){throw n instanceof DOMException&&n.name==="TimeoutError"?new Error(`Request timed out after ${r}ms`):n}}var $o=null,Po=null,To=null,Oo=null;function wE(){return br.default.join(Bt.get("CLAUDE_MEM_DATA_DIR"),"settings.json")}function bE(t){if(!Number.isInteger(t)||t<=0)return!1;try{return process.kill(t,0),!0}catch(e){return e?.code==="EPERM"}}function kE(){try{let t=fe.workerPid();if(!(0,Fe.existsSync)(t))return null;let e=JSON.parse((0,Fe.readFileSync)(t,"utf-8"));return typeof e.pid!="number"||typeof e.port!="number"||!bE(e.pid)?null:e.port}catch{return null}}function Di(){return To!==null||(To=Bt.loadFromFile(wE())),To}function md(t,e){if(!t)return null;let r=parseInt(t,10);return Number.isFinite(r)&&r>=e.min&&r<=e.max?r:null}function xE(t,e,r){let n=process.env[t];if(n!==void 0){let i=md(n,r);return i!==null?i:(f.warn("SYSTEM",`Invalid ${t}, using default`,{value:n,min:r.min,max:r.max}),e)}let o=Di()[t],s=md(o,r);return s!==null?s:(f.warn("SYSTEM",`Invalid ${t} in settings.json, using default`,{value:o,min:r.min,max:r.max}),e)}function $E(){if($o!==null)return $o;let t=Di();return $o=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),$o}function It(){let t=kE();return t!==null?t:$E()}function PE(){return Po!==null||(Po=Di().CLAUDE_MEM_WORKER_HOST),Po}function TE(){return Oo!==null||(Oo=xE("CLAUDE_MEM_API_TIMEOUT_MS",vt(ue.API_REQUEST),EE)),Oo}function OE(t){return`http://${PE()}:${It()}${t}`}function Qt(t,e={}){let r=e.method??"GET",n=e.timeoutMs??TE(),o=OE(t),s={method:r};return e.headers&&(s.headers=e.headers),e.body&&(s.body=e.body),n>0?Ni(o,s,n):fetch(o,s)}async function zE(){return(await Qt("/api/health",{timeoutMs:Ro})).ok}async function hd(){return(await Qt("/api/readiness",{timeoutMs:Ro})).ok}function Li(){let t=[br.default.join(vr,"plugin","scripts","worker-service.cjs"),br.default.join(process.cwd(),"plugin","scripts","worker-service.cjs")];for(let e of t)if((0,Fe.existsSync)(e))return e;return null}async function RE(t){let e=t.backoffMs;for(let r=1;r<=t.attempts;r++){if(await Sd())return!0;r<t.attempts&&(await new Promise(n=>setTimeout(n,e)),e*=2)}return!1}async function Ii(t=_d){if(t<=0)try{return await hd()}catch{return!1}let e=Date.now();for(;Date.now()-e<t;){try{if(await hd())return!0}catch(n){f.debug("SYSTEM","Worker readiness check threw",{error:n instanceof Error?n.message:String(n)})}let r=t-(Date.now()-e);if(r<=0)break;await new Promise(n=>setTimeout(n,Math.min(250,r)))}return!1}async function yd(){try{let e=await(await Qt("/api/health",{timeoutMs:Ro})).json();return typeof e.version=="string"?e.version:null}catch{return null}}async function IE(t,e=_d){let r=Date.now();for(;Date.now()-r<e;){if(await yd()===t)return!0;let o=e-(Date.now()-r);if(o<=0)break;await new Promise(s=>setTimeout(s,Math.min(500,o)))}return!1}async function Ci(t){let e=await yd();e!==null&&e!==t&&f.warn("SYSTEM","Worker is ready but still reports a stale version; not recycling again in this hook invocation (one recycle per hook event)",{pluginVersion:t,workerVersion:e})}async function Sd(){let t;try{t=await zE()}catch(r){return f.debug("SYSTEM","Worker health check threw",{error:r instanceof Error?r.message:String(r)}),!1}if(!t)return!1;let e=pn({logAlive:!1});return e==="missing"||e==="alive"}async function CE(){let t=null;if(await Sd()){let{matches:s,pluginVersion:i,workerVersion:a}=await pd(It());if(i!=="unknown"&&(t=i),s)return await Ii()?(t!==null&&await Ci(t),!0):(f.warn("SYSTEM","Worker is healthy but not ready; skipping hook API call"),!1);f.info("SYSTEM","Worker version mismatch \u2014 recycling stale worker",{pluginVersion:i,workerVersion:a});try{if(await Qt("/api/admin/restart",{method:"POST",timeoutMs:Ro}),await IE(i))return await Ii()?(t!==null&&await Ci(t),!0):(f.warn("SYSTEM","Recycled worker appeared but did not become ready; skipping hook API call"),!1);f.warn("SYSTEM","No successor worker appeared after recycle; falling through to lazy-spawn",{pluginVersion:i,workerVersion:a})}catch(c){f.debug("SYSTEM","Worker restart request failed; falling through to lazy-spawn",{error:c instanceof Error?c.message:String(c)})}}let e=Ri(),r=Li();if(!e)return f.warn("SYSTEM","Cannot lazy-spawn worker: Node runtime not found on PATH"),!1;if(!r)return f.warn("SYSTEM","Cannot lazy-spawn worker: worker-service.cjs not found in plugin/scripts"),!1;let n=ko();try{if(n){f.info("SYSTEM","Worker not running \u2014 lazy-spawning",{runtimePath:e,scriptPath:r});try{yr(e,[r,"--daemon"],{detached:!0,stdio:["ignore","ignore","ignore"]}).unref()}catch(i){return i instanceof Error?f.error("SYSTEM","Lazy-spawn of worker failed",{runtimePath:e,scriptPath:r},i):f.error("SYSTEM","Lazy-spawn of worker failed (non-Error)",{runtimePath:e,scriptPath:r,error:String(i)}),!1}}else f.info("SYSTEM","Another launcher holds the spawn lock \u2014 skipping lazy-spawn and waiting for its worker");if(!await RE({attempts:6,backoffMs:500}))return f.warn("SYSTEM",n?"Worker port did not open after lazy-spawn within the cold-boot wait (~15s)":"Spawn-lock holder's worker port did not open within the cold-boot wait (~15s)"),!1}finally{n&&xo()}return await Ii()?(t!==null&&await Ci(t),!0):(f.warn("SYSTEM","Worker lazy-spawned but did not become ready before hook readiness timeout"),!1)}var zo=null;async function AE(){return zo!==null||(zo=await CE()),zo}var ME=3;function vd(){return br.default.join(B,"state")}function Ed(){return br.default.join(vd(),"hook-failures.json")}function wd(){try{let t=(0,Fe.readFileSync)(Ed(),"utf-8"),e=JSON.parse(t);return{consecutiveFailures:typeof e.consecutiveFailures=="number"&&Number.isFinite(e.consecutiveFailures)?Math.max(0,Math.floor(e.consecutiveFailures)):0,lastFailureAt:typeof e.lastFailureAt=="number"&&Number.isFinite(e.lastFailureAt)?e.lastFailureAt:0}}catch{return{consecutiveFailures:0,lastFailureAt:0}}}function bd(t){let e=vd(),r=Ed(),n=`${r}.tmp`;try{(0,Fe.existsSync)(e)||(0,Fe.mkdirSync)(e,{recursive:!0}),(0,Fe.writeFileSync)(n,JSON.stringify(t),"utf-8"),(0,Fe.renameSync)(n,r)}catch(o){f.debug("SYSTEM","Failed to persist hook-failure counter",{error:o instanceof Error?o.message:String(o)})}}function NE(){try{let e=rt().CLAUDE_MEM_HOOK_FAIL_LOUD_THRESHOLD,r=parseInt(e,10);if(Number.isFinite(r)&&r>=1)return r}catch{}return ME}var DE=["context","session-init","observation","summarize","file-context"],LE=null;function kd(t){LE=DE.includes(t)?t:null}async function ji(){let e={consecutiveFailures:wd().consecutiveFailures+1,lastFailureAt:Date.now()};bd(e);let r=NE();return e.consecutiveFailures>=r&&un(`keepmind worker unreachable for ${e.consecutiveFailures} consecutive hooks \u2014 continuing without memory capture. Run \`keepmind doctor\` to diagnose.`),e.consecutiveFailures}function gd(){wd().consecutiveFailures!==0&&bd({consecutiveFailures:0,lastFailureAt:0})}var Ai=Symbol.for("claude-mem/worker-fallback");function me(t){return typeof t=="object"&&t!==null&&t[Ai]===!0}async function le(t,e,r,n={}){if(!await AE())return await ji(),{continue:!0,reason:"worker_unreachable",[Ai]:!0};let s={method:e};r!==void 0&&(s.headers={"Content-Type":"application/json"},s.body=JSON.stringify(r)),n.timeoutMs!==void 0&&(s.timeoutMs=n.timeoutMs);let i=await Qt(t,s);if(!i.ok){let c=await i.text().catch(()=>"");if(gd(),i.status===429||i.status>=500)return f.warn("SYSTEM",`Worker API ${e} ${t} returned ${i.status}; skipping hook API call`,{body:c.substring(0,200)}),{continue:!0,reason:`worker_api_${i.status}`,[Ai]:!0};let u=c;try{u=JSON.parse(c)}catch{}return u}gd();let a=await i.text();if(a.length!==0)try{return JSON.parse(a)}catch{return a}}var xd=require("fs");function jE(t){let e=ed();return e&&typeof e.port=="number"&&nd(e.pid)?e.port:t}async function UE(t,e){let r=Date.now()+e;for(;Date.now()<r;){let n=jE(t);if(await fn(n,800))return n;await new Promise(o=>setTimeout(o,300))}return null}async function $d(t,e){if(!e)return f.error("SYSTEM","ensureWorkerStarted called with empty workerScriptPath \u2014 caller bug"),"dead";if(!(0,xd.existsSync)(e))return f.error("SYSTEM","ensureWorkerStarted: worker script not found at expected path \u2014 likely a partial install or build artifact missing",{workerScriptPath:e}),"dead";if(await fn(t,1e3)){let a=await mn(t,Rt(ue.READINESS_WAIT));return a||f.warn("SYSTEM","Worker is alive but readiness timed out \u2014 proceeding anyway"),f.info("SYSTEM","Worker already running and healthy (fast path)"),a?"ready":"warming"}if(sd()==="alive"){if(f.info("SYSTEM","Worker PID file points to a live process, waiting for it to become healthy"),await fn(t,Rt(ue.POST_SPAWN_WAIT))){let c=await mn(t,Rt(ue.READINESS_WAIT));return f.info("SYSTEM","Worker became healthy while waiting on live PID"),c?"ready":"warming"}f.warn("SYSTEM","PID file marked live but worker never became healthy within the cold-boot window \u2014 treating it as a stale/reused PID and re-spawning"),td()}if(await ld(t)){if(f.info("SYSTEM","Port in use, waiting for worker to become healthy"),await fn(t,Rt(ue.PORT_IN_USE_WAIT))){let c=await mn(t,Rt(ue.READINESS_WAIT));return f.info("SYSTEM","Worker is now healthy"),c?"ready":"warming"}f.warn("SYSTEM","Configured port in use but no healthy worker \u2014 spawning anyway (worker will pick a free ephemeral port)")}let o=ko(),s=t;try{if(o){if(f.info("SYSTEM","Starting worker daemon",{workerScriptPath:e}),rd(e,t)===void 0)return f.error("SYSTEM","Failed to spawn worker daemon"),"dead"}else f.info("SYSTEM","Another launcher holds the spawn lock \u2014 skipping duplicate spawn and waiting for its worker");let a=await UE(t,Rt(ue.POST_SPAWN_WAIT));if(a===null)return f.warn("SYSTEM",o?"Worker spawned but health endpoint not responding within window \u2014 likely still starting in background":"Spawn-lock holder's worker not healthy within window \u2014 likely still starting in background"),"warming";s=a}finally{o&&xo()}let i=await mn(s,Rt(ue.READINESS_WAIT));return i||f.warn("SYSTEM","Worker is alive but readiness timed out \u2014 proceeding anyway"),od(),f.info("SYSTEM",o?"Worker started successfully":"Worker is up (started by another launcher)"),i?"ready":"warming"}function FE(){try{let t=process.stdin;return t.isTTY?!1:(t.readable,!0)}catch(t){return f.debug("HOOK","stdin not available (expected for some runtimes)",{error:t instanceof Error?t.message:String(t)}),!1}}function ZE(t){let e=t.trim();if(!e)return{success:!1};try{return{success:!0,value:JSON.parse(e)}}catch(r){return f.debug("HOOK","JSON parse attempt incomplete",{error:r instanceof Error?r.message:String(r)}),{success:!1}}}var Pd=3e4;async function Td(){if(FE())return new Promise((t,e)=>{let r="",n=!1,o=()=>{try{process.stdin.removeAllListeners("data"),process.stdin.removeAllListeners("end"),process.stdin.removeAllListeners("error")}catch{}},s=p=>{n||(n=!0,clearTimeout(c),o(),t(p))},i=p=>{n||(n=!0,clearTimeout(c),o(),e(p))},a=()=>{let p=ZE(r);return p.success?(s(p.value),!0):!1},c=setTimeout(()=>{n||a()||(r.trim()?i(new Error(`Incomplete JSON after ${Pd}ms: ${r.slice(0,100)}...`)):s(void 0))},Pd),u=p=>{r+=p,a()},l=()=>{n||a()||(r.trim()?i(new Error(`Malformed JSON at stdin EOF: ${r.slice(0,100)}...`)):s(void 0))},d=()=>{n||s(void 0)};try{process.stdin.on("data",u),process.stdin.on("end",l),process.stdin.on("error",d)}catch(p){f.debug("HOOK","Failed to attach stdin listeners",{error:p instanceof Error?p.message:String(p)}),n=!0,clearTimeout(c),o(),t(void 0)}})}var he=class extends Error{constructor(r){super(`adapter rejected input: ${r}`);this.reason=r;this.name="AdapterRejectedInput"}reason};function Ve(t){return typeof t=="string"&&t.length>0}var qE=128,Od=t=>typeof t=="string"&&t.length>0&&t.length<=qE?t:void 0,zd={normalizeInput(t){let e=t??{},r=e.cwd??process.cwd();if(!Ve(r))throw new he("invalid_cwd");return{sessionId:e.session_id??e.id??e.sessionId,cwd:r,prompt:e.prompt,toolName:e.tool_name,toolInput:e.tool_input,toolResponse:e.tool_response,transcriptPath:e.transcript_path,agentId:Od(e.agent_id),agentType:Od(e.agent_type)}},formatOutput(t){let e=t??{};if(e.hookSpecificOutput){let n={hookSpecificOutput:t.hookSpecificOutput};return e.systemMessage&&(n.systemMessage=e.systemMessage),n}let r={};return e.systemMessage&&(r.systemMessage=e.systemMessage),r}};var Co=require("fs"),Io=we(require("path"),1),qd=we(Fd(),1),ew=10,tw=new Set(["cat","head","tail","less","more","bat","view","nl","tac"]),rw={head:new Set(["-n","-c","--lines","--bytes"]),tail:new Set(["-n","-c","--lines","--bytes"])},nw=new Set;function ow(t){return typeof t=="object"&&t!==null&&"op"in t}function sw(t){let e=[],r=[];for(let n of t){if(ow(n)){r.length>0&&e.push(r),r=[];continue}typeof n=="string"&&r.push(n)}return r.length>0&&e.push(r),e}function iw(t){if(typeof t=="string")return t;if(Array.isArray(t)){let e=t.filter(r=>typeof r=="string");return e.length>0?e.join(" "):null}return null}function Zd(t){return t.startsWith("-")||t.startsWith("+")}function aw(t){return rw[t]??nw}function cw(t,e){let r=aw(e);if(r.has(t))return!0;let n=t.indexOf("=");return n>0&&r.has(t.slice(0,n))}function Hd(t,e){let r=Io.default.isAbsolute(t)?t:Io.default.resolve(e,t);try{return(0,Co.existsSync)(r)?(0,Co.statSync)(r).isFile():!1}catch{return!1}}function Wd(t){let e=new Set,r=[];for(let n of t)if(!e.has(n)&&(e.add(n),r.push(n),r.length>=ew))break;return r}function uw(t,e){let r=iw(t?.command);if(!r)return[];let n=(0,qd.parse)(r),o=[];for(let s of sw(n)){let i=s.findIndex(u=>u&&!Zd(u));if(i===-1)continue;let a=Io.default.basename(s[i]);if(!tw.has(a))continue;let c=!1;for(let u of s.slice(i+1)){if(c){c=!1;continue}if(Zd(u)){c=cw(u,a)&&!u.includes("=");continue}Hd(u,e)&&o.push(u)}}return Wd(o)}function lw(t,e,r){if(!/^mcp__.+__(read|view|cat)(?:_file|_files)?$/.test(t))return[];let n=e??{},o=[];if(typeof n.path=="string"&&o.push(n.path),Array.isArray(n.paths))for(let s of n.paths)typeof s=="string"&&o.push(s);return Wd(o.filter(s=>Hd(s,r)))}function Kd(t,e,r){return t==="Bash"?uw(e,r):t.startsWith("mcp__")?lw(t,e,r):[]}var dw=new Set(["PreToolUse","PermissionRequest","PostToolUse","SessionStart","UserPromptSubmit","Stop"]);function Vd(t){return typeof t=="string"&&dw.has(t)?t:void 0}function Ct(t){return typeof t=="string"&&t.length>0?t:void 0}function pw(t){if(typeof t=="boolean")return t;if(t==="true")return!0;if(t==="false")return!1}function fw(t){return t&&typeof t=="object"&&!Array.isArray(t)?{...t}:t}function mw(t){let e={};return t.continue!==void 0&&(e.continue=t.continue),t.systemMessage&&(e.systemMessage=t.systemMessage),t.decision==="block"&&(e.decision="block"),t.reason&&(e.reason=t.reason),e}function hw(t){return Vd(t.hookSpecificOutput?.hookEventName)}var Jd={normalizeInput(t){let e=t??{},r=typeof e.cwd=="string"?e.cwd:process.cwd();if(!Ve(r))throw new he("invalid_cwd");let n=Vd(e.hook_event_name),o=Ct(e.tool_name),s=fw(e.tool_input);if(n==="PreToolUse"&&o){let u=Kd(o,s,r);u.length>0&&s&&typeof s=="object"&&!Array.isArray(s)&&(s={...s,filePaths:u})}let i=e.source,a=i==="startup"||i==="resume"||i==="clear"?i:void 0,c=Ct(e.session_id);if(!c)throw new he("missing_session_id");return{sessionId:c,cwd:r,prompt:Ct(e.prompt),toolName:o,toolInput:s,toolResponse:e.tool_response,transcriptPath:Ct(e.transcript_path),lastAssistantMessage:Ct(e.last_assistant_message),turnId:Ct(e.turn_id),stopHookActive:pw(e.stop_hook_active),permissionMode:Ct(e.permission_mode),model:Ct(e.model),sessionSource:a}},formatOutput(t){let e=t??{},r=mw(e),n=e.hookSpecificOutput,o=hw(e);if(!n||!o||o==="Stop")return r;let s={hookEventName:o};return n.additionalContext&&(s.additionalContext=n.additionalContext),o==="PreToolUse"&&(n.permissionDecision==="deny"&&(s.permissionDecision="deny",n.permissionDecisionReason&&(s.permissionDecisionReason=n.permissionDecisionReason)),n.updatedInput&&(s.updatedInput=n.updatedInput)),r.hookSpecificOutput=s,r}};var Gd=require("fs"),Bd=require("os"),Yd=require("path");var gw=/^[A-Za-z0-9_-]+$/;function _w(t,e){if(!t||!e||!gw.test(e))return;let r=t.replace(/^\//,"").replace(/[/.]/g,"-"),n=(0,Yd.join)((0,Bd.homedir)(),".cursor","projects",r,"agent-transcripts",e,`${e}.jsonl`);return(0,Gd.existsSync)(n)?n:void 0}var Xd={normalizeInput(t){let e=t??{},r=!!e.command&&!e.tool_name,n=e.workspace_roots?.[0]??e.cwd??process.cwd();if(!Ve(n))throw new he("invalid_cwd");let o=e.conversation_id||e.generation_id||e.id;return{sessionId:o,cwd:n,prompt:e.prompt??e.query??e.input??e.message,toolName:r?"Bash":e.tool_name,toolInput:r?{command:e.command}:e.tool_input,toolResponse:r?{output:e.output}:e.result_json,transcriptPath:_w(n,o),filePath:e.file_path,edits:e.edits}},formatOutput(t){return{continue:t.continue??!0}}};var Qd={normalizeInput(t){let e=t??{},r=e.cwd??process.env.GEMINI_CWD??process.env.GEMINI_PROJECT_DIR??process.env.CLAUDE_PROJECT_DIR??process.cwd();if(!Ve(r))throw new he("invalid_cwd");let n=e.session_id??process.env.GEMINI_SESSION_ID??void 0,o=e.hook_event_name,s=e.tool_name,i=e.tool_input,a=e.tool_response;return o==="AfterAgent"&&e.prompt_response&&(s=s??"GeminiProvider",i=i??{prompt:e.prompt},a=a??{response:e.prompt_response}),o==="BeforeTool"&&s&&!a&&(a={_preExecution:!0}),o==="Notification"&&(s=s??"GeminiNotification",i=i??{notification_type:e.notification_type,message:e.message},a=a??{details:e.details}),{sessionId:n,cwd:r,prompt:e.prompt,toolName:s,toolInput:i,toolResponse:a,transcriptPath:e.transcript_path}},formatOutput(t){let e={};if(e.continue=t.continue??!0,t.suppressOutput!==void 0&&(e.suppressOutput=t.suppressOutput),t.systemMessage){let r=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;e.systemMessage=t.systemMessage.replace(r,"")}return t.hookSpecificOutput&&(e.hookSpecificOutput={additionalContext:t.hookSpecificOutput.additionalContext}),e}};var qi={normalizeInput(t){let e=t??{},r=e.cwd??process.cwd();if(!Ve(r))throw new he("invalid_cwd");return{sessionId:e.sessionId??e.session_id??"unknown",cwd:r,prompt:e.prompt,toolName:e.toolName??e.tool_name,toolInput:e.toolInput??e.tool_input,toolResponse:e.toolResponse??e.tool_response,transcriptPath:e.transcriptPath??e.transcript_path,filePath:e.filePath??e.file_path,edits:e.edits}},formatOutput(t){return t}};var ep={normalizeInput(t){let e=t??{},r=e.tool_info??{},n=e.agent_action_name??"",o=r.cwd??process.cwd();if(!Ve(o))throw new he("invalid_cwd");let s={sessionId:e.trajectory_id??e.execution_id,cwd:o,platform:"windsurf"};switch(n){case"pre_user_prompt":return{...s,prompt:r.user_prompt};case"post_write_code":return{...s,toolName:"Write",filePath:r.file_path,edits:r.edits,toolInput:{file_path:r.file_path,edits:r.edits}};case"post_run_command":return{...s,cwd:r.cwd??s.cwd,toolName:"Bash",toolInput:{command:r.command_line}};case"post_mcp_tool_use":return{...s,toolName:r.mcp_tool_name??"mcp_tool",toolInput:r.mcp_tool_arguments,toolResponse:r.mcp_result};case"post_cascade_response":return{...s,toolName:"cascade_response",toolResponse:r.response};default:return s}},formatOutput(t){return{continue:t.continue??!0}}};function tp(t){switch(t){case"claude-code":return zd;case"codex":return Jd;case"cursor":return Xd;case"gemini":case"gemini-cli":return Qd;case"windsurf":return ep;case"raw":return qi;default:return qi}}var np=require("os"),op=we(require("path"),1),sp=require("child_process");var Mo=require("fs"),Ao=we(require("path"),1);var hn={isWorktree:!1,worktreeName:null,parentRepoPath:null,parentProjectName:null};function rp(t){let e=Ao.default.join(t,".git"),r;try{r=(0,Mo.statSync)(e)}catch(l){return l instanceof Error&&l.code!=="ENOENT"&&f.warn("GIT","Unexpected error checking .git",{error:l instanceof Error?l.message:String(l)}),hn}if(!r.isFile())return hn;let n;try{n=(0,Mo.readFileSync)(e,"utf-8").trim()}catch(l){return f.warn("GIT","Failed to read .git file",{error:l instanceof Error?l.message:String(l)}),hn}let o=n.match(/^gitdir:\s*(.+)$/);if(!o)return hn;let i=o[1].match(/^(.+)[/\\]\.git[/\\]worktrees[/\\]([^/\\]+)$/);if(!i)return hn;let a=i[1],c=Ao.default.basename(t),u=Ao.default.basename(a);return{isWorktree:!0,worktreeName:c,parentRepoPath:a,parentProjectName:u}}function ip(t){return t==="~"||t.startsWith("~/")?t.replace(/^~/,(0,np.homedir)()):t}function yw(t){try{return(0,sp.execFileSync)("git",["rev-parse","--show-toplevel"],{cwd:t,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()||null}catch{return null}}function Hi(t){if(!t||t.trim()==="")return f.warn("PROJECT_NAME","Empty cwd provided, using fallback",{cwd:t}),"unknown-project";let e=ip(t),n=yw(e)??e,o=op.default.basename(n);if(o===""){if(process.platform==="win32"){let i=t.match(/^([A-Z]):\\/i);if(i){let c=`drive-${i[1].toUpperCase()}`;return f.info("PROJECT_NAME","Drive root detected",{cwd:t,projectName:c}),c}}return f.warn("PROJECT_NAME","Root directory detected, using fallback",{cwd:t}),"unknown-project"}return o}function kr(t){let e=Hi(t);if(!t)return{primary:e,parent:null,isWorktree:!1,allProjects:[e]};let r=ip(t),n=rp(r);if(n.isWorktree&&n.parentProjectName){let o=`${n.parentProjectName}/${e}`;return{primary:o,parent:n.parentProjectName,isWorktree:!0,allProjects:[n.parentProjectName,o]}}return{primary:e,parent:null,isWorktree:!1,allProjects:[e]}}var ap=require("child_process"),cp=require("util"),tr=require("fs");var up=require("path");var pA=(0,cp.promisify)(ap.execFile);function lp(){try{let t=(0,up.join)(fe.dataDir(),"oauth-stale.marker");return(0,tr.existsSync)(t)?(0,tr.readFileSync)(t,"utf-8"):void 0}catch{return}}var dp="claude";function Sw(t){return t.trim().toLowerCase().replace(/\s+/g,"-")}function Ce(t){if(!t)return dp;let e=Sw(t);return e?e==="transcript"||e.includes("codex")?"codex":e.includes("cursor")?"cursor":e.includes("claude")?"claude":e:dp}var pp;function S(t,e,r){function n(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,c);let u=i.prototype,l=Object.keys(u);for(let d=0;d<l.length;d++){let p=l[d];p in a||(a[p]=u[p].bind(a))}}let o=r?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:t});function i(a){var c;let u=r?.Parent?new s:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(i,"name",{value:t}),i}var mt=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},xr=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(pp=globalThis).__zod_globalConfig??(pp.__zod_globalConfig={});var $r=globalThis.__zod_globalConfig;function Ze(t){return t&&Object.assign($r,t),$r}var F={};Rl(F,{BIGINT_FORMAT_RANGES:()=>gp,Class:()=>Ki,NUMBER_FORMAT_RANGES:()=>Xi,aborted:()=>Nt,allowsEval:()=>Gi,assert:()=>kw,assertEqual:()=>vw,assertIs:()=>ww,assertNever:()=>bw,assertNotEqual:()=>Ew,assignProp:()=>At,base64ToUint8Array:()=>yp,base64urlToUint8Array:()=>Fw,cached:()=>Tr,captureStackTrace:()=>Lo,cleanEnum:()=>Uw,cleanRegex:()=>Sn,clone:()=>nt,cloneDef:()=>$w,createTransparentProxy:()=>Iw,defineLazy:()=>K,esc:()=>Do,escapeRegex:()=>bt,explicitlyAborted:()=>Qi,extend:()=>Mw,finalizeIssue:()=>Je,floatSafeRemainder:()=>Vi,getElementAtPath:()=>Pw,getEnumValues:()=>_n,getLengthableOrigin:()=>vn,getParsedType:()=>Rw,getSizableOrigin:()=>_p,hexToUint8Array:()=>qw,isObject:()=>rr,isPlainObject:()=>Mt,issue:()=>Or,joinValues:()=>No,jsonStringifyReplacer:()=>Pr,merge:()=>Dw,mergeDefs:()=>wt,normalizeParams:()=>z,nullish:()=>yn,numKeys:()=>zw,objectClone:()=>xw,omit:()=>Aw,optionalKeys:()=>Yi,parsedType:()=>ea,partial:()=>Lw,pick:()=>Cw,prefixIssues:()=>kt,primitiveTypes:()=>hp,promiseAllObject:()=>Tw,propertyKeyTypes:()=>Bi,randomString:()=>Ow,required:()=>jw,safeExtend:()=>Nw,shallowClone:()=>mp,slugify:()=>Ji,stringifyPrimitive:()=>jo,uint8ArrayToBase64:()=>Sp,uint8ArrayToBase64url:()=>Zw,uint8ArrayToHex:()=>Hw,unwrapMessage:()=>gn});function vw(t){return t}function Ew(t){return t}function ww(t){}function bw(t){throw new Error("Unexpected value in exhaustive check")}function kw(t){}function _n(t){let e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,o])=>e.indexOf(+n)===-1).map(([n,o])=>o)}function No(t,e="|"){return t.map(r=>jo(r)).join(e)}function Pr(t,e){return typeof e=="bigint"?e.toString():e}function Tr(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function yn(t){return t==null}function Sn(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function Vi(t,e){let r=t/e,n=Math.round(r),o=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}var fp=Symbol("evaluating");function K(t,e,r){let n;Object.defineProperty(t,e,{get(){if(n!==fp)return n===void 0&&(n=fp,n=r()),n},set(o){Object.defineProperty(t,e,{value:o})},configurable:!0})}function xw(t){return Object.create(Object.getPrototypeOf(t),Object.getOwnPropertyDescriptors(t))}function At(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function wt(...t){let e={};for(let r of t){let n=Object.getOwnPropertyDescriptors(r);Object.assign(e,n)}return Object.defineProperties({},e)}function $w(t){return wt(t._zod.def)}function Pw(t,e){return e?e.reduce((r,n)=>r?.[n],t):t}function Tw(t){let e=Object.keys(t),r=e.map(n=>t[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<e.length;s++)o[e[s]]=n[s];return o})}function Ow(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<t;n++)r+=e[Math.floor(Math.random()*e.length)];return r}function Do(t){return JSON.stringify(t)}function Ji(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Lo="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function rr(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var Gi=Tr(()=>{if($r.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function Mt(t){if(rr(t)===!1)return!1;let e=t.constructor;if(e===void 0||typeof e!="function")return!0;let r=e.prototype;return!(rr(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function mp(t){return Mt(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}function zw(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}var Rw=t=>{let e=typeof t;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},Bi=new Set(["string","number","symbol"]),hp=new Set(["string","number","bigint","boolean","symbol","undefined"]);function bt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function nt(t,e,r){let n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function z(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function Iw(t){let e;return new Proxy({},{get(r,n,o){return e??(e=t()),Reflect.get(e,n,o)},set(r,n,o,s){return e??(e=t()),Reflect.set(e,n,o,s)},has(r,n){return e??(e=t()),Reflect.has(e,n)},deleteProperty(r,n){return e??(e=t()),Reflect.deleteProperty(e,n)},ownKeys(r){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(r,n){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,n)},defineProperty(r,n,o){return e??(e=t()),Reflect.defineProperty(e,n,o)}})}function jo(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function Yi(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}var Xi={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]},gp={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Cw(t,e){let r=t._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s=wt(t._zod.def,{get shape(){let i={};for(let a in e){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(i[a]=r.shape[a])}return At(this,"shape",i),i},checks:[]});return nt(t,s)}function Aw(t,e){let r=t._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=wt(t._zod.def,{get shape(){let i={...t._zod.def.shape};for(let a in e){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete i[a]}return At(this,"shape",i),i},checks:[]});return nt(t,s)}function Mw(t,e){if(!Mt(e))throw new Error("Invalid input to extend: expected a plain object");let r=t._zod.def.checks;if(r&&r.length>0){let s=t._zod.def.shape;for(let i in e)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=wt(t._zod.def,{get shape(){let s={...t._zod.def.shape,...e};return At(this,"shape",s),s}});return nt(t,o)}function Nw(t,e){if(!Mt(e))throw new Error("Invalid input to safeExtend: expected a plain object");let r=wt(t._zod.def,{get shape(){let n={...t._zod.def.shape,...e};return At(this,"shape",n),n}});return nt(t,r)}function Dw(t,e){if(t._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=wt(t._zod.def,{get shape(){let n={...t._zod.def.shape,...e._zod.def.shape};return At(this,"shape",n),n},get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return nt(t,r)}function Lw(t,e,r){let o=e._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let i=wt(e._zod.def,{get shape(){let a=e._zod.def.shape,c={...a};if(r)for(let u in r){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(c[u]=t?new t({type:"optional",innerType:a[u]}):a[u])}else for(let u in a)c[u]=t?new t({type:"optional",innerType:a[u]}):a[u];return At(this,"shape",c),c},checks:[]});return nt(e,i)}function jw(t,e,r){let n=wt(e._zod.def,{get shape(){let o=e._zod.def.shape,s={...o};if(r)for(let i in r){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);r[i]&&(s[i]=new t({type:"nonoptional",innerType:o[i]}))}else for(let i in o)s[i]=new t({type:"nonoptional",innerType:o[i]});return At(this,"shape",s),s}});return nt(e,n)}function Nt(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function Qi(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue===!1)return!0;return!1}function kt(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function gn(t){return typeof t=="string"?t:t?.message}function Je(t,e,r){let n=t.message?t.message:gn(t.inst?._zod.def?.error?.(t))??gn(e?.error?.(t))??gn(r.customError?.(t))??gn(r.localeError?.(t))??"Invalid input",{inst:o,continue:s,input:i,...a}=t;return a.path??(a.path=[]),a.message=n,e?.reportInput&&(a.input=i),a}function _p(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function vn(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function ea(t){let e=typeof t;switch(e){case"number":return Number.isNaN(t)?"nan":"number";case"object":{if(t===null)return"null";if(Array.isArray(t))return"array";let r=t;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return e}function Or(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}function Uw(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function yp(t){let e=atob(t),r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}function Sp(t){let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return btoa(e)}function Fw(t){let e=t.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-e.length%4)%4);return yp(e+r)}function Zw(t){return Sp(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function qw(t){let e=t.replace(/^0x/,"");if(e.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)r[n/2]=Number.parseInt(e.slice(n,n+2),16);return r}function Hw(t){return Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}var Ki=class{constructor(...e){}};var vp=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,Pr,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Uo=S("$ZodError",vp),ta=S("$ZodError",vp,{Parent:Error});function Ep(t,e=r=>r.message){let r={},n=[];for(let o of t.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(e(o))):n.push(e(o));return{formErrors:n,fieldErrors:r}}function wp(t,e=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(e(i));else{let c=r,u=0;for(;u<a.length;){let l=a[u];u===a.length-1?(c[l]=c[l]||{_errors:[]},c[l]._errors.push(e(i))):c[l]=c[l]||{_errors:[]},c=c[l],u++}}}};return n(t),r}var Fo=t=>(e,r,n,o)=>{let s=n?{...n,async:!1}:{async:!1},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new mt;if(i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>Je(c,s,Ze())));throw Lo(a,o?.callee),a}return i.value};var Zo=t=>async(e,r,n,o)=>{let s=n?{...n,async:!0}:{async:!0},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>Je(c,s,Ze())));throw Lo(a,o?.callee),a}return i.value};var En=t=>(e,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=e._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new mt;return s.issues.length?{success:!1,error:new(t??Uo)(s.issues.map(i=>Je(i,o,Ze())))}:{success:!0,data:s.value}},wn=En(ta),bn=t=>async(e,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=e._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new t(s.issues.map(i=>Je(i,o,Ze())))}:{success:!0,data:s.value}},qo=bn(ta),bp=t=>(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Fo(t)(e,r,o)};var kp=t=>(e,r,n)=>Fo(t)(e,r,n);var xp=t=>async(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Zo(t)(e,r,o)};var $p=t=>async(e,r,n)=>Zo(t)(e,r,n);var Pp=t=>(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return En(t)(e,r,o)};var Tp=t=>(e,r,n)=>En(t)(e,r,n);var Op=t=>async(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return bn(t)(e,r,o)};var zp=t=>async(e,r,n)=>bn(t)(e,r,n);var Rp=/^[cC][0-9a-z]{6,}$/,Ip=/^[0-9a-z]+$/,Cp=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Ap=/^[0-9a-vA-V]{20}$/,Mp=/^[A-Za-z0-9]{27}$/,Np=/^[a-zA-Z0-9_-]{21}$/,Dp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Lp=/^([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})$/,ra=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[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 jp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Kw="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Up(){return new RegExp(Kw,"u")}var Fp=/^(?:(?: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])$/,Zp=/^(([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 qp=/^((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])$/,Hp=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Wp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,na=/^[A-Za-z0-9_-]*$/;var Kp=/^https?$/,Vp=/^\+[1-9]\d{6,14}$/,Jp="(?:(?:\\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])))",Gp=new RegExp(`^${Jp}$`);function Bp(t){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Yp(t){return new RegExp(`^${Bp(t)}$`)}function Xp(t){let e=Bp({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${e}(?:${r.join("|")})`;return new RegExp(`^${Jp}T(?:${n})$`)}var Qp=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)};var ef=/^-?\d+$/,oa=/^-?\d+(?:\.\d+)?$/,tf=/^(?:true|false)$/i,rf=/^null$/i;var nf=/^[^A-Z]*$/,of=/^[^a-z]*$/;var ge=S("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),sf={number:"number",bigint:"bigint",object:"date"},sa=S("$ZodCheckLessThan",(t,e)=>{ge.init(t,e);let r=sf[typeof e.value];t._zod.onattach.push(n=>{let o=n._zod.bag,s=(e.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?o.maximum=e.value:o.exclusiveMaximum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),ia=S("$ZodCheckGreaterThan",(t,e)=>{ge.init(t,e);let r=sf[typeof e.value];t._zod.onattach.push(n=>{let o=n._zod.bag,s=(e.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?o.minimum=e.value:o.exclusiveMinimum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),af=S("$ZodCheckMultipleOf",(t,e)=>{ge.init(t,e),t._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=e.value)}),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):Vi(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),cf=S("$ZodCheckNumberFormat",(t,e)=>{ge.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[o,s]=Xi[e.format];t._zod.onattach.push(i=>{let a=i._zod.bag;a.format=e.format,a.minimum=o,a.maximum=s,r&&(a.pattern=ef)}),t._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:e.format,code:"invalid_type",continue:!1,input:a,inst:t});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:t,origin:n,inclusive:!0,continue:!e.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,inclusive:!0,continue:!e.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:t,continue:!e.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:t,continue:!e.abort})}});var uf=S("$ZodCheckMaxLength",(t,e)=>{var r;ge.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!yn(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<o&&(n._zod.bag.maximum=e.maximum)}),t._zod.check=n=>{let o=n.value;if(o.length<=e.maximum)return;let i=vn(o);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),lf=S("$ZodCheckMinLength",(t,e)=>{var r;ge.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!yn(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>o&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{let o=n.value;if(o.length>=e.minimum)return;let i=vn(o);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),df=S("$ZodCheckLengthEquals",(t,e)=>{var r;ge.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!yn(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=e.length,o.maximum=e.length,o.length=e.length}),t._zod.check=n=>{let o=n.value,s=o.length;if(s===e.length)return;let i=vn(o),a=s>e.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),kn=S("$ZodCheckStringFormat",(t,e)=>{var r,n;ge.init(t,e),t._zod.onattach.push(o=>{let s=o._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=o=>{e.pattern.lastIndex=0,!e.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:e.format,input:o.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),pf=S("$ZodCheckRegex",(t,e)=>{kn.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),ff=S("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=nf),kn.init(t,e)}),mf=S("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=of),kn.init(t,e)}),hf=S("$ZodCheckIncludes",(t,e)=>{ge.init(t,e);let r=bt(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(o=>{let s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),t._zod.check=o=>{o.value.includes(e.includes,e.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:o.value,inst:t,continue:!e.abort})}}),gf=S("$ZodCheckStartsWith",(t,e)=>{ge.init(t,e);let r=new RegExp(`^${bt(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),t._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:t,continue:!e.abort})}}),_f=S("$ZodCheckEndsWith",(t,e)=>{ge.init(t,e);let r=new RegExp(`.*${bt(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),t._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:t,continue:!e.abort})}});var yf=S("$ZodCheckOverwrite",(t,e)=>{ge.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});var Wo=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
|
|
23
|
+
`,"utf-8"),a;try{a=(0,W.statSync)(r).mode&511}catch{}let c;try{c=a!==void 0?(0,W.openSync)(s,"w",a):(0,W.openSync)(s,"w");let u=0;for(;u<i.length;){let l=(0,W.writeSync)(c,i,u,i.length-u);if(l===0)throw new Error(`writeSync stalled at ${u}/${i.length} bytes`);u+=l}if((0,W.fsyncSync)(c),(0,W.closeSync)(c),c=void 0,(0,W.renameSync)(s,r),!Yv){let l;try{l=(0,W.openSync)(n,"r"),(0,W.fsyncSync)(l)}catch{}finally{if(l!==void 0)try{(0,W.closeSync)(l)}catch{}}}}catch(u){if(c!==void 0)try{(0,W.closeSync)(c)}catch{}try{(0,W.unlinkSync)(s)}catch{}throw u}}var Bt=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5-20251001",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:String(37700+(process.getuid?.()??77)%100),CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_API_TIMEOUT_MS:String(vt(ue.API_REQUEST)),CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_PROVIDER:"claude",CLAUDE_MEM_CLAUDE_AUTH_METHOD:"subscription",CLAUDE_MEM_GEMINI_API_KEY:"",CLAUDE_MEM_GEMINI_MODEL:"gemini-2.5-flash-lite",CLAUDE_MEM_GEMINI_RATE_LIMITING_ENABLED:"true",CLAUDE_MEM_GEMINI_MAX_CONTEXT_MESSAGES:"20",CLAUDE_MEM_GEMINI_MAX_TOKENS:"100000",CLAUDE_MEM_OPENROUTER_API_KEY:"",CLAUDE_MEM_OPENROUTER_MODEL:"xiaomi/mimo-v2-flash:free",CLAUDE_MEM_OPENROUTER_BASE_URL:"",CLAUDE_MEM_OPENROUTER_SITE_URL:"",CLAUDE_MEM_OPENROUTER_APP_NAME:"claude-mem",CLAUDE_MEM_OPENROUTER_MAX_CONTEXT_MESSAGES:"20",CLAUDE_MEM_OPENROUTER_MAX_TOKENS:"100000",CLAUDE_MEM_DATA_DIR:(0,dn.join)((0,Ei.homedir)(),".keepmind"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_MODE:"code",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"false",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"false",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"false",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_FULL_COUNT:"0",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"5",CLAUDE_MEM_OBSERVATION_BATCH_MAX:"1",CLAUDE_MEM_MAX_CONTEXT_MESSAGES:"40",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false",CLAUDE_MEM_CONTEXT_SHOW_TERMINAL_OUTPUT:"true",CLAUDE_MEM_WELCOME_HINT_ENABLED:"true",CLAUDE_MEM_FOLDER_CLAUDEMD_ENABLED:"false",CLAUDE_MEM_FOLDER_USE_LOCAL_MD:"false",CLAUDE_MEM_TRANSCRIPTS_ENABLED:"true",CLAUDE_MEM_TRANSCRIPTS_CONFIG_PATH:(0,dn.join)((0,Ei.homedir)(),".keepmind","transcript-watch.json"),CLAUDE_MEM_CODEX_TRANSCRIPT_INGESTION:"false",CLAUDE_MEM_MAX_CONCURRENT_AGENTS:"2",CLAUDE_MEM_HOOK_FAIL_LOUD_THRESHOLD:"3",CLAUDE_MEM_EXCLUDED_PROJECTS:"",CLAUDE_MEM_FOLDER_MD_EXCLUDE:"[]",CLAUDE_MEM_FOLDER_MD_SKELETON_DENYLIST:"[]",CLAUDE_MEM_SEMANTIC_INJECT:"false",CLAUDE_MEM_SEMANTIC_INJECT_LIMIT:"5",CLAUDE_MEM_TIER_ROUTING_ENABLED:"true",CLAUDE_MEM_TIER_SIMPLE_MODEL:"haiku",CLAUDE_MEM_TIER_SUMMARY_MODEL:"",CLAUDE_MEM_TIER_FAST_MODEL:"haiku",CLAUDE_MEM_TIER_SMART_MODEL:"sonnet",CLAUDE_MEM_CHROMA_ENABLED:"true",CLAUDE_MEM_TELEGRAM_ENABLED:"true",CLAUDE_MEM_TELEGRAM_BOT_TOKEN:"",CLAUDE_MEM_TELEGRAM_CHAT_ID:"",CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES:"security_alert",CLAUDE_MEM_TELEGRAM_TRIGGER_CONCEPTS:"",CLAUDE_MEM_QUEUE_ENGINE:"sqlite",CLAUDE_MEM_REDIS_URL:"",CLAUDE_MEM_REDIS_HOST:"127.0.0.1",CLAUDE_MEM_REDIS_PORT:"6379",CLAUDE_MEM_REDIS_MODE:"external",CLAUDE_MEM_QUEUE_REDIS_PREFIX:`claude_mem_${process.env.CLAUDE_MEM_WORKER_PORT??String(37700+(process.getuid?.()??77)%100)}`,CLAUDE_MEM_AUTH_MODE:"api-key",CLAUDE_MEM_RUNTIME:"worker",CLAUDE_MEM_SERVER_URL:`http://127.0.0.1:${process.env.CLAUDE_MEM_SERVER_PORT??String(37877+(process.getuid?.()??77)%100)}`,CLAUDE_MEM_SERVER_API_KEY:"",CLAUDE_MEM_SERVER_PROJECT_ID:"",CLAUDE_MEM_SERVER_BETA_URL:`http://127.0.0.1:${process.env.CLAUDE_MEM_SERVER_PORT??String(37877+(process.getuid?.()??77)%100)}`,CLAUDE_MEM_SERVER_BETA_API_KEY:"",CLAUDE_MEM_SERVER_BETA_PROJECT_ID:""};static getAllDefaults(){return{...this.DEFAULTS}}static envOverride(e){let r=e.replace(/^CLAUDE_MEM_/,"KEEPMIND_");return process.env[r]??process.env[e]}static get(e){return this.envOverride(e)??this.DEFAULTS[e]}static getInt(e){let r=this.get(e);return parseInt(r,10)}static getBool(e){let r=this.get(e);return r==="true"||r===!0}static applyEnvOverrides(e){let r={...e};for(let n of Object.keys(this.DEFAULTS)){let o=this.envOverride(n);o!==void 0&&(r[n]=o)}return r}static loadFromFile(e,r=!0){try{if(!(0,dt.existsSync)(e)){let a=this.getAllDefaults();try{let c=(0,dn.dirname)(e);(0,dt.existsSync)(c)||(0,dt.mkdirSync)(c,{recursive:!0}),So(e,a),console.warn("[SETTINGS] Created settings file with defaults:",e)}catch(c){console.warn("[SETTINGS] Failed to create settings file, using in-memory defaults:",e,c instanceof Error?c.message:String(c))}return r?this.applyEnvOverrides(a):a}let n=(0,dt.readFileSync)(e,"utf-8"),o=JSON.parse(n.replace(/^\uFEFF/,"")),s=o;if(o.env&&typeof o.env=="object"){s=o.env;try{So(e,s),console.warn("[SETTINGS] Migrated settings file from nested to flat schema:",e)}catch(a){console.warn("[SETTINGS] Failed to auto-migrate settings file:",e,a instanceof Error?a.message:String(a))}}let i={...this.DEFAULTS};for(let a of Object.keys(this.DEFAULTS))s[a]!==void 0&&(i[a]=s[a]);return r?this.applyEnvOverrides(i):i}catch(n){console.warn("[SETTINGS] Failed to load settings, using defaults:",e,n instanceof Error?n.message:String(n));let o=this.getAllDefaults();try{if((0,dt.existsSync)(e)){let s=`${e}.corrupt-${Date.now()}`;(0,dt.renameSync)(e,s),console.warn("[SETTINGS] Backed up corrupt settings file to:",s)}So(e,o),console.warn("[SETTINGS] Recovered settings file with defaults:",e)}catch(s){console.warn("[SETTINGS] Failed to recover corrupt settings file:",e,s instanceof Error?s.message:String(s))}return r?this.applyEnvOverrides(o):o}}};var vo=null;function rt(){return vo!==null||(vo=Bt.loadFromFile(Al)),vo}var Xt=require("fs");var $i=require("child_process");var pt=require("fs"),ki=we(require("path"),1);var Qv=["CLAUDECODE_","CLAUDE_CODE_"],eE=new Set(["CLAUDECODE","CLAUDE_CODE_SESSION","CLAUDE_CODE_ENTRYPOINT","MCP_SESSION_ID","HTTP_PROXY","HTTPS_PROXY","ALL_PROXY","NO_PROXY","http_proxy","https_proxy","all_proxy","no_proxy","npm_config_proxy","npm_config_https_proxy"]),tE=new Set(["CLAUDE_CODE_OAUTH_TOKEN","CLAUDE_CODE_GIT_BASH_PATH","CLAUDE_CODE_USE_BEDROCK","CLAUDE_CODE_USE_VERTEX","ANTHROPIC_BEDROCK_BASE_URL","AWS_REGION","AWS_PROFILE","AWS_ACCESS_KEY_ID","AWS_SECRET_ACCESS_KEY","AWS_SESSION_TOKEN","ANTHROPIC_VERTEX_PROJECT_ID","CLOUD_ML_REGION","GOOGLE_APPLICATION_CREDENTIALS"]);function Yt(t=process.env){let e={};for(let[r,n]of Object.entries(t))if(n!==void 0){if(tE.has(r)){e[r]=n;continue}eE.has(r)||Qv.some(o=>r.startsWith(o))||(e[r]=n)}return e}var rE=5e3,nE=1e3,oE=fe.supervisorRegistry();function Et(t){if(!Number.isInteger(t)||t<0||t===0)return!1;try{return process.kill(t,0),!0}catch(e){if(e instanceof Error){let r=e.code;return r==="EPERM"?!0:(f.debug("SYSTEM","PID check failed",{pid:t,code:r}),!1)}return f.warn("SYSTEM","PID check threw non-Error",{pid:t,error:String(e)}),!1}}async function Eo(t,e){let r=Date.now()+e;for(;Date.now()<r;){if(t.every(n=>!Et(n.pid)))return;await new Promise(n=>setTimeout(n,100))}}var sE=5e3,Ul=new Map;function iE(t){let e=Ul.get(t);if(e&&Date.now()-e.capturedAtMs<sE)return e.token;let r=null;try{let n=(0,$i.spawnSync)("powershell.exe",["-NoProfile","-NonInteractive","-Command",`(Get-CimInstance Win32_Process -Filter "ProcessId=${t}").CreationDate.ToString('yyyyMMddHHmmss.ffffff')`],{encoding:"utf-8",timeout:5e3,windowsHide:!0,env:{...Yt(process.env),LC_ALL:"C",LANG:"C"}});if(n.status===0){let o=n.stdout.trim();r=o.length>0?o:null}}catch(n){f.debug("SYSTEM","captureProcessStartToken: powershell CIM lookup failed",{pid:t,error:n instanceof Error?n.message:String(n)}),r=null}return Ul.set(t,{token:r,capturedAtMs:Date.now()}),r}function Fl(t){if(!Number.isInteger(t)||t<=0)return null;if(process.platform==="linux")try{let e=(0,pt.readFileSync)(`/proc/${t}/stat`,"utf-8"),r=e.lastIndexOf(") ");if(r<0)return null;let o=e.slice(r+2).split(" ")[19];return o&&/^\d+$/.test(o)?o:null}catch(e){return f.debug("SYSTEM","captureProcessStartToken: /proc read failed",{pid:t,error:e instanceof Error?e.message:String(e)}),null}if(process.platform==="win32")return iE(t);try{let e=(0,$i.spawnSync)("ps",["-p",String(t),"-o","lstart="],{encoding:"utf-8",timeout:2e3,env:{...Yt(process.env),LC_ALL:"C",LANG:"C"}});if(e.status!==0)return null;let r=e.stdout.trim();return r.length>0?r:null}catch(e){return f.debug("SYSTEM","captureProcessStartToken: ps exec failed",{pid:t,error:e instanceof Error?e.message:String(e)}),null}}function Pi(t){if(!t||!Et(t.pid))return!1;if(!t.startToken)return!0;let e=Fl(t.pid);if(e===null)return!0;let r=e===t.startToken;return r||f.debug("SYSTEM","verifyPidFileOwnership: start-token mismatch (PID reused)",{pid:t.pid,stored:t.startToken,current:e}),r}var xi=class{registryPath;entries=new Map;runtimeProcesses=new Map;initialized=!1;constructor(e=oE){this.registryPath=e}initialize(){if(this.initialized)return;if(this.initialized=!0,(0,pt.mkdirSync)(ki.default.dirname(this.registryPath),{recursive:!0}),!(0,pt.existsSync)(this.registryPath)){this.persist();return}try{let n=JSON.parse((0,pt.readFileSync)(this.registryPath,"utf-8")).processes??{};for(let[o,s]of Object.entries(n))this.entries.set(o,s)}catch(r){r instanceof Error?f.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath},r):f.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath,error:String(r)}),this.entries.clear()}let e=this.pruneDeadEntries();e>0&&f.info("SYSTEM","Removed dead processes from supervisor registry",{removed:e}),this.persist()}register(e,r,n){this.initialize(),this.entries.set(e,r),n&&this.runtimeProcesses.set(e,n),this.persist()}unregister(e){this.initialize();let r=this.entries.get(e);this.entries.delete(e),this.runtimeProcesses.delete(e),this.persist(),r?.type==="sdk"&&bi()}clear(){this.entries.clear(),this.runtimeProcesses.clear(),this.persist()}getAll(){return this.initialize(),Array.from(this.entries.entries()).map(([e,r])=>({id:e,...r})).sort((e,r)=>{let n=Date.parse(e.startedAt),o=Date.parse(r.startedAt);return(Number.isNaN(n)?0:n)-(Number.isNaN(o)?0:o)})}getBySession(e){let r=String(e);return this.getAll().filter(n=>n.sessionId!==void 0&&String(n.sessionId)===r)}getRuntimeProcess(e){return this.runtimeProcesses.get(e)}getByPid(e){return this.getAll().filter(r=>r.pid===e)}pruneDeadEntries(){this.initialize();let e=0,r=0;for(let[n,o]of this.entries)Et(o.pid)||(this.entries.delete(n),this.runtimeProcesses.delete(n),e+=1,o.type==="sdk"&&(r+=1));e>0&&this.persist();for(let n=0;n<r;n+=1)bi();return e}async reapSession(e){this.initialize();let r=this.getBySession(e);if(r.length===0)return 0;let n=typeof e=="number"?e:Number(e)||void 0;f.info("SYSTEM",`Reaping ${r.length} process(es) for session ${e}`,{sessionId:n,pids:r.map(i=>i.pid)});let o=r.filter(i=>Et(i.pid));for(let i of o)try{typeof i.pgid=="number"&&process.platform!=="win32"?process.kill(-i.pgid,"SIGTERM"):process.kill(i.pid,"SIGTERM")}catch(a){a instanceof Error?a.code!=="ESRCH"&&f.debug("SYSTEM",`Failed to SIGTERM session process PID ${i.pid}`,{pid:i.pid,pgid:i.pgid},a):f.warn("SYSTEM",`Failed to SIGTERM session process PID ${i.pid} (non-Error)`,{pid:i.pid,pgid:i.pgid,error:String(a)})}await Eo(o,rE);let s=o.filter(i=>Et(i.pid));for(let i of s){f.warn("SYSTEM",`Session process PID ${i.pid} did not exit after SIGTERM, sending SIGKILL`,{pid:i.pid,pgid:i.pgid,sessionId:n});try{typeof i.pgid=="number"&&process.platform!=="win32"?process.kill(-i.pgid,"SIGKILL"):process.kill(i.pid,"SIGKILL")}catch(a){a instanceof Error?a.code!=="ESRCH"&&f.debug("SYSTEM",`Failed to SIGKILL session process PID ${i.pid}`,{pid:i.pid,pgid:i.pgid},a):f.warn("SYSTEM",`Failed to SIGKILL session process PID ${i.pid} (non-Error)`,{pid:i.pid,pgid:i.pgid,error:String(a)})}}if(s.length>0){let i=Date.now()+nE;for(;Date.now()<i&&s.filter(c=>Et(c.pid)).length!==0;)await new Promise(c=>setTimeout(c,100))}for(let i of r)this.entries.delete(i.id),this.runtimeProcesses.delete(i.id);this.persist();for(let i of r)i.type==="sdk"&&bi();return f.info("SYSTEM",`Reaped ${r.length} process(es) for session ${e}`,{sessionId:n,reaped:r.length}),r.length}persist(){let e={processes:Object.fromEntries(this.entries.entries())};(0,pt.mkdirSync)(ki.default.dirname(this.registryPath),{recursive:!0}),(0,pt.writeFileSync)(this.registryPath,JSON.stringify(e,null,2))}},wi=null;function wo(){return wi||(wi=new xi),wi}var aE=[];function bi(){let t=aE.shift();t&&t()}var ql=require("child_process"),Er=require("fs"),Hl=require("util");var cE=(0,Hl.promisify)(ql.execFile),uE=fe.workerPid();async function Wl(t){let e=t.currentPid??process.pid,r=t.pidFilePath??uE,n=t.registry.getAll(),o=[...n].filter(i=>i.pid!==e).sort((i,a)=>Date.parse(a.startedAt)-Date.parse(i.startedAt));for(let i of o){if(!Et(i.pid)){t.registry.unregister(i.id);continue}try{await Zl(i,"SIGTERM")}catch(a){a instanceof Error?f.debug("SYSTEM","Failed to send SIGTERM to child process",{pid:i.pid,pgid:i.pgid,type:i.type},a):f.warn("SYSTEM","Failed to send SIGTERM to child process (non-Error)",{pid:i.pid,pgid:i.pgid,type:i.type,error:String(a)})}}await Eo(o,5e3);let s=o.filter(i=>Et(i.pid));for(let i of s)try{await Zl(i,"SIGKILL")}catch(a){a instanceof Error?f.debug("SYSTEM","Failed to force kill child process",{pid:i.pid,pgid:i.pgid,type:i.type},a):f.warn("SYSTEM","Failed to force kill child process (non-Error)",{pid:i.pid,pgid:i.pgid,type:i.type,error:String(a)})}await Eo(s,1e3);for(let i of o)t.registry.unregister(i.id);for(let i of n.filter(a=>a.pid===e))t.registry.unregister(i.id);lE(r,e),t.registry.pruneDeadEntries()}function lE(t,e){if(!(0,Er.existsSync)(t))return;let r=null;try{let n=JSON.parse((0,Er.readFileSync)(t,"utf-8"));r=typeof n.pid=="number"?n.pid:null}catch(n){f.debug("SYSTEM","PID file unreadable during shutdown \u2014 leaving it (cannot prove ownership)",{pidFilePath:t,error:n instanceof Error?n.message:String(n)});return}if(r!==e){f.debug("SYSTEM","PID file not owned by this process \u2014 leaving it for its owner (restart successor?)",{pidFilePath:t,recordedPid:r,currentPid:e});return}try{(0,Er.rmSync)(t,{force:!0})}catch(n){n instanceof Error?f.debug("SYSTEM","Failed to remove PID file during shutdown",{pidFilePath:t},n):f.warn("SYSTEM","Failed to remove PID file during shutdown (non-Error)",{pidFilePath:t,error:String(n)})}}async function Zl(t,e){let{pid:r,pgid:n}=t;if(process.platform!=="win32"){if(typeof n=="number")try{process.kill(-n,e);return}catch(i){if((i instanceof Error?i.code:void 0)!=="ESRCH")throw i}try{process.kill(r,e)}catch(i){if((i instanceof Error?i.code:void 0)!=="ESRCH")throw i}return}if(e==="SIGTERM"){try{process.kill(r,e)}catch(i){if(i instanceof Error&&i.code==="ESRCH")return;throw i}return}let o=await dE();if(o){await new Promise((i,a)=>{o(r,e,c=>{if(!c){i();return}if(c.code==="ESRCH"){i();return}a(c)})});return}let s=["/PID",String(r),"/T"];e==="SIGKILL"&&s.push("/F"),await cE("taskkill",s,{timeout:ue.POWERSHELL_COMMAND,windowsHide:!0})}async function dE(){let t="tree-kill";try{let e=await import(t);return e.default??e}catch(e){return f.debug("SYSTEM","tree-kill module not available, using fallback",{},e instanceof Error?e:void 0),null}}var Vl=3e4,wr=null;function pE(){let e=wo().pruneDeadEntries();e>0&&f.info("SYSTEM",`Health check: pruned ${e} dead process(es) from registry`)}function Kl(){wr===null&&(wr=setInterval(pE,Vl),wr.unref(),f.debug("SYSTEM","Health checker started",{intervalMs:Vl}))}function Jl(){wr!==null&&(clearInterval(wr),wr=null,f.debug("SYSTEM","Health checker stopped"))}var fE=fe.workerPid(),Ti=class{registry;started=!1;stopPromise=null;signalHandlersRegistered=!1;shutdownInitiated=!1;shutdownHandler=null;constructor(e){this.registry=e}async start(){if(this.started)return;if(this.registry.initialize(),pn({logAlive:!1})==="alive")throw new Error("Worker already running");this.started=!0,Kl()}configureSignalHandlers(e){if(this.shutdownHandler=e,this.signalHandlersRegistered)return;this.signalHandlersRegistered=!0;let r=async n=>{if(this.shutdownInitiated){f.warn("SYSTEM",`Received ${n} but shutdown already in progress`);return}this.shutdownInitiated=!0,f.info("SYSTEM",`Received ${n}, shutting down...`);try{this.shutdownHandler?await this.shutdownHandler():await this.stop()}catch(o){o instanceof Error?f.error("SYSTEM","Error during shutdown",{},o):f.error("SYSTEM","Error during shutdown (non-Error)",{error:String(o)});try{await this.stop()}catch(s){s instanceof Error?f.debug("SYSTEM","Supervisor shutdown fallback failed",{},s):f.debug("SYSTEM","Supervisor shutdown fallback failed",{error:String(s)})}}process.exit(0)};process.on("SIGTERM",()=>{r("SIGTERM")}),process.on("SIGINT",()=>{r("SIGINT")}),process.platform!=="win32"&&(process.argv.includes("--daemon")?process.on("SIGHUP",()=>{f.debug("SYSTEM","Ignoring SIGHUP in daemon mode")}):process.on("SIGHUP",()=>{r("SIGHUP")}))}async stop(){if(this.stopPromise){await this.stopPromise;return}Jl(),this.stopPromise=Wl({registry:this.registry,currentPid:process.pid}).finally(()=>{this.started=!1,this.stopPromise=null}),await this.stopPromise}assertCanSpawn(e){if(this.stopPromise!==null)throw new Error(`Supervisor is shutting down, refusing to spawn ${e}`)}registerProcess(e,r,n){this.registry.register(e,r,n)}unregisterProcess(e){this.registry.unregister(e)}getRegistry(){return this.registry}},mE=new Ti(wo());function Oi(){return mE}function pn(t={}){let e=t.pidFilePath??fE;if(!(0,Xt.existsSync)(e))return"missing";let r=null;try{r=JSON.parse((0,Xt.readFileSync)(e,"utf-8"))}catch(o){return o instanceof Error?f.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:e},o):f.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:e,error:String(o)}),(0,Xt.rmSync)(e,{force:!0}),"invalid"}return Pi(r)&&r?((t.logAlive??!0)&&f.info("SYSTEM","Worker already running (PID alive)",{existingPid:r.pid,existingPort:r.port,startedAt:r.startedAt}),"alive"):(f.info("SYSTEM","Removing stale PID file (worker process is dead or PID has been reused)",{pid:r?.pid,port:r?.port,startedAt:r?.startedAt}),(0,Xt.rmSync)(e,{force:!0}),"stale")}var Yl=we(require("path"),1),Xl=require("os"),be=require("fs"),Ql=require("child_process");function Gl(t){return t instanceof Error?t:new Error(String(t))}var YI=fe.dataDir(),ft=fe.workerPid(),XI=fe.workerPort();function Bl(t){return t?/(^|[\\/])node(\.exe)?$/i.test(t.trim()):!1}function hE(t,e){let r=e==="win32"?`where ${t}`:`which ${t}`,n;try{n=(0,Ql.execSync)(r,{stdio:["ignore","pipe","ignore"],encoding:"utf-8",windowsHide:!0})}catch(s){return s instanceof Error?f.debug("SYSTEM",`Binary lookup failed for ${t}`,{command:r},s):f.debug("SYSTEM",`Binary lookup failed for ${t}`,{command:r},new Error(String(s))),null}return n.split(/\r?\n/).map(s=>s.trim()).find(s=>s.length>0)||null}var zi;function Ri(t={}){let e=Object.keys(t).length===0;if(e&&zi!==void 0)return zi;let r=gE(t);return e&&r!==null&&(zi=r),r}function gE(t){let e=t.platform??process.platform,r=t.execPath??process.execPath;if(Bl(r))return r;let n=t.env??process.env,o=t.homeDirectory??(0,Xl.homedir)(),s=t.pathExists??be.existsSync,i=t.lookupInPath??hE,a=e==="win32"?[n.NODE,Yl.default.join(o,".nvm","current","bin","node.exe"),"node"]:[n.NODE,"/usr/local/bin/node","/opt/homebrew/bin/node","/usr/bin/node","node"];for(let c of a){let u=c?.trim();if(u&&(Bl(u)&&s(u)||u.toLowerCase()==="node"))return u}return i("node",e)}function ed(){if(!(0,be.existsSync)(ft))return null;try{return JSON.parse((0,be.readFileSync)(ft,"utf-8"))}catch(t){return t instanceof Error?f.warn("SYSTEM","Failed to parse PID file",{path:ft},t):f.warn("SYSTEM","Failed to parse PID file",{path:ft},new Error(String(t))),null}}function td(){if((0,be.existsSync)(ft))try{(0,be.unlinkSync)(ft)}catch(t){t instanceof Error?f.warn("SYSTEM","Failed to remove PID file",{path:ft},t):f.warn("SYSTEM","Failed to remove PID file",{path:ft},new Error(String(t)))}}function Rt(t){return process.platform==="win32"?Math.round(t*2):t}function rd(t,e,r={}){Oi().assertCanSpawn("worker daemon");let n=Yt({...process.env,CLAUDE_MEM_WORKER_PORT:String(e),...r}),o=Ri();if(!o){f.error("SYSTEM","Node runtime not found \u2014 ensure node is on PATH or set the NODE env var. The worker daemon runs under Node (node:sqlite).");return}if(process.platform==="win32")try{let l=yr(o,[t,"--daemon"],{detached:!0,stdio:"ignore",windowsHide:!0,env:n});if(l.pid===void 0){f.error("SYSTEM","Worker daemon spawn produced no PID on Windows",{runtimePath:o});return}return l.unref(),l.pid}catch(l){f.error("SYSTEM","Failed to spawn worker daemon on Windows",{runtimePath:o},Gl(l));return}let s="/usr/bin/setsid",i=(0,be.existsSync)(s),u=yr(i?s:o,i?[o,t,"--daemon"]:[t,"--daemon"],{detached:!0,stdio:"ignore",env:n});if(u.pid!==void 0)return u.unref(),u.pid}function nd(t){if(t===0)return!0;if(!Number.isInteger(t)||t<0)return!1;try{return process.kill(t,0),!0}catch(e){if(e instanceof Error){let r=e.code;if(r==="EPERM")return!0;f.debug("SYSTEM","Process not alive",{pid:t,code:r})}else f.debug("SYSTEM","Process not alive (non-Error thrown)",{pid:t},new Error(String(e)));return!1}}function od(){try{if(!(0,be.existsSync)(ft))return;let t=new Date;(0,be.utimesSync)(ft,t,t)}catch{}}function sd(){return pn({logAlive:!1})}var id=we(require("path"),1),ad=we(require("net"),1),cd=require("fs");var _E=2500;async function ud(t,e,r="GET"){let n=await fetch(`http://127.0.0.1:${t}${e}`,{method:r,signal:AbortSignal.timeout(_E)}),o="";try{o=await n.text()}catch{}return{ok:n.ok,statusCode:n.status,body:o}}async function ld(t){return new Promise(e=>{let r=ad.default.createServer();r.once("error",n=>{n.code==="EADDRINUSE"||n.code==="EACCES"?e(!0):e(!1)}),r.once("listening",()=>{r.close(()=>e(!1))}),r.listen(t,"127.0.0.1")})}async function dd(t,e,r,n){let o=Date.now();for(;Date.now()-o<r;){try{if((await ud(t,e)).ok)return!0}catch(s){s instanceof Error?f.debug("SYSTEM",n,{},s):f.debug("SYSTEM",n,{error:String(s)})}await new Promise(s=>setTimeout(s,500))}return!1}function fn(t,e=3e4){return dd(t,"/api/health",e,"Service not ready yet, will retry")}function mn(t,e=3e4){return dd(t,"/api/readiness",e,"Worker not ready yet, will retry")}function yE(){try{let t=id.default.join(vr,"package.json");return JSON.parse((0,cd.readFileSync)(t,"utf-8")).version}catch(t){if(t instanceof Error){let e=t.code;if(e==="ENOENT"||e==="EBUSY")return f.debug("SYSTEM","Could not read plugin version (shutdown race)",{code:e}),"unknown";throw t}throw t}}async function SE(t){try{let e=await ud(t,"/api/version");return e.ok?JSON.parse(e.body).version:null}catch{return f.debug("SYSTEM","Could not fetch worker version",{}),null}}async function pd(t){let e=yE(),r=await SE(t);return!r||e==="unknown"?{matches:!0,pluginVersion:e,workerVersion:r}:{matches:e===r,pluginVersion:e,workerVersion:r}}var bo=require("path"),Ve=require("fs");var vE=6e4;function fd(){return(0,bo.join)(pi(),"spawn.lock")}function ko(){let t=fd(),e=JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()});for(let r=0;r<2;r++)try{return(0,Ve.mkdirSync)((0,bo.dirname)(t),{recursive:!0}),(0,Ve.writeFileSync)(t,e,{flag:"wx"}),!0}catch(n){if(n?.code!=="EEXIST")return!0;if(r>0)return!1;let s;try{s=(0,Ve.statSync)(t).mtimeMs}catch{continue}if(Date.now()-s<=vE)return!1;let i;try{i=(0,Ve.statSync)(t).mtimeMs}catch{continue}if(i!==s)return!1;try{(0,Ve.unlinkSync)(t)}catch{return!1}}return!1}function xo(){let t=fd();try{if(JSON.parse((0,Ve.readFileSync)(t,"utf-8")).pid!==process.pid)return;(0,Ve.unlinkSync)(t)}catch{}}function Mi(t,e,r){let n=process.env[t];if(n){let o=parseInt(n,10);if(Number.isFinite(o)&&o>=r.min&&o<=r.max)return o;f.warn("SYSTEM",`Invalid ${t}, using default`,{value:n,min:r.min,max:r.max})}return e}var Ro=Mi("CLAUDE_MEM_HEALTH_TIMEOUT_MS",vt(ue.HEALTH_CHECK),{min:500,max:3e5}),kC=Mi("CLAUDE_MEM_API_TIMEOUT_MS",vt(ue.API_REQUEST),{min:500,max:3e5}),_d=Mi("CLAUDE_MEM_HOOK_READINESS_TIMEOUT_MS",vt(ue.HOOK_READINESS_WAIT),{min:0,max:3e5}),EE={min:500,max:3e5};async function Ni(t,e={},r){try{return await fetch(t,{...e,signal:AbortSignal.timeout(r)})}catch(n){throw n instanceof DOMException&&n.name==="TimeoutError"?new Error(`Request timed out after ${r}ms`):n}}var $o=null,Po=null,To=null,Oo=null;function wE(){return br.default.join(Bt.get("CLAUDE_MEM_DATA_DIR"),"settings.json")}function bE(t){if(!Number.isInteger(t)||t<=0)return!1;try{return process.kill(t,0),!0}catch(e){return e?.code==="EPERM"}}function kE(){try{let t=fe.workerPid();if(!(0,Fe.existsSync)(t))return null;let e=JSON.parse((0,Fe.readFileSync)(t,"utf-8"));return typeof e.pid!="number"||typeof e.port!="number"||!bE(e.pid)?null:e.port}catch{return null}}function Di(){return To!==null||(To=Bt.loadFromFile(wE())),To}function md(t,e){if(!t)return null;let r=parseInt(t,10);return Number.isFinite(r)&&r>=e.min&&r<=e.max?r:null}function xE(t,e,r){let n=process.env[t];if(n!==void 0){let i=md(n,r);return i!==null?i:(f.warn("SYSTEM",`Invalid ${t}, using default`,{value:n,min:r.min,max:r.max}),e)}let o=Di()[t],s=md(o,r);return s!==null?s:(f.warn("SYSTEM",`Invalid ${t} in settings.json, using default`,{value:o,min:r.min,max:r.max}),e)}function $E(){if($o!==null)return $o;let t=Di();return $o=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),$o}function It(){let t=kE();return t!==null?t:$E()}function PE(){return Po!==null||(Po=Di().CLAUDE_MEM_WORKER_HOST),Po}function TE(){return Oo!==null||(Oo=xE("CLAUDE_MEM_API_TIMEOUT_MS",vt(ue.API_REQUEST),EE)),Oo}function OE(t){return`http://${PE()}:${It()}${t}`}function Qt(t,e={}){let r=e.method??"GET",n=e.timeoutMs??TE(),o=OE(t),s={method:r};return e.headers&&(s.headers=e.headers),e.body&&(s.body=e.body),n>0?Ni(o,s,n):fetch(o,s)}async function zE(){return(await Qt("/api/health",{timeoutMs:Ro})).ok}async function hd(){return(await Qt("/api/readiness",{timeoutMs:Ro})).ok}function Li(){let t=[br.default.join(vr,"plugin","scripts","worker-service.cjs"),br.default.join(process.cwd(),"plugin","scripts","worker-service.cjs")];for(let e of t)if((0,Fe.existsSync)(e))return e;return null}async function RE(t){let e=t.backoffMs;for(let r=1;r<=t.attempts;r++){if(await Sd())return!0;r<t.attempts&&(await new Promise(n=>setTimeout(n,e)),e*=2)}return!1}async function Ii(t=_d){if(t<=0)try{return await hd()}catch{return!1}let e=Date.now();for(;Date.now()-e<t;){try{if(await hd())return!0}catch(n){f.debug("SYSTEM","Worker readiness check threw",{error:n instanceof Error?n.message:String(n)})}let r=t-(Date.now()-e);if(r<=0)break;await new Promise(n=>setTimeout(n,Math.min(250,r)))}return!1}async function yd(){try{let e=await(await Qt("/api/health",{timeoutMs:Ro})).json();return typeof e.version=="string"?e.version:null}catch{return null}}async function IE(t,e=_d){let r=Date.now();for(;Date.now()-r<e;){if(await yd()===t)return!0;let o=e-(Date.now()-r);if(o<=0)break;await new Promise(s=>setTimeout(s,Math.min(500,o)))}return!1}async function Ci(t){let e=await yd();e!==null&&e!==t&&f.warn("SYSTEM","Worker is ready but still reports a stale version; not recycling again in this hook invocation (one recycle per hook event)",{pluginVersion:t,workerVersion:e})}async function Sd(){let t;try{t=await zE()}catch(r){return f.debug("SYSTEM","Worker health check threw",{error:r instanceof Error?r.message:String(r)}),!1}if(!t)return!1;let e=pn({logAlive:!1});return e==="missing"||e==="alive"}async function CE(){let t=null;if(await Sd()){let{matches:s,pluginVersion:i,workerVersion:a}=await pd(It());if(i!=="unknown"&&(t=i),s)return await Ii()?(t!==null&&await Ci(t),!0):(f.warn("SYSTEM","Worker is healthy but not ready; skipping hook API call"),!1);f.info("SYSTEM","Worker version mismatch \u2014 recycling stale worker",{pluginVersion:i,workerVersion:a});try{if(await Qt("/api/admin/restart",{method:"POST",timeoutMs:Ro}),await IE(i))return await Ii()?(t!==null&&await Ci(t),!0):(f.warn("SYSTEM","Recycled worker appeared but did not become ready; skipping hook API call"),!1);f.warn("SYSTEM","No successor worker appeared after recycle; falling through to lazy-spawn",{pluginVersion:i,workerVersion:a})}catch(c){f.debug("SYSTEM","Worker restart request failed; falling through to lazy-spawn",{error:c instanceof Error?c.message:String(c)})}}let e=Ri(),r=Li();if(!e)return f.warn("SYSTEM","Cannot lazy-spawn worker: Node runtime not found on PATH"),!1;if(!r)return f.warn("SYSTEM","Cannot lazy-spawn worker: worker-service.cjs not found in plugin/scripts"),!1;let n=ko();try{if(n){f.info("SYSTEM","Worker not running \u2014 lazy-spawning",{runtimePath:e,scriptPath:r});try{yr(e,[r,"--daemon"],{detached:!0,stdio:["ignore","ignore","ignore"]}).unref()}catch(i){return i instanceof Error?f.error("SYSTEM","Lazy-spawn of worker failed",{runtimePath:e,scriptPath:r},i):f.error("SYSTEM","Lazy-spawn of worker failed (non-Error)",{runtimePath:e,scriptPath:r,error:String(i)}),!1}}else f.info("SYSTEM","Another launcher holds the spawn lock \u2014 skipping lazy-spawn and waiting for its worker");if(!await RE({attempts:6,backoffMs:500}))return f.warn("SYSTEM",n?"Worker port did not open after lazy-spawn within the cold-boot wait (~15s)":"Spawn-lock holder's worker port did not open within the cold-boot wait (~15s)"),!1}finally{n&&xo()}return await Ii()?(t!==null&&await Ci(t),!0):(f.warn("SYSTEM","Worker lazy-spawned but did not become ready before hook readiness timeout"),!1)}var zo=null;async function AE(){return zo!==null||(zo=await CE()),zo}var ME=3;function vd(){return br.default.join(B,"state")}function Ed(){return br.default.join(vd(),"hook-failures.json")}function wd(){try{let t=(0,Fe.readFileSync)(Ed(),"utf-8"),e=JSON.parse(t);return{consecutiveFailures:typeof e.consecutiveFailures=="number"&&Number.isFinite(e.consecutiveFailures)?Math.max(0,Math.floor(e.consecutiveFailures)):0,lastFailureAt:typeof e.lastFailureAt=="number"&&Number.isFinite(e.lastFailureAt)?e.lastFailureAt:0}}catch{return{consecutiveFailures:0,lastFailureAt:0}}}function bd(t){let e=vd(),r=Ed(),n=`${r}.tmp`;try{(0,Fe.existsSync)(e)||(0,Fe.mkdirSync)(e,{recursive:!0}),(0,Fe.writeFileSync)(n,JSON.stringify(t),"utf-8"),(0,Fe.renameSync)(n,r)}catch(o){f.debug("SYSTEM","Failed to persist hook-failure counter",{error:o instanceof Error?o.message:String(o)})}}function NE(){try{let e=rt().CLAUDE_MEM_HOOK_FAIL_LOUD_THRESHOLD,r=parseInt(e,10);if(Number.isFinite(r)&&r>=1)return r}catch{}return ME}var DE=["context","session-init","observation","summarize","file-context"],LE=null;function kd(t){LE=DE.includes(t)?t:null}async function ji(){let e={consecutiveFailures:wd().consecutiveFailures+1,lastFailureAt:Date.now()};bd(e);let r=NE();return e.consecutiveFailures>=r&&un(`keepmind worker unreachable for ${e.consecutiveFailures} consecutive hooks \u2014 continuing without memory capture. Run \`keepmind doctor\` to diagnose.`),e.consecutiveFailures}function gd(){wd().consecutiveFailures!==0&&bd({consecutiveFailures:0,lastFailureAt:0})}var Ai=Symbol.for("claude-mem/worker-fallback");function me(t){return typeof t=="object"&&t!==null&&t[Ai]===!0}async function le(t,e,r,n={}){if(!await AE())return await ji(),{continue:!0,reason:"worker_unreachable",[Ai]:!0};let s={method:e};r!==void 0&&(s.headers={"Content-Type":"application/json"},s.body=JSON.stringify(r)),n.timeoutMs!==void 0&&(s.timeoutMs=n.timeoutMs);let i=await Qt(t,s);if(!i.ok){let c=await i.text().catch(()=>"");if(gd(),i.status===429||i.status>=500)return f.warn("SYSTEM",`Worker API ${e} ${t} returned ${i.status}; skipping hook API call`,{body:c.substring(0,200)}),{continue:!0,reason:`worker_api_${i.status}`,[Ai]:!0};let u=c;try{u=JSON.parse(c)}catch{}return u}gd();let a=await i.text();if(a.length!==0)try{return JSON.parse(a)}catch{return a}}var xd=require("fs");function jE(t){let e=ed();return e&&typeof e.port=="number"&&nd(e.pid)?e.port:t}async function UE(t,e){let r=Date.now()+e;for(;Date.now()<r;){let n=jE(t);if(await fn(n,800))return n;await new Promise(o=>setTimeout(o,300))}return null}async function $d(t,e){if(!e)return f.error("SYSTEM","ensureWorkerStarted called with empty workerScriptPath \u2014 caller bug"),"dead";if(!(0,xd.existsSync)(e))return f.error("SYSTEM","ensureWorkerStarted: worker script not found at expected path \u2014 likely a partial install or build artifact missing",{workerScriptPath:e}),"dead";if(await fn(t,1e3)){let a=await mn(t,Rt(ue.READINESS_WAIT));return a||f.warn("SYSTEM","Worker is alive but readiness timed out \u2014 proceeding anyway"),f.info("SYSTEM","Worker already running and healthy (fast path)"),a?"ready":"warming"}if(sd()==="alive"){if(f.info("SYSTEM","Worker PID file points to a live process, waiting for it to become healthy"),await fn(t,Rt(ue.POST_SPAWN_WAIT))){let c=await mn(t,Rt(ue.READINESS_WAIT));return f.info("SYSTEM","Worker became healthy while waiting on live PID"),c?"ready":"warming"}f.warn("SYSTEM","PID file marked live but worker never became healthy within the cold-boot window \u2014 treating it as a stale/reused PID and re-spawning"),td()}if(await ld(t)){if(f.info("SYSTEM","Port in use, waiting for worker to become healthy"),await fn(t,Rt(ue.PORT_IN_USE_WAIT))){let c=await mn(t,Rt(ue.READINESS_WAIT));return f.info("SYSTEM","Worker is now healthy"),c?"ready":"warming"}f.warn("SYSTEM","Configured port in use but no healthy worker \u2014 spawning anyway (worker will pick a free ephemeral port)")}let o=ko(),s=t;try{if(o){if(f.info("SYSTEM","Starting worker daemon",{workerScriptPath:e}),rd(e,t)===void 0)return f.error("SYSTEM","Failed to spawn worker daemon"),"dead"}else f.info("SYSTEM","Another launcher holds the spawn lock \u2014 skipping duplicate spawn and waiting for its worker");let a=await UE(t,Rt(ue.POST_SPAWN_WAIT));if(a===null)return f.warn("SYSTEM",o?"Worker spawned but health endpoint not responding within window \u2014 likely still starting in background":"Spawn-lock holder's worker not healthy within window \u2014 likely still starting in background"),"warming";s=a}finally{o&&xo()}let i=await mn(s,Rt(ue.READINESS_WAIT));return i||f.warn("SYSTEM","Worker is alive but readiness timed out \u2014 proceeding anyway"),od(),f.info("SYSTEM",o?"Worker started successfully":"Worker is up (started by another launcher)"),i?"ready":"warming"}function FE(){try{let t=process.stdin;return t.isTTY?!1:(t.readable,!0)}catch(t){return f.debug("HOOK","stdin not available (expected for some runtimes)",{error:t instanceof Error?t.message:String(t)}),!1}}function ZE(t){let e=t.trim();if(!e)return{success:!1};try{return{success:!0,value:JSON.parse(e)}}catch(r){return f.debug("HOOK","JSON parse attempt incomplete",{error:r instanceof Error?r.message:String(r)}),{success:!1}}}var Pd=3e4;async function Td(){if(FE())return new Promise((t,e)=>{let r="",n=!1,o=()=>{try{process.stdin.removeAllListeners("data"),process.stdin.removeAllListeners("end"),process.stdin.removeAllListeners("error")}catch{}},s=p=>{n||(n=!0,clearTimeout(c),o(),t(p))},i=p=>{n||(n=!0,clearTimeout(c),o(),e(p))},a=()=>{let p=ZE(r);return p.success?(s(p.value),!0):!1},c=setTimeout(()=>{n||a()||(r.trim()?i(new Error(`Incomplete JSON after ${Pd}ms: ${r.slice(0,100)}...`)):s(void 0))},Pd),u=p=>{r+=p,a()},l=()=>{n||a()||(r.trim()?i(new Error(`Malformed JSON at stdin EOF: ${r.slice(0,100)}...`)):s(void 0))},d=()=>{n||s(void 0)};try{process.stdin.on("data",u),process.stdin.on("end",l),process.stdin.on("error",d)}catch(p){f.debug("HOOK","Failed to attach stdin listeners",{error:p instanceof Error?p.message:String(p)}),n=!0,clearTimeout(c),o(),t(void 0)}})}var he=class extends Error{constructor(r){super(`adapter rejected input: ${r}`);this.reason=r;this.name="AdapterRejectedInput"}reason};function Ke(t){return typeof t=="string"&&t.length>0}var qE=128,Od=t=>typeof t=="string"&&t.length>0&&t.length<=qE?t:void 0,zd={normalizeInput(t){let e=t??{},r=e.cwd??process.cwd();if(!Ke(r))throw new he("invalid_cwd");return{sessionId:e.session_id??e.id??e.sessionId,cwd:r,prompt:e.prompt,toolName:e.tool_name,toolInput:e.tool_input,toolResponse:e.tool_response,transcriptPath:e.transcript_path,agentId:Od(e.agent_id),agentType:Od(e.agent_type)}},formatOutput(t){let e=t??{};if(e.hookSpecificOutput){let n={hookSpecificOutput:t.hookSpecificOutput};return e.systemMessage&&(n.systemMessage=e.systemMessage),n}let r={};return e.systemMessage&&(r.systemMessage=e.systemMessage),r}};var Co=require("fs"),Io=we(require("path"),1),qd=we(Fd(),1),ew=10,tw=new Set(["cat","head","tail","less","more","bat","view","nl","tac"]),rw={head:new Set(["-n","-c","--lines","--bytes"]),tail:new Set(["-n","-c","--lines","--bytes"])},nw=new Set;function ow(t){return typeof t=="object"&&t!==null&&"op"in t}function sw(t){let e=[],r=[];for(let n of t){if(ow(n)){r.length>0&&e.push(r),r=[];continue}typeof n=="string"&&r.push(n)}return r.length>0&&e.push(r),e}function iw(t){if(typeof t=="string")return t;if(Array.isArray(t)){let e=t.filter(r=>typeof r=="string");return e.length>0?e.join(" "):null}return null}function Zd(t){return t.startsWith("-")||t.startsWith("+")}function aw(t){return rw[t]??nw}function cw(t,e){let r=aw(e);if(r.has(t))return!0;let n=t.indexOf("=");return n>0&&r.has(t.slice(0,n))}function Hd(t,e){let r=Io.default.isAbsolute(t)?t:Io.default.resolve(e,t);try{return(0,Co.existsSync)(r)?(0,Co.statSync)(r).isFile():!1}catch{return!1}}function Wd(t){let e=new Set,r=[];for(let n of t)if(!e.has(n)&&(e.add(n),r.push(n),r.length>=ew))break;return r}function uw(t,e){let r=iw(t?.command);if(!r)return[];let n=(0,qd.parse)(r),o=[];for(let s of sw(n)){let i=s.findIndex(u=>u&&!Zd(u));if(i===-1)continue;let a=Io.default.basename(s[i]);if(!tw.has(a))continue;let c=!1;for(let u of s.slice(i+1)){if(c){c=!1;continue}if(Zd(u)){c=cw(u,a)&&!u.includes("=");continue}Hd(u,e)&&o.push(u)}}return Wd(o)}function lw(t,e,r){if(!/^mcp__.+__(read|view|cat)(?:_file|_files)?$/.test(t))return[];let n=e??{},o=[];if(typeof n.path=="string"&&o.push(n.path),Array.isArray(n.paths))for(let s of n.paths)typeof s=="string"&&o.push(s);return Wd(o.filter(s=>Hd(s,r)))}function Vd(t,e,r){return t==="Bash"?uw(e,r):t.startsWith("mcp__")?lw(t,e,r):[]}var dw=new Set(["PreToolUse","PermissionRequest","PostToolUse","SessionStart","UserPromptSubmit","Stop"]);function Kd(t){return typeof t=="string"&&dw.has(t)?t:void 0}function Ct(t){return typeof t=="string"&&t.length>0?t:void 0}function pw(t){if(typeof t=="boolean")return t;if(t==="true")return!0;if(t==="false")return!1}function fw(t){return t&&typeof t=="object"&&!Array.isArray(t)?{...t}:t}function mw(t){let e={};return t.continue!==void 0&&(e.continue=t.continue),t.systemMessage&&(e.systemMessage=t.systemMessage),t.decision==="block"&&(e.decision="block"),t.reason&&(e.reason=t.reason),e}function hw(t){return Kd(t.hookSpecificOutput?.hookEventName)}var Jd={normalizeInput(t){let e=t??{},r=typeof e.cwd=="string"?e.cwd:process.cwd();if(!Ke(r))throw new he("invalid_cwd");let n=Kd(e.hook_event_name),o=Ct(e.tool_name),s=fw(e.tool_input);if(n==="PreToolUse"&&o){let u=Vd(o,s,r);u.length>0&&s&&typeof s=="object"&&!Array.isArray(s)&&(s={...s,filePaths:u})}let i=e.source,a=i==="startup"||i==="resume"||i==="clear"?i:void 0,c=Ct(e.session_id);if(!c)throw new he("missing_session_id");return{sessionId:c,cwd:r,prompt:Ct(e.prompt),toolName:o,toolInput:s,toolResponse:e.tool_response,transcriptPath:Ct(e.transcript_path),lastAssistantMessage:Ct(e.last_assistant_message),turnId:Ct(e.turn_id),stopHookActive:pw(e.stop_hook_active),permissionMode:Ct(e.permission_mode),model:Ct(e.model),sessionSource:a}},formatOutput(t){let e=t??{},r=mw(e),n=e.hookSpecificOutput,o=hw(e);if(!n||!o||o==="Stop")return r;let s={hookEventName:o};return n.additionalContext&&(s.additionalContext=n.additionalContext),o==="PreToolUse"&&(n.permissionDecision==="deny"&&(s.permissionDecision="deny",n.permissionDecisionReason&&(s.permissionDecisionReason=n.permissionDecisionReason)),n.updatedInput&&(s.updatedInput=n.updatedInput)),r.hookSpecificOutput=s,r}};var Gd=require("fs"),Bd=require("os"),Yd=require("path");var gw=/^[A-Za-z0-9_-]+$/;function _w(t,e){if(!t||!e||!gw.test(e))return;let r=t.replace(/^\//,"").replace(/[/.]/g,"-"),n=(0,Yd.join)((0,Bd.homedir)(),".cursor","projects",r,"agent-transcripts",e,`${e}.jsonl`);return(0,Gd.existsSync)(n)?n:void 0}var Xd={normalizeInput(t){let e=t??{},r=!!e.command&&!e.tool_name,n=e.workspace_roots?.[0]??e.cwd??process.cwd();if(!Ke(n))throw new he("invalid_cwd");let o=e.conversation_id||e.generation_id||e.id;return{sessionId:o,cwd:n,prompt:e.prompt??e.query??e.input??e.message,toolName:r?"Bash":e.tool_name,toolInput:r?{command:e.command}:e.tool_input,toolResponse:r?{output:e.output}:e.result_json,transcriptPath:_w(n,o),filePath:e.file_path,edits:e.edits}},formatOutput(t){return{continue:t.continue??!0}}};var Qd={normalizeInput(t){let e=t??{},r=e.cwd??process.env.GEMINI_CWD??process.env.GEMINI_PROJECT_DIR??process.env.CLAUDE_PROJECT_DIR??process.cwd();if(!Ke(r))throw new he("invalid_cwd");let n=e.session_id??process.env.GEMINI_SESSION_ID??void 0,o=e.hook_event_name,s=e.tool_name,i=e.tool_input,a=e.tool_response;return o==="AfterAgent"&&e.prompt_response&&(s=s??"GeminiProvider",i=i??{prompt:e.prompt},a=a??{response:e.prompt_response}),o==="BeforeTool"&&s&&!a&&(a={_preExecution:!0}),o==="Notification"&&(s=s??"GeminiNotification",i=i??{notification_type:e.notification_type,message:e.message},a=a??{details:e.details}),{sessionId:n,cwd:r,prompt:e.prompt,toolName:s,toolInput:i,toolResponse:a,transcriptPath:e.transcript_path}},formatOutput(t){let e={};if(e.continue=t.continue??!0,t.suppressOutput!==void 0&&(e.suppressOutput=t.suppressOutput),t.systemMessage){let r=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;e.systemMessage=t.systemMessage.replace(r,"")}return t.hookSpecificOutput&&(e.hookSpecificOutput={additionalContext:t.hookSpecificOutput.additionalContext}),e}};var qi={normalizeInput(t){let e=t??{},r=e.cwd??process.cwd();if(!Ke(r))throw new he("invalid_cwd");return{sessionId:e.sessionId??e.session_id??"unknown",cwd:r,prompt:e.prompt,toolName:e.toolName??e.tool_name,toolInput:e.toolInput??e.tool_input,toolResponse:e.toolResponse??e.tool_response,transcriptPath:e.transcriptPath??e.transcript_path,filePath:e.filePath??e.file_path,edits:e.edits}},formatOutput(t){return t}};var ep={normalizeInput(t){let e=t??{},r=e.tool_info??{},n=e.agent_action_name??"",o=r.cwd??process.cwd();if(!Ke(o))throw new he("invalid_cwd");let s={sessionId:e.trajectory_id??e.execution_id,cwd:o,platform:"windsurf"};switch(n){case"pre_user_prompt":return{...s,prompt:r.user_prompt};case"post_write_code":return{...s,toolName:"Write",filePath:r.file_path,edits:r.edits,toolInput:{file_path:r.file_path,edits:r.edits}};case"post_run_command":return{...s,cwd:r.cwd??s.cwd,toolName:"Bash",toolInput:{command:r.command_line}};case"post_mcp_tool_use":return{...s,toolName:r.mcp_tool_name??"mcp_tool",toolInput:r.mcp_tool_arguments,toolResponse:r.mcp_result};case"post_cascade_response":return{...s,toolName:"cascade_response",toolResponse:r.response};default:return s}},formatOutput(t){return{continue:t.continue??!0}}};function tp(t){switch(t){case"claude-code":return zd;case"codex":return Jd;case"cursor":return Xd;case"gemini":case"gemini-cli":return Qd;case"windsurf":return ep;case"raw":return qi;default:return qi}}var np=require("os"),op=we(require("path"),1),sp=require("child_process");var Mo=require("fs"),Ao=we(require("path"),1);var hn={isWorktree:!1,worktreeName:null,parentRepoPath:null,parentProjectName:null};function rp(t){let e=Ao.default.join(t,".git"),r;try{r=(0,Mo.statSync)(e)}catch(l){return l instanceof Error&&l.code!=="ENOENT"&&f.warn("GIT","Unexpected error checking .git",{error:l instanceof Error?l.message:String(l)}),hn}if(!r.isFile())return hn;let n;try{n=(0,Mo.readFileSync)(e,"utf-8").trim()}catch(l){return f.warn("GIT","Failed to read .git file",{error:l instanceof Error?l.message:String(l)}),hn}let o=n.match(/^gitdir:\s*(.+)$/);if(!o)return hn;let i=o[1].match(/^(.+)[/\\]\.git[/\\]worktrees[/\\]([^/\\]+)$/);if(!i)return hn;let a=i[1],c=Ao.default.basename(t),u=Ao.default.basename(a);return{isWorktree:!0,worktreeName:c,parentRepoPath:a,parentProjectName:u}}function ip(t){return t==="~"||t.startsWith("~/")?t.replace(/^~/,(0,np.homedir)()):t}function yw(t){try{return(0,sp.execFileSync)("git",["rev-parse","--show-toplevel"],{cwd:t,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()||null}catch{return null}}function Hi(t){if(!t||t.trim()==="")return f.warn("PROJECT_NAME","Empty cwd provided, using fallback",{cwd:t}),"unknown-project";let e=ip(t),n=yw(e)??e,o=op.default.basename(n);if(o===""){if(process.platform==="win32"){let i=t.match(/^([A-Z]):\\/i);if(i){let c=`drive-${i[1].toUpperCase()}`;return f.info("PROJECT_NAME","Drive root detected",{cwd:t,projectName:c}),c}}return f.warn("PROJECT_NAME","Root directory detected, using fallback",{cwd:t}),"unknown-project"}return o}function kr(t){let e=Hi(t);if(!t)return{primary:e,parent:null,isWorktree:!1,allProjects:[e]};let r=ip(t),n=rp(r);if(n.isWorktree&&n.parentProjectName){let o=`${n.parentProjectName}/${e}`;return{primary:o,parent:n.parentProjectName,isWorktree:!0,allProjects:[n.parentProjectName,o]}}return{primary:e,parent:null,isWorktree:!1,allProjects:[e]}}var ap=require("child_process"),cp=require("util"),tr=require("fs");var up=require("path");var pA=(0,cp.promisify)(ap.execFile);function lp(){try{let t=(0,up.join)(fe.dataDir(),"oauth-stale.marker");return(0,tr.existsSync)(t)?(0,tr.readFileSync)(t,"utf-8"):void 0}catch{return}}var dp="claude";function Sw(t){return t.trim().toLowerCase().replace(/\s+/g,"-")}function Ce(t){if(!t)return dp;let e=Sw(t);return e?e==="transcript"||e.includes("codex")?"codex":e.includes("cursor")?"cursor":e.includes("claude")?"claude":e:dp}var pp;function S(t,e,r){function n(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,c);let u=i.prototype,l=Object.keys(u);for(let d=0;d<l.length;d++){let p=l[d];p in a||(a[p]=u[p].bind(a))}}let o=r?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:t});function i(a){var c;let u=r?.Parent?new s:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(i,"name",{value:t}),i}var mt=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},xr=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(pp=globalThis).__zod_globalConfig??(pp.__zod_globalConfig={});var $r=globalThis.__zod_globalConfig;function Ze(t){return t&&Object.assign($r,t),$r}var F={};Rl(F,{BIGINT_FORMAT_RANGES:()=>gp,Class:()=>Vi,NUMBER_FORMAT_RANGES:()=>Xi,aborted:()=>Nt,allowsEval:()=>Gi,assert:()=>kw,assertEqual:()=>vw,assertIs:()=>ww,assertNever:()=>bw,assertNotEqual:()=>Ew,assignProp:()=>At,base64ToUint8Array:()=>yp,base64urlToUint8Array:()=>Fw,cached:()=>Tr,captureStackTrace:()=>Lo,cleanEnum:()=>Uw,cleanRegex:()=>Sn,clone:()=>nt,cloneDef:()=>$w,createTransparentProxy:()=>Iw,defineLazy:()=>V,esc:()=>Do,escapeRegex:()=>bt,explicitlyAborted:()=>Qi,extend:()=>Mw,finalizeIssue:()=>Je,floatSafeRemainder:()=>Ki,getElementAtPath:()=>Pw,getEnumValues:()=>_n,getLengthableOrigin:()=>vn,getParsedType:()=>Rw,getSizableOrigin:()=>_p,hexToUint8Array:()=>qw,isObject:()=>rr,isPlainObject:()=>Mt,issue:()=>Or,joinValues:()=>No,jsonStringifyReplacer:()=>Pr,merge:()=>Dw,mergeDefs:()=>wt,normalizeParams:()=>z,nullish:()=>yn,numKeys:()=>zw,objectClone:()=>xw,omit:()=>Aw,optionalKeys:()=>Yi,parsedType:()=>ea,partial:()=>Lw,pick:()=>Cw,prefixIssues:()=>kt,primitiveTypes:()=>hp,promiseAllObject:()=>Tw,propertyKeyTypes:()=>Bi,randomString:()=>Ow,required:()=>jw,safeExtend:()=>Nw,shallowClone:()=>mp,slugify:()=>Ji,stringifyPrimitive:()=>jo,uint8ArrayToBase64:()=>Sp,uint8ArrayToBase64url:()=>Zw,uint8ArrayToHex:()=>Hw,unwrapMessage:()=>gn});function vw(t){return t}function Ew(t){return t}function ww(t){}function bw(t){throw new Error("Unexpected value in exhaustive check")}function kw(t){}function _n(t){let e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,o])=>e.indexOf(+n)===-1).map(([n,o])=>o)}function No(t,e="|"){return t.map(r=>jo(r)).join(e)}function Pr(t,e){return typeof e=="bigint"?e.toString():e}function Tr(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function yn(t){return t==null}function Sn(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function Ki(t,e){let r=t/e,n=Math.round(r),o=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}var fp=Symbol("evaluating");function V(t,e,r){let n;Object.defineProperty(t,e,{get(){if(n!==fp)return n===void 0&&(n=fp,n=r()),n},set(o){Object.defineProperty(t,e,{value:o})},configurable:!0})}function xw(t){return Object.create(Object.getPrototypeOf(t),Object.getOwnPropertyDescriptors(t))}function At(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function wt(...t){let e={};for(let r of t){let n=Object.getOwnPropertyDescriptors(r);Object.assign(e,n)}return Object.defineProperties({},e)}function $w(t){return wt(t._zod.def)}function Pw(t,e){return e?e.reduce((r,n)=>r?.[n],t):t}function Tw(t){let e=Object.keys(t),r=e.map(n=>t[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<e.length;s++)o[e[s]]=n[s];return o})}function Ow(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<t;n++)r+=e[Math.floor(Math.random()*e.length)];return r}function Do(t){return JSON.stringify(t)}function Ji(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Lo="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function rr(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var Gi=Tr(()=>{if($r.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function Mt(t){if(rr(t)===!1)return!1;let e=t.constructor;if(e===void 0||typeof e!="function")return!0;let r=e.prototype;return!(rr(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function mp(t){return Mt(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}function zw(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}var Rw=t=>{let e=typeof t;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},Bi=new Set(["string","number","symbol"]),hp=new Set(["string","number","bigint","boolean","symbol","undefined"]);function bt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function nt(t,e,r){let n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function z(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function Iw(t){let e;return new Proxy({},{get(r,n,o){return e??(e=t()),Reflect.get(e,n,o)},set(r,n,o,s){return e??(e=t()),Reflect.set(e,n,o,s)},has(r,n){return e??(e=t()),Reflect.has(e,n)},deleteProperty(r,n){return e??(e=t()),Reflect.deleteProperty(e,n)},ownKeys(r){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(r,n){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,n)},defineProperty(r,n,o){return e??(e=t()),Reflect.defineProperty(e,n,o)}})}function jo(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function Yi(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}var Xi={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]},gp={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Cw(t,e){let r=t._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s=wt(t._zod.def,{get shape(){let i={};for(let a in e){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(i[a]=r.shape[a])}return At(this,"shape",i),i},checks:[]});return nt(t,s)}function Aw(t,e){let r=t._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=wt(t._zod.def,{get shape(){let i={...t._zod.def.shape};for(let a in e){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete i[a]}return At(this,"shape",i),i},checks:[]});return nt(t,s)}function Mw(t,e){if(!Mt(e))throw new Error("Invalid input to extend: expected a plain object");let r=t._zod.def.checks;if(r&&r.length>0){let s=t._zod.def.shape;for(let i in e)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=wt(t._zod.def,{get shape(){let s={...t._zod.def.shape,...e};return At(this,"shape",s),s}});return nt(t,o)}function Nw(t,e){if(!Mt(e))throw new Error("Invalid input to safeExtend: expected a plain object");let r=wt(t._zod.def,{get shape(){let n={...t._zod.def.shape,...e};return At(this,"shape",n),n}});return nt(t,r)}function Dw(t,e){if(t._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=wt(t._zod.def,{get shape(){let n={...t._zod.def.shape,...e._zod.def.shape};return At(this,"shape",n),n},get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return nt(t,r)}function Lw(t,e,r){let o=e._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let i=wt(e._zod.def,{get shape(){let a=e._zod.def.shape,c={...a};if(r)for(let u in r){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(c[u]=t?new t({type:"optional",innerType:a[u]}):a[u])}else for(let u in a)c[u]=t?new t({type:"optional",innerType:a[u]}):a[u];return At(this,"shape",c),c},checks:[]});return nt(e,i)}function jw(t,e,r){let n=wt(e._zod.def,{get shape(){let o=e._zod.def.shape,s={...o};if(r)for(let i in r){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);r[i]&&(s[i]=new t({type:"nonoptional",innerType:o[i]}))}else for(let i in o)s[i]=new t({type:"nonoptional",innerType:o[i]});return At(this,"shape",s),s}});return nt(e,n)}function Nt(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function Qi(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue===!1)return!0;return!1}function kt(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function gn(t){return typeof t=="string"?t:t?.message}function Je(t,e,r){let n=t.message?t.message:gn(t.inst?._zod.def?.error?.(t))??gn(e?.error?.(t))??gn(r.customError?.(t))??gn(r.localeError?.(t))??"Invalid input",{inst:o,continue:s,input:i,...a}=t;return a.path??(a.path=[]),a.message=n,e?.reportInput&&(a.input=i),a}function _p(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function vn(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function ea(t){let e=typeof t;switch(e){case"number":return Number.isNaN(t)?"nan":"number";case"object":{if(t===null)return"null";if(Array.isArray(t))return"array";let r=t;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return e}function Or(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}function Uw(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function yp(t){let e=atob(t),r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}function Sp(t){let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return btoa(e)}function Fw(t){let e=t.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-e.length%4)%4);return yp(e+r)}function Zw(t){return Sp(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function qw(t){let e=t.replace(/^0x/,"");if(e.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)r[n/2]=Number.parseInt(e.slice(n,n+2),16);return r}function Hw(t){return Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}var Vi=class{constructor(...e){}};var vp=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,Pr,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Uo=S("$ZodError",vp),ta=S("$ZodError",vp,{Parent:Error});function Ep(t,e=r=>r.message){let r={},n=[];for(let o of t.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(e(o))):n.push(e(o));return{formErrors:n,fieldErrors:r}}function wp(t,e=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(e(i));else{let c=r,u=0;for(;u<a.length;){let l=a[u];u===a.length-1?(c[l]=c[l]||{_errors:[]},c[l]._errors.push(e(i))):c[l]=c[l]||{_errors:[]},c=c[l],u++}}}};return n(t),r}var Fo=t=>(e,r,n,o)=>{let s=n?{...n,async:!1}:{async:!1},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new mt;if(i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>Je(c,s,Ze())));throw Lo(a,o?.callee),a}return i.value};var Zo=t=>async(e,r,n,o)=>{let s=n?{...n,async:!0}:{async:!0},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>Je(c,s,Ze())));throw Lo(a,o?.callee),a}return i.value};var En=t=>(e,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=e._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new mt;return s.issues.length?{success:!1,error:new(t??Uo)(s.issues.map(i=>Je(i,o,Ze())))}:{success:!0,data:s.value}},wn=En(ta),bn=t=>async(e,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=e._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new t(s.issues.map(i=>Je(i,o,Ze())))}:{success:!0,data:s.value}},qo=bn(ta),bp=t=>(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Fo(t)(e,r,o)};var kp=t=>(e,r,n)=>Fo(t)(e,r,n);var xp=t=>async(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Zo(t)(e,r,o)};var $p=t=>async(e,r,n)=>Zo(t)(e,r,n);var Pp=t=>(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return En(t)(e,r,o)};var Tp=t=>(e,r,n)=>En(t)(e,r,n);var Op=t=>async(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return bn(t)(e,r,o)};var zp=t=>async(e,r,n)=>bn(t)(e,r,n);var Rp=/^[cC][0-9a-z]{6,}$/,Ip=/^[0-9a-z]+$/,Cp=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Ap=/^[0-9a-vA-V]{20}$/,Mp=/^[A-Za-z0-9]{27}$/,Np=/^[a-zA-Z0-9_-]{21}$/,Dp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Lp=/^([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})$/,ra=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[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 jp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Vw="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Up(){return new RegExp(Vw,"u")}var Fp=/^(?:(?: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])$/,Zp=/^(([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 qp=/^((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])$/,Hp=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Wp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,na=/^[A-Za-z0-9_-]*$/;var Vp=/^https?$/,Kp=/^\+[1-9]\d{6,14}$/,Jp="(?:(?:\\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])))",Gp=new RegExp(`^${Jp}$`);function Bp(t){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Yp(t){return new RegExp(`^${Bp(t)}$`)}function Xp(t){let e=Bp({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${e}(?:${r.join("|")})`;return new RegExp(`^${Jp}T(?:${n})$`)}var Qp=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)};var ef=/^-?\d+$/,oa=/^-?\d+(?:\.\d+)?$/,tf=/^(?:true|false)$/i,rf=/^null$/i;var nf=/^[^A-Z]*$/,of=/^[^a-z]*$/;var ge=S("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),sf={number:"number",bigint:"bigint",object:"date"},sa=S("$ZodCheckLessThan",(t,e)=>{ge.init(t,e);let r=sf[typeof e.value];t._zod.onattach.push(n=>{let o=n._zod.bag,s=(e.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?o.maximum=e.value:o.exclusiveMaximum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),ia=S("$ZodCheckGreaterThan",(t,e)=>{ge.init(t,e);let r=sf[typeof e.value];t._zod.onattach.push(n=>{let o=n._zod.bag,s=(e.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?o.minimum=e.value:o.exclusiveMinimum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),af=S("$ZodCheckMultipleOf",(t,e)=>{ge.init(t,e),t._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=e.value)}),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):Ki(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),cf=S("$ZodCheckNumberFormat",(t,e)=>{ge.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[o,s]=Xi[e.format];t._zod.onattach.push(i=>{let a=i._zod.bag;a.format=e.format,a.minimum=o,a.maximum=s,r&&(a.pattern=ef)}),t._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:e.format,code:"invalid_type",continue:!1,input:a,inst:t});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:t,origin:n,inclusive:!0,continue:!e.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,inclusive:!0,continue:!e.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:t,continue:!e.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:t,continue:!e.abort})}});var uf=S("$ZodCheckMaxLength",(t,e)=>{var r;ge.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!yn(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<o&&(n._zod.bag.maximum=e.maximum)}),t._zod.check=n=>{let o=n.value;if(o.length<=e.maximum)return;let i=vn(o);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),lf=S("$ZodCheckMinLength",(t,e)=>{var r;ge.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!yn(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>o&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{let o=n.value;if(o.length>=e.minimum)return;let i=vn(o);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),df=S("$ZodCheckLengthEquals",(t,e)=>{var r;ge.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!yn(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=e.length,o.maximum=e.length,o.length=e.length}),t._zod.check=n=>{let o=n.value,s=o.length;if(s===e.length)return;let i=vn(o),a=s>e.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),kn=S("$ZodCheckStringFormat",(t,e)=>{var r,n;ge.init(t,e),t._zod.onattach.push(o=>{let s=o._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=o=>{e.pattern.lastIndex=0,!e.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:e.format,input:o.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),pf=S("$ZodCheckRegex",(t,e)=>{kn.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),ff=S("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=nf),kn.init(t,e)}),mf=S("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=of),kn.init(t,e)}),hf=S("$ZodCheckIncludes",(t,e)=>{ge.init(t,e);let r=bt(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(o=>{let s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),t._zod.check=o=>{o.value.includes(e.includes,e.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:o.value,inst:t,continue:!e.abort})}}),gf=S("$ZodCheckStartsWith",(t,e)=>{ge.init(t,e);let r=new RegExp(`^${bt(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),t._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:t,continue:!e.abort})}}),_f=S("$ZodCheckEndsWith",(t,e)=>{ge.init(t,e);let r=new RegExp(`.*${bt(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),t._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:t,continue:!e.abort})}});var yf=S("$ZodCheckOverwrite",(t,e)=>{ge.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});var Wo=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
|
|
24
24
|
`).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 e=Function,r=this?.args,o=[...(this?.content??[""]).map(s=>` ${s}`)];return new e(...r,o.join(`
|
|
25
|
-
`))}};var vf={major:4,minor:4,patch:3};var X=S("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=vf;let n=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&n.unshift(t);for(let o of n)for(let s of o._zod.onattach)s(t);if(n.length===0)(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{let o=(i,a,c)=>{let u=Nt(i),l;for(let d of a){if(d._zod.def.when){if(Qi(i)||!d._zod.def.when(i))continue}else if(u)continue;let p=i.issues.length,m=d._zod.check(i);if(m instanceof Promise&&c?.async===!1)throw new mt;if(l||m instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await m,i.issues.length!==p&&(u||(u=Nt(i,p)))});else{if(i.issues.length===p)continue;u||(u=Nt(i,p))}}return l?l.then(()=>i):i},s=(i,a,c)=>{if(Nt(i))return i.aborted=!0,i;let u=o(a,n,c);if(u instanceof Promise){if(c.async===!1)throw new mt;return u.then(l=>t._zod.parse(l,c))}return t._zod.parse(u,c)};t._zod.run=(i,a)=>{if(a.skipChecks)return t._zod.parse(i,a);if(a.direction==="backward"){let u=t._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(l=>s(l,i,a)):s(u,i,a)}let c=t._zod.parse(i,a);if(c instanceof Promise){if(a.async===!1)throw new mt;return c.then(u=>o(u,n,a))}return o(c,n,a)}}
|
|
25
|
+
`))}};var vf={major:4,minor:4,patch:3};var X=S("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=vf;let n=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&n.unshift(t);for(let o of n)for(let s of o._zod.onattach)s(t);if(n.length===0)(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{let o=(i,a,c)=>{let u=Nt(i),l;for(let d of a){if(d._zod.def.when){if(Qi(i)||!d._zod.def.when(i))continue}else if(u)continue;let p=i.issues.length,m=d._zod.check(i);if(m instanceof Promise&&c?.async===!1)throw new mt;if(l||m instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await m,i.issues.length!==p&&(u||(u=Nt(i,p)))});else{if(i.issues.length===p)continue;u||(u=Nt(i,p))}}return l?l.then(()=>i):i},s=(i,a,c)=>{if(Nt(i))return i.aborted=!0,i;let u=o(a,n,c);if(u instanceof Promise){if(c.async===!1)throw new mt;return u.then(l=>t._zod.parse(l,c))}return t._zod.parse(u,c)};t._zod.run=(i,a)=>{if(a.skipChecks)return t._zod.parse(i,a);if(a.direction==="backward"){let u=t._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(l=>s(l,i,a)):s(u,i,a)}let c=t._zod.parse(i,a);if(c instanceof Promise){if(a.async===!1)throw new mt;return c.then(u=>o(u,n,a))}return o(c,n,a)}}V(t,"~standard",()=>({validate:o=>{try{let s=wn(t,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return qo(t,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),Jo=S("$ZodString",(t,e)=>{X.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??Qp(t._zod.bag),t._zod.parse=(r,n)=>{if(e.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:t}),r}}),Q=S("$ZodStringFormat",(t,e)=>{kn.init(t,e),Jo.init(t,e)}),Of=S("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=Lp),Q.init(t,e)}),zf=S("$ZodUUID",(t,e)=>{if(e.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(n===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=ra(n))}else e.pattern??(e.pattern=ra());Q.init(t,e)}),Rf=S("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=jp),Q.init(t,e)}),If=S("$ZodURL",(t,e)=>{Q.init(t,e),t._zod.check=r=>{try{let n=r.value.trim();if(!e.normalize&&e.protocol?.source===Vp.source&&!/^https?:\/\//i.test(n)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:t,continue:!e.abort});return}let o=new URL(n);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:r.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:r.value,inst:t,continue:!e.abort})),e.normalize?r.value=o.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:t,continue:!e.abort})}}}),Cf=S("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=Up()),Q.init(t,e)}),Af=S("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=Np),Q.init(t,e)}),Mf=S("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=Rp),Q.init(t,e)}),Nf=S("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=Ip),Q.init(t,e)}),Df=S("$ZodULID",(t,e)=>{e.pattern??(e.pattern=Cp),Q.init(t,e)}),Lf=S("$ZodXID",(t,e)=>{e.pattern??(e.pattern=Ap),Q.init(t,e)}),jf=S("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=Mp),Q.init(t,e)}),Uf=S("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=Xp(e)),Q.init(t,e)}),Ff=S("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=Gp),Q.init(t,e)}),Zf=S("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=Yp(e)),Q.init(t,e)}),qf=S("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=Dp),Q.init(t,e)}),Hf=S("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=Fp),Q.init(t,e),t._zod.bag.format="ipv4"}),Wf=S("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=Zp),Q.init(t,e),t._zod.bag.format="ipv6",t._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:t,continue:!e.abort})}}});var Vf=S("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=qp),Q.init(t,e)}),Kf=S("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=Hp),Q.init(t,e),t._zod.check=r=>{let n=r.value.split("/");try{if(n.length!==2)throw new Error;let[o,s]=n;if(!s)throw new Error;let i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${o}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:t,continue:!e.abort})}}});function Jf(t){if(t==="")return!0;if(/\s/.test(t)||t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}var Gf=S("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=Wp),Q.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=r=>{Jf(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function Gw(t){if(!na.test(t))return!1;let e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return Jf(r)}var Bf=S("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=na),Q.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=r=>{Gw(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),Yf=S("$ZodE164",(t,e)=>{e.pattern??(e.pattern=Kp),Q.init(t,e)});function Bw(t,e=null){try{let r=t.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||e&&(!("alg"in o)||o.alg!==e))}catch{return!1}}var Xf=S("$ZodJWT",(t,e)=>{Q.init(t,e),t._zod.check=r=>{Bw(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}});var ca=S("$ZodNumber",(t,e)=>{X.init(t,e),t._zod.pattern=t._zod.bag.pattern??oa,t._zod.parse=(r,n)=>{if(e.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:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:t,...s?{received:s}:{}}),r}}),Qf=S("$ZodNumberFormat",(t,e)=>{cf.init(t,e),ca.init(t,e)}),em=S("$ZodBoolean",(t,e)=>{X.init(t,e),t._zod.pattern=tf,t._zod.parse=(r,n)=>{if(e.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:t}),r}});var tm=S("$ZodNull",(t,e)=>{X.init(t,e),t._zod.pattern=rf,t._zod.values=new Set([null]),t._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:t}),r}});var rm=S("$ZodUnknown",(t,e)=>{X.init(t,e),t._zod.parse=r=>r}),nm=S("$ZodNever",(t,e)=>{X.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function Ef(t,e,r){t.issues.length&&e.issues.push(...kt(r,t.issues)),e.value[r]=t.value}var om=S("$ZodArray",(t,e)=>{X.init(t,e),t._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:t}),r;r.value=Array(o.length);let s=[];for(let i=0;i<o.length;i++){let a=o[i],c=e.element._zod.run({value:a,issues:[]},n);c instanceof Promise?s.push(c.then(u=>Ef(u,r,i))):Ef(c,r,i)}return s.length?Promise.all(s).then(()=>r):r}});function Ko(t,e,r,n,o,s){let i=r in n;if(t.issues.length){if(o&&s&&!i)return;e.issues.push(...kt(r,t.issues))}if(!i&&!o){t.issues.length||e.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}t.value===void 0?i&&(e.value[r]=void 0):e.value[r]=t.value}function sm(t){let e=Object.keys(t.shape);for(let n of e)if(!t.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=Yi(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(r)}}function im(t,e,r,n,o,s){let i=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,l=c.optin==="optional",d=c.optout==="optional";for(let p in e){if(p==="__proto__"||a.has(p))continue;if(u==="never"){i.push(p);continue}let m=c.run({value:e[p],issues:[]},n);m instanceof Promise?t.push(m.then(h=>Ko(h,r,p,e,l,d))):Ko(m,r,p,e,l,d)}return i.length&&r.issues.push({code:"unrecognized_keys",keys:i,input:e,inst:s}),t.length?Promise.all(t).then(()=>r):r}var Yw=S("$ZodObject",(t,e)=>{if(X.init(t,e),!Object.getOwnPropertyDescriptor(e,"shape")?.get){let a=e.shape;Object.defineProperty(e,"shape",{get:()=>{let c={...a};return Object.defineProperty(e,"shape",{value:c}),c}})}let n=Tr(()=>sm(e));V(t._zod,"propValues",()=>{let a=e.shape,c={};for(let u in a){let l=a[u]._zod;if(l.values){c[u]??(c[u]=new Set);for(let d of l.values)c[u].add(d)}}return c});let o=rr,s=e.catchall,i;t._zod.parse=(a,c)=>{i??(i=n.value);let u=a.value;if(!o(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:t}),a;a.value={};let l=[],d=i.shape;for(let p of i.keys){let m=d[p],h=m._zod.optin==="optional",y=m._zod.optout==="optional",g=m._zod.run({value:u[p],issues:[]},c);g instanceof Promise?l.push(g.then(v=>Ko(v,a,p,u,h,y))):Ko(g,a,p,u,h,y)}return s?im(l,u,a,c,n.value,t):l.length?Promise.all(l).then(()=>a):a}}),am=S("$ZodObjectJIT",(t,e)=>{Yw.init(t,e);let r=t._zod.parse,n=Tr(()=>sm(e)),o=p=>{let m=new Wo(["shape","payload","ctx"]),h=n.value,y=w=>{let $=Do(w);return`shape[${$}]._zod.run({ value: input[${$}], issues: [] }, ctx)`};m.write("const input = payload.value;");let g=Object.create(null),v=0;for(let w of h.keys)g[w]=`key_${v++}`;m.write("const newResult = {};");for(let w of h.keys){let $=g[w],x=Do(w),je=p[w],We=je?._zod?.optin==="optional",sn=je?._zod?.optout==="optional";m.write(`const ${$} = ${y(w)};`),We&&sn?m.write(`
|
|
26
26
|
if (${$}.issues.length) {
|
|
27
27
|
if (${x} in input) {
|
|
28
28
|
payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
|
|
@@ -81,9 +81,9 @@ ${s.stack}`:` ${s.message}`;else if(this.getLevel()===0&&typeof s=="object")try{
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
`)}m.write("payload.value = newResult;"),m.write("return payload;");let b=m.compile();return(w,$)=>b(p,w,$)},s,i=rr,a=!$r.jitless,u=a&&Gi.value,l=e.catchall,d;t._zod.parse=(p,m)=>{d??(d=n.value);let h=p.value;return i(h)?a&&u&&m?.async===!1&&m.jitless!==!0?(s||(s=o(e.shape)),p=s(p,m),l?im([],h,p,m,d,t):p):r(p,m):(p.issues.push({expected:"object",code:"invalid_type",input:h,inst:t}),p)}});function wf(t,e,r,n){for(let s of t)if(s.issues.length===0)return e.value=s.value,e;let o=t.filter(s=>!Nt(s));return o.length===1?(e.value=o[0].value,o[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(s=>s.issues.map(i=>Je(i,n,Ze())))}),e)}var ua=S("$ZodUnion",(t,e)=>{X.init(t,e),K(t._zod,"optin",()=>e.options.some(n=>n._zod.optin==="optional")?"optional":void 0),K(t._zod,"optout",()=>e.options.some(n=>n._zod.optout==="optional")?"optional":void 0),K(t._zod,"values",()=>{if(e.options.every(n=>n._zod.values))return new Set(e.options.flatMap(n=>Array.from(n._zod.values)))}),K(t._zod,"pattern",()=>{if(e.options.every(n=>n._zod.pattern)){let n=e.options.map(o=>o._zod.pattern);return new RegExp(`^(${n.map(o=>Sn(o.source)).join("|")})$`)}});let r=e.options.length===1?e.options[0]._zod.run:null;t._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let a of e.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=>wf(a,n,t,o)):wf(i,n,t,o)}});var cm=S("$ZodDiscriminatedUnion",(t,e)=>{e.inclusive=!1,ua.init(t,e);let r=t._zod.parse;K(t._zod,"propValues",()=>{let o={};for(let s of e.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(let[a,c]of Object.entries(i)){o[a]||(o[a]=new Set);for(let u of c)o[a].add(u)}}return o});let n=Tr(()=>{let o=e.options,s=new Map;for(let i of o){let a=i._zod.propValues?.[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);for(let c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});t._zod.parse=(o,s)=>{let i=o.value;if(!rr(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:t}),o;let a=n.value.get(i?.[e.discriminator]);return a?a._zod.run(o,s):e.unionFallback||s.direction==="backward"?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,options:Array.from(n.value.keys()),input:i,path:[e.discriminator],inst:t}),o)}}),um=S("$ZodIntersection",(t,e)=>{X.init(t,e),t._zod.parse=(r,n)=>{let o=r.value,s=e.left._zod.run({value:o,issues:[]},n),i=e.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>bf(r,c,u)):bf(r,s,i)}});function aa(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(Mt(t)&&Mt(e)){let r=Object.keys(e),n=Object.keys(t).filter(s=>r.indexOf(s)!==-1),o={...t,...e};for(let s of n){let i=aa(t[s],e[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<t.length;n++){let o=t[n],s=e[n],i=aa(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 bf(t,e,r){let n=new Map,o;for(let a of e.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(let c of a.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else t.issues.push(a);for(let a of r.issues)if(a.code==="unrecognized_keys")for(let c of a.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else t.issues.push(a);let s=[...n].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&o&&t.issues.push({...o,keys:s}),Nt(t))return t;let i=aa(e.value,r.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return t.value=i.data,t}var lm=S("$ZodRecord",(t,e)=>{X.init(t,e),t._zod.parse=(r,n)=>{let o=r.value;if(!Mt(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:t}),r;let s=[],i=e.keyType._zod.values;if(i){r.value={};let a=new Set;for(let u of i)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);let l=e.keyType._zod.run({value:u,issues:[]},n);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(l.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(m=>Je(m,n,Ze())),input:u,path:[u],inst:t});continue}let d=l.value,p=e.valueType._zod.run({value:o[u],issues:[]},n);p instanceof Promise?s.push(p.then(m=>{m.issues.length&&r.issues.push(...kt(u,m.issues)),r.value[d]=m.value})):(p.issues.length&&r.issues.push(...kt(u,p.issues)),r.value[d]=p.value)}let c;for(let u in o)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:t,keys:c})}else{r.value={};for(let a of Reflect.ownKeys(o)){if(a==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,a))continue;let c=e.keyType._zod.run({value:a,issues:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&oa.test(a)&&c.issues.length){let d=e.keyType._zod.run({value:Number(a),issues:[]},n);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(c=d)}if(c.issues.length){e.mode==="loose"?r.value[a]=o[a]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(d=>Je(d,n,Ze())),input:a,path:[a],inst:t});continue}let l=e.valueType._zod.run({value:o[a],issues:[]},n);l instanceof Promise?s.push(l.then(d=>{d.issues.length&&r.issues.push(...kt(a,d.issues)),r.value[c.value]=d.value})):(l.issues.length&&r.issues.push(...kt(a,l.issues)),r.value[c.value]=l.value)}}return s.length?Promise.all(s).then(()=>r):r}});var dm=S("$ZodEnum",(t,e)=>{X.init(t,e);let r=_n(e.entries),n=new Set(r);t._zod.values=n,t._zod.pattern=new RegExp(`^(${r.filter(o=>Bi.has(typeof o)).map(o=>typeof o=="string"?bt(o):o.toString()).join("|")})$`),t._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:t}),o}}),pm=S("$ZodLiteral",(t,e)=>{if(X.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(e.values);t._zod.values=r,t._zod.pattern=new RegExp(`^(${e.values.map(n=>typeof n=="string"?bt(n):n?bt(n.toString()):String(n)).join("|")})$`),t._zod.parse=(n,o)=>{let s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:e.values,input:s,inst:t}),n}});var fm=S("$ZodTransform",(t,e)=>{X.init(t,e),t._zod.optin="optional",t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new xr(t.constructor.name);let o=e.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r.fallback=!0,r));if(o instanceof Promise)throw new mt;return r.value=o,r.fallback=!0,r}});function kf(t,e){return e===void 0&&(t.issues.length||t.fallback)?{issues:[],value:void 0}:t}var la=S("$ZodOptional",(t,e)=>{X.init(t,e),t._zod.optin="optional",t._zod.optout="optional",K(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),K(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Sn(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>{if(e.innerType._zod.optin==="optional"){let o=r.value,s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>kf(i,o)):kf(s,o)}return r.value===void 0?r:e.innerType._zod.run(r,n)}}),mm=S("$ZodExactOptional",(t,e)=>{la.init(t,e),K(t._zod,"values",()=>e.innerType._zod.values),K(t._zod,"pattern",()=>e.innerType._zod.pattern),t._zod.parse=(r,n)=>e.innerType._zod.run(r,n)}),hm=S("$ZodNullable",(t,e)=>{X.init(t,e),K(t._zod,"optin",()=>e.innerType._zod.optin),K(t._zod,"optout",()=>e.innerType._zod.optout),K(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Sn(r.source)}|null)$`):void 0}),K(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)}),gm=S("$ZodDefault",(t,e)=>{X.init(t,e),t._zod.optin="optional",K(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);if(r.value===void 0)return r.value=e.defaultValue,r;let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>xf(s,e)):xf(o,e)}});function xf(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}var _m=S("$ZodPrefault",(t,e)=>{X.init(t,e),t._zod.optin="optional",K(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,n))}),ym=S("$ZodNonOptional",(t,e)=>{X.init(t,e),K(t._zod,"values",()=>{let r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>$f(s,t)):$f(o,t)}});function $f(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}var Sm=S("$ZodCatch",(t,e)=>{X.init(t,e),t._zod.optin="optional",K(t._zod,"optout",()=>e.innerType._zod.optout),K(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(i=>Je(i,n,Ze()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=o.value,o.issues.length&&(r.value=e.catchValue({...r,error:{issues:o.issues.map(s=>Je(s,n,Ze()))},input:r.value}),r.issues=[],r.fallback=!0),r)}});var da=S("$ZodPipe",(t,e)=>{X.init(t,e),K(t._zod,"values",()=>e.in._zod.values),K(t._zod,"optin",()=>e.in._zod.optin),K(t._zod,"optout",()=>e.out._zod.optout),K(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=e.out._zod.run(r,n);return s instanceof Promise?s.then(i=>Ko(i,e.in,n)):Ko(s,e.in,n)}let o=e.in._zod.run(r,n);return o instanceof Promise?o.then(s=>Ko(s,e.out,n)):Ko(o,e.out,n)}});function Ko(t,e,r){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues,fallback:t.fallback},r)}var vm=S("$ZodPreprocess",(t,e)=>{da.init(t,e)}),Em=S("$ZodReadonly",(t,e)=>{X.init(t,e),K(t._zod,"propValues",()=>e.innerType._zod.propValues),K(t._zod,"values",()=>e.innerType._zod.values),K(t._zod,"optin",()=>e.innerType?._zod?.optin),K(t._zod,"optout",()=>e.innerType?._zod?.optout),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(Pf):Pf(o)}});function Pf(t){return t.value=Object.freeze(t.value),t}var wm=S("$ZodCustom",(t,e)=>{ge.init(t,e),X.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{let n=r.value,o=e.fn(n);if(o instanceof Promise)return o.then(s=>Tf(s,r,n,t));Tf(o,r,n,t)}});function Tf(t,e,r,n){if(!t){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),e.issues.push(Or(o))}}var Xw=()=>{let t={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 e(o){return t[o]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};return o=>{switch(o.code){case"invalid_type":{let s=n[o.expected]??o.expected,i=ea(o.input),a=n[i]??i;return`Invalid input: expected ${s}, received ${a}`}case"invalid_value":return o.values.length===1?`Invalid input: expected ${jo(o.values[0])}`:`Invalid option: expected one of ${No(o.values,"|")}`;case"too_big":{let s=o.inclusive?"<=":"<",i=e(o.origin);return i?`Too big: expected ${o.origin??"value"} to have ${s}${o.maximum.toString()} ${i.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${s}${o.maximum.toString()}`}case"too_small":{let s=o.inclusive?">=":">",i=e(o.origin);return i?`Too small: expected ${o.origin} to have ${s}${o.minimum.toString()} ${i.unit}`:`Too small: expected ${o.origin} to be ${s}${o.minimum.toString()}`}case"invalid_format":{let s=o;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${r[s.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${No(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return o.options&&Array.isArray(o.options)&&o.options.length>0?`Invalid discriminator value. Expected ${o.options.map(i=>`'${i}'`).join(" | ")}`:"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function bm(){return{localeError:Xw()}}var km;var pa=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...r){let n=r[0];return this._map.set(e,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){let r=e._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let o={...n,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Qw(){return new pa}(km=globalThis).__zod_globalRegistry??(km.__zod_globalRegistry=Qw());var nr=globalThis.__zod_globalRegistry;function xm(t,e){return new t({type:"string",...z(e)})}function $m(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...z(e)})}function fa(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...z(e)})}function Pm(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...z(e)})}function Tm(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...z(e)})}function Om(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...z(e)})}function zm(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...z(e)})}function Rm(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...z(e)})}function Im(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...z(e)})}function Cm(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...z(e)})}function Am(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...z(e)})}function Mm(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...z(e)})}function Nm(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...z(e)})}function Dm(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...z(e)})}function Lm(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...z(e)})}function jm(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...z(e)})}function Um(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...z(e)})}function Fm(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...z(e)})}function Zm(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...z(e)})}function qm(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...z(e)})}function Hm(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...z(e)})}function Wm(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...z(e)})}function Km(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...z(e)})}function Vm(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...z(e)})}function Jm(t,e){return new t({type:"string",format:"date",check:"string_format",...z(e)})}function Gm(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...z(e)})}function Bm(t,e){return new t({type:"string",format:"duration",check:"string_format",...z(e)})}function Ym(t,e){return new t({type:"number",checks:[],...z(e)})}function Xm(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...z(e)})}function Qm(t,e){return new t({type:"boolean",...z(e)})}function eh(t,e){return new t({type:"null",...z(e)})}function th(t){return new t({type:"unknown"})}function rh(t,e){return new t({type:"never",...z(e)})}function Go(t,e){return new sa({check:"less_than",...z(e),value:t,inclusive:!1})}function xn(t,e){return new sa({check:"less_than",...z(e),value:t,inclusive:!0})}function Bo(t,e){return new ia({check:"greater_than",...z(e),value:t,inclusive:!1})}function $n(t,e){return new ia({check:"greater_than",...z(e),value:t,inclusive:!0})}function Yo(t,e){return new af({check:"multiple_of",...z(e),value:t})}function Xo(t,e){return new uf({check:"max_length",...z(e),maximum:t})}function zr(t,e){return new lf({check:"min_length",...z(e),minimum:t})}function Qo(t,e){return new df({check:"length_equals",...z(e),length:t})}function ma(t,e){return new pf({check:"string_format",format:"regex",...z(e),pattern:t})}function ha(t){return new ff({check:"string_format",format:"lowercase",...z(t)})}function ga(t){return new mf({check:"string_format",format:"uppercase",...z(t)})}function _a(t,e){return new hf({check:"string_format",format:"includes",...z(e),includes:t})}function ya(t,e){return new gf({check:"string_format",format:"starts_with",...z(e),prefix:t})}function Sa(t,e){return new _f({check:"string_format",format:"ends_with",...z(e),suffix:t})}function Dt(t){return new yf({check:"overwrite",tx:t})}function va(t){return Dt(e=>e.normalize(t))}function Ea(){return Dt(t=>t.trim())}function wa(){return Dt(t=>t.toLowerCase())}function ba(){return Dt(t=>t.toUpperCase())}function ka(){return Dt(t=>Ji(t))}function nh(t,e,r){return new t({type:"array",element:e,...z(r)})}function oh(t,e,r){let n=z(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function sh(t,e,r){return new t({type:"custom",check:"custom",fn:e,...z(r)})}function ih(t,e){let r=eb(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(Or(o,n.value,r._zod.def));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(Or(s))}},t(n.value,n)),e);return r}function eb(t,e){let r=new ge({check:"custom",...z(e)});return r._zod.check=t,r}function xa(t){let e=t?.target??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:t?.metadata??nr,target:e,unrepresentable:t?.unrepresentable??"throw",override:t?.override??(()=>{}),io:t?.io??"output",counter:0,seen:new Map,cycles:t?.cycles??"ref",reused:t?.reused??"inline",external:t?.external??void 0}}function ae(t,e,r={path:[],schemaPath:[]}){var n;let o=t._zod.def,s=e.seen.get(t);if(s)return s.count++,r.schemaPath.includes(t)&&(s.cycle=r.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:r.path};e.seen.set(t,i);let a=t._zod.toJSONSchema?.();if(a)i.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,t],path:r.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,i.schema,l);else{let p=i.schema,m=e.processors[o.type];if(!m)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);m(t,e,p,l)}let d=t._zod.parent;d&&(i.ref||(i.ref=d),ae(d,e,l),e.seen.get(d).isParent=!0)}let c=e.metadataRegistry.get(t);return c&&Object.assign(i.schema,c),e.io==="input"&&Te(t)&&(delete i.schema.examples,delete i.schema.default),e.io==="input"&&"_prefault"in i.schema&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,e.seen.get(t).schema}function $a(t,e){let r=t.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=new Map;for(let i of t.seen.entries()){let a=t.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=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){let d=t.external.registry.get(i[0])?.id,p=t.external.uri??(h=>h);if(d)return{ref:p(d)};let m=i[1].defId??i[1].schema.id??`schema${t.counter++}`;return i[1].defId=m,{defId:m,ref:`${p("__shared")}#/${a}/${m}`}}if(i[1]===r)return{ref:"#"};let u=`#/${a}/`,l=i[1].schema.id??`__schema${t.counter++}`;return{defId:l,ref:u+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(t.cycles==="throw")for(let i of t.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
84
|
+
`)}m.write("payload.value = newResult;"),m.write("return payload;");let b=m.compile();return(w,$)=>b(p,w,$)},s,i=rr,a=!$r.jitless,u=a&&Gi.value,l=e.catchall,d;t._zod.parse=(p,m)=>{d??(d=n.value);let h=p.value;return i(h)?a&&u&&m?.async===!1&&m.jitless!==!0?(s||(s=o(e.shape)),p=s(p,m),l?im([],h,p,m,d,t):p):r(p,m):(p.issues.push({expected:"object",code:"invalid_type",input:h,inst:t}),p)}});function wf(t,e,r,n){for(let s of t)if(s.issues.length===0)return e.value=s.value,e;let o=t.filter(s=>!Nt(s));return o.length===1?(e.value=o[0].value,o[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(s=>s.issues.map(i=>Je(i,n,Ze())))}),e)}var ua=S("$ZodUnion",(t,e)=>{X.init(t,e),V(t._zod,"optin",()=>e.options.some(n=>n._zod.optin==="optional")?"optional":void 0),V(t._zod,"optout",()=>e.options.some(n=>n._zod.optout==="optional")?"optional":void 0),V(t._zod,"values",()=>{if(e.options.every(n=>n._zod.values))return new Set(e.options.flatMap(n=>Array.from(n._zod.values)))}),V(t._zod,"pattern",()=>{if(e.options.every(n=>n._zod.pattern)){let n=e.options.map(o=>o._zod.pattern);return new RegExp(`^(${n.map(o=>Sn(o.source)).join("|")})$`)}});let r=e.options.length===1?e.options[0]._zod.run:null;t._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let a of e.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=>wf(a,n,t,o)):wf(i,n,t,o)}});var cm=S("$ZodDiscriminatedUnion",(t,e)=>{e.inclusive=!1,ua.init(t,e);let r=t._zod.parse;V(t._zod,"propValues",()=>{let o={};for(let s of e.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(let[a,c]of Object.entries(i)){o[a]||(o[a]=new Set);for(let u of c)o[a].add(u)}}return o});let n=Tr(()=>{let o=e.options,s=new Map;for(let i of o){let a=i._zod.propValues?.[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);for(let c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});t._zod.parse=(o,s)=>{let i=o.value;if(!rr(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:t}),o;let a=n.value.get(i?.[e.discriminator]);return a?a._zod.run(o,s):e.unionFallback||s.direction==="backward"?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,options:Array.from(n.value.keys()),input:i,path:[e.discriminator],inst:t}),o)}}),um=S("$ZodIntersection",(t,e)=>{X.init(t,e),t._zod.parse=(r,n)=>{let o=r.value,s=e.left._zod.run({value:o,issues:[]},n),i=e.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>bf(r,c,u)):bf(r,s,i)}});function aa(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(Mt(t)&&Mt(e)){let r=Object.keys(e),n=Object.keys(t).filter(s=>r.indexOf(s)!==-1),o={...t,...e};for(let s of n){let i=aa(t[s],e[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<t.length;n++){let o=t[n],s=e[n],i=aa(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 bf(t,e,r){let n=new Map,o;for(let a of e.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(let c of a.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else t.issues.push(a);for(let a of r.issues)if(a.code==="unrecognized_keys")for(let c of a.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else t.issues.push(a);let s=[...n].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&o&&t.issues.push({...o,keys:s}),Nt(t))return t;let i=aa(e.value,r.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return t.value=i.data,t}var lm=S("$ZodRecord",(t,e)=>{X.init(t,e),t._zod.parse=(r,n)=>{let o=r.value;if(!Mt(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:t}),r;let s=[],i=e.keyType._zod.values;if(i){r.value={};let a=new Set;for(let u of i)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);let l=e.keyType._zod.run({value:u,issues:[]},n);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(l.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(m=>Je(m,n,Ze())),input:u,path:[u],inst:t});continue}let d=l.value,p=e.valueType._zod.run({value:o[u],issues:[]},n);p instanceof Promise?s.push(p.then(m=>{m.issues.length&&r.issues.push(...kt(u,m.issues)),r.value[d]=m.value})):(p.issues.length&&r.issues.push(...kt(u,p.issues)),r.value[d]=p.value)}let c;for(let u in o)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:t,keys:c})}else{r.value={};for(let a of Reflect.ownKeys(o)){if(a==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,a))continue;let c=e.keyType._zod.run({value:a,issues:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&oa.test(a)&&c.issues.length){let d=e.keyType._zod.run({value:Number(a),issues:[]},n);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(c=d)}if(c.issues.length){e.mode==="loose"?r.value[a]=o[a]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(d=>Je(d,n,Ze())),input:a,path:[a],inst:t});continue}let l=e.valueType._zod.run({value:o[a],issues:[]},n);l instanceof Promise?s.push(l.then(d=>{d.issues.length&&r.issues.push(...kt(a,d.issues)),r.value[c.value]=d.value})):(l.issues.length&&r.issues.push(...kt(a,l.issues)),r.value[c.value]=l.value)}}return s.length?Promise.all(s).then(()=>r):r}});var dm=S("$ZodEnum",(t,e)=>{X.init(t,e);let r=_n(e.entries),n=new Set(r);t._zod.values=n,t._zod.pattern=new RegExp(`^(${r.filter(o=>Bi.has(typeof o)).map(o=>typeof o=="string"?bt(o):o.toString()).join("|")})$`),t._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:t}),o}}),pm=S("$ZodLiteral",(t,e)=>{if(X.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(e.values);t._zod.values=r,t._zod.pattern=new RegExp(`^(${e.values.map(n=>typeof n=="string"?bt(n):n?bt(n.toString()):String(n)).join("|")})$`),t._zod.parse=(n,o)=>{let s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:e.values,input:s,inst:t}),n}});var fm=S("$ZodTransform",(t,e)=>{X.init(t,e),t._zod.optin="optional",t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new xr(t.constructor.name);let o=e.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r.fallback=!0,r));if(o instanceof Promise)throw new mt;return r.value=o,r.fallback=!0,r}});function kf(t,e){return e===void 0&&(t.issues.length||t.fallback)?{issues:[],value:void 0}:t}var la=S("$ZodOptional",(t,e)=>{X.init(t,e),t._zod.optin="optional",t._zod.optout="optional",V(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),V(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Sn(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>{if(e.innerType._zod.optin==="optional"){let o=r.value,s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>kf(i,o)):kf(s,o)}return r.value===void 0?r:e.innerType._zod.run(r,n)}}),mm=S("$ZodExactOptional",(t,e)=>{la.init(t,e),V(t._zod,"values",()=>e.innerType._zod.values),V(t._zod,"pattern",()=>e.innerType._zod.pattern),t._zod.parse=(r,n)=>e.innerType._zod.run(r,n)}),hm=S("$ZodNullable",(t,e)=>{X.init(t,e),V(t._zod,"optin",()=>e.innerType._zod.optin),V(t._zod,"optout",()=>e.innerType._zod.optout),V(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Sn(r.source)}|null)$`):void 0}),V(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)}),gm=S("$ZodDefault",(t,e)=>{X.init(t,e),t._zod.optin="optional",V(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);if(r.value===void 0)return r.value=e.defaultValue,r;let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>xf(s,e)):xf(o,e)}});function xf(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}var _m=S("$ZodPrefault",(t,e)=>{X.init(t,e),t._zod.optin="optional",V(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,n))}),ym=S("$ZodNonOptional",(t,e)=>{X.init(t,e),V(t._zod,"values",()=>{let r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>$f(s,t)):$f(o,t)}});function $f(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}var Sm=S("$ZodCatch",(t,e)=>{X.init(t,e),t._zod.optin="optional",V(t._zod,"optout",()=>e.innerType._zod.optout),V(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(i=>Je(i,n,Ze()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=o.value,o.issues.length&&(r.value=e.catchValue({...r,error:{issues:o.issues.map(s=>Je(s,n,Ze()))},input:r.value}),r.issues=[],r.fallback=!0),r)}});var da=S("$ZodPipe",(t,e)=>{X.init(t,e),V(t._zod,"values",()=>e.in._zod.values),V(t._zod,"optin",()=>e.in._zod.optin),V(t._zod,"optout",()=>e.out._zod.optout),V(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=e.out._zod.run(r,n);return s instanceof Promise?s.then(i=>Vo(i,e.in,n)):Vo(s,e.in,n)}let o=e.in._zod.run(r,n);return o instanceof Promise?o.then(s=>Vo(s,e.out,n)):Vo(o,e.out,n)}});function Vo(t,e,r){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues,fallback:t.fallback},r)}var vm=S("$ZodPreprocess",(t,e)=>{da.init(t,e)}),Em=S("$ZodReadonly",(t,e)=>{X.init(t,e),V(t._zod,"propValues",()=>e.innerType._zod.propValues),V(t._zod,"values",()=>e.innerType._zod.values),V(t._zod,"optin",()=>e.innerType?._zod?.optin),V(t._zod,"optout",()=>e.innerType?._zod?.optout),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(Pf):Pf(o)}});function Pf(t){return t.value=Object.freeze(t.value),t}var wm=S("$ZodCustom",(t,e)=>{ge.init(t,e),X.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{let n=r.value,o=e.fn(n);if(o instanceof Promise)return o.then(s=>Tf(s,r,n,t));Tf(o,r,n,t)}});function Tf(t,e,r,n){if(!t){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),e.issues.push(Or(o))}}var Xw=()=>{let t={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 e(o){return t[o]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};return o=>{switch(o.code){case"invalid_type":{let s=n[o.expected]??o.expected,i=ea(o.input),a=n[i]??i;return`Invalid input: expected ${s}, received ${a}`}case"invalid_value":return o.values.length===1?`Invalid input: expected ${jo(o.values[0])}`:`Invalid option: expected one of ${No(o.values,"|")}`;case"too_big":{let s=o.inclusive?"<=":"<",i=e(o.origin);return i?`Too big: expected ${o.origin??"value"} to have ${s}${o.maximum.toString()} ${i.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${s}${o.maximum.toString()}`}case"too_small":{let s=o.inclusive?">=":">",i=e(o.origin);return i?`Too small: expected ${o.origin} to have ${s}${o.minimum.toString()} ${i.unit}`:`Too small: expected ${o.origin} to be ${s}${o.minimum.toString()}`}case"invalid_format":{let s=o;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${r[s.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${No(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return o.options&&Array.isArray(o.options)&&o.options.length>0?`Invalid discriminator value. Expected ${o.options.map(i=>`'${i}'`).join(" | ")}`:"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function bm(){return{localeError:Xw()}}var km;var pa=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...r){let n=r[0];return this._map.set(e,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){let r=e._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let o={...n,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Qw(){return new pa}(km=globalThis).__zod_globalRegistry??(km.__zod_globalRegistry=Qw());var nr=globalThis.__zod_globalRegistry;function xm(t,e){return new t({type:"string",...z(e)})}function $m(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...z(e)})}function fa(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...z(e)})}function Pm(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...z(e)})}function Tm(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...z(e)})}function Om(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...z(e)})}function zm(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...z(e)})}function Rm(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...z(e)})}function Im(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...z(e)})}function Cm(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...z(e)})}function Am(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...z(e)})}function Mm(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...z(e)})}function Nm(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...z(e)})}function Dm(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...z(e)})}function Lm(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...z(e)})}function jm(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...z(e)})}function Um(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...z(e)})}function Fm(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...z(e)})}function Zm(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...z(e)})}function qm(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...z(e)})}function Hm(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...z(e)})}function Wm(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...z(e)})}function Vm(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...z(e)})}function Km(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...z(e)})}function Jm(t,e){return new t({type:"string",format:"date",check:"string_format",...z(e)})}function Gm(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...z(e)})}function Bm(t,e){return new t({type:"string",format:"duration",check:"string_format",...z(e)})}function Ym(t,e){return new t({type:"number",checks:[],...z(e)})}function Xm(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...z(e)})}function Qm(t,e){return new t({type:"boolean",...z(e)})}function eh(t,e){return new t({type:"null",...z(e)})}function th(t){return new t({type:"unknown"})}function rh(t,e){return new t({type:"never",...z(e)})}function Go(t,e){return new sa({check:"less_than",...z(e),value:t,inclusive:!1})}function xn(t,e){return new sa({check:"less_than",...z(e),value:t,inclusive:!0})}function Bo(t,e){return new ia({check:"greater_than",...z(e),value:t,inclusive:!1})}function $n(t,e){return new ia({check:"greater_than",...z(e),value:t,inclusive:!0})}function Yo(t,e){return new af({check:"multiple_of",...z(e),value:t})}function Xo(t,e){return new uf({check:"max_length",...z(e),maximum:t})}function zr(t,e){return new lf({check:"min_length",...z(e),minimum:t})}function Qo(t,e){return new df({check:"length_equals",...z(e),length:t})}function ma(t,e){return new pf({check:"string_format",format:"regex",...z(e),pattern:t})}function ha(t){return new ff({check:"string_format",format:"lowercase",...z(t)})}function ga(t){return new mf({check:"string_format",format:"uppercase",...z(t)})}function _a(t,e){return new hf({check:"string_format",format:"includes",...z(e),includes:t})}function ya(t,e){return new gf({check:"string_format",format:"starts_with",...z(e),prefix:t})}function Sa(t,e){return new _f({check:"string_format",format:"ends_with",...z(e),suffix:t})}function Dt(t){return new yf({check:"overwrite",tx:t})}function va(t){return Dt(e=>e.normalize(t))}function Ea(){return Dt(t=>t.trim())}function wa(){return Dt(t=>t.toLowerCase())}function ba(){return Dt(t=>t.toUpperCase())}function ka(){return Dt(t=>Ji(t))}function nh(t,e,r){return new t({type:"array",element:e,...z(r)})}function oh(t,e,r){let n=z(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function sh(t,e,r){return new t({type:"custom",check:"custom",fn:e,...z(r)})}function ih(t,e){let r=eb(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(Or(o,n.value,r._zod.def));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(Or(s))}},t(n.value,n)),e);return r}function eb(t,e){let r=new ge({check:"custom",...z(e)});return r._zod.check=t,r}function xa(t){let e=t?.target??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:t?.metadata??nr,target:e,unrepresentable:t?.unrepresentable??"throw",override:t?.override??(()=>{}),io:t?.io??"output",counter:0,seen:new Map,cycles:t?.cycles??"ref",reused:t?.reused??"inline",external:t?.external??void 0}}function ae(t,e,r={path:[],schemaPath:[]}){var n;let o=t._zod.def,s=e.seen.get(t);if(s)return s.count++,r.schemaPath.includes(t)&&(s.cycle=r.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:r.path};e.seen.set(t,i);let a=t._zod.toJSONSchema?.();if(a)i.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,t],path:r.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,i.schema,l);else{let p=i.schema,m=e.processors[o.type];if(!m)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);m(t,e,p,l)}let d=t._zod.parent;d&&(i.ref||(i.ref=d),ae(d,e,l),e.seen.get(d).isParent=!0)}let c=e.metadataRegistry.get(t);return c&&Object.assign(i.schema,c),e.io==="input"&&Te(t)&&(delete i.schema.examples,delete i.schema.default),e.io==="input"&&"_prefault"in i.schema&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,e.seen.get(t).schema}function $a(t,e){let r=t.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=new Map;for(let i of t.seen.entries()){let a=t.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=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){let d=t.external.registry.get(i[0])?.id,p=t.external.uri??(h=>h);if(d)return{ref:p(d)};let m=i[1].defId??i[1].schema.id??`schema${t.counter++}`;return i[1].defId=m,{defId:m,ref:`${p("__shared")}#/${a}/${m}`}}if(i[1]===r)return{ref:"#"};let u=`#/${a}/`,l=i[1].schema.id??`__schema${t.counter++}`;return{defId:l,ref:u+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(t.cycles==="throw")for(let i of t.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
85
85
|
|
|
86
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of t.seen.entries()){let a=i[1];if(e===i[0]){s(i);continue}if(t.external){let u=t.external.registry.get(i[0])?.id;if(e!==i[0]&&u){s(i);continue}}if(t.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}if(a.count>1&&t.reused==="ref"){s(i);continue}}}function Pa(t,e){let r=t.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=t.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 m=t.seen.get(d),h=m.schema;if(h.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(h)):Object.assign(u,h),Object.assign(u,l),a._zod.parent===d)for(let g in u)g==="$ref"||g==="allOf"||g in l||delete u[g];if(h.$ref&&m.def)for(let g in u)g==="$ref"||g==="allOf"||g in m.def&&JSON.stringify(u[g])===JSON.stringify(m.def[g])&&delete u[g]}let p=a._zod.parent;if(p&&p!==d){n(p);let m=t.seen.get(p);if(m?.schema.$ref&&(u.$ref=m.schema.$ref,m.def))for(let h in u)h==="$ref"||h==="allOf"||h in m.def&&JSON.stringify(u[h])===JSON.stringify(m.def[h])&&delete u[h]}t.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(let a of[...t.seen.entries()].reverse())n(a[0]);let o={};if(t.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){let a=t.external.registry.get(e)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=t.external.uri(a)}Object.assign(o,r.def??r.schema);let s=t.metadataRegistry.get(e)?.id;s!==void 0&&o.id===s&&delete o.id;let i=t.external?.defs??{};for(let a of t.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,i[c.defId]=c.def)}t.external||Object.keys(i).length>0&&(t.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...e["~standard"],jsonSchema:{input:Pn(e,"input",t.processors),output:Pn(e,"output",t.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Te(t,e){let r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);let n=t._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Te(n.element,r);if(n.type==="set")return Te(n.valueType,r);if(n.type==="lazy")return Te(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return Te(n.innerType,r);if(n.type==="intersection")return Te(n.left,r)||Te(n.right,r);if(n.type==="record"||n.type==="map")return Te(n.keyType,r)||Te(n.valueType,r);if(n.type==="pipe")return t._zod.traits.has("$ZodCodec")?!0:Te(n.in,r)||Te(n.out,r);if(n.type==="object"){for(let o in n.shape)if(Te(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(Te(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(Te(o,r))return!0;return!!(n.rest&&Te(n.rest,r))}return!1}var ah=(t,e={})=>r=>{let n=xa({...r,processors:e});return ae(t,n),$a(n,t),Pa(n,t)},Pn=(t,e,r={})=>n=>{let{libraryOptions:o,target:s}=n??{},i=xa({...o??{},target:s,io:e,processors:r});return ae(t,i),$a(i,t),Pa(i,t)};var tb={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ch=(t,e,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u}=t._zod.bag;if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=tb[a]??a,o.format===""&&delete o.format,a==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let l=[...c];l.length===1?o.pattern=l[0].source:l.length>1&&(o.allOf=[...l.map(d=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},uh=(t,e,r,n)=>{let o=r,{minimum:s,maximum:i,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=t._zod.bag;typeof a=="string"&&a.includes("int")?o.type="integer":o.type="number";let d=typeof l=="number"&&l>=(s??Number.NEGATIVE_INFINITY),p=typeof u=="number"&&u<=(i??Number.POSITIVE_INFINITY),m=e.target==="draft-04"||e.target==="openapi-3.0";d?m?(o.minimum=l,o.exclusiveMinimum=!0):o.exclusiveMinimum=l:typeof s=="number"&&(o.minimum=s),p?m?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u:typeof i=="number"&&(o.maximum=i),typeof c=="number"&&(o.multipleOf=c)},lh=(t,e,r,n)=>{r.type="boolean"};var dh=(t,e,r,n)=>{e.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var ph=(t,e,r,n)=>{r.not={}};var fh=(t,e,r,n)=>{};var mh=(t,e,r,n)=>{let o=t._zod.def,s=_n(o.entries);s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},hh=(t,e,r,n)=>{let o=t._zod.def,s=[];for(let i of o.values)if(i===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");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,e.target==="draft-04"||e.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 gh=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")};var _h=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")};var yh=(t,e,r,n)=>{let o=r,s=t._zod.def,{minimum:i,maximum:a}=t._zod.bag;typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=ae(s.element,e,{...n,path:[...n.path,"items"]})},Sh=(t,e,r,n)=>{let o=r,s=t._zod.def;o.type="object",o.properties={};let i=s.shape;for(let u in i)o.properties[u]=ae(i[u],e,{...n,path:[...n.path,"properties",u]});let a=new Set(Object.keys(i)),c=new Set([...a].filter(u=>{let l=s.shape[u]._zod;return e.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(o.required=Array.from(c)),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=ae(s.catchall,e,{...n,path:[...n.path,"additionalProperties"]})):e.io==="output"&&(o.additionalProperties=!1)},vh=(t,e,r,n)=>{let o=t._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>ae(a,e,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=i:r.anyOf=i},Eh=(t,e,r,n)=>{let o=t._zod.def,s=ae(o.left,e,{...n,path:[...n.path,"allOf",0]}),i=ae(o.right,e,{...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};var wh=(t,e,r,n)=>{let o=r,s=t._zod.def;o.type="object";let i=s.keyType,c=i._zod.bag?.patterns;if(s.mode==="loose"&&c&&c.size>0){let l=ae(s.valueType,e,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of c)o.patternProperties[d.source]=l}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(o.propertyNames=ae(s.keyType,e,{...n,path:[...n.path,"propertyNames"]})),o.additionalProperties=ae(s.valueType,e,{...n,path:[...n.path,"additionalProperties"]});let u=i._zod.values;if(u){let l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l)}},bh=(t,e,r,n)=>{let o=t._zod.def,s=ae(o.innerType,e,n),i=e.seen.get(t);e.target==="openapi-3.0"?(i.ref=o.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},kh=(t,e,r,n)=>{let o=t._zod.def;ae(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType},xh=(t,e,r,n)=>{let o=t._zod.def;ae(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},$h=(t,e,r,n)=>{let o=t._zod.def;ae(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType,e.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Ph=(t,e,r,n)=>{let o=t._zod.def;ae(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=i},Th=(t,e,r,n)=>{let o=t._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=e.io==="input"?s?o.out:o.in:o.out;ae(i,e,n);let a=e.seen.get(t);a.ref=i},Oh=(t,e,r,n)=>{let o=t._zod.def;ae(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType,r.readOnly=!0};var Ta=(t,e,r,n)=>{let o=t._zod.def;ae(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType};function Rr(t){return!!t._zod}function ot(t,e){return Rr(t)?wn(t,e):t.safeParse(e)}function es(t){if(!t)return;let e;if(Rr(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function zh(t){if(Rr(t)){let s=t._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=t._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=t.value;if(n!==void 0)return n}var On={};Rl(On,{ZodISODate:()=>Ih,ZodISODateTime:()=>Rh,ZodISODuration:()=>Ah,ZodISOTime:()=>Ch,date:()=>za,datetime:()=>Oa,duration:()=>Ia,time:()=>Ra});var Rh=S("ZodISODateTime",(t,e)=>{Uf.init(t,e),ne.init(t,e)});function Oa(t){return Vm(Rh,t)}var Ih=S("ZodISODate",(t,e)=>{Ff.init(t,e),ne.init(t,e)});function za(t){return Jm(Ih,t)}var Ch=S("ZodISOTime",(t,e)=>{Zf.init(t,e),ne.init(t,e)});function Ra(t){return Gm(Ch,t)}var Ah=S("ZodISODuration",(t,e)=>{qf.init(t,e),ne.init(t,e)});function Ia(t){return Bm(Ah,t)}var lb=(t,e)=>{Uo.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>wp(t,r)},flatten:{value:r=>Ep(t,r)},addIssue:{value:r=>{t.issues.push(r),t.message=JSON.stringify(t.issues,Pr,2)}},addIssues:{value:r=>{t.issues.push(...r),t.message=JSON.stringify(t.issues,Pr,2)}},isEmpty:{get(){return t.issues.length===0}}})};var qe=S("ZodError",lb,{Parent:Error});var Mh=Fo(qe),Nh=Zo(qe),Dh=En(qe),Lh=bn(qe),jh=bp(qe),Uh=kp(qe),Fh=xp(qe),Zh=$p(qe),qh=Pp(qe),Hh=Tp(qe),Wh=Op(qe),Kh=zp(qe);var Vh=new WeakMap;function zn(t,e,r){let n=Object.getPrototypeOf(t),o=Vh.get(n);if(o||(o=new Set,Vh.set(n,o)),!o.has(e)){o.add(e);for(let s in r){let i=r[s];Object.defineProperty(n,s,{configurable:!0,enumerable:!1,get(){let a=i.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}var ie=S("ZodType",(t,e)=>(X.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:Pn(t,"input"),output:Pn(t,"output")}}),t.toJSONSchema=ah(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.parse=(r,n)=>Mh(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Dh(t,r,n),t.parseAsync=async(r,n)=>Nh(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>Lh(t,r,n),t.spa=t.safeParseAsync,t.encode=(r,n)=>jh(t,r,n),t.decode=(r,n)=>Uh(t,r,n),t.encodeAsync=async(r,n)=>Fh(t,r,n),t.decodeAsync=async(r,n)=>Zh(t,r,n),t.safeEncode=(r,n)=>qh(t,r,n),t.safeDecode=(r,n)=>Hh(t,r,n),t.safeEncodeAsync=async(r,n)=>Wh(t,r,n),t.safeDecodeAsync=async(r,n)=>Kh(t,r,n),zn(t,"ZodType",{check(...r){let n=this.def;return this.clone(F.mergeDefs(n,{checks:[...n.checks??[],...r.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,n){return nt(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(ek(r,n))},superRefine(r,n){return this.check(tk(r,n))},overwrite(r){return this.check(Dt(r))},optional(){return se(this)},exactOptional(){return Zb(this)},nullable(){return Yh(this)},nullish(){return se(Yh(this))},nonoptional(r){return Jb(this,r)},array(){return j(this)},or(r){return ee([this,r])},and(r){return rs(this,r)},transform(r){return Xh(this,og(r))},default(r){return Wb(this,r)},prefault(r){return Vb(this,r)},catch(r){return Bb(this,r)},pipe(r){return Xh(this,r)},readonly(){return Qb(this)},describe(r){let n=this.clone();return nr.add(n,{description:r}),n},meta(...r){if(r.length===0)return nr.get(this);let n=this.clone();return nr.add(n,r[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(t,"description",{get(){return nr.get(t)?.description},configurable:!0}),t)),Qh=S("_ZodString",(t,e)=>{Jo.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(n,o,s)=>ch(t,n,o,s);let r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,zn(t,"_ZodString",{regex(...n){return this.check(ma(...n))},includes(...n){return this.check(_a(...n))},startsWith(...n){return this.check(ya(...n))},endsWith(...n){return this.check(Sa(...n))},min(...n){return this.check(zr(...n))},max(...n){return this.check(Xo(...n))},length(...n){return this.check(Qo(...n))},nonempty(...n){return this.check(zr(1,...n))},lowercase(n){return this.check(ha(n))},uppercase(n){return this.check(ga(n))},trim(){return this.check(Ea())},normalize(...n){return this.check(va(...n))},toLowerCase(){return this.check(wa())},toUpperCase(){return this.check(ba())},slugify(){return this.check(ka())}})}),pb=S("ZodString",(t,e)=>{Jo.init(t,e),Qh.init(t,e),t.email=r=>t.check($m(fb,r)),t.url=r=>t.check(Rm(mb,r)),t.jwt=r=>t.check(Km(Ob,r)),t.emoji=r=>t.check(Im(hb,r)),t.guid=r=>t.check(fa(Jh,r)),t.uuid=r=>t.check(Pm(ts,r)),t.uuidv4=r=>t.check(Tm(ts,r)),t.uuidv6=r=>t.check(Om(ts,r)),t.uuidv7=r=>t.check(zm(ts,r)),t.nanoid=r=>t.check(Cm(gb,r)),t.guid=r=>t.check(fa(Jh,r)),t.cuid=r=>t.check(Am(_b,r)),t.cuid2=r=>t.check(Mm(yb,r)),t.ulid=r=>t.check(Nm(Sb,r)),t.base64=r=>t.check(qm($b,r)),t.base64url=r=>t.check(Hm(Pb,r)),t.xid=r=>t.check(Dm(vb,r)),t.ksuid=r=>t.check(Lm(Eb,r)),t.ipv4=r=>t.check(jm(wb,r)),t.ipv6=r=>t.check(Um(bb,r)),t.cidrv4=r=>t.check(Fm(kb,r)),t.cidrv6=r=>t.check(Zm(xb,r)),t.e164=r=>t.check(Wm(Tb,r)),t.datetime=r=>t.check(Oa(r)),t.date=r=>t.check(za(r)),t.time=r=>t.check(Ra(r)),t.duration=r=>t.check(Ia(r))});function _(t){return xm(pb,t)}var ne=S("ZodStringFormat",(t,e)=>{Q.init(t,e),Qh.init(t,e)}),fb=S("ZodEmail",(t,e)=>{Rf.init(t,e),ne.init(t,e)});var Jh=S("ZodGUID",(t,e)=>{Of.init(t,e),ne.init(t,e)});var ts=S("ZodUUID",(t,e)=>{zf.init(t,e),ne.init(t,e)});var mb=S("ZodURL",(t,e)=>{If.init(t,e),ne.init(t,e)});var hb=S("ZodEmoji",(t,e)=>{Cf.init(t,e),ne.init(t,e)});var gb=S("ZodNanoID",(t,e)=>{Af.init(t,e),ne.init(t,e)});var _b=S("ZodCUID",(t,e)=>{Mf.init(t,e),ne.init(t,e)});var yb=S("ZodCUID2",(t,e)=>{Nf.init(t,e),ne.init(t,e)});var Sb=S("ZodULID",(t,e)=>{Df.init(t,e),ne.init(t,e)});var vb=S("ZodXID",(t,e)=>{Lf.init(t,e),ne.init(t,e)});var Eb=S("ZodKSUID",(t,e)=>{jf.init(t,e),ne.init(t,e)});var wb=S("ZodIPv4",(t,e)=>{Hf.init(t,e),ne.init(t,e)});var bb=S("ZodIPv6",(t,e)=>{Wf.init(t,e),ne.init(t,e)});var kb=S("ZodCIDRv4",(t,e)=>{Kf.init(t,e),ne.init(t,e)});var xb=S("ZodCIDRv6",(t,e)=>{Vf.init(t,e),ne.init(t,e)});var $b=S("ZodBase64",(t,e)=>{Gf.init(t,e),ne.init(t,e)});var Pb=S("ZodBase64URL",(t,e)=>{Bf.init(t,e),ne.init(t,e)});var Tb=S("ZodE164",(t,e)=>{Yf.init(t,e),ne.init(t,e)});var Ob=S("ZodJWT",(t,e)=>{Xf.init(t,e),ne.init(t,e)});var eg=S("ZodNumber",(t,e)=>{ca.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(n,o,s)=>uh(t,n,o,s),zn(t,"ZodNumber",{gt(n,o){return this.check(Bo(n,o))},gte(n,o){return this.check($n(n,o))},min(n,o){return this.check($n(n,o))},lt(n,o){return this.check(Go(n,o))},lte(n,o){return this.check(xn(n,o))},max(n,o){return this.check(xn(n,o))},int(n){return this.check(Gh(n))},safe(n){return this.check(Gh(n))},positive(n){return this.check(Bo(0,n))},nonnegative(n){return this.check($n(0,n))},negative(n){return this.check(Go(0,n))},nonpositive(n){return this.check(xn(0,n))},multipleOf(n,o){return this.check(Yo(n,o))},step(n,o){return this.check(Yo(n,o))},finite(){return this}});let r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null});function V(t){return Ym(eg,t)}var zb=S("ZodNumberFormat",(t,e)=>{Qf.init(t,e),eg.init(t,e)});function Gh(t){return Xm(zb,t)}var Rb=S("ZodBoolean",(t,e)=>{em.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>lh(t,r,n,o)});function pe(t){return Qm(Rb,t)}var Ib=S("ZodNull",(t,e)=>{tm.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>dh(t,r,n,o)});function tg(t){return eh(Ib,t)}var Cb=S("ZodUnknown",(t,e)=>{rm.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>fh(t,r,n,o)});function oe(){return th(Cb)}var Ab=S("ZodNever",(t,e)=>{nm.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>ph(t,r,n,o)});function Mb(t){return rh(Ab,t)}var Nb=S("ZodArray",(t,e)=>{om.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>yh(t,r,n,o),t.element=e.element,zn(t,"ZodArray",{min(r,n){return this.check(zr(r,n))},nonempty(r){return this.check(zr(1,r))},max(r,n){return this.check(Xo(r,n))},length(r,n){return this.check(Qo(r,n))},unwrap(){return this.element}})});function j(t,e){return nh(Nb,t,e)}var rg=S("ZodObject",(t,e)=>{am.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Sh(t,r,n,o),F.defineLazy(t,"shape",()=>e.shape),zn(t,"ZodObject",{keyof(){return Ae(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:oe()})},loose(){return this.clone({...this._zod.def,catchall:oe()})},strict(){return this.clone({...this._zod.def,catchall:Mb()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return F.extend(this,r)},safeExtend(r){return F.safeExtend(this,r)},merge(r){return F.merge(this,r)},pick(r){return F.pick(this,r)},omit(r){return F.omit(this,r)},partial(...r){return F.partial(sg,this,r[0])},required(...r){return F.required(ig,this,r[0])}})});function k(t,e){let r={type:"object",shape:t??{},...F.normalizeParams(e)};return new rg(r)}function Oe(t,e){return new rg({type:"object",shape:t,catchall:oe(),...F.normalizeParams(e)})}var ng=S("ZodUnion",(t,e)=>{ua.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>vh(t,r,n,o),t.options=e.options});function ee(t,e){return new ng({type:"union",options:t,...F.normalizeParams(e)})}var Db=S("ZodDiscriminatedUnion",(t,e)=>{ng.init(t,e),cm.init(t,e)});function Aa(t,e,r){return new Db({type:"union",options:e,discriminator:t,...F.normalizeParams(r)})}var Lb=S("ZodIntersection",(t,e)=>{um.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Eh(t,r,n,o)});function rs(t,e){return new Lb({type:"intersection",left:t,right:e})}var Bh=S("ZodRecord",(t,e)=>{lm.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>wh(t,r,n,o),t.keyType=e.keyType,t.valueType=e.valueType});function Y(t,e,r){return!e||!e._zod?new Bh({type:"record",keyType:_(),valueType:t,...F.normalizeParams(e)}):new Bh({type:"record",keyType:t,valueType:e,...F.normalizeParams(r)})}var Ca=S("ZodEnum",(t,e)=>{dm.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(n,o,s)=>mh(t,n,o,s),t.enum=e.entries,t.options=Object.values(e.entries);let r=new Set(Object.keys(e.entries));t.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Ca({...e,checks:[],...F.normalizeParams(o),entries:s})},t.exclude=(n,o)=>{let s={...e.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 Ca({...e,checks:[],...F.normalizeParams(o),entries:s})}});function Ae(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new Ca({type:"enum",entries:r,...F.normalizeParams(e)})}var jb=S("ZodLiteral",(t,e)=>{pm.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>hh(t,r,n,o),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function P(t,e){return new jb({type:"literal",values:Array.isArray(t)?t:[t],...F.normalizeParams(e)})}var Ub=S("ZodTransform",(t,e)=>{fm.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>_h(t,r,n,o),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new xr(t.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(F.issue(s,r.value,e));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=t),r.issues.push(F.issue(i))}};let o=e.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r.fallback=!0,r)):(r.value=o,r.fallback=!0,r)}});function og(t){return new Ub({type:"transform",transform:t})}var sg=S("ZodOptional",(t,e)=>{la.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Ta(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function se(t){return new sg({type:"optional",innerType:t})}var Fb=S("ZodExactOptional",(t,e)=>{mm.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Ta(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function Zb(t){return new Fb({type:"optional",innerType:t})}var qb=S("ZodNullable",(t,e)=>{hm.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>bh(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function Yh(t){return new qb({type:"nullable",innerType:t})}var Hb=S("ZodDefault",(t,e)=>{gm.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>xh(t,r,n,o),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function Wb(t,e){return new Hb({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():F.shallowClone(e)}})}var Kb=S("ZodPrefault",(t,e)=>{_m.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>$h(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function Vb(t,e){return new Kb({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():F.shallowClone(e)}})}var ig=S("ZodNonOptional",(t,e)=>{ym.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>kh(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function Jb(t,e){return new ig({type:"nonoptional",innerType:t,...F.normalizeParams(e)})}var Gb=S("ZodCatch",(t,e)=>{Sm.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Ph(t,r,n,o),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function Bb(t,e){return new Gb({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var ag=S("ZodPipe",(t,e)=>{da.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Th(t,r,n,o),t.in=e.in,t.out=e.out});function Xh(t,e){return new ag({type:"pipe",in:t,out:e})}var Yb=S("ZodPreprocess",(t,e)=>{ag.init(t,e),vm.init(t,e)}),Xb=S("ZodReadonly",(t,e)=>{Em.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Oh(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function Qb(t){return new Xb({type:"readonly",innerType:t})}var cg=S("ZodCustom",(t,e)=>{wm.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>gh(t,r,n,o)});function ug(t,e){return oh(cg,t??(()=>!0),e)}function ek(t,e={}){return sh(cg,t,e)}function tk(t,e){return ih(t,e)}function Ma(t,e){return new Yb({type:"pipe",in:og(t),out:e})}Ze(bm());var Da="2025-11-25";var lg=[Da,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Lt="io.modelcontextprotocol/related-task",os="2.0",de=ug(t=>t!==null&&(typeof t=="object"||typeof t=="function")),dg=ee([_(),V().int()]),pg=_(),AN=Oe({ttl:V().optional(),pollInterval:V().optional()}),rk=k({ttl:V().optional()}),nk=k({taskId:_()}),La=Oe({progressToken:dg.optional(),[Lt]:nk.optional()}),He=k({_meta:La.optional()}),Rn=He.extend({task:rk.optional()}),fg=t=>Rn.safeParse(t).success,_e=k({method:_(),params:He.loose().optional()}),Ge=k({_meta:La.optional()}),Be=k({method:_(),params:Ge.loose().optional()}),ye=Oe({_meta:La.optional()}),ss=ee([_(),V().int()]),mg=k({jsonrpc:P(os),id:ss,..._e.shape}).strict(),ja=t=>mg.safeParse(t).success,hg=k({jsonrpc:P(os),...Be.shape}).strict(),gg=t=>hg.safeParse(t).success,Ua=k({jsonrpc:P(os),id:ss,result:ye}).strict(),In=t=>Ua.safeParse(t).success;var R;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(R||(R={}));var Fa=k({jsonrpc:P(os),id:ss.optional(),error:k({code:V().int(),message:_(),data:oe().optional()})}).strict();var _g=t=>Fa.safeParse(t).success;var yg=ee([mg,hg,Ua,Fa]),MN=ee([Ua,Fa]),or=ye.strict(),ok=Ge.extend({requestId:ss.optional(),reason:_().optional()}),is=Be.extend({method:P("notifications/cancelled"),params:ok}),sk=k({src:_(),mimeType:_().optional(),sizes:j(_()).optional(),theme:Ae(["light","dark"]).optional()}),Cn=k({icons:j(sk).optional()}),Ir=k({name:_(),title:_().optional()}),Sg=Ir.extend({...Ir.shape,...Cn.shape,version:_(),websiteUrl:_().optional(),description:_().optional()}),ik=rs(k({applyDefaults:pe().optional()}),Y(_(),oe())),ak=Ma(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,rs(k({form:ik.optional(),url:de.optional()}),Y(_(),oe()).optional())),ck=Oe({list:de.optional(),cancel:de.optional(),requests:Oe({sampling:Oe({createMessage:de.optional()}).optional(),elicitation:Oe({create:de.optional()}).optional()}).optional()}),uk=Oe({list:de.optional(),cancel:de.optional(),requests:Oe({tools:Oe({call:de.optional()}).optional()}).optional()}),lk=k({experimental:Y(_(),de).optional(),sampling:k({context:de.optional(),tools:de.optional()}).optional(),elicitation:ak.optional(),roots:k({listChanged:pe().optional()}).optional(),tasks:ck.optional(),extensions:Y(_(),de).optional()}),dk=He.extend({protocolVersion:_(),capabilities:lk,clientInfo:Sg}),pk=_e.extend({method:P("initialize"),params:dk});var fk=k({experimental:Y(_(),de).optional(),logging:de.optional(),completions:de.optional(),prompts:k({listChanged:pe().optional()}).optional(),resources:k({subscribe:pe().optional(),listChanged:pe().optional()}).optional(),tools:k({listChanged:pe().optional()}).optional(),tasks:uk.optional(),extensions:Y(_(),de).optional()}),Za=ye.extend({protocolVersion:_(),capabilities:fk,serverInfo:Sg,instructions:_().optional()}),mk=Be.extend({method:P("notifications/initialized"),params:Ge.optional()});var as=_e.extend({method:P("ping"),params:He.optional()}),hk=k({progress:V(),total:se(V()),message:se(_())}),gk=k({...Ge.shape,...hk.shape,progressToken:dg}),cs=Be.extend({method:P("notifications/progress"),params:gk}),_k=He.extend({cursor:pg.optional()}),An=_e.extend({params:_k.optional()}),Mn=ye.extend({nextCursor:pg.optional()}),yk=Ae(["working","input_required","completed","failed","cancelled"]),Nn=k({taskId:_(),status:yk,ttl:ee([V(),tg()]),createdAt:_(),lastUpdatedAt:_(),pollInterval:se(V()),statusMessage:se(_())}),sr=ye.extend({task:Nn}),Sk=Ge.merge(Nn),Dn=Be.extend({method:P("notifications/tasks/status"),params:Sk}),us=_e.extend({method:P("tasks/get"),params:He.extend({taskId:_()})}),ls=ye.merge(Nn),ds=_e.extend({method:P("tasks/result"),params:He.extend({taskId:_()})}),NN=ye.loose(),ps=An.extend({method:P("tasks/list")}),fs=Mn.extend({tasks:j(Nn)}),ms=_e.extend({method:P("tasks/cancel"),params:He.extend({taskId:_()})}),vg=ye.merge(Nn),Eg=k({uri:_(),mimeType:se(_()),_meta:Y(_(),oe()).optional()}),wg=Eg.extend({text:_()}),qa=_().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),bg=Eg.extend({blob:qa}),Ln=Ae(["user","assistant"]),Cr=k({audience:j(Ln).optional(),priority:V().min(0).max(1).optional(),lastModified:On.datetime({offset:!0}).optional()}),kg=k({...Ir.shape,...Cn.shape,uri:_(),description:se(_()),mimeType:se(_()),size:se(V()),annotations:Cr.optional(),_meta:se(Oe({}))}),vk=k({...Ir.shape,...Cn.shape,uriTemplate:_(),description:se(_()),mimeType:se(_()),annotations:Cr.optional(),_meta:se(Oe({}))}),Ek=An.extend({method:P("resources/list")}),Ha=Mn.extend({resources:j(kg)}),wk=An.extend({method:P("resources/templates/list")}),Wa=Mn.extend({resourceTemplates:j(vk)}),Ka=He.extend({uri:_()}),bk=Ka,kk=_e.extend({method:P("resources/read"),params:bk}),Va=ye.extend({contents:j(ee([wg,bg]))}),Ja=Be.extend({method:P("notifications/resources/list_changed"),params:Ge.optional()}),xk=Ka,$k=_e.extend({method:P("resources/subscribe"),params:xk}),Pk=Ka,Tk=_e.extend({method:P("resources/unsubscribe"),params:Pk}),Ok=Ge.extend({uri:_()}),zk=Be.extend({method:P("notifications/resources/updated"),params:Ok}),Rk=k({name:_(),description:se(_()),required:se(pe())}),Ik=k({...Ir.shape,...Cn.shape,description:se(_()),arguments:se(j(Rk)),_meta:se(Oe({}))}),Ck=An.extend({method:P("prompts/list")}),Ga=Mn.extend({prompts:j(Ik)}),Ak=He.extend({name:_(),arguments:Y(_(),_()).optional()}),Mk=_e.extend({method:P("prompts/get"),params:Ak}),Ba=k({type:P("text"),text:_(),annotations:Cr.optional(),_meta:Y(_(),oe()).optional()}),Ya=k({type:P("image"),data:qa,mimeType:_(),annotations:Cr.optional(),_meta:Y(_(),oe()).optional()}),Xa=k({type:P("audio"),data:qa,mimeType:_(),annotations:Cr.optional(),_meta:Y(_(),oe()).optional()}),Nk=k({type:P("tool_use"),name:_(),id:_(),input:Y(_(),oe()),_meta:Y(_(),oe()).optional()}),Dk=k({type:P("resource"),resource:ee([wg,bg]),annotations:Cr.optional(),_meta:Y(_(),oe()).optional()}),Lk=kg.extend({type:P("resource_link")}),Qa=ee([Ba,Ya,Xa,Lk,Dk]),jk=k({role:Ln,content:Qa}),ec=ye.extend({description:_().optional(),messages:j(jk)}),tc=Be.extend({method:P("notifications/prompts/list_changed"),params:Ge.optional()}),Uk=k({title:_().optional(),readOnlyHint:pe().optional(),destructiveHint:pe().optional(),idempotentHint:pe().optional(),openWorldHint:pe().optional()}),Fk=k({taskSupport:Ae(["required","optional","forbidden"]).optional()}),xg=k({...Ir.shape,...Cn.shape,description:_().optional(),inputSchema:k({type:P("object"),properties:Y(_(),de).optional(),required:j(_()).optional()}).catchall(oe()),outputSchema:k({type:P("object"),properties:Y(_(),de).optional(),required:j(_()).optional()}).catchall(oe()).optional(),annotations:Uk.optional(),execution:Fk.optional(),_meta:Y(_(),oe()).optional()}),Zk=An.extend({method:P("tools/list")}),rc=Mn.extend({tools:j(xg)}),Ar=ye.extend({content:j(Qa).default([]),structuredContent:Y(_(),oe()).optional(),isError:pe().optional()}),DN=Ar.or(ye.extend({toolResult:oe()})),qk=Rn.extend({name:_(),arguments:Y(_(),oe()).optional()}),Hk=_e.extend({method:P("tools/call"),params:qk}),nc=Be.extend({method:P("notifications/tools/list_changed"),params:Ge.optional()}),$g=k({autoRefresh:pe().default(!0),debounceMs:V().int().nonnegative().default(300)}),Pg=Ae(["debug","info","notice","warning","error","critical","alert","emergency"]),Wk=He.extend({level:Pg}),Kk=_e.extend({method:P("logging/setLevel"),params:Wk}),Vk=Ge.extend({level:Pg,logger:_().optional(),data:oe()}),Jk=Be.extend({method:P("notifications/message"),params:Vk}),Gk=k({name:_().optional()}),Bk=k({hints:j(Gk).optional(),costPriority:V().min(0).max(1).optional(),speedPriority:V().min(0).max(1).optional(),intelligencePriority:V().min(0).max(1).optional()}),Yk=k({mode:Ae(["auto","required","none"]).optional()}),Xk=k({type:P("tool_result"),toolUseId:_().describe("The unique identifier for the corresponding tool call."),content:j(Qa).default([]),structuredContent:k({}).loose().optional(),isError:pe().optional(),_meta:Y(_(),oe()).optional()}),Qk=Aa("type",[Ba,Ya,Xa]),ns=Aa("type",[Ba,Ya,Xa,Nk,Xk]),ex=k({role:Ln,content:ee([ns,j(ns)]),_meta:Y(_(),oe()).optional()}),tx=Rn.extend({messages:j(ex),modelPreferences:Bk.optional(),systemPrompt:_().optional(),includeContext:Ae(["none","thisServer","allServers"]).optional(),temperature:V().optional(),maxTokens:V().int(),stopSequences:j(_()).optional(),metadata:de.optional(),tools:j(xg).optional(),toolChoice:Yk.optional()}),oc=_e.extend({method:P("sampling/createMessage"),params:tx}),sc=ye.extend({model:_(),stopReason:se(Ae(["endTurn","stopSequence","maxTokens"]).or(_())),role:Ln,content:Qk}),ic=ye.extend({model:_(),stopReason:se(Ae(["endTurn","stopSequence","maxTokens","toolUse"]).or(_())),role:Ln,content:ee([ns,j(ns)])}),rx=k({type:P("boolean"),title:_().optional(),description:_().optional(),default:pe().optional()}),nx=k({type:P("string"),title:_().optional(),description:_().optional(),minLength:V().optional(),maxLength:V().optional(),format:Ae(["email","uri","date","date-time"]).optional(),default:_().optional()}),ox=k({type:Ae(["number","integer"]),title:_().optional(),description:_().optional(),minimum:V().optional(),maximum:V().optional(),default:V().optional()}),sx=k({type:P("string"),title:_().optional(),description:_().optional(),enum:j(_()),default:_().optional()}),ix=k({type:P("string"),title:_().optional(),description:_().optional(),oneOf:j(k({const:_(),title:_()})),default:_().optional()}),ax=k({type:P("string"),title:_().optional(),description:_().optional(),enum:j(_()),enumNames:j(_()).optional(),default:_().optional()}),cx=ee([sx,ix]),ux=k({type:P("array"),title:_().optional(),description:_().optional(),minItems:V().optional(),maxItems:V().optional(),items:k({type:P("string"),enum:j(_())}),default:j(_()).optional()}),lx=k({type:P("array"),title:_().optional(),description:_().optional(),minItems:V().optional(),maxItems:V().optional(),items:k({anyOf:j(k({const:_(),title:_()}))}),default:j(_()).optional()}),dx=ee([ux,lx]),px=ee([ax,cx,dx]),fx=ee([px,rx,nx,ox]),mx=Rn.extend({mode:P("form").optional(),message:_(),requestedSchema:k({type:P("object"),properties:Y(_(),fx),required:j(_()).optional()})}),hx=Rn.extend({mode:P("url"),message:_(),elicitationId:_(),url:_().url()}),gx=ee([mx,hx]),ac=_e.extend({method:P("elicitation/create"),params:gx}),_x=Ge.extend({elicitationId:_()}),yx=Be.extend({method:P("notifications/elicitation/complete"),params:_x}),cc=ye.extend({action:Ae(["accept","decline","cancel"]),content:Ma(t=>t===null?void 0:t,Y(_(),ee([_(),V(),pe(),j(_())])).optional())}),Sx=k({type:P("ref/resource"),uri:_()});var vx=k({type:P("ref/prompt"),name:_()}),Ex=He.extend({ref:ee([vx,Sx]),argument:k({name:_(),value:_()}),context:k({arguments:Y(_(),_()).optional()}).optional()}),wx=_e.extend({method:P("completion/complete"),params:Ex});var uc=ye.extend({completion:Oe({values:j(_()).max(100),total:se(V().int()),hasMore:se(pe())})}),bx=k({uri:_().startsWith("file://"),name:_().optional(),_meta:Y(_(),oe()).optional()}),kx=_e.extend({method:P("roots/list"),params:He.optional()}),xx=ye.extend({roots:j(bx)}),$x=Be.extend({method:P("notifications/roots/list_changed"),params:Ge.optional()}),LN=ee([as,pk,wx,Kk,Mk,Ck,Ek,wk,kk,$k,Tk,Hk,Zk,us,ds,ps,ms]),jN=ee([is,cs,mk,$x,Dn]),UN=ee([or,sc,ic,cc,xx,ls,fs,sr]),FN=ee([as,oc,ac,kx,us,ds,ps,ms]),ZN=ee([is,cs,Jk,zk,Ja,nc,tc,Dn,yx]),qN=ee([or,Za,uc,ec,Ga,Ha,Wa,Va,Ar,rc,ls,fs,sr]),O=class t extends Error{constructor(e,r,n){super(`MCP error ${e}: ${r}`),this.code=e,this.data=n,this.name="McpError"}static fromError(e,r,n){if(e===R.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new Na(o.elicitations,r)}return new t(e,r,n)}},Na=class extends O{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(R.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function jt(t){return t==="completed"||t==="failed"||t==="cancelled"}var wD=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function lc(t){let r=es(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=zh(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function dc(t,e){let r=ot(t,e);if(!r.success)throw r.error;return r.data}var Ix=6e4,hs=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(is,r=>{this._oncancel(r)}),this.setNotificationHandler(cs,r=>{this._onprogress(r)}),this.setRequestHandler(as,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(us,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new O(R.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(ds,async(r,n)=>{let o=async()=>{let s=r.params.taskId;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,p=new O(d.error.code,d.error.message,d.error.data);l(p)}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 O(R.InvalidParams,`Task not found: ${s}`);if(!jt(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(jt(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[Lt]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(ps,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 O(R.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(ms,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new O(R.InvalidParams,`Task not found: ${r.params.taskId}`);if(jt(o.status))throw new O(R.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new O(R.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof O?o:new O(R.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,n,o,s=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),O.fromError(R.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){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=e;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),In(s)||_g(s)?this._onresponse(s):ja(s)?this._onrequest(s,i):gg(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let e=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=O.fromError(R.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of e.values())n(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(e,r){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,o=this._transport,s=e.params?._meta?.[Lt]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:R.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);let a=fg(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let d={relatedRequestId:e.id};s&&(d.relatedTask={taskId:s}),await this.notification(l,d)},sendRequest:async(l,d,p)=>{if(i.signal.aborted)throw new O(R.ConnectionClosed,"Request was cancelled");let m={...p,relatedRequestId:e.id};s&&!m.relatedTask&&(m.relatedTask={taskId:s});let h=m.relatedTask?.taskId??s;return h&&c&&await c.updateTaskStatus(h,"input_required"),await this.request(l,d,m)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,u)).then(async l=>{if(i.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:e.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:R.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===i&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...n}=e.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(e)}`));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(e){let r=Number(e.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),In(e))n(e);else{let i=new O(e.error.code,e.error.message,e.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(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if(In(e)&&e.result&&typeof e.result=="object"){let i=e.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),In(e))o(e);else{let i=O.fromError(e.error.code,e.error.message,e.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(e,r,n)}}catch(i){yield{type:"error",error:i instanceof O?i:new O(R.InternalError,String(i))}}return}let s;try{let i=await this.request(e,sr,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new O(R.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},jt(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new O(R.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new O(R.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 O?i:new O(R.InternalError,String(i))}}}request(e,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=b=>{l(b)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(b){d(b);return}n?.signal?.throwIfAborted();let p=this._requestMessageId++,m={...e,jsonrpc:"2.0",id:p};n?.onprogress&&(this._progressHandlers.set(p,n.onprogress),m.params={...e.params,_meta:{...e.params?._meta||{},progressToken:p}}),a&&(m.params={...m.params,task:a}),c&&(m.params={...m.params,_meta:{...m.params?._meta||{},[Lt]:c}});let h=b=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(b)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch($=>this._onerror(new Error(`Failed to send cancellation: ${$}`)));let w=b instanceof O?b:new O(R.RequestTimeout,String(b));l(w)};this._responseHandlers.set(p,b=>{if(!n?.signal?.aborted){if(b instanceof Error)return l(b);try{let w=ot(r,b.result);w.success?u(w.data):l(w.error)}catch(w){l(w)}}}),n?.signal?.addEventListener("abort",()=>{h(n?.signal?.reason)});let y=n?.timeout??Ix,g=()=>h(O.fromError(R.RequestTimeout,"Request timed out",{timeout:y}));this._setupTimeout(p,y,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let v=c?.taskId;if(v){let b=w=>{let $=this._responseHandlers.get(p);$?$(w):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,b),this._enqueueTaskMessage(v,{type:"request",message:m,timestamp:Date.now()}).catch(w=>{this._cleanupTimeout(p),l(w)})}else this._transport.send(m,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(b=>{this._cleanupTimeout(p),l(b)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},ls,r)}async getTaskResult(e,r,n){return this.request({method:"tasks/result",params:e},r,n)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},fs,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},vg,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let n=r?.relatedTask?.taskId;if(n){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[Lt]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Lt]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[Lt]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let n=lc(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=dc(e,o);return Promise.resolve(r(i,s))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){let n=lc(e);this._notificationHandlers.set(n,o=>{let s=dc(e,o);return Promise.resolve(r(s))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,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(e,r,n,o)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,r);for(let o of n)if(o.type==="request"&&ja(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new O(R.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(e);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new O(R.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new O(R.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!e)throw new Error("No request provided");return await n.createTask(o,e.id,{method:e.method,params:e.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new O(R.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=Dn.parse({method:"notifications/tasks/status",params:a});await this.notification(c),jt(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 O(R.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(jt(a.status))throw new O(R.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=Dn.parse({method:"notifications/tasks/status",params:c});await this.notification(u),jt(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function Tg(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Og(t,e){let r={...t};for(let n in e){let o=n,s=e[o];if(s===void 0)continue;let i=r[o];Tg(i)&&Tg(s)?r[o]={...i,...s}:r[o]=s}return r}var vS=we(Yu(),1),ES=we(SS(),1);function Mz(){let t=new vS.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,ES.default)(t),t}var Bs=class{constructor(e){this._ajv=e??Mz()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var Ys=class{constructor(e){this._client=e}async*callToolStream(e,r=Ar,n){let o=this._client,s={...n,task:n?.task??(o.isToolTask(e.name)?{}:void 0)},i=o.requestStream({method:"tools/call",params:e},r,s),a=o.getToolOutputValidator(e.name);for await(let c of i){if(c.type==="result"&&a){let u=c.result;if(!u.structuredContent&&!u.isError){yield{type:"error",error:new O(R.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(u.structuredContent)try{let l=a(u.structuredContent);if(!l.valid){yield{type:"error",error:new O(R.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof O){yield{type:"error",error:l};return}yield{type:"error",error:new O(R.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)};return}}yield c}}async getTask(e,r){return this._client.getTask({taskId:e},r)}async getTaskResult(e,r,n){return this._client.getTaskResult({taskId:e},r,n)}async listTasks(e,r){return this._client.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._client.cancelTask({taskId:e},r)}requestStream(e,r,n){return this._client.requestStream(e,r,n)}};function wS(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function bS(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}function Xs(t,e){if(!(!t||e===null||typeof e!="object")){if(t.type==="object"&&t.properties&&typeof t.properties=="object"){let r=e,n=t.properties;for(let o of Object.keys(n)){let s=n[o];r[o]===void 0&&Object.prototype.hasOwnProperty.call(s,"default")&&(r[o]=s.default),r[o]!==void 0&&Xs(s,r[o])}}if(Array.isArray(t.anyOf))for(let r of t.anyOf)typeof r!="boolean"&&Xs(r,e);if(Array.isArray(t.oneOf))for(let r of t.oneOf)typeof r!="boolean"&&Xs(r,e)}}function Nz(t){if(!t)return{supportsFormMode:!1,supportsUrlMode:!1};let e=t.form!==void 0,r=t.url!==void 0;return{supportsFormMode:e||!e&&!r,supportsUrlMode:r}}var Qs=class extends hs{constructor(e,r){super(r),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=r?.capabilities??{},this._jsonSchemaValidator=r?.jsonSchemaValidator??new Bs,r?.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",nc,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",tc,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",Ja,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new Ys(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Og(this._capabilities,e)}setRequestHandler(e,r){let o=es(e)?.method;if(!o)throw new Error("Schema is missing a method literal");let s;if(Rr(o)){let a=o;s=a._zod?.def?.value??a.value}else{let a=o;s=a._def?.value??a.value}if(typeof s!="string")throw new Error("Schema method literal must be a string");let i=s;if(i==="elicitation/create"){let a=async(c,u)=>{let l=ot(ac,c);if(!l.success){let b=l.error instanceof Error?l.error.message:String(l.error);throw new O(R.InvalidParams,`Invalid elicitation request: ${b}`)}let{params:d}=l.data;d.mode=d.mode??"form";let{supportsFormMode:p,supportsUrlMode:m}=Nz(this._capabilities.elicitation);if(d.mode==="form"&&!p)throw new O(R.InvalidParams,"Client does not support form-mode elicitation requests");if(d.mode==="url"&&!m)throw new O(R.InvalidParams,"Client does not support URL-mode elicitation requests");let h=await Promise.resolve(r(c,u));if(d.task){let b=ot(sr,h);if(!b.success){let w=b.error instanceof Error?b.error.message:String(b.error);throw new O(R.InvalidParams,`Invalid task creation result: ${w}`)}return b.data}let y=ot(cc,h);if(!y.success){let b=y.error instanceof Error?y.error.message:String(y.error);throw new O(R.InvalidParams,`Invalid elicitation result: ${b}`)}let g=y.data,v=d.mode==="form"?d.requestedSchema:void 0;if(d.mode==="form"&&g.action==="accept"&&g.content&&v&&this._capabilities.elicitation?.form?.applyDefaults)try{Xs(v,g.content)}catch{}return g};return super.setRequestHandler(e,a)}if(i==="sampling/createMessage"){let a=async(c,u)=>{let l=ot(oc,c);if(!l.success){let g=l.error instanceof Error?l.error.message:String(l.error);throw new O(R.InvalidParams,`Invalid sampling request: ${g}`)}let{params:d}=l.data,p=await Promise.resolve(r(c,u));if(d.task){let g=ot(sr,p);if(!g.success){let v=g.error instanceof Error?g.error.message:String(g.error);throw new O(R.InvalidParams,`Invalid task creation result: ${v}`)}return g.data}let h=d.tools||d.toolChoice?ic:sc,y=ot(h,p);if(!y.success){let g=y.error instanceof Error?y.error.message:String(y.error);throw new O(R.InvalidParams,`Invalid sampling result: ${g}`)}return y.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,r)}assertCapability(e,r){if(!this._serverCapabilities?.[e])throw new Error(`Server does not support ${e} (required for ${r})`)}async connect(e,r){if(await super.connect(e),e.sessionId===void 0)try{let n=await this.request({method:"initialize",params:{protocolVersion:Da,capabilities:this._capabilities,clientInfo:this._clientInfo}},Za,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!lg.includes(n.protocolVersion))throw new Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(n.protocolVersion),this._instructions=n.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(n){throw this.close(),n}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){switch(e){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw new Error(`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"initialize":break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Client does not support tasks capability (required for ${e})`);break;case"ping":break}}assertTaskCapability(e){wS(this._serverCapabilities?.tasks?.requests,e,"Server")}assertTaskHandlerCapability(e){this._capabilities&&bS(this._capabilities.tasks?.requests,e,"Client")}async ping(e){return this.request({method:"ping"},or,e)}async complete(e,r){return this.request({method:"completion/complete",params:e},uc,r)}async setLoggingLevel(e,r){return this.request({method:"logging/setLevel",params:{level:e}},or,r)}async getPrompt(e,r){return this.request({method:"prompts/get",params:e},ec,r)}async listPrompts(e,r){return this.request({method:"prompts/list",params:e},Ga,r)}async listResources(e,r){return this.request({method:"resources/list",params:e},Ha,r)}async listResourceTemplates(e,r){return this.request({method:"resources/templates/list",params:e},Wa,r)}async readResource(e,r){return this.request({method:"resources/read",params:e},Va,r)}async subscribeResource(e,r){return this.request({method:"resources/subscribe",params:e},or,r)}async unsubscribeResource(e,r){return this.request({method:"resources/unsubscribe",params:e},or,r)}async callTool(e,r=Ar,n){if(this.isToolTaskRequired(e.name))throw new O(R.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let o=await this.request({method:"tools/call",params:e},r,n),s=this.getToolOutputValidator(e.name);if(s){if(!o.structuredContent&&!o.isError)throw new O(R.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(o.structuredContent)try{let i=s(o.structuredContent);if(!i.valid)throw new O(R.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof O?i:new O(R.InvalidParams,`Failed to validate structured content: ${i instanceof Error?i.message:String(i)}`)}}return o}isToolTask(e){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(let r of e){if(r.outputSchema){let o=this._jsonSchemaValidator.getValidator(r.outputSchema);this._cachedToolOutputValidators.set(r.name,o)}let n=r.execution?.taskSupport;(n==="required"||n==="optional")&&this._cachedKnownTaskTools.add(r.name),n==="required"&&this._cachedRequiredTaskTools.add(r.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,r){let n=await this.request({method:"tools/list",params:e},rc,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(e,r,n,o){let s=$g.safeParse(n);if(!s.success)throw new Error(`Invalid ${e} listChanged options: ${s.error.message}`);if(typeof n.onChanged!="function")throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);let{autoRefresh:i,debounceMs:a}=s.data,{onChanged:c}=n,u=async()=>{if(!i){c(null,null);return}try{let d=await o();c(null,d)}catch(d){let p=d instanceof Error?d:new Error(String(d));c(p,null)}},l=()=>{if(a){let d=this._listChangedDebounceTimers.get(e);d&&clearTimeout(d);let p=setTimeout(u,a);this._listChangedDebounceTimers.set(e,p)}else u()};this.setNotificationHandler(r,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var fv=we(dv(),1),ni=we(require("node:process"),1),mv=require("node:stream");var ti=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
|
|
86
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of t.seen.entries()){let a=i[1];if(e===i[0]){s(i);continue}if(t.external){let u=t.external.registry.get(i[0])?.id;if(e!==i[0]&&u){s(i);continue}}if(t.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}if(a.count>1&&t.reused==="ref"){s(i);continue}}}function Pa(t,e){let r=t.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=t.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 m=t.seen.get(d),h=m.schema;if(h.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(h)):Object.assign(u,h),Object.assign(u,l),a._zod.parent===d)for(let g in u)g==="$ref"||g==="allOf"||g in l||delete u[g];if(h.$ref&&m.def)for(let g in u)g==="$ref"||g==="allOf"||g in m.def&&JSON.stringify(u[g])===JSON.stringify(m.def[g])&&delete u[g]}let p=a._zod.parent;if(p&&p!==d){n(p);let m=t.seen.get(p);if(m?.schema.$ref&&(u.$ref=m.schema.$ref,m.def))for(let h in u)h==="$ref"||h==="allOf"||h in m.def&&JSON.stringify(u[h])===JSON.stringify(m.def[h])&&delete u[h]}t.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(let a of[...t.seen.entries()].reverse())n(a[0]);let o={};if(t.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){let a=t.external.registry.get(e)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=t.external.uri(a)}Object.assign(o,r.def??r.schema);let s=t.metadataRegistry.get(e)?.id;s!==void 0&&o.id===s&&delete o.id;let i=t.external?.defs??{};for(let a of t.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,i[c.defId]=c.def)}t.external||Object.keys(i).length>0&&(t.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...e["~standard"],jsonSchema:{input:Pn(e,"input",t.processors),output:Pn(e,"output",t.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Te(t,e){let r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);let n=t._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Te(n.element,r);if(n.type==="set")return Te(n.valueType,r);if(n.type==="lazy")return Te(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return Te(n.innerType,r);if(n.type==="intersection")return Te(n.left,r)||Te(n.right,r);if(n.type==="record"||n.type==="map")return Te(n.keyType,r)||Te(n.valueType,r);if(n.type==="pipe")return t._zod.traits.has("$ZodCodec")?!0:Te(n.in,r)||Te(n.out,r);if(n.type==="object"){for(let o in n.shape)if(Te(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(Te(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(Te(o,r))return!0;return!!(n.rest&&Te(n.rest,r))}return!1}var ah=(t,e={})=>r=>{let n=xa({...r,processors:e});return ae(t,n),$a(n,t),Pa(n,t)},Pn=(t,e,r={})=>n=>{let{libraryOptions:o,target:s}=n??{},i=xa({...o??{},target:s,io:e,processors:r});return ae(t,i),$a(i,t),Pa(i,t)};var tb={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ch=(t,e,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u}=t._zod.bag;if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=tb[a]??a,o.format===""&&delete o.format,a==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let l=[...c];l.length===1?o.pattern=l[0].source:l.length>1&&(o.allOf=[...l.map(d=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},uh=(t,e,r,n)=>{let o=r,{minimum:s,maximum:i,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=t._zod.bag;typeof a=="string"&&a.includes("int")?o.type="integer":o.type="number";let d=typeof l=="number"&&l>=(s??Number.NEGATIVE_INFINITY),p=typeof u=="number"&&u<=(i??Number.POSITIVE_INFINITY),m=e.target==="draft-04"||e.target==="openapi-3.0";d?m?(o.minimum=l,o.exclusiveMinimum=!0):o.exclusiveMinimum=l:typeof s=="number"&&(o.minimum=s),p?m?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u:typeof i=="number"&&(o.maximum=i),typeof c=="number"&&(o.multipleOf=c)},lh=(t,e,r,n)=>{r.type="boolean"};var dh=(t,e,r,n)=>{e.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var ph=(t,e,r,n)=>{r.not={}};var fh=(t,e,r,n)=>{};var mh=(t,e,r,n)=>{let o=t._zod.def,s=_n(o.entries);s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},hh=(t,e,r,n)=>{let o=t._zod.def,s=[];for(let i of o.values)if(i===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");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,e.target==="draft-04"||e.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 gh=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")};var _h=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")};var yh=(t,e,r,n)=>{let o=r,s=t._zod.def,{minimum:i,maximum:a}=t._zod.bag;typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=ae(s.element,e,{...n,path:[...n.path,"items"]})},Sh=(t,e,r,n)=>{let o=r,s=t._zod.def;o.type="object",o.properties={};let i=s.shape;for(let u in i)o.properties[u]=ae(i[u],e,{...n,path:[...n.path,"properties",u]});let a=new Set(Object.keys(i)),c=new Set([...a].filter(u=>{let l=s.shape[u]._zod;return e.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(o.required=Array.from(c)),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=ae(s.catchall,e,{...n,path:[...n.path,"additionalProperties"]})):e.io==="output"&&(o.additionalProperties=!1)},vh=(t,e,r,n)=>{let o=t._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>ae(a,e,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=i:r.anyOf=i},Eh=(t,e,r,n)=>{let o=t._zod.def,s=ae(o.left,e,{...n,path:[...n.path,"allOf",0]}),i=ae(o.right,e,{...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};var wh=(t,e,r,n)=>{let o=r,s=t._zod.def;o.type="object";let i=s.keyType,c=i._zod.bag?.patterns;if(s.mode==="loose"&&c&&c.size>0){let l=ae(s.valueType,e,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of c)o.patternProperties[d.source]=l}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(o.propertyNames=ae(s.keyType,e,{...n,path:[...n.path,"propertyNames"]})),o.additionalProperties=ae(s.valueType,e,{...n,path:[...n.path,"additionalProperties"]});let u=i._zod.values;if(u){let l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l)}},bh=(t,e,r,n)=>{let o=t._zod.def,s=ae(o.innerType,e,n),i=e.seen.get(t);e.target==="openapi-3.0"?(i.ref=o.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},kh=(t,e,r,n)=>{let o=t._zod.def;ae(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType},xh=(t,e,r,n)=>{let o=t._zod.def;ae(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},$h=(t,e,r,n)=>{let o=t._zod.def;ae(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType,e.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Ph=(t,e,r,n)=>{let o=t._zod.def;ae(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=i},Th=(t,e,r,n)=>{let o=t._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=e.io==="input"?s?o.out:o.in:o.out;ae(i,e,n);let a=e.seen.get(t);a.ref=i},Oh=(t,e,r,n)=>{let o=t._zod.def;ae(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType,r.readOnly=!0};var Ta=(t,e,r,n)=>{let o=t._zod.def;ae(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType};function Rr(t){return!!t._zod}function ot(t,e){return Rr(t)?wn(t,e):t.safeParse(e)}function es(t){if(!t)return;let e;if(Rr(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function zh(t){if(Rr(t)){let s=t._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=t._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=t.value;if(n!==void 0)return n}var On={};Rl(On,{ZodISODate:()=>Ih,ZodISODateTime:()=>Rh,ZodISODuration:()=>Ah,ZodISOTime:()=>Ch,date:()=>za,datetime:()=>Oa,duration:()=>Ia,time:()=>Ra});var Rh=S("ZodISODateTime",(t,e)=>{Uf.init(t,e),ne.init(t,e)});function Oa(t){return Km(Rh,t)}var Ih=S("ZodISODate",(t,e)=>{Ff.init(t,e),ne.init(t,e)});function za(t){return Jm(Ih,t)}var Ch=S("ZodISOTime",(t,e)=>{Zf.init(t,e),ne.init(t,e)});function Ra(t){return Gm(Ch,t)}var Ah=S("ZodISODuration",(t,e)=>{qf.init(t,e),ne.init(t,e)});function Ia(t){return Bm(Ah,t)}var lb=(t,e)=>{Uo.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>wp(t,r)},flatten:{value:r=>Ep(t,r)},addIssue:{value:r=>{t.issues.push(r),t.message=JSON.stringify(t.issues,Pr,2)}},addIssues:{value:r=>{t.issues.push(...r),t.message=JSON.stringify(t.issues,Pr,2)}},isEmpty:{get(){return t.issues.length===0}}})};var qe=S("ZodError",lb,{Parent:Error});var Mh=Fo(qe),Nh=Zo(qe),Dh=En(qe),Lh=bn(qe),jh=bp(qe),Uh=kp(qe),Fh=xp(qe),Zh=$p(qe),qh=Pp(qe),Hh=Tp(qe),Wh=Op(qe),Vh=zp(qe);var Kh=new WeakMap;function zn(t,e,r){let n=Object.getPrototypeOf(t),o=Kh.get(n);if(o||(o=new Set,Kh.set(n,o)),!o.has(e)){o.add(e);for(let s in r){let i=r[s];Object.defineProperty(n,s,{configurable:!0,enumerable:!1,get(){let a=i.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}var ie=S("ZodType",(t,e)=>(X.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:Pn(t,"input"),output:Pn(t,"output")}}),t.toJSONSchema=ah(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.parse=(r,n)=>Mh(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Dh(t,r,n),t.parseAsync=async(r,n)=>Nh(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>Lh(t,r,n),t.spa=t.safeParseAsync,t.encode=(r,n)=>jh(t,r,n),t.decode=(r,n)=>Uh(t,r,n),t.encodeAsync=async(r,n)=>Fh(t,r,n),t.decodeAsync=async(r,n)=>Zh(t,r,n),t.safeEncode=(r,n)=>qh(t,r,n),t.safeDecode=(r,n)=>Hh(t,r,n),t.safeEncodeAsync=async(r,n)=>Wh(t,r,n),t.safeDecodeAsync=async(r,n)=>Vh(t,r,n),zn(t,"ZodType",{check(...r){let n=this.def;return this.clone(F.mergeDefs(n,{checks:[...n.checks??[],...r.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,n){return nt(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(ek(r,n))},superRefine(r,n){return this.check(tk(r,n))},overwrite(r){return this.check(Dt(r))},optional(){return se(this)},exactOptional(){return Zb(this)},nullable(){return Yh(this)},nullish(){return se(Yh(this))},nonoptional(r){return Jb(this,r)},array(){return j(this)},or(r){return ee([this,r])},and(r){return rs(this,r)},transform(r){return Xh(this,og(r))},default(r){return Wb(this,r)},prefault(r){return Kb(this,r)},catch(r){return Bb(this,r)},pipe(r){return Xh(this,r)},readonly(){return Qb(this)},describe(r){let n=this.clone();return nr.add(n,{description:r}),n},meta(...r){if(r.length===0)return nr.get(this);let n=this.clone();return nr.add(n,r[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(t,"description",{get(){return nr.get(t)?.description},configurable:!0}),t)),Qh=S("_ZodString",(t,e)=>{Jo.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(n,o,s)=>ch(t,n,o,s);let r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,zn(t,"_ZodString",{regex(...n){return this.check(ma(...n))},includes(...n){return this.check(_a(...n))},startsWith(...n){return this.check(ya(...n))},endsWith(...n){return this.check(Sa(...n))},min(...n){return this.check(zr(...n))},max(...n){return this.check(Xo(...n))},length(...n){return this.check(Qo(...n))},nonempty(...n){return this.check(zr(1,...n))},lowercase(n){return this.check(ha(n))},uppercase(n){return this.check(ga(n))},trim(){return this.check(Ea())},normalize(...n){return this.check(va(...n))},toLowerCase(){return this.check(wa())},toUpperCase(){return this.check(ba())},slugify(){return this.check(ka())}})}),pb=S("ZodString",(t,e)=>{Jo.init(t,e),Qh.init(t,e),t.email=r=>t.check($m(fb,r)),t.url=r=>t.check(Rm(mb,r)),t.jwt=r=>t.check(Vm(Ob,r)),t.emoji=r=>t.check(Im(hb,r)),t.guid=r=>t.check(fa(Jh,r)),t.uuid=r=>t.check(Pm(ts,r)),t.uuidv4=r=>t.check(Tm(ts,r)),t.uuidv6=r=>t.check(Om(ts,r)),t.uuidv7=r=>t.check(zm(ts,r)),t.nanoid=r=>t.check(Cm(gb,r)),t.guid=r=>t.check(fa(Jh,r)),t.cuid=r=>t.check(Am(_b,r)),t.cuid2=r=>t.check(Mm(yb,r)),t.ulid=r=>t.check(Nm(Sb,r)),t.base64=r=>t.check(qm($b,r)),t.base64url=r=>t.check(Hm(Pb,r)),t.xid=r=>t.check(Dm(vb,r)),t.ksuid=r=>t.check(Lm(Eb,r)),t.ipv4=r=>t.check(jm(wb,r)),t.ipv6=r=>t.check(Um(bb,r)),t.cidrv4=r=>t.check(Fm(kb,r)),t.cidrv6=r=>t.check(Zm(xb,r)),t.e164=r=>t.check(Wm(Tb,r)),t.datetime=r=>t.check(Oa(r)),t.date=r=>t.check(za(r)),t.time=r=>t.check(Ra(r)),t.duration=r=>t.check(Ia(r))});function _(t){return xm(pb,t)}var ne=S("ZodStringFormat",(t,e)=>{Q.init(t,e),Qh.init(t,e)}),fb=S("ZodEmail",(t,e)=>{Rf.init(t,e),ne.init(t,e)});var Jh=S("ZodGUID",(t,e)=>{Of.init(t,e),ne.init(t,e)});var ts=S("ZodUUID",(t,e)=>{zf.init(t,e),ne.init(t,e)});var mb=S("ZodURL",(t,e)=>{If.init(t,e),ne.init(t,e)});var hb=S("ZodEmoji",(t,e)=>{Cf.init(t,e),ne.init(t,e)});var gb=S("ZodNanoID",(t,e)=>{Af.init(t,e),ne.init(t,e)});var _b=S("ZodCUID",(t,e)=>{Mf.init(t,e),ne.init(t,e)});var yb=S("ZodCUID2",(t,e)=>{Nf.init(t,e),ne.init(t,e)});var Sb=S("ZodULID",(t,e)=>{Df.init(t,e),ne.init(t,e)});var vb=S("ZodXID",(t,e)=>{Lf.init(t,e),ne.init(t,e)});var Eb=S("ZodKSUID",(t,e)=>{jf.init(t,e),ne.init(t,e)});var wb=S("ZodIPv4",(t,e)=>{Hf.init(t,e),ne.init(t,e)});var bb=S("ZodIPv6",(t,e)=>{Wf.init(t,e),ne.init(t,e)});var kb=S("ZodCIDRv4",(t,e)=>{Vf.init(t,e),ne.init(t,e)});var xb=S("ZodCIDRv6",(t,e)=>{Kf.init(t,e),ne.init(t,e)});var $b=S("ZodBase64",(t,e)=>{Gf.init(t,e),ne.init(t,e)});var Pb=S("ZodBase64URL",(t,e)=>{Bf.init(t,e),ne.init(t,e)});var Tb=S("ZodE164",(t,e)=>{Yf.init(t,e),ne.init(t,e)});var Ob=S("ZodJWT",(t,e)=>{Xf.init(t,e),ne.init(t,e)});var eg=S("ZodNumber",(t,e)=>{ca.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(n,o,s)=>uh(t,n,o,s),zn(t,"ZodNumber",{gt(n,o){return this.check(Bo(n,o))},gte(n,o){return this.check($n(n,o))},min(n,o){return this.check($n(n,o))},lt(n,o){return this.check(Go(n,o))},lte(n,o){return this.check(xn(n,o))},max(n,o){return this.check(xn(n,o))},int(n){return this.check(Gh(n))},safe(n){return this.check(Gh(n))},positive(n){return this.check(Bo(0,n))},nonnegative(n){return this.check($n(0,n))},negative(n){return this.check(Go(0,n))},nonpositive(n){return this.check(xn(0,n))},multipleOf(n,o){return this.check(Yo(n,o))},step(n,o){return this.check(Yo(n,o))},finite(){return this}});let r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null});function K(t){return Ym(eg,t)}var zb=S("ZodNumberFormat",(t,e)=>{Qf.init(t,e),eg.init(t,e)});function Gh(t){return Xm(zb,t)}var Rb=S("ZodBoolean",(t,e)=>{em.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>lh(t,r,n,o)});function pe(t){return Qm(Rb,t)}var Ib=S("ZodNull",(t,e)=>{tm.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>dh(t,r,n,o)});function tg(t){return eh(Ib,t)}var Cb=S("ZodUnknown",(t,e)=>{rm.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>fh(t,r,n,o)});function oe(){return th(Cb)}var Ab=S("ZodNever",(t,e)=>{nm.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>ph(t,r,n,o)});function Mb(t){return rh(Ab,t)}var Nb=S("ZodArray",(t,e)=>{om.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>yh(t,r,n,o),t.element=e.element,zn(t,"ZodArray",{min(r,n){return this.check(zr(r,n))},nonempty(r){return this.check(zr(1,r))},max(r,n){return this.check(Xo(r,n))},length(r,n){return this.check(Qo(r,n))},unwrap(){return this.element}})});function j(t,e){return nh(Nb,t,e)}var rg=S("ZodObject",(t,e)=>{am.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Sh(t,r,n,o),F.defineLazy(t,"shape",()=>e.shape),zn(t,"ZodObject",{keyof(){return Ae(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:oe()})},loose(){return this.clone({...this._zod.def,catchall:oe()})},strict(){return this.clone({...this._zod.def,catchall:Mb()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return F.extend(this,r)},safeExtend(r){return F.safeExtend(this,r)},merge(r){return F.merge(this,r)},pick(r){return F.pick(this,r)},omit(r){return F.omit(this,r)},partial(...r){return F.partial(sg,this,r[0])},required(...r){return F.required(ig,this,r[0])}})});function k(t,e){let r={type:"object",shape:t??{},...F.normalizeParams(e)};return new rg(r)}function Oe(t,e){return new rg({type:"object",shape:t,catchall:oe(),...F.normalizeParams(e)})}var ng=S("ZodUnion",(t,e)=>{ua.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>vh(t,r,n,o),t.options=e.options});function ee(t,e){return new ng({type:"union",options:t,...F.normalizeParams(e)})}var Db=S("ZodDiscriminatedUnion",(t,e)=>{ng.init(t,e),cm.init(t,e)});function Aa(t,e,r){return new Db({type:"union",options:e,discriminator:t,...F.normalizeParams(r)})}var Lb=S("ZodIntersection",(t,e)=>{um.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Eh(t,r,n,o)});function rs(t,e){return new Lb({type:"intersection",left:t,right:e})}var Bh=S("ZodRecord",(t,e)=>{lm.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>wh(t,r,n,o),t.keyType=e.keyType,t.valueType=e.valueType});function Y(t,e,r){return!e||!e._zod?new Bh({type:"record",keyType:_(),valueType:t,...F.normalizeParams(e)}):new Bh({type:"record",keyType:t,valueType:e,...F.normalizeParams(r)})}var Ca=S("ZodEnum",(t,e)=>{dm.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(n,o,s)=>mh(t,n,o,s),t.enum=e.entries,t.options=Object.values(e.entries);let r=new Set(Object.keys(e.entries));t.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Ca({...e,checks:[],...F.normalizeParams(o),entries:s})},t.exclude=(n,o)=>{let s={...e.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 Ca({...e,checks:[],...F.normalizeParams(o),entries:s})}});function Ae(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new Ca({type:"enum",entries:r,...F.normalizeParams(e)})}var jb=S("ZodLiteral",(t,e)=>{pm.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>hh(t,r,n,o),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function P(t,e){return new jb({type:"literal",values:Array.isArray(t)?t:[t],...F.normalizeParams(e)})}var Ub=S("ZodTransform",(t,e)=>{fm.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>_h(t,r,n,o),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new xr(t.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(F.issue(s,r.value,e));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=t),r.issues.push(F.issue(i))}};let o=e.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r.fallback=!0,r)):(r.value=o,r.fallback=!0,r)}});function og(t){return new Ub({type:"transform",transform:t})}var sg=S("ZodOptional",(t,e)=>{la.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Ta(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function se(t){return new sg({type:"optional",innerType:t})}var Fb=S("ZodExactOptional",(t,e)=>{mm.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Ta(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function Zb(t){return new Fb({type:"optional",innerType:t})}var qb=S("ZodNullable",(t,e)=>{hm.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>bh(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function Yh(t){return new qb({type:"nullable",innerType:t})}var Hb=S("ZodDefault",(t,e)=>{gm.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>xh(t,r,n,o),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function Wb(t,e){return new Hb({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():F.shallowClone(e)}})}var Vb=S("ZodPrefault",(t,e)=>{_m.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>$h(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function Kb(t,e){return new Vb({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():F.shallowClone(e)}})}var ig=S("ZodNonOptional",(t,e)=>{ym.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>kh(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function Jb(t,e){return new ig({type:"nonoptional",innerType:t,...F.normalizeParams(e)})}var Gb=S("ZodCatch",(t,e)=>{Sm.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Ph(t,r,n,o),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function Bb(t,e){return new Gb({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var ag=S("ZodPipe",(t,e)=>{da.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Th(t,r,n,o),t.in=e.in,t.out=e.out});function Xh(t,e){return new ag({type:"pipe",in:t,out:e})}var Yb=S("ZodPreprocess",(t,e)=>{ag.init(t,e),vm.init(t,e)}),Xb=S("ZodReadonly",(t,e)=>{Em.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Oh(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function Qb(t){return new Xb({type:"readonly",innerType:t})}var cg=S("ZodCustom",(t,e)=>{wm.init(t,e),ie.init(t,e),t._zod.processJSONSchema=(r,n,o)=>gh(t,r,n,o)});function ug(t,e){return oh(cg,t??(()=>!0),e)}function ek(t,e={}){return sh(cg,t,e)}function tk(t,e){return ih(t,e)}function Ma(t,e){return new Yb({type:"pipe",in:og(t),out:e})}Ze(bm());var Da="2025-11-25";var lg=[Da,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Lt="io.modelcontextprotocol/related-task",os="2.0",de=ug(t=>t!==null&&(typeof t=="object"||typeof t=="function")),dg=ee([_(),K().int()]),pg=_(),AN=Oe({ttl:K().optional(),pollInterval:K().optional()}),rk=k({ttl:K().optional()}),nk=k({taskId:_()}),La=Oe({progressToken:dg.optional(),[Lt]:nk.optional()}),He=k({_meta:La.optional()}),Rn=He.extend({task:rk.optional()}),fg=t=>Rn.safeParse(t).success,_e=k({method:_(),params:He.loose().optional()}),Ge=k({_meta:La.optional()}),Be=k({method:_(),params:Ge.loose().optional()}),ye=Oe({_meta:La.optional()}),ss=ee([_(),K().int()]),mg=k({jsonrpc:P(os),id:ss,..._e.shape}).strict(),ja=t=>mg.safeParse(t).success,hg=k({jsonrpc:P(os),...Be.shape}).strict(),gg=t=>hg.safeParse(t).success,Ua=k({jsonrpc:P(os),id:ss,result:ye}).strict(),In=t=>Ua.safeParse(t).success;var R;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(R||(R={}));var Fa=k({jsonrpc:P(os),id:ss.optional(),error:k({code:K().int(),message:_(),data:oe().optional()})}).strict();var _g=t=>Fa.safeParse(t).success;var yg=ee([mg,hg,Ua,Fa]),MN=ee([Ua,Fa]),or=ye.strict(),ok=Ge.extend({requestId:ss.optional(),reason:_().optional()}),is=Be.extend({method:P("notifications/cancelled"),params:ok}),sk=k({src:_(),mimeType:_().optional(),sizes:j(_()).optional(),theme:Ae(["light","dark"]).optional()}),Cn=k({icons:j(sk).optional()}),Ir=k({name:_(),title:_().optional()}),Sg=Ir.extend({...Ir.shape,...Cn.shape,version:_(),websiteUrl:_().optional(),description:_().optional()}),ik=rs(k({applyDefaults:pe().optional()}),Y(_(),oe())),ak=Ma(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,rs(k({form:ik.optional(),url:de.optional()}),Y(_(),oe()).optional())),ck=Oe({list:de.optional(),cancel:de.optional(),requests:Oe({sampling:Oe({createMessage:de.optional()}).optional(),elicitation:Oe({create:de.optional()}).optional()}).optional()}),uk=Oe({list:de.optional(),cancel:de.optional(),requests:Oe({tools:Oe({call:de.optional()}).optional()}).optional()}),lk=k({experimental:Y(_(),de).optional(),sampling:k({context:de.optional(),tools:de.optional()}).optional(),elicitation:ak.optional(),roots:k({listChanged:pe().optional()}).optional(),tasks:ck.optional(),extensions:Y(_(),de).optional()}),dk=He.extend({protocolVersion:_(),capabilities:lk,clientInfo:Sg}),pk=_e.extend({method:P("initialize"),params:dk});var fk=k({experimental:Y(_(),de).optional(),logging:de.optional(),completions:de.optional(),prompts:k({listChanged:pe().optional()}).optional(),resources:k({subscribe:pe().optional(),listChanged:pe().optional()}).optional(),tools:k({listChanged:pe().optional()}).optional(),tasks:uk.optional(),extensions:Y(_(),de).optional()}),Za=ye.extend({protocolVersion:_(),capabilities:fk,serverInfo:Sg,instructions:_().optional()}),mk=Be.extend({method:P("notifications/initialized"),params:Ge.optional()});var as=_e.extend({method:P("ping"),params:He.optional()}),hk=k({progress:K(),total:se(K()),message:se(_())}),gk=k({...Ge.shape,...hk.shape,progressToken:dg}),cs=Be.extend({method:P("notifications/progress"),params:gk}),_k=He.extend({cursor:pg.optional()}),An=_e.extend({params:_k.optional()}),Mn=ye.extend({nextCursor:pg.optional()}),yk=Ae(["working","input_required","completed","failed","cancelled"]),Nn=k({taskId:_(),status:yk,ttl:ee([K(),tg()]),createdAt:_(),lastUpdatedAt:_(),pollInterval:se(K()),statusMessage:se(_())}),sr=ye.extend({task:Nn}),Sk=Ge.merge(Nn),Dn=Be.extend({method:P("notifications/tasks/status"),params:Sk}),us=_e.extend({method:P("tasks/get"),params:He.extend({taskId:_()})}),ls=ye.merge(Nn),ds=_e.extend({method:P("tasks/result"),params:He.extend({taskId:_()})}),NN=ye.loose(),ps=An.extend({method:P("tasks/list")}),fs=Mn.extend({tasks:j(Nn)}),ms=_e.extend({method:P("tasks/cancel"),params:He.extend({taskId:_()})}),vg=ye.merge(Nn),Eg=k({uri:_(),mimeType:se(_()),_meta:Y(_(),oe()).optional()}),wg=Eg.extend({text:_()}),qa=_().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),bg=Eg.extend({blob:qa}),Ln=Ae(["user","assistant"]),Cr=k({audience:j(Ln).optional(),priority:K().min(0).max(1).optional(),lastModified:On.datetime({offset:!0}).optional()}),kg=k({...Ir.shape,...Cn.shape,uri:_(),description:se(_()),mimeType:se(_()),size:se(K()),annotations:Cr.optional(),_meta:se(Oe({}))}),vk=k({...Ir.shape,...Cn.shape,uriTemplate:_(),description:se(_()),mimeType:se(_()),annotations:Cr.optional(),_meta:se(Oe({}))}),Ek=An.extend({method:P("resources/list")}),Ha=Mn.extend({resources:j(kg)}),wk=An.extend({method:P("resources/templates/list")}),Wa=Mn.extend({resourceTemplates:j(vk)}),Va=He.extend({uri:_()}),bk=Va,kk=_e.extend({method:P("resources/read"),params:bk}),Ka=ye.extend({contents:j(ee([wg,bg]))}),Ja=Be.extend({method:P("notifications/resources/list_changed"),params:Ge.optional()}),xk=Va,$k=_e.extend({method:P("resources/subscribe"),params:xk}),Pk=Va,Tk=_e.extend({method:P("resources/unsubscribe"),params:Pk}),Ok=Ge.extend({uri:_()}),zk=Be.extend({method:P("notifications/resources/updated"),params:Ok}),Rk=k({name:_(),description:se(_()),required:se(pe())}),Ik=k({...Ir.shape,...Cn.shape,description:se(_()),arguments:se(j(Rk)),_meta:se(Oe({}))}),Ck=An.extend({method:P("prompts/list")}),Ga=Mn.extend({prompts:j(Ik)}),Ak=He.extend({name:_(),arguments:Y(_(),_()).optional()}),Mk=_e.extend({method:P("prompts/get"),params:Ak}),Ba=k({type:P("text"),text:_(),annotations:Cr.optional(),_meta:Y(_(),oe()).optional()}),Ya=k({type:P("image"),data:qa,mimeType:_(),annotations:Cr.optional(),_meta:Y(_(),oe()).optional()}),Xa=k({type:P("audio"),data:qa,mimeType:_(),annotations:Cr.optional(),_meta:Y(_(),oe()).optional()}),Nk=k({type:P("tool_use"),name:_(),id:_(),input:Y(_(),oe()),_meta:Y(_(),oe()).optional()}),Dk=k({type:P("resource"),resource:ee([wg,bg]),annotations:Cr.optional(),_meta:Y(_(),oe()).optional()}),Lk=kg.extend({type:P("resource_link")}),Qa=ee([Ba,Ya,Xa,Lk,Dk]),jk=k({role:Ln,content:Qa}),ec=ye.extend({description:_().optional(),messages:j(jk)}),tc=Be.extend({method:P("notifications/prompts/list_changed"),params:Ge.optional()}),Uk=k({title:_().optional(),readOnlyHint:pe().optional(),destructiveHint:pe().optional(),idempotentHint:pe().optional(),openWorldHint:pe().optional()}),Fk=k({taskSupport:Ae(["required","optional","forbidden"]).optional()}),xg=k({...Ir.shape,...Cn.shape,description:_().optional(),inputSchema:k({type:P("object"),properties:Y(_(),de).optional(),required:j(_()).optional()}).catchall(oe()),outputSchema:k({type:P("object"),properties:Y(_(),de).optional(),required:j(_()).optional()}).catchall(oe()).optional(),annotations:Uk.optional(),execution:Fk.optional(),_meta:Y(_(),oe()).optional()}),Zk=An.extend({method:P("tools/list")}),rc=Mn.extend({tools:j(xg)}),Ar=ye.extend({content:j(Qa).default([]),structuredContent:Y(_(),oe()).optional(),isError:pe().optional()}),DN=Ar.or(ye.extend({toolResult:oe()})),qk=Rn.extend({name:_(),arguments:Y(_(),oe()).optional()}),Hk=_e.extend({method:P("tools/call"),params:qk}),nc=Be.extend({method:P("notifications/tools/list_changed"),params:Ge.optional()}),$g=k({autoRefresh:pe().default(!0),debounceMs:K().int().nonnegative().default(300)}),Pg=Ae(["debug","info","notice","warning","error","critical","alert","emergency"]),Wk=He.extend({level:Pg}),Vk=_e.extend({method:P("logging/setLevel"),params:Wk}),Kk=Ge.extend({level:Pg,logger:_().optional(),data:oe()}),Jk=Be.extend({method:P("notifications/message"),params:Kk}),Gk=k({name:_().optional()}),Bk=k({hints:j(Gk).optional(),costPriority:K().min(0).max(1).optional(),speedPriority:K().min(0).max(1).optional(),intelligencePriority:K().min(0).max(1).optional()}),Yk=k({mode:Ae(["auto","required","none"]).optional()}),Xk=k({type:P("tool_result"),toolUseId:_().describe("The unique identifier for the corresponding tool call."),content:j(Qa).default([]),structuredContent:k({}).loose().optional(),isError:pe().optional(),_meta:Y(_(),oe()).optional()}),Qk=Aa("type",[Ba,Ya,Xa]),ns=Aa("type",[Ba,Ya,Xa,Nk,Xk]),ex=k({role:Ln,content:ee([ns,j(ns)]),_meta:Y(_(),oe()).optional()}),tx=Rn.extend({messages:j(ex),modelPreferences:Bk.optional(),systemPrompt:_().optional(),includeContext:Ae(["none","thisServer","allServers"]).optional(),temperature:K().optional(),maxTokens:K().int(),stopSequences:j(_()).optional(),metadata:de.optional(),tools:j(xg).optional(),toolChoice:Yk.optional()}),oc=_e.extend({method:P("sampling/createMessage"),params:tx}),sc=ye.extend({model:_(),stopReason:se(Ae(["endTurn","stopSequence","maxTokens"]).or(_())),role:Ln,content:Qk}),ic=ye.extend({model:_(),stopReason:se(Ae(["endTurn","stopSequence","maxTokens","toolUse"]).or(_())),role:Ln,content:ee([ns,j(ns)])}),rx=k({type:P("boolean"),title:_().optional(),description:_().optional(),default:pe().optional()}),nx=k({type:P("string"),title:_().optional(),description:_().optional(),minLength:K().optional(),maxLength:K().optional(),format:Ae(["email","uri","date","date-time"]).optional(),default:_().optional()}),ox=k({type:Ae(["number","integer"]),title:_().optional(),description:_().optional(),minimum:K().optional(),maximum:K().optional(),default:K().optional()}),sx=k({type:P("string"),title:_().optional(),description:_().optional(),enum:j(_()),default:_().optional()}),ix=k({type:P("string"),title:_().optional(),description:_().optional(),oneOf:j(k({const:_(),title:_()})),default:_().optional()}),ax=k({type:P("string"),title:_().optional(),description:_().optional(),enum:j(_()),enumNames:j(_()).optional(),default:_().optional()}),cx=ee([sx,ix]),ux=k({type:P("array"),title:_().optional(),description:_().optional(),minItems:K().optional(),maxItems:K().optional(),items:k({type:P("string"),enum:j(_())}),default:j(_()).optional()}),lx=k({type:P("array"),title:_().optional(),description:_().optional(),minItems:K().optional(),maxItems:K().optional(),items:k({anyOf:j(k({const:_(),title:_()}))}),default:j(_()).optional()}),dx=ee([ux,lx]),px=ee([ax,cx,dx]),fx=ee([px,rx,nx,ox]),mx=Rn.extend({mode:P("form").optional(),message:_(),requestedSchema:k({type:P("object"),properties:Y(_(),fx),required:j(_()).optional()})}),hx=Rn.extend({mode:P("url"),message:_(),elicitationId:_(),url:_().url()}),gx=ee([mx,hx]),ac=_e.extend({method:P("elicitation/create"),params:gx}),_x=Ge.extend({elicitationId:_()}),yx=Be.extend({method:P("notifications/elicitation/complete"),params:_x}),cc=ye.extend({action:Ae(["accept","decline","cancel"]),content:Ma(t=>t===null?void 0:t,Y(_(),ee([_(),K(),pe(),j(_())])).optional())}),Sx=k({type:P("ref/resource"),uri:_()});var vx=k({type:P("ref/prompt"),name:_()}),Ex=He.extend({ref:ee([vx,Sx]),argument:k({name:_(),value:_()}),context:k({arguments:Y(_(),_()).optional()}).optional()}),wx=_e.extend({method:P("completion/complete"),params:Ex});var uc=ye.extend({completion:Oe({values:j(_()).max(100),total:se(K().int()),hasMore:se(pe())})}),bx=k({uri:_().startsWith("file://"),name:_().optional(),_meta:Y(_(),oe()).optional()}),kx=_e.extend({method:P("roots/list"),params:He.optional()}),xx=ye.extend({roots:j(bx)}),$x=Be.extend({method:P("notifications/roots/list_changed"),params:Ge.optional()}),LN=ee([as,pk,wx,Vk,Mk,Ck,Ek,wk,kk,$k,Tk,Hk,Zk,us,ds,ps,ms]),jN=ee([is,cs,mk,$x,Dn]),UN=ee([or,sc,ic,cc,xx,ls,fs,sr]),FN=ee([as,oc,ac,kx,us,ds,ps,ms]),ZN=ee([is,cs,Jk,zk,Ja,nc,tc,Dn,yx]),qN=ee([or,Za,uc,ec,Ga,Ha,Wa,Ka,Ar,rc,ls,fs,sr]),O=class t extends Error{constructor(e,r,n){super(`MCP error ${e}: ${r}`),this.code=e,this.data=n,this.name="McpError"}static fromError(e,r,n){if(e===R.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new Na(o.elicitations,r)}return new t(e,r,n)}},Na=class extends O{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(R.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function jt(t){return t==="completed"||t==="failed"||t==="cancelled"}var wD=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function lc(t){let r=es(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=zh(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function dc(t,e){let r=ot(t,e);if(!r.success)throw r.error;return r.data}var Ix=6e4,hs=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(is,r=>{this._oncancel(r)}),this.setNotificationHandler(cs,r=>{this._onprogress(r)}),this.setRequestHandler(as,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(us,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new O(R.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(ds,async(r,n)=>{let o=async()=>{let s=r.params.taskId;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,p=new O(d.error.code,d.error.message,d.error.data);l(p)}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 O(R.InvalidParams,`Task not found: ${s}`);if(!jt(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(jt(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[Lt]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(ps,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 O(R.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(ms,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new O(R.InvalidParams,`Task not found: ${r.params.taskId}`);if(jt(o.status))throw new O(R.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new O(R.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof O?o:new O(R.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,n,o,s=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),O.fromError(R.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){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=e;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),In(s)||_g(s)?this._onresponse(s):ja(s)?this._onrequest(s,i):gg(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let e=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=O.fromError(R.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of e.values())n(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(e,r){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,o=this._transport,s=e.params?._meta?.[Lt]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:R.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);let a=fg(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let d={relatedRequestId:e.id};s&&(d.relatedTask={taskId:s}),await this.notification(l,d)},sendRequest:async(l,d,p)=>{if(i.signal.aborted)throw new O(R.ConnectionClosed,"Request was cancelled");let m={...p,relatedRequestId:e.id};s&&!m.relatedTask&&(m.relatedTask={taskId:s});let h=m.relatedTask?.taskId??s;return h&&c&&await c.updateTaskStatus(h,"input_required"),await this.request(l,d,m)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,u)).then(async l=>{if(i.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:e.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:R.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===i&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...n}=e.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(e)}`));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(e){let r=Number(e.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),In(e))n(e);else{let i=new O(e.error.code,e.error.message,e.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(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if(In(e)&&e.result&&typeof e.result=="object"){let i=e.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),In(e))o(e);else{let i=O.fromError(e.error.code,e.error.message,e.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(e,r,n)}}catch(i){yield{type:"error",error:i instanceof O?i:new O(R.InternalError,String(i))}}return}let s;try{let i=await this.request(e,sr,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new O(R.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},jt(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new O(R.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new O(R.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 O?i:new O(R.InternalError,String(i))}}}request(e,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=b=>{l(b)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(b){d(b);return}n?.signal?.throwIfAborted();let p=this._requestMessageId++,m={...e,jsonrpc:"2.0",id:p};n?.onprogress&&(this._progressHandlers.set(p,n.onprogress),m.params={...e.params,_meta:{...e.params?._meta||{},progressToken:p}}),a&&(m.params={...m.params,task:a}),c&&(m.params={...m.params,_meta:{...m.params?._meta||{},[Lt]:c}});let h=b=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(b)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch($=>this._onerror(new Error(`Failed to send cancellation: ${$}`)));let w=b instanceof O?b:new O(R.RequestTimeout,String(b));l(w)};this._responseHandlers.set(p,b=>{if(!n?.signal?.aborted){if(b instanceof Error)return l(b);try{let w=ot(r,b.result);w.success?u(w.data):l(w.error)}catch(w){l(w)}}}),n?.signal?.addEventListener("abort",()=>{h(n?.signal?.reason)});let y=n?.timeout??Ix,g=()=>h(O.fromError(R.RequestTimeout,"Request timed out",{timeout:y}));this._setupTimeout(p,y,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let v=c?.taskId;if(v){let b=w=>{let $=this._responseHandlers.get(p);$?$(w):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,b),this._enqueueTaskMessage(v,{type:"request",message:m,timestamp:Date.now()}).catch(w=>{this._cleanupTimeout(p),l(w)})}else this._transport.send(m,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(b=>{this._cleanupTimeout(p),l(b)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},ls,r)}async getTaskResult(e,r,n){return this.request({method:"tasks/result",params:e},r,n)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},fs,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},vg,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let n=r?.relatedTask?.taskId;if(n){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[Lt]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Lt]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[Lt]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let n=lc(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=dc(e,o);return Promise.resolve(r(i,s))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){let n=lc(e);this._notificationHandlers.set(n,o=>{let s=dc(e,o);return Promise.resolve(r(s))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,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(e,r,n,o)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,r);for(let o of n)if(o.type==="request"&&ja(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new O(R.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(e);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new O(R.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new O(R.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!e)throw new Error("No request provided");return await n.createTask(o,e.id,{method:e.method,params:e.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new O(R.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=Dn.parse({method:"notifications/tasks/status",params:a});await this.notification(c),jt(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 O(R.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(jt(a.status))throw new O(R.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=Dn.parse({method:"notifications/tasks/status",params:c});await this.notification(u),jt(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function Tg(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Og(t,e){let r={...t};for(let n in e){let o=n,s=e[o];if(s===void 0)continue;let i=r[o];Tg(i)&&Tg(s)?r[o]={...i,...s}:r[o]=s}return r}var vS=we(Yu(),1),ES=we(SS(),1);function Mz(){let t=new vS.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,ES.default)(t),t}var Bs=class{constructor(e){this._ajv=e??Mz()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var Ys=class{constructor(e){this._client=e}async*callToolStream(e,r=Ar,n){let o=this._client,s={...n,task:n?.task??(o.isToolTask(e.name)?{}:void 0)},i=o.requestStream({method:"tools/call",params:e},r,s),a=o.getToolOutputValidator(e.name);for await(let c of i){if(c.type==="result"&&a){let u=c.result;if(!u.structuredContent&&!u.isError){yield{type:"error",error:new O(R.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(u.structuredContent)try{let l=a(u.structuredContent);if(!l.valid){yield{type:"error",error:new O(R.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof O){yield{type:"error",error:l};return}yield{type:"error",error:new O(R.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)};return}}yield c}}async getTask(e,r){return this._client.getTask({taskId:e},r)}async getTaskResult(e,r,n){return this._client.getTaskResult({taskId:e},r,n)}async listTasks(e,r){return this._client.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._client.cancelTask({taskId:e},r)}requestStream(e,r,n){return this._client.requestStream(e,r,n)}};function wS(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function bS(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}function Xs(t,e){if(!(!t||e===null||typeof e!="object")){if(t.type==="object"&&t.properties&&typeof t.properties=="object"){let r=e,n=t.properties;for(let o of Object.keys(n)){let s=n[o];r[o]===void 0&&Object.prototype.hasOwnProperty.call(s,"default")&&(r[o]=s.default),r[o]!==void 0&&Xs(s,r[o])}}if(Array.isArray(t.anyOf))for(let r of t.anyOf)typeof r!="boolean"&&Xs(r,e);if(Array.isArray(t.oneOf))for(let r of t.oneOf)typeof r!="boolean"&&Xs(r,e)}}function Nz(t){if(!t)return{supportsFormMode:!1,supportsUrlMode:!1};let e=t.form!==void 0,r=t.url!==void 0;return{supportsFormMode:e||!e&&!r,supportsUrlMode:r}}var Qs=class extends hs{constructor(e,r){super(r),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=r?.capabilities??{},this._jsonSchemaValidator=r?.jsonSchemaValidator??new Bs,r?.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",nc,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",tc,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",Ja,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new Ys(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Og(this._capabilities,e)}setRequestHandler(e,r){let o=es(e)?.method;if(!o)throw new Error("Schema is missing a method literal");let s;if(Rr(o)){let a=o;s=a._zod?.def?.value??a.value}else{let a=o;s=a._def?.value??a.value}if(typeof s!="string")throw new Error("Schema method literal must be a string");let i=s;if(i==="elicitation/create"){let a=async(c,u)=>{let l=ot(ac,c);if(!l.success){let b=l.error instanceof Error?l.error.message:String(l.error);throw new O(R.InvalidParams,`Invalid elicitation request: ${b}`)}let{params:d}=l.data;d.mode=d.mode??"form";let{supportsFormMode:p,supportsUrlMode:m}=Nz(this._capabilities.elicitation);if(d.mode==="form"&&!p)throw new O(R.InvalidParams,"Client does not support form-mode elicitation requests");if(d.mode==="url"&&!m)throw new O(R.InvalidParams,"Client does not support URL-mode elicitation requests");let h=await Promise.resolve(r(c,u));if(d.task){let b=ot(sr,h);if(!b.success){let w=b.error instanceof Error?b.error.message:String(b.error);throw new O(R.InvalidParams,`Invalid task creation result: ${w}`)}return b.data}let y=ot(cc,h);if(!y.success){let b=y.error instanceof Error?y.error.message:String(y.error);throw new O(R.InvalidParams,`Invalid elicitation result: ${b}`)}let g=y.data,v=d.mode==="form"?d.requestedSchema:void 0;if(d.mode==="form"&&g.action==="accept"&&g.content&&v&&this._capabilities.elicitation?.form?.applyDefaults)try{Xs(v,g.content)}catch{}return g};return super.setRequestHandler(e,a)}if(i==="sampling/createMessage"){let a=async(c,u)=>{let l=ot(oc,c);if(!l.success){let g=l.error instanceof Error?l.error.message:String(l.error);throw new O(R.InvalidParams,`Invalid sampling request: ${g}`)}let{params:d}=l.data,p=await Promise.resolve(r(c,u));if(d.task){let g=ot(sr,p);if(!g.success){let v=g.error instanceof Error?g.error.message:String(g.error);throw new O(R.InvalidParams,`Invalid task creation result: ${v}`)}return g.data}let h=d.tools||d.toolChoice?ic:sc,y=ot(h,p);if(!y.success){let g=y.error instanceof Error?y.error.message:String(y.error);throw new O(R.InvalidParams,`Invalid sampling result: ${g}`)}return y.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,r)}assertCapability(e,r){if(!this._serverCapabilities?.[e])throw new Error(`Server does not support ${e} (required for ${r})`)}async connect(e,r){if(await super.connect(e),e.sessionId===void 0)try{let n=await this.request({method:"initialize",params:{protocolVersion:Da,capabilities:this._capabilities,clientInfo:this._clientInfo}},Za,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!lg.includes(n.protocolVersion))throw new Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(n.protocolVersion),this._instructions=n.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(n){throw this.close(),n}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){switch(e){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw new Error(`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"initialize":break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Client does not support tasks capability (required for ${e})`);break;case"ping":break}}assertTaskCapability(e){wS(this._serverCapabilities?.tasks?.requests,e,"Server")}assertTaskHandlerCapability(e){this._capabilities&&bS(this._capabilities.tasks?.requests,e,"Client")}async ping(e){return this.request({method:"ping"},or,e)}async complete(e,r){return this.request({method:"completion/complete",params:e},uc,r)}async setLoggingLevel(e,r){return this.request({method:"logging/setLevel",params:{level:e}},or,r)}async getPrompt(e,r){return this.request({method:"prompts/get",params:e},ec,r)}async listPrompts(e,r){return this.request({method:"prompts/list",params:e},Ga,r)}async listResources(e,r){return this.request({method:"resources/list",params:e},Ha,r)}async listResourceTemplates(e,r){return this.request({method:"resources/templates/list",params:e},Wa,r)}async readResource(e,r){return this.request({method:"resources/read",params:e},Ka,r)}async subscribeResource(e,r){return this.request({method:"resources/subscribe",params:e},or,r)}async unsubscribeResource(e,r){return this.request({method:"resources/unsubscribe",params:e},or,r)}async callTool(e,r=Ar,n){if(this.isToolTaskRequired(e.name))throw new O(R.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let o=await this.request({method:"tools/call",params:e},r,n),s=this.getToolOutputValidator(e.name);if(s){if(!o.structuredContent&&!o.isError)throw new O(R.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(o.structuredContent)try{let i=s(o.structuredContent);if(!i.valid)throw new O(R.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof O?i:new O(R.InvalidParams,`Failed to validate structured content: ${i instanceof Error?i.message:String(i)}`)}}return o}isToolTask(e){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(let r of e){if(r.outputSchema){let o=this._jsonSchemaValidator.getValidator(r.outputSchema);this._cachedToolOutputValidators.set(r.name,o)}let n=r.execution?.taskSupport;(n==="required"||n==="optional")&&this._cachedKnownTaskTools.add(r.name),n==="required"&&this._cachedRequiredTaskTools.add(r.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,r){let n=await this.request({method:"tools/list",params:e},rc,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(e,r,n,o){let s=$g.safeParse(n);if(!s.success)throw new Error(`Invalid ${e} listChanged options: ${s.error.message}`);if(typeof n.onChanged!="function")throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);let{autoRefresh:i,debounceMs:a}=s.data,{onChanged:c}=n,u=async()=>{if(!i){c(null,null);return}try{let d=await o();c(null,d)}catch(d){let p=d instanceof Error?d:new Error(String(d));c(p,null)}},l=()=>{if(a){let d=this._listChangedDebounceTimers.get(e);d&&clearTimeout(d);let p=setTimeout(u,a);this._listChangedDebounceTimers.set(e,p)}else u()};this.setNotificationHandler(r,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var fv=we(dv(),1),ni=we(require("node:process"),1),mv=require("node:stream");var ti=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
|
|
87
87
|
`);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),uR(r)}clear(){this._buffer=void 0}};function uR(t){return yg.parse(JSON.parse(t))}function pv(t){return JSON.stringify(t)+`
|
|
88
88
|
`}var lR=ni.default.platform==="win32"?["APPDATA","HOMEDRIVE","HOMEPATH","LOCALAPPDATA","PATH","PROCESSOR_ARCHITECTURE","SYSTEMDRIVE","SYSTEMROOT","TEMP","USERNAME","USERPROFILE","PROGRAMFILES"]:["HOME","LOGNAME","PATH","SHELL","TERM","USER"];function dR(){let t={};for(let e of lR){let r=ni.default.env[e];r!==void 0&&(r.startsWith("()")||(t[e]=r))}return t}var ri=class{constructor(e){this._readBuffer=new ti,this._stderrStream=null,this._serverParams=e,(e.stderr==="pipe"||e.stderr==="overlapped")&&(this._stderrStream=new mv.PassThrough)}async start(){if(this._process)throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise((e,r)=>{this._process=(0,fv.default)(this._serverParams.command,this._serverParams.args??[],{env:{...dR(),...this._serverParams.env},stdio:["pipe","pipe",this._serverParams.stderr??"inherit"],shell:!1,windowsHide:ni.default.platform==="win32",cwd:this._serverParams.cwd}),this._process.on("error",n=>{r(n),this.onerror?.(n)}),this._process.on("spawn",()=>{e()}),this._process.on("close",n=>{this._process=void 0,this.onclose?.()}),this._process.stdin?.on("error",n=>{this.onerror?.(n)}),this._process.stdout?.on("data",n=>{this._readBuffer.append(n),this.processReadBuffer()}),this._process.stdout?.on("error",n=>{this.onerror?.(n)}),this._stderrStream&&this._process.stderr&&this._process.stderr.pipe(this._stderrStream)})}get stderr(){return this._stderrStream?this._stderrStream:this._process?.stderr??null}get pid(){return this._process?.pid??null}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){if(this._process){let e=this._process;this._process=void 0;let r=new Promise(n=>{e.once("close",()=>{n()})});try{e.stdin?.end()}catch{}if(await Promise.race([r,new Promise(n=>setTimeout(n,2e3).unref())]),e.exitCode===null){try{e.kill("SIGTERM")}catch{}await Promise.race([r,new Promise(n=>setTimeout(n,2e3).unref())])}if(e.exitCode===null)try{e.kill("SIGKILL")}catch{}}this._readBuffer.clear()}send(e){return new Promise(r=>{if(!this._process?.stdin)throw new Error("Not connected");let n=pv(e);this._process.stdin.write(n)?r():this._process.stdin.once("drain",r)})}};var ml=require("child_process"),hl=require("fs"),oi=we(require("path"),1);var pR="claude-mem-hook",fR="1.0.0",mR=3e4;function hR(){let t=[oi.default.join(vr,"plugin","scripts","mcp-server.cjs"),oi.default.join(process.cwd(),"plugin","scripts","mcp-server.cjs")];for(let e of t)if((0,hl.existsSync)(e))return e;return null}function gR(){let t={};for(let[e,r]of Object.entries(Yt(process.env)))r!==void 0&&(t[e]=r);return t}function hv(t){return oi.default.basename(t).toLowerCase().replace(/\.exe$/,"")}function _R(){if(hv(process.execPath)==="node")return process.execPath;let t=process.env.CLAUDE_MEM_NODE_PATH;if(t&&hv(t)==="node"&&(0,hl.existsSync)(t))return t;try{let r=(process.platform==="win32"?(0,ml.execFileSync)("where",["node"],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],windowsHide:!0}):(0,ml.execFileSync)("which",["node"],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]})).split(/\r?\n/).map(n=>n.trim()).find(Boolean);if(r)return r}catch{}return process.platform==="win32"?"node.exe":"node"}function yR(t){if(typeof t!="object"||t===null)throw new Error("MCP tool returned a non-object result");let e=t;if(!Array.isArray(e.content))throw new Error("MCP tool result did not include content");return{text:e.content.filter(n=>typeof n=="object"&&n!==null&&n.type==="text"&&typeof n.text=="string").map(n=>n.text).join(`
|
|
89
89
|
`),...e.isError===!0?{isError:!0}:{}}}async function gv(t,e,r={}){let n=hR();if(!n)throw new Error("mcp-server.cjs not found in plugin/scripts");let o=new ri({command:_R(),args:[n],env:gR(),cwd:process.cwd(),stderr:"pipe"}),s=new Qs({name:pR,version:fR},{capabilities:{}}),i=r.timeoutMs??mR,a=null,c=new Promise((u,l)=>{a=setTimeout(()=>l(new Error(`MCP tool ${t} timed out after ${i}ms`)),i)});try{let u=await Promise.race([(async()=>(await s.connect(o),await s.callTool({name:t,arguments:e})))(),c]);return yR(u)}finally{a&&clearTimeout(a);try{await s.close()}catch(u){f.debug("SYSTEM","Failed to close one-shot MCP client",{error:u instanceof Error?u.message:String(u)})}}}async function _v(t){try{let e=await gv("session_start_context",{projects:t.projects,...t.platformSource?{platformSource:t.platformSource}:{},...t.colors!==void 0?{colors:t.colors}:{}});return e.isError?(f.warn("HOOK","MCP session_start_context returned an error; falling back to worker HTTP",{preview:e.text.slice(0,200)}),null):e.text.trim()}catch(e){return f.warn("HOOK","MCP session_start_context failed; falling back to worker HTTP",{error:e instanceof Error?e.message:String(e)}),null}}var gl={async execute(t){let e=t.cwd??process.cwd(),r=kr(e),n=It(),s=rt().CLAUDE_MEM_CONTEXT_SHOW_TERMINAL_OUTPUT==="true",i=r.allProjects.join(","),a=t.platform?Ce(t.platform):void 0,c=t.platform?`&platformSource=${encodeURIComponent(a)}`:"",u=`/api/context/inject?projects=${encodeURIComponent(i)}${c}`,l=t.platform==="claude-code"?`${u}&colors=true`:u,d={hookSpecificOutput:{hookEventName:"SessionStart",additionalContext:""},exitCode:C.SUCCESS},p,m=t.platform==="codex"?await _v({projects:r.allProjects,...a?{platformSource:a}:{}}):null;if(m!==null)p=m;else{let w=await le(u,"GET");if(me(w))return d;if(typeof w=="string")p=w.trim();else if(w===void 0)p="";else return f.warn("HOOK","Context response was not a string",{type:typeof w}),d}let h=lp();if(h){let w=`[claude-mem] Claude Desktop OAuth token is stale: ${h}
|
|
@@ -112,4 +112,4 @@ View Observations Live @ http://localhost:${n}`:void 0;return{hookSpecificOutput
|
|
|
112
112
|
|
|
113
113
|
---
|
|
114
114
|
|
|
115
|
-
`),permissionDecision:"allow"}}}};async function WR(t,e){let r=0;try{let p=Gt.default.isAbsolute(e)?e:Gt.default.resolve(t.cwd||process.cwd(),e),m=(0,$v.statSync)(p);if(!m.isFile()||m.size<MR)return null;r=m.mtimeMs}catch(p){if(p instanceof Error&&"code"in p&&p.code==="ENOENT")return null;f.debug("HOOK","File stat failed, proceeding with gate",{error:p instanceof Error?p.message:String(p)})}let n=kr(t.cwd),o=t.cwd||process.cwd(),s=Gt.default.isAbsolute(e)?e:Gt.default.resolve(o,e),i=Gt.default.relative(o,s).split(Gt.default.sep).join("/"),a=Array.from(new Set([s.split(Gt.default.sep).join("/"),i].filter(Boolean))),c=new URLSearchParams;for(let p of a)c.append("path",p);n.allProjects.length>0&&c.set("projects",n.allProjects.join(",")),c.set("limit",String(NR));let u=await le(`/api/observations/by-file?${c.toString()}`,"GET");if(me(u))return null;if(!u||!Array.isArray(u.observations))return f.warn("HOOK","File context query returned malformed body, skipping",{filePath:e}),null;let l=u;if(!l.observations||l.observations.length===0)return null;if(r>0){let p=Math.max(...l.observations.map(m=>m.created_at_epoch));if(r>=p)return f.debug("HOOK","File modified since last observation, skipping context injection",{filePath:i,fileMtimeMs:r,newestObservationMs:p}),null}let d=qR(l.observations,i,DR);return d.length===0?null:HR(d,e)}var $l={async execute(t){let e=t.sessionId;return e&&(await le("/api/session/acquire","POST",{sessionId:e}),f.debug("HOOK","Session acquire sent",{sessionId:e})),{continue:!0,suppressOutput:!0,exitCode:C.SUCCESS}}};var Pl={async execute(t){let e=t.sessionId;if(e)try{await Qt("/api/session/release",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:e}),timeoutMs:2e3}),f.debug("HOOK","Session release sent",{sessionId:e})}catch(r){f.debug("HOOK","Session release failed (worker likely already stopped)",{sessionId:e,error:r instanceof Error?r.message:String(r)})}return{continue:!0,suppressOutput:!0,exitCode:C.SUCCESS}}};var
|
|
115
|
+
`),permissionDecision:"allow"}}}};async function WR(t,e){let r=0;try{let p=Gt.default.isAbsolute(e)?e:Gt.default.resolve(t.cwd||process.cwd(),e),m=(0,$v.statSync)(p);if(!m.isFile()||m.size<MR)return null;r=m.mtimeMs}catch(p){if(p instanceof Error&&"code"in p&&p.code==="ENOENT")return null;f.debug("HOOK","File stat failed, proceeding with gate",{error:p instanceof Error?p.message:String(p)})}let n=kr(t.cwd),o=t.cwd||process.cwd(),s=Gt.default.isAbsolute(e)?e:Gt.default.resolve(o,e),i=Gt.default.relative(o,s).split(Gt.default.sep).join("/"),a=Array.from(new Set([s.split(Gt.default.sep).join("/"),i].filter(Boolean))),c=new URLSearchParams;for(let p of a)c.append("path",p);n.allProjects.length>0&&c.set("projects",n.allProjects.join(",")),c.set("limit",String(NR));let u=await le(`/api/observations/by-file?${c.toString()}`,"GET");if(me(u))return null;if(!u||!Array.isArray(u.observations))return f.warn("HOOK","File context query returned malformed body, skipping",{filePath:e}),null;let l=u;if(!l.observations||l.observations.length===0)return null;if(r>0){let p=Math.max(...l.observations.map(m=>m.created_at_epoch));if(r>=p)return f.debug("HOOK","File modified since last observation, skipping context injection",{filePath:i,fileMtimeMs:r,newestObservationMs:p}),null}let d=qR(l.observations,i,DR);return d.length===0?null:HR(d,e)}var $l={async execute(t){let e=t.sessionId;return e&&(await le("/api/session/acquire","POST",{sessionId:e}),f.debug("HOOK","Session acquire sent",{sessionId:e})),{continue:!0,suppressOutput:!0,exitCode:C.SUCCESS}}};var Pl={async execute(t){let e=t.sessionId;if(e)try{await Qt("/api/session/release",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:e}),timeoutMs:2e3}),f.debug("HOOK","Session release sent",{sessionId:e})}catch(r){f.debug("HOOK","Session release failed (worker likely already stopped)",{sessionId:e,error:r instanceof Error?r.message:String(r)})}return{continue:!0,suppressOutput:!0,exitCode:C.SUCCESS}}};var VR=8e3,Tl={async execute(t){let e={continue:!0,suppressOutput:!0,exitCode:C.SUCCESS};if(t.cwd&&!tt(t.cwd))return e;let r="";try{t.lastAssistantMessage?r=tn(t.lastAssistantMessage):t.transcriptPath&&(r=tn(ai(t.transcriptPath,"assistant",!0)))}catch(o){f.debug("HOOK","precompact: transcript extraction failed",{sessionId:t.sessionId},o instanceof Error?o:new Error(String(o)))}if(r=(r??"").trim().slice(0,VR),!r)return f.debug("HOOK","precompact: nothing to capture, skipping",{sessionId:t.sessionId}),e;let n=t.cwd?Hi(t.cwd):void 0;try{let o=await le("/api/memory/save","POST",{text:r,title:"Pre-compaction context capture",project:n,metadata:{source:"precompact",sessionId:t.sessionId}},{timeoutMs:5e3});me(o)?f.debug("HOOK","precompact: worker unreachable, capture skipped",{sessionId:t.sessionId}):f.info("HOOK","precompact: captured evicted context through store chokepoint",{sessionId:t.sessionId,chars:r.length})}catch(o){f.warn("HOOK","precompact: capture failed",{sessionId:t.sessionId},o instanceof Error?o:new Error(String(o)))}return e}};var KR={context:gl,"session-init":Sl,observation:vl,summarize:El,"user-message":wl,"file-edit":bl,"file-context":xl,"session-acquire":$l,"session-release":Pl,precompact:Tl};function Pv(t){let e=KR[t];return e||(f.warn("HOOK",`Unknown event type: ${t}, returning no-op`),{async execute(){return{continue:!0,suppressOutput:!0,exitCode:C.SUCCESS}}})}function JR(t){let e=t instanceof Error?t.message:String(t),r=e.toLowerCase();return["econnrefused","econnreset","epipe","etimedout","enotfound","econnaborted","enetunreach","ehostunreach","fetch failed","unable to connect","socket hang up"].some(o=>r.includes(o))||r.includes("timed out")||r.includes("timeout")||/failed:\s*5\d{2}/.test(e)||/status[:\s]+5\d{2}/.test(e)||/failed:\s*429/.test(e)||/status[:\s]+429/.test(e)?!0:(/failed:\s*4\d{2}/.test(e)||/status[:\s]+4\d{2}/.test(e)||t instanceof TypeError||t instanceof ReferenceError||t instanceof SyntaxError,!1)}function GR(t){let r=(t instanceof Error?t.message:String(t)).toLowerCase();return r.includes("transcript path")&&(r.includes("missing")||r.includes("does not exist"))}async function BR(t,e,r,n){let o=await Td(),s=t.normalizeInput(o);s.platform=r;let i=await e.execute(s);yo(t,i);let a=i.exitCode??C.SUCCESS;return await ln(n),a}async function Tv(t,e,r={}){Ll(),kd(e);let n=Ml(),o=tp(t),s=Pv(e);try{return await BR(o,s,t,r)}catch(i){return i instanceof he?(f.warn("HOOK",`Adapter rejected input (${i.reason}), skipping hook`),yo(o,{continue:!0,suppressOutput:!0}),await ln(r),C.SUCCESS):GR(i)?(f.warn("HOOK",`Hook input unavailable, skipping hook: ${i instanceof Error?i.message:i}`),yo(o,{continue:!0,suppressOutput:!0}),await ln(r),C.SUCCESS):JR(i)?(f.warn("HOOK",`Worker unavailable, skipping hook: ${i instanceof Error?i.message:i}`),await ji(),await ln(r),C.SUCCESS):(f.error("HOOK",`Hook error: ${i instanceof Error?i.message:i}`,{},i instanceof Error?i:void 0),await Dl(`Hook error: ${i instanceof Error?i.message:String(i)}`,r),C.BLOCKING_ERROR)}finally{n.restore()}}function YR(){try{let t=Ov.default.join(__dirname,"worker-service.cjs");if((0,zv.existsSync)(t))return t}catch{}return Li()}async function XR(){let t=process.argv[3],e=process.argv[4];(!t||!e)&&(console.error("Usage: hook-client hook <platform> <event>"),process.exit(1));let r=It(),n=YR();if(n)try{await $d(r,n)==="dead"&&f.warn("SYSTEM","Worker failed to start before hook; handler will proceed gracefully")}catch(o){f.debug("SYSTEM","ensureWorkerStarted threw before hook",{error:o instanceof Error?o.message:String(o)})}else f.warn("SYSTEM","worker-service.cjs not found next to hook-client; running hook against any live worker");await Tv(t,e)}XR().catch(t=>{f.failure("SYSTEM","hook-client fatal error",{},t instanceof Error?t:new Error(String(t))),process.exit(0)});
|