@wispbit/local 1.0.35 → 1.0.36
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/cli-bundle.js +1 -1
- package/package.json +1 -1
package/cli-bundle.js
CHANGED
|
@@ -37,7 +37,7 @@ ${s}`),e.description!==!1){let{description:u}=e;u&&(u=s?Na(`
|
|
|
37
37
|
${u}
|
|
38
38
|
`,e.helpIndent):`
|
|
39
39
|
${u}`,s=`${u}${s}`)}s+=`
|
|
40
|
-
`;let n=u=>{console.log(s),Ma.exit(typeof u=="number"?u:2)},a=()=>{console.log(e.version),Ma.exit(0)};i._.length===0&&e.argv.length===1&&(i.version===!0&&e.autoVersion?a():i.help===!0&&e.autoHelp&&n(0));let o=i._;delete i._,e.allowUnknownFlags||Uf(o);let c=xf(i,{exclude:["--",/^\w$/]}),l={...c};Bf(c,e);for(let u of Object.values(e.flags)){if(Array.isArray(u.aliases))for(let p of u.aliases)delete c[p];delete c[u.shortFlag]}return Gf(e.flags,c,o),{input:o,flags:c,unnormalizedFlags:l,pkg:t,help:s,showHelp:n,showVersion:a}},qf=(t,e={})=>{let r=Mf(t,e),i=kf(r),s=h1(r,i);return Ma.title=s.pkg.bin?Object.keys(s.pkg.bin).at(0):s.pkg.name,s};var by=We(ic(),1);var kd=We(Dd(),1);var l_=Object.prototype.toString,u_=t=>l_.call(t)==="[object Error]",f_=new Set(["network error","Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Load failed","Network request failed","fetch failed","terminated"]);function sc(t){return t&&u_(t)&&t.name==="TypeError"&&typeof t.message=="string"?t.message==="Load failed"?t.stack===void 0:f_.has(t.message):!1}var nc=class extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}},Md=(t,e,r)=>{let i=r.retries-(e-1);return t.attemptNumber=e,t.retriesLeft=i,t};async function oc(t,e){return new Promise((r,i)=>{e={...e},e.onFailedAttempt??=()=>{},e.shouldRetry??=()=>!0,e.retries??=10;let s=kd.default.operation(e),n=()=>{s.stop(),i(e.signal?.reason)};e.signal&&!e.signal.aborted&&e.signal.addEventListener("abort",n,{once:!0});let a=()=>{e.signal?.removeEventListener("abort",n),s.stop()};s.attempt(async o=>{try{let c=await t(o);a(),r(c)}catch(c){try{if(!(c instanceof Error))throw new TypeError(`Non-error was thrown: "${c}". You should only throw errors.`);if(c instanceof nc)throw c.originalError;if(c instanceof TypeError&&!sc(c))throw c;if(Md(c,o,e),await e.shouldRetry(c)||(s.stop(),i(c)),await e.onFailedAttempt(c),!s.retry(c))throw s.mainError()}catch(l){Md(l,o,e),a(),i(l)}}})})}var P={};Do(P,{BRAND:()=>M_,DIRTY:()=>lr,EMPTY_PATH:()=>m_,INVALID:()=>Q,NEVER:()=>xS,OK:()=>Ne,ParseStatus:()=>$e,Schema:()=>ae,ZodAny:()=>Wt,ZodArray:()=>Pt,ZodBigInt:()=>fr,ZodBoolean:()=>hr,ZodBranded:()=>Ji,ZodCatch:()=>_r,ZodDate:()=>dr,ZodDefault:()=>Er,ZodDiscriminatedUnion:()=>dn,ZodEffects:()=>it,ZodEnum:()=>wr,ZodError:()=>Ve,ZodFirstPartyTypeKind:()=>te,ZodFunction:()=>mn,ZodIntersection:()=>yr,ZodIssueCode:()=>N,ZodLazy:()=>br,ZodLiteral:()=>vr,ZodMap:()=>ti,ZodNaN:()=>ii,ZodNativeEnum:()=>xr,ZodNever:()=>dt,ZodNull:()=>mr,ZodNullable:()=>Et,ZodNumber:()=>ur,ZodObject:()=>He,ZodOptional:()=>tt,ZodParsedType:()=>U,ZodPipeline:()=>Qi,ZodPromise:()=>Vt,ZodReadonly:()=>Sr,ZodRecord:()=>pn,ZodSchema:()=>ae,ZodSet:()=>ri,ZodString:()=>zt,ZodSymbol:()=>Qr,ZodTransformer:()=>it,ZodTuple:()=>xt,ZodType:()=>ae,ZodUndefined:()=>pr,ZodUnion:()=>gr,ZodUnknown:()=>Tt,ZodVoid:()=>ei,addIssueToContext:()=>B,any:()=>V_,array:()=>X_,bigint:()=>U_,boolean:()=>Yd,coerce:()=>wS,custom:()=>Vd,date:()=>G_,datetimeRegex:()=>zd,defaultErrorMap:()=>Ot,discriminatedUnion:()=>eS,effect:()=>hS,enum:()=>lS,function:()=>oS,getErrorMap:()=>Xr,getParsedType:()=>wt,instanceof:()=>j_,intersection:()=>tS,isAborted:()=>fn,isAsync:()=>Zr,isDirty:()=>hn,isValid:()=>qt,late:()=>k_,lazy:()=>aS,literal:()=>cS,makeIssue:()=>Zi,map:()=>sS,nan:()=>B_,nativeEnum:()=>uS,never:()=>K_,null:()=>W_,nullable:()=>pS,number:()=>Kd,object:()=>Z_,objectUtil:()=>ac,oboolean:()=>vS,onumber:()=>bS,optional:()=>dS,ostring:()=>yS,pipeline:()=>gS,preprocess:()=>mS,promise:()=>fS,quotelessJson:()=>h_,record:()=>iS,set:()=>nS,setErrorMap:()=>p_,strictObject:()=>J_,string:()=>Hd,symbol:()=>q_,transformer:()=>hS,tuple:()=>rS,undefined:()=>z_,union:()=>Q_,unknown:()=>H_,util:()=>ce,void:()=>Y_});var ce;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{let n={};for(let a of s)n[a]=a;return n},t.getValidEnumValues=s=>{let n=t.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(let o of n)a[o]=s[o];return t.objectValues(a)},t.objectValues=s=>t.objectKeys(s).map(function(n){return s[n]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let n=[];for(let a in s)Object.prototype.hasOwnProperty.call(s,a)&&n.push(a);return n},t.find=(s,n)=>{for(let a of s)if(n(a))return a},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function i(s,n=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(n)}t.joinValues=i,t.jsonStringifyReplacer=(s,n)=>typeof n=="bigint"?n.toString():n})(ce||(ce={}));var ac;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(ac||(ac={}));var U=ce.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),wt=t=>{switch(typeof t){case"undefined":return U.undefined;case"string":return U.string;case"number":return Number.isNaN(t)?U.nan:U.number;case"boolean":return U.boolean;case"function":return U.function;case"bigint":return U.bigint;case"symbol":return U.symbol;case"object":return Array.isArray(t)?U.array:t===null?U.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?U.promise:typeof Map<"u"&&t instanceof Map?U.map:typeof Set<"u"&&t instanceof Set?U.set:typeof Date<"u"&&t instanceof Date?U.date:U.object;default:return U.unknown}};var N=ce.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"]),h_=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Ve=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};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(n){return n.message},i={_errors:[]},s=n=>{for(let a of n.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)i._errors.push(r(a));else{let o=i,c=0;for(;c<a.path.length;){let l=a.path[c];c===a.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(a))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),i}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,ce.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},i=[];for(let s of this.issues)if(s.path.length>0){let n=s.path[0];r[n]=r[n]||[],r[n].push(e(s))}else i.push(e(s));return{formErrors:i,fieldErrors:r}}get formErrors(){return this.flatten()}};Ve.create=t=>new Ve(t);var d_=(t,e)=>{let r;switch(t.code){case N.invalid_type:t.received===U.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case N.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,ce.jsonStringifyReplacer)}`;break;case N.unrecognized_keys:r=`Unrecognized key(s) in object: ${ce.joinValues(t.keys,", ")}`;break;case N.invalid_union:r="Invalid input";break;case N.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${ce.joinValues(t.options)}`;break;case N.invalid_enum_value:r=`Invalid enum value. Expected ${ce.joinValues(t.options)}, received '${t.received}'`;break;case N.invalid_arguments:r="Invalid function arguments";break;case N.invalid_return_type:r="Invalid function return type";break;case N.invalid_date:r="Invalid date";break;case N.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}"`:ce.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case N.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 N.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 N.custom:r="Invalid input";break;case N.invalid_intersection_types:r="Intersection results could not be merged";break;case N.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case N.not_finite:r="Number must be finite";break;default:r=e.defaultError,ce.assertNever(t)}return{message:r}},Ot=d_;var jd=Ot;function p_(t){jd=t}function Xr(){return jd}var Zi=t=>{let{data:e,path:r,errorMaps:i,issueData:s}=t,n=[...r,...s.path||[]],a={...s,path:n};if(s.message!==void 0)return{...s,path:n,message:s.message};let o="",c=i.filter(l=>!!l).slice().reverse();for(let l of c)o=l(a,{data:e,defaultError:o}).message;return{...s,path:n,message:o}},m_=[];function B(t,e){let r=Xr(),i=Zi({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Ot?void 0:Ot].filter(s=>!!s)});t.common.issues.push(i)}var $e=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 i=[];for(let s of r){if(s.status==="aborted")return Q;s.status==="dirty"&&e.dirty(),i.push(s.value)}return{status:e.value,value:i}}static async mergeObjectAsync(e,r){let i=[];for(let s of r){let n=await s.key,a=await s.value;i.push({key:n,value:a})}return t.mergeObjectSync(e,i)}static mergeObjectSync(e,r){let i={};for(let s of r){let{key:n,value:a}=s;if(n.status==="aborted"||a.status==="aborted")return Q;n.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),n.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(i[n.value]=a.value)}return{status:e.value,value:i}}},Q=Object.freeze({status:"aborted"}),lr=t=>({status:"dirty",value:t}),Ne=t=>({status:"valid",value:t}),fn=t=>t.status==="aborted",hn=t=>t.status==="dirty",qt=t=>t.status==="valid",Zr=t=>typeof Promise<"u"&&t instanceof Promise;var K;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(K||(K={}));var rt=class{constructor(e,r,i,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=i,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}},Bd=(t,e)=>{if(qt(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 Ve(t.common.issues);return this._error=r,this._error}}};function ne(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:i,description:s}=t;if(e&&(r||i))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:(a,o)=>{let{message:c}=t;return a.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??i??o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:c??r??o.defaultError}},description:s}}var ae=class{get description(){return this._def.description}_getType(e){return wt(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:wt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new $e,ctx:{common:e.parent.common,data:e.data,parsedType:wt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Zr(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 i=this.safeParse(e,r);if(i.success)return i.data;throw i.error}safeParse(e,r){let i={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:wt(e)},s=this._parseSync({data:e,path:i.path,parent:i});return Bd(i,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:wt(e)};if(!this["~standard"].async)try{let i=this._parseSync({data:e,path:[],parent:r});return qt(i)?{value:i.value}:{issues:r.common.issues}}catch(i){i?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(i=>qt(i)?{value:i.value}:{issues:r.common.issues})}async parseAsync(e,r){let i=await this.safeParseAsync(e,r);if(i.success)return i.data;throw i.error}async safeParseAsync(e,r){let i={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:wt(e)},s=this._parse({data:e,path:i.path,parent:i}),n=await(Zr(s)?s:Promise.resolve(s));return Bd(i,n)}refine(e,r){let i=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,n)=>{let a=e(s),o=()=>n.addIssue({code:N.custom,...i(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,r){return this._refinement((i,s)=>e(i)?!0:(s.addIssue(typeof r=="function"?r(i,s):r),!1))}_refinement(e){return new it({schema:this,typeName:te.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 tt.create(this,this._def)}nullable(){return Et.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Pt.create(this)}promise(){return Vt.create(this,this._def)}or(e){return gr.create([this,e],this._def)}and(e){return yr.create(this,e,this._def)}transform(e){return new it({...ne(this._def),schema:this,typeName:te.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Er({...ne(this._def),innerType:this,defaultValue:r,typeName:te.ZodDefault})}brand(){return new Ji({typeName:te.ZodBranded,type:this,...ne(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new _r({...ne(this._def),innerType:this,catchValue:r,typeName:te.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Qi.create(this,e)}readonly(){return Sr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},g_=/^c[^\s-]{8,}$/i,y_=/^[0-9a-z]+$/,b_=/^[0-9A-HJKMNP-TV-Z]{26}$/i,v_=/^[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,w_=/^[a-z0-9_-]{21}$/i,x_=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,E_=/^[-+]?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)?)??$/,__=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,S_="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",cc,R_=/^(?:(?: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])$/,A_=/^(?:(?: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])$/,C_=/^(([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]))$/,L_=/^(([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])$/,O_=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,$_=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Gd="((\\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])))",T_=new RegExp(`^${Gd}$`);function qd(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 P_(t){return new RegExp(`^${qd(t)}$`)}function zd(t){let e=`${Gd}T${qd(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 I_(t,e){return!!((e==="v4"||!e)&&R_.test(t)||(e==="v6"||!e)&&C_.test(t))}function F_(t,e){if(!x_.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let i=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(i));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function N_(t,e){return!!((e==="v4"||!e)&&A_.test(t)||(e==="v6"||!e)&&L_.test(t))}var zt=class t extends ae{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==U.string){let n=this._getOrReturnCtx(e);return B(n,{code:N.invalid_type,expected:U.string,received:n.parsedType}),Q}let i=new $e,s;for(let n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:N.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),i.dirty());else if(n.kind==="max")e.data.length>n.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:N.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),i.dirty());else if(n.kind==="length"){let a=e.data.length>n.value,o=e.data.length<n.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?B(s,{code:N.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):o&&B(s,{code:N.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),i.dirty())}else if(n.kind==="email")__.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"email",code:N.invalid_string,message:n.message}),i.dirty());else if(n.kind==="emoji")cc||(cc=new RegExp(S_,"u")),cc.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"emoji",code:N.invalid_string,message:n.message}),i.dirty());else if(n.kind==="uuid")v_.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"uuid",code:N.invalid_string,message:n.message}),i.dirty());else if(n.kind==="nanoid")w_.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"nanoid",code:N.invalid_string,message:n.message}),i.dirty());else if(n.kind==="cuid")g_.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"cuid",code:N.invalid_string,message:n.message}),i.dirty());else if(n.kind==="cuid2")y_.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"cuid2",code:N.invalid_string,message:n.message}),i.dirty());else if(n.kind==="ulid")b_.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"ulid",code:N.invalid_string,message:n.message}),i.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),B(s,{validation:"url",code:N.invalid_string,message:n.message}),i.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"regex",code:N.invalid_string,message:n.message}),i.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(s=this._getOrReturnCtx(e,s),B(s,{code:N.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),i.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(s=this._getOrReturnCtx(e,s),B(s,{code:N.invalid_string,validation:{startsWith:n.value},message:n.message}),i.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(s=this._getOrReturnCtx(e,s),B(s,{code:N.invalid_string,validation:{endsWith:n.value},message:n.message}),i.dirty()):n.kind==="datetime"?zd(n).test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{code:N.invalid_string,validation:"datetime",message:n.message}),i.dirty()):n.kind==="date"?T_.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{code:N.invalid_string,validation:"date",message:n.message}),i.dirty()):n.kind==="time"?P_(n).test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{code:N.invalid_string,validation:"time",message:n.message}),i.dirty()):n.kind==="duration"?E_.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"duration",code:N.invalid_string,message:n.message}),i.dirty()):n.kind==="ip"?I_(e.data,n.version)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"ip",code:N.invalid_string,message:n.message}),i.dirty()):n.kind==="jwt"?F_(e.data,n.alg)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"jwt",code:N.invalid_string,message:n.message}),i.dirty()):n.kind==="cidr"?N_(e.data,n.version)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"cidr",code:N.invalid_string,message:n.message}),i.dirty()):n.kind==="base64"?O_.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"base64",code:N.invalid_string,message:n.message}),i.dirty()):n.kind==="base64url"?$_.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"base64url",code:N.invalid_string,message:n.message}),i.dirty()):ce.assertNever(n);return{status:i.value,value:e.data}}_regex(e,r,i){return this.refinement(s=>e.test(s),{validation:r,code:N.invalid_string,...K.errToObj(i)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...K.errToObj(e)})}url(e){return this._addCheck({kind:"url",...K.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...K.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...K.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...K.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...K.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...K.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...K.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...K.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...K.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...K.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...K.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...K.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,...K.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,...K.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...K.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...K.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...K.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...K.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...K.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...K.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...K.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...K.errToObj(r)})}nonempty(e){return this.min(1,K.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}};zt.create=t=>new zt({checks:[],typeName:te.ZodString,coerce:t?.coerce??!1,...ne(t)});function D_(t,e){let r=(t.toString().split(".")[1]||"").length,i=(e.toString().split(".")[1]||"").length,s=r>i?r:i,n=Number.parseInt(t.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return n%a/10**s}var ur=class t extends ae{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)!==U.number){let n=this._getOrReturnCtx(e);return B(n,{code:N.invalid_type,expected:U.number,received:n.parsedType}),Q}let i,s=new $e;for(let n of this._def.checks)n.kind==="int"?ce.isInteger(e.data)||(i=this._getOrReturnCtx(e,i),B(i,{code:N.invalid_type,expected:"integer",received:"float",message:n.message}),s.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(i=this._getOrReturnCtx(e,i),B(i,{code:N.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(i=this._getOrReturnCtx(e,i),B(i,{code:N.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="multipleOf"?D_(e.data,n.value)!==0&&(i=this._getOrReturnCtx(e,i),B(i,{code:N.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(i=this._getOrReturnCtx(e,i),B(i,{code:N.not_finite,message:n.message}),s.dirty()):ce.assertNever(n);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,K.toString(r))}gt(e,r){return this.setLimit("min",e,!1,K.toString(r))}lte(e,r){return this.setLimit("max",e,!0,K.toString(r))}lt(e,r){return this.setLimit("max",e,!1,K.toString(r))}setLimit(e,r,i,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:i,message:K.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:K.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:K.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:K.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:K.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:K.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:K.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:K.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:K.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:K.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"&&ce.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(r===null||i.value>r)&&(r=i.value):i.kind==="max"&&(e===null||i.value<e)&&(e=i.value)}return Number.isFinite(r)&&Number.isFinite(e)}};ur.create=t=>new ur({checks:[],typeName:te.ZodNumber,coerce:t?.coerce||!1,...ne(t)});var fr=class t extends ae{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)!==U.bigint)return this._getInvalidInput(e);let i,s=new $e;for(let n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(i=this._getOrReturnCtx(e,i),B(i,{code:N.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(i=this._getOrReturnCtx(e,i),B(i,{code:N.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(i=this._getOrReturnCtx(e,i),B(i,{code:N.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):ce.assertNever(n);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return B(r,{code:N.invalid_type,expected:U.bigint,received:r.parsedType}),Q}gte(e,r){return this.setLimit("min",e,!0,K.toString(r))}gt(e,r){return this.setLimit("min",e,!1,K.toString(r))}lte(e,r){return this.setLimit("max",e,!0,K.toString(r))}lt(e,r){return this.setLimit("max",e,!1,K.toString(r))}setLimit(e,r,i,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:i,message:K.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:K.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:K.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:K.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:K.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:K.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}};fr.create=t=>new fr({checks:[],typeName:te.ZodBigInt,coerce:t?.coerce??!1,...ne(t)});var hr=class extends ae{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==U.boolean){let i=this._getOrReturnCtx(e);return B(i,{code:N.invalid_type,expected:U.boolean,received:i.parsedType}),Q}return Ne(e.data)}};hr.create=t=>new hr({typeName:te.ZodBoolean,coerce:t?.coerce||!1,...ne(t)});var dr=class t extends ae{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==U.date){let n=this._getOrReturnCtx(e);return B(n,{code:N.invalid_type,expected:U.date,received:n.parsedType}),Q}if(Number.isNaN(e.data.getTime())){let n=this._getOrReturnCtx(e);return B(n,{code:N.invalid_date}),Q}let i=new $e,s;for(let n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:N.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),i.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:N.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),i.dirty()):ce.assertNever(n);return{status:i.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:K.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:K.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}};dr.create=t=>new dr({checks:[],coerce:t?.coerce||!1,typeName:te.ZodDate,...ne(t)});var Qr=class extends ae{_parse(e){if(this._getType(e)!==U.symbol){let i=this._getOrReturnCtx(e);return B(i,{code:N.invalid_type,expected:U.symbol,received:i.parsedType}),Q}return Ne(e.data)}};Qr.create=t=>new Qr({typeName:te.ZodSymbol,...ne(t)});var pr=class extends ae{_parse(e){if(this._getType(e)!==U.undefined){let i=this._getOrReturnCtx(e);return B(i,{code:N.invalid_type,expected:U.undefined,received:i.parsedType}),Q}return Ne(e.data)}};pr.create=t=>new pr({typeName:te.ZodUndefined,...ne(t)});var mr=class extends ae{_parse(e){if(this._getType(e)!==U.null){let i=this._getOrReturnCtx(e);return B(i,{code:N.invalid_type,expected:U.null,received:i.parsedType}),Q}return Ne(e.data)}};mr.create=t=>new mr({typeName:te.ZodNull,...ne(t)});var Wt=class extends ae{constructor(){super(...arguments),this._any=!0}_parse(e){return Ne(e.data)}};Wt.create=t=>new Wt({typeName:te.ZodAny,...ne(t)});var Tt=class extends ae{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ne(e.data)}};Tt.create=t=>new Tt({typeName:te.ZodUnknown,...ne(t)});var dt=class extends ae{_parse(e){let r=this._getOrReturnCtx(e);return B(r,{code:N.invalid_type,expected:U.never,received:r.parsedType}),Q}};dt.create=t=>new dt({typeName:te.ZodNever,...ne(t)});var ei=class extends ae{_parse(e){if(this._getType(e)!==U.undefined){let i=this._getOrReturnCtx(e);return B(i,{code:N.invalid_type,expected:U.void,received:i.parsedType}),Q}return Ne(e.data)}};ei.create=t=>new ei({typeName:te.ZodVoid,...ne(t)});var Pt=class t extends ae{_parse(e){let{ctx:r,status:i}=this._processInputParams(e),s=this._def;if(r.parsedType!==U.array)return B(r,{code:N.invalid_type,expected:U.array,received:r.parsedType}),Q;if(s.exactLength!==null){let a=r.data.length>s.exactLength.value,o=r.data.length<s.exactLength.value;(a||o)&&(B(r,{code:a?N.too_big:N.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),i.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(B(r,{code:N.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),i.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(B(r,{code:N.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),i.dirty()),r.common.async)return Promise.all([...r.data].map((a,o)=>s.type._parseAsync(new rt(r,a,r.path,o)))).then(a=>$e.mergeArray(i,a));let n=[...r.data].map((a,o)=>s.type._parseSync(new rt(r,a,r.path,o)));return $e.mergeArray(i,n)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:K.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:K.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:K.toString(r)}})}nonempty(e){return this.min(1,e)}};Pt.create=(t,e)=>new Pt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:te.ZodArray,...ne(e)});function Jr(t){if(t instanceof He){let e={};for(let r in t.shape){let i=t.shape[r];e[r]=tt.create(Jr(i))}return new He({...t._def,shape:()=>e})}else return t instanceof Pt?new Pt({...t._def,type:Jr(t.element)}):t instanceof tt?tt.create(Jr(t.unwrap())):t instanceof Et?Et.create(Jr(t.unwrap())):t instanceof xt?xt.create(t.items.map(e=>Jr(e))):t}var He=class t extends ae{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=ce.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==U.object){let l=this._getOrReturnCtx(e);return B(l,{code:N.invalid_type,expected:U.object,received:l.parsedType}),Q}let{status:i,ctx:s}=this._processInputParams(e),{shape:n,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof dt&&this._def.unknownKeys==="strip"))for(let l in s.data)a.includes(l)||o.push(l);let c=[];for(let l of a){let u=n[l],p=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new rt(s,p,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof dt){let l=this._def.unknownKeys;if(l==="passthrough")for(let u of o)c.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(l==="strict")o.length>0&&(B(s,{code:N.unrecognized_keys,keys:o}),i.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let u of o){let p=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new rt(s,p,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let u of c){let p=await u.key,b=await u.value;l.push({key:p,value:b,alwaysSet:u.alwaysSet})}return l}).then(l=>$e.mergeObjectSync(i,l)):$e.mergeObjectSync(i,c)}get shape(){return this._def.shape()}strict(e){return K.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,i)=>{let s=this._def.errorMap?.(r,i).message??i.defaultError;return r.code==="unrecognized_keys"?{message:K.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:te.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let i of ce.objectKeys(e))e[i]&&this.shape[i]&&(r[i]=this.shape[i]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let i of ce.objectKeys(this.shape))e[i]||(r[i]=this.shape[i]);return new t({...this._def,shape:()=>r})}deepPartial(){return Jr(this)}partial(e){let r={};for(let i of ce.objectKeys(this.shape)){let s=this.shape[i];e&&!e[i]?r[i]=s:r[i]=s.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let i of ce.objectKeys(this.shape))if(e&&!e[i])r[i]=this.shape[i];else{let n=this.shape[i];for(;n instanceof tt;)n=n._def.innerType;r[i]=n}return new t({...this._def,shape:()=>r})}keyof(){return Wd(ce.objectKeys(this.shape))}};He.create=(t,e)=>new He({shape:()=>t,unknownKeys:"strip",catchall:dt.create(),typeName:te.ZodObject,...ne(e)});He.strictCreate=(t,e)=>new He({shape:()=>t,unknownKeys:"strict",catchall:dt.create(),typeName:te.ZodObject,...ne(e)});He.lazycreate=(t,e)=>new He({shape:t,unknownKeys:"strip",catchall:dt.create(),typeName:te.ZodObject,...ne(e)});var gr=class extends ae{_parse(e){let{ctx:r}=this._processInputParams(e),i=this._def.options;function s(n){for(let o of n)if(o.result.status==="valid")return o.result;for(let o of n)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;let a=n.map(o=>new Ve(o.ctx.common.issues));return B(r,{code:N.invalid_union,unionErrors:a}),Q}if(r.common.async)return Promise.all(i.map(async n=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await n._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(s);{let n,a=[];for(let c of i){let l={...r,common:{...r.common,issues:[]},parent:null},u=c._parseSync({data:r.data,path:r.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!n&&(n={result:u,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(n)return r.common.issues.push(...n.ctx.common.issues),n.result;let o=a.map(c=>new Ve(c));return B(r,{code:N.invalid_union,unionErrors:o}),Q}}get options(){return this._def.options}};gr.create=(t,e)=>new gr({options:t,typeName:te.ZodUnion,...ne(e)});var $t=t=>t instanceof br?$t(t.schema):t instanceof it?$t(t.innerType()):t instanceof vr?[t.value]:t instanceof wr?t.options:t instanceof xr?ce.objectValues(t.enum):t instanceof Er?$t(t._def.innerType):t instanceof pr?[void 0]:t instanceof mr?[null]:t instanceof tt?[void 0,...$t(t.unwrap())]:t instanceof Et?[null,...$t(t.unwrap())]:t instanceof Ji||t instanceof Sr?$t(t.unwrap()):t instanceof _r?$t(t._def.innerType):[],dn=class t extends ae{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==U.object)return B(r,{code:N.invalid_type,expected:U.object,received:r.parsedType}),Q;let i=this.discriminator,s=r.data[i],n=this.optionsMap.get(s);return n?r.common.async?n._parseAsync({data:r.data,path:r.path,parent:r}):n._parseSync({data:r.data,path:r.path,parent:r}):(B(r,{code:N.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[i]}),Q)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,i){let s=new Map;for(let n of r){let a=$t(n.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of a){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,n)}}return new t({typeName:te.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...ne(i)})}};function lc(t,e){let r=wt(t),i=wt(e);if(t===e)return{valid:!0,data:t};if(r===U.object&&i===U.object){let s=ce.objectKeys(e),n=ce.objectKeys(t).filter(o=>s.indexOf(o)!==-1),a={...t,...e};for(let o of n){let c=lc(t[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(r===U.array&&i===U.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let n=0;n<t.length;n++){let a=t[n],o=e[n],c=lc(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===U.date&&i===U.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var yr=class extends ae{_parse(e){let{status:r,ctx:i}=this._processInputParams(e),s=(n,a)=>{if(fn(n)||fn(a))return Q;let o=lc(n.value,a.value);return o.valid?((hn(n)||hn(a))&&r.dirty(),{status:r.value,value:o.data}):(B(i,{code:N.invalid_intersection_types}),Q)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([n,a])=>s(n,a)):s(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}};yr.create=(t,e,r)=>new yr({left:t,right:e,typeName:te.ZodIntersection,...ne(r)});var xt=class t extends ae{_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==U.array)return B(i,{code:N.invalid_type,expected:U.array,received:i.parsedType}),Q;if(i.data.length<this._def.items.length)return B(i,{code:N.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Q;!this._def.rest&&i.data.length>this._def.items.length&&(B(i,{code:N.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let n=[...i.data].map((a,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new rt(i,a,i.path,o)):null}).filter(a=>!!a);return i.common.async?Promise.all(n).then(a=>$e.mergeArray(r,a)):$e.mergeArray(r,n)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};xt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new xt({items:t,typeName:te.ZodTuple,rest:null,...ne(e)})};var pn=class t extends ae{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==U.object)return B(i,{code:N.invalid_type,expected:U.object,received:i.parsedType}),Q;let s=[],n=this._def.keyType,a=this._def.valueType;for(let o in i.data)s.push({key:n._parse(new rt(i,o,i.path,o)),value:a._parse(new rt(i,i.data[o],i.path,o)),alwaysSet:o in i.data});return i.common.async?$e.mergeObjectAsync(r,s):$e.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,i){return r instanceof ae?new t({keyType:e,valueType:r,typeName:te.ZodRecord,...ne(i)}):new t({keyType:zt.create(),valueType:e,typeName:te.ZodRecord,...ne(r)})}},ti=class extends ae{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==U.map)return B(i,{code:N.invalid_type,expected:U.map,received:i.parsedType}),Q;let s=this._def.keyType,n=this._def.valueType,a=[...i.data.entries()].map(([o,c],l)=>({key:s._parse(new rt(i,o,i.path,[l,"key"])),value:n._parse(new rt(i,c,i.path,[l,"value"]))}));if(i.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let c of a){let l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return Q;(l.status==="dirty"||u.status==="dirty")&&r.dirty(),o.set(l.value,u.value)}return{status:r.value,value:o}})}else{let o=new Map;for(let c of a){let l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return Q;(l.status==="dirty"||u.status==="dirty")&&r.dirty(),o.set(l.value,u.value)}return{status:r.value,value:o}}}};ti.create=(t,e,r)=>new ti({valueType:e,keyType:t,typeName:te.ZodMap,...ne(r)});var ri=class t extends ae{_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==U.set)return B(i,{code:N.invalid_type,expected:U.set,received:i.parsedType}),Q;let s=this._def;s.minSize!==null&&i.data.size<s.minSize.value&&(B(i,{code:N.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&i.data.size>s.maxSize.value&&(B(i,{code:N.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let n=this._def.valueType;function a(c){let l=new Set;for(let u of c){if(u.status==="aborted")return Q;u.status==="dirty"&&r.dirty(),l.add(u.value)}return{status:r.value,value:l}}let o=[...i.data.values()].map((c,l)=>n._parse(new rt(i,c,i.path,l)));return i.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,r){return new t({...this._def,minSize:{value:e,message:K.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:K.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};ri.create=(t,e)=>new ri({valueType:t,minSize:null,maxSize:null,typeName:te.ZodSet,...ne(e)});var mn=class t extends ae{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==U.function)return B(r,{code:N.invalid_type,expected:U.function,received:r.parsedType}),Q;function i(o,c){return Zi({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Xr(),Ot].filter(l=>!!l),issueData:{code:N.invalid_arguments,argumentsError:c}})}function s(o,c){return Zi({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Xr(),Ot].filter(l=>!!l),issueData:{code:N.invalid_return_type,returnTypeError:c}})}let n={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof Vt){let o=this;return Ne(async function(...c){let l=new Ve([]),u=await o._def.args.parseAsync(c,n).catch(f=>{throw l.addIssue(i(c,f)),l}),p=await Reflect.apply(a,this,u);return await o._def.returns._def.type.parseAsync(p,n).catch(f=>{throw l.addIssue(s(p,f)),l})})}else{let o=this;return Ne(function(...c){let l=o._def.args.safeParse(c,n);if(!l.success)throw new Ve([i(c,l.error)]);let u=Reflect.apply(a,this,l.data),p=o._def.returns.safeParse(u,n);if(!p.success)throw new Ve([s(u,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:xt.create(e).rest(Tt.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,i){return new t({args:e||xt.create([]).rest(Tt.create()),returns:r||Tt.create(),typeName:te.ZodFunction,...ne(i)})}},br=class extends ae{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})}};br.create=(t,e)=>new br({getter:t,typeName:te.ZodLazy,...ne(e)});var vr=class extends ae{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return B(r,{received:r.data,code:N.invalid_literal,expected:this._def.value}),Q}return{status:"valid",value:e.data}}get value(){return this._def.value}};vr.create=(t,e)=>new vr({value:t,typeName:te.ZodLiteral,...ne(e)});function Wd(t,e){return new wr({values:t,typeName:te.ZodEnum,...ne(e)})}var wr=class t extends ae{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),i=this._def.values;return B(r,{expected:ce.joinValues(i),received:r.parsedType,code:N.invalid_type}),Q}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),i=this._def.values;return B(r,{received:r.data,code:N.invalid_enum_value,options:i}),Q}return Ne(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(i=>!e.includes(i)),{...this._def,...r})}};wr.create=Wd;var xr=class extends ae{_parse(e){let r=ce.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(e);if(i.parsedType!==U.string&&i.parsedType!==U.number){let s=ce.objectValues(r);return B(i,{expected:ce.joinValues(s),received:i.parsedType,code:N.invalid_type}),Q}if(this._cache||(this._cache=new Set(ce.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=ce.objectValues(r);return B(i,{received:i.data,code:N.invalid_enum_value,options:s}),Q}return Ne(e.data)}get enum(){return this._def.values}};xr.create=(t,e)=>new xr({values:t,typeName:te.ZodNativeEnum,...ne(e)});var Vt=class extends ae{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==U.promise&&r.common.async===!1)return B(r,{code:N.invalid_type,expected:U.promise,received:r.parsedType}),Q;let i=r.parsedType===U.promise?r.data:Promise.resolve(r.data);return Ne(i.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Vt.create=(t,e)=>new Vt({type:t,typeName:te.ZodPromise,...ne(e)});var it=class extends ae{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===te.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:i}=this._processInputParams(e),s=this._def.effect||null,n={addIssue:a=>{B(i,a),a.fatal?r.abort():r.dirty()},get path(){return i.path}};if(n.addIssue=n.addIssue.bind(n),s.type==="preprocess"){let a=s.transform(i.data,n);if(i.common.async)return Promise.resolve(a).then(async o=>{if(r.value==="aborted")return Q;let c=await this._def.schema._parseAsync({data:o,path:i.path,parent:i});return c.status==="aborted"?Q:c.status==="dirty"?lr(c.value):r.value==="dirty"?lr(c.value):c});{if(r.value==="aborted")return Q;let o=this._def.schema._parseSync({data:a,path:i.path,parent:i});return o.status==="aborted"?Q:o.status==="dirty"?lr(o.value):r.value==="dirty"?lr(o.value):o}}if(s.type==="refinement"){let a=o=>{let c=s.refinement(o,n);if(i.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(i.common.async===!1){let o=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return o.status==="aborted"?Q:(o.status==="dirty"&&r.dirty(),a(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(o=>o.status==="aborted"?Q:(o.status==="dirty"&&r.dirty(),a(o.value).then(()=>({status:r.value,value:o.value}))))}if(s.type==="transform")if(i.common.async===!1){let a=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!qt(a))return Q;let o=s.transform(a.value,n);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(a=>qt(a)?Promise.resolve(s.transform(a.value,n)).then(o=>({status:r.value,value:o})):Q);ce.assertNever(s)}};it.create=(t,e,r)=>new it({schema:t,typeName:te.ZodEffects,effect:e,...ne(r)});it.createWithPreprocess=(t,e,r)=>new it({schema:e,effect:{type:"preprocess",transform:t},typeName:te.ZodEffects,...ne(r)});var tt=class extends ae{_parse(e){return this._getType(e)===U.undefined?Ne(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};tt.create=(t,e)=>new tt({innerType:t,typeName:te.ZodOptional,...ne(e)});var Et=class extends ae{_parse(e){return this._getType(e)===U.null?Ne(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Et.create=(t,e)=>new Et({innerType:t,typeName:te.ZodNullable,...ne(e)});var Er=class extends ae{_parse(e){let{ctx:r}=this._processInputParams(e),i=r.data;return r.parsedType===U.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Er.create=(t,e)=>new Er({innerType:t,typeName:te.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ne(e)});var _r=class extends ae{_parse(e){let{ctx:r}=this._processInputParams(e),i={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return Zr(s)?s.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Ve(i.common.issues)},input:i.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ve(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}};_r.create=(t,e)=>new _r({innerType:t,typeName:te.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ne(e)});var ii=class extends ae{_parse(e){if(this._getType(e)!==U.nan){let i=this._getOrReturnCtx(e);return B(i,{code:N.invalid_type,expected:U.nan,received:i.parsedType}),Q}return{status:"valid",value:e.data}}};ii.create=t=>new ii({typeName:te.ZodNaN,...ne(t)});var M_=Symbol("zod_brand"),Ji=class extends ae{_parse(e){let{ctx:r}=this._processInputParams(e),i=r.data;return this._def.type._parse({data:i,path:r.path,parent:r})}unwrap(){return this._def.type}},Qi=class t extends ae{_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.common.async)return(async()=>{let n=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?Q:n.status==="dirty"?(r.dirty(),lr(n.value)):this._def.out._parseAsync({data:n.value,path:i.path,parent:i})})();{let s=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return s.status==="aborted"?Q:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:i.path,parent:i})}}static create(e,r){return new t({in:e,out:r,typeName:te.ZodPipeline})}},Sr=class extends ae{_parse(e){let r=this._def.innerType._parse(e),i=s=>(qt(s)&&(s.value=Object.freeze(s.value)),s);return Zr(r)?r.then(s=>i(s)):i(r)}unwrap(){return this._def.innerType}};Sr.create=(t,e)=>new Sr({innerType:t,typeName:te.ZodReadonly,...ne(e)});function Ud(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function Vd(t,e={},r){return t?Wt.create().superRefine((i,s)=>{let n=t(i);if(n instanceof Promise)return n.then(a=>{if(!a){let o=Ud(e,i),c=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:c})}});if(!n){let a=Ud(e,i),o=a.fatal??r??!0;s.addIssue({code:"custom",...a,fatal:o})}}):Wt.create()}var k_={object:He.lazycreate},te;(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"})(te||(te={}));var j_=(t,e={message:`Input not instance of ${t.name}`})=>Vd(r=>r instanceof t,e),Hd=zt.create,Kd=ur.create,B_=ii.create,U_=fr.create,Yd=hr.create,G_=dr.create,q_=Qr.create,z_=pr.create,W_=mr.create,V_=Wt.create,H_=Tt.create,K_=dt.create,Y_=ei.create,X_=Pt.create,Z_=He.create,J_=He.strictCreate,Q_=gr.create,eS=dn.create,tS=yr.create,rS=xt.create,iS=pn.create,sS=ti.create,nS=ri.create,oS=mn.create,aS=br.create,cS=vr.create,lS=wr.create,uS=xr.create,fS=Vt.create,hS=it.create,dS=tt.create,pS=Et.create,mS=it.createWithPreprocess,gS=Qi.create,yS=()=>Hd().optional(),bS=()=>Kd().optional(),vS=()=>Yd().optional(),wS={string:(t=>zt.create({...t,coerce:!0})),number:(t=>ur.create({...t,coerce:!0})),boolean:(t=>hr.create({...t,coerce:!0})),bigint:(t=>fr.create({...t,coerce:!0})),date:(t=>dr.create({...t,coerce:!0}))};var xS=Q;var ES=P.object({repository_url:P.string(),powerlint_version:P.string(),schema_version:P.string()}),_S=P.object({configured:P.boolean(),invalid_api_key:P.boolean().optional(),is_valid_repository:P.boolean().optional(),config:P.object({ignored_globs:P.array(P.string())}).optional()}),SS=P.object({repository_url:P.string(),rule_ids:P.array(P.string()).optional(),schema_version:P.string(),powerlint_version:P.string()}),RS=P.object({rules:P.array(P.object({id:P.string(),internalId:P.string(),internalVersionId:P.string(),message:P.string(),prompt:P.string(),severity:P.enum(["suggestion","violation"]),schema:P.any(),execution:P.enum(["llm","deterministic"]).optional()}))}),AS=P.object({rule:P.object({id:P.string(),versionId:P.string(),contents:P.string(),message:P.string()}),matches:P.array(P.any()),messages:P.array(P.any()),tools:P.array(P.enum(["read","grep","glob"])),files:P.array(P.object({path:P.string(),sha:P.string()})).optional(),schema_version:P.string(),powerlint_version:P.string(),repository_url:P.string(),commit:P.object({sha:P.string(),branch:P.string(),message:P.string(),timestamp:P.string()})}),CS=P.discriminatedUnion("type",[P.object({type:P.literal("tool_request"),tool_calls:P.array(P.any()),usage:P.object({cost:P.string(),inputTokens:P.string(),outputTokens:P.string()})}),P.object({type:P.literal("matches"),matches:P.array(P.any()),usage:P.object({cost:P.string(),inputTokens:P.string(),outputTokens:P.string()}),files:P.array(P.object({path:P.string(),sha:P.string()})).optional()}),P.object({type:P.literal("request_files"),files:P.array(P.object({path:P.string(),sha:P.string()})),usage:P.object({cost:P.string(),inputTokens:P.string(),outputTokens:P.string()})})]),LS=P.object({rule:P.object({id:P.string(),versionId:P.string(),contents:P.string(),message:P.string()}),matches:P.array(P.any()),files:P.array(P.object({path:P.string(),sha:P.string()})).optional(),schema_version:P.string(),powerlint_version:P.string(),repository_url:P.string(),commit:P.object({sha:P.string(),branch:P.string(),message:P.string(),timestamp:P.string()})}),OS=P.object({type:P.literal("matches"),matches:P.array(P.any()),usage:P.object({cost:P.string(),inputTokens:P.string(),outputTokens:P.string()})}),es=class{baseUrl;apiKey;constructor(e){this.baseUrl=e.baseUrl,this.apiKey=e.apiKey}async request(e,r,i){let s=`${this.baseUrl}${e}`,a=await(await oc(async()=>{let o=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify(r)});if(!o.ok){let c=await o.text();throw new Error(`Wispbit API request failed: ${o.status} ${o.statusText} - ${c}`)}return o},{retries:3,minTimeout:1e3,maxTimeout:5e3,onFailedAttempt:o=>{console.warn(`API request to ${e} failed (attempt ${o.attemptNumber}/4): ${o.message}`)}})).json();return i?i.parse(a):a}async initialize(e){let r=ES.parse(e);return await this.request("/plv1/initialize",r,_S)}async getRules(e){let r=SS.parse(e);return await this.request("/plv1/get-rules",r,RS)}async matchLLMSearch(e){let r=AS.parse(e);return await this.request("/plv1/llm-search",r,CS)}async matchLLMValidate(e){let r=LS.parse(e);return await this.request("/plv1/llm-validate",r,OS)}};var gn=class{config;environment;constructor(e,r){this.config=e,this.environment=r}async search(e){let r=this.config.getApiClient(),i=await this.environment.getRepositoryUrl(),s=await this.environment.getCurrentCommit(),n={id:e.rule.internalId,versionId:e.rule.internalVersionId,contents:e.rule.prompt,message:e.rule.config.message};return await r.matchLLMSearch({rule:n,matches:e.matches,messages:e.messages,tools:e.tools,files:e.files,schema_version:this.config.getSchemaVersion(),powerlint_version:this.config.getLocalVersion(),repository_url:i,commit:s})}async validate(e){let r=this.config.getApiClient(),i=await this.environment.getRepositoryUrl(),s=await this.environment.getCurrentCommit(),n={id:e.rule.internalId,versionId:e.rule.internalVersionId,contents:e.rule.prompt,message:e.rule.config.message};return await r.matchLLMValidate({rule:n,matches:e.matches,files:e.files,schema_version:this.config.getSchemaVersion(),powerlint_version:this.config.getLocalVersion(),repository_url:i,commit:s})}};import{readFileSync as UR}from"fs";import{dirname as GR,join as qR}from"path";import{fileURLToPath as zR}from"url";var ts=class extends Error{response;request;options;constructor(e,r,i){let s=e.status||e.status===0?e.status:"",n=e.statusText||"",a=`${s} ${n}`.trim(),o=a?`status code ${a}`:"an unknown error";super(`Request failed with ${o}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=e,this.request=r,this.options=i}};var si=class extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}};var uc=(()=>{let t=!1,e=!1,r=typeof globalThis.ReadableStream=="function",i=typeof globalThis.Request=="function";if(r&&i)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type")}catch(s){if(s instanceof Error&&s.message==="unsupported BodyInit type")return!1;throw s}return t&&!e})(),Xd=typeof globalThis.AbortController=="function",Zd=typeof globalThis.ReadableStream=="function",Jd=typeof globalThis.FormData=="function",yn=["get","post","put","patch","head","delete"],$S=()=>{};$S();var Qd={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},bn=2147483647,ep=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,vn=Symbol("stop"),tp={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},rp={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0};var TS=t=>{if(!t)return 0;if(t instanceof FormData){let e=0;for(let[r,i]of t)e+=ep,e+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,e+=typeof i=="string"?new TextEncoder().encode(i).length:i.size;return e}if(t instanceof Blob)return t.size;if(t instanceof ArrayBuffer)return t.byteLength;if(typeof t=="string")return new TextEncoder().encode(t).length;if(t instanceof URLSearchParams)return new TextEncoder().encode(t.toString()).length;if("byteLength"in t)return t.byteLength;if(typeof t=="object"&&t!==null)try{let e=JSON.stringify(t);return new TextEncoder().encode(e).length}catch{return 0}return 0},ip=(t,e)=>{let r=Number(t.headers.get("content-length"))||0,i=0;return t.status===204?(e&&e({percent:1,totalBytes:r,transferredBytes:i},new Uint8Array),new Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new Response(new ReadableStream({async start(s){let n=t.body.getReader();e&&e({percent:0,transferredBytes:0,totalBytes:r},new Uint8Array);async function a(){let{done:o,value:c}=await n.read();if(o){s.close();return}if(e){i+=c.byteLength;let l=r===0?0:i/r;e({percent:l,transferredBytes:i,totalBytes:r},c)}s.enqueue(c),await a()}await a()}}),{status:t.status,statusText:t.statusText,headers:t.headers})},sp=(t,e)=>{let r=TS(t.body),i=0;return new Request(t,{duplex:"half",body:new ReadableStream({async start(s){let n=t.body instanceof ReadableStream?t.body.getReader():new Response("").body.getReader();async function a(){let{done:o,value:c}=await n.read();if(o){e&&e({percent:1,transferredBytes:i,totalBytes:Math.max(r,i)},new Uint8Array),s.close();return}i+=c.byteLength;let l=r===0?0:i/r;(r<i||l===1)&&(l=.99),e&&e({percent:Number(l.toFixed(2)),transferredBytes:i,totalBytes:r},c),s.enqueue(c),await a()}await a()}})})};var ni=t=>t!==null&&typeof t=="object";var rs=(...t)=>{for(let e of t)if((!ni(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return dc({},...t)},fc=(t={},e={})=>{let r=new globalThis.Headers(t),i=e instanceof globalThis.Headers,s=new globalThis.Headers(e);for(let[n,a]of s.entries())i&&a==="undefined"||a===void 0?r.delete(n):r.set(n,a);return r};function wn(t,e,r){return Object.hasOwn(e,r)&&e[r]===void 0?[]:dc(t[r]??[],e[r]??[])}var hc=(t={},e={})=>({beforeRequest:wn(t,e,"beforeRequest"),beforeRetry:wn(t,e,"beforeRetry"),afterResponse:wn(t,e,"afterResponse"),beforeError:wn(t,e,"beforeError")}),dc=(...t)=>{let e={},r={},i={};for(let s of t)if(Array.isArray(s))Array.isArray(e)||(e=[]),e=[...e,...s];else if(ni(s)){for(let[n,a]of Object.entries(s))ni(a)&&n in e&&(a=dc(e[n],a)),e={...e,[n]:a};ni(s.hooks)&&(i=hc(i,s.hooks),e.hooks=i),ni(s.headers)&&(r=fc(r,s.headers),e.headers=r)}return e};var op=t=>yn.includes(t)?t.toUpperCase():t,PS=["get","put","head","delete","options","trace"],IS=[408,413,429,500,502,503,504],FS=[413,429,503],np={limit:2,methods:PS,statusCodes:IS,afterStatusCodes:FS,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:t=>.3*2**(t-1)*1e3},ap=(t={})=>{if(typeof t=="number")return{...np,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");return{...np,...t}};async function pc(t,e,r,i){return new Promise((s,n)=>{let a=setTimeout(()=>{r&&r.abort(),n(new si(t))},i.timeout);i.fetch(t,e).then(s).catch(n).then(()=>{clearTimeout(a)})})}async function mc(t,{signal:e}){return new Promise((r,i)=>{e&&(e.throwIfAborted(),e.addEventListener("abort",s,{once:!0}));function s(){clearTimeout(n),i(e.reason)}let n=setTimeout(()=>{e?.removeEventListener("abort",s),r()},t)})}var cp=(t,e)=>{let r={};for(let i in e)!(i in rp)&&!(i in tp)&&!(i in t)&&(r[i]=e[i]);return r};var is=class t{static create(e,r){let i=new t(e,r),s=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>bn)throw new RangeError(`The \`timeout\` option cannot be greater than ${bn}`);await Promise.resolve();let o=await i._fetch();for(let c of i._options.hooks.afterResponse){let l=await c(i.request,i._options,i._decorateResponse(o.clone()));l instanceof globalThis.Response&&(o=l)}if(i._decorateResponse(o),!o.ok&&i._options.throwHttpErrors){let c=new ts(o,i.request,i._options);for(let l of i._options.hooks.beforeError)c=await l(c);throw c}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!Zd)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return ip(o.clone(),i._options.onDownloadProgress)}return o},a=(i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(s):s()).finally(async()=>{i.request.bodyUsed||await i.request.body?.cancel()});for(let[o,c]of Object.entries(Qd))a[o]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||c);let l=await a;if(o==="json"){if(l.status===204||(await l.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await l.text())}return l[o]()};return a}request;abortController;_retryCount=0;_input;_options;constructor(e,r={}){if(this._input=e,this._options={...r,headers:fc(this._input.headers,r.headers),hooks:hc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:op(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:ap(r.retry),throwHttpErrors:r.throwHttpErrors!==!1,timeout:r.timeout??1e4,fetch:r.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(Xd){let i=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=i?AbortSignal.any([i,this.abortController.signal]):this.abortController.signal}if(uc&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){let s="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),n=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,s);(Jd&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(n,{...this.request}),this._options)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!uc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=sp(this.request,this._options.onUploadProgress))}}_calculateRetryDelay(e){if(this._retryCount++,this._retryCount>this._options.retry.limit||e instanceof si)throw e;if(e instanceof ts){if(!this._options.retry.statusCodes.includes(e.response.status))throw e;let i=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(i&&this._options.retry.afterStatusCodes.includes(e.response.status)){let s=Number(i)*1e3;Number.isNaN(s)?s=Date.parse(i)-Date.now():s>=Date.parse("2024-01-01")&&(s-=Date.now());let n=this._options.retry.maxRetryAfter??s;return s<n?s:n}if(e.response.status===413)throw e}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(e){return this._options.parseJson&&(e.json=async()=>this._options.parseJson(await e.text())),e}async _retry(e){try{return await e()}catch(r){let i=Math.min(this._calculateRetryDelay(r),bn);if(this._retryCount<1)throw r;await mc(i,{signal:this._options.signal});for(let s of this._options.hooks.beforeRetry)if(await s({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===vn)return;return this._retry(e)}}async _fetch(){for(let i of this._options.hooks.beforeRequest){let s=await i(this.request,this._options);if(s instanceof Request){this.request=s;break}if(s instanceof Response)return s}let e=cp(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,e):pc(r,e,this.abortController,this._options)}};var gc=t=>{let e=(r,i)=>is.create(r,rs(t,i));for(let r of yn)e[r]=(i,s)=>is.create(i,rs(t,s,{method:r}));return e.create=r=>gc(rs(r)),e.extend=r=>(typeof r=="function"&&(r=r(t??{})),gc(rs(t,r))),e.stop=vn,e},NS=gc(),lp=NS;var Pp=We(Tp(),1);function xc(t){let e=(0,Pp.default)("npm",{registry:"https://registry.npmjs.org/"}),r=e[`${t}:registry`]||e.config_registry||e.registry;return r.slice(-1)==="/"?r:`${r}/`}var Am=We(Rm(),1),Cm=We(ic(),1),Fc=class extends Error{constructor(e){super(`Package \`${e}\` could not be found`),this.name="PackageNotFoundError"}},Nc=class extends Error{constructor(e,r){super(`Version \`${r}\` for package \`${e}\` could not be found`),this.name="VersionNotFoundError"}};async function Dc(t,e={}){let{version:r="latest"}=e,{omitDeprecated:i=!0}=e,s=t.split("/")[0],n=e.registryUrl??xc(s),a=new URL(encodeURIComponent(t).replace(/^%40/,"@"),n),o=(0,Am.default)(n.toString(),{recursive:!0}),c={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};e.fullMetadata&&delete c.accept,o&&(c.authorization=`${o.type} ${o.token}`);let l;try{l=await lp(a,{headers:c,keepalive:!0}).json()}catch(p){throw p?.response?.status===404?new Fc(t):p}if(e.allVersions)return l;let u=new Nc(t,r);if(l["dist-tags"][r]){let{time:p}=l;l=l.versions[l["dist-tags"][r]],l.time=p}else if(r){let p=!!l.versions[r];if(i&&!p)for(let[f,d]of Object.entries(l.versions))d.deprecated&&delete l.versions[f];if(!p){let f=Object.keys(l.versions);if(r=Cm.default.maxSatisfying(f,r),!r)throw u}let{time:b}=l;if(l=l.versions[r],l.time=b,!l)throw u}return l}async function Mc(t,e){let{version:r}=await Dc(t.toLowerCase(),e);return r}function Ir(){let t=zR(import.meta.url?import.meta.url:__filename),e=GR(t),r=qR(e,"../package.json");try{let i=UR(r,"utf8");return JSON.parse(i).version}catch{return"0.0.0"}}async function Lm(){try{return await Mc("@wispbit/local")}catch{return Ir()}}var ls=class t{config;apiKey=null;baseUrl=null;apiClient=null;llmProvider=null;constructor(e,r){this.config={...e,ignoredGlobs:e.ignoredGlobs||[]},this.apiKey=e.apiKey||null,this.baseUrl=e.baseUrl||null,this.apiKey&&this.baseUrl&&(this.apiClient=new es({baseUrl:this.baseUrl,apiKey:this.apiKey})),r?.llmProvider&&(this.llmProvider=r.llmProvider)}getIgnoredGlobs(){return this.config.ignoredGlobs||[]}getApiKey(){return this.apiKey}getBaseUrl(){return this.baseUrl}getApiClient(){if(!this.apiClient)throw new Error("API client not initialized. Config must have both apiKey and baseUrl.");return this.apiClient}getLLMProvider(){if(!this.llmProvider)throw new Error("LLM provider not initialized. Use Config.initialize() instead of initializeLocal().");return this.llmProvider}getLocalVersion(){return Ir()}getSchemaVersion(){return"v1"}static initializeLocal(e={}){let r=e.ignoredGlobs||[];return new t({ignoredGlobs:r},{llmProvider:e.llmProvider})}static async initialize(e,{apiKey:r,baseUrl:i}){let s=i||process.env.WISPBIT_API_BASE_URL||"https://api.wispbit.com",n=r||process.env.WISPBIT_API_KEY||null;if(!n)return console.log("No API key found"),{failed:!0,error:"INVALID_API_KEY"};let a=await e.getRepositoryUrl(),c=await new es({baseUrl:s,apiKey:n}).initialize({repository_url:a,powerlint_version:Ir(),schema_version:"v1"});if(c.invalid_api_key)return{failed:!0,error:"INVALID_API_KEY"};if(!c.is_valid_repository)return{failed:!0,error:"INVALID_REPOSITORY"};let l=c.config?.ignored_globs||[],u=new t({ignoredGlobs:l,apiKey:n,baseUrl:s},{});return u.llmProvider=new gn(u,e),u}isConfigured(){return this.getApiKey()!==null}};import{exec as VR,execSync as HR}from"child_process";import{existsSync as KR,readFileSync as YR}from"fs";import{promisify as XR}from"util";import{createHash as WR}from"crypto";function us(t){return WR("sha256").update(t).digest("hex")}var he=XR(VR);function $m(){return HR("git rev-parse --show-toplevel",{encoding:"utf-8"}).trim()}async function Tm(t){let{stdout:e}=await he("git ls-files --ignored --exclude-standard --others",{cwd:t,maxBuffer:52428800});return e.split(`
|
|
40
|
+
`;let n=u=>{console.log(s),Ma.exit(typeof u=="number"?u:2)},a=()=>{console.log(e.version),Ma.exit(0)};i._.length===0&&e.argv.length===1&&(i.version===!0&&e.autoVersion?a():i.help===!0&&e.autoHelp&&n(0));let o=i._;delete i._,e.allowUnknownFlags||Uf(o);let c=xf(i,{exclude:["--",/^\w$/]}),l={...c};Bf(c,e);for(let u of Object.values(e.flags)){if(Array.isArray(u.aliases))for(let p of u.aliases)delete c[p];delete c[u.shortFlag]}return Gf(e.flags,c,o),{input:o,flags:c,unnormalizedFlags:l,pkg:t,help:s,showHelp:n,showVersion:a}},qf=(t,e={})=>{let r=Mf(t,e),i=kf(r),s=h1(r,i);return Ma.title=s.pkg.bin?Object.keys(s.pkg.bin).at(0):s.pkg.name,s};var by=We(ic(),1);var kd=We(Dd(),1);var l_=Object.prototype.toString,u_=t=>l_.call(t)==="[object Error]",f_=new Set(["network error","Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Load failed","Network request failed","fetch failed","terminated"]);function sc(t){return t&&u_(t)&&t.name==="TypeError"&&typeof t.message=="string"?t.message==="Load failed"?t.stack===void 0:f_.has(t.message):!1}var nc=class extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}},Md=(t,e,r)=>{let i=r.retries-(e-1);return t.attemptNumber=e,t.retriesLeft=i,t};async function oc(t,e){return new Promise((r,i)=>{e={...e},e.onFailedAttempt??=()=>{},e.shouldRetry??=()=>!0,e.retries??=10;let s=kd.default.operation(e),n=()=>{s.stop(),i(e.signal?.reason)};e.signal&&!e.signal.aborted&&e.signal.addEventListener("abort",n,{once:!0});let a=()=>{e.signal?.removeEventListener("abort",n),s.stop()};s.attempt(async o=>{try{let c=await t(o);a(),r(c)}catch(c){try{if(!(c instanceof Error))throw new TypeError(`Non-error was thrown: "${c}". You should only throw errors.`);if(c instanceof nc)throw c.originalError;if(c instanceof TypeError&&!sc(c))throw c;if(Md(c,o,e),await e.shouldRetry(c)||(s.stop(),i(c)),await e.onFailedAttempt(c),!s.retry(c))throw s.mainError()}catch(l){Md(l,o,e),a(),i(l)}}})})}var P={};Do(P,{BRAND:()=>M_,DIRTY:()=>lr,EMPTY_PATH:()=>m_,INVALID:()=>Q,NEVER:()=>xS,OK:()=>Ne,ParseStatus:()=>$e,Schema:()=>ae,ZodAny:()=>Wt,ZodArray:()=>Pt,ZodBigInt:()=>fr,ZodBoolean:()=>hr,ZodBranded:()=>Ji,ZodCatch:()=>_r,ZodDate:()=>dr,ZodDefault:()=>Er,ZodDiscriminatedUnion:()=>dn,ZodEffects:()=>it,ZodEnum:()=>wr,ZodError:()=>Ve,ZodFirstPartyTypeKind:()=>te,ZodFunction:()=>mn,ZodIntersection:()=>yr,ZodIssueCode:()=>N,ZodLazy:()=>br,ZodLiteral:()=>vr,ZodMap:()=>ti,ZodNaN:()=>ii,ZodNativeEnum:()=>xr,ZodNever:()=>dt,ZodNull:()=>mr,ZodNullable:()=>Et,ZodNumber:()=>ur,ZodObject:()=>He,ZodOptional:()=>tt,ZodParsedType:()=>U,ZodPipeline:()=>Qi,ZodPromise:()=>Vt,ZodReadonly:()=>Sr,ZodRecord:()=>pn,ZodSchema:()=>ae,ZodSet:()=>ri,ZodString:()=>zt,ZodSymbol:()=>Qr,ZodTransformer:()=>it,ZodTuple:()=>xt,ZodType:()=>ae,ZodUndefined:()=>pr,ZodUnion:()=>gr,ZodUnknown:()=>Tt,ZodVoid:()=>ei,addIssueToContext:()=>B,any:()=>V_,array:()=>X_,bigint:()=>U_,boolean:()=>Yd,coerce:()=>wS,custom:()=>Vd,date:()=>G_,datetimeRegex:()=>zd,defaultErrorMap:()=>Ot,discriminatedUnion:()=>eS,effect:()=>hS,enum:()=>lS,function:()=>oS,getErrorMap:()=>Xr,getParsedType:()=>wt,instanceof:()=>j_,intersection:()=>tS,isAborted:()=>fn,isAsync:()=>Zr,isDirty:()=>hn,isValid:()=>qt,late:()=>k_,lazy:()=>aS,literal:()=>cS,makeIssue:()=>Zi,map:()=>sS,nan:()=>B_,nativeEnum:()=>uS,never:()=>K_,null:()=>W_,nullable:()=>pS,number:()=>Kd,object:()=>Z_,objectUtil:()=>ac,oboolean:()=>vS,onumber:()=>bS,optional:()=>dS,ostring:()=>yS,pipeline:()=>gS,preprocess:()=>mS,promise:()=>fS,quotelessJson:()=>h_,record:()=>iS,set:()=>nS,setErrorMap:()=>p_,strictObject:()=>J_,string:()=>Hd,symbol:()=>q_,transformer:()=>hS,tuple:()=>rS,undefined:()=>z_,union:()=>Q_,unknown:()=>H_,util:()=>ce,void:()=>Y_});var ce;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{let n={};for(let a of s)n[a]=a;return n},t.getValidEnumValues=s=>{let n=t.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),a={};for(let o of n)a[o]=s[o];return t.objectValues(a)},t.objectValues=s=>t.objectKeys(s).map(function(n){return s[n]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let n=[];for(let a in s)Object.prototype.hasOwnProperty.call(s,a)&&n.push(a);return n},t.find=(s,n)=>{for(let a of s)if(n(a))return a},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function i(s,n=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(n)}t.joinValues=i,t.jsonStringifyReplacer=(s,n)=>typeof n=="bigint"?n.toString():n})(ce||(ce={}));var ac;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(ac||(ac={}));var U=ce.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),wt=t=>{switch(typeof t){case"undefined":return U.undefined;case"string":return U.string;case"number":return Number.isNaN(t)?U.nan:U.number;case"boolean":return U.boolean;case"function":return U.function;case"bigint":return U.bigint;case"symbol":return U.symbol;case"object":return Array.isArray(t)?U.array:t===null?U.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?U.promise:typeof Map<"u"&&t instanceof Map?U.map:typeof Set<"u"&&t instanceof Set?U.set:typeof Date<"u"&&t instanceof Date?U.date:U.object;default:return U.unknown}};var N=ce.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"]),h_=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Ve=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=i=>{this.issues=[...this.issues,i]},this.addIssues=(i=[])=>{this.issues=[...this.issues,...i]};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(n){return n.message},i={_errors:[]},s=n=>{for(let a of n.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)i._errors.push(r(a));else{let o=i,c=0;for(;c<a.path.length;){let l=a.path[c];c===a.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(a))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),i}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,ce.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},i=[];for(let s of this.issues)if(s.path.length>0){let n=s.path[0];r[n]=r[n]||[],r[n].push(e(s))}else i.push(e(s));return{formErrors:i,fieldErrors:r}}get formErrors(){return this.flatten()}};Ve.create=t=>new Ve(t);var d_=(t,e)=>{let r;switch(t.code){case N.invalid_type:t.received===U.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case N.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,ce.jsonStringifyReplacer)}`;break;case N.unrecognized_keys:r=`Unrecognized key(s) in object: ${ce.joinValues(t.keys,", ")}`;break;case N.invalid_union:r="Invalid input";break;case N.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${ce.joinValues(t.options)}`;break;case N.invalid_enum_value:r=`Invalid enum value. Expected ${ce.joinValues(t.options)}, received '${t.received}'`;break;case N.invalid_arguments:r="Invalid function arguments";break;case N.invalid_return_type:r="Invalid function return type";break;case N.invalid_date:r="Invalid date";break;case N.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}"`:ce.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case N.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 N.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 N.custom:r="Invalid input";break;case N.invalid_intersection_types:r="Intersection results could not be merged";break;case N.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case N.not_finite:r="Number must be finite";break;default:r=e.defaultError,ce.assertNever(t)}return{message:r}},Ot=d_;var jd=Ot;function p_(t){jd=t}function Xr(){return jd}var Zi=t=>{let{data:e,path:r,errorMaps:i,issueData:s}=t,n=[...r,...s.path||[]],a={...s,path:n};if(s.message!==void 0)return{...s,path:n,message:s.message};let o="",c=i.filter(l=>!!l).slice().reverse();for(let l of c)o=l(a,{data:e,defaultError:o}).message;return{...s,path:n,message:o}},m_=[];function B(t,e){let r=Xr(),i=Zi({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Ot?void 0:Ot].filter(s=>!!s)});t.common.issues.push(i)}var $e=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 i=[];for(let s of r){if(s.status==="aborted")return Q;s.status==="dirty"&&e.dirty(),i.push(s.value)}return{status:e.value,value:i}}static async mergeObjectAsync(e,r){let i=[];for(let s of r){let n=await s.key,a=await s.value;i.push({key:n,value:a})}return t.mergeObjectSync(e,i)}static mergeObjectSync(e,r){let i={};for(let s of r){let{key:n,value:a}=s;if(n.status==="aborted"||a.status==="aborted")return Q;n.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),n.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(i[n.value]=a.value)}return{status:e.value,value:i}}},Q=Object.freeze({status:"aborted"}),lr=t=>({status:"dirty",value:t}),Ne=t=>({status:"valid",value:t}),fn=t=>t.status==="aborted",hn=t=>t.status==="dirty",qt=t=>t.status==="valid",Zr=t=>typeof Promise<"u"&&t instanceof Promise;var K;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(K||(K={}));var rt=class{constructor(e,r,i,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=i,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}},Bd=(t,e)=>{if(qt(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 Ve(t.common.issues);return this._error=r,this._error}}};function ne(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:i,description:s}=t;if(e&&(r||i))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:(a,o)=>{let{message:c}=t;return a.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??i??o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:c??r??o.defaultError}},description:s}}var ae=class{get description(){return this._def.description}_getType(e){return wt(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:wt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new $e,ctx:{common:e.parent.common,data:e.data,parsedType:wt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Zr(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 i=this.safeParse(e,r);if(i.success)return i.data;throw i.error}safeParse(e,r){let i={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:wt(e)},s=this._parseSync({data:e,path:i.path,parent:i});return Bd(i,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:wt(e)};if(!this["~standard"].async)try{let i=this._parseSync({data:e,path:[],parent:r});return qt(i)?{value:i.value}:{issues:r.common.issues}}catch(i){i?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(i=>qt(i)?{value:i.value}:{issues:r.common.issues})}async parseAsync(e,r){let i=await this.safeParseAsync(e,r);if(i.success)return i.data;throw i.error}async safeParseAsync(e,r){let i={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:wt(e)},s=this._parse({data:e,path:i.path,parent:i}),n=await(Zr(s)?s:Promise.resolve(s));return Bd(i,n)}refine(e,r){let i=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,n)=>{let a=e(s),o=()=>n.addIssue({code:N.custom,...i(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,r){return this._refinement((i,s)=>e(i)?!0:(s.addIssue(typeof r=="function"?r(i,s):r),!1))}_refinement(e){return new it({schema:this,typeName:te.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 tt.create(this,this._def)}nullable(){return Et.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Pt.create(this)}promise(){return Vt.create(this,this._def)}or(e){return gr.create([this,e],this._def)}and(e){return yr.create(this,e,this._def)}transform(e){return new it({...ne(this._def),schema:this,typeName:te.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Er({...ne(this._def),innerType:this,defaultValue:r,typeName:te.ZodDefault})}brand(){return new Ji({typeName:te.ZodBranded,type:this,...ne(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new _r({...ne(this._def),innerType:this,catchValue:r,typeName:te.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Qi.create(this,e)}readonly(){return Sr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},g_=/^c[^\s-]{8,}$/i,y_=/^[0-9a-z]+$/,b_=/^[0-9A-HJKMNP-TV-Z]{26}$/i,v_=/^[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,w_=/^[a-z0-9_-]{21}$/i,x_=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,E_=/^[-+]?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)?)??$/,__=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,S_="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",cc,R_=/^(?:(?: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])$/,A_=/^(?:(?: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])$/,C_=/^(([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]))$/,L_=/^(([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])$/,O_=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,$_=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Gd="((\\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])))",T_=new RegExp(`^${Gd}$`);function qd(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 P_(t){return new RegExp(`^${qd(t)}$`)}function zd(t){let e=`${Gd}T${qd(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 I_(t,e){return!!((e==="v4"||!e)&&R_.test(t)||(e==="v6"||!e)&&C_.test(t))}function F_(t,e){if(!x_.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let i=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(i));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function N_(t,e){return!!((e==="v4"||!e)&&A_.test(t)||(e==="v6"||!e)&&L_.test(t))}var zt=class t extends ae{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==U.string){let n=this._getOrReturnCtx(e);return B(n,{code:N.invalid_type,expected:U.string,received:n.parsedType}),Q}let i=new $e,s;for(let n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:N.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),i.dirty());else if(n.kind==="max")e.data.length>n.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:N.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),i.dirty());else if(n.kind==="length"){let a=e.data.length>n.value,o=e.data.length<n.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?B(s,{code:N.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):o&&B(s,{code:N.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),i.dirty())}else if(n.kind==="email")__.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"email",code:N.invalid_string,message:n.message}),i.dirty());else if(n.kind==="emoji")cc||(cc=new RegExp(S_,"u")),cc.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"emoji",code:N.invalid_string,message:n.message}),i.dirty());else if(n.kind==="uuid")v_.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"uuid",code:N.invalid_string,message:n.message}),i.dirty());else if(n.kind==="nanoid")w_.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"nanoid",code:N.invalid_string,message:n.message}),i.dirty());else if(n.kind==="cuid")g_.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"cuid",code:N.invalid_string,message:n.message}),i.dirty());else if(n.kind==="cuid2")y_.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"cuid2",code:N.invalid_string,message:n.message}),i.dirty());else if(n.kind==="ulid")b_.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"ulid",code:N.invalid_string,message:n.message}),i.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),B(s,{validation:"url",code:N.invalid_string,message:n.message}),i.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"regex",code:N.invalid_string,message:n.message}),i.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(s=this._getOrReturnCtx(e,s),B(s,{code:N.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),i.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(s=this._getOrReturnCtx(e,s),B(s,{code:N.invalid_string,validation:{startsWith:n.value},message:n.message}),i.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(s=this._getOrReturnCtx(e,s),B(s,{code:N.invalid_string,validation:{endsWith:n.value},message:n.message}),i.dirty()):n.kind==="datetime"?zd(n).test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{code:N.invalid_string,validation:"datetime",message:n.message}),i.dirty()):n.kind==="date"?T_.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{code:N.invalid_string,validation:"date",message:n.message}),i.dirty()):n.kind==="time"?P_(n).test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{code:N.invalid_string,validation:"time",message:n.message}),i.dirty()):n.kind==="duration"?E_.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"duration",code:N.invalid_string,message:n.message}),i.dirty()):n.kind==="ip"?I_(e.data,n.version)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"ip",code:N.invalid_string,message:n.message}),i.dirty()):n.kind==="jwt"?F_(e.data,n.alg)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"jwt",code:N.invalid_string,message:n.message}),i.dirty()):n.kind==="cidr"?N_(e.data,n.version)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"cidr",code:N.invalid_string,message:n.message}),i.dirty()):n.kind==="base64"?O_.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"base64",code:N.invalid_string,message:n.message}),i.dirty()):n.kind==="base64url"?$_.test(e.data)||(s=this._getOrReturnCtx(e,s),B(s,{validation:"base64url",code:N.invalid_string,message:n.message}),i.dirty()):ce.assertNever(n);return{status:i.value,value:e.data}}_regex(e,r,i){return this.refinement(s=>e.test(s),{validation:r,code:N.invalid_string,...K.errToObj(i)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...K.errToObj(e)})}url(e){return this._addCheck({kind:"url",...K.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...K.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...K.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...K.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...K.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...K.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...K.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...K.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...K.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...K.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...K.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...K.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,...K.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,...K.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...K.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...K.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...K.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...K.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...K.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...K.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...K.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...K.errToObj(r)})}nonempty(e){return this.min(1,K.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}};zt.create=t=>new zt({checks:[],typeName:te.ZodString,coerce:t?.coerce??!1,...ne(t)});function D_(t,e){let r=(t.toString().split(".")[1]||"").length,i=(e.toString().split(".")[1]||"").length,s=r>i?r:i,n=Number.parseInt(t.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return n%a/10**s}var ur=class t extends ae{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)!==U.number){let n=this._getOrReturnCtx(e);return B(n,{code:N.invalid_type,expected:U.number,received:n.parsedType}),Q}let i,s=new $e;for(let n of this._def.checks)n.kind==="int"?ce.isInteger(e.data)||(i=this._getOrReturnCtx(e,i),B(i,{code:N.invalid_type,expected:"integer",received:"float",message:n.message}),s.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(i=this._getOrReturnCtx(e,i),B(i,{code:N.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(i=this._getOrReturnCtx(e,i),B(i,{code:N.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="multipleOf"?D_(e.data,n.value)!==0&&(i=this._getOrReturnCtx(e,i),B(i,{code:N.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(i=this._getOrReturnCtx(e,i),B(i,{code:N.not_finite,message:n.message}),s.dirty()):ce.assertNever(n);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,K.toString(r))}gt(e,r){return this.setLimit("min",e,!1,K.toString(r))}lte(e,r){return this.setLimit("max",e,!0,K.toString(r))}lt(e,r){return this.setLimit("max",e,!1,K.toString(r))}setLimit(e,r,i,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:i,message:K.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:K.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:K.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:K.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:K.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:K.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:K.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:K.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:K.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:K.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"&&ce.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let i of this._def.checks){if(i.kind==="finite"||i.kind==="int"||i.kind==="multipleOf")return!0;i.kind==="min"?(r===null||i.value>r)&&(r=i.value):i.kind==="max"&&(e===null||i.value<e)&&(e=i.value)}return Number.isFinite(r)&&Number.isFinite(e)}};ur.create=t=>new ur({checks:[],typeName:te.ZodNumber,coerce:t?.coerce||!1,...ne(t)});var fr=class t extends ae{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)!==U.bigint)return this._getInvalidInput(e);let i,s=new $e;for(let n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(i=this._getOrReturnCtx(e,i),B(i,{code:N.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(i=this._getOrReturnCtx(e,i),B(i,{code:N.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(i=this._getOrReturnCtx(e,i),B(i,{code:N.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):ce.assertNever(n);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return B(r,{code:N.invalid_type,expected:U.bigint,received:r.parsedType}),Q}gte(e,r){return this.setLimit("min",e,!0,K.toString(r))}gt(e,r){return this.setLimit("min",e,!1,K.toString(r))}lte(e,r){return this.setLimit("max",e,!0,K.toString(r))}lt(e,r){return this.setLimit("max",e,!1,K.toString(r))}setLimit(e,r,i,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:i,message:K.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:K.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:K.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:K.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:K.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:K.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}};fr.create=t=>new fr({checks:[],typeName:te.ZodBigInt,coerce:t?.coerce??!1,...ne(t)});var hr=class extends ae{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==U.boolean){let i=this._getOrReturnCtx(e);return B(i,{code:N.invalid_type,expected:U.boolean,received:i.parsedType}),Q}return Ne(e.data)}};hr.create=t=>new hr({typeName:te.ZodBoolean,coerce:t?.coerce||!1,...ne(t)});var dr=class t extends ae{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==U.date){let n=this._getOrReturnCtx(e);return B(n,{code:N.invalid_type,expected:U.date,received:n.parsedType}),Q}if(Number.isNaN(e.data.getTime())){let n=this._getOrReturnCtx(e);return B(n,{code:N.invalid_date}),Q}let i=new $e,s;for(let n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:N.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),i.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(s=this._getOrReturnCtx(e,s),B(s,{code:N.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),i.dirty()):ce.assertNever(n);return{status:i.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:K.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:K.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}};dr.create=t=>new dr({checks:[],coerce:t?.coerce||!1,typeName:te.ZodDate,...ne(t)});var Qr=class extends ae{_parse(e){if(this._getType(e)!==U.symbol){let i=this._getOrReturnCtx(e);return B(i,{code:N.invalid_type,expected:U.symbol,received:i.parsedType}),Q}return Ne(e.data)}};Qr.create=t=>new Qr({typeName:te.ZodSymbol,...ne(t)});var pr=class extends ae{_parse(e){if(this._getType(e)!==U.undefined){let i=this._getOrReturnCtx(e);return B(i,{code:N.invalid_type,expected:U.undefined,received:i.parsedType}),Q}return Ne(e.data)}};pr.create=t=>new pr({typeName:te.ZodUndefined,...ne(t)});var mr=class extends ae{_parse(e){if(this._getType(e)!==U.null){let i=this._getOrReturnCtx(e);return B(i,{code:N.invalid_type,expected:U.null,received:i.parsedType}),Q}return Ne(e.data)}};mr.create=t=>new mr({typeName:te.ZodNull,...ne(t)});var Wt=class extends ae{constructor(){super(...arguments),this._any=!0}_parse(e){return Ne(e.data)}};Wt.create=t=>new Wt({typeName:te.ZodAny,...ne(t)});var Tt=class extends ae{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ne(e.data)}};Tt.create=t=>new Tt({typeName:te.ZodUnknown,...ne(t)});var dt=class extends ae{_parse(e){let r=this._getOrReturnCtx(e);return B(r,{code:N.invalid_type,expected:U.never,received:r.parsedType}),Q}};dt.create=t=>new dt({typeName:te.ZodNever,...ne(t)});var ei=class extends ae{_parse(e){if(this._getType(e)!==U.undefined){let i=this._getOrReturnCtx(e);return B(i,{code:N.invalid_type,expected:U.void,received:i.parsedType}),Q}return Ne(e.data)}};ei.create=t=>new ei({typeName:te.ZodVoid,...ne(t)});var Pt=class t extends ae{_parse(e){let{ctx:r,status:i}=this._processInputParams(e),s=this._def;if(r.parsedType!==U.array)return B(r,{code:N.invalid_type,expected:U.array,received:r.parsedType}),Q;if(s.exactLength!==null){let a=r.data.length>s.exactLength.value,o=r.data.length<s.exactLength.value;(a||o)&&(B(r,{code:a?N.too_big:N.too_small,minimum:o?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),i.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(B(r,{code:N.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),i.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(B(r,{code:N.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),i.dirty()),r.common.async)return Promise.all([...r.data].map((a,o)=>s.type._parseAsync(new rt(r,a,r.path,o)))).then(a=>$e.mergeArray(i,a));let n=[...r.data].map((a,o)=>s.type._parseSync(new rt(r,a,r.path,o)));return $e.mergeArray(i,n)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:K.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:K.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:K.toString(r)}})}nonempty(e){return this.min(1,e)}};Pt.create=(t,e)=>new Pt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:te.ZodArray,...ne(e)});function Jr(t){if(t instanceof He){let e={};for(let r in t.shape){let i=t.shape[r];e[r]=tt.create(Jr(i))}return new He({...t._def,shape:()=>e})}else return t instanceof Pt?new Pt({...t._def,type:Jr(t.element)}):t instanceof tt?tt.create(Jr(t.unwrap())):t instanceof Et?Et.create(Jr(t.unwrap())):t instanceof xt?xt.create(t.items.map(e=>Jr(e))):t}var He=class t extends ae{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=ce.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==U.object){let l=this._getOrReturnCtx(e);return B(l,{code:N.invalid_type,expected:U.object,received:l.parsedType}),Q}let{status:i,ctx:s}=this._processInputParams(e),{shape:n,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof dt&&this._def.unknownKeys==="strip"))for(let l in s.data)a.includes(l)||o.push(l);let c=[];for(let l of a){let u=n[l],p=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new rt(s,p,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof dt){let l=this._def.unknownKeys;if(l==="passthrough")for(let u of o)c.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(l==="strict")o.length>0&&(B(s,{code:N.unrecognized_keys,keys:o}),i.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let u of o){let p=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new rt(s,p,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let u of c){let p=await u.key,b=await u.value;l.push({key:p,value:b,alwaysSet:u.alwaysSet})}return l}).then(l=>$e.mergeObjectSync(i,l)):$e.mergeObjectSync(i,c)}get shape(){return this._def.shape()}strict(e){return K.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,i)=>{let s=this._def.errorMap?.(r,i).message??i.defaultError;return r.code==="unrecognized_keys"?{message:K.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:te.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let i of ce.objectKeys(e))e[i]&&this.shape[i]&&(r[i]=this.shape[i]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let i of ce.objectKeys(this.shape))e[i]||(r[i]=this.shape[i]);return new t({...this._def,shape:()=>r})}deepPartial(){return Jr(this)}partial(e){let r={};for(let i of ce.objectKeys(this.shape)){let s=this.shape[i];e&&!e[i]?r[i]=s:r[i]=s.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let i of ce.objectKeys(this.shape))if(e&&!e[i])r[i]=this.shape[i];else{let n=this.shape[i];for(;n instanceof tt;)n=n._def.innerType;r[i]=n}return new t({...this._def,shape:()=>r})}keyof(){return Wd(ce.objectKeys(this.shape))}};He.create=(t,e)=>new He({shape:()=>t,unknownKeys:"strip",catchall:dt.create(),typeName:te.ZodObject,...ne(e)});He.strictCreate=(t,e)=>new He({shape:()=>t,unknownKeys:"strict",catchall:dt.create(),typeName:te.ZodObject,...ne(e)});He.lazycreate=(t,e)=>new He({shape:t,unknownKeys:"strip",catchall:dt.create(),typeName:te.ZodObject,...ne(e)});var gr=class extends ae{_parse(e){let{ctx:r}=this._processInputParams(e),i=this._def.options;function s(n){for(let o of n)if(o.result.status==="valid")return o.result;for(let o of n)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;let a=n.map(o=>new Ve(o.ctx.common.issues));return B(r,{code:N.invalid_union,unionErrors:a}),Q}if(r.common.async)return Promise.all(i.map(async n=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await n._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(s);{let n,a=[];for(let c of i){let l={...r,common:{...r.common,issues:[]},parent:null},u=c._parseSync({data:r.data,path:r.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!n&&(n={result:u,ctx:l}),l.common.issues.length&&a.push(l.common.issues)}if(n)return r.common.issues.push(...n.ctx.common.issues),n.result;let o=a.map(c=>new Ve(c));return B(r,{code:N.invalid_union,unionErrors:o}),Q}}get options(){return this._def.options}};gr.create=(t,e)=>new gr({options:t,typeName:te.ZodUnion,...ne(e)});var $t=t=>t instanceof br?$t(t.schema):t instanceof it?$t(t.innerType()):t instanceof vr?[t.value]:t instanceof wr?t.options:t instanceof xr?ce.objectValues(t.enum):t instanceof Er?$t(t._def.innerType):t instanceof pr?[void 0]:t instanceof mr?[null]:t instanceof tt?[void 0,...$t(t.unwrap())]:t instanceof Et?[null,...$t(t.unwrap())]:t instanceof Ji||t instanceof Sr?$t(t.unwrap()):t instanceof _r?$t(t._def.innerType):[],dn=class t extends ae{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==U.object)return B(r,{code:N.invalid_type,expected:U.object,received:r.parsedType}),Q;let i=this.discriminator,s=r.data[i],n=this.optionsMap.get(s);return n?r.common.async?n._parseAsync({data:r.data,path:r.path,parent:r}):n._parseSync({data:r.data,path:r.path,parent:r}):(B(r,{code:N.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[i]}),Q)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,i){let s=new Map;for(let n of r){let a=$t(n.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of a){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,n)}}return new t({typeName:te.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...ne(i)})}};function lc(t,e){let r=wt(t),i=wt(e);if(t===e)return{valid:!0,data:t};if(r===U.object&&i===U.object){let s=ce.objectKeys(e),n=ce.objectKeys(t).filter(o=>s.indexOf(o)!==-1),a={...t,...e};for(let o of n){let c=lc(t[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(r===U.array&&i===U.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let n=0;n<t.length;n++){let a=t[n],o=e[n],c=lc(a,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===U.date&&i===U.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var yr=class extends ae{_parse(e){let{status:r,ctx:i}=this._processInputParams(e),s=(n,a)=>{if(fn(n)||fn(a))return Q;let o=lc(n.value,a.value);return o.valid?((hn(n)||hn(a))&&r.dirty(),{status:r.value,value:o.data}):(B(i,{code:N.invalid_intersection_types}),Q)};return i.common.async?Promise.all([this._def.left._parseAsync({data:i.data,path:i.path,parent:i}),this._def.right._parseAsync({data:i.data,path:i.path,parent:i})]).then(([n,a])=>s(n,a)):s(this._def.left._parseSync({data:i.data,path:i.path,parent:i}),this._def.right._parseSync({data:i.data,path:i.path,parent:i}))}};yr.create=(t,e,r)=>new yr({left:t,right:e,typeName:te.ZodIntersection,...ne(r)});var xt=class t extends ae{_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==U.array)return B(i,{code:N.invalid_type,expected:U.array,received:i.parsedType}),Q;if(i.data.length<this._def.items.length)return B(i,{code:N.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Q;!this._def.rest&&i.data.length>this._def.items.length&&(B(i,{code:N.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let n=[...i.data].map((a,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new rt(i,a,i.path,o)):null}).filter(a=>!!a);return i.common.async?Promise.all(n).then(a=>$e.mergeArray(r,a)):$e.mergeArray(r,n)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};xt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new xt({items:t,typeName:te.ZodTuple,rest:null,...ne(e)})};var pn=class t extends ae{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==U.object)return B(i,{code:N.invalid_type,expected:U.object,received:i.parsedType}),Q;let s=[],n=this._def.keyType,a=this._def.valueType;for(let o in i.data)s.push({key:n._parse(new rt(i,o,i.path,o)),value:a._parse(new rt(i,i.data[o],i.path,o)),alwaysSet:o in i.data});return i.common.async?$e.mergeObjectAsync(r,s):$e.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,i){return r instanceof ae?new t({keyType:e,valueType:r,typeName:te.ZodRecord,...ne(i)}):new t({keyType:zt.create(),valueType:e,typeName:te.ZodRecord,...ne(r)})}},ti=class extends ae{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==U.map)return B(i,{code:N.invalid_type,expected:U.map,received:i.parsedType}),Q;let s=this._def.keyType,n=this._def.valueType,a=[...i.data.entries()].map(([o,c],l)=>({key:s._parse(new rt(i,o,i.path,[l,"key"])),value:n._parse(new rt(i,c,i.path,[l,"value"]))}));if(i.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let c of a){let l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return Q;(l.status==="dirty"||u.status==="dirty")&&r.dirty(),o.set(l.value,u.value)}return{status:r.value,value:o}})}else{let o=new Map;for(let c of a){let l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return Q;(l.status==="dirty"||u.status==="dirty")&&r.dirty(),o.set(l.value,u.value)}return{status:r.value,value:o}}}};ti.create=(t,e,r)=>new ti({valueType:e,keyType:t,typeName:te.ZodMap,...ne(r)});var ri=class t extends ae{_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.parsedType!==U.set)return B(i,{code:N.invalid_type,expected:U.set,received:i.parsedType}),Q;let s=this._def;s.minSize!==null&&i.data.size<s.minSize.value&&(B(i,{code:N.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&i.data.size>s.maxSize.value&&(B(i,{code:N.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let n=this._def.valueType;function a(c){let l=new Set;for(let u of c){if(u.status==="aborted")return Q;u.status==="dirty"&&r.dirty(),l.add(u.value)}return{status:r.value,value:l}}let o=[...i.data.values()].map((c,l)=>n._parse(new rt(i,c,i.path,l)));return i.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,r){return new t({...this._def,minSize:{value:e,message:K.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:K.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};ri.create=(t,e)=>new ri({valueType:t,minSize:null,maxSize:null,typeName:te.ZodSet,...ne(e)});var mn=class t extends ae{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==U.function)return B(r,{code:N.invalid_type,expected:U.function,received:r.parsedType}),Q;function i(o,c){return Zi({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Xr(),Ot].filter(l=>!!l),issueData:{code:N.invalid_arguments,argumentsError:c}})}function s(o,c){return Zi({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Xr(),Ot].filter(l=>!!l),issueData:{code:N.invalid_return_type,returnTypeError:c}})}let n={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof Vt){let o=this;return Ne(async function(...c){let l=new Ve([]),u=await o._def.args.parseAsync(c,n).catch(f=>{throw l.addIssue(i(c,f)),l}),p=await Reflect.apply(a,this,u);return await o._def.returns._def.type.parseAsync(p,n).catch(f=>{throw l.addIssue(s(p,f)),l})})}else{let o=this;return Ne(function(...c){let l=o._def.args.safeParse(c,n);if(!l.success)throw new Ve([i(c,l.error)]);let u=Reflect.apply(a,this,l.data),p=o._def.returns.safeParse(u,n);if(!p.success)throw new Ve([s(u,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:xt.create(e).rest(Tt.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,i){return new t({args:e||xt.create([]).rest(Tt.create()),returns:r||Tt.create(),typeName:te.ZodFunction,...ne(i)})}},br=class extends ae{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})}};br.create=(t,e)=>new br({getter:t,typeName:te.ZodLazy,...ne(e)});var vr=class extends ae{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return B(r,{received:r.data,code:N.invalid_literal,expected:this._def.value}),Q}return{status:"valid",value:e.data}}get value(){return this._def.value}};vr.create=(t,e)=>new vr({value:t,typeName:te.ZodLiteral,...ne(e)});function Wd(t,e){return new wr({values:t,typeName:te.ZodEnum,...ne(e)})}var wr=class t extends ae{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),i=this._def.values;return B(r,{expected:ce.joinValues(i),received:r.parsedType,code:N.invalid_type}),Q}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),i=this._def.values;return B(r,{received:r.data,code:N.invalid_enum_value,options:i}),Q}return Ne(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(i=>!e.includes(i)),{...this._def,...r})}};wr.create=Wd;var xr=class extends ae{_parse(e){let r=ce.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(e);if(i.parsedType!==U.string&&i.parsedType!==U.number){let s=ce.objectValues(r);return B(i,{expected:ce.joinValues(s),received:i.parsedType,code:N.invalid_type}),Q}if(this._cache||(this._cache=new Set(ce.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=ce.objectValues(r);return B(i,{received:i.data,code:N.invalid_enum_value,options:s}),Q}return Ne(e.data)}get enum(){return this._def.values}};xr.create=(t,e)=>new xr({values:t,typeName:te.ZodNativeEnum,...ne(e)});var Vt=class extends ae{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==U.promise&&r.common.async===!1)return B(r,{code:N.invalid_type,expected:U.promise,received:r.parsedType}),Q;let i=r.parsedType===U.promise?r.data:Promise.resolve(r.data);return Ne(i.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Vt.create=(t,e)=>new Vt({type:t,typeName:te.ZodPromise,...ne(e)});var it=class extends ae{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===te.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:i}=this._processInputParams(e),s=this._def.effect||null,n={addIssue:a=>{B(i,a),a.fatal?r.abort():r.dirty()},get path(){return i.path}};if(n.addIssue=n.addIssue.bind(n),s.type==="preprocess"){let a=s.transform(i.data,n);if(i.common.async)return Promise.resolve(a).then(async o=>{if(r.value==="aborted")return Q;let c=await this._def.schema._parseAsync({data:o,path:i.path,parent:i});return c.status==="aborted"?Q:c.status==="dirty"?lr(c.value):r.value==="dirty"?lr(c.value):c});{if(r.value==="aborted")return Q;let o=this._def.schema._parseSync({data:a,path:i.path,parent:i});return o.status==="aborted"?Q:o.status==="dirty"?lr(o.value):r.value==="dirty"?lr(o.value):o}}if(s.type==="refinement"){let a=o=>{let c=s.refinement(o,n);if(i.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(i.common.async===!1){let o=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});return o.status==="aborted"?Q:(o.status==="dirty"&&r.dirty(),a(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(o=>o.status==="aborted"?Q:(o.status==="dirty"&&r.dirty(),a(o.value).then(()=>({status:r.value,value:o.value}))))}if(s.type==="transform")if(i.common.async===!1){let a=this._def.schema._parseSync({data:i.data,path:i.path,parent:i});if(!qt(a))return Q;let o=s.transform(a.value,n);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:i.data,path:i.path,parent:i}).then(a=>qt(a)?Promise.resolve(s.transform(a.value,n)).then(o=>({status:r.value,value:o})):Q);ce.assertNever(s)}};it.create=(t,e,r)=>new it({schema:t,typeName:te.ZodEffects,effect:e,...ne(r)});it.createWithPreprocess=(t,e,r)=>new it({schema:e,effect:{type:"preprocess",transform:t},typeName:te.ZodEffects,...ne(r)});var tt=class extends ae{_parse(e){return this._getType(e)===U.undefined?Ne(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};tt.create=(t,e)=>new tt({innerType:t,typeName:te.ZodOptional,...ne(e)});var Et=class extends ae{_parse(e){return this._getType(e)===U.null?Ne(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Et.create=(t,e)=>new Et({innerType:t,typeName:te.ZodNullable,...ne(e)});var Er=class extends ae{_parse(e){let{ctx:r}=this._processInputParams(e),i=r.data;return r.parsedType===U.undefined&&(i=this._def.defaultValue()),this._def.innerType._parse({data:i,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Er.create=(t,e)=>new Er({innerType:t,typeName:te.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ne(e)});var _r=class extends ae{_parse(e){let{ctx:r}=this._processInputParams(e),i={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:i.data,path:i.path,parent:{...i}});return Zr(s)?s.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Ve(i.common.issues)},input:i.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ve(i.common.issues)},input:i.data})}}removeCatch(){return this._def.innerType}};_r.create=(t,e)=>new _r({innerType:t,typeName:te.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ne(e)});var ii=class extends ae{_parse(e){if(this._getType(e)!==U.nan){let i=this._getOrReturnCtx(e);return B(i,{code:N.invalid_type,expected:U.nan,received:i.parsedType}),Q}return{status:"valid",value:e.data}}};ii.create=t=>new ii({typeName:te.ZodNaN,...ne(t)});var M_=Symbol("zod_brand"),Ji=class extends ae{_parse(e){let{ctx:r}=this._processInputParams(e),i=r.data;return this._def.type._parse({data:i,path:r.path,parent:r})}unwrap(){return this._def.type}},Qi=class t extends ae{_parse(e){let{status:r,ctx:i}=this._processInputParams(e);if(i.common.async)return(async()=>{let n=await this._def.in._parseAsync({data:i.data,path:i.path,parent:i});return n.status==="aborted"?Q:n.status==="dirty"?(r.dirty(),lr(n.value)):this._def.out._parseAsync({data:n.value,path:i.path,parent:i})})();{let s=this._def.in._parseSync({data:i.data,path:i.path,parent:i});return s.status==="aborted"?Q:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:i.path,parent:i})}}static create(e,r){return new t({in:e,out:r,typeName:te.ZodPipeline})}},Sr=class extends ae{_parse(e){let r=this._def.innerType._parse(e),i=s=>(qt(s)&&(s.value=Object.freeze(s.value)),s);return Zr(r)?r.then(s=>i(s)):i(r)}unwrap(){return this._def.innerType}};Sr.create=(t,e)=>new Sr({innerType:t,typeName:te.ZodReadonly,...ne(e)});function Ud(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function Vd(t,e={},r){return t?Wt.create().superRefine((i,s)=>{let n=t(i);if(n instanceof Promise)return n.then(a=>{if(!a){let o=Ud(e,i),c=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:c})}});if(!n){let a=Ud(e,i),o=a.fatal??r??!0;s.addIssue({code:"custom",...a,fatal:o})}}):Wt.create()}var k_={object:He.lazycreate},te;(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"})(te||(te={}));var j_=(t,e={message:`Input not instance of ${t.name}`})=>Vd(r=>r instanceof t,e),Hd=zt.create,Kd=ur.create,B_=ii.create,U_=fr.create,Yd=hr.create,G_=dr.create,q_=Qr.create,z_=pr.create,W_=mr.create,V_=Wt.create,H_=Tt.create,K_=dt.create,Y_=ei.create,X_=Pt.create,Z_=He.create,J_=He.strictCreate,Q_=gr.create,eS=dn.create,tS=yr.create,rS=xt.create,iS=pn.create,sS=ti.create,nS=ri.create,oS=mn.create,aS=br.create,cS=vr.create,lS=wr.create,uS=xr.create,fS=Vt.create,hS=it.create,dS=tt.create,pS=Et.create,mS=it.createWithPreprocess,gS=Qi.create,yS=()=>Hd().optional(),bS=()=>Kd().optional(),vS=()=>Yd().optional(),wS={string:(t=>zt.create({...t,coerce:!0})),number:(t=>ur.create({...t,coerce:!0})),boolean:(t=>hr.create({...t,coerce:!0})),bigint:(t=>fr.create({...t,coerce:!0})),date:(t=>dr.create({...t,coerce:!0}))};var xS=Q;var ES=P.object({repository_url:P.string(),powerlint_version:P.string(),schema_version:P.string()}),_S=P.object({configured:P.boolean(),invalid_api_key:P.boolean().optional(),is_valid_repository:P.boolean().optional(),config:P.object({ignored_globs:P.array(P.string())}).optional()}),SS=P.object({repository_url:P.string(),rule_ids:P.array(P.string()).optional(),schema_version:P.string(),powerlint_version:P.string()}),RS=P.object({rules:P.array(P.object({id:P.string(),internalId:P.string(),internalVersionId:P.string(),message:P.string(),prompt:P.string(),severity:P.enum(["suggestion","violation"]),schema:P.any(),execution:P.enum(["llm","deterministic"]).optional()}))}),AS=P.object({rule:P.object({id:P.string(),versionId:P.string(),contents:P.string(),message:P.string()}),matches:P.array(P.any()),messages:P.array(P.any()),tools:P.array(P.enum(["read","grep","glob"])),files:P.array(P.object({path:P.string(),sha:P.string()})).optional(),schema_version:P.string(),powerlint_version:P.string(),repository_url:P.string(),commit:P.object({sha:P.string(),branch:P.string(),message:P.string(),timestamp:P.string()})}),CS=P.discriminatedUnion("type",[P.object({type:P.literal("tool_request"),tool_calls:P.array(P.any()),usage:P.object({cost:P.string(),inputTokens:P.string(),outputTokens:P.string()})}),P.object({type:P.literal("matches"),matches:P.array(P.any()),usage:P.object({cost:P.string(),inputTokens:P.string(),outputTokens:P.string()}),files:P.array(P.object({path:P.string(),sha:P.string()})).optional()}),P.object({type:P.literal("request_files"),files:P.array(P.object({path:P.string(),sha:P.string()})),usage:P.object({cost:P.string(),inputTokens:P.string(),outputTokens:P.string()})})]),LS=P.object({rule:P.object({id:P.string(),versionId:P.string(),contents:P.string(),message:P.string()}),matches:P.array(P.any()),files:P.array(P.object({path:P.string(),sha:P.string()})).optional(),schema_version:P.string(),powerlint_version:P.string(),repository_url:P.string(),commit:P.object({sha:P.string(),branch:P.string(),message:P.string(),timestamp:P.string()})}),OS=P.object({type:P.literal("matches"),matches:P.array(P.any()),usage:P.object({cost:P.string(),inputTokens:P.string(),outputTokens:P.string()})}),es=class{baseUrl;apiKey;constructor(e){this.baseUrl=e.baseUrl,this.apiKey=e.apiKey}async request(e,r,i){let s=`${this.baseUrl}${e}`,a=await(await oc(async()=>{let o=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify(r)});if(!o.ok){let c=await o.text();throw new Error(`Wispbit API request failed: ${o.status} ${o.statusText} - ${c}`)}return o},{retries:3,minTimeout:1e3,maxTimeout:5e3,onFailedAttempt:o=>{console.warn(`API request to ${e} failed (attempt ${o.attemptNumber}/4): ${o.message}`)}})).json();return i?i.parse(a):a}async initialize(e){let r=ES.parse(e);return await this.request("/plv1/initialize",r,_S)}async getRules(e){let r=SS.parse(e);return await this.request("/plv1/get-rules",r,RS)}async matchLLMSearch(e){let r=AS.parse(e);return await this.request("/plv1/llm-search",r,CS)}async matchLLMValidate(e){let r=LS.parse(e);return await this.request("/plv1/llm-validate",r,OS)}};var gn=class{config;environment;constructor(e,r){this.config=e,this.environment=r}async search(e){let r=this.config.getApiClient(),i=await this.environment.getRepositoryUrl(),s=await this.environment.getCurrentCommit(),n={id:e.rule.internalId,versionId:e.rule.internalVersionId,contents:e.rule.prompt,message:e.rule.config.message};return await r.matchLLMSearch({rule:n,matches:e.matches,messages:e.messages,tools:e.tools,files:e.files,schema_version:this.config.getSchemaVersion(),powerlint_version:this.config.getLocalVersion(),repository_url:i,commit:s})}async validate(e){let r=this.config.getApiClient(),i=await this.environment.getRepositoryUrl(),s=await this.environment.getCurrentCommit(),n={id:e.rule.internalId,versionId:e.rule.internalVersionId,contents:e.rule.prompt,message:e.rule.config.message};return await r.matchLLMValidate({rule:n,matches:e.matches,files:e.files,schema_version:this.config.getSchemaVersion(),powerlint_version:this.config.getLocalVersion(),repository_url:i,commit:s})}};import{readFileSync as UR}from"fs";import{dirname as GR,join as qR}from"path";import{fileURLToPath as zR}from"url";var ts=class extends Error{response;request;options;constructor(e,r,i){let s=e.status||e.status===0?e.status:"",n=e.statusText||"",a=`${s} ${n}`.trim(),o=a?`status code ${a}`:"an unknown error";super(`Request failed with ${o}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=e,this.request=r,this.options=i}};var si=class extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}};var uc=(()=>{let t=!1,e=!1,r=typeof globalThis.ReadableStream=="function",i=typeof globalThis.Request=="function";if(r&&i)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type")}catch(s){if(s instanceof Error&&s.message==="unsupported BodyInit type")return!1;throw s}return t&&!e})(),Xd=typeof globalThis.AbortController=="function",Zd=typeof globalThis.ReadableStream=="function",Jd=typeof globalThis.FormData=="function",yn=["get","post","put","patch","head","delete"],$S=()=>{};$S();var Qd={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},bn=2147483647,ep=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,vn=Symbol("stop"),tp={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},rp={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0};var TS=t=>{if(!t)return 0;if(t instanceof FormData){let e=0;for(let[r,i]of t)e+=ep,e+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,e+=typeof i=="string"?new TextEncoder().encode(i).length:i.size;return e}if(t instanceof Blob)return t.size;if(t instanceof ArrayBuffer)return t.byteLength;if(typeof t=="string")return new TextEncoder().encode(t).length;if(t instanceof URLSearchParams)return new TextEncoder().encode(t.toString()).length;if("byteLength"in t)return t.byteLength;if(typeof t=="object"&&t!==null)try{let e=JSON.stringify(t);return new TextEncoder().encode(e).length}catch{return 0}return 0},ip=(t,e)=>{let r=Number(t.headers.get("content-length"))||0,i=0;return t.status===204?(e&&e({percent:1,totalBytes:r,transferredBytes:i},new Uint8Array),new Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new Response(new ReadableStream({async start(s){let n=t.body.getReader();e&&e({percent:0,transferredBytes:0,totalBytes:r},new Uint8Array);async function a(){let{done:o,value:c}=await n.read();if(o){s.close();return}if(e){i+=c.byteLength;let l=r===0?0:i/r;e({percent:l,transferredBytes:i,totalBytes:r},c)}s.enqueue(c),await a()}await a()}}),{status:t.status,statusText:t.statusText,headers:t.headers})},sp=(t,e)=>{let r=TS(t.body),i=0;return new Request(t,{duplex:"half",body:new ReadableStream({async start(s){let n=t.body instanceof ReadableStream?t.body.getReader():new Response("").body.getReader();async function a(){let{done:o,value:c}=await n.read();if(o){e&&e({percent:1,transferredBytes:i,totalBytes:Math.max(r,i)},new Uint8Array),s.close();return}i+=c.byteLength;let l=r===0?0:i/r;(r<i||l===1)&&(l=.99),e&&e({percent:Number(l.toFixed(2)),transferredBytes:i,totalBytes:r},c),s.enqueue(c),await a()}await a()}})})};var ni=t=>t!==null&&typeof t=="object";var rs=(...t)=>{for(let e of t)if((!ni(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return dc({},...t)},fc=(t={},e={})=>{let r=new globalThis.Headers(t),i=e instanceof globalThis.Headers,s=new globalThis.Headers(e);for(let[n,a]of s.entries())i&&a==="undefined"||a===void 0?r.delete(n):r.set(n,a);return r};function wn(t,e,r){return Object.hasOwn(e,r)&&e[r]===void 0?[]:dc(t[r]??[],e[r]??[])}var hc=(t={},e={})=>({beforeRequest:wn(t,e,"beforeRequest"),beforeRetry:wn(t,e,"beforeRetry"),afterResponse:wn(t,e,"afterResponse"),beforeError:wn(t,e,"beforeError")}),dc=(...t)=>{let e={},r={},i={};for(let s of t)if(Array.isArray(s))Array.isArray(e)||(e=[]),e=[...e,...s];else if(ni(s)){for(let[n,a]of Object.entries(s))ni(a)&&n in e&&(a=dc(e[n],a)),e={...e,[n]:a};ni(s.hooks)&&(i=hc(i,s.hooks),e.hooks=i),ni(s.headers)&&(r=fc(r,s.headers),e.headers=r)}return e};var op=t=>yn.includes(t)?t.toUpperCase():t,PS=["get","put","head","delete","options","trace"],IS=[408,413,429,500,502,503,504],FS=[413,429,503],np={limit:2,methods:PS,statusCodes:IS,afterStatusCodes:FS,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:t=>.3*2**(t-1)*1e3},ap=(t={})=>{if(typeof t=="number")return{...np,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");return{...np,...t}};async function pc(t,e,r,i){return new Promise((s,n)=>{let a=setTimeout(()=>{r&&r.abort(),n(new si(t))},i.timeout);i.fetch(t,e).then(s).catch(n).then(()=>{clearTimeout(a)})})}async function mc(t,{signal:e}){return new Promise((r,i)=>{e&&(e.throwIfAborted(),e.addEventListener("abort",s,{once:!0}));function s(){clearTimeout(n),i(e.reason)}let n=setTimeout(()=>{e?.removeEventListener("abort",s),r()},t)})}var cp=(t,e)=>{let r={};for(let i in e)!(i in rp)&&!(i in tp)&&!(i in t)&&(r[i]=e[i]);return r};var is=class t{static create(e,r){let i=new t(e,r),s=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>bn)throw new RangeError(`The \`timeout\` option cannot be greater than ${bn}`);await Promise.resolve();let o=await i._fetch();for(let c of i._options.hooks.afterResponse){let l=await c(i.request,i._options,i._decorateResponse(o.clone()));l instanceof globalThis.Response&&(o=l)}if(i._decorateResponse(o),!o.ok&&i._options.throwHttpErrors){let c=new ts(o,i.request,i._options);for(let l of i._options.hooks.beforeError)c=await l(c);throw c}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!Zd)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return ip(o.clone(),i._options.onDownloadProgress)}return o},a=(i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(s):s()).finally(async()=>{i.request.bodyUsed||await i.request.body?.cancel()});for(let[o,c]of Object.entries(Qd))a[o]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||c);let l=await a;if(o==="json"){if(l.status===204||(await l.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await l.text())}return l[o]()};return a}request;abortController;_retryCount=0;_input;_options;constructor(e,r={}){if(this._input=e,this._options={...r,headers:fc(this._input.headers,r.headers),hooks:hc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:op(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:ap(r.retry),throwHttpErrors:r.throwHttpErrors!==!1,timeout:r.timeout??1e4,fetch:r.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(Xd){let i=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=i?AbortSignal.any([i,this.abortController.signal]):this.abortController.signal}if(uc&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){let s="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),n=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,s);(Jd&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(n,{...this.request}),this._options)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!uc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=sp(this.request,this._options.onUploadProgress))}}_calculateRetryDelay(e){if(this._retryCount++,this._retryCount>this._options.retry.limit||e instanceof si)throw e;if(e instanceof ts){if(!this._options.retry.statusCodes.includes(e.response.status))throw e;let i=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(i&&this._options.retry.afterStatusCodes.includes(e.response.status)){let s=Number(i)*1e3;Number.isNaN(s)?s=Date.parse(i)-Date.now():s>=Date.parse("2024-01-01")&&(s-=Date.now());let n=this._options.retry.maxRetryAfter??s;return s<n?s:n}if(e.response.status===413)throw e}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(e){return this._options.parseJson&&(e.json=async()=>this._options.parseJson(await e.text())),e}async _retry(e){try{return await e()}catch(r){let i=Math.min(this._calculateRetryDelay(r),bn);if(this._retryCount<1)throw r;await mc(i,{signal:this._options.signal});for(let s of this._options.hooks.beforeRetry)if(await s({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===vn)return;return this._retry(e)}}async _fetch(){for(let i of this._options.hooks.beforeRequest){let s=await i(this.request,this._options);if(s instanceof Request){this.request=s;break}if(s instanceof Response)return s}let e=cp(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,e):pc(r,e,this.abortController,this._options)}};var gc=t=>{let e=(r,i)=>is.create(r,rs(t,i));for(let r of yn)e[r]=(i,s)=>is.create(i,rs(t,s,{method:r}));return e.create=r=>gc(rs(r)),e.extend=r=>(typeof r=="function"&&(r=r(t??{})),gc(rs(t,r))),e.stop=vn,e},NS=gc(),lp=NS;var Pp=We(Tp(),1);function xc(t){let e=(0,Pp.default)("npm",{registry:"https://registry.npmjs.org/"}),r=e[`${t}:registry`]||e.config_registry||e.registry;return r.slice(-1)==="/"?r:`${r}/`}var Am=We(Rm(),1),Cm=We(ic(),1),Fc=class extends Error{constructor(e){super(`Package \`${e}\` could not be found`),this.name="PackageNotFoundError"}},Nc=class extends Error{constructor(e,r){super(`Version \`${r}\` for package \`${e}\` could not be found`),this.name="VersionNotFoundError"}};async function Dc(t,e={}){let{version:r="latest"}=e,{omitDeprecated:i=!0}=e,s=t.split("/")[0],n=e.registryUrl??xc(s),a=new URL(encodeURIComponent(t).replace(/^%40/,"@"),n),o=(0,Am.default)(n.toString(),{recursive:!0}),c={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};e.fullMetadata&&delete c.accept,o&&(c.authorization=`${o.type} ${o.token}`);let l;try{l=await lp(a,{headers:c,keepalive:!0}).json()}catch(p){throw p?.response?.status===404?new Fc(t):p}if(e.allVersions)return l;let u=new Nc(t,r);if(l["dist-tags"][r]){let{time:p}=l;l=l.versions[l["dist-tags"][r]],l.time=p}else if(r){let p=!!l.versions[r];if(i&&!p)for(let[f,d]of Object.entries(l.versions))d.deprecated&&delete l.versions[f];if(!p){let f=Object.keys(l.versions);if(r=Cm.default.maxSatisfying(f,r),!r)throw u}let{time:b}=l;if(l=l.versions[r],l.time=b,!l)throw u}return l}async function Mc(t,e){let{version:r}=await Dc(t.toLowerCase(),e);return r}function Ir(){let t=zR(import.meta.url?import.meta.url:__filename),e=GR(t),r=qR(e,"./package.json");try{let i=UR(r,"utf8");return JSON.parse(i).version}catch{return"0.0.0"}}async function Lm(){try{return await Mc("@wispbit/local")}catch{return Ir()}}var ls=class t{config;apiKey=null;baseUrl=null;apiClient=null;llmProvider=null;constructor(e,r){this.config={...e,ignoredGlobs:e.ignoredGlobs||[]},this.apiKey=e.apiKey||null,this.baseUrl=e.baseUrl||null,this.apiKey&&this.baseUrl&&(this.apiClient=new es({baseUrl:this.baseUrl,apiKey:this.apiKey})),r?.llmProvider&&(this.llmProvider=r.llmProvider)}getIgnoredGlobs(){return this.config.ignoredGlobs||[]}getApiKey(){return this.apiKey}getBaseUrl(){return this.baseUrl}getApiClient(){if(!this.apiClient)throw new Error("API client not initialized. Config must have both apiKey and baseUrl.");return this.apiClient}getLLMProvider(){if(!this.llmProvider)throw new Error("LLM provider not initialized. Use Config.initialize() instead of initializeLocal().");return this.llmProvider}getLocalVersion(){return Ir()}getSchemaVersion(){return"v1"}static initializeLocal(e={}){let r=e.ignoredGlobs||[];return new t({ignoredGlobs:r},{llmProvider:e.llmProvider})}static async initialize(e,{apiKey:r,baseUrl:i}){let s=i||process.env.WISPBIT_API_BASE_URL||"https://api.wispbit.com",n=r||process.env.WISPBIT_API_KEY||null;if(!n)return console.log("No API key found"),{failed:!0,error:"INVALID_API_KEY"};let a=await e.getRepositoryUrl(),c=await new es({baseUrl:s,apiKey:n}).initialize({repository_url:a,powerlint_version:Ir(),schema_version:"v1"});if(c.invalid_api_key)return{failed:!0,error:"INVALID_API_KEY"};if(!c.is_valid_repository)return{failed:!0,error:"INVALID_REPOSITORY"};let l=c.config?.ignored_globs||[],u=new t({ignoredGlobs:l,apiKey:n,baseUrl:s},{});return u.llmProvider=new gn(u,e),u}isConfigured(){return this.getApiKey()!==null}};import{exec as VR,execSync as HR}from"child_process";import{existsSync as KR,readFileSync as YR}from"fs";import{promisify as XR}from"util";import{createHash as WR}from"crypto";function us(t){return WR("sha256").update(t).digest("hex")}var he=XR(VR);function $m(){return HR("git rev-parse --show-toplevel",{encoding:"utf-8"}).trim()}async function Tm(t){let{stdout:e}=await he("git ls-files --ignored --exclude-standard --others",{cwd:t,maxBuffer:52428800});return e.split(`
|
|
41
41
|
`).filter(Boolean).map(r=>r.trim())}async function Pm(t,e="origin"){let{stdout:r}=await he(`git config --get remote.${e}.url`,{cwd:t});return r.trim()||null}async function Im(t,e="origin"){try{let{stdout:r}=await he(`git rev-parse --abbrev-ref ${e}/HEAD`,{cwd:t});return r.trim().split("/").pop()||null}catch{let i=["main","master"];for(let s of i)try{return await he(`git rev-parse --verify ${s}`,{cwd:t}),s}catch{}return null}}async function Fm(t){let{stdout:e}=await he("git rev-parse --abbrev-ref --symbolic-full-name @{u}",{cwd:t});return e.trim()||void 0}function Nm(t,e){let r=`.git/refs/branch-metadata/${e}`,i=`${t}/${r}`;return KR(i)?YR(i,"utf-8").match(/"parent"\s*:\s*"([^"]+)"/)?.[1]:void 0}function st(t){return`'${t.replace(/'/g,"'\\''")}'`}function Kt(t){return t.map(st).join(" ")}function ZR(t){let e={committed:!0,staged:!0,unstaged:!0,untracked:!0};if(!t||t.length===0)return e;let r=new Set(t);return{committed:r.has("committed"),staged:r.has("staged"),unstaged:r.has("unstaged"),untracked:r.has("untracked")}}function Pn(t,e){if(!t)return[];let r=[],i=t.split("\0").filter(Boolean);for(let s=0;s<i.length;){let n=i[s];if(!n)break;if(n.startsWith("R")){let a=i[s+1],o=i[s+2];a&&o?(r.push({status:n,path:o,oldPath:a,source:e}),s+=3):s++}else{let a=i[s+1];a?(r.push({status:n,path:a,source:e}),s+=2):s++}}return r}function JR(t){return t?t.split("\0").filter(Boolean).map(e=>({status:"U",path:e,source:"untracked"})):[]}function QR(t){let e=new Map;for(let r of t){let i=e.get(r.path);if(!i)e.set(r.path,r);else{let s=Om(i.source),n=Om(r.source);n>s?e.set(r.path,r):n===s&&r.oldPath&&(i.oldPath=i.oldPath||r.oldPath)}}return Array.from(e.values())}function Om(t){switch(t){case"untracked":return 4;case"unstaged":return 3;case"staged":return 2;case"committed":return 1}}function kc(t){let e=new Map;if(!t)return e;let r=t.split(/^diff --git /m).filter(Boolean);for(let i of r){let a=i.split(`
|
|
42
42
|
`)[0].match(/a\/(.+?) b\//);if(a){let o=a[1];e.set(o,"diff --git "+i)}}return e}function eA(t){return t.status==="U"||t.status==="A"?"added":t.status==="D"?"removed":"modified"}function fs(t){if(!t)return"";let e=t.split(`
|
|
43
43
|
`),r=[],i=!1;for(let s of e)s.startsWith("diff --git")||s.startsWith("index ")||s.startsWith("--- ")||s.startsWith("+++ ")||s.startsWith("new file mode")||s.startsWith("deleted file mode")||s.startsWith("old mode")||s.startsWith("new mode")||s.startsWith("similarity index")||s.startsWith("rename from")||s.startsWith("rename to")||s.startsWith("copy from")||s.startsWith("copy to")||s==="\"||(s.startsWith("@@")&&(i=!0),i&&r.push(s));return r.join(`
|