claude-mem 13.12.1 → 13.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/dist/npx-cli/index.js +284 -284
- package/dist/opencode-plugin/index.js +1 -1
- package/openclaw/install.sh +1 -1
- package/openclaw/openclaw.plugin.json +1 -1
- package/openclaw/test-install.sh +1 -1
- package/openclaw/tsconfig.json +2 -1
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/.codex-plugin/plugin.json +1 -1
- package/plugin/.mcp.json +1 -1
- package/plugin/hooks/hooks.json +1 -1
- package/plugin/package.json +1 -1
- package/plugin/scripts/bun-runner.js +33 -4
- package/plugin/scripts/context-generator.cjs +28 -888
- package/plugin/scripts/mcp-server.cjs +29 -29
- package/plugin/scripts/server-service.cjs +127 -127
- package/plugin/scripts/transcript-watcher.cjs +17 -17
- package/plugin/scripts/worker-service.cjs +1755 -1711
- package/plugin/scripts/worker-wrapper.cjs +1 -1
- package/plugin/skills/version-bump/SKILL.md +1 -1
- package/plugin/sqlite/SessionStore.js +41 -41
- package/plugin/sqlite/observations/files.js +7 -7
- package/plugin/ui/viewer-bundle.js +12 -12
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
3
|
-
`);let d=(0,F.readlinkSync)(t);r=(0,
|
|
4
|
-
`,"utf-8"),a;try{a=(0,F.statSync)(r).mode&511}catch{}let c;try{c=a!==void 0?(0,F.openSync)(s,"w",a):(0,F.openSync)(s,"w");let u=0;for(;u<i.length;){let l=(0,F.writeSync)(c,i,u,i.length-u);if(l===0)throw new Error(`writeSync stalled at ${u}/${i.length} bytes`);u+=l}if((0,F.fsyncSync)(c),(0,F.closeSync)(c),c=void 0,(0,F.renameSync)(s,r),!
|
|
5
|
-
`)}finally{if(l!==void 0)try{(0,F.closeSync)(l)}catch{}}}}catch(u){if(c!==void 0)try{(0,F.closeSync)(c)}catch{}try{(0,F.unlinkSync)(s)}catch{}throw u}}var F,
|
|
6
|
-
${e.stack}`:e.message;if(Array.isArray(e))return`[${e.length} items]`;let r=Object.keys(e);return r.length===0?"{}":r.length<=3?JSON.stringify(e):`{${r.length} keys: ${r.slice(0,3).join(", ")}...}`}return String(e)}formatTool(e,r){if(!r)return e;let n=r;if(typeof r=="string")try{n=JSON.parse(r)}catch{n=r}if(e==="Bash"&&n.command)return`${e}(${n.command})`;if(n.file_path)return`${e}(${n.file_path})`;if(n.notebook_path)return`${e}(${n.notebook_path})`;if(e==="Glob"&&n.pattern)return`${e}(${n.pattern})`;if(e==="Grep"&&n.pattern)return`${e}(${n.pattern})`;if(n.url)return`${e}(${n.url})`;if(n.query)return`${e}(${n.query})`;if(e==="Task"){if(n.subagent_type)return`${e}(${n.subagent_type})`;if(n.description)return`${e}(${n.description})`}return e==="Skill"&&n.skill?`${e}(${n.skill})`:e==="LSP"&&n.operation?`${e}(${n.operation})`:e}formatTimestamp(e){let r=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0"),s=String(e.getHours()).padStart(2,"0"),i=String(e.getMinutes()).padStart(2,"0"),a=String(e.getSeconds()).padStart(2,"0"),c=String(e.getMilliseconds()).padStart(3,"0");return`${r}-${n}-${o} ${s}:${i}:${a}.${c}`}log(e,r,n,o,s){if(e<this.getLevel())return;this.ensureLogFileInitialized();let i=this.formatTimestamp(new Date),a=
|
|
2
|
+
"use strict";var ay=Object.create;var ni=Object.defineProperty;var cy=Object.getOwnPropertyDescriptor;var uy=Object.getOwnPropertyNames;var ly=Object.getPrototypeOf,dy=Object.prototype.hasOwnProperty;var so=(t,e,r)=>()=>{if(r)throw r[0];try{return t&&(e=t(t=0)),e}catch(n){throw r=[n],n}};var E=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},Fu=(t,e)=>{for(var r in e)ni(t,r,{get:e[r],enumerable:!0})},py=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of uy(e))!dy.call(t,o)&&o!==r&&ni(t,o,{get:()=>e[o],enumerable:!(n=cy(e,o))||n.enumerable});return t};var Tt=(t,e,r)=>(r=t!=null?ay(ly(t)):{},py(e||!t||!t.__esModule?ni(r,"default",{value:t,enumerable:!0}):r,t));function my(t){return(fy??process.stderr.write.bind(process.stderr))(t)}function ar(t){my(t)}var fy,io=so(()=>{"use strict";fy=null});function gy(t){return t.replace(/^\uFEFF/,"")}function Wt(t){return JSON.parse(gy(t))}function _y(t){(0,F.existsSync)(t)||(0,F.mkdirSync)(t,{recursive:!0})}function oi(t,e){let r=t;try{if((0,F.lstatSync)(t).isSymbolicLink())try{r=(0,F.realpathSync)(t)}catch(u){let l=u instanceof Error?u:new Error(String(u));ar(`claude-mem: realpathSync failed for ${t}, resolving symlink manually: ${l.message}
|
|
3
|
+
`);let d=(0,F.readlinkSync)(t);r=(0,ut.resolve)((0,ut.dirname)(t),d)}}catch(u){let l=u.code;if(l!=="ENOENT"&&l!=="ENOTDIR")throw u}_y((0,ut.dirname)(r));let n=(0,ut.dirname)(r),o=(0,ut.basename)(r),s=(0,ut.join)(n,`.${o}.${process.pid}.${(0,Hu.randomBytes)(6).toString("hex")}.tmp`),i=Buffer.from(JSON.stringify(e,null,2)+`
|
|
4
|
+
`,"utf-8"),a;try{a=(0,F.statSync)(r).mode&511}catch{}let c;try{c=a!==void 0?(0,F.openSync)(s,"w",a):(0,F.openSync)(s,"w");let u=0;for(;u<i.length;){let l=(0,F.writeSync)(c,i,u,i.length-u);if(l===0)throw new Error(`writeSync stalled at ${u}/${i.length} bytes`);u+=l}if((0,F.fsyncSync)(c),(0,F.closeSync)(c),c=void 0,(0,F.renameSync)(s,r),!hy){let l;try{l=(0,F.openSync)(n,"r"),(0,F.fsyncSync)(l)}catch(d){let p=d instanceof Error?d:new Error(String(d));ar(`claude-mem: directory fsync failed for ${n}: ${p.message}
|
|
5
|
+
`)}finally{if(l!==void 0)try{(0,F.closeSync)(l)}catch{}}}}catch(u){if(c!==void 0)try{(0,F.closeSync)(c)}catch{}try{(0,F.unlinkSync)(s)}catch{}throw u}}var F,Hu,ut,hy,Fr=so(()=>{"use strict";F=require("fs"),Hu=require("crypto"),ut=require("path");io();hy=process.platform==="win32"});function yy(){return typeof __dirname<"u"?__dirname:(0,J.dirname)((0,Vu.fileURLToPath)(Ey.url))}function Wu(t){return typeof t!="string"||t.length===0?t:t==="~"?(0,Hr.homedir)():t.startsWith("~/")?(0,J.join)((0,Hr.homedir)(),t.slice(2)):t}function ao(){if(process.env.CLAUDE_MEM_DATA_DIR)return Wu(process.env.CLAUDE_MEM_DATA_DIR);let t=(0,J.join)((0,Hr.homedir)(),".claude-mem"),e=(0,J.join)(t,"settings.json");try{if((0,Wr.existsSync)(e)){let r=Wt((0,Wr.readFileSync)(e,"utf-8")),n=r.env??r;if(n.CLAUDE_MEM_DATA_DIR)return Wu(n.CLAUDE_MEM_DATA_DIR)}}catch{}return t}var J,Hr,Wr,Vu,Ey,PT,ue,Sy,co,vy,uo,TT,by,RT,je,Xe=so(()=>{"use strict";J=require("path"),Hr=require("os"),Wr=require("fs"),Vu=require("url");Fr();Ey={};PT=yy();ue=ao(),Sy=process.env.CLAUDE_CONFIG_DIR||(0,J.join)((0,Hr.homedir)(),".claude"),co=(0,J.join)(Sy,"plugins","marketplaces","thedotmack"),vy=(0,J.join)(ue,"logs"),uo=(0,J.join)(ue,"settings.json"),TT=(0,J.join)(ue,"claude-mem.db"),by=(0,J.join)(ue,"observer-sessions"),RT=(0,J.basename)(by),je={dataDir:()=>ue,workerPid:()=>(0,J.join)(ue,"worker.pid"),serverPid:()=>(0,J.join)(ue,".server-beta.pid"),serverPort:()=>(0,J.join)(ue,".server-beta.port"),serverRuntime:()=>(0,J.join)(ue,".server-beta.runtime.json"),settings:()=>(0,J.join)(ue,"settings.json"),database:()=>(0,J.join)(ue,"claude-mem.db"),chroma:()=>(0,J.join)(ue,"chroma"),combinedCerts:()=>(0,J.join)(ue,"combined_certs.pem"),transcriptsConfig:()=>(0,J.join)(ue,"transcript-watch.json"),transcriptsState:()=>(0,J.join)(ue,"transcript-watch-state.json"),corpora:()=>(0,J.join)(ue,"corpora"),supervisorRegistry:()=>(0,J.join)(ue,"supervisor.json"),envFile:()=>(0,J.join)(ue,".env"),logsDir:()=>vy}});var yt,Ku,ii,si,ai,y,ce=so(()=>{"use strict";yt=require("fs"),Ku=require("path");Xe();io();Fr();ii=(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))(ii||{}),si=null,ai=class{level=null;useColor;logFilePath=null;logFileInitialized=!1;constructor(){this.useColor=process.stdout.isTTY??!1}ensureLogFileInitialized(){if(!this.logFileInitialized){this.logFileInitialized=!0;try{let e=je.logsDir();(0,yt.existsSync)(e)||(0,yt.mkdirSync)(e,{recursive:!0});let r=new Date().toISOString().split("T")[0];this.logFilePath=(0,Ku.join)(e,`claude-mem-${r}.log`)}catch(e){console.error("[LOGGER] Failed to initialize log file:",e instanceof Error?e.message:String(e)),this.logFilePath=null}}}getLevel(){if(this.level===null)try{let e=je.settings();if((0,yt.existsSync)(e)){let r=(0,yt.readFileSync)(e,"utf-8"),o=(Wt(r).CLAUDE_MEM_LOG_LEVEL||"INFO").toUpperCase();this.level=ii[o]??1}else this.level=1}catch(e){console.error("[LOGGER] Failed to load log level from settings:",e instanceof Error?e.message:String(e)),this.level=1}return this.level}formatData(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return e.toString();if(typeof e=="object"){if(e instanceof Error)return this.getLevel()===0?`${e.message}
|
|
6
|
+
${e.stack}`:e.message;if(Array.isArray(e))return`[${e.length} items]`;let r=Object.keys(e);return r.length===0?"{}":r.length<=3?JSON.stringify(e):`{${r.length} keys: ${r.slice(0,3).join(", ")}...}`}return String(e)}formatTool(e,r){if(!r)return e;let n=r;if(typeof r=="string")try{n=JSON.parse(r)}catch{n=r}if(e==="Bash"&&n.command)return`${e}(${n.command})`;if(n.file_path)return`${e}(${n.file_path})`;if(n.notebook_path)return`${e}(${n.notebook_path})`;if(e==="Glob"&&n.pattern)return`${e}(${n.pattern})`;if(e==="Grep"&&n.pattern)return`${e}(${n.pattern})`;if(n.url)return`${e}(${n.url})`;if(n.query)return`${e}(${n.query})`;if(e==="Task"){if(n.subagent_type)return`${e}(${n.subagent_type})`;if(n.description)return`${e}(${n.description})`}return e==="Skill"&&n.skill?`${e}(${n.skill})`:e==="LSP"&&n.operation?`${e}(${n.operation})`:e}formatTimestamp(e){let r=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0"),s=String(e.getHours()).padStart(2,"0"),i=String(e.getMinutes()).padStart(2,"0"),a=String(e.getSeconds()).padStart(2,"0"),c=String(e.getMilliseconds()).padStart(3,"0");return`${r}-${n}-${o} ${s}:${i}:${a}.${c}`}log(e,r,n,o,s){if(e<this.getLevel())return;this.ensureLogFileInitialized();let i=this.formatTimestamp(new Date),a=ii[e].padEnd(5),c=r.padEnd(6),u="";o?.correlationId?u=`[${o.correlationId}] `:o?.sessionId&&(u=`[session-${o.sessionId}] `);let l="";if(s!=null)if(s instanceof Error)l=this.getLevel()===0?`
|
|
7
7
|
${s.message}
|
|
8
8
|
${s.stack}`:` ${s.message}`;else if(this.getLevel()===0&&typeof s=="object")try{l=`
|
|
9
9
|
`+JSON.stringify(s,null,2)}catch{l=" "+this.formatData(s)}else l=" "+this.formatData(s);let d="";if(o){let{sessionId:f,memorySessionId:m,correlationId:g,...S}=o;Object.keys(S).length>0&&(d=` {${Object.entries(S).map(([x,b])=>`${x}=${b}`).join(", ")}}`)}let p=`[${i}] [${a}] [${c}] ${u}${n}${d}${l}`;if(this.logFilePath)try{(0,yt.appendFileSync)(this.logFilePath,p+`
|
|
10
10
|
`,"utf8")}catch(f){let m=f instanceof Error?f:new Error(String(f));ar(`[LOGGER] Failed to write to log file: ${m.message}
|
|
11
11
|
${m.stack??""}
|
|
12
12
|
`)}else ar(p+`
|
|
13
|
-
`)}debug(e,r,n,o){this.log(0,e,r,n,o)}info(e,r,n,o){this.log(1,e,r,n,o)}warn(e,r,n,o){this.log(2,e,r,n,o)}setErrorSink(e){ni=e}error(e,r,n,o){this.log(3,e,r,n,o),this.routeErrorToSink(r,n,o)}routeErrorToSink(e,r,n){try{if(!ni||!(n instanceof Error))return;ni(n)}catch{}}dataIn(e,r,n,o){this.info(e,`\u2192 ${r}`,n,o)}dataOut(e,r,n,o){this.info(e,`\u2190 ${r}`,n,o)}success(e,r,n,o){this.info(e,`\u2713 ${r}`,n,o)}failure(e,r,n,o){this.error(e,`\u2717 ${r}`,n,o)}},y=new si});var Sn=E(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.regexpCode=Z.getEsmExportName=Z.getProperty=Z.safeStringify=Z.stringify=Z.strConcat=Z.addCodeArg=Z.str=Z._=Z.nil=Z._Code=Z.Name=Z.IDENTIFIER=Z._CodeOrName=void 0;var _n=class{};Z._CodeOrName=_n;Z.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Jt=class extends _n{constructor(e){if(super(),!Z.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};Z.Name=Jt;var Ze=class extends _n{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof Jt&&(r[n.str]=(r[n.str]||0)+1),r),{})}};Z._Code=Ze;Z.nil=new Ze("");function cm(t,...e){let r=[t[0]],n=0;for(;n<e.length;)ya(r,e[n]),r.push(t[++n]);return new Ze(r)}Z._=cm;var _a=new Ze("+");function um(t,...e){let r=[yn(t[0])],n=0;for(;n<e.length;)r.push(_a),ya(r,e[n]),r.push(_a,yn(t[++n]));return Lb(r),new Ze(r)}Z.str=um;function ya(t,e){e instanceof Ze?t.push(...e._items):e instanceof Jt?t.push(e):t.push(Zb(e))}Z.addCodeArg=ya;function Lb(t){let e=1;for(;e<t.length-1;){if(t[e]===_a){let r=Ub(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function Ub(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof Jt||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof Jt))return`"${t}${e.slice(1)}`}function qb(t,e){return e.emptyStr()?t:t.emptyStr()?e:um`${t}${e}`}Z.strConcat=qb;function Zb(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:yn(Array.isArray(t)?t.join(","):t)}function Fb(t){return new Ze(yn(t))}Z.stringify=Fb;function yn(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}Z.safeStringify=yn;function Hb(t){return typeof t=="string"&&Z.IDENTIFIER.test(t)?new Ze(`.${t}`):cm`[${t}]`}Z.getProperty=Hb;function Wb(t){if(typeof t=="string"&&Z.IDENTIFIER.test(t))return new Ze(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}Z.getEsmExportName=Wb;function Vb(t){return new Ze(t.toString())}Z.regexpCode=Vb});var ba=E(Re=>{"use strict";Object.defineProperty(Re,"__esModule",{value:!0});Re.ValueScope=Re.ValueScopeName=Re.Scope=Re.varKinds=Re.UsedValueState=void 0;var ze=Sn(),Sa=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},Vo;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(Vo||(Re.UsedValueState=Vo={}));Re.varKinds={const:new ze.Name("const"),let:new ze.Name("let"),var:new ze.Name("var")};var Ko=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof ze.Name?e:this.name(e)}name(e){return new ze.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Re.Scope=Ko;var Jo=class extends ze.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,ze._)`.${new ze.Name(r)}[${n}]`}};Re.ValueScopeName=Jo;var Kb=(0,ze._)`\n`,va=class extends Ko{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?Kb:ze.nil}}get(){return this._scope}name(e){return new Jo(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(e),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,ze._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(e,r,n={},o){let s=ze.nil;for(let i in e){let a=e[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,Vo.Started);let l=r(u);if(l){let d=this.opts.es5?Re.varKinds.var:Re.varKinds.const;s=(0,ze._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,ze._)`${s}${l}${this.opts._n}`;else throw new Sa(u);c.set(u,Vo.Completed)})}return s}};Re.ValueScope=va});var A=E(C=>{"use strict";Object.defineProperty(C,"__esModule",{value:!0});C.or=C.and=C.not=C.CodeGen=C.operators=C.varKinds=C.ValueScopeName=C.ValueScope=C.Scope=C.Name=C.regexpCode=C.stringify=C.getProperty=C.nil=C.strConcat=C.str=C._=void 0;var j=Sn(),Qe=ba(),Dt=Sn();Object.defineProperty(C,"_",{enumerable:!0,get:function(){return Dt._}});Object.defineProperty(C,"str",{enumerable:!0,get:function(){return Dt.str}});Object.defineProperty(C,"strConcat",{enumerable:!0,get:function(){return Dt.strConcat}});Object.defineProperty(C,"nil",{enumerable:!0,get:function(){return Dt.nil}});Object.defineProperty(C,"getProperty",{enumerable:!0,get:function(){return Dt.getProperty}});Object.defineProperty(C,"stringify",{enumerable:!0,get:function(){return Dt.stringify}});Object.defineProperty(C,"regexpCode",{enumerable:!0,get:function(){return Dt.regexpCode}});Object.defineProperty(C,"Name",{enumerable:!0,get:function(){return Dt.Name}});var Xo=ba();Object.defineProperty(C,"Scope",{enumerable:!0,get:function(){return Xo.Scope}});Object.defineProperty(C,"ValueScope",{enumerable:!0,get:function(){return Xo.ValueScope}});Object.defineProperty(C,"ValueScopeName",{enumerable:!0,get:function(){return Xo.ValueScopeName}});Object.defineProperty(C,"varKinds",{enumerable:!0,get:function(){return Xo.varKinds}});C.operators={GT:new j._Code(">"),GTE:new j._Code(">="),LT:new j._Code("<"),LTE:new j._Code("<="),EQ:new j._Code("==="),NEQ:new j._Code("!=="),NOT:new j._Code("!"),OR:new j._Code("||"),AND:new j._Code("&&"),ADD:new j._Code("+")};var wt=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},Ea=class extends wt{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?Qe.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=br(this.rhs,e,r)),this}get names(){return this.rhs instanceof j._CodeOrName?this.rhs.names:{}}},Bo=class extends wt{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof j.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=br(this.rhs,e,r),this}get names(){let e=this.lhs instanceof j.Name?{}:{...this.lhs.names};return Go(e,this.rhs)}},wa=class extends Bo{constructor(e,r,n,o){super(e,n,o),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},ka=class extends wt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},xa=class extends wt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},$a=class extends wt{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Pa=class extends wt{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=br(this.code,e,r),this}get names(){return this.code instanceof j._CodeOrName?this.code.names:{}}},vn=class extends wt{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(e,r)||(Jb(e,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Gt(e,r.names),{})}},kt=class extends vn{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Ta=class extends vn{},vr=class extends kt{};vr.kind="else";var Bt=class t extends kt{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new vr(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(lm(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=br(this.condition,e,r),this}get names(){let e=super.names;return Go(e,this.condition),this.else&&Gt(e,this.else.names),e}};Bt.kind="if";var Yt=class extends kt{};Yt.kind="for";var za=class extends Yt{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=br(this.iteration,e,r),this}get names(){return Gt(super.names,this.iteration.names)}},Ra=class extends Yt{constructor(e,r,n,o){super(),this.varKind=e,this.name=r,this.from=n,this.to=o}render(e){let r=e.es5?Qe.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){let e=Go(super.names,this.from);return Go(e,this.to)}},Yo=class extends Yt{constructor(e,r,n,o){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=o}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=br(this.iterable,e,r),this}get names(){return Gt(super.names,this.iterable.names)}},bn=class extends kt{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};bn.kind="func";var En=class extends vn{render(e){return"return "+super.render(e)}};En.kind="return";var Ia=class extends kt{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,o;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(o=this.finally)===null||o===void 0||o.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&Gt(e,this.catch.names),this.finally&&Gt(e,this.finally.names),e}},wn=class extends kt{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};wn.kind="catch";var kn=class extends kt{render(e){return"finally"+super.render(e)}};kn.kind="finally";var Oa=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
14
|
-
`:""},this._extScope=e,this._scope=new Qe.Scope({parent:e}),this._nodes=[new Ta]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new Ea(e,s,n)),s}const(e,r,n){return this._def(Qe.varKinds.const,e,r,n)}let(e,r,n){return this._def(Qe.varKinds.let,e,r,n)}var(e,r,n){return this._def(Qe.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new Bo(e,r,n))}add(e,r){return this._leafNode(new wa(e,C.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==j.nil&&this._leafNode(new Pa(e)),this}object(...e){let r=["{"];for(let[n,o]of e)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,j.addCodeArg)(r,o));return r.push("}"),new j._Code(r)}if(e,r,n){if(this._blockNode(new Bt(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new Bt(e))}else(){return this._elseNode(new vr)}endIf(){return this._endBlockNode(Bt,vr)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new za(e),r)}forRange(e,r,n,o,s=this.opts.es5?Qe.varKinds.var:Qe.varKinds.let){let i=this._scope.toName(e);return this._for(new Ra(s,i,r,n),()=>o(i))}forOf(e,r,n,o=Qe.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let i=r instanceof j.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,j._)`${i}.length`,a=>{this.var(s,(0,j._)`${i}[${a}]`),n(s)})}return this._for(new Yo("of",o,s,r),()=>n(s))}forIn(e,r,n,o=this.opts.es5?Qe.varKinds.var:Qe.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,j._)`Object.keys(${r})`,n);let s=this._scope.toName(e);return this._for(new Yo("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(Yt)}label(e){return this._leafNode(new ka(e))}break(e){return this._leafNode(new xa(e))}return(e){let r=new En;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(En)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new Ia;if(this._blockNode(o),this.code(e),r){let s=this.name("e");this._currNode=o.catch=new wn(s),r(s)}return n&&(this._currNode=o.finally=new kn,this.code(n)),this._endBlockNode(wn,kn)}throw(e){return this._leafNode(new $a(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=j.nil,n,o){return this._blockNode(new bn(e,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(bn)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof Bt))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};C.CodeGen=Oa;function Gt(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function Go(t,e){return e instanceof j._CodeOrName?Gt(t,e.names):t}function br(t,e,r){if(t instanceof j.Name)return n(t);if(!o(t))return t;return new j._Code(t._items.reduce((s,i)=>(i instanceof j.Name&&(i=n(i)),i instanceof j._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||e[s.str]!==1?s:(delete e[s.str],i)}function o(s){return s instanceof j._Code&&s._items.some(i=>i instanceof j.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function Jb(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function lm(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,j._)`!${Aa(t)}`}C.not=lm;var Bb=dm(C.operators.AND);function Yb(...t){return t.reduce(Bb)}C.and=Yb;var Gb=dm(C.operators.OR);function Xb(...t){return t.reduce(Gb)}C.or=Xb;function dm(t){return(e,r)=>e===j.nil?r:r===j.nil?e:(0,j._)`${Aa(e)} ${t} ${Aa(r)}`}function Aa(t){return t instanceof j.Name?t:(0,j._)`(${t})`}});var U=E(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.checkStrictMode=M.getErrorPath=M.Type=M.useFunc=M.setEvaluated=M.evaluatedPropsToName=M.mergeEvaluated=M.eachItem=M.unescapeJsonPointer=M.escapeJsonPointer=M.escapeFragment=M.unescapeFragment=M.schemaRefOrVal=M.schemaHasRulesButRef=M.schemaHasRules=M.checkUnknownRules=M.alwaysValidSchema=M.toHash=void 0;var J=A(),Qb=Sn();function eE(t){let e={};for(let r of t)e[r]=!0;return e}M.toHash=eE;function tE(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(mm(t,e),!hm(e,t.self.RULES.all))}M.alwaysValidSchema=tE;function mm(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let o=n.RULES.keywords;for(let s in e)o[s]||ym(t,`unknown keyword: "${s}"`)}M.checkUnknownRules=mm;function hm(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}M.schemaHasRules=hm;function rE(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}M.schemaHasRulesButRef=rE;function nE({topSchemaRef:t,schemaPath:e},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,J._)`${r}`}return(0,J._)`${t}${e}${(0,J.getProperty)(n)}`}M.schemaRefOrVal=nE;function oE(t){return gm(decodeURIComponent(t))}M.unescapeFragment=oE;function sE(t){return encodeURIComponent(Ma(t))}M.escapeFragment=sE;function Ma(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}M.escapeJsonPointer=Ma;function gm(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}M.unescapeJsonPointer=gm;function iE(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}M.eachItem=iE;function pm({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof J.Name?(s instanceof J.Name?t(o,s,i):e(o,s,i),i):s instanceof J.Name?(e(o,i,s),s):r(s,i);return a===J.Name&&!(c instanceof J.Name)?n(o,c):c}}M.mergeEvaluated={props:pm({mergeNames:(t,e,r)=>t.if((0,J._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,J._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,J._)`${r} || {}`).code((0,J._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,J._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,J._)`${r} || {}`),Da(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:_m}),items:pm({mergeNames:(t,e,r)=>t.if((0,J._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,J._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,J._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,J._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function _m(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,J._)`{}`);return e!==void 0&&Da(t,r,e),r}M.evaluatedPropsToName=_m;function Da(t,e,r){Object.keys(r).forEach(n=>t.assign((0,J._)`${e}${(0,J.getProperty)(n)}`,!0))}M.setEvaluated=Da;var fm={};function aE(t,e){return t.scopeValue("func",{ref:e,code:fm[e.code]||(fm[e.code]=new Qb._Code(e.code))})}M.useFunc=aE;var Ca;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Ca||(M.Type=Ca={}));function cE(t,e,r){if(t instanceof J.Name){let n=e===Ca.Num;return r?n?(0,J._)`"[" + ${t} + "]"`:(0,J._)`"['" + ${t} + "']"`:n?(0,J._)`"/" + ${t}`:(0,J._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,J.getProperty)(t).toString():"/"+Ma(t)}M.getErrorPath=cE;function ym(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}M.checkStrictMode=ym});var xt=E(Na=>{"use strict";Object.defineProperty(Na,"__esModule",{value:!0});var ve=A(),uE={data:new ve.Name("data"),valCxt:new ve.Name("valCxt"),instancePath:new ve.Name("instancePath"),parentData:new ve.Name("parentData"),parentDataProperty:new ve.Name("parentDataProperty"),rootData:new ve.Name("rootData"),dynamicAnchors:new ve.Name("dynamicAnchors"),vErrors:new ve.Name("vErrors"),errors:new ve.Name("errors"),this:new ve.Name("this"),self:new ve.Name("self"),scope:new ve.Name("scope"),json:new ve.Name("json"),jsonPos:new ve.Name("jsonPos"),jsonLen:new ve.Name("jsonLen"),jsonPart:new ve.Name("jsonPart")};Na.default=uE});var xn=E(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.extendErrors=be.resetErrorsCount=be.reportExtraError=be.reportError=be.keyword$DataError=be.keywordError=void 0;var q=A(),Qo=U(),xe=xt();be.keywordError={message:({keyword:t})=>(0,q.str)`must pass "${t}" keyword validation`};be.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,q.str)`"${t}" keyword must be ${e} ($data)`:(0,q.str)`"${t}" keyword is invalid ($data)`};function lE(t,e=be.keywordError,r,n){let{it:o}=t,{gen:s,compositeRule:i,allErrors:a}=o,c=bm(t,e,r);n??(i||a)?Sm(s,c):vm(o,(0,q._)`[${c}]`)}be.reportError=lE;function dE(t,e=be.keywordError,r){let{it:n}=t,{gen:o,compositeRule:s,allErrors:i}=n,a=bm(t,e,r);Sm(o,a),s||i||vm(n,xe.default.vErrors)}be.reportExtraError=dE;function pE(t,e){t.assign(xe.default.errors,e),t.if((0,q._)`${xe.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,q._)`${xe.default.vErrors}.length`,e),()=>t.assign(xe.default.vErrors,null)))}be.resetErrorsCount=pE;function fE({gen:t,keyword:e,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",o,xe.default.errors,a=>{t.const(i,(0,q._)`${xe.default.vErrors}[${a}]`),t.if((0,q._)`${i}.instancePath === undefined`,()=>t.assign((0,q._)`${i}.instancePath`,(0,q.strConcat)(xe.default.instancePath,s.errorPath))),t.assign((0,q._)`${i}.schemaPath`,(0,q.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(t.assign((0,q._)`${i}.schema`,r),t.assign((0,q._)`${i}.data`,n))})}be.extendErrors=fE;function Sm(t,e){let r=t.const("err",e);t.if((0,q._)`${xe.default.vErrors} === null`,()=>t.assign(xe.default.vErrors,(0,q._)`[${r}]`),(0,q._)`${xe.default.vErrors}.push(${r})`),t.code((0,q._)`${xe.default.errors}++`)}function vm(t,e){let{gen:r,validateName:n,schemaEnv:o}=t;o.$async?r.throw((0,q._)`new ${t.ValidationError}(${e})`):(r.assign((0,q._)`${n}.errors`,e),r.return(!1))}var Xt={keyword:new q.Name("keyword"),schemaPath:new q.Name("schemaPath"),params:new q.Name("params"),propertyName:new q.Name("propertyName"),message:new q.Name("message"),schema:new q.Name("schema"),parentSchema:new q.Name("parentSchema")};function bm(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,q._)`{}`:mE(t,e,r)}function mE(t,e,r={}){let{gen:n,it:o}=t,s=[hE(o,r),gE(t,r)];return _E(t,e,s),n.object(...s)}function hE({errorPath:t},{instancePath:e}){let r=e?(0,q.str)`${t}${(0,Qo.getErrorPath)(e,Qo.Type.Str)}`:t;return[xe.default.instancePath,(0,q.strConcat)(xe.default.instancePath,r)]}function gE({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let o=n?e:(0,q.str)`${e}/${t}`;return r&&(o=(0,q.str)`${o}${(0,Qo.getErrorPath)(r,Qo.Type.Str)}`),[Xt.schemaPath,o]}function _E(t,{params:e,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([Xt.keyword,o],[Xt.params,typeof e=="function"?e(t):e||(0,q._)`{}`]),c.messages&&n.push([Xt.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([Xt.schema,i],[Xt.parentSchema,(0,q._)`${l}${d}`],[xe.default.data,s]),u&&n.push([Xt.propertyName,u])}});var wm=E(Er=>{"use strict";Object.defineProperty(Er,"__esModule",{value:!0});Er.boolOrEmptySchema=Er.topBoolOrEmptySchema=void 0;var yE=xn(),SE=A(),vE=xt(),bE={message:"boolean schema is false"};function EE(t){let{gen:e,schema:r,validateName:n}=t;r===!1?Em(t,!1):typeof r=="object"&&r.$async===!0?e.return(vE.default.data):(e.assign((0,SE._)`${n}.errors`,null),e.return(!0))}Er.topBoolOrEmptySchema=EE;function wE(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),Em(t)):r.var(e,!0)}Er.boolOrEmptySchema=wE;function Em(t,e){let{gen:r,data:n}=t,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,yE.reportError)(o,bE,void 0,e)}});var ja=E(wr=>{"use strict";Object.defineProperty(wr,"__esModule",{value:!0});wr.getRules=wr.isJSONType=void 0;var kE=["string","number","integer","boolean","null","object","array"],xE=new Set(kE);function $E(t){return typeof t=="string"&&xE.has(t)}wr.isJSONType=$E;function PE(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}wr.getRules=PE});var La=E(Nt=>{"use strict";Object.defineProperty(Nt,"__esModule",{value:!0});Nt.shouldUseRule=Nt.shouldUseGroup=Nt.schemaHasRulesForType=void 0;function TE({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&km(t,n)}Nt.schemaHasRulesForType=TE;function km(t,e){return e.rules.some(r=>xm(t,r))}Nt.shouldUseGroup=km;function xm(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}Nt.shouldUseRule=xm});var $n=E(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});Ee.reportTypeError=Ee.checkDataTypes=Ee.checkDataType=Ee.coerceAndCheckDataType=Ee.getJSONTypes=Ee.getSchemaTypes=Ee.DataType=void 0;var zE=ja(),RE=La(),IE=xn(),O=A(),$m=U(),kr;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(kr||(Ee.DataType=kr={}));function OE(t){let e=Pm(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}Ee.getSchemaTypes=OE;function Pm(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(zE.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Ee.getJSONTypes=Pm;function AE(t,e){let{gen:r,data:n,opts:o}=t,s=CE(e,o.coerceTypes),i=e.length>0&&!(s.length===0&&e.length===1&&(0,RE.schemaHasRulesForType)(t,e[0]));if(i){let a=qa(e,n,o.strictNumbers,kr.Wrong);r.if(a,()=>{s.length?ME(t,e,s):Za(t)})}return i}Ee.coerceAndCheckDataType=AE;var Tm=new Set(["string","number","integer","boolean","null"]);function CE(t,e){return e?t.filter(r=>Tm.has(r)||e==="array"&&r==="array"):[]}function ME(t,e,r){let{gen:n,data:o,opts:s}=t,i=n.let("dataType",(0,O._)`typeof ${o}`),a=n.let("coerced",(0,O._)`undefined`);s.coerceTypes==="array"&&n.if((0,O._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,O._)`${o}[0]`).assign(i,(0,O._)`typeof ${o}`).if(qa(e,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,O._)`${a} !== undefined`);for(let u of r)(Tm.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),Za(t),n.endIf(),n.if((0,O._)`${a} !== undefined`,()=>{n.assign(o,a),DE(t,a)});function c(u){switch(u){case"string":n.elseIf((0,O._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,O._)`"" + ${o}`).elseIf((0,O._)`${o} === null`).assign(a,(0,O._)`""`);return;case"number":n.elseIf((0,O._)`${i} == "boolean" || ${o} === null
|
|
13
|
+
`)}debug(e,r,n,o){this.log(0,e,r,n,o)}info(e,r,n,o){this.log(1,e,r,n,o)}warn(e,r,n,o){this.log(2,e,r,n,o)}setErrorSink(e){si=e}error(e,r,n,o){this.log(3,e,r,n,o),this.routeErrorToSink(r,n,o)}routeErrorToSink(e,r,n){try{if(!si||!(n instanceof Error))return;si(n)}catch{}}dataIn(e,r,n,o){this.info(e,`\u2192 ${r}`,n,o)}dataOut(e,r,n,o){this.info(e,`\u2190 ${r}`,n,o)}success(e,r,n,o){this.info(e,`\u2713 ${r}`,n,o)}failure(e,r,n,o){this.error(e,`\u2717 ${r}`,n,o)}},y=new ai});var En=E(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.regexpCode=Z.getEsmExportName=Z.getProperty=Z.safeStringify=Z.stringify=Z.strConcat=Z.addCodeArg=Z.str=Z._=Z.nil=Z._Code=Z.Name=Z.IDENTIFIER=Z._CodeOrName=void 0;var vn=class{};Z._CodeOrName=vn;Z.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Jt=class extends vn{constructor(e){if(super(),!Z.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};Z.Name=Jt;var Ze=class extends vn{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof Jt&&(r[n.str]=(r[n.str]||0)+1),r),{})}};Z._Code=Ze;Z.nil=new Ze("");function lm(t,...e){let r=[t[0]],n=0;for(;n<e.length;)va(r,e[n]),r.push(t[++n]);return new Ze(r)}Z._=lm;var Sa=new Ze("+");function dm(t,...e){let r=[bn(t[0])],n=0;for(;n<e.length;)r.push(Sa),va(r,e[n]),r.push(Sa,bn(t[++n]));return Fb(r),new Ze(r)}Z.str=dm;function va(t,e){e instanceof Ze?t.push(...e._items):e instanceof Jt?t.push(e):t.push(Vb(e))}Z.addCodeArg=va;function Fb(t){let e=1;for(;e<t.length-1;){if(t[e]===Sa){let r=Hb(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function Hb(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof Jt||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof Jt))return`"${t}${e.slice(1)}`}function Wb(t,e){return e.emptyStr()?t:t.emptyStr()?e:dm`${t}${e}`}Z.strConcat=Wb;function Vb(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:bn(Array.isArray(t)?t.join(","):t)}function Kb(t){return new Ze(bn(t))}Z.stringify=Kb;function bn(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}Z.safeStringify=bn;function Jb(t){return typeof t=="string"&&Z.IDENTIFIER.test(t)?new Ze(`.${t}`):lm`[${t}]`}Z.getProperty=Jb;function Bb(t){if(typeof t=="string"&&Z.IDENTIFIER.test(t))return new Ze(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}Z.getEsmExportName=Bb;function Yb(t){return new Ze(t.toString())}Z.regexpCode=Yb});var wa=E(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.ValueScope=ze.ValueScopeName=ze.Scope=ze.varKinds=ze.UsedValueState=void 0;var Re=En(),ba=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},Ko;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(Ko||(ze.UsedValueState=Ko={}));ze.varKinds={const:new Re.Name("const"),let:new Re.Name("let"),var:new Re.Name("var")};var Jo=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof Re.Name?e:this.name(e)}name(e){return new Re.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};ze.Scope=Jo;var Bo=class extends Re.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,Re._)`.${new Re.Name(r)}[${n}]`}};ze.ValueScopeName=Bo;var Gb=(0,Re._)`\n`,Ea=class extends Jo{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?Gb:Re.nil}}get(){return this._scope}name(e){return new Bo(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(e),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Re._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(e,r,n={},o){let s=Re.nil;for(let i in e){let a=e[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,Ko.Started);let l=r(u);if(l){let d=this.opts.es5?ze.varKinds.var:ze.varKinds.const;s=(0,Re._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,Re._)`${s}${l}${this.opts._n}`;else throw new ba(u);c.set(u,Ko.Completed)})}return s}};ze.ValueScope=Ea});var A=E(C=>{"use strict";Object.defineProperty(C,"__esModule",{value:!0});C.or=C.and=C.not=C.CodeGen=C.operators=C.varKinds=C.ValueScopeName=C.ValueScope=C.Scope=C.Name=C.regexpCode=C.stringify=C.getProperty=C.nil=C.strConcat=C.str=C._=void 0;var j=En(),et=wa(),Dt=En();Object.defineProperty(C,"_",{enumerable:!0,get:function(){return Dt._}});Object.defineProperty(C,"str",{enumerable:!0,get:function(){return Dt.str}});Object.defineProperty(C,"strConcat",{enumerable:!0,get:function(){return Dt.strConcat}});Object.defineProperty(C,"nil",{enumerable:!0,get:function(){return Dt.nil}});Object.defineProperty(C,"getProperty",{enumerable:!0,get:function(){return Dt.getProperty}});Object.defineProperty(C,"stringify",{enumerable:!0,get:function(){return Dt.stringify}});Object.defineProperty(C,"regexpCode",{enumerable:!0,get:function(){return Dt.regexpCode}});Object.defineProperty(C,"Name",{enumerable:!0,get:function(){return Dt.Name}});var Qo=wa();Object.defineProperty(C,"Scope",{enumerable:!0,get:function(){return Qo.Scope}});Object.defineProperty(C,"ValueScope",{enumerable:!0,get:function(){return Qo.ValueScope}});Object.defineProperty(C,"ValueScopeName",{enumerable:!0,get:function(){return Qo.ValueScopeName}});Object.defineProperty(C,"varKinds",{enumerable:!0,get:function(){return Qo.varKinds}});C.operators={GT:new j._Code(">"),GTE:new j._Code(">="),LT:new j._Code("<"),LTE:new j._Code("<="),EQ:new j._Code("==="),NEQ:new j._Code("!=="),NOT:new j._Code("!"),OR:new j._Code("||"),AND:new j._Code("&&"),ADD:new j._Code("+")};var wt=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},ka=class extends wt{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?et.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=vr(this.rhs,e,r)),this}get names(){return this.rhs instanceof j._CodeOrName?this.rhs.names:{}}},Yo=class extends wt{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof j.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=vr(this.rhs,e,r),this}get names(){let e=this.lhs instanceof j.Name?{}:{...this.lhs.names};return Xo(e,this.rhs)}},xa=class extends Yo{constructor(e,r,n,o){super(e,n,o),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},$a=class extends wt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},Pa=class extends wt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Ta=class extends wt{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Ra=class extends wt{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=vr(this.code,e,r),this}get names(){return this.code instanceof j._CodeOrName?this.code.names:{}}},wn=class extends wt{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(e,r)||(Xb(e,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Gt(e,r.names),{})}},kt=class extends wn{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},za=class extends wn{},Sr=class extends kt{};Sr.kind="else";var Bt=class t extends kt{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Sr(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(pm(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=vr(this.condition,e,r),this}get names(){let e=super.names;return Xo(e,this.condition),this.else&&Gt(e,this.else.names),e}};Bt.kind="if";var Yt=class extends kt{};Yt.kind="for";var Ia=class extends Yt{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=vr(this.iteration,e,r),this}get names(){return Gt(super.names,this.iteration.names)}},Oa=class extends Yt{constructor(e,r,n,o){super(),this.varKind=e,this.name=r,this.from=n,this.to=o}render(e){let r=e.es5?et.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){let e=Xo(super.names,this.from);return Xo(e,this.to)}},Go=class extends Yt{constructor(e,r,n,o){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=o}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=vr(this.iterable,e,r),this}get names(){return Gt(super.names,this.iterable.names)}},kn=class extends kt{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};kn.kind="func";var xn=class extends wn{render(e){return"return "+super.render(e)}};xn.kind="return";var Aa=class extends kt{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,o;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(o=this.finally)===null||o===void 0||o.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&Gt(e,this.catch.names),this.finally&&Gt(e,this.finally.names),e}},$n=class extends kt{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};$n.kind="catch";var Pn=class extends kt{render(e){return"finally"+super.render(e)}};Pn.kind="finally";var Ca=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
14
|
+
`:""},this._extScope=e,this._scope=new et.Scope({parent:e}),this._nodes=[new za]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new ka(e,s,n)),s}const(e,r,n){return this._def(et.varKinds.const,e,r,n)}let(e,r,n){return this._def(et.varKinds.let,e,r,n)}var(e,r,n){return this._def(et.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new Yo(e,r,n))}add(e,r){return this._leafNode(new xa(e,C.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==j.nil&&this._leafNode(new Ra(e)),this}object(...e){let r=["{"];for(let[n,o]of e)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,j.addCodeArg)(r,o));return r.push("}"),new j._Code(r)}if(e,r,n){if(this._blockNode(new Bt(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new Bt(e))}else(){return this._elseNode(new Sr)}endIf(){return this._endBlockNode(Bt,Sr)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Ia(e),r)}forRange(e,r,n,o,s=this.opts.es5?et.varKinds.var:et.varKinds.let){let i=this._scope.toName(e);return this._for(new Oa(s,i,r,n),()=>o(i))}forOf(e,r,n,o=et.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let i=r instanceof j.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,j._)`${i}.length`,a=>{this.var(s,(0,j._)`${i}[${a}]`),n(s)})}return this._for(new Go("of",o,s,r),()=>n(s))}forIn(e,r,n,o=this.opts.es5?et.varKinds.var:et.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,j._)`Object.keys(${r})`,n);let s=this._scope.toName(e);return this._for(new Go("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(Yt)}label(e){return this._leafNode(new $a(e))}break(e){return this._leafNode(new Pa(e))}return(e){let r=new xn;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(xn)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new Aa;if(this._blockNode(o),this.code(e),r){let s=this.name("e");this._currNode=o.catch=new $n(s),r(s)}return n&&(this._currNode=o.finally=new Pn,this.code(n)),this._endBlockNode($n,Pn)}throw(e){return this._leafNode(new Ta(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=j.nil,n,o){return this._blockNode(new kn(e,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(kn)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof Bt))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};C.CodeGen=Ca;function Gt(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function Xo(t,e){return e instanceof j._CodeOrName?Gt(t,e.names):t}function vr(t,e,r){if(t instanceof j.Name)return n(t);if(!o(t))return t;return new j._Code(t._items.reduce((s,i)=>(i instanceof j.Name&&(i=n(i)),i instanceof j._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||e[s.str]!==1?s:(delete e[s.str],i)}function o(s){return s instanceof j._Code&&s._items.some(i=>i instanceof j.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function Xb(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function pm(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,j._)`!${Ma(t)}`}C.not=pm;var Qb=fm(C.operators.AND);function eE(...t){return t.reduce(Qb)}C.and=eE;var tE=fm(C.operators.OR);function rE(...t){return t.reduce(tE)}C.or=rE;function fm(t){return(e,r)=>e===j.nil?r:r===j.nil?e:(0,j._)`${Ma(e)} ${t} ${Ma(r)}`}function Ma(t){return t instanceof j.Name?t:(0,j._)`(${t})`}});var U=E(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.checkStrictMode=M.getErrorPath=M.Type=M.useFunc=M.setEvaluated=M.evaluatedPropsToName=M.mergeEvaluated=M.eachItem=M.unescapeJsonPointer=M.escapeJsonPointer=M.escapeFragment=M.unescapeFragment=M.schemaRefOrVal=M.schemaHasRulesButRef=M.schemaHasRules=M.checkUnknownRules=M.alwaysValidSchema=M.toHash=void 0;var B=A(),nE=En();function oE(t){let e={};for(let r of t)e[r]=!0;return e}M.toHash=oE;function sE(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(gm(t,e),!_m(e,t.self.RULES.all))}M.alwaysValidSchema=sE;function gm(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let o=n.RULES.keywords;for(let s in e)o[s]||vm(t,`unknown keyword: "${s}"`)}M.checkUnknownRules=gm;function _m(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}M.schemaHasRules=_m;function iE(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}M.schemaHasRulesButRef=iE;function aE({topSchemaRef:t,schemaPath:e},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,B._)`${r}`}return(0,B._)`${t}${e}${(0,B.getProperty)(n)}`}M.schemaRefOrVal=aE;function cE(t){return ym(decodeURIComponent(t))}M.unescapeFragment=cE;function uE(t){return encodeURIComponent(Na(t))}M.escapeFragment=uE;function Na(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}M.escapeJsonPointer=Na;function ym(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}M.unescapeJsonPointer=ym;function lE(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}M.eachItem=lE;function mm({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof B.Name?(s instanceof B.Name?t(o,s,i):e(o,s,i),i):s instanceof B.Name?(e(o,i,s),s):r(s,i);return a===B.Name&&!(c instanceof B.Name)?n(o,c):c}}M.mergeEvaluated={props:mm({mergeNames:(t,e,r)=>t.if((0,B._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,B._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,B._)`${r} || {}`).code((0,B._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,B._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,B._)`${r} || {}`),ja(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:Sm}),items:mm({mergeNames:(t,e,r)=>t.if((0,B._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,B._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,B._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,B._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function Sm(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,B._)`{}`);return e!==void 0&&ja(t,r,e),r}M.evaluatedPropsToName=Sm;function ja(t,e,r){Object.keys(r).forEach(n=>t.assign((0,B._)`${e}${(0,B.getProperty)(n)}`,!0))}M.setEvaluated=ja;var hm={};function dE(t,e){return t.scopeValue("func",{ref:e,code:hm[e.code]||(hm[e.code]=new nE._Code(e.code))})}M.useFunc=dE;var Da;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Da||(M.Type=Da={}));function pE(t,e,r){if(t instanceof B.Name){let n=e===Da.Num;return r?n?(0,B._)`"[" + ${t} + "]"`:(0,B._)`"['" + ${t} + "']"`:n?(0,B._)`"/" + ${t}`:(0,B._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,B.getProperty)(t).toString():"/"+Na(t)}M.getErrorPath=pE;function vm(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}M.checkStrictMode=vm});var xt=E(La=>{"use strict";Object.defineProperty(La,"__esModule",{value:!0});var ve=A(),fE={data:new ve.Name("data"),valCxt:new ve.Name("valCxt"),instancePath:new ve.Name("instancePath"),parentData:new ve.Name("parentData"),parentDataProperty:new ve.Name("parentDataProperty"),rootData:new ve.Name("rootData"),dynamicAnchors:new ve.Name("dynamicAnchors"),vErrors:new ve.Name("vErrors"),errors:new ve.Name("errors"),this:new ve.Name("this"),self:new ve.Name("self"),scope:new ve.Name("scope"),json:new ve.Name("json"),jsonPos:new ve.Name("jsonPos"),jsonLen:new ve.Name("jsonLen"),jsonPart:new ve.Name("jsonPart")};La.default=fE});var Tn=E(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.extendErrors=be.resetErrorsCount=be.reportExtraError=be.reportError=be.keyword$DataError=be.keywordError=void 0;var q=A(),es=U(),xe=xt();be.keywordError={message:({keyword:t})=>(0,q.str)`must pass "${t}" keyword validation`};be.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,q.str)`"${t}" keyword must be ${e} ($data)`:(0,q.str)`"${t}" keyword is invalid ($data)`};function mE(t,e=be.keywordError,r,n){let{it:o}=t,{gen:s,compositeRule:i,allErrors:a}=o,c=wm(t,e,r);n??(i||a)?bm(s,c):Em(o,(0,q._)`[${c}]`)}be.reportError=mE;function hE(t,e=be.keywordError,r){let{it:n}=t,{gen:o,compositeRule:s,allErrors:i}=n,a=wm(t,e,r);bm(o,a),s||i||Em(n,xe.default.vErrors)}be.reportExtraError=hE;function gE(t,e){t.assign(xe.default.errors,e),t.if((0,q._)`${xe.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,q._)`${xe.default.vErrors}.length`,e),()=>t.assign(xe.default.vErrors,null)))}be.resetErrorsCount=gE;function _E({gen:t,keyword:e,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",o,xe.default.errors,a=>{t.const(i,(0,q._)`${xe.default.vErrors}[${a}]`),t.if((0,q._)`${i}.instancePath === undefined`,()=>t.assign((0,q._)`${i}.instancePath`,(0,q.strConcat)(xe.default.instancePath,s.errorPath))),t.assign((0,q._)`${i}.schemaPath`,(0,q.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(t.assign((0,q._)`${i}.schema`,r),t.assign((0,q._)`${i}.data`,n))})}be.extendErrors=_E;function bm(t,e){let r=t.const("err",e);t.if((0,q._)`${xe.default.vErrors} === null`,()=>t.assign(xe.default.vErrors,(0,q._)`[${r}]`),(0,q._)`${xe.default.vErrors}.push(${r})`),t.code((0,q._)`${xe.default.errors}++`)}function Em(t,e){let{gen:r,validateName:n,schemaEnv:o}=t;o.$async?r.throw((0,q._)`new ${t.ValidationError}(${e})`):(r.assign((0,q._)`${n}.errors`,e),r.return(!1))}var Xt={keyword:new q.Name("keyword"),schemaPath:new q.Name("schemaPath"),params:new q.Name("params"),propertyName:new q.Name("propertyName"),message:new q.Name("message"),schema:new q.Name("schema"),parentSchema:new q.Name("parentSchema")};function wm(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,q._)`{}`:yE(t,e,r)}function yE(t,e,r={}){let{gen:n,it:o}=t,s=[SE(o,r),vE(t,r)];return bE(t,e,s),n.object(...s)}function SE({errorPath:t},{instancePath:e}){let r=e?(0,q.str)`${t}${(0,es.getErrorPath)(e,es.Type.Str)}`:t;return[xe.default.instancePath,(0,q.strConcat)(xe.default.instancePath,r)]}function vE({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let o=n?e:(0,q.str)`${e}/${t}`;return r&&(o=(0,q.str)`${o}${(0,es.getErrorPath)(r,es.Type.Str)}`),[Xt.schemaPath,o]}function bE(t,{params:e,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([Xt.keyword,o],[Xt.params,typeof e=="function"?e(t):e||(0,q._)`{}`]),c.messages&&n.push([Xt.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([Xt.schema,i],[Xt.parentSchema,(0,q._)`${l}${d}`],[xe.default.data,s]),u&&n.push([Xt.propertyName,u])}});var xm=E(br=>{"use strict";Object.defineProperty(br,"__esModule",{value:!0});br.boolOrEmptySchema=br.topBoolOrEmptySchema=void 0;var EE=Tn(),wE=A(),kE=xt(),xE={message:"boolean schema is false"};function $E(t){let{gen:e,schema:r,validateName:n}=t;r===!1?km(t,!1):typeof r=="object"&&r.$async===!0?e.return(kE.default.data):(e.assign((0,wE._)`${n}.errors`,null),e.return(!0))}br.topBoolOrEmptySchema=$E;function PE(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),km(t)):r.var(e,!0)}br.boolOrEmptySchema=PE;function km(t,e){let{gen:r,data:n}=t,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,EE.reportError)(o,xE,void 0,e)}});var Ua=E(Er=>{"use strict";Object.defineProperty(Er,"__esModule",{value:!0});Er.getRules=Er.isJSONType=void 0;var TE=["string","number","integer","boolean","null","object","array"],RE=new Set(TE);function zE(t){return typeof t=="string"&&RE.has(t)}Er.isJSONType=zE;function IE(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}Er.getRules=IE});var qa=E(Nt=>{"use strict";Object.defineProperty(Nt,"__esModule",{value:!0});Nt.shouldUseRule=Nt.shouldUseGroup=Nt.schemaHasRulesForType=void 0;function OE({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&$m(t,n)}Nt.schemaHasRulesForType=OE;function $m(t,e){return e.rules.some(r=>Pm(t,r))}Nt.shouldUseGroup=$m;function Pm(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}Nt.shouldUseRule=Pm});var Rn=E(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});Ee.reportTypeError=Ee.checkDataTypes=Ee.checkDataType=Ee.coerceAndCheckDataType=Ee.getJSONTypes=Ee.getSchemaTypes=Ee.DataType=void 0;var AE=Ua(),CE=qa(),ME=Tn(),O=A(),Tm=U(),wr;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(wr||(Ee.DataType=wr={}));function DE(t){let e=Rm(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}Ee.getSchemaTypes=DE;function Rm(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(AE.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Ee.getJSONTypes=Rm;function NE(t,e){let{gen:r,data:n,opts:o}=t,s=jE(e,o.coerceTypes),i=e.length>0&&!(s.length===0&&e.length===1&&(0,CE.schemaHasRulesForType)(t,e[0]));if(i){let a=Fa(e,n,o.strictNumbers,wr.Wrong);r.if(a,()=>{s.length?LE(t,e,s):Ha(t)})}return i}Ee.coerceAndCheckDataType=NE;var zm=new Set(["string","number","integer","boolean","null"]);function jE(t,e){return e?t.filter(r=>zm.has(r)||e==="array"&&r==="array"):[]}function LE(t,e,r){let{gen:n,data:o,opts:s}=t,i=n.let("dataType",(0,O._)`typeof ${o}`),a=n.let("coerced",(0,O._)`undefined`);s.coerceTypes==="array"&&n.if((0,O._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,O._)`${o}[0]`).assign(i,(0,O._)`typeof ${o}`).if(Fa(e,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,O._)`${a} !== undefined`);for(let u of r)(zm.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),Ha(t),n.endIf(),n.if((0,O._)`${a} !== undefined`,()=>{n.assign(o,a),UE(t,a)});function c(u){switch(u){case"string":n.elseIf((0,O._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,O._)`"" + ${o}`).elseIf((0,O._)`${o} === null`).assign(a,(0,O._)`""`);return;case"number":n.elseIf((0,O._)`${i} == "boolean" || ${o} === null
|
|
15
15
|
|| (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,O._)`+${o}`);return;case"integer":n.elseIf((0,O._)`${i} === "boolean" || ${o} === null
|
|
16
16
|
|| (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,O._)`+${o}`);return;case"boolean":n.elseIf((0,O._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf((0,O._)`${o} === "true" || ${o} === 1`).assign(a,!0);return;case"null":n.elseIf((0,O._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(a,null);return;case"array":n.elseIf((0,O._)`${i} === "string" || ${i} === "number"
|
|
17
|
-
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,O._)`[${o}]`)}}}function DE({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,O._)`${e} !== undefined`,()=>t.assign((0,O._)`${e}[${r}]`,n))}function Ua(t,e,r,n=kr.Correct){let o=n===kr.Correct?O.operators.EQ:O.operators.NEQ,s;switch(t){case"null":return(0,O._)`${e} ${o} null`;case"array":s=(0,O._)`Array.isArray(${e})`;break;case"object":s=(0,O._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":s=i((0,O._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":s=i();break;default:return(0,O._)`typeof ${e} ${o} ${t}`}return n===kr.Correct?s:(0,O.not)(s);function i(a=O.nil){return(0,O.and)((0,O._)`typeof ${e} == "number"`,a,r?(0,O._)`isFinite(${e})`:O.nil)}}Ee.checkDataType=Ua;function qa(t,e,r,n){if(t.length===1)return Ua(t[0],e,r,n);let o,s=(0,$m.toHash)(t);if(s.array&&s.object){let i=(0,O._)`typeof ${e} != "object"`;o=s.null?i:(0,O._)`!${e} || ${i}`,delete s.null,delete s.array,delete s.object}else o=O.nil;s.number&&delete s.integer;for(let i in s)o=(0,O.and)(o,Ua(i,e,r,n));return o}Ee.checkDataTypes=qa;var NE={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,O._)`{type: ${t}}`:(0,O._)`{type: ${e}}`};function Za(t){let e=jE(t);(0,IE.reportError)(e,NE)}Ee.reportTypeError=Za;function jE(t){let{gen:e,data:r,schema:n}=t,o=(0,$m.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:t}}});var Rm=E(es=>{"use strict";Object.defineProperty(es,"__esModule",{value:!0});es.assignDefaults=void 0;var xr=A(),LE=U();function UE(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let o in r)zm(t,o,r[o].default);else e==="array"&&Array.isArray(n)&&n.forEach((o,s)=>zm(t,s,o.default))}es.assignDefaults=UE;function zm(t,e,r){let{gen:n,compositeRule:o,data:s,opts:i}=t;if(r===void 0)return;let a=(0,xr._)`${s}${(0,xr.getProperty)(e)}`;if(o){(0,LE.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,xr._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,xr._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,xr._)`${a} = ${(0,xr.stringify)(r)}`)}});var Fe=E(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});V.validateUnion=V.validateArray=V.usePattern=V.callValidateCode=V.schemaProperties=V.allSchemaProperties=V.noPropertyInData=V.propertyInData=V.isOwnProperty=V.hasPropFunc=V.reportMissingProp=V.checkMissingProp=V.checkReportMissingProp=void 0;var ee=A(),Fa=U(),jt=xt(),qE=U();function ZE(t,e){let{gen:r,data:n,it:o}=t;r.if(Wa(r,n,e,o.opts.ownProperties),()=>{t.setParams({missingProperty:(0,ee._)`${e}`},!0),t.error()})}V.checkReportMissingProp=ZE;function FE({gen:t,data:e,it:{opts:r}},n,o){return(0,ee.or)(...n.map(s=>(0,ee.and)(Wa(t,e,s,r.ownProperties),(0,ee._)`${o} = ${s}`)))}V.checkMissingProp=FE;function HE(t,e){t.setParams({missingProperty:e},!0),t.error()}V.reportMissingProp=HE;function Im(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,ee._)`Object.prototype.hasOwnProperty`})}V.hasPropFunc=Im;function Ha(t,e,r){return(0,ee._)`${Im(t)}.call(${e}, ${r})`}V.isOwnProperty=Ha;function WE(t,e,r,n){let o=(0,ee._)`${e}${(0,ee.getProperty)(r)} !== undefined`;return n?(0,ee._)`${o} && ${Ha(t,e,r)}`:o}V.propertyInData=WE;function Wa(t,e,r,n){let o=(0,ee._)`${e}${(0,ee.getProperty)(r)} === undefined`;return n?(0,ee.or)(o,(0,ee.not)(Ha(t,e,r))):o}V.noPropertyInData=Wa;function Om(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}V.allSchemaProperties=Om;function VE(t,e){return Om(e).filter(r=>!(0,Fa.alwaysValidSchema)(t,e[r]))}V.schemaProperties=VE;function KE({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,ee._)`${t}, ${e}, ${n}${o}`:e,d=[[jt.default.instancePath,(0,ee.strConcat)(jt.default.instancePath,s)],[jt.default.parentData,i.parentData],[jt.default.parentDataProperty,i.parentDataProperty],[jt.default.rootData,jt.default.rootData]];i.opts.dynamicRef&&d.push([jt.default.dynamicAnchors,jt.default.dynamicAnchors]);let p=(0,ee._)`${l}, ${r.object(...d)}`;return c!==ee.nil?(0,ee._)`${a}.call(${c}, ${p})`:(0,ee._)`${a}(${p})`}V.callValidateCode=KE;var JE=(0,ee._)`new RegExp`;function BE({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:o}=e.code,s=o(r,n);return t.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,ee._)`${o.code==="new RegExp"?JE:(0,qE.useFunc)(t,o)}(${r}, ${n})`})}V.usePattern=BE;function YE(t){let{gen:e,data:r,keyword:n,it:o}=t,s=e.name("valid");if(o.allErrors){let a=e.let("valid",!0);return i(()=>e.assign(a,!1)),a}return e.var(s,!0),i(()=>e.break()),s;function i(a){let c=e.const("len",(0,ee._)`${r}.length`);e.forRange("i",0,c,u=>{t.subschema({keyword:n,dataProp:u,dataPropType:Fa.Type.Num},s),e.if((0,ee.not)(s),a)})}}V.validateArray=YE;function GE(t){let{gen:e,schema:r,keyword:n,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,Fa.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,u)=>{let l=t.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);e.assign(i,(0,ee._)`${i} || ${a}`),t.mergeValidEvaluated(l,a)||e.if((0,ee.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}V.validateUnion=GE});var Mm=E(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.validateKeywordUsage=lt.validSchemaType=lt.funcKeywordCode=lt.macroKeywordCode=void 0;var $e=A(),Qt=xt(),XE=Fe(),QE=xn();function ew(t,e){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=t,a=e.macro.call(i.self,o,s,i),c=Cm(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");t.subschema({schema:a,schemaPath:$e.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}lt.macroKeywordCode=ew;function tw(t,e){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=t;nw(c,e);let u=!a&&e.compile?e.compile.call(c.self,s,i,c):e.validate,l=Cm(n,o,u),d=n.let("valid");t.block$data(d,p),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function p(){if(e.errors===!1)g(),e.modifying&&Am(t),S(()=>t.error());else{let v=e.async?f():m();e.modifying&&Am(t),S(()=>rw(t,v))}}function f(){let v=n.let("ruleErrs",null);return n.try(()=>g((0,$e._)`await `),x=>n.assign(d,!1).if((0,$e._)`${x} instanceof ${c.ValidationError}`,()=>n.assign(v,(0,$e._)`${x}.errors`),()=>n.throw(x))),v}function m(){let v=(0,$e._)`${l}.errors`;return n.assign(v,null),g($e.nil),v}function g(v=e.async?(0,$e._)`await `:$e.nil){let x=c.opts.passContext?Qt.default.this:Qt.default.self,b=!("compile"in e&&!a||e.schema===!1);n.assign(d,(0,$e._)`${v}${(0,XE.callValidateCode)(t,l,x,b)}`,e.modifying)}function S(v){var x;n.if((0,$e.not)((x=e.valid)!==null&&x!==void 0?x:d),v)}}lt.funcKeywordCode=tw;function Am(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,$e._)`${n.parentData}[${n.parentDataProperty}]`))}function rw(t,e){let{gen:r}=t;r.if((0,$e._)`Array.isArray(${e})`,()=>{r.assign(Qt.default.vErrors,(0,$e._)`${Qt.default.vErrors} === null ? ${e} : ${Qt.default.vErrors}.concat(${e})`).assign(Qt.default.errors,(0,$e._)`${Qt.default.vErrors}.length`),(0,QE.extendErrors)(t)},()=>t.error())}function nw({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function Cm(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,$e.stringify)(r)})}function ow(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}lt.validSchemaType=ow;function sw({schema:t,opts:e,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");let i=o.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(t[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}lt.validateKeywordUsage=sw});var Nm=E(Lt=>{"use strict";Object.defineProperty(Lt,"__esModule",{value:!0});Lt.extendSubschemaMode=Lt.extendSubschemaData=Lt.getSubschema=void 0;var dt=A(),Dm=U();function iw(t,{keyword:e,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,dt._)`${t.schemaPath}${(0,dt.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,dt._)`${t.schemaPath}${(0,dt.getProperty)(e)}${(0,dt.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,Dm.escapeFragment)(r)}`}}if(n!==void 0){if(o===void 0||s===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:o,topSchemaRef:i,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}Lt.getSubschema=iw;function aw(t,e,{dataProp:r,dataPropType:n,data:o,dataTypes:s,propertyName:i}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=e,p=a.let("data",(0,dt._)`${e.data}${(0,dt.getProperty)(r)}`,!0);c(p),t.errorPath=(0,dt.str)`${u}${(0,Dm.getErrorPath)(r,n,d.jsPropertySyntax)}`,t.parentDataProperty=(0,dt._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(o!==void 0){let u=o instanceof dt.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(t.propertyName=i)}s&&(t.dataTypes=s);function c(u){t.data=u,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,u]}}Lt.extendSubschemaData=aw;function cw(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(t.compositeRule=n),o!==void 0&&(t.createErrors=o),s!==void 0&&(t.allErrors=s),t.jtdDiscriminator=e,t.jtdMetadata=r}Lt.extendSubschemaMode=cw});var Va=E((GC,jm)=>{"use strict";jm.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!t(e[o],r[o]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(s=Object.keys(e),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var i=s[o];if(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r}});var Um=E((XC,Lm)=>{"use strict";var Ut=Lm.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};ts(e,n,o,t,"",t)};Ut.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Ut.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Ut.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Ut.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function ts(t,e,r,n,o,s,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,o,s,i,a,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in Ut.arrayKeywords)for(var p=0;p<d.length;p++)ts(t,e,r,d[p],o+"/"+l+"/"+p,s,o,l,n,p)}else if(l in Ut.propsKeywords){if(d&&typeof d=="object")for(var f in d)ts(t,e,r,d[f],o+"/"+l+"/"+uw(f),s,o,l,n,f)}else(l in Ut.keywords||t.allKeys&&!(l in Ut.skipKeywords))&&ts(t,e,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function uw(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var Pn=E(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.getSchemaRefs=Ie.resolveUrl=Ie.normalizeId=Ie._getFullPath=Ie.getFullPath=Ie.inlineRef=void 0;var lw=U(),dw=Va(),pw=Um(),fw=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function mw(t,e=!0){return typeof t=="boolean"?!0:e===!0?!Ka(t):e?qm(t)<=e:!1}Ie.inlineRef=mw;var hw=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Ka(t){for(let e in t){if(hw.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(Ka)||typeof r=="object"&&Ka(r))return!0}return!1}function qm(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!fw.has(r)&&(typeof t[r]=="object"&&(0,lw.eachItem)(t[r],n=>e+=qm(n)),e===1/0))return 1/0}return e}function Zm(t,e="",r){r!==!1&&(e=$r(e));let n=t.parse(e);return Fm(t,n)}Ie.getFullPath=Zm;function Fm(t,e){return t.serialize(e).split("#")[0]+"#"}Ie._getFullPath=Fm;var gw=/#\/?$/;function $r(t){return t?t.replace(gw,""):""}Ie.normalizeId=$r;function _w(t,e,r){return r=$r(r),t.resolve(e,r)}Ie.resolveUrl=_w;var yw=/^[a-z_][-a-z0-9._]*$/i;function Sw(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=$r(t[r]||e),s={"":o},i=Zm(n,o,!1),a={},c=new Set;return pw(t,{allKeys:!0},(d,p,f,m)=>{if(m===void 0)return;let g=i+p,S=s[m];typeof d[r]=="string"&&(S=v.call(this,d[r])),x.call(this,d.$anchor),x.call(this,d.$dynamicAnchor),s[p]=S;function v(b){let $=this.opts.uriResolver.resolve;if(b=$r(S?$(S,b):b),c.has(b))throw l(b);c.add(b);let k=this.refs[b];return typeof k=="string"&&(k=this.refs[k]),typeof k=="object"?u(d,k.schema,b):b!==$r(g)&&(b[0]==="#"?(u(d,a[b],b),a[b]=d):this.refs[b]=g),b}function x(b){if(typeof b=="string"){if(!yw.test(b))throw new Error(`invalid anchor "${b}"`);v.call(this,`#${b}`)}}}),a;function u(d,p,f){if(p!==void 0&&!dw(d,p))throw l(f)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Ie.getSchemaRefs=Sw});var Rn=E(qt=>{"use strict";Object.defineProperty(qt,"__esModule",{value:!0});qt.getData=qt.KeywordCxt=qt.validateFunctionCode=void 0;var Jm=wm(),Hm=$n(),Ba=La(),rs=$n(),vw=Rm(),zn=Mm(),Ja=Nm(),T=A(),R=xt(),bw=Pn(),$t=U(),Tn=xn();function Ew(t){if(Gm(t)&&(Xm(t),Ym(t))){xw(t);return}Bm(t,()=>(0,Jm.topBoolOrEmptySchema)(t))}qt.validateFunctionCode=Ew;function Bm({gen:t,validateName:e,schema:r,schemaEnv:n,opts:o},s){o.code.es5?t.func(e,(0,T._)`${R.default.data}, ${R.default.valCxt}`,n.$async,()=>{t.code((0,T._)`"use strict"; ${Wm(r,o)}`),kw(t,o),t.code(s)}):t.func(e,(0,T._)`${R.default.data}, ${ww(o)}`,n.$async,()=>t.code(Wm(r,o)).code(s))}function ww(t){return(0,T._)`{${R.default.instancePath}="", ${R.default.parentData}, ${R.default.parentDataProperty}, ${R.default.rootData}=${R.default.data}${t.dynamicRef?(0,T._)`, ${R.default.dynamicAnchors}={}`:T.nil}}={}`}function kw(t,e){t.if(R.default.valCxt,()=>{t.var(R.default.instancePath,(0,T._)`${R.default.valCxt}.${R.default.instancePath}`),t.var(R.default.parentData,(0,T._)`${R.default.valCxt}.${R.default.parentData}`),t.var(R.default.parentDataProperty,(0,T._)`${R.default.valCxt}.${R.default.parentDataProperty}`),t.var(R.default.rootData,(0,T._)`${R.default.valCxt}.${R.default.rootData}`),e.dynamicRef&&t.var(R.default.dynamicAnchors,(0,T._)`${R.default.valCxt}.${R.default.dynamicAnchors}`)},()=>{t.var(R.default.instancePath,(0,T._)`""`),t.var(R.default.parentData,(0,T._)`undefined`),t.var(R.default.parentDataProperty,(0,T._)`undefined`),t.var(R.default.rootData,R.default.data),e.dynamicRef&&t.var(R.default.dynamicAnchors,(0,T._)`{}`)})}function xw(t){let{schema:e,opts:r,gen:n}=t;Bm(t,()=>{r.$comment&&e.$comment&&eh(t),Rw(t),n.let(R.default.vErrors,null),n.let(R.default.errors,0),r.unevaluated&&$w(t),Qm(t),Aw(t)})}function $w(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,T._)`${r}.evaluated`),e.if((0,T._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,T._)`${t.evaluated}.props`,(0,T._)`undefined`)),e.if((0,T._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,T._)`${t.evaluated}.items`,(0,T._)`undefined`))}function Wm(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,T._)`/*# sourceURL=${r} */`:T.nil}function Pw(t,e){if(Gm(t)&&(Xm(t),Ym(t))){Tw(t,e);return}(0,Jm.boolOrEmptySchema)(t,e)}function Ym({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function Gm(t){return typeof t.schema!="boolean"}function Tw(t,e){let{schema:r,gen:n,opts:o}=t;o.$comment&&r.$comment&&eh(t),Iw(t),Ow(t);let s=n.const("_errs",R.default.errors);Qm(t,s),n.var(e,(0,T._)`${s} === ${R.default.errors}`)}function Xm(t){(0,$t.checkUnknownRules)(t),zw(t)}function Qm(t,e){if(t.opts.jtd)return Vm(t,[],!1,e);let r=(0,Hm.getSchemaTypes)(t.schema),n=(0,Hm.coerceAndCheckDataType)(t,r);Vm(t,r,!n,e)}function zw(t){let{schema:e,errSchemaPath:r,opts:n,self:o}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,$t.schemaHasRulesButRef)(e,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function Rw(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,$t.checkStrictMode)(t,"default is ignored in the schema root")}function Iw(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,bw.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function Ow(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function eh({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)t.code((0,T._)`${R.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,T.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,T._)`${R.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function Aw(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=t;r.$async?e.if((0,T._)`${R.default.errors} === 0`,()=>e.return(R.default.data),()=>e.throw((0,T._)`new ${o}(${R.default.vErrors})`)):(e.assign((0,T._)`${n}.errors`,R.default.vErrors),s.unevaluated&&Cw(t),e.return((0,T._)`${R.default.errors} === 0`))}function Cw({gen:t,evaluated:e,props:r,items:n}){r instanceof T.Name&&t.assign((0,T._)`${e}.props`,r),n instanceof T.Name&&t.assign((0,T._)`${e}.items`,n)}function Vm(t,e,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:u}=t,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,$t.schemaHasRulesButRef)(s,l))){o.block(()=>rh(t,"$ref",l.all.$ref.definition));return}c.jtd||Mw(t,e),o.block(()=>{for(let p of l.rules)d(p);d(l.post)});function d(p){(0,Ba.shouldUseGroup)(s,p)&&(p.type?(o.if((0,rs.checkDataType)(p.type,i,c.strictNumbers)),Km(t,p),e.length===1&&e[0]===p.type&&r&&(o.else(),(0,rs.reportTypeError)(t)),o.endIf()):Km(t,p),a||o.if((0,T._)`${R.default.errors} === ${n||0}`))}}function Km(t,e){let{gen:r,schema:n,opts:{useDefaults:o}}=t;o&&(0,vw.assignDefaults)(t,e.type),r.block(()=>{for(let s of e.rules)(0,Ba.shouldUseRule)(n,s)&&rh(t,s.keyword,s.definition,e.type)})}function Mw(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(Dw(t,e),t.opts.allowUnionTypes||Nw(t,e),jw(t,t.dataTypes))}function Dw(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{th(t.dataTypes,r)||Ya(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),Uw(t,e)}}function Nw(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&Ya(t,"use allowUnionTypes to allow union type keyword")}function jw(t,e){let r=t.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,Ba.shouldUseRule)(t.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>Lw(e,i))&&Ya(t,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function Lw(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function th(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function Uw(t,e){let r=[];for(let n of t.dataTypes)th(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function Ya(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,$t.checkStrictMode)(t,e,t.opts.strictTypes)}var ns=class{constructor(e,r,n){if((0,zn.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,$t.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",nh(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,zn.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",R.default.errors))}result(e,r,n){this.failResult((0,T.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,T.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,T._)`${r} !== undefined && (${(0,T.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?Tn.reportExtraError:Tn.reportError)(this,this.def.error,r)}$dataError(){(0,Tn.reportError)(this,this.def.$dataError||Tn.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Tn.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=T.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=T.nil,r=T.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,T.or)((0,T._)`${o} === undefined`,r)),e!==T.nil&&n.assign(e,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==T.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,T.or)(i(),a());function i(){if(n.length){if(!(r instanceof T.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,T._)`${(0,rs.checkDataTypes)(c,r,s.opts.strictNumbers,rs.DataType.Wrong)}`}return T.nil}function a(){if(o.validateSchema){let c=e.scopeValue("validate$data",{ref:o.validateSchema});return(0,T._)`!${c}(${r})`}return T.nil}}subschema(e,r){let n=(0,Ja.getSubschema)(this.it,e);(0,Ja.extendSubschemaData)(n,this.it,e),(0,Ja.extendSubschemaMode)(n,e);let o={...this.it,...n,items:void 0,props:void 0};return Pw(o,r),o}mergeEvaluated(e,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=$t.mergeEvaluated.props(o,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=$t.mergeEvaluated.items(o,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(e,T.Name)),!0}};qt.KeywordCxt=ns;function rh(t,e,r,n){let o=new ns(t,r,e);"code"in r?r.code(o,n):o.$data&&r.validate?(0,zn.funcKeywordCode)(o,r):"macro"in r?(0,zn.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,zn.funcKeywordCode)(o,r)}var qw=/^\/(?:[^~]|~0|~1)*$/,Zw=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function nh(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let o,s;if(t==="")return R.default.rootData;if(t[0]==="/"){if(!qw.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);o=t,s=R.default.rootData}else{let u=Zw.exec(t);if(!u)throw new Error(`Invalid JSON-pointer: ${t}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=e)throw new Error(c("property/index",l));return n[e-l]}if(l>e)throw new Error(c("data",l));if(s=r[e-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,T._)`${s}${(0,T.getProperty)((0,$t.unescapeJsonPointer)(u))}`,i=(0,T._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${e}`}}qt.getData=nh});var os=E(Xa=>{"use strict";Object.defineProperty(Xa,"__esModule",{value:!0});var Ga=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};Xa.default=Ga});var In=E(tc=>{"use strict";Object.defineProperty(tc,"__esModule",{value:!0});var Qa=Pn(),ec=class extends Error{constructor(e,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Qa.resolveUrl)(e,r,n),this.missingSchema=(0,Qa.normalizeId)((0,Qa.getFullPath)(e,this.missingRef))}};tc.default=ec});var is=E(He=>{"use strict";Object.defineProperty(He,"__esModule",{value:!0});He.resolveSchema=He.getCompilingSchema=He.resolveRef=He.compileSchema=He.SchemaEnv=void 0;var et=A(),Fw=os(),er=xt(),tt=Pn(),oh=U(),Hw=Rn(),Pr=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,tt.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};He.SchemaEnv=Pr;function nc(t){let e=sh.call(this,t);if(e)return e;let r=(0,tt.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new et.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;t.$async&&(a=i.scopeValue("Error",{ref:Fw.default,code:(0,et._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:er.default.data,parentData:er.default.parentData,parentDataProperty:er.default.parentDataProperty,dataNames:[er.default.data],dataPathArr:[et.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,et.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:et.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,et._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,Hw.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(er.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let f=new Function(`${er.default.self}`,`${er.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:f}),f.errors=null,f.schema=t.schema,f.schemaEnv=t,t.$async&&(f.$async=!0),this.opts.code.source===!0&&(f.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:m,items:g}=u;f.evaluated={props:m instanceof et.Name?void 0:m,items:g instanceof et.Name?void 0:g,dynamicProps:m instanceof et.Name,dynamicItems:g instanceof et.Name},f.source&&(f.source.evaluated=(0,et.stringify)(f.evaluated))}return t.validate=f,t}catch(d){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(t)}}He.compileSchema=nc;function Ww(t,e,r){var n;r=(0,tt.resolveUrl)(this.opts.uriResolver,e,r);let o=t.refs[r];if(o)return o;let s=Jw.call(this,t,r);if(s===void 0){let i=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new Pr({schema:i,schemaId:a,root:t,baseId:e}))}if(s!==void 0)return t.refs[r]=Vw.call(this,s)}He.resolveRef=Ww;function Vw(t){return(0,tt.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:nc.call(this,t)}function sh(t){for(let e of this._compilations)if(Kw(e,t))return e}He.getCompilingSchema=sh;function Kw(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function Jw(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||ss.call(this,t,e)}function ss(t,e){let r=this.opts.uriResolver.parse(e),n=(0,tt._getFullPath)(this.opts.uriResolver,r),o=(0,tt.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===o)return rc.call(this,r,t);let s=(0,tt.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=ss.call(this,t,i);return typeof a?.schema!="object"?void 0:rc.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||nc.call(this,i),s===(0,tt.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,tt.resolveUrl)(this.opts.uriResolver,o,u)),new Pr({schema:a,schemaId:c,root:t,baseId:o})}return rc.call(this,r,i)}}He.resolveSchema=ss;var Bw=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function rc(t,{baseId:e,schema:r,root:n}){var o;if(((o=t.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,oh.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!Bw.has(a)&&u&&(e=(0,tt.resolveUrl)(this.opts.uriResolver,e,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,oh.schemaHasRulesButRef)(r,this.RULES)){let a=(0,tt.resolveUrl)(this.opts.uriResolver,e,r.$ref);s=ss.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new Pr({schema:r,schemaId:i,root:n,baseId:e}),s.schema!==s.root.schema)return s}});var ih=E((oM,Yw)=>{Yw.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 ic=E((sM,ph)=>{"use strict";var Gw=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),ch=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),oc=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),uh=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),Xw=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function sc(t){let e="",r=0,n=0;for(n=0;n<t.length;n++)if(r=t[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n];break}for(n+=1;n<t.length;n++){if(r=t[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n]}return e}var Qw=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function ah(t){return t.length=0,!0}function ek(t,e,r){if(t.length){let n=sc(t);if(n!=="")e.push(n);else return r.error=!0,!1;t.length=0}return!0}function tk(t){let e=0,r={error:!1,address:"",zone:""},n=[],o=[],s=!1,i=!1,a=ek;for(let c=0;c<t.length;c++){let u=t[c];if(!(u==="["||u==="]"))if(u===":"){if(s===!0&&(i=!0),!a(o,n,r))break;if(++e>7){r.error=!0;break}c>0&&t[c-1]===":"&&(s=!0),n.push(":");continue}else if(u==="%"){if(!a(o,n,r))break;a=ah}else{o.push(u);continue}}return o.length&&(a===ah?r.zone=o.join(""):i?n.push(o.join("")):n.push(sc(o))),r.address=n.join(""),r}function lh(t){if(rk(t,":")<2)return{host:t,isIPV6:!1};let e=tk(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,isIPV6:!0,escapedHost:n}}}function rk(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function nk(t){let e=t,r=[],n=-1,o=0;for(;o=e.length;){if(o===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(o===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(o===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((n=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,n)),e=e.slice(n)}return r.join("")}var ok={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},sk=/[@/?#:]/g,ik=/[@/?#]/g;function dh(t,e){let r=e?ik:sk;return r.lastIndex=0,t.replace(r,n=>ok[n])}function ak(t,e=!1){if(t.indexOf("%")===-1)return t;let r="";for(let n=0;n<t.length;n++){if(t[n]==="%"&&n+2<t.length){let o=t.slice(n+1,n+3);if(oc(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));e&&uh(i)?r+=i:r+="%"+s,n+=2;continue}}r+=t[n]}return r}function ck(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(oc(n)){let o=n.toUpperCase(),s=String.fromCharCode(parseInt(o,16));s!=="."&&uh(s)?e+=s:e+="%"+o,r+=2;continue}}Xw(t[r])?e+=t[r]:e+=escape(t[r])}return e}function uk(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(oc(n)){e+="%"+n.toUpperCase(),r+=2;continue}}e+=escape(t[r])}return e}function lk(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!ch(r)){let n=lh(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=dh(r,!1)}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}ph.exports={nonSimpleDomain:Qw,recomposeAuthority:lk,reescapeHostDelimiters:dh,normalizePercentEncoding:ak,normalizePathEncoding:ck,escapePreservingEscapes:uk,removeDotSegments:nk,isIPv4:ch,isUUID:Gw,normalizeIPv6:lh,stringArrayToHexStripped:sc}});var _h=E((iM,gh)=>{"use strict";var{isUUID:dk}=ic(),pk=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,fk=["http","https","ws","wss","urn","urn:uuid"];function mk(t){return fk.indexOf(t)!==-1}function ac(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function fh(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function mh(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function hk(t){return t.secure=ac(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function gk(t){if((t.port===(ac(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function _k(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(pk);if(r){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let o=`${n}:${e.nid||t.nid}`,s=cc(o);t.path=void 0,s&&(t=s.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function yk(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),o=`${r}:${e.nid||n}`,s=cc(o);s&&(t=s.serialize(t,e));let i=t,a=t.nss;return i.path=`${n||e.nid}:${a}`,e.skipEscape=!0,i}function Sk(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!dk(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function vk(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var hh={scheme:"http",domainHost:!0,parse:fh,serialize:mh},bk={scheme:"https",domainHost:hh.domainHost,parse:fh,serialize:mh},as={scheme:"ws",domainHost:!0,parse:hk,serialize:gk},Ek={scheme:"wss",domainHost:as.domainHost,parse:as.parse,serialize:as.serialize},wk={scheme:"urn",parse:_k,serialize:yk,skipNormalize:!0},kk={scheme:"urn:uuid",parse:Sk,serialize:vk,skipNormalize:!0},cs={http:hh,https:bk,ws:as,wss:Ek,urn:wk,"urn:uuid":kk};Object.setPrototypeOf(cs,null);function cc(t){return t&&(cs[t]||cs[t.toLowerCase()])||void 0}gh.exports={wsIsSecure:ac,SCHEMES:cs,isValidSchemeName:mk,getSchemeHandler:cc}});var wh=E((aM,us)=>{"use strict";var{normalizeIPv6:xk,removeDotSegments:On,recomposeAuthority:$k,normalizePercentEncoding:Pk,normalizePathEncoding:Tk,escapePreservingEscapes:zk,reescapeHostDelimiters:Rk,isIPv4:Ik,nonSimpleDomain:Ok}=ic(),{SCHEMES:Ak,getSchemeHandler:Sh}=_h();function Ck(t,e){return typeof t=="string"?t=Lk(t,e):typeof t=="object"&&(t=Tr(tr(t,e),e)),t}function Mk(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=vh(Tr(t,n),Tr(e,n),n,!0);return n.skipEscape=!0,tr(o,n)}function vh(t,e,r,n){let o={};return n||(t=Tr(tr(t,r),r),e=Tr(tr(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(o.scheme=e.scheme,o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=On(e.path||""),o.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=On(e.path||""),o.query=e.query):(e.path?(e.path[0]==="/"?o.path=On(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?o.path="/"+e.path:t.path?o.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:o.path=e.path,o.path=On(o.path)),o.query=e.query):(o.path=t.path,e.query!==void 0?o.query=e.query:o.query=t.query),o.userinfo=t.userinfo,o.host=t.host,o.port=t.port),o.scheme=t.scheme),o.fragment=e.fragment,o}function Dk(t,e,r){let n=yh(t,r),o=yh(e,r);return n!==void 0&&o!==void 0&&n.toLowerCase()===o.toLowerCase()}function tr(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},e),o=[],s=Sh(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=Pk(r.path):(r.path=zk(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&o.push(r.scheme,":");let i=$k(r);if(i!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(i),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(a=On(a)),i===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),o.push(a)}return r.query!==void 0&&o.push("?",r.query),r.fragment!==void 0&&o.push("#",r.fragment),o.join("")}var Nk=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function jk(t,e){if(e[2]!==void 0&&t.path&&t.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof t.port=="number"&&(t.port<0||t.port>65535))return"URI port is malformed."}function bh(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1,s=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let i=t.match(Nk);if(i){n.scheme=i[1],n.userinfo=i[3],n.host=i[4],n.port=parseInt(i[5],10),n.path=i[6]||"",n.query=i[7],n.fragment=i[8],isNaN(n.port)&&(n.port=i[5]);let a=jk(n,i);if(a!==void 0&&(n.error=n.error||a,o=!0),n.host)if(Ik(n.host)===!1){let l=xk(n.host);n.host=l.host.toLowerCase(),s=l.isIPV6}else s=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let c=Sh(r.scheme||n.scheme);if(!r.unicodeSupport&&(!c||!c.unicodeSupport)&&n.host&&(r.domainHost||c&&c.domainHost)&&s===!1&&Ok(n.host))try{n.host=new URL("http://"+n.host).hostname}catch(u){n.error=n.error||"Host's domain name can not be converted to ASCII: "+u}if((!c||c&&!c.skipNormalize)&&(t.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=Rk(unescape(n.host),s))),n.path&&(n.path=Tk(n.path)),n.fragment))try{n.fragment=encodeURI(decodeURIComponent(n.fragment))}catch{n.error=n.error||"URI malformed"}c&&c.parse&&c.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o}}function Tr(t,e){return bh(t,e).parsed}function Lk(t,e){return Eh(t,e).normalized}function Eh(t,e){let{parsed:r,malformedAuthorityOrPort:n}=bh(t,e);return{normalized:n?t:tr(r,e),malformedAuthorityOrPort:n}}function yh(t,e){if(typeof t=="string"){let{normalized:r,malformedAuthorityOrPort:n}=Eh(t,e);return n?void 0:r}if(typeof t=="object")return tr(t,e)}var uc={SCHEMES:Ak,normalize:Ck,resolve:Mk,resolveComponent:vh,equal:Dk,serialize:tr,parse:Tr};us.exports=uc;us.exports.default=uc;us.exports.fastUri=uc});var xh=E(lc=>{"use strict";Object.defineProperty(lc,"__esModule",{value:!0});var kh=wh();kh.code='require("ajv/dist/runtime/uri").default';lc.default=kh});var Ah=E(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});_e.CodeGen=_e.Name=_e.nil=_e.stringify=_e.str=_e._=_e.KeywordCxt=void 0;var Uk=Rn();Object.defineProperty(_e,"KeywordCxt",{enumerable:!0,get:function(){return Uk.KeywordCxt}});var zr=A();Object.defineProperty(_e,"_",{enumerable:!0,get:function(){return zr._}});Object.defineProperty(_e,"str",{enumerable:!0,get:function(){return zr.str}});Object.defineProperty(_e,"stringify",{enumerable:!0,get:function(){return zr.stringify}});Object.defineProperty(_e,"nil",{enumerable:!0,get:function(){return zr.nil}});Object.defineProperty(_e,"Name",{enumerable:!0,get:function(){return zr.Name}});Object.defineProperty(_e,"CodeGen",{enumerable:!0,get:function(){return zr.CodeGen}});var qk=os(),Rh=In(),Zk=ja(),An=is(),Fk=A(),Cn=Pn(),ls=$n(),pc=U(),$h=ih(),Hk=xh(),Ih=(t,e)=>new RegExp(t,e);Ih.code="new RegExp";var Wk=["removeAdditional","useDefaults","coerceTypes"],Vk=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),Kk={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."},Jk={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},Ph=200;function Bk(t){var e,r,n,o,s,i,a,c,u,l,d,p,f,m,g,S,v,x,b,$,k,Se,K,at,Ne;let Pt=t.strict,Qs=(e=t.code)===null||e===void 0?void 0:e.optimize,Uu=Qs===!0||Qs===void 0?1:Qs||0,qu=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:Ih,ry=(o=t.uriResolver)!==null&&o!==void 0?o:Hk.default;return{strictSchema:(i=(s=t.strictSchema)!==null&&s!==void 0?s:Pt)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:Pt)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=t.strictTypes)!==null&&u!==void 0?u:Pt)!==null&&l!==void 0?l:"log",strictTuples:(p=(d=t.strictTuples)!==null&&d!==void 0?d:Pt)!==null&&p!==void 0?p:"log",strictRequired:(m=(f=t.strictRequired)!==null&&f!==void 0?f:Pt)!==null&&m!==void 0?m:!1,code:t.code?{...t.code,optimize:Uu,regExp:qu}:{optimize:Uu,regExp:qu},loopRequired:(g=t.loopRequired)!==null&&g!==void 0?g:Ph,loopEnum:(S=t.loopEnum)!==null&&S!==void 0?S:Ph,meta:(v=t.meta)!==null&&v!==void 0?v:!0,messages:(x=t.messages)!==null&&x!==void 0?x:!0,inlineRefs:(b=t.inlineRefs)!==null&&b!==void 0?b:!0,schemaId:($=t.schemaId)!==null&&$!==void 0?$:"$id",addUsedSchema:(k=t.addUsedSchema)!==null&&k!==void 0?k:!0,validateSchema:(Se=t.validateSchema)!==null&&Se!==void 0?Se:!0,validateFormats:(K=t.validateFormats)!==null&&K!==void 0?K:!0,unicodeRegExp:(at=t.unicodeRegExp)!==null&&at!==void 0?at:!0,int32range:(Ne=t.int32range)!==null&&Ne!==void 0?Ne:!0,uriResolver:ry}}var Mn=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...Bk(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new Fk.ValueScope({scope:{},prefixes:Vk,es5:r,lines:n}),this.logger=t0(e.logger);let o=e.validateFormats;e.validateFormats=!1,this.RULES=(0,Zk.getRules)(),Th.call(this,Kk,e,"NOT SUPPORTED"),Th.call(this,Jk,e,"DEPRECATED","warn"),this._metaOpts=Qk.call(this),e.formats&&Gk.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&Xk.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),Yk.call(this),e.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,o=$h;n==="id"&&(o={...$h},o.id=o.$id,delete o.$id),r&&e&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return o.call(this,e,r);async function o(l,d){await s.call(this,l.$schema);let p=this._addSchema(l,d);return p.validate||i.call(this,p)}async function s(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof Rh.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await s.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(e,r,n,o=this.opts.validateSchema){if(Array.isArray(e)){for(let i of e)this.addSchema(i,void 0,n,o);return this}let s;if(typeof e=="object"){let{schemaId:i}=this.opts;if(s=e[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,Cn.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,o,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(n,e);if(!o&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return o}getSchema(e){let r;for(;typeof(r=zh.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,o=new An.SchemaEnv({schema:{},schemaId:n});if(r=An.resolveSchema.call(this,o,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=zh.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,Cn.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(n0.call(this,n,r),!r)return(0,pc.eachItem)(n,s=>dc.call(this,s)),this;s0.call(this,r);let o={...r,type:(0,ls.getJSONTypes)(r.type),schemaType:(0,ls.getJSONTypes)(r.schemaType)};return(0,pc.eachItem)(n,o.type.length===0?s=>dc.call(this,s,o):s=>o.type.forEach(i=>dc.call(this,s,o,i))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===e);o>=0&&n.rules.splice(o,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let o of r){let s=o.split("/").slice(1),i=e;for(let a of s)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=Oh(l))}}return e}_removeAllSchemas(e,r){for(let n in e){let o=e[n];(!r||r.test(n))&&(typeof o=="string"?delete e[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete e[n]))}}_addSchema(e,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof e=="object")i=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;n=(0,Cn.normalizeId)(i||n);let u=Cn.getSchemaRefs.call(this,e,n);return c=new An.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),o&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):An.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{An.compileSchema.call(this,e)}finally{this.opts=r}}};Mn.ValidationError=qk.default;Mn.MissingRefError=Rh.default;_e.default=Mn;function Th(t,e,r,n="error"){for(let o in t){let s=o;s in e&&this.logger[n](`${r}: option ${o}. ${t[s]}`)}}function zh(t){return t=(0,Cn.normalizeId)(t),this.schemas[t]||this.refs[t]}function Yk(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function Gk(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function Xk(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function Qk(){let t={...this.opts};for(let e of Wk)delete t[e];return t}var e0={log(){},warn(){},error(){}};function t0(t){if(t===!1)return e0;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var r0=/^[a-z_$][a-z0-9_$:-]*$/i;function n0(t,e){let{RULES:r}=this;if((0,pc.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!r0.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function dc(t,e,r){var n;let o=e?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,i=o?s.post:s.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},s.rules.push(i)),s.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,ls.getJSONTypes)(e.type),schemaType:(0,ls.getJSONTypes)(e.schemaType)}};e.before?o0.call(this,i,a,e.before):i.rules.push(a),s.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function o0(t,e,r){let n=t.rules.findIndex(o=>o.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function s0(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=Oh(e)),t.validateSchema=this.compile(e,!0))}var i0={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Oh(t){return{anyOf:[t,i0]}}});var Ch=E(fc=>{"use strict";Object.defineProperty(fc,"__esModule",{value:!0});var a0={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};fc.default=a0});var jh=E(rr=>{"use strict";Object.defineProperty(rr,"__esModule",{value:!0});rr.callRef=rr.getValidate=void 0;var c0=In(),Mh=Fe(),Oe=A(),Rr=xt(),Dh=is(),ds=U(),u0={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=Dh.resolveRef.call(c,u,o,r);if(l===void 0)throw new c0.default(n.opts.uriResolver,o,r);if(l instanceof Dh.SchemaEnv)return p(l);return f(l);function d(){if(s===u)return ps(t,i,s,s.$async);let m=e.scopeValue("root",{ref:u});return ps(t,(0,Oe._)`${m}.validate`,u,u.$async)}function p(m){let g=Nh(t,m);ps(t,g,m,m.$async)}function f(m){let g=e.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Oe.stringify)(m)}:{ref:m}),S=e.name("valid"),v=t.subschema({schema:m,dataTypes:[],schemaPath:Oe.nil,topSchemaRef:g,errSchemaPath:r},S);t.mergeEvaluated(v),t.ok(S)}}};function Nh(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Oe._)`${r.scopeValue("wrapper",{ref:e})}.validate`}rr.getValidate=Nh;function ps(t,e,r,n){let{gen:o,it:s}=t,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?Rr.default.this:Oe.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let m=o.let("valid");o.try(()=>{o.code((0,Oe._)`await ${(0,Mh.callValidateCode)(t,e,u)}`),f(e),i||o.assign(m,!0)},g=>{o.if((0,Oe._)`!(${g} instanceof ${s.ValidationError})`,()=>o.throw(g)),p(g),i||o.assign(m,!1)}),t.ok(m)}function d(){t.result((0,Mh.callValidateCode)(t,e,u),()=>f(e),()=>p(e))}function p(m){let g=(0,Oe._)`${m}.errors`;o.assign(Rr.default.vErrors,(0,Oe._)`${Rr.default.vErrors} === null ? ${g} : ${Rr.default.vErrors}.concat(${g})`),o.assign(Rr.default.errors,(0,Oe._)`${Rr.default.vErrors}.length`)}function f(m){var g;if(!s.opts.unevaluated)return;let S=(g=r?.validate)===null||g===void 0?void 0:g.evaluated;if(s.props!==!0)if(S&&!S.dynamicProps)S.props!==void 0&&(s.props=ds.mergeEvaluated.props(o,S.props,s.props));else{let v=o.var("props",(0,Oe._)`${m}.evaluated.props`);s.props=ds.mergeEvaluated.props(o,v,s.props,Oe.Name)}if(s.items!==!0)if(S&&!S.dynamicItems)S.items!==void 0&&(s.items=ds.mergeEvaluated.items(o,S.items,s.items));else{let v=o.var("items",(0,Oe._)`${m}.evaluated.items`);s.items=ds.mergeEvaluated.items(o,v,s.items,Oe.Name)}}}rr.callRef=ps;rr.default=u0});var Lh=E(mc=>{"use strict";Object.defineProperty(mc,"__esModule",{value:!0});var l0=Ch(),d0=jh(),p0=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",l0.default,d0.default];mc.default=p0});var Uh=E(hc=>{"use strict";Object.defineProperty(hc,"__esModule",{value:!0});var fs=A(),Zt=fs.operators,ms={maximum:{okStr:"<=",ok:Zt.LTE,fail:Zt.GT},minimum:{okStr:">=",ok:Zt.GTE,fail:Zt.LT},exclusiveMaximum:{okStr:"<",ok:Zt.LT,fail:Zt.GTE},exclusiveMinimum:{okStr:">",ok:Zt.GT,fail:Zt.LTE}},f0={message:({keyword:t,schemaCode:e})=>(0,fs.str)`must be ${ms[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,fs._)`{comparison: ${ms[t].okStr}, limit: ${e}}`},m0={keyword:Object.keys(ms),type:"number",schemaType:"number",$data:!0,error:f0,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,fs._)`${r} ${ms[e].fail} ${n} || isNaN(${r})`)}};hc.default=m0});var qh=E(gc=>{"use strict";Object.defineProperty(gc,"__esModule",{value:!0});var Dn=A(),h0={message:({schemaCode:t})=>(0,Dn.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,Dn._)`{multipleOf: ${t}}`},g0={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:h0,code(t){let{gen:e,data:r,schemaCode:n,it:o}=t,s=o.opts.multipleOfPrecision,i=e.let("res"),a=s?(0,Dn._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,Dn._)`${i} !== parseInt(${i})`;t.fail$data((0,Dn._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};gc.default=g0});var Fh=E(_c=>{"use strict";Object.defineProperty(_c,"__esModule",{value:!0});function Zh(t){let e=t.length,r=0,n=0,o;for(;n<e;)r++,o=t.charCodeAt(n++),o>=55296&&o<=56319&&n<e&&(o=t.charCodeAt(n),(o&64512)===56320&&n++);return r}_c.default=Zh;Zh.code='require("ajv/dist/runtime/ucs2length").default'});var Hh=E(yc=>{"use strict";Object.defineProperty(yc,"__esModule",{value:!0});var nr=A(),_0=U(),y0=Fh(),S0={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,nr.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,nr._)`{limit: ${t}}`},v0={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:S0,code(t){let{keyword:e,data:r,schemaCode:n,it:o}=t,s=e==="maxLength"?nr.operators.GT:nr.operators.LT,i=o.opts.unicode===!1?(0,nr._)`${r}.length`:(0,nr._)`${(0,_0.useFunc)(t.gen,y0.default)}(${r})`;t.fail$data((0,nr._)`${i} ${s} ${n}`)}};yc.default=v0});var Wh=E(Sc=>{"use strict";Object.defineProperty(Sc,"__esModule",{value:!0});var b0=Fe(),E0=U(),Ir=A(),w0={message:({schemaCode:t})=>(0,Ir.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,Ir._)`{pattern: ${t}}`},k0={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:w0,code(t){let{gen:e,data:r,$data:n,schema:o,schemaCode:s,it:i}=t,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,Ir._)`new RegExp`:(0,E0.useFunc)(e,c),l=e.let("valid");e.try(()=>e.assign(l,(0,Ir._)`${u}(${s}, ${a}).test(${r})`),()=>e.assign(l,!1)),t.fail$data((0,Ir._)`!${l}`)}else{let c=(0,b0.usePattern)(t,o);t.fail$data((0,Ir._)`!${c}.test(${r})`)}}};Sc.default=k0});var Vh=E(vc=>{"use strict";Object.defineProperty(vc,"__esModule",{value:!0});var Nn=A(),x0={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,Nn.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,Nn._)`{limit: ${t}}`},$0={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:x0,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxProperties"?Nn.operators.GT:Nn.operators.LT;t.fail$data((0,Nn._)`Object.keys(${r}).length ${o} ${n}`)}};vc.default=$0});var Kh=E(bc=>{"use strict";Object.defineProperty(bc,"__esModule",{value:!0});var jn=Fe(),Ln=A(),P0=U(),T0={message:({params:{missingProperty:t}})=>(0,Ln.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,Ln._)`{missingProperty: ${t}}`},z0={keyword:"required",type:"object",schemaType:"array",$data:!0,error:T0,code(t){let{gen:e,schema:r,schemaCode:n,data:o,$data:s,it:i}=t,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let f=t.parentSchema.properties,{definedProperties:m}=t.it;for(let g of r)if(f?.[g]===void 0&&!m.has(g)){let S=i.schemaEnv.baseId+i.errSchemaPath,v=`required property "${g}" is not defined at "${S}" (strictRequired)`;(0,P0.checkStrictMode)(i,v,i.opts.strictRequired)}}function u(){if(c||s)t.block$data(Ln.nil,d);else for(let f of r)(0,jn.checkReportMissingProp)(t,f)}function l(){let f=e.let("missing");if(c||s){let m=e.let("valid",!0);t.block$data(m,()=>p(f,m)),t.ok(m)}else e.if((0,jn.checkMissingProp)(t,r,f)),(0,jn.reportMissingProp)(t,f),e.else()}function d(){e.forOf("prop",n,f=>{t.setParams({missingProperty:f}),e.if((0,jn.noPropertyInData)(e,o,f,a.ownProperties),()=>t.error())})}function p(f,m){t.setParams({missingProperty:f}),e.forOf(f,n,()=>{e.assign(m,(0,jn.propertyInData)(e,o,f,a.ownProperties)),e.if((0,Ln.not)(m),()=>{t.error(),e.break()})},Ln.nil)}}};bc.default=z0});var Jh=E(Ec=>{"use strict";Object.defineProperty(Ec,"__esModule",{value:!0});var Un=A(),R0={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,Un.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,Un._)`{limit: ${t}}`},I0={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:R0,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxItems"?Un.operators.GT:Un.operators.LT;t.fail$data((0,Un._)`${r}.length ${o} ${n}`)}};Ec.default=I0});var hs=E(wc=>{"use strict";Object.defineProperty(wc,"__esModule",{value:!0});var Bh=Va();Bh.code='require("ajv/dist/runtime/equal").default';wc.default=Bh});var Yh=E(xc=>{"use strict";Object.defineProperty(xc,"__esModule",{value:!0});var kc=$n(),ye=A(),O0=U(),A0=hs(),C0={message:({params:{i:t,j:e}})=>(0,ye.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,ye._)`{i: ${t}, j: ${e}}`},M0={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:C0,code(t){let{gen:e,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=t;if(!n&&!o)return;let c=e.let("valid"),u=s.items?(0,kc.getSchemaTypes)(s.items):[];t.block$data(c,l,(0,ye._)`${i} === false`),t.ok(c);function l(){let m=e.let("i",(0,ye._)`${r}.length`),g=e.let("j");t.setParams({i:m,j:g}),e.assign(c,!0),e.if((0,ye._)`${m} > 1`,()=>(d()?p:f)(m,g))}function d(){return u.length>0&&!u.some(m=>m==="object"||m==="array")}function p(m,g){let S=e.name("item"),v=(0,kc.checkDataTypes)(u,S,a.opts.strictNumbers,kc.DataType.Wrong),x=e.const("indices",(0,ye._)`{}`);e.for((0,ye._)`;${m}--;`,()=>{e.let(S,(0,ye._)`${r}[${m}]`),e.if(v,(0,ye._)`continue`),u.length>1&&e.if((0,ye._)`typeof ${S} == "string"`,(0,ye._)`${S} += "_"`),e.if((0,ye._)`typeof ${x}[${S}] == "number"`,()=>{e.assign(g,(0,ye._)`${x}[${S}]`),t.error(),e.assign(c,!1).break()}).code((0,ye._)`${x}[${S}] = ${m}`)})}function f(m,g){let S=(0,O0.useFunc)(e,A0.default),v=e.name("outer");e.label(v).for((0,ye._)`;${m}--;`,()=>e.for((0,ye._)`${g} = ${m}; ${g}--;`,()=>e.if((0,ye._)`${S}(${r}[${m}], ${r}[${g}])`,()=>{t.error(),e.assign(c,!1).break(v)})))}}};xc.default=M0});var Gh=E(Pc=>{"use strict";Object.defineProperty(Pc,"__esModule",{value:!0});var $c=A(),D0=U(),N0=hs(),j0={message:"must be equal to constant",params:({schemaCode:t})=>(0,$c._)`{allowedValue: ${t}}`},L0={keyword:"const",$data:!0,error:j0,code(t){let{gen:e,data:r,$data:n,schemaCode:o,schema:s}=t;n||s&&typeof s=="object"?t.fail$data((0,$c._)`!${(0,D0.useFunc)(e,N0.default)}(${r}, ${o})`):t.fail((0,$c._)`${s} !== ${r}`)}};Pc.default=L0});var Xh=E(Tc=>{"use strict";Object.defineProperty(Tc,"__esModule",{value:!0});var qn=A(),U0=U(),q0=hs(),Z0={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,qn._)`{allowedValues: ${t}}`},F0={keyword:"enum",schemaType:"array",$data:!0,error:Z0,code(t){let{gen:e,data:r,$data:n,schema:o,schemaCode:s,it:i}=t;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let a=o.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,U0.useFunc)(e,q0.default)),l;if(a||n)l=e.let("valid"),t.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let f=e.const("vSchema",s);l=(0,qn.or)(...o.map((m,g)=>p(f,g)))}t.pass(l);function d(){e.assign(l,!1),e.forOf("v",s,f=>e.if((0,qn._)`${u()}(${r}, ${f})`,()=>e.assign(l,!0).break()))}function p(f,m){let g=o[m];return typeof g=="object"&&g!==null?(0,qn._)`${u()}(${r}, ${f}[${m}])`:(0,qn._)`${r} === ${g}`}}};Tc.default=F0});var Qh=E(zc=>{"use strict";Object.defineProperty(zc,"__esModule",{value:!0});var H0=Uh(),W0=qh(),V0=Hh(),K0=Wh(),J0=Vh(),B0=Kh(),Y0=Jh(),G0=Yh(),X0=Gh(),Q0=Xh(),ex=[H0.default,W0.default,V0.default,K0.default,J0.default,B0.default,Y0.default,G0.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},X0.default,Q0.default];zc.default=ex});var Ic=E(Zn=>{"use strict";Object.defineProperty(Zn,"__esModule",{value:!0});Zn.validateAdditionalItems=void 0;var or=A(),Rc=U(),tx={message:({params:{len:t}})=>(0,or.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,or._)`{limit: ${t}}`},rx={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:tx,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,Rc.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}eg(t,n)}};function eg(t,e){let{gen:r,schema:n,data:o,keyword:s,it:i}=t;i.items=!0;let a=r.const("len",(0,or._)`${o}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,or._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,Rc.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,or._)`${a} <= ${e.length}`);r.if((0,or.not)(u),()=>c(u)),t.ok(u)}function c(u){r.forRange("i",e.length,a,l=>{t.subschema({keyword:s,dataProp:l,dataPropType:Rc.Type.Num},u),i.allErrors||r.if((0,or.not)(u),()=>r.break())})}}Zn.validateAdditionalItems=eg;Zn.default=rx});var Oc=E(Fn=>{"use strict";Object.defineProperty(Fn,"__esModule",{value:!0});Fn.validateTuple=void 0;var tg=A(),gs=U(),nx=Fe(),ox={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return rg(t,"additionalItems",e);r.items=!0,!(0,gs.alwaysValidSchema)(r,e)&&t.ok((0,nx.validateArray)(t))}};function rg(t,e,r=t.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=t;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=gs.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,tg._)`${s}.length`);r.forEach((d,p)=>{(0,gs.alwaysValidSchema)(a,d)||(n.if((0,tg._)`${u} > ${p}`,()=>t.subschema({keyword:i,schemaProp:p,dataProp:p},c)),t.ok(c))});function l(d){let{opts:p,errSchemaPath:f}=a,m=r.length,g=m===d.minItems&&(m===d.maxItems||d[e]===!1);if(p.strictTuples&&!g){let S=`"${i}" is ${m}-tuple, but minItems or maxItems/${e} are not specified or different at path "${f}"`;(0,gs.checkStrictMode)(a,S,p.strictTuples)}}}Fn.validateTuple=rg;Fn.default=ox});var ng=E(Ac=>{"use strict";Object.defineProperty(Ac,"__esModule",{value:!0});var sx=Oc(),ix={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,sx.validateTuple)(t,"items")};Ac.default=ix});var sg=E(Cc=>{"use strict";Object.defineProperty(Cc,"__esModule",{value:!0});var og=A(),ax=U(),cx=Fe(),ux=Ic(),lx={message:({params:{len:t}})=>(0,og.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,og._)`{limit: ${t}}`},dx={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:lx,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:o}=r;n.items=!0,!(0,ax.alwaysValidSchema)(n,e)&&(o?(0,ux.validateAdditionalItems)(t,o):t.ok((0,cx.validateArray)(t)))}};Cc.default=dx});var ig=E(Mc=>{"use strict";Object.defineProperty(Mc,"__esModule",{value:!0});var We=A(),_s=U(),px={message:({params:{min:t,max:e}})=>e===void 0?(0,We.str)`must contain at least ${t} valid item(s)`:(0,We.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,We._)`{minContains: ${t}}`:(0,We._)`{minContains: ${t}, maxContains: ${e}}`},fx={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:px,code(t){let{gen:e,schema:r,parentSchema:n,data:o,it:s}=t,i,a,{minContains:c,maxContains:u}=n;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=e.const("len",(0,We._)`${o}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,_s.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,_s.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,_s.alwaysValidSchema)(s,r)){let g=(0,We._)`${l} >= ${i}`;a!==void 0&&(g=(0,We._)`${g} && ${l} <= ${a}`),t.pass(g);return}s.items=!0;let d=e.name("valid");a===void 0&&i===1?f(d,()=>e.if(d,()=>e.break())):i===0?(e.let(d,!0),a!==void 0&&e.if((0,We._)`${o}.length > 0`,p)):(e.let(d,!1),p()),t.result(d,()=>t.reset());function p(){let g=e.name("_valid"),S=e.let("count",0);f(g,()=>e.if(g,()=>m(S)))}function f(g,S){e.forRange("i",0,l,v=>{t.subschema({keyword:"contains",dataProp:v,dataPropType:_s.Type.Num,compositeRule:!0},g),S()})}function m(g){e.code((0,We._)`${g}++`),a===void 0?e.if((0,We._)`${g} >= ${i}`,()=>e.assign(d,!0).break()):(e.if((0,We._)`${g} > ${a}`,()=>e.assign(d,!1).break()),i===1?e.assign(d,!0):e.if((0,We._)`${g} >= ${i}`,()=>e.assign(d,!0)))}}};Mc.default=fx});var ug=E(pt=>{"use strict";Object.defineProperty(pt,"__esModule",{value:!0});pt.validateSchemaDeps=pt.validatePropertyDeps=pt.error=void 0;var Dc=A(),mx=U(),Hn=Fe();pt.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,Dc.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,Dc._)`{property: ${t},
|
|
17
|
+
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,O._)`[${o}]`)}}}function UE({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,O._)`${e} !== undefined`,()=>t.assign((0,O._)`${e}[${r}]`,n))}function Za(t,e,r,n=wr.Correct){let o=n===wr.Correct?O.operators.EQ:O.operators.NEQ,s;switch(t){case"null":return(0,O._)`${e} ${o} null`;case"array":s=(0,O._)`Array.isArray(${e})`;break;case"object":s=(0,O._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":s=i((0,O._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":s=i();break;default:return(0,O._)`typeof ${e} ${o} ${t}`}return n===wr.Correct?s:(0,O.not)(s);function i(a=O.nil){return(0,O.and)((0,O._)`typeof ${e} == "number"`,a,r?(0,O._)`isFinite(${e})`:O.nil)}}Ee.checkDataType=Za;function Fa(t,e,r,n){if(t.length===1)return Za(t[0],e,r,n);let o,s=(0,Tm.toHash)(t);if(s.array&&s.object){let i=(0,O._)`typeof ${e} != "object"`;o=s.null?i:(0,O._)`!${e} || ${i}`,delete s.null,delete s.array,delete s.object}else o=O.nil;s.number&&delete s.integer;for(let i in s)o=(0,O.and)(o,Za(i,e,r,n));return o}Ee.checkDataTypes=Fa;var qE={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,O._)`{type: ${t}}`:(0,O._)`{type: ${e}}`};function Ha(t){let e=ZE(t);(0,ME.reportError)(e,qE)}Ee.reportTypeError=Ha;function ZE(t){let{gen:e,data:r,schema:n}=t,o=(0,Tm.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:t}}});var Om=E(ts=>{"use strict";Object.defineProperty(ts,"__esModule",{value:!0});ts.assignDefaults=void 0;var kr=A(),FE=U();function HE(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let o in r)Im(t,o,r[o].default);else e==="array"&&Array.isArray(n)&&n.forEach((o,s)=>Im(t,s,o.default))}ts.assignDefaults=HE;function Im(t,e,r){let{gen:n,compositeRule:o,data:s,opts:i}=t;if(r===void 0)return;let a=(0,kr._)`${s}${(0,kr.getProperty)(e)}`;if(o){(0,FE.checkStrictMode)(t,`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 Fe=E(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});V.validateUnion=V.validateArray=V.usePattern=V.callValidateCode=V.schemaProperties=V.allSchemaProperties=V.noPropertyInData=V.propertyInData=V.isOwnProperty=V.hasPropFunc=V.reportMissingProp=V.checkMissingProp=V.checkReportMissingProp=void 0;var ee=A(),Wa=U(),jt=xt(),WE=U();function VE(t,e){let{gen:r,data:n,it:o}=t;r.if(Ka(r,n,e,o.opts.ownProperties),()=>{t.setParams({missingProperty:(0,ee._)`${e}`},!0),t.error()})}V.checkReportMissingProp=VE;function KE({gen:t,data:e,it:{opts:r}},n,o){return(0,ee.or)(...n.map(s=>(0,ee.and)(Ka(t,e,s,r.ownProperties),(0,ee._)`${o} = ${s}`)))}V.checkMissingProp=KE;function JE(t,e){t.setParams({missingProperty:e},!0),t.error()}V.reportMissingProp=JE;function Am(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,ee._)`Object.prototype.hasOwnProperty`})}V.hasPropFunc=Am;function Va(t,e,r){return(0,ee._)`${Am(t)}.call(${e}, ${r})`}V.isOwnProperty=Va;function BE(t,e,r,n){let o=(0,ee._)`${e}${(0,ee.getProperty)(r)} !== undefined`;return n?(0,ee._)`${o} && ${Va(t,e,r)}`:o}V.propertyInData=BE;function Ka(t,e,r,n){let o=(0,ee._)`${e}${(0,ee.getProperty)(r)} === undefined`;return n?(0,ee.or)(o,(0,ee.not)(Va(t,e,r))):o}V.noPropertyInData=Ka;function Cm(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}V.allSchemaProperties=Cm;function YE(t,e){return Cm(e).filter(r=>!(0,Wa.alwaysValidSchema)(t,e[r]))}V.schemaProperties=YE;function GE({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,ee._)`${t}, ${e}, ${n}${o}`:e,d=[[jt.default.instancePath,(0,ee.strConcat)(jt.default.instancePath,s)],[jt.default.parentData,i.parentData],[jt.default.parentDataProperty,i.parentDataProperty],[jt.default.rootData,jt.default.rootData]];i.opts.dynamicRef&&d.push([jt.default.dynamicAnchors,jt.default.dynamicAnchors]);let p=(0,ee._)`${l}, ${r.object(...d)}`;return c!==ee.nil?(0,ee._)`${a}.call(${c}, ${p})`:(0,ee._)`${a}(${p})`}V.callValidateCode=GE;var XE=(0,ee._)`new RegExp`;function QE({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:o}=e.code,s=o(r,n);return t.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,ee._)`${o.code==="new RegExp"?XE:(0,WE.useFunc)(t,o)}(${r}, ${n})`})}V.usePattern=QE;function ew(t){let{gen:e,data:r,keyword:n,it:o}=t,s=e.name("valid");if(o.allErrors){let a=e.let("valid",!0);return i(()=>e.assign(a,!1)),a}return e.var(s,!0),i(()=>e.break()),s;function i(a){let c=e.const("len",(0,ee._)`${r}.length`);e.forRange("i",0,c,u=>{t.subschema({keyword:n,dataProp:u,dataPropType:Wa.Type.Num},s),e.if((0,ee.not)(s),a)})}}V.validateArray=ew;function tw(t){let{gen:e,schema:r,keyword:n,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,Wa.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,u)=>{let l=t.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);e.assign(i,(0,ee._)`${i} || ${a}`),t.mergeValidEvaluated(l,a)||e.if((0,ee.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}V.validateUnion=tw});var Nm=E(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.validateKeywordUsage=dt.validSchemaType=dt.funcKeywordCode=dt.macroKeywordCode=void 0;var $e=A(),Qt=xt(),rw=Fe(),nw=Tn();function ow(t,e){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=t,a=e.macro.call(i.self,o,s,i),c=Dm(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");t.subschema({schema:a,schemaPath:$e.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}dt.macroKeywordCode=ow;function sw(t,e){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=t;aw(c,e);let u=!a&&e.compile?e.compile.call(c.self,s,i,c):e.validate,l=Dm(n,o,u),d=n.let("valid");t.block$data(d,p),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function p(){if(e.errors===!1)g(),e.modifying&&Mm(t),S(()=>t.error());else{let v=e.async?f():m();e.modifying&&Mm(t),S(()=>iw(t,v))}}function f(){let v=n.let("ruleErrs",null);return n.try(()=>g((0,$e._)`await `),x=>n.assign(d,!1).if((0,$e._)`${x} instanceof ${c.ValidationError}`,()=>n.assign(v,(0,$e._)`${x}.errors`),()=>n.throw(x))),v}function m(){let v=(0,$e._)`${l}.errors`;return n.assign(v,null),g($e.nil),v}function g(v=e.async?(0,$e._)`await `:$e.nil){let x=c.opts.passContext?Qt.default.this:Qt.default.self,b=!("compile"in e&&!a||e.schema===!1);n.assign(d,(0,$e._)`${v}${(0,rw.callValidateCode)(t,l,x,b)}`,e.modifying)}function S(v){var x;n.if((0,$e.not)((x=e.valid)!==null&&x!==void 0?x:d),v)}}dt.funcKeywordCode=sw;function Mm(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,$e._)`${n.parentData}[${n.parentDataProperty}]`))}function iw(t,e){let{gen:r}=t;r.if((0,$e._)`Array.isArray(${e})`,()=>{r.assign(Qt.default.vErrors,(0,$e._)`${Qt.default.vErrors} === null ? ${e} : ${Qt.default.vErrors}.concat(${e})`).assign(Qt.default.errors,(0,$e._)`${Qt.default.vErrors}.length`),(0,nw.extendErrors)(t)},()=>t.error())}function aw({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function Dm(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,$e.stringify)(r)})}function cw(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}dt.validSchemaType=cw;function uw({schema:t,opts:e,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");let i=o.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(t[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}dt.validateKeywordUsage=uw});var Lm=E(Lt=>{"use strict";Object.defineProperty(Lt,"__esModule",{value:!0});Lt.extendSubschemaMode=Lt.extendSubschemaData=Lt.getSubschema=void 0;var pt=A(),jm=U();function lw(t,{keyword:e,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,pt._)`${t.schemaPath}${(0,pt.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,pt._)`${t.schemaPath}${(0,pt.getProperty)(e)}${(0,pt.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,jm.escapeFragment)(r)}`}}if(n!==void 0){if(o===void 0||s===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:o,topSchemaRef:i,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}Lt.getSubschema=lw;function dw(t,e,{dataProp:r,dataPropType:n,data:o,dataTypes:s,propertyName:i}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=e,p=a.let("data",(0,pt._)`${e.data}${(0,pt.getProperty)(r)}`,!0);c(p),t.errorPath=(0,pt.str)`${u}${(0,jm.getErrorPath)(r,n,d.jsPropertySyntax)}`,t.parentDataProperty=(0,pt._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(o!==void 0){let u=o instanceof pt.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(t.propertyName=i)}s&&(t.dataTypes=s);function c(u){t.data=u,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,u]}}Lt.extendSubschemaData=dw;function pw(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(t.compositeRule=n),o!==void 0&&(t.createErrors=o),s!==void 0&&(t.allErrors=s),t.jtdDiscriminator=e,t.jtdMetadata=r}Lt.extendSubschemaMode=pw});var Ja=E((rM,Um)=>{"use strict";Um.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!t(e[o],r[o]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(s=Object.keys(e),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var i=s[o];if(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r}});var Zm=E((nM,qm)=>{"use strict";var Ut=qm.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};rs(e,n,o,t,"",t)};Ut.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Ut.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Ut.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Ut.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function rs(t,e,r,n,o,s,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,o,s,i,a,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in Ut.arrayKeywords)for(var p=0;p<d.length;p++)rs(t,e,r,d[p],o+"/"+l+"/"+p,s,o,l,n,p)}else if(l in Ut.propsKeywords){if(d&&typeof d=="object")for(var f in d)rs(t,e,r,d[f],o+"/"+l+"/"+fw(f),s,o,l,n,f)}else(l in Ut.keywords||t.allKeys&&!(l in Ut.skipKeywords))&&rs(t,e,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function fw(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var zn=E(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.getSchemaRefs=Ie.resolveUrl=Ie.normalizeId=Ie._getFullPath=Ie.getFullPath=Ie.inlineRef=void 0;var mw=U(),hw=Ja(),gw=Zm(),_w=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function yw(t,e=!0){return typeof t=="boolean"?!0:e===!0?!Ba(t):e?Fm(t)<=e:!1}Ie.inlineRef=yw;var Sw=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Ba(t){for(let e in t){if(Sw.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(Ba)||typeof r=="object"&&Ba(r))return!0}return!1}function Fm(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!_w.has(r)&&(typeof t[r]=="object"&&(0,mw.eachItem)(t[r],n=>e+=Fm(n)),e===1/0))return 1/0}return e}function Hm(t,e="",r){r!==!1&&(e=xr(e));let n=t.parse(e);return Wm(t,n)}Ie.getFullPath=Hm;function Wm(t,e){return t.serialize(e).split("#")[0]+"#"}Ie._getFullPath=Wm;var vw=/#\/?$/;function xr(t){return t?t.replace(vw,""):""}Ie.normalizeId=xr;function bw(t,e,r){return r=xr(r),t.resolve(e,r)}Ie.resolveUrl=bw;var Ew=/^[a-z_][-a-z0-9._]*$/i;function ww(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=xr(t[r]||e),s={"":o},i=Hm(n,o,!1),a={},c=new Set;return gw(t,{allKeys:!0},(d,p,f,m)=>{if(m===void 0)return;let g=i+p,S=s[m];typeof d[r]=="string"&&(S=v.call(this,d[r])),x.call(this,d.$anchor),x.call(this,d.$dynamicAnchor),s[p]=S;function v(b){let $=this.opts.uriResolver.resolve;if(b=xr(S?$(S,b):b),c.has(b))throw l(b);c.add(b);let k=this.refs[b];return typeof k=="string"&&(k=this.refs[k]),typeof k=="object"?u(d,k.schema,b):b!==xr(g)&&(b[0]==="#"?(u(d,a[b],b),a[b]=d):this.refs[b]=g),b}function x(b){if(typeof b=="string"){if(!Ew.test(b))throw new Error(`invalid anchor "${b}"`);v.call(this,`#${b}`)}}}),a;function u(d,p,f){if(p!==void 0&&!hw(d,p))throw l(f)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Ie.getSchemaRefs=ww});var An=E(qt=>{"use strict";Object.defineProperty(qt,"__esModule",{value:!0});qt.getData=qt.KeywordCxt=qt.validateFunctionCode=void 0;var Ym=xm(),Vm=Rn(),Ga=qa(),ns=Rn(),kw=Om(),On=Nm(),Ya=Lm(),T=A(),z=xt(),xw=zn(),$t=U(),In=Tn();function $w(t){if(Qm(t)&&(eh(t),Xm(t))){Rw(t);return}Gm(t,()=>(0,Ym.topBoolOrEmptySchema)(t))}qt.validateFunctionCode=$w;function Gm({gen:t,validateName:e,schema:r,schemaEnv:n,opts:o},s){o.code.es5?t.func(e,(0,T._)`${z.default.data}, ${z.default.valCxt}`,n.$async,()=>{t.code((0,T._)`"use strict"; ${Km(r,o)}`),Tw(t,o),t.code(s)}):t.func(e,(0,T._)`${z.default.data}, ${Pw(o)}`,n.$async,()=>t.code(Km(r,o)).code(s))}function Pw(t){return(0,T._)`{${z.default.instancePath}="", ${z.default.parentData}, ${z.default.parentDataProperty}, ${z.default.rootData}=${z.default.data}${t.dynamicRef?(0,T._)`, ${z.default.dynamicAnchors}={}`:T.nil}}={}`}function Tw(t,e){t.if(z.default.valCxt,()=>{t.var(z.default.instancePath,(0,T._)`${z.default.valCxt}.${z.default.instancePath}`),t.var(z.default.parentData,(0,T._)`${z.default.valCxt}.${z.default.parentData}`),t.var(z.default.parentDataProperty,(0,T._)`${z.default.valCxt}.${z.default.parentDataProperty}`),t.var(z.default.rootData,(0,T._)`${z.default.valCxt}.${z.default.rootData}`),e.dynamicRef&&t.var(z.default.dynamicAnchors,(0,T._)`${z.default.valCxt}.${z.default.dynamicAnchors}`)},()=>{t.var(z.default.instancePath,(0,T._)`""`),t.var(z.default.parentData,(0,T._)`undefined`),t.var(z.default.parentDataProperty,(0,T._)`undefined`),t.var(z.default.rootData,z.default.data),e.dynamicRef&&t.var(z.default.dynamicAnchors,(0,T._)`{}`)})}function Rw(t){let{schema:e,opts:r,gen:n}=t;Gm(t,()=>{r.$comment&&e.$comment&&rh(t),Cw(t),n.let(z.default.vErrors,null),n.let(z.default.errors,0),r.unevaluated&&zw(t),th(t),Nw(t)})}function zw(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,T._)`${r}.evaluated`),e.if((0,T._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,T._)`${t.evaluated}.props`,(0,T._)`undefined`)),e.if((0,T._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,T._)`${t.evaluated}.items`,(0,T._)`undefined`))}function Km(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,T._)`/*# sourceURL=${r} */`:T.nil}function Iw(t,e){if(Qm(t)&&(eh(t),Xm(t))){Ow(t,e);return}(0,Ym.boolOrEmptySchema)(t,e)}function Xm({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function Qm(t){return typeof t.schema!="boolean"}function Ow(t,e){let{schema:r,gen:n,opts:o}=t;o.$comment&&r.$comment&&rh(t),Mw(t),Dw(t);let s=n.const("_errs",z.default.errors);th(t,s),n.var(e,(0,T._)`${s} === ${z.default.errors}`)}function eh(t){(0,$t.checkUnknownRules)(t),Aw(t)}function th(t,e){if(t.opts.jtd)return Jm(t,[],!1,e);let r=(0,Vm.getSchemaTypes)(t.schema),n=(0,Vm.coerceAndCheckDataType)(t,r);Jm(t,r,!n,e)}function Aw(t){let{schema:e,errSchemaPath:r,opts:n,self:o}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,$t.schemaHasRulesButRef)(e,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function Cw(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,$t.checkStrictMode)(t,"default is ignored in the schema root")}function Mw(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,xw.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function Dw(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function rh({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)t.code((0,T._)`${z.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,T.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,T._)`${z.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function Nw(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=t;r.$async?e.if((0,T._)`${z.default.errors} === 0`,()=>e.return(z.default.data),()=>e.throw((0,T._)`new ${o}(${z.default.vErrors})`)):(e.assign((0,T._)`${n}.errors`,z.default.vErrors),s.unevaluated&&jw(t),e.return((0,T._)`${z.default.errors} === 0`))}function jw({gen:t,evaluated:e,props:r,items:n}){r instanceof T.Name&&t.assign((0,T._)`${e}.props`,r),n instanceof T.Name&&t.assign((0,T._)`${e}.items`,n)}function Jm(t,e,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:u}=t,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,$t.schemaHasRulesButRef)(s,l))){o.block(()=>oh(t,"$ref",l.all.$ref.definition));return}c.jtd||Lw(t,e),o.block(()=>{for(let p of l.rules)d(p);d(l.post)});function d(p){(0,Ga.shouldUseGroup)(s,p)&&(p.type?(o.if((0,ns.checkDataType)(p.type,i,c.strictNumbers)),Bm(t,p),e.length===1&&e[0]===p.type&&r&&(o.else(),(0,ns.reportTypeError)(t)),o.endIf()):Bm(t,p),a||o.if((0,T._)`${z.default.errors} === ${n||0}`))}}function Bm(t,e){let{gen:r,schema:n,opts:{useDefaults:o}}=t;o&&(0,kw.assignDefaults)(t,e.type),r.block(()=>{for(let s of e.rules)(0,Ga.shouldUseRule)(n,s)&&oh(t,s.keyword,s.definition,e.type)})}function Lw(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(Uw(t,e),t.opts.allowUnionTypes||qw(t,e),Zw(t,t.dataTypes))}function Uw(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{nh(t.dataTypes,r)||Xa(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),Hw(t,e)}}function qw(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&Xa(t,"use allowUnionTypes to allow union type keyword")}function Zw(t,e){let r=t.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,Ga.shouldUseRule)(t.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>Fw(e,i))&&Xa(t,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function Fw(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function nh(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function Hw(t,e){let r=[];for(let n of t.dataTypes)nh(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function Xa(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,$t.checkStrictMode)(t,e,t.opts.strictTypes)}var os=class{constructor(e,r,n){if((0,On.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,$t.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",sh(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,On.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",z.default.errors))}result(e,r,n){this.failResult((0,T.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,T.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,T._)`${r} !== undefined && (${(0,T.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?In.reportExtraError:In.reportError)(this,this.def.error,r)}$dataError(){(0,In.reportError)(this,this.def.$dataError||In.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,In.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=T.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=T.nil,r=T.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,T.or)((0,T._)`${o} === undefined`,r)),e!==T.nil&&n.assign(e,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==T.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,T.or)(i(),a());function i(){if(n.length){if(!(r instanceof T.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,T._)`${(0,ns.checkDataTypes)(c,r,s.opts.strictNumbers,ns.DataType.Wrong)}`}return T.nil}function a(){if(o.validateSchema){let c=e.scopeValue("validate$data",{ref:o.validateSchema});return(0,T._)`!${c}(${r})`}return T.nil}}subschema(e,r){let n=(0,Ya.getSubschema)(this.it,e);(0,Ya.extendSubschemaData)(n,this.it,e),(0,Ya.extendSubschemaMode)(n,e);let o={...this.it,...n,items:void 0,props:void 0};return Iw(o,r),o}mergeEvaluated(e,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=$t.mergeEvaluated.props(o,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=$t.mergeEvaluated.items(o,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(e,T.Name)),!0}};qt.KeywordCxt=os;function oh(t,e,r,n){let o=new os(t,r,e);"code"in r?r.code(o,n):o.$data&&r.validate?(0,On.funcKeywordCode)(o,r):"macro"in r?(0,On.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,On.funcKeywordCode)(o,r)}var Ww=/^\/(?:[^~]|~0|~1)*$/,Vw=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function sh(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let o,s;if(t==="")return z.default.rootData;if(t[0]==="/"){if(!Ww.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);o=t,s=z.default.rootData}else{let u=Vw.exec(t);if(!u)throw new Error(`Invalid JSON-pointer: ${t}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=e)throw new Error(c("property/index",l));return n[e-l]}if(l>e)throw new Error(c("data",l));if(s=r[e-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,T._)`${s}${(0,T.getProperty)((0,$t.unescapeJsonPointer)(u))}`,i=(0,T._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${e}`}}qt.getData=sh});var ss=E(ec=>{"use strict";Object.defineProperty(ec,"__esModule",{value:!0});var Qa=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};ec.default=Qa});var Cn=E(nc=>{"use strict";Object.defineProperty(nc,"__esModule",{value:!0});var tc=zn(),rc=class extends Error{constructor(e,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,tc.resolveUrl)(e,r,n),this.missingSchema=(0,tc.normalizeId)((0,tc.getFullPath)(e,this.missingRef))}};nc.default=rc});var as=E(He=>{"use strict";Object.defineProperty(He,"__esModule",{value:!0});He.resolveSchema=He.getCompilingSchema=He.resolveRef=He.compileSchema=He.SchemaEnv=void 0;var tt=A(),Kw=ss(),er=xt(),rt=zn(),ih=U(),Jw=An(),$r=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,rt.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};He.SchemaEnv=$r;function sc(t){let e=ah.call(this,t);if(e)return e;let r=(0,rt.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new tt.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;t.$async&&(a=i.scopeValue("Error",{ref:Kw.default,code:(0,tt._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:er.default.data,parentData:er.default.parentData,parentDataProperty:er.default.parentDataProperty,dataNames:[er.default.data],dataPathArr:[tt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,tt.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:tt.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,tt._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,Jw.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(er.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let f=new Function(`${er.default.self}`,`${er.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:f}),f.errors=null,f.schema=t.schema,f.schemaEnv=t,t.$async&&(f.$async=!0),this.opts.code.source===!0&&(f.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:m,items:g}=u;f.evaluated={props:m instanceof tt.Name?void 0:m,items:g instanceof tt.Name?void 0:g,dynamicProps:m instanceof tt.Name,dynamicItems:g instanceof tt.Name},f.source&&(f.source.evaluated=(0,tt.stringify)(f.evaluated))}return t.validate=f,t}catch(d){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(t)}}He.compileSchema=sc;function Bw(t,e,r){var n;r=(0,rt.resolveUrl)(this.opts.uriResolver,e,r);let o=t.refs[r];if(o)return o;let s=Xw.call(this,t,r);if(s===void 0){let i=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new $r({schema:i,schemaId:a,root:t,baseId:e}))}if(s!==void 0)return t.refs[r]=Yw.call(this,s)}He.resolveRef=Bw;function Yw(t){return(0,rt.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:sc.call(this,t)}function ah(t){for(let e of this._compilations)if(Gw(e,t))return e}He.getCompilingSchema=ah;function Gw(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function Xw(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||is.call(this,t,e)}function is(t,e){let r=this.opts.uriResolver.parse(e),n=(0,rt._getFullPath)(this.opts.uriResolver,r),o=(0,rt.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===o)return oc.call(this,r,t);let s=(0,rt.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=is.call(this,t,i);return typeof a?.schema!="object"?void 0:oc.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||sc.call(this,i),s===(0,rt.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,rt.resolveUrl)(this.opts.uriResolver,o,u)),new $r({schema:a,schemaId:c,root:t,baseId:o})}return oc.call(this,r,i)}}He.resolveSchema=is;var Qw=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function oc(t,{baseId:e,schema:r,root:n}){var o;if(((o=t.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,ih.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!Qw.has(a)&&u&&(e=(0,rt.resolveUrl)(this.opts.uriResolver,e,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,ih.schemaHasRulesButRef)(r,this.RULES)){let a=(0,rt.resolveUrl)(this.opts.uriResolver,e,r.$ref);s=is.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new $r({schema:r,schemaId:i,root:n,baseId:e}),s.schema!==s.root.schema)return s}});var ch=E((uM,ek)=>{ek.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 cc=E((lM,mh)=>{"use strict";var tk=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),lh=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),ic=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),dh=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),rk=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function ac(t){let e="",r=0,n=0;for(n=0;n<t.length;n++)if(r=t[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n];break}for(n+=1;n<t.length;n++){if(r=t[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n]}return e}var nk=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function uh(t){return t.length=0,!0}function ok(t,e,r){if(t.length){let n=ac(t);if(n!=="")e.push(n);else return r.error=!0,!1;t.length=0}return!0}function sk(t){let e=0,r={error:!1,address:"",zone:""},n=[],o=[],s=!1,i=!1,a=ok;for(let c=0;c<t.length;c++){let u=t[c];if(!(u==="["||u==="]"))if(u===":"){if(s===!0&&(i=!0),!a(o,n,r))break;if(++e>7){r.error=!0;break}c>0&&t[c-1]===":"&&(s=!0),n.push(":");continue}else if(u==="%"){if(!a(o,n,r))break;a=uh}else{o.push(u);continue}}return o.length&&(a===uh?r.zone=o.join(""):i?n.push(o.join("")):n.push(ac(o))),r.address=n.join(""),r}function ph(t){if(ik(t,":")<2)return{host:t,isIPV6:!1};let e=sk(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,isIPV6:!0,escapedHost:n}}}function ik(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function ak(t){let e=t,r=[],n=-1,o=0;for(;o=e.length;){if(o===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(o===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(o===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((n=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,n)),e=e.slice(n)}return r.join("")}var ck={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},uk=/[@/?#:]/g,lk=/[@/?#]/g;function fh(t,e){let r=e?lk:uk;return r.lastIndex=0,t.replace(r,n=>ck[n])}function dk(t,e=!1){if(t.indexOf("%")===-1)return t;let r="";for(let n=0;n<t.length;n++){if(t[n]==="%"&&n+2<t.length){let o=t.slice(n+1,n+3);if(ic(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));e&&dh(i)?r+=i:r+="%"+s,n+=2;continue}}r+=t[n]}return r}function pk(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(ic(n)){let o=n.toUpperCase(),s=String.fromCharCode(parseInt(o,16));s!=="."&&dh(s)?e+=s:e+="%"+o,r+=2;continue}}rk(t[r])?e+=t[r]:e+=escape(t[r])}return e}function fk(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(ic(n)){e+="%"+n.toUpperCase(),r+=2;continue}}e+=escape(t[r])}return e}function mk(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!lh(r)){let n=ph(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=fh(r,!1)}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}mh.exports={nonSimpleDomain:nk,recomposeAuthority:mk,reescapeHostDelimiters:fh,normalizePercentEncoding:dk,normalizePathEncoding:pk,escapePreservingEscapes:fk,removeDotSegments:ak,isIPv4:lh,isUUID:tk,normalizeIPv6:ph,stringArrayToHexStripped:ac}});var Sh=E((dM,yh)=>{"use strict";var{isUUID:hk}=cc(),gk=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,_k=["http","https","ws","wss","urn","urn:uuid"];function yk(t){return _k.indexOf(t)!==-1}function uc(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function hh(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function gh(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function Sk(t){return t.secure=uc(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function vk(t){if((t.port===(uc(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function bk(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(gk);if(r){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let o=`${n}:${e.nid||t.nid}`,s=lc(o);t.path=void 0,s&&(t=s.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function Ek(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),o=`${r}:${e.nid||n}`,s=lc(o);s&&(t=s.serialize(t,e));let i=t,a=t.nss;return i.path=`${n||e.nid}:${a}`,e.skipEscape=!0,i}function wk(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!hk(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function kk(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var _h={scheme:"http",domainHost:!0,parse:hh,serialize:gh},xk={scheme:"https",domainHost:_h.domainHost,parse:hh,serialize:gh},cs={scheme:"ws",domainHost:!0,parse:Sk,serialize:vk},$k={scheme:"wss",domainHost:cs.domainHost,parse:cs.parse,serialize:cs.serialize},Pk={scheme:"urn",parse:bk,serialize:Ek,skipNormalize:!0},Tk={scheme:"urn:uuid",parse:wk,serialize:kk,skipNormalize:!0},us={http:_h,https:xk,ws:cs,wss:$k,urn:Pk,"urn:uuid":Tk};Object.setPrototypeOf(us,null);function lc(t){return t&&(us[t]||us[t.toLowerCase()])||void 0}yh.exports={wsIsSecure:uc,SCHEMES:us,isValidSchemeName:yk,getSchemeHandler:lc}});var xh=E((pM,ls)=>{"use strict";var{normalizeIPv6:Rk,removeDotSegments:Mn,recomposeAuthority:zk,normalizePercentEncoding:Ik,normalizePathEncoding:Ok,escapePreservingEscapes:Ak,reescapeHostDelimiters:Ck,isIPv4:Mk,nonSimpleDomain:Dk}=cc(),{SCHEMES:Nk,getSchemeHandler:bh}=Sh();function jk(t,e){return typeof t=="string"?t=Fk(t,e):typeof t=="object"&&(t=Pr(tr(t,e),e)),t}function Lk(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=Eh(Pr(t,n),Pr(e,n),n,!0);return n.skipEscape=!0,tr(o,n)}function Eh(t,e,r,n){let o={};return n||(t=Pr(tr(t,r),r),e=Pr(tr(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(o.scheme=e.scheme,o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=Mn(e.path||""),o.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=Mn(e.path||""),o.query=e.query):(e.path?(e.path[0]==="/"?o.path=Mn(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?o.path="/"+e.path:t.path?o.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:o.path=e.path,o.path=Mn(o.path)),o.query=e.query):(o.path=t.path,e.query!==void 0?o.query=e.query:o.query=t.query),o.userinfo=t.userinfo,o.host=t.host,o.port=t.port),o.scheme=t.scheme),o.fragment=e.fragment,o}function Uk(t,e,r){let n=vh(t,r),o=vh(e,r);return n!==void 0&&o!==void 0&&n.toLowerCase()===o.toLowerCase()}function tr(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},e),o=[],s=bh(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=Ik(r.path):(r.path=Ak(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&o.push(r.scheme,":");let i=zk(r);if(i!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(i),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(a=Mn(a)),i===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),o.push(a)}return r.query!==void 0&&o.push("?",r.query),r.fragment!==void 0&&o.push("#",r.fragment),o.join("")}var qk=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function Zk(t,e){if(e[2]!==void 0&&t.path&&t.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof t.port=="number"&&(t.port<0||t.port>65535))return"URI port is malformed."}function wh(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1,s=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let i=t.match(qk);if(i){n.scheme=i[1],n.userinfo=i[3],n.host=i[4],n.port=parseInt(i[5],10),n.path=i[6]||"",n.query=i[7],n.fragment=i[8],isNaN(n.port)&&(n.port=i[5]);let a=Zk(n,i);if(a!==void 0&&(n.error=n.error||a,o=!0),n.host)if(Mk(n.host)===!1){let l=Rk(n.host);n.host=l.host.toLowerCase(),s=l.isIPV6}else s=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let c=bh(r.scheme||n.scheme);if(!r.unicodeSupport&&(!c||!c.unicodeSupport)&&n.host&&(r.domainHost||c&&c.domainHost)&&s===!1&&Dk(n.host))try{n.host=new URL("http://"+n.host).hostname}catch(u){n.error=n.error||"Host's domain name can not be converted to ASCII: "+u}if((!c||c&&!c.skipNormalize)&&(t.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=Ck(unescape(n.host),s))),n.path&&(n.path=Ok(n.path)),n.fragment))try{n.fragment=encodeURI(decodeURIComponent(n.fragment))}catch{n.error=n.error||"URI malformed"}c&&c.parse&&c.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o}}function Pr(t,e){return wh(t,e).parsed}function Fk(t,e){return kh(t,e).normalized}function kh(t,e){let{parsed:r,malformedAuthorityOrPort:n}=wh(t,e);return{normalized:n?t:tr(r,e),malformedAuthorityOrPort:n}}function vh(t,e){if(typeof t=="string"){let{normalized:r,malformedAuthorityOrPort:n}=kh(t,e);return n?void 0:r}if(typeof t=="object")return tr(t,e)}var dc={SCHEMES:Nk,normalize:jk,resolve:Lk,resolveComponent:Eh,equal:Uk,serialize:tr,parse:Pr};ls.exports=dc;ls.exports.default=dc;ls.exports.fastUri=dc});var Ph=E(pc=>{"use strict";Object.defineProperty(pc,"__esModule",{value:!0});var $h=xh();$h.code='require("ajv/dist/runtime/uri").default';pc.default=$h});var Mh=E(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.CodeGen=ge.Name=ge.nil=ge.stringify=ge.str=ge._=ge.KeywordCxt=void 0;var Hk=An();Object.defineProperty(ge,"KeywordCxt",{enumerable:!0,get:function(){return Hk.KeywordCxt}});var Tr=A();Object.defineProperty(ge,"_",{enumerable:!0,get:function(){return Tr._}});Object.defineProperty(ge,"str",{enumerable:!0,get:function(){return Tr.str}});Object.defineProperty(ge,"stringify",{enumerable:!0,get:function(){return Tr.stringify}});Object.defineProperty(ge,"nil",{enumerable:!0,get:function(){return Tr.nil}});Object.defineProperty(ge,"Name",{enumerable:!0,get:function(){return Tr.Name}});Object.defineProperty(ge,"CodeGen",{enumerable:!0,get:function(){return Tr.CodeGen}});var Wk=ss(),Oh=Cn(),Vk=Ua(),Dn=as(),Kk=A(),Nn=zn(),ds=Rn(),mc=U(),Th=ch(),Jk=Ph(),Ah=(t,e)=>new RegExp(t,e);Ah.code="new RegExp";var Bk=["removeAdditional","useDefaults","coerceTypes"],Yk=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),Gk={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."},Xk={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},Rh=200;function Qk(t){var e,r,n,o,s,i,a,c,u,l,d,p,f,m,g,S,v,x,b,$,k,Se,K,ct,Ne;let Pt=t.strict,ri=(e=t.code)===null||e===void 0?void 0:e.optimize,qu=ri===!0||ri===void 0?1:ri||0,Zu=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:Ah,iy=(o=t.uriResolver)!==null&&o!==void 0?o:Jk.default;return{strictSchema:(i=(s=t.strictSchema)!==null&&s!==void 0?s:Pt)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:Pt)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=t.strictTypes)!==null&&u!==void 0?u:Pt)!==null&&l!==void 0?l:"log",strictTuples:(p=(d=t.strictTuples)!==null&&d!==void 0?d:Pt)!==null&&p!==void 0?p:"log",strictRequired:(m=(f=t.strictRequired)!==null&&f!==void 0?f:Pt)!==null&&m!==void 0?m:!1,code:t.code?{...t.code,optimize:qu,regExp:Zu}:{optimize:qu,regExp:Zu},loopRequired:(g=t.loopRequired)!==null&&g!==void 0?g:Rh,loopEnum:(S=t.loopEnum)!==null&&S!==void 0?S:Rh,meta:(v=t.meta)!==null&&v!==void 0?v:!0,messages:(x=t.messages)!==null&&x!==void 0?x:!0,inlineRefs:(b=t.inlineRefs)!==null&&b!==void 0?b:!0,schemaId:($=t.schemaId)!==null&&$!==void 0?$:"$id",addUsedSchema:(k=t.addUsedSchema)!==null&&k!==void 0?k:!0,validateSchema:(Se=t.validateSchema)!==null&&Se!==void 0?Se:!0,validateFormats:(K=t.validateFormats)!==null&&K!==void 0?K:!0,unicodeRegExp:(ct=t.unicodeRegExp)!==null&&ct!==void 0?ct:!0,int32range:(Ne=t.int32range)!==null&&Ne!==void 0?Ne:!0,uriResolver:iy}}var jn=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...Qk(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new Kk.ValueScope({scope:{},prefixes:Yk,es5:r,lines:n}),this.logger=s0(e.logger);let o=e.validateFormats;e.validateFormats=!1,this.RULES=(0,Vk.getRules)(),zh.call(this,Gk,e,"NOT SUPPORTED"),zh.call(this,Xk,e,"DEPRECATED","warn"),this._metaOpts=n0.call(this),e.formats&&t0.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&r0.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),e0.call(this),e.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,o=Th;n==="id"&&(o={...Th},o.id=o.$id,delete o.$id),r&&e&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return o.call(this,e,r);async function o(l,d){await s.call(this,l.$schema);let p=this._addSchema(l,d);return p.validate||i.call(this,p)}async function s(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof Oh.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await s.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(e,r,n,o=this.opts.validateSchema){if(Array.isArray(e)){for(let i of e)this.addSchema(i,void 0,n,o);return this}let s;if(typeof e=="object"){let{schemaId:i}=this.opts;if(s=e[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,Nn.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,o,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(n,e);if(!o&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return o}getSchema(e){let r;for(;typeof(r=Ih.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,o=new Dn.SchemaEnv({schema:{},schemaId:n});if(r=Dn.resolveSchema.call(this,o,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=Ih.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,Nn.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(a0.call(this,n,r),!r)return(0,mc.eachItem)(n,s=>fc.call(this,s)),this;u0.call(this,r);let o={...r,type:(0,ds.getJSONTypes)(r.type),schemaType:(0,ds.getJSONTypes)(r.schemaType)};return(0,mc.eachItem)(n,o.type.length===0?s=>fc.call(this,s,o):s=>o.type.forEach(i=>fc.call(this,s,o,i))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===e);o>=0&&n.rules.splice(o,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let o of r){let s=o.split("/").slice(1),i=e;for(let a of s)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=Ch(l))}}return e}_removeAllSchemas(e,r){for(let n in e){let o=e[n];(!r||r.test(n))&&(typeof o=="string"?delete e[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete e[n]))}}_addSchema(e,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof e=="object")i=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;n=(0,Nn.normalizeId)(i||n);let u=Nn.getSchemaRefs.call(this,e,n);return c=new Dn.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),o&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):Dn.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{Dn.compileSchema.call(this,e)}finally{this.opts=r}}};jn.ValidationError=Wk.default;jn.MissingRefError=Oh.default;ge.default=jn;function zh(t,e,r,n="error"){for(let o in t){let s=o;s in e&&this.logger[n](`${r}: option ${o}. ${t[s]}`)}}function Ih(t){return t=(0,Nn.normalizeId)(t),this.schemas[t]||this.refs[t]}function e0(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function t0(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function r0(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function n0(){let t={...this.opts};for(let e of Bk)delete t[e];return t}var o0={log(){},warn(){},error(){}};function s0(t){if(t===!1)return o0;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var i0=/^[a-z_$][a-z0-9_$:-]*$/i;function a0(t,e){let{RULES:r}=this;if((0,mc.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!i0.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function fc(t,e,r){var n;let o=e?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,i=o?s.post:s.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},s.rules.push(i)),s.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,ds.getJSONTypes)(e.type),schemaType:(0,ds.getJSONTypes)(e.schemaType)}};e.before?c0.call(this,i,a,e.before):i.rules.push(a),s.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function c0(t,e,r){let n=t.rules.findIndex(o=>o.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function u0(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=Ch(e)),t.validateSchema=this.compile(e,!0))}var l0={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Ch(t){return{anyOf:[t,l0]}}});var Dh=E(hc=>{"use strict";Object.defineProperty(hc,"__esModule",{value:!0});var d0={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};hc.default=d0});var Uh=E(rr=>{"use strict";Object.defineProperty(rr,"__esModule",{value:!0});rr.callRef=rr.getValidate=void 0;var p0=Cn(),Nh=Fe(),Oe=A(),Rr=xt(),jh=as(),ps=U(),f0={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=jh.resolveRef.call(c,u,o,r);if(l===void 0)throw new p0.default(n.opts.uriResolver,o,r);if(l instanceof jh.SchemaEnv)return p(l);return f(l);function d(){if(s===u)return fs(t,i,s,s.$async);let m=e.scopeValue("root",{ref:u});return fs(t,(0,Oe._)`${m}.validate`,u,u.$async)}function p(m){let g=Lh(t,m);fs(t,g,m,m.$async)}function f(m){let g=e.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Oe.stringify)(m)}:{ref:m}),S=e.name("valid"),v=t.subschema({schema:m,dataTypes:[],schemaPath:Oe.nil,topSchemaRef:g,errSchemaPath:r},S);t.mergeEvaluated(v),t.ok(S)}}};function Lh(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Oe._)`${r.scopeValue("wrapper",{ref:e})}.validate`}rr.getValidate=Lh;function fs(t,e,r,n){let{gen:o,it:s}=t,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?Rr.default.this:Oe.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let m=o.let("valid");o.try(()=>{o.code((0,Oe._)`await ${(0,Nh.callValidateCode)(t,e,u)}`),f(e),i||o.assign(m,!0)},g=>{o.if((0,Oe._)`!(${g} instanceof ${s.ValidationError})`,()=>o.throw(g)),p(g),i||o.assign(m,!1)}),t.ok(m)}function d(){t.result((0,Nh.callValidateCode)(t,e,u),()=>f(e),()=>p(e))}function p(m){let g=(0,Oe._)`${m}.errors`;o.assign(Rr.default.vErrors,(0,Oe._)`${Rr.default.vErrors} === null ? ${g} : ${Rr.default.vErrors}.concat(${g})`),o.assign(Rr.default.errors,(0,Oe._)`${Rr.default.vErrors}.length`)}function f(m){var g;if(!s.opts.unevaluated)return;let S=(g=r?.validate)===null||g===void 0?void 0:g.evaluated;if(s.props!==!0)if(S&&!S.dynamicProps)S.props!==void 0&&(s.props=ps.mergeEvaluated.props(o,S.props,s.props));else{let v=o.var("props",(0,Oe._)`${m}.evaluated.props`);s.props=ps.mergeEvaluated.props(o,v,s.props,Oe.Name)}if(s.items!==!0)if(S&&!S.dynamicItems)S.items!==void 0&&(s.items=ps.mergeEvaluated.items(o,S.items,s.items));else{let v=o.var("items",(0,Oe._)`${m}.evaluated.items`);s.items=ps.mergeEvaluated.items(o,v,s.items,Oe.Name)}}}rr.callRef=fs;rr.default=f0});var qh=E(gc=>{"use strict";Object.defineProperty(gc,"__esModule",{value:!0});var m0=Dh(),h0=Uh(),g0=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",m0.default,h0.default];gc.default=g0});var Zh=E(_c=>{"use strict";Object.defineProperty(_c,"__esModule",{value:!0});var ms=A(),Zt=ms.operators,hs={maximum:{okStr:"<=",ok:Zt.LTE,fail:Zt.GT},minimum:{okStr:">=",ok:Zt.GTE,fail:Zt.LT},exclusiveMaximum:{okStr:"<",ok:Zt.LT,fail:Zt.GTE},exclusiveMinimum:{okStr:">",ok:Zt.GT,fail:Zt.LTE}},_0={message:({keyword:t,schemaCode:e})=>(0,ms.str)`must be ${hs[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,ms._)`{comparison: ${hs[t].okStr}, limit: ${e}}`},y0={keyword:Object.keys(hs),type:"number",schemaType:"number",$data:!0,error:_0,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,ms._)`${r} ${hs[e].fail} ${n} || isNaN(${r})`)}};_c.default=y0});var Fh=E(yc=>{"use strict";Object.defineProperty(yc,"__esModule",{value:!0});var Ln=A(),S0={message:({schemaCode:t})=>(0,Ln.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,Ln._)`{multipleOf: ${t}}`},v0={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:S0,code(t){let{gen:e,data:r,schemaCode:n,it:o}=t,s=o.opts.multipleOfPrecision,i=e.let("res"),a=s?(0,Ln._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,Ln._)`${i} !== parseInt(${i})`;t.fail$data((0,Ln._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};yc.default=v0});var Wh=E(Sc=>{"use strict";Object.defineProperty(Sc,"__esModule",{value:!0});function Hh(t){let e=t.length,r=0,n=0,o;for(;n<e;)r++,o=t.charCodeAt(n++),o>=55296&&o<=56319&&n<e&&(o=t.charCodeAt(n),(o&64512)===56320&&n++);return r}Sc.default=Hh;Hh.code='require("ajv/dist/runtime/ucs2length").default'});var Vh=E(vc=>{"use strict";Object.defineProperty(vc,"__esModule",{value:!0});var nr=A(),b0=U(),E0=Wh(),w0={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,nr.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,nr._)`{limit: ${t}}`},k0={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:w0,code(t){let{keyword:e,data:r,schemaCode:n,it:o}=t,s=e==="maxLength"?nr.operators.GT:nr.operators.LT,i=o.opts.unicode===!1?(0,nr._)`${r}.length`:(0,nr._)`${(0,b0.useFunc)(t.gen,E0.default)}(${r})`;t.fail$data((0,nr._)`${i} ${s} ${n}`)}};vc.default=k0});var Kh=E(bc=>{"use strict";Object.defineProperty(bc,"__esModule",{value:!0});var x0=Fe(),$0=U(),zr=A(),P0={message:({schemaCode:t})=>(0,zr.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,zr._)`{pattern: ${t}}`},T0={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:P0,code(t){let{gen:e,data:r,$data:n,schema:o,schemaCode:s,it:i}=t,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,zr._)`new RegExp`:(0,$0.useFunc)(e,c),l=e.let("valid");e.try(()=>e.assign(l,(0,zr._)`${u}(${s}, ${a}).test(${r})`),()=>e.assign(l,!1)),t.fail$data((0,zr._)`!${l}`)}else{let c=(0,x0.usePattern)(t,o);t.fail$data((0,zr._)`!${c}.test(${r})`)}}};bc.default=T0});var Jh=E(Ec=>{"use strict";Object.defineProperty(Ec,"__esModule",{value:!0});var Un=A(),R0={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,Un.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,Un._)`{limit: ${t}}`},z0={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:R0,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxProperties"?Un.operators.GT:Un.operators.LT;t.fail$data((0,Un._)`Object.keys(${r}).length ${o} ${n}`)}};Ec.default=z0});var Bh=E(wc=>{"use strict";Object.defineProperty(wc,"__esModule",{value:!0});var qn=Fe(),Zn=A(),I0=U(),O0={message:({params:{missingProperty:t}})=>(0,Zn.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,Zn._)`{missingProperty: ${t}}`},A0={keyword:"required",type:"object",schemaType:"array",$data:!0,error:O0,code(t){let{gen:e,schema:r,schemaCode:n,data:o,$data:s,it:i}=t,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let f=t.parentSchema.properties,{definedProperties:m}=t.it;for(let g of r)if(f?.[g]===void 0&&!m.has(g)){let S=i.schemaEnv.baseId+i.errSchemaPath,v=`required property "${g}" is not defined at "${S}" (strictRequired)`;(0,I0.checkStrictMode)(i,v,i.opts.strictRequired)}}function u(){if(c||s)t.block$data(Zn.nil,d);else for(let f of r)(0,qn.checkReportMissingProp)(t,f)}function l(){let f=e.let("missing");if(c||s){let m=e.let("valid",!0);t.block$data(m,()=>p(f,m)),t.ok(m)}else e.if((0,qn.checkMissingProp)(t,r,f)),(0,qn.reportMissingProp)(t,f),e.else()}function d(){e.forOf("prop",n,f=>{t.setParams({missingProperty:f}),e.if((0,qn.noPropertyInData)(e,o,f,a.ownProperties),()=>t.error())})}function p(f,m){t.setParams({missingProperty:f}),e.forOf(f,n,()=>{e.assign(m,(0,qn.propertyInData)(e,o,f,a.ownProperties)),e.if((0,Zn.not)(m),()=>{t.error(),e.break()})},Zn.nil)}}};wc.default=A0});var Yh=E(kc=>{"use strict";Object.defineProperty(kc,"__esModule",{value:!0});var Fn=A(),C0={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,Fn.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,Fn._)`{limit: ${t}}`},M0={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:C0,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxItems"?Fn.operators.GT:Fn.operators.LT;t.fail$data((0,Fn._)`${r}.length ${o} ${n}`)}};kc.default=M0});var gs=E(xc=>{"use strict";Object.defineProperty(xc,"__esModule",{value:!0});var Gh=Ja();Gh.code='require("ajv/dist/runtime/equal").default';xc.default=Gh});var Xh=E(Pc=>{"use strict";Object.defineProperty(Pc,"__esModule",{value:!0});var $c=Rn(),_e=A(),D0=U(),N0=gs(),j0={message:({params:{i:t,j:e}})=>(0,_e.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,_e._)`{i: ${t}, j: ${e}}`},L0={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:j0,code(t){let{gen:e,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=t;if(!n&&!o)return;let c=e.let("valid"),u=s.items?(0,$c.getSchemaTypes)(s.items):[];t.block$data(c,l,(0,_e._)`${i} === false`),t.ok(c);function l(){let m=e.let("i",(0,_e._)`${r}.length`),g=e.let("j");t.setParams({i:m,j:g}),e.assign(c,!0),e.if((0,_e._)`${m} > 1`,()=>(d()?p:f)(m,g))}function d(){return u.length>0&&!u.some(m=>m==="object"||m==="array")}function p(m,g){let S=e.name("item"),v=(0,$c.checkDataTypes)(u,S,a.opts.strictNumbers,$c.DataType.Wrong),x=e.const("indices",(0,_e._)`{}`);e.for((0,_e._)`;${m}--;`,()=>{e.let(S,(0,_e._)`${r}[${m}]`),e.if(v,(0,_e._)`continue`),u.length>1&&e.if((0,_e._)`typeof ${S} == "string"`,(0,_e._)`${S} += "_"`),e.if((0,_e._)`typeof ${x}[${S}] == "number"`,()=>{e.assign(g,(0,_e._)`${x}[${S}]`),t.error(),e.assign(c,!1).break()}).code((0,_e._)`${x}[${S}] = ${m}`)})}function f(m,g){let S=(0,D0.useFunc)(e,N0.default),v=e.name("outer");e.label(v).for((0,_e._)`;${m}--;`,()=>e.for((0,_e._)`${g} = ${m}; ${g}--;`,()=>e.if((0,_e._)`${S}(${r}[${m}], ${r}[${g}])`,()=>{t.error(),e.assign(c,!1).break(v)})))}}};Pc.default=L0});var Qh=E(Rc=>{"use strict";Object.defineProperty(Rc,"__esModule",{value:!0});var Tc=A(),U0=U(),q0=gs(),Z0={message:"must be equal to constant",params:({schemaCode:t})=>(0,Tc._)`{allowedValue: ${t}}`},F0={keyword:"const",$data:!0,error:Z0,code(t){let{gen:e,data:r,$data:n,schemaCode:o,schema:s}=t;n||s&&typeof s=="object"?t.fail$data((0,Tc._)`!${(0,U0.useFunc)(e,q0.default)}(${r}, ${o})`):t.fail((0,Tc._)`${s} !== ${r}`)}};Rc.default=F0});var eg=E(zc=>{"use strict";Object.defineProperty(zc,"__esModule",{value:!0});var Hn=A(),H0=U(),W0=gs(),V0={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,Hn._)`{allowedValues: ${t}}`},K0={keyword:"enum",schemaType:"array",$data:!0,error:V0,code(t){let{gen:e,data:r,$data:n,schema:o,schemaCode:s,it:i}=t;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let a=o.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,H0.useFunc)(e,W0.default)),l;if(a||n)l=e.let("valid"),t.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let f=e.const("vSchema",s);l=(0,Hn.or)(...o.map((m,g)=>p(f,g)))}t.pass(l);function d(){e.assign(l,!1),e.forOf("v",s,f=>e.if((0,Hn._)`${u()}(${r}, ${f})`,()=>e.assign(l,!0).break()))}function p(f,m){let g=o[m];return typeof g=="object"&&g!==null?(0,Hn._)`${u()}(${r}, ${f}[${m}])`:(0,Hn._)`${r} === ${g}`}}};zc.default=K0});var tg=E(Ic=>{"use strict";Object.defineProperty(Ic,"__esModule",{value:!0});var J0=Zh(),B0=Fh(),Y0=Vh(),G0=Kh(),X0=Jh(),Q0=Bh(),ex=Yh(),tx=Xh(),rx=Qh(),nx=eg(),ox=[J0.default,B0.default,Y0.default,G0.default,X0.default,Q0.default,ex.default,tx.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},rx.default,nx.default];Ic.default=ox});var Ac=E(Wn=>{"use strict";Object.defineProperty(Wn,"__esModule",{value:!0});Wn.validateAdditionalItems=void 0;var or=A(),Oc=U(),sx={message:({params:{len:t}})=>(0,or.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,or._)`{limit: ${t}}`},ix={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:sx,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,Oc.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}rg(t,n)}};function rg(t,e){let{gen:r,schema:n,data:o,keyword:s,it:i}=t;i.items=!0;let a=r.const("len",(0,or._)`${o}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,or._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,Oc.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,or._)`${a} <= ${e.length}`);r.if((0,or.not)(u),()=>c(u)),t.ok(u)}function c(u){r.forRange("i",e.length,a,l=>{t.subschema({keyword:s,dataProp:l,dataPropType:Oc.Type.Num},u),i.allErrors||r.if((0,or.not)(u),()=>r.break())})}}Wn.validateAdditionalItems=rg;Wn.default=ix});var Cc=E(Vn=>{"use strict";Object.defineProperty(Vn,"__esModule",{value:!0});Vn.validateTuple=void 0;var ng=A(),_s=U(),ax=Fe(),cx={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return og(t,"additionalItems",e);r.items=!0,!(0,_s.alwaysValidSchema)(r,e)&&t.ok((0,ax.validateArray)(t))}};function og(t,e,r=t.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=t;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=_s.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,ng._)`${s}.length`);r.forEach((d,p)=>{(0,_s.alwaysValidSchema)(a,d)||(n.if((0,ng._)`${u} > ${p}`,()=>t.subschema({keyword:i,schemaProp:p,dataProp:p},c)),t.ok(c))});function l(d){let{opts:p,errSchemaPath:f}=a,m=r.length,g=m===d.minItems&&(m===d.maxItems||d[e]===!1);if(p.strictTuples&&!g){let S=`"${i}" is ${m}-tuple, but minItems or maxItems/${e} are not specified or different at path "${f}"`;(0,_s.checkStrictMode)(a,S,p.strictTuples)}}}Vn.validateTuple=og;Vn.default=cx});var sg=E(Mc=>{"use strict";Object.defineProperty(Mc,"__esModule",{value:!0});var ux=Cc(),lx={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,ux.validateTuple)(t,"items")};Mc.default=lx});var ag=E(Dc=>{"use strict";Object.defineProperty(Dc,"__esModule",{value:!0});var ig=A(),dx=U(),px=Fe(),fx=Ac(),mx={message:({params:{len:t}})=>(0,ig.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,ig._)`{limit: ${t}}`},hx={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:mx,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:o}=r;n.items=!0,!(0,dx.alwaysValidSchema)(n,e)&&(o?(0,fx.validateAdditionalItems)(t,o):t.ok((0,px.validateArray)(t)))}};Dc.default=hx});var cg=E(Nc=>{"use strict";Object.defineProperty(Nc,"__esModule",{value:!0});var We=A(),ys=U(),gx={message:({params:{min:t,max:e}})=>e===void 0?(0,We.str)`must contain at least ${t} valid item(s)`:(0,We.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,We._)`{minContains: ${t}}`:(0,We._)`{minContains: ${t}, maxContains: ${e}}`},_x={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:gx,code(t){let{gen:e,schema:r,parentSchema:n,data:o,it:s}=t,i,a,{minContains:c,maxContains:u}=n;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=e.const("len",(0,We._)`${o}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,ys.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,ys.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,ys.alwaysValidSchema)(s,r)){let g=(0,We._)`${l} >= ${i}`;a!==void 0&&(g=(0,We._)`${g} && ${l} <= ${a}`),t.pass(g);return}s.items=!0;let d=e.name("valid");a===void 0&&i===1?f(d,()=>e.if(d,()=>e.break())):i===0?(e.let(d,!0),a!==void 0&&e.if((0,We._)`${o}.length > 0`,p)):(e.let(d,!1),p()),t.result(d,()=>t.reset());function p(){let g=e.name("_valid"),S=e.let("count",0);f(g,()=>e.if(g,()=>m(S)))}function f(g,S){e.forRange("i",0,l,v=>{t.subschema({keyword:"contains",dataProp:v,dataPropType:ys.Type.Num,compositeRule:!0},g),S()})}function m(g){e.code((0,We._)`${g}++`),a===void 0?e.if((0,We._)`${g} >= ${i}`,()=>e.assign(d,!0).break()):(e.if((0,We._)`${g} > ${a}`,()=>e.assign(d,!1).break()),i===1?e.assign(d,!0):e.if((0,We._)`${g} >= ${i}`,()=>e.assign(d,!0)))}}};Nc.default=_x});var dg=E(ft=>{"use strict";Object.defineProperty(ft,"__esModule",{value:!0});ft.validateSchemaDeps=ft.validatePropertyDeps=ft.error=void 0;var jc=A(),yx=U(),Kn=Fe();ft.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,jc.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,jc._)`{property: ${t},
|
|
18
18
|
missingProperty: ${n},
|
|
19
19
|
depsCount: ${e},
|
|
20
|
-
deps: ${r}}`};var hx={keyword:"dependencies",type:"object",schemaType:"object",error:pt.error,code(t){let[e,r]=gx(t);ag(t,e),cg(t,r)}};function gx({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let o=Array.isArray(t[n])?e:r;o[n]=t[n]}return[e,r]}function ag(t,e=t.schema){let{gen:r,data:n,it:o}=t;if(Object.keys(e).length===0)return;let s=r.let("missing");for(let i in e){let a=e[i];if(a.length===0)continue;let c=(0,Hn.propertyInData)(r,n,i,o.opts.ownProperties);t.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,Hn.checkReportMissingProp)(t,u)}):(r.if((0,Dc._)`${c} && (${(0,Hn.checkMissingProp)(t,a,s)})`),(0,Hn.reportMissingProp)(t,s),r.else())}}pt.validatePropertyDeps=ag;function cg(t,e=t.schema){let{gen:r,data:n,keyword:o,it:s}=t,i=r.name("valid");for(let a in e)(0,mx.alwaysValidSchema)(s,e[a])||(r.if((0,Hn.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=t.subschema({keyword:o,schemaProp:a},i);t.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),t.ok(i))}pt.validateSchemaDeps=cg;pt.default=hx});var dg=E(Nc=>{"use strict";Object.defineProperty(Nc,"__esModule",{value:!0});var lg=A(),_x=U(),yx={message:"property name must be valid",params:({params:t})=>(0,lg._)`{propertyName: ${t.propertyName}}`},Sx={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:yx,code(t){let{gen:e,schema:r,data:n,it:o}=t;if((0,_x.alwaysValidSchema)(o,r))return;let s=e.name("valid");e.forIn("key",n,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),e.if((0,lg.not)(s),()=>{t.error(!0),o.allErrors||e.break()})}),t.ok(s)}};Nc.default=Sx});var Lc=E(jc=>{"use strict";Object.defineProperty(jc,"__esModule",{value:!0});var ys=Fe(),rt=A(),vx=xt(),Ss=U(),bx={message:"must NOT have additional properties",params:({params:t})=>(0,rt._)`{additionalProperty: ${t.additionalProperty}}`},Ex={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:bx,code(t){let{gen:e,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=t;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,Ss.alwaysValidSchema)(i,r))return;let u=(0,ys.allSchemaProperties)(n.properties),l=(0,ys.allSchemaProperties)(n.patternProperties);d(),t.ok((0,rt._)`${s} === ${vx.default.errors}`);function d(){e.forIn("key",o,S=>{!u.length&&!l.length?m(S):e.if(p(S),()=>m(S))})}function p(S){let v;if(u.length>8){let x=(0,Ss.schemaRefOrVal)(i,n.properties,"properties");v=(0,ys.isOwnProperty)(e,x,S)}else u.length?v=(0,rt.or)(...u.map(x=>(0,rt._)`${S} === ${x}`)):v=rt.nil;return l.length&&(v=(0,rt.or)(v,...l.map(x=>(0,rt._)`${(0,ys.usePattern)(t,x)}.test(${S})`))),(0,rt.not)(v)}function f(S){e.code((0,rt._)`delete ${o}[${S}]`)}function m(S){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){f(S);return}if(r===!1){t.setParams({additionalProperty:S}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,Ss.alwaysValidSchema)(i,r)){let v=e.name("valid");c.removeAdditional==="failing"?(g(S,v,!1),e.if((0,rt.not)(v),()=>{t.reset(),f(S)})):(g(S,v),a||e.if((0,rt.not)(v),()=>e.break()))}}function g(S,v,x){let b={keyword:"additionalProperties",dataProp:S,dataPropType:Ss.Type.Str};x===!1&&Object.assign(b,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(b,v)}}};jc.default=Ex});var mg=E(qc=>{"use strict";Object.defineProperty(qc,"__esModule",{value:!0});var wx=Rn(),pg=Fe(),Uc=U(),fg=Lc(),kx={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:o,it:s}=t;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&fg.default.code(new wx.KeywordCxt(s,fg.default,"additionalProperties"));let i=(0,pg.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=Uc.mergeEvaluated.props(e,(0,Uc.toHash)(i),s.props));let a=i.filter(d=>!(0,Uc.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)u(d)?l(d):(e.if((0,pg.propertyInData)(e,o,d,s.opts.ownProperties)),l(d),s.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};qc.default=kx});var yg=E(Zc=>{"use strict";Object.defineProperty(Zc,"__esModule",{value:!0});var hg=Fe(),vs=A(),gg=U(),_g=U(),xx={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:o,it:s}=t,{opts:i}=s,a=(0,hg.allSchemaProperties)(r),c=a.filter(g=>(0,gg.alwaysValidSchema)(s,r[g]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=e.name("valid");s.props!==!0&&!(s.props instanceof vs.Name)&&(s.props=(0,_g.evaluatedPropsToName)(e,s.props));let{props:d}=s;p();function p(){for(let g of a)u&&f(g),s.allErrors?m(g):(e.var(l,!0),m(g),e.if(l))}function f(g){for(let S in u)new RegExp(g).test(S)&&(0,gg.checkStrictMode)(s,`property ${S} matches pattern ${g} (use allowMatchingProperties)`)}function m(g){e.forIn("key",n,S=>{e.if((0,vs._)`${(0,hg.usePattern)(t,g)}.test(${S})`,()=>{let v=c.includes(g);v||t.subschema({keyword:"patternProperties",schemaProp:g,dataProp:S,dataPropType:_g.Type.Str},l),s.opts.unevaluated&&d!==!0?e.assign((0,vs._)`${d}[${S}]`,!0):!v&&!s.allErrors&&e.if((0,vs.not)(l),()=>e.break())})})}}};Zc.default=xx});var Sg=E(Fc=>{"use strict";Object.defineProperty(Fc,"__esModule",{value:!0});var $x=U(),Px={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,$x.alwaysValidSchema)(n,r)){t.fail();return}let o=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),t.failResult(o,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};Fc.default=Px});var vg=E(Hc=>{"use strict";Object.defineProperty(Hc,"__esModule",{value:!0});var Tx=Fe(),zx={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:Tx.validateUnion,error:{message:"must match a schema in anyOf"}};Hc.default=zx});var bg=E(Wc=>{"use strict";Object.defineProperty(Wc,"__esModule",{value:!0});var bs=A(),Rx=U(),Ix={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,bs._)`{passingSchemas: ${t.passing}}`},Ox={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:Ix,code(t){let{gen:e,schema:r,parentSchema:n,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(u),t.result(i,()=>t.reset(),()=>t.error(!0));function u(){s.forEach((l,d)=>{let p;(0,Rx.alwaysValidSchema)(o,l)?e.var(c,!0):p=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,bs._)`${c} && ${i}`).assign(i,!1).assign(a,(0,bs._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,d),p&&t.mergeEvaluated(p,bs.Name)})})}}};Wc.default=Ox});var Eg=E(Vc=>{"use strict";Object.defineProperty(Vc,"__esModule",{value:!0});var Ax=U(),Cx={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=e.name("valid");r.forEach((s,i)=>{if((0,Ax.alwaysValidSchema)(n,s))return;let a=t.subschema({keyword:"allOf",schemaProp:i},o);t.ok(o),t.mergeEvaluated(a)})}};Vc.default=Cx});var xg=E(Kc=>{"use strict";Object.defineProperty(Kc,"__esModule",{value:!0});var Es=A(),kg=U(),Mx={message:({params:t})=>(0,Es.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,Es._)`{failingKeyword: ${t.ifClause}}`},Dx={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:Mx,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,kg.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=wg(n,"then"),s=wg(n,"else");if(!o&&!s)return;let i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),o&&s){let l=e.let("ifClause");t.setParams({ifClause:l}),e.if(a,u("then",l),u("else",l))}else o?e.if(a,u("then")):e.if((0,Es.not)(a),u("else"));t.pass(i,()=>t.error(!0));function c(){let l=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(l)}function u(l,d){return()=>{let p=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(p,i),d?e.assign(d,(0,Es._)`${l}`):t.setParams({ifClause:l})}}}};function wg(t,e){let r=t.schema[e];return r!==void 0&&!(0,kg.alwaysValidSchema)(t,r)}Kc.default=Dx});var $g=E(Jc=>{"use strict";Object.defineProperty(Jc,"__esModule",{value:!0});var Nx=U(),jx={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,Nx.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};Jc.default=jx});var Pg=E(Bc=>{"use strict";Object.defineProperty(Bc,"__esModule",{value:!0});var Lx=Ic(),Ux=ng(),qx=Oc(),Zx=sg(),Fx=ig(),Hx=ug(),Wx=dg(),Vx=Lc(),Kx=mg(),Jx=yg(),Bx=Sg(),Yx=vg(),Gx=bg(),Xx=Eg(),Qx=xg(),e$=$g();function t$(t=!1){let e=[Bx.default,Yx.default,Gx.default,Xx.default,Qx.default,e$.default,Wx.default,Vx.default,Hx.default,Kx.default,Jx.default];return t?e.push(Ux.default,Zx.default):e.push(Lx.default,qx.default),e.push(Fx.default),e}Bc.default=t$});var Tg=E(Yc=>{"use strict";Object.defineProperty(Yc,"__esModule",{value:!0});var ae=A(),r$={message:({schemaCode:t})=>(0,ae.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,ae._)`{format: ${t}}`},n$={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:r$,code(t,e){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?p():f();function p(){let m=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),g=r.const("fDef",(0,ae._)`${m}[${i}]`),S=r.let("fType"),v=r.let("format");r.if((0,ae._)`typeof ${g} == "object" && !(${g} instanceof RegExp)`,()=>r.assign(S,(0,ae._)`${g}.type || "string"`).assign(v,(0,ae._)`${g}.validate`),()=>r.assign(S,(0,ae._)`"string"`).assign(v,g)),t.fail$data((0,ae.or)(x(),b()));function x(){return c.strictSchema===!1?ae.nil:(0,ae._)`${i} && !${v}`}function b(){let $=l.$async?(0,ae._)`(${g}.async ? await ${v}(${n}) : ${v}(${n}))`:(0,ae._)`${v}(${n})`,k=(0,ae._)`(typeof ${v} == "function" ? ${$} : ${v}.test(${n}))`;return(0,ae._)`${v} && ${v} !== true && ${S} === ${e} && !${k}`}}function f(){let m=d.formats[s];if(!m){x();return}if(m===!0)return;let[g,S,v]=b(m);g===e&&t.pass($());function x(){if(c.strictSchema===!1){d.logger.warn(k());return}throw new Error(k());function k(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function b(k){let Se=k instanceof RegExp?(0,ae.regexpCode)(k):c.code.formats?(0,ae._)`${c.code.formats}${(0,ae.getProperty)(s)}`:void 0,K=r.scopeValue("formats",{key:s,ref:k,code:Se});return typeof k=="object"&&!(k instanceof RegExp)?[k.type||"string",k.validate,(0,ae._)`${K}.validate`]:["string",k,K]}function $(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!l.$async)throw new Error("async format in sync schema");return(0,ae._)`await ${v}(${n})`}return typeof S=="function"?(0,ae._)`${v}(${n})`:(0,ae._)`${v}.test(${n})`}}}};Yc.default=n$});var zg=E(Gc=>{"use strict";Object.defineProperty(Gc,"__esModule",{value:!0});var o$=Tg(),s$=[o$.default];Gc.default=s$});var Rg=E(Or=>{"use strict";Object.defineProperty(Or,"__esModule",{value:!0});Or.contentVocabulary=Or.metadataVocabulary=void 0;Or.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Or.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Og=E(Xc=>{"use strict";Object.defineProperty(Xc,"__esModule",{value:!0});var i$=Lh(),a$=Qh(),c$=Pg(),u$=zg(),Ig=Rg(),l$=[i$.default,a$.default,(0,c$.default)(),u$.default,Ig.metadataVocabulary,Ig.contentVocabulary];Xc.default=l$});var Cg=E(ws=>{"use strict";Object.defineProperty(ws,"__esModule",{value:!0});ws.DiscrError=void 0;var Ag;(function(t){t.Tag="tag",t.Mapping="mapping"})(Ag||(ws.DiscrError=Ag={}))});var Dg=E(eu=>{"use strict";Object.defineProperty(eu,"__esModule",{value:!0});var Ar=A(),Qc=Cg(),Mg=is(),d$=In(),p$=U(),f$={message:({params:{discrError:t,tagName:e}})=>t===Qc.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,Ar._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},m$={keyword:"discriminator",type:"object",schemaType:"object",error:f$,code(t){let{gen:e,data:r,schema:n,parentSchema:o,it:s}=t,{oneOf:i}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),u=e.const("tag",(0,Ar._)`${r}${(0,Ar.getProperty)(a)}`);e.if((0,Ar._)`typeof ${u} == "string"`,()=>l(),()=>t.error(!1,{discrError:Qc.DiscrError.Tag,tag:u,tagName:a})),t.ok(c);function l(){let f=p();e.if(!1);for(let m in f)e.elseIf((0,Ar._)`${u} === ${m}`),e.assign(c,d(f[m]));e.else(),t.error(!1,{discrError:Qc.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function d(f){let m=e.name("valid"),g=t.subschema({keyword:"oneOf",schemaProp:f},m);return t.mergeEvaluated(g,Ar.Name),m}function p(){var f;let m={},g=v(o),S=!0;for(let $=0;$<i.length;$++){let k=i[$];if(k?.$ref&&!(0,p$.schemaHasRulesButRef)(k,s.self.RULES)){let K=k.$ref;if(k=Mg.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,K),k instanceof Mg.SchemaEnv&&(k=k.schema),k===void 0)throw new d$.default(s.opts.uriResolver,s.baseId,K)}let Se=(f=k?.properties)===null||f===void 0?void 0:f[a];if(typeof Se!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);S=S&&(g||v(k)),x(Se,$)}if(!S)throw new Error(`discriminator: "${a}" must be required`);return m;function v({required:$}){return Array.isArray($)&&$.includes(a)}function x($,k){if($.const)b($.const,k);else if($.enum)for(let Se of $.enum)b(Se,k);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function b($,k){if(typeof $!="string"||$ in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[$]=k}}}};eu.default=m$});var Ng=E((BM,h$)=>{h$.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 ru=E((te,tu)=>{"use strict";Object.defineProperty(te,"__esModule",{value:!0});te.MissingRefError=te.ValidationError=te.CodeGen=te.Name=te.nil=te.stringify=te.str=te._=te.KeywordCxt=te.Ajv=void 0;var g$=Ah(),_$=Og(),y$=Dg(),jg=Ng(),S$=["/properties"],ks="http://json-schema.org/draft-07/schema",Cr=class extends g$.default{_addVocabularies(){super._addVocabularies(),_$.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(y$.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(jg,S$):jg;this.addMetaSchema(e,ks,!1),this.refs["http://json-schema.org/schema"]=ks}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(ks)?ks:void 0)}};te.Ajv=Cr;tu.exports=te=Cr;tu.exports.Ajv=Cr;Object.defineProperty(te,"__esModule",{value:!0});te.default=Cr;var v$=Rn();Object.defineProperty(te,"KeywordCxt",{enumerable:!0,get:function(){return v$.KeywordCxt}});var Mr=A();Object.defineProperty(te,"_",{enumerable:!0,get:function(){return Mr._}});Object.defineProperty(te,"str",{enumerable:!0,get:function(){return Mr.str}});Object.defineProperty(te,"stringify",{enumerable:!0,get:function(){return Mr.stringify}});Object.defineProperty(te,"nil",{enumerable:!0,get:function(){return Mr.nil}});Object.defineProperty(te,"Name",{enumerable:!0,get:function(){return Mr.Name}});Object.defineProperty(te,"CodeGen",{enumerable:!0,get:function(){return Mr.CodeGen}});var b$=os();Object.defineProperty(te,"ValidationError",{enumerable:!0,get:function(){return b$.default}});var E$=In();Object.defineProperty(te,"MissingRefError",{enumerable:!0,get:function(){return E$.default}})});var Vg=E(mt=>{"use strict";Object.defineProperty(mt,"__esModule",{value:!0});mt.formatNames=mt.fastFormats=mt.fullFormats=void 0;function ft(t,e){return{validate:t,compare:e}}mt.fullFormats={date:ft(Zg,iu),time:ft(ou(!0),au),"date-time":ft(Lg(!0),Hg),"iso-time":ft(ou(),Fg),"iso-date-time":ft(Lg(),Wg),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:T$,"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:M$,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:z$,int32:{type:"number",validate:O$},int64:{type:"number",validate:A$},float:{type:"number",validate:qg},double:{type:"number",validate:qg},password:!0,binary:!0};mt.fastFormats={...mt.fullFormats,date:ft(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,iu),time:ft(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,au),"date-time":ft(/^\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,Hg),"iso-time":ft(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,Fg),"iso-date-time":ft(/^\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,Wg),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};mt.formatNames=Object.keys(mt.fullFormats);function w$(t){return t%4===0&&(t%100!==0||t%400===0)}var k$=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,x$=[0,31,28,31,30,31,30,31,31,30,31,30,31];function Zg(t){let e=k$.exec(t);if(!e)return!1;let r=+e[1],n=+e[2],o=+e[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&w$(r)?29:x$[n])}function iu(t,e){if(t&&e)return t>e?1:t<e?-1:0}var nu=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function ou(t){return function(r){let n=nu.exec(r);if(!n)return!1;let o=+n[1],s=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||t&&!a)return!1;if(o<=23&&s<=59&&i<60)return!0;let d=s-l*c,p=o-u*c-(d<0?1:0);return(p===23||p===-1)&&(d===59||d===-1)&&i<61}}function au(t,e){if(!(t&&e))return;let r=new Date("2020-01-01T"+t).valueOf(),n=new Date("2020-01-01T"+e).valueOf();if(r&&n)return r-n}function Fg(t,e){if(!(t&&e))return;let r=nu.exec(t),n=nu.exec(e);if(r&&n)return t=r[1]+r[2]+r[3],e=n[1]+n[2]+n[3],t>e?1:t<e?-1:0}var su=/t|\s/i;function Lg(t){let e=ou(t);return function(n){let o=n.split(su);return o.length===2&&Zg(o[0])&&e(o[1])}}function Hg(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),n=new Date(e).valueOf();if(r&&n)return r-n}function Wg(t,e){if(!(t&&e))return;let[r,n]=t.split(su),[o,s]=e.split(su),i=iu(r,o);if(i!==void 0)return i||au(n,s)}var $$=/\/|:/,P$=/^(?:[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 T$(t){return $$.test(t)&&P$.test(t)}var Ug=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function z$(t){return Ug.lastIndex=0,Ug.test(t)}var R$=-(2**31),I$=2**31-1;function O$(t){return Number.isInteger(t)&&t<=I$&&t>=R$}function A$(t){return Number.isInteger(t)}function qg(){return!0}var C$=/[^\\]\\Z/;function M$(t){if(C$.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var Kg=E(Dr=>{"use strict";Object.defineProperty(Dr,"__esModule",{value:!0});Dr.formatLimitDefinition=void 0;var D$=ru(),nt=A(),Ft=nt.operators,xs={formatMaximum:{okStr:"<=",ok:Ft.LTE,fail:Ft.GT},formatMinimum:{okStr:">=",ok:Ft.GTE,fail:Ft.LT},formatExclusiveMaximum:{okStr:"<",ok:Ft.LT,fail:Ft.GTE},formatExclusiveMinimum:{okStr:">",ok:Ft.GT,fail:Ft.LTE}},N$={message:({keyword:t,schemaCode:e})=>(0,nt.str)`should be ${xs[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,nt._)`{comparison: ${xs[t].okStr}, limit: ${e}}`};Dr.formatLimitDefinition={keyword:Object.keys(xs),type:"string",schemaType:"string",$data:!0,error:N$,code(t){let{gen:e,data:r,schemaCode:n,keyword:o,it:s}=t,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new D$.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let p=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),f=e.const("fmt",(0,nt._)`${p}[${c.schemaCode}]`);t.fail$data((0,nt.or)((0,nt._)`typeof ${f} != "object"`,(0,nt._)`${f} instanceof RegExp`,(0,nt._)`typeof ${f}.compare != "function"`,d(f)))}function l(){let p=c.schema,f=a.formats[p];if(!f||f===!0)return;if(typeof f!="object"||f instanceof RegExp||typeof f.compare!="function")throw new Error(`"${o}": format "${p}" does not define "compare" function`);let m=e.scopeValue("formats",{key:p,ref:f,code:i.code.formats?(0,nt._)`${i.code.formats}${(0,nt.getProperty)(p)}`:void 0});t.fail$data(d(m))}function d(p){return(0,nt._)`${p}.compare(${r}, ${n}) ${xs[o].fail} 0`}},dependencies:["format"]};var j$=t=>(t.addKeyword(Dr.formatLimitDefinition),t);Dr.default=j$});var Gg=E((Wn,Yg)=>{"use strict";Object.defineProperty(Wn,"__esModule",{value:!0});var Nr=Vg(),L$=Kg(),cu=A(),Jg=new cu.Name("fullFormats"),U$=new cu.Name("fastFormats"),uu=(t,e={keywords:!0})=>{if(Array.isArray(e))return Bg(t,e,Nr.fullFormats,Jg),t;let[r,n]=e.mode==="fast"?[Nr.fastFormats,U$]:[Nr.fullFormats,Jg],o=e.formats||Nr.formatNames;return Bg(t,o,r,n),e.keywords&&(0,L$.default)(t),t};uu.get=(t,e="full")=>{let n=(e==="fast"?Nr.fastFormats:Nr.fullFormats)[t];if(!n)throw new Error(`Unknown format "${t}"`);return n};function Bg(t,e,r,n){var o,s;(o=(s=t.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,cu._)`require("ajv-formats/dist/formats").${n}`);for(let i of e)t.addFormat(i,r[i])}Yg.exports=Wn=uu;Object.defineProperty(Wn,"__esModule",{value:!0});Wn.default=uu});ue();var Vu;function _(t,e,r){function n(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,c);let u=i.prototype,l=Object.keys(u);for(let d=0;d<l.length;d++){let p=l[d];p in a||(a[p]=u[p].bind(a))}}let o=r?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:t});function i(a){var c;let u=r?.Parent?new s:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(i,"name",{value:t}),i}var ut=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},ur=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(Vu=globalThis).__zod_globalConfig??(Vu.__zod_globalConfig={});var lr=globalThis.__zod_globalConfig;function Ce(t){return t&&Object.assign(lr,t),lr}var L={};Zu(L,{BIGINT_FORMAT_RANGES:()=>Yu,Class:()=>ai,NUMBER_FORMAT_RANGES:()=>fi,aborted:()=>It,allowsEval:()=>li,assert:()=>wy,assertEqual:()=>Sy,assertIs:()=>by,assertNever:()=>Ey,assertNotEqual:()=>vy,assignProp:()=>zt,base64ToUint8Array:()=>Xu,base64urlToUint8Array:()=>Uy,cached:()=>pr,captureStackTrace:()=>po,cleanEnum:()=>Ly,cleanRegex:()=>Vr,clone:()=>Xe,cloneDef:()=>xy,createTransparentProxy:()=>Iy,defineLazy:()=>H,esc:()=>lo,escapeRegex:()=>vt,explicitlyAborted:()=>mi,extend:()=>Cy,finalizeIssue:()=>Le,floatSafeRemainder:()=>ci,getElementAtPath:()=>$y,getEnumValues:()=>Hr,getLengthableOrigin:()=>Kr,getParsedType:()=>Ry,getSizableOrigin:()=>Gu,hexToUint8Array:()=>Zy,isObject:()=>Vt,isPlainObject:()=>Rt,issue:()=>fr,joinValues:()=>uo,jsonStringifyReplacer:()=>dr,merge:()=>Dy,mergeDefs:()=>St,normalizeParams:()=>z,nullish:()=>Wr,numKeys:()=>zy,objectClone:()=>ky,omit:()=>Ay,optionalKeys:()=>pi,parsedType:()=>hi,partial:()=>Ny,pick:()=>Oy,prefixIssues:()=>bt,primitiveTypes:()=>Bu,promiseAllObject:()=>Py,propertyKeyTypes:()=>di,randomString:()=>Ty,required:()=>jy,safeExtend:()=>My,shallowClone:()=>Ju,slugify:()=>ui,stringifyPrimitive:()=>fo,uint8ArrayToBase64:()=>Qu,uint8ArrayToBase64url:()=>qy,uint8ArrayToHex:()=>Fy,unwrapMessage:()=>Fr});function Sy(t){return t}function vy(t){return t}function by(t){}function Ey(t){throw new Error("Unexpected value in exhaustive check")}function wy(t){}function Hr(t){let e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,o])=>e.indexOf(+n)===-1).map(([n,o])=>o)}function uo(t,e="|"){return t.map(r=>fo(r)).join(e)}function dr(t,e){return typeof e=="bigint"?e.toString():e}function pr(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Wr(t){return t==null}function Vr(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function ci(t,e){let r=t/e,n=Math.round(r),o=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}var Ku=Symbol("evaluating");function H(t,e,r){let n;Object.defineProperty(t,e,{get(){if(n!==Ku)return n===void 0&&(n=Ku,n=r()),n},set(o){Object.defineProperty(t,e,{value:o})},configurable:!0})}function ky(t){return Object.create(Object.getPrototypeOf(t),Object.getOwnPropertyDescriptors(t))}function zt(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function St(...t){let e={};for(let r of t){let n=Object.getOwnPropertyDescriptors(r);Object.assign(e,n)}return Object.defineProperties({},e)}function xy(t){return St(t._zod.def)}function $y(t,e){return e?e.reduce((r,n)=>r?.[n],t):t}function Py(t){let e=Object.keys(t),r=e.map(n=>t[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<e.length;s++)o[e[s]]=n[s];return o})}function Ty(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<t;n++)r+=e[Math.floor(Math.random()*e.length)];return r}function lo(t){return JSON.stringify(t)}function ui(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var po="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function Vt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var li=pr(()=>{if(lr.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function Rt(t){if(Vt(t)===!1)return!1;let e=t.constructor;if(e===void 0||typeof e!="function")return!0;let r=e.prototype;return!(Vt(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Ju(t){return Rt(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}function zy(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}var Ry=t=>{let e=typeof t;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},di=new Set(["string","number","symbol"]),Bu=new Set(["string","number","bigint","boolean","symbol","undefined"]);function vt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Xe(t,e,r){let n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function z(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function Iy(t){let e;return new Proxy({},{get(r,n,o){return e??(e=t()),Reflect.get(e,n,o)},set(r,n,o,s){return e??(e=t()),Reflect.set(e,n,o,s)},has(r,n){return e??(e=t()),Reflect.has(e,n)},deleteProperty(r,n){return e??(e=t()),Reflect.deleteProperty(e,n)},ownKeys(r){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(r,n){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,n)},defineProperty(r,n,o){return e??(e=t()),Reflect.defineProperty(e,n,o)}})}function fo(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function pi(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}var fi={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]},Yu={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Oy(t,e){let r=t._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s=St(t._zod.def,{get shape(){let i={};for(let a in e){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(i[a]=r.shape[a])}return zt(this,"shape",i),i},checks:[]});return Xe(t,s)}function Ay(t,e){let r=t._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=St(t._zod.def,{get shape(){let i={...t._zod.def.shape};for(let a in e){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete i[a]}return zt(this,"shape",i),i},checks:[]});return Xe(t,s)}function Cy(t,e){if(!Rt(e))throw new Error("Invalid input to extend: expected a plain object");let r=t._zod.def.checks;if(r&&r.length>0){let s=t._zod.def.shape;for(let i in e)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=St(t._zod.def,{get shape(){let s={...t._zod.def.shape,...e};return zt(this,"shape",s),s}});return Xe(t,o)}function My(t,e){if(!Rt(e))throw new Error("Invalid input to safeExtend: expected a plain object");let r=St(t._zod.def,{get shape(){let n={...t._zod.def.shape,...e};return zt(this,"shape",n),n}});return Xe(t,r)}function Dy(t,e){if(t._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=St(t._zod.def,{get shape(){let n={...t._zod.def.shape,...e._zod.def.shape};return zt(this,"shape",n),n},get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return Xe(t,r)}function Ny(t,e,r){let o=e._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let i=St(e._zod.def,{get shape(){let a=e._zod.def.shape,c={...a};if(r)for(let u in r){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(c[u]=t?new t({type:"optional",innerType:a[u]}):a[u])}else for(let u in a)c[u]=t?new t({type:"optional",innerType:a[u]}):a[u];return zt(this,"shape",c),c},checks:[]});return Xe(e,i)}function jy(t,e,r){let n=St(e._zod.def,{get shape(){let o=e._zod.def.shape,s={...o};if(r)for(let i in r){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);r[i]&&(s[i]=new t({type:"nonoptional",innerType:o[i]}))}else for(let i in o)s[i]=new t({type:"nonoptional",innerType:o[i]});return zt(this,"shape",s),s}});return Xe(e,n)}function It(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function mi(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue===!1)return!0;return!1}function bt(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function Fr(t){return typeof t=="string"?t:t?.message}function Le(t,e,r){let n=t.message?t.message:Fr(t.inst?._zod.def?.error?.(t))??Fr(e?.error?.(t))??Fr(r.customError?.(t))??Fr(r.localeError?.(t))??"Invalid input",{inst:o,continue:s,input:i,...a}=t;return a.path??(a.path=[]),a.message=n,e?.reportInput&&(a.input=i),a}function Gu(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function Kr(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function hi(t){let e=typeof t;switch(e){case"number":return Number.isNaN(t)?"nan":"number";case"object":{if(t===null)return"null";if(Array.isArray(t))return"array";let r=t;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return e}function fr(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}function Ly(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function Xu(t){let e=atob(t),r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}function Qu(t){let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return btoa(e)}function Uy(t){let e=t.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-e.length%4)%4);return Xu(e+r)}function qy(t){return Qu(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Zy(t){let e=t.replace(/^0x/,"");if(e.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)r[n/2]=Number.parseInt(e.slice(n,n+2),16);return r}function Fy(t){return Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}var ai=class{constructor(...e){}};var el=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,dr,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},mo=_("$ZodError",el),gi=_("$ZodError",el,{Parent:Error});function tl(t,e=r=>r.message){let r={},n=[];for(let o of t.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(e(o))):n.push(e(o));return{formErrors:n,fieldErrors:r}}function rl(t,e=r=>r.message){let r={_errors:[]},n=(o,s=[])=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>n({issues:a},[...s,...i.path]));else if(i.code==="invalid_key")n({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")n({issues:i.issues},[...s,...i.path]);else{let a=[...s,...i.path];if(a.length===0)r._errors.push(e(i));else{let c=r,u=0;for(;u<a.length;){let l=a[u];u===a.length-1?(c[l]=c[l]||{_errors:[]},c[l]._errors.push(e(i))):c[l]=c[l]||{_errors:[]},c=c[l],u++}}}};return n(t),r}var ho=t=>(e,r,n,o)=>{let s=n?{...n,async:!1}:{async:!1},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new ut;if(i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>Le(c,s,Ce())));throw po(a,o?.callee),a}return i.value};var go=t=>async(e,r,n,o)=>{let s=n?{...n,async:!0}:{async:!0},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>Le(c,s,Ce())));throw po(a,o?.callee),a}return i.value};var Jr=t=>(e,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=e._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new ut;return s.issues.length?{success:!1,error:new(t??mo)(s.issues.map(i=>Le(i,o,Ce())))}:{success:!0,data:s.value}},Br=Jr(gi),Yr=t=>async(e,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=e._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new t(s.issues.map(i=>Le(i,o,Ce())))}:{success:!0,data:s.value}},_o=Yr(gi),nl=t=>(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return ho(t)(e,r,o)};var ol=t=>(e,r,n)=>ho(t)(e,r,n);var sl=t=>async(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return go(t)(e,r,o)};var il=t=>async(e,r,n)=>go(t)(e,r,n);var al=t=>(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Jr(t)(e,r,o)};var cl=t=>(e,r,n)=>Jr(t)(e,r,n);var ul=t=>async(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Yr(t)(e,r,o)};var ll=t=>async(e,r,n)=>Yr(t)(e,r,n);var dl=/^[cC][0-9a-z]{6,}$/,pl=/^[0-9a-z]+$/,fl=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ml=/^[0-9a-vA-V]{20}$/,hl=/^[A-Za-z0-9]{27}$/,gl=/^[a-zA-Z0-9_-]{21}$/,_l=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var yl=/^([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})$/,_i=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;var Sl=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Wy="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function vl(){return new RegExp(Wy,"u")}var bl=/^(?:(?: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])$/,El=/^(([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 wl=/^((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])$/,kl=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,xl=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,yi=/^[A-Za-z0-9_-]*$/;var $l=/^https?$/,Pl=/^\+[1-9]\d{6,14}$/,Tl="(?:(?:\\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])))",zl=new RegExp(`^${Tl}$`);function Rl(t){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Il(t){return new RegExp(`^${Rl(t)}$`)}function Ol(t){let e=Rl({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${e}(?:${r.join("|")})`;return new RegExp(`^${Tl}T(?:${n})$`)}var Al=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)};var Cl=/^-?\d+$/,Si=/^-?\d+(?:\.\d+)?$/,Ml=/^(?:true|false)$/i,Dl=/^null$/i;var Nl=/^[^A-Z]*$/,jl=/^[^a-z]*$/;var fe=_("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),Ll={number:"number",bigint:"bigint",object:"date"},vi=_("$ZodCheckLessThan",(t,e)=>{fe.init(t,e);let r=Ll[typeof e.value];t._zod.onattach.push(n=>{let o=n._zod.bag,s=(e.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?o.maximum=e.value:o.exclusiveMaximum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),bi=_("$ZodCheckGreaterThan",(t,e)=>{fe.init(t,e);let r=Ll[typeof e.value];t._zod.onattach.push(n=>{let o=n._zod.bag,s=(e.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?o.minimum=e.value:o.exclusiveMinimum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Ul=_("$ZodCheckMultipleOf",(t,e)=>{fe.init(t,e),t._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=e.value)}),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):ci(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),ql=_("$ZodCheckNumberFormat",(t,e)=>{fe.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[o,s]=fi[e.format];t._zod.onattach.push(i=>{let a=i._zod.bag;a.format=e.format,a.minimum=o,a.maximum=s,r&&(a.pattern=Cl)}),t._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:e.format,code:"invalid_type",continue:!1,input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,inclusive:!0,continue:!e.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,inclusive:!0,continue:!e.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:t,continue:!e.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:t,continue:!e.abort})}});var Zl=_("$ZodCheckMaxLength",(t,e)=>{var r;fe.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!Wr(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<o&&(n._zod.bag.maximum=e.maximum)}),t._zod.check=n=>{let o=n.value;if(o.length<=e.maximum)return;let i=Kr(o);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),Fl=_("$ZodCheckMinLength",(t,e)=>{var r;fe.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!Wr(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>o&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{let o=n.value;if(o.length>=e.minimum)return;let i=Kr(o);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),Hl=_("$ZodCheckLengthEquals",(t,e)=>{var r;fe.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!Wr(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=e.length,o.maximum=e.length,o.length=e.length}),t._zod.check=n=>{let o=n.value,s=o.length;if(s===e.length)return;let i=Kr(o),a=s>e.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),Gr=_("$ZodCheckStringFormat",(t,e)=>{var r,n;fe.init(t,e),t._zod.onattach.push(o=>{let s=o._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=o=>{e.pattern.lastIndex=0,!e.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:e.format,input:o.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),Wl=_("$ZodCheckRegex",(t,e)=>{Gr.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),Vl=_("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=Nl),Gr.init(t,e)}),Kl=_("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=jl),Gr.init(t,e)}),Jl=_("$ZodCheckIncludes",(t,e)=>{fe.init(t,e);let r=vt(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(o=>{let s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),t._zod.check=o=>{o.value.includes(e.includes,e.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:o.value,inst:t,continue:!e.abort})}}),Bl=_("$ZodCheckStartsWith",(t,e)=>{fe.init(t,e);let r=new RegExp(`^${vt(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),t._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:t,continue:!e.abort})}}),Yl=_("$ZodCheckEndsWith",(t,e)=>{fe.init(t,e);let r=new RegExp(`.*${vt(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),t._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:t,continue:!e.abort})}});var Gl=_("$ZodCheckOverwrite",(t,e)=>{fe.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});var So=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
|
|
20
|
+
deps: ${r}}`};var Sx={keyword:"dependencies",type:"object",schemaType:"object",error:ft.error,code(t){let[e,r]=vx(t);ug(t,e),lg(t,r)}};function vx({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let o=Array.isArray(t[n])?e:r;o[n]=t[n]}return[e,r]}function ug(t,e=t.schema){let{gen:r,data:n,it:o}=t;if(Object.keys(e).length===0)return;let s=r.let("missing");for(let i in e){let a=e[i];if(a.length===0)continue;let c=(0,Kn.propertyInData)(r,n,i,o.opts.ownProperties);t.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,Kn.checkReportMissingProp)(t,u)}):(r.if((0,jc._)`${c} && (${(0,Kn.checkMissingProp)(t,a,s)})`),(0,Kn.reportMissingProp)(t,s),r.else())}}ft.validatePropertyDeps=ug;function lg(t,e=t.schema){let{gen:r,data:n,keyword:o,it:s}=t,i=r.name("valid");for(let a in e)(0,yx.alwaysValidSchema)(s,e[a])||(r.if((0,Kn.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=t.subschema({keyword:o,schemaProp:a},i);t.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),t.ok(i))}ft.validateSchemaDeps=lg;ft.default=Sx});var fg=E(Lc=>{"use strict";Object.defineProperty(Lc,"__esModule",{value:!0});var pg=A(),bx=U(),Ex={message:"property name must be valid",params:({params:t})=>(0,pg._)`{propertyName: ${t.propertyName}}`},wx={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Ex,code(t){let{gen:e,schema:r,data:n,it:o}=t;if((0,bx.alwaysValidSchema)(o,r))return;let s=e.name("valid");e.forIn("key",n,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),e.if((0,pg.not)(s),()=>{t.error(!0),o.allErrors||e.break()})}),t.ok(s)}};Lc.default=wx});var qc=E(Uc=>{"use strict";Object.defineProperty(Uc,"__esModule",{value:!0});var Ss=Fe(),nt=A(),kx=xt(),vs=U(),xx={message:"must NOT have additional properties",params:({params:t})=>(0,nt._)`{additionalProperty: ${t.additionalProperty}}`},$x={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:xx,code(t){let{gen:e,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=t;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,vs.alwaysValidSchema)(i,r))return;let u=(0,Ss.allSchemaProperties)(n.properties),l=(0,Ss.allSchemaProperties)(n.patternProperties);d(),t.ok((0,nt._)`${s} === ${kx.default.errors}`);function d(){e.forIn("key",o,S=>{!u.length&&!l.length?m(S):e.if(p(S),()=>m(S))})}function p(S){let v;if(u.length>8){let x=(0,vs.schemaRefOrVal)(i,n.properties,"properties");v=(0,Ss.isOwnProperty)(e,x,S)}else u.length?v=(0,nt.or)(...u.map(x=>(0,nt._)`${S} === ${x}`)):v=nt.nil;return l.length&&(v=(0,nt.or)(v,...l.map(x=>(0,nt._)`${(0,Ss.usePattern)(t,x)}.test(${S})`))),(0,nt.not)(v)}function f(S){e.code((0,nt._)`delete ${o}[${S}]`)}function m(S){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){f(S);return}if(r===!1){t.setParams({additionalProperty:S}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,vs.alwaysValidSchema)(i,r)){let v=e.name("valid");c.removeAdditional==="failing"?(g(S,v,!1),e.if((0,nt.not)(v),()=>{t.reset(),f(S)})):(g(S,v),a||e.if((0,nt.not)(v),()=>e.break()))}}function g(S,v,x){let b={keyword:"additionalProperties",dataProp:S,dataPropType:vs.Type.Str};x===!1&&Object.assign(b,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(b,v)}}};Uc.default=$x});var gg=E(Fc=>{"use strict";Object.defineProperty(Fc,"__esModule",{value:!0});var Px=An(),mg=Fe(),Zc=U(),hg=qc(),Tx={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:o,it:s}=t;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&hg.default.code(new Px.KeywordCxt(s,hg.default,"additionalProperties"));let i=(0,mg.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=Zc.mergeEvaluated.props(e,(0,Zc.toHash)(i),s.props));let a=i.filter(d=>!(0,Zc.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)u(d)?l(d):(e.if((0,mg.propertyInData)(e,o,d,s.opts.ownProperties)),l(d),s.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};Fc.default=Tx});var vg=E(Hc=>{"use strict";Object.defineProperty(Hc,"__esModule",{value:!0});var _g=Fe(),bs=A(),yg=U(),Sg=U(),Rx={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:o,it:s}=t,{opts:i}=s,a=(0,_g.allSchemaProperties)(r),c=a.filter(g=>(0,yg.alwaysValidSchema)(s,r[g]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=e.name("valid");s.props!==!0&&!(s.props instanceof bs.Name)&&(s.props=(0,Sg.evaluatedPropsToName)(e,s.props));let{props:d}=s;p();function p(){for(let g of a)u&&f(g),s.allErrors?m(g):(e.var(l,!0),m(g),e.if(l))}function f(g){for(let S in u)new RegExp(g).test(S)&&(0,yg.checkStrictMode)(s,`property ${S} matches pattern ${g} (use allowMatchingProperties)`)}function m(g){e.forIn("key",n,S=>{e.if((0,bs._)`${(0,_g.usePattern)(t,g)}.test(${S})`,()=>{let v=c.includes(g);v||t.subschema({keyword:"patternProperties",schemaProp:g,dataProp:S,dataPropType:Sg.Type.Str},l),s.opts.unevaluated&&d!==!0?e.assign((0,bs._)`${d}[${S}]`,!0):!v&&!s.allErrors&&e.if((0,bs.not)(l),()=>e.break())})})}}};Hc.default=Rx});var bg=E(Wc=>{"use strict";Object.defineProperty(Wc,"__esModule",{value:!0});var zx=U(),Ix={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,zx.alwaysValidSchema)(n,r)){t.fail();return}let o=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),t.failResult(o,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};Wc.default=Ix});var Eg=E(Vc=>{"use strict";Object.defineProperty(Vc,"__esModule",{value:!0});var Ox=Fe(),Ax={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:Ox.validateUnion,error:{message:"must match a schema in anyOf"}};Vc.default=Ax});var wg=E(Kc=>{"use strict";Object.defineProperty(Kc,"__esModule",{value:!0});var Es=A(),Cx=U(),Mx={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,Es._)`{passingSchemas: ${t.passing}}`},Dx={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:Mx,code(t){let{gen:e,schema:r,parentSchema:n,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(u),t.result(i,()=>t.reset(),()=>t.error(!0));function u(){s.forEach((l,d)=>{let p;(0,Cx.alwaysValidSchema)(o,l)?e.var(c,!0):p=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,Es._)`${c} && ${i}`).assign(i,!1).assign(a,(0,Es._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,d),p&&t.mergeEvaluated(p,Es.Name)})})}}};Kc.default=Dx});var kg=E(Jc=>{"use strict";Object.defineProperty(Jc,"__esModule",{value:!0});var Nx=U(),jx={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=e.name("valid");r.forEach((s,i)=>{if((0,Nx.alwaysValidSchema)(n,s))return;let a=t.subschema({keyword:"allOf",schemaProp:i},o);t.ok(o),t.mergeEvaluated(a)})}};Jc.default=jx});var Pg=E(Bc=>{"use strict";Object.defineProperty(Bc,"__esModule",{value:!0});var ws=A(),$g=U(),Lx={message:({params:t})=>(0,ws.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,ws._)`{failingKeyword: ${t.ifClause}}`},Ux={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:Lx,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,$g.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=xg(n,"then"),s=xg(n,"else");if(!o&&!s)return;let i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),o&&s){let l=e.let("ifClause");t.setParams({ifClause:l}),e.if(a,u("then",l),u("else",l))}else o?e.if(a,u("then")):e.if((0,ws.not)(a),u("else"));t.pass(i,()=>t.error(!0));function c(){let l=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(l)}function u(l,d){return()=>{let p=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(p,i),d?e.assign(d,(0,ws._)`${l}`):t.setParams({ifClause:l})}}}};function xg(t,e){let r=t.schema[e];return r!==void 0&&!(0,$g.alwaysValidSchema)(t,r)}Bc.default=Ux});var Tg=E(Yc=>{"use strict";Object.defineProperty(Yc,"__esModule",{value:!0});var qx=U(),Zx={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,qx.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};Yc.default=Zx});var Rg=E(Gc=>{"use strict";Object.defineProperty(Gc,"__esModule",{value:!0});var Fx=Ac(),Hx=sg(),Wx=Cc(),Vx=ag(),Kx=cg(),Jx=dg(),Bx=fg(),Yx=qc(),Gx=gg(),Xx=vg(),Qx=bg(),e$=Eg(),t$=wg(),r$=kg(),n$=Pg(),o$=Tg();function s$(t=!1){let e=[Qx.default,e$.default,t$.default,r$.default,n$.default,o$.default,Bx.default,Yx.default,Jx.default,Gx.default,Xx.default];return t?e.push(Hx.default,Vx.default):e.push(Fx.default,Wx.default),e.push(Kx.default),e}Gc.default=s$});var zg=E(Xc=>{"use strict";Object.defineProperty(Xc,"__esModule",{value:!0});var ae=A(),i$={message:({schemaCode:t})=>(0,ae.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,ae._)`{format: ${t}}`},a$={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:i$,code(t,e){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?p():f();function p(){let m=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),g=r.const("fDef",(0,ae._)`${m}[${i}]`),S=r.let("fType"),v=r.let("format");r.if((0,ae._)`typeof ${g} == "object" && !(${g} instanceof RegExp)`,()=>r.assign(S,(0,ae._)`${g}.type || "string"`).assign(v,(0,ae._)`${g}.validate`),()=>r.assign(S,(0,ae._)`"string"`).assign(v,g)),t.fail$data((0,ae.or)(x(),b()));function x(){return c.strictSchema===!1?ae.nil:(0,ae._)`${i} && !${v}`}function b(){let $=l.$async?(0,ae._)`(${g}.async ? await ${v}(${n}) : ${v}(${n}))`:(0,ae._)`${v}(${n})`,k=(0,ae._)`(typeof ${v} == "function" ? ${$} : ${v}.test(${n}))`;return(0,ae._)`${v} && ${v} !== true && ${S} === ${e} && !${k}`}}function f(){let m=d.formats[s];if(!m){x();return}if(m===!0)return;let[g,S,v]=b(m);g===e&&t.pass($());function x(){if(c.strictSchema===!1){d.logger.warn(k());return}throw new Error(k());function k(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function b(k){let Se=k instanceof RegExp?(0,ae.regexpCode)(k):c.code.formats?(0,ae._)`${c.code.formats}${(0,ae.getProperty)(s)}`:void 0,K=r.scopeValue("formats",{key:s,ref:k,code:Se});return typeof k=="object"&&!(k instanceof RegExp)?[k.type||"string",k.validate,(0,ae._)`${K}.validate`]:["string",k,K]}function $(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!l.$async)throw new Error("async format in sync schema");return(0,ae._)`await ${v}(${n})`}return typeof S=="function"?(0,ae._)`${v}(${n})`:(0,ae._)`${v}.test(${n})`}}}};Xc.default=a$});var Ig=E(Qc=>{"use strict";Object.defineProperty(Qc,"__esModule",{value:!0});var c$=zg(),u$=[c$.default];Qc.default=u$});var Og=E(Ir=>{"use strict";Object.defineProperty(Ir,"__esModule",{value:!0});Ir.contentVocabulary=Ir.metadataVocabulary=void 0;Ir.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Ir.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Cg=E(eu=>{"use strict";Object.defineProperty(eu,"__esModule",{value:!0});var l$=qh(),d$=tg(),p$=Rg(),f$=Ig(),Ag=Og(),m$=[l$.default,d$.default,(0,p$.default)(),f$.default,Ag.metadataVocabulary,Ag.contentVocabulary];eu.default=m$});var Dg=E(ks=>{"use strict";Object.defineProperty(ks,"__esModule",{value:!0});ks.DiscrError=void 0;var Mg;(function(t){t.Tag="tag",t.Mapping="mapping"})(Mg||(ks.DiscrError=Mg={}))});var jg=E(ru=>{"use strict";Object.defineProperty(ru,"__esModule",{value:!0});var Or=A(),tu=Dg(),Ng=as(),h$=Cn(),g$=U(),_$={message:({params:{discrError:t,tagName:e}})=>t===tu.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,Or._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},y$={keyword:"discriminator",type:"object",schemaType:"object",error:_$,code(t){let{gen:e,data:r,schema:n,parentSchema:o,it:s}=t,{oneOf:i}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),u=e.const("tag",(0,Or._)`${r}${(0,Or.getProperty)(a)}`);e.if((0,Or._)`typeof ${u} == "string"`,()=>l(),()=>t.error(!1,{discrError:tu.DiscrError.Tag,tag:u,tagName:a})),t.ok(c);function l(){let f=p();e.if(!1);for(let m in f)e.elseIf((0,Or._)`${u} === ${m}`),e.assign(c,d(f[m]));e.else(),t.error(!1,{discrError:tu.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function d(f){let m=e.name("valid"),g=t.subschema({keyword:"oneOf",schemaProp:f},m);return t.mergeEvaluated(g,Or.Name),m}function p(){var f;let m={},g=v(o),S=!0;for(let $=0;$<i.length;$++){let k=i[$];if(k?.$ref&&!(0,g$.schemaHasRulesButRef)(k,s.self.RULES)){let K=k.$ref;if(k=Ng.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,K),k instanceof Ng.SchemaEnv&&(k=k.schema),k===void 0)throw new h$.default(s.opts.uriResolver,s.baseId,K)}let Se=(f=k?.properties)===null||f===void 0?void 0:f[a];if(typeof Se!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);S=S&&(g||v(k)),x(Se,$)}if(!S)throw new Error(`discriminator: "${a}" must be required`);return m;function v({required:$}){return Array.isArray($)&&$.includes(a)}function x($,k){if($.const)b($.const,k);else if($.enum)for(let Se of $.enum)b(Se,k);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function b($,k){if(typeof $!="string"||$ in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[$]=k}}}};ru.default=y$});var Lg=E((eD,S$)=>{S$.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 ou=E((te,nu)=>{"use strict";Object.defineProperty(te,"__esModule",{value:!0});te.MissingRefError=te.ValidationError=te.CodeGen=te.Name=te.nil=te.stringify=te.str=te._=te.KeywordCxt=te.Ajv=void 0;var v$=Mh(),b$=Cg(),E$=jg(),Ug=Lg(),w$=["/properties"],xs="http://json-schema.org/draft-07/schema",Ar=class extends v$.default{_addVocabularies(){super._addVocabularies(),b$.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(E$.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(Ug,w$):Ug;this.addMetaSchema(e,xs,!1),this.refs["http://json-schema.org/schema"]=xs}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(xs)?xs:void 0)}};te.Ajv=Ar;nu.exports=te=Ar;nu.exports.Ajv=Ar;Object.defineProperty(te,"__esModule",{value:!0});te.default=Ar;var k$=An();Object.defineProperty(te,"KeywordCxt",{enumerable:!0,get:function(){return k$.KeywordCxt}});var Cr=A();Object.defineProperty(te,"_",{enumerable:!0,get:function(){return Cr._}});Object.defineProperty(te,"str",{enumerable:!0,get:function(){return Cr.str}});Object.defineProperty(te,"stringify",{enumerable:!0,get:function(){return Cr.stringify}});Object.defineProperty(te,"nil",{enumerable:!0,get:function(){return Cr.nil}});Object.defineProperty(te,"Name",{enumerable:!0,get:function(){return Cr.Name}});Object.defineProperty(te,"CodeGen",{enumerable:!0,get:function(){return Cr.CodeGen}});var x$=ss();Object.defineProperty(te,"ValidationError",{enumerable:!0,get:function(){return x$.default}});var $$=Cn();Object.defineProperty(te,"MissingRefError",{enumerable:!0,get:function(){return $$.default}})});var Jg=E(ht=>{"use strict";Object.defineProperty(ht,"__esModule",{value:!0});ht.formatNames=ht.fastFormats=ht.fullFormats=void 0;function mt(t,e){return{validate:t,compare:e}}ht.fullFormats={date:mt(Hg,cu),time:mt(iu(!0),uu),"date-time":mt(qg(!0),Vg),"iso-time":mt(iu(),Wg),"iso-date-time":mt(qg(),Kg),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:O$,"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:L$,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:A$,int32:{type:"number",validate:D$},int64:{type:"number",validate:N$},float:{type:"number",validate:Fg},double:{type:"number",validate:Fg},password:!0,binary:!0};ht.fastFormats={...ht.fullFormats,date:mt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,cu),time:mt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,uu),"date-time":mt(/^\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,Vg),"iso-time":mt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,Wg),"iso-date-time":mt(/^\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,Kg),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};ht.formatNames=Object.keys(ht.fullFormats);function P$(t){return t%4===0&&(t%100!==0||t%400===0)}var T$=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,R$=[0,31,28,31,30,31,30,31,31,30,31,30,31];function Hg(t){let e=T$.exec(t);if(!e)return!1;let r=+e[1],n=+e[2],o=+e[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&P$(r)?29:R$[n])}function cu(t,e){if(t&&e)return t>e?1:t<e?-1:0}var su=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function iu(t){return function(r){let n=su.exec(r);if(!n)return!1;let o=+n[1],s=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||t&&!a)return!1;if(o<=23&&s<=59&&i<60)return!0;let d=s-l*c,p=o-u*c-(d<0?1:0);return(p===23||p===-1)&&(d===59||d===-1)&&i<61}}function uu(t,e){if(!(t&&e))return;let r=new Date("2020-01-01T"+t).valueOf(),n=new Date("2020-01-01T"+e).valueOf();if(r&&n)return r-n}function Wg(t,e){if(!(t&&e))return;let r=su.exec(t),n=su.exec(e);if(r&&n)return t=r[1]+r[2]+r[3],e=n[1]+n[2]+n[3],t>e?1:t<e?-1:0}var au=/t|\s/i;function qg(t){let e=iu(t);return function(n){let o=n.split(au);return o.length===2&&Hg(o[0])&&e(o[1])}}function Vg(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),n=new Date(e).valueOf();if(r&&n)return r-n}function Kg(t,e){if(!(t&&e))return;let[r,n]=t.split(au),[o,s]=e.split(au),i=cu(r,o);if(i!==void 0)return i||uu(n,s)}var z$=/\/|:/,I$=/^(?:[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 O$(t){return z$.test(t)&&I$.test(t)}var Zg=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function A$(t){return Zg.lastIndex=0,Zg.test(t)}var C$=-(2**31),M$=2**31-1;function D$(t){return Number.isInteger(t)&&t<=M$&&t>=C$}function N$(t){return Number.isInteger(t)}function Fg(){return!0}var j$=/[^\\]\\Z/;function L$(t){if(j$.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var Bg=E(Mr=>{"use strict";Object.defineProperty(Mr,"__esModule",{value:!0});Mr.formatLimitDefinition=void 0;var U$=ou(),ot=A(),Ft=ot.operators,$s={formatMaximum:{okStr:"<=",ok:Ft.LTE,fail:Ft.GT},formatMinimum:{okStr:">=",ok:Ft.GTE,fail:Ft.LT},formatExclusiveMaximum:{okStr:"<",ok:Ft.LT,fail:Ft.GTE},formatExclusiveMinimum:{okStr:">",ok:Ft.GT,fail:Ft.LTE}},q$={message:({keyword:t,schemaCode:e})=>(0,ot.str)`should be ${$s[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,ot._)`{comparison: ${$s[t].okStr}, limit: ${e}}`};Mr.formatLimitDefinition={keyword:Object.keys($s),type:"string",schemaType:"string",$data:!0,error:q$,code(t){let{gen:e,data:r,schemaCode:n,keyword:o,it:s}=t,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new U$.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let p=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),f=e.const("fmt",(0,ot._)`${p}[${c.schemaCode}]`);t.fail$data((0,ot.or)((0,ot._)`typeof ${f} != "object"`,(0,ot._)`${f} instanceof RegExp`,(0,ot._)`typeof ${f}.compare != "function"`,d(f)))}function l(){let p=c.schema,f=a.formats[p];if(!f||f===!0)return;if(typeof f!="object"||f instanceof RegExp||typeof f.compare!="function")throw new Error(`"${o}": format "${p}" does not define "compare" function`);let m=e.scopeValue("formats",{key:p,ref:f,code:i.code.formats?(0,ot._)`${i.code.formats}${(0,ot.getProperty)(p)}`:void 0});t.fail$data(d(m))}function d(p){return(0,ot._)`${p}.compare(${r}, ${n}) ${$s[o].fail} 0`}},dependencies:["format"]};var Z$=t=>(t.addKeyword(Mr.formatLimitDefinition),t);Mr.default=Z$});var Qg=E((Jn,Xg)=>{"use strict";Object.defineProperty(Jn,"__esModule",{value:!0});var Dr=Jg(),F$=Bg(),lu=A(),Yg=new lu.Name("fullFormats"),H$=new lu.Name("fastFormats"),du=(t,e={keywords:!0})=>{if(Array.isArray(e))return Gg(t,e,Dr.fullFormats,Yg),t;let[r,n]=e.mode==="fast"?[Dr.fastFormats,H$]:[Dr.fullFormats,Yg],o=e.formats||Dr.formatNames;return Gg(t,o,r,n),e.keywords&&(0,F$.default)(t),t};du.get=(t,e="full")=>{let n=(e==="fast"?Dr.fastFormats:Dr.fullFormats)[t];if(!n)throw new Error(`Unknown format "${t}"`);return n};function Gg(t,e,r,n){var o,s;(o=(s=t.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,lu._)`require("ajv-formats/dist/formats").${n}`);for(let i of e)t.addFormat(i,r[i])}Xg.exports=Jn=du;Object.defineProperty(Jn,"__esModule",{value:!0});Jn.default=du});ce();var Ju;function _(t,e,r){function n(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,c);let u=i.prototype,l=Object.keys(u);for(let d=0;d<l.length;d++){let p=l[d];p in a||(a[p]=u[p].bind(a))}}let o=r?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:t});function i(a){var c;let u=r?.Parent?new s:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(i,"name",{value:t}),i}var lt=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},cr=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(Ju=globalThis).__zod_globalConfig??(Ju.__zod_globalConfig={});var ur=globalThis.__zod_globalConfig;function Ce(t){return t&&Object.assign(ur,t),ur}var L={};Fu(L,{BIGINT_FORMAT_RANGES:()=>Xu,Class:()=>ui,NUMBER_FORMAT_RANGES:()=>hi,aborted:()=>It,allowsEval:()=>pi,assert:()=>Py,assertEqual:()=>wy,assertIs:()=>xy,assertNever:()=>$y,assertNotEqual:()=>ky,assignProp:()=>Rt,base64ToUint8Array:()=>el,base64urlToUint8Array:()=>Hy,cached:()=>dr,captureStackTrace:()=>fo,cleanEnum:()=>Fy,cleanRegex:()=>Br,clone:()=>Qe,cloneDef:()=>Ry,createTransparentProxy:()=>My,defineLazy:()=>H,esc:()=>po,escapeRegex:()=>vt,explicitlyAborted:()=>gi,extend:()=>jy,finalizeIssue:()=>Le,floatSafeRemainder:()=>li,getElementAtPath:()=>zy,getEnumValues:()=>Kr,getLengthableOrigin:()=>Yr,getParsedType:()=>Cy,getSizableOrigin:()=>Qu,hexToUint8Array:()=>Vy,isObject:()=>Vt,isPlainObject:()=>zt,issue:()=>pr,joinValues:()=>lo,jsonStringifyReplacer:()=>lr,merge:()=>Uy,mergeDefs:()=>St,normalizeParams:()=>R,nullish:()=>Jr,numKeys:()=>Ay,objectClone:()=>Ty,omit:()=>Ny,optionalKeys:()=>mi,parsedType:()=>_i,partial:()=>qy,pick:()=>Dy,prefixIssues:()=>bt,primitiveTypes:()=>Gu,promiseAllObject:()=>Iy,propertyKeyTypes:()=>fi,randomString:()=>Oy,required:()=>Zy,safeExtend:()=>Ly,shallowClone:()=>Yu,slugify:()=>di,stringifyPrimitive:()=>mo,uint8ArrayToBase64:()=>tl,uint8ArrayToBase64url:()=>Wy,uint8ArrayToHex:()=>Ky,unwrapMessage:()=>Vr});function wy(t){return t}function ky(t){return t}function xy(t){}function $y(t){throw new Error("Unexpected value in exhaustive check")}function Py(t){}function Kr(t){let e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,o])=>e.indexOf(+n)===-1).map(([n,o])=>o)}function lo(t,e="|"){return t.map(r=>mo(r)).join(e)}function lr(t,e){return typeof e=="bigint"?e.toString():e}function dr(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Jr(t){return t==null}function Br(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function li(t,e){let r=t/e,n=Math.round(r),o=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}var Bu=Symbol("evaluating");function H(t,e,r){let n;Object.defineProperty(t,e,{get(){if(n!==Bu)return n===void 0&&(n=Bu,n=r()),n},set(o){Object.defineProperty(t,e,{value:o})},configurable:!0})}function Ty(t){return Object.create(Object.getPrototypeOf(t),Object.getOwnPropertyDescriptors(t))}function Rt(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function St(...t){let e={};for(let r of t){let n=Object.getOwnPropertyDescriptors(r);Object.assign(e,n)}return Object.defineProperties({},e)}function Ry(t){return St(t._zod.def)}function zy(t,e){return e?e.reduce((r,n)=>r?.[n],t):t}function Iy(t){let e=Object.keys(t),r=e.map(n=>t[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<e.length;s++)o[e[s]]=n[s];return o})}function Oy(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<t;n++)r+=e[Math.floor(Math.random()*e.length)];return r}function po(t){return JSON.stringify(t)}function di(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var fo="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function Vt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var pi=dr(()=>{if(ur.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function zt(t){if(Vt(t)===!1)return!1;let e=t.constructor;if(e===void 0||typeof e!="function")return!0;let r=e.prototype;return!(Vt(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Yu(t){return zt(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}function Ay(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}var Cy=t=>{let e=typeof t;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},fi=new Set(["string","number","symbol"]),Gu=new Set(["string","number","bigint","boolean","symbol","undefined"]);function vt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Qe(t,e,r){let n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function R(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function My(t){let e;return new Proxy({},{get(r,n,o){return e??(e=t()),Reflect.get(e,n,o)},set(r,n,o,s){return e??(e=t()),Reflect.set(e,n,o,s)},has(r,n){return e??(e=t()),Reflect.has(e,n)},deleteProperty(r,n){return e??(e=t()),Reflect.deleteProperty(e,n)},ownKeys(r){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(r,n){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,n)},defineProperty(r,n,o){return e??(e=t()),Reflect.defineProperty(e,n,o)}})}function mo(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function mi(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}var hi={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]},Xu={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Dy(t,e){let r=t._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s=St(t._zod.def,{get shape(){let i={};for(let a in e){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(i[a]=r.shape[a])}return Rt(this,"shape",i),i},checks:[]});return Qe(t,s)}function Ny(t,e){let r=t._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=St(t._zod.def,{get shape(){let i={...t._zod.def.shape};for(let a in e){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete i[a]}return Rt(this,"shape",i),i},checks:[]});return Qe(t,s)}function jy(t,e){if(!zt(e))throw new Error("Invalid input to extend: expected a plain object");let r=t._zod.def.checks;if(r&&r.length>0){let s=t._zod.def.shape;for(let i in e)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=St(t._zod.def,{get shape(){let s={...t._zod.def.shape,...e};return Rt(this,"shape",s),s}});return Qe(t,o)}function Ly(t,e){if(!zt(e))throw new Error("Invalid input to safeExtend: expected a plain object");let r=St(t._zod.def,{get shape(){let n={...t._zod.def.shape,...e};return Rt(this,"shape",n),n}});return Qe(t,r)}function Uy(t,e){if(t._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=St(t._zod.def,{get shape(){let n={...t._zod.def.shape,...e._zod.def.shape};return Rt(this,"shape",n),n},get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return Qe(t,r)}function qy(t,e,r){let o=e._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let i=St(e._zod.def,{get shape(){let a=e._zod.def.shape,c={...a};if(r)for(let u in r){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(c[u]=t?new t({type:"optional",innerType:a[u]}):a[u])}else for(let u in a)c[u]=t?new t({type:"optional",innerType:a[u]}):a[u];return Rt(this,"shape",c),c},checks:[]});return Qe(e,i)}function Zy(t,e,r){let n=St(e._zod.def,{get shape(){let o=e._zod.def.shape,s={...o};if(r)for(let i in r){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);r[i]&&(s[i]=new t({type:"nonoptional",innerType:o[i]}))}else for(let i in o)s[i]=new t({type:"nonoptional",innerType:o[i]});return Rt(this,"shape",s),s}});return Qe(e,n)}function It(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function gi(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue===!1)return!0;return!1}function bt(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function Vr(t){return typeof t=="string"?t:t?.message}function Le(t,e,r){let n=t.message?t.message:Vr(t.inst?._zod.def?.error?.(t))??Vr(e?.error?.(t))??Vr(r.customError?.(t))??Vr(r.localeError?.(t))??"Invalid input",{inst:o,continue:s,input:i,...a}=t;return a.path??(a.path=[]),a.message=n,e?.reportInput&&(a.input=i),a}function Qu(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function Yr(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function _i(t){let e=typeof t;switch(e){case"number":return Number.isNaN(t)?"nan":"number";case"object":{if(t===null)return"null";if(Array.isArray(t))return"array";let r=t;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return e}function pr(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}function Fy(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function el(t){let e=atob(t),r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}function tl(t){let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return btoa(e)}function Hy(t){let e=t.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-e.length%4)%4);return el(e+r)}function Wy(t){return tl(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Vy(t){let e=t.replace(/^0x/,"");if(e.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)r[n/2]=Number.parseInt(e.slice(n,n+2),16);return r}function Ky(t){return Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}var ui=class{constructor(...e){}};var rl=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,lr,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},ho=_("$ZodError",rl),yi=_("$ZodError",rl,{Parent:Error});function nl(t,e=r=>r.message){let r={},n=[];for(let o of t.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(e(o))):n.push(e(o));return{formErrors:n,fieldErrors:r}}function ol(t,e=r=>r.message){let r={_errors:[]},n=(o,s=[])=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>n({issues:a},[...s,...i.path]));else if(i.code==="invalid_key")n({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")n({issues:i.issues},[...s,...i.path]);else{let a=[...s,...i.path];if(a.length===0)r._errors.push(e(i));else{let c=r,u=0;for(;u<a.length;){let l=a[u];u===a.length-1?(c[l]=c[l]||{_errors:[]},c[l]._errors.push(e(i))):c[l]=c[l]||{_errors:[]},c=c[l],u++}}}};return n(t),r}var go=t=>(e,r,n,o)=>{let s=n?{...n,async:!1}:{async:!1},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new lt;if(i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>Le(c,s,Ce())));throw fo(a,o?.callee),a}return i.value};var _o=t=>async(e,r,n,o)=>{let s=n?{...n,async:!0}:{async:!0},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>Le(c,s,Ce())));throw fo(a,o?.callee),a}return i.value};var Gr=t=>(e,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=e._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new lt;return s.issues.length?{success:!1,error:new(t??ho)(s.issues.map(i=>Le(i,o,Ce())))}:{success:!0,data:s.value}},Xr=Gr(yi),Qr=t=>async(e,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=e._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new t(s.issues.map(i=>Le(i,o,Ce())))}:{success:!0,data:s.value}},yo=Qr(yi),sl=t=>(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return go(t)(e,r,o)};var il=t=>(e,r,n)=>go(t)(e,r,n);var al=t=>async(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return _o(t)(e,r,o)};var cl=t=>async(e,r,n)=>_o(t)(e,r,n);var ul=t=>(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Gr(t)(e,r,o)};var ll=t=>(e,r,n)=>Gr(t)(e,r,n);var dl=t=>async(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Qr(t)(e,r,o)};var pl=t=>async(e,r,n)=>Qr(t)(e,r,n);var fl=/^[cC][0-9a-z]{6,}$/,ml=/^[0-9a-z]+$/,hl=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,gl=/^[0-9a-vA-V]{20}$/,_l=/^[A-Za-z0-9]{27}$/,yl=/^[a-zA-Z0-9_-]{21}$/,Sl=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var vl=/^([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})$/,Si=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;var bl=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var By="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function El(){return new RegExp(By,"u")}var wl=/^(?:(?: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])$/,kl=/^(([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 xl=/^((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])$/,$l=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Pl=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,vi=/^[A-Za-z0-9_-]*$/;var Tl=/^https?$/,Rl=/^\+[1-9]\d{6,14}$/,zl="(?:(?:\\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])))",Il=new RegExp(`^${zl}$`);function Ol(t){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Al(t){return new RegExp(`^${Ol(t)}$`)}function Cl(t){let e=Ol({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${e}(?:${r.join("|")})`;return new RegExp(`^${zl}T(?:${n})$`)}var Ml=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)};var Dl=/^-?\d+$/,bi=/^-?\d+(?:\.\d+)?$/,Nl=/^(?:true|false)$/i,jl=/^null$/i;var Ll=/^[^A-Z]*$/,Ul=/^[^a-z]*$/;var pe=_("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),ql={number:"number",bigint:"bigint",object:"date"},Ei=_("$ZodCheckLessThan",(t,e)=>{pe.init(t,e);let r=ql[typeof e.value];t._zod.onattach.push(n=>{let o=n._zod.bag,s=(e.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?o.maximum=e.value:o.exclusiveMaximum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),wi=_("$ZodCheckGreaterThan",(t,e)=>{pe.init(t,e);let r=ql[typeof e.value];t._zod.onattach.push(n=>{let o=n._zod.bag,s=(e.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?o.minimum=e.value:o.exclusiveMinimum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Zl=_("$ZodCheckMultipleOf",(t,e)=>{pe.init(t,e),t._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=e.value)}),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):li(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),Fl=_("$ZodCheckNumberFormat",(t,e)=>{pe.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[o,s]=hi[e.format];t._zod.onattach.push(i=>{let a=i._zod.bag;a.format=e.format,a.minimum=o,a.maximum=s,r&&(a.pattern=Dl)}),t._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:e.format,code:"invalid_type",continue:!1,input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,inclusive:!0,continue:!e.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,inclusive:!0,continue:!e.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:t,continue:!e.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:t,continue:!e.abort})}});var Hl=_("$ZodCheckMaxLength",(t,e)=>{var r;pe.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!Jr(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<o&&(n._zod.bag.maximum=e.maximum)}),t._zod.check=n=>{let o=n.value;if(o.length<=e.maximum)return;let i=Yr(o);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),Wl=_("$ZodCheckMinLength",(t,e)=>{var r;pe.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!Jr(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>o&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{let o=n.value;if(o.length>=e.minimum)return;let i=Yr(o);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),Vl=_("$ZodCheckLengthEquals",(t,e)=>{var r;pe.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!Jr(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=e.length,o.maximum=e.length,o.length=e.length}),t._zod.check=n=>{let o=n.value,s=o.length;if(s===e.length)return;let i=Yr(o),a=s>e.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),en=_("$ZodCheckStringFormat",(t,e)=>{var r,n;pe.init(t,e),t._zod.onattach.push(o=>{let s=o._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=o=>{e.pattern.lastIndex=0,!e.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:e.format,input:o.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),Kl=_("$ZodCheckRegex",(t,e)=>{en.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),Jl=_("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=Ll),en.init(t,e)}),Bl=_("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=Ul),en.init(t,e)}),Yl=_("$ZodCheckIncludes",(t,e)=>{pe.init(t,e);let r=vt(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(o=>{let s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),t._zod.check=o=>{o.value.includes(e.includes,e.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:o.value,inst:t,continue:!e.abort})}}),Gl=_("$ZodCheckStartsWith",(t,e)=>{pe.init(t,e);let r=new RegExp(`^${vt(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),t._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:t,continue:!e.abort})}}),Xl=_("$ZodCheckEndsWith",(t,e)=>{pe.init(t,e);let r=new RegExp(`.*${vt(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),t._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:t,continue:!e.abort})}});var Ql=_("$ZodCheckOverwrite",(t,e)=>{pe.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});var vo=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
|
|
21
21
|
`).filter(i=>i),o=Math.min(...n.map(i=>i.length-i.trimStart().length)),s=n.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(let i of s)this.content.push(i)}compile(){let e=Function,r=this?.args,o=[...(this?.content??[""]).map(s=>` ${s}`)];return new e(...r,o.join(`
|
|
22
|
-
`))}};var
|
|
22
|
+
`))}};var td={major:4,minor:4,patch:3};var G=_("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=td;let n=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&n.unshift(t);for(let o of n)for(let s of o._zod.onattach)s(t);if(n.length===0)(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{let o=(i,a,c)=>{let u=It(i),l;for(let d of a){if(d._zod.def.when){if(gi(i)||!d._zod.def.when(i))continue}else if(u)continue;let p=i.issues.length,f=d._zod.check(i);if(f instanceof Promise&&c?.async===!1)throw new lt;if(l||f instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await f,i.issues.length!==p&&(u||(u=It(i,p)))});else{if(i.issues.length===p)continue;u||(u=It(i,p))}}return l?l.then(()=>i):i},s=(i,a,c)=>{if(It(i))return i.aborted=!0,i;let u=o(a,n,c);if(u instanceof Promise){if(c.async===!1)throw new lt;return u.then(l=>t._zod.parse(l,c))}return t._zod.parse(u,c)};t._zod.run=(i,a)=>{if(a.skipChecks)return t._zod.parse(i,a);if(a.direction==="backward"){let u=t._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(l=>s(l,i,a)):s(u,i,a)}let c=t._zod.parse(i,a);if(c instanceof Promise){if(a.async===!1)throw new lt;return c.then(u=>o(u,n,a))}return o(c,n,a)}}H(t,"~standard",()=>({validate:o=>{try{let s=Xr(t,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return yo(t,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),wo=_("$ZodString",(t,e)=>{G.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??Ml(t._zod.bag),t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:t}),r}}),X=_("$ZodStringFormat",(t,e)=>{en.init(t,e),wo.init(t,e)}),ld=_("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=vl),X.init(t,e)}),dd=_("$ZodUUID",(t,e)=>{if(e.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(n===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=Si(n))}else e.pattern??(e.pattern=Si());X.init(t,e)}),pd=_("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=bl),X.init(t,e)}),fd=_("$ZodURL",(t,e)=>{X.init(t,e),t._zod.check=r=>{try{let n=r.value.trim();if(!e.normalize&&e.protocol?.source===Tl.source&&!/^https?:\/\//i.test(n)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:t,continue:!e.abort});return}let o=new URL(n);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:r.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:r.value,inst:t,continue:!e.abort})),e.normalize?r.value=o.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:t,continue:!e.abort})}}}),md=_("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=El()),X.init(t,e)}),hd=_("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=yl),X.init(t,e)}),gd=_("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=fl),X.init(t,e)}),_d=_("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=ml),X.init(t,e)}),yd=_("$ZodULID",(t,e)=>{e.pattern??(e.pattern=hl),X.init(t,e)}),Sd=_("$ZodXID",(t,e)=>{e.pattern??(e.pattern=gl),X.init(t,e)}),vd=_("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=_l),X.init(t,e)}),bd=_("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=Cl(e)),X.init(t,e)}),Ed=_("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=Il),X.init(t,e)}),wd=_("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=Al(e)),X.init(t,e)}),kd=_("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=Sl),X.init(t,e)}),xd=_("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=wl),X.init(t,e),t._zod.bag.format="ipv4"}),$d=_("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=kl),X.init(t,e),t._zod.bag.format="ipv6",t._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:t,continue:!e.abort})}}});var Pd=_("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=xl),X.init(t,e)}),Td=_("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=$l),X.init(t,e),t._zod.check=r=>{let n=r.value.split("/");try{if(n.length!==2)throw new Error;let[o,s]=n;if(!s)throw new Error;let i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${o}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:t,continue:!e.abort})}}});function Rd(t){if(t==="")return!0;if(/\s/.test(t)||t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}var zd=_("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=Pl),X.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=r=>{Rd(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function Xy(t){if(!vi.test(t))return!1;let e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return Rd(r)}var Id=_("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=vi),X.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=r=>{Xy(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),Od=_("$ZodE164",(t,e)=>{e.pattern??(e.pattern=Rl),X.init(t,e)});function Qy(t,e=null){try{let r=t.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||e&&(!("alg"in o)||o.alg!==e))}catch{return!1}}var Ad=_("$ZodJWT",(t,e)=>{X.init(t,e),t._zod.check=r=>{Qy(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}});var xi=_("$ZodNumber",(t,e)=>{G.init(t,e),t._zod.pattern=t._zod.bag.pattern??bi,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:t,...s?{received:s}:{}}),r}}),Cd=_("$ZodNumberFormat",(t,e)=>{Fl.init(t,e),xi.init(t,e)}),Md=_("$ZodBoolean",(t,e)=>{G.init(t,e),t._zod.pattern=Nl,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:t}),r}});var Dd=_("$ZodNull",(t,e)=>{G.init(t,e),t._zod.pattern=jl,t._zod.values=new Set([null]),t._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:t}),r}});var Nd=_("$ZodUnknown",(t,e)=>{G.init(t,e),t._zod.parse=r=>r}),jd=_("$ZodNever",(t,e)=>{G.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function rd(t,e,r){t.issues.length&&e.issues.push(...bt(r,t.issues)),e.value[r]=t.value}var Ld=_("$ZodArray",(t,e)=>{G.init(t,e),t._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:t}),r;r.value=Array(o.length);let s=[];for(let i=0;i<o.length;i++){let a=o[i],c=e.element._zod.run({value:a,issues:[]},n);c instanceof Promise?s.push(c.then(u=>rd(u,r,i))):rd(c,r,i)}return s.length?Promise.all(s).then(()=>r):r}});function Eo(t,e,r,n,o,s){let i=r in n;if(t.issues.length){if(o&&s&&!i)return;e.issues.push(...bt(r,t.issues))}if(!i&&!o){t.issues.length||e.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}t.value===void 0?i&&(e.value[r]=void 0):e.value[r]=t.value}function Ud(t){let e=Object.keys(t.shape);for(let n of e)if(!t.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=mi(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(r)}}function qd(t,e,r,n,o,s){let i=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,l=c.optin==="optional",d=c.optout==="optional";for(let p in e){if(p==="__proto__"||a.has(p))continue;if(u==="never"){i.push(p);continue}let f=c.run({value:e[p],issues:[]},n);f instanceof Promise?t.push(f.then(m=>Eo(m,r,p,e,l,d))):Eo(f,r,p,e,l,d)}return i.length&&r.issues.push({code:"unrecognized_keys",keys:i,input:e,inst:s}),t.length?Promise.all(t).then(()=>r):r}var eS=_("$ZodObject",(t,e)=>{if(G.init(t,e),!Object.getOwnPropertyDescriptor(e,"shape")?.get){let a=e.shape;Object.defineProperty(e,"shape",{get:()=>{let c={...a};return Object.defineProperty(e,"shape",{value:c}),c}})}let n=dr(()=>Ud(e));H(t._zod,"propValues",()=>{let a=e.shape,c={};for(let u in a){let l=a[u]._zod;if(l.values){c[u]??(c[u]=new Set);for(let d of l.values)c[u].add(d)}}return c});let o=Vt,s=e.catchall,i;t._zod.parse=(a,c)=>{i??(i=n.value);let u=a.value;if(!o(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:t}),a;a.value={};let l=[],d=i.shape;for(let p of i.keys){let f=d[p],m=f._zod.optin==="optional",g=f._zod.optout==="optional",S=f._zod.run({value:u[p],issues:[]},c);S instanceof Promise?l.push(S.then(v=>Eo(v,a,p,u,m,g))):Eo(S,a,p,u,m,g)}return s?qd(l,u,a,c,n.value,t):l.length?Promise.all(l).then(()=>a):a}}),Zd=_("$ZodObjectJIT",(t,e)=>{eS.init(t,e);let r=t._zod.parse,n=dr(()=>Ud(e)),o=p=>{let f=new vo(["shape","payload","ctx"]),m=n.value,g=b=>{let $=po(b);return`shape[${$}]._zod.run({ value: input[${$}], issues: [] }, ctx)`};f.write("const input = payload.value;");let S=Object.create(null),v=0;for(let b of m.keys)S[b]=`key_${v++}`;f.write("const newResult = {};");for(let b of m.keys){let $=S[b],k=po(b),Se=p[b],K=Se?._zod?.optin==="optional",ct=Se?._zod?.optout==="optional";f.write(`const ${$} = ${g(b)};`),K&&ct?f.write(`
|
|
23
23
|
if (${$}.issues.length) {
|
|
24
24
|
if (${k} in input) {
|
|
25
25
|
payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
|
|
@@ -78,11 +78,11 @@ ${m.stack??""}
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
`)}f.write("payload.value = newResult;"),f.write("return payload;");let x=f.compile();return(b,$)=>x(p,b,$)},s,i=Vt,a=!lr.jitless,u=a&&li.value,l=e.catchall,d;t._zod.parse=(p,f)=>{d??(d=n.value);let m=p.value;return i(m)?a&&u&&f?.async===!1&&f.jitless!==!0?(s||(s=o(e.shape)),p=s(p,f),l?Ld([],m,p,f,d,t):p):r(p,f):(p.issues.push({expected:"object",code:"invalid_type",input:m,inst:t}),p)}});function td(t,e,r,n){for(let s of t)if(s.issues.length===0)return e.value=s.value,e;let o=t.filter(s=>!It(s));return o.length===1?(e.value=o[0].value,o[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(s=>s.issues.map(i=>Le(i,n,Ce())))}),e)}var ki=_("$ZodUnion",(t,e)=>{G.init(t,e),H(t._zod,"optin",()=>e.options.some(n=>n._zod.optin==="optional")?"optional":void 0),H(t._zod,"optout",()=>e.options.some(n=>n._zod.optout==="optional")?"optional":void 0),H(t._zod,"values",()=>{if(e.options.every(n=>n._zod.values))return new Set(e.options.flatMap(n=>Array.from(n._zod.values)))}),H(t._zod,"pattern",()=>{if(e.options.every(n=>n._zod.pattern)){let n=e.options.map(o=>o._zod.pattern);return new RegExp(`^(${n.map(o=>Vr(o.source)).join("|")})$`)}});let r=e.options.length===1?e.options[0]._zod.run:null;t._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let a of e.options){let c=a._zod.run({value:n.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}return s?Promise.all(i).then(a=>td(a,n,t,o)):td(i,n,t,o)}});var qd=_("$ZodDiscriminatedUnion",(t,e)=>{e.inclusive=!1,ki.init(t,e);let r=t._zod.parse;H(t._zod,"propValues",()=>{let o={};for(let s of e.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(let[a,c]of Object.entries(i)){o[a]||(o[a]=new Set);for(let u of c)o[a].add(u)}}return o});let n=pr(()=>{let o=e.options,s=new Map;for(let i of o){let a=i._zod.propValues?.[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);for(let c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});t._zod.parse=(o,s)=>{let i=o.value;if(!Vt(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:t}),o;let a=n.value.get(i?.[e.discriminator]);return a?a._zod.run(o,s):e.unionFallback||s.direction==="backward"?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,options:Array.from(n.value.keys()),input:i,path:[e.discriminator],inst:t}),o)}}),Zd=_("$ZodIntersection",(t,e)=>{G.init(t,e),t._zod.parse=(r,n)=>{let o=r.value,s=e.left._zod.run({value:o,issues:[]},n),i=e.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>rd(r,c,u)):rd(r,s,i)}});function Ei(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(Rt(t)&&Rt(e)){let r=Object.keys(e),n=Object.keys(t).filter(s=>r.indexOf(s)!==-1),o={...t,...e};for(let s of n){let i=Ei(t[s],e[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<t.length;n++){let o=t[n],s=e[n],i=Ei(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 rd(t,e,r){let n=new Map,o;for(let a of e.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(let c of a.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else t.issues.push(a);for(let a of r.issues)if(a.code==="unrecognized_keys")for(let c of a.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else t.issues.push(a);let s=[...n].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&o&&t.issues.push({...o,keys:s}),It(t))return t;let i=Ei(e.value,r.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return t.value=i.data,t}var Fd=_("$ZodRecord",(t,e)=>{G.init(t,e),t._zod.parse=(r,n)=>{let o=r.value;if(!Rt(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:t}),r;let s=[],i=e.keyType._zod.values;if(i){r.value={};let a=new Set;for(let u of i)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);let l=e.keyType._zod.run({value:u,issues:[]},n);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(l.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(f=>Le(f,n,Ce())),input:u,path:[u],inst:t});continue}let d=l.value,p=e.valueType._zod.run({value:o[u],issues:[]},n);p instanceof Promise?s.push(p.then(f=>{f.issues.length&&r.issues.push(...bt(u,f.issues)),r.value[d]=f.value})):(p.issues.length&&r.issues.push(...bt(u,p.issues)),r.value[d]=p.value)}let c;for(let u in o)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:t,keys:c})}else{r.value={};for(let a of Reflect.ownKeys(o)){if(a==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,a))continue;let c=e.keyType._zod.run({value:a,issues:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Si.test(a)&&c.issues.length){let d=e.keyType._zod.run({value:Number(a),issues:[]},n);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(c=d)}if(c.issues.length){e.mode==="loose"?r.value[a]=o[a]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(d=>Le(d,n,Ce())),input:a,path:[a],inst:t});continue}let l=e.valueType._zod.run({value:o[a],issues:[]},n);l instanceof Promise?s.push(l.then(d=>{d.issues.length&&r.issues.push(...bt(a,d.issues)),r.value[c.value]=d.value})):(l.issues.length&&r.issues.push(...bt(a,l.issues)),r.value[c.value]=l.value)}}return s.length?Promise.all(s).then(()=>r):r}});var Hd=_("$ZodEnum",(t,e)=>{G.init(t,e);let r=Hr(e.entries),n=new Set(r);t._zod.values=n,t._zod.pattern=new RegExp(`^(${r.filter(o=>di.has(typeof o)).map(o=>typeof o=="string"?vt(o):o.toString()).join("|")})$`),t._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:t}),o}}),Wd=_("$ZodLiteral",(t,e)=>{if(G.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(e.values);t._zod.values=r,t._zod.pattern=new RegExp(`^(${e.values.map(n=>typeof n=="string"?vt(n):n?vt(n.toString()):String(n)).join("|")})$`),t._zod.parse=(n,o)=>{let s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:e.values,input:s,inst:t}),n}});var Vd=_("$ZodTransform",(t,e)=>{G.init(t,e),t._zod.optin="optional",t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new ur(t.constructor.name);let o=e.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r.fallback=!0,r));if(o instanceof Promise)throw new ut;return r.value=o,r.fallback=!0,r}});function nd(t,e){return e===void 0&&(t.issues.length||t.fallback)?{issues:[],value:void 0}:t}var xi=_("$ZodOptional",(t,e)=>{G.init(t,e),t._zod.optin="optional",t._zod.optout="optional",H(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),H(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Vr(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>{if(e.innerType._zod.optin==="optional"){let o=r.value,s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>nd(i,o)):nd(s,o)}return r.value===void 0?r:e.innerType._zod.run(r,n)}}),Kd=_("$ZodExactOptional",(t,e)=>{xi.init(t,e),H(t._zod,"values",()=>e.innerType._zod.values),H(t._zod,"pattern",()=>e.innerType._zod.pattern),t._zod.parse=(r,n)=>e.innerType._zod.run(r,n)}),Jd=_("$ZodNullable",(t,e)=>{G.init(t,e),H(t._zod,"optin",()=>e.innerType._zod.optin),H(t._zod,"optout",()=>e.innerType._zod.optout),H(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Vr(r.source)}|null)$`):void 0}),H(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)}),Bd=_("$ZodDefault",(t,e)=>{G.init(t,e),t._zod.optin="optional",H(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);if(r.value===void 0)return r.value=e.defaultValue,r;let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>od(s,e)):od(o,e)}});function od(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}var Yd=_("$ZodPrefault",(t,e)=>{G.init(t,e),t._zod.optin="optional",H(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,n))}),Gd=_("$ZodNonOptional",(t,e)=>{G.init(t,e),H(t._zod,"values",()=>{let r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>sd(s,t)):sd(o,t)}});function sd(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}var Xd=_("$ZodCatch",(t,e)=>{G.init(t,e),t._zod.optin="optional",H(t._zod,"optout",()=>e.innerType._zod.optout),H(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(i=>Le(i,n,Ce()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=o.value,o.issues.length&&(r.value=e.catchValue({...r,error:{issues:o.issues.map(s=>Le(s,n,Ce()))},input:r.value}),r.issues=[],r.fallback=!0),r)}});var $i=_("$ZodPipe",(t,e)=>{G.init(t,e),H(t._zod,"values",()=>e.in._zod.values),H(t._zod,"optin",()=>e.in._zod.optin),H(t._zod,"optout",()=>e.out._zod.optout),H(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=e.out._zod.run(r,n);return s instanceof Promise?s.then(i=>vo(i,e.in,n)):vo(s,e.in,n)}let o=e.in._zod.run(r,n);return o instanceof Promise?o.then(s=>vo(s,e.out,n)):vo(o,e.out,n)}});function vo(t,e,r){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues,fallback:t.fallback},r)}var Qd=_("$ZodPreprocess",(t,e)=>{$i.init(t,e)}),ep=_("$ZodReadonly",(t,e)=>{G.init(t,e),H(t._zod,"propValues",()=>e.innerType._zod.propValues),H(t._zod,"values",()=>e.innerType._zod.values),H(t._zod,"optin",()=>e.innerType?._zod?.optin),H(t._zod,"optout",()=>e.innerType?._zod?.optout),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(id):id(o)}});function id(t){return t.value=Object.freeze(t.value),t}var tp=_("$ZodCustom",(t,e)=>{fe.init(t,e),G.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{let n=r.value,o=e.fn(n);if(o instanceof Promise)return o.then(s=>ad(s,r,n,t));ad(o,r,n,t)}});function ad(t,e,r,n){if(!t){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),e.issues.push(fr(o))}}var Gy=()=>{let t={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function e(o){return t[o]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};return o=>{switch(o.code){case"invalid_type":{let s=n[o.expected]??o.expected,i=hi(o.input),a=n[i]??i;return`Invalid input: expected ${s}, received ${a}`}case"invalid_value":return o.values.length===1?`Invalid input: expected ${fo(o.values[0])}`:`Invalid option: expected one of ${uo(o.values,"|")}`;case"too_big":{let s=o.inclusive?"<=":"<",i=e(o.origin);return i?`Too big: expected ${o.origin??"value"} to have ${s}${o.maximum.toString()} ${i.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${s}${o.maximum.toString()}`}case"too_small":{let s=o.inclusive?">=":">",i=e(o.origin);return i?`Too small: expected ${o.origin} to have ${s}${o.minimum.toString()} ${i.unit}`:`Too small: expected ${o.origin} to be ${s}${o.minimum.toString()}`}case"invalid_format":{let s=o;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${r[s.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${uo(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return o.options&&Array.isArray(o.options)&&o.options.length>0?`Invalid discriminator value. Expected ${o.options.map(i=>`'${i}'`).join(" | ")}`:"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function rp(){return{localeError:Gy()}}var np;var Pi=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...r){let n=r[0];return this._map.set(e,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){let r=e._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let o={...n,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Xy(){return new Pi}(np=globalThis).__zod_globalRegistry??(np.__zod_globalRegistry=Xy());var Kt=globalThis.__zod_globalRegistry;function op(t,e){return new t({type:"string",...z(e)})}function sp(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...z(e)})}function Ti(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...z(e)})}function ip(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...z(e)})}function ap(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...z(e)})}function cp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...z(e)})}function up(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...z(e)})}function lp(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...z(e)})}function dp(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...z(e)})}function pp(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...z(e)})}function fp(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...z(e)})}function mp(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...z(e)})}function hp(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...z(e)})}function gp(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...z(e)})}function _p(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...z(e)})}function yp(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...z(e)})}function Sp(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...z(e)})}function vp(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...z(e)})}function bp(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...z(e)})}function Ep(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...z(e)})}function wp(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...z(e)})}function kp(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...z(e)})}function xp(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...z(e)})}function $p(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...z(e)})}function Pp(t,e){return new t({type:"string",format:"date",check:"string_format",...z(e)})}function Tp(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...z(e)})}function zp(t,e){return new t({type:"string",format:"duration",check:"string_format",...z(e)})}function Rp(t,e){return new t({type:"number",checks:[],...z(e)})}function Ip(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...z(e)})}function Op(t,e){return new t({type:"boolean",...z(e)})}function Ap(t,e){return new t({type:"null",...z(e)})}function Cp(t){return new t({type:"unknown"})}function Mp(t,e){return new t({type:"never",...z(e)})}function wo(t,e){return new vi({check:"less_than",...z(e),value:t,inclusive:!1})}function Xr(t,e){return new vi({check:"less_than",...z(e),value:t,inclusive:!0})}function ko(t,e){return new bi({check:"greater_than",...z(e),value:t,inclusive:!1})}function Qr(t,e){return new bi({check:"greater_than",...z(e),value:t,inclusive:!0})}function xo(t,e){return new Ul({check:"multiple_of",...z(e),value:t})}function $o(t,e){return new Zl({check:"max_length",...z(e),maximum:t})}function mr(t,e){return new Fl({check:"min_length",...z(e),minimum:t})}function Po(t,e){return new Hl({check:"length_equals",...z(e),length:t})}function zi(t,e){return new Wl({check:"string_format",format:"regex",...z(e),pattern:t})}function Ri(t){return new Vl({check:"string_format",format:"lowercase",...z(t)})}function Ii(t){return new Kl({check:"string_format",format:"uppercase",...z(t)})}function Oi(t,e){return new Jl({check:"string_format",format:"includes",...z(e),includes:t})}function Ai(t,e){return new Bl({check:"string_format",format:"starts_with",...z(e),prefix:t})}function Ci(t,e){return new Yl({check:"string_format",format:"ends_with",...z(e),suffix:t})}function Ot(t){return new Gl({check:"overwrite",tx:t})}function Mi(t){return Ot(e=>e.normalize(t))}function Di(){return Ot(t=>t.trim())}function Ni(){return Ot(t=>t.toLowerCase())}function ji(){return Ot(t=>t.toUpperCase())}function Li(){return Ot(t=>ui(t))}function Dp(t,e,r){return new t({type:"array",element:e,...z(r)})}function Np(t,e,r){let n=z(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function jp(t,e,r){return new t({type:"custom",check:"custom",fn:e,...z(r)})}function Lp(t,e){let r=Qy(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(fr(o,n.value,r._zod.def));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(fr(s))}},t(n.value,n)),e);return r}function Qy(t,e){let r=new fe({check:"custom",...z(e)});return r._zod.check=t,r}function Ui(t){let e=t?.target??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:t?.metadata??Kt,target:e,unrepresentable:t?.unrepresentable??"throw",override:t?.override??(()=>{}),io:t?.io??"output",counter:0,seen:new Map,cycles:t?.cycles??"ref",reused:t?.reused??"inline",external:t?.external??void 0}}function ie(t,e,r={path:[],schemaPath:[]}){var n;let o=t._zod.def,s=e.seen.get(t);if(s)return s.count++,r.schemaPath.includes(t)&&(s.cycle=r.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:r.path};e.seen.set(t,i);let a=t._zod.toJSONSchema?.();if(a)i.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,t],path:r.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,i.schema,l);else{let p=i.schema,f=e.processors[o.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(t,e,p,l)}let d=t._zod.parent;d&&(i.ref||(i.ref=d),ie(d,e,l),e.seen.get(d).isParent=!0)}let c=e.metadataRegistry.get(t);return c&&Object.assign(i.schema,c),e.io==="input"&&we(t)&&(delete i.schema.examples,delete i.schema.default),e.io==="input"&&"_prefault"in i.schema&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,e.seen.get(t).schema}function qi(t,e){let r=t.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=new Map;for(let i of t.seen.entries()){let a=t.metadataRegistry.get(i[0])?.id;if(a){let c=n.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,i[0])}}let o=i=>{let a=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){let d=t.external.registry.get(i[0])?.id,p=t.external.uri??(m=>m);if(d)return{ref:p(d)};let f=i[1].defId??i[1].schema.id??`schema${t.counter++}`;return i[1].defId=f,{defId:f,ref:`${p("__shared")}#/${a}/${f}`}}if(i[1]===r)return{ref:"#"};let u=`#/${a}/`,l=i[1].schema.id??`__schema${t.counter++}`;return{defId:l,ref:u+l}},s=i=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:u}=o(i);a.def={...a.schema},u&&(a.defId=u);let l=a.schema;for(let d in l)delete l[d];l.$ref=c};if(t.cycles==="throw")for(let i of t.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
81
|
+
`)}f.write("payload.value = newResult;"),f.write("return payload;");let x=f.compile();return(b,$)=>x(p,b,$)},s,i=Vt,a=!ur.jitless,u=a&&pi.value,l=e.catchall,d;t._zod.parse=(p,f)=>{d??(d=n.value);let m=p.value;return i(m)?a&&u&&f?.async===!1&&f.jitless!==!0?(s||(s=o(e.shape)),p=s(p,f),l?qd([],m,p,f,d,t):p):r(p,f):(p.issues.push({expected:"object",code:"invalid_type",input:m,inst:t}),p)}});function nd(t,e,r,n){for(let s of t)if(s.issues.length===0)return e.value=s.value,e;let o=t.filter(s=>!It(s));return o.length===1?(e.value=o[0].value,o[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(s=>s.issues.map(i=>Le(i,n,Ce())))}),e)}var $i=_("$ZodUnion",(t,e)=>{G.init(t,e),H(t._zod,"optin",()=>e.options.some(n=>n._zod.optin==="optional")?"optional":void 0),H(t._zod,"optout",()=>e.options.some(n=>n._zod.optout==="optional")?"optional":void 0),H(t._zod,"values",()=>{if(e.options.every(n=>n._zod.values))return new Set(e.options.flatMap(n=>Array.from(n._zod.values)))}),H(t._zod,"pattern",()=>{if(e.options.every(n=>n._zod.pattern)){let n=e.options.map(o=>o._zod.pattern);return new RegExp(`^(${n.map(o=>Br(o.source)).join("|")})$`)}});let r=e.options.length===1?e.options[0]._zod.run:null;t._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let a of e.options){let c=a._zod.run({value:n.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}return s?Promise.all(i).then(a=>nd(a,n,t,o)):nd(i,n,t,o)}});var Fd=_("$ZodDiscriminatedUnion",(t,e)=>{e.inclusive=!1,$i.init(t,e);let r=t._zod.parse;H(t._zod,"propValues",()=>{let o={};for(let s of e.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(let[a,c]of Object.entries(i)){o[a]||(o[a]=new Set);for(let u of c)o[a].add(u)}}return o});let n=dr(()=>{let o=e.options,s=new Map;for(let i of o){let a=i._zod.propValues?.[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);for(let c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});t._zod.parse=(o,s)=>{let i=o.value;if(!Vt(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:t}),o;let a=n.value.get(i?.[e.discriminator]);return a?a._zod.run(o,s):e.unionFallback||s.direction==="backward"?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,options:Array.from(n.value.keys()),input:i,path:[e.discriminator],inst:t}),o)}}),Hd=_("$ZodIntersection",(t,e)=>{G.init(t,e),t._zod.parse=(r,n)=>{let o=r.value,s=e.left._zod.run({value:o,issues:[]},n),i=e.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>od(r,c,u)):od(r,s,i)}});function ki(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(zt(t)&&zt(e)){let r=Object.keys(e),n=Object.keys(t).filter(s=>r.indexOf(s)!==-1),o={...t,...e};for(let s of n){let i=ki(t[s],e[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<t.length;n++){let o=t[n],s=e[n],i=ki(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function od(t,e,r){let n=new Map,o;for(let a of e.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(let c of a.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else t.issues.push(a);for(let a of r.issues)if(a.code==="unrecognized_keys")for(let c of a.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else t.issues.push(a);let s=[...n].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&o&&t.issues.push({...o,keys:s}),It(t))return t;let i=ki(e.value,r.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return t.value=i.data,t}var Wd=_("$ZodRecord",(t,e)=>{G.init(t,e),t._zod.parse=(r,n)=>{let o=r.value;if(!zt(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:t}),r;let s=[],i=e.keyType._zod.values;if(i){r.value={};let a=new Set;for(let u of i)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);let l=e.keyType._zod.run({value:u,issues:[]},n);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(l.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(f=>Le(f,n,Ce())),input:u,path:[u],inst:t});continue}let d=l.value,p=e.valueType._zod.run({value:o[u],issues:[]},n);p instanceof Promise?s.push(p.then(f=>{f.issues.length&&r.issues.push(...bt(u,f.issues)),r.value[d]=f.value})):(p.issues.length&&r.issues.push(...bt(u,p.issues)),r.value[d]=p.value)}let c;for(let u in o)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:t,keys:c})}else{r.value={};for(let a of Reflect.ownKeys(o)){if(a==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,a))continue;let c=e.keyType._zod.run({value:a,issues:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&bi.test(a)&&c.issues.length){let d=e.keyType._zod.run({value:Number(a),issues:[]},n);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(c=d)}if(c.issues.length){e.mode==="loose"?r.value[a]=o[a]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(d=>Le(d,n,Ce())),input:a,path:[a],inst:t});continue}let l=e.valueType._zod.run({value:o[a],issues:[]},n);l instanceof Promise?s.push(l.then(d=>{d.issues.length&&r.issues.push(...bt(a,d.issues)),r.value[c.value]=d.value})):(l.issues.length&&r.issues.push(...bt(a,l.issues)),r.value[c.value]=l.value)}}return s.length?Promise.all(s).then(()=>r):r}});var Vd=_("$ZodEnum",(t,e)=>{G.init(t,e);let r=Kr(e.entries),n=new Set(r);t._zod.values=n,t._zod.pattern=new RegExp(`^(${r.filter(o=>fi.has(typeof o)).map(o=>typeof o=="string"?vt(o):o.toString()).join("|")})$`),t._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:t}),o}}),Kd=_("$ZodLiteral",(t,e)=>{if(G.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(e.values);t._zod.values=r,t._zod.pattern=new RegExp(`^(${e.values.map(n=>typeof n=="string"?vt(n):n?vt(n.toString()):String(n)).join("|")})$`),t._zod.parse=(n,o)=>{let s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:e.values,input:s,inst:t}),n}});var Jd=_("$ZodTransform",(t,e)=>{G.init(t,e),t._zod.optin="optional",t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new cr(t.constructor.name);let o=e.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r.fallback=!0,r));if(o instanceof Promise)throw new lt;return r.value=o,r.fallback=!0,r}});function sd(t,e){return e===void 0&&(t.issues.length||t.fallback)?{issues:[],value:void 0}:t}var Pi=_("$ZodOptional",(t,e)=>{G.init(t,e),t._zod.optin="optional",t._zod.optout="optional",H(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),H(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Br(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>{if(e.innerType._zod.optin==="optional"){let o=r.value,s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>sd(i,o)):sd(s,o)}return r.value===void 0?r:e.innerType._zod.run(r,n)}}),Bd=_("$ZodExactOptional",(t,e)=>{Pi.init(t,e),H(t._zod,"values",()=>e.innerType._zod.values),H(t._zod,"pattern",()=>e.innerType._zod.pattern),t._zod.parse=(r,n)=>e.innerType._zod.run(r,n)}),Yd=_("$ZodNullable",(t,e)=>{G.init(t,e),H(t._zod,"optin",()=>e.innerType._zod.optin),H(t._zod,"optout",()=>e.innerType._zod.optout),H(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Br(r.source)}|null)$`):void 0}),H(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)}),Gd=_("$ZodDefault",(t,e)=>{G.init(t,e),t._zod.optin="optional",H(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);if(r.value===void 0)return r.value=e.defaultValue,r;let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>id(s,e)):id(o,e)}});function id(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}var Xd=_("$ZodPrefault",(t,e)=>{G.init(t,e),t._zod.optin="optional",H(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,n))}),Qd=_("$ZodNonOptional",(t,e)=>{G.init(t,e),H(t._zod,"values",()=>{let r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>ad(s,t)):ad(o,t)}});function ad(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}var ep=_("$ZodCatch",(t,e)=>{G.init(t,e),t._zod.optin="optional",H(t._zod,"optout",()=>e.innerType._zod.optout),H(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(i=>Le(i,n,Ce()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=o.value,o.issues.length&&(r.value=e.catchValue({...r,error:{issues:o.issues.map(s=>Le(s,n,Ce()))},input:r.value}),r.issues=[],r.fallback=!0),r)}});var Ti=_("$ZodPipe",(t,e)=>{G.init(t,e),H(t._zod,"values",()=>e.in._zod.values),H(t._zod,"optin",()=>e.in._zod.optin),H(t._zod,"optout",()=>e.out._zod.optout),H(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=e.out._zod.run(r,n);return s instanceof Promise?s.then(i=>bo(i,e.in,n)):bo(s,e.in,n)}let o=e.in._zod.run(r,n);return o instanceof Promise?o.then(s=>bo(s,e.out,n)):bo(o,e.out,n)}});function bo(t,e,r){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues,fallback:t.fallback},r)}var tp=_("$ZodPreprocess",(t,e)=>{Ti.init(t,e)}),rp=_("$ZodReadonly",(t,e)=>{G.init(t,e),H(t._zod,"propValues",()=>e.innerType._zod.propValues),H(t._zod,"values",()=>e.innerType._zod.values),H(t._zod,"optin",()=>e.innerType?._zod?.optin),H(t._zod,"optout",()=>e.innerType?._zod?.optout),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(cd):cd(o)}});function cd(t){return t.value=Object.freeze(t.value),t}var np=_("$ZodCustom",(t,e)=>{pe.init(t,e),G.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{let n=r.value,o=e.fn(n);if(o instanceof Promise)return o.then(s=>ud(s,r,n,t));ud(o,r,n,t)}});function ud(t,e,r,n){if(!t){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),e.issues.push(pr(o))}}var tS=()=>{let t={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function e(o){return t[o]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};return o=>{switch(o.code){case"invalid_type":{let s=n[o.expected]??o.expected,i=_i(o.input),a=n[i]??i;return`Invalid input: expected ${s}, received ${a}`}case"invalid_value":return o.values.length===1?`Invalid input: expected ${mo(o.values[0])}`:`Invalid option: expected one of ${lo(o.values,"|")}`;case"too_big":{let s=o.inclusive?"<=":"<",i=e(o.origin);return i?`Too big: expected ${o.origin??"value"} to have ${s}${o.maximum.toString()} ${i.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${s}${o.maximum.toString()}`}case"too_small":{let s=o.inclusive?">=":">",i=e(o.origin);return i?`Too small: expected ${o.origin} to have ${s}${o.minimum.toString()} ${i.unit}`:`Too small: expected ${o.origin} to be ${s}${o.minimum.toString()}`}case"invalid_format":{let s=o;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${r[s.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${lo(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return o.options&&Array.isArray(o.options)&&o.options.length>0?`Invalid discriminator value. Expected ${o.options.map(i=>`'${i}'`).join(" | ")}`:"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function op(){return{localeError:tS()}}var sp;var Ri=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...r){let n=r[0];return this._map.set(e,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){let r=e._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let o={...n,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function rS(){return new Ri}(sp=globalThis).__zod_globalRegistry??(sp.__zod_globalRegistry=rS());var Kt=globalThis.__zod_globalRegistry;function ip(t,e){return new t({type:"string",...R(e)})}function ap(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...R(e)})}function zi(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...R(e)})}function cp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...R(e)})}function up(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...R(e)})}function lp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...R(e)})}function dp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...R(e)})}function pp(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...R(e)})}function fp(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...R(e)})}function mp(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...R(e)})}function hp(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...R(e)})}function gp(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...R(e)})}function _p(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...R(e)})}function yp(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...R(e)})}function Sp(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...R(e)})}function vp(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...R(e)})}function bp(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...R(e)})}function Ep(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...R(e)})}function wp(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...R(e)})}function kp(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...R(e)})}function xp(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...R(e)})}function $p(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...R(e)})}function Pp(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...R(e)})}function Tp(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...R(e)})}function Rp(t,e){return new t({type:"string",format:"date",check:"string_format",...R(e)})}function zp(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...R(e)})}function Ip(t,e){return new t({type:"string",format:"duration",check:"string_format",...R(e)})}function Op(t,e){return new t({type:"number",checks:[],...R(e)})}function Ap(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...R(e)})}function Cp(t,e){return new t({type:"boolean",...R(e)})}function Mp(t,e){return new t({type:"null",...R(e)})}function Dp(t){return new t({type:"unknown"})}function Np(t,e){return new t({type:"never",...R(e)})}function ko(t,e){return new Ei({check:"less_than",...R(e),value:t,inclusive:!1})}function tn(t,e){return new Ei({check:"less_than",...R(e),value:t,inclusive:!0})}function xo(t,e){return new wi({check:"greater_than",...R(e),value:t,inclusive:!1})}function rn(t,e){return new wi({check:"greater_than",...R(e),value:t,inclusive:!0})}function $o(t,e){return new Zl({check:"multiple_of",...R(e),value:t})}function Po(t,e){return new Hl({check:"max_length",...R(e),maximum:t})}function fr(t,e){return new Wl({check:"min_length",...R(e),minimum:t})}function To(t,e){return new Vl({check:"length_equals",...R(e),length:t})}function Ii(t,e){return new Kl({check:"string_format",format:"regex",...R(e),pattern:t})}function Oi(t){return new Jl({check:"string_format",format:"lowercase",...R(t)})}function Ai(t){return new Bl({check:"string_format",format:"uppercase",...R(t)})}function Ci(t,e){return new Yl({check:"string_format",format:"includes",...R(e),includes:t})}function Mi(t,e){return new Gl({check:"string_format",format:"starts_with",...R(e),prefix:t})}function Di(t,e){return new Xl({check:"string_format",format:"ends_with",...R(e),suffix:t})}function Ot(t){return new Ql({check:"overwrite",tx:t})}function Ni(t){return Ot(e=>e.normalize(t))}function ji(){return Ot(t=>t.trim())}function Li(){return Ot(t=>t.toLowerCase())}function Ui(){return Ot(t=>t.toUpperCase())}function qi(){return Ot(t=>di(t))}function jp(t,e,r){return new t({type:"array",element:e,...R(r)})}function Lp(t,e,r){let n=R(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function Up(t,e,r){return new t({type:"custom",check:"custom",fn:e,...R(r)})}function qp(t,e){let r=nS(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(pr(o,n.value,r._zod.def));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(pr(s))}},t(n.value,n)),e);return r}function nS(t,e){let r=new pe({check:"custom",...R(e)});return r._zod.check=t,r}function Zi(t){let e=t?.target??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:t?.metadata??Kt,target:e,unrepresentable:t?.unrepresentable??"throw",override:t?.override??(()=>{}),io:t?.io??"output",counter:0,seen:new Map,cycles:t?.cycles??"ref",reused:t?.reused??"inline",external:t?.external??void 0}}function ie(t,e,r={path:[],schemaPath:[]}){var n;let o=t._zod.def,s=e.seen.get(t);if(s)return s.count++,r.schemaPath.includes(t)&&(s.cycle=r.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:r.path};e.seen.set(t,i);let a=t._zod.toJSONSchema?.();if(a)i.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,t],path:r.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,i.schema,l);else{let p=i.schema,f=e.processors[o.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(t,e,p,l)}let d=t._zod.parent;d&&(i.ref||(i.ref=d),ie(d,e,l),e.seen.get(d).isParent=!0)}let c=e.metadataRegistry.get(t);return c&&Object.assign(i.schema,c),e.io==="input"&&we(t)&&(delete i.schema.examples,delete i.schema.default),e.io==="input"&&"_prefault"in i.schema&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,e.seen.get(t).schema}function Fi(t,e){let r=t.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=new Map;for(let i of t.seen.entries()){let a=t.metadataRegistry.get(i[0])?.id;if(a){let c=n.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,i[0])}}let o=i=>{let a=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){let d=t.external.registry.get(i[0])?.id,p=t.external.uri??(m=>m);if(d)return{ref:p(d)};let f=i[1].defId??i[1].schema.id??`schema${t.counter++}`;return i[1].defId=f,{defId:f,ref:`${p("__shared")}#/${a}/${f}`}}if(i[1]===r)return{ref:"#"};let u=`#/${a}/`,l=i[1].schema.id??`__schema${t.counter++}`;return{defId:l,ref:u+l}},s=i=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:u}=o(i);a.def={...a.schema},u&&(a.defId=u);let l=a.schema;for(let d in l)delete l[d];l.$ref=c};if(t.cycles==="throw")for(let i of t.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
82
82
|
|
|
83
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of t.seen.entries()){let a=i[1];if(e===i[0]){s(i);continue}if(t.external){let u=t.external.registry.get(i[0])?.id;if(e!==i[0]&&u){s(i);continue}}if(t.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}if(a.count>1&&t.reused==="ref"){s(i);continue}}}function Zi(t,e){let r=t.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=t.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){n(d);let f=t.seen.get(d),m=f.schema;if(m.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):Object.assign(u,m),Object.assign(u,l),a._zod.parent===d)for(let S in u)S==="$ref"||S==="allOf"||S in l||delete u[S];if(m.$ref&&f.def)for(let S in u)S==="$ref"||S==="allOf"||S in f.def&&JSON.stringify(u[S])===JSON.stringify(f.def[S])&&delete u[S]}let p=a._zod.parent;if(p&&p!==d){n(p);let f=t.seen.get(p);if(f?.schema.$ref&&(u.$ref=f.schema.$ref,f.def))for(let m in u)m==="$ref"||m==="allOf"||m in f.def&&JSON.stringify(u[m])===JSON.stringify(f.def[m])&&delete u[m]}t.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(let a of[...t.seen.entries()].reverse())n(a[0]);let o={};if(t.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){let a=t.external.registry.get(e)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=t.external.uri(a)}Object.assign(o,r.def??r.schema);let s=t.metadataRegistry.get(e)?.id;s!==void 0&&o.id===s&&delete o.id;let i=t.external?.defs??{};for(let a of t.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,i[c.defId]=c.def)}t.external||Object.keys(i).length>0&&(t.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...e["~standard"],jsonSchema:{input:en(e,"input",t.processors),output:en(e,"output",t.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function we(t,e){let r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);let n=t._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return we(n.element,r);if(n.type==="set")return we(n.valueType,r);if(n.type==="lazy")return we(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return we(n.innerType,r);if(n.type==="intersection")return we(n.left,r)||we(n.right,r);if(n.type==="record"||n.type==="map")return we(n.keyType,r)||we(n.valueType,r);if(n.type==="pipe")return t._zod.traits.has("$ZodCodec")?!0:we(n.in,r)||we(n.out,r);if(n.type==="object"){for(let o in n.shape)if(we(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(we(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(we(o,r))return!0;return!!(n.rest&&we(n.rest,r))}return!1}var Up=(t,e={})=>r=>{let n=Ui({...r,processors:e});return ie(t,n),qi(n,t),Zi(n,t)},en=(t,e,r={})=>n=>{let{libraryOptions:o,target:s}=n??{},i=Ui({...o??{},target:s,io:e,processors:r});return ie(t,i),qi(i,t),Zi(i,t)};var eS={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},qp=(t,e,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u}=t._zod.bag;if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=eS[a]??a,o.format===""&&delete o.format,a==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let l=[...c];l.length===1?o.pattern=l[0].source:l.length>1&&(o.allOf=[...l.map(d=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},Zp=(t,e,r,n)=>{let o=r,{minimum:s,maximum:i,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=t._zod.bag;typeof a=="string"&&a.includes("int")?o.type="integer":o.type="number";let d=typeof l=="number"&&l>=(s??Number.NEGATIVE_INFINITY),p=typeof u=="number"&&u<=(i??Number.POSITIVE_INFINITY),f=e.target==="draft-04"||e.target==="openapi-3.0";d?f?(o.minimum=l,o.exclusiveMinimum=!0):o.exclusiveMinimum=l:typeof s=="number"&&(o.minimum=s),p?f?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u:typeof i=="number"&&(o.maximum=i),typeof c=="number"&&(o.multipleOf=c)},Fp=(t,e,r,n)=>{r.type="boolean"};var Hp=(t,e,r,n)=>{e.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var Wp=(t,e,r,n)=>{r.not={}};var Vp=(t,e,r,n)=>{};var Kp=(t,e,r,n)=>{let o=t._zod.def,s=Hr(o.entries);s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},Jp=(t,e,r,n)=>{let o=t._zod.def,s=[];for(let i of o.values)if(i===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){let i=s[0];r.type=i===null?"null":typeof i,e.target==="draft-04"||e.target==="openapi-3.0"?r.enum=[i]:r.const=i}else s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),s.every(i=>typeof i=="boolean")&&(r.type="boolean"),s.every(i=>i===null)&&(r.type="null"),r.enum=s};var Bp=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")};var Yp=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")};var Gp=(t,e,r,n)=>{let o=r,s=t._zod.def,{minimum:i,maximum:a}=t._zod.bag;typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=ie(s.element,e,{...n,path:[...n.path,"items"]})},Xp=(t,e,r,n)=>{let o=r,s=t._zod.def;o.type="object",o.properties={};let i=s.shape;for(let u in i)o.properties[u]=ie(i[u],e,{...n,path:[...n.path,"properties",u]});let a=new Set(Object.keys(i)),c=new Set([...a].filter(u=>{let l=s.shape[u]._zod;return e.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(o.required=Array.from(c)),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=ie(s.catchall,e,{...n,path:[...n.path,"additionalProperties"]})):e.io==="output"&&(o.additionalProperties=!1)},Qp=(t,e,r,n)=>{let o=t._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>ie(a,e,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=i:r.anyOf=i},ef=(t,e,r,n)=>{let o=t._zod.def,s=ie(o.left,e,{...n,path:[...n.path,"allOf",0]}),i=ie(o.right,e,{...n,path:[...n.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];r.allOf=c};var tf=(t,e,r,n)=>{let o=r,s=t._zod.def;o.type="object";let i=s.keyType,c=i._zod.bag?.patterns;if(s.mode==="loose"&&c&&c.size>0){let l=ie(s.valueType,e,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of c)o.patternProperties[d.source]=l}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(o.propertyNames=ie(s.keyType,e,{...n,path:[...n.path,"propertyNames"]})),o.additionalProperties=ie(s.valueType,e,{...n,path:[...n.path,"additionalProperties"]});let u=i._zod.values;if(u){let l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l)}},rf=(t,e,r,n)=>{let o=t._zod.def,s=ie(o.innerType,e,n),i=e.seen.get(t);e.target==="openapi-3.0"?(i.ref=o.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},nf=(t,e,r,n)=>{let o=t._zod.def;ie(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType},of=(t,e,r,n)=>{let o=t._zod.def;ie(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},sf=(t,e,r,n)=>{let o=t._zod.def;ie(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType,e.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},af=(t,e,r,n)=>{let o=t._zod.def;ie(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=i},cf=(t,e,r,n)=>{let o=t._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=e.io==="input"?s?o.out:o.in:o.out;ie(i,e,n);let a=e.seen.get(t);a.ref=i},uf=(t,e,r,n)=>{let o=t._zod.def;ie(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType,r.readOnly=!0};var Fi=(t,e,r,n)=>{let o=t._zod.def;ie(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType};function hr(t){return!!t._zod}function At(t,e){return hr(t)?Br(t,e):t.safeParse(e)}function To(t){if(!t)return;let e;if(hr(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function lf(t){if(hr(t)){let s=t._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=t.value;if(n!==void 0)return n}var rn={};Zu(rn,{ZodISODate:()=>pf,ZodISODateTime:()=>df,ZodISODuration:()=>mf,ZodISOTime:()=>ff,date:()=>Wi,datetime:()=>Hi,duration:()=>Ki,time:()=>Vi});var df=_("ZodISODateTime",(t,e)=>{Sd.init(t,e),re.init(t,e)});function Hi(t){return $p(df,t)}var pf=_("ZodISODate",(t,e)=>{vd.init(t,e),re.init(t,e)});function Wi(t){return Pp(pf,t)}var ff=_("ZodISOTime",(t,e)=>{bd.init(t,e),re.init(t,e)});function Vi(t){return Tp(ff,t)}var mf=_("ZodISODuration",(t,e)=>{Ed.init(t,e),re.init(t,e)});function Ki(t){return zp(mf,t)}var uS=(t,e)=>{mo.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>rl(t,r)},flatten:{value:r=>tl(t,r)},addIssue:{value:r=>{t.issues.push(r),t.message=JSON.stringify(t.issues,dr,2)}},addIssues:{value:r=>{t.issues.push(...r),t.message=JSON.stringify(t.issues,dr,2)}},isEmpty:{get(){return t.issues.length===0}}})};var Me=_("ZodError",uS,{Parent:Error});var hf=ho(Me),gf=go(Me),_f=Jr(Me),yf=Yr(Me),Sf=nl(Me),vf=ol(Me),bf=sl(Me),Ef=il(Me),wf=al(Me),kf=cl(Me),xf=ul(Me),$f=ll(Me);var Pf=new WeakMap;function nn(t,e,r){let n=Object.getPrototypeOf(t),o=Pf.get(n);if(o||(o=new Set,Pf.set(n,o)),!o.has(e)){o.add(e);for(let s in r){let i=r[s];Object.defineProperty(n,s,{configurable:!0,enumerable:!1,get(){let a=i.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}var se=_("ZodType",(t,e)=>(G.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:en(t,"input"),output:en(t,"output")}}),t.toJSONSchema=Up(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.parse=(r,n)=>hf(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>_f(t,r,n),t.parseAsync=async(r,n)=>gf(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>yf(t,r,n),t.spa=t.safeParseAsync,t.encode=(r,n)=>Sf(t,r,n),t.decode=(r,n)=>vf(t,r,n),t.encodeAsync=async(r,n)=>bf(t,r,n),t.decodeAsync=async(r,n)=>Ef(t,r,n),t.safeEncode=(r,n)=>wf(t,r,n),t.safeDecode=(r,n)=>kf(t,r,n),t.safeEncodeAsync=async(r,n)=>xf(t,r,n),t.safeDecodeAsync=async(r,n)=>$f(t,r,n),nn(t,"ZodType",{check(...r){let n=this.def;return this.clone(L.mergeDefs(n,{checks:[...n.checks??[],...r.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,n){return Xe(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(QS(r,n))},superRefine(r,n){return this.check(ev(r,n))},overwrite(r){return this.check(Ot(r))},optional(){return oe(this)},exactOptional(){return qS(this)},nullable(){return If(this)},nullish(){return oe(If(this))},nonoptional(r){return KS(this,r)},array(){return N(this)},or(r){return Q([this,r])},and(r){return Ro(this,r)},transform(r){return Of(this,jf(r))},default(r){return HS(this,r)},prefault(r){return VS(this,r)},catch(r){return BS(this,r)},pipe(r){return Of(this,r)},readonly(){return XS(this)},describe(r){let n=this.clone();return Kt.add(n,{description:r}),n},meta(...r){if(r.length===0)return Kt.get(this);let n=this.clone();return Kt.add(n,r[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(t,"description",{get(){return Kt.get(t)?.description},configurable:!0}),t)),Af=_("_ZodString",(t,e)=>{Eo.init(t,e),se.init(t,e),t._zod.processJSONSchema=(n,o,s)=>qp(t,n,o,s);let r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,nn(t,"_ZodString",{regex(...n){return this.check(zi(...n))},includes(...n){return this.check(Oi(...n))},startsWith(...n){return this.check(Ai(...n))},endsWith(...n){return this.check(Ci(...n))},min(...n){return this.check(mr(...n))},max(...n){return this.check($o(...n))},length(...n){return this.check(Po(...n))},nonempty(...n){return this.check(mr(1,...n))},lowercase(n){return this.check(Ri(n))},uppercase(n){return this.check(Ii(n))},trim(){return this.check(Di())},normalize(...n){return this.check(Mi(...n))},toLowerCase(){return this.check(Ni())},toUpperCase(){return this.check(ji())},slugify(){return this.check(Li())}})}),dS=_("ZodString",(t,e)=>{Eo.init(t,e),Af.init(t,e),t.email=r=>t.check(sp(pS,r)),t.url=r=>t.check(lp(fS,r)),t.jwt=r=>t.check(xp(TS,r)),t.emoji=r=>t.check(dp(mS,r)),t.guid=r=>t.check(Ti(Tf,r)),t.uuid=r=>t.check(ip(zo,r)),t.uuidv4=r=>t.check(ap(zo,r)),t.uuidv6=r=>t.check(cp(zo,r)),t.uuidv7=r=>t.check(up(zo,r)),t.nanoid=r=>t.check(pp(hS,r)),t.guid=r=>t.check(Ti(Tf,r)),t.cuid=r=>t.check(fp(gS,r)),t.cuid2=r=>t.check(mp(_S,r)),t.ulid=r=>t.check(hp(yS,r)),t.base64=r=>t.check(Ep(xS,r)),t.base64url=r=>t.check(wp($S,r)),t.xid=r=>t.check(gp(SS,r)),t.ksuid=r=>t.check(_p(vS,r)),t.ipv4=r=>t.check(yp(bS,r)),t.ipv6=r=>t.check(Sp(ES,r)),t.cidrv4=r=>t.check(vp(wS,r)),t.cidrv6=r=>t.check(bp(kS,r)),t.e164=r=>t.check(kp(PS,r)),t.datetime=r=>t.check(Hi(r)),t.date=r=>t.check(Wi(r)),t.time=r=>t.check(Vi(r)),t.duration=r=>t.check(Ki(r))});function h(t){return op(dS,t)}var re=_("ZodStringFormat",(t,e)=>{X.init(t,e),Af.init(t,e)}),pS=_("ZodEmail",(t,e)=>{ld.init(t,e),re.init(t,e)});var Tf=_("ZodGUID",(t,e)=>{cd.init(t,e),re.init(t,e)});var zo=_("ZodUUID",(t,e)=>{ud.init(t,e),re.init(t,e)});var fS=_("ZodURL",(t,e)=>{dd.init(t,e),re.init(t,e)});var mS=_("ZodEmoji",(t,e)=>{pd.init(t,e),re.init(t,e)});var hS=_("ZodNanoID",(t,e)=>{fd.init(t,e),re.init(t,e)});var gS=_("ZodCUID",(t,e)=>{md.init(t,e),re.init(t,e)});var _S=_("ZodCUID2",(t,e)=>{hd.init(t,e),re.init(t,e)});var yS=_("ZodULID",(t,e)=>{gd.init(t,e),re.init(t,e)});var SS=_("ZodXID",(t,e)=>{_d.init(t,e),re.init(t,e)});var vS=_("ZodKSUID",(t,e)=>{yd.init(t,e),re.init(t,e)});var bS=_("ZodIPv4",(t,e)=>{wd.init(t,e),re.init(t,e)});var ES=_("ZodIPv6",(t,e)=>{kd.init(t,e),re.init(t,e)});var wS=_("ZodCIDRv4",(t,e)=>{xd.init(t,e),re.init(t,e)});var kS=_("ZodCIDRv6",(t,e)=>{$d.init(t,e),re.init(t,e)});var xS=_("ZodBase64",(t,e)=>{Td.init(t,e),re.init(t,e)});var $S=_("ZodBase64URL",(t,e)=>{zd.init(t,e),re.init(t,e)});var PS=_("ZodE164",(t,e)=>{Rd.init(t,e),re.init(t,e)});var TS=_("ZodJWT",(t,e)=>{Id.init(t,e),re.init(t,e)});var Cf=_("ZodNumber",(t,e)=>{wi.init(t,e),se.init(t,e),t._zod.processJSONSchema=(n,o,s)=>Zp(t,n,o,s),nn(t,"ZodNumber",{gt(n,o){return this.check(ko(n,o))},gte(n,o){return this.check(Qr(n,o))},min(n,o){return this.check(Qr(n,o))},lt(n,o){return this.check(wo(n,o))},lte(n,o){return this.check(Xr(n,o))},max(n,o){return this.check(Xr(n,o))},int(n){return this.check(zf(n))},safe(n){return this.check(zf(n))},positive(n){return this.check(ko(0,n))},nonnegative(n){return this.check(Qr(0,n))},negative(n){return this.check(wo(0,n))},nonpositive(n){return this.check(Xr(0,n))},multipleOf(n,o){return this.check(xo(n,o))},step(n,o){return this.check(xo(n,o))},finite(){return this}});let r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null});function W(t){return Rp(Cf,t)}var zS=_("ZodNumberFormat",(t,e)=>{Od.init(t,e),Cf.init(t,e)});function zf(t){return Ip(zS,t)}var RS=_("ZodBoolean",(t,e)=>{Ad.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Fp(t,r,n,o)});function pe(t){return Op(RS,t)}var IS=_("ZodNull",(t,e)=>{Cd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Hp(t,r,n,o)});function Mf(t){return Ap(IS,t)}var OS=_("ZodUnknown",(t,e)=>{Md.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Vp(t,r,n,o)});function ne(){return Cp(OS)}var AS=_("ZodNever",(t,e)=>{Dd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Wp(t,r,n,o)});function CS(t){return Mp(AS,t)}var MS=_("ZodArray",(t,e)=>{Nd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Gp(t,r,n,o),t.element=e.element,nn(t,"ZodArray",{min(r,n){return this.check(mr(r,n))},nonempty(r){return this.check(mr(1,r))},max(r,n){return this.check($o(r,n))},length(r,n){return this.check(Po(r,n))},unwrap(){return this.element}})});function N(t,e){return Dp(MS,t,e)}var Df=_("ZodObject",(t,e)=>{Ud.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Xp(t,r,n,o),L.defineLazy(t,"shape",()=>e.shape),nn(t,"ZodObject",{keyof(){return Te(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:ne()})},loose(){return this.clone({...this._zod.def,catchall:ne()})},strict(){return this.clone({...this._zod.def,catchall:CS()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return L.extend(this,r)},safeExtend(r){return L.safeExtend(this,r)},merge(r){return L.merge(this,r)},pick(r){return L.pick(this,r)},omit(r){return L.omit(this,r)},partial(...r){return L.partial(Lf,this,r[0])},required(...r){return L.required(Uf,this,r[0])}})});function w(t,e){let r={type:"object",shape:t??{},...L.normalizeParams(e)};return new Df(r)}function ke(t,e){return new Df({type:"object",shape:t,catchall:ne(),...L.normalizeParams(e)})}var Nf=_("ZodUnion",(t,e)=>{ki.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Qp(t,r,n,o),t.options=e.options});function Q(t,e){return new Nf({type:"union",options:t,...L.normalizeParams(e)})}var DS=_("ZodDiscriminatedUnion",(t,e)=>{Nf.init(t,e),qd.init(t,e)});function Bi(t,e,r){return new DS({type:"union",options:e,discriminator:t,...L.normalizeParams(r)})}var NS=_("ZodIntersection",(t,e)=>{Zd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>ef(t,r,n,o)});function Ro(t,e){return new NS({type:"intersection",left:t,right:e})}var Rf=_("ZodRecord",(t,e)=>{Fd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>tf(t,r,n,o),t.keyType=e.keyType,t.valueType=e.valueType});function Y(t,e,r){return!e||!e._zod?new Rf({type:"record",keyType:h(),valueType:t,...L.normalizeParams(e)}):new Rf({type:"record",keyType:t,valueType:e,...L.normalizeParams(r)})}var Ji=_("ZodEnum",(t,e)=>{Hd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(n,o,s)=>Kp(t,n,o,s),t.enum=e.entries,t.options=Object.values(e.entries);let r=new Set(Object.keys(e.entries));t.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Ji({...e,checks:[],...L.normalizeParams(o),entries:s})},t.exclude=(n,o)=>{let s={...e.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new Ji({...e,checks:[],...L.normalizeParams(o),entries:s})}});function Te(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new Ji({type:"enum",entries:r,...L.normalizeParams(e)})}var jS=_("ZodLiteral",(t,e)=>{Wd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Jp(t,r,n,o),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function P(t,e){return new jS({type:"literal",values:Array.isArray(t)?t:[t],...L.normalizeParams(e)})}var LS=_("ZodTransform",(t,e)=>{Vd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Yp(t,r,n,o),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new ur(t.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(L.issue(s,r.value,e));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=t),r.issues.push(L.issue(i))}};let o=e.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r.fallback=!0,r)):(r.value=o,r.fallback=!0,r)}});function jf(t){return new LS({type:"transform",transform:t})}var Lf=_("ZodOptional",(t,e)=>{xi.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Fi(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function oe(t){return new Lf({type:"optional",innerType:t})}var US=_("ZodExactOptional",(t,e)=>{Kd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Fi(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function qS(t){return new US({type:"optional",innerType:t})}var ZS=_("ZodNullable",(t,e)=>{Jd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>rf(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function If(t){return new ZS({type:"nullable",innerType:t})}var FS=_("ZodDefault",(t,e)=>{Bd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>of(t,r,n,o),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function HS(t,e){return new FS({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():L.shallowClone(e)}})}var WS=_("ZodPrefault",(t,e)=>{Yd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>sf(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function VS(t,e){return new WS({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():L.shallowClone(e)}})}var Uf=_("ZodNonOptional",(t,e)=>{Gd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>nf(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function KS(t,e){return new Uf({type:"nonoptional",innerType:t,...L.normalizeParams(e)})}var JS=_("ZodCatch",(t,e)=>{Xd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>af(t,r,n,o),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function BS(t,e){return new JS({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var qf=_("ZodPipe",(t,e)=>{$i.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>cf(t,r,n,o),t.in=e.in,t.out=e.out});function Of(t,e){return new qf({type:"pipe",in:t,out:e})}var YS=_("ZodPreprocess",(t,e)=>{qf.init(t,e),Qd.init(t,e)}),GS=_("ZodReadonly",(t,e)=>{ep.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>uf(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function XS(t){return new GS({type:"readonly",innerType:t})}var Zf=_("ZodCustom",(t,e)=>{tp.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Bp(t,r,n,o)});function Ff(t,e){return Np(Zf,t??(()=>!0),e)}function QS(t,e={}){return jp(Zf,t,e)}function ev(t,e){return Lp(t,e)}function Yi(t,e){return new YS({type:"pipe",in:jf(t),out:e})}Ce(rp());var Xi="2025-11-25";var Hf=[Xi,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Ct="io.modelcontextprotocol/related-task",Oo="2.0",le=Ff(t=>t!==null&&(typeof t=="object"||typeof t=="function")),Wf=Q([h(),W().int()]),Vf=h(),BR=ke({ttl:W().optional(),pollInterval:W().optional()}),tv=w({ttl:W().optional()}),rv=w({taskId:h()}),Qi=ke({progressToken:Wf.optional(),[Ct]:rv.optional()}),De=w({_meta:Qi.optional()}),on=De.extend({task:tv.optional()}),Kf=t=>on.safeParse(t).success,me=w({method:h(),params:De.loose().optional()}),Ue=w({_meta:Qi.optional()}),qe=w({method:h(),params:Ue.loose().optional()}),he=ke({_meta:Qi.optional()}),Ao=Q([h(),W().int()]),Jf=w({jsonrpc:P(Oo),id:Ao,...me.shape}).strict(),ea=t=>Jf.safeParse(t).success,Bf=w({jsonrpc:P(Oo),...qe.shape}).strict(),Yf=t=>Bf.safeParse(t).success,ta=w({jsonrpc:P(Oo),id:Ao,result:he}).strict(),sn=t=>ta.safeParse(t).success;var D;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(D||(D={}));var ra=w({jsonrpc:P(Oo),id:Ao.optional(),error:w({code:W().int(),message:h(),data:ne().optional()})}).strict();var Gf=t=>ra.safeParse(t).success;var Xf=Q([Jf,Bf,ta,ra]),YR=Q([ta,ra]),Co=he.strict(),nv=Ue.extend({requestId:Ao.optional(),reason:h().optional()}),Mo=qe.extend({method:P("notifications/cancelled"),params:nv}),ov=w({src:h(),mimeType:h().optional(),sizes:N(h()).optional(),theme:Te(["light","dark"]).optional()}),an=w({icons:N(ov).optional()}),gr=w({name:h(),title:h().optional()}),Qf=gr.extend({...gr.shape,...an.shape,version:h(),websiteUrl:h().optional(),description:h().optional()}),sv=Ro(w({applyDefaults:pe().optional()}),Y(h(),ne())),iv=Yi(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,Ro(w({form:sv.optional(),url:le.optional()}),Y(h(),ne()).optional())),av=ke({list:le.optional(),cancel:le.optional(),requests:ke({sampling:ke({createMessage:le.optional()}).optional(),elicitation:ke({create:le.optional()}).optional()}).optional()}),cv=ke({list:le.optional(),cancel:le.optional(),requests:ke({tools:ke({call:le.optional()}).optional()}).optional()}),uv=w({experimental:Y(h(),le).optional(),sampling:w({context:le.optional(),tools:le.optional()}).optional(),elicitation:iv.optional(),roots:w({listChanged:pe().optional()}).optional(),tasks:av.optional(),extensions:Y(h(),le).optional()}),lv=De.extend({protocolVersion:h(),capabilities:uv,clientInfo:Qf}),na=me.extend({method:P("initialize"),params:lv});var dv=w({experimental:Y(h(),le).optional(),logging:le.optional(),completions:le.optional(),prompts:w({listChanged:pe().optional()}).optional(),resources:w({subscribe:pe().optional(),listChanged:pe().optional()}).optional(),tools:w({listChanged:pe().optional()}).optional(),tasks:cv.optional(),extensions:Y(h(),le).optional()}),pv=he.extend({protocolVersion:h(),capabilities:dv,serverInfo:Qf,instructions:h().optional()}),oa=qe.extend({method:P("notifications/initialized"),params:Ue.optional()});var Do=me.extend({method:P("ping"),params:De.optional()}),fv=w({progress:W(),total:oe(W()),message:oe(h())}),mv=w({...Ue.shape,...fv.shape,progressToken:Wf}),No=qe.extend({method:P("notifications/progress"),params:mv}),hv=De.extend({cursor:Vf.optional()}),cn=me.extend({params:hv.optional()}),un=he.extend({nextCursor:Vf.optional()}),gv=Te(["working","input_required","completed","failed","cancelled"]),ln=w({taskId:h(),status:gv,ttl:Q([W(),Mf()]),createdAt:h(),lastUpdatedAt:h(),pollInterval:oe(W()),statusMessage:oe(h())}),_r=he.extend({task:ln}),_v=Ue.merge(ln),dn=qe.extend({method:P("notifications/tasks/status"),params:_v}),jo=me.extend({method:P("tasks/get"),params:De.extend({taskId:h()})}),Lo=he.merge(ln),Uo=me.extend({method:P("tasks/result"),params:De.extend({taskId:h()})}),GR=he.loose(),qo=cn.extend({method:P("tasks/list")}),Zo=un.extend({tasks:N(ln)}),Fo=me.extend({method:P("tasks/cancel"),params:De.extend({taskId:h()})}),em=he.merge(ln),tm=w({uri:h(),mimeType:oe(h()),_meta:Y(h(),ne()).optional()}),rm=tm.extend({text:h()}),sa=h().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),nm=tm.extend({blob:sa}),pn=Te(["user","assistant"]),yr=w({audience:N(pn).optional(),priority:W().min(0).max(1).optional(),lastModified:rn.datetime({offset:!0}).optional()}),om=w({...gr.shape,...an.shape,uri:h(),description:oe(h()),mimeType:oe(h()),size:oe(W()),annotations:yr.optional(),_meta:oe(ke({}))}),yv=w({...gr.shape,...an.shape,uriTemplate:h(),description:oe(h()),mimeType:oe(h()),annotations:yr.optional(),_meta:oe(ke({}))}),Sv=cn.extend({method:P("resources/list")}),vv=un.extend({resources:N(om)}),bv=cn.extend({method:P("resources/templates/list")}),Ev=un.extend({resourceTemplates:N(yv)}),ia=De.extend({uri:h()}),wv=ia,kv=me.extend({method:P("resources/read"),params:wv}),xv=he.extend({contents:N(Q([rm,nm]))}),$v=qe.extend({method:P("notifications/resources/list_changed"),params:Ue.optional()}),Pv=ia,Tv=me.extend({method:P("resources/subscribe"),params:Pv}),zv=ia,Rv=me.extend({method:P("resources/unsubscribe"),params:zv}),Iv=Ue.extend({uri:h()}),Ov=qe.extend({method:P("notifications/resources/updated"),params:Iv}),Av=w({name:h(),description:oe(h()),required:oe(pe())}),Cv=w({...gr.shape,...an.shape,description:oe(h()),arguments:oe(N(Av)),_meta:oe(ke({}))}),Mv=cn.extend({method:P("prompts/list")}),Dv=un.extend({prompts:N(Cv)}),Nv=De.extend({name:h(),arguments:Y(h(),h()).optional()}),jv=me.extend({method:P("prompts/get"),params:Nv}),aa=w({type:P("text"),text:h(),annotations:yr.optional(),_meta:Y(h(),ne()).optional()}),ca=w({type:P("image"),data:sa,mimeType:h(),annotations:yr.optional(),_meta:Y(h(),ne()).optional()}),ua=w({type:P("audio"),data:sa,mimeType:h(),annotations:yr.optional(),_meta:Y(h(),ne()).optional()}),Lv=w({type:P("tool_use"),name:h(),id:h(),input:Y(h(),ne()),_meta:Y(h(),ne()).optional()}),Uv=w({type:P("resource"),resource:Q([rm,nm]),annotations:yr.optional(),_meta:Y(h(),ne()).optional()}),qv=om.extend({type:P("resource_link")}),la=Q([aa,ca,ua,qv,Uv]),Zv=w({role:pn,content:la}),Fv=he.extend({description:h().optional(),messages:N(Zv)}),Hv=qe.extend({method:P("notifications/prompts/list_changed"),params:Ue.optional()}),Wv=w({title:h().optional(),readOnlyHint:pe().optional(),destructiveHint:pe().optional(),idempotentHint:pe().optional(),openWorldHint:pe().optional()}),Vv=w({taskSupport:Te(["required","optional","forbidden"]).optional()}),sm=w({...gr.shape,...an.shape,description:h().optional(),inputSchema:w({type:P("object"),properties:Y(h(),le).optional(),required:N(h()).optional()}).catchall(ne()),outputSchema:w({type:P("object"),properties:Y(h(),le).optional(),required:N(h()).optional()}).catchall(ne()).optional(),annotations:Wv.optional(),execution:Vv.optional(),_meta:Y(h(),ne()).optional()}),da=cn.extend({method:P("tools/list")}),Kv=un.extend({tools:N(sm)}),Ho=he.extend({content:N(la).default([]),structuredContent:Y(h(),ne()).optional(),isError:pe().optional()}),XR=Ho.or(he.extend({toolResult:ne()})),Jv=on.extend({name:h(),arguments:Y(h(),ne()).optional()}),fn=me.extend({method:P("tools/call"),params:Jv}),Bv=qe.extend({method:P("notifications/tools/list_changed"),params:Ue.optional()}),QR=w({autoRefresh:pe().default(!0),debounceMs:W().int().nonnegative().default(300)}),mn=Te(["debug","info","notice","warning","error","critical","alert","emergency"]),Yv=De.extend({level:mn}),pa=me.extend({method:P("logging/setLevel"),params:Yv}),Gv=Ue.extend({level:mn,logger:h().optional(),data:ne()}),Xv=qe.extend({method:P("notifications/message"),params:Gv}),Qv=w({name:h().optional()}),eb=w({hints:N(Qv).optional(),costPriority:W().min(0).max(1).optional(),speedPriority:W().min(0).max(1).optional(),intelligencePriority:W().min(0).max(1).optional()}),tb=w({mode:Te(["auto","required","none"]).optional()}),rb=w({type:P("tool_result"),toolUseId:h().describe("The unique identifier for the corresponding tool call."),content:N(la).default([]),structuredContent:w({}).loose().optional(),isError:pe().optional(),_meta:Y(h(),ne()).optional()}),nb=Bi("type",[aa,ca,ua]),Io=Bi("type",[aa,ca,ua,Lv,rb]),ob=w({role:pn,content:Q([Io,N(Io)]),_meta:Y(h(),ne()).optional()}),sb=on.extend({messages:N(ob),modelPreferences:eb.optional(),systemPrompt:h().optional(),includeContext:Te(["none","thisServer","allServers"]).optional(),temperature:W().optional(),maxTokens:W().int(),stopSequences:N(h()).optional(),metadata:le.optional(),tools:N(sm).optional(),toolChoice:tb.optional()}),ib=me.extend({method:P("sampling/createMessage"),params:sb}),hn=he.extend({model:h(),stopReason:oe(Te(["endTurn","stopSequence","maxTokens"]).or(h())),role:pn,content:nb}),fa=he.extend({model:h(),stopReason:oe(Te(["endTurn","stopSequence","maxTokens","toolUse"]).or(h())),role:pn,content:Q([Io,N(Io)])}),ab=w({type:P("boolean"),title:h().optional(),description:h().optional(),default:pe().optional()}),cb=w({type:P("string"),title:h().optional(),description:h().optional(),minLength:W().optional(),maxLength:W().optional(),format:Te(["email","uri","date","date-time"]).optional(),default:h().optional()}),ub=w({type:Te(["number","integer"]),title:h().optional(),description:h().optional(),minimum:W().optional(),maximum:W().optional(),default:W().optional()}),lb=w({type:P("string"),title:h().optional(),description:h().optional(),enum:N(h()),default:h().optional()}),db=w({type:P("string"),title:h().optional(),description:h().optional(),oneOf:N(w({const:h(),title:h()})),default:h().optional()}),pb=w({type:P("string"),title:h().optional(),description:h().optional(),enum:N(h()),enumNames:N(h()).optional(),default:h().optional()}),fb=Q([lb,db]),mb=w({type:P("array"),title:h().optional(),description:h().optional(),minItems:W().optional(),maxItems:W().optional(),items:w({type:P("string"),enum:N(h())}),default:N(h()).optional()}),hb=w({type:P("array"),title:h().optional(),description:h().optional(),minItems:W().optional(),maxItems:W().optional(),items:w({anyOf:N(w({const:h(),title:h()}))}),default:N(h()).optional()}),gb=Q([mb,hb]),_b=Q([pb,fb,gb]),yb=Q([_b,ab,cb,ub]),Sb=on.extend({mode:P("form").optional(),message:h(),requestedSchema:w({type:P("object"),properties:Y(h(),yb),required:N(h()).optional()})}),vb=on.extend({mode:P("url"),message:h(),elicitationId:h(),url:h().url()}),bb=Q([Sb,vb]),Eb=me.extend({method:P("elicitation/create"),params:bb}),wb=Ue.extend({elicitationId:h()}),kb=qe.extend({method:P("notifications/elicitation/complete"),params:wb}),Sr=he.extend({action:Te(["accept","decline","cancel"]),content:Yi(t=>t===null?void 0:t,Y(h(),Q([h(),W(),pe(),N(h())])).optional())}),xb=w({type:P("ref/resource"),uri:h()});var $b=w({type:P("ref/prompt"),name:h()}),Pb=De.extend({ref:Q([$b,xb]),argument:w({name:h(),value:h()}),context:w({arguments:Y(h(),h()).optional()}).optional()}),Tb=me.extend({method:P("completion/complete"),params:Pb});var zb=he.extend({completion:ke({values:N(h()).max(100),total:oe(W().int()),hasMore:oe(pe())})}),Rb=w({uri:h().startsWith("file://"),name:h().optional(),_meta:Y(h(),ne()).optional()}),Ib=me.extend({method:P("roots/list"),params:De.optional()}),ma=he.extend({roots:N(Rb)}),Ob=qe.extend({method:P("notifications/roots/list_changed"),params:Ue.optional()}),eI=Q([Do,na,Tb,pa,jv,Mv,Sv,bv,kv,Tv,Rv,fn,da,jo,Uo,qo,Fo]),tI=Q([Mo,No,oa,Ob,dn]),rI=Q([Co,hn,fa,Sr,ma,Lo,Zo,_r]),nI=Q([Do,ib,Eb,Ib,jo,Uo,qo,Fo]),oI=Q([Mo,No,Xv,Ov,$v,Bv,Hv,dn,kb]),sI=Q([Co,pv,zb,Fv,Dv,vv,Ev,xv,Ho,Kv,Lo,Zo,_r]),I=class t extends Error{constructor(e,r,n){super(`MCP error ${e}: ${r}`),this.code=e,this.data=n,this.name="McpError"}static fromError(e,r,n){if(e===D.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new Gi(o.elicitations,r)}return new t(e,r,n)}},Gi=class extends I{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(D.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function Mt(t){return t==="completed"||t==="failed"||t==="cancelled"}var jI=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function ha(t){let r=To(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=lf(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function ga(t,e){let r=At(t,e);if(!r.success)throw r.error;return r.data}var jb=6e4,Wo=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Mo,r=>{this._oncancel(r)}),this.setNotificationHandler(No,r=>{this._onprogress(r)}),this.setRequestHandler(Do,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(jo,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new I(D.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(Uo,async(r,n)=>{let o=async()=>{let s=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,p=new I(d.error.code,d.error.message,d.error.data);l(p)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new I(D.InvalidParams,`Task not found: ${s}`);if(!Mt(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(Mt(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[Ct]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(qo,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(D.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Fo,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new I(D.InvalidParams,`Task not found: ${r.params.taskId}`);if(Mt(o.status))throw new I(D.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(D.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof I?o:new I(D.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,n,o,s=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),I.fromError(D.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),sn(s)||Gf(s)?this._onresponse(s):ea(s)?this._onrequest(s,i):Yf(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=I.fromError(D.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of e.values())n(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(e,r){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,o=this._transport,s=e.params?._meta?.[Ct]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:D.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);let a=Kf(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let d={relatedRequestId:e.id};s&&(d.relatedTask={taskId:s}),await this.notification(l,d)},sendRequest:async(l,d,p)=>{if(i.signal.aborted)throw new I(D.ConnectionClosed,"Request was cancelled");let f={...p,relatedRequestId:e.id};s&&!f.relatedTask&&(f.relatedTask={taskId:s});let m=f.relatedTask?.taskId??s;return m&&c&&await c.updateTaskStatus(m,"input_required"),await this.request(l,d,f)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,u)).then(async l=>{if(i.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:e.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:D.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===i&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...n}=e.params,o=Number(r),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(n)}_onresponse(e){let r=Number(e.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),sn(e))n(e);else{let i=new I(e.error.code,e.error.message,e.error.data);n(i)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if(sn(e)&&e.result&&typeof e.result=="object"){let i=e.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,r))}}if(s||this._progressHandlers.delete(r),sn(e))o(e);else{let i=I.fromError(e.error.code,e.error.message,e.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(e,r,n)}}catch(i){yield{type:"error",error:i instanceof I?i:new I(D.InternalError,String(i))}}return}let s;try{let i=await this.request(e,_r,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new I(D.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},Mt(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(D.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new I(D.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(D.InternalError,String(i))}}}request(e,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=x=>{l(x)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(x){d(x);return}n?.signal?.throwIfAborted();let p=this._requestMessageId++,f={...e,jsonrpc:"2.0",id:p};n?.onprogress&&(this._progressHandlers.set(p,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:p}}),a&&(f.params={...f.params,task:a}),c&&(f.params={...f.params,_meta:{...f.params?._meta||{},[Ct]:c}});let m=x=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(x)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch($=>this._onerror(new Error(`Failed to send cancellation: ${$}`)));let b=x instanceof I?x:new I(D.RequestTimeout,String(x));l(b)};this._responseHandlers.set(p,x=>{if(!n?.signal?.aborted){if(x instanceof Error)return l(x);try{let b=At(r,x.result);b.success?u(b.data):l(b.error)}catch(b){l(b)}}}),n?.signal?.addEventListener("abort",()=>{m(n?.signal?.reason)});let g=n?.timeout??jb,S=()=>m(I.fromError(D.RequestTimeout,"Request timed out",{timeout:g}));this._setupTimeout(p,g,n?.maxTotalTimeout,S,n?.resetTimeoutOnProgress??!1);let v=c?.taskId;if(v){let x=b=>{let $=this._responseHandlers.get(p);$?$(b):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,x),this._enqueueTaskMessage(v,{type:"request",message:f,timestamp:Date.now()}).catch(b=>{this._cleanupTimeout(p),l(b)})}else this._transport.send(f,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(x=>{this._cleanupTimeout(p),l(x)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Lo,r)}async getTaskResult(e,r,n){return this.request({method:"tasks/result",params:e},r,n)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},Zo,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},em,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let n=r?.relatedTask?.taskId;if(n){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[Ct]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Ct]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[Ct]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let n=ha(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=ga(e,o);return Promise.resolve(r(i,s))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){let n=ha(e);this._notificationHandlers.set(n,o=>{let s=ga(e,o);return Promise.resolve(r(s))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,n,o)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,r);for(let o of n)if(o.type==="request"&&ea(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new I(D.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(e);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new I(D.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new I(D.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!e)throw new Error("No request provided");return await n.createTask(o,e.id,{method:e.method,params:e.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new I(D.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(o,s,i)=>{await n.storeTaskResult(o,s,i,r);let a=await n.getTask(o,r);if(a){let c=dn.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Mt(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(D.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Mt(a.status))throw new I(D.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(o,s,i,r);let c=await n.getTask(o,r);if(c){let u=dn.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Mt(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function im(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function am(t,e){let r={...t};for(let n in e){let o=n,s=e[o];if(s===void 0)continue;let i=r[o];im(i)&&im(s)?r[o]={...i,...s}:r[o]=s}return r}var Xg=Tt(ru(),1),Qg=Tt(Gg(),1);function q$(){let t=new Xg.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,Qg.default)(t),t}var $s=class{constructor(e){this._ajv=e??q$()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var Ps=class{constructor(e){this._server=e}requestStream(e,r,n){return this._server.requestStream(e,r,n)}createMessageStream(e,r){let n=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let o=e.messages[e.messages.length-1],s=Array.isArray(o.content)?o.content:[o.content],i=s.some(l=>l.type==="tool_result"),a=e.messages.length>1?e.messages[e.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(p=>p.type==="tool_use").map(p=>p.id)),d=new Set(s.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(l.size!==d.size||![...l].every(p=>d.has(p)))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:e},hn,r)}elicitInputStream(e,r){let n=this._server.getClientCapabilities(),o=e.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"&&e.mode===void 0?{...e,mode:"form"}:e;return this.requestStream({method:"elicitation/create",params:s},Sr,r)}async getTask(e,r){return this._server.getTask({taskId:e},r)}async getTaskResult(e,r,n){return this._server.getTaskResult({taskId:e},r,n)}async listTasks(e,r){return this._server.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._server.cancelTask({taskId:e},r)}};function e_(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function t_(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}var Ts=class extends Wo{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(mn.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 $s,this.setRequestHandler(na,n=>this._oninitialize(n)),this.setNotificationHandler(oa,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(pa,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=mn.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Ps(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=am(this._capabilities,e)}setRequestHandler(e,r){let o=To(e)?.method;if(!o)throw new Error("Schema is missing a method literal");let s;if(hr(o)){let a=o;s=a._zod?.def?.value??a.value}else{let a=o;s=a._def?.value??a.value}if(typeof s!="string")throw new Error("Schema method literal must be a string");if(s==="tools/call"){let a=async(c,u)=>{let l=At(fn,c);if(!l.success){let m=l.error instanceof Error?l.error.message:String(l.error);throw new I(D.InvalidParams,`Invalid tools/call request: ${m}`)}let{params:d}=l.data,p=await Promise.resolve(r(c,u));if(d.task){let m=At(_r,p);if(!m.success){let g=m.error instanceof Error?m.error.message:String(m.error);throw new I(D.InvalidParams,`Invalid task creation result: ${g}`)}return m.data}let f=At(Ho,p);if(!f.success){let m=f.error instanceof Error?f.error.message:String(f.error);throw new I(D.InvalidParams,`Invalid tools/call result: ${m}`)}return f.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,r)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);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 ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);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 ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);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 ${e})`);break;case"ping":case"initialize":break}}assertTaskCapability(e){t_(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&e_(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){let r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:Hf.includes(r)?r:Xi,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"},Co)}async createMessage(e,r){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let n=e.messages[e.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],s=o.some(u=>u.type==="tool_result"),i=e.messages.length>1?e.messages[e.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 e.tools?this.request({method:"sampling/createMessage",params:e},fa,r):this.request({method:"sampling/createMessage",params:e},hn,r)}async elicitInput(e,r){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=e;return this.request({method:"elicitation/create",params:o},Sr,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=e.mode==="form"?e:{...e,mode:"form"},s=await this.request({method:"elicitation/create",params:o},Sr,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new I(D.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof I?i:new I(D.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return s}}}createElicitationCompletionNotifier(e,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:e}},r)}async listRoots(e,r){return this.request({method:"roots/list",params:e},ma,r)}async sendLoggingMessage(e,r){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,r))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}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 lu=Tt(require("node:process"),1);var zs=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
|
|
84
|
-
`);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),
|
|
85
|
-
`}var Rs=class{constructor(e=lu.default.stdin,r=lu.default.stdout){this._stdin=e,this._stdout=r,this._readBuffer=new zs,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}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(e){return new Promise(r=>{let n=r_(e);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};var Pe=Tt(require("path"),1),Ae=require("fs");var du=require("node:child_process");function Is(t,e,r){return(0,du.spawn)(t,e??[],{windowsHide:!0,...r})}var F$=new Set([".cmd",".bat"]),H$=new Set([".exe",".com"]),fD=new Set([...H$,...F$]);ue();var de={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 Ht(t){return process.platform==="win32"?Math.round(t*de.WINDOWS_MULTIPLIER):t}var Os=require("fs"),pu=require("path"),Vn=require("os");so();var ot=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(Ht(de.API_REQUEST)),CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_PROVIDER:"claude",CLAUDE_MEM_CLAUDE_AUTH_METHOD:"subscription",CLAUDE_MEM_GEMINI_API_KEY:"",CLAUDE_MEM_GEMINI_MODEL:"gemini-2.5-flash-lite",CLAUDE_MEM_GEMINI_RATE_LIMITING_ENABLED:"true",CLAUDE_MEM_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,pu.join)((0,Vn.homedir)(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_MODE:"code",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"false",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"false",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"false",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_FULL_COUNT:"0",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false",CLAUDE_MEM_CONTEXT_SHOW_TERMINAL_OUTPUT:"true",CLAUDE_MEM_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,pu.join)((0,Vn.homedir)(),".claude-mem","transcript-watch.json"),CLAUDE_MEM_CODEX_TRANSCRIPT_INGESTION:"false",CLAUDE_MEM_MAX_CONCURRENT_AGENTS:"2",CLAUDE_MEM_HOOK_FAIL_LOUD_THRESHOLD:"3",CLAUDE_MEM_EXCLUDED_PROJECTS:"",CLAUDE_MEM_FOLDER_MD_EXCLUDE:"[]",CLAUDE_MEM_FOLDER_MD_SKELETON_DENYLIST:"[]",CLAUDE_MEM_SEMANTIC_INJECT:"false",CLAUDE_MEM_SEMANTIC_INJECT_LIMIT:"5",CLAUDE_MEM_TIER_ROUTING_ENABLED:"true",CLAUDE_MEM_TIER_SIMPLE_MODEL:"haiku",CLAUDE_MEM_TIER_SUMMARY_MODEL:"",CLAUDE_MEM_TIER_FAST_MODEL:"haiku",CLAUDE_MEM_TIER_SMART_MODEL:"sonnet",CLAUDE_MEM_CHROMA_ENABLED:"true",CLAUDE_MEM_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_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,Vn.hostname)(),CLAUDE_MEM_CLOUD_SYNC_WS:"true",CLAUDE_MEM_TELEGRAM_ENABLED:"true",CLAUDE_MEM_TELEGRAM_BOT_TOKEN:"",CLAUDE_MEM_TELEGRAM_CHAT_ID:"",CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES:"security_alert",CLAUDE_MEM_TELEGRAM_TRIGGER_CONCEPTS:"",CLAUDE_MEM_QUEUE_ENGINE:"sqlite",CLAUDE_MEM_REDIS_URL:"",CLAUDE_MEM_REDIS_HOST:"127.0.0.1",CLAUDE_MEM_REDIS_PORT:"6379",CLAUDE_MEM_REDIS_MODE:"external",CLAUDE_MEM_QUEUE_REDIS_PREFIX:`claude_mem_${process.env.CLAUDE_MEM_WORKER_PORT??String(37700+(process.getuid?.()??77)%100)}`,CLAUDE_MEM_AUTH_MODE:"api-key",CLAUDE_MEM_RUNTIME:"worker",CLAUDE_MEM_SERVER_URL:`http://127.0.0.1:${process.env.CLAUDE_MEM_SERVER_PORT??String(37877+(process.getuid?.()??77)%100)}`,CLAUDE_MEM_SERVER_API_KEY:"",CLAUDE_MEM_SERVER_PROJECT_ID:"",CLAUDE_MEM_SERVER_BETA_URL:`http://127.0.0.1:${process.env.CLAUDE_MEM_SERVER_PORT??String(37877+(process.getuid?.()??77)%100)}`,CLAUDE_MEM_SERVER_BETA_API_KEY:"",CLAUDE_MEM_SERVER_BETA_PROJECT_ID:""};static getAllDefaults(){return{...this.DEFAULTS}}static get(e){return process.env[e]??this.DEFAULTS[e]}static getInt(e){let r=this.get(e);return parseInt(r,10)}static applyEnvOverrides(e){let r={...e};for(let n of Object.keys(this.DEFAULTS))process.env[n]!==void 0&&(r[n]=process.env[n]);return r}static loadFromFile(e,r=!0){try{if(!(0,Os.existsSync)(e)){let a=this.getAllDefaults();try{ti(e,a),console.warn("[SETTINGS] Created settings file with defaults:",e)}catch(c){console.warn("[SETTINGS] Failed to create settings file, using in-memory defaults:",e,c instanceof Error?c.message:String(c))}return r?this.applyEnvOverrides(a):a}let n=(0,Os.readFileSync)(e,"utf-8"),o=cr(n),s=o;if(o.env&&typeof o.env=="object"){s=o.env;try{ti(e,s),console.warn("[SETTINGS] Migrated settings file from nested to flat schema:",e)}catch(a){console.warn("[SETTINGS] Failed to auto-migrate settings file:",e,a instanceof Error?a.message:String(a))}}let i={...this.DEFAULTS};for(let a of Object.keys(this.DEFAULTS))s[a]!==void 0&&(i[a]=s[a]);return r?this.applyEnvOverrides(i):i}catch(n){console.warn("[SETTINGS] Failed to load settings, using defaults:",e,n instanceof Error?n.message:String(n));let o=this.getAllDefaults();return r?this.applyEnvOverrides(o):o}}};Ge();Ge();var As=null;function Cs(){return As!==null||(As=ot.loadFromFile(co)),As}var sr=require("fs");ue();var _u=require("child_process");var gt=require("fs"),hu=Tt(require("path"),1);ue();var W$=["CLAUDECODE_","CLAUDE_CODE_"],V$=new Set(["CLAUDECODE","CLAUDE_CODE_SESSION","CLAUDE_CODE_ENTRYPOINT","MCP_SESSION_ID"]),K$=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"]),J$=new Set(["CLAUDE_CODE_OAUTH_TOKEN","CLAUDE_CODE_GIT_BASH_PATH","CLAUDE_CODE_USE_BEDROCK","CLAUDE_CODE_USE_VERTEX","CLAUDE_CODE_SKIP_BEDROCK_AUTH","CLAUDE_CODE_SKIP_VERTEX_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",...K$]);function Kn(t=process.env){let e={};for(let[r,n]of Object.entries(t))if(n!==void 0){if(J$.has(r)){e[r]=n;continue}V$.has(r)||W$.some(o=>r.startsWith(o))||(e[r]=n)}return e}Ge();var B$=5e3,Y$=1e3,G$=je.supervisorRegistry();function ht(t){if(!Number.isInteger(t)||t<0||t===0)return!1;try{return process.kill(t,0),!0}catch(e){if(e instanceof Error){let r=e.code;return r==="EPERM"?!0:(y.debug("SYSTEM","PID check failed",{pid:t,code:r}),!1)}return y.warn("SYSTEM","PID check threw non-Error",{pid:t,error:String(e)}),!1}}async function Ms(t,e){let r=Date.now()+e;for(;Date.now()<r;){if(t.every(n=>!ht(n.pid)))return;await new Promise(n=>setTimeout(n,100))}}var X$=5e3,n_=new Map;function Q$(t){let e=(0,_u.spawnSync)("powershell.exe",["-NoProfile","-NonInteractive","-Command",`(Get-CimInstance Win32_Process -Filter "ProcessId=${t}").CreationDate.ToString('yyyyMMddHHmmss.ffffff')`],{encoding:"utf-8",timeout:5e3,windowsHide:!0,env:{...Kn(process.env),LC_ALL:"C",LANG:"C"}});if(e.status===0){let r=e.stdout.trim();return r.length>0?r:null}return null}function eP(t){let e=n_.get(t);if(e&&Date.now()-e.capturedAtMs<X$)return e.token;let r=null;try{r=Q$(t)}catch(n){y.debug("SYSTEM","captureProcessStartToken: powershell CIM lookup failed",{pid:t,error:n instanceof Error?n.message:String(n)}),r=null}return n_.set(t,{token:r,capturedAtMs:Date.now()}),r}function o_(t){if(!Number.isInteger(t)||t<=0)return null;if(process.platform==="linux")try{let e=(0,gt.readFileSync)(`/proc/${t}/stat`,"utf-8"),r=e.lastIndexOf(") ");if(r<0)return null;let o=e.slice(r+2).split(" ")[19];return o&&/^\d+$/.test(o)?o:null}catch(e){return y.debug("SYSTEM","captureProcessStartToken: /proc read failed",{pid:t,error:e instanceof Error?e.message:String(e)}),null}if(process.platform==="win32")return eP(t);try{let e=(0,_u.spawnSync)("ps",["-p",String(t),"-o","lstart="],{encoding:"utf-8",timeout:2e3,env:{...Kn(process.env),LC_ALL:"C",LANG:"C"}});if(e.status!==0)return null;let r=e.stdout.trim();return r.length>0?r:null}catch(e){return y.debug("SYSTEM","captureProcessStartToken: ps exec failed",{pid:t,error:e instanceof Error?e.message:String(e)}),null}}function yu(t){if(!t||!ht(t.pid))return!1;if(!t.startToken)return!0;let e=o_(t.pid);if(e===null)return!0;let r=e===t.startToken;return r||y.debug("SYSTEM","verifyPidFileOwnership: start-token mismatch (PID reused)",{pid:t.pid,stored:t.startToken,current:e}),r}var gu=class{registryPath;entries=new Map;runtimeProcesses=new Map;initialized=!1;constructor(e=G$){this.registryPath=e}initialize(){if(this.initialized)return;if(this.initialized=!0,(0,gt.mkdirSync)(hu.default.dirname(this.registryPath),{recursive:!0}),!(0,gt.existsSync)(this.registryPath)){this.persist();return}try{let n=JSON.parse((0,gt.readFileSync)(this.registryPath,"utf-8")).processes??{};for(let[o,s]of Object.entries(n))this.entries.set(o,s)}catch(r){r instanceof Error?y.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath},r):y.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath,error:String(r)}),this.entries.clear()}let e=this.pruneDeadEntries();e>0&&y.info("SYSTEM","Removed dead processes from supervisor registry",{removed:e}),this.persist()}register(e,r,n){this.initialize(),this.entries.set(e,r),n&&this.runtimeProcesses.set(e,n),this.persist()}unregister(e){this.initialize();let r=this.entries.get(e);this.entries.delete(e),this.runtimeProcesses.delete(e),this.persist(),r?.type==="sdk"&&mu()}clear(){this.entries.clear(),this.runtimeProcesses.clear(),this.persist()}getAll(){return this.initialize(),Array.from(this.entries.entries()).map(([e,r])=>({id:e,...r})).sort((e,r)=>{let n=Date.parse(e.startedAt),o=Date.parse(r.startedAt);return(Number.isNaN(n)?0:n)-(Number.isNaN(o)?0:o)})}getBySession(e){let r=String(e);return this.getAll().filter(n=>n.sessionId!==void 0&&String(n.sessionId)===r)}getRuntimeProcess(e){return this.runtimeProcesses.get(e)}pruneDeadEntries(){this.initialize();let e=0,r=0;for(let[n,o]of this.entries)ht(o.pid)||(this.entries.delete(n),this.runtimeProcesses.delete(n),e+=1,o.type==="sdk"&&(r+=1));e>0&&this.persist();for(let n=0;n<r;n+=1)mu();return e}async reapSession(e){this.initialize();let r=this.getBySession(e);if(r.length===0)return 0;let n=typeof e=="number"?e:Number(e)||void 0;y.info("SYSTEM",`Reaping ${r.length} process(es) for session ${e}`,{sessionId:n,pids:r.map(i=>i.pid)});let o=r.filter(i=>ht(i.pid));for(let i of o)try{typeof i.pgid=="number"&&process.platform!=="win32"?process.kill(-i.pgid,"SIGTERM"):process.kill(i.pid,"SIGTERM")}catch(a){a instanceof Error?a.code!=="ESRCH"&&y.debug("SYSTEM",`Failed to SIGTERM session process PID ${i.pid}`,{pid:i.pid,pgid:i.pgid},a):y.warn("SYSTEM",`Failed to SIGTERM session process PID ${i.pid} (non-Error)`,{pid:i.pid,pgid:i.pgid,error:String(a)})}await Ms(o,B$);let s=o.filter(i=>ht(i.pid));for(let i of s){y.warn("SYSTEM",`Session process PID ${i.pid} did not exit after SIGTERM, sending SIGKILL`,{pid:i.pid,pgid:i.pgid,sessionId:n});try{typeof i.pgid=="number"&&process.platform!=="win32"?process.kill(-i.pgid,"SIGKILL"):process.kill(i.pid,"SIGKILL")}catch(a){a instanceof Error?a.code!=="ESRCH"&&y.debug("SYSTEM",`Failed to SIGKILL session process PID ${i.pid}`,{pid:i.pid,pgid:i.pgid},a):y.warn("SYSTEM",`Failed to SIGKILL session process PID ${i.pid} (non-Error)`,{pid:i.pid,pgid:i.pgid,error:String(a)})}}if(s.length>0){let i=Date.now()+Y$;for(;Date.now()<i&&s.filter(c=>ht(c.pid)).length!==0;)await new Promise(c=>setTimeout(c,100))}for(let i of r)this.entries.delete(i.id),this.runtimeProcesses.delete(i.id);this.persist();for(let i of r)i.type==="sdk"&&mu();return y.info("SYSTEM",`Reaped ${r.length} process(es) for session ${e}`,{sessionId:n,reaped:r.length}),r.length}persist(){let e={processes:Object.fromEntries(this.entries.entries())};(0,gt.mkdirSync)(hu.default.dirname(this.registryPath),{recursive:!0}),(0,gt.writeFileSync)(this.registryPath,JSON.stringify(e,null,2))}},fu=null;function Ds(){return fu||(fu=new gu),fu}var tP=[];function mu(){let t=tP.shift();t&&t()}var i_=require("child_process"),jr=require("fs"),a_=require("util");ue();Ge();var rP=(0,a_.promisify)(i_.execFile),nP=je.workerPid();async function c_(t){let e=t.currentPid??process.pid,r=t.pidFilePath??nP,n=t.registry.getAll(),o=[...n].filter(i=>i.pid!==e).sort((i,a)=>Date.parse(a.startedAt)-Date.parse(i.startedAt));for(let i of o){if(!ht(i.pid)){t.registry.unregister(i.id);continue}try{await s_(i,"SIGTERM")}catch(a){a instanceof Error?y.debug("SYSTEM","Failed to send SIGTERM to child process",{pid:i.pid,pgid:i.pgid,type:i.type},a):y.warn("SYSTEM","Failed to send SIGTERM to child process (non-Error)",{pid:i.pid,pgid:i.pgid,type:i.type,error:String(a)})}}await Ms(o,5e3);let s=o.filter(i=>ht(i.pid));for(let i of s)try{await s_(i,"SIGKILL")}catch(a){a instanceof Error?y.debug("SYSTEM","Failed to force kill child process",{pid:i.pid,pgid:i.pgid,type:i.type},a):y.warn("SYSTEM","Failed to force kill child process (non-Error)",{pid:i.pid,pgid:i.pgid,type:i.type,error:String(a)})}await Ms(s,1e3);for(let i of o)t.registry.unregister(i.id);for(let i of n.filter(a=>a.pid===e))t.registry.unregister(i.id);u_(r,e),t.registry.pruneDeadEntries()}function u_(t,e,r=!1){if(!(0,jr.existsSync)(t))return;let n=null;try{let i=JSON.parse((0,jr.readFileSync)(t,"utf-8"));n=typeof i.pid=="number"?i.pid:null}catch(i){y.debug("SYSTEM","PID file unreadable \u2014 leaving it (cannot prove ownership)",{pidFilePath:t,error:i instanceof Error?i.message:String(i)});return}let o=e!==null&&n===e,s=n===null||!ht(n);if(!o&&!(r&&s)){y.debug("SYSTEM","PID file not owned by this process \u2014 leaving it for its owner (restart successor?)",{pidFilePath:t,recordedPid:n,currentPid:e});return}try{(0,jr.rmSync)(t,{force:!0})}catch(i){i instanceof Error?y.debug("SYSTEM","Failed to remove PID file",{pidFilePath:t},i):y.warn("SYSTEM","Failed to remove PID file (non-Error)",{pidFilePath:t,error:String(i)})}}async function s_(t,e){let{pid:r,pgid:n}=t;if(process.platform!=="win32"){if(typeof n=="number")try{process.kill(-n,e);return}catch(s){if((s instanceof Error?s.code:void 0)!=="ESRCH")throw s}try{process.kill(r,e)}catch(s){if((s instanceof Error?s.code:void 0)!=="ESRCH")throw s}return}if(e==="SIGTERM"){try{process.kill(r,e)}catch(s){if(s instanceof Error&&s.code==="ESRCH")return;throw s}return}let o=["/PID",String(r),"/T"];e==="SIGKILL"&&o.push("/F"),await rP("taskkill",o,{timeout:de.POWERSHELL_COMMAND,windowsHide:!0})}ue();var l_=3e4,Lr=null;function oP(){let e=Ds().pruneDeadEntries();e>0&&y.info("SYSTEM",`Health check: pruned ${e} dead process(es) from registry`)}function d_(){Lr===null&&(Lr=setInterval(oP,l_),Lr.unref(),y.debug("SYSTEM","Health checker started",{intervalMs:l_}))}function p_(){Lr!==null&&(clearInterval(Lr),Lr=null,y.debug("SYSTEM","Health checker stopped"))}Ge();var sP=je.workerPid(),Su=class{registry;started=!1;stopPromise=null;signalHandlersRegistered=!1;shutdownInitiated=!1;shutdownHandler=null;constructor(e){this.registry=e}async start(){if(this.started)return;if(this.registry.initialize(),Ns({logAlive:!1})==="alive")throw new Error("Worker already running");this.started=!0,d_()}configureSignalHandlers(e){if(this.shutdownHandler=e,this.signalHandlersRegistered)return;this.signalHandlersRegistered=!0;let r=async n=>{if(this.shutdownInitiated){y.warn("SYSTEM",`Received ${n} but shutdown already in progress`);return}this.shutdownInitiated=!0,y.info("SYSTEM",`Received ${n}, shutting down...`);try{this.shutdownHandler?await this.shutdownHandler():await this.stop()}catch(o){o instanceof Error?y.error("SYSTEM","Error during shutdown",{},o):y.error("SYSTEM","Error during shutdown (non-Error)",{error:String(o)});try{await this.stop()}catch(s){s instanceof Error?y.debug("SYSTEM","Supervisor shutdown fallback failed",{},s):y.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",()=>{y.debug("SYSTEM","Ignoring SIGHUP in daemon mode")}):process.on("SIGHUP",()=>{r("SIGHUP")}))}async stop(){if(this.stopPromise){await this.stopPromise;return}p_(),this.stopPromise=c_({registry:this.registry,currentPid:process.pid}).finally(()=>{this.started=!1,this.stopPromise=null}),await this.stopPromise}assertCanSpawn(e){if(this.stopPromise!==null)throw new Error(`Supervisor is shutting down, refusing to spawn ${e}`)}registerProcess(e,r,n){this.registry.register(e,r,n)}unregisterProcess(e){this.registry.unregister(e)}getRegistry(){return this.registry}},iP=new Su(Ds());function vu(){return iP}function Ns(t={}){let e=t.pidFilePath??sP;if(!(0,sr.existsSync)(e))return"missing";let r=null;try{r=JSON.parse((0,sr.readFileSync)(e,"utf-8"))}catch(o){return o instanceof Error?y.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:e},o):y.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:e,error:String(o)}),(0,sr.rmSync)(e,{force:!0}),"invalid"}return yu(r)&&r?((t.logAlive??!0)&&y.info("SYSTEM","Worker already running (PID alive)",{existingPid:r.pid,existingPort:r.port,startedAt:r.startedAt}),"alive"):(y.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,sr.rmSync)(e,{force:!0}),"stale")}oo();Ge();ue();ue();var ir=Tt(require("path"),1),h_=require("os"),Ve=require("fs"),js=require("child_process");ue();ue();ue();Ge();var PN=je.dataDir(),f_=je.workerPid();function m_(t){return t?/(^|[\\/])bun(\.exe)?$/i.test(t.trim()):!1}function aP(t,e){let r=e==="win32"?`where ${t}`:`which ${t}`,n;try{n=(0,js.execSync)(r,{stdio:["ignore","pipe","ignore"],encoding:"utf-8",windowsHide:!0})}catch(s){return s instanceof Error?y.debug("SYSTEM",`Binary lookup failed for ${t}`,{command:r},s):y.debug("SYSTEM",`Binary lookup failed for ${t}`,{command:r},new Error(String(s))),null}return n.split(/\r?\n/).map(s=>s.trim()).find(s=>s.length>0)||null}var bu;function g_(t={}){let e=Object.keys(t).length===0;if(e&&bu!==void 0)return bu;let r=cP(t);return e&&r!==null&&(bu=r),r}function cP(t){let e=t.platform??process.platform,r=t.execPath??process.execPath;if(m_(r))return r;let n=t.env??process.env,o=t.homeDirectory??(0,h_.homedir)(),s=t.pathExists??Ve.existsSync,i=t.lookupInPath??aP,a=e==="win32"?[n.BUN,n.BUN_PATH,ir.default.join(o,".bun","bin","bun.exe"),ir.default.join(o,".bun","bin","bun"),n.USERPROFILE?ir.default.join(n.USERPROFILE,".bun","bin","bun.exe"):void 0,n.LOCALAPPDATA?ir.default.join(n.LOCALAPPDATA,"bun","bun.exe"):void 0,n.LOCALAPPDATA?ir.default.join(n.LOCALAPPDATA,"bun","bin","bun.exe"):void 0]:[n.BUN,n.BUN_PATH,ir.default.join(o,".bun","bin","bun"),"/usr/local/bin/bun","/opt/homebrew/bin/bun","/home/linuxbrew/.linuxbrew/bin/bun","/usr/bin/bun","/snap/bin/bun"];for(let c of a){let u=c?.trim();if(u&&(m_(u)&&s(u)||u.toLowerCase()==="bun"))return u}return i("bun",e)}function Wt(t){return process.platform==="win32"?Math.round(t*2):t}function __(t,e,r={}){vu().assertCanSpawn("worker daemon");let n=Kn({...process.env,CLAUDE_MEM_WORKER_PORT:String(e),...r}),o=g_();if(!o){y.error("SYSTEM","Bun runtime not found \u2014 install from https://bun.sh and ensure it is on PATH or set BUN env var. The worker daemon requires Bun because it uses bun:sqlite.");return}if(process.platform==="win32"){let l=`Start-Process -FilePath '${o.replace(/'/g,"''")}' -ArgumentList @('${t.replace(/'/g,"''")}','--daemon') -WindowStyle Hidden`,d=Buffer.from(l,"utf16le").toString("base64");try{return(0,js.execSync)(`powershell -NoProfile -EncodedCommand ${d}`,{stdio:"ignore",windowsHide:!0,env:n}),0}catch(p){let f=p instanceof Error?p:new Error(String(p));y.error("SYSTEM","Failed to spawn worker daemon on Windows",{runtimePath:o},f);return}}let s="/usr/bin/setsid",i=(0,Ve.existsSync)(s),u=Is(i?s:o,i?[o,t,"--daemon"]:[t,"--daemon"],{detached:!0,stdio:"ignore",env:n});if(u.pid!==void 0)return u.unref(),u.pid}function y_(){try{if(!(0,Ve.existsSync)(f_))return;let t=new Date;(0,Ve.utimesSync)(f_,t,t)}catch{}}function S_(){return Ns({logAlive:!1})}var v_=Tt(require("net"),1);ue();Ge();function Eu(){return ot.loadFromFile(co).CLAUDE_MEM_WORKER_HOST}function b_(t){return t.startsWith("[")&&t.endsWith("]")?t:t.includes(":")?`[${t}]`:t}async function uP(t,e,r="GET"){let n=await fetch(`http://${b_(Eu())}:${t}${e}`,{method:r}),o="";try{o=await n.text()}catch{}return{ok:n.ok,statusCode:n.status,body:o}}async function E_(t){if(process.platform==="win32")try{return(await fetch(`http://${b_(Eu())}:${t}/api/health`)).ok}catch(e){return e instanceof Error?y.debug("SYSTEM","Windows health check failed (port not in use)",{},e):y.debug("SYSTEM","Windows health check failed (port not in use)",{error:String(e)}),!1}return new Promise(e=>{let r=v_.default.createServer(),n=Eu();r.once("error",o=>{o.code==="EADDRINUSE"?e(!0):e(!1)}),r.once("listening",()=>{r.close(()=>e(!1))}),r.listen(t,n)})}async function w_(t,e,r,n){let o=Date.now();for(;Date.now()-o<r;){try{if((await uP(t,e)).ok)return!0}catch(s){s instanceof Error?y.debug("SYSTEM",n,{},s):y.debug("SYSTEM",n,{error:String(s)})}await new Promise(s=>setTimeout(s,500))}return!1}function Jn(t,e=3e4){return w_(t,"/api/health",e,"Service not ready yet, will retry")}function Bn(t,e=3e4){return w_(t,"/api/readiness",e,"Worker not ready yet, will retry")}ue();var Ls=require("path"),Ke=require("fs");Ge();ue();var lP=6e4;function k_(){return(0,Ls.join)(io(),"spawn.lock")}function wu(){let t=k_(),e=JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()});for(let r=0;r<2;r++)try{return(0,Ke.mkdirSync)((0,Ls.dirname)(t),{recursive:!0}),(0,Ke.writeFileSync)(t,e,{flag:"wx"}),!0}catch(n){let o=n instanceof Error?n:new Error(String(n)),s=o.code;if(s!=="EEXIST")return y.warn("SYSTEM","Spawn lock write failed for a non-contention reason; failing open (spawning unlocked)",{lockPath:t,code:s},o),!0;if(r>0)return!1;let i;try{i=(0,Ke.statSync)(t).mtimeMs}catch{continue}if(Date.now()-i<=lP)return!1;let a;try{a=(0,Ke.statSync)(t).mtimeMs}catch{continue}if(a!==i)return!1;try{(0,Ke.unlinkSync)(t)}catch{return!1}}return!1}function ku(){let t=k_();try{if(JSON.parse((0,Ke.readFileSync)(t,"utf-8")).pid!==process.pid)return;(0,Ke.unlinkSync)(t)}catch{}}function P_(t,e,r){let n=process.env[t];if(n){let o=parseInt(n,10);if(Number.isFinite(o)&&o>=r.min&&o<=r.max)return o;y.warn("SYSTEM",`Invalid ${t}, using default`,{value:n,min:r.min,max:r.max})}return e}var sj=P_("CLAUDE_MEM_HEALTH_TIMEOUT_MS",Ht(de.HEALTH_CHECK),{min:500,max:3e5}),ij=P_("CLAUDE_MEM_HOOK_READINESS_TIMEOUT_MS",Ht(de.HOOK_READINESS_WAIT),{min:0,max:3e5}),dP={min:500,max:3e5};async function xu(t,e={},r){try{return await fetch(t,{...e,signal:AbortSignal.timeout(r)})}catch(n){throw n instanceof DOMException&&n.name==="TimeoutError"?new Error(`Request timed out after ${r}ms`):n}}var Us=null,qs=null,Zs=null,Fs=null;function pP(){return Pe.default.join(ot.get("CLAUDE_MEM_DATA_DIR"),"settings.json")}function $u(){return Zs!==null||(Zs=ot.loadFromFile(pP())),Zs}function x_(t,e){if(!t)return null;let r=parseInt(t,10);return Number.isFinite(r)&&r>=e.min&&r<=e.max?r:null}function fP(t,e,r){let n=process.env[t];if(n!==void 0){let i=x_(n,r);return i!==null?i:(y.warn("SYSTEM",`Invalid ${t}, using default`,{value:n,min:r.min,max:r.max}),e)}let o=$u()[t],s=x_(o,r);return s!==null?s:(y.warn("SYSTEM",`Invalid ${t} in settings.json, using default`,{value:o,min:r.min,max:r.max}),e)}function Pu(){if(Us!==null)return Us;let t=$u();return Us=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),Us}function mP(){return qs!==null||(qs=$u().CLAUDE_MEM_WORKER_HOST),qs}function hP(){return Fs!==null||(Fs=fP("CLAUDE_MEM_API_TIMEOUT_MS",Ht(de.API_REQUEST),dP)),Fs}function gP(t){return t.startsWith("[")&&t.endsWith("]")?t:t.includes(":")?`[${t}]`:t}function _P(t){return`http://${gP(mP())}:${Pu()}${t}`}function Hs(t,e={}){let r=e.method??"GET",n=e.timeoutMs??hP(),o=_P(t),s={method:r};return e.headers&&(s.headers=e.headers),e.body&&(s.body=e.body),n>0?xu(o,s,n):fetch(o,s)}function T_(t){let e=(0,Ae.existsSync)(Pe.default.join(t,"plugin","scripts"))?Pe.default.join(t,"plugin"):t;return Pe.default.join(e,"scripts","worker-service.cjs")}function yP(t,e){let r=d=>{let p=d.split("-")[0].split(".");return[parseInt(p[0],10)||0,parseInt(p[1],10)||0,parseInt(p[2],10)||0]},[n,o,s]=r(t),[i,a,c]=r(e);if(i!==n)return i-n;if(a!==o)return a-o;if(c!==s)return c-s;let u=t.includes("-")?1:0,l=e.includes("-")?1:0;return u!==l?u-l:t<e?1:t>e?-1:0}function SP(t=Pe.default.join(Pe.default.dirname(Pe.default.dirname(ao)),"cache","thedotmack","claude-mem")){try{return(0,Ae.readdirSync)(t).filter(e=>/^\d/.test(e)).map(e=>Pe.default.join(t,e)).filter(e=>{try{if(!(0,Ae.statSync)(e).isDirectory())return!1}catch{return!1}return!(0,Ae.existsSync)(Pe.default.join(e,".orphaned_at"))}).map(e=>({scriptPath:T_(e),version:Pe.default.basename(e)}))}catch{return[]}}function $_(t){try{let e=JSON.parse((0,Ae.readFileSync)(t,"utf-8"));return typeof e.version=="string"?e.version:null}catch(e){let r=e.code;return r!=="ENOENT"&&y.debug("SYSTEM","Could not read package version for worker resolution",{packageJsonPath:t,code:r}),null}}function vP(){let t=process.env.CLAUDE_MEM_WORKER_SCRIPT_PATH?.trim();if(t){if((0,Ae.existsSync)(t))return{scriptPath:t,version:null};y.debug("SYSTEM","Ignoring missing CLAUDE_MEM_WORKER_SCRIPT_PATH override",{override:t})}let e=[...SP(),{scriptPath:T_(Pe.default.join(ao,"plugin")),version:$_(Pe.default.join(ao,"package.json"))},{scriptPath:Pe.default.join(process.cwd(),"plugin","scripts","worker-service.cjs"),version:$_(Pe.default.join(process.cwd(),"package.json"))}];return bP(e)}function bP(t){let e=t.filter(r=>(0,Ae.existsSync)(r.scriptPath));return e.length===0?null:(e.sort((r,n)=>r.version===null&&n.version===null?0:r.version===null?1:n.version===null?-1:yP(r.version,n.version)),e[0])}function z_(){return vP()?.scriptPath??null}var Tu=Tt(require("path"),1),Je=require("fs");ue();var EP=120*1e3;function zu(){return Tu.default.join(ot.get("CLAUDE_MEM_DATA_DIR"),".worker-start-attempted")}function wP(){if(process.platform!=="win32")return!1;let t=zu();if(!(0,Je.existsSync)(t))return!1;try{let e=(0,Je.statSync)(t).mtimeMs;return Date.now()-e<EP}catch(e){return e instanceof Error?y.debug("SYSTEM","Could not stat worker spawn lock file",{},e):y.debug("SYSTEM","Could not stat worker spawn lock file",{error:String(e)}),!1}}function kP(){if(process.platform==="win32")try{let t=zu();(0,Je.mkdirSync)(Tu.default.dirname(t),{recursive:!0}),(0,Je.writeFileSync)(t,"","utf-8")}catch{}}function Ws(){if(process.platform==="win32")try{let t=zu();(0,Je.existsSync)(t)&&(0,Je.unlinkSync)(t)}catch{}}async function R_(t,e){if(!e)return y.error("SYSTEM","ensureWorkerStarted called with empty workerScriptPath \u2014 caller bug"),"dead";if(!(0,Je.existsSync)(e))return y.error("SYSTEM","ensureWorkerStarted: worker script not found at expected path \u2014 likely a partial install or build artifact missing",{workerScriptPath:e}),"dead";if(S_()==="alive"){if(y.info("SYSTEM","Worker PID file points to a live process, skipping duplicate spawn"),await Jn(t,Wt(de.PORT_IN_USE_WAIT))){Ws();let a=await Bn(t,Wt(de.READINESS_WAIT));return y.info("SYSTEM","Worker became healthy while waiting on live PID"),a?"ready":"warming"}return y.warn("SYSTEM","Live PID detected but worker did not become healthy before timeout \u2014 likely still starting"),"warming"}if(await Jn(t,1e3)){Ws();let i=await Bn(t,Wt(de.READINESS_WAIT));return i||y.warn("SYSTEM","Worker is alive but readiness timed out \u2014 proceeding anyway"),y.info("SYSTEM","Worker already running and healthy"),i?"ready":"warming"}if(await E_(t)){if(y.info("SYSTEM","Port in use, waiting for worker to become healthy"),await Jn(t,Wt(de.PORT_IN_USE_WAIT))){Ws();let a=await Bn(t,Wt(de.READINESS_WAIT));return y.info("SYSTEM","Worker is now healthy"),a?"ready":"warming"}return y.error("SYSTEM","Port in use but worker not responding to health checks"),"dead"}if(wP())return y.warn("SYSTEM","Worker unavailable on Windows \u2014 skipping spawn (recent attempt failed within cooldown)"),"dead";let o=wu();try{if(o){if(y.info("SYSTEM","Starting worker daemon",{workerScriptPath:e}),kP(),__(e,t)===void 0)return y.error("SYSTEM","Failed to spawn worker daemon"),"dead"}else y.info("SYSTEM","Another launcher holds the spawn lock \u2014 skipping duplicate spawn and waiting for its worker");if(!await Jn(t,Wt(de.POST_SPAWN_WAIT)))return y.warn("SYSTEM",o?"Worker spawned but health endpoint not responding within window \u2014 likely still starting in background":"Spawn-lock holder's worker not healthy within window \u2014 likely still starting in background"),"warming"}finally{o&&ku()}let s=await Bn(t,Wt(de.READINESS_WAIT));return s||y.warn("SYSTEM","Worker is alive but readiness timed out \u2014 proceeding anyway"),Ws(),y_(),y.info("SYSTEM",o?"Worker started successfully":"Worker is up (started by another launcher)"),s?"ready":"warming"}var qr=require("node:fs/promises"),Gn=require("node:path");var A_=require("node:child_process"),st=require("node:fs"),Be=require("node:path"),Cu=require("node:os"),Ou=require("node:module");ue();var LP={},Au=typeof __filename<"u"?(0,Ou.createRequire)(__filename):(0,Ou.createRequire)(LP.url),xP={".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 C_(t){let e=t.slice(t.lastIndexOf("."));return xP[e]??"unknown"}var $P={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"},PP={markdown:"tree-sitter-markdown"};function M_(t){let e=$P[t];if(!e)return null;let r=PP[t];if(r){try{let n=Au.resolve(e+"/package.json"),o=(0,Be.join)((0,Be.dirname)(n),r);if((0,st.existsSync)((0,Be.join)(o,"src")))return o}catch{}return null}try{let n=Au.resolve(e+"/package.json");return(0,Be.dirname)(n)}catch{return null}}var TP={jsts:`
|
|
83
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of t.seen.entries()){let a=i[1];if(e===i[0]){s(i);continue}if(t.external){let u=t.external.registry.get(i[0])?.id;if(e!==i[0]&&u){s(i);continue}}if(t.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}if(a.count>1&&t.reused==="ref"){s(i);continue}}}function Hi(t,e){let r=t.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=t.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){n(d);let f=t.seen.get(d),m=f.schema;if(m.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):Object.assign(u,m),Object.assign(u,l),a._zod.parent===d)for(let S in u)S==="$ref"||S==="allOf"||S in l||delete u[S];if(m.$ref&&f.def)for(let S in u)S==="$ref"||S==="allOf"||S in f.def&&JSON.stringify(u[S])===JSON.stringify(f.def[S])&&delete u[S]}let p=a._zod.parent;if(p&&p!==d){n(p);let f=t.seen.get(p);if(f?.schema.$ref&&(u.$ref=f.schema.$ref,f.def))for(let m in u)m==="$ref"||m==="allOf"||m in f.def&&JSON.stringify(u[m])===JSON.stringify(f.def[m])&&delete u[m]}t.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(let a of[...t.seen.entries()].reverse())n(a[0]);let o={};if(t.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){let a=t.external.registry.get(e)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=t.external.uri(a)}Object.assign(o,r.def??r.schema);let s=t.metadataRegistry.get(e)?.id;s!==void 0&&o.id===s&&delete o.id;let i=t.external?.defs??{};for(let a of t.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,i[c.defId]=c.def)}t.external||Object.keys(i).length>0&&(t.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...e["~standard"],jsonSchema:{input:nn(e,"input",t.processors),output:nn(e,"output",t.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function we(t,e){let r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);let n=t._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return we(n.element,r);if(n.type==="set")return we(n.valueType,r);if(n.type==="lazy")return we(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return we(n.innerType,r);if(n.type==="intersection")return we(n.left,r)||we(n.right,r);if(n.type==="record"||n.type==="map")return we(n.keyType,r)||we(n.valueType,r);if(n.type==="pipe")return t._zod.traits.has("$ZodCodec")?!0:we(n.in,r)||we(n.out,r);if(n.type==="object"){for(let o in n.shape)if(we(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(we(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(we(o,r))return!0;return!!(n.rest&&we(n.rest,r))}return!1}var Zp=(t,e={})=>r=>{let n=Zi({...r,processors:e});return ie(t,n),Fi(n,t),Hi(n,t)},nn=(t,e,r={})=>n=>{let{libraryOptions:o,target:s}=n??{},i=Zi({...o??{},target:s,io:e,processors:r});return ie(t,i),Fi(i,t),Hi(i,t)};var oS={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Fp=(t,e,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u}=t._zod.bag;if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=oS[a]??a,o.format===""&&delete o.format,a==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let l=[...c];l.length===1?o.pattern=l[0].source:l.length>1&&(o.allOf=[...l.map(d=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},Hp=(t,e,r,n)=>{let o=r,{minimum:s,maximum:i,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=t._zod.bag;typeof a=="string"&&a.includes("int")?o.type="integer":o.type="number";let d=typeof l=="number"&&l>=(s??Number.NEGATIVE_INFINITY),p=typeof u=="number"&&u<=(i??Number.POSITIVE_INFINITY),f=e.target==="draft-04"||e.target==="openapi-3.0";d?f?(o.minimum=l,o.exclusiveMinimum=!0):o.exclusiveMinimum=l:typeof s=="number"&&(o.minimum=s),p?f?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u:typeof i=="number"&&(o.maximum=i),typeof c=="number"&&(o.multipleOf=c)},Wp=(t,e,r,n)=>{r.type="boolean"};var Vp=(t,e,r,n)=>{e.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var Kp=(t,e,r,n)=>{r.not={}};var Jp=(t,e,r,n)=>{};var Bp=(t,e,r,n)=>{let o=t._zod.def,s=Kr(o.entries);s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},Yp=(t,e,r,n)=>{let o=t._zod.def,s=[];for(let i of o.values)if(i===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){let i=s[0];r.type=i===null?"null":typeof i,e.target==="draft-04"||e.target==="openapi-3.0"?r.enum=[i]:r.const=i}else s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),s.every(i=>typeof i=="boolean")&&(r.type="boolean"),s.every(i=>i===null)&&(r.type="null"),r.enum=s};var Gp=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")};var Xp=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")};var Qp=(t,e,r,n)=>{let o=r,s=t._zod.def,{minimum:i,maximum:a}=t._zod.bag;typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=ie(s.element,e,{...n,path:[...n.path,"items"]})},ef=(t,e,r,n)=>{let o=r,s=t._zod.def;o.type="object",o.properties={};let i=s.shape;for(let u in i)o.properties[u]=ie(i[u],e,{...n,path:[...n.path,"properties",u]});let a=new Set(Object.keys(i)),c=new Set([...a].filter(u=>{let l=s.shape[u]._zod;return e.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(o.required=Array.from(c)),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=ie(s.catchall,e,{...n,path:[...n.path,"additionalProperties"]})):e.io==="output"&&(o.additionalProperties=!1)},tf=(t,e,r,n)=>{let o=t._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>ie(a,e,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=i:r.anyOf=i},rf=(t,e,r,n)=>{let o=t._zod.def,s=ie(o.left,e,{...n,path:[...n.path,"allOf",0]}),i=ie(o.right,e,{...n,path:[...n.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];r.allOf=c};var nf=(t,e,r,n)=>{let o=r,s=t._zod.def;o.type="object";let i=s.keyType,c=i._zod.bag?.patterns;if(s.mode==="loose"&&c&&c.size>0){let l=ie(s.valueType,e,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of c)o.patternProperties[d.source]=l}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(o.propertyNames=ie(s.keyType,e,{...n,path:[...n.path,"propertyNames"]})),o.additionalProperties=ie(s.valueType,e,{...n,path:[...n.path,"additionalProperties"]});let u=i._zod.values;if(u){let l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l)}},of=(t,e,r,n)=>{let o=t._zod.def,s=ie(o.innerType,e,n),i=e.seen.get(t);e.target==="openapi-3.0"?(i.ref=o.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},sf=(t,e,r,n)=>{let o=t._zod.def;ie(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType},af=(t,e,r,n)=>{let o=t._zod.def;ie(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},cf=(t,e,r,n)=>{let o=t._zod.def;ie(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType,e.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},uf=(t,e,r,n)=>{let o=t._zod.def;ie(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=i},lf=(t,e,r,n)=>{let o=t._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=e.io==="input"?s?o.out:o.in:o.out;ie(i,e,n);let a=e.seen.get(t);a.ref=i},df=(t,e,r,n)=>{let o=t._zod.def;ie(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType,r.readOnly=!0};var Wi=(t,e,r,n)=>{let o=t._zod.def;ie(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType};function mr(t){return!!t._zod}function At(t,e){return mr(t)?Xr(t,e):t.safeParse(e)}function Ro(t){if(!t)return;let e;if(mr(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function pf(t){if(mr(t)){let s=t._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=t.value;if(n!==void 0)return n}var sn={};Fu(sn,{ZodISODate:()=>mf,ZodISODateTime:()=>ff,ZodISODuration:()=>gf,ZodISOTime:()=>hf,date:()=>Ki,datetime:()=>Vi,duration:()=>Bi,time:()=>Ji});var ff=_("ZodISODateTime",(t,e)=>{bd.init(t,e),re.init(t,e)});function Vi(t){return Tp(ff,t)}var mf=_("ZodISODate",(t,e)=>{Ed.init(t,e),re.init(t,e)});function Ki(t){return Rp(mf,t)}var hf=_("ZodISOTime",(t,e)=>{wd.init(t,e),re.init(t,e)});function Ji(t){return zp(hf,t)}var gf=_("ZodISODuration",(t,e)=>{kd.init(t,e),re.init(t,e)});function Bi(t){return Ip(gf,t)}var fS=(t,e)=>{ho.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>ol(t,r)},flatten:{value:r=>nl(t,r)},addIssue:{value:r=>{t.issues.push(r),t.message=JSON.stringify(t.issues,lr,2)}},addIssues:{value:r=>{t.issues.push(...r),t.message=JSON.stringify(t.issues,lr,2)}},isEmpty:{get(){return t.issues.length===0}}})};var Me=_("ZodError",fS,{Parent:Error});var _f=go(Me),yf=_o(Me),Sf=Gr(Me),vf=Qr(Me),bf=sl(Me),Ef=il(Me),wf=al(Me),kf=cl(Me),xf=ul(Me),$f=ll(Me),Pf=dl(Me),Tf=pl(Me);var Rf=new WeakMap;function an(t,e,r){let n=Object.getPrototypeOf(t),o=Rf.get(n);if(o||(o=new Set,Rf.set(n,o)),!o.has(e)){o.add(e);for(let s in r){let i=r[s];Object.defineProperty(n,s,{configurable:!0,enumerable:!1,get(){let a=i.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}var se=_("ZodType",(t,e)=>(G.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:nn(t,"input"),output:nn(t,"output")}}),t.toJSONSchema=Zp(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.parse=(r,n)=>_f(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Sf(t,r,n),t.parseAsync=async(r,n)=>yf(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>vf(t,r,n),t.spa=t.safeParseAsync,t.encode=(r,n)=>bf(t,r,n),t.decode=(r,n)=>Ef(t,r,n),t.encodeAsync=async(r,n)=>wf(t,r,n),t.decodeAsync=async(r,n)=>kf(t,r,n),t.safeEncode=(r,n)=>xf(t,r,n),t.safeDecode=(r,n)=>$f(t,r,n),t.safeEncodeAsync=async(r,n)=>Pf(t,r,n),t.safeDecodeAsync=async(r,n)=>Tf(t,r,n),an(t,"ZodType",{check(...r){let n=this.def;return this.clone(L.mergeDefs(n,{checks:[...n.checks??[],...r.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,n){return Qe(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(nv(r,n))},superRefine(r,n){return this.check(ov(r,n))},overwrite(r){return this.check(Ot(r))},optional(){return oe(this)},exactOptional(){return WS(this)},nullable(){return Af(this)},nullish(){return oe(Af(this))},nonoptional(r){return GS(this,r)},array(){return N(this)},or(r){return Q([this,r])},and(r){return Io(this,r)},transform(r){return Cf(this,Uf(r))},default(r){return JS(this,r)},prefault(r){return YS(this,r)},catch(r){return QS(this,r)},pipe(r){return Cf(this,r)},readonly(){return rv(this)},describe(r){let n=this.clone();return Kt.add(n,{description:r}),n},meta(...r){if(r.length===0)return Kt.get(this);let n=this.clone();return Kt.add(n,r[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(t,"description",{get(){return Kt.get(t)?.description},configurable:!0}),t)),Mf=_("_ZodString",(t,e)=>{wo.init(t,e),se.init(t,e),t._zod.processJSONSchema=(n,o,s)=>Fp(t,n,o,s);let r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,an(t,"_ZodString",{regex(...n){return this.check(Ii(...n))},includes(...n){return this.check(Ci(...n))},startsWith(...n){return this.check(Mi(...n))},endsWith(...n){return this.check(Di(...n))},min(...n){return this.check(fr(...n))},max(...n){return this.check(Po(...n))},length(...n){return this.check(To(...n))},nonempty(...n){return this.check(fr(1,...n))},lowercase(n){return this.check(Oi(n))},uppercase(n){return this.check(Ai(n))},trim(){return this.check(ji())},normalize(...n){return this.check(Ni(...n))},toLowerCase(){return this.check(Li())},toUpperCase(){return this.check(Ui())},slugify(){return this.check(qi())}})}),hS=_("ZodString",(t,e)=>{wo.init(t,e),Mf.init(t,e),t.email=r=>t.check(ap(gS,r)),t.url=r=>t.check(pp(_S,r)),t.jwt=r=>t.check(Pp(OS,r)),t.emoji=r=>t.check(fp(yS,r)),t.guid=r=>t.check(zi(zf,r)),t.uuid=r=>t.check(cp(zo,r)),t.uuidv4=r=>t.check(up(zo,r)),t.uuidv6=r=>t.check(lp(zo,r)),t.uuidv7=r=>t.check(dp(zo,r)),t.nanoid=r=>t.check(mp(SS,r)),t.guid=r=>t.check(zi(zf,r)),t.cuid=r=>t.check(hp(vS,r)),t.cuid2=r=>t.check(gp(bS,r)),t.ulid=r=>t.check(_p(ES,r)),t.base64=r=>t.check(kp(RS,r)),t.base64url=r=>t.check(xp(zS,r)),t.xid=r=>t.check(yp(wS,r)),t.ksuid=r=>t.check(Sp(kS,r)),t.ipv4=r=>t.check(vp(xS,r)),t.ipv6=r=>t.check(bp($S,r)),t.cidrv4=r=>t.check(Ep(PS,r)),t.cidrv6=r=>t.check(wp(TS,r)),t.e164=r=>t.check($p(IS,r)),t.datetime=r=>t.check(Vi(r)),t.date=r=>t.check(Ki(r)),t.time=r=>t.check(Ji(r)),t.duration=r=>t.check(Bi(r))});function h(t){return ip(hS,t)}var re=_("ZodStringFormat",(t,e)=>{X.init(t,e),Mf.init(t,e)}),gS=_("ZodEmail",(t,e)=>{pd.init(t,e),re.init(t,e)});var zf=_("ZodGUID",(t,e)=>{ld.init(t,e),re.init(t,e)});var zo=_("ZodUUID",(t,e)=>{dd.init(t,e),re.init(t,e)});var _S=_("ZodURL",(t,e)=>{fd.init(t,e),re.init(t,e)});var yS=_("ZodEmoji",(t,e)=>{md.init(t,e),re.init(t,e)});var SS=_("ZodNanoID",(t,e)=>{hd.init(t,e),re.init(t,e)});var vS=_("ZodCUID",(t,e)=>{gd.init(t,e),re.init(t,e)});var bS=_("ZodCUID2",(t,e)=>{_d.init(t,e),re.init(t,e)});var ES=_("ZodULID",(t,e)=>{yd.init(t,e),re.init(t,e)});var wS=_("ZodXID",(t,e)=>{Sd.init(t,e),re.init(t,e)});var kS=_("ZodKSUID",(t,e)=>{vd.init(t,e),re.init(t,e)});var xS=_("ZodIPv4",(t,e)=>{xd.init(t,e),re.init(t,e)});var $S=_("ZodIPv6",(t,e)=>{$d.init(t,e),re.init(t,e)});var PS=_("ZodCIDRv4",(t,e)=>{Pd.init(t,e),re.init(t,e)});var TS=_("ZodCIDRv6",(t,e)=>{Td.init(t,e),re.init(t,e)});var RS=_("ZodBase64",(t,e)=>{zd.init(t,e),re.init(t,e)});var zS=_("ZodBase64URL",(t,e)=>{Id.init(t,e),re.init(t,e)});var IS=_("ZodE164",(t,e)=>{Od.init(t,e),re.init(t,e)});var OS=_("ZodJWT",(t,e)=>{Ad.init(t,e),re.init(t,e)});var Df=_("ZodNumber",(t,e)=>{xi.init(t,e),se.init(t,e),t._zod.processJSONSchema=(n,o,s)=>Hp(t,n,o,s),an(t,"ZodNumber",{gt(n,o){return this.check(xo(n,o))},gte(n,o){return this.check(rn(n,o))},min(n,o){return this.check(rn(n,o))},lt(n,o){return this.check(ko(n,o))},lte(n,o){return this.check(tn(n,o))},max(n,o){return this.check(tn(n,o))},int(n){return this.check(If(n))},safe(n){return this.check(If(n))},positive(n){return this.check(xo(0,n))},nonnegative(n){return this.check(rn(0,n))},negative(n){return this.check(ko(0,n))},nonpositive(n){return this.check(tn(0,n))},multipleOf(n,o){return this.check($o(n,o))},step(n,o){return this.check($o(n,o))},finite(){return this}});let r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null});function W(t){return Op(Df,t)}var AS=_("ZodNumberFormat",(t,e)=>{Cd.init(t,e),Df.init(t,e)});function If(t){return Ap(AS,t)}var CS=_("ZodBoolean",(t,e)=>{Md.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Wp(t,r,n,o)});function de(t){return Cp(CS,t)}var MS=_("ZodNull",(t,e)=>{Dd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Vp(t,r,n,o)});function Nf(t){return Mp(MS,t)}var DS=_("ZodUnknown",(t,e)=>{Nd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Jp(t,r,n,o)});function ne(){return Dp(DS)}var NS=_("ZodNever",(t,e)=>{jd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Kp(t,r,n,o)});function jS(t){return Np(NS,t)}var LS=_("ZodArray",(t,e)=>{Ld.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Qp(t,r,n,o),t.element=e.element,an(t,"ZodArray",{min(r,n){return this.check(fr(r,n))},nonempty(r){return this.check(fr(1,r))},max(r,n){return this.check(Po(r,n))},length(r,n){return this.check(To(r,n))},unwrap(){return this.element}})});function N(t,e){return jp(LS,t,e)}var jf=_("ZodObject",(t,e)=>{Zd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>ef(t,r,n,o),L.defineLazy(t,"shape",()=>e.shape),an(t,"ZodObject",{keyof(){return Te(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:ne()})},loose(){return this.clone({...this._zod.def,catchall:ne()})},strict(){return this.clone({...this._zod.def,catchall:jS()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return L.extend(this,r)},safeExtend(r){return L.safeExtend(this,r)},merge(r){return L.merge(this,r)},pick(r){return L.pick(this,r)},omit(r){return L.omit(this,r)},partial(...r){return L.partial(qf,this,r[0])},required(...r){return L.required(Zf,this,r[0])}})});function w(t,e){let r={type:"object",shape:t??{},...L.normalizeParams(e)};return new jf(r)}function ke(t,e){return new jf({type:"object",shape:t,catchall:ne(),...L.normalizeParams(e)})}var Lf=_("ZodUnion",(t,e)=>{$i.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>tf(t,r,n,o),t.options=e.options});function Q(t,e){return new Lf({type:"union",options:t,...L.normalizeParams(e)})}var US=_("ZodDiscriminatedUnion",(t,e)=>{Lf.init(t,e),Fd.init(t,e)});function Gi(t,e,r){return new US({type:"union",options:e,discriminator:t,...L.normalizeParams(r)})}var qS=_("ZodIntersection",(t,e)=>{Hd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>rf(t,r,n,o)});function Io(t,e){return new qS({type:"intersection",left:t,right:e})}var Of=_("ZodRecord",(t,e)=>{Wd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>nf(t,r,n,o),t.keyType=e.keyType,t.valueType=e.valueType});function Y(t,e,r){return!e||!e._zod?new Of({type:"record",keyType:h(),valueType:t,...L.normalizeParams(e)}):new Of({type:"record",keyType:t,valueType:e,...L.normalizeParams(r)})}var Yi=_("ZodEnum",(t,e)=>{Vd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(n,o,s)=>Bp(t,n,o,s),t.enum=e.entries,t.options=Object.values(e.entries);let r=new Set(Object.keys(e.entries));t.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Yi({...e,checks:[],...L.normalizeParams(o),entries:s})},t.exclude=(n,o)=>{let s={...e.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new Yi({...e,checks:[],...L.normalizeParams(o),entries:s})}});function Te(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new Yi({type:"enum",entries:r,...L.normalizeParams(e)})}var ZS=_("ZodLiteral",(t,e)=>{Kd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Yp(t,r,n,o),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function P(t,e){return new ZS({type:"literal",values:Array.isArray(t)?t:[t],...L.normalizeParams(e)})}var FS=_("ZodTransform",(t,e)=>{Jd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Xp(t,r,n,o),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new cr(t.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(L.issue(s,r.value,e));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=t),r.issues.push(L.issue(i))}};let o=e.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r.fallback=!0,r)):(r.value=o,r.fallback=!0,r)}});function Uf(t){return new FS({type:"transform",transform:t})}var qf=_("ZodOptional",(t,e)=>{Pi.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Wi(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function oe(t){return new qf({type:"optional",innerType:t})}var HS=_("ZodExactOptional",(t,e)=>{Bd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Wi(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function WS(t){return new HS({type:"optional",innerType:t})}var VS=_("ZodNullable",(t,e)=>{Yd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>of(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function Af(t){return new VS({type:"nullable",innerType:t})}var KS=_("ZodDefault",(t,e)=>{Gd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>af(t,r,n,o),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function JS(t,e){return new KS({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():L.shallowClone(e)}})}var BS=_("ZodPrefault",(t,e)=>{Xd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>cf(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function YS(t,e){return new BS({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():L.shallowClone(e)}})}var Zf=_("ZodNonOptional",(t,e)=>{Qd.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>sf(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function GS(t,e){return new Zf({type:"nonoptional",innerType:t,...L.normalizeParams(e)})}var XS=_("ZodCatch",(t,e)=>{ep.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>uf(t,r,n,o),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function QS(t,e){return new XS({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var Ff=_("ZodPipe",(t,e)=>{Ti.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>lf(t,r,n,o),t.in=e.in,t.out=e.out});function Cf(t,e){return new Ff({type:"pipe",in:t,out:e})}var ev=_("ZodPreprocess",(t,e)=>{Ff.init(t,e),tp.init(t,e)}),tv=_("ZodReadonly",(t,e)=>{rp.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>df(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function rv(t){return new tv({type:"readonly",innerType:t})}var Hf=_("ZodCustom",(t,e)=>{np.init(t,e),se.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Gp(t,r,n,o)});function Wf(t,e){return Lp(Hf,t??(()=>!0),e)}function nv(t,e={}){return Up(Hf,t,e)}function ov(t,e){return qp(t,e)}function Xi(t,e){return new ev({type:"pipe",in:Uf(t),out:e})}Ce(op());var ea="2025-11-25";var Vf=[ea,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Ct="io.modelcontextprotocol/related-task",Ao="2.0",le=Wf(t=>t!==null&&(typeof t=="object"||typeof t=="function")),Kf=Q([h(),W().int()]),Jf=h(),eI=ke({ttl:W().optional(),pollInterval:W().optional()}),sv=w({ttl:W().optional()}),iv=w({taskId:h()}),ta=ke({progressToken:Kf.optional(),[Ct]:iv.optional()}),De=w({_meta:ta.optional()}),cn=De.extend({task:sv.optional()}),Bf=t=>cn.safeParse(t).success,fe=w({method:h(),params:De.loose().optional()}),Ue=w({_meta:ta.optional()}),qe=w({method:h(),params:Ue.loose().optional()}),me=ke({_meta:ta.optional()}),Co=Q([h(),W().int()]),Yf=w({jsonrpc:P(Ao),id:Co,...fe.shape}).strict(),ra=t=>Yf.safeParse(t).success,Gf=w({jsonrpc:P(Ao),...qe.shape}).strict(),Xf=t=>Gf.safeParse(t).success,na=w({jsonrpc:P(Ao),id:Co,result:me}).strict(),un=t=>na.safeParse(t).success;var D;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(D||(D={}));var oa=w({jsonrpc:P(Ao),id:Co.optional(),error:w({code:W().int(),message:h(),data:ne().optional()})}).strict();var Qf=t=>oa.safeParse(t).success;var em=Q([Yf,Gf,na,oa]),tI=Q([na,oa]),Mo=me.strict(),av=Ue.extend({requestId:Co.optional(),reason:h().optional()}),Do=qe.extend({method:P("notifications/cancelled"),params:av}),cv=w({src:h(),mimeType:h().optional(),sizes:N(h()).optional(),theme:Te(["light","dark"]).optional()}),ln=w({icons:N(cv).optional()}),hr=w({name:h(),title:h().optional()}),tm=hr.extend({...hr.shape,...ln.shape,version:h(),websiteUrl:h().optional(),description:h().optional()}),uv=Io(w({applyDefaults:de().optional()}),Y(h(),ne())),lv=Xi(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,Io(w({form:uv.optional(),url:le.optional()}),Y(h(),ne()).optional())),dv=ke({list:le.optional(),cancel:le.optional(),requests:ke({sampling:ke({createMessage:le.optional()}).optional(),elicitation:ke({create:le.optional()}).optional()}).optional()}),pv=ke({list:le.optional(),cancel:le.optional(),requests:ke({tools:ke({call:le.optional()}).optional()}).optional()}),fv=w({experimental:Y(h(),le).optional(),sampling:w({context:le.optional(),tools:le.optional()}).optional(),elicitation:lv.optional(),roots:w({listChanged:de().optional()}).optional(),tasks:dv.optional(),extensions:Y(h(),le).optional()}),mv=De.extend({protocolVersion:h(),capabilities:fv,clientInfo:tm}),sa=fe.extend({method:P("initialize"),params:mv});var hv=w({experimental:Y(h(),le).optional(),logging:le.optional(),completions:le.optional(),prompts:w({listChanged:de().optional()}).optional(),resources:w({subscribe:de().optional(),listChanged:de().optional()}).optional(),tools:w({listChanged:de().optional()}).optional(),tasks:pv.optional(),extensions:Y(h(),le).optional()}),gv=me.extend({protocolVersion:h(),capabilities:hv,serverInfo:tm,instructions:h().optional()}),ia=qe.extend({method:P("notifications/initialized"),params:Ue.optional()});var No=fe.extend({method:P("ping"),params:De.optional()}),_v=w({progress:W(),total:oe(W()),message:oe(h())}),yv=w({...Ue.shape,..._v.shape,progressToken:Kf}),jo=qe.extend({method:P("notifications/progress"),params:yv}),Sv=De.extend({cursor:Jf.optional()}),dn=fe.extend({params:Sv.optional()}),pn=me.extend({nextCursor:Jf.optional()}),vv=Te(["working","input_required","completed","failed","cancelled"]),fn=w({taskId:h(),status:vv,ttl:Q([W(),Nf()]),createdAt:h(),lastUpdatedAt:h(),pollInterval:oe(W()),statusMessage:oe(h())}),gr=me.extend({task:fn}),bv=Ue.merge(fn),mn=qe.extend({method:P("notifications/tasks/status"),params:bv}),Lo=fe.extend({method:P("tasks/get"),params:De.extend({taskId:h()})}),Uo=me.merge(fn),qo=fe.extend({method:P("tasks/result"),params:De.extend({taskId:h()})}),rI=me.loose(),Zo=dn.extend({method:P("tasks/list")}),Fo=pn.extend({tasks:N(fn)}),Ho=fe.extend({method:P("tasks/cancel"),params:De.extend({taskId:h()})}),rm=me.merge(fn),nm=w({uri:h(),mimeType:oe(h()),_meta:Y(h(),ne()).optional()}),om=nm.extend({text:h()}),aa=h().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),sm=nm.extend({blob:aa}),hn=Te(["user","assistant"]),_r=w({audience:N(hn).optional(),priority:W().min(0).max(1).optional(),lastModified:sn.datetime({offset:!0}).optional()}),im=w({...hr.shape,...ln.shape,uri:h(),description:oe(h()),mimeType:oe(h()),size:oe(W()),annotations:_r.optional(),_meta:oe(ke({}))}),Ev=w({...hr.shape,...ln.shape,uriTemplate:h(),description:oe(h()),mimeType:oe(h()),annotations:_r.optional(),_meta:oe(ke({}))}),wv=dn.extend({method:P("resources/list")}),kv=pn.extend({resources:N(im)}),xv=dn.extend({method:P("resources/templates/list")}),$v=pn.extend({resourceTemplates:N(Ev)}),ca=De.extend({uri:h()}),Pv=ca,Tv=fe.extend({method:P("resources/read"),params:Pv}),Rv=me.extend({contents:N(Q([om,sm]))}),zv=qe.extend({method:P("notifications/resources/list_changed"),params:Ue.optional()}),Iv=ca,Ov=fe.extend({method:P("resources/subscribe"),params:Iv}),Av=ca,Cv=fe.extend({method:P("resources/unsubscribe"),params:Av}),Mv=Ue.extend({uri:h()}),Dv=qe.extend({method:P("notifications/resources/updated"),params:Mv}),Nv=w({name:h(),description:oe(h()),required:oe(de())}),jv=w({...hr.shape,...ln.shape,description:oe(h()),arguments:oe(N(Nv)),_meta:oe(ke({}))}),Lv=dn.extend({method:P("prompts/list")}),Uv=pn.extend({prompts:N(jv)}),qv=De.extend({name:h(),arguments:Y(h(),h()).optional()}),Zv=fe.extend({method:P("prompts/get"),params:qv}),ua=w({type:P("text"),text:h(),annotations:_r.optional(),_meta:Y(h(),ne()).optional()}),la=w({type:P("image"),data:aa,mimeType:h(),annotations:_r.optional(),_meta:Y(h(),ne()).optional()}),da=w({type:P("audio"),data:aa,mimeType:h(),annotations:_r.optional(),_meta:Y(h(),ne()).optional()}),Fv=w({type:P("tool_use"),name:h(),id:h(),input:Y(h(),ne()),_meta:Y(h(),ne()).optional()}),Hv=w({type:P("resource"),resource:Q([om,sm]),annotations:_r.optional(),_meta:Y(h(),ne()).optional()}),Wv=im.extend({type:P("resource_link")}),pa=Q([ua,la,da,Wv,Hv]),Vv=w({role:hn,content:pa}),Kv=me.extend({description:h().optional(),messages:N(Vv)}),Jv=qe.extend({method:P("notifications/prompts/list_changed"),params:Ue.optional()}),Bv=w({title:h().optional(),readOnlyHint:de().optional(),destructiveHint:de().optional(),idempotentHint:de().optional(),openWorldHint:de().optional()}),Yv=w({taskSupport:Te(["required","optional","forbidden"]).optional()}),am=w({...hr.shape,...ln.shape,description:h().optional(),inputSchema:w({type:P("object"),properties:Y(h(),le).optional(),required:N(h()).optional()}).catchall(ne()),outputSchema:w({type:P("object"),properties:Y(h(),le).optional(),required:N(h()).optional()}).catchall(ne()).optional(),annotations:Bv.optional(),execution:Yv.optional(),_meta:Y(h(),ne()).optional()}),fa=dn.extend({method:P("tools/list")}),Gv=pn.extend({tools:N(am)}),Wo=me.extend({content:N(pa).default([]),structuredContent:Y(h(),ne()).optional(),isError:de().optional()}),nI=Wo.or(me.extend({toolResult:ne()})),Xv=cn.extend({name:h(),arguments:Y(h(),ne()).optional()}),gn=fe.extend({method:P("tools/call"),params:Xv}),Qv=qe.extend({method:P("notifications/tools/list_changed"),params:Ue.optional()}),oI=w({autoRefresh:de().default(!0),debounceMs:W().int().nonnegative().default(300)}),_n=Te(["debug","info","notice","warning","error","critical","alert","emergency"]),eb=De.extend({level:_n}),ma=fe.extend({method:P("logging/setLevel"),params:eb}),tb=Ue.extend({level:_n,logger:h().optional(),data:ne()}),rb=qe.extend({method:P("notifications/message"),params:tb}),nb=w({name:h().optional()}),ob=w({hints:N(nb).optional(),costPriority:W().min(0).max(1).optional(),speedPriority:W().min(0).max(1).optional(),intelligencePriority:W().min(0).max(1).optional()}),sb=w({mode:Te(["auto","required","none"]).optional()}),ib=w({type:P("tool_result"),toolUseId:h().describe("The unique identifier for the corresponding tool call."),content:N(pa).default([]),structuredContent:w({}).loose().optional(),isError:de().optional(),_meta:Y(h(),ne()).optional()}),ab=Gi("type",[ua,la,da]),Oo=Gi("type",[ua,la,da,Fv,ib]),cb=w({role:hn,content:Q([Oo,N(Oo)]),_meta:Y(h(),ne()).optional()}),ub=cn.extend({messages:N(cb),modelPreferences:ob.optional(),systemPrompt:h().optional(),includeContext:Te(["none","thisServer","allServers"]).optional(),temperature:W().optional(),maxTokens:W().int(),stopSequences:N(h()).optional(),metadata:le.optional(),tools:N(am).optional(),toolChoice:sb.optional()}),lb=fe.extend({method:P("sampling/createMessage"),params:ub}),yn=me.extend({model:h(),stopReason:oe(Te(["endTurn","stopSequence","maxTokens"]).or(h())),role:hn,content:ab}),ha=me.extend({model:h(),stopReason:oe(Te(["endTurn","stopSequence","maxTokens","toolUse"]).or(h())),role:hn,content:Q([Oo,N(Oo)])}),db=w({type:P("boolean"),title:h().optional(),description:h().optional(),default:de().optional()}),pb=w({type:P("string"),title:h().optional(),description:h().optional(),minLength:W().optional(),maxLength:W().optional(),format:Te(["email","uri","date","date-time"]).optional(),default:h().optional()}),fb=w({type:Te(["number","integer"]),title:h().optional(),description:h().optional(),minimum:W().optional(),maximum:W().optional(),default:W().optional()}),mb=w({type:P("string"),title:h().optional(),description:h().optional(),enum:N(h()),default:h().optional()}),hb=w({type:P("string"),title:h().optional(),description:h().optional(),oneOf:N(w({const:h(),title:h()})),default:h().optional()}),gb=w({type:P("string"),title:h().optional(),description:h().optional(),enum:N(h()),enumNames:N(h()).optional(),default:h().optional()}),_b=Q([mb,hb]),yb=w({type:P("array"),title:h().optional(),description:h().optional(),minItems:W().optional(),maxItems:W().optional(),items:w({type:P("string"),enum:N(h())}),default:N(h()).optional()}),Sb=w({type:P("array"),title:h().optional(),description:h().optional(),minItems:W().optional(),maxItems:W().optional(),items:w({anyOf:N(w({const:h(),title:h()}))}),default:N(h()).optional()}),vb=Q([yb,Sb]),bb=Q([gb,_b,vb]),Eb=Q([bb,db,pb,fb]),wb=cn.extend({mode:P("form").optional(),message:h(),requestedSchema:w({type:P("object"),properties:Y(h(),Eb),required:N(h()).optional()})}),kb=cn.extend({mode:P("url"),message:h(),elicitationId:h(),url:h().url()}),xb=Q([wb,kb]),$b=fe.extend({method:P("elicitation/create"),params:xb}),Pb=Ue.extend({elicitationId:h()}),Tb=qe.extend({method:P("notifications/elicitation/complete"),params:Pb}),yr=me.extend({action:Te(["accept","decline","cancel"]),content:Xi(t=>t===null?void 0:t,Y(h(),Q([h(),W(),de(),N(h())])).optional())}),Rb=w({type:P("ref/resource"),uri:h()});var zb=w({type:P("ref/prompt"),name:h()}),Ib=De.extend({ref:Q([zb,Rb]),argument:w({name:h(),value:h()}),context:w({arguments:Y(h(),h()).optional()}).optional()}),Ob=fe.extend({method:P("completion/complete"),params:Ib});var Ab=me.extend({completion:ke({values:N(h()).max(100),total:oe(W().int()),hasMore:oe(de())})}),Cb=w({uri:h().startsWith("file://"),name:h().optional(),_meta:Y(h(),ne()).optional()}),Mb=fe.extend({method:P("roots/list"),params:De.optional()}),ga=me.extend({roots:N(Cb)}),Db=qe.extend({method:P("notifications/roots/list_changed"),params:Ue.optional()}),sI=Q([No,sa,Ob,ma,Zv,Lv,wv,xv,Tv,Ov,Cv,gn,fa,Lo,qo,Zo,Ho]),iI=Q([Do,jo,ia,Db,mn]),aI=Q([Mo,yn,ha,yr,ga,Uo,Fo,gr]),cI=Q([No,lb,$b,Mb,Lo,qo,Zo,Ho]),uI=Q([Do,jo,rb,Dv,zv,Qv,Jv,mn,Tb]),lI=Q([Mo,gv,Ab,Kv,Uv,kv,$v,Rv,Wo,Gv,Uo,Fo,gr]),I=class t extends Error{constructor(e,r,n){super(`MCP error ${e}: ${r}`),this.code=e,this.data=n,this.name="McpError"}static fromError(e,r,n){if(e===D.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new Qi(o.elicitations,r)}return new t(e,r,n)}},Qi=class extends I{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(D.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function Mt(t){return t==="completed"||t==="failed"||t==="cancelled"}var FI=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function _a(t){let r=Ro(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=pf(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function ya(t,e){let r=At(t,e);if(!r.success)throw r.error;return r.data}var Zb=6e4,Vo=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Do,r=>{this._oncancel(r)}),this.setNotificationHandler(jo,r=>{this._onprogress(r)}),this.setRequestHandler(No,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Lo,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new I(D.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(qo,async(r,n)=>{let o=async()=>{let s=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,p=new I(d.error.code,d.error.message,d.error.data);l(p)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new I(D.InvalidParams,`Task not found: ${s}`);if(!Mt(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(Mt(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[Ct]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(Zo,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(D.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Ho,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new I(D.InvalidParams,`Task not found: ${r.params.taskId}`);if(Mt(o.status))throw new I(D.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(D.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof I?o:new I(D.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,n,o,s=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),I.fromError(D.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),un(s)||Qf(s)?this._onresponse(s):ra(s)?this._onrequest(s,i):Xf(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=I.fromError(D.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of e.values())n(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(e,r){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,o=this._transport,s=e.params?._meta?.[Ct]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:D.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);let a=Bf(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let d={relatedRequestId:e.id};s&&(d.relatedTask={taskId:s}),await this.notification(l,d)},sendRequest:async(l,d,p)=>{if(i.signal.aborted)throw new I(D.ConnectionClosed,"Request was cancelled");let f={...p,relatedRequestId:e.id};s&&!f.relatedTask&&(f.relatedTask={taskId:s});let m=f.relatedTask?.taskId??s;return m&&c&&await c.updateTaskStatus(m,"input_required"),await this.request(l,d,f)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,u)).then(async l=>{if(i.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:e.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:D.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===i&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...n}=e.params,o=Number(r),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(n)}_onresponse(e){let r=Number(e.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),un(e))n(e);else{let i=new I(e.error.code,e.error.message,e.error.data);n(i)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if(un(e)&&e.result&&typeof e.result=="object"){let i=e.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,r))}}if(s||this._progressHandlers.delete(r),un(e))o(e);else{let i=I.fromError(e.error.code,e.error.message,e.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(e,r,n)}}catch(i){yield{type:"error",error:i instanceof I?i:new I(D.InternalError,String(i))}}return}let s;try{let i=await this.request(e,gr,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new I(D.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},Mt(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(D.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new I(D.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(D.InternalError,String(i))}}}request(e,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=x=>{l(x)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(x){d(x);return}n?.signal?.throwIfAborted();let p=this._requestMessageId++,f={...e,jsonrpc:"2.0",id:p};n?.onprogress&&(this._progressHandlers.set(p,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:p}}),a&&(f.params={...f.params,task:a}),c&&(f.params={...f.params,_meta:{...f.params?._meta||{},[Ct]:c}});let m=x=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(x)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch($=>this._onerror(new Error(`Failed to send cancellation: ${$}`)));let b=x instanceof I?x:new I(D.RequestTimeout,String(x));l(b)};this._responseHandlers.set(p,x=>{if(!n?.signal?.aborted){if(x instanceof Error)return l(x);try{let b=At(r,x.result);b.success?u(b.data):l(b.error)}catch(b){l(b)}}}),n?.signal?.addEventListener("abort",()=>{m(n?.signal?.reason)});let g=n?.timeout??Zb,S=()=>m(I.fromError(D.RequestTimeout,"Request timed out",{timeout:g}));this._setupTimeout(p,g,n?.maxTotalTimeout,S,n?.resetTimeoutOnProgress??!1);let v=c?.taskId;if(v){let x=b=>{let $=this._responseHandlers.get(p);$?$(b):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,x),this._enqueueTaskMessage(v,{type:"request",message:f,timestamp:Date.now()}).catch(b=>{this._cleanupTimeout(p),l(b)})}else this._transport.send(f,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(x=>{this._cleanupTimeout(p),l(x)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Uo,r)}async getTaskResult(e,r,n){return this.request({method:"tasks/result",params:e},r,n)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},Fo,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},rm,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let n=r?.relatedTask?.taskId;if(n){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[Ct]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Ct]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[Ct]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let n=_a(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=ya(e,o);return Promise.resolve(r(i,s))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){let n=_a(e);this._notificationHandlers.set(n,o=>{let s=ya(e,o);return Promise.resolve(r(s))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,n,o)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,r);for(let o of n)if(o.type==="request"&&ra(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new I(D.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(e);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new I(D.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new I(D.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!e)throw new Error("No request provided");return await n.createTask(o,e.id,{method:e.method,params:e.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new I(D.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=mn.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Mt(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(D.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Mt(a.status))throw new I(D.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=mn.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Mt(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function cm(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function um(t,e){let r={...t};for(let n in e){let o=n,s=e[o];if(s===void 0)continue;let i=r[o];cm(i)&&cm(s)?r[o]={...i,...s}:r[o]=s}return r}var e_=Tt(ou(),1),t_=Tt(Qg(),1);function W$(){let t=new e_.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,t_.default)(t),t}var Ps=class{constructor(e){this._ajv=e??W$()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var Ts=class{constructor(e){this._server=e}requestStream(e,r,n){return this._server.requestStream(e,r,n)}createMessageStream(e,r){let n=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let o=e.messages[e.messages.length-1],s=Array.isArray(o.content)?o.content:[o.content],i=s.some(l=>l.type==="tool_result"),a=e.messages.length>1?e.messages[e.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(p=>p.type==="tool_use").map(p=>p.id)),d=new Set(s.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(l.size!==d.size||![...l].every(p=>d.has(p)))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:e},yn,r)}elicitInputStream(e,r){let n=this._server.getClientCapabilities(),o=e.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"&&e.mode===void 0?{...e,mode:"form"}:e;return this.requestStream({method:"elicitation/create",params:s},yr,r)}async getTask(e,r){return this._server.getTask({taskId:e},r)}async getTaskResult(e,r,n){return this._server.getTaskResult({taskId:e},r,n)}async listTasks(e,r){return this._server.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._server.cancelTask({taskId:e},r)}};function r_(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function n_(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}var Rs=class extends Vo{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(_n.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 Ps,this.setRequestHandler(sa,n=>this._oninitialize(n)),this.setNotificationHandler(ia,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(ma,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=_n.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Ts(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=um(this._capabilities,e)}setRequestHandler(e,r){let o=Ro(e)?.method;if(!o)throw new Error("Schema is missing a method literal");let s;if(mr(o)){let a=o;s=a._zod?.def?.value??a.value}else{let a=o;s=a._def?.value??a.value}if(typeof s!="string")throw new Error("Schema method literal must be a string");if(s==="tools/call"){let a=async(c,u)=>{let l=At(gn,c);if(!l.success){let m=l.error instanceof Error?l.error.message:String(l.error);throw new I(D.InvalidParams,`Invalid tools/call request: ${m}`)}let{params:d}=l.data,p=await Promise.resolve(r(c,u));if(d.task){let m=At(gr,p);if(!m.success){let g=m.error instanceof Error?m.error.message:String(m.error);throw new I(D.InvalidParams,`Invalid task creation result: ${g}`)}return m.data}let f=At(Wo,p);if(!f.success){let m=f.error instanceof Error?f.error.message:String(f.error);throw new I(D.InvalidParams,`Invalid tools/call result: ${m}`)}return f.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,r)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);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 ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);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 ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);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 ${e})`);break;case"ping":case"initialize":break}}assertTaskCapability(e){n_(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&r_(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){let r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:Vf.includes(r)?r:ea,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"},Mo)}async createMessage(e,r){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let n=e.messages[e.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],s=o.some(u=>u.type==="tool_result"),i=e.messages.length>1?e.messages[e.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 e.tools?this.request({method:"sampling/createMessage",params:e},ha,r):this.request({method:"sampling/createMessage",params:e},yn,r)}async elicitInput(e,r){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=e;return this.request({method:"elicitation/create",params:o},yr,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=e.mode==="form"?e:{...e,mode:"form"},s=await this.request({method:"elicitation/create",params:o},yr,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(D.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof I?i:new I(D.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return s}}}createElicitationCompletionNotifier(e,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:e}},r)}async listRoots(e,r){return this.request({method:"roots/list",params:e},ga,r)}async sendLoggingMessage(e,r){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,r))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}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 pu=Tt(require("node:process"),1);var zs=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
|
|
84
|
+
`);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),V$(r)}clear(){this._buffer=void 0}};function V$(t){return em.parse(JSON.parse(t))}function o_(t){return JSON.stringify(t)+`
|
|
85
|
+
`}var Is=class{constructor(e=pu.default.stdin,r=pu.default.stdout){this._stdin=e,this._stdout=r,this._readBuffer=new zs,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}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(e){return new Promise(r=>{let n=o_(e);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};var Pe=Tt(require("path"),1),Ae=require("fs");var fu=require("node:child_process");function Os(t,e,r){return(0,fu.spawn)(t,e??[],{windowsHide:!0,...r})}var K$=new Set([".cmd",".bat"]),J$=new Set([".exe",".com"]),yD=new Set([...J$,...K$]);ce();var ye={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 Ht(t){return process.platform==="win32"?Math.round(t*ye.WINDOWS_MULTIPLIER):t}var As=require("fs"),mu=require("path"),Bn=require("os");Fr();var st=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(Ht(ye.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,mu.join)((0,Bn.homedir)(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_MODE:"code",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"false",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"false",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"false",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_FULL_COUNT:"0",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false",CLAUDE_MEM_CONTEXT_SHOW_TERMINAL_OUTPUT:"true",CLAUDE_MEM_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,mu.join)((0,Bn.homedir)(),".claude-mem","transcript-watch.json"),CLAUDE_MEM_CODEX_TRANSCRIPT_INGESTION:"false",CLAUDE_MEM_MAX_CONCURRENT_AGENTS:"2",CLAUDE_MEM_HOOK_FAIL_LOUD_THRESHOLD:"3",CLAUDE_MEM_EXCLUDED_PROJECTS:"",CLAUDE_MEM_FOLDER_MD_EXCLUDE:"[]",CLAUDE_MEM_FOLDER_MD_SKELETON_DENYLIST:"[]",CLAUDE_MEM_SEMANTIC_INJECT:"false",CLAUDE_MEM_SEMANTIC_INJECT_LIMIT:"5",CLAUDE_MEM_TIER_ROUTING_ENABLED:"true",CLAUDE_MEM_TIER_SIMPLE_MODEL:"haiku",CLAUDE_MEM_TIER_SUMMARY_MODEL:"",CLAUDE_MEM_TIER_FAST_MODEL:"haiku",CLAUDE_MEM_TIER_SMART_MODEL:"sonnet",CLAUDE_MEM_CHROMA_ENABLED:"true",CLAUDE_MEM_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_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,Bn.hostname)(),CLAUDE_MEM_CLOUD_SYNC_WS:"true",CLAUDE_MEM_TELEGRAM_ENABLED:"true",CLAUDE_MEM_TELEGRAM_BOT_TOKEN:"",CLAUDE_MEM_TELEGRAM_CHAT_ID:"",CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES:"security_alert",CLAUDE_MEM_TELEGRAM_TRIGGER_CONCEPTS:"",CLAUDE_MEM_QUEUE_ENGINE:"sqlite",CLAUDE_MEM_REDIS_URL:"",CLAUDE_MEM_REDIS_HOST:"127.0.0.1",CLAUDE_MEM_REDIS_PORT:"6379",CLAUDE_MEM_REDIS_MODE:"external",CLAUDE_MEM_QUEUE_REDIS_PREFIX:`claude_mem_${process.env.CLAUDE_MEM_WORKER_PORT??String(37700+(process.getuid?.()??77)%100)}`,CLAUDE_MEM_AUTH_MODE:"api-key",CLAUDE_MEM_RUNTIME:"worker",CLAUDE_MEM_SERVER_URL:`http://127.0.0.1:${process.env.CLAUDE_MEM_SERVER_PORT??String(37877+(process.getuid?.()??77)%100)}`,CLAUDE_MEM_SERVER_API_KEY:"",CLAUDE_MEM_SERVER_PROJECT_ID:"",CLAUDE_MEM_SERVER_BETA_URL:`http://127.0.0.1:${process.env.CLAUDE_MEM_SERVER_PORT??String(37877+(process.getuid?.()??77)%100)}`,CLAUDE_MEM_SERVER_BETA_API_KEY:"",CLAUDE_MEM_SERVER_BETA_PROJECT_ID:""};static getAllDefaults(){return{...this.DEFAULTS}}static get(e){return process.env[e]??this.DEFAULTS[e]}static getInt(e){let r=this.get(e);return parseInt(r,10)}static applyEnvOverrides(e){let r={...e};for(let n of Object.keys(this.DEFAULTS))process.env[n]!==void 0&&(r[n]=process.env[n]);return r}static loadFromFile(e,r=!0){try{if(!(0,As.existsSync)(e)){let a=this.getAllDefaults();try{oi(e,a),console.warn("[SETTINGS] Created settings file with defaults:",e)}catch(c){console.warn("[SETTINGS] Failed to create settings file, using in-memory defaults:",e,c instanceof Error?c.message:String(c))}return r?this.applyEnvOverrides(a):a}let n=(0,As.readFileSync)(e,"utf-8"),o=Wt(n),s=o;if(o.env&&typeof o.env=="object"){s=o.env;try{oi(e,s),console.warn("[SETTINGS] Migrated settings file from nested to flat schema:",e)}catch(a){console.warn("[SETTINGS] Failed to auto-migrate settings file:",e,a instanceof Error?a.message:String(a))}}let i={...this.DEFAULTS};for(let a of Object.keys(this.DEFAULTS))s[a]!==void 0&&(i[a]=s[a]);return r?this.applyEnvOverrides(i):i}catch(n){console.warn("[SETTINGS] Failed to load settings, using defaults:",e,n instanceof Error?n.message:String(n));let o=this.getAllDefaults();return r?this.applyEnvOverrides(o):o}}};Xe();Xe();var Cs=null;function Ms(){return Cs!==null||(Cs=st.loadFromFile(uo)),Cs}var sr=require("fs");ce();var Su=require("child_process");var gt=require("fs"),_u=Tt(require("path"),1);ce();var B$=["CLAUDECODE_","CLAUDE_CODE_"],Y$=new Set(["CLAUDECODE","CLAUDE_CODE_SESSION","CLAUDE_CODE_ENTRYPOINT","MCP_SESSION_ID"]),G$=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"]),X$=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",...G$]);function Yn(t=process.env){let e={};for(let[r,n]of Object.entries(t))if(n!==void 0){if(X$.has(r)){e[r]=n;continue}Y$.has(r)||B$.some(o=>r.startsWith(o))||(e[r]=n)}return e}Xe();var Q$=5e3,eP=1e3,tP=je.supervisorRegistry();function Ve(t){if(!Number.isInteger(t)||t<0||t===0)return!1;try{return process.kill(t,0),!0}catch(e){if(e instanceof Error){let r=e.code;return r==="EPERM"?!0:(y.debug("SYSTEM","PID check failed",{pid:t,code:r}),!1)}return y.warn("SYSTEM","PID check threw non-Error",{pid:t,error:String(e)}),!1}}async function Ds(t,e){let r=Date.now()+e;for(;Date.now()<r;){if(t.every(n=>!Ve(n.pid)))return;await new Promise(n=>setTimeout(n,100))}}var rP=5e3,s_=new Map;function nP(t){let e=(0,Su.spawnSync)("powershell.exe",["-NoProfile","-NonInteractive","-Command",`(Get-CimInstance Win32_Process -Filter "ProcessId=${t}").CreationDate.ToString('yyyyMMddHHmmss.ffffff')`],{encoding:"utf-8",timeout:5e3,windowsHide:!0,env:{...Yn(process.env),LC_ALL:"C",LANG:"C"}});if(e.status===0){let r=e.stdout.trim();return r.length>0?r:null}return null}function oP(t){let e=s_.get(t);if(e&&Date.now()-e.capturedAtMs<rP)return e.token;let r=null;try{r=nP(t)}catch(n){y.debug("SYSTEM","captureProcessStartToken: powershell CIM lookup failed",{pid:t,error:n instanceof Error?n.message:String(n)}),r=null}return s_.set(t,{token:r,capturedAtMs:Date.now()}),r}function i_(t){if(!Number.isInteger(t)||t<=0)return null;if(process.platform==="linux")try{let e=(0,gt.readFileSync)(`/proc/${t}/stat`,"utf-8"),r=e.lastIndexOf(") ");if(r<0)return null;let o=e.slice(r+2).split(" ")[19];return o&&/^\d+$/.test(o)?o:null}catch(e){return y.debug("SYSTEM","captureProcessStartToken: /proc read failed",{pid:t,error:e instanceof Error?e.message:String(e)}),null}if(process.platform==="win32")return oP(t);try{let e=(0,Su.spawnSync)("ps",["-p",String(t),"-o","lstart="],{encoding:"utf-8",timeout:2e3,env:{...Yn(process.env),LC_ALL:"C",LANG:"C"}});if(e.status!==0)return null;let r=e.stdout.trim();return r.length>0?r:null}catch(e){return y.debug("SYSTEM","captureProcessStartToken: ps exec failed",{pid:t,error:e instanceof Error?e.message:String(e)}),null}}function vu(t){if(!t||!Ve(t.pid))return!1;if(!t.startToken)return!0;let e=i_(t.pid);if(e===null)return!0;let r=e===t.startToken;return r||y.debug("SYSTEM","verifyPidFileOwnership: start-token mismatch (PID reused)",{pid:t.pid,stored:t.startToken,current:e}),r}var yu=class{registryPath;entries=new Map;runtimeProcesses=new Map;initialized=!1;constructor(e=tP){this.registryPath=e}initialize(){if(this.initialized)return;if(this.initialized=!0,(0,gt.mkdirSync)(_u.default.dirname(this.registryPath),{recursive:!0}),!(0,gt.existsSync)(this.registryPath)){this.persist();return}try{let n=JSON.parse((0,gt.readFileSync)(this.registryPath,"utf-8")).processes??{};for(let[o,s]of Object.entries(n))this.entries.set(o,s)}catch(r){r instanceof Error?y.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath},r):y.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath,error:String(r)}),this.entries.clear()}let e=this.pruneDeadEntries();e>0&&y.info("SYSTEM","Removed dead processes from supervisor registry",{removed:e}),this.persist()}register(e,r,n){this.initialize(),this.entries.set(e,r),n&&this.runtimeProcesses.set(e,n),this.persist()}unregister(e){this.initialize();let r=this.entries.get(e);this.entries.delete(e),this.runtimeProcesses.delete(e),this.persist(),r?.type==="sdk"&&gu()}clear(){this.entries.clear(),this.runtimeProcesses.clear(),this.persist()}getAll(){return this.initialize(),Array.from(this.entries.entries()).map(([e,r])=>({id:e,...r})).sort((e,r)=>{let n=Date.parse(e.startedAt),o=Date.parse(r.startedAt);return(Number.isNaN(n)?0:n)-(Number.isNaN(o)?0:o)})}getBySession(e){let r=String(e);return this.getAll().filter(n=>n.sessionId!==void 0&&String(n.sessionId)===r)}getRuntimeProcess(e){return this.runtimeProcesses.get(e)}pruneDeadEntries(){this.initialize();let e=0,r=0;for(let[n,o]of this.entries)Ve(o.pid)||(this.entries.delete(n),this.runtimeProcesses.delete(n),e+=1,o.type==="sdk"&&(r+=1));e>0&&this.persist();for(let n=0;n<r;n+=1)gu();return e}async reapSession(e){this.initialize();let r=this.getBySession(e);if(r.length===0)return 0;let n=typeof e=="number"?e:Number(e)||void 0;y.info("SYSTEM",`Reaping ${r.length} process(es) for session ${e}`,{sessionId:n,pids:r.map(i=>i.pid)});let o=r.filter(i=>Ve(i.pid));for(let i of o)try{typeof i.pgid=="number"&&process.platform!=="win32"?process.kill(-i.pgid,"SIGTERM"):process.kill(i.pid,"SIGTERM")}catch(a){a instanceof Error?a.code!=="ESRCH"&&y.debug("SYSTEM",`Failed to SIGTERM session process PID ${i.pid}`,{pid:i.pid,pgid:i.pgid},a):y.warn("SYSTEM",`Failed to SIGTERM session process PID ${i.pid} (non-Error)`,{pid:i.pid,pgid:i.pgid,error:String(a)})}await Ds(o,Q$);let s=o.filter(i=>Ve(i.pid));for(let i of s){y.warn("SYSTEM",`Session process PID ${i.pid} did not exit after SIGTERM, sending SIGKILL`,{pid:i.pid,pgid:i.pgid,sessionId:n});try{typeof i.pgid=="number"&&process.platform!=="win32"?process.kill(-i.pgid,"SIGKILL"):process.kill(i.pid,"SIGKILL")}catch(a){a instanceof Error?a.code!=="ESRCH"&&y.debug("SYSTEM",`Failed to SIGKILL session process PID ${i.pid}`,{pid:i.pid,pgid:i.pgid},a):y.warn("SYSTEM",`Failed to SIGKILL session process PID ${i.pid} (non-Error)`,{pid:i.pid,pgid:i.pgid,error:String(a)})}}if(s.length>0){let i=Date.now()+eP;for(;Date.now()<i&&s.filter(c=>Ve(c.pid)).length!==0;)await new Promise(c=>setTimeout(c,100))}for(let i of r)this.entries.delete(i.id),this.runtimeProcesses.delete(i.id);this.persist();for(let i of r)i.type==="sdk"&&gu();return y.info("SYSTEM",`Reaped ${r.length} process(es) for session ${e}`,{sessionId:n,reaped:r.length}),r.length}persist(){let e={processes:Object.fromEntries(this.entries.entries())};(0,gt.mkdirSync)(_u.default.dirname(this.registryPath),{recursive:!0}),(0,gt.writeFileSync)(this.registryPath,JSON.stringify(e,null,2))}},hu=null;function Ns(){return hu||(hu=new yu),hu}var sP=[];function gu(){let t=sP.shift();t&&t()}var c_=require("child_process"),Nr=require("fs"),u_=require("util");ce();Xe();var iP=(0,u_.promisify)(c_.execFile),aP=je.workerPid();async function l_(t){let e=t.currentPid??process.pid,r=t.pidFilePath??aP,n=t.registry.getAll(),o=[...n].filter(i=>i.pid!==e).sort((i,a)=>Date.parse(a.startedAt)-Date.parse(i.startedAt));for(let i of o){if(!Ve(i.pid)){t.registry.unregister(i.id);continue}try{await a_(i,"SIGTERM")}catch(a){a instanceof Error?y.debug("SYSTEM","Failed to send SIGTERM to child process",{pid:i.pid,pgid:i.pgid,type:i.type},a):y.warn("SYSTEM","Failed to send SIGTERM to child process (non-Error)",{pid:i.pid,pgid:i.pgid,type:i.type,error:String(a)})}}await Ds(o,5e3);let s=o.filter(i=>Ve(i.pid));for(let i of s)try{await a_(i,"SIGKILL")}catch(a){a instanceof Error?y.debug("SYSTEM","Failed to force kill child process",{pid:i.pid,pgid:i.pgid,type:i.type},a):y.warn("SYSTEM","Failed to force kill child process (non-Error)",{pid:i.pid,pgid:i.pgid,type:i.type,error:String(a)})}await Ds(s,1e3);for(let i of o)t.registry.unregister(i.id);for(let i of n.filter(a=>a.pid===e))t.registry.unregister(i.id);d_(r,e),t.registry.pruneDeadEntries()}function d_(t,e,r=!1){if(!(0,Nr.existsSync)(t))return;let n=null;try{let i=JSON.parse((0,Nr.readFileSync)(t,"utf-8"));n=typeof i.pid=="number"?i.pid:null}catch(i){y.debug("SYSTEM","PID file unreadable \u2014 leaving it (cannot prove ownership)",{pidFilePath:t,error:i instanceof Error?i.message:String(i)});return}let o=e!==null&&n===e,s=n===null||!Ve(n);if(!o&&!(r&&s)){y.debug("SYSTEM","PID file not owned by this process \u2014 leaving it for its owner (restart successor?)",{pidFilePath:t,recordedPid:n,currentPid:e});return}try{(0,Nr.rmSync)(t,{force:!0})}catch(i){i instanceof Error?y.debug("SYSTEM","Failed to remove PID file",{pidFilePath:t},i):y.warn("SYSTEM","Failed to remove PID file (non-Error)",{pidFilePath:t,error:String(i)})}}async function a_(t,e){let{pid:r,pgid:n}=t;if(process.platform!=="win32"){if(typeof n=="number")try{process.kill(-n,e);return}catch(s){if((s instanceof Error?s.code:void 0)!=="ESRCH")throw s}try{process.kill(r,e)}catch(s){if((s instanceof Error?s.code:void 0)!=="ESRCH")throw s}return}if(e==="SIGTERM"){try{process.kill(r,e)}catch(s){if(s instanceof Error&&s.code==="ESRCH")return;throw s}return}let o=["/PID",String(r),"/T"];e==="SIGKILL"&&o.push("/F"),await iP("taskkill",o,{timeout:ye.POWERSHELL_COMMAND,windowsHide:!0})}ce();var p_=3e4,jr=null;function cP(){let e=Ns().pruneDeadEntries();e>0&&y.info("SYSTEM",`Health check: pruned ${e} dead process(es) from registry`)}function f_(){jr===null&&(jr=setInterval(cP,p_),jr.unref(),y.debug("SYSTEM","Health checker started",{intervalMs:p_}))}function m_(){jr!==null&&(clearInterval(jr),jr=null,y.debug("SYSTEM","Health checker stopped"))}Xe();var uP=je.workerPid(),bu=class{registry;started=!1;stopPromise=null;signalHandlersRegistered=!1;shutdownInitiated=!1;shutdownHandler=null;constructor(e){this.registry=e}async start(){if(this.started)return;if(this.registry.initialize(),js({logAlive:!1})==="alive")throw new Error("Worker already running");this.started=!0,f_()}configureSignalHandlers(e){if(this.shutdownHandler=e,this.signalHandlersRegistered)return;this.signalHandlersRegistered=!0;let r=async n=>{if(this.shutdownInitiated){y.warn("SYSTEM",`Received ${n} but shutdown already in progress`);return}this.shutdownInitiated=!0,y.info("SYSTEM",`Received ${n}, shutting down...`);try{this.shutdownHandler?await this.shutdownHandler():await this.stop()}catch(o){o instanceof Error?y.error("SYSTEM","Error during shutdown",{},o):y.error("SYSTEM","Error during shutdown (non-Error)",{error:String(o)});try{await this.stop()}catch(s){s instanceof Error?y.debug("SYSTEM","Supervisor shutdown fallback failed",{},s):y.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",()=>{y.debug("SYSTEM","Ignoring SIGHUP in daemon mode")}):process.on("SIGHUP",()=>{r("SIGHUP")}))}async stop(){if(this.stopPromise){await this.stopPromise;return}m_(),this.stopPromise=l_({registry:this.registry,currentPid:process.pid}).finally(()=>{this.started=!1,this.stopPromise=null}),await this.stopPromise}assertCanSpawn(e){if(this.stopPromise!==null)throw new Error(`Supervisor is shutting down, refusing to spawn ${e}`)}registerProcess(e,r,n){this.registry.register(e,r,n)}unregisterProcess(e){this.registry.unregister(e)}getRegistry(){return this.registry}},lP=new bu(Ns());function Eu(){return lP}function js(t={}){let e=t.pidFilePath??uP;if(!(0,sr.existsSync)(e))return"missing";let r=null;try{r=JSON.parse((0,sr.readFileSync)(e,"utf-8"))}catch(o){return o instanceof Error?y.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:e},o):y.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:e,error:String(o)}),(0,sr.rmSync)(e,{force:!0}),"invalid"}return vu(r)&&r?((t.logAlive??!0)&&y.info("SYSTEM","Worker already running (PID alive)",{existingPid:r.pid,existingPort:r.port,startedAt:r.startedAt}),"alive"):(y.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,sr.rmSync)(e,{force:!0}),"stale")}io();Xe();Fr();ce();ce();var ir=Tt(require("path"),1),__=require("os"),Ke=require("fs"),Ls=require("child_process");ce();ce();ce();Xe();var AN=je.dataDir(),h_=je.workerPid();function g_(t){return t?/(^|[\\/])bun(\.exe)?$/i.test(t.trim()):!1}function dP(t,e){let r=e==="win32"?`where ${t}`:`which ${t}`,n;try{n=(0,Ls.execSync)(r,{stdio:["ignore","pipe","ignore"],encoding:"utf-8",windowsHide:!0})}catch(s){return s instanceof Error?y.debug("SYSTEM",`Binary lookup failed for ${t}`,{command:r},s):y.debug("SYSTEM",`Binary lookup failed for ${t}`,{command:r},new Error(String(s))),null}return n.split(/\r?\n/).map(s=>s.trim()).find(s=>s.length>0)||null}var wu;function y_(t={}){let e=Object.keys(t).length===0;if(e&&wu!==void 0)return wu;let r=pP(t);return e&&r!==null&&(wu=r),r}function pP(t){let e=t.platform??process.platform,r=t.execPath??process.execPath;if(g_(r))return r;let n=t.env??process.env,o=t.homeDirectory??(0,__.homedir)(),s=t.pathExists??Ke.existsSync,i=t.lookupInPath??dP,a=e==="win32"?[n.BUN,n.BUN_PATH,ir.default.join(o,".bun","bin","bun.exe"),ir.default.join(o,".bun","bin","bun"),n.USERPROFILE?ir.default.join(n.USERPROFILE,".bun","bin","bun.exe"):void 0,n.LOCALAPPDATA?ir.default.join(n.LOCALAPPDATA,"bun","bun.exe"):void 0,n.LOCALAPPDATA?ir.default.join(n.LOCALAPPDATA,"bun","bin","bun.exe"):void 0]:[n.BUN,n.BUN_PATH,ir.default.join(o,".bun","bin","bun"),"/usr/local/bin/bun","/opt/homebrew/bin/bun","/home/linuxbrew/.linuxbrew/bin/bun","/usr/bin/bun","/snap/bin/bun"];for(let c of a){let u=c?.trim();if(u&&(g_(u)&&s(u)||u.toLowerCase()==="bun"))return u}return i("bun",e)}function Lr(t){return process.platform==="win32"?Math.round(t*2):t}function fP(t,e){let r=n=>n.replace(/'/g,"''");return`Start-Process -FilePath '${r(t)}' -ArgumentList @('"${r(e)}"','--daemon') -WindowStyle Hidden`}function S_(t,e,r={}){Eu().assertCanSpawn("worker daemon");let n=Yn({...process.env,CLAUDE_MEM_WORKER_PORT:String(e),...r}),o=y_();if(!o){y.error("SYSTEM","Bun runtime not found \u2014 install from https://bun.sh and ensure it is on PATH or set BUN env var. The worker daemon requires Bun because it uses bun:sqlite.");return}if(process.platform==="win32"){let l=fP(o,t),d=Buffer.from(l,"utf16le").toString("base64");try{return(0,Ls.execSync)(`powershell -NoProfile -EncodedCommand ${d}`,{stdio:"ignore",windowsHide:!0,env:n}),0}catch(p){let f=p instanceof Error?p:new Error(String(p));y.error("SYSTEM","Failed to spawn worker daemon on Windows",{runtimePath:o},f);return}}let s="/usr/bin/setsid",i=(0,Ke.existsSync)(s),u=Os(i?s:o,i?[o,t,"--daemon"]:[t,"--daemon"],{detached:!0,stdio:"ignore",env:n});if(u.pid!==void 0)return u.unref(),u.pid}function v_(){try{if(!(0,Ke.existsSync)(h_))return;let t=new Date;(0,Ke.utimesSync)(h_,t,t)}catch{}}function Us(){return js({logAlive:!1})}var b_=Tt(require("net"),1);ce();Xe();function ku(){return st.loadFromFile(uo).CLAUDE_MEM_WORKER_HOST}function E_(t){return t.startsWith("[")&&t.endsWith("]")?t:t.includes(":")?`[${t}]`:t}async function mP(t,e,r="GET"){let n=await fetch(`http://${E_(ku())}:${t}${e}`,{method:r}),o="";try{o=await n.text()}catch{}return{ok:n.ok,statusCode:n.status,body:o}}async function w_(t){if(process.platform==="win32")try{let e=await fetch(`http://${E_(ku())}:${t}/api/health`);if(e.ok)return!0;y.debug("SYSTEM","Windows health check returned non-ok; falling through to socket probe",{port:t,status:e.status})}catch(e){e instanceof Error?y.debug("SYSTEM","Windows health check threw; falling through to socket probe",{port:t,message:e.message}):y.debug("SYSTEM","Windows health check threw; falling through to socket probe",{port:t,error:String(e)})}return new Promise(e=>{let r=b_.default.createServer(),n=ku();r.once("error",o=>{o.code==="EADDRINUSE"?e(!0):e(!1)}),r.once("listening",()=>{r.close(()=>e(!1))}),r.listen(t,n)})}async function k_(t,e,r,n){let o=Date.now();for(;Date.now()-o<r;){try{if((await mP(t,e)).ok)return!0}catch(s){s instanceof Error?y.debug("SYSTEM",n,{},s):y.debug("SYSTEM",n,{error:String(s)})}await new Promise(s=>setTimeout(s,500))}return!1}function Gn(t,e=3e4){return k_(t,"/api/health",e,"Service not ready yet, will retry")}function Xn(t,e=3e4){return k_(t,"/api/readiness",e,"Worker not ready yet, will retry")}ce();var qs=require("path"),Je=require("fs");Xe();ce();var hP=9e4;function x_(){return(0,qs.join)(ao(),"spawn.lock")}function xu(){let t=x_(),e=JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()});for(let r=0;r<2;r++)try{return(0,Je.mkdirSync)((0,qs.dirname)(t),{recursive:!0}),(0,Je.writeFileSync)(t,e,{flag:"wx"}),!0}catch(n){let o=n instanceof Error?n:new Error(String(n)),s=o.code;if(s!=="EEXIST")return y.warn("SYSTEM","Spawn lock write failed for a non-contention reason; failing open (spawning unlocked)",{lockPath:t,code:s},o),!0;if(r>0)return!1;let i;try{i=(0,Je.statSync)(t).mtimeMs}catch{continue}if(Date.now()-i<=hP)return!1;let a;try{a=(0,Je.statSync)(t).mtimeMs}catch{continue}if(a!==i)return!1;try{(0,Je.unlinkSync)(t)}catch{return!1}}return!1}function $u(){let t=x_();try{if(JSON.parse((0,Je.readFileSync)(t,"utf-8")).pid!==process.pid)return;(0,Je.unlinkSync)(t)}catch{}}function T_(t,e,r){let n=process.env[t];if(n){let o=parseInt(n,10);if(Number.isFinite(o)&&o>=r.min&&o<=r.max)return o;y.warn("SYSTEM",`Invalid ${t}, using default`,{value:n,min:r.min,max:r.max})}return e}var dj=T_("CLAUDE_MEM_HEALTH_TIMEOUT_MS",Ht(ye.HEALTH_CHECK),{min:500,max:3e5}),pj=T_("CLAUDE_MEM_HOOK_READINESS_TIMEOUT_MS",Ht(ye.HOOK_READINESS_WAIT),{min:0,max:3e5}),gP={min:500,max:3e5};async function Pu(t,e={},r){try{return await fetch(t,{...e,signal:AbortSignal.timeout(r)})}catch(n){throw n instanceof DOMException&&n.name==="TimeoutError"?new Error(`Request timed out after ${r}ms`):n}}var Zs=null,Fs=null,Hs=null,Ws=null;function _P(){return Pe.default.join(st.get("CLAUDE_MEM_DATA_DIR"),"settings.json")}function Tu(){return Hs!==null||(Hs=st.loadFromFile(_P())),Hs}function $_(t,e){if(!t)return null;let r=parseInt(t,10);return Number.isFinite(r)&&r>=e.min&&r<=e.max?r:null}function yP(t,e,r){let n=process.env[t];if(n!==void 0){let i=$_(n,r);return i!==null?i:(y.warn("SYSTEM",`Invalid ${t}, using default`,{value:n,min:r.min,max:r.max}),e)}let o=Tu()[t],s=$_(o,r);return s!==null?s:(y.warn("SYSTEM",`Invalid ${t} in settings.json, using default`,{value:o,min:r.min,max:r.max}),e)}function Ru(){if(Zs!==null)return Zs;let t=Tu();return Zs=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),Zs}function SP(){return Fs!==null||(Fs=Tu().CLAUDE_MEM_WORKER_HOST),Fs}function vP(){return Ws!==null||(Ws=yP("CLAUDE_MEM_API_TIMEOUT_MS",Ht(ye.API_REQUEST),gP)),Ws}function bP(t){return t.startsWith("[")&&t.endsWith("]")?t:t.includes(":")?`[${t}]`:t}function EP(t){return`http://${bP(SP())}:${Ru()}${t}`}function Vs(t,e={}){let r=e.method??"GET",n=e.timeoutMs??vP(),o=EP(t),s={method:r};return e.headers&&(s.headers=e.headers),e.body&&(s.body=e.body),n>0?Pu(o,s,n):fetch(o,s)}function R_(t){let e=(0,Ae.existsSync)(Pe.default.join(t,"plugin","scripts"))?Pe.default.join(t,"plugin"):t;return Pe.default.join(e,"scripts","worker-service.cjs")}function wP(t,e){let r=d=>{let p=d.split("-")[0].split(".");return[parseInt(p[0],10)||0,parseInt(p[1],10)||0,parseInt(p[2],10)||0]},[n,o,s]=r(t),[i,a,c]=r(e);if(i!==n)return i-n;if(a!==o)return a-o;if(c!==s)return c-s;let u=t.includes("-")?1:0,l=e.includes("-")?1:0;return u!==l?u-l:t<e?1:t>e?-1:0}function kP(t=Pe.default.join(Pe.default.dirname(Pe.default.dirname(co)),"cache","thedotmack","claude-mem")){try{return(0,Ae.readdirSync)(t).filter(e=>/^\d/.test(e)).map(e=>Pe.default.join(t,e)).filter(e=>{try{if(!(0,Ae.statSync)(e).isDirectory())return!1}catch{return!1}return!(0,Ae.existsSync)(Pe.default.join(e,".orphaned_at"))}).map(e=>({scriptPath:R_(e),version:Pe.default.basename(e)}))}catch{return[]}}function P_(t){try{let e=JSON.parse((0,Ae.readFileSync)(t,"utf-8"));return typeof e.version=="string"?e.version:null}catch(e){let r=e.code;return r!=="ENOENT"&&y.debug("SYSTEM","Could not read package version for worker resolution",{packageJsonPath:t,code:r}),null}}function xP(){let t=process.env.CLAUDE_MEM_WORKER_SCRIPT_PATH?.trim();if(t){if((0,Ae.existsSync)(t))return{scriptPath:t,version:null};y.debug("SYSTEM","Ignoring missing CLAUDE_MEM_WORKER_SCRIPT_PATH override",{override:t})}let e=[...kP(),{scriptPath:R_(Pe.default.join(co,"plugin")),version:P_(Pe.default.join(co,"package.json"))},{scriptPath:Pe.default.join(process.cwd(),"plugin","scripts","worker-service.cjs"),version:P_(Pe.default.join(process.cwd(),"package.json"))}];return $P(e)}function $P(t){let e=t.filter(r=>(0,Ae.existsSync)(r.scriptPath));return e.length===0?null:(e.sort((r,n)=>r.version===null&&n.version===null?0:r.version===null?1:n.version===null?-1:wP(r.version,n.version)),e[0])}function z_(){return xP()?.scriptPath??null}var zu=Tt(require("path"),1),Be=require("fs");ce();var PP=120*1e3;function Iu(){return zu.default.join(st.get("CLAUDE_MEM_DATA_DIR"),".worker-start-attempted")}function TP(){if(process.platform!=="win32")return!1;let t=Iu();if(!(0,Be.existsSync)(t))return!1;try{let e=(0,Be.statSync)(t).mtimeMs;return Date.now()-e<PP}catch(e){return e instanceof Error?y.debug("SYSTEM","Could not stat worker spawn lock file",{},e):y.debug("SYSTEM","Could not stat worker spawn lock file",{error:String(e)}),!1}}function RP(){if(process.platform==="win32")try{let t=Iu();(0,Be.mkdirSync)(zu.default.dirname(t),{recursive:!0}),(0,Be.writeFileSync)(t,"","utf-8")}catch{}}function Ks(){if(process.platform==="win32")try{let t=Iu();(0,Be.existsSync)(t)&&(0,Be.unlinkSync)(t)}catch{}}async function I_(t,e){if(!e)return y.error("SYSTEM","ensureWorkerStarted called with empty workerScriptPath \u2014 caller bug"),"dead";if(!(0,Be.existsSync)(e))return y.error("SYSTEM","ensureWorkerStarted: worker script not found at expected path \u2014 likely a partial install or build artifact missing",{workerScriptPath:e}),"dead";if(Us()==="alive"){if(y.info("SYSTEM","Worker PID file points to a live process, skipping duplicate spawn"),await Xn(t,Lr(ye.READINESS_WAIT)))return Ks(),y.info("SYSTEM","Worker became ready while waiting on live PID"),"ready";let a=await Gn(t,1e3),c=Us()==="alive";return!a&&!c?(y.error("SYSTEM","Live PID disappeared before readiness endpoint became available"),"dead"):(y.warn("SYSTEM","Live PID detected but worker did not become ready before timeout"),"warming")}if(await Gn(t,1e3)){Ks();let i=await Xn(t,Lr(ye.READINESS_WAIT));return i||y.warn("SYSTEM","Worker is alive but readiness timed out \u2014 proceeding anyway"),y.info("SYSTEM","Worker already running and healthy"),i?"ready":"warming"}if(await w_(t)){if(y.info("SYSTEM","Port in use, waiting for worker to become healthy"),await Gn(t,Lr(ye.PORT_IN_USE_WAIT))){Ks();let a=await Xn(t,Lr(ye.READINESS_WAIT));return y.info("SYSTEM","Worker is now healthy"),a?"ready":"warming"}return y.error("SYSTEM","Port in use but worker not responding to health checks"),"dead"}if(TP())return y.warn("SYSTEM","Worker unavailable on Windows \u2014 skipping spawn (recent attempt failed within cooldown)"),"dead";let o=xu(),s;try{if(o){if(y.info("SYSTEM","Starting worker daemon",{workerScriptPath:e}),RP(),s=S_(e,t),s===void 0)return y.error("SYSTEM","Failed to spawn worker daemon"),"dead"}else y.info("SYSTEM","Another launcher holds the spawn lock \u2014 skipping duplicate spawn and waiting for its worker");if(!await Xn(t,Lr(ye.READINESS_WAIT))){let a=await Gn(t,1e3),c=Us()==="alive",u=s!==void 0&&s>0&&Ve(s);return!a&&!c&&!u?(y.error("SYSTEM",o?"Worker exited before readiness endpoint became available":"Spawn-lock holder never produced a live worker before readiness timed out"),"dead"):(y.warn("SYSTEM",o?"Worker spawned but readiness endpoint not responding within window":"Spawn-lock holder's worker not ready within window"),"warming")}return Ks(),v_(),y.info("SYSTEM",o?"Worker started successfully":"Worker is up (started by another launcher)"),"ready"}finally{o&&$u()}}var qr=require("node:fs/promises"),eo=require("node:path");var C_=require("node:child_process"),it=require("node:fs"),Ye=require("node:path"),Du=require("node:os"),Cu=require("node:module");ce();var HP={},Mu=typeof __filename<"u"?(0,Cu.createRequire)(__filename):(0,Cu.createRequire)(HP.url),zP={".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 M_(t){let e=t.slice(t.lastIndexOf("."));return zP[e]??"unknown"}var IP={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"},OP={markdown:"tree-sitter-markdown"};function D_(t){let e=IP[t];if(!e)return null;let r=OP[t];if(r){try{let n=Mu.resolve(e+"/package.json"),o=(0,Ye.join)((0,Ye.dirname)(n),r);if((0,it.existsSync)((0,Ye.join)(o,"src")))return o}catch{}return null}try{let n=Mu.resolve(e+"/package.json");return(0,Ye.dirname)(n)}catch{return null}}var AP={jsts:`
|
|
86
86
|
(function_declaration name: (identifier) @name) @func
|
|
87
87
|
(lexical_declaration (variable_declarator name: (identifier) @name value: [(arrow_function) (function_expression)])) @const_func
|
|
88
88
|
(class_declaration name: (type_identifier) @name) @cls
|
|
@@ -204,25 +204,25 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
204
204
|
(class_definition name: (identifier) @name) @cls
|
|
205
205
|
(import_statement) @imp
|
|
206
206
|
(import_declaration) @imp
|
|
207
|
-
`};function
|
|
208
|
-
`)){if(o.length>0&&!o.startsWith(" ")&&!o.startsWith(" ")){r=o.trim(),e.has(r)||e.set(r,[]),n=null;continue}if(!r)continue;let s=o.match(/^\s+pattern:\s+(\d+)/);if(s){n={pattern:parseInt(s[1]),captures:[]},e.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 e}var
|
|
209
|
-
`),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
|
|
210
|
-
`).trim():void 0}function
|
|
211
|
-
`),o=
|
|
212
|
-
`);e.set(u.relativePath,{filePath:u.relativePath,language:n,symbols:[],imports:[],totalLines:l.length,foldedTokenEstimate:50})}continue}let i=N_(
|
|
213
|
-
`),d=c.get(u.absolutePath)||[],p=
|
|
214
|
-
`)}function
|
|
215
|
-
`)}function
|
|
216
|
-
`).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(`${e} \u{1F4AC} ${c}`)}}if(t.children&&t.children.length>0)for(let i of t.children)r.push(
|
|
217
|
-
`)}function
|
|
207
|
+
`};function N_(t){switch(t){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 Ou=null,Au=new Map;function j_(t){if(Au.has(t))return Au.get(t);Ou||(Ou=(0,it.mkdtempSync)((0,Ye.join)((0,Du.tmpdir)(),"smart-read-queries-")));let e=(0,Ye.join)(Ou,`${t}.scm`);return(0,it.writeFileSync)(e,AP[t]),Au.set(t,e),e}var Qn=null;function CP(){if(Qn)return Qn;try{let t=Mu.resolve("tree-sitter-cli/package.json"),e=(0,Ye.join)((0,Ye.dirname)(t),"tree-sitter");if((0,it.existsSync)(e))return Qn=e,e}catch{}return Qn="tree-sitter",Qn}function MP(t,e,r){return L_(t,[e],r).get(e)||[]}function L_(t,e,r){if(e.length===0)return new Map;let n=CP(),o=["query","-p",r,t,...e],s;try{s=(0,C_.execFileSync)(n,o,{encoding:"utf-8",timeout:3e4,stdio:["pipe","pipe","pipe"]})}catch(i){return y.debug("WORKER",`tree-sitter query failed for ${e.length} file(s)`,void 0,i instanceof Error?i:void 0),new Map}return DP(s)}function DP(t){let e=new Map,r=null,n=null;for(let o of t.split(`
|
|
208
|
+
`)){if(o.length>0&&!o.startsWith(" ")&&!o.startsWith(" ")){r=o.trim(),e.has(r)||e.set(r,[]),n=null;continue}if(!r)continue;let s=o.match(/^\s+pattern:\s+(\d+)/);if(s){n={pattern:parseInt(s[1]),captures:[]},e.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 e}var O_={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"},NP=new Set(["class","struct","impl","trait"]);function jP(t,e,r,n=200){let s=t[e]||"";if(!s.trimEnd().endsWith("{")&&!s.trimEnd().endsWith(":")){let i=t.slice(e,Math.min(e+10,r+1)).join(`
|
|
209
|
+
`),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 LP(t,e){let r=[],n=!1;for(let o=e-1;o>=0;o--){let s=t[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(t[o]),n=!0;else break}return r.length>0?r.join(`
|
|
210
|
+
`).trim():void 0}function UP(t,e,r){for(let n=e+1;n<=Math.min(e+3,r);n++){let o=t[n]?.trim();if(o){if(o.startsWith('"""')||o.startsWith("'''"))return o;break}}}function qP(t,e,r,n,o,s){switch(s){case"javascript":case"typescript":case"tsx":return n.some(i=>e>=i.startRow&&r<=i.endRow);case"python":return!t.startsWith("_");case"go":return t.length>0&&t[0]===t[0].toUpperCase()&&t[0]!==t[0].toLowerCase();case"rust":return o[e]?.trimStart().startsWith("pub")??!1;default:return!0}}function U_(t,e,r){let n=[],o=[],s=[],i=[];for(let c of t)for(let u of c.captures)u.tag==="exp"&&s.push({startRow:u.startRow,endRow:u.endRow}),u.tag==="imp"&&o.push(u.text||e[u.startRow]?.trim()||"");for(let c of t){let u=c.captures.find(b=>O_[b.tag]),l=c.captures.find(b=>b.tag==="name");if(!u)continue;let d=u.startRow,p=u.endRow,f=O_[u.tag],m=l?.text||"anonymous",g;if(r==="markdown"&&f==="section"){let $=(e[d]||"").match(/^(#{1,6})\s/),k=$?$[1].length:1;g=`${"#".repeat(k)} ${m}`}else if(r==="markdown"&&f==="code"){let b=m!=="anonymous"?m:"";g=b?"```"+b:"```"}else r==="markdown"&&f==="metadata"?g="---frontmatter---":r==="markdown"&&f==="reference"?g=e[d]?.trim()||m:g=jP(e,d,p);let S=r==="markdown"?void 0:LP(e,d),v=r==="python"?UP(e,d,p):void 0,x={name:m,kind:f,signature:g,jsdoc:S||v,lineStart:d,lineEnd:p,exported:qP(m,d,p,s,e,r)};NP.has(f)&&(x.children=[],i.push({sym:x,startRow:d,endRow:p})),n.push(x)}if(r==="markdown"){let c=new Map,u=new Set;for(let l of n){if(l.kind!=="code")continue;let d=`${l.lineStart}:${l.lineEnd}`,p=c.get(d);p?l.name!=="anonymous"?(u.add(p),c.set(d,l)):u.add(l):c.set(d,l)}if(u.size>0){let l=n.filter(d=>!u.has(d));n.length=0,n.push(...l)}}let 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 Js(t,e){let r=M_(e),n=t.split(`
|
|
211
|
+
`),o=D_(r);if(!o)return{filePath:e,language:r,symbols:[],imports:[],totalLines:n.length,foldedTokenEstimate:50};let s=j_(N_(r)),i=e.slice(e.lastIndexOf("."))||".txt",a=(0,it.mkdtempSync)((0,Ye.join)((0,Du.tmpdir)(),"smart-src-")),c=(0,Ye.join)(a,`source${i}`);(0,it.writeFileSync)(c,t);try{let u=MP(s,c,o),l=U_(u,n,r),d=Ur({filePath:e,language:r,symbols:l.symbols,imports:l.imports,totalLines:n.length,foldedTokenEstimate:0});return{filePath:e,language:r,symbols:l.symbols,imports:l.imports,totalLines:n.length,foldedTokenEstimate:Math.ceil(d.length/4)}}finally{(0,it.rmSync)(a,{recursive:!0,force:!0})}}function q_(t){let e=new Map,r=new Map;for(let n of t){let o=M_(n.relativePath);r.has(o)||r.set(o,[]),r.get(o).push(n)}for(let[n,o]of r){let s=D_(n);if(!s){for(let u of o){let l=u.content.split(`
|
|
212
|
+
`);e.set(u.relativePath,{filePath:u.relativePath,language:n,symbols:[],imports:[],totalLines:l.length,foldedTokenEstimate:50})}continue}let i=j_(N_(n)),a=o.map(u=>u.absolutePath),c=L_(i,a,s);for(let u of o){let l=u.content.split(`
|
|
213
|
+
`),d=c.get(u.absolutePath)||[],p=U_(d,l,n),f=Ur({filePath:u.relativePath,language:n,symbols:p.symbols,imports:p.imports,totalLines:l.length,foldedTokenEstimate:0});e.set(u.relativePath,{filePath:u.relativePath,language:n,symbols:p.symbols,imports:p.imports,totalLines:l.length,foldedTokenEstimate:Math.ceil(f.length/4)})}}return e}function Ur(t){if(t.language==="markdown")return ZP(t);let e=[];if(e.push(`\u{1F4C1} ${t.filePath} (${t.language}, ${t.totalLines} lines)`),e.push(""),t.imports.length>0){e.push(` \u{1F4E6} Imports: ${t.imports.length} statements`);for(let r of t.imports.slice(0,10))e.push(` ${r}`);t.imports.length>10&&e.push(` ... +${t.imports.length-10} more`),e.push("")}for(let r of t.symbols)e.push(Z_(r," "));return e.join(`
|
|
214
|
+
`)}function ZP(t){let e=[];e.push(`\u{1F4C4} ${t.filePath} (${t.language}, ${t.totalLines} lines)`);for(let n of t.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}`;e.push(`${c.padEnd(56)}${a}`)}else if(n.kind==="code"){let o=A_(t.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}`;e.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}`;e.push(`${s.padEnd(56)}${o}`)}else if(n.kind==="reference"){let o=A_(t.symbols,n.lineStart),s=" ".repeat(o+1),i=`L${n.lineStart+1}`,a=`${s}\u2197 ${n.name}`;e.push(`${a.padEnd(56)}${i}`)}return e.join(`
|
|
215
|
+
`)}function A_(t,e){let r=0;for(let n of t)if(n.kind==="section"&&n.lineStart<e){let o=n.signature.match(/^(#{1,6})\s/);r=o?o[1].length:1}return r}function Z_(t,e){let r=[],n=FP(t.kind),o=t.exported?" [exported]":"",s=t.lineStart===t.lineEnd?`L${t.lineStart+1}`:`L${t.lineStart+1}-${t.lineEnd+1}`;if(r.push(`${e}${n} ${t.name}${o} (${s})`),r.push(`${e} ${t.signature}`),t.jsdoc){let a=t.jsdoc.split(`
|
|
216
|
+
`).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(`${e} \u{1F4AC} ${c}`)}}if(t.children&&t.children.length>0)for(let i of t.children)r.push(Z_(i,e+" "));return r.join(`
|
|
217
|
+
`)}function FP(t){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"}[t]||"\xB7"}function F_(t,e,r){let n=Js(t,e),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=t.split(`
|
|
218
218
|
`);if(n.language==="markdown"&&s.kind==="section"){let u=s.signature.match(/^(#{1,6})\s/),l=u?u[1].length:1,d=s.lineStart,p=i.length-1;for(let m of n.symbols)if(m.kind==="section"&&m.lineStart>d){let g=m.signature.match(/^(#{1,6})\s/);if((g?g[1].length:1)<=l){for(p=m.lineStart-1;p>d&&i[p].trim()==="";)p--;break}}let f=i.slice(d,p+1).join(`
|
|
219
219
|
`);return`<!-- \u{1F4CD} ${e} L${d+1}-${p+1} -->
|
|
220
220
|
${f}`}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(`
|
|
221
221
|
`);return`// \u{1F4CD} ${e} L${a+1}-${s.lineEnd+1}
|
|
222
|
-
${c}`}
|
|
222
|
+
${c}`}ce();var WP=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"]),VP=new Set(["node_modules",".git","dist","build",".next","__pycache__",".venv","venv","env",".env","target","vendor",".cache",".turbo","coverage",".nyc_output",".claude",".smart-file-read"]),KP=512*1024;async function*H_(t,e,r=20){if(r<=0)return;let n;try{n=await(0,qr.readdir)(t,{withFileTypes:!0})}catch(o){y.debug("WORKER",`walkDir: failed to read directory ${t}`,void 0,o instanceof Error?o:void 0);return}for(let o of n){if(o.name.startsWith(".")&&o.name!=="."||VP.has(o.name))continue;let s=(0,eo.join)(t,o.name);if(o.isDirectory())yield*H_(s,e,r-1);else if(o.isFile()){let i=o.name.slice(o.name.lastIndexOf("."));WP.has(i)&&(yield s)}}}async function JP(t){try{let e=await(0,qr.stat)(t);if(e.size>KP||e.size===0)return null;let r=await(0,qr.readFile)(t,"utf-8");return r.slice(0,1e3).includes("\0")?null:r}catch(e){return y.debug("WORKER",`safeReadFile: failed to read ${t}`,void 0,e instanceof Error?e:void 0),null}}async function W_(t,e,r={}){let n=r.maxResults||20,o=e.toLowerCase(),s=o.split(/[\s_\-./]+/).filter(g=>g.length>0),i=[];for await(let g of H_(t,t,20)){if(r.filePattern&&!(0,eo.relative)(t,g).toLowerCase().includes(r.filePattern.toLowerCase()))continue;let S=await JP(g);S&&i.push({absolutePath:g,relativePath:(0,eo.relative)(t,g),content:S})}let a=q_(i),c=[],u=[],l=0;for(let[g,S]of a){l+=BP(S);let x=Bs(g.toLowerCase(),s)>0,b=[],$=(k,Se)=>{for(let K of k){let ct=0,Ne="",Pt=Bs(K.name.toLowerCase(),s);Pt>0&&(ct+=Pt*3,Ne="name match"),K.signature.toLowerCase().includes(o)&&(ct+=2,Ne=Ne?`${Ne} + signature`:"signature match"),K.jsdoc&&K.jsdoc.toLowerCase().includes(o)&&(ct+=1,Ne=Ne?`${Ne} + jsdoc`:"jsdoc match"),ct>0&&(x=!0,b.push({filePath:g,symbolName:Se?`${Se}.${K.name}`:K.name,kind:K.kind,signature:K.signature,jsdoc:K.jsdoc,lineStart:K.lineStart,lineEnd:K.lineEnd,matchReason:Ne})),K.children&&$(K.children,K.name)}};$(S.symbols),x&&(c.push(S),u.push(...b))}u.sort((g,S)=>{let v=Bs(g.symbolName.toLowerCase(),s);return Bs(S.symbolName.toLowerCase(),s)-v});let d=u.slice(0,n),p=new Set(d.map(g=>g.filePath)),f=c.filter(g=>p.has(g.filePath)).slice(0,n),m=f.reduce((g,S)=>g+S.foldedTokenEstimate,0);return{foldedFiles:f,matchingSymbols:d,totalFilesScanned:i.length,totalSymbolsFound:l,tokenEstimate:m}}function Bs(t,e){let r=0;for(let n of e)if(t===n)r+=10;else if(t.includes(n))r+=5;else{let o=0,s=0;for(let i of n){let a=t.indexOf(i,o);a!==-1&&(s++,o=a+1)}s===n.length&&(r+=1)}return r}function BP(t){let e=t.symbols.length;for(let r of t.symbols)r.children&&(e+=r.children.length);return e}function V_(t,e){let r=[];if(r.push(`\u{1F50D} Smart Search: "${e}"`),r.push(` Scanned ${t.totalFilesScanned} files, found ${t.totalSymbolsFound} symbols`),r.push(` ${t.matchingSymbols.length} matches across ${t.foldedFiles.length} files (~${t.tokenEstimate} tokens for folded view)`),r.push(""),t.matchingSymbols.length===0)return r.push(" No matching symbols found."),r.join(`
|
|
223
223
|
`);r.push("\u2500\u2500 Matching Symbols \u2500\u2500"),r.push("");for(let n of t.matchingSymbols){if(r.push(` ${n.kind} ${n.symbolName} (${n.filePath}:${n.lineStart+1})`),r.push(` ${n.signature}`),n.jsdoc){let o=n.jsdoc.split(`
|
|
224
224
|
`).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 t.foldedFiles)r.push(Ur(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(`
|
|
225
|
-
`)}var Nu=require("node:fs/promises"),Ys=require("node:fs"),it=require("node:path"),Y_=require("node:os"),G_=require("node:url");var V_="claude";function WP(t){return t.trim().toLowerCase().replace(/\s+/g,"-")}function Js(t){if(!t)return V_;let e=WP(t);return e?e==="transcript"||e.includes("codex")?"codex":e.includes("cursor")?"cursor":e.includes("claude")?"claude":e:V_}var VP=Ht(de.API_REQUEST),Ye=class extends Error{kind;status;cause;constructor(e,r,n={}){super(r),this.name="ServerClientError",this.kind=e,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)}},Bs=class{baseUrl;apiKey;timeoutMs;constructor(e){this.baseUrl=KP(e.serverBaseUrl),this.apiKey=e.apiKey,this.timeoutMs=e.timeoutMs??VP}async startSession(e){let r=this.buildStartSessionPayload(e);return this.request("POST","/v1/sessions/start",r)}async recordEvent(e){let r=this.buildEventPayload(e),n=e.generate===!1?"/v1/events?generate=false":"/v1/events";return this.request("POST",n,r)}async endSession(e){if(!e.sessionId)throw new Ye("invalid_response","sessionId is required for endSession");return this.request("POST",`/v1/sessions/${encodeURIComponent(e.sessionId)}/end`,{})}async addObservation(e){return this.request("POST","/v1/memories",this.buildAddObservationPayload(e))}async searchObservations(e){return this.request("POST","/v1/search",this.buildSearchPayload(e))}async contextObservations(e){return this.request("POST","/v1/context",this.buildSearchPayload(e))}async getJobStatus(e){if(!e)throw new Ye("invalid_response","jobId is required for getJobStatus");return this.request("GET",`/v1/jobs/${encodeURIComponent(e)}`)}buildAddObservationPayload(e){let r=e.content,n=e.kind??"manual",o=typeof e.metadata?.title=="string"?e.metadata.title:void 0;return{projectId:e.projectId,kind:n,type:n,narrative:r,...o?{title:o}:{},...e.serverSessionId!==void 0?{serverSessionId:e.serverSessionId}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}}buildSearchPayload(e){return{projectId:e.projectId,query:e.query,...e.limit!==void 0?{limit:e.limit}:{},...e.platformSource!==void 0?{platformSource:Mu(e.platformSource)}:{}}}buildStartSessionPayload(e){return{projectId:e.projectId,...e.externalSessionId!==void 0?{externalSessionId:e.externalSessionId}:{},...e.contentSessionId!==void 0?{contentSessionId:e.contentSessionId}:{},...e.agentId!==void 0?{agentId:e.agentId}:{},...e.agentType!==void 0?{agentType:e.agentType}:{},...e.platformSource!==void 0?{platformSource:Mu(e.platformSource)}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}}buildEventPayload(e){return{projectId:e.projectId,sourceType:e.sourceType,eventType:e.eventType,occurredAtEpoch:e.occurredAtEpoch,...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:Mu(e.platformSource)}:{},...e.payload!==void 0?{payload:e.payload}:{}}}async request(e,r,n){if(!this.apiKey||!this.apiKey.trim())throw new Ye("missing_api_key","Server API key is not configured (CLAUDE_MEM_SERVER_API_KEY).");let o=`${this.baseUrl}${r}`,s={method:e,headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}};n!==void 0&&(s.body=JSON.stringify(n));let i;try{i=await xu(o,s,this.timeoutMs)}catch(c){let u=c instanceof Error?c.message:String(c),l=/timed out|timeout/i.test(u);throw new Ye(l?"timeout":"transport",`Server ${e} ${r} failed: ${u}`,{cause:c})}if(!i.ok){let c=await i.text().catch(()=>"");throw new Ye("http_error",`Server ${e} ${r} returned ${i.status}: ${JP(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 Ye("invalid_response",`Server ${e} ${r} returned non-JSON response`,{cause:u})}}};function K_(t){return t instanceof Ye}function KP(t){return t.replace(/\/+$/,"")}function Mu(t){return typeof t=="string"?Js(t):null}function JP(t,e){return t.length<=e?t:`${t.slice(0,e)}\u2026`}ue();function Du(){let e=(Cs().CLAUDE_MEM_RUNTIME??"worker").trim().toLowerCase();return e==="server"||e==="server-beta"?"server":"worker"}function J_(){let t=Cs(),e=(...i)=>{for(let a of i){let c=(a??"").trim();if(c.length>0)return c}return""},r=e(t.CLAUDE_MEM_SERVER_URL,t.CLAUDE_MEM_SERVER_BETA_URL),n=e(t.CLAUDE_MEM_SERVER_API_KEY,t.CLAUDE_MEM_SERVER_BETA_API_KEY),o=e(t.CLAUDE_MEM_SERVER_PROJECT_ID,t.CLAUDE_MEM_SERVER_BETA_PROJECT_ID);if(!r)return y.warn("HOOK","[server-fallback] reason=missing_base_url"),null;if(!n)return y.warn("HOOK","[server-fallback] reason=missing_api_key"),null;if(!o)return y.warn("HOOK","[server-fallback] reason=missing_project_id"),null;let s={serverBaseUrl:r,apiKey:n};return{runtime:"server",client:new Bs(s),projectId:o,serverBaseUrl:r}}var hT={},BP="13.12.1";console.log=(...t)=>{y.error("CONSOLE","Intercepted console output (MCP protocol protection)",void 0,{args:t})};var X_=!1,Q_=(()=>{if(typeof __dirname<"u")return __dirname;try{return(0,it.dirname)((0,G_.fileURLToPath)(hT.url))}catch(t){return X_=!0,y.warn("SYSTEM","mcp-server: failed to resolve module directory from import.meta.url, falling back to process.cwd()",void 0,t instanceof Error?t:new Error(String(t))),process.cwd()}})(),ju=z_()??(0,it.resolve)(Q_,"worker-service.cjs");function YP(){X_&&((0,Ys.existsSync)(ju)||y.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:ju,mcpServerDir:Q_}))}async function _t(t,e={}){y.debug("SYSTEM","\u2192 Worker API",void 0,{endpoint:t});try{let r;if(e.body)r=await Hs(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e.body)});else{let n=new URLSearchParams;for(let[o,s]of Object.entries(e.query??{}))s!=null&&n.append(o,String(s));r=await Hs(`${t}?${n}`)}if(!r.ok){let n=await r.text();throw new Error(`Worker API error (${r.status}): ${n}`)}return y.debug("SYSTEM","\u2190 Worker API success",void 0,{endpoint:t}),e.text?{content:[{type:"text",text:await r.text()}]}:e.body?{content:[{type:"text",text:JSON.stringify(await r.json(),null,2)}]}:await r.json()}catch(r){return y.error("SYSTEM","\u2190 Worker API error",{endpoint:t},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 GP(){try{return(await Hs("/api/health")).ok}catch(t){return y.debug("SYSTEM","Worker health check failed",{},t instanceof Error?t:new Error(String(t))),!1}}function XP(){if(Du()!=="server")return null;let e=J_();return e?{...e,available:!0}:{runtime:"server",available:!1,reason:"server runtime is selected but configuration is incomplete (missing url, api key, or project id)"}}function QP(t){return K_(t)?{content:[{type:"text",text:`Server error (${t.kind}${t.status?` ${t.status}`:""}): ${t.message}`}],isError:!0}:{content:[{type:"text",text:`Tool error: ${t instanceof Error?t.message:String(t)}`}],isError:!0}}function Qn(t){return{content:[{type:"text",text:JSON.stringify(t,null,2)}]}}function eo(t){let e=XP();if(!e)throw new Ye("transport",`${t} requires CLAUDE_MEM_RUNTIME=server. Current runtime is "worker"; use the existing search/timeline/get_observations tools for worker-mode memory access.`);if(!e.available)throw new Ye("missing_api_key",`${t}: ${e.reason}`);return e}function to(t,e){return async r=>{try{return await e(r)}catch(n){let o=n instanceof Error?n:new Error(String(n));return y.warn("SYSTEM",`${t} failed`,void 0,o),QP(n)}}}var eT=to("observation_add",async t=>{let e=eo("observation_add");if(typeof t?.content!="string"||t.content.trim().length===0)throw new Error('observation_add: "content" is required');let n={projectId:t.projectId&&t.projectId.trim().length>0?t.projectId:e.projectId,content:t.content,...t.serverSessionId!==void 0?{serverSessionId:t.serverSessionId}:{},...t.kind!==void 0?{kind:t.kind}:{},...t.metadata!==void 0?{metadata:t.metadata}:{}},o=await e.client.addObservation(n);return Qn(o)});function Xs(t){return typeof t=="string"?Js(t):null}var tT=to("observation_record_event",async t=>{let e=eo("observation_record_event");if(typeof t?.eventType!="string"||t.eventType.trim().length===0)throw new Error('observation_record_event: "eventType" is required');let n={projectId:t.projectId&&t.projectId.trim().length>0?t.projectId:e.projectId,sourceType:t.sourceType??"api",eventType:t.eventType,occurredAtEpoch:typeof t.occurredAtEpoch=="number"?t.occurredAtEpoch:Date.now(),...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:Xs(t.platformSource)}:{},...t.payload!==void 0?{payload:t.payload}:{},...t.generate!==void 0?{generate:t.generate}:{}},o=await e.client.recordEvent(n);return Qn(o)}),rT=to("observation_search",async t=>{let e=eo("observation_search");if(typeof t?.query!="string"||t.query.trim().length===0)throw new Error('observation_search: "query" is required');let n={projectId:t.projectId&&t.projectId.trim().length>0?t.projectId:e.projectId,query:t.query,...t.limit!==void 0?{limit:t.limit}:{},...t.platformSource!==void 0?{platformSource:Xs(t.platformSource)}:{}},o=await e.client.searchObservations(n);return Qn(o)}),nT=to("observation_context",async t=>{let e=eo("observation_context");if(typeof t?.query!="string"||t.query.trim().length===0)throw new Error('observation_context: "query" is required');let n={projectId:t.projectId&&t.projectId.trim().length>0?t.projectId:e.projectId,query:t.query,...t.limit!==void 0?{limit:t.limit}:{},...t.platformSource!==void 0?{platformSource:Xs(t.platformSource)}:{}},o=await e.client.contextObservations(n);return Qn(o)});function oT(t){return Array.isArray(t.projects)?t.projects.map(e=>typeof e=="string"?e.trim():"").filter(Boolean):typeof t.projects=="string"?t.projects.split(",").map(e=>e.trim()).filter(Boolean):typeof t.project=="string"&&t.project.trim().length>0?[t.project.trim()]:[]}async function sT(t){let e=oT(t);return e.length===0?{content:[{type:"text",text:'session_start_context: "project" or "projects" is required'}],isError:!0}:_t("/api/context/inject",{query:{projects:e.join(","),...t.platformSource!==void 0?{platformSource:Xs(t.platformSource)}:{},...t.full!==void 0?{full:t.full}:{},...t.colors!==void 0?{colors:t.colors}:{}},text:!0})}var iT=to("observation_generation_status",async t=>{let e=eo("observation_generation_status"),r=(t?.jobId??t?.job_id??"").trim();if(!r)throw new Error('observation_generation_status: "jobId" is required');let n=await e.client.getJobStatus(r);return Qn(n)});async function aT(){if(await GP())return!0;y.warn("SYSTEM","Worker not available, attempting auto-start for MCP client"),YP();try{let t=Pu(),e=await R_(t,ju);return e==="dead"&&y.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.)."),e!=="dead"}catch(t){return y.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,t instanceof Error?t:new Error(String(t))),!1}}var ey=[{name:"__IMPORTANT",description:`3-LAYER WORKFLOW (ALWAYS FOLLOW):
|
|
225
|
+
`)}var ju=require("node:fs/promises"),Qs=require("node:fs"),at=require("node:path"),Q_=require("node:os"),ey=require("node:url");var K_="claude";function YP(t){return t.trim().toLowerCase().replace(/\s+/g,"-")}function Ys(t){if(!t)return K_;let e=YP(t);return e?e==="transcript"||e.includes("codex")?"codex":e.includes("cursor")?"cursor":e.includes("claude")?"claude":e:K_}var GP=Ht(ye.API_REQUEST),Ge=class extends Error{kind;status;cause;constructor(e,r,n={}){super(r),this.name="ServerClientError",this.kind=e,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)}},Gs=class{baseUrl;apiKey;timeoutMs;constructor(e){this.baseUrl=XP(e.serverBaseUrl),this.apiKey=e.apiKey,this.timeoutMs=e.timeoutMs??GP}async startSession(e){let r=this.buildStartSessionPayload(e);return this.request("POST","/v1/sessions/start",r)}async recordEvent(e){let r=this.buildEventPayload(e),n=e.generate===!1?"/v1/events?generate=false":"/v1/events";return this.request("POST",n,r)}async endSession(e){if(!e.sessionId)throw new Ge("invalid_response","sessionId is required for endSession");return this.request("POST",`/v1/sessions/${encodeURIComponent(e.sessionId)}/end`,{})}async addObservation(e){return this.request("POST","/v1/memories",this.buildAddObservationPayload(e))}async searchObservations(e){return this.request("POST","/v1/search",this.buildSearchPayload(e))}async contextObservations(e){return this.request("POST","/v1/context",this.buildSearchPayload(e))}async getJobStatus(e){if(!e)throw new Ge("invalid_response","jobId is required for getJobStatus");return this.request("GET",`/v1/jobs/${encodeURIComponent(e)}`)}buildAddObservationPayload(e){let r=e.content,n=e.kind??"manual",o=typeof e.metadata?.title=="string"?e.metadata.title:void 0;return{projectId:e.projectId,kind:n,type:n,narrative:r,...o?{title:o}:{},...e.serverSessionId!==void 0?{serverSessionId:e.serverSessionId}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}}buildSearchPayload(e){return{projectId:e.projectId,query:e.query,...e.limit!==void 0?{limit:e.limit}:{},...e.platformSource!==void 0?{platformSource:Nu(e.platformSource)}:{}}}buildStartSessionPayload(e){return{projectId:e.projectId,...e.externalSessionId!==void 0?{externalSessionId:e.externalSessionId}:{},...e.contentSessionId!==void 0?{contentSessionId:e.contentSessionId}:{},...e.agentId!==void 0?{agentId:e.agentId}:{},...e.agentType!==void 0?{agentType:e.agentType}:{},...e.platformSource!==void 0?{platformSource:Nu(e.platformSource)}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}}buildEventPayload(e){return{projectId:e.projectId,sourceType:e.sourceType,eventType:e.eventType,occurredAtEpoch:e.occurredAtEpoch,...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:Nu(e.platformSource)}:{},...e.payload!==void 0?{payload:e.payload}:{}}}async request(e,r,n){if(!this.apiKey||!this.apiKey.trim())throw new Ge("missing_api_key","Server API key is not configured (CLAUDE_MEM_SERVER_API_KEY).");let o=`${this.baseUrl}${r}`,s={method:e,headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}};n!==void 0&&(s.body=JSON.stringify(n));let i;try{i=await Pu(o,s,this.timeoutMs)}catch(c){let u=c instanceof Error?c.message:String(c),l=/timed out|timeout/i.test(u);throw new Ge(l?"timeout":"transport",`Server ${e} ${r} failed: ${u}`,{cause:c})}if(!i.ok){let c=await i.text().catch(()=>"");throw new Ge("http_error",`Server ${e} ${r} returned ${i.status}: ${QP(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 Ge("invalid_response",`Server ${e} ${r} returned non-JSON response`,{cause:u})}}};function J_(t){return t instanceof Ge}function XP(t){return t.replace(/\/+$/,"")}function Nu(t){return typeof t=="string"?Ys(t):null}function QP(t,e){return t.length<=e?t:`${t.slice(0,e)}\u2026`}ce();function Xs(){let e=(Ms().CLAUDE_MEM_RUNTIME??"worker").trim().toLowerCase();return e==="server"||e==="server-beta"?"server":"worker"}function B_(){let t=Ms(),e=(...i)=>{for(let a of i){let c=(a??"").trim();if(c.length>0)return c}return""},r=e(t.CLAUDE_MEM_SERVER_URL,t.CLAUDE_MEM_SERVER_BETA_URL),n=e(t.CLAUDE_MEM_SERVER_API_KEY,t.CLAUDE_MEM_SERVER_BETA_API_KEY),o=e(t.CLAUDE_MEM_SERVER_PROJECT_ID,t.CLAUDE_MEM_SERVER_BETA_PROJECT_ID);if(!r)return y.warn("HOOK","[server-fallback] reason=missing_base_url"),null;if(!n)return y.warn("HOOK","[server-fallback] reason=missing_api_key"),null;if(!o)return y.warn("HOOK","[server-fallback] reason=missing_project_id"),null;let s={serverBaseUrl:r,apiKey:n};return{runtime:"server",client:new Gs(s),projectId:o,serverBaseUrl:r}}ce();var Y_=["observation_add","observation_record_event","observation_search","observation_context","observation_generation_status","memory_add","memory_search","memory_context"],eT=new Set(Y_);function G_(t,e){return e==="server"?[...t]:(y.debug("SYSTEM","Filtering server-beta-only MCP tools from worker runtime advertisement",{runtime:e,hiddenToolCount:Y_.length}),t.filter(r=>!eT.has(r.name)))}var vT={},tT="13.12.2";console.log=(...t)=>{y.error("CONSOLE","Intercepted console output (MCP protocol protection)",void 0,{args:t})};var ty=!1,ry=(()=>{if(typeof __dirname<"u")return __dirname;try{return(0,at.dirname)((0,ey.fileURLToPath)(vT.url))}catch(t){return ty=!0,y.warn("SYSTEM","mcp-server: failed to resolve module directory from import.meta.url, falling back to process.cwd()",void 0,t instanceof Error?t:new Error(String(t))),process.cwd()}})(),Lu=z_()??(0,at.resolve)(ry,"worker-service.cjs");function rT(){ty&&((0,Qs.existsSync)(Lu)||y.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:Lu,mcpServerDir:ry}))}async function _t(t,e={}){y.debug("SYSTEM","\u2192 Worker API",void 0,{endpoint:t});try{let r;if(e.body)r=await Vs(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e.body)});else{let n=new URLSearchParams;for(let[o,s]of Object.entries(e.query??{}))s!=null&&n.append(o,String(s));r=await Vs(`${t}?${n}`)}if(!r.ok){let n=await r.text();throw new Error(`Worker API error (${r.status}): ${n}`)}return y.debug("SYSTEM","\u2190 Worker API success",void 0,{endpoint:t}),e.text?{content:[{type:"text",text:await r.text()}]}:e.body?{content:[{type:"text",text:JSON.stringify(await r.json(),null,2)}]}:await r.json()}catch(r){return y.error("SYSTEM","\u2190 Worker API error",{endpoint:t},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 nT(){try{return(await Vs("/api/health")).ok}catch(t){return y.debug("SYSTEM","Worker health check failed",{},t instanceof Error?t:new Error(String(t))),!1}}function ny(){if(Xs()!=="server")return null;let e=B_();return e?{...e,available:!0}:{runtime:"server",available:!1,reason:"server runtime is selected but configuration is incomplete (missing url, api key, or project id)"}}function oT(t){return J_(t)?{content:[{type:"text",text:`Server error (${t.kind}${t.status?` ${t.status}`:""}): ${t.message}`}],isError:!0}:{content:[{type:"text",text:`Tool error: ${t instanceof Error?t.message:String(t)}`}],isError:!0}}function Zr(t){return{content:[{type:"text",text:JSON.stringify(t,null,2)}]}}function ro(t){let e=ny();if(!e)throw new Ge("transport",`${t} requires CLAUDE_MEM_RUNTIME=server. Current runtime is "worker"; use the existing search/timeline/get_observations tools for worker-mode memory access.`);if(!e.available)throw new Ge("missing_api_key",`${t}: ${e.reason}`);return e}function no(t,e){return async r=>{try{return await e(r)}catch(n){let o=n instanceof Error?n:new Error(String(n));return y.warn("SYSTEM",`${t} failed`,void 0,o),oT(n)}}}var sT=no("observation_add",async t=>{let e=ro("observation_add");if(typeof t?.content!="string"||t.content.trim().length===0)throw new Error('observation_add: "content" is required');let n={projectId:t.projectId&&t.projectId.trim().length>0?t.projectId:e.projectId,content:t.content,...t.serverSessionId!==void 0?{serverSessionId:t.serverSessionId}:{},...t.kind!==void 0?{kind:t.kind}:{},...t.metadata!==void 0?{metadata:t.metadata}:{}},o=await e.client.addObservation(n);return Zr(o)});function ti(t){return typeof t=="string"?Ys(t):null}var iT=no("observation_record_event",async t=>{let e=ro("observation_record_event");if(typeof t?.eventType!="string"||t.eventType.trim().length===0)throw new Error('observation_record_event: "eventType" is required');let n={projectId:t.projectId&&t.projectId.trim().length>0?t.projectId:e.projectId,sourceType:t.sourceType??"api",eventType:t.eventType,occurredAtEpoch:typeof t.occurredAtEpoch=="number"?t.occurredAtEpoch:Date.now(),...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:ti(t.platformSource)}:{},...t.payload!==void 0?{payload:t.payload}:{},...t.generate!==void 0?{generate:t.generate}:{}},o=await e.client.recordEvent(n);return Zr(o)}),aT=no("observation_search",async t=>{let e=ro("observation_search");if(typeof t?.query!="string"||t.query.trim().length===0)throw new Error('observation_search: "query" is required');let n={projectId:t.projectId&&t.projectId.trim().length>0?t.projectId:e.projectId,query:t.query,...t.limit!==void 0?{limit:t.limit}:{},...t.platformSource!==void 0?{platformSource:ti(t.platformSource)}:{}},o=await e.client.searchObservations(n);return Zr(o)}),cT=no("observation_context",async t=>{let e=ro("observation_context");if(typeof t?.query!="string"||t.query.trim().length===0)throw new Error('observation_context: "query" is required');let n={projectId:t.projectId&&t.projectId.trim().length>0?t.projectId:e.projectId,query:t.query,...t.limit!==void 0?{limit:t.limit}:{},...t.platformSource!==void 0?{platformSource:ti(t.platformSource)}:{}},o=await e.client.contextObservations(n);return Zr(o)});function uT(t){return Array.isArray(t.projects)?t.projects.map(e=>typeof e=="string"?e.trim():"").filter(Boolean):typeof t.projects=="string"?t.projects.split(",").map(e=>e.trim()).filter(Boolean):typeof t.project=="string"&&t.project.trim().length>0?[t.project.trim()]:[]}async function lT(t){let e=uT(t);return e.length===0?{content:[{type:"text",text:'session_start_context: "project" or "projects" is required'}],isError:!0}:_t("/api/context/inject",{query:{projects:e.join(","),...t.platformSource!==void 0?{platformSource:ti(t.platformSource)}:{},...t.full!==void 0?{full:t.full}:{},...t.colors!==void 0?{colors:t.colors}:{}},text:!0})}var dT=no("observation_generation_status",async t=>{let e=ro("observation_generation_status"),r=(t?.jobId??t?.job_id??"").trim();if(!r)throw new Error('observation_generation_status: "jobId" is required');let n=await e.client.getJobStatus(r);return Zr(n)});async function pT(){if(await nT())return!0;y.warn("SYSTEM","Worker not available, attempting auto-start for MCP client"),rT();try{let t=Ru(),e=await I_(t,Lu);return e==="dead"&&y.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.)."),e!=="dead"}catch(t){return y.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,t instanceof Error?t:new Error(String(t))),!1}}var oy=[{name:"important_workflow",description:`3-LAYER WORKFLOW (ALWAYS FOLLOW):
|
|
226
226
|
1. search(query) \u2192 Get index with IDs (~50-100 tokens/result)
|
|
227
227
|
2. timeline(anchor=ID) \u2192 Get context around interesting results
|
|
228
228
|
3. get_observations([IDs]) \u2192 Fetch full details ONLY for filtered IDs
|
|
@@ -242,8 +242,8 @@ NEVER fetch full details without filtering first. 10x token savings.`,inputSchem
|
|
|
242
242
|
\`get_observations(ids=[...])\` # ALWAYS batch for 2+ items
|
|
243
243
|
Returns: Complete details (~500-1000 tokens/result)
|
|
244
244
|
|
|
245
|
-
**Why:** 10x token savings. Never fetch full details without filtering first.`}]})},{name:"search",description:"Step 1: Search memory. Returns index with IDs. Params: query, limit, project, 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:"
|
|
245
|
+
**Why:** 10x token savings. Never fetch full details without filtering first.`}]})},{name:"search",description:"Step 1: Search memory. Returns index with IDs. Params: query, limit, project, 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 t=>{let e=ny(),r=typeof t?.query=="string"&&t.query.trim().length>0,n=t?.type===void 0||t?.type==="observations",o=t?.platformSource!==void 0||t?.project!==void 0||t?.obs_type!==void 0||t?.dateStart!==void 0||t?.dateEnd!==void 0||t?.offset!==void 0||t?.orderBy!==void 0;if(e&&e.available&&r&&n&&!o){let s={projectId:e.projectId,query:t.query,...t.limit!==void 0?{limit:t.limit}:{}};return Zr(await e.client.searchObservations(s))}return await _t("/api/search",{query:t})}},{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 t=>await _t("/api/timeline",{query:t})},{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 t=>await _t("/api/observations/batch",{body:t})},{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 t=>lT(t??{})},{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 t=>sT(t??{})},{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 t=>iT(t??{})},{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 t=>aT(t??{})},{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 t=>cT(t??{})},{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 t=>dT(t??{})},{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 t=>{let e=(0,at.resolve)(t.path||process.cwd()),r=await W_(e,t.query,{maxResults:t.max_results||20,filePattern:t.file_pattern});return{content:[{type:"text",text:V_(r,t.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 t=>{let e=(0,at.resolve)(t.file_path),r=await(0,ju.readFile)(e,"utf-8"),n=F_(r,e,t.symbol_name);if(n)return{content:[{type:"text",text:n}]};let o=Js(r,e);if(o.symbols.length>0){let s=o.symbols.map(i=>` - ${i.name} (${i.kind})`).join(`
|
|
246
246
|
`);return{content:[{type:"text",text:`Symbol "${t.symbol_name}" not found in ${t.file_path}.
|
|
247
247
|
|
|
248
248
|
Available symbols:
|
|
249
|
-
${s}`}]}}return{content:[{type:"text",text:`Could not parse ${t.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 t=>{let e=(0,
|
|
249
|
+
${s}`}]}}return{content:[{type:"text",text:`Could not parse ${t.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 t=>{let e=(0,at.resolve)(t.file_path),r=await(0,ju.readFile)(e,"utf-8"),n=Js(r,e);return n.symbols.length>0?{content:[{type:"text",text:Ur(n)}]}:{content:[{type:"text",text:`Could not parse ${t.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 t=>await _t("/api/corpus",{body:t})},{name:"list_corpora",description:"List all knowledge corpora with their stats and priming status",inputSchema:{type:"object",properties:{},additionalProperties:!0},handler:async t=>await _t("/api/corpus",{query:t})},{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 t=>{let{name:e,...r}=t;if(typeof e!="string"||e.trim()==="")throw new Error("Missing required argument: name");return await _t(`/api/corpus/${encodeURIComponent(e)}/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 t=>{let{name:e,...r}=t;if(typeof e!="string"||e.trim()==="")throw new Error("Missing required argument: name");return await _t(`/api/corpus/${encodeURIComponent(e)}/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 t=>{let{name:e,...r}=t;if(typeof e!="string"||e.trim()==="")throw new Error("Missing required argument: name");return await _t(`/api/corpus/${encodeURIComponent(e)}/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 t=>{let{name:e,...r}=t;if(typeof e!="string"||e.trim()==="")throw new Error("Missing required argument: name");return await _t(`/api/corpus/${encodeURIComponent(e)}/reprime`,{body:r})}}],Uu=new Rs({name:"claude-mem",version:tT},{capabilities:{tools:{}}});Uu.setRequestHandler(fa,async()=>({tools:G_(oy,Xs()).map(e=>({name:e.name,description:e.description,inputSchema:e.inputSchema}))}));Uu.setRequestHandler(gn,async t=>{let e=oy.find(r=>r.name===t.params.name);if(!e)throw new Error(`Unknown tool: ${t.params.name}`);try{return await e.handler(t.params.arguments||{})}catch(r){return y.error("SYSTEM","Tool execution failed",{tool:t.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 fT=3e4,to=null,X_=!1;function ei(){oo("stdio-closed")}function sy(t){y.warn("SYSTEM","MCP stdio stream errored, shutting down",{message:t.message}),oo("stdio-error")}function mT(){process.stdin.on("end",ei),process.stdin.on("close",ei),process.stdin.on("error",sy)}function hT(){process.stdin.off("end",ei),process.stdin.off("close",ei),process.stdin.off("error",sy)}function gT(){if(process.platform==="win32")return;let t=process.ppid;to=setInterval(()=>{(process.ppid===1||process.ppid!==t)&&(y.info("SYSTEM","Parent process died, self-exiting to prevent orphan",{initialPpid:t,currentPpid:process.ppid}),oo())},fT),to.unref&&to.unref()}function oo(t="shutdown"){X_||(X_=!0,to&&clearInterval(to),hT(),y.info("SYSTEM","MCP server shutting down",{reason:t}),process.exit(0))}process.on("SIGTERM",oo);process.on("SIGINT",oo);function _T(){let t=(0,Q_.homedir)(),e=[(0,at.resolve)(t,".claude","plugins","marketplaces","thedotmack"),(0,at.resolve)(t,".config","claude","plugins","marketplaces","thedotmack")],r=e.some(i=>i&&(0,Qs.existsSync)(i)),n=[(0,at.resolve)(t,".claude","plugins","cache","thedotmack","claude-mem"),(0,at.resolve)(t,".config","claude","plugins","cache","thedotmack","claude-mem")],o=n.some(i=>i&&(0,Qs.existsSync)(i)),s=n[0];!r&&o&&y.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:e,cacheRoot:s})}function yT(){try{_T()}catch(t){y.warn("SYSTEM","checkMarketplaceMarker failed (non-fatal startup check)",void 0,t instanceof Error?t:new Error(String(t)))}}async function ST(){let t=new Is;mT(),await Uu.connect(t),y.info("SYSTEM","Claude-mem search server started"),yT(),gT(),setTimeout(async()=>{if(Xs()==="server"){y.info("SYSTEM","MCP runtime=server \u2014 skipping worker auto-start",void 0,{});return}await pT()?y.info("SYSTEM","Worker available",void 0,{}):(y.error("SYSTEM","Worker not available",void 0,{}),y.error("SYSTEM","Tools will fail until Worker is started"),y.error("SYSTEM","Start Worker with: npm run worker:restart"))},0)}ST().catch(t=>{y.error("SYSTEM","Fatal error",void 0,t),process.exit(0)});
|