@tokmizer/plugin 1.1.4 → 1.1.5

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.
@@ -2,7 +2,7 @@ import { createRequire as __tkrCreateRequire } from "node:module"; const require
2
2
  var Rt=Object.defineProperty;var A=(r,e,t)=>()=>{if(t)throw t[0];try{return r&&(e=r(r=0)),e}catch(s){throw t=[s],s}};var Ve=(r,e)=>{for(var t in e)Rt(r,t,{get:e[t],enumerable:!0})};import Nt from"node:os";import{join as It}from"node:path";function x(){return process.env.TOKMIZER_HOME||It(Nt.homedir(),".tokmizer")}var B=A(()=>{"use strict"});var v,Ne,f,I,ye=A(()=>{(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})(v||(v={}));(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Ne||(Ne={}));f=v.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),I=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 u,Kt,w,be=A(()=>{ye();u=v.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"]),Kt=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),w=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,c=0;for(;c<i.path.length;){let d=i.path[c];c===i.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(t(i))):o[d]=o[d]||{_errors:[]},o=o[d],c++}}};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,v.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()}};w.create=r=>new w(r)});var Bt,j,Ie=A(()=>{be();ye();Bt=(r,e)=>{let t;switch(r.code){case u.invalid_type:r.received===f.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case u.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,v.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:t=`Unrecognized key(s) in object: ${v.joinValues(r.keys,", ")}`;break;case u.invalid_union:t="Invalid input";break;case u.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${v.joinValues(r.options)}`;break;case u.invalid_enum_value:t=`Invalid enum value. Expected ${v.joinValues(r.options)}, received '${r.received}'`;break;case u.invalid_arguments:t="Invalid function arguments";break;case u.invalid_return_type:t="Invalid function return type";break;case u.invalid_date:t="Invalid date";break;case u.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}"`:v.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case u.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 u.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 u.custom:t="Invalid input";break;case u.invalid_intersection_types:t="Intersection results could not be merged";break;case u.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case u.not_finite:t="Number must be finite";break;default:t=e.defaultError,v.assertNever(r)}return{message:t}},j=Bt});function Ut(r){Ge=r}function oe(){return Ge}var Ge,Ee=A(()=>{Ie();Ge=j});function l(r,e){let t=oe(),s=_e({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===j?void 0:j].filter(n=>!!n)});r.common.issues.push(s)}var _e,Ht,k,h,U,b,we,Te,L,ce,$e=A(()=>{Ee();Ie();_e=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="",c=s.filter(d=>!!d).slice().reverse();for(let d of c)o=d(i,{data:e,defaultError:o}).message;return{...n,path:a,message:o}},Ht=[];k=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"}),U=r=>({status:"dirty",value:r}),b=r=>({status:"valid",value:r}),we=r=>r.status==="aborted",Te=r=>r.status==="dirty",L=r=>r.status==="valid",ce=r=>typeof Promise<"u"&&r instanceof Promise});var Xe=A(()=>{});var p,Qe=A(()=>{(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(p||(p={}))});function y(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:c}=r;return i.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??s??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:c??t??o.defaultError}},description:n}}function st(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 ur(r){return new RegExp(`^${st(r)}$`)}function nt(r){let e=`${rt}T${st(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 dr(r,e){return!!((e==="v4"||!e)&&rr.test(r)||(e==="v6"||!e)&&nr.test(r))}function lr(r,e){if(!Xt.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 fr(r,e){return!!((e==="v4"||!e)&&sr.test(r)||(e==="v6"||!e)&&ar.test(r))}function pr(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}function ue(r){if(r instanceof T){let e={};for(let t in r.shape){let s=r.shape[t];e[t]=S.create(ue(s))}return new T({...r._def,shape:()=>e})}else return r instanceof M?new M({...r._def,type:ue(r.element)}):r instanceof S?S.create(ue(r.unwrap())):r instanceof Z?Z.create(ue(r.unwrap())):r instanceof $?$.create(r.items.map(e=>ue(e))):r}function je(r,e){let t=I(r),s=I(e);if(r===e)return{valid:!0,data:r};if(t===f.object&&s===f.object){let n=v.objectKeys(e),a=v.objectKeys(r).filter(o=>n.indexOf(o)!==-1),i={...r,...e};for(let o of a){let c=je(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.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],c=je(i,o);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return t===f.date&&s===f.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}function at(r,e){return new re({values:r,typeName:m.ZodEnum,...y(e)})}function tt(r,e){let t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function it(r,e={},t){return r?F.create().superRefine((s,n)=>{let a=r(s);if(a instanceof Promise)return a.then(i=>{if(!i){let o=tt(e,s),c=o.fatal??t??!0;n.addIssue({code:"custom",...o,fatal:c})}});if(!a){let i=tt(e,s),o=i.fatal??t??!0;n.addIssue({code:"custom",...i,fatal:o})}}):F.create()}var C,et,_,Wt,Yt,qt,Jt,Gt,Xt,Qt,er,tr,Ze,rr,sr,nr,ar,ir,or,rt,cr,V,H,W,Y,q,de,J,G,F,P,D,le,M,T,X,z,Ae,Q,$,Se,fe,pe,Ce,ee,te,re,se,K,R,S,Z,ne,ae,he,hr,ve,xe,ie,mr,m,gr,ot,ct,yr,_r,ut,vr,xr,kr,br,Er,wr,Tr,Ar,Sr,Cr,Rr,Or,Dr,Nr,Ir,$r,Zr,jr,zr,Pr,Mr,Lr,Vr,Fr,Kr,Br,Ur,Hr,Wr,Yr,qr,Jr,Gr,Xr,dt=A(()=>{be();Ee();Qe();$e();ye();C=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}},et=(r,e)=>{if(L(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 w(r.common.issues);return this._error=t,this._error}}};_=class{get description(){return this._def.description}_getType(e){return I(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:I(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new k,ctx:{common:e.parent.common,data:e.data,parsedType:I(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(ce(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:I(e)},n=this._parseSync({data:e,path:s.path,parent:s});return et(s,n)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:I(e)};if(!this["~standard"].async)try{let s=this._parseSync({data:e,path:[],parent:t});return L(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=>L(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:I(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(ce(n)?n:Promise.resolve(n));return et(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:u.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!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 R({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 S.create(this,this._def)}nullable(){return Z.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return M.create(this)}promise(){return K.create(this,this._def)}or(e){return X.create([this,e],this._def)}and(e){return Q.create(this,e,this._def)}transform(e){return new R({...y(this._def),schema:this,typeName:m.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new ne({...y(this._def),innerType:this,defaultValue:t,typeName:m.ZodDefault})}brand(){return new ve({typeName:m.ZodBranded,type:this,...y(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new ae({...y(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 xe.create(this,e)}readonly(){return ie.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Wt=/^c[^\s-]{8,}$/i,Yt=/^[0-9a-z]+$/,qt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Jt=/^[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,Gt=/^[a-z0-9_-]{21}$/i,Xt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Qt=/^[-+]?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)?)??$/,er=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,tr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",rr=/^(?:(?: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])$/,sr=/^(?:(?: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])$/,nr=/^(([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]))$/,ar=/^(([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])$/,ir=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,or=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,rt="((\\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])))",cr=new RegExp(`^${rt}$`);V=class r extends _{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){let a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_type,expected:f.string,received:a.parsedType}),h}let s=new k,n;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:u.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),l(n,{code:u.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?l(n,{code:u.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&l(n,{code:u.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")er.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"email",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")Ze||(Ze=new RegExp(tr,"u")),Ze.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"emoji",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")Jt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"uuid",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")Gt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"nanoid",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")Wt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cuid",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")Yt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cuid2",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")qt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"ulid",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),l(n,{validation:"url",code:u.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),l(n,{validation:"regex",code:u.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),l(n,{code:u.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),l(n,{code:u.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),l(n,{code:u.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?nt(a).test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:u.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?cr.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:u.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?ur(a).test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:u.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?Qt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"duration",code:u.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?dr(e.data,a.version)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"ip",code:u.invalid_string,message:a.message}),s.dirty()):a.kind==="jwt"?lr(e.data,a.alg)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"jwt",code:u.invalid_string,message:a.message}),s.dirty()):a.kind==="cidr"?fr(e.data,a.version)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cidr",code:u.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?ir.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"base64",code:u.invalid_string,message:a.message}),s.dirty()):a.kind==="base64url"?or.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"base64url",code:u.invalid_string,message:a.message}),s.dirty()):v.assertNever(a);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:u.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}};V.create=r=>new V({checks:[],typeName:m.ZodString,coerce:r?.coerce??!1,...y(r)});H=class r extends _{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 l(a,{code:u.invalid_type,expected:f.number,received:a.parsedType}),h}let s,n=new k;for(let a of this._def.checks)a.kind==="int"?v.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:u.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),l(s,{code:u.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),l(s,{code:u.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?pr(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:u.not_finite,message:a.message}),n.dirty()):v.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"&&v.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)}};H.create=r=>new H({checks:[],typeName:m.ZodNumber,coerce:r?.coerce||!1,...y(r)});W=class r extends _{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 k;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),l(s,{code:u.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),l(s,{code:u.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),l(s,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):v.assertNever(a);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return l(t,{code:u.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}};W.create=r=>new W({checks:[],typeName:m.ZodBigInt,coerce:r?.coerce??!1,...y(r)});Y=class extends _{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){let s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:f.boolean,received:s.parsedType}),h}return b(e.data)}};Y.create=r=>new Y({typeName:m.ZodBoolean,coerce:r?.coerce||!1,...y(r)});q=class r extends _{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){let a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_type,expected:f.date,received:a.parsedType}),h}if(Number.isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_date}),h}let s=new k,n;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:u.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),l(n,{code:u.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):v.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}};q.create=r=>new q({checks:[],coerce:r?.coerce||!1,typeName:m.ZodDate,...y(r)});de=class extends _{_parse(e){if(this._getType(e)!==f.symbol){let s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:f.symbol,received:s.parsedType}),h}return b(e.data)}};de.create=r=>new de({typeName:m.ZodSymbol,...y(r)});J=class extends _{_parse(e){if(this._getType(e)!==f.undefined){let s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:f.undefined,received:s.parsedType}),h}return b(e.data)}};J.create=r=>new J({typeName:m.ZodUndefined,...y(r)});G=class extends _{_parse(e){if(this._getType(e)!==f.null){let s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:f.null,received:s.parsedType}),h}return b(e.data)}};G.create=r=>new G({typeName:m.ZodNull,...y(r)});F=class extends _{constructor(){super(...arguments),this._any=!0}_parse(e){return b(e.data)}};F.create=r=>new F({typeName:m.ZodAny,...y(r)});P=class extends _{constructor(){super(...arguments),this._unknown=!0}_parse(e){return b(e.data)}};P.create=r=>new P({typeName:m.ZodUnknown,...y(r)});D=class extends _{_parse(e){let t=this._getOrReturnCtx(e);return l(t,{code:u.invalid_type,expected:f.never,received:t.parsedType}),h}};D.create=r=>new D({typeName:m.ZodNever,...y(r)});le=class extends _{_parse(e){if(this._getType(e)!==f.undefined){let s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:f.void,received:s.parsedType}),h}return b(e.data)}};le.create=r=>new le({typeName:m.ZodVoid,...y(r)});M=class r extends _{_parse(e){let{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==f.array)return l(t,{code:u.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)&&(l(t,{code:i?u.too_big:u.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&&(l(t,{code:u.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&&(l(t,{code:u.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 C(t,i,t.path,o)))).then(i=>k.mergeArray(s,i));let a=[...t.data].map((i,o)=>n.type._parseSync(new C(t,i,t.path,o)));return k.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)}};M.create=(r,e)=>new M({type:r,minLength:null,maxLength:null,exactLength:null,typeName:m.ZodArray,...y(e)});T=class r extends _{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=v.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==f.object){let d=this._getOrReturnCtx(e);return l(d,{code:u.invalid_type,expected:f.object,received:d.parsedType}),h}let{status:s,ctx:n}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof D&&this._def.unknownKeys==="strip"))for(let d in n.data)i.includes(d)||o.push(d);let c=[];for(let d of i){let g=a[d],E=n.data[d];c.push({key:{status:"valid",value:d},value:g._parse(new C(n,E,n.path,d)),alwaysSet:d in n.data})}if(this._def.catchall instanceof D){let d=this._def.unknownKeys;if(d==="passthrough")for(let g of o)c.push({key:{status:"valid",value:g},value:{status:"valid",value:n.data[g]}});else if(d==="strict")o.length>0&&(l(n,{code:u.unrecognized_keys,keys:o}),s.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let d=this._def.catchall;for(let g of o){let E=n.data[g];c.push({key:{status:"valid",value:g},value:d._parse(new C(n,E,n.path,g)),alwaysSet:g in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let d=[];for(let g of c){let E=await g.key,Le=await g.value;d.push({key:E,value:Le,alwaysSet:g.alwaysSet})}return d}).then(d=>k.mergeObjectSync(s,d)):k.mergeObjectSync(s,c)}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 v.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 v.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new r({...this._def,shape:()=>t})}deepPartial(){return ue(this)}partial(e){let t={};for(let s of v.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 v.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof S;)a=a._def.innerType;t[s]=a}return new r({...this._def,shape:()=>t})}keyof(){return at(v.objectKeys(this.shape))}};T.create=(r,e)=>new T({shape:()=>r,unknownKeys:"strip",catchall:D.create(),typeName:m.ZodObject,...y(e)});T.strictCreate=(r,e)=>new T({shape:()=>r,unknownKeys:"strict",catchall:D.create(),typeName:m.ZodObject,...y(e)});T.lazycreate=(r,e)=>new T({shape:r,unknownKeys:"strip",catchall:D.create(),typeName:m.ZodObject,...y(e)});X=class extends _{_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 w(o.ctx.common.issues));return l(t,{code:u.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 c of s){let d={...t,common:{...t.common,issues:[]},parent:null},g=c._parseSync({data:t.data,path:t.path,parent:d});if(g.status==="valid")return g;g.status==="dirty"&&!a&&(a={result:g,ctx:d}),d.common.issues.length&&i.push(d.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(c=>new w(c));return l(t,{code:u.invalid_union,unionErrors:o}),h}}get options(){return this._def.options}};X.create=(r,e)=>new X({options:r,typeName:m.ZodUnion,...y(e)});z=r=>r instanceof ee?z(r.schema):r instanceof R?z(r.innerType()):r instanceof te?[r.value]:r instanceof re?r.options:r instanceof se?v.objectValues(r.enum):r instanceof ne?z(r._def.innerType):r instanceof J?[void 0]:r instanceof G?[null]:r instanceof S?[void 0,...z(r.unwrap())]:r instanceof Z?[null,...z(r.unwrap())]:r instanceof ve||r instanceof ie?z(r.unwrap()):r instanceof ae?z(r._def.innerType):[],Ae=class r extends _{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return l(t,{code:u.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}):(l(t,{code:u.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=z(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,...y(s)})}};Q=class extends _{_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=(a,i)=>{if(we(a)||we(i))return h;let o=je(a.value,i.value);return o.valid?((Te(a)||Te(i))&&t.dirty(),{status:t.value,value:o.data}):(l(s,{code:u.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}))}};Q.create=(r,e,t)=>new Q({left:r,right:e,typeName:m.ZodIntersection,...y(t)});$=class r extends _{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.array)return l(s,{code:u.invalid_type,expected:f.array,received:s.parsedType}),h;if(s.data.length<this._def.items.length)return l(s,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),h;!this._def.rest&&s.data.length>this._def.items.length&&(l(s,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let a=[...s.data].map((i,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new C(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>k.mergeArray(t,i)):k.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};$.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new $({items:r,typeName:m.ZodTuple,rest:null,...y(e)})};Se=class r extends _{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 l(s,{code:u.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 C(s,o,s.path,o)),value:i._parse(new C(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?k.mergeObjectAsync(t,n):k.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof _?new r({keyType:e,valueType:t,typeName:m.ZodRecord,...y(s)}):new r({keyType:V.create(),valueType:e,typeName:m.ZodRecord,...y(t)})}},fe=class extends _{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 l(s,{code:u.invalid_type,expected:f.map,received:s.parsedType}),h;let n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,c],d)=>({key:n._parse(new C(s,o,s.path,[d,"key"])),value:a._parse(new C(s,c,s.path,[d,"value"]))}));if(s.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let c of i){let d=await c.key,g=await c.value;if(d.status==="aborted"||g.status==="aborted")return h;(d.status==="dirty"||g.status==="dirty")&&t.dirty(),o.set(d.value,g.value)}return{status:t.value,value:o}})}else{let o=new Map;for(let c of i){let d=c.key,g=c.value;if(d.status==="aborted"||g.status==="aborted")return h;(d.status==="dirty"||g.status==="dirty")&&t.dirty(),o.set(d.value,g.value)}return{status:t.value,value:o}}}};fe.create=(r,e,t)=>new fe({valueType:e,keyType:r,typeName:m.ZodMap,...y(t)});pe=class r extends _{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.set)return l(s,{code:u.invalid_type,expected:f.set,received:s.parsedType}),h;let n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(l(s,{code:u.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&&(l(s,{code:u.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(c){let d=new Set;for(let g of c){if(g.status==="aborted")return h;g.status==="dirty"&&t.dirty(),d.add(g.value)}return{status:t.value,value:d}}let o=[...s.data.values()].map((c,d)=>a._parse(new C(s,c,s.path,d)));return s.common.async?Promise.all(o).then(c=>i(c)):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)}};pe.create=(r,e)=>new pe({valueType:r,minSize:null,maxSize:null,typeName:m.ZodSet,...y(e)});Ce=class r extends _{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return l(t,{code:u.invalid_type,expected:f.function,received:t.parsedType}),h;function s(o,c){return _e({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,oe(),j].filter(d=>!!d),issueData:{code:u.invalid_arguments,argumentsError:c}})}function n(o,c){return _e({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,oe(),j].filter(d=>!!d),issueData:{code:u.invalid_return_type,returnTypeError:c}})}let a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof K){let o=this;return b(async function(...c){let d=new w([]),g=await o._def.args.parseAsync(c,a).catch(Oe=>{throw d.addIssue(s(c,Oe)),d}),E=await Reflect.apply(i,this,g);return await o._def.returns._def.type.parseAsync(E,a).catch(Oe=>{throw d.addIssue(n(E,Oe)),d})})}else{let o=this;return b(function(...c){let d=o._def.args.safeParse(c,a);if(!d.success)throw new w([s(c,d.error)]);let g=Reflect.apply(i,this,d.data),E=o._def.returns.safeParse(g,a);if(!E.success)throw new w([n(g,E.error)]);return E.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:$.create(e).rest(P.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||$.create([]).rest(P.create()),returns:t||P.create(),typeName:m.ZodFunction,...y(s)})}},ee=class extends _{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})}};ee.create=(r,e)=>new ee({getter:r,typeName:m.ZodLazy,...y(e)});te=class extends _{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return l(t,{received:t.data,code:u.invalid_literal,expected:this._def.value}),h}return{status:"valid",value:e.data}}get value(){return this._def.value}};te.create=(r,e)=>new te({value:r,typeName:m.ZodLiteral,...y(e)});re=class r extends _{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),s=this._def.values;return l(t,{expected:v.joinValues(s),received:t.parsedType,code:u.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 l(t,{received:t.data,code:u.invalid_enum_value,options:s}),h}return b(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})}};re.create=at;se=class extends _{_parse(e){let t=v.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==f.string&&s.parsedType!==f.number){let n=v.objectValues(t);return l(s,{expected:v.joinValues(n),received:s.parsedType,code:u.invalid_type}),h}if(this._cache||(this._cache=new Set(v.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let n=v.objectValues(t);return l(s,{received:s.data,code:u.invalid_enum_value,options:n}),h}return b(e.data)}get enum(){return this._def.values}};se.create=(r,e)=>new se({values:r,typeName:m.ZodNativeEnum,...y(e)});K=class extends _{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return l(t,{code:u.invalid_type,expected:f.promise,received:t.parsedType}),h;let s=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return b(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}};K.create=(r,e)=>new K({type:r,typeName:m.ZodPromise,...y(e)});R=class extends _{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=>{l(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 c=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return c.status==="aborted"?h:c.status==="dirty"?U(c.value):t.value==="dirty"?U(c.value):c});{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"?U(o.value):t.value==="dirty"?U(o.value):o}}if(n.type==="refinement"){let i=o=>{let c=n.refinement(o,a);if(s.common.async)return Promise.resolve(c);if(c 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(!L(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=>L(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):h);v.assertNever(n)}};R.create=(r,e,t)=>new R({schema:r,typeName:m.ZodEffects,effect:e,...y(t)});R.createWithPreprocess=(r,e,t)=>new R({schema:e,effect:{type:"preprocess",transform:r},typeName:m.ZodEffects,...y(t)});S=class extends _{_parse(e){return this._getType(e)===f.undefined?b(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};S.create=(r,e)=>new S({innerType:r,typeName:m.ZodOptional,...y(e)});Z=class extends _{_parse(e){return this._getType(e)===f.null?b(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Z.create=(r,e)=>new Z({innerType:r,typeName:m.ZodNullable,...y(e)});ne=class extends _{_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}};ne.create=(r,e)=>new ne({innerType:r,typeName:m.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...y(e)});ae=class extends _{_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 ce(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new w(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new w(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};ae.create=(r,e)=>new ae({innerType:r,typeName:m.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...y(e)});he=class extends _{_parse(e){if(this._getType(e)!==f.nan){let s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:f.nan,received:s.parsedType}),h}return{status:"valid",value:e.data}}};he.create=r=>new he({typeName:m.ZodNaN,...y(r)});hr=Symbol("zod_brand"),ve=class extends _{_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}},xe=class r extends _{_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(),U(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})}},ie=class extends _{_parse(e){let t=this._def.innerType._parse(e),s=n=>(L(n)&&(n.value=Object.freeze(n.value)),n);return ce(t)?t.then(n=>s(n)):s(t)}unwrap(){return this._def.innerType}};ie.create=(r,e)=>new ie({innerType:r,typeName:m.ZodReadonly,...y(e)});mr={object:T.lazycreate};(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={}));gr=(r,e={message:`Input not instance of ${r.name}`})=>it(t=>t instanceof r,e),ot=V.create,ct=H.create,yr=he.create,_r=W.create,ut=Y.create,vr=q.create,xr=de.create,kr=J.create,br=G.create,Er=F.create,wr=P.create,Tr=D.create,Ar=le.create,Sr=M.create,Cr=T.create,Rr=T.strictCreate,Or=X.create,Dr=Ae.create,Nr=Q.create,Ir=$.create,$r=Se.create,Zr=fe.create,jr=pe.create,zr=Ce.create,Pr=ee.create,Mr=te.create,Lr=re.create,Vr=se.create,Fr=K.create,Kr=R.create,Br=S.create,Ur=Z.create,Hr=R.createWithPreprocess,Wr=xe.create,Yr=()=>ot().optional(),qr=()=>ct().optional(),Jr=()=>ut().optional(),Gr={string:(r=>V.create({...r,coerce:!0})),number:(r=>H.create({...r,coerce:!0})),boolean:(r=>Y.create({...r,coerce:!0})),bigint:(r=>W.create({...r,coerce:!0})),date:(r=>q.create({...r,coerce:!0}))},Xr=h});var O={};Ve(O,{BRAND:()=>hr,DIRTY:()=>U,EMPTY_PATH:()=>Ht,INVALID:()=>h,NEVER:()=>Xr,OK:()=>b,ParseStatus:()=>k,Schema:()=>_,ZodAny:()=>F,ZodArray:()=>M,ZodBigInt:()=>W,ZodBoolean:()=>Y,ZodBranded:()=>ve,ZodCatch:()=>ae,ZodDate:()=>q,ZodDefault:()=>ne,ZodDiscriminatedUnion:()=>Ae,ZodEffects:()=>R,ZodEnum:()=>re,ZodError:()=>w,ZodFirstPartyTypeKind:()=>m,ZodFunction:()=>Ce,ZodIntersection:()=>Q,ZodIssueCode:()=>u,ZodLazy:()=>ee,ZodLiteral:()=>te,ZodMap:()=>fe,ZodNaN:()=>he,ZodNativeEnum:()=>se,ZodNever:()=>D,ZodNull:()=>G,ZodNullable:()=>Z,ZodNumber:()=>H,ZodObject:()=>T,ZodOptional:()=>S,ZodParsedType:()=>f,ZodPipeline:()=>xe,ZodPromise:()=>K,ZodReadonly:()=>ie,ZodRecord:()=>Se,ZodSchema:()=>_,ZodSet:()=>pe,ZodString:()=>V,ZodSymbol:()=>de,ZodTransformer:()=>R,ZodTuple:()=>$,ZodType:()=>_,ZodUndefined:()=>J,ZodUnion:()=>X,ZodUnknown:()=>P,ZodVoid:()=>le,addIssueToContext:()=>l,any:()=>Er,array:()=>Sr,bigint:()=>_r,boolean:()=>ut,coerce:()=>Gr,custom:()=>it,date:()=>vr,datetimeRegex:()=>nt,defaultErrorMap:()=>j,discriminatedUnion:()=>Dr,effect:()=>Kr,enum:()=>Lr,function:()=>zr,getErrorMap:()=>oe,getParsedType:()=>I,instanceof:()=>gr,intersection:()=>Nr,isAborted:()=>we,isAsync:()=>ce,isDirty:()=>Te,isValid:()=>L,late:()=>mr,lazy:()=>Pr,literal:()=>Mr,makeIssue:()=>_e,map:()=>Zr,nan:()=>yr,nativeEnum:()=>Vr,never:()=>Tr,null:()=>br,nullable:()=>Ur,number:()=>ct,object:()=>Cr,objectUtil:()=>Ne,oboolean:()=>Jr,onumber:()=>qr,optional:()=>Br,ostring:()=>Yr,pipeline:()=>Wr,preprocess:()=>Hr,promise:()=>Fr,quotelessJson:()=>Kt,record:()=>$r,set:()=>jr,setErrorMap:()=>Ut,strictObject:()=>Rr,string:()=>ot,symbol:()=>xr,transformer:()=>Kr,tuple:()=>Ir,undefined:()=>kr,union:()=>Or,unknown:()=>wr,util:()=>v,void:()=>Ar});var ze=A(()=>{Ee();$e();Xe();ye();dt();be()});var lt=A(()=>{ze();ze()});var Qr,es,me,ft=A(()=>{"use strict";lt();Qr=O.enum(["normal","compact","minimal"]),es=O.enum(["off","light","balanced","max"]),me=O.object({enabled:O.boolean().default(!0),telemetryOptIn:O.boolean().default(!0),outputVerbosity:Qr.default("compact"),reducer:es.default("off"),filters:O.object({enableAll:O.boolean().default(!0),disabled:O.array(O.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})})});var kt={};Ve(kt,{clearSettingsCache:()=>is,loadSettingsCache:()=>Re,saveSettingsCache:()=>xt,updateSettingsCache:()=>as});import{readFile as gt,writeFile as yt,mkdir as _t,chmod as ts,rm as ke,rename as vt,readdir as rs}from"node:fs/promises";import{randomUUID as ss}from"node:crypto";import{join as ge}from"node:path";import{setTimeout as pt}from"node:timers/promises";async function Re(){let r=null;try{let e=JSON.parse(await gt(ge(x(),Pe),"utf8"));typeof e=="object"&&e!==null&&!Array.isArray(e)&&(r=e)}catch{}return r?me.parse({...ht,...r}):ht}async function xt(r){await _t(x(),{recursive:!0,mode:448});let e=ge(x(),Pe),t=`${e}.tmp-${process.pid}-${process.hrtime.bigint()}`;await yt(t,JSON.stringify(r,null,2),{mode:384});try{await ts(t,384),await vt(t,e)}catch(s){try{await ke(t,{force:!0})}catch{}throw s}}async function mt(r){let e=[];for(let t of await rs(r)){let s=/^([1-9]\d*)-[0-9a-f-]{36}\.json$/.exec(t);if(!s)continue;let n=ge(r,t);try{process.kill(Number(s[1]),0)}catch(a){let i=a.code;if(i==="ESRCH"){await ke(n,{force:!0});continue}if(i!=="EPERM")throw a}try{let a=JSON.parse(await gt(n,"utf8"));if(!Number.isSafeInteger(a)||a<0)throw new Error("Invalid local settings lock");e.push({id:t,ticket:a})}catch(a){if(a.code!=="ENOENT")throw a}}return e}async function as(r){let e=ns.parse(r),t=ge(x(),"settings-cache-locks");await _t(t,{recursive:!0,mode:448});let s=`${process.pid}-${ss()}.json`,n=ge(t,s),a=`${n}.tmp`,i=performance.now()+3e3,o=async c=>{for(await yt(a,String(c),{mode:384});;)try{await vt(a,n);return}catch(d){let g=d.code;if(process.platform!=="win32"||g!=="EPERM"&&g!=="EBUSY"||performance.now()>=i)throw d;await pt(10)}};try{await o(0);let c=Math.max(0,...(await mt(t)).map(d=>d.ticket))+1;if(!Number.isSafeInteger(c))throw new Error("Invalid local settings lock");for(await o(c);;){if(!(await mt(t)).some(g=>g.id!==s&&(g.ticket===0||g.ticket<c||g.ticket===c&&g.id<s))){let g=await Re(),E=me.parse({...g,...e,filters:{...g.filters,...e.filters}});return await xt(E),E}if(performance.now()>=i)throw new Error("Timed out waiting for local settings lock after 3 seconds; another process may still be updating settings");await pt(10)}}finally{await Promise.all([ke(n,{force:!0}),ke(a,{force:!0})])}}async function is(){try{await ke(ge(x(),Pe),{force:!0})}catch{}}var Pe,ht,ns,Me=A(()=>{"use strict";ft();B();Pe="settings-cache.json",ht=me.parse({}),ns=me.partial().extend({filters:me.shape.filters.removeDefault().partial().optional()})});function Fe(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=c=>{t.push(Buffer.isBuffer(c)?c:Buffer.from(c))},o=setTimeout(a,r);s.on("data",i).once("end",a).once("error",a),s.resume()})}import{realpathSync as Ke}from"node:fs";import{fileURLToPath as Ot,pathToFileURL as Dt}from"node:url";var Be=null;function Ue(r,e,t){if(t!==void 0&&Be===t)return!0;if(Be!==null||!r)return!1;if(e===Dt(r).href)return!0;try{return Ke(r)===Ke(Ot(e))}catch{return!1}}B();import{appendFileSync as Us,mkdirSync as Hs,readFileSync as $t,writeFileSync as Ws,renameSync as Ys,statSync as Zt,readdirSync as jt,rmSync as zt,chmodSync as qs}from"node:fs";import{join as De}from"node:path";var N="[tkr: secret masked]",Ls=[[/(-----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${N}`],[/(?<![A-Za-z0-9_])(gh[pousr])_[A-Za-z0-9]{36,255}(?![A-Za-z0-9])/g,`$1_${N}`],[/(?<![A-Za-z0-9_])github_pat_[A-Za-z0-9_]{22,255}/g,`github_pat_${N}`],[/(?<![A-Za-z0-9_])npm_[A-Za-z0-9]{36}(?![A-Za-z0-9])/g,`npm_${N}`],[/(?<![A-Z0-9])(AKIA|ASIA)[A-Z0-9]{16}(?![A-Z0-9])/g,`$1${N}`],[/(?<![A-Za-z0-9])(xox[abpors]-)[A-Za-z0-9-]{10,}/g,`$1${N}`],[/(?<![A-Za-z0-9])((?:sk|rk)_live_)[A-Za-z0-9]{16,}/g,`$1${N}`],[/(?<![A-Za-z0-9_-])(sk-(?:ant-|proj-))[A-Za-z0-9_-]{20,}/g,`$1${N}`],[/(authorization["']?\s*[:=]\s*["']?bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi,`$1${N}`],[/(?<![A-Za-z0-9+.-])([a-zA-Z][a-zA-Z0-9+.-]{0,31}:\/\/[^\s:/@]*:)[^\s@/]+(@[^\s@/]+)/g,`$1${N}$2`]];var Qs=96*1024;var Pt=168*3600*1e3;function He(){return De(x(),"sessions")}function Mt(r){let e=r.replace(/[^A-Za-z0-9._-]/g,"-").replace(/\.\./g,"-").slice(0,80)||"default";return De(He(),`${e}.jsonl`)}function We(r){try{let e=$t(Mt(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 Ye(){try{let r=He(),e=Date.now();for(let t of jt(r)){let s=De(r,t);try{e-Zt(s).mtimeMs>Pt&&zt(s,{force:!0})}catch{}}}catch{}}function qe(r){if(r.length===0)return"";let e=new Map,t=[],s=[];for(let c of r)c.tool==="Read"?e.set(c.target,(e.get(c.target)??0)+1):c.tool==="Grep"||c.tool==="Glob"?t.includes(c.target)||t.push(c.target):c.tool==="Bash"&&s.push({target:c.target,fail:c.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[c,d]of a)n.push(d>1?` ${c} \xD7${d}`:` ${c}`)}t.length>0&&n.push(`Searches: ${t.slice(-5).join(", ")}`);let i=new Set,o=[];for(let c=s.length-1;c>=0&&o.length<8;c--){let d=s[c];i.has(d.target)||(i.add(d.target),o.unshift(d))}if(o.length>0){n.push("Recent commands:");for(let c of o)n.push(c.fail?` ${c.target} \u2717 failed`:` ${c.target}`)}return n.push("Originals of trimmed outputs stay recoverable: tkr restore <hash>."),n.slice(0,30).join(`
4
4
  `)}B();import{appendFileSync as sn,chmodSync as nn,mkdirSync as an,readFileSync as on,rmSync as Lt,statSync as cn}from"node:fs";import{join as Vt}from"node:path";var fn=256*1024;function Ft(r){let e=r.replace(/[^A-Za-z0-9._-]/g,"-").replace(/\.\./g,"-").slice(0,80)||"default";return Vt(x(),"sessions",`${e}.seen`)}function Je(r){try{Lt(Ft(r),{force:!0})}catch{}}B();Me();import{existsSync as Tt,mkdirSync as ms,writeFileSync as gs}from"node:fs";import{join as ys}from"node:path";B();import{existsSync as os,mkdirSync as qn,rmSync as Jn,writeFileSync as Gn}from"node:fs";import{join as cs}from"node:path";var us=new Set(["0","off","false","no"]);var ea=["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, the plugin version and how it was installed (npm, Homebrew, Claude Code...), nothing that describes your machine: no computer name, OS, hardware or user name. Command contents and output are never sent.","Usage stats (command names, token counts and install health counts) are sent only while they are on, to spot when compression gets worse and fix it before it reaches everyone. Check with: tkr telemetry status.","Turn all network access off: tkr network off. Usage stats only: tkr telemetry off."].join(`
5
- `);function ds(){return cs(x(),"network-off")}function ls(){let r=process.env.TOKMIZER_NETWORK;return r!==void 0&&us.has(r.trim().toLowerCase())}function bt(){return ls()?!1:!os(ds())}import{createRequire as fs}from"node:module";var ps=fs(import.meta.url);function hs(){let r="1.1.4";if(r)return r;for(let e of["../package.json","../../package.json"])try{let t=ps(e).version;if(typeof t=="string"&&t)return t}catch{}return"0.0.0"}var Et=hs();var _s="telemetry-notice-shown";var vs="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 wt(){return ys(x(),_s)}function xs(r,e){if(Tt(r))return!1;try{ms(x(),{recursive:!0,mode:448}),gs(r,e,{mode:384})}catch{return!1}return!0}async function At(){return!bt()||Tt(wt())||!(await Re()).telemetryOptIn?null:xs(wt(),`${Et} ${Date.now()}`)?vs:null}B();import{existsSync as ks,mkdirSync as fa,rmSync as bs,writeFileSync as pa}from"node:fs";import{join as Es}from"node:path";var ws="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 St(){return Es(x(),"codex-hook-notice")}function Ct(){if(!ks(St()))return null;try{bs(St())}catch{return null}return ws}async function Ts(r){if(r.source!=="compact"&&r.source!=="resume"||!r.session_id)return null;let e=We(r.session_id);return qe(e)||null}async function As(){let r=await Fe();r||process.exit(0);let e;try{e=JSON.parse(r)}catch{process.exit(0)}let t=[await At().catch(()=>null),Ct()].filter(n=>n!==null),s=Ss(await Cs(e),t.length?t.join(`
5
+ `);function ds(){return cs(x(),"network-off")}function ls(){let r=process.env.TOKMIZER_NETWORK;return r!==void 0&&us.has(r.trim().toLowerCase())}function bt(){return ls()?!1:!os(ds())}import{createRequire as fs}from"node:module";var ps=fs(import.meta.url);function hs(){let r="1.1.5";if(r)return r;for(let e of["../package.json","../../package.json"])try{let t=ps(e).version;if(typeof t=="string"&&t)return t}catch{}return"0.0.0"}var Et=hs();var _s="telemetry-notice-shown";var vs="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 wt(){return ys(x(),_s)}function xs(r,e){if(Tt(r))return!1;try{ms(x(),{recursive:!0,mode:448}),gs(r,e,{mode:384})}catch{return!1}return!0}async function At(){return!bt()||Tt(wt())||!(await Re()).telemetryOptIn?null:xs(wt(),`${Et} ${Date.now()}`)?vs:null}B();import{existsSync as ks,mkdirSync as fa,rmSync as bs,writeFileSync as pa}from"node:fs";import{join as Es}from"node:path";var ws="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 St(){return Es(x(),"codex-hook-notice")}function Ct(){if(!ks(St()))return null;try{bs(St())}catch{return null}return ws}async function Ts(r){if(r.source!=="compact"&&r.source!=="resume"||!r.session_id)return null;let e=We(r.session_id);return qe(e)||null}async function As(){let r=await Fe();r||process.exit(0);let e;try{e=JSON.parse(r)}catch{process.exit(0)}let t=[await At().catch(()=>null),Ct()].filter(n=>n!==null),s=Ss(await Cs(e),t.length?t.join(`
6
6
  `):null);s&&process.stdout.write(s)}function Ss(r,e){return e?JSON.stringify({systemMessage:e,...r?{hookSpecificOutput:{hookEventName:"SessionStart",additionalContext:r}}:{}}):r}async function Cs(r){try{Ye()}catch{}r.session_id&&r.source!=="startup"&&Je(r.session_id);let e=await Ts(r),t=r.source!=="resume"&&await Os()?Rs:null;return[e,t].filter(s=>s!==null).join(`
7
7
 
8
8
  `)||null}var Rs="Tokmizer shortens long command output. A line `[tkr restore <id>]` marks a cut: run `tkr restore <id>` (or add `--lines a:b`) to read the full text instead of re-running the command.";async function Os(){try{let{loadSettingsCache:r}=await Promise.resolve().then(()=>(Me(),kt));return(await r()).enabled}catch{return!1}}var Ds=process.argv[1]??"";Ue(Ds,import.meta.url,"session-recap")&&As().catch(()=>{process.exit(0)});export{Rs as RESTORE_NOTE,Cs as handleSessionStart,Ts as recapForSessionStart,Ss as sessionStartOutput};