palmagent 0.1.0-alpha.21 → 0.1.0-alpha.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-info.json +2 -2
- package/cli.js +1 -1
- package/package.json +1 -1
- package/server.js +1 -1
- package/web/assets/index-B6mu7UwY.js +375 -0
- package/web/assets/index-CpS3KD9r.css +1 -0
- package/web/index.html +2 -2
- package/web/sw.js +1 -1
- package/web/assets/index-9Xd8KgJN.js +0 -375
- package/web/assets/index-G7r4W1qv.css +0 -1
package/build-info.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.1.0-alpha.
|
|
2
|
+
"version": "0.1.0-alpha.22",
|
|
3
3
|
"agentCliCompatibility": {
|
|
4
4
|
"claude": {
|
|
5
5
|
"range": ">=2.1.268 <2.2.0",
|
|
@@ -12,6 +12,6 @@
|
|
|
12
12
|
"exclusiveMaximum": "0.155.0"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
|
-
"sourceCommit": "
|
|
15
|
+
"sourceCommit": "071684f39d95c8ad6074da0ed9990576befb51c6",
|
|
16
16
|
"dirty": false
|
|
17
17
|
}
|
package/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var cc=Object.defineProperty;var C=(t,e)=>()=>(t&&(e=t(t=0)),e);var Nr=(t,e)=>{for(var n in e)cc(t,n,{get:e[n],enumerable:!0})};var Ys=C(()=>{});function uc(t){let e=dc.exec(t);return e?{repo:e[1],number:Number(e[2])}:null}function Dn(t){let e=uc(t);return e?{url:t,number:e.number,repo:e.repo,status:"open",checks:"unknown"}:null}var dc,Zs=C(()=>{dc=/^https:\/\/github\.com\/([\w.-]+\/[\w.-]+)\/pull\/(\d+)/});var Or,Qs=C(()=>{Or={claude:"acceptEdits",codex:"workspace-write"}});var ei=C(()=>{});var E,ti=C(()=>{E={productName:"Palmagent",displayName:"PalmAgent",packageName:"palmagent",cliName:"palmagent",unitBase:"palmagent",stateDirName:"palmagent"}});var et,Dr=C(()=>{et={claude:{range:">=2.1.268 <2.2.0",minimum:"2.1.268",exclusiveMaximum:"2.2.0"},codex:{range:">=0.154.0 <0.155.0",minimum:"0.154.0",exclusiveMaximum:"0.155.0"}}});function ni(t,e){let n=o=>/^\d+\.\d+\.\d+$/.test(o)?o.split(".").map(Number):void 0,r=n(e);if(!r)return!1;let s=o=>{let a=n(o);for(let c=0;c<3;c++)if(r[c]!==a[c])return r[c]-a[c];return 0},i=et[t];return s(i.minimum)>=0&&s(i.exclusiveMaximum)<0}var ri=C(()=>{Dr();Dr()});var P,Pr,y,ge,Xt=C(()=>{(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{let i={};for(let o of s)i[o]=o;return i},t.getValidEnumValues=s=>{let i=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(let a of i)o[a]=s[a];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=(s,i)=>{for(let o of s)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(P||(P={}));(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Pr||(Pr={}));y=P.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ge=t=>{switch(typeof t){case"undefined":return y.undefined;case"string":return y.string;case"number":return Number.isNaN(t)?y.nan:y.number;case"boolean":return y.boolean;case"function":return y.function;case"bigint":return y.bigint;case"symbol":return y.symbol;case"object":return Array.isArray(t)?y.array:t===null?y.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?y.promise:typeof Map<"u"&&t instanceof Map?y.map:typeof Set<"u"&&t instanceof Set?y.set:typeof Date<"u"&&t instanceof Date?y.date:y.object;default:return y.unknown}}});var h,pc,Z,Pn=C(()=>{Xt();h=P.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"]),pc=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Z=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){let n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,c=0;for(;c<o.path.length;){let u=o.path[c];c===o.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(n(o))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return s(this),r}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,P.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};Z.create=t=>new Z(t)});var fc,we,Lr=C(()=>{Pn();Xt();fc=(t,e)=>{let n;switch(t.code){case h.invalid_type:t.received===y.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case h.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,P.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:n=`Unrecognized key(s) in object: ${P.joinValues(t.keys,", ")}`;break;case h.invalid_union:n="Invalid input";break;case h.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${P.joinValues(t.options)}`;break;case h.invalid_enum_value:n=`Invalid enum value. Expected ${P.joinValues(t.options)}, received '${t.received}'`;break;case h.invalid_arguments:n="Invalid function arguments";break;case h.invalid_return_type:n="Invalid function return type";break;case h.invalid_date:n="Invalid date";break;case h.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:P.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case h.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case h.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case h.custom:n="Invalid input";break;case h.invalid_intersection_types:n="Intersection results could not be merged";break;case h.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case h.not_finite:n="Number must be finite";break;default:n=e.defaultError,P.assertNever(t)}return{message:n}},we=fc});function hc(t){si=t}function Rt(){return si}var si,Ln=C(()=>{Lr();si=we});function g(t,e){let n=Rt(),r=Kt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===we?void 0:we].filter(s=>!!s)});t.common.issues.push(r)}var Kt,mc,z,w,tt,X,Un,$n,$e,At,Ur=C(()=>{Ln();Lr();Kt=t=>{let{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="",c=r.filter(u=>!!u).slice().reverse();for(let u of c)a=u(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}},mc=[];z=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let s of n){if(s.status==="aborted")return w;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let s of n){let i=await s.key,o=await s.value;r.push({key:i,value:o})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let s of n){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return w;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}},w=Object.freeze({status:"aborted"}),tt=t=>({status:"dirty",value:t}),X=t=>({status:"valid",value:t}),Un=t=>t.status==="aborted",$n=t=>t.status==="dirty",$e=t=>t.status==="valid",At=t=>typeof Promise<"u"&&t instanceof Promise});var ii=C(()=>{});var v,oi=C(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(v||(v={}))});function R(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{let{message:c}=t;return o.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:c??n??a.defaultError}},description:s}}function ui(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function Oc(t){return new RegExp(`^${ui(t)}$`)}function li(t){let e=`${di}T${ui(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Dc(t,e){return!!((e==="v4"||!e)&&kc.test(t)||(e==="v6"||!e)&&Rc.test(t))}function Pc(t,e){if(!wc.test(t))return!1;try{let[n]=t.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Lc(t,e){return!!((e==="v4"||!e)&&Tc.test(t)||(e==="v6"||!e)&&Ac.test(t))}function Uc(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}function It(t){if(t instanceof Q){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=ie.create(It(r))}return new Q({...t._def,shape:()=>e})}else return t instanceof Se?new Se({...t._def,type:It(t.element)}):t instanceof ie?ie.create(It(t.unwrap())):t instanceof be?be.create(It(t.unwrap())):t instanceof ye?ye.create(t.items.map(e=>It(e))):t}function Mr(t,e){let n=ge(t),r=ge(e);if(t===e)return{valid:!0,data:t};if(n===y.object&&r===y.object){let s=P.objectKeys(e),i=P.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(let a of i){let c=Mr(t[a],e[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(n===y.array&&r===y.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let o=t[i],a=e[i],c=Mr(o,a);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return n===y.date&&r===y.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function pi(t,e){return new pt({values:t,typeName:x.ZodEnum,...R(e)})}function ci(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function fi(t,e={},n){return t?je.create().superRefine((r,s)=>{let i=t(r);if(i instanceof Promise)return i.then(o=>{if(!o){let a=ci(e,r),c=a.fatal??n??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!i){let o=ci(e,r),a=o.fatal??n??!0;s.addIssue({code:"custom",...o,fatal:a})}}):je.create()}var oe,ai,I,gc,yc,bc,vc,Ec,wc,_c,xc,Sc,$r,kc,Tc,Rc,Ac,Ic,Cc,di,Nc,Me,nt,rt,st,it,Ct,ot,at,je,xe,le,Nt,Se,Q,ct,_e,Mn,dt,ye,jn,Ot,Dt,Hn,ut,lt,pt,ft,He,ae,ie,be,ht,mt,Pt,$c,Yt,Zt,gt,Mc,x,jc,hi,mi,Hc,qc,gi,Fc,Bc,Wc,Vc,Gc,zc,Jc,Xc,Kc,Yc,Zc,Qc,ed,td,nd,rd,sd,id,od,ad,cd,dd,ud,ld,pd,fd,hd,md,gd,yd,bd,vd,Ed,wd,yi=C(()=>{Pn();Ln();oi();Ur();Xt();oe=class{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=s}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}},ai=(t,e)=>{if($e(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 n=new Z(t.common.issues);return this._error=n,this._error}}};I=class{get description(){return this._def.description}_getType(e){return ge(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:ge(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new z,ctx:{common:e.parent.common,data:e.data,parsedType:ge(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(At(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ge(e)},s=this._parseSync({data:e,path:r.path,parent:r});return ai(r,s)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ge(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return $e(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>$e(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ge(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(At(s)?s:Promise.resolve(s));return ai(r,i)}refine(e,n){let r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{let o=e(s),a=()=>i.addIssue({code:h.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new ae({schema:this,typeName:x.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:n=>this["~validate"](n)}}optional(){return ie.create(this,this._def)}nullable(){return be.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Se.create(this)}promise(){return He.create(this,this._def)}or(e){return ct.create([this,e],this._def)}and(e){return dt.create(this,e,this._def)}transform(e){return new ae({...R(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new ht({...R(this._def),innerType:this,defaultValue:n,typeName:x.ZodDefault})}brand(){return new Yt({typeName:x.ZodBranded,type:this,...R(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new mt({...R(this._def),innerType:this,catchValue:n,typeName:x.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Zt.create(this,e)}readonly(){return gt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},gc=/^c[^\s-]{8,}$/i,yc=/^[0-9a-z]+$/,bc=/^[0-9A-HJKMNP-TV-Z]{26}$/i,vc=/^[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,Ec=/^[a-z0-9_-]{21}$/i,wc=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,_c=/^[-+]?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)?)??$/,xc=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Sc="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",kc=/^(?:(?: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])$/,Tc=/^(?:(?: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])$/,Rc=/^(([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]))$/,Ac=/^(([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])$/,Ic=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Cc=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,di="((\\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])))",Nc=new RegExp(`^${di}$`);Me=class t extends I{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y.string){let i=this._getOrReturnCtx(e);return g(i,{code:h.invalid_type,expected:y.string,received:i.parsedType}),w}let r=new z,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:h.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:h.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(e,s),o?g(s,{code:h.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&g(s,{code:h.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")xc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"email",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")$r||($r=new RegExp(Sc,"u")),$r.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"emoji",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")vc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"uuid",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Ec.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"nanoid",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")gc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"cuid",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")yc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"cuid2",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")bc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"ulid",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),g(s,{validation:"url",code:h.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"regex",code:h.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),g(s,{code:h.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),g(s,{code:h.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),g(s,{code:h.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?li(i).test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{code:h.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Nc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{code:h.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Oc(i).test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{code:h.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?_c.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"duration",code:h.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Dc(e.data,i.version)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"ip",code:h.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?Pc(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"jwt",code:h.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Lc(e.data,i.version)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"cidr",code:h.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?Ic.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"base64",code:h.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Cc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"base64url",code:h.invalid_string,message:i.message}),r.dirty()):P.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:h.invalid_string,...v.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...v.errToObj(e)})}url(e){return this._addCheck({kind:"url",...v.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...v.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...v.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...v.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...v.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...v.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...v.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...v.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...v.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...v.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...v.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...v.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,...v.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,...v.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...v.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...v.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...v.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...v.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...v.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...v.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...v.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...v.errToObj(n)})}nonempty(e){return this.min(1,v.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 n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Me.create=t=>new Me({checks:[],typeName:x.ZodString,coerce:t?.coerce??!1,...R(t)});nt=class t extends I{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)!==y.number){let i=this._getOrReturnCtx(e);return g(i,{code:h.invalid_type,expected:y.number,received:i.parsedType}),w}let r,s=new z;for(let i of this._def.checks)i.kind==="int"?P.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),g(r,{code:h.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:h.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:h.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Uc(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),g(r,{code:h.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),g(r,{code:h.not_finite,message:i.message}),s.dirty()):P.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,v.toString(n))}gt(e,n){return this.setLimit("min",e,!1,v.toString(n))}lte(e,n){return this.setLimit("max",e,!0,v.toString(n))}lt(e,n){return this.setLimit("max",e,!1,v.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:v.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:v.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:v.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:v.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:v.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:v.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&P.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};nt.create=t=>new nt({checks:[],typeName:x.ZodNumber,coerce:t?.coerce||!1,...R(t)});rt=class t extends I{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)!==y.bigint)return this._getInvalidInput(e);let r,s=new z;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:h.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:h.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),g(r,{code:h.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):P.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return g(n,{code:h.invalid_type,expected:y.bigint,received:n.parsedType}),w}gte(e,n){return this.setLimit("min",e,!0,v.toString(n))}gt(e,n){return this.setLimit("min",e,!1,v.toString(n))}lte(e,n){return this.setLimit("max",e,!0,v.toString(n))}lt(e,n){return this.setLimit("max",e,!1,v.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:v.toString(s)}]})}_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:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:v.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};rt.create=t=>new rt({checks:[],typeName:x.ZodBigInt,coerce:t?.coerce??!1,...R(t)});st=class extends I{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){let r=this._getOrReturnCtx(e);return g(r,{code:h.invalid_type,expected:y.boolean,received:r.parsedType}),w}return X(e.data)}};st.create=t=>new st({typeName:x.ZodBoolean,coerce:t?.coerce||!1,...R(t)});it=class t extends I{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y.date){let i=this._getOrReturnCtx(e);return g(i,{code:h.invalid_type,expected:y.date,received:i.parsedType}),w}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return g(i,{code:h.invalid_date}),w}let r=new z,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:h.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:h.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):P.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:v.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:v.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};it.create=t=>new it({checks:[],coerce:t?.coerce||!1,typeName:x.ZodDate,...R(t)});Ct=class extends I{_parse(e){if(this._getType(e)!==y.symbol){let r=this._getOrReturnCtx(e);return g(r,{code:h.invalid_type,expected:y.symbol,received:r.parsedType}),w}return X(e.data)}};Ct.create=t=>new Ct({typeName:x.ZodSymbol,...R(t)});ot=class extends I{_parse(e){if(this._getType(e)!==y.undefined){let r=this._getOrReturnCtx(e);return g(r,{code:h.invalid_type,expected:y.undefined,received:r.parsedType}),w}return X(e.data)}};ot.create=t=>new ot({typeName:x.ZodUndefined,...R(t)});at=class extends I{_parse(e){if(this._getType(e)!==y.null){let r=this._getOrReturnCtx(e);return g(r,{code:h.invalid_type,expected:y.null,received:r.parsedType}),w}return X(e.data)}};at.create=t=>new at({typeName:x.ZodNull,...R(t)});je=class extends I{constructor(){super(...arguments),this._any=!0}_parse(e){return X(e.data)}};je.create=t=>new je({typeName:x.ZodAny,...R(t)});xe=class extends I{constructor(){super(...arguments),this._unknown=!0}_parse(e){return X(e.data)}};xe.create=t=>new xe({typeName:x.ZodUnknown,...R(t)});le=class extends I{_parse(e){let n=this._getOrReturnCtx(e);return g(n,{code:h.invalid_type,expected:y.never,received:n.parsedType}),w}};le.create=t=>new le({typeName:x.ZodNever,...R(t)});Nt=class extends I{_parse(e){if(this._getType(e)!==y.undefined){let r=this._getOrReturnCtx(e);return g(r,{code:h.invalid_type,expected:y.void,received:r.parsedType}),w}return X(e.data)}};Nt.create=t=>new Nt({typeName:x.ZodVoid,...R(t)});Se=class t extends I{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==y.array)return g(n,{code:h.invalid_type,expected:y.array,received:n.parsedType}),w;if(s.exactLength!==null){let o=n.data.length>s.exactLength.value,a=n.data.length<s.exactLength.value;(o||a)&&(g(n,{code:o?h.too_big:h.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(g(n,{code:h.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(g(n,{code:h.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>s.type._parseAsync(new oe(n,o,n.path,a)))).then(o=>z.mergeArray(r,o));let i=[...n.data].map((o,a)=>s.type._parseSync(new oe(n,o,n.path,a)));return z.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:v.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:v.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:v.toString(n)}})}nonempty(e){return this.min(1,e)}};Se.create=(t,e)=>new Se({type:t,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...R(e)});Q=class t extends I{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(),n=P.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==y.object){let u=this._getOrReturnCtx(e);return g(u,{code:h.invalid_type,expected:y.object,received:u.parsedType}),w}let{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof le&&this._def.unknownKeys==="strip"))for(let u in s.data)o.includes(u)||a.push(u);let c=[];for(let u of o){let l=i[u],p=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new oe(s,p,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof le){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")a.length>0&&(g(s,{code:h.unrecognized_keys,keys:a}),r.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 p=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new oe(s,p,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let p=await l.key,f=await l.value;u.push({key:p,value:f,alwaysSet:l.alwaysSet})}return u}).then(u=>z.mergeObjectSync(r,u)):z.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return v.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:v.errToObj(e).message??s}:{message:s}}}:{}})}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:x.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of P.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of P.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return It(this)}partial(e){let n={};for(let r of P.objectKeys(this.shape)){let s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of P.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof ie;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return pi(P.objectKeys(this.shape))}};Q.create=(t,e)=>new Q({shape:()=>t,unknownKeys:"strip",catchall:le.create(),typeName:x.ZodObject,...R(e)});Q.strictCreate=(t,e)=>new Q({shape:()=>t,unknownKeys:"strict",catchall:le.create(),typeName:x.ZodObject,...R(e)});Q.lazycreate=(t,e)=>new Q({shape:t,unknownKeys:"strip",catchall:le.create(),typeName:x.ZodObject,...R(e)});ct=class extends I{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(let a of i)if(a.result.status==="valid")return a.result;for(let a of i)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(a=>new Z(a.ctx.common.issues));return g(n,{code:h.invalid_union,unionErrors:o}),w}if(n.common.async)return Promise.all(r.map(async i=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let c of r){let u={...n,common:{...n.common,issues:[]},parent:null},l=c._parseSync({data:n.data,path:n.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!i&&(i={result:l,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(c=>new Z(c));return g(n,{code:h.invalid_union,unionErrors:a}),w}}get options(){return this._def.options}};ct.create=(t,e)=>new ct({options:t,typeName:x.ZodUnion,...R(e)});_e=t=>t instanceof ut?_e(t.schema):t instanceof ae?_e(t.innerType()):t instanceof lt?[t.value]:t instanceof pt?t.options:t instanceof ft?P.objectValues(t.enum):t instanceof ht?_e(t._def.innerType):t instanceof ot?[void 0]:t instanceof at?[null]:t instanceof ie?[void 0,..._e(t.unwrap())]:t instanceof be?[null,..._e(t.unwrap())]:t instanceof Yt||t instanceof gt?_e(t.unwrap()):t instanceof mt?_e(t._def.innerType):[],Mn=class t extends I{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.object)return g(n,{code:h.invalid_type,expected:y.object,received:n.parsedType}),w;let r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(g(n,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),w)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let s=new Map;for(let i of n){let o=_e(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,i)}}return new t({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...R(r)})}};dt=class extends I{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(Un(i)||Un(o))return w;let a=Mr(i.value,o.value);return a.valid?(($n(i)||$n(o))&&n.dirty(),{status:n.value,value:a.data}):(g(r,{code:h.invalid_intersection_types}),w)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};dt.create=(t,e,n)=>new dt({left:t,right:e,typeName:x.ZodIntersection,...R(n)});ye=class t extends I{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.array)return g(r,{code:h.invalid_type,expected:y.array,received:r.parsedType}),w;if(r.data.length<this._def.items.length)return g(r,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),w;!this._def.rest&&r.data.length>this._def.items.length&&(g(r,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...r.data].map((o,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new oe(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>z.mergeArray(n,o)):z.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};ye.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ye({items:t,typeName:x.ZodTuple,rest:null,...R(e)})};jn=class t extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.object)return g(r,{code:h.invalid_type,expected:y.object,received:r.parsedType}),w;let s=[],i=this._def.keyType,o=this._def.valueType;for(let a in r.data)s.push({key:i._parse(new oe(r,a,r.path,a)),value:o._parse(new oe(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?z.mergeObjectAsync(n,s):z.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof I?new t({keyType:e,valueType:n,typeName:x.ZodRecord,...R(r)}):new t({keyType:Me.create(),valueType:e,typeName:x.ZodRecord,...R(n)})}},Ot=class extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.map)return g(r,{code:h.invalid_type,expected:y.map,received:r.parsedType}),w;let s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,c],u)=>({key:s._parse(new oe(r,a,r.path,[u,"key"])),value:i._parse(new oe(r,c,r.path,[u,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of o){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return w;(u.status==="dirty"||l.status==="dirty")&&n.dirty(),a.set(u.value,l.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let c of o){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return w;(u.status==="dirty"||l.status==="dirty")&&n.dirty(),a.set(u.value,l.value)}return{status:n.value,value:a}}}};Ot.create=(t,e,n)=>new Ot({valueType:e,keyType:t,typeName:x.ZodMap,...R(n)});Dt=class t extends I{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.set)return g(r,{code:h.invalid_type,expected:y.set,received:r.parsedType}),w;let s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(g(r,{code:h.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(g(r,{code:h.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());let i=this._def.valueType;function o(c){let u=new Set;for(let l of c){if(l.status==="aborted")return w;l.status==="dirty"&&n.dirty(),u.add(l.value)}return{status:n.value,value:u}}let a=[...r.data.values()].map((c,u)=>i._parse(new oe(r,c,r.path,u)));return r.common.async?Promise.all(a).then(c=>o(c)):o(a)}min(e,n){return new t({...this._def,minSize:{value:e,message:v.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:v.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};Dt.create=(t,e)=>new Dt({valueType:t,minSize:null,maxSize:null,typeName:x.ZodSet,...R(e)});Hn=class t extends I{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.function)return g(n,{code:h.invalid_type,expected:y.function,received:n.parsedType}),w;function r(a,c){return Kt({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Rt(),we].filter(u=>!!u),issueData:{code:h.invalid_arguments,argumentsError:c}})}function s(a,c){return Kt({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Rt(),we].filter(u=>!!u),issueData:{code:h.invalid_return_type,returnTypeError:c}})}let i={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof He){let a=this;return X(async function(...c){let u=new Z([]),l=await a._def.args.parseAsync(c,i).catch(_=>{throw u.addIssue(r(c,_)),u}),p=await Reflect.apply(o,this,l);return await a._def.returns._def.type.parseAsync(p,i).catch(_=>{throw u.addIssue(s(p,_)),u})})}else{let a=this;return X(function(...c){let u=a._def.args.safeParse(c,i);if(!u.success)throw new Z([r(c,u.error)]);let l=Reflect.apply(o,this,u.data),p=a._def.returns.safeParse(l,i);if(!p.success)throw new Z([s(l,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:ye.create(e).rest(xe.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,n,r){return new t({args:e||ye.create([]).rest(xe.create()),returns:n||xe.create(),typeName:x.ZodFunction,...R(r)})}},ut=class extends I{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};ut.create=(t,e)=>new ut({getter:t,typeName:x.ZodLazy,...R(e)});lt=class extends I{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return g(n,{received:n.data,code:h.invalid_literal,expected:this._def.value}),w}return{status:"valid",value:e.data}}get value(){return this._def.value}};lt.create=(t,e)=>new lt({value:t,typeName:x.ZodLiteral,...R(e)});pt=class t extends I{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return g(n,{expected:P.joinValues(r),received:n.parsedType,code:h.invalid_type}),w}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return g(n,{received:n.data,code:h.invalid_enum_value,options:r}),w}return X(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};pt.create=pi;ft=class extends I{_parse(e){let n=P.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==y.string&&r.parsedType!==y.number){let s=P.objectValues(n);return g(r,{expected:P.joinValues(s),received:r.parsedType,code:h.invalid_type}),w}if(this._cache||(this._cache=new Set(P.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=P.objectValues(n);return g(r,{received:r.data,code:h.invalid_enum_value,options:s}),w}return X(e.data)}get enum(){return this._def.values}};ft.create=(t,e)=>new ft({values:t,typeName:x.ZodNativeEnum,...R(e)});He=class extends I{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.promise&&n.common.async===!1)return g(n,{code:h.invalid_type,expected:y.promise,received:n.parsedType}),w;let r=n.parsedType===y.promise?n.data:Promise.resolve(n.data);return X(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};He.create=(t,e)=>new He({type:t,typeName:x.ZodPromise,...R(e)});ae=class extends I{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{g(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return w;let c=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return c.status==="aborted"?w:c.status==="dirty"?tt(c.value):n.value==="dirty"?tt(c.value):c});{if(n.value==="aborted")return w;let a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?w:a.status==="dirty"?tt(a.value):n.value==="dirty"?tt(a.value):a}}if(s.type==="refinement"){let o=a=>{let c=s.refinement(a,i);if(r.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(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?w:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?w:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!$e(o))return w;let a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>$e(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:n.value,value:a})):w);P.assertNever(s)}};ae.create=(t,e,n)=>new ae({schema:t,typeName:x.ZodEffects,effect:e,...R(n)});ae.createWithPreprocess=(t,e,n)=>new ae({schema:e,effect:{type:"preprocess",transform:t},typeName:x.ZodEffects,...R(n)});ie=class extends I{_parse(e){return this._getType(e)===y.undefined?X(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ie.create=(t,e)=>new ie({innerType:t,typeName:x.ZodOptional,...R(e)});be=class extends I{_parse(e){return this._getType(e)===y.null?X(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};be.create=(t,e)=>new be({innerType:t,typeName:x.ZodNullable,...R(e)});ht=class extends I{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===y.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};ht.create=(t,e)=>new ht({innerType:t,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...R(e)});mt=class extends I{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return At(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Z(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Z(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};mt.create=(t,e)=>new mt({innerType:t,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...R(e)});Pt=class extends I{_parse(e){if(this._getType(e)!==y.nan){let r=this._getOrReturnCtx(e);return g(r,{code:h.invalid_type,expected:y.nan,received:r.parsedType}),w}return{status:"valid",value:e.data}}};Pt.create=t=>new Pt({typeName:x.ZodNaN,...R(t)});$c=Symbol("zod_brand"),Yt=class extends I{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},Zt=class t extends I{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?w:i.status==="dirty"?(n.dirty(),tt(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{let s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?w:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:x.ZodPipeline})}},gt=class extends I{_parse(e){let n=this._def.innerType._parse(e),r=s=>($e(s)&&(s.value=Object.freeze(s.value)),s);return At(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};gt.create=(t,e)=>new gt({innerType:t,typeName:x.ZodReadonly,...R(e)});Mc={object:Q.lazycreate};(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"})(x||(x={}));jc=(t,e={message:`Input not instance of ${t.name}`})=>fi(n=>n instanceof t,e),hi=Me.create,mi=nt.create,Hc=Pt.create,qc=rt.create,gi=st.create,Fc=it.create,Bc=Ct.create,Wc=ot.create,Vc=at.create,Gc=je.create,zc=xe.create,Jc=le.create,Xc=Nt.create,Kc=Se.create,Yc=Q.create,Zc=Q.strictCreate,Qc=ct.create,ed=Mn.create,td=dt.create,nd=ye.create,rd=jn.create,sd=Ot.create,id=Dt.create,od=Hn.create,ad=ut.create,cd=lt.create,dd=pt.create,ud=ft.create,ld=He.create,pd=ae.create,fd=ie.create,hd=be.create,md=ae.createWithPreprocess,gd=Zt.create,yd=()=>hi().optional(),bd=()=>mi().optional(),vd=()=>gi().optional(),Ed={string:t=>Me.create({...t,coerce:!0}),number:t=>nt.create({...t,coerce:!0}),boolean:t=>st.create({...t,coerce:!0}),bigint:t=>rt.create({...t,coerce:!0}),date:t=>it.create({...t,coerce:!0})},wd=w});var d={};Nr(d,{BRAND:()=>$c,DIRTY:()=>tt,EMPTY_PATH:()=>mc,INVALID:()=>w,NEVER:()=>wd,OK:()=>X,ParseStatus:()=>z,Schema:()=>I,ZodAny:()=>je,ZodArray:()=>Se,ZodBigInt:()=>rt,ZodBoolean:()=>st,ZodBranded:()=>Yt,ZodCatch:()=>mt,ZodDate:()=>it,ZodDefault:()=>ht,ZodDiscriminatedUnion:()=>Mn,ZodEffects:()=>ae,ZodEnum:()=>pt,ZodError:()=>Z,ZodFirstPartyTypeKind:()=>x,ZodFunction:()=>Hn,ZodIntersection:()=>dt,ZodIssueCode:()=>h,ZodLazy:()=>ut,ZodLiteral:()=>lt,ZodMap:()=>Ot,ZodNaN:()=>Pt,ZodNativeEnum:()=>ft,ZodNever:()=>le,ZodNull:()=>at,ZodNullable:()=>be,ZodNumber:()=>nt,ZodObject:()=>Q,ZodOptional:()=>ie,ZodParsedType:()=>y,ZodPipeline:()=>Zt,ZodPromise:()=>He,ZodReadonly:()=>gt,ZodRecord:()=>jn,ZodSchema:()=>I,ZodSet:()=>Dt,ZodString:()=>Me,ZodSymbol:()=>Ct,ZodTransformer:()=>ae,ZodTuple:()=>ye,ZodType:()=>I,ZodUndefined:()=>ot,ZodUnion:()=>ct,ZodUnknown:()=>xe,ZodVoid:()=>Nt,addIssueToContext:()=>g,any:()=>Gc,array:()=>Kc,bigint:()=>qc,boolean:()=>gi,coerce:()=>Ed,custom:()=>fi,date:()=>Fc,datetimeRegex:()=>li,defaultErrorMap:()=>we,discriminatedUnion:()=>ed,effect:()=>pd,enum:()=>dd,function:()=>od,getErrorMap:()=>Rt,getParsedType:()=>ge,instanceof:()=>jc,intersection:()=>td,isAborted:()=>Un,isAsync:()=>At,isDirty:()=>$n,isValid:()=>$e,late:()=>Mc,lazy:()=>ad,literal:()=>cd,makeIssue:()=>Kt,map:()=>sd,nan:()=>Hc,nativeEnum:()=>ud,never:()=>Jc,null:()=>Vc,nullable:()=>hd,number:()=>mi,object:()=>Yc,objectUtil:()=>Pr,oboolean:()=>vd,onumber:()=>bd,optional:()=>fd,ostring:()=>yd,pipeline:()=>gd,preprocess:()=>md,promise:()=>ld,quotelessJson:()=>pc,record:()=>rd,set:()=>id,setErrorMap:()=>hc,strictObject:()=>Zc,string:()=>hi,symbol:()=>Bc,transformer:()=>pd,tuple:()=>nd,undefined:()=>Wc,union:()=>Qc,unknown:()=>zc,util:()=>P,void:()=>Xc});var jr=C(()=>{Ln();Ur();ii();Xt();yi();Pn()});var pe=C(()=>{jr();jr()});var qe,Hr,qn,rh,qr,Fr,_d,sh,yt=C(()=>{"use strict";pe();qe=d.enum(["stable","preview"]),Hr=d.object({schemaVersion:d.literal(1),status:d.enum(["applying","succeeded","failed","deferred"]),previousVersion:d.string(),targetVersion:d.string(),reason:d.string(),checkedAt:d.string()}),qn=d.union([d.object({channel:qe}).strict(),d.object({autoUpdate:d.boolean()}).strict()]),rh=d.union([d.object({action:d.enum(["visit","check"])}).strict(),d.object({action:d.literal("install"),version:d.string().min(1).max(100)}).strict()]),qr=d.object({channel:qe,currentVersion:d.string(),targetVersion:d.string().nullable(),checkedAt:d.string().datetime(),eligible:d.boolean(),error:d.boolean()}),Fr=d.object({id:d.string().uuid(),channel:qe,currentVersion:d.string(),targetVersion:d.string(),automatic:d.boolean()}),_d=d.object({availability:d.enum(["available","not-installed","source-install","installation-mismatch","permission-required","authentication-required","unavailable"]),settings:d.object({channel:qe,autoUpdate:d.boolean(),independentExecutions:d.boolean().optional(),discovery:qr.nullable(),pending:Fr.nullable(),lastUpdate:Hr.nullable()}).nullable()}),sh=d.union([d.object({ok:d.literal(!0),state:_d}),d.object({ok:d.literal(!1),error:d.enum(["busy","unavailable","save-failed","stale-update","update-failed"])})])});var xd,Lt,Br,bi=C(()=>{pe();xd=d.string().trim().min(1).max(4096).refine(t=>!/[\x00-\x1f\x7f]/.test(t),"Path contains control characters"),Lt=d.array(xd).max(64),Br=d.discriminatedUnion("action",[d.object({action:d.literal("set"),paths:Lt}).strict(),d.object({action:d.literal("add"),paths:Lt.min(1)}).strict(),d.object({action:d.literal("remove"),paths:Lt.min(1)}).strict(),d.object({action:d.literal("reset")}).strict()])});var Wr,M,V,Qt,Fe,Vr,dh,uh,lh,ph,fh,hh,Sd,vi,Ei,mh,gh,kd,yh,bh,Td,Rd,vh,Ad,Eh,wh,_h,xh,Sh,kh,Th,wi,Rh,Ah,en=C(()=>{"use strict";pe();yt();bi();Wr=d.enum(["claude","codex"]),M=d.string(),V=M.min(1),Qt={permission:M.optional(),model:M.optional(),effort:M.optional()},Fe=d.object({mediaType:M,data:M}),Vr=d.array(Fe).optional(),dh=d.object({path:V,name:M.optional(),defaultBaseRef:M.optional()}),uh=d.object({repoId:V,agent:Wr,prompt:M,...Qt,title:M.optional(),images:Vr,isolate:d.boolean().optional()}),lh=d.object({prompt:M,images:Vr,...Qt}),ph=d.object({title:M.trim().min(1,"Enter a session name.").max(200,"Use 200 characters or fewer.").regex(/^[^\r\n]*$/,"Use a single line for the session name.")}),fh=d.object({text:M,images:Vr,...Qt}),hh=d.object({decision:d.enum(["approve","deny"]),scope:M.optional()}),Sd=d.object({question:M,selected:d.array(M),notes:M.optional()}),vi=d.object({requestId:V,answers:d.array(Sd),response:M.optional()}),Ei={preset:d.enum(["hourly","daily","weekly","weekdays","manual","custom"]).optional(),schedule:M.optional(),hour:d.number().int().min(0).max(23).optional(),dayOfWeek:d.number().int().min(0).max(6).optional()},mh=d.object({repoId:V,agent:Wr,prompt:V,...Ei,...Qt,title:M.optional()}),gh=d.object({prompt:V.optional(),...Ei,...Qt,title:M.optional(),enabled:d.boolean().optional()}),kd=d.object({endpoint:V,expirationTime:d.number().nullable().optional(),keys:d.record(M).optional()}),yh=d.object({subscription:kd}),bh=d.object({endpoint:V}),Td=d.object({agent:Wr,sessionId:V,cwd:V,home:V,waitPid:d.number().int().positive()}),Rd=d.enum(["queued","running","awaiting_approval","awaiting_input","idle","archived","failed","cancelled"]),vh=d.object({status:Rd.optional()}),Ad=d.coerce.number().int().min(1).max(Number.MAX_SAFE_INTEGER),Eh=d.object({before:Ad}),wh=d.object({task:M.optional(),lastEventId:M.optional(),tail:d.literal("1").optional(),snapshots:d.literal("1").optional()}),_h=d.object({path:M.optional()}),xh=d.object({refresh:d.enum(["0","1"]).optional()}),Sh=d.object({id:V}),kh=d.object({}),Th=d.object({token:M.optional()}),wi={id:V,rawId:V,type:d.literal("public-key"),authenticatorAttachment:d.enum(["platform","cross-platform"]).optional(),clientExtensionResults:d.object({}).passthrough()},Rh=d.object({...wi,response:d.object({clientDataJSON:V,authenticatorData:V,signature:V,userHandle:M.optional()})}),Ah=d.object({response:d.object({...wi,response:d.object({clientDataJSON:V,attestationObject:V,transports:d.array(d.enum(["ble","cable","hybrid","internal","nfc","smart-card","usb"])).optional(),publicKeyAlgorithm:d.number().optional(),publicKey:M.optional(),authenticatorData:M.optional()})}),label:M.optional()})});var Id,Ph,Lh,_i=C(()=>{pe();en();Id=d.object({model:d.string().optional(),effort:d.string().optional(),permission:d.string().optional()}),Ph=d.object({clientMessageId:d.string().uuid(),mode:d.enum(["send","queue"]),text:d.string().trim().min(1).max(1e5),images:d.array(Fe).optional(),expectedRunId:d.string().nullable(),settings:Id.optional()}),Lh=d.discriminatedUnion("action",[d.object({action:d.literal("edit"),version:d.number().int(),token:d.string().uuid()}),d.object({action:d.literal("renew"),token:d.string().uuid()}),d.object({action:d.literal("save"),token:d.string().uuid(),version:d.number().int(),text:d.string().trim().min(1).max(1e5),images:d.array(Fe).optional()}),d.object({action:d.literal("release"),token:d.string().uuid()}),d.object({action:d.literal("delete"),version:d.number().int()}),d.object({action:d.literal("send"),version:d.number().int(),expectedRunId:d.string().nullable()})])});var ee=C(()=>{"use strict";Ys();Zs();Qs();ei();ti();ri();_i()});var ts=C(()=>{});import{homedir as Ji}from"node:os";import{join as bu}from"node:path";function bt(t){return t==="~"?Ji():t.startsWith("~/")?bu(Ji(),t.slice(2)):t}var Yn=C(()=>{});import{homedir as vu}from"node:os";import{existsSync as Xi}from"node:fs";import{dirname as Qi,join as Mt,resolve as vt}from"node:path";import{fileURLToPath as Eu}from"node:url";function Su(t){let e={};for(let[n,r]of Object.entries(t))r!==void 0&&r!==""&&(e[n]=r);return e}var wu,_u,xu,L,eo,ns,rs,Ki,Yi,Zi,jt,an=C(()=>{pe();ee();Yn();wu=Qi(Eu(import.meta.url)),_u=t=>t==="localhost"||t==="::1"||/^127(?:\.\d{1,3}){3}$/.test(t),xu=d.object({PORT:d.coerce.number().int().positive().default(4e3),HOST:d.string().min(1).refine(_u,"HOST must be loopback; terminate public HTTPS at the reverse proxy").default("localhost"),DISPATCH_CONCURRENCY:d.coerce.number().int().min(1).default(8),SSE_KEEPALIVE_MS:d.coerce.number().int().positive().default(15e3),AUTH_SESSION_TTL_MS:d.coerce.number().int().positive().default(30*24*60*60*1e3),AUTH_COOKIE_NAME:d.string().min(1).default("palmagent_session"),AUTH_RP_ID:d.string().min(1).regex(/^[A-Za-z0-9.-]+$/,"AUTH_RP_ID must be a hostname without a scheme, path, or port").optional(),AUTH_RP_NAME:d.string().min(1).optional(),AUTH_ORIGIN:d.string().url().startsWith("https://","AUTH_ORIGIN must use https://").optional(),AUTH_ENABLED:d.string().optional(),AUTH_DISABLED:d.string().optional(),PUSH_SUBJECT:d.string().regex(/^(mailto:|https:\/\/)/,"PUSH_SUBJECT must be a mailto: or https:// URL").optional(),DISPATCHER_DATA_DIR:d.string().min(1).optional(),XDG_STATE_HOME:d.string().min(1).optional(),DISPATCHER_DB:d.string().min(1).optional(),VAPID_KEY_PATH:d.string().min(1).optional(),STATIC_DIR:d.string().min(1).optional(),REPO_ROOTS:d.string().optional(),GITHUB_TOKEN:d.string().min(1).optional(),RUNNER_SOCKET:d.string().min(1).optional(),EXECUTION_RELEASE:d.string().min(1).optional(),EXECUTION_NODE:d.string().min(1).optional(),CLAUDE_MODEL:d.string().min(1).optional(),CODEX_MODEL:d.string().min(1).optional(),CLAUDE_EFFORT:d.string().min(1).optional(),CODEX_EFFORT:d.string().min(1).optional(),CLAUDE_CONFIG_DIR:d.string().min(1).optional(),NODE_ENV:d.string().optional()}).passthrough();L=xu.parse(Su(process.env)),eo=L.AUTH_DISABLED==="1"?!1:L.AUTH_ENABLED==="1"?!0:L.NODE_ENV==="production",ns=L.AUTH_RP_ID??(eo?"":"localhost"),rs=L.DISPATCHER_DATA_DIR?vt(L.DISPATCHER_DATA_DIR):L.XDG_STATE_HOME?Mt(vt(L.XDG_STATE_HOME),E.stateDirName):Mt(vu(),".local","state",E.stateDirName),Ki=Mt(rs,"palmagent.db"),Yi=Mt(rs,"dispatcher.db"),Zi=L.DISPATCHER_DB?vt(L.DISPATCHER_DB):Xi(Ki)||!Xi(Yi)?Ki:Yi,jt={port:L.PORT,host:L.HOST,concurrency:L.DISPATCH_CONCURRENCY,dataDir:rs,dbPath:Zi,keepAliveMs:L.SSE_KEEPALIVE_MS,claudeModel:L.CLAUDE_MODEL,codexModel:L.CODEX_MODEL,claudeEffort:L.CLAUDE_EFFORT,codexEffort:L.CODEX_EFFORT,claudeConfigDir:L.CLAUDE_CONFIG_DIR?vt(bt(L.CLAUDE_CONFIG_DIR)):void 0,vapidKeyPath:L.VAPID_KEY_PATH?vt(L.VAPID_KEY_PATH):Mt(Qi(Zi),"vapid.json"),pushSubject:L.PUSH_SUBJECT,staticDir:L.STATIC_DIR?vt(L.STATIC_DIR):Mt(wu,"..","..","web","dist"),repoRoots:(L.REPO_ROOTS??"").split(":").filter(Boolean).map(t=>vt(bt(t))),runnerSocket:L.RUNNER_SOCKET,executionRelease:L.EXECUTION_RELEASE,executionNode:L.EXECUTION_NODE,githubToken:L.GITHUB_TOKEN,authEnabled:eo,rpId:ns,rpName:L.AUTH_RP_NAME??E.displayName,authOrigin:L.AUTH_ORIGIN??(ns?`https://${ns}`:""),sessionTtlMs:L.AUTH_SESSION_TTL_MS,cookieName:L.AUTH_COOKIE_NAME,nodeEnv:L.NODE_ENV}});var ss=C(()=>{});import{createHash as Tu}from"node:crypto";import{readFileSync as to,readdirSync as hy,realpathSync as my,statSync as gy}from"node:fs";function is(t){if(!Number.isSafeInteger(t)||t<=1)throw new Error("A valid local CLI process id is required");try{let e=to(`/proc/${t}/stat`,"utf8"),n=e.slice(e.lastIndexOf(")")+2).split(" ");return n[0]==="Z"?void 0:`${to("/proc/sys/kernel/random/boot_id","utf8").trim()}:${n[19]}`}catch(e){if(e.code==="ENOENT")return;throw new Error("Cannot verify the local CLI process; ownership is retained")}}var Ru,Au,os=C(()=>{an();ss();Ru=t=>Tu("sha256").update(t).digest("hex");Au=Ru(Buffer.alloc(0))});var no=C(()=>{});function Nu({permission:t,model:e,effort:n,resumeId:r}){let s=["-p","--input-format","stream-json","--output-format","stream-json","--verbose","--include-partial-messages","--permission-mode",Cu(t),"--permission-prompt-tool","stdio"];return e&&s.push("--model",e),n&&s.push("--effort",n),r&&s.push("--resume",r),s}function Ou(t,e=[]){let n=e.map(r=>({type:"image",source:{type:"base64",media_type:r.mediaType,data:r.data}}));return n.push({type:"text",text:t}),{type:"user",message:{role:"user",content:n}}}var Iu,ro,Cu,Zn,so=C(()=>{ee();an();Iu=1500,ro={plan:"plan",acceptEdits:"acceptEdits",dontAsk:"dontAsk",bypassPermissions:"bypassPermissions",readonly:"plan","auto-edit":"acceptEdits",full:"bypassPermissions"},Cu=t=>ro[t??""]??ro[Or.claude];Zn=class{agent="claude";start(e,n,r){let{taskId:s,cwd:i,prompt:o,images:a,resumeId:c,permission:u,model:l,effort:p,reattach:f,resumeFromSeq:_,pendingInput:N}=e,b=Nu({permission:u,model:l,effort:p,resumeId:c});e.interactive&&b.push("--replay-user-messages");let k=c,q=e.providerHome??jt.claudeConfigDir,Tt=q?{CLAUDE_CONFIG_DIR:q}:void 0,S=f?r.attach(s,0):r.start({turnId:s,command:"claude",argv:b,cwd:i,env:Tt});if(!S)return n({taskId:s,kind:"status",sessionId:k,payload:{subtype:"reattach_failed"}}),{steer:()=>!1,interrupt:()=>!1,approve:()=>!1,answer:()=>!1,cancel:()=>{},done:Promise.resolve()};let H,A=F=>{H&&(clearTimeout(H.timer),H.resolve(F),H=void 0,O=!1)},U,O=!1,Ye,Ze,Ar=!1,Ks=0,Nn=new Map;f&&N&&Nn.set(N.requestId,{questions:N.questions});let Qe=F=>{S.writeStdin(JSON.stringify(F)+`
|
|
2
|
+
var cc=Object.defineProperty;var C=(t,e)=>()=>(t&&(e=t(t=0)),e);var Nr=(t,e)=>{for(var n in e)cc(t,n,{get:e[n],enumerable:!0})};var Ys=C(()=>{});function uc(t){let e=dc.exec(t);return e?{repo:e[1],number:Number(e[2])}:null}function Dn(t){let e=uc(t);return e?{url:t,number:e.number,repo:e.repo,status:"open",checks:"unknown"}:null}var dc,Zs=C(()=>{dc=/^https:\/\/github\.com\/([\w.-]+\/[\w.-]+)\/pull\/(\d+)/});var Or,Qs=C(()=>{Or={claude:"acceptEdits",codex:"workspace-write"}});var ei=C(()=>{});var E,ti=C(()=>{E={productName:"Palmagent",displayName:"PalmAgent",packageName:"palmagent",cliName:"palmagent",unitBase:"palmagent",stateDirName:"palmagent"}});var et,Dr=C(()=>{et={claude:{range:">=2.1.268 <2.2.0",minimum:"2.1.268",exclusiveMaximum:"2.2.0"},codex:{range:">=0.154.0 <0.155.0",minimum:"0.154.0",exclusiveMaximum:"0.155.0"}}});function ni(t,e){let n=o=>/^\d+\.\d+\.\d+$/.test(o)?o.split(".").map(Number):void 0,r=n(e);if(!r)return!1;let s=o=>{let a=n(o);for(let c=0;c<3;c++)if(r[c]!==a[c])return r[c]-a[c];return 0},i=et[t];return s(i.minimum)>=0&&s(i.exclusiveMaximum)<0}var ri=C(()=>{Dr();Dr()});var P,Pr,y,ge,Xt=C(()=>{(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{let i={};for(let o of s)i[o]=o;return i},t.getValidEnumValues=s=>{let i=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(let a of i)o[a]=s[a];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=(s,i)=>{for(let o of s)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(P||(P={}));(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Pr||(Pr={}));y=P.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ge=t=>{switch(typeof t){case"undefined":return y.undefined;case"string":return y.string;case"number":return Number.isNaN(t)?y.nan:y.number;case"boolean":return y.boolean;case"function":return y.function;case"bigint":return y.bigint;case"symbol":return y.symbol;case"object":return Array.isArray(t)?y.array:t===null?y.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?y.promise:typeof Map<"u"&&t instanceof Map?y.map:typeof Set<"u"&&t instanceof Set?y.set:typeof Date<"u"&&t instanceof Date?y.date:y.object;default:return y.unknown}}});var h,pc,Z,Pn=C(()=>{Xt();h=P.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"]),pc=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Z=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){let n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,c=0;for(;c<o.path.length;){let u=o.path[c];c===o.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(n(o))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return s(this),r}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,P.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};Z.create=t=>new Z(t)});var fc,we,Lr=C(()=>{Pn();Xt();fc=(t,e)=>{let n;switch(t.code){case h.invalid_type:t.received===y.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case h.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,P.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:n=`Unrecognized key(s) in object: ${P.joinValues(t.keys,", ")}`;break;case h.invalid_union:n="Invalid input";break;case h.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${P.joinValues(t.options)}`;break;case h.invalid_enum_value:n=`Invalid enum value. Expected ${P.joinValues(t.options)}, received '${t.received}'`;break;case h.invalid_arguments:n="Invalid function arguments";break;case h.invalid_return_type:n="Invalid function return type";break;case h.invalid_date:n="Invalid date";break;case h.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:P.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case h.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case h.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case h.custom:n="Invalid input";break;case h.invalid_intersection_types:n="Intersection results could not be merged";break;case h.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case h.not_finite:n="Number must be finite";break;default:n=e.defaultError,P.assertNever(t)}return{message:n}},we=fc});function hc(t){si=t}function Rt(){return si}var si,Ln=C(()=>{Lr();si=we});function g(t,e){let n=Rt(),r=Kt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===we?void 0:we].filter(s=>!!s)});t.common.issues.push(r)}var Kt,mc,z,w,tt,X,Un,$n,$e,At,Ur=C(()=>{Ln();Lr();Kt=t=>{let{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="",c=r.filter(u=>!!u).slice().reverse();for(let u of c)a=u(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}},mc=[];z=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let s of n){if(s.status==="aborted")return w;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let s of n){let i=await s.key,o=await s.value;r.push({key:i,value:o})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let s of n){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return w;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}},w=Object.freeze({status:"aborted"}),tt=t=>({status:"dirty",value:t}),X=t=>({status:"valid",value:t}),Un=t=>t.status==="aborted",$n=t=>t.status==="dirty",$e=t=>t.status==="valid",At=t=>typeof Promise<"u"&&t instanceof Promise});var ii=C(()=>{});var v,oi=C(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(v||(v={}))});function R(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{let{message:c}=t;return o.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:c??n??a.defaultError}},description:s}}function ui(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function Oc(t){return new RegExp(`^${ui(t)}$`)}function li(t){let e=`${di}T${ui(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Dc(t,e){return!!((e==="v4"||!e)&&kc.test(t)||(e==="v6"||!e)&&Rc.test(t))}function Pc(t,e){if(!wc.test(t))return!1;try{let[n]=t.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Lc(t,e){return!!((e==="v4"||!e)&&Tc.test(t)||(e==="v6"||!e)&&Ac.test(t))}function Uc(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}function It(t){if(t instanceof Q){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=ie.create(It(r))}return new Q({...t._def,shape:()=>e})}else return t instanceof Se?new Se({...t._def,type:It(t.element)}):t instanceof ie?ie.create(It(t.unwrap())):t instanceof be?be.create(It(t.unwrap())):t instanceof ye?ye.create(t.items.map(e=>It(e))):t}function Mr(t,e){let n=ge(t),r=ge(e);if(t===e)return{valid:!0,data:t};if(n===y.object&&r===y.object){let s=P.objectKeys(e),i=P.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(let a of i){let c=Mr(t[a],e[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(n===y.array&&r===y.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let o=t[i],a=e[i],c=Mr(o,a);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return n===y.date&&r===y.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function pi(t,e){return new pt({values:t,typeName:x.ZodEnum,...R(e)})}function ci(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function fi(t,e={},n){return t?je.create().superRefine((r,s)=>{let i=t(r);if(i instanceof Promise)return i.then(o=>{if(!o){let a=ci(e,r),c=a.fatal??n??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!i){let o=ci(e,r),a=o.fatal??n??!0;s.addIssue({code:"custom",...o,fatal:a})}}):je.create()}var oe,ai,I,gc,yc,bc,vc,Ec,wc,_c,xc,Sc,$r,kc,Tc,Rc,Ac,Ic,Cc,di,Nc,Me,nt,rt,st,it,Ct,ot,at,je,xe,le,Nt,Se,Q,ct,_e,Mn,dt,ye,jn,Ot,Dt,Hn,ut,lt,pt,ft,He,ae,ie,be,ht,mt,Pt,$c,Yt,Zt,gt,Mc,x,jc,hi,mi,Hc,qc,gi,Fc,Bc,Wc,Vc,Gc,zc,Jc,Xc,Kc,Yc,Zc,Qc,ed,td,nd,rd,sd,id,od,ad,cd,dd,ud,ld,pd,fd,hd,md,gd,yd,bd,vd,Ed,wd,yi=C(()=>{Pn();Ln();oi();Ur();Xt();oe=class{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=s}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}},ai=(t,e)=>{if($e(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 n=new Z(t.common.issues);return this._error=n,this._error}}};I=class{get description(){return this._def.description}_getType(e){return ge(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:ge(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new z,ctx:{common:e.parent.common,data:e.data,parsedType:ge(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(At(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ge(e)},s=this._parseSync({data:e,path:r.path,parent:r});return ai(r,s)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ge(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return $e(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>$e(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ge(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(At(s)?s:Promise.resolve(s));return ai(r,i)}refine(e,n){let r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{let o=e(s),a=()=>i.addIssue({code:h.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new ae({schema:this,typeName:x.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:n=>this["~validate"](n)}}optional(){return ie.create(this,this._def)}nullable(){return be.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Se.create(this)}promise(){return He.create(this,this._def)}or(e){return ct.create([this,e],this._def)}and(e){return dt.create(this,e,this._def)}transform(e){return new ae({...R(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new ht({...R(this._def),innerType:this,defaultValue:n,typeName:x.ZodDefault})}brand(){return new Yt({typeName:x.ZodBranded,type:this,...R(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new mt({...R(this._def),innerType:this,catchValue:n,typeName:x.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Zt.create(this,e)}readonly(){return gt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},gc=/^c[^\s-]{8,}$/i,yc=/^[0-9a-z]+$/,bc=/^[0-9A-HJKMNP-TV-Z]{26}$/i,vc=/^[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,Ec=/^[a-z0-9_-]{21}$/i,wc=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,_c=/^[-+]?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)?)??$/,xc=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Sc="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",kc=/^(?:(?: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])$/,Tc=/^(?:(?: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])$/,Rc=/^(([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]))$/,Ac=/^(([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])$/,Ic=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Cc=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,di="((\\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])))",Nc=new RegExp(`^${di}$`);Me=class t extends I{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y.string){let i=this._getOrReturnCtx(e);return g(i,{code:h.invalid_type,expected:y.string,received:i.parsedType}),w}let r=new z,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:h.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:h.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(e,s),o?g(s,{code:h.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&g(s,{code:h.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")xc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"email",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")$r||($r=new RegExp(Sc,"u")),$r.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"emoji",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")vc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"uuid",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Ec.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"nanoid",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")gc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"cuid",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")yc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"cuid2",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")bc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"ulid",code:h.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),g(s,{validation:"url",code:h.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"regex",code:h.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),g(s,{code:h.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),g(s,{code:h.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),g(s,{code:h.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?li(i).test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{code:h.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Nc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{code:h.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Oc(i).test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{code:h.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?_c.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"duration",code:h.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Dc(e.data,i.version)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"ip",code:h.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?Pc(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"jwt",code:h.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Lc(e.data,i.version)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"cidr",code:h.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?Ic.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"base64",code:h.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Cc.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"base64url",code:h.invalid_string,message:i.message}),r.dirty()):P.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:h.invalid_string,...v.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...v.errToObj(e)})}url(e){return this._addCheck({kind:"url",...v.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...v.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...v.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...v.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...v.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...v.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...v.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...v.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...v.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...v.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...v.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...v.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,...v.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,...v.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...v.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...v.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...v.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...v.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...v.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...v.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...v.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...v.errToObj(n)})}nonempty(e){return this.min(1,v.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 n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Me.create=t=>new Me({checks:[],typeName:x.ZodString,coerce:t?.coerce??!1,...R(t)});nt=class t extends I{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)!==y.number){let i=this._getOrReturnCtx(e);return g(i,{code:h.invalid_type,expected:y.number,received:i.parsedType}),w}let r,s=new z;for(let i of this._def.checks)i.kind==="int"?P.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),g(r,{code:h.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:h.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:h.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Uc(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),g(r,{code:h.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),g(r,{code:h.not_finite,message:i.message}),s.dirty()):P.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,v.toString(n))}gt(e,n){return this.setLimit("min",e,!1,v.toString(n))}lte(e,n){return this.setLimit("max",e,!0,v.toString(n))}lt(e,n){return this.setLimit("max",e,!1,v.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:v.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:v.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:v.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:v.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:v.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:v.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&P.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};nt.create=t=>new nt({checks:[],typeName:x.ZodNumber,coerce:t?.coerce||!1,...R(t)});rt=class t extends I{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)!==y.bigint)return this._getInvalidInput(e);let r,s=new z;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:h.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:h.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),g(r,{code:h.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):P.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return g(n,{code:h.invalid_type,expected:y.bigint,received:n.parsedType}),w}gte(e,n){return this.setLimit("min",e,!0,v.toString(n))}gt(e,n){return this.setLimit("min",e,!1,v.toString(n))}lte(e,n){return this.setLimit("max",e,!0,v.toString(n))}lt(e,n){return this.setLimit("max",e,!1,v.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:v.toString(s)}]})}_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:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:v.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};rt.create=t=>new rt({checks:[],typeName:x.ZodBigInt,coerce:t?.coerce??!1,...R(t)});st=class extends I{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){let r=this._getOrReturnCtx(e);return g(r,{code:h.invalid_type,expected:y.boolean,received:r.parsedType}),w}return X(e.data)}};st.create=t=>new st({typeName:x.ZodBoolean,coerce:t?.coerce||!1,...R(t)});it=class t extends I{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y.date){let i=this._getOrReturnCtx(e);return g(i,{code:h.invalid_type,expected:y.date,received:i.parsedType}),w}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return g(i,{code:h.invalid_date}),w}let r=new z,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:h.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:h.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):P.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:v.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:v.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};it.create=t=>new it({checks:[],coerce:t?.coerce||!1,typeName:x.ZodDate,...R(t)});Ct=class extends I{_parse(e){if(this._getType(e)!==y.symbol){let r=this._getOrReturnCtx(e);return g(r,{code:h.invalid_type,expected:y.symbol,received:r.parsedType}),w}return X(e.data)}};Ct.create=t=>new Ct({typeName:x.ZodSymbol,...R(t)});ot=class extends I{_parse(e){if(this._getType(e)!==y.undefined){let r=this._getOrReturnCtx(e);return g(r,{code:h.invalid_type,expected:y.undefined,received:r.parsedType}),w}return X(e.data)}};ot.create=t=>new ot({typeName:x.ZodUndefined,...R(t)});at=class extends I{_parse(e){if(this._getType(e)!==y.null){let r=this._getOrReturnCtx(e);return g(r,{code:h.invalid_type,expected:y.null,received:r.parsedType}),w}return X(e.data)}};at.create=t=>new at({typeName:x.ZodNull,...R(t)});je=class extends I{constructor(){super(...arguments),this._any=!0}_parse(e){return X(e.data)}};je.create=t=>new je({typeName:x.ZodAny,...R(t)});xe=class extends I{constructor(){super(...arguments),this._unknown=!0}_parse(e){return X(e.data)}};xe.create=t=>new xe({typeName:x.ZodUnknown,...R(t)});le=class extends I{_parse(e){let n=this._getOrReturnCtx(e);return g(n,{code:h.invalid_type,expected:y.never,received:n.parsedType}),w}};le.create=t=>new le({typeName:x.ZodNever,...R(t)});Nt=class extends I{_parse(e){if(this._getType(e)!==y.undefined){let r=this._getOrReturnCtx(e);return g(r,{code:h.invalid_type,expected:y.void,received:r.parsedType}),w}return X(e.data)}};Nt.create=t=>new Nt({typeName:x.ZodVoid,...R(t)});Se=class t extends I{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==y.array)return g(n,{code:h.invalid_type,expected:y.array,received:n.parsedType}),w;if(s.exactLength!==null){let o=n.data.length>s.exactLength.value,a=n.data.length<s.exactLength.value;(o||a)&&(g(n,{code:o?h.too_big:h.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(g(n,{code:h.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(g(n,{code:h.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>s.type._parseAsync(new oe(n,o,n.path,a)))).then(o=>z.mergeArray(r,o));let i=[...n.data].map((o,a)=>s.type._parseSync(new oe(n,o,n.path,a)));return z.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:v.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:v.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:v.toString(n)}})}nonempty(e){return this.min(1,e)}};Se.create=(t,e)=>new Se({type:t,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...R(e)});Q=class t extends I{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(),n=P.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==y.object){let u=this._getOrReturnCtx(e);return g(u,{code:h.invalid_type,expected:y.object,received:u.parsedType}),w}let{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof le&&this._def.unknownKeys==="strip"))for(let u in s.data)o.includes(u)||a.push(u);let c=[];for(let u of o){let l=i[u],p=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new oe(s,p,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof le){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")a.length>0&&(g(s,{code:h.unrecognized_keys,keys:a}),r.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 p=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new oe(s,p,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let p=await l.key,f=await l.value;u.push({key:p,value:f,alwaysSet:l.alwaysSet})}return u}).then(u=>z.mergeObjectSync(r,u)):z.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return v.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:v.errToObj(e).message??s}:{message:s}}}:{}})}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:x.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of P.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of P.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return It(this)}partial(e){let n={};for(let r of P.objectKeys(this.shape)){let s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of P.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof ie;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return pi(P.objectKeys(this.shape))}};Q.create=(t,e)=>new Q({shape:()=>t,unknownKeys:"strip",catchall:le.create(),typeName:x.ZodObject,...R(e)});Q.strictCreate=(t,e)=>new Q({shape:()=>t,unknownKeys:"strict",catchall:le.create(),typeName:x.ZodObject,...R(e)});Q.lazycreate=(t,e)=>new Q({shape:t,unknownKeys:"strip",catchall:le.create(),typeName:x.ZodObject,...R(e)});ct=class extends I{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(let a of i)if(a.result.status==="valid")return a.result;for(let a of i)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(a=>new Z(a.ctx.common.issues));return g(n,{code:h.invalid_union,unionErrors:o}),w}if(n.common.async)return Promise.all(r.map(async i=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let c of r){let u={...n,common:{...n.common,issues:[]},parent:null},l=c._parseSync({data:n.data,path:n.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!i&&(i={result:l,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(c=>new Z(c));return g(n,{code:h.invalid_union,unionErrors:a}),w}}get options(){return this._def.options}};ct.create=(t,e)=>new ct({options:t,typeName:x.ZodUnion,...R(e)});_e=t=>t instanceof ut?_e(t.schema):t instanceof ae?_e(t.innerType()):t instanceof lt?[t.value]:t instanceof pt?t.options:t instanceof ft?P.objectValues(t.enum):t instanceof ht?_e(t._def.innerType):t instanceof ot?[void 0]:t instanceof at?[null]:t instanceof ie?[void 0,..._e(t.unwrap())]:t instanceof be?[null,..._e(t.unwrap())]:t instanceof Yt||t instanceof gt?_e(t.unwrap()):t instanceof mt?_e(t._def.innerType):[],Mn=class t extends I{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.object)return g(n,{code:h.invalid_type,expected:y.object,received:n.parsedType}),w;let r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(g(n,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),w)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let s=new Map;for(let i of n){let o=_e(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,i)}}return new t({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...R(r)})}};dt=class extends I{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(Un(i)||Un(o))return w;let a=Mr(i.value,o.value);return a.valid?(($n(i)||$n(o))&&n.dirty(),{status:n.value,value:a.data}):(g(r,{code:h.invalid_intersection_types}),w)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};dt.create=(t,e,n)=>new dt({left:t,right:e,typeName:x.ZodIntersection,...R(n)});ye=class t extends I{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.array)return g(r,{code:h.invalid_type,expected:y.array,received:r.parsedType}),w;if(r.data.length<this._def.items.length)return g(r,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),w;!this._def.rest&&r.data.length>this._def.items.length&&(g(r,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...r.data].map((o,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new oe(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>z.mergeArray(n,o)):z.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};ye.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ye({items:t,typeName:x.ZodTuple,rest:null,...R(e)})};jn=class t extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.object)return g(r,{code:h.invalid_type,expected:y.object,received:r.parsedType}),w;let s=[],i=this._def.keyType,o=this._def.valueType;for(let a in r.data)s.push({key:i._parse(new oe(r,a,r.path,a)),value:o._parse(new oe(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?z.mergeObjectAsync(n,s):z.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof I?new t({keyType:e,valueType:n,typeName:x.ZodRecord,...R(r)}):new t({keyType:Me.create(),valueType:e,typeName:x.ZodRecord,...R(n)})}},Ot=class extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.map)return g(r,{code:h.invalid_type,expected:y.map,received:r.parsedType}),w;let s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,c],u)=>({key:s._parse(new oe(r,a,r.path,[u,"key"])),value:i._parse(new oe(r,c,r.path,[u,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of o){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return w;(u.status==="dirty"||l.status==="dirty")&&n.dirty(),a.set(u.value,l.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let c of o){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return w;(u.status==="dirty"||l.status==="dirty")&&n.dirty(),a.set(u.value,l.value)}return{status:n.value,value:a}}}};Ot.create=(t,e,n)=>new Ot({valueType:e,keyType:t,typeName:x.ZodMap,...R(n)});Dt=class t extends I{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.set)return g(r,{code:h.invalid_type,expected:y.set,received:r.parsedType}),w;let s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(g(r,{code:h.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(g(r,{code:h.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());let i=this._def.valueType;function o(c){let u=new Set;for(let l of c){if(l.status==="aborted")return w;l.status==="dirty"&&n.dirty(),u.add(l.value)}return{status:n.value,value:u}}let a=[...r.data.values()].map((c,u)=>i._parse(new oe(r,c,r.path,u)));return r.common.async?Promise.all(a).then(c=>o(c)):o(a)}min(e,n){return new t({...this._def,minSize:{value:e,message:v.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:v.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};Dt.create=(t,e)=>new Dt({valueType:t,minSize:null,maxSize:null,typeName:x.ZodSet,...R(e)});Hn=class t extends I{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.function)return g(n,{code:h.invalid_type,expected:y.function,received:n.parsedType}),w;function r(a,c){return Kt({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Rt(),we].filter(u=>!!u),issueData:{code:h.invalid_arguments,argumentsError:c}})}function s(a,c){return Kt({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Rt(),we].filter(u=>!!u),issueData:{code:h.invalid_return_type,returnTypeError:c}})}let i={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof He){let a=this;return X(async function(...c){let u=new Z([]),l=await a._def.args.parseAsync(c,i).catch(_=>{throw u.addIssue(r(c,_)),u}),p=await Reflect.apply(o,this,l);return await a._def.returns._def.type.parseAsync(p,i).catch(_=>{throw u.addIssue(s(p,_)),u})})}else{let a=this;return X(function(...c){let u=a._def.args.safeParse(c,i);if(!u.success)throw new Z([r(c,u.error)]);let l=Reflect.apply(o,this,u.data),p=a._def.returns.safeParse(l,i);if(!p.success)throw new Z([s(l,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:ye.create(e).rest(xe.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,n,r){return new t({args:e||ye.create([]).rest(xe.create()),returns:n||xe.create(),typeName:x.ZodFunction,...R(r)})}},ut=class extends I{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};ut.create=(t,e)=>new ut({getter:t,typeName:x.ZodLazy,...R(e)});lt=class extends I{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return g(n,{received:n.data,code:h.invalid_literal,expected:this._def.value}),w}return{status:"valid",value:e.data}}get value(){return this._def.value}};lt.create=(t,e)=>new lt({value:t,typeName:x.ZodLiteral,...R(e)});pt=class t extends I{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return g(n,{expected:P.joinValues(r),received:n.parsedType,code:h.invalid_type}),w}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return g(n,{received:n.data,code:h.invalid_enum_value,options:r}),w}return X(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};pt.create=pi;ft=class extends I{_parse(e){let n=P.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==y.string&&r.parsedType!==y.number){let s=P.objectValues(n);return g(r,{expected:P.joinValues(s),received:r.parsedType,code:h.invalid_type}),w}if(this._cache||(this._cache=new Set(P.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=P.objectValues(n);return g(r,{received:r.data,code:h.invalid_enum_value,options:s}),w}return X(e.data)}get enum(){return this._def.values}};ft.create=(t,e)=>new ft({values:t,typeName:x.ZodNativeEnum,...R(e)});He=class extends I{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.promise&&n.common.async===!1)return g(n,{code:h.invalid_type,expected:y.promise,received:n.parsedType}),w;let r=n.parsedType===y.promise?n.data:Promise.resolve(n.data);return X(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};He.create=(t,e)=>new He({type:t,typeName:x.ZodPromise,...R(e)});ae=class extends I{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{g(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return w;let c=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return c.status==="aborted"?w:c.status==="dirty"?tt(c.value):n.value==="dirty"?tt(c.value):c});{if(n.value==="aborted")return w;let a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?w:a.status==="dirty"?tt(a.value):n.value==="dirty"?tt(a.value):a}}if(s.type==="refinement"){let o=a=>{let c=s.refinement(a,i);if(r.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(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?w:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?w:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!$e(o))return w;let a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>$e(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:n.value,value:a})):w);P.assertNever(s)}};ae.create=(t,e,n)=>new ae({schema:t,typeName:x.ZodEffects,effect:e,...R(n)});ae.createWithPreprocess=(t,e,n)=>new ae({schema:e,effect:{type:"preprocess",transform:t},typeName:x.ZodEffects,...R(n)});ie=class extends I{_parse(e){return this._getType(e)===y.undefined?X(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ie.create=(t,e)=>new ie({innerType:t,typeName:x.ZodOptional,...R(e)});be=class extends I{_parse(e){return this._getType(e)===y.null?X(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};be.create=(t,e)=>new be({innerType:t,typeName:x.ZodNullable,...R(e)});ht=class extends I{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===y.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};ht.create=(t,e)=>new ht({innerType:t,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...R(e)});mt=class extends I{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return At(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Z(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Z(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};mt.create=(t,e)=>new mt({innerType:t,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...R(e)});Pt=class extends I{_parse(e){if(this._getType(e)!==y.nan){let r=this._getOrReturnCtx(e);return g(r,{code:h.invalid_type,expected:y.nan,received:r.parsedType}),w}return{status:"valid",value:e.data}}};Pt.create=t=>new Pt({typeName:x.ZodNaN,...R(t)});$c=Symbol("zod_brand"),Yt=class extends I{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},Zt=class t extends I{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?w:i.status==="dirty"?(n.dirty(),tt(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{let s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?w:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:x.ZodPipeline})}},gt=class extends I{_parse(e){let n=this._def.innerType._parse(e),r=s=>($e(s)&&(s.value=Object.freeze(s.value)),s);return At(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};gt.create=(t,e)=>new gt({innerType:t,typeName:x.ZodReadonly,...R(e)});Mc={object:Q.lazycreate};(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"})(x||(x={}));jc=(t,e={message:`Input not instance of ${t.name}`})=>fi(n=>n instanceof t,e),hi=Me.create,mi=nt.create,Hc=Pt.create,qc=rt.create,gi=st.create,Fc=it.create,Bc=Ct.create,Wc=ot.create,Vc=at.create,Gc=je.create,zc=xe.create,Jc=le.create,Xc=Nt.create,Kc=Se.create,Yc=Q.create,Zc=Q.strictCreate,Qc=ct.create,ed=Mn.create,td=dt.create,nd=ye.create,rd=jn.create,sd=Ot.create,id=Dt.create,od=Hn.create,ad=ut.create,cd=lt.create,dd=pt.create,ud=ft.create,ld=He.create,pd=ae.create,fd=ie.create,hd=be.create,md=ae.createWithPreprocess,gd=Zt.create,yd=()=>hi().optional(),bd=()=>mi().optional(),vd=()=>gi().optional(),Ed={string:t=>Me.create({...t,coerce:!0}),number:t=>nt.create({...t,coerce:!0}),boolean:t=>st.create({...t,coerce:!0}),bigint:t=>rt.create({...t,coerce:!0}),date:t=>it.create({...t,coerce:!0})},wd=w});var d={};Nr(d,{BRAND:()=>$c,DIRTY:()=>tt,EMPTY_PATH:()=>mc,INVALID:()=>w,NEVER:()=>wd,OK:()=>X,ParseStatus:()=>z,Schema:()=>I,ZodAny:()=>je,ZodArray:()=>Se,ZodBigInt:()=>rt,ZodBoolean:()=>st,ZodBranded:()=>Yt,ZodCatch:()=>mt,ZodDate:()=>it,ZodDefault:()=>ht,ZodDiscriminatedUnion:()=>Mn,ZodEffects:()=>ae,ZodEnum:()=>pt,ZodError:()=>Z,ZodFirstPartyTypeKind:()=>x,ZodFunction:()=>Hn,ZodIntersection:()=>dt,ZodIssueCode:()=>h,ZodLazy:()=>ut,ZodLiteral:()=>lt,ZodMap:()=>Ot,ZodNaN:()=>Pt,ZodNativeEnum:()=>ft,ZodNever:()=>le,ZodNull:()=>at,ZodNullable:()=>be,ZodNumber:()=>nt,ZodObject:()=>Q,ZodOptional:()=>ie,ZodParsedType:()=>y,ZodPipeline:()=>Zt,ZodPromise:()=>He,ZodReadonly:()=>gt,ZodRecord:()=>jn,ZodSchema:()=>I,ZodSet:()=>Dt,ZodString:()=>Me,ZodSymbol:()=>Ct,ZodTransformer:()=>ae,ZodTuple:()=>ye,ZodType:()=>I,ZodUndefined:()=>ot,ZodUnion:()=>ct,ZodUnknown:()=>xe,ZodVoid:()=>Nt,addIssueToContext:()=>g,any:()=>Gc,array:()=>Kc,bigint:()=>qc,boolean:()=>gi,coerce:()=>Ed,custom:()=>fi,date:()=>Fc,datetimeRegex:()=>li,defaultErrorMap:()=>we,discriminatedUnion:()=>ed,effect:()=>pd,enum:()=>dd,function:()=>od,getErrorMap:()=>Rt,getParsedType:()=>ge,instanceof:()=>jc,intersection:()=>td,isAborted:()=>Un,isAsync:()=>At,isDirty:()=>$n,isValid:()=>$e,late:()=>Mc,lazy:()=>ad,literal:()=>cd,makeIssue:()=>Kt,map:()=>sd,nan:()=>Hc,nativeEnum:()=>ud,never:()=>Jc,null:()=>Vc,nullable:()=>hd,number:()=>mi,object:()=>Yc,objectUtil:()=>Pr,oboolean:()=>vd,onumber:()=>bd,optional:()=>fd,ostring:()=>yd,pipeline:()=>gd,preprocess:()=>md,promise:()=>ld,quotelessJson:()=>pc,record:()=>rd,set:()=>id,setErrorMap:()=>hc,strictObject:()=>Zc,string:()=>hi,symbol:()=>Bc,transformer:()=>pd,tuple:()=>nd,undefined:()=>Wc,union:()=>Qc,unknown:()=>zc,util:()=>P,void:()=>Xc});var jr=C(()=>{Ln();Ur();ii();Xt();yi();Pn()});var pe=C(()=>{jr();jr()});var qe,Hr,qn,rh,qr,Fr,_d,sh,yt=C(()=>{"use strict";pe();qe=d.enum(["stable","preview"]),Hr=d.object({schemaVersion:d.literal(1),status:d.enum(["applying","succeeded","failed","deferred"]),previousVersion:d.string(),targetVersion:d.string(),reason:d.string(),checkedAt:d.string()}),qn=d.union([d.object({channel:qe}).strict(),d.object({autoUpdate:d.boolean()}).strict()]),rh=d.union([d.object({action:d.enum(["visit","check"])}).strict(),d.object({action:d.literal("install"),version:d.string().min(1).max(100)}).strict()]),qr=d.object({channel:qe,currentVersion:d.string(),targetVersion:d.string().nullable(),checkedAt:d.string().datetime(),eligible:d.boolean(),error:d.boolean()}),Fr=d.object({id:d.string().uuid(),channel:qe,currentVersion:d.string(),targetVersion:d.string(),automatic:d.boolean()}),_d=d.object({availability:d.enum(["available","not-installed","source-install","installation-mismatch","permission-required","authentication-required","unavailable"]),settings:d.object({channel:qe,autoUpdate:d.boolean(),independentExecutions:d.boolean().optional(),discovery:qr.nullable(),pending:Fr.nullable(),lastUpdate:Hr.nullable()}).nullable()}),sh=d.union([d.object({ok:d.literal(!0),state:_d}),d.object({ok:d.literal(!1),error:d.enum(["busy","unavailable","save-failed","stale-update","update-failed"])})])});var xd,Lt,Br,bi=C(()=>{pe();xd=d.string().trim().min(1).max(4096).refine(t=>!/[\x00-\x1f\x7f]/.test(t),"Path contains control characters"),Lt=d.array(xd).max(64),Br=d.discriminatedUnion("action",[d.object({action:d.literal("set"),paths:Lt}).strict(),d.object({action:d.literal("add"),paths:Lt.min(1)}).strict(),d.object({action:d.literal("remove"),paths:Lt.min(1)}).strict(),d.object({action:d.literal("reset")}).strict()])});var Wr,M,V,Qt,Fe,Vr,dh,uh,lh,ph,fh,hh,Sd,vi,Ei,mh,gh,kd,yh,bh,Td,Rd,vh,Ad,Eh,wh,_h,xh,Sh,kh,Th,wi,Rh,Ah,en=C(()=>{pe();yt();bi();Wr=d.enum(["claude","codex"]),M=d.string(),V=M.min(1),Qt={permission:M.optional(),model:M.optional(),effort:M.optional()},Fe=d.object({mediaType:M,data:M}),Vr=d.array(Fe).optional(),dh=d.object({path:V,name:M.optional(),defaultBaseRef:M.optional()}),uh=d.object({repoId:V,agent:Wr,prompt:M,...Qt,title:M.optional(),images:Vr,isolate:d.boolean().optional()}),lh=d.object({prompt:M,images:Vr,...Qt}),ph=d.object({title:M.trim().min(1,"Enter a session name.").max(200,"Use 200 characters or fewer.").regex(/^[^\r\n]*$/,"Use a single line for the session name.")}),fh=d.object({text:M,images:Vr,...Qt}),hh=d.object({decision:d.enum(["approve","deny"]),scope:M.optional()}),Sd=d.object({question:M,selected:d.array(M),notes:M.optional()}),vi=d.object({requestId:V,answers:d.array(Sd),response:M.optional()}),Ei={preset:d.enum(["hourly","daily","weekly","weekdays","manual","custom"]).optional(),schedule:M.optional(),hour:d.number().int().min(0).max(23).optional(),dayOfWeek:d.number().int().min(0).max(6).optional()},mh=d.object({repoId:V,agent:Wr,prompt:V,...Ei,...Qt,title:M.optional()}),gh=d.object({prompt:V.optional(),...Ei,...Qt,title:M.optional(),enabled:d.boolean().optional()}),kd=d.object({endpoint:V,expirationTime:d.number().nullable().optional(),keys:d.record(M).optional()}),yh=d.object({subscription:kd}),bh=d.object({endpoint:V}),Td=d.object({agent:Wr,sessionId:V,cwd:V,home:V,waitPid:d.number().int().positive()}),Rd=d.enum(["queued","running","awaiting_approval","awaiting_input","idle","archived","failed","cancelled"]),vh=d.object({status:Rd.optional()}),Ad=d.coerce.number().int().min(1).max(Number.MAX_SAFE_INTEGER),Eh=d.object({before:Ad}),wh=d.object({task:M.optional(),lastEventId:M.optional(),tail:d.literal("1").optional(),snapshots:d.literal("1").optional()}),_h=d.object({path:M.optional()}),xh=d.object({refresh:d.enum(["0","1"]).optional()}),Sh=d.object({id:V}),kh=d.object({}),Th=d.object({token:M.optional()}),wi={id:V,rawId:V,type:d.literal("public-key"),authenticatorAttachment:d.enum(["platform","cross-platform"]).optional(),clientExtensionResults:d.object({}).passthrough()},Rh=d.object({...wi,response:d.object({clientDataJSON:V,authenticatorData:V,signature:V,userHandle:M.optional()})}),Ah=d.object({response:d.object({...wi,response:d.object({clientDataJSON:V,attestationObject:V,transports:d.array(d.enum(["ble","cable","hybrid","internal","nfc","smart-card","usb"])).optional(),publicKeyAlgorithm:d.number().optional(),publicKey:M.optional(),authenticatorData:M.optional()})}),label:M.optional()})});var Id,Ph,Lh,_i=C(()=>{pe();en();Id=d.object({model:d.string().optional(),effort:d.string().optional(),permission:d.string().optional()}),Ph=d.object({clientMessageId:d.string().uuid(),mode:d.enum(["send","queue"]),text:d.string().trim().min(1).max(1e5),images:d.array(Fe).optional(),expectedRunId:d.string().nullable(),settings:Id.optional()}),Lh=d.discriminatedUnion("action",[d.object({action:d.literal("edit"),version:d.number().int(),token:d.string().uuid()}),d.object({action:d.literal("renew"),token:d.string().uuid()}),d.object({action:d.literal("save"),token:d.string().uuid(),version:d.number().int(),text:d.string().trim().min(1).max(1e5),images:d.array(Fe).optional()}),d.object({action:d.literal("release"),token:d.string().uuid()}),d.object({action:d.literal("delete"),version:d.number().int()}),d.object({action:d.literal("send"),version:d.number().int(),expectedRunId:d.string().nullable()})])});var ee=C(()=>{"use strict";Ys();Zs();Qs();ei();ti();ri();_i()});var ts=C(()=>{});import{homedir as Ji}from"node:os";import{join as bu}from"node:path";function bt(t){return t==="~"?Ji():t.startsWith("~/")?bu(Ji(),t.slice(2)):t}var Yn=C(()=>{});import{homedir as vu}from"node:os";import{existsSync as Xi}from"node:fs";import{dirname as Qi,join as Mt,resolve as vt}from"node:path";import{fileURLToPath as Eu}from"node:url";function Su(t){let e={};for(let[n,r]of Object.entries(t))r!==void 0&&r!==""&&(e[n]=r);return e}var wu,_u,xu,L,eo,ns,rs,Ki,Yi,Zi,jt,an=C(()=>{pe();ee();Yn();wu=Qi(Eu(import.meta.url)),_u=t=>t==="localhost"||t==="::1"||/^127(?:\.\d{1,3}){3}$/.test(t),xu=d.object({PORT:d.coerce.number().int().positive().default(4e3),HOST:d.string().min(1).refine(_u,"HOST must be loopback; terminate public HTTPS at the reverse proxy").default("localhost"),DISPATCH_CONCURRENCY:d.coerce.number().int().min(1).default(8),SSE_KEEPALIVE_MS:d.coerce.number().int().positive().default(15e3),AUTH_SESSION_TTL_MS:d.coerce.number().int().positive().default(30*24*60*60*1e3),AUTH_COOKIE_NAME:d.string().min(1).default("palmagent_session"),AUTH_RP_ID:d.string().min(1).regex(/^[A-Za-z0-9.-]+$/,"AUTH_RP_ID must be a hostname without a scheme, path, or port").optional(),AUTH_RP_NAME:d.string().min(1).optional(),AUTH_ORIGIN:d.string().url().startsWith("https://","AUTH_ORIGIN must use https://").optional(),AUTH_ENABLED:d.string().optional(),AUTH_DISABLED:d.string().optional(),PUSH_SUBJECT:d.string().regex(/^(mailto:|https:\/\/)/,"PUSH_SUBJECT must be a mailto: or https:// URL").optional(),DISPATCHER_DATA_DIR:d.string().min(1).optional(),XDG_STATE_HOME:d.string().min(1).optional(),DISPATCHER_DB:d.string().min(1).optional(),VAPID_KEY_PATH:d.string().min(1).optional(),STATIC_DIR:d.string().min(1).optional(),REPO_ROOTS:d.string().optional(),GITHUB_TOKEN:d.string().min(1).optional(),RUNNER_SOCKET:d.string().min(1).optional(),EXECUTION_RELEASE:d.string().min(1).optional(),EXECUTION_NODE:d.string().min(1).optional(),CLAUDE_MODEL:d.string().min(1).optional(),CODEX_MODEL:d.string().min(1).optional(),CLAUDE_EFFORT:d.string().min(1).optional(),CODEX_EFFORT:d.string().min(1).optional(),CLAUDE_CONFIG_DIR:d.string().min(1).optional(),NODE_ENV:d.string().optional()}).passthrough();L=xu.parse(Su(process.env)),eo=L.AUTH_DISABLED==="1"?!1:L.AUTH_ENABLED==="1"?!0:L.NODE_ENV==="production",ns=L.AUTH_RP_ID??(eo?"":"localhost"),rs=L.DISPATCHER_DATA_DIR?vt(L.DISPATCHER_DATA_DIR):L.XDG_STATE_HOME?Mt(vt(L.XDG_STATE_HOME),E.stateDirName):Mt(vu(),".local","state",E.stateDirName),Ki=Mt(rs,"palmagent.db"),Yi=Mt(rs,"dispatcher.db"),Zi=L.DISPATCHER_DB?vt(L.DISPATCHER_DB):Xi(Ki)||!Xi(Yi)?Ki:Yi,jt={port:L.PORT,host:L.HOST,concurrency:L.DISPATCH_CONCURRENCY,dataDir:rs,dbPath:Zi,keepAliveMs:L.SSE_KEEPALIVE_MS,claudeModel:L.CLAUDE_MODEL,codexModel:L.CODEX_MODEL,claudeEffort:L.CLAUDE_EFFORT,codexEffort:L.CODEX_EFFORT,claudeConfigDir:L.CLAUDE_CONFIG_DIR?vt(bt(L.CLAUDE_CONFIG_DIR)):void 0,vapidKeyPath:L.VAPID_KEY_PATH?vt(L.VAPID_KEY_PATH):Mt(Qi(Zi),"vapid.json"),pushSubject:L.PUSH_SUBJECT,staticDir:L.STATIC_DIR?vt(L.STATIC_DIR):Mt(wu,"..","..","web","dist"),repoRoots:(L.REPO_ROOTS??"").split(":").filter(Boolean).map(t=>vt(bt(t))),runnerSocket:L.RUNNER_SOCKET,executionRelease:L.EXECUTION_RELEASE,executionNode:L.EXECUTION_NODE,githubToken:L.GITHUB_TOKEN,authEnabled:eo,rpId:ns,rpName:L.AUTH_RP_NAME??E.displayName,authOrigin:L.AUTH_ORIGIN??(ns?`https://${ns}`:""),sessionTtlMs:L.AUTH_SESSION_TTL_MS,cookieName:L.AUTH_COOKIE_NAME,nodeEnv:L.NODE_ENV}});var ss=C(()=>{});import{createHash as Tu}from"node:crypto";import{readFileSync as to,readdirSync as hy,realpathSync as my,statSync as gy}from"node:fs";function is(t){if(!Number.isSafeInteger(t)||t<=1)throw new Error("A valid local CLI process id is required");try{let e=to(`/proc/${t}/stat`,"utf8"),n=e.slice(e.lastIndexOf(")")+2).split(" ");return n[0]==="Z"?void 0:`${to("/proc/sys/kernel/random/boot_id","utf8").trim()}:${n[19]}`}catch(e){if(e.code==="ENOENT")return;throw new Error("Cannot verify the local CLI process; ownership is retained")}}var Ru,Au,os=C(()=>{an();ss();Ru=t=>Tu("sha256").update(t).digest("hex");Au=Ru(Buffer.alloc(0))});var no=C(()=>{});function Nu({permission:t,model:e,effort:n,resumeId:r}){let s=["-p","--input-format","stream-json","--output-format","stream-json","--verbose","--include-partial-messages","--permission-mode",Cu(t),"--permission-prompt-tool","stdio"];return e&&s.push("--model",e),n&&s.push("--effort",n),r&&s.push("--resume",r),s}function Ou(t,e=[]){let n=e.map(r=>({type:"image",source:{type:"base64",media_type:r.mediaType,data:r.data}}));return n.push({type:"text",text:t}),{type:"user",message:{role:"user",content:n}}}var Iu,ro,Cu,Zn,so=C(()=>{ee();an();Iu=1500,ro={plan:"plan",acceptEdits:"acceptEdits",dontAsk:"dontAsk",bypassPermissions:"bypassPermissions",readonly:"plan","auto-edit":"acceptEdits",full:"bypassPermissions"},Cu=t=>ro[t??""]??ro[Or.claude];Zn=class{agent="claude";start(e,n,r){let{taskId:s,cwd:i,prompt:o,images:a,resumeId:c,permission:u,model:l,effort:p,reattach:f,resumeFromSeq:_,pendingInput:N}=e,b=Nu({permission:u,model:l,effort:p,resumeId:c});e.interactive&&b.push("--replay-user-messages");let k=c,q=e.providerHome??jt.claudeConfigDir,Tt=q?{CLAUDE_CONFIG_DIR:q}:void 0,S=f?r.attach(s,0):r.start({turnId:s,command:"claude",argv:b,cwd:i,env:Tt});if(!S)return n({taskId:s,kind:"status",sessionId:k,payload:{subtype:"reattach_failed"}}),{steer:()=>!1,interrupt:()=>!1,approve:()=>!1,answer:()=>!1,cancel:()=>{},done:Promise.resolve()};let H,A=F=>{H&&(clearTimeout(H.timer),H.resolve(F),H=void 0,O=!1)},U,O=!1,Ye,Ze,Ar=!1,Ks=0,Nn=new Map;f&&N&&Nn.set(N.requestId,{questions:N.questions});let Qe=F=>{S.writeStdin(JSON.stringify(F)+`
|
|
3
3
|
`)},Ir=(F,re,D)=>{Qe({...Ou(F,re),...D?{uuid:D}:{}})},Cr=(F=!1)=>{Ze&&clearTimeout(Ze),Ar=F,Ze=setTimeout(()=>{!O&&S.stdinWritable()&&S.closeStdin()},Iu)},On=()=>{Ze&&clearTimeout(Ze),Ze=void 0,Ar=!1};S.onLine((F,re)=>{let D;try{D=JSON.parse(re)}catch{return}D.session_id&&(k=D.session_id);let J=$=>n($,F),me=f&&F<=(_??0);switch(Ar&&["stream_event","assistant","user","control_request"].includes(D.type)&&On(),D.type){case"system":J({taskId:s,kind:"status",sessionId:k,payload:{subtype:D.subtype,model:D.model,cwd:D.cwd,tools:D.tools?.length}});break;case"rate_limit_event":J({taskId:s,kind:"status",sessionId:k,payload:{subtype:"rate_limit",info:D}});break;case"stream_event":{let $=D.event;if($?.type==="message_start"&&(U=$.message?.id),$?.type==="message_delta"&&U){let Ue=$.delta?.stop_reason,Ee=Ue==="tool_use"?"progress":Ue==="end_turn"?"final":void 0;Ee&&J({taskId:s,kind:"status",sessionId:k,payload:{subtype:"assistant_message",messageId:U,phase:Ee}})}$?.type==="message_stop"&&(U=void 0),$?.type==="content_block_delta"&&$.delta?.type==="text_delta"&&J({taskId:s,kind:"assistant_text",sessionId:k,payload:{text:$.delta.text,...U?{messageId:U}:{}}});break}case"assistant":{for(let $ of D.message?.content??[])$.type==="tool_use"&&J({taskId:s,kind:"tool_call",sessionId:k,payload:{id:$.id,name:$.name,input:$.input}});break}case"user":{typeof D.uuid=="string"&&(D.uuid===e.messageId||D.uuid===H?.id||e.interactive&&D.message?.role==="user"&&D.message?.content?.some($=>$.type==="text"))&&(J({taskId:s,kind:"status",sessionId:k,payload:{subtype:"message_delivered",messageId:D.uuid}}),H?.id===D.uuid&&A("delivered"));for(let $ of D.message?.content??[])$.type==="tool_result"&&J({taskId:s,kind:"tool_result",sessionId:k,payload:{tool_use_id:$.tool_use_id,content:$.content,is_error:$.is_error}});break}case"result":J({taskId:s,kind:"result",sessionId:k,payload:{subtype:D.subtype,is_error:D.is_error,result:D.result,num_turns:D.num_turns,duration_ms:D.duration_ms,total_cost_usd:D.total_cost_usd}}),H&&!H.sent&&(H.sent=!0,Ir(H.text,H.images,H.id)),O||Cr(!!me);break;case"control_response":J({taskId:s,kind:"status",sessionId:k,payload:{subtype:"control_response",response:D.response}});break;case"control_request":{if(me)break;let $=D.request_id,Ue=D.request??{};if(Ue.subtype!=="can_use_tool")break;if(Ue.tool_name==="AskUserQuestion"&&Array.isArray(Ue.input?.questions)){let Ee=Ue.input.questions;Nn.set($,{questions:Ee}),J({taskId:s,kind:"question",sessionId:k,payload:{requestId:$,questions:Ee}})}else Qe({type:"control_response",response:{subtype:"success",request_id:$,response:{behavior:"deny",message:"Auto-denied (non-interactive dispatch)."}}});break}default:break}}),S.onStderr(F=>{n({taskId:s,kind:"status",sessionId:k,payload:{subtype:"stderr",text:F}})});let ac=new Promise(F=>{S.onExit(re=>{On(),A("unknown"),n({taskId:s,kind:"status",sessionId:k,payload:{subtype:"process_exit",code:re}}),F()})});return f||Ir(o,a,e.messageId),{send:(F,re,D)=>!S.stdinWritable()||H||Ze||!e.interactive?Promise.resolve("rejected"):(O=!0,On(),new Promise(J=>{let me=setTimeout(()=>{A("unknown"),Cr()},15e3);me.unref(),H={id:D,text:F,images:re,sent:!1,resolve:J,timer:me},Qe({type:"control_request",request_id:`send_${D}`,request:{subtype:"interrupt"}})})),steer:(F,re)=>S.stdinWritable()?(O=!0,On(),Qe({type:"control_request",request_id:`int_${++Ks}`,request:{subtype:"interrupt"}}),Ye=setTimeout(()=>{Ir(F,re),O=!1},250),!0):!1,interrupt:()=>S.stdinWritable()?(Ye&&clearTimeout(Ye),A(H?.sent?"unknown":"rejected"),O=!1,Qe({type:"control_request",request_id:`int_${++Ks}`,request:{subtype:"interrupt"}}),Cr(),!0):!1,approve:()=>!1,answer:F=>{let re=Nn.get(F.requestId);if(!re||!S.stdinWritable())return!1;Nn.delete(F.requestId);let D=new Map(re.questions.map(ue=>[ue.question,ue])),J={},me={};for(let ue of F.answers??[])ue.selected?.length&&(J[ue.question]=D.get(ue.question)?.multiSelect?ue.selected:ue.selected[0]),ue.notes?.trim()&&(me[ue.question]={notes:ue.notes.trim()});let $=F.response?.trim();if(!(Object.keys(J).length>0||Object.keys(me).length>0||!!$))return Qe({type:"control_response",response:{subtype:"success",request_id:F.requestId,response:{behavior:"deny",message:"User declined to answer."}}}),!0;let Ee={questions:re.questions,answers:J};return Object.keys(me).length&&(Ee.annotations=me),$&&(Ee.response=$),Qe({type:"control_response",response:{subtype:"success",request_id:F.requestId,response:{behavior:"allow",updatedInput:Ee}}}),!0},cancel:()=>S.kill("SIGINT"),done:ac}}}});function oo(t,e,n){let{taskId:r,reattach:s}=t,i=t.resumeId,o,a=!1,c,u=new Map,l=t.permission,p=l==="read-only"||l==="readonly"?"read-only":l==="danger-full-access"||l==="full"?"danger-full-access":"workspace-write",f=s?n.attach(r,0):n.start({turnId:r,command:"codex",cwd:t.cwd,argv:["app-server","--listen","stdio://","-c",'approval_policy="never"',"-c",`sandbox_mode=${JSON.stringify(p)}`,...l==="workspace-write-net"?["-c","sandbox_workspace_write.network_access=true"]:[]],...t.providerHome?{env:{CODEX_HOME:t.providerHome}}:{}});if(!f)return e({taskId:r,kind:"status",sessionId:i,payload:{subtype:"reattach_failed"}}),{steer:()=>!1,interrupt:()=>!1,approve:()=>!1,answer:()=>!1,cancel(){},done:Promise.resolve()};let _=S=>f.writeStdin(JSON.stringify(S)+`
|
|
4
4
|
`),N=(S,H,A)=>_({jsonrpc:"2.0",id:S,method:H,params:A}),b=(S,H,A)=>e({taskId:r,sessionId:i,kind:S,payload:H},A),k=(S,H)=>{b("status",{subtype:"message_delivered",messageId:S},H);let A=u.get(S);A&&(clearTimeout(A.timer),u.delete(S),A.resolve("delivered"))},q=setTimeout(()=>{!o&&!a&&(b("error",{message:"Codex did not start a turn; the request will not be replayed automatically."}),f.kill("SIGINT"))},3e4);q.unref(),f.onLine((S,H)=>{let A;try{A=JSON.parse(H)}catch{return}let U=A.params??{};if(typeof A.id=="string"&&("result"in A||"error"in A)){if(A.id.startsWith("message:")){let O=A.id.slice(8),Ye=u.get(O);A.error?Ye&&(clearTimeout(Ye.timer),u.delete(O),Ye.resolve("rejected")):k(O,S)}else A.error?(b("error",{message:A.error.message??"Codex request failed"},S),a=!0,f.closeStdin()):A.id==="initialize"&&!s?(_({jsonrpc:"2.0",method:"initialized",params:{}}),N("session",t.resumeId?"thread/resume":"thread/start",{...t.resumeId?{threadId:t.resumeId}:{},cwd:t.cwd,approvalPolicy:"never",sandbox:p,...t.model?{model:t.model}:{},...t.effort?{config:{model_reasoning_effort:t.effort}}:{}})):A.id==="session"?(i=A.result.thread.id,b("status",{subtype:"thread_started"},S),s||N("start","turn/start",{threadId:i,input:io(t.prompt,t.images),...t.messageId?{clientUserMessageId:t.messageId}:{},...t.effort?{effort:t.effort}:{}})):A.id==="start"&&(o=A.result.turn.id,clearTimeout(q),t.messageId&&k(t.messageId,S));return}if(!(U.threadId&&i&&U.threadId!==i))switch(A.method){case"thread/started":i=U.thread.id,b("status",{subtype:"thread_started"},S);break;case"turn/started":o=U.turn.id,clearTimeout(q),b("status",{subtype:"turn_started",turnId:o},S);break;case"item/agentMessage/delta":b("assistant_text",{text:U.delta,messageId:U.itemId},S);break;case"item/started":U.item?.type==="commandExecution"&&b("tool_call",{id:U.item.id,name:"bash",command:U.item.command},S);break;case"item/completed":{let O=U.item;O?.type==="userMessage"&&O.clientId?k(O.clientId,S):O?.type==="agentMessage"?b("status",{subtype:"assistant_message",messageId:O.id,phase:O.phase==="commentary"?"progress":O.phase==="final_answer"?"final":void 0},S):O?.type==="commandExecution"?b("tool_result",{tool_use_id:O.id,output:O.aggregatedOutput,exit_code:O.exitCode},S):O?.type==="fileChange"?b("tool_call",{id:O.id,name:"file_change",changes:O.changes},S):(O?.type==="mcpToolCall"||O?.type==="webSearch")&&b("tool_result",{tool_use_id:O.id,content:O.result??O.action,name:O.tool??O.type},S);break}case"turn/completed":a=!0,o=void 0,clearTimeout(q),U.turn.status==="failed"&&b("error",{message:U.turn.error?.message??"Codex turn failed."},S),b("result",{is_error:U.turn.status!=="completed",subtype:U.turn.status,error:U.turn.error,usage:c},S),f.closeStdin();break;case"thread/tokenUsage/updated":U.tokenUsage?.last&&(c={input_tokens:U.tokenUsage.last.inputTokens,cached_input_tokens:U.tokenUsage.last.cachedInputTokens,output_tokens:U.tokenUsage.last.outputTokens}),b("status",{subtype:"usage",usage:U.tokenUsage},S);break;case"error":b("error",{message:U.error?.message??U.message},S);break;case"item/commandExecution/requestApproval":case"item/fileChange/requestApproval":_({jsonrpc:"2.0",id:A.id,result:{decision:"decline"}});break;case"item/tool/requestUserInput":_({jsonrpc:"2.0",id:A.id,result:{answers:{}}});break}}),f.onStderr(S=>b("status",{subtype:"stderr",text:S}));let Tt=new Promise(S=>f.onExit(H=>{clearTimeout(q);for(let A of u.values())clearTimeout(A.timer),A.resolve("unknown");u.clear(),a||b("error",{message:"Codex exited before a terminal turn result."}),b("status",{subtype:"process_exit",code:H}),S()}));return s||N("initialize","initialize",{clientInfo:{name:"palmagent",version:"1.0.0"},capabilities:{}}),{send:(S,H,A)=>!o||a||!f.stdinWritable()?Promise.resolve("rejected"):new Promise(U=>{let O=setTimeout(()=>{u.delete(A),U("unknown")},15e3);O.unref(),u.set(A,{resolve:U,timer:O}),N(`message:${A}`,"turn/steer",{threadId:i,expectedTurnId:o,clientUserMessageId:A,input:io(S,H)})||(clearTimeout(O),u.delete(A),U("unknown"))}),steer:()=>!1,interrupt:()=>!!o&&!a&&N(`stop:${o}`,"turn/interrupt",{threadId:i,turnId:o}),approve:()=>!1,answer:()=>!1,cancel:()=>f.kill("SIGINT"),done:Tt}}var io,ao=C(()=>{io=(t,e)=>[{type:"text",text:t,text_elements:[]},...(e??[]).map(n=>({type:"image",url:`data:${n.mediaType};base64,${n.data}`}))]});import{mkdtempSync as Du,rmSync as Pu,writeFileSync as Lu}from"node:fs";import{tmpdir as Uu}from"node:os";import{join as co}from"node:path";function Mu(t){if(!t?.length)return{argv:[],cleanup:()=>{}};let e=Du(co(Uu(),"palmagent-img-")),n=[];return t.forEach((r,s)=>{let i=co(e,`img-${s}${$u[r.mediaType]??".png"}`);Lu(i,Buffer.from(r.data,"base64")),n.push("-i",i)}),{argv:n,cleanup:()=>Pu(e,{recursive:!0,force:!0})}}function ju(t){return uo[t??""]??uo["workspace-write"]}function Hu({prompt:t,resumeId:e,permission:n,model:r,effort:s},i=[]){let o=[...r?["-c",`model=${r}`]:[],...s?["-c",`model_reasoning_effort=${s}`]:[]],a=ju(n),c=e?["-c",`sandbox_mode=${a.mode}`]:["--sandbox",a.mode],u=a.network?["-c","sandbox_workspace_write.network_access=true"]:[],l=["--json","--skip-git-repo-check","-c","approval_policy=never",...c,...u,...o,...i];return e?["exec","resume",e,t,...l]:["exec",t,...l]}var $u,uo,Qn,lo=C(()=>{ao();$u={"image/png":".png","image/jpeg":".jpg","image/webp":".webp","image/gif":".gif"};uo={"read-only":{mode:"read-only"},"workspace-write":{mode:"workspace-write"},"workspace-write-net":{mode:"workspace-write",network:!0},"danger-full-access":{mode:"danger-full-access"},readonly:{mode:"read-only"},"auto-edit":{mode:"workspace-write"},full:{mode:"danger-full-access"}};Qn=class{agent="codex";start(e,n,r){if(e.interactive)return oo(e,n,r);let{taskId:s,cwd:i,prompt:o,images:a,resumeId:c,permission:u,model:l,effort:p,reattach:f}=e,_=c;if(f){let q=r.attach(s,0);return q?this.wire(s,q,n,()=>{},()=>_,Tt=>{_=Tt}):(n({taskId:s,kind:"status",sessionId:_,payload:{subtype:"reattach_failed"}}),{steer:()=>!1,interrupt:()=>!1,approve:()=>!1,answer:()=>!1,cancel:()=>{},done:Promise.resolve()})}let N=Mu(a),b=Hu({prompt:o,resumeId:c,permission:u,model:l,effort:p},N.argv),k=r.start({turnId:s,command:"codex",argv:b,cwd:i,...e.providerHome?{env:{CODEX_HOME:e.providerHome}}:{}});return k.closeStdin(),this.wire(s,k,n,N.cleanup,()=>_,q=>{_=q})}wire(e,n,r,s,i,o){let a=(u,l)=>{let p=i();switch(u?.type){case"agent_message":l({taskId:e,kind:"assistant_text",sessionId:p,payload:{text:u.text,messageId:u.id,...u.phase==="commentary"?{phase:"progress"}:u.phase==="final_answer"?{phase:"final"}:{}}});break;case"reasoning":l({taskId:e,kind:"status",sessionId:p,payload:{subtype:"reasoning",text:u.text}});break;case"command_execution":l({taskId:e,kind:"tool_call",sessionId:p,payload:{id:u.id,name:"bash",command:u.command,status:u.status}}),(u.aggregated_output!=null||u.exit_code!=null)&&l({taskId:e,kind:"tool_result",sessionId:p,payload:{tool_use_id:u.id,output:u.aggregated_output,exit_code:u.exit_code,status:u.status}});break;case"file_change":l({taskId:e,kind:"tool_call",sessionId:p,payload:{id:u.id,name:"file_change",changes:u.changes,status:u.status}});break;case"mcp_tool_call":case"web_search":l({taskId:e,kind:"tool_call",sessionId:p,payload:{id:u.id,name:u.type,status:u.status,item:u}});break;case"error":l({taskId:e,kind:"error",sessionId:p,payload:{message:u.message}});break;default:l({taskId:e,kind:"status",sessionId:p,payload:{subtype:u?.type??"item",item:u}})}};n.onLine((u,l)=>{let p;try{p=JSON.parse(l)}catch{return}let f=N=>r(N,u),_=i();switch(p.type){case"thread.started":o(p.thread_id),f({taskId:e,kind:"status",sessionId:p.thread_id,payload:{subtype:"thread_started",thread_id:p.thread_id}});break;case"turn.started":f({taskId:e,kind:"status",sessionId:_,payload:{subtype:"turn_started"}});break;case"item.started":p.item?.type==="command_execution"&&a(p.item,f);break;case"item.updated":break;case"item.completed":a(p.item,f);break;case"turn.completed":f({taskId:e,kind:"result",sessionId:_,payload:{usage:p.usage}});break;case"turn.failed":f({taskId:e,kind:"error",sessionId:_,payload:{error:p.error}});break;case"error":f({taskId:e,kind:"error",sessionId:_,payload:{message:p.message}});break;default:break}}),n.onStderr(u=>{r({taskId:e,kind:"status",sessionId:i(),payload:{subtype:"stderr",text:u}})});let c=new Promise(u=>{n.onExit(l=>{s(),r({taskId:e,kind:"status",sessionId:i(),payload:{subtype:"process_exit",code:l}}),u()})});return{steer:()=>!1,interrupt:()=>!1,approve:()=>!1,answer:()=>!1,cancel:()=>n.kill("SIGINT"),done:c}}}});var Oy,po=C(()=>{so();lo();Oy={claude:new Zn,codex:new Qn}});var fo=C(()=>{});var G,tb,cn=C(()=>{ts();ee();os();ss();no();an();po();Yn();fo();G=class extends Error{constructor(n,r){super(r);this.status=n}},tb=4.5*1024*1024});import{chmodSync as bo,mkdirSync as vo,openSync as ho,closeSync as mo,fsyncSync as go,writeFileSync as qu,renameSync as Fu,unlinkSync as Bu}from"node:fs";import{dirname as yo}from"node:path";import{randomUUID as Wu}from"node:crypto";function ce(t){vo(t,{recursive:!0,mode:448}),bo(t,448)}function fe(t){vo(t,{recursive:!0,mode:448})}function Ve(t){bo(t,384)}function Ge(t,e){fe(yo(t));let n=`${t}.${Wu()}.tmp`,r=ho(n,"wx",384);try{qu(r,e),go(r)}finally{mo(r)}try{Fu(n,t);let s=ho(yo(t),"r");try{go(s)}finally{mo(s)}}finally{try{Bu(n)}catch(s){if(s.code!=="ENOENT")throw s}}}var se=C(()=>{});function qp(t){let e=[],n=[],r="",s=!1,i="",o=!1,a=[],c=!1,u=()=>{s&&(o?(a.push({end:r,tabs:c}),o=!1):n.push(r),r="",s=!1)},l=()=>{u(),n.length&&e.push(n),n=[]};for(let p=0;p<t.length;p++){let f=t[p];if(i){if(f===i){i="";continue}if(i==='"'&&(f==="$"||f==="`"))return null;if(i==='"'&&f==="\\"&&/[\\"$`\n]/.test(t[p+1]??"")){let _=t[++p];_!==`
|
|
5
5
|
`&&(r+=_)}else r+=f;continue}if(f==="'"||f==='"'){i=f,s=!0;continue}if(f==="\\"){if(++p>=t.length)return null;t[p]!==`
|