@tokmizer/plugin 0.9.51 → 0.9.53

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