@anmol-srv/sigil 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +596 -408
- package/dist/daemon.js +298 -154
- package/dist/hooks/post-tool-use.js +25 -25
- package/dist/hooks/session-end.js +80 -69
- package/dist/hooks/stop.js +90 -79
- package/dist/hooks/user-prompt-submit.js +49 -49
- package/dist/server.js +47 -47
- package/package.json +2 -2
- package/prompts/chunk-context.md +12 -6
- package/prompts/graph-extraction.md +42 -0
- package/src/db/drivers/index.js +22 -4
- package/src/gui/web/app.css +308 -0
- package/src/gui/web/app.js +908 -15
- package/src/gui/web/index.html +77 -4
- package/src/gui/web/setup.js +12 -5
package/dist/server.js
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __sigilCreateRequire } from 'node:module'; const require = __sigilCreateRequire(import.meta.url);
|
|
3
|
-
var
|
|
4
|
-
`,{mode:384}),
|
|
5
|
-
`)){let n=r.match(/^\s*([A-Z_][A-Z0-9_]*)\s*=\s*(.*)$/i);if(!n)continue;let
|
|
3
|
+
var Wa=Object.defineProperty;var K=(t,e)=>()=>(t&&(e=t(t=0)),e);var Ze=(t,e)=>{for(var r in e)Wa(t,r,{get:e[r],enumerable:!0})};import{fileURLToPath as $l}from"node:url";import{dirname as ea,join as A}from"node:path";import{existsSync as ta}from"node:fs";import{homedir as Ml}from"node:os";function Dl(){let t=ea($l(import.meta.url));for(let e=0;e<10;e++){if(ta(A(t,"package.json"))&&ta(A(t,"prompts")))return t;let r=ea(t);if(r===t)break;t=r}return process.cwd()}var Ue,vv,bv,ra,N,or,ee,Tv,Iv,Ev,Sv,wv,Ov,Av,kv,Rv,Fe,ar,sr,na,Lv,Cv,Nv,Pv,$v,oa,Mv,Dv,ht=K(()=>{Ue=Dl(),vv=A(Ue,"prompts"),bv=A(Ue,"src","db","migrations"),ra=Ml(),N=A(ra,".sigil"),or=A(N,".env"),ee=A(N,"config.json"),Tv=A(N,"db"),Iv=A(N,"CLAUDE.md"),Ev=A(N,"schemas"),Sv=A(N,".hook-errors.log"),wv=A(N,".last-clean-doctor"),Ov=A(N,".active-session.json"),Av=A(N,".stop-cursor.json"),kv=A(N,".stop-spool.jsonl"),Rv=A(N,".hook-dedup.json"),Fe=A(N,"sock"),ar=A(N,"sigild.pid"),sr=A(N,"sigild.log"),na=A(N,"heartbeat.json"),Lv=A(N,"gui.token"),Cv=A(Ue,"dist","gui"),Nv=A(Ue,"src","gui","web"),Pv=A(N,"iroh"),$v=A(N,"identity.key"),oa=A(ra,".claude"),Mv=A(oa,"settings.json"),Dv=A(oa,"CLAUDE.md")});var He,ir=K(()=>{He=1024});var fa={};Ze(fa,{CONFIG_SCHEMA_VERSION:()=>Rt,EMBEDDING_DIM:()=>He,ensureDeviceId:()=>Xl,getConfig:()=>_t,isSetupComplete:()=>td,loadConfig:()=>ua,markSetupComplete:()=>ed,patchConfig:()=>Lt,resetConfig:()=>rd,setStepStatus:()=>Ql});import{existsSync as cr,readFileSync as ia,writeFileSync as jl,renameSync as ca,mkdirSync as Gl,chmodSync as Bl,unlinkSync as Ul}from"node:fs";import{dirname as Fl}from"node:path";import{randomUUID as Hl}from"node:crypto";function kt(){return{schemaVersion:Rt,device:{id:null},database:{mode:null,url:null,host:"localhost",port:5432,name:"sigil",user:"sigil_app",password:null},llm:{provider:null,model:null,apiKey:null,host:null},embedding:{provider:null,model:null,apiKey:null,host:null},identity:{name:null},setup:{complete:!1,steps:{}}}}function gt(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function ur(t,e){if(!gt(e))return e;let r=Array.isArray(t)?[...t]:{...t};for(let[n,o]of Object.entries(e))r[n]=gt(o)&>(r[n])?ur(r[n],o):o;return r}function yt(){if(!cr(ee))return{};try{return JSON.parse(ia(ee,"utf8"))||{}}catch{return{}}}function Zl(t){let e=t,r=Number(e.schemaVersion)||1;for(;r<Rt;){let n=r+1,o=Vl[n];e=o?o(e):{...e,schemaVersion:n},r=n}return e}function ze(t){let e=kt(),r={};for(let n of Object.keys(e)){if(!(n in t))continue;if(!gt(e[n])){r[n]=t[n];continue}let o={};for(let a of Object.keys(e[n]))t[n]&&a in t[n]&&(o[a]=t[n][a]);n==="setup"&>(t.setup?.steps)&&(o.steps=t.setup.steps),r[n]=o}return r}function Or(t){Gl(Fl(ee),{recursive:!0});let e=`${ee}.tmp`;jl(e,`${JSON.stringify(t,null,2)}
|
|
4
|
+
`,{mode:384}),ca(e,ee);try{Bl(ee,384)}catch{}}function Kl(t,e){let r={};if(!gt(e))throw new Error(`config patch for "${t}" must be an object`);if(t==="database"&&("mode"in e&&e.mode!==null&&!aa.includes(e.mode)&&(r.mode=`must be one of ${aa.join(", ")}`),"port"in e&&e.port!=null&&!Number.isInteger(Number(e.port))&&(r.port="must be an integer"),"url"in e&&e.url!=null&&typeof e.url!="string"&&(r.url="must be a string")),Object.keys(r).length){let n=new Error(`invalid config for "${t}": ${JSON.stringify(r)}`);throw n.code="invalid_config",n.errors=r,n}}function Wl(t){if(!cr(t))return null;let e={};for(let r of ia(t,"utf8").split(`
|
|
5
|
+
`)){let n=r.match(/^\s*([A-Z_][A-Z0-9_]*)\s*=\s*(.*)$/i);if(!n)continue;let o=n[2].trim();(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))&&(o=o.slice(1,-1)),e[n[1]]=o}return e}function Yl(t){let e={},r={};if(t.SIGIL_DATABASE_URL||t.DATABASE_URL?(r.mode="url",r.url=t.SIGIL_DATABASE_URL||t.DATABASE_URL):(t.SIGIL_DB_HOST||t.SIGIL_DB_NAME||t.SIGIL_DB_PASSWORD)&&(r.mode="local",t.SIGIL_DB_HOST&&(r.host=t.SIGIL_DB_HOST),t.SIGIL_DB_PORT&&(r.port=Number(t.SIGIL_DB_PORT)||5432),t.SIGIL_DB_NAME&&(r.name=t.SIGIL_DB_NAME),t.SIGIL_DB_USER&&(r.user=t.SIGIL_DB_USER),t.SIGIL_DB_PASSWORD&&(r.password=t.SIGIL_DB_PASSWORD)),Object.keys(r).length&&(e.database=r),t.LLM_PROVIDER){let n={provider:t.LLM_PROVIDER},o={anthropic:t.ANTHROPIC_API_KEY,openai:t.OPENAI_API_KEY,openrouter:t.OPENROUTER_API_KEY}[t.LLM_PROVIDER];o&&(n.apiKey=o);let a={openai:t.LLM_OPENAI_MODEL,openrouter:t.LLM_OPENROUTER_MODEL,ollama:t.LLM_OLLAMA_MODEL,"claude-cli":t.LLM_CLI_MODEL}[t.LLM_PROVIDER];a&&(n.model=a),t.LLM_PROVIDER==="ollama"&&(t.LLM_OLLAMA_HOST||t.OLLAMA_HOST)&&(n.host=t.LLM_OLLAMA_HOST||t.OLLAMA_HOST),e.llm=n}if(t.EMBEDDING_PROVIDER){let n={provider:t.EMBEDDING_PROVIDER};t.EMBEDDING_MODEL&&(n.model=t.EMBEDDING_MODEL);let o={openai:t.OPENAI_API_KEY,voyage:t.VOYAGE_API_KEY,openrouter:t.OPENROUTER_API_KEY}[t.EMBEDDING_PROVIDER];o&&(n.apiKey=o),t.EMBEDDING_PROVIDER==="ollama"&&t.OLLAMA_HOST&&(n.host=t.OLLAMA_HOST),e.embedding=n}return t.SIGIL_SETUP_COMPLETE==="true"&&(e.setup={complete:!0}),e}function ql(){if(!sa){sa=!0;try{let t=Wl(or);if(!t)return;let e=Yl(t),r=ze(yt()),n={database:!!r.database?.mode,llm:!!r.llm?.provider,embedding:!!r.embedding?.provider,setup:!!r.setup?.complete};for(let[o,a]of Object.entries(e))if(!n[o])try{Lt(o,a)}catch{}try{ca(or,`${or}.migrated`)}catch{}}catch{}}}function ua(){ql();let t=yt(),e=Zl(t);return cr(ee)&&e.schemaVersion!==t.schemaVersion&&Or(ze(e)),Te=ur(kt(),ze(e)),Jl(),Te}function Jl(){let t=Te?.setup?.steps;if(!t)return;let e=Object.entries(t).filter(([,o])=>o==="active").map(([o])=>o);if(!e.length)return;let r=ze(yt()),n={...r.setup?.steps||{}};for(let o of e)n[o]="pending";Or({...r,schemaVersion:Rt,setup:{...r.setup||{},steps:n}}),Te=ur(kt(),ze(yt()))}function _t(){return Te||ua()}function Lt(t,e){if(!(t in kt()))throw new Error(`unknown config section: ${t}`);Kl(t,e);let r=ze(yt());return r.schemaVersion=Rt,r[t]={...r[t]||{},...e},Or(r),Te=ur(kt(),r),Te}function Xl(){let t=_t();if(t.device?.id)return t.device.id;let e=Hl();return Lt("device",{id:e}),e}function Ql(t,e){if(!zl.includes(e))throw new Error(`invalid step status: ${e}`);let r=ze(yt()),n={...r.setup?.steps||{},[t]:e};return Lt("setup",{...r.setup||{},steps:n})}function ed(t=!0){return Lt("setup",{complete:!!t})}function td(){return!!_t().setup?.complete}function rd(){try{cr(ee)&&Ul(ee)}catch{}return Te=null,_t()}var Rt,aa,zl,Vl,Te,sa,Ar=K(()=>{ht();ir();Rt=1,aa=["embedded","local","docker","url"],zl=["pending","active","done","error"];Vl={},Te=null;sa=!1});var da={};Ze(da,{default:()=>od});var C,P,kr,fr,Rr,la,nd,od,pa=K(()=>{Ar();ir();C=(t,e)=>process.env[t]??e,P=()=>_t(),kr=t=>P().llm.provider===t&&P().llm.apiKey||"",fr=t=>P().llm.provider===t&&P().llm.model||"",Rr=t=>P().embedding.provider===t&&P().embedding.apiKey||"",la=C("SIGIL_DB_TYPE","postgres");if(la!=="postgres")throw new Error(`SIGIL_DB_TYPE=${la} is no longer supported. Sigil 0.10.0+ is Postgres-only.
|
|
6
6
|
PGlite was deprecated; existing PGlite data at ~/.sigil/db is preserved but unreachable from this version.
|
|
7
7
|
Set SIGIL_DB_TYPE=postgres in ~/.sigil/.env and configure SIGIL_DB_HOST / PORT / NAME / USER / PASSWORD.
|
|
8
|
-
Run \`sigil init\` for an interactive setup.`);
|
|
9
|
-
`))!==-1;){let y=i.slice(0,
|
|
10
|
-
`;return new Promise((E,
|
|
11
|
-
`),await
|
|
12
|
-
`);let n=[
|
|
13
|
-
`)}function
|
|
14
|
-
`)[0].slice(0,80)})`:"unknown"}function
|
|
8
|
+
Run \`sigil init\` for an interactive setup.`);nd={db:{type:"postgres",get mode(){return process.env.SIGIL_DB_MODE||P().database.mode||null},get url(){return process.env.SIGIL_DATABASE_URL||process.env.DATABASE_URL||P().database.url||null},get host(){return process.env.SIGIL_DB_HOST||P().database.host||"localhost"},get port(){return Number(process.env.SIGIL_DB_PORT||P().database.port||5432)},get database(){return process.env.SIGIL_DB_NAME||P().database.name||"sigil"},get user(){return process.env.SIGIL_DB_USER||P().database.user||"sigil_app"},get password(){return process.env.SIGIL_DB_PASSWORD||P().database.password||""}},embedding:{get provider(){return process.env.EMBEDDING_PROVIDER||P().embedding.provider||""},get model(){return process.env.EMBEDDING_MODEL||P().embedding.model||"mxbai-embed-large"},get dimensions(){return 1024},get ollamaHost(){return process.env.OLLAMA_HOST||(P().embedding.provider==="ollama"?P().embedding.host:"")||"http://localhost:11434"},get openaiApiKey(){return process.env.OPENAI_API_KEY||Rr("openai")},get voyageApiKey(){return process.env.VOYAGE_API_KEY||Rr("voyage")},get openrouterApiKey(){return process.env.OPENROUTER_API_KEY||Rr("openrouter")},openrouterBaseUrl:process.env.EMBEDDING_OPENROUTER_BASE_URL||process.env.LLM_OPENROUTER_BASE_URL||"",openrouterReferer:process.env.EMBEDDING_OPENROUTER_REFERER||process.env.LLM_OPENROUTER_REFERER||"https://github.com/Anmol-Srv/sigil",openrouterTitle:process.env.EMBEDDING_OPENROUTER_TITLE||process.env.LLM_OPENROUTER_TITLE||"Sigil"},llm:{get provider(){return process.env.LLM_PROVIDER||P().llm.provider||""},get openaiApiKey(){return process.env.OPENAI_API_KEY||kr("openai")},get openaiModel(){return process.env.LLM_OPENAI_MODEL||fr("openai")||"gpt-4o-mini"},get ollamaHost(){return process.env.LLM_OLLAMA_HOST||process.env.OLLAMA_HOST||(P().llm.provider==="ollama"?P().llm.host:"")||"http://localhost:11434"},get ollamaModel(){return process.env.LLM_OLLAMA_MODEL||fr("ollama")||"qwen2.5:7b"},get cliModel(){return process.env.LLM_CLI_MODEL||fr("claude-cli")||"haiku"},get cliPath(){return process.env.LLM_CLI_PATH||""},get apiKey(){return process.env.ANTHROPIC_API_KEY||kr("anthropic")},get openrouterApiKey(){return process.env.OPENROUTER_API_KEY||kr("openrouter")},get openrouterModel(){return process.env.LLM_OPENROUTER_MODEL||fr("openrouter")||"google/gemini-flash-latest"},get openrouterBaseUrl(){return process.env.LLM_OPENROUTER_BASE_URL||""},get openrouterReferer(){return process.env.LLM_OPENROUTER_REFERER||"https://github.com/Anmol-Srv/sigil"},get openrouterTitle(){return process.env.LLM_OPENROUTER_TITLE||"Sigil"},get extractionModel(){return process.env.LLM_EXTRACTION_MODEL||""},get decisionModel(){return process.env.LLM_DECISION_MODEL||""},get entityModel(){return process.env.LLM_ENTITY_MODEL||""},get maxRetries(){return Number(process.env.LLM_MAX_RETRIES)||3},get cliTimeout(){return Number(process.env.LLM_CLI_TIMEOUT)||12e4},get requestTimeout(){return Number(process.env.LLM_REQUEST_TIMEOUT)||6e4}},output:{storage:process.env.OUTPUT_STORAGE||"local",dir:process.env.OUTPUT_DIR||"./output",s3:{endpoint:process.env.S3_ENDPOINT||"",bucket:process.env.S3_BUCKET||"",region:process.env.S3_REGION||"us-east-1",accessKey:process.env.S3_ACCESS_KEY||"",secretKey:process.env.S3_SECRET_KEY||"",publicUrl:process.env.S3_PUBLIC_URL||""}},server:{port:Number(process.env.PORT)||4e3,host:process.env.HOST||"0.0.0.0",logLevel:process.env.LOG_LEVEL||"info"},http:{enabled:C("SIGIL_HTTP_ENABLED","true")!=="false",host:C("SIGIL_HTTP_HOST","127.0.0.1"),port:Number(C("SIGIL_HTTP_PORT",7777))},network:{mode:C("SIGIL_MODE","solo"),enabled:C("SIGIL_NETWORK_ENABLED",null)===null?C("SIGIL_MODE","solo")!=="solo":C("SIGIL_NETWORK_ENABLED","false")!=="false",masterNodeId:C("SIGIL_MASTER_NODE_ID","")||null},defaults:{namespace:process.env.DEFAULT_NAMESPACE||"default"},memory:{skipThreshold:Number(process.env.MEMORY_SKIP_THRESHOLD)||.88,ambiguousThreshold:Number(process.env.MEMORY_AMBIGUOUS_THRESHOLD)||.78,minFactSimilarity:Number(process.env.MEMORY_MIN_FACT_SIMILARITY)||.45,injectionFloor:Number(process.env.MEMORY_INJECTION_FLOOR)||.6},search:{synthesize:C("SIGIL_SYNTHESIZE","true")!=="false",synthesizeModel:C("SIGIL_SYNTH_MODEL","")},ingest:{eagerExtract:C("SIGIL_EAGER_EXTRACT","true")!=="false",extractRelations:C("SIGIL_EXTRACT_RELATIONS","true")!=="false",graphGleanRounds:Number(C("SIGIL_GRAPH_GLEAN_ROUNDS",0))},hebbian:{entity:{enabled:C("SIGIL_HEBBIAN_ENTITY_ENABLED",null,"true")!=="false",eta:Number(C("SIGIL_HEBBIAN_ENTITY_ETA",null,1)),cap:Number(C("SIGIL_HEBBIAN_ENTITY_CAP",null,50)),halfLifeDays:Number(C("SIGIL_HEBBIAN_ENTITY_HALF_LIFE_DAYS",null,30)),minEffective:Number(C("SIGIL_HEBBIAN_ENTITY_MIN_EFFECTIVE",null,.5)),rrfWeight:Number(C("SIGIL_HEBBIAN_ENTITY_RRF_WEIGHT",null,.3)),maxWriteEntities:Number(C("SIGIL_HEBBIAN_ENTITY_MAX_WRITE",null,12)),expandPerSeed:Number(C("SIGIL_HEBBIAN_ENTITY_EXPAND_PER_SEED",null,3))}}},od=nd});import{readFile as ma,writeFile as Wv,unlink as ha,mkdir as Yv}from"node:fs/promises";import{existsSync as ga}from"node:fs";function ad(t){if(!t||!Number.isFinite(t))return!1;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}async function sd(){if(!ga(ar))return null;try{let t=(await ma(ar,"utf8")).trim(),e=Number(t);return Number.isFinite(e)?e:null}catch{return null}}async function id(){try{await ha(ar)}catch{}}async function cd(){try{await ha(Fe)}catch{}}async function ud(){try{let t=JSON.parse(await ma(na,"utf8"));return Number.isFinite(t?.pid)?t.pid:null}catch{return null}}async function fd(){try{let{default:t}=await Promise.resolve().then(()=>(pa(),da));if(!t.http.enabled)return!1;let{host:e,port:r}=t.http,n=new AbortController,o=setTimeout(()=>n.abort(),500);try{return(await fetch(`http://${e}:${r}/healthz`,{signal:n.signal})).ok}finally{clearTimeout(o)}}catch{return!1}}async function ya(){let t=await sd();return t&&ad(t)?t:await fd()?await ud()??"unknown":(t&&await id(),ga(Fe)&&await cd(),null)}var _a=K(()=>{ht()});import{existsSync as ld}from"node:fs";import{dirname as dd,join as Lr}from"node:path";import{fileURLToPath as pd}from"node:url";function xa(){let t=[Lr(Ue,"dist","daemon.js"),Lr(Ue,"src","daemon","index.js"),Lr(dd(pd(import.meta.url)),"..","daemon","index.js")];for(let e of t)if(ld(e))return e;throw new Error("cannot locate daemon entry point (looked in dist/ and src/daemon/)")}var va=K(()=>{ht()});import{connect as md}from"node:net";import{randomUUID as hd}from"node:crypto";function lr({path:t=Fe,timeoutMs:e=3e4}={}){return new Promise((r,n)=>{let o=md(t),a=new Map,i="",s=!1;o.setEncoding("utf8"),o.once("connect",()=>{o.off("error",c),r(u())});function c(l){n(l)}o.once("error",c),o.on("data",l=>{i+=l;let p;for(;(p=i.indexOf(`
|
|
9
|
+
`))!==-1;){let y=i.slice(0,p);if(i=i.slice(p+1),!y.trim())continue;let x;try{x=JSON.parse(y)}catch{continue}let O=a.get(x.id);O&&(a.delete(x.id),clearTimeout(O.timer),x.ok?O.resolve(x):O.reject(new Cr(x.error||{})))}}),o.on("close",()=>{s=!0;for(let[,l]of a){clearTimeout(l.timer);let p=new Error("daemon connection closed");p.code="ECLOSED",l.reject(p)}a.clear()}),o.on("error",()=>{});function u(){return{call(l,p){if(s){let E=new Error("client is closed");return E.code="ECLOSED",Promise.reject(E)}let y=hd(),x=process.env.SIGIL_AGENT||null,O=JSON.stringify({id:y,method:l,params:p,agent:x})+`
|
|
10
|
+
`;return new Promise((E,w)=>{let $=setTimeout(()=>{a.delete(y)&&w(new Error(`rpc timeout after ${e}ms: ${l}`))},e);a.set(y,{resolve:E,reject:w,timer:$}),o.write(O)})},close(){return new Promise(l=>{if(s)return l();o.end(()=>l())})}}}})}var Cr,ba=K(()=>{ht();Cr=class extends Error{constructor({code:e,message:r,stack:n}){super(r||e||"rpc error"),this.name="SigilRpcError",this.code=e||"handler_error",n&&(this.remoteStack=n)}}});import{spawn as gd}from"node:child_process";import{existsSync as yd,openSync as Ta,closeSync as Ia,mkdirSync as _d}from"node:fs";import{setTimeout as xd}from"node:timers/promises";async function dr({quiet:t=!1,timeoutMs:e}={}){let r=e?{timeoutMs:e}:void 0;return await Sa()?lr(r):(t||process.stderr.write(`[sigil] daemon not running, starting it...
|
|
11
|
+
`),await Td(),await Id(),lr(r))}async function Sa(){if(!yd(Fe))return!1;try{let t=await lr({timeoutMs:1e3});return await t.call("ping",{}),await t.close(),!0}catch{return!1}}async function Td(){_d(N,{recursive:!0}),await ya();let t=xa(),e=Ta(sr,"a"),r=Ta(sr,"a");gd(process.execPath,[t],{detached:!0,stdio:["ignore",e,r],env:{...process.env,SIGIL_DAEMON_AUTOSPAWN:"1"}}).unref();try{Ia(e)}catch{}try{Ia(r)}catch{}}async function Id(){let t=Date.now()+Ea,e=vd;for(;Date.now()<t;){if(await Sa())return;await xd(e),e=Math.min(e*2,bd)}throw new Error(`daemon did not become ready within ${Ea}ms \u2014 check ${sr}`)}var Ea,vd,bd,Nr=K(()=>{ht();_a();va();ba();Ea=5e3,vd=25,bd=400});var Oa={};Ze(Oa,{closeDaemonConnection:()=>Od,daemonCall:()=>L,setInProcessDispatch:()=>Ed});function Ed(t){Pr=t}async function wa(){return vt||(xt||(xt=dr({quiet:!0}).then(t=>(vt=t,t)).catch(t=>{throw xt=null,t})),xt)}function wd(t){return t?t.code&&Sd.has(t.code)?!0:/^(daemon connection closed|client is closed)/i.test(t.message||""):!1}async function L(t,e){if(Pr)return Pr(t,e??{});let r=await wa();try{let{data:n}=await r.call(t,e??{});return n}catch(n){if(wd(n)){vt=null,xt=null;let o=await wa(),{data:a}=await o.call(t,e??{});return a}throw n}}async function Od(){let t=vt;vt=null,xt=null,t&&await t.close()}var xt,vt,Pr,Sd,H=K(()=>{Nr();xt=null,vt=null,Pr=null;Sd=new Set(["ECONNREFUSED","ENOENT","EPIPE","ECONNRESET","ECLOSED"])});var Ga={};Ze(Ga,{buildPreamble:()=>kd});async function kd({cwd:t=process.cwd(),limit:e=12,call:r}={}){let n={state:"ready",checks:{},config:{},totals:{facts:0,documents:0},facts:[],issues:[]};n.config=await Rd(),n.checks.llm=n.config.llmProvider?{ok:!0,detail:`${n.config.llmProvider}${n.config.llmModel?`/${n.config.llmModel}`:""}`}:{ok:!1,detail:"not configured"},n.checks.embedding=n.config.embProvider?{ok:!0,detail:`${n.config.embProvider}/${n.config.embModel} (dim=${n.config.dim})`}:{ok:!1,detail:"not configured"},n.config.llmProvider||n.issues.push("No LLM provider configured \u2014 fact extraction is off. Run `sigil init`."),n.config.embProvider||n.issues.push("No embedding provider configured \u2014 semantic search is off. Run `sigil init`.");let o=null,a=r;if(!a)try{o=await dr({quiet:!0}),a=async(i,s)=>(await o.call(i,s??{})).data}catch(i){return n.checks.daemon={ok:!1,detail:i.message},n.issues.push("Sigil daemon not reachable \u2014 run `npx sigil` (or `sigil daemon start`)."),ja(n)}n.checks.daemon={ok:!0};try{let i=null;try{i=await a("status",{}),n.totals={facts:i.facts??0,documents:i.documents??0},n.checks.db=i.db?.healthy?{ok:!0,detail:`${i.facts??0} facts`}:{ok:!1,detail:i.db?.error||"unreachable"},i.db?.healthy||n.issues.push(`Database unreachable: ${i.db?.error||"unknown"} \u2014 check Postgres, then \`sigil doctor\`.`);let s=i.providers;s?.embedding&&(n.checks.embedding=s.embedding.ok?{ok:!0,detail:`${s.embedding.provider}/${s.embedding.model} (dim=${s.embedding.dim})`}:{ok:!1,detail:s.embedding.error||"unreachable"},s.embedding.ok||n.issues.push(`Embedding provider unreachable: ${s.embedding.error} \u2014 semantic search/ingest will fail.`)),s?.llm&&(n.checks.llm=s.llm.ok?{ok:!0,detail:`${s.llm.provider}${s.llm.model?`/${s.llm.model}`:""}`}:{ok:!1,detail:s.llm.error||"unreachable"},s.llm.ok||n.issues.push(`LLM provider unreachable: ${s.llm.error} \u2014 fact extraction will fail.`))}catch(s){n.checks.db={ok:!1,detail:s.message},n.issues.push(`Could not query Sigil status: ${s.message}`)}try{let s=await a("setup.state",{});n.checks.setup=s.complete?{ok:!0}:{ok:!1,detail:`next: ${s.currentStep}`},s.complete||n.issues.push(`Setup incomplete \u2014 next step "${s.currentStep}". Run \`sigil init\` or open the GUI.`)}catch{}if(n.checks.db?.ok)try{let s=await a("refreshContext.explain",{cwd:t}),c=new Set;for(let u of s.sections||[]){for(let l of u.facts||[]){let p=(typeof l=="string"?l:l.content||"").trim();if(p&&!c.has(p)&&(c.add(p),n.facts.push({content:p,section:u.name}),n.facts.length>=e))break}if(n.facts.length>=e)break}}catch(s){n.checks.collection={ok:!1,detail:s.message}}}finally{if(o)try{await o.close()}catch{}}return ja(n)}function ja(t){let e=t.checks.daemon&&!t.checks.daemon.ok,r=t.checks.db&&!t.checks.db.ok,n=!!(t.config.llmProvider&&t.config.embProvider),o=t.checks.llm?.ok&&t.checks.embedding?.ok,a=t.checks.setup&&!t.checks.setup.ok||!n;return e||r||n&&!o?t.state="degraded":a?t.state="setup":t.state="ready",t}async function Rd(){try{let{getConfig:t}=await Promise.resolve().then(()=>(Ar(),fa)),e=t();return{llmProvider:e.llm?.provider||"",llmModel:e.llm?.model||"",embProvider:e.embedding?.provider||"",embModel:e.embedding?.model||"",dim:1024,name:e.identity?.name||""}}catch{return{llmProvider:"",llmModel:"",embProvider:"",embModel:"",dim:1024,name:""}}}var Ba=K(()=>{Nr();ir()});var Fa={};Ze(Fa,{renderPreamble:()=>Ld,statusLines:()=>$r});function Ld(t,{format:e="md",transport:r="cli"}={}){if(e==="json")return JSON.stringify(t,null,2);if(e==="lines")return $r(t).join(`
|
|
12
|
+
`);let n=[...$r(t),""];if(t.facts.length){n.push(`## Sigil memory (${t.facts.length} facts loaded at session start)`);for(let o of t.facts)n.push(`- ${o.content}`)}else t.state==="degraded"?(n.push("## Sigil memory"),n.push("- (unavailable \u2014 see the health warnings below)")):(n.push("## Sigil memory"),n.push("- (nothing stored yet \u2014 facts accrue as you and the user work)"));if(n.push("",Cd(r)),t.issues.length){n.push("","## Sigil health");for(let o of t.issues)n.push(`- \u26A0 ${o}`)}return n.join(`
|
|
13
|
+
`)}function Ua(t){return t?t.ok?t.detail||"ok":!t.detail||t.detail==="not configured"?"not configured":`down (${String(t.detail).split(`
|
|
14
|
+
`)[0].slice(0,80)})`:"unknown"}function $r(t){let e=[`SIGIL: ${t.state}`];return t.checks.daemon&&e.push(`DAEMON: ${t.checks.daemon.ok?"up":`down (${t.checks.daemon.detail||"unreachable"})`}`),t.checks.db&&e.push(`DB: ${t.checks.db.ok?`ok${t.checks.db.detail?` (${t.checks.db.detail})`:""}`:`down (${t.checks.db.detail||"unreachable"})`}`),e.push(`LLM: ${Ua(t.checks.llm)}`),e.push(`EMBED: ${Ua(t.checks.embedding)}`),e.push(`FACTS: ${t.facts.length} loaded / ${t.totals?.facts??0} total`),e}function Cd(t){return t==="mcp"?["## Using Sigil (no automatic memory in this client)","- Nothing is injected or saved automatically here. Call the `search` tool BEFORE answering anything that depends on the user, their preferences, or this project; call `ingest` to save durable facts the user will want next session.","- When you use a stored fact, name it in one short clause so the user sees their context being applied."].join(`
|
|
15
15
|
`):["## Using Sigil","- Memory is auto-injected per prompt and saved by hooks. Read the injected facts first; use `search` only to drill down when the injection missed something."].join(`
|
|
16
|
-
`)}var Fo=K(()=>{});import{config as Nd}from"dotenv";import{resolve as $r,dirname as Vo}from"node:path";import{fileURLToPath as Pd}from"node:url";import{existsSync as $d}from"node:fs";import"dotenv/config";import{McpServer as Rd}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as Ld}from"@modelcontextprotocol/sdk/server/stdio.js";var g={};Ze(g,{BRAND:()=>_s,DIRTY:()=>we,EMPTY_PATH:()=>qo,INVALID:()=>_,NEVER:()=>ri,OK:()=>j,ParseStatus:()=>D,Schema:()=>T,ZodAny:()=>de,ZodArray:()=>se,ZodBigInt:()=>Ee,ZodBoolean:()=>Se,ZodBranded:()=>wt,ZodCatch:()=>De,ZodDate:()=>Oe,ZodDefault:()=>Me,ZodDiscriminatedUnion:()=>Mt,ZodEffects:()=>Z,ZodEnum:()=>Pe,ZodError:()=>B,ZodFirstPartyTypeKind:()=>v,ZodFunction:()=>jt,ZodIntersection:()=>Le,ZodIssueCode:()=>f,ZodLazy:()=>Ce,ZodLiteral:()=>Ne,ZodMap:()=>Xe,ZodNaN:()=>et,ZodNativeEnum:()=>$e,ZodNever:()=>W,ZodNull:()=>ke,ZodNullable:()=>Q,ZodNumber:()=>Ie,ZodObject:()=>U,ZodOptional:()=>z,ZodParsedType:()=>p,ZodPipeline:()=>It,ZodPromise:()=>pe,ZodReadonly:()=>je,ZodRecord:()=>Dt,ZodSchema:()=>T,ZodSet:()=>Qe,ZodString:()=>le,ZodSymbol:()=>qe,ZodTransformer:()=>Z,ZodTuple:()=>X,ZodType:()=>T,ZodUndefined:()=>Ae,ZodUnion:()=>Re,ZodUnknown:()=>oe,ZodVoid:()=>Je,addIssueToContext:()=>d,any:()=>Os,array:()=>Ls,bigint:()=>Ts,boolean:()=>Zr,coerce:()=>ti,custom:()=>Hr,date:()=>ws,datetimeRegex:()=>Ur,defaultErrorMap:()=>ne,discriminatedUnion:()=>$s,effect:()=>Ks,enum:()=>zs,function:()=>Us,getErrorMap:()=>Ke,getParsedType:()=>J,instanceof:()=>vs,intersection:()=>Ms,isAborted:()=>Pt,isAsync:()=>We,isDirty:()=>$t,isValid:()=>fe,late:()=>xs,lazy:()=>Fs,literal:()=>Hs,makeIssue:()=>Tt,map:()=>Gs,nan:()=>bs,nativeEnum:()=>Vs,never:()=>ks,null:()=>Ss,nullable:()=>Ys,number:()=>Vr,object:()=>Cs,objectUtil:()=>pr,oboolean:()=>ei,onumber:()=>Qs,optional:()=>Ws,ostring:()=>Xs,pipeline:()=>Js,preprocess:()=>qs,promise:()=>Zs,quotelessJson:()=>Ko,record:()=>js,set:()=>Bs,setErrorMap:()=>Yo,strictObject:()=>Ns,string:()=>zr,symbol:()=>Is,transformer:()=>Ks,tuple:()=>Ds,undefined:()=>Es,union:()=>Ps,unknown:()=>As,util:()=>I,void:()=>Rs});var I;(function(t){t.assertEqual=a=>{};function e(a){}t.assertIs=e;function r(a){throw new Error}t.assertNever=r,t.arrayToEnum=a=>{let o={};for(let i of a)o[i]=i;return o},t.getValidEnumValues=a=>{let o=t.objectKeys(a).filter(s=>typeof a[a[s]]!="number"),i={};for(let s of o)i[s]=a[s];return t.objectValues(i)},t.objectValues=a=>t.objectKeys(a).map(function(o){return a[o]}),t.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{let o=[];for(let i in a)Object.prototype.hasOwnProperty.call(a,i)&&o.push(i);return o},t.find=(a,o)=>{for(let i of a)if(o(i))return i},t.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function n(a,o=" | "){return a.map(i=>typeof i=="string"?`'${i}'`:i).join(o)}t.joinValues=n,t.jsonStringifyReplacer=(a,o)=>typeof o=="bigint"?o.toString():o})(I||(I={}));var pr;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(pr||(pr={}));var p=I.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),J=t=>{switch(typeof t){case"undefined":return p.undefined;case"string":return p.string;case"number":return Number.isNaN(t)?p.nan:p.number;case"boolean":return p.boolean;case"function":return p.function;case"bigint":return p.bigint;case"symbol":return p.symbol;case"object":return Array.isArray(t)?p.array:t===null?p.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?p.promise:typeof Map<"u"&&t instanceof Map?p.map:typeof Set<"u"&&t instanceof Set?p.set:typeof Date<"u"&&t instanceof Date?p.date:p.object;default:return p.unknown}};var f=I.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Ko=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),B=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(o){return o.message},n={_errors:[]},a=o=>{for(let i of o.issues)if(i.code==="invalid_union")i.unionErrors.map(a);else if(i.code==="invalid_return_type")a(i.returnTypeError);else if(i.code==="invalid_arguments")a(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let s=n,c=0;for(;c<i.path.length;){let u=i.path[c];c===i.path.length-1?(s[u]=s[u]||{_errors:[]},s[u]._errors.push(r(i))):s[u]=s[u]||{_errors:[]},s=s[u],c++}}};return a(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,I.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let a of this.issues)if(a.path.length>0){let o=a.path[0];r[o]=r[o]||[],r[o].push(e(a))}else n.push(e(a));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};B.create=t=>new B(t);var Wo=(t,e)=>{let r;switch(t.code){case f.invalid_type:t.received===p.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case f.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,I.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:r=`Unrecognized key(s) in object: ${I.joinValues(t.keys,", ")}`;break;case f.invalid_union:r="Invalid input";break;case f.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${I.joinValues(t.options)}`;break;case f.invalid_enum_value:r=`Invalid enum value. Expected ${I.joinValues(t.options)}, received '${t.received}'`;break;case f.invalid_arguments:r="Invalid function arguments";break;case f.invalid_return_type:r="Invalid function return type";break;case f.invalid_date:r="Invalid date";break;case f.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:I.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case f.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case f.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case f.custom:r="Invalid input";break;case f.invalid_intersection_types:r="Intersection results could not be merged";break;case f.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case f.not_finite:r="Number must be finite";break;default:r=e.defaultError,I.assertNever(t)}return{message:r}},ne=Wo;var Mr=ne;function Yo(t){Mr=t}function Ke(){return Mr}var Tt=t=>{let{data:e,path:r,errorMaps:n,issueData:a}=t,o=[...r,...a.path||[]],i={...a,path:o};if(a.message!==void 0)return{...a,path:o,message:a.message};let s="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)s=u(i,{data:e,defaultError:s}).message;return{...a,path:o,message:s}},qo=[];function d(t,e){let r=Ke(),n=Tt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===ne?void 0:ne].filter(a=>!!a)});t.common.issues.push(n)}var D=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let a of r){if(a.status==="aborted")return _;a.status==="dirty"&&e.dirty(),n.push(a.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let a of r){let o=await a.key,i=await a.value;n.push({key:o,value:i})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let a of r){let{key:o,value:i}=a;if(o.status==="aborted"||i.status==="aborted")return _;o.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof i.value<"u"||a.alwaysSet)&&(n[o.value]=i.value)}return{status:e.value,value:n}}},_=Object.freeze({status:"aborted"}),we=t=>({status:"dirty",value:t}),j=t=>({status:"valid",value:t}),Pt=t=>t.status==="aborted",$t=t=>t.status==="dirty",fe=t=>t.status==="valid",We=t=>typeof Promise<"u"&&t instanceof Promise;var h;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(h||(h={}));var V=class{constructor(e,r,n,a){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Dr=(t,e)=>{if(fe(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new B(t.common.issues);return this._error=r,this._error}}};function b(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:a}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(i,s)=>{let{message:c}=t;return i.code==="invalid_enum_value"?{message:c??s.defaultError}:typeof s.data>"u"?{message:c??n??s.defaultError}:i.code!=="invalid_type"?{message:s.defaultError}:{message:c??r??s.defaultError}},description:a}}var T=class{get description(){return this._def.description}_getType(e){return J(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:J(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new D,ctx:{common:e.parent.common,data:e.data,parsedType:J(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(We(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:J(e)},a=this._parseSync({data:e,path:n.path,parent:n});return Dr(n,a)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:J(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return fe(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>fe(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:J(e)},a=this._parse({data:e,path:n.path,parent:n}),o=await(We(a)?a:Promise.resolve(a));return Dr(n,o)}refine(e,r){let n=a=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(a):r;return this._refinement((a,o)=>{let i=e(a),s=()=>o.addIssue({code:f.custom,...n(a)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(s(),!1)):i?!0:(s(),!1)})}refinement(e,r){return this._refinement((n,a)=>e(n)?!0:(a.addIssue(typeof r=="function"?r(n,a):r),!1))}_refinement(e){return new Z({schema:this,typeName:v.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return z.create(this,this._def)}nullable(){return Q.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return se.create(this)}promise(){return pe.create(this,this._def)}or(e){return Re.create([this,e],this._def)}and(e){return Le.create(this,e,this._def)}transform(e){return new Z({...b(this._def),schema:this,typeName:v.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Me({...b(this._def),innerType:this,defaultValue:r,typeName:v.ZodDefault})}brand(){return new wt({typeName:v.ZodBranded,type:this,...b(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new De({...b(this._def),innerType:this,catchValue:r,typeName:v.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return It.create(this,e)}readonly(){return je.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Jo=/^c[^\s-]{8,}$/i,Xo=/^[0-9a-z]+$/,Qo=/^[0-9A-HJKMNP-TV-Z]{26}$/i,es=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,ts=/^[a-z0-9_-]{21}$/i,rs=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ns=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,as=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,os="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",mr,ss=/^(?:(?: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])$/,is=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,cs=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,us=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,fs=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ls=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Gr="((\\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])))",ds=new RegExp(`^${Gr}$`);function Br(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function ps(t){return new RegExp(`^${Br(t)}$`)}function Ur(t){let e=`${Gr}T${Br(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function ms(t,e){return!!((e==="v4"||!e)&&ss.test(t)||(e==="v6"||!e)&&cs.test(t))}function hs(t,e){if(!rs.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),a=JSON.parse(atob(n));return!(typeof a!="object"||a===null||"typ"in a&&a?.typ!=="JWT"||!a.alg||e&&a.alg!==e)}catch{return!1}}function gs(t,e){return!!((e==="v4"||!e)&&is.test(t)||(e==="v6"||!e)&&us.test(t))}var le=class t extends T{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==p.string){let o=this._getOrReturnCtx(e);return d(o,{code:f.invalid_type,expected:p.string,received:o.parsedType}),_}let n=new D,a;for(let o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(a=this._getOrReturnCtx(e,a),d(a,{code:f.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="max")e.data.length>o.value&&(a=this._getOrReturnCtx(e,a),d(a,{code:f.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){let i=e.data.length>o.value,s=e.data.length<o.value;(i||s)&&(a=this._getOrReturnCtx(e,a),i?d(a,{code:f.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):s&&d(a,{code:f.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),n.dirty())}else if(o.kind==="email")as.test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"email",code:f.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")mr||(mr=new RegExp(os,"u")),mr.test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"emoji",code:f.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")es.test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"uuid",code:f.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")ts.test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"nanoid",code:f.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")Jo.test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"cuid",code:f.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")Xo.test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"cuid2",code:f.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")Qo.test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"ulid",code:f.invalid_string,message:o.message}),n.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),d(a,{validation:"url",code:f.invalid_string,message:o.message}),n.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"regex",code:f.invalid_string,message:o.message}),n.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(a=this._getOrReturnCtx(e,a),d(a,{code:f.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(a=this._getOrReturnCtx(e,a),d(a,{code:f.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(a=this._getOrReturnCtx(e,a),d(a,{code:f.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?Ur(o).test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{code:f.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?ds.test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{code:f.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?ps(o).test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{code:f.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?ns.test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"duration",code:f.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?ms(e.data,o.version)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"ip",code:f.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?hs(e.data,o.alg)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"jwt",code:f.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?gs(e.data,o.version)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"cidr",code:f.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?fs.test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"base64",code:f.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?ls.test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"base64url",code:f.invalid_string,message:o.message}),n.dirty()):I.assertNever(o);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(a=>e.test(a),{validation:r,code:f.invalid_string,...h.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...h.errToObj(e)})}url(e){return this._addCheck({kind:"url",...h.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...h.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...h.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...h.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...h.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...h.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...h.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...h.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...h.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...h.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...h.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...h.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...h.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...h.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...h.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...h.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...h.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...h.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...h.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...h.errToObj(r)})}nonempty(e){return this.min(1,h.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};le.create=t=>new le({checks:[],typeName:v.ZodString,coerce:t?.coerce??!1,...b(t)});function ys(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,a=r>n?r:n,o=Number.parseInt(t.toFixed(a).replace(".","")),i=Number.parseInt(e.toFixed(a).replace(".",""));return o%i/10**a}var Ie=class t extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==p.number){let o=this._getOrReturnCtx(e);return d(o,{code:f.invalid_type,expected:p.number,received:o.parsedType}),_}let n,a=new D;for(let o of this._def.checks)o.kind==="int"?I.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:f.invalid_type,expected:"integer",received:"float",message:o.message}),a.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:f.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:f.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="multipleOf"?ys(e.data,o.value)!==0&&(n=this._getOrReturnCtx(e,n),d(n,{code:f.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:f.not_finite,message:o.message}),a.dirty()):I.assertNever(o);return{status:a.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,h.toString(r))}gt(e,r){return this.setLimit("min",e,!1,h.toString(r))}lte(e,r){return this.setLimit("max",e,!0,h.toString(r))}lt(e,r){return this.setLimit("max",e,!1,h.toString(r))}setLimit(e,r,n,a){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:h.toString(a)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:h.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:h.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:h.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:h.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:h.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&I.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};Ie.create=t=>new Ie({checks:[],typeName:v.ZodNumber,coerce:t?.coerce||!1,...b(t)});var Ee=class t extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==p.bigint)return this._getInvalidInput(e);let n,a=new D;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:f.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),a.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:f.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),a.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),d(n,{code:f.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):I.assertNever(o);return{status:a.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return d(r,{code:f.invalid_type,expected:p.bigint,received:r.parsedType}),_}gte(e,r){return this.setLimit("min",e,!0,h.toString(r))}gt(e,r){return this.setLimit("min",e,!1,h.toString(r))}lte(e,r){return this.setLimit("max",e,!0,h.toString(r))}lt(e,r){return this.setLimit("max",e,!1,h.toString(r))}setLimit(e,r,n,a){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:h.toString(a)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:h.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Ee.create=t=>new Ee({checks:[],typeName:v.ZodBigInt,coerce:t?.coerce??!1,...b(t)});var Se=class extends T{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==p.boolean){let n=this._getOrReturnCtx(e);return d(n,{code:f.invalid_type,expected:p.boolean,received:n.parsedType}),_}return j(e.data)}};Se.create=t=>new Se({typeName:v.ZodBoolean,coerce:t?.coerce||!1,...b(t)});var Oe=class t extends T{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==p.date){let o=this._getOrReturnCtx(e);return d(o,{code:f.invalid_type,expected:p.date,received:o.parsedType}),_}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return d(o,{code:f.invalid_date}),_}let n=new D,a;for(let o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(a=this._getOrReturnCtx(e,a),d(a,{code:f.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),n.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(a=this._getOrReturnCtx(e,a),d(a,{code:f.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):I.assertNever(o);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:h.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};Oe.create=t=>new Oe({checks:[],coerce:t?.coerce||!1,typeName:v.ZodDate,...b(t)});var qe=class extends T{_parse(e){if(this._getType(e)!==p.symbol){let n=this._getOrReturnCtx(e);return d(n,{code:f.invalid_type,expected:p.symbol,received:n.parsedType}),_}return j(e.data)}};qe.create=t=>new qe({typeName:v.ZodSymbol,...b(t)});var Ae=class extends T{_parse(e){if(this._getType(e)!==p.undefined){let n=this._getOrReturnCtx(e);return d(n,{code:f.invalid_type,expected:p.undefined,received:n.parsedType}),_}return j(e.data)}};Ae.create=t=>new Ae({typeName:v.ZodUndefined,...b(t)});var ke=class extends T{_parse(e){if(this._getType(e)!==p.null){let n=this._getOrReturnCtx(e);return d(n,{code:f.invalid_type,expected:p.null,received:n.parsedType}),_}return j(e.data)}};ke.create=t=>new ke({typeName:v.ZodNull,...b(t)});var de=class extends T{constructor(){super(...arguments),this._any=!0}_parse(e){return j(e.data)}};de.create=t=>new de({typeName:v.ZodAny,...b(t)});var oe=class extends T{constructor(){super(...arguments),this._unknown=!0}_parse(e){return j(e.data)}};oe.create=t=>new oe({typeName:v.ZodUnknown,...b(t)});var W=class extends T{_parse(e){let r=this._getOrReturnCtx(e);return d(r,{code:f.invalid_type,expected:p.never,received:r.parsedType}),_}};W.create=t=>new W({typeName:v.ZodNever,...b(t)});var Je=class extends T{_parse(e){if(this._getType(e)!==p.undefined){let n=this._getOrReturnCtx(e);return d(n,{code:f.invalid_type,expected:p.void,received:n.parsedType}),_}return j(e.data)}};Je.create=t=>new Je({typeName:v.ZodVoid,...b(t)});var se=class t extends T{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),a=this._def;if(r.parsedType!==p.array)return d(r,{code:f.invalid_type,expected:p.array,received:r.parsedType}),_;if(a.exactLength!==null){let i=r.data.length>a.exactLength.value,s=r.data.length<a.exactLength.value;(i||s)&&(d(r,{code:i?f.too_big:f.too_small,minimum:s?a.exactLength.value:void 0,maximum:i?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),n.dirty())}if(a.minLength!==null&&r.data.length<a.minLength.value&&(d(r,{code:f.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),n.dirty()),a.maxLength!==null&&r.data.length>a.maxLength.value&&(d(r,{code:f.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,s)=>a.type._parseAsync(new V(r,i,r.path,s)))).then(i=>D.mergeArray(n,i));let o=[...r.data].map((i,s)=>a.type._parseSync(new V(r,i,r.path,s)));return D.mergeArray(n,o)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:h.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:h.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:h.toString(r)}})}nonempty(e){return this.min(1,e)}};se.create=(t,e)=>new se({type:t,minLength:null,maxLength:null,exactLength:null,typeName:v.ZodArray,...b(e)});function Ye(t){if(t instanceof U){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=z.create(Ye(n))}return new U({...t._def,shape:()=>e})}else return t instanceof se?new se({...t._def,type:Ye(t.element)}):t instanceof z?z.create(Ye(t.unwrap())):t instanceof Q?Q.create(Ye(t.unwrap())):t instanceof X?X.create(t.items.map(e=>Ye(e))):t}var U=class t extends T{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=I.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==p.object){let u=this._getOrReturnCtx(e);return d(u,{code:f.invalid_type,expected:p.object,received:u.parsedType}),_}let{status:n,ctx:a}=this._processInputParams(e),{shape:o,keys:i}=this._getCached(),s=[];if(!(this._def.catchall instanceof W&&this._def.unknownKeys==="strip"))for(let u in a.data)i.includes(u)||s.push(u);let c=[];for(let u of i){let l=o[u],m=a.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new V(a,m,a.path,u)),alwaysSet:u in a.data})}if(this._def.catchall instanceof W){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of s)c.push({key:{status:"valid",value:l},value:{status:"valid",value:a.data[l]}});else if(u==="strict")s.length>0&&(d(a,{code:f.unrecognized_keys,keys:s}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of s){let m=a.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new V(a,m,a.path,l)),alwaysSet:l in a.data})}}return a.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let m=await l.key,y=await l.value;u.push({key:m,value:y,alwaysSet:l.alwaysSet})}return u}).then(u=>D.mergeObjectSync(n,u)):D.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let a=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:h.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:v.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of I.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of I.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Ye(this)}partial(e){let r={};for(let n of I.objectKeys(this.shape)){let a=this.shape[n];e&&!e[n]?r[n]=a:r[n]=a.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of I.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof z;)o=o._def.innerType;r[n]=o}return new t({...this._def,shape:()=>r})}keyof(){return Fr(I.objectKeys(this.shape))}};U.create=(t,e)=>new U({shape:()=>t,unknownKeys:"strip",catchall:W.create(),typeName:v.ZodObject,...b(e)});U.strictCreate=(t,e)=>new U({shape:()=>t,unknownKeys:"strict",catchall:W.create(),typeName:v.ZodObject,...b(e)});U.lazycreate=(t,e)=>new U({shape:t,unknownKeys:"strip",catchall:W.create(),typeName:v.ZodObject,...b(e)});var Re=class extends T{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function a(o){for(let s of o)if(s.result.status==="valid")return s.result;for(let s of o)if(s.result.status==="dirty")return r.common.issues.push(...s.ctx.common.issues),s.result;let i=o.map(s=>new B(s.ctx.common.issues));return d(r,{code:f.invalid_union,unionErrors:i}),_}if(r.common.async)return Promise.all(n.map(async o=>{let i={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(a);{let o,i=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!o&&(o={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;let s=i.map(c=>new B(c));return d(r,{code:f.invalid_union,unionErrors:s}),_}}get options(){return this._def.options}};Re.create=(t,e)=>new Re({options:t,typeName:v.ZodUnion,...b(e)});var ae=t=>t instanceof Ce?ae(t.schema):t instanceof Z?ae(t.innerType()):t instanceof Ne?[t.value]:t instanceof Pe?t.options:t instanceof $e?I.objectValues(t.enum):t instanceof Me?ae(t._def.innerType):t instanceof Ae?[void 0]:t instanceof ke?[null]:t instanceof z?[void 0,...ae(t.unwrap())]:t instanceof Q?[null,...ae(t.unwrap())]:t instanceof wt||t instanceof je?ae(t.unwrap()):t instanceof De?ae(t._def.innerType):[],Mt=class t extends T{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==p.object)return d(r,{code:f.invalid_type,expected:p.object,received:r.parsedType}),_;let n=this.discriminator,a=r.data[n],o=this.optionsMap.get(a);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(d(r,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),_)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let a=new Map;for(let o of r){let i=ae(o.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let s of i){if(a.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);a.set(s,o)}}return new t({typeName:v.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:a,...b(n)})}};function hr(t,e){let r=J(t),n=J(e);if(t===e)return{valid:!0,data:t};if(r===p.object&&n===p.object){let a=I.objectKeys(e),o=I.objectKeys(t).filter(s=>a.indexOf(s)!==-1),i={...t,...e};for(let s of o){let c=hr(t[s],e[s]);if(!c.valid)return{valid:!1};i[s]=c.data}return{valid:!0,data:i}}else if(r===p.array&&n===p.array){if(t.length!==e.length)return{valid:!1};let a=[];for(let o=0;o<t.length;o++){let i=t[o],s=e[o],c=hr(i,s);if(!c.valid)return{valid:!1};a.push(c.data)}return{valid:!0,data:a}}else return r===p.date&&n===p.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Le=class extends T{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),a=(o,i)=>{if(Pt(o)||Pt(i))return _;let s=hr(o.value,i.value);return s.valid?(($t(o)||$t(i))&&r.dirty(),{status:r.value,value:s.data}):(d(n,{code:f.invalid_intersection_types}),_)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,i])=>a(o,i)):a(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Le.create=(t,e,r)=>new Le({left:t,right:e,typeName:v.ZodIntersection,...b(r)});var X=class t extends T{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.array)return d(n,{code:f.invalid_type,expected:p.array,received:n.parsedType}),_;if(n.data.length<this._def.items.length)return d(n,{code:f.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),_;!this._def.rest&&n.data.length>this._def.items.length&&(d(n,{code:f.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let o=[...n.data].map((i,s)=>{let c=this._def.items[s]||this._def.rest;return c?c._parse(new V(n,i,n.path,s)):null}).filter(i=>!!i);return n.common.async?Promise.all(o).then(i=>D.mergeArray(r,i)):D.mergeArray(r,o)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};X.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new X({items:t,typeName:v.ZodTuple,rest:null,...b(e)})};var Dt=class t extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.object)return d(n,{code:f.invalid_type,expected:p.object,received:n.parsedType}),_;let a=[],o=this._def.keyType,i=this._def.valueType;for(let s in n.data)a.push({key:o._parse(new V(n,s,n.path,s)),value:i._parse(new V(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?D.mergeObjectAsync(r,a):D.mergeObjectSync(r,a)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof T?new t({keyType:e,valueType:r,typeName:v.ZodRecord,...b(n)}):new t({keyType:le.create(),valueType:e,typeName:v.ZodRecord,...b(r)})}},Xe=class extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.map)return d(n,{code:f.invalid_type,expected:p.map,received:n.parsedType}),_;let a=this._def.keyType,o=this._def.valueType,i=[...n.data.entries()].map(([s,c],u)=>({key:a._parse(new V(n,s,n.path,[u,"key"])),value:o._parse(new V(n,c,n.path,[u,"value"]))}));if(n.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let c of i){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return _;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(u.value,l.value)}return{status:r.value,value:s}})}else{let s=new Map;for(let c of i){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return _;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(u.value,l.value)}return{status:r.value,value:s}}}};Xe.create=(t,e,r)=>new Xe({valueType:e,keyType:t,typeName:v.ZodMap,...b(r)});var Qe=class t extends T{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.set)return d(n,{code:f.invalid_type,expected:p.set,received:n.parsedType}),_;let a=this._def;a.minSize!==null&&n.data.size<a.minSize.value&&(d(n,{code:f.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),r.dirty()),a.maxSize!==null&&n.data.size>a.maxSize.value&&(d(n,{code:f.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),r.dirty());let o=this._def.valueType;function i(c){let u=new Set;for(let l of c){if(l.status==="aborted")return _;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let s=[...n.data.values()].map((c,u)=>o._parse(new V(n,c,n.path,u)));return n.common.async?Promise.all(s).then(c=>i(c)):i(s)}min(e,r){return new t({...this._def,minSize:{value:e,message:h.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:h.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Qe.create=(t,e)=>new Qe({valueType:t,minSize:null,maxSize:null,typeName:v.ZodSet,...b(e)});var jt=class t extends T{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==p.function)return d(r,{code:f.invalid_type,expected:p.function,received:r.parsedType}),_;function n(s,c){return Tt({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ke(),ne].filter(u=>!!u),issueData:{code:f.invalid_arguments,argumentsError:c}})}function a(s,c){return Tt({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ke(),ne].filter(u=>!!u),issueData:{code:f.invalid_return_type,returnTypeError:c}})}let o={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof pe){let s=this;return j(async function(...c){let u=new B([]),l=await s._def.args.parseAsync(c,o).catch(x=>{throw u.addIssue(n(c,x)),u}),m=await Reflect.apply(i,this,l);return await s._def.returns._def.type.parseAsync(m,o).catch(x=>{throw u.addIssue(a(m,x)),u})})}else{let s=this;return j(function(...c){let u=s._def.args.safeParse(c,o);if(!u.success)throw new B([n(c,u.error)]);let l=Reflect.apply(i,this,u.data),m=s._def.returns.safeParse(l,o);if(!m.success)throw new B([a(l,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:X.create(e).rest(oe.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||X.create([]).rest(oe.create()),returns:r||oe.create(),typeName:v.ZodFunction,...b(n)})}},Ce=class extends T{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Ce.create=(t,e)=>new Ce({getter:t,typeName:v.ZodLazy,...b(e)});var Ne=class extends T{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return d(r,{received:r.data,code:f.invalid_literal,expected:this._def.value}),_}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ne.create=(t,e)=>new Ne({value:t,typeName:v.ZodLiteral,...b(e)});function Fr(t,e){return new Pe({values:t,typeName:v.ZodEnum,...b(e)})}var Pe=class t extends T{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return d(r,{expected:I.joinValues(n),received:r.parsedType,code:f.invalid_type}),_}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return d(r,{received:r.data,code:f.invalid_enum_value,options:n}),_}return j(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};Pe.create=Fr;var $e=class extends T{_parse(e){let r=I.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==p.string&&n.parsedType!==p.number){let a=I.objectValues(r);return d(n,{expected:I.joinValues(a),received:n.parsedType,code:f.invalid_type}),_}if(this._cache||(this._cache=new Set(I.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let a=I.objectValues(r);return d(n,{received:n.data,code:f.invalid_enum_value,options:a}),_}return j(e.data)}get enum(){return this._def.values}};$e.create=(t,e)=>new $e({values:t,typeName:v.ZodNativeEnum,...b(e)});var pe=class extends T{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==p.promise&&r.common.async===!1)return d(r,{code:f.invalid_type,expected:p.promise,received:r.parsedType}),_;let n=r.parsedType===p.promise?r.data:Promise.resolve(r.data);return j(n.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}};pe.create=(t,e)=>new pe({type:t,typeName:v.ZodPromise,...b(e)});var Z=class extends T{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===v.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),a=this._def.effect||null,o={addIssue:i=>{d(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),a.type==="preprocess"){let i=a.transform(n.data,o);if(n.common.async)return Promise.resolve(i).then(async s=>{if(r.value==="aborted")return _;let c=await this._def.schema._parseAsync({data:s,path:n.path,parent:n});return c.status==="aborted"?_:c.status==="dirty"?we(c.value):r.value==="dirty"?we(c.value):c});{if(r.value==="aborted")return _;let s=this._def.schema._parseSync({data:i,path:n.path,parent:n});return s.status==="aborted"?_:s.status==="dirty"?we(s.value):r.value==="dirty"?we(s.value):s}}if(a.type==="refinement"){let i=s=>{let c=a.refinement(s,o);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?_:(s.status==="dirty"&&r.dirty(),i(s.value),{status:r.value,value:s.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>s.status==="aborted"?_:(s.status==="dirty"&&r.dirty(),i(s.value).then(()=>({status:r.value,value:s.value}))))}if(a.type==="transform")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!fe(i))return _;let s=a.transform(i.value,o);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:s}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>fe(i)?Promise.resolve(a.transform(i.value,o)).then(s=>({status:r.value,value:s})):_);I.assertNever(a)}};Z.create=(t,e,r)=>new Z({schema:t,typeName:v.ZodEffects,effect:e,...b(r)});Z.createWithPreprocess=(t,e,r)=>new Z({schema:e,effect:{type:"preprocess",transform:t},typeName:v.ZodEffects,...b(r)});var z=class extends T{_parse(e){return this._getType(e)===p.undefined?j(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};z.create=(t,e)=>new z({innerType:t,typeName:v.ZodOptional,...b(e)});var Q=class extends T{_parse(e){return this._getType(e)===p.null?j(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Q.create=(t,e)=>new Q({innerType:t,typeName:v.ZodNullable,...b(e)});var Me=class extends T{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===p.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Me.create=(t,e)=>new Me({innerType:t,typeName:v.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...b(e)});var De=class extends T{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},a=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return We(a)?a.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new B(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new B(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};De.create=(t,e)=>new De({innerType:t,typeName:v.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...b(e)});var et=class extends T{_parse(e){if(this._getType(e)!==p.nan){let n=this._getOrReturnCtx(e);return d(n,{code:f.invalid_type,expected:p.nan,received:n.parsedType}),_}return{status:"valid",value:e.data}}};et.create=t=>new et({typeName:v.ZodNaN,...b(t)});var _s=Symbol("zod_brand"),wt=class extends T{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},It=class t extends T{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?_:o.status==="dirty"?(r.dirty(),we(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{let a=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?_:a.status==="dirty"?(r.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:v.ZodPipeline})}},je=class extends T{_parse(e){let r=this._def.innerType._parse(e),n=a=>(fe(a)&&(a.value=Object.freeze(a.value)),a);return We(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}};je.create=(t,e)=>new je({innerType:t,typeName:v.ZodReadonly,...b(e)});function jr(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function Hr(t,e={},r){return t?de.create().superRefine((n,a)=>{let o=t(n);if(o instanceof Promise)return o.then(i=>{if(!i){let s=jr(e,n),c=s.fatal??r??!0;a.addIssue({code:"custom",...s,fatal:c})}});if(!o){let i=jr(e,n),s=i.fatal??r??!0;a.addIssue({code:"custom",...i,fatal:s})}}):de.create()}var xs={object:U.lazycreate},v;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(v||(v={}));var vs=(t,e={message:`Input not instance of ${t.name}`})=>Hr(r=>r instanceof t,e),zr=le.create,Vr=Ie.create,bs=et.create,Ts=Ee.create,Zr=Se.create,ws=Oe.create,Is=qe.create,Es=Ae.create,Ss=ke.create,Os=de.create,As=oe.create,ks=W.create,Rs=Je.create,Ls=se.create,Cs=U.create,Ns=U.strictCreate,Ps=Re.create,$s=Mt.create,Ms=Le.create,Ds=X.create,js=Dt.create,Gs=Xe.create,Bs=Qe.create,Us=jt.create,Fs=Ce.create,Hs=Ne.create,zs=Pe.create,Vs=$e.create,Zs=pe.create,Ks=Z.create,Ws=z.create,Ys=Q.create,qs=Z.createWithPreprocess,Js=It.create,Xs=()=>zr().optional(),Qs=()=>Vr().optional(),ei=()=>Zr().optional(),ti={string:(t=>le.create({...t,coerce:!0})),number:(t=>Ie.create({...t,coerce:!0})),boolean:(t=>Se.create({...t,coerce:!0})),bigint:(t=>Ee.create({...t,coerce:!0})),date:(t=>Oe.create({...t,coerce:!0}))};var ri=_;var ni=typeof global=="object"&&global&&global.Object===Object&&global,Gt=ni;var ai=typeof self=="object"&&self&&self.Object===Object&&self,oi=Gt||ai||Function("return this")(),M=oi;var si=M.Symbol,G=si;var Kr=Object.prototype,ii=Kr.hasOwnProperty,ci=Kr.toString,Et=G?G.toStringTag:void 0;function ui(t){var e=ii.call(t,Et),r=t[Et];try{t[Et]=void 0;var n=!0}catch{}var a=ci.call(t);return n&&(e?t[Et]=r:delete t[Et]),a}var Wr=ui;var fi=Object.prototype,li=fi.toString;function di(t){return li.call(t)}var Yr=di;var pi="[object Null]",mi="[object Undefined]",qr=G?G.toStringTag:void 0;function hi(t){return t==null?t===void 0?mi:pi:qr&&qr in Object(t)?Wr(t):Yr(t)}var Y=hi;function gi(t){return t!=null&&typeof t=="object"}var q=gi;var yi="[object Symbol]";function _i(t){return typeof t=="symbol"||q(t)&&Y(t)==yi}var ie=_i;function xi(t,e){for(var r=-1,n=t==null?0:t.length,a=Array(n);++r<n;)a[r]=e(t[r],r,t);return a}var tt=xi;var vi=Array.isArray,R=vi;var bi=1/0,Jr=G?G.prototype:void 0,Xr=Jr?Jr.toString:void 0;function Qr(t){if(typeof t=="string")return t;if(R(t))return tt(t,Qr)+"";if(ie(t))return Xr?Xr.call(t):"";var e=t+"";return e=="0"&&1/t==-bi?"-0":e}var en=Qr;function Ti(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var me=Ti;function wi(t){return t}var he=wi;var Ii="[object AsyncFunction]",Ei="[object Function]",Si="[object GeneratorFunction]",Oi="[object Proxy]";function Ai(t){if(!me(t))return!1;var e=Y(t);return e==Ei||e==Si||e==Ii||e==Oi}var Bt=Ai;var ki=M["__core-js_shared__"],Ut=ki;var tn=(function(){var t=/[^.]+$/.exec(Ut&&Ut.keys&&Ut.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function Ri(t){return!!tn&&tn in t}var rn=Ri;var Li=Function.prototype,Ci=Li.toString;function Ni(t){if(t!=null){try{return Ci.call(t)}catch{}try{return t+""}catch{}}return""}var ce=Ni;var Pi=/[\\^$.*+?()[\]{}|]/g,$i=/^\[object .+?Constructor\]$/,Mi=Function.prototype,Di=Object.prototype,ji=Mi.toString,Gi=Di.hasOwnProperty,Bi=RegExp("^"+ji.call(Gi).replace(Pi,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ui(t){if(!me(t)||rn(t))return!1;var e=Bt(t)?Bi:$i;return e.test(ce(t))}var nn=Ui;function Fi(t,e){return t?.[e]}var an=Fi;function Hi(t,e){var r=an(t,e);return nn(r)?r:void 0}var F=Hi;var zi=F(M,"WeakMap"),Ft=zi;function Vi(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var on=Vi;var Zi=800,Ki=16,Wi=Date.now;function Yi(t){var e=0,r=0;return function(){var n=Wi(),a=Ki-(n-r);if(r=n,a>0){if(++e>=Zi)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var sn=Yi;function qi(t){return function(){return t}}var cn=qi;var Ji=(function(){try{var t=F(Object,"defineProperty");return t({},"",{}),t}catch{}})(),rt=Ji;var Xi=rt?function(t,e){return rt(t,"toString",{configurable:!0,enumerable:!1,value:cn(e),writable:!0})}:he,un=Xi;var Qi=sn(un),fn=Qi;var ec=9007199254740991,tc=/^(?:0|[1-9]\d*)$/;function rc(t,e){var r=typeof t;return e=e??ec,!!e&&(r=="number"||r!="symbol"&&tc.test(t))&&t>-1&&t%1==0&&t<e}var nt=rc;function nc(t,e,r){e=="__proto__"&&rt?rt(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var ln=nc;function ac(t,e){return t===e||t!==t&&e!==e}var at=ac;var dn=Math.max;function oc(t,e,r){return e=dn(e===void 0?t.length-1:e,0),function(){for(var n=arguments,a=-1,o=dn(n.length-e,0),i=Array(o);++a<o;)i[a]=n[e+a];a=-1;for(var s=Array(e+1);++a<e;)s[a]=n[a];return s[e]=r(i),on(t,this,s)}}var pn=oc;function sc(t,e){return fn(pn(t,e,he),t+"")}var mn=sc;var ic=9007199254740991;function cc(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=ic}var ot=cc;function uc(t){return t!=null&&ot(t.length)&&!Bt(t)}var ge=uc;function fc(t,e,r){if(!me(r))return!1;var n=typeof e;return(n=="number"?ge(r)&&nt(e,r.length):n=="string"&&e in r)?at(r[e],t):!1}var gr=fc;var lc=Object.prototype;function dc(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||lc;return t===r}var hn=dc;function pc(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}var gn=pc;var mc="[object Arguments]";function hc(t){return q(t)&&Y(t)==mc}var yr=hc;var yn=Object.prototype,gc=yn.hasOwnProperty,yc=yn.propertyIsEnumerable,_c=yr((function(){return arguments})())?yr:function(t){return q(t)&&gc.call(t,"callee")&&!yc.call(t,"callee")},st=_c;function xc(){return!1}var _n=xc;var bn=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xn=bn&&typeof module=="object"&&module&&!module.nodeType&&module,vc=xn&&xn.exports===bn,vn=vc?M.Buffer:void 0,bc=vn?vn.isBuffer:void 0,Tc=bc||_n,St=Tc;var wc="[object Arguments]",Ic="[object Array]",Ec="[object Boolean]",Sc="[object Date]",Oc="[object Error]",Ac="[object Function]",kc="[object Map]",Rc="[object Number]",Lc="[object Object]",Cc="[object RegExp]",Nc="[object Set]",Pc="[object String]",$c="[object WeakMap]",Mc="[object ArrayBuffer]",Dc="[object DataView]",jc="[object Float32Array]",Gc="[object Float64Array]",Bc="[object Int8Array]",Uc="[object Int16Array]",Fc="[object Int32Array]",Hc="[object Uint8Array]",zc="[object Uint8ClampedArray]",Vc="[object Uint16Array]",Zc="[object Uint32Array]",k={};k[jc]=k[Gc]=k[Bc]=k[Uc]=k[Fc]=k[Hc]=k[zc]=k[Vc]=k[Zc]=!0;k[wc]=k[Ic]=k[Mc]=k[Ec]=k[Dc]=k[Sc]=k[Oc]=k[Ac]=k[kc]=k[Rc]=k[Lc]=k[Cc]=k[Nc]=k[Pc]=k[$c]=!1;function Kc(t){return q(t)&&ot(t.length)&&!!k[Y(t)]}var Tn=Kc;function Wc(t){return function(e){return t(e)}}var Ht=Wc;var wn=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ot=wn&&typeof module=="object"&&module&&!module.nodeType&&module,Yc=Ot&&Ot.exports===wn,_r=Yc&&Gt.process,qc=(function(){try{var t=Ot&&Ot.require&&Ot.require("util").types;return t||_r&&_r.binding&&_r.binding("util")}catch{}})(),xr=qc;var In=xr&&xr.isTypedArray,Jc=In?Ht(In):Tn,zt=Jc;var Xc=Object.prototype,Qc=Xc.hasOwnProperty;function eu(t,e){var r=R(t),n=!r&&st(t),a=!r&&!n&&St(t),o=!r&&!n&&!a&&zt(t),i=r||n||a||o,s=i?gn(t.length,String):[],c=s.length;for(var u in t)(e||Qc.call(t,u))&&!(i&&(u=="length"||a&&(u=="offset"||u=="parent")||o&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||nt(u,c)))&&s.push(u);return s}var En=eu;function tu(t,e){return function(r){return t(e(r))}}var Sn=tu;var ru=Sn(Object.keys,Object),On=ru;var nu=Object.prototype,au=nu.hasOwnProperty;function ou(t){if(!hn(t))return On(t);var e=[];for(var r in Object(t))au.call(t,r)&&r!="constructor"&&e.push(r);return e}var An=ou;function su(t){return ge(t)?En(t):An(t)}var it=su;var iu=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,cu=/^\w*$/;function uu(t,e){if(R(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||ie(t)?!0:cu.test(t)||!iu.test(t)||e!=null&&t in Object(e)}var ct=uu;var fu=F(Object,"create"),ue=fu;function lu(){this.__data__=ue?ue(null):{},this.size=0}var kn=lu;function du(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Rn=du;var pu="__lodash_hash_undefined__",mu=Object.prototype,hu=mu.hasOwnProperty;function gu(t){var e=this.__data__;if(ue){var r=e[t];return r===pu?void 0:r}return hu.call(e,t)?e[t]:void 0}var Ln=gu;var yu=Object.prototype,_u=yu.hasOwnProperty;function xu(t){var e=this.__data__;return ue?e[t]!==void 0:_u.call(e,t)}var Cn=xu;var vu="__lodash_hash_undefined__";function bu(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=ue&&e===void 0?vu:e,this}var Nn=bu;function ut(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}ut.prototype.clear=kn;ut.prototype.delete=Rn;ut.prototype.get=Ln;ut.prototype.has=Cn;ut.prototype.set=Nn;var vr=ut;function Tu(){this.__data__=[],this.size=0}var Pn=Tu;function wu(t,e){for(var r=t.length;r--;)if(at(t[r][0],e))return r;return-1}var ye=wu;var Iu=Array.prototype,Eu=Iu.splice;function Su(t){var e=this.__data__,r=ye(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():Eu.call(e,r,1),--this.size,!0}var $n=Su;function Ou(t){var e=this.__data__,r=ye(e,t);return r<0?void 0:e[r][1]}var Mn=Ou;function Au(t){return ye(this.__data__,t)>-1}var Dn=Au;function ku(t,e){var r=this.__data__,n=ye(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}var jn=ku;function ft(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}ft.prototype.clear=Pn;ft.prototype.delete=$n;ft.prototype.get=Mn;ft.prototype.has=Dn;ft.prototype.set=jn;var _e=ft;var Ru=F(M,"Map"),xe=Ru;function Lu(){this.size=0,this.__data__={hash:new vr,map:new(xe||_e),string:new vr}}var Gn=Lu;function Cu(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var Bn=Cu;function Nu(t,e){var r=t.__data__;return Bn(e)?r[typeof e=="string"?"string":"hash"]:r.map}var ve=Nu;function Pu(t){var e=ve(this,t).delete(t);return this.size-=e?1:0,e}var Un=Pu;function $u(t){return ve(this,t).get(t)}var Fn=$u;function Mu(t){return ve(this,t).has(t)}var Hn=Mu;function Du(t,e){var r=ve(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this}var zn=Du;function lt(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}lt.prototype.clear=Gn;lt.prototype.delete=Un;lt.prototype.get=Fn;lt.prototype.has=Hn;lt.prototype.set=zn;var Ge=lt;var ju="Expected a function";function br(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(ju);var r=function(){var n=arguments,a=e?e.apply(this,n):n[0],o=r.cache;if(o.has(a))return o.get(a);var i=t.apply(this,n);return r.cache=o.set(a,i)||o,i};return r.cache=new(br.Cache||Ge),r}br.Cache=Ge;var Vn=br;var Gu=500;function Bu(t){var e=Vn(t,function(n){return r.size===Gu&&r.clear(),n}),r=e.cache;return e}var Zn=Bu;var Uu=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Fu=/\\(\\)?/g,Hu=Zn(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(Uu,function(r,n,a,o){e.push(a?o.replace(Fu,"$1"):n||r)}),e}),Kn=Hu;function zu(t){return t==null?"":en(t)}var Wn=zu;function Vu(t,e){return R(t)?t:ct(t,e)?[t]:Kn(Wn(t))}var Vt=Vu;var Zu=1/0;function Ku(t){if(typeof t=="string"||ie(t))return t;var e=t+"";return e=="0"&&1/t==-Zu?"-0":e}var be=Ku;function Wu(t,e){e=Vt(e,t);for(var r=0,n=e.length;t!=null&&r<n;)t=t[be(e[r++])];return r&&r==n?t:void 0}var dt=Wu;function Yu(t,e,r){var n=t==null?void 0:dt(t,e);return n===void 0?r:n}var Yn=Yu;function qu(t,e){for(var r=-1,n=e.length,a=t.length;++r<n;)t[a+r]=e[r];return t}var Zt=qu;var qn=G?G.isConcatSpreadable:void 0;function Ju(t){return R(t)||st(t)||!!(qn&&t&&t[qn])}var Jn=Ju;function Xn(t,e,r,n,a){var o=-1,i=t.length;for(r||(r=Jn),a||(a=[]);++o<i;){var s=t[o];e>0&&r(s)?e>1?Xn(s,e-1,r,n,a):Zt(a,s):n||(a[a.length]=s)}return a}var Qn=Xn;function Xu(){this.__data__=new _e,this.size=0}var ea=Xu;function Qu(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var ta=Qu;function ef(t){return this.__data__.get(t)}var ra=ef;function tf(t){return this.__data__.has(t)}var na=tf;var rf=200;function nf(t,e){var r=this.__data__;if(r instanceof _e){var n=r.__data__;if(!xe||n.length<rf-1)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Ge(n)}return r.set(t,e),this.size=r.size,this}var aa=nf;function pt(t){var e=this.__data__=new _e(t);this.size=e.size}pt.prototype.clear=ea;pt.prototype.delete=ta;pt.prototype.get=ra;pt.prototype.has=na;pt.prototype.set=aa;var mt=pt;function af(t,e){for(var r=-1,n=t==null?0:t.length,a=0,o=[];++r<n;){var i=t[r];e(i,r,t)&&(o[a++]=i)}return o}var oa=af;function of(){return[]}var sa=of;var sf=Object.prototype,cf=sf.propertyIsEnumerable,ia=Object.getOwnPropertySymbols,uf=ia?function(t){return t==null?[]:(t=Object(t),oa(ia(t),function(e){return cf.call(t,e)}))}:sa,ca=uf;function ff(t,e,r){var n=e(t);return R(t)?n:Zt(n,r(t))}var ua=ff;function lf(t){return ua(t,it,ca)}var Tr=lf;var df=F(M,"DataView"),Kt=df;var pf=F(M,"Promise"),Wt=pf;var mf=F(M,"Set"),Yt=mf;var fa="[object Map]",hf="[object Object]",la="[object Promise]",da="[object Set]",pa="[object WeakMap]",ma="[object DataView]",gf=ce(Kt),yf=ce(xe),_f=ce(Wt),xf=ce(Yt),vf=ce(Ft),Be=Y;(Kt&&Be(new Kt(new ArrayBuffer(1)))!=ma||xe&&Be(new xe)!=fa||Wt&&Be(Wt.resolve())!=la||Yt&&Be(new Yt)!=da||Ft&&Be(new Ft)!=pa)&&(Be=function(t){var e=Y(t),r=e==hf?t.constructor:void 0,n=r?ce(r):"";if(n)switch(n){case gf:return ma;case yf:return fa;case _f:return la;case xf:return da;case vf:return pa}return e});var wr=Be;var bf=M.Uint8Array,Ir=bf;var Tf="__lodash_hash_undefined__";function wf(t){return this.__data__.set(t,Tf),this}var ha=wf;function If(t){return this.__data__.has(t)}var ga=If;function qt(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Ge;++e<r;)this.add(t[e])}qt.prototype.add=qt.prototype.push=ha;qt.prototype.has=ga;var ya=qt;function Ef(t,e){for(var r=-1,n=t==null?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}var _a=Ef;function Sf(t,e){return t.has(e)}var xa=Sf;var Of=1,Af=2;function kf(t,e,r,n,a,o){var i=r&Of,s=t.length,c=e.length;if(s!=c&&!(i&&c>s))return!1;var u=o.get(t),l=o.get(e);if(u&&l)return u==e&&l==t;var m=-1,y=!0,x=r&Af?new ya:void 0;for(o.set(t,e),o.set(e,t);++m<s;){var O=t[m],E=e[m];if(n)var S=i?n(E,O,m,e,t,o):n(O,E,m,t,e,o);if(S!==void 0){if(S)continue;y=!1;break}if(x){if(!_a(e,function($,re){if(!xa(x,re)&&(O===$||a(O,$,r,n,o)))return x.push(re)})){y=!1;break}}else if(!(O===E||a(O,E,r,n,o))){y=!1;break}}return o.delete(t),o.delete(e),y}var Jt=kf;function Rf(t){var e=-1,r=Array(t.size);return t.forEach(function(n,a){r[++e]=[a,n]}),r}var va=Rf;function Lf(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}var ba=Lf;var Cf=1,Nf=2,Pf="[object Boolean]",$f="[object Date]",Mf="[object Error]",Df="[object Map]",jf="[object Number]",Gf="[object RegExp]",Bf="[object Set]",Uf="[object String]",Ff="[object Symbol]",Hf="[object ArrayBuffer]",zf="[object DataView]",Ta=G?G.prototype:void 0,Er=Ta?Ta.valueOf:void 0;function Vf(t,e,r,n,a,o,i){switch(r){case zf:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case Hf:return!(t.byteLength!=e.byteLength||!o(new Ir(t),new Ir(e)));case Pf:case $f:case jf:return at(+t,+e);case Mf:return t.name==e.name&&t.message==e.message;case Gf:case Uf:return t==e+"";case Df:var s=va;case Bf:var c=n&Cf;if(s||(s=ba),t.size!=e.size&&!c)return!1;var u=i.get(t);if(u)return u==e;n|=Nf,i.set(t,e);var l=Jt(s(t),s(e),n,a,o,i);return i.delete(t),l;case Ff:if(Er)return Er.call(t)==Er.call(e)}return!1}var wa=Vf;var Zf=1,Kf=Object.prototype,Wf=Kf.hasOwnProperty;function Yf(t,e,r,n,a,o){var i=r&Zf,s=Tr(t),c=s.length,u=Tr(e),l=u.length;if(c!=l&&!i)return!1;for(var m=c;m--;){var y=s[m];if(!(i?y in e:Wf.call(e,y)))return!1}var x=o.get(t),O=o.get(e);if(x&&O)return x==e&&O==t;var E=!0;o.set(t,e),o.set(e,t);for(var S=i;++m<c;){y=s[m];var $=t[y],re=e[y];if(n)var Ct=i?n(re,$,y,e,t,o):n($,re,y,t,e,o);if(!(Ct===void 0?$===re||a($,re,r,n,o):Ct)){E=!1;break}S||(S=y=="constructor")}if(E&&!S){var Ve=t.constructor,Nt=e.constructor;Ve!=Nt&&"constructor"in t&&"constructor"in e&&!(typeof Ve=="function"&&Ve instanceof Ve&&typeof Nt=="function"&&Nt instanceof Nt)&&(E=!1)}return o.delete(t),o.delete(e),E}var Ia=Yf;var qf=1,Ea="[object Arguments]",Sa="[object Array]",Xt="[object Object]",Jf=Object.prototype,Oa=Jf.hasOwnProperty;function Xf(t,e,r,n,a,o){var i=R(t),s=R(e),c=i?Sa:wr(t),u=s?Sa:wr(e);c=c==Ea?Xt:c,u=u==Ea?Xt:u;var l=c==Xt,m=u==Xt,y=c==u;if(y&&St(t)){if(!St(e))return!1;i=!0,l=!1}if(y&&!l)return o||(o=new mt),i||zt(t)?Jt(t,e,r,n,a,o):wa(t,e,c,r,n,a,o);if(!(r&qf)){var x=l&&Oa.call(t,"__wrapped__"),O=m&&Oa.call(e,"__wrapped__");if(x||O){var E=x?t.value():t,S=O?e.value():e;return o||(o=new mt),a(E,S,r,n,o)}}return y?(o||(o=new mt),Ia(t,e,r,n,a,o)):!1}var Aa=Xf;function ka(t,e,r,n,a){return t===e?!0:t==null||e==null||!q(t)&&!q(e)?t!==t&&e!==e:Aa(t,e,r,n,ka,a)}var Qt=ka;var Qf=1,el=2;function tl(t,e,r,n){var a=r.length,o=a,i=!n;if(t==null)return!o;for(t=Object(t);a--;){var s=r[a];if(i&&s[2]?s[1]!==t[s[0]]:!(s[0]in t))return!1}for(;++a<o;){s=r[a];var c=s[0],u=t[c],l=s[1];if(i&&s[2]){if(u===void 0&&!(c in t))return!1}else{var m=new mt;if(n)var y=n(u,l,c,t,e,m);if(!(y===void 0?Qt(l,u,Qf|el,n,m):y))return!1}}return!0}var Ra=tl;function rl(t){return t===t&&!me(t)}var er=rl;function nl(t){for(var e=it(t),r=e.length;r--;){var n=e[r],a=t[n];e[r]=[n,a,er(a)]}return e}var La=nl;function al(t,e){return function(r){return r==null?!1:r[t]===e&&(e!==void 0||t in Object(r))}}var tr=al;function ol(t){var e=La(t);return e.length==1&&e[0][2]?tr(e[0][0],e[0][1]):function(r){return r===t||Ra(r,t,e)}}var Ca=ol;function sl(t,e){return t!=null&&e in Object(t)}var Na=sl;function il(t,e,r){e=Vt(e,t);for(var n=-1,a=e.length,o=!1;++n<a;){var i=be(e[n]);if(!(o=t!=null&&r(t,i)))break;t=t[i]}return o||++n!=a?o:(a=t==null?0:t.length,!!a&&ot(a)&&nt(i,a)&&(R(t)||st(t)))}var Pa=il;function cl(t,e){return t!=null&&Pa(t,e,Na)}var $a=cl;var ul=1,fl=2;function ll(t,e){return ct(t)&&er(e)?tr(be(t),e):function(r){var n=Yn(r,t);return n===void 0&&n===e?$a(r,t):Qt(e,n,ul|fl)}}var Ma=ll;function dl(t){return function(e){return e?.[t]}}var Da=dl;function pl(t){return function(e){return dt(e,t)}}var ja=pl;function ml(t){return ct(t)?Da(be(t)):ja(t)}var Ga=ml;function hl(t){return typeof t=="function"?t:t==null?he:typeof t=="object"?R(t)?Ma(t[0],t[1]):Ca(t):Ga(t)}var rr=hl;function gl(t,e,r,n){for(var a=-1,o=t==null?0:t.length;++a<o;){var i=t[a];e(n,i,r(i),t)}return n}var Ba=gl;function yl(t){return function(e,r,n){for(var a=-1,o=Object(e),i=n(e),s=i.length;s--;){var c=i[t?s:++a];if(r(o[c],c,o)===!1)break}return e}}var Ua=yl;var _l=Ua(),Fa=_l;function xl(t,e){return t&&Fa(t,e,it)}var Ha=xl;function vl(t,e){return function(r,n){if(r==null)return r;if(!ge(r))return t(r,n);for(var a=r.length,o=e?a:-1,i=Object(r);(e?o--:++o<a)&&n(i[o],o,i)!==!1;);return r}}var za=vl;var bl=za(Ha),nr=bl;function Tl(t,e,r,n){return nr(t,function(a,o,i){e(n,a,r(a),i)}),n}var Va=Tl;function wl(t,e){return function(r,n){var a=R(r)?Ba:Va,o=e?e():{};return a(r,t,rr(n,2),o)}}var Za=wl;function Il(t,e){var r=-1,n=ge(t)?Array(t.length):[];return nr(t,function(a,o,i){n[++r]=e(a,o,i)}),n}var Ka=Il;var El=Object.prototype,Sl=El.hasOwnProperty,Ol=Za(function(t,e,r){Sl.call(t,r)?t[r].push(e):ln(t,r,[e])}),At=Ol;function Al(t,e){var r=t.length;for(t.sort(e);r--;)t[r]=t[r].value;return t}var Wa=Al;function kl(t,e){if(t!==e){var r=t!==void 0,n=t===null,a=t===t,o=ie(t),i=e!==void 0,s=e===null,c=e===e,u=ie(e);if(!s&&!u&&!o&&t>e||o&&i&&c&&!s&&!u||n&&i&&c||!r&&c||!a)return 1;if(!n&&!o&&!u&&t<e||u&&r&&a&&!n&&!o||s&&r&&a||!i&&a||!c)return-1}return 0}var Ya=kl;function Rl(t,e,r){for(var n=-1,a=t.criteria,o=e.criteria,i=a.length,s=r.length;++n<i;){var c=Ya(a[n],o[n]);if(c){if(n>=s)return c;var u=r[n];return c*(u=="desc"?-1:1)}}return t.index-e.index}var qa=Rl;function Ll(t,e,r){e.length?e=tt(e,function(o){return R(o)?function(i){return dt(i,o.length===1?o[0]:o)}:o}):e=[he];var n=-1;e=tt(e,Ht(rr));var a=Ka(t,function(o,i,s){var c=tt(e,function(u){return u(o)});return{criteria:c,index:++n,value:o}});return Wa(a,function(o,i){return qa(o,i,r)})}var Ja=Ll;var Cl=mn(function(t,e){if(t==null)return[];var r=e.length;return r>1&&gr(t,e[0],e[1])?e=[]:r>2&&gr(e[0],e[1],e[2])&&(e=[e[0]]),Ja(t,Qn(e,1),[])}),Sr=Cl;H();function w(t){return{content:[{type:"text",text:t}]}}function te(t,e){return!t||t.length<=e?t:t.slice(0,e)+"..."}var bt=200;function Oo(t){t.tool("search",`Search Sigil knowledge base for facts across all ingested documents.
|
|
16
|
+
`)}var Ha=K(()=>{});import{config as $d}from"dotenv";import{resolve as Mr,dirname as Ka}from"node:path";import{fileURLToPath as Md}from"node:url";import{existsSync as Dd}from"node:fs";import"dotenv/config";import{StdioServerTransport as Pd}from"@modelcontextprotocol/sdk/server/stdio.js";import{McpServer as Nd}from"@modelcontextprotocol/sdk/server/mcp.js";var g={};Ze(g,{BRAND:()=>vs,DIRTY:()=>Ie,EMPTY_PATH:()=>Xa,INVALID:()=>_,NEVER:()=>oi,OK:()=>j,ParseStatus:()=>D,Schema:()=>T,ZodAny:()=>de,ZodArray:()=>se,ZodBigInt:()=>Se,ZodBoolean:()=>we,ZodBranded:()=>It,ZodCatch:()=>De,ZodDate:()=>Oe,ZodDefault:()=>Me,ZodDiscriminatedUnion:()=>Mt,ZodEffects:()=>Z,ZodEnum:()=>Pe,ZodError:()=>B,ZodFirstPartyTypeKind:()=>v,ZodFunction:()=>jt,ZodIntersection:()=>Le,ZodIssueCode:()=>f,ZodLazy:()=>Ce,ZodLiteral:()=>Ne,ZodMap:()=>Xe,ZodNaN:()=>et,ZodNativeEnum:()=>$e,ZodNever:()=>W,ZodNull:()=>ke,ZodNullable:()=>Q,ZodNumber:()=>Ee,ZodObject:()=>U,ZodOptional:()=>z,ZodParsedType:()=>m,ZodPipeline:()=>Et,ZodPromise:()=>pe,ZodReadonly:()=>je,ZodRecord:()=>Dt,ZodSchema:()=>T,ZodSet:()=>Qe,ZodString:()=>le,ZodSymbol:()=>qe,ZodTransformer:()=>Z,ZodTuple:()=>X,ZodType:()=>T,ZodUndefined:()=>Ae,ZodUnion:()=>Re,ZodUnknown:()=>ae,ZodVoid:()=>Je,addIssueToContext:()=>d,any:()=>ks,array:()=>Ns,bigint:()=>Es,boolean:()=>Kr,coerce:()=>ni,custom:()=>zr,date:()=>Ss,datetimeRegex:()=>Fr,defaultErrorMap:()=>ne,discriminatedUnion:()=>Ds,effect:()=>Ys,enum:()=>Zs,function:()=>Hs,getErrorMap:()=>Ke,getParsedType:()=>J,instanceof:()=>Ts,intersection:()=>js,isAborted:()=>Pt,isAsync:()=>We,isDirty:()=>$t,isValid:()=>fe,late:()=>bs,lazy:()=>zs,literal:()=>Vs,makeIssue:()=>Tt,map:()=>Us,nan:()=>Is,nativeEnum:()=>Ks,never:()=>Ls,null:()=>As,nullable:()=>Js,number:()=>Zr,object:()=>Ps,objectUtil:()=>pr,oboolean:()=>ri,onumber:()=>ti,optional:()=>qs,ostring:()=>ei,pipeline:()=>Qs,preprocess:()=>Xs,promise:()=>Ws,quotelessJson:()=>Ya,record:()=>Bs,set:()=>Fs,setErrorMap:()=>Ja,strictObject:()=>$s,string:()=>Vr,symbol:()=>ws,transformer:()=>Ys,tuple:()=>Gs,undefined:()=>Os,union:()=>Ms,unknown:()=>Rs,util:()=>S,void:()=>Cs});var S;(function(t){t.assertEqual=o=>{};function e(o){}t.assertIs=e;function r(o){throw new Error}t.assertNever=r,t.arrayToEnum=o=>{let a={};for(let i of o)a[i]=i;return a},t.getValidEnumValues=o=>{let a=t.objectKeys(o).filter(s=>typeof o[o[s]]!="number"),i={};for(let s of a)i[s]=o[s];return t.objectValues(i)},t.objectValues=o=>t.objectKeys(o).map(function(a){return o[a]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let a=[];for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&a.push(i);return a},t.find=(o,a)=>{for(let i of o)if(a(i))return i},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,a=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(o,a)=>typeof a=="bigint"?a.toString():a})(S||(S={}));var pr;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(pr||(pr={}));var m=S.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),J=t=>{switch(typeof t){case"undefined":return m.undefined;case"string":return m.string;case"number":return Number.isNaN(t)?m.nan:m.number;case"boolean":return m.boolean;case"function":return m.function;case"bigint":return m.bigint;case"symbol":return m.symbol;case"object":return Array.isArray(t)?m.array:t===null?m.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?m.promise:typeof Map<"u"&&t instanceof Map?m.map:typeof Set<"u"&&t instanceof Set?m.set:typeof Date<"u"&&t instanceof Date?m.date:m.object;default:return m.unknown}};var f=S.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Ya=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),B=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(a){return a.message},n={_errors:[]},o=a=>{for(let i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let s=n,c=0;for(;c<i.path.length;){let u=i.path[c];c===i.path.length-1?(s[u]=s[u]||{_errors:[]},s[u]._errors.push(r(i))):s[u]=s[u]||{_errors:[]},s=s[u],c++}}};return o(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,S.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let o of this.issues)if(o.path.length>0){let a=o.path[0];r[a]=r[a]||[],r[a].push(e(o))}else n.push(e(o));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};B.create=t=>new B(t);var qa=(t,e)=>{let r;switch(t.code){case f.invalid_type:t.received===m.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case f.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,S.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:r=`Unrecognized key(s) in object: ${S.joinValues(t.keys,", ")}`;break;case f.invalid_union:r="Invalid input";break;case f.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${S.joinValues(t.options)}`;break;case f.invalid_enum_value:r=`Invalid enum value. Expected ${S.joinValues(t.options)}, received '${t.received}'`;break;case f.invalid_arguments:r="Invalid function arguments";break;case f.invalid_return_type:r="Invalid function return type";break;case f.invalid_date:r="Invalid date";break;case f.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:S.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case f.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case f.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case f.custom:r="Invalid input";break;case f.invalid_intersection_types:r="Intersection results could not be merged";break;case f.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case f.not_finite:r="Number must be finite";break;default:r=e.defaultError,S.assertNever(t)}return{message:r}},ne=qa;var Dr=ne;function Ja(t){Dr=t}function Ke(){return Dr}var Tt=t=>{let{data:e,path:r,errorMaps:n,issueData:o}=t,a=[...r,...o.path||[]],i={...o,path:a};if(o.message!==void 0)return{...o,path:a,message:o.message};let s="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)s=u(i,{data:e,defaultError:s}).message;return{...o,path:a,message:s}},Xa=[];function d(t,e){let r=Ke(),n=Tt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===ne?void 0:ne].filter(o=>!!o)});t.common.issues.push(n)}var D=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let o of r){if(o.status==="aborted")return _;o.status==="dirty"&&e.dirty(),n.push(o.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let o of r){let a=await o.key,i=await o.value;n.push({key:a,value:i})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let o of r){let{key:a,value:i}=o;if(a.status==="aborted"||i.status==="aborted")return _;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}},_=Object.freeze({status:"aborted"}),Ie=t=>({status:"dirty",value:t}),j=t=>({status:"valid",value:t}),Pt=t=>t.status==="aborted",$t=t=>t.status==="dirty",fe=t=>t.status==="valid",We=t=>typeof Promise<"u"&&t instanceof Promise;var h;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(h||(h={}));var V=class{constructor(e,r,n,o){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},jr=(t,e)=>{if(fe(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new B(t.common.issues);return this._error=r,this._error}}};function b(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:o}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:o}:{errorMap:(i,s)=>{let{message:c}=t;return i.code==="invalid_enum_value"?{message:c??s.defaultError}:typeof s.data>"u"?{message:c??n??s.defaultError}:i.code!=="invalid_type"?{message:s.defaultError}:{message:c??r??s.defaultError}},description:o}}var T=class{get description(){return this._def.description}_getType(e){return J(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:J(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new D,ctx:{common:e.parent.common,data:e.data,parsedType:J(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(We(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:J(e)},o=this._parseSync({data:e,path:n.path,parent:n});return jr(n,o)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:J(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return fe(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>fe(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:J(e)},o=this._parse({data:e,path:n.path,parent:n}),a=await(We(o)?o:Promise.resolve(o));return jr(n,a)}refine(e,r){let n=o=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(o):r;return this._refinement((o,a)=>{let i=e(o),s=()=>a.addIssue({code:f.custom,...n(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(s(),!1)):i?!0:(s(),!1)})}refinement(e,r){return this._refinement((n,o)=>e(n)?!0:(o.addIssue(typeof r=="function"?r(n,o):r),!1))}_refinement(e){return new Z({schema:this,typeName:v.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return z.create(this,this._def)}nullable(){return Q.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return se.create(this)}promise(){return pe.create(this,this._def)}or(e){return Re.create([this,e],this._def)}and(e){return Le.create(this,e,this._def)}transform(e){return new Z({...b(this._def),schema:this,typeName:v.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Me({...b(this._def),innerType:this,defaultValue:r,typeName:v.ZodDefault})}brand(){return new It({typeName:v.ZodBranded,type:this,...b(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new De({...b(this._def),innerType:this,catchValue:r,typeName:v.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Et.create(this,e)}readonly(){return je.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Qa=/^c[^\s-]{8,}$/i,es=/^[0-9a-z]+$/,ts=/^[0-9A-HJKMNP-TV-Z]{26}$/i,rs=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,ns=/^[a-z0-9_-]{21}$/i,os=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,as=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ss=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,is="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",mr,cs=/^(?:(?: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])$/,us=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,fs=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,ls=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ds=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ps=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Br="((\\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])))",ms=new RegExp(`^${Br}$`);function Ur(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function hs(t){return new RegExp(`^${Ur(t)}$`)}function Fr(t){let e=`${Br}T${Ur(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function gs(t,e){return!!((e==="v4"||!e)&&cs.test(t)||(e==="v6"||!e)&&fs.test(t))}function ys(t,e){if(!os.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),o=JSON.parse(atob(n));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||e&&o.alg!==e)}catch{return!1}}function _s(t,e){return!!((e==="v4"||!e)&&us.test(t)||(e==="v6"||!e)&&ls.test(t))}var le=class t extends T{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==m.string){let a=this._getOrReturnCtx(e);return d(a,{code:f.invalid_type,expected:m.string,received:a.parsedType}),_}let n=new D,o;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(o=this._getOrReturnCtx(e,o),d(o,{code:f.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(o=this._getOrReturnCtx(e,o),d(o,{code:f.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let i=e.data.length>a.value,s=e.data.length<a.value;(i||s)&&(o=this._getOrReturnCtx(e,o),i?d(o,{code:f.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&d(o,{code:f.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")ss.test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"email",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")mr||(mr=new RegExp(is,"u")),mr.test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"emoji",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")rs.test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"uuid",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")ns.test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"nanoid",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")Qa.test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"cuid",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")es.test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"cuid2",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")ts.test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"ulid",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),d(o,{validation:"url",code:f.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"regex",code:f.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(o=this._getOrReturnCtx(e,o),d(o,{code:f.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(o=this._getOrReturnCtx(e,o),d(o,{code:f.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(o=this._getOrReturnCtx(e,o),d(o,{code:f.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Fr(a).test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{code:f.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?ms.test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{code:f.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?hs(a).test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{code:f.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?as.test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"duration",code:f.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?gs(e.data,a.version)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"ip",code:f.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?ys(e.data,a.alg)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"jwt",code:f.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?_s(e.data,a.version)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"cidr",code:f.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?ds.test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"base64",code:f.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?ps.test(e.data)||(o=this._getOrReturnCtx(e,o),d(o,{validation:"base64url",code:f.invalid_string,message:a.message}),n.dirty()):S.assertNever(a);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(o=>e.test(o),{validation:r,code:f.invalid_string,...h.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...h.errToObj(e)})}url(e){return this._addCheck({kind:"url",...h.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...h.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...h.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...h.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...h.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...h.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...h.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...h.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...h.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...h.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...h.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...h.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...h.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...h.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...h.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...h.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...h.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...h.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...h.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...h.errToObj(r)})}nonempty(e){return this.min(1,h.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};le.create=t=>new le({checks:[],typeName:v.ZodString,coerce:t?.coerce??!1,...b(t)});function xs(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=r>n?r:n,a=Number.parseInt(t.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return a%i/10**o}var Ee=class t extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==m.number){let a=this._getOrReturnCtx(e);return d(a,{code:f.invalid_type,expected:m.number,received:a.parsedType}),_}let n,o=new D;for(let a of this._def.checks)a.kind==="int"?S.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:f.invalid_type,expected:"integer",received:"float",message:a.message}),o.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:f.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),o.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:f.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),o.dirty()):a.kind==="multipleOf"?xs(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),d(n,{code:f.not_multiple_of,multipleOf:a.value,message:a.message}),o.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:f.not_finite,message:a.message}),o.dirty()):S.assertNever(a);return{status:o.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,h.toString(r))}gt(e,r){return this.setLimit("min",e,!1,h.toString(r))}lte(e,r){return this.setLimit("max",e,!0,h.toString(r))}lt(e,r){return this.setLimit("max",e,!1,h.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:h.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:h.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:h.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:h.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:h.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:h.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&S.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};Ee.create=t=>new Ee({checks:[],typeName:v.ZodNumber,coerce:t?.coerce||!1,...b(t)});var Se=class t extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==m.bigint)return this._getInvalidInput(e);let n,o=new D;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:f.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),o.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:f.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),o.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),d(n,{code:f.not_multiple_of,multipleOf:a.value,message:a.message}),o.dirty()):S.assertNever(a);return{status:o.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return d(r,{code:f.invalid_type,expected:m.bigint,received:r.parsedType}),_}gte(e,r){return this.setLimit("min",e,!0,h.toString(r))}gt(e,r){return this.setLimit("min",e,!1,h.toString(r))}lte(e,r){return this.setLimit("max",e,!0,h.toString(r))}lt(e,r){return this.setLimit("max",e,!1,h.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:h.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:h.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Se.create=t=>new Se({checks:[],typeName:v.ZodBigInt,coerce:t?.coerce??!1,...b(t)});var we=class extends T{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==m.boolean){let n=this._getOrReturnCtx(e);return d(n,{code:f.invalid_type,expected:m.boolean,received:n.parsedType}),_}return j(e.data)}};we.create=t=>new we({typeName:v.ZodBoolean,coerce:t?.coerce||!1,...b(t)});var Oe=class t extends T{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==m.date){let a=this._getOrReturnCtx(e);return d(a,{code:f.invalid_type,expected:m.date,received:a.parsedType}),_}if(Number.isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return d(a,{code:f.invalid_date}),_}let n=new D,o;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(o=this._getOrReturnCtx(e,o),d(o,{code:f.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(o=this._getOrReturnCtx(e,o),d(o,{code:f.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):S.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:h.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};Oe.create=t=>new Oe({checks:[],coerce:t?.coerce||!1,typeName:v.ZodDate,...b(t)});var qe=class extends T{_parse(e){if(this._getType(e)!==m.symbol){let n=this._getOrReturnCtx(e);return d(n,{code:f.invalid_type,expected:m.symbol,received:n.parsedType}),_}return j(e.data)}};qe.create=t=>new qe({typeName:v.ZodSymbol,...b(t)});var Ae=class extends T{_parse(e){if(this._getType(e)!==m.undefined){let n=this._getOrReturnCtx(e);return d(n,{code:f.invalid_type,expected:m.undefined,received:n.parsedType}),_}return j(e.data)}};Ae.create=t=>new Ae({typeName:v.ZodUndefined,...b(t)});var ke=class extends T{_parse(e){if(this._getType(e)!==m.null){let n=this._getOrReturnCtx(e);return d(n,{code:f.invalid_type,expected:m.null,received:n.parsedType}),_}return j(e.data)}};ke.create=t=>new ke({typeName:v.ZodNull,...b(t)});var de=class extends T{constructor(){super(...arguments),this._any=!0}_parse(e){return j(e.data)}};de.create=t=>new de({typeName:v.ZodAny,...b(t)});var ae=class extends T{constructor(){super(...arguments),this._unknown=!0}_parse(e){return j(e.data)}};ae.create=t=>new ae({typeName:v.ZodUnknown,...b(t)});var W=class extends T{_parse(e){let r=this._getOrReturnCtx(e);return d(r,{code:f.invalid_type,expected:m.never,received:r.parsedType}),_}};W.create=t=>new W({typeName:v.ZodNever,...b(t)});var Je=class extends T{_parse(e){if(this._getType(e)!==m.undefined){let n=this._getOrReturnCtx(e);return d(n,{code:f.invalid_type,expected:m.void,received:n.parsedType}),_}return j(e.data)}};Je.create=t=>new Je({typeName:v.ZodVoid,...b(t)});var se=class t extends T{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),o=this._def;if(r.parsedType!==m.array)return d(r,{code:f.invalid_type,expected:m.array,received:r.parsedType}),_;if(o.exactLength!==null){let i=r.data.length>o.exactLength.value,s=r.data.length<o.exactLength.value;(i||s)&&(d(r,{code:i?f.too_big:f.too_small,minimum:s?o.exactLength.value:void 0,maximum:i?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),n.dirty())}if(o.minLength!==null&&r.data.length<o.minLength.value&&(d(r,{code:f.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),n.dirty()),o.maxLength!==null&&r.data.length>o.maxLength.value&&(d(r,{code:f.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,s)=>o.type._parseAsync(new V(r,i,r.path,s)))).then(i=>D.mergeArray(n,i));let a=[...r.data].map((i,s)=>o.type._parseSync(new V(r,i,r.path,s)));return D.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:h.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:h.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:h.toString(r)}})}nonempty(e){return this.min(1,e)}};se.create=(t,e)=>new se({type:t,minLength:null,maxLength:null,exactLength:null,typeName:v.ZodArray,...b(e)});function Ye(t){if(t instanceof U){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=z.create(Ye(n))}return new U({...t._def,shape:()=>e})}else return t instanceof se?new se({...t._def,type:Ye(t.element)}):t instanceof z?z.create(Ye(t.unwrap())):t instanceof Q?Q.create(Ye(t.unwrap())):t instanceof X?X.create(t.items.map(e=>Ye(e))):t}var U=class t extends T{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=S.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==m.object){let u=this._getOrReturnCtx(e);return d(u,{code:f.invalid_type,expected:m.object,received:u.parsedType}),_}let{status:n,ctx:o}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),s=[];if(!(this._def.catchall instanceof W&&this._def.unknownKeys==="strip"))for(let u in o.data)i.includes(u)||s.push(u);let c=[];for(let u of i){let l=a[u],p=o.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new V(o,p,o.path,u)),alwaysSet:u in o.data})}if(this._def.catchall instanceof W){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of s)c.push({key:{status:"valid",value:l},value:{status:"valid",value:o.data[l]}});else if(u==="strict")s.length>0&&(d(o,{code:f.unrecognized_keys,keys:s}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of s){let p=o.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new V(o,p,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let p=await l.key,y=await l.value;u.push({key:p,value:y,alwaysSet:l.alwaysSet})}return u}).then(u=>D.mergeObjectSync(n,u)):D.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let o=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:h.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:v.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of S.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of S.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Ye(this)}partial(e){let r={};for(let n of S.objectKeys(this.shape)){let o=this.shape[n];e&&!e[n]?r[n]=o:r[n]=o.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of S.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof z;)a=a._def.innerType;r[n]=a}return new t({...this._def,shape:()=>r})}keyof(){return Hr(S.objectKeys(this.shape))}};U.create=(t,e)=>new U({shape:()=>t,unknownKeys:"strip",catchall:W.create(),typeName:v.ZodObject,...b(e)});U.strictCreate=(t,e)=>new U({shape:()=>t,unknownKeys:"strict",catchall:W.create(),typeName:v.ZodObject,...b(e)});U.lazycreate=(t,e)=>new U({shape:t,unknownKeys:"strip",catchall:W.create(),typeName:v.ZodObject,...b(e)});var Re=class extends T{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function o(a){for(let s of a)if(s.result.status==="valid")return s.result;for(let s of a)if(s.result.status==="dirty")return r.common.issues.push(...s.ctx.common.issues),s.result;let i=a.map(s=>new B(s.ctx.common.issues));return d(r,{code:f.invalid_union,unionErrors:i}),_}if(r.common.async)return Promise.all(n.map(async a=>{let i={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(o);{let a,i=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;let s=i.map(c=>new B(c));return d(r,{code:f.invalid_union,unionErrors:s}),_}}get options(){return this._def.options}};Re.create=(t,e)=>new Re({options:t,typeName:v.ZodUnion,...b(e)});var oe=t=>t instanceof Ce?oe(t.schema):t instanceof Z?oe(t.innerType()):t instanceof Ne?[t.value]:t instanceof Pe?t.options:t instanceof $e?S.objectValues(t.enum):t instanceof Me?oe(t._def.innerType):t instanceof Ae?[void 0]:t instanceof ke?[null]:t instanceof z?[void 0,...oe(t.unwrap())]:t instanceof Q?[null,...oe(t.unwrap())]:t instanceof It||t instanceof je?oe(t.unwrap()):t instanceof De?oe(t._def.innerType):[],Mt=class t extends T{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==m.object)return d(r,{code:f.invalid_type,expected:m.object,received:r.parsedType}),_;let n=this.discriminator,o=r.data[n],a=this.optionsMap.get(o);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(d(r,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),_)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let o=new Map;for(let a of r){let i=oe(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let s of i){if(o.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);o.set(s,a)}}return new t({typeName:v.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:o,...b(n)})}};function hr(t,e){let r=J(t),n=J(e);if(t===e)return{valid:!0,data:t};if(r===m.object&&n===m.object){let o=S.objectKeys(e),a=S.objectKeys(t).filter(s=>o.indexOf(s)!==-1),i={...t,...e};for(let s of a){let c=hr(t[s],e[s]);if(!c.valid)return{valid:!1};i[s]=c.data}return{valid:!0,data:i}}else if(r===m.array&&n===m.array){if(t.length!==e.length)return{valid:!1};let o=[];for(let a=0;a<t.length;a++){let i=t[a],s=e[a],c=hr(i,s);if(!c.valid)return{valid:!1};o.push(c.data)}return{valid:!0,data:o}}else return r===m.date&&n===m.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Le=class extends T{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=(a,i)=>{if(Pt(a)||Pt(i))return _;let s=hr(a.value,i.value);return s.valid?(($t(a)||$t(i))&&r.dirty(),{status:r.value,value:s.data}):(d(n,{code:f.invalid_intersection_types}),_)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>o(a,i)):o(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Le.create=(t,e,r)=>new Le({left:t,right:e,typeName:v.ZodIntersection,...b(r)});var X=class t extends T{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==m.array)return d(n,{code:f.invalid_type,expected:m.array,received:n.parsedType}),_;if(n.data.length<this._def.items.length)return d(n,{code:f.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),_;!this._def.rest&&n.data.length>this._def.items.length&&(d(n,{code:f.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let a=[...n.data].map((i,s)=>{let c=this._def.items[s]||this._def.rest;return c?c._parse(new V(n,i,n.path,s)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>D.mergeArray(r,i)):D.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};X.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new X({items:t,typeName:v.ZodTuple,rest:null,...b(e)})};var Dt=class t extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==m.object)return d(n,{code:f.invalid_type,expected:m.object,received:n.parsedType}),_;let o=[],a=this._def.keyType,i=this._def.valueType;for(let s in n.data)o.push({key:a._parse(new V(n,s,n.path,s)),value:i._parse(new V(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?D.mergeObjectAsync(r,o):D.mergeObjectSync(r,o)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof T?new t({keyType:e,valueType:r,typeName:v.ZodRecord,...b(n)}):new t({keyType:le.create(),valueType:e,typeName:v.ZodRecord,...b(r)})}},Xe=class extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==m.map)return d(n,{code:f.invalid_type,expected:m.map,received:n.parsedType}),_;let o=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([s,c],u)=>({key:o._parse(new V(n,s,n.path,[u,"key"])),value:a._parse(new V(n,c,n.path,[u,"value"]))}));if(n.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let c of i){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return _;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(u.value,l.value)}return{status:r.value,value:s}})}else{let s=new Map;for(let c of i){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return _;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(u.value,l.value)}return{status:r.value,value:s}}}};Xe.create=(t,e,r)=>new Xe({valueType:e,keyType:t,typeName:v.ZodMap,...b(r)});var Qe=class t extends T{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==m.set)return d(n,{code:f.invalid_type,expected:m.set,received:n.parsedType}),_;let o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&(d(n,{code:f.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),r.dirty()),o.maxSize!==null&&n.data.size>o.maxSize.value&&(d(n,{code:f.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),r.dirty());let a=this._def.valueType;function i(c){let u=new Set;for(let l of c){if(l.status==="aborted")return _;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let s=[...n.data.values()].map((c,u)=>a._parse(new V(n,c,n.path,u)));return n.common.async?Promise.all(s).then(c=>i(c)):i(s)}min(e,r){return new t({...this._def,minSize:{value:e,message:h.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:h.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Qe.create=(t,e)=>new Qe({valueType:t,minSize:null,maxSize:null,typeName:v.ZodSet,...b(e)});var jt=class t extends T{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==m.function)return d(r,{code:f.invalid_type,expected:m.function,received:r.parsedType}),_;function n(s,c){return Tt({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ke(),ne].filter(u=>!!u),issueData:{code:f.invalid_arguments,argumentsError:c}})}function o(s,c){return Tt({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ke(),ne].filter(u=>!!u),issueData:{code:f.invalid_return_type,returnTypeError:c}})}let a={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof pe){let s=this;return j(async function(...c){let u=new B([]),l=await s._def.args.parseAsync(c,a).catch(x=>{throw u.addIssue(n(c,x)),u}),p=await Reflect.apply(i,this,l);return await s._def.returns._def.type.parseAsync(p,a).catch(x=>{throw u.addIssue(o(p,x)),u})})}else{let s=this;return j(function(...c){let u=s._def.args.safeParse(c,a);if(!u.success)throw new B([n(c,u.error)]);let l=Reflect.apply(i,this,u.data),p=s._def.returns.safeParse(l,a);if(!p.success)throw new B([o(l,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:X.create(e).rest(ae.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||X.create([]).rest(ae.create()),returns:r||ae.create(),typeName:v.ZodFunction,...b(n)})}},Ce=class extends T{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Ce.create=(t,e)=>new Ce({getter:t,typeName:v.ZodLazy,...b(e)});var Ne=class extends T{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return d(r,{received:r.data,code:f.invalid_literal,expected:this._def.value}),_}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ne.create=(t,e)=>new Ne({value:t,typeName:v.ZodLiteral,...b(e)});function Hr(t,e){return new Pe({values:t,typeName:v.ZodEnum,...b(e)})}var Pe=class t extends T{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return d(r,{expected:S.joinValues(n),received:r.parsedType,code:f.invalid_type}),_}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return d(r,{received:r.data,code:f.invalid_enum_value,options:n}),_}return j(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};Pe.create=Hr;var $e=class extends T{_parse(e){let r=S.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==m.string&&n.parsedType!==m.number){let o=S.objectValues(r);return d(n,{expected:S.joinValues(o),received:n.parsedType,code:f.invalid_type}),_}if(this._cache||(this._cache=new Set(S.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=S.objectValues(r);return d(n,{received:n.data,code:f.invalid_enum_value,options:o}),_}return j(e.data)}get enum(){return this._def.values}};$e.create=(t,e)=>new $e({values:t,typeName:v.ZodNativeEnum,...b(e)});var pe=class extends T{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==m.promise&&r.common.async===!1)return d(r,{code:f.invalid_type,expected:m.promise,received:r.parsedType}),_;let n=r.parsedType===m.promise?r.data:Promise.resolve(r.data);return j(n.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}};pe.create=(t,e)=>new pe({type:t,typeName:v.ZodPromise,...b(e)});var Z=class extends T{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===v.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=this._def.effect||null,a={addIssue:i=>{d(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),o.type==="preprocess"){let i=o.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async s=>{if(r.value==="aborted")return _;let c=await this._def.schema._parseAsync({data:s,path:n.path,parent:n});return c.status==="aborted"?_:c.status==="dirty"?Ie(c.value):r.value==="dirty"?Ie(c.value):c});{if(r.value==="aborted")return _;let s=this._def.schema._parseSync({data:i,path:n.path,parent:n});return s.status==="aborted"?_:s.status==="dirty"?Ie(s.value):r.value==="dirty"?Ie(s.value):s}}if(o.type==="refinement"){let i=s=>{let c=o.refinement(s,a);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?_:(s.status==="dirty"&&r.dirty(),i(s.value),{status:r.value,value:s.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>s.status==="aborted"?_:(s.status==="dirty"&&r.dirty(),i(s.value).then(()=>({status:r.value,value:s.value}))))}if(o.type==="transform")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!fe(i))return _;let s=o.transform(i.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:s}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>fe(i)?Promise.resolve(o.transform(i.value,a)).then(s=>({status:r.value,value:s})):_);S.assertNever(o)}};Z.create=(t,e,r)=>new Z({schema:t,typeName:v.ZodEffects,effect:e,...b(r)});Z.createWithPreprocess=(t,e,r)=>new Z({schema:e,effect:{type:"preprocess",transform:t},typeName:v.ZodEffects,...b(r)});var z=class extends T{_parse(e){return this._getType(e)===m.undefined?j(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};z.create=(t,e)=>new z({innerType:t,typeName:v.ZodOptional,...b(e)});var Q=class extends T{_parse(e){return this._getType(e)===m.null?j(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Q.create=(t,e)=>new Q({innerType:t,typeName:v.ZodNullable,...b(e)});var Me=class extends T{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===m.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Me.create=(t,e)=>new Me({innerType:t,typeName:v.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...b(e)});var De=class extends T{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},o=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return We(o)?o.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new B(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new B(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};De.create=(t,e)=>new De({innerType:t,typeName:v.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...b(e)});var et=class extends T{_parse(e){if(this._getType(e)!==m.nan){let n=this._getOrReturnCtx(e);return d(n,{code:f.invalid_type,expected:m.nan,received:n.parsedType}),_}return{status:"valid",value:e.data}}};et.create=t=>new et({typeName:v.ZodNaN,...b(t)});var vs=Symbol("zod_brand"),It=class extends T{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Et=class t extends T{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?_:a.status==="dirty"?(r.dirty(),Ie(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{let o=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?_:o.status==="dirty"?(r.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:v.ZodPipeline})}},je=class extends T{_parse(e){let r=this._def.innerType._parse(e),n=o=>(fe(o)&&(o.value=Object.freeze(o.value)),o);return We(r)?r.then(o=>n(o)):n(r)}unwrap(){return this._def.innerType}};je.create=(t,e)=>new je({innerType:t,typeName:v.ZodReadonly,...b(e)});function Gr(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function zr(t,e={},r){return t?de.create().superRefine((n,o)=>{let a=t(n);if(a instanceof Promise)return a.then(i=>{if(!i){let s=Gr(e,n),c=s.fatal??r??!0;o.addIssue({code:"custom",...s,fatal:c})}});if(!a){let i=Gr(e,n),s=i.fatal??r??!0;o.addIssue({code:"custom",...i,fatal:s})}}):de.create()}var bs={object:U.lazycreate},v;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(v||(v={}));var Ts=(t,e={message:`Input not instance of ${t.name}`})=>zr(r=>r instanceof t,e),Vr=le.create,Zr=Ee.create,Is=et.create,Es=Se.create,Kr=we.create,Ss=Oe.create,ws=qe.create,Os=Ae.create,As=ke.create,ks=de.create,Rs=ae.create,Ls=W.create,Cs=Je.create,Ns=se.create,Ps=U.create,$s=U.strictCreate,Ms=Re.create,Ds=Mt.create,js=Le.create,Gs=X.create,Bs=Dt.create,Us=Xe.create,Fs=Qe.create,Hs=jt.create,zs=Ce.create,Vs=Ne.create,Zs=Pe.create,Ks=$e.create,Ws=pe.create,Ys=Z.create,qs=z.create,Js=Q.create,Xs=Z.createWithPreprocess,Qs=Et.create,ei=()=>Vr().optional(),ti=()=>Zr().optional(),ri=()=>Kr().optional(),ni={string:(t=>le.create({...t,coerce:!0})),number:(t=>Ee.create({...t,coerce:!0})),boolean:(t=>we.create({...t,coerce:!0})),bigint:(t=>Se.create({...t,coerce:!0})),date:(t=>Oe.create({...t,coerce:!0}))};var oi=_;var ai=typeof global=="object"&&global&&global.Object===Object&&global,Gt=ai;var si=typeof self=="object"&&self&&self.Object===Object&&self,ii=Gt||si||Function("return this")(),M=ii;var ci=M.Symbol,G=ci;var Wr=Object.prototype,ui=Wr.hasOwnProperty,fi=Wr.toString,St=G?G.toStringTag:void 0;function li(t){var e=ui.call(t,St),r=t[St];try{t[St]=void 0;var n=!0}catch{}var o=fi.call(t);return n&&(e?t[St]=r:delete t[St]),o}var Yr=li;var di=Object.prototype,pi=di.toString;function mi(t){return pi.call(t)}var qr=mi;var hi="[object Null]",gi="[object Undefined]",Jr=G?G.toStringTag:void 0;function yi(t){return t==null?t===void 0?gi:hi:Jr&&Jr in Object(t)?Yr(t):qr(t)}var Y=yi;function _i(t){return t!=null&&typeof t=="object"}var q=_i;var xi="[object Symbol]";function vi(t){return typeof t=="symbol"||q(t)&&Y(t)==xi}var ie=vi;function bi(t,e){for(var r=-1,n=t==null?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}var tt=bi;var Ti=Array.isArray,R=Ti;var Ii=1/0,Xr=G?G.prototype:void 0,Qr=Xr?Xr.toString:void 0;function en(t){if(typeof t=="string")return t;if(R(t))return tt(t,en)+"";if(ie(t))return Qr?Qr.call(t):"";var e=t+"";return e=="0"&&1/t==-Ii?"-0":e}var tn=en;function Ei(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var me=Ei;function Si(t){return t}var he=Si;var wi="[object AsyncFunction]",Oi="[object Function]",Ai="[object GeneratorFunction]",ki="[object Proxy]";function Ri(t){if(!me(t))return!1;var e=Y(t);return e==Oi||e==Ai||e==wi||e==ki}var Bt=Ri;var Li=M["__core-js_shared__"],Ut=Li;var rn=(function(){var t=/[^.]+$/.exec(Ut&&Ut.keys&&Ut.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function Ci(t){return!!rn&&rn in t}var nn=Ci;var Ni=Function.prototype,Pi=Ni.toString;function $i(t){if(t!=null){try{return Pi.call(t)}catch{}try{return t+""}catch{}}return""}var ce=$i;var Mi=/[\\^$.*+?()[\]{}|]/g,Di=/^\[object .+?Constructor\]$/,ji=Function.prototype,Gi=Object.prototype,Bi=ji.toString,Ui=Gi.hasOwnProperty,Fi=RegExp("^"+Bi.call(Ui).replace(Mi,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Hi(t){if(!me(t)||nn(t))return!1;var e=Bt(t)?Fi:Di;return e.test(ce(t))}var on=Hi;function zi(t,e){return t?.[e]}var an=zi;function Vi(t,e){var r=an(t,e);return on(r)?r:void 0}var F=Vi;var Zi=F(M,"WeakMap"),Ft=Zi;function Ki(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var sn=Ki;var Wi=800,Yi=16,qi=Date.now;function Ji(t){var e=0,r=0;return function(){var n=qi(),o=Yi-(n-r);if(r=n,o>0){if(++e>=Wi)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var cn=Ji;function Xi(t){return function(){return t}}var un=Xi;var Qi=(function(){try{var t=F(Object,"defineProperty");return t({},"",{}),t}catch{}})(),rt=Qi;var ec=rt?function(t,e){return rt(t,"toString",{configurable:!0,enumerable:!1,value:un(e),writable:!0})}:he,fn=ec;var tc=cn(fn),ln=tc;var rc=9007199254740991,nc=/^(?:0|[1-9]\d*)$/;function oc(t,e){var r=typeof t;return e=e??rc,!!e&&(r=="number"||r!="symbol"&&nc.test(t))&&t>-1&&t%1==0&&t<e}var nt=oc;function ac(t,e,r){e=="__proto__"&&rt?rt(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var dn=ac;function sc(t,e){return t===e||t!==t&&e!==e}var ot=sc;var pn=Math.max;function ic(t,e,r){return e=pn(e===void 0?t.length-1:e,0),function(){for(var n=arguments,o=-1,a=pn(n.length-e,0),i=Array(a);++o<a;)i[o]=n[e+o];o=-1;for(var s=Array(e+1);++o<e;)s[o]=n[o];return s[e]=r(i),sn(t,this,s)}}var mn=ic;function cc(t,e){return ln(mn(t,e,he),t+"")}var hn=cc;var uc=9007199254740991;function fc(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=uc}var at=fc;function lc(t){return t!=null&&at(t.length)&&!Bt(t)}var ge=lc;function dc(t,e,r){if(!me(r))return!1;var n=typeof e;return(n=="number"?ge(r)&&nt(e,r.length):n=="string"&&e in r)?ot(r[e],t):!1}var gr=dc;var pc=Object.prototype;function mc(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||pc;return t===r}var gn=mc;function hc(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}var yn=hc;var gc="[object Arguments]";function yc(t){return q(t)&&Y(t)==gc}var yr=yc;var _n=Object.prototype,_c=_n.hasOwnProperty,xc=_n.propertyIsEnumerable,vc=yr((function(){return arguments})())?yr:function(t){return q(t)&&_c.call(t,"callee")&&!xc.call(t,"callee")},st=vc;function bc(){return!1}var xn=bc;var Tn=typeof exports=="object"&&exports&&!exports.nodeType&&exports,vn=Tn&&typeof module=="object"&&module&&!module.nodeType&&module,Tc=vn&&vn.exports===Tn,bn=Tc?M.Buffer:void 0,Ic=bn?bn.isBuffer:void 0,Ec=Ic||xn,wt=Ec;var Sc="[object Arguments]",wc="[object Array]",Oc="[object Boolean]",Ac="[object Date]",kc="[object Error]",Rc="[object Function]",Lc="[object Map]",Cc="[object Number]",Nc="[object Object]",Pc="[object RegExp]",$c="[object Set]",Mc="[object String]",Dc="[object WeakMap]",jc="[object ArrayBuffer]",Gc="[object DataView]",Bc="[object Float32Array]",Uc="[object Float64Array]",Fc="[object Int8Array]",Hc="[object Int16Array]",zc="[object Int32Array]",Vc="[object Uint8Array]",Zc="[object Uint8ClampedArray]",Kc="[object Uint16Array]",Wc="[object Uint32Array]",k={};k[Bc]=k[Uc]=k[Fc]=k[Hc]=k[zc]=k[Vc]=k[Zc]=k[Kc]=k[Wc]=!0;k[Sc]=k[wc]=k[jc]=k[Oc]=k[Gc]=k[Ac]=k[kc]=k[Rc]=k[Lc]=k[Cc]=k[Nc]=k[Pc]=k[$c]=k[Mc]=k[Dc]=!1;function Yc(t){return q(t)&&at(t.length)&&!!k[Y(t)]}var In=Yc;function qc(t){return function(e){return t(e)}}var Ht=qc;var En=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ot=En&&typeof module=="object"&&module&&!module.nodeType&&module,Jc=Ot&&Ot.exports===En,_r=Jc&&Gt.process,Xc=(function(){try{var t=Ot&&Ot.require&&Ot.require("util").types;return t||_r&&_r.binding&&_r.binding("util")}catch{}})(),xr=Xc;var Sn=xr&&xr.isTypedArray,Qc=Sn?Ht(Sn):In,zt=Qc;var eu=Object.prototype,tu=eu.hasOwnProperty;function ru(t,e){var r=R(t),n=!r&&st(t),o=!r&&!n&&wt(t),a=!r&&!n&&!o&&zt(t),i=r||n||o||a,s=i?yn(t.length,String):[],c=s.length;for(var u in t)(e||tu.call(t,u))&&!(i&&(u=="length"||o&&(u=="offset"||u=="parent")||a&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||nt(u,c)))&&s.push(u);return s}var wn=ru;function nu(t,e){return function(r){return t(e(r))}}var On=nu;var ou=On(Object.keys,Object),An=ou;var au=Object.prototype,su=au.hasOwnProperty;function iu(t){if(!gn(t))return An(t);var e=[];for(var r in Object(t))su.call(t,r)&&r!="constructor"&&e.push(r);return e}var kn=iu;function cu(t){return ge(t)?wn(t):kn(t)}var it=cu;var uu=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,fu=/^\w*$/;function lu(t,e){if(R(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||ie(t)?!0:fu.test(t)||!uu.test(t)||e!=null&&t in Object(e)}var ct=lu;var du=F(Object,"create"),ue=du;function pu(){this.__data__=ue?ue(null):{},this.size=0}var Rn=pu;function mu(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Ln=mu;var hu="__lodash_hash_undefined__",gu=Object.prototype,yu=gu.hasOwnProperty;function _u(t){var e=this.__data__;if(ue){var r=e[t];return r===hu?void 0:r}return yu.call(e,t)?e[t]:void 0}var Cn=_u;var xu=Object.prototype,vu=xu.hasOwnProperty;function bu(t){var e=this.__data__;return ue?e[t]!==void 0:vu.call(e,t)}var Nn=bu;var Tu="__lodash_hash_undefined__";function Iu(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=ue&&e===void 0?Tu:e,this}var Pn=Iu;function ut(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}ut.prototype.clear=Rn;ut.prototype.delete=Ln;ut.prototype.get=Cn;ut.prototype.has=Nn;ut.prototype.set=Pn;var vr=ut;function Eu(){this.__data__=[],this.size=0}var $n=Eu;function Su(t,e){for(var r=t.length;r--;)if(ot(t[r][0],e))return r;return-1}var ye=Su;var wu=Array.prototype,Ou=wu.splice;function Au(t){var e=this.__data__,r=ye(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():Ou.call(e,r,1),--this.size,!0}var Mn=Au;function ku(t){var e=this.__data__,r=ye(e,t);return r<0?void 0:e[r][1]}var Dn=ku;function Ru(t){return ye(this.__data__,t)>-1}var jn=Ru;function Lu(t,e){var r=this.__data__,n=ye(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}var Gn=Lu;function ft(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}ft.prototype.clear=$n;ft.prototype.delete=Mn;ft.prototype.get=Dn;ft.prototype.has=jn;ft.prototype.set=Gn;var _e=ft;var Cu=F(M,"Map"),xe=Cu;function Nu(){this.size=0,this.__data__={hash:new vr,map:new(xe||_e),string:new vr}}var Bn=Nu;function Pu(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var Un=Pu;function $u(t,e){var r=t.__data__;return Un(e)?r[typeof e=="string"?"string":"hash"]:r.map}var ve=$u;function Mu(t){var e=ve(this,t).delete(t);return this.size-=e?1:0,e}var Fn=Mu;function Du(t){return ve(this,t).get(t)}var Hn=Du;function ju(t){return ve(this,t).has(t)}var zn=ju;function Gu(t,e){var r=ve(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this}var Vn=Gu;function lt(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}lt.prototype.clear=Bn;lt.prototype.delete=Fn;lt.prototype.get=Hn;lt.prototype.has=zn;lt.prototype.set=Vn;var Ge=lt;var Bu="Expected a function";function br(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(Bu);var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],a=r.cache;if(a.has(o))return a.get(o);var i=t.apply(this,n);return r.cache=a.set(o,i)||a,i};return r.cache=new(br.Cache||Ge),r}br.Cache=Ge;var Zn=br;var Uu=500;function Fu(t){var e=Zn(t,function(n){return r.size===Uu&&r.clear(),n}),r=e.cache;return e}var Kn=Fu;var Hu=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,zu=/\\(\\)?/g,Vu=Kn(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(Hu,function(r,n,o,a){e.push(o?a.replace(zu,"$1"):n||r)}),e}),Wn=Vu;function Zu(t){return t==null?"":tn(t)}var Yn=Zu;function Ku(t,e){return R(t)?t:ct(t,e)?[t]:Wn(Yn(t))}var Vt=Ku;var Wu=1/0;function Yu(t){if(typeof t=="string"||ie(t))return t;var e=t+"";return e=="0"&&1/t==-Wu?"-0":e}var be=Yu;function qu(t,e){e=Vt(e,t);for(var r=0,n=e.length;t!=null&&r<n;)t=t[be(e[r++])];return r&&r==n?t:void 0}var dt=qu;function Ju(t,e,r){var n=t==null?void 0:dt(t,e);return n===void 0?r:n}var qn=Ju;function Xu(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}var Zt=Xu;var Jn=G?G.isConcatSpreadable:void 0;function Qu(t){return R(t)||st(t)||!!(Jn&&t&&t[Jn])}var Xn=Qu;function Qn(t,e,r,n,o){var a=-1,i=t.length;for(r||(r=Xn),o||(o=[]);++a<i;){var s=t[a];e>0&&r(s)?e>1?Qn(s,e-1,r,n,o):Zt(o,s):n||(o[o.length]=s)}return o}var eo=Qn;function ef(){this.__data__=new _e,this.size=0}var to=ef;function tf(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var ro=tf;function rf(t){return this.__data__.get(t)}var no=rf;function nf(t){return this.__data__.has(t)}var oo=nf;var of=200;function af(t,e){var r=this.__data__;if(r instanceof _e){var n=r.__data__;if(!xe||n.length<of-1)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Ge(n)}return r.set(t,e),this.size=r.size,this}var ao=af;function pt(t){var e=this.__data__=new _e(t);this.size=e.size}pt.prototype.clear=to;pt.prototype.delete=ro;pt.prototype.get=no;pt.prototype.has=oo;pt.prototype.set=ao;var mt=pt;function sf(t,e){for(var r=-1,n=t==null?0:t.length,o=0,a=[];++r<n;){var i=t[r];e(i,r,t)&&(a[o++]=i)}return a}var so=sf;function cf(){return[]}var io=cf;var uf=Object.prototype,ff=uf.propertyIsEnumerable,co=Object.getOwnPropertySymbols,lf=co?function(t){return t==null?[]:(t=Object(t),so(co(t),function(e){return ff.call(t,e)}))}:io,uo=lf;function df(t,e,r){var n=e(t);return R(t)?n:Zt(n,r(t))}var fo=df;function pf(t){return fo(t,it,uo)}var Tr=pf;var mf=F(M,"DataView"),Kt=mf;var hf=F(M,"Promise"),Wt=hf;var gf=F(M,"Set"),Yt=gf;var lo="[object Map]",yf="[object Object]",po="[object Promise]",mo="[object Set]",ho="[object WeakMap]",go="[object DataView]",_f=ce(Kt),xf=ce(xe),vf=ce(Wt),bf=ce(Yt),Tf=ce(Ft),Be=Y;(Kt&&Be(new Kt(new ArrayBuffer(1)))!=go||xe&&Be(new xe)!=lo||Wt&&Be(Wt.resolve())!=po||Yt&&Be(new Yt)!=mo||Ft&&Be(new Ft)!=ho)&&(Be=function(t){var e=Y(t),r=e==yf?t.constructor:void 0,n=r?ce(r):"";if(n)switch(n){case _f:return go;case xf:return lo;case vf:return po;case bf:return mo;case Tf:return ho}return e});var Ir=Be;var If=M.Uint8Array,Er=If;var Ef="__lodash_hash_undefined__";function Sf(t){return this.__data__.set(t,Ef),this}var yo=Sf;function wf(t){return this.__data__.has(t)}var _o=wf;function qt(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Ge;++e<r;)this.add(t[e])}qt.prototype.add=qt.prototype.push=yo;qt.prototype.has=_o;var xo=qt;function Of(t,e){for(var r=-1,n=t==null?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}var vo=Of;function Af(t,e){return t.has(e)}var bo=Af;var kf=1,Rf=2;function Lf(t,e,r,n,o,a){var i=r&kf,s=t.length,c=e.length;if(s!=c&&!(i&&c>s))return!1;var u=a.get(t),l=a.get(e);if(u&&l)return u==e&&l==t;var p=-1,y=!0,x=r&Rf?new xo:void 0;for(a.set(t,e),a.set(e,t);++p<s;){var O=t[p],E=e[p];if(n)var w=i?n(E,O,p,e,t,a):n(O,E,p,t,e,a);if(w!==void 0){if(w)continue;y=!1;break}if(x){if(!vo(e,function($,re){if(!bo(x,re)&&(O===$||o(O,$,r,n,a)))return x.push(re)})){y=!1;break}}else if(!(O===E||o(O,E,r,n,a))){y=!1;break}}return a.delete(t),a.delete(e),y}var Jt=Lf;function Cf(t){var e=-1,r=Array(t.size);return t.forEach(function(n,o){r[++e]=[o,n]}),r}var To=Cf;function Nf(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}var Io=Nf;var Pf=1,$f=2,Mf="[object Boolean]",Df="[object Date]",jf="[object Error]",Gf="[object Map]",Bf="[object Number]",Uf="[object RegExp]",Ff="[object Set]",Hf="[object String]",zf="[object Symbol]",Vf="[object ArrayBuffer]",Zf="[object DataView]",Eo=G?G.prototype:void 0,Sr=Eo?Eo.valueOf:void 0;function Kf(t,e,r,n,o,a,i){switch(r){case Zf:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case Vf:return!(t.byteLength!=e.byteLength||!a(new Er(t),new Er(e)));case Mf:case Df:case Bf:return ot(+t,+e);case jf:return t.name==e.name&&t.message==e.message;case Uf:case Hf:return t==e+"";case Gf:var s=To;case Ff:var c=n&Pf;if(s||(s=Io),t.size!=e.size&&!c)return!1;var u=i.get(t);if(u)return u==e;n|=$f,i.set(t,e);var l=Jt(s(t),s(e),n,o,a,i);return i.delete(t),l;case zf:if(Sr)return Sr.call(t)==Sr.call(e)}return!1}var So=Kf;var Wf=1,Yf=Object.prototype,qf=Yf.hasOwnProperty;function Jf(t,e,r,n,o,a){var i=r&Wf,s=Tr(t),c=s.length,u=Tr(e),l=u.length;if(c!=l&&!i)return!1;for(var p=c;p--;){var y=s[p];if(!(i?y in e:qf.call(e,y)))return!1}var x=a.get(t),O=a.get(e);if(x&&O)return x==e&&O==t;var E=!0;a.set(t,e),a.set(e,t);for(var w=i;++p<c;){y=s[p];var $=t[y],re=e[y];if(n)var Ct=i?n(re,$,y,e,t,a):n($,re,y,t,e,a);if(!(Ct===void 0?$===re||o($,re,r,n,a):Ct)){E=!1;break}w||(w=y=="constructor")}if(E&&!w){var Ve=t.constructor,Nt=e.constructor;Ve!=Nt&&"constructor"in t&&"constructor"in e&&!(typeof Ve=="function"&&Ve instanceof Ve&&typeof Nt=="function"&&Nt instanceof Nt)&&(E=!1)}return a.delete(t),a.delete(e),E}var wo=Jf;var Xf=1,Oo="[object Arguments]",Ao="[object Array]",Xt="[object Object]",Qf=Object.prototype,ko=Qf.hasOwnProperty;function el(t,e,r,n,o,a){var i=R(t),s=R(e),c=i?Ao:Ir(t),u=s?Ao:Ir(e);c=c==Oo?Xt:c,u=u==Oo?Xt:u;var l=c==Xt,p=u==Xt,y=c==u;if(y&&wt(t)){if(!wt(e))return!1;i=!0,l=!1}if(y&&!l)return a||(a=new mt),i||zt(t)?Jt(t,e,r,n,o,a):So(t,e,c,r,n,o,a);if(!(r&Xf)){var x=l&&ko.call(t,"__wrapped__"),O=p&&ko.call(e,"__wrapped__");if(x||O){var E=x?t.value():t,w=O?e.value():e;return a||(a=new mt),o(E,w,r,n,a)}}return y?(a||(a=new mt),wo(t,e,r,n,o,a)):!1}var Ro=el;function Lo(t,e,r,n,o){return t===e?!0:t==null||e==null||!q(t)&&!q(e)?t!==t&&e!==e:Ro(t,e,r,n,Lo,o)}var Qt=Lo;var tl=1,rl=2;function nl(t,e,r,n){var o=r.length,a=o,i=!n;if(t==null)return!a;for(t=Object(t);o--;){var s=r[o];if(i&&s[2]?s[1]!==t[s[0]]:!(s[0]in t))return!1}for(;++o<a;){s=r[o];var c=s[0],u=t[c],l=s[1];if(i&&s[2]){if(u===void 0&&!(c in t))return!1}else{var p=new mt;if(n)var y=n(u,l,c,t,e,p);if(!(y===void 0?Qt(l,u,tl|rl,n,p):y))return!1}}return!0}var Co=nl;function ol(t){return t===t&&!me(t)}var er=ol;function al(t){for(var e=it(t),r=e.length;r--;){var n=e[r],o=t[n];e[r]=[n,o,er(o)]}return e}var No=al;function sl(t,e){return function(r){return r==null?!1:r[t]===e&&(e!==void 0||t in Object(r))}}var tr=sl;function il(t){var e=No(t);return e.length==1&&e[0][2]?tr(e[0][0],e[0][1]):function(r){return r===t||Co(r,t,e)}}var Po=il;function cl(t,e){return t!=null&&e in Object(t)}var $o=cl;function ul(t,e,r){e=Vt(e,t);for(var n=-1,o=e.length,a=!1;++n<o;){var i=be(e[n]);if(!(a=t!=null&&r(t,i)))break;t=t[i]}return a||++n!=o?a:(o=t==null?0:t.length,!!o&&at(o)&&nt(i,o)&&(R(t)||st(t)))}var Mo=ul;function fl(t,e){return t!=null&&Mo(t,e,$o)}var Do=fl;var ll=1,dl=2;function pl(t,e){return ct(t)&&er(e)?tr(be(t),e):function(r){var n=qn(r,t);return n===void 0&&n===e?Do(r,t):Qt(e,n,ll|dl)}}var jo=pl;function ml(t){return function(e){return e?.[t]}}var Go=ml;function hl(t){return function(e){return dt(e,t)}}var Bo=hl;function gl(t){return ct(t)?Go(be(t)):Bo(t)}var Uo=gl;function yl(t){return typeof t=="function"?t:t==null?he:typeof t=="object"?R(t)?jo(t[0],t[1]):Po(t):Uo(t)}var rr=yl;function _l(t,e,r,n){for(var o=-1,a=t==null?0:t.length;++o<a;){var i=t[o];e(n,i,r(i),t)}return n}var Fo=_l;function xl(t){return function(e,r,n){for(var o=-1,a=Object(e),i=n(e),s=i.length;s--;){var c=i[t?s:++o];if(r(a[c],c,a)===!1)break}return e}}var Ho=xl;var vl=Ho(),zo=vl;function bl(t,e){return t&&zo(t,e,it)}var Vo=bl;function Tl(t,e){return function(r,n){if(r==null)return r;if(!ge(r))return t(r,n);for(var o=r.length,a=e?o:-1,i=Object(r);(e?a--:++a<o)&&n(i[a],a,i)!==!1;);return r}}var Zo=Tl;var Il=Zo(Vo),nr=Il;function El(t,e,r,n){return nr(t,function(o,a,i){e(n,o,r(o),i)}),n}var Ko=El;function Sl(t,e){return function(r,n){var o=R(r)?Fo:Ko,a=e?e():{};return o(r,t,rr(n,2),a)}}var Wo=Sl;function wl(t,e){var r=-1,n=ge(t)?Array(t.length):[];return nr(t,function(o,a,i){n[++r]=e(o,a,i)}),n}var Yo=wl;var Ol=Object.prototype,Al=Ol.hasOwnProperty,kl=Wo(function(t,e,r){Al.call(t,r)?t[r].push(e):dn(t,r,[e])}),At=kl;function Rl(t,e){var r=t.length;for(t.sort(e);r--;)t[r]=t[r].value;return t}var qo=Rl;function Ll(t,e){if(t!==e){var r=t!==void 0,n=t===null,o=t===t,a=ie(t),i=e!==void 0,s=e===null,c=e===e,u=ie(e);if(!s&&!u&&!a&&t>e||a&&i&&c&&!s&&!u||n&&i&&c||!r&&c||!o)return 1;if(!n&&!a&&!u&&t<e||u&&r&&o&&!n&&!a||s&&r&&o||!i&&o||!c)return-1}return 0}var Jo=Ll;function Cl(t,e,r){for(var n=-1,o=t.criteria,a=e.criteria,i=o.length,s=r.length;++n<i;){var c=Jo(o[n],a[n]);if(c){if(n>=s)return c;var u=r[n];return c*(u=="desc"?-1:1)}}return t.index-e.index}var Xo=Cl;function Nl(t,e,r){e.length?e=tt(e,function(a){return R(a)?function(i){return dt(i,a.length===1?a[0]:a)}:a}):e=[he];var n=-1;e=tt(e,Ht(rr));var o=Yo(t,function(a,i,s){var c=tt(e,function(u){return u(a)});return{criteria:c,index:++n,value:a}});return qo(o,function(a,i){return Xo(a,i,r)})}var Qo=Nl;var Pl=hn(function(t,e){if(t==null)return[];var r=e.length;return r>1&&gr(t,e[0],e[1])?e=[]:r>2&&gr(e[0],e[1],e[2])&&(e=[e[0]]),Qo(t,eo(e,1),[])}),wr=Pl;H();function I(t){return{content:[{type:"text",text:t}]}}function te(t,e){return!t||t.length<=e?t:t.slice(0,e)+"..."}var bt=200;function Aa(t){t.tool("search",`Search Sigil knowledge base for facts across all ingested documents.
|
|
17
17
|
Automatically detects entity names and returns entity-centric results.
|
|
18
18
|
Use for: "how does X work", "what is Y?", "what are the rules for Z", domain knowledge, decisions.
|
|
19
19
|
Returns compact facts. Use get_fact_context(factId) for full detail on any fact.
|
|
20
20
|
Set includeChunks=true only when raw document context is needed.
|
|
21
|
-
Set format="compact" for token-efficient output (one line per category, no IDs/metadata).`,{query:g.string().describe("Natural language search query"),limit:g.number().optional().default(5).describe("Max facts to return (default 5)"),namespaces:g.array(g.string()).optional().describe("Filter by namespaces"),minConfidence:g.enum(["low","medium","high"]).optional().default("medium").describe("Minimum fact confidence"),includeChunks:g.boolean().optional().default(!1).describe("Include raw document chunks (verbose \u2014 only when needed)"),useGraph:g.boolean().optional().default(!1).describe("Traverse entity graph for additional related facts"),pointInTime:g.string().optional().describe("ISO timestamp \u2014 return only facts valid at this point in time"),format:g.enum(["full","compact"]).optional().default("full").describe('Output format: "full" (default) or "compact" (token-efficient, one line per category)'),podScope:g.union([g.literal("auto"),g.literal("global"),g.array(g.string())]).optional().describe('Pod scope: "auto" (active project/session pods \u2014 the default), "global" (whole brain, no scope), or list of pod uids/names.')},async({query:e,limit:r,namespaces:n,minConfidence:
|
|
22
|
-
${$}${te(
|
|
23
|
-
_Drill down: get_entity_context(entityId=${x.id}) for full details about ${x.name}_`),
|
|
24
|
-
`))})}function
|
|
25
|
-
`);let n=At(t,"category");for(let[a
|
|
26
|
-
`)}H();function
|
|
21
|
+
Set format="compact" for token-efficient output (one line per category, no IDs/metadata).`,{query:g.string().describe("Natural language search query"),limit:g.number().optional().default(5).describe("Max facts to return (default 5)"),namespaces:g.array(g.string()).optional().describe("Filter by namespaces"),minConfidence:g.enum(["low","medium","high"]).optional().default("medium").describe("Minimum fact confidence"),includeChunks:g.boolean().optional().default(!1).describe("Include raw document chunks (verbose \u2014 only when needed)"),useGraph:g.boolean().optional().default(!1).describe("Traverse entity graph for additional related facts"),pointInTime:g.string().optional().describe("ISO timestamp \u2014 return only facts valid at this point in time"),format:g.enum(["full","compact"]).optional().default("full").describe('Output format: "full" (default) or "compact" (token-efficient, one line per category)'),podScope:g.union([g.literal("auto"),g.literal("global"),g.array(g.string())]).optional().describe('Pod scope: "auto" (active project/session pods \u2014 the default), "global" (whole brain, no scope), or list of pod uids/names.')},async({query:e,limit:r,namespaces:n,minConfidence:o,includeChunks:a,useGraph:i,pointInTime:s,format:c,podScope:u})=>{let l=await L("search",{query:e,namespaces:n,limit:r,minConfidence:o,includeChunks:a,useGraph:i,pointInTime:s,podScope:u??"auto",cwd:process.cwd(),route:!1,synthesize:!1}),{facts:p,chunks:y,matchedEntity:x,relatedEntities:O}=l;if(c==="compact")return I(Ad(p,x));let E=[];if(x&&(E.push(`**Matched entity:** ${x.name} (${x.entityType||x.type}, id:${x.id}, ${x.mentions??x.mentionCount??0} mentions)`),x.description&&E.push(x.description),E.push("")),p.length){E.push(`**Facts (${p.length}):**`);for(let w of p){let $=te(w.content,bt),re=w.importance==="vital"?" **[VITAL]**":"",Ct=w.agent?` \xB7 via ${w.agent}`:"",Ve=Array.isArray(w.sourceDocumentIds)&&w.sourceDocumentIds.length?` \xB7 doc#${w.sourceDocumentIds[0]}`:"";E.push(`- [${w.category}] ${$}${re} _(${w.confidence}, id:${w.id}${Ct}${Ve})_`)}}if(O.length){E.push(""),E.push(`**Related entities (${O.length}):**`);for(let w of O.slice(0,10))E.push(`- ${w.name} (${w.entityType||w.type}) [${w.relation}] id:${w.id}`)}if(a&&y.length){E.push(""),E.push(`**Chunks (${y.length}):**`);for(let w of y.slice(0,3)){let $=w.sectionHeading?`[${w.sectionHeading}] `:"";E.push(`---
|
|
22
|
+
${$}${te(w.content,500)}`)}}return!p.length&&!y.length&&E.push("No results found. Try broader terms or use search_entity to find entity names."),x&&E.push(`
|
|
23
|
+
_Drill down: get_entity_context(entityId=${x.id}) for full details about ${x.name}_`),I(E.join(`
|
|
24
|
+
`))})}function Ad(t,e){let r=[];if(e&&r.push(`> ${e.name} (${e.entityType||e.type})`),!t.length)return r.push("No results."),r.join(`
|
|
25
|
+
`);let n=At(t,"category");for(let[o,a]of Object.entries(n)){let s=wr(a,c=>c.importance==="vital"?0:1).map(c=>c.content);r.push(`[${o}]: ${s.join(". ")}`)}return r.join(`
|
|
26
|
+
`)}H();function ka(t){t.tool("search_entity",`Find entities in the knowledge graph by name or type.
|
|
27
27
|
Use for: "find Alice", "list all topics", "show all people", "find documents about normalization".
|
|
28
28
|
Entity types: document, person, topic (extensible per domain).
|
|
29
|
-
Returns compact entity list. Use get_entity_context(entityId) for full details.`,{query:g.string().optional().describe('Entity name to search (e.g. "Alice", "Cohort 6")'),entityType:g.string().optional().describe("Filter by type: session, course, person, topic"),limit:g.number().optional().default(10).describe("Max results"),namespace:g.string().optional().describe("Namespace. Omit for default.")},async({query:e,entityType:r,limit:n,namespace:
|
|
29
|
+
Returns compact entity list. Use get_entity_context(entityId) for full details.`,{query:g.string().optional().describe('Entity name to search (e.g. "Alice", "Cohort 6")'),entityType:g.string().optional().describe("Filter by type: session, course, person, topic"),limit:g.number().optional().default(10).describe("Max results"),namespace:g.string().optional().describe("Namespace. Omit for default.")},async({query:e,entityType:r,limit:n,namespace:o})=>{if(!e&&!r)return I("Error: Provide either a query (entity name) or entityType.");let{entities:a}=await L("searchEntity",{query:e,entityType:r,limit:n,namespace:o});if(!a.length){let c=e?`matching "${e}"`:`of type "${r}"`;return I(`No entities found ${c}.`)}let i=a.map(c=>{let u=c.description?` \u2014 ${c.description}`:"";return`- **${c.name}** (${c.entityType}, id:${c.id}, ${c.mentionCount} mentions)${u}`}),s=e?`Entities matching "${e}"`:`${r} entities`;return I(`${s} (${a.length}):
|
|
30
30
|
${i.join(`
|
|
31
31
|
`)}
|
|
32
32
|
|
|
33
|
-
_Use get_entity_context(entityId=<id>) for details or traverse_graph(startEntityId=<id>) for connections._`)})}H();function
|
|
33
|
+
_Use get_entity_context(entityId=<id>) for details or traverse_graph(startEntityId=<id>) for connections._`)})}H();function Ra(t){t.tool("traverse_graph",`Navigate entity relationships in the knowledge graph.
|
|
34
34
|
Use for: "who did Alice mentor?", "what topics does course X cover?", "how is A related to B?",
|
|
35
35
|
"what documents cover this topic?", "show mentorship chain".
|
|
36
|
-
Relation types: PART_OF, LED_BY, MENTORED, COVERS, FOLLOWS.`,{startEntityId:g.number().describe("Starting entity ID (from search_entity results)"),action:g.enum(["neighbors","path","related"]).optional().default("neighbors").describe("neighbors = direct connections, path = shortest path to target, related = all reachable"),targetEntityId:g.number().optional().describe('Target entity ID (required for "path" action)'),relationType:g.string().optional().describe("Filter: PART_OF, LED_BY, MENTORED, COVERS, FOLLOWS"),maxDepth:g.number().optional().default(2).describe("Traversal depth 1-3"),limit:g.number().optional().default(20).describe("Max results")},async({startEntityId:e,action:r,targetEntityId:n,relationType:
|
|
37
|
-
${y.join("")}`)}if(s.action==="related"){let y=s.related||[];if(!y.length)return
|
|
38
|
-
${
|
|
39
|
-
`))}if(s.related){let y=s.related.map(x=>`- [${x.relationType}] ${x.name} (${x.entityType}, id:${x.entityId||x.id}) depth:${x.depth}`);return
|
|
36
|
+
Relation types: PART_OF, LED_BY, MENTORED, COVERS, FOLLOWS.`,{startEntityId:g.number().describe("Starting entity ID (from search_entity results)"),action:g.enum(["neighbors","path","related"]).optional().default("neighbors").describe("neighbors = direct connections, path = shortest path to target, related = all reachable"),targetEntityId:g.number().optional().describe('Target entity ID (required for "path" action)'),relationType:g.string().optional().describe("Filter: PART_OF, LED_BY, MENTORED, COVERS, FOLLOWS"),maxDepth:g.number().optional().default(2).describe("Traversal depth 1-3"),limit:g.number().optional().default(20).describe("Max results")},async({startEntityId:e,action:r,targetEntityId:n,relationType:o,maxDepth:a,limit:i})=>{let s=await L("traverseGraph",{startEntityId:e,action:r,targetEntityId:n,relationType:o,maxDepth:a,limit:i});if(s.notFound)return I(`Error: Entity ID ${e} not found.`);let c=`${s.start.name} (${s.start.entityType}, id:${s.start.id})`;if(s.action==="path"){if(!s.path)return I(`No path found from ${s.start.name} to entity ${n}.`);let y=s.path.path.map((x,O)=>{let E=O<s.path.relationTypes.length?` --[${s.path.relationTypes[O]}]--> `:"";return`${x.name} (${x.entityType})${E}`});return I(`Path (${s.path.depth} hops):
|
|
37
|
+
${y.join("")}`)}if(s.action==="related"){let y=s.related||[];if(!y.length)return I(`${s.start.name} has no related entities within ${a} hops.`);let x=At(y,"depth"),O=[`Entities related to ${c} (${y.length}):`];for(let E of Object.keys(x).sort()){let w=E==="1"?"Direct":`${E} hops`;O.push(`
|
|
38
|
+
${w}:`);for(let $ of x[E])O.push(`- [${$.relationType}] ${$.name} (${$.entityType}, id:${$.entityId})`)}return I(O.join(`
|
|
39
|
+
`))}if(s.related){let y=s.related.map(x=>`- [${x.relationType}] ${x.name} (${x.entityType}, id:${x.entityId||x.id}) depth:${x.depth}`);return I(`${c}
|
|
40
40
|
Connections (${s.related.length}):
|
|
41
41
|
${y.join(`
|
|
42
|
-
`)}`)}if(!s.relations?.length)return
|
|
43
|
-
No connections found.`);let u=s.relations.filter(y=>y.direction==="outgoing"),l=s.relations.filter(y=>y.direction==="incoming"),
|
|
44
|
-
Outgoing (${u.length}):`);for(let y of u)
|
|
45
|
-
Incoming (${l.length}):`);for(let y of l)
|
|
46
|
-
`))})}H();function
|
|
42
|
+
`)}`)}if(!s.relations?.length)return I(`${c}
|
|
43
|
+
No connections found.`);let u=s.relations.filter(y=>y.direction==="outgoing"),l=s.relations.filter(y=>y.direction==="incoming"),p=[c];if(u.length){p.push(`
|
|
44
|
+
Outgoing (${u.length}):`);for(let y of u)p.push(`- [${y.relationType}] ${y.name} (${y.entityType}, id:${y.entityId})`)}if(l.length){p.push(`
|
|
45
|
+
Incoming (${l.length}):`);for(let y of l)p.push(`- ${y.name} (${y.entityType}, id:${y.entityId}) [${y.relationType}]`)}return I(p.join(`
|
|
46
|
+
`))})}H();function La(t){t.tool("get_fact_context",`Get full context for a specific fact: complete content, entities mentioned, relations created, sources.
|
|
47
47
|
Use for: drilling down on a fact from search results, checking provenance, understanding connections.
|
|
48
|
-
This is the detail view \u2014 search returns truncated facts, this returns everything.`,{factId:g.number().optional().describe("Fact ID (from search results)"),uid:g.string().optional().describe('Fact UID (e.g. "fact-a1b2c3d4")')},async({uid:e,factId:r})=>{if(!e&&!r)return
|
|
49
|
-
Entities mentioned: ${
|
|
48
|
+
This is the detail view \u2014 search returns truncated facts, this returns everything.`,{factId:g.number().optional().describe("Fact ID (from search results)"),uid:g.string().optional().describe('Fact UID (e.g. "fact-a1b2c3d4")')},async({uid:e,factId:r})=>{if(!e&&!r)return I("Error: Provide either factId or uid.");let n=await L("getFactContext",{uid:e,factId:r});if(n.notFound)return I("Error: Fact not found.");let{fact:o,entities:a,relations:i,documents:s}=n,c=[`**Fact ${o.uid}** (${o.category}, ${o.confidence}, ${o.status})`,o.content];if(o.sourceSection&&c.push(`Source section: ${o.sourceSection}`),a.length&&c.push(`
|
|
49
|
+
Entities mentioned: ${a.map(u=>`${u.name} (${u.entityType}, id:${u.id})`).join(", ")}`),i.length){c.push(`
|
|
50
50
|
Relations from this fact:`);for(let u of i)c.push(`- ${u.sourceName} --[${u.relationType}]--> ${u.targetName}`)}return s.length&&c.push(`
|
|
51
|
-
Sources: ${s.map(u=>`${u.title} (${u.sourceType})`).join(", ")}`),
|
|
52
|
-
`))})}H();function
|
|
51
|
+
Sources: ${s.map(u=>`${u.title} (${u.sourceType})`).join(", ")}`),I(c.join(`
|
|
52
|
+
`))})}H();function Ca(t){t.tool("get_entity_context",`Get full context for an entity: relations, connected facts, graph position.
|
|
53
53
|
Use for: "tell me about Alice", "what documents cover this topic?", "show expertise areas".
|
|
54
|
-
Returns entity details + relations + key facts (truncated \u2014 use get_fact_context for full text).`,{entityId:g.number().optional().describe("Entity ID (from search_entity or search results)"),name:g.string().optional().describe("Entity name (alternative to ID)"),namespace:g.string().optional().describe("Namespace. Omit for default.")},async({entityId:e,name:r,namespace:n})=>{if(!e&&!r)return
|
|
55
|
-
Outgoing relations (${u.length}):`);for(let
|
|
56
|
-
Incoming relations (${l.length}):`);for(let
|
|
57
|
-
Key facts (${s.length}):`);for(let
|
|
54
|
+
Returns entity details + relations + key facts (truncated \u2014 use get_fact_context for full text).`,{entityId:g.number().optional().describe("Entity ID (from search_entity or search results)"),name:g.string().optional().describe("Entity name (alternative to ID)"),namespace:g.string().optional().describe("Namespace. Omit for default.")},async({entityId:e,name:r,namespace:n})=>{if(!e&&!r)return I("Error: Provide either entityId or name.");let o=await L("getEntityContext",{entityId:e,name:r,namespace:n});if(o.notFound)return I("Error: Entity not found.");let{entity:a,relations:i,facts:s}=o,c=[`**${a.name}** (${a.entityType}, id:${a.id}, ${a.mentionCount} mentions)`];a.description&&c.push(a.description);let u=i.filter(p=>p.direction==="outgoing"),l=i.filter(p=>p.direction==="incoming");if(u.length){c.push(`
|
|
55
|
+
Outgoing relations (${u.length}):`);for(let p of u.slice(0,15))c.push(`- [${p.relationType}] ${p.name} (${p.entityType}, id:${p.entityId})`);u.length>15&&c.push(` ...and ${u.length-15} more`)}if(l.length){c.push(`
|
|
56
|
+
Incoming relations (${l.length}):`);for(let p of l.slice(0,15))c.push(`- ${p.name} (${p.entityType}, id:${p.entityId}) [${p.relationType}]`);l.length>15&&c.push(` ...and ${l.length-15} more`)}if(s.length){c.push(`
|
|
57
|
+
Key facts (${s.length}):`);for(let p of s){let y=te(p.content,bt);c.push(`- [${p.category}] ${y} _(${p.confidence}, id:${p.id})_`)}}return!u.length&&!l.length&&!s.length&&c.push(`
|
|
58
58
|
No connections or facts found for this entity.`),c.push(`
|
|
59
|
-
_Use traverse_graph(startEntityId=${
|
|
60
|
-
`))})}H();function
|
|
61
|
-
Use when: checking system health, verifying ingestion, reviewing knowledge graph size.`,{namespace:g.string().optional().describe("Filter by namespace. Omit for global stats.")},async({namespace:e})=>{let r=await L("status",{namespace:e,hotFactsLimit:5}),
|
|
62
|
-
`);return
|
|
59
|
+
_Use traverse_graph(startEntityId=${a.id}) for deeper graph exploration._`),I(c.join(`
|
|
60
|
+
`))})}H();function Na(t){t.tool("status",`Show Sigil knowledge base statistics \u2014 documents, chunks, facts, entities, relations.
|
|
61
|
+
Use when: checking system health, verifying ingestion, reviewing knowledge graph size.`,{namespace:g.string().optional().describe("Filter by namespace. Omit for global stats.")},async({namespace:e})=>{let r=await L("status",{namespace:e,hotFactsLimit:5}),o=[`Sigil KB${r.namespace?` (${r.namespace})`:""}: ${r.documents} docs, ${r.chunks} chunks, ${r.facts} facts`,`Entities: ${r.entities.documents} documents, ${r.entities.people} people, ${r.entities.topics} topics`,`Relations: ${r.relations}`,`Hot facts (top ${r.hotFacts.length}): ${r.hotFacts.map(a=>`${te(a.content,60)} (${a.accessCount}x)`).join(", ")||"none yet"}`].join(`
|
|
62
|
+
`);return I(o)})}H();function Pa(t){t.tool("ingest",`Ingest a document into the Sigil knowledge base. Accepts raw content, a file path, or a URL.
|
|
63
63
|
Parses the content, chunks it, embeds it, extracts facts, links entities, and stores everything for search.
|
|
64
|
-
Use when: adding documents to the knowledge base, ingesting files, URLs, or raw text.`,{content:g.string().optional().describe("Raw text content to ingest. Provide this OR filePath OR url."),filePath:g.string().optional().describe("Local file path to ingest. Provide this OR content OR url."),url:g.string().optional().describe("URL to fetch and ingest. Provide this OR content OR filePath."),title:g.string().optional().describe("Document title. Auto-detected if not provided."),namespace:g.string().optional().describe("Namespace for the document. Defaults to config default."),sourceType:g.string().optional().describe("Source type label (e.g., docs, code, notes). Auto-detected from format."),skipFacts:g.boolean().optional().default(!1).describe("Skip fact extraction (faster, chunks only)"),skipEntities:g.boolean().optional().default(!1).describe("Skip entity linking")},async({content:e,filePath:r,url:n,title:
|
|
65
|
-
`);return
|
|
64
|
+
Use when: adding documents to the knowledge base, ingesting files, URLs, or raw text.`,{content:g.string().optional().describe("Raw text content to ingest. Provide this OR filePath OR url."),filePath:g.string().optional().describe("Local file path to ingest. Provide this OR content OR url."),url:g.string().optional().describe("URL to fetch and ingest. Provide this OR content OR filePath."),title:g.string().optional().describe("Document title. Auto-detected if not provided."),namespace:g.string().optional().describe("Namespace for the document. Defaults to config default."),sourceType:g.string().optional().describe("Source type label (e.g., docs, code, notes). Auto-detected from format."),skipFacts:g.boolean().optional().default(!1).describe("Skip fact extraction (faster, chunks only)"),skipEntities:g.boolean().optional().default(!1).describe("Skip entity linking")},async({content:e,filePath:r,url:n,title:o,namespace:a,sourceType:i,skipFacts:s,skipEntities:c})=>{let u=await L("ingestDoc",{content:e,filePath:r,url:n,title:o,namespace:a,sourceType:i,skipFacts:s,skipEntities:c}),l=u.skipped?`Document "${u.title}" already up to date \u2014 skipped.`:[`Document "${u.title}" ingested.`,`- Document ID: ${u.documentId}`,`- Chunks: ${u.chunkCount}`,u.facts?`- Facts: ${u.facts.total} extracted (${u.facts.added} new, ${u.facts.skipped} skipped)`:"- Facts: skipped",u.entities?`- Entities: ${u.entities.entityCount}, Relations: ${u.entities.relationCount}`:"- Entities: skipped",u.output?`- Output: ${u.output}`:""].filter(Boolean).join(`
|
|
65
|
+
`);return I(l)})}H();function $a(t){t.tool("remember",`Save one or more standalone facts to the Sigil knowledge base.
|
|
66
66
|
Each fact is classified, embedded, deduped against existing memory, and stored.
|
|
67
67
|
Use when: the user states a durable preference, decision, constraint, or factual claim worth recalling later.
|
|
68
68
|
Pass each distinct fact as its own array element \u2014 don't concatenate unrelated facts into one string.
|
|
69
|
-
Facts are written under the agent provenance "mcp" and survive across sessions.`,{facts:g.array(g.string()).min(1).describe("One or more self-contained facts to remember. Each element is a separate fact."),namespace:g.string().optional().describe("Target namespace. Defaults to the config default namespace.")},async({facts:e,namespace:r})=>{let n=await L("remember",{facts:e,namespace:r}),
|
|
69
|
+
Facts are written under the agent provenance "mcp" and survive across sessions.`,{facts:g.array(g.string()).min(1).describe("One or more self-contained facts to remember. Each element is a separate fact."),namespace:g.string().optional().describe("Target namespace. Defaults to the config default namespace.")},async({facts:e,namespace:r})=>{let n=await L("remember",{facts:e,namespace:r}),o=[];n.added&&o.push(`${n.added} new`),n.updated&&o.push(`${n.updated} updated`),n.alreadyKnown&&o.push(`${n.alreadyKnown} already known`);let a=o.length?o.join(", "):"nothing stored";return I(`Remembered ${e.length} input${e.length===1?"":"s"} \u2192 ${a} (namespace: ${n.namespace}).`)})}H();function Ma(t){t.tool("list_pods",`List memory pods (typed containers segregating facts by source or subject).
|
|
70
70
|
Use for: "what sessions do I have?", "list everyone I have a pod for", "which workspaces?".
|
|
71
71
|
Pod types: session (Claude Code), person (people you have a relationship with),
|
|
72
|
-
project, connector_workspace, custom.`,{type:g.enum(["session","person","project","connector_workspace","custom"]).optional().describe("Filter by pod type. Omit for all types."),namespace:g.string().optional().describe("Namespace. Omit for default."),status:g.enum(["active","archived"]).optional().default("active"),limit:g.number().int().positive().max(100).optional().default(20)},async({type:e,namespace:r,status:n,limit:
|
|
73
|
-
`))})}H();function
|
|
72
|
+
project, connector_workspace, custom.`,{type:g.enum(["session","person","project","connector_workspace","custom"]).optional().describe("Filter by pod type. Omit for all types."),namespace:g.string().optional().describe("Namespace. Omit for default."),status:g.enum(["active","archived"]).optional().default("active"),limit:g.number().int().positive().max(100).optional().default(20)},async({type:e,namespace:r,status:n,limit:o})=>{let{pods:a}=await L("listPods",{type:e,namespace:r,status:n,limit:o});if(!a.length){let s=e?` of type "${e}"`:"";return I(`No${s} pods found.`)}let i=[`Found ${a.length} pod${a.length===1?"":"s"}:`,""];for(let s of a){let c=s.memberFactCount??0,u=s.memberDocCount??0,l=s.updatedAt?new Date(s.updatedAt).toISOString().slice(0,16).replace("T"," "):"\u2014";i.push(`- **${s.name}** (${s.podType}, uid:${s.uid})`),i.push(` facts=${c} docs=${u} updated=${l}`)}return i.push(""),i.push("_Use get_pod(uid=...) for member facts and full metadata._"),I(i.join(`
|
|
73
|
+
`))})}H();function Da(t){t.tool("get_pod",`Get a memory pod with its member facts, documents, and (for person pods)
|
|
74
74
|
the canonical entity link.
|
|
75
75
|
Use for: "what happened in this session?", "show me everything sigil knows
|
|
76
76
|
about Dhaval", "what's in the Slack workspace pod?".
|
|
77
|
-
Returns pod metadata + up to 20 latest facts + up to 10 latest documents.`,{uid:g.string().describe("Pod uid (from list_pods or sigil session current)")},async({uid:e})=>{let r=await L("getPod",{uid:e});if(r.notFound)return
|
|
78
|
-
`))})}H();function
|
|
77
|
+
Returns pod metadata + up to 20 latest facts + up to 10 latest documents.`,{uid:g.string().describe("Pod uid (from list_pods or sigil session current)")},async({uid:e})=>{let r=await L("getPod",{uid:e});if(r.notFound)return I(`Error: pod ${e} not found.`);let{pod:n,facts:o,documents:a}=r,i=[`**${n.name}** (${n.podType}, uid:${n.uid})`,"",`- namespace: ${n.namespace}`,`- status: ${n.status}`];n.startedAt&&i.push(`- started_at: ${n.startedAt}`),n.endedAt&&i.push(`- ended_at: ${n.endedAt}`),n.entityId&&i.push(`- entity_id: ${n.entityId}`),n.connectionId&&i.push(`- connection_id: ${n.connectionId}`),n.externalId&&i.push(`- external_id: ${n.externalId}`);let s=Object.entries(n.attrs||{}).filter(([,c])=>c!=null&&c!=="");if(s.length){i.push("","Attrs:");for(let[c,u]of s){let l=typeof u=="object"?JSON.stringify(u):u;i.push(`- ${c}: ${l}`)}}if(o.length){i.push("",`Member facts (${o.length}, up to 20):`);for(let c of o){let u=te(c.content,bt),l=c.podRole==="mention"?" _[mention]_":"";i.push(`- ${u} (id:${c.id})${l}`)}}if(a.length){i.push("",`Member documents (${a.length}, up to 10):`);for(let c of a){let u=c.title||c.sourcePath||`doc-${c.id}`;i.push(`- ${te(u,80)} (id:${c.id})`)}}return!o.length&&!a.length&&i.push("","_Pod has no member facts or documents yet._"),I(i.join(`
|
|
78
|
+
`))})}H();function za(t){t.tool("prime","Prime your memory for this session \u2014 CALL THIS FIRST, before answering anything.\nThis client has no automatic memory: nothing is recalled or saved for you.\nReturns: Sigil health (DB/providers) + fresh facts about the user and this project.\nIf you skip it, you start with zero knowledge of who the user is or what they're working on.\nAfter priming, still call `search` for specifics and `ingest` to save durable facts.",{limit:g.number().optional().default(12).describe("Max fresh facts to load (default 12)")},async({limit:e}={})=>{let{buildPreamble:r}=await Promise.resolve().then(()=>(Ba(),Ga)),{renderPreamble:n}=await Promise.resolve().then(()=>(Ha(),Fa)),o=await r({cwd:process.cwd(),limit:Number.isFinite(e)?e:12,call:L});return I(n(o,{format:"md",transport:"mcp"}))})}function Va(){let t=new Nd({name:"sigil",version:"0.2.0"});return za(t),Aa(t),ka(t),Ra(t),La(t),Ca(t),Da(t),Ma(t),Na(t),Pa(t),$a(t),t}process.env.SIGIL_AGENT||(process.env.SIGIL_AGENT="mcp");async function Za(){let t=Va(),e=new Pd;await t.connect(e);let{closeDaemonConnection:r}=await Promise.resolve().then(()=>(H(),Oa)),n=()=>{r().catch(()=>{})};return process.on("SIGTERM",n),process.on("SIGINT",n),process.on("beforeExit",n),t}var jd=Ka(Ka(Md(import.meta.url))),Gd=process.env.DOTENV_CONFIG_PATH||(Dd(Mr(process.cwd(),".env"))?Mr(process.cwd(),".env"):null)||Mr(jd,".env");$d({path:Gd,quiet:!0});await Za();
|