@tokmizer/plugin 0.9.51 → 0.9.52

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,43 +1,47 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __tkrCreateRequire } from "node:module"; const require = __tkrCreateRequire(import.meta.url);
3
- var hr=Object.defineProperty;var gr=(t,e)=>{for(var n in e)hr(t,n,{get:e[n],enumerable:!0})};import{readdir as As,readFile as Rs}from"node:fs/promises";import{join as Gt,dirname as Cs}from"node:path";import{fileURLToPath as Is}from"node:url";var m={};gr(m,{BRAND:()=>Zr,DIRTY:()=>ee,EMPTY_PATH:()=>vr,INVALID:()=>v,NEVER:()=>Ts,OK:()=>O,ParseStatus:()=>I,Schema:()=>w,ZodAny:()=>q,ZodArray:()=>W,ZodBigInt:()=>ne,ZodBoolean:()=>re,ZodBranded:()=>De,ZodCatch:()=>me,ZodDate:()=>se,ZodDefault:()=>pe,ZodDiscriminatedUnion:()=>Ke,ZodEffects:()=>L,ZodEnum:()=>de,ZodError:()=>D,ZodFirstPartyTypeKind:()=>x,ZodFunction:()=>Ge,ZodIntersection:()=>ce,ZodIssueCode:()=>p,ZodLazy:()=>le,ZodLiteral:()=>ue,ZodMap:()=>ke,ZodNaN:()=>we,ZodNativeEnum:()=>fe,ZodNever:()=>F,ZodNull:()=>oe,ZodNullable:()=>U,ZodNumber:()=>te,ZodObject:()=>N,ZodOptional:()=>P,ZodParsedType:()=>y,ZodPipeline:()=>Ne,ZodPromise:()=>J,ZodReadonly:()=>he,ZodRecord:()=>We,ZodSchema:()=>w,ZodSet:()=>Ee,ZodString:()=>Y,ZodSymbol:()=>ve,ZodTransformer:()=>L,ZodTuple:()=>Z,ZodType:()=>w,ZodUndefined:()=>ie,ZodUnion:()=>ae,ZodUnknown:()=>K,ZodVoid:()=>xe,addIssueToContext:()=>h,any:()=>Jr,array:()=>ts,bigint:()=>Kr,boolean:()=>Vt,coerce:()=>Ss,custom:()=>Zt,date:()=>Wr,datetimeRegex:()=>Bt,defaultErrorMap:()=>H,discriminatedUnion:()=>is,effect:()=>ys,enum:()=>ms,function:()=>ds,getErrorMap:()=>ye,getParsedType:()=>z,instanceof:()=>Hr,intersection:()=>os,isAborted:()=>He,isAsync:()=>_e,isDirty:()=>Ve,isValid:()=>G,late:()=>Ur,lazy:()=>fs,literal:()=>ps,makeIssue:()=>Oe,map:()=>ls,nan:()=>Vr,nativeEnum:()=>hs,never:()=>Qr,null:()=>qr,nullable:()=>bs,number:()=>Ht,object:()=>ns,objectUtil:()=>rt,oboolean:()=>ws,onumber:()=>Es,optional:()=>_s,ostring:()=>ks,pipeline:()=>xs,preprocess:()=>vs,promise:()=>gs,quotelessJson:()=>yr,record:()=>cs,set:()=>us,setErrorMap:()=>br,strictObject:()=>rs,string:()=>Ut,symbol:()=>Gr,transformer:()=>ys,tuple:()=>as,undefined:()=>Yr,union:()=>ss,unknown:()=>Xr,util:()=>S,void:()=>es});var S;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{let i={};for(let o of s)i[o]=o;return i},t.getValidEnumValues=s=>{let i=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(let a of i)o[a]=s[a];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=(s,i)=>{for(let o of s)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(S||(S={}));var rt;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(rt||(rt={}));var y=S.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 y.undefined;case"string":return y.string;case"number":return Number.isNaN(t)?y.nan:y.number;case"boolean":return y.boolean;case"function":return y.function;case"bigint":return y.bigint;case"symbol":return y.symbol;case"object":return Array.isArray(t)?y.array:t===null?y.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?y.promise:typeof Map<"u"&&t instanceof Map?y.map:typeof Set<"u"&&t instanceof Set?y.set:typeof Date<"u"&&t instanceof Date?y.date:y.object;default:return y.unknown}};var p=S.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"]),yr=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=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){let n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,l=0;for(;l<o.path.length;){let u=o.path[l];l===o.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(n(o))):a[u]=a[u]||{_errors:[]},a=a[u],l++}}};return s(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,S.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};D.create=t=>new D(t);var _r=(t,e)=>{let n;switch(t.code){case p.invalid_type:t.received===y.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case p.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,S.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:n=`Unrecognized key(s) in object: ${S.joinValues(t.keys,", ")}`;break;case p.invalid_union:n="Invalid input";break;case p.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${S.joinValues(t.options)}`;break;case p.invalid_enum_value:n=`Invalid enum value. Expected ${S.joinValues(t.options)}, received '${t.received}'`;break;case p.invalid_arguments:n="Invalid function arguments";break;case p.invalid_return_type:n="Invalid function return type";break;case p.invalid_date:n="Invalid date";break;case p.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:S.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case p.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case p.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case p.custom:n="Invalid input";break;case p.invalid_intersection_types:n="Intersection results could not be merged";break;case p.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case p.not_finite:n="Number must be finite";break;default:n=e.defaultError,S.assertNever(t)}return{message:n}},H=_r;var Pt=H;function br(t){Pt=t}function ye(){return Pt}var Oe=t=>{let{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="",l=r.filter(u=>!!u).slice().reverse();for(let u of l)a=u(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}},vr=[];function h(t,e){let n=ye(),r=Oe({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===H?void 0:H].filter(s=>!!s)});t.common.issues.push(r)}var I=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let s of n){if(s.status==="aborted")return v;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let s of n){let i=await s.key,o=await s.value;r.push({key:i,value:o})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let s of n){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return v;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}},v=Object.freeze({status:"aborted"}),ee=t=>({status:"dirty",value:t}),O=t=>({status:"valid",value:t}),He=t=>t.status==="aborted",Ve=t=>t.status==="dirty",G=t=>t.status==="valid",_e=t=>typeof Promise<"u"&&t instanceof Promise;var b;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(b||(b={}));var M=class{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Mt=(t,e)=>{if(G(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new D(t.common.issues);return this._error=n,this._error}}};function E(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{let{message:l}=t;return o.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:s}}var w=class{get description(){return this._def.description}_getType(e){return z(e.data)}_getOrReturnCtx(e,n){return n||{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 I,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 n=this._parse(e);if(_e(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)},s=this._parseSync({data:e,path:r.path,parent:r});return Mt(r,s)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return G(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>G(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(_e(s)?s:Promise.resolve(s));return Mt(r,i)}refine(e,n){let r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{let o=e(s),a=()=>i.addIssue({code:p.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new L({schema:this,typeName:x.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return P.create(this,this._def)}nullable(){return U.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return W.create(this)}promise(){return J.create(this,this._def)}or(e){return ae.create([this,e],this._def)}and(e){return ce.create(this,e,this._def)}transform(e){return new L({...E(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new pe({...E(this._def),innerType:this,defaultValue:n,typeName:x.ZodDefault})}brand(){return new De({typeName:x.ZodBranded,type:this,...E(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new me({...E(this._def),innerType:this,catchValue:n,typeName:x.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Ne.create(this,e)}readonly(){return he.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},xr=/^c[^\s-]{8,}$/i,kr=/^[0-9a-z]+$/,Er=/^[0-9A-HJKMNP-TV-Z]{26}$/i,wr=/^[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,Sr=/^[a-z0-9_-]{21}$/i,Tr=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ar=/^[-+]?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)?)??$/,Rr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Cr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",st,Ir=/^(?:(?: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])$/,Or=/^(?:(?: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])$/,Dr=/^(([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]))$/,Nr=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,$r=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Pr=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ft="((\\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])))",Mr=new RegExp(`^${Ft}$`);function jt(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function Lr(t){return new RegExp(`^${jt(t)}$`)}function Bt(t){let e=`${Ft}T${jt(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Fr(t,e){return!!((e==="v4"||!e)&&Ir.test(t)||(e==="v6"||!e)&&Dr.test(t))}function jr(t,e){if(!Tr.test(t))return!1;try{let[n]=t.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Br(t,e){return!!((e==="v4"||!e)&&Or.test(t)||(e==="v6"||!e)&&Nr.test(t))}var Y=class t extends w{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y.string){let i=this._getOrReturnCtx(e);return h(i,{code:p.invalid_type,expected:y.string,received:i.parsedType}),v}let r=new I,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:p.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:p.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(e,s),o?h(s,{code:p.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&h(s,{code:p.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")Rr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"email",code:p.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")st||(st=new RegExp(Cr,"u")),st.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"emoji",code:p.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")wr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"uuid",code:p.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Sr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"nanoid",code:p.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")xr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cuid",code:p.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")kr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cuid2",code:p.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")Er.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"ulid",code:p.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),h(s,{validation:"url",code:p.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"regex",code:p.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),h(s,{code:p.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),h(s,{code:p.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),h(s,{code:p.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?Bt(i).test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:p.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Mr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:p.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Lr(i).test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:p.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Ar.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"duration",code:p.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Fr(e.data,i.version)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"ip",code:p.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?jr(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"jwt",code:p.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Br(e.data,i.version)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cidr",code:p.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?$r.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64",code:p.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Pr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64url",code:p.invalid_string,message:i.message}),r.dirty()):S.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:p.invalid_string,...b.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...b.errToObj(e)})}url(e){return this._addCheck({kind:"url",...b.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...b.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...b.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...b.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...b.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...b.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...b.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...b.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...b.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...b.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...b.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...b.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,...b.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,...b.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...b.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...b.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...b.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...b.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...b.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...b.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...b.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...b.errToObj(n)})}nonempty(e){return this.min(1,b.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Y.create=t=>new Y({checks:[],typeName:x.ZodString,coerce:t?.coerce??!1,...E(t)});function zr(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}var te=class t extends w{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==y.number){let i=this._getOrReturnCtx(e);return h(i,{code:p.invalid_type,expected:y.number,received:i.parsedType}),v}let r,s=new I;for(let i of this._def.checks)i.kind==="int"?S.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:p.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:p.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:p.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?zr(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),h(r,{code:p.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:p.not_finite,message:i.message}),s.dirty()):S.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,b.toString(n))}gt(e,n){return this.setLimit("min",e,!1,b.toString(n))}lte(e,n){return this.setLimit("max",e,!0,b.toString(n))}lt(e,n){return this.setLimit("max",e,!1,b.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:b.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:b.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:b.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:b.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:b.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&S.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};te.create=t=>new te({checks:[],typeName:x.ZodNumber,coerce:t?.coerce||!1,...E(t)});var ne=class t extends w{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==y.bigint)return this._getInvalidInput(e);let r,s=new I;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:p.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:p.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),h(r,{code:p.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):S.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return h(n,{code:p.invalid_type,expected:y.bigint,received:n.parsedType}),v}gte(e,n){return this.setLimit("min",e,!0,b.toString(n))}gt(e,n){return this.setLimit("min",e,!1,b.toString(n))}lte(e,n){return this.setLimit("max",e,!0,b.toString(n))}lt(e,n){return this.setLimit("max",e,!1,b.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:b.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:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:b.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};ne.create=t=>new ne({checks:[],typeName:x.ZodBigInt,coerce:t?.coerce??!1,...E(t)});var re=class extends w{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){let r=this._getOrReturnCtx(e);return h(r,{code:p.invalid_type,expected:y.boolean,received:r.parsedType}),v}return O(e.data)}};re.create=t=>new re({typeName:x.ZodBoolean,coerce:t?.coerce||!1,...E(t)});var se=class t extends w{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y.date){let i=this._getOrReturnCtx(e);return h(i,{code:p.invalid_type,expected:y.date,received:i.parsedType}),v}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return h(i,{code:p.invalid_date}),v}let r=new I,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:p.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:p.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):S.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:b.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:b.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};se.create=t=>new se({checks:[],coerce:t?.coerce||!1,typeName:x.ZodDate,...E(t)});var ve=class extends w{_parse(e){if(this._getType(e)!==y.symbol){let r=this._getOrReturnCtx(e);return h(r,{code:p.invalid_type,expected:y.symbol,received:r.parsedType}),v}return O(e.data)}};ve.create=t=>new ve({typeName:x.ZodSymbol,...E(t)});var ie=class extends w{_parse(e){if(this._getType(e)!==y.undefined){let r=this._getOrReturnCtx(e);return h(r,{code:p.invalid_type,expected:y.undefined,received:r.parsedType}),v}return O(e.data)}};ie.create=t=>new ie({typeName:x.ZodUndefined,...E(t)});var oe=class extends w{_parse(e){if(this._getType(e)!==y.null){let r=this._getOrReturnCtx(e);return h(r,{code:p.invalid_type,expected:y.null,received:r.parsedType}),v}return O(e.data)}};oe.create=t=>new oe({typeName:x.ZodNull,...E(t)});var q=class extends w{constructor(){super(...arguments),this._any=!0}_parse(e){return O(e.data)}};q.create=t=>new q({typeName:x.ZodAny,...E(t)});var K=class extends w{constructor(){super(...arguments),this._unknown=!0}_parse(e){return O(e.data)}};K.create=t=>new K({typeName:x.ZodUnknown,...E(t)});var F=class extends w{_parse(e){let n=this._getOrReturnCtx(e);return h(n,{code:p.invalid_type,expected:y.never,received:n.parsedType}),v}};F.create=t=>new F({typeName:x.ZodNever,...E(t)});var xe=class extends w{_parse(e){if(this._getType(e)!==y.undefined){let r=this._getOrReturnCtx(e);return h(r,{code:p.invalid_type,expected:y.void,received:r.parsedType}),v}return O(e.data)}};xe.create=t=>new xe({typeName:x.ZodVoid,...E(t)});var W=class t extends w{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==y.array)return h(n,{code:p.invalid_type,expected:y.array,received:n.parsedType}),v;if(s.exactLength!==null){let o=n.data.length>s.exactLength.value,a=n.data.length<s.exactLength.value;(o||a)&&(h(n,{code:o?p.too_big:p.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(h(n,{code:p.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(h(n,{code:p.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>s.type._parseAsync(new M(n,o,n.path,a)))).then(o=>I.mergeArray(r,o));let i=[...n.data].map((o,a)=>s.type._parseSync(new M(n,o,n.path,a)));return I.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:b.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:b.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:b.toString(n)}})}nonempty(e){return this.min(1,e)}};W.create=(t,e)=>new W({type:t,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...E(e)});function be(t){if(t instanceof N){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=P.create(be(r))}return new N({...t._def,shape:()=>e})}else return t instanceof W?new W({...t._def,type:be(t.element)}):t instanceof P?P.create(be(t.unwrap())):t instanceof U?U.create(be(t.unwrap())):t instanceof Z?Z.create(t.items.map(e=>be(e))):t}var N=class t extends w{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=S.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==y.object){let u=this._getOrReturnCtx(e);return h(u,{code:p.invalid_type,expected:y.object,received:u.parsedType}),v}let{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof F&&this._def.unknownKeys==="strip"))for(let u in s.data)o.includes(u)||a.push(u);let l=[];for(let u of o){let d=i[u],f=s.data[u];l.push({key:{status:"valid",value:u},value:d._parse(new M(s,f,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof F){let u=this._def.unknownKeys;if(u==="passthrough")for(let d of a)l.push({key:{status:"valid",value:d},value:{status:"valid",value:s.data[d]}});else if(u==="strict")a.length>0&&(h(s,{code:p.unrecognized_keys,keys:a}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let d of a){let f=s.data[d];l.push({key:{status:"valid",value:d},value:u._parse(new M(s,f,s.path,d)),alwaysSet:d in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let d of l){let f=await d.key,c=await d.value;u.push({key:f,value:c,alwaysSet:d.alwaysSet})}return u}).then(u=>I.mergeObjectSync(r,u)):I.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return b.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:b.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:x.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of S.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of S.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return be(this)}partial(e){let n={};for(let r of S.objectKeys(this.shape)){let s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of S.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof P;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return zt(S.objectKeys(this.shape))}};N.create=(t,e)=>new N({shape:()=>t,unknownKeys:"strip",catchall:F.create(),typeName:x.ZodObject,...E(e)});N.strictCreate=(t,e)=>new N({shape:()=>t,unknownKeys:"strict",catchall:F.create(),typeName:x.ZodObject,...E(e)});N.lazycreate=(t,e)=>new N({shape:t,unknownKeys:"strip",catchall:F.create(),typeName:x.ZodObject,...E(e)});var ae=class extends w{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(let a of i)if(a.result.status==="valid")return a.result;for(let a of i)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(a=>new D(a.ctx.common.issues));return h(n,{code:p.invalid_union,unionErrors:o}),v}if(n.common.async)return Promise.all(r.map(async i=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let l of r){let u={...n,common:{...n.common,issues:[]},parent:null},d=l._parseSync({data:n.data,path:n.path,parent:u});if(d.status==="valid")return d;d.status==="dirty"&&!i&&(i={result:d,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(l=>new D(l));return h(n,{code:p.invalid_union,unionErrors:a}),v}}get options(){return this._def.options}};ae.create=(t,e)=>new ae({options:t,typeName:x.ZodUnion,...E(e)});var V=t=>t instanceof le?V(t.schema):t instanceof L?V(t.innerType()):t instanceof ue?[t.value]:t instanceof de?t.options:t instanceof fe?S.objectValues(t.enum):t instanceof pe?V(t._def.innerType):t instanceof ie?[void 0]:t instanceof oe?[null]:t instanceof P?[void 0,...V(t.unwrap())]:t instanceof U?[null,...V(t.unwrap())]:t instanceof De||t instanceof he?V(t.unwrap()):t instanceof me?V(t._def.innerType):[],Ke=class t extends w{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.object)return h(n,{code:p.invalid_type,expected:y.object,received:n.parsedType}),v;let r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(h(n,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let s=new Map;for(let i of n){let o=V(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,i)}}return new t({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...E(r)})}};function it(t,e){let n=z(t),r=z(e);if(t===e)return{valid:!0,data:t};if(n===y.object&&r===y.object){let s=S.objectKeys(e),i=S.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(let a of i){let l=it(t[a],e[a]);if(!l.valid)return{valid:!1};o[a]=l.data}return{valid:!0,data:o}}else if(n===y.array&&r===y.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let o=t[i],a=e[i],l=it(o,a);if(!l.valid)return{valid:!1};s.push(l.data)}return{valid:!0,data:s}}else return n===y.date&&r===y.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var ce=class extends w{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(He(i)||He(o))return v;let a=it(i.value,o.value);return a.valid?((Ve(i)||Ve(o))&&n.dirty(),{status:n.value,value:a.data}):(h(r,{code:p.invalid_intersection_types}),v)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};ce.create=(t,e,n)=>new ce({left:t,right:e,typeName:x.ZodIntersection,...E(n)});var Z=class t extends w{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.array)return h(r,{code:p.invalid_type,expected:y.array,received:r.parsedType}),v;if(r.data.length<this._def.items.length)return h(r,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&r.data.length>this._def.items.length&&(h(r,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...r.data].map((o,a)=>{let l=this._def.items[a]||this._def.rest;return l?l._parse(new M(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>I.mergeArray(n,o)):I.mergeArray(n,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:x.ZodTuple,rest:null,...E(e)})};var We=class t extends w{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.object)return h(r,{code:p.invalid_type,expected:y.object,received:r.parsedType}),v;let s=[],i=this._def.keyType,o=this._def.valueType;for(let a in r.data)s.push({key:i._parse(new M(r,a,r.path,a)),value:o._parse(new M(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?I.mergeObjectAsync(n,s):I.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof w?new t({keyType:e,valueType:n,typeName:x.ZodRecord,...E(r)}):new t({keyType:Y.create(),valueType:e,typeName:x.ZodRecord,...E(n)})}},ke=class extends w{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.map)return h(r,{code:p.invalid_type,expected:y.map,received:r.parsedType}),v;let s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,l],u)=>({key:s._parse(new M(r,a,r.path,[u,"key"])),value:i._parse(new M(r,l,r.path,[u,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let l of o){let u=await l.key,d=await l.value;if(u.status==="aborted"||d.status==="aborted")return v;(u.status==="dirty"||d.status==="dirty")&&n.dirty(),a.set(u.value,d.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let l of o){let u=l.key,d=l.value;if(u.status==="aborted"||d.status==="aborted")return v;(u.status==="dirty"||d.status==="dirty")&&n.dirty(),a.set(u.value,d.value)}return{status:n.value,value:a}}}};ke.create=(t,e,n)=>new ke({valueType:e,keyType:t,typeName:x.ZodMap,...E(n)});var Ee=class t extends w{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.set)return h(r,{code:p.invalid_type,expected:y.set,received:r.parsedType}),v;let s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(h(r,{code:p.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(h(r,{code:p.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());let i=this._def.valueType;function o(l){let u=new Set;for(let d of l){if(d.status==="aborted")return v;d.status==="dirty"&&n.dirty(),u.add(d.value)}return{status:n.value,value:u}}let a=[...r.data.values()].map((l,u)=>i._parse(new M(r,l,r.path,u)));return r.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(e,n){return new t({...this._def,minSize:{value:e,message:b.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:b.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};Ee.create=(t,e)=>new Ee({valueType:t,minSize:null,maxSize:null,typeName:x.ZodSet,...E(e)});var Ge=class t extends w{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.function)return h(n,{code:p.invalid_type,expected:y.function,received:n.parsedType}),v;function r(a,l){return Oe({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,ye(),H].filter(u=>!!u),issueData:{code:p.invalid_arguments,argumentsError:l}})}function s(a,l){return Oe({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,ye(),H].filter(u=>!!u),issueData:{code:p.invalid_return_type,returnTypeError:l}})}let i={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof J){let a=this;return O(async function(...l){let u=new D([]),d=await a._def.args.parseAsync(l,i).catch(g=>{throw u.addIssue(r(l,g)),u}),f=await Reflect.apply(o,this,d);return await a._def.returns._def.type.parseAsync(f,i).catch(g=>{throw u.addIssue(s(f,g)),u})})}else{let a=this;return O(function(...l){let u=a._def.args.safeParse(l,i);if(!u.success)throw new D([r(l,u.error)]);let d=Reflect.apply(o,this,u.data),f=a._def.returns.safeParse(d,i);if(!f.success)throw new D([s(d,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Z.create(e).rest(K.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||Z.create([]).rest(K.create()),returns:n||K.create(),typeName:x.ZodFunction,...E(r)})}},le=class extends w{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};le.create=(t,e)=>new le({getter:t,typeName:x.ZodLazy,...E(e)});var ue=class extends w{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return h(n,{received:n.data,code:p.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}};ue.create=(t,e)=>new ue({value:t,typeName:x.ZodLiteral,...E(e)});function zt(t,e){return new de({values:t,typeName:x.ZodEnum,...E(e)})}var de=class t extends w{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return h(n,{expected:S.joinValues(r),received:n.parsedType,code:p.invalid_type}),v}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return h(n,{received:n.data,code:p.invalid_enum_value,options:r}),v}return O(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};de.create=zt;var fe=class extends w{_parse(e){let n=S.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==y.string&&r.parsedType!==y.number){let s=S.objectValues(n);return h(r,{expected:S.joinValues(s),received:r.parsedType,code:p.invalid_type}),v}if(this._cache||(this._cache=new Set(S.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=S.objectValues(n);return h(r,{received:r.data,code:p.invalid_enum_value,options:s}),v}return O(e.data)}get enum(){return this._def.values}};fe.create=(t,e)=>new fe({values:t,typeName:x.ZodNativeEnum,...E(e)});var J=class extends w{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.promise&&n.common.async===!1)return h(n,{code:p.invalid_type,expected:y.promise,received:n.parsedType}),v;let r=n.parsedType===y.promise?n.data:Promise.resolve(n.data);return O(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};J.create=(t,e)=>new J({type:t,typeName:x.ZodPromise,...E(e)});var L=class extends w{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{h(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return v;let l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?v:l.status==="dirty"?ee(l.value):n.value==="dirty"?ee(l.value):l});{if(n.value==="aborted")return v;let a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?v:a.status==="dirty"?ee(a.value):n.value==="dirty"?ee(a.value):a}}if(s.type==="refinement"){let o=a=>{let l=s.refinement(a,i);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?v:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?v:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!G(o))return v;let a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>G(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:n.value,value:a})):v);S.assertNever(s)}};L.create=(t,e,n)=>new L({schema:t,typeName:x.ZodEffects,effect:e,...E(n)});L.createWithPreprocess=(t,e,n)=>new L({schema:e,effect:{type:"preprocess",transform:t},typeName:x.ZodEffects,...E(n)});var P=class extends w{_parse(e){return this._getType(e)===y.undefined?O(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};P.create=(t,e)=>new P({innerType:t,typeName:x.ZodOptional,...E(e)});var U=class extends w{_parse(e){return this._getType(e)===y.null?O(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};U.create=(t,e)=>new U({innerType:t,typeName:x.ZodNullable,...E(e)});var pe=class extends w{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===y.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};pe.create=(t,e)=>new pe({innerType:t,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...E(e)});var me=class extends w{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return _e(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new D(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new D(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};me.create=(t,e)=>new me({innerType:t,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...E(e)});var we=class extends w{_parse(e){if(this._getType(e)!==y.nan){let r=this._getOrReturnCtx(e);return h(r,{code:p.invalid_type,expected:y.nan,received:r.parsedType}),v}return{status:"valid",value:e.data}}};we.create=t=>new we({typeName:x.ZodNaN,...E(t)});var Zr=Symbol("zod_brand"),De=class extends w{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},Ne=class t extends w{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?v:i.status==="dirty"?(n.dirty(),ee(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{let s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?v:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:x.ZodPipeline})}},he=class extends w{_parse(e){let n=this._def.innerType._parse(e),r=s=>(G(s)&&(s.value=Object.freeze(s.value)),s);return _e(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};he.create=(t,e)=>new he({innerType:t,typeName:x.ZodReadonly,...E(e)});function Lt(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Zt(t,e={},n){return t?q.create().superRefine((r,s)=>{let i=t(r);if(i instanceof Promise)return i.then(o=>{if(!o){let a=Lt(e,r),l=a.fatal??n??!0;s.addIssue({code:"custom",...a,fatal:l})}});if(!i){let o=Lt(e,r),a=o.fatal??n??!0;s.addIssue({code:"custom",...o,fatal:a})}}):q.create()}var Ur={object:N.lazycreate},x;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(x||(x={}));var Hr=(t,e={message:`Input not instance of ${t.name}`})=>Zt(n=>n instanceof t,e),Ut=Y.create,Ht=te.create,Vr=we.create,Kr=ne.create,Vt=re.create,Wr=se.create,Gr=ve.create,Yr=ie.create,qr=oe.create,Jr=q.create,Xr=K.create,Qr=F.create,es=xe.create,ts=W.create,ns=N.create,rs=N.strictCreate,ss=ae.create,is=Ke.create,os=ce.create,as=Z.create,cs=We.create,ls=ke.create,us=Ee.create,ds=Ge.create,fs=le.create,ps=ue.create,ms=de.create,hs=fe.create,gs=J.create,ys=L.create,_s=P.create,bs=U.create,vs=L.createWithPreprocess,xs=Ne.create,ks=()=>Ut().optional(),Es=()=>Ht().optional(),ws=()=>Vt().optional(),Ss={string:(t=>Y.create({...t,coerce:!0})),number:(t=>te.create({...t,coerce:!0})),boolean:(t=>re.create({...t,coerce:!0})),bigint:(t=>ne.create({...t,coerce:!0})),date:(t=>se.create({...t,coerce:!0}))};var Ts=v;var Se=m.object({slug:m.string().min(1).max(64),description:m.string().max(255).optional(),match_command:m.string().min(1),priority:m.number().int().default(50),strip_ansi:m.boolean().default(!1),strip_lines_matching:m.array(m.string()).default([]),keep_failures:m.boolean().default(!1),fold_passing:m.boolean().default(!1),fold_passing_threshold:m.number().int().positive().max(1e3).optional(),mask_abs_paths:m.boolean().default(!1),preserve_exact:m.boolean().default(!1),truncate_lines_at:m.number().int().positive().max(1e4).optional(),max_lines:m.number().int().positive().max(1e5).optional(),scale_with_level:m.boolean().default(!0),transform:m.string().max(64).optional(),on_empty:m.string().max(255).optional()});var Os=Cs(Is(import.meta.url)),Kt=process.env.TOKMIZER_FILTERS_DIR||Gt(Os,"..","..","filters"),X=null,Wt=!1;function Ds(){return process.env.TOKMIZER_DEV==="1"||process.env.TOKMIZER_DEV==="true"}async function Yt(){if(X)return X;if(!Ds())return!Wt&&process.env.TOKMIZER_DEBUG==="1"&&(process.stderr.write(`tokmizer: disk loader disabled (set TOKMIZER_DEV=1 to re-enable for local dev).
4
- `),Wt=!0),X=new Map,X;let t=new Map,e,n;try{e=(await import("smol-toml")).parse,n=(await As(Kt)).filter(r=>r.endsWith(".toml"))}catch{return X=t,X}for(let r of n){let s=await Rs(Gt(Kt,r),"utf8"),o=e(s).filters;if(o)for(let[a,l]of Object.entries(o)){let u=Se.parse({slug:a,...l});t.set(a,{...u,matchRegex:new RegExp(u.match_command)})}}return X=t,X}import{createHash as Ns}from"node:crypto";var $s=m.enum(["normal","compact","minimal"]),Ps=m.enum(["off","light","balanced","max"]),$e=m.object({enabled:m.boolean().default(!0),telemetryOptIn:m.boolean().default(!0),outputVerbosity:$s.default("compact"),reducer:Ps.default("off"),filters:m.object({enableAll:m.boolean().default(!0),disabled:m.array(m.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})}),Ms=["git","git-status","git-log","git-diff","grep","find","diff","ls","ls-long","ps","cat","head","tail","df","du","tree","wc","nl","xargs","seq","echo","printf","sleep","shasum","python","node","read-tool","grep-tool","glob-tool","bash-tool","npm","npm-test","docker","kubectl","curl","cargo","go-test","go-build","gh","gh-api","aws","dotnet","prisma","tsc","next","jest","vitest","pytest","pip","rspec"],Ls=/^[0-9a-f]{16}$/,qt=new Map;function j(t){let e=qt.get(t);return e||(e=Ns("sha256").update(`tkr:${t}`).digest("hex").slice(0,16),qt.set(t,e)),e}var Jt=null;function Ye(t,e=!1){return e||!t||t.length===0?(Jt??=new Set(Ms.map(j)),new Set(Jt)):new Set(t.map(n=>Ls.test(n)?n:j(n)))}var Te=new Map,Fs=256,Xt=new WeakMap;function js(t){if(!t)return"*";let e=Xt.get(t);return e===void 0&&(e=[...t].join(","),Xt.set(t,e)),e}function qe(t,e,n){let r=`${t}::${js(n)}`,s=Te.get(r);if(s!==void 0)return s;let i=null;for(let o of e)n&&!n.has(j(o.slug))||o.matchRegex.test(t)&&(!i||o.priority>i.priority)&&(i=o);if(Te.size>=Fs){let o=Te.keys().next().value;o&&Te.delete(o)}return Te.set(r,i),i}function Qt(){Te.clear()}var Bs=/\x1b\[[0-9;?]*[ -/]*[@-~]/g,zs=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g;function ge(t){return t.replace(Bs,"").replace(zs,"")}function en(t,e){return e.length===0?t:t.filter(n=>!e.some(r=>r.test(n)))}function tn(t,e){return t.map(n=>{if(n.length<=e)return n;let r=n.charCodeAt(e-1),s=n.charCodeAt(e),i=r>=55296&&r<=56319&&s>=56320&&s<=57343?e-1:e;return`${n.slice(0,i)}\u2026`})}function Je(t){return`\u2026 (${t} more lines omitted)`}function nn(t,e){if(t.length<=e)return{kept:t,dropped:[]};let n=Math.ceil(e*.7),r=e-n,s=t.slice(n,t.length-r);return{kept:[...t.slice(0,n),Je(s.length),...t.slice(t.length-r)],dropped:s}}var Zs=/^\s*(?:[✓✔√]|ok )/,Q=/✕|✗|×|\bFAIL\b|\bERROR\b|\bFATAL\b|\bError|\berror|Expected|Received|\bfailed\b|^\s*Tests?:|^\s*Test Suites?:/;function rn(t,e){let n=e>0?e:5,r=[],s=0,i=a=>{s>=n?r.push(`\u2026 ${s} passing checks folded \u2026`):r.push(...a)},o=[];for(let a of t)Zs.test(a)&&!Q.test(a)?(o.push(a),s+=1):(i(o),o=[],s=0,r.push(a));return i(o),r}var Us=/(?:\/[\w.@+-]+){3,}/g;function sn(t){return t.map(e=>e.replace(Us,n=>{let r=n.split("/").filter(Boolean);return r.length<=2?n:`\u2026/${r.slice(-2).join("/")}`}))}var Hs=/^(\s*)(?:export\s+)?(?:async\s+)?(?:function|interface|type|const|let|var|def|fn|impl|trait|struct|enum)\s+[\w$]+/,Vs=/\{\s*$/;var Ks=/^\s*(?:(?:public|private|protected|static|async|get|set|readonly|override)\s+)*([\w$]+)\s*\(([^)]*)\)\s*(?::\s*[^{]+)?\{\s*$/,Ws=new Set(["if","for","while","switch","catch","do","with","return","else","function","await","yield"]);function Gs(t){let e=Ks.exec(t);return!e||Ws.has(e[1])?!1:!/=>|\bfunction\b/.test(e[2])}var Ys=/^\s*(?:if|for|while|switch|try|do)\b[^{}]*\{\s*$/;function qs(t,e,n){let r=e;for(;r<t.length;){if(t[r]==="\\"){r+=2;continue}if(t[r]===n)return!0;r+=1}return!1}function Js(t,e){let n=0,r=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(r){if(i==="\\"){s+=2;continue}i===r&&(r=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==='"'){let o=s>0?t[s-1]:"";!(i==="'"&&(o==="<"||o==="&"))&&qs(t,s+1,i)&&(r=i),s+=1;continue}i==="{"||i==="("||i==="["?n+=1:(i==="}"||i===")"||i==="]")&&(n-=1),s+=1}return n}var Xs=/^\s*… (\d+) lines? folded …$/;function ot(t){let e=new Array(t.length).fill(!1);for(let n=0;n<t.length;n+=1){let r=Xs.exec(t[n]);if(!r)continue;let s=Number(r[1])-1,i=n+1;for(;s>0&&i<t.length&&t[i]==="";)e[i]=!0,s-=1,i+=1;n=i-1}return e}function Xe(t){let e=[],n=0;for(;n<t.length;){let r=t[n];if(Hs.test(r)&&Vs.test(r)||Gs(r)||Ys.test(r)){let s={inBlockComment:!1,inTemplate:!1},i=0,o=n,a=!1;for(;o<t.length&&o-n<200;)if(i+=Js(t[o],s),o+=1,i<=0&&!s.inTemplate&&!s.inBlockComment){a=!0;break}let l=o-n;if(a&&l>=3){let u=l-2,d=/^\s*/.exec(t[n+1]??"")?.[0]??" ";e.push(r),e.push(`${d}\u2026 ${u} ${u===1?"line":"lines"} folded \u2026`);for(let f=0;f<u-1;f++)e.push("");e.push(t[o-1]),n=o;continue}}e.push(r),n+=1}return e}var Qs=/\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 on(t){let e=t.slice(0,4096);return!(!Qs.test(e)||e.split(`
5
- `).length<6)}var ei=/^\s*(?:\d{4}-\d{2}-\d{2}[T\s]\d{2}:\d{2}:\d{2}(?:\.\d+)?Z?|\d{2}:\d{2}:\d{2}(?:\.\d+)?)\s*/,ti=/^\s*(?:\[(?:DEBUG|TRACE|INFO|VERBOSE)\]|(?:DEBUG|TRACE|INFO|VERBOSE)(?!\s*:))(?=\s|:|$)(?!\s*[+\-*\/%&|^?]*=)/,ni=new RegExp(Q.source,"i"),ri=/\bWARN(?:ING)?\b/i;function an(t){let e=[],n=0,r=()=>{n>0&&e.push(`\u2026 ${n} verbose log line${n===1?"":"s"} dropped \u2026`),n=0};for(let s of t){if(ti.test(s.replace(ei,""))&&!ni.test(s)&&!ri.test(s)){n+=1;continue}r(),e.push(s)}return r(),e}function cn(t){if(t.length===0)return t;let e=[],n=1,r=t[0];for(let s=1;s<t.length;s++){if(t[s]===r){n+=1;continue}e.push(n>1?`${r} \xD7${n}`:r),r=t[s],n=1}return e.push(n>1?`${r} \xD7${n}`:r),e}function ln(t){let e=[],n=0;for(let r of t){if(r.trim()===""){n+=1;continue}n>0&&e.push(""),n=0,e.push(r)}return e}var un=new Map;function $(t,e){un.set(t,e)}function dn(t){return un.get(t)}var si=/^[dbclps\-][rwxsStT\-]{9}[@.+]?(?:\s|$)/,ii=/^[./~][^\s]*:$/,at=1e3;function oi(t){if(t<1024)return String(t);let e=["K","M","G","T"],n=t/1024,r=0;for(;n>=1024&&r<e.length-1;)n/=1024,r+=1;return`${n.toFixed(1)}${e[r]}`}function ai(t){if(!si.test(t))return null;let e=t.split(/\s+/);if(e.length<9)return null;let n=Number(e[4]);if(!Number.isFinite(n))return null;let r=e.slice(8).join(" ").trim();if(r===""||r==="."||r==="..")return null;let s=e[0].charCodeAt(0)===100;return{name:r,size:n,isDir:s}}function ci(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 o=s.name.slice(i);e.set(o,(e.get(o)??0)+1)}let n=null,r=0;for(let[s,i]of e)i>r&&(r=i,n=s);return n&&r>=Math.ceil(t.length/2)?`${r} ${n}`:null}function li(t){let e=[],n=[],r=!1;for(let c of t){if(/^total\s+\d+/.test(c))continue;if(ii.test(c.trim()))return t;let g=ai(c);g&&(r=!0,(g.isDir?e:n).push(g))}if(!r)return t;let s=(c,g)=>c.name.localeCompare(g.name);e.sort(s),n.sort((c,g)=>g.size-c.size||s(c,g));let i=[...e,...n],o=Math.min(40,Math.max(0,...i.map(c=>c.isDir?c.name.length+1:c.name.length))),a=[];for(let c of i){let g=c.isDir?`${c.name}/`:c.name,_=c.isDir?"":oi(c.size);a.push(_?`${g.padEnd(o)} ${_}`:g)}if(a.length>at){let c=a.length-at;a=[...a.slice(0,at),`\u2026 ${c} more lines omitted`]}let l=n.length===1?"file":"files",u=e.length===1?"dir":"dirs",d=ci(n),f=`${n.length} ${l}, ${e.length} ${u}`+(d?` (${d})`:"");return a.push(f),a}$("smart-ls",li);$("smart-read",t=>Xe(t));var fn=1e3;function ui(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 r=new Map,s=[],i=0;for(let d of e){let f=d.trim();if(f.startsWith("find:")){s.push(f);continue}let c=f.replace(/^\.\//,"").replace(/\/+$/,""),g=c.lastIndexOf("/"),_=g>=0?c.slice(0,g):"",k=g>=0?c.slice(g+1):c;if(!k)continue;let A=r.get(_)??[];A.push(/\s/.test(k)?`"${k}"`:k),r.set(_,A),i+=1}if(i===0)return t;let o=new Set([""]);for(let d of r.keys()){if(d==="")continue;let f=d.split("/");for(let c=1;c<=f.length;c+=1)o.add(f.slice(0,c).join("/"))}let a=[...o].sort(),l=a.filter(d=>d!=="").length,u=[`${i}F ${l}D:`,""];for(let d of a){let f=d===""?0:d.split("/").length,c=d===""?".":d.slice(d.lastIndexOf("/")+1),g=r.get(d)??[],_=g.length?` ${g.join(" ")}`:"";u.push(`${" ".repeat(f)}${c}/${_}`)}if(u.length+s.length>fn){let d=Math.max(0,fn-s.length),f=u.length-d;return[...u.slice(0,d),`\u2026 ${f} more lines omitted`,...s]}return[...u,...s]}$("smart-find",ui);var ct=1e3,pn=200,di=60,fi=190,pi=/^([^\s:]+):(\d+):(.*)$/,mi=/^([^:]+?)-(\d+)-(.*)$/,hi=/^([^\s:]+):(.*)$/,mn=/(?:^|\/)(?:__tests__|tests?|spec|fixtures?|__mocks__|__snapshots__)\/|\.(?:test|spec)\.[^/]+$/i;function hn(t){let e=t.trim();return e.length>pn?`${e.slice(0,pn)}\u2026`:e}function gi(t){let e=[],n="";for(let r of t){let s=n?`${n}, ${r}`:r;s.length>fi&&n?(e.push(`${n},`),n=r):n=s}return n&&e.push(n),e}function yi(t){let e=t.filter(f=>f.trim()!=="");if(e.length===0)return t;let n=new Map,r=new Map,s=null,i=0,o=0;for(let f of e){if(f==="--"){s&&n.get(s).push({separator:!0});continue}if(/^[A-Za-z]:[\\/]/.test(f))return t;let c=pi.exec(f),g=mi.exec(f);if(c&&g)return t;let _=c||g?null:hi.exec(f),k=(c??g??_)?.[1];if(!k)return t;let A=c?{line:c[2],content:c[3],context:!1}:g?{line:g[2],content:g[3],context:!0}:{line:"",content:_[2],context:!1},R=n.get(k)??[];R.push(A),n.set(k,R),A.context||(i+=1,r.set(k,(r.get(k)??0)+1)),o+=1,s=k}if(n.size===o)return t;let a=[...n.keys()].sort((f,c)=>{let g=mn.test(f)?1:0,_=mn.test(c)?1:0;return g-_||(f<c?-1:f>c?1:0)}),l=[];for(let f of a){l.push(`${f} (${r.get(f)??0}):`);for(let c of n.get(f))"separator"in c?l.push(" --"):c.line?l.push(` ${c.line}${c.context?"-":":"} ${hn(c.content)}`):l.push(` ${hn(c.content)}`)}let u=a.length>1&&l.length>di?gi(a.map(f=>`${f} (${r.get(f)??0})`)):[],d=[`${i}m ${a.length}f:`,...u,"",...l];if(d.length>ct){let f=d.length-ct;return[...d.slice(0,ct),`\u2026 ${f} more lines omitted`]}return d}$("smart-grep",yi);var gn=/^(?:([|\\/ ._-]*\*[|\\/* ._-]* ))?commit [0-9a-f]{7,40}\b/,_i=/^[|\\/* ._-]*$/,bi=/^ {4}/,vi=2;function xi(t){if(!t.some(u=>gn.test(u)))return t;let e=[],n=0,r=0,s=0,i="",o=!1,a=!1,l=()=>{r>0&&e.push(`${i} \u2026 ${r} ${r===1?"line":"lines"} folded \u2026`),r=0};for(let u of t){let d=u.slice(0,s),f=_i.test(d),c=f?u.slice(s):u,g=bi.test(c),_=o&&g?null:gn.exec(u);if(_){l(),n=0,s=_[1]?.length??0,o=!0,a=!1,e.push(u);continue}if(/^diff --(?:git|cc|combined) /.test(c)&&(a=!0),g&&!a&&!(s>0&&c.trim().length===0)){n+=1,n<=vi?e.push(u):(r+=1,i=f?d:"");continue}l(),e.push(u)}return l(),e}$("smart-log",xi);var ki=/^[\s=]+$/,Ei=/^\s*=+\s+(.*?)\s+=+\s*$/,wi=512;$("strip-banners",t=>{let e=[];for(let n of t){if(ki.test(n))continue;let r=n.length<=wi?Ei.exec(n):null;e.push(r?r[1]:n)}return e});function Si(t){let e=[],n=0,r=0;for(;r<t.length;){let s=t[r].replace(/\s+$/,"");if(s===""){n+=1,r+=1,n<=1&&e.push("");continue}n=0;let i=1;for(;r+i<t.length&&t[r+i].replace(/\s+$/,"")===s;)i+=1;if(i>=3)e.push(s),e.push(` \u2026 (repeated ${i}x)`);else for(let o=0;o<i;o++)e.push(s);r+=i}for(;e.length>0&&e[e.length-1]==="";)e.pop();return e}$("squeeze-output",Si);function Ti(t){return t==="compact"?.6:t==="minimal"?.3:1}var Ai=20;function Ri(t){let[e,n,r,s]=t.slice(-4);if(!e||!n||!r||!s||!/^\s*Test Files\s+([1-9]\d*) passed \(\1\)$/.test(e)||!/^\s*Tests\s+([1-9]\d*) passed \(\1\)$/.test(n)||!/^\s*Start at\s+\d{2}:\d{2}:\d{2}$/.test(r))return t;let i=/^(\s*Duration\s+\d+(?:\.\d+)?(?:ms|s)) \(transform [^\n]+\)$/.exec(s)?.[1];return i?[...t.slice(0,-4).filter((a,l)=>l>2||!/^ RUN v\d+\.\d+\.\d+(?:[\w.+-]*) .+$/.test(a)),e,n,i]:t}var yn=new WeakMap;function Ci(t){let e=yn.get(t);if(e)return e;let n=t.strip_lines_matching.map(s=>new RegExp(s)),r={def:t,stripRegexes:n};return yn.set(t,r),r}function _n(t,e,n={}){return lt(t,e,n).text}function lt(t,e,n={}){let r=n.verbosity??"normal";if(!e.strip_ansi&&e.strip_lines_matching.length===0&&!e.transform&&!e.mask_abs_paths&&!e.fold_passing&&!e.truncate_lines_at&&!e.max_lines&&!e.on_empty&&!n.smartCode&&r==="normal")return{text:t,droppedTail:null};let s=Ci(e),i=t;e.strip_ansi&&(i=ge(i));let o=i.endsWith(`
3
+ var _r=Object.defineProperty;var br=(t,e)=>{for(var n in e)_r(t,n,{get:e[n],enumerable:!0})};import{readdir as Is,readFile as Os}from"node:fs/promises";import{join as Jt,dirname as Ds}from"node:path";import{fileURLToPath as Ns}from"node:url";var m={};br(m,{BRAND:()=>Vr,DIRTY:()=>te,EMPTY_PATH:()=>Er,INVALID:()=>v,NEVER:()=>Cs,OK:()=>O,ParseStatus:()=>C,Schema:()=>w,ZodAny:()=>J,ZodArray:()=>W,ZodBigInt:()=>re,ZodBoolean:()=>se,ZodBranded:()=>Oe,ZodCatch:()=>he,ZodDate:()=>ie,ZodDefault:()=>me,ZodDiscriminatedUnion:()=>Ke,ZodEffects:()=>L,ZodEnum:()=>fe,ZodError:()=>D,ZodFirstPartyTypeKind:()=>x,ZodFunction:()=>Ge,ZodIntersection:()=>le,ZodIssueCode:()=>p,ZodLazy:()=>ue,ZodLiteral:()=>de,ZodMap:()=>Ee,ZodNaN:()=>Se,ZodNativeEnum:()=>pe,ZodNever:()=>F,ZodNull:()=>ae,ZodNullable:()=>U,ZodNumber:()=>ne,ZodObject:()=>N,ZodOptional:()=>P,ZodParsedType:()=>y,ZodPipeline:()=>De,ZodPromise:()=>X,ZodReadonly:()=>ge,ZodRecord:()=>We,ZodSchema:()=>w,ZodSet:()=>we,ZodString:()=>q,ZodSymbol:()=>xe,ZodTransformer:()=>L,ZodTuple:()=>Z,ZodType:()=>w,ZodUndefined:()=>oe,ZodUnion:()=>ce,ZodUnknown:()=>K,ZodVoid:()=>ke,addIssueToContext:()=>h,any:()=>es,array:()=>ss,bigint:()=>Yr,boolean:()=>Gt,coerce:()=>Rs,custom:()=>Vt,date:()=>qr,datetimeRegex:()=>Ut,defaultErrorMap:()=>H,discriminatedUnion:()=>cs,effect:()=>vs,enum:()=>ys,function:()=>ms,getErrorMap:()=>_e,getParsedType:()=>z,instanceof:()=>Wr,intersection:()=>ls,isAborted:()=>He,isAsync:()=>be,isDirty:()=>Ve,isValid:()=>Y,late:()=>Kr,lazy:()=>hs,literal:()=>gs,makeIssue:()=>Ie,map:()=>fs,nan:()=>Gr,nativeEnum:()=>_s,never:()=>ns,null:()=>Qr,nullable:()=>ks,number:()=>Wt,object:()=>is,objectUtil:()=>ot,oboolean:()=>As,onumber:()=>Ts,optional:()=>xs,ostring:()=>Ss,pipeline:()=>ws,preprocess:()=>Es,promise:()=>bs,quotelessJson:()=>vr,record:()=>ds,set:()=>ps,setErrorMap:()=>kr,strictObject:()=>os,string:()=>Kt,symbol:()=>Jr,transformer:()=>vs,tuple:()=>us,undefined:()=>Xr,union:()=>as,unknown:()=>ts,util:()=>S,void:()=>rs});var S;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{let i={};for(let o of s)i[o]=o;return i},t.getValidEnumValues=s=>{let i=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(let a of i)o[a]=s[a];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=(s,i)=>{for(let o of s)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(S||(S={}));var ot;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(ot||(ot={}));var y=S.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 y.undefined;case"string":return y.string;case"number":return Number.isNaN(t)?y.nan:y.number;case"boolean":return y.boolean;case"function":return y.function;case"bigint":return y.bigint;case"symbol":return y.symbol;case"object":return Array.isArray(t)?y.array:t===null?y.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?y.promise:typeof Map<"u"&&t instanceof Map?y.map:typeof Set<"u"&&t instanceof Set?y.set:typeof Date<"u"&&t instanceof Date?y.date:y.object;default:return y.unknown}};var p=S.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"]),vr=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=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){let n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,l=0;for(;l<o.path.length;){let u=o.path[l];l===o.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(n(o))):a[u]=a[u]||{_errors:[]},a=a[u],l++}}};return s(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,S.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};D.create=t=>new D(t);var xr=(t,e)=>{let n;switch(t.code){case p.invalid_type:t.received===y.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case p.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,S.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:n=`Unrecognized key(s) in object: ${S.joinValues(t.keys,", ")}`;break;case p.invalid_union:n="Invalid input";break;case p.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${S.joinValues(t.options)}`;break;case p.invalid_enum_value:n=`Invalid enum value. Expected ${S.joinValues(t.options)}, received '${t.received}'`;break;case p.invalid_arguments:n="Invalid function arguments";break;case p.invalid_return_type:n="Invalid function return type";break;case p.invalid_date:n="Invalid date";break;case p.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:S.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case p.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case p.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case p.custom:n="Invalid input";break;case p.invalid_intersection_types:n="Intersection results could not be merged";break;case p.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case p.not_finite:n="Number must be finite";break;default:n=e.defaultError,S.assertNever(t)}return{message:n}},H=xr;var Ft=H;function kr(t){Ft=t}function _e(){return Ft}var Ie=t=>{let{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="",l=r.filter(u=>!!u).slice().reverse();for(let u of l)a=u(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}},Er=[];function h(t,e){let n=_e(),r=Ie({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===H?void 0:H].filter(s=>!!s)});t.common.issues.push(r)}var C=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let s of n){if(s.status==="aborted")return v;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let s of n){let i=await s.key,o=await s.value;r.push({key:i,value:o})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let s of n){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return v;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}},v=Object.freeze({status:"aborted"}),te=t=>({status:"dirty",value:t}),O=t=>({status:"valid",value:t}),He=t=>t.status==="aborted",Ve=t=>t.status==="dirty",Y=t=>t.status==="valid",be=t=>typeof Promise<"u"&&t instanceof Promise;var b;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(b||(b={}));var M=class{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Bt=(t,e)=>{if(Y(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new D(t.common.issues);return this._error=n,this._error}}};function E(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{let{message:l}=t;return o.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:s}}var w=class{get description(){return this._def.description}_getType(e){return z(e.data)}_getOrReturnCtx(e,n){return n||{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 C,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 n=this._parse(e);if(be(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)},s=this._parseSync({data:e,path:r.path,parent:r});return Bt(r,s)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return Y(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>Y(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(be(s)?s:Promise.resolve(s));return Bt(r,i)}refine(e,n){let r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{let o=e(s),a=()=>i.addIssue({code:p.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new L({schema:this,typeName:x.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return P.create(this,this._def)}nullable(){return U.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return W.create(this)}promise(){return X.create(this,this._def)}or(e){return ce.create([this,e],this._def)}and(e){return le.create(this,e,this._def)}transform(e){return new L({...E(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new me({...E(this._def),innerType:this,defaultValue:n,typeName:x.ZodDefault})}brand(){return new Oe({typeName:x.ZodBranded,type:this,...E(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new he({...E(this._def),innerType:this,catchValue:n,typeName:x.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return De.create(this,e)}readonly(){return ge.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},wr=/^c[^\s-]{8,}$/i,Sr=/^[0-9a-z]+$/,Tr=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ar=/^[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,Rr=/^[a-z0-9_-]{21}$/i,Cr=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ir=/^[-+]?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)?)??$/,Or=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Dr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",at,Nr=/^(?:(?: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])$/,$r=/^(?:(?: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])$/,Pr=/^(([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]))$/,Mr=/^(([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])$/,Lr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Fr=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,zt="((\\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])))",Br=new RegExp(`^${zt}$`);function Zt(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function jr(t){return new RegExp(`^${Zt(t)}$`)}function Ut(t){let e=`${zt}T${Zt(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function zr(t,e){return!!((e==="v4"||!e)&&Nr.test(t)||(e==="v6"||!e)&&Pr.test(t))}function Zr(t,e){if(!Cr.test(t))return!1;try{let[n]=t.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Ur(t,e){return!!((e==="v4"||!e)&&$r.test(t)||(e==="v6"||!e)&&Mr.test(t))}var q=class t extends w{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y.string){let i=this._getOrReturnCtx(e);return h(i,{code:p.invalid_type,expected:y.string,received:i.parsedType}),v}let r=new C,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:p.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:p.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(e,s),o?h(s,{code:p.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&h(s,{code:p.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")Or.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"email",code:p.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")at||(at=new RegExp(Dr,"u")),at.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"emoji",code:p.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")Ar.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"uuid",code:p.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Rr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"nanoid",code:p.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")wr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cuid",code:p.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")Sr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cuid2",code:p.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")Tr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"ulid",code:p.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),h(s,{validation:"url",code:p.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"regex",code:p.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),h(s,{code:p.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),h(s,{code:p.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),h(s,{code:p.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?Ut(i).test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:p.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Br.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:p.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?jr(i).test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:p.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Ir.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"duration",code:p.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?zr(e.data,i.version)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"ip",code:p.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?Zr(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"jwt",code:p.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Ur(e.data,i.version)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cidr",code:p.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?Lr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64",code:p.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Fr.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64url",code:p.invalid_string,message:i.message}),r.dirty()):S.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:p.invalid_string,...b.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...b.errToObj(e)})}url(e){return this._addCheck({kind:"url",...b.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...b.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...b.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...b.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...b.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...b.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...b.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...b.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...b.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...b.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...b.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...b.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,...b.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,...b.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...b.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...b.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...b.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...b.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...b.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...b.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...b.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...b.errToObj(n)})}nonempty(e){return this.min(1,b.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};q.create=t=>new q({checks:[],typeName:x.ZodString,coerce:t?.coerce??!1,...E(t)});function Hr(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}var ne=class t extends w{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==y.number){let i=this._getOrReturnCtx(e);return h(i,{code:p.invalid_type,expected:y.number,received:i.parsedType}),v}let r,s=new C;for(let i of this._def.checks)i.kind==="int"?S.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:p.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:p.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:p.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Hr(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),h(r,{code:p.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:p.not_finite,message:i.message}),s.dirty()):S.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,b.toString(n))}gt(e,n){return this.setLimit("min",e,!1,b.toString(n))}lte(e,n){return this.setLimit("max",e,!0,b.toString(n))}lt(e,n){return this.setLimit("max",e,!1,b.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:b.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:b.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:b.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:b.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:b.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&S.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};ne.create=t=>new ne({checks:[],typeName:x.ZodNumber,coerce:t?.coerce||!1,...E(t)});var re=class t extends w{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==y.bigint)return this._getInvalidInput(e);let r,s=new C;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:p.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:p.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),h(r,{code:p.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):S.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return h(n,{code:p.invalid_type,expected:y.bigint,received:n.parsedType}),v}gte(e,n){return this.setLimit("min",e,!0,b.toString(n))}gt(e,n){return this.setLimit("min",e,!1,b.toString(n))}lte(e,n){return this.setLimit("max",e,!0,b.toString(n))}lt(e,n){return this.setLimit("max",e,!1,b.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:b.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:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:b.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};re.create=t=>new re({checks:[],typeName:x.ZodBigInt,coerce:t?.coerce??!1,...E(t)});var se=class extends w{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){let r=this._getOrReturnCtx(e);return h(r,{code:p.invalid_type,expected:y.boolean,received:r.parsedType}),v}return O(e.data)}};se.create=t=>new se({typeName:x.ZodBoolean,coerce:t?.coerce||!1,...E(t)});var ie=class t extends w{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y.date){let i=this._getOrReturnCtx(e);return h(i,{code:p.invalid_type,expected:y.date,received:i.parsedType}),v}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return h(i,{code:p.invalid_date}),v}let r=new C,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:p.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:p.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):S.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:b.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:b.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};ie.create=t=>new ie({checks:[],coerce:t?.coerce||!1,typeName:x.ZodDate,...E(t)});var xe=class extends w{_parse(e){if(this._getType(e)!==y.symbol){let r=this._getOrReturnCtx(e);return h(r,{code:p.invalid_type,expected:y.symbol,received:r.parsedType}),v}return O(e.data)}};xe.create=t=>new xe({typeName:x.ZodSymbol,...E(t)});var oe=class extends w{_parse(e){if(this._getType(e)!==y.undefined){let r=this._getOrReturnCtx(e);return h(r,{code:p.invalid_type,expected:y.undefined,received:r.parsedType}),v}return O(e.data)}};oe.create=t=>new oe({typeName:x.ZodUndefined,...E(t)});var ae=class extends w{_parse(e){if(this._getType(e)!==y.null){let r=this._getOrReturnCtx(e);return h(r,{code:p.invalid_type,expected:y.null,received:r.parsedType}),v}return O(e.data)}};ae.create=t=>new ae({typeName:x.ZodNull,...E(t)});var J=class extends w{constructor(){super(...arguments),this._any=!0}_parse(e){return O(e.data)}};J.create=t=>new J({typeName:x.ZodAny,...E(t)});var K=class extends w{constructor(){super(...arguments),this._unknown=!0}_parse(e){return O(e.data)}};K.create=t=>new K({typeName:x.ZodUnknown,...E(t)});var F=class extends w{_parse(e){let n=this._getOrReturnCtx(e);return h(n,{code:p.invalid_type,expected:y.never,received:n.parsedType}),v}};F.create=t=>new F({typeName:x.ZodNever,...E(t)});var ke=class extends w{_parse(e){if(this._getType(e)!==y.undefined){let r=this._getOrReturnCtx(e);return h(r,{code:p.invalid_type,expected:y.void,received:r.parsedType}),v}return O(e.data)}};ke.create=t=>new ke({typeName:x.ZodVoid,...E(t)});var W=class t extends w{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==y.array)return h(n,{code:p.invalid_type,expected:y.array,received:n.parsedType}),v;if(s.exactLength!==null){let o=n.data.length>s.exactLength.value,a=n.data.length<s.exactLength.value;(o||a)&&(h(n,{code:o?p.too_big:p.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(h(n,{code:p.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(h(n,{code:p.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>s.type._parseAsync(new M(n,o,n.path,a)))).then(o=>C.mergeArray(r,o));let i=[...n.data].map((o,a)=>s.type._parseSync(new M(n,o,n.path,a)));return C.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:b.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:b.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:b.toString(n)}})}nonempty(e){return this.min(1,e)}};W.create=(t,e)=>new W({type:t,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...E(e)});function ve(t){if(t instanceof N){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=P.create(ve(r))}return new N({...t._def,shape:()=>e})}else return t instanceof W?new W({...t._def,type:ve(t.element)}):t instanceof P?P.create(ve(t.unwrap())):t instanceof U?U.create(ve(t.unwrap())):t instanceof Z?Z.create(t.items.map(e=>ve(e))):t}var N=class t extends w{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=S.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==y.object){let u=this._getOrReturnCtx(e);return h(u,{code:p.invalid_type,expected:y.object,received:u.parsedType}),v}let{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof F&&this._def.unknownKeys==="strip"))for(let u in s.data)o.includes(u)||a.push(u);let l=[];for(let u of o){let f=i[u],d=s.data[u];l.push({key:{status:"valid",value:u},value:f._parse(new M(s,d,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof F){let u=this._def.unknownKeys;if(u==="passthrough")for(let f of a)l.push({key:{status:"valid",value:f},value:{status:"valid",value:s.data[f]}});else if(u==="strict")a.length>0&&(h(s,{code:p.unrecognized_keys,keys:a}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let f of a){let d=s.data[f];l.push({key:{status:"valid",value:f},value:u._parse(new M(s,d,s.path,f)),alwaysSet:f in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let f of l){let d=await f.key,c=await f.value;u.push({key:d,value:c,alwaysSet:f.alwaysSet})}return u}).then(u=>C.mergeObjectSync(r,u)):C.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return b.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:b.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:x.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of S.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of S.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return ve(this)}partial(e){let n={};for(let r of S.objectKeys(this.shape)){let s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of S.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof P;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return Ht(S.objectKeys(this.shape))}};N.create=(t,e)=>new N({shape:()=>t,unknownKeys:"strip",catchall:F.create(),typeName:x.ZodObject,...E(e)});N.strictCreate=(t,e)=>new N({shape:()=>t,unknownKeys:"strict",catchall:F.create(),typeName:x.ZodObject,...E(e)});N.lazycreate=(t,e)=>new N({shape:t,unknownKeys:"strip",catchall:F.create(),typeName:x.ZodObject,...E(e)});var ce=class extends w{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(let a of i)if(a.result.status==="valid")return a.result;for(let a of i)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(a=>new D(a.ctx.common.issues));return h(n,{code:p.invalid_union,unionErrors:o}),v}if(n.common.async)return Promise.all(r.map(async i=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let l of r){let u={...n,common:{...n.common,issues:[]},parent:null},f=l._parseSync({data:n.data,path:n.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!i&&(i={result:f,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(l=>new D(l));return h(n,{code:p.invalid_union,unionErrors:a}),v}}get options(){return this._def.options}};ce.create=(t,e)=>new ce({options:t,typeName:x.ZodUnion,...E(e)});var V=t=>t instanceof ue?V(t.schema):t instanceof L?V(t.innerType()):t instanceof de?[t.value]:t instanceof fe?t.options:t instanceof pe?S.objectValues(t.enum):t instanceof me?V(t._def.innerType):t instanceof oe?[void 0]:t instanceof ae?[null]:t instanceof P?[void 0,...V(t.unwrap())]:t instanceof U?[null,...V(t.unwrap())]:t instanceof Oe||t instanceof ge?V(t.unwrap()):t instanceof he?V(t._def.innerType):[],Ke=class t extends w{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.object)return h(n,{code:p.invalid_type,expected:y.object,received:n.parsedType}),v;let r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(h(n,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let s=new Map;for(let i of n){let o=V(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,i)}}return new t({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...E(r)})}};function ct(t,e){let n=z(t),r=z(e);if(t===e)return{valid:!0,data:t};if(n===y.object&&r===y.object){let s=S.objectKeys(e),i=S.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(let a of i){let l=ct(t[a],e[a]);if(!l.valid)return{valid:!1};o[a]=l.data}return{valid:!0,data:o}}else if(n===y.array&&r===y.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let o=t[i],a=e[i],l=ct(o,a);if(!l.valid)return{valid:!1};s.push(l.data)}return{valid:!0,data:s}}else return n===y.date&&r===y.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var le=class extends w{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(He(i)||He(o))return v;let a=ct(i.value,o.value);return a.valid?((Ve(i)||Ve(o))&&n.dirty(),{status:n.value,value:a.data}):(h(r,{code:p.invalid_intersection_types}),v)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};le.create=(t,e,n)=>new le({left:t,right:e,typeName:x.ZodIntersection,...E(n)});var Z=class t extends w{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.array)return h(r,{code:p.invalid_type,expected:y.array,received:r.parsedType}),v;if(r.data.length<this._def.items.length)return h(r,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&r.data.length>this._def.items.length&&(h(r,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...r.data].map((o,a)=>{let l=this._def.items[a]||this._def.rest;return l?l._parse(new M(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>C.mergeArray(n,o)):C.mergeArray(n,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:x.ZodTuple,rest:null,...E(e)})};var We=class t extends w{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.object)return h(r,{code:p.invalid_type,expected:y.object,received:r.parsedType}),v;let s=[],i=this._def.keyType,o=this._def.valueType;for(let a in r.data)s.push({key:i._parse(new M(r,a,r.path,a)),value:o._parse(new M(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?C.mergeObjectAsync(n,s):C.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof w?new t({keyType:e,valueType:n,typeName:x.ZodRecord,...E(r)}):new t({keyType:q.create(),valueType:e,typeName:x.ZodRecord,...E(n)})}},Ee=class extends w{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.map)return h(r,{code:p.invalid_type,expected:y.map,received:r.parsedType}),v;let s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,l],u)=>({key:s._parse(new M(r,a,r.path,[u,"key"])),value:i._parse(new M(r,l,r.path,[u,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let l of o){let u=await l.key,f=await l.value;if(u.status==="aborted"||f.status==="aborted")return v;(u.status==="dirty"||f.status==="dirty")&&n.dirty(),a.set(u.value,f.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let l of o){let u=l.key,f=l.value;if(u.status==="aborted"||f.status==="aborted")return v;(u.status==="dirty"||f.status==="dirty")&&n.dirty(),a.set(u.value,f.value)}return{status:n.value,value:a}}}};Ee.create=(t,e,n)=>new Ee({valueType:e,keyType:t,typeName:x.ZodMap,...E(n)});var we=class t extends w{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.set)return h(r,{code:p.invalid_type,expected:y.set,received:r.parsedType}),v;let s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(h(r,{code:p.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(h(r,{code:p.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());let i=this._def.valueType;function o(l){let u=new Set;for(let f of l){if(f.status==="aborted")return v;f.status==="dirty"&&n.dirty(),u.add(f.value)}return{status:n.value,value:u}}let a=[...r.data.values()].map((l,u)=>i._parse(new M(r,l,r.path,u)));return r.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(e,n){return new t({...this._def,minSize:{value:e,message:b.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:b.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};we.create=(t,e)=>new we({valueType:t,minSize:null,maxSize:null,typeName:x.ZodSet,...E(e)});var Ge=class t extends w{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.function)return h(n,{code:p.invalid_type,expected:y.function,received:n.parsedType}),v;function r(a,l){return Ie({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,_e(),H].filter(u=>!!u),issueData:{code:p.invalid_arguments,argumentsError:l}})}function s(a,l){return Ie({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,_e(),H].filter(u=>!!u),issueData:{code:p.invalid_return_type,returnTypeError:l}})}let i={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof X){let a=this;return O(async function(...l){let u=new D([]),f=await a._def.args.parseAsync(l,i).catch(g=>{throw u.addIssue(r(l,g)),u}),d=await Reflect.apply(o,this,f);return await a._def.returns._def.type.parseAsync(d,i).catch(g=>{throw u.addIssue(s(d,g)),u})})}else{let a=this;return O(function(...l){let u=a._def.args.safeParse(l,i);if(!u.success)throw new D([r(l,u.error)]);let f=Reflect.apply(o,this,u.data),d=a._def.returns.safeParse(f,i);if(!d.success)throw new D([s(f,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Z.create(e).rest(K.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||Z.create([]).rest(K.create()),returns:n||K.create(),typeName:x.ZodFunction,...E(r)})}},ue=class extends w{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};ue.create=(t,e)=>new ue({getter:t,typeName:x.ZodLazy,...E(e)});var de=class extends w{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return h(n,{received:n.data,code:p.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}};de.create=(t,e)=>new de({value:t,typeName:x.ZodLiteral,...E(e)});function Ht(t,e){return new fe({values:t,typeName:x.ZodEnum,...E(e)})}var fe=class t extends w{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return h(n,{expected:S.joinValues(r),received:n.parsedType,code:p.invalid_type}),v}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return h(n,{received:n.data,code:p.invalid_enum_value,options:r}),v}return O(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};fe.create=Ht;var pe=class extends w{_parse(e){let n=S.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==y.string&&r.parsedType!==y.number){let s=S.objectValues(n);return h(r,{expected:S.joinValues(s),received:r.parsedType,code:p.invalid_type}),v}if(this._cache||(this._cache=new Set(S.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=S.objectValues(n);return h(r,{received:r.data,code:p.invalid_enum_value,options:s}),v}return O(e.data)}get enum(){return this._def.values}};pe.create=(t,e)=>new pe({values:t,typeName:x.ZodNativeEnum,...E(e)});var X=class extends w{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.promise&&n.common.async===!1)return h(n,{code:p.invalid_type,expected:y.promise,received:n.parsedType}),v;let r=n.parsedType===y.promise?n.data:Promise.resolve(n.data);return O(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};X.create=(t,e)=>new X({type:t,typeName:x.ZodPromise,...E(e)});var L=class extends w{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{h(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return v;let l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?v:l.status==="dirty"?te(l.value):n.value==="dirty"?te(l.value):l});{if(n.value==="aborted")return v;let a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?v:a.status==="dirty"?te(a.value):n.value==="dirty"?te(a.value):a}}if(s.type==="refinement"){let o=a=>{let l=s.refinement(a,i);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?v:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?v:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Y(o))return v;let a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Y(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:n.value,value:a})):v);S.assertNever(s)}};L.create=(t,e,n)=>new L({schema:t,typeName:x.ZodEffects,effect:e,...E(n)});L.createWithPreprocess=(t,e,n)=>new L({schema:e,effect:{type:"preprocess",transform:t},typeName:x.ZodEffects,...E(n)});var P=class extends w{_parse(e){return this._getType(e)===y.undefined?O(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};P.create=(t,e)=>new P({innerType:t,typeName:x.ZodOptional,...E(e)});var U=class extends w{_parse(e){return this._getType(e)===y.null?O(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};U.create=(t,e)=>new U({innerType:t,typeName:x.ZodNullable,...E(e)});var me=class extends w{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===y.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};me.create=(t,e)=>new me({innerType:t,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...E(e)});var he=class extends w{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return be(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new D(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new D(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};he.create=(t,e)=>new he({innerType:t,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...E(e)});var Se=class extends w{_parse(e){if(this._getType(e)!==y.nan){let r=this._getOrReturnCtx(e);return h(r,{code:p.invalid_type,expected:y.nan,received:r.parsedType}),v}return{status:"valid",value:e.data}}};Se.create=t=>new Se({typeName:x.ZodNaN,...E(t)});var Vr=Symbol("zod_brand"),Oe=class extends w{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},De=class t extends w{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?v:i.status==="dirty"?(n.dirty(),te(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{let s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?v:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:x.ZodPipeline})}},ge=class extends w{_parse(e){let n=this._def.innerType._parse(e),r=s=>(Y(s)&&(s.value=Object.freeze(s.value)),s);return be(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};ge.create=(t,e)=>new ge({innerType:t,typeName:x.ZodReadonly,...E(e)});function jt(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Vt(t,e={},n){return t?J.create().superRefine((r,s)=>{let i=t(r);if(i instanceof Promise)return i.then(o=>{if(!o){let a=jt(e,r),l=a.fatal??n??!0;s.addIssue({code:"custom",...a,fatal:l})}});if(!i){let o=jt(e,r),a=o.fatal??n??!0;s.addIssue({code:"custom",...o,fatal:a})}}):J.create()}var Kr={object:N.lazycreate},x;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(x||(x={}));var Wr=(t,e={message:`Input not instance of ${t.name}`})=>Vt(n=>n instanceof t,e),Kt=q.create,Wt=ne.create,Gr=Se.create,Yr=re.create,Gt=se.create,qr=ie.create,Jr=xe.create,Xr=oe.create,Qr=ae.create,es=J.create,ts=K.create,ns=F.create,rs=ke.create,ss=W.create,is=N.create,os=N.strictCreate,as=ce.create,cs=Ke.create,ls=le.create,us=Z.create,ds=We.create,fs=Ee.create,ps=we.create,ms=Ge.create,hs=ue.create,gs=de.create,ys=fe.create,_s=pe.create,bs=X.create,vs=L.create,xs=P.create,ks=U.create,Es=L.createWithPreprocess,ws=De.create,Ss=()=>Kt().optional(),Ts=()=>Wt().optional(),As=()=>Gt().optional(),Rs={string:(t=>q.create({...t,coerce:!0})),number:(t=>ne.create({...t,coerce:!0})),boolean:(t=>se.create({...t,coerce:!0})),bigint:(t=>re.create({...t,coerce:!0})),date:(t=>ie.create({...t,coerce:!0}))};var Cs=v;var Te=m.object({slug:m.string().min(1).max(64),description:m.string().max(255).optional(),match_command:m.string().min(1),priority:m.number().int().default(50),strip_ansi:m.boolean().default(!1),strip_lines_matching:m.array(m.string()).default([]),keep_failures:m.boolean().default(!1),fold_passing:m.boolean().default(!1),fold_passing_threshold:m.number().int().positive().max(1e3).optional(),mask_abs_paths:m.boolean().default(!1),preserve_exact:m.boolean().default(!1),truncate_lines_at:m.number().int().positive().max(1e4).optional(),max_lines:m.number().int().positive().max(1e5).optional(),scale_with_level:m.boolean().default(!0),transform:m.string().max(64).optional(),on_empty:m.string().max(255).optional()});var $s=Ds(Ns(import.meta.url)),Yt=process.env.TOKMIZER_FILTERS_DIR||Jt($s,"..","..","filters"),Q=null,qt=!1;function Ps(){return process.env.TOKMIZER_DEV==="1"||process.env.TOKMIZER_DEV==="true"}async function Xt(){if(Q)return Q;if(!Ps())return!qt&&process.env.TOKMIZER_DEBUG==="1"&&(process.stderr.write(`tokmizer: disk loader disabled (set TOKMIZER_DEV=1 to re-enable for local dev).
4
+ `),qt=!0),Q=new Map,Q;let t=new Map,e,n;try{e=(await import("smol-toml")).parse,n=(await Is(Yt)).filter(r=>r.endsWith(".toml"))}catch{return Q=t,Q}for(let r of n){let s=await Os(Jt(Yt,r),"utf8"),o=e(s).filters;if(o)for(let[a,l]of Object.entries(o)){let u=Te.parse({slug:a,...l});t.set(a,{...u,matchRegex:new RegExp(u.match_command)})}}return Q=t,Q}import{createHash as Ms}from"node:crypto";var Ls=m.enum(["normal","compact","minimal"]),Fs=m.enum(["off","light","balanced","max"]),Ne=m.object({enabled:m.boolean().default(!0),telemetryOptIn:m.boolean().default(!0),outputVerbosity:Ls.default("compact"),reducer:Fs.default("off"),filters:m.object({enableAll:m.boolean().default(!0),disabled:m.array(m.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})}),Bs=["git","git-status","git-log","git-diff","grep","find","diff","ls","ls-long","ps","cat","head","tail","df","du","tree","wc","nl","xargs","seq","echo","printf","sleep","shasum","python","node","read-tool","grep-tool","glob-tool","bash-tool","npm","npm-test","docker","kubectl","curl","cargo","go-test","go-build","gh","gh-api","aws","dotnet","prisma","tsc","next","jest","vitest","pytest","pip","rspec"],js=/^[0-9a-f]{16}$/,Qt=new Map;function B(t){let e=Qt.get(t);return e||(e=Ms("sha256").update(`tkr:${t}`).digest("hex").slice(0,16),Qt.set(t,e)),e}var en=null;function Ye(t,e=!1){return e||!t||t.length===0?(en??=new Set(Bs.map(B)),new Set(en)):new Set(t.map(n=>js.test(n)?n:B(n)))}var Ae=new Map,zs=256,tn=new WeakMap;function Zs(t){if(!t)return"*";let e=tn.get(t);return e===void 0&&(e=[...t].join(","),tn.set(t,e)),e}function qe(t,e,n){let r=`${t}::${Zs(n)}`,s=Ae.get(r);if(s!==void 0)return s;let i=null;for(let o of e)n&&!n.has(B(o.slug))||o.matchRegex.test(t)&&(!i||o.priority>i.priority)&&(i=o);if(Ae.size>=zs){let o=Ae.keys().next().value;o&&Ae.delete(o)}return Ae.set(r,i),i}function nn(){Ae.clear()}var Us=/\x1b\[[0-9;?]*[ -/]*[@-~]/g,Hs=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g;function ye(t){return t.replace(Us,"").replace(Hs,"")}function rn(t,e){return e.length===0?t:t.filter(n=>!e.some(r=>r.test(n)))}function sn(t,e){return t.map(n=>{if(n.length<=e)return n;let r=n.charCodeAt(e-1),s=n.charCodeAt(e),i=r>=55296&&r<=56319&&s>=56320&&s<=57343?e-1:e;return`${n.slice(0,i)}\u2026`})}function Je(t){return`\u2026 (${t} more lines omitted)`}function on(t,e){if(t.length<=e)return{kept:t,dropped:[]};let n=Math.ceil(e*.7),r=e-n,s=t.slice(n,t.length-r);return{kept:[...t.slice(0,n),Je(s.length),...t.slice(t.length-r)],dropped:s}}var Vs=/^\s*(?:[✓✔√]|ok )/,ee=/✕|✗|×|\bFAIL\b|\bERROR\b|\bFATAL\b|\bError|\berror|Expected|Received|\bfailed\b|^\s*Tests?:|^\s*Test Suites?:/;function an(t,e){let n=e>0?e:5,r=[],s=0,i=a=>{s>=n?r.push(`\u2026 ${s} passing checks folded \u2026`):r.push(...a)},o=[];for(let a of t)Vs.test(a)&&!ee.test(a)?(o.push(a),s+=1):(i(o),o=[],s=0,r.push(a));return i(o),r}var Ks=/(?:\/[\w.@+-]+){3,}/g;function cn(t){return t.map(e=>e.replace(Ks,n=>{let r=n.split("/").filter(Boolean);return r.length<=2?n:`\u2026/${r.slice(-2).join("/")}`}))}var Ws=/^(\s*)(?:export\s+)?(?:async\s+)?(?:function|interface|type|const|let|var|def|fn|impl|trait|struct|enum)\s+[\w$]+/,Gs=/\{\s*$/;var Ys=/^\s*(?:(?:public|private|protected|static|async|get|set|readonly|override)\s+)*([\w$]+)\s*\(([^)]*)\)\s*(?::\s*[^{]+)?\{\s*$/,qs=new Set(["if","for","while","switch","catch","do","with","return","else","function","await","yield"]);function Js(t){let e=Ys.exec(t);return!e||qs.has(e[1])?!1:!/=>|\bfunction\b/.test(e[2])}var Xs=/^\s*(?:if|for|while|switch|try|do)\b[^{}]*\{\s*$/;function Qs(t,e,n){let r=e;for(;r<t.length;){if(t[r]==="\\"){r+=2;continue}if(t[r]===n)return!0;r+=1}return!1}function ei(t,e){let n=0,r=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(r){if(i==="\\"){s+=2;continue}i===r&&(r=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==='"'){let o=s>0?t[s-1]:"";!(i==="'"&&(o==="<"||o==="&"))&&Qs(t,s+1,i)&&(r=i),s+=1;continue}i==="{"||i==="("||i==="["?n+=1:(i==="}"||i===")"||i==="]")&&(n-=1),s+=1}return n}var ti=/^\s*… (\d+) lines? folded …$/;function lt(t){let e=new Array(t.length).fill(!1);for(let n=0;n<t.length;n+=1){let r=ti.exec(t[n]);if(!r)continue;let s=Number(r[1])-1,i=n+1;for(;s>0&&i<t.length&&t[i]==="";)e[i]=!0,s-=1,i+=1;n=i-1}return e}function Xe(t){let e=[],n=0;for(;n<t.length;){let r=t[n];if(Ws.test(r)&&Gs.test(r)||Js(r)||Xs.test(r)){let s={inBlockComment:!1,inTemplate:!1},i=0,o=n,a=!1;for(;o<t.length&&o-n<200;)if(i+=ei(t[o],s),o+=1,i<=0&&!s.inTemplate&&!s.inBlockComment){a=!0;break}let l=o-n;if(a&&l>=3){let u=l-2,f=/^\s*/.exec(t[n+1]??"")?.[0]??" ";e.push(r),e.push(`${f}\u2026 ${u} ${u===1?"line":"lines"} folded \u2026`);for(let d=0;d<u-1;d++)e.push("");e.push(t[o-1]),n=o;continue}}e.push(r),n+=1}return e}var ni=/\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 Qe(t){let e=t.slice(0,4096);return!(!ni.test(e)||e.split(`
5
+ `).length<6)}var ri=/^\s*(?:\d{4}-\d{2}-\d{2}[T\s]\d{2}:\d{2}:\d{2}(?:\.\d+)?Z?|\d{2}:\d{2}:\d{2}(?:\.\d+)?)\s*/,si=/^\s*(?:\[(?:DEBUG|TRACE|INFO|VERBOSE)\]|(?:DEBUG|TRACE|INFO|VERBOSE)(?!\s*:))(?=\s|:|$)(?!\s*[+\-*\/%&|^?]*=)/,ii=new RegExp(ee.source,"i"),oi=/\bWARN(?:ING)?\b/i;function ln(t){let e=[],n=0,r=()=>{n>0&&e.push(`\u2026 ${n} verbose log line${n===1?"":"s"} dropped \u2026`),n=0};for(let s of t){if(si.test(s.replace(ri,""))&&!ii.test(s)&&!oi.test(s)){n+=1;continue}r(),e.push(s)}return r(),e}function un(t){if(t.length===0)return t;let e=[],n=1,r=t[0];for(let s=1;s<t.length;s++){if(t[s]===r){n+=1;continue}e.push(n>1?`${r} \xD7${n}`:r),r=t[s],n=1}return e.push(n>1?`${r} \xD7${n}`:r),e}function dn(t){let e=[],n=0;for(let r of t){if(r.trim()===""){n+=1;continue}n>0&&e.push(""),n=0,e.push(r)}return e}var fn=new Map;function $(t,e){fn.set(t,e)}function pn(t){return fn.get(t)}var ai=/^[dbclps\-][rwxsStT\-]{9}[@.+]?(?:\s|$)/,ci=/^[./~][^\s]*:$/,ut=1e3;function li(t){if(t<1024)return String(t);let e=["K","M","G","T"],n=t/1024,r=0;for(;n>=1024&&r<e.length-1;)n/=1024,r+=1;return`${n.toFixed(1)}${e[r]}`}function ui(t){if(!ai.test(t))return null;let e=t.split(/\s+/);if(e.length<9)return null;let n=Number(e[4]);if(!Number.isFinite(n))return null;let r=e.slice(8).join(" ").trim();if(r===""||r==="."||r==="..")return null;let s=e[0].charCodeAt(0)===100;return{name:r,size:n,isDir:s}}function di(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 o=s.name.slice(i);e.set(o,(e.get(o)??0)+1)}let n=null,r=0;for(let[s,i]of e)i>r&&(r=i,n=s);return n&&r>=Math.ceil(t.length/2)?`${r} ${n}`:null}function fi(t){let e=[],n=[],r=!1;for(let c of t){if(/^total\s+\d+/.test(c))continue;if(ci.test(c.trim()))return t;let g=ui(c);g&&(r=!0,(g.isDir?e:n).push(g))}if(!r)return t;let s=(c,g)=>c.name.localeCompare(g.name);e.sort(s),n.sort((c,g)=>g.size-c.size||s(c,g));let i=[...e,...n],o=Math.min(40,Math.max(0,...i.map(c=>c.isDir?c.name.length+1:c.name.length))),a=[];for(let c of i){let g=c.isDir?`${c.name}/`:c.name,_=c.isDir?"":li(c.size);a.push(_?`${g.padEnd(o)} ${_}`:g)}if(a.length>ut){let c=a.length-ut;a=[...a.slice(0,ut),`\u2026 ${c} more lines omitted`]}let l=n.length===1?"file":"files",u=e.length===1?"dir":"dirs",f=di(n),d=`${n.length} ${l}, ${e.length} ${u}`+(f?` (${f})`:"");return a.push(d),a}$("smart-ls",fi);$("smart-read",t=>Xe(t));var mn=1e3;function pi(t){let e=t.filter(f=>f.trim()!=="");if(e.length===0||e.filter(f=>!/\s/.test(f.trim())).length<e.length*.6)return t;let r=new Map,s=[],i=0;for(let f of e){let d=f.trim();if(d.startsWith("find:")){s.push(d);continue}let c=d.replace(/^\.\//,"").replace(/\/+$/,""),g=c.lastIndexOf("/"),_=g>=0?c.slice(0,g):"",k=g>=0?c.slice(g+1):c;if(!k)continue;let R=r.get(_)??[];R.push(/\s/.test(k)?`"${k}"`:k),r.set(_,R),i+=1}if(i===0)return t;let o=new Set([""]);for(let f of r.keys()){if(f==="")continue;let d=f.split("/");for(let c=1;c<=d.length;c+=1)o.add(d.slice(0,c).join("/"))}let a=[...o].sort(),l=a.filter(f=>f!=="").length,u=[`${i}F ${l}D:`,""];for(let f of a){let d=f===""?0:f.split("/").length,c=f===""?".":f.slice(f.lastIndexOf("/")+1),g=r.get(f)??[],_=g.length?` ${g.join(" ")}`:"";u.push(`${" ".repeat(d)}${c}/${_}`)}if(u.length+s.length>mn){let f=Math.max(0,mn-s.length),d=u.length-f;return[...u.slice(0,f),`\u2026 ${d} more lines omitted`,...s]}return[...u,...s]}$("smart-find",pi);var dt=1e3,hn=200,mi=60,hi=190,gi=/^([^\s:]+):(\d+):(.*)$/,yi=/^([^:]+?)-(\d+)-(.*)$/,_i=/^([^\s:]+):(.*)$/,gn=/(?:^|\/)(?:__tests__|tests?|spec|fixtures?|__mocks__|__snapshots__)\/|\.(?:test|spec)\.[^/]+$/i;function yn(t){let e=t.trim();return e.length>hn?`${e.slice(0,hn)}\u2026`:e}function bi(t){let e=[],n="";for(let r of t){let s=n?`${n}, ${r}`:r;s.length>hi&&n?(e.push(`${n},`),n=r):n=s}return n&&e.push(n),e}function vi(t){let e=t.filter(d=>d.trim()!=="");if(e.length===0)return t;let n=new Map,r=new Map,s=null,i=0,o=0;for(let d of e){if(d==="--"){s&&n.get(s).push({separator:!0});continue}if(/^[A-Za-z]:[\\/]/.test(d))return t;let c=gi.exec(d),g=yi.exec(d);if(c&&g)return t;let _=c||g?null:_i.exec(d),k=(c??g??_)?.[1];if(!k)return t;let R=c?{line:c[2],content:c[3],context:!1}:g?{line:g[2],content:g[3],context:!0}:{line:"",content:_[2],context:!1},A=n.get(k)??[];A.push(R),n.set(k,A),R.context||(i+=1,r.set(k,(r.get(k)??0)+1)),o+=1,s=k}if(n.size===o)return t;let a=[...n.keys()].sort((d,c)=>{let g=gn.test(d)?1:0,_=gn.test(c)?1:0;return g-_||(d<c?-1:d>c?1:0)}),l=[];for(let d of a){l.push(`${d} (${r.get(d)??0}):`);for(let c of n.get(d))"separator"in c?l.push(" --"):c.line?l.push(` ${c.line}${c.context?"-":":"} ${yn(c.content)}`):l.push(` ${yn(c.content)}`)}let u=a.length>1&&l.length>mi?bi(a.map(d=>`${d} (${r.get(d)??0})`)):[],f=[`${i}m ${a.length}f:`,...u,"",...l];if(f.length>dt){let d=f.length-dt;return[...f.slice(0,dt),`\u2026 ${d} more lines omitted`]}return f}$("smart-grep",vi);var _n=/^(?:([|\\/ ._-]*\*[|\\/* ._-]* ))?commit [0-9a-f]{7,40}\b/,xi=/^[|\\/* ._-]*$/,ki=/^ {4}/,Ei=2;function wi(t){if(!t.some(u=>_n.test(u)))return t;let e=[],n=0,r=0,s=0,i="",o=!1,a=!1,l=()=>{r>0&&e.push(`${i} \u2026 ${r} ${r===1?"line":"lines"} folded \u2026`),r=0};for(let u of t){let f=u.slice(0,s),d=xi.test(f),c=d?u.slice(s):u,g=ki.test(c),_=o&&g?null:_n.exec(u);if(_){l(),n=0,s=_[1]?.length??0,o=!0,a=!1,e.push(u);continue}if(/^diff --(?:git|cc|combined) /.test(c)&&(a=!0),g&&!a&&!(s>0&&c.trim().length===0)){n+=1,n<=Ei?e.push(u):(r+=1,i=d?f:"");continue}l(),e.push(u)}return l(),e}$("smart-log",wi);var Si=/^[\s=]+$/,Ti=/^\s*=+\s+(.*?)\s+=+\s*$/,Ai=512;$("strip-banners",t=>{let e=[];for(let n of t){if(Si.test(n))continue;let r=n.length<=Ai?Ti.exec(n):null;e.push(r?r[1]:n)}return e});function Ri(t){let e=[],n=0,r=0;for(;r<t.length;){let s=t[r].replace(/\s+$/,"");if(s===""){n+=1,r+=1,n<=1&&e.push("");continue}n=0;let i=1;for(;r+i<t.length&&t[r+i].replace(/\s+$/,"")===s;)i+=1;if(i>=3)e.push(s),e.push(` \u2026 (repeated ${i}x)`);else for(let o=0;o<i;o++)e.push(s);r+=i}for(;e.length>0&&e[e.length-1]==="";)e.pop();return e}$("squeeze-output",Ri);function Ci(t){return t==="compact"?.6:t==="minimal"?.3:1}var Ii=20;function Oi(t){let[e,n,r,s]=t.slice(-4);if(!e||!n||!r||!s||!/^\s*Test Files\s+([1-9]\d*) passed \(\1\)$/.test(e)||!/^\s*Tests\s+([1-9]\d*) passed \(\1\)$/.test(n)||!/^\s*Start at\s+\d{2}:\d{2}:\d{2}$/.test(r))return t;let i=/^(\s*Duration\s+\d+(?:\.\d+)?(?:ms|s)) \(transform [^\n]+\)$/.exec(s)?.[1];return i?[...t.slice(0,-4).filter((a,l)=>l>2||!/^ RUN v\d+\.\d+\.\d+(?:[\w.+-]*) .+$/.test(a)),e,n,i]:t}var bn=new WeakMap;function Di(t){let e=bn.get(t);if(e)return e;let n=t.strip_lines_matching.map(s=>new RegExp(s)),r={def:t,stripRegexes:n};return bn.set(t,r),r}function vn(t,e,n={}){return ft(t,e,n).text}function ft(t,e,n={}){let r=n.verbosity??"normal";if(!e.strip_ansi&&e.strip_lines_matching.length===0&&!e.transform&&!e.mask_abs_paths&&!e.fold_passing&&!e.truncate_lines_at&&!e.max_lines&&!e.on_empty&&!n.smartCode&&r==="normal")return{text:t,droppedTail:null};let s=Di(e),i=t;e.strip_ansi&&(i=ye(i));let o=i.endsWith(`
6
6
  `),a=(o?i.slice(0,-1):i).split(`
7
- `);if(s.stripRegexes.length&&(a=e.keep_failures?a.filter(f=>Q.test(f)||!s.stripRegexes.some(c=>c.test(f))):en(a,s.stripRegexes)),r!=="normal"&&!e.preserve_exact&&(a=cn(a),a=ln(a)),r==="minimal"&&!e.preserve_exact&&(a=an(a),(e.slug==="vitest"||e.slug==="npm-test")&&(a=Ri(a))),!e.preserve_exact&&(n.smartCode||n.smartCode===void 0&&r!=="normal"&&on(i))&&(a=Xe(a)),e.transform){let f=dn(e.transform);f&&(a=f(a))}let l=e.slug==="read-tool";if(!l){let f=ot(a);f.some(Boolean)&&(a=a.filter((c,g)=>!f[g]))}e.mask_abs_paths&&(a=sn(a)),e.fold_passing&&(a=rn(a,e.fold_passing_threshold??5)),e.truncate_lines_at&&(a=tn(a,e.truncate_lines_at));let u=null;if(e.max_lines){let f=e.scale_with_level?Ti(n.verbosity):1,c=Math.min(e.max_lines,Math.max(Ai,Math.round(e.max_lines*f))),g=l?ot(a):null,_=g?g.filter(k=>!k).length:a.length;if(_>c){let k=c;if(g){let R=0;for(k=0;k<a.length&&R<c;)g[k]||(R+=1),k+=1}let A=_-c;if(e.keep_failures){let R=a.slice(k),B=R.filter(C=>!Q.test(C)),Re=R.reduce((C,Ce,Ie)=>C+(!Q.test(Ce)&&!g?.[k+Ie]?1:0),0);u=B.length>0?B.join(`
8
- `):null,a=[...a.slice(0,k),...Re>0?[Je(Re)]:[],...R.filter(C=>Q.test(C))]}else if(l)u=a.slice(k).join(`
9
- `),a=[...a.slice(0,k),Je(A)];else{let{kept:R,dropped:B}=nn(a,c);u=B.length>0?B.join(`
10
- `):null,a=R}}}let d=a.join(`
11
- `);return o&&d.length>0&&(d+=`
12
- `),d.trim().length===0&&e.on_empty&&(d=e.on_empty),{text:d,droppedTail:u}}var Ii=[/\bERROR\b/,/\bFAIL\b/,/\bFAILED\b/,/\bFATAL\b/,/^Traceback /m,/^Error: /m,/^\s+at .*\(.*:\d+:\d+\)/m,/panic:/,/SyntaxError:/,/TypeError:/,/ReferenceError:/,/AssertionError:/,/^\s*(?:error|fatal):/i,/thread '.*' panicked/,/\b[1-9]\d* (?:failed|errors?)\b/];function bn(t){if(!t)return!1;for(let e of ge(t).split(`
13
- `))if(!/^\s*[✓✔√]\s/.test(e)&&Ii.some(n=>n.test(e)))return!0;return!1}var Oi=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),Di=/^[A-Za-z_][A-Za-z0-9_]*=/,ut=/^([a-z]+)-tool(?::\s|$)/;function Pe(t){let e=t.trim(),n=e.split(/\s+/),r=0;for(;r<n.length;){let a=n[r];if(Di.test(a)){r++;continue}if(Oi.has(a)){for(r++,a==="timeout"&&r<n.length&&/^\d+(?:\.\d+)?[smhd]?$/.test(n[r])&&r++;(a==="stdbuf"||a==="nice")&&r<n.length&&n[r].startsWith("-");)r++;continue}break}if(r>=n.length)return e;let s=n[r],i=s.includes("/")?s.slice(s.lastIndexOf("/")+1):s,o=n.slice(r+1);return o.length?`${i} ${o.join(" ")}`:i}var Ni=new Set(["cd","export","source","set","unset","mkdir","true",":","pushd","popd","alias","ulimit","umask","echo","printf","sleep","touch","rm","cp","mv","chmod","ln"]);function vn(t,e){let n=!1,r=!1,s=0,i=[];for(let o=0;o<t.length;o++){let a=t[o];if(a==="\\"&&!n){o++;continue}a==="'"&&!r?n=!n:a==='"'&&!n?r=!r:!n&&!r&&(a===";"?(i.push(t.slice(s,o)),s=o+1):a==="|"&&t[o+1]==="|"?(i.push(t.slice(s,o)),o++,s=o+1):a==="|"?e||(i.push(t.slice(s,o)),s=o+1):a==="&"&&t[o+1]==="&"&&(i.push(t.slice(s,o)),o++,s=o+1))}return i.push(t.slice(s)),i}function $i(t){let e=vn(t,!1);for(let n=e.length-1;n>=0;n--){let r=e[n].trim();if(r)return r}return t.trim()}function dt(t){let e=vn(t,!0).map(n=>n.trim()).filter(Boolean);if(e.length===0)return null;for(let n of e.slice(0,-1)){let r=Pe(n).split(/\s+/)[0]??"";if(!Ni.has(r))return null}return $i(e[e.length-1])}function xn(t){let e=!1,n=!1,r=0,s=[];for(let i=0;i<t.length;i++){let o=t[i];if(o==="\\"&&!e){i++;continue}o==="'"&&!n?e=!e:o==='"'&&!e?n=!n:!e&&!n&&(o==="|"||o===";"?(s.push(t.slice(r,i)),o==="|"&&t[i+1]==="|"&&i++,r=i+1):o==="&"&&t[i+1]==="&"&&(s.push(t.slice(r,i)),i++,r=i+1))}s.push(t.slice(r));for(let i=s.length-1;i>=0;i--){let o=s[i].trim();if(o)return o}return t.trim()}function kn(t){let e=ut.exec(t),n=t;if(e){if(e[1]!=="bash")return[t];let i=t.indexOf(": ");if(i<0)return[t];n=t.slice(i+2)}let r=dt(n),s=r?Pe(r):null;return s&&s!==t?[s,t]:[t]}var En=`
7
+ `);if(s.stripRegexes.length&&(a=e.keep_failures?a.filter(d=>ee.test(d)||!s.stripRegexes.some(c=>c.test(d))):rn(a,s.stripRegexes)),r!=="normal"&&!e.preserve_exact&&(a=un(a),a=dn(a)),r==="minimal"&&!e.preserve_exact&&(a=ln(a),(e.slug==="vitest"||e.slug==="npm-test")&&(a=Oi(a))),!e.preserve_exact&&(n.smartCode||n.smartCode===void 0&&r!=="normal"&&Qe(i))&&(a=Xe(a)),e.transform){let d=pn(e.transform);d&&(a=d(a))}let l=e.slug==="read-tool";if(!l){let d=lt(a);d.some(Boolean)&&(a=a.filter((c,g)=>!d[g]))}e.mask_abs_paths&&(a=cn(a)),e.fold_passing&&(a=an(a,e.fold_passing_threshold??5)),e.truncate_lines_at&&(a=sn(a,e.truncate_lines_at));let u=null;if(e.max_lines){let d=e.scale_with_level?Ci(n.verbosity):1,c=Math.min(e.max_lines,Math.max(Ii,Math.round(e.max_lines*d))),g=l?lt(a):null,_=g?g.filter(k=>!k).length:a.length;if(_>c){let k=c;if(g){let A=0;for(k=0;k<a.length&&A<c;)g[k]||(A+=1),k+=1}let R=_-c;if(e.keep_failures){let A=a.slice(k),j=A.filter(G=>!ee.test(G)),Ze=A.reduce((G,Ue,I)=>G+(!ee.test(Ue)&&!g?.[k+I]?1:0),0);u=j.length>0?j.join(`
8
+ `):null,a=[...a.slice(0,k),...Ze>0?[Je(Ze)]:[],...A.filter(G=>ee.test(G))]}else if(l)u=a.slice(k).join(`
9
+ `),a=[...a.slice(0,k),Je(R)];else{let{kept:A,dropped:j}=on(a,c);u=j.length>0?j.join(`
10
+ `):null,a=A}}}let f=a.join(`
11
+ `);return o&&f.length>0&&(f+=`
12
+ `),f.trim().length===0&&e.on_empty&&(f=e.on_empty),{text:f,droppedTail:u}}var Ni=[/\bERROR\b/,/\bFAIL\b/,/\bFAILED\b/,/\bFATAL\b/,/^Traceback /m,/^Error: /m,/^\s+at .*\(.*:\d+:\d+\)/m,/panic:/,/SyntaxError:/,/TypeError:/,/ReferenceError:/,/AssertionError:/,/^\s*(?:error|fatal):/i,/thread '.*' panicked/,/\b[1-9]\d* (?:failed|errors?)\b/];function xn(t){if(!t)return!1;for(let e of ye(t).split(`
13
+ `))if(!/^\s*[✓✔√]\s/.test(e)&&Ni.some(n=>n.test(e)))return!0;return!1}var $i=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),Pi=/^[A-Za-z_][A-Za-z0-9_]*=/,pt=/^([a-z]+)-tool(?::\s|$)/;function Re(t){let e=t.trim(),n=e.split(/\s+/),r=0;for(;r<n.length;){let a=n[r];if(Pi.test(a)){r++;continue}if($i.has(a)){for(r++,a==="timeout"&&r<n.length&&/^\d+(?:\.\d+)?[smhd]?$/.test(n[r])&&r++;(a==="stdbuf"||a==="nice")&&r<n.length&&n[r].startsWith("-");)r++;continue}break}if(r>=n.length)return e;let s=n[r],i=s.includes("/")?s.slice(s.lastIndexOf("/")+1):s,o=n.slice(r+1);return o.length?`${i} ${o.join(" ")}`:i}var Mi=new Set(["cd","export","source","set","unset","mkdir","true",":","pushd","popd","alias","ulimit","umask","echo","printf","sleep","touch","rm","cp","mv","chmod","ln"]);function kn(t,e){let n=!1,r=!1,s=0,i=[];for(let o=0;o<t.length;o++){let a=t[o];if(a==="\\"&&!n){o++;continue}a==="'"&&!r?n=!n:a==='"'&&!n?r=!r:!n&&!r&&(a===";"?(i.push(t.slice(s,o)),s=o+1):a==="|"&&t[o+1]==="|"?(i.push(t.slice(s,o)),o++,s=o+1):a==="|"?e||(i.push(t.slice(s,o)),s=o+1):a==="&"&&t[o+1]==="&"&&(i.push(t.slice(s,o)),o++,s=o+1))}return i.push(t.slice(s)),i}function Li(t){let e=kn(t,!1);for(let n=e.length-1;n>=0;n--){let r=e[n].trim();if(r)return r}return t.trim()}function mt(t){let e=kn(t,!0).map(n=>n.trim()).filter(Boolean);if(e.length===0)return null;for(let n of e.slice(0,-1)){let r=Re(n).split(/\s+/)[0]??"";if(!Mi.has(r))return null}return Li(e[e.length-1])}function En(t){let e=!1,n=!1,r=0,s=[];for(let i=0;i<t.length;i++){let o=t[i];if(o==="\\"&&!e){i++;continue}o==="'"&&!n?e=!e:o==='"'&&!e?n=!n:!e&&!n&&(o==="|"||o===";"?(s.push(t.slice(r,i)),o==="|"&&t[i+1]==="|"&&i++,r=i+1):o==="&"&&t[i+1]==="&"&&(s.push(t.slice(r,i)),i++,r=i+1))}s.push(t.slice(r));for(let i=s.length-1;i>=0;i--){let o=s[i].trim();if(o)return o}return t.trim()}function wn(t){let e=pt.exec(t),n=t;if(e){if(e[1]!=="bash")return[t];let i=t.indexOf(": ");if(i<0)return[t];n=t.slice(i+2)}let r=mt(n),s=r?Re(r):null;return s&&s!==t?[s,t]:[t]}var Sn=`
14
14
  [YOLO: omitted]
15
- `;function ft(t){let e=Buffer.from(t,"utf8");if(e.length<=256)return t;let n=256-Buffer.byteLength(En,"utf8"),r=Math.floor(n/2);for(;(e[r]&192)===128;)r-=1;let s=e.length-(n-r);for(;(e[s]&192)===128;)s+=1;return e.subarray(0,r).toString("utf8")+En+e.subarray(s).toString("utf8")}var Pi=/^ID {2,}TITLE {2,}BRANCH {2,}STATE {2,}CREATED *$/,Mi=/^… \([1-9]\d* more lines omitted\)$/,Li=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/;function Fi(t,e){if(!e)return t.split(`
15
+ `;function ht(t){let e=Buffer.from(t,"utf8");if(e.length<=256)return t;let n=256-Buffer.byteLength(Sn,"utf8"),r=Math.floor(n/2);for(;(e[r]&192)===128;)r-=1;let s=e.length-(n-r);for(;(e[s]&192)===128;)s+=1;return e.subarray(0,r).toString("utf8")+Sn+e.subarray(s).toString("utf8")}var Fi=/^ID {2,}TITLE {2,}BRANCH {2,}STATE {2,}CREATED *$/,Bi=/^… \([1-9]\d* more lines omitted\)$/,ji=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/;function zi(t,e){if(!e)return t.split(`
16
16
  `).map(i=>i.replace(/^[ \t]+|[ \t]+(?=\r?$)/g,"")).join(`
17
17
  `);let n="",r=!1,s=!1;for(let i of t)r?(n+=i,s?s=!1:i==="\\"?s=!0:i==='"'&&(r=!1)):i==='"'?(r=!0,n+=i):i!==" "&&i!==" "&&i!=="\r"&&i!==`
18
18
  `&&(n+=i);return n+(t.endsWith(`
19
19
  `)?`
20
- `:"")}function ji(t,e){if(/@\d|\r/.test(t))return t;let n=t.endsWith(`
20
+ `:"")}function Zi(t,e){if(/@\d|\r/.test(t))return t;let n=t.endsWith(`
21
21
  `)?`
22
22
  `:"",r=(n?t.slice(0,-1):t).split(`
23
- `),s=r.findIndex(c=>Pi.test(c));if(s>=0&&r.slice(0,s).some(c=>c!==""&&!/^Showing \d+ of \d+ (?:open|closed|all) pull requests in \S+$/.test(c)))return t;let i=s>=0?[...r[s].matchAll(/\S+/g)].map(c=>c.index):[],o=[];for(let c=s+1;c<r.length;c+=1){let g=r[c];if(Mi.test(g))continue;if(/…|\.\.\./.test(g))return t;let _;if(s>=0){if(/[^\x20-\x7e]/.test(g))return t;let k=i.map((A,R)=>g.slice(A,i[R+1]));if(k.slice(0,-1).some(A=>A[0]===" "||!A.endsWith(" "))||(_=k.map(A=>A.replace(/ +$/,"")),!/^#\d+$/.test(_[0])||!/^\S+$/.test(_[2])||!/^(OPEN|CLOSED|MERGED|DRAFT)$/.test(_[3])||!/^\d+(?:s|m|h|d|w|mo|y)$/.test(_[4])))return t}else if(_=g.split(" "),_.length!==5||!/^\d+$/.test(_[0])||!_[1]||!_[2]||!/^(OPEN|CLOSED|MERGED|DRAFT)$/.test(_[3])||!Li.test(_[4])||!Number.isFinite(Date.parse(_[4])))return t;if(_.some(k=>/[\u0000-\u001f\u007f]/.test(k)))return t;o.push({index:c,cells:_})}if(o.length===0)return t;s>=0&&(r[s]="ID TITLE BRANCH STATE CREATED");for(let c of o)r[c.index]=c.cells.join(" ");let a=r.join(`
24
- `)+n;if(!e)return a;let l=new Map;for(let{cells:c}of o)l.set(c[1],(l.get(c[1])??0)+1);let u=new Map,d=[];for(let[c,g]of l){if(c.length<40||g<3||c.trim().split(/\s+/).length<8)continue;let _=`@${u.size+1}`,k=JSON.stringify(c).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),A=`TITLE ${_} = ${k}`;g*(Buffer.byteLength(c)-Buffer.byteLength(_))<=Buffer.byteLength(A)+1||(u.set(c,_),d.push(A))}if(d.length===0)return a;for(let{index:c,cells:g}of o)r[c]=g.map((_,k)=>k===1?u.get(_)??_:_).join(" ");let f=[...r,"",...d].join(`
25
- `)+n;return Buffer.byteLength(f)<Buffer.byteLength(a)?f:a}function pt(t,e,n){if(e!=="compact"&&e!=="minimal")return t;let r=t;if(/^[ \t\r\n]*[\[{]/.test(t)){try{JSON.parse(t)}catch{return t}r=Fi(t,e==="minimal")}else n==="gh"&&(r=ji(t,e==="minimal"));return Buffer.byteLength(r)<Buffer.byteLength(t)?r:t}var wn=null;function mt(t){wn=t}async function Bi(t,e){let n=await Yt();return qe(t,n.values(),e)}var zi=/^(?:grep|rg|find|eslint|ruff|flake8|mypy|prettier|biome|black|stylelint)(?:\s|$)|^git\s+(?:diff|grep)\b/,Zi=2048;async function ht(t,e,n,r={}){let s=Buffer.byteLength(e,"utf8"),{exitCode:i,yolo:o=!1,...a}=r,l=Pe(xn(t.startsWith("bash-tool: ")?t.slice(11):t)),u=i!=null&&i!==0&&!(i===1&&zi.test(l)),d=wn??Bi,f=null;for(let C of kn(t))if(f=await d(C,n),f)break;!f&&s>=Zi&&!ut.test(t)&&(f=await d(`bash-tool: ${t}`,n));let c=dt(t.startsWith("bash-tool: ")?t.slice(11):t),g=f?.slug==="git-log"&&c!=null&&/^git\s+log(?:\s|$)/.test(Pe(c)),_=i==null&&(g?/^(?:fatal|error):/im.test(ge(e)):bn(e));if(!f||(u||_)&&f.preserve_exact&&!o)return{output:e,filterId:null,rawBytes:s,filteredBytes:s,debugBypass:u||_,...o?{droppedTail:null}:{}};let k=C=>{if(!o)return C;let Ce=C.filteredBytes>s||s>0&&C.output.length===0?e:C.output,Ie=!C.debugBypass&&!f?.preserve_exact?pt(Ce,"minimal",C.filterId??""):Ce,$t=ft(Ie)===Ie?Ie:ft(Ce);return{...C,output:$t,filteredBytes:Buffer.byteLength($t,"utf8"),droppedTail:null}};if(u||_){let C=o?_n(e,{...f,keep_failures:!0,transform:void 0,max_lines:void 0,truncate_lines_at:void 0,on_empty:void 0},{verbosity:"minimal",smartCode:!1}):f.strip_ansi&&!f.preserve_exact?ge(e):e;return k({output:C,filterId:f.slug,rawBytes:s,filteredBytes:Buffer.byteLength(C,"utf8"),debugBypass:!0})}let{text:A,droppedTail:R}=lt(e,f,o?{...a,verbosity:"minimal"}:a),B=!o&&!f.preserve_exact?pt(A,a.verbosity,f.slug):A,Re=Buffer.byteLength(B,"utf8");return e.trim().length>0&&Re>=s?k({output:e,filterId:f.slug,rawBytes:s,filteredBytes:s,debugBypass:!1,droppedTail:null}):k({output:B,filterId:f.slug,rawBytes:s,filteredBytes:Re,debugBypass:!1,droppedTail:R})}async function Sn(){let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf8")}import{existsSync as no}from"node:fs";import{fileURLToPath as ro}from"node:url";import{dirname as so,join as io}from"node:path";import{appendFileSync as Gi,chmodSync as Yi,mkdirSync as qi,existsSync as Ji,readFileSync as ou,rmSync as au}from"node:fs";import{dirname as Xi,join as Qi}from"node:path";import Ui from"node:os";import{join as Tn}from"node:path";function T(){return process.env.TOKMIZER_HOME||Tn(Ui.homedir(),".tokmizer")}function Me(){return Tn(T(),"install-id")}import{readFileSync as Hi,renameSync as Vi,statSync as Ki,writeFileSync as Wi}from"node:fs";function Qe(t,e,n){try{if(Ki(t).size<=e)return;let r=Hi(t,"utf8").split(`
26
- `).filter(a=>a.trim()!==""),s=[],i=0;for(let a=r.length-1;a>=0;a-=1){let l=r[a],u=Buffer.byteLength(l)+1;if(i+u>n)break;s.push(l),i+=u}s.reverse();let o=`${t}.tmp-${process.pid}`;Wi(o,s.length?`${s.join(`
23
+ `),s=r.findIndex(c=>Fi.test(c));if(s>=0&&r.slice(0,s).some(c=>c!==""&&!/^Showing \d+ of \d+ (?:open|closed|all) pull requests in \S+$/.test(c)))return t;let i=s>=0?[...r[s].matchAll(/\S+/g)].map(c=>c.index):[],o=[];for(let c=s+1;c<r.length;c+=1){let g=r[c];if(Bi.test(g))continue;if(/…|\.\.\./.test(g))return t;let _;if(s>=0){if(/[^\x20-\x7e]/.test(g))return t;let k=i.map((R,A)=>g.slice(R,i[A+1]));if(k.slice(0,-1).some(R=>R[0]===" "||!R.endsWith(" "))||(_=k.map(R=>R.replace(/ +$/,"")),!/^#\d+$/.test(_[0])||!/^\S+$/.test(_[2])||!/^(OPEN|CLOSED|MERGED|DRAFT)$/.test(_[3])||!/^\d+(?:s|m|h|d|w|mo|y)$/.test(_[4])))return t}else if(_=g.split(" "),_.length!==5||!/^\d+$/.test(_[0])||!_[1]||!_[2]||!/^(OPEN|CLOSED|MERGED|DRAFT)$/.test(_[3])||!ji.test(_[4])||!Number.isFinite(Date.parse(_[4])))return t;if(_.some(k=>/[\u0000-\u001f\u007f]/.test(k)))return t;o.push({index:c,cells:_})}if(o.length===0)return t;s>=0&&(r[s]="ID TITLE BRANCH STATE CREATED");for(let c of o)r[c.index]=c.cells.join(" ");let a=r.join(`
24
+ `)+n;if(!e)return a;let l=new Map;for(let{cells:c}of o)l.set(c[1],(l.get(c[1])??0)+1);let u=new Map,f=[];for(let[c,g]of l){if(c.length<40||g<3||c.trim().split(/\s+/).length<8)continue;let _=`@${u.size+1}`,k=JSON.stringify(c).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),R=`TITLE ${_} = ${k}`;g*(Buffer.byteLength(c)-Buffer.byteLength(_))<=Buffer.byteLength(R)+1||(u.set(c,_),f.push(R))}if(f.length===0)return a;for(let{index:c,cells:g}of o)r[c]=g.map((_,k)=>k===1?u.get(_)??_:_).join(" ");let d=[...r,"",...f].join(`
25
+ `)+n;return Buffer.byteLength(d)<Buffer.byteLength(a)?d:a}function gt(t,e,n){if(e!=="compact"&&e!=="minimal")return t;let r=t;if(/^[ \t\r\n]*[\[{]/.test(t)){try{JSON.parse(t)}catch{return t}r=zi(t,e==="minimal")}else n==="gh"&&(r=Zi(t,e==="minimal"));return Buffer.byteLength(r)<Buffer.byteLength(t)?r:t}var Ui=/^(?:\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?Z?\s+)?(?:\[(?:DEBUG|TRACE|INFO|WARN|WARNING|ERROR|FATAL)\]|DEBUG|TRACE|INFO|WARN|WARNING|ERROR|FATAL)(?::|\s|$)/,Hi=/^\[tkr: previous log line repeated \d+ additional times\]$/m;function Tn(t){if(Buffer.byteLength(t)<2048||Qe(t)||Hi.test(t))return t;let e=t.split(`
26
+ `),n=[];for(let r=0;r<e.length;){let s=e[r],i=r+1;if(Ui.test(s))for(;i<e.length&&e[i]===s;)i+=1;let o=i-r,a=`[tkr: previous log line repeated ${o-1} additional times]`;if(o>=3&&Buffer.byteLength(a)+1<(o-1)*(Buffer.byteLength(s)+1))n.push(s,a);else for(let l=r;l<i;l+=1)n.push(s);r=i}return n.join(`
27
+ `)}var An=null;function yt(t){An=t}async function Vi(t,e){let n=await Xt();return qe(t,n.values(),e)}var Ki=/^(?:grep|rg|find|eslint|ruff|flake8|mypy|prettier|biome|black|stylelint)(?:\s|$)|^git\s+(?:diff|grep)\b/,Wi=2048;async function _t(t,e,n,r={}){let s=Buffer.byteLength(e,"utf8"),{exitCode:i,yolo:o=!1,...a}=r,l=Re(En(t.startsWith("bash-tool: ")?t.slice(11):t)),u=i!=null&&i!==0&&!(i===1&&Ki.test(l)),f=An??Vi,d=null;for(let I of wn(t))if(d=await f(I,n),d)break;!d&&s>=Wi&&!pt.test(t)&&(d=await f(`bash-tool: ${t}`,n));let c=mt(t.startsWith("bash-tool: ")?t.slice(11):t),g=d?.slug==="git-log"&&c!=null&&/^git\s+log(?:\s|$)/.test(Re(c)),_=i==null&&(g?/^(?:fatal|error):/im.test(ye(e)):xn(e)),k=d?.transform==="smart-read"&&s<=16384&&(e.endsWith(`
28
+ `)?e.slice(0,-1):e).split(`
29
+ `).length<=200,R=s<=16384&&c!=null&&/^(?:head|tail)(?:\s|$)|^sed\s+(?:(?:-[Eru]+|--(?:regexp-extended|unbuffered|sandbox))\s+)*(?:-[Enruse]*n[Enruse]*(?:\s|$)|--(?:quiet|silent)(?:\s|$))/.test(Re(c));if(!o&&(R||k&&a.smartCode!==!0))return{output:e,filterId:d?.slug??null,rawBytes:s,filteredBytes:s,debugBypass:u||_,droppedTail:null};if(!d||(u||_)&&d.preserve_exact&&!o)return{output:e,filterId:null,rawBytes:s,filteredBytes:s,debugBypass:u||_,...o?{droppedTail:null}:{}};let A=I=>{if(!o)return I;let st=I.filteredBytes>s||s>0&&I.output.length===0?e:I.output,it=!I.debugBypass&&!d?.preserve_exact?gt(st,"minimal",I.filterId??""):st,Lt=ht(it)===it?it:ht(st);return{...I,output:Lt,filteredBytes:Buffer.byteLength(Lt,"utf8"),droppedTail:null}};if(u||_){let I=o?vn(e,{...d,keep_failures:!0,transform:void 0,max_lines:void 0,truncate_lines_at:void 0,on_empty:void 0},{verbosity:"minimal",smartCode:!1}):d.strip_ansi&&!d.preserve_exact?ye(e):e;return!o&&a.verbosity==="minimal"&&d.transform!=="smart-read"&&(I=Tn(I)),A({output:I,filterId:d.slug,rawBytes:s,filteredBytes:Buffer.byteLength(I,"utf8"),debugBypass:!0})}let{text:j,droppedTail:Ze}=ft(e,d,o?{...a,verbosity:"minimal"}:a),G=!o&&!d.preserve_exact?gt(j,a.verbosity,d.slug):j,Ue=Buffer.byteLength(G,"utf8");return e.trim().length>0&&Ue>=s?A({output:e,filterId:d.slug,rawBytes:s,filteredBytes:s,debugBypass:!1,droppedTail:null}):A({output:G,filterId:d.slug,rawBytes:s,filteredBytes:Ue,debugBypass:!1,droppedTail:Ze})}async function Rn(){let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf8")}import{existsSync as ao}from"node:fs";import{fileURLToPath as co}from"node:url";import{dirname as lo,join as uo}from"node:path";import{appendFileSync as Qi,chmodSync as eo,mkdirSync as to,existsSync as no,readFileSync as mu,rmSync as hu}from"node:fs";import{dirname as ro,join as so}from"node:path";import Gi from"node:os";import{join as Cn}from"node:path";function T(){return process.env.TOKMIZER_HOME||Cn(Gi.homedir(),".tokmizer")}function $e(){return Cn(T(),"install-id")}import{readFileSync as Yi,renameSync as qi,statSync as Ji,writeFileSync as Xi}from"node:fs";function et(t,e,n){try{if(Ji(t).size<=e)return;let r=Yi(t,"utf8").split(`
30
+ `).filter(a=>a.trim()!==""),s=[],i=0;for(let a=r.length-1;a>=0;a-=1){let l=r[a],u=Buffer.byteLength(l)+1;if(i+u>n)break;s.push(l),i+=u}s.reverse();let o=`${t}.tmp-${process.pid}`;Xi(o,s.length?`${s.join(`
27
31
  `)}
28
- `:"",{mode:384}),Vi(o,t)}catch{}}var eo="usage.jsonl";var An=2*1024*1024;function to(){return Qi(T(),eo)}function Rn(t,e,n=to()){try{let r=Xi(n);Ji(r)||qi(r,{recursive:!0,mode:448});let s=t.replace(/[^A-Za-z0-9._-]/g,"").slice(0,64)||"unknown";Gi(n,`{"t":${Math.floor(Date.now()/1e3)},"s":"${s}","o":${e?1:0}}
29
- `,{mode:384}),Yi(n,384),Qe(n,An,An/2)}catch{}}var oo=new Set(["tkr","tkr-exec","token","claude","cd","export","source","echo","mkdir","rm","mv","cp","chmod","ln","true","false",":","test","[","exit","return","nohup","sudo","doas","env"]),ao=new Set(["for","while","until","if","then","else","elif","fi","do","done","case","esac","select","function","time","coproc","in","!","[[","]]","{","}",".","declare","typeset","local","readonly","unset","set","shift","trap","wait","read","eval","exec","break","continue","pushd","popd","dirs","alias","unalias","hash","ulimit","umask","getopts","let","shopt","builtin","command","compgen","complete","disown","suspend","jobs","fg","bg","kill","history","fc","bind","enable","caller","type"]),Cn=new Set(["sh","bash","zsh","dash","ksh","fish","python","python3","python2","node","ruby","perl","php","awk","sed","deno","bun"]),In=/(?:^|\s)(?:--follow|-[0-9a-zA-Z]*f[a-zA-Z]*)(?:\s|=|$)/,co=new Set(["docker","podman","kubectl","nerdctl","docker-compose","stern","flyctl"]);function lo(t,e){let n=gt(e);return n==="tail"||n==="journalctl"?In.test(t):n==="stern"?!0:co.has(n)?/\blogs?\b/.test(t)&&In.test(t):!1}var On=/^[A-Za-z_][A-Za-z0-9_]*\+?=/,uo=/^[A-Za-z_][A-Za-z0-9_-]*\s*\(\s*\)/,fo=/(?:^|[;&|\n({])\s*[A-Za-z_][A-Za-z0-9_-]*\s*\(\s*\)/;function gt(t){let e=t.lastIndexOf("/");return e===-1?t:t.slice(e+1)}function po(t){let e=!1,n=!1,r=!1,s=!1;for(let i=0;i<t.length;i++){let o=t[i];if(s){s=!1;continue}if(o==="\\"&&!e){s=!0;continue}if(!n&&!r&&o==="'"){e=!e;continue}if(!e&&!r&&o==='"'){n=!n;continue}if(!e&&!n&&o==="`"){r=!r;continue}if(!e&&!n&&!r&&o===">")return!0}return!1}function Dn(t){let e=[],n="",r=0,s=!1,i=!1,o=!1,a=!1,l=0,u=0,d=()=>{n.length>0&&(e.push({kind:"cmd",text:n}),n="")},f=c=>{d(),e.push({kind:"sep",text:c})};for(;r<t.length;){let c=t[r];if(a){n+=c,a=!1,r+=1;continue}if(c==="\\"&&!s){n+=c,a=!0,r+=1;continue}if(!i&&!o&&c==="'"){s=!s,n+=c,r+=1;continue}if(!s&&!o&&c==='"'){i=!i,n+=c,r+=1;continue}if(!s&&!i&&c==="`"){o=!o,n+=c,r+=1;continue}if(!(s||i||o)){if(c==="$"&&t[r+1]==="{"){n+="${",u+=1,r+=2;continue}if(u>0){c==="{"?u+=1:c==="}"&&(u-=1),n+=c,r+=1;continue}if(c==="$"&&t[r+1]==="("){n+="$(",l+=1,r+=2;continue}if(c==="("){n+="(",l+=1,r+=1;continue}if(l>0){c==="("?l+=1:c===")"&&(l-=1),n+=c,r+=1;continue}if(c===">"&&t[r+1]==="|"){n+=">|",r+=2;continue}if(c==="&"&&t[r+1]==="&"){f("&&"),r+=2;continue}if(c==="&"&&t[r+1]!==">"){let _=n.replace(/\s+$/,""),k=_[_.length-1];if(k!==">"&&k!=="<"&&k!=="&"){f("&"),r+=1;continue}}if(c==="|"&&t[r+1]==="|"){f("||"),r+=2;continue}if(c==="|"&&t[r+1]==="&"){f("|&"),r+=2;continue}if(c===";"&&t[r+1]===";"){let _=t[r+2]==="&";f(_?";;&":";;"),r+=_?3:2;continue}if(c===";"){f(";"),r+=1;continue}if(c===`
30
- `){f(`
31
- `),r+=1;continue}if(c==="|"){f("|"),r+=1;continue}}n+=c,r+=1}return s||i||o||l!==0||u!==0||a?[{kind:"cmd",text:t,unsafe:!0}]:(d(),e)}function mo(t){return t.trim().split(/\s+/)[0]??""}function ho(){try{let t=so(ro(import.meta.url)),e=io(t,"..","bin","tkr-exec.js");return no(e)?`node '${e.replace(/'/g,"'\\''")}'`:null}catch{return null}}function go(t,e="tkr-exec"){if(t.includes("<<")||fo.test(t))return t;let n=Dn(t),r=[];for(let s=0;s<n.length;s++){let i=n[s];if(i.kind==="sep"||i.unsafe){r.push(i.text);continue}let o=i.text.trim();if(!o){r.push(i.text);continue}let a=mo(o),l=n[s+1],u=l?.kind==="sep"&&(l.text==="|"||l.text==="|&"),d=l?.kind==="sep"&&l.text==="&";if(oo.has(a)||ao.has(a)||Cn.has(a)||Cn.has(gt(a))||On.test(a)||a.startsWith("(")||a.startsWith("#")||a.startsWith("<")||a.startsWith(">")||uo.test(o)||lo(o,a)||a.endsWith(")")||u||d||po(i.text)||i.text.includes("<(")||i.text.includes(">(")||a==="node"&&o.includes("tkr-exec.js")){r.push(i.text);continue}let f=i.text.match(/^\s*/)?.[0]??"",c=i.text.match(/\s*$/)?.[0]??"";r.push(`${f}${e} ${o}${c}`)}return r.join("")}var yo=new Set(["command","workdir","timeout_ms","yield_time_ms","max_output_tokens","shell","login","tty","description"]),_o=new Set(["cd","cat","head","tail","ls","tree","find","grep","rg","wc","nl","sort","cut","diff","stat","file","du","df","ps","jq","yq","pwd","which"]),bo=new Set(["log","diff","show","status","blame","ls-files","rev-parse","describe","shortlog"]),vo={find:/^-(?:delete|exec|execdir|ok|okdir|fprint|fls)/,sort:/^(?:-[^-]*o|--output|--compress-program)/,rg:/^(?:--pre|-[^-]*z|--search-zip)/,yq:/^(?:-[^-]*[is]|--inplace|--split-exp)/,file:/^(?:-C|--compile)/,tree:/^(?:-o|--output|-R$|-H$)/,git:/^(?:--output|--ext-diff|--textconv|-c$|--exec-path|--git-dir|--work-tree)/};function xo(t){if(/\$|`|<\(|>\(|\\\r?\n/.test(t)||/>/.test(t.replace(/2>&1|[12]?>\s*\/dev\/null/g,"")))return!1;for(let e of Dn(t)){if(e.kind==="sep")continue;if(e.unsafe)return!1;let n=e.text.trim().split(/\s+/).filter(Boolean).map(i=>i.replace(/['"\\]/g,""));if(n.length===0)continue;if(n.some(i=>On.test(i)))return!1;let r=gt(n[0]);if(r!==n[0])return!1;let s=vo[r];if(s&&n.slice(1).some(i=>s.test(i)))return!1;if(!(r==="git"?bo.has(n[1]??""):_o.has(r)))return!1}return!0}function Nn(t,e,n=ho()){if(t.tool_name!=="Bash")return null;let r=t.tool_input??{};if(r.run_in_background)return null;let s=r.command;if(typeof s!="string"||!s||e==="codex"&&Object.keys(r).some(o=>!yo.has(o))||e==="codex"&&!xo(s)||!n)return null;let i=go(s,n);return Rn(t.session_id??"unknown",i!==s),i===s?null:JSON.stringify({hookSpecificOutput:e==="codex"?{hookEventName:"PreToolUse",permissionDecision:"allow",updatedInput:{...r,command:i}}:{hookEventName:"PreToolUse",updatedInput:{command:i}}})}import{join as ko}from"node:path";import{mkdir as bu,readFile as Eo,writeFile as vu,unlink as xu,rename as ku}from"node:fs/promises";var wo="state.json";function So(){try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t&&t.length>0?t:"Etc/UTC"}catch{return"Etc/UTC"}}function To(t){return t?.dir??T()}async function Le(t){let e=To(t);try{let n=await Eo(ko(e,wo),"utf8"),r=JSON.parse(n);return{...r,lastSettingsRevision:r.lastSettingsRevision??0,timeZone:r.timeZone??So(),bonusActive:r.bonusActive??!1,...r.bonusResetAt!==void 0?{bonusResetAt:r.bonusResetAt}:{}}}catch{return null}}function Ao(){let t=Number(process.env.TOKMIZER_OFFLINE_GRACE_MS);return Number.isFinite(t)&&t>0?t:6048e5}function $n(t,e=Date.now()){let n=t.lastHeartbeatOkAt;if(typeof n=="number"&&e-n>Ao())return!0;if(t.subEndsAt){let r=Date.parse(t.subEndsAt);if(Number.isFinite(r)&&e>r)return!0}return!1}function Pn(t,e=Date.now()){return t.plan}import{readFile as Ro,writeFile as Au,mkdir as Ru,chmod as Cu,rm as Iu,rename as Ou,readdir as Du}from"node:fs/promises";import{join as Co}from"node:path";var Io="settings-cache.json",Mn=$e.parse({}),Mu=$e.partial().extend({filters:$e.shape.filters.removeDefault().partial().optional()});async function Fe(){try{let t=await Ro(Co(T(),Io),"utf8"),e=JSON.parse(t);return $e.parse({...Mn,...e})}catch{return Mn}}var Oo=[[/(authorization\s*:\s*)([A-Za-z][A-Za-z0-9._-]*)\s+[^\s'"]+/gi,"$1$2 [REDACTED]"],[/(authorization\s*:\s*)[A-Za-z0-9._\-+/=]{8,}/gi,"$1[REDACTED]"],[/(bearer\s+)[A-Za-z0-9._\-+/=]{8,}/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-b|--cookie)[=\s]+['"]?)[^\s'";=]+=[^\s'";]+(?:\s*;\s*[^\s'";=]+=[^\s'";]+)*/gi,"$1[REDACTED]"],[/((?:^|[\s'"])(?:Set-)?Cookie\s*:\s*)[^\s'";=]+=[^\s'";]+(?:\s*;\s*[^\s'";=]+=[^\s'";]+)*/gi,"$1[REDACTED]"],[/(--?(?:password|passwd|passphrase|apipass|pass|pwd|token|api[-_]?key|secret|bearer|cookie|jwt)(?:-[a-z0-9]+)*[=\s]+)\S+/gi,"$1[REDACTED]"],[/((?:^|\s)-b[=\s]?['"]?)[^\s'"=]+=[^\s'"]+/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?[^\s:/'"]*:)(\/[^/\s'"][^\s'"]*|[^\s/'"0-9][^\s'"]*|[0-9][^\s'"]*[^\s'"0-9][^\s'"]*)/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?[^\s:/'"]*[^\s:/'"0-9][^\s:/'"]*:)(?:\/[^/\s'"]|[^\s/'"])[^\s'"]*/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?:)(?:\/[^/\s'"]|[^\s/'"])[^\s'"]*/gi,"$1[REDACTED]"],[/((?:[A-Za-z0-9]+-){0,8}(?:X-Api-Key|Private-Token|[A-Za-z0-9]+-(?:Token|Key|Auth|Secret))\s*:\s*)[^\s'"]+/gi,"$1[REDACTED]"],[/((?:^|[\s'"])(?:Set-)?Cookie\s*:\s*)[^\s'"]+/gi,"$1[REDACTED]"],[/(-i\s+)(\/[^\s]+|~\/[^\s]+|[A-Z]:\\[^\s]+)/g,"$1[REDACTED]"],[/([a-zA-Z][a-zA-Z0-9+.-]{0,31}:\/\/[^:/\s@]*:)[^\s@]+(@[^@/\s]+)/g,"$1[REDACTED]$2"],[/(AWS_(?:ACCESS_KEY_ID|SECRET_ACCESS_KEY|SESSION_TOKEN)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(GOOGLE_APPLICATION_CREDENTIALS\s*=\s*)\S+/g,"$1[REDACTED]"],[/(AZURE_(?:CLIENT_SECRET|TENANT_ID|CLIENT_ID)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-(?:proj-)?[A-Za-z0-9_-]{20,})/g,"sk-[REDACTED]"],[/\b(OPENAI_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(ANTHROPIC_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-ant-[A-Za-z0-9_-]{20,})/g,"sk-ant-[REDACTED]"],[/\b(GH(?:_|ITHUB_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(GITLAB_TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(SLACK_(?:BOT_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/(xox[bpsoa]-[A-Za-z0-9-]{10,})/g,"xox[REDACTED]"],[/(xapp-[A-Za-z0-9-]{10,})/g,"[REDACTED]"],[/(sk_(?:test|live)_[A-Za-z0-9]{16,})/g,"sk_[REDACTED]"],[/(gh[a-z])_[A-Za-z0-9]{20,}/g,"$1_[REDACTED]"],[/(github_pat)_[A-Za-z0-9_]{20,}/g,"$1_[REDACTED]"],[/(gl(?:pat|rt|soat|imt|dt|ft|agent|oas|cbt|ptt))-[A-Za-z0-9_-]{16,}/g,"$1-[REDACTED]"],[/(npm_[A-Za-z0-9_-]{20,})/g,"npm_[REDACTED]"],[/(?:AKIA|ASIA|AGPA|AIDA|AROA|ANPA)[0-9A-Z]{16,}/g,"[REDACTED_AWS_KEY]"],[/AIza[A-Za-z0-9_-]{35}/g,"[REDACTED_GOOGLE_KEY]"],[/hv[sb]\.[A-Za-z0-9_-]{20,}/g,"[REDACTED_VAULT_TOKEN]"],[/dop_v1_[A-Za-z0-9]{40,}/g,"[REDACTED]"],[/dckr_pat_[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/pypi-[A-Za-z0-9_-]{16,}/g,"[REDACTED]"],[/rk_(?:live|test)_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/whsec_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/SG\.[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/(eyJ[A-Za-z0-9_-]{6,}(?:\.[A-Za-z0-9_-]{4,}){1,2})/g,"[REDACTED_JWT]"],[/-----BEGIN [A-Z ]*PRIVATE KEY-----(?:[\s\S]*?-----END[^\n]*-----|\r?\n[A-Za-z0-9+/=][A-Za-z0-9+/=\r\n]*)?/g,"[REDACTED_PEM]"],[/\b((?:--?)?[A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|AUTH|_PWD)[A-Za-z0-9_]*['"]?\s*=\s*)(?:"[^"]*"|'[^']*'|[^"'\s]\S*)/gi,"$1[REDACTED]"],[/\b([A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|_PWD)[A-Za-z0-9_]*['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/((?:^|[\s'"{,])['"]?(?:[A-Za-z0-9_]+_)?auth['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/(\bpwd\s*[=:]\s*)(?:"[^"]*"|'[^']*'|[^/~\s][^\s;'"]*)/gi,"$1[REDACTED]"],[/([=:]\s*["']?)[A-Za-z0-9_\-+/=]{40,}/g,"$1[REDACTED]"]];function je(t){let e=t;for(let[n,r]of Oo)e=e.replace(n,r);return e}import{join as zn}from"node:path";import{appendFileSync as Fo,chmodSync as jo,existsSync as Bo,mkdirSync as zo,readFileSync as ed,renameSync as td,rmdirSync as nd,statSync as Zo,unlinkSync as rd,utimesSync as sd,writeFileSync as id}from"node:fs";import{createHash as Bu,randomUUID as Do}from"node:crypto";import{readFile as Ln,writeFile as Fn,mkdir as No}from"node:fs/promises";async function yt(){try{let n=(await Ln(Me(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(n))return n}catch{}await No(T(),{recursive:!0});let t=Do();try{return await Fn(Me(),t,{mode:384,flag:"wx"}),t}catch{try{let e=(await Ln(Me(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(e))return e}catch{}return await Fn(Me(),t,{mode:384}),t}}import{createRequire as $o}from"node:module";var Po=$o(import.meta.url);function Mo(){for(let t of["../package.json","../../package.json"])try{let e=Po(t).version;if(typeof e=="string"&&e)return e}catch{}return"0.0.0"}var _t=Mo();var jn=`-----BEGIN PUBLIC KEY-----
32
+ `:"",{mode:384}),qi(o,t)}catch{}}var io="usage.jsonl";var In=2*1024*1024;function oo(){return so(T(),io)}function On(t,e,n=oo()){try{let r=ro(n);no(r)||to(r,{recursive:!0,mode:448});let s=t.replace(/[^A-Za-z0-9._-]/g,"").slice(0,64)||"unknown";Qi(n,`{"t":${Math.floor(Date.now()/1e3)},"s":"${s}","o":${e?1:0}}
33
+ `,{mode:384}),eo(n,384),et(n,In,In/2)}catch{}}var fo=new Set(["tkr","tkr-exec","token","claude","cd","export","source","echo","mkdir","rm","mv","cp","chmod","ln","true","false",":","test","[","exit","return","nohup","sudo","doas","env"]),po=new Set(["for","while","until","if","then","else","elif","fi","do","done","case","esac","select","function","time","coproc","in","!","[[","]]","{","}",".","declare","typeset","local","readonly","unset","set","shift","trap","wait","read","eval","exec","break","continue","pushd","popd","dirs","alias","unalias","hash","ulimit","umask","getopts","let","shopt","builtin","command","compgen","complete","disown","suspend","jobs","fg","bg","kill","history","fc","bind","enable","caller","type"]),Dn=new Set(["sh","bash","zsh","dash","ksh","fish","python","python3","python2","node","ruby","perl","php","awk","sed","deno","bun"]),Nn=/(?:^|\s)(?:--follow|-[0-9a-zA-Z]*f[a-zA-Z]*)(?:\s|=|$)/,mo=new Set(["docker","podman","kubectl","nerdctl","docker-compose","stern","flyctl"]);function ho(t,e){let n=bt(e);return n==="tail"||n==="journalctl"?Nn.test(t):n==="stern"?!0:mo.has(n)?/\blogs?\b/.test(t)&&Nn.test(t):!1}var $n=/^[A-Za-z_][A-Za-z0-9_]*\+?=/,go=/^[A-Za-z_][A-Za-z0-9_-]*\s*\(\s*\)/,yo=/(?:^|[;&|\n({])\s*[A-Za-z_][A-Za-z0-9_-]*\s*\(\s*\)/;function bt(t){let e=t.lastIndexOf("/");return e===-1?t:t.slice(e+1)}function _o(t){let e=!1,n=!1,r=!1,s=!1;for(let i=0;i<t.length;i++){let o=t[i];if(s){s=!1;continue}if(o==="\\"&&!e){s=!0;continue}if(!n&&!r&&o==="'"){e=!e;continue}if(!e&&!r&&o==='"'){n=!n;continue}if(!e&&!n&&o==="`"){r=!r;continue}if(!e&&!n&&!r&&o===">")return!0}return!1}function Pn(t){let e=[],n="",r=0,s=!1,i=!1,o=!1,a=!1,l=0,u=0,f=()=>{n.length>0&&(e.push({kind:"cmd",text:n}),n="")},d=c=>{f(),e.push({kind:"sep",text:c})};for(;r<t.length;){let c=t[r];if(a){n+=c,a=!1,r+=1;continue}if(c==="\\"&&!s){n+=c,a=!0,r+=1;continue}if(!i&&!o&&c==="'"){s=!s,n+=c,r+=1;continue}if(!s&&!o&&c==='"'){i=!i,n+=c,r+=1;continue}if(!s&&!i&&c==="`"){o=!o,n+=c,r+=1;continue}if(!(s||i||o)){if(c==="$"&&t[r+1]==="{"){n+="${",u+=1,r+=2;continue}if(u>0){c==="{"?u+=1:c==="}"&&(u-=1),n+=c,r+=1;continue}if(c==="$"&&t[r+1]==="("){n+="$(",l+=1,r+=2;continue}if(c==="("){n+="(",l+=1,r+=1;continue}if(l>0){c==="("?l+=1:c===")"&&(l-=1),n+=c,r+=1;continue}if(c===">"&&t[r+1]==="|"){n+=">|",r+=2;continue}if(c==="&"&&t[r+1]==="&"){d("&&"),r+=2;continue}if(c==="&"&&t[r+1]!==">"){let _=n.replace(/\s+$/,""),k=_[_.length-1];if(k!==">"&&k!=="<"&&k!=="&"){d("&"),r+=1;continue}}if(c==="|"&&t[r+1]==="|"){d("||"),r+=2;continue}if(c==="|"&&t[r+1]==="&"){d("|&"),r+=2;continue}if(c===";"&&t[r+1]===";"){let _=t[r+2]==="&";d(_?";;&":";;"),r+=_?3:2;continue}if(c===";"){d(";"),r+=1;continue}if(c===`
34
+ `){d(`
35
+ `),r+=1;continue}if(c==="|"){d("|"),r+=1;continue}}n+=c,r+=1}return s||i||o||l!==0||u!==0||a?[{kind:"cmd",text:t,unsafe:!0}]:(f(),e)}function bo(t){return t.trim().split(/\s+/)[0]??""}function vo(){try{let t=lo(co(import.meta.url)),e=uo(t,"..","bin","tkr-exec.js");return ao(e)?`node '${e.replace(/'/g,"'\\''")}'`:null}catch{return null}}function xo(t,e="tkr-exec"){if(t.includes("<<")||yo.test(t))return t;let n=Pn(t),r=[];for(let s=0;s<n.length;s++){let i=n[s];if(i.kind==="sep"||i.unsafe){r.push(i.text);continue}let o=i.text.trim();if(!o){r.push(i.text);continue}let a=bo(o),l=n[s+1],u=l?.kind==="sep"&&(l.text==="|"||l.text==="|&"),f=l?.kind==="sep"&&l.text==="&";if(fo.has(a)||po.has(a)||Dn.has(a)||Dn.has(bt(a))||$n.test(a)||a.startsWith("(")||a.startsWith("#")||a.startsWith("<")||a.startsWith(">")||go.test(o)||ho(o,a)||a.endsWith(")")||u||f||_o(i.text)||i.text.includes("<(")||i.text.includes(">(")||a==="node"&&o.includes("tkr-exec.js")){r.push(i.text);continue}let d=i.text.match(/^\s*/)?.[0]??"",c=i.text.match(/\s*$/)?.[0]??"";r.push(`${d}${e} ${o}${c}`)}return r.join("")}var ko=new Set(["command","workdir","timeout_ms","yield_time_ms","max_output_tokens","shell","login","tty","description"]),Eo=new Set(["cd","cat","head","tail","ls","tree","find","grep","rg","wc","nl","sort","cut","diff","stat","file","du","df","ps","jq","yq","pwd","which"]),wo=new Set(["log","diff","show","status","blame","ls-files","rev-parse","describe","shortlog"]),So={find:/^-(?:delete|exec|execdir|ok|okdir|fprint|fls)/,sort:/^(?:-[^-]*o|--output|--compress-program)/,rg:/^(?:--pre|-[^-]*z|--search-zip)/,yq:/^(?:-[^-]*[is]|--inplace|--split-exp)/,file:/^(?:-C|--compile)/,tree:/^(?:-o|--output|-R$|-H$)/,git:/^(?:--output|--ext-diff|--textconv|-c$|--exec-path|--git-dir|--work-tree)/};function To(t){if(/\$|`|<\(|>\(|\\\r?\n/.test(t)||/>/.test(t.replace(/2>&1|[12]?>\s*\/dev\/null/g,"")))return!1;for(let e of Pn(t)){if(e.kind==="sep")continue;if(e.unsafe)return!1;let n=e.text.trim().split(/\s+/).filter(Boolean).map(i=>i.replace(/['"\\]/g,""));if(n.length===0)continue;if(n.some(i=>$n.test(i)))return!1;let r=bt(n[0]);if(r!==n[0])return!1;let s=So[r];if(s&&n.slice(1).some(i=>s.test(i)))return!1;if(!(r==="git"?wo.has(n[1]??""):Eo.has(r)))return!1}return!0}function Mn(t,e,n=vo()){if(t.tool_name!=="Bash")return null;let r=t.tool_input??{};if(r.run_in_background)return null;let s=r.command;if(typeof s!="string"||!s||e==="codex"&&Object.keys(r).some(o=>!ko.has(o))||e==="codex"&&!To(s)||!n)return null;let i=xo(s,n);return On(t.session_id??"unknown",i!==s),i===s?null:JSON.stringify({hookSpecificOutput:e==="codex"?{hookEventName:"PreToolUse",permissionDecision:"allow",updatedInput:{...r,command:i}}:{hookEventName:"PreToolUse",updatedInput:{command:i}}})}import{join as Ao}from"node:path";import{mkdir as Au,readFile as Ro,writeFile as Ru,unlink as Cu,rename as Iu}from"node:fs/promises";var Co="state.json";function Io(){try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t&&t.length>0?t:"Etc/UTC"}catch{return"Etc/UTC"}}function Oo(t){return t?.dir??T()}async function Pe(t){let e=Oo(t);try{let n=await Ro(Ao(e,Co),"utf8"),r=JSON.parse(n);return{...r,lastSettingsRevision:r.lastSettingsRevision??0,timeZone:r.timeZone??Io(),bonusActive:r.bonusActive??!1,...r.bonusResetAt!==void 0?{bonusResetAt:r.bonusResetAt}:{}}}catch{return null}}function Do(){let t=Number(process.env.TOKMIZER_OFFLINE_GRACE_MS);return Number.isFinite(t)&&t>0?t:6048e5}function Ln(t,e=Date.now()){let n=t.lastHeartbeatOkAt;if(typeof n=="number"&&e-n>Do())return!0;if(t.subEndsAt){let r=Date.parse(t.subEndsAt);if(Number.isFinite(r)&&e>r)return!0}return!1}function Fn(t,e=Date.now()){return t.plan}import{readFile as No,writeFile as Pu,mkdir as Mu,chmod as Lu,rm as Fu,rename as Bu,readdir as ju}from"node:fs/promises";import{join as $o}from"node:path";var Po="settings-cache.json",Bn=Ne.parse({}),Hu=Ne.partial().extend({filters:Ne.shape.filters.removeDefault().partial().optional()});async function Me(){try{let t=await No($o(T(),Po),"utf8"),e=JSON.parse(t);return Ne.parse({...Bn,...e})}catch{return Bn}}var Mo=[[/(authorization\s*:\s*)([A-Za-z][A-Za-z0-9._-]*)\s+[^\s'"]+/gi,"$1$2 [REDACTED]"],[/(authorization\s*:\s*)[A-Za-z0-9._\-+/=]{8,}/gi,"$1[REDACTED]"],[/(bearer\s+)[A-Za-z0-9._\-+/=]{8,}/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-b|--cookie)[=\s]+['"]?)[^\s'";=]+=[^\s'";]+(?:\s*;\s*[^\s'";=]+=[^\s'";]+)*/gi,"$1[REDACTED]"],[/((?:^|[\s'"])(?:Set-)?Cookie\s*:\s*)[^\s'";=]+=[^\s'";]+(?:\s*;\s*[^\s'";=]+=[^\s'";]+)*/gi,"$1[REDACTED]"],[/(--?(?:password|passwd|passphrase|apipass|pass|pwd|token|api[-_]?key|secret|bearer|cookie|jwt)(?:-[a-z0-9]+)*[=\s]+)\S+/gi,"$1[REDACTED]"],[/((?:^|\s)-b[=\s]?['"]?)[^\s'"=]+=[^\s'"]+/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?[^\s:/'"]*:)(\/[^/\s'"][^\s'"]*|[^\s/'"0-9][^\s'"]*|[0-9][^\s'"]*[^\s'"0-9][^\s'"]*)/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?[^\s:/'"]*[^\s:/'"0-9][^\s:/'"]*:)(?:\/[^/\s'"]|[^\s/'"])[^\s'"]*/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?:)(?:\/[^/\s'"]|[^\s/'"])[^\s'"]*/gi,"$1[REDACTED]"],[/((?:[A-Za-z0-9]+-){0,8}(?:X-Api-Key|Private-Token|[A-Za-z0-9]+-(?:Token|Key|Auth|Secret))\s*:\s*)[^\s'"]+/gi,"$1[REDACTED]"],[/((?:^|[\s'"])(?:Set-)?Cookie\s*:\s*)[^\s'"]+/gi,"$1[REDACTED]"],[/(-i\s+)(\/[^\s]+|~\/[^\s]+|[A-Z]:\\[^\s]+)/g,"$1[REDACTED]"],[/([a-zA-Z][a-zA-Z0-9+.-]{0,31}:\/\/[^:/\s@]*:)[^\s@]+(@[^@/\s]+)/g,"$1[REDACTED]$2"],[/(AWS_(?:ACCESS_KEY_ID|SECRET_ACCESS_KEY|SESSION_TOKEN)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(GOOGLE_APPLICATION_CREDENTIALS\s*=\s*)\S+/g,"$1[REDACTED]"],[/(AZURE_(?:CLIENT_SECRET|TENANT_ID|CLIENT_ID)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-(?:proj-)?[A-Za-z0-9_-]{20,})/g,"sk-[REDACTED]"],[/\b(OPENAI_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(ANTHROPIC_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-ant-[A-Za-z0-9_-]{20,})/g,"sk-ant-[REDACTED]"],[/\b(GH(?:_|ITHUB_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(GITLAB_TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(SLACK_(?:BOT_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/(xox[bpsoa]-[A-Za-z0-9-]{10,})/g,"xox[REDACTED]"],[/(xapp-[A-Za-z0-9-]{10,})/g,"[REDACTED]"],[/(sk_(?:test|live)_[A-Za-z0-9]{16,})/g,"sk_[REDACTED]"],[/(gh[a-z])_[A-Za-z0-9]{20,}/g,"$1_[REDACTED]"],[/(github_pat)_[A-Za-z0-9_]{20,}/g,"$1_[REDACTED]"],[/(gl(?:pat|rt|soat|imt|dt|ft|agent|oas|cbt|ptt))-[A-Za-z0-9_-]{16,}/g,"$1-[REDACTED]"],[/(npm_[A-Za-z0-9_-]{20,})/g,"npm_[REDACTED]"],[/(?:AKIA|ASIA|AGPA|AIDA|AROA|ANPA)[0-9A-Z]{16,}/g,"[REDACTED_AWS_KEY]"],[/AIza[A-Za-z0-9_-]{35}/g,"[REDACTED_GOOGLE_KEY]"],[/hv[sb]\.[A-Za-z0-9_-]{20,}/g,"[REDACTED_VAULT_TOKEN]"],[/dop_v1_[A-Za-z0-9]{40,}/g,"[REDACTED]"],[/dckr_pat_[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/pypi-[A-Za-z0-9_-]{16,}/g,"[REDACTED]"],[/rk_(?:live|test)_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/whsec_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/SG\.[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/(eyJ[A-Za-z0-9_-]{6,}(?:\.[A-Za-z0-9_-]{4,}){1,2})/g,"[REDACTED_JWT]"],[/-----BEGIN [A-Z ]*PRIVATE KEY-----(?:[\s\S]*?-----END[^\n]*-----|\r?\n[A-Za-z0-9+/=][A-Za-z0-9+/=\r\n]*)?/g,"[REDACTED_PEM]"],[/\b((?:--?)?[A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|AUTH|_PWD)[A-Za-z0-9_]*['"]?\s*=\s*)(?:"[^"]*"|'[^']*'|[^"'\s]\S*)/gi,"$1[REDACTED]"],[/\b([A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|_PWD)[A-Za-z0-9_]*['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/((?:^|[\s'"{,])['"]?(?:[A-Za-z0-9_]+_)?auth['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/(\bpwd\s*[=:]\s*)(?:"[^"]*"|'[^']*'|[^/~\s][^\s;'"]*)/gi,"$1[REDACTED]"],[/([=:]\s*["']?)[A-Za-z0-9_\-+/=]{40,}/g,"$1[REDACTED]"]];function Le(t){let e=t;for(let[n,r]of Mo)e=e.replace(n,r);return e}import{join as Hn}from"node:path";import{appendFileSync as Uo,chmodSync as Ho,existsSync as Vo,mkdirSync as Ko,readFileSync as cd,renameSync as ld,rmdirSync as ud,statSync as Wo,unlinkSync as dd,utimesSync as fd,writeFileSync as pd}from"node:fs";import{createHash as Gu,randomUUID as Lo}from"node:crypto";import{readFile as jn,writeFile as zn,mkdir as Fo}from"node:fs/promises";async function vt(){try{let n=(await jn($e(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(n))return n}catch{}await Fo(T(),{recursive:!0});let t=Lo();try{return await zn($e(),t,{mode:384,flag:"wx"}),t}catch{try{let e=(await jn($e(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(e))return e}catch{}return await zn($e(),t,{mode:384}),t}}import{createRequire as Bo}from"node:module";var jo=Bo(import.meta.url);function zo(){for(let t of["../package.json","../../package.json"])try{let e=jo(t).version;if(typeof e=="string"&&e)return e}catch{}return"0.0.0"}var xt=zo();var Zn=`-----BEGIN PUBLIC KEY-----
32
36
  MCowBQYDK2VwAyEAj/kMlXlhTIGHRKxOKMuGFa1S1ybxxwgdYcAE0YM9fgU=
33
37
  -----END PUBLIC KEY-----
34
- `;var Yu=300*1e3;function Bn(){return((process.env.TOKMIZER_DEV==="1"?process.env.TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM:void 0)??jn).replace(/\\n/g,`
35
- `)}var Uo=512*1024;function Zn(){return zn(T(),"spool")}function Ho(t){return zn(Zn(),`${t}.jsonl`)}function et(t,e){try{zo(Zn(),{recursive:!0,mode:448});let n=Ho(t);if(Bo(n)&&Zo(n).size>=Uo)return;Fo(n,JSON.stringify(e)+`
36
- `,{mode:384}),jo(n,384)}catch{return}}var Ko=/^[a-z0-9][a-z0-9._-]*$/i,Wo=/^[a-z][a-z-]+$/,Go=/^[A-Za-z_][A-Za-z0-9_]*=/,Yo=new Set(["gh","glab","gup","hub","gist"]),qo=/^(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,Jo=24,Xo=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"]);function Un(t){let e=t.toLowerCase();return e.startsWith("git")||Yo.has(e)}function bt(t){let e=t.trim().split(/\s+/).filter(a=>a.length>0),n=0;for(;n<e.length&&Go.test(e[n]??"");)n+=1;let r=e[n];if(!r||!Ko.test(r)||r.length>Jo||Un(r)||qo.test(r)||je(r)!==r)return"";let s=e[n+1];return s&&Un(s)?"":(s&&Xo.has(r.toLowerCase())&&Wo.test(s)?`${r} ${s}`:r).slice(0,64)}async function Hn(t){if(!t.telemetryOptIn)return;let e=bt(t.cmd),n=e&&je(e)===e?e:"other",r=t.sessionId?t.sessionId.replace(/[^A-Za-z0-9._-]/g,"").slice(0,64):"";et("telemetry",{cmd:n,tokensSaved:Math.max(0,Math.round(t.tokensSaved)),...t.tokensRestored?{tokensRestored:Math.max(0,Math.round(t.tokensRestored))}:{},...t.rawTokens!=null?{rawTokens:Math.max(0,Math.round(t.rawTokens))}:{},optimized:t.optimized,...r?{sessionId:r}:{},...t.host?{host:t.host}:{}})}async function Vn(t){if(t.plan!=="pro"||!(await Fe()).telemetryOptIn)return;let e=bt(t.cmd);!e||je(e)!==e||et("learn",{cmd:e,filterId:t.filterId==null?null:j(t.filterId),rawBytes:t.rawBytes,filteredBytes:t.filteredBytes})}import{appendFileSync as Qo,chmodSync as ea,mkdirSync as ta}from"node:fs";import{join as na}from"node:path";var ra="stats.jsonl";var Kn=2*1024*1024;var sa=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),ia=new Set(["-u","-g","-n","-s","-k"]),oa=/^[a-z0-9][a-z0-9._-]*$/i,aa=new Set(["git","npm","pnpm","yarn","npx","docker","kubectl","helm","cargo","go","brew","gh","pip","pip3","apt","apt-get","systemctl","terraform","aws","gcloud","az","bundle","rake","rails","prisma","poetry","uv","gem","composer"]),Gn=/^[A-Za-z_][A-Za-z0-9_]*=/;function Wn(t){return t.length===0||t[0]==="cd"||t.every(e=>Gn.test(e))}function ca(t){let e=[],n="",r=!1,s=null,i=()=>{r&&e.push(n),n="",r=!1};for(let o of t){if(s){o===s?s=null:n+=o;continue}if(o==="'"||o==='"'){s=o,r=!0;continue}if(o===" "||o===" "){i();continue}if(`|;&<>
37
- `.includes(o)){if(i(),Wn(e)){e=[];continue}return e}n+=o,r=!0}return i(),Wn(e)?[]:e}function Yn(t){let e=ca(t).map(a=>a.replace(/^[({]+/,"")).filter(Boolean),n=0;for(;n<e.length;){let a=e[n];if(Gn.test(a)){n+=1;continue}if(sa.has(a)){for(n+=1;n<e.length;){let l=e[n];if(l.startsWith("-")){n+=ia.has(l)?2:1;continue}if(/^\d+(?:\.\d+)?[smhd]?$/.test(l)){n+=1;continue}break}continue}break}if(n>=e.length)return"";let r=e[n],s=r.includes("/")?r.slice(r.lastIndexOf("/")+1):r,i=e[n+1];return(i&&!i.startsWith("-")&&oa.test(i)&&aa.has(s.toLowerCase())?`${s} ${i}`:s).slice(0,24)}function la(){return na(T(),ra)}function qn(t,e,n=la(),r=!1,s,i,o){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(e)||t<0||e<0||t+e===0)return;let a=s?`,"h":${JSON.stringify(s)}`:"",l=i?`,"k":${JSON.stringify(i)}`:"",u=o?`,"c":${JSON.stringify(o.slice(0,24))}`:"",d=`{"t":${Math.floor(Date.now()/1e3)},"r":${t},"f":${e}${r?',"m":1':""}${a}${l}${u}}
38
- `;try{ta(T(),{recursive:!0,mode:448}),Qo(n,d,{mode:384}),ea(n,384),Qe(n,Kn,Kn/2)}catch{return}}function Jn(t,e,n){let r=n!=null?Math.min(t,n):t,s=n!=null?Math.min(e,n):e;return{raw:r,filtered:s}}var ua=[{host:"claude-code",vars:["CLAUDECODE","CLAUDE_CODE_ENTRYPOINT","CLAUDE_CODE","CLAUDE_CODE_VERSION","ANTHROPIC_CLAUDE_CODE"]},{host:"codex",vars:["CODEX_VERSION","CODEX_CLI","OPENAI_CODEX","CODEX_THREAD_ID","CODEX_SESSION_ID"]},{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"]}],Cd=[...ua.map(t=>t.host),"shell"];function Xn(t){return null}import{createConnection as wa}from"node:net";import{spawn as Sa}from"node:child_process";import{existsSync as ir,openSync as Et,closeSync as rr,unlinkSync as St,writeFileSync as Tt,mkdirSync as At,readFileSync as Ta,appendFileSync as Aa,rmSync as Ra,statSync as Ca}from"node:fs";import{dirname as Ia,join as Rt}from"node:path";import{fileURLToPath as Oa}from"node:url";var da=m.object({id:m.string().min(1).max(64),op:m.literal("filter"),cmd:m.string().min(1).max(2048),plan:m.enum(["trial","smart","pro"]),allowed:m.array(m.string().min(1).max(64)).max(512).optional(),installId:m.string().min(1).max(64).optional()}),fa=m.object({id:m.string().min(1).max(64),op:m.literal("ping")}),pa=m.object({id:m.string().min(1).max(64),op:m.literal("shutdown"),installId:m.string().min(1).max(64)}),ma=m.object({id:m.string().min(1).max(64),op:m.literal("reload"),installId:m.string().min(1).max(64).optional()}),Nd=m.discriminatedUnion("op",[da,fa,pa,ma]),$d=m.object({id:m.string(),ok:m.literal(!0),data:m.unknown()}),Pd=m.object({id:m.string(),ok:m.literal(!1),err:m.string(),retryAfterMs:m.number().int().nonnegative().optional()}),Qn=m.object({filter:Se.nullable(),cacheHit:m.boolean().optional()}),tt=`
39
- `,Md=64*1024;function vt(t){return JSON.stringify(t)+tt}function*er(t){let e=0;for(;;){let n=t.indexOf(tt,e);if(n<0)return;yield t.slice(e,n),e=n+1}}function Be(){return`${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import ha from"node:os";import{join as ze}from"node:path";import{existsSync as ga,statSync as ya,lstatSync as tr,unlinkSync as _a,mkdirSync as ba,chmodSync as va}from"node:fs";import{createHash as xa}from"node:crypto";var xt=100;function ka(t){let e=xa("sha256").update(T()).digest("hex").slice(0,8),n=ze(ha.tmpdir(),`tkr-${t}-${e}`),r=ze(n,"d.sock");if(Buffer.byteLength(r)>xt)throw new Error("Temporary directory path is too long for IPC");return nr(n,t),r}function Ea(t,e){try{let n=tr(t);return n.isDirectory()&&n.uid===e&&(n.mode&63)===0}catch{return!1}}function nr(t,e){ba(t,{recursive:!0,mode:448});let n=tr(t);if(!n.isDirectory()||n.uid!==e)throw new Error("Unsafe IPC directory");va(t,448)}function Ze(){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&&Ea(e,t)){let s=ze(e,`tokmizer-${t}.sock`);if(Buffer.byteLength(s)<=xt)return{path:s,isPipe:!1}}let n=ze(T(),"run"),r=ze(n,"daemon.sock");return Buffer.byteLength(r)>xt?{path:ka(t),isPipe:!1}:(nr(n,t),{path:r,isPipe:!1})}async function kt(){let{path:t,isPipe:e}=Ze();if(e||!ga(t))return;try{if(!ya(t).isSocket())return}catch{return}let n=await import("node:net");if(!await new Promise(s=>{let i=n.createConnection(t),o=a=>{i.removeAllListeners();try{i.destroy()}catch{}s(a)};i.once("connect",()=>o(!0)),i.once("error",a=>{let l=a.code;o(l!=="ECONNREFUSED"&&l!=="ENOENT")}),setTimeout(()=>o(!0),250)}))try{_a(t)}catch{}}var Ud=5*6e4;var or=500,Da=3e3,sr=1,Na=6e4,$a=256*1024;function Ct(){return Rt(T(),"daemon.spawn.fail")}function It(){return Rt(T(),"daemon.log")}function Pa(){try{let t=Number(Ta(Ct(),"utf8"));return Number.isFinite(t)&&Date.now()-t<Na}catch{return!1}}function Ma(t){try{At(T(),{recursive:!0});let e=It();try{Ca(e).size>$a&&St(e)}catch{}Aa(e,`${new Date().toISOString()} ${t}
40
- `)}catch{}}function La(t){try{At(T(),{recursive:!0}),Tt(Ct(),String(Date.now()))}catch{}Ma(`spawn failed: ${t.message}`)}function Fa(){try{Ra(Ct(),{force:!0})}catch{}}async function nt(t,e){return new Promise((n,r)=>{let s=wa(t),i=a=>{if(s.removeAllListeners("connect"),s.removeAllListeners("error"),clearTimeout(o),a){try{s.destroy()}catch{}r(a)}else n(s)},o=setTimeout(()=>i(new Error("connect timeout")),e);s.once("connect",()=>i(null)),s.once("error",a=>i(a))})}function ja(){return process.env.TOKMIZER_DAEMON_BIN?process.env.TOKMIZER_DAEMON_BIN:Oa(new URL("../bin/tkr-daemon.js",import.meta.url))}async function wt(t,e=3e3){let n=Math.ceil(e/75),r=process.platform==="win32";for(let s=0;s<n;s++){if(r)try{return(await nt(t,75)).destroy(),!0}catch{}else if(ir(t))return!0;await new Promise(i=>setTimeout(i,75))}return!1}async function Ba(t){let e=ja();if(!ir(e))throw new Error(`tkr-daemon binary not found at ${e}`);let{path:n}=Ze(),r=process.platform==="win32"?T():Ia(n);try{At(r,{recursive:!0})}catch{}let s=Rt(r,"daemon.spawn.lock"),i=null;try{i=Et(s,"wx"),Tt(i,String(process.pid))}catch(o){if(o.code==="EEXIST"){if(await wt(n,5e3))return;try{St(s)}catch{}try{i=Et(s,"wx"),Tt(i,String(process.pid))}catch(l){if(l.code==="EEXIST"){await wt(n,5e3);return}throw l}}else throw o}try{let o=null;try{o=Et(It(),"a")}catch{}if(Sa(process.execPath,[e],{detached:!0,stdio:["ignore","ignore",o??"ignore"],env:{...process.env,TOKMIZER_DAEMON_INSTALL_ID:t}}).unref(),o!==null)try{rr(o)}catch{}if(!await wt(n,3e3))throw new Error("tkr-daemon failed to bind socket within 3s")}finally{if(i!==null){try{rr(i)}catch{}try{St(s)}catch{}}}}async function za(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:Ze(),n=await yt();try{let r=await nt(e,or);r.write(vt({id:Be(),op:"shutdown",installId:n})),await new Promise(s=>setTimeout(s,150));try{r.destroy()}catch{}return!0}catch{return!1}}async function Za(t,e){let n=Date.now()+e;for(;Date.now()<n;){try{(await nt(t,250)).destroy()}catch{return!0}await new Promise(r=>setTimeout(r,100))}return!1}async function Ot(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:Ze(),n=await yt(),r=null,s=0,i=!1;for(;s<=sr;)try{r=await nt(e,or),Fa();break}catch{if(s+=1,s>sr)throw new Error(`tkr-daemon unreachable at ${e}`);if(Pa())throw new Error(`tkr-daemon spawn on cooldown (see ${It()})`);await kt();try{await Ba(n),i=!0}catch(d){throw La(d),d}}if(!r)throw new Error("tkr-daemon: socket setup failed");let o=new Map,a="";r.setEncoding("utf8"),r.on("data",d=>{a+=d;let f=-1;for(let g=0;g<a.length;g++)a[g]===tt&&(f=g);if(f<0)return;let c=[];for(let g of er(a.slice(0,f+1)))c.push(g);a=a.slice(f+1);for(let g of c)if(g)try{let _=JSON.parse(g),k=o.get(_.id);if(!k)continue;clearTimeout(k.timer),o.delete(_.id),k.resolve(_)}catch{}}),r.on("close",()=>{for(let d of o.values())clearTimeout(d.timer),d.reject(new Error("daemon socket closed"));o.clear()}),r.on("error",()=>{});function l(d){return new Promise((f,c)=>{let g=setTimeout(()=>{o.delete(d.id),c(new Error(`daemon request timeout (${d.op})`))},Da);o.set(d.id,{resolve:f,reject:c,timer:g}),r.write(vt(d))})}let u={filter:async(d,f,c)=>{let g=await l({id:Be(),op:"filter",cmd:d.slice(0,2048),plan:f,...c&&c.length>0?{allowed:c.slice(0,512)}:{},installId:n});if(!g.ok)return null;let _=Qn.safeParse(g.data);return _.success?_.data.filter:null},ping:async()=>{let d=await l({id:Be(),op:"ping"});if(!d.ok)throw new Error(d.err);return d.data},reload:async()=>{let d=await l({id:Be(),op:"reload",installId:n});if(!d.ok)throw new Error(d.err);return d.data},close:()=>{try{r.end()}catch{}}};if(!t.skipVersionCheck&&!i){let d=!1;try{d=(await u.ping()).version!==_t}catch{}if(d){try{await za(t.socketPath?{socketPath:t.socketPath}:{})}catch{}u.close();let f=await Za(e,2e3);if(await kt(),!f)throw new Error("stale daemon still running after shutdown request");return Ot({...t,skipVersionCheck:!0})}}return u}import{createPublicKey as Xa,verify as Qa}from"node:crypto";import{createCipheriv as sf,createDecipheriv as Ua,hkdfSync as Ha,randomBytes as of}from"node:crypto";var Va=Buffer.from("tokmizer-bundle-enc-v1"),Ka=Buffer.from("rules-bundle");function Wa(t){return Buffer.from(Ha("sha256",Buffer.from(t,"utf8"),Va,Ka,32))}function ar(t,e){let n=Wa(e),r=Buffer.from(t,"base64url"),s=r.subarray(0,12),i=r.subarray(12,28),o=r.subarray(28),a=Ua("aes-256-gcm",n,s);return a.setAuthTag(i),Buffer.concat([a.update(o),a.final()]).toString("utf8")}import{chmodSync as lf,readFileSync as Ga,writeFileSync as uf,mkdirSync as df,renameSync as ff}from"node:fs";import{join as Ya}from"node:path";var qa=m.object({payload:m.string().min(1),signature:m.string().min(1),enc:m.literal("v1"),fetchedAt:m.number().int().nonnegative()});function Ja(){return Ya(T(),"bundle-cache.json")}function cr(){try{let t=Ga(Ja(),"utf8"),e=qa.safeParse(JSON.parse(t));return e.success?e.data:null}catch{return null}}var ec=m.object({bundleVersion:m.number().int().nonnegative(),signedAt:m.number().int(),filters:m.array(Se)}),Tf=m.object({payload:m.string().min(1),signature:m.string().min(1),enc:m.literal("v1")}),tc=10080*60*1e3;function nc(){let t=Number(process.env.TOKMIZER_MAX_BUNDLE_AGE_MS);return Number.isFinite(t)&&t>0?t:tc}function rc(t,e){let n=Bn();if(!n||!n.includes("BEGIN PUBLIC KEY"))throw new Error("tkr-daemon: no valid signing public key configured (set TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM at build time).");let r=Xa({key:n,format:"pem"});if(!Qa(null,Buffer.from(t.payload,"utf8"),r,Buffer.from(t.signature,"base64url")))throw new Error("tkr-daemon: rules bundle signature invalid");return JSON.parse(ar(t.payload,e))}function sc(t,e){let n=rc(t,e),r=ec.parse(n);if(Date.now()-r.signedAt>nc())throw new Error("tkr-daemon: rules bundle is stale");let s=new Map;for(let i of r.filters)s.set(i.slug,{...i,matchRegex:new RegExp(i.match_command)});return Qt(),{bundleVersion:r.bundleVersion,signedAt:r.signedAt,ruleCount:s.size,startedAt:Date.now(),fetchedAt:Date.now(),selectFor:(i,o,a)=>qe(i,s.values(),a&&a.length>0?new Set(a):null)}}async function lr(){try{let t=cr();if(!t)return null;let e=await Le();return e?.signingSecret?sc(t,e.signingSecret):null}catch{return null}}var Ae=null,Ue=null;async function ic(){if(Ae)return Ae;if(Ue)return Ue;let t=Ot().then(e=>{if(Ue===t)return Ae=e,e;try{e.close()}catch{}return null}).catch(()=>null);return Ue=t,t}var Dt=null,Nt=!1;async function oc(){return Nt||(Nt=!0,Dt=await lr()),Dt}async function ur(t,e,n){let r=await oc();if(!r)return null;let s=r.selectFor(t,e,[...n]);return!s||!n.has(j(s.slug))?null:s}function ac(t){return t?{...t,matchRegex:new RegExp(t.match_command)}:null}function dr(t){mt(async(e,n)=>{let r=t==="free"?"trial":t,s=n??Ye(void 0),i=await ic();if(!i)return ur(e,r,s);try{let o=await i.filter(e,r,[...s]);return!o||!s.has(j(o.slug))?null:ac(o)}catch{return ur(e,r,s)}})}function fr(){if(mt(null),Ae)try{Ae.close()}catch{}Ae=null,Ue=null,Dt=null,Nt=!1}import{readFileSync as cc}from"node:fs";import{join as lc}from"node:path";function pr(){try{return cc(lc(T(),"yolo-mode"),"utf8")==="on"}catch{return!1}}var uc=new Set(["shell","bash","exec","run_shell_command","execute_shell_command"]);async function dc(t){if(t.event!=="after_tool_call")return{action:"continue"};if(!uc.has(t.tool))return{action:"continue"};let e=t.command??(t.args??[]).join(" ");if(!e)return{action:"continue"};let n=t.stdout??"",r=t.stderr??"",s=pr();if(!n&&(!s||!r))return{action:"continue"};let i=await Fe();if(!i.enabled)return{action:"continue"};let o=await Le();if(!o||!o.token)return{action:"continue"};let a=Pn(o);dr(a);let l=Ye(o.allowedFilters,$n(o)),u=new Set(i.filters.disabled.map(j)),d=u.size>0?new Set([...l].filter(B=>!u.has(B))):l,f,c=null;try{f=await ht(e,n,d,{verbosity:i.outputVerbosity,yolo:s,exitCode:t.exit_code}),s&&r&&(c=await ht(e,r,d,{verbosity:i.outputVerbosity,yolo:s,exitCode:t.exit_code}))}finally{fr()}let g=f.filteredBytes<f.rawBytes||c!=null&&c.filteredBytes<c.rawBytes,_=c?.output??r,k=_?f.output?`${f.output}
41
- ${_}`:_:f.output,A=Buffer.byteLength(n,"utf8")+Buffer.byteLength(r,"utf8"),R=Jn(A,g?Buffer.byteLength(k,"utf8"):A,Xn("codex"));return qn(R.raw,R.filtered,void 0,!1,"codex","sh",Yn(e)),await Vn({cmd:e,filterId:f.filterId,rawBytes:f.rawBytes,filteredBytes:f.filteredBytes,plan:a}),await Hn({cmd:e,tokensSaved:Math.max(0,Math.round((R.raw-R.filtered)/4)),rawTokens:Math.round(R.raw/4),optimized:f.filterId!=null,telemetryOptIn:i.telemetryOptIn,host:"codex"}),g?{action:"replace_output",replacement:k,reason:"tokmizer"}:{action:"continue"}}async function fc(t){let e=JSON.stringify({action:"continue"});if(!t)return e;let n;try{n=JSON.parse(t)}catch{return e}if(n.hook_event_name==="PreToolUse")return Nn(n,"codex")??"";if(n.hook_event_name)return"";try{return JSON.stringify(await dc(n))}catch(r){return process.stderr.write(`tkr-codex: ${r.message}
42
- `),e}}async function mr(){let t=await fc(await Sn());t&&process.stdout.write(t)}mr().catch(t=>{process.stderr.write(`tkr-codex-hook: ${t.message}
38
+ `;var rd=300*1e3;function Un(){return((process.env.TOKMIZER_DEV==="1"?process.env.TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM:void 0)??Zn).replace(/\\n/g,`
39
+ `)}var Go=512*1024;function Vn(){return Hn(T(),"spool")}function Yo(t){return Hn(Vn(),`${t}.jsonl`)}function tt(t,e){try{Ko(Vn(),{recursive:!0,mode:448});let n=Yo(t);if(Vo(n)&&Wo(n).size>=Go)return;Uo(n,JSON.stringify(e)+`
40
+ `,{mode:384}),Ho(n,384)}catch{return}}var Jo=/^[a-z0-9][a-z0-9._-]*$/i,Xo=/^[a-z][a-z-]+$/,Qo=/^[A-Za-z_][A-Za-z0-9_]*=/,ea=new Set(["gh","glab","gup","hub","gist"]),ta=/^(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,na=24,ra=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"]);function Kn(t){let e=t.toLowerCase();return e.startsWith("git")||ea.has(e)}function kt(t){let e=t.trim().split(/\s+/).filter(a=>a.length>0),n=0;for(;n<e.length&&Qo.test(e[n]??"");)n+=1;let r=e[n];if(!r||!Jo.test(r)||r.length>na||Kn(r)||ta.test(r)||Le(r)!==r)return"";let s=e[n+1];return s&&Kn(s)?"":(s&&ra.has(r.toLowerCase())&&Xo.test(s)?`${r} ${s}`:r).slice(0,64)}async function Wn(t){if(!t.telemetryOptIn)return;let e=kt(t.cmd),n=e&&Le(e)===e?e:"other",r=t.sessionId?t.sessionId.replace(/[^A-Za-z0-9._-]/g,"").slice(0,64):"";tt("telemetry",{cmd:n,tokensSaved:Math.max(0,Math.round(t.tokensSaved)),...t.tokensRestored?{tokensRestored:Math.max(0,Math.round(t.tokensRestored))}:{},...t.rawTokens!=null?{rawTokens:Math.max(0,Math.round(t.rawTokens))}:{},optimized:t.optimized,...r?{sessionId:r}:{},...t.host?{host:t.host}:{}})}async function Gn(t){if(t.plan!=="pro"||!(await Me()).telemetryOptIn)return;let e=kt(t.cmd);!e||Le(e)!==e||tt("learn",{cmd:e,filterId:t.filterId==null?null:B(t.filterId),rawBytes:t.rawBytes,filteredBytes:t.filteredBytes})}import{appendFileSync as sa,chmodSync as ia,mkdirSync as oa}from"node:fs";import{join as aa}from"node:path";var ca="stats.jsonl";var Yn=2*1024*1024;var la=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),ua=new Set(["-u","-g","-n","-s","-k"]),da=/^[a-z0-9][a-z0-9._-]*$/i,fa=new Set(["git","npm","pnpm","yarn","npx","docker","kubectl","helm","cargo","go","brew","gh","pip","pip3","apt","apt-get","systemctl","terraform","aws","gcloud","az","bundle","rake","rails","prisma","poetry","uv","gem","composer"]),Jn=/^[A-Za-z_][A-Za-z0-9_]*=/;function qn(t){return t.length===0||t[0]==="cd"||t.every(e=>Jn.test(e))}function pa(t){let e=[],n="",r=!1,s=null,i=()=>{r&&e.push(n),n="",r=!1};for(let o of t){if(s){o===s?s=null:n+=o;continue}if(o==="'"||o==='"'){s=o,r=!0;continue}if(o===" "||o===" "){i();continue}if(`|;&<>
41
+ `.includes(o)){if(i(),qn(e)){e=[];continue}return e}n+=o,r=!0}return i(),qn(e)?[]:e}function Xn(t){let e=pa(t).map(a=>a.replace(/^[({]+/,"")).filter(Boolean),n=0;for(;n<e.length;){let a=e[n];if(Jn.test(a)){n+=1;continue}if(la.has(a)){for(n+=1;n<e.length;){let l=e[n];if(l.startsWith("-")){n+=ua.has(l)?2:1;continue}if(/^\d+(?:\.\d+)?[smhd]?$/.test(l)){n+=1;continue}break}continue}break}if(n>=e.length)return"";let r=e[n],s=r.includes("/")?r.slice(r.lastIndexOf("/")+1):r,i=e[n+1];return(i&&!i.startsWith("-")&&da.test(i)&&fa.has(s.toLowerCase())?`${s} ${i}`:s).slice(0,24)}function ma(){return aa(T(),ca)}function Qn(t,e,n=ma(),r=!1,s,i,o){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(e)||t<0||e<0||t+e===0)return;let a=s?`,"h":${JSON.stringify(s)}`:"",l=i?`,"k":${JSON.stringify(i)}`:"",u=o?`,"c":${JSON.stringify(o.slice(0,24))}`:"",f=`{"t":${Math.floor(Date.now()/1e3)},"r":${t},"f":${e}${r?',"m":1':""}${a}${l}${u}}
42
+ `;try{oa(T(),{recursive:!0,mode:448}),sa(n,f,{mode:384}),ia(n,384),et(n,Yn,Yn/2)}catch{return}}function er(t,e,n){let r=n!=null?Math.min(t,n):t,s=n!=null?Math.min(e,n):e;return{raw:r,filtered:s}}var ha=[{host:"claude-code",vars:["CLAUDECODE","CLAUDE_CODE_ENTRYPOINT","CLAUDE_CODE","CLAUDE_CODE_VERSION","ANTHROPIC_CLAUDE_CODE"]},{host:"codex",vars:["CODEX_VERSION","CODEX_CLI","OPENAI_CODEX","CODEX_THREAD_ID","CODEX_SESSION_ID"]},{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"]}],Ld=[...ha.map(t=>t.host),"shell"];function tr(t){return null}import{createConnection as Ca}from"node:net";import{spawn as Ia}from"node:child_process";import{existsSync as cr,openSync as Tt,closeSync as or,unlinkSync as Rt,writeFileSync as Ct,mkdirSync as It,readFileSync as Oa,appendFileSync as Da,rmSync as Na,statSync as $a}from"node:fs";import{dirname as Pa,join as Ot}from"node:path";import{fileURLToPath as Ma}from"node:url";var ga=m.object({id:m.string().min(1).max(64),op:m.literal("filter"),cmd:m.string().min(1).max(2048),plan:m.enum(["trial","smart","pro"]),allowed:m.array(m.string().min(1).max(64)).max(512).optional(),installId:m.string().min(1).max(64).optional()}),ya=m.object({id:m.string().min(1).max(64),op:m.literal("ping")}),_a=m.object({id:m.string().min(1).max(64),op:m.literal("shutdown"),installId:m.string().min(1).max(64)}),ba=m.object({id:m.string().min(1).max(64),op:m.literal("reload"),installId:m.string().min(1).max(64).optional()}),zd=m.discriminatedUnion("op",[ga,ya,_a,ba]),Zd=m.object({id:m.string(),ok:m.literal(!0),data:m.unknown()}),Ud=m.object({id:m.string(),ok:m.literal(!1),err:m.string(),retryAfterMs:m.number().int().nonnegative().optional()}),nr=m.object({filter:Te.nullable(),cacheHit:m.boolean().optional()}),nt=`
43
+ `,Hd=64*1024;function Et(t){return JSON.stringify(t)+nt}function*rr(t){let e=0;for(;;){let n=t.indexOf(nt,e);if(n<0)return;yield t.slice(e,n),e=n+1}}function Fe(){return`${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import va from"node:os";import{join as Be}from"node:path";import{existsSync as xa,statSync as ka,lstatSync as sr,unlinkSync as Ea,mkdirSync as wa,chmodSync as Sa}from"node:fs";import{createHash as Ta}from"node:crypto";var wt=100;function Aa(t){let e=Ta("sha256").update(T()).digest("hex").slice(0,8),n=Be(va.tmpdir(),`tkr-${t}-${e}`),r=Be(n,"d.sock");if(Buffer.byteLength(r)>wt)throw new Error("Temporary directory path is too long for IPC");return ir(n,t),r}function Ra(t,e){try{let n=sr(t);return n.isDirectory()&&n.uid===e&&(n.mode&63)===0}catch{return!1}}function ir(t,e){wa(t,{recursive:!0,mode:448});let n=sr(t);if(!n.isDirectory()||n.uid!==e)throw new Error("Unsafe IPC directory");Sa(t,448)}function je(){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&&Ra(e,t)){let s=Be(e,`tokmizer-${t}.sock`);if(Buffer.byteLength(s)<=wt)return{path:s,isPipe:!1}}let n=Be(T(),"run"),r=Be(n,"daemon.sock");return Buffer.byteLength(r)>wt?{path:Aa(t),isPipe:!1}:(ir(n,t),{path:r,isPipe:!1})}async function St(){let{path:t,isPipe:e}=je();if(e||!xa(t))return;try{if(!ka(t).isSocket())return}catch{return}let n=await import("node:net");if(!await new Promise(s=>{let i=n.createConnection(t),o=a=>{i.removeAllListeners();try{i.destroy()}catch{}s(a)};i.once("connect",()=>o(!0)),i.once("error",a=>{let l=a.code;o(l!=="ECONNREFUSED"&&l!=="ENOENT")}),setTimeout(()=>o(!0),250)}))try{Ea(t)}catch{}}var Jd=5*6e4;var lr=500,La=3e3,ar=1,Fa=6e4,Ba=256*1024;function Dt(){return Ot(T(),"daemon.spawn.fail")}function Nt(){return Ot(T(),"daemon.log")}function ja(){try{let t=Number(Oa(Dt(),"utf8"));return Number.isFinite(t)&&Date.now()-t<Fa}catch{return!1}}function za(t){try{It(T(),{recursive:!0});let e=Nt();try{$a(e).size>Ba&&Rt(e)}catch{}Da(e,`${new Date().toISOString()} ${t}
44
+ `)}catch{}}function Za(t){try{It(T(),{recursive:!0}),Ct(Dt(),String(Date.now()))}catch{}za(`spawn failed: ${t.message}`)}function Ua(){try{Na(Dt(),{force:!0})}catch{}}async function rt(t,e){return new Promise((n,r)=>{let s=Ca(t),i=a=>{if(s.removeAllListeners("connect"),s.removeAllListeners("error"),clearTimeout(o),a){try{s.destroy()}catch{}r(a)}else n(s)},o=setTimeout(()=>i(new Error("connect timeout")),e);s.once("connect",()=>i(null)),s.once("error",a=>i(a))})}function Ha(){return process.env.TOKMIZER_DAEMON_BIN?process.env.TOKMIZER_DAEMON_BIN:Ma(new URL("../bin/tkr-daemon.js",import.meta.url))}async function At(t,e=3e3){let n=Math.ceil(e/75),r=process.platform==="win32";for(let s=0;s<n;s++){if(r)try{return(await rt(t,75)).destroy(),!0}catch{}else if(cr(t))return!0;await new Promise(i=>setTimeout(i,75))}return!1}async function Va(t){let e=Ha();if(!cr(e))throw new Error(`tkr-daemon binary not found at ${e}`);let{path:n}=je(),r=process.platform==="win32"?T():Pa(n);try{It(r,{recursive:!0})}catch{}let s=Ot(r,"daemon.spawn.lock"),i=null;try{i=Tt(s,"wx"),Ct(i,String(process.pid))}catch(o){if(o.code==="EEXIST"){if(await At(n,5e3))return;try{Rt(s)}catch{}try{i=Tt(s,"wx"),Ct(i,String(process.pid))}catch(l){if(l.code==="EEXIST"){await At(n,5e3);return}throw l}}else throw o}try{let o=null;try{o=Tt(Nt(),"a")}catch{}if(Ia(process.execPath,[e],{detached:!0,stdio:["ignore","ignore",o??"ignore"],env:{...process.env,TOKMIZER_DAEMON_INSTALL_ID:t}}).unref(),o!==null)try{or(o)}catch{}if(!await At(n,3e3))throw new Error("tkr-daemon failed to bind socket within 3s")}finally{if(i!==null){try{or(i)}catch{}try{Rt(s)}catch{}}}}async function Ka(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:je(),n=await vt();try{let r=await rt(e,lr);r.write(Et({id:Fe(),op:"shutdown",installId:n})),await new Promise(s=>setTimeout(s,150));try{r.destroy()}catch{}return!0}catch{return!1}}async function Wa(t,e){let n=Date.now()+e;for(;Date.now()<n;){try{(await rt(t,250)).destroy()}catch{return!0}await new Promise(r=>setTimeout(r,100))}return!1}async function $t(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:je(),n=await vt(),r=null,s=0,i=!1;for(;s<=ar;)try{r=await rt(e,lr),Ua();break}catch{if(s+=1,s>ar)throw new Error(`tkr-daemon unreachable at ${e}`);if(ja())throw new Error(`tkr-daemon spawn on cooldown (see ${Nt()})`);await St();try{await Va(n),i=!0}catch(f){throw Za(f),f}}if(!r)throw new Error("tkr-daemon: socket setup failed");let o=new Map,a="";r.setEncoding("utf8"),r.on("data",f=>{a+=f;let d=-1;for(let g=0;g<a.length;g++)a[g]===nt&&(d=g);if(d<0)return;let c=[];for(let g of rr(a.slice(0,d+1)))c.push(g);a=a.slice(d+1);for(let g of c)if(g)try{let _=JSON.parse(g),k=o.get(_.id);if(!k)continue;clearTimeout(k.timer),o.delete(_.id),k.resolve(_)}catch{}}),r.on("close",()=>{for(let f of o.values())clearTimeout(f.timer),f.reject(new Error("daemon socket closed"));o.clear()}),r.on("error",()=>{});function l(f){return new Promise((d,c)=>{let g=setTimeout(()=>{o.delete(f.id),c(new Error(`daemon request timeout (${f.op})`))},La);o.set(f.id,{resolve:d,reject:c,timer:g}),r.write(Et(f))})}let u={filter:async(f,d,c)=>{let g=await l({id:Fe(),op:"filter",cmd:f.slice(0,2048),plan:d,...c&&c.length>0?{allowed:c.slice(0,512)}:{},installId:n});if(!g.ok)return null;let _=nr.safeParse(g.data);return _.success?_.data.filter:null},ping:async()=>{let f=await l({id:Fe(),op:"ping"});if(!f.ok)throw new Error(f.err);return f.data},reload:async()=>{let f=await l({id:Fe(),op:"reload",installId:n});if(!f.ok)throw new Error(f.err);return f.data},close:()=>{try{r.end()}catch{}}};if(!t.skipVersionCheck&&!i){let f=!1;try{f=(await u.ping()).version!==xt}catch{}if(f){try{await Ka(t.socketPath?{socketPath:t.socketPath}:{})}catch{}u.close();let d=await Wa(e,2e3);if(await St(),!d)throw new Error("stale daemon still running after shutdown request");return $t({...t,skipVersionCheck:!0})}}return u}import{createPublicKey as rc,verify as sc}from"node:crypto";import{createCipheriv as pf,createDecipheriv as Ga,hkdfSync as Ya,randomBytes as mf}from"node:crypto";var qa=Buffer.from("tokmizer-bundle-enc-v1"),Ja=Buffer.from("rules-bundle");function Xa(t){return Buffer.from(Ya("sha256",Buffer.from(t,"utf8"),qa,Ja,32))}function ur(t,e){let n=Xa(e),r=Buffer.from(t,"base64url"),s=r.subarray(0,12),i=r.subarray(12,28),o=r.subarray(28),a=Ga("aes-256-gcm",n,s);return a.setAuthTag(i),Buffer.concat([a.update(o),a.final()]).toString("utf8")}import{chmodSync as yf,readFileSync as Qa,writeFileSync as _f,mkdirSync as bf,renameSync as vf}from"node:fs";import{join as ec}from"node:path";var tc=m.object({payload:m.string().min(1),signature:m.string().min(1),enc:m.literal("v1"),fetchedAt:m.number().int().nonnegative()});function nc(){return ec(T(),"bundle-cache.json")}function dr(){try{let t=Qa(nc(),"utf8"),e=tc.safeParse(JSON.parse(t));return e.success?e.data:null}catch{return null}}var ic=m.object({bundleVersion:m.number().int().nonnegative(),signedAt:m.number().int(),filters:m.array(Te)}),$f=m.object({payload:m.string().min(1),signature:m.string().min(1),enc:m.literal("v1")}),oc=10080*60*1e3;function ac(){let t=Number(process.env.TOKMIZER_MAX_BUNDLE_AGE_MS);return Number.isFinite(t)&&t>0?t:oc}function cc(t,e){let n=Un();if(!n||!n.includes("BEGIN PUBLIC KEY"))throw new Error("tkr-daemon: no valid signing public key configured (set TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM at build time).");let r=rc({key:n,format:"pem"});if(!sc(null,Buffer.from(t.payload,"utf8"),r,Buffer.from(t.signature,"base64url")))throw new Error("tkr-daemon: rules bundle signature invalid");return JSON.parse(ur(t.payload,e))}function lc(t,e){let n=cc(t,e),r=ic.parse(n);if(Date.now()-r.signedAt>ac())throw new Error("tkr-daemon: rules bundle is stale");let s=new Map;for(let i of r.filters)s.set(i.slug,{...i,matchRegex:new RegExp(i.match_command)});return nn(),{bundleVersion:r.bundleVersion,signedAt:r.signedAt,ruleCount:s.size,startedAt:Date.now(),fetchedAt:Date.now(),selectFor:(i,o,a)=>qe(i,s.values(),a&&a.length>0?new Set(a):null)}}async function fr(){try{let t=dr();if(!t)return null;let e=await Pe();return e?.signingSecret?lc(t,e.signingSecret):null}catch{return null}}var Ce=null,ze=null;async function uc(){if(Ce)return Ce;if(ze)return ze;let t=$t().then(e=>{if(ze===t)return Ce=e,e;try{e.close()}catch{}return null}).catch(()=>null);return ze=t,t}var Pt=null,Mt=!1;async function dc(){return Mt||(Mt=!0,Pt=await fr()),Pt}async function pr(t,e,n){let r=await dc();if(!r)return null;let s=r.selectFor(t,e,[...n]);return!s||!n.has(B(s.slug))?null:s}function fc(t){return t?{...t,matchRegex:new RegExp(t.match_command)}:null}function mr(t){yt(async(e,n)=>{let r=t==="free"?"trial":t,s=n??Ye(void 0),i=await uc();if(!i)return pr(e,r,s);try{let o=await i.filter(e,r,[...s]);return!o||!s.has(B(o.slug))?null:fc(o)}catch{return pr(e,r,s)}})}function hr(){if(yt(null),Ce)try{Ce.close()}catch{}Ce=null,ze=null,Pt=null,Mt=!1}import{readFileSync as pc}from"node:fs";import{join as mc}from"node:path";function gr(){try{return pc(mc(T(),"yolo-mode"),"utf8")==="on"}catch{return!1}}var hc=new Set(["shell","bash","exec","run_shell_command","execute_shell_command"]);async function gc(t){if(t.event!=="after_tool_call")return{action:"continue"};if(!hc.has(t.tool))return{action:"continue"};let e=t.command??(t.args??[]).join(" ");if(!e)return{action:"continue"};let n=t.stdout??"",r=t.stderr??"",s=gr();if(!n&&(!s||!r))return{action:"continue"};let i=await Me();if(!i.enabled)return{action:"continue"};let o=await Pe();if(!o||!o.token)return{action:"continue"};let a=Fn(o);mr(a);let l=Ye(o.allowedFilters,Ln(o)),u=new Set(i.filters.disabled.map(B)),f=u.size>0?new Set([...l].filter(j=>!u.has(j))):l,d,c=null;try{d=await _t(e,n,f,{verbosity:i.outputVerbosity,yolo:s,exitCode:t.exit_code}),s&&r&&(c=await _t(e,r,f,{verbosity:i.outputVerbosity,yolo:s,exitCode:t.exit_code}))}finally{hr()}let g=d.filteredBytes<d.rawBytes||c!=null&&c.filteredBytes<c.rawBytes,_=c?.output??r,k=_?d.output?`${d.output}
45
+ ${_}`:_:d.output,R=Buffer.byteLength(n,"utf8")+Buffer.byteLength(r,"utf8"),A=er(R,g?Buffer.byteLength(k,"utf8"):R,tr("codex"));return Qn(A.raw,A.filtered,void 0,!1,"codex","sh",Xn(e)),await Gn({cmd:e,filterId:d.filterId,rawBytes:d.rawBytes,filteredBytes:d.filteredBytes,plan:a}),await Wn({cmd:e,tokensSaved:Math.max(0,Math.round((A.raw-A.filtered)/4)),rawTokens:Math.round(A.raw/4),optimized:d.filterId!=null,telemetryOptIn:i.telemetryOptIn,host:"codex"}),g?{action:"replace_output",replacement:k,reason:"tokmizer"}:{action:"continue"}}async function yc(t){let e=JSON.stringify({action:"continue"});if(!t)return e;let n;try{n=JSON.parse(t)}catch{return e}if(n.hook_event_name==="PreToolUse")return Mn(n,"codex")??"";if(n.hook_event_name)return"";try{return JSON.stringify(await gc(n))}catch(r){return process.stderr.write(`tkr-codex: ${r.message}
46
+ `),e}}async function yr(){let t=await yc(await Rn());t&&process.stdout.write(t)}yr().catch(t=>{process.stderr.write(`tkr-codex-hook: ${t.message}
43
47
  `),process.stdout.write(JSON.stringify({action:"continue"})),process.exit(0)});