@tokmizer/plugin 0.9.50 → 0.9.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,41 +1,56 @@
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 ci=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 At=(t,e)=>{for(var n in e)ci(t,n,{get:e[n],enumerable:!0})};import li from"node:os";import{join as ot}from"node:path";function R(){return process.env.TOKMIZER_HOME||ot(li.homedir(),".tokmizer")}function He(){return ot(R(),"install-id")}function Ct(){return ot(R(),"content-cache")}function kn(t){return ot(Ct(),t)}var N=_(()=>{"use strict"});import{join as fi}from"node:path";import{mkdir as Mu,readFile as pi,writeFile as Lu,unlink as Fu,rename as Bu}from"node:fs/promises";function hi(){try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t&&t.length>0?t:"Etc/UTC"}catch{return"Etc/UTC"}}function gi(t){return t?.dir??R()}async function Ke(t){let e=gi(t);try{let n=await pi(fi(e,mi),"utf8"),r=JSON.parse(n);return{...r,lastSettingsRevision:r.lastSettingsRevision??0,timeZone:r.timeZone??hi(),bonusActive:r.bonusActive??!1,...r.bonusResetAt!==void 0?{bonusResetAt:r.bonusResetAt}:{}}}catch{return null}}var mi,at=_(()=>{"use strict";N();mi="state.json"});import{readFileSync as zi}from"node:fs";import{join as Zi}from"node:path";function ee(){try{return zi(Zi(R(),"yolo-mode"),"utf8")==="on"}catch{return!1}}var Ot=_(()=>{"use strict";N()});var T,Dt,y,H,Ge=_(()=>{(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})})(Dt||(Dt={}));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,Ui,P,ct=_(()=>{Ge();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"]),Ui=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 Vi,Y,$t=_(()=>{ct();Ge();Vi=(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=Vi});function Hi(t){Ln=t}function Ce(){return Ln}var Ln,lt=_(()=>{$t();Ln=Y});function h(t,e){let n=Ce(),r=We({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 We,Ki,D,x,ce,$,ut,dt,te,Ie,Nt=_(()=>{lt();$t();We=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}},Ki=[];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"}),ce=t=>({status:"dirty",value:t}),$=t=>({status:"valid",value:t}),ut=t=>t.status==="aborted",dt=t=>t.status==="dirty",te=t=>t.status==="valid",Ie=t=>typeof Promise<"u"&&t instanceof Promise});var Fn=_(()=>{});var b,Bn=_(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(b||(b={}))});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 Un(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 lo(t){return new RegExp(`^${Un(t)}$`)}function Vn(t){let e=`${Zn}T${Un(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 uo(t,e){return!!((e==="v4"||!e)&&no.test(t)||(e==="v6"||!e)&&so.test(t))}function fo(t,e){if(!Xi.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 po(t,e){return!!((e==="v4"||!e)&&ro.test(t)||(e==="v6"||!e)&&io.test(t))}function mo(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 Oe(t){if(t instanceof M){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=F.create(Oe(r))}return new M({...t._def,shape:()=>e})}else return t instanceof X?new X({...t._def,type:Oe(t.element)}):t instanceof F?F.create(Oe(t.unwrap())):t instanceof G?G.create(Oe(t.unwrap())):t instanceof K?K.create(t.items.map(e=>Oe(e))):t}function Mt(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=Mt(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=Mt(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 Hn(t,e){return new be({values:t,typeName:E.ZodEnum,...k(e)})}function zn(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Kn(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=zn(e,r),c=a.fatal??n??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!i){let o=zn(e,r),a=o.fatal??n??!0;s.addIssue({code:"custom",...o,fatal:a})}}):re.create()}var B,jn,S,Gi,Wi,Yi,Ji,qi,Xi,Qi,eo,to,Pt,no,ro,so,io,oo,ao,Zn,co,ne,le,ue,de,fe,De,pe,me,re,q,Z,$e,X,M,he,J,ft,ge,K,pt,Ne,Pe,mt,ye,_e,be,ve,se,j,F,G,xe,Ee,Me,ho,Ye,Je,ke,go,E,yo,Gn,Wn,_o,bo,Yn,vo,xo,Eo,ko,wo,So,To,Ro,Ao,Co,Io,Oo,Do,$o,No,Po,Mo,Lo,Fo,Bo,jo,zo,Zo,Uo,Vo,Ho,Ko,Go,Wo,Yo,Jo,qo,Xo,Qo,Jn=_(()=>{ct();lt();Bn();Nt();Ge();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}},jn=(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(Ie(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 jn(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(Ie(s)?s:Promise.resolve(s));return jn(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:E.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 he.create([this,e],this._def)}and(e){return ge.create(this,e,this._def)}transform(e){return new j({...k(this._def),schema:this,typeName:E.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new xe({...k(this._def),innerType:this,defaultValue:n,typeName:E.ZodDefault})}brand(){return new Ye({typeName:E.ZodBranded,type:this,...k(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new Ee({...k(this._def),innerType:this,catchValue:n,typeName:E.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Je.create(this,e)}readonly(){return ke.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Gi=/^c[^\s-]{8,}$/i,Wi=/^[0-9a-z]+$/,Yi=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ji=/^[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,qi=/^[a-z0-9_-]{21}$/i,Xi=/^[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)?)??$/,eo=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,to="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",no=/^(?:(?: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])$/,ro=/^(?:(?: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])$/,so=/^(([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]))$/,io=/^(([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])$/,oo=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ao=/^([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])))",co=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")eo.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")Pt||(Pt=new RegExp(to,"u")),Pt.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")Ji.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")qi.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")Gi.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")Wi.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")Yi.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"?Vn(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"?co.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:p.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?lo(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"?uo(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"?fo(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"?po(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"?oo.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64",code:p.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?ao.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:E.ZodString,coerce:t?.coerce??!1,...k(t)});le=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"?mo(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)}};le.create=t=>new le({checks:[],typeName:E.ZodNumber,coerce:t?.coerce||!1,...k(t)});ue=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}};ue.create=t=>new ue({checks:[],typeName:E.ZodBigInt,coerce:t?.coerce??!1,...k(t)});de=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)}};de.create=t=>new de({typeName:E.ZodBoolean,coerce:t?.coerce||!1,...k(t)});fe=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}};fe.create=t=>new fe({checks:[],coerce:t?.coerce||!1,typeName:E.ZodDate,...k(t)});De=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)}};De.create=t=>new De({typeName:E.ZodSymbol,...k(t)});pe=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)}};pe.create=t=>new pe({typeName:E.ZodUndefined,...k(t)});me=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)}};me.create=t=>new me({typeName:E.ZodNull,...k(t)});re=class extends S{constructor(){super(...arguments),this._any=!0}_parse(e){return $(e.data)}};re.create=t=>new re({typeName:E.ZodAny,...k(t)});q=class extends S{constructor(){super(...arguments),this._unknown=!0}_parse(e){return $(e.data)}};q.create=t=>new q({typeName:E.ZodUnknown,...k(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:E.ZodNever,...k(t)});$e=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)}};$e.create=t=>new $e({typeName:E.ZodVoid,...k(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:E.ZodArray,...k(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:E.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 Oe(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 Hn(T.objectKeys(this.shape))}};M.create=(t,e)=>new M({shape:()=>t,unknownKeys:"strip",catchall:Z.create(),typeName:E.ZodObject,...k(e)});M.strictCreate=(t,e)=>new M({shape:()=>t,unknownKeys:"strict",catchall:Z.create(),typeName:E.ZodObject,...k(e)});M.lazycreate=(t,e)=>new M({shape:t,unknownKeys:"strip",catchall:Z.create(),typeName:E.ZodObject,...k(e)});he=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}};he.create=(t,e)=>new he({options:t,typeName:E.ZodUnion,...k(e)});J=t=>t instanceof ye?J(t.schema):t instanceof j?J(t.innerType()):t instanceof _e?[t.value]:t instanceof be?t.options:t instanceof ve?T.objectValues(t.enum):t instanceof xe?J(t._def.innerType):t instanceof pe?[void 0]:t instanceof me?[null]:t instanceof F?[void 0,...J(t.unwrap())]:t instanceof G?[null,...J(t.unwrap())]:t instanceof Ye||t instanceof ke?J(t.unwrap()):t instanceof Ee?J(t._def.innerType):[],ft=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:E.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...k(r)})}};ge=class extends S{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(ut(i)||ut(o))return x;let a=Mt(i.value,o.value);return a.valid?((dt(i)||dt(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}))}};ge.create=(t,e,n)=>new ge({left:t,right:e,typeName:E.ZodIntersection,...k(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:E.ZodTuple,rest:null,...k(e)})};pt=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:E.ZodRecord,...k(r)}):new t({keyType:ne.create(),valueType:e,typeName:E.ZodRecord,...k(n)})}},Ne=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}}}};Ne.create=(t,e,n)=>new Ne({valueType:e,keyType:t,typeName:E.ZodMap,...k(n)});Pe=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)}};Pe.create=(t,e)=>new Pe({valueType:t,minSize:null,maxSize:null,typeName:E.ZodSet,...k(e)});mt=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 We({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Ce(),Y].filter(l=>!!l),issueData:{code:p.invalid_arguments,argumentsError:c}})}function s(a,c){return We({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Ce(),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:E.ZodFunction,...k(r)})}},ye=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})}};ye.create=(t,e)=>new ye({getter:t,typeName:E.ZodLazy,...k(e)});_e=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}};_e.create=(t,e)=>new _e({value:t,typeName:E.ZodLiteral,...k(e)});be=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})}};be.create=Hn;ve=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}};ve.create=(t,e)=>new ve({values:t,typeName:E.ZodNativeEnum,...k(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:E.ZodPromise,...k(e)});j=class extends S{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===E.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"?ce(c.value):n.value==="dirty"?ce(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"?ce(a.value):n.value==="dirty"?ce(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:E.ZodEffects,effect:e,...k(n)});j.createWithPreprocess=(t,e,n)=>new j({schema:e,effect:{type:"preprocess",transform:t},typeName:E.ZodEffects,...k(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:E.ZodOptional,...k(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:E.ZodNullable,...k(e)});xe=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}};xe.create=(t,e)=>new xe({innerType:t,typeName:E.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...k(e)});Ee=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 Ie(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}};Ee.create=(t,e)=>new Ee({innerType:t,typeName:E.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...k(e)});Me=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}}};Me.create=t=>new Me({typeName:E.ZodNaN,...k(t)});ho=Symbol("zod_brand"),Ye=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}},Je=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(),ce(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:E.ZodPipeline})}},ke=class extends S{_parse(e){let n=this._def.innerType._parse(e),r=s=>(te(s)&&(s.value=Object.freeze(s.value)),s);return Ie(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};ke.create=(t,e)=>new ke({innerType:t,typeName:E.ZodReadonly,...k(e)});go={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"})(E||(E={}));yo=(t,e={message:`Input not instance of ${t.name}`})=>Kn(n=>n instanceof t,e),Gn=ne.create,Wn=le.create,_o=Me.create,bo=ue.create,Yn=de.create,vo=fe.create,xo=De.create,Eo=pe.create,ko=me.create,wo=re.create,So=q.create,To=Z.create,Ro=$e.create,Ao=X.create,Co=M.create,Io=M.strictCreate,Oo=he.create,Do=ft.create,$o=ge.create,No=K.create,Po=pt.create,Mo=Ne.create,Lo=Pe.create,Fo=mt.create,Bo=ye.create,jo=_e.create,zo=be.create,Zo=ve.create,Uo=se.create,Vo=j.create,Ho=F.create,Ko=G.create,Go=j.createWithPreprocess,Wo=Je.create,Yo=()=>Gn().optional(),Jo=()=>Wn().optional(),qo=()=>Yn().optional(),Xo={string:(t=>ne.create({...t,coerce:!0})),number:(t=>le.create({...t,coerce:!0})),boolean:(t=>de.create({...t,coerce:!0})),bigint:(t=>ue.create({...t,coerce:!0})),date:(t=>fe.create({...t,coerce:!0}))},Qo=x});var m={};At(m,{BRAND:()=>ho,DIRTY:()=>ce,EMPTY_PATH:()=>Ki,INVALID:()=>x,NEVER:()=>Qo,OK:()=>$,ParseStatus:()=>D,Schema:()=>S,ZodAny:()=>re,ZodArray:()=>X,ZodBigInt:()=>ue,ZodBoolean:()=>de,ZodBranded:()=>Ye,ZodCatch:()=>Ee,ZodDate:()=>fe,ZodDefault:()=>xe,ZodDiscriminatedUnion:()=>ft,ZodEffects:()=>j,ZodEnum:()=>be,ZodError:()=>P,ZodFirstPartyTypeKind:()=>E,ZodFunction:()=>mt,ZodIntersection:()=>ge,ZodIssueCode:()=>p,ZodLazy:()=>ye,ZodLiteral:()=>_e,ZodMap:()=>Ne,ZodNaN:()=>Me,ZodNativeEnum:()=>ve,ZodNever:()=>Z,ZodNull:()=>me,ZodNullable:()=>G,ZodNumber:()=>le,ZodObject:()=>M,ZodOptional:()=>F,ZodParsedType:()=>y,ZodPipeline:()=>Je,ZodPromise:()=>se,ZodReadonly:()=>ke,ZodRecord:()=>pt,ZodSchema:()=>S,ZodSet:()=>Pe,ZodString:()=>ne,ZodSymbol:()=>De,ZodTransformer:()=>j,ZodTuple:()=>K,ZodType:()=>S,ZodUndefined:()=>pe,ZodUnion:()=>he,ZodUnknown:()=>q,ZodVoid:()=>$e,addIssueToContext:()=>h,any:()=>wo,array:()=>Ao,bigint:()=>bo,boolean:()=>Yn,coerce:()=>Xo,custom:()=>Kn,date:()=>vo,datetimeRegex:()=>Vn,defaultErrorMap:()=>Y,discriminatedUnion:()=>Do,effect:()=>Vo,enum:()=>zo,function:()=>Fo,getErrorMap:()=>Ce,getParsedType:()=>H,instanceof:()=>yo,intersection:()=>$o,isAborted:()=>ut,isAsync:()=>Ie,isDirty:()=>dt,isValid:()=>te,late:()=>go,lazy:()=>Bo,literal:()=>jo,makeIssue:()=>We,map:()=>Mo,nan:()=>_o,nativeEnum:()=>Zo,never:()=>To,null:()=>ko,nullable:()=>Ko,number:()=>Wn,object:()=>Co,objectUtil:()=>Dt,oboolean:()=>qo,onumber:()=>Jo,optional:()=>Ho,ostring:()=>Yo,pipeline:()=>Wo,preprocess:()=>Go,promise:()=>Uo,quotelessJson:()=>Ui,record:()=>Po,set:()=>Lo,setErrorMap:()=>Hi,strictObject:()=>Io,string:()=>Gn,symbol:()=>xo,transformer:()=>Vo,tuple:()=>No,undefined:()=>Eo,union:()=>Oo,unknown:()=>So,util:()=>T,void:()=>Ro});var Lt=_(()=>{lt();Nt();Fn();Ge();Jn();ct()});var Le=_(()=>{Lt();Lt()});var Fe,ht=_(()=>{"use strict";Le();Fe=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 ea,readFile as ta}from"node:fs/promises";import{join as Qn,dirname as na}from"node:path";import{fileURLToPath as ra}from"node:url";function ia(){return process.env.TOKMIZER_DEV==="1"||process.env.TOKMIZER_DEV==="true"}async function er(){if(ie)return ie;if(!ia())return!Xn&&process.env.TOKMIZER_DEBUG==="1"&&(process.stderr.write(`tokmizer: disk loader disabled (set TOKMIZER_DEV=1 to re-enable for local dev).
3
+ `),Xn=!0),ie=new Map,ie;let t=new Map,e,n;try{e=(await import("smol-toml")).parse,n=(await ea(qn)).filter(r=>r.endsWith(".toml"))}catch{return ie=t,ie}for(let r of n){let s=await ta(Qn(qn,r),"utf8"),o=e(s).filters;if(o)for(let[a,c]of Object.entries(o)){let l=Fe.parse({slug:a,...c});t.set(a,{...l,matchRegex:new RegExp(l.match_command)})}}return ie=t,ie}var sa,qn,ie,Xn,tr=_(()=>{"use strict";ht();sa=na(ra(import.meta.url)),qn=process.env.TOKMIZER_FILTERS_DIR||Qn(sa,"..","..","filters"),ie=null,Xn=!1});var ar={};At(ar,{FREE_FALLBACK:()=>or,OutputVerbosity:()=>sr,ReducerLevel:()=>ir,Settings:()=>Be,resolveAllowedFilters:()=>qe,slugKey:()=>W});import{createHash as oa}from"node:crypto";function W(t){let e=nr.get(t);return e||(e=oa("sha256").update(`tkr:${t}`).digest("hex").slice(0,16),nr.set(t,e)),e}function qe(t,e=!1){return e||!t||t.length===0?(rr??=new Set(or.map(W)),new Set(rr)):new Set(t.map(n=>aa.test(n)?n:W(n)))}var sr,ir,Be,or,aa,nr,rr,we=_(()=>{"use strict";Le();sr=m.enum(["normal","compact","minimal"]),ir=m.enum(["off","light","balanced","max"]),Be=m.object({enabled:m.boolean().default(!0),telemetryOptIn:m.boolean().default(!0),outputVerbosity:sr.default("compact"),reducer:ir.default("off"),filters:m.object({enableAll:m.boolean().default(!0),disabled:m.array(m.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})}),or=["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"],aa=/^[0-9a-f]{16}$/,nr=new Map;rr=null});function la(t){if(!t)return"*";let e=cr.get(t);return e===void 0&&(e=[...t].join(","),cr.set(t,e)),e}function gt(t,e,n){let r=`${t}::${la(n)}`,s=je.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(je.size>=ca){let o=je.keys().next().value;o&&je.delete(o)}return je.set(r,i),i}function lr(){je.clear()}var je,ca,cr,Ft=_(()=>{"use strict";we();je=new Map,ca=256,cr=new WeakMap});function Se(t){return t.replace(ua,"").replace(da,"")}var ua,da,yt=_(()=>{"use strict";ua=/\x1b\[[0-9;?]*[ -/]*[@-~]/g,da=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g});function ur(t,e){return e.length===0?t:t.filter(n=>!e.some(r=>r.test(n)))}var dr=_(()=>{"use strict"});function fr(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 pr=_(()=>{"use strict"});function _t(t){return`\u2026 (${t} more lines omitted)`}function mr(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),_t(s.length),...t.slice(t.length-r)],dropped:s}}var hr=_(()=>{"use strict"});function gr(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)fa.test(a)&&!oe.test(a)?(o.push(a),s+=1):(i(o),o=[],s=0,r.push(a));return i(o),r}var fa,oe,Bt=_(()=>{"use strict";fa=/^\s*(?:[✓✔√]|ok )/,oe=/✕|✗|×|\bFAIL\b|\bERROR\b|\bFATAL\b|\bError|\berror|Expected|Received|\bfailed\b|^\s*Tests?:|^\s*Test Suites?:/});function yr(t){return t.map(e=>e.replace(pa,n=>{let r=n.split("/").filter(Boolean);return r.length<=2?n:`\u2026/${r.slice(-2).join("/")}`}))}var pa,_r=_(()=>{"use strict";pa=/(?:\/[\w.@+-]+){3,}/g});function _a(t){let e=ga.exec(t);return!e||ya.has(e[1])?!1:!/=>|\bfunction\b/.test(e[2])}function va(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 xa(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==="&"))&&va(t,s+1,i)&&(r=i),s+=1;continue}i==="{"||i==="("||i==="["?n+=1:(i==="}"||i===")"||i==="]")&&(n-=1),s+=1}return n}function jt(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 bt(t){let e=[],n=0;for(;n<t.length;){let r=t[n];if(ma.test(r)&&ha.test(r)||_a(r)||ba.test(r)){let s={inBlockComment:!1,inTemplate:!1},i=0,o=n,a=!1;for(;o<t.length&&o-n<200;)if(i+=xa(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 vt(t){let e=t.slice(0,4096);return!(!ka.test(e)||e.split(`
4
+ `).length<6)}var ma,ha,ga,ya,ba,br,Ea,ka,Xe=_(()=>{"use strict";ma=/^(\s*)(?:export\s+)?(?:async\s+)?(?:function|interface|type|const|let|var|def|fn|impl|trait|struct|enum)\s+[\w$]+/,ha=/\{\s*$/,ga=/^\s*(?:(?:public|private|protected|static|async|get|set|readonly|override)\s+)*([\w$]+)\s*\(([^)]*)\)\s*(?::\s*[^{]+)?\{\s*$/,ya=new Set(["if","for","while","switch","catch","do","with","return","else","function","await","yield"]);ba=/^\s*(?:if|for|while|switch|try|do)\b[^{}]*\{\s*$/;br=/^\s*… \d+ lines? folded …$/,Ea=/^\s*… (\d+) lines? folded …$/;ka=/\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(Sa.test(s.replace(wa,""))&&!Ta.test(s)&&!Ra.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 Er(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 wa,Sa,Ta,Ra,kr=_(()=>{"use strict";Bt();wa=/^\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*/,Sa=/^\s*(?:\[(?:DEBUG|TRACE|INFO|VERBOSE)\]|(?:DEBUG|TRACE|INFO|VERBOSE)(?!\s*:))(?=\s|:|$)(?!\s*[+\-*\/%&|^?]*=)/,Ta=new RegExp(oe.source,"i"),Ra=/\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 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(!Aa.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 Da(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 $a(t){let e=[],n=[],r=!1;for(let d of t){if(/^total\s+\d+/.test(d))continue;if(Ca.test(d.trim()))return t;let g=Oa(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?"":Ia(d.size);a.push(v?`${g.padEnd(o)} ${v}`:g)}if(a.length>zt){let d=a.length-zt;a=[...a.slice(0,zt),`\u2026 ${d} more lines omitted`]}let c=n.length===1?"file":"files",l=e.length===1?"dir":"dirs",u=Da(n),f=`${n.length} ${c}, ${e.length} ${l}`+(u?` (${u})`:"");return a.push(f),a}var Aa,Ca,zt,Tr=_(()=>{"use strict";Q();Aa=/^[dbclps\-][rwxsStT\-]{9}[@.+]?(?:\s|$)/,Ca=/^[./~][^\s]*:$/,zt=1e3;L("smart-ls",$a)});var Rr=_(()=>{"use strict";Xe();Q();L("smart-read",t=>bt(t))});function Na(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):"",w=g>=0?d.slice(g+1):d;if(!w)continue;let A=r.get(v)??[];A.push(/\s/.test(w)?`"${w}"`:w),r.set(v,A),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>Ar){let u=Math.max(0,Ar-s.length),f=l.length-u;return[...l.slice(0,u),`\u2026 ${f} more lines omitted`,...s]}return[...l,...s]}var Ar,Cr=_(()=>{"use strict";Q();Ar=1e3;L("smart-find",Na)});function Dr(t){let e=t.trim();return e.length>Ir?`${e.slice(0,Ir)}\u2026`:e}function ja(t){let e=[],n="";for(let r of t){let s=n?`${n}, ${r}`:r;s.length>Ma&&n?(e.push(`${n},`),n=r):n=s}return n&&e.push(n),e}function za(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=La.exec(f),g=Fa.exec(f);if(d&&g)return t;let v=d||g?null:Ba.exec(f),w=(d??g??v)?.[1];if(!w)return t;let A=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(w)??[];O.push(A),n.set(w,O),A.context||(i+=1,r.set(w,(r.get(w)??0)+1)),o+=1,s=w}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>Pa?ja(a.map(f=>`${f} (${r.get(f)??0})`)):[],u=[`${i}m ${a.length}f:`,...l,"",...c];if(u.length>Zt){let f=u.length-Zt;return[...u.slice(0,Zt),`\u2026 ${f} more lines omitted`]}return u}var Zt,Ir,Pa,Ma,La,Fa,Ba,Or,$r=_(()=>{"use strict";Q();Zt=1e3,Ir=200,Pa=60,Ma=190,La=/^([^\s:]+):(\d+):(.*)$/,Fa=/^([^:]+?)-(\d+)-(.*)$/,Ba=/^([^\s:]+):(.*)$/,Or=/(?:^|\/)(?:__tests__|tests?|spec|fixtures?|__mocks__|__snapshots__)\/|\.(?:test|spec)\.[^/]+$/i;L("smart-grep",za)});function Ha(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=Za.test(u),d=f?l.slice(s):l,g=Ua.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<=Va?e.push(l):(r+=1,i=f?u:"");continue}c(),e.push(l)}return c(),e}var Nr,Za,Ua,Va,Pr=_(()=>{"use strict";Q();Nr=/^(?:([|\\/ ._-]*\*[|\\/* ._-]* ))?commit [0-9a-f]{7,40}\b/,Za=/^[|\\/* ._-]*$/,Ua=/^ {4}/,Va=2;L("smart-log",Ha)});var Ka,Ga,Wa,Mr=_(()=>{"use strict";Q();Ka=/^[\s=]+$/,Ga=/^\s*=+\s+(.*?)\s+=+\s*$/,Wa=512;L("strip-banners",t=>{let e=[];for(let n of t){if(Ka.test(n))continue;let r=n.length<=Wa?Ga.exec(n):null;e.push(r?r[1]:n)}return e})});function Ya(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",Ya)});function Ja(t){return t==="compact"?.6:t==="minimal"?.3:1}function Xa(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 Ut(t,e,n).text}function Ut(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=Se(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))):ur(a,s.stripRegexes)),r!=="normal"&&!e.preserve_exact&&(a=xr(a),a=Er(a)),r==="minimal"&&!e.preserve_exact&&(a=vr(a),(e.slug==="vitest"||e.slug==="npm-test")&&(a=Xa(a))),!e.preserve_exact&&(n.smartCode||n.smartCode===void 0&&r!=="normal"&&vt(i))&&(a=bt(a)),e.transform){let f=Sr(e.transform);f&&(a=f(a))}let c=e.slug==="read-tool";if(!c){let f=jt(a);f.some(Boolean)&&(a=a.filter((d,g)=>!f[g]))}e.mask_abs_paths&&(a=yr(a)),e.fold_passing&&(a=gr(a,e.fold_passing_threshold??5)),e.truncate_lines_at&&(a=fr(a,e.truncate_lines_at));let l=null;if(e.max_lines){let f=e.scale_with_level?Ja(n.verbosity):1,d=Math.min(e.max_lines,Math.max(qa,Math.round(e.max_lines*f))),g=c?jt(a):null,v=g?g.filter(w=>!w).length:a.length;if(v>d){let w=d;if(g){let O=0;for(w=0;w<a.length&&O<d;)g[w]||(O+=1),w+=1}let A=v-d;if(e.keep_failures){let O=a.slice(w),U=O.filter(V=>!oe.test(V)),Te=O.reduce((V,Re,C)=>V+(!oe.test(Re)&&!g?.[w+C]?1:0),0);l=U.length>0?U.join(`
7
+ `):null,a=[...a.slice(0,w),...Te>0?[_t(Te)]:[],...O.filter(V=>oe.test(V))]}else if(c)l=a.slice(w).join(`
8
+ `),a=[...a.slice(0,w),_t(A)];else{let{kept:O,dropped:U}=mr(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 qa,Fr,jr=_(()=>{"use strict";yt();dr();pr();hr();Bt();_r();Xe();kr();Q();Tr();Rr();Cr();$r();Pr();Mr();Lr();qa=20;Fr=new WeakMap});function zr(t){if(!t)return!1;for(let e of Se(t).split(`
12
+ `))if(!/^\s*[✓✔√]\s/.test(e)&&ec.some(n=>n.test(e)))return!0;return!1}var ec,Zr=_(()=>{"use strict";yt();ec=[/\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 ze(t){let e=t.trim(),n=e.split(/\s+/),r=0;for(;r<n.length;){let a=n[r];if(nc.test(a)){r++;continue}if(tc.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 sc(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 Ht(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=ze(n).split(/\s+/)[0]??"";if(!rc.has(r))return null}return sc(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=Vt.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=Ht(n),s=r?ze(r):null;return s&&s!==t?[s,t]:[t]}var tc,nc,Vt,rc,Kr=_(()=>{"use strict";tc=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),nc=/^[A-Za-z_][A-Za-z0-9_]*=/,Vt=/^([a-z]+)-tool(?::\s|$)/;rc=new Set(["cd","export","source","set","unset","mkdir","true",":","pushd","popd","alias","ulimit","umask","echo","printf","sleep","touch","rm","cp","mv","chmod","ln"])});function Kt(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 cc(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 lc(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=>ic.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(oc.test(g))continue;if(/…|\.\.\./.test(g))return t;let v;if(s>=0){if(/[^\x20-\x7e]/.test(g))return t;let w=i.map((A,O)=>g.slice(A,i[O+1]));if(w.slice(0,-1).some(A=>A[0]===" "||!A.endsWith(" "))||(v=w.map(A=>A.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])||!ac.test(v[4])||!Number.isFinite(Date.parse(v[4])))return t;if(v.some(w=>/[\u0000-\u001f\u007f]/.test(w)))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}`,w=JSON.stringify(d).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),A=`TITLE ${v} = ${w}`;g*(Buffer.byteLength(d)-Buffer.byteLength(v))<=Buffer.byteLength(A)+1||(l.set(d,v),u.push(A))}if(u.length===0)return a;for(let{index:d,cells:g}of o)r[d]=g.map((v,w)=>w===1?l.get(v)??v:v).join(" ");let f=[...r,"",...u].join(`
24
+ `)+n;return Buffer.byteLength(f)<Buffer.byteLength(a)?f:a}function Gt(t,e,n){if(e!=="compact"&&e!=="minimal")return t;let r=t;if(/^[ \t\r\n]*[\[{]/.test(t)){try{JSON.parse(t)}catch{return t}r=cc(t,e==="minimal")}else n==="gh"&&(r=lc(t,e==="minimal"));return Buffer.byteLength(r)<Buffer.byteLength(t)?r:t}var ic,oc,ac,Yr=_(()=>{"use strict";ic=/^ID {2,}TITLE {2,}BRANCH {2,}STATE {2,}CREATED *$/,oc=/^… \([1-9]\d* more lines omitted\)$/,ac=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/});function Jr(t){if(Buffer.byteLength(t)<2048||vt(t)||dc.test(t))return t;let e=t.split(`
25
+ `),n=[];for(let r=0;r<e.length;){let s=e[r],i=r+1;if(uc.test(s))for(;i<e.length&&e[i]===s;)i+=1;let o=i-r,a=`[tkr: previous log line repeated ${o-1} additional times]`;if(o>=3&&Buffer.byteLength(a)+1<(o-1)*(Buffer.byteLength(s)+1))n.push(s,a);else for(let c=r;c<i;c+=1)n.push(s);r=i}return n.join(`
26
+ `)}var uc,dc,qr=_(()=>{"use strict";Xe();uc=/^(?:\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?Z?\s+)?(?:\[(?:DEBUG|TRACE|INFO|WARN|WARNING|ERROR|FATAL)\]|DEBUG|TRACE|INFO|WARN|WARNING|ERROR|FATAL)(?::|\s|$)/,dc=/^\[tkr: previous log line repeated \d+ additional times\]$/m});function Wt(t){Xr=t}async function fc(t,e){let n=await er();return gt(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=ze(Vr(t.startsWith("bash-tool: ")?t.slice(11):t)),l=i!=null&&i!==0&&!(i===1&&pc.test(c)),u=Xr??fc,f=null;for(let C of Hr(t))if(f=await u(C,n),f)break;!f&&s>=mc&&!Vt.test(t)&&(f=await u(`bash-tool: ${t}`,n));let d=Ht(t.startsWith("bash-tool: ")?t.slice(11):t),g=f?.slug==="git-log"&&d!=null&&/^git\s+log(?:\s|$)/.test(ze(d)),v=i==null&&(g?/^(?:fatal|error):/im.test(Se(e)):zr(e)),w=f?.transform==="smart-read"&&s<=16384&&(e.endsWith(`
27
+ `)?e.slice(0,-1):e).split(`
28
+ `).length<=200,A=s<=16384&&d!=null&&/^(?:head|tail)(?:\s|$)|^sed\s+(?:(?:-[Eru]+|--(?:regexp-extended|unbuffered|sandbox))\s+)*(?:-[Enruse]*n[Enruse]*(?:\s|$)|--(?:quiet|silent)(?:\s|$))/.test(ze(d));if(!o&&(A||w&&a.smartCode!==!0))return{output:e,filterId:f?.slug??null,rawBytes:s,filteredBytes:s,debugBypass:l||v,droppedTail:null};if(!f||(l||v)&&f.preserve_exact&&!o)return{output:e,filterId:null,rawBytes:s,filteredBytes:s,debugBypass:l||v,...o?{droppedTail:null}:{}};let O=C=>{if(!o)return C;let Ue=C.filteredBytes>s||s>0&&C.output.length===0?e:C.output,Ae=!C.debugBypass&&!f?.preserve_exact?Gt(Ue,"minimal",C.filterId??""):Ue,Ve=Kt(Ae)===Ae?Ae:Kt(Ue);return{...C,output:Ve,filteredBytes:Buffer.byteLength(Ve,"utf8"),droppedTail:null}};if(l||v){let C=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?Se(e):e;return!o&&a.verbosity==="minimal"&&f.transform!=="smart-read"&&(C=Jr(C)),O({output:C,filterId:f.slug,rawBytes:s,filteredBytes:Buffer.byteLength(C,"utf8"),debugBypass:!0})}let{text:U,droppedTail:Te}=Ut(e,f,o?{...a,verbosity:"minimal"}:a),V=!o&&!f.preserve_exact?Gt(U,a.verbosity,f.slug):U,Re=Buffer.byteLength(V,"utf8");return e.trim().length>0&&Re>=s?O({output:e,filterId:f.slug,rawBytes:s,filteredBytes:s,debugBypass:!1,droppedTail:null}):O({output:V,filterId:f.slug,rawBytes:s,filteredBytes:Re,debugBypass:!1,droppedTail:Te})}var Xr,pc,mc,Yt=_(()=>{"use strict";tr();Ft();jr();Zr();Kr();Wr();yt();Yr();qr();Xr=null;pc=/^(?:grep|rg|find|eslint|ruff|flake8|mypy|prettier|biome|black|stylelint)(?:\s|$)|^git\s+(?:diff|grep)\b/,mc=2048});import{chmod as hc,mkdir as gc,readFile as Xf,writeFile as yc,stat as Qf,readdir as ep,rm as es,rename as _c}from"node:fs/promises";import{createHash as ts}from"node:crypto";function xc(t,e){let n=Number(process.env[t]);return Number.isFinite(n)&&n>0?n:e}async function ns(t,e){if(ee()||!vc.test(t)||Buffer.byteLength(e,"utf8")>xc("TOKMIZER_CCR_ENTRY_MAX_BYTES",bc))return!1;let n=kn(t),r=`${n}.tmp-${process.pid}-${process.hrtime.bigint()}`;try{return await gc(Ct(),{recursive:!0}),ee()?!1:(await yc(r,e,{mode:384}),await hc(r,384),ee()?(await es(r,{force:!0}),!1):(await _c(r,n),!0))}catch{try{await es(r)}catch{}return!1}}async function rs(t,e){let n=process.env.TOKMIZER_CCR_DISABLED;if(n==="1"||n==="true"||ee()||!t)return e;let r=ts("sha256").update(t).digest("hex").slice(0,16),s=`
29
+ [tkr restore ${r}]`;return Buffer.byteLength(t,"utf8")<=Buffer.byteLength(s,"utf8")||!await ns(r,t)?e:`${e}${s}`}async function ss(t,e){let n=process.env.TOKMIZER_CCR_DISABLED;if(n==="1"||n==="true"||ee()||!t)return e;let r=ts("sha256").update(t).digest("hex").slice(0,16);return await ns(r,t)?`${e}
30
+ [tkr restore ${r}]`:e}var sp,ip,bc,vc,is=_(()=>{"use strict";N();Ot();sp=10080*60*1e3,ip=100*1024*1024,bc=2*1024*1024,vc=/^[0-9a-f]{8,64}$/i});function Ec(){let t=Number(process.env.TOKMIZER_OFFLINE_GRACE_MS);return Number.isFinite(t)&&t>0?t:6048e5}function os(t,e=Date.now()){let n=t.lastHeartbeatOkAt;if(typeof n=="number"&&e-n>Ec())return!0;if(t.subEndsAt){let r=Date.parse(t.subEndsAt);if(Number.isFinite(r)&&e>r)return!0}return!1}function as(t,e=Date.now()){return t.plan}var cs=_(()=>{"use strict"});function Qe(t){let e=t;for(let[n,r]of kc)e=e.replace(n,r);return e}var kc,Jt=_(()=>{"use strict";kc=[[/(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 up,randomUUID as wc}from"node:crypto";import{readFile as ls,writeFile as us,mkdir as Sc}from"node:fs/promises";async function qt(){try{let n=(await ls(He(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(n))return n}catch{}await Sc(R(),{recursive:!0});let t=wc();try{return await us(He(),t,{mode:384,flag:"wx"}),t}catch{try{let e=(await ls(He(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(e))return e}catch{}return await us(He(),t,{mode:384}),t}}var Xt=_(()=>{"use strict";N()});import{createRequire as Tc}from"node:module";function Ac(){for(let t of["../package.json","../../package.json"])try{let e=Rc(t).version;if(typeof e=="string"&&e)return e}catch{}return"0.0.0"}var Rc,Qt,en=_(()=>{"use strict";Rc=Tc(import.meta.url);Qt=Ac()});var ds,fs=_(()=>{"use strict";ds=`-----BEGIN PUBLIC KEY-----
16
31
  MCowBQYDK2VwAyEAj/kMlXlhTIGHRKxOKMuGFa1S1ybxxwgdYcAE0YM9fgU=
17
32
  -----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(`
33
+ `});function ps(){return((process.env.TOKMIZER_DEV==="1"?process.env.TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM:void 0)??ds).replace(/\\n/g,`
34
+ `)}var bp,tn=_(()=>{"use strict";en();fs();bp=300*1e3});import{readFile as Cc,writeFile as Ep,mkdir as kp,chmod as wp,rm as Sp,rename as Tp,readdir as Rp}from"node:fs/promises";import{join as Ic}from"node:path";async function et(){try{let t=await Cc(Ic(R(),Oc),"utf8"),e=JSON.parse(t);return Be.parse({...ms,...e})}catch{return ms}}var Oc,ms,Op,xt=_(()=>{"use strict";we();N();Oc="settings-cache.json",ms=Be.parse({}),Op=Be.partial().extend({filters:Be.shape.filters.removeDefault().partial().optional()})});import{join as hs}from"node:path";import{appendFileSync as $c,chmodSync as Nc,existsSync as Pc,mkdirSync as Mc,readFileSync as Mp,renameSync as Lp,rmdirSync as Fp,statSync as Lc,unlinkSync as Bp,utimesSync as jp,writeFileSync as zp}from"node:fs";function gs(){return hs(R(),"spool")}function Bc(t){return hs(gs(),`${t}.jsonl`)}function Et(t,e){try{Mc(gs(),{recursive:!0,mode:448});let n=Bc(t);if(Pc(n)&&Lc(n).size>=Fc)return;$c(n,JSON.stringify(e)+`
35
+ `,{mode:384}),Nc(n,384)}catch{return}}var Fc,nn=_(()=>{"use strict";N();at();Xt();tn();xt();Fc=512*1024});function ys(t){let e=t.toLowerCase();return e.startsWith("git")||Vc.has(e)}function rn(t){let e=t.trim().split(/\s+/).filter(a=>a.length>0),n=0;for(;n<e.length&&Uc.test(e[n]??"");)n+=1;let r=e[n];if(!r||!zc.test(r)||r.length>Kc||ys(r)||Hc.test(r)||Qe(r)!==r)return"";let s=e[n+1];return s&&ys(s)?"":(s&&Gc.has(r.toLowerCase())&&Zc.test(s)?`${r} ${s}`:r).slice(0,64)}async function _s(t){if(!t.telemetryOptIn)return;let e=rn(t.cmd),n=e&&Qe(e)===e?e:"other",r=t.sessionId?t.sessionId.replace(/[^A-Za-z0-9._-]/g,"").slice(0,64):"";Et("telemetry",{cmd:n,tokensSaved:Math.max(0,Math.round(t.tokensSaved)),...t.tokensRestored?{tokensRestored:Math.max(0,Math.round(t.tokensRestored))}:{},...t.rawTokens!=null?{rawTokens:Math.max(0,Math.round(t.rawTokens))}:{},optimized:t.optimized,...r?{sessionId:r}:{},...t.host?{host:t.host}:{}})}var zc,Zc,Uc,Vc,Hc,Kc,Gc,sn=_(()=>{"use strict";Jt();nn();zc=/^[a-z0-9][a-z0-9._-]*$/i,Zc=/^[a-z][a-z-]+$/,Uc=/^[A-Za-z_][A-Za-z0-9_]*=/,Vc=new Set(["gh","glab","gup","hub","gist"]),Hc=/^(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,Kc=24,Gc=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 bs(t){if(t.plan!=="pro"||!(await et()).telemetryOptIn)return;let e=rn(t.cmd);!e||Qe(e)!==e||Et("learn",{cmd:e,filterId:t.filterId==null?null:W(t.filterId),rawBytes:t.rawBytes,filteredBytes:t.filteredBytes})}var vs=_(()=>{"use strict";sn();Jt();nn();we();xt()});import{readFileSync as Wc,renameSync as Yc,statSync as Jc,writeFileSync as qc}from"node:fs";function xs(t,e,n){try{if(Jc(t).size<=e)return;let r=Wc(t,"utf8").split(`
36
+ `).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}`;qc(o,s.length?`${s.join(`
22
37
  `)}
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(`
38
+ `:"",{mode:384}),Yc(o,t)}catch{}}var Es=_(()=>{"use strict"});var ks=_(()=>{"use strict"});import{appendFileSync as Xc,chmodSync as Qc,mkdirSync as el}from"node:fs";import{join as tl}from"node:path";function Ss(t){return t.length===0||t[0]==="cd"||t.every(e=>Ts.test(e))}function al(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(`|;&<>
39
+ `.includes(o)){if(i(),Ss(e)){e=[];continue}return e}n+=o,r=!0}return i(),Ss(e)?[]:e}function Rs(t){let e=al(t).map(a=>a.replace(/^[({]+/,"")).filter(Boolean),n=0;for(;n<e.length;){let a=e[n];if(Ts.test(a)){n+=1;continue}if(rl.has(a)){for(n+=1;n<e.length;){let c=e[n];if(c.startsWith("-")){n+=sl.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("-")&&il.test(i)&&ol.has(s.toLowerCase())?`${s} ${i}`:s).slice(0,24)}function cl(){return tl(R(),nl)}function As(t,e,n=cl(),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}}
40
+ `;try{el(R(),{recursive:!0,mode:448}),Xc(n,u,{mode:384}),Qc(n,384),xs(n,ws,ws/2)}catch{return}}function Cs(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 nl,ws,rl,sl,il,ol,Ts,Is=_(()=>{"use strict";Es();N();ks();nl="stats.jsonl",ws=2*1024*1024,rl=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),sl=new Set(["-u","-g","-n","-s","-k"]),il=/^[a-z0-9][a-z0-9._-]*$/i,ol=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"]),Ts=/^[A-Za-z_][A-Za-z0-9_]*=/});function on(t){return JSON.stringify(t)+kt}function*Ds(t){let e=0;for(;;){let n=t.indexOf(kt,e);if(n<0)return;yield t.slice(e,n),e=n+1}}function tt(){return`${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var ll,ul,dl,fl,hm,gm,ym,Os,kt,_m,$s=_(()=>{"use strict";Le();ht();ll=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()}),ul=m.object({id:m.string().min(1).max(64),op:m.literal("ping")}),dl=m.object({id:m.string().min(1).max(64),op:m.literal("shutdown"),installId:m.string().min(1).max(64)}),fl=m.object({id:m.string().min(1).max(64),op:m.literal("reload"),installId:m.string().min(1).max(64).optional()}),hm=m.discriminatedUnion("op",[ll,ul,dl,fl]),gm=m.object({id:m.string(),ok:m.literal(!0),data:m.unknown()}),ym=m.object({id:m.string(),ok:m.literal(!1),err:m.string(),retryAfterMs:m.number().int().nonnegative().optional()}),Os=m.object({filter:Fe.nullable(),cacheHit:m.boolean().optional()}),kt=`
41
+ `,_m=64*1024});import pl from"node:os";import{join as nt}from"node:path";import{existsSync as ml,statSync as hl,lstatSync as Ns,unlinkSync as gl,mkdirSync as yl,chmodSync as _l}from"node:fs";import{createHash as bl}from"node:crypto";function vl(t){let e=bl("sha256").update(R()).digest("hex").slice(0,8),n=nt(pl.tmpdir(),`tkr-${t}-${e}`),r=nt(n,"d.sock");if(Buffer.byteLength(r)>an)throw new Error("Temporary directory path is too long for IPC");return Ps(n,t),r}function xl(t,e){try{let n=Ns(t);return n.isDirectory()&&n.uid===e&&(n.mode&63)===0}catch{return!1}}function Ps(t,e){yl(t,{recursive:!0,mode:448});let n=Ns(t);if(!n.isDirectory()||n.uid!==e)throw new Error("Unsafe IPC directory");_l(t,448)}function rt(){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&&xl(e,t)){let s=nt(e,`tokmizer-${t}.sock`);if(Buffer.byteLength(s)<=an)return{path:s,isPipe:!1}}let n=nt(R(),"run"),r=nt(n,"daemon.sock");return Buffer.byteLength(r)>an?{path:vl(t),isPipe:!1}:(Ps(n,t),{path:r,isPipe:!1})}async function cn(){let{path:t,isPipe:e}=rt();if(e||!ml(t))return;try{if(!hl(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{gl(t)}catch{}}var an,Sm,Ms=_(()=>{"use strict";N();an=100;Sm=5*6e4});import{createConnection as El}from"node:net";import{spawn as kl}from"node:child_process";import{existsSync as Bs,openSync as ln,closeSync as Ls,unlinkSync as dn,writeFileSync as fn,mkdirSync as pn,readFileSync as wl,appendFileSync as Sl,rmSync as Tl,statSync as Rl}from"node:fs";import{dirname as Al,join as mn}from"node:path";import{fileURLToPath as Cl}from"node:url";function hn(){return mn(R(),"daemon.spawn.fail")}function gn(){return mn(R(),"daemon.log")}function $l(){try{let t=Number(wl(hn(),"utf8"));return Number.isFinite(t)&&Date.now()-t<Ol}catch{return!1}}function Nl(t){try{pn(R(),{recursive:!0});let e=gn();try{Rl(e).size>Dl&&dn(e)}catch{}Sl(e,`${new Date().toISOString()} ${t}
42
+ `)}catch{}}function Pl(t){try{pn(R(),{recursive:!0}),fn(hn(),String(Date.now()))}catch{}Nl(`spawn failed: ${t.message}`)}function Ml(){try{Tl(hn(),{force:!0})}catch{}}async function wt(t,e){return new Promise((n,r)=>{let s=El(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 Ll(){return process.env.TOKMIZER_DAEMON_BIN?process.env.TOKMIZER_DAEMON_BIN:Cl(new URL("../bin/tkr-daemon.js",import.meta.url))}async function un(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 wt(t,75)).destroy(),!0}catch{}else if(Bs(t))return!0;await new Promise(i=>setTimeout(i,75))}return!1}async function Fl(t){let e=Ll();if(!Bs(e))throw new Error(`tkr-daemon binary not found at ${e}`);let{path:n}=rt(),r=process.platform==="win32"?R():Al(n);try{pn(r,{recursive:!0})}catch{}let s=mn(r,"daemon.spawn.lock"),i=null;try{i=ln(s,"wx"),fn(i,String(process.pid))}catch(o){if(o.code==="EEXIST"){if(await un(n,5e3))return;try{dn(s)}catch{}try{i=ln(s,"wx"),fn(i,String(process.pid))}catch(c){if(c.code==="EEXIST"){await un(n,5e3);return}throw c}}else throw o}try{let o=null;try{o=ln(gn(),"a")}catch{}if(kl(process.execPath,[e],{detached:!0,stdio:["ignore","ignore",o??"ignore"],env:{...process.env,TOKMIZER_DAEMON_INSTALL_ID:t}}).unref(),o!==null)try{Ls(o)}catch{}if(!await un(n,3e3))throw new Error("tkr-daemon failed to bind socket within 3s")}finally{if(i!==null){try{Ls(i)}catch{}try{dn(s)}catch{}}}}async function Bl(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:rt(),n=await qt();try{let r=await wt(e,js);r.write(on({id:tt(),op:"shutdown",installId:n})),await new Promise(s=>setTimeout(s,150));try{r.destroy()}catch{}return!0}catch{return!1}}async function jl(t,e){let n=Date.now()+e;for(;Date.now()<n;){try{(await wt(t,250)).destroy()}catch{return!0}await new Promise(r=>setTimeout(r,100))}return!1}async function yn(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:rt(),n=await qt(),r=null,s=0,i=!1;for(;s<=Fs;)try{r=await wt(e,js),Ml();break}catch{if(s+=1,s>Fs)throw new Error(`tkr-daemon unreachable at ${e}`);if($l())throw new Error(`tkr-daemon spawn on cooldown (see ${gn()})`);await cn();try{await Fl(n),i=!0}catch(u){throw Pl(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]===kt&&(f=g);if(f<0)return;let d=[];for(let g of Ds(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),w=o.get(v.id);if(!w)continue;clearTimeout(w.timer),o.delete(v.id),w.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})`))},Il);o.set(u.id,{resolve:f,reject:d,timer:g}),r.write(on(u))})}let l={filter:async(u,f,d)=>{let g=await c({id:tt(),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=Os.safeParse(g.data);return v.success?v.data.filter:null},ping:async()=>{let u=await c({id:tt(),op:"ping"});if(!u.ok)throw new Error(u.err);return u.data},reload:async()=>{let u=await c({id:tt(),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!==Qt}catch{}if(u){try{await Bl(t.socketPath?{socketPath:t.socketPath}:{})}catch{}l.close();let f=await jl(e,2e3);if(await cn(),!f)throw new Error("stale daemon still running after shutdown request");return yn({...t,skipVersionCheck:!0})}}return l}var js,Il,Fs,Ol,Dl,zs=_(()=>{"use strict";$s();Ms();N();Xt();en();js=500,Il=3e3,Fs=1,Ol=6e4,Dl=256*1024});import{createCipheriv as jm,createDecipheriv as zl,hkdfSync as Zl,randomBytes as zm}from"node:crypto";function Hl(t){return Buffer.from(Zl("sha256",Buffer.from(t,"utf8"),Ul,Vl,32))}function Zs(t,e){let n=Hl(e),r=Buffer.from(t,"base64url"),s=r.subarray(0,12),i=r.subarray(12,28),o=r.subarray(28),a=zl("aes-256-gcm",n,s);return a.setAuthTag(i),Buffer.concat([a.update(o),a.final()]).toString("utf8")}var Ul,Vl,Us=_(()=>{"use strict";Ul=Buffer.from("tokmizer-bundle-enc-v1"),Vl=Buffer.from("rules-bundle")});import{chmodSync as Vm,readFileSync as Kl,writeFileSync as Hm,mkdirSync as Km,renameSync as Gm}from"node:fs";import{join as Gl}from"node:path";function Yl(){return Gl(R(),"bundle-cache.json")}function Vs(){try{let t=Kl(Yl(),"utf8"),e=Wl.safeParse(JSON.parse(t));return e.success?e.data:null}catch{return null}}var Wl,Hs=_(()=>{"use strict";Le();N();Wl=m.object({payload:m.string().min(1),signature:m.string().min(1),enc:m.literal("v1"),fetchedAt:m.number().int().nonnegative()})});import{createPublicKey as Jl,verify as ql}from"node:crypto";function eu(){let t=Number(process.env.TOKMIZER_MAX_BUNDLE_AGE_MS);return Number.isFinite(t)&&t>0?t:Ql}function tu(t,e){let n=ps();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=Jl({key:n,format:"pem"});if(!ql(null,Buffer.from(t.payload,"utf8"),r,Buffer.from(t.signature,"base64url")))throw new Error("tkr-daemon: rules bundle signature invalid");return JSON.parse(Zs(t.payload,e))}function nu(t,e){let n=tu(t,e),r=Xl.parse(n);if(Date.now()-r.signedAt>eu())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 lr(),{bundleVersion:r.bundleVersion,signedAt:r.signedAt,ruleCount:s.size,startedAt:Date.now(),fetchedAt:Date.now(),selectFor:(i,o,a)=>gt(i,s.values(),a&&a.length>0?new Set(a):null)}}async function Ks(){try{let t=Vs();if(!t)return null;let e=await Ke();return e?.signingSecret?nu(t,e.signingSecret):null}catch{return null}}var Xl,ah,Ql,Gs=_(()=>{"use strict";Le();ht();Ft();at();tn();Us();Hs();Xl=m.object({bundleVersion:m.number().int().nonnegative(),signedAt:m.number().int(),filters:m.array(Fe)}),ah=m.object({payload:m.string().min(1),signature:m.string().min(1),enc:m.literal("v1")}),Ql=10080*60*1e3});async function ru(){if(Ze)return Ze;if(st)return st;let t=yn().then(e=>{if(st===t)return Ze=e,e;try{e.close()}catch{}return null}).catch(()=>null);return st=t,t}async function su(){return bn||(bn=!0,_n=await Ks()),_n}async function Ws(t,e,n){let r=await su();if(!r)return null;let s=r.selectFor(t,e,[...n]);return!s||!n.has(W(s.slug))?null:s}function iu(t){return t?{...t,matchRegex:new RegExp(t.match_command)}:null}function Ys(t){Wt(async(e,n)=>{let r=t==="free"?"trial":t,s=n??qe(void 0),i=await ru();if(!i)return Ws(e,r,s);try{let o=await i.filter(e,r,[...s]);return!o||!s.has(W(o.slug))?null:iu(o)}catch{return Ws(e,r,s)}})}function Js(){if(Wt(null),Ze)try{Ze.close()}catch{}Ze=null,st=null,_n=null,bn=!1}var Ze,st,_n,bn,qs=_(()=>{"use strict";zs();Yt();we();Gs();Ze=null,st=null;_n=null,bn=!1});var Xs={};At(Xs,{FOLD_MARKER_RE:()=>br,captureForRestore:()=>rs,captureOriginalForRestore:()=>ss,closeDaemonResolver:()=>Js,countedSaving:()=>Cs,gatingPlan:()=>as,graceExceeded:()=>os,installDaemonResolver:()=>Ys,loadSettingsCache:()=>et,processOutput:()=>Qr,recordEvent:()=>bs,recordStat:()=>As,recordTelemetry:()=>_s,resolveAllowedFilters:()=>qe,statCmdLabel:()=>Rs});var Qs=_(()=>{"use strict";Yt();is();Xe();we();cs();vs();sn();Is();qs();xt()});N();import{existsSync as ou,writeFileSync as au,appendFileSync as cu,statSync as lu}from"node:fs";import{join as ni}from"node:path";async function wn(){let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf8")}import{realpathSync as Sn}from"node:fs";import{fileURLToPath as ui,pathToFileURL as di}from"node:url";function Tn(t,e){if(!t)return!1;if(e===di(t).href)return!0;try{return Sn(t)===Sn(ui(e))}catch{return!1}}at();var Rn=[{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"]}],Zu=[...Rn.map(t=>t.host),"shell"],yi=new Set(["claude-code","codex"]);function An(t){return null}function Cn(t=process.env){let e=process.platform,n=e==="darwin"||e==="linux"||e==="win32"?e:"other",r=process.arch;for(let s of Rn)if(s.vars.some(i=>t[i]))return{host:s.host,source:"env",os:n,arch:r,shimRecommended:!yi.has(s.host)};return{host:"shell",source:"fallback",os:n,arch:r,shimRecommended:!0}}N();import{appendFileSync as _i,mkdirSync as bi,readFileSync as vi,writeFileSync as xi,renameSync as Ei,statSync as ki,readdirSync as Hu,rmSync as Ku,chmodSync as wi}from"node:fs";import{join as In}from"node:path";var Si=96*1024,Ti=500,Yu=168*3600*1e3,Ri=120;function On(){return In(R(),"sessions")}function Ai(t){let e=t.replace(/[^A-Za-z0-9._-]/g,"-").replace(/\.\./g,"-").slice(0,80)||"default";return In(On(),`${e}.jsonl`)}function Dn(t,e){try{let n=Ai(t);bi(On(),{recursive:!0,mode:448});let r=JSON.stringify({t:e.t??Math.floor(Date.now()/1e3),tool:e.tool,target:e.target.slice(0,Ri),...e.fail?{fail:1}:{}});if(_i(n,`${r}
43
+ `,{mode:384}),wi(n,384),ki(n).size>Si){let s=vi(n,"utf8").split(`
44
+ `).filter(a=>a.trim()!==""),i=s.slice(s.length-Ti),o=`${n}.tmp-${process.pid}`;xi(o,`${i.join(`
30
45
  `)}
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(`
46
+ `,{mode:384}),Ei(o,n)}}catch{}}N();import{readFileSync as Ci}from"node:fs";import{join as Ii}from"node:path";function $n(){try{return JSON.parse(Ci(Ii(R(),"settings-cache.json"),"utf8")).enabled!==!1}catch{return!0}}N();import{createHash as Oi}from"node:crypto";import{appendFileSync as Di,chmodSync as $i,mkdirSync as Ni,readFileSync as Pi,rmSync as Mi,statSync as Li}from"node:fs";import{join as Nn}from"node:path";var Fi=256*1024,Bi=80;function ji(t){let e=t.replace(/[^A-Za-z0-9._-]/g,"-").replace(/\.\./g,"-").slice(0,80)||"default";return Nn(R(),"sessions",`${e}.seen`)}function It(t){return t.replace(/[\t\r\n]+/g," ").trim().slice(0,Bi)}function Pn(t,e,n,r){try{let s=ji(t),i=It(e),o=Oi("sha256").update(n).digest("hex").slice(0,32),a="";try{a=Pi(s,"utf8")}catch{}for(let c of a.split(`
47
+ `)){let[l,u,f]=c.split(" ");if(l===i&&u===o)return{cmd:f??""}}Ni(Nn(R(),"sessions"),{recursive:!0,mode:448}),Di(s,`${i} ${o} ${It(r)}
48
+ `,{mode:384}),$i(s,384),Li(s).size>Fi&&Mi(s,{force:!0})}catch{}return null}function Mn(t,e){return`[same output as \`${It(t)}\` earlier in this session, unchanged, ~${Math.round(e/4)} tokens]`}Ot();var uu=new Set(["Read","Grep","Glob","Bash"]),du=10*1024*1024,fu=1024,pu=/^… \(?\d+ more lines omitted\)?$/,mu=/^\[tkr restore [0-9a-f]{8,64}\]$/;function hu(t){return pu.test(t)||mu.test(t)||t==="[YOLO: omitted]"}function ri(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(`
49
+ `).filter(s=>n.has(s)||hu(s));return{...t,filenames:r}}return e}function gu(t,e,n){return JSON.stringify({...n?{systemMessage:n}:{},hookSpecificOutput:{hookEventName:"PostToolUse",updatedToolOutput:ri(t.tool_response,e)}})}var yu=100,vn=null;function _u(){let t=vn;return vn=null,t}function ei(t){let e=Math.round(t/4);return e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function bu(t,e){try{if(Math.round((t-e)/4)<yu)return;let n=ni(R(),"first-save");if(ou(n))return;au(n,String(Date.now())),vn=`Tokmizer just optimized its first command output here: ~${ei(t)} tokens down to ~${ei(e)}. Watch it add up: /tkr-gain`}catch{}}function ti(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
50
  `):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};
51
+ `):null:""}var vu=64*1024;function xu(t,e){try{if(!e||typeof e!="object")return;let n=ni(R(),"drift.jsonl");try{if(lu(n).size>vu)return}catch{}let r=Object.keys(e).slice(0,12);cu(n,`${JSON.stringify({t:Math.floor(Date.now()/1e3),tool:t,keys:r})}
52
+ `)}catch{}}function Eu(t){let e=t.tool_name??"tool",n=t.tool_input??{};return n.command?n.command.split(`
53
+ `)[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 ku(t){let e=ee();if(!t.tool_name||!uu.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 Ke();if(!s||!s.token||!$n())return null;if(t.session_id&&!r){let I=t.tool_input??{},it=I.command??I.file_path??I.pattern??I.path??"";it&&Dn(t.session_id,{tool:t.tool_name,target:it.split(`
54
+ `)[0].trim()})}if(t.tool_name==="Read"&&(t.tool_input?.offset!=null||t.tool_input?.limit!=null))return null;let i=ti(t.tool_response);if(i==null)return xu(t.tool_name,t.tool_response),null;if(!i)return null;let o=Buffer.byteLength(i,"utf8");if(o>du||t.tool_name==="Bash"&&o<fu||r)return null;let{loadSettingsCache:a,processOutput:c,captureForRestore:l,captureOriginalForRestore:u,FOLD_MARKER_RE:f,resolveAllowedFilters:d,gatingPlan:g,graceExceeded:v,recordEvent:w,recordTelemetry:A,recordStat:O,countedSaving:U,statCmdLabel:Te,installDaemonResolver:V,closeDaemonResolver:Re}=await Promise.resolve().then(()=>(Qs(),Xs)),C=await a();if(!C.enabled)return null;let{slugKey:Ue}=await Promise.resolve().then(()=>(we(),ar)),Ae=g(s);V(Ae);let St=d(s.allowedFilters,v(s)),Ve=new Set(C.filters.disabled.map(Ue)),si=Ve.size>0?new Set([...St].filter(I=>!Ve.has(I))):St,ii=Eu(t),Tt=`${t.tool_name.toLowerCase()}-tool`,oi=`${Tt}: ${ii}`;try{let I=await c(oi,i,si,{verbosity:C.outputVerbosity,yolo:e,exitCode:t.tool_name==="Bash"?void 0:0});if(I.filterId!=null&&t.tool_name==="Bash"&&t.session_id){let xn=Pn(t.session_id,t.agent_id??"main",i,n.split(`
55
+ `)[0]??"");if(xn){let En=Mn(xn.cmd,o);return e?En:await u(i,En)}}await w({cmd:Tt,filterId:I.filterId,rawBytes:I.rawBytes,filteredBytes:I.filteredBytes,plan:Ae});let it=new RegExp(f.source,"m"),z;I.filteredBytes>=I.rawBytes?z=null:e?z=I.output:it.test(I.output)?z=await u(i,I.output):z=await l(I.droppedTail??null,I.output),e&&z!=null&&(z=ti(ri(t.tool_response,z)));let ai=z==null?I.rawBytes:Buffer.byteLength(z,"utf8"),Rt=Cn().host,ae=U(I.rawBytes,ai,An(Rt));return z!=null&&bu(ae.raw,ae.filtered),O(ae.raw,ae.filtered,void 0,!1,Rt,t.tool_name==="Bash"?"sh":void 0,t.tool_name==="Bash"?Te(t.tool_input?.command??""):t.tool_name),await A({cmd:Tt,tokensSaved:Math.round((ae.raw-ae.filtered)/4),rawTokens:Math.round(ae.raw/4),optimized:I.filterId!=null,telemetryOptIn:C.telemetryOptIn,host:Rt}),z}finally{Re()}}async function wu(){let t=await wn();t||process.exit(0);let e;try{e=JSON.parse(t)}catch{process.exit(0)}let n=await ku(e);n||process.exit(0),process.stdout.write(gu(e,n,_u()??void 0))}var Su=process.argv[1]??"";Tn(Su,import.meta.url)&&wu().catch(t=>{process.stderr.write(`tkr post-tool-use: ${t.message}
56
+ `),process.exit(0)});export{gu as buildHookEnvelope,ku as processToolOutput,_u as takeFirstSaveNotice};