@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,37 +1,52 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __tkrCreateRequire } from "node:module"; const require = __tkrCreateRequire(import.meta.url);
3
- var Ls=Object.create;var gt=Object.defineProperty;var Fs=Object.getOwnPropertyDescriptor;var Bs=Object.getOwnPropertyNames;var js=Object.getPrototypeOf,zs=Object.prototype.hasOwnProperty;var Q=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var F=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(n){throw e=0,n}},Zs=(t,e)=>{for(var n in e)gt(t,n,{get:e[n],enumerable:!0})},Us=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Bs(e))!zs.call(t,s)&&s!==n&&gt(t,s,{get:()=>e[s],enumerable:!(r=Fs(e,s))||r.enumerable});return t};var un=(t,e,n)=>(n=t!=null?Ls(js(t)):{},Us(e||!t||!t.__esModule?gt(n,"default",{value:t,enumerable:!0}):n,t));var hn=F((au,mn)=>{mn.exports=pn;pn.sync=Vs;var dn=Q("fs");function Hs(t,e){var n=e.pathExt!==void 0?e.pathExt:process.env.PATHEXT;if(!n||(n=n.split(";"),n.indexOf("")!==-1))return!0;for(var r=0;r<n.length;r++){var s=n[r].toLowerCase();if(s&&t.substr(-s.length).toLowerCase()===s)return!0}return!1}function fn(t,e,n){return!t.isSymbolicLink()&&!t.isFile()?!1:Hs(e,n)}function pn(t,e,n){dn.stat(t,function(r,s){n(r,r?!1:fn(s,t,e))})}function Vs(t,e){return fn(dn.statSync(t),t,e)}});var xn=F((cu,vn)=>{vn.exports=yn;yn.sync=Ks;var gn=Q("fs");function yn(t,e,n){gn.stat(t,function(r,s){n(r,r?!1:_n(s,e))})}function Ks(t,e){return _n(gn.statSync(t),e)}function _n(t,e){return t.isFile()&&Gs(t,e)}function Gs(t,e){var n=t.mode,r=t.uid,s=t.gid,i=e.uid!==void 0?e.uid:process.getuid&&process.getuid(),o=e.gid!==void 0?e.gid:process.getgid&&process.getgid(),a=parseInt("100",8),c=parseInt("010",8),l=parseInt("001",8),u=a|c,d=n&l||n&c&&s===o||n&a&&r===i||n&u&&i===0;return d}});var En=F((uu,bn)=>{var lu=Q("fs"),Xe;process.platform==="win32"||global.TESTING_WINDOWS?Xe=hn():Xe=xn();bn.exports=yt;yt.sync=Ws;function yt(t,e,n){if(typeof e=="function"&&(n=e,e={}),!n){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(r,s){yt(t,e||{},function(i,o){i?s(i):r(o)})})}Xe(t,e||{},function(r,s){r&&(r.code==="EACCES"||e&&e.ignoreErrors)&&(r=null,s=!1),n(r,s)})}function Ws(t,e){try{return Xe.sync(t,e||{})}catch(n){if(e&&e.ignoreErrors||n.code==="EACCES")return!1;throw n}}});var Cn=F((du,Rn)=>{var be=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",kn=Q("path"),qs=be?";":":",wn=En(),Sn=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),Tn=(t,e)=>{let n=e.colon||qs,r=t.match(/\//)||be&&t.match(/\\/)?[""]:[...be?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(n)],s=be?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",i=be?s.split(n):[""];return be&&t.indexOf(".")!==-1&&i[0]!==""&&i.unshift(""),{pathEnv:r,pathExt:i,pathExtExe:s}},An=(t,e,n)=>{typeof e=="function"&&(n=e,e={}),e||(e={});let{pathEnv:r,pathExt:s,pathExtExe:i}=Tn(t,e),o=[],a=l=>new Promise((u,d)=>{if(l===r.length)return e.all&&o.length?u(o):d(Sn(t));let p=r[l],y=/^".*"$/.test(p)?p.slice(1,-1):p,w=kn.join(y,t),b=!y&&/^\.[\\\/]/.test(t)?t.slice(0,2)+w:w;u(c(b,l,0))}),c=(l,u,d)=>new Promise((p,y)=>{if(d===s.length)return p(a(u+1));let w=s[d];wn(l+w,{pathExt:i},(b,C)=>{if(!b&&C)if(e.all)o.push(l+w);else return p(l+w);return p(c(l,u,d+1))})});return n?a(0).then(l=>n(null,l),n):a(0)},Ys=(t,e)=>{e=e||{};let{pathEnv:n,pathExt:r,pathExtExe:s}=Tn(t,e),i=[];for(let o=0;o<n.length;o++){let a=n[o],c=/^".*"$/.test(a)?a.slice(1,-1):a,l=kn.join(c,t),u=!c&&/^\.[\\\/]/.test(t)?t.slice(0,2)+l:l;for(let d=0;d<r.length;d++){let p=u+r[d];try{if(wn.sync(p,{pathExt:s}))if(e.all)i.push(p);else return p}catch{}}}if(e.all&&i.length)return i;if(e.nothrow)return null;throw Sn(t)};Rn.exports=An;An.sync=Ys});var $n=F((fu,_t)=>{"use strict";var In=(t={})=>{let e=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(r=>r.toUpperCase()==="PATH")||"Path"};_t.exports=In;_t.exports.default=In});var Nn=F((pu,Dn)=>{"use strict";var On=Q("path"),Xs=Cn(),Js=$n();function Pn(t,e){let n=t.options.env||process.env,r=process.cwd(),s=t.options.cwd!=null,i=s&&process.chdir!==void 0&&!process.chdir.disabled;if(i)try{process.chdir(t.options.cwd)}catch{}let o;try{o=Xs.sync(t.command,{path:n[Js({env:n})],pathExt:e?On.delimiter:void 0})}catch{}finally{i&&process.chdir(r)}return o&&(o=On.resolve(s?t.options.cwd:"",o)),o}function Qs(t){return Pn(t)||Pn(t,!0)}Dn.exports=Qs});var Mn=F((mu,xt)=>{"use strict";var vt=/([()\][%!^"`<>&|;, *?])/g;function ei(t){return t=t.replace(vt,"^$1"),t}function ti(t,e){return t=`${t}`,t=t.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),t=t.replace(/(?=(\\+?)?)\1$/,"$1$1"),t=`"${t}"`,t=t.replace(vt,"^$1"),e&&(t=t.replace(vt,"^$1")),t}xt.exports.command=ei;xt.exports.argument=ti});var Fn=F((hu,Ln)=>{"use strict";Ln.exports=/^#!(.*)/});var jn=F((gu,Bn)=>{"use strict";var ni=Fn();Bn.exports=(t="")=>{let e=t.match(ni);if(!e)return null;let[n,r]=e[0].replace(/#! ?/,"").split(" "),s=n.split("/").pop();return s==="env"?r:r?`${s} ${r}`:s}});var Zn=F((yu,zn)=>{"use strict";var bt=Q("fs"),ri=jn();function si(t){let n=Buffer.alloc(150),r;try{r=bt.openSync(t,"r"),bt.readSync(r,n,0,150,0),bt.closeSync(r)}catch{}return ri(n.toString())}zn.exports=si});var Kn=F((_u,Vn)=>{"use strict";var ii=Q("path"),Un=Nn(),Hn=Mn(),oi=Zn(),ai=process.platform==="win32",ci=/\.(?:com|exe)$/i,li=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function ui(t){t.file=Un(t);let e=t.file&&oi(t.file);return e?(t.args.unshift(t.file),t.command=e,Un(t)):t.file}function di(t){if(!ai)return t;let e=ui(t),n=!ci.test(e);if(t.options.forceShell||n){let r=li.test(e);t.command=ii.normalize(t.command),t.command=Hn.command(t.command),t.args=t.args.map(i=>Hn.argument(i,r));let s=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${s}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}function fi(t,e,n){e&&!Array.isArray(e)&&(n=e,e=null),e=e?e.slice(0):[],n=Object.assign({},n);let r={command:t,args:e,options:n,file:void 0,original:{command:t,args:e}};return n.shell?r:di(r)}Vn.exports=fi});var qn=F((vu,Wn)=>{"use strict";var Et=process.platform==="win32";function kt(t,e){return Object.assign(new Error(`${e} ${t.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${t.command}`,path:t.command,spawnargs:t.args})}function pi(t,e){if(!Et)return;let n=t.emit;t.emit=function(r,s){if(r==="exit"){let i=Gn(s,e);if(i)return n.call(t,"error",i)}return n.apply(t,arguments)}}function Gn(t,e){return Et&&t===1&&!e.file?kt(e.original,"spawn"):null}function mi(t,e){return Et&&t===1&&!e.file?kt(e.original,"spawnSync"):null}Wn.exports={hookChildProcess:pi,verifyENOENT:Gn,verifyENOENTSync:mi,notFoundError:kt}});var Tt=F((xu,Ee)=>{"use strict";var Yn=Q("child_process"),wt=Kn(),St=qn();function Xn(t,e,n){let r=wt(t,e,n),s=Yn.spawn(r.command,r.args,r.options);return St.hookChildProcess(s,r),s}function hi(t,e,n){let r=wt(t,e,n),s=Yn.spawnSync(r.command,r.args,r.options);return s.error=s.error||St.verifyENOENTSync(s.status,r),s}Ee.exports=Xn;Ee.exports.spawn=Xn;Ee.exports.sync=hi;Ee.exports._parse=wt;Ee.exports._enoent=St});var Ms=un(Tt(),1);var nn=un(Tt(),1);import{existsSync as Kl,readFileSync as Gl,writeFileSync as Wl,mkdirSync as ql}from"node:fs";import{join as Yl}from"node:path";import{fileURLToPath as Xl}from"node:url";import{readdir as Ao,readFile as Ro}from"node:fs/promises";import{join as dr,dirname as Co}from"node:path";import{fileURLToPath as Io}from"node:url";var m={};Zs(m,{BRAND:()=>zi,DIRTY:()=>ie,EMPTY_PATH:()=>vi,INVALID:()=>v,NEVER:()=>To,OK:()=>O,ParseStatus:()=>I,Schema:()=>k,ZodAny:()=>ne,ZodArray:()=>Y,ZodBigInt:()=>ae,ZodBoolean:()=>ce,ZodBranded:()=>je,ZodCatch:()=>ve,ZodDate:()=>le,ZodDefault:()=>_e,ZodDiscriminatedUnion:()=>et,ZodEffects:()=>z,ZodEnum:()=>ge,ZodError:()=>P,ZodFirstPartyTypeKind:()=>x,ZodFunction:()=>nt,ZodIntersection:()=>pe,ZodIssueCode:()=>f,ZodLazy:()=>me,ZodLiteral:()=>he,ZodMap:()=>Re,ZodNaN:()=>Ie,ZodNativeEnum:()=>ye,ZodNever:()=>Z,ZodNull:()=>de,ZodNullable:()=>K,ZodNumber:()=>oe,ZodObject:()=>D,ZodOptional:()=>B,ZodParsedType:()=>g,ZodPipeline:()=>ze,ZodPromise:()=>re,ZodReadonly:()=>xe,ZodRecord:()=>tt,ZodSchema:()=>k,ZodSet:()=>Ce,ZodString:()=>te,ZodSymbol:()=>Te,ZodTransformer:()=>z,ZodTuple:()=>V,ZodType:()=>k,ZodUndefined:()=>ue,ZodUnion:()=>fe,ZodUnknown:()=>q,ZodVoid:()=>Ae,addIssueToContext:()=>h,any:()=>Yi,array:()=>eo,bigint:()=>Vi,boolean:()=>cr,coerce:()=>So,custom:()=>ir,date:()=>Ki,datetimeRegex:()=>rr,defaultErrorMap:()=>G,discriminatedUnion:()=>so,effect:()=>yo,enum:()=>mo,function:()=>uo,getErrorMap:()=>ke,getParsedType:()=>H,instanceof:()=>Ui,intersection:()=>io,isAborted:()=>Je,isAsync:()=>we,isDirty:()=>Qe,isValid:()=>ee,late:()=>Zi,lazy:()=>fo,literal:()=>po,makeIssue:()=>Be,map:()=>co,nan:()=>Hi,nativeEnum:()=>ho,never:()=>Ji,null:()=>qi,nullable:()=>vo,number:()=>ar,object:()=>to,objectUtil:()=>At,oboolean:()=>wo,onumber:()=>ko,optional:()=>_o,ostring:()=>Eo,pipeline:()=>bo,preprocess:()=>xo,promise:()=>go,quotelessJson:()=>gi,record:()=>ao,set:()=>lo,setErrorMap:()=>_i,strictObject:()=>no,string:()=>or,symbol:()=>Gi,transformer:()=>yo,tuple:()=>oo,undefined:()=>Wi,union:()=>ro,unknown:()=>Xi,util:()=>S,void:()=>Qi});var S;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{let i={};for(let o of s)i[o]=o;return i},t.getValidEnumValues=s=>{let i=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(let a of i)o[a]=s[a];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=(s,i)=>{for(let o of s)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(S||(S={}));var At;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(At||(At={}));var g=S.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 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 f=S.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),gi=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,S.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};P.create=t=>new P(t);var yi=(t,e)=>{let n;switch(t.code){case f.invalid_type:t.received===g.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case f.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,S.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:n=`Unrecognized key(s) in object: ${S.joinValues(t.keys,", ")}`;break;case f.invalid_union:n="Invalid input";break;case f.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${S.joinValues(t.options)}`;break;case f.invalid_enum_value:n=`Invalid enum value. Expected ${S.joinValues(t.options)}, received '${t.received}'`;break;case f.invalid_arguments:n="Invalid function arguments";break;case f.invalid_return_type:n="Invalid function return type";break;case f.invalid_date:n="Invalid date";break;case f.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:S.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case f.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 f.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 f.custom:n="Invalid input";break;case f.invalid_intersection_types:n="Intersection results could not be merged";break;case f.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case f.not_finite:n="Number must be finite";break;default:n=e.defaultError,S.assertNever(t)}return{message:n}},G=yi;var Jn=G;function _i(t){Jn=t}function ke(){return Jn}var Be=t=>{let{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="",c=r.filter(l=>!!l).slice().reverse();for(let l of c)a=l(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}},vi=[];function h(t,e){let n=ke(),r=Be({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===G?void 0:G].filter(s=>!!s)});t.common.issues.push(r)}var I=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let s of n){if(s.status==="aborted")return v;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let s of n){let i=await s.key,o=await s.value;r.push({key:i,value:o})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let s of n){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return v;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}},v=Object.freeze({status:"aborted"}),ie=t=>({status:"dirty",value:t}),O=t=>({status:"valid",value:t}),Je=t=>t.status==="aborted",Qe=t=>t.status==="dirty",ee=t=>t.status==="valid",we=t=>typeof Promise<"u"&&t instanceof Promise;var _;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(_||(_={}));var j=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}},Qn=(t,e)=>{if(ee(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}}};function E(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{let{message: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}}var k=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 I,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(we(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 Qn(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 ee(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=>ee(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(we(s)?s:Promise.resolve(s));return Qn(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:f.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 z({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 B.create(this,this._def)}nullable(){return K.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Y.create(this)}promise(){return re.create(this,this._def)}or(e){return fe.create([this,e],this._def)}and(e){return pe.create(this,e,this._def)}transform(e){return new z({...E(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new _e({...E(this._def),innerType:this,defaultValue:n,typeName:x.ZodDefault})}brand(){return new je({typeName:x.ZodBranded,type:this,...E(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new ve({...E(this._def),innerType:this,catchValue:n,typeName:x.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return ze.create(this,e)}readonly(){return xe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},xi=/^c[^\s-]{8,}$/i,bi=/^[0-9a-z]+$/,Ei=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ki=/^[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,wi=/^[a-z0-9_-]{21}$/i,Si=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ti=/^[-+]?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)?)??$/,Ai=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ri="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Rt,Ci=/^(?:(?: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]))$/,Oi=/^(([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}=))?$/,Di=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,tr="((\\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])))",Ni=new RegExp(`^${tr}$`);function nr(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 Mi(t){return new RegExp(`^${nr(t)}$`)}function rr(t){let e=`${tr}T${nr(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 Li(t,e){return!!((e==="v4"||!e)&&Ci.test(t)||(e==="v6"||!e)&&$i.test(t))}function Fi(t,e){if(!Si.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 Bi(t,e){return!!((e==="v4"||!e)&&Ii.test(t)||(e==="v6"||!e)&&Oi.test(t))}var te=class t extends k{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==g.string){let i=this._getOrReturnCtx(e);return h(i,{code:f.invalid_type,expected:g.string,received:i.parsedType}),v}let r=new I,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:f.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:f.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:f.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&h(s,{code:f.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")Ai.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"email",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Rt||(Rt=new RegExp(Ri,"u")),Rt.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"emoji",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")ki.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"uuid",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")wi.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"nanoid",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")xi.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cuid",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")bi.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cuid2",code:f.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")Ei.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"ulid",code:f.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:f.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:f.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:f.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:f.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:f.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?rr(i).test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:f.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Ni.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:f.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Mi(i).test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{code:f.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?Ti.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"duration",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Li(e.data,i.version)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"ip",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?Fi(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"jwt",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Bi(e.data,i.version)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"cidr",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?Pi.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64",code:f.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Di.test(e.data)||(s=this._getOrReturnCtx(e,s),h(s,{validation:"base64url",code:f.invalid_string,message:i.message}),r.dirty()):S.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:f.invalid_string,..._.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",..._.errToObj(e)})}url(e){return this._addCheck({kind:"url",..._.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",..._.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",..._.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",..._.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",..._.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",..._.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",..._.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",..._.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",..._.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",..._.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",..._.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",..._.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,..._.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,..._.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",..._.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,..._.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,..._.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,..._.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,..._.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,..._.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,..._.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,..._.errToObj(n)})}nonempty(e){return this.min(1,_.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}};te.create=t=>new te({checks:[],typeName:x.ZodString,coerce:t?.coerce??!1,...E(t)});function ji(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}var oe=class t extends k{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 h(i,{code:f.invalid_type,expected:g.number,received:i.parsedType}),v}let r,s=new I;for(let i of this._def.checks)i.kind==="int"?S.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:f.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:f.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:f.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?ji(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),h(r,{code:f.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:f.not_finite,message:i.message}),s.dirty()):S.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,_.toString(n))}gt(e,n){return this.setLimit("min",e,!1,_.toString(n))}lte(e,n){return this.setLimit("max",e,!0,_.toString(n))}lt(e,n){return this.setLimit("max",e,!1,_.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:_.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:_.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:_.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:_.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:_.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:_.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&S.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};oe.create=t=>new oe({checks:[],typeName:x.ZodNumber,coerce:t?.coerce||!1,...E(t)});var ae=class t extends k{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 I;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:f.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:f.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:f.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):S.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:g.bigint,received:n.parsedType}),v}gte(e,n){return this.setLimit("min",e,!0,_.toString(n))}gt(e,n){return this.setLimit("min",e,!1,_.toString(n))}lte(e,n){return this.setLimit("max",e,!0,_.toString(n))}lt(e,n){return this.setLimit("max",e,!1,_.toString(n))}setLimit(e,n,r,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:_.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:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:_.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:_.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}};ae.create=t=>new ae({checks:[],typeName:x.ZodBigInt,coerce:t?.coerce??!1,...E(t)});var ce=class extends k{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==g.boolean){let r=this._getOrReturnCtx(e);return h(r,{code:f.invalid_type,expected:g.boolean,received:r.parsedType}),v}return O(e.data)}};ce.create=t=>new ce({typeName:x.ZodBoolean,coerce:t?.coerce||!1,...E(t)});var le=class t extends k{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==g.date){let i=this._getOrReturnCtx(e);return h(i,{code:f.invalid_type,expected:g.date,received:i.parsedType}),v}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return h(i,{code:f.invalid_date}),v}let r=new I,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),h(s,{code:f.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:f.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):S.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:_.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:_.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}};le.create=t=>new le({checks:[],coerce:t?.coerce||!1,typeName:x.ZodDate,...E(t)});var Te=class extends k{_parse(e){if(this._getType(e)!==g.symbol){let r=this._getOrReturnCtx(e);return h(r,{code:f.invalid_type,expected:g.symbol,received:r.parsedType}),v}return O(e.data)}};Te.create=t=>new Te({typeName:x.ZodSymbol,...E(t)});var ue=class extends k{_parse(e){if(this._getType(e)!==g.undefined){let r=this._getOrReturnCtx(e);return h(r,{code:f.invalid_type,expected:g.undefined,received:r.parsedType}),v}return O(e.data)}};ue.create=t=>new ue({typeName:x.ZodUndefined,...E(t)});var de=class extends k{_parse(e){if(this._getType(e)!==g.null){let r=this._getOrReturnCtx(e);return h(r,{code:f.invalid_type,expected:g.null,received:r.parsedType}),v}return O(e.data)}};de.create=t=>new de({typeName:x.ZodNull,...E(t)});var ne=class extends k{constructor(){super(...arguments),this._any=!0}_parse(e){return O(e.data)}};ne.create=t=>new ne({typeName:x.ZodAny,...E(t)});var q=class extends k{constructor(){super(...arguments),this._unknown=!0}_parse(e){return O(e.data)}};q.create=t=>new q({typeName:x.ZodUnknown,...E(t)});var Z=class extends k{_parse(e){let n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:g.never,received:n.parsedType}),v}};Z.create=t=>new Z({typeName:x.ZodNever,...E(t)});var Ae=class extends k{_parse(e){if(this._getType(e)!==g.undefined){let r=this._getOrReturnCtx(e);return h(r,{code:f.invalid_type,expected:g.void,received:r.parsedType}),v}return O(e.data)}};Ae.create=t=>new Ae({typeName:x.ZodVoid,...E(t)});var Y=class t extends k{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==g.array)return h(n,{code:f.invalid_type,expected:g.array,received:n.parsedType}),v;if(s.exactLength!==null){let o=n.data.length>s.exactLength.value,a=n.data.length<s.exactLength.value;(o||a)&&(h(n,{code:o?f.too_big:f.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:f.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:f.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 j(n,o,n.path,a)))).then(o=>I.mergeArray(r,o));let i=[...n.data].map((o,a)=>s.type._parseSync(new j(n,o,n.path,a)));return I.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:_.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:_.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:_.toString(n)}})}nonempty(e){return this.min(1,e)}};Y.create=(t,e)=>new Y({type:t,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...E(e)});function Se(t){if(t instanceof D){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=B.create(Se(r))}return new D({...t._def,shape:()=>e})}else return t instanceof Y?new Y({...t._def,type:Se(t.element)}):t instanceof B?B.create(Se(t.unwrap())):t instanceof K?K.create(Se(t.unwrap())):t instanceof V?V.create(t.items.map(e=>Se(e))):t}var D=class t extends k{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=S.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==g.object){let l=this._getOrReturnCtx(e);return h(l,{code:f.invalid_type,expected:g.object,received:l.parsedType}),v}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],d=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new j(s,d,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:f.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 d=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new j(s,d,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let u of c){let d=await u.key,p=await u.value;l.push({key:d,value:p,alwaysSet:u.alwaysSet})}return l}).then(l=>I.mergeObjectSync(r,l)):I.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return _.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:_.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:x.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of S.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of S.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return Se(this)}partial(e){let n={};for(let r of S.objectKeys(this.shape)){let s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of S.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof B;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return sr(S.objectKeys(this.shape))}};D.create=(t,e)=>new D({shape:()=>t,unknownKeys:"strip",catchall:Z.create(),typeName:x.ZodObject,...E(e)});D.strictCreate=(t,e)=>new D({shape:()=>t,unknownKeys:"strict",catchall:Z.create(),typeName:x.ZodObject,...E(e)});D.lazycreate=(t,e)=>new D({shape:t,unknownKeys:"strip",catchall:Z.create(),typeName:x.ZodObject,...E(e)});var fe=class extends k{_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:f.invalid_union,unionErrors:o}),v}if(n.common.async)return Promise.all(r.map(async i=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let 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:f.invalid_union,unionErrors:a}),v}}get options(){return this._def.options}};fe.create=(t,e)=>new fe({options:t,typeName:x.ZodUnion,...E(e)});var W=t=>t instanceof me?W(t.schema):t instanceof z?W(t.innerType()):t instanceof he?[t.value]:t instanceof ge?t.options:t instanceof ye?S.objectValues(t.enum):t instanceof _e?W(t._def.innerType):t instanceof ue?[void 0]:t instanceof de?[null]:t instanceof B?[void 0,...W(t.unwrap())]:t instanceof K?[null,...W(t.unwrap())]:t instanceof je||t instanceof xe?W(t.unwrap()):t instanceof ve?W(t._def.innerType):[],et=class t extends k{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==g.object)return h(n,{code:f.invalid_type,expected:g.object,received:n.parsedType}),v;let r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(h(n,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let s=new Map;for(let i of n){let o=W(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,i)}}return new t({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...E(r)})}};function Ct(t,e){let n=H(t),r=H(e);if(t===e)return{valid:!0,data:t};if(n===g.object&&r===g.object){let s=S.objectKeys(e),i=S.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(let a of i){let c=Ct(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=Ct(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}}var pe=class extends k{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(Je(i)||Je(o))return v;let a=Ct(i.value,o.value);return a.valid?((Qe(i)||Qe(o))&&n.dirty(),{status:n.value,value:a.data}):(h(r,{code:f.invalid_intersection_types}),v)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};pe.create=(t,e,n)=>new pe({left:t,right:e,typeName:x.ZodIntersection,...E(n)});var V=class t extends k{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.array)return h(r,{code:f.invalid_type,expected:g.array,received:r.parsedType}),v;if(r.data.length<this._def.items.length)return h(r,{code:f.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&r.data.length>this._def.items.length&&(h(r,{code:f.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 j(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>I.mergeArray(n,o)):I.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};V.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new V({items:t,typeName:x.ZodTuple,rest:null,...E(e)})};var tt=class t extends k{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 h(r,{code:f.invalid_type,expected:g.object,received:r.parsedType}),v;let s=[],i=this._def.keyType,o=this._def.valueType;for(let a in r.data)s.push({key:i._parse(new j(r,a,r.path,a)),value:o._parse(new j(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?I.mergeObjectAsync(n,s):I.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof k?new t({keyType:e,valueType:n,typeName:x.ZodRecord,...E(r)}):new t({keyType:te.create(),valueType:e,typeName:x.ZodRecord,...E(n)})}},Re=class extends k{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 h(r,{code:f.invalid_type,expected:g.map,received:r.parsedType}),v;let s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,c],l)=>({key:s._parse(new j(r,a,r.path,[l,"key"])),value:i._parse(new j(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 v;(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 v;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(l.value,u.value)}return{status:n.value,value:a}}}};Re.create=(t,e,n)=>new Re({valueType:e,keyType:t,typeName:x.ZodMap,...E(n)});var Ce=class t extends k{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.set)return h(r,{code:f.invalid_type,expected:g.set,received:r.parsedType}),v;let s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(h(r,{code:f.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:f.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 v;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 j(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:_.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:_.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};Ce.create=(t,e)=>new Ce({valueType:t,minSize:null,maxSize:null,typeName:x.ZodSet,...E(e)});var nt=class t extends k{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==g.function)return h(n,{code:f.invalid_type,expected:g.function,received:n.parsedType}),v;function r(a,c){return Be({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,ke(),G].filter(l=>!!l),issueData:{code:f.invalid_arguments,argumentsError:c}})}function s(a,c){return Be({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,ke(),G].filter(l=>!!l),issueData:{code:f.invalid_return_type,returnTypeError:c}})}let i={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof re){let a=this;return O(async function(...c){let l=new P([]),u=await a._def.args.parseAsync(c,i).catch(y=>{throw l.addIssue(r(c,y)),l}),d=await Reflect.apply(o,this,u);return await a._def.returns._def.type.parseAsync(d,i).catch(y=>{throw l.addIssue(s(d,y)),l})})}else{let a=this;return O(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),d=a._def.returns.safeParse(u,i);if(!d.success)throw new P([s(u,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:V.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||V.create([]).rest(q.create()),returns:n||q.create(),typeName:x.ZodFunction,...E(r)})}},me=class extends k{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})}};me.create=(t,e)=>new me({getter:t,typeName:x.ZodLazy,...E(e)});var he=class extends k{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return h(n,{received:n.data,code:f.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}};he.create=(t,e)=>new he({value:t,typeName:x.ZodLiteral,...E(e)});function sr(t,e){return new ge({values:t,typeName:x.ZodEnum,...E(e)})}var ge=class t extends k{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return h(n,{expected:S.joinValues(r),received:n.parsedType,code:f.invalid_type}),v}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return h(n,{received:n.data,code:f.invalid_enum_value,options:r}),v}return O(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};ge.create=sr;var ye=class extends k{_parse(e){let n=S.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==g.string&&r.parsedType!==g.number){let s=S.objectValues(n);return h(r,{expected:S.joinValues(s),received:r.parsedType,code:f.invalid_type}),v}if(this._cache||(this._cache=new Set(S.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=S.objectValues(n);return h(r,{received:r.data,code:f.invalid_enum_value,options:s}),v}return O(e.data)}get enum(){return this._def.values}};ye.create=(t,e)=>new ye({values:t,typeName:x.ZodNativeEnum,...E(e)});var re=class extends k{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==g.promise&&n.common.async===!1)return h(n,{code:f.invalid_type,expected:g.promise,received:n.parsedType}),v;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})))}};re.create=(t,e)=>new re({type:t,typeName:x.ZodPromise,...E(e)});var z=class extends k{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{h(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return v;let c=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return c.status==="aborted"?v:c.status==="dirty"?ie(c.value):n.value==="dirty"?ie(c.value):c});{if(n.value==="aborted")return v;let a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?v:a.status==="dirty"?ie(a.value):n.value==="dirty"?ie(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"?v:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?v:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!ee(o))return v;let a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>ee(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:n.value,value:a})):v);S.assertNever(s)}};z.create=(t,e,n)=>new z({schema:t,typeName:x.ZodEffects,effect:e,...E(n)});z.createWithPreprocess=(t,e,n)=>new z({schema:e,effect:{type:"preprocess",transform:t},typeName:x.ZodEffects,...E(n)});var B=class extends k{_parse(e){return this._getType(e)===g.undefined?O(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};B.create=(t,e)=>new B({innerType:t,typeName:x.ZodOptional,...E(e)});var K=class extends k{_parse(e){return this._getType(e)===g.null?O(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};K.create=(t,e)=>new K({innerType:t,typeName:x.ZodNullable,...E(e)});var _e=class extends k{_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}};_e.create=(t,e)=>new _e({innerType:t,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...E(e)});var ve=class extends k{_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 we(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}};ve.create=(t,e)=>new ve({innerType:t,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...E(e)});var Ie=class extends k{_parse(e){if(this._getType(e)!==g.nan){let r=this._getOrReturnCtx(e);return h(r,{code:f.invalid_type,expected:g.nan,received:r.parsedType}),v}return{status:"valid",value:e.data}}};Ie.create=t=>new Ie({typeName:x.ZodNaN,...E(t)});var zi=Symbol("zod_brand"),je=class extends k{_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}},ze=class t extends k{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?v:i.status==="dirty"?(n.dirty(),ie(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{let s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?v:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:x.ZodPipeline})}},xe=class extends k{_parse(e){let n=this._def.innerType._parse(e),r=s=>(ee(s)&&(s.value=Object.freeze(s.value)),s);return we(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};xe.create=(t,e)=>new xe({innerType:t,typeName:x.ZodReadonly,...E(e)});function er(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function ir(t,e={},n){return t?ne.create().superRefine((r,s)=>{let i=t(r);if(i instanceof Promise)return i.then(o=>{if(!o){let a=er(e,r),c=a.fatal??n??!0;s.addIssue({code:"custom",...a,fatal:c})}});if(!i){let o=er(e,r),a=o.fatal??n??!0;s.addIssue({code:"custom",...o,fatal:a})}}):ne.create()}var Zi={object:D.lazycreate},x;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(x||(x={}));var Ui=(t,e={message:`Input not instance of ${t.name}`})=>ir(n=>n instanceof t,e),or=te.create,ar=oe.create,Hi=Ie.create,Vi=ae.create,cr=ce.create,Ki=le.create,Gi=Te.create,Wi=ue.create,qi=de.create,Yi=ne.create,Xi=q.create,Ji=Z.create,Qi=Ae.create,eo=Y.create,to=D.create,no=D.strictCreate,ro=fe.create,so=et.create,io=pe.create,oo=V.create,ao=tt.create,co=Re.create,lo=Ce.create,uo=nt.create,fo=me.create,po=he.create,mo=ge.create,ho=ye.create,go=re.create,yo=z.create,_o=B.create,vo=K.create,xo=z.createWithPreprocess,bo=ze.create,Eo=()=>or().optional(),ko=()=>ar().optional(),wo=()=>cr().optional(),So={string:(t=>te.create({...t,coerce:!0})),number:(t=>oe.create({...t,coerce:!0})),boolean:(t=>ce.create({...t,coerce:!0})),bigint:(t=>ae.create({...t,coerce:!0})),date:(t=>le.create({...t,coerce:!0}))};var To=v;var $e=m.object({slug:m.string().min(1).max(64),description:m.string().max(255).optional(),match_command:m.string().min(1),priority:m.number().int().default(50),strip_ansi:m.boolean().default(!1),strip_lines_matching:m.array(m.string()).default([]),keep_failures:m.boolean().default(!1),fold_passing:m.boolean().default(!1),fold_passing_threshold:m.number().int().positive().max(1e3).optional(),mask_abs_paths:m.boolean().default(!1),preserve_exact:m.boolean().default(!1),truncate_lines_at:m.number().int().positive().max(1e4).optional(),max_lines:m.number().int().positive().max(1e5).optional(),scale_with_level:m.boolean().default(!0),transform:m.string().max(64).optional(),on_empty:m.string().max(255).optional()});var $o=Co(Io(import.meta.url)),lr=process.env.TOKMIZER_FILTERS_DIR||dr($o,"..","..","filters"),se=null,ur=!1;function Oo(){return process.env.TOKMIZER_DEV==="1"||process.env.TOKMIZER_DEV==="true"}async function fr(){if(se)return se;if(!Oo())return!ur&&process.env.TOKMIZER_DEBUG==="1"&&(process.stderr.write(`tokmizer: disk loader disabled (set TOKMIZER_DEV=1 to re-enable for local dev).
4
- `),ur=!0),se=new Map,se;let t=new Map,e,n;try{e=(await import("smol-toml")).parse,n=(await Ao(lr)).filter(r=>r.endsWith(".toml"))}catch{return se=t,se}for(let r of n){let s=await Ro(dr(lr,r),"utf8"),o=e(s).filters;if(o)for(let[a,c]of Object.entries(o)){let l=$e.parse({slug:a,...c});t.set(a,{...l,matchRegex:new RegExp(l.match_command)})}}return se=t,se}import{createHash as Po}from"node:crypto";var Do=m.enum(["normal","compact","minimal"]),No=m.enum(["off","light","balanced","max"]),It=m.object({enabled:m.boolean().default(!0),telemetryOptIn:m.boolean().default(!0),outputVerbosity:Do.default("compact"),reducer:No.default("off"),filters:m.object({enableAll:m.boolean().default(!0),disabled:m.array(m.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})}),Mo=["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"],Lo=/^[0-9a-f]{16}$/,pr=new Map;function U(t){let e=pr.get(t);return e||(e=Po("sha256").update(`tkr:${t}`).digest("hex").slice(0,16),pr.set(t,e)),e}var mr=null;function rt(t,e=!1){return e||!t||t.length===0?(mr??=new Set(Mo.map(U)),new Set(mr)):new Set(t.map(n=>Lo.test(n)?n:U(n)))}var Oe=new Map,Fo=256,hr=new WeakMap;function Bo(t){if(!t)return"*";let e=hr.get(t);return e===void 0&&(e=[...t].join(","),hr.set(t,e)),e}function st(t,e,n){let r=`${t}::${Bo(n)}`,s=Oe.get(r);if(s!==void 0)return s;let i=null;for(let o of e)n&&!n.has(U(o.slug))||o.matchRegex.test(t)&&(!i||o.priority>i.priority)&&(i=o);if(Oe.size>=Fo){let o=Oe.keys().next().value;o&&Oe.delete(o)}return Oe.set(r,i),i}function gr(){Oe.clear()}var jo=/\x1b\[[0-9;?]*[ -/]*[@-~]/g,zo=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g;function yr(t){return t.replace(jo,"").replace(zo,"")}function _r(t,e){return e.length===0?t:t.filter(n=>!e.some(r=>r.test(n)))}function vr(t,e){return t.map(n=>n.length<=e?n:`${n.slice(0,e)}\u2026`)}function it(t){return`\u2026 (${t} more lines omitted)`}function xr(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),it(s.length),...t.slice(t.length-r)],dropped:s}}var Zo=/^\s*(?:[✓✔√]|ok )/,Ze=/✕|✗|×|\bFAIL\b|\bERROR\b|\bFATAL\b|\bError|\berror|Expected|Received|\bfailed\b|^\s*Tests?:|^\s*Test Suites?:/;function br(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)Zo.test(a)&&!Ze.test(a)?(o.push(a),s+=1):(i(o),o=[],s=0,r.push(a));return i(o),r}var Uo=/(?:\/[\w.@+-]+){3,}/g;function Er(t){return t.map(e=>e.replace(Uo,n=>{let r=n.split("/").filter(Boolean);return r.length<=2?n:`\u2026/${r.slice(-2).join("/")}`}))}var Ho=/^(\s*)(?:export\s+)?(?:async\s+)?(?:function|interface|type|const|let|var|def|fn|impl|trait|struct|enum)\s+[\w$]+/,Vo=/\{\s*$/;var Ko=/^\s*(?:(?:public|private|protected|static|async|get|set|readonly|override)\s+)*([\w$]+)\s*\(([^)]*)\)\s*(?::\s*[^{]+)?\{\s*$/,Go=new Set(["if","for","while","switch","catch","do","with","return","else","function","await","yield"]);function Wo(t){let e=Ko.exec(t);return!e||Go.has(e[1])?!1:!/=>|\bfunction\b/.test(e[2])}var qo=/^\s*(?:if|for|while|switch|try|do)\b[^{}]*\{\s*$/;function Yo(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 Xo(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==="&"))&&Yo(t,s+1,i)&&(r=i),s+=1;continue}i==="{"||i==="("||i==="["?n+=1:(i==="}"||i===")"||i==="]")&&(n-=1),s+=1}return n}var kr=/^\s*… \d+ lines? folded …$/,Jo=/^\s*… (\d+) lines? folded …$/;function $t(t){let e=new Array(t.length).fill(!1);for(let n=0;n<t.length;n+=1){let r=Jo.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 ot(t){let e=[],n=0;for(;n<t.length;){let r=t[n];if(Ho.test(r)&&Vo.test(r)||Wo(r)||qo.test(r)){let s={inBlockComment:!1,inTemplate:!1},i=0,o=n,a=!1;for(;o<t.length&&o-n<200;)if(i+=Xo(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 d=0;d<l-1;d++)e.push("");e.push(t[o-1]),n=o;continue}}e.push(r),n+=1}return e}var Qo=/\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 wr(t){let e=t.slice(0,4096);return!(!Qo.test(e)||e.split(`
5
- `).length<6)}var ea=/\b(?:DEBUG|TRACE|INFO|VERBOSE)\b/;function Sr(t){let e=[],n=0,r=()=>{n>0&&e.push(`\u2026 ${n} verbose log line${n===1?"":"s"} dropped \u2026`),n=0};for(let s of t){if(ea.test(s)){n+=1;continue}r(),e.push(s)}return r(),e}function Tr(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 Ar(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 Rr=new Map;function N(t,e){Rr.set(t,e)}function Cr(t){return Rr.get(t)}var ta=/^[dbclps\-][rwxsStT\-]{9}[@.+]?(?:\s|$)/,na=/^[./~][^\s]*:$/,Ot=1e3;function ra(t){if(t<1024)return String(t);let e=["K","M","G","T"],n=t/1024,r=0;for(;n>=1024&&r<e.length-1;)n/=1024,r+=1;return`${n.toFixed(1)}${e[r]}`}function sa(t){if(!ta.test(t))return null;let e=t.split(/\s+/);if(e.length<9)return null;let n=Number(e[4]);if(!Number.isFinite(n))return null;let r=e.slice(8).join(" ").trim();if(r===""||r==="."||r==="..")return null;let s=e[0].charCodeAt(0)===100;return{name:r,size:n,isDir:s}}function ia(t){if(t.length<3)return null;let e=new Map;for(let s of t){let i=s.name.lastIndexOf(".");if(i<=0)continue;let o=s.name.slice(i);e.set(o,(e.get(o)??0)+1)}let n=null,r=0;for(let[s,i]of e)i>r&&(r=i,n=s);return n&&r>=Math.ceil(t.length/2)?`${r} ${n}`:null}function oa(t){let e=[],n=[],r=!1;for(let p of t){if(/^total\s+\d+/.test(p))continue;if(na.test(p.trim()))return t;let y=sa(p);y&&(r=!0,(y.isDir?e:n).push(y))}if(!r)return t;let s=(p,y)=>p.name.localeCompare(y.name);e.sort(s),n.sort((p,y)=>y.size-p.size||s(p,y));let i=[...e,...n],o=Math.min(40,Math.max(0,...i.map(p=>p.isDir?p.name.length+1:p.name.length))),a=[];for(let p of i){let y=p.isDir?`${p.name}/`:p.name,w=p.isDir?"":ra(p.size);a.push(w?`${y.padEnd(o)} ${w}`:y)}if(a.length>Ot){let p=a.length-Ot;a=[...a.slice(0,Ot),`\u2026 ${p} more lines omitted`]}let c=n.length===1?"file":"files",l=e.length===1?"dir":"dirs",u=ia(n),d=`${n.length} ${c}, ${e.length} ${l}`+(u?` (${u})`:"");return a.push(d),a}N("smart-ls",oa);N("smart-read",t=>ot(t));var Ir=1e3;function aa(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 d=u.trim();if(d.startsWith("find:")){s.push(d);continue}let p=d.replace(/^\.\//,"").replace(/\/+$/,""),y=p.lastIndexOf("/"),w=y>=0?p.slice(0,y):"",b=y>=0?p.slice(y+1):p;if(!b)continue;let C=r.get(w)??[];C.push(/\s/.test(b)?`"${b}"`:b),r.set(w,C),i+=1}if(i===0)return t;let o=new Set([""]);for(let u of r.keys()){if(u==="")continue;let d=u.split("/");for(let p=1;p<=d.length;p+=1)o.add(d.slice(0,p).join("/"))}let a=[...o].sort(),c=a.filter(u=>u!=="").length,l=[`${i}F ${c}D:`,""];for(let u of a){let d=u===""?0:u.split("/").length,p=u===""?".":u.slice(u.lastIndexOf("/")+1),y=r.get(u)??[],w=y.length?` ${y.join(" ")}`:"";l.push(`${" ".repeat(d)}${p}/${w}`)}if(l.length+s.length>Ir){let u=Math.max(0,Ir-s.length),d=l.length-u;return[...l.slice(0,u),`\u2026 ${d} more lines omitted`,...s]}return[...l,...s]}N("smart-find",aa);var Pt=1e3,$r=200,ca=60,la=190,ua=/^([^\s:]+):(\d+):(.*)$/,da=/^([^:]+?)-(\d+)-(.*)$/,fa=/^([^\s:]+):(.*)$/,Or=/(?:^|\/)(?:__tests__|tests?|spec|fixtures?|__mocks__|__snapshots__)\/|\.(?:test|spec)\.[^/]+$/i;function Pr(t){let e=t.trim();return e.length>$r?`${e.slice(0,$r)}\u2026`:e}function pa(t){let e=[],n="";for(let r of t){let s=n?`${n}, ${r}`:r;s.length>la&&n?(e.push(`${n},`),n=r):n=s}return n&&e.push(n),e}function ma(t){let e=t.filter(d=>d.trim()!=="");if(e.length===0)return t;let n=new Map,r=new Map,s=null,i=0,o=0;for(let d of e){if(d==="--"){s&&n.get(s).push({separator:!0});continue}let p=ua.exec(d),y=p?null:da.exec(d),w=p||y?null:fa.exec(d),b=(p??y??w)?.[1];if(!b)return t;let C=p?{line:p[2],content:p[3],context:!1}:y?{line:y[2],content:y[3],context:!0}:{line:"",content:w[2],context:!1},M=n.get(b)??[];M.push(C),n.set(b,M),C.context||(i+=1,r.set(b,(r.get(b)??0)+1)),o+=1,s=b}if(n.size===o)return t;let a=[...n.keys()].sort((d,p)=>{let y=Or.test(d)?1:0,w=Or.test(p)?1:0;return y-w||(d<p?-1:d>p?1:0)}),c=[];for(let d of a){c.push(`${d} (${r.get(d)??0}):`);for(let p of n.get(d))"separator"in p?c.push(" --"):p.line?c.push(` ${p.line}${p.context?"-":":"} ${Pr(p.content)}`):c.push(` ${Pr(p.content)}`)}let l=a.length>1&&c.length>ca?pa(a.map(d=>`${d} (${r.get(d)??0})`)):[],u=[`${i}m ${a.length}f:`,...l,"",...c];if(u.length>Pt){let d=u.length-Pt;return[...u.slice(0,Pt),`\u2026 ${d} more lines omitted`]}return u}N("smart-grep",ma);var Dr=/^commit [0-9a-f]{7,40}\b/,ha=/^ {4}/,ga=2;function ya(t){if(!t.some(i=>Dr.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(Dr.test(i)){s(),n=0,e.push(i);continue}if(ha.test(i)){n+=1,n<=ga?e.push(i):r+=1;continue}s(),e.push(i)}return s(),e}N("smart-log",ya);var _a=/^[\s=]+$/,va=/^\s*=+\s+(.*?)\s+=+\s*$/,xa=512;N("strip-banners",t=>{let e=[];for(let n of t){if(_a.test(n))continue;let r=n.length<=xa?va.exec(n):null;e.push(r?r[1]:n)}return e});function ba(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}N("squeeze-output",ba);function Ea(t){return t==="compact"?.6:t==="minimal"?.3:1}var ka=20,Nr=new WeakMap;function wa(t){let e=Nr.get(t);if(e)return e;let n=t.strip_lines_matching.map(s=>new RegExp(s)),r={def:t,stripRegexes:n};return Nr.set(t,r),r}function Mr(t,e,n={}){return Dt(t,e,n).text}function Dt(t,e,n={}){let r=wa(e),s=t;e.strip_ansi&&(s=yr(s));let i=s.endsWith(`
6
- `),o=(i?s.slice(0,-1):s).split(`
7
- `);r.stripRegexes.length&&(o=e.keep_failures?o.filter(d=>Ze.test(d)||!r.stripRegexes.some(p=>p.test(d))):_r(o,r.stripRegexes));let a=n.verbosity??"normal";if(a!=="normal"&&!e.preserve_exact&&(o=Tr(o),o=Ar(o)),a==="minimal"&&!e.preserve_exact&&(o=Sr(o)),!e.preserve_exact&&(n.smartCode||n.smartCode===void 0&&a!=="normal"&&wr(s))&&(o=ot(o)),e.transform){let d=Cr(e.transform);d&&(o=d(o))}let c=e.slug==="read-tool";if(!c){let d=$t(o);d.some(Boolean)&&(o=o.filter((p,y)=>!d[y]))}e.mask_abs_paths&&(o=Er(o)),e.fold_passing&&(o=br(o,e.fold_passing_threshold??5)),e.truncate_lines_at&&(o=vr(o,e.truncate_lines_at));let l=null;if(e.max_lines){let d=e.scale_with_level?Ea(n.verbosity):1,p=Math.min(e.max_lines,Math.max(ka,Math.round(e.max_lines*d))),y=c?$t(o):null,w=y?y.filter(b=>!b).length:o.length;if(w>p){let b=p;if(y){let M=0;for(b=0;b<o.length&&M<p;)y[b]||(M+=1),b+=1}let C=w-p;if(e.keep_failures){let M=o.slice(b),X=M.filter(J=>!Ze.test(J));l=X.length>0?X.join(`
8
- `):null,o=[...o.slice(0,b),it(C),...M.filter(J=>Ze.test(J))]}else if(c)l=o.slice(b).join(`
9
- `),o=[...o.slice(0,b),it(C)];else{let{kept:M,dropped:X}=xr(o,p);l=X.length>0?X.join(`
10
- `):null,o=M}}}let u=o.join(`
11
- `);return i&&u.length>0&&(u+=`
12
- `),u.trim().length===0&&e.on_empty&&(u=e.on_empty),{text:u,droppedTail:l}}var Sa=[/\bERROR\b/,/\bFAIL\b/,/\bFAILED\b/,/\bFATAL\b/,/^Traceback /m,/^Error: /m,/^\s+at .*\(.*:\d+:\d+\)/m,/panic:/,/SyntaxError:/,/TypeError:/,/ReferenceError:/,/thread '.*' panicked/];function Lr(t){if(!t)return!1;let e=t.split(`
13
- `),n=e.length<=60?t:[...e.slice(0,30),...e.slice(-30)].join(`
14
- `),r=n.length<=32768*2?[n]:[n.slice(0,32768),n.slice(-32768)];for(let s of Sa)for(let i of r)if(s.test(i))return!0;return!1}var Ta=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),Aa=/^[A-Za-z_][A-Za-z0-9_]*=/,Nt=/^([a-z]+)-tool(?::\s|$)/;function at(t){let e=t.trim(),n=e.split(/\s+/),r=0;for(;r<n.length;){let a=n[r];if(Aa.test(a)){r++;continue}if(Ta.has(a)){for(r++,a==="timeout"&&r<n.length&&/^\d+(?:\.\d+)?[smhd]?$/.test(n[r])&&r++;(a==="stdbuf"||a==="nice")&&r<n.length&&n[r].startsWith("-");)r++;continue}break}if(r>=n.length)return e;let s=n[r],i=s.includes("/")?s.slice(s.lastIndexOf("/")+1):s,o=n.slice(r+1);return o.length?`${i} ${o.join(" ")}`:i}var Ra=new Set(["cd","export","source","set","unset","mkdir","true",":","pushd","popd","alias","ulimit","umask","echo","printf","sleep","touch","rm","cp","mv","chmod","ln"]);function Fr(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 Ca(t){let e=Fr(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=Fr(t,!0).map(n=>n.trim()).filter(Boolean);if(e.length===0)return null;for(let n of e.slice(0,-1)){let r=at(n).split(/\s+/)[0]??"";if(!Ra.has(r))return null}return Ca(e[e.length-1])}function Br(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 jr(t){let e=Nt.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?at(r):null;return s&&s!==t?[s,t]:[t]}var zr=null;function Mt(t){zr=t}async function $a(t,e){let n=await fr();return st(t,n.values(),e)}var Oa=/^(?:grep|rg|find|eslint|ruff|flake8|mypy|prettier|biome|black|stylelint)(?:\s|$)|^git\s+(?:diff|grep)\b/,Pa=2048;async function Lt(t,e,n,r={}){let s=Buffer.byteLength(e,"utf8"),{exitCode:i,...o}=r,a=at(Br(t.startsWith("bash-tool: ")?t.slice(11):t)),c=i!=null&&i!==0&&!(i===1&&Oa.test(a)),l=i==null&&Lr(e),u=zr??$a,d=null;for(let b of jr(t))if(d=await u(b,n),d)break;if(!d&&s>=Pa&&!Nt.test(t)&&(d=await u(`bash-tool: ${t}`,n)),!d||c&&d.preserve_exact)return{output:e,filterId:null,rawBytes:s,filteredBytes:s,debugBypass:c||l};if(c){let b={...d,keep_failures:!0,transform:void 0,max_lines:void 0,truncate_lines_at:void 0},C=Mr(e,b,{verbosity:"normal",smartCode:!1});return{output:C,filterId:d.slug,rawBytes:s,filteredBytes:Buffer.byteLength(C,"utf8"),debugBypass:!0}}let p=l&&!d.preserve_exact?{...d,keep_failures:!0}:d,{text:y,droppedTail:w}=Dt(e,p,o);return{output:y,filterId:d.slug,rawBytes:s,filteredBytes:Buffer.byteLength(y,"utf8"),debugBypass:!1,droppedTail:w}}import{join as Na}from"node:path";import{mkdir as rf,readFile as Ma,writeFile as sf,unlink as of,rename as af}from"node:fs/promises";import Da from"node:os";import{join as ct}from"node:path";function T(){return process.env.TOKMIZER_HOME||ct(Da.homedir(),".tokmizer")}function Ue(){return ct(T(),"install-id")}function Ft(){return ct(T(),"content-cache")}function Zr(t){return ct(Ft(),t)}var La="state.json";function Fa(){try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t&&t.length>0?t:"Etc/UTC"}catch{return"Etc/UTC"}}function Ba(t){return t?.dir??T()}async function He(t){let e=Ba(t);try{let n=await Ma(Na(e,La),"utf8"),r=JSON.parse(n);return{...r,lastSettingsRevision:r.lastSettingsRevision??0,timeZone:r.timeZone??Fa(),bonusActive:r.bonusActive??!1,...r.bonusResetAt!==void 0?{bonusResetAt:r.bonusResetAt}:{}}}catch{return null}}function ja(){let t=Number(process.env.TOKMIZER_OFFLINE_GRACE_MS);return Number.isFinite(t)&&t>0?t:6048e5}function Ur(t,e=Date.now()){let n=t.lastHeartbeatOkAt;if(typeof n=="number"&&e-n>ja())return!0;if(t.subEndsAt){let r=Date.parse(t.subEndsAt);if(Number.isFinite(r)&&e>r)return!0}return!1}function Hr(t,e=Date.now()){return t.plan}var za=[[/(authorization\s*:\s*)([A-Za-z][A-Za-z0-9._-]*)\s+[^\s'"]+/gi,"$1$2 [REDACTED]"],[/(authorization\s*:\s*)[A-Za-z0-9._\-+/=]{8,}/gi,"$1[REDACTED]"],[/(bearer\s+)[A-Za-z0-9._\-+/=]{8,}/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-b|--cookie)[=\s]+['"]?)[^\s'";=]+=[^\s'";]+(?:\s*;\s*[^\s'";=]+=[^\s'";]+)*/gi,"$1[REDACTED]"],[/((?:^|[\s'"])(?:Set-)?Cookie\s*:\s*)[^\s'";=]+=[^\s'";]+(?:\s*;\s*[^\s'";=]+=[^\s'";]+)*/gi,"$1[REDACTED]"],[/(--?(?:password|passwd|passphrase|apipass|pass|pwd|token|api[-_]?key|secret|bearer|cookie|jwt)(?:-[a-z0-9]+)*[=\s]+)\S+/gi,"$1[REDACTED]"],[/((?:^|\s)-b[=\s]?['"]?)[^\s'"=]+=[^\s'"]+/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?[^\s:/'"]*:)(\/[^/\s'"][^\s'"]*|[^\s/'"0-9][^\s'"]*|[0-9][^\s'"]*[^\s'"0-9][^\s'"]*)/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?[^\s:/'"]*[^\s:/'"0-9][^\s:/'"]*:)(?:\/[^/\s'"]|[^\s/'"])[^\s'"]*/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?:)(?:\/[^/\s'"]|[^\s/'"])[^\s'"]*/gi,"$1[REDACTED]"],[/((?:[A-Za-z0-9]+-){0,8}(?:X-Api-Key|Private-Token|[A-Za-z0-9]+-(?:Token|Key|Auth|Secret))\s*:\s*)[^\s'"]+/gi,"$1[REDACTED]"],[/((?:^|[\s'"])(?:Set-)?Cookie\s*:\s*)[^\s'"]+/gi,"$1[REDACTED]"],[/(-i\s+)(\/[^\s]+|~\/[^\s]+|[A-Z]:\\[^\s]+)/g,"$1[REDACTED]"],[/([a-zA-Z][a-zA-Z0-9+.-]{0,31}:\/\/[^:/\s@]*:)[^\s@]+(@[^@/\s]+)/g,"$1[REDACTED]$2"],[/(AWS_(?:ACCESS_KEY_ID|SECRET_ACCESS_KEY|SESSION_TOKEN)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(GOOGLE_APPLICATION_CREDENTIALS\s*=\s*)\S+/g,"$1[REDACTED]"],[/(AZURE_(?:CLIENT_SECRET|TENANT_ID|CLIENT_ID)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-(?:proj-)?[A-Za-z0-9_-]{20,})/g,"sk-[REDACTED]"],[/\b(OPENAI_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(ANTHROPIC_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-ant-[A-Za-z0-9_-]{20,})/g,"sk-ant-[REDACTED]"],[/\b(GH(?:_|ITHUB_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(GITLAB_TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(SLACK_(?:BOT_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/(xox[bpsoa]-[A-Za-z0-9-]{10,})/g,"xox[REDACTED]"],[/(xapp-[A-Za-z0-9-]{10,})/g,"[REDACTED]"],[/(sk_(?:test|live)_[A-Za-z0-9]{16,})/g,"sk_[REDACTED]"],[/(gh[a-z])_[A-Za-z0-9]{20,}/g,"$1_[REDACTED]"],[/(github_pat)_[A-Za-z0-9_]{20,}/g,"$1_[REDACTED]"],[/(gl(?:pat|rt|soat|imt|dt|ft|agent|oas|cbt|ptt))-[A-Za-z0-9_-]{16,}/g,"$1-[REDACTED]"],[/(npm_[A-Za-z0-9_-]{20,})/g,"npm_[REDACTED]"],[/(?:AKIA|ASIA|AGPA|AIDA|AROA|ANPA)[0-9A-Z]{16,}/g,"[REDACTED_AWS_KEY]"],[/AIza[A-Za-z0-9_-]{35}/g,"[REDACTED_GOOGLE_KEY]"],[/hv[sb]\.[A-Za-z0-9_-]{20,}/g,"[REDACTED_VAULT_TOKEN]"],[/dop_v1_[A-Za-z0-9]{40,}/g,"[REDACTED]"],[/dckr_pat_[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/pypi-[A-Za-z0-9_-]{16,}/g,"[REDACTED]"],[/rk_(?:live|test)_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/whsec_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/SG\.[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/(eyJ[A-Za-z0-9_-]{6,}(?:\.[A-Za-z0-9_-]{4,}){1,2})/g,"[REDACTED_JWT]"],[/-----BEGIN [A-Z ]*PRIVATE KEY-----(?:[\s\S]*?-----END[^\n]*-----|\r?\n[A-Za-z0-9+/=][A-Za-z0-9+/=\r\n]*)?/g,"[REDACTED_PEM]"],[/\b((?:--?)?[A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|AUTH|_PWD)[A-Za-z0-9_]*['"]?\s*=\s*)(?:"[^"]*"|'[^']*'|[^"'\s]\S*)/gi,"$1[REDACTED]"],[/\b([A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|_PWD)[A-Za-z0-9_]*['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/((?:^|[\s'"{,])['"]?(?:[A-Za-z0-9_]+_)?auth['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/(\bpwd\s*[=:]\s*)(?:"[^"]*"|'[^']*'|[^/~\s][^\s;'"]*)/gi,"$1[REDACTED]"],[/([=:]\s*["']?)[A-Za-z0-9_\-+/=]{40,}/g,"$1[REDACTED]"]];function Ve(t){let e=t;for(let[n,r]of za)e=e.replace(n,r);return e}import{join as Yr}from"node:path";import{appendFileSync as Xa,chmodSync as Ja,existsSync as Qa,mkdirSync as ec,readFileSync as Lf,renameSync as Ff,rmdirSync as Bf,statSync as tc,unlinkSync as jf,utimesSync as zf,writeFileSync as Zf}from"node:fs";import{createHash as pf,randomUUID as Za}from"node:crypto";import{readFile as Vr,writeFile as Kr,mkdir as Ua}from"node:fs/promises";async function Bt(){try{let n=(await Vr(Ue(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(n))return n}catch{}await Ua(T(),{recursive:!0});let t=Za();try{return await Kr(Ue(),t,{mode:384,flag:"wx"}),t}catch{try{let e=(await Vr(Ue(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(e))return e}catch{}return await Kr(Ue(),t,{mode:384}),t}}import{createRequire as Ha}from"node:module";var Va=Ha(import.meta.url);function Ka(){for(let t of["../package.json","../../package.json"])try{let e=Va(t).version;if(typeof e=="string"&&e)return e}catch{}return"0.0.0"}var jt=Ka();var Gr=`-----BEGIN PUBLIC KEY-----
3
+ var Ws=Object.create;var vt=Object.defineProperty;var qs=Object.getOwnPropertyDescriptor;var Ys=Object.getOwnPropertyNames;var Js=Object.getPrototypeOf,Xs=Object.prototype.hasOwnProperty;var Q=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var B=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},Qs=(t,e)=>{for(var r in e)vt(t,r,{get:e[r],enumerable:!0})},ei=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ys(e))!Xs.call(t,s)&&s!==r&&vt(t,s,{get:()=>e[s],enumerable:!(n=qs(e,s))||n.enumerable});return t};var _r=(t,e,r)=>(r=t!=null?Ws(Js(t)):{},ei(e||!t||!t.__esModule?vt(r,"default",{value:t,enumerable:!0}):r,t));var wr=B(($l,Er)=>{Er.exports=xr;xr.sync=ri;var br=Q("fs");function ti(t,e){var r=e.pathExt!==void 0?e.pathExt:process.env.PATHEXT;if(!r||(r=r.split(";"),r.indexOf("")!==-1))return!0;for(var n=0;n<r.length;n++){var s=r[n].toLowerCase();if(s&&t.substr(-s.length).toLowerCase()===s)return!0}return!1}function vr(t,e,r){return!t.isSymbolicLink()&&!t.isFile()?!1:ti(e,r)}function xr(t,e,r){br.stat(t,function(n,s){r(n,n?!1:vr(s,t,e))})}function ri(t,e){return vr(br.statSync(t),t,e)}});var Ar=B((Ol,Rr)=>{Rr.exports=Sr;Sr.sync=ni;var kr=Q("fs");function Sr(t,e,r){kr.stat(t,function(n,s){r(n,n?!1:Tr(s,e))})}function ni(t,e){return Tr(kr.statSync(t),e)}function Tr(t,e){return t.isFile()&&si(t,e)}function si(t,e){var r=t.mode,n=t.uid,s=t.gid,i=e.uid!==void 0?e.uid:process.getuid&&process.getuid(),o=e.gid!==void 0?e.gid:process.getgid&&process.getgid(),a=parseInt("100",8),u=parseInt("010",8),c=parseInt("001",8),l=a|u,f=r&c||r&u&&s===o||r&a&&n===i||r&l&&i===0;return f}});var Ir=B((Dl,Cr)=>{var Nl=Q("fs"),st;process.platform==="win32"||global.TESTING_WINDOWS?st=wr():st=Ar();Cr.exports=xt;xt.sync=ii;function xt(t,e,r){if(typeof e=="function"&&(r=e,e={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(n,s){xt(t,e||{},function(i,o){i?s(i):n(o)})})}st(t,e||{},function(n,s){n&&(n.code==="EACCES"||e&&e.ignoreErrors)&&(n=null,s=!1),r(n,s)})}function ii(t,e){try{return st.sync(t,e||{})}catch(r){if(e&&e.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var Lr=B((Pl,Mr)=>{var Ae=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",$r=Q("path"),oi=Ae?";":":",Or=Ir(),Nr=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),Dr=(t,e)=>{let r=e.colon||oi,n=t.match(/\//)||Ae&&t.match(/\\/)?[""]:[...Ae?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(r)],s=Ae?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",i=Ae?s.split(r):[""];return Ae&&t.indexOf(".")!==-1&&i[0]!==""&&i.unshift(""),{pathEnv:n,pathExt:i,pathExtExe:s}},Pr=(t,e,r)=>{typeof e=="function"&&(r=e,e={}),e||(e={});let{pathEnv:n,pathExt:s,pathExtExe:i}=Dr(t,e),o=[],a=c=>new Promise((l,f)=>{if(c===n.length)return e.all&&o.length?l(o):f(Nr(t));let d=n[c],m=/^".*"$/.test(d)?d.slice(1,-1):d,_=$r.join(m,t),x=!m&&/^\.[\\\/]/.test(t)?t.slice(0,2)+_:_;l(u(x,c,0))}),u=(c,l,f)=>new Promise((d,m)=>{if(f===s.length)return d(a(l+1));let _=s[f];Or(c+_,{pathExt:i},(x,A)=>{if(!x&&A)if(e.all)o.push(c+_);else return d(c+_);return d(u(c,l,f+1))})});return r?a(0).then(c=>r(null,c),r):a(0)},ai=(t,e)=>{e=e||{};let{pathEnv:r,pathExt:n,pathExtExe:s}=Dr(t,e),i=[];for(let o=0;o<r.length;o++){let a=r[o],u=/^".*"$/.test(a)?a.slice(1,-1):a,c=$r.join(u,t),l=!u&&/^\.[\\\/]/.test(t)?t.slice(0,2)+c:c;for(let f=0;f<n.length;f++){let d=l+n[f];try{if(Or.sync(d,{pathExt:s}))if(e.all)i.push(d);else return d}catch{}}}if(e.all&&i.length)return i;if(e.nothrow)return null;throw Nr(t)};Mr.exports=Pr;Pr.sync=ai});var Br=B((Ml,Et)=>{"use strict";var Fr=(t={})=>{let e=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};Et.exports=Fr;Et.exports.default=Fr});var Ur=B((Ll,Zr)=>{"use strict";var jr=Q("path"),ci=Lr(),ui=Br();function zr(t,e){let r=t.options.env||process.env,n=process.cwd(),s=t.options.cwd!=null,i=s&&process.chdir!==void 0&&!process.chdir.disabled;if(i)try{process.chdir(t.options.cwd)}catch{}let o;try{o=ci.sync(t.command,{path:r[ui({env:r})],pathExt:e?jr.delimiter:void 0})}catch{}finally{i&&process.chdir(n)}return o&&(o=jr.resolve(s?t.options.cwd:"",o)),o}function li(t){return zr(t)||zr(t,!0)}Zr.exports=li});var Hr=B((Fl,kt)=>{"use strict";var wt=/([()\][%!^"`<>&|;, *?])/g;function di(t){return t=t.replace(wt,"^$1"),t}function fi(t,e){return t=`${t}`,t=t.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),t=t.replace(/(?=(\\+?)?)\1$/,"$1$1"),t=`"${t}"`,t=t.replace(wt,"^$1"),e&&(t=t.replace(wt,"^$1")),t}kt.exports.command=di;kt.exports.argument=fi});var Gr=B((Bl,Vr)=>{"use strict";Vr.exports=/^#!(.*)/});var Wr=B((jl,Kr)=>{"use strict";var pi=Gr();Kr.exports=(t="")=>{let e=t.match(pi);if(!e)return null;let[r,n]=e[0].replace(/#! ?/,"").split(" "),s=r.split("/").pop();return s==="env"?n:n?`${s} ${n}`:s}});var Yr=B((zl,qr)=>{"use strict";var St=Q("fs"),mi=Wr();function hi(t){let r=Buffer.alloc(150),n;try{n=St.openSync(t,"r"),St.readSync(n,r,0,150,0),St.closeSync(n)}catch{}return mi(r.toString())}qr.exports=hi});var en=B((Zl,Qr)=>{"use strict";var gi=Q("path"),Jr=Ur(),Xr=Hr(),yi=Yr(),_i=process.platform==="win32",bi=/\.(?:com|exe)$/i,vi=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function xi(t){t.file=Jr(t);let e=t.file&&yi(t.file);return e?(t.args.unshift(t.file),t.command=e,Jr(t)):t.file}function Ei(t){if(!_i)return t;let e=xi(t),r=!bi.test(e);if(t.options.forceShell||r){let n=vi.test(e);t.command=gi.normalize(t.command),t.command=Xr.command(t.command),t.args=t.args.map(i=>Xr.argument(i,n));let s=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${s}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}function wi(t,e,r){e&&!Array.isArray(e)&&(r=e,e=null),e=e?e.slice(0):[],r=Object.assign({},r);let n={command:t,args:e,options:r,file:void 0,original:{command:t,args:e}};return r.shell?n:Ei(n)}Qr.exports=wi});var nn=B((Ul,rn)=>{"use strict";var Tt=process.platform==="win32";function Rt(t,e){return Object.assign(new Error(`${e} ${t.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${t.command}`,path:t.command,spawnargs:t.args})}function ki(t,e){if(!Tt)return;let r=t.emit;t.emit=function(n,s){if(n==="exit"){let i=tn(s,e);if(i)return r.call(t,"error",i)}return r.apply(t,arguments)}}function tn(t,e){return Tt&&t===1&&!e.file?Rt(e.original,"spawn"):null}function Si(t,e){return Tt&&t===1&&!e.file?Rt(e.original,"spawnSync"):null}rn.exports={hookChildProcess:ki,verifyENOENT:tn,verifyENOENTSync:Si,notFoundError:Rt}});var It=B((Hl,Ce)=>{"use strict";var sn=Q("child_process"),At=en(),Ct=nn();function on(t,e,r){let n=At(t,e,r),s=sn.spawn(n.command,n.args,n.options);return Ct.hookChildProcess(s,n),s}function Ti(t,e,r){let n=At(t,e,r),s=sn.spawnSync(n.command,n.args,n.options);return s.error=s.error||Ct.verifyENOENTSync(s.status,n),s}Ce.exports=on;Ce.exports.spawn=on;Ce.exports.sync=Ti;Ce.exports._parse=At;Ce.exports._enoent=Ct});var Ks=_r(It(),1);var cr=_r(It(),1);import{existsSync as hl,readFileSync as gl,writeFileSync as yl,mkdirSync as _l}from"node:fs";import{join as bl}from"node:path";import{fileURLToPath as vl}from"node:url";import{StringDecoder as xl}from"node:string_decoder";import{readdir as Fo,readFile as Bo}from"node:fs/promises";import{join as vn,dirname as jo}from"node:path";import{fileURLToPath as zo}from"node:url";var h={};Qs(h,{BRAND:()=>Xi,DIRTY:()=>ue,EMPTY_PATH:()=>Ii,INVALID:()=>v,NEVER:()=>Lo,OK:()=>N,ParseStatus:()=>O,Schema:()=>S,ZodAny:()=>re,ZodArray:()=>X,ZodBigInt:()=>de,ZodBoolean:()=>fe,ZodBranded:()=>Ke,ZodCatch:()=>we,ZodDate:()=>pe,ZodDefault:()=>Ee,ZodDiscriminatedUnion:()=>at,ZodEffects:()=>Z,ZodEnum:()=>ve,ZodError:()=>M,ZodFirstPartyTypeKind:()=>E,ZodFunction:()=>ut,ZodIntersection:()=>ye,ZodIssueCode:()=>p,ZodLazy:()=>_e,ZodLiteral:()=>be,ZodMap:()=>Pe,ZodNaN:()=>Le,ZodNativeEnum:()=>xe,ZodNever:()=>H,ZodNull:()=>he,ZodNullable:()=>W,ZodNumber:()=>le,ZodObject:()=>L,ZodOptional:()=>j,ZodParsedType:()=>y,ZodPipeline:()=>We,ZodPromise:()=>ne,ZodReadonly:()=>ke,ZodRecord:()=>ct,ZodSchema:()=>S,ZodSet:()=>Me,ZodString:()=>te,ZodSymbol:()=>Ne,ZodTransformer:()=>Z,ZodTuple:()=>K,ZodType:()=>S,ZodUndefined:()=>me,ZodUnion:()=>ge,ZodUnknown:()=>J,ZodVoid:()=>De,addIssueToContext:()=>g,any:()=>ao,array:()=>fo,bigint:()=>ro,boolean:()=>yn,coerce:()=>Mo,custom:()=>mn,date:()=>no,datetimeRegex:()=>fn,defaultErrorMap:()=>q,discriminatedUnion:()=>go,effect:()=>Ao,enum:()=>So,function:()=>Eo,getErrorMap:()=>Ie,getParsedType:()=>G,instanceof:()=>eo,intersection:()=>yo,isAborted:()=>it,isAsync:()=>$e,isDirty:()=>ot,isValid:()=>ee,late:()=>Qi,lazy:()=>wo,literal:()=>ko,makeIssue:()=>Ge,map:()=>vo,nan:()=>to,nativeEnum:()=>To,never:()=>uo,null:()=>oo,nullable:()=>Io,number:()=>gn,object:()=>po,objectUtil:()=>$t,oboolean:()=>Po,onumber:()=>Do,optional:()=>Co,ostring:()=>No,pipeline:()=>Oo,preprocess:()=>$o,promise:()=>Ro,quotelessJson:()=>Ri,record:()=>bo,set:()=>xo,setErrorMap:()=>Ci,strictObject:()=>mo,string:()=>hn,symbol:()=>so,transformer:()=>Ao,tuple:()=>_o,undefined:()=>io,union:()=>ho,unknown:()=>co,util:()=>T,void:()=>lo});var T;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{let i={};for(let 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 n(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=n,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(T||(T={}));var $t;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})($t||($t={}));var y=T.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),G=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=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"]),Ri=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),M=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(i){return i.message},n={_errors:[]},s=i=>{for(let 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)n._errors.push(r(o));else{let a=n,u=0;for(;u<o.path.length;){let c=o.path[u];u===o.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(r(o))):a[c]=a[c]||{_errors:[]},a=a[c],u++}}};return s(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,T.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];r[i]=r[i]||[],r[i].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};M.create=t=>new M(t);var Ai=(t,e)=>{let r;switch(t.code){case p.invalid_type:t.received===y.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case p.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,T.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:r=`Unrecognized key(s) in object: ${T.joinValues(t.keys,", ")}`;break;case p.invalid_union:r="Invalid input";break;case p.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${T.joinValues(t.options)}`;break;case p.invalid_enum_value:r=`Invalid enum value. Expected ${T.joinValues(t.options)}, received '${t.received}'`;break;case p.invalid_arguments:r="Invalid function arguments";break;case p.invalid_return_type:r="Invalid function return type";break;case p.invalid_date:r="Invalid date";break;case p.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:T.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case p.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case p.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case p.custom:r="Invalid input";break;case p.invalid_intersection_types:r="Intersection results could not be merged";break;case p.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case p.not_finite:r="Number must be finite";break;default:r=e.defaultError,T.assertNever(t)}return{message:r}},q=Ai;var an=q;function Ci(t){an=t}function Ie(){return an}var Ge=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,i=[...r,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="",u=n.filter(c=>!!c).slice().reverse();for(let c of u)a=c(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}},Ii=[];function g(t,e){let r=Ie(),n=Ge({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===q?void 0:q].filter(s=>!!s)});t.common.issues.push(n)}var O=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return v;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r){let i=await s.key,o=await s.value;n.push({key:i,value:o})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return v;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(n[i.value]=o.value)}return{status:e.value,value:n}}},v=Object.freeze({status:"aborted"}),ue=t=>({status:"dirty",value:t}),N=t=>({status:"valid",value:t}),it=t=>t.status==="aborted",ot=t=>t.status==="dirty",ee=t=>t.status==="valid",$e=t=>typeof Promise<"u"&&t instanceof Promise;var b;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(b||(b={}));var z=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},cn=(t,e)=>{if(ee(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new M(t.common.issues);return this._error=r,this._error}}};function k(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{let{message:u}=t;return o.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:u??n??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:u??r??a.defaultError}},description:s}}var S=class{get description(){return this._def.description}_getType(e){return G(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:G(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new O,ctx:{common:e.parent.common,data:e.data,parsedType:G(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if($e(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:G(e)},s=this._parseSync({data:e,path:n.path,parent:n});return cn(n,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:G(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return ee(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>ee(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:G(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await($e(s)?s:Promise.resolve(s));return cn(n,i)}refine(e,r){let n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,i)=>{let o=e(s),a=()=>i.addIssue({code:p.custom,...n(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new Z({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:r=>this["~validate"](r)}}optional(){return j.create(this,this._def)}nullable(){return W.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return X.create(this)}promise(){return ne.create(this,this._def)}or(e){return ge.create([this,e],this._def)}and(e){return ye.create(this,e,this._def)}transform(e){return new Z({...k(this._def),schema:this,typeName:E.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Ee({...k(this._def),innerType:this,defaultValue:r,typeName:E.ZodDefault})}brand(){return new Ke({typeName:E.ZodBranded,type:this,...k(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new we({...k(this._def),innerType:this,catchValue:r,typeName:E.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return We.create(this,e)}readonly(){return ke.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},$i=/^c[^\s-]{8,}$/i,Oi=/^[0-9a-z]+$/,Ni=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Di=/^[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,Pi=/^[a-z0-9_-]{21}$/i,Mi=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Li=/^[-+]?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)?)??$/,Fi=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Bi="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ot,ji=/^(?:(?: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])$/,zi=/^(?:(?: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])$/,Zi=/^(([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]))$/,Ui=/^(([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])$/,Hi=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Vi=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ln="((\\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])))",Gi=new RegExp(`^${ln}$`);function dn(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function Ki(t){return new RegExp(`^${dn(t)}$`)}function fn(t){let e=`${ln}T${dn(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function Wi(t,e){return!!((e==="v4"||!e)&&ji.test(t)||(e==="v6"||!e)&&Zi.test(t))}function qi(t,e){if(!Mi.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Yi(t,e){return!!((e==="v4"||!e)&&zi.test(t)||(e==="v6"||!e)&&Ui.test(t))}var te=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 g(i,{code:p.invalid_type,expected:y.string,received:i.parsedType}),v}let n=new O,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:p.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:p.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.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?g(s,{code:p.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&g(s,{code:p.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Fi.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"email",code:p.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")Ot||(Ot=new RegExp(Bi,"u")),Ot.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"emoji",code:p.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")Di.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"uuid",code:p.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")Pi.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"nanoid",code:p.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")$i.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"cuid",code:p.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")Oi.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"cuid2",code:p.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")Ni.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"ulid",code:p.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),g(s,{validation:"url",code:p.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"regex",code:p.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),g(s,{code:p.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),g(s,{code:p.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),g(s,{code:p.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?fn(i).test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{code:p.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?Gi.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{code:p.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?Ki(i).test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{code:p.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?Li.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"duration",code:p.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?Wi(e.data,i.version)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"ip",code:p.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?qi(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"jwt",code:p.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?Yi(e.data,i.version)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"cidr",code:p.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?Hi.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"base64",code:p.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?Vi.test(e.data)||(s=this._getOrReturnCtx(e,s),g(s,{validation:"base64url",code:p.invalid_string,message:i.message}),n.dirty()):T.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:p.invalid_string,...b.errToObj(n)})}_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,r){return this._addCheck({kind:"regex",regex:e,...b.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...b.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...b.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...b.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...b.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...b.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...b.errToObj(r)})}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 r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};te.create=t=>new te({checks:[],typeName:E.ZodString,coerce:t?.coerce??!1,...k(t)});function Ji(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}var 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 g(i,{code:p.invalid_type,expected:y.number,received:i.parsedType}),v}let n,s=new O;for(let i of this._def.checks)i.kind==="int"?T.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{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)&&(n=this._getOrReturnCtx(e,n),g(n,{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)&&(n=this._getOrReturnCtx(e,n),g(n,{code:p.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Ji(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),g(n,{code:p.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),g(n,{code:p.not_finite,message:i.message}),s.dirty()):T.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,b.toString(r))}gt(e,r){return this.setLimit("min",e,!1,b.toString(r))}lte(e,r){return this.setLimit("max",e,!0,b.toString(r))}lt(e,r){return this.setLimit("max",e,!1,b.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,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,r){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(r)})}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 r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&T.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};le.create=t=>new le({checks:[],typeName:E.ZodNumber,coerce:t?.coerce||!1,...k(t)});var de=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 n,s=new O;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),g(n,{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)&&(n=this._getOrReturnCtx(e,n),g(n,{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)&&(n=this._getOrReturnCtx(e,n),g(n,{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 r=this._getOrReturnCtx(e);return g(r,{code:p.invalid_type,expected:y.bigint,received:r.parsedType}),v}gte(e,r){return this.setLimit("min",e,!0,b.toString(r))}gt(e,r){return this.setLimit("min",e,!1,b.toString(r))}lte(e,r){return this.setLimit("max",e,!0,b.toString(r))}lt(e,r){return this.setLimit("max",e,!1,b.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,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,r){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};de.create=t=>new de({checks:[],typeName:E.ZodBigInt,coerce:t?.coerce??!1,...k(t)});var fe=class extends S{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){let n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_type,expected:y.boolean,received:n.parsedType}),v}return N(e.data)}};fe.create=t=>new fe({typeName:E.ZodBoolean,coerce:t?.coerce||!1,...k(t)});var pe=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 g(i,{code:p.invalid_type,expected:y.date,received:i.parsedType}),v}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return g(i,{code:p.invalid_date}),v}let n=new O,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:p.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),g(s,{code:p.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):T.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:b.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:b.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};pe.create=t=>new pe({checks:[],coerce:t?.coerce||!1,typeName:E.ZodDate,...k(t)});var Ne=class extends S{_parse(e){if(this._getType(e)!==y.symbol){let n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_type,expected:y.symbol,received:n.parsedType}),v}return N(e.data)}};Ne.create=t=>new Ne({typeName:E.ZodSymbol,...k(t)});var me=class extends S{_parse(e){if(this._getType(e)!==y.undefined){let n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_type,expected:y.undefined,received:n.parsedType}),v}return N(e.data)}};me.create=t=>new me({typeName:E.ZodUndefined,...k(t)});var he=class extends S{_parse(e){if(this._getType(e)!==y.null){let n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_type,expected:y.null,received:n.parsedType}),v}return N(e.data)}};he.create=t=>new he({typeName:E.ZodNull,...k(t)});var re=class extends S{constructor(){super(...arguments),this._any=!0}_parse(e){return N(e.data)}};re.create=t=>new re({typeName:E.ZodAny,...k(t)});var J=class extends S{constructor(){super(...arguments),this._unknown=!0}_parse(e){return N(e.data)}};J.create=t=>new J({typeName:E.ZodUnknown,...k(t)});var H=class extends S{_parse(e){let r=this._getOrReturnCtx(e);return g(r,{code:p.invalid_type,expected:y.never,received:r.parsedType}),v}};H.create=t=>new H({typeName:E.ZodNever,...k(t)});var De=class extends S{_parse(e){if(this._getType(e)!==y.undefined){let n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_type,expected:y.void,received:n.parsedType}),v}return N(e.data)}};De.create=t=>new De({typeName:E.ZodVoid,...k(t)});var X=class t extends S{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==y.array)return g(r,{code:p.invalid_type,expected:y.array,received:r.parsedType}),v;if(s.exactLength!==null){let o=r.data.length>s.exactLength.value,a=r.data.length<s.exactLength.value;(o||a)&&(g(r,{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}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(g(r,{code:p.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(g(r,{code:p.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,a)=>s.type._parseAsync(new z(r,o,r.path,a)))).then(o=>O.mergeArray(n,o));let i=[...r.data].map((o,a)=>s.type._parseSync(new z(r,o,r.path,a)));return O.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:b.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:b.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:b.toString(r)}})}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)});function Oe(t){if(t instanceof L){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=j.create(Oe(n))}return new L({...t._def,shape:()=>e})}else return t instanceof X?new X({...t._def,type:Oe(t.element)}):t instanceof j?j.create(Oe(t.unwrap())):t instanceof W?W.create(Oe(t.unwrap())):t instanceof K?K.create(t.items.map(e=>Oe(e))):t}var L=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(),r=T.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==y.object){let c=this._getOrReturnCtx(e);return g(c,{code:p.invalid_type,expected:y.object,received:c.parsedType}),v}let{status:n,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof H&&this._def.unknownKeys==="strip"))for(let c in s.data)o.includes(c)||a.push(c);let u=[];for(let c of o){let l=i[c],f=s.data[c];u.push({key:{status:"valid",value:c},value:l._parse(new z(s,f,s.path,c)),alwaysSet:c in s.data})}if(this._def.catchall instanceof H){let c=this._def.unknownKeys;if(c==="passthrough")for(let l of a)u.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(c==="strict")a.length>0&&(g(s,{code:p.unrecognized_keys,keys:a}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let l of a){let f=s.data[l];u.push({key:{status:"valid",value:l},value:c._parse(new z(s,f,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let c=[];for(let l of u){let f=await l.key,d=await l.value;c.push({key:f,value:d,alwaysSet:l.alwaysSet})}return c}).then(c=>O.mergeObjectSync(n,c)):O.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return b.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let s=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message: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,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of T.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of T.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Oe(this)}partial(e){let r={};for(let n of T.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of T.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof j;)i=i._def.innerType;r[n]=i}return new t({...this._def,shape:()=>r})}keyof(){return pn(T.objectKeys(this.shape))}};L.create=(t,e)=>new L({shape:()=>t,unknownKeys:"strip",catchall:H.create(),typeName:E.ZodObject,...k(e)});L.strictCreate=(t,e)=>new L({shape:()=>t,unknownKeys:"strict",catchall:H.create(),typeName:E.ZodObject,...k(e)});L.lazycreate=(t,e)=>new L({shape:t,unknownKeys:"strip",catchall:H.create(),typeName:E.ZodObject,...k(e)});var ge=class extends S{_parse(e){let{ctx:r}=this._processInputParams(e),n=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 r.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(a=>new M(a.ctx.common.issues));return g(r,{code:p.invalid_union,unionErrors:o}),v}if(r.common.async)return Promise.all(n.map(async i=>{let o={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let u of n){let c={...r,common:{...r.common,issues:[]},parent:null},l=u._parseSync({data:r.data,path:r.path,parent:c});if(l.status==="valid")return l;l.status==="dirty"&&!i&&(i={result:l,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(u=>new M(u));return g(r,{code:p.invalid_union,unionErrors:a}),v}}get options(){return this._def.options}};ge.create=(t,e)=>new ge({options:t,typeName:E.ZodUnion,...k(e)});var Y=t=>t instanceof _e?Y(t.schema):t instanceof Z?Y(t.innerType()):t instanceof be?[t.value]:t instanceof ve?t.options:t instanceof xe?T.objectValues(t.enum):t instanceof Ee?Y(t._def.innerType):t instanceof me?[void 0]:t instanceof he?[null]:t instanceof j?[void 0,...Y(t.unwrap())]:t instanceof W?[null,...Y(t.unwrap())]:t instanceof Ke||t instanceof ke?Y(t.unwrap()):t instanceof we?Y(t._def.innerType):[],at=class t extends S{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==y.object)return g(r,{code:p.invalid_type,expected:y.object,received:r.parsedType}),v;let n=this.discriminator,s=r.data[n],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(g(r,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=new Map;for(let i of r){let o=Y(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:r,optionsMap:s,...k(n)})}};function Nt(t,e){let r=G(t),n=G(e);if(t===e)return{valid:!0,data:t};if(r===y.object&&n===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 u=Nt(t[a],e[a]);if(!u.valid)return{valid:!1};o[a]=u.data}return{valid:!0,data:o}}else if(r===y.array&&n===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],u=Nt(o,a);if(!u.valid)return{valid:!1};s.push(u.data)}return{valid:!0,data:s}}else return r===y.date&&n===y.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var ye=class extends S{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=(i,o)=>{if(it(i)||it(o))return v;let a=Nt(i.value,o.value);return a.valid?((ot(i)||ot(o))&&r.dirty(),{status:r.value,value:a.data}):(g(n,{code:p.invalid_intersection_types}),v)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};ye.create=(t,e,r)=>new ye({left:t,right:e,typeName:E.ZodIntersection,...k(r)});var K=class t extends S{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==y.array)return g(n,{code:p.invalid_type,expected:y.array,received:n.parsedType}),v;if(n.data.length<this._def.items.length)return g(n,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&n.data.length>this._def.items.length&&(g(n,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((o,a)=>{let u=this._def.items[a]||this._def.rest;return u?u._parse(new z(n,o,n.path,a)):null}).filter(o=>!!o);return n.common.async?Promise.all(i).then(o=>O.mergeArray(r,o)):O.mergeArray(r,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)})};var ct=class t extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==y.object)return g(n,{code:p.invalid_type,expected:y.object,received:n.parsedType}),v;let s=[],i=this._def.keyType,o=this._def.valueType;for(let a in n.data)s.push({key:i._parse(new z(n,a,n.path,a)),value:o._parse(new z(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?O.mergeObjectAsync(r,s):O.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof S?new t({keyType:e,valueType:r,typeName:E.ZodRecord,...k(n)}):new t({keyType:te.create(),valueType:e,typeName:E.ZodRecord,...k(r)})}},Pe=class extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==y.map)return g(n,{code:p.invalid_type,expected:y.map,received:n.parsedType}),v;let s=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([a,u],c)=>({key:s._parse(new z(n,a,n.path,[c,"key"])),value:i._parse(new z(n,u,n.path,[c,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let u of o){let c=await u.key,l=await u.value;if(c.status==="aborted"||l.status==="aborted")return v;(c.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(c.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let u of o){let c=u.key,l=u.value;if(c.status==="aborted"||l.status==="aborted")return v;(c.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(c.value,l.value)}return{status:r.value,value:a}}}};Pe.create=(t,e,r)=>new Pe({valueType:e,keyType:t,typeName:E.ZodMap,...k(r)});var Me=class t extends S{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==y.set)return g(n,{code:p.invalid_type,expected:y.set,received:n.parsedType}),v;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(g(n,{code:p.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(g(n,{code:p.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function o(u){let c=new Set;for(let l of u){if(l.status==="aborted")return v;l.status==="dirty"&&r.dirty(),c.add(l.value)}return{status:r.value,value:c}}let a=[...n.data.values()].map((u,c)=>i._parse(new z(n,u,n.path,c)));return n.common.async?Promise.all(a).then(u=>o(u)):o(a)}min(e,r){return new t({...this._def,minSize:{value:e,message:b.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:b.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Me.create=(t,e)=>new Me({valueType:t,minSize:null,maxSize:null,typeName:E.ZodSet,...k(e)});var ut=class t extends S{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==y.function)return g(r,{code:p.invalid_type,expected:y.function,received:r.parsedType}),v;function n(a,u){return Ge({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ie(),q].filter(c=>!!c),issueData:{code:p.invalid_arguments,argumentsError:u}})}function s(a,u){return Ge({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ie(),q].filter(c=>!!c),issueData:{code:p.invalid_return_type,returnTypeError:u}})}let i={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof ne){let a=this;return N(async function(...u){let c=new M([]),l=await a._def.args.parseAsync(u,i).catch(m=>{throw c.addIssue(n(u,m)),c}),f=await Reflect.apply(o,this,l);return await a._def.returns._def.type.parseAsync(f,i).catch(m=>{throw c.addIssue(s(f,m)),c})})}else{let a=this;return N(function(...u){let c=a._def.args.safeParse(u,i);if(!c.success)throw new M([n(u,c.error)]);let l=Reflect.apply(o,this,c.data),f=a._def.returns.safeParse(l,i);if(!f.success)throw new M([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:K.create(e).rest(J.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||K.create([]).rest(J.create()),returns:r||J.create(),typeName:E.ZodFunction,...k(n)})}},_e=class extends S{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};_e.create=(t,e)=>new _e({getter:t,typeName:E.ZodLazy,...k(e)});var be=class extends S{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return g(r,{received:r.data,code:p.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}};be.create=(t,e)=>new be({value:t,typeName:E.ZodLiteral,...k(e)});function pn(t,e){return new ve({values:t,typeName:E.ZodEnum,...k(e)})}var ve=class t extends S{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return g(r,{expected:T.joinValues(n),received:r.parsedType,code:p.invalid_type}),v}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return g(r,{received:r.data,code:p.invalid_enum_value,options:n}),v}return N(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};ve.create=pn;var xe=class extends S{_parse(e){let r=T.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==y.string&&n.parsedType!==y.number){let s=T.objectValues(r);return g(n,{expected:T.joinValues(s),received:n.parsedType,code:p.invalid_type}),v}if(this._cache||(this._cache=new Set(T.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=T.objectValues(r);return g(n,{received:n.data,code:p.invalid_enum_value,options:s}),v}return N(e.data)}get enum(){return this._def.values}};xe.create=(t,e)=>new xe({values:t,typeName:E.ZodNativeEnum,...k(e)});var ne=class extends S{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==y.promise&&r.common.async===!1)return g(r,{code:p.invalid_type,expected:y.promise,received:r.parsedType}),v;let n=r.parsedType===y.promise?r.data:Promise.resolve(r.data);return N(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};ne.create=(t,e)=>new ne({type:t,typeName:E.ZodPromise,...k(e)});var Z=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:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{g(n,o),o.fatal?r.abort():r.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(n.data,i);if(n.common.async)return Promise.resolve(o).then(async a=>{if(r.value==="aborted")return v;let u=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return u.status==="aborted"?v:u.status==="dirty"?ue(u.value):r.value==="dirty"?ue(u.value):u});{if(r.value==="aborted")return v;let a=this._def.schema._parseSync({data:o,path:n.path,parent:n});return a.status==="aborted"?v:a.status==="dirty"?ue(a.value):r.value==="dirty"?ue(a.value):a}}if(s.type==="refinement"){let o=a=>{let u=s.refinement(a,i);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?v:(a.status==="dirty"&&r.dirty(),o(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?v:(a.status==="dirty"&&r.dirty(),o(a.value).then(()=>({status:r.value,value:a.value}))))}if(s.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ee(o))return v;let a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>ee(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:r.value,value:a})):v);T.assertNever(s)}};Z.create=(t,e,r)=>new Z({schema:t,typeName:E.ZodEffects,effect:e,...k(r)});Z.createWithPreprocess=(t,e,r)=>new Z({schema:e,effect:{type:"preprocess",transform:t},typeName:E.ZodEffects,...k(r)});var j=class extends S{_parse(e){return this._getType(e)===y.undefined?N(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};j.create=(t,e)=>new j({innerType:t,typeName:E.ZodOptional,...k(e)});var W=class extends S{_parse(e){return this._getType(e)===y.null?N(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};W.create=(t,e)=>new W({innerType:t,typeName:E.ZodNullable,...k(e)});var Ee=class extends S{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===y.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Ee.create=(t,e)=>new Ee({innerType:t,typeName:E.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...k(e)});var we=class extends S{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return $e(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new M(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new M(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};we.create=(t,e)=>new we({innerType:t,typeName:E.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...k(e)});var Le=class extends S{_parse(e){if(this._getType(e)!==y.nan){let n=this._getOrReturnCtx(e);return g(n,{code:p.invalid_type,expected:y.nan,received:n.parsedType}),v}return{status:"valid",value:e.data}}};Le.create=t=>new Le({typeName:E.ZodNaN,...k(t)});var Xi=Symbol("zod_brand"),Ke=class extends S{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},We=class t extends S{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?v:i.status==="dirty"?(r.dirty(),ue(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?v:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:E.ZodPipeline})}},ke=class extends S{_parse(e){let r=this._def.innerType._parse(e),n=s=>(ee(s)&&(s.value=Object.freeze(s.value)),s);return $e(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};ke.create=(t,e)=>new ke({innerType:t,typeName:E.ZodReadonly,...k(e)});function un(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function mn(t,e={},r){return t?re.create().superRefine((n,s)=>{let i=t(n);if(i instanceof Promise)return i.then(o=>{if(!o){let a=un(e,n),u=a.fatal??r??!0;s.addIssue({code:"custom",...a,fatal:u})}});if(!i){let o=un(e,n),a=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:a})}}):re.create()}var Qi={object:L.lazycreate},E;(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={}));var eo=(t,e={message:`Input not instance of ${t.name}`})=>mn(r=>r instanceof t,e),hn=te.create,gn=le.create,to=Le.create,ro=de.create,yn=fe.create,no=pe.create,so=Ne.create,io=me.create,oo=he.create,ao=re.create,co=J.create,uo=H.create,lo=De.create,fo=X.create,po=L.create,mo=L.strictCreate,ho=ge.create,go=at.create,yo=ye.create,_o=K.create,bo=ct.create,vo=Pe.create,xo=Me.create,Eo=ut.create,wo=_e.create,ko=be.create,So=ve.create,To=xe.create,Ro=ne.create,Ao=Z.create,Co=j.create,Io=W.create,$o=Z.createWithPreprocess,Oo=We.create,No=()=>hn().optional(),Do=()=>gn().optional(),Po=()=>yn().optional(),Mo={string:(t=>te.create({...t,coerce:!0})),number:(t=>le.create({...t,coerce:!0})),boolean:(t=>fe.create({...t,coerce:!0})),bigint:(t=>de.create({...t,coerce:!0})),date:(t=>pe.create({...t,coerce:!0}))};var Lo=v;var Fe=h.object({slug:h.string().min(1).max(64),description:h.string().max(255).optional(),match_command:h.string().min(1),priority:h.number().int().default(50),strip_ansi:h.boolean().default(!1),strip_lines_matching:h.array(h.string()).default([]),keep_failures:h.boolean().default(!1),fold_passing:h.boolean().default(!1),fold_passing_threshold:h.number().int().positive().max(1e3).optional(),mask_abs_paths:h.boolean().default(!1),preserve_exact:h.boolean().default(!1),truncate_lines_at:h.number().int().positive().max(1e4).optional(),max_lines:h.number().int().positive().max(1e5).optional(),scale_with_level:h.boolean().default(!0),transform:h.string().max(64).optional(),on_empty:h.string().max(255).optional()});var Zo=jo(zo(import.meta.url)),_n=process.env.TOKMIZER_FILTERS_DIR||vn(Zo,"..","..","filters"),se=null,bn=!1;function Uo(){return process.env.TOKMIZER_DEV==="1"||process.env.TOKMIZER_DEV==="true"}async function xn(){if(se)return se;if(!Uo())return!bn&&process.env.TOKMIZER_DEBUG==="1"&&(process.stderr.write(`tokmizer: disk loader disabled (set TOKMIZER_DEV=1 to re-enable for local dev).
4
+ `),bn=!0),se=new Map,se;let t=new Map,e,r;try{e=(await import("smol-toml")).parse,r=(await Fo(_n)).filter(n=>n.endsWith(".toml"))}catch{return se=t,se}for(let n of r){let s=await Bo(vn(_n,n),"utf8"),o=e(s).filters;if(o)for(let[a,u]of Object.entries(o)){let c=Fe.parse({slug:a,...u});t.set(a,{...c,matchRegex:new RegExp(c.match_command)})}}return se=t,se}import{createHash as Ho}from"node:crypto";var Vo=h.enum(["normal","compact","minimal"]),Go=h.enum(["off","light","balanced","max"]),qe=h.object({enabled:h.boolean().default(!0),telemetryOptIn:h.boolean().default(!0),outputVerbosity:Vo.default("compact"),reducer:Go.default("off"),filters:h.object({enableAll:h.boolean().default(!0),disabled:h.array(h.string().max(64)).max(100).default([])}).default({enableAll:!0,disabled:[]})}),Ko=["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"],Wo=/^[0-9a-f]{16}$/,En=new Map;function V(t){let e=En.get(t);return e||(e=Ho("sha256").update(`tkr:${t}`).digest("hex").slice(0,16),En.set(t,e)),e}var wn=null;function lt(t,e=!1){return e||!t||t.length===0?(wn??=new Set(Ko.map(V)),new Set(wn)):new Set(t.map(r=>Wo.test(r)?r:V(r)))}var Be=new Map,qo=256,kn=new WeakMap;function Yo(t){if(!t)return"*";let e=kn.get(t);return e===void 0&&(e=[...t].join(","),kn.set(t,e)),e}function dt(t,e,r){let n=`${t}::${Yo(r)}`,s=Be.get(n);if(s!==void 0)return s;let i=null;for(let o of e)r&&!r.has(V(o.slug))||o.matchRegex.test(t)&&(!i||o.priority>i.priority)&&(i=o);if(Be.size>=qo){let o=Be.keys().next().value;o&&Be.delete(o)}return Be.set(n,i),i}function Sn(){Be.clear()}var Jo=/\x1b\[[0-9;?]*[ -/]*[@-~]/g,Xo=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g;function Se(t){return t.replace(Jo,"").replace(Xo,"")}function Tn(t,e){return e.length===0?t:t.filter(r=>!e.some(n=>n.test(r)))}function Rn(t,e){return t.map(r=>{if(r.length<=e)return r;let n=r.charCodeAt(e-1),s=r.charCodeAt(e),i=n>=55296&&n<=56319&&s>=56320&&s<=57343?e-1:e;return`${r.slice(0,i)}\u2026`})}function ft(t){return`\u2026 (${t} more lines omitted)`}function An(t,e){if(t.length<=e)return{kept:t,dropped:[]};let r=Math.ceil(e*.7),n=e-r,s=t.slice(r,t.length-n);return{kept:[...t.slice(0,r),ft(s.length),...t.slice(t.length-n)],dropped:s}}var Qo=/^\s*(?:[✓✔√]|ok )/,ie=/✕|✗|×|\bFAIL\b|\bERROR\b|\bFATAL\b|\bError|\berror|Expected|Received|\bfailed\b|^\s*Tests?:|^\s*Test Suites?:/;function Cn(t,e){let r=e>0?e:5,n=[],s=0,i=a=>{s>=r?n.push(`\u2026 ${s} passing checks folded \u2026`):n.push(...a)},o=[];for(let a of t)Qo.test(a)&&!ie.test(a)?(o.push(a),s+=1):(i(o),o=[],s=0,n.push(a));return i(o),n}var ea=/(?:\/[\w.@+-]+){3,}/g;function In(t){return t.map(e=>e.replace(ea,r=>{let n=r.split("/").filter(Boolean);return n.length<=2?r:`\u2026/${n.slice(-2).join("/")}`}))}var ta=/^(\s*)(?:export\s+)?(?:async\s+)?(?:function|interface|type|const|let|var|def|fn|impl|trait|struct|enum)\s+[\w$]+/,ra=/\{\s*$/;var na=/^\s*(?:(?:public|private|protected|static|async|get|set|readonly|override)\s+)*([\w$]+)\s*\(([^)]*)\)\s*(?::\s*[^{]+)?\{\s*$/,sa=new Set(["if","for","while","switch","catch","do","with","return","else","function","await","yield"]);function ia(t){let e=na.exec(t);return!e||sa.has(e[1])?!1:!/=>|\bfunction\b/.test(e[2])}var oa=/^\s*(?:if|for|while|switch|try|do)\b[^{}]*\{\s*$/;function aa(t,e,r){let n=e;for(;n<t.length;){if(t[n]==="\\"){n+=2;continue}if(t[n]===r)return!0;n+=1}return!1}function ca(t,e){let r=0,n=null,s=0;for(;s<t.length;){let i=t[s];if(e.inBlockComment){if(i==="*"&&t[s+1]==="/"){e.inBlockComment=!1,s+=2;continue}s+=1;continue}if(e.inTemplate){if(i==="\\"){s+=2;continue}i==="`"&&(e.inTemplate=!1),s+=1;continue}if(n){if(i==="\\"){s+=2;continue}i===n&&(n=null),s+=1;continue}if(i==="/"&&t[s+1]==="/")break;if(i==="/"&&t[s+1]==="*"){e.inBlockComment=!0,s+=2;continue}if(i==="`"){e.inTemplate=!0,s+=1;continue}if(i==="'"||i==='"'){let o=s>0?t[s-1]:"";!(i==="'"&&(o==="<"||o==="&"))&&aa(t,s+1,i)&&(n=i),s+=1;continue}i==="{"||i==="("||i==="["?r+=1:(i==="}"||i===")"||i==="]")&&(r-=1),s+=1}return r}var $n=/^\s*… \d+ lines? folded …$/,ua=/^\s*… (\d+) lines? folded …$/;function Dt(t){let e=new Array(t.length).fill(!1);for(let r=0;r<t.length;r+=1){let n=ua.exec(t[r]);if(!n)continue;let s=Number(n[1])-1,i=r+1;for(;s>0&&i<t.length&&t[i]==="";)e[i]=!0,s-=1,i+=1;r=i-1}return e}function pt(t){let e=[],r=0;for(;r<t.length;){let n=t[r];if(ta.test(n)&&ra.test(n)||ia(n)||oa.test(n)){let s={inBlockComment:!1,inTemplate:!1},i=0,o=r,a=!1;for(;o<t.length&&o-r<200;)if(i+=ca(t[o],s),o+=1,i<=0&&!s.inTemplate&&!s.inBlockComment){a=!0;break}let u=o-r;if(a&&u>=3){let c=u-2,l=/^\s*/.exec(t[r+1]??"")?.[0]??" ";e.push(n),e.push(`${l}\u2026 ${c} ${c===1?"line":"lines"} folded \u2026`);for(let f=0;f<c-1;f++)e.push("");e.push(t[o-1]),r=o;continue}}e.push(n),r+=1}return e}var la=/\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 mt(t){let e=t.slice(0,4096);return!(!la.test(e)||e.split(`
5
+ `).length<6)}var da=/^\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*/,fa=/^\s*(?:\[(?:DEBUG|TRACE|INFO|VERBOSE)\]|(?:DEBUG|TRACE|INFO|VERBOSE)(?!\s*:))(?=\s|:|$)(?!\s*[+\-*\/%&|^?]*=)/,pa=new RegExp(ie.source,"i"),ma=/\bWARN(?:ING)?\b/i;function On(t){let e=[],r=0,n=()=>{r>0&&e.push(`\u2026 ${r} verbose log line${r===1?"":"s"} dropped \u2026`),r=0};for(let s of t){if(fa.test(s.replace(da,""))&&!pa.test(s)&&!ma.test(s)){r+=1;continue}n(),e.push(s)}return n(),e}function Nn(t){if(t.length===0)return t;let e=[],r=1,n=t[0];for(let s=1;s<t.length;s++){if(t[s]===n){r+=1;continue}e.push(r>1?`${n} \xD7${r}`:n),n=t[s],r=1}return e.push(r>1?`${n} \xD7${r}`:n),e}function Dn(t){let e=[],r=0;for(let n of t){if(n.trim()===""){r+=1;continue}r>0&&e.push(""),r=0,e.push(n)}return e}var Pn=new Map;function F(t,e){Pn.set(t,e)}function Mn(t){return Pn.get(t)}var ha=/^[dbclps\-][rwxsStT\-]{9}[@.+]?(?:\s|$)/,ga=/^[./~][^\s]*:$/,Pt=1e3;function ya(t){if(t<1024)return String(t);let e=["K","M","G","T"],r=t/1024,n=0;for(;r>=1024&&n<e.length-1;)r/=1024,n+=1;return`${r.toFixed(1)}${e[n]}`}function _a(t){if(!ha.test(t))return null;let e=t.split(/\s+/);if(e.length<9)return null;let r=Number(e[4]);if(!Number.isFinite(r))return null;let n=e.slice(8).join(" ").trim();if(n===""||n==="."||n==="..")return null;let s=e[0].charCodeAt(0)===100;return{name:n,size:r,isDir:s}}function ba(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 r=null,n=0;for(let[s,i]of e)i>n&&(n=i,r=s);return r&&n>=Math.ceil(t.length/2)?`${n} ${r}`:null}function va(t){let e=[],r=[],n=!1;for(let d of t){if(/^total\s+\d+/.test(d))continue;if(ga.test(d.trim()))return t;let m=_a(d);m&&(n=!0,(m.isDir?e:r).push(m))}if(!n)return t;let s=(d,m)=>d.name.localeCompare(m.name);e.sort(s),r.sort((d,m)=>m.size-d.size||s(d,m));let i=[...e,...r],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 m=d.isDir?`${d.name}/`:d.name,_=d.isDir?"":ya(d.size);a.push(_?`${m.padEnd(o)} ${_}`:m)}if(a.length>Pt){let d=a.length-Pt;a=[...a.slice(0,Pt),`\u2026 ${d} more lines omitted`]}let u=r.length===1?"file":"files",c=e.length===1?"dir":"dirs",l=ba(r),f=`${r.length} ${u}, ${e.length} ${c}`+(l?` (${l})`:"");return a.push(f),a}F("smart-ls",va);F("smart-read",t=>pt(t));var Ln=1e3;function xa(t){let e=t.filter(l=>l.trim()!=="");if(e.length===0||e.filter(l=>!/\s/.test(l.trim())).length<e.length*.6)return t;let n=new Map,s=[],i=0;for(let l of e){let f=l.trim();if(f.startsWith("find:")){s.push(f);continue}let d=f.replace(/^\.\//,"").replace(/\/+$/,""),m=d.lastIndexOf("/"),_=m>=0?d.slice(0,m):"",x=m>=0?d.slice(m+1):d;if(!x)continue;let A=n.get(_)??[];A.push(/\s/.test(x)?`"${x}"`:x),n.set(_,A),i+=1}if(i===0)return t;let o=new Set([""]);for(let l of n.keys()){if(l==="")continue;let f=l.split("/");for(let d=1;d<=f.length;d+=1)o.add(f.slice(0,d).join("/"))}let a=[...o].sort(),u=a.filter(l=>l!=="").length,c=[`${i}F ${u}D:`,""];for(let l of a){let f=l===""?0:l.split("/").length,d=l===""?".":l.slice(l.lastIndexOf("/")+1),m=n.get(l)??[],_=m.length?` ${m.join(" ")}`:"";c.push(`${" ".repeat(f)}${d}/${_}`)}if(c.length+s.length>Ln){let l=Math.max(0,Ln-s.length),f=c.length-l;return[...c.slice(0,l),`\u2026 ${f} more lines omitted`,...s]}return[...c,...s]}F("smart-find",xa);var Mt=1e3,Fn=200,Ea=60,wa=190,ka=/^([^\s:]+):(\d+):(.*)$/,Sa=/^([^:]+?)-(\d+)-(.*)$/,Ta=/^([^\s:]+):(.*)$/,Bn=/(?:^|\/)(?:__tests__|tests?|spec|fixtures?|__mocks__|__snapshots__)\/|\.(?:test|spec)\.[^/]+$/i;function jn(t){let e=t.trim();return e.length>Fn?`${e.slice(0,Fn)}\u2026`:e}function Ra(t){let e=[],r="";for(let n of t){let s=r?`${r}, ${n}`:n;s.length>wa&&r?(e.push(`${r},`),r=n):r=s}return r&&e.push(r),e}function Aa(t){let e=t.filter(f=>f.trim()!=="");if(e.length===0)return t;let r=new Map,n=new Map,s=null,i=0,o=0;for(let f of e){if(f==="--"){s&&r.get(s).push({separator:!0});continue}if(/^[A-Za-z]:[\\/]/.test(f))return t;let d=ka.exec(f),m=Sa.exec(f);if(d&&m)return t;let _=d||m?null:Ta.exec(f),x=(d??m??_)?.[1];if(!x)return t;let A=d?{line:d[2],content:d[3],context:!1}:m?{line:m[2],content:m[3],context:!0}:{line:"",content:_[2],context:!1},I=r.get(x)??[];I.push(A),r.set(x,I),A.context||(i+=1,n.set(x,(n.get(x)??0)+1)),o+=1,s=x}if(r.size===o)return t;let a=[...r.keys()].sort((f,d)=>{let m=Bn.test(f)?1:0,_=Bn.test(d)?1:0;return m-_||(f<d?-1:f>d?1:0)}),u=[];for(let f of a){u.push(`${f} (${n.get(f)??0}):`);for(let d of r.get(f))"separator"in d?u.push(" --"):d.line?u.push(` ${d.line}${d.context?"-":":"} ${jn(d.content)}`):u.push(` ${jn(d.content)}`)}let c=a.length>1&&u.length>Ea?Ra(a.map(f=>`${f} (${n.get(f)??0})`)):[],l=[`${i}m ${a.length}f:`,...c,"",...u];if(l.length>Mt){let f=l.length-Mt;return[...l.slice(0,Mt),`\u2026 ${f} more lines omitted`]}return l}F("smart-grep",Aa);var zn=/^(?:([|\\/ ._-]*\*[|\\/* ._-]* ))?commit [0-9a-f]{7,40}\b/,Ca=/^[|\\/* ._-]*$/,Ia=/^ {4}/,$a=2;function Oa(t){if(!t.some(c=>zn.test(c)))return t;let e=[],r=0,n=0,s=0,i="",o=!1,a=!1,u=()=>{n>0&&e.push(`${i} \u2026 ${n} ${n===1?"line":"lines"} folded \u2026`),n=0};for(let c of t){let l=c.slice(0,s),f=Ca.test(l),d=f?c.slice(s):c,m=Ia.test(d),_=o&&m?null:zn.exec(c);if(_){u(),r=0,s=_[1]?.length??0,o=!0,a=!1,e.push(c);continue}if(/^diff --(?:git|cc|combined) /.test(d)&&(a=!0),m&&!a&&!(s>0&&d.trim().length===0)){r+=1,r<=$a?e.push(c):(n+=1,i=f?l:"");continue}u(),e.push(c)}return u(),e}F("smart-log",Oa);var Na=/^[\s=]+$/,Da=/^\s*=+\s+(.*?)\s+=+\s*$/,Pa=512;F("strip-banners",t=>{let e=[];for(let r of t){if(Na.test(r))continue;let n=r.length<=Pa?Da.exec(r):null;e.push(n?n[1]:r)}return e});function Ma(t){let e=[],r=0,n=0;for(;n<t.length;){let s=t[n].replace(/\s+$/,"");if(s===""){r+=1,n+=1,r<=1&&e.push("");continue}r=0;let i=1;for(;n+i<t.length&&t[n+i].replace(/\s+$/,"")===s;)i+=1;if(i>=3)e.push(s),e.push(` \u2026 (repeated ${i}x)`);else for(let o=0;o<i;o++)e.push(s);n+=i}for(;e.length>0&&e[e.length-1]==="";)e.pop();return e}F("squeeze-output",Ma);function La(t){return t==="compact"?.6:t==="minimal"?.3:1}var Fa=20;function Ba(t){let[e,r,n,s]=t.slice(-4);if(!e||!r||!n||!s||!/^\s*Test Files\s+([1-9]\d*) passed \(\1\)$/.test(e)||!/^\s*Tests\s+([1-9]\d*) passed \(\1\)$/.test(r)||!/^\s*Start at\s+\d{2}:\d{2}:\d{2}$/.test(n))return t;let i=/^(\s*Duration\s+\d+(?:\.\d+)?(?:ms|s)) \(transform [^\n]+\)$/.exec(s)?.[1];return i?[...t.slice(0,-4).filter((a,u)=>u>2||!/^ RUN v\d+\.\d+\.\d+(?:[\w.+-]*) .+$/.test(a)),e,r,i]:t}var Zn=new WeakMap;function ja(t){let e=Zn.get(t);if(e)return e;let r=t.strip_lines_matching.map(s=>new RegExp(s)),n={def:t,stripRegexes:r};return Zn.set(t,n),n}function Un(t,e,r={}){return Lt(t,e,r).text}function Lt(t,e,r={}){let n=r.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&&!r.smartCode&&n==="normal")return{text:t,droppedTail:null};let s=ja(e),i=t;e.strip_ansi&&(i=Se(i));let o=i.endsWith(`
6
+ `),a=(o?i.slice(0,-1):i).split(`
7
+ `);if(s.stripRegexes.length&&(a=e.keep_failures?a.filter(f=>ie.test(f)||!s.stripRegexes.some(d=>d.test(f))):Tn(a,s.stripRegexes)),n!=="normal"&&!e.preserve_exact&&(a=Nn(a),a=Dn(a)),n==="minimal"&&!e.preserve_exact&&(a=On(a),(e.slug==="vitest"||e.slug==="npm-test")&&(a=Ba(a))),!e.preserve_exact&&(r.smartCode||r.smartCode===void 0&&n!=="normal"&&mt(i))&&(a=pt(a)),e.transform){let f=Mn(e.transform);f&&(a=f(a))}let u=e.slug==="read-tool";if(!u){let f=Dt(a);f.some(Boolean)&&(a=a.filter((d,m)=>!f[m]))}e.mask_abs_paths&&(a=In(a)),e.fold_passing&&(a=Cn(a,e.fold_passing_threshold??5)),e.truncate_lines_at&&(a=Rn(a,e.truncate_lines_at));let c=null;if(e.max_lines){let f=e.scale_with_level?La(r.verbosity):1,d=Math.min(e.max_lines,Math.max(Fa,Math.round(e.max_lines*f))),m=u?Dt(a):null,_=m?m.filter(x=>!x).length:a.length;if(_>d){let x=d;if(m){let I=0;for(x=0;x<a.length&&I<d;)m[x]||(I+=1),x+=1}let A=_-d;if(e.keep_failures){let I=a.slice(x),P=I.filter(U=>!ie.test(U)),ae=I.reduce((U,ce,w)=>U+(!ie.test(ce)&&!m?.[x+w]?1:0),0);c=P.length>0?P.join(`
8
+ `):null,a=[...a.slice(0,x),...ae>0?[ft(ae)]:[],...I.filter(U=>ie.test(U))]}else if(u)c=a.slice(x).join(`
9
+ `),a=[...a.slice(0,x),ft(A)];else{let{kept:I,dropped:P}=An(a,d);c=P.length>0?P.join(`
10
+ `):null,a=I}}}let l=a.join(`
11
+ `);return o&&l.length>0&&(l+=`
12
+ `),l.trim().length===0&&e.on_empty&&(l=e.on_empty),{text:l,droppedTail:c}}var za=[/\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 Hn(t){if(!t)return!1;for(let e of Se(t).split(`
13
+ `))if(!/^\s*[✓✔√]\s/.test(e)&&za.some(r=>r.test(e)))return!0;return!1}var Za=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),Ua=/^[A-Za-z_][A-Za-z0-9_]*=/,Ft=/^([a-z]+)-tool(?::\s|$)/;function je(t){let e=t.trim(),r=e.split(/\s+/),n=0;for(;n<r.length;){let a=r[n];if(Ua.test(a)){n++;continue}if(Za.has(a)){for(n++,a==="timeout"&&n<r.length&&/^\d+(?:\.\d+)?[smhd]?$/.test(r[n])&&n++;(a==="stdbuf"||a==="nice")&&n<r.length&&r[n].startsWith("-");)n++;continue}break}if(n>=r.length)return e;let s=r[n],i=s.includes("/")?s.slice(s.lastIndexOf("/")+1):s,o=r.slice(n+1);return o.length?`${i} ${o.join(" ")}`:i}var Ha=new Set(["cd","export","source","set","unset","mkdir","true",":","pushd","popd","alias","ulimit","umask","echo","printf","sleep","touch","rm","cp","mv","chmod","ln"]);function Vn(t,e){let r=!1,n=!1,s=0,i=[];for(let o=0;o<t.length;o++){let a=t[o];if(a==="\\"&&!r){o++;continue}a==="'"&&!n?r=!r:a==='"'&&!r?n=!n:!r&&!n&&(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 Va(t){let e=Vn(t,!1);for(let r=e.length-1;r>=0;r--){let n=e[r].trim();if(n)return n}return t.trim()}function Bt(t){let e=Vn(t,!0).map(r=>r.trim()).filter(Boolean);if(e.length===0)return null;for(let r of e.slice(0,-1)){let n=je(r).split(/\s+/)[0]??"";if(!Ha.has(n))return null}return Va(e[e.length-1])}function Gn(t){let e=!1,r=!1,n=0,s=[];for(let i=0;i<t.length;i++){let o=t[i];if(o==="\\"&&!e){i++;continue}o==="'"&&!r?e=!e:o==='"'&&!e?r=!r:!e&&!r&&(o==="|"||o===";"?(s.push(t.slice(n,i)),o==="|"&&t[i+1]==="|"&&i++,n=i+1):o==="&"&&t[i+1]==="&"&&(s.push(t.slice(n,i)),i++,n=i+1))}s.push(t.slice(n));for(let i=s.length-1;i>=0;i--){let o=s[i].trim();if(o)return o}return t.trim()}function Kn(t){let e=Ft.exec(t),r=t;if(e){if(e[1]!=="bash")return[t];let i=t.indexOf(": ");if(i<0)return[t];r=t.slice(i+2)}let n=Bt(r),s=n?je(n):null;return s&&s!==t?[s,t]:[t]}var Wn=`
14
+ [YOLO: omitted]
15
+ `;function jt(t){let e=Buffer.from(t,"utf8");if(e.length<=256)return t;let r=256-Buffer.byteLength(Wn,"utf8"),n=Math.floor(r/2);for(;(e[n]&192)===128;)n-=1;let s=e.length-(r-n);for(;(e[s]&192)===128;)s+=1;return e.subarray(0,n).toString("utf8")+Wn+e.subarray(s).toString("utf8")}var Ga=/^ID {2,}TITLE {2,}BRANCH {2,}STATE {2,}CREATED *$/,Ka=/^… \([1-9]\d* more lines omitted\)$/,Wa=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/;function qa(t,e){if(!e)return t.split(`
16
+ `).map(i=>i.replace(/^[ \t]+|[ \t]+(?=\r?$)/g,"")).join(`
17
+ `);let r="",n=!1,s=!1;for(let i of t)n?(r+=i,s?s=!1:i==="\\"?s=!0:i==='"'&&(n=!1)):i==='"'?(n=!0,r+=i):i!==" "&&i!==" "&&i!=="\r"&&i!==`
18
+ `&&(r+=i);return r+(t.endsWith(`
19
+ `)?`
20
+ `:"")}function Ya(t,e){if(/@\d|\r/.test(t))return t;let r=t.endsWith(`
21
+ `)?`
22
+ `:"",n=(r?t.slice(0,-1):t).split(`
23
+ `),s=n.findIndex(d=>Ga.test(d));if(s>=0&&n.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?[...n[s].matchAll(/\S+/g)].map(d=>d.index):[],o=[];for(let d=s+1;d<n.length;d+=1){let m=n[d];if(Ka.test(m))continue;if(/…|\.\.\./.test(m))return t;let _;if(s>=0){if(/[^\x20-\x7e]/.test(m))return t;let x=i.map((A,I)=>m.slice(A,i[I+1]));if(x.slice(0,-1).some(A=>A[0]===" "||!A.endsWith(" "))||(_=x.map(A=>A.replace(/ +$/,"")),!/^#\d+$/.test(_[0])||!/^\S+$/.test(_[2])||!/^(OPEN|CLOSED|MERGED|DRAFT)$/.test(_[3])||!/^\d+(?:s|m|h|d|w|mo|y)$/.test(_[4])))return t}else if(_=m.split(" "),_.length!==5||!/^\d+$/.test(_[0])||!_[1]||!_[2]||!/^(OPEN|CLOSED|MERGED|DRAFT)$/.test(_[3])||!Wa.test(_[4])||!Number.isFinite(Date.parse(_[4])))return t;if(_.some(x=>/[\u0000-\u001f\u007f]/.test(x)))return t;o.push({index:d,cells:_})}if(o.length===0)return t;s>=0&&(n[s]="ID TITLE BRANCH STATE CREATED");for(let d of o)n[d.index]=d.cells.join(" ");let a=n.join(`
24
+ `)+r;if(!e)return a;let u=new Map;for(let{cells:d}of o)u.set(d[1],(u.get(d[1])??0)+1);let c=new Map,l=[];for(let[d,m]of u){if(d.length<40||m<3||d.trim().split(/\s+/).length<8)continue;let _=`@${c.size+1}`,x=JSON.stringify(d).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"),A=`TITLE ${_} = ${x}`;m*(Buffer.byteLength(d)-Buffer.byteLength(_))<=Buffer.byteLength(A)+1||(c.set(d,_),l.push(A))}if(l.length===0)return a;for(let{index:d,cells:m}of o)n[d]=m.map((_,x)=>x===1?c.get(_)??_:_).join(" ");let f=[...n,"",...l].join(`
25
+ `)+r;return Buffer.byteLength(f)<Buffer.byteLength(a)?f:a}function zt(t,e,r){if(e!=="compact"&&e!=="minimal")return t;let n=t;if(/^[ \t\r\n]*[\[{]/.test(t)){try{JSON.parse(t)}catch{return t}n=qa(t,e==="minimal")}else r==="gh"&&(n=Ya(t,e==="minimal"));return Buffer.byteLength(n)<Buffer.byteLength(t)?n:t}var Ja=/^(?:\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|$)/,Xa=/^\[tkr: previous log line repeated \d+ additional times\]$/m;function qn(t){if(Buffer.byteLength(t)<2048||mt(t)||Xa.test(t))return t;let e=t.split(`
26
+ `),r=[];for(let n=0;n<e.length;){let s=e[n],i=n+1;if(Ja.test(s))for(;i<e.length&&e[i]===s;)i+=1;let o=i-n,a=`[tkr: previous log line repeated ${o-1} additional times]`;if(o>=3&&Buffer.byteLength(a)+1<(o-1)*(Buffer.byteLength(s)+1))r.push(s,a);else for(let u=n;u<i;u+=1)r.push(s);n=i}return r.join(`
27
+ `)}var Yn=null;function Zt(t){Yn=t}async function Qa(t,e){let r=await xn();return dt(t,r.values(),e)}var ec=/^(?:grep|rg|find|eslint|ruff|flake8|mypy|prettier|biome|black|stylelint)(?:\s|$)|^git\s+(?:diff|grep)\b/,tc=2048;async function Ut(t,e,r,n={}){let s=Buffer.byteLength(e,"utf8"),{exitCode:i,yolo:o=!1,...a}=n,u=je(Gn(t.startsWith("bash-tool: ")?t.slice(11):t)),c=i!=null&&i!==0&&!(i===1&&ec.test(u)),l=Yn??Qa,f=null;for(let w of Kn(t))if(f=await l(w,r),f)break;!f&&s>=tc&&!Ft.test(t)&&(f=await l(`bash-tool: ${t}`,r));let d=Bt(t.startsWith("bash-tool: ")?t.slice(11):t),m=f?.slug==="git-log"&&d!=null&&/^git\s+log(?:\s|$)/.test(je(d)),_=i==null&&(m?/^(?:fatal|error):/im.test(Se(e)):Hn(e)),x=f?.transform==="smart-read"&&s<=16384&&(e.endsWith(`
28
+ `)?e.slice(0,-1):e).split(`
29
+ `).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(je(d));if(!o&&(A||x&&a.smartCode!==!0))return{output:e,filterId:f?.slug??null,rawBytes:s,filteredBytes:s,debugBypass:c||_,droppedTail:null};if(!f||(c||_)&&f.preserve_exact&&!o)return{output:e,filterId:null,rawBytes:s,filteredBytes:s,debugBypass:c||_,...o?{droppedTail:null}:{}};let I=w=>{if(!o)return w;let C=w.filteredBytes>s||s>0&&w.output.length===0?e:w.output,$=!w.debugBypass&&!f?.preserve_exact?zt(C,"minimal",w.filterId??""):C,Re=jt($)===$?$:jt(C);return{...w,output:Re,filteredBytes:Buffer.byteLength(Re,"utf8"),droppedTail:null}};if(c||_){let w=o?Un(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"&&(w=qn(w)),I({output:w,filterId:f.slug,rawBytes:s,filteredBytes:Buffer.byteLength(w,"utf8"),debugBypass:!0})}let{text:P,droppedTail:ae}=Lt(e,f,o?{...a,verbosity:"minimal"}:a),U=!o&&!f.preserve_exact?zt(P,a.verbosity,f.slug):P,ce=Buffer.byteLength(U,"utf8");return e.trim().length>0&&ce>=s?I({output:e,filterId:f.slug,rawBytes:s,filteredBytes:s,debugBypass:!1,droppedTail:null}):I({output:U,filterId:f.slug,rawBytes:s,filteredBytes:ce,debugBypass:!1,droppedTail:ae})}import{join as nc}from"node:path";import{mkdir as Ff,readFile as sc,writeFile as Bf,unlink as jf,rename as zf}from"node:fs/promises";import rc from"node:os";import{join as ht}from"node:path";function R(){return process.env.TOKMIZER_HOME||ht(rc.homedir(),".tokmizer")}function Ye(){return ht(R(),"install-id")}function Ht(){return ht(R(),"content-cache")}function Jn(t){return ht(Ht(),t)}var ic="state.json";function oc(){try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t&&t.length>0?t:"Etc/UTC"}catch{return"Etc/UTC"}}function ac(t){return t?.dir??R()}async function Je(t){let e=ac(t);try{let r=await sc(nc(e,ic),"utf8"),n=JSON.parse(r);return{...n,lastSettingsRevision:n.lastSettingsRevision??0,timeZone:n.timeZone??oc(),bonusActive:n.bonusActive??!1,...n.bonusResetAt!==void 0?{bonusResetAt:n.bonusResetAt}:{}}}catch{return null}}function cc(){let t=Number(process.env.TOKMIZER_OFFLINE_GRACE_MS);return Number.isFinite(t)&&t>0?t:6048e5}function Xn(t,e=Date.now()){let r=t.lastHeartbeatOkAt;if(typeof r=="number"&&e-r>cc())return!0;if(t.subEndsAt){let n=Date.parse(t.subEndsAt);if(Number.isFinite(n)&&e>n)return!0}return!1}function Qn(t,e=Date.now()){return t.plan}var uc=[[/(authorization\s*:\s*)([A-Za-z][A-Za-z0-9._-]*)\s+[^\s'"]+/gi,"$1$2 [REDACTED]"],[/(authorization\s*:\s*)[A-Za-z0-9._\-+/=]{8,}/gi,"$1[REDACTED]"],[/(bearer\s+)[A-Za-z0-9._\-+/=]{8,}/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-b|--cookie)[=\s]+['"]?)[^\s'";=]+=[^\s'";]+(?:\s*;\s*[^\s'";=]+=[^\s'";]+)*/gi,"$1[REDACTED]"],[/((?:^|[\s'"])(?:Set-)?Cookie\s*:\s*)[^\s'";=]+=[^\s'";]+(?:\s*;\s*[^\s'";=]+=[^\s'";]+)*/gi,"$1[REDACTED]"],[/(--?(?:password|passwd|passphrase|apipass|pass|pwd|token|api[-_]?key|secret|bearer|cookie|jwt)(?:-[a-z0-9]+)*[=\s]+)\S+/gi,"$1[REDACTED]"],[/((?:^|\s)-b[=\s]?['"]?)[^\s'"=]+=[^\s'"]+/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?[^\s:/'"]*:)(\/[^/\s'"][^\s'"]*|[^\s/'"0-9][^\s'"]*|[0-9][^\s'"]*[^\s'"0-9][^\s'"]*)/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?[^\s:/'"]*[^\s:/'"0-9][^\s:/'"]*:)(?:\/[^/\s'"]|[^\s/'"])[^\s'"]*/gi,"$1[REDACTED]"],[/((?:^|\s)(?:-u[=\s]?|(?:--user|-a)[=\s])['"]?:)(?:\/[^/\s'"]|[^\s/'"])[^\s'"]*/gi,"$1[REDACTED]"],[/((?:[A-Za-z0-9]+-){0,8}(?:X-Api-Key|Private-Token|[A-Za-z0-9]+-(?:Token|Key|Auth|Secret))\s*:\s*)[^\s'"]+/gi,"$1[REDACTED]"],[/((?:^|[\s'"])(?:Set-)?Cookie\s*:\s*)[^\s'"]+/gi,"$1[REDACTED]"],[/(-i\s+)(\/[^\s]+|~\/[^\s]+|[A-Z]:\\[^\s]+)/g,"$1[REDACTED]"],[/([a-zA-Z][a-zA-Z0-9+.-]{0,31}:\/\/[^:/\s@]*:)[^\s@]+(@[^@/\s]+)/g,"$1[REDACTED]$2"],[/(AWS_(?:ACCESS_KEY_ID|SECRET_ACCESS_KEY|SESSION_TOKEN)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(GOOGLE_APPLICATION_CREDENTIALS\s*=\s*)\S+/g,"$1[REDACTED]"],[/(AZURE_(?:CLIENT_SECRET|TENANT_ID|CLIENT_ID)\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-(?:proj-)?[A-Za-z0-9_-]{20,})/g,"sk-[REDACTED]"],[/\b(OPENAI_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(ANTHROPIC_API_KEY\s*=\s*)\S+/g,"$1[REDACTED]"],[/(sk-ant-[A-Za-z0-9_-]{20,})/g,"sk-ant-[REDACTED]"],[/\b(GH(?:_|ITHUB_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(GITLAB_TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/\b(SLACK_(?:BOT_)?TOKEN\s*=\s*)\S+/g,"$1[REDACTED]"],[/(xox[bpsoa]-[A-Za-z0-9-]{10,})/g,"xox[REDACTED]"],[/(xapp-[A-Za-z0-9-]{10,})/g,"[REDACTED]"],[/(sk_(?:test|live)_[A-Za-z0-9]{16,})/g,"sk_[REDACTED]"],[/(gh[a-z])_[A-Za-z0-9]{20,}/g,"$1_[REDACTED]"],[/(github_pat)_[A-Za-z0-9_]{20,}/g,"$1_[REDACTED]"],[/(gl(?:pat|rt|soat|imt|dt|ft|agent|oas|cbt|ptt))-[A-Za-z0-9_-]{16,}/g,"$1-[REDACTED]"],[/(npm_[A-Za-z0-9_-]{20,})/g,"npm_[REDACTED]"],[/(?:AKIA|ASIA|AGPA|AIDA|AROA|ANPA)[0-9A-Z]{16,}/g,"[REDACTED_AWS_KEY]"],[/AIza[A-Za-z0-9_-]{35}/g,"[REDACTED_GOOGLE_KEY]"],[/hv[sb]\.[A-Za-z0-9_-]{20,}/g,"[REDACTED_VAULT_TOKEN]"],[/dop_v1_[A-Za-z0-9]{40,}/g,"[REDACTED]"],[/dckr_pat_[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/pypi-[A-Za-z0-9_-]{16,}/g,"[REDACTED]"],[/rk_(?:live|test)_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/whsec_[A-Za-z0-9]{16,}/g,"[REDACTED]"],[/SG\.[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}/g,"[REDACTED]"],[/(eyJ[A-Za-z0-9_-]{6,}(?:\.[A-Za-z0-9_-]{4,}){1,2})/g,"[REDACTED_JWT]"],[/-----BEGIN [A-Z ]*PRIVATE KEY-----(?:[\s\S]*?-----END[^\n]*-----|\r?\n[A-Za-z0-9+/=][A-Za-z0-9+/=\r\n]*)?/g,"[REDACTED_PEM]"],[/\b((?:--?)?[A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|AUTH|_PWD)[A-Za-z0-9_]*['"]?\s*=\s*)(?:"[^"]*"|'[^']*'|[^"'\s]\S*)/gi,"$1[REDACTED]"],[/\b([A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|PASS|APIKEY|KEY|CRED|CREDS|CREDENTIAL|CREDENTIALS|_PWD)[A-Za-z0-9_]*['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/((?:^|[\s'"{,])['"]?(?:[A-Za-z0-9_]+_)?auth['"]?\s*:\s*)(?:"[^"]*"|'[^']*'|[^\s'",}]+)/gi,"$1[REDACTED]"],[/(\bpwd\s*[=:]\s*)(?:"[^"]*"|'[^']*'|[^/~\s][^\s;'"]*)/gi,"$1[REDACTED]"],[/([=:]\s*["']?)[A-Za-z0-9_\-+/=]{40,}/g,"$1[REDACTED]"]];function Xe(t){let e=t;for(let[r,n]of uc)e=e.replace(r,n);return e}import{join as is}from"node:path";import{appendFileSync as bc,chmodSync as vc,existsSync as xc,mkdirSync as Ec,readFileSync as bp,renameSync as vp,rmdirSync as xp,statSync as wc,unlinkSync as Ep,utimesSync as wp,writeFileSync as kp}from"node:fs";import{createHash as Kf,randomUUID as lc}from"node:crypto";import{readFile as es,writeFile as ts,mkdir as dc}from"node:fs/promises";async function Vt(){try{let r=(await es(Ye(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(r))return r}catch{}await dc(R(),{recursive:!0});let t=lc();try{return await ts(Ye(),t,{mode:384,flag:"wx"}),t}catch{try{let e=(await es(Ye(),"utf8")).trim();if(/^[0-9a-f-]{36}$/i.test(e))return e}catch{}return await ts(Ye(),t,{mode:384}),t}}import{createRequire as fc}from"node:module";var pc=fc(import.meta.url);function mc(){for(let t of["../package.json","../../package.json"])try{let e=pc(t).version;if(typeof e=="string"&&e)return e}catch{}return"0.0.0"}var Gt=mc();var rs=`-----BEGIN PUBLIC KEY-----
15
30
  MCowBQYDK2VwAyEAj/kMlXlhTIGHRKxOKMuGFa1S1ybxxwgdYcAE0YM9fgU=
16
31
  -----END PUBLIC KEY-----
17
- `;var Ef=300*1e3;function Wr(){return((process.env.TOKMIZER_DEV==="1"?process.env.TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM:void 0)??Gr).replace(/\\n/g,`
18
- `)}import{readFile as Ga,writeFile as Sf,mkdir as Tf,chmod as Af,rm as Rf,rename as Cf}from"node:fs/promises";import{join as Wa}from"node:path";var qa="settings-cache.json",qr=It.parse({});async function Ke(){try{let t=await Ga(Wa(T(),qa),"utf8"),e=JSON.parse(t);return It.parse({...qr,...e})}catch{return qr}}var nc=512*1024;function Xr(){return Yr(T(),"spool")}function rc(t){return Yr(Xr(),`${t}.jsonl`)}function lt(t,e){try{ec(Xr(),{recursive:!0,mode:448});let n=rc(t);if(Qa(n)&&tc(n).size>=nc)return;Xa(n,JSON.stringify(e)+`
19
- `,{mode:384}),Ja(n,384)}catch{return}}var ic=/^[a-z0-9][a-z0-9._-]*$/i,oc=/^[a-z][a-z-]+$/,ac=/^[A-Za-z_][A-Za-z0-9_]*=/,cc=new Set(["gh","glab","gup","hub","gist"]),lc=/^(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,uc=24,dc=new Set(["docker","podman","npm","pnpm","yarn","npx","bun","deno","cargo","rustup","go","pip","pip3","uv","poetry","brew","apt","apt-get","dnf","yum","pacman","kubectl","helm","terraform","aws","gcloud","az","systemctl","composer","bundle","gem","dotnet","prisma","tkr","rtk","token"]);function Jr(t){let e=t.toLowerCase();return e.startsWith("git")||cc.has(e)}function zt(t){let e=t.trim().split(/\s+/).filter(a=>a.length>0),n=0;for(;n<e.length&&ac.test(e[n]??"");)n+=1;let r=e[n];if(!r||!ic.test(r)||r.length>uc||Jr(r)||lc.test(r)||Ve(r)!==r)return"";let s=e[n+1];return s&&Jr(s)?"":(s&&dc.has(r.toLowerCase())&&oc.test(s)?`${r} ${s}`:r).slice(0,64)}async function Qr(t){if(!t.telemetryOptIn)return;let e=zt(t.cmd),n=e&&Ve(e)===e?e:"other",r=t.sessionId?t.sessionId.replace(/[^A-Za-z0-9._-]/g,"").slice(0,64):"";lt("telemetry",{cmd:n,tokensSaved:Math.max(0,Math.round(t.tokensSaved)),...t.tokensRestored?{tokensRestored:Math.max(0,Math.round(t.tokensRestored))}:{},...t.rawTokens!=null?{rawTokens:Math.max(0,Math.round(t.rawTokens))}:{},optimized:t.optimized,...r?{sessionId:r}:{},...t.host?{host:t.host}:{}})}async function es(t){if(t.plan!=="pro"||!(await Ke()).telemetryOptIn)return;let e=zt(t.cmd);!e||Ve(e)!==e||lt("learn",{cmd:e,filterId:t.filterId==null?null:U(t.filterId),rawBytes:t.rawBytes,filteredBytes:t.filteredBytes})}import{appendFileSync as gc,chmodSync as yc,mkdirSync as _c}from"node:fs";import{readFileSync as fc,renameSync as pc,statSync as mc,writeFileSync as hc}from"node:fs";function ts(t,e,n){try{if(mc(t).size<=e)return;let r=fc(t,"utf8").split(`
20
- `).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}`;hc(o,s.length?`${s.join(`
32
+ `;var rp=300*1e3;function ns(){return((process.env.TOKMIZER_DEV==="1"?process.env.TOKMIZER_RESP_SIGNING_PUBLIC_KEY_PEM:void 0)??rs).replace(/\\n/g,`
33
+ `)}import{readFile as hc,writeFile as ip,mkdir as op,chmod as ap,rm as cp,rename as up,readdir as lp}from"node:fs/promises";import{join as gc}from"node:path";var yc="settings-cache.json",ss=qe.parse({}),mp=qe.partial().extend({filters:qe.shape.filters.removeDefault().partial().optional()});async function Qe(){try{let t=await hc(gc(R(),yc),"utf8"),e=JSON.parse(t);return qe.parse({...ss,...e})}catch{return ss}}var kc=512*1024;function os(){return is(R(),"spool")}function Sc(t){return is(os(),`${t}.jsonl`)}function gt(t,e){try{Ec(os(),{recursive:!0,mode:448});let r=Sc(t);if(xc(r)&&wc(r).size>=kc)return;bc(r,JSON.stringify(e)+`
34
+ `,{mode:384}),vc(r,384)}catch{return}}var Rc=/^[a-z0-9][a-z0-9._-]*$/i,Ac=/^[a-z][a-z-]+$/,Cc=/^[A-Za-z_][A-Za-z0-9_]*=/,Ic=new Set(["gh","glab","gup","hub","gist"]),$c=/^(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,Oc=24,Nc=new Set(["docker","podman","npm","pnpm","yarn","npx","bun","deno","cargo","rustup","go","pip","pip3","uv","poetry","brew","apt","apt-get","dnf","yum","pacman","kubectl","helm","terraform","aws","gcloud","az","systemctl","composer","bundle","gem","dotnet","prisma","tkr","rtk","token"]);function as(t){let e=t.toLowerCase();return e.startsWith("git")||Ic.has(e)}function Kt(t){let e=t.trim().split(/\s+/).filter(a=>a.length>0),r=0;for(;r<e.length&&Cc.test(e[r]??"");)r+=1;let n=e[r];if(!n||!Rc.test(n)||n.length>Oc||as(n)||$c.test(n)||Xe(n)!==n)return"";let s=e[r+1];return s&&as(s)?"":(s&&Nc.has(n.toLowerCase())&&Ac.test(s)?`${n} ${s}`:n).slice(0,64)}async function cs(t){if(!t.telemetryOptIn)return;let e=Kt(t.cmd),r=e&&Xe(e)===e?e:"other",n=t.sessionId?t.sessionId.replace(/[^A-Za-z0-9._-]/g,"").slice(0,64):"";gt("telemetry",{cmd:r,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,...n?{sessionId:n}:{},...t.host?{host:t.host}:{}})}async function us(t){if(t.plan!=="pro"||!(await Qe()).telemetryOptIn)return;let e=Kt(t.cmd);!e||Xe(e)!==e||gt("learn",{cmd:e,filterId:t.filterId==null?null:V(t.filterId),rawBytes:t.rawBytes,filteredBytes:t.filteredBytes})}import{appendFileSync as Fc,chmodSync as Bc,mkdirSync as jc}from"node:fs";import{readFileSync as Dc,renameSync as Pc,statSync as Mc,writeFileSync as Lc}from"node:fs";function ls(t,e,r){try{if(Mc(t).size<=e)return;let n=Dc(t,"utf8").split(`
35
+ `).filter(a=>a.trim()!==""),s=[],i=0;for(let a=n.length-1;a>=0;a-=1){let u=n[a],c=Buffer.byteLength(u)+1;if(i+c>r)break;s.push(u),i+=c}s.reverse();let o=`${t}.tmp-${process.pid}`;Lc(o,s.length?`${s.join(`
21
36
  `)}
22
- `:"",{mode:384}),pc(o,t)}catch{}}import{join as vc}from"node:path";var xc="stats.jsonl";var ns=2*1024*1024;var bc=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),Ec=new Set(["-u","-g","-n","-s","-k"]),kc=/^[a-z0-9][a-z0-9._-]*$/i,wc=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"]),ss=/^[A-Za-z_][A-Za-z0-9_]*=/;function rs(t){return t.length===0||t[0]==="cd"||t.every(e=>ss.test(e))}function Sc(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(`|;&<>
23
- `.includes(o)){if(i(),rs(e)){e=[];continue}return e}n+=o,r=!0}return i(),rs(e)?[]:e}function is(t){let e=Sc(t).map(a=>a.replace(/^[({]+/,"")).filter(Boolean),n=0;for(;n<e.length;){let a=e[n];if(ss.test(a)){n+=1;continue}if(bc.has(a)){for(n+=1;n<e.length;){let c=e[n];if(c.startsWith("-")){n+=Ec.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("-")&&kc.test(i)&&wc.has(s.toLowerCase())?`${s} ${i}`:s).slice(0,24)}function Tc(){return vc(T(),xc)}function os(t,e,n=Tc(),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)}`:"",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}}
24
- `;try{_c(T(),{recursive:!0,mode:448}),gc(n,u,{mode:384}),yc(n,384),ts(n,ns,ns/2)}catch{return}}function as(t,e,n){let r=n!=null?Math.min(t,n):t,s=Math.min(e,r);return{raw:r,filtered:s}}import{appendFileSync as Ac,mkdirSync as Rc,readFileSync as Cc,writeFileSync as Ic,renameSync as $c,statSync as Oc,readdirSync as gp,rmSync as yp,chmodSync as Pc}from"node:fs";import{join as cs}from"node:path";var Dc=96*1024,Nc=500,xp=168*3600*1e3,Mc=120;function ls(){return cs(T(),"sessions")}function Lc(t){let e=t.replace(/[^A-Za-z0-9._-]/g,"-").replace(/\.\./g,"-").slice(0,80)||"default";return cs(ls(),`${e}.jsonl`)}function us(t,e){try{let n=Lc(t);Rc(ls(),{recursive:!0,mode:448});let r=JSON.stringify({t:e.t??Math.floor(Date.now()/1e3),tool:e.tool,target:e.target.slice(0,Mc),...e.fail?{fail:1}:{}});if(Ac(n,`${r}
25
- `,{mode:384}),Pc(n,384),Oc(n).size>Dc){let s=Cc(n,"utf8").split(`
26
- `).filter(a=>a.trim()!==""),i=s.slice(s.length-Nc),o=`${n}.tmp-${process.pid}`;Ic(o,`${i.join(`
37
+ `:"",{mode:384}),Pc(o,t)}catch{}}import{join as zc}from"node:path";var Zc="stats.jsonl";var ds=2*1024*1024;var Uc=new Set(["sudo","command","time","nice","nohup","env","stdbuf","timeout"]),Hc=new Set(["-u","-g","-n","-s","-k"]),Vc=/^[a-z0-9][a-z0-9._-]*$/i,Gc=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"]),ps=/^[A-Za-z_][A-Za-z0-9_]*=/;function fs(t){return t.length===0||t[0]==="cd"||t.every(e=>ps.test(e))}function Kc(t){let e=[],r="",n=!1,s=null,i=()=>{n&&e.push(r),r="",n=!1};for(let o of t){if(s){o===s?s=null:r+=o;continue}if(o==="'"||o==='"'){s=o,n=!0;continue}if(o===" "||o===" "){i();continue}if(`|;&<>
38
+ `.includes(o)){if(i(),fs(e)){e=[];continue}return e}r+=o,n=!0}return i(),fs(e)?[]:e}function ms(t){let e=Kc(t).map(a=>a.replace(/^[({]+/,"")).filter(Boolean),r=0;for(;r<e.length;){let a=e[r];if(ps.test(a)){r+=1;continue}if(Uc.has(a)){for(r+=1;r<e.length;){let u=e[r];if(u.startsWith("-")){r+=Hc.has(u)?2:1;continue}if(/^\d+(?:\.\d+)?[smhd]?$/.test(u)){r+=1;continue}break}continue}break}if(r>=e.length)return"";let n=e[r],s=n.includes("/")?n.slice(n.lastIndexOf("/")+1):n,i=e[r+1];return(i&&!i.startsWith("-")&&Vc.test(i)&&Gc.has(s.toLowerCase())?`${s} ${i}`:s).slice(0,24)}function Wc(){return zc(R(),Zc)}function hs(t,e,r=Wc(),n=!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)}`:"",u=i?`,"k":${JSON.stringify(i)}`:"",c=o?`,"c":${JSON.stringify(o.slice(0,24))}`:"",l=`{"t":${Math.floor(Date.now()/1e3)},"r":${t},"f":${e}${n?',"m":1':""}${a}${u}${c}}
39
+ `;try{jc(R(),{recursive:!0,mode:448}),Fc(r,l,{mode:384}),Bc(r,384),ls(r,ds,ds/2)}catch{return}}function gs(t,e,r){let n=r!=null?Math.min(t,r):t,s=r!=null?Math.min(e,r):e;return{raw:n,filtered:s}}import{appendFileSync as qc,mkdirSync as Yc,readFileSync as Jc,writeFileSync as Xc,renameSync as Qc,statSync as eu,readdirSync as Jp,rmSync as Xp,chmodSync as tu}from"node:fs";import{join as ys}from"node:path";var ru=96*1024,nu=500,tm=168*3600*1e3,su=120;function _s(){return ys(R(),"sessions")}function iu(t){let e=t.replace(/[^A-Za-z0-9._-]/g,"-").replace(/\.\./g,"-").slice(0,80)||"default";return ys(_s(),`${e}.jsonl`)}function bs(t,e){try{let r=iu(t);Yc(_s(),{recursive:!0,mode:448});let n=JSON.stringify({t:e.t??Math.floor(Date.now()/1e3),tool:e.tool,target:e.target.slice(0,su),...e.fail?{fail:1}:{}});if(qc(r,`${n}
40
+ `,{mode:384}),tu(r,384),eu(r).size>ru){let s=Jc(r,"utf8").split(`
41
+ `).filter(a=>a.trim()!==""),i=s.slice(s.length-nu),o=`${r}.tmp-${process.pid}`;Xc(o,`${i.join(`
27
42
  `)}
28
- `,{mode:384}),$c(o,n)}}catch{}}var ds=[{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"]}],Ep=[...ds.map(t=>t.host),"shell"],Fc=new Set(["claude-code","codex"]);function fs(t){return null}function ps(t=process.env){let e=process.platform,n=e==="darwin"||e==="linux"||e==="win32"?e:"other",r=process.arch;for(let s of ds)if(s.vars.some(i=>t[i]))return{host:s.host,source:"env",os:n,arch:r,shimRecommended:!Fc.has(s.host)};return{host:"shell",source:"fallback",os:n,arch:r,shimRecommended:!0}}import{delimiter as ms,join as Bc,dirname as Tp}from"node:path";function jc(){return Bc(T(),"shims")}function hs(){let t=jc(),e={...process.env},n=process.platform==="win32"?"Path":"PATH",s=(e[n]??e.PATH??"").split(ms).filter(i=>i&&i!==t);return e[n]=s.join(ms),n==="Path"&&(e.PATH=e[n]),e}import{createConnection as el}from"node:net";import{spawn as tl}from"node:child_process";import{existsSync as Es,openSync as Vt,closeSync as xs,unlinkSync as Gt,writeFileSync as Wt,mkdirSync as qt,readFileSync as nl,appendFileSync as rl,rmSync as sl,statSync as il}from"node:fs";import{dirname as ol,join as Yt}from"node:path";import{fileURLToPath as al}from"node:url";var zc=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()}),Zc=m.object({id:m.string().min(1).max(64),op:m.literal("ping")}),Uc=m.object({id:m.string().min(1).max(64),op:m.literal("shutdown"),installId:m.string().min(1).max(64)}),Hc=m.object({id:m.string().min(1).max(64),op:m.literal("reload"),installId:m.string().min(1).max(64).optional()}),Op=m.discriminatedUnion("op",[zc,Zc,Uc,Hc]),Pp=m.object({id:m.string(),ok:m.literal(!0),data:m.unknown()}),Dp=m.object({id:m.string(),ok:m.literal(!1),err:m.string(),retryAfterMs:m.number().int().nonnegative().optional()}),gs=m.object({filter:$e.nullable(),cacheHit:m.boolean().optional()}),ut=`
29
- `,Np=64*1024;function Zt(t){return JSON.stringify(t)+ut}function*ys(t){let e=0;for(;;){let n=t.indexOf(ut,e);if(n<0)return;yield t.slice(e,n),e=n+1}}function Ge(){return`${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import Vc from"node:os";import{join as We}from"node:path";import{existsSync as Kc,statSync as Gc,lstatSync as _s,unlinkSync as Wc,mkdirSync as qc,chmodSync as Yc}from"node:fs";import{createHash as Xc}from"node:crypto";var Ut=100;function Jc(t){let e=Xc("sha256").update(T()).digest("hex").slice(0,8),n=We(Vc.tmpdir(),`tkr-${t}-${e}`),r=We(n,"d.sock");if(Buffer.byteLength(r)>Ut)throw new Error("Temporary directory path is too long for IPC");return vs(n,t),r}function Qc(t,e){try{let n=_s(t);return n.isDirectory()&&n.uid===e&&(n.mode&63)===0}catch{return!1}}function vs(t,e){qc(t,{recursive:!0,mode:448});let n=_s(t);if(!n.isDirectory()||n.uid!==e)throw new Error("Unsafe IPC directory");Yc(t,448)}function qe(){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&&Qc(e,t)){let s=We(e,`tokmizer-${t}.sock`);if(Buffer.byteLength(s)<=Ut)return{path:s,isPipe:!1}}let n=We(T(),"run"),r=We(n,"daemon.sock");return Buffer.byteLength(r)>Ut?{path:Jc(t),isPipe:!1}:(vs(n,t),{path:r,isPipe:!1})}async function Ht(){let{path:t,isPipe:e}=qe();if(e||!Kc(t))return;try{if(!Gc(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{Wc(t)}catch{}}var Zp=5*6e4;var ks=500,cl=3e3,bs=1,ll=6e4,ul=256*1024;function Xt(){return Yt(T(),"daemon.spawn.fail")}function Jt(){return Yt(T(),"daemon.log")}function dl(){try{let t=Number(nl(Xt(),"utf8"));return Number.isFinite(t)&&Date.now()-t<ll}catch{return!1}}function fl(t){try{qt(T(),{recursive:!0});let e=Jt();try{il(e).size>ul&&Gt(e)}catch{}rl(e,`${new Date().toISOString()} ${t}
30
- `)}catch{}}function pl(t){try{qt(T(),{recursive:!0}),Wt(Xt(),String(Date.now()))}catch{}fl(`spawn failed: ${t.message}`)}function ml(){try{sl(Xt(),{force:!0})}catch{}}async function dt(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 hl(){return process.env.TOKMIZER_DAEMON_BIN?process.env.TOKMIZER_DAEMON_BIN:al(new URL("../bin/tkr-daemon.js",import.meta.url))}async function Kt(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 dt(t,75)).destroy(),!0}catch{}else if(Es(t))return!0;await new Promise(i=>setTimeout(i,75))}return!1}async function gl(t){let e=hl();if(!Es(e))throw new Error(`tkr-daemon binary not found at ${e}`);let{path:n}=qe(),r=process.platform==="win32"?T():ol(n);try{qt(r,{recursive:!0})}catch{}let s=Yt(r,"daemon.spawn.lock"),i=null;try{i=Vt(s,"wx"),Wt(i,String(process.pid))}catch(o){if(o.code==="EEXIST"){if(await Kt(n,5e3))return;try{Gt(s)}catch{}try{i=Vt(s,"wx"),Wt(i,String(process.pid))}catch(c){if(c.code==="EEXIST"){await Kt(n,5e3);return}throw c}}else throw o}try{let o=null;try{o=Vt(Jt(),"a")}catch{}if(tl(process.execPath,[e],{detached:!0,stdio:["ignore","ignore",o??"ignore"],env:{...process.env,TOKMIZER_DAEMON_INSTALL_ID:t}}).unref(),o!==null)try{xs(o)}catch{}if(!await Kt(n,3e3))throw new Error("tkr-daemon failed to bind socket within 3s")}finally{if(i!==null){try{xs(i)}catch{}try{Gt(s)}catch{}}}}async function yl(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:qe(),n=await Bt();try{let r=await dt(e,ks);r.write(Zt({id:Ge(),op:"shutdown",installId:n})),await new Promise(s=>setTimeout(s,150));try{r.destroy()}catch{}return!0}catch{return!1}}async function _l(t,e){let n=Date.now()+e;for(;Date.now()<n;){try{(await dt(t,250)).destroy()}catch{return!0}await new Promise(r=>setTimeout(r,100))}return!1}async function Qt(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:qe(),n=await Bt(),r=null,s=0,i=!1;for(;s<=bs;)try{r=await dt(e,ks),ml();break}catch{if(s+=1,s>bs)throw new Error(`tkr-daemon unreachable at ${e}`);if(dl())throw new Error(`tkr-daemon spawn on cooldown (see ${Jt()})`);await Ht();try{await gl(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 d=-1;for(let y=0;y<a.length;y++)a[y]===ut&&(d=y);if(d<0)return;let p=[];for(let y of ys(a.slice(0,d+1)))p.push(y);a=a.slice(d+1);for(let y of p)if(y)try{let w=JSON.parse(y),b=o.get(w.id);if(!b)continue;clearTimeout(b.timer),o.delete(w.id),b.resolve(w)}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((d,p)=>{let y=setTimeout(()=>{o.delete(u.id),p(new Error(`daemon request timeout (${u.op})`))},cl);o.set(u.id,{resolve:d,reject:p,timer:y}),r.write(Zt(u))})}let l={filter:async(u,d,p)=>{let y=await c({id:Ge(),op:"filter",cmd:u.slice(0,2048),plan:d,...p&&p.length>0?{allowed:p.slice(0,512)}:{},installId:n});if(!y.ok)return null;let w=gs.safeParse(y.data);return w.success?w.data.filter:null},ping:async()=>{let u=await c({id:Ge(),op:"ping"});if(!u.ok)throw new Error(u.err);return u.data},reload:async()=>{let u=await c({id:Ge(),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!==jt}catch{}if(u){try{await yl(t.socketPath?{socketPath:t.socketPath}:{})}catch{}l.close();let d=await _l(e,2e3);if(await Ht(),!d)throw new Error("stale daemon still running after shutdown request");return Qt({...t,skipVersionCheck:!0})}}return l}import{createPublicKey as Rl,verify as Cl}from"node:crypto";import{createCipheriv as rm,createDecipheriv as vl,hkdfSync as xl,randomBytes as sm}from"node:crypto";var bl=Buffer.from("tokmizer-bundle-enc-v1"),El=Buffer.from("rules-bundle");function kl(t){return Buffer.from(xl("sha256",Buffer.from(t,"utf8"),bl,El,32))}function ws(t,e){let n=kl(e),r=Buffer.from(t,"base64url"),s=r.subarray(0,12),i=r.subarray(12,28),o=r.subarray(28),a=vl("aes-256-gcm",n,s);return a.setAuthTag(i),Buffer.concat([a.update(o),a.final()]).toString("utf8")}import{chmodSync as am,readFileSync as wl,writeFileSync as cm,mkdirSync as lm,renameSync as um}from"node:fs";import{join as Sl}from"node:path";var Tl=m.object({payload:m.string().min(1),signature:m.string().min(1),enc:m.literal("v1"),fetchedAt:m.number().int().nonnegative()});function Al(){return Sl(T(),"bundle-cache.json")}function Ss(){try{let t=wl(Al(),"utf8"),e=Tl.safeParse(JSON.parse(t));return e.success?e.data:null}catch{return null}}var Il=m.object({bundleVersion:m.number().int().nonnegative(),signedAt:m.number().int(),filters:m.array($e)}),wm=m.object({payload:m.string().min(1),signature:m.string().min(1),enc:m.literal("v1")}),$l=10080*60*1e3;function Ol(){let t=Number(process.env.TOKMIZER_MAX_BUNDLE_AGE_MS);return Number.isFinite(t)&&t>0?t:$l}function Pl(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=Rl({key:n,format:"pem"});if(!Cl(null,Buffer.from(t.payload,"utf8"),r,Buffer.from(t.signature,"base64url")))throw new Error("tkr-daemon: rules bundle signature invalid");return JSON.parse(ws(t.payload,e))}function Dl(t,e){let n=Pl(t,e),r=Il.parse(n);if(Date.now()-r.signedAt>Ol())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 gr(),{bundleVersion:r.bundleVersion,signedAt:r.signedAt,ruleCount:s.size,startedAt:Date.now(),fetchedAt:Date.now(),selectFor:(i,o,a)=>st(i,s.values(),a&&a.length>0?new Set(a):null)}}async function Ts(){try{let t=Ss();if(!t)return null;let e=await He();return e?.signingSecret?Dl(t,e.signingSecret):null}catch{return null}}var Pe=null,Ye=null;async function Nl(){if(Pe)return Pe;if(Ye)return Ye;let t=Qt().then(e=>{if(Ye===t)return Pe=e,e;try{e.close()}catch{}return null}).catch(()=>null);return Ye=t,t}var en=null,tn=!1;async function Ml(){return tn||(tn=!0,en=await Ts()),en}async function As(t,e,n){let r=await Ml();if(!r)return null;let s=r.selectFor(t,e,[...n]);return!s||!n.has(U(s.slug))?null:s}function Ll(t){return t?{...t,matchRegex:new RegExp(t.match_command)}:null}function Rs(t){Mt(async(e,n)=>{let r=t==="free"?"trial":t,s=n??rt(void 0),i=await Nl();if(!i)return As(e,r,s);try{let o=await i.filter(e,r,[...s]);return!o||!s.has(U(o.slug))?null:Ll(o)}catch{return As(e,r,s)}})}function Cs(){if(Mt(null),Pe)try{Pe.close()}catch{}Pe=null,Ye=null,en=null,tn=!1}import{chmod as Fl,mkdir as Bl,readFile as Om,writeFile as jl,stat as Pm,readdir as Dm,rm as zl,rename as Zl}from"node:fs/promises";import{createHash as Is}from"node:crypto";var Lm=10080*60*1e3,Fm=100*1024*1024,Ul=2*1024*1024,Hl=/^[0-9a-f]{8,64}$/i;function Vl(t,e){let n=Number(process.env[t]);return Number.isFinite(n)&&n>0?n:e}async function $s(t,e){if(!Hl.test(t)||Buffer.byteLength(e,"utf8")>Vl("TOKMIZER_CCR_ENTRY_MAX_BYTES",Ul))return!1;let n=Zr(t),r=`${n}.tmp-${process.pid}-${process.hrtime.bigint()}`;try{return await Bl(Ft(),{recursive:!0}),await jl(r,e,{mode:384}),await Fl(r,384),await Zl(r,n),!0}catch{try{await zl(r)}catch{}return!1}}async function Os(t,e){let n=process.env.TOKMIZER_CCR_DISABLED;if(n==="1"||n==="true"||!t)return e;let r=Is("sha256").update(t).digest("hex").slice(0,16),s=`
31
- [tkr restore ${r}]`;return Buffer.byteLength(t,"utf8")<=Buffer.byteLength(s,"utf8")||!await $s(r,t)?e:`${e}${s}`}async function Ps(t,e){let n=process.env.TOKMIZER_CCR_DISABLED;if(n==="1"||n==="true"||!t)return e;let r=Is("sha256").update(t).digest("hex").slice(0,16);return await $s(r,t)?`${e}
32
- [tkr restore ${r}]`:e}var De=10*1024*1024,Jl=1024,Ql=6e4;function eu(){try{let t=process.env.TOKMIZER_TKR_BIN||Xl(new URL("../bin/tkr.js",import.meta.url));if(!Kl(t))return;let e=Yl(T(),"enroll-kick");try{let r=Number(Gl(e,"utf8"));if(Number.isFinite(r)&&Date.now()-r<Ql)return}catch{}ql(T(),{recursive:!0}),Wl(e,String(Date.now())),(0,nn.default)(process.execPath,[t,"heartbeat"],{detached:!0,stdio:"ignore"}).unref()}catch{}}function tu(t){let e=Number(t.TOKMIZER_EXEC_TIMEOUT_MS);if(Number.isFinite(e)&&e>0)return e;let n=Number(t.BASH_MAX_TIMEOUT_MS);return Number.isFinite(n)&&n>6e5?n:6e5}var nu=tu(process.env),ru={SIGHUP:1,SIGINT:2,SIGQUIT:3,SIGILL:4,SIGTRAP:5,SIGABRT:6,SIGBUS:7,SIGFPE:8,SIGKILL:9,SIGUSR1:10,SIGSEGV:11,SIGUSR2:12,SIGPIPE:13,SIGALRM:14,SIGTERM:15};function rn(t){return ru[t]??15}async function Ds(t){let[e,...n]=t;if(!e)throw new Error("tkr-exec: missing command");let r=(0,nn.default)(e,n,{stdio:["inherit","pipe","pipe"],env:hs()}),s=!1;r.on("spawn",()=>{s=!0});let i=A=>{try{r.kill(A)}catch{}},o=()=>i("SIGINT"),a=()=>i("SIGTERM");process.on("SIGINT",o),process.on("SIGTERM",a);let c=[],l=[],u=0,d=0,p=!1,y=!1;r.stdout?.on("data",A=>{if(u>=De){p=!0;return}let R=De-u,L=A.length>R?A.subarray(0,R):A;c.push(L),u+=L.length,A.length>R&&(p=!0)}),r.stderr?.on("data",A=>{if(d>=De){y=!0;return}let R=De-d,L=A.length>R?A.subarray(0,R):A;l.push(L),d+=L.length,A.length>R&&(y=!0)});let w,b;try{b=await new Promise((A,R)=>{r.on("error",L=>{w&&clearTimeout(w),s?A(1):R(L)}),r.on("close",(L,Ne)=>{w&&clearTimeout(w),A(L??(Ne?128+rn(Ne):0))}),w=setTimeout(()=>{r.kill("SIGTERM"),setTimeout(()=>r.kill("SIGKILL"),2e3)},nu),w.unref?.()})}finally{process.off("SIGINT",o),process.off("SIGTERM",a)}let C=Buffer.concat(c).toString("utf8"),M=Buffer.concat(l).toString("utf8"),X=p?`
33
- \u2026 (output truncated at ${De/(1024*1024)}MB)`:"",J=y?M+`
34
- \u2026 (stderr truncated at ${De/(1024*1024)}MB)`:M,sn=()=>{let A=C+X,R=Buffer.byteLength(A,"utf8");return{stdout:A,stderr:J,code:b,filterId:null,rawBytes:R,filteredBytes:R,truncated:p}};try{let A=await He();A||eu();let R=await Ke();if(!R.enabled)return sn();let L=process.env.CLAUDE_CODE_SESSION_ID;L&&A?.token&&us(L,{tool:"Bash",target:t.join(" "),...b!==0?{fail:1}:{}});let Ne=A?Hr(A):null,ft=A?rt(A.allowedFilters,Ur(A)):null,on=new Set(R.filters.disabled.map(U)),an=ft&&on.size>0?new Set([...ft].filter(Fe=>!on.has(Fe))):ft,Me=t.join(" ");A&&Rs(Ne);let $=await Lt(Me,C,an,{verbosity:R.outputVerbosity,exitCode:b}),cn=J,pt=0,mt=0;if(b===0&&Buffer.byteLength(J,"utf8")>=Jl){let Fe=await Lt(Me,J,an,{verbosity:R.outputVerbosity,exitCode:b});cn=Fe.output,pt=Fe.rawBytes,mt=Fe.filteredBytes}let ht=ps().host,Le=as($.rawBytes+pt,$.filteredBytes+mt,fs(ht));try{os(Le.raw,Le.filtered,void 0,!1,ht,"sh",is(Me)),await es({cmd:Me,filterId:$.filterId,rawBytes:$.rawBytes,filteredBytes:$.filteredBytes,plan:Ne}),await Qr({cmd:Me,tokensSaved:Math.round((Le.raw-Le.filtered)/4),rawTokens:Math.round(Le.raw/4),optimized:$.filterId!=null,telemetryOptIn:R.telemetryOptIn,sessionId:process.env.CLAUDE_CODE_SESSION_ID,host:ht})}catch{}let ln=$.output;if($.filteredBytes<$.rawBytes)try{ln=new RegExp(kr.source,"m").test($.output)?await Ps(C,$.output):await Os($.droppedTail??null,$.output)}catch{}return{stdout:ln+X,stderr:cn,code:b,filterId:$.filterId,rawBytes:$.rawBytes+pt,filteredBytes:$.filteredBytes+mt,truncated:p}}catch{return sn()}finally{Cs()}}function Ns(t=process.stdout,e=n=>process.exit(n)){t.on("error",n=>{if(n.code==="EPIPE"){e(141);return}throw n})}Ns();async function su(t){let[e,...n]=t;e||process.exit(2);let r=(0,Ms.default)(e,n,{stdio:"inherit"}),s=await new Promise(i=>{r.on("error",()=>i(127)),r.on("close",(o,a)=>i(o??(a?128+rn(a):0)))});process.exit(s)}async function iu(){let t=process.argv.slice(2);t.length===0&&(process.stderr.write(`tkr-exec: missing command
35
- `),process.exit(2));let e;try{e=await Ds(t)}catch(n){return process.stderr.write(`tkr-exec: ${n.message??n}
36
- `),su(t)}e.stdout&&process.stdout.write(e.stdout),e.stderr&&process.stderr.write(e.stderr),process.exitCode=e.code}iu().catch(t=>{process.stderr.write(`${t.message??t}
43
+ `,{mode:384}),Qc(o,r)}}catch{}}var vs=[{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"]}],nm=[...vs.map(t=>t.host),"shell"],ou=new Set(["claude-code","codex"]);function xs(t){return null}function Es(t=process.env){let e=process.platform,r=e==="darwin"||e==="linux"||e==="win32"?e:"other",n=process.arch;for(let s of vs)if(s.vars.some(i=>t[i]))return{host:s.host,source:"env",os:r,arch:n,shimRecommended:!ou.has(s.host)};return{host:"shell",source:"fallback",os:r,arch:n,shimRecommended:!0}}import{delimiter as ws,join as au,dirname as am}from"node:path";function cu(){return au(R(),"shims")}function ks(){let t=cu(),e={...process.env},r=process.platform==="win32"?"Path":"PATH",s=(e[r]??e.PATH??"").split(ws).filter(i=>i&&i!==t);return e[r]=s.join(ws),r==="Path"&&(e.PATH=e[r]),e}import{createConnection as Eu}from"node:net";import{spawn as wu}from"node:child_process";import{existsSync as $s,openSync as Jt,closeSync as Cs,unlinkSync as Qt,writeFileSync as er,mkdirSync as tr,readFileSync as ku,appendFileSync as Su,rmSync as Tu,statSync as Ru}from"node:fs";import{dirname as Au,join as rr}from"node:path";import{fileURLToPath as Cu}from"node:url";var uu=h.object({id:h.string().min(1).max(64),op:h.literal("filter"),cmd:h.string().min(1).max(2048),plan:h.enum(["trial","smart","pro"]),allowed:h.array(h.string().min(1).max(64)).max(512).optional(),installId:h.string().min(1).max(64).optional()}),lu=h.object({id:h.string().min(1).max(64),op:h.literal("ping")}),du=h.object({id:h.string().min(1).max(64),op:h.literal("shutdown"),installId:h.string().min(1).max(64)}),fu=h.object({id:h.string().min(1).max(64),op:h.literal("reload"),installId:h.string().min(1).max(64).optional()}),pm=h.discriminatedUnion("op",[uu,lu,du,fu]),mm=h.object({id:h.string(),ok:h.literal(!0),data:h.unknown()}),hm=h.object({id:h.string(),ok:h.literal(!1),err:h.string(),retryAfterMs:h.number().int().nonnegative().optional()}),Ss=h.object({filter:Fe.nullable(),cacheHit:h.boolean().optional()}),yt=`
44
+ `,gm=64*1024;function Wt(t){return JSON.stringify(t)+yt}function*Ts(t){let e=0;for(;;){let r=t.indexOf(yt,e);if(r<0)return;yield t.slice(e,r),e=r+1}}function et(){return`${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import pu from"node:os";import{join as tt}from"node:path";import{existsSync as mu,statSync as hu,lstatSync as Rs,unlinkSync as gu,mkdirSync as yu,chmodSync as _u}from"node:fs";import{createHash as bu}from"node:crypto";var qt=100;function vu(t){let e=bu("sha256").update(R()).digest("hex").slice(0,8),r=tt(pu.tmpdir(),`tkr-${t}-${e}`),n=tt(r,"d.sock");if(Buffer.byteLength(n)>qt)throw new Error("Temporary directory path is too long for IPC");return As(r,t),n}function xu(t,e){try{let r=Rs(t);return r.isDirectory()&&r.uid===e&&(r.mode&63)===0}catch{return!1}}function As(t,e){yu(t,{recursive:!0,mode:448});let r=Rs(t);if(!r.isDirectory()||r.uid!==e)throw new Error("Unsafe IPC directory");_u(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&&xu(e,t)){let s=tt(e,`tokmizer-${t}.sock`);if(Buffer.byteLength(s)<=qt)return{path:s,isPipe:!1}}let r=tt(R(),"run"),n=tt(r,"daemon.sock");return Buffer.byteLength(n)>qt?{path:vu(t),isPipe:!1}:(As(r,t),{path:n,isPipe:!1})}async function Yt(){let{path:t,isPipe:e}=rt();if(e||!mu(t))return;try{if(!hu(t).isSocket())return}catch{return}let r=await import("node:net");if(!await new Promise(s=>{let i=r.createConnection(t),o=a=>{i.removeAllListeners();try{i.destroy()}catch{}s(a)};i.once("connect",()=>o(!0)),i.once("error",a=>{let u=a.code;o(u!=="ECONNREFUSED"&&u!=="ENOENT")}),setTimeout(()=>o(!0),250)}))try{gu(t)}catch{}}var wm=5*6e4;var Os=500,Iu=3e3,Is=1,$u=6e4,Ou=256*1024;function nr(){return rr(R(),"daemon.spawn.fail")}function sr(){return rr(R(),"daemon.log")}function Nu(){try{let t=Number(ku(nr(),"utf8"));return Number.isFinite(t)&&Date.now()-t<$u}catch{return!1}}function Du(t){try{tr(R(),{recursive:!0});let e=sr();try{Ru(e).size>Ou&&Qt(e)}catch{}Su(e,`${new Date().toISOString()} ${t}
45
+ `)}catch{}}function Pu(t){try{tr(R(),{recursive:!0}),er(nr(),String(Date.now()))}catch{}Du(`spawn failed: ${t.message}`)}function Mu(){try{Tu(nr(),{force:!0})}catch{}}async function _t(t,e){return new Promise((r,n)=>{let s=Eu(t),i=a=>{if(s.removeAllListeners("connect"),s.removeAllListeners("error"),clearTimeout(o),a){try{s.destroy()}catch{}n(a)}else r(s)},o=setTimeout(()=>i(new Error("connect timeout")),e);s.once("connect",()=>i(null)),s.once("error",a=>i(a))})}function Lu(){return process.env.TOKMIZER_DAEMON_BIN?process.env.TOKMIZER_DAEMON_BIN:Cu(new URL("../bin/tkr-daemon.js",import.meta.url))}async function Xt(t,e=3e3){let r=Math.ceil(e/75),n=process.platform==="win32";for(let s=0;s<r;s++){if(n)try{return(await _t(t,75)).destroy(),!0}catch{}else if($s(t))return!0;await new Promise(i=>setTimeout(i,75))}return!1}async function Fu(t){let e=Lu();if(!$s(e))throw new Error(`tkr-daemon binary not found at ${e}`);let{path:r}=rt(),n=process.platform==="win32"?R():Au(r);try{tr(n,{recursive:!0})}catch{}let s=rr(n,"daemon.spawn.lock"),i=null;try{i=Jt(s,"wx"),er(i,String(process.pid))}catch(o){if(o.code==="EEXIST"){if(await Xt(r,5e3))return;try{Qt(s)}catch{}try{i=Jt(s,"wx"),er(i,String(process.pid))}catch(u){if(u.code==="EEXIST"){await Xt(r,5e3);return}throw u}}else throw o}try{let o=null;try{o=Jt(sr(),"a")}catch{}if(wu(process.execPath,[e],{detached:!0,stdio:["ignore","ignore",o??"ignore"],env:{...process.env,TOKMIZER_DAEMON_INSTALL_ID:t}}).unref(),o!==null)try{Cs(o)}catch{}if(!await Xt(r,3e3))throw new Error("tkr-daemon failed to bind socket within 3s")}finally{if(i!==null){try{Cs(i)}catch{}try{Qt(s)}catch{}}}}async function Bu(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:rt(),r=await Vt();try{let n=await _t(e,Os);n.write(Wt({id:et(),op:"shutdown",installId:r})),await new Promise(s=>setTimeout(s,150));try{n.destroy()}catch{}return!0}catch{return!1}}async function ju(t,e){let r=Date.now()+e;for(;Date.now()<r;){try{(await _t(t,250)).destroy()}catch{return!0}await new Promise(n=>setTimeout(n,100))}return!1}async function ir(t={}){let{path:e}=t.socketPath?{path:t.socketPath}:rt(),r=await Vt(),n=null,s=0,i=!1;for(;s<=Is;)try{n=await _t(e,Os),Mu();break}catch{if(s+=1,s>Is)throw new Error(`tkr-daemon unreachable at ${e}`);if(Nu())throw new Error(`tkr-daemon spawn on cooldown (see ${sr()})`);await Yt();try{await Fu(r),i=!0}catch(l){throw Pu(l),l}}if(!n)throw new Error("tkr-daemon: socket setup failed");let o=new Map,a="";n.setEncoding("utf8"),n.on("data",l=>{a+=l;let f=-1;for(let m=0;m<a.length;m++)a[m]===yt&&(f=m);if(f<0)return;let d=[];for(let m of Ts(a.slice(0,f+1)))d.push(m);a=a.slice(f+1);for(let m of d)if(m)try{let _=JSON.parse(m),x=o.get(_.id);if(!x)continue;clearTimeout(x.timer),o.delete(_.id),x.resolve(_)}catch{}}),n.on("close",()=>{for(let l of o.values())clearTimeout(l.timer),l.reject(new Error("daemon socket closed"));o.clear()}),n.on("error",()=>{});function u(l){return new Promise((f,d)=>{let m=setTimeout(()=>{o.delete(l.id),d(new Error(`daemon request timeout (${l.op})`))},Iu);o.set(l.id,{resolve:f,reject:d,timer:m}),n.write(Wt(l))})}let c={filter:async(l,f,d)=>{let m=await u({id:et(),op:"filter",cmd:l.slice(0,2048),plan:f,...d&&d.length>0?{allowed:d.slice(0,512)}:{},installId:r});if(!m.ok)return null;let _=Ss.safeParse(m.data);return _.success?_.data.filter:null},ping:async()=>{let l=await u({id:et(),op:"ping"});if(!l.ok)throw new Error(l.err);return l.data},reload:async()=>{let l=await u({id:et(),op:"reload",installId:r});if(!l.ok)throw new Error(l.err);return l.data},close:()=>{try{n.end()}catch{}}};if(!t.skipVersionCheck&&!i){let l=!1;try{l=(await c.ping()).version!==Gt}catch{}if(l){try{await Bu(t.socketPath?{socketPath:t.socketPath}:{})}catch{}c.close();let f=await ju(e,2e3);if(await Yt(),!f)throw new Error("stale daemon still running after shutdown request");return ir({...t,skipVersionCheck:!0})}}return c}import{createPublicKey as Yu,verify as Ju}from"node:crypto";import{createCipheriv as Fm,createDecipheriv as zu,hkdfSync as Zu,randomBytes as Bm}from"node:crypto";var Uu=Buffer.from("tokmizer-bundle-enc-v1"),Hu=Buffer.from("rules-bundle");function Vu(t){return Buffer.from(Zu("sha256",Buffer.from(t,"utf8"),Uu,Hu,32))}function Ns(t,e){let r=Vu(e),n=Buffer.from(t,"base64url"),s=n.subarray(0,12),i=n.subarray(12,28),o=n.subarray(28),a=zu("aes-256-gcm",r,s);return a.setAuthTag(i),Buffer.concat([a.update(o),a.final()]).toString("utf8")}import{chmodSync as Zm,readFileSync as Gu,writeFileSync as Um,mkdirSync as Hm,renameSync as Vm}from"node:fs";import{join as Ku}from"node:path";var Wu=h.object({payload:h.string().min(1),signature:h.string().min(1),enc:h.literal("v1"),fetchedAt:h.number().int().nonnegative()});function qu(){return Ku(R(),"bundle-cache.json")}function Ds(){try{let t=Gu(qu(),"utf8"),e=Wu.safeParse(JSON.parse(t));return e.success?e.data:null}catch{return null}}var Xu=h.object({bundleVersion:h.number().int().nonnegative(),signedAt:h.number().int(),filters:h.array(Fe)}),ih=h.object({payload:h.string().min(1),signature:h.string().min(1),enc:h.literal("v1")}),Qu=10080*60*1e3;function el(){let t=Number(process.env.TOKMIZER_MAX_BUNDLE_AGE_MS);return Number.isFinite(t)&&t>0?t:Qu}function tl(t,e){let r=ns();if(!r||!r.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 n=Yu({key:r,format:"pem"});if(!Ju(null,Buffer.from(t.payload,"utf8"),n,Buffer.from(t.signature,"base64url")))throw new Error("tkr-daemon: rules bundle signature invalid");return JSON.parse(Ns(t.payload,e))}function rl(t,e){let r=tl(t,e),n=Xu.parse(r);if(Date.now()-n.signedAt>el())throw new Error("tkr-daemon: rules bundle is stale");let s=new Map;for(let i of n.filters)s.set(i.slug,{...i,matchRegex:new RegExp(i.match_command)});return Sn(),{bundleVersion:n.bundleVersion,signedAt:n.signedAt,ruleCount:s.size,startedAt:Date.now(),fetchedAt:Date.now(),selectFor:(i,o,a)=>dt(i,s.values(),a&&a.length>0?new Set(a):null)}}async function Ps(){try{let t=Ds();if(!t)return null;let e=await Je();return e?.signingSecret?rl(t,e.signingSecret):null}catch{return null}}var ze=null,nt=null;async function nl(){if(ze)return ze;if(nt)return nt;let t=ir().then(e=>{if(nt===t)return ze=e,e;try{e.close()}catch{}return null}).catch(()=>null);return nt=t,t}var or=null,ar=!1;async function sl(){return ar||(ar=!0,or=await Ps()),or}async function Ms(t,e,r){let n=await sl();if(!n)return null;let s=n.selectFor(t,e,[...r]);return!s||!r.has(V(s.slug))?null:s}function il(t){return t?{...t,matchRegex:new RegExp(t.match_command)}:null}function Ls(t){Zt(async(e,r)=>{let n=t==="free"?"trial":t,s=r??lt(void 0),i=await nl();if(!i)return Ms(e,n,s);try{let o=await i.filter(e,n,[...s]);return!o||!s.has(V(o.slug))?null:il(o)}catch{return Ms(e,n,s)}})}function Fs(){if(Zt(null),ze)try{ze.close()}catch{}ze=null,nt=null,or=null,ar=!1}import{chmod as cl,mkdir as ul,readFile as yh,writeFile as ll,stat as _h,readdir as bh,rm as Bs,rename as dl}from"node:fs/promises";import{createHash as js}from"node:crypto";import{readFileSync as ol}from"node:fs";import{join as al}from"node:path";function oe(){try{return ol(al(R(),"yolo-mode"),"utf8")==="on"}catch{return!1}}var wh=10080*60*1e3,kh=100*1024*1024,fl=2*1024*1024,pl=/^[0-9a-f]{8,64}$/i;function ml(t,e){let r=Number(process.env[t]);return Number.isFinite(r)&&r>0?r:e}async function zs(t,e){if(oe()||!pl.test(t)||Buffer.byteLength(e,"utf8")>ml("TOKMIZER_CCR_ENTRY_MAX_BYTES",fl))return!1;let r=Jn(t),n=`${r}.tmp-${process.pid}-${process.hrtime.bigint()}`;try{return await ul(Ht(),{recursive:!0}),oe()?!1:(await ll(n,e,{mode:384}),await cl(n,384),oe()?(await Bs(n,{force:!0}),!1):(await dl(n,r),!0))}catch{try{await Bs(n)}catch{}return!1}}async function Zs(t,e){let r=process.env.TOKMIZER_CCR_DISABLED;if(r==="1"||r==="true"||oe()||!t)return e;let n=js("sha256").update(t).digest("hex").slice(0,16),s=`
46
+ [tkr restore ${n}]`;return Buffer.byteLength(t,"utf8")<=Buffer.byteLength(s,"utf8")||!await zs(n,t)?e:`${e}${s}`}async function Us(t,e){let r=process.env.TOKMIZER_CCR_DISABLED;if(r==="1"||r==="true"||oe()||!t)return e;let n=js("sha256").update(t).digest("hex").slice(0,16);return await zs(n,t)?`${e}
47
+ [tkr restore ${n}]`:e}var Ze=10*1024*1024,El=1024,wl=6e4;function Hs(t,e){let r=new xl("utf8"),n=r.write(Buffer.concat(t));return e?n:n+r.end()}function kl(){try{let t=process.env.TOKMIZER_TKR_BIN||vl(new URL("../bin/tkr.js",import.meta.url));if(!hl(t))return;let e=bl(R(),"enroll-kick");try{let n=Number(gl(e,"utf8"));if(Number.isFinite(n)&&Date.now()-n<wl)return}catch{}_l(R(),{recursive:!0}),yl(e,String(Date.now())),(0,cr.default)(process.execPath,[t,"heartbeat"],{detached:!0,stdio:"ignore"}).unref()}catch{}}function Sl(t){let e=Number(t.TOKMIZER_EXEC_TIMEOUT_MS);if(Number.isFinite(e)&&e>0)return e;let r=Number(t.BASH_MAX_TIMEOUT_MS);return Number.isFinite(r)&&r>6e5?r:6e5}var Tl=Sl(process.env),Rl={SIGHUP:1,SIGINT:2,SIGQUIT:3,SIGILL:4,SIGTRAP:5,SIGABRT:6,SIGBUS:7,SIGFPE:8,SIGKILL:9,SIGUSR1:10,SIGSEGV:11,SIGUSR2:12,SIGPIPE:13,SIGALRM:14,SIGTERM:15};function ur(t){return Rl[t]??15}async function Vs(t){let[e,...r]=t;if(!e)throw new Error("tkr-exec: missing command");let n=oe(),s=(0,cr.default)(e,r,{stdio:["inherit","pipe","pipe"],env:ks()}),i=!1;s.on("spawn",()=>{i=!0});let o=w=>{try{s.kill(w)}catch{}},a=()=>o("SIGINT"),u=()=>o("SIGTERM");process.on("SIGINT",a),process.on("SIGTERM",u);let c=[],l=[],f=0,d=0,m=!1,_=!1;s.stdout?.on("data",w=>{if(f>=Ze){m=!0;return}let C=Ze-f,$=w.length>C?w.subarray(0,C):w;c.push($),f+=$.length,w.length>C&&(m=!0)}),s.stderr?.on("data",w=>{if(d>=Ze){_=!0;return}let C=Ze-d,$=w.length>C?w.subarray(0,C):w;l.push($),d+=$.length,w.length>C&&(_=!0)});let x,A;try{A=await new Promise((w,C)=>{s.on("error",$=>{x&&clearTimeout(x),i?w(1):C($)}),s.on("close",($,Te)=>{x&&clearTimeout(x),w($??(Te?128+ur(Te):0))}),x=setTimeout(()=>{s.kill("SIGTERM"),setTimeout(()=>s.kill("SIGKILL"),2e3)},Tl),x.unref?.()})}finally{process.off("SIGINT",a),process.off("SIGTERM",u)}let I=Hs(c,m),P=Hs(l,_),ae=m?`
48
+ \u2026 (output truncated at ${Ze/(1024*1024)}MB)`:"",U=_?`
49
+ \u2026 (stderr truncated at ${Ze/(1024*1024)}MB)`:"",ce=()=>{let w=I+ae,C=Buffer.byteLength(w,"utf8");return{stdout:w,stderr:P+U,code:A,filterId:null,rawBytes:C,filteredBytes:C,truncated:m}};try{let w=await Je();w||kl();let C=await Qe();if(!C.enabled)return ce();let $=process.env.CLAUDE_CODE_SESSION_ID;$&&w?.token&&bs($,{tool:"Bash",target:t.join(" "),...A!==0?{fail:1}:{}});let Te=w?Qn(w):null,Re=w?lt(w.allowedFilters,Xn(w)):null,lr=new Set(C.filters.disabled.map(V)),dr=Re&&lr.size>0?new Set([...Re].filter(Ve=>!lr.has(Ve))):Re,Ue=t.join(" ");w&&Ls(Te);let D=await Ut(Ue,I,dr,{verbosity:C.outputVerbosity,yolo:n,exitCode:A}),fr=P,pr=0,mr=0;if((n||A===0)&&Buffer.byteLength(P,"utf8")>=(n?1:El)){let Ve=await Ut(Ue,P,dr,{verbosity:C.outputVerbosity,yolo:n,exitCode:A});fr=Ve.output,pr=Ve.rawBytes,mr=Ve.filteredBytes}let hr=D.output;if(!n&&D.filteredBytes<D.rawBytes)try{hr=new RegExp($n.source,"m").test(D.output)?await Us(I,D.output):await Zs(D.droppedTail??null,D.output)}catch{}let gr=hr+ae,yr=fr+U,bt=Es().host,He=gs(D.rawBytes+Buffer.byteLength(P,"utf8"),Buffer.byteLength(gr,"utf8")+Buffer.byteLength(yr,"utf8"),xs(bt));try{hs(He.raw,He.filtered,void 0,!1,bt,"sh",ms(Ue)),await us({cmd:Ue,filterId:D.filterId,rawBytes:D.rawBytes,filteredBytes:D.filteredBytes,plan:Te}),await cs({cmd:Ue,tokensSaved:Math.max(0,Math.round((He.raw-He.filtered)/4)),rawTokens:Math.round(He.raw/4),optimized:D.filterId!=null,telemetryOptIn:C.telemetryOptIn,sessionId:process.env.CLAUDE_CODE_SESSION_ID,host:bt})}catch{}return{stdout:gr,stderr:yr,code:A,filterId:D.filterId,rawBytes:D.rawBytes+pr,filteredBytes:D.filteredBytes+mr,truncated:m}}catch{return ce()}finally{Fs()}}function Gs(t=process.stdout,e=r=>process.exit(r)){t.on("error",r=>{if(r.code==="EPIPE"){e(141);return}throw r})}Gs();async function Al(t){let[e,...r]=t;e||process.exit(2);let n=(0,Ks.default)(e,r,{stdio:"inherit"}),s=await new Promise(i=>{n.on("error",()=>i(127)),n.on("close",(o,a)=>i(o??(a?128+ur(a):0)))});process.exit(s)}async function Cl(){let t=process.argv.slice(2);t.length===0&&(process.stderr.write(`tkr-exec: missing command
50
+ `),process.exit(2));let e;try{e=await Vs(t)}catch(r){return process.stderr.write(`tkr-exec: ${r.message??r}
51
+ `),Al(t)}e.stdout&&process.stdout.write(e.stdout),e.stderr&&process.stderr.write(e.stderr),process.exitCode=e.code}Cl().catch(t=>{process.stderr.write(`${t.message??t}
37
52
  `),process.exit(1)});