claude-mem 13.25.3 → 13.26.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/README.md +1 -1
- package/dist/bug-report/index.js +74 -155
- package/dist/npx-cli/index.js +197 -197
- package/dist/opencode-plugin/index.js +11 -11
- package/openclaw/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/.codex-plugin/plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/plugin/scripts/context-generator.cjs +21 -21
- package/plugin/scripts/context-generator.cjs.map +2 -2
- package/plugin/scripts/mcp-server.cjs +30 -30
- package/plugin/scripts/mcp-server.cjs.map +2 -2
- package/plugin/scripts/server-service.cjs +137 -137
- package/plugin/scripts/server-service.cjs.map +3 -3
- package/plugin/scripts/transcript-watcher.cjs +21 -21
- package/plugin/scripts/transcript-watcher.cjs.map +2 -2
- package/plugin/scripts/worker-service.cjs +528 -607
- package/plugin/scripts/worker-service.cjs.map +3 -3
- package/plugin/ui/viewer-bundle.js +15 -14
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
var __CM_FILENAME__ = typeof __filename !== "undefined" ? __filename : require("node:path").resolve(process.argv[1] || "");
|
|
3
3
|
var __CM_DIRNAME__ = typeof __dirname !== "undefined" ? __dirname : require("node:path").dirname(__CM_FILENAME__);
|
|
4
|
-
"use strict";var RE=Object.create;var ta=Object.defineProperty;var AE=Object.getOwnPropertyDescriptor;var OE=Object.getOwnPropertyNames;var IE=Object.getPrototypeOf,CE=Object.prototype.hasOwnProperty;var
|
|
4
|
+
"use strict";var RE=Object.create;var ta=Object.defineProperty;var AE=Object.getOwnPropertyDescriptor;var OE=Object.getOwnPropertyNames;var IE=Object.getPrototypeOf,CE=Object.prototype.hasOwnProperty;var dn=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(n){throw r=[n],n}};var v=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},md=(e,t)=>{for(var r in t)ta(e,r,{get:t[r],enumerable:!0})},ME=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of OE(t))!CE.call(e,o)&&o!==r&&ta(e,o,{get:()=>t[o],enumerable:!(n=AE(t,o))||n.enumerable});return e};var Lt=(e,t,r)=>(r=e!=null?RE(IE(e)):{},ME(t||!e||!e.__esModule?ta(r,"default",{value:e,enumerable:!0}):r,e));function DE(e){return(zE??process.stderr.write.bind(process.stderr))(e)}function jt(e){DE(e)}var zE,Co=dn(()=>{"use strict";zE=null});function LE(e){return e.replace(/^\uFEFF/,"")}function or(e){return JSON.parse(LE(e))}function jE(e){(0,B.existsSync)(e)||(0,B.mkdirSync)(e,{recursive:!0})}function Pr(e,t){let r=e;try{if((0,B.lstatSync)(e).isSymbolicLink())try{r=(0,B.realpathSync)(e)}catch(u){let l=u instanceof Error?u:new Error(String(u));jt(`claude-mem: realpathSync failed for ${e}, resolving symlink manually: ${l.message}
|
|
5
5
|
`);let d=(0,B.readlinkSync)(e);r=(0,yt.resolve)((0,yt.dirname)(e),d)}}catch(u){let l=u.code;if(l!=="ENOENT"&&l!=="ENOTDIR")throw u}jE((0,yt.dirname)(r));let n=(0,yt.dirname)(r),o=(0,yt.basename)(r),s=(0,yt.join)(n,`.${o}.${process.pid}.${(0,hd.randomBytes)(6).toString("hex")}.tmp`),i=Buffer.from(JSON.stringify(t,null,2)+`
|
|
6
6
|
`,"utf-8"),a;try{a=(0,B.statSync)(r).mode&511}catch{}let c;try{c=a!==void 0?(0,B.openSync)(s,"w",a):(0,B.openSync)(s,"w");let u=0;for(;u<i.length;){let l=(0,B.writeSync)(c,i,u,i.length-u);if(l===0)throw new Error(`writeSync stalled at ${u}/${i.length} bytes`);u+=l}if((0,B.fsyncSync)(c),(0,B.closeSync)(c),c=void 0,(0,B.renameSync)(s,r),!NE){let l;try{l=(0,B.openSync)(n,"r"),(0,B.fsyncSync)(l)}catch(d){let f=d instanceof Error?d:new Error(String(d));jt(`claude-mem: directory fsync failed for ${n}: ${f.message}
|
|
7
|
-
`)}finally{if(l!==void 0)try{(0,B.closeSync)(l)}catch{}}}}catch(u){if(c!==void 0)try{(0,B.closeSync)(c)}catch{}try{(0,B.unlinkSync)(s)}catch{}throw u}}var B,hd,yt,NE,
|
|
7
|
+
`)}finally{if(l!==void 0)try{(0,B.closeSync)(l)}catch{}}}}catch(u){if(c!==void 0)try{(0,B.closeSync)(c)}catch{}try{(0,B.unlinkSync)(s)}catch{}throw u}}var B,hd,yt,NE,Tr=dn(()=>{"use strict";B=require("fs"),hd=require("crypto"),yt=require("path");Co();NE=process.platform==="win32"});function Mo(e,t=process.platform,r=(0,gd.homedir)()){return typeof e!="string"||e.length===0?e:e==="~"?r:e.startsWith("~/")||t==="win32"&&e.startsWith("~\\")?(0,_d.join)(r,e.slice(2)):e}var gd,_d,ra=dn(()=>{"use strict";gd=require("os"),_d=require("path")});function UE(){return typeof __CM_DIRNAME__<"u"?__CM_DIRNAME__:(0,Y.dirname)((0,yd.fileURLToPath)(HE.url))}function sr(){if(process.env.CLAUDE_MEM_DATA_DIR)return Mo(process.env.CLAUDE_MEM_DATA_DIR);let e=(0,Y.join)((0,na.homedir)(),".claude-mem"),t=(0,Y.join)(e,"settings.json");try{if((0,fn.existsSync)(t)){let r=or((0,fn.readFileSync)(t,"utf-8")),n=r.env??r;if(n.CLAUDE_MEM_DATA_DIR)return Mo(n.CLAUDE_MEM_DATA_DIR)}}catch{}return e}var Y,na,fn,yd,HE,kI,ce,FE,qE,zo,ZE,Do,Sd,xI,Ed,PI,qe,Ze=dn(()=>{"use strict";Y=require("path"),na=require("os"),fn=require("fs"),yd=require("url");Tr();ra();ra();HE={};kI=UE();ce=sr(),FE=(0,Y.join)((0,na.homedir)(),".claude"),qE=process.env.CLAUDE_CONFIG_DIR||FE,zo=(0,Y.join)(qE,"plugins","marketplaces","thedotmack"),ZE=(0,Y.join)(ce,"logs"),Do=(0,Y.join)(ce,"settings.json"),Sd="claude-mem.db",xI=(0,Y.join)(ce,Sd),Ed=(0,Y.join)(ce,"observer-sessions"),PI=(0,Y.basename)(Ed),qe={dataDir:()=>ce,workerPid:()=>(0,Y.join)(ce,"worker.pid"),serverPid:()=>(0,Y.join)(ce,".server-beta.pid"),serverPort:()=>(0,Y.join)(ce,".server-beta.port"),serverRuntime:()=>(0,Y.join)(ce,".server-beta.runtime.json"),settings:()=>(0,Y.join)(ce,"settings.json"),database:()=>(0,Y.join)(ce,Sd),chroma:()=>(0,Y.join)(ce,"chroma"),combinedCerts:()=>(0,Y.join)(ce,"combined_certs.pem"),transcriptsConfig:()=>(0,Y.join)(ce,"transcript-watch.json"),transcriptsState:()=>(0,Y.join)(ce,"transcript-watch-state.json"),corpora:()=>(0,Y.join)(ce,"corpora"),supervisorRegistry:()=>(0,Y.join)(ce,"supervisor.json"),envFile:()=>(0,Y.join)(ce,".env"),logsDir:()=>ZE}});var kt,bd,sa,oa,ia,_,X=dn(()=>{"use strict";kt=require("fs"),bd=require("path");Ze();Co();Tr();sa=(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))(sa||{}),oa=null,ia=class{level=null;useColor;logFilePath=null;logFileInitialized=!1;logFileDate=null;constructor(){this.useColor=process.stdout.isTTY??!1}ensureLogFileInitialized(){let t=new Date().toISOString().split("T")[0];if(!(this.logFileInitialized&&this.logFileDate===t)){this.logFileInitialized=!0,this.logFileDate=t;try{let r=qe.logsDir();(0,kt.existsSync)(r)||(0,kt.mkdirSync)(r,{recursive:!0}),this.logFilePath=(0,bd.join)(r,`claude-mem-${t}.log`)}catch(r){console.error("[LOGGER] Failed to initialize log file:",r instanceof Error?r.message:String(r)),this.logFilePath=null}}}getLevel(){if(this.level===null)try{let t=qe.settings();if((0,kt.existsSync)(t)){let r=(0,kt.readFileSync)(t,"utf-8"),o=(or(r).CLAUDE_MEM_LOG_LEVEL||"INFO").toUpperCase();this.level=sa[o]??1}else this.level=1}catch(t){console.error("[LOGGER] Failed to load log level from settings:",t instanceof Error?t.message:String(t)),this.level=1}return this.level}formatData(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return t.toString();if(typeof t=="object"){if(t instanceof Error)return this.getLevel()===0?`${t.message}
|
|
8
8
|
${t.stack}`:t.message;if(Array.isArray(t))return`[${t.length} items]`;let r=Object.keys(t);return r.length===0?"{}":r.length<=3?JSON.stringify(t):`{${r.length} keys: ${r.slice(0,3).join(", ")}...}`}return String(t)}formatTool(t,r){if(!r)return t;let n=r;if(typeof r=="string")try{n=JSON.parse(r)}catch{n=r}if(t==="Bash"&&n.command)return`${t}(${n.command})`;if(n.file_path)return`${t}(${n.file_path})`;if(n.notebook_path)return`${t}(${n.notebook_path})`;if(t==="Glob"&&n.pattern)return`${t}(${n.pattern})`;if(t==="Grep"&&n.pattern)return`${t}(${n.pattern})`;if(n.url)return`${t}(${n.url})`;if(n.query)return`${t}(${n.query})`;if(t==="Task"){if(n.subagent_type)return`${t}(${n.subagent_type})`;if(n.description)return`${t}(${n.description})`}return t==="Skill"&&n.skill?`${t}(${n.skill})`:t==="LSP"&&n.operation?`${t}(${n.operation})`:t}formatTimestamp(t){let r=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0"),a=String(t.getSeconds()).padStart(2,"0"),c=String(t.getMilliseconds()).padStart(3,"0");return`${r}-${n}-${o} ${s}:${i}:${a}.${c}`}log(t,r,n,o,s){if(t<this.getLevel())return;this.ensureLogFileInitialized();let i=this.formatTimestamp(new Date),a=sa[t].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?`
|
|
9
9
|
${s.message}
|
|
10
10
|
${s.stack}`:` ${s.message}`;else if(this.getLevel()===0&&typeof s=="object")try{l=`
|
|
11
|
-
`+JSON.stringify(s,null,2)}catch{l=" "+this.formatData(s)}else l=" "+this.formatData(s);let d="";if(o){let{sessionId:p,memorySessionId:m,correlationId:h,...g}=o;Object.keys(g).length>0&&(d=` {${Object.entries(g).map(([b,
|
|
11
|
+
`+JSON.stringify(s,null,2)}catch{l=" "+this.formatData(s)}else l=" "+this.formatData(s);let d="";if(o){let{sessionId:p,memorySessionId:m,correlationId:h,...g}=o;Object.keys(g).length>0&&(d=` {${Object.entries(g).map(([b,w])=>`${b}=${w}`).join(", ")}}`)}let f=`[${i}] [${a}] [${c}] ${u}${n}${d}${l}`;if(this.logFilePath)try{(0,kt.appendFileSync)(this.logFilePath,f+`
|
|
12
12
|
`,"utf8")}catch(p){let m=p instanceof Error?p:new Error(String(p));jt(`[LOGGER] Failed to write to log file: ${m.message}
|
|
13
13
|
${m.stack??""}
|
|
14
14
|
`)}else jt(f+`
|
|
15
|
-
`)}debug(t,r,n,o){this.log(0,t,r,n,o)}info(t,r,n,o){this.log(1,t,r,n,o)}warn(t,r,n,o){this.log(2,t,r,n,o)}setErrorSink(t){oa=t}error(t,r,n,o){this.log(3,t,r,n,o),this.routeErrorToSink(r,n,o)}routeErrorToSink(t,r,n){try{if(!oa||!(n instanceof Error))return;oa(n)}catch{}}dataIn(t,r,n,o){this.info(t,`\u2192 ${r}`,n,o)}dataOut(t,r,n,o){this.info(t,`\u2190 ${r}`,n,o)}success(t,r,n,o){this.info(t,`\u2713 ${r}`,n,o)}failure(t,r,n,o){this.error(t,`\u2717 ${r}`,n,o)}},_=new ia});var Bn=w(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 Wn=class{};H._CodeOrName=Wn;H.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var ur=class extends Wn{constructor(t){if(super(),!H.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};H.Name=ur;var Qe=class extends Wn{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof ur&&(r[n.str]=(r[n.str]||0)+1),r),{})}};H._Code=Qe;H.nil=new Qe("");function dg(e,...t){let r=[e[0]],n=0;for(;n<t.length;)Ac(r,t[n]),r.push(e[++n]);return new Qe(r)}H._=dg;var Rc=new Qe("+");function fg(e,...t){let r=[Hn(e[0])],n=0;for(;n<t.length;)r.push(Rc),Ac(r,t[n]),r.push(Rc,Hn(e[++n]));return Y0(r),new Qe(r)}H.str=fg;function Ac(e,t){t instanceof Qe?e.push(...t._items):t instanceof ur?e.push(t):e.push(Q0(t))}H.addCodeArg=Ac;function Y0(e){let t=1;for(;t<e.length-1;){if(e[t]===Rc){let r=J0(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function J0(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof ur||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof ur))return`"${e}${t.slice(1)}`}function X0(e,t){return t.emptyStr()?e:e.emptyStr()?t:fg`${e}${t}`}H.strConcat=X0;function Q0(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:Hn(Array.isArray(e)?e.join(","):e)}function ek(e){return new Qe(Hn(e))}H.stringify=ek;function Hn(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}H.safeStringify=Hn;function tk(e){return typeof e=="string"&&H.IDENTIFIER.test(e)?new Qe(`.${e}`):dg`[${e}]`}H.getProperty=tk;function rk(e){if(typeof e=="string"&&H.IDENTIFIER.test(e))return new Qe(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}H.getEsmExportName=rk;function nk(e){return new Qe(e.toString())}H.regexpCode=nk});var Cc=w(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});Le.ValueScope=Le.ValueScopeName=Le.Scope=Le.varKinds=Le.UsedValueState=void 0;var Ne=Bn(),Oc=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},Us;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(Us||(Le.UsedValueState=Us={}));Le.varKinds={const:new Ne.Name("const"),let:new Ne.Name("let"),var:new Ne.Name("var")};var Fs=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof Ne.Name?t:this.name(t)}name(t){return new Ne.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};Le.Scope=Fs;var qs=class extends Ne.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,Ne._)`.${new Ne.Name(r)}[${n}]`}};Le.ValueScopeName=qs;var ok=(0,Ne._)`\n`,Ic=class extends Fs{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?ok:Ne.nil}}get(){return this._scope}name(t){return new qs(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(t),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Ne._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(t,r,n={},o){let s=Ne.nil;for(let i in t){let a=t[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,Us.Started);let l=r(u);if(l){let d=this.opts.es5?Le.varKinds.var:Le.varKinds.const;s=(0,Ne._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,Ne._)`${s}${l}${this.opts._n}`;else throw new Oc(u);c.set(u,Us.Completed)})}return s}};Le.ValueScope=Ic});var M=w(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.or=D.and=D.not=D.CodeGen=D.operators=D.varKinds=D.ValueScopeName=D.ValueScope=D.Scope=D.Name=D.regexpCode=D.stringify=D.getProperty=D.nil=D.strConcat=D.str=D._=void 0;var F=Bn(),lt=Cc(),Kt=Bn();Object.defineProperty(D,"_",{enumerable:!0,get:function(){return Kt._}});Object.defineProperty(D,"str",{enumerable:!0,get:function(){return Kt.str}});Object.defineProperty(D,"strConcat",{enumerable:!0,get:function(){return Kt.strConcat}});Object.defineProperty(D,"nil",{enumerable:!0,get:function(){return Kt.nil}});Object.defineProperty(D,"getProperty",{enumerable:!0,get:function(){return Kt.getProperty}});Object.defineProperty(D,"stringify",{enumerable:!0,get:function(){return Kt.stringify}});Object.defineProperty(D,"regexpCode",{enumerable:!0,get:function(){return Kt.regexpCode}});Object.defineProperty(D,"Name",{enumerable:!0,get:function(){return Kt.Name}});var Bs=Cc();Object.defineProperty(D,"Scope",{enumerable:!0,get:function(){return Bs.Scope}});Object.defineProperty(D,"ValueScope",{enumerable:!0,get:function(){return Bs.ValueScope}});Object.defineProperty(D,"ValueScopeName",{enumerable:!0,get:function(){return Bs.ValueScopeName}});Object.defineProperty(D,"varKinds",{enumerable:!0,get:function(){return Bs.varKinds}});D.operators={GT:new F._Code(">"),GTE:new F._Code(">="),LT:new F._Code("<"),LTE:new F._Code("<="),EQ:new F._Code("==="),NEQ:new F._Code("!=="),NOT:new F._Code("!"),OR:new F._Code("||"),AND:new F._Code("&&"),ADD:new F._Code("+")};var Ot=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},Mc=class extends Ot{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?lt.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=qr(this.rhs,t,r)),this}get names(){return this.rhs instanceof F._CodeOrName?this.rhs.names:{}}},Zs=class extends Ot{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof F.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=qr(this.rhs,t,r),this}get names(){let t=this.lhs instanceof F.Name?{}:{...this.lhs.names};return Hs(t,this.rhs)}},zc=class extends Zs{constructor(t,r,n,o){super(t,n,o),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},Dc=class extends Ot{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},Nc=class extends Ot{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},Lc=class extends Ot{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},jc=class extends Ot{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=qr(this.code,t,r),this}get names(){return this.code instanceof F._CodeOrName?this.code.names:{}}},Kn=class extends Ot{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(t,r)||(sk(t,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>fr(t,r.names),{})}},It=class extends Kn{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},Uc=class extends Kn{},Fr=class extends It{};Fr.kind="else";var lr=class e extends It{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Fr(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(pg(t),r instanceof e?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=qr(this.condition,t,r),this}get names(){let t=super.names;return Hs(t,this.condition),this.else&&fr(t,this.else.names),t}};lr.kind="if";var dr=class extends It{};dr.kind="for";var Fc=class extends dr{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=qr(this.iteration,t,r),this}get names(){return fr(super.names,this.iteration.names)}},qc=class extends dr{constructor(t,r,n,o){super(),this.varKind=t,this.name=r,this.from=n,this.to=o}render(t){let r=t.es5?lt.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(t)}get names(){let t=Hs(super.names,this.from);return Hs(t,this.to)}},Ws=class extends dr{constructor(t,r,n,o){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=o}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=qr(this.iterable,t,r),this}get names(){return fr(super.names,this.iterable.names)}},Gn=class extends It{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};Gn.kind="func";var Vn=class extends Kn{render(t){return"return "+super.render(t)}};Vn.kind="return";var Zc=class extends It{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,o;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(o=this.finally)===null||o===void 0||o.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&fr(t,this.catch.names),this.finally&&fr(t,this.finally.names),t}},Yn=class extends It{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};Yn.kind="catch";var Jn=class extends It{render(t){return"finally"+super.render(t)}};Jn.kind="finally";var Wc=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
16
|
-
`:""},this._extScope=t,this._scope=new lt.Scope({parent:t}),this._nodes=[new Uc]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new Mc(t,s,n)),s}const(t,r,n){return this._def(lt.varKinds.const,t,r,n)}let(t,r,n){return this._def(lt.varKinds.let,t,r,n)}var(t,r,n){return this._def(lt.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new Zs(t,r,n))}add(t,r){return this._leafNode(new zc(t,D.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==F.nil&&this._leafNode(new jc(t)),this}object(...t){let r=["{"];for(let[n,o]of t)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,F.addCodeArg)(r,o));return r.push("}"),new F._Code(r)}if(t,r,n){if(this._blockNode(new lr(t)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new lr(t))}else(){return this._elseNode(new Fr)}endIf(){return this._endBlockNode(lr,Fr)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new Fc(t),r)}forRange(t,r,n,o,s=this.opts.es5?lt.varKinds.var:lt.varKinds.let){let i=this._scope.toName(t);return this._for(new qc(s,i,r,n),()=>o(i))}forOf(t,r,n,o=lt.varKinds.const){let s=this._scope.toName(t);if(this.opts.es5){let i=r instanceof F.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,F._)`${i}.length`,a=>{this.var(s,(0,F._)`${i}[${a}]`),n(s)})}return this._for(new Ws("of",o,s,r),()=>n(s))}forIn(t,r,n,o=this.opts.es5?lt.varKinds.var:lt.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,F._)`Object.keys(${r})`,n);let s=this._scope.toName(t);return this._for(new Ws("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(dr)}label(t){return this._leafNode(new Dc(t))}break(t){return this._leafNode(new Nc(t))}return(t){let r=new Vn;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Vn)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new Zc;if(this._blockNode(o),this.code(t),r){let s=this.name("e");this._currNode=o.catch=new Yn(s),r(s)}return n&&(this._currNode=o.finally=new Jn,this.code(n)),this._endBlockNode(Yn,Jn)}throw(t){return this._leafNode(new Lc(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=F.nil,n,o){return this._blockNode(new Gn(t,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(Gn)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof lr))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};D.CodeGen=Wc;function fr(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function Hs(e,t){return t instanceof F._CodeOrName?fr(e,t.names):e}function qr(e,t,r){if(e instanceof F.Name)return n(e);if(!o(e))return e;return new F._Code(e._items.reduce((s,i)=>(i instanceof F.Name&&(i=n(i)),i instanceof F._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||t[s.str]!==1?s:(delete t[s.str],i)}function o(s){return s instanceof F._Code&&s._items.some(i=>i instanceof F.Name&&t[i.str]===1&&r[i.str]!==void 0)}}function sk(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function pg(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,F._)`!${Hc(e)}`}D.not=pg;var ik=mg(D.operators.AND);function ak(...e){return e.reduce(ik)}D.and=ak;var ck=mg(D.operators.OR);function uk(...e){return e.reduce(ck)}D.or=uk;function mg(e){return(t,r)=>t===F.nil?r:r===F.nil?t:(0,F._)`${Hc(t)} ${e} ${Hc(r)}`}function Hc(e){return e instanceof F.Name?e:(0,F._)`(${e})`}});var q=w(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.checkStrictMode=N.getErrorPath=N.Type=N.useFunc=N.setEvaluated=N.evaluatedPropsToName=N.mergeEvaluated=N.eachItem=N.unescapeJsonPointer=N.escapeJsonPointer=N.escapeFragment=N.unescapeFragment=N.schemaRefOrVal=N.schemaHasRulesButRef=N.schemaHasRules=N.checkUnknownRules=N.alwaysValidSchema=N.toHash=void 0;var V=M(),lk=Bn();function dk(e){let t={};for(let r of e)t[r]=!0;return t}N.toHash=dk;function fk(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(_g(e,t),!yg(t,e.self.RULES.all))}N.alwaysValidSchema=fk;function _g(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let o=n.RULES.keywords;for(let s in t)o[s]||bg(e,`unknown keyword: "${s}"`)}N.checkUnknownRules=_g;function yg(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}N.schemaHasRules=yg;function pk(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}N.schemaHasRulesButRef=pk;function mk({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,V._)`${r}`}return(0,V._)`${e}${t}${(0,V.getProperty)(n)}`}N.schemaRefOrVal=mk;function hk(e){return Sg(decodeURIComponent(e))}N.unescapeFragment=hk;function gk(e){return encodeURIComponent(Kc(e))}N.escapeFragment=gk;function Kc(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}N.escapeJsonPointer=Kc;function Sg(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}N.unescapeJsonPointer=Sg;function _k(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}N.eachItem=_k;function hg({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof V.Name?(s instanceof V.Name?e(o,s,i):t(o,s,i),i):s instanceof V.Name?(t(o,i,s),s):r(s,i);return a===V.Name&&!(c instanceof V.Name)?n(o,c):c}}N.mergeEvaluated={props:hg({mergeNames:(e,t,r)=>e.if((0,V._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,V._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,V._)`${r} || {}`).code((0,V._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,V._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,V._)`${r} || {}`),Gc(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Eg}),items:hg({mergeNames:(e,t,r)=>e.if((0,V._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,V._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,V._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,V._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Eg(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,V._)`{}`);return t!==void 0&&Gc(e,r,t),r}N.evaluatedPropsToName=Eg;function Gc(e,t,r){Object.keys(r).forEach(n=>e.assign((0,V._)`${t}${(0,V.getProperty)(n)}`,!0))}N.setEvaluated=Gc;var gg={};function yk(e,t){return e.scopeValue("func",{ref:t,code:gg[t.code]||(gg[t.code]=new lk._Code(t.code))})}N.useFunc=yk;var Bc;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Bc||(N.Type=Bc={}));function Sk(e,t,r){if(e instanceof V.Name){let n=t===Bc.Num;return r?n?(0,V._)`"[" + ${e} + "]"`:(0,V._)`"['" + ${e} + "']"`:n?(0,V._)`"/" + ${e}`:(0,V._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,V.getProperty)(e).toString():"/"+Kc(e)}N.getErrorPath=Sk;function bg(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}N.checkStrictMode=bg});var Ct=w(Vc=>{"use strict";Object.defineProperty(Vc,"__esModule",{value:!0});var be=M(),Ek={data:new be.Name("data"),valCxt:new be.Name("valCxt"),instancePath:new be.Name("instancePath"),parentData:new be.Name("parentData"),parentDataProperty:new be.Name("parentDataProperty"),rootData:new be.Name("rootData"),dynamicAnchors:new be.Name("dynamicAnchors"),vErrors:new be.Name("vErrors"),errors:new be.Name("errors"),this:new be.Name("this"),self:new be.Name("self"),scope:new be.Name("scope"),json:new be.Name("json"),jsonPos:new be.Name("jsonPos"),jsonLen:new be.Name("jsonLen"),jsonPart:new be.Name("jsonPart")};Vc.default=Ek});var Xn=w(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});ve.extendErrors=ve.resetErrorsCount=ve.reportExtraError=ve.reportError=ve.keyword$DataError=ve.keywordError=void 0;var Z=M(),Ks=q(),$e=Ct();ve.keywordError={message:({keyword:e})=>(0,Z.str)`must pass "${e}" keyword validation`};ve.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,Z.str)`"${e}" keyword must be ${t} ($data)`:(0,Z.str)`"${e}" keyword is invalid ($data)`};function bk(e,t=ve.keywordError,r,n){let{it:o}=e,{gen:s,compositeRule:i,allErrors:a}=o,c=kg(e,t,r);n??(i||a)?vg(s,c):wg(o,(0,Z._)`[${c}]`)}ve.reportError=bk;function vk(e,t=ve.keywordError,r){let{it:n}=e,{gen:o,compositeRule:s,allErrors:i}=n,a=kg(e,t,r);vg(o,a),s||i||wg(n,$e.default.vErrors)}ve.reportExtraError=vk;function wk(e,t){e.assign($e.default.errors,t),e.if((0,Z._)`${$e.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,Z._)`${$e.default.vErrors}.length`,t),()=>e.assign($e.default.vErrors,null)))}ve.resetErrorsCount=wk;function kk({gen:e,keyword:t,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=e.name("err");e.forRange("i",o,$e.default.errors,a=>{e.const(i,(0,Z._)`${$e.default.vErrors}[${a}]`),e.if((0,Z._)`${i}.instancePath === undefined`,()=>e.assign((0,Z._)`${i}.instancePath`,(0,Z.strConcat)($e.default.instancePath,s.errorPath))),e.assign((0,Z._)`${i}.schemaPath`,(0,Z.str)`${s.errSchemaPath}/${t}`),s.opts.verbose&&(e.assign((0,Z._)`${i}.schema`,r),e.assign((0,Z._)`${i}.data`,n))})}ve.extendErrors=kk;function vg(e,t){let r=e.const("err",t);e.if((0,Z._)`${$e.default.vErrors} === null`,()=>e.assign($e.default.vErrors,(0,Z._)`[${r}]`),(0,Z._)`${$e.default.vErrors}.push(${r})`),e.code((0,Z._)`${$e.default.errors}++`)}function wg(e,t){let{gen:r,validateName:n,schemaEnv:o}=e;o.$async?r.throw((0,Z._)`new ${e.ValidationError}(${t})`):(r.assign((0,Z._)`${n}.errors`,t),r.return(!1))}var pr={keyword:new Z.Name("keyword"),schemaPath:new Z.Name("schemaPath"),params:new Z.Name("params"),propertyName:new Z.Name("propertyName"),message:new Z.Name("message"),schema:new Z.Name("schema"),parentSchema:new Z.Name("parentSchema")};function kg(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,Z._)`{}`:xk(e,t,r)}function xk(e,t,r={}){let{gen:n,it:o}=e,s=[Pk(o,r),Tk(e,r)];return $k(e,t,s),n.object(...s)}function Pk({errorPath:e},{instancePath:t}){let r=t?(0,Z.str)`${e}${(0,Ks.getErrorPath)(t,Ks.Type.Str)}`:e;return[$e.default.instancePath,(0,Z.strConcat)($e.default.instancePath,r)]}function Tk({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let o=n?t:(0,Z.str)`${t}/${e}`;return r&&(o=(0,Z.str)`${o}${(0,Ks.getErrorPath)(r,Ks.Type.Str)}`),[pr.schemaPath,o]}function $k(e,{params:t,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=e,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([pr.keyword,o],[pr.params,typeof t=="function"?t(e):t||(0,Z._)`{}`]),c.messages&&n.push([pr.message,typeof r=="function"?r(e):r]),c.verbose&&n.push([pr.schema,i],[pr.parentSchema,(0,Z._)`${l}${d}`],[$e.default.data,s]),u&&n.push([pr.propertyName,u])}});var Pg=w(Zr=>{"use strict";Object.defineProperty(Zr,"__esModule",{value:!0});Zr.boolOrEmptySchema=Zr.topBoolOrEmptySchema=void 0;var Rk=Xn(),Ak=M(),Ok=Ct(),Ik={message:"boolean schema is false"};function Ck(e){let{gen:t,schema:r,validateName:n}=e;r===!1?xg(e,!1):typeof r=="object"&&r.$async===!0?t.return(Ok.default.data):(t.assign((0,Ak._)`${n}.errors`,null),t.return(!0))}Zr.topBoolOrEmptySchema=Ck;function Mk(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),xg(e)):r.var(t,!0)}Zr.boolOrEmptySchema=Mk;function xg(e,t){let{gen:r,data:n}=e,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,Rk.reportError)(o,Ik,void 0,t)}});var Yc=w(Wr=>{"use strict";Object.defineProperty(Wr,"__esModule",{value:!0});Wr.getRules=Wr.isJSONType=void 0;var zk=["string","number","integer","boolean","null","object","array"],Dk=new Set(zk);function Nk(e){return typeof e=="string"&&Dk.has(e)}Wr.isJSONType=Nk;function Lk(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Wr.getRules=Lk});var Jc=w(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});Gt.shouldUseRule=Gt.shouldUseGroup=Gt.schemaHasRulesForType=void 0;function jk({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&Tg(e,n)}Gt.schemaHasRulesForType=jk;function Tg(e,t){return t.rules.some(r=>$g(e,r))}Gt.shouldUseGroup=Tg;function $g(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}Gt.shouldUseRule=$g});var Qn=w(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.reportTypeError=we.checkDataTypes=we.checkDataType=we.coerceAndCheckDataType=we.getJSONTypes=we.getSchemaTypes=we.DataType=void 0;var Uk=Yc(),Fk=Jc(),qk=Xn(),C=M(),Rg=q(),Hr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Hr||(we.DataType=Hr={}));function Zk(e){let t=Ag(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}we.getSchemaTypes=Zk;function Ag(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(Uk.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}we.getJSONTypes=Ag;function Wk(e,t){let{gen:r,data:n,opts:o}=e,s=Hk(t,o.coerceTypes),i=t.length>0&&!(s.length===0&&t.length===1&&(0,Fk.schemaHasRulesForType)(e,t[0]));if(i){let a=Qc(t,n,o.strictNumbers,Hr.Wrong);r.if(a,()=>{s.length?Bk(e,t,s):eu(e)})}return i}we.coerceAndCheckDataType=Wk;var Og=new Set(["string","number","integer","boolean","null"]);function Hk(e,t){return t?e.filter(r=>Og.has(r)||t==="array"&&r==="array"):[]}function Bk(e,t,r){let{gen:n,data:o,opts:s}=e,i=n.let("dataType",(0,C._)`typeof ${o}`),a=n.let("coerced",(0,C._)`undefined`);s.coerceTypes==="array"&&n.if((0,C._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,C._)`${o}[0]`).assign(i,(0,C._)`typeof ${o}`).if(Qc(t,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,C._)`${a} !== undefined`);for(let u of r)(Og.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),eu(e),n.endIf(),n.if((0,C._)`${a} !== undefined`,()=>{n.assign(o,a),Kk(e,a)});function c(u){switch(u){case"string":n.elseIf((0,C._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,C._)`"" + ${o}`).elseIf((0,C._)`${o} === null`).assign(a,(0,C._)`""`);return;case"number":n.elseIf((0,C._)`${i} == "boolean" || ${o} === null
|
|
15
|
+
`)}debug(t,r,n,o){this.log(0,t,r,n,o)}info(t,r,n,o){this.log(1,t,r,n,o)}warn(t,r,n,o){this.log(2,t,r,n,o)}setErrorSink(t){oa=t}error(t,r,n,o){this.log(3,t,r,n,o),this.routeErrorToSink(r,n,o)}routeErrorToSink(t,r,n){try{if(!oa||!(n instanceof Error))return;oa(n)}catch{}}dataIn(t,r,n,o){this.info(t,`\u2192 ${r}`,n,o)}dataOut(t,r,n,o){this.info(t,`\u2190 ${r}`,n,o)}success(t,r,n,o){this.info(t,`\u2713 ${r}`,n,o)}failure(t,r,n,o){this.error(t,`\u2717 ${r}`,n,o)}},_=new ia});var Bn=v(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.regexpCode=W.getEsmExportName=W.getProperty=W.safeStringify=W.stringify=W.strConcat=W.addCodeArg=W.str=W._=W.nil=W._Code=W.Name=W.IDENTIFIER=W._CodeOrName=void 0;var Hn=class{};W._CodeOrName=Hn;W.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var ur=class extends Hn{constructor(t){if(super(),!W.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};W.Name=ur;var Qe=class extends Hn{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof ur&&(r[n.str]=(r[n.str]||0)+1),r),{})}};W._Code=Qe;W.nil=new Qe("");function dg(e,...t){let r=[e[0]],n=0;for(;n<t.length;)Ac(r,t[n]),r.push(e[++n]);return new Qe(r)}W._=dg;var Rc=new Qe("+");function fg(e,...t){let r=[Wn(e[0])],n=0;for(;n<t.length;)r.push(Rc),Ac(r,t[n]),r.push(Rc,Wn(e[++n]));return Y0(r),new Qe(r)}W.str=fg;function Ac(e,t){t instanceof Qe?e.push(...t._items):t instanceof ur?e.push(t):e.push(Q0(t))}W.addCodeArg=Ac;function Y0(e){let t=1;for(;t<e.length-1;){if(e[t]===Rc){let r=J0(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function J0(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof ur||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof ur))return`"${e}${t.slice(1)}`}function X0(e,t){return t.emptyStr()?e:e.emptyStr()?t:fg`${e}${t}`}W.strConcat=X0;function Q0(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:Wn(Array.isArray(e)?e.join(","):e)}function ek(e){return new Qe(Wn(e))}W.stringify=ek;function Wn(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}W.safeStringify=Wn;function tk(e){return typeof e=="string"&&W.IDENTIFIER.test(e)?new Qe(`.${e}`):dg`[${e}]`}W.getProperty=tk;function rk(e){if(typeof e=="string"&&W.IDENTIFIER.test(e))return new Qe(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}W.getEsmExportName=rk;function nk(e){return new Qe(e.toString())}W.regexpCode=nk});var Cc=v(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});Le.ValueScope=Le.ValueScopeName=Le.Scope=Le.varKinds=Le.UsedValueState=void 0;var Ne=Bn(),Oc=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},Us;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(Us||(Le.UsedValueState=Us={}));Le.varKinds={const:new Ne.Name("const"),let:new Ne.Name("let"),var:new Ne.Name("var")};var Fs=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof Ne.Name?t:this.name(t)}name(t){return new Ne.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};Le.Scope=Fs;var qs=class extends Ne.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,Ne._)`.${new Ne.Name(r)}[${n}]`}};Le.ValueScopeName=qs;var ok=(0,Ne._)`\n`,Ic=class extends Fs{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?ok:Ne.nil}}get(){return this._scope}name(t){return new qs(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(t),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Ne._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(t,r,n={},o){let s=Ne.nil;for(let i in t){let a=t[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,Us.Started);let l=r(u);if(l){let d=this.opts.es5?Le.varKinds.var:Le.varKinds.const;s=(0,Ne._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,Ne._)`${s}${l}${this.opts._n}`;else throw new Oc(u);c.set(u,Us.Completed)})}return s}};Le.ValueScope=Ic});var M=v(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.or=D.and=D.not=D.CodeGen=D.operators=D.varKinds=D.ValueScopeName=D.ValueScope=D.Scope=D.Name=D.regexpCode=D.stringify=D.getProperty=D.nil=D.strConcat=D.str=D._=void 0;var F=Bn(),lt=Cc(),Kt=Bn();Object.defineProperty(D,"_",{enumerable:!0,get:function(){return Kt._}});Object.defineProperty(D,"str",{enumerable:!0,get:function(){return Kt.str}});Object.defineProperty(D,"strConcat",{enumerable:!0,get:function(){return Kt.strConcat}});Object.defineProperty(D,"nil",{enumerable:!0,get:function(){return Kt.nil}});Object.defineProperty(D,"getProperty",{enumerable:!0,get:function(){return Kt.getProperty}});Object.defineProperty(D,"stringify",{enumerable:!0,get:function(){return Kt.stringify}});Object.defineProperty(D,"regexpCode",{enumerable:!0,get:function(){return Kt.regexpCode}});Object.defineProperty(D,"Name",{enumerable:!0,get:function(){return Kt.Name}});var Bs=Cc();Object.defineProperty(D,"Scope",{enumerable:!0,get:function(){return Bs.Scope}});Object.defineProperty(D,"ValueScope",{enumerable:!0,get:function(){return Bs.ValueScope}});Object.defineProperty(D,"ValueScopeName",{enumerable:!0,get:function(){return Bs.ValueScopeName}});Object.defineProperty(D,"varKinds",{enumerable:!0,get:function(){return Bs.varKinds}});D.operators={GT:new F._Code(">"),GTE:new F._Code(">="),LT:new F._Code("<"),LTE:new F._Code("<="),EQ:new F._Code("==="),NEQ:new F._Code("!=="),NOT:new F._Code("!"),OR:new F._Code("||"),AND:new F._Code("&&"),ADD:new F._Code("+")};var Ot=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},Mc=class extends Ot{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?lt.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=Zr(this.rhs,t,r)),this}get names(){return this.rhs instanceof F._CodeOrName?this.rhs.names:{}}},Zs=class extends Ot{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof F.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=Zr(this.rhs,t,r),this}get names(){let t=this.lhs instanceof F.Name?{}:{...this.lhs.names};return Ws(t,this.rhs)}},zc=class extends Zs{constructor(t,r,n,o){super(t,n,o),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},Dc=class extends Ot{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},Nc=class extends Ot{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},Lc=class extends Ot{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},jc=class extends Ot{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=Zr(this.code,t,r),this}get names(){return this.code instanceof F._CodeOrName?this.code.names:{}}},Kn=class extends Ot{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(t,r)||(sk(t,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>fr(t,r.names),{})}},It=class extends Kn{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},Uc=class extends Kn{},qr=class extends It{};qr.kind="else";var lr=class e extends It{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new qr(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(pg(t),r instanceof e?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=Zr(this.condition,t,r),this}get names(){let t=super.names;return Ws(t,this.condition),this.else&&fr(t,this.else.names),t}};lr.kind="if";var dr=class extends It{};dr.kind="for";var Fc=class extends dr{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=Zr(this.iteration,t,r),this}get names(){return fr(super.names,this.iteration.names)}},qc=class extends dr{constructor(t,r,n,o){super(),this.varKind=t,this.name=r,this.from=n,this.to=o}render(t){let r=t.es5?lt.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(t)}get names(){let t=Ws(super.names,this.from);return Ws(t,this.to)}},Hs=class extends dr{constructor(t,r,n,o){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=o}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=Zr(this.iterable,t,r),this}get names(){return fr(super.names,this.iterable.names)}},Gn=class extends It{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};Gn.kind="func";var Vn=class extends Kn{render(t){return"return "+super.render(t)}};Vn.kind="return";var Zc=class extends It{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,o;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(o=this.finally)===null||o===void 0||o.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&fr(t,this.catch.names),this.finally&&fr(t,this.finally.names),t}},Yn=class extends It{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};Yn.kind="catch";var Jn=class extends It{render(t){return"finally"+super.render(t)}};Jn.kind="finally";var Hc=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
16
|
+
`:""},this._extScope=t,this._scope=new lt.Scope({parent:t}),this._nodes=[new Uc]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new Mc(t,s,n)),s}const(t,r,n){return this._def(lt.varKinds.const,t,r,n)}let(t,r,n){return this._def(lt.varKinds.let,t,r,n)}var(t,r,n){return this._def(lt.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new Zs(t,r,n))}add(t,r){return this._leafNode(new zc(t,D.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==F.nil&&this._leafNode(new jc(t)),this}object(...t){let r=["{"];for(let[n,o]of t)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,F.addCodeArg)(r,o));return r.push("}"),new F._Code(r)}if(t,r,n){if(this._blockNode(new lr(t)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new lr(t))}else(){return this._elseNode(new qr)}endIf(){return this._endBlockNode(lr,qr)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new Fc(t),r)}forRange(t,r,n,o,s=this.opts.es5?lt.varKinds.var:lt.varKinds.let){let i=this._scope.toName(t);return this._for(new qc(s,i,r,n),()=>o(i))}forOf(t,r,n,o=lt.varKinds.const){let s=this._scope.toName(t);if(this.opts.es5){let i=r instanceof F.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,F._)`${i}.length`,a=>{this.var(s,(0,F._)`${i}[${a}]`),n(s)})}return this._for(new Hs("of",o,s,r),()=>n(s))}forIn(t,r,n,o=this.opts.es5?lt.varKinds.var:lt.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,F._)`Object.keys(${r})`,n);let s=this._scope.toName(t);return this._for(new Hs("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(dr)}label(t){return this._leafNode(new Dc(t))}break(t){return this._leafNode(new Nc(t))}return(t){let r=new Vn;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Vn)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new Zc;if(this._blockNode(o),this.code(t),r){let s=this.name("e");this._currNode=o.catch=new Yn(s),r(s)}return n&&(this._currNode=o.finally=new Jn,this.code(n)),this._endBlockNode(Yn,Jn)}throw(t){return this._leafNode(new Lc(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=F.nil,n,o){return this._blockNode(new Gn(t,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(Gn)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof lr))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};D.CodeGen=Hc;function fr(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function Ws(e,t){return t instanceof F._CodeOrName?fr(e,t.names):e}function Zr(e,t,r){if(e instanceof F.Name)return n(e);if(!o(e))return e;return new F._Code(e._items.reduce((s,i)=>(i instanceof F.Name&&(i=n(i)),i instanceof F._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||t[s.str]!==1?s:(delete t[s.str],i)}function o(s){return s instanceof F._Code&&s._items.some(i=>i instanceof F.Name&&t[i.str]===1&&r[i.str]!==void 0)}}function sk(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function pg(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,F._)`!${Wc(e)}`}D.not=pg;var ik=mg(D.operators.AND);function ak(...e){return e.reduce(ik)}D.and=ak;var ck=mg(D.operators.OR);function uk(...e){return e.reduce(ck)}D.or=uk;function mg(e){return(t,r)=>t===F.nil?r:r===F.nil?t:(0,F._)`${Wc(t)} ${e} ${Wc(r)}`}function Wc(e){return e instanceof F.Name?e:(0,F._)`(${e})`}});var q=v(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.checkStrictMode=N.getErrorPath=N.Type=N.useFunc=N.setEvaluated=N.evaluatedPropsToName=N.mergeEvaluated=N.eachItem=N.unescapeJsonPointer=N.escapeJsonPointer=N.escapeFragment=N.unescapeFragment=N.schemaRefOrVal=N.schemaHasRulesButRef=N.schemaHasRules=N.checkUnknownRules=N.alwaysValidSchema=N.toHash=void 0;var V=M(),lk=Bn();function dk(e){let t={};for(let r of e)t[r]=!0;return t}N.toHash=dk;function fk(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(_g(e,t),!yg(t,e.self.RULES.all))}N.alwaysValidSchema=fk;function _g(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let o=n.RULES.keywords;for(let s in t)o[s]||bg(e,`unknown keyword: "${s}"`)}N.checkUnknownRules=_g;function yg(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}N.schemaHasRules=yg;function pk(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}N.schemaHasRulesButRef=pk;function mk({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,V._)`${r}`}return(0,V._)`${e}${t}${(0,V.getProperty)(n)}`}N.schemaRefOrVal=mk;function hk(e){return Sg(decodeURIComponent(e))}N.unescapeFragment=hk;function gk(e){return encodeURIComponent(Kc(e))}N.escapeFragment=gk;function Kc(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}N.escapeJsonPointer=Kc;function Sg(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}N.unescapeJsonPointer=Sg;function _k(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}N.eachItem=_k;function hg({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof V.Name?(s instanceof V.Name?e(o,s,i):t(o,s,i),i):s instanceof V.Name?(t(o,i,s),s):r(s,i);return a===V.Name&&!(c instanceof V.Name)?n(o,c):c}}N.mergeEvaluated={props:hg({mergeNames:(e,t,r)=>e.if((0,V._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,V._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,V._)`${r} || {}`).code((0,V._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,V._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,V._)`${r} || {}`),Gc(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Eg}),items:hg({mergeNames:(e,t,r)=>e.if((0,V._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,V._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,V._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,V._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Eg(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,V._)`{}`);return t!==void 0&&Gc(e,r,t),r}N.evaluatedPropsToName=Eg;function Gc(e,t,r){Object.keys(r).forEach(n=>e.assign((0,V._)`${t}${(0,V.getProperty)(n)}`,!0))}N.setEvaluated=Gc;var gg={};function yk(e,t){return e.scopeValue("func",{ref:t,code:gg[t.code]||(gg[t.code]=new lk._Code(t.code))})}N.useFunc=yk;var Bc;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Bc||(N.Type=Bc={}));function Sk(e,t,r){if(e instanceof V.Name){let n=t===Bc.Num;return r?n?(0,V._)`"[" + ${e} + "]"`:(0,V._)`"['" + ${e} + "']"`:n?(0,V._)`"/" + ${e}`:(0,V._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,V.getProperty)(e).toString():"/"+Kc(e)}N.getErrorPath=Sk;function bg(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}N.checkStrictMode=bg});var Ct=v(Vc=>{"use strict";Object.defineProperty(Vc,"__esModule",{value:!0});var be=M(),Ek={data:new be.Name("data"),valCxt:new be.Name("valCxt"),instancePath:new be.Name("instancePath"),parentData:new be.Name("parentData"),parentDataProperty:new be.Name("parentDataProperty"),rootData:new be.Name("rootData"),dynamicAnchors:new be.Name("dynamicAnchors"),vErrors:new be.Name("vErrors"),errors:new be.Name("errors"),this:new be.Name("this"),self:new be.Name("self"),scope:new be.Name("scope"),json:new be.Name("json"),jsonPos:new be.Name("jsonPos"),jsonLen:new be.Name("jsonLen"),jsonPart:new be.Name("jsonPart")};Vc.default=Ek});var Xn=v(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.extendErrors=we.resetErrorsCount=we.reportExtraError=we.reportError=we.keyword$DataError=we.keywordError=void 0;var Z=M(),Ks=q(),$e=Ct();we.keywordError={message:({keyword:e})=>(0,Z.str)`must pass "${e}" keyword validation`};we.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,Z.str)`"${e}" keyword must be ${t} ($data)`:(0,Z.str)`"${e}" keyword is invalid ($data)`};function bk(e,t=we.keywordError,r,n){let{it:o}=e,{gen:s,compositeRule:i,allErrors:a}=o,c=kg(e,t,r);n??(i||a)?wg(s,c):vg(o,(0,Z._)`[${c}]`)}we.reportError=bk;function wk(e,t=we.keywordError,r){let{it:n}=e,{gen:o,compositeRule:s,allErrors:i}=n,a=kg(e,t,r);wg(o,a),s||i||vg(n,$e.default.vErrors)}we.reportExtraError=wk;function vk(e,t){e.assign($e.default.errors,t),e.if((0,Z._)`${$e.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,Z._)`${$e.default.vErrors}.length`,t),()=>e.assign($e.default.vErrors,null)))}we.resetErrorsCount=vk;function kk({gen:e,keyword:t,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=e.name("err");e.forRange("i",o,$e.default.errors,a=>{e.const(i,(0,Z._)`${$e.default.vErrors}[${a}]`),e.if((0,Z._)`${i}.instancePath === undefined`,()=>e.assign((0,Z._)`${i}.instancePath`,(0,Z.strConcat)($e.default.instancePath,s.errorPath))),e.assign((0,Z._)`${i}.schemaPath`,(0,Z.str)`${s.errSchemaPath}/${t}`),s.opts.verbose&&(e.assign((0,Z._)`${i}.schema`,r),e.assign((0,Z._)`${i}.data`,n))})}we.extendErrors=kk;function wg(e,t){let r=e.const("err",t);e.if((0,Z._)`${$e.default.vErrors} === null`,()=>e.assign($e.default.vErrors,(0,Z._)`[${r}]`),(0,Z._)`${$e.default.vErrors}.push(${r})`),e.code((0,Z._)`${$e.default.errors}++`)}function vg(e,t){let{gen:r,validateName:n,schemaEnv:o}=e;o.$async?r.throw((0,Z._)`new ${e.ValidationError}(${t})`):(r.assign((0,Z._)`${n}.errors`,t),r.return(!1))}var pr={keyword:new Z.Name("keyword"),schemaPath:new Z.Name("schemaPath"),params:new Z.Name("params"),propertyName:new Z.Name("propertyName"),message:new Z.Name("message"),schema:new Z.Name("schema"),parentSchema:new Z.Name("parentSchema")};function kg(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,Z._)`{}`:xk(e,t,r)}function xk(e,t,r={}){let{gen:n,it:o}=e,s=[Pk(o,r),Tk(e,r)];return $k(e,t,s),n.object(...s)}function Pk({errorPath:e},{instancePath:t}){let r=t?(0,Z.str)`${e}${(0,Ks.getErrorPath)(t,Ks.Type.Str)}`:e;return[$e.default.instancePath,(0,Z.strConcat)($e.default.instancePath,r)]}function Tk({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let o=n?t:(0,Z.str)`${t}/${e}`;return r&&(o=(0,Z.str)`${o}${(0,Ks.getErrorPath)(r,Ks.Type.Str)}`),[pr.schemaPath,o]}function $k(e,{params:t,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=e,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([pr.keyword,o],[pr.params,typeof t=="function"?t(e):t||(0,Z._)`{}`]),c.messages&&n.push([pr.message,typeof r=="function"?r(e):r]),c.verbose&&n.push([pr.schema,i],[pr.parentSchema,(0,Z._)`${l}${d}`],[$e.default.data,s]),u&&n.push([pr.propertyName,u])}});var Pg=v(Hr=>{"use strict";Object.defineProperty(Hr,"__esModule",{value:!0});Hr.boolOrEmptySchema=Hr.topBoolOrEmptySchema=void 0;var Rk=Xn(),Ak=M(),Ok=Ct(),Ik={message:"boolean schema is false"};function Ck(e){let{gen:t,schema:r,validateName:n}=e;r===!1?xg(e,!1):typeof r=="object"&&r.$async===!0?t.return(Ok.default.data):(t.assign((0,Ak._)`${n}.errors`,null),t.return(!0))}Hr.topBoolOrEmptySchema=Ck;function Mk(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),xg(e)):r.var(t,!0)}Hr.boolOrEmptySchema=Mk;function xg(e,t){let{gen:r,data:n}=e,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,Rk.reportError)(o,Ik,void 0,t)}});var Yc=v(Wr=>{"use strict";Object.defineProperty(Wr,"__esModule",{value:!0});Wr.getRules=Wr.isJSONType=void 0;var zk=["string","number","integer","boolean","null","object","array"],Dk=new Set(zk);function Nk(e){return typeof e=="string"&&Dk.has(e)}Wr.isJSONType=Nk;function Lk(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Wr.getRules=Lk});var Jc=v(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});Gt.shouldUseRule=Gt.shouldUseGroup=Gt.schemaHasRulesForType=void 0;function jk({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&Tg(e,n)}Gt.schemaHasRulesForType=jk;function Tg(e,t){return t.rules.some(r=>$g(e,r))}Gt.shouldUseGroup=Tg;function $g(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}Gt.shouldUseRule=$g});var Qn=v(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});ve.reportTypeError=ve.checkDataTypes=ve.checkDataType=ve.coerceAndCheckDataType=ve.getJSONTypes=ve.getSchemaTypes=ve.DataType=void 0;var Uk=Yc(),Fk=Jc(),qk=Xn(),C=M(),Rg=q(),Br;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Br||(ve.DataType=Br={}));function Zk(e){let t=Ag(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}ve.getSchemaTypes=Zk;function Ag(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(Uk.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}ve.getJSONTypes=Ag;function Hk(e,t){let{gen:r,data:n,opts:o}=e,s=Wk(t,o.coerceTypes),i=t.length>0&&!(s.length===0&&t.length===1&&(0,Fk.schemaHasRulesForType)(e,t[0]));if(i){let a=Qc(t,n,o.strictNumbers,Br.Wrong);r.if(a,()=>{s.length?Bk(e,t,s):eu(e)})}return i}ve.coerceAndCheckDataType=Hk;var Og=new Set(["string","number","integer","boolean","null"]);function Wk(e,t){return t?e.filter(r=>Og.has(r)||t==="array"&&r==="array"):[]}function Bk(e,t,r){let{gen:n,data:o,opts:s}=e,i=n.let("dataType",(0,C._)`typeof ${o}`),a=n.let("coerced",(0,C._)`undefined`);s.coerceTypes==="array"&&n.if((0,C._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,C._)`${o}[0]`).assign(i,(0,C._)`typeof ${o}`).if(Qc(t,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,C._)`${a} !== undefined`);for(let u of r)(Og.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),eu(e),n.endIf(),n.if((0,C._)`${a} !== undefined`,()=>{n.assign(o,a),Kk(e,a)});function c(u){switch(u){case"string":n.elseIf((0,C._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,C._)`"" + ${o}`).elseIf((0,C._)`${o} === null`).assign(a,(0,C._)`""`);return;case"number":n.elseIf((0,C._)`${i} == "boolean" || ${o} === null
|
|
17
17
|
|| (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,C._)`+${o}`);return;case"integer":n.elseIf((0,C._)`${i} === "boolean" || ${o} === null
|
|
18
18
|
|| (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,C._)`+${o}`);return;case"boolean":n.elseIf((0,C._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf((0,C._)`${o} === "true" || ${o} === 1`).assign(a,!0);return;case"null":n.elseIf((0,C._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(a,null);return;case"array":n.elseIf((0,C._)`${i} === "string" || ${i} === "number"
|
|
19
|
-
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,C._)`[${o}]`)}}}function Kk({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,C._)`${t} !== undefined`,()=>e.assign((0,C._)`${t}[${r}]`,n))}function Xc(e,t,r,n=Hr.Correct){let o=n===Hr.Correct?C.operators.EQ:C.operators.NEQ,s;switch(e){case"null":return(0,C._)`${t} ${o} null`;case"array":s=(0,C._)`Array.isArray(${t})`;break;case"object":s=(0,C._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=i((0,C._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=i();break;default:return(0,C._)`typeof ${t} ${o} ${e}`}return n===Hr.Correct?s:(0,C.not)(s);function i(a=C.nil){return(0,C.and)((0,C._)`typeof ${t} == "number"`,a,r?(0,C._)`isFinite(${t})`:C.nil)}}we.checkDataType=Xc;function Qc(e,t,r,n){if(e.length===1)return Xc(e[0],t,r,n);let o,s=(0,Rg.toHash)(e);if(s.array&&s.object){let i=(0,C._)`typeof ${t} != "object"`;o=s.null?i:(0,C._)`!${t} || ${i}`,delete s.null,delete s.array,delete s.object}else o=C.nil;s.number&&delete s.integer;for(let i in s)o=(0,C.and)(o,Xc(i,t,r,n));return o}we.checkDataTypes=Qc;var Gk={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,C._)`{type: ${e}}`:(0,C._)`{type: ${t}}`};function eu(e){let t=Vk(e);(0,qk.reportError)(t,Gk)}we.reportTypeError=eu;function Vk(e){let{gen:t,data:r,schema:n}=e,o=(0,Rg.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}});var Cg=w(Gs=>{"use strict";Object.defineProperty(Gs,"__esModule",{value:!0});Gs.assignDefaults=void 0;var Br=M(),Yk=q();function Jk(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let o in r)Ig(e,o,r[o].default);else t==="array"&&Array.isArray(n)&&n.forEach((o,s)=>Ig(e,s,o.default))}Gs.assignDefaults=Jk;function Ig(e,t,r){let{gen:n,compositeRule:o,data:s,opts:i}=e;if(r===void 0)return;let a=(0,Br._)`${s}${(0,Br.getProperty)(t)}`;if(o){(0,Yk.checkStrictMode)(e,`default is ignored for: ${a}`);return}let c=(0,Br._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,Br._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Br._)`${a} = ${(0,Br.stringify)(r)}`)}});var et=w(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.validateUnion=G.validateArray=G.usePattern=G.callValidateCode=G.schemaProperties=G.allSchemaProperties=G.noPropertyInData=G.propertyInData=G.isOwnProperty=G.hasPropFunc=G.reportMissingProp=G.checkMissingProp=G.checkReportMissingProp=void 0;var re=M(),tu=q(),Vt=Ct(),Xk=q();function Qk(e,t){let{gen:r,data:n,it:o}=e;r.if(nu(r,n,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:(0,re._)`${t}`},!0),e.error()})}G.checkReportMissingProp=Qk;function ex({gen:e,data:t,it:{opts:r}},n,o){return(0,re.or)(...n.map(s=>(0,re.and)(nu(e,t,s,r.ownProperties),(0,re._)`${o} = ${s}`)))}G.checkMissingProp=ex;function tx(e,t){e.setParams({missingProperty:t},!0),e.error()}G.reportMissingProp=tx;function Mg(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,re._)`Object.prototype.hasOwnProperty`})}G.hasPropFunc=Mg;function ru(e,t,r){return(0,re._)`${Mg(e)}.call(${t}, ${r})`}G.isOwnProperty=ru;function rx(e,t,r,n){let o=(0,re._)`${t}${(0,re.getProperty)(r)} !== undefined`;return n?(0,re._)`${o} && ${ru(e,t,r)}`:o}G.propertyInData=rx;function nu(e,t,r,n){let o=(0,re._)`${t}${(0,re.getProperty)(r)} === undefined`;return n?(0,re.or)(o,(0,re.not)(ru(e,t,r))):o}G.noPropertyInData=nu;function zg(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}G.allSchemaProperties=zg;function nx(e,t){return zg(t).filter(r=>!(0,tu.alwaysValidSchema)(e,t[r]))}G.schemaProperties=nx;function ox({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,re._)`${e}, ${t}, ${n}${o}`:t,d=[[Vt.default.instancePath,(0,re.strConcat)(Vt.default.instancePath,s)],[Vt.default.parentData,i.parentData],[Vt.default.parentDataProperty,i.parentDataProperty],[Vt.default.rootData,Vt.default.rootData]];i.opts.dynamicRef&&d.push([Vt.default.dynamicAnchors,Vt.default.dynamicAnchors]);let f=(0,re._)`${l}, ${r.object(...d)}`;return c!==re.nil?(0,re._)`${a}.call(${c}, ${f})`:(0,re._)`${a}(${f})`}G.callValidateCode=ox;var sx=(0,re._)`new RegExp`;function ix({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:o}=t.code,s=o(r,n);return e.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,re._)`${o.code==="new RegExp"?sx:(0,Xk.useFunc)(e,o)}(${r}, ${n})`})}G.usePattern=ix;function ax(e){let{gen:t,data:r,keyword:n,it:o}=e,s=t.name("valid");if(o.allErrors){let a=t.let("valid",!0);return i(()=>t.assign(a,!1)),a}return t.var(s,!0),i(()=>t.break()),s;function i(a){let c=t.const("len",(0,re._)`${r}.length`);t.forRange("i",0,c,u=>{e.subschema({keyword:n,dataProp:u,dataPropType:tu.Type.Num},s),t.if((0,re.not)(s),a)})}}G.validateArray=ax;function cx(e){let{gen:t,schema:r,keyword:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,tu.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=t.let("valid",!1),a=t.name("_valid");t.block(()=>r.forEach((c,u)=>{let l=e.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);t.assign(i,(0,re._)`${i} || ${a}`),e.mergeValidEvaluated(l,a)||t.if((0,re.not)(i))})),e.result(i,()=>e.reset(),()=>e.error(!0))}G.validateUnion=cx});var Lg=w(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.validateKeywordUsage=St.validSchemaType=St.funcKeywordCode=St.macroKeywordCode=void 0;var Re=M(),mr=Ct(),ux=et(),lx=Xn();function dx(e,t){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=e,a=t.macro.call(i.self,o,s,i),c=Ng(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");e.subschema({schema:a,schemaPath:Re.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),e.pass(u,()=>e.error(!0))}St.macroKeywordCode=dx;function fx(e,t){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=e;mx(c,t);let u=!a&&t.compile?t.compile.call(c.self,s,i,c):t.validate,l=Ng(n,o,u),d=n.let("valid");e.block$data(d,f),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function f(){if(t.errors===!1)h(),t.modifying&&Dg(e),g(()=>e.error());else{let y=t.async?p():m();t.modifying&&Dg(e),g(()=>px(e,y))}}function p(){let y=n.let("ruleErrs",null);return n.try(()=>h((0,Re._)`await `),b=>n.assign(d,!1).if((0,Re._)`${b} instanceof ${c.ValidationError}`,()=>n.assign(y,(0,Re._)`${b}.errors`),()=>n.throw(b))),y}function m(){let y=(0,Re._)`${l}.errors`;return n.assign(y,null),h(Re.nil),y}function h(y=t.async?(0,Re._)`await `:Re.nil){let b=c.opts.passContext?mr.default.this:mr.default.self,v=!("compile"in t&&!a||t.schema===!1);n.assign(d,(0,Re._)`${y}${(0,ux.callValidateCode)(e,l,b,v)}`,t.modifying)}function g(y){var b;n.if((0,Re.not)((b=t.valid)!==null&&b!==void 0?b:d),y)}}St.funcKeywordCode=fx;function Dg(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Re._)`${n.parentData}[${n.parentDataProperty}]`))}function px(e,t){let{gen:r}=e;r.if((0,Re._)`Array.isArray(${t})`,()=>{r.assign(mr.default.vErrors,(0,Re._)`${mr.default.vErrors} === null ? ${t} : ${mr.default.vErrors}.concat(${t})`).assign(mr.default.errors,(0,Re._)`${mr.default.vErrors}.length`),(0,lx.extendErrors)(e)},()=>e.error())}function mx({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function Ng(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Re.stringify)(r)})}function hx(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}St.validSchemaType=hx;function gx({schema:e,opts:t,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");let i=o.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(e,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(e[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}St.validateKeywordUsage=gx});var Ug=w(Yt=>{"use strict";Object.defineProperty(Yt,"__esModule",{value:!0});Yt.extendSubschemaMode=Yt.extendSubschemaData=Yt.getSubschema=void 0;var Et=M(),jg=q();function _x(e,{keyword:t,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let a=e.schema[t];return r===void 0?{schema:a,schemaPath:(0,Et._)`${e.schemaPath}${(0,Et.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[r],schemaPath:(0,Et._)`${e.schemaPath}${(0,Et.getProperty)(t)}${(0,Et.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,jg.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')}Yt.getSubschema=_x;function yx(e,t,{dataProp:r,dataPropType:n,data:o,dataTypes:s,propertyName:i}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=t;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=t,f=a.let("data",(0,Et._)`${t.data}${(0,Et.getProperty)(r)}`,!0);c(f),e.errorPath=(0,Et.str)`${u}${(0,jg.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0,Et._)`${r}`,e.dataPathArr=[...l,e.parentDataProperty]}if(o!==void 0){let u=o instanceof Et.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(e.propertyName=i)}s&&(e.dataTypes=s);function c(u){e.data=u,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,u]}}Yt.extendSubschemaData=yx;function Sx(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(e.compositeRule=n),o!==void 0&&(e.createErrors=o),s!==void 0&&(e.allErrors=s),e.jtdDiscriminator=t,e.jtdMetadata=r}Yt.extendSubschemaMode=Sx});var ou=w((h1,Fg)=>{"use strict";Fg.exports=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!e(t[o],r[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(s=Object.keys(t),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var i=s[o];if(!e(t[i],r[i]))return!1}return!0}return t!==t&&r!==r}});var Zg=w((g1,qg)=>{"use strict";var Jt=qg.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};Vs(t,n,o,e,"",e)};Jt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Jt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Jt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Jt.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 Vs(e,t,r,n,o,s,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,o,s,i,a,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in Jt.arrayKeywords)for(var f=0;f<d.length;f++)Vs(e,t,r,d[f],o+"/"+l+"/"+f,s,o,l,n,f)}else if(l in Jt.propsKeywords){if(d&&typeof d=="object")for(var p in d)Vs(e,t,r,d[p],o+"/"+l+"/"+Ex(p),s,o,l,n,p)}else(l in Jt.keywords||e.allKeys&&!(l in Jt.skipKeywords))&&Vs(e,t,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function Ex(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var eo=w(je=>{"use strict";Object.defineProperty(je,"__esModule",{value:!0});je.getSchemaRefs=je.resolveUrl=je.normalizeId=je._getFullPath=je.getFullPath=je.inlineRef=void 0;var bx=q(),vx=ou(),wx=Zg(),kx=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function xx(e,t=!0){return typeof e=="boolean"?!0:t===!0?!su(e):t?Wg(e)<=t:!1}je.inlineRef=xx;var Px=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function su(e){for(let t in e){if(Px.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(su)||typeof r=="object"&&su(r))return!0}return!1}function Wg(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!kx.has(r)&&(typeof e[r]=="object"&&(0,bx.eachItem)(e[r],n=>t+=Wg(n)),t===1/0))return 1/0}return t}function Hg(e,t="",r){r!==!1&&(t=Kr(t));let n=e.parse(t);return Bg(e,n)}je.getFullPath=Hg;function Bg(e,t){return e.serialize(t).split("#")[0]+"#"}je._getFullPath=Bg;var Tx=/#\/?$/;function Kr(e){return e?e.replace(Tx,""):""}je.normalizeId=Kr;function $x(e,t,r){return r=Kr(r),e.resolve(t,r)}je.resolveUrl=$x;var Rx=/^[a-z_][-a-z0-9._]*$/i;function Ax(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=Kr(e[r]||t),s={"":o},i=Hg(n,o,!1),a={},c=new Set;return wx(e,{allKeys:!0},(d,f,p,m)=>{if(m===void 0)return;let h=i+f,g=s[m];typeof d[r]=="string"&&(g=y.call(this,d[r])),b.call(this,d.$anchor),b.call(this,d.$dynamicAnchor),s[f]=g;function y(v){let O=this.opts.uriResolver.resolve;if(v=Kr(g?O(g,v):v),c.has(v))throw l(v);c.add(v);let x=this.refs[v];return typeof x=="string"&&(x=this.refs[x]),typeof x=="object"?u(d,x.schema,v):v!==Kr(h)&&(v[0]==="#"?(u(d,a[v],v),a[v]=d):this.refs[v]=h),v}function b(v){if(typeof v=="string"){if(!Rx.test(v))throw new Error(`invalid anchor "${v}"`);y.call(this,`#${v}`)}}}),a;function u(d,f,p){if(f!==void 0&&!vx(d,f))throw l(p)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}je.getSchemaRefs=Ax});var no=w(Xt=>{"use strict";Object.defineProperty(Xt,"__esModule",{value:!0});Xt.getData=Xt.KeywordCxt=Xt.validateFunctionCode=void 0;var Jg=Pg(),Kg=Qn(),au=Jc(),Ys=Qn(),Ox=Cg(),ro=Lg(),iu=Ug(),T=M(),A=Ct(),Ix=eo(),Mt=q(),to=Xn();function Cx(e){if(e_(e)&&(t_(e),Qg(e))){Dx(e);return}Xg(e,()=>(0,Jg.topBoolOrEmptySchema)(e))}Xt.validateFunctionCode=Cx;function Xg({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},s){o.code.es5?e.func(t,(0,T._)`${A.default.data}, ${A.default.valCxt}`,n.$async,()=>{e.code((0,T._)`"use strict"; ${Gg(r,o)}`),zx(e,o),e.code(s)}):e.func(t,(0,T._)`${A.default.data}, ${Mx(o)}`,n.$async,()=>e.code(Gg(r,o)).code(s))}function Mx(e){return(0,T._)`{${A.default.instancePath}="", ${A.default.parentData}, ${A.default.parentDataProperty}, ${A.default.rootData}=${A.default.data}${e.dynamicRef?(0,T._)`, ${A.default.dynamicAnchors}={}`:T.nil}}={}`}function zx(e,t){e.if(A.default.valCxt,()=>{e.var(A.default.instancePath,(0,T._)`${A.default.valCxt}.${A.default.instancePath}`),e.var(A.default.parentData,(0,T._)`${A.default.valCxt}.${A.default.parentData}`),e.var(A.default.parentDataProperty,(0,T._)`${A.default.valCxt}.${A.default.parentDataProperty}`),e.var(A.default.rootData,(0,T._)`${A.default.valCxt}.${A.default.rootData}`),t.dynamicRef&&e.var(A.default.dynamicAnchors,(0,T._)`${A.default.valCxt}.${A.default.dynamicAnchors}`)},()=>{e.var(A.default.instancePath,(0,T._)`""`),e.var(A.default.parentData,(0,T._)`undefined`),e.var(A.default.parentDataProperty,(0,T._)`undefined`),e.var(A.default.rootData,A.default.data),t.dynamicRef&&e.var(A.default.dynamicAnchors,(0,T._)`{}`)})}function Dx(e){let{schema:t,opts:r,gen:n}=e;Xg(e,()=>{r.$comment&&t.$comment&&n_(e),Fx(e),n.let(A.default.vErrors,null),n.let(A.default.errors,0),r.unevaluated&&Nx(e),r_(e),Wx(e)})}function Nx(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,T._)`${r}.evaluated`),t.if((0,T._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,T._)`${e.evaluated}.props`,(0,T._)`undefined`)),t.if((0,T._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,T._)`${e.evaluated}.items`,(0,T._)`undefined`))}function Gg(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,T._)`/*# sourceURL=${r} */`:T.nil}function Lx(e,t){if(e_(e)&&(t_(e),Qg(e))){jx(e,t);return}(0,Jg.boolOrEmptySchema)(e,t)}function Qg({schema:e,self:t}){if(typeof e=="boolean")return!e;for(let r in e)if(t.RULES.all[r])return!0;return!1}function e_(e){return typeof e.schema!="boolean"}function jx(e,t){let{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&n_(e),qx(e),Zx(e);let s=n.const("_errs",A.default.errors);r_(e,s),n.var(t,(0,T._)`${s} === ${A.default.errors}`)}function t_(e){(0,Mt.checkUnknownRules)(e),Ux(e)}function r_(e,t){if(e.opts.jtd)return Vg(e,[],!1,t);let r=(0,Kg.getSchemaTypes)(e.schema),n=(0,Kg.coerceAndCheckDataType)(e,r);Vg(e,r,!n,t)}function Ux(e){let{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,Mt.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function Fx(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Mt.checkStrictMode)(e,"default is ignored in the schema root")}function qx(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,Ix.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function Zx(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function n_({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)e.code((0,T._)`${A.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,T.str)`${n}/$comment`,a=e.scopeValue("root",{ref:t.root});e.code((0,T._)`${A.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function Wx(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=e;r.$async?t.if((0,T._)`${A.default.errors} === 0`,()=>t.return(A.default.data),()=>t.throw((0,T._)`new ${o}(${A.default.vErrors})`)):(t.assign((0,T._)`${n}.errors`,A.default.vErrors),s.unevaluated&&Hx(e),t.return((0,T._)`${A.default.errors} === 0`))}function Hx({gen:e,evaluated:t,props:r,items:n}){r instanceof T.Name&&e.assign((0,T._)`${t}.props`,r),n instanceof T.Name&&e.assign((0,T._)`${t}.items`,n)}function Vg(e,t,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:u}=e,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,Mt.schemaHasRulesButRef)(s,l))){o.block(()=>s_(e,"$ref",l.all.$ref.definition));return}c.jtd||Bx(e,t),o.block(()=>{for(let f of l.rules)d(f);d(l.post)});function d(f){(0,au.shouldUseGroup)(s,f)&&(f.type?(o.if((0,Ys.checkDataType)(f.type,i,c.strictNumbers)),Yg(e,f),t.length===1&&t[0]===f.type&&r&&(o.else(),(0,Ys.reportTypeError)(e)),o.endIf()):Yg(e,f),a||o.if((0,T._)`${A.default.errors} === ${n||0}`))}}function Yg(e,t){let{gen:r,schema:n,opts:{useDefaults:o}}=e;o&&(0,Ox.assignDefaults)(e,t.type),r.block(()=>{for(let s of t.rules)(0,au.shouldUseRule)(n,s)&&s_(e,s.keyword,s.definition,t.type)})}function Bx(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(Kx(e,t),e.opts.allowUnionTypes||Gx(e,t),Vx(e,e.dataTypes))}function Kx(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{o_(e.dataTypes,r)||cu(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),Jx(e,t)}}function Gx(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&cu(e,"use allowUnionTypes to allow union type keyword")}function Vx(e,t){let r=e.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,au.shouldUseRule)(e.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>Yx(t,i))&&cu(e,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function Yx(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function o_(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function Jx(e,t){let r=[];for(let n of e.dataTypes)o_(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function cu(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,Mt.checkStrictMode)(e,t,e.opts.strictTypes)}var Js=class{constructor(t,r,n){if((0,ro.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Mt.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",i_(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,ro.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",A.default.errors))}result(t,r,n){this.failResult((0,T.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,T.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0,T._)`${r} !== undefined && (${(0,T.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?to.reportExtraError:to.reportError)(this,this.def.error,r)}$dataError(){(0,to.reportError)(this,this.def.$dataError||to.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,to.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=T.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=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)),t!==T.nil&&n.assign(t,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==T.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,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,Ys.checkDataTypes)(c,r,s.opts.strictNumbers,Ys.DataType.Wrong)}`}return T.nil}function a(){if(o.validateSchema){let c=t.scopeValue("validate$data",{ref:o.validateSchema});return(0,T._)`!${c}(${r})`}return T.nil}}subschema(t,r){let n=(0,iu.getSubschema)(this.it,t);(0,iu.extendSubschemaData)(n,this.it,t),(0,iu.extendSubschemaMode)(n,t);let o={...this.it,...n,items:void 0,props:void 0};return Lx(o,r),o}mergeEvaluated(t,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=Mt.mergeEvaluated.props(o,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=Mt.mergeEvaluated.items(o,t.items,n.items,r)))}mergeValidEvaluated(t,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(t,T.Name)),!0}};Xt.KeywordCxt=Js;function s_(e,t,r,n){let o=new Js(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,ro.funcKeywordCode)(o,r):"macro"in r?(0,ro.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,ro.funcKeywordCode)(o,r)}var Xx=/^\/(?:[^~]|~0|~1)*$/,Qx=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function i_(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,s;if(e==="")return A.default.rootData;if(e[0]==="/"){if(!Xx.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=A.default.rootData}else{let u=Qx.exec(e);if(!u)throw new Error(`Invalid JSON-pointer: ${e}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=t)throw new Error(c("property/index",l));return n[t-l]}if(l>t)throw new Error(c("data",l));if(s=r[t-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,T._)`${s}${(0,T.getProperty)((0,Mt.unescapeJsonPointer)(u))}`,i=(0,T._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${t}`}}Xt.getData=i_});var Xs=w(lu=>{"use strict";Object.defineProperty(lu,"__esModule",{value:!0});var uu=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};lu.default=uu});var oo=w(pu=>{"use strict";Object.defineProperty(pu,"__esModule",{value:!0});var du=eo(),fu=class extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,du.resolveUrl)(t,r,n),this.missingSchema=(0,du.normalizeId)((0,du.getFullPath)(t,this.missingRef))}};pu.default=fu});var ei=w(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.resolveSchema=tt.getCompilingSchema=tt.resolveRef=tt.compileSchema=tt.SchemaEnv=void 0;var dt=M(),eP=Xs(),hr=Ct(),ft=eo(),a_=q(),tP=no(),Gr=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,ft.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};tt.SchemaEnv=Gr;function hu(e){let t=c_.call(this,e);if(t)return t;let r=(0,ft.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new dt.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;e.$async&&(a=i.scopeValue("Error",{ref:eP.default,code:(0,dt._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");e.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:hr.default.data,parentData:hr.default.parentData,parentDataProperty:hr.default.parentDataProperty,dataNames:[hr.default.data],dataPathArr:[dt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,dt.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:dt.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,dt._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(e),(0,tP.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(hr.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,e));let p=new Function(`${hr.default.self}`,`${hr.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:p}),p.errors=null,p.schema=e.schema,p.schemaEnv=e,e.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:m,items:h}=u;p.evaluated={props:m instanceof dt.Name?void 0:m,items:h instanceof dt.Name?void 0:h,dynamicProps:m instanceof dt.Name,dynamicItems:h instanceof dt.Name},p.source&&(p.source.evaluated=(0,dt.stringify)(p.evaluated))}return e.validate=p,e}catch(d){throw delete e.validate,delete e.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(e)}}tt.compileSchema=hu;function rP(e,t,r){var n;r=(0,ft.resolveUrl)(this.opts.uriResolver,t,r);let o=e.refs[r];if(o)return o;let s=sP.call(this,e,r);if(s===void 0){let i=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new Gr({schema:i,schemaId:a,root:e,baseId:t}))}if(s!==void 0)return e.refs[r]=nP.call(this,s)}tt.resolveRef=rP;function nP(e){return(0,ft.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:hu.call(this,e)}function c_(e){for(let t of this._compilations)if(oP(t,e))return t}tt.getCompilingSchema=c_;function oP(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function sP(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Qs.call(this,e,t)}function Qs(e,t){let r=this.opts.uriResolver.parse(t),n=(0,ft._getFullPath)(this.opts.uriResolver,r),o=(0,ft.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return mu.call(this,r,e);let s=(0,ft.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=Qs.call(this,e,i);return typeof a?.schema!="object"?void 0:mu.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||hu.call(this,i),s===(0,ft.normalizeId)(t)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,ft.resolveUrl)(this.opts.uriResolver,o,u)),new Gr({schema:a,schemaId:c,root:e,baseId:o})}return mu.call(this,r,i)}}tt.resolveSchema=Qs;var iP=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function mu(e,{baseId:t,schema:r,root:n}){var o;if(((o=e.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,a_.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!iP.has(a)&&u&&(t=(0,ft.resolveUrl)(this.opts.uriResolver,t,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,a_.schemaHasRulesButRef)(r,this.RULES)){let a=(0,ft.resolveUrl)(this.opts.uriResolver,t,r.$ref);s=Qs.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new Gr({schema:r,schemaId:i,root:n,baseId:t}),s.schema!==s.root.schema)return s}});var u_=w((v1,aP)=>{aP.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 bu=w((w1,g_)=>{"use strict";var cP=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),_u=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),uP=RegExp.prototype.test.bind(/^\d*$/u),gr=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),yu=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),d_=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),Su=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),lP=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),Ue=new Array(256);{let e="0123456789ABCDEF";for(let t=0;t<256;t++)Ue[t]="%"+e[t>>4]+e[t&15]}function ke(e){return e<2048?Ue[192|e>>6]+Ue[128|e&63]:e<65536?Ue[224|e>>12]+Ue[128|e>>6&63]+Ue[128|e&63]:Ue[240|e>>18]+Ue[128|e>>12&63]+Ue[128|e>>6&63]+Ue[128|e&63]}function dP(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}var fP=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),pP=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),mP=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),hP=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function gP(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!mP(e[t])){if(e[t]==="%"&&t+2<e.length&&gr(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}function l_(e){let t=-1,r=0,n=-1,o=0;for(let a=0;a<e.length;a++)e[a]==="0"?(n===-1&&(n=a),o++,o>r&&(r=o,t=n)):(n=-1,o=0);if(r<2)return e.join(":");let s=e.slice(0,t).join(":"),i=e.slice(t+r).join(":");return s+"::"+i}function _P(e){let t=e.indexOf("::");if(t!==-1&&e.indexOf("::",t+1)!==-1)return;let r=t===-1?e.split(":"):e.slice(0,t).split(":"),n=t===-1?[]:e.slice(t+2).split(":");t!==-1&&(r.length===1&&r[0]===""&&(r.length=0),n.length===1&&n[0]===""&&(n.length=0));let o=r.concat(n),s=0;for(let a=0;a<o.length;a++){let c=o[a];if(c==="")return;if(c.indexOf(".")!==-1){if(a!==o.length-1||t!==-1&&n.length===0||!_u(c))return;s+=2;continue}if(!fP(c))return;o[a]=parseInt(c,16).toString(16),s++}if(t===-1)return s!==8?void 0:l_(o);if(s>=8)return;let i=o.slice(0,r.length);for(let a=s;a<8;a++)i.push("0");for(let a=r.length;a<o.length;a++)i.push(o[a]);return l_(i)}function gu(e){let t=e[0]==="["&&e[e.length-1]==="]";if((e[0]==="["||e[e.length-1]==="]")&&!t)return{host:e,isIPV6:!1,error:!0};let n=t?e.slice(1,-1):e;if(t&&pP(n))return n=n.toLowerCase(),{host:`[${n}]`,escapedHost:n,isIPV6:!1,isIPVFuture:!0};if(yP(n,":")<2)return{host:e,isIPV6:!1,error:t};let o="",s=n.indexOf("%");if(s!==-1){let a=n.slice(s,s+3).toLowerCase()==="%25"?3:1;if(o=n.slice(s+a),!gP(o))return{host:e,isIPV6:!1,error:!0};n=n.slice(0,s)}let i=_P(n);return i===void 0?{host:e,isIPV6:!1,error:!0}:{host:i+(o?"%"+o:""),escapedHost:i+(o?"%25"+o:""),isIPV6:!0}}function yP(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function SP(e){let t=e,r=[],n=-1,o=0;for(;o=t.length;){if(o===1){if(t===".")break;if(t==="/"){r.push("/");break}else{r.push(t);break}}else if(o===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(o===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((n=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,n)),t=t.slice(n)}return r.join("")}var EP={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},bP=/[@/?#:]/g,vP=/[@/?#]/g;function f_(e,t){let r=t?vP:bP;return r.lastIndex=0,e.replace(r,n=>EP[n])}function p_(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n<e.length;n++){if(e[n]==="%"&&n+2<e.length){let o=e.slice(n+1,n+3);if(gr(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));t&&yu(i)?r+=i:r+="%"+s,n+=2;continue}}r+=e[n]}return r}function wP(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(gr(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));i!=="."&&yu(i)?t+=i:t+="%"+s,r+=2;continue}}if(d_(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=h_(o)?n:Ue[o];else if(o<55296||o>57343)t+=ke(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=ke(65536+(o-55296<<10)+(s-56320)),r++):t+=ke(65533)}else t+=ke(65533)}}return t}function kP(e,t=!1){let r="",n=t&&e[0]!=="/";for(let o=0;o<e.length;o++){let s=e[o];if(s==="%"&&o+2<e.length){let i=e.slice(o+1,o+3);if(gr(i)){r+="%"+i.toUpperCase(),o+=2;continue}}if(s==="/"&&(n=!1),d_(s)&&(s!==":"||!n))r+=s;else{let i=e.charCodeAt(o);if(i<128)r+=Ue[i];else if(i<55296||i>57343)r+=ke(i);else if(i<=56319&&o+1<e.length){let a=e.charCodeAt(o+1);a>=56320&&a<=57343?(r+=ke(65536+(i-55296<<10)+(a-56320)),o++):r+=ke(65533)}else r+=ke(65533)}}return r}function Eu(e,t){let r="";for(let n=0;n<e.length;n++){let o=e[n];if(o==="%"&&n+2<e.length){let s=e.slice(n+1,n+3);if(gr(s)){r+="%"+s.toUpperCase(),n+=2;continue}}if(t(o))r+=o;else{let s=e.charCodeAt(n);if(s<128)r+=Ue[s];else if(s<55296||s>57343)r+=ke(s);else if(s<=56319&&n+1<e.length){let i=e.charCodeAt(n+1);i>=56320&&i<=57343?(r+=ke(65536+(s-55296<<10)+(i-56320)),n++):r+=ke(65533)}else r+=ke(65533)}}return r}function m_(e){return Eu(e,lP)}function xP(e){return Eu(e,Su)}function PP(e){return Eu(e,Su)}function h_(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===42||e===43||e===45||e===46||e===47||e===64||e===95}function TP(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(gr(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));yu(i)?t+=i:t+="%"+s,r+=2;continue}}if(Su(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=h_(o)?n:Ue[o];else if(o<55296||o>57343)t+=ke(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=ke(65536+(o-55296<<10)+(s-56320)),r++):t+=ke(65533)}else t+=ke(65533)}}return t}function $P(e){let t="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){let n=e.slice(r+1,r+3);if(gr(n)){t+="%"+n.toUpperCase(),r+=2;continue}}t+=escape(e[r])}return t}function RP(e){let t=[];if(e.userinfo!==void 0&&(t.push(m_(e.userinfo)),t.push("@")),e.host!==void 0){let r=e.host;if(!_u(r)){let n=gu(r);n.isIPV6!==!0&&n.isIPVFuture!==!0&&(r=p_(r,!0),n=gu(r)),n.isIPV6===!0||n.isIPVFuture===!0?r=`[${n.escapedHost}]`:r=f_(r,!1)}t.push(r)}if(typeof e.port=="number"||typeof e.port=="string"){let r=String(e.port);if(!uP(r))throw new TypeError("URI port is malformed.");t.push(":"),t.push(r)}return t.length?t.join(""):void 0}g_.exports={nonSimpleDomain:hP,recomposeAuthority:RP,reescapeHostDelimiters:f_,normalizePercentEncoding:p_,normalizePathEncoding:wP,serializePathEncoding:kP,normalizeQueryFragmentEncoding:TP,encodeUserinfo:m_,encodeQuery:xP,encodeFragment:PP,escapePreservingEscapes:$P,removeDotSegments:SP,isIPv4:_u,isUUID:cP,normalizeIPv6:gu,stringArrayToHexStripped:dP}});var b_=w((k1,E_)=>{"use strict";var{isUUID:AP}=bu(),OP=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,IP=["http","https","ws","wss","urn","urn:uuid"];function CP(e){return IP.indexOf(e)!==-1}function vu(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}function __(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function y_(e){let t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function MP(e){return e.secure=vu(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function zP(e){if((e.port===(vu(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let t=e.resourceName.indexOf("?"),r=t===-1?e.resourceName:e.resourceName.slice(0,t);e.path=r&&r!=="/"?r:void 0,e.query=t===-1?void 0:e.resourceName.slice(t+1),e.resourceName=void 0}return e.fragment=void 0,e}function DP(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(OP);if(r&&r[0]===e.path){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let o=`${n}:${t.nid||e.nid}`,s=wu(o);e.path=void 0,s&&(e=s.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function NP(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),o=`${r}:${t.nid||n}`,s=wu(o);s&&(e=s.serialize(e,t));let i=e,a=e.nss;return i.path=`${n||t.nid}:${a}`,t.skipEscape=!0,i}function LP(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!AP(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function jP(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var S_={scheme:"http",domainHost:!0,parse:__,serialize:y_},UP={scheme:"https",domainHost:S_.domainHost,parse:__,serialize:y_},ti={scheme:"ws",domainHost:!0,parse:MP,serialize:zP},FP={scheme:"wss",domainHost:ti.domainHost,parse:ti.parse,serialize:ti.serialize},qP={scheme:"urn",parse:DP,serialize:NP,skipNormalize:!0},ZP={scheme:"urn:uuid",parse:LP,serialize:jP,skipNormalize:!0},ri={http:S_,https:UP,ws:ti,wss:FP,urn:qP,"urn:uuid":ZP};Object.setPrototypeOf(ri,null);function wu(e){return e&&(ri[e]||ri[e.toLowerCase()])||void 0}E_.exports={wsIsSecure:vu,SCHEMES:ri,isValidSchemeName:CP,getSchemeHandler:wu}});var M_=w((x1,si)=>{"use strict";var{normalizeIPv6:P_,removeDotSegments:io,recomposeAuthority:WP,normalizePercentEncoding:ku,normalizePathEncoding:HP,serializePathEncoding:v_,normalizeQueryFragmentEncoding:w_,encodeQuery:BP,encodeFragment:KP,reescapeHostDelimiters:GP,isIPv4:T_,nonSimpleDomain:VP}=bu(),{SCHEMES:$_,getSchemeHandler:xu}=b_(),R_=/^[A-Za-z][A-Za-z0-9+.-]*$/u,A_="URI scheme is malformed.";function k_(e){let t=unescape(String(e));if(!R_.test(t))throw new TypeError(A_);return t}function YP(e,t){return typeof e=="string"?e=oT(e,t):typeof e=="object"&&(e=oi(_r(e,t),t)),e}function JP(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},{parsed:o,malformedAuthorityOrPort:s,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:c,malformedScheme:u}=ni(e,n),{parsed:l,malformedAuthorityOrPort:d,malformedPercentEncoding:f,malformedSchemeSpecific:p,malformedHost:m,malformedScheme:h}=ni(t,n);if(s||d||i||f||a||p||c||m||u||h)throw new Error(o.error||l.error||"URI is malformed.");let g=O_(o,l,n,!0),y=xu(r&&r.scheme||g.scheme),b=g.host,v=b!==void 0&&b!==""&&(T_(b)||P_(b).isIPV6);I_(g,r||{},y,v);let O=b&&b.indexOf("%")!==-1&&!new RegExp("\\P{ASCII}","u").test(b);if(g.error&&!O)throw new Error(g.error);return n.skipEscape=!0,_r(g,n)}function O_(e,t,r,n){let o={};return n||(e=oi(_r(e,r),r),t=oi(_r(t,r),r)),r=r||{},!r.tolerant&&t.scheme?(o.scheme=t.scheme,o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=io(t.path||""),o.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=io(t.path||""),o.query=t.query):(t.path?(t.path[0]==="/"?o.path=io(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?o.path="/"+t.path:e.path?o.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:o.path=t.path,o.path=io(o.path)),o.query=t.query):(o.path=e.path,t.query!==void 0?o.query=t.query:o.query=e.query),o.userinfo=e.userinfo,o.host=e.host,o.port=e.port),o.scheme=e.scheme),o.fragment=t.fragment,o}function XP(e,t,r){let n=x_(e,r),o=x_(t,r);return n!==void 0&&o!==void 0&&n===o}function _r(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},n=Object.assign({},t),o=[];r.scheme&&(r.scheme=k_(r.scheme));let s=xu(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n);let i=r.userinfo!==void 0||r.host!==void 0||r.port!==void 0,a=!n.skipEscape&&r.scheme===void 0&&!i;r.path!==void 0&&(n.skipEscape?r.path=ku(r.path):r.path=v_(r.path,a)),n.reference!=="suffix"&&r.scheme&&(r.scheme=k_(r.scheme),o.push(r.scheme,":"));let c=WP(r);if(c!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(c),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let u=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(u=io(u)),a&&(u=v_(u,!0)),c===void 0&&u[0]==="/"&&u[1]==="/"&&(u="/%2F"+u.slice(2)),o.push(u)}return r.query!==void 0&&o.push("?",BP(r.query)),r.fragment!==void 0&&o.push("#",KP(r.fragment)),o.join("")}var QP=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,eT=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,tT=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function rT(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof e.port=="number"&&(e.port<0||e.port>65535))return"URI port is malformed."}function so(e){if(e===void 0)return!1;let t=e.indexOf("%");for(;t!==-1;){if(t+2>=e.length||!/^[\da-f]{2}$/iu.test(e.slice(t+1,t+3)))return!0;t=e.indexOf("%",t+3)}return!1}function Pu(e){return e[0]==="["&&e[e.length-1]==="]"}function nT(e){let t=e[4];return so(e[3])||t!==void 0&&!Pu(t)&&so(t)||so(e[6])||so(e[7])||so(e[8])}function I_(e,t,r,n){if(!t.unicodeSupport&&(!r||!r.unicodeSupport)&&e.host&&!Pu(e.host)&&(t.domainHost||r&&r.domainHost)&&n===!1&&VP(e.host))try{e.host=new URL("http://"+e.host).hostname}catch(o){return e.error=e.error||"Host's domain name can not be converted to ASCII: "+o,!0}return!1}function ni(e,t){let r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1,s=!1,i=!1,a=!1,c=!1,u=!1,l=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let d=e.match(eT);d!==null&&d[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",o=!0);let f=e.match(tT);if(f!==null){let m=f[1],h=m.replace(/[\t\n\r]/g,"");h.length>=2&&(h.slice(0,2)!=="//"?(n.error=n.error||"URI authority must not contain a literal backslash.",o=!0):m.length!==h.length&&(n.error=n.error||"URI authority introducer must not contain whitespace.",o=!0))}let p=e.match(QP);if(p){if(n.scheme=p[1],n.userinfo=p[3],n.host=p[4],n.port=parseInt(p[5],10),n.path=p[6]||"",n.query=p[7],n.fragment=p[8],n.scheme!==void 0){let g=unescape(n.scheme);R_.test(g)?n.scheme=g.toLowerCase():(n.error=n.error||A_,u=!0)}s=nT(p),s&&(n.error=n.error||"URI contains malformed percent-encoding."),isNaN(n.port)&&(n.port=p[5]);let m=rT(n,p);if(m!==void 0&&(n.error=n.error||m,o=!0),n.host)if(T_(n.host)===!1){let y=Pu(n.host),b=n.host.indexOf("[")!==-1||n.host.indexOf("]")!==-1,v=P_(n.host);l=v.isIPV6||v.isIPVFuture===!0,c=b&&(!y||v.error===!0),n.host=l?v.host:v.host.toLowerCase(),c&&(n.error=n.error||"URI host is malformed.",o=!0)}else l=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let h=xu(r.scheme||n.scheme);if(c||(a=I_(n,r,h,l)),e.indexOf("%")!==-1&&n.host!==void 0&&!c){let g=l?n.host:ku(n.host,!0);l||(g=ku(g.toLowerCase())),n.host=GP(g,l)}(!h||h&&!h.skipNormalize)&&(n.path&&(n.path=HP(n.path)),n.query&&(n.query=w_(n.query)),n.fragment&&(n.fragment=w_(n.fragment))),h&&h.parse&&(h.parse(n,r),h===$_.urn&&n.nid===void 0&&(i=!0))}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:u}}function oi(e,t){return ni(e,t).parsed}function oT(e,t){return C_(e,t).normalized}function C_(e,t){let{parsed:r,malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}=ni(e,t);return{normalized:n||o||s||i||a?e:_r(r,t),malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}}function x_(e,t){if(typeof e!="string"&&typeof e!="object")return;let r;try{r=typeof e=="string"?e:_r(e,t)}catch{return}let{normalized:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:c}=C_(r,t);return o||s||i||a||c?void 0:n}var Tu={SCHEMES:$_,normalize:YP,resolve:JP,resolveComponent:O_,equal:XP,serialize:_r,parse:oi};si.exports=Tu;si.exports.default=Tu;si.exports.fastUri=Tu});var D_=w($u=>{"use strict";Object.defineProperty($u,"__esModule",{value:!0});var z_=M_();z_.code='require("ajv/dist/runtime/uri").default';$u.default=z_});var W_=w(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});ye.CodeGen=ye.Name=ye.nil=ye.stringify=ye.str=ye._=ye.KeywordCxt=void 0;var sT=no();Object.defineProperty(ye,"KeywordCxt",{enumerable:!0,get:function(){return sT.KeywordCxt}});var Vr=M();Object.defineProperty(ye,"_",{enumerable:!0,get:function(){return Vr._}});Object.defineProperty(ye,"str",{enumerable:!0,get:function(){return Vr.str}});Object.defineProperty(ye,"stringify",{enumerable:!0,get:function(){return Vr.stringify}});Object.defineProperty(ye,"nil",{enumerable:!0,get:function(){return Vr.nil}});Object.defineProperty(ye,"Name",{enumerable:!0,get:function(){return Vr.Name}});Object.defineProperty(ye,"CodeGen",{enumerable:!0,get:function(){return Vr.CodeGen}});var iT=Xs(),F_=oo(),aT=Yc(),ao=ei(),cT=M(),co=eo(),ii=Qn(),Au=q(),N_=u_(),uT=D_(),q_=(e,t)=>new RegExp(e,t);q_.code="new RegExp";var lT=["removeAdditional","useDefaults","coerceTypes"],dT=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),fT={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."},pT={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},L_=200;function mT(e){var t,r,n,o,s,i,a,c,u,l,d,f,p,m,h,g,y,b,v,O,x,z,j,Ge,xe;let Ve=e.strict,xr=(t=e.code)===null||t===void 0?void 0:t.optimize,Oo=xr===!0||xr===void 0?1:xr||0,Io=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:q_,$E=(o=e.uriResolver)!==null&&o!==void 0?o:uT.default;return{strictSchema:(i=(s=e.strictSchema)!==null&&s!==void 0?s:Ve)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=e.strictNumbers)!==null&&a!==void 0?a:Ve)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=e.strictTypes)!==null&&u!==void 0?u:Ve)!==null&&l!==void 0?l:"log",strictTuples:(f=(d=e.strictTuples)!==null&&d!==void 0?d:Ve)!==null&&f!==void 0?f:"log",strictRequired:(m=(p=e.strictRequired)!==null&&p!==void 0?p:Ve)!==null&&m!==void 0?m:!1,code:e.code?{...e.code,optimize:Oo,regExp:Io}:{optimize:Oo,regExp:Io},loopRequired:(h=e.loopRequired)!==null&&h!==void 0?h:L_,loopEnum:(g=e.loopEnum)!==null&&g!==void 0?g:L_,meta:(y=e.meta)!==null&&y!==void 0?y:!0,messages:(b=e.messages)!==null&&b!==void 0?b:!0,inlineRefs:(v=e.inlineRefs)!==null&&v!==void 0?v:!0,schemaId:(O=e.schemaId)!==null&&O!==void 0?O:"$id",addUsedSchema:(x=e.addUsedSchema)!==null&&x!==void 0?x:!0,validateSchema:(z=e.validateSchema)!==null&&z!==void 0?z:!0,validateFormats:(j=e.validateFormats)!==null&&j!==void 0?j:!0,unicodeRegExp:(Ge=e.unicodeRegExp)!==null&&Ge!==void 0?Ge:!0,int32range:(xe=e.int32range)!==null&&xe!==void 0?xe:!0,uriResolver:$E}}var uo=class{constructor(t={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...mT(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new cT.ValueScope({scope:{},prefixes:dT,es5:r,lines:n}),this.logger=ET(t.logger);let o=t.validateFormats;t.validateFormats=!1,this.RULES=(0,aT.getRules)(),j_.call(this,fT,t,"NOT SUPPORTED"),j_.call(this,pT,t,"DEPRECATED","warn"),this._metaOpts=yT.call(this),t.formats&&gT.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&_T.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),hT.call(this),t.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,o=N_;n==="id"&&(o={...N_},o.id=o.$id,delete o.$id),r&&t&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let n;if(typeof t=="string"){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(t,r){let n=this._addSchema(t,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return o.call(this,t,r);async function o(l,d){await s.call(this,l.$schema);let f=this._addSchema(l,d);return f.validate||i.call(this,f)}async function s(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof F_.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await s.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(t,r,n,o=this.opts.validateSchema){if(Array.isArray(t)){for(let i of t)this.addSchema(i,void 0,n,o);return this}let s;if(typeof t=="object"){let{schemaId:i}=this.opts;if(s=t[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,co.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(t,n,r,o,!0),this}addMetaSchema(t,r,n=this.opts.validateSchema){return this.addSchema(t,r,!0,n),this}validateSchema(t,r){if(typeof t=="boolean")return!0;let n;if(n=t.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(n,t);if(!o&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return o}getSchema(t){let r;for(;typeof(r=U_.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,o=new ao.SchemaEnv({schema:{},schemaId:n});if(r=ao.resolveSchema.call(this,o,t),!r)return;this.refs[t]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=U_.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{let r=t;this._cache.delete(r);let n=t[this.opts.schemaId];return n&&(n=(0,co.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let n;if(typeof t=="string")n=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof t=="object"&&r===void 0){if(r=t,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(vT.call(this,n,r),!r)return(0,Au.eachItem)(n,s=>Ru.call(this,s)),this;kT.call(this,r);let o={...r,type:(0,ii.getJSONTypes)(r.type),schemaType:(0,ii.getJSONTypes)(r.schemaType)};return(0,Au.eachItem)(n,o.type.length===0?s=>Ru.call(this,s,o):s=>o.type.forEach(i=>Ru.call(this,s,o,i))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===t);o>=0&&n.rules.splice(o,1)}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!t||t.length===0?"No errors":t.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let o of r){let s=o.split("/").slice(1),i=t;for(let a of s)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=Z_(l))}}return t}_removeAllSchemas(t,r){for(let n in t){let o=t[n];(!r||r.test(n))&&(typeof o=="string"?delete t[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete t[n]))}}_addSchema(t,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof t=="object")i=t[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(t);if(c!==void 0)return c;n=(0,co.normalizeId)(i||n);let u=co.getSchemaRefs.call(this,t,n);return c=new ao.SchemaEnv({schema:t,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),o&&this.validateSchema(t,!0),c}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):ao.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{ao.compileSchema.call(this,t)}finally{this.opts=r}}};uo.ValidationError=iT.default;uo.MissingRefError=F_.default;ye.default=uo;function j_(e,t,r,n="error"){for(let o in e){let s=o;s in t&&this.logger[n](`${r}: option ${o}. ${e[s]}`)}}function U_(e){return e=(0,co.normalizeId)(e),this.schemas[e]||this.refs[e]}function hT(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function gT(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function _T(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}function yT(){let e={...this.opts};for(let t of lT)delete e[t];return e}var ST={log(){},warn(){},error(){}};function ET(e){if(e===!1)return ST;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var bT=/^[a-z_$][a-z0-9_$:-]*$/i;function vT(e,t){let{RULES:r}=this;if((0,Au.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!bT.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function Ru(e,t,r){var n;let o=t?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,i=o?s.post:s.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},s.rules.push(i)),s.keywords[e]=!0,!t)return;let a={keyword:e,definition:{...t,type:(0,ii.getJSONTypes)(t.type),schemaType:(0,ii.getJSONTypes)(t.schemaType)}};t.before?wT.call(this,i,a,t.before):i.rules.push(a),s.all[e]=a,(n=t.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function wT(e,t,r){let n=e.rules.findIndex(o=>o.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function kT(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=Z_(t)),e.validateSchema=this.compile(t,!0))}var xT={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Z_(e){return{anyOf:[e,xT]}}});var H_=w(Ou=>{"use strict";Object.defineProperty(Ou,"__esModule",{value:!0});var PT={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Ou.default=PT});var V_=w(yr=>{"use strict";Object.defineProperty(yr,"__esModule",{value:!0});yr.callRef=yr.getValidate=void 0;var TT=oo(),B_=et(),Fe=M(),Yr=Ct(),K_=ei(),ai=q(),$T={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=K_.resolveRef.call(c,u,o,r);if(l===void 0)throw new TT.default(n.opts.uriResolver,o,r);if(l instanceof K_.SchemaEnv)return f(l);return p(l);function d(){if(s===u)return ci(e,i,s,s.$async);let m=t.scopeValue("root",{ref:u});return ci(e,(0,Fe._)`${m}.validate`,u,u.$async)}function f(m){let h=G_(e,m);ci(e,h,m,m.$async)}function p(m){let h=t.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Fe.stringify)(m)}:{ref:m}),g=t.name("valid"),y=e.subschema({schema:m,dataTypes:[],schemaPath:Fe.nil,topSchemaRef:h,errSchemaPath:r},g);e.mergeEvaluated(y),e.ok(g)}}};function G_(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Fe._)`${r.scopeValue("wrapper",{ref:t})}.validate`}yr.getValidate=G_;function ci(e,t,r,n){let{gen:o,it:s}=e,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?Yr.default.this:Fe.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let m=o.let("valid");o.try(()=>{o.code((0,Fe._)`await ${(0,B_.callValidateCode)(e,t,u)}`),p(t),i||o.assign(m,!0)},h=>{o.if((0,Fe._)`!(${h} instanceof ${s.ValidationError})`,()=>o.throw(h)),f(h),i||o.assign(m,!1)}),e.ok(m)}function d(){e.result((0,B_.callValidateCode)(e,t,u),()=>p(t),()=>f(t))}function f(m){let h=(0,Fe._)`${m}.errors`;o.assign(Yr.default.vErrors,(0,Fe._)`${Yr.default.vErrors} === null ? ${h} : ${Yr.default.vErrors}.concat(${h})`),o.assign(Yr.default.errors,(0,Fe._)`${Yr.default.vErrors}.length`)}function p(m){var h;if(!s.opts.unevaluated)return;let g=(h=r?.validate)===null||h===void 0?void 0:h.evaluated;if(s.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(s.props=ai.mergeEvaluated.props(o,g.props,s.props));else{let y=o.var("props",(0,Fe._)`${m}.evaluated.props`);s.props=ai.mergeEvaluated.props(o,y,s.props,Fe.Name)}if(s.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(s.items=ai.mergeEvaluated.items(o,g.items,s.items));else{let y=o.var("items",(0,Fe._)`${m}.evaluated.items`);s.items=ai.mergeEvaluated.items(o,y,s.items,Fe.Name)}}}yr.callRef=ci;yr.default=$T});var Y_=w(Iu=>{"use strict";Object.defineProperty(Iu,"__esModule",{value:!0});var RT=H_(),AT=V_(),OT=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",RT.default,AT.default];Iu.default=OT});var J_=w(Cu=>{"use strict";Object.defineProperty(Cu,"__esModule",{value:!0});var ui=M(),Qt=ui.operators,li={maximum:{okStr:"<=",ok:Qt.LTE,fail:Qt.GT},minimum:{okStr:">=",ok:Qt.GTE,fail:Qt.LT},exclusiveMaximum:{okStr:"<",ok:Qt.LT,fail:Qt.GTE},exclusiveMinimum:{okStr:">",ok:Qt.GT,fail:Qt.LTE}},IT={message:({keyword:e,schemaCode:t})=>(0,ui.str)`must be ${li[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,ui._)`{comparison: ${li[e].okStr}, limit: ${t}}`},CT={keyword:Object.keys(li),type:"number",schemaType:"number",$data:!0,error:IT,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,ui._)`${r} ${li[t].fail} ${n} || isNaN(${r})`)}};Cu.default=CT});var X_=w(Mu=>{"use strict";Object.defineProperty(Mu,"__esModule",{value:!0});var lo=M(),MT={message:({schemaCode:e})=>(0,lo.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,lo._)`{multipleOf: ${e}}`},zT={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:MT,code(e){let{gen:t,data:r,schemaCode:n,it:o}=e,s=o.opts.multipleOfPrecision,i=t.let("res"),a=s?(0,lo._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,lo._)`${i} !== parseInt(${i})`;e.fail$data((0,lo._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};Mu.default=zT});var ey=w(zu=>{"use strict";Object.defineProperty(zu,"__esModule",{value:!0});function Q_(e){let t=e.length,r=0,n=0,o;for(;n<t;)r++,o=e.charCodeAt(n++),o>=55296&&o<=56319&&n<t&&(o=e.charCodeAt(n),(o&64512)===56320&&n++);return r}zu.default=Q_;Q_.code='require("ajv/dist/runtime/ucs2length").default'});var ty=w(Du=>{"use strict";Object.defineProperty(Du,"__esModule",{value:!0});var Sr=M(),DT=q(),NT=ey(),LT={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,Sr.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,Sr._)`{limit: ${e}}`},jT={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:LT,code(e){let{keyword:t,data:r,schemaCode:n,it:o}=e,s=t==="maxLength"?Sr.operators.GT:Sr.operators.LT,i=o.opts.unicode===!1?(0,Sr._)`${r}.length`:(0,Sr._)`${(0,DT.useFunc)(e.gen,NT.default)}(${r})`;e.fail$data((0,Sr._)`${i} ${s} ${n}`)}};Du.default=jT});var ry=w(Nu=>{"use strict";Object.defineProperty(Nu,"__esModule",{value:!0});var UT=et(),FT=q(),Jr=M(),qT={message:({schemaCode:e})=>(0,Jr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Jr._)`{pattern: ${e}}`},ZT={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:qT,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,Jr._)`new RegExp`:(0,FT.useFunc)(t,c),l=t.let("valid");t.try(()=>t.assign(l,(0,Jr._)`${u}(${s}, ${a}).test(${r})`),()=>t.assign(l,!1)),e.fail$data((0,Jr._)`!${l}`)}else{let c=(0,UT.usePattern)(e,o);e.fail$data((0,Jr._)`!${c}.test(${r})`)}}};Nu.default=ZT});var ny=w(Lu=>{"use strict";Object.defineProperty(Lu,"__esModule",{value:!0});var fo=M(),WT={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,fo.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,fo._)`{limit: ${e}}`},HT={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:WT,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxProperties"?fo.operators.GT:fo.operators.LT;e.fail$data((0,fo._)`Object.keys(${r}).length ${o} ${n}`)}};Lu.default=HT});var oy=w(ju=>{"use strict";Object.defineProperty(ju,"__esModule",{value:!0});var po=et(),mo=M(),BT=q(),KT={message:({params:{missingProperty:e}})=>(0,mo.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,mo._)`{missingProperty: ${e}}`},GT={keyword:"required",type:"object",schemaType:"array",$data:!0,error:KT,code(e){let{gen:t,schema:r,schemaCode:n,data:o,$data:s,it:i}=e,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let p=e.parentSchema.properties,{definedProperties:m}=e.it;for(let h of r)if(p?.[h]===void 0&&!m.has(h)){let g=i.schemaEnv.baseId+i.errSchemaPath,y=`required property "${h}" is not defined at "${g}" (strictRequired)`;(0,BT.checkStrictMode)(i,y,i.opts.strictRequired)}}function u(){if(c||s)e.block$data(mo.nil,d);else for(let p of r)(0,po.checkReportMissingProp)(e,p)}function l(){let p=t.let("missing");if(c||s){let m=t.let("valid",!0);e.block$data(m,()=>f(p,m)),e.ok(m)}else t.if((0,po.checkMissingProp)(e,r,p)),(0,po.reportMissingProp)(e,p),t.else()}function d(){t.forOf("prop",n,p=>{e.setParams({missingProperty:p}),t.if((0,po.noPropertyInData)(t,o,p,a.ownProperties),()=>e.error())})}function f(p,m){e.setParams({missingProperty:p}),t.forOf(p,n,()=>{t.assign(m,(0,po.propertyInData)(t,o,p,a.ownProperties)),t.if((0,mo.not)(m),()=>{e.error(),t.break()})},mo.nil)}}};ju.default=GT});var sy=w(Uu=>{"use strict";Object.defineProperty(Uu,"__esModule",{value:!0});var ho=M(),VT={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,ho.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,ho._)`{limit: ${e}}`},YT={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:VT,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxItems"?ho.operators.GT:ho.operators.LT;e.fail$data((0,ho._)`${r}.length ${o} ${n}`)}};Uu.default=YT});var di=w(Fu=>{"use strict";Object.defineProperty(Fu,"__esModule",{value:!0});var iy=ou();iy.code='require("ajv/dist/runtime/equal").default';Fu.default=iy});var ay=w(Zu=>{"use strict";Object.defineProperty(Zu,"__esModule",{value:!0});var qu=Qn(),Se=M(),JT=q(),XT=di(),QT={message:({params:{i:e,j:t}})=>(0,Se.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,Se._)`{i: ${e}, j: ${t}}`},e$={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:QT,code(e){let{gen:t,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=e;if(!n&&!o)return;let c=t.let("valid"),u=s.items?(0,qu.getSchemaTypes)(s.items):[];e.block$data(c,l,(0,Se._)`${i} === false`),e.ok(c);function l(){let m=t.let("i",(0,Se._)`${r}.length`),h=t.let("j");e.setParams({i:m,j:h}),t.assign(c,!0),t.if((0,Se._)`${m} > 1`,()=>(d()?f:p)(m,h))}function d(){return u.length>0&&!u.some(m=>m==="object"||m==="array")}function f(m,h){let g=t.name("item"),y=(0,qu.checkDataTypes)(u,g,a.opts.strictNumbers,qu.DataType.Wrong),b=t.const("indices",(0,Se._)`{}`);t.for((0,Se._)`;${m}--;`,()=>{t.let(g,(0,Se._)`${r}[${m}]`),t.if(y,(0,Se._)`continue`),u.length>1&&t.if((0,Se._)`typeof ${g} == "string"`,(0,Se._)`${g} += "_"`),t.if((0,Se._)`typeof ${b}[${g}] == "number"`,()=>{t.assign(h,(0,Se._)`${b}[${g}]`),e.error(),t.assign(c,!1).break()}).code((0,Se._)`${b}[${g}] = ${m}`)})}function p(m,h){let g=(0,JT.useFunc)(t,XT.default),y=t.name("outer");t.label(y).for((0,Se._)`;${m}--;`,()=>t.for((0,Se._)`${h} = ${m}; ${h}--;`,()=>t.if((0,Se._)`${g}(${r}[${m}], ${r}[${h}])`,()=>{e.error(),t.assign(c,!1).break(y)})))}}};Zu.default=e$});var cy=w(Hu=>{"use strict";Object.defineProperty(Hu,"__esModule",{value:!0});var Wu=M(),t$=q(),r$=di(),n$={message:"must be equal to constant",params:({schemaCode:e})=>(0,Wu._)`{allowedValue: ${e}}`},o$={keyword:"const",$data:!0,error:n$,code(e){let{gen:t,data:r,$data:n,schemaCode:o,schema:s}=e;n||s&&typeof s=="object"?e.fail$data((0,Wu._)`!${(0,t$.useFunc)(t,r$.default)}(${r}, ${o})`):e.fail((0,Wu._)`${s} !== ${r}`)}};Hu.default=o$});var uy=w(Bu=>{"use strict";Object.defineProperty(Bu,"__esModule",{value:!0});var go=M(),s$=q(),i$=di(),a$={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,go._)`{allowedValues: ${e}}`},c$={keyword:"enum",schemaType:"array",$data:!0,error:a$,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let a=o.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,s$.useFunc)(t,i$.default)),l;if(a||n)l=t.let("valid"),e.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let p=t.const("vSchema",s);l=(0,go.or)(...o.map((m,h)=>f(p,h)))}e.pass(l);function d(){t.assign(l,!1),t.forOf("v",s,p=>t.if((0,go._)`${u()}(${r}, ${p})`,()=>t.assign(l,!0).break()))}function f(p,m){let h=o[m];return typeof h=="object"&&h!==null?(0,go._)`${u()}(${r}, ${p}[${m}])`:(0,go._)`${r} === ${h}`}}};Bu.default=c$});var ly=w(Ku=>{"use strict";Object.defineProperty(Ku,"__esModule",{value:!0});var u$=J_(),l$=X_(),d$=ty(),f$=ry(),p$=ny(),m$=oy(),h$=sy(),g$=ay(),_$=cy(),y$=uy(),S$=[u$.default,l$.default,d$.default,f$.default,p$.default,m$.default,h$.default,g$.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},_$.default,y$.default];Ku.default=S$});var Vu=w(_o=>{"use strict";Object.defineProperty(_o,"__esModule",{value:!0});_o.validateAdditionalItems=void 0;var Er=M(),Gu=q(),E$={message:({params:{len:e}})=>(0,Er.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Er._)`{limit: ${e}}`},b$={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:E$,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Gu.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}dy(e,n)}};function dy(e,t){let{gen:r,schema:n,data:o,keyword:s,it:i}=e;i.items=!0;let a=r.const("len",(0,Er._)`${o}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,Er._)`${a} <= ${t.length}`);else if(typeof n=="object"&&!(0,Gu.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,Er._)`${a} <= ${t.length}`);r.if((0,Er.not)(u),()=>c(u)),e.ok(u)}function c(u){r.forRange("i",t.length,a,l=>{e.subschema({keyword:s,dataProp:l,dataPropType:Gu.Type.Num},u),i.allErrors||r.if((0,Er.not)(u),()=>r.break())})}}_o.validateAdditionalItems=dy;_o.default=b$});var Yu=w(yo=>{"use strict";Object.defineProperty(yo,"__esModule",{value:!0});yo.validateTuple=void 0;var fy=M(),fi=q(),v$=et(),w$={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return py(e,"additionalItems",t);r.items=!0,!(0,fi.alwaysValidSchema)(r,t)&&e.ok((0,v$.validateArray)(e))}};function py(e,t,r=e.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=e;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=fi.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,fy._)`${s}.length`);r.forEach((d,f)=>{(0,fi.alwaysValidSchema)(a,d)||(n.if((0,fy._)`${u} > ${f}`,()=>e.subschema({keyword:i,schemaProp:f,dataProp:f},c)),e.ok(c))});function l(d){let{opts:f,errSchemaPath:p}=a,m=r.length,h=m===d.minItems&&(m===d.maxItems||d[t]===!1);if(f.strictTuples&&!h){let g=`"${i}" is ${m}-tuple, but minItems or maxItems/${t} are not specified or different at path "${p}"`;(0,fi.checkStrictMode)(a,g,f.strictTuples)}}}yo.validateTuple=py;yo.default=w$});var my=w(Ju=>{"use strict";Object.defineProperty(Ju,"__esModule",{value:!0});var k$=Yu(),x$={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,k$.validateTuple)(e,"items")};Ju.default=x$});var gy=w(Xu=>{"use strict";Object.defineProperty(Xu,"__esModule",{value:!0});var hy=M(),P$=q(),T$=et(),$$=Vu(),R$={message:({params:{len:e}})=>(0,hy.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,hy._)`{limit: ${e}}`},A$={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:R$,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,!(0,P$.alwaysValidSchema)(n,t)&&(o?(0,$$.validateAdditionalItems)(e,o):e.ok((0,T$.validateArray)(e)))}};Xu.default=A$});var _y=w(Qu=>{"use strict";Object.defineProperty(Qu,"__esModule",{value:!0});var rt=M(),pi=q(),O$={message:({params:{min:e,max:t}})=>t===void 0?(0,rt.str)`must contain at least ${e} valid item(s)`:(0,rt.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,rt._)`{minContains: ${e}}`:(0,rt._)`{minContains: ${e}, maxContains: ${t}}`},I$={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:O$,code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e,i,a,{minContains:c,maxContains:u}=n;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=t.const("len",(0,rt._)`${o}.length`);if(e.setParams({min:i,max:a}),a===void 0&&i===0){(0,pi.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,pi.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,pi.alwaysValidSchema)(s,r)){let h=(0,rt._)`${l} >= ${i}`;a!==void 0&&(h=(0,rt._)`${h} && ${l} <= ${a}`),e.pass(h);return}s.items=!0;let d=t.name("valid");a===void 0&&i===1?p(d,()=>t.if(d,()=>t.break())):i===0?(t.let(d,!0),a!==void 0&&t.if((0,rt._)`${o}.length > 0`,f)):(t.let(d,!1),f()),e.result(d,()=>e.reset());function f(){let h=t.name("_valid"),g=t.let("count",0);p(h,()=>t.if(h,()=>m(g)))}function p(h,g){t.forRange("i",0,l,y=>{e.subschema({keyword:"contains",dataProp:y,dataPropType:pi.Type.Num,compositeRule:!0},h),g()})}function m(h){t.code((0,rt._)`${h}++`),a===void 0?t.if((0,rt._)`${h} >= ${i}`,()=>t.assign(d,!0).break()):(t.if((0,rt._)`${h} > ${a}`,()=>t.assign(d,!1).break()),i===1?t.assign(d,!0):t.if((0,rt._)`${h} >= ${i}`,()=>t.assign(d,!0)))}}};Qu.default=I$});var Ey=w(bt=>{"use strict";Object.defineProperty(bt,"__esModule",{value:!0});bt.validateSchemaDeps=bt.validatePropertyDeps=bt.error=void 0;var el=M(),C$=q(),So=et();bt.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,el.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,el._)`{property: ${e},
|
|
19
|
+
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,C._)`[${o}]`)}}}function Kk({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,C._)`${t} !== undefined`,()=>e.assign((0,C._)`${t}[${r}]`,n))}function Xc(e,t,r,n=Br.Correct){let o=n===Br.Correct?C.operators.EQ:C.operators.NEQ,s;switch(e){case"null":return(0,C._)`${t} ${o} null`;case"array":s=(0,C._)`Array.isArray(${t})`;break;case"object":s=(0,C._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=i((0,C._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=i();break;default:return(0,C._)`typeof ${t} ${o} ${e}`}return n===Br.Correct?s:(0,C.not)(s);function i(a=C.nil){return(0,C.and)((0,C._)`typeof ${t} == "number"`,a,r?(0,C._)`isFinite(${t})`:C.nil)}}ve.checkDataType=Xc;function Qc(e,t,r,n){if(e.length===1)return Xc(e[0],t,r,n);let o,s=(0,Rg.toHash)(e);if(s.array&&s.object){let i=(0,C._)`typeof ${t} != "object"`;o=s.null?i:(0,C._)`!${t} || ${i}`,delete s.null,delete s.array,delete s.object}else o=C.nil;s.number&&delete s.integer;for(let i in s)o=(0,C.and)(o,Xc(i,t,r,n));return o}ve.checkDataTypes=Qc;var Gk={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,C._)`{type: ${e}}`:(0,C._)`{type: ${t}}`};function eu(e){let t=Vk(e);(0,qk.reportError)(t,Gk)}ve.reportTypeError=eu;function Vk(e){let{gen:t,data:r,schema:n}=e,o=(0,Rg.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}});var Cg=v(Gs=>{"use strict";Object.defineProperty(Gs,"__esModule",{value:!0});Gs.assignDefaults=void 0;var Kr=M(),Yk=q();function Jk(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let o in r)Ig(e,o,r[o].default);else t==="array"&&Array.isArray(n)&&n.forEach((o,s)=>Ig(e,s,o.default))}Gs.assignDefaults=Jk;function Ig(e,t,r){let{gen:n,compositeRule:o,data:s,opts:i}=e;if(r===void 0)return;let a=(0,Kr._)`${s}${(0,Kr.getProperty)(t)}`;if(o){(0,Yk.checkStrictMode)(e,`default is ignored for: ${a}`);return}let c=(0,Kr._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,Kr._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Kr._)`${a} = ${(0,Kr.stringify)(r)}`)}});var et=v(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.validateUnion=G.validateArray=G.usePattern=G.callValidateCode=G.schemaProperties=G.allSchemaProperties=G.noPropertyInData=G.propertyInData=G.isOwnProperty=G.hasPropFunc=G.reportMissingProp=G.checkMissingProp=G.checkReportMissingProp=void 0;var re=M(),tu=q(),Vt=Ct(),Xk=q();function Qk(e,t){let{gen:r,data:n,it:o}=e;r.if(nu(r,n,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:(0,re._)`${t}`},!0),e.error()})}G.checkReportMissingProp=Qk;function ex({gen:e,data:t,it:{opts:r}},n,o){return(0,re.or)(...n.map(s=>(0,re.and)(nu(e,t,s,r.ownProperties),(0,re._)`${o} = ${s}`)))}G.checkMissingProp=ex;function tx(e,t){e.setParams({missingProperty:t},!0),e.error()}G.reportMissingProp=tx;function Mg(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,re._)`Object.prototype.hasOwnProperty`})}G.hasPropFunc=Mg;function ru(e,t,r){return(0,re._)`${Mg(e)}.call(${t}, ${r})`}G.isOwnProperty=ru;function rx(e,t,r,n){let o=(0,re._)`${t}${(0,re.getProperty)(r)} !== undefined`;return n?(0,re._)`${o} && ${ru(e,t,r)}`:o}G.propertyInData=rx;function nu(e,t,r,n){let o=(0,re._)`${t}${(0,re.getProperty)(r)} === undefined`;return n?(0,re.or)(o,(0,re.not)(ru(e,t,r))):o}G.noPropertyInData=nu;function zg(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}G.allSchemaProperties=zg;function nx(e,t){return zg(t).filter(r=>!(0,tu.alwaysValidSchema)(e,t[r]))}G.schemaProperties=nx;function ox({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,re._)`${e}, ${t}, ${n}${o}`:t,d=[[Vt.default.instancePath,(0,re.strConcat)(Vt.default.instancePath,s)],[Vt.default.parentData,i.parentData],[Vt.default.parentDataProperty,i.parentDataProperty],[Vt.default.rootData,Vt.default.rootData]];i.opts.dynamicRef&&d.push([Vt.default.dynamicAnchors,Vt.default.dynamicAnchors]);let f=(0,re._)`${l}, ${r.object(...d)}`;return c!==re.nil?(0,re._)`${a}.call(${c}, ${f})`:(0,re._)`${a}(${f})`}G.callValidateCode=ox;var sx=(0,re._)`new RegExp`;function ix({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:o}=t.code,s=o(r,n);return e.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,re._)`${o.code==="new RegExp"?sx:(0,Xk.useFunc)(e,o)}(${r}, ${n})`})}G.usePattern=ix;function ax(e){let{gen:t,data:r,keyword:n,it:o}=e,s=t.name("valid");if(o.allErrors){let a=t.let("valid",!0);return i(()=>t.assign(a,!1)),a}return t.var(s,!0),i(()=>t.break()),s;function i(a){let c=t.const("len",(0,re._)`${r}.length`);t.forRange("i",0,c,u=>{e.subschema({keyword:n,dataProp:u,dataPropType:tu.Type.Num},s),t.if((0,re.not)(s),a)})}}G.validateArray=ax;function cx(e){let{gen:t,schema:r,keyword:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,tu.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=t.let("valid",!1),a=t.name("_valid");t.block(()=>r.forEach((c,u)=>{let l=e.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);t.assign(i,(0,re._)`${i} || ${a}`),e.mergeValidEvaluated(l,a)||t.if((0,re.not)(i))})),e.result(i,()=>e.reset(),()=>e.error(!0))}G.validateUnion=cx});var Lg=v(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.validateKeywordUsage=St.validSchemaType=St.funcKeywordCode=St.macroKeywordCode=void 0;var Re=M(),mr=Ct(),ux=et(),lx=Xn();function dx(e,t){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=e,a=t.macro.call(i.self,o,s,i),c=Ng(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");e.subschema({schema:a,schemaPath:Re.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),e.pass(u,()=>e.error(!0))}St.macroKeywordCode=dx;function fx(e,t){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=e;mx(c,t);let u=!a&&t.compile?t.compile.call(c.self,s,i,c):t.validate,l=Ng(n,o,u),d=n.let("valid");e.block$data(d,f),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function f(){if(t.errors===!1)h(),t.modifying&&Dg(e),g(()=>e.error());else{let y=t.async?p():m();t.modifying&&Dg(e),g(()=>px(e,y))}}function p(){let y=n.let("ruleErrs",null);return n.try(()=>h((0,Re._)`await `),b=>n.assign(d,!1).if((0,Re._)`${b} instanceof ${c.ValidationError}`,()=>n.assign(y,(0,Re._)`${b}.errors`),()=>n.throw(b))),y}function m(){let y=(0,Re._)`${l}.errors`;return n.assign(y,null),h(Re.nil),y}function h(y=t.async?(0,Re._)`await `:Re.nil){let b=c.opts.passContext?mr.default.this:mr.default.self,w=!("compile"in t&&!a||t.schema===!1);n.assign(d,(0,Re._)`${y}${(0,ux.callValidateCode)(e,l,b,w)}`,t.modifying)}function g(y){var b;n.if((0,Re.not)((b=t.valid)!==null&&b!==void 0?b:d),y)}}St.funcKeywordCode=fx;function Dg(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Re._)`${n.parentData}[${n.parentDataProperty}]`))}function px(e,t){let{gen:r}=e;r.if((0,Re._)`Array.isArray(${t})`,()=>{r.assign(mr.default.vErrors,(0,Re._)`${mr.default.vErrors} === null ? ${t} : ${mr.default.vErrors}.concat(${t})`).assign(mr.default.errors,(0,Re._)`${mr.default.vErrors}.length`),(0,lx.extendErrors)(e)},()=>e.error())}function mx({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function Ng(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Re.stringify)(r)})}function hx(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}St.validSchemaType=hx;function gx({schema:e,opts:t,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");let i=o.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(e,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(e[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}St.validateKeywordUsage=gx});var Ug=v(Yt=>{"use strict";Object.defineProperty(Yt,"__esModule",{value:!0});Yt.extendSubschemaMode=Yt.extendSubschemaData=Yt.getSubschema=void 0;var Et=M(),jg=q();function _x(e,{keyword:t,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let a=e.schema[t];return r===void 0?{schema:a,schemaPath:(0,Et._)`${e.schemaPath}${(0,Et.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[r],schemaPath:(0,Et._)`${e.schemaPath}${(0,Et.getProperty)(t)}${(0,Et.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,jg.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')}Yt.getSubschema=_x;function yx(e,t,{dataProp:r,dataPropType:n,data:o,dataTypes:s,propertyName:i}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=t;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=t,f=a.let("data",(0,Et._)`${t.data}${(0,Et.getProperty)(r)}`,!0);c(f),e.errorPath=(0,Et.str)`${u}${(0,jg.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0,Et._)`${r}`,e.dataPathArr=[...l,e.parentDataProperty]}if(o!==void 0){let u=o instanceof Et.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(e.propertyName=i)}s&&(e.dataTypes=s);function c(u){e.data=u,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,u]}}Yt.extendSubschemaData=yx;function Sx(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(e.compositeRule=n),o!==void 0&&(e.createErrors=o),s!==void 0&&(e.allErrors=s),e.jtdDiscriminator=t,e.jtdMetadata=r}Yt.extendSubschemaMode=Sx});var ou=v((y1,Fg)=>{"use strict";Fg.exports=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!e(t[o],r[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(s=Object.keys(t),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var i=s[o];if(!e(t[i],r[i]))return!1}return!0}return t!==t&&r!==r}});var Zg=v((S1,qg)=>{"use strict";var Jt=qg.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};Vs(t,n,o,e,"",e)};Jt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Jt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Jt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Jt.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 Vs(e,t,r,n,o,s,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,o,s,i,a,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in Jt.arrayKeywords)for(var f=0;f<d.length;f++)Vs(e,t,r,d[f],o+"/"+l+"/"+f,s,o,l,n,f)}else if(l in Jt.propsKeywords){if(d&&typeof d=="object")for(var p in d)Vs(e,t,r,d[p],o+"/"+l+"/"+Ex(p),s,o,l,n,p)}else(l in Jt.keywords||e.allKeys&&!(l in Jt.skipKeywords))&&Vs(e,t,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function Ex(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var eo=v(je=>{"use strict";Object.defineProperty(je,"__esModule",{value:!0});je.getSchemaRefs=je.resolveUrl=je.normalizeId=je._getFullPath=je.getFullPath=je.inlineRef=void 0;var bx=q(),wx=ou(),vx=Zg(),kx=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function xx(e,t=!0){return typeof e=="boolean"?!0:t===!0?!su(e):t?Hg(e)<=t:!1}je.inlineRef=xx;var Px=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function su(e){for(let t in e){if(Px.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(su)||typeof r=="object"&&su(r))return!0}return!1}function Hg(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!kx.has(r)&&(typeof e[r]=="object"&&(0,bx.eachItem)(e[r],n=>t+=Hg(n)),t===1/0))return 1/0}return t}function Wg(e,t="",r){r!==!1&&(t=Gr(t));let n=e.parse(t);return Bg(e,n)}je.getFullPath=Wg;function Bg(e,t){return e.serialize(t).split("#")[0]+"#"}je._getFullPath=Bg;var Tx=/#\/?$/;function Gr(e){return e?e.replace(Tx,""):""}je.normalizeId=Gr;function $x(e,t,r){return r=Gr(r),e.resolve(t,r)}je.resolveUrl=$x;var Rx=/^[a-z_][-a-z0-9._]*$/i;function Ax(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=Gr(e[r]||t),s={"":o},i=Wg(n,o,!1),a={},c=new Set;return vx(e,{allKeys:!0},(d,f,p,m)=>{if(m===void 0)return;let h=i+f,g=s[m];typeof d[r]=="string"&&(g=y.call(this,d[r])),b.call(this,d.$anchor),b.call(this,d.$dynamicAnchor),s[f]=g;function y(w){let O=this.opts.uriResolver.resolve;if(w=Gr(g?O(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!==Gr(h)&&(w[0]==="#"?(u(d,a[w],w),a[w]=d):this.refs[w]=h),w}function b(w){if(typeof w=="string"){if(!Rx.test(w))throw new Error(`invalid anchor "${w}"`);y.call(this,`#${w}`)}}}),a;function u(d,f,p){if(f!==void 0&&!wx(d,f))throw l(p)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}je.getSchemaRefs=Ax});var no=v(Xt=>{"use strict";Object.defineProperty(Xt,"__esModule",{value:!0});Xt.getData=Xt.KeywordCxt=Xt.validateFunctionCode=void 0;var Jg=Pg(),Kg=Qn(),au=Jc(),Ys=Qn(),Ox=Cg(),ro=Lg(),iu=Ug(),T=M(),A=Ct(),Ix=eo(),Mt=q(),to=Xn();function Cx(e){if(e_(e)&&(t_(e),Qg(e))){Dx(e);return}Xg(e,()=>(0,Jg.topBoolOrEmptySchema)(e))}Xt.validateFunctionCode=Cx;function Xg({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},s){o.code.es5?e.func(t,(0,T._)`${A.default.data}, ${A.default.valCxt}`,n.$async,()=>{e.code((0,T._)`"use strict"; ${Gg(r,o)}`),zx(e,o),e.code(s)}):e.func(t,(0,T._)`${A.default.data}, ${Mx(o)}`,n.$async,()=>e.code(Gg(r,o)).code(s))}function Mx(e){return(0,T._)`{${A.default.instancePath}="", ${A.default.parentData}, ${A.default.parentDataProperty}, ${A.default.rootData}=${A.default.data}${e.dynamicRef?(0,T._)`, ${A.default.dynamicAnchors}={}`:T.nil}}={}`}function zx(e,t){e.if(A.default.valCxt,()=>{e.var(A.default.instancePath,(0,T._)`${A.default.valCxt}.${A.default.instancePath}`),e.var(A.default.parentData,(0,T._)`${A.default.valCxt}.${A.default.parentData}`),e.var(A.default.parentDataProperty,(0,T._)`${A.default.valCxt}.${A.default.parentDataProperty}`),e.var(A.default.rootData,(0,T._)`${A.default.valCxt}.${A.default.rootData}`),t.dynamicRef&&e.var(A.default.dynamicAnchors,(0,T._)`${A.default.valCxt}.${A.default.dynamicAnchors}`)},()=>{e.var(A.default.instancePath,(0,T._)`""`),e.var(A.default.parentData,(0,T._)`undefined`),e.var(A.default.parentDataProperty,(0,T._)`undefined`),e.var(A.default.rootData,A.default.data),t.dynamicRef&&e.var(A.default.dynamicAnchors,(0,T._)`{}`)})}function Dx(e){let{schema:t,opts:r,gen:n}=e;Xg(e,()=>{r.$comment&&t.$comment&&n_(e),Fx(e),n.let(A.default.vErrors,null),n.let(A.default.errors,0),r.unevaluated&&Nx(e),r_(e),Hx(e)})}function Nx(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,T._)`${r}.evaluated`),t.if((0,T._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,T._)`${e.evaluated}.props`,(0,T._)`undefined`)),t.if((0,T._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,T._)`${e.evaluated}.items`,(0,T._)`undefined`))}function Gg(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,T._)`/*# sourceURL=${r} */`:T.nil}function Lx(e,t){if(e_(e)&&(t_(e),Qg(e))){jx(e,t);return}(0,Jg.boolOrEmptySchema)(e,t)}function Qg({schema:e,self:t}){if(typeof e=="boolean")return!e;for(let r in e)if(t.RULES.all[r])return!0;return!1}function e_(e){return typeof e.schema!="boolean"}function jx(e,t){let{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&n_(e),qx(e),Zx(e);let s=n.const("_errs",A.default.errors);r_(e,s),n.var(t,(0,T._)`${s} === ${A.default.errors}`)}function t_(e){(0,Mt.checkUnknownRules)(e),Ux(e)}function r_(e,t){if(e.opts.jtd)return Vg(e,[],!1,t);let r=(0,Kg.getSchemaTypes)(e.schema),n=(0,Kg.coerceAndCheckDataType)(e,r);Vg(e,r,!n,t)}function Ux(e){let{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,Mt.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function Fx(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Mt.checkStrictMode)(e,"default is ignored in the schema root")}function qx(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,Ix.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function Zx(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function n_({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)e.code((0,T._)`${A.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,T.str)`${n}/$comment`,a=e.scopeValue("root",{ref:t.root});e.code((0,T._)`${A.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function Hx(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=e;r.$async?t.if((0,T._)`${A.default.errors} === 0`,()=>t.return(A.default.data),()=>t.throw((0,T._)`new ${o}(${A.default.vErrors})`)):(t.assign((0,T._)`${n}.errors`,A.default.vErrors),s.unevaluated&&Wx(e),t.return((0,T._)`${A.default.errors} === 0`))}function Wx({gen:e,evaluated:t,props:r,items:n}){r instanceof T.Name&&e.assign((0,T._)`${t}.props`,r),n instanceof T.Name&&e.assign((0,T._)`${t}.items`,n)}function Vg(e,t,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:u}=e,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,Mt.schemaHasRulesButRef)(s,l))){o.block(()=>s_(e,"$ref",l.all.$ref.definition));return}c.jtd||Bx(e,t),o.block(()=>{for(let f of l.rules)d(f);d(l.post)});function d(f){(0,au.shouldUseGroup)(s,f)&&(f.type?(o.if((0,Ys.checkDataType)(f.type,i,c.strictNumbers)),Yg(e,f),t.length===1&&t[0]===f.type&&r&&(o.else(),(0,Ys.reportTypeError)(e)),o.endIf()):Yg(e,f),a||o.if((0,T._)`${A.default.errors} === ${n||0}`))}}function Yg(e,t){let{gen:r,schema:n,opts:{useDefaults:o}}=e;o&&(0,Ox.assignDefaults)(e,t.type),r.block(()=>{for(let s of t.rules)(0,au.shouldUseRule)(n,s)&&s_(e,s.keyword,s.definition,t.type)})}function Bx(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(Kx(e,t),e.opts.allowUnionTypes||Gx(e,t),Vx(e,e.dataTypes))}function Kx(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{o_(e.dataTypes,r)||cu(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),Jx(e,t)}}function Gx(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&cu(e,"use allowUnionTypes to allow union type keyword")}function Vx(e,t){let r=e.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,au.shouldUseRule)(e.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>Yx(t,i))&&cu(e,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function Yx(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function o_(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function Jx(e,t){let r=[];for(let n of e.dataTypes)o_(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function cu(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,Mt.checkStrictMode)(e,t,e.opts.strictTypes)}var Js=class{constructor(t,r,n){if((0,ro.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Mt.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",i_(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,ro.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",A.default.errors))}result(t,r,n){this.failResult((0,T.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,T.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0,T._)`${r} !== undefined && (${(0,T.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?to.reportExtraError:to.reportError)(this,this.def.error,r)}$dataError(){(0,to.reportError)(this,this.def.$dataError||to.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,to.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=T.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=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)),t!==T.nil&&n.assign(t,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==T.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,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,Ys.checkDataTypes)(c,r,s.opts.strictNumbers,Ys.DataType.Wrong)}`}return T.nil}function a(){if(o.validateSchema){let c=t.scopeValue("validate$data",{ref:o.validateSchema});return(0,T._)`!${c}(${r})`}return T.nil}}subschema(t,r){let n=(0,iu.getSubschema)(this.it,t);(0,iu.extendSubschemaData)(n,this.it,t),(0,iu.extendSubschemaMode)(n,t);let o={...this.it,...n,items:void 0,props:void 0};return Lx(o,r),o}mergeEvaluated(t,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=Mt.mergeEvaluated.props(o,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=Mt.mergeEvaluated.items(o,t.items,n.items,r)))}mergeValidEvaluated(t,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(t,T.Name)),!0}};Xt.KeywordCxt=Js;function s_(e,t,r,n){let o=new Js(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,ro.funcKeywordCode)(o,r):"macro"in r?(0,ro.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,ro.funcKeywordCode)(o,r)}var Xx=/^\/(?:[^~]|~0|~1)*$/,Qx=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function i_(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,s;if(e==="")return A.default.rootData;if(e[0]==="/"){if(!Xx.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=A.default.rootData}else{let u=Qx.exec(e);if(!u)throw new Error(`Invalid JSON-pointer: ${e}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=t)throw new Error(c("property/index",l));return n[t-l]}if(l>t)throw new Error(c("data",l));if(s=r[t-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,T._)`${s}${(0,T.getProperty)((0,Mt.unescapeJsonPointer)(u))}`,i=(0,T._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${t}`}}Xt.getData=i_});var Xs=v(lu=>{"use strict";Object.defineProperty(lu,"__esModule",{value:!0});var uu=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};lu.default=uu});var oo=v(pu=>{"use strict";Object.defineProperty(pu,"__esModule",{value:!0});var du=eo(),fu=class extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,du.resolveUrl)(t,r,n),this.missingSchema=(0,du.normalizeId)((0,du.getFullPath)(t,this.missingRef))}};pu.default=fu});var ei=v(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.resolveSchema=tt.getCompilingSchema=tt.resolveRef=tt.compileSchema=tt.SchemaEnv=void 0;var dt=M(),eP=Xs(),hr=Ct(),ft=eo(),a_=q(),tP=no(),Vr=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,ft.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};tt.SchemaEnv=Vr;function hu(e){let t=c_.call(this,e);if(t)return t;let r=(0,ft.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new dt.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;e.$async&&(a=i.scopeValue("Error",{ref:eP.default,code:(0,dt._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");e.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:hr.default.data,parentData:hr.default.parentData,parentDataProperty:hr.default.parentDataProperty,dataNames:[hr.default.data],dataPathArr:[dt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,dt.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:dt.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,dt._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(e),(0,tP.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(hr.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,e));let p=new Function(`${hr.default.self}`,`${hr.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:p}),p.errors=null,p.schema=e.schema,p.schemaEnv=e,e.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:m,items:h}=u;p.evaluated={props:m instanceof dt.Name?void 0:m,items:h instanceof dt.Name?void 0:h,dynamicProps:m instanceof dt.Name,dynamicItems:h instanceof dt.Name},p.source&&(p.source.evaluated=(0,dt.stringify)(p.evaluated))}return e.validate=p,e}catch(d){throw delete e.validate,delete e.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(e)}}tt.compileSchema=hu;function rP(e,t,r){var n;r=(0,ft.resolveUrl)(this.opts.uriResolver,t,r);let o=e.refs[r];if(o)return o;let s=sP.call(this,e,r);if(s===void 0){let i=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new Vr({schema:i,schemaId:a,root:e,baseId:t}))}if(s!==void 0)return e.refs[r]=nP.call(this,s)}tt.resolveRef=rP;function nP(e){return(0,ft.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:hu.call(this,e)}function c_(e){for(let t of this._compilations)if(oP(t,e))return t}tt.getCompilingSchema=c_;function oP(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function sP(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Qs.call(this,e,t)}function Qs(e,t){let r=this.opts.uriResolver.parse(t),n=(0,ft._getFullPath)(this.opts.uriResolver,r),o=(0,ft.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return mu.call(this,r,e);let s=(0,ft.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=Qs.call(this,e,i);return typeof a?.schema!="object"?void 0:mu.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||hu.call(this,i),s===(0,ft.normalizeId)(t)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,ft.resolveUrl)(this.opts.uriResolver,o,u)),new Vr({schema:a,schemaId:c,root:e,baseId:o})}return mu.call(this,r,i)}}tt.resolveSchema=Qs;var iP=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function mu(e,{baseId:t,schema:r,root:n}){var o;if(((o=e.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,a_.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!iP.has(a)&&u&&(t=(0,ft.resolveUrl)(this.opts.uriResolver,t,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,a_.schemaHasRulesButRef)(r,this.RULES)){let a=(0,ft.resolveUrl)(this.opts.uriResolver,t,r.$ref);s=Qs.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new Vr({schema:r,schemaId:i,root:n,baseId:t}),s.schema!==s.root.schema)return s}});var u_=v((x1,aP)=>{aP.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 bu=v((P1,g_)=>{"use strict";var cP=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),_u=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),uP=RegExp.prototype.test.bind(/^\d*$/u),gr=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),yu=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),d_=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),Su=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),lP=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),Ue=new Array(256);{let e="0123456789ABCDEF";for(let t=0;t<256;t++)Ue[t]="%"+e[t>>4]+e[t&15]}function ke(e){return e<2048?Ue[192|e>>6]+Ue[128|e&63]:e<65536?Ue[224|e>>12]+Ue[128|e>>6&63]+Ue[128|e&63]:Ue[240|e>>18]+Ue[128|e>>12&63]+Ue[128|e>>6&63]+Ue[128|e&63]}function dP(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}var fP=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),pP=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),mP=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),hP=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function gP(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!mP(e[t])){if(e[t]==="%"&&t+2<e.length&&gr(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}function l_(e){let t=-1,r=0,n=-1,o=0;for(let a=0;a<e.length;a++)e[a]==="0"?(n===-1&&(n=a),o++,o>r&&(r=o,t=n)):(n=-1,o=0);if(r<2)return e.join(":");let s=e.slice(0,t).join(":"),i=e.slice(t+r).join(":");return s+"::"+i}function _P(e){let t=e.indexOf("::");if(t!==-1&&e.indexOf("::",t+1)!==-1)return;let r=t===-1?e.split(":"):e.slice(0,t).split(":"),n=t===-1?[]:e.slice(t+2).split(":");t!==-1&&(r.length===1&&r[0]===""&&(r.length=0),n.length===1&&n[0]===""&&(n.length=0));let o=r.concat(n),s=0;for(let a=0;a<o.length;a++){let c=o[a];if(c==="")return;if(c.indexOf(".")!==-1){if(a!==o.length-1||t!==-1&&n.length===0||!_u(c))return;s+=2;continue}if(!fP(c))return;o[a]=parseInt(c,16).toString(16),s++}if(t===-1)return s!==8?void 0:l_(o);if(s>=8)return;let i=o.slice(0,r.length);for(let a=s;a<8;a++)i.push("0");for(let a=r.length;a<o.length;a++)i.push(o[a]);return l_(i)}function gu(e){let t=e[0]==="["&&e[e.length-1]==="]";if((e[0]==="["||e[e.length-1]==="]")&&!t)return{host:e,isIPV6:!1,error:!0};let n=t?e.slice(1,-1):e;if(t&&pP(n))return n=n.toLowerCase(),{host:`[${n}]`,escapedHost:n,isIPV6:!1,isIPVFuture:!0};if(yP(n,":")<2)return{host:e,isIPV6:!1,error:t};let o="",s=n.indexOf("%");if(s!==-1){let a=n.slice(s,s+3).toLowerCase()==="%25"?3:1;if(o=n.slice(s+a),!gP(o))return{host:e,isIPV6:!1,error:!0};n=n.slice(0,s)}let i=_P(n);return i===void 0?{host:e,isIPV6:!1,error:!0}:{host:i+(o?"%"+o:""),escapedHost:i+(o?"%25"+o:""),isIPV6:!0}}function yP(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function SP(e){let t=e,r=[],n=-1,o=0;for(;o=t.length;){if(o===1){if(t===".")break;if(t==="/"){r.push("/");break}else{r.push(t);break}}else if(o===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(o===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((n=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,n)),t=t.slice(n)}return r.join("")}var EP={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},bP=/[@/?#:]/g,wP=/[@/?#]/g;function f_(e,t){let r=t?wP:bP;return r.lastIndex=0,e.replace(r,n=>EP[n])}function p_(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n<e.length;n++){if(e[n]==="%"&&n+2<e.length){let o=e.slice(n+1,n+3);if(gr(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));t&&yu(i)?r+=i:r+="%"+s,n+=2;continue}}r+=e[n]}return r}function vP(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(gr(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));i!=="."&&yu(i)?t+=i:t+="%"+s,r+=2;continue}}if(d_(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=h_(o)?n:Ue[o];else if(o<55296||o>57343)t+=ke(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=ke(65536+(o-55296<<10)+(s-56320)),r++):t+=ke(65533)}else t+=ke(65533)}}return t}function kP(e,t=!1){let r="",n=t&&e[0]!=="/";for(let o=0;o<e.length;o++){let s=e[o];if(s==="%"&&o+2<e.length){let i=e.slice(o+1,o+3);if(gr(i)){r+="%"+i.toUpperCase(),o+=2;continue}}if(s==="/"&&(n=!1),d_(s)&&(s!==":"||!n))r+=s;else{let i=e.charCodeAt(o);if(i<128)r+=Ue[i];else if(i<55296||i>57343)r+=ke(i);else if(i<=56319&&o+1<e.length){let a=e.charCodeAt(o+1);a>=56320&&a<=57343?(r+=ke(65536+(i-55296<<10)+(a-56320)),o++):r+=ke(65533)}else r+=ke(65533)}}return r}function Eu(e,t){let r="";for(let n=0;n<e.length;n++){let o=e[n];if(o==="%"&&n+2<e.length){let s=e.slice(n+1,n+3);if(gr(s)){r+="%"+s.toUpperCase(),n+=2;continue}}if(t(o))r+=o;else{let s=e.charCodeAt(n);if(s<128)r+=Ue[s];else if(s<55296||s>57343)r+=ke(s);else if(s<=56319&&n+1<e.length){let i=e.charCodeAt(n+1);i>=56320&&i<=57343?(r+=ke(65536+(s-55296<<10)+(i-56320)),n++):r+=ke(65533)}else r+=ke(65533)}}return r}function m_(e){return Eu(e,lP)}function xP(e){return Eu(e,Su)}function PP(e){return Eu(e,Su)}function h_(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===42||e===43||e===45||e===46||e===47||e===64||e===95}function TP(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(gr(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));yu(i)?t+=i:t+="%"+s,r+=2;continue}}if(Su(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=h_(o)?n:Ue[o];else if(o<55296||o>57343)t+=ke(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=ke(65536+(o-55296<<10)+(s-56320)),r++):t+=ke(65533)}else t+=ke(65533)}}return t}function $P(e){let t="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){let n=e.slice(r+1,r+3);if(gr(n)){t+="%"+n.toUpperCase(),r+=2;continue}}t+=escape(e[r])}return t}function RP(e){let t=[];if(e.userinfo!==void 0&&(t.push(m_(e.userinfo)),t.push("@")),e.host!==void 0){let r=e.host;if(!_u(r)){let n=gu(r);n.isIPV6!==!0&&n.isIPVFuture!==!0&&(r=p_(r,!0),n=gu(r)),n.isIPV6===!0||n.isIPVFuture===!0?r=`[${n.escapedHost}]`:r=f_(r,!1)}t.push(r)}if(typeof e.port=="number"||typeof e.port=="string"){let r=String(e.port);if(!uP(r))throw new TypeError("URI port is malformed.");t.push(":"),t.push(r)}return t.length?t.join(""):void 0}g_.exports={nonSimpleDomain:hP,recomposeAuthority:RP,reescapeHostDelimiters:f_,normalizePercentEncoding:p_,normalizePathEncoding:vP,serializePathEncoding:kP,normalizeQueryFragmentEncoding:TP,encodeUserinfo:m_,encodeQuery:xP,encodeFragment:PP,escapePreservingEscapes:$P,removeDotSegments:SP,isIPv4:_u,isUUID:cP,normalizeIPv6:gu,stringArrayToHexStripped:dP}});var b_=v((T1,E_)=>{"use strict";var{isUUID:AP}=bu(),OP=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,IP=["http","https","ws","wss","urn","urn:uuid"];function CP(e){return IP.indexOf(e)!==-1}function wu(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}function __(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function y_(e){let t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function MP(e){return e.secure=wu(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function zP(e){if((e.port===(wu(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let t=e.resourceName.indexOf("?"),r=t===-1?e.resourceName:e.resourceName.slice(0,t);e.path=r&&r!=="/"?r:void 0,e.query=t===-1?void 0:e.resourceName.slice(t+1),e.resourceName=void 0}return e.fragment=void 0,e}function DP(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(OP);if(r&&r[0]===e.path){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let o=`${n}:${t.nid||e.nid}`,s=vu(o);e.path=void 0,s&&(e=s.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function NP(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),o=`${r}:${t.nid||n}`,s=vu(o);s&&(e=s.serialize(e,t));let i=e,a=e.nss;return i.path=`${n||t.nid}:${a}`,t.skipEscape=!0,i}function LP(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!AP(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function jP(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var S_={scheme:"http",domainHost:!0,parse:__,serialize:y_},UP={scheme:"https",domainHost:S_.domainHost,parse:__,serialize:y_},ti={scheme:"ws",domainHost:!0,parse:MP,serialize:zP},FP={scheme:"wss",domainHost:ti.domainHost,parse:ti.parse,serialize:ti.serialize},qP={scheme:"urn",parse:DP,serialize:NP,skipNormalize:!0},ZP={scheme:"urn:uuid",parse:LP,serialize:jP,skipNormalize:!0},ri={http:S_,https:UP,ws:ti,wss:FP,urn:qP,"urn:uuid":ZP};Object.setPrototypeOf(ri,null);function vu(e){return e&&(ri[e]||ri[e.toLowerCase()])||void 0}E_.exports={wsIsSecure:wu,SCHEMES:ri,isValidSchemeName:CP,getSchemeHandler:vu}});var M_=v(($1,si)=>{"use strict";var{normalizeIPv6:P_,removeDotSegments:io,recomposeAuthority:HP,normalizePercentEncoding:ku,normalizePathEncoding:WP,serializePathEncoding:w_,normalizeQueryFragmentEncoding:v_,encodeQuery:BP,encodeFragment:KP,reescapeHostDelimiters:GP,isIPv4:T_,nonSimpleDomain:VP}=bu(),{SCHEMES:$_,getSchemeHandler:xu}=b_(),R_=/^[A-Za-z][A-Za-z0-9+.-]*$/u,A_="URI scheme is malformed.";function k_(e){let t=unescape(String(e));if(!R_.test(t))throw new TypeError(A_);return t}function YP(e,t){return typeof e=="string"?e=oT(e,t):typeof e=="object"&&(e=oi(_r(e,t),t)),e}function JP(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},{parsed:o,malformedAuthorityOrPort:s,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:c,malformedScheme:u}=ni(e,n),{parsed:l,malformedAuthorityOrPort:d,malformedPercentEncoding:f,malformedSchemeSpecific:p,malformedHost:m,malformedScheme:h}=ni(t,n);if(s||d||i||f||a||p||c||m||u||h)throw new Error(o.error||l.error||"URI is malformed.");let g=O_(o,l,n,!0),y=xu(r&&r.scheme||g.scheme),b=g.host,w=b!==void 0&&b!==""&&(T_(b)||P_(b).isIPV6);I_(g,r||{},y,w);let O=b&&b.indexOf("%")!==-1&&!new RegExp("\\P{ASCII}","u").test(b);if(g.error&&!O)throw new Error(g.error);return n.skipEscape=!0,_r(g,n)}function O_(e,t,r,n){let o={};return n||(e=oi(_r(e,r),r),t=oi(_r(t,r),r)),r=r||{},!r.tolerant&&t.scheme?(o.scheme=t.scheme,o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=io(t.path||""),o.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=io(t.path||""),o.query=t.query):(t.path?(t.path[0]==="/"?o.path=io(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?o.path="/"+t.path:e.path?o.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:o.path=t.path,o.path=io(o.path)),o.query=t.query):(o.path=e.path,t.query!==void 0?o.query=t.query:o.query=e.query),o.userinfo=e.userinfo,o.host=e.host,o.port=e.port),o.scheme=e.scheme),o.fragment=t.fragment,o}function XP(e,t,r){let n=x_(e,r),o=x_(t,r);return n!==void 0&&o!==void 0&&n===o}function _r(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},n=Object.assign({},t),o=[];r.scheme&&(r.scheme=k_(r.scheme));let s=xu(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n);let i=r.userinfo!==void 0||r.host!==void 0||r.port!==void 0,a=!n.skipEscape&&r.scheme===void 0&&!i;r.path!==void 0&&(n.skipEscape?r.path=ku(r.path):r.path=w_(r.path,a)),n.reference!=="suffix"&&r.scheme&&(r.scheme=k_(r.scheme),o.push(r.scheme,":"));let c=HP(r);if(c!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(c),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let u=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(u=io(u)),a&&(u=w_(u,!0)),c===void 0&&u[0]==="/"&&u[1]==="/"&&(u="/%2F"+u.slice(2)),o.push(u)}return r.query!==void 0&&o.push("?",BP(r.query)),r.fragment!==void 0&&o.push("#",KP(r.fragment)),o.join("")}var QP=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,eT=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,tT=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function rT(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof e.port=="number"&&(e.port<0||e.port>65535))return"URI port is malformed."}function so(e){if(e===void 0)return!1;let t=e.indexOf("%");for(;t!==-1;){if(t+2>=e.length||!/^[\da-f]{2}$/iu.test(e.slice(t+1,t+3)))return!0;t=e.indexOf("%",t+3)}return!1}function Pu(e){return e[0]==="["&&e[e.length-1]==="]"}function nT(e){let t=e[4];return so(e[3])||t!==void 0&&!Pu(t)&&so(t)||so(e[6])||so(e[7])||so(e[8])}function I_(e,t,r,n){if(!t.unicodeSupport&&(!r||!r.unicodeSupport)&&e.host&&!Pu(e.host)&&(t.domainHost||r&&r.domainHost)&&n===!1&&VP(e.host))try{e.host=new URL("http://"+e.host).hostname}catch(o){return e.error=e.error||"Host's domain name can not be converted to ASCII: "+o,!0}return!1}function ni(e,t){let r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1,s=!1,i=!1,a=!1,c=!1,u=!1,l=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let d=e.match(eT);d!==null&&d[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",o=!0);let f=e.match(tT);if(f!==null){let m=f[1],h=m.replace(/[\t\n\r]/g,"");h.length>=2&&(h.slice(0,2)!=="//"?(n.error=n.error||"URI authority must not contain a literal backslash.",o=!0):m.length!==h.length&&(n.error=n.error||"URI authority introducer must not contain whitespace.",o=!0))}let p=e.match(QP);if(p){if(n.scheme=p[1],n.userinfo=p[3],n.host=p[4],n.port=parseInt(p[5],10),n.path=p[6]||"",n.query=p[7],n.fragment=p[8],n.scheme!==void 0){let g=unescape(n.scheme);R_.test(g)?n.scheme=g.toLowerCase():(n.error=n.error||A_,u=!0)}s=nT(p),s&&(n.error=n.error||"URI contains malformed percent-encoding."),isNaN(n.port)&&(n.port=p[5]);let m=rT(n,p);if(m!==void 0&&(n.error=n.error||m,o=!0),n.host)if(T_(n.host)===!1){let y=Pu(n.host),b=n.host.indexOf("[")!==-1||n.host.indexOf("]")!==-1,w=P_(n.host);l=w.isIPV6||w.isIPVFuture===!0,c=b&&(!y||w.error===!0),n.host=l?w.host:w.host.toLowerCase(),c&&(n.error=n.error||"URI host is malformed.",o=!0)}else l=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let h=xu(r.scheme||n.scheme);if(c||(a=I_(n,r,h,l)),e.indexOf("%")!==-1&&n.host!==void 0&&!c){let g=l?n.host:ku(n.host,!0);l||(g=ku(g.toLowerCase())),n.host=GP(g,l)}(!h||h&&!h.skipNormalize)&&(n.path&&(n.path=WP(n.path)),n.query&&(n.query=v_(n.query)),n.fragment&&(n.fragment=v_(n.fragment))),h&&h.parse&&(h.parse(n,r),h===$_.urn&&n.nid===void 0&&(i=!0))}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:u}}function oi(e,t){return ni(e,t).parsed}function oT(e,t){return C_(e,t).normalized}function C_(e,t){let{parsed:r,malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}=ni(e,t);return{normalized:n||o||s||i||a?e:_r(r,t),malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}}function x_(e,t){if(typeof e!="string"&&typeof e!="object")return;let r;try{r=typeof e=="string"?e:_r(e,t)}catch{return}let{normalized:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:c}=C_(r,t);return o||s||i||a||c?void 0:n}var Tu={SCHEMES:$_,normalize:YP,resolve:JP,resolveComponent:O_,equal:XP,serialize:_r,parse:oi};si.exports=Tu;si.exports.default=Tu;si.exports.fastUri=Tu});var D_=v($u=>{"use strict";Object.defineProperty($u,"__esModule",{value:!0});var z_=M_();z_.code='require("ajv/dist/runtime/uri").default';$u.default=z_});var H_=v(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});ye.CodeGen=ye.Name=ye.nil=ye.stringify=ye.str=ye._=ye.KeywordCxt=void 0;var sT=no();Object.defineProperty(ye,"KeywordCxt",{enumerable:!0,get:function(){return sT.KeywordCxt}});var Yr=M();Object.defineProperty(ye,"_",{enumerable:!0,get:function(){return Yr._}});Object.defineProperty(ye,"str",{enumerable:!0,get:function(){return Yr.str}});Object.defineProperty(ye,"stringify",{enumerable:!0,get:function(){return Yr.stringify}});Object.defineProperty(ye,"nil",{enumerable:!0,get:function(){return Yr.nil}});Object.defineProperty(ye,"Name",{enumerable:!0,get:function(){return Yr.Name}});Object.defineProperty(ye,"CodeGen",{enumerable:!0,get:function(){return Yr.CodeGen}});var iT=Xs(),F_=oo(),aT=Yc(),ao=ei(),cT=M(),co=eo(),ii=Qn(),Au=q(),N_=u_(),uT=D_(),q_=(e,t)=>new RegExp(e,t);q_.code="new RegExp";var lT=["removeAdditional","useDefaults","coerceTypes"],dT=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),fT={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."},pT={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},L_=200;function mT(e){var t,r,n,o,s,i,a,c,u,l,d,f,p,m,h,g,y,b,w,O,x,z,j,Ge,xe;let Ve=e.strict,xr=(t=e.code)===null||t===void 0?void 0:t.optimize,Oo=xr===!0||xr===void 0?1:xr||0,Io=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:q_,$E=(o=e.uriResolver)!==null&&o!==void 0?o:uT.default;return{strictSchema:(i=(s=e.strictSchema)!==null&&s!==void 0?s:Ve)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=e.strictNumbers)!==null&&a!==void 0?a:Ve)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=e.strictTypes)!==null&&u!==void 0?u:Ve)!==null&&l!==void 0?l:"log",strictTuples:(f=(d=e.strictTuples)!==null&&d!==void 0?d:Ve)!==null&&f!==void 0?f:"log",strictRequired:(m=(p=e.strictRequired)!==null&&p!==void 0?p:Ve)!==null&&m!==void 0?m:!1,code:e.code?{...e.code,optimize:Oo,regExp:Io}:{optimize:Oo,regExp:Io},loopRequired:(h=e.loopRequired)!==null&&h!==void 0?h:L_,loopEnum:(g=e.loopEnum)!==null&&g!==void 0?g:L_,meta:(y=e.meta)!==null&&y!==void 0?y:!0,messages:(b=e.messages)!==null&&b!==void 0?b:!0,inlineRefs:(w=e.inlineRefs)!==null&&w!==void 0?w:!0,schemaId:(O=e.schemaId)!==null&&O!==void 0?O:"$id",addUsedSchema:(x=e.addUsedSchema)!==null&&x!==void 0?x:!0,validateSchema:(z=e.validateSchema)!==null&&z!==void 0?z:!0,validateFormats:(j=e.validateFormats)!==null&&j!==void 0?j:!0,unicodeRegExp:(Ge=e.unicodeRegExp)!==null&&Ge!==void 0?Ge:!0,int32range:(xe=e.int32range)!==null&&xe!==void 0?xe:!0,uriResolver:$E}}var uo=class{constructor(t={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...mT(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new cT.ValueScope({scope:{},prefixes:dT,es5:r,lines:n}),this.logger=ET(t.logger);let o=t.validateFormats;t.validateFormats=!1,this.RULES=(0,aT.getRules)(),j_.call(this,fT,t,"NOT SUPPORTED"),j_.call(this,pT,t,"DEPRECATED","warn"),this._metaOpts=yT.call(this),t.formats&&gT.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&_T.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),hT.call(this),t.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,o=N_;n==="id"&&(o={...N_},o.id=o.$id,delete o.$id),r&&t&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let n;if(typeof t=="string"){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(t,r){let n=this._addSchema(t,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return o.call(this,t,r);async function o(l,d){await s.call(this,l.$schema);let f=this._addSchema(l,d);return f.validate||i.call(this,f)}async function s(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof F_.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await s.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(t,r,n,o=this.opts.validateSchema){if(Array.isArray(t)){for(let i of t)this.addSchema(i,void 0,n,o);return this}let s;if(typeof t=="object"){let{schemaId:i}=this.opts;if(s=t[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,co.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(t,n,r,o,!0),this}addMetaSchema(t,r,n=this.opts.validateSchema){return this.addSchema(t,r,!0,n),this}validateSchema(t,r){if(typeof t=="boolean")return!0;let n;if(n=t.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(n,t);if(!o&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return o}getSchema(t){let r;for(;typeof(r=U_.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,o=new ao.SchemaEnv({schema:{},schemaId:n});if(r=ao.resolveSchema.call(this,o,t),!r)return;this.refs[t]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=U_.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{let r=t;this._cache.delete(r);let n=t[this.opts.schemaId];return n&&(n=(0,co.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let n;if(typeof t=="string")n=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof t=="object"&&r===void 0){if(r=t,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(wT.call(this,n,r),!r)return(0,Au.eachItem)(n,s=>Ru.call(this,s)),this;kT.call(this,r);let o={...r,type:(0,ii.getJSONTypes)(r.type),schemaType:(0,ii.getJSONTypes)(r.schemaType)};return(0,Au.eachItem)(n,o.type.length===0?s=>Ru.call(this,s,o):s=>o.type.forEach(i=>Ru.call(this,s,o,i))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===t);o>=0&&n.rules.splice(o,1)}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!t||t.length===0?"No errors":t.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let o of r){let s=o.split("/").slice(1),i=t;for(let a of s)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=Z_(l))}}return t}_removeAllSchemas(t,r){for(let n in t){let o=t[n];(!r||r.test(n))&&(typeof o=="string"?delete t[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete t[n]))}}_addSchema(t,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof t=="object")i=t[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(t);if(c!==void 0)return c;n=(0,co.normalizeId)(i||n);let u=co.getSchemaRefs.call(this,t,n);return c=new ao.SchemaEnv({schema:t,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),o&&this.validateSchema(t,!0),c}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):ao.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{ao.compileSchema.call(this,t)}finally{this.opts=r}}};uo.ValidationError=iT.default;uo.MissingRefError=F_.default;ye.default=uo;function j_(e,t,r,n="error"){for(let o in e){let s=o;s in t&&this.logger[n](`${r}: option ${o}. ${e[s]}`)}}function U_(e){return e=(0,co.normalizeId)(e),this.schemas[e]||this.refs[e]}function hT(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function gT(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function _T(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}function yT(){let e={...this.opts};for(let t of lT)delete e[t];return e}var ST={log(){},warn(){},error(){}};function ET(e){if(e===!1)return ST;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var bT=/^[a-z_$][a-z0-9_$:-]*$/i;function wT(e,t){let{RULES:r}=this;if((0,Au.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!bT.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function Ru(e,t,r){var n;let o=t?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,i=o?s.post:s.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},s.rules.push(i)),s.keywords[e]=!0,!t)return;let a={keyword:e,definition:{...t,type:(0,ii.getJSONTypes)(t.type),schemaType:(0,ii.getJSONTypes)(t.schemaType)}};t.before?vT.call(this,i,a,t.before):i.rules.push(a),s.all[e]=a,(n=t.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function vT(e,t,r){let n=e.rules.findIndex(o=>o.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function kT(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=Z_(t)),e.validateSchema=this.compile(t,!0))}var xT={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Z_(e){return{anyOf:[e,xT]}}});var W_=v(Ou=>{"use strict";Object.defineProperty(Ou,"__esModule",{value:!0});var PT={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Ou.default=PT});var V_=v(yr=>{"use strict";Object.defineProperty(yr,"__esModule",{value:!0});yr.callRef=yr.getValidate=void 0;var TT=oo(),B_=et(),Fe=M(),Jr=Ct(),K_=ei(),ai=q(),$T={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=K_.resolveRef.call(c,u,o,r);if(l===void 0)throw new TT.default(n.opts.uriResolver,o,r);if(l instanceof K_.SchemaEnv)return f(l);return p(l);function d(){if(s===u)return ci(e,i,s,s.$async);let m=t.scopeValue("root",{ref:u});return ci(e,(0,Fe._)`${m}.validate`,u,u.$async)}function f(m){let h=G_(e,m);ci(e,h,m,m.$async)}function p(m){let h=t.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Fe.stringify)(m)}:{ref:m}),g=t.name("valid"),y=e.subschema({schema:m,dataTypes:[],schemaPath:Fe.nil,topSchemaRef:h,errSchemaPath:r},g);e.mergeEvaluated(y),e.ok(g)}}};function G_(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Fe._)`${r.scopeValue("wrapper",{ref:t})}.validate`}yr.getValidate=G_;function ci(e,t,r,n){let{gen:o,it:s}=e,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?Jr.default.this:Fe.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let m=o.let("valid");o.try(()=>{o.code((0,Fe._)`await ${(0,B_.callValidateCode)(e,t,u)}`),p(t),i||o.assign(m,!0)},h=>{o.if((0,Fe._)`!(${h} instanceof ${s.ValidationError})`,()=>o.throw(h)),f(h),i||o.assign(m,!1)}),e.ok(m)}function d(){e.result((0,B_.callValidateCode)(e,t,u),()=>p(t),()=>f(t))}function f(m){let h=(0,Fe._)`${m}.errors`;o.assign(Jr.default.vErrors,(0,Fe._)`${Jr.default.vErrors} === null ? ${h} : ${Jr.default.vErrors}.concat(${h})`),o.assign(Jr.default.errors,(0,Fe._)`${Jr.default.vErrors}.length`)}function p(m){var h;if(!s.opts.unevaluated)return;let g=(h=r?.validate)===null||h===void 0?void 0:h.evaluated;if(s.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(s.props=ai.mergeEvaluated.props(o,g.props,s.props));else{let y=o.var("props",(0,Fe._)`${m}.evaluated.props`);s.props=ai.mergeEvaluated.props(o,y,s.props,Fe.Name)}if(s.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(s.items=ai.mergeEvaluated.items(o,g.items,s.items));else{let y=o.var("items",(0,Fe._)`${m}.evaluated.items`);s.items=ai.mergeEvaluated.items(o,y,s.items,Fe.Name)}}}yr.callRef=ci;yr.default=$T});var Y_=v(Iu=>{"use strict";Object.defineProperty(Iu,"__esModule",{value:!0});var RT=W_(),AT=V_(),OT=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",RT.default,AT.default];Iu.default=OT});var J_=v(Cu=>{"use strict";Object.defineProperty(Cu,"__esModule",{value:!0});var ui=M(),Qt=ui.operators,li={maximum:{okStr:"<=",ok:Qt.LTE,fail:Qt.GT},minimum:{okStr:">=",ok:Qt.GTE,fail:Qt.LT},exclusiveMaximum:{okStr:"<",ok:Qt.LT,fail:Qt.GTE},exclusiveMinimum:{okStr:">",ok:Qt.GT,fail:Qt.LTE}},IT={message:({keyword:e,schemaCode:t})=>(0,ui.str)`must be ${li[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,ui._)`{comparison: ${li[e].okStr}, limit: ${t}}`},CT={keyword:Object.keys(li),type:"number",schemaType:"number",$data:!0,error:IT,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,ui._)`${r} ${li[t].fail} ${n} || isNaN(${r})`)}};Cu.default=CT});var X_=v(Mu=>{"use strict";Object.defineProperty(Mu,"__esModule",{value:!0});var lo=M(),MT={message:({schemaCode:e})=>(0,lo.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,lo._)`{multipleOf: ${e}}`},zT={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:MT,code(e){let{gen:t,data:r,schemaCode:n,it:o}=e,s=o.opts.multipleOfPrecision,i=t.let("res"),a=s?(0,lo._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,lo._)`${i} !== parseInt(${i})`;e.fail$data((0,lo._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};Mu.default=zT});var ey=v(zu=>{"use strict";Object.defineProperty(zu,"__esModule",{value:!0});function Q_(e){let t=e.length,r=0,n=0,o;for(;n<t;)r++,o=e.charCodeAt(n++),o>=55296&&o<=56319&&n<t&&(o=e.charCodeAt(n),(o&64512)===56320&&n++);return r}zu.default=Q_;Q_.code='require("ajv/dist/runtime/ucs2length").default'});var ty=v(Du=>{"use strict";Object.defineProperty(Du,"__esModule",{value:!0});var Sr=M(),DT=q(),NT=ey(),LT={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,Sr.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,Sr._)`{limit: ${e}}`},jT={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:LT,code(e){let{keyword:t,data:r,schemaCode:n,it:o}=e,s=t==="maxLength"?Sr.operators.GT:Sr.operators.LT,i=o.opts.unicode===!1?(0,Sr._)`${r}.length`:(0,Sr._)`${(0,DT.useFunc)(e.gen,NT.default)}(${r})`;e.fail$data((0,Sr._)`${i} ${s} ${n}`)}};Du.default=jT});var ry=v(Nu=>{"use strict";Object.defineProperty(Nu,"__esModule",{value:!0});var UT=et(),FT=q(),Xr=M(),qT={message:({schemaCode:e})=>(0,Xr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Xr._)`{pattern: ${e}}`},ZT={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:qT,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,Xr._)`new RegExp`:(0,FT.useFunc)(t,c),l=t.let("valid");t.try(()=>t.assign(l,(0,Xr._)`${u}(${s}, ${a}).test(${r})`),()=>t.assign(l,!1)),e.fail$data((0,Xr._)`!${l}`)}else{let c=(0,UT.usePattern)(e,o);e.fail$data((0,Xr._)`!${c}.test(${r})`)}}};Nu.default=ZT});var ny=v(Lu=>{"use strict";Object.defineProperty(Lu,"__esModule",{value:!0});var fo=M(),HT={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,fo.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,fo._)`{limit: ${e}}`},WT={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:HT,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxProperties"?fo.operators.GT:fo.operators.LT;e.fail$data((0,fo._)`Object.keys(${r}).length ${o} ${n}`)}};Lu.default=WT});var oy=v(ju=>{"use strict";Object.defineProperty(ju,"__esModule",{value:!0});var po=et(),mo=M(),BT=q(),KT={message:({params:{missingProperty:e}})=>(0,mo.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,mo._)`{missingProperty: ${e}}`},GT={keyword:"required",type:"object",schemaType:"array",$data:!0,error:KT,code(e){let{gen:t,schema:r,schemaCode:n,data:o,$data:s,it:i}=e,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let p=e.parentSchema.properties,{definedProperties:m}=e.it;for(let h of r)if(p?.[h]===void 0&&!m.has(h)){let g=i.schemaEnv.baseId+i.errSchemaPath,y=`required property "${h}" is not defined at "${g}" (strictRequired)`;(0,BT.checkStrictMode)(i,y,i.opts.strictRequired)}}function u(){if(c||s)e.block$data(mo.nil,d);else for(let p of r)(0,po.checkReportMissingProp)(e,p)}function l(){let p=t.let("missing");if(c||s){let m=t.let("valid",!0);e.block$data(m,()=>f(p,m)),e.ok(m)}else t.if((0,po.checkMissingProp)(e,r,p)),(0,po.reportMissingProp)(e,p),t.else()}function d(){t.forOf("prop",n,p=>{e.setParams({missingProperty:p}),t.if((0,po.noPropertyInData)(t,o,p,a.ownProperties),()=>e.error())})}function f(p,m){e.setParams({missingProperty:p}),t.forOf(p,n,()=>{t.assign(m,(0,po.propertyInData)(t,o,p,a.ownProperties)),t.if((0,mo.not)(m),()=>{e.error(),t.break()})},mo.nil)}}};ju.default=GT});var sy=v(Uu=>{"use strict";Object.defineProperty(Uu,"__esModule",{value:!0});var ho=M(),VT={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,ho.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,ho._)`{limit: ${e}}`},YT={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:VT,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxItems"?ho.operators.GT:ho.operators.LT;e.fail$data((0,ho._)`${r}.length ${o} ${n}`)}};Uu.default=YT});var di=v(Fu=>{"use strict";Object.defineProperty(Fu,"__esModule",{value:!0});var iy=ou();iy.code='require("ajv/dist/runtime/equal").default';Fu.default=iy});var ay=v(Zu=>{"use strict";Object.defineProperty(Zu,"__esModule",{value:!0});var qu=Qn(),Se=M(),JT=q(),XT=di(),QT={message:({params:{i:e,j:t}})=>(0,Se.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,Se._)`{i: ${e}, j: ${t}}`},e$={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:QT,code(e){let{gen:t,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=e;if(!n&&!o)return;let c=t.let("valid"),u=s.items?(0,qu.getSchemaTypes)(s.items):[];e.block$data(c,l,(0,Se._)`${i} === false`),e.ok(c);function l(){let m=t.let("i",(0,Se._)`${r}.length`),h=t.let("j");e.setParams({i:m,j:h}),t.assign(c,!0),t.if((0,Se._)`${m} > 1`,()=>(d()?f:p)(m,h))}function d(){return u.length>0&&!u.some(m=>m==="object"||m==="array")}function f(m,h){let g=t.name("item"),y=(0,qu.checkDataTypes)(u,g,a.opts.strictNumbers,qu.DataType.Wrong),b=t.const("indices",(0,Se._)`{}`);t.for((0,Se._)`;${m}--;`,()=>{t.let(g,(0,Se._)`${r}[${m}]`),t.if(y,(0,Se._)`continue`),u.length>1&&t.if((0,Se._)`typeof ${g} == "string"`,(0,Se._)`${g} += "_"`),t.if((0,Se._)`typeof ${b}[${g}] == "number"`,()=>{t.assign(h,(0,Se._)`${b}[${g}]`),e.error(),t.assign(c,!1).break()}).code((0,Se._)`${b}[${g}] = ${m}`)})}function p(m,h){let g=(0,JT.useFunc)(t,XT.default),y=t.name("outer");t.label(y).for((0,Se._)`;${m}--;`,()=>t.for((0,Se._)`${h} = ${m}; ${h}--;`,()=>t.if((0,Se._)`${g}(${r}[${m}], ${r}[${h}])`,()=>{e.error(),t.assign(c,!1).break(y)})))}}};Zu.default=e$});var cy=v(Wu=>{"use strict";Object.defineProperty(Wu,"__esModule",{value:!0});var Hu=M(),t$=q(),r$=di(),n$={message:"must be equal to constant",params:({schemaCode:e})=>(0,Hu._)`{allowedValue: ${e}}`},o$={keyword:"const",$data:!0,error:n$,code(e){let{gen:t,data:r,$data:n,schemaCode:o,schema:s}=e;n||s&&typeof s=="object"?e.fail$data((0,Hu._)`!${(0,t$.useFunc)(t,r$.default)}(${r}, ${o})`):e.fail((0,Hu._)`${s} !== ${r}`)}};Wu.default=o$});var uy=v(Bu=>{"use strict";Object.defineProperty(Bu,"__esModule",{value:!0});var go=M(),s$=q(),i$=di(),a$={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,go._)`{allowedValues: ${e}}`},c$={keyword:"enum",schemaType:"array",$data:!0,error:a$,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let a=o.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,s$.useFunc)(t,i$.default)),l;if(a||n)l=t.let("valid"),e.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let p=t.const("vSchema",s);l=(0,go.or)(...o.map((m,h)=>f(p,h)))}e.pass(l);function d(){t.assign(l,!1),t.forOf("v",s,p=>t.if((0,go._)`${u()}(${r}, ${p})`,()=>t.assign(l,!0).break()))}function f(p,m){let h=o[m];return typeof h=="object"&&h!==null?(0,go._)`${u()}(${r}, ${p}[${m}])`:(0,go._)`${r} === ${h}`}}};Bu.default=c$});var ly=v(Ku=>{"use strict";Object.defineProperty(Ku,"__esModule",{value:!0});var u$=J_(),l$=X_(),d$=ty(),f$=ry(),p$=ny(),m$=oy(),h$=sy(),g$=ay(),_$=cy(),y$=uy(),S$=[u$.default,l$.default,d$.default,f$.default,p$.default,m$.default,h$.default,g$.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},_$.default,y$.default];Ku.default=S$});var Vu=v(_o=>{"use strict";Object.defineProperty(_o,"__esModule",{value:!0});_o.validateAdditionalItems=void 0;var Er=M(),Gu=q(),E$={message:({params:{len:e}})=>(0,Er.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Er._)`{limit: ${e}}`},b$={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:E$,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Gu.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}dy(e,n)}};function dy(e,t){let{gen:r,schema:n,data:o,keyword:s,it:i}=e;i.items=!0;let a=r.const("len",(0,Er._)`${o}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,Er._)`${a} <= ${t.length}`);else if(typeof n=="object"&&!(0,Gu.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,Er._)`${a} <= ${t.length}`);r.if((0,Er.not)(u),()=>c(u)),e.ok(u)}function c(u){r.forRange("i",t.length,a,l=>{e.subschema({keyword:s,dataProp:l,dataPropType:Gu.Type.Num},u),i.allErrors||r.if((0,Er.not)(u),()=>r.break())})}}_o.validateAdditionalItems=dy;_o.default=b$});var Yu=v(yo=>{"use strict";Object.defineProperty(yo,"__esModule",{value:!0});yo.validateTuple=void 0;var fy=M(),fi=q(),w$=et(),v$={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return py(e,"additionalItems",t);r.items=!0,!(0,fi.alwaysValidSchema)(r,t)&&e.ok((0,w$.validateArray)(e))}};function py(e,t,r=e.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=e;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=fi.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,fy._)`${s}.length`);r.forEach((d,f)=>{(0,fi.alwaysValidSchema)(a,d)||(n.if((0,fy._)`${u} > ${f}`,()=>e.subschema({keyword:i,schemaProp:f,dataProp:f},c)),e.ok(c))});function l(d){let{opts:f,errSchemaPath:p}=a,m=r.length,h=m===d.minItems&&(m===d.maxItems||d[t]===!1);if(f.strictTuples&&!h){let g=`"${i}" is ${m}-tuple, but minItems or maxItems/${t} are not specified or different at path "${p}"`;(0,fi.checkStrictMode)(a,g,f.strictTuples)}}}yo.validateTuple=py;yo.default=v$});var my=v(Ju=>{"use strict";Object.defineProperty(Ju,"__esModule",{value:!0});var k$=Yu(),x$={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,k$.validateTuple)(e,"items")};Ju.default=x$});var gy=v(Xu=>{"use strict";Object.defineProperty(Xu,"__esModule",{value:!0});var hy=M(),P$=q(),T$=et(),$$=Vu(),R$={message:({params:{len:e}})=>(0,hy.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,hy._)`{limit: ${e}}`},A$={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:R$,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,!(0,P$.alwaysValidSchema)(n,t)&&(o?(0,$$.validateAdditionalItems)(e,o):e.ok((0,T$.validateArray)(e)))}};Xu.default=A$});var _y=v(Qu=>{"use strict";Object.defineProperty(Qu,"__esModule",{value:!0});var rt=M(),pi=q(),O$={message:({params:{min:e,max:t}})=>t===void 0?(0,rt.str)`must contain at least ${e} valid item(s)`:(0,rt.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,rt._)`{minContains: ${e}}`:(0,rt._)`{minContains: ${e}, maxContains: ${t}}`},I$={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:O$,code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e,i,a,{minContains:c,maxContains:u}=n;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=t.const("len",(0,rt._)`${o}.length`);if(e.setParams({min:i,max:a}),a===void 0&&i===0){(0,pi.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,pi.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,pi.alwaysValidSchema)(s,r)){let h=(0,rt._)`${l} >= ${i}`;a!==void 0&&(h=(0,rt._)`${h} && ${l} <= ${a}`),e.pass(h);return}s.items=!0;let d=t.name("valid");a===void 0&&i===1?p(d,()=>t.if(d,()=>t.break())):i===0?(t.let(d,!0),a!==void 0&&t.if((0,rt._)`${o}.length > 0`,f)):(t.let(d,!1),f()),e.result(d,()=>e.reset());function f(){let h=t.name("_valid"),g=t.let("count",0);p(h,()=>t.if(h,()=>m(g)))}function p(h,g){t.forRange("i",0,l,y=>{e.subschema({keyword:"contains",dataProp:y,dataPropType:pi.Type.Num,compositeRule:!0},h),g()})}function m(h){t.code((0,rt._)`${h}++`),a===void 0?t.if((0,rt._)`${h} >= ${i}`,()=>t.assign(d,!0).break()):(t.if((0,rt._)`${h} > ${a}`,()=>t.assign(d,!1).break()),i===1?t.assign(d,!0):t.if((0,rt._)`${h} >= ${i}`,()=>t.assign(d,!0)))}}};Qu.default=I$});var Ey=v(bt=>{"use strict";Object.defineProperty(bt,"__esModule",{value:!0});bt.validateSchemaDeps=bt.validatePropertyDeps=bt.error=void 0;var el=M(),C$=q(),So=et();bt.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,el.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,el._)`{property: ${e},
|
|
20
20
|
missingProperty: ${n},
|
|
21
21
|
depsCount: ${t},
|
|
22
|
-
deps: ${r}}`};var M$={keyword:"dependencies",type:"object",schemaType:"object",error:bt.error,code(e){let[t,r]=z$(e);yy(e,t),Sy(e,r)}};function z$({schema:e}){let t={},r={};for(let n in e){if(n==="__proto__")continue;let o=Array.isArray(e[n])?t:r;o[n]=e[n]}return[t,r]}function yy(e,t=e.schema){let{gen:r,data:n,it:o}=e;if(Object.keys(t).length===0)return;let s=r.let("missing");for(let i in t){let a=t[i];if(a.length===0)continue;let c=(0,So.propertyInData)(r,n,i,o.opts.ownProperties);e.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,So.checkReportMissingProp)(e,u)}):(r.if((0,el._)`${c} && (${(0,So.checkMissingProp)(e,a,s)})`),(0,So.reportMissingProp)(e,s),r.else())}}bt.validatePropertyDeps=yy;function Sy(e,t=e.schema){let{gen:r,data:n,keyword:o,it:s}=e,i=r.name("valid");for(let a in t)(0,C$.alwaysValidSchema)(s,t[a])||(r.if((0,So.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=e.subschema({keyword:o,schemaProp:a},i);e.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),e.ok(i))}bt.validateSchemaDeps=Sy;bt.default=M$});var vy=w(tl=>{"use strict";Object.defineProperty(tl,"__esModule",{value:!0});var by=M(),D$=q(),N$={message:"property name must be valid",params:({params:e})=>(0,by._)`{propertyName: ${e.propertyName}}`},L$={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:N$,code(e){let{gen:t,schema:r,data:n,it:o}=e;if((0,D$.alwaysValidSchema)(o,r))return;let s=t.name("valid");t.forIn("key",n,i=>{e.setParams({propertyName:i}),e.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),t.if((0,by.not)(s),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(s)}};tl.default=L$});var nl=w(rl=>{"use strict";Object.defineProperty(rl,"__esModule",{value:!0});var mi=et(),pt=M(),j$=Ct(),hi=q(),U$={message:"must NOT have additional properties",params:({params:e})=>(0,pt._)`{additionalProperty: ${e.additionalProperty}}`},F$={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:U$,code(e){let{gen:t,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=e;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,hi.alwaysValidSchema)(i,r))return;let u=(0,mi.allSchemaProperties)(n.properties),l=(0,mi.allSchemaProperties)(n.patternProperties);d(),e.ok((0,pt._)`${s} === ${j$.default.errors}`);function d(){t.forIn("key",o,g=>{!u.length&&!l.length?m(g):t.if(f(g),()=>m(g))})}function f(g){let y;if(u.length>8){let b=(0,hi.schemaRefOrVal)(i,n.properties,"properties");y=(0,mi.isOwnProperty)(t,b,g)}else u.length?y=(0,pt.or)(...u.map(b=>(0,pt._)`${g} === ${b}`)):y=pt.nil;return l.length&&(y=(0,pt.or)(y,...l.map(b=>(0,pt._)`${(0,mi.usePattern)(e,b)}.test(${g})`))),(0,pt.not)(y)}function p(g){t.code((0,pt._)`delete ${o}[${g}]`)}function m(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){p(g);return}if(r===!1){e.setParams({additionalProperty:g}),e.error(),a||t.break();return}if(typeof r=="object"&&!(0,hi.alwaysValidSchema)(i,r)){let y=t.name("valid");c.removeAdditional==="failing"?(h(g,y,!1),t.if((0,pt.not)(y),()=>{e.reset(),p(g)})):(h(g,y),a||t.if((0,pt.not)(y),()=>t.break()))}}function h(g,y,b){let v={keyword:"additionalProperties",dataProp:g,dataPropType:hi.Type.Str};b===!1&&Object.assign(v,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(v,y)}}};rl.default=F$});var xy=w(sl=>{"use strict";Object.defineProperty(sl,"__esModule",{value:!0});var q$=no(),wy=et(),ol=q(),ky=nl(),Z$={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&ky.default.code(new q$.KeywordCxt(s,ky.default,"additionalProperties"));let i=(0,wy.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=ol.mergeEvaluated.props(t,(0,ol.toHash)(i),s.props));let a=i.filter(d=>!(0,ol.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=t.name("valid");for(let d of a)u(d)?l(d):(t.if((0,wy.propertyInData)(t,o,d,s.opts.ownProperties)),l(d),s.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};sl.default=Z$});var Ry=w(il=>{"use strict";Object.defineProperty(il,"__esModule",{value:!0});var Py=et(),gi=M(),Ty=q(),$y=q(),W$={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:o,it:s}=e,{opts:i}=s,a=(0,Py.allSchemaProperties)(r),c=a.filter(h=>(0,Ty.alwaysValidSchema)(s,r[h]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=t.name("valid");s.props!==!0&&!(s.props instanceof gi.Name)&&(s.props=(0,$y.evaluatedPropsToName)(t,s.props));let{props:d}=s;f();function f(){for(let h of a)u&&p(h),s.allErrors?m(h):(t.var(l,!0),m(h),t.if(l))}function p(h){for(let g in u)new RegExp(h).test(g)&&(0,Ty.checkStrictMode)(s,`property ${g} matches pattern ${h} (use allowMatchingProperties)`)}function m(h){t.forIn("key",n,g=>{t.if((0,gi._)`${(0,Py.usePattern)(e,h)}.test(${g})`,()=>{let y=c.includes(h);y||e.subschema({keyword:"patternProperties",schemaProp:h,dataProp:g,dataPropType:$y.Type.Str},l),s.opts.unevaluated&&d!==!0?t.assign((0,gi._)`${d}[${g}]`,!0):!y&&!s.allErrors&&t.if((0,gi.not)(l),()=>t.break())})})}}};il.default=W$});var Ay=w(al=>{"use strict";Object.defineProperty(al,"__esModule",{value:!0});var H$=q(),B$={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,H$.alwaysValidSchema)(n,r)){e.fail();return}let o=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),e.failResult(o,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};al.default=B$});var Oy=w(cl=>{"use strict";Object.defineProperty(cl,"__esModule",{value:!0});var K$=et(),G$={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:K$.validateUnion,error:{message:"must match a schema in anyOf"}};cl.default=G$});var Iy=w(ul=>{"use strict";Object.defineProperty(ul,"__esModule",{value:!0});var _i=M(),V$=q(),Y$={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,_i._)`{passingSchemas: ${e.passing}}`},J$={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:Y$,code(e){let{gen:t,schema:r,parentSchema:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,i=t.let("valid",!1),a=t.let("passing",null),c=t.name("_valid");e.setParams({passing:a}),t.block(u),e.result(i,()=>e.reset(),()=>e.error(!0));function u(){s.forEach((l,d)=>{let f;(0,V$.alwaysValidSchema)(o,l)?t.var(c,!0):f=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&t.if((0,_i._)`${c} && ${i}`).assign(i,!1).assign(a,(0,_i._)`[${a}, ${d}]`).else(),t.if(c,()=>{t.assign(i,!0),t.assign(a,d),f&&e.mergeEvaluated(f,_i.Name)})})}}};ul.default=J$});var Cy=w(ll=>{"use strict";Object.defineProperty(ll,"__esModule",{value:!0});var X$=q(),Q$={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=t.name("valid");r.forEach((s,i)=>{if((0,X$.alwaysValidSchema)(n,s))return;let a=e.subschema({keyword:"allOf",schemaProp:i},o);e.ok(o),e.mergeEvaluated(a)})}};ll.default=Q$});var Dy=w(dl=>{"use strict";Object.defineProperty(dl,"__esModule",{value:!0});var yi=M(),zy=q(),eR={message:({params:e})=>(0,yi.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,yi._)`{failingKeyword: ${e.ifClause}}`},tR={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:eR,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,zy.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=My(n,"then"),s=My(n,"else");if(!o&&!s)return;let i=t.let("valid",!0),a=t.name("_valid");if(c(),e.reset(),o&&s){let l=t.let("ifClause");e.setParams({ifClause:l}),t.if(a,u("then",l),u("else",l))}else o?t.if(a,u("then")):t.if((0,yi.not)(a),u("else"));e.pass(i,()=>e.error(!0));function c(){let l=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(l)}function u(l,d){return()=>{let f=e.subschema({keyword:l},a);t.assign(i,a),e.mergeValidEvaluated(f,i),d?t.assign(d,(0,yi._)`${l}`):e.setParams({ifClause:l})}}}};function My(e,t){let r=e.schema[t];return r!==void 0&&!(0,zy.alwaysValidSchema)(e,r)}dl.default=tR});var Ny=w(fl=>{"use strict";Object.defineProperty(fl,"__esModule",{value:!0});var rR=q(),nR={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,rR.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};fl.default=nR});var Ly=w(pl=>{"use strict";Object.defineProperty(pl,"__esModule",{value:!0});var oR=Vu(),sR=my(),iR=Yu(),aR=gy(),cR=_y(),uR=Ey(),lR=vy(),dR=nl(),fR=xy(),pR=Ry(),mR=Ay(),hR=Oy(),gR=Iy(),_R=Cy(),yR=Dy(),SR=Ny();function ER(e=!1){let t=[mR.default,hR.default,gR.default,_R.default,yR.default,SR.default,lR.default,dR.default,uR.default,fR.default,pR.default];return e?t.push(sR.default,aR.default):t.push(oR.default,iR.default),t.push(cR.default),t}pl.default=ER});var jy=w(ml=>{"use strict";Object.defineProperty(ml,"__esModule",{value:!0});var le=M(),bR={message:({schemaCode:e})=>(0,le.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,le._)`{format: ${e}}`},vR={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:bR,code(e,t){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=e,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?f():p();function f(){let m=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),h=r.const("fDef",(0,le._)`${m}[${i}]`),g=r.let("fType"),y=r.let("format");r.if((0,le._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>r.assign(g,(0,le._)`${h}.type || "string"`).assign(y,(0,le._)`${h}.validate`),()=>r.assign(g,(0,le._)`"string"`).assign(y,h)),e.fail$data((0,le.or)(b(),v()));function b(){return c.strictSchema===!1?le.nil:(0,le._)`${i} && !${y}`}function v(){let O=l.$async?(0,le._)`(${h}.async ? await ${y}(${n}) : ${y}(${n}))`:(0,le._)`${y}(${n})`,x=(0,le._)`(typeof ${y} == "function" ? ${O} : ${y}.test(${n}))`;return(0,le._)`${y} && ${y} !== true && ${g} === ${t} && !${x}`}}function p(){let m=d.formats[s];if(!m){b();return}if(m===!0)return;let[h,g,y]=v(m);h===t&&e.pass(O());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 v(x){let z=x instanceof RegExp?(0,le.regexpCode)(x):c.code.formats?(0,le._)`${c.code.formats}${(0,le.getProperty)(s)}`:void 0,j=r.scopeValue("formats",{key:s,ref:x,code:z});return typeof x=="object"&&!(x instanceof RegExp)?[x.type||"string",x.validate,(0,le._)`${j}.validate`]:["string",x,j]}function O(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!l.$async)throw new Error("async format in sync schema");return(0,le._)`await ${y}(${n})`}return typeof g=="function"?(0,le._)`${y}(${n})`:(0,le._)`${y}.test(${n})`}}}};ml.default=vR});var Uy=w(hl=>{"use strict";Object.defineProperty(hl,"__esModule",{value:!0});var wR=jy(),kR=[wR.default];hl.default=kR});var Fy=w(Xr=>{"use strict";Object.defineProperty(Xr,"__esModule",{value:!0});Xr.contentVocabulary=Xr.metadataVocabulary=void 0;Xr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Xr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Zy=w(gl=>{"use strict";Object.defineProperty(gl,"__esModule",{value:!0});var xR=Y_(),PR=ly(),TR=Ly(),$R=Uy(),qy=Fy(),RR=[xR.default,PR.default,(0,TR.default)(),$R.default,qy.metadataVocabulary,qy.contentVocabulary];gl.default=RR});var Hy=w(Si=>{"use strict";Object.defineProperty(Si,"__esModule",{value:!0});Si.DiscrError=void 0;var Wy;(function(e){e.Tag="tag",e.Mapping="mapping"})(Wy||(Si.DiscrError=Wy={}))});var Ky=w(yl=>{"use strict";Object.defineProperty(yl,"__esModule",{value:!0});var Qr=M(),_l=Hy(),By=ei(),AR=oo(),OR=q(),IR={message:({params:{discrError:e,tagName:t}})=>e===_l.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Qr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},CR={keyword:"discriminator",type:"object",schemaType:"object",error:IR,code(e){let{gen:t,data:r,schema:n,parentSchema:o,it:s}=e,{oneOf:i}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=t.let("valid",!1),u=t.const("tag",(0,Qr._)`${r}${(0,Qr.getProperty)(a)}`);t.if((0,Qr._)`typeof ${u} == "string"`,()=>l(),()=>e.error(!1,{discrError:_l.DiscrError.Tag,tag:u,tagName:a})),e.ok(c);function l(){let p=f();t.if(!1);for(let m in p)t.elseIf((0,Qr._)`${u} === ${m}`),t.assign(c,d(p[m]));t.else(),e.error(!1,{discrError:_l.DiscrError.Mapping,tag:u,tagName:a}),t.endIf()}function d(p){let m=t.name("valid"),h=e.subschema({keyword:"oneOf",schemaProp:p},m);return e.mergeEvaluated(h,Qr.Name),m}function f(){var p;let m={},h=y(o),g=!0;for(let O=0;O<i.length;O++){let x=i[O];if(x?.$ref&&!(0,OR.schemaHasRulesButRef)(x,s.self.RULES)){let j=x.$ref;if(x=By.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,j),x instanceof By.SchemaEnv&&(x=x.schema),x===void 0)throw new AR.default(s.opts.uriResolver,s.baseId,j)}let z=(p=x?.properties)===null||p===void 0?void 0:p[a];if(typeof z!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(h||y(x)),b(z,O)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return m;function y({required:O}){return Array.isArray(O)&&O.includes(a)}function b(O,x){if(O.const)v(O.const,x);else if(O.enum)for(let z of O.enum)v(z,x);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function v(O,x){if(typeof O!="string"||O in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[O]=x}}}};yl.default=CR});var Gy=w((pj,MR)=>{MR.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 El=w((ne,Sl)=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});ne.MissingRefError=ne.ValidationError=ne.CodeGen=ne.Name=ne.nil=ne.stringify=ne.str=ne._=ne.KeywordCxt=ne.Ajv=void 0;var zR=W_(),DR=Zy(),NR=Ky(),Vy=Gy(),LR=["/properties"],Ei="http://json-schema.org/draft-07/schema",en=class extends zR.default{_addVocabularies(){super._addVocabularies(),DR.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(NR.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(Vy,LR):Vy;this.addMetaSchema(t,Ei,!1),this.refs["http://json-schema.org/schema"]=Ei}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Ei)?Ei:void 0)}};ne.Ajv=en;Sl.exports=ne=en;Sl.exports.Ajv=en;Object.defineProperty(ne,"__esModule",{value:!0});ne.default=en;var jR=no();Object.defineProperty(ne,"KeywordCxt",{enumerable:!0,get:function(){return jR.KeywordCxt}});var tn=M();Object.defineProperty(ne,"_",{enumerable:!0,get:function(){return tn._}});Object.defineProperty(ne,"str",{enumerable:!0,get:function(){return tn.str}});Object.defineProperty(ne,"stringify",{enumerable:!0,get:function(){return tn.stringify}});Object.defineProperty(ne,"nil",{enumerable:!0,get:function(){return tn.nil}});Object.defineProperty(ne,"Name",{enumerable:!0,get:function(){return tn.Name}});Object.defineProperty(ne,"CodeGen",{enumerable:!0,get:function(){return tn.CodeGen}});var UR=Xs();Object.defineProperty(ne,"ValidationError",{enumerable:!0,get:function(){return UR.default}});var FR=oo();Object.defineProperty(ne,"MissingRefError",{enumerable:!0,get:function(){return FR.default}})});var nS=w(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.formatNames=wt.fastFormats=wt.fullFormats=void 0;function vt(e,t){return{validate:e,compare:t}}wt.fullFormats={date:vt(Qy,kl),time:vt(vl(!0),xl),"date-time":vt(Yy(!0),tS),"iso-time":vt(vl(),eS),"iso-date-time":vt(Yy(),rS),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:KR,"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:eA,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:GR,int32:{type:"number",validate:JR},int64:{type:"number",validate:XR},float:{type:"number",validate:Xy},double:{type:"number",validate:Xy},password:!0,binary:!0};wt.fastFormats={...wt.fullFormats,date:vt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,kl),time:vt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,xl),"date-time":vt(/^\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,tS),"iso-time":vt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,eS),"iso-date-time":vt(/^\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,rS),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};wt.formatNames=Object.keys(wt.fullFormats);function qR(e){return e%4===0&&(e%100!==0||e%400===0)}var ZR=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,WR=[0,31,28,31,30,31,30,31,31,30,31,30,31];function Qy(e){let t=ZR.exec(e);if(!t)return!1;let r=+t[1],n=+t[2],o=+t[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&qR(r)?29:WR[n])}function kl(e,t){if(e&&t)return e>t?1:e<t?-1:0}var bl=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function vl(e){return function(r){let n=bl.exec(r);if(!n)return!1;let o=+n[1],s=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||e&&!a)return!1;if(o<=23&&s<=59&&i<60)return!0;let d=s-l*c,f=o-u*c-(d<0?1:0);return(f===23||f===-1)&&(d===59||d===-1)&&i<61}}function xl(e,t){if(!(e&&t))return;let r=new Date("2020-01-01T"+e).valueOf(),n=new Date("2020-01-01T"+t).valueOf();if(r&&n)return r-n}function eS(e,t){if(!(e&&t))return;let r=bl.exec(e),n=bl.exec(t);if(r&&n)return e=r[1]+r[2]+r[3],t=n[1]+n[2]+n[3],e>t?1:e<t?-1:0}var wl=/t|\s/i;function Yy(e){let t=vl(e);return function(n){let o=n.split(wl);return o.length===2&&Qy(o[0])&&t(o[1])}}function tS(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}function rS(e,t){if(!(e&&t))return;let[r,n]=e.split(wl),[o,s]=t.split(wl),i=kl(r,o);if(i!==void 0)return i||xl(n,s)}var HR=/\/|:/,BR=/^(?:[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 KR(e){return HR.test(e)&&BR.test(e)}var Jy=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function GR(e){return Jy.lastIndex=0,Jy.test(e)}var VR=-(2**31),YR=2**31-1;function JR(e){return Number.isInteger(e)&&e<=YR&&e>=VR}function XR(e){return Number.isInteger(e)}function Xy(){return!0}var QR=/[^\\]\\Z/;function eA(e){if(QR.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var oS=w(rn=>{"use strict";Object.defineProperty(rn,"__esModule",{value:!0});rn.formatLimitDefinition=void 0;var tA=El(),mt=M(),er=mt.operators,bi={formatMaximum:{okStr:"<=",ok:er.LTE,fail:er.GT},formatMinimum:{okStr:">=",ok:er.GTE,fail:er.LT},formatExclusiveMaximum:{okStr:"<",ok:er.LT,fail:er.GTE},formatExclusiveMinimum:{okStr:">",ok:er.GT,fail:er.LTE}},rA={message:({keyword:e,schemaCode:t})=>(0,mt.str)`should be ${bi[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,mt._)`{comparison: ${bi[e].okStr}, limit: ${t}}`};rn.formatLimitDefinition={keyword:Object.keys(bi),type:"string",schemaType:"string",$data:!0,error:rA,code(e){let{gen:t,data:r,schemaCode:n,keyword:o,it:s}=e,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new tA.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let f=t.scopeValue("formats",{ref:a.formats,code:i.code.formats}),p=t.const("fmt",(0,mt._)`${f}[${c.schemaCode}]`);e.fail$data((0,mt.or)((0,mt._)`typeof ${p} != "object"`,(0,mt._)`${p} instanceof RegExp`,(0,mt._)`typeof ${p}.compare != "function"`,d(p)))}function l(){let f=c.schema,p=a.formats[f];if(!p||p===!0)return;if(typeof p!="object"||p instanceof RegExp||typeof p.compare!="function")throw new Error(`"${o}": format "${f}" does not define "compare" function`);let m=t.scopeValue("formats",{key:f,ref:p,code:i.code.formats?(0,mt._)`${i.code.formats}${(0,mt.getProperty)(f)}`:void 0});e.fail$data(d(m))}function d(f){return(0,mt._)`${f}.compare(${r}, ${n}) ${bi[o].fail} 0`}},dependencies:["format"]};var nA=e=>(e.addKeyword(rn.formatLimitDefinition),e);rn.default=nA});var cS=w((Eo,aS)=>{"use strict";Object.defineProperty(Eo,"__esModule",{value:!0});var nn=nS(),oA=oS(),Pl=M(),sS=new Pl.Name("fullFormats"),sA=new Pl.Name("fastFormats"),Tl=(e,t={keywords:!0})=>{if(Array.isArray(t))return iS(e,t,nn.fullFormats,sS),e;let[r,n]=t.mode==="fast"?[nn.fastFormats,sA]:[nn.fullFormats,sS],o=t.formats||nn.formatNames;return iS(e,o,r,n),t.keywords&&(0,oA.default)(e),e};Tl.get=(e,t="full")=>{let n=(t==="fast"?nn.fastFormats:nn.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function iS(e,t,r,n){var o,s;(o=(s=e.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,Pl._)`require("ajv-formats/dist/formats").${n}`);for(let i of t)e.addFormat(i,r[i])}aS.exports=Eo=Tl;Object.defineProperty(Eo,"__esModule",{value:!0});Eo.default=Tl});X();var R={};md(R,{BIGINT_FORMAT_RANGES:()=>Uo,CONSTANT_CATCH:()=>Id,Class:()=>ua,NUMBER_FORMAT_RANGES:()=>mn,aborted:()=>at,allowsEval:()=>ma,assert:()=>YE,assertEqual:()=>HE,assertIs:()=>GE,assertNever:()=>VE,assertNotEqual:()=>BE,assignProp:()=>We,attachSchema:()=>qo,base64ToUint8Array:()=>Ad,base64urlToUint8Array:()=>hb,cached:()=>Ar,captureStackTrace:()=>Lo,cleanEnum:()=>mb,cleanRegex:()=>pn,clone:()=>it,cloneDef:()=>QE,codePointLength:()=>hn,constantCatch:()=>Cd,createTransparentProxy:()=>sb,defineLazy:()=>wd,defineLazyInternal:()=>W,derived:()=>Sb,esc:()=>fa,escapeRegex:()=>Tt,explicitlyAborted:()=>_a,extend:()=>cb,finalizeIssue:()=>ct,floatSafeRemainder:()=>da,getElementAtPath:()=>eb,getEnumValues:()=>$r,getLengthableOrigin:()=>gn,getParsedType:()=>ob,getSizableOrigin:()=>Rd,hexToUint8Array:()=>_b,hide:()=>Zo,installLazyProp:()=>wb,isObject:()=>ar,isPlainObject:()=>qt,issue:()=>Ir,joinValues:()=>No,jsonStringifyReplacer:()=>Rr,members:()=>Sa,merge:()=>lb,mergeDefs:()=>Pt,normalizeParams:()=>$,nullish:()=>la,numKeys:()=>nb,objectClone:()=>JE,omit:()=>ab,optionalKeys:()=>ga,own:()=>Ft,parsedType:()=>ya,partial:()=>db,pick:()=>ib,prefixIssues:()=>$t,primitiveTypes:()=>Td,promiseAllObject:()=>tb,propertyKeyTypes:()=>ha,randomString:()=>rb,rawShape:()=>Or,required:()=>fb,safeExtend:()=>ub,shallowClone:()=>Pd,slugify:()=>pa,stringifyPrimitive:()=>jo,toZod:()=>KE,uint8ArrayToBase64:()=>Od,uint8ArrayToBase64url:()=>gb,uint8ArrayToHex:()=>yb,unwrapMessage:()=>Tr});function HE(e){return e}function BE(e){return e}function KE(){return e=>e}function GE(e){}function VE(e){throw new Error("Unexpected value in exhaustive check")}function YE(e){}function $r(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function No(e,t="|"){return e.map(r=>jo(r)).join(t)}function Rr(e,t){return typeof t=="bigint"?t.toString():t}var ca=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function Ar(e){return new ca(e)}function la(e){return e==null}function pn(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function da(e,t){let r=e/t,n=Math.round(r),o=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}var vd=Symbol("evaluating");function wd(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==vd)return n===void 0&&(n=vd,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function JE(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function We(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Or(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function xt(e){return Or(e._zod.def)??e._zod.def.shape}function kd(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return We(this,t,n),n},enumerable:!0,configurable:!0})}function xd(e,t,r){t in e?We(e,t,r):e[t]=r}function ir(e,t,r,n){let o=xt(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(o,s);i.enumerable&&(i.get?kd(e,s,()=>{let a=t._zod.def.shape[s];return n?n(a,s):a}):xd(e,s,n?n(i.value,s):i.value))}}function XE(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);n.enumerable&&(n.get?kd(e,r,()=>t[r]):xd(e,r,n.value))}}function Pt(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function QE(e){return Pt(e._zod.def)}function eb(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function tb(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<t.length;s++)o[t[s]]=n[s];return o})}function rb(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function fa(e){return JSON.stringify(e)}function pa(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Lo="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ar(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var ma=Ar(()=>{if(ze.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function qt(e){if(ar(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(ar(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Pd(e){return qt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function nb(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var ob=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},ha=new Set(["string","number","symbol"]),Td=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Tt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function it(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function $(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function sb(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,s){return t??(t=e()),Reflect.set(t,n,o,s)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}function jo(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function ga(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var mn={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]},Uo={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function ib(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s={};return ir(s,e,Fo(e,t)),it(e,Pt(r,{shape:s,checks:[]}))}function Fo(e,t){let r=xt(e),n=[];for(let o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,o)?.enumerable)throw new Error(`Unrecognized key: "${String(o)}"`);t[o]&&n.push(o)}return n}function ab(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(Fo(e,t)),i={};return ir(i,e,Reflect.ownKeys(xt(e)).filter(a=>!s.has(a))),it(e,Pt(r,{shape:i,checks:[]}))}function cb(e,t){if(!qt(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=xt(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return it(e,Pt(e._zod.def,{shape:$d(e,t)}))}function $d(e,t){let r={};return ir(r,e,Reflect.ownKeys(xt(e))),XE(r,t),r}function ub(e,t){if(!qt(t))throw new Error("Invalid input to safeExtend: expected a plain object");return it(e,Pt(e._zod.def,{shape:$d(e,t)}))}function lb(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};ir(r,e,Reflect.ownKeys(xt(e))),ir(r,t,Reflect.ownKeys(xt(t)));let n=Pt(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return it(e,n)}function db(e,t,r,n="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw new Error(`.${n}() cannot be used on object schemas containing refinements`);let a=r?new Set(Fo(t,r)):void 0,c={};return ir(c,t,Reflect.ownKeys(xt(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),it(t,Pt(t._zod.def,{shape:c,checks:[]}))}function fb(e,t,r){let n=r?new Set(Fo(t,r)):void 0,o={};return ir(o,t,Reflect.ownKeys(xt(t)),(s,i)=>n&&!n.has(i)?s:new e({type:"nonoptional",innerType:s})),it(t,Pt(t._zod.def,{shape:o}))}function at(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function _a(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function $t(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Tr(e){return typeof e=="string"?e:e?.message}function qo(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function ct(e,t,r){var n;let o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(n=e).schema??(n.schema=e.inst):e.schema=e.inst);let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:Tr(e.inst?._zod.def?.error?.(e))??Tr(s?.(e))??Tr(t?.error?.(e))??Tr(r.customError?.(e))??Tr(r.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(a[c]=e[c]);return a.path??(a.path=[]),a.message=i,t?.reportInput&&(a.input=e.input),a}function Rd(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var pb=/[\uD800-\uDBFF]/;function hn(e){let t=e.length;if(!pb.test(e))return t;let r=t;for(let n=0;n<t-1;n++)(e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320&&(r--,n++);return r}function gn(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ya(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function Ir(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function mb(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Ad(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function Od(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function hb(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return Ad(t+r)}function gb(e){return Od(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function _b(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function yb(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var ua=class{constructor(...t){}};function Sa(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);n.get?Object.defineProperty(e,r,{...n,enumerable:!1}):Eb(e,r,n.value)}}function Ft(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function Zo(e,t,r){return Ft(e,t,r,!1)}function Sb(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return Ft(this,r,n(this))},set(o){Ft(this,r,o)}})}return t}function Eb(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:Ft(this,t,r.bind(this))},set(n){Ft(this,t,n)}})}function bb(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var aa,Ut=!1,vb={configurable:!0,get(){Ut=!0}};function W(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&aa!==e._zod){aa=void 0;return}aa=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,vb);let o=Ut;Ut=!1;try{let s=r(this);return Ut?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s}),Ut=Ut||o,s}catch(s){throw delete this[t],Ut=Ut||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function wb(e,t,r,n){let o=bb(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,s),s.value=r(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:s})}})}var Id="~constantCatch";function Cd(e){let t=()=>e;return t[Id]=!0,t}var Md;var Ea={value:void 0,enumerable:!1},zd="captureStackTrace"in Error?Error:null;function kb(e){let t=zd;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return zd=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function E(e,t,r,n){let o={};function s(f){this.def=f,this.constr=d,this.traits=new Set}s.prototype=o;let i=r,a=i&&new WeakSet;function c(f,p){if(f._zod){if(f._zod.traits.has(e))return}else{Ea.value=new s(p);try{Object.defineProperty(f,"_zod",Ea)}finally{Ea.value=void 0}}if(f._zod.traits.add(e),t(f,p),a){let h=Object.getPrototypeOf(f),g=f._zod.constr.prototype,y=h;for(;y&&y!==g;)y=Object.getPrototypeOf(y);let b=y??h;a.has(b)||(a.add(b),Sa(b,i))}let m=d.prototype;for(let h in m)Object.prototype.hasOwnProperty.call(m,h)&&(h in f||(f[h]=m[h].bind(f)))}let u=n?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function d(f){let p=n?.Parent?kb(l):this;c(p,f);let m=p._zod.deferred;if(m){for(let g of m)g();p._zod.deferred=void 0}let h=globalThis.__zod_globalConfig?.postProcessor;return h&&h(p),p}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:f=>n?.Parent&&f instanceof n.Parent?!0:f?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var ut=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Cr=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(Md=globalThis).__zod_globalConfig??(Md.__zod_globalConfig={});var ze=globalThis.__zod_globalConfig;function He(e){return e&&Object.assign(ze,e),ze}function xb(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Rr,2)),e.message}function Pb(e){this._zod.message=e}var Tb={get:xb,set:Pb,enumerable:!0,configurable:!0},va={value:void 0,enumerable:!1},Dd=new WeakSet([Object.prototype,Error.prototype]),Nd=(e,t)=>{e.name="$ZodError",va.value=t,Object.defineProperty(e,"issues",va),va.value=void 0,Object.defineProperty(e,"message",Tb);let r=Object.getPrototypeOf(e);Dd.has(r)||(Dd.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}}))},Ld=E("$ZodError",Nd),jd=E("$ZodError",Nd,void 0,{Parent:Error});function $b(e,t,r){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0}):e[t]=r()),e[t]}function Ud(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?$b(r,o.path[0],()=>[]).push(t(o)):n.push(t(o));return{formErrors:n,fieldErrors:r}}function Fd(e,t=r=>r.message){let r={_errors:[]},n=(o,s=[])=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>n({issues:a},[...s,...i.path]));else if(i.code==="invalid_key")n({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")n({issues:i.issues},[...s,...i.path]);else{let a=[...s,...i.path];if(a.length===0)r._errors.push(t(i));else{let c=r,u=0;for(;u<a.length;){let l=a[u],d=u===a.length-1;if(l==="_errors"){d&&c._errors.push(t(i)),u++;continue}Object.prototype.hasOwnProperty.call(c,l)||Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let f=c[l];d&&f._errors.push(t(i)),c=f,u++}}}};return n(e),r}function Wo(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Ho=e=>{let t=(r,n,o,s)=>{let i=o?{...o,async:!1}:{async:!1},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new ut;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>ct(u,i,He())));throw Lo(c,s?.callee??t),c}return a.value};return t};var Bo=e=>{let t=async(r,n,o,s)=>{let i=o?{...o,async:!0}:{async:!0},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>ct(u,i,He())));throw Lo(c,s?.callee??t),c}return a.value};return t};var _n=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new ut;return s.issues.length?qd(e,s.issues,o):{success:!0,data:s.value}},wa=_n(jd);function qd(e,t,r){let n;return{success:!1,get error(){return n||(n=new e(t.map(o=>ct(o,r,He()))),t=void 0,r=void 0),n},set error(o){n=o,t=void 0,r=void 0}}}var Ko=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?qd(e,s.issues,o):{success:!0,data:s.value}};var Ab=Symbol.for("zod.compile.invalid"),Ob=Symbol.for("zod.compile.fallback"),Go=((e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==Ab)return!0;if(n.definite===!0&&r===void 0)return!1}return Ib(e,t,r)});function Ib(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,s;if(o?(n[Ob]=!0,s=o({value:t,issues:[]},n)):s=e._zod.run({value:t,issues:[]},n),s instanceof Promise)throw new ut;return s.issues.length===0}var Vo=async(e,t,r)=>{let n=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:t,issues:[]},n);return o instanceof Promise&&(o=await o),o.issues.length===0},Zd=e=>{let t=Ho(e),r=(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(n,o,a,Wo(r,i))};return r};var Wd=e=>{let t=Ho(e),r=(n,o,s,i)=>t(n,o,s,Wo(r,i));return r};var Hd=e=>{let t=Bo(e),r=async(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(n,o,a,Wo(r,i))};return r};var Bd=e=>{let t=Bo(e),r=async(n,o,s,i)=>await t(n,o,s,Wo(r,i));return r};var Kd=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return _n(e)(t,r,o)};var Gd=e=>(t,r,n)=>_n(e)(t,r,n);var Vd=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Ko(e)(t,r,o)};var Yd=e=>async(t,r,n)=>Ko(e)(t,r,n);var Jd=/^[cC][0-9a-z]{6,}$/,Xd=/^[0-9a-z]+$/,Qd=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,ef=/^[0-9a-vA-V]{20}$/,tf=/^[A-Za-z0-9]{27}$/,rf=/^[a-zA-Z0-9_-]{21}$/;function nf(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var of=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var sf=/^([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})$/,xa=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;var af=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Cb="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function cf(){return new RegExp(Cb,"u")}var uf=/^(?:(?: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])$/,lf=/^(([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 df=/^((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])$/,ff=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,pf=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,mf=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var hf=/^https?$/,gf=/^\+[1-9]\d{6,14}$/;var _f="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function Mb(e){return new RegExp(`^${e}$`)}var yf=Mb(_f);function ka(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Sf(e){return new RegExp(`^${ka(e)}$`)}function Ef(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${ka({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${ka({precision:e.precision})}`:r;return new RegExp(`^${_f}T(?:${n})$`)}var bf=/^[\s\S]{0,}$/;var Pa=/^-?\d+$/,yn=/^-?\d+(?:\.\d+)?$/,vf=/^(?:true|false)$/i,wf=/^null$/i;var kf=/^[^A-Z]*$/,xf=/^[^a-z]*$/;var me=E("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Ta=e=>{let t=e.value;return!la(t)&&t.length!==void 0},Yo={number:"number",bigint:"bigint",object:"date"},$a=E("$ZodCheckLessThan",(e,t)=>{me.init(e,t);let r=Yo[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:Yo[typeof n.value]??r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ra=E("$ZodCheckGreaterThan",(e,t)=>{me.init(e,t);let r=Yo[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:Yo[typeof n.value]??r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Pf=E("$ZodCheckMultipleOf",(e,t)=>{me.init(e,t),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):da(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Tf=E("$ZodCheckNumberFormat",(e,t)=>{me.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=mn[t.format];e._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var $f=E("$ZodCheckMaxLength",(e,t)=>{var r;me.init(e,t),(r=e._zod.def).when??(r.when=Ta),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>t.maximum?hn(o):s)<=t.maximum)return;let a=gn(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Rf=E("$ZodCheckMinLength",(e,t)=>{var r;me.init(e,t),(r=e._zod.def).when??(r.when=Ta),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>=t.minimum&&s<t.minimum*2?hn(o):s)>=t.minimum)return;let a=gn(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Af=E("$ZodCheckLengthEquals",(e,t)=>{var r;me.init(e,t),(r=e._zod.def).when??(r.when=Ta),e._zod.check=n=>{let o=n.value,s=o.length,i=typeof o=="string"&&s>=t.length&&s<=t.length*2?hn(o):s;if(i===t.length)return;let a=gn(o),c=i>t.length;n.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),En=E("$ZodCheckStringFormat",(e,t)=>{var r,n;me.init(e,t),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Of=E("$ZodCheckRegex",(e,t)=>{En.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),If=E("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=kf),En.init(e,t)}),Cf=E("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=xf),En.init(e,t)}),Mf=E("$ZodCheckIncludes",(e,t)=>{me.init(e,t);let r=Tt(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position},}${r}`:r);t.pattern=n,e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),zf=E("$ZodCheckStartsWith",(e,t)=>{me.init(e,t);let r=new RegExp(`^${Tt(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Df=E("$ZodCheckEndsWith",(e,t)=>{me.init(e,t);let r=new RegExp(`.*${Tt(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var Nf=E("$ZodCheckOverwrite",(e,t)=>{me.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var Jo=class{constructor(t=[],r={}){this.content=[],this.indent=0,this.args=t,this.closed=r}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
|
|
22
|
+
deps: ${r}}`};var M$={keyword:"dependencies",type:"object",schemaType:"object",error:bt.error,code(e){let[t,r]=z$(e);yy(e,t),Sy(e,r)}};function z$({schema:e}){let t={},r={};for(let n in e){if(n==="__proto__")continue;let o=Array.isArray(e[n])?t:r;o[n]=e[n]}return[t,r]}function yy(e,t=e.schema){let{gen:r,data:n,it:o}=e;if(Object.keys(t).length===0)return;let s=r.let("missing");for(let i in t){let a=t[i];if(a.length===0)continue;let c=(0,So.propertyInData)(r,n,i,o.opts.ownProperties);e.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,So.checkReportMissingProp)(e,u)}):(r.if((0,el._)`${c} && (${(0,So.checkMissingProp)(e,a,s)})`),(0,So.reportMissingProp)(e,s),r.else())}}bt.validatePropertyDeps=yy;function Sy(e,t=e.schema){let{gen:r,data:n,keyword:o,it:s}=e,i=r.name("valid");for(let a in t)(0,C$.alwaysValidSchema)(s,t[a])||(r.if((0,So.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=e.subschema({keyword:o,schemaProp:a},i);e.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),e.ok(i))}bt.validateSchemaDeps=Sy;bt.default=M$});var wy=v(tl=>{"use strict";Object.defineProperty(tl,"__esModule",{value:!0});var by=M(),D$=q(),N$={message:"property name must be valid",params:({params:e})=>(0,by._)`{propertyName: ${e.propertyName}}`},L$={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:N$,code(e){let{gen:t,schema:r,data:n,it:o}=e;if((0,D$.alwaysValidSchema)(o,r))return;let s=t.name("valid");t.forIn("key",n,i=>{e.setParams({propertyName:i}),e.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),t.if((0,by.not)(s),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(s)}};tl.default=L$});var nl=v(rl=>{"use strict";Object.defineProperty(rl,"__esModule",{value:!0});var mi=et(),pt=M(),j$=Ct(),hi=q(),U$={message:"must NOT have additional properties",params:({params:e})=>(0,pt._)`{additionalProperty: ${e.additionalProperty}}`},F$={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:U$,code(e){let{gen:t,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=e;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,hi.alwaysValidSchema)(i,r))return;let u=(0,mi.allSchemaProperties)(n.properties),l=(0,mi.allSchemaProperties)(n.patternProperties);d(),e.ok((0,pt._)`${s} === ${j$.default.errors}`);function d(){t.forIn("key",o,g=>{!u.length&&!l.length?m(g):t.if(f(g),()=>m(g))})}function f(g){let y;if(u.length>8){let b=(0,hi.schemaRefOrVal)(i,n.properties,"properties");y=(0,mi.isOwnProperty)(t,b,g)}else u.length?y=(0,pt.or)(...u.map(b=>(0,pt._)`${g} === ${b}`)):y=pt.nil;return l.length&&(y=(0,pt.or)(y,...l.map(b=>(0,pt._)`${(0,mi.usePattern)(e,b)}.test(${g})`))),(0,pt.not)(y)}function p(g){t.code((0,pt._)`delete ${o}[${g}]`)}function m(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){p(g);return}if(r===!1){e.setParams({additionalProperty:g}),e.error(),a||t.break();return}if(typeof r=="object"&&!(0,hi.alwaysValidSchema)(i,r)){let y=t.name("valid");c.removeAdditional==="failing"?(h(g,y,!1),t.if((0,pt.not)(y),()=>{e.reset(),p(g)})):(h(g,y),a||t.if((0,pt.not)(y),()=>t.break()))}}function h(g,y,b){let w={keyword:"additionalProperties",dataProp:g,dataPropType:hi.Type.Str};b===!1&&Object.assign(w,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(w,y)}}};rl.default=F$});var xy=v(sl=>{"use strict";Object.defineProperty(sl,"__esModule",{value:!0});var q$=no(),vy=et(),ol=q(),ky=nl(),Z$={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&ky.default.code(new q$.KeywordCxt(s,ky.default,"additionalProperties"));let i=(0,vy.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=ol.mergeEvaluated.props(t,(0,ol.toHash)(i),s.props));let a=i.filter(d=>!(0,ol.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=t.name("valid");for(let d of a)u(d)?l(d):(t.if((0,vy.propertyInData)(t,o,d,s.opts.ownProperties)),l(d),s.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};sl.default=Z$});var Ry=v(il=>{"use strict";Object.defineProperty(il,"__esModule",{value:!0});var Py=et(),gi=M(),Ty=q(),$y=q(),H$={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:o,it:s}=e,{opts:i}=s,a=(0,Py.allSchemaProperties)(r),c=a.filter(h=>(0,Ty.alwaysValidSchema)(s,r[h]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=t.name("valid");s.props!==!0&&!(s.props instanceof gi.Name)&&(s.props=(0,$y.evaluatedPropsToName)(t,s.props));let{props:d}=s;f();function f(){for(let h of a)u&&p(h),s.allErrors?m(h):(t.var(l,!0),m(h),t.if(l))}function p(h){for(let g in u)new RegExp(h).test(g)&&(0,Ty.checkStrictMode)(s,`property ${g} matches pattern ${h} (use allowMatchingProperties)`)}function m(h){t.forIn("key",n,g=>{t.if((0,gi._)`${(0,Py.usePattern)(e,h)}.test(${g})`,()=>{let y=c.includes(h);y||e.subschema({keyword:"patternProperties",schemaProp:h,dataProp:g,dataPropType:$y.Type.Str},l),s.opts.unevaluated&&d!==!0?t.assign((0,gi._)`${d}[${g}]`,!0):!y&&!s.allErrors&&t.if((0,gi.not)(l),()=>t.break())})})}}};il.default=H$});var Ay=v(al=>{"use strict";Object.defineProperty(al,"__esModule",{value:!0});var W$=q(),B$={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,W$.alwaysValidSchema)(n,r)){e.fail();return}let o=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),e.failResult(o,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};al.default=B$});var Oy=v(cl=>{"use strict";Object.defineProperty(cl,"__esModule",{value:!0});var K$=et(),G$={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:K$.validateUnion,error:{message:"must match a schema in anyOf"}};cl.default=G$});var Iy=v(ul=>{"use strict";Object.defineProperty(ul,"__esModule",{value:!0});var _i=M(),V$=q(),Y$={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,_i._)`{passingSchemas: ${e.passing}}`},J$={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:Y$,code(e){let{gen:t,schema:r,parentSchema:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,i=t.let("valid",!1),a=t.let("passing",null),c=t.name("_valid");e.setParams({passing:a}),t.block(u),e.result(i,()=>e.reset(),()=>e.error(!0));function u(){s.forEach((l,d)=>{let f;(0,V$.alwaysValidSchema)(o,l)?t.var(c,!0):f=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&t.if((0,_i._)`${c} && ${i}`).assign(i,!1).assign(a,(0,_i._)`[${a}, ${d}]`).else(),t.if(c,()=>{t.assign(i,!0),t.assign(a,d),f&&e.mergeEvaluated(f,_i.Name)})})}}};ul.default=J$});var Cy=v(ll=>{"use strict";Object.defineProperty(ll,"__esModule",{value:!0});var X$=q(),Q$={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=t.name("valid");r.forEach((s,i)=>{if((0,X$.alwaysValidSchema)(n,s))return;let a=e.subschema({keyword:"allOf",schemaProp:i},o);e.ok(o),e.mergeEvaluated(a)})}};ll.default=Q$});var Dy=v(dl=>{"use strict";Object.defineProperty(dl,"__esModule",{value:!0});var yi=M(),zy=q(),eR={message:({params:e})=>(0,yi.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,yi._)`{failingKeyword: ${e.ifClause}}`},tR={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:eR,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,zy.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=My(n,"then"),s=My(n,"else");if(!o&&!s)return;let i=t.let("valid",!0),a=t.name("_valid");if(c(),e.reset(),o&&s){let l=t.let("ifClause");e.setParams({ifClause:l}),t.if(a,u("then",l),u("else",l))}else o?t.if(a,u("then")):t.if((0,yi.not)(a),u("else"));e.pass(i,()=>e.error(!0));function c(){let l=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(l)}function u(l,d){return()=>{let f=e.subschema({keyword:l},a);t.assign(i,a),e.mergeValidEvaluated(f,i),d?t.assign(d,(0,yi._)`${l}`):e.setParams({ifClause:l})}}}};function My(e,t){let r=e.schema[t];return r!==void 0&&!(0,zy.alwaysValidSchema)(e,r)}dl.default=tR});var Ny=v(fl=>{"use strict";Object.defineProperty(fl,"__esModule",{value:!0});var rR=q(),nR={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,rR.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};fl.default=nR});var Ly=v(pl=>{"use strict";Object.defineProperty(pl,"__esModule",{value:!0});var oR=Vu(),sR=my(),iR=Yu(),aR=gy(),cR=_y(),uR=Ey(),lR=wy(),dR=nl(),fR=xy(),pR=Ry(),mR=Ay(),hR=Oy(),gR=Iy(),_R=Cy(),yR=Dy(),SR=Ny();function ER(e=!1){let t=[mR.default,hR.default,gR.default,_R.default,yR.default,SR.default,lR.default,dR.default,uR.default,fR.default,pR.default];return e?t.push(sR.default,aR.default):t.push(oR.default,iR.default),t.push(cR.default),t}pl.default=ER});var jy=v(ml=>{"use strict";Object.defineProperty(ml,"__esModule",{value:!0});var le=M(),bR={message:({schemaCode:e})=>(0,le.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,le._)`{format: ${e}}`},wR={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:bR,code(e,t){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=e,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?f():p();function f(){let m=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),h=r.const("fDef",(0,le._)`${m}[${i}]`),g=r.let("fType"),y=r.let("format");r.if((0,le._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>r.assign(g,(0,le._)`${h}.type || "string"`).assign(y,(0,le._)`${h}.validate`),()=>r.assign(g,(0,le._)`"string"`).assign(y,h)),e.fail$data((0,le.or)(b(),w()));function b(){return c.strictSchema===!1?le.nil:(0,le._)`${i} && !${y}`}function w(){let O=l.$async?(0,le._)`(${h}.async ? await ${y}(${n}) : ${y}(${n}))`:(0,le._)`${y}(${n})`,x=(0,le._)`(typeof ${y} == "function" ? ${O} : ${y}.test(${n}))`;return(0,le._)`${y} && ${y} !== true && ${g} === ${t} && !${x}`}}function p(){let m=d.formats[s];if(!m){b();return}if(m===!0)return;let[h,g,y]=w(m);h===t&&e.pass(O());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 z=x instanceof RegExp?(0,le.regexpCode)(x):c.code.formats?(0,le._)`${c.code.formats}${(0,le.getProperty)(s)}`:void 0,j=r.scopeValue("formats",{key:s,ref:x,code:z});return typeof x=="object"&&!(x instanceof RegExp)?[x.type||"string",x.validate,(0,le._)`${j}.validate`]:["string",x,j]}function O(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!l.$async)throw new Error("async format in sync schema");return(0,le._)`await ${y}(${n})`}return typeof g=="function"?(0,le._)`${y}(${n})`:(0,le._)`${y}.test(${n})`}}}};ml.default=wR});var Uy=v(hl=>{"use strict";Object.defineProperty(hl,"__esModule",{value:!0});var vR=jy(),kR=[vR.default];hl.default=kR});var Fy=v(Qr=>{"use strict";Object.defineProperty(Qr,"__esModule",{value:!0});Qr.contentVocabulary=Qr.metadataVocabulary=void 0;Qr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Qr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Zy=v(gl=>{"use strict";Object.defineProperty(gl,"__esModule",{value:!0});var xR=Y_(),PR=ly(),TR=Ly(),$R=Uy(),qy=Fy(),RR=[xR.default,PR.default,(0,TR.default)(),$R.default,qy.metadataVocabulary,qy.contentVocabulary];gl.default=RR});var Wy=v(Si=>{"use strict";Object.defineProperty(Si,"__esModule",{value:!0});Si.DiscrError=void 0;var Hy;(function(e){e.Tag="tag",e.Mapping="mapping"})(Hy||(Si.DiscrError=Hy={}))});var Ky=v(yl=>{"use strict";Object.defineProperty(yl,"__esModule",{value:!0});var en=M(),_l=Wy(),By=ei(),AR=oo(),OR=q(),IR={message:({params:{discrError:e,tagName:t}})=>e===_l.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,en._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},CR={keyword:"discriminator",type:"object",schemaType:"object",error:IR,code(e){let{gen:t,data:r,schema:n,parentSchema:o,it:s}=e,{oneOf:i}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=t.let("valid",!1),u=t.const("tag",(0,en._)`${r}${(0,en.getProperty)(a)}`);t.if((0,en._)`typeof ${u} == "string"`,()=>l(),()=>e.error(!1,{discrError:_l.DiscrError.Tag,tag:u,tagName:a})),e.ok(c);function l(){let p=f();t.if(!1);for(let m in p)t.elseIf((0,en._)`${u} === ${m}`),t.assign(c,d(p[m]));t.else(),e.error(!1,{discrError:_l.DiscrError.Mapping,tag:u,tagName:a}),t.endIf()}function d(p){let m=t.name("valid"),h=e.subschema({keyword:"oneOf",schemaProp:p},m);return e.mergeEvaluated(h,en.Name),m}function f(){var p;let m={},h=y(o),g=!0;for(let O=0;O<i.length;O++){let x=i[O];if(x?.$ref&&!(0,OR.schemaHasRulesButRef)(x,s.self.RULES)){let j=x.$ref;if(x=By.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,j),x instanceof By.SchemaEnv&&(x=x.schema),x===void 0)throw new AR.default(s.opts.uriResolver,s.baseId,j)}let z=(p=x?.properties)===null||p===void 0?void 0:p[a];if(typeof z!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(h||y(x)),b(z,O)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return m;function y({required:O}){return Array.isArray(O)&&O.includes(a)}function b(O,x){if(O.const)w(O.const,x);else if(O.enum)for(let z of O.enum)w(z,x);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function w(O,x){if(typeof O!="string"||O in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[O]=x}}}};yl.default=CR});var Gy=v((gj,MR)=>{MR.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 El=v((ne,Sl)=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});ne.MissingRefError=ne.ValidationError=ne.CodeGen=ne.Name=ne.nil=ne.stringify=ne.str=ne._=ne.KeywordCxt=ne.Ajv=void 0;var zR=H_(),DR=Zy(),NR=Ky(),Vy=Gy(),LR=["/properties"],Ei="http://json-schema.org/draft-07/schema",tn=class extends zR.default{_addVocabularies(){super._addVocabularies(),DR.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(NR.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(Vy,LR):Vy;this.addMetaSchema(t,Ei,!1),this.refs["http://json-schema.org/schema"]=Ei}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Ei)?Ei:void 0)}};ne.Ajv=tn;Sl.exports=ne=tn;Sl.exports.Ajv=tn;Object.defineProperty(ne,"__esModule",{value:!0});ne.default=tn;var jR=no();Object.defineProperty(ne,"KeywordCxt",{enumerable:!0,get:function(){return jR.KeywordCxt}});var rn=M();Object.defineProperty(ne,"_",{enumerable:!0,get:function(){return rn._}});Object.defineProperty(ne,"str",{enumerable:!0,get:function(){return rn.str}});Object.defineProperty(ne,"stringify",{enumerable:!0,get:function(){return rn.stringify}});Object.defineProperty(ne,"nil",{enumerable:!0,get:function(){return rn.nil}});Object.defineProperty(ne,"Name",{enumerable:!0,get:function(){return rn.Name}});Object.defineProperty(ne,"CodeGen",{enumerable:!0,get:function(){return rn.CodeGen}});var UR=Xs();Object.defineProperty(ne,"ValidationError",{enumerable:!0,get:function(){return UR.default}});var FR=oo();Object.defineProperty(ne,"MissingRefError",{enumerable:!0,get:function(){return FR.default}})});var nS=v(vt=>{"use strict";Object.defineProperty(vt,"__esModule",{value:!0});vt.formatNames=vt.fastFormats=vt.fullFormats=void 0;function wt(e,t){return{validate:e,compare:t}}vt.fullFormats={date:wt(Qy,kl),time:wt(wl(!0),xl),"date-time":wt(Yy(!0),tS),"iso-time":wt(wl(),eS),"iso-date-time":wt(Yy(),rS),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:KR,"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:eA,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:GR,int32:{type:"number",validate:JR},int64:{type:"number",validate:XR},float:{type:"number",validate:Xy},double:{type:"number",validate:Xy},password:!0,binary:!0};vt.fastFormats={...vt.fullFormats,date:wt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,kl),time:wt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,xl),"date-time":wt(/^\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,tS),"iso-time":wt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,eS),"iso-date-time":wt(/^\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,rS),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};vt.formatNames=Object.keys(vt.fullFormats);function qR(e){return e%4===0&&(e%100!==0||e%400===0)}var ZR=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,HR=[0,31,28,31,30,31,30,31,31,30,31,30,31];function Qy(e){let t=ZR.exec(e);if(!t)return!1;let r=+t[1],n=+t[2],o=+t[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&qR(r)?29:HR[n])}function kl(e,t){if(e&&t)return e>t?1:e<t?-1:0}var bl=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function wl(e){return function(r){let n=bl.exec(r);if(!n)return!1;let o=+n[1],s=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||e&&!a)return!1;if(o<=23&&s<=59&&i<60)return!0;let d=s-l*c,f=o-u*c-(d<0?1:0);return(f===23||f===-1)&&(d===59||d===-1)&&i<61}}function xl(e,t){if(!(e&&t))return;let r=new Date("2020-01-01T"+e).valueOf(),n=new Date("2020-01-01T"+t).valueOf();if(r&&n)return r-n}function eS(e,t){if(!(e&&t))return;let r=bl.exec(e),n=bl.exec(t);if(r&&n)return e=r[1]+r[2]+r[3],t=n[1]+n[2]+n[3],e>t?1:e<t?-1:0}var vl=/t|\s/i;function Yy(e){let t=wl(e);return function(n){let o=n.split(vl);return o.length===2&&Qy(o[0])&&t(o[1])}}function tS(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}function rS(e,t){if(!(e&&t))return;let[r,n]=e.split(vl),[o,s]=t.split(vl),i=kl(r,o);if(i!==void 0)return i||xl(n,s)}var WR=/\/|:/,BR=/^(?:[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 KR(e){return WR.test(e)&&BR.test(e)}var Jy=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function GR(e){return Jy.lastIndex=0,Jy.test(e)}var VR=-(2**31),YR=2**31-1;function JR(e){return Number.isInteger(e)&&e<=YR&&e>=VR}function XR(e){return Number.isInteger(e)}function Xy(){return!0}var QR=/[^\\]\\Z/;function eA(e){if(QR.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var oS=v(nn=>{"use strict";Object.defineProperty(nn,"__esModule",{value:!0});nn.formatLimitDefinition=void 0;var tA=El(),mt=M(),er=mt.operators,bi={formatMaximum:{okStr:"<=",ok:er.LTE,fail:er.GT},formatMinimum:{okStr:">=",ok:er.GTE,fail:er.LT},formatExclusiveMaximum:{okStr:"<",ok:er.LT,fail:er.GTE},formatExclusiveMinimum:{okStr:">",ok:er.GT,fail:er.LTE}},rA={message:({keyword:e,schemaCode:t})=>(0,mt.str)`should be ${bi[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,mt._)`{comparison: ${bi[e].okStr}, limit: ${t}}`};nn.formatLimitDefinition={keyword:Object.keys(bi),type:"string",schemaType:"string",$data:!0,error:rA,code(e){let{gen:t,data:r,schemaCode:n,keyword:o,it:s}=e,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new tA.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let f=t.scopeValue("formats",{ref:a.formats,code:i.code.formats}),p=t.const("fmt",(0,mt._)`${f}[${c.schemaCode}]`);e.fail$data((0,mt.or)((0,mt._)`typeof ${p} != "object"`,(0,mt._)`${p} instanceof RegExp`,(0,mt._)`typeof ${p}.compare != "function"`,d(p)))}function l(){let f=c.schema,p=a.formats[f];if(!p||p===!0)return;if(typeof p!="object"||p instanceof RegExp||typeof p.compare!="function")throw new Error(`"${o}": format "${f}" does not define "compare" function`);let m=t.scopeValue("formats",{key:f,ref:p,code:i.code.formats?(0,mt._)`${i.code.formats}${(0,mt.getProperty)(f)}`:void 0});e.fail$data(d(m))}function d(f){return(0,mt._)`${f}.compare(${r}, ${n}) ${bi[o].fail} 0`}},dependencies:["format"]};var nA=e=>(e.addKeyword(nn.formatLimitDefinition),e);nn.default=nA});var cS=v((Eo,aS)=>{"use strict";Object.defineProperty(Eo,"__esModule",{value:!0});var on=nS(),oA=oS(),Pl=M(),sS=new Pl.Name("fullFormats"),sA=new Pl.Name("fastFormats"),Tl=(e,t={keywords:!0})=>{if(Array.isArray(t))return iS(e,t,on.fullFormats,sS),e;let[r,n]=t.mode==="fast"?[on.fastFormats,sA]:[on.fullFormats,sS],o=t.formats||on.formatNames;return iS(e,o,r,n),t.keywords&&(0,oA.default)(e),e};Tl.get=(e,t="full")=>{let n=(t==="fast"?on.fastFormats:on.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function iS(e,t,r,n){var o,s;(o=(s=e.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,Pl._)`require("ajv-formats/dist/formats").${n}`);for(let i of t)e.addFormat(i,r[i])}aS.exports=Eo=Tl;Object.defineProperty(Eo,"__esModule",{value:!0});Eo.default=Tl});X();var R={};md(R,{BIGINT_FORMAT_RANGES:()=>Uo,CONSTANT_CATCH:()=>Id,Class:()=>ua,NUMBER_FORMAT_RANGES:()=>mn,aborted:()=>at,allowsEval:()=>ma,assert:()=>YE,assertEqual:()=>WE,assertIs:()=>GE,assertNever:()=>VE,assertNotEqual:()=>BE,assignProp:()=>He,attachSchema:()=>qo,base64ToUint8Array:()=>Ad,base64urlToUint8Array:()=>hb,cached:()=>Or,captureStackTrace:()=>Lo,cleanEnum:()=>mb,cleanRegex:()=>pn,clone:()=>it,cloneDef:()=>QE,codePointLength:()=>hn,constantCatch:()=>Cd,createTransparentProxy:()=>sb,defineLazy:()=>vd,defineLazyInternal:()=>H,derived:()=>Sb,esc:()=>fa,escapeRegex:()=>Tt,explicitlyAborted:()=>_a,extend:()=>cb,finalizeIssue:()=>ct,floatSafeRemainder:()=>da,getElementAtPath:()=>eb,getEnumValues:()=>Rr,getLengthableOrigin:()=>gn,getParsedType:()=>ob,getSizableOrigin:()=>Rd,hexToUint8Array:()=>_b,hide:()=>Zo,installLazyProp:()=>vb,isObject:()=>ar,isPlainObject:()=>qt,issue:()=>Cr,joinValues:()=>No,jsonStringifyReplacer:()=>Ar,members:()=>Sa,merge:()=>lb,mergeDefs:()=>Pt,normalizeParams:()=>$,nullish:()=>la,numKeys:()=>nb,objectClone:()=>JE,omit:()=>ab,optionalKeys:()=>ga,own:()=>Ft,parsedType:()=>ya,partial:()=>db,pick:()=>ib,prefixIssues:()=>$t,primitiveTypes:()=>Td,promiseAllObject:()=>tb,propertyKeyTypes:()=>ha,randomString:()=>rb,rawShape:()=>Ir,required:()=>fb,safeExtend:()=>ub,shallowClone:()=>Pd,slugify:()=>pa,stringifyPrimitive:()=>jo,toZod:()=>KE,uint8ArrayToBase64:()=>Od,uint8ArrayToBase64url:()=>gb,uint8ArrayToHex:()=>yb,unwrapMessage:()=>$r});function WE(e){return e}function BE(e){return e}function KE(){return e=>e}function GE(e){}function VE(e){throw new Error("Unexpected value in exhaustive check")}function YE(e){}function Rr(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function No(e,t="|"){return e.map(r=>jo(r)).join(t)}function Ar(e,t){return typeof t=="bigint"?t.toString():t}var ca=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function Or(e){return new ca(e)}function la(e){return e==null}function pn(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function da(e,t){let r=e/t,n=Math.round(r),o=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}var wd=Symbol("evaluating");function vd(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==wd)return n===void 0&&(n=wd,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function JE(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function He(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Ir(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function xt(e){return Ir(e._zod.def)??e._zod.def.shape}function kd(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return He(this,t,n),n},enumerable:!0,configurable:!0})}function xd(e,t,r){t in e?He(e,t,r):e[t]=r}function ir(e,t,r,n){let o=xt(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(o,s);i.enumerable&&(i.get?kd(e,s,()=>{let a=t._zod.def.shape[s];return n?n(a,s):a}):xd(e,s,n?n(i.value,s):i.value))}}function XE(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);n.enumerable&&(n.get?kd(e,r,()=>t[r]):xd(e,r,n.value))}}function Pt(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function QE(e){return Pt(e._zod.def)}function eb(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function tb(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<t.length;s++)o[t[s]]=n[s];return o})}function rb(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function fa(e){return JSON.stringify(e)}function pa(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Lo="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ar(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var ma=Or(()=>{if(ze.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function qt(e){if(ar(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(ar(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Pd(e){return qt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function nb(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var ob=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},ha=new Set(["string","number","symbol"]),Td=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Tt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function it(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function $(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function sb(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,s){return t??(t=e()),Reflect.set(t,n,o,s)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}function jo(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function ga(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var mn={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]},Uo={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function ib(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s={};return ir(s,e,Fo(e,t)),it(e,Pt(r,{shape:s,checks:[]}))}function Fo(e,t){let r=xt(e),n=[];for(let o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,o)?.enumerable)throw new Error(`Unrecognized key: "${String(o)}"`);t[o]&&n.push(o)}return n}function ab(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(Fo(e,t)),i={};return ir(i,e,Reflect.ownKeys(xt(e)).filter(a=>!s.has(a))),it(e,Pt(r,{shape:i,checks:[]}))}function cb(e,t){if(!qt(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=xt(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return it(e,Pt(e._zod.def,{shape:$d(e,t)}))}function $d(e,t){let r={};return ir(r,e,Reflect.ownKeys(xt(e))),XE(r,t),r}function ub(e,t){if(!qt(t))throw new Error("Invalid input to safeExtend: expected a plain object");return it(e,Pt(e._zod.def,{shape:$d(e,t)}))}function lb(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};ir(r,e,Reflect.ownKeys(xt(e))),ir(r,t,Reflect.ownKeys(xt(t)));let n=Pt(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return it(e,n)}function db(e,t,r,n="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw new Error(`.${n}() cannot be used on object schemas containing refinements`);let a=r?new Set(Fo(t,r)):void 0,c={};return ir(c,t,Reflect.ownKeys(xt(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),it(t,Pt(t._zod.def,{shape:c,checks:[]}))}function fb(e,t,r){let n=r?new Set(Fo(t,r)):void 0,o={};return ir(o,t,Reflect.ownKeys(xt(t)),(s,i)=>n&&!n.has(i)?s:new e({type:"nonoptional",innerType:s})),it(t,Pt(t._zod.def,{shape:o}))}function at(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function _a(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function $t(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function $r(e){return typeof e=="string"?e:e?.message}function qo(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function ct(e,t,r){var n;let o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(n=e).schema??(n.schema=e.inst):e.schema=e.inst);let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:$r(e.inst?._zod.def?.error?.(e))??$r(s?.(e))??$r(t?.error?.(e))??$r(r.customError?.(e))??$r(r.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(a[c]=e[c]);return a.path??(a.path=[]),a.message=i,t?.reportInput&&(a.input=e.input),a}function Rd(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var pb=/[\uD800-\uDBFF]/;function hn(e){let t=e.length;if(!pb.test(e))return t;let r=t;for(let n=0;n<t-1;n++)(e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320&&(r--,n++);return r}function gn(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ya(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function Cr(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function mb(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Ad(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function Od(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function hb(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return Ad(t+r)}function gb(e){return Od(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function _b(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function yb(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var ua=class{constructor(...t){}};function Sa(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);n.get?Object.defineProperty(e,r,{...n,enumerable:!1}):Eb(e,r,n.value)}}function Ft(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function Zo(e,t,r){return Ft(e,t,r,!1)}function Sb(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return Ft(this,r,n(this))},set(o){Ft(this,r,o)}})}return t}function Eb(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:Ft(this,t,r.bind(this))},set(n){Ft(this,t,n)}})}function bb(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var aa,Ut=!1,wb={configurable:!0,get(){Ut=!0}};function H(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&aa!==e._zod){aa=void 0;return}aa=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,wb);let o=Ut;Ut=!1;try{let s=r(this);return Ut?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s}),Ut=Ut||o,s}catch(s){throw delete this[t],Ut=Ut||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function vb(e,t,r,n){let o=bb(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,s),s.value=r(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:s})}})}var Id="~constantCatch";function Cd(e){let t=()=>e;return t[Id]=!0,t}var Md;var Ea={value:void 0,enumerable:!1},zd="captureStackTrace"in Error?Error:null;function kb(e){let t=zd;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return zd=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function E(e,t,r,n){let o={};function s(f){this.def=f,this.constr=d,this.traits=new Set}s.prototype=o;let i=r,a=i&&new WeakSet;function c(f,p){if(f._zod){if(f._zod.traits.has(e))return}else{Ea.value=new s(p);try{Object.defineProperty(f,"_zod",Ea)}finally{Ea.value=void 0}}if(f._zod.traits.add(e),t(f,p),a){let h=Object.getPrototypeOf(f),g=f._zod.constr.prototype,y=h;for(;y&&y!==g;)y=Object.getPrototypeOf(y);let b=y??h;a.has(b)||(a.add(b),Sa(b,i))}let m=d.prototype;for(let h in m)Object.prototype.hasOwnProperty.call(m,h)&&(h in f||(f[h]=m[h].bind(f)))}let u=n?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function d(f){let p=n?.Parent?kb(l):this;c(p,f);let m=p._zod.deferred;if(m){for(let g of m)g();p._zod.deferred=void 0}let h=globalThis.__zod_globalConfig?.postProcessor;return h&&h(p),p}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:f=>n?.Parent&&f instanceof n.Parent?!0:f?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var ut=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Mr=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(Md=globalThis).__zod_globalConfig??(Md.__zod_globalConfig={});var ze=globalThis.__zod_globalConfig;function We(e){return e&&Object.assign(ze,e),ze}function xb(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Ar,2)),e.message}function Pb(e){this._zod.message=e}var Tb={get:xb,set:Pb,enumerable:!0,configurable:!0},wa={value:void 0,enumerable:!1},Dd=new WeakSet([Object.prototype,Error.prototype]),Nd=(e,t)=>{e.name="$ZodError",wa.value=t,Object.defineProperty(e,"issues",wa),wa.value=void 0,Object.defineProperty(e,"message",Tb);let r=Object.getPrototypeOf(e);Dd.has(r)||(Dd.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}}))},Ld=E("$ZodError",Nd),jd=E("$ZodError",Nd,void 0,{Parent:Error});function $b(e,t,r){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0}):e[t]=r()),e[t]}function Ud(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?$b(r,o.path[0],()=>[]).push(t(o)):n.push(t(o));return{formErrors:n,fieldErrors:r}}function Fd(e,t=r=>r.message){let r={_errors:[]},n=(o,s=[])=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>n({issues:a},[...s,...i.path]));else if(i.code==="invalid_key")n({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")n({issues:i.issues},[...s,...i.path]);else{let a=[...s,...i.path];if(a.length===0)r._errors.push(t(i));else{let c=r,u=0;for(;u<a.length;){let l=a[u],d=u===a.length-1;if(l==="_errors"){d&&c._errors.push(t(i)),u++;continue}Object.prototype.hasOwnProperty.call(c,l)||Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let f=c[l];d&&f._errors.push(t(i)),c=f,u++}}}};return n(e),r}function Ho(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Wo=e=>{let t=(r,n,o,s)=>{let i=o?{...o,async:!1}:{async:!1},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new ut;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>ct(u,i,We())));throw Lo(c,s?.callee??t),c}return a.value};return t};var Bo=e=>{let t=async(r,n,o,s)=>{let i=o?{...o,async:!0}:{async:!0},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>ct(u,i,We())));throw Lo(c,s?.callee??t),c}return a.value};return t};var _n=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new ut;return s.issues.length?qd(e,s.issues,o):{success:!0,data:s.value}},va=_n(jd);function qd(e,t,r){let n;return{success:!1,get error(){return n||(n=new e(t.map(o=>ct(o,r,We()))),t=void 0,r=void 0),n},set error(o){n=o,t=void 0,r=void 0}}}var Ko=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?qd(e,s.issues,o):{success:!0,data:s.value}};var Ab=Symbol.for("zod.compile.invalid"),Ob=Symbol.for("zod.compile.fallback"),Go=((e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==Ab)return!0;if(n.definite===!0&&r===void 0)return!1}return Ib(e,t,r)});function Ib(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,s;if(o?(n[Ob]=!0,s=o({value:t,issues:[]},n)):s=e._zod.run({value:t,issues:[]},n),s instanceof Promise)throw new ut;return s.issues.length===0}var Vo=async(e,t,r)=>{let n=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:t,issues:[]},n);return o instanceof Promise&&(o=await o),o.issues.length===0},Zd=e=>{let t=Wo(e),r=(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(n,o,a,Ho(r,i))};return r};var Hd=e=>{let t=Wo(e),r=(n,o,s,i)=>t(n,o,s,Ho(r,i));return r};var Wd=e=>{let t=Bo(e),r=async(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(n,o,a,Ho(r,i))};return r};var Bd=e=>{let t=Bo(e),r=async(n,o,s,i)=>await t(n,o,s,Ho(r,i));return r};var Kd=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return _n(e)(t,r,o)};var Gd=e=>(t,r,n)=>_n(e)(t,r,n);var Vd=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Ko(e)(t,r,o)};var Yd=e=>async(t,r,n)=>Ko(e)(t,r,n);var Jd=/^[cC][0-9a-z]{6,}$/,Xd=/^[0-9a-z]+$/,Qd=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,ef=/^[0-9a-vA-V]{20}$/,tf=/^[A-Za-z0-9]{27}$/,rf=/^[a-zA-Z0-9_-]{21}$/;function nf(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var of=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var sf=/^([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})$/,xa=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;var af=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Cb="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function cf(){return new RegExp(Cb,"u")}var uf=/^(?:(?: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])$/,lf=/^(([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 df=/^((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])$/,ff=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,pf=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,mf=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var hf=/^https?$/,gf=/^\+[1-9]\d{6,14}$/;var _f="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function Mb(e){return new RegExp(`^${e}$`)}var yf=Mb(_f);function ka(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Sf(e){return new RegExp(`^${ka(e)}$`)}function Ef(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${ka({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${ka({precision:e.precision})}`:r;return new RegExp(`^${_f}T(?:${n})$`)}var bf=/^[\s\S]{0,}$/;var Pa=/^-?\d+$/,yn=/^-?\d+(?:\.\d+)?$/,wf=/^(?:true|false)$/i,vf=/^null$/i;var kf=/^[^A-Z]*$/,xf=/^[^a-z]*$/;var me=E("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Ta=e=>{let t=e.value;return!la(t)&&t.length!==void 0},Yo={number:"number",bigint:"bigint",object:"date"},$a=E("$ZodCheckLessThan",(e,t)=>{me.init(e,t);let r=Yo[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:Yo[typeof n.value]??r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ra=E("$ZodCheckGreaterThan",(e,t)=>{me.init(e,t);let r=Yo[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:Yo[typeof n.value]??r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Pf=E("$ZodCheckMultipleOf",(e,t)=>{me.init(e,t),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):da(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Tf=E("$ZodCheckNumberFormat",(e,t)=>{me.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=mn[t.format];e._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var $f=E("$ZodCheckMaxLength",(e,t)=>{var r;me.init(e,t),(r=e._zod.def).when??(r.when=Ta),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>t.maximum?hn(o):s)<=t.maximum)return;let a=gn(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Rf=E("$ZodCheckMinLength",(e,t)=>{var r;me.init(e,t),(r=e._zod.def).when??(r.when=Ta),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>=t.minimum&&s<t.minimum*2?hn(o):s)>=t.minimum)return;let a=gn(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Af=E("$ZodCheckLengthEquals",(e,t)=>{var r;me.init(e,t),(r=e._zod.def).when??(r.when=Ta),e._zod.check=n=>{let o=n.value,s=o.length,i=typeof o=="string"&&s>=t.length&&s<=t.length*2?hn(o):s;if(i===t.length)return;let a=gn(o),c=i>t.length;n.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),En=E("$ZodCheckStringFormat",(e,t)=>{var r,n;me.init(e,t),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Of=E("$ZodCheckRegex",(e,t)=>{En.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),If=E("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=kf),En.init(e,t)}),Cf=E("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=xf),En.init(e,t)}),Mf=E("$ZodCheckIncludes",(e,t)=>{me.init(e,t);let r=Tt(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position},}${r}`:r);t.pattern=n,e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),zf=E("$ZodCheckStartsWith",(e,t)=>{me.init(e,t);let r=new RegExp(`^${Tt(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Df=E("$ZodCheckEndsWith",(e,t)=>{me.init(e,t);let r=new RegExp(`.*${Tt(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var Nf=E("$ZodCheckOverwrite",(e,t)=>{me.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var Jo=class{constructor(t=[],r={}){this.content=[],this.indent=0,this.args=t,this.closed=r}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
|
|
23
23
|
`).filter(i=>i),o=Math.min(...n.map(i=>i.length-i.trimStart().length)),s=n.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(let i of s)this.content.push(i)}compile(){let t=Function,r=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
24
24
|
${r.join(`
|
|
25
25
|
`)}
|
|
26
|
-
};`)(...Object.values(this.closed))}};var jf={major:4,minor:6,patch:5};var Q=E("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=jf;let n=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let s of o)for(let i of s._zod.onattach)i(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,u)=>{if(a.memo)return a;let l=at(a),d;for(let f of c){if(f._zod.def.when){if(_a(a)||!f._zod.def.when(a))continue}else if(l)continue;let p=a.issues.length,m=f._zod.check(a);if(m instanceof Promise&&u?.async===!1)throw new ut;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,a.issues.length!==p&&(qo(a.issues,p,e),l||(l=at(a,p)))});else{if(a.issues.length===p)continue;qo(a.issues,p,e),l||(l=at(a,p))}}return d?d.then(()=>a):a},i=(a,c,u)=>{if(at(a))return a.aborted=!0,a;let l=s(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new ut;return l.then(d=>e._zod.parse(d,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(d=>i(d,a,c)):i(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new ut;return u.then(l=>s(l,o,c))}return s(u,o,c)}}},{get"~standard"(){return Zo(this,"~standard",Oa(this))},set"~standard"(e){Ft(this,"~standard",e)}}),Yf=(e,t)=>e.issues.length?{issues:e.issues.map(r=>ct(r,t,He()))}:{value:e.value};async function zb(e,t){let r={async:!0};return Yf(await e._zod.run({value:t,issues:[]},r),r)}function Oa(e){return{validate:t=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return Yf(n,r)}catch{}return zb(e,t)},vendor:"zod",version:1}}var ts=E("$ZodString",(e,t)=>{Q.init(e,t),e._zod.pattern=t.pattern??bf,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),ee=E("$ZodStringFormat",(e,t)=>{En.init(e,t),ts.init(e,t)}),Jf=E("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=sf),ee.init(e,t)}),Xf=E("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=xa(n))}else t.pattern??(t.pattern=xa());ee.init(e,t)}),Qf=E("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=af),ee.init(e,t)}),ep=1,Qo=2;function tp(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Db(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?tp(e)||Qo:Nb(e,t)}function Nb(e,t){if(!t.normalize&&t.protocol?.source===hf.source&&!/^https?:\/\//i.test(e))return ep;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse=="function")return r.parse(e)??Qo}return new URL(e)}catch{return Qo}}var Lb=/[\t\n\r]/g;function Uf(e){return e.replace(Lb,"")}function jb(e,t){return t.lastIndex=0,t.test(e.hostname)}function Ub(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var rp=E("$ZodURL",(e,t)=>{ee.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),o=Db(n,t);if(o===ep){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===Qo){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=Uf(n);return}t.hostname&&!jb(o,t.hostname)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort}),t.protocol&&!Ub(o,t.protocol)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort}),r.value=t.normalize?o.href:Uf(n);return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),np=E("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=cf()),ee.init(e,t)}),op=E("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?rf:nf(t.length)),ee.init(e,t)}),sp=E("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Jd),ee.init(e,t)}),ip=E("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Xd),ee.init(e,t)}),ap=E("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Qd),ee.init(e,t)}),cp=E("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ef),ee.init(e,t)}),up=E("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=tf),ee.init(e,t)}),lp=E("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Ef(t)),ee.init(e,t)}),dp=E("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=yf),ee.init(e,t)}),fp=E("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Sf(t)),ee.init(e,t)}),pp=E("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=of),ee.init(e,t)}),mp=E("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=uf),ee.init(e,t)}),Fb=/^[0-9a-fA-F:.]+$/;function hp(e){return Fb.test(e)?tp(`http://[${e}]`):!1}var gp=E("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=lf),ee.init(e,t),e._zod.check=r=>{hp(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var _p=E("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=df),ee.init(e,t)});function qb(e){let t=e.split("/");if(t.length!==2)return!1;let[r,n]=t;if(!n)return!1;let o=Number(n);return`${o}`!==n||o<0||o>128?!1:hp(r)}var yp=E("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ff),ee.init(e,t),e._zod.check=r=>{qb(r.value)||r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function Sp(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Ia=/^[0-9a-zA-Z+/]*={0,2}$/,Ep=E("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Ia),ee.init(e,t),e._zod.check=r=>{Sp(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),rs=/^[A-Za-z0-9_-]*$/;function Zb(e){if(!rs.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Sp(r)}var bp=E("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=rs),ee.init(e,t),e._zod.check=r=>{Zb(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),vp=E("$ZodE164",(e,t)=>{t.pattern??(t.pattern=gf),ee.init(e,t)});function Wb(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var wp=E("$ZodJWT",(e,t)=>{ee.init(e,t),e._zod.check=r=>{Wb(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var Ca=E("$ZodNumber",(e,t)=>{Q.init(e,t),e._zod.pattern=yn,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),kp=E("$ZodNumberFormat",(e,t)=>{Tf.init(e,t),Ca.init(e,t)}),xp=E("$ZodBoolean",(e,t)=>{Q.init(e,t),e._zod.pattern=vf,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}});var Pp=E("$ZodNull",(e,t)=>{Q.init(e,t),e._zod.pattern=wf,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}});var Tp=E("$ZodUnknown",(e,t)=>{Q.init(e,t),e._zod.parse=r=>r}),$p=E("$ZodNever",(e,t)=>{Q.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Ff(e,t,r){e.issues.length&&t.issues.push(...$t(r,e.issues)),t.value[r]=e.value}var Rp=E("$ZodArray",(e,t)=>{Q.init(e,t);let r=ze.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=r?r.alloc(e,n,Array(s.length),o):Array(s.length);let i=[],a=o?.abortEarly;for(let c=0;c<s.length;c++){let u=s[c],l=t.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)i.push(l.then(d=>Ff(d,n,c)));else if(Ff(l,n,c),a&&l.issues.length!==0&&at(l))break}return i.length?Promise.all(i).then(()=>n):n}});function es(e,t,r,n,o,s){let i=r in n,a=s==="optional";if(!(!i&&a&&o==="optional")){if(e.issues.length){if(o!==void 0&&a&&!i)return;t.issues.push(...$t(r,e.issues))}if(!i&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?(i||o==="defaulted"&&!a)&&(t.value[r]=void 0):t.value[r]=e.value}}var Hb=[];function Ap(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:Hb,o=n.length?[...t,...n]:t;for(let i of o)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(i)}": expected a Zod schema`);let s=ga(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Op(e,t,r,n,o,s,i){let a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,d=u.optin,f=u.optout,p=0;for(let m in t){if(i&&r.issues.length!==p){if(at(r,p))break;p=r.issues.length}if(c.has(m))continue;if(m==="__proto__"){l==="never"&&a.push(m);continue}if(l==="never"){a.push(m);continue}let h=u.run({value:t[m],issues:[]},n);h instanceof Promise?e.push(h.then(g=>es(g,r,m,t,d,f))):es(h,r,m,t,d,f)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0}),e.length?Promise.all(e).then(()=>r):r}var Bb=E("$ZodObject",(e,t)=>{Q.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let u=()=>{let l={...n};return Object.defineProperty(t,"shape",{value:l}),u.raw=l,l};u.raw=n,Object.defineProperty(t,"shape",{get:u})}let o=Ar(()=>Ap(t));W(e,"propValues",u=>{let l=u.def.shape,d={};for(let f in l){let p=l[f]._zod;if(p.values){Object.prototype.hasOwnProperty.call(d,f)||We(d,f,new Set);for(let m of p.values)d[f].add(m);p.optin!==void 0&&d[f].add(void 0)}}return d});let s=ar,i=t.catchall,a,c=ze.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);let d=u.value;if(!s(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};let f=[],p=a.shape,m=l?.abortEarly,h=u.issues.length;for(let g of a.allKeys){if(m&&u.issues.length!==h){if(at(u,h))break;h=u.issues.length}if(g==="__proto__")continue;let y=p[g],b=y._zod.optin,v=y._zod.optout,O=y._zod.run({value:d[g],issues:[]},l);O instanceof Promise?f.push(O.then(x=>es(x,u,g,d,b,v))):es(O,u,g,d,b,v)}return i?Op(f,d,u,l,o.value,e,m===!0):f.length?Promise.all(f).then(()=>u):u}}),Ip=E("$ZodObjectJIT",(e,t)=>{Bb.init(e,t);let r=e._zod.parse,n=Ar(()=>Ap(t)),o=ze.memoizer,s=p=>{let m=n.value,h=m.symbolKeys,g=new Jo(["payload","ctx"],{shape:p,inst:e,memo:o,syms:h}),y=x=>`shape[${x}]._zod.run({ value: input[${x}], issues: [] }, ctx)`,b=(x,z)=>`
|
|
26
|
+
};`)(...Object.values(this.closed))}};var jf={major:4,minor:6,patch:5};var Q=E("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=jf;let n=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let s of o)for(let i of s._zod.onattach)i(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,u)=>{if(a.memo)return a;let l=at(a),d;for(let f of c){if(f._zod.def.when){if(_a(a)||!f._zod.def.when(a))continue}else if(l)continue;let p=a.issues.length,m=f._zod.check(a);if(m instanceof Promise&&u?.async===!1)throw new ut;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,a.issues.length!==p&&(qo(a.issues,p,e),l||(l=at(a,p)))});else{if(a.issues.length===p)continue;qo(a.issues,p,e),l||(l=at(a,p))}}return d?d.then(()=>a):a},i=(a,c,u)=>{if(at(a))return a.aborted=!0,a;let l=s(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new ut;return l.then(d=>e._zod.parse(d,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(d=>i(d,a,c)):i(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new ut;return u.then(l=>s(l,o,c))}return s(u,o,c)}}},{get"~standard"(){return Zo(this,"~standard",Oa(this))},set"~standard"(e){Ft(this,"~standard",e)}}),Yf=(e,t)=>e.issues.length?{issues:e.issues.map(r=>ct(r,t,We()))}:{value:e.value};async function zb(e,t){let r={async:!0};return Yf(await e._zod.run({value:t,issues:[]},r),r)}function Oa(e){return{validate:t=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return Yf(n,r)}catch{}return zb(e,t)},vendor:"zod",version:1}}var ts=E("$ZodString",(e,t)=>{Q.init(e,t),e._zod.pattern=t.pattern??bf,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),ee=E("$ZodStringFormat",(e,t)=>{En.init(e,t),ts.init(e,t)}),Jf=E("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=sf),ee.init(e,t)}),Xf=E("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=xa(n))}else t.pattern??(t.pattern=xa());ee.init(e,t)}),Qf=E("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=af),ee.init(e,t)}),ep=1,Qo=2;function tp(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Db(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?tp(e)||Qo:Nb(e,t)}function Nb(e,t){if(!t.normalize&&t.protocol?.source===hf.source&&!/^https?:\/\//i.test(e))return ep;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse=="function")return r.parse(e)??Qo}return new URL(e)}catch{return Qo}}var Lb=/[\t\n\r]/g;function Uf(e){return e.replace(Lb,"")}function jb(e,t){return t.lastIndex=0,t.test(e.hostname)}function Ub(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var rp=E("$ZodURL",(e,t)=>{ee.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),o=Db(n,t);if(o===ep){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===Qo){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=Uf(n);return}t.hostname&&!jb(o,t.hostname)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort}),t.protocol&&!Ub(o,t.protocol)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort}),r.value=t.normalize?o.href:Uf(n);return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),np=E("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=cf()),ee.init(e,t)}),op=E("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?rf:nf(t.length)),ee.init(e,t)}),sp=E("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Jd),ee.init(e,t)}),ip=E("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Xd),ee.init(e,t)}),ap=E("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Qd),ee.init(e,t)}),cp=E("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ef),ee.init(e,t)}),up=E("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=tf),ee.init(e,t)}),lp=E("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Ef(t)),ee.init(e,t)}),dp=E("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=yf),ee.init(e,t)}),fp=E("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Sf(t)),ee.init(e,t)}),pp=E("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=of),ee.init(e,t)}),mp=E("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=uf),ee.init(e,t)}),Fb=/^[0-9a-fA-F:.]+$/;function hp(e){return Fb.test(e)?tp(`http://[${e}]`):!1}var gp=E("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=lf),ee.init(e,t),e._zod.check=r=>{hp(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var _p=E("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=df),ee.init(e,t)});function qb(e){let t=e.split("/");if(t.length!==2)return!1;let[r,n]=t;if(!n)return!1;let o=Number(n);return`${o}`!==n||o<0||o>128?!1:hp(r)}var yp=E("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ff),ee.init(e,t),e._zod.check=r=>{qb(r.value)||r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function Sp(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Ia=/^[0-9a-zA-Z+/]*={0,2}$/,Ep=E("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Ia),ee.init(e,t),e._zod.check=r=>{Sp(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),rs=/^[A-Za-z0-9_-]*$/;function Zb(e){if(!rs.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Sp(r)}var bp=E("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=rs),ee.init(e,t),e._zod.check=r=>{Zb(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),wp=E("$ZodE164",(e,t)=>{t.pattern??(t.pattern=gf),ee.init(e,t)});function Hb(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var vp=E("$ZodJWT",(e,t)=>{ee.init(e,t),e._zod.check=r=>{Hb(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var Ca=E("$ZodNumber",(e,t)=>{Q.init(e,t),e._zod.pattern=yn,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),kp=E("$ZodNumberFormat",(e,t)=>{Tf.init(e,t),Ca.init(e,t)}),xp=E("$ZodBoolean",(e,t)=>{Q.init(e,t),e._zod.pattern=wf,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}});var Pp=E("$ZodNull",(e,t)=>{Q.init(e,t),e._zod.pattern=vf,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}});var Tp=E("$ZodUnknown",(e,t)=>{Q.init(e,t),e._zod.parse=r=>r}),$p=E("$ZodNever",(e,t)=>{Q.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Ff(e,t,r){e.issues.length&&t.issues.push(...$t(r,e.issues)),t.value[r]=e.value}var Rp=E("$ZodArray",(e,t)=>{Q.init(e,t);let r=ze.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=r?r.alloc(e,n,Array(s.length),o):Array(s.length);let i=[],a=o?.abortEarly;for(let c=0;c<s.length;c++){let u=s[c],l=t.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)i.push(l.then(d=>Ff(d,n,c)));else if(Ff(l,n,c),a&&l.issues.length!==0&&at(l))break}return i.length?Promise.all(i).then(()=>n):n}});function es(e,t,r,n,o,s){let i=r in n,a=s==="optional";if(!(!i&&a&&o==="optional")){if(e.issues.length){if(o!==void 0&&a&&!i)return;t.issues.push(...$t(r,e.issues))}if(!i&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?(i||o==="defaulted"&&!a)&&(t.value[r]=void 0):t.value[r]=e.value}}var Wb=[];function Ap(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:Wb,o=n.length?[...t,...n]:t;for(let i of o)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(i)}": expected a Zod schema`);let s=ga(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Op(e,t,r,n,o,s,i){let a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,d=u.optin,f=u.optout,p=0;for(let m in t){if(i&&r.issues.length!==p){if(at(r,p))break;p=r.issues.length}if(c.has(m))continue;if(m==="__proto__"){l==="never"&&a.push(m);continue}if(l==="never"){a.push(m);continue}let h=u.run({value:t[m],issues:[]},n);h instanceof Promise?e.push(h.then(g=>es(g,r,m,t,d,f))):es(h,r,m,t,d,f)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0}),e.length?Promise.all(e).then(()=>r):r}var Bb=E("$ZodObject",(e,t)=>{Q.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let u=()=>{let l={...n};return Object.defineProperty(t,"shape",{value:l}),u.raw=l,l};u.raw=n,Object.defineProperty(t,"shape",{get:u})}let o=Or(()=>Ap(t));H(e,"propValues",u=>{let l=u.def.shape,d={};for(let f in l){let p=l[f]._zod;if(p.values){Object.prototype.hasOwnProperty.call(d,f)||He(d,f,new Set);for(let m of p.values)d[f].add(m);p.optin!==void 0&&d[f].add(void 0)}}return d});let s=ar,i=t.catchall,a,c=ze.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);let d=u.value;if(!s(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};let f=[],p=a.shape,m=l?.abortEarly,h=u.issues.length;for(let g of a.allKeys){if(m&&u.issues.length!==h){if(at(u,h))break;h=u.issues.length}if(g==="__proto__")continue;let y=p[g],b=y._zod.optin,w=y._zod.optout,O=y._zod.run({value:d[g],issues:[]},l);O instanceof Promise?f.push(O.then(x=>es(x,u,g,d,b,w))):es(O,u,g,d,b,w)}return i?Op(f,d,u,l,o.value,e,m===!0):f.length?Promise.all(f).then(()=>u):u}}),Ip=E("$ZodObjectJIT",(e,t)=>{Bb.init(e,t);let r=e._zod.parse,n=Or(()=>Ap(t)),o=ze.memoizer,s=p=>{let m=n.value,h=m.symbolKeys,g=new Jo(["payload","ctx"],{shape:p,inst:e,memo:o,syms:h}),y=x=>`shape[${x}]._zod.run({ value: input[${x}], issues: [] }, ctx)`,b=(x,z)=>`
|
|
27
27
|
let ${x}_ab = false;
|
|
28
28
|
for (let i = 0; i < ${x}.issues.length; i++) {
|
|
29
29
|
const iss = ${x}.issues[i];
|
|
@@ -34,7 +34,7 @@ ${r.join(`
|
|
|
34
34
|
if (${x}_ab && ctx && ctx.abortEarly) {
|
|
35
35
|
payload.value = newResult;
|
|
36
36
|
return payload;
|
|
37
|
-
}`;g.write("const input = payload.value;");let
|
|
37
|
+
}`;g.write("const input = payload.value;");let w=Object.create(null),O=0;for(let x of m.allKeys)w[x]=`key_${O++}`;g.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let x of m.allKeys){if(x==="__proto__")continue;let z=w[x],j=typeof x=="symbol"?`syms[${h.indexOf(x)}]`:fa(x),Ge=`${j} in input`,xe=p[x],Ve=xe?._zod?.optin,xr=Ve!==void 0,Oo=xe?._zod?.optout==="optional";if(g.write(`const ${z} = ${y(j)};`),xr&&Oo){let Io=Ve==="optional"?`${z}_present`:`${z}.value !== undefined || ${z}_present`;g.write(`
|
|
38
38
|
const ${z}_present = ${Ge};
|
|
39
39
|
if (!${z}.issues.length || ${z}_present) {
|
|
40
40
|
if (${z}.issues.length) {${b(z,j)}
|
|
@@ -73,15 +73,15 @@ ${r.join(`
|
|
|
73
73
|
newResult[${j}] = ${z}.value;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
`)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()},i,a=ar,c=!ze.jitless,l=c&&ma.value,d=t.catchall,f;e._zod.parse=(p,m)=>{f??(f=n.value);let h=p.value;return a(h)?c&&l&&m?.async===!1&&m.jitless!==!0?(i||(i=s(t.shape)),p=i(p,m),d?Op([],h,p,m,f,e,m?.abortEarly===!0):p):r(p,m):(p.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),p)}});function qf(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter(s=>!at(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(i=>ct(i,n,He())))}),t)}var Ma=E("$ZodUnion",(e,t)=>{Q.init(e,t),W(e,"optin",n=>n.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":n.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),W(e,"optout",n=>n.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),W(e,"values",n=>{if(n.def.options.every(o=>o._zod.values))return new Set(n.def.options.flatMap(o=>Array.from(o._zod.values)))}),W(e,"pattern",n=>{if(n.def.options.every(o=>o._zod.pattern)){let o=n.def.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>pn(s.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let a of t.options){let c=a._zod.run({value:n.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}return s?Promise.all(i).then(a=>qf(a,n,e,o)):qf(i,n,e,o)}});function Kb(e){let t=new Map;for(let r of e.options){let n=r._zod.propValues?.[e.discriminator];if(!n||n.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let o of n)if(t.has(o)){if(o!==void 0)throw new Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,r)}return t}var Cp=E("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ma.init(e,t);let r=e._zod.parse;W(e,"propValues",o=>{let s={},i=0;for(let a of o.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);c[o.def.discriminator]?.has(void 0)&&i++;for(let[u,l]of Object.entries(c)){Object.prototype.hasOwnProperty.call(s,u)||We(s,u,new Set);for(let d of l)s[u].add(d)}}return!o.def.unionFallback&&i>1&&s[o.def.discriminator]?.delete(void 0),s}),t.options.forEach((o,s)=>{let i=Or(o._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw new Error(`Invalid discriminated union option at index "${s}"`)});let n=Ar(()=>Kb(t));e._zod.parse=(o,s)=>{let i=o.value;if(!ar(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;let a=i?.[t.discriminator],c=n.value.get(a);return c&&(a!==void 0||s.direction!=="backward")?c._zod.run(o,s):t.unionFallback||s.direction==="backward"?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()).filter(u=>n.value.get(u)!==null),input:i,path:[t.discriminator],inst:e}),o)}}),Mp=E("$ZodIntersection",(e,t)=>{Q.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Zf(r,c,u)):Zf(r,s,i)}});function Aa(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(qt(e)&&qt(t)){let r=Object.keys(t),n=Object.keys(e).filter(s=>r.indexOf(s)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(let s of n){if(s==="__proto__")continue;let i=Aa(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],s=t[n],i=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 Zf(e,t,r){let n=new Map,o,s=new Map,i=(u,l)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),d=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let f=String(u.path[0]);s.has(f)||s.set(f,u),d=[f]}else return!1;for(let f of d)n.has(f)||n.set(f,{}),n.get(f)[l]=!0;return!0};for(let u of t.issues)i(u,"l")||e.issues.push(u);for(let u of r.issues)i(u,"r")||e.issues.push(u);let a=[...n].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter(l=>o.keys.includes(l)):[];u.length&&e.issues.push({...o,keys:u});for(let l of a)!u.includes(l)&&s.has(l)&&e.issues.push(s.get(l))}let c=Aa(t.value,r.value);if(!c.valid){if(at(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var zp=E("$ZodRecord",(e,t)=>{Q.init(e,t);let r=ze.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!qt(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;let i=[],a=t.keyType._zod.values;if(a&&!t.partial){n.value=r?r.alloc(e,n,{},o):{};let c=new Set;for(let l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(c.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;let d=t.keyType._zod.run({value:l,issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(m=>ct(m,o,He())),input:l,path:[l],inst:e});continue}let f=d.value;if(f==="__proto__")continue;let p=t.valueType._zod.run({value:s[l],issues:[]},o);p instanceof Promise?i.push(p.then(m=>{m.issues.length&&n.issues.push(...$t(l,m.issues)),n.value[f]=m.value})):(p.issues.length&&n.issues.push(...$t(l,p.issues)),n.value[f]=p.value)}let u;for(let l in s)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;n.value[l]=s[l]}else u=u??[],u.push(l);u&&u.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:u,continue:!0})}else{n.value=r?r.alloc(e,n,{},o):{};let c;for(let u of Reflect.ownKeys(s)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(s,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&yn.test(u)&&l.issues.length){let m=t.keyType._zod.run({value:Number(u),issues:[]},o);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");m.issues.length===0&&(l=m)}if(l.issues.length){t.mode==="loose"?n.value[u]=s[u]:a?(c=c??[],c.push(u)):n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(m=>ct(m,o,He())),input:u,path:[u],inst:e});continue}let f=l.value;if(f==="__proto__")continue;let p=t.valueType._zod.run({value:s[u],issues:[]},o);p instanceof Promise?i.push(p.then(m=>{m.issues.length&&n.issues.push(...$t(u,m.issues)),n.value[f]=m.value})):(p.issues.length&&n.issues.push(...$t(u,p.issues)),n.value[f]=p.value)}c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}return i.length?Promise.all(i).then(()=>n):n}});var Dp=E("$ZodEnum",(e,t)=>{Q.init(e,t);let r=$r(t.entries),n=new Set(r);e._zod.values=n,W(e,"pattern",o=>{let s=$r(o.def.entries).filter(i=>ha.has(typeof i));return new RegExp(s.length?`^(${s.map(i=>Tt(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}}),Np=E("$ZodLiteral",(e,t)=>{Q.init(e,t);let r=new Set(t.values);e._zod.values=r,W(e,"pattern",n=>{let o=n.def.values;return new RegExp(o.length?`^(${o.map(s=>typeof s=="string"?Tt(s):s?Tt(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,o)=>{let s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}});var Lp=E("$ZodTransform",(e,t)=>{Q.init(e,t),e._zod.optin="optional",ze.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Cr(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new ut;return r.value=o,r}});function Wf(e,t){return e.value=t.issues.length?void 0:t.value,e}var za=E("$ZodOptional",(e,t)=>{Q.init(e,t),W(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",W(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),W(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${pn(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>Wf(r,s)):Wf(r,o)}return t.innerType._zod.run(r,n)}}),jp=E("$ZodExactOptional",(e,t)=>{za.init(e,t),W(e,"values",r=>r.def.innerType._zod.values),W(e,"pattern",r=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Up=E("$ZodNullable",(e,t)=>{Q.init(e,t),W(e,"optin",r=>r.def.innerType._zod.optin),W(e,"optout",r=>r.def.innerType._zod.optout),W(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${pn(n.source)}|null)$`):void 0}),W(e,"values",r=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Fp=E("$ZodDefault",(e,t)=>{Q.init(e,t),e._zod.optin="defaulted",W(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Hf(s,t)):Hf(o,t)}});function Hf(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var qp=E("$ZodPrefault",(e,t)=>{Q.init(e,t),e._zod.optin="defaulted",W(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Zp=E("$ZodNonOptional",(e,t)=>{Q.init(e,t),W(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Bf(s,e)):Bf(o,e)}});function Bf(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function Kf(e,t,r,n){return t.issues.length?(e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>ct(o,n,He()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Wp=E("$ZodCatch",(e,t)=>{Q.init(e,t),W(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),W(e,"optout",r=>r.def.innerType._zod.optout),W(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>Kf(r,s,t,n)):Kf(r,o,t,n)}});var Da=E("$ZodPipe",(e,t)=>{Q.init(e,t),W(e,"values",r=>r.def.in._zod.values),W(e,"optin",r=>r.def.in._zod.optin),W(e,"optout",r=>r.def.out._zod.optout),W(e,"propValues",r=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=t.out._zod.run(r,n);return s instanceof Promise?s.then(i=>Xo(i,t.in,n)):Xo(s,t.in,n)}let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(s=>Xo(s,t.out,n)):Xo(o,t.out,n)}});function Xo(e,t,r){return e.issues.some(n=>n.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var Hp=E("$ZodPreprocess",(e,t)=>{Da.init(e,t)}),Bp=E("$ZodReadonly",(e,t)=>{Q.init(e,t),W(e,"propValues",r=>r.def.innerType._zod.propValues),W(e,"values",r=>r.def.innerType._zod.values),W(e,"optin",r=>r.def.innerType?._zod?.optin),W(e,"optout",r=>r.def.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(Gf):Gf(o)}});function Gf(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Kp=E("$ZodCustom",(e,t)=>{me.init(e,t),Q.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(s=>Vf(s,r,n,e));Vf(o,r,n,e)}});function Vf(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(Ir(o))}}var La=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},ja="~memo",Gp=[];function Vp(e){return e!==null&&typeof e=="object"}function Na(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}var Yp=new WeakMap,bn=0,ss=1,vn=2;function is(e,t,r){let n=Yp.get(e);if(n!==void 0)return n?vn:bn;if(t.has(e))return vn;t.add(e);let o=bn,s=l=>{if(o!==vn&&l?._zod){let d=is(l,t,r);d>o&&(o=d)}},i=(l,d)=>{let f=bn;for(let p of Reflect.ownKeys(l)){let m=Object.getOwnPropertyDescriptor(l,p);if(d&&!m.enumerable)continue;let h=m.get?ss:m.value?._zod?is(m.value,t,r):bn;h>f&&(f=h)}return f},a=l=>{l>o&&(o=l)},c=e._zod.def,u=c.type;switch(u){case"object":{let l=Or(c);a(l?i(l,!0):ss),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let l of c.items)s(l);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let l of c.options)s(l);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let l=c._cachedInner??(r?e._zod.innerType:void 0);a(l?is(l,t,!1):ss);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let l in c){let d=Object.getOwnPropertyDescriptor(c,l);if(!d||d.get)continue;let f=d.value;if(!(!f||typeof f!="object")){if(f._zod)s(f);else if(Array.isArray(f))for(let p of f)s(p)}}}return t.delete(e),Gb(e,o)}function Gb(e,t){return t!==ss&&Yp.set(e,t===vn),t}function Vb(e,t){let r=e.buckets.get(t);return r||(r=new WeakMap,e.buckets.set(t,r)),r}var ns,os=[],Yb={alloc(e,t,r){let n=ns;if(!n)return r;ns=void 0;let o={value:r,issues:null};return n.set(t.value,o),os.push(o),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,n=(o,s)=>{if(s.direction!=="backward"&&Jb(s,o.value))throw new La;return r(o,s)};e._zod.parse=n,e._zod.run===r&&(e._zod.run=n)})},attach(e){var t;let r,n=!1,o,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let i=e._zod.parse,a=(c,u)=>{if(r===void 0){let y=is(e,new Set,!1);if(y===bn)return e._zod.parse=i,e._zod.run===a&&(e._zod.run=i),i(c,u);y===vn||n?r=!0:n=!0}let l=c.value;if(!Vp(l))return i(c,u);let d=u[ja];d||(d={buckets:new WeakMap,backEdges:void 0},u[ja]=d);let f;o===u?f=s:(f=Vb(d,e),o=u,s=f);let p=f.get(l);if(p)return c.value=p.value,p.issues?p.issues.length&&c.issues.push(...Na(p.issues)):(c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(p.value)),c;ns=f;let m=os.length,h=i(c,u);ns=void 0;let g=os.length>m?os.pop():void 0;return h instanceof Promise?h.then(y=>(g&&(g.issues=y.issues.length?Na(y.issues):Gp),y)):(g&&(g.issues=h.issues.length?Na(h.issues):Gp),h)};e._zod.parse=a,e._zod.run===i&&(e._zod.run=a)})}};function Jp(){return Yb}function Jb(e,t){let r=e[ja]?.backEdges;return r!==void 0&&Vp(t)&&r.has(t)}var Xb=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};function o(s,i){return s==="number"&&typeof i=="number"&&!Number.isFinite(i)?String(i):n[s]??s}return s=>{switch(s.code){case"invalid_type":{let i=o(s.expected),a=ya(s.input),c=o(a,s.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":return s.values.length===1?`Invalid input: expected ${jo(s.values[0])}`:`Invalid option: expected one of ${No(s.values,"|")}`;case"too_big":{let i=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);return a?`Too big: expected ${s.origin??"value"} to have ${i}${s.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${s.origin??"value"} to be ${i}${s.maximum.toString()}`}case"too_small":{let i=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);return a?`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${a.unit}`:`Too small: expected ${s.origin} to be ${i}${s.minimum.toString()}`}case"invalid_format":{let i=s;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${r[i.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${No(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":return s.options&&Array.isArray(s.options)&&s.options.length>0?`Invalid discriminator value. Expected ${s.options.map(a=>`'${a}'`).join(" | ")}`:s.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function Xp(){return{localeError:Xb()}}var Qp;var Ua=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let o={...n,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function Qb(){return new Ua}(Qp=globalThis).__zod_globalRegistry??(Qp.__zod_globalRegistry=Qb());var cr=globalThis.__zod_globalRegistry;function em(e){return e.checks&&(e.checks=[...e.checks]),e}function tm(e,t){return new e(em({type:"string",...$(t)}))}function rm(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...$(t)})}function nm(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...$(t)})}function om(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...$(t)})}function sm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...$(t)})}function im(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...$(t)})}function am(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...$(t)})}function cm(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...$(t)})}function um(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...$(t)})}function lm(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...$(t)})}function dm(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...$(t)})}function fm(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...$(t)})}function pm(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...$(t)})}function mm(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...$(t)})}function hm(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...$(t)})}function gm(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...$(t)})}function _m(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...$(t)})}function ym(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...$(t)})}function Sm(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...$(t)})}function Em(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...$(t)})}function bm(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...$(t)})}function vm(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...$(t)})}function wm(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...$(t)})}function as(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...$(t)})}function cs(e,t){return new e({type:"string",format:"date",check:"string_format",...$(t)})}function us(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...$(t)})}function ls(e,t){return new e({type:"string",format:"duration",check:"string_format",...$(t)})}function km(e,t){return new e(em({type:"number",checks:[],...$(t)}))}function xm(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...$(t)})}function Pm(e,t){return new e({type:"boolean",...$(t)})}function Tm(e,t){return new e({type:"null",...$(t)})}function $m(e){return new e({type:"unknown"})}function Rm(e,t){return new e({type:"never",...$(t)})}function ds(e,t){return new $a({check:"less_than",...$(t),value:e,inclusive:!1})}function wn(e,t){return new $a({check:"less_than",...$(t),value:e,inclusive:!0})}function fs(e,t){return new Ra({check:"greater_than",...$(t),value:e,inclusive:!1})}function kn(e,t){return new Ra({check:"greater_than",...$(t),value:e,inclusive:!0})}function ps(e,t){return new Pf({check:"multiple_of",...$(t),value:e})}function ms(e,t){return new $f({check:"max_length",...$(t),maximum:e})}function Mr(e,t){return new Rf({check:"min_length",...$(t),minimum:e})}function hs(e,t){return new Af({check:"length_equals",...$(t),length:e})}function Fa(e,t){return new Of({check:"string_format",format:"regex",...$(t),pattern:e})}function qa(e){return new If({check:"string_format",format:"lowercase",...$(e)})}function Za(e){return new Cf({check:"string_format",format:"uppercase",...$(e)})}function Wa(e,t){return new Mf({check:"string_format",format:"includes",...$(t),includes:e})}function Ha(e,t){return new zf({check:"string_format",format:"starts_with",...$(t),prefix:e})}function Ba(e,t){return new Df({check:"string_format",format:"ends_with",...$(t),suffix:e})}function Zt(e){return new Nf({check:"overwrite",tx:e})}function Ka(e){return Zt(t=>t.normalize(e))}function Ga(){return Zt(e=>e.trim())}function Va(){return Zt(e=>e.toLowerCase())}function Ya(){return Zt(e=>e.toUpperCase())}function Ja(){return Zt(e=>pa(e))}function Am(e,t,r){return new e({type:"array",element:t,...$(r)})}function Om(e,t,r){let n=$(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function Im(e,t,r){return new e({type:"custom",check:"custom",fn:t,...$(r)})}function Cm(e,t){let r=ev(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(Ir(o,n.value,r._zod.def));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=n.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(Ir(s))}},e(n.value,n)),t);return r}function ev(e,t){let r=new me({check:"custom",...$(t)});return r._zod.check=e,r}function xn(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,n)&&We(e,n,r[n]);return e}function Qa(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??cr,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Rt(e,t,r,n,o){let s=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:n.path,message:o}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw new Error(o);return Object.assign(r,s),!0}function ue(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,r.schemaPath.includes(e)&&(s.cycle=r.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,l);else{let f=i.schema,p=t.processors[o.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);p(e,t,f,l)}let d=e._zod.parent;d&&(i.ref||(i.ref=d),ue(d,t,l),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&xn(i.schema,c),t.io==="input"&&Pe(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function Mm(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ec(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let n=new Map;for(let i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let c=n.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,i[0])}}let o=i=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(i[0])?.id,f=e.external.uri??(m=>m);if(d)return{ref:f(d)};let p=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=p,{defId:p,ref:`${f("__shared")}#/${a}/${Mm(p)}`}}let c="#",u=`${c}/${a}/`;if(i[1]===r&&!i[1].schema.id)return{ref:c};let l=i[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+Mm(l)}},s=i=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:u}=o(i);a.def={...a.schema},u&&(a.defId=u);let l=a.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let i of e.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
76
|
+
`)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()},i,a=ar,c=!ze.jitless,l=c&&ma.value,d=t.catchall,f;e._zod.parse=(p,m)=>{f??(f=n.value);let h=p.value;return a(h)?c&&l&&m?.async===!1&&m.jitless!==!0?(i||(i=s(t.shape)),p=i(p,m),d?Op([],h,p,m,f,e,m?.abortEarly===!0):p):r(p,m):(p.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),p)}});function qf(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter(s=>!at(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(i=>ct(i,n,We())))}),t)}var Ma=E("$ZodUnion",(e,t)=>{Q.init(e,t),H(e,"optin",n=>n.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":n.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),H(e,"optout",n=>n.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),H(e,"values",n=>{if(n.def.options.every(o=>o._zod.values))return new Set(n.def.options.flatMap(o=>Array.from(o._zod.values)))}),H(e,"pattern",n=>{if(n.def.options.every(o=>o._zod.pattern)){let o=n.def.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>pn(s.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let a of t.options){let c=a._zod.run({value:n.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}return s?Promise.all(i).then(a=>qf(a,n,e,o)):qf(i,n,e,o)}});function Kb(e){let t=new Map;for(let r of e.options){let n=r._zod.propValues?.[e.discriminator];if(!n||n.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let o of n)if(t.has(o)){if(o!==void 0)throw new Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,r)}return t}var Cp=E("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ma.init(e,t);let r=e._zod.parse;H(e,"propValues",o=>{let s={},i=0;for(let a of o.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);c[o.def.discriminator]?.has(void 0)&&i++;for(let[u,l]of Object.entries(c)){Object.prototype.hasOwnProperty.call(s,u)||He(s,u,new Set);for(let d of l)s[u].add(d)}}return!o.def.unionFallback&&i>1&&s[o.def.discriminator]?.delete(void 0),s}),t.options.forEach((o,s)=>{let i=Ir(o._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw new Error(`Invalid discriminated union option at index "${s}"`)});let n=Or(()=>Kb(t));e._zod.parse=(o,s)=>{let i=o.value;if(!ar(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;let a=i?.[t.discriminator],c=n.value.get(a);return c&&(a!==void 0||s.direction!=="backward")?c._zod.run(o,s):t.unionFallback||s.direction==="backward"?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()).filter(u=>n.value.get(u)!==null),input:i,path:[t.discriminator],inst:e}),o)}}),Mp=E("$ZodIntersection",(e,t)=>{Q.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Zf(r,c,u)):Zf(r,s,i)}});function Aa(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(qt(e)&&qt(t)){let r=Object.keys(t),n=Object.keys(e).filter(s=>r.indexOf(s)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(let s of n){if(s==="__proto__")continue;let i=Aa(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],s=t[n],i=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 Zf(e,t,r){let n=new Map,o,s=new Map,i=(u,l)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),d=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let f=String(u.path[0]);s.has(f)||s.set(f,u),d=[f]}else return!1;for(let f of d)n.has(f)||n.set(f,{}),n.get(f)[l]=!0;return!0};for(let u of t.issues)i(u,"l")||e.issues.push(u);for(let u of r.issues)i(u,"r")||e.issues.push(u);let a=[...n].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter(l=>o.keys.includes(l)):[];u.length&&e.issues.push({...o,keys:u});for(let l of a)!u.includes(l)&&s.has(l)&&e.issues.push(s.get(l))}let c=Aa(t.value,r.value);if(!c.valid){if(at(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var zp=E("$ZodRecord",(e,t)=>{Q.init(e,t);let r=ze.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!qt(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;let i=[],a=t.keyType._zod.values;if(a&&!t.partial){n.value=r?r.alloc(e,n,{},o):{};let c=new Set;for(let l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(c.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;let d=t.keyType._zod.run({value:l,issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(m=>ct(m,o,We())),input:l,path:[l],inst:e});continue}let f=d.value;if(f==="__proto__")continue;let p=t.valueType._zod.run({value:s[l],issues:[]},o);p instanceof Promise?i.push(p.then(m=>{m.issues.length&&n.issues.push(...$t(l,m.issues)),n.value[f]=m.value})):(p.issues.length&&n.issues.push(...$t(l,p.issues)),n.value[f]=p.value)}let u;for(let l in s)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;n.value[l]=s[l]}else u=u??[],u.push(l);u&&u.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:u,continue:!0})}else{n.value=r?r.alloc(e,n,{},o):{};let c;for(let u of Reflect.ownKeys(s)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(s,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&yn.test(u)&&l.issues.length){let m=t.keyType._zod.run({value:Number(u),issues:[]},o);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");m.issues.length===0&&(l=m)}if(l.issues.length){t.mode==="loose"?n.value[u]=s[u]:a?(c=c??[],c.push(u)):n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(m=>ct(m,o,We())),input:u,path:[u],inst:e});continue}let f=l.value;if(f==="__proto__")continue;let p=t.valueType._zod.run({value:s[u],issues:[]},o);p instanceof Promise?i.push(p.then(m=>{m.issues.length&&n.issues.push(...$t(u,m.issues)),n.value[f]=m.value})):(p.issues.length&&n.issues.push(...$t(u,p.issues)),n.value[f]=p.value)}c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}return i.length?Promise.all(i).then(()=>n):n}});var Dp=E("$ZodEnum",(e,t)=>{Q.init(e,t);let r=Rr(t.entries),n=new Set(r);e._zod.values=n,H(e,"pattern",o=>{let s=Rr(o.def.entries).filter(i=>ha.has(typeof i));return new RegExp(s.length?`^(${s.map(i=>Tt(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}}),Np=E("$ZodLiteral",(e,t)=>{Q.init(e,t);let r=new Set(t.values);e._zod.values=r,H(e,"pattern",n=>{let o=n.def.values;return new RegExp(o.length?`^(${o.map(s=>typeof s=="string"?Tt(s):s?Tt(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,o)=>{let s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}});var Lp=E("$ZodTransform",(e,t)=>{Q.init(e,t),e._zod.optin="optional",ze.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Mr(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new ut;return r.value=o,r}});function Hf(e,t){return e.value=t.issues.length?void 0:t.value,e}var za=E("$ZodOptional",(e,t)=>{Q.init(e,t),H(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",H(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),H(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${pn(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>Hf(r,s)):Hf(r,o)}return t.innerType._zod.run(r,n)}}),jp=E("$ZodExactOptional",(e,t)=>{za.init(e,t),H(e,"values",r=>r.def.innerType._zod.values),H(e,"pattern",r=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Up=E("$ZodNullable",(e,t)=>{Q.init(e,t),H(e,"optin",r=>r.def.innerType._zod.optin),H(e,"optout",r=>r.def.innerType._zod.optout),H(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${pn(n.source)}|null)$`):void 0}),H(e,"values",r=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Fp=E("$ZodDefault",(e,t)=>{Q.init(e,t),e._zod.optin="defaulted",H(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Wf(s,t)):Wf(o,t)}});function Wf(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var qp=E("$ZodPrefault",(e,t)=>{Q.init(e,t),e._zod.optin="defaulted",H(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Zp=E("$ZodNonOptional",(e,t)=>{Q.init(e,t),H(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Bf(s,e)):Bf(o,e)}});function Bf(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function Kf(e,t,r,n){return t.issues.length?(e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>ct(o,n,We()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Hp=E("$ZodCatch",(e,t)=>{Q.init(e,t),H(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),H(e,"optout",r=>r.def.innerType._zod.optout),H(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>Kf(r,s,t,n)):Kf(r,o,t,n)}});var Da=E("$ZodPipe",(e,t)=>{Q.init(e,t),H(e,"values",r=>r.def.in._zod.values),H(e,"optin",r=>r.def.in._zod.optin),H(e,"optout",r=>r.def.out._zod.optout),H(e,"propValues",r=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=t.out._zod.run(r,n);return s instanceof Promise?s.then(i=>Xo(i,t.in,n)):Xo(s,t.in,n)}let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(s=>Xo(s,t.out,n)):Xo(o,t.out,n)}});function Xo(e,t,r){return e.issues.some(n=>n.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var Wp=E("$ZodPreprocess",(e,t)=>{Da.init(e,t)}),Bp=E("$ZodReadonly",(e,t)=>{Q.init(e,t),H(e,"propValues",r=>r.def.innerType._zod.propValues),H(e,"values",r=>r.def.innerType._zod.values),H(e,"optin",r=>r.def.innerType?._zod?.optin),H(e,"optout",r=>r.def.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(Gf):Gf(o)}});function Gf(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Kp=E("$ZodCustom",(e,t)=>{me.init(e,t),Q.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(s=>Vf(s,r,n,e));Vf(o,r,n,e)}});function Vf(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(Cr(o))}}var La=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},ja="~memo",Gp=[];function Vp(e){return e!==null&&typeof e=="object"}function Na(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}var Yp=new WeakMap,bn=0,ss=1,wn=2;function is(e,t,r){let n=Yp.get(e);if(n!==void 0)return n?wn:bn;if(t.has(e))return wn;t.add(e);let o=bn,s=l=>{if(o!==wn&&l?._zod){let d=is(l,t,r);d>o&&(o=d)}},i=(l,d)=>{let f=bn;for(let p of Reflect.ownKeys(l)){let m=Object.getOwnPropertyDescriptor(l,p);if(d&&!m.enumerable)continue;let h=m.get?ss:m.value?._zod?is(m.value,t,r):bn;h>f&&(f=h)}return f},a=l=>{l>o&&(o=l)},c=e._zod.def,u=c.type;switch(u){case"object":{let l=Ir(c);a(l?i(l,!0):ss),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let l of c.items)s(l);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let l of c.options)s(l);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let l=c._cachedInner??(r?e._zod.innerType:void 0);a(l?is(l,t,!1):ss);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let l in c){let d=Object.getOwnPropertyDescriptor(c,l);if(!d||d.get)continue;let f=d.value;if(!(!f||typeof f!="object")){if(f._zod)s(f);else if(Array.isArray(f))for(let p of f)s(p)}}}return t.delete(e),Gb(e,o)}function Gb(e,t){return t!==ss&&Yp.set(e,t===wn),t}function Vb(e,t){let r=e.buckets.get(t);return r||(r=new WeakMap,e.buckets.set(t,r)),r}var ns,os=[],Yb={alloc(e,t,r){let n=ns;if(!n)return r;ns=void 0;let o={value:r,issues:null};return n.set(t.value,o),os.push(o),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,n=(o,s)=>{if(s.direction!=="backward"&&Jb(s,o.value))throw new La;return r(o,s)};e._zod.parse=n,e._zod.run===r&&(e._zod.run=n)})},attach(e){var t;let r,n=!1,o,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let i=e._zod.parse,a=(c,u)=>{if(r===void 0){let y=is(e,new Set,!1);if(y===bn)return e._zod.parse=i,e._zod.run===a&&(e._zod.run=i),i(c,u);y===wn||n?r=!0:n=!0}let l=c.value;if(!Vp(l))return i(c,u);let d=u[ja];d||(d={buckets:new WeakMap,backEdges:void 0},u[ja]=d);let f;o===u?f=s:(f=Vb(d,e),o=u,s=f);let p=f.get(l);if(p)return c.value=p.value,p.issues?p.issues.length&&c.issues.push(...Na(p.issues)):(c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(p.value)),c;ns=f;let m=os.length,h=i(c,u);ns=void 0;let g=os.length>m?os.pop():void 0;return h instanceof Promise?h.then(y=>(g&&(g.issues=y.issues.length?Na(y.issues):Gp),y)):(g&&(g.issues=h.issues.length?Na(h.issues):Gp),h)};e._zod.parse=a,e._zod.run===i&&(e._zod.run=a)})}};function Jp(){return Yb}function Jb(e,t){let r=e[ja]?.backEdges;return r!==void 0&&Vp(t)&&r.has(t)}var Xb=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};function o(s,i){return s==="number"&&typeof i=="number"&&!Number.isFinite(i)?String(i):n[s]??s}return s=>{switch(s.code){case"invalid_type":{let i=o(s.expected),a=ya(s.input),c=o(a,s.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":return s.values.length===1?`Invalid input: expected ${jo(s.values[0])}`:`Invalid option: expected one of ${No(s.values,"|")}`;case"too_big":{let i=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);return a?`Too big: expected ${s.origin??"value"} to have ${i}${s.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${s.origin??"value"} to be ${i}${s.maximum.toString()}`}case"too_small":{let i=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);return a?`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${a.unit}`:`Too small: expected ${s.origin} to be ${i}${s.minimum.toString()}`}case"invalid_format":{let i=s;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${r[i.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${No(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":return s.options&&Array.isArray(s.options)&&s.options.length>0?`Invalid discriminator value. Expected ${s.options.map(a=>`'${a}'`).join(" | ")}`:s.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function Xp(){return{localeError:Xb()}}var Qp;var Ua=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let o={...n,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function Qb(){return new Ua}(Qp=globalThis).__zod_globalRegistry??(Qp.__zod_globalRegistry=Qb());var cr=globalThis.__zod_globalRegistry;function em(e){return e.checks&&(e.checks=[...e.checks]),e}function tm(e,t){return new e(em({type:"string",...$(t)}))}function rm(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...$(t)})}function nm(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...$(t)})}function om(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...$(t)})}function sm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...$(t)})}function im(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...$(t)})}function am(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...$(t)})}function cm(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...$(t)})}function um(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...$(t)})}function lm(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...$(t)})}function dm(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...$(t)})}function fm(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...$(t)})}function pm(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...$(t)})}function mm(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...$(t)})}function hm(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...$(t)})}function gm(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...$(t)})}function _m(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...$(t)})}function ym(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...$(t)})}function Sm(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...$(t)})}function Em(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...$(t)})}function bm(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...$(t)})}function wm(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...$(t)})}function vm(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...$(t)})}function as(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...$(t)})}function cs(e,t){return new e({type:"string",format:"date",check:"string_format",...$(t)})}function us(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...$(t)})}function ls(e,t){return new e({type:"string",format:"duration",check:"string_format",...$(t)})}function km(e,t){return new e(em({type:"number",checks:[],...$(t)}))}function xm(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...$(t)})}function Pm(e,t){return new e({type:"boolean",...$(t)})}function Tm(e,t){return new e({type:"null",...$(t)})}function $m(e){return new e({type:"unknown"})}function Rm(e,t){return new e({type:"never",...$(t)})}function ds(e,t){return new $a({check:"less_than",...$(t),value:e,inclusive:!1})}function vn(e,t){return new $a({check:"less_than",...$(t),value:e,inclusive:!0})}function fs(e,t){return new Ra({check:"greater_than",...$(t),value:e,inclusive:!1})}function kn(e,t){return new Ra({check:"greater_than",...$(t),value:e,inclusive:!0})}function ps(e,t){return new Pf({check:"multiple_of",...$(t),value:e})}function ms(e,t){return new $f({check:"max_length",...$(t),maximum:e})}function zr(e,t){return new Rf({check:"min_length",...$(t),minimum:e})}function hs(e,t){return new Af({check:"length_equals",...$(t),length:e})}function Fa(e,t){return new Of({check:"string_format",format:"regex",...$(t),pattern:e})}function qa(e){return new If({check:"string_format",format:"lowercase",...$(e)})}function Za(e){return new Cf({check:"string_format",format:"uppercase",...$(e)})}function Ha(e,t){return new Mf({check:"string_format",format:"includes",...$(t),includes:e})}function Wa(e,t){return new zf({check:"string_format",format:"starts_with",...$(t),prefix:e})}function Ba(e,t){return new Df({check:"string_format",format:"ends_with",...$(t),suffix:e})}function Zt(e){return new Nf({check:"overwrite",tx:e})}function Ka(e){return Zt(t=>t.normalize(e))}function Ga(){return Zt(e=>e.trim())}function Va(){return Zt(e=>e.toLowerCase())}function Ya(){return Zt(e=>e.toUpperCase())}function Ja(){return Zt(e=>pa(e))}function Am(e,t,r){return new e({type:"array",element:t,...$(r)})}function Om(e,t,r){let n=$(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function Im(e,t,r){return new e({type:"custom",check:"custom",fn:t,...$(r)})}function Cm(e,t){let r=ew(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(Cr(o,n.value,r._zod.def));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=n.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(Cr(s))}},e(n.value,n)),t);return r}function ew(e,t){let r=new me({check:"custom",...$(t)});return r._zod.check=e,r}function xn(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,n)&&He(e,n,r[n]);return e}function Qa(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??cr,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Rt(e,t,r,n,o){let s=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:n.path,message:o}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw new Error(o);return Object.assign(r,s),!0}function ue(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,r.schemaPath.includes(e)&&(s.cycle=r.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,l);else{let f=i.schema,p=t.processors[o.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);p(e,t,f,l)}let d=e._zod.parent;d&&(i.ref||(i.ref=d),ue(d,t,l),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&xn(i.schema,c),t.io==="input"&&Pe(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function Mm(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ec(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let n=new Map;for(let i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let c=n.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,i[0])}}let o=i=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(i[0])?.id,f=e.external.uri??(m=>m);if(d)return{ref:f(d)};let p=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=p,{defId:p,ref:`${f("__shared")}#/${a}/${Mm(p)}`}}let c="#",u=`${c}/${a}/`;if(i[1]===r&&!i[1].schema.id)return{ref:c};let l=i[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+Mm(l)}},s=i=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:u}=o(i);a.def={...a.schema},u&&(a.defId=u);let l=a.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let i of e.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
77
77
|
|
|
78
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=i[1];if(t===i[0]){s(i);continue}if(e.external){let u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}a.count>1&&e.reused==="ref"&&s(i)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Nm(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!="object")return;Nm(n);let o=Object.keys(n);if(o.length!==1||o[0]!=="type")return;let s=n.type;for(let i of Array.isArray(s)?s:[s]){if(typeof i!="string")return;r.includes(i)||r.push(i)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var Lm=new Set(["type","properties","required","additionalProperties"]),zm=["oneOf","anyOf"];function Dm(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Xa(e){let t=[];for(let s of e){if(typeof s!="object"||s.type!=="object")return null;for(let i in s)if(!Lm.has(i))return null;t.push(s)}let r={},n=new Set;for(let s of t){for(let i in s.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let a=[];for(let u of t){let l=u.properties?.[i]??Dm(u);l!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(l))||a.push(l))}let c=a.length===1?a[0]:Xa(a)??{allOf:a};We(r,i,c)}for(let i of s.required??[])n.add(i)}let o={type:"object",properties:r};if(n.size&&(o.required=[...n]),t.every(s=>s.additionalProperties===!1))o.additionalProperties=!1;else{let s=[];for(let i of t){let a=Dm(i);a&&!s.some(c=>JSON.stringify(c)===JSON.stringify(a))&&s.push(a)}s.length===1?o.additionalProperties=s[0]:s.length>1&&(o.additionalProperties={allOf:s})}return o}function tv(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Lm)if(o in e)return;let r=t.filter(o=>zm.some(s=>Array.isArray(o[s]))),n=null;if(!r.length)n=Xa(t);else{let o=r[0],s=zm.find(c=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let i=t.filter(c=>c!==o),a=o[s].map(c=>Xa([...i,c]));if(a.some(c=>!c))return;n={[s]:a}}n&&(delete e.allOf,xn(e,n))}function tc(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){n(d);let p=e.seen.get(d),m=p.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):xn(u,m),xn(u,l),a._zod.parent===d)for(let g in u)g==="$ref"||g==="allOf"||g in l||delete u[g];if(m.$ref&&p.def)for(let g in u)g==="$ref"||g==="allOf"||g in p.def&&JSON.stringify(u[g])===JSON.stringify(p.def[g])&&delete u[g]}let f=a._zod.parent;if(f&&f!==d){n(f);let p=e.seen.get(f);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(let m in u)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(u[m])===JSON.stringify(p.def[m])&&delete u[m]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Nm(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let d=a.get(l);d?d.push(u):a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])tv(u)}}let o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}xn(o,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;s!==void 0&&o.id===s&&delete o.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,We(i,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Pn(t,"input",e.processors),output:Pn(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Pe(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Pe(n.element,r);if(n.type==="set")return Pe(n.valueType,r);if(n.type==="lazy")return Pe(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return Pe(n.innerType,r);if(n.type==="intersection")return Pe(n.left,r)||Pe(n.right,r);if(n.type==="record"||n.type==="map")return Pe(n.keyType,r)||Pe(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Pe(n.in,r)||Pe(n.out,r);if(n.type==="object"){for(let o in n.shape)if(Pe(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(Pe(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(Pe(o,r))return!0;return!!(n.rest&&Pe(n.rest,r))}return!1}var jm=(e,t={})=>r=>{let n=Qa({...r,processors:t});return ue(e,n),ec(n,e),tc(n,e)},Pn=(e,t,r={})=>n=>{let{libraryOptions:o,target:s}=n??{},i=Qa({...o??{},target:s,io:t,processors:r});return ue(e,i),ec(i,e),tc(i,e)};var zr=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},Dr=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},Um=(e,t)=>{zr(e,"minimum",t),Dr(e,"maximum",t)},Wm=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Hm=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Bm=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},Km=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Fm=(e,t)=>zr(e,"minimum",t.minimum),qm=(e,t)=>Dr(e,"maximum",t.maximum),Zm=e=>(t,r)=>{Km(t,r.format);let[n,o]=e[r.format];zr(t,"minimum",n),Dr(t,"maximum",o)},rv={greater_than:(e,t)=>zr(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Dr(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Wm(e,t.value),number_format:Zm(mn),bigint_format:Zm(Uo),min_length:Fm,max_length:qm,length_equals:(e,t)=>Um(e,t.length),min_size:Fm,max_size:qm,size_equals:(e,t)=>Um(e,t.size),string_format:(e,t)=>{Km(e,t.format),t.pattern&&Hm(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Bm(e,t.mime)};function Ye(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of n)rv[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;o.minimum!==void 0&&zr(t,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&zr(t,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&Dr(t,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&Dr(t,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&Wm(t,o.multipleOf),o.format!==void 0&&(t.format??(t.format=o.format),o.format.includes("int")&&(t.isInt=!0)),o.mime&&Bm(t,o.mime);for(let s of o.patterns??[])Hm(t,s);return t}var nv={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ov=new Map([[Ia,pf],[rs,mf]]),Gm=e=>ov.get(e)??e,Vm=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u,laxFormat:l}=Ye(e);if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=nv[a]??a,o.format===""&&delete o.format,(a==="time"||l)&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let d=[...c].map(Gm);d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Ym=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=Ye(e);o.type=l?"integer":"number";let d=typeof u=="number"&&u>=(s??Number.NEGATIVE_INFINITY),f=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";if(d?p?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u:typeof s=="number"&&(o.minimum=s),f?p?(o.maximum=c,o.exclusiveMaximum=!0):o.exclusiveMaximum=c:typeof i=="number"&&(o.maximum=i),a){let m=new Set;for(let y of a)Number.isFinite(y)&&y!==0?m.add(Math.abs(y)):Rt(e,t,o,n,`A multipleOf divisor of ${y} cannot be represented in JSON Schema`);let[h,...g]=m;h!==void 0&&(o.multipleOf=h),g.length&&(o.allOf=[...o.allOf??[],...g.map(y=>({multipleOf:y}))])}},Jm=(e,t,r,n)=>{r.type="boolean"};var Xm=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var Qm=(e,t,r,n)=>{r.not={}};var eh=(e,t,r,n)=>{};var th=(e,t,r,n)=>{let o=e._zod.def,s=$r(o.entries);if(s.length===0){r.not={};return}s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},rh=(e,t,r,n)=>{let o=e._zod.def;if(o.values.length===0){r.not={};return}let s=[];for(let i of o.values)if(i===void 0){if(Rt(e,t,r,n,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(Rt(e,t,r,n,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){let i=s[0];r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[i]:r.const=i}else s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),s.every(i=>typeof i=="boolean")&&(r.type="boolean"),s.every(i=>i===null)&&(r.type="null"),r.enum=s};var nh=(e,t,r,n)=>{Rt(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var oh=(e,t,r,n)=>{Rt(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var sh=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:a}=Ye(e);typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=ue(s.element,t,{...n,path:[...n.path,"items"]})};function gs(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?gs(t.out):t.type==="catch"?gs(t.innerType):e._zod.optin}var ih=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&Rt(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in i)We(o.properties,u,ue(i[u],t,{...n,path:[...n.path,"properties",u]}));let c=[];for(let u of Object.keys(i)){let l=s.shape[u];(t.io==="input"?gs(l)===void 0:l._zod.optout===void 0)&&c.push(u)}c.length>0&&(o.required=c),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=ue(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},ah=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>ue(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=i:r.anyOf=i},ch=(e,t,r,n)=>{let o=e._zod.def,s=ue(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=ue(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];r.allOf=c,t.intersections.push(c)};function rc(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let m=e.get(t)?.def;if(!m)return t;let h=rc(e,m,r);return h===m?t:h}for(let m of["anyOf","oneOf"]){let h=t[m];if(!Array.isArray(h))continue;let g=h.map(y=>rc(e,y,r));g.some((y,b)=>y!==h[b])&&(t={...t,[m]:g})}let n=Array.isArray(t.type)?t.type:[t.type],o=!n.includes("string")&&n.some(m=>m==="number"||m==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!s?.some(m=>typeof m=="number"))return t;let{minimum:i,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(m=>typeof m=="number"?String(m):m):typeof p.const=="number"&&(p.const=String(p.const)),o&&(p.type="string",s||(p.pattern=(n.includes("number")?yn:Pa).source)),p}var nc=new WeakMap;function sv(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let r=new Map;for(let n of nc.get(e)??[]){let o=e.seen.get(n),s=(o?.def??o?.schema)?.propertyNames;if(!s||s===!0||r.has(s))continue;let i=rc(t,s,new Set);i!==s&&r.set(s,i)}if(r.size)for(let n of e.seen.values())for(let o of[n.schema,n.def]){let s=o&&r.get(o.propertyNames);s&&(o.propertyNames=s)}}var uh=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object";let i=s.keyType,a=Ye(i).patterns;if(s.mode==="loose"&&a&&a.size>0){let l=ue(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of a)We(o.patternProperties,Gm(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=ue(s.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=nc.get(t);l||(l=[],nc.set(t,l),t.deferred.push(()=>sv(t))),l.push(e)}o.additionalProperties=ue(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=i._zod.values,u=t.io==="input"&&gs(s.valueType)!==void 0;if(c&&!s.partial&&!u){let l=[...c].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l.map(String))}},lh=(e,t,r,n)=>{let o=e._zod.def,s=ue(o.innerType,t,n),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},dh=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},oc=Symbol();function fh(e,t,r,n,o){let s=!1,i=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(s=!0,null));return s?(Rt(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),oc):JSON.parse(i)}var ph=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=fh(o.defaultValue,e,t,r,n);i!==oc&&(r.default=i)},mh=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;let i=fh(o.defaultValue,e,t,r,n);i!==oc&&(r._prefault=i)},hh=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{Rt(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},gh=(e,t,r,n)=>{let o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;ue(i,t,n);let a=t.seen.get(e);a.ref=i},_h=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0};var sc=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType};function _s(e){return!!e._zod}function Wt(e,t){return _s(e)?wa(e,t):e.safeParse(t)}function ys(e){if(!e)return;let t;if(_s(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Ss(e){if(_s(e)){let s=e._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let r=e._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=e.value;if(n!==void 0)return n}var yh=new WeakSet([Object.prototype,Error.prototype]);function Es(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var hv=(e,t)=>{Ld.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);yh.has(r)||(yh.add(r),Es(r,"format",n=>o=>Fd(n,o)),Es(r,"flatten",n=>o=>Ud(n,o)),Es(r,"addIssue",n=>o=>{n.issues.push(o),n.message=JSON.stringify(n.issues,Rr,2)}),Es(r,"addIssues",n=>o=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,Rr,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))};var Be=E("ZodError",hv,void 0,{Parent:Error});var Sh=Ho(Be),Eh=Bo(Be),bh=_n(Be),vh=Ko(Be),wh=Zd(Be),kh=Wd(Be),xh=Hd(Be),Ph=Bd(Be),Th=Kd(Be),$h=Gd(Be),Rh=Vd(Be),Ah=Yd(Be);function _v(){ze.localeError||He(Xp())}function vs(){ze.memoizer||He({memoizer:Jp()})}var ie=E("ZodType",(e,t)=>(_v(),Q.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(R.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return it(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(iw(e,t))},superRefine(e,t){return this.check(aw(e,t))},overwrite(e){return this.check(Zt(e))},optional(){return se(this)},exactOptional(){return Gv(this)},nullable(){return Ch(this)},nullish(){return se(Ch(this))},nonoptional(e){return ew(this,e)},array(){return U(this)},or(e){return te([this,e])},and(e){return ws(this,e)},transform(e){return Mh(this,Uh(e))},default(e){return Jv(this,e)},prefault(e){return Qv(this,e)},catch(e){return rw(this,e)},pipe(e){return Mh(this,e)},readonly(){return sw(this)},describe(e){let t=this.clone();return cr.add(t,{description:e}),t},meta(...e){if(e.length===0)return cr.get(this);let t=this.clone();return cr.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return R.hide(this,"~standard",{...Oa(this),jsonSchema:{input:Pn(this,"input"),output:Pn(this,"output")}})},set"~standard"(e){R.own(this,"~standard",e)},parse:function e(t,r){return Sh(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Eh(this,t,r,{callee:e})},safeParse(e,t){return bh(this,e,t)},async safeParseAsync(e,t){return vh(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){R.own(this,"spa",e)},validate(e,t){return Go(this,e,t)},validateAsync(e,t){return Vo(this,e,t)},encode:function e(t,r){return wh(this,t,r,{callee:e})},decode:function e(t,r){return kh(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await xh(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Ph(this,t,r,{callee:e})},safeEncode(e,t){return Th(this,e,t)},safeDecode(e,t){return $h(this,e,t)},async safeEncodeAsync(e,t){return Rh(this,e,t)},async safeDecodeAsync(e,t){return Ah(this,e,t)},toJSONSchema(e){return jm(this,{})(e)},get description(){return cr.get(this)?.description},get _def(){return this._zod.def}}),zh=E("_ZodString",(e,t)=>{ts.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Vm(e,r,n,o)},R.derived({format:e=>Ye(e).format??null,minLength:e=>Ye(e).minimum??null,maxLength:e=>Ye(e).maximum??null},{regex(...e){return this.check(Fa(...e))},includes(...e){return this.check(Wa(...e))},startsWith(...e){return this.check(Ha(...e))},endsWith(...e){return this.check(Ba(...e))},min(...e){return this.check(Mr(...e))},max(...e){return this.check(ms(...e))},length(...e){return this.check(hs(...e))},nonempty(...e){return this.check(Mr(1,...e))},lowercase(e){return this.check(qa(e))},uppercase(e){return this.check(Za(e))},trim(){return this.check(Ga())},normalize(...e){return this.check(Ka(...e))},toLowerCase(){return this.check(Va())},toUpperCase(){return this.check(Ya())},slugify(){return this.check(Ja())}})),yv=E("ZodString",(e,t)=>{ts.init(e,t),zh.init(e,t)},{email(e){return this.check(rm(Sv,e))},url(e){return this.check(cm(bv,e))},jwt(e){return this.check(wm(Dv,e))},emoji(e){return this.check(um(vv,e))},guid(e){return this.check(nm(Ev,e))},uuid(e){return this.check(om(bs,e))},uuidv4(e){return this.check(sm(bs,e))},uuidv6(e){return this.check(im(bs,e))},uuidv7(e){return this.check(am(bs,e))},nanoid(e){return this.check(lm(wv,e))},cuid(e){return this.check(dm(kv,e))},cuid2(e){return this.check(fm(xv,e))},ulid(e){return this.check(pm(Pv,e))},base64(e){return this.check(Em(Cv,e))},base64url(e){return this.check(bm(Mv,e))},xid(e){return this.check(mm(Tv,e))},ksuid(e){return this.check(hm($v,e))},ipv4(e){return this.check(gm(Rv,e))},ipv6(e){return this.check(_m(Av,e))},cidrv4(e){return this.check(ym(Ov,e))},cidrv6(e){return this.check(Sm(Iv,e))},e164(e){return this.check(vm(zv,e))},datetime(e){return this.check(as($n,e))},date(e){return this.check(cs(Rn,e))},time(e){return this.check(us(An,e))},duration(e){return this.check(ls(On,e))}});function S(e){return tm(yv,e)}var ae=E("ZodStringFormat",(e,t)=>{ee.init(e,t),zh.init(e,t)}),$n=E("ZodISODateTime",(e,t)=>{lp.init(e,t),ae.init(e,t)}),Rn=E("ZodISODate",(e,t)=>{dp.init(e,t),ae.init(e,t)}),An=E("ZodISOTime",(e,t)=>{fp.init(e,t),ae.init(e,t)}),On=E("ZodISODuration",(e,t)=>{pp.init(e,t),ae.init(e,t)}),Sv=E("ZodEmail",(e,t)=>{Qf.init(e,t),ae.init(e,t)});var Ev=E("ZodGUID",(e,t)=>{Jf.init(e,t),ae.init(e,t)});var bs=E("ZodUUID",(e,t)=>{Xf.init(e,t),ae.init(e,t)});var bv=E("ZodURL",(e,t)=>{rp.init(e,t),ae.init(e,t)});var vv=E("ZodEmoji",(e,t)=>{np.init(e,t),ae.init(e,t)});var wv=E("ZodNanoID",(e,t)=>{op.init(e,t),ae.init(e,t)});var kv=E("ZodCUID",(e,t)=>{sp.init(e,t),ae.init(e,t)});var xv=E("ZodCUID2",(e,t)=>{ip.init(e,t),ae.init(e,t)});var Pv=E("ZodULID",(e,t)=>{ap.init(e,t),ae.init(e,t)});var Tv=E("ZodXID",(e,t)=>{cp.init(e,t),ae.init(e,t)});var $v=E("ZodKSUID",(e,t)=>{up.init(e,t),ae.init(e,t)});var Rv=E("ZodIPv4",(e,t)=>{mp.init(e,t),ae.init(e,t)});var Av=E("ZodIPv6",(e,t)=>{gp.init(e,t),ae.init(e,t)});var Ov=E("ZodCIDRv4",(e,t)=>{_p.init(e,t),ae.init(e,t)});var Iv=E("ZodCIDRv6",(e,t)=>{yp.init(e,t),ae.init(e,t)});var Cv=E("ZodBase64",(e,t)=>{Ep.init(e,t),ae.init(e,t)});var Mv=E("ZodBase64URL",(e,t)=>{bp.init(e,t),ae.init(e,t)});var zv=E("ZodE164",(e,t)=>{vp.init(e,t),ae.init(e,t)});var Dv=E("ZodJWT",(e,t)=>{wp.init(e,t),ae.init(e,t)});var Dh=E("ZodNumber",(e,t)=>{Ca.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ym(e,r,n,o),e.isFinite=!0},R.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=Ye(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=Ye(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=Ye(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>Ye(e).format??null},{gt(e,t){return this.check(fs(e,t))},gte(e,t){return this.check(kn(e,t))},min(e,t){return this.check(kn(e,t))},lt(e,t){return this.check(ds(e,t))},lte(e,t){return this.check(wn(e,t))},max(e,t){return this.check(wn(e,t))},int(e){return this.check(Oh(e))},safe(e){return this.check(Oh(e))},positive(e){return this.check(fs(0,e))},nonnegative(e){return this.check(kn(0,e))},negative(e){return this.check(ds(0,e))},nonpositive(e){return this.check(wn(0,e))},multipleOf(e,t){return this.check(ps(e,t))},step(e,t){return this.check(ps(e,t))},finite(){return this}}));function K(e){return km(Dh,e)}var Nv=E("ZodNumberFormat",(e,t)=>{kp.init(e,t),Dh.init(e,t)});function Oh(e){return xm(Nv,e)}var Lv=E("ZodBoolean",(e,t)=>{xp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Jm(e,r,n,o)});function fe(e){return Pm(Lv,e)}var jv=E("ZodNull",(e,t)=>{Pp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Xm(e,r,n,o)});function Nh(e){return Tm(jv,e)}var Uv=E("ZodUnknown",(e,t)=>{Tp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>eh(e,r,n,o)});function oe(){return $m(Uv)}var Fv=E("ZodNever",(e,t)=>{$p.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qm(e,r,n,o)});function qv(e){return Rm(Fv,e)}var Zv=E("ZodArray",(e,t)=>{vs(),Rp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sh(e,r,n,o),e.element=t.element},{min(e,t){return this.check(Mr(e,t))},nonempty(e){return this.check(Mr(1,e))},max(e,t){return this.check(ms(e,t))},length(e,t){return this.check(hs(e,t))},unwrap(){return this.element}});function U(e,t){return Am(Zv,e,t)}var Lh=E("ZodObject",(e,t)=>{vs(),Ip.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ih(e,r,n,o),R.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return De(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(R.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(R.mergeDefs(this._zod.def,{catchall:oe()}))},loose(){return this.clone(R.mergeDefs(this._zod.def,{catchall:oe()}))},strict(){return this.clone(R.mergeDefs(this._zod.def,{catchall:qv()}))},strip(){return this.clone(R.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return R.extend(this,e)},safeExtend(e){return R.safeExtend(this,e)},merge(e){return R.merge(this,e)},pick(e){return R.pick(this,e)},omit(e){return R.omit(this,e)},partial(...e){return R.partial(Fh,this,e[0])},exactPartial(...e){return R.partial(qh,this,e[0],"exactPartial")},required(...e){return R.required(Zh,this,e[0])}});function k(e,t){let r={type:"object",shape:e??{},...R.normalizeParams(t)};return new Lh(r)}function Te(e,t){return new Lh({type:"object",shape:e,catchall:oe(),...R.normalizeParams(t)})}var jh=E("ZodUnion",(e,t)=>{Ma.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ah(e,r,n,o),e.options=t.options});function te(e,t){return new jh({type:"union",options:e,...R.normalizeParams(t)})}var Wv=E("ZodDiscriminatedUnion",(e,t)=>{jh.init(e,t),Cp.init(e,t)});function ac(e,t,r){return new Wv({type:"union",options:t,discriminator:e,...R.normalizeParams(r)})}var Hv=E("ZodIntersection",(e,t)=>{Mp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ch(e,r,n,o)});function ws(e,t){return new Hv({type:"intersection",left:e,right:t})}var Ih=E("ZodRecord",(e,t)=>{vs(),zp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>uh(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function J(e,t,r){return!t||!t._zod?new Ih({type:"record",keyType:S(),valueType:e,...R.normalizeParams(t)}):new Ih({type:"record",keyType:e,valueType:t,...R.normalizeParams(r)})}var ic=E("ZodEnum",(e,t)=>{Dp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(n,o,s)=>th(e,n,o,s),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new ic({...t,checks:[],...R.normalizeParams(o),entries:s})},e.exclude=(n,o)=>{let s={...t.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new ic({...t,checks:[],...R.normalizeParams(o),entries:s})}});function De(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new ic({type:"enum",entries:r,...R.normalizeParams(t)})}var Bv=E("ZodLiteral",(e,t)=>{Np.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rh(e,r,n,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function P(e,t){return new Bv({type:"literal",values:Array.isArray(e)?e:[e],...R.normalizeParams(t)})}var Kv=E("ZodTransform",(e,t)=>{vs(),Lp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>oh(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Cr(e.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(R.issue(s,r.value,t));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=e),r.issues.push(R.issue(i))}};let o=t.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function Uh(e){return new Kv({type:"transform",transform:e})}var Fh=E("ZodOptional",(e,t)=>{za.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sc(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function se(e){return new Fh({type:"optional",innerType:e})}var qh=E("ZodExactOptional",(e,t)=>{jp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sc(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Gv(e){return new qh({type:"optional",innerType:e})}var Vv=E("ZodNullable",(e,t)=>{Up.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>lh(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Ch(e){return new Vv({type:"nullable",innerType:e})}var Yv=E("ZodDefault",(e,t)=>{Fp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ph(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Jv(e,t){return new Yv({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():R.shallowClone(t)}})}var Xv=E("ZodPrefault",(e,t)=>{qp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>mh(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Qv(e,t){return new Xv({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():R.shallowClone(t)}})}var Zh=E("ZodNonOptional",(e,t)=>{Zp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>dh(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ew(e,t){return new Zh({type:"nonoptional",innerType:e,...R.normalizeParams(t)})}var tw=E("ZodCatch",(e,t)=>{Wp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>hh(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function rw(e,t){return new tw({type:"catch",innerType:e,catchValue:typeof t=="function"?t:R.constantCatch(t)})}var Wh=E("ZodPipe",(e,t)=>{Da.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>gh(e,r,n,o),e.in=t.in,e.out=t.out});function Mh(e,t){return new Wh({type:"pipe",in:e,out:t})}var nw=E("ZodPreprocess",(e,t)=>{Wh.init(e,t),Hp.init(e,t)}),ow=E("ZodReadonly",(e,t)=>{Bp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>_h(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function sw(e){return new ow({type:"readonly",innerType:e})}var Hh=E("ZodCustom",(e,t)=>{Kp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>nh(e,r,n,o)});function Bh(e,t){return Om(Hh,e??(()=>!0),t)}function iw(e,t={}){return Im(Hh,e,t)}function aw(e,t){return Cm(e,t)}function cc(e,t){return new nw({type:"pipe",in:Uh(e),out:t})}var ks={};md(ks,{ZodISODate:()=>Rn,ZodISODateTime:()=>$n,ZodISODuration:()=>On,ZodISOTime:()=>An,date:()=>uw,datetime:()=>cw,duration:()=>dw,time:()=>lw});function cw(e){return as($n,e)}function uw(e){return cs(Rn,e)}function lw(e){return us(An,e)}function dw(e){return ls(On,e)}var lc="2025-11-25";var Kh=[lc,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Ht="io.modelcontextprotocol/related-task",Ps="2.0",de=Bh(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Gh=te([S(),K().int()]),Vh=S(),pz=Te({ttl:K().optional(),pollInterval:K().optional()}),fw=k({ttl:K().optional()}),pw=k({taskId:S()}),dc=Te({progressToken:Gh.optional(),[Ht]:pw.optional()}),Ke=k({_meta:dc.optional()}),In=Ke.extend({task:fw.optional()}),Yh=e=>In.safeParse(e).success,he=k({method:S(),params:Ke.loose().optional()}),Je=k({_meta:dc.optional()}),Xe=k({method:S(),params:Je.loose().optional()}),ge=Te({_meta:dc.optional()}),Ts=te([S(),K().int()]),Jh=k({jsonrpc:P(Ps),id:Ts,...he.shape}).strict(),fc=e=>Jh.safeParse(e).success,Xh=k({jsonrpc:P(Ps),...Xe.shape}).strict(),Qh=e=>Xh.safeParse(e).success,pc=k({jsonrpc:P(Ps),id:Ts,result:ge}).strict(),Cn=e=>pc.safeParse(e).success;var L;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(L||(L={}));var mc=k({jsonrpc:P(Ps),id:Ts.optional(),error:k({code:K().int(),message:S(),data:oe().optional()})}).strict();var eg=e=>mc.safeParse(e).success;var tg=te([Jh,Xh,pc,mc]),mz=te([pc,mc]),$s=ge.strict(),mw=Je.extend({requestId:Ts.optional(),reason:S().optional()}),Rs=Xe.extend({method:P("notifications/cancelled"),params:mw}),hw=k({src:S(),mimeType:S().optional(),sizes:U(S()).optional(),theme:De(["light","dark"]).optional()}),Mn=k({icons:U(hw).optional()}),Nr=k({name:S(),title:S().optional()}),rg=Nr.extend({...Nr.shape,...Mn.shape,version:S(),websiteUrl:S().optional(),description:S().optional()}),gw=ws(k({applyDefaults:fe().optional()}),J(S(),oe())),_w=cc(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ws(k({form:gw.optional(),url:de.optional()}),J(S(),oe()).optional())),yw=Te({list:de.optional(),cancel:de.optional(),requests:Te({sampling:Te({createMessage:de.optional()}).optional(),elicitation:Te({create:de.optional()}).optional()}).optional()}),Sw=Te({list:de.optional(),cancel:de.optional(),requests:Te({tools:Te({call:de.optional()}).optional()}).optional()}),Ew=k({experimental:J(S(),de).optional(),sampling:k({context:de.optional(),tools:de.optional()}).optional(),elicitation:_w.optional(),roots:k({listChanged:fe().optional()}).optional(),tasks:yw.optional(),extensions:J(S(),de).optional()}),bw=Ke.extend({protocolVersion:S(),capabilities:Ew,clientInfo:rg}),hc=he.extend({method:P("initialize"),params:bw});var vw=k({experimental:J(S(),de).optional(),logging:de.optional(),completions:de.optional(),prompts:k({listChanged:fe().optional()}).optional(),resources:k({subscribe:fe().optional(),listChanged:fe().optional()}).optional(),tools:k({listChanged:fe().optional()}).optional(),tasks:Sw.optional(),extensions:J(S(),de).optional()}),ww=ge.extend({protocolVersion:S(),capabilities:vw,serverInfo:rg,instructions:S().optional()}),gc=Xe.extend({method:P("notifications/initialized"),params:Je.optional()});var As=he.extend({method:P("ping"),params:Ke.optional()}),kw=k({progress:K(),total:se(K()),message:se(S())}),xw=k({...Je.shape,...kw.shape,progressToken:Gh}),Os=Xe.extend({method:P("notifications/progress"),params:xw}),Pw=Ke.extend({cursor:Vh.optional()}),zn=he.extend({params:Pw.optional()}),Dn=ge.extend({nextCursor:Vh.optional()}),Tw=De(["working","input_required","completed","failed","cancelled"]),Nn=k({taskId:S(),status:Tw,ttl:te([K(),Nh()]),createdAt:S(),lastUpdatedAt:S(),pollInterval:se(K()),statusMessage:se(S())}),Lr=ge.extend({task:Nn}),$w=Je.merge(Nn),Ln=Xe.extend({method:P("notifications/tasks/status"),params:$w}),Is=he.extend({method:P("tasks/get"),params:Ke.extend({taskId:S()})}),Cs=ge.merge(Nn),Ms=he.extend({method:P("tasks/result"),params:Ke.extend({taskId:S()})}),hz=ge.loose(),zs=zn.extend({method:P("tasks/list")}),Ds=Dn.extend({tasks:U(Nn)}),Ns=he.extend({method:P("tasks/cancel"),params:Ke.extend({taskId:S()})}),ng=ge.merge(Nn),og=k({uri:S(),mimeType:se(S()),_meta:J(S(),oe()).optional()}),sg=og.extend({text:S()}),_c=S().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),ig=og.extend({blob:_c}),jn=De(["user","assistant"]),jr=k({audience:U(jn).optional(),priority:K().min(0).max(1).optional(),lastModified:ks.datetime({offset:!0}).optional()}),ag=k({...Nr.shape,...Mn.shape,uri:S(),description:se(S()),mimeType:se(S()),size:se(K()),annotations:jr.optional(),_meta:se(Te({}))}),Rw=k({...Nr.shape,...Mn.shape,uriTemplate:S(),description:se(S()),mimeType:se(S()),annotations:jr.optional(),_meta:se(Te({}))}),Aw=zn.extend({method:P("resources/list")}),Ow=Dn.extend({resources:U(ag)}),Iw=zn.extend({method:P("resources/templates/list")}),Cw=Dn.extend({resourceTemplates:U(Rw)}),yc=Ke.extend({uri:S()}),Mw=yc,zw=he.extend({method:P("resources/read"),params:Mw}),Dw=ge.extend({contents:U(te([sg,ig]))}),Nw=Xe.extend({method:P("notifications/resources/list_changed"),params:Je.optional()}),Lw=yc,jw=he.extend({method:P("resources/subscribe"),params:Lw}),Uw=yc,Fw=he.extend({method:P("resources/unsubscribe"),params:Uw}),qw=Je.extend({uri:S()}),Zw=Xe.extend({method:P("notifications/resources/updated"),params:qw}),Ww=k({name:S(),description:se(S()),required:se(fe())}),Hw=k({...Nr.shape,...Mn.shape,description:se(S()),arguments:se(U(Ww)),_meta:se(Te({}))}),Bw=zn.extend({method:P("prompts/list")}),Kw=Dn.extend({prompts:U(Hw)}),Gw=Ke.extend({name:S(),arguments:J(S(),S()).optional()}),Vw=he.extend({method:P("prompts/get"),params:Gw}),Sc=k({type:P("text"),text:S(),annotations:jr.optional(),_meta:J(S(),oe()).optional()}),Ec=k({type:P("image"),data:_c,mimeType:S(),annotations:jr.optional(),_meta:J(S(),oe()).optional()}),bc=k({type:P("audio"),data:_c,mimeType:S(),annotations:jr.optional(),_meta:J(S(),oe()).optional()}),Yw=k({type:P("tool_use"),name:S(),id:S(),input:J(S(),oe()),_meta:J(S(),oe()).optional()}),Jw=k({type:P("resource"),resource:te([sg,ig]),annotations:jr.optional(),_meta:J(S(),oe()).optional()}),Xw=ag.extend({type:P("resource_link")}),vc=te([Sc,Ec,bc,Xw,Jw]),Qw=k({role:jn,content:vc}),e0=ge.extend({description:S().optional(),messages:U(Qw)}),t0=Xe.extend({method:P("notifications/prompts/list_changed"),params:Je.optional()}),r0=k({title:S().optional(),readOnlyHint:fe().optional(),destructiveHint:fe().optional(),idempotentHint:fe().optional(),openWorldHint:fe().optional()}),n0=k({taskSupport:De(["required","optional","forbidden"]).optional()}),cg=k({...Nr.shape,...Mn.shape,description:S().optional(),inputSchema:k({type:P("object"),properties:J(S(),de).optional(),required:U(S()).optional()}).catchall(oe()),outputSchema:k({type:P("object"),properties:J(S(),de).optional(),required:U(S()).optional()}).catchall(oe()).optional(),annotations:r0.optional(),execution:n0.optional(),_meta:J(S(),oe()).optional()}),wc=zn.extend({method:P("tools/list")}),o0=Dn.extend({tools:U(cg)}),Ls=ge.extend({content:U(vc).default([]),structuredContent:J(S(),oe()).optional(),isError:fe().optional()}),gz=Ls.or(ge.extend({toolResult:oe()})),s0=In.extend({name:S(),arguments:J(S(),oe()).optional()}),Un=he.extend({method:P("tools/call"),params:s0}),i0=Xe.extend({method:P("notifications/tools/list_changed"),params:Je.optional()}),_z=k({autoRefresh:fe().default(!0),debounceMs:K().int().nonnegative().default(300)}),Fn=De(["debug","info","notice","warning","error","critical","alert","emergency"]),a0=Ke.extend({level:Fn}),kc=he.extend({method:P("logging/setLevel"),params:a0}),c0=Je.extend({level:Fn,logger:S().optional(),data:oe()}),u0=Xe.extend({method:P("notifications/message"),params:c0}),l0=k({name:S().optional()}),d0=k({hints:U(l0).optional(),costPriority:K().min(0).max(1).optional(),speedPriority:K().min(0).max(1).optional(),intelligencePriority:K().min(0).max(1).optional()}),f0=k({mode:De(["auto","required","none"]).optional()}),p0=k({type:P("tool_result"),toolUseId:S().describe("The unique identifier for the corresponding tool call."),content:U(vc).default([]),structuredContent:k({}).loose().optional(),isError:fe().optional(),_meta:J(S(),oe()).optional()}),m0=ac("type",[Sc,Ec,bc]),xs=ac("type",[Sc,Ec,bc,Yw,p0]),h0=k({role:jn,content:te([xs,U(xs)]),_meta:J(S(),oe()).optional()}),g0=In.extend({messages:U(h0),modelPreferences:d0.optional(),systemPrompt:S().optional(),includeContext:De(["none","thisServer","allServers"]).optional(),temperature:K().optional(),maxTokens:K().int(),stopSequences:U(S()).optional(),metadata:de.optional(),tools:U(cg).optional(),toolChoice:f0.optional()}),_0=he.extend({method:P("sampling/createMessage"),params:g0}),qn=ge.extend({model:S(),stopReason:se(De(["endTurn","stopSequence","maxTokens"]).or(S())),role:jn,content:m0}),xc=ge.extend({model:S(),stopReason:se(De(["endTurn","stopSequence","maxTokens","toolUse"]).or(S())),role:jn,content:te([xs,U(xs)])}),y0=k({type:P("boolean"),title:S().optional(),description:S().optional(),default:fe().optional()}),S0=k({type:P("string"),title:S().optional(),description:S().optional(),minLength:K().optional(),maxLength:K().optional(),format:De(["email","uri","date","date-time"]).optional(),default:S().optional()}),E0=k({type:De(["number","integer"]),title:S().optional(),description:S().optional(),minimum:K().optional(),maximum:K().optional(),default:K().optional()}),b0=k({type:P("string"),title:S().optional(),description:S().optional(),enum:U(S()),default:S().optional()}),v0=k({type:P("string"),title:S().optional(),description:S().optional(),oneOf:U(k({const:S(),title:S()})),default:S().optional()}),w0=k({type:P("string"),title:S().optional(),description:S().optional(),enum:U(S()),enumNames:U(S()).optional(),default:S().optional()}),k0=te([b0,v0]),x0=k({type:P("array"),title:S().optional(),description:S().optional(),minItems:K().optional(),maxItems:K().optional(),items:k({type:P("string"),enum:U(S())}),default:U(S()).optional()}),P0=k({type:P("array"),title:S().optional(),description:S().optional(),minItems:K().optional(),maxItems:K().optional(),items:k({anyOf:U(k({const:S(),title:S()}))}),default:U(S()).optional()}),T0=te([x0,P0]),$0=te([w0,k0,T0]),R0=te([$0,y0,S0,E0]),A0=In.extend({mode:P("form").optional(),message:S(),requestedSchema:k({type:P("object"),properties:J(S(),R0),required:U(S()).optional()})}),O0=In.extend({mode:P("url"),message:S(),elicitationId:S(),url:S().url()}),I0=te([A0,O0]),C0=he.extend({method:P("elicitation/create"),params:I0}),M0=Je.extend({elicitationId:S()}),z0=Xe.extend({method:P("notifications/elicitation/complete"),params:M0}),Ur=ge.extend({action:De(["accept","decline","cancel"]),content:cc(e=>e===null?void 0:e,J(S(),te([S(),K(),fe(),U(S())])).optional())}),D0=k({type:P("ref/resource"),uri:S()});var N0=k({type:P("ref/prompt"),name:S()}),L0=Ke.extend({ref:te([N0,D0]),argument:k({name:S(),value:S()}),context:k({arguments:J(S(),S()).optional()}).optional()}),j0=he.extend({method:P("completion/complete"),params:L0});var U0=ge.extend({completion:Te({values:U(S()).max(100),total:se(K().int()),hasMore:se(fe())})}),F0=k({uri:S().startsWith("file://"),name:S().optional(),_meta:J(S(),oe()).optional()}),q0=he.extend({method:P("roots/list"),params:Ke.optional()}),Pc=ge.extend({roots:U(F0)}),Z0=Xe.extend({method:P("notifications/roots/list_changed"),params:Je.optional()}),yz=te([As,hc,j0,kc,Vw,Bw,Aw,Iw,zw,jw,Fw,Un,wc,Is,Ms,zs,Ns]),Sz=te([Rs,Os,gc,Z0,Ln]),Ez=te([$s,qn,xc,Ur,Pc,Cs,Ds,Lr]),bz=te([As,_0,C0,q0,Is,Ms,zs,Ns]),vz=te([Rs,Os,u0,Zw,Nw,i0,t0,Ln,z0]),wz=te([$s,ww,U0,e0,Kw,Ow,Cw,Dw,Ls,o0,Cs,Ds,Lr]),I=class e extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===L.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new uc(o.elicitations,r)}return new e(t,r,n)}},uc=class extends I{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(L.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};function Bt(e){return e==="completed"||e==="failed"||e==="cancelled"}var rD=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Tc(e){let r=ys(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Ss(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function $c(e,t){let r=Wt(e,t);if(!r.success)throw r.error;return r.data}var V0=6e4,js=class{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Rs,r=>{this._oncancel(r)}),this.setNotificationHandler(Os,r=>{this._onprogress(r)}),this.setRequestHandler(As,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Is,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new I(L.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(Ms,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,f=new I(d.error.code,d.error.message,d.error.data);l(f)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new I(L.InvalidParams,`Task not found: ${s}`);if(!Bt(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(Bt(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[Ht]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(zs,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 I(L.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Ns,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new I(L.InvalidParams,`Task not found: ${r.params.taskId}`);if(Bt(o.status))throw new I(L.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 I(L.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof I?o:new I(L.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,n,o,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),I.fromError(L.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),Cn(s)||eg(s)?this._onresponse(s):fc(s)?this._onrequest(s,i):Qh(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=I.fromError(L.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of t.values())n(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){let n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,o=this._transport,s=t.params?._meta?.[Ht]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:t.id,error:{code:L.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(t.id,i);let a=Yh(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:t.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let d={relatedRequestId:t.id};s&&(d.relatedTask={taskId:s}),await this.notification(l,d)},sendRequest:async(l,d,f)=>{if(i.signal.aborted)throw new I(L.ConnectionClosed,"Request was cancelled");let p={...f,relatedRequestId:t.id};s&&!p.relatedTask&&(p.relatedTask={taskId:s});let m=p.relatedTask?.taskId??s;return m&&c&&await c.updateTaskStatus(m,"input_required"),await this.request(l,d,p)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,u)).then(async l=>{if(i.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:t.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:t.id,error:{code:Number.isSafeInteger(l.code)?l.code:L.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(t.id)===i&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.params,o=Number(r),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(n)}_onresponse(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Cn(t))n(t);else{let i=new I(t.error.code,t.error.message,t.error.data);n(i)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if(Cn(t)&&t.result&&typeof t.result=="object"){let i=t.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,r))}}if(s||this._progressHandlers.delete(r),Cn(t))o(t);else{let i=I.fromError(t.error.code,t.error.message,t.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(t,r,n)}}catch(i){yield{type:"error",error:i instanceof I?i:new I(L.InternalError,String(i))}}return}let s;try{let i=await this.request(t,Lr,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new I(L.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},Bt(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new I(L.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new I(L.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 I?i:new I(L.InternalError,String(i))}}}request(t,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=b=>{l(b)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(b){d(b);return}n?.signal?.throwIfAborted();let f=this._requestMessageId++,p={...t,jsonrpc:"2.0",id:f};n?.onprogress&&(this._progressHandlers.set(f,n.onprogress),p.params={...t.params,_meta:{...t.params?._meta||{},progressToken:f}}),a&&(p.params={...p.params,task:a}),c&&(p.params={...p.params,_meta:{...p.params?._meta||{},[Ht]:c}});let m=b=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(b)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(O=>this._onerror(new Error(`Failed to send cancellation: ${O}`)));let v=b instanceof I?b:new I(L.RequestTimeout,String(b));l(v)};this._responseHandlers.set(f,b=>{if(!n?.signal?.aborted){if(b instanceof Error)return l(b);try{let v=Wt(r,b.result);v.success?u(v.data):l(v.error)}catch(v){l(v)}}}),n?.signal?.addEventListener("abort",()=>{m(n?.signal?.reason)});let h=n?.timeout??V0,g=()=>m(I.fromError(L.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(f,h,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let y=c?.taskId;if(y){let b=v=>{let O=this._responseHandlers.get(f);O?O(v):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,b),this._enqueueTaskMessage(y,{type:"request",message:p,timestamp:Date.now()}).catch(v=>{this._cleanupTimeout(f),l(v)})}else this._transport.send(p,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(b=>{this._cleanupTimeout(f),l(b)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},Cs,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},Ds,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},ng,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let n=r?.relatedTask?.taskId;if(n){let a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[Ht]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Ht]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...t,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[Ht]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(t,r){let n=Tc(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=$c(t,o);return Promise.resolve(r(i,s))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let n=Tc(t);this._notificationHandlers.set(n,o=>{let s=$c(t,o);return Promise.resolve(r(s))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,n,o)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(t,r);for(let o of n)if(o.type==="request"&&fc(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new I(L.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(t);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new I(L.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new I(L.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!t)throw new Error("No request provided");return await n.createTask(o,t.id,{method:t.method,params:t.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new I(L.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=Ln.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Bt(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 I(L.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Bt(a.status))throw new I(L.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=Ln.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Bt(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function ug(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function lg(e,t){let r={...e};for(let n in t){let o=n,s=t[o];if(s===void 0)continue;let i=r[o];ug(i)&&ug(s)?r[o]={...i,...s}:r[o]=s}return r}var uS=Lt(El(),1),lS=Lt(cS(),1);function iA(){let e=new uS.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,lS.default)(e),e}var vi=class{constructor(t){this._ajv=t??iA()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var wi=class{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}createMessageStream(t,r){let n=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let o=t.messages[t.messages.length-1],s=Array.isArray(o.content)?o.content:[o.content],i=s.some(l=>l.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],u=c.some(l=>l.type==="tool_use");if(i){if(s.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(f=>f.type==="tool_use").map(f=>f.id)),d=new Set(s.filter(f=>f.type==="tool_result").map(f=>f.toolUseId));if(l.size!==d.size||![...l].every(f=>d.has(f)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:t},qn,r)}elicitInputStream(t,r){let n=this._server.getClientCapabilities(),o=t.mode??"form";switch(o){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let s=o==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:s},Ur,r)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._server.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._server.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._server.cancelTask({taskId:t},r)}};function dS(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}function fS(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}var ki=class extends js{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Fn.options.map((n,o)=>[n,o])),this.isMessageIgnored=(n,o)=>{let s=this._loggingLevels.get(o);return s?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(s):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new vi,this.setRequestHandler(hc,n=>this._oninitialize(n)),this.setNotificationHandler(gc,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(kc,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=Fn.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new wi(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=lg(this._capabilities,t)}setRequestHandler(t,r){let o=ys(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let s=Ss(o);if(typeof s!="string")throw new Error("Schema method literal must be a string");if(s==="tools/call"){let a=async(c,u)=>{let l=Wt(Un,c);if(!l.success){let m=l.error instanceof Error?l.error.message:String(l.error);throw new I(L.InvalidParams,`Invalid tools/call request: ${m}`)}let{params:d}=l.data,f=await Promise.resolve(r(c,u));if(d.task){let m=Wt(Lr,f);if(!m.success){let h=m.error instanceof Error?m.error.message:String(m.error);throw new I(L.InvalidParams,`Invalid task creation result: ${h}`)}return m.data}let p=Wt(Ls,f);if(!p.success){let m=p.error instanceof Error?p.error.message:String(p.error);throw new I(L.InvalidParams,`Invalid tools/call result: ${m}`)}return p.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){fS(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&dS(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let r=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:Kh.includes(r)?r:lc,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},$s)}async createMessage(t,r){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let n=t.messages[t.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],s=o.some(u=>u.type==="tool_result"),i=t.messages.length>1?t.messages[t.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],c=a.some(u=>u.type==="tool_use");if(s){if(o.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(o.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return t.tools?this.request({method:"sampling/createMessage",params:t},xc,r):this.request({method:"sampling/createMessage",params:t},qn,r)}async elicitInput(t,r){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=t;return this.request({method:"elicitation/create",params:o},Ur,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=t.mode==="form"?t:{...t,mode:"form"},s=await this.request({method:"elicitation/create",params:o},Ur,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new I(L.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof I?i:new I(L.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return s}}}createElicitationCompletionNotifier(t,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:t}},r)}async listRoots(t,r){return this.request({method:"roots/list",params:t},Pc,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};var $l=Lt(require("node:process"),1);var aA=10*1024*1024,xi=class{constructor(t){this._maxBufferSize=t?.maxBufferSize??aA}append(t){if((this._buffer?.length??0)+t.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
|
|
78
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=i[1];if(t===i[0]){s(i);continue}if(e.external){let u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}a.count>1&&e.reused==="ref"&&s(i)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Nm(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!="object")return;Nm(n);let o=Object.keys(n);if(o.length!==1||o[0]!=="type")return;let s=n.type;for(let i of Array.isArray(s)?s:[s]){if(typeof i!="string")return;r.includes(i)||r.push(i)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var Lm=new Set(["type","properties","required","additionalProperties"]),zm=["oneOf","anyOf"];function Dm(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Xa(e){let t=[];for(let s of e){if(typeof s!="object"||s.type!=="object")return null;for(let i in s)if(!Lm.has(i))return null;t.push(s)}let r={},n=new Set;for(let s of t){for(let i in s.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let a=[];for(let u of t){let l=u.properties?.[i]??Dm(u);l!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(l))||a.push(l))}let c=a.length===1?a[0]:Xa(a)??{allOf:a};He(r,i,c)}for(let i of s.required??[])n.add(i)}let o={type:"object",properties:r};if(n.size&&(o.required=[...n]),t.every(s=>s.additionalProperties===!1))o.additionalProperties=!1;else{let s=[];for(let i of t){let a=Dm(i);a&&!s.some(c=>JSON.stringify(c)===JSON.stringify(a))&&s.push(a)}s.length===1?o.additionalProperties=s[0]:s.length>1&&(o.additionalProperties={allOf:s})}return o}function tw(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Lm)if(o in e)return;let r=t.filter(o=>zm.some(s=>Array.isArray(o[s]))),n=null;if(!r.length)n=Xa(t);else{let o=r[0],s=zm.find(c=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let i=t.filter(c=>c!==o),a=o[s].map(c=>Xa([...i,c]));if(a.some(c=>!c))return;n={[s]:a}}n&&(delete e.allOf,xn(e,n))}function tc(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){n(d);let p=e.seen.get(d),m=p.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):xn(u,m),xn(u,l),a._zod.parent===d)for(let g in u)g==="$ref"||g==="allOf"||g in l||delete u[g];if(m.$ref&&p.def)for(let g in u)g==="$ref"||g==="allOf"||g in p.def&&JSON.stringify(u[g])===JSON.stringify(p.def[g])&&delete u[g]}let f=a._zod.parent;if(f&&f!==d){n(f);let p=e.seen.get(f);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(let m in u)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(u[m])===JSON.stringify(p.def[m])&&delete u[m]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Nm(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let d=a.get(l);d?d.push(u):a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])tw(u)}}let o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}xn(o,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;s!==void 0&&o.id===s&&delete o.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,He(i,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Pn(t,"input",e.processors),output:Pn(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Pe(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Pe(n.element,r);if(n.type==="set")return Pe(n.valueType,r);if(n.type==="lazy")return Pe(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return Pe(n.innerType,r);if(n.type==="intersection")return Pe(n.left,r)||Pe(n.right,r);if(n.type==="record"||n.type==="map")return Pe(n.keyType,r)||Pe(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Pe(n.in,r)||Pe(n.out,r);if(n.type==="object"){for(let o in n.shape)if(Pe(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(Pe(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(Pe(o,r))return!0;return!!(n.rest&&Pe(n.rest,r))}return!1}var jm=(e,t={})=>r=>{let n=Qa({...r,processors:t});return ue(e,n),ec(n,e),tc(n,e)},Pn=(e,t,r={})=>n=>{let{libraryOptions:o,target:s}=n??{},i=Qa({...o??{},target:s,io:t,processors:r});return ue(e,i),ec(i,e),tc(i,e)};var Dr=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},Nr=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},Um=(e,t)=>{Dr(e,"minimum",t),Nr(e,"maximum",t)},Hm=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Wm=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Bm=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},Km=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Fm=(e,t)=>Dr(e,"minimum",t.minimum),qm=(e,t)=>Nr(e,"maximum",t.maximum),Zm=e=>(t,r)=>{Km(t,r.format);let[n,o]=e[r.format];Dr(t,"minimum",n),Nr(t,"maximum",o)},rw={greater_than:(e,t)=>Dr(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Nr(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Hm(e,t.value),number_format:Zm(mn),bigint_format:Zm(Uo),min_length:Fm,max_length:qm,length_equals:(e,t)=>Um(e,t.length),min_size:Fm,max_size:qm,size_equals:(e,t)=>Um(e,t.size),string_format:(e,t)=>{Km(e,t.format),t.pattern&&Wm(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Bm(e,t.mime)};function Ye(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of n)rw[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;o.minimum!==void 0&&Dr(t,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&Dr(t,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&Nr(t,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&Nr(t,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&Hm(t,o.multipleOf),o.format!==void 0&&(t.format??(t.format=o.format),o.format.includes("int")&&(t.isInt=!0)),o.mime&&Bm(t,o.mime);for(let s of o.patterns??[])Wm(t,s);return t}var nw={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ow=new Map([[Ia,pf],[rs,mf]]),Gm=e=>ow.get(e)??e,Vm=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u,laxFormat:l}=Ye(e);if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=nw[a]??a,o.format===""&&delete o.format,(a==="time"||l)&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let d=[...c].map(Gm);d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Ym=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=Ye(e);o.type=l?"integer":"number";let d=typeof u=="number"&&u>=(s??Number.NEGATIVE_INFINITY),f=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";if(d?p?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u:typeof s=="number"&&(o.minimum=s),f?p?(o.maximum=c,o.exclusiveMaximum=!0):o.exclusiveMaximum=c:typeof i=="number"&&(o.maximum=i),a){let m=new Set;for(let y of a)Number.isFinite(y)&&y!==0?m.add(Math.abs(y)):Rt(e,t,o,n,`A multipleOf divisor of ${y} cannot be represented in JSON Schema`);let[h,...g]=m;h!==void 0&&(o.multipleOf=h),g.length&&(o.allOf=[...o.allOf??[],...g.map(y=>({multipleOf:y}))])}},Jm=(e,t,r,n)=>{r.type="boolean"};var Xm=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var Qm=(e,t,r,n)=>{r.not={}};var eh=(e,t,r,n)=>{};var th=(e,t,r,n)=>{let o=e._zod.def,s=Rr(o.entries);if(s.length===0){r.not={};return}s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},rh=(e,t,r,n)=>{let o=e._zod.def;if(o.values.length===0){r.not={};return}let s=[];for(let i of o.values)if(i===void 0){if(Rt(e,t,r,n,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(Rt(e,t,r,n,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){let i=s[0];r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[i]:r.const=i}else s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),s.every(i=>typeof i=="boolean")&&(r.type="boolean"),s.every(i=>i===null)&&(r.type="null"),r.enum=s};var nh=(e,t,r,n)=>{Rt(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var oh=(e,t,r,n)=>{Rt(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var sh=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:a}=Ye(e);typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=ue(s.element,t,{...n,path:[...n.path,"items"]})};function gs(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?gs(t.out):t.type==="catch"?gs(t.innerType):e._zod.optin}var ih=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&Rt(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in i)He(o.properties,u,ue(i[u],t,{...n,path:[...n.path,"properties",u]}));let c=[];for(let u of Object.keys(i)){let l=s.shape[u];(t.io==="input"?gs(l)===void 0:l._zod.optout===void 0)&&c.push(u)}c.length>0&&(o.required=c),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=ue(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},ah=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>ue(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=i:r.anyOf=i},ch=(e,t,r,n)=>{let o=e._zod.def,s=ue(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=ue(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];r.allOf=c,t.intersections.push(c)};function rc(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let m=e.get(t)?.def;if(!m)return t;let h=rc(e,m,r);return h===m?t:h}for(let m of["anyOf","oneOf"]){let h=t[m];if(!Array.isArray(h))continue;let g=h.map(y=>rc(e,y,r));g.some((y,b)=>y!==h[b])&&(t={...t,[m]:g})}let n=Array.isArray(t.type)?t.type:[t.type],o=!n.includes("string")&&n.some(m=>m==="number"||m==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!s?.some(m=>typeof m=="number"))return t;let{minimum:i,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(m=>typeof m=="number"?String(m):m):typeof p.const=="number"&&(p.const=String(p.const)),o&&(p.type="string",s||(p.pattern=(n.includes("number")?yn:Pa).source)),p}var nc=new WeakMap;function sw(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let r=new Map;for(let n of nc.get(e)??[]){let o=e.seen.get(n),s=(o?.def??o?.schema)?.propertyNames;if(!s||s===!0||r.has(s))continue;let i=rc(t,s,new Set);i!==s&&r.set(s,i)}if(r.size)for(let n of e.seen.values())for(let o of[n.schema,n.def]){let s=o&&r.get(o.propertyNames);s&&(o.propertyNames=s)}}var uh=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object";let i=s.keyType,a=Ye(i).patterns;if(s.mode==="loose"&&a&&a.size>0){let l=ue(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of a)He(o.patternProperties,Gm(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=ue(s.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=nc.get(t);l||(l=[],nc.set(t,l),t.deferred.push(()=>sw(t))),l.push(e)}o.additionalProperties=ue(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=i._zod.values,u=t.io==="input"&&gs(s.valueType)!==void 0;if(c&&!s.partial&&!u){let l=[...c].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l.map(String))}},lh=(e,t,r,n)=>{let o=e._zod.def,s=ue(o.innerType,t,n),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},dh=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},oc=Symbol();function fh(e,t,r,n,o){let s=!1,i=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(s=!0,null));return s?(Rt(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),oc):JSON.parse(i)}var ph=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=fh(o.defaultValue,e,t,r,n);i!==oc&&(r.default=i)},mh=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;let i=fh(o.defaultValue,e,t,r,n);i!==oc&&(r._prefault=i)},hh=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{Rt(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},gh=(e,t,r,n)=>{let o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;ue(i,t,n);let a=t.seen.get(e);a.ref=i},_h=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0};var sc=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType};function _s(e){return!!e._zod}function Ht(e,t){return _s(e)?va(e,t):e.safeParse(t)}function ys(e){if(!e)return;let t;if(_s(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Ss(e){if(_s(e)){let s=e._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let r=e._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=e.value;if(n!==void 0)return n}var yh=new WeakSet([Object.prototype,Error.prototype]);function Es(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var hw=(e,t)=>{Ld.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);yh.has(r)||(yh.add(r),Es(r,"format",n=>o=>Fd(n,o)),Es(r,"flatten",n=>o=>Ud(n,o)),Es(r,"addIssue",n=>o=>{n.issues.push(o),n.message=JSON.stringify(n.issues,Ar,2)}),Es(r,"addIssues",n=>o=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,Ar,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))};var Be=E("ZodError",hw,void 0,{Parent:Error});var Sh=Wo(Be),Eh=Bo(Be),bh=_n(Be),wh=Ko(Be),vh=Zd(Be),kh=Hd(Be),xh=Wd(Be),Ph=Bd(Be),Th=Kd(Be),$h=Gd(Be),Rh=Vd(Be),Ah=Yd(Be);function _w(){ze.localeError||We(Xp())}function ws(){ze.memoizer||We({memoizer:Jp()})}var ie=E("ZodType",(e,t)=>(_w(),Q.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(R.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return it(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(iv(e,t))},superRefine(e,t){return this.check(av(e,t))},overwrite(e){return this.check(Zt(e))},optional(){return se(this)},exactOptional(){return Gw(this)},nullable(){return Ch(this)},nullish(){return se(Ch(this))},nonoptional(e){return ev(this,e)},array(){return U(this)},or(e){return te([this,e])},and(e){return vs(this,e)},transform(e){return Mh(this,Uh(e))},default(e){return Jw(this,e)},prefault(e){return Qw(this,e)},catch(e){return rv(this,e)},pipe(e){return Mh(this,e)},readonly(){return sv(this)},describe(e){let t=this.clone();return cr.add(t,{description:e}),t},meta(...e){if(e.length===0)return cr.get(this);let t=this.clone();return cr.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return R.hide(this,"~standard",{...Oa(this),jsonSchema:{input:Pn(this,"input"),output:Pn(this,"output")}})},set"~standard"(e){R.own(this,"~standard",e)},parse:function e(t,r){return Sh(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Eh(this,t,r,{callee:e})},safeParse(e,t){return bh(this,e,t)},async safeParseAsync(e,t){return wh(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){R.own(this,"spa",e)},validate(e,t){return Go(this,e,t)},validateAsync(e,t){return Vo(this,e,t)},encode:function e(t,r){return vh(this,t,r,{callee:e})},decode:function e(t,r){return kh(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await xh(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Ph(this,t,r,{callee:e})},safeEncode(e,t){return Th(this,e,t)},safeDecode(e,t){return $h(this,e,t)},async safeEncodeAsync(e,t){return Rh(this,e,t)},async safeDecodeAsync(e,t){return Ah(this,e,t)},toJSONSchema(e){return jm(this,{})(e)},get description(){return cr.get(this)?.description},get _def(){return this._zod.def}}),zh=E("_ZodString",(e,t)=>{ts.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Vm(e,r,n,o)},R.derived({format:e=>Ye(e).format??null,minLength:e=>Ye(e).minimum??null,maxLength:e=>Ye(e).maximum??null},{regex(...e){return this.check(Fa(...e))},includes(...e){return this.check(Ha(...e))},startsWith(...e){return this.check(Wa(...e))},endsWith(...e){return this.check(Ba(...e))},min(...e){return this.check(zr(...e))},max(...e){return this.check(ms(...e))},length(...e){return this.check(hs(...e))},nonempty(...e){return this.check(zr(1,...e))},lowercase(e){return this.check(qa(e))},uppercase(e){return this.check(Za(e))},trim(){return this.check(Ga())},normalize(...e){return this.check(Ka(...e))},toLowerCase(){return this.check(Va())},toUpperCase(){return this.check(Ya())},slugify(){return this.check(Ja())}})),yw=E("ZodString",(e,t)=>{ts.init(e,t),zh.init(e,t)},{email(e){return this.check(rm(Sw,e))},url(e){return this.check(cm(bw,e))},jwt(e){return this.check(vm(Dw,e))},emoji(e){return this.check(um(ww,e))},guid(e){return this.check(nm(Ew,e))},uuid(e){return this.check(om(bs,e))},uuidv4(e){return this.check(sm(bs,e))},uuidv6(e){return this.check(im(bs,e))},uuidv7(e){return this.check(am(bs,e))},nanoid(e){return this.check(lm(vw,e))},cuid(e){return this.check(dm(kw,e))},cuid2(e){return this.check(fm(xw,e))},ulid(e){return this.check(pm(Pw,e))},base64(e){return this.check(Em(Cw,e))},base64url(e){return this.check(bm(Mw,e))},xid(e){return this.check(mm(Tw,e))},ksuid(e){return this.check(hm($w,e))},ipv4(e){return this.check(gm(Rw,e))},ipv6(e){return this.check(_m(Aw,e))},cidrv4(e){return this.check(ym(Ow,e))},cidrv6(e){return this.check(Sm(Iw,e))},e164(e){return this.check(wm(zw,e))},datetime(e){return this.check(as($n,e))},date(e){return this.check(cs(Rn,e))},time(e){return this.check(us(An,e))},duration(e){return this.check(ls(On,e))}});function S(e){return tm(yw,e)}var ae=E("ZodStringFormat",(e,t)=>{ee.init(e,t),zh.init(e,t)}),$n=E("ZodISODateTime",(e,t)=>{lp.init(e,t),ae.init(e,t)}),Rn=E("ZodISODate",(e,t)=>{dp.init(e,t),ae.init(e,t)}),An=E("ZodISOTime",(e,t)=>{fp.init(e,t),ae.init(e,t)}),On=E("ZodISODuration",(e,t)=>{pp.init(e,t),ae.init(e,t)}),Sw=E("ZodEmail",(e,t)=>{Qf.init(e,t),ae.init(e,t)});var Ew=E("ZodGUID",(e,t)=>{Jf.init(e,t),ae.init(e,t)});var bs=E("ZodUUID",(e,t)=>{Xf.init(e,t),ae.init(e,t)});var bw=E("ZodURL",(e,t)=>{rp.init(e,t),ae.init(e,t)});var ww=E("ZodEmoji",(e,t)=>{np.init(e,t),ae.init(e,t)});var vw=E("ZodNanoID",(e,t)=>{op.init(e,t),ae.init(e,t)});var kw=E("ZodCUID",(e,t)=>{sp.init(e,t),ae.init(e,t)});var xw=E("ZodCUID2",(e,t)=>{ip.init(e,t),ae.init(e,t)});var Pw=E("ZodULID",(e,t)=>{ap.init(e,t),ae.init(e,t)});var Tw=E("ZodXID",(e,t)=>{cp.init(e,t),ae.init(e,t)});var $w=E("ZodKSUID",(e,t)=>{up.init(e,t),ae.init(e,t)});var Rw=E("ZodIPv4",(e,t)=>{mp.init(e,t),ae.init(e,t)});var Aw=E("ZodIPv6",(e,t)=>{gp.init(e,t),ae.init(e,t)});var Ow=E("ZodCIDRv4",(e,t)=>{_p.init(e,t),ae.init(e,t)});var Iw=E("ZodCIDRv6",(e,t)=>{yp.init(e,t),ae.init(e,t)});var Cw=E("ZodBase64",(e,t)=>{Ep.init(e,t),ae.init(e,t)});var Mw=E("ZodBase64URL",(e,t)=>{bp.init(e,t),ae.init(e,t)});var zw=E("ZodE164",(e,t)=>{wp.init(e,t),ae.init(e,t)});var Dw=E("ZodJWT",(e,t)=>{vp.init(e,t),ae.init(e,t)});var Dh=E("ZodNumber",(e,t)=>{Ca.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ym(e,r,n,o),e.isFinite=!0},R.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=Ye(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=Ye(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=Ye(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>Ye(e).format??null},{gt(e,t){return this.check(fs(e,t))},gte(e,t){return this.check(kn(e,t))},min(e,t){return this.check(kn(e,t))},lt(e,t){return this.check(ds(e,t))},lte(e,t){return this.check(vn(e,t))},max(e,t){return this.check(vn(e,t))},int(e){return this.check(Oh(e))},safe(e){return this.check(Oh(e))},positive(e){return this.check(fs(0,e))},nonnegative(e){return this.check(kn(0,e))},negative(e){return this.check(ds(0,e))},nonpositive(e){return this.check(vn(0,e))},multipleOf(e,t){return this.check(ps(e,t))},step(e,t){return this.check(ps(e,t))},finite(){return this}}));function K(e){return km(Dh,e)}var Nw=E("ZodNumberFormat",(e,t)=>{kp.init(e,t),Dh.init(e,t)});function Oh(e){return xm(Nw,e)}var Lw=E("ZodBoolean",(e,t)=>{xp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Jm(e,r,n,o)});function pe(e){return Pm(Lw,e)}var jw=E("ZodNull",(e,t)=>{Pp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Xm(e,r,n,o)});function Nh(e){return Tm(jw,e)}var Uw=E("ZodUnknown",(e,t)=>{Tp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>eh(e,r,n,o)});function oe(){return $m(Uw)}var Fw=E("ZodNever",(e,t)=>{$p.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qm(e,r,n,o)});function qw(e){return Rm(Fw,e)}var Zw=E("ZodArray",(e,t)=>{ws(),Rp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sh(e,r,n,o),e.element=t.element},{min(e,t){return this.check(zr(e,t))},nonempty(e){return this.check(zr(1,e))},max(e,t){return this.check(ms(e,t))},length(e,t){return this.check(hs(e,t))},unwrap(){return this.element}});function U(e,t){return Am(Zw,e,t)}var Lh=E("ZodObject",(e,t)=>{ws(),Ip.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ih(e,r,n,o),R.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return De(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(R.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(R.mergeDefs(this._zod.def,{catchall:oe()}))},loose(){return this.clone(R.mergeDefs(this._zod.def,{catchall:oe()}))},strict(){return this.clone(R.mergeDefs(this._zod.def,{catchall:qw()}))},strip(){return this.clone(R.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return R.extend(this,e)},safeExtend(e){return R.safeExtend(this,e)},merge(e){return R.merge(this,e)},pick(e){return R.pick(this,e)},omit(e){return R.omit(this,e)},partial(...e){return R.partial(Fh,this,e[0])},exactPartial(...e){return R.partial(qh,this,e[0],"exactPartial")},required(...e){return R.required(Zh,this,e[0])}});function k(e,t){let r={type:"object",shape:e??{},...R.normalizeParams(t)};return new Lh(r)}function Te(e,t){return new Lh({type:"object",shape:e,catchall:oe(),...R.normalizeParams(t)})}var jh=E("ZodUnion",(e,t)=>{Ma.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ah(e,r,n,o),e.options=t.options});function te(e,t){return new jh({type:"union",options:e,...R.normalizeParams(t)})}var Hw=E("ZodDiscriminatedUnion",(e,t)=>{jh.init(e,t),Cp.init(e,t)});function ac(e,t,r){return new Hw({type:"union",options:t,discriminator:e,...R.normalizeParams(r)})}var Ww=E("ZodIntersection",(e,t)=>{Mp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ch(e,r,n,o)});function vs(e,t){return new Ww({type:"intersection",left:e,right:t})}var Ih=E("ZodRecord",(e,t)=>{ws(),zp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>uh(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function J(e,t,r){return!t||!t._zod?new Ih({type:"record",keyType:S(),valueType:e,...R.normalizeParams(t)}):new Ih({type:"record",keyType:e,valueType:t,...R.normalizeParams(r)})}var ic=E("ZodEnum",(e,t)=>{Dp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(n,o,s)=>th(e,n,o,s),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new ic({...t,checks:[],...R.normalizeParams(o),entries:s})},e.exclude=(n,o)=>{let s={...t.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new ic({...t,checks:[],...R.normalizeParams(o),entries:s})}});function De(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new ic({type:"enum",entries:r,...R.normalizeParams(t)})}var Bw=E("ZodLiteral",(e,t)=>{Np.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rh(e,r,n,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function P(e,t){return new Bw({type:"literal",values:Array.isArray(e)?e:[e],...R.normalizeParams(t)})}var Kw=E("ZodTransform",(e,t)=>{ws(),Lp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>oh(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Mr(e.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(R.issue(s,r.value,t));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=e),r.issues.push(R.issue(i))}};let o=t.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function Uh(e){return new Kw({type:"transform",transform:e})}var Fh=E("ZodOptional",(e,t)=>{za.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sc(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function se(e){return new Fh({type:"optional",innerType:e})}var qh=E("ZodExactOptional",(e,t)=>{jp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sc(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Gw(e){return new qh({type:"optional",innerType:e})}var Vw=E("ZodNullable",(e,t)=>{Up.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>lh(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Ch(e){return new Vw({type:"nullable",innerType:e})}var Yw=E("ZodDefault",(e,t)=>{Fp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ph(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Jw(e,t){return new Yw({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():R.shallowClone(t)}})}var Xw=E("ZodPrefault",(e,t)=>{qp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>mh(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Qw(e,t){return new Xw({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():R.shallowClone(t)}})}var Zh=E("ZodNonOptional",(e,t)=>{Zp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>dh(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ev(e,t){return new Zh({type:"nonoptional",innerType:e,...R.normalizeParams(t)})}var tv=E("ZodCatch",(e,t)=>{Hp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>hh(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function rv(e,t){return new tv({type:"catch",innerType:e,catchValue:typeof t=="function"?t:R.constantCatch(t)})}var Hh=E("ZodPipe",(e,t)=>{Da.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>gh(e,r,n,o),e.in=t.in,e.out=t.out});function Mh(e,t){return new Hh({type:"pipe",in:e,out:t})}var nv=E("ZodPreprocess",(e,t)=>{Hh.init(e,t),Wp.init(e,t)}),ov=E("ZodReadonly",(e,t)=>{Bp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>_h(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function sv(e){return new ov({type:"readonly",innerType:e})}var Wh=E("ZodCustom",(e,t)=>{Kp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>nh(e,r,n,o)});function Bh(e,t){return Om(Wh,e??(()=>!0),t)}function iv(e,t={}){return Im(Wh,e,t)}function av(e,t){return Cm(e,t)}function cc(e,t){return new nv({type:"pipe",in:Uh(e),out:t})}var ks={};md(ks,{ZodISODate:()=>Rn,ZodISODateTime:()=>$n,ZodISODuration:()=>On,ZodISOTime:()=>An,date:()=>uv,datetime:()=>cv,duration:()=>dv,time:()=>lv});function cv(e){return as($n,e)}function uv(e){return cs(Rn,e)}function lv(e){return us(An,e)}function dv(e){return ls(On,e)}var lc="2025-11-25";var Kh=[lc,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Wt="io.modelcontextprotocol/related-task",Ps="2.0",de=Bh(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Gh=te([S(),K().int()]),Vh=S(),gz=Te({ttl:K().optional(),pollInterval:K().optional()}),fv=k({ttl:K().optional()}),pv=k({taskId:S()}),dc=Te({progressToken:Gh.optional(),[Wt]:pv.optional()}),Ke=k({_meta:dc.optional()}),In=Ke.extend({task:fv.optional()}),Yh=e=>In.safeParse(e).success,he=k({method:S(),params:Ke.loose().optional()}),Je=k({_meta:dc.optional()}),Xe=k({method:S(),params:Je.loose().optional()}),ge=Te({_meta:dc.optional()}),Ts=te([S(),K().int()]),Jh=k({jsonrpc:P(Ps),id:Ts,...he.shape}).strict(),fc=e=>Jh.safeParse(e).success,Xh=k({jsonrpc:P(Ps),...Xe.shape}).strict(),Qh=e=>Xh.safeParse(e).success,pc=k({jsonrpc:P(Ps),id:Ts,result:ge}).strict(),Cn=e=>pc.safeParse(e).success;var L;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(L||(L={}));var mc=k({jsonrpc:P(Ps),id:Ts.optional(),error:k({code:K().int(),message:S(),data:oe().optional()})}).strict();var eg=e=>mc.safeParse(e).success;var tg=te([Jh,Xh,pc,mc]),_z=te([pc,mc]),$s=ge.strict(),mv=Je.extend({requestId:Ts.optional(),reason:S().optional()}),Rs=Xe.extend({method:P("notifications/cancelled"),params:mv}),hv=k({src:S(),mimeType:S().optional(),sizes:U(S()).optional(),theme:De(["light","dark"]).optional()}),Mn=k({icons:U(hv).optional()}),Lr=k({name:S(),title:S().optional()}),rg=Lr.extend({...Lr.shape,...Mn.shape,version:S(),websiteUrl:S().optional(),description:S().optional()}),gv=vs(k({applyDefaults:pe().optional()}),J(S(),oe())),_v=cc(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,vs(k({form:gv.optional(),url:de.optional()}),J(S(),oe()).optional())),yv=Te({list:de.optional(),cancel:de.optional(),requests:Te({sampling:Te({createMessage:de.optional()}).optional(),elicitation:Te({create:de.optional()}).optional()}).optional()}),Sv=Te({list:de.optional(),cancel:de.optional(),requests:Te({tools:Te({call:de.optional()}).optional()}).optional()}),Ev=k({experimental:J(S(),de).optional(),sampling:k({context:de.optional(),tools:de.optional()}).optional(),elicitation:_v.optional(),roots:k({listChanged:pe().optional()}).optional(),tasks:yv.optional(),extensions:J(S(),de).optional()}),bv=Ke.extend({protocolVersion:S(),capabilities:Ev,clientInfo:rg}),hc=he.extend({method:P("initialize"),params:bv});var wv=k({experimental:J(S(),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:Sv.optional(),extensions:J(S(),de).optional()}),vv=ge.extend({protocolVersion:S(),capabilities:wv,serverInfo:rg,instructions:S().optional()}),gc=Xe.extend({method:P("notifications/initialized"),params:Je.optional()});var As=he.extend({method:P("ping"),params:Ke.optional()}),kv=k({progress:K(),total:se(K()),message:se(S())}),xv=k({...Je.shape,...kv.shape,progressToken:Gh}),Os=Xe.extend({method:P("notifications/progress"),params:xv}),Pv=Ke.extend({cursor:Vh.optional()}),zn=he.extend({params:Pv.optional()}),Dn=ge.extend({nextCursor:Vh.optional()}),Tv=De(["working","input_required","completed","failed","cancelled"]),Nn=k({taskId:S(),status:Tv,ttl:te([K(),Nh()]),createdAt:S(),lastUpdatedAt:S(),pollInterval:se(K()),statusMessage:se(S())}),jr=ge.extend({task:Nn}),$v=Je.merge(Nn),Ln=Xe.extend({method:P("notifications/tasks/status"),params:$v}),Is=he.extend({method:P("tasks/get"),params:Ke.extend({taskId:S()})}),Cs=ge.merge(Nn),Ms=he.extend({method:P("tasks/result"),params:Ke.extend({taskId:S()})}),yz=ge.loose(),zs=zn.extend({method:P("tasks/list")}),Ds=Dn.extend({tasks:U(Nn)}),Ns=he.extend({method:P("tasks/cancel"),params:Ke.extend({taskId:S()})}),ng=ge.merge(Nn),og=k({uri:S(),mimeType:se(S()),_meta:J(S(),oe()).optional()}),sg=og.extend({text:S()}),_c=S().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),ig=og.extend({blob:_c}),jn=De(["user","assistant"]),Ur=k({audience:U(jn).optional(),priority:K().min(0).max(1).optional(),lastModified:ks.datetime({offset:!0}).optional()}),ag=k({...Lr.shape,...Mn.shape,uri:S(),description:se(S()),mimeType:se(S()),size:se(K()),annotations:Ur.optional(),_meta:se(Te({}))}),Rv=k({...Lr.shape,...Mn.shape,uriTemplate:S(),description:se(S()),mimeType:se(S()),annotations:Ur.optional(),_meta:se(Te({}))}),Av=zn.extend({method:P("resources/list")}),Ov=Dn.extend({resources:U(ag)}),Iv=zn.extend({method:P("resources/templates/list")}),Cv=Dn.extend({resourceTemplates:U(Rv)}),yc=Ke.extend({uri:S()}),Mv=yc,zv=he.extend({method:P("resources/read"),params:Mv}),Dv=ge.extend({contents:U(te([sg,ig]))}),Nv=Xe.extend({method:P("notifications/resources/list_changed"),params:Je.optional()}),Lv=yc,jv=he.extend({method:P("resources/subscribe"),params:Lv}),Uv=yc,Fv=he.extend({method:P("resources/unsubscribe"),params:Uv}),qv=Je.extend({uri:S()}),Zv=Xe.extend({method:P("notifications/resources/updated"),params:qv}),Hv=k({name:S(),description:se(S()),required:se(pe())}),Wv=k({...Lr.shape,...Mn.shape,description:se(S()),arguments:se(U(Hv)),_meta:se(Te({}))}),Bv=zn.extend({method:P("prompts/list")}),Kv=Dn.extend({prompts:U(Wv)}),Gv=Ke.extend({name:S(),arguments:J(S(),S()).optional()}),Vv=he.extend({method:P("prompts/get"),params:Gv}),Sc=k({type:P("text"),text:S(),annotations:Ur.optional(),_meta:J(S(),oe()).optional()}),Ec=k({type:P("image"),data:_c,mimeType:S(),annotations:Ur.optional(),_meta:J(S(),oe()).optional()}),bc=k({type:P("audio"),data:_c,mimeType:S(),annotations:Ur.optional(),_meta:J(S(),oe()).optional()}),Yv=k({type:P("tool_use"),name:S(),id:S(),input:J(S(),oe()),_meta:J(S(),oe()).optional()}),Jv=k({type:P("resource"),resource:te([sg,ig]),annotations:Ur.optional(),_meta:J(S(),oe()).optional()}),Xv=ag.extend({type:P("resource_link")}),wc=te([Sc,Ec,bc,Xv,Jv]),Qv=k({role:jn,content:wc}),e0=ge.extend({description:S().optional(),messages:U(Qv)}),t0=Xe.extend({method:P("notifications/prompts/list_changed"),params:Je.optional()}),r0=k({title:S().optional(),readOnlyHint:pe().optional(),destructiveHint:pe().optional(),idempotentHint:pe().optional(),openWorldHint:pe().optional()}),n0=k({taskSupport:De(["required","optional","forbidden"]).optional()}),cg=k({...Lr.shape,...Mn.shape,description:S().optional(),inputSchema:k({type:P("object"),properties:J(S(),de).optional(),required:U(S()).optional()}).catchall(oe()),outputSchema:k({type:P("object"),properties:J(S(),de).optional(),required:U(S()).optional()}).catchall(oe()).optional(),annotations:r0.optional(),execution:n0.optional(),_meta:J(S(),oe()).optional()}),vc=zn.extend({method:P("tools/list")}),o0=Dn.extend({tools:U(cg)}),Ls=ge.extend({content:U(wc).default([]),structuredContent:J(S(),oe()).optional(),isError:pe().optional()}),Sz=Ls.or(ge.extend({toolResult:oe()})),s0=In.extend({name:S(),arguments:J(S(),oe()).optional()}),Un=he.extend({method:P("tools/call"),params:s0}),i0=Xe.extend({method:P("notifications/tools/list_changed"),params:Je.optional()}),Ez=k({autoRefresh:pe().default(!0),debounceMs:K().int().nonnegative().default(300)}),Fn=De(["debug","info","notice","warning","error","critical","alert","emergency"]),a0=Ke.extend({level:Fn}),kc=he.extend({method:P("logging/setLevel"),params:a0}),c0=Je.extend({level:Fn,logger:S().optional(),data:oe()}),u0=Xe.extend({method:P("notifications/message"),params:c0}),l0=k({name:S().optional()}),d0=k({hints:U(l0).optional(),costPriority:K().min(0).max(1).optional(),speedPriority:K().min(0).max(1).optional(),intelligencePriority:K().min(0).max(1).optional()}),f0=k({mode:De(["auto","required","none"]).optional()}),p0=k({type:P("tool_result"),toolUseId:S().describe("The unique identifier for the corresponding tool call."),content:U(wc).default([]),structuredContent:k({}).loose().optional(),isError:pe().optional(),_meta:J(S(),oe()).optional()}),m0=ac("type",[Sc,Ec,bc]),xs=ac("type",[Sc,Ec,bc,Yv,p0]),h0=k({role:jn,content:te([xs,U(xs)]),_meta:J(S(),oe()).optional()}),g0=In.extend({messages:U(h0),modelPreferences:d0.optional(),systemPrompt:S().optional(),includeContext:De(["none","thisServer","allServers"]).optional(),temperature:K().optional(),maxTokens:K().int(),stopSequences:U(S()).optional(),metadata:de.optional(),tools:U(cg).optional(),toolChoice:f0.optional()}),_0=he.extend({method:P("sampling/createMessage"),params:g0}),qn=ge.extend({model:S(),stopReason:se(De(["endTurn","stopSequence","maxTokens"]).or(S())),role:jn,content:m0}),xc=ge.extend({model:S(),stopReason:se(De(["endTurn","stopSequence","maxTokens","toolUse"]).or(S())),role:jn,content:te([xs,U(xs)])}),y0=k({type:P("boolean"),title:S().optional(),description:S().optional(),default:pe().optional()}),S0=k({type:P("string"),title:S().optional(),description:S().optional(),minLength:K().optional(),maxLength:K().optional(),format:De(["email","uri","date","date-time"]).optional(),default:S().optional()}),E0=k({type:De(["number","integer"]),title:S().optional(),description:S().optional(),minimum:K().optional(),maximum:K().optional(),default:K().optional()}),b0=k({type:P("string"),title:S().optional(),description:S().optional(),enum:U(S()),default:S().optional()}),w0=k({type:P("string"),title:S().optional(),description:S().optional(),oneOf:U(k({const:S(),title:S()})),default:S().optional()}),v0=k({type:P("string"),title:S().optional(),description:S().optional(),enum:U(S()),enumNames:U(S()).optional(),default:S().optional()}),k0=te([b0,w0]),x0=k({type:P("array"),title:S().optional(),description:S().optional(),minItems:K().optional(),maxItems:K().optional(),items:k({type:P("string"),enum:U(S())}),default:U(S()).optional()}),P0=k({type:P("array"),title:S().optional(),description:S().optional(),minItems:K().optional(),maxItems:K().optional(),items:k({anyOf:U(k({const:S(),title:S()}))}),default:U(S()).optional()}),T0=te([x0,P0]),$0=te([v0,k0,T0]),R0=te([$0,y0,S0,E0]),A0=In.extend({mode:P("form").optional(),message:S(),requestedSchema:k({type:P("object"),properties:J(S(),R0),required:U(S()).optional()})}),O0=In.extend({mode:P("url"),message:S(),elicitationId:S(),url:S().url()}),I0=te([A0,O0]),C0=he.extend({method:P("elicitation/create"),params:I0}),M0=Je.extend({elicitationId:S()}),z0=Xe.extend({method:P("notifications/elicitation/complete"),params:M0}),Fr=ge.extend({action:De(["accept","decline","cancel"]),content:cc(e=>e===null?void 0:e,J(S(),te([S(),K(),pe(),U(S())])).optional())}),D0=k({type:P("ref/resource"),uri:S()});var N0=k({type:P("ref/prompt"),name:S()}),L0=Ke.extend({ref:te([N0,D0]),argument:k({name:S(),value:S()}),context:k({arguments:J(S(),S()).optional()}).optional()}),j0=he.extend({method:P("completion/complete"),params:L0});var U0=ge.extend({completion:Te({values:U(S()).max(100),total:se(K().int()),hasMore:se(pe())})}),F0=k({uri:S().startsWith("file://"),name:S().optional(),_meta:J(S(),oe()).optional()}),q0=he.extend({method:P("roots/list"),params:Ke.optional()}),Pc=ge.extend({roots:U(F0)}),Z0=Xe.extend({method:P("notifications/roots/list_changed"),params:Je.optional()}),bz=te([As,hc,j0,kc,Vv,Bv,Av,Iv,zv,jv,Fv,Un,vc,Is,Ms,zs,Ns]),wz=te([Rs,Os,gc,Z0,Ln]),vz=te([$s,qn,xc,Fr,Pc,Cs,Ds,jr]),kz=te([As,_0,C0,q0,Is,Ms,zs,Ns]),xz=te([Rs,Os,u0,Zv,Nv,i0,t0,Ln,z0]),Pz=te([$s,vv,U0,e0,Kv,Ov,Cv,Dv,Ls,o0,Cs,Ds,jr]),I=class e extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===L.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new uc(o.elicitations,r)}return new e(t,r,n)}},uc=class extends I{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(L.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};function Bt(e){return e==="completed"||e==="failed"||e==="cancelled"}var sD=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Tc(e){let r=ys(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Ss(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function $c(e,t){let r=Ht(e,t);if(!r.success)throw r.error;return r.data}var V0=6e4,js=class{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Rs,r=>{this._oncancel(r)}),this.setNotificationHandler(Os,r=>{this._onprogress(r)}),this.setRequestHandler(As,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Is,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new I(L.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(Ms,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,f=new I(d.error.code,d.error.message,d.error.data);l(f)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new I(L.InvalidParams,`Task not found: ${s}`);if(!Bt(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(Bt(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[Wt]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(zs,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 I(L.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Ns,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new I(L.InvalidParams,`Task not found: ${r.params.taskId}`);if(Bt(o.status))throw new I(L.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 I(L.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof I?o:new I(L.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,n,o,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),I.fromError(L.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),Cn(s)||eg(s)?this._onresponse(s):fc(s)?this._onrequest(s,i):Qh(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=I.fromError(L.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of t.values())n(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){let n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,o=this._transport,s=t.params?._meta?.[Wt]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:t.id,error:{code:L.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(t.id,i);let a=Yh(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:t.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let d={relatedRequestId:t.id};s&&(d.relatedTask={taskId:s}),await this.notification(l,d)},sendRequest:async(l,d,f)=>{if(i.signal.aborted)throw new I(L.ConnectionClosed,"Request was cancelled");let p={...f,relatedRequestId:t.id};s&&!p.relatedTask&&(p.relatedTask={taskId:s});let m=p.relatedTask?.taskId??s;return m&&c&&await c.updateTaskStatus(m,"input_required"),await this.request(l,d,p)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,u)).then(async l=>{if(i.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:t.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:t.id,error:{code:Number.isSafeInteger(l.code)?l.code:L.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(t.id)===i&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.params,o=Number(r),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(n)}_onresponse(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Cn(t))n(t);else{let i=new I(t.error.code,t.error.message,t.error.data);n(i)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if(Cn(t)&&t.result&&typeof t.result=="object"){let i=t.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,r))}}if(s||this._progressHandlers.delete(r),Cn(t))o(t);else{let i=I.fromError(t.error.code,t.error.message,t.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(t,r,n)}}catch(i){yield{type:"error",error:i instanceof I?i:new I(L.InternalError,String(i))}}return}let s;try{let i=await this.request(t,jr,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new I(L.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},Bt(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new I(L.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new I(L.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 I?i:new I(L.InternalError,String(i))}}}request(t,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=b=>{l(b)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(b){d(b);return}n?.signal?.throwIfAborted();let f=this._requestMessageId++,p={...t,jsonrpc:"2.0",id:f};n?.onprogress&&(this._progressHandlers.set(f,n.onprogress),p.params={...t.params,_meta:{...t.params?._meta||{},progressToken:f}}),a&&(p.params={...p.params,task:a}),c&&(p.params={...p.params,_meta:{...p.params?._meta||{},[Wt]:c}});let m=b=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(b)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(O=>this._onerror(new Error(`Failed to send cancellation: ${O}`)));let w=b instanceof I?b:new I(L.RequestTimeout,String(b));l(w)};this._responseHandlers.set(f,b=>{if(!n?.signal?.aborted){if(b instanceof Error)return l(b);try{let w=Ht(r,b.result);w.success?u(w.data):l(w.error)}catch(w){l(w)}}}),n?.signal?.addEventListener("abort",()=>{m(n?.signal?.reason)});let h=n?.timeout??V0,g=()=>m(I.fromError(L.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(f,h,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let y=c?.taskId;if(y){let b=w=>{let O=this._responseHandlers.get(f);O?O(w):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,b),this._enqueueTaskMessage(y,{type:"request",message:p,timestamp:Date.now()}).catch(w=>{this._cleanupTimeout(f),l(w)})}else this._transport.send(p,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(b=>{this._cleanupTimeout(f),l(b)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},Cs,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},Ds,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},ng,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let n=r?.relatedTask?.taskId;if(n){let a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[Wt]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Wt]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...t,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[Wt]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(t,r){let n=Tc(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=$c(t,o);return Promise.resolve(r(i,s))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let n=Tc(t);this._notificationHandlers.set(n,o=>{let s=$c(t,o);return Promise.resolve(r(s))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,n,o)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(t,r);for(let o of n)if(o.type==="request"&&fc(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new I(L.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(t);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new I(L.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new I(L.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!t)throw new Error("No request provided");return await n.createTask(o,t.id,{method:t.method,params:t.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new I(L.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=Ln.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Bt(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 I(L.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Bt(a.status))throw new I(L.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=Ln.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Bt(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function ug(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function lg(e,t){let r={...e};for(let n in t){let o=n,s=t[o];if(s===void 0)continue;let i=r[o];ug(i)&&ug(s)?r[o]={...i,...s}:r[o]=s}return r}var uS=Lt(El(),1),lS=Lt(cS(),1);function iA(){let e=new uS.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,lS.default)(e),e}var wi=class{constructor(t){this._ajv=t??iA()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var vi=class{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}createMessageStream(t,r){let n=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let o=t.messages[t.messages.length-1],s=Array.isArray(o.content)?o.content:[o.content],i=s.some(l=>l.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],u=c.some(l=>l.type==="tool_use");if(i){if(s.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(f=>f.type==="tool_use").map(f=>f.id)),d=new Set(s.filter(f=>f.type==="tool_result").map(f=>f.toolUseId));if(l.size!==d.size||![...l].every(f=>d.has(f)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:t},qn,r)}elicitInputStream(t,r){let n=this._server.getClientCapabilities(),o=t.mode??"form";switch(o){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let s=o==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:s},Fr,r)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._server.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._server.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._server.cancelTask({taskId:t},r)}};function dS(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}function fS(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}var ki=class extends js{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Fn.options.map((n,o)=>[n,o])),this.isMessageIgnored=(n,o)=>{let s=this._loggingLevels.get(o);return s?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(s):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new wi,this.setRequestHandler(hc,n=>this._oninitialize(n)),this.setNotificationHandler(gc,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(kc,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=Fn.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new vi(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=lg(this._capabilities,t)}setRequestHandler(t,r){let o=ys(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let s=Ss(o);if(typeof s!="string")throw new Error("Schema method literal must be a string");if(s==="tools/call"){let a=async(c,u)=>{let l=Ht(Un,c);if(!l.success){let m=l.error instanceof Error?l.error.message:String(l.error);throw new I(L.InvalidParams,`Invalid tools/call request: ${m}`)}let{params:d}=l.data,f=await Promise.resolve(r(c,u));if(d.task){let m=Ht(jr,f);if(!m.success){let h=m.error instanceof Error?m.error.message:String(m.error);throw new I(L.InvalidParams,`Invalid task creation result: ${h}`)}return m.data}let p=Ht(Ls,f);if(!p.success){let m=p.error instanceof Error?p.error.message:String(p.error);throw new I(L.InvalidParams,`Invalid tools/call result: ${m}`)}return p.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){fS(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&dS(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let r=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:Kh.includes(r)?r:lc,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},$s)}async createMessage(t,r){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let n=t.messages[t.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],s=o.some(u=>u.type==="tool_result"),i=t.messages.length>1?t.messages[t.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],c=a.some(u=>u.type==="tool_use");if(s){if(o.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(o.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return t.tools?this.request({method:"sampling/createMessage",params:t},xc,r):this.request({method:"sampling/createMessage",params:t},qn,r)}async elicitInput(t,r){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=t;return this.request({method:"elicitation/create",params:o},Fr,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=t.mode==="form"?t:{...t,mode:"form"},s=await this.request({method:"elicitation/create",params:o},Fr,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new I(L.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof I?i:new I(L.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return s}}}createElicitationCompletionNotifier(t,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:t}},r)}async listRoots(t,r){return this.request({method:"roots/list",params:t},Pc,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};var $l=Lt(require("node:process"),1);var aA=10*1024*1024,xi=class{constructor(t){this._maxBufferSize=t?.maxBufferSize??aA}append(t){if((this._buffer?.length??0)+t.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
|
|
79
79
|
`);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),cA(r)}clear(){this._buffer=void 0}};function cA(e){return tg.parse(JSON.parse(e))}function pS(e){return JSON.stringify(e)+`
|
|
80
|
-
`}var Pi=class{constructor(t=$l.default.stdin,r=$l.default.stdout,n){this._stdin=t,this._stdout=r,this._started=!1,this._ondata=o=>{try{this._readBuffer.append(o),this.processReadBuffer()}catch(s){this.onerror?.(s),this.close().catch(()=>{})}},this._onerror=o=>{this.onerror?.(o)},this._readBuffer=new xi({maxBufferSize:n?.maxBufferSize})}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(r=>{let n=pS(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};var Ie=Lt(require("path"),1);var Ce=require("fs");var Rl=require("node:child_process");function Ti(e,t,r){return(0,Rl.spawn)(e,t??[],{windowsHide:!0,...r})}var uA=new Set([".cmd",".bat"]),lA=new Set([".exe",".com"]),Oj=new Set([...lA,...uA]);X();var Ae={HEALTH_CHECK:3e3,API_REQUEST:3e4,HOOK_READINESS_WAIT:1e4,POST_SPAWN_WAIT:15e3,READINESS_WAIT:3e4,PORT_IN_USE_WAIT:3e3,POWERSHELL_COMMAND:1e4,WINDOWS_MULTIPLIER:1.5};function tr(e){return process.platform==="win32"?Math.round(e*Ae.WINDOWS_MULTIPLIER):e}var $i=require("fs"),Al=require("path"),bo=require("os");Pr();var dA="security_alert",ht=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(tr(Ae.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-flash-latest",CLAUDE_MEM_GEMINI_RATE_LIMITING_ENABLED:"true",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_DATA_DIR:(0,Al.join)((0,bo.homedir)(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_CLAUDE_CONFIG_DIR:"",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_OBSERVATION_TYPES:"",CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS:"",CLAUDE_MEM_CONTEXT_FULL_COUNT:"0",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false",CLAUDE_MEM_CONTEXT_SHOW_TERMINAL_OUTPUT:"true",CLAUDE_MEM_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,Al.join)((0,bo.homedir)(),".claude-mem","transcript-watch.json"),CLAUDE_MEM_CODEX_TRANSCRIPT_INGESTION:"false",CLAUDE_MEM_MAX_CONCURRENT_AGENTS:"2",CLAUDE_MEM_OBSERVER_MAX_CONVERSATION_CHARS:"400000",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_CHROMA_MODE:"local",CLAUDE_MEM_CHROMA_HOST:"127.0.0.1",CLAUDE_MEM_CHROMA_PORT:"8000",CLAUDE_MEM_CHROMA_SSL:"false",CLAUDE_MEM_CHROMA_API_KEY:"",CLAUDE_MEM_CHROMA_TENANT:"default_tenant",CLAUDE_MEM_CHROMA_DATABASE:"default_database",CLAUDE_MEM_CHROMA_PREWARM_TIMEOUT_MS:"120000",CLAUDE_MEM_CHROMA_MAX_PENDING_MUTATIONS:"5000",CLAUDE_MEM_CLOUD_SYNC_TOKEN:"",CLAUDE_MEM_CLOUD_SYNC_USER_ID:"",CLAUDE_MEM_CLOUD_SYNC_HUB_URL:"",CLAUDE_MEM_CLOUD_SYNC_DEVICE_ID:"",CLAUDE_MEM_CLOUD_SYNC_DEVICE_NAME:(0,bo.hostname)(),CLAUDE_MEM_CLOUD_SYNC_WS:"true",CLAUDE_MEM_CLOUD_SYNC_CONTENT_BATCH_SIZE:"40",CLAUDE_MEM_CLOUD_SYNC_REQUEST_TIMEOUT_MS:"90000",CLAUDE_MEM_LLM_TIMEOUT_MS:"30000",CLAUDE_MEM_TV_TOKEN:"",CLAUDE_MEM_PRO_TRIAL_EMAIL:"",CLAUDE_MEM_PRO_TRIAL_AT:"",CLAUDE_MEM_PRO_TRIAL_STATE:"",CLAUDE_MEM_PRO_TRIAL_ENDS_AT:"",CLAUDE_MEM_PRO_PLAN:"",CLAUDE_MEM_PRO_FALLBACK_AT:"",CLAUDE_MEM_PRO_MEMORY_KEY:"",CLAUDE_MEM_PRO_MEMORY_BASE_URL:"",CLAUDE_MEM_PRO_MEMORY_MODEL:"",CLAUDE_MEM_TELEGRAM_ENABLED:"true",CLAUDE_MEM_TELEGRAM_BOT_TOKEN:"",CLAUDE_MEM_TELEGRAM_CHAT_ID:"",CLAUDE_MEM_TELEGRAM_WRAPUPS_ENABLED:"true",CLAUDE_MEM_TELEGRAM_OBSERVATION_ALERTS_ENABLED:"false",CLAUDE_MEM_TELEGRAM_WRAPUP_ROUTES:"{}",CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES:"security_alert,sensitive",CLAUDE_MEM_TELEGRAM_TRIGGER_CONCEPTS:"",CLAUDE_MEM_GROK_BOT_AWARENESS_ENABLED:"true",CLAUDE_MEM_GROK_BOT_AWARENESS_AGENT_IDS:"521e962d-2ec3-4488-bfbc-54d5209ce118,95601360-61f7-4fd9-bb3a-2c976b2b85c0",CLAUDE_MEM_GROK_BOT_AWARENESS_TRIGGER_TYPES:"decision,bugfix,security_alert,sensitive",CLAUDE_MEM_GROK_BOT_AWARENESS_TRIGGER_CONCEPTS:"",CLAUDE_MEM_GROK_BOT_INJECT_ENABLED:"true",CLAUDE_MEM_GROK_BOT_INJECT_AGENT_IDS:"*",CLAUDE_MEM_GROK_BOT_INJECT_TIER:"episode",CLAUDE_MEM_GROK_BOT_INJECT_WINDOW:"80",CLAUDE_MEM_GROK_BOT_INJECT_FALLBACK:"house",CLAUDE_MEM_GROK_BOT_INJECT_PLATFORM_SOURCE:"",CLAUDE_MEM_GROK_BOT_INJECT_PROJECTS_BY_AGENT:"",CLAUDE_MEM_GROK_BOT_INJECT_MAX_LINE_CHARS:"160",CLAUDE_MEM_GROK_BOT_INJECT_DEBOUNCE_MS:"1500",CLAUDE_MEM_CCS_ALIGN_ENABLED:"true",CLAUDE_MEM_CCS_ALIGN_VIEWER_IDS:"ccs-align",CLAUDE_MEM_CCS_ALIGN_TRIGGER_TYPES:"decision,bugfix,security_alert,sensitive",CLAUDE_MEM_CCS_ALIGN_PATCH_SHADOWS:"false",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 get(t){let r=process.env[t]??this.DEFAULTS[t];return t==="CLAUDE_MEM_WORKER_HOST"?this.normalizeWorkerHost(r):r}static normalizeWorkerHost(t){return t==="localhost"?"127.0.0.1":t}static finalizeSettings(t,r){let n=r?this.applyEnvOverrides(t):t;return n.CLAUDE_MEM_WORKER_HOST=this.normalizeWorkerHost(n.CLAUDE_MEM_WORKER_HOST),n}static getInt(t){let r=this.get(t);return parseInt(r,10)}static applyEnvOverrides(t){let r={...t};for(let n of Object.keys(this.DEFAULTS))process.env[n]!==void 0&&(r[n]=process.env[n]);return r}static loadFromFile(t,r=!0){try{if(!(0,$i.existsSync)(t)){let u=this.getAllDefaults();try{dn(t,u),console.warn("[SETTINGS] Created settings file with defaults:",t)}catch(l){console.warn("[SETTINGS] Failed to create settings file, using in-memory defaults:",t,l instanceof Error?l.message:String(l))}return this.finalizeSettings(u,r)}let n=(0,$i.readFileSync)(t,"utf-8"),o=or(n),s=o,i=o.env&&typeof o.env=="object"&&!Array.isArray(o.env),a=i&&Object.keys(o).some(u=>u!=="env");if(i&&(s=o.env,!a))try{dn(t,s),console.warn("[SETTINGS] Migrated settings file from nested to flat schema:",t)}catch(u){console.warn("[SETTINGS] Failed to auto-migrate settings file:",t,u instanceof Error?u.message:String(u))}if(s.CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES===dA){s={...s,CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES:this.DEFAULTS.CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES};try{dn(t,a?{...o,env:s}:s),console.warn("[SETTINGS] Migrated Telegram trigger types off the legacy default:",t)}catch(u){console.warn("[SETTINGS] Failed to migrate Telegram trigger types:",t,u instanceof Error?u.message:String(u))}}let c={...this.DEFAULTS};for(let u of Object.keys(this.DEFAULTS))s[u]!==void 0&&(c[u]=s[u]);return this.finalizeSettings(c,r)}catch(n){console.warn("[SETTINGS] Failed to load settings, using defaults:",t,n instanceof Error?n.message:String(n));let o=this.getAllDefaults();return this.finalizeSettings(o,r)}}};Ze();Ze();var Ri=null;function Ai(){return Ri!==null||(Ri=ht.loadFromFile(Do)),Ri}var vr=require("fs");X();var Dt=require("fs"),Dl=Lt(require("path"),1);X();var fA=["CLAUDECODE_","CLAUDE_CODE_"],pA=new Set(["CLAUDECODE","CLAUDE_CODE_SESSION","CLAUDE_CODE_ENTRYPOINT","MCP_SESSION_ID"]),mA=new Set(["HTTP_PROXY","HTTPS_PROXY","ALL_PROXY","NO_PROXY","http_proxy","https_proxy","all_proxy","no_proxy","npm_config_proxy","npm_config_https_proxy","npm_config_noproxy"]),hA=new Set(["CLAUDE_CODE_OAUTH_TOKEN","CLAUDE_CODE_GIT_BASH_PATH","CLAUDE_CODE_USE_BEDROCK","CLAUDE_CODE_USE_VERTEX","CLAUDE_CODE_USE_FOUNDRY","CLAUDE_CODE_SKIP_BEDROCK_AUTH","CLAUDE_CODE_SKIP_VERTEX_AUTH","CLAUDE_CODE_SKIP_FOUNDRY_AUTH","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",...mA]);function br(e=process.env){let t={};for(let[r,n]of Object.entries(e))if(n!==void 0){if(hA.has(r)){t[r]=n;continue}pA.has(r)||fA.some(o=>r.startsWith(o))||(t[r]=n)}return t}Ze();var Il=require("child_process"),hS=require("fs");X();var gA=5e3,mS=new Map,Ol=0;function _A(e){Ol+=1;let t=(0,Il.spawnSync)("powershell.exe",["-NoProfile","-NonInteractive","-Command",`(Get-CimInstance Win32_Process -Filter "ProcessId=${e}").CreationDate.ToString('yyyyMMddHHmmss.ffffff')`],{encoding:"utf-8",timeout:5e3,windowsHide:!0,env:{...br(process.env),LC_ALL:"C",LANG:"C"}});if(t.status===0){let r=t.stdout.trim();return r.length>0?r:null}return null}function yA(e,t=!1){if(!t){let n=mS.get(e);if(n&&Date.now()-n.capturedAtMs<gA)return n.token}let r=null;try{r=_A(e)}catch(n){_.debug("SYSTEM","captureProcessStartToken: powershell CIM lookup failed",{pid:e,error:n instanceof Error?n.message:String(n)}),r=null}return mS.set(e,{token:r,capturedAtMs:Date.now()}),r}function gS(e,t){if(!Number.isInteger(e)||e<=0)return null;if(process.platform==="linux"){Ol+=1;try{let r=(0,hS.readFileSync)(`/proc/${e}/stat`,"utf-8"),n=r.lastIndexOf(") ");if(n<0)return null;let s=r.slice(n+2).split(" ")[19];return s&&/^\d+$/.test(s)?s:null}catch(r){return _.debug("SYSTEM","captureProcessStartToken: /proc read failed",{pid:e,error:r instanceof Error?r.message:String(r)}),null}}if(process.platform==="win32")return yA(e,t);Ol+=1;try{let r=(0,Il.spawnSync)("ps",["-p",String(e),"-o","lstart="],{encoding:"utf-8",timeout:2e3,env:{...br(process.env),LC_ALL:"C",LANG:"C"}});if(r.status!==0)return null;let n=r.stdout.trim();return n.length>0?n:null}catch(r){return _.debug("SYSTEM","captureProcessStartToken: ps exec failed",{pid:e,error:r instanceof Error?r.message:String(r)}),null}}function rr(e){return gS(e,!1)}function zt(e,t){if(t===null)return!0;let r=gS(e,!0);return r===null?!0:r===t}var _S=require("child_process"),Ci=require("fs"),yS=require("util");X();var Cl=(0,yS.promisify)(_S.execFile),SA=128,EA=/not found|no running instance|no tasks/i,Oi=class extends Error{pid;constructor(t,r,n){super(r,n),this.name="ProcessTreeKillError",this.pid=t}};async function gt(e,t={}){let r=t.signalMode==="immediate",n=t.expectedStartToken!==void 0?t.expectedStartToken:rr(e),o=()=>zt(e,n);if(!o()){_.warn("PROCESS","Skipping tree-kill: root PID was reused since it was captured",{pid:e});return}if(_.debug("PROCESS",`Killing process tree rooted at PID ${e}`,{immediate:r}),process.platform==="win32"){try{await Cl("taskkill",["/PID",String(e),"/T","/F"],{timeout:5e3,windowsHide:!0})}catch(s){let i=s.code,a=String(s.stderr??""),c=s instanceof Error?s.message:String(s);if(i===SA||EA.test(`${a} ${c}`)){_.debug("PROCESS","taskkill reported the process was already gone",{pid:e});return}throw new Oi(e,`taskkill failed for PID ${e} (exit ${String(i)}): ${a.trim()||c}`,{cause:s})}return}try{let s=r?"SIGKILL":"SIGTERM",i=await Ii(e);for(let u of i){if(!zt(u.pid,u.startToken)){_.debug("PROCESS",`Skipping ${s}: descendant PID was reused since enumeration`,{pid:u.pid,rootPid:e});continue}try{process.kill(u.pid,s)}catch{}}if(o())try{process.kill(e,s)}catch(u){let l=u instanceof Error?u:new Error(String(u)),d=l.code;d!=="ESRCH"&&_.debug("PROCESS",`Failed to ${s} PID ${e}`,{code:d},l)}else _.warn("PROCESS","Skipping root signal: PID was reused during descendant enumeration",{pid:e,signal:s});r||await new Promise(u=>setTimeout(u,500));let a=o()?await Ii(e):[],c=new Map;for(let u of i)c.set(u.pid,u.startToken);for(let u of a)c.set(u.pid,u.startToken);for(let[u,l]of c){if(!zt(u,l)){_.debug("PROCESS","Skipping SIGKILL: descendant PID was reused since the scan",{pid:u,rootPid:e});continue}try{process.kill(u,"SIGKILL")}catch{}}if(!r&&o())try{process.kill(e,"SIGKILL")}catch{}}catch(s){throw new Oi(e,`tree-kill failed for PID ${e}: ${s instanceof Error?s.message:String(s)}`,{cause:s})}}async function bA(){return process.platform==="win32"?kA():process.platform==="linux"?vA():wA()}function vA(){let e=[],t;try{t=(0,Ci.readdirSync)("/proc")}catch(r){return _.warn("PROCESS","Cannot read /proc \u2014 tree-kill degrades to a single-PID kill",{error:r instanceof Error?r.message:String(r)}),e}for(let r of t){if(!/^\d+$/.test(r))continue;let n;try{n=(0,Ci.readFileSync)(`/proc/${r}/stat`,"utf-8")}catch{continue}let o=n.lastIndexOf(") ");if(o<0)continue;let s=n.slice(o+2).split(" "),i=Number.parseInt(s[1]??"",10),a=s[19];Number.isFinite(i)&&e.push({pid:Number.parseInt(r,10),ppid:i,startToken:a&&/^\d+$/.test(a)?a:null})}return e}async function wA(){let e;try{e=(await Cl("ps",["-eo","pid=,ppid=,lstart="],{timeout:1e4,maxBuffer:33554432,env:{...process.env,LC_ALL:"C",LANG:"C"}})).stdout}catch(r){return _.warn("PROCESS","Cannot enumerate the process table \u2014 tree-kill degrades to a single-PID kill",{error:r instanceof Error?r.message:String(r)}),[]}let t=[];for(let r of e.split(`
|
|
81
|
-
`)){let n=r.trim().match(/^(\d+)\s+(\d+)\s+(.*)$/);if(!n)continue;let o=n[3].trim();t.push({pid:Number.parseInt(n[1],10),ppid:Number.parseInt(n[2],10),startToken:o.length>0?o:null})}return t}async function
|
|
82
|
-
`)){let n=r.trim().match(/^(\d+)\s+(\d+)\s+(.*)$/);n&&t.push({pid:Number.parseInt(n[1],10),ppid:Number.parseInt(n[2],10),command:n[3].trim()})}return t}async function
|
|
83
|
-
`)}function CS(e,t,r={}){Ul().assertCanSpawn("worker daemon");let n=br({...process.env,CLAUDE_MEM_WORKER_PORT:String(t),...r}),o=Zl();if(!o){_.error("SYSTEM",RS);return}if(process.platform==="win32"){let l=
|
|
84
|
-
`)}async function qS(e,t={}){let r=VA(t);try{return await fetch(e,r)}catch(n){throw FS()&&JA(e,t,n),n}}async function Yl(e,t={},r){try{return await qS(e,{...t,signal:AbortSignal.timeout(r)})}catch(n){throw n instanceof DOMException&&n.name==="TimeoutError"?new Error(`Request timed out after ${r}ms`):n}}var ji=null,Ui=null,Fi=null,qi=null;function XA(){return Ie.default.join(ht.get("CLAUDE_MEM_DATA_DIR"),"settings.json")}function Jl(){return Fi!==null||(Fi=ht.loadFromFile(XA())),Fi}function jS(e,t){if(!e)return null;let r=parseInt(e,10);return Number.isFinite(r)&&r>=t.min&&r<=t.max?r:null}function QA(e,t,r){let n=process.env[e];if(n!==void 0){let i=jS(n,r);return i!==null?i:(_.warn("SYSTEM",`Invalid ${e}, using default`,{value:n,min:r.min,max:r.max}),t)}let o=Jl()[e],s=jS(o,r);return s!==null?s:(_.warn("SYSTEM",`Invalid ${e} in settings.json, using default`,{value:o,min:r.min,max:r.max}),t)}function Xl(){if(ji!==null)return ji;let e=Jl();return ji=parseInt(e.CLAUDE_MEM_WORKER_PORT,10),ji}function eO(){return Ui!==null||(Ui=Jl().CLAUDE_MEM_WORKER_HOST),Ui}function tO(){return qi!==null||(qi=QA("CLAUDE_MEM_API_TIMEOUT_MS",tr(Ae.API_REQUEST),GA)),qi}function rO(e){return e.startsWith("[")&&e.endsWith("]")?e:e.includes(":")?`[${e}]`:e}function nO(e){return`http://${rO(eO())}:${Xl()}${e}`}function Zi(e,t={}){let r=t.method??"GET",n=t.timeoutMs??tO(),o=nO(e),s={method:r};return t.headers&&(s.headers=t.headers),t.body&&(s.body=t.body),n>0?Yl(o,s,n):qS(o,s)}function ZS(e){let t=(0,Ce.existsSync)(Ie.default.join(e,"plugin","scripts"))?Ie.default.join(e,"plugin"):e;return Ie.default.join(t,"scripts","worker-service.cjs")}function oO(e,t){let r=d=>{let f=d.split("-")[0].split(".");return[parseInt(f[0],10)||0,parseInt(f[1],10)||0,parseInt(f[2],10)||0]},[n,o,s]=r(e),[i,a,c]=r(t);if(i!==n)return i-n;if(a!==o)return a-o;if(c!==s)return c-s;let u=e.includes("-")?1:0,l=t.includes("-")?1:0;return u!==l?u-l:e<t?1:e>t?-1:0}function sO(e=Ie.default.join(Ie.default.dirname(Ie.default.dirname(zo)),"cache","thedotmack","claude-mem")){try{return(0,Ce.readdirSync)(e).filter(t=>/^\d/.test(t)).map(t=>Ie.default.join(e,t)).filter(t=>{try{if(!(0,Ce.statSync)(t).isDirectory())return!1}catch{return!1}return!(0,Ce.existsSync)(Ie.default.join(t,".orphaned_at"))}).map(t=>({scriptPath:ZS(t),version:Ie.default.basename(t)}))}catch{return[]}}function US(e){try{let t=JSON.parse((0,Ce.readFileSync)(e,"utf-8"));return typeof t.version=="string"?t.version:null}catch(t){let r=t.code;return r!=="ENOENT"&&_.debug("SYSTEM","Could not read package version for worker resolution",{packageJsonPath:e,code:r}),null}}function iO(){let e=process.env.CLAUDE_MEM_WORKER_SCRIPT_PATH?.trim();if(e){if((0,Ce.existsSync)(e))return{scriptPath:e,version:null};_.debug("SYSTEM","Ignoring missing CLAUDE_MEM_WORKER_SCRIPT_PATH override",{override:e})}let t=[...sO(),{scriptPath:ZS(Ie.default.join(zo,"plugin")),version:US(Ie.default.join(zo,"package.json"))},{scriptPath:Ie.default.join(process.cwd(),"plugin","scripts","worker-service.cjs"),version:US(Ie.default.join(process.cwd(),"package.json"))}];return aO(t)}function aO(e){let t=e.filter(r=>(0,Ce.existsSync)(r.scriptPath));return t.length===0?null:(t.sort((r,n)=>r.version===null&&n.version===null?0:r.version===null?1:n.version===null?-1:oO(r.version,n.version)),t[0])}function WS(){return iO()?.scriptPath??null}var cO=1e3;var uO=5e3,GF=uO+cO;var Ql=Lt(require("path"),1),ot=require("fs");X();var BS=require("node:child_process"),KS=require("node:util");X();Ze();var GS=(0,KS.promisify)(BS.execFile),lO=/^(uv|uvx|python|chroma-mcp)(\.exe)?$/i;function HS(e){return lO.test(e.trim())}function dO(e,t){if(!e)return!1;let r=e.toLowerCase().replace(/\\/g,"/"),n=r.indexOf("--data-dir");if(n<0)return!1;let o=r.slice(n+10).trim();if(o.startsWith('"')){let i=o.indexOf('"',1);o=i<0?o.slice(1):o.slice(1,i)}let s=t.toLowerCase().replace(/\\/g,"/");return o===s||o.startsWith(s)&&o[s.length]==="/"}async function fO(){try{let e=await GS("powershell.exe",["-NoProfile","-NonInteractive","-Command","Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,Name,CommandLine,@{Name='StartToken';Expression={$_.CreationDate.ToString('yyyyMMddHHmmss.ffffff')}} | ConvertTo-Json -Compress"],{timeout:3e4,windowsHide:!0,maxBuffer:33554432}),t=JSON.parse(e.stdout),r=Array.isArray(t)?t:t===null?[]:[t],n=[];for(let o of r){let s=typeof o.Name=="string"?o.Name.trim():"";if(!s)continue;let i=typeof o.ProcessId=="number"?o.ProcessId:Number.parseInt(String(o.ProcessId),10),a=typeof o.ParentProcessId=="number"?o.ParentProcessId:Number.parseInt(String(o.ParentProcessId),10);!Number.isInteger(i)||!Number.isInteger(a)||n.push({pid:i,ppid:a,name:s,cmdline:typeof o.CommandLine=="string"?o.CommandLine:null,startToken:typeof o.StartToken=="string"&&o.StartToken.length>0?o.StartToken:null})}return n}catch(e){return _.warn("PROCESS","Cannot enumerate the Windows process table with names \u2014 ghost-port reclaim disabled",{error:e instanceof Error?e.message:String(e)}),null}}async function pO(e){try{let t=await GS("netstat",["-ano"],{timeout:15e3,windowsHide:!0,maxBuffer:16777216});return mO(t.stdout,e)}catch(t){return _.warn("PROCESS","netstat failed \u2014 ghost-port reclaim disabled for this attempt",{port:e,error:t instanceof Error?t.message:String(t)}),null}}function mO(e,t){let r=new Set,n=`:${t}`;for(let o of e.split(/\r?\n/)){let s=o.trim();if(!/^TCP\b/i.test(s))continue;let i=s.split(/\s+/);if(!i[1]?.endsWith(n)||i[3]!=="LISTENING")continue;let c=Number.parseInt(i[4]??"",10);Number.isInteger(c)&&c>0&&r.add(c)}return[...r]}async function VS(e,t={}){let r=t.isWin32??(()=>process.platform==="win32"),n=t.listOwners??pO,o=t.readTable??fO,s=t.killTree??((y,b)=>gt(y,b)),i=t.dataDir??(()=>ce);if(!r())return{reclaimed:!1,reason:"not-supported",killedPids:[]};let a=await n(e);if(a===null)return{reclaimed:!1,reason:"netstat-unreadable",killedPids:[]};if(a.length===0)return{reclaimed:!1,reason:"no-listener",killedPids:[]};let c=await o();if(c===null)return{reclaimed:!1,reason:"table-unreadable",killedPids:[]};if(a.filter(y=>pe(y)).length>0)return{reclaimed:!1,reason:"owner-alive",killedPids:[]};let l=new Map;for(let y of c){let b=l.get(y.ppid);b?b.push(y):l.set(y.ppid,[y])}let d=new Map,f=new Set,p=y=>{for(let b of l.get(y)??[])f.has(b.pid)||(f.add(b.pid),p(b.pid),HS(b.name)&&d.set(b.pid,b))};for(let y of a)p(y);let m=i();if(m)for(let y of c)d.has(y.pid)||HS(y.name)&&dO(y.cmdline,m)&&d.set(y.pid,y);if(d.size===0)return _.info("PROCESS","Ghost listener owner is dead but no chroma-sidecar descendants found",{port:e,deadOwners:a,processTableRows:c.length,dataDir:m??"(unresolved)"}),{reclaimed:!1,reason:"no-chroma-descendants",killedPids:[]};_.warn("PROCESS","Reclaiming ghost listener: killing dead worker's surviving chroma sidecar chain",{port:e,deadOwners:a,targets:[...d.values()].map(y=>({pid:y.pid,name:y.name}))});let h=[];for(let y of d.values())try{await s(y.pid,{expectedStartToken:y.startToken,signalMode:"immediate"}),h.push(y.pid)}catch(b){return _.error("PROCESS","Ghost-port reclaim tree-kill failed",{port:e,pid:y.pid},b instanceof Error?b:new Error(String(b))),{reclaimed:!1,reason:"kill-failed",killedPids:h}}let g=await n(e);return g!==null&&g.length===0?(_.info("PROCESS","Ghost listener reclaimed \u2014 port is free again",{port:e,killedPids:h}),{reclaimed:!0,killedPids:h}):(_.warn("PROCESS","Ghost-port reclaim killed the sidecar chain but the port is still bound",{port:e,killedPids:h,stillOwnedBy:g}),{reclaimed:!1,reason:"still-bound",killedPids:h})}var hO=120*1e3;function ed(){return Ql.default.join(ht.get("CLAUDE_MEM_DATA_DIR"),".worker-start-attempted")}function gO(){if(process.platform!=="win32")return!1;let e=ed();if(!(0,ot.existsSync)(e))return!1;try{let t=(0,ot.statSync)(e).mtimeMs;return Date.now()-t<hO}catch(t){return t instanceof Error?_.debug("SYSTEM","Could not stat worker spawn lock file",{},t):_.debug("SYSTEM","Could not stat worker spawn lock file",{error:String(t)}),!1}}function _O(){if(process.platform==="win32")try{let e=ed();(0,ot.mkdirSync)(Ql.default.dirname(e),{recursive:!0}),(0,ot.writeFileSync)(e,"","utf-8")}catch{}}function xo(){if(process.platform==="win32")try{let e=ed();(0,ot.existsSync)(e)&&(0,ot.unlinkSync)(e)}catch{}}var Wi;async function YS(e,t){if(Wi=void 0,!t)return _.error("SYSTEM","ensureWorkerStarted called with empty workerScriptPath \u2014 caller bug"),"dead";if(!(0,ot.existsSync)(t))return _.error("SYSTEM","ensureWorkerStarted: worker script not found at expected path \u2014 likely a partial install or build artifact missing",{workerScriptPath:t}),"dead";if(Ni()==="alive"){if(_.info("SYSTEM","Worker PID file points to a live process, skipping duplicate spawn"),await ko(e,wr(Ae.READINESS_WAIT)))return xo(),_.info("SYSTEM","Worker became ready while waiting on live PID"),"ready";let a=await wo(e,1e3),c=Ni()==="alive";return!a&&!c?(_.error("SYSTEM","Live PID disappeared before readiness endpoint became available"),"dead"):(_.warn("SYSTEM","Live PID detected but worker did not become ready before timeout"),"warming")}if(await wo(e,1e3)){xo();let i=await ko(e,wr(Ae.READINESS_WAIT));return i||_.warn("SYSTEM","Worker is alive but readiness timed out \u2014 proceeding anyway"),_.info("SYSTEM","Worker already running and healthy"),i?"ready":"warming"}if(await Bl(e)){if(_.info("SYSTEM","Port in use, waiting for worker to become healthy"),await wo(e,wr(Ae.PORT_IN_USE_WAIT))){xo();let c=await ko(e,wr(Ae.READINESS_WAIT));return _.info("SYSTEM","Worker is now healthy"),c?"ready":"warming"}let a=await VS(e);if(a.reclaimed)_.info("SYSTEM","Reclaimed ghost listener left by a dead worker \u2014 proceeding to spawn",{port:e,killedPids:a.killedPids}),xo();else return _.error("SYSTEM","Port in use but worker not responding to health checks",{port:e,reclaimReason:a.reason}),"dead"}if(gO())return _.warn("SYSTEM","Worker unavailable on Windows \u2014 skipping spawn (recent attempt failed within cooldown)"),"dead";let o=Kl(),s;try{if(o){if(_.info("SYSTEM","Starting worker daemon",{workerScriptPath:t}),_O(),s=CS(t,e),s===void 0)return _.error("SYSTEM","Failed to spawn worker daemon"),"dead"}else _.info("SYSTEM","Another launcher holds the spawn lock \u2014 skipping duplicate spawn and waiting for its worker");if(!await ko(e,wr(Ae.READINESS_WAIT))){let a=await wo(e,1e3),c=Ni()==="alive",u=s!==void 0&&s>0&&pe(s);return!a&&!c&&!u?o?(Wi=IS(t),_.error("SYSTEM","Worker exited before readiness endpoint became available",Wi?{bootFailure:Wi}:{}),"dead"):(_.error("SYSTEM","Spawn-lock holder never produced a live worker before readiness timed out"),"dead"):(_.warn("SYSTEM",o?"Worker spawned but readiness endpoint not responding within window":"Spawn-lock holder's worker not ready within window"),"warming")}return xo(),MS(),_.info("SYSTEM",o?"Worker started successfully":"Worker is up (started by another launcher)"),"ready"}finally{o&&Gl()}}var cn=require("node:fs/promises"),Po=require("node:path");var id=require("node:child_process"),Ee=require("node:fs"),Me=require("node:path"),ad=require("node:os"),nd=require("node:module");X();Ze();var zO={},od=typeof __CM_FILENAME__<"u"?(0,nd.createRequire)(__CM_FILENAME__):(0,nd.createRequire)(zO.url),yO={".js":"javascript",".mjs":"javascript",".cjs":"javascript",".jsx":"tsx",".ts":"typescript",".tsx":"tsx",".py":"python",".pyw":"python",".go":"go",".rs":"rust",".rb":"ruby",".java":"java",".c":"c",".h":"c",".cpp":"cpp",".cc":"cpp",".cxx":"cpp",".hpp":"cpp",".hh":"cpp",".kt":"kotlin",".kts":"kotlin",".swift":"swift",".php":"php",".lua":"lua",".scala":"scala",".sc":"scala",".sh":"bash",".bash":"bash",".zsh":"bash",".hs":"haskell",".zig":"zig",".css":"css",".scss":"scss",".toml":"toml",".yml":"yaml",".yaml":"yaml",".sql":"sql",".md":"markdown",".mdx":"markdown"};function rE(e){let t=e.slice(e.lastIndexOf("."));return yO[t]??"unknown"}var SO={javascript:"tree-sitter-javascript",typescript:"tree-sitter-typescript/typescript",tsx:"tree-sitter-typescript/tsx",python:"tree-sitter-python",go:"tree-sitter-go",rust:"tree-sitter-rust",ruby:"tree-sitter-ruby",java:"tree-sitter-java",c:"tree-sitter-c",cpp:"tree-sitter-cpp",kotlin:"tree-sitter-kotlin",swift:"tree-sitter-swift",php:"tree-sitter-php/php",lua:"@tree-sitter-grammars/tree-sitter-lua",scala:"tree-sitter-scala",bash:"tree-sitter-bash",haskell:"tree-sitter-haskell",zig:"@tree-sitter-grammars/tree-sitter-zig",css:"tree-sitter-css",scss:"tree-sitter-scss",toml:"@tree-sitter-grammars/tree-sitter-toml",yaml:"@tree-sitter-grammars/tree-sitter-yaml",sql:"@derekstride/tree-sitter-sql",markdown:"@tree-sitter-grammars/tree-sitter-markdown"},EO={markdown:"tree-sitter-markdown"};function nE(e){let t=SO[e];if(!t)return null;let r=EO[e];if(r){try{let n=od.resolve(t+"/package.json"),o=(0,Me.join)((0,Me.dirname)(n),r);if((0,Ee.existsSync)((0,Me.join)(o,"src")))return o}catch{}return null}try{let n=od.resolve(t+"/package.json");return(0,Me.dirname)(n)}catch{return null}}var bO={jsts:`
|
|
80
|
+
`}var Pi=class{constructor(t=$l.default.stdin,r=$l.default.stdout,n){this._stdin=t,this._stdout=r,this._started=!1,this._ondata=o=>{try{this._readBuffer.append(o),this.processReadBuffer()}catch(s){this.onerror?.(s),this.close().catch(()=>{})}},this._onerror=o=>{this.onerror?.(o)},this._readBuffer=new xi({maxBufferSize:n?.maxBufferSize})}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(r=>{let n=pS(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};var Ie=Lt(require("path"),1);var Ce=require("fs");var Rl=require("node:child_process");function Ti(e,t,r){return(0,Rl.spawn)(e,t??[],{windowsHide:!0,...r})}var uA=new Set([".cmd",".bat"]),lA=new Set([".exe",".com"]),Mj=new Set([...lA,...uA]);X();var Ae={HEALTH_CHECK:3e3,API_REQUEST:3e4,HOOK_READINESS_WAIT:1e4,POST_SPAWN_WAIT:15e3,READINESS_WAIT:3e4,PORT_IN_USE_WAIT:3e3,POWERSHELL_COMMAND:1e4,WINDOWS_MULTIPLIER:1.5};function tr(e){return process.platform==="win32"?Math.round(e*Ae.WINDOWS_MULTIPLIER):e}var $i=require("fs"),Al=require("path"),bo=require("os");Tr();var dA="security_alert",fA="sync-hub.black-pond-afbb.workers.dev",pA="https://sync.cmem.ai";function mA(e){if(typeof e!="string")return null;let t=e.trim();if(t.length===0)return null;try{if(new URL(t).hostname===fA)return pA}catch{return null}return null}var ht=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(tr(Ae.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-flash-latest",CLAUDE_MEM_GEMINI_RATE_LIMITING_ENABLED:"true",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_DATA_DIR:(0,Al.join)((0,bo.homedir)(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_CLAUDE_CONFIG_DIR:"",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_OBSERVATION_TYPES:"",CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS:"",CLAUDE_MEM_CONTEXT_FULL_COUNT:"0",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false",CLAUDE_MEM_CONTEXT_SHOW_TERMINAL_OUTPUT:"true",CLAUDE_MEM_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,Al.join)((0,bo.homedir)(),".claude-mem","transcript-watch.json"),CLAUDE_MEM_CODEX_TRANSCRIPT_INGESTION:"false",CLAUDE_MEM_MAX_CONCURRENT_AGENTS:"2",CLAUDE_MEM_OBSERVER_MAX_CONVERSATION_CHARS:"400000",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_CHROMA_MODE:"local",CLAUDE_MEM_CHROMA_HOST:"127.0.0.1",CLAUDE_MEM_CHROMA_PORT:"8000",CLAUDE_MEM_CHROMA_SSL:"false",CLAUDE_MEM_CHROMA_API_KEY:"",CLAUDE_MEM_CHROMA_TENANT:"default_tenant",CLAUDE_MEM_CHROMA_DATABASE:"default_database",CLAUDE_MEM_CHROMA_PREWARM_TIMEOUT_MS:"120000",CLAUDE_MEM_CHROMA_MAX_PENDING_MUTATIONS:"5000",CLAUDE_MEM_CLOUD_SYNC_TOKEN:"",CLAUDE_MEM_CLOUD_SYNC_USER_ID:"",CLAUDE_MEM_CLOUD_SYNC_HUB_URL:"",CLAUDE_MEM_CLOUD_SYNC_DEVICE_ID:"",CLAUDE_MEM_CLOUD_SYNC_DEVICE_NAME:(0,bo.hostname)(),CLAUDE_MEM_CLOUD_SYNC_WS:"true",CLAUDE_MEM_CLOUD_SYNC_CONTENT_BATCH_SIZE:"40",CLAUDE_MEM_CLOUD_SYNC_REQUEST_TIMEOUT_MS:"90000",CLAUDE_MEM_LLM_TIMEOUT_MS:"30000",CLAUDE_MEM_TV_TOKEN:"",CLAUDE_MEM_PRO_TRIAL_EMAIL:"",CLAUDE_MEM_PRO_TRIAL_AT:"",CLAUDE_MEM_PRO_TRIAL_STATE:"",CLAUDE_MEM_PRO_TRIAL_ENDS_AT:"",CLAUDE_MEM_PRO_PLAN:"",CLAUDE_MEM_PRO_FALLBACK_AT:"",CLAUDE_MEM_PRO_MEMORY_KEY:"",CLAUDE_MEM_PRO_MEMORY_BASE_URL:"",CLAUDE_MEM_PRO_MEMORY_MODEL:"",CLAUDE_MEM_TELEGRAM_ENABLED:"true",CLAUDE_MEM_TELEGRAM_BOT_TOKEN:"",CLAUDE_MEM_TELEGRAM_CHAT_ID:"",CLAUDE_MEM_TELEGRAM_WRAPUPS_ENABLED:"true",CLAUDE_MEM_TELEGRAM_OBSERVATION_ALERTS_ENABLED:"false",CLAUDE_MEM_TELEGRAM_WRAPUP_ROUTES:"{}",CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES:"security_alert,sensitive",CLAUDE_MEM_TELEGRAM_TRIGGER_CONCEPTS:"",CLAUDE_MEM_GROK_BOT_AWARENESS_ENABLED:"true",CLAUDE_MEM_GROK_BOT_AWARENESS_AGENT_IDS:"521e962d-2ec3-4488-bfbc-54d5209ce118,95601360-61f7-4fd9-bb3a-2c976b2b85c0",CLAUDE_MEM_GROK_BOT_AWARENESS_TRIGGER_TYPES:"decision,bugfix,security_alert,sensitive",CLAUDE_MEM_GROK_BOT_AWARENESS_TRIGGER_CONCEPTS:"",CLAUDE_MEM_GROK_BOT_INJECT_ENABLED:"true",CLAUDE_MEM_GROK_BOT_INJECT_AGENT_IDS:"*",CLAUDE_MEM_GROK_BOT_INJECT_TIER:"episode",CLAUDE_MEM_GROK_BOT_INJECT_WINDOW:"80",CLAUDE_MEM_GROK_BOT_INJECT_FALLBACK:"house",CLAUDE_MEM_GROK_BOT_INJECT_PLATFORM_SOURCE:"",CLAUDE_MEM_GROK_BOT_INJECT_PROJECTS_BY_AGENT:"",CLAUDE_MEM_GROK_BOT_INJECT_MAX_LINE_CHARS:"160",CLAUDE_MEM_GROK_BOT_INJECT_DEBOUNCE_MS:"1500",CLAUDE_MEM_CCS_ALIGN_ENABLED:"true",CLAUDE_MEM_CCS_ALIGN_VIEWER_IDS:"ccs-align",CLAUDE_MEM_CCS_ALIGN_TRIGGER_TYPES:"decision,bugfix,security_alert,sensitive",CLAUDE_MEM_CCS_ALIGN_PATCH_SHADOWS:"false",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 get(t){let r=process.env[t]??this.DEFAULTS[t];return t==="CLAUDE_MEM_WORKER_HOST"?this.normalizeWorkerHost(r):r}static normalizeWorkerHost(t){return t==="localhost"?"127.0.0.1":t}static finalizeSettings(t,r){let n=r?this.applyEnvOverrides(t):t;return n.CLAUDE_MEM_WORKER_HOST=this.normalizeWorkerHost(n.CLAUDE_MEM_WORKER_HOST),n}static getInt(t){let r=this.get(t);return parseInt(r,10)}static applyEnvOverrides(t){let r={...t};for(let n of Object.keys(this.DEFAULTS))process.env[n]!==void 0&&(r[n]=process.env[n]);return r}static loadFromFile(t,r=!0){try{if(!(0,$i.existsSync)(t)){let l=this.getAllDefaults();try{Pr(t,l),console.warn("[SETTINGS] Created settings file with defaults:",t)}catch(d){console.warn("[SETTINGS] Failed to create settings file, using in-memory defaults:",t,d instanceof Error?d.message:String(d))}return this.finalizeSettings(l,r)}let n=(0,$i.readFileSync)(t,"utf-8"),o=or(n),s=o,i=o.env&&typeof o.env=="object"&&!Array.isArray(o.env),a=i&&Object.keys(o).some(l=>l!=="env");if(i&&(s=o.env,!a))try{Pr(t,s),console.warn("[SETTINGS] Migrated settings file from nested to flat schema:",t)}catch(l){console.warn("[SETTINGS] Failed to auto-migrate settings file:",t,l instanceof Error?l.message:String(l))}if(s.CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES===dA){s={...s,CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES:this.DEFAULTS.CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES};try{Pr(t,a?{...o,env:s}:s),console.warn("[SETTINGS] Migrated Telegram trigger types off the legacy default:",t)}catch(l){console.warn("[SETTINGS] Failed to migrate Telegram trigger types:",t,l instanceof Error?l.message:String(l))}}let c=mA(s.CLAUDE_MEM_CLOUD_SYNC_HUB_URL);if(c!==null){s={...s,CLAUDE_MEM_CLOUD_SYNC_HUB_URL:c};try{Pr(t,a?{...o,env:s}:s),console.warn("[SETTINGS] Migrated cloud sync hub URL off the legacy workers.dev host:",t)}catch(l){console.warn("[SETTINGS] Failed to migrate cloud sync hub URL:",t,l instanceof Error?l.message:String(l))}}let u={...this.DEFAULTS};for(let l of Object.keys(this.DEFAULTS))s[l]!==void 0&&(u[l]=s[l]);return this.finalizeSettings(u,r)}catch(n){console.warn("[SETTINGS] Failed to load settings, using defaults:",t,n instanceof Error?n.message:String(n));let o=this.getAllDefaults();return this.finalizeSettings(o,r)}}};Ze();Ze();var Ri=null;function Ai(){return Ri!==null||(Ri=ht.loadFromFile(Do)),Ri}var wr=require("fs");X();var Dt=require("fs"),Dl=Lt(require("path"),1);X();var hA=["CLAUDECODE_","CLAUDE_CODE_"],gA=new Set(["CLAUDECODE","CLAUDE_CODE_SESSION","CLAUDE_CODE_ENTRYPOINT","MCP_SESSION_ID"]),_A=new Set(["HTTP_PROXY","HTTPS_PROXY","ALL_PROXY","NO_PROXY","http_proxy","https_proxy","all_proxy","no_proxy","npm_config_proxy","npm_config_https_proxy","npm_config_noproxy"]),yA=new Set(["CLAUDE_CODE_OAUTH_TOKEN","CLAUDE_CODE_GIT_BASH_PATH","CLAUDE_CODE_USE_BEDROCK","CLAUDE_CODE_USE_VERTEX","CLAUDE_CODE_USE_FOUNDRY","CLAUDE_CODE_SKIP_BEDROCK_AUTH","CLAUDE_CODE_SKIP_VERTEX_AUTH","CLAUDE_CODE_SKIP_FOUNDRY_AUTH","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",..._A]);function br(e=process.env){let t={};for(let[r,n]of Object.entries(e))if(n!==void 0){if(yA.has(r)){t[r]=n;continue}gA.has(r)||hA.some(o=>r.startsWith(o))||(t[r]=n)}return t}Ze();var Il=require("child_process"),hS=require("fs");X();var SA=5e3,mS=new Map,Ol=0;function EA(e){Ol+=1;let t=(0,Il.spawnSync)("powershell.exe",["-NoProfile","-NonInteractive","-Command",`(Get-CimInstance Win32_Process -Filter "ProcessId=${e}").CreationDate.ToString('yyyyMMddHHmmss.ffffff')`],{encoding:"utf-8",timeout:5e3,windowsHide:!0,env:{...br(process.env),LC_ALL:"C",LANG:"C"}});if(t.status===0){let r=t.stdout.trim();return r.length>0?r:null}return null}function bA(e,t=!1){if(!t){let n=mS.get(e);if(n&&Date.now()-n.capturedAtMs<SA)return n.token}let r=null;try{r=EA(e)}catch(n){_.debug("SYSTEM","captureProcessStartToken: powershell CIM lookup failed",{pid:e,error:n instanceof Error?n.message:String(n)}),r=null}return mS.set(e,{token:r,capturedAtMs:Date.now()}),r}function gS(e,t){if(!Number.isInteger(e)||e<=0)return null;if(process.platform==="linux"){Ol+=1;try{let r=(0,hS.readFileSync)(`/proc/${e}/stat`,"utf-8"),n=r.lastIndexOf(") ");if(n<0)return null;let s=r.slice(n+2).split(" ")[19];return s&&/^\d+$/.test(s)?s:null}catch(r){return _.debug("SYSTEM","captureProcessStartToken: /proc read failed",{pid:e,error:r instanceof Error?r.message:String(r)}),null}}if(process.platform==="win32")return bA(e,t);Ol+=1;try{let r=(0,Il.spawnSync)("ps",["-p",String(e),"-o","lstart="],{encoding:"utf-8",timeout:2e3,env:{...br(process.env),LC_ALL:"C",LANG:"C"}});if(r.status!==0)return null;let n=r.stdout.trim();return n.length>0?n:null}catch(r){return _.debug("SYSTEM","captureProcessStartToken: ps exec failed",{pid:e,error:r instanceof Error?r.message:String(r)}),null}}function rr(e){return gS(e,!1)}function zt(e,t){if(t===null)return!0;let r=gS(e,!0);return r===null?!0:r===t}var _S=require("child_process"),Ci=require("fs"),yS=require("util");X();var Cl=(0,yS.promisify)(_S.execFile),wA=128,vA=/not found|no running instance|no tasks/i,Oi=class extends Error{pid;constructor(t,r,n){super(r,n),this.name="ProcessTreeKillError",this.pid=t}};async function gt(e,t={}){let r=t.signalMode==="immediate",n=t.expectedStartToken!==void 0?t.expectedStartToken:rr(e),o=()=>zt(e,n);if(!o()){_.warn("PROCESS","Skipping tree-kill: root PID was reused since it was captured",{pid:e});return}if(_.debug("PROCESS",`Killing process tree rooted at PID ${e}`,{immediate:r}),process.platform==="win32"){try{await Cl("taskkill",["/PID",String(e),"/T","/F"],{timeout:5e3,windowsHide:!0})}catch(s){let i=s.code,a=String(s.stderr??""),c=s instanceof Error?s.message:String(s);if(i===wA||vA.test(`${a} ${c}`)){_.debug("PROCESS","taskkill reported the process was already gone",{pid:e});return}throw new Oi(e,`taskkill failed for PID ${e} (exit ${String(i)}): ${a.trim()||c}`,{cause:s})}return}try{let s=r?"SIGKILL":"SIGTERM",i=await Ii(e);for(let u of i){if(!zt(u.pid,u.startToken)){_.debug("PROCESS",`Skipping ${s}: descendant PID was reused since enumeration`,{pid:u.pid,rootPid:e});continue}try{process.kill(u.pid,s)}catch{}}if(o())try{process.kill(e,s)}catch(u){let l=u instanceof Error?u:new Error(String(u)),d=l.code;d!=="ESRCH"&&_.debug("PROCESS",`Failed to ${s} PID ${e}`,{code:d},l)}else _.warn("PROCESS","Skipping root signal: PID was reused during descendant enumeration",{pid:e,signal:s});r||await new Promise(u=>setTimeout(u,500));let a=o()?await Ii(e):[],c=new Map;for(let u of i)c.set(u.pid,u.startToken);for(let u of a)c.set(u.pid,u.startToken);for(let[u,l]of c){if(!zt(u,l)){_.debug("PROCESS","Skipping SIGKILL: descendant PID was reused since the scan",{pid:u,rootPid:e});continue}try{process.kill(u,"SIGKILL")}catch{}}if(!r&&o())try{process.kill(e,"SIGKILL")}catch{}}catch(s){throw new Oi(e,`tree-kill failed for PID ${e}: ${s instanceof Error?s.message:String(s)}`,{cause:s})}}async function kA(){return process.platform==="win32"?TA():process.platform==="linux"?xA():PA()}function xA(){let e=[],t;try{t=(0,Ci.readdirSync)("/proc")}catch(r){return _.warn("PROCESS","Cannot read /proc \u2014 tree-kill degrades to a single-PID kill",{error:r instanceof Error?r.message:String(r)}),e}for(let r of t){if(!/^\d+$/.test(r))continue;let n;try{n=(0,Ci.readFileSync)(`/proc/${r}/stat`,"utf-8")}catch{continue}let o=n.lastIndexOf(") ");if(o<0)continue;let s=n.slice(o+2).split(" "),i=Number.parseInt(s[1]??"",10),a=s[19];Number.isFinite(i)&&e.push({pid:Number.parseInt(r,10),ppid:i,startToken:a&&/^\d+$/.test(a)?a:null})}return e}async function PA(){let e;try{e=(await Cl("ps",["-eo","pid=,ppid=,lstart="],{timeout:1e4,maxBuffer:33554432,env:{...process.env,LC_ALL:"C",LANG:"C"}})).stdout}catch(r){return _.warn("PROCESS","Cannot enumerate the process table \u2014 tree-kill degrades to a single-PID kill",{error:r instanceof Error?r.message:String(r)}),[]}let t=[];for(let r of e.split(`
|
|
81
|
+
`)){let n=r.trim().match(/^(\d+)\s+(\d+)\s+(.*)$/);if(!n)continue;let o=n[3].trim();t.push({pid:Number.parseInt(n[1],10),ppid:Number.parseInt(n[2],10),startToken:o.length>0?o:null})}return t}async function TA(){let e;try{e=(await Cl("powershell.exe",["-NoProfile","-NonInteractive","-Command","Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,@{Name='StartToken';Expression={$_.CreationDate.ToString('yyyyMMddHHmmss.ffffff')}} | ConvertTo-Csv -NoTypeInformation"],{timeout:3e4,windowsHide:!0,maxBuffer:33554432})).stdout}catch(r){return _.warn("PROCESS","Cannot enumerate the Windows process table \u2014 tree-kill degrades to a single-PID kill",{error:r instanceof Error?r.message:String(r)}),[]}let t=[];for(let r of e.split(/\r?\n/).slice(1)){let n=r.match(/^"(\d+)","(\d+)","(.*)"$/);if(!n)continue;let o=n[3].trim();t.push({pid:Number.parseInt(n[1],10),ppid:Number.parseInt(n[2],10),startToken:o.length>0?o:null})}return t}async function Ii(e){let t=await kA(),r=new Map;for(let i of t){let a=r.get(i.ppid);a?a.push(i):r.set(i.ppid,[i])}let n=new Set([e]),o=[],s=i=>{for(let a of r.get(i)??[])n.has(a.pid)||(n.add(a.pid),s(a.pid),o.push({pid:a.pid,startToken:a.startToken}))};return s(e),o}var $A=5e3,RA=1e3,AA=qe.supervisorRegistry();function fe(e){if(!Number.isInteger(e)||e<0||e===0)return!1;try{return process.kill(e,0),!0}catch(t){if(t instanceof Error){let r=t.code;return r==="EPERM"?!0:(_.debug("SYSTEM","PID check failed",{pid:e,code:r}),!1)}return _.warn("SYSTEM","PID check threw non-Error",{pid:e,error:String(t)}),!1}}async function Mi(e,t){let r=Date.now()+t;for(;Date.now()<r;){if(e.every(n=>!fe(n.pid)))return;await new Promise(n=>setTimeout(n,100))}}function Ll(e){if(!e||!fe(e.pid))return!1;if(!e.startToken)return!0;let t=rr(e.pid);if(t===null)return!0;let r=t===e.startToken;return r||_.debug("SYSTEM","verifyPidFileOwnership: start-token mismatch (PID reused)",{pid:e.pid,stored:e.startToken,current:t}),r}var Nl=class{registryPath;entries=new Map;runtimeProcesses=new Map;initialized=!1;constructor(t=AA){this.registryPath=t}initialize(){if(this.initialized)return;if(this.initialized=!0,(0,Dt.mkdirSync)(Dl.default.dirname(this.registryPath),{recursive:!0}),!(0,Dt.existsSync)(this.registryPath)){this.persist();return}try{let n=JSON.parse((0,Dt.readFileSync)(this.registryPath,"utf-8")).processes??{};for(let[o,s]of Object.entries(n))this.entries.set(o,s)}catch(r){r instanceof Error?_.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath},r):_.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath,error:String(r)}),this.entries.clear()}let t=this.pruneDeadEntries();t>0&&_.info("SYSTEM","Removed dead processes from supervisor registry",{removed:t}),this.persist()}retainSupersededEntry(t,r){let n=this.entries.get(t);if(!n||n.pid===r||!fe(n.pid))return;let o=`${t}#superseded:${n.pid}`;this.entries.set(o,n);let s=this.runtimeProcesses.get(t);s&&(this.runtimeProcesses.set(o,s),this.runtimeProcesses.delete(t)),_.warn("SYSTEM","Registry id reused while the previous process was still alive; kept it for reaping",{id:t,supersededId:o,supersededPid:n.pid,incomingPid:r})}register(t,r,n){this.initialize(),this.retainSupersededEntry(t,r.pid),this.entries.set(t,r),n&&this.runtimeProcesses.set(t,n),this.persist()}unregister(t){this.initialize();let r=this.entries.get(t);this.entries.delete(t),this.runtimeProcesses.delete(t),this.persist(),r?.type==="sdk"&&zl()}clear(){this.entries.clear(),this.runtimeProcesses.clear(),this.persist()}getAll(){return this.initialize(),Array.from(this.entries.entries()).map(([t,r])=>({id:t,...r})).sort((t,r)=>{let n=Date.parse(t.startedAt),o=Date.parse(r.startedAt);return(Number.isNaN(n)?0:n)-(Number.isNaN(o)?0:o)})}getBySession(t){let r=String(t);return this.getAll().filter(n=>n.sessionId!==void 0&&String(n.sessionId)===r)}getRuntimeProcess(t){return this.runtimeProcesses.get(t)}pruneDeadEntries(){this.initialize();let t=0,r=0;for(let[n,o]of this.entries)fe(o.pid)||(this.entries.delete(n),this.runtimeProcesses.delete(n),t+=1,o.type==="sdk"&&(r+=1));t>0&&this.persist();for(let n=0;n<r;n+=1)zl();return t}async reapSession(t){this.initialize();let r=this.getBySession(t);if(r.length===0)return 0;let n=typeof t=="number"?t:Number(t)||void 0;_.info("SYSTEM",`Reaping ${r.length} process(es) for session ${t}`,{sessionId:n,pids:r.map(a=>a.pid)});let o=r.filter(a=>fe(a.pid)),s=new Map(o.map(a=>[a.pid,rr(a.pid)]));for(let a of o)try{process.platform==="win32"?await gt(a.pid,{expectedStartToken:s.get(a.pid)??null}):typeof a.pgid=="number"?process.kill(-a.pgid,"SIGTERM"):process.kill(a.pid,"SIGTERM")}catch(c){c instanceof Error?c.code!=="ESRCH"&&_.debug("SYSTEM",`Failed to SIGTERM session process PID ${a.pid}`,{pid:a.pid,pgid:a.pgid},c):_.warn("SYSTEM",`Failed to SIGTERM session process PID ${a.pid} (non-Error)`,{pid:a.pid,pgid:a.pgid,error:String(c)})}await Mi(o,$A);let i=o.filter(a=>fe(a.pid));for(let a of i){_.warn("SYSTEM",`Session process PID ${a.pid} did not exit after SIGTERM, sending SIGKILL`,{pid:a.pid,pgid:a.pgid,sessionId:n});let c=s.get(a.pid)??null;if(!zt(a.pid,c)){_.warn("SYSTEM","Skipping SIGKILL: session process PID was reused during the grace window",{pid:a.pid,sessionId:n});continue}try{process.platform==="win32"?await gt(a.pid,{expectedStartToken:c}):typeof a.pgid=="number"?process.kill(-a.pgid,"SIGKILL"):process.kill(a.pid,"SIGKILL")}catch(u){u instanceof Error?u.code!=="ESRCH"&&_.debug("SYSTEM",`Failed to SIGKILL session process PID ${a.pid}`,{pid:a.pid,pgid:a.pgid},u):_.warn("SYSTEM",`Failed to SIGKILL session process PID ${a.pid} (non-Error)`,{pid:a.pid,pgid:a.pgid,error:String(u)})}}if(i.length>0){let a=Date.now()+RA;for(;Date.now()<a&&i.filter(u=>fe(u.pid)).length!==0;)await new Promise(u=>setTimeout(u,100))}for(let a of r)this.entries.delete(a.id),this.runtimeProcesses.delete(a.id);this.persist();for(let a of r)a.type==="sdk"&&zl();return _.info("SYSTEM",`Reaped ${r.length} process(es) for session ${t}`,{sessionId:n,reaped:r.length}),r.length}persist(){let t={processes:Object.fromEntries(this.entries.entries())};(0,Dt.mkdirSync)(Dl.default.dirname(this.registryPath),{recursive:!0}),(0,Dt.writeFileSync)(this.registryPath,JSON.stringify(t,null,2))}},Ml=null;function zi(){return Ml||(Ml=new Nl),Ml}var nU=180*1e3,OA=[];function zl(){let e=OA.shift();e&&e.notify()}var sn=require("fs");X();Ze();var IA=qe.workerPid();async function ES(e){let t=e.currentPid??process.pid,r=e.pidFilePath??IA,n=e.registry.getAll(),o=[...n].filter(c=>c.pid!==t).sort((c,u)=>Date.parse(u.startedAt)-Date.parse(c.startedAt)),s=new Map,i=new Map;for(let c of o){if(!fe(c.pid)){e.registry.unregister(c.id);continue}i.set(c.id,rr(c.pid)),s.set(c.id,await Ii(c.pid));try{await SS(c,"SIGTERM")}catch(u){u instanceof Error?_.debug("SYSTEM","Failed to send SIGTERM to child process",{pid:c.pid,pgid:c.pgid,type:c.type},u):_.warn("SYSTEM","Failed to send SIGTERM to child process (non-Error)",{pid:c.pid,pgid:c.pgid,type:c.type,error:String(u)})}}await Mi(o,5e3);let a=o.filter(c=>fe(c.pid)||(s.get(c.id)??[]).some(u=>fe(u.pid)));for(let c of a){let u=zt(c.pid,i.get(c.id)??null);u||_.warn("SYSTEM","Skipping tree-kill: root PID was reused during the grace window",{pid:c.pid,type:c.type});try{u&&await SS(c,"SIGKILL")}catch(l){l instanceof Error?_.debug("SYSTEM","Failed to force kill child process",{pid:c.pid,pgid:c.pgid,type:c.type},l):_.warn("SYSTEM","Failed to force kill child process (non-Error)",{pid:c.pid,pgid:c.pgid,type:c.type,error:String(l)})}finally{CA(s.get(c.id)??[],c.pid)}}await Mi(a,1e3);for(let c of o)e.registry.unregister(c.id);for(let c of n.filter(u=>u.pid===t))e.registry.unregister(c.id);bS(r,t),e.registry.pruneDeadEntries()}function bS(e,t,r=!1){if(!(0,sn.existsSync)(e))return;let n=null;try{let i=JSON.parse((0,sn.readFileSync)(e,"utf-8"));n=typeof i.pid=="number"?i.pid:null}catch(i){_.debug("SYSTEM","PID file unreadable \u2014 leaving it (cannot prove ownership)",{pidFilePath:e,error:i instanceof Error?i.message:String(i)});return}let o=t!==null&&n===t,s=n===null||!fe(n);if(!o&&!(r&&s)){_.debug("SYSTEM","PID file not owned by this process \u2014 leaving it for its owner (restart successor?)",{pidFilePath:e,recordedPid:n,currentPid:t});return}try{(0,sn.rmSync)(e,{force:!0})}catch(i){i instanceof Error?_.debug("SYSTEM","Failed to remove PID file",{pidFilePath:e},i):_.warn("SYSTEM","Failed to remove PID file (non-Error)",{pidFilePath:e,error:String(i)})}}function CA(e,t){for(let{pid:r,startToken:n}of e)if(!(r===t||!fe(r))){if(!zt(r,n)){_.debug("SYSTEM","Skipping reap: PID was recycled during the grace window",{pid:r,rootPid:t});continue}try{process.kill(r,"SIGKILL"),_.debug("SYSTEM","Reaped orphaned descendant during shutdown cascade",{pid:r,rootPid:t})}catch(o){let s=o instanceof Error?o.code:void 0;s!=="ESRCH"&&_.warn("SYSTEM","Failed to reap orphaned descendant during shutdown cascade",{pid:r,rootPid:t,errno:s})}}}async function SS(e,t){let{pid:r,pgid:n}=e;if(process.platform!=="win32"){if(typeof n=="number")try{process.kill(-n,t);return}catch(o){if((o instanceof Error?o.code:void 0)!=="ESRCH")throw o}if(t==="SIGKILL"){await gt(r,{signalMode:"immediate"});return}try{process.kill(r,t)}catch(o){if((o instanceof Error?o.code:void 0)!=="ESRCH")throw o}return}await gt(r)}X();var wS=3e4,an=null;function MA(){let t=zi().pruneDeadEntries();t>0&&_.info("SYSTEM",`Health check: pruned ${t} dead process(es) from registry`)}function vS(){an===null&&(an=setInterval(MA,wS),an.unref(),_.debug("SYSTEM","Health checker started",{intervalMs:wS}))}function kS(){an!==null&&(clearInterval(an),an=null,_.debug("SYSTEM","Health checker stopped"))}var xS=require("child_process"),PS=require("util");X();var zA=(0,PS.promisify)(xS.execFile),DA=/(?:^|\/)(?:uvx|uv|python[\d.]*)(?:\s|$).*chroma-mcp/;function NA(e){let t=[];for(let r of e.split(`
|
|
82
|
+
`)){let n=r.trim().match(/^(\d+)\s+(\d+)\s+(.*)$/);n&&t.push({pid:Number.parseInt(n[1],10),ppid:Number.parseInt(n[2],10),command:n[3].trim()})}return t}async function LA(){let e=await zA("ps",["-eo","pid=,ppid=,command="],{timeout:1e4,maxBuffer:33554432});return NA(e.stdout)}function jA(e,t){let r=e.filter(i=>DA.test(i.command)&&i.pid!==t.selfPid),n=new Set(r.map(i=>i.pid)),o=r.filter(i=>!n.has(i.ppid)),s=o.filter(i=>i.ppid===t.selfPid?!1:i.ppid===1?!0:!t.isAlive(i.ppid));return{matched:r,roots:o,orphans:s}}async function TS(e={}){let t=e.platform??process.platform,r={matched:0,trees:0,orphans:0,killed:0,failed:0,unregistered:0,skipped:null};if(t==="win32")return r.skipped="windows",r;let n=e.readTable??LA,o=e.isAlive??fe,s=e.killTree??(p=>gt(p,{signalMode:"graceful"})),i=e.selfPid??process.pid,a;try{a=await n()}catch(p){return _.warn("PROCESS","Orphaned chroma-mcp sweep skipped: cannot read the process table",{error:p instanceof Error?p.message:String(p)}),r.skipped="unreadable",r}let{matched:c,roots:u,orphans:l}=jA(a,{isAlive:o,selfPid:i});if(r.matched=c.length,r.trees=u.length,r.orphans=l.length,l.length===0)return _.debug("PROCESS","No orphaned chroma-mcp trees found",{matched:r.matched,trees:r.trees}),r;_.warn("PROCESS","Reaping orphaned chroma-mcp trees left by dead workers",{orphans:l.length,roots:l.map(p=>p.pid)});let d=new Set,f=8;for(let p=0;p<l.length;p+=f){let m=l.slice(p,p+f);(await Promise.allSettled(m.map(g=>s(g.pid)))).forEach((g,y)=>{let b=m[y];g.status==="fulfilled"?(r.killed+=1,d.add(b.pid)):(r.failed+=1,_.warn("PROCESS","Failed to reap an orphaned chroma-mcp tree",{pid:b.pid,ppid:b.ppid,error:g.reason instanceof Error?g.reason.message:String(g.reason)}))})}if(e.registry)for(let p of e.registry.getAll())p.type==="chroma"&&d.has(p.pid)&&(e.registry.unregister(p.id),r.unregistered+=1);return _.info("PROCESS","Orphaned chroma-mcp sweep finished",{orphans:r.orphans,killed:r.killed,failed:r.failed,unregistered:r.unregistered}),r}Ze();var UA=qe.workerPid(),jl=class{registry;started=!1;stopPromise=null;signalHandlersRegistered=!1;shutdownInitiated=!1;shutdownHandler=null;constructor(t){this.registry=t}async start(){if(this.started)return;if(this.registry.initialize(),Di({logAlive:!1})==="alive")throw new Error("Worker already running");this.started=!0,TS({registry:this.registry}).catch(r=>{_.warn("PROCESS","Orphaned chroma-mcp sweep failed",{error:r instanceof Error?r.message:String(r)})}),vS()}configureSignalHandlers(t){if(this.shutdownHandler=t,this.signalHandlersRegistered)return;this.signalHandlersRegistered=!0;let r=async n=>{if(this.shutdownInitiated){_.warn("SYSTEM",`Received ${n} but shutdown already in progress`);return}this.shutdownInitiated=!0,_.info("SYSTEM",`Received ${n}, shutting down...`);try{this.shutdownHandler?await this.shutdownHandler():await this.stop()}catch(o){o instanceof Error?_.error("SYSTEM","Error during shutdown",{},o):_.error("SYSTEM","Error during shutdown (non-Error)",{error:String(o)});try{await this.stop()}catch(s){s instanceof Error?_.debug("SYSTEM","Supervisor shutdown fallback failed",{},s):_.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",()=>{_.debug("SYSTEM","Ignoring SIGHUP in daemon mode")}):process.on("SIGHUP",()=>{r("SIGHUP")}))}async stop(){if(this.stopPromise){await this.stopPromise;return}kS(),this.stopPromise=ES({registry:this.registry,currentPid:process.pid}).finally(()=>{this.started=!1,this.stopPromise=null}),await this.stopPromise}assertCanSpawn(t){if(this.stopPromise!==null)throw new Error(`Supervisor is shutting down, refusing to spawn ${t}`)}registerProcess(t,r,n){this.registry.register(t,r,n)}unregisterProcess(t){this.registry.unregister(t)}getRegistry(){return this.registry}},FA=new jl(zi());function Ul(){return FA}function Di(e={}){let t=e.pidFilePath??UA;if(!(0,wr.existsSync)(t))return"missing";let r=null;try{r=JSON.parse((0,wr.readFileSync)(t,"utf-8"))}catch(o){return o instanceof Error?_.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:t},o):_.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:t,error:String(o)}),(0,wr.rmSync)(t,{force:!0}),"invalid"}return Ll(r)&&r?((e.logAlive??!0)&&_.info("SYSTEM","Worker already running (PID alive)",{existingPid:r.pid,existingPort:r.port,startedAt:r.startedAt}),"alive"):(_.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,wr.rmSync)(t,{force:!0}),"stale")}Co();Ze();Tr();X();X();X();var Nt=Lt(require("path"),1),AS=require("os"),Oe=require("fs"),wo=require("child_process");X();X();X();Ze();var pF=qe.dataDir(),$S=qe.workerPid(),RS="Bun runtime not found \u2014 install from https://bun.sh and ensure it is on PATH or set BUN env var. The worker daemon requires Bun because it uses bun:sqlite.";function qA(e){try{return(0,Oe.realpathSync)(e)}catch{return null}}function Fl(e){return e?/(^|[\\/])bun(\.exe)?$/i.test(e.trim()):!1}function ZA(e,t){let r=t==="win32"?`where ${e}`:`which ${e}`,n;try{n=(0,wo.execSync)(r,{stdio:["ignore","pipe","ignore"],encoding:"utf-8",windowsHide:!0})}catch(s){return s instanceof Error?_.debug("SYSTEM",`Binary lookup failed for ${e}`,{command:r},s):_.debug("SYSTEM",`Binary lookup failed for ${e}`,{command:r},new Error(String(s))),null}return n.split(/\r?\n/).map(s=>s.trim()).find(s=>s.length>0)||null}var ql;function Zl(e={}){let t=Object.keys(e).length===0;if(t&&ql!==void 0)return ql;let r=HA(e);return t&&r!==null&&(ql=r),r}function HA(e){let t=e.platform??process.platform,r=e.execPath??process.execPath;if(Fl(r))return r;let n=e.env??process.env,o=e.homeDirectory??(0,AS.homedir)(),s=e.pathExists??Oe.existsSync,i=e.lookupInPath??ZA,a=e.realpath??qA,c=t==="win32"?[n.BUN,n.BUN_PATH,Nt.default.join(o,".bun","bin","bun.exe"),Nt.default.join(o,".bun","bin","bun"),n.USERPROFILE?Nt.default.join(n.USERPROFILE,".bun","bin","bun.exe"):void 0,n.LOCALAPPDATA?Nt.default.join(n.LOCALAPPDATA,"bun","bun.exe"):void 0,n.LOCALAPPDATA?Nt.default.join(n.LOCALAPPDATA,"bun","bin","bun.exe"):void 0,n.npm_config_prefix?Nt.default.join(n.npm_config_prefix,"bun.exe"):void 0]:[n.BUN,n.BUN_PATH,Nt.default.join(o,".bun","bin","bun"),"/usr/local/bin/bun","/opt/homebrew/bin/bun","/home/linuxbrew/.linuxbrew/bin/bun","/usr/bin/bun","/snap/bin/bun",n.npm_config_prefix?Nt.default.join(n.npm_config_prefix,"bin","bun"):void 0];for(let d of c){let f=d?.trim();if(f&&(Fl(f)&&s(f)||f.toLowerCase()==="bun"))return f}let u=i("bun",t)?.trim();if(!u||!Fl(u))return null;let l=a(u)??u;return s(l)?l:null}function vr(e){return process.platform==="win32"?Math.round(e*2):e}function OS(){let e=qe.dataDir();return(0,Oe.mkdirSync)(e,{recursive:!0}),e}function WA(e,t,r=OS()){let n=o=>o.replace(/'/g,"''");return`Start-Process -FilePath '${n(e)}' -ArgumentList @('"${n(t)}"','--daemon') -WorkingDirectory '${n(r)}' -WindowStyle Hidden`}var BA=5e3,KA=8;function GA(e,t,r){return e?.code!=="ETIMEDOUT"?!1:t<r/2}function IS(e,t=vr(BA)){let r=Zl();if(!r)return;let n=()=>{let a=Date.now();try{return{result:(0,wo.spawnSync)(r,[e,"status"],{encoding:"utf-8",timeout:t,windowsHide:!0,env:br({...process.env})}),elapsedMs:Date.now()-a}}catch(c){let u=c instanceof Error?c:new Error(String(c));_.debug("SYSTEM","Worker boot probe could not be launched",{scriptPath:e},u);return}},o=n();if(o===void 0||GA(o.result.error,o.elapsedMs,t)&&(_.debug("SYSTEM","Worker boot probe timed out before it could run \u2014 retrying once",{scriptPath:e,elapsedMs:o.elapsedMs,timeoutMs:t}),o=n(),o===void 0))return;let{result:s}=o;if(s.error||s.status===0)return;let i=`${s.stdout??""}${s.stderr??""}`.trim();if(i)return i.split(/\r?\n/).slice(0,KA).join(`
|
|
83
|
+
`)}function CS(e,t,r={}){Ul().assertCanSpawn("worker daemon");let n=br({...process.env,CLAUDE_MEM_WORKER_PORT:String(t),...r}),o=Zl();if(!o){_.error("SYSTEM",RS);return}if(process.platform==="win32"){let l=WA(o,e),d=Buffer.from(l,"utf16le").toString("base64");try{return(0,wo.execSync)(`powershell -NoProfile -EncodedCommand ${d}`,{stdio:"ignore",windowsHide:!0,env:n}),0}catch(f){let p=f instanceof Error?f:new Error(String(f));_.error("SYSTEM","Failed to spawn worker daemon on Windows",{runtimePath:o},p);return}}let s="/usr/bin/setsid",i=(0,Oe.existsSync)(s),a=i?s:o,u=Ti(a,i?[o,e,"--daemon"]:[e,"--daemon"],{detached:!0,stdio:"ignore",cwd:OS(),env:n});if(u.on("error",l=>{_.error("SYSTEM",RS,{runtimePath:o,execPath:a},l)}),u.pid!==void 0)return u.unref(),u.pid}function MS(){try{if(!(0,Oe.existsSync)($S))return;let e=new Date;(0,Oe.utimesSync)($S,e,e)}catch{}}function Ni(){return Di({logAlive:!1})}var zS=Lt(require("net"),1);X();Ze();function Hl(){return ht.loadFromFile(Do).CLAUDE_MEM_WORKER_HOST}function DS(e){return e.startsWith("[")&&e.endsWith("]")?e:e.includes(":")?`[${e}]`:e}var Wl=5e3;async function VA(e,t,r="GET",n=Wl){let o=await fetch(`http://${DS(Hl())}:${e}${t}`,{method:r,signal:AbortSignal.timeout(Math.max(1,n))}),s="";try{s=await o.text()}catch{}return{ok:o.ok,statusCode:o.status,body:s}}async function Bl(e,t=Wl){if(process.platform==="win32")try{let r=await fetch(`http://${DS(Hl())}:${e}/api/health`,{signal:AbortSignal.timeout(Math.max(1,t))});if(r.ok)return!0;_.debug("SYSTEM","Windows health check returned non-ok; falling through to socket probe",{port:e,status:r.status})}catch(r){r instanceof Error?_.debug("SYSTEM","Windows health check threw; falling through to socket probe",{port:e,message:r.message}):_.debug("SYSTEM","Windows health check threw; falling through to socket probe",{port:e,error:String(r)})}return new Promise(r=>{let n=zS.default.createServer(),o=Hl();n.once("error",s=>{s.code==="EADDRINUSE"?r(!0):r(!1)}),n.once("listening",()=>{n.close(()=>r(!1))}),n.listen(e,o)})}async function NS(e,t,r,n){let o=Date.now()+r;for(;Date.now()<o;){try{let i=o-Date.now();if((await VA(e,t,"GET",Math.min(Wl,i))).ok)return!0}catch(i){i instanceof Error?_.debug("SYSTEM",n,{},i):_.debug("SYSTEM",n,{error:String(i)})}let s=Math.min(500,o-Date.now());s>0&&await new Promise(i=>setTimeout(i,s))}return!1}function vo(e,t=3e4){return NS(e,"/api/health",t,"Service not ready yet, will retry")}function ko(e,t=3e4){return NS(e,"/api/readiness",t,"Worker not ready yet, will retry")}X();var Li=require("path"),nt=require("fs");Ze();X();var YA=9e4;function LS(){return(0,Li.join)(sr(),"spawn.lock")}function Kl(){let e=LS(),t=JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()});for(let r=0;r<2;r++)try{return(0,nt.mkdirSync)((0,Li.dirname)(e),{recursive:!0}),(0,nt.writeFileSync)(e,t,{flag:"wx"}),!0}catch(n){let o=n instanceof Error?n:new Error(String(n)),s=o.code;if(s!=="EEXIST")return _.warn("SYSTEM","Spawn lock write failed for a non-contention reason; failing open (spawning unlocked)",{lockPath:e,code:s},o),!0;if(r>0)return!1;let i;try{i=(0,nt.statSync)(e).mtimeMs}catch{continue}if(Date.now()-i<=YA)return!1;let a;try{a=(0,nt.statSync)(e).mtimeMs}catch{continue}if(a!==i)return!1;try{(0,nt.unlinkSync)(e)}catch{return!1}}return!1}function Gl(){let e=LS();try{if(JSON.parse((0,nt.readFileSync)(e,"utf-8")).pid!==process.pid)return;(0,nt.unlinkSync)(e)}catch{}}Tr();function Vl(e,t,r){let n=process.env[e];if(n){let o=parseInt(n,10);if(Number.isFinite(o)&&o>=r.min&&o<=r.max)return o;_.warn("SYSTEM",`Invalid ${e}, using default`,{value:n,min:r.min,max:r.max})}return t}var GF=Vl("CLAUDE_MEM_HEALTH_TIMEOUT_MS",tr(Ae.HEALTH_CHECK),{min:500,max:3e5}),VF=Vl("CLAUDE_MEM_HOOK_READINESS_TIMEOUT_MS",tr(Ae.HOOK_READINESS_WAIT),{min:0,max:3e5}),YF=Vl("CLAUDE_MEM_WEDGED_WORKER_UPTIME_S",300,{min:60,max:86400}),JA={min:500,max:3e5};function FS(e=process.env){let t=e.CLAUDE_MEM_FETCH_VERBOSE;if(t===void 0)return!1;let r=t.trim().toLowerCase();return r==="1"||r==="true"||r==="on"||r==="yes"}function XA(e){return FS()?{...e,verbose:!0}:e}function QA(e){let t={},r=e;for(let n=0;r&&n<4;n++){let o=n===0?"error":`cause${n}`;if(r instanceof Error){let s=r;t[o]={name:r.name,message:r.message,...s.code!==void 0?{code:s.code}:{}},r=r.cause;continue}t[o]=String(r);break}return t}function eO(e,t,r){let n=typeof t.method=="string"?t.method:"GET",o=QA(r),s=JSON.stringify(o);_.warn("SYSTEM","Worker IPC fetch failed",{url:e,method:n},s),jt(`[claude-mem] fetch verbose: ${n} ${e} ${s}
|
|
84
|
+
`)}async function qS(e,t={}){let r=XA(t);try{return await fetch(e,r)}catch(n){throw FS()&&eO(e,t,n),n}}async function Yl(e,t={},r){try{return await qS(e,{...t,signal:AbortSignal.timeout(r)})}catch(n){throw n instanceof DOMException&&n.name==="TimeoutError"?new Error(`Request timed out after ${r}ms`):n}}var ji=null,Ui=null,Fi=null,qi=null;function tO(){return Ie.default.join(ht.get("CLAUDE_MEM_DATA_DIR"),"settings.json")}function Jl(){return Fi!==null||(Fi=ht.loadFromFile(tO())),Fi}function jS(e,t){if(!e)return null;let r=parseInt(e,10);return Number.isFinite(r)&&r>=t.min&&r<=t.max?r:null}function rO(e,t,r){let n=process.env[e];if(n!==void 0){let i=jS(n,r);return i!==null?i:(_.warn("SYSTEM",`Invalid ${e}, using default`,{value:n,min:r.min,max:r.max}),t)}let o=Jl()[e],s=jS(o,r);return s!==null?s:(_.warn("SYSTEM",`Invalid ${e} in settings.json, using default`,{value:o,min:r.min,max:r.max}),t)}function Xl(){if(ji!==null)return ji;let e=Jl();return ji=parseInt(e.CLAUDE_MEM_WORKER_PORT,10),ji}function nO(){return Ui!==null||(Ui=Jl().CLAUDE_MEM_WORKER_HOST),Ui}function oO(){return qi!==null||(qi=rO("CLAUDE_MEM_API_TIMEOUT_MS",tr(Ae.API_REQUEST),JA)),qi}function sO(e){return e.startsWith("[")&&e.endsWith("]")?e:e.includes(":")?`[${e}]`:e}function iO(e){return`http://${sO(nO())}:${Xl()}${e}`}function Zi(e,t={}){let r=t.method??"GET",n=t.timeoutMs??oO(),o=iO(e),s={method:r};return t.headers&&(s.headers=t.headers),t.body&&(s.body=t.body),n>0?Yl(o,s,n):qS(o,s)}function ZS(e){let t=(0,Ce.existsSync)(Ie.default.join(e,"plugin","scripts"))?Ie.default.join(e,"plugin"):e;return Ie.default.join(t,"scripts","worker-service.cjs")}function aO(e,t){let r=d=>{let f=d.split("-")[0].split(".");return[parseInt(f[0],10)||0,parseInt(f[1],10)||0,parseInt(f[2],10)||0]},[n,o,s]=r(e),[i,a,c]=r(t);if(i!==n)return i-n;if(a!==o)return a-o;if(c!==s)return c-s;let u=e.includes("-")?1:0,l=t.includes("-")?1:0;return u!==l?u-l:e<t?1:e>t?-1:0}function cO(e=Ie.default.join(Ie.default.dirname(Ie.default.dirname(zo)),"cache","thedotmack","claude-mem")){try{return(0,Ce.readdirSync)(e).filter(t=>/^\d/.test(t)).map(t=>Ie.default.join(e,t)).filter(t=>{try{if(!(0,Ce.statSync)(t).isDirectory())return!1}catch{return!1}return!(0,Ce.existsSync)(Ie.default.join(t,".orphaned_at"))}).map(t=>({scriptPath:ZS(t),version:Ie.default.basename(t)}))}catch{return[]}}function US(e){try{let t=JSON.parse((0,Ce.readFileSync)(e,"utf-8"));return typeof t.version=="string"?t.version:null}catch(t){let r=t.code;return r!=="ENOENT"&&_.debug("SYSTEM","Could not read package version for worker resolution",{packageJsonPath:e,code:r}),null}}function uO(){let e=process.env.CLAUDE_MEM_WORKER_SCRIPT_PATH?.trim();if(e){if((0,Ce.existsSync)(e))return{scriptPath:e,version:null};_.debug("SYSTEM","Ignoring missing CLAUDE_MEM_WORKER_SCRIPT_PATH override",{override:e})}let t=[...cO(),{scriptPath:ZS(Ie.default.join(zo,"plugin")),version:US(Ie.default.join(zo,"package.json"))},{scriptPath:Ie.default.join(process.cwd(),"plugin","scripts","worker-service.cjs"),version:US(Ie.default.join(process.cwd(),"package.json"))}];return lO(t)}function lO(e){let t=e.filter(r=>(0,Ce.existsSync)(r.scriptPath));return t.length===0?null:(t.sort((r,n)=>r.version===null&&n.version===null?0:r.version===null?1:n.version===null?-1:aO(r.version,n.version)),t[0])}function HS(){return uO()?.scriptPath??null}var dO=1e3;var fO=5e3,JF=fO+dO;var Ql=Lt(require("path"),1),ot=require("fs");X();var BS=require("node:child_process"),KS=require("node:util");X();Ze();var GS=(0,KS.promisify)(BS.execFile),pO=/^(uv|uvx|python|chroma-mcp)(\.exe)?$/i;function WS(e){return pO.test(e.trim())}function mO(e,t){if(!e)return!1;let r=e.toLowerCase().replace(/\\/g,"/"),n=r.indexOf("--data-dir");if(n<0)return!1;let o=r.slice(n+10).trim();if(o.startsWith('"')){let i=o.indexOf('"',1);o=i<0?o.slice(1):o.slice(1,i)}let s=t.toLowerCase().replace(/\\/g,"/");return o===s||o.startsWith(s)&&o[s.length]==="/"}async function hO(){try{let e=await GS("powershell.exe",["-NoProfile","-NonInteractive","-Command","Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,Name,CommandLine,@{Name='StartToken';Expression={$_.CreationDate.ToString('yyyyMMddHHmmss.ffffff')}} | ConvertTo-Json -Compress"],{timeout:3e4,windowsHide:!0,maxBuffer:33554432}),t=JSON.parse(e.stdout),r=Array.isArray(t)?t:t===null?[]:[t],n=[];for(let o of r){let s=typeof o.Name=="string"?o.Name.trim():"";if(!s)continue;let i=typeof o.ProcessId=="number"?o.ProcessId:Number.parseInt(String(o.ProcessId),10),a=typeof o.ParentProcessId=="number"?o.ParentProcessId:Number.parseInt(String(o.ParentProcessId),10);!Number.isInteger(i)||!Number.isInteger(a)||n.push({pid:i,ppid:a,name:s,cmdline:typeof o.CommandLine=="string"?o.CommandLine:null,startToken:typeof o.StartToken=="string"&&o.StartToken.length>0?o.StartToken:null})}return n}catch(e){return _.warn("PROCESS","Cannot enumerate the Windows process table with names \u2014 ghost-port reclaim disabled",{error:e instanceof Error?e.message:String(e)}),null}}async function gO(e){try{let t=await GS("netstat",["-ano"],{timeout:15e3,windowsHide:!0,maxBuffer:16777216});return _O(t.stdout,e)}catch(t){return _.warn("PROCESS","netstat failed \u2014 ghost-port reclaim disabled for this attempt",{port:e,error:t instanceof Error?t.message:String(t)}),null}}function _O(e,t){let r=new Set,n=`:${t}`;for(let o of e.split(/\r?\n/)){let s=o.trim();if(!/^TCP\b/i.test(s))continue;let i=s.split(/\s+/);if(!i[1]?.endsWith(n)||i[3]!=="LISTENING")continue;let c=Number.parseInt(i[4]??"",10);Number.isInteger(c)&&c>0&&r.add(c)}return[...r]}async function VS(e,t={}){let r=t.isWin32??(()=>process.platform==="win32"),n=t.listOwners??gO,o=t.readTable??hO,s=t.killTree??((y,b)=>gt(y,b)),i=t.dataDir??(()=>ce);if(!r())return{reclaimed:!1,reason:"not-supported",killedPids:[]};let a=await n(e);if(a===null)return{reclaimed:!1,reason:"netstat-unreadable",killedPids:[]};if(a.length===0)return{reclaimed:!1,reason:"no-listener",killedPids:[]};let c=await o();if(c===null)return{reclaimed:!1,reason:"table-unreadable",killedPids:[]};if(a.filter(y=>fe(y)).length>0)return{reclaimed:!1,reason:"owner-alive",killedPids:[]};let l=new Map;for(let y of c){let b=l.get(y.ppid);b?b.push(y):l.set(y.ppid,[y])}let d=new Map,f=new Set,p=y=>{for(let b of l.get(y)??[])f.has(b.pid)||(f.add(b.pid),p(b.pid),WS(b.name)&&d.set(b.pid,b))};for(let y of a)p(y);let m=i();if(m)for(let y of c)d.has(y.pid)||WS(y.name)&&mO(y.cmdline,m)&&d.set(y.pid,y);if(d.size===0)return _.info("PROCESS","Ghost listener owner is dead but no chroma-sidecar descendants found",{port:e,deadOwners:a,processTableRows:c.length,dataDir:m??"(unresolved)"}),{reclaimed:!1,reason:"no-chroma-descendants",killedPids:[]};_.warn("PROCESS","Reclaiming ghost listener: killing dead worker's surviving chroma sidecar chain",{port:e,deadOwners:a,targets:[...d.values()].map(y=>({pid:y.pid,name:y.name}))});let h=[];for(let y of d.values())try{await s(y.pid,{expectedStartToken:y.startToken,signalMode:"immediate"}),h.push(y.pid)}catch(b){return _.error("PROCESS","Ghost-port reclaim tree-kill failed",{port:e,pid:y.pid},b instanceof Error?b:new Error(String(b))),{reclaimed:!1,reason:"kill-failed",killedPids:h}}let g=await n(e);return g!==null&&g.length===0?(_.info("PROCESS","Ghost listener reclaimed \u2014 port is free again",{port:e,killedPids:h}),{reclaimed:!0,killedPids:h}):(_.warn("PROCESS","Ghost-port reclaim killed the sidecar chain but the port is still bound",{port:e,killedPids:h,stillOwnedBy:g}),{reclaimed:!1,reason:"still-bound",killedPids:h})}var yO=120*1e3;function ed(){return Ql.default.join(ht.get("CLAUDE_MEM_DATA_DIR"),".worker-start-attempted")}function SO(){if(process.platform!=="win32")return!1;let e=ed();if(!(0,ot.existsSync)(e))return!1;try{let t=(0,ot.statSync)(e).mtimeMs;return Date.now()-t<yO}catch(t){return t instanceof Error?_.debug("SYSTEM","Could not stat worker spawn lock file",{},t):_.debug("SYSTEM","Could not stat worker spawn lock file",{error:String(t)}),!1}}function EO(){if(process.platform==="win32")try{let e=ed();(0,ot.mkdirSync)(Ql.default.dirname(e),{recursive:!0}),(0,ot.writeFileSync)(e,"","utf-8")}catch{}}function xo(){if(process.platform==="win32")try{let e=ed();(0,ot.existsSync)(e)&&(0,ot.unlinkSync)(e)}catch{}}var Hi;async function YS(e,t){if(Hi=void 0,!t)return _.error("SYSTEM","ensureWorkerStarted called with empty workerScriptPath \u2014 caller bug"),"dead";if(!(0,ot.existsSync)(t))return _.error("SYSTEM","ensureWorkerStarted: worker script not found at expected path \u2014 likely a partial install or build artifact missing",{workerScriptPath:t}),"dead";if(Ni()==="alive"){if(_.info("SYSTEM","Worker PID file points to a live process, skipping duplicate spawn"),await ko(e,vr(Ae.READINESS_WAIT)))return xo(),_.info("SYSTEM","Worker became ready while waiting on live PID"),"ready";let a=await vo(e,1e3),c=Ni()==="alive";return!a&&!c?(_.error("SYSTEM","Live PID disappeared before readiness endpoint became available"),"dead"):(_.warn("SYSTEM","Live PID detected but worker did not become ready before timeout"),"warming")}if(await vo(e,1e3)){xo();let i=await ko(e,vr(Ae.READINESS_WAIT));return i||_.warn("SYSTEM","Worker is alive but readiness timed out \u2014 proceeding anyway"),_.info("SYSTEM","Worker already running and healthy"),i?"ready":"warming"}if(await Bl(e)){if(_.info("SYSTEM","Port in use, waiting for worker to become healthy"),await vo(e,vr(Ae.PORT_IN_USE_WAIT))){xo();let c=await ko(e,vr(Ae.READINESS_WAIT));return _.info("SYSTEM","Worker is now healthy"),c?"ready":"warming"}let a=await VS(e);if(a.reclaimed)_.info("SYSTEM","Reclaimed ghost listener left by a dead worker \u2014 proceeding to spawn",{port:e,killedPids:a.killedPids}),xo();else return _.error("SYSTEM","Port in use but worker not responding to health checks",{port:e,reclaimReason:a.reason}),"dead"}if(SO())return _.warn("SYSTEM","Worker unavailable on Windows \u2014 skipping spawn (recent attempt failed within cooldown)"),"dead";let o=Kl(),s;try{if(o){if(_.info("SYSTEM","Starting worker daemon",{workerScriptPath:t}),EO(),s=CS(t,e),s===void 0)return _.error("SYSTEM","Failed to spawn worker daemon"),"dead"}else _.info("SYSTEM","Another launcher holds the spawn lock \u2014 skipping duplicate spawn and waiting for its worker");if(!await ko(e,vr(Ae.READINESS_WAIT))){let a=await vo(e,1e3),c=Ni()==="alive",u=s!==void 0&&s>0&&fe(s);return!a&&!c&&!u?o?(Hi=IS(t),_.error("SYSTEM","Worker exited before readiness endpoint became available",Hi?{bootFailure:Hi}:{}),"dead"):(_.error("SYSTEM","Spawn-lock holder never produced a live worker before readiness timed out"),"dead"):(_.warn("SYSTEM",o?"Worker spawned but readiness endpoint not responding within window":"Spawn-lock holder's worker not ready within window"),"warming")}return xo(),MS(),_.info("SYSTEM",o?"Worker started successfully":"Worker is up (started by another launcher)"),"ready"}finally{o&&Gl()}}var un=require("node:fs/promises"),Po=require("node:path");var id=require("node:child_process"),Ee=require("node:fs"),Me=require("node:path"),ad=require("node:os"),nd=require("node:module");X();Ze();var LO={},od=typeof __CM_FILENAME__<"u"?(0,nd.createRequire)(__CM_FILENAME__):(0,nd.createRequire)(LO.url),bO={".js":"javascript",".mjs":"javascript",".cjs":"javascript",".jsx":"tsx",".ts":"typescript",".tsx":"tsx",".py":"python",".pyw":"python",".go":"go",".rs":"rust",".rb":"ruby",".java":"java",".c":"c",".h":"c",".cpp":"cpp",".cc":"cpp",".cxx":"cpp",".hpp":"cpp",".hh":"cpp",".kt":"kotlin",".kts":"kotlin",".swift":"swift",".php":"php",".lua":"lua",".scala":"scala",".sc":"scala",".sh":"bash",".bash":"bash",".zsh":"bash",".hs":"haskell",".zig":"zig",".css":"css",".scss":"scss",".toml":"toml",".yml":"yaml",".yaml":"yaml",".sql":"sql",".md":"markdown",".mdx":"markdown"};function rE(e){let t=e.slice(e.lastIndexOf("."));return bO[t]??"unknown"}var wO={javascript:"tree-sitter-javascript",typescript:"tree-sitter-typescript/typescript",tsx:"tree-sitter-typescript/tsx",python:"tree-sitter-python",go:"tree-sitter-go",rust:"tree-sitter-rust",ruby:"tree-sitter-ruby",java:"tree-sitter-java",c:"tree-sitter-c",cpp:"tree-sitter-cpp",kotlin:"tree-sitter-kotlin",swift:"tree-sitter-swift",php:"tree-sitter-php/php",lua:"@tree-sitter-grammars/tree-sitter-lua",scala:"tree-sitter-scala",bash:"tree-sitter-bash",haskell:"tree-sitter-haskell",zig:"@tree-sitter-grammars/tree-sitter-zig",css:"tree-sitter-css",scss:"tree-sitter-scss",toml:"@tree-sitter-grammars/tree-sitter-toml",yaml:"@tree-sitter-grammars/tree-sitter-yaml",sql:"@derekstride/tree-sitter-sql",markdown:"@tree-sitter-grammars/tree-sitter-markdown"},vO={markdown:"tree-sitter-markdown"};function nE(e){let t=wO[e];if(!t)return null;let r=vO[e];if(r){try{let n=od.resolve(t+"/package.json"),o=(0,Me.join)((0,Me.dirname)(n),r);if((0,Ee.existsSync)((0,Me.join)(o,"src")))return o}catch{}return null}try{let n=od.resolve(t+"/package.json");return(0,Me.dirname)(n)}catch{return null}}var kO={jsts:`
|
|
85
85
|
(function_declaration name: (identifier) @name) @func
|
|
86
86
|
(lexical_declaration (variable_declarator name: (identifier) @name value: [(arrow_function) (function_expression)])) @const_func
|
|
87
87
|
(class_declaration name: (type_identifier) @name) @cls
|
|
@@ -203,25 +203,25 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
203
203
|
(class_definition name: (identifier) @name) @cls
|
|
204
204
|
(import_statement) @imp
|
|
205
205
|
(import_declaration) @imp
|
|
206
|
-
`};function oE(e){switch(e){case"javascript":return"js";case"typescript":case"tsx":return"jsts";case"python":return"python";case"go":return"go";case"rust":return"rust";case"ruby":return"ruby";case"java":return"java";case"kotlin":return"kotlin";case"swift":return"swift";case"php":return"php";case"lua":return"lua";case"scala":return"scala";case"bash":return"bash";case"haskell":return"haskell";case"zig":return"zig";case"css":return"css";case"scss":return"scss";case"toml":return"toml";case"yaml":return"yaml";case"sql":return"sql";case"markdown":return"markdown";default:return"generic"}}var td=null,rd=new Map;function sE(e){if(rd.has(e))return rd.get(e);td||(td=(0,Ee.mkdtempSync)((0,Me.join)((0,ad.tmpdir)(),"smart-read-queries-")));let t=(0,Me.join)(td,`${e}.scm`);return(0,Ee.writeFileSync)(t,
|
|
207
|
-
`)){if(o.length>0&&!o.startsWith(" ")&&!o.startsWith(" ")){r=o.trim(),t.has(r)||t.set(r,[]),n=null;continue}if(!r)continue;let s=o.match(/^\s+pattern:\s+(\d+)/);if(s){n={pattern:parseInt(s[1]),captures:[]},t.get(r).push(n);continue}let i=o.match(/^\s+capture:\s+(?:\d+\s*-\s*)?(\w+),\s*start:\s*\((\d+),\s*(\d+)\),\s*end:\s*\((\d+),\s*(\d+)\)(?:,\s*text:\s*`([^`]*)`)?/);i&&n&&n.captures.push({tag:i[1],startRow:parseInt(i[2]),startCol:parseInt(i[3]),endRow:parseInt(i[4]),endCol:parseInt(i[5]),text:i[6]})}return t}var eE={func:"function",const_func:"function",cls:"class",method:"method",iface:"interface",tdef:"type",enm:"enum",struct_def:"struct",trait_def:"trait",impl_def:"impl",mixin_def:"mixin",heading:"section",code_block:"code",frontmatter:"metadata",ref:"reference"}
|
|
208
|
-
`),a=i.indexOf("{");a!==-1&&a<500&&(s=i.slice(0,a).replace(/\n/g," ").replace(/\s+/g," ").trim())}return s=s.replace(/\s*[{:]\s*$/,"").trim(),s.length>n&&(s=s.slice(0,n-3)+"..."),s}function
|
|
209
|
-
`).trim():void 0}function
|
|
210
|
-
`),o=nE(r);if(!o)return{filePath:t,language:r,symbols:[],imports:[],totalLines:n.length,foldedTokenEstimate:50};let s=sE(oE(r)),i=t.slice(t.lastIndexOf("."))||".txt",a=(0,Ee.mkdtempSync)((0,Me.join)((0,ad.tmpdir)(),"smart-src-")),c=(0,Me.join)(a,`source${i}`);(0,Ee.writeFileSync)(c,e);try{let u=
|
|
206
|
+
`};function oE(e){switch(e){case"javascript":return"js";case"typescript":case"tsx":return"jsts";case"python":return"python";case"go":return"go";case"rust":return"rust";case"ruby":return"ruby";case"java":return"java";case"kotlin":return"kotlin";case"swift":return"swift";case"php":return"php";case"lua":return"lua";case"scala":return"scala";case"bash":return"bash";case"haskell":return"haskell";case"zig":return"zig";case"css":return"css";case"scss":return"scss";case"toml":return"toml";case"yaml":return"yaml";case"sql":return"sql";case"markdown":return"markdown";default:return"generic"}}var td=null,rd=new Map;function sE(e){if(rd.has(e))return rd.get(e);td||(td=(0,Ee.mkdtempSync)((0,Me.join)((0,ad.tmpdir)(),"smart-read-queries-")));let t=(0,Me.join)(td,`${e}.scm`);return(0,Ee.writeFileSync)(t,kO[e]),rd.set(e,t),t}function xO(e=process.platform){let t=e==="win32"?"tree-sitter.exe":"tree-sitter";try{let r=od.resolve("tree-sitter-cli/package.json"),n=(0,Me.join)((0,Me.dirname)(r),t);if((0,Ee.existsSync)(n))return n}catch{}return t}var Wi=null;function iE(){return Wi||(Wi=xO(),Wi)}var JS=(0,Me.join)(sr(),"tree-sitter-libs"),PO=process.platform==="win32"?".dll":process.platform==="darwin"?".dylib":".so",TO=["parser.c","scanner.c","scanner.cc"],sd=new Set;function $O(e){let t=0;for(let r of TO)try{let n=(0,Ee.statSync)((0,Me.join)(e,"src",r));n.mtimeMs>t&&(t=n.mtimeMs)}catch{}return t}function RO(e,t){if(sd.has(e))return null;let r=(0,Me.join)(JS,`${e}${PO}`);try{return(!(0,Ee.existsSync)(r)||(0,Ee.statSync)(r).mtimeMs<$O(t))&&((0,Ee.mkdirSync)(JS,{recursive:!0}),(0,id.execFileSync)(iE(),["build","-o",r,t],{encoding:"utf-8",timeout:12e4,stdio:["pipe","pipe","pipe"]})),r}catch(n){return _.debug("WORKER",`tree-sitter build failed for ${e}; falling back to --grammar-path`,void 0,n instanceof Error?n:void 0),sd.add(e),null}}function AO(e,t,r,n){return aE(e,[t],r,n).get(t)||[]}function XS(e,t){try{return(0,id.execFileSync)(iE(),e,{encoding:"utf-8",timeout:3e4,stdio:["pipe","pipe","pipe"]})}catch(r){return _.debug("WORKER",`tree-sitter query failed for ${t} file(s)`,void 0,r instanceof Error?r:void 0),null}}function aE(e,t,r,n){if(t.length===0)return new Map;let o=RO(n,r);if(o){let i=XS(["query","-l",o,"--lang-name",n,e,...t],t.length);if(i!==null)return QS(i);sd.add(n)}let s=XS(["query","-p",r,e,...t],t.length);return s===null?new Map:QS(s)}function QS(e){let t=new Map,r=null,n=null;for(let o of e.split(`
|
|
207
|
+
`)){if(o.length>0&&!o.startsWith(" ")&&!o.startsWith(" ")){r=o.trim(),t.has(r)||t.set(r,[]),n=null;continue}if(!r)continue;let s=o.match(/^\s+pattern:\s+(\d+)/);if(s){n={pattern:parseInt(s[1]),captures:[]},t.get(r).push(n);continue}let i=o.match(/^\s+capture:\s+(?:\d+\s*-\s*)?(\w+),\s*start:\s*\((\d+),\s*(\d+)\),\s*end:\s*\((\d+),\s*(\d+)\)(?:,\s*text:\s*`([^`]*)`)?/);i&&n&&n.captures.push({tag:i[1],startRow:parseInt(i[2]),startCol:parseInt(i[3]),endRow:parseInt(i[4]),endCol:parseInt(i[5]),text:i[6]})}return t}var eE={func:"function",const_func:"function",cls:"class",method:"method",iface:"interface",tdef:"type",enm:"enum",struct_def:"struct",trait_def:"trait",impl_def:"impl",mixin_def:"mixin",heading:"section",code_block:"code",frontmatter:"metadata",ref:"reference"},OO=new Set(["class","struct","impl","trait"]);function IO(e,t,r,n=200){let s=e[t]||"";if(!s.trimEnd().endsWith("{")&&!s.trimEnd().endsWith(":")){let i=e.slice(t,Math.min(t+10,r+1)).join(`
|
|
208
|
+
`),a=i.indexOf("{");a!==-1&&a<500&&(s=i.slice(0,a).replace(/\n/g," ").replace(/\s+/g," ").trim())}return s=s.replace(/\s*[{:]\s*$/,"").trim(),s.length>n&&(s=s.slice(0,n-3)+"..."),s}function CO(e,t){let r=[],n=!1;for(let o=t-1;o>=0;o--){let s=e[o].trim();if(s===""){if(n)break;continue}if(s.startsWith("/**")||s.startsWith("*")||s.startsWith("*/")||s.startsWith("//")||s.startsWith("///")||s.startsWith("//!")||s.startsWith("#")||s.startsWith("@"))r.unshift(e[o]),n=!0;else break}return r.length>0?r.join(`
|
|
209
|
+
`).trim():void 0}function MO(e,t,r){for(let n=t+1;n<=Math.min(t+3,r);n++){let o=e[n]?.trim();if(o){if(o.startsWith('"""')||o.startsWith("'''"))return o;break}}}function zO(e,t,r,n,o,s){switch(s){case"javascript":case"typescript":case"tsx":return n.some(i=>t>=i.startRow&&r<=i.endRow);case"python":return!e.startsWith("_");case"go":return e.length>0&&e[0]===e[0].toUpperCase()&&e[0]!==e[0].toLowerCase();case"rust":return o[t]?.trimStart().startsWith("pub")??!1;default:return!0}}function cE(e,t,r){let n=[],o=[],s=[],i=[];for(let c of e)for(let u of c.captures)u.tag==="exp"&&s.push({startRow:u.startRow,endRow:u.endRow}),u.tag==="imp"&&o.push(u.text||t[u.startRow]?.trim()||"");for(let c of e){let u=c.captures.find(w=>eE[w.tag]),l=c.captures.find(w=>w.tag==="name");if(!u)continue;let d=u.startRow,f=u.endRow,p=eE[u.tag],m=l?.text||"anonymous",h;if(r==="markdown"&&p==="section"){let O=(t[d]||"").match(/^(#{1,6})\s/),x=O?O[1].length:1;h=`${"#".repeat(x)} ${m}`}else if(r==="markdown"&&p==="code"){let w=m!=="anonymous"?m:"";h=w?"```"+w:"```"}else r==="markdown"&&p==="metadata"?h="---frontmatter---":r==="markdown"&&p==="reference"?h=t[d]?.trim()||m:h=IO(t,d,f);let g=r==="markdown"?void 0:CO(t,d),y=r==="python"?MO(t,d,f):void 0,b={name:m,kind:p,signature:h,jsdoc:g||y,lineStart:d,lineEnd:f,exported:zO(m,d,f,s,t,r)};OO.has(p)&&(b.children=[],i.push({sym:b,startRow:d,endRow:f})),n.push(b)}if(r==="markdown"){let c=new Map,u=new Set;for(let l of n){if(l.kind!=="code")continue;let d=`${l.lineStart}:${l.lineEnd}`,f=c.get(d);f?l.name!=="anonymous"?(u.add(f),c.set(d,l)):u.add(l):c.set(d,l)}if(u.size>0){let l=n.filter(d=>!u.has(d));n.length=0,n.push(...l)}}let a=new Set;for(let c of i)for(let u of n)u!==c.sym&&u.lineStart>c.startRow&&u.lineEnd<=c.endRow&&(u.kind==="function"&&(u.kind="method"),c.sym.children.push(u),a.add(u));return{symbols:n.filter(c=>!a.has(c)),imports:o}}function Bi(e,t){let r=rE(t),n=e.split(`
|
|
210
|
+
`),o=nE(r);if(!o)return{filePath:t,language:r,symbols:[],imports:[],totalLines:n.length,foldedTokenEstimate:50};let s=sE(oE(r)),i=t.slice(t.lastIndexOf("."))||".txt",a=(0,Ee.mkdtempSync)((0,Me.join)((0,ad.tmpdir)(),"smart-src-")),c=(0,Me.join)(a,`source${i}`);(0,Ee.writeFileSync)(c,e);try{let u=AO(s,c,o,r),l=cE(u,n,r),d=cn({filePath:t,language:r,symbols:l.symbols,imports:l.imports,totalLines:n.length,foldedTokenEstimate:0});return{filePath:t,language:r,symbols:l.symbols,imports:l.imports,totalLines:n.length,foldedTokenEstimate:Math.ceil(d.length/4)}}finally{(0,Ee.rmSync)(a,{recursive:!0,force:!0})}}function uE(e){let t=new Map,r=new Map;for(let n of e){let o=rE(n.relativePath);r.has(o)||r.set(o,[]),r.get(o).push(n)}for(let[n,o]of r){let s=nE(n);if(!s){for(let u of o){let l=u.content.split(`
|
|
211
211
|
`);t.set(u.relativePath,{filePath:u.relativePath,language:n,symbols:[],imports:[],totalLines:l.length,foldedTokenEstimate:50})}continue}let i=sE(oE(n)),a=o.map(u=>u.absolutePath),c=aE(i,a,s,n);for(let u of o){let l=u.content.split(`
|
|
212
|
-
`),d=c.get(u.absolutePath)||[],f=cE(d,l,n),p=
|
|
213
|
-
`)}function
|
|
214
|
-
`)}function tE(e,t){let r=0;for(let n of e)if(n.kind==="section"&&n.lineStart<t){let o=n.signature.match(/^(#{1,6})\s/);r=o?o[1].length:1}return r}function lE(e,t){let r=[],n=
|
|
212
|
+
`),d=c.get(u.absolutePath)||[],f=cE(d,l,n),p=cn({filePath:u.relativePath,language:n,symbols:f.symbols,imports:f.imports,totalLines:l.length,foldedTokenEstimate:0});t.set(u.relativePath,{filePath:u.relativePath,language:n,symbols:f.symbols,imports:f.imports,totalLines:l.length,foldedTokenEstimate:Math.ceil(p.length/4)})}}return t}function cn(e){if(e.language==="markdown")return DO(e);let t=[];if(t.push(`\u{1F4C1} ${e.filePath} (${e.language}, ${e.totalLines} lines)`),t.push(""),e.imports.length>0){t.push(` \u{1F4E6} Imports: ${e.imports.length} statements`);for(let r of e.imports.slice(0,10))t.push(` ${r}`);e.imports.length>10&&t.push(` ... +${e.imports.length-10} more`),t.push("")}for(let r of e.symbols)t.push(lE(r," "));return t.join(`
|
|
213
|
+
`)}function DO(e){let t=[];t.push(`\u{1F4C4} ${e.filePath} (${e.language}, ${e.totalLines} lines)`);for(let n of e.symbols)if(n.kind==="section"){let o=n.signature.match(/^(#{1,6})\s/),s=o?o[1].length:1,i=" ".repeat(s),a=`L${n.lineStart+1}`,c=`${i}${n.signature}`;t.push(`${c.padEnd(56)}${a}`)}else if(n.kind==="code"){let o=tE(e.symbols,n.lineStart),s=" ".repeat(o+1),i=n.lineStart===n.lineEnd?`L${n.lineStart+1}`:`L${n.lineStart+1}-${n.lineEnd+1}`,a=`${s}${n.signature}`;t.push(`${a.padEnd(56)}${i}`)}else if(n.kind==="metadata"){let o=n.lineStart===n.lineEnd?`L${n.lineStart+1}`:`L${n.lineStart+1}-${n.lineEnd+1}`,s=` ${n.signature}`;t.push(`${s.padEnd(56)}${o}`)}else if(n.kind==="reference"){let o=tE(e.symbols,n.lineStart),s=" ".repeat(o+1),i=`L${n.lineStart+1}`,a=`${s}\u2197 ${n.name}`;t.push(`${a.padEnd(56)}${i}`)}return t.join(`
|
|
214
|
+
`)}function tE(e,t){let r=0;for(let n of e)if(n.kind==="section"&&n.lineStart<t){let o=n.signature.match(/^(#{1,6})\s/);r=o?o[1].length:1}return r}function lE(e,t){let r=[],n=NO(e.kind),o=e.exported?" [exported]":"",s=e.lineStart===e.lineEnd?`L${e.lineStart+1}`:`L${e.lineStart+1}-${e.lineEnd+1}`;if(r.push(`${t}${n} ${e.name}${o} (${s})`),r.push(`${t} ${e.signature}`),e.jsdoc){let a=e.jsdoc.split(`
|
|
215
215
|
`).find(c=>{let u=c.replace(/^[\s*/]+/,"").replace(/^['"`]{3}/,"").trim();return u.length>0&&!u.startsWith("/**")});if(a){let c=a.replace(/^[\s*/]+/,"").replace(/^['"`]{3}/,"").replace(/['"`]{3}$/,"").trim();c&&r.push(`${t} \u{1F4AC} ${c}`)}}if(e.children&&e.children.length>0)for(let i of e.children)r.push(lE(i,t+" "));return r.join(`
|
|
216
|
-
`)}function
|
|
216
|
+
`)}function NO(e){return{function:"\u0192",method:"\u0192",class:"\u25C6",interface:"\u25C7",type:"\u25C7",const:"\u25CF",variable:"\u25CB",export:"\u2192",struct:"\u25C6",enum:"\u25A3",trait:"\u25C7",impl:"\u25C8",property:"\u25CB",getter:"\u21E2",setter:"\u21E0",mixin:"\u25C8",section:"\xA7",code:"\u2318",metadata:"\u25CA",reference:"\u2197"}[e]||"\xB7"}function dE(e,t,r){let n=Bi(e,t),o=u=>{for(let l of u){if(l.name===r)return l;if(l.children){let d=o(l.children);if(d)return d}}return null},s=o(n.symbols);if(!s)return null;let i=e.split(`
|
|
217
217
|
`);if(n.language==="markdown"&&s.kind==="section"){let u=s.signature.match(/^(#{1,6})\s/),l=u?u[1].length:1,d=s.lineStart,f=i.length-1;for(let m of n.symbols)if(m.kind==="section"&&m.lineStart>d){let h=m.signature.match(/^(#{1,6})\s/);if((h?h[1].length:1)<=l){for(f=m.lineStart-1;f>d&&i[f].trim()==="";)f--;break}}let p=i.slice(d,f+1).join(`
|
|
218
218
|
`);return`<!-- \u{1F4CD} ${t} L${d+1}-${f+1} -->
|
|
219
219
|
${p}`}let a=s.lineStart;for(let u=s.lineStart-1;u>=0;u--){let l=i[u].trim();if(l===""||l.startsWith("*")||l.startsWith("/**")||l.startsWith("///")||l.startsWith("//")||l.startsWith("#")||l.startsWith("@")||l==="*/")a=u;else break}let c=i.slice(a,s.lineEnd+1).join(`
|
|
220
220
|
`);return`// \u{1F4CD} ${t} L${a+1}-${s.lineEnd+1}
|
|
221
|
-
${c}`}X();var
|
|
221
|
+
${c}`}X();var jO=new Set([".js",".jsx",".ts",".tsx",".mjs",".cjs",".py",".pyw",".go",".rs",".rb",".java",".cs",".cpp",".cc",".cxx",".c",".h",".hpp",".hh",".swift",".kt",".kts",".php",".vue",".svelte",".lua",".scala",".sc",".sh",".bash",".zsh",".hs",".zig",".css",".scss",".toml",".yml",".yaml",".sql",".md",".mdx"]),UO=new Set(["node_modules",".git","dist","build",".next","__pycache__",".venv","venv","env",".env","target","vendor",".cache",".turbo","coverage",".nyc_output",".claude",".smart-file-read"]),FO=512*1024;async function*fE(e,t,r=20){if(r<=0)return;let n;try{n=await(0,un.readdir)(e,{withFileTypes:!0})}catch(o){_.debug("WORKER",`walkDir: failed to read directory ${e}`,void 0,o instanceof Error?o:void 0);return}for(let o of n){if(o.name.startsWith(".")&&o.name!=="."||UO.has(o.name))continue;let s=(0,Po.join)(e,o.name);if(o.isDirectory())yield*fE(s,t,r-1);else if(o.isFile()){let i=o.name.slice(o.name.lastIndexOf("."));jO.has(i)&&(yield s)}}}async function qO(e){try{let t=await(0,un.stat)(e);if(t.size>FO||t.size===0)return null;let r=await(0,un.readFile)(e,"utf-8");return r.slice(0,1e3).includes("\0")?null:r}catch(t){return _.debug("WORKER",`safeReadFile: failed to read ${e}`,void 0,t instanceof Error?t:void 0),null}}async function pE(e,t,r={}){let n=r.maxResults||20,o=t.toLowerCase(),s=o.split(/[\s_\-./]+/).filter(h=>h.length>0),i=[];for await(let h of fE(e,e,20)){if(r.filePattern&&!(0,Po.relative)(e,h).toLowerCase().includes(r.filePattern.toLowerCase()))continue;let g=await qO(h);g&&i.push({absolutePath:h,relativePath:(0,Po.relative)(e,h),content:g})}let a=uE(i),c=[],u=[],l=0;for(let[h,g]of a){l+=ZO(g);let b=Ki(h.toLowerCase(),s)>0,w=[],O=(x,z)=>{for(let j of x){let Ge=0,xe="",Ve=Ki(j.name.toLowerCase(),s);Ve>0&&(Ge+=Ve*3,xe="name match"),j.signature.toLowerCase().includes(o)&&(Ge+=2,xe=xe?`${xe} + signature`:"signature match"),j.jsdoc&&j.jsdoc.toLowerCase().includes(o)&&(Ge+=1,xe=xe?`${xe} + jsdoc`:"jsdoc match"),Ge>0&&(b=!0,w.push({filePath:h,symbolName:z?`${z}.${j.name}`:j.name,kind:j.kind,signature:j.signature,jsdoc:j.jsdoc,lineStart:j.lineStart,lineEnd:j.lineEnd,matchReason:xe})),j.children&&O(j.children,j.name)}};O(g.symbols),b&&(c.push(g),u.push(...w))}u.sort((h,g)=>{let y=Ki(h.symbolName.toLowerCase(),s);return Ki(g.symbolName.toLowerCase(),s)-y});let d=u.slice(0,n),f=new Set(d.map(h=>h.filePath)),p=c.filter(h=>f.has(h.filePath)).slice(0,n),m=p.reduce((h,g)=>h+g.foldedTokenEstimate,0);return{foldedFiles:p,matchingSymbols:d,totalFilesScanned:i.length,totalSymbolsFound:l,tokenEstimate:m}}function Ki(e,t){let r=0;for(let n of t)if(e===n)r+=10;else if(e.includes(n))r+=5;else{let o=0,s=0;for(let i of n){let a=e.indexOf(i,o);a!==-1&&(s++,o=a+1)}s===n.length&&(r+=1)}return r}function ZO(e){let t=e.symbols.length;for(let r of e.symbols)r.children&&(t+=r.children.length);return t}function mE(e,t){let r=[];if(r.push(`\u{1F50D} Smart Search: "${t}"`),r.push(` Scanned ${e.totalFilesScanned} files, found ${e.totalSymbolsFound} symbols`),r.push(` ${e.matchingSymbols.length} matches across ${e.foldedFiles.length} files (~${e.tokenEstimate} tokens for folded view)`),r.push(""),e.matchingSymbols.length===0)return r.push(" No matching symbols found."),r.join(`
|
|
222
222
|
`);r.push("\u2500\u2500 Matching Symbols \u2500\u2500"),r.push("");for(let n of e.matchingSymbols){if(r.push(` ${n.kind} ${n.symbolName} (${n.filePath}:${n.lineStart+1})`),r.push(` ${n.signature}`),n.jsdoc){let o=n.jsdoc.split(`
|
|
223
|
-
`).find(s=>s.replace(/^[\s*/]+/,"").trim().length>0);o&&r.push(` \u{1F4AC} ${o.replace(/^[\s*/]+/,"").trim()}`)}r.push("")}r.push("\u2500\u2500 Folded File Views \u2500\u2500"),r.push("");for(let n of e.foldedFiles)r.push(
|
|
224
|
-
`)}var cd=require("node:fs/promises"),ud=require("node:os"),kr=require("node:path");function FO(e){return e==="~"?(0,ud.homedir)():e.startsWith("~/")||e.startsWith("~\\")?(0,kr.join)((0,ud.homedir)(),e.slice(2)):e}async function Gi(e,t=process.cwd()){if(typeof e!="string"||e.trim().length===0)throw new Error("file_path is required");let r=await(0,cd.realpath)((0,kr.resolve)(t)),n=(0,kr.resolve)(r,FO(e.trim())),o;try{o=await(0,cd.realpath)(n)}catch{o=n}if(o!==r&&!o.startsWith(r+kr.sep))throw new Error(`Access denied: "${e}" resolves outside the workspace (${r}). MCP file tools can only read files within the current project.`);return o}var dd=require("node:fs/promises"),Xi=require("node:fs"),nr=require("node:path"),bE=require("node:os"),vE=require("node:url");var hE="claude";function qO(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function Vi(e){if(!e)return hE;let t=qO(e);return t?t==="transcript"||t.includes("codex")?"codex":t.includes("cursor")?"cursor":t.includes("claude")?"claude":t:hE}var ZO=tr(Ae.API_REQUEST),st=class extends Error{kind;status;cause;constructor(t,r,n={}){super(r),this.name="ServerClientError",this.kind=t,this.status=n.status??null,this.cause=n.cause}isFallbackEligible(){return this.kind==="transport"||this.kind==="timeout"||this.kind==="missing_api_key"||this.kind==="http_error"&&(this.status!==null&&this.status>=500||this.status===429)}},Yi=class{baseUrl;apiKey;timeoutMs;constructor(t){this.baseUrl=WO(t.serverBaseUrl),this.apiKey=t.apiKey,this.timeoutMs=t.timeoutMs??ZO}async startSession(t){let r=this.buildStartSessionPayload(t);return this.request("POST","/v1/sessions/start",r)}async recordEvent(t){let r=this.buildEventPayload(t),n=t.generate===!1?"/v1/events?generate=false":"/v1/events";return this.request("POST",n,r)}async endSession(t){if(!t.sessionId)throw new st("invalid_response","sessionId is required for endSession");return this.request("POST",`/v1/sessions/${encodeURIComponent(t.sessionId)}/end`,{})}async addObservation(t){return this.request("POST","/v1/memories",this.buildAddObservationPayload(t))}async searchObservations(t){return this.request("POST","/v1/search",this.buildSearchPayload(t))}async contextObservations(t){return this.request("POST","/v1/context",this.buildSearchPayload(t))}async getJobStatus(t){if(!t)throw new st("invalid_response","jobId is required for getJobStatus");return this.request("GET",`/v1/jobs/${encodeURIComponent(t)}`)}buildAddObservationPayload(t){let r=t.content,n=t.kind??"manual",o=typeof t.metadata?.title=="string"?t.metadata.title:void 0;return{projectId:t.projectId,kind:n,type:n,narrative:r,...o?{title:o}:{},...t.serverSessionId!==void 0?{serverSessionId:t.serverSessionId}:{},...t.contentSessionId!==void 0?{contentSessionId:t.contentSessionId}:{},...t.platformSource!==void 0?{platformSource:t.platformSource}:{},...t.metadata!==void 0?{metadata:t.metadata}:{}}}buildSearchPayload(t){return{projectId:t.projectId,query:t.query,...t.limit!==void 0?{limit:t.limit}:{},...t.platformSource!==void 0?{platformSource:ld(t.platformSource)}:{}}}buildStartSessionPayload(t){return{projectId:t.projectId,...t.externalSessionId!==void 0?{externalSessionId:t.externalSessionId}:{},...t.contentSessionId!==void 0?{contentSessionId:t.contentSessionId}:{},...t.agentId!==void 0?{agentId:t.agentId}:{},...t.agentType!==void 0?{agentType:t.agentType}:{},...t.platformSource!==void 0?{platformSource:ld(t.platformSource)}:{},...t.metadata!==void 0?{metadata:t.metadata}:{}}}buildEventPayload(t){return{projectId:t.projectId,sourceType:t.sourceType,eventType:t.eventType,occurredAtEpoch:t.occurredAtEpoch,...t.serverSessionId!==void 0?{serverSessionId:t.serverSessionId}:{},...t.contentSessionId!==void 0?{contentSessionId:t.contentSessionId}:{},...t.memorySessionId!==void 0?{memorySessionId:t.memorySessionId}:{},...t.platformSource!==void 0?{platformSource:ld(t.platformSource)}:{},...t.payload!==void 0?{payload:t.payload}:{}}}async request(t,r,n){if(!this.apiKey||!this.apiKey.trim())throw new st("missing_api_key","Server API key is not configured (CLAUDE_MEM_SERVER_API_KEY).");let o=`${this.baseUrl}${r}`,s={method:t,headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}};n!==void 0&&(s.body=JSON.stringify(n));let i;try{i=await Yl(o,s,this.timeoutMs)}catch(c){let u=c instanceof Error?c.message:String(c),l=/timed out|timeout/i.test(u);throw new st(l?"timeout":"transport",`Server ${t} ${r} failed: ${u}`,{cause:c})}if(!i.ok){let c=await i.text().catch(()=>"");throw new st("http_error",`Server ${t} ${r} returned ${i.status}: ${HO(c,200)}`,{status:i.status})}let a=await i.text();if(!a||a.length===0)return{};try{return JSON.parse(a)}catch(c){let u=c instanceof Error?c:new Error(String(c));throw new st("invalid_response",`Server ${t} ${r} returned non-JSON response`,{cause:u})}}};function gE(e){return e instanceof st}function WO(e){return e.replace(/\/+$/,"")}function ld(e){return typeof e=="string"?Vi(e):null}function HO(e,t){return e.length<=t?e:`${e.slice(0,t)}\u2026`}X();function Ji(){let t=(Ai().CLAUDE_MEM_RUNTIME??"worker").trim().toLowerCase();return t==="server"||t==="server-beta"?"server":"worker"}function _E(){let e=Ai(),t=(...i)=>{for(let a of i){let c=(a??"").trim();if(c.length>0)return c}return""},r=t(e.CLAUDE_MEM_SERVER_URL,e.CLAUDE_MEM_SERVER_BETA_URL),n=t(e.CLAUDE_MEM_SERVER_API_KEY,e.CLAUDE_MEM_SERVER_BETA_API_KEY),o=t(e.CLAUDE_MEM_SERVER_PROJECT_ID,e.CLAUDE_MEM_SERVER_BETA_PROJECT_ID);if(!r)return _.warn("HOOK","[server-fallback] reason=missing_base_url"),null;if(!n)return _.warn("HOOK","[server-fallback] reason=missing_api_key"),null;if(!o)return _.warn("HOOK","[server-fallback] reason=missing_project_id"),null;let s={serverBaseUrl:r,apiKey:n};return{runtime:"server",client:new Yi(s),projectId:o,serverBaseUrl:r}}X();var yE=["observation_add","observation_record_event","observation_search","observation_context","observation_generation_status","memory_add","memory_search","memory_context"],BO=new Set(yE);function SE(e,t){return t==="server"?[...e]:(_.debug("SYSTEM","Filtering server-beta-only MCP tools from worker runtime advertisement",{runtime:t,hiddenToolCount:yE.length}),e.filter(r=>!BO.has(r.name)))}var fI={},KO="13.25.3";console.log=(...e)=>{_.error("CONSOLE","Intercepted console output (MCP protocol protection)",void 0,{args:e})};var wE=!1,kE=(()=>{if(typeof __CM_DIRNAME__<"u")return __CM_DIRNAME__;try{return(0,nr.dirname)((0,vE.fileURLToPath)(fI.url))}catch(e){return wE=!0,_.warn("SYSTEM","mcp-server: failed to resolve module directory from import.meta.url, falling back to process.cwd()",void 0,e instanceof Error?e:new Error(String(e))),process.cwd()}})(),fd=WS()??(0,nr.resolve)(kE,"worker-service.cjs");function GO(){wE&&((0,Xi.existsSync)(fd)||_.error("SYSTEM","mcp-server: dirname resolution failed (both __dirname and import.meta.url are unavailable). Fell back to process.cwd() and the resolved WORKER_SCRIPT_PATH does not exist. This is the actual problem \u2014 the worker bundle is fine, but mcp-server cannot locate it. Worker auto-start will fail until the dirname-resolution path is fixed.",{workerScriptPath:fd,mcpServerDir:kE}))}async function _t(e,t={}){_.debug("SYSTEM","\u2192 Worker API",void 0,{endpoint:e});try{let r;if(t.body)r=await Zi(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.body)});else{let n=new URLSearchParams;for(let[o,s]of Object.entries(t.query??{}))s!=null&&n.append(o,String(s));r=await Zi(`${e}?${n}`)}if(!r.ok){let n=await r.text();throw new Error(`Worker API error (${r.status}): ${n}`)}return _.debug("SYSTEM","\u2190 Worker API success",void 0,{endpoint:e}),t.text?{content:[{type:"text",text:await r.text()}]}:t.body?{content:[{type:"text",text:JSON.stringify(await r.json(),null,2)}]}:await r.json()}catch(r){return _.error("SYSTEM","\u2190 Worker API error",{endpoint:e},r instanceof Error?r:new Error(String(r))),{content:[{type:"text",text:`Error calling Worker API: ${r instanceof Error?r.message:String(r)}`}],isError:!0}}}async function VO(){try{return(await Zi("/api/health")).ok}catch(e){return _.debug("SYSTEM","Worker health check failed",{},e instanceof Error?e:new Error(String(e))),!1}}function xE(){if(Ji()!=="server")return null;let t=_E();return t?{...t,available:!0}:{runtime:"server",available:!1,reason:"server runtime is selected but configuration is incomplete (missing url, api key, or project id)"}}function YO(e){return gE(e)?{content:[{type:"text",text:`Server error (${e.kind}${e.status?` ${e.status}`:""}): ${e.message}`}],isError:!0}:{content:[{type:"text",text:`Tool error: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}function un(e){return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}function $o(e){let t=xE();if(!t)throw new st("transport",`${e} requires CLAUDE_MEM_RUNTIME=server. Current runtime is "worker"; use the existing search/timeline/get_observations tools for worker-mode memory access.`);if(!t.available)throw new st("missing_api_key",`${e}: ${t.reason}`);return t}function Ro(e,t){return async r=>{try{return await t(r)}catch(n){let o=n instanceof Error?n:new Error(String(n));return _.warn("SYSTEM",`${e} failed`,void 0,o),YO(n)}}}var JO=Ro("observation_add",async e=>{let t=$o("observation_add");if(typeof e?.content!="string"||e.content.trim().length===0)throw new Error('observation_add: "content" is required');let n={projectId:e.projectId&&e.projectId.trim().length>0?e.projectId:t.projectId,content:e.content,...e.serverSessionId!==void 0?{serverSessionId:e.serverSessionId}:{},...e.contentSessionId!==void 0?{contentSessionId:e.contentSessionId}:{},...e.platformSource!==void 0?{platformSource:e.platformSource}:{},...e.kind!==void 0?{kind:e.kind}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}},o=await t.client.addObservation(n);return un(o)});function ea(e){return typeof e=="string"?Vi(e):null}var XO=Ro("observation_record_event",async e=>{let t=$o("observation_record_event");if(typeof e?.eventType!="string"||e.eventType.trim().length===0)throw new Error('observation_record_event: "eventType" is required');let n={projectId:e.projectId&&e.projectId.trim().length>0?e.projectId:t.projectId,sourceType:e.sourceType??"api",eventType:e.eventType,occurredAtEpoch:typeof e.occurredAtEpoch=="number"?e.occurredAtEpoch:Date.now(),...e.serverSessionId!==void 0?{serverSessionId:e.serverSessionId}:{},...e.contentSessionId!==void 0?{contentSessionId:e.contentSessionId}:{},...e.memorySessionId!==void 0?{memorySessionId:e.memorySessionId}:{},...e.platformSource!==void 0?{platformSource:ea(e.platformSource)}:{},...e.payload!==void 0?{payload:e.payload}:{},...e.generate!==void 0?{generate:e.generate}:{}},o=await t.client.recordEvent(n);return un(o)}),QO=Ro("observation_search",async e=>{let t=$o("observation_search");if(typeof e?.query!="string"||e.query.trim().length===0)throw new Error('observation_search: "query" is required');let n={projectId:e.projectId&&e.projectId.trim().length>0?e.projectId:t.projectId,query:e.query,...e.limit!==void 0?{limit:e.limit}:{},...e.platformSource!==void 0?{platformSource:ea(e.platformSource)}:{}},o=await t.client.searchObservations(n);return un(o)}),eI=Ro("observation_context",async e=>{let t=$o("observation_context");if(typeof e?.query!="string"||e.query.trim().length===0)throw new Error('observation_context: "query" is required');let n={projectId:e.projectId&&e.projectId.trim().length>0?e.projectId:t.projectId,query:e.query,...e.limit!==void 0?{limit:e.limit}:{},...e.platformSource!==void 0?{platformSource:ea(e.platformSource)}:{}},o=await t.client.contextObservations(n);return un(o)});function tI(e){return Array.isArray(e.projects)?e.projects.map(t=>typeof t=="string"?t.trim():"").filter(Boolean):typeof e.projects=="string"?e.projects.split(",").map(t=>t.trim()).filter(Boolean):typeof e.project=="string"&&e.project.trim().length>0?[e.project.trim()]:[]}async function rI(e){let t=tI(e);return t.length===0?{content:[{type:"text",text:'session_start_context: "project" or "projects" is required'}],isError:!0}:_t("/api/context/inject",{query:{projects:t.join(","),...e.platformSource!==void 0?{platformSource:ea(e.platformSource)}:{},...e.full!==void 0?{full:e.full}:{},...e.colors!==void 0?{colors:e.colors}:{}},text:!0})}var nI=Ro("observation_generation_status",async e=>{let t=$o("observation_generation_status"),r=(e?.jobId??e?.job_id??"").trim();if(!r)throw new Error('observation_generation_status: "jobId" is required');let n=await t.client.getJobStatus(r);return un(n)});async function oI(){if(await VO())return!0;_.warn("SYSTEM","Worker not available, attempting auto-start for MCP client"),GO();try{let e=Xl(),t=await YS(e,fd);return t==="dead"&&_.error("SYSTEM","Worker auto-start failed \u2014 MCP tools that require the worker (search, timeline, get_observations) will fail until the worker is running. Check earlier log lines for the specific failure reason (Bun not found, missing worker bundle, port conflict, etc.)."),t!=="dead"}catch(e){return _.error("SYSTEM","Worker auto-start threw \u2014 MCP tools that require the worker (search, timeline, get_observations) will fail until the worker is running.",void 0,e instanceof Error?e:new Error(String(e))),!1}}var PE=[{name:"important_workflow",description:`LAYERED WORKFLOW (ALWAYS FOLLOW):
|
|
223
|
+
`).find(s=>s.replace(/^[\s*/]+/,"").trim().length>0);o&&r.push(` \u{1F4AC} ${o.replace(/^[\s*/]+/,"").trim()}`)}r.push("")}r.push("\u2500\u2500 Folded File Views \u2500\u2500"),r.push("");for(let n of e.foldedFiles)r.push(cn(n)),r.push("");return r.push("\u2500\u2500 Actions \u2500\u2500"),r.push(" To see full implementation: use smart_unfold with file path and symbol name"),r.join(`
|
|
224
|
+
`)}var cd=require("node:fs/promises"),ud=require("node:os"),kr=require("node:path");function HO(e){return e==="~"?(0,ud.homedir)():e.startsWith("~/")||e.startsWith("~\\")?(0,kr.join)((0,ud.homedir)(),e.slice(2)):e}async function Gi(e,t=process.cwd()){if(typeof e!="string"||e.trim().length===0)throw new Error("file_path is required");let r=await(0,cd.realpath)((0,kr.resolve)(t)),n=(0,kr.resolve)(r,HO(e.trim())),o;try{o=await(0,cd.realpath)(n)}catch{o=n}if(o!==r&&!o.startsWith(r+kr.sep))throw new Error(`Access denied: "${e}" resolves outside the workspace (${r}). MCP file tools can only read files within the current project.`);return o}var dd=require("node:fs/promises"),Xi=require("node:fs"),nr=require("node:path"),bE=require("node:os"),wE=require("node:url");var hE="claude";function WO(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function Vi(e){if(!e)return hE;let t=WO(e);return t?t==="transcript"||t.includes("codex")?"codex":t.includes("cursor")?"cursor":t.includes("claude")?"claude":t:hE}var BO=tr(Ae.API_REQUEST),st=class extends Error{kind;status;cause;constructor(t,r,n={}){super(r),this.name="ServerClientError",this.kind=t,this.status=n.status??null,this.cause=n.cause}isFallbackEligible(){return this.kind==="transport"||this.kind==="timeout"||this.kind==="missing_api_key"||this.kind==="http_error"&&(this.status!==null&&this.status>=500||this.status===429)}},Yi=class{baseUrl;apiKey;timeoutMs;constructor(t){this.baseUrl=KO(t.serverBaseUrl),this.apiKey=t.apiKey,this.timeoutMs=t.timeoutMs??BO}async startSession(t){let r=this.buildStartSessionPayload(t);return this.request("POST","/v1/sessions/start",r)}async recordEvent(t){let r=this.buildEventPayload(t),n=t.generate===!1?"/v1/events?generate=false":"/v1/events";return this.request("POST",n,r)}async endSession(t){if(!t.sessionId)throw new st("invalid_response","sessionId is required for endSession");return this.request("POST",`/v1/sessions/${encodeURIComponent(t.sessionId)}/end`,{})}async addObservation(t){return this.request("POST","/v1/memories",this.buildAddObservationPayload(t))}async searchObservations(t){return this.request("POST","/v1/search",this.buildSearchPayload(t))}async contextObservations(t){return this.request("POST","/v1/context",this.buildSearchPayload(t))}async getJobStatus(t){if(!t)throw new st("invalid_response","jobId is required for getJobStatus");return this.request("GET",`/v1/jobs/${encodeURIComponent(t)}`)}buildAddObservationPayload(t){let r=t.content,n=t.kind??"manual",o=typeof t.metadata?.title=="string"?t.metadata.title:void 0;return{projectId:t.projectId,kind:n,type:n,narrative:r,...o?{title:o}:{},...t.serverSessionId!==void 0?{serverSessionId:t.serverSessionId}:{},...t.contentSessionId!==void 0?{contentSessionId:t.contentSessionId}:{},...t.platformSource!==void 0?{platformSource:t.platformSource}:{},...t.metadata!==void 0?{metadata:t.metadata}:{}}}buildSearchPayload(t){return{projectId:t.projectId,query:t.query,...t.limit!==void 0?{limit:t.limit}:{},...t.platformSource!==void 0?{platformSource:ld(t.platformSource)}:{}}}buildStartSessionPayload(t){return{projectId:t.projectId,...t.externalSessionId!==void 0?{externalSessionId:t.externalSessionId}:{},...t.contentSessionId!==void 0?{contentSessionId:t.contentSessionId}:{},...t.agentId!==void 0?{agentId:t.agentId}:{},...t.agentType!==void 0?{agentType:t.agentType}:{},...t.platformSource!==void 0?{platformSource:ld(t.platformSource)}:{},...t.metadata!==void 0?{metadata:t.metadata}:{}}}buildEventPayload(t){return{projectId:t.projectId,sourceType:t.sourceType,eventType:t.eventType,occurredAtEpoch:t.occurredAtEpoch,...t.serverSessionId!==void 0?{serverSessionId:t.serverSessionId}:{},...t.contentSessionId!==void 0?{contentSessionId:t.contentSessionId}:{},...t.memorySessionId!==void 0?{memorySessionId:t.memorySessionId}:{},...t.platformSource!==void 0?{platformSource:ld(t.platformSource)}:{},...t.payload!==void 0?{payload:t.payload}:{}}}async request(t,r,n){if(!this.apiKey||!this.apiKey.trim())throw new st("missing_api_key","Server API key is not configured (CLAUDE_MEM_SERVER_API_KEY).");let o=`${this.baseUrl}${r}`,s={method:t,headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}};n!==void 0&&(s.body=JSON.stringify(n));let i;try{i=await Yl(o,s,this.timeoutMs)}catch(c){let u=c instanceof Error?c.message:String(c),l=/timed out|timeout/i.test(u);throw new st(l?"timeout":"transport",`Server ${t} ${r} failed: ${u}`,{cause:c})}if(!i.ok){let c=await i.text().catch(()=>"");throw new st("http_error",`Server ${t} ${r} returned ${i.status}: ${GO(c,200)}`,{status:i.status})}let a=await i.text();if(!a||a.length===0)return{};try{return JSON.parse(a)}catch(c){let u=c instanceof Error?c:new Error(String(c));throw new st("invalid_response",`Server ${t} ${r} returned non-JSON response`,{cause:u})}}};function gE(e){return e instanceof st}function KO(e){return e.replace(/\/+$/,"")}function ld(e){return typeof e=="string"?Vi(e):null}function GO(e,t){return e.length<=t?e:`${e.slice(0,t)}\u2026`}X();function Ji(){let t=(Ai().CLAUDE_MEM_RUNTIME??"worker").trim().toLowerCase();return t==="server"||t==="server-beta"?"server":"worker"}function _E(){let e=Ai(),t=(...i)=>{for(let a of i){let c=(a??"").trim();if(c.length>0)return c}return""},r=t(e.CLAUDE_MEM_SERVER_URL,e.CLAUDE_MEM_SERVER_BETA_URL),n=t(e.CLAUDE_MEM_SERVER_API_KEY,e.CLAUDE_MEM_SERVER_BETA_API_KEY),o=t(e.CLAUDE_MEM_SERVER_PROJECT_ID,e.CLAUDE_MEM_SERVER_BETA_PROJECT_ID);if(!r)return _.warn("HOOK","[server-fallback] reason=missing_base_url"),null;if(!n)return _.warn("HOOK","[server-fallback] reason=missing_api_key"),null;if(!o)return _.warn("HOOK","[server-fallback] reason=missing_project_id"),null;let s={serverBaseUrl:r,apiKey:n};return{runtime:"server",client:new Yi(s),projectId:o,serverBaseUrl:r}}X();var yE=["observation_add","observation_record_event","observation_search","observation_context","observation_generation_status","memory_add","memory_search","memory_context"],VO=new Set(yE);function SE(e,t){return t==="server"?[...e]:(_.debug("SYSTEM","Filtering server-beta-only MCP tools from worker runtime advertisement",{runtime:t,hiddenToolCount:yE.length}),e.filter(r=>!VO.has(r.name)))}var hI={},YO="13.26.0";console.log=(...e)=>{_.error("CONSOLE","Intercepted console output (MCP protocol protection)",void 0,{args:e})};var vE=!1,kE=(()=>{if(typeof __CM_DIRNAME__<"u")return __CM_DIRNAME__;try{return(0,nr.dirname)((0,wE.fileURLToPath)(hI.url))}catch(e){return vE=!0,_.warn("SYSTEM","mcp-server: failed to resolve module directory from import.meta.url, falling back to process.cwd()",void 0,e instanceof Error?e:new Error(String(e))),process.cwd()}})(),fd=HS()??(0,nr.resolve)(kE,"worker-service.cjs");function JO(){vE&&((0,Xi.existsSync)(fd)||_.error("SYSTEM","mcp-server: dirname resolution failed (both __dirname and import.meta.url are unavailable). Fell back to process.cwd() and the resolved WORKER_SCRIPT_PATH does not exist. This is the actual problem \u2014 the worker bundle is fine, but mcp-server cannot locate it. Worker auto-start will fail until the dirname-resolution path is fixed.",{workerScriptPath:fd,mcpServerDir:kE}))}async function _t(e,t={}){_.debug("SYSTEM","\u2192 Worker API",void 0,{endpoint:e});try{let r;if(t.body)r=await Zi(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.body)});else{let n=new URLSearchParams;for(let[o,s]of Object.entries(t.query??{}))s!=null&&n.append(o,String(s));r=await Zi(`${e}?${n}`)}if(!r.ok){let n=await r.text();throw new Error(`Worker API error (${r.status}): ${n}`)}return _.debug("SYSTEM","\u2190 Worker API success",void 0,{endpoint:e}),t.text?{content:[{type:"text",text:await r.text()}]}:t.body?{content:[{type:"text",text:JSON.stringify(await r.json(),null,2)}]}:await r.json()}catch(r){return _.error("SYSTEM","\u2190 Worker API error",{endpoint:e},r instanceof Error?r:new Error(String(r))),{content:[{type:"text",text:`Error calling Worker API: ${r instanceof Error?r.message:String(r)}`}],isError:!0}}}async function XO(){try{return(await Zi("/api/health")).ok}catch(e){return _.debug("SYSTEM","Worker health check failed",{},e instanceof Error?e:new Error(String(e))),!1}}function xE(){if(Ji()!=="server")return null;let t=_E();return t?{...t,available:!0}:{runtime:"server",available:!1,reason:"server runtime is selected but configuration is incomplete (missing url, api key, or project id)"}}function QO(e){return gE(e)?{content:[{type:"text",text:`Server error (${e.kind}${e.status?` ${e.status}`:""}): ${e.message}`}],isError:!0}:{content:[{type:"text",text:`Tool error: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}function ln(e){return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}function $o(e){let t=xE();if(!t)throw new st("transport",`${e} requires CLAUDE_MEM_RUNTIME=server. Current runtime is "worker"; use the existing search/timeline/get_observations tools for worker-mode memory access.`);if(!t.available)throw new st("missing_api_key",`${e}: ${t.reason}`);return t}function Ro(e,t){return async r=>{try{return await t(r)}catch(n){let o=n instanceof Error?n:new Error(String(n));return _.warn("SYSTEM",`${e} failed`,void 0,o),QO(n)}}}var eI=Ro("observation_add",async e=>{let t=$o("observation_add");if(typeof e?.content!="string"||e.content.trim().length===0)throw new Error('observation_add: "content" is required');let n={projectId:e.projectId&&e.projectId.trim().length>0?e.projectId:t.projectId,content:e.content,...e.serverSessionId!==void 0?{serverSessionId:e.serverSessionId}:{},...e.contentSessionId!==void 0?{contentSessionId:e.contentSessionId}:{},...e.platformSource!==void 0?{platformSource:e.platformSource}:{},...e.kind!==void 0?{kind:e.kind}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}},o=await t.client.addObservation(n);return ln(o)});function ea(e){return typeof e=="string"?Vi(e):null}var tI=Ro("observation_record_event",async e=>{let t=$o("observation_record_event");if(typeof e?.eventType!="string"||e.eventType.trim().length===0)throw new Error('observation_record_event: "eventType" is required');let n={projectId:e.projectId&&e.projectId.trim().length>0?e.projectId:t.projectId,sourceType:e.sourceType??"api",eventType:e.eventType,occurredAtEpoch:typeof e.occurredAtEpoch=="number"?e.occurredAtEpoch:Date.now(),...e.serverSessionId!==void 0?{serverSessionId:e.serverSessionId}:{},...e.contentSessionId!==void 0?{contentSessionId:e.contentSessionId}:{},...e.memorySessionId!==void 0?{memorySessionId:e.memorySessionId}:{},...e.platformSource!==void 0?{platformSource:ea(e.platformSource)}:{},...e.payload!==void 0?{payload:e.payload}:{},...e.generate!==void 0?{generate:e.generate}:{}},o=await t.client.recordEvent(n);return ln(o)}),rI=Ro("observation_search",async e=>{let t=$o("observation_search");if(typeof e?.query!="string"||e.query.trim().length===0)throw new Error('observation_search: "query" is required');let n={projectId:e.projectId&&e.projectId.trim().length>0?e.projectId:t.projectId,query:e.query,...e.limit!==void 0?{limit:e.limit}:{},...e.platformSource!==void 0?{platformSource:ea(e.platformSource)}:{}},o=await t.client.searchObservations(n);return ln(o)}),nI=Ro("observation_context",async e=>{let t=$o("observation_context");if(typeof e?.query!="string"||e.query.trim().length===0)throw new Error('observation_context: "query" is required');let n={projectId:e.projectId&&e.projectId.trim().length>0?e.projectId:t.projectId,query:e.query,...e.limit!==void 0?{limit:e.limit}:{},...e.platformSource!==void 0?{platformSource:ea(e.platformSource)}:{}},o=await t.client.contextObservations(n);return ln(o)});function oI(e){return Array.isArray(e.projects)?e.projects.map(t=>typeof t=="string"?t.trim():"").filter(Boolean):typeof e.projects=="string"?e.projects.split(",").map(t=>t.trim()).filter(Boolean):typeof e.project=="string"&&e.project.trim().length>0?[e.project.trim()]:[]}async function sI(e){let t=oI(e);return t.length===0?{content:[{type:"text",text:'session_start_context: "project" or "projects" is required'}],isError:!0}:_t("/api/context/inject",{query:{projects:t.join(","),...e.platformSource!==void 0?{platformSource:ea(e.platformSource)}:{},...e.full!==void 0?{full:e.full}:{},...e.colors!==void 0?{colors:e.colors}:{}},text:!0})}var iI=Ro("observation_generation_status",async e=>{let t=$o("observation_generation_status"),r=(e?.jobId??e?.job_id??"").trim();if(!r)throw new Error('observation_generation_status: "jobId" is required');let n=await t.client.getJobStatus(r);return ln(n)});async function aI(){if(await XO())return!0;_.warn("SYSTEM","Worker not available, attempting auto-start for MCP client"),JO();try{let e=Xl(),t=await YS(e,fd);return t==="dead"&&_.error("SYSTEM","Worker auto-start failed \u2014 MCP tools that require the worker (search, timeline, get_observations) will fail until the worker is running. Check earlier log lines for the specific failure reason (Bun not found, missing worker bundle, port conflict, etc.)."),t!=="dead"}catch(e){return _.error("SYSTEM","Worker auto-start threw \u2014 MCP tools that require the worker (search, timeline, get_observations) will fail until the worker is running.",void 0,e instanceof Error?e:new Error(String(e))),!1}}var PE=[{name:"important_workflow",description:`LAYERED WORKFLOW (ALWAYS FOLLOW):
|
|
225
225
|
1. search(query) \u2192 Get index with IDs (~50-100 tokens/result)
|
|
226
226
|
2. timeline(anchor=ID) \u2192 Get context around interesting results
|
|
227
227
|
3. get_observations([IDs]) \u2192 Fetch full details ONLY for filtered IDs
|
|
@@ -246,9 +246,9 @@ NEVER fetch full details without filtering first. 10x token savings.`,inputSchem
|
|
|
246
246
|
\`get_tool_uses(ids=[...])\`
|
|
247
247
|
Returns: The original tool_input / tool_response bodies (UNSUMMARIZED \u2014 can be thousands of tokens each)
|
|
248
248
|
|
|
249
|
-
**Why:** 10x token savings. Never fetch full details without filtering first, and never reach for layer 4 before layer 3 answered.`}]})},{name:"search",description:"Step 1: Search memory. Returns index with IDs. Params: query, limit, project, platformSource, type, obs_type, dateStart, dateEnd, offset, orderBy",inputSchema:{type:"object",properties:{query:{type:"string",description:"Search query"},limit:{type:"number",description:"Max results (default 20)"},project:{type:"string",description:"Filter by project name"},platformSource:{type:"string",description:"Filter by platform source (e.g. claude, codex, cursor) \u2014 restricts results to that agent's own memory"},type:{type:"string",description:"Document category to search: 'observations', 'sessions', or 'prompts' (default: all). Any other value is treated as an observation-type filter (alias for obs_type)."},obs_type:{type:"string",description:"Filter observations by their type (e.g. bugfix, feature). Comma-separated for multiple."},dateStart:{type:"string",description:"Start date filter (ISO)"},dateEnd:{type:"string",description:"End date filter (ISO)"},offset:{type:"number",description:"Pagination offset"},orderBy:{type:"string",description:"Sort order: date_desc or date_asc"}},additionalProperties:!0},handler:async e=>{let t=xE(),r=typeof e?.query=="string"&&e.query.trim().length>0,n=e?.type===void 0||e?.type==="observations",o=e?.platformSource!==void 0||e?.project!==void 0||e?.obs_type!==void 0||e?.dateStart!==void 0||e?.dateEnd!==void 0||e?.offset!==void 0||e?.orderBy!==void 0;if(t&&t.available&&r&&n&&!o){let s={projectId:t.projectId,query:e.query,...e.limit!==void 0?{limit:e.limit}:{}};return
|
|
249
|
+
**Why:** 10x token savings. Never fetch full details without filtering first, and never reach for layer 4 before layer 3 answered.`}]})},{name:"search",description:"Step 1: Search memory. Returns index with IDs. Params: query, limit, project, platformSource, type, obs_type, dateStart, dateEnd, offset, orderBy",inputSchema:{type:"object",properties:{query:{type:"string",description:"Search query"},limit:{type:"number",description:"Max results (default 20)"},project:{type:"string",description:"Filter by project name"},platformSource:{type:"string",description:"Filter by platform source (e.g. claude, codex, cursor) \u2014 restricts results to that agent's own memory"},type:{type:"string",description:"Document category to search: 'observations', 'sessions', or 'prompts' (default: all). Any other value is treated as an observation-type filter (alias for obs_type)."},obs_type:{type:"string",description:"Filter observations by their type (e.g. bugfix, feature). Comma-separated for multiple."},dateStart:{type:"string",description:"Start date filter (ISO)"},dateEnd:{type:"string",description:"End date filter (ISO)"},offset:{type:"number",description:"Pagination offset"},orderBy:{type:"string",description:"Sort order: date_desc or date_asc"}},additionalProperties:!0},handler:async e=>{let t=xE(),r=typeof e?.query=="string"&&e.query.trim().length>0,n=e?.type===void 0||e?.type==="observations",o=e?.platformSource!==void 0||e?.project!==void 0||e?.obs_type!==void 0||e?.dateStart!==void 0||e?.dateEnd!==void 0||e?.offset!==void 0||e?.orderBy!==void 0;if(t&&t.available&&r&&n&&!o){let s={projectId:t.projectId,query:e.query,...e.limit!==void 0?{limit:e.limit}:{}};return ln(await t.client.searchObservations(s))}return await _t("/api/search",{query:e})}},{name:"timeline",description:"Step 2: Get context around results. Params: anchor (observation ID) OR query (finds anchor automatically), depth_before, depth_after, project",inputSchema:{type:"object",properties:{anchor:{type:"number",description:"Observation ID to center the timeline around"},query:{type:"string",description:"Query to find anchor automatically"},depth_before:{type:"number",description:"Items before anchor (default 3)"},depth_after:{type:"number",description:"Items after anchor (default 3)"},project:{type:"string",description:"Filter by project name"}},additionalProperties:!0},handler:async e=>await _t("/api/timeline",{query:e})},{name:"get_observations",description:"Step 3: Fetch full details for filtered IDs. Params: ids (array of observation IDs, required), orderBy, limit, project",inputSchema:{type:"object",properties:{ids:{type:"array",items:{type:"number"},description:"Array of observation IDs to fetch (required)"}},required:["ids"],additionalProperties:!0},handler:async e=>await _t("/api/observations/batch",{body:e})},{name:"get_tool_uses",description:"Step 4 (raw tool I/O, rarely needed): fetch the ORIGINAL tool_input/tool_response for tool calls you already identified. Requires ids \u2014 run search/timeline/get_observations first and pass only the ids you actually need; these payloads are large and unsummarized. ids accept numeric tool_uses ids or tool_use_id strings. Params: ids (required), limit, project, contentSessionId.",inputSchema:{type:"object",properties:{ids:{type:"array",items:{type:["number","string"]},description:"Tool-use ids to fetch (required). Numeric tool_uses.id or opaque tool_use_id strings."},limit:{type:"number",description:"Max rows to return"},project:{type:"string",description:"Filter by project name"},contentSessionId:{type:"string",description:"Filter to one content session"}},required:["ids"],additionalProperties:!0},handler:async e=>await _t("/api/tool-uses/batch",{body:e})},{name:"session_start_context",description:"Render the exact worker-mode SessionStart context for a project. Calls /api/context/inject and returns the same text hooks inject at startup. Params: project OR projects, platformSource, full, colors.",inputSchema:{type:"object",properties:{project:{type:"string",description:"Project name, e.g. claude-mem/night-parsnip"},projects:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}],description:"Project chain for context injection. Array or comma-separated string; last project is treated as primary."},platformSource:{type:"string",description:"Optional platform source filter, e.g. claude, codex, cursor"},full:{type:"boolean",description:"When true, request full context instead of configured limits"},colors:{type:"boolean",description:"When true, request human terminal-color formatting"}},additionalProperties:!1},handler:async e=>sI(e??{})},{name:"observation_add",description:"Insert a manual observation directly into server storage. Calls /v1/memories \u2014 does NOT enqueue generation. Server runtime only. Params: content (required), projectId (optional, falls back to settings), serverSessionId, kind, metadata.",inputSchema:{type:"object",properties:{projectId:{type:"string",description:"Project id (falls back to CLAUDE_MEM_SERVER_PROJECT_ID)"},serverSessionId:{type:"string",description:"Optional server_session_id to attach the observation to"},kind:{type:"string",description:"Observation kind (default: manual)"},content:{type:"string",description:"Observation content (required)"},metadata:{type:"object",description:"Free-form metadata object",additionalProperties:!0}},required:["content"],additionalProperties:!1},handler:async e=>eI(e??{})},{name:"observation_record_event",description:"Record an agent event into the server. Calls /v1/events \u2014 server inserts the event row, the outbox row, and enqueues a generation job atomically. Server runtime only.",inputSchema:{type:"object",properties:{projectId:{type:"string"},eventType:{type:"string",description:"Event type (required), e.g. PostToolUse, UserPromptSubmit"},sourceType:{type:"string",enum:["hook","worker","provider","server","api"]},serverSessionId:{type:"string"},contentSessionId:{type:"string"},memorySessionId:{type:"string"},platformSource:{type:"string",description:"Optional platform source for session linkage and event scoping"},payload:{description:"Event payload (any JSON value)"},occurredAtEpoch:{type:"number",description:"Unix epoch millis (defaults to now)"},generate:{type:"boolean",description:"If false, skip generation job (default: true)"}},required:["eventType"],additionalProperties:!1},handler:async e=>tI(e??{})},{name:"observation_search",description:"Full-text search across generated observations using the server's GIN tsvector index (Phase 1). Calls /v1/search. Server runtime only. Params: query (required), projectId (optional), platformSource, limit (default 20, max 100).",inputSchema:{type:"object",properties:{projectId:{type:"string"},query:{type:"string",description:"Search query (required)"},platformSource:{type:"string",description:"Optional platform source filter, e.g. claude, codex, cursor"},limit:{type:"number",description:"Max results (default 20, max 100)"}},required:["query"],additionalProperties:!1},handler:async e=>rI(e??{})},{name:"observation_context",description:"Get top-N relevant observations for context injection. Returns matched observations AND a pre-joined context string suitable for prompt injection. Calls /v1/context. Server runtime only.",inputSchema:{type:"object",properties:{projectId:{type:"string"},query:{type:"string",description:"Search query (required)"},platformSource:{type:"string",description:"Optional platform source filter, e.g. claude, codex, cursor"},limit:{type:"number",description:"Max observations (default 10, max 50)"}},required:["query"],additionalProperties:!1},handler:async e=>nI(e??{})},{name:"observation_generation_status",description:"Look up the status of an observation generation job by id. Calls /v1/jobs/:id. Server runtime only. Returns the same payload as REST.",inputSchema:{type:"object",properties:{jobId:{type:"string",description:"Generation job id (required)"}},required:["jobId"],additionalProperties:!1},handler:async e=>iI(e??{})},{name:"smart_search",description:"Search codebase for symbols, functions, classes using tree-sitter AST parsing. Returns folded structural views with token counts. Use path parameter to scope the search.",inputSchema:{type:"object",properties:{query:{type:"string",description:"Search term \u2014 matches against symbol names, file names, and file content"},path:{type:"string",description:"Root directory to search (default: current working directory)"},max_results:{type:"number",description:"Maximum results to return (default: 20)"},file_pattern:{type:"string",description:'Substring filter for file paths (e.g. ".ts", "src/services")'}},required:["query"]},handler:async e=>{let t=await Gi(e.path||process.cwd()),r=await pE(t,e.query,{maxResults:e.max_results||20,filePattern:e.file_pattern});return{content:[{type:"text",text:mE(r,e.query)}]}}},{name:"smart_unfold",description:"Expand a specific symbol (function, class, method) from a file. Returns the full source code of just that symbol. Use after smart_search or smart_outline to read specific code.",inputSchema:{type:"object",properties:{file_path:{type:"string",description:"Path to the source file"},symbol_name:{type:"string",description:"Name of the symbol to unfold (function, class, method, etc.)"}},required:["file_path","symbol_name"]},handler:async e=>{let t=await Gi(e.file_path),r=await(0,dd.readFile)(t,"utf-8"),n=dE(r,t,e.symbol_name);if(n)return{content:[{type:"text",text:n}]};let o=Bi(r,t);if(o.symbols.length>0){let s=o.symbols.map(i=>` - ${i.name} (${i.kind})`).join(`
|
|
250
250
|
`);return{content:[{type:"text",text:`Symbol "${e.symbol_name}" not found in ${e.file_path}.
|
|
251
251
|
|
|
252
252
|
Available symbols:
|
|
253
|
-
${s}`}]}}return{content:[{type:"text",text:`Could not parse ${e.file_path}. File may be unsupported or empty.`}]}}},{name:"smart_outline",description:"Get structural outline of a file \u2014 shows all symbols (functions, classes, methods, types) with signatures but bodies folded. Much cheaper than reading the full file.",inputSchema:{type:"object",properties:{file_path:{type:"string",description:"Path to the source file"}},required:["file_path"]},handler:async e=>{let t=await Gi(e.file_path),r=await(0,dd.readFile)(t,"utf-8"),n=Bi(r,t);return n.symbols.length>0?{content:[{type:"text",text:
|
|
253
|
+
${s}`}]}}return{content:[{type:"text",text:`Could not parse ${e.file_path}. File may be unsupported or empty.`}]}}},{name:"smart_outline",description:"Get structural outline of a file \u2014 shows all symbols (functions, classes, methods, types) with signatures but bodies folded. Much cheaper than reading the full file.",inputSchema:{type:"object",properties:{file_path:{type:"string",description:"Path to the source file"}},required:["file_path"]},handler:async e=>{let t=await Gi(e.file_path),r=await(0,dd.readFile)(t,"utf-8"),n=Bi(r,t);return n.symbols.length>0?{content:[{type:"text",text:cn(n)}]}:{content:[{type:"text",text:`Could not parse ${e.file_path}. File may use an unsupported language or be empty.`}]}}},{name:"build_corpus",description:"Build a knowledge corpus from filtered observations. Creates a queryable knowledge agent. Params: name (required), description, project, types (comma-separated), concepts (comma-separated), files (comma-separated), query, dateStart, dateEnd, limit",inputSchema:{type:"object",properties:{name:{type:"string",description:"Corpus name (used as filename)"},description:{type:"string",description:"What this corpus is about"},project:{type:"string",description:"Filter by project"},types:{type:"string",description:"Comma-separated observation types: decision,bugfix,feature,refactor,discovery,change"},concepts:{type:"string",description:"Comma-separated concepts to filter by"},files:{type:"string",description:"Comma-separated file paths to filter by"},query:{type:"string",description:"Semantic search query"},dateStart:{type:"string",description:"Start date (ISO format)"},dateEnd:{type:"string",description:"End date (ISO format)"},limit:{type:"number",description:"Maximum observations (default 500)"}},required:["name"],additionalProperties:!0},handler:async e=>await _t("/api/corpus",{body:e})},{name:"list_corpora",description:"List all knowledge corpora with their stats and priming status",inputSchema:{type:"object",properties:{},additionalProperties:!0},handler:async e=>await _t("/api/corpus",{query:e})},{name:"prime_corpus",description:"Prime a knowledge corpus \u2014 creates an AI session loaded with the corpus knowledge. Must be called before query_corpus.",inputSchema:{type:"object",properties:{name:{type:"string",description:"Name of the corpus to prime"}},required:["name"],additionalProperties:!0},handler:async e=>{let{name:t,...r}=e;if(typeof t!="string"||t.trim()==="")throw new Error("Missing required argument: name");return await _t(`/api/corpus/${encodeURIComponent(t)}/prime`,{body:r})}},{name:"query_corpus",description:"Ask a question to a primed knowledge corpus. The corpus must be primed first with prime_corpus.",inputSchema:{type:"object",properties:{name:{type:"string",description:"Name of the corpus to query"},question:{type:"string",description:"The question to ask"}},required:["name","question"],additionalProperties:!0},handler:async e=>{let{name:t,...r}=e;if(typeof t!="string"||t.trim()==="")throw new Error("Missing required argument: name");return await _t(`/api/corpus/${encodeURIComponent(t)}/query`,{body:r})}},{name:"rebuild_corpus",description:"Rebuild a knowledge corpus from its stored filter \u2014 re-runs the search to refresh with new observations. Does not re-prime the session.",inputSchema:{type:"object",properties:{name:{type:"string",description:"Name of the corpus to rebuild"}},required:["name"],additionalProperties:!0},handler:async e=>{let{name:t,...r}=e;if(typeof t!="string"||t.trim()==="")throw new Error("Missing required argument: name");return await _t(`/api/corpus/${encodeURIComponent(t)}/rebuild`,{body:r})}},{name:"reprime_corpus",description:"Create a fresh knowledge agent session for a corpus, clearing prior Q&A context. Use when conversation has drifted or after rebuilding.",inputSchema:{type:"object",properties:{name:{type:"string",description:"Name of the corpus to reprime"}},required:["name"],additionalProperties:!0},handler:async e=>{let{name:t,...r}=e;if(typeof t!="string"||t.trim()==="")throw new Error("Missing required argument: name");return await _t(`/api/corpus/${encodeURIComponent(t)}/reprime`,{body:r})}}],pd=new ki({name:"claude-mem",version:YO},{capabilities:{tools:{}}});pd.setRequestHandler(vc,async()=>({tools:SE(PE,Ji()).map(t=>({name:t.name,description:t.description,inputSchema:t.inputSchema}))}));pd.setRequestHandler(Un,async e=>{let t=PE.find(r=>r.name===e.params.name);if(!t)throw new Error(`Unknown tool: ${e.params.name}`);try{return await t.handler(e.params.arguments||{})}catch(r){return _.error("SYSTEM","Tool execution failed",{tool:e.params.name},r instanceof Error?r:new Error(String(r))),{content:[{type:"text",text:`Tool execution failed: ${r instanceof Error?r.message:String(r)}`}],isError:!0}}});var cI=3e4,To=null,EE=!1;function Qi(){Ao("stdio-closed")}function TE(e){_.warn("SYSTEM","MCP stdio stream errored, shutting down",{message:e.message}),Ao("stdio-error")}function uI(){process.stdin.on("end",Qi),process.stdin.on("close",Qi),process.stdin.on("error",TE)}function lI(){process.stdin.off("end",Qi),process.stdin.off("close",Qi),process.stdin.off("error",TE)}function dI(){if(process.platform==="win32")return;let e=process.ppid;To=setInterval(()=>{(process.ppid===1||process.ppid!==e)&&(_.info("SYSTEM","Parent process died, self-exiting to prevent orphan",{initialPpid:e,currentPpid:process.ppid}),Ao())},cI),To.unref&&To.unref()}function Ao(e="shutdown"){EE||(EE=!0,To&&clearInterval(To),lI(),_.info("SYSTEM","MCP server shutting down",{reason:e}),process.exit(0))}process.on("SIGTERM",Ao);process.on("SIGINT",Ao);function fI(){let e=(0,bE.homedir)(),t=[(0,nr.resolve)(e,".claude","plugins","marketplaces","thedotmack"),(0,nr.resolve)(e,".config","claude","plugins","marketplaces","thedotmack")],r=t.some(i=>i&&(0,Xi.existsSync)(i)),n=[(0,nr.resolve)(e,".claude","plugins","cache","thedotmack","claude-mem"),(0,nr.resolve)(e,".config","claude","plugins","cache","thedotmack","claude-mem")],o=n.some(i=>i&&(0,Xi.existsSync)(i)),s=n[0];!r&&o&&_.error("SYSTEM","claude-mem MCP started but no marketplace directory was found at ~/.claude/plugins/marketplaces/thedotmack or the XDG equivalent. The IDE plugin loader needs that directory to fire claude-mem hooks (SessionStart, PostToolUse, Stop, etc.). Without it, MCP search will work but no new memories will be captured. To self-heal, run: node ~/.claude/plugins/cache/thedotmack/claude-mem/*/scripts/smart-install.js (or reinstall the plugin from the marketplace).",{marketplaceCandidates:t,cacheRoot:s})}function pI(){try{fI()}catch(e){_.warn("SYSTEM","checkMarketplaceMarker failed (non-fatal startup check)",void 0,e instanceof Error?e:new Error(String(e)))}}async function mI(){let e=new Pi;uI(),await pd.connect(e),_.info("SYSTEM","Claude-mem search server started"),pI(),dI(),setTimeout(async()=>{if(Ji()==="server"){_.info("SYSTEM","MCP runtime=server \u2014 skipping worker auto-start",void 0,{});return}await aI()?_.info("SYSTEM","Worker available",void 0,{}):(_.error("SYSTEM","Worker not available",void 0,{}),_.error("SYSTEM","Tools will fail until Worker is started"),_.error("SYSTEM","Start Worker with: npm run worker:restart"))},0)}mI().catch(e=>{_.error("SYSTEM","Fatal error",void 0,e),process.exit(0)});
|
|
254
254
|
//# sourceMappingURL=mcp-server.cjs.map
|