@tokmizer/plugin 0.5.11 → 0.5.13

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,21 +1,21 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __tkrCreateRequire } from "node:module"; const require = __tkrCreateRequire(import.meta.url);
3
- var Rn=Object.defineProperty;var k=(t,e)=>()=>(t&&(e=t(t=0)),e);var In=(t,e)=>{for(var r in e)Rn(t,r,{get:e[r],enumerable:!0})};var b,_t,f,B,je=k(()=>{(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{let i={};for(let a of s)i[a]=a;return i},t.getValidEnumValues=s=>{let i=t.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(let o of i)a[o]=s[o];return t.objectValues(a)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},t.find=(s,i)=>{for(let a of s)if(i(a))return a},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}t.joinValues=n,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(b||(b={}));(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(_t||(_t={}));f=b.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),B=t=>{switch(typeof t){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(t)?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(t)?f.array:t===null?f.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?f.promise:typeof Map<"u"&&t instanceof Map?f.map:typeof Set<"u"&&t instanceof Set?f.set:typeof Date<"u"&&t instanceof Date?f.date:f.object;default:return f.unknown}}});var u,Cn,D,Je=k(()=>{je();u=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"]),Cn=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),D=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(i){return i.message},n={_errors:[]},s=i=>{for(let a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)n._errors.push(r(a));else{let o=n,c=0;for(;c<a.path.length;){let l=a.path[c];c===a.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(a))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,b.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];r[i]=r[i]||[],r[i].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};D.create=t=>new D(t)});var On,W,vt=k(()=>{Je();je();On=(t,e)=>{let r;switch(t.code){case u.invalid_type:t.received===f.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case u.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,b.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:r=`Unrecognized key(s) in object: ${b.joinValues(t.keys,", ")}`;break;case u.invalid_union:r="Invalid input";break;case u.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${b.joinValues(t.options)}`;break;case u.invalid_enum_value:r=`Invalid enum value. Expected ${b.joinValues(t.options)}, received '${t.received}'`;break;case u.invalid_arguments:r="Invalid function arguments";break;case u.invalid_return_type:r="Invalid function return type";break;case u.invalid_date:r="Invalid date";break;case u.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:b.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case u.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case u.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case u.custom:r="Invalid input";break;case u.invalid_intersection_types:r="Intersection results could not be merged";break;case u.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case u.not_finite:r="Number must be finite";break;default:r=e.defaultError,b.assertNever(t)}return{message:r}},W=On});function Dn(t){Ut=t}function ke(){return Ut}var Ut,Xe=k(()=>{vt();Ut=W});function d(t,e){let r=ke(),n=ze({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===W?void 0:W].filter(s=>!!s)});t.common.issues.push(n)}var ze,Pn,I,g,ie,C,Qe,et,X,Ee,xt=k(()=>{Xe();vt();ze=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,i=[...r,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let o="",c=n.filter(l=>!!l).slice().reverse();for(let l of c)o=l(a,{data:e,defaultError:o}).message;return{...s,path:i,message:o}},Pn=[];I=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return g;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r){let i=await s.key,a=await s.value;n.push({key:i,value:a})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return g;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}},g=Object.freeze({status:"aborted"}),ie=t=>({status:"dirty",value:t}),C=t=>({status:"valid",value:t}),Qe=t=>t.status==="aborted",et=t=>t.status==="dirty",X=t=>t.status==="valid",Ee=t=>typeof Promise<"u"&&t instanceof Promise});var Vt=k(()=>{});var m,Ht=k(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(m||(m={}))});function v(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,o)=>{let{message:c}=t;return a.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??n??o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:c??r??o.defaultError}},description:s}}function qt(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function Yn(t){return new RegExp(`^${qt(t)}$`)}function Yt(t){let e=`${Wt}T${qt(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function Jn(t,e){return!!((e==="v4"||!e)&&Un.test(t)||(e==="v6"||!e)&&Hn.test(t))}function Xn(t,e){if(!jn.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Qn(t,e){return!!((e==="v4"||!e)&&Vn.test(t)||(e==="v6"||!e)&&Kn.test(t))}function es(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,i=Number.parseInt(t.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return i%a/10**s}function Se(t){if(t instanceof P){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=$.create(Se(n))}return new P({...t._def,shape:()=>e})}else return t instanceof J?new J({...t._def,type:Se(t.element)}):t instanceof $?$.create(Se(t.unwrap())):t instanceof V?V.create(Se(t.unwrap())):t instanceof U?U.create(t.items.map(e=>Se(e))):t}function wt(t,e){let r=B(t),n=B(e);if(t===e)return{valid:!0,data:t};if(r===f.object&&n===f.object){let s=b.objectKeys(e),i=b.objectKeys(t).filter(o=>s.indexOf(o)!==-1),a={...t,...e};for(let o of i){let c=wt(t[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(r===f.array&&n===f.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let a=t[i],o=e[i],c=wt(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===f.date&&n===f.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function Jt(t,e){return new ge({values:t,typeName:_.ZodEnum,...v(e)})}function Gt(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function Xt(t,e={},r){return t?ee.create().superRefine((n,s)=>{let i=t(n);if(i instanceof Promise)return i.then(a=>{if(!a){let o=Gt(e,n),c=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:c})}});if(!i){let a=Gt(e,n),o=a.fatal??r??!0;s.addIssue({code:"custom",...a,fatal:o})}}):ee.create()}var M,Kt,x,Nn,$n,Mn,Ln,Fn,jn,zn,Zn,Bn,bt,Un,Vn,Hn,Kn,Gn,Wn,Wt,qn,Q,ae,oe,ce,le,Te,ue,de,ee,Y,j,Ae,J,P,fe,q,tt,pe,U,rt,Re,Ie,nt,me,he,ge,ye,te,L,$,V,_e,ve,Ce,ts,Ze,Be,xe,rs,_,ns,Qt,er,ss,is,tr,as,os,cs,ls,us,ds,fs,ps,ms,hs,gs,ys,_s,vs,xs,bs,ws,ks,Es,Ss,Ts,As,Rs,Is,Cs,Os,Ds,Ps,Ns,$s,Ms,Ls,Fs,js,rr=k(()=>{Je();Xe();Ht();xt();je();M=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,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}},Kt=(t,e)=>{if(X(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new D(t.common.issues);return this._error=r,this._error}}};x=class{get description(){return this._def.description}_getType(e){return B(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:B(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new I,ctx:{common:e.parent.common,data:e.data,parsedType:B(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Ee(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:B(e)},s=this._parseSync({data:e,path:n.path,parent:n});return Kt(n,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:B(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return X(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>X(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:B(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(Ee(s)?s:Promise.resolve(s));return Kt(n,i)}refine(e,r){let n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,i)=>{let a=e(s),o=()=>i.addIssue({code:u.custom,...n(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new L({schema:this,typeName:_.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return $.create(this,this._def)}nullable(){return V.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 L({...v(this._def),schema:this,typeName:_.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new _e({...v(this._def),innerType:this,defaultValue:r,typeName:_.ZodDefault})}brand(){return new Ze({typeName:_.ZodBranded,type:this,...v(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new ve({...v(this._def),innerType:this,catchValue:r,typeName:_.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Be.create(this,e)}readonly(){return xe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Nn=/^c[^\s-]{8,}$/i,$n=/^[0-9a-z]+$/,Mn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ln=/^[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,Fn=/^[a-z0-9_-]{21}$/i,jn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,zn=/^[-+]?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)?)??$/,Zn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Bn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Un=/^(?:(?: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])$/,Vn=/^(?:(?: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])$/,Hn=/^(([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]))$/,Kn=/^(([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])$/,Gn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Wn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Wt="((\\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])))",qn=new RegExp(`^${Wt}$`);Q=class t extends x{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){let i=this._getOrReturnCtx(e);return d(i,{code:u.invalid_type,expected:f.string,received:i.parsedType}),g}let n=new I,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?d(s,{code:u.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&d(s,{code:u.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Zn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"email",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")bt||(bt=new RegExp(Bn,"u")),bt.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"emoji",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")Ln.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"uuid",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")Fn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"nanoid",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")Nn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"cuid",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")$n.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"cuid2",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")Mn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"ulid",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),d(s,{validation:"url",code:u.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"regex",code:u.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?Yt(i).test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?qn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?Yn(i).test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{code:u.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?zn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"duration",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?Jn(e.data,i.version)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"ip",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?Xn(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"jwt",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?Qn(e.data,i.version)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"cidr",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?Gn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"base64",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?Wn.test(e.data)||(s=this._getOrReturnCtx(e,s),d(s,{validation:"base64url",code:u.invalid_string,message:i.message}),n.dirty()):b.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:u.invalid_string,...m.errToObj(n)})}_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,r){return this._addCheck({kind:"regex",regex:e,...m.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...m.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...m.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...m.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...m.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...m.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...m.errToObj(r)})}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 r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Q.create=t=>new Q({checks:[],typeName:_.ZodString,coerce:t?.coerce??!1,...v(t)});ae=class t extends x{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 i=this._getOrReturnCtx(e);return d(i,{code:u.invalid_type,expected:f.number,received:i.parsedType}),g}let n,s=new I;for(let i of this._def.checks)i.kind==="int"?b.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:u.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?es(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:u.not_finite,message:i.message}),s.dirty()):b.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,m.toString(r))}gt(e,r){return this.setLimit("min",e,!1,m.toString(r))}lte(e,r){return this.setLimit("max",e,!0,m.toString(r))}lt(e,r){return this.setLimit("max",e,!1,m.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,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,r){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(r)})}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 r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&b.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};ae.create=t=>new ae({checks:[],typeName:_.ZodNumber,coerce:t?.coerce||!1,...v(t)});oe=class t extends x{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 n,s=new I;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),d(n,{code:u.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):b.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return d(r,{code:u.invalid_type,expected:f.bigint,received:r.parsedType}),g}gte(e,r){return this.setLimit("min",e,!0,m.toString(r))}gt(e,r){return this.setLimit("min",e,!1,m.toString(r))}lte(e,r){return this.setLimit("max",e,!0,m.toString(r))}lt(e,r){return this.setLimit("max",e,!1,m.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,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,r){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};oe.create=t=>new oe({checks:[],typeName:_.ZodBigInt,coerce:t?.coerce??!1,...v(t)});ce=class extends x{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){let n=this._getOrReturnCtx(e);return d(n,{code:u.invalid_type,expected:f.boolean,received:n.parsedType}),g}return C(e.data)}};ce.create=t=>new ce({typeName:_.ZodBoolean,coerce:t?.coerce||!1,...v(t)});le=class t extends x{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){let i=this._getOrReturnCtx(e);return d(i,{code:u.invalid_type,expected:f.date,received:i.parsedType}),g}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return d(i,{code:u.invalid_date}),g}let n=new I,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),d(s,{code:u.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):b.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:m.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};le.create=t=>new le({checks:[],coerce:t?.coerce||!1,typeName:_.ZodDate,...v(t)});Te=class extends x{_parse(e){if(this._getType(e)!==f.symbol){let n=this._getOrReturnCtx(e);return d(n,{code:u.invalid_type,expected:f.symbol,received:n.parsedType}),g}return C(e.data)}};Te.create=t=>new Te({typeName:_.ZodSymbol,...v(t)});ue=class extends x{_parse(e){if(this._getType(e)!==f.undefined){let n=this._getOrReturnCtx(e);return d(n,{code:u.invalid_type,expected:f.undefined,received:n.parsedType}),g}return C(e.data)}};ue.create=t=>new ue({typeName:_.ZodUndefined,...v(t)});de=class extends x{_parse(e){if(this._getType(e)!==f.null){let n=this._getOrReturnCtx(e);return d(n,{code:u.invalid_type,expected:f.null,received:n.parsedType}),g}return C(e.data)}};de.create=t=>new de({typeName:_.ZodNull,...v(t)});ee=class extends x{constructor(){super(...arguments),this._any=!0}_parse(e){return C(e.data)}};ee.create=t=>new ee({typeName:_.ZodAny,...v(t)});Y=class extends x{constructor(){super(...arguments),this._unknown=!0}_parse(e){return C(e.data)}};Y.create=t=>new Y({typeName:_.ZodUnknown,...v(t)});j=class extends x{_parse(e){let r=this._getOrReturnCtx(e);return d(r,{code:u.invalid_type,expected:f.never,received:r.parsedType}),g}};j.create=t=>new j({typeName:_.ZodNever,...v(t)});Ae=class extends x{_parse(e){if(this._getType(e)!==f.undefined){let n=this._getOrReturnCtx(e);return d(n,{code:u.invalid_type,expected:f.void,received:n.parsedType}),g}return C(e.data)}};Ae.create=t=>new Ae({typeName:_.ZodVoid,...v(t)});J=class t extends x{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==f.array)return d(r,{code:u.invalid_type,expected:f.array,received:r.parsedType}),g;if(s.exactLength!==null){let a=r.data.length>s.exactLength.value,o=r.data.length<s.exactLength.value;(a||o)&&(d(r,{code:a?u.too_big:u.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(d(r,{code:u.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(d(r,{code:u.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((a,o)=>s.type._parseAsync(new M(r,a,r.path,o)))).then(a=>I.mergeArray(n,a));let i=[...r.data].map((a,o)=>s.type._parseSync(new M(r,a,r.path,o)));return I.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:m.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:m.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:m.toString(r)}})}nonempty(e){return this.min(1,e)}};J.create=(t,e)=>new J({type:t,minLength:null,maxLength:null,exactLength:null,typeName:_.ZodArray,...v(e)});P=class t extends x{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=b.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==f.object){let l=this._getOrReturnCtx(e);return d(l,{code:u.invalid_type,expected:f.object,received:l.parsedType}),g}let{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof j&&this._def.unknownKeys==="strip"))for(let l in s.data)a.includes(l)||o.push(l);let c=[];for(let l of a){let p=i[l],y=s.data[l];c.push({key:{status:"valid",value:l},value:p._parse(new M(s,y,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof j){let l=this._def.unknownKeys;if(l==="passthrough")for(let p of o)c.push({key:{status:"valid",value:p},value:{status:"valid",value:s.data[p]}});else if(l==="strict")o.length>0&&(d(s,{code:u.unrecognized_keys,keys:o}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let p of o){let y=s.data[p];c.push({key:{status:"valid",value:p},value:l._parse(new M(s,y,s.path,p)),alwaysSet:p in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let p of c){let y=await p.key,w=await p.value;l.push({key:y,value:w,alwaysSet:p.alwaysSet})}return l}).then(l=>I.mergeObjectSync(n,l)):I.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return m.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let s=this._def.errorMap?.(r,n).message??n.defaultError;return r.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:_.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of b.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of b.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Se(this)}partial(e){let r={};for(let n of b.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of b.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof $;)i=i._def.innerType;r[n]=i}return new t({...this._def,shape:()=>r})}keyof(){return Jt(b.objectKeys(this.shape))}};P.create=(t,e)=>new P({shape:()=>t,unknownKeys:"strip",catchall:j.create(),typeName:_.ZodObject,...v(e)});P.strictCreate=(t,e)=>new P({shape:()=>t,unknownKeys:"strict",catchall:j.create(),typeName:_.ZodObject,...v(e)});P.lazycreate=(t,e)=>new P({shape:t,unknownKeys:"strip",catchall:j.create(),typeName:_.ZodObject,...v(e)});fe=class extends x{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(i){for(let o of i)if(o.result.status==="valid")return o.result;for(let o of i)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;let a=i.map(o=>new D(o.ctx.common.issues));return d(r,{code:u.invalid_union,unionErrors:a}),g}if(r.common.async)return Promise.all(n.map(async i=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(s);{let i,a=[];for(let c of n){let l={...r,common:{...r.common,issues:[]},parent:null},p=c._parseSync({data:r.data,path:r.path,parent:l});if(p.status==="valid")return p;p.status==="dirty"&&!i&&(i={result:p,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let o=a.map(c=>new D(c));return d(r,{code:u.invalid_union,unionErrors:o}),g}}get options(){return this._def.options}};fe.create=(t,e)=>new fe({options:t,typeName:_.ZodUnion,...v(e)});q=t=>t instanceof me?q(t.schema):t instanceof L?q(t.innerType()):t instanceof he?[t.value]:t instanceof ge?t.options:t instanceof ye?b.objectValues(t.enum):t instanceof _e?q(t._def.innerType):t instanceof ue?[void 0]:t instanceof de?[null]:t instanceof $?[void 0,...q(t.unwrap())]:t instanceof V?[null,...q(t.unwrap())]:t instanceof Ze||t instanceof xe?q(t.unwrap()):t instanceof ve?q(t._def.innerType):[],tt=class t extends x{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==f.object)return d(r,{code:u.invalid_type,expected:f.object,received:r.parsedType}),g;let n=this.discriminator,s=r.data[n],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(d(r,{code:u.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),g)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=new Map;for(let i of r){let a=q(i.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of a){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new t({typeName:_.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...v(n)})}};pe=class extends x{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(Qe(i)||Qe(a))return g;let o=wt(i.value,a.value);return o.valid?((et(i)||et(a))&&r.dirty(),{status:r.value,value:o.data}):(d(n,{code:u.invalid_intersection_types}),g)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};pe.create=(t,e,r)=>new pe({left:t,right:e,typeName:_.ZodIntersection,...v(r)});U=class t extends x{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.array)return d(n,{code:u.invalid_type,expected:f.array,received:n.parsedType}),g;if(n.data.length<this._def.items.length)return d(n,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;!this._def.rest&&n.data.length>this._def.items.length&&(d(n,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((a,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new M(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>I.mergeArray(r,a)):I.mergeArray(r,i)}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:_.ZodTuple,rest:null,...v(e)})};rt=class t extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.object)return d(n,{code:u.invalid_type,expected:f.object,received:n.parsedType}),g;let s=[],i=this._def.keyType,a=this._def.valueType;for(let o in n.data)s.push({key:i._parse(new M(n,o,n.path,o)),value:a._parse(new M(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?I.mergeObjectAsync(r,s):I.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof x?new t({keyType:e,valueType:r,typeName:_.ZodRecord,...v(n)}):new t({keyType:Q.create(),valueType:e,typeName:_.ZodRecord,...v(r)})}},Re=class extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.map)return d(n,{code:u.invalid_type,expected:f.map,received:n.parsedType}),g;let s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],l)=>({key:s._parse(new M(n,o,n.path,[l,"key"])),value:i._parse(new M(n,c,n.path,[l,"value"]))}));if(n.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let c of a){let l=await c.key,p=await c.value;if(l.status==="aborted"||p.status==="aborted")return g;(l.status==="dirty"||p.status==="dirty")&&r.dirty(),o.set(l.value,p.value)}return{status:r.value,value:o}})}else{let o=new Map;for(let c of a){let l=c.key,p=c.value;if(l.status==="aborted"||p.status==="aborted")return g;(l.status==="dirty"||p.status==="dirty")&&r.dirty(),o.set(l.value,p.value)}return{status:r.value,value:o}}}};Re.create=(t,e,r)=>new Re({valueType:e,keyType:t,typeName:_.ZodMap,...v(r)});Ie=class t extends x{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.set)return d(n,{code:u.invalid_type,expected:f.set,received:n.parsedType}),g;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(d(n,{code:u.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(d(n,{code:u.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function a(c){let l=new Set;for(let p of c){if(p.status==="aborted")return g;p.status==="dirty"&&r.dirty(),l.add(p.value)}return{status:r.value,value:l}}let o=[...n.data.values()].map((c,l)=>i._parse(new M(n,c,n.path,l)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,r){return new t({...this._def,minSize:{value:e,message:m.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:m.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Ie.create=(t,e)=>new Ie({valueType:t,minSize:null,maxSize:null,typeName:_.ZodSet,...v(e)});nt=class t extends x{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==f.function)return d(r,{code:u.invalid_type,expected:f.function,received:r.parsedType}),g;function n(o,c){return ze({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ke(),W].filter(l=>!!l),issueData:{code:u.invalid_arguments,argumentsError:c}})}function s(o,c){return ze({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ke(),W].filter(l=>!!l),issueData:{code:u.invalid_return_type,returnTypeError:c}})}let i={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof te){let o=this;return C(async function(...c){let l=new D([]),p=await o._def.args.parseAsync(c,i).catch(T=>{throw l.addIssue(n(c,T)),l}),y=await Reflect.apply(a,this,p);return await o._def.returns._def.type.parseAsync(y,i).catch(T=>{throw l.addIssue(s(y,T)),l})})}else{let o=this;return C(function(...c){let l=o._def.args.safeParse(c,i);if(!l.success)throw new D([n(c,l.error)]);let p=Reflect.apply(a,this,l.data),y=o._def.returns.safeParse(p,i);if(!y.success)throw new D([s(p,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,r,n){return new t({args:e||U.create([]).rest(Y.create()),returns:r||Y.create(),typeName:_.ZodFunction,...v(n)})}},me=class extends x{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};me.create=(t,e)=>new me({getter:t,typeName:_.ZodLazy,...v(e)});he=class extends x{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return d(r,{received:r.data,code:u.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:e.data}}get value(){return this._def.value}};he.create=(t,e)=>new he({value:t,typeName:_.ZodLiteral,...v(e)});ge=class t extends x{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return d(r,{expected:b.joinValues(n),received:r.parsedType,code:u.invalid_type}),g}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return d(r,{received:r.data,code:u.invalid_enum_value,options:n}),g}return C(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};ge.create=Jt;ye=class extends x{_parse(e){let r=b.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){let s=b.objectValues(r);return d(n,{expected:b.joinValues(s),received:n.parsedType,code:u.invalid_type}),g}if(this._cache||(this._cache=new Set(b.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=b.objectValues(r);return d(n,{received:n.data,code:u.invalid_enum_value,options:s}),g}return C(e.data)}get enum(){return this._def.values}};ye.create=(t,e)=>new ye({values:t,typeName:_.ZodNativeEnum,...v(e)});te=class extends x{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==f.promise&&r.common.async===!1)return d(r,{code:u.invalid_type,expected:f.promise,received:r.parsedType}),g;let n=r.parsedType===f.promise?r.data:Promise.resolve(r.data);return C(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};te.create=(t,e)=>new te({type:t,typeName:_.ZodPromise,...v(e)});L=class extends x{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===_.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{d(n,a),a.fatal?r.abort():r.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let a=s.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async o=>{if(r.value==="aborted")return g;let c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?g:c.status==="dirty"?ie(c.value):r.value==="dirty"?ie(c.value):c});{if(r.value==="aborted")return g;let o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?g:o.status==="dirty"?ie(o.value):r.value==="dirty"?ie(o.value):o}}if(s.type==="refinement"){let a=o=>{let c=s.refinement(o,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?g:(o.status==="dirty"&&r.dirty(),a(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?g:(o.status==="dirty"&&r.dirty(),a(o.value).then(()=>({status:r.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!X(a))return g;let o=s.transform(a.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>X(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:r.value,value:o})):g);b.assertNever(s)}};L.create=(t,e,r)=>new L({schema:t,typeName:_.ZodEffects,effect:e,...v(r)});L.createWithPreprocess=(t,e,r)=>new L({schema:e,effect:{type:"preprocess",transform:t},typeName:_.ZodEffects,...v(r)});$=class extends x{_parse(e){return this._getType(e)===f.undefined?C(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};$.create=(t,e)=>new $({innerType:t,typeName:_.ZodOptional,...v(e)});V=class extends x{_parse(e){return this._getType(e)===f.null?C(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};V.create=(t,e)=>new V({innerType:t,typeName:_.ZodNullable,...v(e)});_e=class extends x{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===f.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};_e.create=(t,e)=>new _e({innerType:t,typeName:_.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...v(e)});ve=class extends x{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ee(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new D(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new D(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ve.create=(t,e)=>new ve({innerType:t,typeName:_.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...v(e)});Ce=class extends x{_parse(e){if(this._getType(e)!==f.nan){let n=this._getOrReturnCtx(e);return d(n,{code:u.invalid_type,expected:f.nan,received:n.parsedType}),g}return{status:"valid",value:e.data}}};Ce.create=t=>new Ce({typeName:_.ZodNaN,...v(t)});ts=Symbol("zod_brand"),Ze=class extends x{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Be=class t extends x{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?g:i.status==="dirty"?(r.dirty(),ie(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?g:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:_.ZodPipeline})}},xe=class extends x{_parse(e){let r=this._def.innerType._parse(e),n=s=>(X(s)&&(s.value=Object.freeze(s.value)),s);return Ee(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};xe.create=(t,e)=>new xe({innerType:t,typeName:_.ZodReadonly,...v(e)});rs={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"})(_||(_={}));ns=(t,e={message:`Input not instance of ${t.name}`})=>Xt(r=>r instanceof t,e),Qt=Q.create,er=ae.create,ss=Ce.create,is=oe.create,tr=ce.create,as=le.create,os=Te.create,cs=ue.create,ls=de.create,us=ee.create,ds=Y.create,fs=j.create,ps=Ae.create,ms=J.create,hs=P.create,gs=P.strictCreate,ys=fe.create,_s=tt.create,vs=pe.create,xs=U.create,bs=rt.create,ws=Re.create,ks=Ie.create,Es=nt.create,Ss=me.create,Ts=he.create,As=ge.create,Rs=ye.create,Is=te.create,Cs=L.create,Os=$.create,Ds=V.create,Ps=L.createWithPreprocess,Ns=Be.create,$s=()=>Qt().optional(),Ms=()=>er().optional(),Ls=()=>tr().optional(),Fs={string:(t=>Q.create({...t,coerce:!0})),number:(t=>ae.create({...t,coerce:!0})),boolean:(t=>ce.create({...t,coerce:!0})),bigint:(t=>oe.create({...t,coerce:!0})),date:(t=>le.create({...t,coerce:!0}))},js=g});var h={};In(h,{BRAND:()=>ts,DIRTY:()=>ie,EMPTY_PATH:()=>Pn,INVALID:()=>g,NEVER:()=>js,OK:()=>C,ParseStatus:()=>I,Schema:()=>x,ZodAny:()=>ee,ZodArray:()=>J,ZodBigInt:()=>oe,ZodBoolean:()=>ce,ZodBranded:()=>Ze,ZodCatch:()=>ve,ZodDate:()=>le,ZodDefault:()=>_e,ZodDiscriminatedUnion:()=>tt,ZodEffects:()=>L,ZodEnum:()=>ge,ZodError:()=>D,ZodFirstPartyTypeKind:()=>_,ZodFunction:()=>nt,ZodIntersection:()=>pe,ZodIssueCode:()=>u,ZodLazy:()=>me,ZodLiteral:()=>he,ZodMap:()=>Re,ZodNaN:()=>Ce,ZodNativeEnum:()=>ye,ZodNever:()=>j,ZodNull:()=>de,ZodNullable:()=>V,ZodNumber:()=>ae,ZodObject:()=>P,ZodOptional:()=>$,ZodParsedType:()=>f,ZodPipeline:()=>Be,ZodPromise:()=>te,ZodReadonly:()=>xe,ZodRecord:()=>rt,ZodSchema:()=>x,ZodSet:()=>Ie,ZodString:()=>Q,ZodSymbol:()=>Te,ZodTransformer:()=>L,ZodTuple:()=>U,ZodType:()=>x,ZodUndefined:()=>ue,ZodUnion:()=>fe,ZodUnknown:()=>Y,ZodVoid:()=>Ae,addIssueToContext:()=>d,any:()=>us,array:()=>ms,bigint:()=>is,boolean:()=>tr,coerce:()=>Fs,custom:()=>Xt,date:()=>as,datetimeRegex:()=>Yt,defaultErrorMap:()=>W,discriminatedUnion:()=>_s,effect:()=>Cs,enum:()=>As,function:()=>Es,getErrorMap:()=>ke,getParsedType:()=>B,instanceof:()=>ns,intersection:()=>vs,isAborted:()=>Qe,isAsync:()=>Ee,isDirty:()=>et,isValid:()=>X,late:()=>rs,lazy:()=>Ss,literal:()=>Ts,makeIssue:()=>ze,map:()=>ws,nan:()=>ss,nativeEnum:()=>Rs,never:()=>fs,null:()=>ls,nullable:()=>Ds,number:()=>er,object:()=>hs,objectUtil:()=>_t,oboolean:()=>Ls,onumber:()=>Ms,optional:()=>Os,ostring:()=>$s,pipeline:()=>Ns,preprocess:()=>Ps,promise:()=>Is,quotelessJson:()=>Cn,record:()=>bs,set:()=>ks,setErrorMap:()=>Dn,strictObject:()=>gs,string:()=>Qt,symbol:()=>os,transformer:()=>Cs,tuple:()=>xs,undefined:()=>cs,union:()=>ys,unknown:()=>ds,util:()=>b,void:()=>ps});var kt=k(()=>{Xe();xt();Vt();je();rr();Je()});var st=k(()=>{kt();kt()});var it,Et=k(()=>{"use strict";st();it=h.object({slug:h.string().min(1).max(64),description:h.string().max(255).optional(),match_command:h.string().min(1),priority:h.number().int().default(50),strip_ansi:h.boolean().default(!1),strip_lines_matching:h.array(h.string()).default([]),truncate_lines_at:h.number().int().positive().max(1e4).optional(),max_lines:h.number().int().positive().max(1e5).optional(),transform:h.string().max(64).optional(),on_empty:h.string().max(255).optional()})});import{createHash as Ks}from"node:crypto";function z(t){let e=or.get(t);return e||(e=Ks("sha256").update(`tkr:${t}`).digest("hex").slice(0,16),or.set(t,e)),e}function at(t,e=!1){return e||!t||t.length===0?(cr??=new Set(qs.map(z)),new Set(cr)):new Set(t.map(r=>Ys.test(r)?r:z(r)))}var Gs,Ws,St,qs,Ys,or,cr,be=k(()=>{"use strict";st();Gs=h.enum(["normal","compact","minimal"]),Ws=h.enum(["off","light","balanced","max"]),St=h.object({enabled:h.boolean().default(!0),telemetryOptIn:h.boolean().default(!0),outputVerbosity:Gs.default("compact"),reducer:Ws.default("off"),filters:h.object({enableAll:h.boolean().default(!0),disabled:h.array(h.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})}),qs=["git","grep","find","ls","ps","cat","head","tail","df","du","tree","wc","read-tool","grep-tool","glob-tool","npm","docker","kubectl","curl","cargo","go-test","gh","aws","dotnet","prisma","tsc","next","jest","vitest","pytest","pip","rspec"],Ys=/^[0-9a-f]{16}$/,or=new Map;cr=null});import Tr from"node:os";import{join as ne}from"node:path";function S(){return process.env.TOKMIZER_HOME||ne(Tr.homedir(),".tokmizer")}function At(){return ne(S(),"install-id")}function Ar(){return ne(S(),"enroll-cooldown")}function Rr(){return ne(S(),"bundle-refresh.json")}function ct(){return ne(S(),"skills")}function lt(t){return ne(ct(),`${t}.md`)}function ut(){return process.env.TOKMIZER_CLAUDE_COMMANDS_DIR||ne(Tr.homedir(),".claude","commands")}function dt(t){return ne(ut(),`${t}.md`)}var K=k(()=>{"use strict"});import Oe from"node:os";import{createHash as ki,randomUUID as Ei}from"node:crypto";import{readFile as Si,writeFile as Ti,mkdir as Ai}from"node:fs/promises";async function It(){try{let r=(await Si(At(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(r))return r}catch{}await Ai(S(),{recursive:!0});let t=Ei();return await Ti(At(),t,{mode:384}),t}function Rt(t){return ki("sha256").update(t).digest("hex")}function Ri(){let t=Oe.networkInterfaces();for(let e of Object.keys(t))for(let r of t[e]??[])if(!r.internal&&r.mac&&r.mac!=="00:00:00:00:00:00")return r.mac;return"no-mac"}async function De(){let t=await It(),e=Oe.hostname(),r=Oe.platform(),n=Oe.release(),s=Oe.cpus(),i=s[0]?.model??"unknown",a=s.length,o=Rt(Ri()),c=Rt(Oe.userInfo().username),l=[e,r,n,i,String(a),o,c,t].join("|");return{fingerprint:Rt(l),installId:t,hostname:e,os:r,osVersion:n,cpuModel:i,cpuCores:a,macHash:o,usernameHash:c}}var Pe=k(()=>{"use strict";K()});import{join as Ir}from"node:path";import{mkdir as Ii,readFile as Ci,writeFile as Oi,unlink as Fc,rename as Di}from"node:fs/promises";function ft(){try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t&&t.length>0?t:"Etc/UTC"}catch{return"Etc/UTC"}}function Or(t){return t?.dir??S()}async function Ne(t){let e=Or(t);try{let r=await Ci(Ir(e,Cr),"utf8"),n=JSON.parse(r);return{...n,lastSettingsRevision:n.lastSettingsRevision??0,timeZone:n.timeZone??ft(),bonusActive:n.bonusActive??!1,...n.bonusResetAt!==void 0?{bonusResetAt:n.bonusResetAt}:{}}}catch{return null}}async function Dr(t,e){let r=Or(e);await Ii(r,{recursive:!0});let n=Ir(r,Cr),s=`${n}.tmp`;await Oi(s,JSON.stringify(t,null,2),{mode:384}),await Di(s,n)}var Cr,zc,Ve=k(()=>{"use strict";K();Cr="state.json",zc={lastSettingsRevision:0,timeZone:ft(),bonusActive:!1}});import{createRequire as Pi}from"node:module";function $i(){for(let t of["../package.json","../../package.json"])try{let e=Ni(t).version;if(typeof e=="string"&&e)return e}catch{}return"0.0.0"}var Ni,He,Ct=k(()=>{"use strict";Ni=Pi(import.meta.url);He=$i()});var Pr,Nr=k(()=>{"use strict";Pr=`-----BEGIN PUBLIC KEY-----
3
+ var Pn=Object.defineProperty;var E=(t,e)=>()=>(t&&(e=t(t=0)),e);var Nn=(t,e)=>{for(var r in e)Pn(t,r,{get:e[r],enumerable:!0})};var w,yt,p,z,Le=E(()=>{(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{let i={};for(let a of s)i[a]=a;return i},t.getValidEnumValues=s=>{let i=t.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(let o of i)a[o]=s[o];return t.objectValues(a)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let a in s)Object.prototype.hasOwnProperty.call(s,a)&&i.push(a);return i},t.find=(s,i)=>{for(let a of s)if(i(a))return a},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}t.joinValues=n,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(w||(w={}));(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(yt||(yt={}));p=w.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),z=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 u,$n,C,Xe=E(()=>{Le();u=w.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"]),$n=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),C=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(i){return i.message},n={_errors:[]},s=i=>{for(let a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)n._errors.push(r(a));else{let o=n,c=0;for(;c<a.path.length;){let l=a.path[c];c===a.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(a))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,w.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];r[i]=r[i]||[],r[i].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};C.create=t=>new C(t)});var Mn,H,_t=E(()=>{Xe();Le();Mn=(t,e)=>{let r;switch(t.code){case u.invalid_type:t.received===p.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case u.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,w.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:r=`Unrecognized key(s) in object: ${w.joinValues(t.keys,", ")}`;break;case u.invalid_union:r="Invalid input";break;case u.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${w.joinValues(t.options)}`;break;case u.invalid_enum_value:r=`Invalid enum value. Expected ${w.joinValues(t.options)}, received '${t.received}'`;break;case u.invalid_arguments:r="Invalid function arguments";break;case u.invalid_return_type:r="Invalid function return type";break;case u.invalid_date:r="Invalid date";break;case u.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:w.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case u.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case u.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case u.custom:r="Invalid input";break;case u.invalid_intersection_types:r="Intersection results could not be merged";break;case u.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case u.not_finite:r="Number must be finite";break;default:r=e.defaultError,w.assertNever(t)}return{message:r}},H=Mn});function Ln(t){Gt=t}function xe(){return Gt}var Gt,Qe=E(()=>{_t();Gt=H});function f(t,e){let r=xe(),n=Fe({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===H?void 0:H].filter(s=>!!s)});t.common.issues.push(n)}var Fe,Fn,R,g,ne,I,et,tt,q,we,vt=E(()=>{Qe();_t();Fe=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,i=[...r,...s.path||[]],a={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let o="",c=n.filter(l=>!!l).slice().reverse();for(let l of c)o=l(a,{data:e,defaultError:o}).message;return{...s,path:i,message:o}},Fn=[];R=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return g;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r){let i=await s.key,a=await s.value;n.push({key:i,value:a})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:i,value:a}=s;if(i.status==="aborted"||a.status==="aborted")return g;i.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[i.value]=a.value)}return{status:e.value,value:n}}},g=Object.freeze({status:"aborted"}),ne=t=>({status:"dirty",value:t}),I=t=>({status:"valid",value:t}),et=t=>t.status==="aborted",tt=t=>t.status==="dirty",q=t=>t.status==="valid",we=t=>typeof Promise<"u"&&t instanceof Promise});var Wt=E(()=>{});var m,qt=E(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(m||(m={}))});function b(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,o)=>{let{message:c}=t;return a.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??n??o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:c??r??o.defaultError}},description:s}}function Qt(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function ts(t){return new RegExp(`^${Qt(t)}$`)}function er(t){let e=`${Xt}T${Qt(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function rs(t,e){return!!((e==="v4"||!e)&&Wn.test(t)||(e==="v6"||!e)&&Yn.test(t))}function ns(t,e){if(!Vn.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function ss(t,e){return!!((e==="v4"||!e)&&qn.test(t)||(e==="v6"||!e)&&Jn.test(t))}function is(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,i=Number.parseInt(t.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return i%a/10**s}function ke(t){if(t instanceof O){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=P.create(ke(n))}return new O({...t._def,shape:()=>e})}else return t instanceof W?new W({...t._def,type:ke(t.element)}):t instanceof P?P.create(ke(t.unwrap())):t instanceof B?B.create(ke(t.unwrap())):t instanceof Z?Z.create(t.items.map(e=>ke(e))):t}function xt(t,e){let r=z(t),n=z(e);if(t===e)return{valid:!0,data:t};if(r===p.object&&n===p.object){let s=w.objectKeys(e),i=w.objectKeys(t).filter(o=>s.indexOf(o)!==-1),a={...t,...e};for(let o of i){let c=xt(t[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(r===p.array&&n===p.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let a=t[i],o=e[i],c=xt(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===p.date&&n===p.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function tr(t,e){return new me({values:t,typeName:y.ZodEnum,...b(e)})}function Jt(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function rr(t,e={},r){return t?J.create().superRefine((n,s)=>{let i=t(n);if(i instanceof Promise)return i.then(a=>{if(!a){let o=Jt(e,n),c=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:c})}});if(!i){let a=Jt(e,n),o=a.fatal??r??!0;s.addIssue({code:"custom",...a,fatal:o})}}):J.create()}var N,Yt,x,jn,zn,Zn,Bn,Un,Vn,Hn,Kn,Gn,bt,Wn,qn,Yn,Jn,Xn,Qn,Xt,es,Y,se,ie,ae,oe,Ee,ce,le,J,G,M,Se,W,O,ue,K,rt,de,Z,nt,Te,Ae,st,fe,pe,me,he,X,$,P,B,ge,ye,Re,as,je,ze,_e,os,y,cs,nr,sr,ls,us,ir,ds,fs,ps,ms,hs,gs,ys,_s,vs,bs,xs,ws,ks,Es,Ss,Ts,As,Rs,Is,Cs,Os,Ds,Ps,Ns,$s,Ms,Ls,Fs,js,zs,Zs,Bs,Us,Vs,ar=E(()=>{Xe();Qe();qt();vt();Le();N=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,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}},Yt=(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 r=new C(t.common.issues);return this._error=r,this._error}}};x=class{get description(){return this._def.description}_getType(e){return z(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:z(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new R,ctx:{common:e.parent.common,data:e.data,parsedType:z(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(we(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)},s=this._parseSync({data:e,path:n.path,parent:n});return Yt(n,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return q(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>q(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(we(s)?s:Promise.resolve(s));return Yt(n,i)}refine(e,r){let n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,i)=>{let a=e(s),o=()=>i.addIssue({code:u.custom,...n(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new $({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return P.create(this,this._def)}nullable(){return B.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return W.create(this)}promise(){return X.create(this,this._def)}or(e){return ue.create([this,e],this._def)}and(e){return de.create(this,e,this._def)}transform(e){return new $({...b(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new ge({...b(this._def),innerType:this,defaultValue:r,typeName:y.ZodDefault})}brand(){return new je({typeName:y.ZodBranded,type:this,...b(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new ye({...b(this._def),innerType:this,catchValue:r,typeName:y.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return ze.create(this,e)}readonly(){return _e.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},jn=/^c[^\s-]{8,}$/i,zn=/^[0-9a-z]+$/,Zn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Bn=/^[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,Un=/^[a-z0-9_-]{21}$/i,Vn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Hn=/^[-+]?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)?)??$/,Kn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Gn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Wn=/^(?:(?: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])$/,qn=/^(?:(?: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])$/,Yn=/^(([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]))$/,Jn=/^(([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])$/,Xn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Qn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Xt="((\\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])))",es=new RegExp(`^${Xt}$`);Y=class t extends x{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==p.string){let i=this._getOrReturnCtx(e);return f(i,{code:u.invalid_type,expected:p.string,received:i.parsedType}),g}let n=new R,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:u.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:u.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let a=e.data.length>i.value,o=e.data.length<i.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?f(s,{code:u.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&f(s,{code:u.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Kn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"email",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")bt||(bt=new RegExp(Gn,"u")),bt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"emoji",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")Bn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"uuid",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")Un.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"nanoid",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")jn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")zn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid2",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")Zn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ulid",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),f(s,{validation:"url",code:u.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"regex",code:u.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?er(i).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?es.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?ts(i).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?Hn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"duration",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?rs(e.data,i.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ip",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?ns(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"jwt",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?ss(e.data,i.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cidr",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?Xn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?Qn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64url",code:u.invalid_string,message:i.message}),n.dirty()):w.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:u.invalid_string,...m.errToObj(n)})}_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,r){return this._addCheck({kind:"regex",regex:e,...m.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...m.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...m.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...m.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...m.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...m.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...m.errToObj(r)})}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 r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Y.create=t=>new Y({checks:[],typeName:y.ZodString,coerce:t?.coerce??!1,...b(t)});se=class t extends x{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 i=this._getOrReturnCtx(e);return f(i,{code:u.invalid_type,expected:p.number,received:i.parsedType}),g}let n,s=new R;for(let i of this._def.checks)i.kind==="int"?w.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:u.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:u.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:u.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?is(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),f(n,{code:u.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:u.not_finite,message:i.message}),s.dirty()):w.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,m.toString(r))}gt(e,r){return this.setLimit("min",e,!1,m.toString(r))}lte(e,r){return this.setLimit("max",e,!0,m.toString(r))}lt(e,r){return this.setLimit("max",e,!1,m.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,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,r){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(r)})}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 r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&w.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};se.create=t=>new se({checks:[],typeName:y.ZodNumber,coerce:t?.coerce||!1,...b(t)});ie=class t extends x{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==p.bigint)return this._getInvalidInput(e);let n,s=new R;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:u.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:u.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),f(n,{code:u.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):w.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:p.bigint,received:r.parsedType}),g}gte(e,r){return this.setLimit("min",e,!0,m.toString(r))}gt(e,r){return this.setLimit("min",e,!1,m.toString(r))}lte(e,r){return this.setLimit("max",e,!0,m.toString(r))}lt(e,r){return this.setLimit("max",e,!1,m.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,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,r){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};ie.create=t=>new ie({checks:[],typeName:y.ZodBigInt,coerce:t?.coerce??!1,...b(t)});ae=class extends x{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==p.boolean){let n=this._getOrReturnCtx(e);return f(n,{code:u.invalid_type,expected:p.boolean,received:n.parsedType}),g}return I(e.data)}};ae.create=t=>new ae({typeName:y.ZodBoolean,coerce:t?.coerce||!1,...b(t)});oe=class t extends x{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==p.date){let i=this._getOrReturnCtx(e);return f(i,{code:u.invalid_type,expected:p.date,received:i.parsedType}),g}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return f(i,{code:u.invalid_date}),g}let n=new R,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:u.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:u.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):w.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:m.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};oe.create=t=>new oe({checks:[],coerce:t?.coerce||!1,typeName:y.ZodDate,...b(t)});Ee=class extends x{_parse(e){if(this._getType(e)!==p.symbol){let n=this._getOrReturnCtx(e);return f(n,{code:u.invalid_type,expected:p.symbol,received:n.parsedType}),g}return I(e.data)}};Ee.create=t=>new Ee({typeName:y.ZodSymbol,...b(t)});ce=class extends x{_parse(e){if(this._getType(e)!==p.undefined){let n=this._getOrReturnCtx(e);return f(n,{code:u.invalid_type,expected:p.undefined,received:n.parsedType}),g}return I(e.data)}};ce.create=t=>new ce({typeName:y.ZodUndefined,...b(t)});le=class extends x{_parse(e){if(this._getType(e)!==p.null){let n=this._getOrReturnCtx(e);return f(n,{code:u.invalid_type,expected:p.null,received:n.parsedType}),g}return I(e.data)}};le.create=t=>new le({typeName:y.ZodNull,...b(t)});J=class extends x{constructor(){super(...arguments),this._any=!0}_parse(e){return I(e.data)}};J.create=t=>new J({typeName:y.ZodAny,...b(t)});G=class extends x{constructor(){super(...arguments),this._unknown=!0}_parse(e){return I(e.data)}};G.create=t=>new G({typeName:y.ZodUnknown,...b(t)});M=class extends x{_parse(e){let r=this._getOrReturnCtx(e);return f(r,{code:u.invalid_type,expected:p.never,received:r.parsedType}),g}};M.create=t=>new M({typeName:y.ZodNever,...b(t)});Se=class extends x{_parse(e){if(this._getType(e)!==p.undefined){let n=this._getOrReturnCtx(e);return f(n,{code:u.invalid_type,expected:p.void,received:n.parsedType}),g}return I(e.data)}};Se.create=t=>new Se({typeName:y.ZodVoid,...b(t)});W=class t extends x{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==p.array)return f(r,{code:u.invalid_type,expected:p.array,received:r.parsedType}),g;if(s.exactLength!==null){let a=r.data.length>s.exactLength.value,o=r.data.length<s.exactLength.value;(a||o)&&(f(r,{code:a?u.too_big:u.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(f(r,{code:u.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(f(r,{code:u.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((a,o)=>s.type._parseAsync(new N(r,a,r.path,o)))).then(a=>R.mergeArray(n,a));let i=[...r.data].map((a,o)=>s.type._parseSync(new N(r,a,r.path,o)));return R.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:m.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:m.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:m.toString(r)}})}nonempty(e){return this.min(1,e)}};W.create=(t,e)=>new W({type:t,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,...b(e)});O=class t extends x{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=w.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==p.object){let l=this._getOrReturnCtx(e);return f(l,{code:u.invalid_type,expected:p.object,received:l.parsedType}),g}let{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof M&&this._def.unknownKeys==="strip"))for(let l in s.data)a.includes(l)||o.push(l);let c=[];for(let l of a){let d=i[l],v=s.data[l];c.push({key:{status:"valid",value:l},value:d._parse(new N(s,v,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof M){let l=this._def.unknownKeys;if(l==="passthrough")for(let d of o)c.push({key:{status:"valid",value:d},value:{status:"valid",value:s.data[d]}});else if(l==="strict")o.length>0&&(f(s,{code:u.unrecognized_keys,keys:o}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let d of o){let v=s.data[d];c.push({key:{status:"valid",value:d},value:l._parse(new N(s,v,s.path,d)),alwaysSet:d in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let d of c){let v=await d.key,_=await d.value;l.push({key:v,value:_,alwaysSet:d.alwaysSet})}return l}).then(l=>R.mergeObjectSync(n,l)):R.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return m.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let s=this._def.errorMap?.(r,n).message??n.defaultError;return r.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:y.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of w.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of w.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return ke(this)}partial(e){let r={};for(let n of w.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of w.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof P;)i=i._def.innerType;r[n]=i}return new t({...this._def,shape:()=>r})}keyof(){return tr(w.objectKeys(this.shape))}};O.create=(t,e)=>new O({shape:()=>t,unknownKeys:"strip",catchall:M.create(),typeName:y.ZodObject,...b(e)});O.strictCreate=(t,e)=>new O({shape:()=>t,unknownKeys:"strict",catchall:M.create(),typeName:y.ZodObject,...b(e)});O.lazycreate=(t,e)=>new O({shape:t,unknownKeys:"strip",catchall:M.create(),typeName:y.ZodObject,...b(e)});ue=class extends x{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(i){for(let o of i)if(o.result.status==="valid")return o.result;for(let o of i)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;let a=i.map(o=>new C(o.ctx.common.issues));return f(r,{code:u.invalid_union,unionErrors:a}),g}if(r.common.async)return Promise.all(n.map(async i=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(s);{let i,a=[];for(let c of n){let l={...r,common:{...r.common,issues:[]},parent:null},d=c._parseSync({data:r.data,path:r.path,parent:l});if(d.status==="valid")return d;d.status==="dirty"&&!i&&(i={result:d,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let o=a.map(c=>new C(c));return f(r,{code:u.invalid_union,unionErrors:o}),g}}get options(){return this._def.options}};ue.create=(t,e)=>new ue({options:t,typeName:y.ZodUnion,...b(e)});K=t=>t instanceof fe?K(t.schema):t instanceof $?K(t.innerType()):t instanceof pe?[t.value]:t instanceof me?t.options:t instanceof he?w.objectValues(t.enum):t instanceof ge?K(t._def.innerType):t instanceof ce?[void 0]:t instanceof le?[null]:t instanceof P?[void 0,...K(t.unwrap())]:t instanceof B?[null,...K(t.unwrap())]:t instanceof je||t instanceof _e?K(t.unwrap()):t instanceof ye?K(t._def.innerType):[],rt=class t extends x{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==p.object)return f(r,{code:u.invalid_type,expected:p.object,received:r.parsedType}),g;let n=this.discriminator,s=r.data[n],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(f(r,{code:u.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),g)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=new Map;for(let i of r){let a=K(i.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of a){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new t({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...b(n)})}};de=class extends x{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=(i,a)=>{if(et(i)||et(a))return g;let o=xt(i.value,a.value);return o.valid?((tt(i)||tt(a))&&r.dirty(),{status:r.value,value:o.data}):(f(n,{code:u.invalid_intersection_types}),g)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,a])=>s(i,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};de.create=(t,e,r)=>new de({left:t,right:e,typeName:y.ZodIntersection,...b(r)});Z=class t extends x{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.array)return f(n,{code:u.invalid_type,expected:p.array,received:n.parsedType}),g;if(n.data.length<this._def.items.length)return f(n,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;!this._def.rest&&n.data.length>this._def.items.length&&(f(n,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((a,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new N(n,a,n.path,o)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>R.mergeArray(r,a)):R.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Z.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Z({items:t,typeName:y.ZodTuple,rest:null,...b(e)})};nt=class t extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.object)return f(n,{code:u.invalid_type,expected:p.object,received:n.parsedType}),g;let s=[],i=this._def.keyType,a=this._def.valueType;for(let o in n.data)s.push({key:i._parse(new N(n,o,n.path,o)),value:a._parse(new N(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?R.mergeObjectAsync(r,s):R.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof x?new t({keyType:e,valueType:r,typeName:y.ZodRecord,...b(n)}):new t({keyType:Y.create(),valueType:e,typeName:y.ZodRecord,...b(r)})}},Te=class extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.map)return f(n,{code:u.invalid_type,expected:p.map,received:n.parsedType}),g;let s=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([o,c],l)=>({key:s._parse(new N(n,o,n.path,[l,"key"])),value:i._parse(new N(n,c,n.path,[l,"value"]))}));if(n.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let c of a){let l=await c.key,d=await c.value;if(l.status==="aborted"||d.status==="aborted")return g;(l.status==="dirty"||d.status==="dirty")&&r.dirty(),o.set(l.value,d.value)}return{status:r.value,value:o}})}else{let o=new Map;for(let c of a){let l=c.key,d=c.value;if(l.status==="aborted"||d.status==="aborted")return g;(l.status==="dirty"||d.status==="dirty")&&r.dirty(),o.set(l.value,d.value)}return{status:r.value,value:o}}}};Te.create=(t,e,r)=>new Te({valueType:e,keyType:t,typeName:y.ZodMap,...b(r)});Ae=class t extends x{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.set)return f(n,{code:u.invalid_type,expected:p.set,received:n.parsedType}),g;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(f(n,{code:u.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(f(n,{code:u.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function a(c){let l=new Set;for(let d of c){if(d.status==="aborted")return g;d.status==="dirty"&&r.dirty(),l.add(d.value)}return{status:r.value,value:l}}let o=[...n.data.values()].map((c,l)=>i._parse(new N(n,c,n.path,l)));return n.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,r){return new t({...this._def,minSize:{value:e,message:m.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:m.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Ae.create=(t,e)=>new Ae({valueType:t,minSize:null,maxSize:null,typeName:y.ZodSet,...b(e)});st=class t extends x{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==p.function)return f(r,{code:u.invalid_type,expected:p.function,received:r.parsedType}),g;function n(o,c){return Fe({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,xe(),H].filter(l=>!!l),issueData:{code:u.invalid_arguments,argumentsError:c}})}function s(o,c){return Fe({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,xe(),H].filter(l=>!!l),issueData:{code:u.invalid_return_type,returnTypeError:c}})}let i={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof X){let o=this;return I(async function(...c){let l=new C([]),d=await o._def.args.parseAsync(c,i).catch(k=>{throw l.addIssue(n(c,k)),l}),v=await Reflect.apply(a,this,d);return await o._def.returns._def.type.parseAsync(v,i).catch(k=>{throw l.addIssue(s(v,k)),l})})}else{let o=this;return I(function(...c){let l=o._def.args.safeParse(c,i);if(!l.success)throw new C([n(c,l.error)]);let d=Reflect.apply(a,this,l.data),v=o._def.returns.safeParse(d,i);if(!v.success)throw new C([s(d,v.error)]);return v.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Z.create(e).rest(G.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||Z.create([]).rest(G.create()),returns:r||G.create(),typeName:y.ZodFunction,...b(n)})}},fe=class extends x{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};fe.create=(t,e)=>new fe({getter:t,typeName:y.ZodLazy,...b(e)});pe=class extends x{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return f(r,{received:r.data,code:u.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:e.data}}get value(){return this._def.value}};pe.create=(t,e)=>new pe({value:t,typeName:y.ZodLiteral,...b(e)});me=class t extends x{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return f(r,{expected:w.joinValues(n),received:r.parsedType,code:u.invalid_type}),g}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return f(r,{received:r.data,code:u.invalid_enum_value,options:n}),g}return I(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};me.create=tr;he=class extends x{_parse(e){let r=w.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==p.string&&n.parsedType!==p.number){let s=w.objectValues(r);return f(n,{expected:w.joinValues(s),received:n.parsedType,code:u.invalid_type}),g}if(this._cache||(this._cache=new Set(w.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=w.objectValues(r);return f(n,{received:n.data,code:u.invalid_enum_value,options:s}),g}return I(e.data)}get enum(){return this._def.values}};he.create=(t,e)=>new he({values:t,typeName:y.ZodNativeEnum,...b(e)});X=class extends x{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==p.promise&&r.common.async===!1)return f(r,{code:u.invalid_type,expected:p.promise,received:r.parsedType}),g;let n=r.parsedType===p.promise?r.data:Promise.resolve(r.data);return I(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};X.create=(t,e)=>new X({type:t,typeName:y.ZodPromise,...b(e)});$=class extends x{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a=>{f(n,a),a.fatal?r.abort():r.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let a=s.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async o=>{if(r.value==="aborted")return g;let c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?g:c.status==="dirty"?ne(c.value):r.value==="dirty"?ne(c.value):c});{if(r.value==="aborted")return g;let o=this._def.schema._parseSync({data:a,path:n.path,parent:n});return o.status==="aborted"?g:o.status==="dirty"?ne(o.value):r.value==="dirty"?ne(o.value):o}}if(s.type==="refinement"){let a=o=>{let c=s.refinement(o,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?g:(o.status==="dirty"&&r.dirty(),a(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?g:(o.status==="dirty"&&r.dirty(),a(o.value).then(()=>({status:r.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!q(a))return g;let o=s.transform(a.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>q(a)?Promise.resolve(s.transform(a.value,i)).then(o=>({status:r.value,value:o})):g);w.assertNever(s)}};$.create=(t,e,r)=>new $({schema:t,typeName:y.ZodEffects,effect:e,...b(r)});$.createWithPreprocess=(t,e,r)=>new $({schema:e,effect:{type:"preprocess",transform:t},typeName:y.ZodEffects,...b(r)});P=class extends x{_parse(e){return this._getType(e)===p.undefined?I(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};P.create=(t,e)=>new P({innerType:t,typeName:y.ZodOptional,...b(e)});B=class extends x{_parse(e){return this._getType(e)===p.null?I(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};B.create=(t,e)=>new B({innerType:t,typeName:y.ZodNullable,...b(e)});ge=class extends x{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===p.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};ge.create=(t,e)=>new ge({innerType:t,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...b(e)});ye=class extends x{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return we(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new C(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new C(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ye.create=(t,e)=>new ye({innerType:t,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...b(e)});Re=class extends x{_parse(e){if(this._getType(e)!==p.nan){let n=this._getOrReturnCtx(e);return f(n,{code:u.invalid_type,expected:p.nan,received:n.parsedType}),g}return{status:"valid",value:e.data}}};Re.create=t=>new Re({typeName:y.ZodNaN,...b(t)});as=Symbol("zod_brand"),je=class extends x{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},ze=class t extends x{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?g:i.status==="dirty"?(r.dirty(),ne(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?g:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:y.ZodPipeline})}},_e=class extends x{_parse(e){let r=this._def.innerType._parse(e),n=s=>(q(s)&&(s.value=Object.freeze(s.value)),s);return we(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};_e.create=(t,e)=>new _e({innerType:t,typeName:y.ZodReadonly,...b(e)});os={object:O.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"})(y||(y={}));cs=(t,e={message:`Input not instance of ${t.name}`})=>rr(r=>r instanceof t,e),nr=Y.create,sr=se.create,ls=Re.create,us=ie.create,ir=ae.create,ds=oe.create,fs=Ee.create,ps=ce.create,ms=le.create,hs=J.create,gs=G.create,ys=M.create,_s=Se.create,vs=W.create,bs=O.create,xs=O.strictCreate,ws=ue.create,ks=rt.create,Es=de.create,Ss=Z.create,Ts=nt.create,As=Te.create,Rs=Ae.create,Is=st.create,Cs=fe.create,Os=pe.create,Ds=me.create,Ps=he.create,Ns=X.create,$s=$.create,Ms=P.create,Ls=B.create,Fs=$.createWithPreprocess,js=ze.create,zs=()=>nr().optional(),Zs=()=>sr().optional(),Bs=()=>ir().optional(),Us={string:(t=>Y.create({...t,coerce:!0})),number:(t=>se.create({...t,coerce:!0})),boolean:(t=>ae.create({...t,coerce:!0})),bigint:(t=>ie.create({...t,coerce:!0})),date:(t=>oe.create({...t,coerce:!0}))},Vs=g});var h={};Nn(h,{BRAND:()=>as,DIRTY:()=>ne,EMPTY_PATH:()=>Fn,INVALID:()=>g,NEVER:()=>Vs,OK:()=>I,ParseStatus:()=>R,Schema:()=>x,ZodAny:()=>J,ZodArray:()=>W,ZodBigInt:()=>ie,ZodBoolean:()=>ae,ZodBranded:()=>je,ZodCatch:()=>ye,ZodDate:()=>oe,ZodDefault:()=>ge,ZodDiscriminatedUnion:()=>rt,ZodEffects:()=>$,ZodEnum:()=>me,ZodError:()=>C,ZodFirstPartyTypeKind:()=>y,ZodFunction:()=>st,ZodIntersection:()=>de,ZodIssueCode:()=>u,ZodLazy:()=>fe,ZodLiteral:()=>pe,ZodMap:()=>Te,ZodNaN:()=>Re,ZodNativeEnum:()=>he,ZodNever:()=>M,ZodNull:()=>le,ZodNullable:()=>B,ZodNumber:()=>se,ZodObject:()=>O,ZodOptional:()=>P,ZodParsedType:()=>p,ZodPipeline:()=>ze,ZodPromise:()=>X,ZodReadonly:()=>_e,ZodRecord:()=>nt,ZodSchema:()=>x,ZodSet:()=>Ae,ZodString:()=>Y,ZodSymbol:()=>Ee,ZodTransformer:()=>$,ZodTuple:()=>Z,ZodType:()=>x,ZodUndefined:()=>ce,ZodUnion:()=>ue,ZodUnknown:()=>G,ZodVoid:()=>Se,addIssueToContext:()=>f,any:()=>hs,array:()=>vs,bigint:()=>us,boolean:()=>ir,coerce:()=>Us,custom:()=>rr,date:()=>ds,datetimeRegex:()=>er,defaultErrorMap:()=>H,discriminatedUnion:()=>ks,effect:()=>$s,enum:()=>Ds,function:()=>Is,getErrorMap:()=>xe,getParsedType:()=>z,instanceof:()=>cs,intersection:()=>Es,isAborted:()=>et,isAsync:()=>we,isDirty:()=>tt,isValid:()=>q,late:()=>os,lazy:()=>Cs,literal:()=>Os,makeIssue:()=>Fe,map:()=>As,nan:()=>ls,nativeEnum:()=>Ps,never:()=>ys,null:()=>ms,nullable:()=>Ls,number:()=>sr,object:()=>bs,objectUtil:()=>yt,oboolean:()=>Bs,onumber:()=>Zs,optional:()=>Ms,ostring:()=>zs,pipeline:()=>js,preprocess:()=>Fs,promise:()=>Ns,quotelessJson:()=>$n,record:()=>Ts,set:()=>Rs,setErrorMap:()=>Ln,strictObject:()=>xs,string:()=>nr,symbol:()=>fs,transformer:()=>$s,tuple:()=>Ss,undefined:()=>ps,union:()=>ws,unknown:()=>gs,util:()=>w,void:()=>_s});var wt=E(()=>{Qe();vt();Wt();Le();ar();Xe()});var it=E(()=>{wt();wt()});var at,kt=E(()=>{"use strict";it();at=h.object({slug:h.string().min(1).max(64),description:h.string().max(255).optional(),match_command:h.string().min(1),priority:h.number().int().default(50),strip_ansi:h.boolean().default(!1),strip_lines_matching:h.array(h.string()).default([]),truncate_lines_at:h.number().int().positive().max(1e4).optional(),max_lines:h.number().int().positive().max(1e5).optional(),transform:h.string().max(64).optional(),on_empty:h.string().max(255).optional()})});import{createHash as Js}from"node:crypto";function L(t){let e=dr.get(t);return e||(e=Js("sha256").update(`tkr:${t}`).digest("hex").slice(0,16),dr.set(t,e)),e}function ot(t,e=!1){return e||!t||t.length===0?(fr??=new Set(ei.map(L)),new Set(fr)):new Set(t.map(r=>ti.test(r)?r:L(r)))}var Xs,Qs,Et,ei,ti,dr,fr,ve=E(()=>{"use strict";it();Xs=h.enum(["normal","compact","minimal"]),Qs=h.enum(["off","light","balanced","max"]),Et=h.object({enabled:h.boolean().default(!0),telemetryOptIn:h.boolean().default(!0),outputVerbosity:Xs.default("compact"),reducer:Qs.default("off"),filters:h.object({enableAll:h.boolean().default(!0),disabled:h.array(h.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})}),ei=["git","grep","find","ls","ps","cat","head","tail","df","du","tree","wc","read-tool","grep-tool","glob-tool","npm","docker","kubectl","curl","cargo","go-test","gh","aws","dotnet","prisma","tsc","next","jest","vitest","pytest","pip","rspec"],ti=/^[0-9a-f]{16}$/,dr=new Map;fr=null});import Cr from"node:os";import{join as ee}from"node:path";function T(){return process.env.TOKMIZER_HOME||ee(Cr.homedir(),".tokmizer")}function Be(){return ee(T(),"install-id")}function Or(){return ee(T(),"enroll-cooldown")}function Rt(){return ee(T(),"bundle-refresh.json")}function lt(){return ee(T(),"skills")}function Ue(t){return ee(lt(),`${t}.md`)}function ut(){return process.env.TOKMIZER_CLAUDE_COMMANDS_DIR||ee(Cr.homedir(),".claude","commands")}function Ve(t){return ee(ut(),`${t}.md`)}var V=E(()=>{"use strict"});import Ie from"node:os";import{createHash as Ri,randomUUID as Ii}from"node:crypto";import{readFile as Dr,writeFile as Pr,mkdir as Ci}from"node:fs/promises";async function Ct(){try{let r=(await Dr(Be(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(r))return r}catch{}await Ci(T(),{recursive:!0});let t=Ii();try{return await Pr(Be(),t,{mode:384,flag:"wx"}),t}catch{try{let e=(await Dr(Be(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(e))return e}catch{}return await Pr(Be(),t,{mode:384}),t}}function It(t){return Ri("sha256").update(t).digest("hex")}function Oi(){let t=Ie.networkInterfaces();for(let e of Object.keys(t))for(let r of t[e]??[])if(!r.internal&&r.mac&&r.mac!=="00:00:00:00:00:00")return r.mac;return"no-mac"}async function Ce(){let t=await Ct(),e=Ie.hostname(),r=Ie.platform(),n=Ie.release(),s=Ie.cpus(),i=s[0]?.model??"unknown",a=s.length,o=It(Oi()),c=It(Ie.userInfo().username),l=[e,r,n,i,String(a),o,c,t].join("|");return{fingerprint:It(l),installId:t,hostname:e,os:r,osVersion:n,cpuModel:i,cpuCores:a,macHash:o,usernameHash:c}}var Oe=E(()=>{"use strict";V()});import{join as Nr}from"node:path";import{mkdir as Di,readFile as Pi,writeFile as Ni,unlink as Bc,rename as $i}from"node:fs/promises";function dt(){try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t&&t.length>0?t:"Etc/UTC"}catch{return"Etc/UTC"}}function Mr(t){return t?.dir??T()}async function De(t){let e=Mr(t);try{let r=await Pi(Nr(e,$r),"utf8"),n=JSON.parse(r);return{...n,lastSettingsRevision:n.lastSettingsRevision??0,timeZone:n.timeZone??dt(),bonusActive:n.bonusActive??!1,...n.bonusResetAt!==void 0?{bonusResetAt:n.bonusResetAt}:{}}}catch{return null}}async function Lr(t,e){let r=Mr(e);await Di(r,{recursive:!0});let n=Nr(r,$r),s=`${n}.tmp`;await Ni(s,JSON.stringify(t,null,2),{mode:384}),await $i(s,n)}var $r,Vc,He=E(()=>{"use strict";V();$r="state.json",Vc={lastSettingsRevision:0,timeZone:dt(),bonusActive:!1}});import{createRequire as Mi}from"node:module";function Fi(){for(let t of["../package.json","../../package.json"])try{let e=Li(t).version;if(typeof e=="string"&&e)return e}catch{}return"0.0.0"}var Li,Ke,Ot=E(()=>{"use strict";Li=Mi(import.meta.url);Ke=Fi()});var Fr,jr=E(()=>{"use strict";Fr=`-----BEGIN PUBLIC KEY-----
4
4
  MCowBQYDK2VwAyEAj/kMlXlhTIGHRKxOKMuGFa1S1ybxxwgdYcAE0YM9fgU=
5
5
  -----END PUBLIC KEY-----
6
- `});import{createHmac as Mi,createPublicKey as Li,verify as Fi}from"node:crypto";function Ot(){return((process.env.TOKMIZER_DEV==="1"?process.env.TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM:void 0)??Pr).replace(/\\n/g,`
7
- `)}function zi(t,e,r,n){try{let s=Li({key:n,format:"pem"});return Fi(null,Buffer.from(`${e}.${t}`,"utf8"),s,Buffer.from(r,"base64url"))}catch{return!1}}async function Ke(t){let e=await t.text(),r=Ot(),n=t.headers?.get?.("x-tokmizer-resp-ts")??null;if(n!==null){let a=Number(n);if(!Number.isFinite(a)||Date.now()-a>ji)throw new se("http","stale server response (resp-ts outside freshness window)")}if(!r||!r.includes("BEGIN PUBLIC KEY"))throw new se("http","no signing public key configured; refusing to trust server response");let s=t.headers?.get?.("x-tokmizer-resp-sig")??null,i=Number(n);if(!s||n===null||!Number.isFinite(i))throw new se("http","missing server response signature");if(!zi(e,i,s,r))throw new se("http","invalid server response signature");return JSON.parse(e)}function Zi(t,e,r){return Mi("sha256",r).update(`${e}.${t}`).digest("hex")}async function $e(t,e,r,n){let s=Date.now(),i=r===void 0?"":JSON.stringify(r),a=n.signingSecret?Zi(i,s,n.signingSecret):"0".repeat(64),o={"content-type":"application/json","x-tokmizer-fingerprint":n.fingerprint,"x-tokmizer-install-id":n.installId,"x-tokmizer-sig":a,"x-tokmizer-ts":String(s),"x-tokmizer-plugin-version":He};n.bearer&&(o.authorization=`Bearer ${n.bearer}`);let c=n.timeoutMs??5e3,l=t!=="GET"&&t!=="DELETE",p={method:t,headers:o,signal:AbortSignal.timeout(c)};l&&(p.body=i);try{return await fetch(`${n.baseUrl}${e}`,p)}catch(y){let w=y.name;throw w==="TimeoutError"||w==="AbortError"?new se("timeout",`${t} ${e} timed out after ${c}ms`):new se("network",`${t} ${e} failed: ${y.message}`)}}var ji,se,Ge=k(()=>{"use strict";Ct();Nr();ji=300*1e3;se=class extends Error{constructor(r,n,s){super(n);this.kind=r;this.status=s;this.name="TransportError"}kind;status}});function We(t){let e=t;for(let[r,n]of la)e=e.replace(r,n);return e}var la,Mt=k(()=>{"use strict";la=[[/(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]+-)*(?: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+.-]*:\/\/[^:/\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]"]]});import{join as Wr}from"node:path";import{appendFileSync as ua,existsSync as da,mkdirSync as fa,readFileSync as Ll,renameSync as Fl,statSync as pa,unlinkSync as jl,writeFileSync as zl}from"node:fs";function qr(){return Wr(S(),"spool")}function ha(t){return Wr(qr(),`${t}.jsonl`)}function pt(t,e){try{fa(qr(),{recursive:!0,mode:448});let r=ha(t);if(da(r)&&pa(r).size>=ma)return;ua(r,JSON.stringify(e)+`
8
- `,{mode:384})}catch{return}}var ma,Lt=k(()=>{"use strict";K();Ve();Pe();Ge();ma=512*1024});function Yr(t){let e=t.toLowerCase();return e.startsWith("git")||xa.has(e)}function Ft(t){let e=t.trim().split(/\s+/).filter(o=>o.length>0),r=0;for(;r<e.length&&va.test(e[r]??"");)r+=1;let n=e[r];if(!n||!ya.test(n)||n.length>wa||Yr(n)||ba.test(n)||We(n)!==n)return"";let s=e[r+1];return s&&Yr(s)?"":(s&&ka.has(n.toLowerCase())&&_a.test(s)?`${n} ${s}`:n).slice(0,64)}async function Jr(t){if(!t.telemetryOptIn)return;let e=Ft(t.cmd),r=e&&We(e)===e?e:"other";pt("telemetry",{cmd:r,tokensSaved:Math.max(0,Math.round(t.tokensSaved)),optimized:t.optimized})}var ya,_a,va,xa,ba,wa,ka,jt=k(()=>{"use strict";Mt();Lt();ya=/^[a-z0-9][a-z0-9._-]*$/i,_a=/^[a-z][a-z-]+$/,va=/^[A-Za-z_][A-Za-z0-9_]*=/,xa=new Set(["gh","glab","gup","hub","gist"]),ba=/^(gh[a-z]_|github_pat_|gl(?:pat|rt|soat|imt|dt|ft|agent|oas)-|npm_|xox|sk-|sk_|eyj|a(?:kia|sia|gpa|ida|roa|npa)|aiza|hv[sb]\.)/i,wa=24,ka=new Set(["docker","podman","npm","pnpm","yarn","npx","bun","deno","cargo","rustup","go","pip","pip3","uv","poetry","brew","apt","apt-get","dnf","yum","pacman","kubectl","helm","terraform","aws","gcloud","az","systemctl","composer","bundle","gem","dotnet","prisma","tkr","rtk","token"])});async function Xr(t){if(t.plan!=="pro")return;let e=Ft(t.cmd);!e||We(e)!==e||pt("learn",{cmd:e,filterId:t.filterId==null?null:z(t.filterId),rawBytes:t.rawBytes,filteredBytes:t.filteredBytes})}var Qr=k(()=>{"use strict";jt();Mt();Lt();be()});function ln(t){return JSON.stringify(t)+mt}function*un(t){let e=0;for(;;){let r=t.indexOf(mt,e);if(r<0)return;yield t.slice(e,r),e=r+1}}function ht(){return`${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var Na,$a,Ma,La,uu,du,fu,cn,mt,pu,dn=k(()=>{"use strict";st();Et();Na=h.object({id:h.string().min(1).max(64),op:h.literal("filter"),cmd:h.string().min(1).max(2048),plan:h.enum(["trial","smart","pro"]),installId:h.string().min(1).max(64).optional()}),$a=h.object({id:h.string().min(1).max(64),op:h.literal("ping")}),Ma=h.object({id:h.string().min(1).max(64),op:h.literal("shutdown"),installId:h.string().min(1).max(64)}),La=h.object({id:h.string().min(1).max(64),op:h.literal("reload"),installId:h.string().min(1).max(64).optional()}),uu=h.discriminatedUnion("op",[Na,$a,Ma,La]),du=h.object({id:h.string(),ok:h.literal(!0),data:h.unknown()}),fu=h.object({id:h.string(),ok:h.literal(!1),err:h.string(),retryAfterMs:h.number().int().nonnegative().optional()}),cn=h.object({filter:it.nullable(),cacheHit:h.boolean().optional()}),mt=`
9
- `,pu=64*1024});import{join as zt}from"node:path";import{existsSync as fn,statSync as Fa,unlinkSync as ja,mkdirSync as za,chmodSync as Za}from"node:fs";function gt(){if(process.platform==="win32")return{path:`\\\\.\\pipe\\tokmizer-${process.env.USERNAME??"tokmizer"}`,isPipe:!0};let t=typeof process.getuid=="function"?process.getuid():0,e=process.env.XDG_RUNTIME_DIR;if(e&&fn(e))return{path:zt(e,`tokmizer-${t}.sock`),isPipe:!1};let r=zt(S(),"run");try{za(r,{recursive:!0,mode:448}),Za(r,448)}catch{}return{path:zt(r,"daemon.sock"),isPipe:!1}}async function pn(){let{path:t,isPipe:e}=gt();if(e||!fn(t))return;try{if(!Fa(t).isSocket())return}catch{return}let r=await import("node:net");if(!await new Promise(s=>{let i=r.createConnection(t),a=o=>{i.removeAllListeners();try{i.destroy()}catch{}s(o)};i.once("connect",()=>a(!0)),i.once("error",o=>{let c=o.code;a(c!=="ECONNREFUSED"&&c!=="ENOENT")}),setTimeout(()=>a(!0),250)}))try{ja(t)}catch{}}var _u,mn=k(()=>{"use strict";K();_u=5*6e4});import{createConnection as Ba}from"node:net";import{spawn as Ua}from"node:child_process";import{existsSync as xn,openSync as hn,closeSync as Va,unlinkSync as gn,writeFileSync as yn}from"node:fs";import{dirname as Ha,join as Ka}from"node:path";import{fileURLToPath as Ga}from"node:url";async function Ya(t,e){return new Promise((r,n)=>{let s=Ba(t),i=o=>{if(s.removeAllListeners("connect"),s.removeAllListeners("error"),clearTimeout(a),o){try{s.destroy()}catch{}n(o)}else r(s)},a=setTimeout(()=>i(new Error("connect timeout")),e);s.once("connect",()=>i(null)),s.once("error",o=>i(o))})}function Ja(){return process.env.TOKMIZER_DAEMON_BIN?process.env.TOKMIZER_DAEMON_BIN:Ga(new URL("../bin/tkr-daemon.js",import.meta.url))}async function vn(t,e=3e3){let r=Math.ceil(e/75);for(let n=0;n<r;n++){if(xn(t))return!0;await new Promise(s=>setTimeout(s,75))}return!1}async function Xa(t){let e=Ja();if(!xn(e))throw new Error(`tkr-daemon binary not found at ${e}`);let{path:r}=gt(),n=Ka(Ha(r),"daemon.spawn.lock"),s=null;try{s=hn(n,"wx"),yn(s,String(process.pid))}catch(i){if(i.code==="EEXIST"){if(await vn(r,5e3))return;try{gn(n)}catch{}s=hn(n,"wx"),yn(s,String(process.pid))}else throw i}try{if(Ua(process.execPath,[e],{detached:!0,stdio:["ignore","ignore","ignore"],env:{...process.env,TOKMIZER_DAEMON_INSTALL_ID:t}}).unref(),!await vn(r,3e3))throw new Error("tkr-daemon failed to bind socket within 3s")}finally{if(s!==null){try{Va(s)}catch{}try{gn(n)}catch{}}}}async function bn(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:gt(),r=await It(),n=null,s=0;for(;s<=_n;)try{n=await Ya(e,Wa);break}catch{if(s+=1,s>_n)throw new Error(`tkr-daemon unreachable at ${e}`);await pn(),await Xa(r)}if(!n)throw new Error("tkr-daemon: socket setup failed");let i=new Map,a="";n.setEncoding("utf8"),n.on("data",c=>{a+=c;let l=-1;for(let y=0;y<a.length;y++)a[y]===mt&&(l=y);if(l<0)return;let p=[];for(let y of un(a.slice(0,l+1)))p.push(y);a=a.slice(l+1);for(let y of p)if(y)try{let w=JSON.parse(y),T=i.get(w.id);if(!T)continue;clearTimeout(T.timer),i.delete(w.id),T.resolve(w)}catch{}}),n.on("close",()=>{for(let c of i.values())clearTimeout(c.timer),c.reject(new Error("daemon socket closed"));i.clear()}),n.on("error",()=>{});function o(c){return new Promise((l,p)=>{let y=setTimeout(()=>{i.delete(c.id),p(new Error(`daemon request timeout (${c.op})`))},qa);i.set(c.id,{resolve:l,reject:p,timer:y}),n.write(ln(c))})}return{filter:async(c,l)=>{let p=await o({id:ht(),op:"filter",cmd:c.slice(0,2048),plan:l,installId:r});if(!p.ok)return null;let y=cn.safeParse(p.data);return y.success?y.data.filter:null},ping:async()=>{let c=await o({id:ht(),op:"ping"});if(!c.ok)throw new Error(c.err);return c.data},reload:async()=>{let c=await o({id:ht(),op:"reload",installId:r});if(!c.ok)throw new Error(c.err);return c.data},close:()=>{try{n.end()}catch{}}}}var Wa,qa,_n,wn=k(()=>{"use strict";dn();mn();Pe();Wa=500,qa=3e3,_n=1});import{spawn as so}from"node:child_process";import{spawn as to}from"node:child_process";Et();import{readdir as zs,readFile as Zs}from"node:fs/promises";import{join as ir,dirname as Bs}from"node:path";import{fileURLToPath as Us}from"node:url";var Vs=Bs(Us(import.meta.url)),nr=ir(Vs,"..","..","filters"),re=null,sr=!1;function Hs(){return process.env.TOKMIZER_DEV==="1"||process.env.TOKMIZER_DEV==="true"}async function ar(){if(re)return re;if(!Hs())return!sr&&process.env.TOKMIZER_DEBUG==="1"&&(process.stderr.write(`tokmizer: disk loader disabled (set TOKMIZER_DEV=1 to re-enable for local dev).
10
- `),sr=!0),re=new Map,re;let t=new Map,e,r;try{e=(await import("smol-toml")).parse,r=(await zs(nr)).filter(n=>n.endsWith(".toml"))}catch{return re=t,re}for(let n of r){let s=await Zs(ir(nr,n),"utf8"),a=e(s).filters;if(a)for(let[o,c]of Object.entries(a)){let l=it.parse({slug:o,...c});t.set(o,{...l,matchRegex:new RegExp(l.match_command)})}}return re=t,re}be();var Ue=new Map,Js=256,lr=new WeakMap;function Xs(t){if(!t)return"*";let e=lr.get(t);return e===void 0&&(e=[...t].join(","),lr.set(t,e)),e}function ur(t,e,r){let n=`${t}::${Xs(r)}`,s=Ue.get(n);if(s!==void 0)return s;let i=null;for(let a of e)r&&!r.has(z(a.slug))||a.matchRegex.test(t)&&(!i||a.priority>i.priority)&&(i=a);if(Ue.size>=Js){let a=Ue.keys().next().value;a&&Ue.delete(a)}return Ue.set(n,i),i}var Qs=/\x1b\[[0-9;?]*[ -/]*[@-~]/g,ei=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g;function dr(t){return t.replace(Qs,"").replace(ei,"")}function fr(t,e){return e.length===0?t:t.filter(r=>!e.some(n=>n.test(r)))}function pr(t,e){return t.map(r=>r.length<=e?r:`${r.slice(0,e)}\u2026`)}function mr(t,e){if(t.length<=e)return t;let r=t.length-e;return[...t.slice(0,e),`\u2026 (${r} more lines omitted)`]}var ti=/^(\s*)(?:export\s+)?(?:async\s+)?(?:function|interface|type|const|let|var|def|fn|impl|trait|struct|enum)\s+[\w$]+/,ri=/\{\s*$/;var ni=/^\s*(?:(?:public|private|protected|static|async|get|set|readonly|override)\s+)*([\w$]+)\s*\(([^)]*)\)\s*(?::\s*[^{]+)?\{\s*$/,si=new Set(["if","for","while","switch","catch","do","with","return","else","function","await","yield"]);function ii(t){let e=ni.exec(t);return!e||si.has(e[1])?!1:!/=>|\bfunction\b/.test(e[2])}var ai=/^\s*(?:if|for|while|switch|try|do)\b[^{}]*\{\s*$/;function ot(t){let e=[],r=0;for(;r<t.length;){let n=t[r];if(ti.test(n)&&ri.test(n)||ii(n)||ai.test(n)){let s=0,i=r,a=!1;for(;i<t.length&&i-r<200;){for(let o of t[i])o==="{"||o==="("||o==="["?s+=1:(o==="}"||o===")"||o==="]")&&(s-=1);if(i+=1,s<=0){a=!0;break}}if(a){e.push(`${n.replace(/\{\s*$/,"")}{ \u2026 }`),r=i;continue}}e.push(n),r+=1}return e}var oi=/\b(?:function|class|interface|import\s+|export\s+|def\s+|fn\s+|impl\s+|package\s+|namespace\s+|using\s+|#include|=>\s*\{|=\s*function)/;function hr(t){let e=t.slice(0,4096);return!(!oi.test(e)||e.split(`
11
- `).length<6)}var ci=/\b(?:DEBUG|TRACE|INFO|VERBOSE)\b/;function gr(t){return t.filter(e=>!ci.test(e))}function yr(t){if(t.length===0)return t;let e=[],r=1,n=t[0];for(let s=1;s<t.length;s++){if(t[s]===n){r+=1;continue}e.push(r>1?`${n} \xD7${r}`:n),n=t[s],r=1}return e.push(r>1?`${n} \xD7${r}`:n),e}function _r(t){let e=[],r=0;for(let n of t){if(n.trim()===""){r+=1;continue}r>0&&e.push(""),r=0,e.push(n)}return e}var vr=new Map;function H(t,e){vr.set(t,e)}function xr(t){return vr.get(t)}var li=/^[dbclps\-][rwxsStT\-]{9}[@.+]?(?:\s|$)/;function ui(t){if(t<1024)return String(t);let e=["K","M","G","T"],r=t/1024,n=0;for(;r>=1024&&n<e.length-1;)r/=1024,n+=1;return`${r.toFixed(1)}${e[n]}`}function di(t){if(!li.test(t))return null;let e=t.split(/\s+/);if(e.length<9)return null;let r=Number(e[4]);if(!Number.isFinite(r))return null;let n=e.slice(8).join(" ").trim();if(n===""||n==="."||n==="..")return null;let s=e[0].charCodeAt(0)===100;return{name:n,size:r,isDir:s}}var fi=16;function pi(t){if(t.length<3)return null;let e=new Map;for(let s of t){let i=s.name.lastIndexOf(".");if(i<=0)continue;let a=s.name.slice(i);e.set(a,(e.get(a)??0)+1)}let r=null,n=0;for(let[s,i]of e)i>n&&(n=i,r=s);return r&&n>=Math.ceil(t.length/2)?`${n} ${r}`:null}function mi(t){let e=[],r=[],n=!1;for(let A of t){if(/^total\s+\d+/.test(A))continue;let O=di(A);O&&(n=!0,(O.isDir?e:r).push(O))}if(!n)return t;let s=(A,O)=>A.name.localeCompare(O.name);e.sort(s),r.sort((A,O)=>O.size-A.size||s(A,O));let a=e.slice(0,3),o=r.slice(0,Math.max(0,fi-a.length)),c=[...a,...o],l=e.length-a.length+(r.length-o.length),p=Math.min(40,Math.max(0,...c.map(A=>A.isDir?A.name.length+1:A.name.length))),y=[];for(let A of c){let O=A.isDir?`${A.name}/`:A.name,Fe=A.isDir?"":ui(A.size);y.push(Fe?`${O.padEnd(p)} ${Fe}`:O)}l>0&&y.push(`\u2026 ${l} more`);let w=r.length===1?"file":"files",T=e.length===1?"dir":"dirs",F=pi(r),G=`${r.length} ${w}, ${e.length} ${T}`+(F?` (${F})`:"");return y.push(G),y}H("smart-ls",mi);H("smart-read",t=>ot(t));var hi=12;function gi(t){let e=t.filter(l=>l.trim()!=="");if(e.length===0||e.filter(l=>!/\s/.test(l.trim())).length<e.length*.6)return t;let n=new Map,s=0;for(let l of e){let p=l.trim();if(/\s/.test(p))continue;let y=p.replace(/^\.\//,"").replace(/\/+$/,""),w=y.lastIndexOf("/"),T=w>=0?y.slice(0,w):"",F=w>=0?y.slice(w+1):y;if(!F)continue;let G=n.get(T)??[];G.push(F),n.set(T,G),s+=1}if(s===0)return t;let i=new Set([""]);for(let l of n.keys()){if(l==="")continue;let p=l.split("/");for(let y=1;y<=p.length;y+=1)i.add(p.slice(0,y).join("/"))}let a=[...i].sort(),o=a.filter(l=>l!=="").length,c=[`${s}F ${o}D:`,""];for(let l of a){let p=l===""?0:l.split("/").length,y=l===""?".":l.slice(l.lastIndexOf("/")+1),w=n.get(l)??[],T=w.slice(0,hi),F=w.length-T.length,G=T.length?` ${T.join(" ")}${F>0?` +${F}`:""}`:"";c.push(`${" ".repeat(p)}${y}/${G}`)}return c}H("smart-find",gi);var yi=/^[\s=]+$/,_i=/^\s*=+\s+(.*?)\s+=+\s*$/;H("strip-banners",t=>{let e=[];for(let r of t){if(yi.test(r))continue;let n=_i.exec(r);e.push(n?n[1]:r)}return e});function vi(t){let e=[],r=0,n=0;for(;n<t.length;){let s=t[n].replace(/\s+$/,"");if(s===""){r+=1,n+=1,r<=1&&e.push("");continue}r=0;let i=1;for(;n+i<t.length&&t[n+i].replace(/\s+$/,"")===s;)i+=1;if(i>=3)e.push(s),e.push(` \u2026 (repeated ${i}x)`);else for(let a=0;a<i;a++)e.push(s);n+=i}for(;e.length>0&&e[e.length-1]==="";)e.pop();return e}H("squeeze-output",vi);var br=new WeakMap;function xi(t){let e=br.get(t);if(e)return e;let r=t.strip_lines_matching.map(s=>new RegExp(s)),n={def:t,stripRegexes:r};return br.set(t,n),n}function wr(t,e,r={}){let n=xi(e),s=t;e.strip_ansi&&(s=dr(s));let i=s.split(`
12
- `);n.stripRegexes.length&&(i=fr(i,n.stripRegexes));let a=r.verbosity??"normal";if(a!=="normal"&&(i=yr(i),i=_r(i)),a==="minimal"&&(i=gr(i)),(r.smartCode||r.smartCode===void 0&&a!=="normal"&&hr(s))&&(i=ot(i)),e.transform){let c=xr(e.transform);c&&(i=c(i))}e.truncate_lines_at&&(i=pr(i,e.truncate_lines_at)),e.max_lines&&(i=mr(i,e.max_lines));let o=i.join(`
13
- `);return o.trim().length===0&&e.on_empty&&(o=e.on_empty),o}var bi=[/\bERROR\b/,/\bFAIL\b/,/\bFAILED\b/,/\bFATAL\b/,/^Traceback /m,/^Error: /m,/^\s+at .*\(.*:\d+:\d+\)/m,/panic:/,/SyntaxError:/,/TypeError:/,/ReferenceError:/,/thread '.*' panicked/];function kr(t){if(!t)return!1;let e=t.length<=262144*2?[t]:[t.slice(0,262144),t.slice(-262144)];for(let r of bi)for(let n of e)if(r.test(n))return!0;return!1}var Er=null;function Tt(t){Er=t}async function wi(t,e){let r=await ar();return ur(t,r.values(),e)}async function Sr(t,e,r,n={}){let s=Buffer.byteLength(e,"utf8"),{exitCode:i,...a}=n;if(i!=null?i!==0:kr(e))return{output:e,filterId:null,rawBytes:s,filteredBytes:s,debugBypass:!0};let l=await(Er??wi)(t,r);if(!l)return{output:e,filterId:null,rawBytes:s,filteredBytes:s,debugBypass:!1};let p=wr(e,l,a);return{output:p,filterId:l.slug,rawBytes:s,filteredBytes:Buffer.byteLength(p,"utf8"),debugBypass:!1}}be();be();Pe();Ve();Ge();K();import{readFile as ta,writeFile as ra,mkdir as na}from"node:fs/promises";Ge();Ve();Pe();import{createPublicKey as Bi,verify as Ui}from"node:crypto";function Vi(t,e){let r=Ot();if(!r||!r.includes("BEGIN PUBLIC KEY"))throw new Error("Tokmizer plugin: no valid signing public key. Set TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM or rebuild plugin against a prod key.");let n=Bi({key:r,format:"pem"});try{let s=Buffer.from(e,"base64url");return Ui(null,Buffer.from(t,"utf8"),n,s)}catch{return!1}}var Hi=/^[a-z0-9][a-z0-9-]*$/;async function $r(t){let e=await Ne();if(!e)throw new Error("Plugin not activated.");let r=await De(),n=await $e("GET","/api/v1/skills/bundle",void 0,{baseUrl:t,bearer:e.jwt,signingSecret:e.signingSecret,fingerprint:r.fingerprint,installId:r.installId,timeoutMs:8e3});if(!n.ok)throw new Error(`bundle fetch failed ${n.status}`);let s=await Ke(n),i=[];for(let a of s.bundles){if(!Hi.test(a.slug))throw new Error(`invalid bundle slug ${a.slug}`);let o=[...a.fragments].sort((c,l)=>c.position-l.position);for(let c of o)if(!Vi(c.body,c.hash))throw new Error(`fragment signature mismatch on ${a.slug}[${c.position}]`);i.push({slug:a.slug,version:a.version,body:o.map(c=>c.body).join(`
6
+ `});import{createHmac as ji,createPublicKey as zi,verify as Zi}from"node:crypto";function Dt(){return((process.env.TOKMIZER_DEV==="1"?process.env.TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM:void 0)??Fr).replace(/\\n/g,`
7
+ `)}function Ui(t,e,r,n){try{let s=zi({key:n,format:"pem"});return Zi(null,Buffer.from(`${e}.${t}`,"utf8"),s,Buffer.from(r,"base64url"))}catch{return!1}}async function Ge(t){let e=await t.text(),r=Dt(),n=t.headers?.get?.("x-tokmizer-resp-ts")??null;if(n!==null){let a=Number(n);if(!Number.isFinite(a)||Date.now()-a>Bi)throw new te("http","stale server response (resp-ts outside freshness window)")}if(!r||!r.includes("BEGIN PUBLIC KEY"))throw new te("http","no signing public key configured; refusing to trust server response");let s=t.headers?.get?.("x-tokmizer-resp-sig")??null,i=Number(n);if(!s||n===null||!Number.isFinite(i))throw new te("http","missing server response signature");if(!Ui(e,i,s,r))throw new te("http","invalid server response signature");return JSON.parse(e)}function Vi(t,e,r){return ji("sha256",r).update(`${e}.${t}`).digest("hex")}async function Pe(t,e,r,n){let s=Date.now(),i=r===void 0?"":JSON.stringify(r),a=n.signingSecret?Vi(i,s,n.signingSecret):"0".repeat(64),o={"content-type":"application/json","x-tokmizer-fingerprint":n.fingerprint,"x-tokmizer-install-id":n.installId,"x-tokmizer-sig":a,"x-tokmizer-ts":String(s),"x-tokmizer-plugin-version":Ke};n.bearer&&(o.authorization=`Bearer ${n.bearer}`);let c=n.timeoutMs??5e3,l=t!=="GET"&&t!=="DELETE",d={method:t,headers:o,signal:AbortSignal.timeout(c)};l&&(d.body=i);try{return await fetch(`${n.baseUrl}${e}`,d)}catch(v){let _=v.name;throw _==="TimeoutError"||_==="AbortError"?new te("timeout",`${t} ${e} timed out after ${c}ms`):new te("network",`${t} ${e} failed: ${v.message}`)}}var Bi,te,We=E(()=>{"use strict";Ot();jr();Bi=300*1e3;te=class extends Error{constructor(r,n,s){super(n);this.kind=r;this.status=s;this.name="TransportError"}kind;status}});function qe(t){let e=t;for(let[r,n]of fa)e=e.replace(r,n);return e}var fa,Ft=E(()=>{"use strict";fa=[[/(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]+-)*(?: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+.-]*:\/\/[^:/\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]"]]});import{join as Qr}from"node:path";import{appendFileSync as pa,chmodSync as ma,existsSync as ha,mkdirSync as ga,readFileSync as Zl,renameSync as Bl,rmdirSync as Ul,statSync as ya,unlinkSync as Vl,writeFileSync as Hl}from"node:fs";function en(){return Qr(T(),"spool")}function va(t){return Qr(en(),`${t}.jsonl`)}function ft(t,e){try{ga(en(),{recursive:!0,mode:448});let r=va(t);if(ha(r)&&ya(r).size>=_a)return;pa(r,JSON.stringify(e)+`
8
+ `,{mode:384}),ma(r,384)}catch{return}}var _a,jt=E(()=>{"use strict";V();He();Oe();We();_a=512*1024});function tn(t){let e=t.toLowerCase();return e.startsWith("git")||Ea.has(e)}function zt(t){let e=t.trim().split(/\s+/).filter(o=>o.length>0),r=0;for(;r<e.length&&ka.test(e[r]??"");)r+=1;let n=e[r];if(!n||!xa.test(n)||n.length>Ta||tn(n)||Sa.test(n)||qe(n)!==n)return"";let s=e[r+1];return s&&tn(s)?"":(s&&Aa.has(n.toLowerCase())&&wa.test(s)?`${n} ${s}`:n).slice(0,64)}async function rn(t){if(!t.telemetryOptIn)return;let e=zt(t.cmd),r=e&&qe(e)===e?e:"other";ft("telemetry",{cmd:r,tokensSaved:Math.max(0,Math.round(t.tokensSaved)),optimized:t.optimized})}var xa,wa,ka,Ea,Sa,Ta,Aa,Zt=E(()=>{"use strict";Ft();jt();xa=/^[a-z0-9][a-z0-9._-]*$/i,wa=/^[a-z][a-z-]+$/,ka=/^[A-Za-z_][A-Za-z0-9_]*=/,Ea=new Set(["gh","glab","gup","hub","gist"]),Sa=/^(gh[a-z]_|github_pat_|gl(?:pat|rt|soat|imt|dt|ft|agent|oas)-|npm_|xox|sk-|sk_|eyj|a(?:kia|sia|gpa|ida|roa|npa)|aiza|hv[sb]\.)/i,Ta=24,Aa=new Set(["docker","podman","npm","pnpm","yarn","npx","bun","deno","cargo","rustup","go","pip","pip3","uv","poetry","brew","apt","apt-get","dnf","yum","pacman","kubectl","helm","terraform","aws","gcloud","az","systemctl","composer","bundle","gem","dotnet","prisma","tkr","rtk","token"])});async function nn(t){if(t.plan!=="pro")return;let e=zt(t.cmd);!e||qe(e)!==e||ft("learn",{cmd:e,filterId:t.filterId==null?null:L(t.filterId),rawBytes:t.rawBytes,filteredBytes:t.filteredBytes})}var sn=E(()=>{"use strict";Zt();Ft();jt();ve()});function mn(t){return JSON.stringify(t)+pt}function*hn(t){let e=0;for(;;){let r=t.indexOf(pt,e);if(r<0)return;yield t.slice(e,r),e=r+1}}function mt(){return`${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var Fa,ja,za,Za,hu,gu,yu,pn,pt,_u,gn=E(()=>{"use strict";it();kt();Fa=h.object({id:h.string().min(1).max(64),op:h.literal("filter"),cmd:h.string().min(1).max(2048),plan:h.enum(["trial","smart","pro"]),installId:h.string().min(1).max(64).optional()}),ja=h.object({id:h.string().min(1).max(64),op:h.literal("ping")}),za=h.object({id:h.string().min(1).max(64),op:h.literal("shutdown"),installId:h.string().min(1).max(64)}),Za=h.object({id:h.string().min(1).max(64),op:h.literal("reload"),installId:h.string().min(1).max(64).optional()}),hu=h.discriminatedUnion("op",[Fa,ja,za,Za]),gu=h.object({id:h.string(),ok:h.literal(!0),data:h.unknown()}),yu=h.object({id:h.string(),ok:h.literal(!1),err:h.string(),retryAfterMs:h.number().int().nonnegative().optional()}),pn=h.object({filter:at.nullable(),cacheHit:h.boolean().optional()}),pt=`
9
+ `,_u=64*1024});import{join as Bt}from"node:path";import{existsSync as yn,statSync as Ba,unlinkSync as Ua,mkdirSync as Va,chmodSync as Ha}from"node:fs";function ht(){if(process.platform==="win32")return{path:`\\\\.\\pipe\\tokmizer-${process.env.USERNAME??"tokmizer"}`,isPipe:!0};let t=typeof process.getuid=="function"?process.getuid():0,e=process.env.XDG_RUNTIME_DIR;if(e&&yn(e))return{path:Bt(e,`tokmizer-${t}.sock`),isPipe:!1};let r=Bt(T(),"run");try{Va(r,{recursive:!0,mode:448}),Ha(r,448)}catch{}return{path:Bt(r,"daemon.sock"),isPipe:!1}}async function _n(){let{path:t,isPipe:e}=ht();if(e||!yn(t))return;try{if(!Ba(t).isSocket())return}catch{return}let r=await import("node:net");if(!await new Promise(s=>{let i=r.createConnection(t),a=o=>{i.removeAllListeners();try{i.destroy()}catch{}s(o)};i.once("connect",()=>a(!0)),i.once("error",o=>{let c=o.code;a(c!=="ECONNREFUSED"&&c!=="ENOENT")}),setTimeout(()=>a(!0),250)}))try{Ua(t)}catch{}}var ku,vn=E(()=>{"use strict";V();ku=5*6e4});import{createConnection as Ka}from"node:net";import{spawn as Ga}from"node:child_process";import{existsSync as Sn,openSync as bn,closeSync as Wa,unlinkSync as xn,writeFileSync as wn}from"node:fs";import{dirname as qa,join as Ya}from"node:path";import{fileURLToPath as Ja}from"node:url";async function eo(t,e){return new Promise((r,n)=>{let s=Ka(t),i=o=>{if(s.removeAllListeners("connect"),s.removeAllListeners("error"),clearTimeout(a),o){try{s.destroy()}catch{}n(o)}else r(s)},a=setTimeout(()=>i(new Error("connect timeout")),e);s.once("connect",()=>i(null)),s.once("error",o=>i(o))})}function to(){return process.env.TOKMIZER_DAEMON_BIN?process.env.TOKMIZER_DAEMON_BIN:Ja(new URL("../bin/tkr-daemon.js",import.meta.url))}async function En(t,e=3e3){let r=Math.ceil(e/75);for(let n=0;n<r;n++){if(Sn(t))return!0;await new Promise(s=>setTimeout(s,75))}return!1}async function ro(t){let e=to();if(!Sn(e))throw new Error(`tkr-daemon binary not found at ${e}`);let{path:r}=ht(),n=Ya(qa(r),"daemon.spawn.lock"),s=null;try{s=bn(n,"wx"),wn(s,String(process.pid))}catch(i){if(i.code==="EEXIST"){if(await En(r,5e3))return;try{xn(n)}catch{}s=bn(n,"wx"),wn(s,String(process.pid))}else throw i}try{if(Ga(process.execPath,[e],{detached:!0,stdio:["ignore","ignore","ignore"],env:{...process.env,TOKMIZER_DAEMON_INSTALL_ID:t}}).unref(),!await En(r,3e3))throw new Error("tkr-daemon failed to bind socket within 3s")}finally{if(s!==null){try{Wa(s)}catch{}try{xn(n)}catch{}}}}async function Tn(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:ht(),r=await Ct(),n=null,s=0;for(;s<=kn;)try{n=await eo(e,Xa);break}catch{if(s+=1,s>kn)throw new Error(`tkr-daemon unreachable at ${e}`);await _n(),await ro(r)}if(!n)throw new Error("tkr-daemon: socket setup failed");let i=new Map,a="";n.setEncoding("utf8"),n.on("data",c=>{a+=c;let l=-1;for(let v=0;v<a.length;v++)a[v]===pt&&(l=v);if(l<0)return;let d=[];for(let v of hn(a.slice(0,l+1)))d.push(v);a=a.slice(l+1);for(let v of d)if(v)try{let _=JSON.parse(v),k=i.get(_.id);if(!k)continue;clearTimeout(k.timer),i.delete(_.id),k.resolve(_)}catch{}}),n.on("close",()=>{for(let c of i.values())clearTimeout(c.timer),c.reject(new Error("daemon socket closed"));i.clear()}),n.on("error",()=>{});function o(c){return new Promise((l,d)=>{let v=setTimeout(()=>{i.delete(c.id),d(new Error(`daemon request timeout (${c.op})`))},Qa);i.set(c.id,{resolve:l,reject:d,timer:v}),n.write(mn(c))})}return{filter:async(c,l)=>{let d=await o({id:mt(),op:"filter",cmd:c.slice(0,2048),plan:l,installId:r});if(!d.ok)return null;let v=pn.safeParse(d.data);return v.success?v.data.filter:null},ping:async()=>{let c=await o({id:mt(),op:"ping"});if(!c.ok)throw new Error(c.err);return c.data},reload:async()=>{let c=await o({id:mt(),op:"reload",installId:r});if(!c.ok)throw new Error(c.err);return c.data},close:()=>{try{n.end()}catch{}}}}var Xa,Qa,kn,An=E(()=>{"use strict";gn();vn();Oe();Xa=500,Qa=3e3,kn=1});import{spawn as co}from"node:child_process";import{spawn as io}from"node:child_process";kt();import{readdir as Hs,readFile as Ks}from"node:fs/promises";import{join as lr,dirname as Gs}from"node:path";import{fileURLToPath as Ws}from"node:url";var qs=Gs(Ws(import.meta.url)),or=lr(qs,"..","..","filters"),Q=null,cr=!1;function Ys(){return process.env.TOKMIZER_DEV==="1"||process.env.TOKMIZER_DEV==="true"}async function ur(){if(Q)return Q;if(!Ys())return!cr&&process.env.TOKMIZER_DEBUG==="1"&&(process.stderr.write(`tokmizer: disk loader disabled (set TOKMIZER_DEV=1 to re-enable for local dev).
10
+ `),cr=!0),Q=new Map,Q;let t=new Map,e,r;try{e=(await import("smol-toml")).parse,r=(await Hs(or)).filter(n=>n.endsWith(".toml"))}catch{return Q=t,Q}for(let n of r){let s=await Ks(lr(or,n),"utf8"),a=e(s).filters;if(a)for(let[o,c]of Object.entries(a)){let l=at.parse({slug:o,...c});t.set(o,{...l,matchRegex:new RegExp(l.match_command)})}}return Q=t,Q}ve();var Ze=new Map,ri=256,pr=new WeakMap;function ni(t){if(!t)return"*";let e=pr.get(t);return e===void 0&&(e=[...t].join(","),pr.set(t,e)),e}function mr(t,e,r){let n=`${t}::${ni(r)}`,s=Ze.get(n);if(s!==void 0)return s;let i=null;for(let a of e)r&&!r.has(L(a.slug))||a.matchRegex.test(t)&&(!i||a.priority>i.priority)&&(i=a);if(Ze.size>=ri){let a=Ze.keys().next().value;a&&Ze.delete(a)}return Ze.set(n,i),i}var si=/\x1b\[[0-9;?]*[ -/]*[@-~]/g,ii=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g;function hr(t){return t.replace(si,"").replace(ii,"")}function gr(t,e){return e.length===0?t:t.filter(r=>!e.some(n=>n.test(r)))}function yr(t,e){return t.map(r=>r.length<=e?r:`${r.slice(0,e)}\u2026`)}function _r(t,e){if(t.length<=e)return t;let r=t.length-e;return[...t.slice(0,e),`\u2026 (${r} more lines omitted)`]}var ai=/^(\s*)(?:export\s+)?(?:async\s+)?(?:function|interface|type|const|let|var|def|fn|impl|trait|struct|enum)\s+[\w$]+/,oi=/\{\s*$/;var ci=/^\s*(?:(?:public|private|protected|static|async|get|set|readonly|override)\s+)*([\w$]+)\s*\(([^)]*)\)\s*(?::\s*[^{]+)?\{\s*$/,li=new Set(["if","for","while","switch","catch","do","with","return","else","function","await","yield"]);function ui(t){let e=ci.exec(t);return!e||li.has(e[1])?!1:!/=>|\bfunction\b/.test(e[2])}var di=/^\s*(?:if|for|while|switch|try|do)\b[^{}]*\{\s*$/;function fi(t,e){let r=0,n=null,s=0;for(;s<t.length;){let i=t[s];if(e.inBlockComment){if(i==="*"&&t[s+1]==="/"){e.inBlockComment=!1,s+=2;continue}s+=1;continue}if(e.inTemplate){if(i==="\\"){s+=2;continue}i==="`"&&(e.inTemplate=!1),s+=1;continue}if(n){if(i==="\\"){s+=2;continue}i===n&&(n=null),s+=1;continue}if(i==="/"&&t[s+1]==="/")break;if(i==="/"&&t[s+1]==="*"){e.inBlockComment=!0,s+=2;continue}if(i==="`"){e.inTemplate=!0,s+=1;continue}if(i==="'"||i==='"'){n=i,s+=1;continue}i==="{"||i==="("||i==="["?r+=1:(i==="}"||i===")"||i==="]")&&(r-=1),s+=1}return r}function ct(t){let e=[],r=0;for(;r<t.length;){let n=t[r];if(ai.test(n)&&oi.test(n)||ui(n)||di.test(n)){let s={inBlockComment:!1,inTemplate:!1},i=0,a=r,o=!1;for(;a<t.length&&a-r<200;)if(i+=fi(t[a],s),a+=1,i<=0&&!s.inTemplate&&!s.inBlockComment){o=!0;break}if(o){e.push(`${n.replace(/\{\s*$/,"")}{ \u2026 }`),r=a;continue}}e.push(n),r+=1}return e}var pi=/\b(?:function|class|interface|import\s+|export\s+|def\s+|fn\s+|impl\s+|package\s+|namespace\s+|using\s+|#include|=>\s*\{|=\s*function)/;function vr(t){let e=t.slice(0,4096);return!(!pi.test(e)||e.split(`
11
+ `).length<6)}var mi=/\b(?:DEBUG|TRACE|INFO|VERBOSE)\b/;function br(t){return t.filter(e=>!mi.test(e))}function xr(t){if(t.length===0)return t;let e=[],r=1,n=t[0];for(let s=1;s<t.length;s++){if(t[s]===n){r+=1;continue}e.push(r>1?`${n} \xD7${r}`:n),n=t[s],r=1}return e.push(r>1?`${n} \xD7${r}`:n),e}function wr(t){let e=[],r=0;for(let n of t){if(n.trim()===""){r+=1;continue}r>0&&e.push(""),r=0,e.push(n)}return e}var kr=new Map;function U(t,e){kr.set(t,e)}function Er(t){return kr.get(t)}var hi=/^[dbclps\-][rwxsStT\-]{9}[@.+]?(?:\s|$)/,gi=/^[./~][^\s]*:$/,St=1e3;function yi(t){if(t<1024)return String(t);let e=["K","M","G","T"],r=t/1024,n=0;for(;r>=1024&&n<e.length-1;)r/=1024,n+=1;return`${r.toFixed(1)}${e[n]}`}function _i(t){if(!hi.test(t))return null;let e=t.split(/\s+/);if(e.length<9)return null;let r=Number(e[4]);if(!Number.isFinite(r))return null;let n=e.slice(8).join(" ").trim();if(n===""||n==="."||n==="..")return null;let s=e[0].charCodeAt(0)===100;return{name:n,size:r,isDir:s}}function vi(t){if(t.length<3)return null;let e=new Map;for(let s of t){let i=s.name.lastIndexOf(".");if(i<=0)continue;let a=s.name.slice(i);e.set(a,(e.get(a)??0)+1)}let r=null,n=0;for(let[s,i]of e)i>n&&(n=i,r=s);return r&&n>=Math.ceil(t.length/2)?`${n} ${r}`:null}function bi(t){let e=[],r=[],n=!1;for(let _ of t){if(/^total\s+\d+/.test(_))continue;if(gi.test(_.trim()))return t;let k=_i(_);k&&(n=!0,(k.isDir?e:r).push(k))}if(!n)return t;let s=(_,k)=>_.name.localeCompare(k.name);e.sort(s),r.sort((_,k)=>k.size-_.size||s(_,k));let i=[...e,...r],a=Math.min(40,Math.max(0,...i.map(_=>_.isDir?_.name.length+1:_.name.length))),o=[];for(let _ of i){let k=_.isDir?`${_.name}/`:_.name,F=_.isDir?"":yi(_.size);o.push(F?`${k.padEnd(a)} ${F}`:k)}if(o.length>St){let _=o.length-St;o=[...o.slice(0,St),`\u2026 ${_} more lines omitted`]}let c=r.length===1?"file":"files",l=e.length===1?"dir":"dirs",d=vi(r),v=`${r.length} ${c}, ${e.length} ${l}`+(d?` (${d})`:"");return o.push(v),o}U("smart-ls",bi);U("smart-read",t=>ct(t));var Tt=1e3;function xi(t){let e=t.filter(d=>d.trim()!=="");if(e.length===0||e.filter(d=>!/\s/.test(d.trim())).length<e.length*.6)return t;let n=new Map,s=[],i=0;for(let d of e){let v=d.trim();if(v.startsWith("find:")){s.push(v);continue}let _=v.replace(/^\.\//,"").replace(/\/+$/,""),k=_.lastIndexOf("/"),F=k>=0?_.slice(0,k):"",re=k>=0?_.slice(k+1):_;if(!re)continue;let Me=n.get(F)??[];Me.push(/\s/.test(re)?`"${re}"`:re),n.set(F,Me),i+=1}if(i===0)return t;let a=new Set([""]);for(let d of n.keys()){if(d==="")continue;let v=d.split("/");for(let _=1;_<=v.length;_+=1)a.add(v.slice(0,_).join("/"))}let o=[...a].sort(),c=o.filter(d=>d!=="").length,l=[`${i}F ${c}D:`,""];for(let d of o){let v=d===""?0:d.split("/").length,_=d===""?".":d.slice(d.lastIndexOf("/")+1),k=n.get(d)??[],F=k.length?` ${k.join(" ")}`:"";l.push(`${" ".repeat(v)}${_}/${F}`)}if(l.push(...s),l.length>Tt){let d=l.length-Tt;return[...l.slice(0,Tt),`\u2026 ${d} more lines omitted`]}return l}U("smart-find",xi);var wi=/^[\s=]+$/,ki=/^\s*=+\s+(.*?)\s+=+\s*$/;U("strip-banners",t=>{let e=[];for(let r of t){if(wi.test(r))continue;let n=ki.exec(r);e.push(n?n[1]:r)}return e});function Ei(t){let e=[],r=0,n=0;for(;n<t.length;){let s=t[n].replace(/\s+$/,"");if(s===""){r+=1,n+=1,r<=1&&e.push("");continue}r=0;let i=1;for(;n+i<t.length&&t[n+i].replace(/\s+$/,"")===s;)i+=1;if(i>=3)e.push(s),e.push(` \u2026 (repeated ${i}x)`);else for(let a=0;a<i;a++)e.push(s);n+=i}for(;e.length>0&&e[e.length-1]==="";)e.pop();return e}U("squeeze-output",Ei);var Sr=new WeakMap;function Si(t){let e=Sr.get(t);if(e)return e;let r=t.strip_lines_matching.map(s=>new RegExp(s)),n={def:t,stripRegexes:r};return Sr.set(t,n),n}function Tr(t,e,r={}){let n=Si(e),s=t;e.strip_ansi&&(s=hr(s));let i=s.split(`
12
+ `);n.stripRegexes.length&&(i=gr(i,n.stripRegexes));let a=r.verbosity??"normal";if(a!=="normal"&&(i=xr(i),i=wr(i)),a==="minimal"&&(i=br(i)),(r.smartCode||r.smartCode===void 0&&a!=="normal"&&vr(s))&&(i=ct(i)),e.transform){let c=Er(e.transform);c&&(i=c(i))}e.truncate_lines_at&&(i=yr(i,e.truncate_lines_at)),e.max_lines&&(i=_r(i,e.max_lines));let o=i.join(`
13
+ `);return o.trim().length===0&&e.on_empty&&(o=e.on_empty),o}var Ti=[/\bERROR\b/,/\bFAIL\b/,/\bFAILED\b/,/\bFATAL\b/,/^Traceback /m,/^Error: /m,/^\s+at .*\(.*:\d+:\d+\)/m,/panic:/,/SyntaxError:/,/TypeError:/,/ReferenceError:/,/thread '.*' panicked/];function Ar(t){if(!t)return!1;let e=t.length<=262144*2?[t]:[t.slice(0,262144),t.slice(-262144)];for(let r of Ti)for(let n of e)if(r.test(n))return!0;return!1}var Rr=null;function At(t){Rr=t}async function Ai(t,e){let r=await ur();return mr(t,r.values(),e)}async function Ir(t,e,r,n={}){let s=Buffer.byteLength(e,"utf8"),{exitCode:i,...a}=n;if(i!=null?i!==0:Ar(e))return{output:e,filterId:null,rawBytes:s,filteredBytes:s,debugBypass:!0};let l=await(Rr??Ai)(t,r);if(!l)return{output:e,filterId:null,rawBytes:s,filteredBytes:s,debugBypass:!1};let d=Tr(e,l,a);return{output:d,filterId:l.slug,rawBytes:s,filteredBytes:Buffer.byteLength(d,"utf8"),debugBypass:!1}}ve();ve();Oe();He();We();V();import{readFile as sa,writeFile as ia,mkdir as aa}from"node:fs/promises";We();He();Oe();import{createPublicKey as Hi,verify as Ki}from"node:crypto";function Gi(t,e){let r=Dt();if(!r||!r.includes("BEGIN PUBLIC KEY"))throw new Error("Tokmizer plugin: no valid signing public key. Set TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM or rebuild plugin against a prod key.");let n=Hi({key:r,format:"pem"});try{let s=Buffer.from(e,"base64url");return Ki(null,Buffer.from(t,"utf8"),n,s)}catch{return!1}}var Wi=/^[a-z0-9][a-z0-9-]*$/;async function zr(t){let e=await De();if(!e)throw new Error("Plugin not activated.");let r=await Ce(),n=await Pe("GET","/api/v1/skills/bundle",void 0,{baseUrl:t,bearer:e.jwt,signingSecret:e.signingSecret,fingerprint:r.fingerprint,installId:r.installId,timeoutMs:8e3});if(!n.ok)throw new Error(`bundle fetch failed ${n.status}`);let s=await Ge(n),i=[];for(let a of s.bundles){if(!Wi.test(a.slug))throw new Error(`invalid bundle slug ${a.slug}`);let o=[...a.fragments].sort((c,l)=>c.position-l.position);for(let c of o)if(!Gi(c.body,c.hash))throw new Error(`fragment signature mismatch on ${a.slug}[${c.position}]`);i.push({slug:a.slug,version:a.version,body:o.map(c=>c.body).join(`
14
14
 
15
- `)})}return i}K();import{mkdir as Dt,readFile as Ki,writeFile as Pt,stat as Gi,readdir as Mr,rm as Lr}from"node:fs/promises";var Wi="managed-by: tokmizer",qi=3600*1e3,Yi=10080*60*1e3;function Ji(){let t=Number(process.env.TOKMIZER_MAX_BUNDLE_AGE_MS);return Number.isFinite(t)&&t>0?t:Yi}async function Fr(t){try{let e=await Gi(lt(t)),r=Date.now()-e.mtimeMs;return r<qi&&r<=Ji()}catch{return!1}}async function jr(t,e){await Dt(ct(),{recursive:!0}),await Pt(lt(t),e,{mode:384})}async function zr(t){let e=new Set(t),r;try{r=await Mr(ct())}catch{return}for(let n of r){if(!n.endsWith(".md"))continue;let s=n.slice(0,-3);if(!e.has(s))try{await Lr(lt(s))}catch{}}}async function Zr(t,e){await Dt(ut(),{recursive:!0}),await Pt(dt(t),e,{mode:384})}async function Br(t){let e=new Set(t),r;try{r=await Mr(ut())}catch{return}for(let n of r){if(!n.endsWith(".md"))continue;let s=n.slice(0,-3);if(!e.has(s))try{if(!(await Ki(dt(s),"utf8")).includes(Wi))continue;await Lr(dt(s))}catch{}}}async function Nt(t){try{await Dt(S(),{recursive:!0}),await Pt(Rr(),JSON.stringify({at:Date.now(),error:t}),{mode:384})}catch{}}Ve();Pe();Ge();be();K();import{readFile as Xi,writeFile as il,mkdir as al,chmod as ol}from"node:fs/promises";import{join as Qi}from"node:path";var ea="settings-cache.json",Ur=St.parse({});async function Vr(){try{let t=await Xi(Qi(S(),ea),"utf8"),e=JSON.parse(t);return St.parse({...Ur,...e})}catch{return Ur}}Ct();var Hr="-command";async function sa(t,e){if(!(!e&&await Fr("power")))try{let r=await $r(t),n=[],s=[];for(let i of r)if(i.slug.endsWith(Hr)){let a=i.slug.slice(0,-Hr.length);await Zr(a,i.body),s.push(a)}else await jr(i.slug,i.body),n.push(i.slug);await zr(n),await Br(s),await Nt(null)}catch(r){await Nt(r instanceof Error?r.message:String(r))}}var ia=5*6e4;function aa(){return process.env.TOKMIZER_BASE_URL??"https://tokmizer.com"}async function oa(t){let e=await De(),r=ft(),n={pluginVersion:He,timeZone:r,...e},s=await $e("POST","/api/v1/license/enroll",n,{baseUrl:t,fingerprint:e.fingerprint,installId:e.installId,timeoutMs:4e3});if(!s.ok)throw new Error(`enroll failed ${s.status}`);let i=await Ke(s),a={token:i.token,jwt:i.jwt,signingSecret:i.signingSecret,plan:i.plan,status:i.status,trialEndsAt:i.trialEndsAt,subEndsAt:i.subEndsAt,jwtVersion:i.jwtVersion,installId:e.installId,fingerprint:e.fingerprint,pluginVersion:He,email:"",timeZone:r,bonusActive:!1,lastHeartbeatOkAt:Date.now()};return await Dr(a),await sa(t,!0),a}async function Kr(t){let e=await Ne();if(e)return e;let r=Ar();try{let n=await ta(r,"utf8"),s=Number(n);if(Number.isFinite(s)&&Date.now()-s<ia)return null}catch{}try{return await oa(t??aa())}catch{return await na(S(),{recursive:!0}),await ra(r,String(Date.now()),{mode:384}),null}}function ca(){let t=Number(process.env.TOKMIZER_OFFLINE_GRACE_MS);return Number.isFinite(t)&&t>0?t:6048e5}function $t(t,e=Date.now()){let r=t.lastHeartbeatOkAt;if(typeof r=="number"&&e-r>ca())return!0;if(t.subEndsAt){let n=Date.parse(t.subEndsAt);if(Number.isFinite(n)&&e>n)return!0}return!1}function Gr(t,e=Date.now()){return $t(t,e)?"free":t.plan}Qr();jt();K();import{appendFileSync as Ea,chmodSync as Sa,mkdirSync as Ta}from"node:fs";import{join as Aa}from"node:path";var Ra="stats.jsonl";function Ia(){return Aa(S(),Ra)}function en(t,e,r=Ia()){if(t<=0||e<0||e>t)return;let n=`{"t":${Math.floor(Date.now()/1e3)},"r":${t},"f":${e}}
16
- `;try{Ta(S(),{recursive:!0,mode:448}),Ea(r,n,{mode:384}),Sa(r,384)}catch{return}}function tn(t,e,r){let n=r!=null?Math.min(t,r):t,s=Math.min(e,n);return{raw:n,filtered:s}}var Ca=[{host:"claude-code",vars:["CLAUDE_CODE","CLAUDE_CODE_VERSION","ANTHROPIC_CLAUDE_CODE"]},{host:"codex",vars:["CODEX_VERSION","CODEX_CLI","OPENAI_CODEX"]},{host:"cursor",vars:["CURSOR_VERSION","CURSOR_TRACE_ID"]},{host:"cline",vars:["CLINE_VERSION","CLINE_API_KEY"]},{host:"aider",vars:["AIDER_VERSION","AIDER_MODEL"]},{host:"gemini-cli",vars:["GEMINI_CLI_VERSION","GEMINI_API_KEY"]},{host:"windsurf",vars:["WINDSURF_VERSION","WINDSURF_USER"]},{host:"copilot",vars:["GITHUB_COPILOT_VERSION","COPILOT_INTEGRATION_ID"]}],rn=new Set(["claude-code","codex"]),Oa=3e4;function nn(t){return rn.has(t)?Oa:null}function sn(t=process.env){let e=process.platform,r=e==="darwin"||e==="linux"||e==="win32"?e:"other",n=process.arch;for(let s of Ca)if(s.vars.some(i=>t[i]))return{host:s.host,source:"env",os:r,arch:n,shimRecommended:!rn.has(s.host)};return{host:"shell",source:"fallback",os:r,arch:n,shimRecommended:!0}}import{delimiter as an,join as Da}from"node:path";K();function Pa(){return Da(S(),"shims")}function on(){let t=Pa(),e={...process.env},r=process.platform==="win32"?"Path":"PATH",s=(e[r]??e.PATH??"").split(an).filter(i=>i&&i!==t);return e[r]=s.join(an),r==="Path"&&(e.PATH=e[r]),e}wn();be();var Me=null,qe=null;async function Qa(){return Me||qe||(qe=bn().then(t=>(Me=t,t)).catch(()=>null),qe)}function eo(t){return t?{...t,matchRegex:new RegExp(t.match_command)}:null}function kn(t){Tt(async(e,r)=>{let n=await Qa();if(!n)return null;try{let s=t==="free"?"trial":t,i=await n.filter(e,s);return!i||!(r??at(void 0)).has(z(i.slug))?null:eo(i)}catch{return null}})}function En(){if(Tt(null),Me){try{Me.close()}catch{}Me=null,qe=null}}var Le=10*1024*1024,ro=Number(process.env.TOKMIZER_EXEC_TIMEOUT_MS??"600000"),no={SIGHUP:1,SIGINT:2,SIGQUIT:3,SIGILL:4,SIGTRAP:5,SIGABRT:6,SIGBUS:7,SIGFPE:8,SIGKILL:9,SIGUSR1:10,SIGSEGV:11,SIGUSR2:12,SIGPIPE:13,SIGALRM:14,SIGTERM:15};function Zt(t){return no[t]??15}async function Sn(t){let[e,...r]=t;if(!e)throw new Error("tkr-exec: missing command");let n=to(e,r,{stdio:["inherit","pipe","pipe"],env:on()}),s=!1;n.on("spawn",()=>{s=!0});let i=E=>{try{n.kill(E)}catch{}};process.on("SIGINT",()=>i("SIGINT")),process.on("SIGTERM",()=>i("SIGTERM"));let a=[],o=[],c=0,l=0,p=!1,y=!1;n.stdout.on("data",E=>{if(c>=Le){p=!0;return}let R=Le-c,N=E.length>R?E.subarray(0,R):E;a.push(N),c+=N.length,E.length>R&&(p=!0)}),n.stderr.on("data",E=>{if(l>=Le){y=!0;return}let R=Le-l,N=E.length>R?E.subarray(0,R):E;o.push(N),l+=N.length,E.length>R&&(y=!0)});let w,T=await new Promise((E,R)=>{n.on("error",N=>{w&&clearTimeout(w),s?E(1):R(N)}),n.on("close",(N,we)=>{w&&clearTimeout(w),E(N??(we?128+Zt(we):0))}),w=setTimeout(()=>{n.kill("SIGTERM"),setTimeout(()=>n.kill("SIGKILL"),2e3)},ro),w.unref?.()}),F=Buffer.concat(a).toString("utf8"),G=Buffer.concat(o).toString("utf8"),A=p?`
17
- \u2026 (output truncated at ${Le/(1024*1024)}MB)`:"",O=y?G+`
18
- \u2026 (stderr truncated at ${Le/(1024*1024)}MB)`:G,Fe=()=>{let E=F+A,R=Buffer.byteLength(E,"utf8");return{stdout:E,stderr:O,code:T,filterId:null,rawBytes:R,filteredBytes:R,truncated:p}};try{let E=await Kr(),R=await Vr();if(!R.enabled)return Fe();let N=E?Gr(E):null,we=E?at(E.allowedFilters,$t(E)):null,Bt=new Set(R.filters.disabled.map(z)),Tn=we&&Bt.size>0?new Set([...we].filter(An=>!Bt.has(An))):we,yt=t.join(" ");E&&kn(N);let Z=await Sr(yt,F,Tn,{verbosity:R.outputVerbosity,exitCode:T}),Ye=tn(Z.rawBytes,Z.filteredBytes,nn(sn().host));return en(Ye.raw,Ye.filtered),await Xr({cmd:yt,filterId:Z.filterId,rawBytes:Z.rawBytes,filteredBytes:Z.filteredBytes,plan:N}),await Jr({cmd:yt,tokensSaved:Math.round((Ye.raw-Ye.filtered)/4),optimized:Z.filterId!=null,telemetryOptIn:R.telemetryOptIn}),{stdout:Z.output+A,stderr:O,code:T,filterId:Z.filterId,rawBytes:Z.rawBytes,filteredBytes:Z.filteredBytes,truncated:p}}catch{return Fe()}finally{En()}}async function io(t){let[e,...r]=t;e||process.exit(2);let n=so(e,r,{stdio:"inherit"}),s=await new Promise(i=>{n.on("error",()=>i(127)),n.on("close",(a,o)=>i(a??(o?128+Zt(o):0)))});process.exit(s)}async function ao(){let t=process.argv.slice(2);t.length===0&&(process.stderr.write(`tkr-exec: missing command
19
- `),process.exit(2));let e;try{e=await Sn(t)}catch(r){return process.stderr.write(`tkr-exec: ${r.message??r}
20
- `),io(t)}e.stdout&&process.stdout.write(e.stdout),e.stderr&&process.stderr.write(e.stderr),process.exitCode=e.code}ao().catch(t=>{process.stderr.write(`${t.message??t}
15
+ `)})}return i}V();import{chmod as Pt,mkdir as Nt,readFile as qi,writeFile as $t,stat as Yi,readdir as Zr,rm as Br}from"node:fs/promises";var Ji="managed-by: tokmizer",Xi=3600*1e3,Qi=10080*60*1e3;function ea(){let t=Number(process.env.TOKMIZER_MAX_BUNDLE_AGE_MS);return Number.isFinite(t)&&t>0?t:Qi}async function Ur(t){try{let e=await Yi(Ue(t)),r=Date.now()-e.mtimeMs;return r<Xi&&r<=ea()}catch{return!1}}async function Vr(t,e){await Nt(lt(),{recursive:!0}),await $t(Ue(t),e,{mode:384}),await Pt(Ue(t),384)}async function Hr(t){let e=new Set(t),r;try{r=await Zr(lt())}catch{return}for(let n of r){if(!n.endsWith(".md"))continue;let s=n.slice(0,-3);if(!e.has(s))try{await Br(Ue(s))}catch{}}}async function Kr(t,e){await Nt(ut(),{recursive:!0}),await $t(Ve(t),e,{mode:384}),await Pt(Ve(t),384)}async function Gr(t){let e=new Set(t),r;try{r=await Zr(ut())}catch{return}for(let n of r){if(!n.endsWith(".md"))continue;let s=n.slice(0,-3);if(!e.has(s))try{if(!(await qi(Ve(s),"utf8")).includes(Ji))continue;await Br(Ve(s))}catch{}}}async function Mt(t){try{await Nt(T(),{recursive:!0}),await $t(Rt(),JSON.stringify({at:Date.now(),error:t}),{mode:384}),await Pt(Rt(),384)}catch{}}He();Oe();We();ve();V();import{readFile as ta,writeFile as ll,mkdir as ul,chmod as dl}from"node:fs/promises";import{join as ra}from"node:path";var na="settings-cache.json",Wr=Et.parse({});async function qr(){try{let t=await ta(ra(T(),na),"utf8"),e=JSON.parse(t);return Et.parse({...Wr,...e})}catch{return Wr}}Ot();var Yr="-command";async function oa(t,e){if(!(!e&&await Ur("power")))try{let r=await zr(t),n=[],s=[];for(let i of r)if(i.slug.endsWith(Yr)){let a=i.slug.slice(0,-Yr.length);await Kr(a,i.body),s.push(a)}else await Vr(i.slug,i.body),n.push(i.slug);await Hr(n),await Gr(s),await Mt(null)}catch(r){await Mt(r instanceof Error?r.message:String(r))}}var ca=5*6e4;function la(){return process.env.TOKMIZER_BASE_URL??"https://tokmizer.com"}async function ua(t){let e=await Ce(),r=dt(),n={pluginVersion:Ke,timeZone:r,...e},s=await Pe("POST","/api/v1/license/enroll",n,{baseUrl:t,fingerprint:e.fingerprint,installId:e.installId,timeoutMs:4e3});if(!s.ok)throw new Error(`enroll failed ${s.status}`);let i=await Ge(s),a={token:i.token,jwt:i.jwt,signingSecret:i.signingSecret,plan:i.plan,status:i.status,trialEndsAt:i.trialEndsAt,subEndsAt:i.subEndsAt,jwtVersion:i.jwtVersion,installId:e.installId,fingerprint:e.fingerprint,pluginVersion:Ke,email:"",timeZone:r,bonusActive:!1,linked:!1,lastHeartbeatOkAt:Date.now()};return await Lr(a),await oa(t,!0),a}async function Jr(t){let e=await De();if(e)return e;let r=Or();try{let n=await sa(r,"utf8"),s=Number(n);if(Number.isFinite(s)&&Date.now()-s<ca)return null}catch{}try{return await ua(t??la())}catch{return await aa(T(),{recursive:!0}),await ia(r,String(Date.now()),{mode:384}),null}}function da(){let t=Number(process.env.TOKMIZER_OFFLINE_GRACE_MS);return Number.isFinite(t)&&t>0?t:6048e5}function Lt(t,e=Date.now()){let r=t.lastHeartbeatOkAt;if(typeof r=="number"&&e-r>da())return!0;if(t.subEndsAt){let n=Date.parse(t.subEndsAt);if(Number.isFinite(n)&&e>n)return!0}return!1}function Xr(t,e=Date.now()){return Lt(t,e)?"free":t.plan}sn();Zt();V();import{appendFileSync as Ra,chmodSync as Ia,mkdirSync as Ca}from"node:fs";import{join as Oa}from"node:path";var Da="stats.jsonl";function Pa(){return Oa(T(),Da)}function an(t,e,r=Pa()){if(t<=0||e<0||e>t)return;let n=`{"t":${Math.floor(Date.now()/1e3)},"r":${t},"f":${e}}
16
+ `;try{Ca(T(),{recursive:!0,mode:448}),Ra(r,n,{mode:384}),Ia(r,384)}catch{return}}function on(t,e,r){let n=r!=null?Math.min(t,r):t,s=Math.min(e,n);return{raw:n,filtered:s}}var Na=[{host:"claude-code",vars:["CLAUDE_CODE","CLAUDE_CODE_VERSION","ANTHROPIC_CLAUDE_CODE"]},{host:"codex",vars:["CODEX_VERSION","CODEX_CLI","OPENAI_CODEX"]},{host:"cursor",vars:["CURSOR_VERSION","CURSOR_TRACE_ID"]},{host:"cline",vars:["CLINE_VERSION","CLINE_API_KEY"]},{host:"aider",vars:["AIDER_VERSION","AIDER_MODEL"]},{host:"gemini-cli",vars:["GEMINI_CLI_VERSION","GEMINI_API_KEY"]},{host:"windsurf",vars:["WINDSURF_VERSION","WINDSURF_USER"]},{host:"copilot",vars:["GITHUB_COPILOT_VERSION","COPILOT_INTEGRATION_ID"]}],cn=new Set(["claude-code","codex"]),$a=3e4;function ln(t){return cn.has(t)?$a:null}function un(t=process.env){let e=process.platform,r=e==="darwin"||e==="linux"||e==="win32"?e:"other",n=process.arch;for(let s of Na)if(s.vars.some(i=>t[i]))return{host:s.host,source:"env",os:r,arch:n,shimRecommended:!cn.has(s.host)};return{host:"shell",source:"fallback",os:r,arch:n,shimRecommended:!0}}import{delimiter as dn,join as Ma}from"node:path";V();function La(){return Ma(T(),"shims")}function fn(){let t=La(),e={...process.env},r=process.platform==="win32"?"Path":"PATH",s=(e[r]??e.PATH??"").split(dn).filter(i=>i&&i!==t);return e[r]=s.join(dn),r==="Path"&&(e.PATH=e[r]),e}An();ve();var Ne=null,Ye=null;async function no(){if(Ne)return Ne;if(Ye)return Ye;let t=Tn().then(e=>{if(Ye===t)return Ne=e,e;try{e.close()}catch{}return null}).catch(()=>null);return Ye=t,t}function so(t){return t?{...t,matchRegex:new RegExp(t.match_command)}:null}function Rn(t){At(async(e,r)=>{let n=await no();if(!n)return null;try{let s=t==="free"?"trial":t,i=await n.filter(e,s);return!i||!(r??ot(void 0)).has(L(i.slug))?null:so(i)}catch{return null}})}function In(){if(At(null),Ne)try{Ne.close()}catch{}Ne=null,Ye=null}var $e=10*1024*1024,ao=Number(process.env.TOKMIZER_EXEC_TIMEOUT_MS??"600000"),oo={SIGHUP:1,SIGINT:2,SIGQUIT:3,SIGILL:4,SIGTRAP:5,SIGABRT:6,SIGBUS:7,SIGFPE:8,SIGKILL:9,SIGUSR1:10,SIGSEGV:11,SIGUSR2:12,SIGPIPE:13,SIGALRM:14,SIGTERM:15};function Ut(t){return oo[t]??15}async function Cn(t){let[e,...r]=t;if(!e)throw new Error("tkr-exec: missing command");let n=io(e,r,{stdio:["inherit","pipe","pipe"],env:fn()}),s=!1;n.on("spawn",()=>{s=!0});let i=S=>{try{n.kill(S)}catch{}};process.on("SIGINT",()=>i("SIGINT")),process.on("SIGTERM",()=>i("SIGTERM"));let a=[],o=[],c=0,l=0,d=!1,v=!1;n.stdout.on("data",S=>{if(c>=$e){d=!0;return}let A=$e-c,D=S.length>A?S.subarray(0,A):S;a.push(D),c+=D.length,S.length>A&&(d=!0)}),n.stderr.on("data",S=>{if(l>=$e){v=!0;return}let A=$e-l,D=S.length>A?S.subarray(0,A):S;o.push(D),l+=D.length,S.length>A&&(v=!0)});let _,k=await new Promise((S,A)=>{n.on("error",D=>{_&&clearTimeout(_),s?S(1):A(D)}),n.on("close",(D,be)=>{_&&clearTimeout(_),S(D??(be?128+Ut(be):0))}),_=setTimeout(()=>{n.kill("SIGTERM"),setTimeout(()=>n.kill("SIGKILL"),2e3)},ao),_.unref?.()}),F=Buffer.concat(a).toString("utf8"),re=Buffer.concat(o).toString("utf8"),Me=d?`
17
+ \u2026 (output truncated at ${$e/(1024*1024)}MB)`:"",Vt=v?re+`
18
+ \u2026 (stderr truncated at ${$e/(1024*1024)}MB)`:re,Ht=()=>{let S=F+Me,A=Buffer.byteLength(S,"utf8");return{stdout:S,stderr:Vt,code:k,filterId:null,rawBytes:A,filteredBytes:A,truncated:d}};try{let S=await Jr(),A=await qr();if(!A.enabled)return Ht();let D=S?Xr(S):null,be=S?ot(S.allowedFilters,Lt(S)):null,Kt=new Set(A.filters.disabled.map(L)),On=be&&Kt.size>0?new Set([...be].filter(Dn=>!Kt.has(Dn))):be,gt=t.join(" ");S&&Rn(D);let j=await Ir(gt,F,On,{verbosity:A.outputVerbosity,exitCode:k}),Je=on(j.rawBytes,j.filteredBytes,ln(un().host));try{an(Je.raw,Je.filtered),await nn({cmd:gt,filterId:j.filterId,rawBytes:j.rawBytes,filteredBytes:j.filteredBytes,plan:D}),await rn({cmd:gt,tokensSaved:Math.round((Je.raw-Je.filtered)/4),optimized:j.filterId!=null,telemetryOptIn:A.telemetryOptIn})}catch{}return{stdout:j.output+Me,stderr:Vt,code:k,filterId:j.filterId,rawBytes:j.rawBytes,filteredBytes:j.filteredBytes,truncated:d}}catch{return Ht()}finally{In()}}async function lo(t){let[e,...r]=t;e||process.exit(2);let n=co(e,r,{stdio:"inherit"}),s=await new Promise(i=>{n.on("error",()=>i(127)),n.on("close",(a,o)=>i(a??(o?128+Ut(o):0)))});process.exit(s)}async function uo(){let t=process.argv.slice(2);t.length===0&&(process.stderr.write(`tkr-exec: missing command
19
+ `),process.exit(2));let e;try{e=await Cn(t)}catch(r){return process.stderr.write(`tkr-exec: ${r.message??r}
20
+ `),lo(t)}e.stdout&&process.stdout.write(e.stdout),e.stderr&&process.stderr.write(e.stderr),process.exitCode=e.code}uo().catch(t=>{process.stderr.write(`${t.message??t}
21
21
  `),process.exit(1)});