opencode-metis 0.2.0 → 0.2.1

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.
@@ -42,7 +42,7 @@
42
42
 
43
43
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let l of this.seen.entries()){let d=l[1];if(e===l[0]){i(l);continue}if(n.external){let m=n.external.registry.get(l[0])?.id;if(e!==l[0]&&m){i(l);continue}}if(this.metadataRegistry.get(l[0])?.id){i(l);continue}if(d.cycle){i(l);continue}if(d.count>1&&n.reused==="ref"){i(l);continue}}let a=(l,d)=>{let h=this.seen.get(l),m=h.def??h.schema,f={...m};if(h.ref===null)return;let p=h.ref;if(h.ref=null,p){a(p,d);let g=this.seen.get(p).schema;g.$ref&&d.target==="draft-7"?(m.allOf=m.allOf??[],m.allOf.push(g)):(Object.assign(m,g),Object.assign(m,f))}h.isParent||this.override({zodSchema:l,jsonSchema:m,path:h.path??[]})};for(let l of[...this.seen.entries()].reverse())a(l[0],{target:this.target});let c={};if(this.target==="draft-2020-12"?c.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?c.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),n.external?.uri){let l=n.external.registry.get(e)?.id;if(!l)throw new Error("Schema is missing an `id` property");c.$id=n.external.uri(l)}Object.assign(c,o.def);let u=n.external?.defs??{};for(let l of this.seen.entries()){let d=l[1];d.def&&d.defId&&(u[d.defId]=d.def)}n.external||Object.keys(u).length>0&&(this.target==="draft-2020-12"?c.$defs=u:c.definitions=u);try{return JSON.parse(JSON.stringify(c))}catch{throw new Error("Error converting schema to JSON.")}}};function Ml(t,e){if(t instanceof Bo){let n=new Oi(e),o={};for(let a of t._idmap.entries()){let[c,u]=a;n.process(u)}let s={},i={registry:t,uri:e?.uri,defs:o};for(let a of t._idmap.entries()){let[c,u]=a;s[c]=n.emit(u,{...e,external:i})}if(Object.keys(o).length>0){let a=n.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[a]:o}}return{schemas:s}}let r=new Oi(e);return r.process(t),r.emit(t,e)}function Oe(t,e){let r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);let o=t._zod.def;switch(o.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":return!1;case"array":return Oe(o.element,r);case"object":{for(let s in o.shape)if(Oe(o.shape[s],r))return!0;return!1}case"union":{for(let s of o.options)if(Oe(s,r))return!0;return!1}case"intersection":return Oe(o.left,r)||Oe(o.right,r);case"tuple":{for(let s of o.items)if(Oe(s,r))return!0;return!!(o.rest&&Oe(o.rest,r))}case"record":return Oe(o.keyType,r)||Oe(o.valueType,r);case"map":return Oe(o.keyType,r)||Oe(o.valueType,r);case"set":return Oe(o.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return Oe(o.innerType,r);case"lazy":return Oe(o.getter(),r);case"default":return Oe(o.innerType,r);case"prefault":return Oe(o.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return Oe(o.in,r)||Oe(o.out,r);case"success":return!1;case"catch":return!1;default:}throw new Error(`Unknown schema type: ${o.type}`)}var Wo={};qc(Wo,{ZodISODate:()=>yg,ZodISODateTime:()=>gg,ZodISODuration:()=>vg,ZodISOTime:()=>_g,date:()=>Zl,datetime:()=>Al,duration:()=>Dl,time:()=>ql});var gg=b("ZodISODateTime",(t,e)=>{ng.init(t,e),xe.init(t,e)});function Al(t){return lg(gg,t)}var yg=b("ZodISODate",(t,e)=>{og.init(t,e),xe.init(t,e)});function Zl(t){return dg(yg,t)}var _g=b("ZodISOTime",(t,e)=>{sg.init(t,e),xe.init(t,e)});function ql(t){return fg(_g,t)}var vg=b("ZodISODuration",(t,e)=>{ig.init(t,e),xe.init(t,e)});function Dl(t){return pg(vg,t)}var $g=(t,e)=>{vi.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>Yc(t,r)},flatten:{value:r=>Xc(t,r)},addIssue:{value:r=>t.issues.push(r)},addIssues:{value:r=>t.issues.push(...r)},isEmpty:{get(){return t.issues.length===0}}})},rZ=b("ZodError",$g),Xo=b("ZodError",$g,{Parent:Error});var bg=Qc(Xo),wg=tu(Xo),xg=nu(Xo),kg=ou(Xo);var ze=b("ZodType",(t,e)=>(le.init(t,e),t.def=e,Object.defineProperty(t,"_def",{value:e}),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>gt(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t)),t.parse=(r,n)=>bg(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>xg(t,r,n),t.parseAsync=async(r,n)=>wg(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>kg(t,r,n),t.spa=t.safeParseAsync,t.refine=(r,n)=>t.check(gk(r,n)),t.superRefine=r=>t.check(yk(r)),t.overwrite=r=>t.check(Qr(r)),t.optional=()=>Ee(t),t.nullable=()=>Eg(t),t.nullish=()=>Ee(Eg(t)),t.nonoptional=r=>uk(t,r),t.array=()=>Q(t),t.or=r=>_e([t,r]),t.and=r=>ji(t,r),t.transform=r=>Vl(t,Og(r)),t.default=r=>ik(t,r),t.prefault=r=>ck(t,r),t.catch=r=>dk(t,r),t.pipe=r=>Vl(t,r),t.readonly=()=>mk(t),t.describe=r=>{let n=t.clone();return $r.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return $r.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return $r.get(t);let n=t.clone();return $r.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),zg=b("_ZodString",(t,e)=>{Ko.init(t,e),ze.init(t,e);let r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,t.regex=(...n)=>t.check(kl(...n)),t.includes=(...n)=>t.check(El(...n)),t.startsWith=(...n)=>t.check(zl(...n)),t.endsWith=(...n)=>t.check(Tl(...n)),t.min=(...n)=>t.check(Ln(...n)),t.max=(...n)=>t.check(Ri(...n)),t.length=(...n)=>t.check(Ii(...n)),t.nonempty=(...n)=>t.check(Ln(1,...n)),t.lowercase=n=>t.check(Sl(n)),t.uppercase=n=>t.check(Pl(n)),t.trim=()=>t.check(Il()),t.normalize=(...n)=>t.check(Rl(...n)),t.toLowerCase=()=>t.check(Ol()),t.toUpperCase=()=>t.check(Nl())}),zx=b("ZodString",(t,e)=>{Ko.init(t,e),zg.init(t,e),t.email=r=>t.check(Xu(Tx,r)),t.url=r=>t.check(rl(Rx,r)),t.jwt=r=>t.check(yl(Hx,r)),t.emoji=r=>t.check(nl(Ix,r)),t.guid=r=>t.check(Pi(Sg,r)),t.uuid=r=>t.check(Yu(Ni,r)),t.uuidv4=r=>t.check(Qu(Ni,r)),t.uuidv6=r=>t.check(el(Ni,r)),t.uuidv7=r=>t.check(tl(Ni,r)),t.nanoid=r=>t.check(ol(Ox,r)),t.guid=r=>t.check(Pi(Sg,r)),t.cuid=r=>t.check(sl(Nx,r)),t.cuid2=r=>t.check(il(jx,r)),t.ulid=r=>t.check(al(Cx,r)),t.base64=r=>t.check(ml(Vx,r)),t.base64url=r=>t.check(hl(Ux,r)),t.xid=r=>t.check(cl(Mx,r)),t.ksuid=r=>t.check(ul(Ax,r)),t.ipv4=r=>t.check(ll(Zx,r)),t.ipv6=r=>t.check(dl(qx,r)),t.cidrv4=r=>t.check(fl(Dx,r)),t.cidrv6=r=>t.check(pl(Lx,r)),t.e164=r=>t.check(gl(Fx,r)),t.datetime=r=>t.check(Al(r)),t.date=r=>t.check(Zl(r)),t.time=r=>t.check(ql(r)),t.duration=r=>t.check(Dl(r))});function v(t){return Wu(zx,t)}var xe=b("ZodStringFormat",(t,e)=>{ye.init(t,e),zg.init(t,e)}),Tx=b("ZodEmail",(t,e)=>{fu.init(t,e),xe.init(t,e)});var Sg=b("ZodGUID",(t,e)=>{lu.init(t,e),xe.init(t,e)});var Ni=b("ZodUUID",(t,e)=>{du.init(t,e),xe.init(t,e)});var Rx=b("ZodURL",(t,e)=>{pu.init(t,e),xe.init(t,e)});var Ix=b("ZodEmoji",(t,e)=>{mu.init(t,e),xe.init(t,e)});var Ox=b("ZodNanoID",(t,e)=>{hu.init(t,e),xe.init(t,e)});var Nx=b("ZodCUID",(t,e)=>{gu.init(t,e),xe.init(t,e)});var jx=b("ZodCUID2",(t,e)=>{yu.init(t,e),xe.init(t,e)});var Cx=b("ZodULID",(t,e)=>{_u.init(t,e),xe.init(t,e)});var Mx=b("ZodXID",(t,e)=>{vu.init(t,e),xe.init(t,e)});var Ax=b("ZodKSUID",(t,e)=>{$u.init(t,e),xe.init(t,e)});var Zx=b("ZodIPv4",(t,e)=>{bu.init(t,e),xe.init(t,e)});var qx=b("ZodIPv6",(t,e)=>{wu.init(t,e),xe.init(t,e)});var Dx=b("ZodCIDRv4",(t,e)=>{xu.init(t,e),xe.init(t,e)});var Lx=b("ZodCIDRv6",(t,e)=>{ku.init(t,e),xe.init(t,e)});var Vx=b("ZodBase64",(t,e)=>{Su.init(t,e),xe.init(t,e)});var Ux=b("ZodBase64URL",(t,e)=>{Pu.init(t,e),xe.init(t,e)});var Fx=b("ZodE164",(t,e)=>{Eu.init(t,e),xe.init(t,e)});var Hx=b("ZodJWT",(t,e)=>{zu.init(t,e),xe.init(t,e)});var Tg=b("ZodNumber",(t,e)=>{xi.init(t,e),ze.init(t,e),t.gt=(n,o)=>t.check(zi(n,o)),t.gte=(n,o)=>t.check(Jo(n,o)),t.min=(n,o)=>t.check(Jo(n,o)),t.lt=(n,o)=>t.check(Ei(n,o)),t.lte=(n,o)=>t.check(Go(n,o)),t.max=(n,o)=>t.check(Go(n,o)),t.int=n=>t.check(Pg(n)),t.safe=n=>t.check(Pg(n)),t.positive=n=>t.check(zi(0,n)),t.nonnegative=n=>t.check(Jo(0,n)),t.negative=n=>t.check(Ei(0,n)),t.nonpositive=n=>t.check(Go(0,n)),t.multipleOf=(n,o)=>t.check(Ti(n,o)),t.step=(n,o)=>t.check(Ti(n,o)),t.finite=()=>t;let r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null});function ue(t){return _l(Tg,t)}var Kx=b("ZodNumberFormat",(t,e)=>{Tu.init(t,e),Tg.init(t,e)});function Pg(t){return vl(Kx,t)}var Bx=b("ZodBoolean",(t,e)=>{Ru.init(t,e),ze.init(t,e)});function je(t){return $l(Bx,t)}var Gx=b("ZodNull",(t,e)=>{Iu.init(t,e),ze.init(t,e)});function Ul(t){return bl(Gx,t)}var Jx=b("ZodUnknown",(t,e)=>{Ou.init(t,e),ze.init(t,e)});function ke(){return wl(Jx)}var Wx=b("ZodNever",(t,e)=>{Nu.init(t,e),ze.init(t,e)});function Xx(t){return xl(Wx,t)}var Yx=b("ZodArray",(t,e)=>{ju.init(t,e),ze.init(t,e),t.element=e.element,t.min=(r,n)=>t.check(Ln(r,n)),t.nonempty=r=>t.check(Ln(1,r)),t.max=(r,n)=>t.check(Ri(r,n)),t.length=(r,n)=>t.check(Ii(r,n)),t.unwrap=()=>t.element});function Q(t,e){return mg(Yx,t,e)}var Rg=b("ZodObject",(t,e)=>{ki.init(t,e),ze.init(t,e),Y.defineLazy(t,"shape",()=>e.shape),t.keyof=()=>nt(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:ke()}),t.loose=()=>t.clone({...t._zod.def,catchall:ke()}),t.strict=()=>t.clone({...t._zod.def,catchall:Xx()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>Y.extend(t,r),t.merge=r=>Y.merge(t,r),t.pick=r=>Y.pick(t,r),t.omit=r=>Y.omit(t,r),t.partial=(...r)=>Y.partial(Ng,t,r[0]),t.required=(...r)=>Y.required(jg,t,r[0])});function T(t,e){let r={type:"object",get shape(){return Y.assignProp(this,"shape",{...t}),this.shape},...Y.normalizeParams(e)};return new Rg(r)}function Xe(t,e){return new Rg({type:"object",get shape(){return Y.assignProp(this,"shape",{...t}),this.shape},catchall:ke(),...Y.normalizeParams(e)})}var Ig=b("ZodUnion",(t,e)=>{Si.init(t,e),ze.init(t,e),t.options=e.options});function _e(t,e){return new Ig({type:"union",options:t,...Y.normalizeParams(e)})}var Qx=b("ZodDiscriminatedUnion",(t,e)=>{Ig.init(t,e),Cu.init(t,e)});function Fl(t,e,r){return new Qx({type:"union",options:e,discriminator:t,...Y.normalizeParams(r)})}var ek=b("ZodIntersection",(t,e)=>{Mu.init(t,e),ze.init(t,e)});function ji(t,e){return new ek({type:"intersection",left:t,right:e})}var tk=b("ZodRecord",(t,e)=>{Au.init(t,e),ze.init(t,e),t.keyType=e.keyType,t.valueType=e.valueType});function Se(t,e,r){return new tk({type:"record",keyType:t,valueType:e,...Y.normalizeParams(r)})}var Ll=b("ZodEnum",(t,e)=>{Zu.init(t,e),ze.init(t,e),t.enum=e.entries,t.options=Object.values(e.entries);let r=new Set(Object.keys(e.entries));t.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Ll({...e,checks:[],...Y.normalizeParams(o),entries:s})},t.exclude=(n,o)=>{let s={...e.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new Ll({...e,checks:[],...Y.normalizeParams(o),entries:s})}});function nt(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new Ll({type:"enum",entries:r,...Y.normalizeParams(e)})}var rk=b("ZodLiteral",(t,e)=>{qu.init(t,e),ze.init(t,e),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function O(t,e){return new rk({type:"literal",values:Array.isArray(t)?t:[t],...Y.normalizeParams(e)})}var nk=b("ZodTransform",(t,e)=>{Du.init(t,e),ze.init(t,e),t._zod.parse=(r,n)=>{r.addIssue=s=>{if(typeof s=="string")r.issues.push(Y.issue(s,r.value,e));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=t),i.continue??(i.continue=!0),r.issues.push(Y.issue(i))}};let o=e.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function Og(t){return new nk({type:"transform",transform:t})}var Ng=b("ZodOptional",(t,e)=>{Lu.init(t,e),ze.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Ee(t){return new Ng({type:"optional",innerType:t})}var ok=b("ZodNullable",(t,e)=>{Vu.init(t,e),ze.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Eg(t){return new ok({type:"nullable",innerType:t})}var sk=b("ZodDefault",(t,e)=>{Uu.init(t,e),ze.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function ik(t,e){return new sk({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var ak=b("ZodPrefault",(t,e)=>{Fu.init(t,e),ze.init(t,e),t.unwrap=()=>t._zod.def.innerType});function ck(t,e){return new ak({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var jg=b("ZodNonOptional",(t,e)=>{Hu.init(t,e),ze.init(t,e),t.unwrap=()=>t._zod.def.innerType});function uk(t,e){return new jg({type:"nonoptional",innerType:t,...Y.normalizeParams(e)})}var lk=b("ZodCatch",(t,e)=>{Ku.init(t,e),ze.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function dk(t,e){return new lk({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var fk=b("ZodPipe",(t,e)=>{Bu.init(t,e),ze.init(t,e),t.in=e.in,t.out=e.out});function Vl(t,e){return new fk({type:"pipe",in:t,out:e})}var pk=b("ZodReadonly",(t,e)=>{Gu.init(t,e),ze.init(t,e)});function mk(t){return new pk({type:"readonly",innerType:t})}var Cg=b("ZodCustom",(t,e)=>{Ju.init(t,e),ze.init(t,e)});function hk(t){let e=new Ce({check:"custom"});return e._zod.check=t,e}function Mg(t,e){return jl(Cg,t??(()=>!0),e)}function gk(t,e={}){return Cl(Cg,t,e)}function yk(t){let e=hk(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(Y.issue(n,r.value,e._zod.def));else{let o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=e),o.continue??(o.continue=!e._zod.def.abort),r.issues.push(Y.issue(o))}},t(r.value,r)));return e}function Hl(t,e){return Vl(Og(t),e)}ht(cg());var Bl="2025-11-25";var Ag=[Bl,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],br="io.modelcontextprotocol/related-task",Mi="2.0",Me=Mg(t=>t!==null&&(typeof t=="object"||typeof t=="function")),Zg=_e([v(),ue().int()]),qg=v(),gZ=Xe({ttl:_e([ue(),Ul()]).optional(),pollInterval:ue().optional()}),_k=T({ttl:ue().optional()}),vk=T({taskId:v()}),Gl=Xe({progressToken:Zg.optional(),[br]:vk.optional()}),yt=T({_meta:Gl.optional()}),Yo=yt.extend({task:_k.optional()}),Dg=t=>Yo.safeParse(t).success,Ae=T({method:v(),params:yt.loose().optional()}),_t=T({_meta:Gl.optional()}),vt=T({method:v(),params:_t.loose().optional()}),Ze=Xe({_meta:Gl.optional()}),Ai=_e([v(),ue().int()]),Lg=T({jsonrpc:O(Mi),id:Ai,...Ae.shape}).strict(),Jl=t=>Lg.safeParse(t).success,Vg=T({jsonrpc:O(Mi),...vt.shape}).strict(),Ug=t=>Vg.safeParse(t).success,Wl=T({jsonrpc:O(Mi),id:Ai,result:Ze}).strict(),Qo=t=>Wl.safeParse(t).success;var C;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(C||(C={}));var Xl=T({jsonrpc:O(Mi),id:Ai.optional(),error:T({code:ue().int(),message:v(),data:ke().optional()})}).strict();var Fg=t=>Xl.safeParse(t).success;var Hg=_e([Lg,Vg,Wl,Xl]),yZ=_e([Wl,Xl]),Zi=Ze.strict(),$k=_t.extend({requestId:Ai.optional(),reason:v().optional()}),qi=vt.extend({method:O("notifications/cancelled"),params:$k}),bk=T({src:v(),mimeType:v().optional(),sizes:Q(v()).optional(),theme:nt(["light","dark"]).optional()}),es=T({icons:Q(bk).optional()}),Vn=T({name:v(),title:v().optional()}),Kg=Vn.extend({...Vn.shape,...es.shape,version:v(),websiteUrl:v().optional(),description:v().optional()}),wk=ji(T({applyDefaults:je().optional()}),Se(v(),ke())),xk=Hl(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,ji(T({form:wk.optional(),url:Me.optional()}),Se(v(),ke()).optional())),kk=Xe({list:Me.optional(),cancel:Me.optional(),requests:Xe({sampling:Xe({createMessage:Me.optional()}).optional(),elicitation:Xe({create:Me.optional()}).optional()}).optional()}),Sk=Xe({list:Me.optional(),cancel:Me.optional(),requests:Xe({tools:Xe({call:Me.optional()}).optional()}).optional()}),Pk=T({experimental:Se(v(),Me).optional(),sampling:T({context:Me.optional(),tools:Me.optional()}).optional(),elicitation:xk.optional(),roots:T({listChanged:je().optional()}).optional(),tasks:kk.optional()}),Ek=yt.extend({protocolVersion:v(),capabilities:Pk,clientInfo:Kg}),Yl=Ae.extend({method:O("initialize"),params:Ek});var zk=T({experimental:Se(v(),Me).optional(),logging:Me.optional(),completions:Me.optional(),prompts:T({listChanged:je().optional()}).optional(),resources:T({subscribe:je().optional(),listChanged:je().optional()}).optional(),tools:T({listChanged:je().optional()}).optional(),tasks:Sk.optional()}),Tk=Ze.extend({protocolVersion:v(),capabilities:zk,serverInfo:Kg,instructions:v().optional()}),Ql=vt.extend({method:O("notifications/initialized"),params:_t.optional()});var Di=Ae.extend({method:O("ping"),params:yt.optional()}),Rk=T({progress:ue(),total:Ee(ue()),message:Ee(v())}),Ik=T({..._t.shape,...Rk.shape,progressToken:Zg}),Li=vt.extend({method:O("notifications/progress"),params:Ik}),Ok=yt.extend({cursor:qg.optional()}),ts=Ae.extend({params:Ok.optional()}),rs=Ze.extend({nextCursor:qg.optional()}),Nk=nt(["working","input_required","completed","failed","cancelled"]),ns=T({taskId:v(),status:Nk,ttl:_e([ue(),Ul()]),createdAt:v(),lastUpdatedAt:v(),pollInterval:Ee(ue()),statusMessage:Ee(v())}),Un=Ze.extend({task:ns}),jk=_t.merge(ns),os=vt.extend({method:O("notifications/tasks/status"),params:jk}),Vi=Ae.extend({method:O("tasks/get"),params:yt.extend({taskId:v()})}),Ui=Ze.merge(ns),Fi=Ae.extend({method:O("tasks/result"),params:yt.extend({taskId:v()})}),_Z=Ze.loose(),Hi=ts.extend({method:O("tasks/list")}),Ki=rs.extend({tasks:Q(ns)}),Bi=Ae.extend({method:O("tasks/cancel"),params:yt.extend({taskId:v()})}),Bg=Ze.merge(ns),Gg=T({uri:v(),mimeType:Ee(v()),_meta:Se(v(),ke()).optional()}),Jg=Gg.extend({text:v()}),ed=v().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),Wg=Gg.extend({blob:ed}),ss=nt(["user","assistant"]),Fn=T({audience:Q(ss).optional(),priority:ue().min(0).max(1).optional(),lastModified:Wo.datetime({offset:!0}).optional()}),Xg=T({...Vn.shape,...es.shape,uri:v(),description:Ee(v()),mimeType:Ee(v()),annotations:Fn.optional(),_meta:Ee(Xe({}))}),Ck=T({...Vn.shape,...es.shape,uriTemplate:v(),description:Ee(v()),mimeType:Ee(v()),annotations:Fn.optional(),_meta:Ee(Xe({}))}),Gi=ts.extend({method:O("resources/list")}),Mk=rs.extend({resources:Q(Xg)}),Ji=ts.extend({method:O("resources/templates/list")}),Ak=rs.extend({resourceTemplates:Q(Ck)}),td=yt.extend({uri:v()}),Zk=td,Wi=Ae.extend({method:O("resources/read"),params:Zk}),qk=Ze.extend({contents:Q(_e([Jg,Wg]))}),Dk=vt.extend({method:O("notifications/resources/list_changed"),params:_t.optional()}),Lk=td,Vk=Ae.extend({method:O("resources/subscribe"),params:Lk}),Uk=td,Fk=Ae.extend({method:O("resources/unsubscribe"),params:Uk}),Hk=_t.extend({uri:v()}),Kk=vt.extend({method:O("notifications/resources/updated"),params:Hk}),Bk=T({name:v(),description:Ee(v()),required:Ee(je())}),Gk=T({...Vn.shape,...es.shape,description:Ee(v()),arguments:Ee(Q(Bk)),_meta:Ee(Xe({}))}),Xi=ts.extend({method:O("prompts/list")}),Jk=rs.extend({prompts:Q(Gk)}),Wk=yt.extend({name:v(),arguments:Se(v(),v()).optional()}),Yi=Ae.extend({method:O("prompts/get"),params:Wk}),rd=T({type:O("text"),text:v(),annotations:Fn.optional(),_meta:Se(v(),ke()).optional()}),nd=T({type:O("image"),data:ed,mimeType:v(),annotations:Fn.optional(),_meta:Se(v(),ke()).optional()}),od=T({type:O("audio"),data:ed,mimeType:v(),annotations:Fn.optional(),_meta:Se(v(),ke()).optional()}),Xk=T({type:O("tool_use"),name:v(),id:v(),input:Se(v(),ke()),_meta:Se(v(),ke()).optional()}),Yk=T({type:O("resource"),resource:_e([Jg,Wg]),annotations:Fn.optional(),_meta:Se(v(),ke()).optional()}),Qk=Xg.extend({type:O("resource_link")}),sd=_e([rd,nd,od,Qk,Yk]),eS=T({role:ss,content:sd}),tS=Ze.extend({description:v().optional(),messages:Q(eS)}),rS=vt.extend({method:O("notifications/prompts/list_changed"),params:_t.optional()}),nS=T({title:v().optional(),readOnlyHint:je().optional(),destructiveHint:je().optional(),idempotentHint:je().optional(),openWorldHint:je().optional()}),oS=T({taskSupport:nt(["required","optional","forbidden"]).optional()}),Yg=T({...Vn.shape,...es.shape,description:v().optional(),inputSchema:T({type:O("object"),properties:Se(v(),Me).optional(),required:Q(v()).optional()}).catchall(ke()),outputSchema:T({type:O("object"),properties:Se(v(),Me).optional(),required:Q(v()).optional()}).catchall(ke()).optional(),annotations:nS.optional(),execution:oS.optional(),_meta:Se(v(),ke()).optional()}),Qi=ts.extend({method:O("tools/list")}),sS=rs.extend({tools:Q(Yg)}),ea=Ze.extend({content:Q(sd).default([]),structuredContent:Se(v(),ke()).optional(),isError:je().optional()}),vZ=ea.or(Ze.extend({toolResult:ke()})),iS=Yo.extend({name:v(),arguments:Se(v(),ke()).optional()}),Hn=Ae.extend({method:O("tools/call"),params:iS}),aS=vt.extend({method:O("notifications/tools/list_changed"),params:_t.optional()}),$Z=T({autoRefresh:je().default(!0),debounceMs:ue().int().nonnegative().default(300)}),is=nt(["debug","info","notice","warning","error","critical","alert","emergency"]),cS=yt.extend({level:is}),id=Ae.extend({method:O("logging/setLevel"),params:cS}),uS=_t.extend({level:is,logger:v().optional(),data:ke()}),lS=vt.extend({method:O("notifications/message"),params:uS}),dS=T({name:v().optional()}),fS=T({hints:Q(dS).optional(),costPriority:ue().min(0).max(1).optional(),speedPriority:ue().min(0).max(1).optional(),intelligencePriority:ue().min(0).max(1).optional()}),pS=T({mode:nt(["auto","required","none"]).optional()}),mS=T({type:O("tool_result"),toolUseId:v().describe("The unique identifier for the corresponding tool call."),content:Q(sd).default([]),structuredContent:T({}).loose().optional(),isError:je().optional(),_meta:Se(v(),ke()).optional()}),hS=Fl("type",[rd,nd,od]),Ci=Fl("type",[rd,nd,od,Xk,mS]),gS=T({role:ss,content:_e([Ci,Q(Ci)]),_meta:Se(v(),ke()).optional()}),yS=Yo.extend({messages:Q(gS),modelPreferences:fS.optional(),systemPrompt:v().optional(),includeContext:nt(["none","thisServer","allServers"]).optional(),temperature:ue().optional(),maxTokens:ue().int(),stopSequences:Q(v()).optional(),metadata:Me.optional(),tools:Q(Yg).optional(),toolChoice:pS.optional()}),_S=Ae.extend({method:O("sampling/createMessage"),params:yS}),ad=Ze.extend({model:v(),stopReason:Ee(nt(["endTurn","stopSequence","maxTokens"]).or(v())),role:ss,content:hS}),cd=Ze.extend({model:v(),stopReason:Ee(nt(["endTurn","stopSequence","maxTokens","toolUse"]).or(v())),role:ss,content:_e([Ci,Q(Ci)])}),vS=T({type:O("boolean"),title:v().optional(),description:v().optional(),default:je().optional()}),$S=T({type:O("string"),title:v().optional(),description:v().optional(),minLength:ue().optional(),maxLength:ue().optional(),format:nt(["email","uri","date","date-time"]).optional(),default:v().optional()}),bS=T({type:nt(["number","integer"]),title:v().optional(),description:v().optional(),minimum:ue().optional(),maximum:ue().optional(),default:ue().optional()}),wS=T({type:O("string"),title:v().optional(),description:v().optional(),enum:Q(v()),default:v().optional()}),xS=T({type:O("string"),title:v().optional(),description:v().optional(),oneOf:Q(T({const:v(),title:v()})),default:v().optional()}),kS=T({type:O("string"),title:v().optional(),description:v().optional(),enum:Q(v()),enumNames:Q(v()).optional(),default:v().optional()}),SS=_e([wS,xS]),PS=T({type:O("array"),title:v().optional(),description:v().optional(),minItems:ue().optional(),maxItems:ue().optional(),items:T({type:O("string"),enum:Q(v())}),default:Q(v()).optional()}),ES=T({type:O("array"),title:v().optional(),description:v().optional(),minItems:ue().optional(),maxItems:ue().optional(),items:T({anyOf:Q(T({const:v(),title:v()}))}),default:Q(v()).optional()}),zS=_e([PS,ES]),TS=_e([kS,SS,zS]),RS=_e([TS,vS,$S,bS]),IS=Yo.extend({mode:O("form").optional(),message:v(),requestedSchema:T({type:O("object"),properties:Se(v(),RS),required:Q(v()).optional()})}),OS=Yo.extend({mode:O("url"),message:v(),elicitationId:v(),url:v().url()}),NS=_e([IS,OS]),jS=Ae.extend({method:O("elicitation/create"),params:NS}),CS=_t.extend({elicitationId:v()}),MS=vt.extend({method:O("notifications/elicitation/complete"),params:CS}),ta=Ze.extend({action:nt(["accept","decline","cancel"]),content:Hl(t=>t===null?void 0:t,Se(v(),_e([v(),ue(),je(),Q(v())])).optional())}),AS=T({type:O("ref/resource"),uri:v()});var ZS=T({type:O("ref/prompt"),name:v()}),qS=yt.extend({ref:_e([ZS,AS]),argument:T({name:v(),value:v()}),context:T({arguments:Se(v(),v()).optional()}).optional()}),ra=Ae.extend({method:O("completion/complete"),params:qS});function Qg(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function ey(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}var DS=Ze.extend({completion:Xe({values:Q(v()).max(100),total:Ee(ue().int()),hasMore:Ee(je())})}),LS=T({uri:v().startsWith("file://"),name:v().optional(),_meta:Se(v(),ke()).optional()}),VS=Ae.extend({method:O("roots/list"),params:yt.optional()}),ud=Ze.extend({roots:Q(LS)}),US=vt.extend({method:O("notifications/roots/list_changed"),params:_t.optional()}),bZ=_e([Di,Yl,ra,id,Yi,Xi,Gi,Ji,Wi,Vk,Fk,Hn,Qi,Vi,Fi,Hi,Bi]),wZ=_e([qi,Li,Ql,US,os]),xZ=_e([Zi,ad,cd,ta,ud,Ui,Ki,Un]),kZ=_e([Di,_S,jS,VS,Vi,Fi,Hi,Bi]),SZ=_e([qi,Li,lS,Kk,Dk,aS,rS,os,MS]),PZ=_e([Zi,Tk,DS,tS,Jk,Mk,Ak,qk,ea,sS,Ui,Ki,Un]),I=class t extends Error{constructor(e,r,n){super(`MCP error ${e}: ${r}`),this.code=e,this.data=n,this.name="McpError"}static fromError(e,r,n){if(e===C.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new Kl(o.elicitations,r)}return new t(e,r,n)}},Kl=class extends I{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(C.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};var na=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
44
44
  `);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),FS(r)}clear(){this._buffer=void 0}};function FS(t){return Hg.parse(JSON.parse(t))}function ty(t){return JSON.stringify(t)+`
45
- `}var oa=class{constructor(e=ld.default.stdin,r=ld.default.stdout){this._stdin=e,this._stdout=r,this._readBuffer=new na,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(r=>{let n=ty(e);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};var sa=class{constructor(e,r=null){this.workerUrl=e;this.authToken=r}buildHeaders(e){let r={...e};return this.authToken&&(r.Authorization=`Bearer ${this.authToken}`),r}async search(e){let r=new URL("/api/search",this.workerUrl);return r.searchParams.set("query",e.query),e.limit!==void 0&&r.searchParams.set("limit",String(e.limit)),e.type!==void 0&&r.searchParams.set("type",e.type),e.project!==void 0&&r.searchParams.set("project",e.project),this.get(r)}async timeline(e){let r=new URL("/api/timeline",this.workerUrl);return r.searchParams.set("anchor",e.anchor),e.depth_before!==void 0&&r.searchParams.set("depth_before",String(e.depth_before)),e.depth_after!==void 0&&r.searchParams.set("depth_after",String(e.depth_after)),this.get(r)}async getObservations(e){return this.post("/api/observations/batch",{ids:e.ids})}async saveMemory(e){let r={text:e.text};return e.title!==void 0&&(r.title=e.title),e.project!==void 0&&(r.project=e.project),this.post("/api/memory/save",r)}async isWorkerAvailable(){try{return(await fetch(`${this.workerUrl}/api/health`,{signal:AbortSignal.timeout(15e3)})).ok}catch{return!1}}async get(e){let r=await fetch(e.toString(),{method:"GET",headers:this.buildHeaders(),signal:AbortSignal.timeout(15e3)});if(!r.ok){let n=await r.text().catch(()=>"");throw new Error(`Worker returned ${r.status}: ${n}`)}return r.json()}async post(e,r){let n=await fetch(`${this.workerUrl}${e}`,{method:"POST",headers:this.buildHeaders({"Content-Type":"application/json"}),body:JSON.stringify(r),signal:AbortSignal.timeout(15e3)});if(!n.ok){let o=await n.text().catch(()=>"");throw new Error(`Worker returned ${n.status}: ${o}`)}return n.json()}};var Ne={};qc(Ne,{BRAND:()=>gP,DIRTY:()=>tn,EMPTY_PATH:()=>GS,INVALID:()=>A,NEVER:()=>QP,OK:()=>Fe,ParseStatus:()=>qe,Schema:()=>F,ZodAny:()=>kr,ZodArray:()=>ur,ZodBigInt:()=>nn,ZodBoolean:()=>on,ZodBranded:()=>cs,ZodCatch:()=>gn,ZodDate:()=>sn,ZodDefault:()=>hn,ZodDiscriminatedUnion:()=>ca,ZodEffects:()=>bt,ZodEnum:()=>pn,ZodError:()=>ot,ZodFirstPartyTypeKind:()=>S,ZodFunction:()=>la,ZodIntersection:()=>ln,ZodIssueCode:()=>x,ZodLazy:()=>dn,ZodLiteral:()=>fn,ZodMap:()=>Xn,ZodNaN:()=>Qn,ZodNativeEnum:()=>mn,ZodNever:()=>Nt,ZodNull:()=>cn,ZodNullable:()=>Jt,ZodNumber:()=>rn,ZodObject:()=>it,ZodOptional:()=>st,ZodParsedType:()=>z,ZodPipeline:()=>us,ZodPromise:()=>Sr,ZodReadonly:()=>yn,ZodRecord:()=>ua,ZodSchema:()=>F,ZodSet:()=>Yn,ZodString:()=>xr,ZodSymbol:()=>Jn,ZodTransformer:()=>bt,ZodTuple:()=>Gt,ZodType:()=>F,ZodUndefined:()=>an,ZodUnion:()=>un,ZodUnknown:()=>cr,ZodVoid:()=>Wn,addIssueToContext:()=>E,any:()=>SP,array:()=>TP,bigint:()=>$P,boolean:()=>fy,coerce:()=>YP,custom:()=>uy,date:()=>bP,datetimeRegex:()=>ay,defaultErrorMap:()=>ir,discriminatedUnion:()=>OP,effect:()=>FP,enum:()=>LP,function:()=>ZP,getErrorMap:()=>Kn,getParsedType:()=>Bt,instanceof:()=>_P,intersection:()=>NP,isAborted:()=>ia,isAsync:()=>Bn,isDirty:()=>aa,isValid:()=>wr,late:()=>yP,lazy:()=>qP,literal:()=>DP,makeIssue:()=>as,map:()=>MP,nan:()=>vP,nativeEnum:()=>VP,never:()=>EP,null:()=>kP,nullable:()=>KP,number:()=>dy,object:()=>md,objectUtil:()=>dd,oboolean:()=>XP,onumber:()=>WP,optional:()=>HP,ostring:()=>JP,pipeline:()=>GP,preprocess:()=>BP,promise:()=>UP,quotelessJson:()=>HS,record:()=>CP,set:()=>AP,setErrorMap:()=>BS,strictObject:()=>RP,string:()=>ly,symbol:()=>wP,transformer:()=>FP,tuple:()=>jP,undefined:()=>xP,union:()=>IP,unknown:()=>PP,util:()=>X,void:()=>zP});var X;(function(t){t.assertEqual=o=>{};function e(o){}t.assertIs=e;function r(o){throw new Error}t.assertNever=r,t.arrayToEnum=o=>{let s={};for(let i of o)s[i]=i;return s},t.getValidEnumValues=o=>{let s=t.objectKeys(o).filter(a=>typeof o[o[a]]!="number"),i={};for(let a of s)i[a]=o[a];return t.objectValues(i)},t.objectValues=o=>t.objectKeys(o).map(function(s){return o[s]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let s=[];for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&s.push(i);return s},t.find=(o,s)=>{for(let i of o)if(s(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,s=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(s)}t.joinValues=n,t.jsonStringifyReplacer=(o,s)=>typeof s=="bigint"?s.toString():s})(X||(X={}));var dd;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(dd||(dd={}));var z=X.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Bt=t=>{switch(typeof t){case"undefined":return z.undefined;case"string":return z.string;case"number":return Number.isNaN(t)?z.nan:z.number;case"boolean":return z.boolean;case"function":return z.function;case"bigint":return z.bigint;case"symbol":return z.symbol;case"object":return Array.isArray(t)?z.array:t===null?z.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?z.promise:typeof Map<"u"&&t instanceof Map?z.map:typeof Set<"u"&&t instanceof Set?z.set:typeof Date<"u"&&t instanceof Date?z.date:z.object;default:return z.unknown}};var x=X.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"]),HS=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),ot=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(s){return s.message},n={_errors:[]},o=s=>{for(let i of s.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 a=n,c=0;for(;c<i.path.length;){let u=i.path[c];c===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(i))):a[u]=a[u]||{_errors:[]},a=a[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,X.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 s=o.path[0];r[s]=r[s]||[],r[s].push(e(o))}else n.push(e(o));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};ot.create=t=>new ot(t);var KS=(t,e)=>{let r;switch(t.code){case x.invalid_type:t.received===z.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case x.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,X.jsonStringifyReplacer)}`;break;case x.unrecognized_keys:r=`Unrecognized key(s) in object: ${X.joinValues(t.keys,", ")}`;break;case x.invalid_union:r="Invalid input";break;case x.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${X.joinValues(t.options)}`;break;case x.invalid_enum_value:r=`Invalid enum value. Expected ${X.joinValues(t.options)}, received '${t.received}'`;break;case x.invalid_arguments:r="Invalid function arguments";break;case x.invalid_return_type:r="Invalid function return type";break;case x.invalid_date:r="Invalid date";break;case x.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}"`:X.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case x.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 x.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 x.custom:r="Invalid input";break;case x.invalid_intersection_types:r="Intersection results could not be merged";break;case x.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case x.not_finite:r="Number must be finite";break;default:r=e.defaultError,X.assertNever(t)}return{message:r}},ir=KS;var ry=ir;function BS(t){ry=t}function Kn(){return ry}var as=t=>{let{data:e,path:r,errorMaps:n,issueData:o}=t,s=[...r,...o.path||[]],i={...o,path:s};if(o.message!==void 0)return{...o,path:s,message:o.message};let a="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)a=u(i,{data:e,defaultError:a}).message;return{...o,path:s,message:a}},GS=[];function E(t,e){let r=Kn(),n=as({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===ir?void 0:ir].filter(o=>!!o)});t.common.issues.push(n)}var qe=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 A;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 s=await o.key,i=await o.value;n.push({key:s,value:i})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let o of r){let{key:s,value:i}=o;if(s.status==="aborted"||i.status==="aborted")return A;s.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(n[s.value]=i.value)}return{status:e.value,value:n}}},A=Object.freeze({status:"aborted"}),tn=t=>({status:"dirty",value:t}),Fe=t=>({status:"valid",value:t}),ia=t=>t.status==="aborted",aa=t=>t.status==="dirty",wr=t=>t.status==="valid",Bn=t=>typeof Promise<"u"&&t instanceof Promise;var R;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(R||(R={}));var $t=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}},ny=(t,e)=>{if(wr(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 ot(t.common.issues);return this._error=r,this._error}}};function L(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,a)=>{let{message:c}=t;return i.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??n??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:o}}var F=class{get description(){return this._def.description}_getType(e){return Bt(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Bt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new qe,ctx:{common:e.parent.common,data:e.data,parsedType:Bt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Bn(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:Bt(e)},o=this._parseSync({data:e,path:n.path,parent:n});return ny(n,o)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Bt(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return wr(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=>wr(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:Bt(e)},o=this._parse({data:e,path:n.path,parent:n}),s=await(Bn(o)?o:Promise.resolve(o));return ny(n,s)}refine(e,r){let n=o=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(o):r;return this._refinement((o,s)=>{let i=e(o),a=()=>s.addIssue({code:x.custom,...n(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(a(),!1)):i?!0:(a(),!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 bt({schema:this,typeName:S.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 st.create(this,this._def)}nullable(){return Jt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ur.create(this)}promise(){return Sr.create(this,this._def)}or(e){return un.create([this,e],this._def)}and(e){return ln.create(this,e,this._def)}transform(e){return new bt({...L(this._def),schema:this,typeName:S.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new hn({...L(this._def),innerType:this,defaultValue:r,typeName:S.ZodDefault})}brand(){return new cs({typeName:S.ZodBranded,type:this,...L(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new gn({...L(this._def),innerType:this,catchValue:r,typeName:S.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return us.create(this,e)}readonly(){return yn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},JS=/^c[^\s-]{8,}$/i,WS=/^[0-9a-z]+$/,XS=/^[0-9A-HJKMNP-TV-Z]{26}$/i,YS=/^[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,QS=/^[a-z0-9_-]{21}$/i,eP=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,tP=/^[-+]?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)?)??$/,rP=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,nP="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",fd,oP=/^(?:(?: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])$/,sP=/^(?:(?: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])$/,iP=/^(([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]))$/,aP=/^(([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])$/,cP=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,uP=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,sy="((\\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])))",lP=new RegExp(`^${sy}$`);function iy(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 dP(t){return new RegExp(`^${iy(t)}$`)}function ay(t){let e=`${sy}T${iy(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 fP(t,e){return!!((e==="v4"||!e)&&oP.test(t)||(e==="v6"||!e)&&iP.test(t))}function pP(t,e){if(!eP.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 mP(t,e){return!!((e==="v4"||!e)&&sP.test(t)||(e==="v6"||!e)&&aP.test(t))}var xr=class t extends F{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==z.string){let s=this._getOrReturnCtx(e);return E(s,{code:x.invalid_type,expected:z.string,received:s.parsedType}),A}let n=new qe,o;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),E(o,{code:x.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(o=this._getOrReturnCtx(e,o),E(o,{code:x.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){let i=e.data.length>s.value,a=e.data.length<s.value;(i||a)&&(o=this._getOrReturnCtx(e,o),i?E(o,{code:x.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&E(o,{code:x.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")rP.test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"email",code:x.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")fd||(fd=new RegExp(nP,"u")),fd.test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"emoji",code:x.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")YS.test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"uuid",code:x.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")QS.test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"nanoid",code:x.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")JS.test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"cuid",code:x.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")WS.test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"cuid2",code:x.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")XS.test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"ulid",code:x.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),E(o,{validation:"url",code:x.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"regex",code:x.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(e,o),E(o,{code:x.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(o=this._getOrReturnCtx(e,o),E(o,{code:x.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),E(o,{code:x.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?ay(s).test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{code:x.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?lP.test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{code:x.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?dP(s).test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{code:x.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?tP.test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"duration",code:x.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?fP(e.data,s.version)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"ip",code:x.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?pP(e.data,s.alg)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"jwt",code:x.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?mP(e.data,s.version)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"cidr",code:x.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?cP.test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"base64",code:x.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?uP.test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"base64url",code:x.invalid_string,message:s.message}),n.dirty()):X.assertNever(s);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(o=>e.test(o),{validation:r,code:x.invalid_string,...R.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...R.errToObj(e)})}url(e){return this._addCheck({kind:"url",...R.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...R.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...R.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...R.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...R.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...R.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...R.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...R.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...R.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...R.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...R.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...R.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,...R.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,...R.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...R.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...R.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...R.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...R.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...R.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...R.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...R.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...R.errToObj(r)})}nonempty(e){return this.min(1,R.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}};xr.create=t=>new xr({checks:[],typeName:S.ZodString,coerce:t?.coerce??!1,...L(t)});function hP(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(t.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return s%i/10**o}var rn=class t extends F{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)!==z.number){let s=this._getOrReturnCtx(e);return E(s,{code:x.invalid_type,expected:z.number,received:s.parsedType}),A}let n,o=new qe;for(let s of this._def.checks)s.kind==="int"?X.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{code:x.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),E(n,{code:x.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),E(n,{code:x.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="multipleOf"?hP(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),E(n,{code:x.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{code:x.not_finite,message:s.message}),o.dirty()):X.assertNever(s);return{status:o.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,R.toString(r))}gt(e,r){return this.setLimit("min",e,!1,R.toString(r))}lte(e,r){return this.setLimit("max",e,!0,R.toString(r))}lt(e,r){return this.setLimit("max",e,!1,R.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:R.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:R.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:R.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:R.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:R.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:R.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:R.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:R.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:R.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:R.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"&&X.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)}};rn.create=t=>new rn({checks:[],typeName:S.ZodNumber,coerce:t?.coerce||!1,...L(t)});var nn=class t extends F{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)!==z.bigint)return this._getInvalidInput(e);let n,o=new qe;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),E(n,{code:x.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),E(n,{code:x.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),E(n,{code:x.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):X.assertNever(s);return{status:o.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return E(r,{code:x.invalid_type,expected:z.bigint,received:r.parsedType}),A}gte(e,r){return this.setLimit("min",e,!0,R.toString(r))}gt(e,r){return this.setLimit("min",e,!1,R.toString(r))}lte(e,r){return this.setLimit("max",e,!0,R.toString(r))}lt(e,r){return this.setLimit("max",e,!1,R.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:R.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:R.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:R.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:R.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:R.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:R.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}};nn.create=t=>new nn({checks:[],typeName:S.ZodBigInt,coerce:t?.coerce??!1,...L(t)});var on=class extends F{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==z.boolean){let n=this._getOrReturnCtx(e);return E(n,{code:x.invalid_type,expected:z.boolean,received:n.parsedType}),A}return Fe(e.data)}};on.create=t=>new on({typeName:S.ZodBoolean,coerce:t?.coerce||!1,...L(t)});var sn=class t extends F{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==z.date){let s=this._getOrReturnCtx(e);return E(s,{code:x.invalid_type,expected:z.date,received:s.parsedType}),A}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return E(s,{code:x.invalid_date}),A}let n=new qe,o;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),E(o,{code:x.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(o=this._getOrReturnCtx(e,o),E(o,{code:x.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):X.assertNever(s);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:R.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:R.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}};sn.create=t=>new sn({checks:[],coerce:t?.coerce||!1,typeName:S.ZodDate,...L(t)});var Jn=class extends F{_parse(e){if(this._getType(e)!==z.symbol){let n=this._getOrReturnCtx(e);return E(n,{code:x.invalid_type,expected:z.symbol,received:n.parsedType}),A}return Fe(e.data)}};Jn.create=t=>new Jn({typeName:S.ZodSymbol,...L(t)});var an=class extends F{_parse(e){if(this._getType(e)!==z.undefined){let n=this._getOrReturnCtx(e);return E(n,{code:x.invalid_type,expected:z.undefined,received:n.parsedType}),A}return Fe(e.data)}};an.create=t=>new an({typeName:S.ZodUndefined,...L(t)});var cn=class extends F{_parse(e){if(this._getType(e)!==z.null){let n=this._getOrReturnCtx(e);return E(n,{code:x.invalid_type,expected:z.null,received:n.parsedType}),A}return Fe(e.data)}};cn.create=t=>new cn({typeName:S.ZodNull,...L(t)});var kr=class extends F{constructor(){super(...arguments),this._any=!0}_parse(e){return Fe(e.data)}};kr.create=t=>new kr({typeName:S.ZodAny,...L(t)});var cr=class extends F{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Fe(e.data)}};cr.create=t=>new cr({typeName:S.ZodUnknown,...L(t)});var Nt=class extends F{_parse(e){let r=this._getOrReturnCtx(e);return E(r,{code:x.invalid_type,expected:z.never,received:r.parsedType}),A}};Nt.create=t=>new Nt({typeName:S.ZodNever,...L(t)});var Wn=class extends F{_parse(e){if(this._getType(e)!==z.undefined){let n=this._getOrReturnCtx(e);return E(n,{code:x.invalid_type,expected:z.void,received:n.parsedType}),A}return Fe(e.data)}};Wn.create=t=>new Wn({typeName:S.ZodVoid,...L(t)});var ur=class t extends F{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),o=this._def;if(r.parsedType!==z.array)return E(r,{code:x.invalid_type,expected:z.array,received:r.parsedType}),A;if(o.exactLength!==null){let i=r.data.length>o.exactLength.value,a=r.data.length<o.exactLength.value;(i||a)&&(E(r,{code:i?x.too_big:x.too_small,minimum:a?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&&(E(r,{code:x.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&&(E(r,{code:x.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,a)=>o.type._parseAsync(new $t(r,i,r.path,a)))).then(i=>qe.mergeArray(n,i));let s=[...r.data].map((i,a)=>o.type._parseSync(new $t(r,i,r.path,a)));return qe.mergeArray(n,s)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:R.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:R.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:R.toString(r)}})}nonempty(e){return this.min(1,e)}};ur.create=(t,e)=>new ur({type:t,minLength:null,maxLength:null,exactLength:null,typeName:S.ZodArray,...L(e)});function Gn(t){if(t instanceof it){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=st.create(Gn(n))}return new it({...t._def,shape:()=>e})}else return t instanceof ur?new ur({...t._def,type:Gn(t.element)}):t instanceof st?st.create(Gn(t.unwrap())):t instanceof Jt?Jt.create(Gn(t.unwrap())):t instanceof Gt?Gt.create(t.items.map(e=>Gn(e))):t}var it=class t extends F{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=X.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==z.object){let u=this._getOrReturnCtx(e);return E(u,{code:x.invalid_type,expected:z.object,received:u.parsedType}),A}let{status:n,ctx:o}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Nt&&this._def.unknownKeys==="strip"))for(let u in o.data)i.includes(u)||a.push(u);let c=[];for(let u of i){let l=s[u],d=o.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new $t(o,d,o.path,u)),alwaysSet:u in o.data})}if(this._def.catchall instanceof Nt){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:o.data[l]}});else if(u==="strict")a.length>0&&(E(o,{code:x.unrecognized_keys,keys:a}),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 a){let d=o.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new $t(o,d,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let d=await l.key,h=await l.value;u.push({key:d,value:h,alwaysSet:l.alwaysSet})}return u}).then(u=>qe.mergeObjectSync(n,u)):qe.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return R.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:R.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:S.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 X.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 X.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Gn(this)}partial(e){let r={};for(let n of X.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 X.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof st;)s=s._def.innerType;r[n]=s}return new t({...this._def,shape:()=>r})}keyof(){return cy(X.objectKeys(this.shape))}};it.create=(t,e)=>new it({shape:()=>t,unknownKeys:"strip",catchall:Nt.create(),typeName:S.ZodObject,...L(e)});it.strictCreate=(t,e)=>new it({shape:()=>t,unknownKeys:"strict",catchall:Nt.create(),typeName:S.ZodObject,...L(e)});it.lazycreate=(t,e)=>new it({shape:t,unknownKeys:"strip",catchall:Nt.create(),typeName:S.ZodObject,...L(e)});var un=class extends F{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function o(s){for(let a of s)if(a.result.status==="valid")return a.result;for(let a of s)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let i=s.map(a=>new ot(a.ctx.common.issues));return E(r,{code:x.invalid_union,unionErrors:i}),A}if(r.common.async)return Promise.all(n.map(async s=>{let i={...r,common:{...r.common,issues:[]},parent:null};return{result:await s._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(o);{let s,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"&&!s&&(s={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;let a=i.map(c=>new ot(c));return E(r,{code:x.invalid_union,unionErrors:a}),A}}get options(){return this._def.options}};un.create=(t,e)=>new un({options:t,typeName:S.ZodUnion,...L(e)});var ar=t=>t instanceof dn?ar(t.schema):t instanceof bt?ar(t.innerType()):t instanceof fn?[t.value]:t instanceof pn?t.options:t instanceof mn?X.objectValues(t.enum):t instanceof hn?ar(t._def.innerType):t instanceof an?[void 0]:t instanceof cn?[null]:t instanceof st?[void 0,...ar(t.unwrap())]:t instanceof Jt?[null,...ar(t.unwrap())]:t instanceof cs||t instanceof yn?ar(t.unwrap()):t instanceof gn?ar(t._def.innerType):[],ca=class t extends F{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==z.object)return E(r,{code:x.invalid_type,expected:z.object,received:r.parsedType}),A;let n=this.discriminator,o=r.data[n],s=this.optionsMap.get(o);return s?r.common.async?s._parseAsync({data:r.data,path:r.path,parent:r}):s._parseSync({data:r.data,path:r.path,parent:r}):(E(r,{code:x.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),A)}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 s of r){let i=ar(s.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of i){if(o.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);o.set(a,s)}}return new t({typeName:S.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:o,...L(n)})}};function pd(t,e){let r=Bt(t),n=Bt(e);if(t===e)return{valid:!0,data:t};if(r===z.object&&n===z.object){let o=X.objectKeys(e),s=X.objectKeys(t).filter(a=>o.indexOf(a)!==-1),i={...t,...e};for(let a of s){let c=pd(t[a],e[a]);if(!c.valid)return{valid:!1};i[a]=c.data}return{valid:!0,data:i}}else if(r===z.array&&n===z.array){if(t.length!==e.length)return{valid:!1};let o=[];for(let s=0;s<t.length;s++){let i=t[s],a=e[s],c=pd(i,a);if(!c.valid)return{valid:!1};o.push(c.data)}return{valid:!0,data:o}}else return r===z.date&&n===z.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var ln=class extends F{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=(s,i)=>{if(ia(s)||ia(i))return A;let a=pd(s.value,i.value);return a.valid?((aa(s)||aa(i))&&r.dirty(),{status:r.value,value:a.data}):(E(n,{code:x.invalid_intersection_types}),A)};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(([s,i])=>o(s,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}))}};ln.create=(t,e,r)=>new ln({left:t,right:e,typeName:S.ZodIntersection,...L(r)});var Gt=class t extends F{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.array)return E(n,{code:x.invalid_type,expected:z.array,received:n.parsedType}),A;if(n.data.length<this._def.items.length)return E(n,{code:x.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),A;!this._def.rest&&n.data.length>this._def.items.length&&(E(n,{code:x.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let s=[...n.data].map((i,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new $t(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>qe.mergeArray(r,i)):qe.mergeArray(r,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Gt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Gt({items:t,typeName:S.ZodTuple,rest:null,...L(e)})};var ua=class t extends F{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!==z.object)return E(n,{code:x.invalid_type,expected:z.object,received:n.parsedType}),A;let o=[],s=this._def.keyType,i=this._def.valueType;for(let a in n.data)o.push({key:s._parse(new $t(n,a,n.path,a)),value:i._parse(new $t(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?qe.mergeObjectAsync(r,o):qe.mergeObjectSync(r,o)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof F?new t({keyType:e,valueType:r,typeName:S.ZodRecord,...L(n)}):new t({keyType:xr.create(),valueType:e,typeName:S.ZodRecord,...L(r)})}},Xn=class extends F{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!==z.map)return E(n,{code:x.invalid_type,expected:z.map,received:n.parsedType}),A;let o=this._def.keyType,s=this._def.valueType,i=[...n.data.entries()].map(([a,c],u)=>({key:o._parse(new $t(n,a,n.path,[u,"key"])),value:s._parse(new $t(n,c,n.path,[u,"value"]))}));if(n.common.async){let a=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 A;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let c of i){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return A;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}}}};Xn.create=(t,e,r)=>new Xn({valueType:e,keyType:t,typeName:S.ZodMap,...L(r)});var Yn=class t extends F{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.set)return E(n,{code:x.invalid_type,expected:z.set,received:n.parsedType}),A;let o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&(E(n,{code:x.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&&(E(n,{code:x.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),r.dirty());let s=this._def.valueType;function i(c){let u=new Set;for(let l of c){if(l.status==="aborted")return A;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let a=[...n.data.values()].map((c,u)=>s._parse(new $t(n,c,n.path,u)));return n.common.async?Promise.all(a).then(c=>i(c)):i(a)}min(e,r){return new t({...this._def,minSize:{value:e,message:R.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:R.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Yn.create=(t,e)=>new Yn({valueType:t,minSize:null,maxSize:null,typeName:S.ZodSet,...L(e)});var la=class t extends F{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==z.function)return E(r,{code:x.invalid_type,expected:z.function,received:r.parsedType}),A;function n(a,c){return as({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Kn(),ir].filter(u=>!!u),issueData:{code:x.invalid_arguments,argumentsError:c}})}function o(a,c){return as({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Kn(),ir].filter(u=>!!u),issueData:{code:x.invalid_return_type,returnTypeError:c}})}let s={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof Sr){let a=this;return Fe(async function(...c){let u=new ot([]),l=await a._def.args.parseAsync(c,s).catch(m=>{throw u.addIssue(n(c,m)),u}),d=await Reflect.apply(i,this,l);return await a._def.returns._def.type.parseAsync(d,s).catch(m=>{throw u.addIssue(o(d,m)),u})})}else{let a=this;return Fe(function(...c){let u=a._def.args.safeParse(c,s);if(!u.success)throw new ot([n(c,u.error)]);let l=Reflect.apply(i,this,u.data),d=a._def.returns.safeParse(l,s);if(!d.success)throw new ot([o(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Gt.create(e).rest(cr.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||Gt.create([]).rest(cr.create()),returns:r||cr.create(),typeName:S.ZodFunction,...L(n)})}},dn=class extends F{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})}};dn.create=(t,e)=>new dn({getter:t,typeName:S.ZodLazy,...L(e)});var fn=class extends F{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return E(r,{received:r.data,code:x.invalid_literal,expected:this._def.value}),A}return{status:"valid",value:e.data}}get value(){return this._def.value}};fn.create=(t,e)=>new fn({value:t,typeName:S.ZodLiteral,...L(e)});function cy(t,e){return new pn({values:t,typeName:S.ZodEnum,...L(e)})}var pn=class t extends F{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return E(r,{expected:X.joinValues(n),received:r.parsedType,code:x.invalid_type}),A}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 E(r,{received:r.data,code:x.invalid_enum_value,options:n}),A}return Fe(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})}};pn.create=cy;var mn=class extends F{_parse(e){let r=X.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==z.string&&n.parsedType!==z.number){let o=X.objectValues(r);return E(n,{expected:X.joinValues(o),received:n.parsedType,code:x.invalid_type}),A}if(this._cache||(this._cache=new Set(X.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=X.objectValues(r);return E(n,{received:n.data,code:x.invalid_enum_value,options:o}),A}return Fe(e.data)}get enum(){return this._def.values}};mn.create=(t,e)=>new mn({values:t,typeName:S.ZodNativeEnum,...L(e)});var Sr=class extends F{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==z.promise&&r.common.async===!1)return E(r,{code:x.invalid_type,expected:z.promise,received:r.parsedType}),A;let n=r.parsedType===z.promise?r.data:Promise.resolve(r.data);return Fe(n.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Sr.create=(t,e)=>new Sr({type:t,typeName:S.ZodPromise,...L(e)});var bt=class extends F{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===S.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=this._def.effect||null,s={addIssue:i=>{E(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){let i=o.transform(n.data,s);if(n.common.async)return Promise.resolve(i).then(async a=>{if(r.value==="aborted")return A;let c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?A:c.status==="dirty"?tn(c.value):r.value==="dirty"?tn(c.value):c});{if(r.value==="aborted")return A;let a=this._def.schema._parseSync({data:i,path:n.path,parent:n});return a.status==="aborted"?A:a.status==="dirty"?tn(a.value):r.value==="dirty"?tn(a.value):a}}if(o.type==="refinement"){let i=a=>{let c=o.refinement(a,s);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 a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?A:(a.status==="dirty"&&r.dirty(),i(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?A:(a.status==="dirty"&&r.dirty(),i(a.value).then(()=>({status:r.value,value:a.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(!wr(i))return A;let a=o.transform(i.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>wr(i)?Promise.resolve(o.transform(i.value,s)).then(a=>({status:r.value,value:a})):A);X.assertNever(o)}};bt.create=(t,e,r)=>new bt({schema:t,typeName:S.ZodEffects,effect:e,...L(r)});bt.createWithPreprocess=(t,e,r)=>new bt({schema:e,effect:{type:"preprocess",transform:t},typeName:S.ZodEffects,...L(r)});var st=class extends F{_parse(e){return this._getType(e)===z.undefined?Fe(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};st.create=(t,e)=>new st({innerType:t,typeName:S.ZodOptional,...L(e)});var Jt=class extends F{_parse(e){return this._getType(e)===z.null?Fe(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Jt.create=(t,e)=>new Jt({innerType:t,typeName:S.ZodNullable,...L(e)});var hn=class extends F{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===z.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};hn.create=(t,e)=>new hn({innerType:t,typeName:S.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...L(e)});var gn=class extends F{_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 Bn(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ot(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new ot(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};gn.create=(t,e)=>new gn({innerType:t,typeName:S.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...L(e)});var Qn=class extends F{_parse(e){if(this._getType(e)!==z.nan){let n=this._getOrReturnCtx(e);return E(n,{code:x.invalid_type,expected:z.nan,received:n.parsedType}),A}return{status:"valid",value:e.data}}};Qn.create=t=>new Qn({typeName:S.ZodNaN,...L(t)});var gP=Symbol("zod_brand"),cs=class extends F{_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}},us=class t extends F{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?A:s.status==="dirty"?(r.dirty(),tn(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{let o=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?A: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:S.ZodPipeline})}},yn=class extends F{_parse(e){let r=this._def.innerType._parse(e),n=o=>(wr(o)&&(o.value=Object.freeze(o.value)),o);return Bn(r)?r.then(o=>n(o)):n(r)}unwrap(){return this._def.innerType}};yn.create=(t,e)=>new yn({innerType:t,typeName:S.ZodReadonly,...L(e)});function oy(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function uy(t,e={},r){return t?kr.create().superRefine((n,o)=>{let s=t(n);if(s instanceof Promise)return s.then(i=>{if(!i){let a=oy(e,n),c=a.fatal??r??!0;o.addIssue({code:"custom",...a,fatal:c})}});if(!s){let i=oy(e,n),a=i.fatal??r??!0;o.addIssue({code:"custom",...i,fatal:a})}}):kr.create()}var yP={object:it.lazycreate},S;(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"})(S||(S={}));var _P=(t,e={message:`Input not instance of ${t.name}`})=>uy(r=>r instanceof t,e),ly=xr.create,dy=rn.create,vP=Qn.create,$P=nn.create,fy=on.create,bP=sn.create,wP=Jn.create,xP=an.create,kP=cn.create,SP=kr.create,PP=cr.create,EP=Nt.create,zP=Wn.create,TP=ur.create,md=it.create,RP=it.strictCreate,IP=un.create,OP=ca.create,NP=ln.create,jP=Gt.create,CP=ua.create,MP=Xn.create,AP=Yn.create,ZP=la.create,qP=dn.create,DP=fn.create,LP=pn.create,VP=mn.create,UP=Sr.create,FP=bt.create,HP=st.create,KP=Jt.create,BP=bt.createWithPreprocess,GP=us.create,JP=()=>ly().optional(),WP=()=>dy().optional(),XP=()=>fy().optional(),YP={string:(t=>xr.create({...t,coerce:!0})),number:(t=>rn.create({...t,coerce:!0})),boolean:(t=>on.create({...t,coerce:!0})),bigint:(t=>nn.create({...t,coerce:!0})),date:(t=>sn.create({...t,coerce:!0}))};var QP=A;var tE=b("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");le.init(t,e),t.def=e,t.parse=(r,n)=>eu(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Xr(t,r,n),t.parseAsync=async(r,n)=>ru(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>Yr(t,r,n),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>gt(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t))});var rE=b("ZodMiniObject",(t,e)=>{ki.init(t,e),tE.init(t,e),Y.defineLazy(t,"shape",()=>e.shape)});function hd(t,e){let r={type:"object",get shape(){return Y.assignProp(this,"shape",{...t}),this.shape},...Y.normalizeParams(e)};return new rE(r)}function wt(t){return!!t._zod}function _n(t){let e=Object.values(t);if(e.length===0)return hd({});let r=e.every(wt),n=e.every(o=>!wt(o));if(r)return hd(t);if(n)return md(t);throw new Error("Mixed Zod versions detected in object shape.")}function Pr(t,e){return wt(t)?Xr(t,e):t.safeParse(e)}async function da(t,e){return wt(t)?await Yr(t,e):await t.safeParseAsync(e)}function Er(t){if(!t)return;let e;if(wt(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function eo(t){if(t){if(typeof t=="object"){let e=t,r=t;if(!e._def&&!r._zod){let n=Object.values(t);if(n.length>0&&n.every(o=>typeof o=="object"&&o!==null&&(o._def!==void 0||o._zod!==void 0||typeof o.parse=="function")))return _n(t)}}if(wt(t)){let r=t._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return t}else if(t.shape!==void 0)return t}}function fa(t){if(t&&typeof t=="object"){if("message"in t&&typeof t.message=="string")return t.message;if("issues"in t&&Array.isArray(t.issues)&&t.issues.length>0){let e=t.issues[0];if(e&&typeof e=="object"&&"message"in e)return String(e.message)}try{return JSON.stringify(t)}catch{return String(t)}}return String(t)}function py(t){return t.description}function my(t){if(wt(t))return t._zod?.def?.type==="optional";let e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function pa(t){if(wt(t)){let s=t._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=t.value;if(n!==void 0)return n}function zr(t){return t==="completed"||t==="failed"||t==="cancelled"}var gy=Symbol("Let zodToJsonSchema decide on which parser to use");var hy={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},yy=t=>typeof t=="string"?{...hy,name:t}:{...hy,...t};var _y=t=>{let e=yy(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,o])=>[o._def,{def:o._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))}};function gd(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function ee(t,e,r,n,o){t[e]=r,gd(t,e,n,o)}var ma=(t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")};function Pe(t){if(t.target!=="openAi")return{};let e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?ma(e,t.currentPath):e.join("/")}}function vy(t,e){let r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==S.ZodAny&&(r.items=Z(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&ee(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&ee(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(ee(r,"minItems",t.exactLength.value,t.exactLength.message,e),ee(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}function $y(t,e){let r={type:"integer",format:"int64"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?ee(r,"minimum",n.value,n.message,e):ee(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),ee(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?ee(r,"maximum",n.value,n.message,e):ee(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),ee(r,"maximum",n.value,n.message,e));break;case"multipleOf":ee(r,"multipleOf",n.value,n.message,e);break}return r}function by(){return{type:"boolean"}}function ha(t,e){return Z(t.type._def,e)}var wy=(t,e)=>Z(t.innerType._def,e);function yd(t,e,r){let n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((o,s)=>yd(t,e,o))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return oE(t,e)}}var oE=(t,e)=>{let r={type:"integer",format:"unix-time"};if(e.target==="openApi3")return r;for(let n of t.checks)switch(n.kind){case"min":ee(r,"minimum",n.value,n.message,e);break;case"max":ee(r,"maximum",n.value,n.message,e);break}return r};function xy(t,e){return{...Z(t.innerType._def,e),default:t.defaultValue()}}function ky(t,e){return e.effectStrategy==="input"?Z(t.schema._def,e):Pe(e)}function Sy(t){return{type:"string",enum:Array.from(t.values)}}var sE=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function Py(t,e){let r=[Z(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),Z(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(s=>!!s),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,o=[];return r.forEach(s=>{if(sE(s))o.push(...s.allOf),s.unevaluatedProperties===void 0&&(n=void 0);else{let i=s;if("additionalProperties"in s&&s.additionalProperties===!1){let{additionalProperties:a,...c}=s;i=c}else n=void 0;o.push(i)}}),o.length?{allOf:o,...n}:void 0}function Ey(t,e){let r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}var _d,jt={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(_d===void 0&&(_d=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),_d),uuid:/^[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}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?: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])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([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])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function ga(t,e){let r={type:"string"};if(t.checks)for(let n of t.checks)switch(n.kind){case"min":ee(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":ee(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"email":switch(e.emailStrategy){case"format:email":Ct(r,"email",n.message,e);break;case"format:idn-email":Ct(r,"idn-email",n.message,e);break;case"pattern:zod":Ye(r,jt.email,n.message,e);break}break;case"url":Ct(r,"uri",n.message,e);break;case"uuid":Ct(r,"uuid",n.message,e);break;case"regex":Ye(r,n.regex,n.message,e);break;case"cuid":Ye(r,jt.cuid,n.message,e);break;case"cuid2":Ye(r,jt.cuid2,n.message,e);break;case"startsWith":Ye(r,RegExp(`^${vd(n.value,e)}`),n.message,e);break;case"endsWith":Ye(r,RegExp(`${vd(n.value,e)}$`),n.message,e);break;case"datetime":Ct(r,"date-time",n.message,e);break;case"date":Ct(r,"date",n.message,e);break;case"time":Ct(r,"time",n.message,e);break;case"duration":Ct(r,"duration",n.message,e);break;case"length":ee(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),ee(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{Ye(r,RegExp(vd(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&Ct(r,"ipv4",n.message,e),n.version!=="v4"&&Ct(r,"ipv6",n.message,e);break}case"base64url":Ye(r,jt.base64url,n.message,e);break;case"jwt":Ye(r,jt.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&Ye(r,jt.ipv4Cidr,n.message,e),n.version!=="v4"&&Ye(r,jt.ipv6Cidr,n.message,e);break}case"emoji":Ye(r,jt.emoji(),n.message,e);break;case"ulid":{Ye(r,jt.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{Ct(r,"binary",n.message,e);break}case"contentEncoding:base64":{ee(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{Ye(r,jt.base64,n.message,e);break}}break}case"nanoid":Ye(r,jt.nanoid,n.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function vd(t,e){return e.patternStrategy==="escape"?aE(t):t}var iE=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function aE(t){let e="";for(let r=0;r<t.length;r++)iE.has(t[r])||(e+="\\"),e+=t[r];return e}function Ct(t,e,r,n){t.format||t.anyOf?.some(o=>o.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format,...t.errorMessage&&n.errorMessages&&{errorMessage:{format:t.errorMessage.format}}}),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push({format:e,...r&&n.errorMessages&&{errorMessage:{format:r}}})):ee(t,"format",e,r,n)}function Ye(t,e,r,n){t.pattern||t.allOf?.some(o=>o.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern,...t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}}}),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push({pattern:zy(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):ee(t,"pattern",zy(e,n),r,n)}function zy(t,e){if(!e.applyRegexFlags||!t.flags)return t.source;let r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},n=r.i?t.source.toLowerCase():t.source,o="",s=!1,i=!1,a=!1;for(let c=0;c<n.length;c++){if(s){o+=n[c],s=!1;continue}if(r.i){if(i){if(n[c].match(/[a-z]/)){a?(o+=n[c],o+=`${n[c-2]}-${n[c]}`.toUpperCase(),a=!1):n[c+1]==="-"&&n[c+2]?.match(/[a-z]/)?(o+=n[c],a=!0):o+=`${n[c]}${n[c].toUpperCase()}`;continue}}else if(n[c].match(/[a-z]/)){o+=`[${n[c]}${n[c].toUpperCase()}]`;continue}}if(r.m){if(n[c]==="^"){o+=`(^|(?<=[\r
45
+ `}var oa=class{constructor(e=ld.default.stdin,r=ld.default.stdout){this._stdin=e,this._stdout=r,this._readBuffer=new na,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(r=>{let n=ty(e);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};var sa=class{constructor(e,r=null){this.workerUrl=e;typeof r=="function"?this.getToken=r:this.getToken=()=>r}getToken;buildHeaders(e){let r={...e},n=this.getToken();return n&&(r.Authorization=`Bearer ${n}`),r}async search(e){let r=new URL("/api/search",this.workerUrl);return r.searchParams.set("query",e.query),e.limit!==void 0&&r.searchParams.set("limit",String(e.limit)),e.type!==void 0&&r.searchParams.set("type",e.type),e.project!==void 0&&r.searchParams.set("project",e.project),this.get(r)}async timeline(e){let r=new URL("/api/timeline",this.workerUrl);return r.searchParams.set("anchor",e.anchor),e.depth_before!==void 0&&r.searchParams.set("depth_before",String(e.depth_before)),e.depth_after!==void 0&&r.searchParams.set("depth_after",String(e.depth_after)),this.get(r)}async getObservations(e){return this.post("/api/observations/batch",{ids:e.ids})}async saveMemory(e){let r={text:e.text};return e.title!==void 0&&(r.title=e.title),e.project!==void 0&&(r.project=e.project),this.post("/api/memory/save",r)}async isWorkerAvailable(){try{return(await fetch(`${this.workerUrl}/api/health`,{signal:AbortSignal.timeout(15e3)})).ok}catch{return!1}}async get(e){let r=await fetch(e.toString(),{method:"GET",headers:this.buildHeaders(),signal:AbortSignal.timeout(15e3)});if(!r.ok){let n=await r.text().catch(()=>"");throw new Error(`Worker returned ${r.status}: ${n}`)}return r.json()}async post(e,r){let n=await fetch(`${this.workerUrl}${e}`,{method:"POST",headers:this.buildHeaders({"Content-Type":"application/json"}),body:JSON.stringify(r),signal:AbortSignal.timeout(15e3)});if(!n.ok){let o=await n.text().catch(()=>"");throw new Error(`Worker returned ${n.status}: ${o}`)}return n.json()}};var Ne={};qc(Ne,{BRAND:()=>gP,DIRTY:()=>tn,EMPTY_PATH:()=>GS,INVALID:()=>A,NEVER:()=>QP,OK:()=>Fe,ParseStatus:()=>qe,Schema:()=>F,ZodAny:()=>kr,ZodArray:()=>ur,ZodBigInt:()=>nn,ZodBoolean:()=>on,ZodBranded:()=>cs,ZodCatch:()=>gn,ZodDate:()=>sn,ZodDefault:()=>hn,ZodDiscriminatedUnion:()=>ca,ZodEffects:()=>bt,ZodEnum:()=>pn,ZodError:()=>ot,ZodFirstPartyTypeKind:()=>S,ZodFunction:()=>la,ZodIntersection:()=>ln,ZodIssueCode:()=>x,ZodLazy:()=>dn,ZodLiteral:()=>fn,ZodMap:()=>Xn,ZodNaN:()=>Qn,ZodNativeEnum:()=>mn,ZodNever:()=>Nt,ZodNull:()=>cn,ZodNullable:()=>Jt,ZodNumber:()=>rn,ZodObject:()=>it,ZodOptional:()=>st,ZodParsedType:()=>z,ZodPipeline:()=>us,ZodPromise:()=>Sr,ZodReadonly:()=>yn,ZodRecord:()=>ua,ZodSchema:()=>F,ZodSet:()=>Yn,ZodString:()=>xr,ZodSymbol:()=>Jn,ZodTransformer:()=>bt,ZodTuple:()=>Gt,ZodType:()=>F,ZodUndefined:()=>an,ZodUnion:()=>un,ZodUnknown:()=>cr,ZodVoid:()=>Wn,addIssueToContext:()=>E,any:()=>SP,array:()=>TP,bigint:()=>$P,boolean:()=>fy,coerce:()=>YP,custom:()=>uy,date:()=>bP,datetimeRegex:()=>ay,defaultErrorMap:()=>ir,discriminatedUnion:()=>OP,effect:()=>FP,enum:()=>LP,function:()=>ZP,getErrorMap:()=>Kn,getParsedType:()=>Bt,instanceof:()=>_P,intersection:()=>NP,isAborted:()=>ia,isAsync:()=>Bn,isDirty:()=>aa,isValid:()=>wr,late:()=>yP,lazy:()=>qP,literal:()=>DP,makeIssue:()=>as,map:()=>MP,nan:()=>vP,nativeEnum:()=>VP,never:()=>EP,null:()=>kP,nullable:()=>KP,number:()=>dy,object:()=>md,objectUtil:()=>dd,oboolean:()=>XP,onumber:()=>WP,optional:()=>HP,ostring:()=>JP,pipeline:()=>GP,preprocess:()=>BP,promise:()=>UP,quotelessJson:()=>HS,record:()=>CP,set:()=>AP,setErrorMap:()=>BS,strictObject:()=>RP,string:()=>ly,symbol:()=>wP,transformer:()=>FP,tuple:()=>jP,undefined:()=>xP,union:()=>IP,unknown:()=>PP,util:()=>X,void:()=>zP});var X;(function(t){t.assertEqual=o=>{};function e(o){}t.assertIs=e;function r(o){throw new Error}t.assertNever=r,t.arrayToEnum=o=>{let s={};for(let i of o)s[i]=i;return s},t.getValidEnumValues=o=>{let s=t.objectKeys(o).filter(a=>typeof o[o[a]]!="number"),i={};for(let a of s)i[a]=o[a];return t.objectValues(i)},t.objectValues=o=>t.objectKeys(o).map(function(s){return o[s]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let s=[];for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&s.push(i);return s},t.find=(o,s)=>{for(let i of o)if(s(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,s=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(s)}t.joinValues=n,t.jsonStringifyReplacer=(o,s)=>typeof s=="bigint"?s.toString():s})(X||(X={}));var dd;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(dd||(dd={}));var z=X.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Bt=t=>{switch(typeof t){case"undefined":return z.undefined;case"string":return z.string;case"number":return Number.isNaN(t)?z.nan:z.number;case"boolean":return z.boolean;case"function":return z.function;case"bigint":return z.bigint;case"symbol":return z.symbol;case"object":return Array.isArray(t)?z.array:t===null?z.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?z.promise:typeof Map<"u"&&t instanceof Map?z.map:typeof Set<"u"&&t instanceof Set?z.set:typeof Date<"u"&&t instanceof Date?z.date:z.object;default:return z.unknown}};var x=X.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"]),HS=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),ot=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(s){return s.message},n={_errors:[]},o=s=>{for(let i of s.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 a=n,c=0;for(;c<i.path.length;){let u=i.path[c];c===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(i))):a[u]=a[u]||{_errors:[]},a=a[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,X.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 s=o.path[0];r[s]=r[s]||[],r[s].push(e(o))}else n.push(e(o));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};ot.create=t=>new ot(t);var KS=(t,e)=>{let r;switch(t.code){case x.invalid_type:t.received===z.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case x.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,X.jsonStringifyReplacer)}`;break;case x.unrecognized_keys:r=`Unrecognized key(s) in object: ${X.joinValues(t.keys,", ")}`;break;case x.invalid_union:r="Invalid input";break;case x.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${X.joinValues(t.options)}`;break;case x.invalid_enum_value:r=`Invalid enum value. Expected ${X.joinValues(t.options)}, received '${t.received}'`;break;case x.invalid_arguments:r="Invalid function arguments";break;case x.invalid_return_type:r="Invalid function return type";break;case x.invalid_date:r="Invalid date";break;case x.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}"`:X.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case x.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 x.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 x.custom:r="Invalid input";break;case x.invalid_intersection_types:r="Intersection results could not be merged";break;case x.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case x.not_finite:r="Number must be finite";break;default:r=e.defaultError,X.assertNever(t)}return{message:r}},ir=KS;var ry=ir;function BS(t){ry=t}function Kn(){return ry}var as=t=>{let{data:e,path:r,errorMaps:n,issueData:o}=t,s=[...r,...o.path||[]],i={...o,path:s};if(o.message!==void 0)return{...o,path:s,message:o.message};let a="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)a=u(i,{data:e,defaultError:a}).message;return{...o,path:s,message:a}},GS=[];function E(t,e){let r=Kn(),n=as({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===ir?void 0:ir].filter(o=>!!o)});t.common.issues.push(n)}var qe=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 A;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 s=await o.key,i=await o.value;n.push({key:s,value:i})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let o of r){let{key:s,value:i}=o;if(s.status==="aborted"||i.status==="aborted")return A;s.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(n[s.value]=i.value)}return{status:e.value,value:n}}},A=Object.freeze({status:"aborted"}),tn=t=>({status:"dirty",value:t}),Fe=t=>({status:"valid",value:t}),ia=t=>t.status==="aborted",aa=t=>t.status==="dirty",wr=t=>t.status==="valid",Bn=t=>typeof Promise<"u"&&t instanceof Promise;var R;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(R||(R={}));var $t=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}},ny=(t,e)=>{if(wr(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 ot(t.common.issues);return this._error=r,this._error}}};function L(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,a)=>{let{message:c}=t;return i.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??n??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:o}}var F=class{get description(){return this._def.description}_getType(e){return Bt(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Bt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new qe,ctx:{common:e.parent.common,data:e.data,parsedType:Bt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Bn(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:Bt(e)},o=this._parseSync({data:e,path:n.path,parent:n});return ny(n,o)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Bt(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return wr(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=>wr(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:Bt(e)},o=this._parse({data:e,path:n.path,parent:n}),s=await(Bn(o)?o:Promise.resolve(o));return ny(n,s)}refine(e,r){let n=o=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(o):r;return this._refinement((o,s)=>{let i=e(o),a=()=>s.addIssue({code:x.custom,...n(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(a(),!1)):i?!0:(a(),!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 bt({schema:this,typeName:S.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 st.create(this,this._def)}nullable(){return Jt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ur.create(this)}promise(){return Sr.create(this,this._def)}or(e){return un.create([this,e],this._def)}and(e){return ln.create(this,e,this._def)}transform(e){return new bt({...L(this._def),schema:this,typeName:S.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new hn({...L(this._def),innerType:this,defaultValue:r,typeName:S.ZodDefault})}brand(){return new cs({typeName:S.ZodBranded,type:this,...L(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new gn({...L(this._def),innerType:this,catchValue:r,typeName:S.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return us.create(this,e)}readonly(){return yn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},JS=/^c[^\s-]{8,}$/i,WS=/^[0-9a-z]+$/,XS=/^[0-9A-HJKMNP-TV-Z]{26}$/i,YS=/^[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,QS=/^[a-z0-9_-]{21}$/i,eP=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,tP=/^[-+]?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)?)??$/,rP=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,nP="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",fd,oP=/^(?:(?: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])$/,sP=/^(?:(?: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])$/,iP=/^(([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]))$/,aP=/^(([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])$/,cP=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,uP=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,sy="((\\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])))",lP=new RegExp(`^${sy}$`);function iy(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 dP(t){return new RegExp(`^${iy(t)}$`)}function ay(t){let e=`${sy}T${iy(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 fP(t,e){return!!((e==="v4"||!e)&&oP.test(t)||(e==="v6"||!e)&&iP.test(t))}function pP(t,e){if(!eP.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 mP(t,e){return!!((e==="v4"||!e)&&sP.test(t)||(e==="v6"||!e)&&aP.test(t))}var xr=class t extends F{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==z.string){let s=this._getOrReturnCtx(e);return E(s,{code:x.invalid_type,expected:z.string,received:s.parsedType}),A}let n=new qe,o;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),E(o,{code:x.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(o=this._getOrReturnCtx(e,o),E(o,{code:x.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){let i=e.data.length>s.value,a=e.data.length<s.value;(i||a)&&(o=this._getOrReturnCtx(e,o),i?E(o,{code:x.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&E(o,{code:x.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")rP.test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"email",code:x.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")fd||(fd=new RegExp(nP,"u")),fd.test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"emoji",code:x.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")YS.test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"uuid",code:x.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")QS.test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"nanoid",code:x.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")JS.test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"cuid",code:x.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")WS.test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"cuid2",code:x.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")XS.test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"ulid",code:x.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),E(o,{validation:"url",code:x.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"regex",code:x.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(e,o),E(o,{code:x.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(o=this._getOrReturnCtx(e,o),E(o,{code:x.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),E(o,{code:x.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?ay(s).test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{code:x.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?lP.test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{code:x.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?dP(s).test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{code:x.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?tP.test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"duration",code:x.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?fP(e.data,s.version)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"ip",code:x.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?pP(e.data,s.alg)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"jwt",code:x.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?mP(e.data,s.version)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"cidr",code:x.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?cP.test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"base64",code:x.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?uP.test(e.data)||(o=this._getOrReturnCtx(e,o),E(o,{validation:"base64url",code:x.invalid_string,message:s.message}),n.dirty()):X.assertNever(s);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(o=>e.test(o),{validation:r,code:x.invalid_string,...R.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...R.errToObj(e)})}url(e){return this._addCheck({kind:"url",...R.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...R.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...R.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...R.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...R.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...R.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...R.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...R.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...R.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...R.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...R.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...R.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,...R.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,...R.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...R.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...R.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...R.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...R.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...R.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...R.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...R.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...R.errToObj(r)})}nonempty(e){return this.min(1,R.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}};xr.create=t=>new xr({checks:[],typeName:S.ZodString,coerce:t?.coerce??!1,...L(t)});function hP(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(t.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return s%i/10**o}var rn=class t extends F{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)!==z.number){let s=this._getOrReturnCtx(e);return E(s,{code:x.invalid_type,expected:z.number,received:s.parsedType}),A}let n,o=new qe;for(let s of this._def.checks)s.kind==="int"?X.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{code:x.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),E(n,{code:x.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),E(n,{code:x.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="multipleOf"?hP(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),E(n,{code:x.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),E(n,{code:x.not_finite,message:s.message}),o.dirty()):X.assertNever(s);return{status:o.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,R.toString(r))}gt(e,r){return this.setLimit("min",e,!1,R.toString(r))}lte(e,r){return this.setLimit("max",e,!0,R.toString(r))}lt(e,r){return this.setLimit("max",e,!1,R.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:R.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:R.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:R.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:R.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:R.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:R.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:R.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:R.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:R.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:R.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"&&X.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)}};rn.create=t=>new rn({checks:[],typeName:S.ZodNumber,coerce:t?.coerce||!1,...L(t)});var nn=class t extends F{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)!==z.bigint)return this._getInvalidInput(e);let n,o=new qe;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),E(n,{code:x.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),E(n,{code:x.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),E(n,{code:x.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):X.assertNever(s);return{status:o.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return E(r,{code:x.invalid_type,expected:z.bigint,received:r.parsedType}),A}gte(e,r){return this.setLimit("min",e,!0,R.toString(r))}gt(e,r){return this.setLimit("min",e,!1,R.toString(r))}lte(e,r){return this.setLimit("max",e,!0,R.toString(r))}lt(e,r){return this.setLimit("max",e,!1,R.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:R.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:R.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:R.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:R.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:R.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:R.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}};nn.create=t=>new nn({checks:[],typeName:S.ZodBigInt,coerce:t?.coerce??!1,...L(t)});var on=class extends F{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==z.boolean){let n=this._getOrReturnCtx(e);return E(n,{code:x.invalid_type,expected:z.boolean,received:n.parsedType}),A}return Fe(e.data)}};on.create=t=>new on({typeName:S.ZodBoolean,coerce:t?.coerce||!1,...L(t)});var sn=class t extends F{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==z.date){let s=this._getOrReturnCtx(e);return E(s,{code:x.invalid_type,expected:z.date,received:s.parsedType}),A}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return E(s,{code:x.invalid_date}),A}let n=new qe,o;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),E(o,{code:x.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(o=this._getOrReturnCtx(e,o),E(o,{code:x.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):X.assertNever(s);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:R.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:R.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}};sn.create=t=>new sn({checks:[],coerce:t?.coerce||!1,typeName:S.ZodDate,...L(t)});var Jn=class extends F{_parse(e){if(this._getType(e)!==z.symbol){let n=this._getOrReturnCtx(e);return E(n,{code:x.invalid_type,expected:z.symbol,received:n.parsedType}),A}return Fe(e.data)}};Jn.create=t=>new Jn({typeName:S.ZodSymbol,...L(t)});var an=class extends F{_parse(e){if(this._getType(e)!==z.undefined){let n=this._getOrReturnCtx(e);return E(n,{code:x.invalid_type,expected:z.undefined,received:n.parsedType}),A}return Fe(e.data)}};an.create=t=>new an({typeName:S.ZodUndefined,...L(t)});var cn=class extends F{_parse(e){if(this._getType(e)!==z.null){let n=this._getOrReturnCtx(e);return E(n,{code:x.invalid_type,expected:z.null,received:n.parsedType}),A}return Fe(e.data)}};cn.create=t=>new cn({typeName:S.ZodNull,...L(t)});var kr=class extends F{constructor(){super(...arguments),this._any=!0}_parse(e){return Fe(e.data)}};kr.create=t=>new kr({typeName:S.ZodAny,...L(t)});var cr=class extends F{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Fe(e.data)}};cr.create=t=>new cr({typeName:S.ZodUnknown,...L(t)});var Nt=class extends F{_parse(e){let r=this._getOrReturnCtx(e);return E(r,{code:x.invalid_type,expected:z.never,received:r.parsedType}),A}};Nt.create=t=>new Nt({typeName:S.ZodNever,...L(t)});var Wn=class extends F{_parse(e){if(this._getType(e)!==z.undefined){let n=this._getOrReturnCtx(e);return E(n,{code:x.invalid_type,expected:z.void,received:n.parsedType}),A}return Fe(e.data)}};Wn.create=t=>new Wn({typeName:S.ZodVoid,...L(t)});var ur=class t extends F{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),o=this._def;if(r.parsedType!==z.array)return E(r,{code:x.invalid_type,expected:z.array,received:r.parsedType}),A;if(o.exactLength!==null){let i=r.data.length>o.exactLength.value,a=r.data.length<o.exactLength.value;(i||a)&&(E(r,{code:i?x.too_big:x.too_small,minimum:a?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&&(E(r,{code:x.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&&(E(r,{code:x.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,a)=>o.type._parseAsync(new $t(r,i,r.path,a)))).then(i=>qe.mergeArray(n,i));let s=[...r.data].map((i,a)=>o.type._parseSync(new $t(r,i,r.path,a)));return qe.mergeArray(n,s)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:R.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:R.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:R.toString(r)}})}nonempty(e){return this.min(1,e)}};ur.create=(t,e)=>new ur({type:t,minLength:null,maxLength:null,exactLength:null,typeName:S.ZodArray,...L(e)});function Gn(t){if(t instanceof it){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=st.create(Gn(n))}return new it({...t._def,shape:()=>e})}else return t instanceof ur?new ur({...t._def,type:Gn(t.element)}):t instanceof st?st.create(Gn(t.unwrap())):t instanceof Jt?Jt.create(Gn(t.unwrap())):t instanceof Gt?Gt.create(t.items.map(e=>Gn(e))):t}var it=class t extends F{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=X.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==z.object){let u=this._getOrReturnCtx(e);return E(u,{code:x.invalid_type,expected:z.object,received:u.parsedType}),A}let{status:n,ctx:o}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Nt&&this._def.unknownKeys==="strip"))for(let u in o.data)i.includes(u)||a.push(u);let c=[];for(let u of i){let l=s[u],d=o.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new $t(o,d,o.path,u)),alwaysSet:u in o.data})}if(this._def.catchall instanceof Nt){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:o.data[l]}});else if(u==="strict")a.length>0&&(E(o,{code:x.unrecognized_keys,keys:a}),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 a){let d=o.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new $t(o,d,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let d=await l.key,h=await l.value;u.push({key:d,value:h,alwaysSet:l.alwaysSet})}return u}).then(u=>qe.mergeObjectSync(n,u)):qe.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return R.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:R.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:S.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 X.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 X.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Gn(this)}partial(e){let r={};for(let n of X.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 X.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof st;)s=s._def.innerType;r[n]=s}return new t({...this._def,shape:()=>r})}keyof(){return cy(X.objectKeys(this.shape))}};it.create=(t,e)=>new it({shape:()=>t,unknownKeys:"strip",catchall:Nt.create(),typeName:S.ZodObject,...L(e)});it.strictCreate=(t,e)=>new it({shape:()=>t,unknownKeys:"strict",catchall:Nt.create(),typeName:S.ZodObject,...L(e)});it.lazycreate=(t,e)=>new it({shape:t,unknownKeys:"strip",catchall:Nt.create(),typeName:S.ZodObject,...L(e)});var un=class extends F{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function o(s){for(let a of s)if(a.result.status==="valid")return a.result;for(let a of s)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let i=s.map(a=>new ot(a.ctx.common.issues));return E(r,{code:x.invalid_union,unionErrors:i}),A}if(r.common.async)return Promise.all(n.map(async s=>{let i={...r,common:{...r.common,issues:[]},parent:null};return{result:await s._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(o);{let s,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"&&!s&&(s={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;let a=i.map(c=>new ot(c));return E(r,{code:x.invalid_union,unionErrors:a}),A}}get options(){return this._def.options}};un.create=(t,e)=>new un({options:t,typeName:S.ZodUnion,...L(e)});var ar=t=>t instanceof dn?ar(t.schema):t instanceof bt?ar(t.innerType()):t instanceof fn?[t.value]:t instanceof pn?t.options:t instanceof mn?X.objectValues(t.enum):t instanceof hn?ar(t._def.innerType):t instanceof an?[void 0]:t instanceof cn?[null]:t instanceof st?[void 0,...ar(t.unwrap())]:t instanceof Jt?[null,...ar(t.unwrap())]:t instanceof cs||t instanceof yn?ar(t.unwrap()):t instanceof gn?ar(t._def.innerType):[],ca=class t extends F{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==z.object)return E(r,{code:x.invalid_type,expected:z.object,received:r.parsedType}),A;let n=this.discriminator,o=r.data[n],s=this.optionsMap.get(o);return s?r.common.async?s._parseAsync({data:r.data,path:r.path,parent:r}):s._parseSync({data:r.data,path:r.path,parent:r}):(E(r,{code:x.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),A)}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 s of r){let i=ar(s.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of i){if(o.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);o.set(a,s)}}return new t({typeName:S.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:o,...L(n)})}};function pd(t,e){let r=Bt(t),n=Bt(e);if(t===e)return{valid:!0,data:t};if(r===z.object&&n===z.object){let o=X.objectKeys(e),s=X.objectKeys(t).filter(a=>o.indexOf(a)!==-1),i={...t,...e};for(let a of s){let c=pd(t[a],e[a]);if(!c.valid)return{valid:!1};i[a]=c.data}return{valid:!0,data:i}}else if(r===z.array&&n===z.array){if(t.length!==e.length)return{valid:!1};let o=[];for(let s=0;s<t.length;s++){let i=t[s],a=e[s],c=pd(i,a);if(!c.valid)return{valid:!1};o.push(c.data)}return{valid:!0,data:o}}else return r===z.date&&n===z.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var ln=class extends F{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=(s,i)=>{if(ia(s)||ia(i))return A;let a=pd(s.value,i.value);return a.valid?((aa(s)||aa(i))&&r.dirty(),{status:r.value,value:a.data}):(E(n,{code:x.invalid_intersection_types}),A)};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(([s,i])=>o(s,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}))}};ln.create=(t,e,r)=>new ln({left:t,right:e,typeName:S.ZodIntersection,...L(r)});var Gt=class t extends F{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.array)return E(n,{code:x.invalid_type,expected:z.array,received:n.parsedType}),A;if(n.data.length<this._def.items.length)return E(n,{code:x.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),A;!this._def.rest&&n.data.length>this._def.items.length&&(E(n,{code:x.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let s=[...n.data].map((i,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new $t(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>qe.mergeArray(r,i)):qe.mergeArray(r,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Gt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Gt({items:t,typeName:S.ZodTuple,rest:null,...L(e)})};var ua=class t extends F{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!==z.object)return E(n,{code:x.invalid_type,expected:z.object,received:n.parsedType}),A;let o=[],s=this._def.keyType,i=this._def.valueType;for(let a in n.data)o.push({key:s._parse(new $t(n,a,n.path,a)),value:i._parse(new $t(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?qe.mergeObjectAsync(r,o):qe.mergeObjectSync(r,o)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof F?new t({keyType:e,valueType:r,typeName:S.ZodRecord,...L(n)}):new t({keyType:xr.create(),valueType:e,typeName:S.ZodRecord,...L(r)})}},Xn=class extends F{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!==z.map)return E(n,{code:x.invalid_type,expected:z.map,received:n.parsedType}),A;let o=this._def.keyType,s=this._def.valueType,i=[...n.data.entries()].map(([a,c],u)=>({key:o._parse(new $t(n,a,n.path,[u,"key"])),value:s._parse(new $t(n,c,n.path,[u,"value"]))}));if(n.common.async){let a=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 A;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let c of i){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return A;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}}}};Xn.create=(t,e,r)=>new Xn({valueType:e,keyType:t,typeName:S.ZodMap,...L(r)});var Yn=class t extends F{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==z.set)return E(n,{code:x.invalid_type,expected:z.set,received:n.parsedType}),A;let o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&(E(n,{code:x.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&&(E(n,{code:x.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),r.dirty());let s=this._def.valueType;function i(c){let u=new Set;for(let l of c){if(l.status==="aborted")return A;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let a=[...n.data.values()].map((c,u)=>s._parse(new $t(n,c,n.path,u)));return n.common.async?Promise.all(a).then(c=>i(c)):i(a)}min(e,r){return new t({...this._def,minSize:{value:e,message:R.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:R.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Yn.create=(t,e)=>new Yn({valueType:t,minSize:null,maxSize:null,typeName:S.ZodSet,...L(e)});var la=class t extends F{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==z.function)return E(r,{code:x.invalid_type,expected:z.function,received:r.parsedType}),A;function n(a,c){return as({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Kn(),ir].filter(u=>!!u),issueData:{code:x.invalid_arguments,argumentsError:c}})}function o(a,c){return as({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Kn(),ir].filter(u=>!!u),issueData:{code:x.invalid_return_type,returnTypeError:c}})}let s={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof Sr){let a=this;return Fe(async function(...c){let u=new ot([]),l=await a._def.args.parseAsync(c,s).catch(m=>{throw u.addIssue(n(c,m)),u}),d=await Reflect.apply(i,this,l);return await a._def.returns._def.type.parseAsync(d,s).catch(m=>{throw u.addIssue(o(d,m)),u})})}else{let a=this;return Fe(function(...c){let u=a._def.args.safeParse(c,s);if(!u.success)throw new ot([n(c,u.error)]);let l=Reflect.apply(i,this,u.data),d=a._def.returns.safeParse(l,s);if(!d.success)throw new ot([o(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Gt.create(e).rest(cr.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||Gt.create([]).rest(cr.create()),returns:r||cr.create(),typeName:S.ZodFunction,...L(n)})}},dn=class extends F{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})}};dn.create=(t,e)=>new dn({getter:t,typeName:S.ZodLazy,...L(e)});var fn=class extends F{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return E(r,{received:r.data,code:x.invalid_literal,expected:this._def.value}),A}return{status:"valid",value:e.data}}get value(){return this._def.value}};fn.create=(t,e)=>new fn({value:t,typeName:S.ZodLiteral,...L(e)});function cy(t,e){return new pn({values:t,typeName:S.ZodEnum,...L(e)})}var pn=class t extends F{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return E(r,{expected:X.joinValues(n),received:r.parsedType,code:x.invalid_type}),A}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 E(r,{received:r.data,code:x.invalid_enum_value,options:n}),A}return Fe(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})}};pn.create=cy;var mn=class extends F{_parse(e){let r=X.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==z.string&&n.parsedType!==z.number){let o=X.objectValues(r);return E(n,{expected:X.joinValues(o),received:n.parsedType,code:x.invalid_type}),A}if(this._cache||(this._cache=new Set(X.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=X.objectValues(r);return E(n,{received:n.data,code:x.invalid_enum_value,options:o}),A}return Fe(e.data)}get enum(){return this._def.values}};mn.create=(t,e)=>new mn({values:t,typeName:S.ZodNativeEnum,...L(e)});var Sr=class extends F{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==z.promise&&r.common.async===!1)return E(r,{code:x.invalid_type,expected:z.promise,received:r.parsedType}),A;let n=r.parsedType===z.promise?r.data:Promise.resolve(r.data);return Fe(n.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Sr.create=(t,e)=>new Sr({type:t,typeName:S.ZodPromise,...L(e)});var bt=class extends F{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===S.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=this._def.effect||null,s={addIssue:i=>{E(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){let i=o.transform(n.data,s);if(n.common.async)return Promise.resolve(i).then(async a=>{if(r.value==="aborted")return A;let c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?A:c.status==="dirty"?tn(c.value):r.value==="dirty"?tn(c.value):c});{if(r.value==="aborted")return A;let a=this._def.schema._parseSync({data:i,path:n.path,parent:n});return a.status==="aborted"?A:a.status==="dirty"?tn(a.value):r.value==="dirty"?tn(a.value):a}}if(o.type==="refinement"){let i=a=>{let c=o.refinement(a,s);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 a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?A:(a.status==="dirty"&&r.dirty(),i(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?A:(a.status==="dirty"&&r.dirty(),i(a.value).then(()=>({status:r.value,value:a.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(!wr(i))return A;let a=o.transform(i.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>wr(i)?Promise.resolve(o.transform(i.value,s)).then(a=>({status:r.value,value:a})):A);X.assertNever(o)}};bt.create=(t,e,r)=>new bt({schema:t,typeName:S.ZodEffects,effect:e,...L(r)});bt.createWithPreprocess=(t,e,r)=>new bt({schema:e,effect:{type:"preprocess",transform:t},typeName:S.ZodEffects,...L(r)});var st=class extends F{_parse(e){return this._getType(e)===z.undefined?Fe(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};st.create=(t,e)=>new st({innerType:t,typeName:S.ZodOptional,...L(e)});var Jt=class extends F{_parse(e){return this._getType(e)===z.null?Fe(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Jt.create=(t,e)=>new Jt({innerType:t,typeName:S.ZodNullable,...L(e)});var hn=class extends F{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===z.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};hn.create=(t,e)=>new hn({innerType:t,typeName:S.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...L(e)});var gn=class extends F{_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 Bn(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ot(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new ot(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};gn.create=(t,e)=>new gn({innerType:t,typeName:S.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...L(e)});var Qn=class extends F{_parse(e){if(this._getType(e)!==z.nan){let n=this._getOrReturnCtx(e);return E(n,{code:x.invalid_type,expected:z.nan,received:n.parsedType}),A}return{status:"valid",value:e.data}}};Qn.create=t=>new Qn({typeName:S.ZodNaN,...L(t)});var gP=Symbol("zod_brand"),cs=class extends F{_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}},us=class t extends F{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?A:s.status==="dirty"?(r.dirty(),tn(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{let o=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?A: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:S.ZodPipeline})}},yn=class extends F{_parse(e){let r=this._def.innerType._parse(e),n=o=>(wr(o)&&(o.value=Object.freeze(o.value)),o);return Bn(r)?r.then(o=>n(o)):n(r)}unwrap(){return this._def.innerType}};yn.create=(t,e)=>new yn({innerType:t,typeName:S.ZodReadonly,...L(e)});function oy(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function uy(t,e={},r){return t?kr.create().superRefine((n,o)=>{let s=t(n);if(s instanceof Promise)return s.then(i=>{if(!i){let a=oy(e,n),c=a.fatal??r??!0;o.addIssue({code:"custom",...a,fatal:c})}});if(!s){let i=oy(e,n),a=i.fatal??r??!0;o.addIssue({code:"custom",...i,fatal:a})}}):kr.create()}var yP={object:it.lazycreate},S;(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"})(S||(S={}));var _P=(t,e={message:`Input not instance of ${t.name}`})=>uy(r=>r instanceof t,e),ly=xr.create,dy=rn.create,vP=Qn.create,$P=nn.create,fy=on.create,bP=sn.create,wP=Jn.create,xP=an.create,kP=cn.create,SP=kr.create,PP=cr.create,EP=Nt.create,zP=Wn.create,TP=ur.create,md=it.create,RP=it.strictCreate,IP=un.create,OP=ca.create,NP=ln.create,jP=Gt.create,CP=ua.create,MP=Xn.create,AP=Yn.create,ZP=la.create,qP=dn.create,DP=fn.create,LP=pn.create,VP=mn.create,UP=Sr.create,FP=bt.create,HP=st.create,KP=Jt.create,BP=bt.createWithPreprocess,GP=us.create,JP=()=>ly().optional(),WP=()=>dy().optional(),XP=()=>fy().optional(),YP={string:(t=>xr.create({...t,coerce:!0})),number:(t=>rn.create({...t,coerce:!0})),boolean:(t=>on.create({...t,coerce:!0})),bigint:(t=>nn.create({...t,coerce:!0})),date:(t=>sn.create({...t,coerce:!0}))};var QP=A;var tE=b("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");le.init(t,e),t.def=e,t.parse=(r,n)=>eu(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Xr(t,r,n),t.parseAsync=async(r,n)=>ru(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>Yr(t,r,n),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>gt(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t))});var rE=b("ZodMiniObject",(t,e)=>{ki.init(t,e),tE.init(t,e),Y.defineLazy(t,"shape",()=>e.shape)});function hd(t,e){let r={type:"object",get shape(){return Y.assignProp(this,"shape",{...t}),this.shape},...Y.normalizeParams(e)};return new rE(r)}function wt(t){return!!t._zod}function _n(t){let e=Object.values(t);if(e.length===0)return hd({});let r=e.every(wt),n=e.every(o=>!wt(o));if(r)return hd(t);if(n)return md(t);throw new Error("Mixed Zod versions detected in object shape.")}function Pr(t,e){return wt(t)?Xr(t,e):t.safeParse(e)}async function da(t,e){return wt(t)?await Yr(t,e):await t.safeParseAsync(e)}function Er(t){if(!t)return;let e;if(wt(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function eo(t){if(t){if(typeof t=="object"){let e=t,r=t;if(!e._def&&!r._zod){let n=Object.values(t);if(n.length>0&&n.every(o=>typeof o=="object"&&o!==null&&(o._def!==void 0||o._zod!==void 0||typeof o.parse=="function")))return _n(t)}}if(wt(t)){let r=t._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return t}else if(t.shape!==void 0)return t}}function fa(t){if(t&&typeof t=="object"){if("message"in t&&typeof t.message=="string")return t.message;if("issues"in t&&Array.isArray(t.issues)&&t.issues.length>0){let e=t.issues[0];if(e&&typeof e=="object"&&"message"in e)return String(e.message)}try{return JSON.stringify(t)}catch{return String(t)}}return String(t)}function py(t){return t.description}function my(t){if(wt(t))return t._zod?.def?.type==="optional";let e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function pa(t){if(wt(t)){let s=t._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=t.value;if(n!==void 0)return n}function zr(t){return t==="completed"||t==="failed"||t==="cancelled"}var gy=Symbol("Let zodToJsonSchema decide on which parser to use");var hy={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},yy=t=>typeof t=="string"?{...hy,name:t}:{...hy,...t};var _y=t=>{let e=yy(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,o])=>[o._def,{def:o._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))}};function gd(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function ee(t,e,r,n,o){t[e]=r,gd(t,e,n,o)}var ma=(t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")};function Pe(t){if(t.target!=="openAi")return{};let e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?ma(e,t.currentPath):e.join("/")}}function vy(t,e){let r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==S.ZodAny&&(r.items=Z(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&ee(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&ee(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(ee(r,"minItems",t.exactLength.value,t.exactLength.message,e),ee(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}function $y(t,e){let r={type:"integer",format:"int64"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?ee(r,"minimum",n.value,n.message,e):ee(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),ee(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?ee(r,"maximum",n.value,n.message,e):ee(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),ee(r,"maximum",n.value,n.message,e));break;case"multipleOf":ee(r,"multipleOf",n.value,n.message,e);break}return r}function by(){return{type:"boolean"}}function ha(t,e){return Z(t.type._def,e)}var wy=(t,e)=>Z(t.innerType._def,e);function yd(t,e,r){let n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((o,s)=>yd(t,e,o))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return oE(t,e)}}var oE=(t,e)=>{let r={type:"integer",format:"unix-time"};if(e.target==="openApi3")return r;for(let n of t.checks)switch(n.kind){case"min":ee(r,"minimum",n.value,n.message,e);break;case"max":ee(r,"maximum",n.value,n.message,e);break}return r};function xy(t,e){return{...Z(t.innerType._def,e),default:t.defaultValue()}}function ky(t,e){return e.effectStrategy==="input"?Z(t.schema._def,e):Pe(e)}function Sy(t){return{type:"string",enum:Array.from(t.values)}}var sE=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function Py(t,e){let r=[Z(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),Z(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(s=>!!s),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,o=[];return r.forEach(s=>{if(sE(s))o.push(...s.allOf),s.unevaluatedProperties===void 0&&(n=void 0);else{let i=s;if("additionalProperties"in s&&s.additionalProperties===!1){let{additionalProperties:a,...c}=s;i=c}else n=void 0;o.push(i)}}),o.length?{allOf:o,...n}:void 0}function Ey(t,e){let r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}var _d,jt={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(_d===void 0&&(_d=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),_d),uuid:/^[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}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?: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])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([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])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function ga(t,e){let r={type:"string"};if(t.checks)for(let n of t.checks)switch(n.kind){case"min":ee(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":ee(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"email":switch(e.emailStrategy){case"format:email":Ct(r,"email",n.message,e);break;case"format:idn-email":Ct(r,"idn-email",n.message,e);break;case"pattern:zod":Ye(r,jt.email,n.message,e);break}break;case"url":Ct(r,"uri",n.message,e);break;case"uuid":Ct(r,"uuid",n.message,e);break;case"regex":Ye(r,n.regex,n.message,e);break;case"cuid":Ye(r,jt.cuid,n.message,e);break;case"cuid2":Ye(r,jt.cuid2,n.message,e);break;case"startsWith":Ye(r,RegExp(`^${vd(n.value,e)}`),n.message,e);break;case"endsWith":Ye(r,RegExp(`${vd(n.value,e)}$`),n.message,e);break;case"datetime":Ct(r,"date-time",n.message,e);break;case"date":Ct(r,"date",n.message,e);break;case"time":Ct(r,"time",n.message,e);break;case"duration":Ct(r,"duration",n.message,e);break;case"length":ee(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),ee(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{Ye(r,RegExp(vd(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&Ct(r,"ipv4",n.message,e),n.version!=="v4"&&Ct(r,"ipv6",n.message,e);break}case"base64url":Ye(r,jt.base64url,n.message,e);break;case"jwt":Ye(r,jt.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&Ye(r,jt.ipv4Cidr,n.message,e),n.version!=="v4"&&Ye(r,jt.ipv6Cidr,n.message,e);break}case"emoji":Ye(r,jt.emoji(),n.message,e);break;case"ulid":{Ye(r,jt.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{Ct(r,"binary",n.message,e);break}case"contentEncoding:base64":{ee(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{Ye(r,jt.base64,n.message,e);break}}break}case"nanoid":Ye(r,jt.nanoid,n.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function vd(t,e){return e.patternStrategy==="escape"?aE(t):t}var iE=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function aE(t){let e="";for(let r=0;r<t.length;r++)iE.has(t[r])||(e+="\\"),e+=t[r];return e}function Ct(t,e,r,n){t.format||t.anyOf?.some(o=>o.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format,...t.errorMessage&&n.errorMessages&&{errorMessage:{format:t.errorMessage.format}}}),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push({format:e,...r&&n.errorMessages&&{errorMessage:{format:r}}})):ee(t,"format",e,r,n)}function Ye(t,e,r,n){t.pattern||t.allOf?.some(o=>o.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern,...t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}}}),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push({pattern:zy(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):ee(t,"pattern",zy(e,n),r,n)}function zy(t,e){if(!e.applyRegexFlags||!t.flags)return t.source;let r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},n=r.i?t.source.toLowerCase():t.source,o="",s=!1,i=!1,a=!1;for(let c=0;c<n.length;c++){if(s){o+=n[c],s=!1;continue}if(r.i){if(i){if(n[c].match(/[a-z]/)){a?(o+=n[c],o+=`${n[c-2]}-${n[c]}`.toUpperCase(),a=!1):n[c+1]==="-"&&n[c+2]?.match(/[a-z]/)?(o+=n[c],a=!0):o+=`${n[c]}${n[c].toUpperCase()}`;continue}}else if(n[c].match(/[a-z]/)){o+=`[${n[c]}${n[c].toUpperCase()}]`;continue}}if(r.m){if(n[c]==="^"){o+=`(^|(?<=[\r
46
46
  ]))`;continue}else if(n[c]==="$"){o+=`($|(?=[\r
47
47
  ]))`;continue}}if(r.s&&n[c]==="."){o+=i?`${n[c]}\r
48
48
  `:`[${n[c]}\r
package/dist/plugin.cjs CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";var x=Object.defineProperty;var ot=Object.getOwnPropertyDescriptor;var it=Object.getOwnPropertyNames;var st=Object.prototype.hasOwnProperty;var at=(t,e)=>{for(var n in e)x(t,n,{get:e[n],enumerable:!0})},ct=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of it(e))!st.call(t,o)&&o!==n&&x(t,o,{get:()=>e[o],enumerable:!(r=ot(e,o))||r.enumerable});return t};var lt=t=>ct(x({},"__esModule",{value:!0}),t);var se={};at(se,{default:()=>et});module.exports=lt(se);var S=require("node:fs");var C=require("node:os"),p=require("node:path"),w=41777,F="127.0.0.1",ut=(0,p.join)((0,C.homedir)(),".config","opencode"),ce=(0,p.join)(ut,"opencode.json"),y=(0,p.join)((0,C.homedir)(),".config","opencode","memory"),pt="memory.db",gt="settings.json",h=(0,p.join)(y,"worker.pid");var le=(0,p.join)(y,pt),R=(0,p.join)(y,gt),ue=(0,p.join)(y,"logs");var b={workerPort:w,workerBind:F,chromaDbUrl:"http://localhost:8000",chromaDbEnabled:!0,recencyWindowDays:90,retentionDays:365,tddEnabled:!0,fileLengthWarn:300,fileLengthCritical:500,testFilePatterns:["*.test.ts","*.spec.ts","*_test.go","test_*.py"],toolRedirectRules:[],aiProvider:null,aiModel:null,aiCompressionTimeoutMs:15e3,aiCompressionMaxRetries:3,aiSkipTools:[],secretDetectionEnabled:!0,secretPatterns:[],contextTokenBudget:2e3,notificationsEnabled:!1},g=null;function m(){if(g!==null)return g;if(!(0,S.existsSync)(R))return g={...b},g;try{let t=(0,S.readFileSync)(R,"utf-8"),e=JSON.parse(t);return g={...b,...e},g}catch{return g={...b},g}}function A(){let t=m();return`http://${t.workerBind}:${t.workerPort}`}var d=require("node:fs"),M=require("node:os"),_=require("node:path");var $=require("node:child_process");function c(t){process.platform==="darwin"&&m().notificationsEnabled&&(0,$.execFile)("osascript",["-e",`display notification "${t}" with title "opencode"`])}var mt=5e3;function dt(){return process.env.OPENCODE_SESSIONS_DIR??(0,_.join)((0,M.homedir)(),".config","opencode","sessions")}function ft(t){return(0,_.join)(dt(),"sessions",t,"pre-compact-state.json")}function yt(t){let e=["[Memory Context Restored After Compaction]"];return t.activePlan&&e.push(`Active plan: ${t.activePlan}`),t.currentTask&&e.push(`Current task: ${t.currentTask}`),t.status&&e.push(`Status: ${t.status}`),t.summary&&e.push(`Recent context: ${t.summary}`),e.join(`
2
- `)}async function ht(t,e,n){let r=`${t}/api/context/inject?project=${encodeURIComponent(n)}`,o={};e!==null&&(o.Authorization=`Bearer ${e}`);let i=await fetch(r,{headers:o,signal:AbortSignal.timeout(mt)});return i.ok?(await i.json()).context??null:null}function St(t){let e=ft(t);if(!(0,d.existsSync)(e))return null;try{let n=(0,d.readFileSync)(e,"utf-8"),r=JSON.parse(n);return(0,d.unlinkSync)(e),r}catch{return null}}function j(t,e){t.messages=t.messages??[],t.messages.push({role:"user",content:e})}async function D(t,e,n,r,o){c("Session compacted!");try{let i=null;try{i=await ht(e,n,t.project.name)}catch(a){if(a instanceof TypeError)throw a}if(i){j(o,i);return}let s=St(r.sessionId);if(s){let a=yt(s);j(o,a)}}catch(i){t.client.app.log("warn","Compacted state restore failed",{error:i instanceof Error?i.message:String(i),sessionId:r.sessionId})}}var P=require("node:fs"),N=require("node:os"),T=require("node:path");var Tt=5e3;function Pt(){return process.env.OPENCODE_SESSIONS_DIR??(0,T.join)((0,N.homedir)(),".config","opencode","sessions")}function Et(t){return{sessionId:t.sessionId,activePlan:t.context?.activePlan??null,currentTask:t.context?.currentTask??null,summary:t.context?.summary??null,timestamp:new Date().toISOString(),type:"compaction-state"}}async function xt(t,e,n){try{let r={"Content-Type":"application/json"};return e!==null&&(r.Authorization=`Bearer ${e}`),(await fetch(`${t}/api/memory/save`,{method:"POST",headers:r,body:JSON.stringify(n),signal:AbortSignal.timeout(Tt)})).ok}catch{return!1}}function Ct(t,e){let n=(0,T.join)(Pt(),"sessions",t);(0,P.mkdirSync)(n,{recursive:!0});let r=(0,T.join)(n,"pre-compact-state.json");(0,P.writeFileSync)(r,JSON.stringify(e,null,2),"utf-8")}async function L(t,e,n,r,o){c("Session compacting...");let i=Et(r);if(!await xt(e,n,i))try{Ct(r.sessionId,i)}catch(a){t.client.app.log("warn","Failed to write compaction fallback file",{error:a instanceof Error?a.message:String(a),sessionId:r.sessionId})}}var U=require("node:fs"),l=require("node:path");var Rt=300,bt=500,_t=["*.test.ts","*.spec.ts","*_test.go","test_*.py"];function It(t,e){let n=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${n}$`).test(t)}function Ot(t,e){let n=(0,l.basename)(t);return e.some(r=>It(n,r))}function vt(t,e){let n=(0,l.dirname)(t),r=(0,l.extname)(t),o=(0,l.basename)(t,r),i=[];for(let s of e)if(s.startsWith("*.")){let a=s.slice(1);i.push((0,l.join)(n,`${o}${a}`))}else if(s.endsWith("*")){let a=s.slice(0,-1);i.push((0,l.join)(n,`${a}${o}${r}`))}return i}function I(t,e){t.messages=t.messages??[],t.messages.push({role:"system",content:e})}function kt(t,e,n,r){if(Ot(e,n))return;let o=vt(e,n),i=t.project.root;o.some(a=>{let u=a.startsWith("/")?a:(0,l.join)(i,a);return(0,U.existsSync)(u)})||I(r,`\u26A0\uFE0F TDD Warning: No test file found for ${e}. Consider writing tests first (Red-Green-Refactor).`)}function wt(t,e,n,r,o){if(e>r){I(o,`\u{1F6A8} File Length Critical: ${t} has ${e} lines. This file should be refactored.`);return}e>n&&I(o,`\u26A0\uFE0F File Length Warning: ${t} has ${e} lines. Consider splitting this file.`)}async function B(t,e,n,r){try{c(`File edited: ${n.filePath}`);let o=m(),i=n.testFilePatterns??o.testFilePatterns??_t,s=n.fileLengthWarn??o.fileLengthWarn??Rt,a=n.fileLengthCritical??o.fileLengthCritical??bt;kt(t,n.filePath,i,r);let u=n.lineCount??0;wt(n.filePath,u,s,a,r)}catch(o){t.client.app.log("warn","File edited check failed",{error:o instanceof Error?o.message:String(o),filePath:n.filePath})}}var Ft=15e3;function At(t){let{context:e}=t;return e?!!(e.requested||e.investigated||e.learned||e.completed):!1}function $t(t){let e=t.context??{};return["Session Summary:",`Requested: ${e.requested??"Not specified"}`,`Investigated: ${e.investigated??"Not specified"}`,`Learned: ${e.learned??"Not specified"}`,`Completed: ${e.completed??"Not specified"}`].join(`
3
- `)}async function z(t,e,n,r,o){if(c("Session idle"),!At(r))return;let i={"Content-Type":"application/json"};n!==null&&(i.Authorization=`Bearer ${n}`);try{let s=await fetch(`${e}/api/memory/save`,{method:"POST",headers:i,body:JSON.stringify({type:"session-summary",title:`Session Summary: ${r.sessionId}`,text:$t(r),project:t.project.name}),signal:AbortSignal.timeout(Ft)});s.ok||t.client.app.log("warn","Failed to save session summary",{status:s.status})}catch(s){t.client.app.log("warn","Session summary save failed",{error:s instanceof Error?s.message:String(s)})}}var jt=3e3;function Mt(t){let e={};return t!==null&&(e.Authorization=`Bearer ${t}`),e}async function W(t,e){return fetch(t,{headers:Mt(e),signal:AbortSignal.timeout(jt)})}async function G(t,e,n,r,o,i){c("Session started!");let s=`${e}/api/context/inject?project=${encodeURIComponent(t.project.name)}`;try{let a=await W(s,n);if(a.status===401&&i!==void 0){let E=i();a=await W(s,E)}if(!a.ok){t.client.app.log("warn","Failed to load memory context",{status:a.status});return}let u=await a.json();u.context&&(o.messages=o.messages??[],o.messages.push({role:"system",content:u.context}))}catch(a){t.client.app.log("warn","Memory context injection failed",{error:a instanceof Error?a.message:String(a)})}}var Dt=15e3,Nt=200;async function J(t,e,n,r,o,i,s){c(`Tool completed: ${o.tool}`),Lt(t,e,n,r,o,i,s).catch(a=>{t.client.app.log("warn","Observation capture failed",{error:a instanceof Error?a.message:String(a)})})}async function Lt(t,e,n,r,o,i,s){let a=`Tool ${o.tool}: ${Bt(o,i)}`,u=`${o.tool} execution`,E=Ut(o.input),nt=i.output??i.error??"",v={text:r.sanitize(a),title:r.sanitize(u),project:t.project.name,toolName:o.tool,toolInput:r.sanitize(E),toolOutput:r.sanitize(nt)},k=`${e}/api/memory/save`,f=await H(k,v,n);if(f.status===401&&s!==void 0){let rt=s();f=await H(k,v,rt)}f.ok||t.client.app.log("warn","Observation save failed",{status:f.status})}async function H(t,e,n){let r={"Content-Type":"application/json"};return n!==null&&(r.Authorization=`Bearer ${n}`),fetch(t,{method:"POST",headers:r,body:JSON.stringify(e),signal:AbortSignal.timeout(Dt)})}function Ut(t){try{return JSON.stringify(t)}catch{return String(t)}}function Bt(t,e){let n=e.output??e.error??"",r=zt(t.input),o=n.slice(0,Nt).trim();return r&&o?`${r} -> ${o}`:r||o||"(no details)"}function zt(t){let e=Object.entries(t);return e.length===0?"":e.map(([n,r])=>`${n}=${String(r).slice(0,80)}`).join(", ")}function Wt(){let t=process.env.MEMORY_TOOL_REDIRECT_RULES;if(t!==void 0)try{return JSON.parse(t)}catch{return[]}return m().toolRedirectRules}function Gt(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.tool=="string"&&(e.action==="deny"||e.action==="redirect")}function Ht(t){return t.message??`Tool '${t.tool}' is blocked by project configuration.`}function Jt(t){let e=t.message??`Tool '${t.tool}' has been redirected.`;return t.alternative?`${e} Suggested alternative: ${t.alternative}.`:e}function qt(t,e){e.blocked=!0,e.messages=[{role:"user",content:Ht(t)}]}function Kt(t,e){e.messages=[{role:"user",content:Jt(t)}]}async function q(t,e,n,r){c(`Tool executing: ${n.tool}`);let o=Wt();for(let i of o)try{if(!Gt(i))throw new Error("Invalid rule: tool must be a string and action must be 'deny' or 'redirect'");if(i.tool!==n.tool)continue;i.action==="deny"?qt(i,r):Kt(i,r);return}catch(s){t.client.app.log("warn","Tool redirect rule evaluation failed",{error:s instanceof Error?s.message:String(s),rule:JSON.stringify(i)})}}var K=require("node:fs");function Zt(t){return typeof t=="object"&&t!==null&&"token"in t&&typeof t.token=="string"&&"pid"in t&&typeof t.pid=="number"}function Yt(t){try{return process.kill(t,0),!0}catch{return!1}}function O(t){try{let e=(0,K.readFileSync)(t,"utf-8");if(e.trim().length===0)return null;let n=JSON.parse(e);return!Zt(n)||!Yt(n.pid)?null:n.token}catch{return null}}var Z=[{name:"aws_access_key",pattern:/AKIA[0-9A-Z]{16}/g},{name:"github_pat",pattern:/ghp_[a-zA-Z0-9]{36}/g},{name:"github_oauth",pattern:/gho_[a-zA-Z0-9]{36}/g},{name:"anthropic_key",pattern:/sk-ant-[a-zA-Z0-9\-_]{20,}/g},{name:"openai_key",pattern:/sk-[a-zA-Z0-9]{20,}/g},{name:"jwt_token",pattern:/eyJ[a-zA-Z0-9_-]+\.eyJ[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+/g},{name:"pem_private_key",pattern:/-----BEGIN (RSA |EC |OPENSSH )?PRIVATE KEY-----/g},{name:"generic_api_key",pattern:/(?:api[_-]?key|token|secret|password)\s*[:=]\s*['"]?([a-zA-Z0-9\-_]{20,})['"]?/gi}];function Vt(t,e=Z){if(!t)return t;let n=t;for(let{pattern:r}of e)r.lastIndex=0,n=n.replace(r,"[REDACTED]");return n}function Y(t=[]){let e=[...Z,...t];return n=>Vt(n,e)}var Xt=/<private>[\s\S]*?<\/private>/gi;function V(t){return t.replace(Xt,"")}function X(t={}){let{additionalSecretPatterns:e=[],secretDetectionEnabled:n=!0}=t,r=Y(e);return{sanitize(o){let i=V(o);return n?r(i):i}}}function Q(t,e,n){return[Qt(t,e,n),te(t,e,n)]}function Qt(t,e,n){return{name:"memory_search",description:"Search memory observations by topic or keyword",parameters:{query:{type:"string",description:"The search query or topic to look up in memory",required:!0},limit:{type:"number",description:"Maximum number of results to return (default 20)"},project:{type:"string",description:"Filter results to a specific project name"}},execute:r=>ee(t,e,n,r)}}function te(t,e,n){return{name:"memory_save",description:"Save an observation to memory for future reference",parameters:{text:{type:"string",description:"The observation text to save to memory",required:!0},title:{type:"string",description:"Optional short title summarising the observation"}},execute:r=>ne(t,e,n,r)}}function tt(t){return t===null?{}:{Authorization:`Bearer ${t}`}}async function ee(t,e,n,r){try{let o=re(e,r),i=await fetch(o,{headers:tt(n),signal:AbortSignal.timeout(1e4)});if(!i.ok)return{result:`Error: Worker returned status ${i.status}`};let s=await i.json();return{result:oe(s.results??[])}}catch(o){return t.client.app.log("warn","memory_search failed",{error:o instanceof Error?o.message:String(o)}),{result:`Error: ${o instanceof Error?o.message:String(o)}`}}}async function ne(t,e,n,r){try{let o={text:r.text};r.title!==void 0&&(o.title=r.title);let i={"Content-Type":"application/json",...tt(n)},s=await fetch(`${e}/api/memory/save`,{method:"POST",headers:i,body:JSON.stringify(o),signal:AbortSignal.timeout(1e4)});if(!s.ok)return{result:`Error: Worker returned status ${s.status}`};let a=await s.json();return{result:ie(a)}}catch(o){return t.client.app.log("warn","memory_save failed",{error:o instanceof Error?o.message:String(o)}),{result:`Error: ${o instanceof Error?o.message:String(o)}`}}}function re(t,e){let n=new URLSearchParams;return n.set("query",String(e.query??"")),e.limit!==void 0&&n.set("limit",String(e.limit)),e.project!==void 0&&n.set("project",String(e.project)),`${t}/api/search?${n.toString()}`}function oe(t){return t.length===0?"No results found for the given query.":t.map(e=>`[${e.id}] ${e.title} (${e.type}, ${e.project}) \u2014 ${e.summary}`).join(`
4
- `)}function ie(t){let e=t.id??"unknown",n=t.title??"(untitled)";return`Saved observation #${e}: "${n}"`}async function et(t){let e=A(),n=X(),r=O(h);r===null&&t.client.app.log("warn","Auth token not found in PID file \u2014 requests will be unauthenticated",{pidFilePath:h});function o(){return r=O(h),r}return Q(t,e,r),{"session.created":(i,s)=>G(t,e,r,i,s,o),"tool.execute.after":(i,s)=>J(t,e,r,n,i,s,o),"tool.execute.before":(i,s)=>q(t,e,i,s),"session.idle":(i,s)=>z(t,e,r,i,s),"experimental.session.compacting":(i,s)=>L(t,e,r,i,s),"session.compacted":(i,s)=>D(t,e,r,i,s),"file.edited":(i,s)=>B(t,e,i,s)}}
2
+ `)}async function ht(t,e,n){let r=`${t}/api/context/inject?project=${encodeURIComponent(n)}`,o={};e!==null&&(o.Authorization=`Bearer ${e}`);let s=await fetch(r,{headers:o,signal:AbortSignal.timeout(mt)});return s.ok?(await s.json()).context??null:null}function St(t){let e=ft(t);if(!(0,d.existsSync)(e))return null;try{let n=(0,d.readFileSync)(e,"utf-8"),r=JSON.parse(n);return(0,d.unlinkSync)(e),r}catch{return null}}function j(t,e){t.messages=t.messages??[],t.messages.push({role:"user",content:e})}async function D(t,e,n,r,o){c("Session compacted!");try{let s=null;try{s=await ht(e,n,t.project.name)}catch(a){if(a instanceof TypeError)throw a}if(s){j(o,s);return}let i=St(r.sessionId);if(i){let a=yt(i);j(o,a)}}catch(s){t.client.app.log("warn","Compacted state restore failed",{error:s instanceof Error?s.message:String(s),sessionId:r.sessionId})}}var P=require("node:fs"),N=require("node:os"),T=require("node:path");var Tt=5e3;function Pt(){return process.env.OPENCODE_SESSIONS_DIR??(0,T.join)((0,N.homedir)(),".config","opencode","sessions")}function Et(t){return{sessionId:t.sessionId,activePlan:t.context?.activePlan??null,currentTask:t.context?.currentTask??null,summary:t.context?.summary??null,timestamp:new Date().toISOString(),type:"compaction-state"}}async function xt(t,e,n){try{let r={"Content-Type":"application/json"};return e!==null&&(r.Authorization=`Bearer ${e}`),(await fetch(`${t}/api/memory/save`,{method:"POST",headers:r,body:JSON.stringify(n),signal:AbortSignal.timeout(Tt)})).ok}catch{return!1}}function Ct(t,e){let n=(0,T.join)(Pt(),"sessions",t);(0,P.mkdirSync)(n,{recursive:!0});let r=(0,T.join)(n,"pre-compact-state.json");(0,P.writeFileSync)(r,JSON.stringify(e,null,2),"utf-8")}async function L(t,e,n,r,o){c("Session compacting...");let s=Et(r);if(!await xt(e,n,s))try{Ct(r.sessionId,s)}catch(a){t.client.app.log("warn","Failed to write compaction fallback file",{error:a instanceof Error?a.message:String(a),sessionId:r.sessionId})}}var U=require("node:fs"),l=require("node:path");var Rt=300,bt=500,_t=["*.test.ts","*.spec.ts","*_test.go","test_*.py"];function kt(t,e){let n=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${n}$`).test(t)}function It(t,e){let n=(0,l.basename)(t);return e.some(r=>kt(n,r))}function Ot(t,e){let n=(0,l.dirname)(t),r=(0,l.extname)(t),o=(0,l.basename)(t,r),s=[];for(let i of e)if(i.startsWith("*.")){let a=i.slice(1);s.push((0,l.join)(n,`${o}${a}`))}else if(i.endsWith("*")){let a=i.slice(0,-1);s.push((0,l.join)(n,`${a}${o}${r}`))}return s}function k(t,e){t.messages=t.messages??[],t.messages.push({role:"system",content:e})}function vt(t,e,n,r){if(It(e,n))return;let o=Ot(e,n),s=t.project.root;o.some(a=>{let u=a.startsWith("/")?a:(0,l.join)(s,a);return(0,U.existsSync)(u)})||k(r,`\u26A0\uFE0F TDD Warning: No test file found for ${e}. Consider writing tests first (Red-Green-Refactor).`)}function wt(t,e,n,r,o){if(e>r){k(o,`\u{1F6A8} File Length Critical: ${t} has ${e} lines. This file should be refactored.`);return}e>n&&k(o,`\u26A0\uFE0F File Length Warning: ${t} has ${e} lines. Consider splitting this file.`)}async function B(t,e,n,r){try{c(`File edited: ${n.filePath}`);let o=m(),s=n.testFilePatterns??o.testFilePatterns??_t,i=n.fileLengthWarn??o.fileLengthWarn??Rt,a=n.fileLengthCritical??o.fileLengthCritical??bt;vt(t,n.filePath,s,r);let u=n.lineCount??0;wt(n.filePath,u,i,a,r)}catch(o){t.client.app.log("warn","File edited check failed",{error:o instanceof Error?o.message:String(o),filePath:n.filePath})}}var Ft=15e3;function At(t){let{context:e}=t;return e?!!(e.requested||e.investigated||e.learned||e.completed):!1}function $t(t){let e=t.context??{};return["Session Summary:",`Requested: ${e.requested??"Not specified"}`,`Investigated: ${e.investigated??"Not specified"}`,`Learned: ${e.learned??"Not specified"}`,`Completed: ${e.completed??"Not specified"}`].join(`
3
+ `)}async function z(t,e,n,r,o){if(c("Session idle"),!At(r))return;let s={"Content-Type":"application/json"};n!==null&&(s.Authorization=`Bearer ${n}`);try{let i=await fetch(`${e}/api/memory/save`,{method:"POST",headers:s,body:JSON.stringify({type:"session-summary",title:`Session Summary: ${r.sessionId}`,text:$t(r),project:t.project.name}),signal:AbortSignal.timeout(Ft)});i.ok||t.client.app.log("warn","Failed to save session summary",{status:i.status})}catch(i){t.client.app.log("warn","Session summary save failed",{error:i instanceof Error?i.message:String(i)})}}var jt=3e3;function Mt(t){let e={};return t!==null&&(e.Authorization=`Bearer ${t}`),e}async function W(t,e){return fetch(t,{headers:Mt(e),signal:AbortSignal.timeout(jt)})}async function G(t,e,n,r,o,s){c("Session started!");let i=`${e}/api/context/inject?project=${encodeURIComponent(t.project.name)}`;try{let a=await W(i,n);if(a.status===401&&s!==void 0){let E=s();a=await W(i,E)}if(!a.ok){t.client.app.log("warn","Failed to load memory context",{status:a.status});return}let u=await a.json();u.context&&(o.messages=o.messages??[],o.messages.push({role:"system",content:u.context}))}catch(a){t.client.app.log("warn","Memory context injection failed",{error:a instanceof Error?a.message:String(a)})}}var Dt=15e3,Nt=200;async function J(t,e,n,r,o,s,i){c(`Tool completed: ${o.tool}`),Lt(t,e,n,r,o,s,i).catch(a=>{t.client.app.log("warn","Observation capture failed",{error:a instanceof Error?a.message:String(a)})})}async function Lt(t,e,n,r,o,s,i){let a=`Tool ${o.tool}: ${Bt(o,s)}`,u=`${o.tool} execution`,E=Ut(o.input),nt=s.output??s.error??"",O={text:r.sanitize(a),title:r.sanitize(u),project:t.project.name,toolName:o.tool,toolInput:r.sanitize(E),toolOutput:r.sanitize(nt)},v=`${e}/api/memory/save`,f=await H(v,O,n);if(f.status===401&&i!==void 0){let rt=i();f=await H(v,O,rt)}f.ok||t.client.app.log("warn","Observation save failed",{status:f.status})}async function H(t,e,n){let r={"Content-Type":"application/json"};return n!==null&&(r.Authorization=`Bearer ${n}`),fetch(t,{method:"POST",headers:r,body:JSON.stringify(e),signal:AbortSignal.timeout(Dt)})}function Ut(t){try{return JSON.stringify(t)}catch{return String(t)}}function Bt(t,e){let n=e.output??e.error??"",r=zt(t.input),o=n.slice(0,Nt).trim();return r&&o?`${r} -> ${o}`:r||o||"(no details)"}function zt(t){let e=Object.entries(t);return e.length===0?"":e.map(([n,r])=>`${n}=${String(r).slice(0,80)}`).join(", ")}function Wt(){let t=process.env.MEMORY_TOOL_REDIRECT_RULES;if(t!==void 0)try{return JSON.parse(t)}catch{return[]}return m().toolRedirectRules}function Gt(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.tool=="string"&&(e.action==="deny"||e.action==="redirect")}function Ht(t){return t.message??`Tool '${t.tool}' is blocked by project configuration.`}function Jt(t){let e=t.message??`Tool '${t.tool}' has been redirected.`;return t.alternative?`${e} Suggested alternative: ${t.alternative}.`:e}function qt(t,e){e.blocked=!0,e.messages=[{role:"user",content:Ht(t)}]}function Kt(t,e){e.messages=[{role:"user",content:Jt(t)}]}async function q(t,e,n,r){c(`Tool executing: ${n.tool}`);let o=Wt();for(let s of o)try{if(!Gt(s))throw new Error("Invalid rule: tool must be a string and action must be 'deny' or 'redirect'");if(s.tool!==n.tool)continue;s.action==="deny"?qt(s,r):Kt(s,r);return}catch(i){t.client.app.log("warn","Tool redirect rule evaluation failed",{error:i instanceof Error?i.message:String(i),rule:JSON.stringify(s)})}}var K=require("node:fs");function Zt(t){return typeof t=="object"&&t!==null&&"token"in t&&typeof t.token=="string"&&"pid"in t&&typeof t.pid=="number"}function Yt(t){try{return process.kill(t,0),!0}catch{return!1}}function I(t){try{let e=(0,K.readFileSync)(t,"utf-8");if(e.trim().length===0)return null;let n=JSON.parse(e);return!Zt(n)||!Yt(n.pid)?null:n.token}catch{return null}}var Z=[{name:"aws_access_key",pattern:/AKIA[0-9A-Z]{16}/g},{name:"github_pat",pattern:/ghp_[a-zA-Z0-9]{36}/g},{name:"github_oauth",pattern:/gho_[a-zA-Z0-9]{36}/g},{name:"anthropic_key",pattern:/sk-ant-[a-zA-Z0-9\-_]{20,}/g},{name:"openai_key",pattern:/sk-[a-zA-Z0-9]{20,}/g},{name:"jwt_token",pattern:/eyJ[a-zA-Z0-9_-]+\.eyJ[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+/g},{name:"pem_private_key",pattern:/-----BEGIN (RSA |EC |OPENSSH )?PRIVATE KEY-----/g},{name:"generic_api_key",pattern:/(?:api[_-]?key|token|secret|password)\s*[:=]\s*['"]?([a-zA-Z0-9\-_]{20,})['"]?/gi}];function Vt(t,e=Z){if(!t)return t;let n=t;for(let{pattern:r}of e)r.lastIndex=0,n=n.replace(r,"[REDACTED]");return n}function Y(t=[]){let e=[...Z,...t];return n=>Vt(n,e)}var Xt=/<private>[\s\S]*?<\/private>/gi;function V(t){return t.replace(Xt,"")}function X(t={}){let{additionalSecretPatterns:e=[],secretDetectionEnabled:n=!0}=t,r=Y(e);return{sanitize(o){let s=V(o);return n?r(s):s}}}function Q(t,e,n){return[Qt(t,e,n),te(t,e,n)]}function Qt(t,e,n){return{name:"memory_search",description:"Search memory observations by topic or keyword",parameters:{query:{type:"string",description:"The search query or topic to look up in memory",required:!0},limit:{type:"number",description:"Maximum number of results to return (default 20)"},project:{type:"string",description:"Filter results to a specific project name"}},execute:r=>ee(t,e,n,r)}}function te(t,e,n){return{name:"memory_save",description:"Save an observation to memory for future reference",parameters:{text:{type:"string",description:"The observation text to save to memory",required:!0},title:{type:"string",description:"Optional short title summarising the observation"}},execute:r=>ne(t,e,n,r)}}function tt(t){return t===null?{}:{Authorization:`Bearer ${t}`}}async function ee(t,e,n,r){try{let o=re(e,r),s=await fetch(o,{headers:tt(n()),signal:AbortSignal.timeout(1e4)});if(!s.ok)return{result:`Error: Worker returned status ${s.status}`};let i=await s.json();return{result:oe(i.results??[])}}catch(o){return t.client.app.log("warn","memory_search failed",{error:o instanceof Error?o.message:String(o)}),{result:`Error: ${o instanceof Error?o.message:String(o)}`}}}async function ne(t,e,n,r){try{let o={text:r.text};r.title!==void 0&&(o.title=r.title);let s={"Content-Type":"application/json",...tt(n())},i=await fetch(`${e}/api/memory/save`,{method:"POST",headers:s,body:JSON.stringify(o),signal:AbortSignal.timeout(1e4)});if(!i.ok)return{result:`Error: Worker returned status ${i.status}`};let a=await i.json();return{result:ie(a)}}catch(o){return t.client.app.log("warn","memory_save failed",{error:o instanceof Error?o.message:String(o)}),{result:`Error: ${o instanceof Error?o.message:String(o)}`}}}function re(t,e){let n=new URLSearchParams;return n.set("query",String(e.query??"")),e.limit!==void 0&&n.set("limit",String(e.limit)),e.project!==void 0&&n.set("project",String(e.project)),`${t}/api/search?${n.toString()}`}function oe(t){return t.length===0?"No results found for the given query.":t.map(e=>`[${e.id}] ${e.title} (${e.type}, ${e.project}) \u2014 ${e.summary}`).join(`
4
+ `)}function ie(t){let e=t.id??"unknown",n=t.title??"(untitled)";return`Saved observation #${e}: "${n}"`}async function et(t){let e=A(),n=X(),r=I(h);r===null&&t.client.app.log("warn","Auth token not found in PID file \u2014 requests will be unauthenticated",{pidFilePath:h});function o(){return r=I(h),r}return Q(t,e,()=>r),{"session.created":(i,a)=>G(t,e,r,i,a,o),"tool.execute.after":(i,a)=>J(t,e,r,n,i,a,o),"tool.execute.before":(i,a)=>q(t,e,i,a),"session.idle":(i,a)=>z(t,e,r,i,a),"experimental.session.compacting":(i,a)=>L(t,e,r,i,a),"session.compacted":(i,a)=>D(t,e,r,i,a),"file.edited":(i,a)=>B(t,e,i,a)}}