@tokmizer/plugin 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __tkrCreateRequire } from "node:module"; const require = __tkrCreateRequire(import.meta.url);
3
- var Br=Object.defineProperty;var S=(t,e,n)=>()=>{if(n)throw n[0];try{return t&&(e=t(t=0)),e}catch(r){throw n=[r],r}};var ke=(t,e)=>{for(var n in e)Br(t,n,{get:e[n],enumerable:!0})};import cn from"node:os";import{join as q}from"node:path";function w(){return process.env.TOKMIZER_HOME||q(cn.homedir(),".tokmizer")}function Ze(){return q(w(),"install-id")}function Qe(){return q(w(),"bundle-refresh.json")}function Xe(){return q(w(),"skills")}function re(t){return q(Xe(),`${t}.md`)}function Tt(){return q(w(),"managed-commands.json")}function et(){return process.env.TOKMIZER_CLAUDE_COMMANDS_DIR||q(cn.homedir(),".claude","commands")}function se(t){return q(et(),`${t}.md`)}var L=S(()=>{"use strict"});var b,Et,p,V,Le=S(()=>{(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{let a={};for(let o of s)a[o]=o;return a},t.getValidEnumValues=s=>{let a=t.objectKeys(s).filter(i=>typeof s[s[i]]!="number"),o={};for(let i of a)o[i]=s[i];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(a){return s[a]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let a=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&a.push(o);return a},t.find=(s,a)=>{for(let o of s)if(a(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,a=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}t.joinValues=r,t.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(b||(b={}));(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Et||(Et={}));p=b.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),V=t=>{switch(typeof t){case"undefined":return p.undefined;case"string":return p.string;case"number":return Number.isNaN(t)?p.nan:p.number;case"boolean":return p.boolean;case"function":return p.function;case"bigint":return p.bigint;case"symbol":return p.symbol;case"object":return Array.isArray(t)?p.array:t===null?p.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?p.promise:typeof Map<"u"&&t instanceof Map?p.map:typeof Set<"u"&&t instanceof Set?p.set:typeof Date<"u"&&t instanceof Date?p.date:p.object;default:return p.unknown}}});var d,Wr,I,tt=S(()=>{Le();d=b.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"]),Wr=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),I=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(a){return a.message},r={_errors:[]},s=a=>{for(let o of a.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 i=r,c=0;for(;c<o.path.length;){let u=o.path[c];c===o.path.length-1?(i[u]=i[u]||{_errors:[]},i[u]._errors.push(n(o))):i[u]=i[u]||{_errors:[]},i=i[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,b.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 a=s.path[0];n[a]=n[a]||[],n[a].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};I.create=t=>new I(t)});var Gr,W,At=S(()=>{tt();Le();Gr=(t,e)=>{let n;switch(t.code){case d.invalid_type:t.received===p.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case d.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,b.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:n=`Unrecognized key(s) in object: ${b.joinValues(t.keys,", ")}`;break;case d.invalid_union:n="Invalid input";break;case d.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${b.joinValues(t.options)}`;break;case d.invalid_enum_value:n=`Invalid enum value. Expected ${b.joinValues(t.options)}, received '${t.received}'`;break;case d.invalid_arguments:n="Invalid function arguments";break;case d.invalid_return_type:n="Invalid function return type";break;case d.invalid_date:n="Invalid date";break;case d.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}"`:b.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case d.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 d.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 d.custom:n="Invalid input";break;case d.invalid_intersection_types:n="Intersection results could not be merged";break;case d.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case d.not_finite:n="Number must be finite";break;default:n=e.defaultError,b.assertNever(t)}return{message:n}},W=Gr});function Yr(t){dn=t}function xe(){return dn}var dn,nt=S(()=>{At();dn=W});function f(t,e){let n=xe(),r=Fe({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===W?void 0:W].filter(s=>!!s)});t.common.issues.push(r)}var Fe,Jr,$,h,ae,C,rt,st,Q,we,$t=S(()=>{nt();At();Fe=t=>{let{data:e,path:n,errorMaps:r,issueData:s}=t,a=[...n,...s.path||[]],o={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let i="",c=r.filter(u=>!!u).slice().reverse();for(let u of c)i=u(o,{data:e,defaultError:i}).message;return{...s,path:a,message:i}},Jr=[];$=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 h;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 a=await s.key,o=await s.value;r.push({key:a,value:o})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let s of n){let{key:a,value:o}=s;if(a.status==="aborted"||o.status==="aborted")return h;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[a.value]=o.value)}return{status:e.value,value:r}}},h=Object.freeze({status:"aborted"}),ae=t=>({status:"dirty",value:t}),C=t=>({status:"valid",value:t}),rt=t=>t.status==="aborted",st=t=>t.status==="dirty",Q=t=>t.status==="valid",we=t=>typeof Promise<"u"&&t instanceof Promise});var ln=S(()=>{});var m,fn=S(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(m||(m={}))});function _(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,i)=>{let{message:c}=t;return o.code==="invalid_enum_value"?{message:c??i.defaultError}:typeof i.data>"u"?{message:c??r??i.defaultError}:o.code!=="invalid_type"?{message:i.defaultError}:{message:c??n??i.defaultError}},description:s}}function gn(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 ps(t){return new RegExp(`^${gn(t)}$`)}function yn(t){let e=`${hn}T${gn(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 ms(t,e){return!!((e==="v4"||!e)&&os.test(t)||(e==="v6"||!e)&&cs.test(t))}function hs(t,e){if(!ns.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 gs(t,e){return!!((e==="v4"||!e)&&is.test(t)||(e==="v6"||!e)&&us.test(t))}function ys(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,a=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return a%o/10**s}function Se(t){if(t instanceof P){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=M.create(Se(r))}return new P({...t._def,shape:()=>e})}else return t instanceof J?new J({...t._def,type:Se(t.element)}):t instanceof M?M.create(Se(t.unwrap())):t instanceof B?B.create(Se(t.unwrap())):t instanceof U?U.create(t.items.map(e=>Se(e))):t}function Ct(t,e){let n=V(t),r=V(e);if(t===e)return{valid:!0,data:t};if(n===p.object&&r===p.object){let s=b.objectKeys(e),a=b.objectKeys(t).filter(i=>s.indexOf(i)!==-1),o={...t,...e};for(let i of a){let c=Ct(t[i],e[i]);if(!c.valid)return{valid:!1};o[i]=c.data}return{valid:!0,data:o}}else if(n===p.array&&r===p.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let a=0;a<t.length;a++){let o=t[a],i=e[a],c=Ct(o,i);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return n===p.date&&r===p.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function _n(t,e){return new ge({values:t,typeName:g.ZodEnum,..._(e)})}function mn(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function vn(t,e={},n){return t?ee.create().superRefine((r,s)=>{let a=t(r);if(a instanceof Promise)return a.then(o=>{if(!o){let i=mn(e,r),c=i.fatal??n??!0;s.addIssue({code:"custom",...i,fatal:c})}});if(!a){let o=mn(e,r),i=o.fatal??n??!0;s.addIssue({code:"custom",...o,fatal:i})}}):ee.create()}var j,pn,v,qr,Qr,Xr,es,ts,ns,rs,ss,as,Rt,os,is,cs,us,ds,ls,hn,fs,X,oe,ie,ce,ue,Te,de,le,ee,Y,F,Ee,J,P,fe,G,at,pe,U,ot,Ae,$e,it,me,he,ge,ye,te,z,M,B,_e,ve,Re,_s,Ve,Ue,be,vs,g,bs,bn,kn,ks,xs,xn,ws,Ss,Ts,Es,As,$s,Rs,Cs,Os,Ns,Ds,Is,Ps,Ms,js,zs,Zs,Ls,Fs,Vs,Us,Bs,Ks,Hs,Ws,Gs,Ys,Js,qs,Qs,Xs,ea,ta,na,wn=S(()=>{tt();nt();fn();$t();Le();j=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}},pn=(t,e)=>{if(Q(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 I(t.common.issues);return this._error=n,this._error}}};v=class{get description(){return this._def.description}_getType(e){return V(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:V(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new $,ctx:{common:e.parent.common,data:e.data,parsedType:V(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(we(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:V(e)},s=this._parseSync({data:e,path:r.path,parent:r});return pn(r,s)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return Q(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=>Q(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:V(e)},s=this._parse({data:e,path:r.path,parent:r}),a=await(we(s)?s:Promise.resolve(s));return pn(r,a)}refine(e,n){let r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,a)=>{let o=e(s),i=()=>a.addIssue({code:d.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(i(),!1)):o?!0:(i(),!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 z({schema:this,typeName:g.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 M.create(this,this._def)}nullable(){return B.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return J.create(this)}promise(){return te.create(this,this._def)}or(e){return fe.create([this,e],this._def)}and(e){return pe.create(this,e,this._def)}transform(e){return new z({..._(this._def),schema:this,typeName:g.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new _e({..._(this._def),innerType:this,defaultValue:n,typeName:g.ZodDefault})}brand(){return new Ve({typeName:g.ZodBranded,type:this,..._(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new ve({..._(this._def),innerType:this,catchValue:n,typeName:g.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Ue.create(this,e)}readonly(){return be.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},qr=/^c[^\s-]{8,}$/i,Qr=/^[0-9a-z]+$/,Xr=/^[0-9A-HJKMNP-TV-Z]{26}$/i,es=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,ts=/^[a-z0-9_-]{21}$/i,ns=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,rs=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ss=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,as="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",os=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,is=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,cs=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,us=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ds=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ls=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,hn="((\\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])))",fs=new RegExp(`^${hn}$`);X=class t extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==p.string){let a=this._getOrReturnCtx(e);return f(a,{code:d.invalid_type,expected:p.string,received:a.parsedType}),h}let r=new $,s;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){let o=e.data.length>a.value,i=e.data.length<a.value;(o||i)&&(s=this._getOrReturnCtx(e,s),o?f(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):i&&f(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")ss.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"email",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")Rt||(Rt=new RegExp(as,"u")),Rt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"emoji",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")es.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"uuid",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")ts.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"nanoid",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")qr.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")Qr.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid2",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")Xr.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ulid",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),f(s,{validation:"url",code:d.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"regex",code:d.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?yn(a).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?fs.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?ps(a).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?rs.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"duration",code:d.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?ms(e.data,a.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ip",code:d.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?hs(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"jwt",code:d.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?gs(e.data,a.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cidr",code:d.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?ds.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64",code:d.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?ls.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64url",code:d.invalid_string,message:a.message}),r.dirty()):b.assertNever(a);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:d.invalid_string,...m.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...m.errToObj(e)})}url(e){return this._addCheck({kind:"url",...m.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...m.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...m.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...m.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...m.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...m.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...m.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...m.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...m.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...m.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...m.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...m.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,...m.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,...m.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...m.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...m.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...m.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...m.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...m.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...m.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...m.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...m.errToObj(n)})}nonempty(e){return this.min(1,m.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}};X.create=t=>new X({checks:[],typeName:g.ZodString,coerce:t?.coerce??!1,..._(t)});oe=class t extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==p.number){let a=this._getOrReturnCtx(e);return f(a,{code:d.invalid_type,expected:p.number,received:a.parsedType}),h}let r,s=new $;for(let a of this._def.checks)a.kind==="int"?b.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:d.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:d.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:d.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?ys(e.data,a.value)!==0&&(r=this._getOrReturnCtx(e,r),f(r,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:d.not_finite,message:a.message}),s.dirty()):b.assertNever(a);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,m.toString(n))}gt(e,n){return this.setLimit("min",e,!1,m.toString(n))}lte(e,n){return this.setLimit("max",e,!0,m.toString(n))}lt(e,n){return this.setLimit("max",e,!1,m.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:m.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:m.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:m.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:m.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:m.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:m.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"&&b.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)}};oe.create=t=>new oe({checks:[],typeName:g.ZodNumber,coerce:t?.coerce||!1,..._(t)});ie=class t extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==p.bigint)return this._getInvalidInput(e);let r,s=new $;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:d.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:d.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),f(r,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):b.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return f(n,{code:d.invalid_type,expected:p.bigint,received:n.parsedType}),h}gte(e,n){return this.setLimit("min",e,!0,m.toString(n))}gt(e,n){return this.setLimit("min",e,!1,m.toString(n))}lte(e,n){return this.setLimit("max",e,!0,m.toString(n))}lt(e,n){return this.setLimit("max",e,!1,m.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:m.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:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:m.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:m.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}};ie.create=t=>new ie({checks:[],typeName:g.ZodBigInt,coerce:t?.coerce??!1,..._(t)});ce=class extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==p.boolean){let r=this._getOrReturnCtx(e);return f(r,{code:d.invalid_type,expected:p.boolean,received:r.parsedType}),h}return C(e.data)}};ce.create=t=>new ce({typeName:g.ZodBoolean,coerce:t?.coerce||!1,..._(t)});ue=class t extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==p.date){let a=this._getOrReturnCtx(e);return f(a,{code:d.invalid_type,expected:p.date,received:a.parsedType}),h}if(Number.isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return f(a,{code:d.invalid_date}),h}let r=new $,s;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:d.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:d.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):b.assertNever(a);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:m.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:m.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}};ue.create=t=>new ue({checks:[],coerce:t?.coerce||!1,typeName:g.ZodDate,..._(t)});Te=class extends v{_parse(e){if(this._getType(e)!==p.symbol){let r=this._getOrReturnCtx(e);return f(r,{code:d.invalid_type,expected:p.symbol,received:r.parsedType}),h}return C(e.data)}};Te.create=t=>new Te({typeName:g.ZodSymbol,..._(t)});de=class extends v{_parse(e){if(this._getType(e)!==p.undefined){let r=this._getOrReturnCtx(e);return f(r,{code:d.invalid_type,expected:p.undefined,received:r.parsedType}),h}return C(e.data)}};de.create=t=>new de({typeName:g.ZodUndefined,..._(t)});le=class extends v{_parse(e){if(this._getType(e)!==p.null){let r=this._getOrReturnCtx(e);return f(r,{code:d.invalid_type,expected:p.null,received:r.parsedType}),h}return C(e.data)}};le.create=t=>new le({typeName:g.ZodNull,..._(t)});ee=class extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return C(e.data)}};ee.create=t=>new ee({typeName:g.ZodAny,..._(t)});Y=class extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return C(e.data)}};Y.create=t=>new Y({typeName:g.ZodUnknown,..._(t)});F=class extends v{_parse(e){let n=this._getOrReturnCtx(e);return f(n,{code:d.invalid_type,expected:p.never,received:n.parsedType}),h}};F.create=t=>new F({typeName:g.ZodNever,..._(t)});Ee=class extends v{_parse(e){if(this._getType(e)!==p.undefined){let r=this._getOrReturnCtx(e);return f(r,{code:d.invalid_type,expected:p.void,received:r.parsedType}),h}return C(e.data)}};Ee.create=t=>new Ee({typeName:g.ZodVoid,..._(t)});J=class t extends v{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==p.array)return f(n,{code:d.invalid_type,expected:p.array,received:n.parsedType}),h;if(s.exactLength!==null){let o=n.data.length>s.exactLength.value,i=n.data.length<s.exactLength.value;(o||i)&&(f(n,{code:o?d.too_big:d.too_small,minimum:i?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&&(f(n,{code:d.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&&(f(n,{code:d.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,i)=>s.type._parseAsync(new j(n,o,n.path,i)))).then(o=>$.mergeArray(r,o));let a=[...n.data].map((o,i)=>s.type._parseSync(new j(n,o,n.path,i)));return $.mergeArray(r,a)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:m.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:m.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:m.toString(n)}})}nonempty(e){return this.min(1,e)}};J.create=(t,e)=>new J({type:t,minLength:null,maxLength:null,exactLength:null,typeName:g.ZodArray,..._(e)});P=class t extends v{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=b.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==p.object){let u=this._getOrReturnCtx(e);return f(u,{code:d.invalid_type,expected:p.object,received:u.parsedType}),h}let{status:r,ctx:s}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),i=[];if(!(this._def.catchall instanceof F&&this._def.unknownKeys==="strip"))for(let u in s.data)o.includes(u)||i.push(u);let c=[];for(let u of o){let l=a[u],y=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new j(s,y,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof F){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of i)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")i.length>0&&(f(s,{code:d.unrecognized_keys,keys:i}),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 i){let y=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new j(s,y,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let y=await l.key,k=await l.value;u.push({key:y,value:k,alwaysSet:l.alwaysSet})}return u}).then(u=>$.mergeObjectSync(r,u)):$.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return m.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:m.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:g.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 b.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 b.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return Se(this)}partial(e){let n={};for(let r of b.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 b.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof M;)a=a._def.innerType;n[r]=a}return new t({...this._def,shape:()=>n})}keyof(){return _n(b.objectKeys(this.shape))}};P.create=(t,e)=>new P({shape:()=>t,unknownKeys:"strip",catchall:F.create(),typeName:g.ZodObject,..._(e)});P.strictCreate=(t,e)=>new P({shape:()=>t,unknownKeys:"strict",catchall:F.create(),typeName:g.ZodObject,..._(e)});P.lazycreate=(t,e)=>new P({shape:t,unknownKeys:"strip",catchall:F.create(),typeName:g.ZodObject,..._(e)});fe=class extends v{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function s(a){for(let i of a)if(i.result.status==="valid")return i.result;for(let i of a)if(i.result.status==="dirty")return n.common.issues.push(...i.ctx.common.issues),i.result;let o=a.map(i=>new I(i.ctx.common.issues));return f(n,{code:d.invalid_union,unionErrors:o}),h}if(n.common.async)return Promise.all(r.map(async a=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await a._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let a,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"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(a)return n.common.issues.push(...a.ctx.common.issues),a.result;let i=o.map(c=>new I(c));return f(n,{code:d.invalid_union,unionErrors:i}),h}}get options(){return this._def.options}};fe.create=(t,e)=>new fe({options:t,typeName:g.ZodUnion,..._(e)});G=t=>t instanceof me?G(t.schema):t instanceof z?G(t.innerType()):t instanceof he?[t.value]:t instanceof ge?t.options:t instanceof ye?b.objectValues(t.enum):t instanceof _e?G(t._def.innerType):t instanceof de?[void 0]:t instanceof le?[null]:t instanceof M?[void 0,...G(t.unwrap())]:t instanceof B?[null,...G(t.unwrap())]:t instanceof Ve||t instanceof be?G(t.unwrap()):t instanceof ve?G(t._def.innerType):[],at=class t extends v{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==p.object)return f(n,{code:d.invalid_type,expected:p.object,received:n.parsedType}),h;let r=this.discriminator,s=n.data[r],a=this.optionsMap.get(s);return a?n.common.async?a._parseAsync({data:n.data,path:n.path,parent:n}):a._parseSync({data:n.data,path:n.path,parent:n}):(f(n,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),h)}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 a of n){let o=G(a.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of o){if(s.has(i))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);s.set(i,a)}}return new t({typeName:g.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,..._(r)})}};pe=class extends v{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=(a,o)=>{if(rt(a)||rt(o))return h;let i=Ct(a.value,o.value);return i.valid?((st(a)||st(o))&&n.dirty(),{status:n.value,value:i.data}):(f(r,{code:d.invalid_intersection_types}),h)};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(([a,o])=>s(a,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}))}};pe.create=(t,e,n)=>new pe({left:t,right:e,typeName:g.ZodIntersection,..._(n)});U=class t extends v{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==p.array)return f(r,{code:d.invalid_type,expected:p.array,received:r.parsedType}),h;if(r.data.length<this._def.items.length)return f(r,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),h;!this._def.rest&&r.data.length>this._def.items.length&&(f(r,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let a=[...r.data].map((o,i)=>{let c=this._def.items[i]||this._def.rest;return c?c._parse(new j(r,o,r.path,i)):null}).filter(o=>!!o);return r.common.async?Promise.all(a).then(o=>$.mergeArray(n,o)):$.mergeArray(n,a)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};U.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new U({items:t,typeName:g.ZodTuple,rest:null,..._(e)})};ot=class t extends v{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!==p.object)return f(r,{code:d.invalid_type,expected:p.object,received:r.parsedType}),h;let s=[],a=this._def.keyType,o=this._def.valueType;for(let i in r.data)s.push({key:a._parse(new j(r,i,r.path,i)),value:o._parse(new j(r,r.data[i],r.path,i)),alwaysSet:i in r.data});return r.common.async?$.mergeObjectAsync(n,s):$.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof v?new t({keyType:e,valueType:n,typeName:g.ZodRecord,..._(r)}):new t({keyType:X.create(),valueType:e,typeName:g.ZodRecord,..._(n)})}},Ae=class extends v{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!==p.map)return f(r,{code:d.invalid_type,expected:p.map,received:r.parsedType}),h;let s=this._def.keyType,a=this._def.valueType,o=[...r.data.entries()].map(([i,c],u)=>({key:s._parse(new j(r,i,r.path,[u,"key"])),value:a._parse(new j(r,c,r.path,[u,"value"]))}));if(r.common.async){let i=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 h;(u.status==="dirty"||l.status==="dirty")&&n.dirty(),i.set(u.value,l.value)}return{status:n.value,value:i}})}else{let i=new Map;for(let c of o){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return h;(u.status==="dirty"||l.status==="dirty")&&n.dirty(),i.set(u.value,l.value)}return{status:n.value,value:i}}}};Ae.create=(t,e,n)=>new Ae({valueType:e,keyType:t,typeName:g.ZodMap,..._(n)});$e=class t extends v{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==p.set)return f(r,{code:d.invalid_type,expected:p.set,received:r.parsedType}),h;let s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(f(r,{code:d.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&&(f(r,{code:d.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());let a=this._def.valueType;function o(c){let u=new Set;for(let l of c){if(l.status==="aborted")return h;l.status==="dirty"&&n.dirty(),u.add(l.value)}return{status:n.value,value:u}}let i=[...r.data.values()].map((c,u)=>a._parse(new j(r,c,r.path,u)));return r.common.async?Promise.all(i).then(c=>o(c)):o(i)}min(e,n){return new t({...this._def,minSize:{value:e,message:m.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:m.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};$e.create=(t,e)=>new $e({valueType:t,minSize:null,maxSize:null,typeName:g.ZodSet,..._(e)});it=class t extends v{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==p.function)return f(n,{code:d.invalid_type,expected:p.function,received:n.parsedType}),h;function r(i,c){return Fe({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,xe(),W].filter(u=>!!u),issueData:{code:d.invalid_arguments,argumentsError:c}})}function s(i,c){return Fe({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,xe(),W].filter(u=>!!u),issueData:{code:d.invalid_return_type,returnTypeError:c}})}let a={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof te){let i=this;return C(async function(...c){let u=new I([]),l=await i._def.args.parseAsync(c,a).catch(T=>{throw u.addIssue(r(c,T)),u}),y=await Reflect.apply(o,this,l);return await i._def.returns._def.type.parseAsync(y,a).catch(T=>{throw u.addIssue(s(y,T)),u})})}else{let i=this;return C(function(...c){let u=i._def.args.safeParse(c,a);if(!u.success)throw new I([r(c,u.error)]);let l=Reflect.apply(o,this,u.data),y=i._def.returns.safeParse(l,a);if(!y.success)throw new I([s(l,y.error)]);return y.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:U.create(e).rest(Y.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||U.create([]).rest(Y.create()),returns:n||Y.create(),typeName:g.ZodFunction,..._(r)})}},me=class extends v{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})}};me.create=(t,e)=>new me({getter:t,typeName:g.ZodLazy,..._(e)});he=class extends v{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return f(n,{received:n.data,code:d.invalid_literal,expected:this._def.value}),h}return{status:"valid",value:e.data}}get value(){return this._def.value}};he.create=(t,e)=>new he({value:t,typeName:g.ZodLiteral,..._(e)});ge=class t extends v{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return f(n,{expected:b.joinValues(r),received:n.parsedType,code:d.invalid_type}),h}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 f(n,{received:n.data,code:d.invalid_enum_value,options:r}),h}return C(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})}};ge.create=_n;ye=class extends v{_parse(e){let n=b.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==p.string&&r.parsedType!==p.number){let s=b.objectValues(n);return f(r,{expected:b.joinValues(s),received:r.parsedType,code:d.invalid_type}),h}if(this._cache||(this._cache=new Set(b.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=b.objectValues(n);return f(r,{received:r.data,code:d.invalid_enum_value,options:s}),h}return C(e.data)}get enum(){return this._def.values}};ye.create=(t,e)=>new ye({values:t,typeName:g.ZodNativeEnum,..._(e)});te=class extends v{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==p.promise&&n.common.async===!1)return f(n,{code:d.invalid_type,expected:p.promise,received:n.parsedType}),h;let r=n.parsedType===p.promise?n.data:Promise.resolve(n.data);return C(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};te.create=(t,e)=>new te({type:t,typeName:g.ZodPromise,..._(e)});z=class extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===g.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:o=>{f(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){let o=s.transform(r.data,a);if(r.common.async)return Promise.resolve(o).then(async i=>{if(n.value==="aborted")return h;let c=await this._def.schema._parseAsync({data:i,path:r.path,parent:r});return c.status==="aborted"?h:c.status==="dirty"?ae(c.value):n.value==="dirty"?ae(c.value):c});{if(n.value==="aborted")return h;let i=this._def.schema._parseSync({data:o,path:r.path,parent:r});return i.status==="aborted"?h:i.status==="dirty"?ae(i.value):n.value==="dirty"?ae(i.value):i}}if(s.type==="refinement"){let o=i=>{let c=s.refinement(i,a);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 i};if(r.common.async===!1){let i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?h:(i.status==="dirty"&&n.dirty(),o(i.value),{status:n.value,value:i.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>i.status==="aborted"?h:(i.status==="dirty"&&n.dirty(),o(i.value).then(()=>({status:n.value,value:i.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(!Q(o))return h;let i=s.transform(o.value,a);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:i}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Q(o)?Promise.resolve(s.transform(o.value,a)).then(i=>({status:n.value,value:i})):h);b.assertNever(s)}};z.create=(t,e,n)=>new z({schema:t,typeName:g.ZodEffects,effect:e,..._(n)});z.createWithPreprocess=(t,e,n)=>new z({schema:e,effect:{type:"preprocess",transform:t},typeName:g.ZodEffects,..._(n)});M=class extends v{_parse(e){return this._getType(e)===p.undefined?C(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};M.create=(t,e)=>new M({innerType:t,typeName:g.ZodOptional,..._(e)});B=class extends v{_parse(e){return this._getType(e)===p.null?C(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};B.create=(t,e)=>new B({innerType:t,typeName:g.ZodNullable,..._(e)});_e=class extends v{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===p.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};_e.create=(t,e)=>new _e({innerType:t,typeName:g.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});ve=class extends v{_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 we(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new I(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new I(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};ve.create=(t,e)=>new ve({innerType:t,typeName:g.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});Re=class extends v{_parse(e){if(this._getType(e)!==p.nan){let r=this._getOrReturnCtx(e);return f(r,{code:d.invalid_type,expected:p.nan,received:r.parsedType}),h}return{status:"valid",value:e.data}}};Re.create=t=>new Re({typeName:g.ZodNaN,..._(t)});_s=Symbol("zod_brand"),Ve=class extends v{_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}},Ue=class t extends v{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?h:a.status==="dirty"?(n.dirty(),ae(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{let s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?h: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:g.ZodPipeline})}},be=class extends v{_parse(e){let n=this._def.innerType._parse(e),r=s=>(Q(s)&&(s.value=Object.freeze(s.value)),s);return we(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};be.create=(t,e)=>new be({innerType:t,typeName:g.ZodReadonly,..._(e)});vs={object:P.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"})(g||(g={}));bs=(t,e={message:`Input not instance of ${t.name}`})=>vn(n=>n instanceof t,e),bn=X.create,kn=oe.create,ks=Re.create,xs=ie.create,xn=ce.create,ws=ue.create,Ss=Te.create,Ts=de.create,Es=le.create,As=ee.create,$s=Y.create,Rs=F.create,Cs=Ee.create,Os=J.create,Ns=P.create,Ds=P.strictCreate,Is=fe.create,Ps=at.create,Ms=pe.create,js=U.create,zs=ot.create,Zs=Ae.create,Ls=$e.create,Fs=it.create,Vs=me.create,Us=he.create,Bs=ge.create,Ks=ye.create,Hs=te.create,Ws=z.create,Gs=M.create,Ys=B.create,Js=z.createWithPreprocess,qs=Ue.create,Qs=()=>bn().optional(),Xs=()=>kn().optional(),ea=()=>xn().optional(),ta={string:(t=>X.create({...t,coerce:!0})),number:(t=>oe.create({...t,coerce:!0})),boolean:(t=>ce.create({...t,coerce:!0})),bigint:(t=>ie.create({...t,coerce:!0})),date:(t=>ue.create({...t,coerce:!0}))},na=h});var Z={};ke(Z,{BRAND:()=>_s,DIRTY:()=>ae,EMPTY_PATH:()=>Jr,INVALID:()=>h,NEVER:()=>na,OK:()=>C,ParseStatus:()=>$,Schema:()=>v,ZodAny:()=>ee,ZodArray:()=>J,ZodBigInt:()=>ie,ZodBoolean:()=>ce,ZodBranded:()=>Ve,ZodCatch:()=>ve,ZodDate:()=>ue,ZodDefault:()=>_e,ZodDiscriminatedUnion:()=>at,ZodEffects:()=>z,ZodEnum:()=>ge,ZodError:()=>I,ZodFirstPartyTypeKind:()=>g,ZodFunction:()=>it,ZodIntersection:()=>pe,ZodIssueCode:()=>d,ZodLazy:()=>me,ZodLiteral:()=>he,ZodMap:()=>Ae,ZodNaN:()=>Re,ZodNativeEnum:()=>ye,ZodNever:()=>F,ZodNull:()=>le,ZodNullable:()=>B,ZodNumber:()=>oe,ZodObject:()=>P,ZodOptional:()=>M,ZodParsedType:()=>p,ZodPipeline:()=>Ue,ZodPromise:()=>te,ZodReadonly:()=>be,ZodRecord:()=>ot,ZodSchema:()=>v,ZodSet:()=>$e,ZodString:()=>X,ZodSymbol:()=>Te,ZodTransformer:()=>z,ZodTuple:()=>U,ZodType:()=>v,ZodUndefined:()=>de,ZodUnion:()=>fe,ZodUnknown:()=>Y,ZodVoid:()=>Ee,addIssueToContext:()=>f,any:()=>As,array:()=>Os,bigint:()=>xs,boolean:()=>xn,coerce:()=>ta,custom:()=>vn,date:()=>ws,datetimeRegex:()=>yn,defaultErrorMap:()=>W,discriminatedUnion:()=>Ps,effect:()=>Ws,enum:()=>Bs,function:()=>Fs,getErrorMap:()=>xe,getParsedType:()=>V,instanceof:()=>bs,intersection:()=>Ms,isAborted:()=>rt,isAsync:()=>we,isDirty:()=>st,isValid:()=>Q,late:()=>vs,lazy:()=>Vs,literal:()=>Us,makeIssue:()=>Fe,map:()=>Zs,nan:()=>ks,nativeEnum:()=>Ks,never:()=>Rs,null:()=>Es,nullable:()=>Ys,number:()=>kn,object:()=>Ns,objectUtil:()=>Et,oboolean:()=>ea,onumber:()=>Xs,optional:()=>Gs,ostring:()=>Qs,pipeline:()=>qs,preprocess:()=>Js,promise:()=>Hs,quotelessJson:()=>Wr,record:()=>zs,set:()=>Ls,setErrorMap:()=>Yr,strictObject:()=>Ds,string:()=>bn,symbol:()=>Ss,transformer:()=>Ws,tuple:()=>js,undefined:()=>Ts,union:()=>Is,unknown:()=>$s,util:()=>b,void:()=>Cs});var Ot=S(()=>{nt();$t();ln();Le();wn();tt()});var Sn=S(()=>{Ot();Ot()});var ra,sa,Ce,Tn=S(()=>{"use strict";Sn();ra=Z.enum(["normal","compact","minimal"]),sa=Z.enum(["off","light","balanced","max"]),Ce=Z.object({enabled:Z.boolean().default(!0),telemetryOptIn:Z.boolean().default(!0),outputVerbosity:ra.default("compact"),reducer:sa.default("off"),filters:Z.object({enableAll:Z.boolean().default(!0),disabled:Z.array(Z.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})})});var In={};ke(In,{clearSettingsCache:()=>da,loadSettingsCache:()=>Ne,saveSettingsCache:()=>Dn,updateSettingsCache:()=>ua});import{readFile as Rn,writeFile as Cn,mkdir as On,chmod as aa,rm as Be,rename as Nn,readdir as oa}from"node:fs/promises";import{randomUUID as ia}from"node:crypto";import{join as Oe}from"node:path";import{setTimeout as En}from"node:timers/promises";async function Ne(){let t=null;try{let e=JSON.parse(await Rn(Oe(w(),Nt),"utf8"));typeof e=="object"&&e!==null&&!Array.isArray(e)&&(t=e)}catch{}return t?Ce.parse({...An,...t}):An}async function Dn(t){await On(w(),{recursive:!0,mode:448});let e=Oe(w(),Nt),n=`${e}.tmp-${process.pid}-${process.hrtime.bigint()}`;await Cn(n,JSON.stringify(t,null,2),{mode:384});try{await aa(n,384),await Nn(n,e)}catch(r){try{await Be(n,{force:!0})}catch{}throw r}}async function $n(t){let e=[];for(let n of await oa(t)){let r=/^([1-9]\d*)-[0-9a-f-]{36}\.json$/.exec(n);if(!r)continue;let s=Oe(t,n);try{process.kill(Number(r[1]),0)}catch(a){let o=a.code;if(o==="ESRCH"){await Be(s,{force:!0});continue}if(o!=="EPERM")throw a}try{let a=JSON.parse(await Rn(s,"utf8"));if(!Number.isSafeInteger(a)||a<0)throw new Error("Invalid local settings lock");e.push({id:n,ticket:a})}catch(a){if(a.code!=="ENOENT")throw a}}return e}async function ua(t){let e=ca.parse(t),n=Oe(w(),"settings-cache-locks");await On(n,{recursive:!0,mode:448});let r=`${process.pid}-${ia()}.json`,s=Oe(n,r),a=`${s}.tmp`,o=performance.now()+3e3,i=async c=>{for(await Cn(a,String(c),{mode:384});;)try{await Nn(a,s);return}catch(u){let l=u.code;if(process.platform!=="win32"||l!=="EPERM"&&l!=="EBUSY"||performance.now()>=o)throw u;await En(10)}};try{await i(0);let c=Math.max(0,...(await $n(n)).map(u=>u.ticket))+1;if(!Number.isSafeInteger(c))throw new Error("Invalid local settings lock");for(await i(c);;){if(!(await $n(n)).some(l=>l.id!==r&&(l.ticket===0||l.ticket<c||l.ticket===c&&l.id<r))){let l=await Ne(),y=Ce.parse({...l,...e,filters:{...l.filters,...e.filters}});return await Dn(y),y}if(performance.now()>=o)throw new Error("Timed out waiting for local settings lock after 3 seconds; another process may still be updating settings");await En(10)}}finally{await Promise.all([Be(s,{force:!0}),Be(a,{force:!0})])}}async function da(){try{await Be(Oe(w(),Nt),{force:!0})}catch{}}var Nt,An,ca,ct=S(()=>{"use strict";Tn();L();Nt="settings-cache.json",An=Ce.parse({}),ca=Ce.partial().extend({filters:Ce.shape.filters.removeDefault().partial().optional()})});var Vn={};ke(Vn,{STATIC_COMMAND_NAMES:()=>ut,commandInstalled:()=>Fn,commandsInstallStatus:()=>ka,installCommand:()=>va,isFresh:()=>ga,pruneCommands:()=>ba,pruneSkills:()=>_a,readBundleRefresh:()=>wa,readSkill:()=>Sa,recordBundleRefresh:()=>xa,writeSkill:()=>ya});import{chmod as Dt,mkdir as dt,readFile as Ke,writeFile as lt,stat as It,readdir as la,rm as Mn}from"node:fs/promises";import{existsSync as fa}from"node:fs";import{dirname as pa}from"node:path";async function zn(){try{let t=JSON.parse(await Ke(Tt(),"utf8"));return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}catch{return[]}}async function Zn(t){try{await dt(w(),{recursive:!0,mode:448}),await lt(Tt(),JSON.stringify(t),{mode:384})}catch{}}function Ln(){let t=Number(process.env.TOKMIZER_MAX_BUNDLE_AGE_MS);return Number.isFinite(t)&&t>0?Math.min(t,Pn):Pn}async function ga(t){try{let e=await It(re(t)),n=Date.now()-e.mtimeMs;return n<ha&&n<=Ln()}catch{return!1}}async function ya(t,e){await dt(Xe(),{recursive:!0,mode:448}),await lt(re(t),e,{mode:384}),await Dt(re(t),384)}async function _a(t){let e=new Set(t),n;try{n=await la(Xe())}catch{return}for(let r of n){if(!r.endsWith(".md"))continue;let s=r.slice(0,-3);if(!e.has(s))try{await Mn(re(s))}catch{}}}async function va(t,e){if(!process.env.TOKMIZER_CLAUDE_COMMANDS_DIR&&!fa(pa(et())))return;await dt(et(),{recursive:!0});try{if(!(await Ke(se(t),"utf8")).includes(jn))return}catch{}await lt(se(t),e,{mode:384}),await Dt(se(t),384);let n=await zn();n.includes(t)||await Zn([...n,t])}async function ba(t){let e=new Set([...t,...ut]),n=await zn(),r=new Set([...n,...ma]);for(let s of r)if(!e.has(s))try{if(!(await Ke(se(s),"utf8")).includes(jn))continue;await Mn(se(s))}catch{}await Zn(n.filter(s=>e.has(s)))}async function ka(){let t=0;for(let e of ut)await Fn(e)&&t++;return{installed:t,total:ut.length}}async function Fn(t){try{return await It(se(t)),!0}catch{return!1}}async function xa(t){try{await dt(w(),{recursive:!0,mode:448}),await lt(Qe(),JSON.stringify({at:Date.now(),error:t}),{mode:384}),await Dt(Qe(),384)}catch{}}async function wa(){try{return JSON.parse(await Ke(Qe(),"utf8"))}catch{return null}}async function Sa(t){try{let e=await It(re(t));return Date.now()-e.mtimeMs>Ln()?null:await Ke(re(t),"utf8")}catch{return null}}var jn,ut,ma,ha,Pn,Un=S(()=>{"use strict";L();jn="managed-by: tokmizer",ut=["tkr","tkr-gain","tkr-status","tkr-link","tkr-unlink","tkr-compression","tkr-telemetry","tkr-update","tkr-yolo"],ma=["power","tkr-reducer"];ha=3600*1e3,Pn=10080*60*1e3});import{join as Ta}from"node:path";import{mkdir as jc,readFile as Ea,writeFile as zc,unlink as Zc,rename as Lc}from"node:fs/promises";function $a(){try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t&&t.length>0?t:"Etc/UTC"}catch{return"Etc/UTC"}}function Ra(t){return t?.dir??w()}async function ft(t){let e=Ra(t);try{let n=await Ea(Ta(e,Aa),"utf8"),r=JSON.parse(n),s=r.timeZone;return{...r,lastSettingsRevision:r.lastSettingsRevision??0,get timeZone(){return s??=$a()},bonusActive:r.bonusActive??!1,...r.bonusResetAt!==void 0?{bonusResetAt:r.bonusResetAt}:{}}}catch{return null}}var Aa,Pt=S(()=>{"use strict";L();Aa="state.json"});var Bn={};ke(Bn,{reducerStillEntitled:()=>Ca});async function Ca(){return await ft()!==null}var Kn=S(()=>{"use strict";Pt()});function Mt(t){let e=t;for(let[n,r]of Oa)e=e.replace(n,r);return e}var Oa,K,Bc,Hn=S(()=>{"use strict";Oa=[[/(\baws_(?:secret_access_key|session_token|access_key_id)\s+)\S+/gi,"$1[REDACTED]"],[/(\bsshpass\b[^;&|\n]{0,200}?\s-p\s*)\S+/g,"$1[REDACTED]"],[/(\bredis-cli\b[^;&|\n]{0,200}?\s(?:-a|--pass)\s+)\S+/g,"$1[REDACTED]"],[/(\bopenssl\b[^;&|\n]{0,200}?\s-k\s+)\S+/g,"$1[REDACTED]"],[/(\s-pass(?:in|out)?\s+(?:pass|env|file):)\S+/g,"$1[REDACTED]"],[/(https?:\/\/hooks\.slack\.com\/(?:services|workflows|triggers)\/)\S+/gi,"$1[REDACTED]"],[/(authorization\s*:\s*)([A-Za-z][A-Za-z0-9._-]*)\s+[^\s'"]+/gi,"$1$2 [REDACTED]"],[/(authorization\s*:\s*)[A-Za-z0-9._\-+/=]{8,}/gi,"$1[REDACTED]"],[/(bearer\s+)[A-Za-z0-9._\-+/=]{8,}/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-b|--cookie)[=\s]+['"]?)[^\s'";=]+=[^\s'";]+(?:\s*;\s*[^\s'";=]+=[^\s'";]+)*/gi,"$1[REDACTED]"],[/((?:^|[\s'"])(?:Set-)?Cookie\s*:\s*)[^\s'";=]+=[^\s'";]+(?:\s*;\s*[^\s'";=]+=[^\s'";]+)*/gi,"$1[REDACTED]"],[/(--?(?:password|passwd|passphrase|apipass|pass|pwd|token|api[-_]?key|secret|bearer|cookie|jwt)(?:-[a-z0-9]+)*[=\s]+)\S+/gi,"$1[REDACTED]"],[/((?:^|\s)-b[=\s]?['"]?)[^\s'"=]+=[^\s'"]+/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?[^\s:/'"]*:)(\/[^/\s'"][^\s'"]*|[^\s/'"0-9][^\s'"]*|[0-9][^\s'"]*[^\s'"0-9][^\s'"]*)/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?[^\s:/'"]*[^\s:/'"0-9][^\s:/'"]*:)(?:\/[^/\s'"]|[^\s/'"])[^\s'"]*/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?:)(?:\/[^/\s'"]|[^\s/'"])[^\s'"]*/gi,"$1[REDACTED]"],[/((?:[A-Za-z0-9]+-){0,8}(?:X-Api-Key|Private-Token|[A-Za-z0-9]+-(?:Token|Key|Auth|Secret))\s*:\s*)[^\s'"]+/gi,"$1[REDACTED]"],[/((?:^|[\s'"])(?:Set-)?Cookie\s*:\s*)[^\s'"]+/gi,"$1[REDACTED]"],[/(-i\s+)(\/[^\s]+|~\/[^\s]+|[A-Z]:\\[^\s]+)/g,"$1[REDACTED]"],[/([a-zA-Z][a-zA-Z0-9+.-]{0,31}:\/\/[^:/\s@]*:)[^\s@]+(@[^@/\s]+)/g,"$1[REDACTED]$2"],[/(AWS_(?:ACCESS_KEY_ID|SECRET_ACCESS_KEY|SESSION_TOKEN)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(GOOGLE_APPLICATION_CREDENTIALS\s*=\s*)\S+/g,"$1[REDACTED]"],[/(AZURE_(?:CLIENT_SECRET|TENANT_ID|CLIENT_ID)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-(?:proj-)?[A-Za-z0-9_-]{20,})/g,"sk-[REDACTED]"],[/\b(OPENAI_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(ANTHROPIC_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-ant-[A-Za-z0-9_-]{20,})/g,"sk-ant-[REDACTED]"],[/\b(GH(?:_|ITHUB_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(GITLAB_TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(SLACK_(?:BOT_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/(xox[bpsoa]-[A-Za-z0-9-]{10,})/g,"xox[REDACTED]"],[/(xapp-[A-Za-z0-9-]{10,})/g,"[REDACTED]"],[/(sk_(?:test|live)_[A-Za-z0-9]{16,})/g,"sk_[REDACTED]"],[/(gh[a-z])_[A-Za-z0-9]{20,}/g,"$1_[REDACTED]"],[/(github_pat)_[A-Za-z0-9_]{20,}/g,"$1_[REDACTED]"],[/(gl(?:pat|rt|soat|imt|dt|ft|agent|oas|cbt|ptt))-[A-Za-z0-9_-]{16,}/g,"$1-[REDACTED]"],[/(npm_[A-Za-z0-9_-]{20,})/g,"npm_[REDACTED]"],[/(?:AKIA|ASIA|AGPA|AIDA|AROA|ANPA)[0-9A-Z]{16,}/g,"[REDACTED_AWS_KEY]"],[/AIza[A-Za-z0-9_-]{35}/g,"[REDACTED_GOOGLE_KEY]"],[/hv[sb]\.[A-Za-z0-9_-]{20,}/g,"[REDACTED_VAULT_TOKEN]"],[/dop_v1_[A-Za-z0-9]{40,}/g,"[REDACTED]"],[/dckr_pat_[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/pypi-[A-Za-z0-9_-]{16,}/g,"[REDACTED]"],[/rk_(?:live|test)_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/whsec_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/SG\.[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/(eyJ[A-Za-z0-9_-]{6,}(?:\.[A-Za-z0-9_-]{4,}){1,2})/g,"[REDACTED_JWT]"],[/-----BEGIN [A-Z ]*PRIVATE KEY-----(?:[\s\S]*?-----END[^\n]*-----|\r?\n[A-Za-z0-9+/=][A-Za-z0-9+/=\r\n]*)?/g,"[REDACTED_PEM]"],[/\b((?:--?)?[A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|AUTH|_PWD)[A-Za-z0-9_]*['"]?\s*=\s*)(?:"[^"]*"|'[^']*'|[^"'\s]\S*)/gi,"$1[REDACTED]"],[/\b([A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|_PWD)[A-Za-z0-9_]*['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/((?:^|[\s'"{,])['"]?(?:[A-Za-z0-9_]+_)?auth['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/(\bpwd\s*[=:]\s*)(?:"[^"]*"|'[^']*'|[^/~\s][^\s;'"]*)/gi,"$1[REDACTED]"],[/([=:]\s*["']?)[A-Za-z0-9_\-+/=]{40,}/g,"$1[REDACTED]"]];K="[tkr: secret masked]",Bc=[[/(-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----)(?:\r?\n(?:[A-Za-z0-9+/=]{16,}|[A-Za-z-]+: [^\r\n]*|\r?(?=\n)))*(?:(?:\r?\n[A-Za-z0-9+/=]{1,15})?\r?\n-----END [A-Z0-9 ]*PRIVATE KEY-----)?/g,`$1${K}`],[/(?<![A-Za-z0-9_])(gh[pousr])_[A-Za-z0-9]{36,255}(?![A-Za-z0-9])/g,`$1_${K}`],[/(?<![A-Za-z0-9_])github_pat_[A-Za-z0-9_]{22,255}/g,`github_pat_${K}`],[/(?<![A-Za-z0-9_])npm_[A-Za-z0-9]{36}(?![A-Za-z0-9])/g,`npm_${K}`],[/(?<![A-Z0-9])(AKIA|ASIA)[A-Z0-9]{16}(?![A-Z0-9])/g,`$1${K}`],[/(?<![A-Za-z0-9])(xox[abpors]-)[A-Za-z0-9-]{10,}/g,`$1${K}`],[/(?<![A-Za-z0-9])((?:sk|rk)_live_)[A-Za-z0-9]{16,}/g,`$1${K}`],[/(?<![A-Za-z0-9_-])(sk-(?:ant-|proj-))[A-Za-z0-9_-]{20,}/g,`$1${K}`],[/(authorization["']?\s*[:=]\s*["']?bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi,`$1${K}`],[/(?<![A-Za-z0-9+.-])([a-zA-Z][a-zA-Z0-9+.-]{0,31}:\/\/[^\s:/@]*:)[^\s@/]+(@[^\s@/]+)/g,`$1${K}$2`]]});function Wn(){let t=process.env.TOKMIZER_BASE_URL;if(t===De||t===`${De}/`||!t)return De;try{let e=new URL(t);return e.protocol==="http:"&&Na.has(e.hostname)&&!e.username&&!e.password?t:De}catch{return De}}var De,Na,Gn=S(()=>{"use strict";De="https://tokmizer.com",Na=new Set(["127.0.0.1","localhost"])});import Ie from"node:os";import{createHash as Da,createHmac as Yn,randomUUID as Ia}from"node:crypto";import{readFile as Jn,writeFile as qn,mkdir as Pa}from"node:fs/promises";async function Ma(){try{let n=(await Jn(Ze(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(n))return n}catch{}await Pa(w(),{recursive:!0,mode:448});let t=Ia();try{return await qn(Ze(),t,{mode:384,flag:"wx"}),t}catch{try{let e=(await Jn(Ze(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(e))return e}catch{}return await qn(Ze(),t,{mode:384}),t}}function jt(t){return Da("sha256").update(t).digest("hex")}function ja(){let t=Ie.networkInterfaces();for(let e of Object.keys(t))for(let n of t[e]??[])if(!n.internal&&n.mac&&n.mac!=="00:00:00:00:00:00")return n.mac;return"no-mac"}async function Qn(){let t=await Ma(),e=Ie.hostname(),n=Ie.platform(),r=Ie.release(),s=Ie.cpus(),a=s[0]?.model??"unknown",o=s.length,i=ja(),c=Ie.userInfo().username,u=[e,n,r,a,String(o),jt(i),jt(c),t].join("|");return{fingerprint:jt(u),installId:t,hostname:e,os:n,osVersion:r,cpuModel:a,cpuCores:o,macHash:Yn("sha256",t).update(i).digest("hex"),usernameHash:Yn("sha256",t).update(c).digest("hex")}}var Xn=S(()=>{"use strict";L()});import{createRequire as za}from"node:module";function La(){let t="1.0.0";if(t)return t;for(let e of["../package.json","../../package.json"])try{let n=Za(e).version;if(typeof n=="string"&&n)return n}catch{}return"0.0.0"}var Za,zt,Zt=S(()=>{"use strict";Za=za(import.meta.url);zt=La()});var er=S(()=>{"use strict"});import{existsSync as Fa,mkdirSync as nu,rmSync as ru,writeFileSync as su}from"node:fs";import{join as Va}from"node:path";function Ka(){return Va(w(),"network-off")}function Ha(){let t=process.env.TOKMIZER_NETWORK;return t!==void 0&&Ua.has(t.trim().toLowerCase())}function He(){return Ha()?!1:!Fa(Ka())}function tr(){if(!He())throw new Lt}var Ua,Ba,iu,Lt,pt=S(()=>{"use strict";L();Ua=new Set(["0","off","false","no"]),Ba="Network is off for Tokmizer. Turn it back on with: tkr network on",iu=["Tokmizer contacts tokmizer.com to keep its rules up to date and to improve the product. No account or email is needed.","It sends a random install ID, your computer name, OS and CPU model, a hash of your network card address and of your user name, and the plugin version. Command contents and output are never sent.","Usage stats (command names, token counts and install health counts) are sent only while they are on. Check with: tkr telemetry status.","Turn all network access off: tkr network off. Usage stats only: tkr telemetry off."].join(`
3
+ var Br=Object.defineProperty;var S=(t,e,n)=>()=>{if(n)throw n[0];try{return t&&(e=t(t=0)),e}catch(r){throw n=[r],r}};var ke=(t,e)=>{for(var n in e)Br(t,n,{get:e[n],enumerable:!0})};import cn from"node:os";import{join as q}from"node:path";function w(){return process.env.TOKMIZER_HOME||q(cn.homedir(),".tokmizer")}function Ze(){return q(w(),"install-id")}function Qe(){return q(w(),"bundle-refresh.json")}function Xe(){return q(w(),"skills")}function re(t){return q(Xe(),`${t}.md`)}function Tt(){return q(w(),"managed-commands.json")}function et(){return process.env.TOKMIZER_CLAUDE_COMMANDS_DIR||q(cn.homedir(),".claude","commands")}function se(t){return q(et(),`${t}.md`)}var L=S(()=>{"use strict"});var b,Et,p,V,Le=S(()=>{(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{let a={};for(let o of s)a[o]=o;return a},t.getValidEnumValues=s=>{let a=t.objectKeys(s).filter(i=>typeof s[s[i]]!="number"),o={};for(let i of a)o[i]=s[i];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(a){return s[a]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let a=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&a.push(o);return a},t.find=(s,a)=>{for(let o of s)if(a(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,a=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}t.joinValues=r,t.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(b||(b={}));(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Et||(Et={}));p=b.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),V=t=>{switch(typeof t){case"undefined":return p.undefined;case"string":return p.string;case"number":return Number.isNaN(t)?p.nan:p.number;case"boolean":return p.boolean;case"function":return p.function;case"bigint":return p.bigint;case"symbol":return p.symbol;case"object":return Array.isArray(t)?p.array:t===null?p.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?p.promise:typeof Map<"u"&&t instanceof Map?p.map:typeof Set<"u"&&t instanceof Set?p.set:typeof Date<"u"&&t instanceof Date?p.date:p.object;default:return p.unknown}}});var d,Wr,I,tt=S(()=>{Le();d=b.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"]),Wr=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),I=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(a){return a.message},r={_errors:[]},s=a=>{for(let o of a.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 i=r,c=0;for(;c<o.path.length;){let u=o.path[c];c===o.path.length-1?(i[u]=i[u]||{_errors:[]},i[u]._errors.push(n(o))):i[u]=i[u]||{_errors:[]},i=i[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,b.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 a=s.path[0];n[a]=n[a]||[],n[a].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};I.create=t=>new I(t)});var Gr,W,At=S(()=>{tt();Le();Gr=(t,e)=>{let n;switch(t.code){case d.invalid_type:t.received===p.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case d.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,b.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:n=`Unrecognized key(s) in object: ${b.joinValues(t.keys,", ")}`;break;case d.invalid_union:n="Invalid input";break;case d.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${b.joinValues(t.options)}`;break;case d.invalid_enum_value:n=`Invalid enum value. Expected ${b.joinValues(t.options)}, received '${t.received}'`;break;case d.invalid_arguments:n="Invalid function arguments";break;case d.invalid_return_type:n="Invalid function return type";break;case d.invalid_date:n="Invalid date";break;case d.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}"`:b.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case d.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 d.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 d.custom:n="Invalid input";break;case d.invalid_intersection_types:n="Intersection results could not be merged";break;case d.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case d.not_finite:n="Number must be finite";break;default:n=e.defaultError,b.assertNever(t)}return{message:n}},W=Gr});function Yr(t){dn=t}function xe(){return dn}var dn,nt=S(()=>{At();dn=W});function f(t,e){let n=xe(),r=Fe({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===W?void 0:W].filter(s=>!!s)});t.common.issues.push(r)}var Fe,Jr,$,h,ae,C,rt,st,Q,we,$t=S(()=>{nt();At();Fe=t=>{let{data:e,path:n,errorMaps:r,issueData:s}=t,a=[...n,...s.path||[]],o={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let i="",c=r.filter(u=>!!u).slice().reverse();for(let u of c)i=u(o,{data:e,defaultError:i}).message;return{...s,path:a,message:i}},Jr=[];$=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 h;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 a=await s.key,o=await s.value;r.push({key:a,value:o})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let s of n){let{key:a,value:o}=s;if(a.status==="aborted"||o.status==="aborted")return h;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[a.value]=o.value)}return{status:e.value,value:r}}},h=Object.freeze({status:"aborted"}),ae=t=>({status:"dirty",value:t}),C=t=>({status:"valid",value:t}),rt=t=>t.status==="aborted",st=t=>t.status==="dirty",Q=t=>t.status==="valid",we=t=>typeof Promise<"u"&&t instanceof Promise});var ln=S(()=>{});var m,fn=S(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(m||(m={}))});function _(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,i)=>{let{message:c}=t;return o.code==="invalid_enum_value"?{message:c??i.defaultError}:typeof i.data>"u"?{message:c??r??i.defaultError}:o.code!=="invalid_type"?{message:i.defaultError}:{message:c??n??i.defaultError}},description:s}}function gn(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 ps(t){return new RegExp(`^${gn(t)}$`)}function yn(t){let e=`${hn}T${gn(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 ms(t,e){return!!((e==="v4"||!e)&&os.test(t)||(e==="v6"||!e)&&cs.test(t))}function hs(t,e){if(!ns.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 gs(t,e){return!!((e==="v4"||!e)&&is.test(t)||(e==="v6"||!e)&&us.test(t))}function ys(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,a=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return a%o/10**s}function Se(t){if(t instanceof P){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=M.create(Se(r))}return new P({...t._def,shape:()=>e})}else return t instanceof J?new J({...t._def,type:Se(t.element)}):t instanceof M?M.create(Se(t.unwrap())):t instanceof B?B.create(Se(t.unwrap())):t instanceof U?U.create(t.items.map(e=>Se(e))):t}function Ct(t,e){let n=V(t),r=V(e);if(t===e)return{valid:!0,data:t};if(n===p.object&&r===p.object){let s=b.objectKeys(e),a=b.objectKeys(t).filter(i=>s.indexOf(i)!==-1),o={...t,...e};for(let i of a){let c=Ct(t[i],e[i]);if(!c.valid)return{valid:!1};o[i]=c.data}return{valid:!0,data:o}}else if(n===p.array&&r===p.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let a=0;a<t.length;a++){let o=t[a],i=e[a],c=Ct(o,i);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return n===p.date&&r===p.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function _n(t,e){return new ge({values:t,typeName:g.ZodEnum,..._(e)})}function mn(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function vn(t,e={},n){return t?ee.create().superRefine((r,s)=>{let a=t(r);if(a instanceof Promise)return a.then(o=>{if(!o){let i=mn(e,r),c=i.fatal??n??!0;s.addIssue({code:"custom",...i,fatal:c})}});if(!a){let o=mn(e,r),i=o.fatal??n??!0;s.addIssue({code:"custom",...o,fatal:i})}}):ee.create()}var j,pn,v,qr,Qr,Xr,es,ts,ns,rs,ss,as,Rt,os,is,cs,us,ds,ls,hn,fs,X,oe,ie,ce,ue,Te,de,le,ee,Y,F,Ee,J,P,fe,G,at,pe,U,ot,Ae,$e,it,me,he,ge,ye,te,z,M,B,_e,ve,Re,_s,Ve,Ue,be,vs,g,bs,bn,kn,ks,xs,xn,ws,Ss,Ts,Es,As,$s,Rs,Cs,Os,Ns,Ds,Is,Ps,Ms,js,zs,Zs,Ls,Fs,Vs,Us,Bs,Ks,Hs,Ws,Gs,Ys,Js,qs,Qs,Xs,ea,ta,na,wn=S(()=>{tt();nt();fn();$t();Le();j=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}},pn=(t,e)=>{if(Q(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 I(t.common.issues);return this._error=n,this._error}}};v=class{get description(){return this._def.description}_getType(e){return V(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:V(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new $,ctx:{common:e.parent.common,data:e.data,parsedType:V(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(we(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:V(e)},s=this._parseSync({data:e,path:r.path,parent:r});return pn(r,s)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return Q(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=>Q(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:V(e)},s=this._parse({data:e,path:r.path,parent:r}),a=await(we(s)?s:Promise.resolve(s));return pn(r,a)}refine(e,n){let r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,a)=>{let o=e(s),i=()=>a.addIssue({code:d.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(i(),!1)):o?!0:(i(),!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 z({schema:this,typeName:g.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 M.create(this,this._def)}nullable(){return B.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return J.create(this)}promise(){return te.create(this,this._def)}or(e){return fe.create([this,e],this._def)}and(e){return pe.create(this,e,this._def)}transform(e){return new z({..._(this._def),schema:this,typeName:g.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new _e({..._(this._def),innerType:this,defaultValue:n,typeName:g.ZodDefault})}brand(){return new Ve({typeName:g.ZodBranded,type:this,..._(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new ve({..._(this._def),innerType:this,catchValue:n,typeName:g.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Ue.create(this,e)}readonly(){return be.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},qr=/^c[^\s-]{8,}$/i,Qr=/^[0-9a-z]+$/,Xr=/^[0-9A-HJKMNP-TV-Z]{26}$/i,es=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,ts=/^[a-z0-9_-]{21}$/i,ns=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,rs=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ss=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,as="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",os=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,is=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,cs=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,us=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ds=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ls=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,hn="((\\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])))",fs=new RegExp(`^${hn}$`);X=class t extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==p.string){let a=this._getOrReturnCtx(e);return f(a,{code:d.invalid_type,expected:p.string,received:a.parsedType}),h}let r=new $,s;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){let o=e.data.length>a.value,i=e.data.length<a.value;(o||i)&&(s=this._getOrReturnCtx(e,s),o?f(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):i&&f(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")ss.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"email",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")Rt||(Rt=new RegExp(as,"u")),Rt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"emoji",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")es.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"uuid",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")ts.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"nanoid",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")qr.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")Qr.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid2",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")Xr.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ulid",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),f(s,{validation:"url",code:d.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"regex",code:d.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?yn(a).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?fs.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?ps(a).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?rs.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"duration",code:d.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?ms(e.data,a.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ip",code:d.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?hs(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"jwt",code:d.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?gs(e.data,a.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cidr",code:d.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?ds.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64",code:d.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?ls.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64url",code:d.invalid_string,message:a.message}),r.dirty()):b.assertNever(a);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:d.invalid_string,...m.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...m.errToObj(e)})}url(e){return this._addCheck({kind:"url",...m.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...m.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...m.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...m.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...m.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...m.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...m.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...m.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...m.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...m.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...m.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...m.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,...m.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,...m.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...m.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...m.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...m.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...m.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...m.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...m.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...m.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...m.errToObj(n)})}nonempty(e){return this.min(1,m.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}};X.create=t=>new X({checks:[],typeName:g.ZodString,coerce:t?.coerce??!1,..._(t)});oe=class t extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==p.number){let a=this._getOrReturnCtx(e);return f(a,{code:d.invalid_type,expected:p.number,received:a.parsedType}),h}let r,s=new $;for(let a of this._def.checks)a.kind==="int"?b.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:d.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:d.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:d.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?ys(e.data,a.value)!==0&&(r=this._getOrReturnCtx(e,r),f(r,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:d.not_finite,message:a.message}),s.dirty()):b.assertNever(a);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,m.toString(n))}gt(e,n){return this.setLimit("min",e,!1,m.toString(n))}lte(e,n){return this.setLimit("max",e,!0,m.toString(n))}lt(e,n){return this.setLimit("max",e,!1,m.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:m.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:m.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:m.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:m.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:m.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:m.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"&&b.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)}};oe.create=t=>new oe({checks:[],typeName:g.ZodNumber,coerce:t?.coerce||!1,..._(t)});ie=class t extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==p.bigint)return this._getInvalidInput(e);let r,s=new $;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:d.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),f(r,{code:d.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),f(r,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):b.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return f(n,{code:d.invalid_type,expected:p.bigint,received:n.parsedType}),h}gte(e,n){return this.setLimit("min",e,!0,m.toString(n))}gt(e,n){return this.setLimit("min",e,!1,m.toString(n))}lte(e,n){return this.setLimit("max",e,!0,m.toString(n))}lt(e,n){return this.setLimit("max",e,!1,m.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:m.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:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:m.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:m.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}};ie.create=t=>new ie({checks:[],typeName:g.ZodBigInt,coerce:t?.coerce??!1,..._(t)});ce=class extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==p.boolean){let r=this._getOrReturnCtx(e);return f(r,{code:d.invalid_type,expected:p.boolean,received:r.parsedType}),h}return C(e.data)}};ce.create=t=>new ce({typeName:g.ZodBoolean,coerce:t?.coerce||!1,..._(t)});ue=class t extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==p.date){let a=this._getOrReturnCtx(e);return f(a,{code:d.invalid_type,expected:p.date,received:a.parsedType}),h}if(Number.isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return f(a,{code:d.invalid_date}),h}let r=new $,s;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:d.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:d.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):b.assertNever(a);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:m.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:m.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}};ue.create=t=>new ue({checks:[],coerce:t?.coerce||!1,typeName:g.ZodDate,..._(t)});Te=class extends v{_parse(e){if(this._getType(e)!==p.symbol){let r=this._getOrReturnCtx(e);return f(r,{code:d.invalid_type,expected:p.symbol,received:r.parsedType}),h}return C(e.data)}};Te.create=t=>new Te({typeName:g.ZodSymbol,..._(t)});de=class extends v{_parse(e){if(this._getType(e)!==p.undefined){let r=this._getOrReturnCtx(e);return f(r,{code:d.invalid_type,expected:p.undefined,received:r.parsedType}),h}return C(e.data)}};de.create=t=>new de({typeName:g.ZodUndefined,..._(t)});le=class extends v{_parse(e){if(this._getType(e)!==p.null){let r=this._getOrReturnCtx(e);return f(r,{code:d.invalid_type,expected:p.null,received:r.parsedType}),h}return C(e.data)}};le.create=t=>new le({typeName:g.ZodNull,..._(t)});ee=class extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return C(e.data)}};ee.create=t=>new ee({typeName:g.ZodAny,..._(t)});Y=class extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return C(e.data)}};Y.create=t=>new Y({typeName:g.ZodUnknown,..._(t)});F=class extends v{_parse(e){let n=this._getOrReturnCtx(e);return f(n,{code:d.invalid_type,expected:p.never,received:n.parsedType}),h}};F.create=t=>new F({typeName:g.ZodNever,..._(t)});Ee=class extends v{_parse(e){if(this._getType(e)!==p.undefined){let r=this._getOrReturnCtx(e);return f(r,{code:d.invalid_type,expected:p.void,received:r.parsedType}),h}return C(e.data)}};Ee.create=t=>new Ee({typeName:g.ZodVoid,..._(t)});J=class t extends v{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==p.array)return f(n,{code:d.invalid_type,expected:p.array,received:n.parsedType}),h;if(s.exactLength!==null){let o=n.data.length>s.exactLength.value,i=n.data.length<s.exactLength.value;(o||i)&&(f(n,{code:o?d.too_big:d.too_small,minimum:i?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&&(f(n,{code:d.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&&(f(n,{code:d.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,i)=>s.type._parseAsync(new j(n,o,n.path,i)))).then(o=>$.mergeArray(r,o));let a=[...n.data].map((o,i)=>s.type._parseSync(new j(n,o,n.path,i)));return $.mergeArray(r,a)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:m.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:m.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:m.toString(n)}})}nonempty(e){return this.min(1,e)}};J.create=(t,e)=>new J({type:t,minLength:null,maxLength:null,exactLength:null,typeName:g.ZodArray,..._(e)});P=class t extends v{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=b.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==p.object){let u=this._getOrReturnCtx(e);return f(u,{code:d.invalid_type,expected:p.object,received:u.parsedType}),h}let{status:r,ctx:s}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),i=[];if(!(this._def.catchall instanceof F&&this._def.unknownKeys==="strip"))for(let u in s.data)o.includes(u)||i.push(u);let c=[];for(let u of o){let l=a[u],y=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new j(s,y,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof F){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of i)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")i.length>0&&(f(s,{code:d.unrecognized_keys,keys:i}),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 i){let y=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new j(s,y,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let y=await l.key,k=await l.value;u.push({key:y,value:k,alwaysSet:l.alwaysSet})}return u}).then(u=>$.mergeObjectSync(r,u)):$.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return m.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:m.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:g.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 b.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 b.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return Se(this)}partial(e){let n={};for(let r of b.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 b.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof M;)a=a._def.innerType;n[r]=a}return new t({...this._def,shape:()=>n})}keyof(){return _n(b.objectKeys(this.shape))}};P.create=(t,e)=>new P({shape:()=>t,unknownKeys:"strip",catchall:F.create(),typeName:g.ZodObject,..._(e)});P.strictCreate=(t,e)=>new P({shape:()=>t,unknownKeys:"strict",catchall:F.create(),typeName:g.ZodObject,..._(e)});P.lazycreate=(t,e)=>new P({shape:t,unknownKeys:"strip",catchall:F.create(),typeName:g.ZodObject,..._(e)});fe=class extends v{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function s(a){for(let i of a)if(i.result.status==="valid")return i.result;for(let i of a)if(i.result.status==="dirty")return n.common.issues.push(...i.ctx.common.issues),i.result;let o=a.map(i=>new I(i.ctx.common.issues));return f(n,{code:d.invalid_union,unionErrors:o}),h}if(n.common.async)return Promise.all(r.map(async a=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await a._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let a,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"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(a)return n.common.issues.push(...a.ctx.common.issues),a.result;let i=o.map(c=>new I(c));return f(n,{code:d.invalid_union,unionErrors:i}),h}}get options(){return this._def.options}};fe.create=(t,e)=>new fe({options:t,typeName:g.ZodUnion,..._(e)});G=t=>t instanceof me?G(t.schema):t instanceof z?G(t.innerType()):t instanceof he?[t.value]:t instanceof ge?t.options:t instanceof ye?b.objectValues(t.enum):t instanceof _e?G(t._def.innerType):t instanceof de?[void 0]:t instanceof le?[null]:t instanceof M?[void 0,...G(t.unwrap())]:t instanceof B?[null,...G(t.unwrap())]:t instanceof Ve||t instanceof be?G(t.unwrap()):t instanceof ve?G(t._def.innerType):[],at=class t extends v{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==p.object)return f(n,{code:d.invalid_type,expected:p.object,received:n.parsedType}),h;let r=this.discriminator,s=n.data[r],a=this.optionsMap.get(s);return a?n.common.async?a._parseAsync({data:n.data,path:n.path,parent:n}):a._parseSync({data:n.data,path:n.path,parent:n}):(f(n,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),h)}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 a of n){let o=G(a.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of o){if(s.has(i))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);s.set(i,a)}}return new t({typeName:g.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,..._(r)})}};pe=class extends v{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=(a,o)=>{if(rt(a)||rt(o))return h;let i=Ct(a.value,o.value);return i.valid?((st(a)||st(o))&&n.dirty(),{status:n.value,value:i.data}):(f(r,{code:d.invalid_intersection_types}),h)};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(([a,o])=>s(a,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}))}};pe.create=(t,e,n)=>new pe({left:t,right:e,typeName:g.ZodIntersection,..._(n)});U=class t extends v{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==p.array)return f(r,{code:d.invalid_type,expected:p.array,received:r.parsedType}),h;if(r.data.length<this._def.items.length)return f(r,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),h;!this._def.rest&&r.data.length>this._def.items.length&&(f(r,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let a=[...r.data].map((o,i)=>{let c=this._def.items[i]||this._def.rest;return c?c._parse(new j(r,o,r.path,i)):null}).filter(o=>!!o);return r.common.async?Promise.all(a).then(o=>$.mergeArray(n,o)):$.mergeArray(n,a)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};U.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new U({items:t,typeName:g.ZodTuple,rest:null,..._(e)})};ot=class t extends v{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!==p.object)return f(r,{code:d.invalid_type,expected:p.object,received:r.parsedType}),h;let s=[],a=this._def.keyType,o=this._def.valueType;for(let i in r.data)s.push({key:a._parse(new j(r,i,r.path,i)),value:o._parse(new j(r,r.data[i],r.path,i)),alwaysSet:i in r.data});return r.common.async?$.mergeObjectAsync(n,s):$.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof v?new t({keyType:e,valueType:n,typeName:g.ZodRecord,..._(r)}):new t({keyType:X.create(),valueType:e,typeName:g.ZodRecord,..._(n)})}},Ae=class extends v{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!==p.map)return f(r,{code:d.invalid_type,expected:p.map,received:r.parsedType}),h;let s=this._def.keyType,a=this._def.valueType,o=[...r.data.entries()].map(([i,c],u)=>({key:s._parse(new j(r,i,r.path,[u,"key"])),value:a._parse(new j(r,c,r.path,[u,"value"]))}));if(r.common.async){let i=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 h;(u.status==="dirty"||l.status==="dirty")&&n.dirty(),i.set(u.value,l.value)}return{status:n.value,value:i}})}else{let i=new Map;for(let c of o){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return h;(u.status==="dirty"||l.status==="dirty")&&n.dirty(),i.set(u.value,l.value)}return{status:n.value,value:i}}}};Ae.create=(t,e,n)=>new Ae({valueType:e,keyType:t,typeName:g.ZodMap,..._(n)});$e=class t extends v{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==p.set)return f(r,{code:d.invalid_type,expected:p.set,received:r.parsedType}),h;let s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(f(r,{code:d.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&&(f(r,{code:d.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());let a=this._def.valueType;function o(c){let u=new Set;for(let l of c){if(l.status==="aborted")return h;l.status==="dirty"&&n.dirty(),u.add(l.value)}return{status:n.value,value:u}}let i=[...r.data.values()].map((c,u)=>a._parse(new j(r,c,r.path,u)));return r.common.async?Promise.all(i).then(c=>o(c)):o(i)}min(e,n){return new t({...this._def,minSize:{value:e,message:m.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:m.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};$e.create=(t,e)=>new $e({valueType:t,minSize:null,maxSize:null,typeName:g.ZodSet,..._(e)});it=class t extends v{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==p.function)return f(n,{code:d.invalid_type,expected:p.function,received:n.parsedType}),h;function r(i,c){return Fe({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,xe(),W].filter(u=>!!u),issueData:{code:d.invalid_arguments,argumentsError:c}})}function s(i,c){return Fe({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,xe(),W].filter(u=>!!u),issueData:{code:d.invalid_return_type,returnTypeError:c}})}let a={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof te){let i=this;return C(async function(...c){let u=new I([]),l=await i._def.args.parseAsync(c,a).catch(T=>{throw u.addIssue(r(c,T)),u}),y=await Reflect.apply(o,this,l);return await i._def.returns._def.type.parseAsync(y,a).catch(T=>{throw u.addIssue(s(y,T)),u})})}else{let i=this;return C(function(...c){let u=i._def.args.safeParse(c,a);if(!u.success)throw new I([r(c,u.error)]);let l=Reflect.apply(o,this,u.data),y=i._def.returns.safeParse(l,a);if(!y.success)throw new I([s(l,y.error)]);return y.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:U.create(e).rest(Y.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||U.create([]).rest(Y.create()),returns:n||Y.create(),typeName:g.ZodFunction,..._(r)})}},me=class extends v{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})}};me.create=(t,e)=>new me({getter:t,typeName:g.ZodLazy,..._(e)});he=class extends v{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return f(n,{received:n.data,code:d.invalid_literal,expected:this._def.value}),h}return{status:"valid",value:e.data}}get value(){return this._def.value}};he.create=(t,e)=>new he({value:t,typeName:g.ZodLiteral,..._(e)});ge=class t extends v{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return f(n,{expected:b.joinValues(r),received:n.parsedType,code:d.invalid_type}),h}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 f(n,{received:n.data,code:d.invalid_enum_value,options:r}),h}return C(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})}};ge.create=_n;ye=class extends v{_parse(e){let n=b.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==p.string&&r.parsedType!==p.number){let s=b.objectValues(n);return f(r,{expected:b.joinValues(s),received:r.parsedType,code:d.invalid_type}),h}if(this._cache||(this._cache=new Set(b.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=b.objectValues(n);return f(r,{received:r.data,code:d.invalid_enum_value,options:s}),h}return C(e.data)}get enum(){return this._def.values}};ye.create=(t,e)=>new ye({values:t,typeName:g.ZodNativeEnum,..._(e)});te=class extends v{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==p.promise&&n.common.async===!1)return f(n,{code:d.invalid_type,expected:p.promise,received:n.parsedType}),h;let r=n.parsedType===p.promise?n.data:Promise.resolve(n.data);return C(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};te.create=(t,e)=>new te({type:t,typeName:g.ZodPromise,..._(e)});z=class extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===g.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:o=>{f(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){let o=s.transform(r.data,a);if(r.common.async)return Promise.resolve(o).then(async i=>{if(n.value==="aborted")return h;let c=await this._def.schema._parseAsync({data:i,path:r.path,parent:r});return c.status==="aborted"?h:c.status==="dirty"?ae(c.value):n.value==="dirty"?ae(c.value):c});{if(n.value==="aborted")return h;let i=this._def.schema._parseSync({data:o,path:r.path,parent:r});return i.status==="aborted"?h:i.status==="dirty"?ae(i.value):n.value==="dirty"?ae(i.value):i}}if(s.type==="refinement"){let o=i=>{let c=s.refinement(i,a);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 i};if(r.common.async===!1){let i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?h:(i.status==="dirty"&&n.dirty(),o(i.value),{status:n.value,value:i.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>i.status==="aborted"?h:(i.status==="dirty"&&n.dirty(),o(i.value).then(()=>({status:n.value,value:i.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(!Q(o))return h;let i=s.transform(o.value,a);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:i}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Q(o)?Promise.resolve(s.transform(o.value,a)).then(i=>({status:n.value,value:i})):h);b.assertNever(s)}};z.create=(t,e,n)=>new z({schema:t,typeName:g.ZodEffects,effect:e,..._(n)});z.createWithPreprocess=(t,e,n)=>new z({schema:e,effect:{type:"preprocess",transform:t},typeName:g.ZodEffects,..._(n)});M=class extends v{_parse(e){return this._getType(e)===p.undefined?C(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};M.create=(t,e)=>new M({innerType:t,typeName:g.ZodOptional,..._(e)});B=class extends v{_parse(e){return this._getType(e)===p.null?C(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};B.create=(t,e)=>new B({innerType:t,typeName:g.ZodNullable,..._(e)});_e=class extends v{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===p.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};_e.create=(t,e)=>new _e({innerType:t,typeName:g.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});ve=class extends v{_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 we(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new I(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new I(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};ve.create=(t,e)=>new ve({innerType:t,typeName:g.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});Re=class extends v{_parse(e){if(this._getType(e)!==p.nan){let r=this._getOrReturnCtx(e);return f(r,{code:d.invalid_type,expected:p.nan,received:r.parsedType}),h}return{status:"valid",value:e.data}}};Re.create=t=>new Re({typeName:g.ZodNaN,..._(t)});_s=Symbol("zod_brand"),Ve=class extends v{_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}},Ue=class t extends v{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?h:a.status==="dirty"?(n.dirty(),ae(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{let s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?h: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:g.ZodPipeline})}},be=class extends v{_parse(e){let n=this._def.innerType._parse(e),r=s=>(Q(s)&&(s.value=Object.freeze(s.value)),s);return we(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};be.create=(t,e)=>new be({innerType:t,typeName:g.ZodReadonly,..._(e)});vs={object:P.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"})(g||(g={}));bs=(t,e={message:`Input not instance of ${t.name}`})=>vn(n=>n instanceof t,e),bn=X.create,kn=oe.create,ks=Re.create,xs=ie.create,xn=ce.create,ws=ue.create,Ss=Te.create,Ts=de.create,Es=le.create,As=ee.create,$s=Y.create,Rs=F.create,Cs=Ee.create,Os=J.create,Ns=P.create,Ds=P.strictCreate,Is=fe.create,Ps=at.create,Ms=pe.create,js=U.create,zs=ot.create,Zs=Ae.create,Ls=$e.create,Fs=it.create,Vs=me.create,Us=he.create,Bs=ge.create,Ks=ye.create,Hs=te.create,Ws=z.create,Gs=M.create,Ys=B.create,Js=z.createWithPreprocess,qs=Ue.create,Qs=()=>bn().optional(),Xs=()=>kn().optional(),ea=()=>xn().optional(),ta={string:(t=>X.create({...t,coerce:!0})),number:(t=>oe.create({...t,coerce:!0})),boolean:(t=>ce.create({...t,coerce:!0})),bigint:(t=>ie.create({...t,coerce:!0})),date:(t=>ue.create({...t,coerce:!0}))},na=h});var Z={};ke(Z,{BRAND:()=>_s,DIRTY:()=>ae,EMPTY_PATH:()=>Jr,INVALID:()=>h,NEVER:()=>na,OK:()=>C,ParseStatus:()=>$,Schema:()=>v,ZodAny:()=>ee,ZodArray:()=>J,ZodBigInt:()=>ie,ZodBoolean:()=>ce,ZodBranded:()=>Ve,ZodCatch:()=>ve,ZodDate:()=>ue,ZodDefault:()=>_e,ZodDiscriminatedUnion:()=>at,ZodEffects:()=>z,ZodEnum:()=>ge,ZodError:()=>I,ZodFirstPartyTypeKind:()=>g,ZodFunction:()=>it,ZodIntersection:()=>pe,ZodIssueCode:()=>d,ZodLazy:()=>me,ZodLiteral:()=>he,ZodMap:()=>Ae,ZodNaN:()=>Re,ZodNativeEnum:()=>ye,ZodNever:()=>F,ZodNull:()=>le,ZodNullable:()=>B,ZodNumber:()=>oe,ZodObject:()=>P,ZodOptional:()=>M,ZodParsedType:()=>p,ZodPipeline:()=>Ue,ZodPromise:()=>te,ZodReadonly:()=>be,ZodRecord:()=>ot,ZodSchema:()=>v,ZodSet:()=>$e,ZodString:()=>X,ZodSymbol:()=>Te,ZodTransformer:()=>z,ZodTuple:()=>U,ZodType:()=>v,ZodUndefined:()=>de,ZodUnion:()=>fe,ZodUnknown:()=>Y,ZodVoid:()=>Ee,addIssueToContext:()=>f,any:()=>As,array:()=>Os,bigint:()=>xs,boolean:()=>xn,coerce:()=>ta,custom:()=>vn,date:()=>ws,datetimeRegex:()=>yn,defaultErrorMap:()=>W,discriminatedUnion:()=>Ps,effect:()=>Ws,enum:()=>Bs,function:()=>Fs,getErrorMap:()=>xe,getParsedType:()=>V,instanceof:()=>bs,intersection:()=>Ms,isAborted:()=>rt,isAsync:()=>we,isDirty:()=>st,isValid:()=>Q,late:()=>vs,lazy:()=>Vs,literal:()=>Us,makeIssue:()=>Fe,map:()=>Zs,nan:()=>ks,nativeEnum:()=>Ks,never:()=>Rs,null:()=>Es,nullable:()=>Ys,number:()=>kn,object:()=>Ns,objectUtil:()=>Et,oboolean:()=>ea,onumber:()=>Xs,optional:()=>Gs,ostring:()=>Qs,pipeline:()=>qs,preprocess:()=>Js,promise:()=>Hs,quotelessJson:()=>Wr,record:()=>zs,set:()=>Ls,setErrorMap:()=>Yr,strictObject:()=>Ds,string:()=>bn,symbol:()=>Ss,transformer:()=>Ws,tuple:()=>js,undefined:()=>Ts,union:()=>Is,unknown:()=>$s,util:()=>b,void:()=>Cs});var Ot=S(()=>{nt();$t();ln();Le();wn();tt()});var Sn=S(()=>{Ot();Ot()});var ra,sa,Ce,Tn=S(()=>{"use strict";Sn();ra=Z.enum(["normal","compact","minimal"]),sa=Z.enum(["off","light","balanced","max"]),Ce=Z.object({enabled:Z.boolean().default(!0),telemetryOptIn:Z.boolean().default(!0),outputVerbosity:ra.default("compact"),reducer:sa.default("off"),filters:Z.object({enableAll:Z.boolean().default(!0),disabled:Z.array(Z.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})})});var In={};ke(In,{clearSettingsCache:()=>da,loadSettingsCache:()=>Ne,saveSettingsCache:()=>Dn,updateSettingsCache:()=>ua});import{readFile as Rn,writeFile as Cn,mkdir as On,chmod as aa,rm as Be,rename as Nn,readdir as oa}from"node:fs/promises";import{randomUUID as ia}from"node:crypto";import{join as Oe}from"node:path";import{setTimeout as En}from"node:timers/promises";async function Ne(){let t=null;try{let e=JSON.parse(await Rn(Oe(w(),Nt),"utf8"));typeof e=="object"&&e!==null&&!Array.isArray(e)&&(t=e)}catch{}return t?Ce.parse({...An,...t}):An}async function Dn(t){await On(w(),{recursive:!0,mode:448});let e=Oe(w(),Nt),n=`${e}.tmp-${process.pid}-${process.hrtime.bigint()}`;await Cn(n,JSON.stringify(t,null,2),{mode:384});try{await aa(n,384),await Nn(n,e)}catch(r){try{await Be(n,{force:!0})}catch{}throw r}}async function $n(t){let e=[];for(let n of await oa(t)){let r=/^([1-9]\d*)-[0-9a-f-]{36}\.json$/.exec(n);if(!r)continue;let s=Oe(t,n);try{process.kill(Number(r[1]),0)}catch(a){let o=a.code;if(o==="ESRCH"){await Be(s,{force:!0});continue}if(o!=="EPERM")throw a}try{let a=JSON.parse(await Rn(s,"utf8"));if(!Number.isSafeInteger(a)||a<0)throw new Error("Invalid local settings lock");e.push({id:n,ticket:a})}catch(a){if(a.code!=="ENOENT")throw a}}return e}async function ua(t){let e=ca.parse(t),n=Oe(w(),"settings-cache-locks");await On(n,{recursive:!0,mode:448});let r=`${process.pid}-${ia()}.json`,s=Oe(n,r),a=`${s}.tmp`,o=performance.now()+3e3,i=async c=>{for(await Cn(a,String(c),{mode:384});;)try{await Nn(a,s);return}catch(u){let l=u.code;if(process.platform!=="win32"||l!=="EPERM"&&l!=="EBUSY"||performance.now()>=o)throw u;await En(10)}};try{await i(0);let c=Math.max(0,...(await $n(n)).map(u=>u.ticket))+1;if(!Number.isSafeInteger(c))throw new Error("Invalid local settings lock");for(await i(c);;){if(!(await $n(n)).some(l=>l.id!==r&&(l.ticket===0||l.ticket<c||l.ticket===c&&l.id<r))){let l=await Ne(),y=Ce.parse({...l,...e,filters:{...l.filters,...e.filters}});return await Dn(y),y}if(performance.now()>=o)throw new Error("Timed out waiting for local settings lock after 3 seconds; another process may still be updating settings");await En(10)}}finally{await Promise.all([Be(s,{force:!0}),Be(a,{force:!0})])}}async function da(){try{await Be(Oe(w(),Nt),{force:!0})}catch{}}var Nt,An,ca,ct=S(()=>{"use strict";Tn();L();Nt="settings-cache.json",An=Ce.parse({}),ca=Ce.partial().extend({filters:Ce.shape.filters.removeDefault().partial().optional()})});var Vn={};ke(Vn,{STATIC_COMMAND_NAMES:()=>ut,commandInstalled:()=>Fn,commandsInstallStatus:()=>ka,installCommand:()=>va,isFresh:()=>ga,pruneCommands:()=>ba,pruneSkills:()=>_a,readBundleRefresh:()=>wa,readSkill:()=>Sa,recordBundleRefresh:()=>xa,writeSkill:()=>ya});import{chmod as Dt,mkdir as dt,readFile as Ke,writeFile as lt,stat as It,readdir as la,rm as Mn}from"node:fs/promises";import{existsSync as fa}from"node:fs";import{dirname as pa}from"node:path";async function zn(){try{let t=JSON.parse(await Ke(Tt(),"utf8"));return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}catch{return[]}}async function Zn(t){try{await dt(w(),{recursive:!0,mode:448}),await lt(Tt(),JSON.stringify(t),{mode:384})}catch{}}function Ln(){let t=Number(process.env.TOKMIZER_MAX_BUNDLE_AGE_MS);return Number.isFinite(t)&&t>0?Math.min(t,Pn):Pn}async function ga(t){try{let e=await It(re(t)),n=Date.now()-e.mtimeMs;return n<ha&&n<=Ln()}catch{return!1}}async function ya(t,e){await dt(Xe(),{recursive:!0,mode:448}),await lt(re(t),e,{mode:384}),await Dt(re(t),384)}async function _a(t){let e=new Set(t),n;try{n=await la(Xe())}catch{return}for(let r of n){if(!r.endsWith(".md"))continue;let s=r.slice(0,-3);if(!e.has(s))try{await Mn(re(s))}catch{}}}async function va(t,e){if(!process.env.TOKMIZER_CLAUDE_COMMANDS_DIR&&!fa(pa(et())))return;await dt(et(),{recursive:!0});try{if(!(await Ke(se(t),"utf8")).includes(jn))return}catch{}await lt(se(t),e,{mode:384}),await Dt(se(t),384);let n=await zn();n.includes(t)||await Zn([...n,t])}async function ba(t){let e=new Set([...t,...ut]),n=await zn(),r=new Set([...n,...ma]);for(let s of r)if(!e.has(s))try{if(!(await Ke(se(s),"utf8")).includes(jn))continue;await Mn(se(s))}catch{}await Zn(n.filter(s=>e.has(s)))}async function ka(){let t=0;for(let e of ut)await Fn(e)&&t++;return{installed:t,total:ut.length}}async function Fn(t){try{return await It(se(t)),!0}catch{return!1}}async function xa(t){try{await dt(w(),{recursive:!0,mode:448}),await lt(Qe(),JSON.stringify({at:Date.now(),error:t}),{mode:384}),await Dt(Qe(),384)}catch{}}async function wa(){try{return JSON.parse(await Ke(Qe(),"utf8"))}catch{return null}}async function Sa(t){try{let e=await It(re(t));return Date.now()-e.mtimeMs>Ln()?null:await Ke(re(t),"utf8")}catch{return null}}var jn,ut,ma,ha,Pn,Un=S(()=>{"use strict";L();jn="managed-by: tokmizer",ut=["tkr","tkr-gain","tkr-status","tkr-link","tkr-unlink","tkr-compression","tkr-telemetry","tkr-update","tkr-yolo"],ma=["power","tkr-reducer"];ha=3600*1e3,Pn=10080*60*1e3});import{join as Ta}from"node:path";import{mkdir as jc,readFile as Ea,writeFile as zc,unlink as Zc,rename as Lc}from"node:fs/promises";function $a(){try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t&&t.length>0?t:"Etc/UTC"}catch{return"Etc/UTC"}}function Ra(t){return t?.dir??w()}async function ft(t){let e=Ra(t);try{let n=await Ea(Ta(e,Aa),"utf8"),r=JSON.parse(n),s=r.timeZone;return{...r,lastSettingsRevision:r.lastSettingsRevision??0,get timeZone(){return s??=$a()},bonusActive:r.bonusActive??!1,...r.bonusResetAt!==void 0?{bonusResetAt:r.bonusResetAt}:{}}}catch{return null}}var Aa,Pt=S(()=>{"use strict";L();Aa="state.json"});var Bn={};ke(Bn,{reducerStillEntitled:()=>Ca});async function Ca(){return await ft()!==null}var Kn=S(()=>{"use strict";Pt()});function Mt(t){let e=t;for(let[n,r]of Oa)e=e.replace(n,r);return e}var Oa,K,Bc,Hn=S(()=>{"use strict";Oa=[[/(\baws_(?:secret_access_key|session_token|access_key_id)\s+)\S+/gi,"$1[REDACTED]"],[/(\bsshpass\b[^;&|\n]{0,200}?\s-p\s*)\S+/g,"$1[REDACTED]"],[/(\bredis-cli\b[^;&|\n]{0,200}?\s(?:-a|--pass)\s+)\S+/g,"$1[REDACTED]"],[/(\bopenssl\b[^;&|\n]{0,200}?\s-k\s+)\S+/g,"$1[REDACTED]"],[/(\s-pass(?:in|out)?\s+(?:pass|env|file):)\S+/g,"$1[REDACTED]"],[/(https?:\/\/hooks\.slack\.com\/(?:services|workflows|triggers)\/)\S+/gi,"$1[REDACTED]"],[/(authorization\s*:\s*)([A-Za-z][A-Za-z0-9._-]*)\s+[^\s'"]+/gi,"$1$2 [REDACTED]"],[/(authorization\s*:\s*)[A-Za-z0-9._\-+/=]{8,}/gi,"$1[REDACTED]"],[/(bearer\s+)[A-Za-z0-9._\-+/=]{8,}/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-b|--cookie)[=\s]+['"]?)[^\s'";=]+=[^\s'";]+(?:\s*;\s*[^\s'";=]+=[^\s'";]+)*/gi,"$1[REDACTED]"],[/((?:^|[\s'"])(?:Set-)?Cookie\s*:\s*)[^\s'";=]+=[^\s'";]+(?:\s*;\s*[^\s'";=]+=[^\s'";]+)*/gi,"$1[REDACTED]"],[/(--?(?:password|passwd|passphrase|apipass|pass|pwd|token|api[-_]?key|secret|bearer|cookie|jwt)(?:-[a-z0-9]+)*[=\s]+)\S+/gi,"$1[REDACTED]"],[/((?:^|\s)-b[=\s]?['"]?)[^\s'"=]+=[^\s'"]+/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?[^\s:/'"]*:)(\/[^/\s'"][^\s'"]*|[^\s/'"0-9][^\s'"]*|[0-9][^\s'"]*[^\s'"0-9][^\s'"]*)/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?[^\s:/'"]*[^\s:/'"0-9][^\s:/'"]*:)(?:\/[^/\s'"]|[^\s/'"])[^\s'"]*/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?:)(?:\/[^/\s'"]|[^\s/'"])[^\s'"]*/gi,"$1[REDACTED]"],[/((?:[A-Za-z0-9]+-){0,8}(?:X-Api-Key|Private-Token|[A-Za-z0-9]+-(?:Token|Key|Auth|Secret))\s*:\s*)[^\s'"]+/gi,"$1[REDACTED]"],[/((?:^|[\s'"])(?:Set-)?Cookie\s*:\s*)[^\s'"]+/gi,"$1[REDACTED]"],[/(-i\s+)(\/[^\s]+|~\/[^\s]+|[A-Z]:\\[^\s]+)/g,"$1[REDACTED]"],[/([a-zA-Z][a-zA-Z0-9+.-]{0,31}:\/\/[^:/\s@]*:)[^\s@]+(@[^@/\s]+)/g,"$1[REDACTED]$2"],[/(AWS_(?:ACCESS_KEY_ID|SECRET_ACCESS_KEY|SESSION_TOKEN)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(GOOGLE_APPLICATION_CREDENTIALS\s*=\s*)\S+/g,"$1[REDACTED]"],[/(AZURE_(?:CLIENT_SECRET|TENANT_ID|CLIENT_ID)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-(?:proj-)?[A-Za-z0-9_-]{20,})/g,"sk-[REDACTED]"],[/\b(OPENAI_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(ANTHROPIC_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-ant-[A-Za-z0-9_-]{20,})/g,"sk-ant-[REDACTED]"],[/\b(GH(?:_|ITHUB_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(GITLAB_TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(SLACK_(?:BOT_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/(xox[bpsoa]-[A-Za-z0-9-]{10,})/g,"xox[REDACTED]"],[/(xapp-[A-Za-z0-9-]{10,})/g,"[REDACTED]"],[/(sk_(?:test|live)_[A-Za-z0-9]{16,})/g,"sk_[REDACTED]"],[/(gh[a-z])_[A-Za-z0-9]{20,}/g,"$1_[REDACTED]"],[/(github_pat)_[A-Za-z0-9_]{20,}/g,"$1_[REDACTED]"],[/(gl(?:pat|rt|soat|imt|dt|ft|agent|oas|cbt|ptt))-[A-Za-z0-9_-]{16,}/g,"$1-[REDACTED]"],[/(npm_[A-Za-z0-9_-]{20,})/g,"npm_[REDACTED]"],[/(?:AKIA|ASIA|AGPA|AIDA|AROA|ANPA)[0-9A-Z]{16,}/g,"[REDACTED_AWS_KEY]"],[/AIza[A-Za-z0-9_-]{35}/g,"[REDACTED_GOOGLE_KEY]"],[/hv[sb]\.[A-Za-z0-9_-]{20,}/g,"[REDACTED_VAULT_TOKEN]"],[/dop_v1_[A-Za-z0-9]{40,}/g,"[REDACTED]"],[/dckr_pat_[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/pypi-[A-Za-z0-9_-]{16,}/g,"[REDACTED]"],[/rk_(?:live|test)_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/whsec_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/SG\.[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/(eyJ[A-Za-z0-9_-]{6,}(?:\.[A-Za-z0-9_-]{4,}){1,2})/g,"[REDACTED_JWT]"],[/-----BEGIN [A-Z ]*PRIVATE KEY-----(?:[\s\S]*?-----END[^\n]*-----|\r?\n[A-Za-z0-9+/=][A-Za-z0-9+/=\r\n]*)?/g,"[REDACTED_PEM]"],[/\b((?:--?)?[A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|AUTH|_PWD)[A-Za-z0-9_]*['"]?\s*=\s*)(?:"[^"]*"|'[^']*'|[^"'\s]\S*)/gi,"$1[REDACTED]"],[/\b([A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|_PWD)[A-Za-z0-9_]*['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/((?:^|[\s'"{,])['"]?(?:[A-Za-z0-9_]+_)?auth['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/(\bpwd\s*[=:]\s*)(?:"[^"]*"|'[^']*'|[^/~\s][^\s;'"]*)/gi,"$1[REDACTED]"],[/([=:]\s*["']?)[A-Za-z0-9_\-+/=]{40,}/g,"$1[REDACTED]"]];K="[tkr: secret masked]",Bc=[[/(-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----)(?:\r?\n(?:[A-Za-z0-9+/=]{16,}|[A-Za-z-]+: [^\r\n]*|\r?(?=\n)))*(?:(?:\r?\n[A-Za-z0-9+/=]{1,15})?\r?\n-----END [A-Z0-9 ]*PRIVATE KEY-----)?/g,`$1${K}`],[/(?<![A-Za-z0-9_])(gh[pousr])_[A-Za-z0-9]{36,255}(?![A-Za-z0-9])/g,`$1_${K}`],[/(?<![A-Za-z0-9_])github_pat_[A-Za-z0-9_]{22,255}/g,`github_pat_${K}`],[/(?<![A-Za-z0-9_])npm_[A-Za-z0-9]{36}(?![A-Za-z0-9])/g,`npm_${K}`],[/(?<![A-Z0-9])(AKIA|ASIA)[A-Z0-9]{16}(?![A-Z0-9])/g,`$1${K}`],[/(?<![A-Za-z0-9])(xox[abpors]-)[A-Za-z0-9-]{10,}/g,`$1${K}`],[/(?<![A-Za-z0-9])((?:sk|rk)_live_)[A-Za-z0-9]{16,}/g,`$1${K}`],[/(?<![A-Za-z0-9_-])(sk-(?:ant-|proj-))[A-Za-z0-9_-]{20,}/g,`$1${K}`],[/(authorization["']?\s*[:=]\s*["']?bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi,`$1${K}`],[/(?<![A-Za-z0-9+.-])([a-zA-Z][a-zA-Z0-9+.-]{0,31}:\/\/[^\s:/@]*:)[^\s@/]+(@[^\s@/]+)/g,`$1${K}$2`]]});function Wn(){let t=process.env.TOKMIZER_BASE_URL;if(t===De||t===`${De}/`||!t)return De;try{let e=new URL(t);return e.protocol==="http:"&&Na.has(e.hostname)&&!e.username&&!e.password?t:De}catch{return De}}var De,Na,Gn=S(()=>{"use strict";De="https://tokmizer.com",Na=new Set(["127.0.0.1","localhost"])});import Ie from"node:os";import{createHash as Da,createHmac as Yn,randomUUID as Ia}from"node:crypto";import{readFile as Jn,writeFile as qn,mkdir as Pa}from"node:fs/promises";async function Ma(){try{let n=(await Jn(Ze(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(n))return n}catch{}await Pa(w(),{recursive:!0,mode:448});let t=Ia();try{return await qn(Ze(),t,{mode:384,flag:"wx"}),t}catch{try{let e=(await Jn(Ze(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(e))return e}catch{}return await qn(Ze(),t,{mode:384}),t}}function jt(t){return Da("sha256").update(t).digest("hex")}function ja(){let t=Ie.networkInterfaces();for(let e of Object.keys(t))for(let n of t[e]??[])if(!n.internal&&n.mac&&n.mac!=="00:00:00:00:00:00")return n.mac;return"no-mac"}async function Qn(){let t=await Ma(),e=Ie.hostname(),n=Ie.platform(),r=Ie.release(),s=Ie.cpus(),a=s[0]?.model??"unknown",o=s.length,i=ja(),c=Ie.userInfo().username,u=[e,n,r,a,String(o),jt(i),jt(c),t].join("|");return{fingerprint:jt(u),installId:t,hostname:e,os:n,osVersion:r,cpuModel:a,cpuCores:o,macHash:Yn("sha256",t).update(i).digest("hex"),usernameHash:Yn("sha256",t).update(c).digest("hex")}}var Xn=S(()=>{"use strict";L()});import{createRequire as za}from"node:module";function La(){let t="1.0.2";if(t)return t;for(let e of["../package.json","../../package.json"])try{let n=Za(e).version;if(typeof n=="string"&&n)return n}catch{}return"0.0.0"}var Za,zt,Zt=S(()=>{"use strict";Za=za(import.meta.url);zt=La()});var er=S(()=>{"use strict"});import{existsSync as Fa,mkdirSync as nu,rmSync as ru,writeFileSync as su}from"node:fs";import{join as Va}from"node:path";function Ka(){return Va(w(),"network-off")}function Ha(){let t=process.env.TOKMIZER_NETWORK;return t!==void 0&&Ua.has(t.trim().toLowerCase())}function He(){return Ha()?!1:!Fa(Ka())}function tr(){if(!He())throw new Lt}var Ua,Ba,iu,Lt,pt=S(()=>{"use strict";L();Ua=new Set(["0","off","false","no"]),Ba="Network is off for Tokmizer. Turn it back on with: tkr network on",iu=["Tokmizer contacts tokmizer.com to keep its rules up to date and to improve the product. No account or email is needed.","It sends a random install ID, your computer name, OS and CPU model, a hash of your network card address and of your user name, and the plugin version. Command contents and output are never sent.","Usage stats (command names, token counts and install health counts) are sent only while they are on. Check with: tkr telemetry status.","Turn all network access off: tkr network off. Usage stats only: tkr telemetry off."].join(`
4
4
  `),Lt=class extends Error{constructor(){super(Ba),this.name="NetworkDisabledError"}}});import{createHmac as Wa,createPublicKey as lu,verify as fu}from"node:crypto";function Ya(t,e,n,r,s){return Wa("sha256",s).update(`${t}
5
5
  ${e}
6
6
  ${r}
@@ -2,5 +2,5 @@ import { createRequire as __tkrCreateRequire } from "node:module"; const require
2
2
  var st=Object.defineProperty;var nt=(r,e)=>{for(var t in e)st(r,t,{get:e[t],enumerable:!0})};function Ce(r=3e3){return new Promise(e=>{let t=[],s=process.stdin,n=!1,a=()=>{n||(n=!0,clearTimeout(o),s.off("data",i),s.pause(),s.unref?.(),e(Buffer.concat(t).toString("utf8")))},i=u=>{t.push(Buffer.isBuffer(u)?u:Buffer.from(u))},o=setTimeout(a,r);s.on("data",i).once("end",a).once("error",a),s.resume()})}import{realpathSync as Re}from"node:fs";import{fileURLToPath as at,pathToFileURL as it}from"node:url";var Oe=null;function De(r,e,t){if(t!==void 0&&Oe===t)return!0;if(Oe!==null||!r)return!1;if(e===it(r).href)return!0;try{return Re(r)===Re(at(e))}catch{return!1}}import{appendFileSync as ms,mkdirSync as gs,readFileSync as ut,writeFileSync as ys,renameSync as _s,statSync as dt,readdirSync as lt,rmSync as ft,chmodSync as vs}from"node:fs";import{join as Ee}from"node:path";import ot from"node:os";import{join as ct}from"node:path";function w(){return process.env.TOKMIZER_HOME||ct(ot.homedir(),".tokmizer")}var D="[tkr: secret masked]",ds=[[/(-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----)(?:\r?\n(?:[A-Za-z0-9+/=]{16,}|[A-Za-z-]+: [^\r\n]*|\r?(?=\n)))*(?:(?:\r?\n[A-Za-z0-9+/=]{1,15})?\r?\n-----END [A-Z0-9 ]*PRIVATE KEY-----)?/g,`$1${D}`],[/(?<![A-Za-z0-9_])(gh[pousr])_[A-Za-z0-9]{36,255}(?![A-Za-z0-9])/g,`$1_${D}`],[/(?<![A-Za-z0-9_])github_pat_[A-Za-z0-9_]{22,255}/g,`github_pat_${D}`],[/(?<![A-Za-z0-9_])npm_[A-Za-z0-9]{36}(?![A-Za-z0-9])/g,`npm_${D}`],[/(?<![A-Z0-9])(AKIA|ASIA)[A-Z0-9]{16}(?![A-Z0-9])/g,`$1${D}`],[/(?<![A-Za-z0-9])(xox[abpors]-)[A-Za-z0-9-]{10,}/g,`$1${D}`],[/(?<![A-Za-z0-9])((?:sk|rk)_live_)[A-Za-z0-9]{16,}/g,`$1${D}`],[/(?<![A-Za-z0-9_-])(sk-(?:ant-|proj-))[A-Za-z0-9_-]{20,}/g,`$1${D}`],[/(authorization["']?\s*[:=]\s*["']?bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi,`$1${D}`],[/(?<![A-Za-z0-9+.-])([a-zA-Z][a-zA-Z0-9+.-]{0,31}:\/\/[^\s:/@]*:)[^\s@/]+(@[^\s@/]+)/g,`$1${D}$2`]];var Es=96*1024;var pt=168*3600*1e3;function Ne(){return Ee(w(),"sessions")}function ht(r){let e=r.replace(/[^A-Za-z0-9._-]/g,"-").replace(/\.\./g,"-").slice(0,80)||"default";return Ee(Ne(),`${e}.jsonl`)}function Ie(r){try{let e=ut(ht(r),"utf8"),t=[];for(let s of e.split(`
3
3
  `))if(s.trim())try{let n=JSON.parse(s);typeof n.tool=="string"&&typeof n.target=="string"&&t.push(n)}catch{}return t}catch{return[]}}function $e(){try{let r=Ne(),e=Date.now();for(let t of lt(r)){let s=Ee(r,t);try{e-dt(s).mtimeMs>pt&&ft(s,{force:!0})}catch{}}}catch{}}function Ze(r){if(r.length===0)return"";let e=new Map,t=[],s=[];for(let u of r)u.tool==="Read"?e.set(u.target,(e.get(u.target)??0)+1):u.tool==="Grep"||u.tool==="Glob"?t.includes(u.target)||t.push(u.target):u.tool==="Bash"&&s.push({target:u.target,fail:u.fail===1});let n=["Tokmizer session recap (this session before context trimming):"],a=[...e.entries()].slice(-12);if(a.length>0){n.push("Files read:");for(let[u,l]of a)n.push(l>1?` ${u} \xD7${l}`:` ${u}`)}t.length>0&&n.push(`Searches: ${t.slice(-5).join(", ")}`);let i=new Set,o=[];for(let u=s.length-1;u>=0&&o.length<8;u--){let l=s[u];i.has(l.target)||(i.add(l.target),o.unshift(l))}if(o.length>0){n.push("Recent commands:");for(let u of o)n.push(u.fail?` ${u.target} \u2717 failed`:` ${u.target}`)}return n.push("Originals of trimmed outputs stay recoverable: tkr restore <hash>."),n.slice(0,30).join(`
4
4
  `)}import{appendFileSync as Ss,chmodSync as Cs,mkdirSync as Rs,readFileSync as Os,rmSync as mt,statSync as Ds}from"node:fs";import{join as gt}from"node:path";var Zs=256*1024;function yt(r){let e=r.replace(/[^A-Za-z0-9._-]/g,"-").replace(/\.\./g,"-").slice(0,80)||"default";return gt(w(),"sessions",`${e}.seen`)}function je(r){try{mt(yt(r),{force:!0})}catch{}}import{existsSync as Qe,mkdirSync as Vr,writeFileSync as Fr}from"node:fs";import{join as Kr}from"node:path";import{readFile as Or,writeFile as pn,mkdir as hn,chmod as mn,rm as gn,rename as yn,readdir as _n}from"node:fs/promises";import{join as Dr}from"node:path";var R={};nt(R,{BRAND:()=>Kt,DIRTY:()=>K,EMPTY_PATH:()=>kt,INVALID:()=>h,NEVER:()=>Sr,OK:()=>k,ParseStatus:()=>x,Schema:()=>y,ZodAny:()=>V,ZodArray:()=>P,ZodBigInt:()=>B,ZodBoolean:()=>H,ZodBranded:()=>he,ZodCatch:()=>se,ZodDate:()=>W,ZodDefault:()=>re,ZodDiscriminatedUnion:()=>ve,ZodEffects:()=>C,ZodEnum:()=>ee,ZodError:()=>b,ZodFirstPartyTypeKind:()=>m,ZodFunction:()=>ke,ZodIntersection:()=>G,ZodIssueCode:()=>c,ZodLazy:()=>X,ZodLiteral:()=>Q,ZodMap:()=>de,ZodNaN:()=>fe,ZodNativeEnum:()=>te,ZodNever:()=>O,ZodNull:()=>q,ZodNullable:()=>$,ZodNumber:()=>U,ZodObject:()=>E,ZodOptional:()=>A,ZodParsedType:()=>f,ZodPipeline:()=>me,ZodPromise:()=>F,ZodReadonly:()=>ne,ZodRecord:()=>xe,ZodSchema:()=>y,ZodSet:()=>le,ZodString:()=>L,ZodSymbol:()=>ce,ZodTransformer:()=>C,ZodTuple:()=>I,ZodType:()=>y,ZodUndefined:()=>Y,ZodUnion:()=>J,ZodUnknown:()=>z,ZodVoid:()=>ue,addIssueToContext:()=>d,any:()=>Xt,array:()=>rr,bigint:()=>Wt,boolean:()=>We,coerce:()=>Ar,custom:()=>Ue,date:()=>Yt,datetimeRegex:()=>Fe,defaultErrorMap:()=>Z,discriminatedUnion:()=>ir,effect:()=>_r,enum:()=>mr,function:()=>fr,getErrorMap:()=>ae,getParsedType:()=>N,instanceof:()=>Bt,intersection:()=>or,isAborted:()=>ye,isAsync:()=>ie,isDirty:()=>_e,isValid:()=>M,late:()=>Ut,lazy:()=>pr,literal:()=>hr,makeIssue:()=>pe,map:()=>dr,nan:()=>Ht,nativeEnum:()=>gr,never:()=>er,null:()=>Gt,nullable:()=>xr,number:()=>He,object:()=>sr,objectUtil:()=>we,oboolean:()=>Tr,onumber:()=>wr,optional:()=>vr,ostring:()=>Er,pipeline:()=>br,preprocess:()=>kr,promise:()=>yr,quotelessJson:()=>_t,record:()=>ur,set:()=>lr,setErrorMap:()=>xt,strictObject:()=>nr,string:()=>Be,symbol:()=>qt,transformer:()=>_r,tuple:()=>cr,undefined:()=>Jt,union:()=>ar,unknown:()=>Qt,util:()=>_,void:()=>tr});var _;(function(r){r.assertEqual=n=>{};function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{let a={};for(let i of n)a[i]=i;return a},r.getValidEnumValues=n=>{let a=r.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(let o of a)i[o]=n[o];return r.objectValues(i)},r.objectValues=n=>r.objectKeys(n).map(function(a){return n[a]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let a=[];for(let i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},r.find=(n,a)=>{for(let i of n)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=s,r.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(_||(_={}));var we;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(we||(we={}));var f=_.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),N=r=>{switch(typeof r){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(r)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(r)?f.array:r===null?f.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?f.promise:typeof Map<"u"&&r instanceof Map?f.map:typeof Set<"u"&&r instanceof Set?f.set:typeof Date<"u"&&r instanceof Date?f.date:f.object;default:return f.unknown}};var c=_.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"]),_t=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),b=class r extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(a){return a.message},s={_errors:[]},n=a=>{for(let i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else{let o=s,u=0;for(;u<i.path.length;){let l=i.path[u];u===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],u++}}};return n(this),s}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,_.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},s=[];for(let n of this.issues)if(n.path.length>0){let a=n.path[0];t[a]=t[a]||[],t[a].push(e(n))}else s.push(e(n));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}};b.create=r=>new b(r);var vt=(r,e)=>{let t;switch(r.code){case c.invalid_type:r.received===f.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case c.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,_.jsonStringifyReplacer)}`;break;case c.unrecognized_keys:t=`Unrecognized key(s) in object: ${_.joinValues(r.keys,", ")}`;break;case c.invalid_union:t="Invalid input";break;case c.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${_.joinValues(r.options)}`;break;case c.invalid_enum_value:t=`Invalid enum value. Expected ${_.joinValues(r.options)}, received '${r.received}'`;break;case c.invalid_arguments:t="Invalid function arguments";break;case c.invalid_return_type:t="Invalid function return type";break;case c.invalid_date:t="Invalid date";break;case c.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:_.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case c.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case c.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case c.custom:t="Invalid input";break;case c.invalid_intersection_types:t="Intersection results could not be merged";break;case c.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case c.not_finite:t="Number must be finite";break;default:t=e.defaultError,_.assertNever(r)}return{message:t}},Z=vt;var ze=Z;function xt(r){ze=r}function ae(){return ze}var pe=r=>{let{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],i={...n,path:a};if(n.message!==void 0)return{...n,path:a,message:n.message};let o="",u=s.filter(l=>!!l).slice().reverse();for(let l of u)o=l(i,{data:e,defaultError:o}).message;return{...n,path:a,message:o}},kt=[];function d(r,e){let t=ae(),s=pe({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===Z?void 0:Z].filter(n=>!!n)});r.common.issues.push(s)}var x=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let s=[];for(let n of t){if(n.status==="aborted")return h;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){let s=[];for(let n of t){let a=await n.key,i=await n.value;s.push({key:a,value:i})}return r.mergeObjectSync(e,s)}static mergeObjectSync(e,t){let s={};for(let n of t){let{key:a,value:i}=n;if(a.status==="aborted"||i.status==="aborted")return h;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}},h=Object.freeze({status:"aborted"}),K=r=>({status:"dirty",value:r}),k=r=>({status:"valid",value:r}),ye=r=>r.status==="aborted",_e=r=>r.status==="dirty",M=r=>r.status==="valid",ie=r=>typeof Promise<"u"&&r instanceof Promise;var p;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(p||(p={}));var S=class{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}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}},Pe=(r,e)=>{if(M(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new b(r.common.issues);return this._error=t,this._error}}};function g(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(i,o)=>{let{message:u}=r;return i.code==="invalid_enum_value"?{message:u??o.defaultError}:typeof o.data>"u"?{message:u??s??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:u??t??o.defaultError}},description:n}}var y=class{get description(){return this._def.description}_getType(e){return N(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:N(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new x,ctx:{common:e.parent.common,data:e.data,parsedType:N(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(ie(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){let s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:N(e)},n=this._parseSync({data:e,path:s.path,parent:s});return Pe(s,n)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:N(e)};if(!this["~standard"].async)try{let s=this._parseSync({data:e,path:[],parent:t});return M(s)?{value:s.value}:{issues:t.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(s=>M(s)?{value:s.value}:{issues:t.common.issues})}async parseAsync(e,t){let s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){let s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:N(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(ie(n)?n:Promise.resolve(n));return Pe(s,a)}refine(e,t){let s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{let i=e(n),o=()=>a.addIssue({code:c.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new C({schema:this,typeName:m.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:t=>this["~validate"](t)}}optional(){return A.create(this,this._def)}nullable(){return $.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return P.create(this)}promise(){return F.create(this,this._def)}or(e){return J.create([this,e],this._def)}and(e){return G.create(this,e,this._def)}transform(e){return new C({...g(this._def),schema:this,typeName:m.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new re({...g(this._def),innerType:this,defaultValue:t,typeName:m.ZodDefault})}brand(){return new he({typeName:m.ZodBranded,type:this,...g(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new se({...g(this._def),innerType:this,catchValue:t,typeName:m.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return me.create(this,e)}readonly(){return ne.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},bt=/^c[^\s-]{8,}$/i,Et=/^[0-9a-z]+$/,wt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Tt=/^[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,At=/^[a-z0-9_-]{21}$/i,St=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ct=/^[-+]?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)?)??$/,Rt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ot="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Te,Dt=/^(?:(?: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])$/,Nt=/^(?:(?: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])$/,It=/^(([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]))$/,$t=/^(([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])$/,Zt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,jt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Le="((\\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])))",zt=new RegExp(`^${Le}$`);function Ve(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);let t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function Pt(r){return new RegExp(`^${Ve(r)}$`)}function Fe(r){let e=`${Le}T${Ve(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Mt(r,e){return!!((e==="v4"||!e)&&Dt.test(r)||(e==="v6"||!e)&&It.test(r))}function Lt(r,e){if(!St.test(r))return!1;try{let[t]=r.split(".");if(!t)return!1;let s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),n=JSON.parse(atob(s));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function Vt(r,e){return!!((e==="v4"||!e)&&Nt.test(r)||(e==="v6"||!e)&&$t.test(r))}var L=class r extends y{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){let a=this._getOrReturnCtx(e);return d(a,{code:c.invalid_type,expected:f.string,received:a.parsedType}),h}let s=new x,n;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),d(n,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="max")e.data.length>a.value&&(n=this._getOrReturnCtx(e,n),d(n,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="length"){let i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(n=this._getOrReturnCtx(e,n),i?d(n,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&d(n,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")Rt.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"email",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")Te||(Te=new RegExp(Ot,"u")),Te.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"emoji",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")Tt.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"uuid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")At.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"nanoid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")bt.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"cuid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")Et.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"cuid2",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")wt.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"ulid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),d(n,{validation:"url",code:c.invalid_string,message:a.message}),s.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"regex",code:c.invalid_string,message:a.message}),s.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(e,n),d(n,{code:c.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),s.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(n=this._getOrReturnCtx(e,n),d(n,{code:c.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),d(n,{code:c.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?Fe(a).test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:c.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?zt.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:c.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?Pt(a).test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:c.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?Ct.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"duration",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?Mt(e.data,a.version)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"ip",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="jwt"?Lt(e.data,a.alg)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"jwt",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="cidr"?Vt(e.data,a.version)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"cidr",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?Zt.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"base64",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="base64url"?jt.test(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{validation:"base64url",code:c.invalid_string,message:a.message}),s.dirty()):_.assertNever(a);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:c.invalid_string,...p.errToObj(s)})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...p.errToObj(e)})}url(e){return this._addCheck({kind:"url",...p.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...p.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...p.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...p.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...p.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...p.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...p.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...p.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...p.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...p.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...p.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...p.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,...p.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,...p.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...p.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...p.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...p.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...p.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...p.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...p.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...p.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...p.errToObj(t)})}nonempty(e){return this.min(1,p.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...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 t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};L.create=r=>new L({checks:[],typeName:m.ZodString,coerce:r?.coerce??!1,...g(r)});function Ft(r,e){let t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=Number.parseInt(r.toFixed(n).replace(".","")),i=Number.parseInt(e.toFixed(n).replace(".",""));return a%i/10**n}var U=class r extends y{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)!==f.number){let a=this._getOrReturnCtx(e);return d(a,{code:c.invalid_type,expected:f.number,received:a.parsedType}),h}let s,n=new x;for(let a of this._def.checks)a.kind==="int"?_.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:c.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),d(s,{code:c.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),d(s,{code:c.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?Ft(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),d(s,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:c.not_finite,message:a.message}),n.dirty()):_.assertNever(a);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,s,n){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:p.toString(n)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:p.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:p.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:p.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:p.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&_.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}};U.create=r=>new U({checks:[],typeName:m.ZodNumber,coerce:r?.coerce||!1,...g(r)});var B=class r extends y{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)!==f.bigint)return this._getInvalidInput(e);let s,n=new x;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),d(s,{code:c.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),d(s,{code:c.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),d(s,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):_.assertNever(a);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return d(t,{code:c.invalid_type,expected:f.bigint,received:t.parsedType}),h}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,s,n){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:p.toString(n)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};B.create=r=>new B({checks:[],typeName:m.ZodBigInt,coerce:r?.coerce??!1,...g(r)});var H=class extends y{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){let s=this._getOrReturnCtx(e);return d(s,{code:c.invalid_type,expected:f.boolean,received:s.parsedType}),h}return k(e.data)}};H.create=r=>new H({typeName:m.ZodBoolean,coerce:r?.coerce||!1,...g(r)});var W=class r extends y{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){let a=this._getOrReturnCtx(e);return d(a,{code:c.invalid_type,expected:f.date,received:a.parsedType}),h}if(Number.isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return d(a,{code:c.invalid_date}),h}let s=new x,n;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(n=this._getOrReturnCtx(e,n),d(n,{code:c.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(n=this._getOrReturnCtx(e,n),d(n,{code:c.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):_.assertNever(a);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:p.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:p.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};W.create=r=>new W({checks:[],coerce:r?.coerce||!1,typeName:m.ZodDate,...g(r)});var ce=class extends y{_parse(e){if(this._getType(e)!==f.symbol){let s=this._getOrReturnCtx(e);return d(s,{code:c.invalid_type,expected:f.symbol,received:s.parsedType}),h}return k(e.data)}};ce.create=r=>new ce({typeName:m.ZodSymbol,...g(r)});var Y=class extends y{_parse(e){if(this._getType(e)!==f.undefined){let s=this._getOrReturnCtx(e);return d(s,{code:c.invalid_type,expected:f.undefined,received:s.parsedType}),h}return k(e.data)}};Y.create=r=>new Y({typeName:m.ZodUndefined,...g(r)});var q=class extends y{_parse(e){if(this._getType(e)!==f.null){let s=this._getOrReturnCtx(e);return d(s,{code:c.invalid_type,expected:f.null,received:s.parsedType}),h}return k(e.data)}};q.create=r=>new q({typeName:m.ZodNull,...g(r)});var V=class extends y{constructor(){super(...arguments),this._any=!0}_parse(e){return k(e.data)}};V.create=r=>new V({typeName:m.ZodAny,...g(r)});var z=class extends y{constructor(){super(...arguments),this._unknown=!0}_parse(e){return k(e.data)}};z.create=r=>new z({typeName:m.ZodUnknown,...g(r)});var O=class extends y{_parse(e){let t=this._getOrReturnCtx(e);return d(t,{code:c.invalid_type,expected:f.never,received:t.parsedType}),h}};O.create=r=>new O({typeName:m.ZodNever,...g(r)});var ue=class extends y{_parse(e){if(this._getType(e)!==f.undefined){let s=this._getOrReturnCtx(e);return d(s,{code:c.invalid_type,expected:f.void,received:s.parsedType}),h}return k(e.data)}};ue.create=r=>new ue({typeName:m.ZodVoid,...g(r)});var P=class r extends y{_parse(e){let{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==f.array)return d(t,{code:c.invalid_type,expected:f.array,received:t.parsedType}),h;if(n.exactLength!==null){let i=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(i||o)&&(d(t,{code:i?c.too_big:c.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(d(t,{code:c.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(d(t,{code:c.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>n.type._parseAsync(new S(t,i,t.path,o)))).then(i=>x.mergeArray(s,i));let a=[...t.data].map((i,o)=>n.type._parseSync(new S(t,i,t.path,o)));return x.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:p.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:p.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:p.toString(t)}})}nonempty(e){return this.min(1,e)}};P.create=(r,e)=>new P({type:r,minLength:null,maxLength:null,exactLength:null,typeName:m.ZodArray,...g(e)});function oe(r){if(r instanceof E){let e={};for(let t in r.shape){let s=r.shape[t];e[t]=A.create(oe(s))}return new E({...r._def,shape:()=>e})}else return r instanceof P?new P({...r._def,type:oe(r.element)}):r instanceof A?A.create(oe(r.unwrap())):r instanceof $?$.create(oe(r.unwrap())):r instanceof I?I.create(r.items.map(e=>oe(e))):r}var E=class r extends y{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(),t=_.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==f.object){let l=this._getOrReturnCtx(e);return d(l,{code:c.invalid_type,expected:f.object,received:l.parsedType}),h}let{status:s,ctx:n}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof O&&this._def.unknownKeys==="strip"))for(let l in n.data)i.includes(l)||o.push(l);let u=[];for(let l of i){let v=a[l],T=n.data[l];u.push({key:{status:"valid",value:l},value:v._parse(new S(n,T,n.path,l)),alwaysSet:l in n.data})}if(this._def.catchall instanceof O){let l=this._def.unknownKeys;if(l==="passthrough")for(let v of o)u.push({key:{status:"valid",value:v},value:{status:"valid",value:n.data[v]}});else if(l==="strict")o.length>0&&(d(n,{code:c.unrecognized_keys,keys:o}),s.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let v of o){let T=n.data[v];u.push({key:{status:"valid",value:v},value:l._parse(new S(n,T,n.path,v)),alwaysSet:v in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let l=[];for(let v of u){let T=await v.key,Se=await v.value;l.push({key:T,value:Se,alwaysSet:v.alwaysSet})}return l}).then(l=>x.mergeObjectSync(s,l)):x.mergeObjectSync(s,u)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{let n=this._def.errorMap?.(t,s).message??s.defaultError;return t.code==="unrecognized_keys"?{message:p.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:m.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};for(let s of _.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new r({...this._def,shape:()=>t})}omit(e){let t={};for(let s of _.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new r({...this._def,shape:()=>t})}deepPartial(){return oe(this)}partial(e){let t={};for(let s of _.objectKeys(this.shape)){let n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}return new r({...this._def,shape:()=>t})}required(e){let t={};for(let s of _.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof A;)a=a._def.innerType;t[s]=a}return new r({...this._def,shape:()=>t})}keyof(){return Ke(_.objectKeys(this.shape))}};E.create=(r,e)=>new E({shape:()=>r,unknownKeys:"strip",catchall:O.create(),typeName:m.ZodObject,...g(e)});E.strictCreate=(r,e)=>new E({shape:()=>r,unknownKeys:"strict",catchall:O.create(),typeName:m.ZodObject,...g(e)});E.lazycreate=(r,e)=>new E({shape:r,unknownKeys:"strip",catchall:O.create(),typeName:m.ZodObject,...g(e)});var J=class extends y{_parse(e){let{ctx:t}=this._processInputParams(e),s=this._def.options;function n(a){for(let o of a)if(o.result.status==="valid")return o.result;for(let o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;let i=a.map(o=>new b(o.ctx.common.issues));return d(t,{code:c.invalid_union,unionErrors:i}),h}if(t.common.async)return Promise.all(s.map(async a=>{let i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(n);{let a,i=[];for(let u of s){let l={...t,common:{...t.common,issues:[]},parent:null},v=u._parseSync({data:t.data,path:t.path,parent:l});if(v.status==="valid")return v;v.status==="dirty"&&!a&&(a={result:v,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(u=>new b(u));return d(t,{code:c.invalid_union,unionErrors:o}),h}}get options(){return this._def.options}};J.create=(r,e)=>new J({options:r,typeName:m.ZodUnion,...g(e)});var j=r=>r instanceof X?j(r.schema):r instanceof C?j(r.innerType()):r instanceof Q?[r.value]:r instanceof ee?r.options:r instanceof te?_.objectValues(r.enum):r instanceof re?j(r._def.innerType):r instanceof Y?[void 0]:r instanceof q?[null]:r instanceof A?[void 0,...j(r.unwrap())]:r instanceof $?[null,...j(r.unwrap())]:r instanceof he||r instanceof ne?j(r.unwrap()):r instanceof se?j(r._def.innerType):[],ve=class r extends y{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return d(t,{code:c.invalid_type,expected:f.object,received:t.parsedType}),h;let s=this.discriminator,n=t.data[s],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(d(t,{code:c.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),h)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){let n=new Map;for(let a of t){let i=j(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of i){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,a)}}return new r({typeName:m.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...g(s)})}};function Ae(r,e){let t=N(r),s=N(e);if(r===e)return{valid:!0,data:r};if(t===f.object&&s===f.object){let n=_.objectKeys(e),a=_.objectKeys(r).filter(o=>n.indexOf(o)!==-1),i={...r,...e};for(let o of a){let u=Ae(r[o],e[o]);if(!u.valid)return{valid:!1};i[o]=u.data}return{valid:!0,data:i}}else if(t===f.array&&s===f.array){if(r.length!==e.length)return{valid:!1};let n=[];for(let a=0;a<r.length;a++){let i=r[a],o=e[a],u=Ae(i,o);if(!u.valid)return{valid:!1};n.push(u.data)}return{valid:!0,data:n}}else return t===f.date&&s===f.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var G=class extends y{_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=(a,i)=>{if(ye(a)||ye(i))return h;let o=Ae(a.value,i.value);return o.valid?((_e(a)||_e(i))&&t.dirty(),{status:t.value,value:o.data}):(d(s,{code:c.invalid_intersection_types}),h)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};G.create=(r,e,t)=>new G({left:r,right:e,typeName:m.ZodIntersection,...g(t)});var I=class r extends y{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.array)return d(s,{code:c.invalid_type,expected:f.array,received:s.parsedType}),h;if(s.data.length<this._def.items.length)return d(s,{code:c.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),h;!this._def.rest&&s.data.length>this._def.items.length&&(d(s,{code:c.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let a=[...s.data].map((i,o)=>{let u=this._def.items[o]||this._def.rest;return u?u._parse(new S(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>x.mergeArray(t,i)):x.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};I.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new I({items:r,typeName:m.ZodTuple,rest:null,...g(e)})};var xe=class r extends y{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.object)return d(s,{code:c.invalid_type,expected:f.object,received:s.parsedType}),h;let n=[],a=this._def.keyType,i=this._def.valueType;for(let o in s.data)n.push({key:a._parse(new S(s,o,s.path,o)),value:i._parse(new S(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?x.mergeObjectAsync(t,n):x.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof y?new r({keyType:e,valueType:t,typeName:m.ZodRecord,...g(s)}):new r({keyType:L.create(),valueType:e,typeName:m.ZodRecord,...g(t)})}},de=class extends y{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.map)return d(s,{code:c.invalid_type,expected:f.map,received:s.parsedType}),h;let n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,u],l)=>({key:n._parse(new S(s,o,s.path,[l,"key"])),value:a._parse(new S(s,u,s.path,[l,"value"]))}));if(s.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let u of i){let l=await u.key,v=await u.value;if(l.status==="aborted"||v.status==="aborted")return h;(l.status==="dirty"||v.status==="dirty")&&t.dirty(),o.set(l.value,v.value)}return{status:t.value,value:o}})}else{let o=new Map;for(let u of i){let l=u.key,v=u.value;if(l.status==="aborted"||v.status==="aborted")return h;(l.status==="dirty"||v.status==="dirty")&&t.dirty(),o.set(l.value,v.value)}return{status:t.value,value:o}}}};de.create=(r,e,t)=>new de({valueType:e,keyType:r,typeName:m.ZodMap,...g(t)});var le=class r extends y{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.set)return d(s,{code:c.invalid_type,expected:f.set,received:s.parsedType}),h;let n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(d(s,{code:c.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(d(s,{code:c.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());let a=this._def.valueType;function i(u){let l=new Set;for(let v of u){if(v.status==="aborted")return h;v.status==="dirty"&&t.dirty(),l.add(v.value)}return{status:t.value,value:l}}let o=[...s.data.values()].map((u,l)=>a._parse(new S(s,u,s.path,l)));return s.common.async?Promise.all(o).then(u=>i(u)):i(o)}min(e,t){return new r({...this._def,minSize:{value:e,message:p.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:p.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};le.create=(r,e)=>new le({valueType:r,minSize:null,maxSize:null,typeName:m.ZodSet,...g(e)});var ke=class r extends y{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return d(t,{code:c.invalid_type,expected:f.function,received:t.parsedType}),h;function s(o,u){return pe({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ae(),Z].filter(l=>!!l),issueData:{code:c.invalid_arguments,argumentsError:u}})}function n(o,u){return pe({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ae(),Z].filter(l=>!!l),issueData:{code:c.invalid_return_type,returnTypeError:u}})}let a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof F){let o=this;return k(async function(...u){let l=new b([]),v=await o._def.args.parseAsync(u,a).catch(be=>{throw l.addIssue(s(u,be)),l}),T=await Reflect.apply(i,this,v);return await o._def.returns._def.type.parseAsync(T,a).catch(be=>{throw l.addIssue(n(T,be)),l})})}else{let o=this;return k(function(...u){let l=o._def.args.safeParse(u,a);if(!l.success)throw new b([s(u,l.error)]);let v=Reflect.apply(i,this,l.data),T=o._def.returns.safeParse(v,a);if(!T.success)throw new b([n(v,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:I.create(e).rest(z.create())})}returns(e){return new r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new r({args:e||I.create([]).rest(z.create()),returns:t||z.create(),typeName:m.ZodFunction,...g(s)})}},X=class extends y{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};X.create=(r,e)=>new X({getter:r,typeName:m.ZodLazy,...g(e)});var Q=class extends y{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return d(t,{received:t.data,code:c.invalid_literal,expected:this._def.value}),h}return{status:"valid",value:e.data}}get value(){return this._def.value}};Q.create=(r,e)=>new Q({value:r,typeName:m.ZodLiteral,...g(e)});function Ke(r,e){return new ee({values:r,typeName:m.ZodEnum,...g(e)})}var ee=class r extends y{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),s=this._def.values;return d(t,{expected:_.joinValues(s),received:t.parsedType,code:c.invalid_type}),h}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),s=this._def.values;return d(t,{received:t.data,code:c.invalid_enum_value,options:s}),h}return k(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,{...this._def,...t})}exclude(e,t=this._def){return r.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}};ee.create=Ke;var te=class extends y{_parse(e){let t=_.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==f.string&&s.parsedType!==f.number){let n=_.objectValues(t);return d(s,{expected:_.joinValues(n),received:s.parsedType,code:c.invalid_type}),h}if(this._cache||(this._cache=new Set(_.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let n=_.objectValues(t);return d(s,{received:s.data,code:c.invalid_enum_value,options:n}),h}return k(e.data)}get enum(){return this._def.values}};te.create=(r,e)=>new te({values:r,typeName:m.ZodNativeEnum,...g(e)});var F=class extends y{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return d(t,{code:c.invalid_type,expected:f.promise,received:t.parsedType}),h;let s=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return k(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}};F.create=(r,e)=>new F({type:r,typeName:m.ZodPromise,...g(e)});var C=class extends y{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===m.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{d(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){let i=n.transform(s.data,a);if(s.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return h;let u=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return u.status==="aborted"?h:u.status==="dirty"?K(u.value):t.value==="dirty"?K(u.value):u});{if(t.value==="aborted")return h;let o=this._def.schema._parseSync({data:i,path:s.path,parent:s});return o.status==="aborted"?h:o.status==="dirty"?K(o.value):t.value==="dirty"?K(o.value):o}}if(n.type==="refinement"){let i=o=>{let u=n.refinement(o,a);if(s.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){let o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?h:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?h:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){let i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!M(i))return h;let o=n.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>M(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):h);_.assertNever(n)}};C.create=(r,e,t)=>new C({schema:r,typeName:m.ZodEffects,effect:e,...g(t)});C.createWithPreprocess=(r,e,t)=>new C({schema:e,effect:{type:"preprocess",transform:r},typeName:m.ZodEffects,...g(t)});var A=class extends y{_parse(e){return this._getType(e)===f.undefined?k(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};A.create=(r,e)=>new A({innerType:r,typeName:m.ZodOptional,...g(e)});var $=class extends y{_parse(e){return this._getType(e)===f.null?k(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};$.create=(r,e)=>new $({innerType:r,typeName:m.ZodNullable,...g(e)});var re=class extends y{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return t.parsedType===f.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};re.create=(r,e)=>new re({innerType:r,typeName:m.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...g(e)});var se=class extends y{_parse(e){let{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return ie(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new b(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new b(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};se.create=(r,e)=>new se({innerType:r,typeName:m.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...g(e)});var fe=class extends y{_parse(e){if(this._getType(e)!==f.nan){let s=this._getOrReturnCtx(e);return d(s,{code:c.invalid_type,expected:f.nan,received:s.parsedType}),h}return{status:"valid",value:e.data}}};fe.create=r=>new fe({typeName:m.ZodNaN,...g(r)});var Kt=Symbol("zod_brand"),he=class extends y{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}},me=class r extends y{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?h:a.status==="dirty"?(t.dirty(),K(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{let n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?h:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new r({in:e,out:t,typeName:m.ZodPipeline})}},ne=class extends y{_parse(e){let t=this._def.innerType._parse(e),s=n=>(M(n)&&(n.value=Object.freeze(n.value)),n);return ie(t)?t.then(n=>s(n)):s(t)}unwrap(){return this._def.innerType}};ne.create=(r,e)=>new ne({innerType:r,typeName:m.ZodReadonly,...g(e)});function Me(r,e){let t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function Ue(r,e={},t){return r?V.create().superRefine((s,n)=>{let a=r(s);if(a instanceof Promise)return a.then(i=>{if(!i){let o=Me(e,s),u=o.fatal??t??!0;n.addIssue({code:"custom",...o,fatal:u})}});if(!a){let i=Me(e,s),o=i.fatal??t??!0;n.addIssue({code:"custom",...i,fatal:o})}}):V.create()}var Ut={object:E.lazycreate},m;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(m||(m={}));var Bt=(r,e={message:`Input not instance of ${r.name}`})=>Ue(t=>t instanceof r,e),Be=L.create,He=U.create,Ht=fe.create,Wt=B.create,We=H.create,Yt=W.create,qt=ce.create,Jt=Y.create,Gt=q.create,Xt=V.create,Qt=z.create,er=O.create,tr=ue.create,rr=P.create,sr=E.create,nr=E.strictCreate,ar=J.create,ir=ve.create,or=G.create,cr=I.create,ur=xe.create,dr=de.create,lr=le.create,fr=ke.create,pr=X.create,hr=Q.create,mr=ee.create,gr=te.create,yr=F.create,_r=C.create,vr=A.create,xr=$.create,kr=C.createWithPreprocess,br=me.create,Er=()=>Be().optional(),wr=()=>He().optional(),Tr=()=>We().optional(),Ar={string:(r=>L.create({...r,coerce:!0})),number:(r=>U.create({...r,coerce:!0})),boolean:(r=>H.create({...r,coerce:!0})),bigint:(r=>B.create({...r,coerce:!0})),date:(r=>W.create({...r,coerce:!0}))};var Sr=h;var Cr=R.enum(["normal","compact","minimal"]),Rr=R.enum(["off","light","balanced","max"]),ge=R.object({enabled:R.boolean().default(!0),telemetryOptIn:R.boolean().default(!0),outputVerbosity:Cr.default("compact"),reducer:Rr.default("off"),filters:R.object({enableAll:R.boolean().default(!0),disabled:R.array(R.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})});var Nr="settings-cache.json",Ye=ge.parse({}),bn=ge.partial().extend({filters:ge.shape.filters.removeDefault().partial().optional()});async function qe(){let r=null;try{let e=JSON.parse(await Or(Dr(w(),Nr),"utf8"));typeof e=="object"&&e!==null&&!Array.isArray(e)&&(r=e)}catch{}return r?ge.parse({...Ye,...r}):Ye}import{existsSync as Ir,mkdirSync as Tn,rmSync as An,writeFileSync as Sn}from"node:fs";import{join as $r}from"node:path";var Zr=new Set(["0","off","false","no"]);var On=["Tokmizer contacts tokmizer.com to keep its rules up to date and to improve the product. No account or email is needed.","It sends a random install ID, your computer name, OS and CPU model, a hash of your network card address and of your user name, and the plugin version. Command contents and output are never sent.","Usage stats (command names, token counts and install health counts) are sent only while they are on. Check with: tkr telemetry status.","Turn all network access off: tkr network off. Usage stats only: tkr telemetry off."].join(`
5
- `);function jr(){return $r(w(),"network-off")}function zr(){let r=process.env.TOKMIZER_NETWORK;return r!==void 0&&Zr.has(r.trim().toLowerCase())}function Je(){return zr()?!1:!Ir(jr())}import{createRequire as Pr}from"node:module";var Mr=Pr(import.meta.url);function Lr(){let r="1.0.0";if(r)return r;for(let e of["../package.json","../../package.json"])try{let t=Mr(e).version;if(typeof t=="string"&&t)return t}catch{}return"0.0.0"}var Ge=Lr();var Ur="telemetry-notice-shown";var Br="Tokmizer sends usage stats (command names and tokens saved, never content, files or arguments) to improve the product. No account or email needed. To turn off: tkr telemetry off (or tkr network off to cut all network access).";function Xe(){return Kr(w(),Ur)}function Hr(r,e){if(Qe(r))return!1;try{Vr(w(),{recursive:!0,mode:448}),Fr(r,e,{mode:384})}catch{return!1}return!0}async function et(){return!Je()||Qe(Xe())||!(await qe()).telemetryOptIn?null:Hr(Xe(),`${Ge} ${Date.now()}`)?Br:null}import{existsSync as Wr,mkdirSync as Fn,rmSync as Yr,writeFileSync as Kn}from"node:fs";import{join as qr}from"node:path";var Jr="An automatic Tokmizer update added its hook to Codex (hooks.json) so Codex commands are optimized too. To remove it: tkr setup-codex --remove";function tt(){return qr(w(),"codex-hook-notice")}function rt(){if(!Wr(tt()))return null;try{Yr(tt())}catch{return null}return Jr}async function Gr(r){if(r.source!=="compact"&&r.source!=="resume"||!r.session_id)return null;let e=Ie(r.session_id);return Ze(e)||null}async function Xr(){let r=await Ce();r||process.exit(0);let e;try{e=JSON.parse(r)}catch{process.exit(0)}let t=[await et().catch(()=>null),rt()].filter(n=>n!==null),s=Qr(await es(e),t.length?t.join(`
5
+ `);function jr(){return $r(w(),"network-off")}function zr(){let r=process.env.TOKMIZER_NETWORK;return r!==void 0&&Zr.has(r.trim().toLowerCase())}function Je(){return zr()?!1:!Ir(jr())}import{createRequire as Pr}from"node:module";var Mr=Pr(import.meta.url);function Lr(){let r="1.0.2";if(r)return r;for(let e of["../package.json","../../package.json"])try{let t=Mr(e).version;if(typeof t=="string"&&t)return t}catch{}return"0.0.0"}var Ge=Lr();var Ur="telemetry-notice-shown";var Br="Tokmizer sends usage stats (command names and tokens saved, never content, files or arguments) to improve the product. No account or email needed. To turn off: tkr telemetry off (or tkr network off to cut all network access).";function Xe(){return Kr(w(),Ur)}function Hr(r,e){if(Qe(r))return!1;try{Vr(w(),{recursive:!0,mode:448}),Fr(r,e,{mode:384})}catch{return!1}return!0}async function et(){return!Je()||Qe(Xe())||!(await qe()).telemetryOptIn?null:Hr(Xe(),`${Ge} ${Date.now()}`)?Br:null}import{existsSync as Wr,mkdirSync as Fn,rmSync as Yr,writeFileSync as Kn}from"node:fs";import{join as qr}from"node:path";var Jr="An automatic Tokmizer update added its hook to Codex (hooks.json) so Codex commands are optimized too. To remove it: tkr setup-codex --remove";function tt(){return qr(w(),"codex-hook-notice")}function rt(){if(!Wr(tt()))return null;try{Yr(tt())}catch{return null}return Jr}async function Gr(r){if(r.source!=="compact"&&r.source!=="resume"||!r.session_id)return null;let e=Ie(r.session_id);return Ze(e)||null}async function Xr(){let r=await Ce();r||process.exit(0);let e;try{e=JSON.parse(r)}catch{process.exit(0)}let t=[await et().catch(()=>null),rt()].filter(n=>n!==null),s=Qr(await es(e),t.length?t.join(`
6
6
  `):null);s&&process.stdout.write(s)}function Qr(r,e){return e?JSON.stringify({systemMessage:e,...r?{hookSpecificOutput:{hookEventName:"SessionStart",additionalContext:r}}:{}}):r}async function es(r){try{$e()}catch{}return r.session_id&&r.source!=="startup"&&je(r.session_id),Gr(r)}var ts=process.argv[1]??"";De(ts,import.meta.url,"session-recap")&&Xr().catch(()=>{process.exit(0)});export{es as handleSessionStart,Gr as recapForSessionStart,Qr as sessionStartOutput};