@tokmizer/plugin 0.9.50 → 0.9.51

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,41 +1,52 @@
1
1
  import { createRequire as __tkrCreateRequire } from "node:module"; const require = __tkrCreateRequire(import.meta.url);
2
- var js=Object.defineProperty;var v=(t,e,n)=>()=>{if(n)throw n[0];try{return t&&(e=t(t=0)),e}catch(r){throw n=[r],r}};var cn=(t,e)=>{for(var n in e)js(t,n,{get:e[n],enumerable:!0})};import Bs from"node:os";import{join as Ge}from"node:path";function S(){return process.env.TOKMIZER_HOME||Ge(Bs.homedir(),".tokmizer")}function Pe(){return Ge(S(),"install-id")}function yt(){return Ge(S(),"content-cache")}function ln(t){return Ge(yt(),t)}var D=v(()=>{"use strict"});import{join as Us}from"node:path";import{mkdir as ou,readFile as Vs,writeFile as au,unlink as cu,rename as lu}from"node:fs/promises";function Ks(){try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t&&t.length>0?t:"Etc/UTC"}catch{return"Etc/UTC"}}function Ws(t){return t?.dir??S()}async function Me(t){let e=Ws(t);try{let n=await Vs(Us(e,Hs),"utf8"),r=JSON.parse(n);return{...r,lastSettingsRevision:r.lastSettingsRevision??0,timeZone:r.timeZone??Ks(),bonusActive:r.bonusActive??!1,...r.bonusResetAt!==void 0?{bonusResetAt:r.bonusResetAt}:{}}}catch{return null}}var Hs,Ye=v(()=>{"use strict";D();Hs="state.json"});var w,vt,g,z,Le=v(()=>{(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})(w||(w={}));(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(vt||(vt={}));g=w.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),z=t=>{switch(typeof t){case"undefined":return g.undefined;case"string":return g.string;case"number":return Number.isNaN(t)?g.nan:g.number;case"boolean":return g.boolean;case"function":return g.function;case"bigint":return g.bigint;case"symbol":return g.symbol;case"object":return Array.isArray(t)?g.array:t===null?g.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?g.promise:typeof Map<"u"&&t instanceof Map?g.map:typeof Set<"u"&&t instanceof Set?g.set:typeof Date<"u"&&t instanceof Date?g.date:g.object;default:return g.unknown}}});var d,_i,I,qe=v(()=>{Le();d=w.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),_i=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),I=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){let n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,c=0;for(;c<o.path.length;){let u=o.path[c];c===o.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(n(o))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return s(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,w.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()}};I.create=t=>new I(t)});var vi,V,bt=v(()=>{qe();Le();vi=(t,e)=>{let n;switch(t.code){case d.invalid_type:t.received===g.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case d.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,w.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:n=`Unrecognized key(s) in object: ${w.joinValues(t.keys,", ")}`;break;case d.invalid_union:n="Invalid input";break;case d.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${w.joinValues(t.options)}`;break;case d.invalid_enum_value:n=`Invalid enum value. Expected ${w.joinValues(t.options)}, received '${t.received}'`;break;case d.invalid_arguments:n="Invalid function arguments";break;case d.invalid_return_type:n="Invalid function return type";break;case d.invalid_date:n="Invalid date";break;case d.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:w.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case d.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case d.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case d.custom:n="Invalid input";break;case d.invalid_intersection_types:n="Intersection results could not be merged";break;case d.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case d.not_finite:n="Number must be finite";break;default:n=e.defaultError,w.assertNever(t)}return{message:n}},V=vi});function bi(t){En=t}function xe(){return En}var En,Je=v(()=>{bt();En=V});function m(t,e){let n=xe(),r=Fe({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===V?void 0:V].filter(s=>!!s)});t.common.issues.push(r)}var Fe,xi,C,b,se,O,Xe,Qe,q,ke,xt=v(()=>{Je();bt();Fe=t=>{let{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="",c=r.filter(u=>!!u).slice().reverse();for(let u of c)a=u(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}},xi=[];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 b;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 b;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}}},b=Object.freeze({status:"aborted"}),se=t=>({status:"dirty",value:t}),O=t=>({status:"valid",value:t}),Xe=t=>t.status==="aborted",Qe=t=>t.status==="dirty",q=t=>t.status==="valid",ke=t=>typeof Promise<"u"&&t instanceof Promise});var wn=v(()=>{});var y,Sn=v(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(y||(y={}))});function k(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{let{message:c}=t;return o.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:c??n??a.defaultError}},description:s}}function Cn(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 Fi(t){return new RegExp(`^${Cn(t)}$`)}function On(t){let e=`${Rn}T${Cn(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 ji(t,e){return!!((e==="v4"||!e)&&Di.test(t)||(e==="v6"||!e)&&$i.test(t))}function Bi(t,e){if(!Ai.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 zi(t,e){return!!((e==="v4"||!e)&&Ii.test(t)||(e==="v6"||!e)&&Ni.test(t))}function Zi(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}function Ee(t){if(t instanceof $){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=L.create(Ee(r))}return new $({...t._def,shape:()=>e})}else return t instanceof W?new W({...t._def,type:Ee(t.element)}):t instanceof L?L.create(Ee(t.unwrap())):t instanceof U?U.create(Ee(t.unwrap())):t instanceof Z?Z.create(t.items.map(e=>Ee(e))):t}function Et(t,e){let n=z(t),r=z(e);if(t===e)return{valid:!0,data:t};if(n===g.object&&r===g.object){let s=w.objectKeys(e),i=w.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(let a of i){let c=Et(t[a],e[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(n===g.array&&r===g.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let o=t[i],a=e[i],c=Et(o,a);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return n===g.date&&r===g.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function Dn(t,e){return new he({values:t,typeName:x.ZodEnum,...k(e)})}function An(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function In(t,e={},n){return t?X.create().superRefine((r,s)=>{let i=t(r);if(i instanceof Promise)return i.then(o=>{if(!o){let a=An(e,r),c=a.fatal??n??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!i){let o=An(e,r),a=o.fatal??n??!0;s.addIssue({code:"custom",...o,fatal:a})}}):X.create()}var F,Tn,E,ki,Ei,wi,Si,Ti,Ai,Ri,Ci,Oi,kt,Di,Ii,$i,Ni,Pi,Mi,Rn,Li,J,ie,oe,ae,ce,we,le,ue,X,K,B,Se,W,$,de,H,et,fe,Z,tt,Te,Ae,nt,pe,me,he,ge,Q,j,L,U,ye,_e,Re,Ui,je,Be,ve,Vi,x,Hi,$n,Nn,Ki,Wi,Pn,Gi,Yi,qi,Ji,Xi,Qi,eo,to,no,ro,so,io,oo,ao,co,lo,uo,fo,po,mo,ho,go,yo,_o,vo,bo,xo,ko,Eo,wo,So,To,Ao,Ro,Mn=v(()=>{qe();Je();Sn();xt();Le();F=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}},Tn=(t,e)=>{if(q(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new I(t.common.issues);return this._error=n,this._error}}};E=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(ke(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 Tn(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 q(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>q(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(ke(s)?s:Promise.resolve(s));return Tn(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:d.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new j({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 L.create(this,this._def)}nullable(){return U.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return W.create(this)}promise(){return Q.create(this,this._def)}or(e){return de.create([this,e],this._def)}and(e){return fe.create(this,e,this._def)}transform(e){return new j({...k(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new ye({...k(this._def),innerType:this,defaultValue:n,typeName:x.ZodDefault})}brand(){return new je({typeName:x.ZodBranded,type:this,...k(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new _e({...k(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 Be.create(this,e)}readonly(){return ve.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},ki=/^c[^\s-]{8,}$/i,Ei=/^[0-9a-z]+$/,wi=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Si=/^[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,Ti=/^[a-z0-9_-]{21}$/i,Ai=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ri=/^[-+]?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)?)??$/,Ci=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Oi="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Di=/^(?:(?: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])$/,Ii=/^(?:(?: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])$/,$i=/^(([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]))$/,Ni=/^(([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])$/,Pi=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Mi=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Rn="((\\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])))",Li=new RegExp(`^${Rn}$`);J=class t extends E{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==g.string){let i=this._getOrReturnCtx(e);return m(i,{code:d.invalid_type,expected:g.string,received:i.parsedType}),b}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),m(s,{code:d.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),m(s,{code:d.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?m(s,{code:d.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&m(s,{code:d.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")Ci.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"email",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")kt||(kt=new RegExp(Oi,"u")),kt.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"emoji",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")Si.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"uuid",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Ti.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"nanoid",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")ki.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")Ei.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid2",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")wi.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"ulid",code:d.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),m(s,{validation:"url",code:d.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),m(s,{validation:"regex",code:d.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),m(s,{code:d.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),m(s,{code:d.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?On(i).test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Li.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Fi(i).test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Ri.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"duration",code:d.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?ji(e.data,i.version)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"ip",code:d.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?Bi(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"jwt",code:d.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?zi(e.data,i.version)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cidr",code:d.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?Pi.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"base64",code:d.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Mi.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"base64url",code:d.invalid_string,message:i.message}),r.dirty()):w.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:d.invalid_string,...y.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...y.errToObj(e)})}url(e){return this._addCheck({kind:"url",...y.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...y.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...y.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...y.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...y.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...y.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...y.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...y.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...y.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...y.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...y.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...y.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,...y.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,...y.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...y.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...y.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...y.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...y.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...y.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...y.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...y.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...y.errToObj(n)})}nonempty(e){return this.min(1,y.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}};J.create=t=>new J({checks:[],typeName:x.ZodString,coerce:t?.coerce??!1,...k(t)});ie=class t extends E{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)!==g.number){let i=this._getOrReturnCtx(e);return m(i,{code:d.invalid_type,expected:g.number,received:i.parsedType}),b}let r,s=new C;for(let i of this._def.checks)i.kind==="int"?w.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:d.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),m(r,{code:d.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),m(r,{code:d.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Zi(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),m(r,{code:d.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:d.not_finite,message:i.message}),s.dirty()):w.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,y.toString(n))}gt(e,n){return this.setLimit("min",e,!1,y.toString(n))}lte(e,n){return this.setLimit("max",e,!0,y.toString(n))}lt(e,n){return this.setLimit("max",e,!1,y.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:y.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:y.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:y.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:y.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:y.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"&&w.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)}};ie.create=t=>new ie({checks:[],typeName:x.ZodNumber,coerce:t?.coerce||!1,...k(t)});oe=class t extends E{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)!==g.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),m(r,{code:d.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),m(r,{code:d.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),m(r,{code:d.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):w.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:g.bigint,received:n.parsedType}),b}gte(e,n){return this.setLimit("min",e,!0,y.toString(n))}gt(e,n){return this.setLimit("min",e,!1,y.toString(n))}lte(e,n){return this.setLimit("max",e,!0,y.toString(n))}lt(e,n){return this.setLimit("max",e,!1,y.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:y.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:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:y.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:y.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}};oe.create=t=>new oe({checks:[],typeName:x.ZodBigInt,coerce:t?.coerce??!1,...k(t)});ae=class extends E{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==g.boolean){let r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:g.boolean,received:r.parsedType}),b}return O(e.data)}};ae.create=t=>new ae({typeName:x.ZodBoolean,coerce:t?.coerce||!1,...k(t)});ce=class t extends E{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==g.date){let i=this._getOrReturnCtx(e);return m(i,{code:d.invalid_type,expected:g.date,received:i.parsedType}),b}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return m(i,{code:d.invalid_date}),b}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),m(s,{code:d.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),m(s,{code:d.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):w.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:y.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:y.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}};ce.create=t=>new ce({checks:[],coerce:t?.coerce||!1,typeName:x.ZodDate,...k(t)});we=class extends E{_parse(e){if(this._getType(e)!==g.symbol){let r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:g.symbol,received:r.parsedType}),b}return O(e.data)}};we.create=t=>new we({typeName:x.ZodSymbol,...k(t)});le=class extends E{_parse(e){if(this._getType(e)!==g.undefined){let r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:g.undefined,received:r.parsedType}),b}return O(e.data)}};le.create=t=>new le({typeName:x.ZodUndefined,...k(t)});ue=class extends E{_parse(e){if(this._getType(e)!==g.null){let r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:g.null,received:r.parsedType}),b}return O(e.data)}};ue.create=t=>new ue({typeName:x.ZodNull,...k(t)});X=class extends E{constructor(){super(...arguments),this._any=!0}_parse(e){return O(e.data)}};X.create=t=>new X({typeName:x.ZodAny,...k(t)});K=class extends E{constructor(){super(...arguments),this._unknown=!0}_parse(e){return O(e.data)}};K.create=t=>new K({typeName:x.ZodUnknown,...k(t)});B=class extends E{_parse(e){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:g.never,received:n.parsedType}),b}};B.create=t=>new B({typeName:x.ZodNever,...k(t)});Se=class extends E{_parse(e){if(this._getType(e)!==g.undefined){let r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:g.void,received:r.parsedType}),b}return O(e.data)}};Se.create=t=>new Se({typeName:x.ZodVoid,...k(t)});W=class t extends E{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==g.array)return m(n,{code:d.invalid_type,expected:g.array,received:n.parsedType}),b;if(s.exactLength!==null){let o=n.data.length>s.exactLength.value,a=n.data.length<s.exactLength.value;(o||a)&&(m(n,{code:o?d.too_big:d.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&&(m(n,{code:d.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(m(n,{code:d.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>s.type._parseAsync(new F(n,o,n.path,a)))).then(o=>C.mergeArray(r,o));let i=[...n.data].map((o,a)=>s.type._parseSync(new F(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:y.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:y.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:y.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,...k(e)});$=class t extends E{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=w.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==g.object){let u=this._getOrReturnCtx(e);return m(u,{code:d.invalid_type,expected:g.object,received:u.parsedType}),b}let{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof B&&this._def.unknownKeys==="strip"))for(let u in s.data)o.includes(u)||a.push(u);let c=[];for(let u of o){let l=i[u],f=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new F(s,f,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof B){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")a.length>0&&(m(s,{code:d.unrecognized_keys,keys:a}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of a){let f=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new F(s,f,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let f=await l.key,h=await l.value;u.push({key:f,value:h,alwaysSet:l.alwaysSet})}return u}).then(u=>C.mergeObjectSync(r,u)):C.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return y.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:y.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 w.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 w.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return Ee(this)}partial(e){let n={};for(let r of w.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 w.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof L;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return Dn(w.objectKeys(this.shape))}};$.create=(t,e)=>new $({shape:()=>t,unknownKeys:"strip",catchall:B.create(),typeName:x.ZodObject,...k(e)});$.strictCreate=(t,e)=>new $({shape:()=>t,unknownKeys:"strict",catchall:B.create(),typeName:x.ZodObject,...k(e)});$.lazycreate=(t,e)=>new $({shape:t,unknownKeys:"strip",catchall:B.create(),typeName:x.ZodObject,...k(e)});de=class extends E{_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 I(a.ctx.common.issues));return m(n,{code:d.invalid_union,unionErrors:o}),b}if(n.common.async)return Promise.all(r.map(async i=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let c of r){let u={...n,common:{...n.common,issues:[]},parent:null},l=c._parseSync({data:n.data,path:n.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!i&&(i={result:l,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(c=>new I(c));return m(n,{code:d.invalid_union,unionErrors:a}),b}}get options(){return this._def.options}};de.create=(t,e)=>new de({options:t,typeName:x.ZodUnion,...k(e)});H=t=>t instanceof pe?H(t.schema):t instanceof j?H(t.innerType()):t instanceof me?[t.value]:t instanceof he?t.options:t instanceof ge?w.objectValues(t.enum):t instanceof ye?H(t._def.innerType):t instanceof le?[void 0]:t instanceof ue?[null]:t instanceof L?[void 0,...H(t.unwrap())]:t instanceof U?[null,...H(t.unwrap())]:t instanceof je||t instanceof ve?H(t.unwrap()):t instanceof _e?H(t._def.innerType):[],et=class t extends E{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==g.object)return m(n,{code:d.invalid_type,expected:g.object,received:n.parsedType}),b;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}):(m(n,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),b)}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=H(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,...k(r)})}};fe=class extends E{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(Xe(i)||Xe(o))return b;let a=Et(i.value,o.value);return a.valid?((Qe(i)||Qe(o))&&n.dirty(),{status:n.value,value:a.data}):(m(r,{code:d.invalid_intersection_types}),b)};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}))}};fe.create=(t,e,n)=>new fe({left:t,right:e,typeName:x.ZodIntersection,...k(n)});Z=class t extends E{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.array)return m(r,{code:d.invalid_type,expected:g.array,received:r.parsedType}),b;if(r.data.length<this._def.items.length)return m(r,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),b;!this._def.rest&&r.data.length>this._def.items.length&&(m(r,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...r.data].map((o,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new F(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,...k(e)})};tt=class t extends E{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!==g.object)return m(r,{code:d.invalid_type,expected:g.object,received:r.parsedType}),b;let s=[],i=this._def.keyType,o=this._def.valueType;for(let a in r.data)s.push({key:i._parse(new F(r,a,r.path,a)),value:o._parse(new F(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 E?new t({keyType:e,valueType:n,typeName:x.ZodRecord,...k(r)}):new t({keyType:J.create(),valueType:e,typeName:x.ZodRecord,...k(n)})}},Te=class extends E{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!==g.map)return m(r,{code:d.invalid_type,expected:g.map,received:r.parsedType}),b;let s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,c],u)=>({key:s._parse(new F(r,a,r.path,[u,"key"])),value:i._parse(new F(r,c,r.path,[u,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of o){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return b;(u.status==="dirty"||l.status==="dirty")&&n.dirty(),a.set(u.value,l.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let c of o){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return b;(u.status==="dirty"||l.status==="dirty")&&n.dirty(),a.set(u.value,l.value)}return{status:n.value,value:a}}}};Te.create=(t,e,n)=>new Te({valueType:e,keyType:t,typeName:x.ZodMap,...k(n)});Ae=class t extends E{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.set)return m(r,{code:d.invalid_type,expected:g.set,received:r.parsedType}),b;let s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(m(r,{code:d.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(m(r,{code:d.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());let i=this._def.valueType;function o(c){let u=new Set;for(let l of c){if(l.status==="aborted")return b;l.status==="dirty"&&n.dirty(),u.add(l.value)}return{status:n.value,value:u}}let a=[...r.data.values()].map((c,u)=>i._parse(new F(r,c,r.path,u)));return r.common.async?Promise.all(a).then(c=>o(c)):o(a)}min(e,n){return new t({...this._def,minSize:{value:e,message:y.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:y.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};Ae.create=(t,e)=>new Ae({valueType:t,minSize:null,maxSize:null,typeName:x.ZodSet,...k(e)});nt=class t extends E{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==g.function)return m(n,{code:d.invalid_type,expected:g.function,received:n.parsedType}),b;function r(a,c){return Fe({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,xe(),V].filter(u=>!!u),issueData:{code:d.invalid_arguments,argumentsError:c}})}function s(a,c){return Fe({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,xe(),V].filter(u=>!!u),issueData:{code:d.invalid_return_type,returnTypeError:c}})}let i={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof Q){let a=this;return O(async function(...c){let u=new I([]),l=await a._def.args.parseAsync(c,i).catch(_=>{throw u.addIssue(r(c,_)),u}),f=await Reflect.apply(o,this,l);return await a._def.returns._def.type.parseAsync(f,i).catch(_=>{throw u.addIssue(s(f,_)),u})})}else{let a=this;return O(function(...c){let u=a._def.args.safeParse(c,i);if(!u.success)throw new I([r(c,u.error)]);let l=Reflect.apply(o,this,u.data),f=a._def.returns.safeParse(l,i);if(!f.success)throw new I([s(l,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,...k(r)})}},pe=class extends E{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})}};pe.create=(t,e)=>new pe({getter:t,typeName:x.ZodLazy,...k(e)});me=class extends E{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return m(n,{received:n.data,code:d.invalid_literal,expected:this._def.value}),b}return{status:"valid",value:e.data}}get value(){return this._def.value}};me.create=(t,e)=>new me({value:t,typeName:x.ZodLiteral,...k(e)});he=class t extends E{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return m(n,{expected:w.joinValues(r),received:n.parsedType,code:d.invalid_type}),b}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 m(n,{received:n.data,code:d.invalid_enum_value,options:r}),b}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})}};he.create=Dn;ge=class extends E{_parse(e){let n=w.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==g.string&&r.parsedType!==g.number){let s=w.objectValues(n);return m(r,{expected:w.joinValues(s),received:r.parsedType,code:d.invalid_type}),b}if(this._cache||(this._cache=new Set(w.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=w.objectValues(n);return m(r,{received:r.data,code:d.invalid_enum_value,options:s}),b}return O(e.data)}get enum(){return this._def.values}};ge.create=(t,e)=>new ge({values:t,typeName:x.ZodNativeEnum,...k(e)});Q=class extends E{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==g.promise&&n.common.async===!1)return m(n,{code:d.invalid_type,expected:g.promise,received:n.parsedType}),b;let r=n.parsedType===g.promise?n.data:Promise.resolve(n.data);return O(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};Q.create=(t,e)=>new Q({type:t,typeName:x.ZodPromise,...k(e)});j=class extends E{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=>{m(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 b;let c=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return c.status==="aborted"?b:c.status==="dirty"?se(c.value):n.value==="dirty"?se(c.value):c});{if(n.value==="aborted")return b;let a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?b:a.status==="dirty"?se(a.value):n.value==="dirty"?se(a.value):a}}if(s.type==="refinement"){let o=a=>{let c=s.refinement(a,i);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?b:(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"?b:(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(!q(o))return b;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=>q(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:n.value,value:a})):b);w.assertNever(s)}};j.create=(t,e,n)=>new j({schema:t,typeName:x.ZodEffects,effect:e,...k(n)});j.createWithPreprocess=(t,e,n)=>new j({schema:e,effect:{type:"preprocess",transform:t},typeName:x.ZodEffects,...k(n)});L=class extends E{_parse(e){return this._getType(e)===g.undefined?O(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};L.create=(t,e)=>new L({innerType:t,typeName:x.ZodOptional,...k(e)});U=class extends E{_parse(e){return this._getType(e)===g.null?O(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};U.create=(t,e)=>new U({innerType:t,typeName:x.ZodNullable,...k(e)});ye=class extends E{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===g.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};ye.create=(t,e)=>new ye({innerType:t,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...k(e)});_e=class extends E{_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 ke(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new I(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new I(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};_e.create=(t,e)=>new _e({innerType:t,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...k(e)});Re=class extends E{_parse(e){if(this._getType(e)!==g.nan){let r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:g.nan,received:r.parsedType}),b}return{status:"valid",value:e.data}}};Re.create=t=>new Re({typeName:x.ZodNaN,...k(t)});Ui=Symbol("zod_brand"),je=class extends E{_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}},Be=class t extends E{_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"?b:i.status==="dirty"?(n.dirty(),se(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"?b: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})}},ve=class extends E{_parse(e){let n=this._def.innerType._parse(e),r=s=>(q(s)&&(s.value=Object.freeze(s.value)),s);return ke(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};ve.create=(t,e)=>new ve({innerType:t,typeName:x.ZodReadonly,...k(e)});Vi={object:$.lazycreate};(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(x||(x={}));Hi=(t,e={message:`Input not instance of ${t.name}`})=>In(n=>n instanceof t,e),$n=J.create,Nn=ie.create,Ki=Re.create,Wi=oe.create,Pn=ae.create,Gi=ce.create,Yi=we.create,qi=le.create,Ji=ue.create,Xi=X.create,Qi=K.create,eo=B.create,to=Se.create,no=W.create,ro=$.create,so=$.strictCreate,io=de.create,oo=et.create,ao=fe.create,co=Z.create,lo=tt.create,uo=Te.create,fo=Ae.create,po=nt.create,mo=pe.create,ho=me.create,go=he.create,yo=ge.create,_o=Q.create,vo=j.create,bo=L.create,xo=U.create,ko=j.createWithPreprocess,Eo=Be.create,wo=()=>$n().optional(),So=()=>Nn().optional(),To=()=>Pn().optional(),Ao={string:(t=>J.create({...t,coerce:!0})),number:(t=>ie.create({...t,coerce:!0})),boolean:(t=>ae.create({...t,coerce:!0})),bigint:(t=>oe.create({...t,coerce:!0})),date:(t=>ce.create({...t,coerce:!0}))},Ro=b});var p={};cn(p,{BRAND:()=>Ui,DIRTY:()=>se,EMPTY_PATH:()=>xi,INVALID:()=>b,NEVER:()=>Ro,OK:()=>O,ParseStatus:()=>C,Schema:()=>E,ZodAny:()=>X,ZodArray:()=>W,ZodBigInt:()=>oe,ZodBoolean:()=>ae,ZodBranded:()=>je,ZodCatch:()=>_e,ZodDate:()=>ce,ZodDefault:()=>ye,ZodDiscriminatedUnion:()=>et,ZodEffects:()=>j,ZodEnum:()=>he,ZodError:()=>I,ZodFirstPartyTypeKind:()=>x,ZodFunction:()=>nt,ZodIntersection:()=>fe,ZodIssueCode:()=>d,ZodLazy:()=>pe,ZodLiteral:()=>me,ZodMap:()=>Te,ZodNaN:()=>Re,ZodNativeEnum:()=>ge,ZodNever:()=>B,ZodNull:()=>ue,ZodNullable:()=>U,ZodNumber:()=>ie,ZodObject:()=>$,ZodOptional:()=>L,ZodParsedType:()=>g,ZodPipeline:()=>Be,ZodPromise:()=>Q,ZodReadonly:()=>ve,ZodRecord:()=>tt,ZodSchema:()=>E,ZodSet:()=>Ae,ZodString:()=>J,ZodSymbol:()=>we,ZodTransformer:()=>j,ZodTuple:()=>Z,ZodType:()=>E,ZodUndefined:()=>le,ZodUnion:()=>de,ZodUnknown:()=>K,ZodVoid:()=>Se,addIssueToContext:()=>m,any:()=>Xi,array:()=>no,bigint:()=>Wi,boolean:()=>Pn,coerce:()=>Ao,custom:()=>In,date:()=>Gi,datetimeRegex:()=>On,defaultErrorMap:()=>V,discriminatedUnion:()=>oo,effect:()=>vo,enum:()=>go,function:()=>po,getErrorMap:()=>xe,getParsedType:()=>z,instanceof:()=>Hi,intersection:()=>ao,isAborted:()=>Xe,isAsync:()=>ke,isDirty:()=>Qe,isValid:()=>q,late:()=>Vi,lazy:()=>mo,literal:()=>ho,makeIssue:()=>Fe,map:()=>uo,nan:()=>Ki,nativeEnum:()=>yo,never:()=>eo,null:()=>Ji,nullable:()=>xo,number:()=>Nn,object:()=>ro,objectUtil:()=>vt,oboolean:()=>To,onumber:()=>So,optional:()=>bo,ostring:()=>wo,pipeline:()=>Eo,preprocess:()=>ko,promise:()=>_o,quotelessJson:()=>_i,record:()=>lo,set:()=>fo,setErrorMap:()=>bi,strictObject:()=>so,string:()=>$n,symbol:()=>Yi,transformer:()=>vo,tuple:()=>co,undefined:()=>qi,union:()=>io,unknown:()=>Qi,util:()=>w,void:()=>to});var wt=v(()=>{Je();xt();wn();Le();Mn();qe()});var Ce=v(()=>{wt();wt()});var Oe,rt=v(()=>{"use strict";Ce();Oe=p.object({slug:p.string().min(1).max(64),description:p.string().max(255).optional(),match_command:p.string().min(1),priority:p.number().int().default(50),strip_ansi:p.boolean().default(!1),strip_lines_matching:p.array(p.string()).default([]),keep_failures:p.boolean().default(!1),fold_passing:p.boolean().default(!1),fold_passing_threshold:p.number().int().positive().max(1e3).optional(),mask_abs_paths:p.boolean().default(!1),preserve_exact:p.boolean().default(!1),truncate_lines_at:p.number().int().positive().max(1e4).optional(),max_lines:p.number().int().positive().max(1e5).optional(),scale_with_level:p.boolean().default(!0),transform:p.string().max(64).optional(),on_empty:p.string().max(255).optional()})});import{readdir as Co,readFile as Oo}from"node:fs/promises";import{join as jn,dirname as Do}from"node:path";import{fileURLToPath as Io}from"node:url";function No(){return process.env.TOKMIZER_DEV==="1"||process.env.TOKMIZER_DEV==="true"}async function Bn(){if(ee)return ee;if(!No())return!Fn&&process.env.TOKMIZER_DEBUG==="1"&&(process.stderr.write(`tokmizer: disk loader disabled (set TOKMIZER_DEV=1 to re-enable for local dev).
3
- `),Fn=!0),ee=new Map,ee;let t=new Map,e,n;try{e=(await import("smol-toml")).parse,n=(await Co(Ln)).filter(r=>r.endsWith(".toml"))}catch{return ee=t,ee}for(let r of n){let s=await Oo(jn(Ln,r),"utf8"),o=e(s).filters;if(o)for(let[a,c]of Object.entries(o)){let u=Oe.parse({slug:a,...c});t.set(a,{...u,matchRegex:new RegExp(u.match_command)})}}return ee=t,ee}var $o,Ln,ee,Fn,zn=v(()=>{"use strict";rt();$o=Do(Io(import.meta.url)),Ln=process.env.TOKMIZER_FILTERS_DIR||jn($o,"..","..","filters"),ee=null,Fn=!1});import{createHash as Po}from"node:crypto";function G(t){let e=Zn.get(t);return e||(e=Po("sha256").update(`tkr:${t}`).digest("hex").slice(0,16),Zn.set(t,e)),e}function st(t,e=!1){return e||!t||t.length===0?(Un??=new Set(Fo.map(G)),new Set(Un)):new Set(t.map(n=>jo.test(n)?n:G(n)))}var Mo,Lo,St,Fo,jo,Zn,Un,De=v(()=>{"use strict";Ce();Mo=p.enum(["normal","compact","minimal"]),Lo=p.enum(["off","light","balanced","max"]),St=p.object({enabled:p.boolean().default(!0),telemetryOptIn:p.boolean().default(!0),outputVerbosity:Mo.default("compact"),reducer:Lo.default("off"),filters:p.object({enableAll:p.boolean().default(!0),disabled:p.array(p.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})}),Fo=["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"],jo=/^[0-9a-f]{16}$/,Zn=new Map;Un=null});function zo(t){if(!t)return"*";let e=Vn.get(t);return e===void 0&&(e=[...t].join(","),Vn.set(t,e)),e}function it(t,e,n){let r=`${t}::${zo(n)}`,s=Ie.get(r);if(s!==void 0)return s;let i=null;for(let o of e)n&&!n.has(G(o.slug))||o.matchRegex.test(t)&&(!i||o.priority>i.priority)&&(i=o);if(Ie.size>=Bo){let o=Ie.keys().next().value;o&&Ie.delete(o)}return Ie.set(r,i),i}function Hn(){Ie.clear()}var Ie,Bo,Vn,Tt=v(()=>{"use strict";De();Ie=new Map,Bo=256,Vn=new WeakMap});function Kn(t){return t.replace(Zo,"").replace(Uo,"")}var Zo,Uo,Wn=v(()=>{"use strict";Zo=/\x1b\[[0-9;?]*[ -/]*[@-~]/g,Uo=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g});function Gn(t,e){return e.length===0?t:t.filter(n=>!e.some(r=>r.test(n)))}var Yn=v(()=>{"use strict"});function qn(t,e){return t.map(n=>n.length<=e?n:`${n.slice(0,e)}\u2026`)}var Jn=v(()=>{"use strict"});function ot(t){return`\u2026 (${t} more lines omitted)`}function Xn(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),ot(s.length),...t.slice(t.length-r)],dropped:s}}var Qn=v(()=>{"use strict"});function er(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)Vo.test(a)&&!ze.test(a)?(o.push(a),s+=1):(i(o),o=[],s=0,r.push(a));return i(o),r}var Vo,ze,tr=v(()=>{"use strict";Vo=/^\s*(?:[✓✔√]|ok )/,ze=/✕|✗|×|\bFAIL\b|\bERROR\b|\bFATAL\b|\bError|\berror|Expected|Received|\bfailed\b|^\s*Tests?:|^\s*Test Suites?:/});function nr(t){return t.map(e=>e.replace(Ho,n=>{let r=n.split("/").filter(Boolean);return r.length<=2?n:`\u2026/${r.slice(-2).join("/")}`}))}var Ho,rr=v(()=>{"use strict";Ho=/(?:\/[\w.@+-]+){3,}/g});function qo(t){let e=Go.exec(t);return!e||Yo.has(e[1])?!1:!/=>|\bfunction\b/.test(e[2])}function Xo(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 Qo(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==="&"))&&Xo(t,s+1,i)&&(r=i),s+=1;continue}i==="{"||i==="("||i==="["?n+=1:(i==="}"||i===")"||i==="]")&&(n-=1),s+=1}return n}function At(t){let e=new Array(t.length).fill(!1);for(let n=0;n<t.length;n+=1){let r=ea.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 at(t){let e=[],n=0;for(;n<t.length;){let r=t[n];if(Ko.test(r)&&Wo.test(r)||qo(r)||Jo.test(r)){let s={inBlockComment:!1,inTemplate:!1},i=0,o=n,a=!1;for(;o<t.length&&o-n<200;)if(i+=Qo(t[o],s),o+=1,i<=0&&!s.inTemplate&&!s.inBlockComment){a=!0;break}let c=o-n;if(a&&c>=3){let u=c-2,l=/^\s*/.exec(t[n+1]??"")?.[0]??" ";e.push(r),e.push(`${l}\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}function ir(t){let e=t.slice(0,4096);return!(!ta.test(e)||e.split(`
4
- `).length<6)}var Ko,Wo,Go,Yo,Jo,sr,ea,ta,ct=v(()=>{"use strict";Ko=/^(\s*)(?:export\s+)?(?:async\s+)?(?:function|interface|type|const|let|var|def|fn|impl|trait|struct|enum)\s+[\w$]+/,Wo=/\{\s*$/,Go=/^\s*(?:(?:public|private|protected|static|async|get|set|readonly|override)\s+)*([\w$]+)\s*\(([^)]*)\)\s*(?::\s*[^{]+)?\{\s*$/,Yo=new Set(["if","for","while","switch","catch","do","with","return","else","function","await","yield"]);Jo=/^\s*(?:if|for|while|switch|try|do)\b[^{}]*\{\s*$/;sr=/^\s*… \d+ lines? folded …$/,ea=/^\s*… (\d+) lines? folded …$/;ta=/\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 or(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(na.test(s)){n+=1;continue}r(),e.push(s)}return r(),e}function ar(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 cr(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 na,lr=v(()=>{"use strict";na=/\b(?:DEBUG|TRACE|INFO|VERBOSE)\b/});function N(t,e){ur.set(t,e)}function dr(t){return ur.get(t)}var ur,Y=v(()=>{"use strict";ur=new Map});function ia(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 oa(t){if(!ra.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 aa(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 ca(t){let e=[],n=[],r=!1;for(let h of t){if(/^total\s+\d+/.test(h))continue;if(sa.test(h.trim()))return t;let _=oa(h);_&&(r=!0,(_.isDir?e:n).push(_))}if(!r)return t;let s=(h,_)=>h.name.localeCompare(_.name);e.sort(s),n.sort((h,_)=>_.size-h.size||s(h,_));let i=[...e,...n],o=Math.min(40,Math.max(0,...i.map(h=>h.isDir?h.name.length+1:h.name.length))),a=[];for(let h of i){let _=h.isDir?`${h.name}/`:h.name,A=h.isDir?"":ia(h.size);a.push(A?`${_.padEnd(o)} ${A}`:_)}if(a.length>Rt){let h=a.length-Rt;a=[...a.slice(0,Rt),`\u2026 ${h} more lines omitted`]}let c=n.length===1?"file":"files",u=e.length===1?"dir":"dirs",l=aa(n),f=`${n.length} ${c}, ${e.length} ${u}`+(l?` (${l})`:"");return a.push(f),a}var ra,sa,Rt,fr=v(()=>{"use strict";Y();ra=/^[dbclps\-][rwxsStT\-]{9}[@.+]?(?:\s|$)/,sa=/^[./~][^\s]*:$/,Rt=1e3;N("smart-ls",ca)});var pr=v(()=>{"use strict";ct();Y();N("smart-read",t=>at(t))});function la(t){let e=t.filter(l=>l.trim()!=="");if(e.length===0||e.filter(l=>!/\s/.test(l.trim())).length<e.length*.6)return t;let r=new Map,s=[],i=0;for(let l of e){let f=l.trim();if(f.startsWith("find:")){s.push(f);continue}let h=f.replace(/^\.\//,"").replace(/\/+$/,""),_=h.lastIndexOf("/"),A=_>=0?h.slice(0,_):"",T=_>=0?h.slice(_+1):h;if(!T)continue;let P=r.get(A)??[];P.push(/\s/.test(T)?`"${T}"`:T),r.set(A,P),i+=1}if(i===0)return t;let o=new Set([""]);for(let l of r.keys()){if(l==="")continue;let f=l.split("/");for(let h=1;h<=f.length;h+=1)o.add(f.slice(0,h).join("/"))}let a=[...o].sort(),c=a.filter(l=>l!=="").length,u=[`${i}F ${c}D:`,""];for(let l of a){let f=l===""?0:l.split("/").length,h=l===""?".":l.slice(l.lastIndexOf("/")+1),_=r.get(l)??[],A=_.length?` ${_.join(" ")}`:"";u.push(`${" ".repeat(f)}${h}/${A}`)}if(u.length+s.length>mr){let l=Math.max(0,mr-s.length),f=u.length-l;return[...u.slice(0,l),`\u2026 ${f} more lines omitted`,...s]}return[...u,...s]}var mr,hr=v(()=>{"use strict";Y();mr=1e3;N("smart-find",la)});function _r(t){let e=t.trim();return e.length>gr?`${e.slice(0,gr)}\u2026`:e}function ha(t){let e=[],n="";for(let r of t){let s=n?`${n}, ${r}`:r;s.length>da&&n?(e.push(`${n},`),n=r):n=s}return n&&e.push(n),e}function ga(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}let h=fa.exec(f),_=h?null:pa.exec(f),A=h||_?null:ma.exec(f),T=(h??_??A)?.[1];if(!T)return t;let P=h?{line:h[2],content:h[3],context:!1}:_?{line:_[2],content:_[3],context:!0}:{line:"",content:A[2],context:!1},M=n.get(T)??[];M.push(P),n.set(T,M),P.context||(i+=1,r.set(T,(r.get(T)??0)+1)),o+=1,s=T}if(n.size===o)return t;let a=[...n.keys()].sort((f,h)=>{let _=yr.test(f)?1:0,A=yr.test(h)?1:0;return _-A||(f<h?-1:f>h?1:0)}),c=[];for(let f of a){c.push(`${f} (${r.get(f)??0}):`);for(let h of n.get(f))"separator"in h?c.push(" --"):h.line?c.push(` ${h.line}${h.context?"-":":"} ${_r(h.content)}`):c.push(` ${_r(h.content)}`)}let u=a.length>1&&c.length>ua?ha(a.map(f=>`${f} (${r.get(f)??0})`)):[],l=[`${i}m ${a.length}f:`,...u,"",...c];if(l.length>Ct){let f=l.length-Ct;return[...l.slice(0,Ct),`\u2026 ${f} more lines omitted`]}return l}var Ct,gr,ua,da,fa,pa,ma,yr,vr=v(()=>{"use strict";Y();Ct=1e3,gr=200,ua=60,da=190,fa=/^([^\s:]+):(\d+):(.*)$/,pa=/^([^:]+?)-(\d+)-(.*)$/,ma=/^([^\s:]+):(.*)$/,yr=/(?:^|\/)(?:__tests__|tests?|spec|fixtures?|__mocks__|__snapshots__)\/|\.(?:test|spec)\.[^/]+$/i;N("smart-grep",ga)});function va(t){if(!t.some(i=>br.test(i)))return t;let e=[],n=0,r=0,s=()=>{r>0&&e.push(` \u2026 ${r} ${r===1?"line":"lines"} folded \u2026`),r=0};for(let i of t){if(br.test(i)){s(),n=0,e.push(i);continue}if(ya.test(i)){n+=1,n<=_a?e.push(i):r+=1;continue}s(),e.push(i)}return s(),e}var br,ya,_a,xr=v(()=>{"use strict";Y();br=/^commit [0-9a-f]{7,40}\b/,ya=/^ {4}/,_a=2;N("smart-log",va)});var ba,xa,ka,kr=v(()=>{"use strict";Y();ba=/^[\s=]+$/,xa=/^\s*=+\s+(.*?)\s+=+\s*$/,ka=512;N("strip-banners",t=>{let e=[];for(let n of t){if(ba.test(n))continue;let r=n.length<=ka?xa.exec(n):null;e.push(r?r[1]:n)}return e})});function Ea(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}var Er=v(()=>{"use strict";Y();N("squeeze-output",Ea)});function wa(t){return t==="compact"?.6:t==="minimal"?.3:1}function Ta(t){let e=wr.get(t);if(e)return e;let n=t.strip_lines_matching.map(s=>new RegExp(s)),r={def:t,stripRegexes:n};return wr.set(t,r),r}function Sr(t,e,n={}){return Ot(t,e,n).text}function Ot(t,e,n={}){let r=Ta(e),s=t;e.strip_ansi&&(s=Kn(s));let i=s.endsWith(`
5
- `),o=(i?s.slice(0,-1):s).split(`
6
- `);r.stripRegexes.length&&(o=e.keep_failures?o.filter(f=>ze.test(f)||!r.stripRegexes.some(h=>h.test(f))):Gn(o,r.stripRegexes));let a=n.verbosity??"normal";if(a!=="normal"&&!e.preserve_exact&&(o=ar(o),o=cr(o)),a==="minimal"&&!e.preserve_exact&&(o=or(o)),!e.preserve_exact&&(n.smartCode||n.smartCode===void 0&&a!=="normal"&&ir(s))&&(o=at(o)),e.transform){let f=dr(e.transform);f&&(o=f(o))}let c=e.slug==="read-tool";if(!c){let f=At(o);f.some(Boolean)&&(o=o.filter((h,_)=>!f[_]))}e.mask_abs_paths&&(o=nr(o)),e.fold_passing&&(o=er(o,e.fold_passing_threshold??5)),e.truncate_lines_at&&(o=qn(o,e.truncate_lines_at));let u=null;if(e.max_lines){let f=e.scale_with_level?wa(n.verbosity):1,h=Math.min(e.max_lines,Math.max(Sa,Math.round(e.max_lines*f))),_=c?At(o):null,A=_?_.filter(T=>!T).length:o.length;if(A>h){let T=h;if(_){let M=0;for(T=0;T<o.length&&M<h;)_[T]||(M+=1),T+=1}let P=A-h;if(e.keep_failures){let M=o.slice(T),te=M.filter(Ne=>!ze.test(Ne));u=te.length>0?te.join(`
7
- `):null,o=[...o.slice(0,T),ot(P),...M.filter(Ne=>ze.test(Ne))]}else if(c)u=o.slice(T).join(`
8
- `),o=[...o.slice(0,T),ot(P)];else{let{kept:M,dropped:te}=Xn(o,h);u=te.length>0?te.join(`
9
- `):null,o=M}}}let l=o.join(`
10
- `);return i&&l.length>0&&(l+=`
11
- `),l.trim().length===0&&e.on_empty&&(l=e.on_empty),{text:l,droppedTail:u}}var Sa,wr,Tr=v(()=>{"use strict";Wn();Yn();Jn();Qn();tr();rr();ct();lr();Y();fr();pr();hr();vr();xr();kr();Er();Sa=20,wr=new WeakMap});function Ar(t){if(!t)return!1;let e=t.split(`
12
- `),n=e.length<=60?t:[...e.slice(0,30),...e.slice(-30)].join(`
13
- `),r=n.length<=32768*2?[n]:[n.slice(0,32768),n.slice(-32768)];for(let s of Aa)for(let i of r)if(s.test(i))return!0;return!1}var Aa,Rr=v(()=>{"use strict";Aa=[/\bERROR\b/,/\bFAIL\b/,/\bFAILED\b/,/\bFATAL\b/,/^Traceback /m,/^Error: /m,/^\s+at .*\(.*:\d+:\d+\)/m,/panic:/,/SyntaxError:/,/TypeError:/,/ReferenceError:/,/thread '.*' panicked/]});function lt(t){let e=t.trim(),n=e.split(/\s+/),r=0;for(;r<n.length;){let a=n[r];if(Ca.test(a)){r++;continue}if(Ra.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}function Cr(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 Da(t){let e=Cr(t,!1);for(let n=e.length-1;n>=0;n--){let r=e[n].trim();if(r)return r}return t.trim()}function Ia(t){let e=Cr(t,!0).map(n=>n.trim()).filter(Boolean);if(e.length===0)return null;for(let n of e.slice(0,-1)){let r=lt(n).split(/\s+/)[0]??"";if(!Oa.has(r))return null}return Da(e[e.length-1])}function Or(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 Dr(t){let e=Dt.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=Ia(n),s=r?lt(r):null;return s&&s!==t?[s,t]:[t]}var Ra,Ca,Dt,Oa,Ir=v(()=>{"use strict";Ra=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),Ca=/^[A-Za-z_][A-Za-z0-9_]*=/,Dt=/^([a-z]+)-tool(?::\s|$)/;Oa=new Set(["cd","export","source","set","unset","mkdir","true",":","pushd","popd","alias","ulimit","umask","echo","printf","sleep","touch","rm","cp","mv","chmod","ln"])});function It(t){$r=t}async function $a(t,e){let n=await Bn();return it(t,n.values(),e)}async function Nr(t,e,n,r={}){let s=Buffer.byteLength(e,"utf8"),{exitCode:i,...o}=r,a=lt(Or(t.startsWith("bash-tool: ")?t.slice(11):t)),c=i!=null&&i!==0&&!(i===1&&Na.test(a)),u=i==null&&Ar(e),l=$r??$a,f=null;for(let T of Dr(t))if(f=await l(T,n),f)break;if(!f&&s>=Pa&&!Dt.test(t)&&(f=await l(`bash-tool: ${t}`,n)),!f||c&&f.preserve_exact)return{output:e,filterId:null,rawBytes:s,filteredBytes:s,debugBypass:c||u};if(c){let T={...f,keep_failures:!0,transform:void 0,max_lines:void 0,truncate_lines_at:void 0},P=Sr(e,T,{verbosity:"normal",smartCode:!1});return{output:P,filterId:f.slug,rawBytes:s,filteredBytes:Buffer.byteLength(P,"utf8"),debugBypass:!0}}let h=u&&!f.preserve_exact?{...f,keep_failures:!0}:f,{text:_,droppedTail:A}=Ot(e,h,o);return{output:_,filterId:f.slug,rawBytes:s,filteredBytes:Buffer.byteLength(_,"utf8"),debugBypass:!1,droppedTail:A}}var $r,Na,Pa,$t=v(()=>{"use strict";zn();Tt();Tr();Rr();Ir();$r=null;Na=/^(?:grep|rg|find|eslint|ruff|flake8|mypy|prettier|biome|black|stylelint)(?:\s|$)|^git\s+(?:diff|grep)\b/,Pa=2048});import{chmod as Ma,mkdir as La,readFile as lf,writeFile as Fa,stat as uf,readdir as df,rm as ja,rename as Ba}from"node:fs/promises";import{createHash as Pr}from"node:crypto";function Ua(t,e){let n=Number(process.env[t]);return Number.isFinite(n)&&n>0?n:e}async function Mr(t,e){if(!Za.test(t)||Buffer.byteLength(e,"utf8")>Ua("TOKMIZER_CCR_ENTRY_MAX_BYTES",za))return!1;let n=ln(t),r=`${n}.tmp-${process.pid}-${process.hrtime.bigint()}`;try{return await La(yt(),{recursive:!0}),await Fa(r,e,{mode:384}),await Ma(r,384),await Ba(r,n),!0}catch{try{await ja(r)}catch{}return!1}}async function Lr(t,e){let n=process.env.TOKMIZER_CCR_DISABLED;if(n==="1"||n==="true"||!t)return e;let r=Pr("sha256").update(t).digest("hex").slice(0,16),s=`
14
- [tkr restore ${r}]`;return Buffer.byteLength(t,"utf8")<=Buffer.byteLength(s,"utf8")||!await Mr(r,t)?e:`${e}${s}`}async function Fr(t,e){let n=process.env.TOKMIZER_CCR_DISABLED;if(n==="1"||n==="true"||!t)return e;let r=Pr("sha256").update(t).digest("hex").slice(0,16);return await Mr(r,t)?`${e}
15
- [tkr restore ${r}]`:e}var mf,hf,za,Za,jr=v(()=>{"use strict";D();mf=10080*60*1e3,hf=100*1024*1024,za=2*1024*1024,Za=/^[0-9a-f]{8,64}$/i});function Va(){let t=Number(process.env.TOKMIZER_OFFLINE_GRACE_MS);return Number.isFinite(t)&&t>0?t:6048e5}function Br(t,e=Date.now()){let n=t.lastHeartbeatOkAt;if(typeof n=="number"&&e-n>Va())return!0;if(t.subEndsAt){let r=Date.parse(t.subEndsAt);if(Number.isFinite(r)&&e>r)return!0}return!1}function zr(t,e=Date.now()){return t.plan}var Zr=v(()=>{"use strict"});function Ze(t){let e=t;for(let[n,r]of Ha)e=e.replace(n,r);return e}var Ha,Nt=v(()=>{"use strict";Ha=[[/(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]"]]});import{createHash as bf,randomUUID as Ka}from"node:crypto";import{readFile as Ur,writeFile as Vr,mkdir as Wa}from"node:fs/promises";async function Pt(){try{let n=(await Ur(Pe(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(n))return n}catch{}await Wa(S(),{recursive:!0});let t=Ka();try{return await Vr(Pe(),t,{mode:384,flag:"wx"}),t}catch{try{let e=(await Ur(Pe(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(e))return e}catch{}return await Vr(Pe(),t,{mode:384}),t}}var Mt=v(()=>{"use strict";D()});import{createRequire as Ga}from"node:module";function qa(){for(let t of["../package.json","../../package.json"])try{let e=Ya(t).version;if(typeof e=="string"&&e)return e}catch{}return"0.0.0"}var Ya,Lt,Ft=v(()=>{"use strict";Ya=Ga(import.meta.url);Lt=qa()});var Hr,Kr=v(()=>{"use strict";Hr=`-----BEGIN PUBLIC KEY-----
2
+ var oi=Object.defineProperty;var _=(t,e,n)=>()=>{if(n)throw n[0];try{return t&&(e=t(t=0)),e}catch(r){throw n=[r],r}};var wt=(t,e)=>{for(var n in e)oi(t,n,{get:e[n],enumerable:!0})};import ai from"node:os";import{join as rt}from"node:path";function A(){return process.env.TOKMIZER_HOME||rt(ai.homedir(),".tokmizer")}function Ze(){return rt(A(),"install-id")}function St(){return rt(A(),"content-cache")}function kn(t){return rt(St(),t)}var N=_(()=>{"use strict"});import{join as ui}from"node:path";import{mkdir as Du,readFile as di,writeFile as $u,unlink as Nu,rename as Pu}from"node:fs/promises";function pi(){try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t&&t.length>0?t:"Etc/UTC"}catch{return"Etc/UTC"}}function mi(t){return t?.dir??A()}async function Ue(t){let e=mi(t);try{let n=await di(ui(e,fi),"utf8"),r=JSON.parse(n);return{...r,lastSettingsRevision:r.lastSettingsRevision??0,timeZone:r.timeZone??pi(),bonusActive:r.bonusActive??!1,...r.bonusResetAt!==void 0?{bonusResetAt:r.bonusResetAt}:{}}}catch{return null}}var fi,st=_(()=>{"use strict";N();fi="state.json"});import{readFileSync as Bi}from"node:fs";import{join as ji}from"node:path";function ee(){try{return Bi(ji(A(),"yolo-mode"),"utf8")==="on"}catch{return!1}}var At=_(()=>{"use strict";N()});var T,Rt,y,H,Ve=_(()=>{(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})(T||(T={}));(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Rt||(Rt={}));y=T.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),H=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,zi,P,it=_(()=>{Ve();p=T.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"]),zi=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),P=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){let n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,c=0;for(;c<o.path.length;){let l=o.path[c];c===o.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(n(o))):a[l]=a[l]||{_errors:[]},a=a[l],c++}}};return s(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,T.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()}};P.create=t=>new P(t)});var Zi,Y,Ct=_(()=>{it();Ve();Zi=(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,T.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:n=`Unrecognized key(s) in object: ${T.joinValues(t.keys,", ")}`;break;case p.invalid_union:n="Invalid input";break;case p.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${T.joinValues(t.options)}`;break;case p.invalid_enum_value:n=`Invalid enum value. Expected ${T.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}"`:T.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,T.assertNever(t)}return{message:n}},Y=Zi});function Ui(t){Mn=t}function Re(){return Mn}var Mn,ot=_(()=>{Ct();Mn=Y});function h(t,e){let n=Re(),r=He({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===Y?void 0:Y].filter(s=>!!s)});t.common.issues.push(r)}var He,Vi,D,x,ue,$,at,ct,te,Ce,It=_(()=>{ot();Ct();He=t=>{let{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="",c=r.filter(l=>!!l).slice().reverse();for(let l of c)a=l(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}},Vi=[];D=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 x;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 x;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}}},x=Object.freeze({status:"aborted"}),ue=t=>({status:"dirty",value:t}),$=t=>({status:"valid",value:t}),at=t=>t.status==="aborted",ct=t=>t.status==="dirty",te=t=>t.status==="valid",Ce=t=>typeof Promise<"u"&&t instanceof Promise});var Ln=_(()=>{});var b,Fn=_(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(b||(b={}))});function w(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{let{message:c}=t;return o.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:c??n??a.defaultError}},description:s}}function Zn(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 ao(t){return new RegExp(`^${Zn(t)}$`)}function Un(t){let e=`${zn}T${Zn(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 co(t,e){return!!((e==="v4"||!e)&&eo.test(t)||(e==="v6"||!e)&&no.test(t))}function lo(t,e){if(!Ji.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 uo(t,e){return!!((e==="v4"||!e)&&to.test(t)||(e==="v6"||!e)&&ro.test(t))}function fo(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}function Ie(t){if(t instanceof M){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=F.create(Ie(r))}return new M({...t._def,shape:()=>e})}else return t instanceof X?new X({...t._def,type:Ie(t.element)}):t instanceof F?F.create(Ie(t.unwrap())):t instanceof G?G.create(Ie(t.unwrap())):t instanceof K?K.create(t.items.map(e=>Ie(e))):t}function Dt(t,e){let n=H(t),r=H(e);if(t===e)return{valid:!0,data:t};if(n===y.object&&r===y.object){let s=T.objectKeys(e),i=T.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(let a of i){let c=Dt(t[a],e[a]);if(!c.valid)return{valid:!1};o[a]=c.data}return{valid:!0,data:o}}else if(n===y.array&&r===y.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let o=t[i],a=e[i],c=Dt(o,a);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return n===y.date&&r===y.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function Vn(t,e){return new xe({values:t,typeName:k.ZodEnum,...w(e)})}function jn(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Hn(t,e={},n){return t?re.create().superRefine((r,s)=>{let i=t(r);if(i instanceof Promise)return i.then(o=>{if(!o){let a=jn(e,r),c=a.fatal??n??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!i){let o=jn(e,r),a=o.fatal??n??!0;s.addIssue({code:"custom",...o,fatal:a})}}):re.create()}var B,Bn,S,Hi,Ki,Gi,Wi,Yi,Ji,qi,Xi,Qi,Ot,eo,to,no,ro,so,io,zn,oo,ne,de,fe,pe,me,Oe,he,ge,re,q,Z,De,X,M,ye,J,lt,_e,K,ut,$e,Ne,dt,be,ve,xe,ke,se,j,F,G,Ee,we,Pe,po,Ke,Ge,Se,mo,k,ho,Kn,Gn,go,yo,Wn,_o,bo,vo,xo,ko,Eo,wo,So,To,Ao,Ro,Co,Io,Oo,Do,$o,No,Po,Mo,Lo,Fo,Bo,jo,zo,Zo,Uo,Vo,Ho,Ko,Go,Wo,Yo,Jo,qo,Yn=_(()=>{it();ot();Fn();It();Ve();B=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}},Bn=(t,e)=>{if(te(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 P(t.common.issues);return this._error=n,this._error}}};S=class{get description(){return this._def.description}_getType(e){return H(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:H(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new D,ctx:{common:e.parent.common,data:e.data,parsedType:H(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(Ce(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:H(e)},s=this._parseSync({data:e,path:r.path,parent:r});return Bn(r,s)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:H(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return te(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=>te(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:H(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(Ce(s)?s:Promise.resolve(s));return Bn(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(c=>c?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new j({schema:this,typeName:k.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 F.create(this,this._def)}nullable(){return G.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return X.create(this)}promise(){return se.create(this,this._def)}or(e){return ye.create([this,e],this._def)}and(e){return _e.create(this,e,this._def)}transform(e){return new j({...w(this._def),schema:this,typeName:k.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new Ee({...w(this._def),innerType:this,defaultValue:n,typeName:k.ZodDefault})}brand(){return new Ke({typeName:k.ZodBranded,type:this,...w(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new we({...w(this._def),innerType:this,catchValue:n,typeName:k.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Ge.create(this,e)}readonly(){return Se.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Hi=/^c[^\s-]{8,}$/i,Ki=/^[0-9a-z]+$/,Gi=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Wi=/^[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,Yi=/^[a-z0-9_-]{21}$/i,Ji=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,qi=/^[-+]?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)?)??$/,Xi=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Qi="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",eo=/^(?:(?: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])$/,to=/^(?:(?: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])$/,no=/^(([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]))$/,ro=/^(([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])$/,so=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,io=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,zn="((\\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])))",oo=new RegExp(`^${zn}$`);ne=class t extends S{_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}),x}let r=new D,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")Xi.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")Ot||(Ot=new RegExp(Qi,"u")),Ot.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")Wi.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")Yi.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")Hi.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")Ki.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")Gi.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"?Un(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"?oo.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:p.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?ao(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"?qi.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"duration",code:p.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?co(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"?lo(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"?uo(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"?so.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64",code:p.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?io.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64url",code:p.invalid_string,message:i.message}),r.dirty()):T.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}};ne.create=t=>new ne({checks:[],typeName:k.ZodString,coerce:t?.coerce??!1,...w(t)});de=class t extends S{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}),x}let r,s=new D;for(let i of this._def.checks)i.kind==="int"?T.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"?fo(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()):T.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"&&T.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)}};de.create=t=>new de({checks:[],typeName:k.ZodNumber,coerce:t?.coerce||!1,...w(t)});fe=class t extends S{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 D;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()):T.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}),x}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}};fe.create=t=>new fe({checks:[],typeName:k.ZodBigInt,coerce:t?.coerce??!1,...w(t)});pe=class extends S{_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}),x}return $(e.data)}};pe.create=t=>new pe({typeName:k.ZodBoolean,coerce:t?.coerce||!1,...w(t)});me=class t extends S{_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}),x}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return h(i,{code:p.invalid_date}),x}let r=new D,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()):T.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}};me.create=t=>new me({checks:[],coerce:t?.coerce||!1,typeName:k.ZodDate,...w(t)});Oe=class extends S{_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}),x}return $(e.data)}};Oe.create=t=>new Oe({typeName:k.ZodSymbol,...w(t)});he=class extends S{_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}),x}return $(e.data)}};he.create=t=>new he({typeName:k.ZodUndefined,...w(t)});ge=class extends S{_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}),x}return $(e.data)}};ge.create=t=>new ge({typeName:k.ZodNull,...w(t)});re=class extends S{constructor(){super(...arguments),this._any=!0}_parse(e){return $(e.data)}};re.create=t=>new re({typeName:k.ZodAny,...w(t)});q=class extends S{constructor(){super(...arguments),this._unknown=!0}_parse(e){return $(e.data)}};q.create=t=>new q({typeName:k.ZodUnknown,...w(t)});Z=class extends S{_parse(e){let n=this._getOrReturnCtx(e);return h(n,{code:p.invalid_type,expected:y.never,received:n.parsedType}),x}};Z.create=t=>new Z({typeName:k.ZodNever,...w(t)});De=class extends S{_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}),x}return $(e.data)}};De.create=t=>new De({typeName:k.ZodVoid,...w(t)});X=class t extends S{_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}),x;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 B(n,o,n.path,a)))).then(o=>D.mergeArray(r,o));let i=[...n.data].map((o,a)=>s.type._parseSync(new B(n,o,n.path,a)));return D.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)}};X.create=(t,e)=>new X({type:t,minLength:null,maxLength:null,exactLength:null,typeName:k.ZodArray,...w(e)});M=class t extends S{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=T.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==y.object){let l=this._getOrReturnCtx(e);return h(l,{code:p.invalid_type,expected:y.object,received:l.parsedType}),x}let{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Z&&this._def.unknownKeys==="strip"))for(let l in s.data)o.includes(l)||a.push(l);let c=[];for(let l of o){let u=i[l],f=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new B(s,f,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof Z){let l=this._def.unknownKeys;if(l==="passthrough")for(let u of a)c.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(l==="strict")a.length>0&&(h(s,{code:p.unrecognized_keys,keys:a}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let u of a){let f=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new B(s,f,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let u of c){let f=await u.key,d=await u.value;l.push({key:f,value:d,alwaysSet:u.alwaysSet})}return l}).then(l=>D.mergeObjectSync(r,l)):D.mergeObjectSync(r,c)}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:k.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 T.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 T.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return Ie(this)}partial(e){let n={};for(let r of T.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 T.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof F;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return Vn(T.objectKeys(this.shape))}};M.create=(t,e)=>new M({shape:()=>t,unknownKeys:"strip",catchall:Z.create(),typeName:k.ZodObject,...w(e)});M.strictCreate=(t,e)=>new M({shape:()=>t,unknownKeys:"strict",catchall:Z.create(),typeName:k.ZodObject,...w(e)});M.lazycreate=(t,e)=>new M({shape:t,unknownKeys:"strip",catchall:Z.create(),typeName:k.ZodObject,...w(e)});ye=class extends S{_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 P(a.ctx.common.issues));return h(n,{code:p.invalid_union,unionErrors:o}),x}if(n.common.async)return Promise.all(r.map(async i=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let c of r){let l={...n,common:{...n.common,issues:[]},parent:null},u=c._parseSync({data:n.data,path:n.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(c=>new P(c));return h(n,{code:p.invalid_union,unionErrors:a}),x}}get options(){return this._def.options}};ye.create=(t,e)=>new ye({options:t,typeName:k.ZodUnion,...w(e)});J=t=>t instanceof be?J(t.schema):t instanceof j?J(t.innerType()):t instanceof ve?[t.value]:t instanceof xe?t.options:t instanceof ke?T.objectValues(t.enum):t instanceof Ee?J(t._def.innerType):t instanceof he?[void 0]:t instanceof ge?[null]:t instanceof F?[void 0,...J(t.unwrap())]:t instanceof G?[null,...J(t.unwrap())]:t instanceof Ke||t instanceof Se?J(t.unwrap()):t instanceof we?J(t._def.innerType):[],lt=class t extends S{_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}),x;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]}),x)}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=J(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:k.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...w(r)})}};_e=class extends S{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(at(i)||at(o))return x;let a=Dt(i.value,o.value);return a.valid?((ct(i)||ct(o))&&n.dirty(),{status:n.value,value:a.data}):(h(r,{code:p.invalid_intersection_types}),x)};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}))}};_e.create=(t,e,n)=>new _e({left:t,right:e,typeName:k.ZodIntersection,...w(n)});K=class t extends S{_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}),x;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"}),x;!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 c=this._def.items[a]||this._def.rest;return c?c._parse(new B(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>D.mergeArray(n,o)):D.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};K.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new K({items:t,typeName:k.ZodTuple,rest:null,...w(e)})};ut=class t extends S{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}),x;let s=[],i=this._def.keyType,o=this._def.valueType;for(let a in r.data)s.push({key:i._parse(new B(r,a,r.path,a)),value:o._parse(new B(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?D.mergeObjectAsync(n,s):D.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof S?new t({keyType:e,valueType:n,typeName:k.ZodRecord,...w(r)}):new t({keyType:ne.create(),valueType:e,typeName:k.ZodRecord,...w(n)})}},$e=class extends S{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}),x;let s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,c],l)=>({key:s._parse(new B(r,a,r.path,[l,"key"])),value:i._parse(new B(r,c,r.path,[l,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of o){let l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return x;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(l.value,u.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let c of o){let l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return x;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(l.value,u.value)}return{status:n.value,value:a}}}};$e.create=(t,e,n)=>new $e({valueType:e,keyType:t,typeName:k.ZodMap,...w(n)});Ne=class t extends S{_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}),x;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(c){let l=new Set;for(let u of c){if(u.status==="aborted")return x;u.status==="dirty"&&n.dirty(),l.add(u.value)}return{status:n.value,value:l}}let a=[...r.data.values()].map((c,l)=>i._parse(new B(r,c,r.path,l)));return r.common.async?Promise.all(a).then(c=>o(c)):o(a)}min(e,n){return new t({...this._def,minSize:{value:e,message: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)}};Ne.create=(t,e)=>new Ne({valueType:t,minSize:null,maxSize:null,typeName:k.ZodSet,...w(e)});dt=class t extends S{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}),x;function r(a,c){return He({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Re(),Y].filter(l=>!!l),issueData:{code:p.invalid_arguments,argumentsError:c}})}function s(a,c){return He({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Re(),Y].filter(l=>!!l),issueData:{code:p.invalid_return_type,returnTypeError:c}})}let i={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof se){let a=this;return $(async function(...c){let l=new P([]),u=await a._def.args.parseAsync(c,i).catch(g=>{throw l.addIssue(r(c,g)),l}),f=await Reflect.apply(o,this,u);return await a._def.returns._def.type.parseAsync(f,i).catch(g=>{throw l.addIssue(s(f,g)),l})})}else{let a=this;return $(function(...c){let l=a._def.args.safeParse(c,i);if(!l.success)throw new P([r(c,l.error)]);let u=Reflect.apply(o,this,l.data),f=a._def.returns.safeParse(u,i);if(!f.success)throw new P([s(u,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:K.create(e).rest(q.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||K.create([]).rest(q.create()),returns:n||q.create(),typeName:k.ZodFunction,...w(r)})}},be=class extends S{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})}};be.create=(t,e)=>new be({getter:t,typeName:k.ZodLazy,...w(e)});ve=class extends S{_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}),x}return{status:"valid",value:e.data}}get value(){return this._def.value}};ve.create=(t,e)=>new ve({value:t,typeName:k.ZodLiteral,...w(e)});xe=class t extends S{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return h(n,{expected:T.joinValues(r),received:n.parsedType,code:p.invalid_type}),x}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}),x}return $(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})}};xe.create=Vn;ke=class extends S{_parse(e){let n=T.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==y.string&&r.parsedType!==y.number){let s=T.objectValues(n);return h(r,{expected:T.joinValues(s),received:r.parsedType,code:p.invalid_type}),x}if(this._cache||(this._cache=new Set(T.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=T.objectValues(n);return h(r,{received:r.data,code:p.invalid_enum_value,options:s}),x}return $(e.data)}get enum(){return this._def.values}};ke.create=(t,e)=>new ke({values:t,typeName:k.ZodNativeEnum,...w(e)});se=class extends S{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}),x;let r=n.parsedType===y.promise?n.data:Promise.resolve(n.data);return $(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};se.create=(t,e)=>new se({type:t,typeName:k.ZodPromise,...w(e)});j=class extends S{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===k.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 x;let c=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return c.status==="aborted"?x:c.status==="dirty"?ue(c.value):n.value==="dirty"?ue(c.value):c});{if(n.value==="aborted")return x;let a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?x:a.status==="dirty"?ue(a.value):n.value==="dirty"?ue(a.value):a}}if(s.type==="refinement"){let o=a=>{let c=s.refinement(a,i);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?x:(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"?x:(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(!te(o))return x;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=>te(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:n.value,value:a})):x);T.assertNever(s)}};j.create=(t,e,n)=>new j({schema:t,typeName:k.ZodEffects,effect:e,...w(n)});j.createWithPreprocess=(t,e,n)=>new j({schema:e,effect:{type:"preprocess",transform:t},typeName:k.ZodEffects,...w(n)});F=class extends S{_parse(e){return this._getType(e)===y.undefined?$(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};F.create=(t,e)=>new F({innerType:t,typeName:k.ZodOptional,...w(e)});G=class extends S{_parse(e){return this._getType(e)===y.null?$(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};G.create=(t,e)=>new G({innerType:t,typeName:k.ZodNullable,...w(e)});Ee=class extends S{_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}};Ee.create=(t,e)=>new Ee({innerType:t,typeName:k.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...w(e)});we=class extends S{_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 Ce(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new P(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new P(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};we.create=(t,e)=>new we({innerType:t,typeName:k.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...w(e)});Pe=class extends S{_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}),x}return{status:"valid",value:e.data}}};Pe.create=t=>new Pe({typeName:k.ZodNaN,...w(t)});po=Symbol("zod_brand"),Ke=class extends S{_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}},Ge=class t extends S{_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"?x:i.status==="dirty"?(n.dirty(),ue(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"?x: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:k.ZodPipeline})}},Se=class extends S{_parse(e){let n=this._def.innerType._parse(e),r=s=>(te(s)&&(s.value=Object.freeze(s.value)),s);return Ce(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};Se.create=(t,e)=>new Se({innerType:t,typeName:k.ZodReadonly,...w(e)});mo={object:M.lazycreate};(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(k||(k={}));ho=(t,e={message:`Input not instance of ${t.name}`})=>Hn(n=>n instanceof t,e),Kn=ne.create,Gn=de.create,go=Pe.create,yo=fe.create,Wn=pe.create,_o=me.create,bo=Oe.create,vo=he.create,xo=ge.create,ko=re.create,Eo=q.create,wo=Z.create,So=De.create,To=X.create,Ao=M.create,Ro=M.strictCreate,Co=ye.create,Io=lt.create,Oo=_e.create,Do=K.create,$o=ut.create,No=$e.create,Po=Ne.create,Mo=dt.create,Lo=be.create,Fo=ve.create,Bo=xe.create,jo=ke.create,zo=se.create,Zo=j.create,Uo=F.create,Vo=G.create,Ho=j.createWithPreprocess,Ko=Ge.create,Go=()=>Kn().optional(),Wo=()=>Gn().optional(),Yo=()=>Wn().optional(),Jo={string:(t=>ne.create({...t,coerce:!0})),number:(t=>de.create({...t,coerce:!0})),boolean:(t=>pe.create({...t,coerce:!0})),bigint:(t=>fe.create({...t,coerce:!0})),date:(t=>me.create({...t,coerce:!0}))},qo=x});var m={};wt(m,{BRAND:()=>po,DIRTY:()=>ue,EMPTY_PATH:()=>Vi,INVALID:()=>x,NEVER:()=>qo,OK:()=>$,ParseStatus:()=>D,Schema:()=>S,ZodAny:()=>re,ZodArray:()=>X,ZodBigInt:()=>fe,ZodBoolean:()=>pe,ZodBranded:()=>Ke,ZodCatch:()=>we,ZodDate:()=>me,ZodDefault:()=>Ee,ZodDiscriminatedUnion:()=>lt,ZodEffects:()=>j,ZodEnum:()=>xe,ZodError:()=>P,ZodFirstPartyTypeKind:()=>k,ZodFunction:()=>dt,ZodIntersection:()=>_e,ZodIssueCode:()=>p,ZodLazy:()=>be,ZodLiteral:()=>ve,ZodMap:()=>$e,ZodNaN:()=>Pe,ZodNativeEnum:()=>ke,ZodNever:()=>Z,ZodNull:()=>ge,ZodNullable:()=>G,ZodNumber:()=>de,ZodObject:()=>M,ZodOptional:()=>F,ZodParsedType:()=>y,ZodPipeline:()=>Ge,ZodPromise:()=>se,ZodReadonly:()=>Se,ZodRecord:()=>ut,ZodSchema:()=>S,ZodSet:()=>Ne,ZodString:()=>ne,ZodSymbol:()=>Oe,ZodTransformer:()=>j,ZodTuple:()=>K,ZodType:()=>S,ZodUndefined:()=>he,ZodUnion:()=>ye,ZodUnknown:()=>q,ZodVoid:()=>De,addIssueToContext:()=>h,any:()=>ko,array:()=>To,bigint:()=>yo,boolean:()=>Wn,coerce:()=>Jo,custom:()=>Hn,date:()=>_o,datetimeRegex:()=>Un,defaultErrorMap:()=>Y,discriminatedUnion:()=>Io,effect:()=>Zo,enum:()=>Bo,function:()=>Mo,getErrorMap:()=>Re,getParsedType:()=>H,instanceof:()=>ho,intersection:()=>Oo,isAborted:()=>at,isAsync:()=>Ce,isDirty:()=>ct,isValid:()=>te,late:()=>mo,lazy:()=>Lo,literal:()=>Fo,makeIssue:()=>He,map:()=>No,nan:()=>go,nativeEnum:()=>jo,never:()=>wo,null:()=>xo,nullable:()=>Vo,number:()=>Gn,object:()=>Ao,objectUtil:()=>Rt,oboolean:()=>Yo,onumber:()=>Wo,optional:()=>Uo,ostring:()=>Go,pipeline:()=>Ko,preprocess:()=>Ho,promise:()=>zo,quotelessJson:()=>zi,record:()=>$o,set:()=>Po,setErrorMap:()=>Ui,strictObject:()=>Ro,string:()=>Kn,symbol:()=>bo,transformer:()=>Zo,tuple:()=>Do,undefined:()=>vo,union:()=>Co,unknown:()=>Eo,util:()=>T,void:()=>So});var $t=_(()=>{ot();It();Ln();Ve();Yn();it()});var Me=_(()=>{$t();$t()});var Le,ft=_(()=>{"use strict";Me();Le=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()})});import{readdir as Xo,readFile as Qo}from"node:fs/promises";import{join as Xn,dirname as ea}from"node:path";import{fileURLToPath as ta}from"node:url";function ra(){return process.env.TOKMIZER_DEV==="1"||process.env.TOKMIZER_DEV==="true"}async function Qn(){if(ie)return ie;if(!ra())return!qn&&process.env.TOKMIZER_DEBUG==="1"&&(process.stderr.write(`tokmizer: disk loader disabled (set TOKMIZER_DEV=1 to re-enable for local dev).
3
+ `),qn=!0),ie=new Map,ie;let t=new Map,e,n;try{e=(await import("smol-toml")).parse,n=(await Xo(Jn)).filter(r=>r.endsWith(".toml"))}catch{return ie=t,ie}for(let r of n){let s=await Qo(Xn(Jn,r),"utf8"),o=e(s).filters;if(o)for(let[a,c]of Object.entries(o)){let l=Le.parse({slug:a,...c});t.set(a,{...l,matchRegex:new RegExp(l.match_command)})}}return ie=t,ie}var na,Jn,ie,qn,er=_(()=>{"use strict";ft();na=ea(ta(import.meta.url)),Jn=process.env.TOKMIZER_FILTERS_DIR||Xn(na,"..","..","filters"),ie=null,qn=!1});var or={};wt(or,{FREE_FALLBACK:()=>ir,OutputVerbosity:()=>rr,ReducerLevel:()=>sr,Settings:()=>Fe,resolveAllowedFilters:()=>We,slugKey:()=>W});import{createHash as sa}from"node:crypto";function W(t){let e=tr.get(t);return e||(e=sa("sha256").update(`tkr:${t}`).digest("hex").slice(0,16),tr.set(t,e)),e}function We(t,e=!1){return e||!t||t.length===0?(nr??=new Set(ir.map(W)),new Set(nr)):new Set(t.map(n=>ia.test(n)?n:W(n)))}var rr,sr,Fe,ir,ia,tr,nr,Te=_(()=>{"use strict";Me();rr=m.enum(["normal","compact","minimal"]),sr=m.enum(["off","light","balanced","max"]),Fe=m.object({enabled:m.boolean().default(!0),telemetryOptIn:m.boolean().default(!0),outputVerbosity:rr.default("compact"),reducer:sr.default("off"),filters:m.object({enableAll:m.boolean().default(!0),disabled:m.array(m.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})}),ir=["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"],ia=/^[0-9a-f]{16}$/,tr=new Map;nr=null});function aa(t){if(!t)return"*";let e=ar.get(t);return e===void 0&&(e=[...t].join(","),ar.set(t,e)),e}function pt(t,e,n){let r=`${t}::${aa(n)}`,s=Be.get(r);if(s!==void 0)return s;let i=null;for(let o of e)n&&!n.has(W(o.slug))||o.matchRegex.test(t)&&(!i||o.priority>i.priority)&&(i=o);if(Be.size>=oa){let o=Be.keys().next().value;o&&Be.delete(o)}return Be.set(r,i),i}function cr(){Be.clear()}var Be,oa,ar,Nt=_(()=>{"use strict";Te();Be=new Map,oa=256,ar=new WeakMap});function Ae(t){return t.replace(ca,"").replace(la,"")}var ca,la,mt=_(()=>{"use strict";ca=/\x1b\[[0-9;?]*[ -/]*[@-~]/g,la=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g});function lr(t,e){return e.length===0?t:t.filter(n=>!e.some(r=>r.test(n)))}var ur=_(()=>{"use strict"});function dr(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`})}var fr=_(()=>{"use strict"});function ht(t){return`\u2026 (${t} more lines omitted)`}function pr(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),ht(s.length),...t.slice(t.length-r)],dropped:s}}var mr=_(()=>{"use strict"});function hr(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)ua.test(a)&&!oe.test(a)?(o.push(a),s+=1):(i(o),o=[],s=0,r.push(a));return i(o),r}var ua,oe,Pt=_(()=>{"use strict";ua=/^\s*(?:[✓✔√]|ok )/,oe=/✕|✗|×|\bFAIL\b|\bERROR\b|\bFATAL\b|\bError|\berror|Expected|Received|\bfailed\b|^\s*Tests?:|^\s*Test Suites?:/});function gr(t){return t.map(e=>e.replace(da,n=>{let r=n.split("/").filter(Boolean);return r.length<=2?n:`\u2026/${r.slice(-2).join("/")}`}))}var da,yr=_(()=>{"use strict";da=/(?:\/[\w.@+-]+){3,}/g});function ga(t){let e=ma.exec(t);return!e||ha.has(e[1])?!1:!/=>|\bfunction\b/.test(e[2])}function _a(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 ba(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==="&"))&&_a(t,s+1,i)&&(r=i),s+=1;continue}i==="{"||i==="("||i==="["?n+=1:(i==="}"||i===")"||i==="]")&&(n-=1),s+=1}return n}function Mt(t){let e=new Array(t.length).fill(!1);for(let n=0;n<t.length;n+=1){let r=va.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 gt(t){let e=[],n=0;for(;n<t.length;){let r=t[n];if(fa.test(r)&&pa.test(r)||ga(r)||ya.test(r)){let s={inBlockComment:!1,inTemplate:!1},i=0,o=n,a=!1;for(;o<t.length&&o-n<200;)if(i+=ba(t[o],s),o+=1,i<=0&&!s.inTemplate&&!s.inBlockComment){a=!0;break}let c=o-n;if(a&&c>=3){let l=c-2,u=/^\s*/.exec(t[n+1]??"")?.[0]??" ";e.push(r),e.push(`${u}\u2026 ${l} ${l===1?"line":"lines"} folded \u2026`);for(let f=0;f<l-1;f++)e.push("");e.push(t[o-1]),n=o;continue}}e.push(r),n+=1}return e}function br(t){let e=t.slice(0,4096);return!(!xa.test(e)||e.split(`
4
+ `).length<6)}var fa,pa,ma,ha,ya,_r,va,xa,yt=_(()=>{"use strict";fa=/^(\s*)(?:export\s+)?(?:async\s+)?(?:function|interface|type|const|let|var|def|fn|impl|trait|struct|enum)\s+[\w$]+/,pa=/\{\s*$/,ma=/^\s*(?:(?:public|private|protected|static|async|get|set|readonly|override)\s+)*([\w$]+)\s*\(([^)]*)\)\s*(?::\s*[^{]+)?\{\s*$/,ha=new Set(["if","for","while","switch","catch","do","with","return","else","function","await","yield"]);ya=/^\s*(?:if|for|while|switch|try|do)\b[^{}]*\{\s*$/;_r=/^\s*… \d+ lines? folded …$/,va=/^\s*… (\d+) lines? folded …$/;xa=/\b(?:function|class|interface|import\s+|export\s+|def\s+|fn\s+|impl\s+|package\s+|namespace\s+|using\s+|#include|=>\s*\{|=\s*function)/});function vr(t){let e=[],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(Ea.test(s.replace(ka,""))&&!wa.test(s)&&!Sa.test(s)){n+=1;continue}r(),e.push(s)}return r(),e}function xr(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 kr(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 ka,Ea,wa,Sa,Er=_(()=>{"use strict";Pt();ka=/^\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*/,Ea=/^\s*(?:\[(?:DEBUG|TRACE|INFO|VERBOSE)\]|(?:DEBUG|TRACE|INFO|VERBOSE)(?!\s*:))(?=\s|:|$)(?!\s*[+\-*\/%&|^?]*=)/,wa=new RegExp(oe.source,"i"),Sa=/\bWARN(?:ING)?\b/i});function L(t,e){wr.set(t,e)}function Sr(t){return wr.get(t)}var wr,Q=_(()=>{"use strict";wr=new Map});function Ra(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 Ca(t){if(!Ta.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 Ia(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 Oa(t){let e=[],n=[],r=!1;for(let d of t){if(/^total\s+\d+/.test(d))continue;if(Aa.test(d.trim()))return t;let g=Ca(d);g&&(r=!0,(g.isDir?e:n).push(g))}if(!r)return t;let s=(d,g)=>d.name.localeCompare(g.name);e.sort(s),n.sort((d,g)=>g.size-d.size||s(d,g));let i=[...e,...n],o=Math.min(40,Math.max(0,...i.map(d=>d.isDir?d.name.length+1:d.name.length))),a=[];for(let d of i){let g=d.isDir?`${d.name}/`:d.name,v=d.isDir?"":Ra(d.size);a.push(v?`${g.padEnd(o)} ${v}`:g)}if(a.length>Lt){let d=a.length-Lt;a=[...a.slice(0,Lt),`\u2026 ${d} more lines omitted`]}let c=n.length===1?"file":"files",l=e.length===1?"dir":"dirs",u=Ia(n),f=`${n.length} ${c}, ${e.length} ${l}`+(u?` (${u})`:"");return a.push(f),a}var Ta,Aa,Lt,Tr=_(()=>{"use strict";Q();Ta=/^[dbclps\-][rwxsStT\-]{9}[@.+]?(?:\s|$)/,Aa=/^[./~][^\s]*:$/,Lt=1e3;L("smart-ls",Oa)});var Ar=_(()=>{"use strict";yt();Q();L("smart-read",t=>gt(t))});function Da(t){let e=t.filter(u=>u.trim()!=="");if(e.length===0||e.filter(u=>!/\s/.test(u.trim())).length<e.length*.6)return t;let r=new Map,s=[],i=0;for(let u of e){let f=u.trim();if(f.startsWith("find:")){s.push(f);continue}let d=f.replace(/^\.\//,"").replace(/\/+$/,""),g=d.lastIndexOf("/"),v=g>=0?d.slice(0,g):"",E=g>=0?d.slice(g+1):d;if(!E)continue;let R=r.get(v)??[];R.push(/\s/.test(E)?`"${E}"`:E),r.set(v,R),i+=1}if(i===0)return t;let o=new Set([""]);for(let u of r.keys()){if(u==="")continue;let f=u.split("/");for(let d=1;d<=f.length;d+=1)o.add(f.slice(0,d).join("/"))}let a=[...o].sort(),c=a.filter(u=>u!=="").length,l=[`${i}F ${c}D:`,""];for(let u of a){let f=u===""?0:u.split("/").length,d=u===""?".":u.slice(u.lastIndexOf("/")+1),g=r.get(u)??[],v=g.length?` ${g.join(" ")}`:"";l.push(`${" ".repeat(f)}${d}/${v}`)}if(l.length+s.length>Rr){let u=Math.max(0,Rr-s.length),f=l.length-u;return[...l.slice(0,u),`\u2026 ${f} more lines omitted`,...s]}return[...l,...s]}var Rr,Cr=_(()=>{"use strict";Q();Rr=1e3;L("smart-find",Da)});function Dr(t){let e=t.trim();return e.length>Ir?`${e.slice(0,Ir)}\u2026`:e}function Fa(t){let e=[],n="";for(let r of t){let s=n?`${n}, ${r}`:r;s.length>Na&&n?(e.push(`${n},`),n=r):n=s}return n&&e.push(n),e}function Ba(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 d=Pa.exec(f),g=Ma.exec(f);if(d&&g)return t;let v=d||g?null:La.exec(f),E=(d??g??v)?.[1];if(!E)return t;let R=d?{line:d[2],content:d[3],context:!1}:g?{line:g[2],content:g[3],context:!0}:{line:"",content:v[2],context:!1},O=n.get(E)??[];O.push(R),n.set(E,O),R.context||(i+=1,r.set(E,(r.get(E)??0)+1)),o+=1,s=E}if(n.size===o)return t;let a=[...n.keys()].sort((f,d)=>{let g=Or.test(f)?1:0,v=Or.test(d)?1:0;return g-v||(f<d?-1:f>d?1:0)}),c=[];for(let f of a){c.push(`${f} (${r.get(f)??0}):`);for(let d of n.get(f))"separator"in d?c.push(" --"):d.line?c.push(` ${d.line}${d.context?"-":":"} ${Dr(d.content)}`):c.push(` ${Dr(d.content)}`)}let l=a.length>1&&c.length>$a?Fa(a.map(f=>`${f} (${r.get(f)??0})`)):[],u=[`${i}m ${a.length}f:`,...l,"",...c];if(u.length>Ft){let f=u.length-Ft;return[...u.slice(0,Ft),`\u2026 ${f} more lines omitted`]}return u}var Ft,Ir,$a,Na,Pa,Ma,La,Or,$r=_(()=>{"use strict";Q();Ft=1e3,Ir=200,$a=60,Na=190,Pa=/^([^\s:]+):(\d+):(.*)$/,Ma=/^([^:]+?)-(\d+)-(.*)$/,La=/^([^\s:]+):(.*)$/,Or=/(?:^|\/)(?:__tests__|tests?|spec|fixtures?|__mocks__|__snapshots__)\/|\.(?:test|spec)\.[^/]+$/i;L("smart-grep",Ba)});function Ua(t){if(!t.some(l=>Nr.test(l)))return t;let e=[],n=0,r=0,s=0,i="",o=!1,a=!1,c=()=>{r>0&&e.push(`${i} \u2026 ${r} ${r===1?"line":"lines"} folded \u2026`),r=0};for(let l of t){let u=l.slice(0,s),f=ja.test(u),d=f?l.slice(s):l,g=za.test(d),v=o&&g?null:Nr.exec(l);if(v){c(),n=0,s=v[1]?.length??0,o=!0,a=!1,e.push(l);continue}if(/^diff --(?:git|cc|combined) /.test(d)&&(a=!0),g&&!a&&!(s>0&&d.trim().length===0)){n+=1,n<=Za?e.push(l):(r+=1,i=f?u:"");continue}c(),e.push(l)}return c(),e}var Nr,ja,za,Za,Pr=_(()=>{"use strict";Q();Nr=/^(?:([|\\/ ._-]*\*[|\\/* ._-]* ))?commit [0-9a-f]{7,40}\b/,ja=/^[|\\/* ._-]*$/,za=/^ {4}/,Za=2;L("smart-log",Ua)});var Va,Ha,Ka,Mr=_(()=>{"use strict";Q();Va=/^[\s=]+$/,Ha=/^\s*=+\s+(.*?)\s+=+\s*$/,Ka=512;L("strip-banners",t=>{let e=[];for(let n of t){if(Va.test(n))continue;let r=n.length<=Ka?Ha.exec(n):null;e.push(r?r[1]:n)}return e})});function Ga(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}var Lr=_(()=>{"use strict";Q();L("squeeze-output",Ga)});function Wa(t){return t==="compact"?.6:t==="minimal"?.3:1}function Ja(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,c)=>c>2||!/^ RUN v\d+\.\d+\.\d+(?:[\w.+-]*) .+$/.test(a)),e,n,i]:t}function qa(t){let e=Fr.get(t);if(e)return e;let n=t.strip_lines_matching.map(s=>new RegExp(s)),r={def:t,stripRegexes:n};return Fr.set(t,r),r}function Br(t,e,n={}){return Bt(t,e,n).text}function Bt(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=qa(e),i=t;e.strip_ansi&&(i=Ae(i));let o=i.endsWith(`
5
+ `),a=(o?i.slice(0,-1):i).split(`
6
+ `);if(s.stripRegexes.length&&(a=e.keep_failures?a.filter(f=>oe.test(f)||!s.stripRegexes.some(d=>d.test(f))):lr(a,s.stripRegexes)),r!=="normal"&&!e.preserve_exact&&(a=xr(a),a=kr(a)),r==="minimal"&&!e.preserve_exact&&(a=vr(a),(e.slug==="vitest"||e.slug==="npm-test")&&(a=Ja(a))),!e.preserve_exact&&(n.smartCode||n.smartCode===void 0&&r!=="normal"&&br(i))&&(a=gt(a)),e.transform){let f=Sr(e.transform);f&&(a=f(a))}let c=e.slug==="read-tool";if(!c){let f=Mt(a);f.some(Boolean)&&(a=a.filter((d,g)=>!f[g]))}e.mask_abs_paths&&(a=gr(a)),e.fold_passing&&(a=hr(a,e.fold_passing_threshold??5)),e.truncate_lines_at&&(a=dr(a,e.truncate_lines_at));let l=null;if(e.max_lines){let f=e.scale_with_level?Wa(n.verbosity):1,d=Math.min(e.max_lines,Math.max(Ya,Math.round(e.max_lines*f))),g=c?Mt(a):null,v=g?g.filter(E=>!E).length:a.length;if(v>d){let E=d;if(g){let O=0;for(E=0;E<a.length&&O<d;)g[E]||(O+=1),E+=1}let R=v-d;if(e.keep_failures){let O=a.slice(E),U=O.filter(I=>!oe.test(I)),ae=O.reduce((I,ce,V)=>I+(!oe.test(ce)&&!g?.[E+V]?1:0),0);l=U.length>0?U.join(`
7
+ `):null,a=[...a.slice(0,E),...ae>0?[ht(ae)]:[],...O.filter(I=>oe.test(I))]}else if(c)l=a.slice(E).join(`
8
+ `),a=[...a.slice(0,E),ht(R)];else{let{kept:O,dropped:U}=pr(a,d);l=U.length>0?U.join(`
9
+ `):null,a=O}}}let u=a.join(`
10
+ `);return o&&u.length>0&&(u+=`
11
+ `),u.trim().length===0&&e.on_empty&&(u=e.on_empty),{text:u,droppedTail:l}}var Ya,Fr,jr=_(()=>{"use strict";mt();ur();fr();mr();Pt();yr();yt();Er();Q();Tr();Ar();Cr();$r();Pr();Mr();Lr();Ya=20;Fr=new WeakMap});function zr(t){if(!t)return!1;for(let e of Ae(t).split(`
12
+ `))if(!/^\s*[✓✔√]\s/.test(e)&&Xa.some(n=>n.test(e)))return!0;return!1}var Xa,Zr=_(()=>{"use strict";mt();Xa=[/\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 Ye(t){let e=t.trim(),n=e.split(/\s+/),r=0;for(;r<n.length;){let a=n[r];if(ec.test(a)){r++;continue}if(Qa.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}function Ur(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 nc(t){let e=Ur(t,!1);for(let n=e.length-1;n>=0;n--){let r=e[n].trim();if(r)return r}return t.trim()}function zt(t){let e=Ur(t,!0).map(n=>n.trim()).filter(Boolean);if(e.length===0)return null;for(let n of e.slice(0,-1)){let r=Ye(n).split(/\s+/)[0]??"";if(!tc.has(r))return null}return nc(e[e.length-1])}function Vr(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 Hr(t){let e=jt.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=zt(n),s=r?Ye(r):null;return s&&s!==t?[s,t]:[t]}var Qa,ec,jt,tc,Kr=_(()=>{"use strict";Qa=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),ec=/^[A-Za-z_][A-Za-z0-9_]*=/,jt=/^([a-z]+)-tool(?::\s|$)/;tc=new Set(["cd","export","source","set","unset","mkdir","true",":","pushd","popd","alias","ulimit","umask","echo","printf","sleep","touch","rm","cp","mv","chmod","ln"])});function Zt(t){let e=Buffer.from(t,"utf8");if(e.length<=256)return t;let n=256-Buffer.byteLength(Gr,"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")+Gr+e.subarray(s).toString("utf8")}var Gr,Wr=_(()=>{"use strict";Gr=`
13
+ [YOLO: omitted]
14
+ `});function oc(t,e){if(!e)return t.split(`
15
+ `).map(i=>i.replace(/^[ \t]+|[ \t]+(?=\r?$)/g,"")).join(`
16
+ `);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!==`
17
+ `&&(n+=i);return n+(t.endsWith(`
18
+ `)?`
19
+ `:"")}function ac(t,e){if(/@\d|\r/.test(t))return t;let n=t.endsWith(`
20
+ `)?`
21
+ `:"",r=(n?t.slice(0,-1):t).split(`
22
+ `),s=r.findIndex(d=>rc.test(d));if(s>=0&&r.slice(0,s).some(d=>d!==""&&!/^Showing \d+ of \d+ (?:open|closed|all) pull requests in \S+$/.test(d)))return t;let i=s>=0?[...r[s].matchAll(/\S+/g)].map(d=>d.index):[],o=[];for(let d=s+1;d<r.length;d+=1){let g=r[d];if(sc.test(g))continue;if(/…|\.\.\./.test(g))return t;let v;if(s>=0){if(/[^\x20-\x7e]/.test(g))return t;let E=i.map((R,O)=>g.slice(R,i[O+1]));if(E.slice(0,-1).some(R=>R[0]===" "||!R.endsWith(" "))||(v=E.map(R=>R.replace(/ +$/,"")),!/^#\d+$/.test(v[0])||!/^\S+$/.test(v[2])||!/^(OPEN|CLOSED|MERGED|DRAFT)$/.test(v[3])||!/^\d+(?:s|m|h|d|w|mo|y)$/.test(v[4])))return t}else if(v=g.split(" "),v.length!==5||!/^\d+$/.test(v[0])||!v[1]||!v[2]||!/^(OPEN|CLOSED|MERGED|DRAFT)$/.test(v[3])||!ic.test(v[4])||!Number.isFinite(Date.parse(v[4])))return t;if(v.some(E=>/[\u0000-\u001f\u007f]/.test(E)))return t;o.push({index:d,cells:v})}if(o.length===0)return t;s>=0&&(r[s]="ID TITLE BRANCH STATE CREATED");for(let d of o)r[d.index]=d.cells.join(" ");let a=r.join(`
23
+ `)+n;if(!e)return a;let c=new Map;for(let{cells:d}of o)c.set(d[1],(c.get(d[1])??0)+1);let l=new Map,u=[];for(let[d,g]of c){if(d.length<40||g<3||d.trim().split(/\s+/).length<8)continue;let v=`@${l.size+1}`,E=JSON.stringify(d).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),R=`TITLE ${v} = ${E}`;g*(Buffer.byteLength(d)-Buffer.byteLength(v))<=Buffer.byteLength(R)+1||(l.set(d,v),u.push(R))}if(u.length===0)return a;for(let{index:d,cells:g}of o)r[d]=g.map((v,E)=>E===1?l.get(v)??v:v).join(" ");let f=[...r,"",...u].join(`
24
+ `)+n;return Buffer.byteLength(f)<Buffer.byteLength(a)?f:a}function Ut(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=oc(t,e==="minimal")}else n==="gh"&&(r=ac(t,e==="minimal"));return Buffer.byteLength(r)<Buffer.byteLength(t)?r:t}var rc,sc,ic,Yr=_(()=>{"use strict";rc=/^ID {2,}TITLE {2,}BRANCH {2,}STATE {2,}CREATED *$/,sc=/^… \([1-9]\d* more lines omitted\)$/,ic=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/});function Vt(t){Jr=t}async function cc(t,e){let n=await Qn();return pt(t,n.values(),e)}async function qr(t,e,n,r={}){let s=Buffer.byteLength(e,"utf8"),{exitCode:i,yolo:o=!1,...a}=r,c=Ye(Vr(t.startsWith("bash-tool: ")?t.slice(11):t)),l=i!=null&&i!==0&&!(i===1&&lc.test(c)),u=Jr??cc,f=null;for(let I of Hr(t))if(f=await u(I,n),f)break;!f&&s>=uc&&!jt.test(t)&&(f=await u(`bash-tool: ${t}`,n));let d=zt(t.startsWith("bash-tool: ")?t.slice(11):t),g=f?.slug==="git-log"&&d!=null&&/^git\s+log(?:\s|$)/.test(Ye(d)),v=i==null&&(g?/^(?:fatal|error):/im.test(Ae(e)):zr(e));if(!f||(l||v)&&f.preserve_exact&&!o)return{output:e,filterId:null,rawBytes:s,filteredBytes:s,debugBypass:l||v,...o?{droppedTail:null}:{}};let E=I=>{if(!o)return I;let ce=I.filteredBytes>s||s>0&&I.output.length===0?e:I.output,V=!I.debugBypass&&!f?.preserve_exact?Ut(ce,"minimal",I.filterId??""):ce,ze=Zt(V)===V?V:Zt(ce);return{...I,output:ze,filteredBytes:Buffer.byteLength(ze,"utf8"),droppedTail:null}};if(l||v){let I=o?Br(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?Ae(e):e;return E({output:I,filterId:f.slug,rawBytes:s,filteredBytes:Buffer.byteLength(I,"utf8"),debugBypass:!0})}let{text:R,droppedTail:O}=Bt(e,f,o?{...a,verbosity:"minimal"}:a),U=!o&&!f.preserve_exact?Ut(R,a.verbosity,f.slug):R,ae=Buffer.byteLength(U,"utf8");return e.trim().length>0&&ae>=s?E({output:e,filterId:f.slug,rawBytes:s,filteredBytes:s,debugBypass:!1,droppedTail:null}):E({output:U,filterId:f.slug,rawBytes:s,filteredBytes:ae,debugBypass:!1,droppedTail:O})}var Jr,lc,uc,Ht=_(()=>{"use strict";er();Nt();jr();Zr();Kr();Wr();mt();Yr();Jr=null;lc=/^(?:grep|rg|find|eslint|ruff|flake8|mypy|prettier|biome|black|stylelint)(?:\s|$)|^git\s+(?:diff|grep)\b/,uc=2048});import{chmod as dc,mkdir as fc,readFile as Hf,writeFile as pc,stat as Kf,readdir as Gf,rm as Xr,rename as mc}from"node:fs/promises";import{createHash as Qr}from"node:crypto";function yc(t,e){let n=Number(process.env[t]);return Number.isFinite(n)&&n>0?n:e}async function es(t,e){if(ee()||!gc.test(t)||Buffer.byteLength(e,"utf8")>yc("TOKMIZER_CCR_ENTRY_MAX_BYTES",hc))return!1;let n=kn(t),r=`${n}.tmp-${process.pid}-${process.hrtime.bigint()}`;try{return await fc(St(),{recursive:!0}),ee()?!1:(await pc(r,e,{mode:384}),await dc(r,384),ee()?(await Xr(r,{force:!0}),!1):(await mc(r,n),!0))}catch{try{await Xr(r)}catch{}return!1}}async function ts(t,e){let n=process.env.TOKMIZER_CCR_DISABLED;if(n==="1"||n==="true"||ee()||!t)return e;let r=Qr("sha256").update(t).digest("hex").slice(0,16),s=`
25
+ [tkr restore ${r}]`;return Buffer.byteLength(t,"utf8")<=Buffer.byteLength(s,"utf8")||!await es(r,t)?e:`${e}${s}`}async function ns(t,e){let n=process.env.TOKMIZER_CCR_DISABLED;if(n==="1"||n==="true"||ee()||!t)return e;let r=Qr("sha256").update(t).digest("hex").slice(0,16);return await es(r,t)?`${e}
26
+ [tkr restore ${r}]`:e}var qf,Xf,hc,gc,rs=_(()=>{"use strict";N();At();qf=10080*60*1e3,Xf=100*1024*1024,hc=2*1024*1024,gc=/^[0-9a-f]{8,64}$/i});function _c(){let t=Number(process.env.TOKMIZER_OFFLINE_GRACE_MS);return Number.isFinite(t)&&t>0?t:6048e5}function ss(t,e=Date.now()){let n=t.lastHeartbeatOkAt;if(typeof n=="number"&&e-n>_c())return!0;if(t.subEndsAt){let r=Date.parse(t.subEndsAt);if(Number.isFinite(r)&&e>r)return!0}return!1}function is(t,e=Date.now()){return t.plan}var os=_(()=>{"use strict"});function Je(t){let e=t;for(let[n,r]of bc)e=e.replace(n,r);return e}var bc,Kt=_(()=>{"use strict";bc=[[/(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]"]]});import{createHash as rp,randomUUID as vc}from"node:crypto";import{readFile as as,writeFile as cs,mkdir as xc}from"node:fs/promises";async function Gt(){try{let n=(await as(Ze(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(n))return n}catch{}await xc(A(),{recursive:!0});let t=vc();try{return await cs(Ze(),t,{mode:384,flag:"wx"}),t}catch{try{let e=(await as(Ze(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(e))return e}catch{}return await cs(Ze(),t,{mode:384}),t}}var Wt=_(()=>{"use strict";N()});import{createRequire as kc}from"node:module";function wc(){for(let t of["../package.json","../../package.json"])try{let e=Ec(t).version;if(typeof e=="string"&&e)return e}catch{}return"0.0.0"}var Ec,Yt,Jt=_(()=>{"use strict";Ec=kc(import.meta.url);Yt=wc()});var ls,us=_(()=>{"use strict";ls=`-----BEGIN PUBLIC KEY-----
16
27
  MCowBQYDK2VwAyEAj/kMlXlhTIGHRKxOKMuGFa1S1ybxxwgdYcAE0YM9fgU=
17
28
  -----END PUBLIC KEY-----
18
- `});function Wr(){return((process.env.TOKMIZER_DEV==="1"?process.env.TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM:void 0)??Hr).replace(/\\n/g,`
19
- `)}var Cf,jt=v(()=>{"use strict";Ft();Kr();Cf=300*1e3});import{readFile as Ja,writeFile as If,mkdir as $f,chmod as Nf,rm as Pf,rename as Mf}from"node:fs/promises";import{join as Xa}from"node:path";async function Ue(){try{let t=await Ja(Xa(S(),Qa),"utf8"),e=JSON.parse(t);return St.parse({...Gr,...e})}catch{return Gr}}var Qa,Gr,ut=v(()=>{"use strict";De();D();Qa="settings-cache.json",Gr=St.parse({})});import{join as Yr}from"node:path";import{appendFileSync as tc,chmodSync as nc,existsSync as rc,mkdirSync as sc,readFileSync as Vf,renameSync as Hf,rmdirSync as Kf,statSync as ic,unlinkSync as Wf,utimesSync as Gf,writeFileSync as Yf}from"node:fs";function qr(){return Yr(S(),"spool")}function ac(t){return Yr(qr(),`${t}.jsonl`)}function dt(t,e){try{sc(qr(),{recursive:!0,mode:448});let n=ac(t);if(rc(n)&&ic(n).size>=oc)return;tc(n,JSON.stringify(e)+`
20
- `,{mode:384}),nc(n,384)}catch{return}}var oc,Bt=v(()=>{"use strict";D();Ye();Mt();jt();ut();oc=512*1024});function Jr(t){let e=t.toLowerCase();return e.startsWith("git")||fc.has(e)}function zt(t){let e=t.trim().split(/\s+/).filter(a=>a.length>0),n=0;for(;n<e.length&&dc.test(e[n]??"");)n+=1;let r=e[n];if(!r||!lc.test(r)||r.length>mc||Jr(r)||pc.test(r)||Ze(r)!==r)return"";let s=e[n+1];return s&&Jr(s)?"":(s&&hc.has(r.toLowerCase())&&uc.test(s)?`${r} ${s}`:r).slice(0,64)}async function Xr(t){if(!t.telemetryOptIn)return;let e=zt(t.cmd),n=e&&Ze(e)===e?e:"other",r=t.sessionId?t.sessionId.replace(/[^A-Za-z0-9._-]/g,"").slice(0,64):"";dt("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}:{}})}var lc,uc,dc,fc,pc,mc,hc,Zt=v(()=>{"use strict";Nt();Bt();lc=/^[a-z0-9][a-z0-9._-]*$/i,uc=/^[a-z][a-z-]+$/,dc=/^[A-Za-z_][A-Za-z0-9_]*=/,fc=new Set(["gh","glab","gup","hub","gist"]),pc=/^(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,mc=24,hc=new Set(["docker","podman","npm","pnpm","yarn","npx","bun","deno","cargo","rustup","go","pip","pip3","uv","poetry","brew","apt","apt-get","dnf","yum","pacman","kubectl","helm","terraform","aws","gcloud","az","systemctl","composer","bundle","gem","dotnet","prisma","tkr","rtk","token"])});async function Qr(t){if(t.plan!=="pro"||!(await Ue()).telemetryOptIn)return;let e=zt(t.cmd);!e||Ze(e)!==e||dt("learn",{cmd:e,filterId:t.filterId==null?null:G(t.filterId),rawBytes:t.rawBytes,filteredBytes:t.filteredBytes})}var es=v(()=>{"use strict";Zt();Nt();Bt();De();ut()});import{readFileSync as gc,renameSync as yc,statSync as _c,writeFileSync as vc}from"node:fs";function ts(t,e,n){try{if(_c(t).size<=e)return;let r=gc(t,"utf8").split(`
21
- `).filter(a=>a.trim()!==""),s=[],i=0;for(let a=r.length-1;a>=0;a-=1){let c=r[a],u=Buffer.byteLength(c)+1;if(i+u>n)break;s.push(c),i+=u}s.reverse();let o=`${t}.tmp-${process.pid}`;vc(o,s.length?`${s.join(`
29
+ `});function ds(){return((process.env.TOKMIZER_DEV==="1"?process.env.TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM:void 0)??ls).replace(/\\n/g,`
30
+ `)}var fp,qt=_(()=>{"use strict";Jt();us();fp=300*1e3});import{readFile as Sc,writeFile as hp,mkdir as gp,chmod as yp,rm as _p,rename as bp,readdir as vp}from"node:fs/promises";import{join as Tc}from"node:path";async function qe(){try{let t=await Sc(Tc(A(),Ac),"utf8"),e=JSON.parse(t);return Fe.parse({...fs,...e})}catch{return fs}}var Ac,fs,wp,_t=_(()=>{"use strict";Te();N();Ac="settings-cache.json",fs=Fe.parse({}),wp=Fe.partial().extend({filters:Fe.shape.filters.removeDefault().partial().optional()})});import{join as ps}from"node:path";import{appendFileSync as Cc,chmodSync as Ic,existsSync as Oc,mkdirSync as Dc,readFileSync as Cp,renameSync as Ip,rmdirSync as Op,statSync as $c,unlinkSync as Dp,utimesSync as $p,writeFileSync as Np}from"node:fs";function ms(){return ps(A(),"spool")}function Pc(t){return ps(ms(),`${t}.jsonl`)}function bt(t,e){try{Dc(ms(),{recursive:!0,mode:448});let n=Pc(t);if(Oc(n)&&$c(n).size>=Nc)return;Cc(n,JSON.stringify(e)+`
31
+ `,{mode:384}),Ic(n,384)}catch{return}}var Nc,Xt=_(()=>{"use strict";N();st();Wt();qt();_t();Nc=512*1024});function hs(t){let e=t.toLowerCase();return e.startsWith("git")||jc.has(e)}function Qt(t){let e=t.trim().split(/\s+/).filter(a=>a.length>0),n=0;for(;n<e.length&&Bc.test(e[n]??"");)n+=1;let r=e[n];if(!r||!Lc.test(r)||r.length>Zc||hs(r)||zc.test(r)||Je(r)!==r)return"";let s=e[n+1];return s&&hs(s)?"":(s&&Uc.has(r.toLowerCase())&&Fc.test(s)?`${r} ${s}`:r).slice(0,64)}async function gs(t){if(!t.telemetryOptIn)return;let e=Qt(t.cmd),n=e&&Je(e)===e?e:"other",r=t.sessionId?t.sessionId.replace(/[^A-Za-z0-9._-]/g,"").slice(0,64):"";bt("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}:{}})}var Lc,Fc,Bc,jc,zc,Zc,Uc,en=_(()=>{"use strict";Kt();Xt();Lc=/^[a-z0-9][a-z0-9._-]*$/i,Fc=/^[a-z][a-z-]+$/,Bc=/^[A-Za-z_][A-Za-z0-9_]*=/,jc=new Set(["gh","glab","gup","hub","gist"]),zc=/^(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,Zc=24,Uc=new Set(["docker","podman","npm","pnpm","yarn","npx","bun","deno","cargo","rustup","go","pip","pip3","uv","poetry","brew","apt","apt-get","dnf","yum","pacman","kubectl","helm","terraform","aws","gcloud","az","systemctl","composer","bundle","gem","dotnet","prisma","tkr","rtk","token"])});async function ys(t){if(t.plan!=="pro"||!(await qe()).telemetryOptIn)return;let e=Qt(t.cmd);!e||Je(e)!==e||bt("learn",{cmd:e,filterId:t.filterId==null?null:W(t.filterId),rawBytes:t.rawBytes,filteredBytes:t.filteredBytes})}var _s=_(()=>{"use strict";en();Kt();Xt();Te();_t()});import{readFileSync as Vc,renameSync as Hc,statSync as Kc,writeFileSync as Gc}from"node:fs";function bs(t,e,n){try{if(Kc(t).size<=e)return;let r=Vc(t,"utf8").split(`
32
+ `).filter(a=>a.trim()!==""),s=[],i=0;for(let a=r.length-1;a>=0;a-=1){let c=r[a],l=Buffer.byteLength(c)+1;if(i+l>n)break;s.push(c),i+=l}s.reverse();let o=`${t}.tmp-${process.pid}`;Gc(o,s.length?`${s.join(`
22
33
  `)}
23
- `:"",{mode:384}),yc(o,t)}catch{}}var ns=v(()=>{"use strict"});var rs=v(()=>{"use strict"});import{appendFileSync as bc,chmodSync as xc,mkdirSync as kc}from"node:fs";import{join as Ec}from"node:path";function is(t){return t.length===0||t[0]==="cd"||t.every(e=>os.test(e))}function Cc(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(`|;&<>
24
- `.includes(o)){if(i(),is(e)){e=[];continue}return e}n+=o,r=!0}return i(),is(e)?[]:e}function as(t){let e=Cc(t).map(a=>a.replace(/^[({]+/,"")).filter(Boolean),n=0;for(;n<e.length;){let a=e[n];if(os.test(a)){n+=1;continue}if(Sc.has(a)){for(n+=1;n<e.length;){let c=e[n];if(c.startsWith("-")){n+=Tc.has(c)?2:1;continue}if(/^\d+(?:\.\d+)?[smhd]?$/.test(c)){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("-")&&Ac.test(i)&&Rc.has(s.toLowerCase())?`${s} ${i}`:s).slice(0,24)}function Oc(){return Ec(S(),wc)}function cs(t,e,n=Oc(),r=!1,s,i,o){if(t<=0||e<0||e>t)return;let a=s?`,"h":${JSON.stringify(s)}`:"",c=i?`,"k":${JSON.stringify(i)}`:"",u=o?`,"c":${JSON.stringify(o.slice(0,24))}`:"",l=`{"t":${Math.floor(Date.now()/1e3)},"r":${t},"f":${e}${r?',"m":1':""}${a}${c}${u}}
25
- `;try{kc(S(),{recursive:!0,mode:448}),bc(n,l,{mode:384}),xc(n,384),ts(n,ss,ss/2)}catch{return}}function ls(t,e,n){let r=n!=null?Math.min(t,n):t,s=Math.min(e,r);return{raw:r,filtered:s}}var wc,ss,Sc,Tc,Ac,Rc,os,us=v(()=>{"use strict";ns();D();rs();wc="stats.jsonl",ss=2*1024*1024,Sc=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),Tc=new Set(["-u","-g","-n","-s","-k"]),Ac=/^[a-z0-9][a-z0-9._-]*$/i,Rc=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"]),os=/^[A-Za-z_][A-Za-z0-9_]*=/});function Ut(t){return JSON.stringify(t)+ft}function*fs(t){let e=0;for(;;){let n=t.indexOf(ft,e);if(n<0)return;yield t.slice(e,n),e=n+1}}function Ve(){return`${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var Dc,Ic,$c,Nc,wp,Sp,Tp,ds,ft,Ap,ps=v(()=>{"use strict";Ce();rt();Dc=p.object({id:p.string().min(1).max(64),op:p.literal("filter"),cmd:p.string().min(1).max(2048),plan:p.enum(["trial","smart","pro"]),allowed:p.array(p.string().min(1).max(64)).max(512).optional(),installId:p.string().min(1).max(64).optional()}),Ic=p.object({id:p.string().min(1).max(64),op:p.literal("ping")}),$c=p.object({id:p.string().min(1).max(64),op:p.literal("shutdown"),installId:p.string().min(1).max(64)}),Nc=p.object({id:p.string().min(1).max(64),op:p.literal("reload"),installId:p.string().min(1).max(64).optional()}),wp=p.discriminatedUnion("op",[Dc,Ic,$c,Nc]),Sp=p.object({id:p.string(),ok:p.literal(!0),data:p.unknown()}),Tp=p.object({id:p.string(),ok:p.literal(!1),err:p.string(),retryAfterMs:p.number().int().nonnegative().optional()}),ds=p.object({filter:Oe.nullable(),cacheHit:p.boolean().optional()}),ft=`
26
- `,Ap=64*1024});import Pc from"node:os";import{join as He}from"node:path";import{existsSync as Mc,statSync as Lc,lstatSync as ms,unlinkSync as Fc,mkdirSync as jc,chmodSync as Bc}from"node:fs";import{createHash as zc}from"node:crypto";function Zc(t){let e=zc("sha256").update(S()).digest("hex").slice(0,8),n=He(Pc.tmpdir(),`tkr-${t}-${e}`),r=He(n,"d.sock");if(Buffer.byteLength(r)>Vt)throw new Error("Temporary directory path is too long for IPC");return hs(n,t),r}function Uc(t,e){try{let n=ms(t);return n.isDirectory()&&n.uid===e&&(n.mode&63)===0}catch{return!1}}function hs(t,e){jc(t,{recursive:!0,mode:448});let n=ms(t);if(!n.isDirectory()||n.uid!==e)throw new Error("Unsafe IPC directory");Bc(t,448)}function Ke(){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&&Uc(e,t)){let s=He(e,`tokmizer-${t}.sock`);if(Buffer.byteLength(s)<=Vt)return{path:s,isPipe:!1}}let n=He(S(),"run"),r=He(n,"daemon.sock");return Buffer.byteLength(r)>Vt?{path:Zc(t),isPipe:!1}:(hs(n,t),{path:r,isPipe:!1})}async function Ht(){let{path:t,isPipe:e}=Ke();if(e||!Mc(t))return;try{if(!Lc(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 c=a.code;o(c!=="ECONNREFUSED"&&c!=="ENOENT")}),setTimeout(()=>o(!0),250)}))try{Fc(t)}catch{}}var Vt,Np,gs=v(()=>{"use strict";D();Vt=100;Np=5*6e4});import{createConnection as Vc}from"node:net";import{spawn as Hc}from"node:child_process";import{existsSync as vs,openSync as Kt,closeSync as ys,unlinkSync as Gt,writeFileSync as Yt,mkdirSync as qt,readFileSync as Kc,appendFileSync as Wc,rmSync as Gc,statSync as Yc}from"node:fs";import{dirname as qc,join as Jt}from"node:path";import{fileURLToPath as Jc}from"node:url";function Xt(){return Jt(S(),"daemon.spawn.fail")}function Qt(){return Jt(S(),"daemon.log")}function tl(){try{let t=Number(Kc(Xt(),"utf8"));return Number.isFinite(t)&&Date.now()-t<Qc}catch{return!1}}function nl(t){try{qt(S(),{recursive:!0});let e=Qt();try{Yc(e).size>el&&Gt(e)}catch{}Wc(e,`${new Date().toISOString()} ${t}
27
- `)}catch{}}function rl(t){try{qt(S(),{recursive:!0}),Yt(Xt(),String(Date.now()))}catch{}nl(`spawn failed: ${t.message}`)}function sl(){try{Gc(Xt(),{force:!0})}catch{}}async function pt(t,e){return new Promise((n,r)=>{let s=Vc(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 il(){return process.env.TOKMIZER_DAEMON_BIN?process.env.TOKMIZER_DAEMON_BIN:Jc(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 pt(t,75)).destroy(),!0}catch{}else if(vs(t))return!0;await new Promise(i=>setTimeout(i,75))}return!1}async function ol(t){let e=il();if(!vs(e))throw new Error(`tkr-daemon binary not found at ${e}`);let{path:n}=Ke(),r=process.platform==="win32"?S():qc(n);try{qt(r,{recursive:!0})}catch{}let s=Jt(r,"daemon.spawn.lock"),i=null;try{i=Kt(s,"wx"),Yt(i,String(process.pid))}catch(o){if(o.code==="EEXIST"){if(await Wt(n,5e3))return;try{Gt(s)}catch{}try{i=Kt(s,"wx"),Yt(i,String(process.pid))}catch(c){if(c.code==="EEXIST"){await Wt(n,5e3);return}throw c}}else throw o}try{let o=null;try{o=Kt(Qt(),"a")}catch{}if(Hc(process.execPath,[e],{detached:!0,stdio:["ignore","ignore",o??"ignore"],env:{...process.env,TOKMIZER_DAEMON_INSTALL_ID:t}}).unref(),o!==null)try{ys(o)}catch{}if(!await Wt(n,3e3))throw new Error("tkr-daemon failed to bind socket within 3s")}finally{if(i!==null){try{ys(i)}catch{}try{Gt(s)}catch{}}}}async function al(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:Ke(),n=await Pt();try{let r=await pt(e,bs);r.write(Ut({id:Ve(),op:"shutdown",installId:n})),await new Promise(s=>setTimeout(s,150));try{r.destroy()}catch{}return!0}catch{return!1}}async function cl(t,e){let n=Date.now()+e;for(;Date.now()<n;){try{(await pt(t,250)).destroy()}catch{return!0}await new Promise(r=>setTimeout(r,100))}return!1}async function en(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:Ke(),n=await Pt(),r=null,s=0,i=!1;for(;s<=_s;)try{r=await pt(e,bs),sl();break}catch{if(s+=1,s>_s)throw new Error(`tkr-daemon unreachable at ${e}`);if(tl())throw new Error(`tkr-daemon spawn on cooldown (see ${Qt()})`);await Ht();try{await ol(n),i=!0}catch(l){throw rl(l),l}}if(!r)throw new Error("tkr-daemon: socket setup failed");let o=new Map,a="";r.setEncoding("utf8"),r.on("data",l=>{a+=l;let f=-1;for(let _=0;_<a.length;_++)a[_]===ft&&(f=_);if(f<0)return;let h=[];for(let _ of fs(a.slice(0,f+1)))h.push(_);a=a.slice(f+1);for(let _ of h)if(_)try{let A=JSON.parse(_),T=o.get(A.id);if(!T)continue;clearTimeout(T.timer),o.delete(A.id),T.resolve(A)}catch{}}),r.on("close",()=>{for(let l of o.values())clearTimeout(l.timer),l.reject(new Error("daemon socket closed"));o.clear()}),r.on("error",()=>{});function c(l){return new Promise((f,h)=>{let _=setTimeout(()=>{o.delete(l.id),h(new Error(`daemon request timeout (${l.op})`))},Xc);o.set(l.id,{resolve:f,reject:h,timer:_}),r.write(Ut(l))})}let u={filter:async(l,f,h)=>{let _=await c({id:Ve(),op:"filter",cmd:l.slice(0,2048),plan:f,...h&&h.length>0?{allowed:h.slice(0,512)}:{},installId:n});if(!_.ok)return null;let A=ds.safeParse(_.data);return A.success?A.data.filter:null},ping:async()=>{let l=await c({id:Ve(),op:"ping"});if(!l.ok)throw new Error(l.err);return l.data},reload:async()=>{let l=await c({id:Ve(),op:"reload",installId:n});if(!l.ok)throw new Error(l.err);return l.data},close:()=>{try{r.end()}catch{}}};if(!t.skipVersionCheck&&!i){let l=!1;try{l=(await u.ping()).version!==Lt}catch{}if(l){try{await al(t.socketPath?{socketPath:t.socketPath}:{})}catch{}u.close();let f=await cl(e,2e3);if(await Ht(),!f)throw new Error("stale daemon still running after shutdown request");return en({...t,skipVersionCheck:!0})}}return u}var bs,Xc,_s,Qc,el,xs=v(()=>{"use strict";ps();gs();D();Mt();Ft();bs=500,Xc=3e3,_s=1,Qc=6e4,el=256*1024});import{createCipheriv as Yp,createDecipheriv as ll,hkdfSync as ul,randomBytes as qp}from"node:crypto";function pl(t){return Buffer.from(ul("sha256",Buffer.from(t,"utf8"),dl,fl,32))}function ks(t,e){let n=pl(e),r=Buffer.from(t,"base64url"),s=r.subarray(0,12),i=r.subarray(12,28),o=r.subarray(28),a=ll("aes-256-gcm",n,s);return a.setAuthTag(i),Buffer.concat([a.update(o),a.final()]).toString("utf8")}var dl,fl,Es=v(()=>{"use strict";dl=Buffer.from("tokmizer-bundle-enc-v1"),fl=Buffer.from("rules-bundle")});import{chmodSync as Qp,readFileSync as ml,writeFileSync as em,mkdirSync as tm,renameSync as nm}from"node:fs";import{join as hl}from"node:path";function yl(){return hl(S(),"bundle-cache.json")}function ws(){try{let t=ml(yl(),"utf8"),e=gl.safeParse(JSON.parse(t));return e.success?e.data:null}catch{return null}}var gl,Ss=v(()=>{"use strict";Ce();D();gl=p.object({payload:p.string().min(1),signature:p.string().min(1),enc:p.literal("v1"),fetchedAt:p.number().int().nonnegative()})});import{createPublicKey as _l,verify as vl}from"node:crypto";function kl(){let t=Number(process.env.TOKMIZER_MAX_BUNDLE_AGE_MS);return Number.isFinite(t)&&t>0?t:xl}function El(t,e){let n=Wr();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=_l({key:n,format:"pem"});if(!vl(null,Buffer.from(t.payload,"utf8"),r,Buffer.from(t.signature,"base64url")))throw new Error("tkr-daemon: rules bundle signature invalid");return JSON.parse(ks(t.payload,e))}function wl(t,e){let n=El(t,e),r=bl.parse(n);if(Date.now()-r.signedAt>kl())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 Hn(),{bundleVersion:r.bundleVersion,signedAt:r.signedAt,ruleCount:s.size,startedAt:Date.now(),fetchedAt:Date.now(),selectFor:(i,o,a)=>it(i,s.values(),a&&a.length>0?new Set(a):null)}}async function Ts(){try{let t=ws();if(!t)return null;let e=await Me();return e?.signingSecret?wl(t,e.signingSecret):null}catch{return null}}var bl,gm,xl,As=v(()=>{"use strict";Ce();rt();Tt();Ye();jt();Es();Ss();bl=p.object({bundleVersion:p.number().int().nonnegative(),signedAt:p.number().int(),filters:p.array(Oe)}),gm=p.object({payload:p.string().min(1),signature:p.string().min(1),enc:p.literal("v1")}),xl=10080*60*1e3});async function Sl(){if($e)return $e;if(We)return We;let t=en().then(e=>{if(We===t)return $e=e,e;try{e.close()}catch{}return null}).catch(()=>null);return We=t,t}async function Tl(){return nn||(nn=!0,tn=await Ts()),tn}async function Rs(t,e,n){let r=await Tl();if(!r)return null;let s=r.selectFor(t,e,[...n]);return!s||!n.has(G(s.slug))?null:s}function Al(t){return t?{...t,matchRegex:new RegExp(t.match_command)}:null}function Cs(t){It(async(e,n)=>{let r=t==="free"?"trial":t,s=n??st(void 0),i=await Sl();if(!i)return Rs(e,r,s);try{let o=await i.filter(e,r,[...s]);return!o||!s.has(G(o.slug))?null:Al(o)}catch{return Rs(e,r,s)}})}function Os(){if(It(null),$e)try{$e.close()}catch{}$e=null,We=null,tn=null,nn=!1}var $e,We,tn,nn,Ds=v(()=>{"use strict";xs();$t();De();As();$e=null,We=null;tn=null,nn=!1});var rn={};cn(rn,{FOLD_MARKER_RE:()=>sr,captureForRestore:()=>Lr,captureOriginalForRestore:()=>Fr,closeDaemonResolver:()=>Os,countedSaving:()=>ls,gatingPlan:()=>zr,graceExceeded:()=>Br,installDaemonResolver:()=>Cs,loadSettingsCache:()=>Ue,processOutput:()=>Nr,recordEvent:()=>Qr,recordStat:()=>cs,recordTelemetry:()=>Xr,resolveAllowedFilters:()=>st,statCmdLabel:()=>as});var sn=v(()=>{"use strict";$t();jr();ct();De();Zr();es();Zt();us();Ds();ut()});D();import{existsSync as Rl,writeFileSync as Cl,appendFileSync as Ol,statSync as Dl}from"node:fs";import{join as $s}from"node:path";async function un(){let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf8")}import{realpathSync as dn}from"node:fs";import{fileURLToPath as zs,pathToFileURL as Zs}from"node:url";function fn(t,e){if(!t)return!1;if(e===Zs(t).href)return!0;try{return dn(t)===dn(zs(e))}catch{return!1}}Ye();var pn=[{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"]}],fu=[...pn.map(t=>t.host),"shell"],Gs=new Set(["claude-code","codex"]);function mn(t){return null}function hn(t=process.env){let e=process.platform,n=e==="darwin"||e==="linux"||e==="win32"?e:"other",r=process.arch;for(let s of pn)if(s.vars.some(i=>t[i]))return{host:s.host,source:"env",os:n,arch:r,shimRecommended:!Gs.has(s.host)};return{host:"shell",source:"fallback",os:n,arch:r,shimRecommended:!0}}D();import{appendFileSync as Ys,mkdirSync as qs,readFileSync as Js,writeFileSync as Xs,renameSync as Qs,statSync as ei,readdirSync as hu,rmSync as gu,chmodSync as ti}from"node:fs";import{join as gn}from"node:path";var ni=96*1024,ri=500,vu=168*3600*1e3,si=120;function yn(){return gn(S(),"sessions")}function ii(t){let e=t.replace(/[^A-Za-z0-9._-]/g,"-").replace(/\.\./g,"-").slice(0,80)||"default";return gn(yn(),`${e}.jsonl`)}function _n(t,e){try{let n=ii(t);qs(yn(),{recursive:!0,mode:448});let r=JSON.stringify({t:e.t??Math.floor(Date.now()/1e3),tool:e.tool,target:e.target.slice(0,si),...e.fail?{fail:1}:{}});if(Ys(n,`${r}
28
- `,{mode:384}),ti(n,384),ei(n).size>ni){let s=Js(n,"utf8").split(`
29
- `).filter(a=>a.trim()!==""),i=s.slice(s.length-ri),o=`${n}.tmp-${process.pid}`;Xs(o,`${i.join(`
34
+ `:"",{mode:384}),Hc(o,t)}catch{}}var vs=_(()=>{"use strict"});var xs=_(()=>{"use strict"});import{appendFileSync as Wc,chmodSync as Yc,mkdirSync as Jc}from"node:fs";import{join as qc}from"node:path";function Es(t){return t.length===0||t[0]==="cd"||t.every(e=>ws.test(e))}function rl(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(`|;&<>
35
+ `.includes(o)){if(i(),Es(e)){e=[];continue}return e}n+=o,r=!0}return i(),Es(e)?[]:e}function Ss(t){let e=rl(t).map(a=>a.replace(/^[({]+/,"")).filter(Boolean),n=0;for(;n<e.length;){let a=e[n];if(ws.test(a)){n+=1;continue}if(Qc.has(a)){for(n+=1;n<e.length;){let c=e[n];if(c.startsWith("-")){n+=el.has(c)?2:1;continue}if(/^\d+(?:\.\d+)?[smhd]?$/.test(c)){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("-")&&tl.test(i)&&nl.has(s.toLowerCase())?`${s} ${i}`:s).slice(0,24)}function sl(){return qc(A(),Xc)}function Ts(t,e,n=sl(),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)}`:"",c=i?`,"k":${JSON.stringify(i)}`:"",l=o?`,"c":${JSON.stringify(o.slice(0,24))}`:"",u=`{"t":${Math.floor(Date.now()/1e3)},"r":${t},"f":${e}${r?',"m":1':""}${a}${c}${l}}
36
+ `;try{Jc(A(),{recursive:!0,mode:448}),Wc(n,u,{mode:384}),Yc(n,384),bs(n,ks,ks/2)}catch{return}}function As(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 Xc,ks,Qc,el,tl,nl,ws,Rs=_(()=>{"use strict";vs();N();xs();Xc="stats.jsonl",ks=2*1024*1024,Qc=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),el=new Set(["-u","-g","-n","-s","-k"]),tl=/^[a-z0-9][a-z0-9._-]*$/i,nl=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"]),ws=/^[A-Za-z_][A-Za-z0-9_]*=/});function tn(t){return JSON.stringify(t)+vt}function*Is(t){let e=0;for(;;){let n=t.indexOf(vt,e);if(n<0)return;yield t.slice(e,n),e=n+1}}function Xe(){return`${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var il,ol,al,cl,cm,lm,um,Cs,vt,dm,Os=_(()=>{"use strict";Me();ft();il=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()}),ol=m.object({id:m.string().min(1).max(64),op:m.literal("ping")}),al=m.object({id:m.string().min(1).max(64),op:m.literal("shutdown"),installId:m.string().min(1).max(64)}),cl=m.object({id:m.string().min(1).max(64),op:m.literal("reload"),installId:m.string().min(1).max(64).optional()}),cm=m.discriminatedUnion("op",[il,ol,al,cl]),lm=m.object({id:m.string(),ok:m.literal(!0),data:m.unknown()}),um=m.object({id:m.string(),ok:m.literal(!1),err:m.string(),retryAfterMs:m.number().int().nonnegative().optional()}),Cs=m.object({filter:Le.nullable(),cacheHit:m.boolean().optional()}),vt=`
37
+ `,dm=64*1024});import ll from"node:os";import{join as Qe}from"node:path";import{existsSync as ul,statSync as dl,lstatSync as Ds,unlinkSync as fl,mkdirSync as pl,chmodSync as ml}from"node:fs";import{createHash as hl}from"node:crypto";function gl(t){let e=hl("sha256").update(A()).digest("hex").slice(0,8),n=Qe(ll.tmpdir(),`tkr-${t}-${e}`),r=Qe(n,"d.sock");if(Buffer.byteLength(r)>nn)throw new Error("Temporary directory path is too long for IPC");return $s(n,t),r}function yl(t,e){try{let n=Ds(t);return n.isDirectory()&&n.uid===e&&(n.mode&63)===0}catch{return!1}}function $s(t,e){pl(t,{recursive:!0,mode:448});let n=Ds(t);if(!n.isDirectory()||n.uid!==e)throw new Error("Unsafe IPC directory");ml(t,448)}function et(){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&&yl(e,t)){let s=Qe(e,`tokmizer-${t}.sock`);if(Buffer.byteLength(s)<=nn)return{path:s,isPipe:!1}}let n=Qe(A(),"run"),r=Qe(n,"daemon.sock");return Buffer.byteLength(r)>nn?{path:gl(t),isPipe:!1}:($s(n,t),{path:r,isPipe:!1})}async function rn(){let{path:t,isPipe:e}=et();if(e||!ul(t))return;try{if(!dl(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 c=a.code;o(c!=="ECONNREFUSED"&&c!=="ENOENT")}),setTimeout(()=>o(!0),250)}))try{fl(t)}catch{}}var nn,_m,Ns=_(()=>{"use strict";N();nn=100;_m=5*6e4});import{createConnection as _l}from"node:net";import{spawn as bl}from"node:child_process";import{existsSync as Ls,openSync as sn,closeSync as Ps,unlinkSync as an,writeFileSync as cn,mkdirSync as ln,readFileSync as vl,appendFileSync as xl,rmSync as kl,statSync as El}from"node:fs";import{dirname as wl,join as un}from"node:path";import{fileURLToPath as Sl}from"node:url";function dn(){return un(A(),"daemon.spawn.fail")}function fn(){return un(A(),"daemon.log")}function Cl(){try{let t=Number(vl(dn(),"utf8"));return Number.isFinite(t)&&Date.now()-t<Al}catch{return!1}}function Il(t){try{ln(A(),{recursive:!0});let e=fn();try{El(e).size>Rl&&an(e)}catch{}xl(e,`${new Date().toISOString()} ${t}
38
+ `)}catch{}}function Ol(t){try{ln(A(),{recursive:!0}),cn(dn(),String(Date.now()))}catch{}Il(`spawn failed: ${t.message}`)}function Dl(){try{kl(dn(),{force:!0})}catch{}}async function xt(t,e){return new Promise((n,r)=>{let s=_l(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 $l(){return process.env.TOKMIZER_DAEMON_BIN?process.env.TOKMIZER_DAEMON_BIN:Sl(new URL("../bin/tkr-daemon.js",import.meta.url))}async function on(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 xt(t,75)).destroy(),!0}catch{}else if(Ls(t))return!0;await new Promise(i=>setTimeout(i,75))}return!1}async function Nl(t){let e=$l();if(!Ls(e))throw new Error(`tkr-daemon binary not found at ${e}`);let{path:n}=et(),r=process.platform==="win32"?A():wl(n);try{ln(r,{recursive:!0})}catch{}let s=un(r,"daemon.spawn.lock"),i=null;try{i=sn(s,"wx"),cn(i,String(process.pid))}catch(o){if(o.code==="EEXIST"){if(await on(n,5e3))return;try{an(s)}catch{}try{i=sn(s,"wx"),cn(i,String(process.pid))}catch(c){if(c.code==="EEXIST"){await on(n,5e3);return}throw c}}else throw o}try{let o=null;try{o=sn(fn(),"a")}catch{}if(bl(process.execPath,[e],{detached:!0,stdio:["ignore","ignore",o??"ignore"],env:{...process.env,TOKMIZER_DAEMON_INSTALL_ID:t}}).unref(),o!==null)try{Ps(o)}catch{}if(!await on(n,3e3))throw new Error("tkr-daemon failed to bind socket within 3s")}finally{if(i!==null){try{Ps(i)}catch{}try{an(s)}catch{}}}}async function Pl(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:et(),n=await Gt();try{let r=await xt(e,Fs);r.write(tn({id:Xe(),op:"shutdown",installId:n})),await new Promise(s=>setTimeout(s,150));try{r.destroy()}catch{}return!0}catch{return!1}}async function Ml(t,e){let n=Date.now()+e;for(;Date.now()<n;){try{(await xt(t,250)).destroy()}catch{return!0}await new Promise(r=>setTimeout(r,100))}return!1}async function pn(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:et(),n=await Gt(),r=null,s=0,i=!1;for(;s<=Ms;)try{r=await xt(e,Fs),Dl();break}catch{if(s+=1,s>Ms)throw new Error(`tkr-daemon unreachable at ${e}`);if(Cl())throw new Error(`tkr-daemon spawn on cooldown (see ${fn()})`);await rn();try{await Nl(n),i=!0}catch(u){throw Ol(u),u}}if(!r)throw new Error("tkr-daemon: socket setup failed");let o=new Map,a="";r.setEncoding("utf8"),r.on("data",u=>{a+=u;let f=-1;for(let g=0;g<a.length;g++)a[g]===vt&&(f=g);if(f<0)return;let d=[];for(let g of Is(a.slice(0,f+1)))d.push(g);a=a.slice(f+1);for(let g of d)if(g)try{let v=JSON.parse(g),E=o.get(v.id);if(!E)continue;clearTimeout(E.timer),o.delete(v.id),E.resolve(v)}catch{}}),r.on("close",()=>{for(let u of o.values())clearTimeout(u.timer),u.reject(new Error("daemon socket closed"));o.clear()}),r.on("error",()=>{});function c(u){return new Promise((f,d)=>{let g=setTimeout(()=>{o.delete(u.id),d(new Error(`daemon request timeout (${u.op})`))},Tl);o.set(u.id,{resolve:f,reject:d,timer:g}),r.write(tn(u))})}let l={filter:async(u,f,d)=>{let g=await c({id:Xe(),op:"filter",cmd:u.slice(0,2048),plan:f,...d&&d.length>0?{allowed:d.slice(0,512)}:{},installId:n});if(!g.ok)return null;let v=Cs.safeParse(g.data);return v.success?v.data.filter:null},ping:async()=>{let u=await c({id:Xe(),op:"ping"});if(!u.ok)throw new Error(u.err);return u.data},reload:async()=>{let u=await c({id:Xe(),op:"reload",installId:n});if(!u.ok)throw new Error(u.err);return u.data},close:()=>{try{r.end()}catch{}}};if(!t.skipVersionCheck&&!i){let u=!1;try{u=(await l.ping()).version!==Yt}catch{}if(u){try{await Pl(t.socketPath?{socketPath:t.socketPath}:{})}catch{}l.close();let f=await Ml(e,2e3);if(await rn(),!f)throw new Error("stale daemon still running after shutdown request");return pn({...t,skipVersionCheck:!0})}}return l}var Fs,Tl,Ms,Al,Rl,Bs=_(()=>{"use strict";Os();Ns();N();Wt();Jt();Fs=500,Tl=3e3,Ms=1,Al=6e4,Rl=256*1024});import{createCipheriv as $m,createDecipheriv as Ll,hkdfSync as Fl,randomBytes as Nm}from"node:crypto";function zl(t){return Buffer.from(Fl("sha256",Buffer.from(t,"utf8"),Bl,jl,32))}function js(t,e){let n=zl(e),r=Buffer.from(t,"base64url"),s=r.subarray(0,12),i=r.subarray(12,28),o=r.subarray(28),a=Ll("aes-256-gcm",n,s);return a.setAuthTag(i),Buffer.concat([a.update(o),a.final()]).toString("utf8")}var Bl,jl,zs=_(()=>{"use strict";Bl=Buffer.from("tokmizer-bundle-enc-v1"),jl=Buffer.from("rules-bundle")});import{chmodSync as Lm,readFileSync as Zl,writeFileSync as Fm,mkdirSync as Bm,renameSync as jm}from"node:fs";import{join as Ul}from"node:path";function Hl(){return Ul(A(),"bundle-cache.json")}function Zs(){try{let t=Zl(Hl(),"utf8"),e=Vl.safeParse(JSON.parse(t));return e.success?e.data:null}catch{return null}}var Vl,Us=_(()=>{"use strict";Me();N();Vl=m.object({payload:m.string().min(1),signature:m.string().min(1),enc:m.literal("v1"),fetchedAt:m.number().int().nonnegative()})});import{createPublicKey as Kl,verify as Gl}from"node:crypto";function Jl(){let t=Number(process.env.TOKMIZER_MAX_BUNDLE_AGE_MS);return Number.isFinite(t)&&t>0?t:Yl}function ql(t,e){let n=ds();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=Kl({key:n,format:"pem"});if(!Gl(null,Buffer.from(t.payload,"utf8"),r,Buffer.from(t.signature,"base64url")))throw new Error("tkr-daemon: rules bundle signature invalid");return JSON.parse(js(t.payload,e))}function Xl(t,e){let n=ql(t,e),r=Wl.parse(n);if(Date.now()-r.signedAt>Jl())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 cr(),{bundleVersion:r.bundleVersion,signedAt:r.signedAt,ruleCount:s.size,startedAt:Date.now(),fetchedAt:Date.now(),selectFor:(i,o,a)=>pt(i,s.values(),a&&a.length>0?new Set(a):null)}}async function Vs(){try{let t=Zs();if(!t)return null;let e=await Ue();return e?.signingSecret?Xl(t,e.signingSecret):null}catch{return null}}var Wl,eh,Yl,Hs=_(()=>{"use strict";Me();ft();Nt();st();qt();zs();Us();Wl=m.object({bundleVersion:m.number().int().nonnegative(),signedAt:m.number().int(),filters:m.array(Le)}),eh=m.object({payload:m.string().min(1),signature:m.string().min(1),enc:m.literal("v1")}),Yl=10080*60*1e3});async function Ql(){if(je)return je;if(tt)return tt;let t=pn().then(e=>{if(tt===t)return je=e,e;try{e.close()}catch{}return null}).catch(()=>null);return tt=t,t}async function eu(){return hn||(hn=!0,mn=await Vs()),mn}async function Ks(t,e,n){let r=await eu();if(!r)return null;let s=r.selectFor(t,e,[...n]);return!s||!n.has(W(s.slug))?null:s}function tu(t){return t?{...t,matchRegex:new RegExp(t.match_command)}:null}function Gs(t){Vt(async(e,n)=>{let r=t==="free"?"trial":t,s=n??We(void 0),i=await Ql();if(!i)return Ks(e,r,s);try{let o=await i.filter(e,r,[...s]);return!o||!s.has(W(o.slug))?null:tu(o)}catch{return Ks(e,r,s)}})}function Ws(){if(Vt(null),je)try{je.close()}catch{}je=null,tt=null,mn=null,hn=!1}var je,tt,mn,hn,Ys=_(()=>{"use strict";Bs();Ht();Te();Hs();je=null,tt=null;mn=null,hn=!1});var Js={};wt(Js,{FOLD_MARKER_RE:()=>_r,captureForRestore:()=>ts,captureOriginalForRestore:()=>ns,closeDaemonResolver:()=>Ws,countedSaving:()=>As,gatingPlan:()=>is,graceExceeded:()=>ss,installDaemonResolver:()=>Gs,loadSettingsCache:()=>qe,processOutput:()=>qr,recordEvent:()=>ys,recordStat:()=>Ts,recordTelemetry:()=>gs,resolveAllowedFilters:()=>We,statCmdLabel:()=>Ss});var qs=_(()=>{"use strict";Ht();rs();yt();Te();os();_s();en();Rs();Ys();_t()});N();import{existsSync as nu,writeFileSync as ru,appendFileSync as su,statSync as iu}from"node:fs";import{join as ei}from"node:path";async function En(){let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf8")}import{realpathSync as wn}from"node:fs";import{fileURLToPath as ci,pathToFileURL as li}from"node:url";function Sn(t,e){if(!t)return!1;if(e===li(t).href)return!0;try{return wn(t)===wn(ci(e))}catch{return!1}}st();var Tn=[{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"]}],Fu=[...Tn.map(t=>t.host),"shell"],hi=new Set(["claude-code","codex"]);function An(t){return null}function Rn(t=process.env){let e=process.platform,n=e==="darwin"||e==="linux"||e==="win32"?e:"other",r=process.arch;for(let s of Tn)if(s.vars.some(i=>t[i]))return{host:s.host,source:"env",os:n,arch:r,shimRecommended:!hi.has(s.host)};return{host:"shell",source:"fallback",os:n,arch:r,shimRecommended:!0}}N();import{appendFileSync as gi,mkdirSync as yi,readFileSync as _i,writeFileSync as bi,renameSync as vi,statSync as xi,readdirSync as zu,rmSync as Zu,chmodSync as ki}from"node:fs";import{join as Cn}from"node:path";var Ei=96*1024,wi=500,Hu=168*3600*1e3,Si=120;function In(){return Cn(A(),"sessions")}function Ti(t){let e=t.replace(/[^A-Za-z0-9._-]/g,"-").replace(/\.\./g,"-").slice(0,80)||"default";return Cn(In(),`${e}.jsonl`)}function On(t,e){try{let n=Ti(t);yi(In(),{recursive:!0,mode:448});let r=JSON.stringify({t:e.t??Math.floor(Date.now()/1e3),tool:e.tool,target:e.target.slice(0,Si),...e.fail?{fail:1}:{}});if(gi(n,`${r}
39
+ `,{mode:384}),ki(n,384),xi(n).size>Ei){let s=_i(n,"utf8").split(`
40
+ `).filter(a=>a.trim()!==""),i=s.slice(s.length-wi),o=`${n}.tmp-${process.pid}`;bi(o,`${i.join(`
30
41
  `)}
31
- `,{mode:384}),Qs(o,n)}}catch{}}D();import{readFileSync as oi}from"node:fs";import{join as ai}from"node:path";function vn(){try{return JSON.parse(oi(ai(S(),"settings-cache.json"),"utf8")).enabled!==!1}catch{return!0}}D();import{createHash as ci}from"node:crypto";import{appendFileSync as li,chmodSync as ui,mkdirSync as di,readFileSync as fi,rmSync as pi,statSync as mi}from"node:fs";import{join as bn}from"node:path";var hi=256*1024,gi=80;function yi(t){let e=t.replace(/[^A-Za-z0-9._-]/g,"-").replace(/\.\./g,"-").slice(0,80)||"default";return bn(S(),"sessions",`${e}.seen`)}function _t(t){return t.replace(/[\t\r\n]+/g," ").trim().slice(0,gi)}function xn(t,e,n,r){try{let s=yi(t),i=_t(e),o=ci("sha256").update(n).digest("hex").slice(0,32),a="";try{a=fi(s,"utf8")}catch{}for(let c of a.split(`
32
- `)){let[u,l,f]=c.split(" ");if(u===i&&l===o)return{cmd:f??""}}di(bn(S(),"sessions"),{recursive:!0,mode:448}),li(s,`${i} ${o} ${_t(r)}
33
- `,{mode:384}),ui(s,384),mi(s).size>hi&&pi(s,{force:!0})}catch{}return null}function kn(t,e){return`[same output as \`${_t(t)}\` earlier in this session, unchanged, ~${Math.round(e/4)} tokens]`}var Il=new Set(["Read","Grep","Glob","Bash"]),$l=10*1024*1024,Nl=1024,Pl=/^… \(?\d+ more lines omitted\)?$/,Ml=/^\[tkr restore [0-9a-f]{8,64}\]$/;function Ll(t){return Pl.test(t)||Ml.test(t)}function Fl(t,e){if(!t||typeof t=="string")return e;if(t.file?.content!=null)return{...t,file:{...t.file,content:e}};if(t.content!=null)return{...t,content:e};if(t.output!=null)return{...t,output:e};if(t.stdout!=null||t.stderr!=null)return{...t,stdout:e,stderr:""};if(Array.isArray(t.filenames)){let n=new Set(t.filenames),r=e.split(`
34
- `).filter(s=>n.has(s)||Ll(s));return{...t,filenames:r}}return e}function jl(t,e,n){return JSON.stringify({...n?{systemMessage:n}:{},hookSpecificOutput:{hookEventName:"PostToolUse",updatedToolOutput:Fl(t.tool_response,e)}})}var Bl=100,on=null;function zl(){let t=on;return on=null,t}function Is(t){let e=Math.round(t/4);return e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function Zl(t,e){try{if(Math.round((t-e)/4)<Bl)return;let n=$s(S(),"first-save");if(Rl(n))return;Cl(n,String(Date.now())),on=`Tokmizer just optimized its first command output here: ~${Is(t)} tokens down to ~${Is(e)}. Watch it add up: /tkr-gain`}catch{}}function Ul(t){return t?typeof t=="string"?t:t.file?.content!=null?t.file.content:t.content!=null?t.content:t.output!=null?t.output:t.stdout!=null||t.stderr!=null?[t.stdout??"",t.stderr??""].filter(Boolean).join(`
42
+ `,{mode:384}),vi(o,n)}}catch{}}N();import{readFileSync as Ai}from"node:fs";import{join as Ri}from"node:path";function Dn(){try{return JSON.parse(Ai(Ri(A(),"settings-cache.json"),"utf8")).enabled!==!1}catch{return!0}}N();import{createHash as Ci}from"node:crypto";import{appendFileSync as Ii,chmodSync as Oi,mkdirSync as Di,readFileSync as $i,rmSync as Ni,statSync as Pi}from"node:fs";import{join as $n}from"node:path";var Mi=256*1024,Li=80;function Fi(t){let e=t.replace(/[^A-Za-z0-9._-]/g,"-").replace(/\.\./g,"-").slice(0,80)||"default";return $n(A(),"sessions",`${e}.seen`)}function Tt(t){return t.replace(/[\t\r\n]+/g," ").trim().slice(0,Li)}function Nn(t,e,n,r){try{let s=Fi(t),i=Tt(e),o=Ci("sha256").update(n).digest("hex").slice(0,32),a="";try{a=$i(s,"utf8")}catch{}for(let c of a.split(`
43
+ `)){let[l,u,f]=c.split(" ");if(l===i&&u===o)return{cmd:f??""}}Di($n(A(),"sessions"),{recursive:!0,mode:448}),Ii(s,`${i} ${o} ${Tt(r)}
44
+ `,{mode:384}),Oi(s,384),Pi(s).size>Mi&&Ni(s,{force:!0})}catch{}return null}function Pn(t,e){return`[same output as \`${Tt(t)}\` earlier in this session, unchanged, ~${Math.round(e/4)} tokens]`}At();var ou=new Set(["Read","Grep","Glob","Bash"]),au=10*1024*1024,cu=1024,lu=/^… \(?\d+ more lines omitted\)?$/,uu=/^\[tkr restore [0-9a-f]{8,64}\]$/;function du(t){return lu.test(t)||uu.test(t)||t==="[YOLO: omitted]"}function ti(t,e){if(!t||typeof t=="string")return e;if(t.file?.content!=null)return{...t,file:{...t.file,content:e}};if(t.content!=null)return{...t,content:e};if(t.output!=null)return{...t,output:e};if(t.stdout!=null||t.stderr!=null)return{...t,stdout:e,stderr:""};if(Array.isArray(t.filenames)){let n=new Set(t.filenames),r=e.split(`
45
+ `).filter(s=>n.has(s)||du(s));return{...t,filenames:r}}return e}function fu(t,e,n){return JSON.stringify({...n?{systemMessage:n}:{},hookSpecificOutput:{hookEventName:"PostToolUse",updatedToolOutput:ti(t.tool_response,e)}})}var pu=100,gn=null;function mu(){let t=gn;return gn=null,t}function Xs(t){let e=Math.round(t/4);return e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function hu(t,e){try{if(Math.round((t-e)/4)<pu)return;let n=ei(A(),"first-save");if(nu(n))return;ru(n,String(Date.now())),gn=`Tokmizer just optimized its first command output here: ~${Xs(t)} tokens down to ~${Xs(e)}. Watch it add up: /tkr-gain`}catch{}}function Qs(t){return t?typeof t=="string"?t:t.file?.content!=null?t.file.content:t.content!=null?t.content:t.output!=null?t.output:t.stdout!=null||t.stderr!=null?[t.stdout??"",t.stderr??""].filter(Boolean).join(`
35
46
  `):Array.isArray(t.filenames)?t.filenames.join(`
36
- `):null:""}var Vl=64*1024;function Hl(t,e){try{if(!e||typeof e!="object")return;let n=$s(S(),"drift.jsonl");try{if(Dl(n).size>Vl)return}catch{}let r=Object.keys(e).slice(0,12);Ol(n,`${JSON.stringify({t:Math.floor(Date.now()/1e3),tool:t,keys:r})}
37
- `)}catch{}}function Kl(t){let e=t.tool_name??"tool",n=t.tool_input??{};return n.command?n.command.split(`
38
- `)[0].trim().slice(0,200):n.file_path?`${e.toLowerCase()} ${n.file_path}`:n.pattern?`${e.toLowerCase()} ${n.pattern}`:n.path?`${e.toLowerCase()} ${n.path}`:e.toLowerCase()}async function Wl(t){if(!t.tool_name||!Il.has(t.tool_name))return null;let e=t.tool_name==="Bash"?t.tool_input?.command??"":"",n=e.includes("tkr-exec");if(/\btkr(?:\.js)?\s+restore\b/.test(e))return null;let r=await Me();if(!r||!r.token||!vn())return null;if(t.session_id&&!n){let R=t.tool_input??{},be=R.command??R.file_path??R.pattern??R.path??"";be&&_n(t.session_id,{tool:t.tool_name,target:be.split(`
39
- `)[0].trim()})}if(t.tool_name==="Read"&&(t.tool_input?.offset!=null||t.tool_input?.limit!=null))return null;let s=Ul(t.tool_response);if(s==null)return Hl(t.tool_name,t.tool_response),null;if(!s)return null;let i=Buffer.byteLength(s,"utf8");if(i>$l||t.tool_name==="Bash"&&i<Nl)return null;if(t.tool_name==="Bash"&&t.session_id){let R=xn(t.session_id,t.agent_id??"main",s,e.split(`
40
- `)[0]??"");if(R){let{captureOriginalForRestore:be}=await Promise.resolve().then(()=>(sn(),rn));return be(s,kn(R.cmd,i))}}if(n)return null;let{loadSettingsCache:o,processOutput:a,captureForRestore:c,captureOriginalForRestore:u,FOLD_MARKER_RE:l,resolveAllowedFilters:f,gatingPlan:h,graceExceeded:_,recordEvent:A,recordTelemetry:T,recordStat:P,countedSaving:M,statCmdLabel:te,installDaemonResolver:Ne,closeDaemonResolver:Ns}=await Promise.resolve().then(()=>(sn(),rn)),mt=await o();if(!mt.enabled)return null;let an=h(r);Ne(an);let Ps=f(r.allowedFilters,_(r)),Ms=Kl(t),ht=`${t.tool_name.toLowerCase()}-tool`,Ls=`${ht}: ${Ms}`;try{let R=await a(Ls,s,Ps,{verbosity:mt.outputVerbosity,exitCode:t.tool_name==="Bash"?void 0:0});await A({cmd:ht,filterId:R.filterId,rawBytes:R.rawBytes,filteredBytes:R.filteredBytes,plan:an});let be=new RegExp(l.source,"m"),ne;R.filteredBytes>=R.rawBytes?ne=null:be.test(R.output)?ne=await u(s,R.output):ne=await c(R.droppedTail??null,R.output);let Fs=ne==null?R.rawBytes:Buffer.byteLength(ne,"utf8"),gt=hn().host,re=M(R.rawBytes,Fs,mn(gt));return ne!=null&&Zl(re.raw,re.filtered),P(re.raw,re.filtered,void 0,!1,gt,t.tool_name==="Bash"?"sh":void 0,t.tool_name==="Bash"?te(t.tool_input?.command??""):t.tool_name),await T({cmd:ht,tokensSaved:Math.round((re.raw-re.filtered)/4),rawTokens:Math.round(re.raw/4),optimized:R.filterId!=null,telemetryOptIn:mt.telemetryOptIn,host:gt}),ne}finally{Ns()}}async function Gl(){let t=await un();t||process.exit(0);let e;try{e=JSON.parse(t)}catch{process.exit(0)}let n=await Wl(e);n||process.exit(0),process.stdout.write(jl(e,n,zl()??void 0))}var Yl=process.argv[1]??"";fn(Yl,import.meta.url)&&Gl().catch(t=>{process.stderr.write(`tkr post-tool-use: ${t.message}
41
- `),process.exit(0)});export{jl as buildHookEnvelope,Wl as processToolOutput,zl as takeFirstSaveNotice};
47
+ `):null:""}var gu=64*1024;function yu(t,e){try{if(!e||typeof e!="object")return;let n=ei(A(),"drift.jsonl");try{if(iu(n).size>gu)return}catch{}let r=Object.keys(e).slice(0,12);su(n,`${JSON.stringify({t:Math.floor(Date.now()/1e3),tool:t,keys:r})}
48
+ `)}catch{}}function _u(t){let e=t.tool_name??"tool",n=t.tool_input??{};return n.command?n.command.split(`
49
+ `)[0].trim().slice(0,200):n.file_path?`${e.toLowerCase()} ${n.file_path}`:n.pattern?`${e.toLowerCase()} ${n.pattern}`:n.path?`${e.toLowerCase()} ${n.path}`:e.toLowerCase()}async function bu(t){let e=ee();if(!t.tool_name||!ou.has(t.tool_name))return null;let n=t.tool_name==="Bash"?t.tool_input?.command??"":"",r=n.includes("tkr-exec");if(/\btkr(?:\.js)?\s+restore\b/.test(n))return null;let s=await Ue();if(!s||!s.token||!Dn())return null;if(t.session_id&&!r){let C=t.tool_input??{},nt=C.command??C.file_path??C.pattern??C.path??"";nt&&On(t.session_id,{tool:t.tool_name,target:nt.split(`
50
+ `)[0].trim()})}if(t.tool_name==="Read"&&(t.tool_input?.offset!=null||t.tool_input?.limit!=null))return null;let i=Qs(t.tool_response);if(i==null)return yu(t.tool_name,t.tool_response),null;if(!i)return null;let o=Buffer.byteLength(i,"utf8");if(o>au||t.tool_name==="Bash"&&o<cu||r)return null;let{loadSettingsCache:a,processOutput:c,captureForRestore:l,captureOriginalForRestore:u,FOLD_MARKER_RE:f,resolveAllowedFilters:d,gatingPlan:g,graceExceeded:v,recordEvent:E,recordTelemetry:R,recordStat:O,countedSaving:U,statCmdLabel:ae,installDaemonResolver:I,closeDaemonResolver:ce}=await Promise.resolve().then(()=>(qs(),Js)),V=await a();if(!V.enabled)return null;let{slugKey:yn}=await Promise.resolve().then(()=>(Te(),or)),ze=g(s);I(ze);let _n=d(s.allowedFilters,v(s)),bn=new Set(V.filters.disabled.map(yn)),ni=bn.size>0?new Set([..._n].filter(C=>!bn.has(C))):_n,ri=_u(t),kt=`${t.tool_name.toLowerCase()}-tool`,si=`${kt}: ${ri}`;try{let C=await c(si,i,ni,{verbosity:V.outputVerbosity,yolo:e,exitCode:t.tool_name==="Bash"?void 0:0});if(C.filterId!=null&&t.tool_name==="Bash"&&t.session_id){let vn=Nn(t.session_id,t.agent_id??"main",i,n.split(`
51
+ `)[0]??"");if(vn){let xn=Pn(vn.cmd,o);return e?xn:await u(i,xn)}}await E({cmd:kt,filterId:C.filterId,rawBytes:C.rawBytes,filteredBytes:C.filteredBytes,plan:ze});let nt=new RegExp(f.source,"m"),z;C.filteredBytes>=C.rawBytes?z=null:e?z=C.output:nt.test(C.output)?z=await u(i,C.output):z=await l(C.droppedTail??null,C.output),e&&z!=null&&(z=Qs(ti(t.tool_response,z)));let ii=z==null?C.rawBytes:Buffer.byteLength(z,"utf8"),Et=Rn().host,le=U(C.rawBytes,ii,An(Et));return z!=null&&hu(le.raw,le.filtered),O(le.raw,le.filtered,void 0,!1,Et,t.tool_name==="Bash"?"sh":void 0,t.tool_name==="Bash"?ae(t.tool_input?.command??""):t.tool_name),await R({cmd:kt,tokensSaved:Math.round((le.raw-le.filtered)/4),rawTokens:Math.round(le.raw/4),optimized:C.filterId!=null,telemetryOptIn:V.telemetryOptIn,host:Et}),z}finally{ce()}}async function vu(){let t=await En();t||process.exit(0);let e;try{e=JSON.parse(t)}catch{process.exit(0)}let n=await bu(e);n||process.exit(0),process.stdout.write(fu(e,n,mu()??void 0))}var xu=process.argv[1]??"";Sn(xu,import.meta.url)&&vu().catch(t=>{process.stderr.write(`tkr post-tool-use: ${t.message}
52
+ `),process.exit(0)});export{fu as buildHookEnvelope,bu as processToolOutput,mu as takeFirstSaveNotice};