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