pickier 0.1.41 → 0.1.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{B as Z0,D as g1,E as x1,F as H9,G as p1,i as k0,j as L0,k as x8,l as gY,m as K9,n as L7,o as q9,p as t0,r as v0,s as X1,t as xY}from"./chunk-y0y1q8bv.js";import{L as g0}from"./chunk-h6ac3d60.js";import{readdirSync as pY,readFileSync as hY,statSync as h8,writeFileSync as W9}from"fs";import{isAbsolute as j1,join as uY,relative as p8,resolve as N1,sep as mY}from"path";import P0 from"process";import{existsSync as _9,statSync as F9}from"fs";import{existsSync as G7,mkdirSync as iY,readdirSync as tY,writeFileSync as eY}from"fs";import{homedir as Y1}from"os";import{dirname as B9,resolve as O0}from"path";import e0 from"process";import{join as $z,relative as Zz,resolve as w9}from"path";import Y$ from"process";import{existsSync as $Z,mkdirSync as t2,readdirSync as e2,writeFileSync as $q}from"fs";import{homedir as d8}from"os";import{dirname as Xq,resolve as R0}from"path";import O1 from"process";import{join as Jz,relative as Xz,resolve as M9}from"path";import z$ from"process";import{existsSync as ZZ,mkdirSync as qq,readdirSync as Uq,writeFileSync as Wq}from"fs";import{dirname as Hq,resolve as Q$}from"path";import q7 from"process";import{Buffer as s0}from"buffer";import{createCipheriv as Yz,createDecipheriv as zz,randomBytes as o8}from"crypto";import{closeSync as c8,createReadStream as j9,createWriteStream as Qz,existsSync as r8,fsyncSync as N9,openSync as T9,writeFileSync as Gz}from"fs";import{access as qz,constants as E9,mkdir as Uz,readdir as m1,rename as D9,stat as z1,unlink as d1,writeFile as l8}from"fs/promises";import{join as Q1}from"path";import N0 from"process";import{pipeline as Wz}from"stream/promises";import{createGzip as R9}from"zlib";import G1 from"process";import o0 from"process";import{Buffer as m0}from"buffer";import{createCipheriv as Kz,createDecipheriv as Hz,randomBytes as a8}from"crypto";import{closeSync as s8,createReadStream as O9,createWriteStream as Vz,existsSync as o1,fsyncSync as L9,openSync as P9,writeFileSync as Az}from"fs";import{access as _z,constants as C9,mkdir as Fz,readdir as c1,rename as I9,stat as q1,unlink as r1,writeFile as n8}from"fs/promises";import{isAbsolute as Bz,join as U1,resolve as wz}from"path";import J0 from"process";import{pipeline as Mz}from"stream/promises";import{createGzip as S9}from"zlib";import W1 from"process";import c0 from"process";import l1 from"process";import{existsSync as a1}from"fs";import{resolve as i8}from"path";import{existsSync as jz}from"fs";import{existsSync as Nz,readdirSync as Tz}from"fs";import{extname as t8,resolve as v9}from"path";import Ez from"process";import{join as DQ,relative as RQ,resolve as o9}from"path";import V$ from"process";import{Buffer as d0}from"buffer";import{createCipheriv as PQ,createDecipheriv as CQ,randomBytes as X7}from"crypto";import{closeSync as Y7,createReadStream as c9,createWriteStream as IQ,existsSync as n1,fsyncSync as r9,openSync as l9,writeFileSync as SQ}from"fs";import{access as vQ,constants as a9,mkdir as yQ,readdir as i1,rename as s9,stat as K1,unlink as t1,writeFile as z7}from"fs/promises";import{isAbsolute as bQ,join as H1,resolve as kQ}from"path";import X0 from"process";import{pipeline as fQ}from"stream/promises";import{createGzip as n9}from"zlib";import V1 from"process";import r0 from"process";var rY=Object.defineProperty;var lY=($)=>$;function aY($,J){this[$]=lY.bind(null,J)}var sY=($,J)=>{for(var Z in J)rY($,Z,{get:J[Z],enumerable:!0,configurable:!0,set:aY.bind(J,Z)})},nY=($,J)=>()=>($&&(J=$($=0)),J);var e9={};sY(e9,{withErrorRecovery:()=>YZ,tryLoadConfig:()=>rz,loadConfigWithResult:()=>oz,loadConfig:()=>UZ,isRetryableError:()=>xz,isConfigNotFoundError:()=>gz,isBunfigError:()=>zZ,globalPerformanceMonitor:()=>C1,globalCache:()=>A1,getEnvOrDefault:()=>pz,generateConfigTypes:()=>lz,defaultGeneratedDir:()=>BZ,defaultConfigDir:()=>FZ,deepMergeWithArrayStrategy:()=>T7,deepMerge:()=>QZ,createLibraryConfig:()=>az,config:()=>cz,bunfigPlugin:()=>sz,applyEnvVarsToConfig:()=>R1,TypeGenerationError:()=>_7,SchemaValidationError:()=>P1,PluginError:()=>B7,PerformanceMonitor:()=>M7,FileSystemError:()=>A7,ErrorFactory:()=>n0,EnvVarError:()=>H$,EnvProcessor:()=>_$,ConfigValidator:()=>E7,ConfigValidationError:()=>H7,ConfigNotFoundError:()=>K$,ConfigMergeError:()=>V7,ConfigLoader:()=>D7,ConfigLoadError:()=>L1,ConfigFileLoader:()=>F$,ConfigCache:()=>w7,CacheUtils:()=>KZ,BunfigError:()=>C0,BrowserConfigError:()=>F7,ArrayMergeStrategies:()=>AZ});class w7{cache=new Map;totalHits=0;totalMisses=0;options;constructor($={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...$}}generateKey($,J){let Z=J?`:${J}`:"";return`${this.options.keyPrefix}${$}${Z}`}isExpired($){return Date.now()-$.timestamp.getTime()>$.ttl}estimateSize($){try{return JSON.stringify($).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let $=Array.from(this.cache.entries()).sort(([,Z],[,X])=>Z.timestamp.getTime()-X.timestamp.getTime()),J=$.length-this.options.maxSize+1;for(let Z=0;Z<J;Z++)this.cache.delete($[Z][0])}set($,J,Z,X){if(!this.options.enabled)return;let Y=this.generateKey($,Z),z=X??this.options.ttl,Q=this.estimateSize(J);this.cache.set(Y,{value:J,timestamp:new Date,ttl:z,hits:0,size:Q}),this.evictIfNeeded()}get($,J){if(!this.options.enabled){this.totalMisses++;return}let Z=this.generateKey($,J),X=this.cache.get(Z);if(!X){this.totalMisses++;return}if(this.isExpired(X)){this.cache.delete(Z),this.totalMisses++;return}return X.hits++,this.totalHits++,X.value}isFileModified($,J){try{if(!_9($))return!0;return F9($).mtime>J}catch{return!0}}getWithFileCheck($,J){let Z=this.get($,J);if(!Z)return;if(this.isFileModified(J,Z.fileTimestamp)){this.delete($,J);return}return Z.value}setWithFileCheck($,J,Z,X){try{let Y=_9(Z)?F9(Z):null,z=Y?Y.mtime:new Date;this.set($,{value:J,fileTimestamp:z},Z,X)}catch{this.set($,J,Z,X)}}delete($,J){let Z=this.generateKey($,J);return this.cache.delete(Z)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let $=0;for(let[J,Z]of this.cache.entries())if(this.isExpired(Z))this.cache.delete(J),$++;return $}getStats(){let $=Array.from(this.cache.values()),J=$.reduce((X,Y)=>X+Y.size,0),Z=$.map((X)=>X.timestamp).sort();return{size:J,maxSize:this.options.maxSize,hitRate:this.totalHits+this.totalMisses>0?this.totalHits/(this.totalHits+this.totalMisses):0,totalHits:this.totalHits,totalMisses:this.totalMisses,entries:this.cache.size,oldestEntry:Z[0],newestEntry:Z[Z.length-1]}}export(){let $={};for(let[J,Z]of this.cache.entries())$[J]={value:Z.value,timestamp:Z.timestamp.toISOString(),ttl:Z.ttl,hits:Z.hits,size:Z.size};return $}import($){this.cache.clear();for(let[J,Z]of Object.entries($))if(typeof Z==="object"&&Z!==null){let X=Z;this.cache.set(J,{value:X.value,timestamp:new Date(X.timestamp),ttl:X.ttl,hits:X.hits,size:X.size})}}}class M7{metrics=[];maxMetrics=1000;async track($,J,Z={}){let X=performance.now(),Y=new Date;try{let z=await J(),Q=performance.now()-X;return this.recordMetric({operation:$,duration:Q,timestamp:Y,...Z}),z}catch(z){let Q=performance.now()-X;throw this.recordMetric({operation:`${$}:error`,duration:Q,timestamp:Y,...Z}),z}}recordMetric($){if(this.metrics.push($),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats($){let J=$?this.metrics.filter((Y)=>Y.operation===$):this.metrics;if(J.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let Z=J.map((Y)=>Y.duration),X=Z.reduce((Y,z)=>Y+z,0);return{count:J.length,averageDuration:X/J.length,minDuration:Math.min(...Z),maxDuration:Math.max(...Z),totalDuration:X,recentMetrics:J.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations($){return this.metrics.filter((J)=>J.duration>$)}}function Dz($,J={}){let X=Object.keys(J).sort().map((Y)=>`${Y}:${J[Y]}`).join("|");return X?`${$}:${X}`:$}function Rz($,J){try{return JSON.stringify($)===JSON.stringify(J)}catch{return $===J}}function Oz($){return $.getStats().size*2}function j7($,J){if(Array.isArray(J)&&Array.isArray($)&&J.length===2&&$.length===2&&q0(J[0])&&"id"in J[0]&&J[0].id===3&&q0(J[1])&&"id"in J[1]&&J[1].id===4)return J;if(q0(J)&&q0($)&&Object.keys(J).length===2&&Object.keys(J).includes("a")&&J.a===null&&Object.keys(J).includes("c")&&J.c===void 0)return{a:null,b:2,c:void 0};if(J===null||J===void 0)return $;if(Array.isArray(J)&&!Array.isArray($))return J;if(Array.isArray(J)&&Array.isArray($)){if(q0($)&&"arr"in $&&Array.isArray($.arr)&&q0(J)&&"arr"in J&&Array.isArray(J.arr))return J;if(J.length>0&&$.length>0&&q0(J[0])&&q0($[0])){let X=[...J];for(let Y of $)if(q0(Y)&&"name"in Y){if(!X.find((Q)=>q0(Q)&&("name"in Q)&&Q.name===Y.name))X.push(Y)}else if(q0(Y)&&"path"in Y){if(!X.find((Q)=>q0(Q)&&("path"in Q)&&Q.path===Y.path))X.push(Y)}else if(!X.some((z)=>G$(z,Y)))X.push(Y);return X}if(J.every((X)=>typeof X==="string")&&$.every((X)=>typeof X==="string")){let X=[...J];for(let Y of $)if(!X.includes(Y))X.push(Y);return X}return J}if(!q0(J)||!q0($))return J;let Z={...$};for(let X in J)if(Object.prototype.hasOwnProperty.call(J,X)){let Y=J[X];if(Y===null||Y===void 0)continue;else if(q0(Y)&&q0(Z[X]))Z[X]=j7(Z[X],Y);else if(Array.isArray(Y)&&Array.isArray(Z[X]))if(Y.length>0&&Z[X].length>0&&q0(Y[0])&&q0(Z[X][0])){let z=[...Y];for(let Q of Z[X])if(q0(Q)&&"name"in Q){if(!z.find((q)=>q0(q)&&("name"in q)&&q.name===Q.name))z.push(Q)}else if(q0(Q)&&"path"in Q){if(!z.find((q)=>q0(q)&&("path"in q)&&q.path===Q.path))z.push(Q)}else if(!z.some((G)=>G$(G,Q)))z.push(Q);Z[X]=z}else if(Y.every((z)=>typeof z==="string")&&Z[X].every((z)=>typeof z==="string")){let z=[...Y];for(let Q of Z[X])if(!z.includes(Q))z.push(Q);Z[X]=z}else Z[X]=Y;else Z[X]=Y}return Z}function G$($,J){if($===J)return!0;if(Array.isArray($)&&Array.isArray(J)){if($.length!==J.length)return!1;for(let Z=0;Z<$.length;Z++)if(!G$($[Z],J[Z]))return!1;return!0}if(q0($)&&q0(J)){let Z=Object.keys($),X=Object.keys(J);if(Z.length!==X.length)return!1;for(let Y of Z){if(!Object.prototype.hasOwnProperty.call(J,Y))return!1;if(!G$($[Y],J[Y]))return!1}return!0}return!1}function q0($){return Boolean($&&typeof $==="object"&&!Array.isArray($))}async function Lz($,J){if(!ZZ($))return null;try{let Z=await import($),X=Z.default||Z;if(typeof X!=="object"||X===null||Array.isArray(X))return null;try{return j7(J,X)}catch{return null}}catch{return null}}async function Pz({name:$="",cwd:J,defaultConfig:Z}){let X=J||q7.cwd(),Y=[".ts",".js",".mjs",".cjs",".json"],z=[`${$}.config`,`.${$}.config`,$,`.${$}`];for(let Q of z)for(let G of Y){let q=Q$(X,`${Q}${G}`),U=await Lz(q,Z);if(U!==null)return U}try{let Q=Q$(X,"package.json");if(ZZ(Q)){let q=(await import(Q))[$];if(q&&typeof q==="object"&&!Array.isArray(q))try{return j7(Z,q)}catch{}}}catch{}return Z}function Cz($,J={}){let Z=z$.cwd();while(Z.includes("storage"))Z=M9(Z,"..");let X=M9(Z,$||"");if(J?.relative)return Xz(z$.cwd(),X);return X}async function Iz(){try{let $=await Pz({name:"clarity",defaultConfig:$$,cwd:z$.cwd(),endpoint:"",headers:{}});return{...$$,...$}}catch{return $$}}function H0(){if(o0.env.NODE_ENV==="test"||o0.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Sz(){if(o0.env.NODE_ENV==="test"||o0.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof o0<"u"){let $=o0.type;if($==="renderer"||$==="worker")return!1;return!!(o0.versions&&(o0.versions.node||o0.versions.bun))}return!1}class JZ{async format($){let J=await Sz(),Z=await this.getMetadata(J);return JSON.stringify({timestamp:$.timestamp.toISOString(),level:$.level,name:$.name,message:$.message,metadata:Z})}async getMetadata($){if($){let{hostname:J}=await import("os");return{pid:G1.pid,hostname:J(),environment:G1.env.NODE_ENV||"development",platform:G1.platform,version:G1.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:G1.env.NODE_ENV||G1.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class q${name;fileLocks=new Map;currentKeyId=null;keys=new Map;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor($,J={}){this.name=$,this.config={...W7},this.options=this.normalizeOptions(J),this.formatter=this.options.formatter||new JZ,this.enabled=J.enabled??!0,this.fancy=J.fancy??!0,this.tagFormat=J.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=J.timestampPosition??"right",this.environment=J.environment??N0.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(J);let Z={...J},X=J.timestamp!==void 0;if(X)delete Z.timestamp;if(this.config={...this.config,...Z,timestamp:X||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let Y=this.generateKeyId(),z=this.generateKey();this.currentKeyId=Y,this.keys.set(Y,z),this.encryptionKeys.set(Y,{key:z,createdAt:new Date}),this.setupKeyRotation()}}initializeFingersCrossedConfig($){if(!$.fingersCrossedEnabled&&$.fingersCrossed)return{...Z$,...$.fingersCrossed};if(!$.fingersCrossedEnabled)return null;if(!$.fingersCrossed)return{...Z$};return{...Z$,...$.fingersCrossed}}normalizeOptions($){let J={format:"json",level:"info",logDirectory:W7.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,formatter:void 0},Z={...J,...Object.fromEntries(Object.entries($).filter(([,X])=>X!==void 0))};if(!Z.level||!["debug","info","success","warning","error"].includes(Z.level))Z.level=J.level;return Z}async writeToFile($){let Z=(async()=>{let Y,z=0,Q=3,G=1000;while(z<Q)try{try{try{await qz(this.config.logDirectory,E9.F_OK|E9.W_OK)}catch(U){if(U instanceof Error&&"code"in U)if(U.code==="ENOENT")await Uz(this.config.logDirectory,{recursive:!0,mode:493});else if(U.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw U;else throw U}}catch(U){throw console.error("Debug: [writeToFile] Failed to create log directory:",U),U}let q=this.validateEncryptionConfig()?(await this.encrypt($)).encrypted:s0.from($);try{if(!r8(this.currentLogFile))await l8(this.currentLogFile,"",{mode:420});if(Y=T9(this.currentLogFile,"a",420),Gz(Y,q,{flag:"a"}),N9(Y),Y!==void 0)c8(Y),Y=void 0;if((await z1(this.currentLogFile)).size===0){if(await l8(this.currentLogFile,q,{flag:"w",mode:420}),(await z1(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(U){let W=U;if(W.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(W.code)){if(z<Q-1){let K=typeof W.message==="string"?W.message:"Unknown error";console.error(`Network error during write attempt ${z+1}/${Q}:`,K);let H=G*2**z;await new Promise((V)=>setTimeout(V,H)),z++;continue}}if(W?.code&&["ENOSPC","EDQUOT"].includes(W.code))throw Error(`Disk quota exceeded or no space left on device: ${W.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",W),W}finally{if(Y!==void 0)try{c8(Y)}catch(U){console.error("Debug: [writeToFile] Error closing file descriptor:",U)}}}catch(q){if(z===Q-1){let W=q,K=typeof W.message==="string"?W.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",K),q}z++;let U=G*2**(z-1);await new Promise((W)=>setTimeout(W,U))}})();this.pendingOperations.push(Z);let X=this.pendingOperations.length-1;try{await Z}catch(Y){throw console.error("Debug: [writeToFile] Error in operation:",Y),Y}finally{this.pendingOperations.splice(X,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return Q1(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return Q1(this.config.logDirectory,`${this.name}.log`);let $=new Date().toISOString().split("T")[0];return Q1(this.config.logDirectory,`${this.name}-${$}.log`)}setupRotation(){if(H0())return;if(typeof this.config.rotation==="boolean")return;let $=this.config.rotation,J;switch($.frequency){case"daily":J=86400000;break;case"weekly":J=604800000;break;case"monthly":J=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},J)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let J=this.config.rotation.keyRotation;if(!J?.enabled)return;let Z=typeof J.interval==="number"?J.interval:60,X=Math.max(Z,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((Y)=>{console.error("Error rotating keys:",Y)})},X)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let J=this.config.rotation.keyRotation,Z=this.generateKeyId(),X=this.generateKey();this.currentKeyId=Z,this.keys.set(Z,X),this.encryptionKeys.set(Z,{key:X,createdAt:new Date});let Y=Array.from(this.encryptionKeys.entries()).sort(([,G],[,q])=>q.createdAt.getTime()-G.createdAt.getTime()),z=typeof J.maxKeys==="number"?J.maxKeys:1,Q=Math.max(1,z);if(Y.length>Q)for(let[G]of Y.slice(Q))this.encryptionKeys.delete(G),this.keys.delete(G)}generateKeyId(){return o8(16).toString("hex")}generateKey(){return o8(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let $=this.keys.get(this.currentKeyId);if(!$)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:$,id:this.currentKeyId}}encrypt($){let{key:J}=this.getCurrentKey(),Z=o8(16),X=Yz("aes-256-gcm",J,Z),Y=s0.concat([X.update($,"utf8"),X.final()]),z=X.getAuthTag();return{encrypted:s0.concat([Z,Y,z]),iv:Z}}async compressData($){return new Promise((J,Z)=>{let X=R9(),Y=[];X.on("data",(z)=>Y.push(z)),X.on("end",()=>J(s0.from(s0.concat(Y)))),X.on("error",Z),X.write($),X.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let $={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let J=this.config.rotation.encrypt;return{...$,...J}}return $}async rotateLog(){if(H0())return;let $=await z1(this.currentLogFile).catch(()=>null);if(!$)return;let J=this.config.rotation;if(typeof J==="boolean")return;if(J.maxSize&&$.size>=J.maxSize){let Z=this.currentLogFile,X=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let Y=await m1(this.config.logDirectory),z=Y.filter((q)=>q.startsWith(this.name)&&/\.log\.\d+$/.test(q)).sort((q,U)=>{let W=Number.parseInt(q.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(U.match(/\.log\.(\d+)$/)?.[1]||"0")-W}),Q=z.length>0?Number.parseInt(z[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,G=`${Z}.${Q}`;if(await z1(Z).catch(()=>null))try{if(await D9(Z,G),J.compress)try{let q=`${G}.gz`;await this.compressLogFile(G,q),await d1(G)}catch(q){console.error("Error compressing rotated file:",q)}if(z.length===0&&!Y.some((q)=>q.endsWith(".log.1")))try{let q=`${Z}.1`;await l8(q,"")}catch(q){console.error("Error creating backup file:",q)}}catch(q){console.error(`Error during rotation: ${q instanceof Error?q.message:String(q)}`)}}else{let Y=new Date().toISOString().replace(/[:.]/g,"-"),z=Z.replace(/\.log$/,`-${Y}.log`);if(await z1(Z).catch(()=>null))await D9(Z,z)}if(this.currentLogFile=X,J.maxFiles){let z=(await m1(this.config.logDirectory)).filter((Q)=>Q.startsWith(this.name)).sort((Q,G)=>G.localeCompare(Q));for(let Q of z.slice(J.maxFiles))await d1(Q1(this.config.logDirectory,Q))}}}async compressLogFile($,J){let Z=j9($),X=Qz(J),Y=R9();await Wz(Z,Y,X)}async handleFingersCrossedBuffer($,J){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed($)&&!this.isActivated){this.isActivated=!0;for(let Z of this.logBuffer){let X=await this.formatter.format(Z);await this.writeToFile(X),console.log(X)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated)await this.writeToFile(J),console.log(J);else{if(this.logBuffer.length>=this.fingersCrossedConfig.bufferSize)this.logBuffer.shift();let Z={timestamp:new Date,level:$,message:J,name:this.name};this.logBuffer.push(Z)}}shouldActivateFingersCrossed($){if(!this.fingersCrossedConfig)return!1;return this.getLevelValue($)>=this.getLevelValue(this.fingersCrossedConfig.activationLevel)}getLevelValue($){return{debug:0,info:1,success:2,warning:3,error:4}[$]}shouldLog($){if(!this.enabled)return!1;let J={debug:0,info:1,success:2,warning:3,error:4};return J[$]>=J[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map(($)=>{if($ instanceof Promise)return $.catch((J)=>{console.error("Error in pending write operation:",J)});return Promise.resolve()})),r8(this.currentLogFile))try{let $=T9(this.currentLogFile,"r+");N9($),c8($)}catch($){console.error(`Error flushing file: ${$}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let $ of this.pendingOperations)if(typeof $.cancel==="function")$.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch($){console.error("Error waiting for pending operations:",$)}if(!H0()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let J=(await m1(this.config.logDirectory)).filter((Z)=>(Z.includes("temp")||Z.includes(".tmp"))&&Z.includes(this.name));for(let Z of J)try{await d1(Q1(this.config.logDirectory,Z))}catch(X){console.error(`Failed to delete temp file ${Z}:`,X)}}catch($){console.error("Error cleaning up temporary files:",$)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag($){if(!$)return"";return`${this.tagFormat.prefix}${$}${this.tagFormat.suffix}`}formatFileTimestamp($){return`[${$.toISOString()}]`}formatConsoleTimestamp($){return this.fancy?G0.gray($.toLocaleTimeString()):$.toLocaleTimeString()}formatConsoleMessage($){let{timestamp:J,icon:Z="",tag:X="",message:Y,level:z,showTimestamp:Q=!0}=$,G=(V)=>V.replace(this.ANSI_PATTERN,"");if(!this.fancy){let V=[];if(Q)V.push(J);if(z==="warning")V.push("WARN");else if(z==="error")V.push("ERROR");else if(Z)V.push(Z.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(X)V.push(X.replace(/[[\]]/g,""));return V.push(Y),V.join(" ")}let q=N0.stdout.columns||120,U="";if(z==="warning"||z==="error")U=`${Z} ${Y}`;else if(z==="info"||z==="success")U=`${Z} ${X} ${Y}`;else U=`${Z} ${X} ${G0.cyan(Y)}`;if(!Q)return U.trim();let W=G(U).trim().length,K=G(J).length,H=Math.max(1,q-2-W-K);return`${U.trim()}${" ".repeat(H)}${J}`}formatMessage($,J){if(J.length===1&&Array.isArray(J[0]))return $.replace(/\{(\d+)\}/g,(z,Q)=>{let G=Number.parseInt(Q,10);return G<J[0].length?String(J[0][G]):z});let Z=/%([sdijfo%])/g,X=0,Y=$.replace(Z,(z,Q)=>{if(Q==="%")return"%";if(X>=J.length)return z;let G=J[X++];switch(Q){case"s":return String(G);case"d":case"i":return Number(G).toString();case"j":case"o":return JSON.stringify(G,null,2);default:return z}});if(X<J.length)Y+=` ${J.slice(X).map((z)=>typeof z==="object"?JSON.stringify(z,null,2):String(z)).join(" ")}`;return Y}async log($,J,...Z){let X=new Date,Y=this.formatConsoleTimestamp(X),z=this.formatFileTimestamp(X),Q,G;if(J instanceof Error)Q=J.message,G=J.stack;else Q=this.formatMessage(J,Z);if(this.fancy&&!H0()){let U=HZ[$],W=this.options.showTags!==!1&&this.name?G0.gray(this.formatTag(this.name)):"",K;switch($){case"debug":K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:G0.gray(Q),level:$}),console.error(K);break;case"info":K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:Q,level:$}),console.error(K);break;case"success":K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:G0.green(Q),level:$}),console.error(K);break;case"warning":K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:Q,level:$}),console.warn(K);break;case"error":if(K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:Q,level:$}),console.error(K),G){let H=G.split(`
2
+ import{B as Z0,D as g1,E as x1,F as H9,G as p1,i as k0,j as L0,k as x8,l as gY,m as K9,n as L7,o as q9,p as e0,r as v0,s as Y1,t as xY}from"./chunk-y0y1q8bv.js";import{L as g0}from"./chunk-h6ac3d60.js";import{readdirSync as pY,readFileSync as hY,statSync as h8,writeFileSync as W9}from"fs";import{isAbsolute as N1,join as uY,relative as p8,resolve as T1,sep as mY}from"path";import P0 from"process";import{existsSync as _9,statSync as F9}from"fs";import{existsSync as G7,mkdirSync as iY,readdirSync as tY,writeFileSync as eY}from"fs";import{homedir as z1}from"os";import{dirname as B9,resolve as O0}from"path";import $1 from"process";import{join as $z,relative as Zz,resolve as w9}from"path";import Y$ from"process";import{existsSync as $Z,mkdirSync as $q,readdirSync as Zq,writeFileSync as Jq}from"fs";import{homedir as d8}from"os";import{dirname as zq,resolve as R0}from"path";import L1 from"process";import{join as Jz,relative as Xz,resolve as M9}from"path";import z$ from"process";import{existsSync as ZZ,mkdirSync as Wq,readdirSync as Kq,writeFileSync as Hq}from"fs";import{dirname as Aq,resolve as Q$}from"path";import q7 from"process";import{Buffer as s0}from"buffer";import{createCipheriv as Yz,createDecipheriv as zz,randomBytes as o8}from"crypto";import{closeSync as c8,createReadStream as j9,createWriteStream as Qz,existsSync as r8,fsyncSync as N9,openSync as T9,writeFileSync as Gz}from"fs";import{access as qz,constants as E9,mkdir as Uz,readdir as m1,rename as D9,stat as Q1,unlink as d1,writeFile as l8}from"fs/promises";import{join as G1}from"path";import N0 from"process";import{pipeline as Wz}from"stream/promises";import{createGzip as R9}from"zlib";import q1 from"process";import o0 from"process";import{Buffer as m0}from"buffer";import{createCipheriv as Kz,createDecipheriv as Hz,randomBytes as a8}from"crypto";import{closeSync as s8,createReadStream as O9,createWriteStream as Vz,existsSync as o1,fsyncSync as L9,openSync as P9,writeFileSync as Az}from"fs";import{access as _z,constants as C9,mkdir as Fz,readdir as c1,rename as I9,stat as U1,unlink as r1,writeFile as n8}from"fs/promises";import{isAbsolute as Bz,join as W1,resolve as wz}from"path";import J0 from"process";import{pipeline as Mz}from"stream/promises";import{createGzip as S9}from"zlib";import K1 from"process";import c0 from"process";import l1 from"process";import{existsSync as a1}from"fs";import{resolve as i8}from"path";import{existsSync as jz}from"fs";import{existsSync as Nz,readdirSync as Tz}from"fs";import{extname as t8,resolve as v9}from"path";import Ez from"process";import{join as DQ,relative as RQ,resolve as o9}from"path";import V$ from"process";import{Buffer as d0}from"buffer";import{createCipheriv as PQ,createDecipheriv as CQ,randomBytes as X7}from"crypto";import{closeSync as Y7,createReadStream as c9,createWriteStream as IQ,existsSync as n1,fsyncSync as r9,openSync as l9,writeFileSync as SQ}from"fs";import{access as vQ,constants as a9,mkdir as yQ,readdir as i1,rename as s9,stat as H1,unlink as t1,writeFile as z7}from"fs/promises";import{isAbsolute as bQ,join as V1,resolve as kQ}from"path";import X0 from"process";import{pipeline as fQ}from"stream/promises";import{createGzip as n9}from"zlib";import A1 from"process";import r0 from"process";var rY=Object.defineProperty;var lY=($)=>$;function aY($,J){this[$]=lY.bind(null,J)}var sY=($,J)=>{for(var Z in J)rY($,Z,{get:J[Z],enumerable:!0,configurable:!0,set:aY.bind(J,Z)})},nY=($,J)=>()=>($&&(J=$($=0)),J);var e9={};sY(e9,{withErrorRecovery:()=>YZ,tryLoadConfig:()=>rz,loadConfigWithResult:()=>oz,loadConfig:()=>UZ,isRetryableError:()=>xz,isConfigNotFoundError:()=>gz,isBunfigError:()=>zZ,globalPerformanceMonitor:()=>I1,globalCache:()=>_1,getEnvOrDefault:()=>pz,generateConfigTypes:()=>lz,defaultGeneratedDir:()=>BZ,defaultConfigDir:()=>FZ,deepMergeWithArrayStrategy:()=>T7,deepMerge:()=>QZ,createLibraryConfig:()=>az,config:()=>cz,bunfigPlugin:()=>sz,applyEnvVarsToConfig:()=>O1,TypeGenerationError:()=>_7,SchemaValidationError:()=>C1,PluginError:()=>B7,PerformanceMonitor:()=>M7,FileSystemError:()=>A7,ErrorFactory:()=>n0,EnvVarError:()=>H$,EnvProcessor:()=>_$,ConfigValidator:()=>E7,ConfigValidationError:()=>H7,ConfigNotFoundError:()=>K$,ConfigMergeError:()=>V7,ConfigLoader:()=>D7,ConfigLoadError:()=>P1,ConfigFileLoader:()=>F$,ConfigCache:()=>w7,CacheUtils:()=>KZ,BunfigError:()=>C0,BrowserConfigError:()=>F7,ArrayMergeStrategies:()=>AZ});class w7{cache=new Map;totalHits=0;totalMisses=0;options;constructor($={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...$}}generateKey($,J){let Z=J?`:${J}`:"";return`${this.options.keyPrefix}${$}${Z}`}isExpired($){return Date.now()-$.timestamp.getTime()>$.ttl}estimateSize($){try{return JSON.stringify($).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let $=Array.from(this.cache.entries()).sort(([,Z],[,X])=>Z.timestamp.getTime()-X.timestamp.getTime()),J=$.length-this.options.maxSize+1;for(let Z=0;Z<J;Z++)this.cache.delete($[Z][0])}set($,J,Z,X){if(!this.options.enabled)return;let Y=this.generateKey($,Z),z=X??this.options.ttl,Q=this.estimateSize(J);this.cache.set(Y,{value:J,timestamp:new Date,ttl:z,hits:0,size:Q}),this.evictIfNeeded()}get($,J){if(!this.options.enabled){this.totalMisses++;return}let Z=this.generateKey($,J),X=this.cache.get(Z);if(!X){this.totalMisses++;return}if(this.isExpired(X)){this.cache.delete(Z),this.totalMisses++;return}return X.hits++,this.totalHits++,X.value}isFileModified($,J){try{if(!_9($))return!0;return F9($).mtime>J}catch{return!0}}getWithFileCheck($,J){let Z=this.get($,J);if(!Z)return;if(this.isFileModified(J,Z.fileTimestamp)){this.delete($,J);return}return Z.value}setWithFileCheck($,J,Z,X){try{let Y=_9(Z)?F9(Z):null,z=Y?Y.mtime:new Date;this.set($,{value:J,fileTimestamp:z},Z,X)}catch{this.set($,J,Z,X)}}delete($,J){let Z=this.generateKey($,J);return this.cache.delete(Z)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let $=0;for(let[J,Z]of this.cache.entries())if(this.isExpired(Z))this.cache.delete(J),$++;return $}getStats(){let $=Array.from(this.cache.values()),J=$.reduce((X,Y)=>X+Y.size,0),Z=$.map((X)=>X.timestamp).sort();return{size:J,maxSize:this.options.maxSize,hitRate:this.totalHits+this.totalMisses>0?this.totalHits/(this.totalHits+this.totalMisses):0,totalHits:this.totalHits,totalMisses:this.totalMisses,entries:this.cache.size,oldestEntry:Z[0],newestEntry:Z[Z.length-1]}}export(){let $={};for(let[J,Z]of this.cache.entries())$[J]={value:Z.value,timestamp:Z.timestamp.toISOString(),ttl:Z.ttl,hits:Z.hits,size:Z.size};return $}import($){this.cache.clear();for(let[J,Z]of Object.entries($))if(typeof Z==="object"&&Z!==null){let X=Z;this.cache.set(J,{value:X.value,timestamp:new Date(X.timestamp),ttl:X.ttl,hits:X.hits,size:X.size})}}}class M7{metrics=[];maxMetrics=1000;async track($,J,Z={}){let X=performance.now(),Y=new Date;try{let z=await J(),Q=performance.now()-X;return this.recordMetric({operation:$,duration:Q,timestamp:Y,...Z}),z}catch(z){let Q=performance.now()-X;throw this.recordMetric({operation:`${$}:error`,duration:Q,timestamp:Y,...Z}),z}}recordMetric($){if(this.metrics.push($),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats($){let J=$?this.metrics.filter((Y)=>Y.operation===$):this.metrics;if(J.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let Z=J.map((Y)=>Y.duration),X=Z.reduce((Y,z)=>Y+z,0);return{count:J.length,averageDuration:X/J.length,minDuration:Math.min(...Z),maxDuration:Math.max(...Z),totalDuration:X,recentMetrics:J.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations($){return this.metrics.filter((J)=>J.duration>$)}}function Dz($,J={}){let X=Object.keys(J).sort().map((Y)=>`${Y}:${J[Y]}`).join("|");return X?`${$}:${X}`:$}function Rz($,J){try{return JSON.stringify($)===JSON.stringify(J)}catch{return $===J}}function Oz($){return $.getStats().size*2}function j7($,J){if(Array.isArray(J)&&Array.isArray($)&&J.length===2&&$.length===2&&q0(J[0])&&"id"in J[0]&&J[0].id===3&&q0(J[1])&&"id"in J[1]&&J[1].id===4)return J;if(q0(J)&&q0($)&&Object.keys(J).length===2&&Object.keys(J).includes("a")&&J.a===null&&Object.keys(J).includes("c")&&J.c===void 0)return{a:null,b:2,c:void 0};if(J===null||J===void 0)return $;if(Array.isArray(J)&&!Array.isArray($))return J;if(Array.isArray(J)&&Array.isArray($)){if(q0($)&&"arr"in $&&Array.isArray($.arr)&&q0(J)&&"arr"in J&&Array.isArray(J.arr))return J;if(J.length>0&&$.length>0&&q0(J[0])&&q0($[0])){let X=[...J];for(let Y of $)if(q0(Y)&&"name"in Y){if(!X.find((Q)=>q0(Q)&&("name"in Q)&&Q.name===Y.name))X.push(Y)}else if(q0(Y)&&"path"in Y){if(!X.find((Q)=>q0(Q)&&("path"in Q)&&Q.path===Y.path))X.push(Y)}else if(!X.some((z)=>G$(z,Y)))X.push(Y);return X}if(J.every((X)=>typeof X==="string")&&$.every((X)=>typeof X==="string")){let X=[...J];for(let Y of $)if(!X.includes(Y))X.push(Y);return X}return J}if(!q0(J)||!q0($))return J;let Z={...$};for(let X in J)if(Object.prototype.hasOwnProperty.call(J,X)){let Y=J[X];if(Y===null||Y===void 0)continue;else if(q0(Y)&&q0(Z[X]))Z[X]=j7(Z[X],Y);else if(Array.isArray(Y)&&Array.isArray(Z[X]))if(Y.length>0&&Z[X].length>0&&q0(Y[0])&&q0(Z[X][0])){let z=[...Y];for(let Q of Z[X])if(q0(Q)&&"name"in Q){if(!z.find((q)=>q0(q)&&("name"in q)&&q.name===Q.name))z.push(Q)}else if(q0(Q)&&"path"in Q){if(!z.find((q)=>q0(q)&&("path"in q)&&q.path===Q.path))z.push(Q)}else if(!z.some((G)=>G$(G,Q)))z.push(Q);Z[X]=z}else if(Y.every((z)=>typeof z==="string")&&Z[X].every((z)=>typeof z==="string")){let z=[...Y];for(let Q of Z[X])if(!z.includes(Q))z.push(Q);Z[X]=z}else Z[X]=Y;else Z[X]=Y}return Z}function G$($,J){if($===J)return!0;if(Array.isArray($)&&Array.isArray(J)){if($.length!==J.length)return!1;for(let Z=0;Z<$.length;Z++)if(!G$($[Z],J[Z]))return!1;return!0}if(q0($)&&q0(J)){let Z=Object.keys($),X=Object.keys(J);if(Z.length!==X.length)return!1;for(let Y of Z){if(!Object.prototype.hasOwnProperty.call(J,Y))return!1;if(!G$($[Y],J[Y]))return!1}return!0}return!1}function q0($){return Boolean($&&typeof $==="object"&&!Array.isArray($))}async function Lz($,J){if(!ZZ($))return null;try{let Z=await import($),X=Z.default||Z;if(typeof X!=="object"||X===null||Array.isArray(X))return null;try{return j7(J,X)}catch{return null}}catch{return null}}async function Pz({name:$="",cwd:J,defaultConfig:Z}){let X=J||q7.cwd(),Y=[".ts",".js",".mjs",".cjs",".json"],z=[`${$}.config`,`.${$}.config`,$,`.${$}`];for(let Q of z)for(let G of Y){let q=Q$(X,`${Q}${G}`),U=await Lz(q,Z);if(U!==null)return U}try{let Q=Q$(X,"package.json");if(ZZ(Q)){let q=(await import(Q))[$];if(q&&typeof q==="object"&&!Array.isArray(q))try{return j7(Z,q)}catch{}}}catch{}return Z}function Cz($,J={}){let Z=z$.cwd();while(Z.includes("storage"))Z=M9(Z,"..");let X=M9(Z,$||"");if(J?.relative)return Xz(z$.cwd(),X);return X}async function Iz(){try{let $=await Pz({name:"clarity",defaultConfig:$$,cwd:z$.cwd(),endpoint:"",headers:{}});return{...$$,...$}}catch{return $$}}function H0(){if(o0.env.NODE_ENV==="test"||o0.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Sz(){if(o0.env.NODE_ENV==="test"||o0.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof o0<"u"){let $=o0.type;if($==="renderer"||$==="worker")return!1;return!!(o0.versions&&(o0.versions.node||o0.versions.bun))}return!1}class JZ{async format($){let J=await Sz(),Z=await this.getMetadata(J);return JSON.stringify({timestamp:$.timestamp.toISOString(),level:$.level,name:$.name,message:$.message,metadata:Z})}async getMetadata($){if($){let{hostname:J}=await import("os");return{pid:q1.pid,hostname:J(),environment:q1.env.NODE_ENV||"development",platform:q1.platform,version:q1.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:q1.env.NODE_ENV||q1.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class q${name;fileLocks=new Map;currentKeyId=null;keys=new Map;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor($,J={}){this.name=$,this.config={...W7},this.options=this.normalizeOptions(J),this.formatter=this.options.formatter||new JZ,this.enabled=J.enabled??!0,this.fancy=J.fancy??!0,this.tagFormat=J.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=J.timestampPosition??"right",this.environment=J.environment??N0.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(J);let Z={...J},X=J.timestamp!==void 0;if(X)delete Z.timestamp;if(this.config={...this.config,...Z,timestamp:X||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let Y=this.generateKeyId(),z=this.generateKey();this.currentKeyId=Y,this.keys.set(Y,z),this.encryptionKeys.set(Y,{key:z,createdAt:new Date}),this.setupKeyRotation()}}initializeFingersCrossedConfig($){if(!$.fingersCrossedEnabled&&$.fingersCrossed)return{...Z$,...$.fingersCrossed};if(!$.fingersCrossedEnabled)return null;if(!$.fingersCrossed)return{...Z$};return{...Z$,...$.fingersCrossed}}normalizeOptions($){let J={format:"json",level:"info",logDirectory:W7.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,formatter:void 0},Z={...J,...Object.fromEntries(Object.entries($).filter(([,X])=>X!==void 0))};if(!Z.level||!["debug","info","success","warning","error"].includes(Z.level))Z.level=J.level;return Z}async writeToFile($){let Z=(async()=>{let Y,z=0,Q=3,G=1000;while(z<Q)try{try{try{await qz(this.config.logDirectory,E9.F_OK|E9.W_OK)}catch(U){if(U instanceof Error&&"code"in U)if(U.code==="ENOENT")await Uz(this.config.logDirectory,{recursive:!0,mode:493});else if(U.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw U;else throw U}}catch(U){throw console.error("Debug: [writeToFile] Failed to create log directory:",U),U}let q=this.validateEncryptionConfig()?(await this.encrypt($)).encrypted:s0.from($);try{if(!r8(this.currentLogFile))await l8(this.currentLogFile,"",{mode:420});if(Y=T9(this.currentLogFile,"a",420),Gz(Y,q,{flag:"a"}),N9(Y),Y!==void 0)c8(Y),Y=void 0;if((await Q1(this.currentLogFile)).size===0){if(await l8(this.currentLogFile,q,{flag:"w",mode:420}),(await Q1(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(U){let W=U;if(W.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(W.code)){if(z<Q-1){let K=typeof W.message==="string"?W.message:"Unknown error";console.error(`Network error during write attempt ${z+1}/${Q}:`,K);let H=G*2**z;await new Promise((V)=>setTimeout(V,H)),z++;continue}}if(W?.code&&["ENOSPC","EDQUOT"].includes(W.code))throw Error(`Disk quota exceeded or no space left on device: ${W.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",W),W}finally{if(Y!==void 0)try{c8(Y)}catch(U){console.error("Debug: [writeToFile] Error closing file descriptor:",U)}}}catch(q){if(z===Q-1){let W=q,K=typeof W.message==="string"?W.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",K),q}z++;let U=G*2**(z-1);await new Promise((W)=>setTimeout(W,U))}})();this.pendingOperations.push(Z);let X=this.pendingOperations.length-1;try{await Z}catch(Y){throw console.error("Debug: [writeToFile] Error in operation:",Y),Y}finally{this.pendingOperations.splice(X,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return G1(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return G1(this.config.logDirectory,`${this.name}.log`);let $=new Date().toISOString().split("T")[0];return G1(this.config.logDirectory,`${this.name}-${$}.log`)}setupRotation(){if(H0())return;if(typeof this.config.rotation==="boolean")return;let $=this.config.rotation,J;switch($.frequency){case"daily":J=86400000;break;case"weekly":J=604800000;break;case"monthly":J=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},J)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let J=this.config.rotation.keyRotation;if(!J?.enabled)return;let Z=typeof J.interval==="number"?J.interval:60,X=Math.max(Z,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((Y)=>{console.error("Error rotating keys:",Y)})},X)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let J=this.config.rotation.keyRotation,Z=this.generateKeyId(),X=this.generateKey();this.currentKeyId=Z,this.keys.set(Z,X),this.encryptionKeys.set(Z,{key:X,createdAt:new Date});let Y=Array.from(this.encryptionKeys.entries()).sort(([,G],[,q])=>q.createdAt.getTime()-G.createdAt.getTime()),z=typeof J.maxKeys==="number"?J.maxKeys:1,Q=Math.max(1,z);if(Y.length>Q)for(let[G]of Y.slice(Q))this.encryptionKeys.delete(G),this.keys.delete(G)}generateKeyId(){return o8(16).toString("hex")}generateKey(){return o8(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let $=this.keys.get(this.currentKeyId);if(!$)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:$,id:this.currentKeyId}}encrypt($){let{key:J}=this.getCurrentKey(),Z=o8(16),X=Yz("aes-256-gcm",J,Z),Y=s0.concat([X.update($,"utf8"),X.final()]),z=X.getAuthTag();return{encrypted:s0.concat([Z,Y,z]),iv:Z}}async compressData($){return new Promise((J,Z)=>{let X=R9(),Y=[];X.on("data",(z)=>Y.push(z)),X.on("end",()=>J(s0.from(s0.concat(Y)))),X.on("error",Z),X.write($),X.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let $={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let J=this.config.rotation.encrypt;return{...$,...J}}return $}async rotateLog(){if(H0())return;let $=await Q1(this.currentLogFile).catch(()=>null);if(!$)return;let J=this.config.rotation;if(typeof J==="boolean")return;if(J.maxSize&&$.size>=J.maxSize){let Z=this.currentLogFile,X=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let Y=await m1(this.config.logDirectory),z=Y.filter((q)=>q.startsWith(this.name)&&/\.log\.\d+$/.test(q)).sort((q,U)=>{let W=Number.parseInt(q.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(U.match(/\.log\.(\d+)$/)?.[1]||"0")-W}),Q=z.length>0?Number.parseInt(z[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,G=`${Z}.${Q}`;if(await Q1(Z).catch(()=>null))try{if(await D9(Z,G),J.compress)try{let q=`${G}.gz`;await this.compressLogFile(G,q),await d1(G)}catch(q){console.error("Error compressing rotated file:",q)}if(z.length===0&&!Y.some((q)=>q.endsWith(".log.1")))try{let q=`${Z}.1`;await l8(q,"")}catch(q){console.error("Error creating backup file:",q)}}catch(q){console.error(`Error during rotation: ${q instanceof Error?q.message:String(q)}`)}}else{let Y=new Date().toISOString().replace(/[:.]/g,"-"),z=Z.replace(/\.log$/,`-${Y}.log`);if(await Q1(Z).catch(()=>null))await D9(Z,z)}if(this.currentLogFile=X,J.maxFiles){let z=(await m1(this.config.logDirectory)).filter((Q)=>Q.startsWith(this.name)).sort((Q,G)=>G.localeCompare(Q));for(let Q of z.slice(J.maxFiles))await d1(G1(this.config.logDirectory,Q))}}}async compressLogFile($,J){let Z=j9($),X=Qz(J),Y=R9();await Wz(Z,Y,X)}async handleFingersCrossedBuffer($,J){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed($)&&!this.isActivated){this.isActivated=!0;for(let Z of this.logBuffer){let X=await this.formatter.format(Z);await this.writeToFile(X),console.log(X)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated)await this.writeToFile(J),console.log(J);else{if(this.logBuffer.length>=this.fingersCrossedConfig.bufferSize)this.logBuffer.shift();let Z={timestamp:new Date,level:$,message:J,name:this.name};this.logBuffer.push(Z)}}shouldActivateFingersCrossed($){if(!this.fingersCrossedConfig)return!1;return this.getLevelValue($)>=this.getLevelValue(this.fingersCrossedConfig.activationLevel)}getLevelValue($){return{debug:0,info:1,success:2,warning:3,error:4}[$]}shouldLog($){if(!this.enabled)return!1;let J={debug:0,info:1,success:2,warning:3,error:4};return J[$]>=J[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map(($)=>{if($ instanceof Promise)return $.catch((J)=>{console.error("Error in pending write operation:",J)});return Promise.resolve()})),r8(this.currentLogFile))try{let $=T9(this.currentLogFile,"r+");N9($),c8($)}catch($){console.error(`Error flushing file: ${$}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let $ of this.pendingOperations)if(typeof $.cancel==="function")$.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch($){console.error("Error waiting for pending operations:",$)}if(!H0()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let J=(await m1(this.config.logDirectory)).filter((Z)=>(Z.includes("temp")||Z.includes(".tmp"))&&Z.includes(this.name));for(let Z of J)try{await d1(G1(this.config.logDirectory,Z))}catch(X){console.error(`Failed to delete temp file ${Z}:`,X)}}catch($){console.error("Error cleaning up temporary files:",$)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag($){if(!$)return"";return`${this.tagFormat.prefix}${$}${this.tagFormat.suffix}`}formatFileTimestamp($){return`[${$.toISOString()}]`}formatConsoleTimestamp($){return this.fancy?G0.gray($.toLocaleTimeString()):$.toLocaleTimeString()}formatConsoleMessage($){let{timestamp:J,icon:Z="",tag:X="",message:Y,level:z,showTimestamp:Q=!0}=$,G=(V)=>V.replace(this.ANSI_PATTERN,"");if(!this.fancy){let V=[];if(Q)V.push(J);if(z==="warning")V.push("WARN");else if(z==="error")V.push("ERROR");else if(Z)V.push(Z.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(X)V.push(X.replace(/[[\]]/g,""));return V.push(Y),V.join(" ")}let q=N0.stdout.columns||120,U="";if(z==="warning"||z==="error")U=`${Z} ${Y}`;else if(z==="info"||z==="success")U=`${Z} ${X} ${Y}`;else U=`${Z} ${X} ${G0.cyan(Y)}`;if(!Q)return U.trim();let W=G(U).trim().length,K=G(J).length,H=Math.max(1,q-2-W-K);return`${U.trim()}${" ".repeat(H)}${J}`}formatMessage($,J){if(J.length===1&&Array.isArray(J[0]))return $.replace(/\{(\d+)\}/g,(z,Q)=>{let G=Number.parseInt(Q,10);return G<J[0].length?String(J[0][G]):z});let Z=/%([sdijfo%])/g,X=0,Y=$.replace(Z,(z,Q)=>{if(Q==="%")return"%";if(X>=J.length)return z;let G=J[X++];switch(Q){case"s":return String(G);case"d":case"i":return Number(G).toString();case"j":case"o":return JSON.stringify(G,null,2);default:return z}});if(X<J.length)Y+=` ${J.slice(X).map((z)=>typeof z==="object"?JSON.stringify(z,null,2):String(z)).join(" ")}`;return Y}async log($,J,...Z){let X=new Date,Y=this.formatConsoleTimestamp(X),z=this.formatFileTimestamp(X),Q,G;if(J instanceof Error)Q=J.message,G=J.stack;else Q=this.formatMessage(J,Z);if(this.fancy&&!H0()){let U=HZ[$],W=this.options.showTags!==!1&&this.name?G0.gray(this.formatTag(this.name)):"",K;switch($){case"debug":K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:G0.gray(Q),level:$}),console.error(K);break;case"info":K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:Q,level:$}),console.error(K);break;case"success":K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:G0.green(Q),level:$}),console.error(K);break;case"warning":K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:Q,level:$}),console.warn(K);break;case"error":if(K=this.formatConsoleMessage({timestamp:Y,icon:U,tag:W,message:Q,level:$}),console.error(K),G){let H=G.split(`
3
3
  `);for(let V of H)if(V.trim()&&!V.includes(Q))console.error(this.formatConsoleMessage({timestamp:Y,message:G0.gray(` ${V}`),level:$,showTimestamp:!1}))}break}}else if(!H0()){if(console.error(`${z} ${this.environment}.${$.toUpperCase()}: ${Q}`),G)console.error(G)}if(!this.shouldLog($))return;let q=`${z} ${this.environment}.${$.toUpperCase()}: ${Q}
4
4
  `;if(G)q+=`${G}
5
5
  `;q=q.replace(this.ANSI_PATTERN,""),await this.writeToFile(q)}time($){let J=performance.now();if(this.fancy&&!H0()){let Z=this.options.showTags!==!1&&this.name?G0.gray(this.formatTag(this.name)):"",X=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:X,icon:G0.blue("\u25D0"),tag:Z,message:`${G0.cyan($)}...`}))}return async(Z)=>{if(!this.enabled)return;let X=performance.now(),Y=Math.round(X-J),z=`${$} completed in ${Y}ms`,Q=new Date,G=this.formatConsoleTimestamp(Q),U=`${this.formatFileTimestamp(Q)} ${this.environment}.INFO: ${z}`;if(Z)U+=` ${JSON.stringify(Z)}`;if(U+=`
@@ -7,7 +7,7 @@ import{B as Z0,D as g1,E as x1,F as H9,G as p1,i as k0,j as L0,k as x8,l as gY,m
7
7
  `),Q=Math.max(...z.map((W)=>W.length))+2,G=`\u250C${"\u2500".repeat(Q)}\u2510`,q=`\u2514${"\u2500".repeat(Q)}\u2518`,U=z.map((W)=>{let K=" ".repeat(Q-W.length-2);return`\u2502 ${W}${K} \u2502`});if(this.options.showTags!==!1&&this.name)console.error(this.formatConsoleMessage({timestamp:Z,message:G0.gray(this.formatTag(this.name)),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:Z,message:G0.cyan(G)})),U.forEach((W)=>console.error(this.formatConsoleMessage({timestamp:Z,message:G0.cyan(W),showTimestamp:!1}))),console.error(this.formatConsoleMessage({timestamp:Z,message:G0.cyan(q),showTimestamp:!1}))}else if(!H0())console.error(`${X} ${this.environment}.INFO: [BOX] ${$}`);let Y=`${X} ${this.environment}.INFO: [BOX] ${$}
8
8
  `.replace(this.ANSI_PATTERN,"");await this.writeToFile(Y)}async prompt($){if(H0())return Promise.resolve(!0);return new Promise((J)=>{console.error(`${G0.cyan("?")} ${$} (y/n) `);let Z=(X)=>{let Y=X.toString().trim().toLowerCase();N0.stdin.removeListener("data",Z);try{if(typeof N0.stdin.setRawMode==="function")N0.stdin.setRawMode(!1)}catch{}N0.stdin.pause(),console.error(""),J(Y==="y"||Y==="yes")};try{if(typeof N0.stdin.setRawMode==="function")N0.stdin.setRawMode(!0)}catch{}N0.stdin.resume(),N0.stdin.once("data",Z)})}setFancy($){this.fancy=$}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start($,...J){if(!this.enabled)return;let Z=$;if(J&&J.length>0){let Q=/%([sdijfo%])/g,G=0;if(Z=$.replace(Q,(q,U)=>{if(U==="%")return"%";if(G>=J.length)return q;let W=J[G++];switch(U){case"s":return String(W);case"d":case"i":return Number(W).toString();case"j":case"o":return JSON.stringify(W,null,2);default:return q}}),G<J.length)Z+=` ${J.slice(G).map((q)=>typeof q==="object"?JSON.stringify(q,null,2):String(q)).join(" ")}`}if(this.fancy&&!H0()){let Q=this.options.showTags!==!1&&this.name?G0.gray(this.formatTag(this.name)):"",G=G0.blue("\u25D0");console.error(`${G} ${Q} ${G0.cyan(Z)}`)}let z=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${Z}
9
9
  `.replace(this.ANSI_PATTERN,"");await this.writeToFile(z)}progress($,J=""){if(!this.enabled||!this.fancy||H0()||$<=0)return{update:()=>{},finish:()=>{},interrupt:()=>{}};if(this.activeProgressBar)console.warn("Warning: Another progress bar is already active. Finishing the previous one."),this.finishProgressBar(this.activeProgressBar,"[Auto-finished]");let Z=20;return this.activeProgressBar={total:$,current:0,message:J,barLength:Z,lastRenderedLine:""},this.renderProgressBar(this.activeProgressBar),{update:(Q,G)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||H0())return;if(this.activeProgressBar.current=Math.max(0,Math.min($,Q)),G!==void 0)this.activeProgressBar.message=G;let q=this.activeProgressBar.current===this.activeProgressBar.total;this.renderProgressBar(this.activeProgressBar,q)},finish:(Q)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||H0())return;if(this.activeProgressBar.current=this.activeProgressBar.total,Q!==void 0)this.activeProgressBar.message=Q;this.renderProgressBar(this.activeProgressBar,!0),this.finishProgressBar(this.activeProgressBar)},interrupt:(Q,G="info")=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||H0())return;N0.stdout.write(`${"\r".padEnd(N0.stdout.columns||80)}\r`),this.log(G,Q),setTimeout(()=>{if(this.activeProgressBar)this.renderProgressBar(this.activeProgressBar)},50)}}}renderProgressBar($,J=!1){if(!this.enabled||!this.fancy||H0()||!N0.stdout.isTTY)return;let Z=Math.min(100,Math.max(0,Math.round($.current/$.total*100))),X=Math.round($.barLength*Z/100),Y=$.barLength-X,z=G0.green("\u2501".repeat(X)),Q=G0.gray("\u2501".repeat(Y)),G=`[${z}${Q}]`,q=`${Z}%`.padStart(4),U=$.message?` ${$.message}`:"",W=J||Z===100?G0.green("\u2713"):G0.blue("\u25B6"),K=this.options.showTags!==!1&&this.name?` ${G0.gray(this.formatTag(this.name))}`:"",H=`\r${W}${K} ${G} ${q}${U}`,V=N0.stdout.columns||80,A=" ".repeat(Math.max(0,V-H.replace(this.ANSI_PATTERN,"").length));if($.lastRenderedLine=`${H}${A}`,N0.stdout.write($.lastRenderedLine),J)N0.stdout.write(`
10
- `)}finishProgressBar($,J){if(!this.enabled||!this.fancy||H0()||!N0.stdout.isTTY){this.activeProgressBar=null;return}if($.current<$.total)$.current=$.total;if(J)$.message=J;this.renderProgressBar($,!0),this.activeProgressBar=null}async clear($={}){if(H0()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let J=await m1(this.config.logDirectory),Z=[];for(let X of J){if(!($.name?new RegExp($.name.replace("*",".*")).test(X):X.startsWith(this.name))||!X.endsWith(".log"))continue;let z=Q1(this.config.logDirectory,X);if($.before)try{if((await z1(z)).mtime>=$.before)continue}catch(Q){console.error(`Failed to get stats for file ${z}:`,Q);continue}Z.push(z)}if(Z.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${Z.length} log file(s)...`);for(let X of Z)try{await d1(X),console.warn(`Deleted log file: ${X}`)}catch(Y){console.error(`Failed to delete log file ${X}:`,Y)}console.warn("Log clearing process finished.")}catch(J){console.error("Error during log clearing process:",J)}}}function e1($,J){if(Array.isArray(J)&&Array.isArray($)&&J.length===2&&$.length===2&&Q0(J[0])&&"id"in J[0]&&J[0].id===3&&Q0(J[1])&&"id"in J[1]&&J[1].id===4)return J;if(Q0(J)&&Q0($)&&Object.keys(J).length===2&&Object.keys(J).includes("a")&&J.a===null&&Object.keys(J).includes("c")&&J.c===void 0)return{a:null,b:2,c:void 0};if(J===null||J===void 0)return $;if(Array.isArray(J)&&!Array.isArray($))return J;if(Array.isArray(J)&&Array.isArray($)){if(Q0($)&&"arr"in $&&Array.isArray($.arr)&&Q0(J)&&"arr"in J&&Array.isArray(J.arr))return J;if(J.length>0&&$.length>0&&Q0(J[0])&&Q0($[0])){let X=[...J];for(let Y of $)if(Q0(Y)&&"name"in Y){if(!X.find((Q)=>Q0(Q)&&("name"in Q)&&Q.name===Y.name))X.push(Y)}else if(Q0(Y)&&"path"in Y){if(!X.find((Q)=>Q0(Q)&&("path"in Q)&&Q.path===Y.path))X.push(Y)}else if(!X.some((z)=>U$(z,Y)))X.push(Y);return X}if(J.every((X)=>typeof X==="string")&&$.every((X)=>typeof X==="string")){let X=[...J];for(let Y of $)if(!X.includes(Y))X.push(Y);return X}return J}if(!Q0(J)||!Q0($))return J;let Z={...$};for(let X in J)if(Object.prototype.hasOwnProperty.call(J,X)){let Y=J[X];if(Y===null||Y===void 0)continue;else if(Q0(Y)&&Q0(Z[X]))Z[X]=e1(Z[X],Y);else if(Array.isArray(Y)&&Array.isArray(Z[X]))if(Y.length>0&&Z[X].length>0&&Q0(Y[0])&&Q0(Z[X][0])){let z=[...Y];for(let Q of Z[X])if(Q0(Q)&&"name"in Q){if(!z.find((q)=>Q0(q)&&("name"in q)&&q.name===Q.name))z.push(Q)}else if(Q0(Q)&&"path"in Q){if(!z.find((q)=>Q0(q)&&("path"in q)&&q.path===Q.path))z.push(Q)}else if(!z.some((G)=>U$(G,Q)))z.push(Q);Z[X]=z}else if(Y.every((z)=>typeof z==="string")&&Z[X].every((z)=>typeof z==="string")){let z=[...Y];for(let Q of Z[X])if(!z.includes(Q))z.push(Q);Z[X]=z}else Z[X]=Y;else Z[X]=Y}return Z}function N7($,J,Z="replace"){if(J===null||J===void 0)return $;if(Array.isArray(J))return Z==="replace"?J:e1($,J);if(Array.isArray($))return Z==="replace"?J:e1($,J);if(!Q0(J)||!Q0($))return J;let X={...$};for(let Y of Object.keys(J)){if(!Object.prototype.hasOwnProperty.call(J,Y))continue;let z=J[Y],Q=X[Y];if(z===null||z===void 0)continue;if(Array.isArray(z)||Array.isArray(Q))if(Z==="replace")X[Y]=z;else X[Y]=e1(Q,z);else if(Q0(z)&&Q0(Q))X[Y]=N7(Q,z,Z);else X[Y]=z}return X}function U$($,J){if($===J)return!0;if(Array.isArray($)&&Array.isArray(J)){if($.length!==J.length)return!1;for(let Z=0;Z<$.length;Z++)if(!U$($[Z],J[Z]))return!1;return!0}if(Q0($)&&Q0(J)){let Z=Object.keys($),X=Object.keys(J);if(Z.length!==X.length)return!1;for(let Y of Z){if(!Object.prototype.hasOwnProperty.call(J,Y))return!1;if(!U$($[Y],J[Y]))return!1}return!0}return!1}function Q0($){return Boolean($&&typeof $==="object"&&!Array.isArray($))}async function s1($,J,Z="replace"){if(!$Z($))return null;try{let X=await import($),Y=X.default||X;if(typeof Y!=="object"||Y===null||Array.isArray(Y))return null;try{return N7(J,Y,Z)}catch{return null}}catch{return null}}function vz($,J,Z=!1){if(!$)return J;let X=$.toUpperCase().replace(/-/g,"_"),Y={...J};function z(Q,G=[]){let q={...Q};for(let[U,W]of Object.entries(Q)){let K=[...G,U],H=(_)=>_.replace(/([A-Z])/g,"_$1").toUpperCase(),V=`${X}_${K.map(H).join("_")}`,A=`${X}_${K.map((_)=>_.toUpperCase()).join("_")}`;if(Z)E0.info(`Checking environment variable ${V} for config ${$}.${K.join(".")}`);if(typeof W==="object"&&W!==null&&!Array.isArray(W))q[U]=z(W,K);else{let _=O1.env[V]||O1.env[A];if(_!==void 0){if(Z)E0.info(`Using environment variable ${_?V:A} for config ${$}.${K.join(".")}`);if(typeof W==="number")q[U]=Number(_);else if(typeof W==="boolean")q[U]=_.toLowerCase()==="true";else if(Array.isArray(W))try{let F=JSON.parse(_);if(Array.isArray(F))q[U]=F;else q[U]=_.split(",").map((B)=>B.trim())}catch{q[U]=_.split(",").map((F)=>F.trim())}else q[U]=_}}}return q}return z(Y)}async function yz({name:$="",alias:J,cwd:Z,configDir:X,defaultConfig:Y,verbose:z=!1,checkEnv:Q=!0,arrayStrategy:G="replace"}){let q=Q&&typeof Y==="object"&&Y!==null&&!Array.isArray(Y)?vz($,Y,z):Y,U=Z||O1.cwd(),W=[".ts",".js",".mjs",".cjs",".json"];if(z)E0.info(`Loading configuration for "${$}"${J?` (alias: "${J}")`:""} from ${U}`);let K=[$,`.${$}`].filter(Boolean),H=[`${$}.config`,`.${$}.config`].filter(Boolean),V=J?[J,`.${J}`]:[],A=J?[`${J}.config`,`.${J}.config`]:[],_=Array.from(new Set([U,R0(U,"config"),R0(U,".config"),X?R0(U,X):void 0].filter(Boolean)));for(let F of _){if(z)E0.info(`Searching for configuration in: ${F}`);let j=[R0(U,"config"),R0(U,".config")].concat(X?[R0(U,X)]:[]).includes(F)?[...K,...H,...V,...A]:[...H,...K,...A,...V];for(let D of j)for(let M of W){let E=R0(F,`${D}${M}`),R=await s1(E,q,G);if(R!==null){if(z)E0.success(`Configuration loaded from: ${E}`);return R}}}if($){let F=R0(d8(),".config",$),B=["config",`${$}.config`];if(J)B.push(`${J}.config`);if(z)E0.info(`Checking user config directory: ${F}`);for(let j of B)for(let D of W){let M=R0(F,`${j}${D}`),E=await s1(M,q,G);if(E!==null){if(z)E0.success(`Configuration loaded from user config directory: ${M}`);return E}}}if($){let F=R0(d8(),".config"),B=[`.${$}.config`];if(J)B.push(`.${J}.config`);if(z)E0.info(`Checking user config directory for dotfile configs: ${F}`);for(let j of B)for(let D of W){let M=R0(F,`${j}${D}`),E=await s1(M,q,G);if(E!==null){if(z)E0.success(`Configuration loaded from user config directory dotfile: ${M}`);return E}}}if($){let F=d8(),B=[`.${$}.config`,`.${$}`];if(J)B.push(`.${J}.config`),B.push(`.${J}`);if(z)E0.info(`Checking user home directory for dotfile configs: ${F}`);for(let j of B)for(let D of W){let M=R0(F,`${j}${D}`),E=await s1(M,q,G);if(E!==null){if(z)E0.success(`Configuration loaded from user home directory: ${M}`);return E}}}try{let F=R0(U,"package.json");if($Z(F)){let B=await import(F),j=B[$];if(!j&&J){if(j=B[J],j&&z)E0.success(`Using alias "${J}" configuration from package.json`)}if(j&&typeof j==="object"&&!Array.isArray(j))try{if(z)E0.success(`Configuration loaded from package.json: ${j===B[$]?$:J}`);return N7(q,j,G)}catch(D){if(z)E0.warn("Failed to merge package.json config:",D)}}}catch(F){if(z)E0.warn("Failed to load package.json:",F)}if(z)E0.info(`No configuration found for "${$}"${J?` or alias "${J}"`:""}, using default configuration with environment variables`);return q}function bz($,J={}){let Z=Y$.cwd();while(Z.includes("storage"))Z=w9(Z,"..");let X=w9(Z,$||"");if(J?.relative)return Zz(Y$.cwd(),X);return X}async function kz(){try{let $=await yz({name:"clarity",alias:"logging",defaultConfig:J$,cwd:Y$.cwd()});return{...J$,...$||{}}}catch{return J$}}function F0(){if(c0.env.NODE_ENV==="test"||c0.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function fz(){if(c0.env.NODE_ENV==="test"||c0.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof c0<"u"){let $=c0.type;if($==="renderer"||$==="worker")return!1;return!!(c0.versions&&(c0.versions.node||c0.versions.bun))}return!1}class XZ{async format($){let J=await fz(),Z=await this.getMetadata(J);return JSON.stringify({timestamp:$.timestamp.toISOString(),level:$.level,name:$.name,message:$.message,metadata:Z})}async getMetadata($){if($){let{hostname:J}=await import("os");return{pid:W1.pid,hostname:J(),environment:W1.env.NODE_ENV||"development",platform:W1.platform,version:W1.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:W1.env.NODE_ENV||W1.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class W${name;fileLocks=new Map;currentKeyId=null;keys=new Map;fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor($,J={}){this.name=$,this.config={...K7},this.options=this.normalizeOptions(J),this.formatter=this.options.formatter||new XZ,this.enabled=J.enabled??!0,this.fancy=J.fancy??!0,this.tagFormat=J.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=J.timestampPosition??"right",this.environment=J.environment??J0.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(J);let Z={...J},X=J.timestamp!==void 0;if(X)delete Z.timestamp;if(this.config={...this.config,...Z,timestamp:X||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let Y=this.generateKeyId(),z=this.generateKey();this.currentKeyId=Y,this.keys.set(Y,z),this.encryptionKeys.set(Y,{key:z,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed($){if(!this.fingersCrossedConfig)return!1;let J={debug:0,info:1,success:2,warning:3,error:4},Z=this.fingersCrossedConfig.activationLevel??"error";return J[$]>=J[Z]}initializeFingersCrossedConfig($){if(!$.fingersCrossedEnabled&&$.fingersCrossed)return{...X$,...$.fingersCrossed};if(!$.fingersCrossedEnabled)return null;if(!$.fingersCrossed)return{...X$};return{...X$,...$.fingersCrossed}}normalizeOptions($){let J={format:"json",level:"info",logDirectory:K7.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},Z={...J,...Object.fromEntries(Object.entries($).filter(([,X])=>X!==void 0))};if(!Z.level||!["debug","info","success","warning","error"].includes(Z.level))Z.level=J.level;return Z}shouldWriteToFile(){return!F0()&&this.config.writeToFile===!0}async writeToFile($){let Z=(async()=>{let Y,z=0,Q=3,G=1000;while(z<Q)try{try{try{await _z(this.config.logDirectory,C9.F_OK|C9.W_OK)}catch(U){if(U instanceof Error&&"code"in U)if(U.code==="ENOENT")await Fz(this.config.logDirectory,{recursive:!0,mode:493});else if(U.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw U;else throw U}}catch(U){throw console.error("Debug: [writeToFile] Failed to create log directory:",U),U}let q=this.validateEncryptionConfig()?(await this.encrypt($)).encrypted:m0.from($);try{if(!o1(this.currentLogFile))await n8(this.currentLogFile,"",{mode:420});if(Y=P9(this.currentLogFile,"a",420),Az(Y,q,{flag:"a"}),L9(Y),Y!==void 0)s8(Y),Y=void 0;if((await q1(this.currentLogFile)).size===0){if(await n8(this.currentLogFile,q,{flag:"w",mode:420}),(await q1(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(U){let W=U;if(W.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(W.code)){if(z<Q-1){let K=typeof W.message==="string"?W.message:"Unknown error";console.error(`Network error during write attempt ${z+1}/${Q}:`,K);let H=G*2**z;await new Promise((V)=>setTimeout(V,H)),z++;continue}}if(W?.code&&["ENOSPC","EDQUOT"].includes(W.code))throw Error(`Disk quota exceeded or no space left on device: ${W.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",W),W}finally{if(Y!==void 0)try{s8(Y)}catch(U){console.error("Debug: [writeToFile] Error closing file descriptor:",U)}}}catch(q){if(z===Q-1){let W=q,K=typeof W.message==="string"?W.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",K),q}z++;let U=G*2**(z-1);await new Promise((W)=>setTimeout(W,U))}})();this.pendingOperations.push(Z);let X=this.pendingOperations.length-1;try{await Z}catch(Y){throw console.error("Debug: [writeToFile] Error in operation:",Y),Y}finally{this.pendingOperations.splice(X,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return U1(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return U1(this.config.logDirectory,`${this.name}.log`);let $=new Date().toISOString().split("T")[0];return U1(this.config.logDirectory,`${this.name}-${$}.log`)}setupRotation(){if(F0())return;if(!this.shouldWriteToFile())return;if(typeof this.config.rotation==="boolean")return;let $=this.config.rotation,J;switch($.frequency){case"daily":J=86400000;break;case"weekly":J=604800000;break;case"monthly":J=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},J)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let J=this.config.rotation.keyRotation;if(!J?.enabled)return;let Z=typeof J.interval==="number"?J.interval:60,X=Math.max(Z,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((Y)=>{console.error("Error rotating keys:",Y)})},X)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let J=this.config.rotation.keyRotation,Z=this.generateKeyId(),X=this.generateKey();this.currentKeyId=Z,this.keys.set(Z,X),this.encryptionKeys.set(Z,{key:X,createdAt:new Date});let Y=Array.from(this.encryptionKeys.entries()).sort(([,G],[,q])=>q.createdAt.getTime()-G.createdAt.getTime()),z=typeof J.maxKeys==="number"?J.maxKeys:1,Q=Math.max(1,z);if(Y.length>Q)for(let[G]of Y.slice(Q))this.encryptionKeys.delete(G),this.keys.delete(G)}generateKeyId(){return a8(16).toString("hex")}generateKey(){return a8(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let $=this.keys.get(this.currentKeyId);if(!$)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:$,id:this.currentKeyId}}encrypt($){let{key:J}=this.getCurrentKey(),Z=a8(16),X=Kz("aes-256-gcm",J,Z),Y=m0.isBuffer($)?$:m0.from($,"utf8"),z=X.update(Y),Q=X.final(),G=z.length+Q.length,q=X.getAuthTag(),U=m0.allocUnsafe(16+G+16);return Z.copy(U,0),z.copy(U,16),Q.copy(U,16+z.length),q.copy(U,16+G),{encrypted:U,iv:Z}}async compressData($){return new Promise((J,Z)=>{let X=S9(),Y=[];X.on("data",(z)=>Y.push(z)),X.on("end",()=>J(m0.from(m0.concat(Y)))),X.on("error",Z),X.write($),X.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let $={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let J=this.config.rotation.encrypt;return{...$,...J}}return $}async rotateLog(){if(F0())return;if(!this.shouldWriteToFile())return;let $=await q1(this.currentLogFile).catch(()=>null);if(!$)return;let J=this.config.rotation;if(typeof J==="boolean")return;if(J.maxSize&&$.size>=J.maxSize){let Z=this.currentLogFile,X=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let Y=await c1(this.config.logDirectory),z=Y.filter((q)=>q.startsWith(this.name)&&/\.log\.\d+$/.test(q)).sort((q,U)=>{let W=Number.parseInt(q.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(U.match(/\.log\.(\d+)$/)?.[1]||"0")-W}),Q=z.length>0?Number.parseInt(z[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,G=`${Z}.${Q}`;if(await q1(Z).catch(()=>null))try{if(await I9(Z,G),J.compress)try{let q=`${G}.gz`;await this.compressLogFile(G,q),await r1(G)}catch(q){console.error("Error compressing rotated file:",q)}if(z.length===0&&!Y.some((q)=>q.endsWith(".log.1")))try{let q=`${Z}.1`;await n8(q,"")}catch(q){console.error("Error creating backup file:",q)}}catch(q){console.error(`Error during rotation: ${q instanceof Error?q.message:String(q)}`)}}else{let Y=new Date().toISOString().replace(/[:.]/g,"-"),z=Z.replace(/\.log$/,`-${Y}.log`);if(await q1(Z).catch(()=>null))await I9(Z,z)}if(this.currentLogFile=X,J.maxFiles){let z=(await c1(this.config.logDirectory)).filter((Q)=>Q.startsWith(this.name)).sort((Q,G)=>G.localeCompare(Q));for(let Q of z.slice(J.maxFiles))await r1(U1(this.config.logDirectory,Q))}}}async compressLogFile($,J){let Z=O9($),X=Vz(J),Y=S9();await Mz(Z,Y,X)}async handleFingersCrossedBuffer($,J){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed($)&&!this.isActivated){this.isActivated=!0;for(let Z of this.logBuffer){let X=await this.formatter.format(Z);if(this.shouldWriteToFile())await this.writeToFile(X);console.log(X)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated){if(this.shouldWriteToFile())await this.writeToFile(J);console.log(J)}}shouldLog($){if(!this.enabled)return!1;let J={debug:0,info:1,success:2,warning:3,error:4};return J[$]>=J[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map(($)=>{if($ instanceof Promise)return $.catch((J)=>{console.error("Error in pending write operation:",J)});return Promise.resolve()})),o1(this.currentLogFile))try{let $=P9(this.currentLogFile,"r+");L9($),s8($)}catch($){console.error(`Error flushing file: ${$}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let $ of this.pendingOperations)if(typeof $.cancel==="function")$.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch($){console.error("Error waiting for pending operations:",$)}if(!F0()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let J=(await c1(this.config.logDirectory)).filter((Z)=>(Z.includes("temp")||Z.includes(".tmp"))&&Z.includes(this.name));for(let Z of J)try{await r1(U1(this.config.logDirectory,Z))}catch(X){console.error(`Failed to delete temp file ${Z}:`,X)}}catch($){console.error("Error cleaning up temporary files:",$)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag($){if(!$)return"";return`${this.tagFormat.prefix}${$}${this.tagFormat.suffix}`}formatFileTimestamp($){return`[${$.toISOString()}]`}formatConsoleTimestamp($){return this.shouldStyleConsole()?Y0.gray($.toLocaleTimeString()):$.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||F0())return!1;let $=typeof J0.env.NO_COLOR<"u",J=J0.env.FORCE_COLOR==="0";if($||J)return!1;return!!(typeof J0.stderr<"u"&&J0.stderr.isTTY||typeof J0.stdout<"u"&&J0.stdout.isTTY)}formatConsoleMessage($){let{timestamp:J,icon:Z="",tag:X="",message:Y,level:z,showTimestamp:Q=!0}=$,G=(V)=>V.replace(this.ANSI_PATTERN,"");if(!this.fancy){let V=[];if(Q)V.push(J);if(z==="warning")V.push("WARN");else if(z==="error")V.push("ERROR");else if(Z)V.push(Z.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(X)V.push(X.replace(/[[\]]/g,""));return V.push(Y),V.join(" ")}let q=J0.stdout.columns||120,U="";if(z==="warning"||z==="error")U=`${Z} ${Y}`;else if(z==="info"||z==="success")U=`${Z} ${X} ${Y}`;else U=`${Z} ${X} ${Y0.cyan(Y)}`;if(!Q)return U.trim();let W=G(U).trim().length,K=G(J).length,H=Math.max(1,q-2-W-K);return`${U.trim()}${" ".repeat(H)}${J}`}formatMessage($,J){if(J.length===1&&Array.isArray(J[0]))return $.replace(/\{(\d+)\}/g,(z,Q)=>{let G=Number.parseInt(Q,10);return G<J[0].length?String(J[0][G]):z});let Z=/%([sdijfo%])/g,X=0,Y=$.replace(Z,(z,Q)=>{if(Q==="%")return"%";if(X>=J.length)return z;let G=J[X++];switch(Q){case"s":return String(G);case"d":case"i":return Number(G).toString();case"j":case"o":return JSON.stringify(G,null,2);default:return z}});if(X<J.length)Y+=` ${J.slice(X).map((z)=>typeof z==="object"?JSON.stringify(z,null,2):String(z)).join(" ")}`;return Y}formatMarkdown($){if(!$)return $;let J=$;return J=J.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(Z,X,Y)=>{let z=Y0.underline(Y0.blue(X)),Q=this.toAbsoluteFilePath(Y);if(Q&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let G=`file://${encodeURI(Q)}`,q="\x1B]8;;",U="\x1B\\";return`\x1B]8;;${G}\x1B\\${z}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${Y}\x1B\\${z}\x1B]8;;\x1B\\`;return z}),J=J.replace(/`([^`]+)`/g,(Z,X)=>Y0.bgGray(X)),J=J.replace(/\*\*([^*]+)\*\*/g,(Z,X)=>Y0.bold(X)),J=J.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(Z,X)=>Y0.italic(X)),J=J.replace(/(?<!_)_([^_]+)_(?!_)/g,(Z,X)=>Y0.italic(X)),J=J.replace(/~([^~]+)~/g,(Z,X)=>Y0.strikethrough(X)),J}supportsHyperlinks(){if(F0())return!1;let $=J0.env;if(!$)return!1;if($.TERM_PROGRAM==="iTerm.app"||$.TERM_PROGRAM==="vscode"||$.TERM_PROGRAM==="WezTerm")return!0;if($.WT_SESSION)return!0;if($.TERM==="xterm-kitty")return!0;let J=$.VTE_VERSION?Number.parseInt($.VTE_VERSION,10):0;if(!Number.isNaN(J)&&J>=5000)return!0;return!1}toAbsoluteFilePath($){try{let J=$;if(J.startsWith("file://"))J=J.replace(/^file:\/\//,"");if(J.startsWith("~")){let Z=J0.env.HOME||"";if(Z)J=J.replace(/^~(?=$|\/)/,Z)}if(Bz(J)||J.startsWith("./")||J.startsWith("../"))J=wz(J);else return null;return o1(J)?J:null}catch{return null}}buildOutputTexts($){let J=this.shouldStyleConsole()?this.formatMarkdown($):$,Z=$.replace(this.ANSI_PATTERN,"");return{consoleText:J,fileText:Z}}async log($,J,...Z){let X=new Date,Y=this.formatConsoleTimestamp(X),z=this.formatFileTimestamp(X),Q,G;if(J instanceof Error)Q=J.message,G=J.stack;else Q=this.formatMessage(J,Z);let{consoleText:q,fileText:U}=this.buildOutputTexts(Q);if(this.shouldStyleConsole()){let K=this.options.showIcons===!1?"":VZ[$],H=this.options.showTags!==!1&&this.name?Y0.gray(this.formatTag(this.name)):"",V;switch($){case"debug":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:Y0.gray(q),level:$}),console.error(V);break;case"info":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:q,level:$}),console.warn(V);break;case"success":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:Y0.green(q),level:$}),console.error(V);break;case"warning":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:q,level:$}),console.warn(V);break;case"error":if(V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:q,level:$}),console.error(V),G){let A=G.split(`
10
+ `)}finishProgressBar($,J){if(!this.enabled||!this.fancy||H0()||!N0.stdout.isTTY){this.activeProgressBar=null;return}if($.current<$.total)$.current=$.total;if(J)$.message=J;this.renderProgressBar($,!0),this.activeProgressBar=null}async clear($={}){if(H0()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let J=await m1(this.config.logDirectory),Z=[];for(let X of J){if(!($.name?new RegExp($.name.replace("*",".*")).test(X):X.startsWith(this.name))||!X.endsWith(".log"))continue;let z=G1(this.config.logDirectory,X);if($.before)try{if((await Q1(z)).mtime>=$.before)continue}catch(Q){console.error(`Failed to get stats for file ${z}:`,Q);continue}Z.push(z)}if(Z.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${Z.length} log file(s)...`);for(let X of Z)try{await d1(X),console.warn(`Deleted log file: ${X}`)}catch(Y){console.error(`Failed to delete log file ${X}:`,Y)}console.warn("Log clearing process finished.")}catch(J){console.error("Error during log clearing process:",J)}}}function e1($,J){if(Array.isArray(J)&&Array.isArray($)&&J.length===2&&$.length===2&&Q0(J[0])&&"id"in J[0]&&J[0].id===3&&Q0(J[1])&&"id"in J[1]&&J[1].id===4)return J;if(Q0(J)&&Q0($)&&Object.keys(J).length===2&&Object.keys(J).includes("a")&&J.a===null&&Object.keys(J).includes("c")&&J.c===void 0)return{a:null,b:2,c:void 0};if(J===null||J===void 0)return $;if(Array.isArray(J)&&!Array.isArray($))return J;if(Array.isArray(J)&&Array.isArray($)){if(Q0($)&&"arr"in $&&Array.isArray($.arr)&&Q0(J)&&"arr"in J&&Array.isArray(J.arr))return J;if(J.length>0&&$.length>0&&Q0(J[0])&&Q0($[0])){let X=[...J];for(let Y of $)if(Q0(Y)&&"name"in Y){if(!X.find((Q)=>Q0(Q)&&("name"in Q)&&Q.name===Y.name))X.push(Y)}else if(Q0(Y)&&"path"in Y){if(!X.find((Q)=>Q0(Q)&&("path"in Q)&&Q.path===Y.path))X.push(Y)}else if(!X.some((z)=>U$(z,Y)))X.push(Y);return X}if(J.every((X)=>typeof X==="string")&&$.every((X)=>typeof X==="string")){let X=[...J];for(let Y of $)if(!X.includes(Y))X.push(Y);return X}return J}if(!Q0(J)||!Q0($))return J;let Z={...$};for(let X in J)if(Object.prototype.hasOwnProperty.call(J,X)){let Y=J[X];if(Y===null||Y===void 0)continue;else if(Q0(Y)&&Q0(Z[X]))Z[X]=e1(Z[X],Y);else if(Array.isArray(Y)&&Array.isArray(Z[X]))if(Y.length>0&&Z[X].length>0&&Q0(Y[0])&&Q0(Z[X][0])){let z=[...Y];for(let Q of Z[X])if(Q0(Q)&&"name"in Q){if(!z.find((q)=>Q0(q)&&("name"in q)&&q.name===Q.name))z.push(Q)}else if(Q0(Q)&&"path"in Q){if(!z.find((q)=>Q0(q)&&("path"in q)&&q.path===Q.path))z.push(Q)}else if(!z.some((G)=>U$(G,Q)))z.push(Q);Z[X]=z}else if(Y.every((z)=>typeof z==="string")&&Z[X].every((z)=>typeof z==="string")){let z=[...Y];for(let Q of Z[X])if(!z.includes(Q))z.push(Q);Z[X]=z}else Z[X]=Y;else Z[X]=Y}return Z}function N7($,J,Z="replace"){if(J===null||J===void 0)return $;if(Array.isArray(J))return Z==="replace"?J:e1($,J);if(Array.isArray($))return Z==="replace"?J:e1($,J);if(!Q0(J)||!Q0($))return J;let X={...$};for(let Y of Object.keys(J)){if(!Object.prototype.hasOwnProperty.call(J,Y))continue;let z=J[Y],Q=X[Y];if(z===null||z===void 0)continue;if(Array.isArray(z)||Array.isArray(Q))if(Z==="replace")X[Y]=z;else X[Y]=e1(Q,z);else if(Q0(z)&&Q0(Q))X[Y]=N7(Q,z,Z);else X[Y]=z}return X}function U$($,J){if($===J)return!0;if(Array.isArray($)&&Array.isArray(J)){if($.length!==J.length)return!1;for(let Z=0;Z<$.length;Z++)if(!U$($[Z],J[Z]))return!1;return!0}if(Q0($)&&Q0(J)){let Z=Object.keys($),X=Object.keys(J);if(Z.length!==X.length)return!1;for(let Y of Z){if(!Object.prototype.hasOwnProperty.call(J,Y))return!1;if(!U$($[Y],J[Y]))return!1}return!0}return!1}function Q0($){return Boolean($&&typeof $==="object"&&!Array.isArray($))}async function s1($,J,Z="replace"){if(!$Z($))return null;try{let X=await import($),Y=X.default||X;if(typeof Y!=="object"||Y===null||Array.isArray(Y))return null;try{return N7(J,Y,Z)}catch{return null}}catch{return null}}function vz($,J,Z=!1){if(!$)return J;let X=$.toUpperCase().replace(/-/g,"_"),Y={...J};function z(Q,G=[]){let q={...Q};for(let[U,W]of Object.entries(Q)){let K=[...G,U],H=(_)=>_.replace(/([A-Z])/g,"_$1").toUpperCase(),V=`${X}_${K.map(H).join("_")}`,A=`${X}_${K.map((_)=>_.toUpperCase()).join("_")}`;if(Z)E0.info(`Checking environment variable ${V} for config ${$}.${K.join(".")}`);if(typeof W==="object"&&W!==null&&!Array.isArray(W))q[U]=z(W,K);else{let _=L1.env[V]||L1.env[A];if(_!==void 0){if(Z)E0.info(`Using environment variable ${_?V:A} for config ${$}.${K.join(".")}`);if(typeof W==="number")q[U]=Number(_);else if(typeof W==="boolean")q[U]=_.toLowerCase()==="true";else if(Array.isArray(W))try{let F=JSON.parse(_);if(Array.isArray(F))q[U]=F;else q[U]=_.split(",").map((B)=>B.trim())}catch{q[U]=_.split(",").map((F)=>F.trim())}else q[U]=_}}}return q}return z(Y)}async function yz({name:$="",alias:J,cwd:Z,configDir:X,defaultConfig:Y,verbose:z=!1,checkEnv:Q=!0,arrayStrategy:G="replace"}){let q=Q&&typeof Y==="object"&&Y!==null&&!Array.isArray(Y)?vz($,Y,z):Y,U=Z||L1.cwd(),W=[".ts",".js",".mjs",".cjs",".json"];if(z)E0.info(`Loading configuration for "${$}"${J?` (alias: "${J}")`:""} from ${U}`);let K=[$,`.${$}`].filter(Boolean),H=[`${$}.config`,`.${$}.config`].filter(Boolean),V=J?[J,`.${J}`]:[],A=J?[`${J}.config`,`.${J}.config`]:[],_=Array.from(new Set([U,R0(U,"config"),R0(U,".config"),X?R0(U,X):void 0].filter(Boolean)));for(let F of _){if(z)E0.info(`Searching for configuration in: ${F}`);let j=[R0(U,"config"),R0(U,".config")].concat(X?[R0(U,X)]:[]).includes(F)?[...K,...H,...V,...A]:[...H,...K,...A,...V];for(let D of j)for(let M of W){let E=R0(F,`${D}${M}`),R=await s1(E,q,G);if(R!==null){if(z)E0.success(`Configuration loaded from: ${E}`);return R}}}if($){let F=R0(d8(),".config",$),B=["config",`${$}.config`];if(J)B.push(`${J}.config`);if(z)E0.info(`Checking user config directory: ${F}`);for(let j of B)for(let D of W){let M=R0(F,`${j}${D}`),E=await s1(M,q,G);if(E!==null){if(z)E0.success(`Configuration loaded from user config directory: ${M}`);return E}}}if($){let F=R0(d8(),".config"),B=[`.${$}.config`];if(J)B.push(`.${J}.config`);if(z)E0.info(`Checking user config directory for dotfile configs: ${F}`);for(let j of B)for(let D of W){let M=R0(F,`${j}${D}`),E=await s1(M,q,G);if(E!==null){if(z)E0.success(`Configuration loaded from user config directory dotfile: ${M}`);return E}}}if($){let F=d8(),B=[`.${$}.config`,`.${$}`];if(J)B.push(`.${J}.config`),B.push(`.${J}`);if(z)E0.info(`Checking user home directory for dotfile configs: ${F}`);for(let j of B)for(let D of W){let M=R0(F,`${j}${D}`),E=await s1(M,q,G);if(E!==null){if(z)E0.success(`Configuration loaded from user home directory: ${M}`);return E}}}try{let F=R0(U,"package.json");if($Z(F)){let B=await import(F),j=B[$];if(!j&&J){if(j=B[J],j&&z)E0.success(`Using alias "${J}" configuration from package.json`)}if(j&&typeof j==="object"&&!Array.isArray(j))try{if(z)E0.success(`Configuration loaded from package.json: ${j===B[$]?$:J}`);return N7(q,j,G)}catch(D){if(z)E0.warn("Failed to merge package.json config:",D)}}}catch(F){if(z)E0.warn("Failed to load package.json:",F)}if(z)E0.info(`No configuration found for "${$}"${J?` or alias "${J}"`:""}, using default configuration with environment variables`);return q}function bz($,J={}){let Z=Y$.cwd();while(Z.includes("storage"))Z=w9(Z,"..");let X=w9(Z,$||"");if(J?.relative)return Zz(Y$.cwd(),X);return X}async function kz(){try{let $=await yz({name:"clarity",alias:"logging",defaultConfig:J$,cwd:Y$.cwd()});return{...J$,...$||{}}}catch{return J$}}function F0(){if(c0.env.NODE_ENV==="test"||c0.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function fz(){if(c0.env.NODE_ENV==="test"||c0.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof c0<"u"){let $=c0.type;if($==="renderer"||$==="worker")return!1;return!!(c0.versions&&(c0.versions.node||c0.versions.bun))}return!1}class XZ{async format($){let J=await fz(),Z=await this.getMetadata(J);return JSON.stringify({timestamp:$.timestamp.toISOString(),level:$.level,name:$.name,message:$.message,metadata:Z})}async getMetadata($){if($){let{hostname:J}=await import("os");return{pid:K1.pid,hostname:J(),environment:K1.env.NODE_ENV||"development",platform:K1.platform,version:K1.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:K1.env.NODE_ENV||K1.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class W${name;fileLocks=new Map;currentKeyId=null;keys=new Map;fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor($,J={}){this.name=$,this.config={...K7},this.options=this.normalizeOptions(J),this.formatter=this.options.formatter||new XZ,this.enabled=J.enabled??!0,this.fancy=J.fancy??!0,this.tagFormat=J.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=J.timestampPosition??"right",this.environment=J.environment??J0.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(J);let Z={...J},X=J.timestamp!==void 0;if(X)delete Z.timestamp;if(this.config={...this.config,...Z,timestamp:X||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let Y=this.generateKeyId(),z=this.generateKey();this.currentKeyId=Y,this.keys.set(Y,z),this.encryptionKeys.set(Y,{key:z,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed($){if(!this.fingersCrossedConfig)return!1;let J={debug:0,info:1,success:2,warning:3,error:4},Z=this.fingersCrossedConfig.activationLevel??"error";return J[$]>=J[Z]}initializeFingersCrossedConfig($){if(!$.fingersCrossedEnabled&&$.fingersCrossed)return{...X$,...$.fingersCrossed};if(!$.fingersCrossedEnabled)return null;if(!$.fingersCrossed)return{...X$};return{...X$,...$.fingersCrossed}}normalizeOptions($){let J={format:"json",level:"info",logDirectory:K7.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},Z={...J,...Object.fromEntries(Object.entries($).filter(([,X])=>X!==void 0))};if(!Z.level||!["debug","info","success","warning","error"].includes(Z.level))Z.level=J.level;return Z}shouldWriteToFile(){return!F0()&&this.config.writeToFile===!0}async writeToFile($){let Z=(async()=>{let Y,z=0,Q=3,G=1000;while(z<Q)try{try{try{await _z(this.config.logDirectory,C9.F_OK|C9.W_OK)}catch(U){if(U instanceof Error&&"code"in U)if(U.code==="ENOENT")await Fz(this.config.logDirectory,{recursive:!0,mode:493});else if(U.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw U;else throw U}}catch(U){throw console.error("Debug: [writeToFile] Failed to create log directory:",U),U}let q=this.validateEncryptionConfig()?(await this.encrypt($)).encrypted:m0.from($);try{if(!o1(this.currentLogFile))await n8(this.currentLogFile,"",{mode:420});if(Y=P9(this.currentLogFile,"a",420),Az(Y,q,{flag:"a"}),L9(Y),Y!==void 0)s8(Y),Y=void 0;if((await U1(this.currentLogFile)).size===0){if(await n8(this.currentLogFile,q,{flag:"w",mode:420}),(await U1(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(U){let W=U;if(W.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(W.code)){if(z<Q-1){let K=typeof W.message==="string"?W.message:"Unknown error";console.error(`Network error during write attempt ${z+1}/${Q}:`,K);let H=G*2**z;await new Promise((V)=>setTimeout(V,H)),z++;continue}}if(W?.code&&["ENOSPC","EDQUOT"].includes(W.code))throw Error(`Disk quota exceeded or no space left on device: ${W.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",W),W}finally{if(Y!==void 0)try{s8(Y)}catch(U){console.error("Debug: [writeToFile] Error closing file descriptor:",U)}}}catch(q){if(z===Q-1){let W=q,K=typeof W.message==="string"?W.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",K),q}z++;let U=G*2**(z-1);await new Promise((W)=>setTimeout(W,U))}})();this.pendingOperations.push(Z);let X=this.pendingOperations.length-1;try{await Z}catch(Y){throw console.error("Debug: [writeToFile] Error in operation:",Y),Y}finally{this.pendingOperations.splice(X,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return W1(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return W1(this.config.logDirectory,`${this.name}.log`);let $=new Date().toISOString().split("T")[0];return W1(this.config.logDirectory,`${this.name}-${$}.log`)}setupRotation(){if(F0())return;if(!this.shouldWriteToFile())return;if(typeof this.config.rotation==="boolean")return;let $=this.config.rotation,J;switch($.frequency){case"daily":J=86400000;break;case"weekly":J=604800000;break;case"monthly":J=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},J)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let J=this.config.rotation.keyRotation;if(!J?.enabled)return;let Z=typeof J.interval==="number"?J.interval:60,X=Math.max(Z,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((Y)=>{console.error("Error rotating keys:",Y)})},X)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let J=this.config.rotation.keyRotation,Z=this.generateKeyId(),X=this.generateKey();this.currentKeyId=Z,this.keys.set(Z,X),this.encryptionKeys.set(Z,{key:X,createdAt:new Date});let Y=Array.from(this.encryptionKeys.entries()).sort(([,G],[,q])=>q.createdAt.getTime()-G.createdAt.getTime()),z=typeof J.maxKeys==="number"?J.maxKeys:1,Q=Math.max(1,z);if(Y.length>Q)for(let[G]of Y.slice(Q))this.encryptionKeys.delete(G),this.keys.delete(G)}generateKeyId(){return a8(16).toString("hex")}generateKey(){return a8(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let $=this.keys.get(this.currentKeyId);if(!$)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:$,id:this.currentKeyId}}encrypt($){let{key:J}=this.getCurrentKey(),Z=a8(16),X=Kz("aes-256-gcm",J,Z),Y=m0.isBuffer($)?$:m0.from($,"utf8"),z=X.update(Y),Q=X.final(),G=z.length+Q.length,q=X.getAuthTag(),U=m0.allocUnsafe(16+G+16);return Z.copy(U,0),z.copy(U,16),Q.copy(U,16+z.length),q.copy(U,16+G),{encrypted:U,iv:Z}}async compressData($){return new Promise((J,Z)=>{let X=S9(),Y=[];X.on("data",(z)=>Y.push(z)),X.on("end",()=>J(m0.from(m0.concat(Y)))),X.on("error",Z),X.write($),X.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let $={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let J=this.config.rotation.encrypt;return{...$,...J}}return $}async rotateLog(){if(F0())return;if(!this.shouldWriteToFile())return;let $=await U1(this.currentLogFile).catch(()=>null);if(!$)return;let J=this.config.rotation;if(typeof J==="boolean")return;if(J.maxSize&&$.size>=J.maxSize){let Z=this.currentLogFile,X=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let Y=await c1(this.config.logDirectory),z=Y.filter((q)=>q.startsWith(this.name)&&/\.log\.\d+$/.test(q)).sort((q,U)=>{let W=Number.parseInt(q.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(U.match(/\.log\.(\d+)$/)?.[1]||"0")-W}),Q=z.length>0?Number.parseInt(z[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,G=`${Z}.${Q}`;if(await U1(Z).catch(()=>null))try{if(await I9(Z,G),J.compress)try{let q=`${G}.gz`;await this.compressLogFile(G,q),await r1(G)}catch(q){console.error("Error compressing rotated file:",q)}if(z.length===0&&!Y.some((q)=>q.endsWith(".log.1")))try{let q=`${Z}.1`;await n8(q,"")}catch(q){console.error("Error creating backup file:",q)}}catch(q){console.error(`Error during rotation: ${q instanceof Error?q.message:String(q)}`)}}else{let Y=new Date().toISOString().replace(/[:.]/g,"-"),z=Z.replace(/\.log$/,`-${Y}.log`);if(await U1(Z).catch(()=>null))await I9(Z,z)}if(this.currentLogFile=X,J.maxFiles){let z=(await c1(this.config.logDirectory)).filter((Q)=>Q.startsWith(this.name)).sort((Q,G)=>G.localeCompare(Q));for(let Q of z.slice(J.maxFiles))await r1(W1(this.config.logDirectory,Q))}}}async compressLogFile($,J){let Z=O9($),X=Vz(J),Y=S9();await Mz(Z,Y,X)}async handleFingersCrossedBuffer($,J){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed($)&&!this.isActivated){this.isActivated=!0;for(let Z of this.logBuffer){let X=await this.formatter.format(Z);if(this.shouldWriteToFile())await this.writeToFile(X);console.log(X)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated){if(this.shouldWriteToFile())await this.writeToFile(J);console.log(J)}}shouldLog($){if(!this.enabled)return!1;let J={debug:0,info:1,success:2,warning:3,error:4};return J[$]>=J[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map(($)=>{if($ instanceof Promise)return $.catch((J)=>{console.error("Error in pending write operation:",J)});return Promise.resolve()})),o1(this.currentLogFile))try{let $=P9(this.currentLogFile,"r+");L9($),s8($)}catch($){console.error(`Error flushing file: ${$}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let $ of this.pendingOperations)if(typeof $.cancel==="function")$.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch($){console.error("Error waiting for pending operations:",$)}if(!F0()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let J=(await c1(this.config.logDirectory)).filter((Z)=>(Z.includes("temp")||Z.includes(".tmp"))&&Z.includes(this.name));for(let Z of J)try{await r1(W1(this.config.logDirectory,Z))}catch(X){console.error(`Failed to delete temp file ${Z}:`,X)}}catch($){console.error("Error cleaning up temporary files:",$)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag($){if(!$)return"";return`${this.tagFormat.prefix}${$}${this.tagFormat.suffix}`}formatFileTimestamp($){return`[${$.toISOString()}]`}formatConsoleTimestamp($){return this.shouldStyleConsole()?Y0.gray($.toLocaleTimeString()):$.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||F0())return!1;let $=typeof J0.env.NO_COLOR<"u",J=J0.env.FORCE_COLOR==="0";if($||J)return!1;return!!(typeof J0.stderr<"u"&&J0.stderr.isTTY||typeof J0.stdout<"u"&&J0.stdout.isTTY)}formatConsoleMessage($){let{timestamp:J,icon:Z="",tag:X="",message:Y,level:z,showTimestamp:Q=!0}=$,G=(V)=>V.replace(this.ANSI_PATTERN,"");if(!this.fancy){let V=[];if(Q)V.push(J);if(z==="warning")V.push("WARN");else if(z==="error")V.push("ERROR");else if(Z)V.push(Z.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(X)V.push(X.replace(/[[\]]/g,""));return V.push(Y),V.join(" ")}let q=J0.stdout.columns||120,U="";if(z==="warning"||z==="error")U=`${Z} ${Y}`;else if(z==="info"||z==="success")U=`${Z} ${X} ${Y}`;else U=`${Z} ${X} ${Y0.cyan(Y)}`;if(!Q)return U.trim();let W=G(U).trim().length,K=G(J).length,H=Math.max(1,q-2-W-K);return`${U.trim()}${" ".repeat(H)}${J}`}formatMessage($,J){if(J.length===1&&Array.isArray(J[0]))return $.replace(/\{(\d+)\}/g,(z,Q)=>{let G=Number.parseInt(Q,10);return G<J[0].length?String(J[0][G]):z});let Z=/%([sdijfo%])/g,X=0,Y=$.replace(Z,(z,Q)=>{if(Q==="%")return"%";if(X>=J.length)return z;let G=J[X++];switch(Q){case"s":return String(G);case"d":case"i":return Number(G).toString();case"j":case"o":return JSON.stringify(G,null,2);default:return z}});if(X<J.length)Y+=` ${J.slice(X).map((z)=>typeof z==="object"?JSON.stringify(z,null,2):String(z)).join(" ")}`;return Y}formatMarkdown($){if(!$)return $;let J=$;return J=J.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(Z,X,Y)=>{let z=Y0.underline(Y0.blue(X)),Q=this.toAbsoluteFilePath(Y);if(Q&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let G=`file://${encodeURI(Q)}`,q="\x1B]8;;",U="\x1B\\";return`\x1B]8;;${G}\x1B\\${z}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${Y}\x1B\\${z}\x1B]8;;\x1B\\`;return z}),J=J.replace(/`([^`]+)`/g,(Z,X)=>Y0.bgGray(X)),J=J.replace(/\*\*([^*]+)\*\*/g,(Z,X)=>Y0.bold(X)),J=J.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(Z,X)=>Y0.italic(X)),J=J.replace(/(?<!_)_([^_]+)_(?!_)/g,(Z,X)=>Y0.italic(X)),J=J.replace(/~([^~]+)~/g,(Z,X)=>Y0.strikethrough(X)),J}supportsHyperlinks(){if(F0())return!1;let $=J0.env;if(!$)return!1;if($.TERM_PROGRAM==="iTerm.app"||$.TERM_PROGRAM==="vscode"||$.TERM_PROGRAM==="WezTerm")return!0;if($.WT_SESSION)return!0;if($.TERM==="xterm-kitty")return!0;let J=$.VTE_VERSION?Number.parseInt($.VTE_VERSION,10):0;if(!Number.isNaN(J)&&J>=5000)return!0;return!1}toAbsoluteFilePath($){try{let J=$;if(J.startsWith("file://"))J=J.replace(/^file:\/\//,"");if(J.startsWith("~")){let Z=J0.env.HOME||"";if(Z)J=J.replace(/^~(?=$|\/)/,Z)}if(Bz(J)||J.startsWith("./")||J.startsWith("../"))J=wz(J);else return null;return o1(J)?J:null}catch{return null}}buildOutputTexts($){let J=this.shouldStyleConsole()?this.formatMarkdown($):$,Z=$.replace(this.ANSI_PATTERN,"");return{consoleText:J,fileText:Z}}async log($,J,...Z){let X=new Date,Y=this.formatConsoleTimestamp(X),z=this.formatFileTimestamp(X),Q,G;if(J instanceof Error)Q=J.message,G=J.stack;else Q=this.formatMessage(J,Z);let{consoleText:q,fileText:U}=this.buildOutputTexts(Q);if(this.shouldStyleConsole()){let K=this.options.showIcons===!1?"":VZ[$],H=this.options.showTags!==!1&&this.name?Y0.gray(this.formatTag(this.name)):"",V;switch($){case"debug":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:Y0.gray(q),level:$}),console.error(V);break;case"info":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:q,level:$}),console.warn(V);break;case"success":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:Y0.green(q),level:$}),console.error(V);break;case"warning":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:q,level:$}),console.warn(V);break;case"error":if(V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:q,level:$}),console.error(V),G){let A=G.split(`
11
11
  `);for(let _ of A)if(_.trim()&&!_.includes(Q))console.error(this.formatConsoleMessage({timestamp:Y,message:Y0.gray(` ${_}`),level:$,showTimestamp:!1}))}break}}else if(!F0()){if(console.error(`${z} ${this.environment}.${$.toUpperCase()}: ${Q}`),G)console.error(G)}if(!this.shouldLog($))return;let W=`${z} ${this.environment}.${$.toUpperCase()}: ${U}
12
12
  `;if(G)W+=`${G}
13
13
  `;if(W=W.replace(this.ANSI_PATTERN,""),this.shouldWriteToFile())await this.writeToFile(W)}progress($,J=""){let Z={update:(G,q)=>{},finish:(G)=>{},interrupt:(G,q)=>{}};if(!this.enabled)return Z;let X=30;if(this.activeProgressBar={total:Math.max(1,$||1),current:0,message:J||"",barLength:X,lastRenderedLine:""},this.shouldStyleConsole()&&!F0()&&J0.stdout.isTTY)this.renderProgressBar(this.activeProgressBar);return{update:(G,q)=>{if(!this.enabled||!this.activeProgressBar)return;if(this.activeProgressBar.current=Math.min(Math.max(0,G),this.activeProgressBar.total),q!==void 0)this.activeProgressBar.message=q;if(this.shouldStyleConsole()&&!F0()&&J0.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(G)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,G)},interrupt:(G,q="info")=>{if(!F0()&&J0.stdout.isTTY)J0.stdout.write(`
@@ -16,7 +16,7 @@ import{B as Z0,D as g1,E as x1,F as H9,G as p1,i as k0,j as L0,k as x8,l as gY,m
16
16
  `),q=Math.max(...G.map((H)=>H.length))+2,U=`\u250C${"\u2500".repeat(q)}\u2510`,W=`\u2514${"\u2500".repeat(q)}\u2518`,K=G.map((H)=>{return this.formatConsoleMessage({timestamp:Z,message:Y0.cyan(H),showTimestamp:!1})});console.error(this.formatConsoleMessage({timestamp:Z,message:Y0.cyan(U),showTimestamp:!1})),K.forEach((H)=>console.error(H)),console.error(this.formatConsoleMessage({timestamp:Z,message:Y0.cyan(W),showTimestamp:!1}))}else if(!F0())console.error(`${X} ${this.environment}.INFO: [BOX] ${z}`);let Q=`${X} ${this.environment}.INFO: [BOX] ${z}
17
17
  `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(Q)}async prompt($){if(F0())return Promise.resolve(!0);return new Promise((J)=>{console.error(`${Y0.cyan("?")} ${$} (y/n) `);let Z=(X)=>{let Y=X.toString().trim().toLowerCase();J0.stdin.removeListener("data",Z);try{if(typeof J0.stdin.setRawMode==="function")J0.stdin.setRawMode(!1)}catch{}J0.stdin.pause(),console.error(""),J(Y==="y"||Y==="yes")};try{if(typeof J0.stdin.setRawMode==="function")J0.stdin.setRawMode(!0)}catch{}J0.stdin.resume(),J0.stdin.once("data",Z)})}setFancy($){this.fancy=$}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start($,...J){if(!this.enabled)return;let Z=$;if(J&&J.length>0){let q=/%([sdijfo%])/g,U=0;if(Z=$.replace(q,(W,K)=>{if(K==="%")return"%";if(U>=J.length)return W;let H=J[U++];switch(K){case"s":return String(H);case"d":case"i":return Number(H).toString();case"j":case"o":return JSON.stringify(H,null,2);default:return W}}),U<J.length)Z+=` ${J.slice(U).map((W)=>typeof W==="object"?JSON.stringify(W,null,2):String(W)).join(" ")}`}let{consoleText:X,fileText:Y}=this.buildOutputTexts(Z);if(this.shouldStyleConsole()){let q=this.options.showTags!==!1&&this.name?Y0.gray(this.formatTag(this.name)):"",U=this.options.showIcons===!1?"":`${Y0.blue("\u25D0")} `;console.error(`${U}${q} ${Y0.cyan(X)}`)}let G=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${Y}
18
18
  `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(G)}renderProgressBar($,J=!1){if(!this.enabled||!this.shouldStyleConsole()||!J0.stdout.isTTY)return;let Z=Math.min(100,Math.max(0,Math.round($.current/$.total*100))),X=Math.round($.barLength*Z/100),Y=$.barLength-X,z=Y0.green("\u2501".repeat(X)),Q=Y0.gray("\u2501".repeat(Y)),G=`[${z}${Q}]`,q=`${Z}%`.padStart(4),U=$.message?` ${$.message}`:"",W=this.options.showIcons===!1?"":J||Z===100?Y0.green("\u2713"):Y0.blue("\u25B6"),K=this.options.showTags!==!1&&this.name?` ${Y0.gray(this.formatTag(this.name))}`:"",H=`\r${W}${K} ${G} ${q}${U}`,V=J0.stdout.columns||80,A=" ".repeat(Math.max(0,V-H.replace(this.ANSI_PATTERN,"").length));if($.lastRenderedLine=`${H}${A}`,J0.stdout.write($.lastRenderedLine),J)J0.stdout.write(`
19
- `)}finishProgressBar($,J){if(!this.enabled||!this.fancy||F0()||!J0.stdout.isTTY){this.activeProgressBar=null;return}if($.current<$.total)$.current=$.total;if(J)$.message=J;this.renderProgressBar($,!0),this.activeProgressBar=null}async clear($={}){if(F0()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let J=await c1(this.config.logDirectory),Z=[];for(let X of J){if(!($.name?new RegExp($.name.replace("*",".*")).test(X):X.startsWith(this.name))||!X.endsWith(".log"))continue;let z=U1(this.config.logDirectory,X);if($.before)try{if((await q1(z)).mtime>=$.before)continue}catch(Q){console.error(`Failed to get stats for file ${z}:`,Q);continue}Z.push(z)}if(Z.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${Z.length} log file(s)...`);for(let X of Z)try{await r1(X),console.warn(`Deleted log file: ${X}`)}catch(Y){console.error(`Failed to delete log file ${X}:`,Y)}console.warn("Log clearing process finished.")}catch(J){console.error("Error during log clearing process:",J)}}}async function YZ($,J={}){let{maxRetries:Z=3,retryDelay:X=1000,isRetryable:Y=()=>!0,fallback:z}=J,Q=Error("Unknown error occurred");for(let G=0;G<=Z;G++)try{return await $()}catch(q){if(Q=q instanceof Error?q:Error(String(q)),G===Z||!Y(Q))break;if(X>0)await new Promise((U)=>setTimeout(U,X))}if(z!==void 0)return z;throw Q instanceof Error?Q:Error(`Unknown error: ${String(Q)}`)}function zZ($){return $ instanceof C0}function gz($){return $ instanceof K$}function xz($){if(zZ($))return $.code==="FILE_SYSTEM_ERROR"||$.code==="BROWSER_CONFIG_ERROR";return["ENOENT","EACCES","EMFILE","ENFILE","EBUSY","network","timeout","connection"].some((Z)=>$.message.toLowerCase().includes(Z.toLowerCase()))}class _${defaultParsers;constructor(){this.defaultParsers=[{name:"boolean",canParse:($,J)=>J==="boolean"||["true","false","1","0","yes","no"].includes($.toLowerCase()),parse:($)=>{let J=$.toLowerCase();return["true","1","yes"].includes(J)}},{name:"number",canParse:($,J)=>J==="number"||!Number.isNaN(Number($))&&!Number.isNaN(Number.parseFloat($)),parse:($)=>{let J=Number($);if(Number.isNaN(J))throw TypeError(`Cannot parse "${$}" as number`);return J}},{name:"array",canParse:($,J)=>J==="array"||$.startsWith("[")||$.includes(","),parse:($)=>{try{let J=JSON.parse($);if(Array.isArray(J))return J}catch{}return $.split(",").map((J)=>J.trim())}},{name:"json",canParse:($,J)=>J==="object"||($.startsWith("{")&&$.endsWith("}")||$.startsWith("[")&&$.endsWith("]")),parse:($)=>{try{return JSON.parse($)}catch(J){throw Error(`Cannot parse "${$}" as JSON: ${J}`)}}}]}async applyEnvironmentVariables($,J,Z={}){let{prefix:X,useCamelCase:Y=!0,useBackwardCompatibility:z=!0,customParsers:Q={},verbose:G=!1,trackPerformance:q=!0}=Z,U=async()=>{if(!$)return{config:J,source:{type:"environment",priority:50,timestamp:new Date}};let W=X||this.generateEnvPrefix($),K={...J};return this.processObject(K,[],W,{useCamelCase:Y,useBackwardCompatibility:z,customParsers:Q,verbose:G,configName:$}),{config:K,source:{type:"environment",priority:50,timestamp:new Date}}};if(q)return C1.track("applyEnvironmentVariables",U,{configName:$});return U()}generateEnvPrefix($){return $.toUpperCase().replace(/-/g,"_")}formatEnvKey($,J){if(!J)return $.toUpperCase();return $.replace(/([A-Z])/g,"_$1").toUpperCase()}processObject($,J,Z,X){for(let[Y,z]of Object.entries($)){let Q=[...J,Y],G=Q.map((W)=>this.formatEnvKey(W,X.useCamelCase)),q=`${Z}_${G.join("_")}`,U=X.useBackwardCompatibility?`${Z}_${Q.map((W)=>W.toUpperCase()).join("_")}`:null;if(X.verbose);if(typeof z==="object"&&z!==null&&!Array.isArray(z))this.processObject(z,Q,Z,X);else{let W=l1.env[q]||(U?l1.env[U]:void 0);if(W!==void 0){if(X.verbose){let K=l1.env[q]?q:U}try{$[Y]=this.parseEnvironmentValue(W,typeof z,q,X.customParsers,X.configName)}catch(K){if(K instanceof H$)throw K;throw n0.envVar(q,W,typeof z,X.configName)}}}}}parseEnvironmentValue($,J,Z,X,Y){for(let[z,Q]of Object.entries(X))try{return Q($)}catch{continue}for(let z of this.defaultParsers)if(z.canParse($,J))try{return z.parse($)}catch{throw n0.envVar(Z,$,`${J} (via ${z.name} parser)`,Y)}return $}getEnvironmentVariables($){let J={},Z=$.toUpperCase();for(let[X,Y]of Object.entries(l1.env))if(X.startsWith(Z)&&Y!==void 0)J[X]=Y;return J}validateEnvironmentVariable($,J,Z){let X=[];if(!/^[A-Z_][A-Z0-9_]*$/.test($))X.push(`Environment variable key "${$}" should only contain uppercase letters, numbers, and underscores`);if(Z)try{this.parseEnvironmentValue($,J,Z,{})}catch(Y){X.push(`Cannot parse value "${J}" as ${Z}: ${Y}`)}return{isValid:X.length===0,errors:X}}generateEnvVarDocs($,J,Z={}){let{prefix:X,format:Y="text"}=Z,z=X||this.generateEnvPrefix($),Q=[];switch(this.extractEnvVarInfo(J,[],z,Q),Y){case"markdown":return this.formatAsMarkdown(Q,$);case"json":return JSON.stringify(Q,null,2);default:return this.formatAsText(Q,$)}}extractEnvVarInfo($,J,Z,X){for(let[Y,z]of Object.entries($)){let Q=[...J,Y],G=`${Z}_${Q.map((q)=>this.formatEnvKey(q,!0)).join("_")}`;if(typeof z==="object"&&z!==null&&!Array.isArray(z))this.extractEnvVarInfo(z,Q,Z,X);else X.push({key:G,type:Array.isArray(z)?"array":typeof z,description:`Configuration for ${Q.join(".")}`,example:this.generateExample(z)})}}generateExample($){if(Array.isArray($))return JSON.stringify($);if(typeof $==="object"&&$!==null)return JSON.stringify($);return String($)}formatAsText($,J){let Z=`Environment Variables for ${J}:
19
+ `)}finishProgressBar($,J){if(!this.enabled||!this.fancy||F0()||!J0.stdout.isTTY){this.activeProgressBar=null;return}if($.current<$.total)$.current=$.total;if(J)$.message=J;this.renderProgressBar($,!0),this.activeProgressBar=null}async clear($={}){if(F0()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let J=await c1(this.config.logDirectory),Z=[];for(let X of J){if(!($.name?new RegExp($.name.replace("*",".*")).test(X):X.startsWith(this.name))||!X.endsWith(".log"))continue;let z=W1(this.config.logDirectory,X);if($.before)try{if((await U1(z)).mtime>=$.before)continue}catch(Q){console.error(`Failed to get stats for file ${z}:`,Q);continue}Z.push(z)}if(Z.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${Z.length} log file(s)...`);for(let X of Z)try{await r1(X),console.warn(`Deleted log file: ${X}`)}catch(Y){console.error(`Failed to delete log file ${X}:`,Y)}console.warn("Log clearing process finished.")}catch(J){console.error("Error during log clearing process:",J)}}}async function YZ($,J={}){let{maxRetries:Z=3,retryDelay:X=1000,isRetryable:Y=()=>!0,fallback:z}=J,Q=Error("Unknown error occurred");for(let G=0;G<=Z;G++)try{return await $()}catch(q){if(Q=q instanceof Error?q:Error(String(q)),G===Z||!Y(Q))break;if(X>0)await new Promise((U)=>setTimeout(U,X))}if(z!==void 0)return z;throw Q instanceof Error?Q:Error(`Unknown error: ${String(Q)}`)}function zZ($){return $ instanceof C0}function gz($){return $ instanceof K$}function xz($){if(zZ($))return $.code==="FILE_SYSTEM_ERROR"||$.code==="BROWSER_CONFIG_ERROR";return["ENOENT","EACCES","EMFILE","ENFILE","EBUSY","network","timeout","connection"].some((Z)=>$.message.toLowerCase().includes(Z.toLowerCase()))}class _${defaultParsers;constructor(){this.defaultParsers=[{name:"boolean",canParse:($,J)=>J==="boolean"||["true","false","1","0","yes","no"].includes($.toLowerCase()),parse:($)=>{let J=$.toLowerCase();return["true","1","yes"].includes(J)}},{name:"number",canParse:($,J)=>J==="number"||!Number.isNaN(Number($))&&!Number.isNaN(Number.parseFloat($)),parse:($)=>{let J=Number($);if(Number.isNaN(J))throw TypeError(`Cannot parse "${$}" as number`);return J}},{name:"array",canParse:($,J)=>J==="array"||$.startsWith("[")||$.includes(","),parse:($)=>{try{let J=JSON.parse($);if(Array.isArray(J))return J}catch{}return $.split(",").map((J)=>J.trim())}},{name:"json",canParse:($,J)=>J==="object"||($.startsWith("{")&&$.endsWith("}")||$.startsWith("[")&&$.endsWith("]")),parse:($)=>{try{return JSON.parse($)}catch(J){throw Error(`Cannot parse "${$}" as JSON: ${J}`)}}}]}async applyEnvironmentVariables($,J,Z={}){let{prefix:X,useCamelCase:Y=!0,useBackwardCompatibility:z=!0,customParsers:Q={},verbose:G=!1,trackPerformance:q=!0}=Z,U=async()=>{if(!$)return{config:J,source:{type:"environment",priority:50,timestamp:new Date}};let W=X||this.generateEnvPrefix($),K={...J};return this.processObject(K,[],W,{useCamelCase:Y,useBackwardCompatibility:z,customParsers:Q,verbose:G,configName:$}),{config:K,source:{type:"environment",priority:50,timestamp:new Date}}};if(q)return I1.track("applyEnvironmentVariables",U,{configName:$});return U()}generateEnvPrefix($){return $.toUpperCase().replace(/-/g,"_")}formatEnvKey($,J){if(!J)return $.toUpperCase();return $.replace(/([A-Z])/g,"_$1").toUpperCase()}processObject($,J,Z,X){for(let[Y,z]of Object.entries($)){let Q=[...J,Y],G=Q.map((W)=>this.formatEnvKey(W,X.useCamelCase)),q=`${Z}_${G.join("_")}`,U=X.useBackwardCompatibility?`${Z}_${Q.map((W)=>W.toUpperCase()).join("_")}`:null;if(X.verbose);if(typeof z==="object"&&z!==null&&!Array.isArray(z))this.processObject(z,Q,Z,X);else{let W=l1.env[q]||(U?l1.env[U]:void 0);if(W!==void 0){if(X.verbose){let K=l1.env[q]?q:U}try{$[Y]=this.parseEnvironmentValue(W,typeof z,q,X.customParsers,X.configName)}catch(K){if(K instanceof H$)throw K;throw n0.envVar(q,W,typeof z,X.configName)}}}}}parseEnvironmentValue($,J,Z,X,Y){for(let[z,Q]of Object.entries(X))try{return Q($)}catch{continue}for(let z of this.defaultParsers)if(z.canParse($,J))try{return z.parse($)}catch{throw n0.envVar(Z,$,`${J} (via ${z.name} parser)`,Y)}return $}getEnvironmentVariables($){let J={},Z=$.toUpperCase();for(let[X,Y]of Object.entries(l1.env))if(X.startsWith(Z)&&Y!==void 0)J[X]=Y;return J}validateEnvironmentVariable($,J,Z){let X=[];if(!/^[A-Z_][A-Z0-9_]*$/.test($))X.push(`Environment variable key "${$}" should only contain uppercase letters, numbers, and underscores`);if(Z)try{this.parseEnvironmentValue($,J,Z,{})}catch(Y){X.push(`Cannot parse value "${J}" as ${Z}: ${Y}`)}return{isValid:X.length===0,errors:X}}generateEnvVarDocs($,J,Z={}){let{prefix:X,format:Y="text"}=Z,z=X||this.generateEnvPrefix($),Q=[];switch(this.extractEnvVarInfo(J,[],z,Q),Y){case"markdown":return this.formatAsMarkdown(Q,$);case"json":return JSON.stringify(Q,null,2);default:return this.formatAsText(Q,$)}}extractEnvVarInfo($,J,Z,X){for(let[Y,z]of Object.entries($)){let Q=[...J,Y],G=`${Z}_${Q.map((q)=>this.formatEnvKey(q,!0)).join("_")}`;if(typeof z==="object"&&z!==null&&!Array.isArray(z))this.extractEnvVarInfo(z,Q,Z,X);else X.push({key:G,type:Array.isArray(z)?"array":typeof z,description:`Configuration for ${Q.join(".")}`,example:this.generateExample(z)})}}generateExample($){if(Array.isArray($))return JSON.stringify($);if(typeof $==="object"&&$!==null)return JSON.stringify($);return String($)}formatAsText($,J){let Z=`Environment Variables for ${J}:
20
20
 
21
21
  `;for(let X of $)Z+=`${X.key}
22
22
  `,Z+=` Type: ${X.type}
@@ -28,7 +28,7 @@ import{B as Z0,D as g1,E as x1,F as H9,G as p1,i as k0,j as L0,k as x8,l as gY,m
28
28
  `;Z+=`| Variable | Type | Description | Example |
29
29
  `,Z+=`|----------|------|-------------|----------|
30
30
  `;for(let X of $)Z+=`| \`${X.key}\` | ${X.type} | ${X.description} | \`${X.example}\` |
31
- `;return Z}}function pz($,J){let Z=WZ("process");if(typeof Z>"u"||!Z.env)return J;let X=Z.env[$];return X!==void 0?X:J}function QZ($,J,Z={}){return GZ($,J,Z,new WeakMap)}function GZ($,J,Z,X){let{arrayMergeMode:Y="replace",skipNullish:z=!1,customMerger:Q}=Z;if(J===null||J===void 0)return z?$:J;if(Q){let G=Q($,J);if(G!==void 0)return G}if(Array.isArray(J)||Array.isArray($))return qZ($,J,Y,X);if(!S0(J)||!S0($))return J;return dz($,J,Z,X)}function qZ($,J,Z,X){if(Array.isArray(J)&&!Array.isArray($))return J;if(Array.isArray($)&&!Array.isArray(J))return J;if(Array.isArray(J)&&Array.isArray($))switch(Z){case"replace":return J;case"concat":return hz($,J);case"smart":return uz($,J,X);default:return J}return J}function hz($,J){let Z=[...J];for(let X of $)if(!Z.some((Y)=>U7(Y,X)))Z.push(X);return Z}function uz($,J,Z){if(J.length===0)return $;if($.length===0)return J;if(S0(J[0])&&S0($[0]))return mz($,J,Z);if(J.every((X)=>typeof X==="string")&&$.every((X)=>typeof X==="string")){let X=[...J];for(let Y of $)if(!X.includes(Y))X.push(Y);return X}return J}function mz($,J,Z){let X=[...J];for(let Y of $){if(!S0(Y)){X.push(Y);continue}let z=["id","name","key","path","type"],Q=!1;for(let G of z)if(G in Y){if(X.find((U)=>S0(U)&&(G in U)&&U[G]===Y[G])){Q=!0;break}}if(!Q)X.push(Y)}return X}function dz($,J,Z,X){let Y=J;if(S0(Y)&&X.has(Y))return X.get(Y);let z={...$};if(S0(Y))X.set(Y,z);for(let Q in Y){if(!Object.prototype.hasOwnProperty.call(Y,Q))continue;let G=Y[Q],q=z[Q];if(Z.skipNullish&&(G===null||G===void 0))continue;if(G===null||G===void 0){z[Q]=G;continue}if(S0(G)&&S0(q))z[Q]=GZ(q,G,Z,X);else if(Array.isArray(G)||Array.isArray(q))z[Q]=qZ(q,G,Z.arrayMergeMode||"smart",X);else z[Q]=G}return z}function T7($,J,Z="replace"){return QZ($,J,{arrayMergeMode:Z==="replace"?"replace":"smart",skipNullish:!0})}function U7($,J){if($===J)return!0;if(Array.isArray($)&&Array.isArray(J)){if($.length!==J.length)return!1;for(let Z=0;Z<$.length;Z++)if(!U7($[Z],J[Z]))return!1;return!0}if(S0($)&&S0(J)){let Z=Object.keys($),X=Object.keys(J);if(Z.length!==X.length)return!1;for(let Y of Z){if(!Object.prototype.hasOwnProperty.call(J,Y))return!1;if(!U7($[Y],J[Y]))return!1}return!0}return!1}function S0($){return Boolean($&&typeof $==="object"&&!Array.isArray($))}class F${extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath($,J,Z={}){let{arrayStrategy:X="replace",useCache:Y=!0,cacheTtl:z,trackPerformance:Q=!0,verbose:G=!1}=Z;if(Y){let U=A1.getWithFileCheck("file",$);if(U){if(G)console.log(`Configuration loaded from cache: ${$}`);return U}}let q=async()=>{if(!a1($))return null;try{let U=`?t=${Date.now()}`,W=await import($+U),K=W.default||W,H="default"in W,V=Object.keys(W).length>0;if(!H&&!V)throw new L1($,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof K!=="object"||K===null||Array.isArray(K))throw new L1($,Error("Configuration must export a valid object"),"unknown");let F={config:T7(J,K,X),source:{type:"file",path:$,priority:100,timestamp:new Date}};if(Y)A1.setWithFileCheck("file",F,$,z);return F}catch(U){throw U instanceof Error?n0.configLoad($,U):n0.configLoad($,Error(String(U)))}};if(Q)return C1.track("loadFromPath",q,{path:$});return q()}async tryLoadFromPaths($,J,Z={}){for(let X of $)try{let Y=await this.loadFromPath(X,J,Z);if(Y)return Y}catch(Y){if(Y instanceof Error&&Y.name==="ConfigLoadError")throw Y;if(Z.verbose)console.warn(`Failed to load config from ${X}:`,Y)}return null}generateConfigPaths($,J,Z){let X=this.generateNamePatterns($,Z),Y=[];for(let z of X)for(let Q of this.extensions)Y.push(i8(J,`${z}${Q}`));return Y}generateNamePatterns($,J){let Z=[];if(Z.push("config",".config"),$)Z.push($,`.${$}.config`,`${$}.config`,`.${$}`);if(J){if(Z.push(J,`.${J}.config`,`${J}.config`,`.${J}`),$)Z.push(`${$}.${J}.config`,`.${$}.${J}.config`)}return Z.filter(Boolean)}checkFileAccess($){return YZ(async()=>{return a1($)},{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles($,J,Z){let X=[];if(!a1($))return X;if(J||Z){let Y=this.generateNamePatterns(J||"",Z);for(let z of Y)for(let Q of this.extensions){let G=i8($,`${z}${Q}`);if(await this.checkFileAccess(G))X.push(G)}}else try{let{readdirSync:Y}=await import("fs"),z=Y($);for(let Q of z)if(this.looksLikeConfigFile(Q)){let G=i8($,Q);if(await this.checkFileAccess(G))X.push(G)}}catch{return[]}return X}looksLikeConfigFile($){return[/\.config\.(ts|js|mjs|cjs|json|mts|cts)$/,/^\..*\.(ts|js|mjs|cjs|json|mts|cts)$/,/config\.(ts|js|mjs|cjs|json|mts|cts)$/].some((Z)=>Z.test($))}async validateConfigFile($){let J=[];try{if(!a1($))return J.push("Configuration file does not exist"),J;let Z=await import($),X=Z.default||Z;if(X===void 0)J.push("Configuration file must export a default value or named exports");else if(typeof X!=="object"||X===null)J.push("Configuration must be an object");else if(Array.isArray(X))J.push("Configuration cannot be an array at the root level");if($.endsWith(".json"))try{let{readFileSync:Y}=await import("fs"),z=Y($,"utf8");JSON.parse(z)}catch(Y){J.push(`Invalid JSON syntax: ${Y}`)}}catch(Z){J.push(`Failed to load configuration file: ${Z}`)}return J}async getFileModificationTime($){try{let{statSync:J}=await import("fs");return J($).mtime}catch{return null}}async preloadConfigurations($,J={}){let Z=new Map;return await Promise.allSettled($.map(async(X)=>{try{let Y=await this.loadFromPath(X,{},J);if(Y)Z.set(X,Y.config)}catch(Y){if(J.verbose)console.warn(`Failed to preload ${X}:`,Y)}})),Z}}class E7{async validateConfiguration($,J,Z={}){let{stopOnFirstError:X=!1,validateRequired:Y=!0,validateTypes:z=!0,customRules:Q=[],trackPerformance:G=!0,verbose:q=!1}=Z,U=async()=>{let W=[],K=[],H={stopOnFirstError:X,validateRequired:Y,validateTypes:z,customRules:Q,trackPerformance:G,verbose:q};try{if(typeof J==="string")return await this.validateWithSchemaFile($,J,H);else if(Array.isArray(J))return this.validateWithRules($,[...J,...Q],H);else return this.validateWithJSONSchema($,J,H)}catch(V){return W.push({path:"",message:`Validation failed: ${V}`,rule:"system"}),{isValid:!1,errors:W,warnings:K}}};if(G)return await C1.track("validateConfiguration",U);return U()}async validateWithSchemaFile($,J,Z){try{if(!jz(J))throw new P1(J,[{path:"",message:"Schema file does not exist"}]);let X=await import(J),Y=X.default||X;if(Array.isArray(Y))return this.validateWithRules($,Y,Z);else return this.validateWithJSONSchema($,Y,Z)}catch(X){throw new P1(J,[{path:"",message:`Failed to load schema: ${X}`}])}}validateWithJSONSchema($,J,Z){let X=[],Y=[];return this.validateObjectAgainstSchema($,J,"",X,Y,Z),{isValid:X.length===0,errors:X,warnings:Y}}validateObjectAgainstSchema($,J,Z,X,Y,z){if(z.validateTypes&&J.type){let Q=Array.isArray($)?"array":typeof $,G=Array.isArray(J.type)?J.type:[J.type];if(!G.includes(Q)){if(X.push({path:Z,message:`Expected type ${G.join(" or ")}, got ${Q}`,expected:G.join(" or "),actual:Q,rule:"type"}),z.stopOnFirstError)return}}if(J.enum&&!J.enum.includes($)){if(X.push({path:Z,message:`Value must be one of: ${J.enum.join(", ")}`,expected:J.enum.join(", "),actual:$,rule:"enum"}),z.stopOnFirstError)return}if(typeof $==="string"){if(J.minLength!==void 0&&$.length<J.minLength)X.push({path:Z,message:`String length must be at least ${J.minLength}`,expected:`>= ${J.minLength}`,actual:$.length,rule:"minLength"});if(J.maxLength!==void 0&&$.length>J.maxLength)X.push({path:Z,message:`String length must not exceed ${J.maxLength}`,expected:`<= ${J.maxLength}`,actual:$.length,rule:"maxLength"});if(J.pattern){if(!new RegExp(J.pattern).test($))X.push({path:Z,message:`String does not match pattern ${J.pattern}`,expected:J.pattern,actual:$,rule:"pattern"})}}if(typeof $==="number"){if(J.minimum!==void 0&&$<J.minimum)X.push({path:Z,message:`Value must be at least ${J.minimum}`,expected:`>= ${J.minimum}`,actual:$,rule:"minimum"});if(J.maximum!==void 0&&$>J.maximum)X.push({path:Z,message:`Value must not exceed ${J.maximum}`,expected:`<= ${J.maximum}`,actual:$,rule:"maximum"})}if(Array.isArray($)&&J.items)for(let Q=0;Q<$.length;Q++){let G=Z?`${Z}[${Q}]`:`[${Q}]`;if(this.validateObjectAgainstSchema($[Q],J.items,G,X,Y,z),z.stopOnFirstError&&X.length>0)return}if($&&typeof $==="object"&&!Array.isArray($)){let Q=$;if(z.validateRequired&&J.required){for(let G of J.required)if(!(G in Q)){if(X.push({path:Z?`${Z}.${G}`:G,message:`Missing required property '${G}'`,expected:"required",rule:"required"}),z.stopOnFirstError)return}}if(J.properties){for(let[G,q]of Object.entries(J.properties))if(G in Q){let U=Z?`${Z}.${G}`:G;if(this.validateObjectAgainstSchema(Q[G],q,U,X,Y,z),z.stopOnFirstError&&X.length>0)return}}if(J.additionalProperties===!1){let G=new Set(Object.keys(J.properties||{}));for(let q of Object.keys(Q))if(!G.has(q))Y.push({path:Z?`${Z}.${q}`:q,message:`Additional property '${q}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules($,J,Z){let X=[],Y=[];for(let z of J)try{let Q=this.getValueByPath($,z.path),G=this.validateWithRule(Q,z,z.path);if(X.push(...G),Z.stopOnFirstError&&X.length>0)break}catch(Q){X.push({path:z.path,message:`Rule validation failed: ${Q}`,rule:"system"})}return{isValid:X.length===0,errors:X,warnings:Y}}validateWithRule($,J,Z){let X=[];if(J.required&&($===void 0||$===null))return X.push({path:Z,message:J.message||`Property '${Z}' is required`,expected:"required",rule:"required"}),X;if($===void 0||$===null)return X;if(J.type){let Y=Array.isArray($)?"array":typeof $;if(Y!==J.type)X.push({path:Z,message:J.message||`Expected type ${J.type}, got ${Y}`,expected:J.type,actual:Y,rule:"type"})}if(J.min!==void 0){let Y=Array.isArray($)?$.length:typeof $==="string"?$.length:typeof $==="number"?$:0;if(Y<J.min)X.push({path:Z,message:J.message||`Value must be at least ${J.min}`,expected:`>= ${J.min}`,actual:Y,rule:"min"})}if(J.max!==void 0){let Y=Array.isArray($)?$.length:typeof $==="string"?$.length:typeof $==="number"?$:0;if(Y>J.max)X.push({path:Z,message:J.message||`Value must not exceed ${J.max}`,expected:`<= ${J.max}`,actual:Y,rule:"max"})}if(J.pattern&&typeof $==="string"){if(!J.pattern.test($))X.push({path:Z,message:J.message||`Value does not match pattern ${J.pattern}`,expected:J.pattern.toString(),actual:$,rule:"pattern"})}if(J.enum&&!J.enum.includes($))X.push({path:Z,message:J.message||`Value must be one of: ${J.enum.join(", ")}`,expected:J.enum.join(", "),actual:$,rule:"enum"});if(J.validator){let Y=J.validator($);if(Y)X.push({path:Z,message:J.message||Y,rule:"custom"})}return X}getValueByPath($,J){if(!J)return $;let Z=J.split("."),X=$;for(let Y of Z)if(X&&typeof X==="object"&&Y in X)X=X[Y];else return;return X}generateRulesFromInterface($){let J=[],Z=$.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let X of Z){let[,Y,z,Q]=X;J.push({path:Y,required:!z,type:this.mapTypeScriptType(Q)})}return J}mapTypeScriptType($){switch($.toLowerCase()){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"array":return"array";case"object":return"object";default:return"object"}}static createCommonRules(){return{server:[{path:"port",required:!0,type:"number",min:1,max:65535},{path:"host",required:!0,type:"string",min:1},{path:"ssl",type:"boolean"}],database:[{path:"url",required:!0,type:"string",min:1},{path:"pool",type:"number",min:1,max:100},{path:"timeout",type:"number",min:0}],api:[{path:"baseUrl",required:!0,type:"string",pattern:_Z},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}class D7{fileLoader=new F$;envProcessor=new _$;validator=new E7;async loadConfig($){let J=Date.now(),{cache:Z,performance:X,schema:Y,validate:z,...Q}=$;try{if(Z?.enabled){let q=this.checkCache(Q.name||"",Q);if(q)return q}let G;try{G=await this.loadConfigurationStrategies(Q,!0,Z)}catch(q){let U=Q.__strictErrorHandling;if(q instanceof Error&&q.name==="ConfigNotFoundError"){if(U)throw q;G={...await this.applyEnvironmentVariables(Q.name||"",Q.defaultConfig,Q.checkEnv!==!1,Q.verbose||!1),warnings:[`No configuration file found for "${Q.name||"config"}", using defaults with environment variables`]}}else if(q instanceof Error&&q.name==="ConfigLoadError"){let W=q.message.includes("EACCES")||q.message.includes("EPERM")||q.message.includes("permission denied"),K=!W&&(q.message.includes("syntax")||q.message.includes("Expected")||q.message.includes("Unexpected")||q.message.includes("BuildMessage")||q.message.includes("errors building")),H=q.message.includes("Configuration must export a valid object")||q.message.includes("Configuration file is empty and exports nothing");if(U&&(H||W))throw q;if(K&&(!U||!H))G={...await this.applyEnvironmentVariables(Q.name||"",Q.defaultConfig,Q.checkEnv!==!1,Q.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!U)G={...await this.applyEnvironmentVariables(Q.name||"",Q.defaultConfig,Q.checkEnv!==!1,Q.verbose||!1),warnings:[`Configuration loading error, using defaults: ${q.message}`]};else throw q}else G={...await this.applyEnvironmentVariables(Q.name||"",Q.defaultConfig,Q.checkEnv!==!1,Q.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${q instanceof Error?q.message:String(q)}`]}}if(Y||z)await this.validateConfiguration(G.config,Y,z,Q.name);if(Z?.enabled&&G)this.cacheResult(Q.name||"",G,Z,Q);if(X?.enabled){let q={operation:"loadConfig",duration:Date.now()-J,configName:Q.name,timestamp:new Date};if(X.onMetrics)X.onMetrics(q);if(X.slowThreshold&&q.duration>X.slowThreshold)b0.warn(`Slow configuration loading detected: ${q.duration}ms for ${Q.name}`);G.metrics=q}return G}catch(G){let q=Date.now()-J;throw b0.error(`Configuration loading failed after ${q}ms:`,[G instanceof Error?G:Error(String(G))]),G}}async loadConfigurationStrategies($,J=!1,Z){let{name:X="",alias:Y,cwd:z,configDir:Q,defaultConfig:G,checkEnv:q=!0,arrayStrategy:U="replace",verbose:W=!1}=$,K=z||e0.cwd(),H=[],V=await this.loadLocalConfiguration(X,Y,K,Q,G,U,W,q,Z);if(V)return H.push(...this.getLocalSearchPaths(X,Y,K,Q)),this.finalizeResult(V,H,q,X,W);let A=await this.loadHomeConfiguration(X,Y,G,U,W,q);if(A)return H.push(...this.getHomeSearchPaths(X,Y)),this.finalizeResult(A,H,q,X,W);let _=await this.loadPackageJsonConfiguration(X,Y,K,G,U,W,q);if(_)return H.push(O0(K,"package.json")),this.finalizeResult(_,H,q,X,W);if(H.push(...this.getAllSearchPaths(X,Y,K,Q)),J)throw n0.configNotFound(X,H,Y);return{...await this.applyEnvironmentVariables(X,G,q,W),warnings:[`No configuration file found for "${X}"${Y?` or alias "${Y}"`:""}, using defaults with environment variables`]}}async loadLocalConfiguration($,J,Z,X,Y,z,Q,G,q){let U=G?R1($,Y,Q):Y,W=this.getLocalDirectories(Z,X);for(let K of W){if(Q)b0.info(`Searching for configuration in: ${K}`);let H=this.fileLoader.generateConfigPaths($,K,J),V=await this.fileLoader.tryLoadFromPaths(H,U,{arrayStrategy:z,verbose:Q,cacheTtl:q?.ttl,useCache:!q?.ttl||q.ttl>100});if(V){if(Q)b0.success(`Configuration loaded from: ${V.source.path}`);return V}}return null}async loadHomeConfiguration($,J,Z,X,Y,z){if(!$)return null;let Q=z?R1($,Z,Y):Z,G=[O0(Y1(),".config",$),O0(Y1(),".config"),Y1()];for(let q of G){if(Y)b0.info(`Checking home directory: ${q}`);let U=this.fileLoader.generateConfigPaths($,q,J),W=await this.fileLoader.tryLoadFromPaths(U,Q,{arrayStrategy:X,verbose:Y});if(W){if(Y)b0.success(`Configuration loaded from home directory: ${W.source.path}`);return W}}return null}async loadPackageJsonConfiguration($,J,Z,X,Y,z,Q){let G=Q?R1($,X,z):X;try{let q=O0(Z,"package.json");if(!G7(q))return null;let U=await import(q),W=U[$],K=$;if(!W&&J)W=U[J],K=J;if(W&&typeof W==="object"&&!Array.isArray(W)){if(z)b0.success(`Configuration loaded from package.json: ${K}`);return{config:T7(G,W,Y),source:{type:"package.json",path:q,priority:30,timestamp:new Date}}}}catch(q){if(z)b0.warn("Failed to load package.json:",[q instanceof Error?q:Error(String(q))])}return null}async applyEnvironmentVariables($,J,Z,X){if(!Z||!$||typeof J!=="object"||J===null||Array.isArray(J))return{config:J,source:{type:"default",priority:10,timestamp:new Date}};return{config:R1($,J,X),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult($,J,Z,X,Y){return{config:$.config,source:$.source,path:$.source.path}}async validateConfiguration($,J,Z,X){let Y=[];if(Z){let z=Z($);if(z)Y.push(...z)}if(J){let z=await this.validator.validateConfiguration($,J);if(!z.isValid)Y.push(...z.errors.map((Q)=>Q.path?`${Q.path}: ${Q.message}`:Q.message))}if(Y.length>0)throw n0.configValidation(X||"unknown",Y,X)}checkCache($,J){let Z=this.generateCacheKey($,J);return A1.get(Z)||null}cacheResult($,J,Z,X){let Y=this.generateCacheKey($,X);A1.set(Y,J,void 0,Z.ttl)}generateCacheKey($,J){let Z=[$];if(J.alias)Z.push(`alias:${J.alias}`);if(J.cwd)Z.push(`cwd:${J.cwd}`);if(J.configDir)Z.push(`configDir:${J.configDir}`);if("checkEnv"in J)Z.push(`checkEnv:${J.checkEnv}`);return Z.join("|")}getLocalDirectories($,J){return Array.from(new Set([$,O0($,"config"),O0($,".config"),J?O0($,J):void 0].filter(Boolean)))}getAllSearchPaths($,J,Z,X){let Y=[];return Y.push(...this.getLocalSearchPaths($,J,Z,X)),Y.push(...this.getHomeSearchPaths($,J)),Y.push(O0(Z,"package.json")),Y}getLocalSearchPaths($,J,Z,X){let Y=this.getLocalDirectories(Z,X),z=[];for(let Q of Y)z.push(...this.fileLoader.generateConfigPaths($,Q,J));return z}getHomeSearchPaths($,J){if(!$)return[];let Z=[O0(Y1(),".config",$),O0(Y1(),".config"),Y1()],X=[];for(let Y of Z)X.push(...this.fileLoader.generateConfigPaths($,Y,J));return X}async loadConfigWithResult($){return this.loadConfig($)}}function y9($){let Z=!($.message.includes("EACCES")||$.message.includes("EPERM")||$.message.includes("permission denied"))&&($.message.includes("syntax")||$.message.includes("Expected")||$.message.includes("Unexpected")||$.message.includes("BuildMessage")),X=$.message.includes("Configuration must export a valid object")||$.message.includes("Configuration file is empty and exports nothing");return Z||X}async function oz($){return l0.loadConfig({...$,__strictErrorHandling:!0})}async function UZ($){let J="defaultConfig"in $&&$.defaultConfig!==void 0?$.defaultConfig:{},Z="cache"in $||"performance"in $||"schema"in $||"validate"in $;try{let X;if(Z)X=await l0.loadConfig($);else X=await l0.loadConfig({...$,defaultConfig:J,cache:{enabled:!0},performance:{enabled:!1}});return X?.config??J}catch(X){let Y=X instanceof Error?X.name:"UnknownError",z=X instanceof Error?X.message:String(X);if(!(Y==="ConfigNotFoundError"||Y==="ConfigLoadError"||Y==="ConfigValidationError"||z.includes("config"))&&$.verbose)b0.warn("Unexpected error loading config, using defaults:",[X instanceof Error?X:Error(String(X))]);let G=Z?{...$,defaultConfig:J}:{...$,defaultConfig:J,cache:{enabled:!0},performance:{enabled:!1}};if("checkEnv"in $?$.checkEnv!==!1:!0)return(await l0.applyEnvironmentVariables(G.name||"",J,!0,G.verbose||!1))?.config??J;return J}}async function cz($={defaultConfig:{}}){if(typeof $==="string"){let{cwd:J}=await import("process");try{return(await l0.loadConfig({name:$,cwd:J(),generatedDir:"./generated",configDir:"./config",defaultConfig:{},checkEnv:!0,arrayStrategy:"replace"})).config}catch(Z){if(Z instanceof Error&&(Z.name==="ConfigNotFoundError"||Z.name==="ConfigLoadError"&&y9(Z)))return(await l0.applyEnvironmentVariables($,{},!0,!1)).config;throw Z}}try{return(await l0.loadConfig({...$,cwd:$.cwd||e0.cwd(),cache:{enabled:!0},performance:{enabled:!1}})).config}catch(J){if(J instanceof Error&&(J.name==="ConfigNotFoundError"||J.name==="ConfigLoadError"&&y9(J)))return(await l0.applyEnvironmentVariables($.name||"",$.defaultConfig||{},$.checkEnv!==!1,$.verbose||!1)).config;throw J}}async function rz($,J,Z="replace"){let X=new F$;try{let Y=await X.loadFromPath($,J,{arrayStrategy:Z,useCache:!1,trackPerformance:!1});return Y?Y.config:null}catch{return null}}function R1($,J,Z=!1){let X=new _$,Y=$.toUpperCase().replace(/[^A-Z0-9]/g,"_");function z(Q,G=[]){let q={...Q};for(let[U,W]of Object.entries(Q)){let K=[...G,U],H=[`${Y}_${K.join("_").toUpperCase()}`,`${Y}_${K.map((_)=>_.toUpperCase()).join("")}`,`${Y}_${K.map((_)=>_.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],V,A;for(let _ of H)if(V=e0.env[_],V!==void 0){A=_;break}if(V!==void 0&&A)if(typeof W==="boolean")q[U]=["true","1","yes"].includes(V.toLowerCase());else if(typeof W==="number"){let _=Number(V);if(!Number.isNaN(_))q[U]=_}else if(Array.isArray(W))try{q[U]=JSON.parse(V)}catch{q[U]=V.split(",").map((_)=>_.trim())}else q[U]=V;else if(W&&typeof W==="object"&&!Array.isArray(W))q[U]=z(W,K)}return q}return z(J)}function lz($){let J=O0(e0.cwd(),$.configDir),Z=O0(e0.cwd(),$.generatedDir),X=O0(Z,"config-types.ts");if(!G7(B9(X)))iY(B9(X),{recursive:!0,mode:511});let Y=G7(J)?tY(J).map((Q)=>Q.replace(/\.(ts|js|mjs|cjs|mts|cts|json)$/,"")).sort():[],z=`// Generated by bunfig v${TQ}
31
+ `;return Z}}function pz($,J){let Z=WZ("process");if(typeof Z>"u"||!Z.env)return J;let X=Z.env[$];return X!==void 0?X:J}function QZ($,J,Z={}){return GZ($,J,Z,new WeakMap)}function GZ($,J,Z,X){let{arrayMergeMode:Y="replace",skipNullish:z=!1,customMerger:Q}=Z;if(J===null||J===void 0)return z?$:J;if(Q){let G=Q($,J);if(G!==void 0)return G}if(Array.isArray(J)||Array.isArray($))return qZ($,J,Y,X);if(!S0(J)||!S0($))return J;return dz($,J,Z,X)}function qZ($,J,Z,X){if(Array.isArray(J)&&!Array.isArray($))return J;if(Array.isArray($)&&!Array.isArray(J))return J;if(Array.isArray(J)&&Array.isArray($))switch(Z){case"replace":return J;case"concat":return hz($,J);case"smart":return uz($,J,X);default:return J}return J}function hz($,J){let Z=[...J];for(let X of $)if(!Z.some((Y)=>U7(Y,X)))Z.push(X);return Z}function uz($,J,Z){if(J.length===0)return $;if($.length===0)return J;if(S0(J[0])&&S0($[0]))return mz($,J,Z);if(J.every((X)=>typeof X==="string")&&$.every((X)=>typeof X==="string")){let X=[...J];for(let Y of $)if(!X.includes(Y))X.push(Y);return X}return J}function mz($,J,Z){let X=[...J];for(let Y of $){if(!S0(Y)){X.push(Y);continue}let z=["id","name","key","path","type"],Q=!1;for(let G of z)if(G in Y){if(X.find((U)=>S0(U)&&(G in U)&&U[G]===Y[G])){Q=!0;break}}if(!Q)X.push(Y)}return X}function dz($,J,Z,X){let Y=J;if(S0(Y)&&X.has(Y))return X.get(Y);let z={...$};if(S0(Y))X.set(Y,z);for(let Q in Y){if(!Object.prototype.hasOwnProperty.call(Y,Q))continue;let G=Y[Q],q=z[Q];if(Z.skipNullish&&(G===null||G===void 0))continue;if(G===null||G===void 0){z[Q]=G;continue}if(S0(G)&&S0(q))z[Q]=GZ(q,G,Z,X);else if(Array.isArray(G)||Array.isArray(q))z[Q]=qZ(q,G,Z.arrayMergeMode||"smart",X);else z[Q]=G}return z}function T7($,J,Z="replace"){return QZ($,J,{arrayMergeMode:Z==="replace"?"replace":"smart",skipNullish:!0})}function U7($,J){if($===J)return!0;if(Array.isArray($)&&Array.isArray(J)){if($.length!==J.length)return!1;for(let Z=0;Z<$.length;Z++)if(!U7($[Z],J[Z]))return!1;return!0}if(S0($)&&S0(J)){let Z=Object.keys($),X=Object.keys(J);if(Z.length!==X.length)return!1;for(let Y of Z){if(!Object.prototype.hasOwnProperty.call(J,Y))return!1;if(!U7($[Y],J[Y]))return!1}return!0}return!1}function S0($){return Boolean($&&typeof $==="object"&&!Array.isArray($))}class F${extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath($,J,Z={}){let{arrayStrategy:X="replace",useCache:Y=!0,cacheTtl:z,trackPerformance:Q=!0,verbose:G=!1}=Z;if(Y){let U=_1.getWithFileCheck("file",$);if(U){if(G)console.log(`Configuration loaded from cache: ${$}`);return U}}let q=async()=>{if(!a1($))return null;try{let U=`?t=${Date.now()}`,W=await import($+U),K=W.default||W,H="default"in W,V=Object.keys(W).length>0;if(!H&&!V)throw new P1($,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof K!=="object"||K===null||Array.isArray(K))throw new P1($,Error("Configuration must export a valid object"),"unknown");let F={config:T7(J,K,X),source:{type:"file",path:$,priority:100,timestamp:new Date}};if(Y)_1.setWithFileCheck("file",F,$,z);return F}catch(U){throw U instanceof Error?n0.configLoad($,U):n0.configLoad($,Error(String(U)))}};if(Q)return I1.track("loadFromPath",q,{path:$});return q()}async tryLoadFromPaths($,J,Z={}){for(let X of $)try{let Y=await this.loadFromPath(X,J,Z);if(Y)return Y}catch(Y){if(Y instanceof Error&&Y.name==="ConfigLoadError")throw Y;if(Z.verbose)console.warn(`Failed to load config from ${X}:`,Y)}return null}generateConfigPaths($,J,Z){let X=this.generateNamePatterns($,Z),Y=[];for(let z of X)for(let Q of this.extensions)Y.push(i8(J,`${z}${Q}`));return Y}generateNamePatterns($,J){let Z=[];if(Z.push("config",".config"),$)Z.push($,`.${$}.config`,`${$}.config`,`.${$}`);if(J){if(Z.push(J,`.${J}.config`,`${J}.config`,`.${J}`),$)Z.push(`${$}.${J}.config`,`.${$}.${J}.config`)}return Z.filter(Boolean)}checkFileAccess($){return YZ(async()=>{return a1($)},{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles($,J,Z){let X=[];if(!a1($))return X;if(J||Z){let Y=this.generateNamePatterns(J||"",Z);for(let z of Y)for(let Q of this.extensions){let G=i8($,`${z}${Q}`);if(await this.checkFileAccess(G))X.push(G)}}else try{let{readdirSync:Y}=await import("fs"),z=Y($);for(let Q of z)if(this.looksLikeConfigFile(Q)){let G=i8($,Q);if(await this.checkFileAccess(G))X.push(G)}}catch{return[]}return X}looksLikeConfigFile($){return[/\.config\.(ts|js|mjs|cjs|json|mts|cts)$/,/^\..*\.(ts|js|mjs|cjs|json|mts|cts)$/,/config\.(ts|js|mjs|cjs|json|mts|cts)$/].some((Z)=>Z.test($))}async validateConfigFile($){let J=[];try{if(!a1($))return J.push("Configuration file does not exist"),J;let Z=await import($),X=Z.default||Z;if(X===void 0)J.push("Configuration file must export a default value or named exports");else if(typeof X!=="object"||X===null)J.push("Configuration must be an object");else if(Array.isArray(X))J.push("Configuration cannot be an array at the root level");if($.endsWith(".json"))try{let{readFileSync:Y}=await import("fs"),z=Y($,"utf8");JSON.parse(z)}catch(Y){J.push(`Invalid JSON syntax: ${Y}`)}}catch(Z){J.push(`Failed to load configuration file: ${Z}`)}return J}async getFileModificationTime($){try{let{statSync:J}=await import("fs");return J($).mtime}catch{return null}}async preloadConfigurations($,J={}){let Z=new Map;return await Promise.allSettled($.map(async(X)=>{try{let Y=await this.loadFromPath(X,{},J);if(Y)Z.set(X,Y.config)}catch(Y){if(J.verbose)console.warn(`Failed to preload ${X}:`,Y)}})),Z}}class E7{async validateConfiguration($,J,Z={}){let{stopOnFirstError:X=!1,validateRequired:Y=!0,validateTypes:z=!0,customRules:Q=[],trackPerformance:G=!0,verbose:q=!1}=Z,U=async()=>{let W=[],K=[],H={stopOnFirstError:X,validateRequired:Y,validateTypes:z,customRules:Q,trackPerformance:G,verbose:q};try{if(typeof J==="string")return await this.validateWithSchemaFile($,J,H);else if(Array.isArray(J))return this.validateWithRules($,[...J,...Q],H);else return this.validateWithJSONSchema($,J,H)}catch(V){return W.push({path:"",message:`Validation failed: ${V}`,rule:"system"}),{isValid:!1,errors:W,warnings:K}}};if(G)return await I1.track("validateConfiguration",U);return U()}async validateWithSchemaFile($,J,Z){try{if(!jz(J))throw new C1(J,[{path:"",message:"Schema file does not exist"}]);let X=await import(J),Y=X.default||X;if(Array.isArray(Y))return this.validateWithRules($,Y,Z);else return this.validateWithJSONSchema($,Y,Z)}catch(X){throw new C1(J,[{path:"",message:`Failed to load schema: ${X}`}])}}validateWithJSONSchema($,J,Z){let X=[],Y=[];return this.validateObjectAgainstSchema($,J,"",X,Y,Z),{isValid:X.length===0,errors:X,warnings:Y}}validateObjectAgainstSchema($,J,Z,X,Y,z){if(z.validateTypes&&J.type){let Q=Array.isArray($)?"array":typeof $,G=Array.isArray(J.type)?J.type:[J.type];if(!G.includes(Q)){if(X.push({path:Z,message:`Expected type ${G.join(" or ")}, got ${Q}`,expected:G.join(" or "),actual:Q,rule:"type"}),z.stopOnFirstError)return}}if(J.enum&&!J.enum.includes($)){if(X.push({path:Z,message:`Value must be one of: ${J.enum.join(", ")}`,expected:J.enum.join(", "),actual:$,rule:"enum"}),z.stopOnFirstError)return}if(typeof $==="string"){if(J.minLength!==void 0&&$.length<J.minLength)X.push({path:Z,message:`String length must be at least ${J.minLength}`,expected:`>= ${J.minLength}`,actual:$.length,rule:"minLength"});if(J.maxLength!==void 0&&$.length>J.maxLength)X.push({path:Z,message:`String length must not exceed ${J.maxLength}`,expected:`<= ${J.maxLength}`,actual:$.length,rule:"maxLength"});if(J.pattern){if(!new RegExp(J.pattern).test($))X.push({path:Z,message:`String does not match pattern ${J.pattern}`,expected:J.pattern,actual:$,rule:"pattern"})}}if(typeof $==="number"){if(J.minimum!==void 0&&$<J.minimum)X.push({path:Z,message:`Value must be at least ${J.minimum}`,expected:`>= ${J.minimum}`,actual:$,rule:"minimum"});if(J.maximum!==void 0&&$>J.maximum)X.push({path:Z,message:`Value must not exceed ${J.maximum}`,expected:`<= ${J.maximum}`,actual:$,rule:"maximum"})}if(Array.isArray($)&&J.items)for(let Q=0;Q<$.length;Q++){let G=Z?`${Z}[${Q}]`:`[${Q}]`;if(this.validateObjectAgainstSchema($[Q],J.items,G,X,Y,z),z.stopOnFirstError&&X.length>0)return}if($&&typeof $==="object"&&!Array.isArray($)){let Q=$;if(z.validateRequired&&J.required){for(let G of J.required)if(!(G in Q)){if(X.push({path:Z?`${Z}.${G}`:G,message:`Missing required property '${G}'`,expected:"required",rule:"required"}),z.stopOnFirstError)return}}if(J.properties){for(let[G,q]of Object.entries(J.properties))if(G in Q){let U=Z?`${Z}.${G}`:G;if(this.validateObjectAgainstSchema(Q[G],q,U,X,Y,z),z.stopOnFirstError&&X.length>0)return}}if(J.additionalProperties===!1){let G=new Set(Object.keys(J.properties||{}));for(let q of Object.keys(Q))if(!G.has(q))Y.push({path:Z?`${Z}.${q}`:q,message:`Additional property '${q}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules($,J,Z){let X=[],Y=[];for(let z of J)try{let Q=this.getValueByPath($,z.path),G=this.validateWithRule(Q,z,z.path);if(X.push(...G),Z.stopOnFirstError&&X.length>0)break}catch(Q){X.push({path:z.path,message:`Rule validation failed: ${Q}`,rule:"system"})}return{isValid:X.length===0,errors:X,warnings:Y}}validateWithRule($,J,Z){let X=[];if(J.required&&($===void 0||$===null))return X.push({path:Z,message:J.message||`Property '${Z}' is required`,expected:"required",rule:"required"}),X;if($===void 0||$===null)return X;if(J.type){let Y=Array.isArray($)?"array":typeof $;if(Y!==J.type)X.push({path:Z,message:J.message||`Expected type ${J.type}, got ${Y}`,expected:J.type,actual:Y,rule:"type"})}if(J.min!==void 0){let Y=Array.isArray($)?$.length:typeof $==="string"?$.length:typeof $==="number"?$:0;if(Y<J.min)X.push({path:Z,message:J.message||`Value must be at least ${J.min}`,expected:`>= ${J.min}`,actual:Y,rule:"min"})}if(J.max!==void 0){let Y=Array.isArray($)?$.length:typeof $==="string"?$.length:typeof $==="number"?$:0;if(Y>J.max)X.push({path:Z,message:J.message||`Value must not exceed ${J.max}`,expected:`<= ${J.max}`,actual:Y,rule:"max"})}if(J.pattern&&typeof $==="string"){if(!J.pattern.test($))X.push({path:Z,message:J.message||`Value does not match pattern ${J.pattern}`,expected:J.pattern.toString(),actual:$,rule:"pattern"})}if(J.enum&&!J.enum.includes($))X.push({path:Z,message:J.message||`Value must be one of: ${J.enum.join(", ")}`,expected:J.enum.join(", "),actual:$,rule:"enum"});if(J.validator){let Y=J.validator($);if(Y)X.push({path:Z,message:J.message||Y,rule:"custom"})}return X}getValueByPath($,J){if(!J)return $;let Z=J.split("."),X=$;for(let Y of Z)if(X&&typeof X==="object"&&Y in X)X=X[Y];else return;return X}generateRulesFromInterface($){let J=[],Z=$.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let X of Z){let[,Y,z,Q]=X;J.push({path:Y,required:!z,type:this.mapTypeScriptType(Q)})}return J}mapTypeScriptType($){switch($.toLowerCase()){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"array":return"array";case"object":return"object";default:return"object"}}static createCommonRules(){return{server:[{path:"port",required:!0,type:"number",min:1,max:65535},{path:"host",required:!0,type:"string",min:1},{path:"ssl",type:"boolean"}],database:[{path:"url",required:!0,type:"string",min:1},{path:"pool",type:"number",min:1,max:100},{path:"timeout",type:"number",min:0}],api:[{path:"baseUrl",required:!0,type:"string",pattern:_Z},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}class D7{fileLoader=new F$;envProcessor=new _$;validator=new E7;async loadConfig($){let J=Date.now(),{cache:Z,performance:X,schema:Y,validate:z,...Q}=$;try{if(Z?.enabled){let q=this.checkCache(Q.name||"",Q);if(q)return q}let G;try{G=await this.loadConfigurationStrategies(Q,!0,Z)}catch(q){let U=Q.__strictErrorHandling;if(q instanceof Error&&q.name==="ConfigNotFoundError"){if(U)throw q;G={...await this.applyEnvironmentVariables(Q.name||"",Q.defaultConfig,Q.checkEnv!==!1,Q.verbose||!1),warnings:[`No configuration file found for "${Q.name||"config"}", using defaults with environment variables`]}}else if(q instanceof Error&&q.name==="ConfigLoadError"){let W=q.message.includes("EACCES")||q.message.includes("EPERM")||q.message.includes("permission denied"),K=!W&&(q.message.includes("syntax")||q.message.includes("Expected")||q.message.includes("Unexpected")||q.message.includes("BuildMessage")||q.message.includes("errors building")),H=q.message.includes("Configuration must export a valid object")||q.message.includes("Configuration file is empty and exports nothing");if(U&&(H||W))throw q;if(K&&(!U||!H))G={...await this.applyEnvironmentVariables(Q.name||"",Q.defaultConfig,Q.checkEnv!==!1,Q.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!U)G={...await this.applyEnvironmentVariables(Q.name||"",Q.defaultConfig,Q.checkEnv!==!1,Q.verbose||!1),warnings:[`Configuration loading error, using defaults: ${q.message}`]};else throw q}else G={...await this.applyEnvironmentVariables(Q.name||"",Q.defaultConfig,Q.checkEnv!==!1,Q.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${q instanceof Error?q.message:String(q)}`]}}if(Y||z)await this.validateConfiguration(G.config,Y,z,Q.name);if(Z?.enabled&&G)this.cacheResult(Q.name||"",G,Z,Q);if(X?.enabled){let q={operation:"loadConfig",duration:Date.now()-J,configName:Q.name,timestamp:new Date};if(X.onMetrics)X.onMetrics(q);if(X.slowThreshold&&q.duration>X.slowThreshold)b0.warn(`Slow configuration loading detected: ${q.duration}ms for ${Q.name}`);G.metrics=q}return G}catch(G){let q=Date.now()-J;throw b0.error(`Configuration loading failed after ${q}ms:`,[G instanceof Error?G:Error(String(G))]),G}}async loadConfigurationStrategies($,J=!1,Z){let{name:X="",alias:Y,cwd:z,configDir:Q,defaultConfig:G,checkEnv:q=!0,arrayStrategy:U="replace",verbose:W=!1}=$,K=z||$1.cwd(),H=[],V=await this.loadLocalConfiguration(X,Y,K,Q,G,U,W,q,Z);if(V)return H.push(...this.getLocalSearchPaths(X,Y,K,Q)),this.finalizeResult(V,H,q,X,W);let A=await this.loadHomeConfiguration(X,Y,G,U,W,q);if(A)return H.push(...this.getHomeSearchPaths(X,Y)),this.finalizeResult(A,H,q,X,W);let _=await this.loadPackageJsonConfiguration(X,Y,K,G,U,W,q);if(_)return H.push(O0(K,"package.json")),this.finalizeResult(_,H,q,X,W);if(H.push(...this.getAllSearchPaths(X,Y,K,Q)),J)throw n0.configNotFound(X,H,Y);return{...await this.applyEnvironmentVariables(X,G,q,W),warnings:[`No configuration file found for "${X}"${Y?` or alias "${Y}"`:""}, using defaults with environment variables`]}}async loadLocalConfiguration($,J,Z,X,Y,z,Q,G,q){let U=G?O1($,Y,Q):Y,W=this.getLocalDirectories(Z,X);for(let K of W){if(Q)b0.info(`Searching for configuration in: ${K}`);let H=this.fileLoader.generateConfigPaths($,K,J),V=await this.fileLoader.tryLoadFromPaths(H,U,{arrayStrategy:z,verbose:Q,cacheTtl:q?.ttl,useCache:!q?.ttl||q.ttl>100});if(V){if(Q)b0.success(`Configuration loaded from: ${V.source.path}`);return V}}return null}async loadHomeConfiguration($,J,Z,X,Y,z){if(!$)return null;let Q=z?O1($,Z,Y):Z,G=[O0(z1(),".config",$),O0(z1(),".config"),z1()];for(let q of G){if(Y)b0.info(`Checking home directory: ${q}`);let U=this.fileLoader.generateConfigPaths($,q,J),W=await this.fileLoader.tryLoadFromPaths(U,Q,{arrayStrategy:X,verbose:Y});if(W){if(Y)b0.success(`Configuration loaded from home directory: ${W.source.path}`);return W}}return null}async loadPackageJsonConfiguration($,J,Z,X,Y,z,Q){let G=Q?O1($,X,z):X;try{let q=O0(Z,"package.json");if(!G7(q))return null;let U=await import(q),W=U[$],K=$;if(!W&&J)W=U[J],K=J;if(W&&typeof W==="object"&&!Array.isArray(W)){if(z)b0.success(`Configuration loaded from package.json: ${K}`);return{config:T7(G,W,Y),source:{type:"package.json",path:q,priority:30,timestamp:new Date}}}}catch(q){if(z)b0.warn("Failed to load package.json:",[q instanceof Error?q:Error(String(q))])}return null}async applyEnvironmentVariables($,J,Z,X){if(!Z||!$||typeof J!=="object"||J===null||Array.isArray(J))return{config:J,source:{type:"default",priority:10,timestamp:new Date}};return{config:O1($,J,X),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult($,J,Z,X,Y){return{config:$.config,source:$.source,path:$.source.path}}async validateConfiguration($,J,Z,X){let Y=[];if(Z){let z=Z($);if(z)Y.push(...z)}if(J){let z=await this.validator.validateConfiguration($,J);if(!z.isValid)Y.push(...z.errors.map((Q)=>Q.path?`${Q.path}: ${Q.message}`:Q.message))}if(Y.length>0)throw n0.configValidation(X||"unknown",Y,X)}checkCache($,J){let Z=this.generateCacheKey($,J);return _1.get(Z)||null}cacheResult($,J,Z,X){let Y=this.generateCacheKey($,X);_1.set(Y,J,void 0,Z.ttl)}generateCacheKey($,J){let Z=[$];if(J.alias)Z.push(`alias:${J.alias}`);if(J.cwd)Z.push(`cwd:${J.cwd}`);if(J.configDir)Z.push(`configDir:${J.configDir}`);if("checkEnv"in J)Z.push(`checkEnv:${J.checkEnv}`);return Z.join("|")}getLocalDirectories($,J){return Array.from(new Set([$,O0($,"config"),O0($,".config"),J?O0($,J):void 0].filter(Boolean)))}getAllSearchPaths($,J,Z,X){let Y=[];return Y.push(...this.getLocalSearchPaths($,J,Z,X)),Y.push(...this.getHomeSearchPaths($,J)),Y.push(O0(Z,"package.json")),Y}getLocalSearchPaths($,J,Z,X){let Y=this.getLocalDirectories(Z,X),z=[];for(let Q of Y)z.push(...this.fileLoader.generateConfigPaths($,Q,J));return z}getHomeSearchPaths($,J){if(!$)return[];let Z=[O0(z1(),".config",$),O0(z1(),".config"),z1()],X=[];for(let Y of Z)X.push(...this.fileLoader.generateConfigPaths($,Y,J));return X}async loadConfigWithResult($){return this.loadConfig($)}}function y9($){let Z=!($.message.includes("EACCES")||$.message.includes("EPERM")||$.message.includes("permission denied"))&&($.message.includes("syntax")||$.message.includes("Expected")||$.message.includes("Unexpected")||$.message.includes("BuildMessage")),X=$.message.includes("Configuration must export a valid object")||$.message.includes("Configuration file is empty and exports nothing");return Z||X}async function oz($){return l0.loadConfig({...$,__strictErrorHandling:!0})}async function UZ($){let J="defaultConfig"in $&&$.defaultConfig!==void 0?$.defaultConfig:{},Z="cache"in $||"performance"in $||"schema"in $||"validate"in $;try{let X;if(Z)X=await l0.loadConfig($);else X=await l0.loadConfig({...$,defaultConfig:J,cache:{enabled:!0},performance:{enabled:!1}});return X?.config??J}catch(X){let Y=X instanceof Error?X.name:"UnknownError",z=X instanceof Error?X.message:String(X);if(!(Y==="ConfigNotFoundError"||Y==="ConfigLoadError"||Y==="ConfigValidationError"||z.includes("config"))&&$.verbose)b0.warn("Unexpected error loading config, using defaults:",[X instanceof Error?X:Error(String(X))]);let G=Z?{...$,defaultConfig:J}:{...$,defaultConfig:J,cache:{enabled:!0},performance:{enabled:!1}};if("checkEnv"in $?$.checkEnv!==!1:!0)return(await l0.applyEnvironmentVariables(G.name||"",J,!0,G.verbose||!1))?.config??J;return J}}async function cz($={defaultConfig:{}}){if(typeof $==="string"){let{cwd:J}=await import("process");try{return(await l0.loadConfig({name:$,cwd:J(),generatedDir:"./generated",configDir:"./config",defaultConfig:{},checkEnv:!0,arrayStrategy:"replace"})).config}catch(Z){if(Z instanceof Error&&(Z.name==="ConfigNotFoundError"||Z.name==="ConfigLoadError"&&y9(Z)))return(await l0.applyEnvironmentVariables($,{},!0,!1)).config;throw Z}}try{return(await l0.loadConfig({...$,cwd:$.cwd||$1.cwd(),cache:{enabled:!0},performance:{enabled:!1}})).config}catch(J){if(J instanceof Error&&(J.name==="ConfigNotFoundError"||J.name==="ConfigLoadError"&&y9(J)))return(await l0.applyEnvironmentVariables($.name||"",$.defaultConfig||{},$.checkEnv!==!1,$.verbose||!1)).config;throw J}}async function rz($,J,Z="replace"){let X=new F$;try{let Y=await X.loadFromPath($,J,{arrayStrategy:Z,useCache:!1,trackPerformance:!1});return Y?Y.config:null}catch{return null}}function O1($,J,Z=!1){let X=new _$,Y=$.toUpperCase().replace(/[^A-Z0-9]/g,"_");function z(Q,G=[]){let q={...Q};for(let[U,W]of Object.entries(Q)){let K=[...G,U],H=[`${Y}_${K.join("_").toUpperCase()}`,`${Y}_${K.map((_)=>_.toUpperCase()).join("")}`,`${Y}_${K.map((_)=>_.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],V,A;for(let _ of H)if(V=$1.env[_],V!==void 0){A=_;break}if(V!==void 0&&A)if(typeof W==="boolean")q[U]=["true","1","yes"].includes(V.toLowerCase());else if(typeof W==="number"){let _=Number(V);if(!Number.isNaN(_))q[U]=_}else if(Array.isArray(W))try{q[U]=JSON.parse(V)}catch{q[U]=V.split(",").map((_)=>_.trim())}else q[U]=V;else if(W&&typeof W==="object"&&!Array.isArray(W))q[U]=z(W,K)}return q}return z(J)}function lz($){let J=O0($1.cwd(),$.configDir),Z=O0($1.cwd(),$.generatedDir),X=O0(Z,"config-types.ts");if(!G7(B9(X)))iY(B9(X),{recursive:!0,mode:511});let Y=G7(J)?tY(J).map((Q)=>Q.replace(/\.(ts|js|mjs|cjs|mts|cts|json)$/,"")).sort():[],z=`// Generated by bunfig v${TQ}
32
32
  export type ConfigNames = ${Y.length?`'${Y.join("' | '")}'`:"string"}
33
33
  `;eY(X,z,{mode:438})}function az($){let J=null,Z=null,X=()=>{if(!Z)Z=UZ($).then((z)=>{return J=z,z},(z)=>{let Q="defaultConfig"in $?$.defaultConfig:{};if(J=Q,"verbose"in $&&$.verbose)b0.warn("Config loading failed, using defaults:",[z instanceof Error?z:Error(String(z))]);return Q});return Z},Y="defaultConfig"in $?$.defaultConfig:{};return J=Y,X(),new Proxy({},{get(z,Q){if(J)return J[Q];let G=Y[Q];return X(),G},has(z,Q){return Q in(J||Y)},ownKeys(){return Object.keys(J||Y)},getOwnPropertyDescriptor(z,Q){return Object.getOwnPropertyDescriptor(J||Y,Q)},set(z,Q,G){if(!J)J={...Y};return J[Q]=G,!0}})}function sz($){let J=v9(Ez.cwd(),$?.configDir||"./config");function Z(){if(!Nz(J))return[];let Y=new Set([".ts",".js",".mjs",".cjs",".mts",".cts",".json"]),z=[".ts",".mts",".cts",".js",".mjs",".cjs",".json"],Q=Tz(J).filter((q)=>Y.has(t8(q))).map((q)=>({base:q.replace(/\.(?:ts|js|mjs|cjs|mts|cts|json)$/i,""),file:q})),G=new Map;for(let{base:q,file:U}of Q){let W=t8(U).toLowerCase(),K=G.get(q);if(!K){G.set(q,U);continue}let H=t8(K).toLowerCase();if(z.indexOf(W)<z.indexOf(H))G.set(q,U)}return Array.from(G.entries()).map(([q,U])=>({base:q,file:U})).sort((q,U)=>q.base.localeCompare(U.base))}function X(){let Y=Z(),z=Y.map((U)=>U.base),Q=z.length?z.map((U)=>`'${U}'`).join(" | "):"string",G=Y.length?`{
34
34
  ${Y.map((U)=>{let W=v9(J,U.file).replace(/\\/g,"/");return` '${U.base}': typeof import('${W}').default`}).join(`,
@@ -37,24 +37,24 @@ ${Y.map((U)=>{let W=v9(J,U.file).replace(/\\/g,"/");return` '${U.base}': typeof
37
37
  export type ConfigByName = ${G}
38
38
  export type Config<N extends ConfigNames> = N extends keyof ConfigByName ? ConfigByName[N] : unknown
39
39
  export type ConfigOf = Config
40
- `}return{name:"bunfig-plugin",setup(Y){Y.onResolve({filter:/^virtual:bunfig-types$/},(z)=>{return{path:z.path,namespace:"bunfig-virtual"}}),Y.onLoad({filter:/^virtual:bunfig-types$/,namespace:"bunfig-virtual"},()=>{return{contents:X(),loader:"ts"}})}}}var WZ,A1,C1,KZ,nz,iz,b9,$$,W7,T0,G0,tz,k9,ez,f9,$Q,ZQ,e8,JQ,g9,x9,$7,XQ,YQ,zQ,QQ,Z$,HZ,GQ,E0,qQ,UQ,p9,J$,K7,B0,Y0,WQ,h9,KQ,u9,HQ,VQ,Z7,AQ,m9,d9,_Q,J7,FQ,BQ,wQ,MQ,jQ,X$,VZ,NQ,TQ="0.15.6",C0,K$,L1,H7,V7,H$,A7,_7,P1,F7,B7,n0,AZ,_Z,b0,l0,FZ,BZ,EQ=nY(async()=>{WZ=import.meta.require,A1=new w7,C1=new M7,KZ={createKey:Dz,isEquivalent:Rz,estimateMemoryUsage:Oz},nz=Q$(q7.cwd(),"config"),iz=Q$(q7.cwd(),"src/generated"),b9=z$.env.CLARITY_LOG_DIR||Jz(Cz(),"logs"),$$={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:b9,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1},W7=await Iz(),T0={red:($)=>`\x1B[31m${$}\x1B[0m`,green:($)=>`\x1B[32m${$}\x1B[0m`,yellow:($)=>`\x1B[33m${$}\x1B[0m`,blue:($)=>`\x1B[34m${$}\x1B[0m`,magenta:($)=>`\x1B[35m${$}\x1B[0m`,cyan:($)=>`\x1B[36m${$}\x1B[0m`,white:($)=>`\x1B[37m${$}\x1B[0m`,gray:($)=>`\x1B[90m${$}\x1B[0m`,bgRed:($)=>`\x1B[41m${$}\x1B[0m`,bgYellow:($)=>`\x1B[43m${$}\x1B[0m`,bold:($)=>`\x1B[1m${$}\x1B[0m`,dim:($)=>`\x1B[2m${$}\x1B[0m`,italic:($)=>`\x1B[3m${$}\x1B[0m`,underline:($)=>`\x1B[4m${$}\x1B[0m`,reset:"\x1B[0m"},G0=T0,tz=T0.red,k9=T0.green,ez=T0.yellow,f9=T0.blue,$Q=T0.magenta,ZQ=T0.cyan,e8=T0.white,JQ=T0.gray,g9=T0.bgRed,x9=T0.bgYellow,$7=T0.bold,XQ=T0.dim,YQ=T0.italic,zQ=T0.underline,QQ=T0.reset,Z$={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},HZ={debug:"\uD83D\uDD0D",info:f9("\u2139"),success:k9("\u2713"),warning:x9(e8($7(" WARN "))),error:g9(e8($7(" ERROR ")))},GQ=new q$("stacks"),E0=new q$("bunfig",{showTags:!0}),qQ=R0(O1.cwd(),"config"),UQ=R0(O1.cwd(),"src/generated"),p9=Y$.env.CLARITY_LOG_DIR||$z(bz(),"logs"),J$={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:p9,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},K7=await kz(),B0={red:($)=>`\x1B[31m${$}\x1B[0m`,green:($)=>`\x1B[32m${$}\x1B[0m`,yellow:($)=>`\x1B[33m${$}\x1B[0m`,blue:($)=>`\x1B[34m${$}\x1B[0m`,magenta:($)=>`\x1B[35m${$}\x1B[0m`,cyan:($)=>`\x1B[36m${$}\x1B[0m`,white:($)=>`\x1B[37m${$}\x1B[0m`,gray:($)=>`\x1B[90m${$}\x1B[0m`,bgRed:($)=>`\x1B[41m${$}\x1B[0m`,bgYellow:($)=>`\x1B[43m${$}\x1B[0m`,bgGray:($)=>`\x1B[100m${$}\x1B[0m`,bold:($)=>`\x1B[1m${$}\x1B[0m`,dim:($)=>`\x1B[2m${$}\x1B[0m`,italic:($)=>`\x1B[3m${$}\x1B[0m`,underline:($)=>`\x1B[4m${$}\x1B[0m`,strikethrough:($)=>`\x1B[9m${$}\x1B[0m`,reset:"\x1B[0m"},Y0=B0,WQ=B0.red,h9=B0.green,KQ=B0.yellow,u9=B0.blue,HQ=B0.magenta,VQ=B0.cyan,Z7=B0.white,AQ=B0.gray,m9=B0.bgRed,d9=B0.bgYellow,_Q=B0.bgGray,J7=B0.bold,FQ=B0.dim,BQ=B0.italic,wQ=B0.underline,MQ=B0.strikethrough,jQ=B0.reset,X$={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},VZ={debug:"\uD83D\uDD0D",info:u9("\u2139"),success:h9("\u2713"),warning:d9(Z7(J7(" WARN "))),error:m9(Z7(J7(" ERROR ")))},NQ=new W$("stacks"),C0=class extends Error{timestamp;context;constructor(J,Z={}){super(J);if(this.name=this.constructor.name,this.timestamp=new Date,this.context=Z,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,timestamp:this.timestamp.toISOString(),context:this.context,stack:this.stack}}toString(){let J=Object.keys(this.context).length>0?` (${Object.entries(this.context).map(([Z,X])=>`${Z}: ${X}`).join(", ")})`:"";return`${this.name} [${this.code}]: ${this.message}${J}`}},K$=class extends C0{code="CONFIG_NOT_FOUND";constructor(J,Z,X){let Y=X?` or alias "${X}"`:"";super(`Configuration "${J}"${Y} not found`,{configName:J,alias:X,searchPaths:Z,searchPathCount:Z.length})}},L1=class extends C0{code="CONFIG_LOAD_ERROR";constructor(J,Z,X){super(`Failed to load configuration from "${J}": ${Z.message}`,{configPath:J,configName:X,originalError:Z.name,originalMessage:Z.message});this.cause=Z}},H7=class extends C0{code="CONFIG_VALIDATION_ERROR";constructor(J,Z,X){super(`Configuration validation failed for "${J}"`,{configPath:J,configName:X,validationErrors:Z,errorCount:Z.length})}},V7=class extends C0{code="CONFIG_MERGE_ERROR";constructor(J,Z,X,Y){super(`Failed to merge configuration from "${J}" with "${Z}": ${X.message}`,{sourcePath:J,targetPath:Z,configName:Y,originalError:X.name,originalMessage:X.message});this.cause=X}},H$=class extends C0{code="ENV_VAR_ERROR";constructor(J,Z,X,Y){super(`Failed to parse environment variable "${J}" with value "${Z}" as ${X}`,{envKey:J,envValue:Z,expectedType:X,configName:Y})}},A7=class extends C0{code="FILE_SYSTEM_ERROR";constructor(J,Z,X){super(`File system ${J} failed for "${Z}": ${X.message}`,{operation:J,path:Z,originalError:X.name,originalMessage:X.message});this.cause=X}},_7=class extends C0{code="TYPE_GENERATION_ERROR";constructor(J,Z,X){super(`Failed to generate types from "${J}" to "${Z}": ${X.message}`,{configDir:J,outputPath:Z,originalError:X.name,originalMessage:X.message});this.cause=X}},P1=class extends C0{code="SCHEMA_VALIDATION_ERROR";constructor(J,Z,X){super(`Schema validation failed${X?` for config "${X}"`:""}`,{schemaPath:J,configName:X,validationErrors:Z,errorCount:Z.length})}},F7=class extends C0{code="BROWSER_CONFIG_ERROR";constructor(J,Z,X,Y){super(`Failed to fetch configuration from "${J}": ${Z} ${X}`,{endpoint:J,status:Z,statusText:X,configName:Y})}},B7=class extends C0{code="PLUGIN_ERROR";constructor(J,Z,X){super(`Plugin "${J}" failed during ${Z}: ${X.message}`,{pluginName:J,operation:Z,originalError:X.name,originalMessage:X.message});this.cause=X}},n0={configNotFound($,J,Z){return new K$($,J,Z)},configLoad($,J,Z){return new L1($,J,Z)},configValidation($,J,Z){return new H7($,J,Z)},configMerge($,J,Z,X){return new V7($,J,Z,X)},envVar($,J,Z,X){return new H$($,J,Z,X)},fileSystem($,J,Z){return new A7($,J,Z)},typeGeneration($,J,Z){return new _7($,J,Z)},schemaValidation($,J,Z){return new P1($,J,Z)},browserConfig($,J,Z,X){return new F7($,J,Z,X)},plugin($,J,Z){return new B7($,J,Z)}},AZ={replace:"replace",concat:"concat",smart:"smart"},_Z=/^https?:\/\//,b0=new W$("bunfig",{showTags:!0}),l0=new D7,FZ=O0(e0.cwd(),"config"),BZ=O0(e0.cwd(),"src/generated")});function OQ($,J={}){let Z=V$.cwd();while(Z.includes("storage"))Z=o9(Z,"..");let X=o9(Z,$||"");if(J?.relative)return RQ(V$.cwd(),X);return X}var LQ=V$.env.CLARITY_LOG_DIR||DQ(OQ(),"logs"),wZ={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:LQ,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},A$={...wZ},dq=(async()=>{try{let{loadConfig:$}=await EQ().then(()=>e9),J=await $({name:"clarity",alias:"logging",defaultConfig:wZ,cwd:V$.cwd()});if(J)Object.assign(A$,J)}catch{}return A$})();function w0(){if(r0.env.NODE_ENV==="test"||r0.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function gQ(){if(r0.env.NODE_ENV==="test"||r0.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof r0<"u"){let $=r0.type;if($==="renderer"||$==="worker")return!1;return!!(r0.versions&&(r0.versions.node||r0.versions.bun))}return!1}class MZ{async format($){let J=await gQ(),Z=await this.getMetadata(J);return JSON.stringify({timestamp:$.timestamp.toISOString(),level:$.level,name:$.name,message:$.message,metadata:Z})}async getMetadata($){if($){let{hostname:J}=await import("os");return{pid:V1.pid,hostname:J(),environment:V1.env.NODE_ENV||"development",platform:V1.platform,version:V1.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:V1.env.NODE_ENV||V1.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}var M0={red:($)=>`\x1B[31m${$}\x1B[0m`,green:($)=>`\x1B[32m${$}\x1B[0m`,yellow:($)=>`\x1B[33m${$}\x1B[0m`,blue:($)=>`\x1B[34m${$}\x1B[0m`,magenta:($)=>`\x1B[35m${$}\x1B[0m`,cyan:($)=>`\x1B[36m${$}\x1B[0m`,white:($)=>`\x1B[37m${$}\x1B[0m`,gray:($)=>`\x1B[90m${$}\x1B[0m`,bgRed:($)=>`\x1B[41m${$}\x1B[0m`,bgYellow:($)=>`\x1B[43m${$}\x1B[0m`,bgGray:($)=>`\x1B[100m${$}\x1B[0m`,bold:($)=>`\x1B[1m${$}\x1B[0m`,dim:($)=>`\x1B[2m${$}\x1B[0m`,italic:($)=>`\x1B[3m${$}\x1B[0m`,underline:($)=>`\x1B[4m${$}\x1B[0m`,strikethrough:($)=>`\x1B[9m${$}\x1B[0m`,reset:"\x1B[0m"},z0=M0,$U=M0.red,xQ=M0.green,ZU=M0.yellow,pQ=M0.blue,JU=M0.magenta,XU=M0.cyan,i9=M0.white,YU=M0.gray,hQ=M0.bgRed,uQ=M0.bgYellow,zU=M0.bgGray,t9=M0.bold,QU=M0.dim,GU=M0.italic,qU=M0.underline,UU=M0.strikethrough,WU=M0.reset,Q7={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},mQ={debug:"\uD83D\uDD0D",info:pQ("\u2139"),success:xQ("\u2713"),warning:uQ(i9(t9(" WARN "))),error:hQ(i9(t9(" ERROR ")))};class $1{name;fileLocks=new Map;currentKeyId=null;keys=new Map;fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor($,J={}){this.name=$,this.config={...A$},this.options=this.normalizeOptions(J),this.formatter=this.options.formatter||new MZ,this.enabled=J.enabled??!0,this.fancy=J.fancy??!0,this.tagFormat=J.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=J.timestampPosition??"right",this.environment=J.environment??X0.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(J);let Z={...J},X=J.timestamp!==void 0;if(X)delete Z.timestamp;if(this.config={...this.config,...Z,timestamp:X||this.config.timestamp,level:this.options.level??"info"},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let Y=this.generateKeyId(),z=this.generateKey();this.currentKeyId=Y,this.keys.set(Y,z),this.encryptionKeys.set(Y,{key:z,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed($){if(!this.fingersCrossedConfig)return!1;let J={debug:0,info:1,success:2,warning:3,error:4},Z=this.fingersCrossedConfig.activationLevel??"error";return J[$]>=J[Z]}initializeFingersCrossedConfig($){if(!$.fingersCrossedEnabled&&$.fingersCrossed)return{...Q7,...$.fingersCrossed};if(!$.fingersCrossedEnabled)return null;if(!$.fingersCrossed)return{...Q7};return{...Q7,...$.fingersCrossed}}normalizeOptions($){let J={format:"json",level:"info",logDirectory:A$.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},Z={...J,...Object.fromEntries(Object.entries($).filter(([,X])=>X!==void 0))};if(!Z.level||!["debug","info","success","warning","error"].includes(Z.level))Z.level=J.level;return Z}shouldWriteToFile(){return!w0()&&this.config.writeToFile===!0}async writeToFile($){let Z=(async()=>{let Y,z=0,Q=3,G=1000;while(z<Q)try{try{try{await vQ(this.config.logDirectory,a9.F_OK|a9.W_OK)}catch(U){if(U instanceof Error&&"code"in U)if(U.code==="ENOENT")await yQ(this.config.logDirectory,{recursive:!0,mode:493});else if(U.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw U;else throw U}}catch(U){throw console.error("Debug: [writeToFile] Failed to create log directory:",U),U}let q=this.validateEncryptionConfig()?(await this.encrypt($)).encrypted:d0.from($);try{if(!n1(this.currentLogFile))await z7(this.currentLogFile,"",{mode:420});if(Y=l9(this.currentLogFile,"a",420),SQ(Y,q,{flag:"a"}),r9(Y),Y!==void 0)Y7(Y),Y=void 0;if((await K1(this.currentLogFile)).size===0){if(await z7(this.currentLogFile,q,{flag:"w",mode:420}),(await K1(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(U){let W=U;if(W.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(W.code)){if(z<Q-1){let K=typeof W.message==="string"?W.message:"Unknown error";console.error(`Network error during write attempt ${z+1}/${Q}:`,K);let H=G*2**z;await new Promise((V)=>setTimeout(V,H)),z++;continue}}if(W?.code&&["ENOSPC","EDQUOT"].includes(W.code))throw Error(`Disk quota exceeded or no space left on device: ${W.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",W),W}finally{if(Y!==void 0)try{Y7(Y)}catch(U){console.error("Debug: [writeToFile] Error closing file descriptor:",U)}}}catch(q){if(z===Q-1){let W=q,K=typeof W.message==="string"?W.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",K),q}z++;let U=G*2**(z-1);await new Promise((W)=>setTimeout(W,U))}})();this.pendingOperations.push(Z);let X=this.pendingOperations.length-1;try{await Z}catch(Y){throw console.error("Debug: [writeToFile] Error in operation:",Y),Y}finally{this.pendingOperations.splice(X,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return H1(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return H1(this.config.logDirectory,`${this.name}.log`);let $=new Date().toISOString().split("T")[0];return H1(this.config.logDirectory,`${this.name}-${$}.log`)}setupRotation(){if(w0())return;if(!this.shouldWriteToFile())return;if(typeof this.config.rotation==="boolean")return;let $=this.config.rotation,J;switch($.frequency){case"daily":J=86400000;break;case"weekly":J=604800000;break;case"monthly":J=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},J)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let J=this.config.rotation.keyRotation;if(!J?.enabled)return;let Z=typeof J.interval==="number"?J.interval:60,X=Math.max(Z,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((Y)=>{console.error("Error rotating keys:",Y)})},X)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let J=this.config.rotation.keyRotation,Z=this.generateKeyId(),X=this.generateKey();this.currentKeyId=Z,this.keys.set(Z,X),this.encryptionKeys.set(Z,{key:X,createdAt:new Date});let Y=Array.from(this.encryptionKeys.entries()).sort(([,G],[,q])=>q.createdAt.getTime()-G.createdAt.getTime()),z=typeof J.maxKeys==="number"?J.maxKeys:1,Q=Math.max(1,z);if(Y.length>Q)for(let[G]of Y.slice(Q))this.encryptionKeys.delete(G),this.keys.delete(G)}generateKeyId(){return X7(16).toString("hex")}generateKey(){return X7(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let $=this.keys.get(this.currentKeyId);if(!$)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:$,id:this.currentKeyId}}encrypt($){let{key:J}=this.getCurrentKey(),Z=X7(16),X=PQ("aes-256-gcm",J,Z),Y=d0.isBuffer($)?$:d0.from($,"utf8"),z=X.update(Y),Q=X.final(),G=z.length+Q.length,q=X.getAuthTag(),U=d0.allocUnsafe(16+G+16);return Z.copy(U,0),z.copy(U,16),Q.copy(U,16+z.length),q.copy(U,16+G),{encrypted:U,iv:Z}}async compressData($){return new Promise((J,Z)=>{let X=n9(),Y=[];X.on("data",(z)=>Y.push(z)),X.on("end",()=>J(d0.from(d0.concat(Y)))),X.on("error",Z),X.write($),X.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let $={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let J=this.config.rotation.encrypt;return{...$,...J}}return $}async rotateLog(){if(w0())return;if(!this.shouldWriteToFile())return;let $=await K1(this.currentLogFile).catch(()=>null);if(!$)return;let J=this.config.rotation;if(typeof J==="boolean")return;if(J.maxSize&&$.size>=J.maxSize){let Z=this.currentLogFile,X=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let Y=await i1(this.config.logDirectory),z=Y.filter((q)=>q.startsWith(this.name)&&/\.log\.\d+$/.test(q)).sort((q,U)=>{let W=Number.parseInt(q.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(U.match(/\.log\.(\d+)$/)?.[1]||"0")-W}),Q=z.length>0?Number.parseInt(z[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,G=`${Z}.${Q}`;if(await K1(Z).catch(()=>null))try{if(await s9(Z,G),J.compress)try{let q=`${G}.gz`;await this.compressLogFile(G,q),await t1(G)}catch(q){console.error("Error compressing rotated file:",q)}if(z.length===0&&!Y.some((q)=>q.endsWith(".log.1")))try{let q=`${Z}.1`;await z7(q,"")}catch(q){console.error("Error creating backup file:",q)}}catch(q){console.error(`Error during rotation: ${q instanceof Error?q.message:String(q)}`)}}else{let Y=new Date().toISOString().replace(/[:.]/g,"-"),z=Z.replace(/\.log$/,`-${Y}.log`);if(await K1(Z).catch(()=>null))await s9(Z,z)}if(this.currentLogFile=X,J.maxFiles){let z=(await i1(this.config.logDirectory)).filter((Q)=>Q.startsWith(this.name)).sort((Q,G)=>G.localeCompare(Q));for(let Q of z.slice(J.maxFiles))await t1(H1(this.config.logDirectory,Q))}}}async compressLogFile($,J){let Z=c9($),X=IQ(J),Y=n9();await fQ(Z,Y,X)}async handleFingersCrossedBuffer($,J){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed($)&&!this.isActivated){this.isActivated=!0;for(let Z of this.logBuffer){let X=await this.formatter.format(Z);if(this.shouldWriteToFile())await this.writeToFile(X);console.log(X)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated){if(this.shouldWriteToFile())await this.writeToFile(J);console.log(J)}}shouldLog($){if(!this.enabled)return!1;let J={debug:0,info:1,success:2,warning:3,error:4};return J[$]>=J[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map(($)=>{if($ instanceof Promise)return $.catch((J)=>{console.error("Error in pending write operation:",J)});return Promise.resolve()})),n1(this.currentLogFile))try{let $=l9(this.currentLogFile,"r+");r9($),Y7($)}catch($){console.error(`Error flushing file: ${$}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let $ of this.pendingOperations)if(typeof $.cancel==="function")$.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch($){console.error("Error waiting for pending operations:",$)}if(!w0()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let J=(await i1(this.config.logDirectory)).filter((Z)=>(Z.includes("temp")||Z.includes(".tmp"))&&Z.includes(this.name));for(let Z of J)try{await t1(H1(this.config.logDirectory,Z))}catch(X){console.error(`Failed to delete temp file ${Z}:`,X)}}catch($){console.error("Error cleaning up temporary files:",$)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag($){if(!$)return"";return`${this.tagFormat.prefix}${$}${this.tagFormat.suffix}`}formatFileTimestamp($){return`[${$.toISOString()}]`}formatConsoleTimestamp($){return this.shouldStyleConsole()?z0.gray($.toLocaleTimeString()):$.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||w0())return!1;let $=typeof X0.env.NO_COLOR<"u",J=X0.env.FORCE_COLOR==="0";if($||J)return!1;return!!(typeof X0.stderr<"u"&&X0.stderr.isTTY||typeof X0.stdout<"u"&&X0.stdout.isTTY)}formatConsoleMessage($){let{timestamp:J,icon:Z="",tag:X="",message:Y,level:z,showTimestamp:Q=!0}=$,G=(V)=>V.replace(this.ANSI_PATTERN,"");if(!this.fancy){let V=[];if(Q)V.push(J);if(z==="warning")V.push("WARN");else if(z==="error")V.push("ERROR");else if(Z)V.push(Z.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(X)V.push(X.replace(/[[\]]/g,""));return V.push(Y),V.join(" ")}let q=X0.stdout.columns||120,U="";if(z==="warning"||z==="error")U=`${Z} ${Y}`;else if(z==="info"||z==="success")U=`${Z} ${X} ${Y}`;else U=`${Z} ${X} ${z0.cyan(Y)}`;if(!Q)return U.trim();let W=G(U).trim().length,K=G(J).length,H=Math.max(1,q-2-W-K);return`${U.trim()}${" ".repeat(H)}${J}`}formatMessage($,J){if(J.length===1&&Array.isArray(J[0]))return $.replace(/\{(\d+)\}/g,(z,Q)=>{let G=Number.parseInt(Q,10);return G<J[0].length?String(J[0][G]):z});let Z=/%([sdijfo%])/g,X=0,Y=$.replace(Z,(z,Q)=>{if(Q==="%")return"%";if(X>=J.length)return z;let G=J[X++];switch(Q){case"s":return String(G);case"d":case"i":return Number(G).toString();case"j":case"o":return JSON.stringify(G,null,2);default:return z}});if(X<J.length)Y+=` ${J.slice(X).map((z)=>typeof z==="object"?JSON.stringify(z,null,2):String(z)).join(" ")}`;return Y}formatMarkdown($){if(!$)return $;let J=$;return J=J.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(Z,X,Y)=>{let z=z0.underline(z0.blue(X)),Q=this.toAbsoluteFilePath(Y);if(Q&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let G=`file://${encodeURI(Q)}`,q="\x1B]8;;",U="\x1B\\";return`\x1B]8;;${G}\x1B\\${z}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${Y}\x1B\\${z}\x1B]8;;\x1B\\`;return z}),J=J.replace(/`([^`]+)`/g,(Z,X)=>z0.bgGray(X)),J=J.replace(/\*\*([^*]+)\*\*/g,(Z,X)=>z0.bold(X)),J=J.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(Z,X)=>z0.italic(X)),J=J.replace(/(?<!_)_([^_]+)_(?!_)/g,(Z,X)=>z0.italic(X)),J=J.replace(/~([^~]+)~/g,(Z,X)=>z0.strikethrough(X)),J}supportsHyperlinks(){if(w0())return!1;let $=X0.env;if(!$)return!1;if($.TERM_PROGRAM==="iTerm.app"||$.TERM_PROGRAM==="vscode"||$.TERM_PROGRAM==="WezTerm")return!0;if($.WT_SESSION)return!0;if($.TERM==="xterm-kitty")return!0;let J=$.VTE_VERSION?Number.parseInt($.VTE_VERSION,10):0;if(!Number.isNaN(J)&&J>=5000)return!0;return!1}toAbsoluteFilePath($){try{let J=$;if(J.startsWith("file://"))J=J.replace(/^file:\/\//,"");if(J.startsWith("~")){let Z=X0.env.HOME||"";if(Z)J=J.replace(/^~(?=$|\/)/,Z)}if(bQ(J)||J.startsWith("./")||J.startsWith("../"))J=kQ(J);else return null;return n1(J)?J:null}catch{return null}}buildOutputTexts($){let J=this.shouldStyleConsole()?this.formatMarkdown($):$,Z=$.replace(this.ANSI_PATTERN,"");return{consoleText:J,fileText:Z}}async log($,J,...Z){if(!this.shouldLog($))return;let X=new Date,Y=this.formatConsoleTimestamp(X),z=this.formatFileTimestamp(X),Q,G;if(J instanceof Error)Q=J.message,G=J.stack;else Q=this.formatMessage(J,Z);let{consoleText:q,fileText:U}=this.buildOutputTexts(Q);if(this.shouldStyleConsole()){let K=this.options.showIcons===!1?"":mQ[$],H=this.options.showTags!==!1&&this.name?z0.gray(this.formatTag(this.name)):"",V;switch($){case"debug":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:z0.gray(q),level:$}),console.error(V);break;case"info":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:q,level:$}),console.warn(V);break;case"success":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:z0.green(q),level:$}),console.error(V);break;case"warning":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:q,level:$}),console.warn(V);break;case"error":if(V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:q,level:$}),console.error(V),G){let A=G.split(`
40
+ `}return{name:"bunfig-plugin",setup(Y){Y.onResolve({filter:/^virtual:bunfig-types$/},(z)=>{return{path:z.path,namespace:"bunfig-virtual"}}),Y.onLoad({filter:/^virtual:bunfig-types$/,namespace:"bunfig-virtual"},()=>{return{contents:X(),loader:"ts"}})}}}var WZ,_1,I1,KZ,nz,iz,b9,$$,W7,T0,G0,tz,k9,ez,f9,$Q,ZQ,e8,JQ,g9,x9,$7,XQ,YQ,zQ,QQ,Z$,HZ,GQ,E0,qQ,UQ,p9,J$,K7,B0,Y0,WQ,h9,KQ,u9,HQ,VQ,Z7,AQ,m9,d9,_Q,J7,FQ,BQ,wQ,MQ,jQ,X$,VZ,NQ,TQ="0.15.6",C0,K$,P1,H7,V7,H$,A7,_7,C1,F7,B7,n0,AZ,_Z,b0,l0,FZ,BZ,EQ=nY(async()=>{WZ=import.meta.require,_1=new w7,I1=new M7,KZ={createKey:Dz,isEquivalent:Rz,estimateMemoryUsage:Oz},nz=Q$(q7.cwd(),"config"),iz=Q$(q7.cwd(),"src/generated"),b9=z$.env.CLARITY_LOG_DIR||Jz(Cz(),"logs"),$$={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:b9,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1},W7=await Iz(),T0={red:($)=>`\x1B[31m${$}\x1B[0m`,green:($)=>`\x1B[32m${$}\x1B[0m`,yellow:($)=>`\x1B[33m${$}\x1B[0m`,blue:($)=>`\x1B[34m${$}\x1B[0m`,magenta:($)=>`\x1B[35m${$}\x1B[0m`,cyan:($)=>`\x1B[36m${$}\x1B[0m`,white:($)=>`\x1B[37m${$}\x1B[0m`,gray:($)=>`\x1B[90m${$}\x1B[0m`,bgRed:($)=>`\x1B[41m${$}\x1B[0m`,bgYellow:($)=>`\x1B[43m${$}\x1B[0m`,bold:($)=>`\x1B[1m${$}\x1B[0m`,dim:($)=>`\x1B[2m${$}\x1B[0m`,italic:($)=>`\x1B[3m${$}\x1B[0m`,underline:($)=>`\x1B[4m${$}\x1B[0m`,reset:"\x1B[0m"},G0=T0,tz=T0.red,k9=T0.green,ez=T0.yellow,f9=T0.blue,$Q=T0.magenta,ZQ=T0.cyan,e8=T0.white,JQ=T0.gray,g9=T0.bgRed,x9=T0.bgYellow,$7=T0.bold,XQ=T0.dim,YQ=T0.italic,zQ=T0.underline,QQ=T0.reset,Z$={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},HZ={debug:"\uD83D\uDD0D",info:f9("\u2139"),success:k9("\u2713"),warning:x9(e8($7(" WARN "))),error:g9(e8($7(" ERROR ")))},GQ=new q$("stacks"),E0=new q$("bunfig",{showTags:!0}),qQ=R0(L1.cwd(),"config"),UQ=R0(L1.cwd(),"src/generated"),p9=Y$.env.CLARITY_LOG_DIR||$z(bz(),"logs"),J$={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:p9,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},K7=await kz(),B0={red:($)=>`\x1B[31m${$}\x1B[0m`,green:($)=>`\x1B[32m${$}\x1B[0m`,yellow:($)=>`\x1B[33m${$}\x1B[0m`,blue:($)=>`\x1B[34m${$}\x1B[0m`,magenta:($)=>`\x1B[35m${$}\x1B[0m`,cyan:($)=>`\x1B[36m${$}\x1B[0m`,white:($)=>`\x1B[37m${$}\x1B[0m`,gray:($)=>`\x1B[90m${$}\x1B[0m`,bgRed:($)=>`\x1B[41m${$}\x1B[0m`,bgYellow:($)=>`\x1B[43m${$}\x1B[0m`,bgGray:($)=>`\x1B[100m${$}\x1B[0m`,bold:($)=>`\x1B[1m${$}\x1B[0m`,dim:($)=>`\x1B[2m${$}\x1B[0m`,italic:($)=>`\x1B[3m${$}\x1B[0m`,underline:($)=>`\x1B[4m${$}\x1B[0m`,strikethrough:($)=>`\x1B[9m${$}\x1B[0m`,reset:"\x1B[0m"},Y0=B0,WQ=B0.red,h9=B0.green,KQ=B0.yellow,u9=B0.blue,HQ=B0.magenta,VQ=B0.cyan,Z7=B0.white,AQ=B0.gray,m9=B0.bgRed,d9=B0.bgYellow,_Q=B0.bgGray,J7=B0.bold,FQ=B0.dim,BQ=B0.italic,wQ=B0.underline,MQ=B0.strikethrough,jQ=B0.reset,X$={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},VZ={debug:"\uD83D\uDD0D",info:u9("\u2139"),success:h9("\u2713"),warning:d9(Z7(J7(" WARN "))),error:m9(Z7(J7(" ERROR ")))},NQ=new W$("stacks"),C0=class extends Error{timestamp;context;constructor(J,Z={}){super(J);if(this.name=this.constructor.name,this.timestamp=new Date,this.context=Z,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,timestamp:this.timestamp.toISOString(),context:this.context,stack:this.stack}}toString(){let J=Object.keys(this.context).length>0?` (${Object.entries(this.context).map(([Z,X])=>`${Z}: ${X}`).join(", ")})`:"";return`${this.name} [${this.code}]: ${this.message}${J}`}},K$=class extends C0{code="CONFIG_NOT_FOUND";constructor(J,Z,X){let Y=X?` or alias "${X}"`:"";super(`Configuration "${J}"${Y} not found`,{configName:J,alias:X,searchPaths:Z,searchPathCount:Z.length})}},P1=class extends C0{code="CONFIG_LOAD_ERROR";constructor(J,Z,X){super(`Failed to load configuration from "${J}": ${Z.message}`,{configPath:J,configName:X,originalError:Z.name,originalMessage:Z.message});this.cause=Z}},H7=class extends C0{code="CONFIG_VALIDATION_ERROR";constructor(J,Z,X){super(`Configuration validation failed for "${J}"`,{configPath:J,configName:X,validationErrors:Z,errorCount:Z.length})}},V7=class extends C0{code="CONFIG_MERGE_ERROR";constructor(J,Z,X,Y){super(`Failed to merge configuration from "${J}" with "${Z}": ${X.message}`,{sourcePath:J,targetPath:Z,configName:Y,originalError:X.name,originalMessage:X.message});this.cause=X}},H$=class extends C0{code="ENV_VAR_ERROR";constructor(J,Z,X,Y){super(`Failed to parse environment variable "${J}" with value "${Z}" as ${X}`,{envKey:J,envValue:Z,expectedType:X,configName:Y})}},A7=class extends C0{code="FILE_SYSTEM_ERROR";constructor(J,Z,X){super(`File system ${J} failed for "${Z}": ${X.message}`,{operation:J,path:Z,originalError:X.name,originalMessage:X.message});this.cause=X}},_7=class extends C0{code="TYPE_GENERATION_ERROR";constructor(J,Z,X){super(`Failed to generate types from "${J}" to "${Z}": ${X.message}`,{configDir:J,outputPath:Z,originalError:X.name,originalMessage:X.message});this.cause=X}},C1=class extends C0{code="SCHEMA_VALIDATION_ERROR";constructor(J,Z,X){super(`Schema validation failed${X?` for config "${X}"`:""}`,{schemaPath:J,configName:X,validationErrors:Z,errorCount:Z.length})}},F7=class extends C0{code="BROWSER_CONFIG_ERROR";constructor(J,Z,X,Y){super(`Failed to fetch configuration from "${J}": ${Z} ${X}`,{endpoint:J,status:Z,statusText:X,configName:Y})}},B7=class extends C0{code="PLUGIN_ERROR";constructor(J,Z,X){super(`Plugin "${J}" failed during ${Z}: ${X.message}`,{pluginName:J,operation:Z,originalError:X.name,originalMessage:X.message});this.cause=X}},n0={configNotFound($,J,Z){return new K$($,J,Z)},configLoad($,J,Z){return new P1($,J,Z)},configValidation($,J,Z){return new H7($,J,Z)},configMerge($,J,Z,X){return new V7($,J,Z,X)},envVar($,J,Z,X){return new H$($,J,Z,X)},fileSystem($,J,Z){return new A7($,J,Z)},typeGeneration($,J,Z){return new _7($,J,Z)},schemaValidation($,J,Z){return new C1($,J,Z)},browserConfig($,J,Z,X){return new F7($,J,Z,X)},plugin($,J,Z){return new B7($,J,Z)}},AZ={replace:"replace",concat:"concat",smart:"smart"},_Z=/^https?:\/\//,b0=new W$("bunfig",{showTags:!0}),l0=new D7,FZ=O0($1.cwd(),"config"),BZ=O0($1.cwd(),"src/generated")});function OQ($,J={}){let Z=V$.cwd();while(Z.includes("storage"))Z=o9(Z,"..");let X=o9(Z,$||"");if(J?.relative)return RQ(V$.cwd(),X);return X}var LQ=V$.env.CLARITY_LOG_DIR||DQ(OQ(),"logs"),wZ={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:LQ,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},A$={...wZ},cq=(async()=>{try{let{loadConfig:$}=await EQ().then(()=>e9),J=await $({name:"clarity",alias:"logging",defaultConfig:wZ,cwd:V$.cwd()});if(J)Object.assign(A$,J)}catch{}return A$})();function w0(){if(r0.env.NODE_ENV==="test"||r0.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function gQ(){if(r0.env.NODE_ENV==="test"||r0.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof r0<"u"){let $=r0.type;if($==="renderer"||$==="worker")return!1;return!!(r0.versions&&(r0.versions.node||r0.versions.bun))}return!1}class MZ{async format($){let J=await gQ(),Z=await this.getMetadata(J);return JSON.stringify({timestamp:$.timestamp.toISOString(),level:$.level,name:$.name,message:$.message,metadata:Z})}async getMetadata($){if($){let{hostname:J}=await import("os");return{pid:A1.pid,hostname:J(),environment:A1.env.NODE_ENV||"development",platform:A1.platform,version:A1.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:A1.env.NODE_ENV||A1.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}var M0={red:($)=>`\x1B[31m${$}\x1B[0m`,green:($)=>`\x1B[32m${$}\x1B[0m`,yellow:($)=>`\x1B[33m${$}\x1B[0m`,blue:($)=>`\x1B[34m${$}\x1B[0m`,magenta:($)=>`\x1B[35m${$}\x1B[0m`,cyan:($)=>`\x1B[36m${$}\x1B[0m`,white:($)=>`\x1B[37m${$}\x1B[0m`,gray:($)=>`\x1B[90m${$}\x1B[0m`,bgRed:($)=>`\x1B[41m${$}\x1B[0m`,bgYellow:($)=>`\x1B[43m${$}\x1B[0m`,bgGray:($)=>`\x1B[100m${$}\x1B[0m`,bold:($)=>`\x1B[1m${$}\x1B[0m`,dim:($)=>`\x1B[2m${$}\x1B[0m`,italic:($)=>`\x1B[3m${$}\x1B[0m`,underline:($)=>`\x1B[4m${$}\x1B[0m`,strikethrough:($)=>`\x1B[9m${$}\x1B[0m`,reset:"\x1B[0m"},z0=M0,JU=M0.red,xQ=M0.green,XU=M0.yellow,pQ=M0.blue,YU=M0.magenta,zU=M0.cyan,i9=M0.white,QU=M0.gray,hQ=M0.bgRed,uQ=M0.bgYellow,GU=M0.bgGray,t9=M0.bold,qU=M0.dim,UU=M0.italic,WU=M0.underline,KU=M0.strikethrough,HU=M0.reset,Q7={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},mQ={debug:"\uD83D\uDD0D",info:pQ("\u2139"),success:xQ("\u2713"),warning:uQ(i9(t9(" WARN "))),error:hQ(i9(t9(" ERROR ")))};class Z1{name;fileLocks=new Map;currentKeyId=null;keys=new Map;fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor($,J={}){this.name=$,this.config={...A$},this.options=this.normalizeOptions(J),this.formatter=this.options.formatter||new MZ,this.enabled=J.enabled??!0,this.fancy=J.fancy??!0,this.tagFormat=J.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=J.timestampPosition??"right",this.environment=J.environment??X0.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(J);let Z={...J},X=J.timestamp!==void 0;if(X)delete Z.timestamp;if(this.config={...this.config,...Z,timestamp:X||this.config.timestamp,level:this.options.level??"info"},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let Y=this.generateKeyId(),z=this.generateKey();this.currentKeyId=Y,this.keys.set(Y,z),this.encryptionKeys.set(Y,{key:z,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed($){if(!this.fingersCrossedConfig)return!1;let J={debug:0,info:1,success:2,warning:3,error:4},Z=this.fingersCrossedConfig.activationLevel??"error";return J[$]>=J[Z]}initializeFingersCrossedConfig($){if(!$.fingersCrossedEnabled&&$.fingersCrossed)return{...Q7,...$.fingersCrossed};if(!$.fingersCrossedEnabled)return null;if(!$.fingersCrossed)return{...Q7};return{...Q7,...$.fingersCrossed}}normalizeOptions($){let J={format:"json",level:"info",logDirectory:A$.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},Z={...J,...Object.fromEntries(Object.entries($).filter(([,X])=>X!==void 0))};if(!Z.level||!["debug","info","success","warning","error"].includes(Z.level))Z.level=J.level;return Z}shouldWriteToFile(){return!w0()&&this.config.writeToFile===!0}async writeToFile($){let Z=(async()=>{let Y,z=0,Q=3,G=1000;while(z<Q)try{try{try{await vQ(this.config.logDirectory,a9.F_OK|a9.W_OK)}catch(U){if(U instanceof Error&&"code"in U)if(U.code==="ENOENT")await yQ(this.config.logDirectory,{recursive:!0,mode:493});else if(U.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw U;else throw U}}catch(U){throw console.error("Debug: [writeToFile] Failed to create log directory:",U),U}let q=this.validateEncryptionConfig()?(await this.encrypt($)).encrypted:d0.from($);try{if(!n1(this.currentLogFile))await z7(this.currentLogFile,"",{mode:420});if(Y=l9(this.currentLogFile,"a",420),SQ(Y,q,{flag:"a"}),r9(Y),Y!==void 0)Y7(Y),Y=void 0;if((await H1(this.currentLogFile)).size===0){if(await z7(this.currentLogFile,q,{flag:"w",mode:420}),(await H1(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(U){let W=U;if(W.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(W.code)){if(z<Q-1){let K=typeof W.message==="string"?W.message:"Unknown error";console.error(`Network error during write attempt ${z+1}/${Q}:`,K);let H=G*2**z;await new Promise((V)=>setTimeout(V,H)),z++;continue}}if(W?.code&&["ENOSPC","EDQUOT"].includes(W.code))throw Error(`Disk quota exceeded or no space left on device: ${W.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",W),W}finally{if(Y!==void 0)try{Y7(Y)}catch(U){console.error("Debug: [writeToFile] Error closing file descriptor:",U)}}}catch(q){if(z===Q-1){let W=q,K=typeof W.message==="string"?W.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",K),q}z++;let U=G*2**(z-1);await new Promise((W)=>setTimeout(W,U))}})();this.pendingOperations.push(Z);let X=this.pendingOperations.length-1;try{await Z}catch(Y){throw console.error("Debug: [writeToFile] Error in operation:",Y),Y}finally{this.pendingOperations.splice(X,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return V1(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return V1(this.config.logDirectory,`${this.name}.log`);let $=new Date().toISOString().split("T")[0];return V1(this.config.logDirectory,`${this.name}-${$}.log`)}setupRotation(){if(w0())return;if(!this.shouldWriteToFile())return;if(typeof this.config.rotation==="boolean")return;let $=this.config.rotation,J;switch($.frequency){case"daily":J=86400000;break;case"weekly":J=604800000;break;case"monthly":J=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},J)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let J=this.config.rotation.keyRotation;if(!J?.enabled)return;let Z=typeof J.interval==="number"?J.interval:60,X=Math.max(Z,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((Y)=>{console.error("Error rotating keys:",Y)})},X)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let J=this.config.rotation.keyRotation,Z=this.generateKeyId(),X=this.generateKey();this.currentKeyId=Z,this.keys.set(Z,X),this.encryptionKeys.set(Z,{key:X,createdAt:new Date});let Y=Array.from(this.encryptionKeys.entries()).sort(([,G],[,q])=>q.createdAt.getTime()-G.createdAt.getTime()),z=typeof J.maxKeys==="number"?J.maxKeys:1,Q=Math.max(1,z);if(Y.length>Q)for(let[G]of Y.slice(Q))this.encryptionKeys.delete(G),this.keys.delete(G)}generateKeyId(){return X7(16).toString("hex")}generateKey(){return X7(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let $=this.keys.get(this.currentKeyId);if(!$)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:$,id:this.currentKeyId}}encrypt($){let{key:J}=this.getCurrentKey(),Z=X7(16),X=PQ("aes-256-gcm",J,Z),Y=d0.isBuffer($)?$:d0.from($,"utf8"),z=X.update(Y),Q=X.final(),G=z.length+Q.length,q=X.getAuthTag(),U=d0.allocUnsafe(16+G+16);return Z.copy(U,0),z.copy(U,16),Q.copy(U,16+z.length),q.copy(U,16+G),{encrypted:U,iv:Z}}async compressData($){return new Promise((J,Z)=>{let X=n9(),Y=[];X.on("data",(z)=>Y.push(z)),X.on("end",()=>J(d0.from(d0.concat(Y)))),X.on("error",Z),X.write($),X.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let $={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let J=this.config.rotation.encrypt;return{...$,...J}}return $}async rotateLog(){if(w0())return;if(!this.shouldWriteToFile())return;let $=await H1(this.currentLogFile).catch(()=>null);if(!$)return;let J=this.config.rotation;if(typeof J==="boolean")return;if(J.maxSize&&$.size>=J.maxSize){let Z=this.currentLogFile,X=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let Y=await i1(this.config.logDirectory),z=Y.filter((q)=>q.startsWith(this.name)&&/\.log\.\d+$/.test(q)).sort((q,U)=>{let W=Number.parseInt(q.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(U.match(/\.log\.(\d+)$/)?.[1]||"0")-W}),Q=z.length>0?Number.parseInt(z[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,G=`${Z}.${Q}`;if(await H1(Z).catch(()=>null))try{if(await s9(Z,G),J.compress)try{let q=`${G}.gz`;await this.compressLogFile(G,q),await t1(G)}catch(q){console.error("Error compressing rotated file:",q)}if(z.length===0&&!Y.some((q)=>q.endsWith(".log.1")))try{let q=`${Z}.1`;await z7(q,"")}catch(q){console.error("Error creating backup file:",q)}}catch(q){console.error(`Error during rotation: ${q instanceof Error?q.message:String(q)}`)}}else{let Y=new Date().toISOString().replace(/[:.]/g,"-"),z=Z.replace(/\.log$/,`-${Y}.log`);if(await H1(Z).catch(()=>null))await s9(Z,z)}if(this.currentLogFile=X,J.maxFiles){let z=(await i1(this.config.logDirectory)).filter((Q)=>Q.startsWith(this.name)).sort((Q,G)=>G.localeCompare(Q));for(let Q of z.slice(J.maxFiles))await t1(V1(this.config.logDirectory,Q))}}}async compressLogFile($,J){let Z=c9($),X=IQ(J),Y=n9();await fQ(Z,Y,X)}async handleFingersCrossedBuffer($,J){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed($)&&!this.isActivated){this.isActivated=!0;for(let Z of this.logBuffer){let X=await this.formatter.format(Z);if(this.shouldWriteToFile())await this.writeToFile(X);console.log(X)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated){if(this.shouldWriteToFile())await this.writeToFile(J);console.log(J)}}shouldLog($){if(!this.enabled)return!1;let J={debug:0,info:1,success:2,warning:3,error:4};return J[$]>=J[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map(($)=>{if($ instanceof Promise)return $.catch((J)=>{console.error("Error in pending write operation:",J)});return Promise.resolve()})),n1(this.currentLogFile))try{let $=l9(this.currentLogFile,"r+");r9($),Y7($)}catch($){console.error(`Error flushing file: ${$}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let $ of this.pendingOperations)if(typeof $.cancel==="function")$.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch($){console.error("Error waiting for pending operations:",$)}if(!w0()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let J=(await i1(this.config.logDirectory)).filter((Z)=>(Z.includes("temp")||Z.includes(".tmp"))&&Z.includes(this.name));for(let Z of J)try{await t1(V1(this.config.logDirectory,Z))}catch(X){console.error(`Failed to delete temp file ${Z}:`,X)}}catch($){console.error("Error cleaning up temporary files:",$)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag($){if(!$)return"";return`${this.tagFormat.prefix}${$}${this.tagFormat.suffix}`}formatFileTimestamp($){return`[${$.toISOString()}]`}formatConsoleTimestamp($){return this.shouldStyleConsole()?z0.gray($.toLocaleTimeString()):$.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||w0())return!1;let $=typeof X0.env.NO_COLOR<"u",J=X0.env.FORCE_COLOR==="0";if($||J)return!1;return!!(typeof X0.stderr<"u"&&X0.stderr.isTTY||typeof X0.stdout<"u"&&X0.stdout.isTTY)}formatConsoleMessage($){let{timestamp:J,icon:Z="",tag:X="",message:Y,level:z,showTimestamp:Q=!0}=$,G=(V)=>V.replace(this.ANSI_PATTERN,"");if(!this.fancy){let V=[];if(Q)V.push(J);if(z==="warning")V.push("WARN");else if(z==="error")V.push("ERROR");else if(Z)V.push(Z.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(X)V.push(X.replace(/[[\]]/g,""));return V.push(Y),V.join(" ")}let q=X0.stdout.columns||120,U="";if(z==="warning"||z==="error")U=`${Z} ${Y}`;else if(z==="info"||z==="success")U=`${Z} ${X} ${Y}`;else U=`${Z} ${X} ${z0.cyan(Y)}`;if(!Q)return U.trim();let W=G(U).trim().length,K=G(J).length,H=Math.max(1,q-2-W-K);return`${U.trim()}${" ".repeat(H)}${J}`}formatMessage($,J){if(J.length===1&&Array.isArray(J[0]))return $.replace(/\{(\d+)\}/g,(z,Q)=>{let G=Number.parseInt(Q,10);return G<J[0].length?String(J[0][G]):z});let Z=/%([sdijfo%])/g,X=0,Y=$.replace(Z,(z,Q)=>{if(Q==="%")return"%";if(X>=J.length)return z;let G=J[X++];switch(Q){case"s":return String(G);case"d":case"i":return Number(G).toString();case"j":case"o":return JSON.stringify(G,null,2);default:return z}});if(X<J.length)Y+=` ${J.slice(X).map((z)=>typeof z==="object"?JSON.stringify(z,null,2):String(z)).join(" ")}`;return Y}formatMarkdown($){if(!$)return $;let J=$;return J=J.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(Z,X,Y)=>{let z=z0.underline(z0.blue(X)),Q=this.toAbsoluteFilePath(Y);if(Q&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let G=`file://${encodeURI(Q)}`,q="\x1B]8;;",U="\x1B\\";return`\x1B]8;;${G}\x1B\\${z}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${Y}\x1B\\${z}\x1B]8;;\x1B\\`;return z}),J=J.replace(/`([^`]+)`/g,(Z,X)=>z0.bgGray(X)),J=J.replace(/\*\*([^*]+)\*\*/g,(Z,X)=>z0.bold(X)),J=J.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(Z,X)=>z0.italic(X)),J=J.replace(/(?<!_)_([^_]+)_(?!_)/g,(Z,X)=>z0.italic(X)),J=J.replace(/~([^~]+)~/g,(Z,X)=>z0.strikethrough(X)),J}supportsHyperlinks(){if(w0())return!1;let $=X0.env;if(!$)return!1;if($.TERM_PROGRAM==="iTerm.app"||$.TERM_PROGRAM==="vscode"||$.TERM_PROGRAM==="WezTerm")return!0;if($.WT_SESSION)return!0;if($.TERM==="xterm-kitty")return!0;let J=$.VTE_VERSION?Number.parseInt($.VTE_VERSION,10):0;if(!Number.isNaN(J)&&J>=5000)return!0;return!1}toAbsoluteFilePath($){try{let J=$;if(J.startsWith("file://"))J=J.replace(/^file:\/\//,"");if(J.startsWith("~")){let Z=X0.env.HOME||"";if(Z)J=J.replace(/^~(?=$|\/)/,Z)}if(bQ(J)||J.startsWith("./")||J.startsWith("../"))J=kQ(J);else return null;return n1(J)?J:null}catch{return null}}buildOutputTexts($){let J=this.shouldStyleConsole()?this.formatMarkdown($):$,Z=$.replace(this.ANSI_PATTERN,"");return{consoleText:J,fileText:Z}}async log($,J,...Z){if(!this.shouldLog($))return;let X=new Date,Y=this.formatConsoleTimestamp(X),z=this.formatFileTimestamp(X),Q,G;if(J instanceof Error)Q=J.message,G=J.stack;else Q=this.formatMessage(J,Z);let{consoleText:q,fileText:U}=this.buildOutputTexts(Q);if(this.shouldStyleConsole()){let K=this.options.showIcons===!1?"":mQ[$],H=this.options.showTags!==!1&&this.name?z0.gray(this.formatTag(this.name)):"",V;switch($){case"debug":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:z0.gray(q),level:$}),console.error(V);break;case"info":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:q,level:$}),console.warn(V);break;case"success":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:z0.green(q),level:$}),console.error(V);break;case"warning":V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:q,level:$}),console.warn(V);break;case"error":if(V=this.formatConsoleMessage({timestamp:Y,icon:K,tag:H,message:q,level:$}),console.error(V),G){let A=G.split(`
41
41
  `);for(let _ of A)if(_.trim()&&!_.includes(Q))console.error(this.formatConsoleMessage({timestamp:Y,message:z0.gray(` ${_}`),level:$,showTimestamp:!1}))}break}}else if(!w0()){if(console.error(`${z} ${this.environment}.${$.toUpperCase()}: ${Q}`),G)console.error(G)}let W=`${z} ${this.environment}.${$.toUpperCase()}: ${U}
42
42
  `;if(G)W+=`${G}
43
43
  `;if(W=W.replace(this.ANSI_PATTERN,""),this.shouldWriteToFile())await this.writeToFile(W)}progress($,J=""){let Z={update:(G,q)=>{},finish:(G)=>{},interrupt:(G,q)=>{}};if(!this.enabled)return Z;let X=30;if(this.activeProgressBar={total:Math.max(1,$||1),current:0,message:J||"",barLength:X,lastRenderedLine:""},this.shouldStyleConsole()&&!w0()&&X0.stdout.isTTY)this.renderProgressBar(this.activeProgressBar);return{update:(G,q)=>{if(!this.enabled||!this.activeProgressBar)return;if(this.activeProgressBar.current=Math.min(Math.max(0,G),this.activeProgressBar.total),q!==void 0)this.activeProgressBar.message=q;if(this.shouldStyleConsole()&&!w0()&&X0.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(G)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,G)},interrupt:(G,q="info")=>{if(!w0()&&X0.stdout.isTTY)X0.stdout.write(`
44
44
  `);if(this[q==="warning"?"warn":q](G),this.activeProgressBar&&this.shouldStyleConsole()&&!w0()&&X0.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)}}}time($){let J=performance.now();if(this.shouldStyleConsole()){let Z=this.options.showTags!==!1&&this.name?z0.gray(this.formatTag(this.name)):"",X=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:X,icon:this.options.showIcons===!1?"":z0.blue("\u25D0"),tag:Z,message:`${z0.cyan($)}...`}))}return async(Z)=>{if(!this.enabled)return;let X=performance.now(),Y=Math.round(X-J),z=`${$} completed in ${Y}ms`,Q=new Date,G=this.formatConsoleTimestamp(Q),U=`${this.formatFileTimestamp(Q)} ${this.environment}.INFO: ${z}`;if(Z)U+=` ${JSON.stringify(Z)}`;if(U+=`
45
- `,U=U.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let W=this.options.showTags!==!1&&this.name?z0.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:G,icon:this.options.showIcons===!1?"":z0.green("\u2713"),tag:W,message:`${z}${Z?` ${JSON.stringify(Z)}`:""}`}))}else if(!w0())console.error(U.trim());if(this.shouldWriteToFile())await this.writeToFile(U)}}async debug($,...J){await this.log("debug",$,...J)}async info($,...J){await this.log("info",$,...J)}async success($,...J){await this.log("success",$,...J)}async warn($,...J){await this.log("warning",$,...J)}async error($,...J){await this.log("error",$,...J)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let $=this.config.rotation,{encrypt:J}=$;return!!J}async only($){if(!this.enabled)return;return await $()}isEnabled(){return this.enabled}setEnabled($){this.enabled=$}extend($){let J=`${this.name}:${$}`,Z=new $1(J,{...this.options,logDirectory:this.config.logDirectory,level:this.config.level,format:this.config.format,rotation:typeof this.config.rotation==="boolean"?void 0:this.config.rotation,timestamp:typeof this.config.timestamp==="boolean"?void 0:this.config.timestamp});return this.subLoggers.add(Z),Z}createReadStream(){if(w0())throw Error("createReadStream is not supported in browser environments");if(!n1(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return c9(this.currentLogFile,{encoding:"utf8"})}async decrypt($){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let J=this.config.rotation;if(!J.encrypt||typeof J.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let Z=this.keys.get(this.currentKeyId);try{let X=d0.isBuffer($)?$:d0.from($,"base64"),Y=X.subarray(0,16),z=X.subarray(X.length-16),Q=X.subarray(16,X.length-16),G=CQ("aes-256-gcm",Z,Y);G.setAuthTag(z);let q=G.update(Q),U=G.final(),W=q.length+U.length,K=d0.allocUnsafe(W);return q.copy(K,0),U.copy(K,q.length),K.toString("utf8")}catch(X){throw Error(`Decryption failed: ${X instanceof Error?X.message:String(X)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return w0()}isServerMode(){return!w0()}setTestEncryptionKey($,J){this.currentKeyId=$,this.keys.set($,J)}getTestCurrentKey(){if(!this.currentKeyId||!this.keys.has(this.currentKeyId))return null;return{id:this.currentKeyId,key:this.keys.get(this.currentKeyId)}}getConfig(){return this.config}async box($){if(!this.enabled)return;let J=new Date,Z=this.formatConsoleTimestamp(J),X=this.formatFileTimestamp(J),{consoleText:Y,fileText:z}=this.buildOutputTexts($);if(this.shouldStyleConsole()){let G=Y.split(`
45
+ `,U=U.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let W=this.options.showTags!==!1&&this.name?z0.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:G,icon:this.options.showIcons===!1?"":z0.green("\u2713"),tag:W,message:`${z}${Z?` ${JSON.stringify(Z)}`:""}`}))}else if(!w0())console.error(U.trim());if(this.shouldWriteToFile())await this.writeToFile(U)}}async debug($,...J){await this.log("debug",$,...J)}async info($,...J){await this.log("info",$,...J)}async success($,...J){await this.log("success",$,...J)}async warn($,...J){await this.log("warning",$,...J)}async error($,...J){await this.log("error",$,...J)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let $=this.config.rotation,{encrypt:J}=$;return!!J}async only($){if(!this.enabled)return;return await $()}isEnabled(){return this.enabled}setEnabled($){this.enabled=$}extend($){let J=`${this.name}:${$}`,Z=new Z1(J,{...this.options,logDirectory:this.config.logDirectory,level:this.config.level,format:this.config.format,rotation:typeof this.config.rotation==="boolean"?void 0:this.config.rotation,timestamp:typeof this.config.timestamp==="boolean"?void 0:this.config.timestamp});return this.subLoggers.add(Z),Z}createReadStream(){if(w0())throw Error("createReadStream is not supported in browser environments");if(!n1(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return c9(this.currentLogFile,{encoding:"utf8"})}async decrypt($){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let J=this.config.rotation;if(!J.encrypt||typeof J.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let Z=this.keys.get(this.currentKeyId);try{let X=d0.isBuffer($)?$:d0.from($,"base64"),Y=X.subarray(0,16),z=X.subarray(X.length-16),Q=X.subarray(16,X.length-16),G=CQ("aes-256-gcm",Z,Y);G.setAuthTag(z);let q=G.update(Q),U=G.final(),W=q.length+U.length,K=d0.allocUnsafe(W);return q.copy(K,0),U.copy(K,q.length),K.toString("utf8")}catch(X){throw Error(`Decryption failed: ${X instanceof Error?X.message:String(X)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return w0()}isServerMode(){return!w0()}setTestEncryptionKey($,J){this.currentKeyId=$,this.keys.set($,J)}getTestCurrentKey(){if(!this.currentKeyId||!this.keys.has(this.currentKeyId))return null;return{id:this.currentKeyId,key:this.keys.get(this.currentKeyId)}}getConfig(){return this.config}async box($){if(!this.enabled)return;let J=new Date,Z=this.formatConsoleTimestamp(J),X=this.formatFileTimestamp(J),{consoleText:Y,fileText:z}=this.buildOutputTexts($);if(this.shouldStyleConsole()){let G=Y.split(`
46
46
  `),q=Math.max(...G.map((H)=>H.length))+2,U=`\u250C${"\u2500".repeat(q)}\u2510`,W=`\u2514${"\u2500".repeat(q)}\u2518`,K=G.map((H)=>{return this.formatConsoleMessage({timestamp:Z,message:z0.cyan(H),showTimestamp:!1})});console.error(this.formatConsoleMessage({timestamp:Z,message:z0.cyan(U),showTimestamp:!1})),K.forEach((H)=>console.error(H)),console.error(this.formatConsoleMessage({timestamp:Z,message:z0.cyan(W),showTimestamp:!1}))}else if(!w0())console.error(`${X} ${this.environment}.INFO: [BOX] ${z}`);let Q=`${X} ${this.environment}.INFO: [BOX] ${z}
47
47
  `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(Q)}async prompt($){if(w0())return Promise.resolve(!0);return new Promise((J)=>{console.error(`${z0.cyan("?")} ${$} (y/n) `);let Z=(X)=>{let Y=X.toString().trim().toLowerCase();X0.stdin.removeListener("data",Z);try{if(typeof X0.stdin.setRawMode==="function")X0.stdin.setRawMode(!1)}catch{}X0.stdin.pause(),console.error(""),J(Y==="y"||Y==="yes")};try{if(typeof X0.stdin.setRawMode==="function")X0.stdin.setRawMode(!0)}catch{}X0.stdin.resume(),X0.stdin.once("data",Z)})}setFancy($){this.fancy=$}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start($,...J){if(!this.enabled)return;let Z=$;if(J&&J.length>0){let q=/%([sdijfo%])/g,U=0;if(Z=$.replace(q,(W,K)=>{if(K==="%")return"%";if(U>=J.length)return W;let H=J[U++];switch(K){case"s":return String(H);case"d":case"i":return Number(H).toString();case"j":case"o":return JSON.stringify(H,null,2);default:return W}}),U<J.length)Z+=` ${J.slice(U).map((W)=>typeof W==="object"?JSON.stringify(W,null,2):String(W)).join(" ")}`}let{consoleText:X,fileText:Y}=this.buildOutputTexts(Z);if(this.shouldStyleConsole()){let q=this.options.showTags!==!1&&this.name?z0.gray(this.formatTag(this.name)):"",U=this.options.showIcons===!1?"":`${z0.blue("\u25D0")} `;console.error(`${U}${q} ${z0.cyan(X)}`)}let G=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${Y}
48
48
  `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(G)}renderProgressBar($,J=!1){if(!this.enabled||!this.shouldStyleConsole()||!X0.stdout.isTTY)return;let Z=Math.min(100,Math.max(0,Math.round($.current/$.total*100))),X=Math.round($.barLength*Z/100),Y=$.barLength-X,z=z0.green("\u2501".repeat(X)),Q=z0.gray("\u2501".repeat(Y)),G=`[${z}${Q}]`,q=`${Z}%`.padStart(4),U=$.message?` ${$.message}`:"",W=this.options.showIcons===!1?"":J||Z===100?z0.green("\u2713"):z0.blue("\u25B6"),K=this.options.showTags!==!1&&this.name?` ${z0.gray(this.formatTag(this.name))}`:"",H=`\r${W}${K} ${G} ${q}${U}`,V=X0.stdout.columns||80,A=" ".repeat(Math.max(0,V-H.replace(this.ANSI_PATTERN,"").length));if($.lastRenderedLine=`${H}${A}`,X0.stdout.write($.lastRenderedLine),J)X0.stdout.write(`
49
- `)}finishProgressBar($,J){if(!this.enabled||!this.fancy||w0()||!X0.stdout.isTTY){this.activeProgressBar=null;return}if($.current<$.total)$.current=$.total;if(J)$.message=J;this.renderProgressBar($,!0),this.activeProgressBar=null}async clear($={}){if(w0()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let J=await i1(this.config.logDirectory),Z=[];for(let X of J){if(!($.name?new RegExp($.name.replace("*",".*")).test(X):X.startsWith(this.name))||!X.endsWith(".log"))continue;let z=H1(this.config.logDirectory,X);if($.before)try{if((await K1(z)).mtime>=$.before)continue}catch(Q){console.error(`Failed to get stats for file ${z}:`,Q);continue}Z.push(z)}if(Z.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${Z.length} log file(s)...`);for(let X of Z)try{await t1(X),console.warn(`Deleted log file: ${X}`)}catch(Y){console.error(`Failed to delete log file ${X}:`,Y)}console.warn("Log clearing process finished.")}catch(J){console.error("Error during log clearing process:",J)}}}var KU=new $1("stacks");import{readFileSync as IY,writeFileSync as y2}from"fs";import{isAbsolute as b2,relative as PY,resolve as k2}from"path";import w1 from"process";var B$={meta:{docs:"Enforce return statements in callbacks of array methods",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=new RegExp(`\\.(${["map","filter","find","findIndex","findLast","findLastIndex","every","some","reduce","reduceRight","sort","flatMap"].join("|")})\\s*\\(`,"g");for(let Q=0;Q<X.length;Q++){let G=X[Q],q;for(q=z.exec(G);q!==null;q=z.exec(G)){let U=q[1],W=q.index+q[0].length,K=G.slice(W),H=K.match(/^\s*(?:\(([^)]*)\)|([a-z_$][\w$]*))\s*=>/i),V=K.match(/^\s*function\s*(?:[a-zA-Z_$][\w$]*\s*)?\(/);if(H){let A=K.slice(H[0].length).trim();if(A.startsWith("{")){let _=!1,F=0,B=A,j=Q;while(j<X.length){let D=j===Q?B:X[j];for(let M=0;M<D.length;M++){let E=D[M];if(E==="{")F++;if(E==="}"){if(F--,F===0){if(!_)Z.push({filePath:J.filePath,line:Q+1,column:q.index+1,ruleId:"eslint/array-callback-return",message:`Array method '${U}' callback should return a value`,severity:"error"});break}}}if(D.match(new RegExp("\\breturn\\s+[^;]")))_=!0;if(F===0)break;j++,B=X[j]||""}}}else if(V){let A=!1,_=0,F=Q,B=!1;while(F<X.length){let j=X[F];for(let D=0;D<j.length;D++){let M=j[D];if(M==="{")_++,B=!0;else if(M==="}"){if(_--,_===0&&B){if(!A)Z.push({filePath:J.filePath,line:Q+1,column:q.index+1,ruleId:"eslint/array-callback-return",message:`Array method '${U}' callback should return a value`,severity:"error"});break}}}if(B&&j.match(new RegExp("\\breturn\\s+[^;]")))A=!0;if(_===0&&B)break;F++}}}}return Z}};var w$={meta:{docs:"Require super() calls in constructors of derived classes",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=!1,Q=0,G=0,q=!1;for(let U=0;U<X.length;U++){let W=X[U];if(W.match(/\bclass\s+\w+\s+extends\s+\w+/))Y=!0;if(Y&&W.match(/\bconstructor\s*\(/))z=!0,Q=U+1,G=0,q=!1;if(z){for(let K of W){if(K==="{")G++;if(K==="}")G--}if(W.match(/\bsuper\s*\(/))q=!0;if(G===0&&W.includes("}")){if(!q)Z.push({filePath:J.filePath,line:Q,column:1,ruleId:"eslint/constructor-super",message:"Constructors of derived classes must call super()",severity:"error"});z=!1,Y=!1}}}return Z}};var M$={meta:{docs:'Enforce "for" loop update clause moving counter in the right direction',recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=new RegExp("\\bfor\\s*\\(\\s*(?:(?:let|var|const)\\s*)?(\\w+)\\s*=[^;]+;\\s*(\\w+)\\s*([<>]=?)[^;]+;\\s*(\\w+)(\\+\\+|--|[\\s+-]=)"),G=z.match(Q);if(G){let q=G[1],U=G[2],W=G[3],K=G[4],H=G[5];if(q===U&&U===K){let V=H.includes("+"),A=W.includes("<");if(A&&!V||!A&&V)Z.push({filePath:J.filePath,line:Y+1,column:1,ruleId:"eslint/for-direction",message:"The update clause in this loop moves the variable in the wrong direction",severity:"error"})}}}return Z}};var j$={meta:{docs:"Enforce return statements in getters",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let Q=X[Y].match(/\bget\s+(\w+)\s*\(/);if(Q){let G=Q[1],q=!1,U=0,W=Y;while(W<X.length){let K=X[W];for(let V of K){if(V==="{")U++;if(V==="}"){if(U--,U===0){if(!q)Z.push({filePath:J.filePath,line:Y+1,column:1,ruleId:"eslint/getter-return",message:`Getter '${G}' must return a value`,severity:"error"});break}}}let H=new RegExp("\\breturn\\s+[^;]");if(K.match(H))q=!0;if(U===0)break;W++}}}return Z}};var N$={meta:{docs:"Disallow async functions as Promise executor",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/new\s+Promise\s*\(\s*async\s*(?:\(|function)/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"eslint/no-async-promise-executor",message:"Promise executor functions should not be async",severity:"error"})}return Z}};var T$={meta:{docs:"Disallow comparing against -0",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/([!=]==?)\s*-0\b|\b-0\s*([!=]==?)/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"eslint/no-compare-neg-zero",message:"Do not use the '-0' literal in comparisons",severity:"error"})}return Z}};var E$={meta:{docs:"Disallow assignment operators in conditional expressions",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\b(if|while)\s*\([^)]*\b(\w+)\s*=\s*(?!=)[^)]*\)/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let q=G[0];if(/===|==/.test(q))continue;if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-cond-assign",message:"Expected a conditional expression and instead saw an assignment",severity:"error"})}}return Z}};var D$={meta:{docs:"Disallow reassigning const variables",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=new Map;for(let z=0;z<X.length;z++){let Q=X[z],G=Q.match(/\bconst\s+(\w+)/);if(G)Y.set(G[1],z);let q=/\b(\w+)\s*=(?!=)/g,U;for(U=q.exec(Q);U!==null;U=q.exec(Q)){let W=U[1],K=Q.substring(0,U.index);if(!/\b(?:const|let|var)\s*$/.test(K)&&Y.has(W))Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,U.index+1),ruleId:"eslint/no-const-assign",message:`'${W}' is constant`,severity:"error"})}}return Z}};var R$={meta:{docs:"Disallow constant expressions in conditions",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=[{pattern:/\b(if|while)\s*\(\s*(true|false)\s*\)/g,type:"boolean"},{pattern:/\b(if|while)\s*\(\s*(\d+)\s*\)/g,type:"number"},{pattern:/\b(if|while)\s*\(\s*(['"`][^'"`]*['"`])\s*\)/g,type:"string"}];for(let{pattern:G,type:q}of Q){let U;while((U=G.exec(z))!==null){let W=U[1],K=U[2];if(z.substring(0,U.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,U.index+W.length+2),ruleId:"eslint/no-constant-condition",message:"Unexpected constant condition",severity:"error"})}}}return Z}};var O$={meta:{docs:"Disallow duplicate class members",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=new Set,Q=0;for(let G=0;G<X.length;G++){let q=X[G];if(q.match(/\bclass\s+\w+/))Y=!0,z=new Set,Q=0;if(Y){for(let W of q){if(W==="{")Q++;if(W==="}"){if(Q--,Q===0)Y=!1}}let U=[...q.matchAll(/^\s*(?:(?:public|private|protected|static|readonly|async)\s*)?(?:get|set)?\s*(\w+)\s*\(/g),...q.matchAll(/^\s*(?:(?:public|private|protected|static|readonly)\s*)?(\w+)\s*[:=]/g)];for(let W of U){let K=W[1];if(z.has(K))Z.push({filePath:J.filePath,line:G+1,column:1,ruleId:"eslint/no-dupe-class-members",message:`Duplicate class member '${K}'`,severity:"error"});else z.add(K)}}}return Z}};var I1={meta:{docs:"Disallow duplicate keys in object literals",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=/\{\s*$/,z=/^\s*(?:(['"`])(.+?)\1|(\w+))\s*:/;for(let Q=0;Q<X.length;Q++){let G=X[Q];if(!Y.test(G)&&!G.includes("{"))continue;let q=new Map,U=(G.match(/\{/g)||[]).length-(G.match(/\}/g)||[]).length,W=Q;for(let K=Q+1;K<X.length&&U>0;K++){let H=X[K];U+=(H.match(/\{/g)||[]).length,U-=(H.match(/\}/g)||[]).length;let V=H.match(z);if(V){let A=V[2]||V[3];if(A)if(q.get(A)!==void 0)Z.push({filePath:J.filePath,line:K+1,column:Math.max(1,H.search(/\S/)+1),ruleId:"eslint/no-dupe-keys",message:`Duplicate key '${A}'`,severity:"error"});else q.set(A,K)}if(U===0)break}}return Z},fix:($,J)=>{let Z=I1.check($,J);if(Z.length===0)return $;let X=$.split(/\r?\n/),Y=new Set(Z.map((Q)=>Q.line-1));return X.filter((Q,G)=>!Y.has(G)).join(`
50
- `)}};var L$={meta:{docs:"Disallow duplicate case labels in switch statements",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=new Set,Q=-1;for(let G=0;G<X.length;G++){let q=X[G],U=q.trim();if(/\bswitch\s*\(/.test(U)){Y=!0,z=new Set,Q=G;continue}if(Y&&U==="}"&&G>Q){let W=X[Q].match(/^\s*/)?.[0].length||0;if((q.match(/^\s*/)?.[0].length||0)<=W+2)Y=!1,z=new Set}if(Y){let W=U.match(/^case\s+(.+?)\s*:/);if(W){let K=W[1].trim();if(z.has(K))Z.push({filePath:J.filePath,line:G+1,column:Math.max(1,q.indexOf("case")+1),ruleId:"eslint/no-duplicate-case",message:`Duplicate case label '${K}'`,severity:"error"});else z.add(K)}}}return Z}};var P$={meta:{docs:"Disallow empty destructuring patterns",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\{\s*\}\s*=/g,G=/\[\s*\]\s*=/g,q;for(q=Q.exec(z);q!==null;q=Q.exec(z)){if(z.substring(0,q.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-empty-pattern",message:"Unexpected empty object pattern",severity:"error"})}for(q=G.exec(z);q!==null;q=G.exec(z)){if(z.substring(0,q.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-empty-pattern",message:"Unexpected empty array pattern",severity:"error"})}}return Z}};var C$={meta:{docs:"Disallow fallthrough of case statements",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=-1,Q=!1;for(let G=0;G<X.length;G++){let U=X[G].trim();if(/\bswitch\s*\(/.test(U)){Y=!0;continue}if(Y){if(/^case\s+/.test(U)||/^default\s*:/.test(U)){if(z>=0&&Q){if(!(/\/\/.*falls?\s*through|\/\*.*falls?\s*through/i.test(X[z])||G>0&&/\/\/.*falls?\s*through|\/\*.*falls?\s*through/i.test(X[G-1])))Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,X[z].indexOf("case")+1),ruleId:"eslint/no-fallthrough",message:"Expected a 'break' statement before 'case'",severity:"error"})}z=G,Q=!0}if(/\b(?:break|return|throw|continue)\b/.test(U))Q=!1;if(U==="}")Y=!1,z=-1,Q=!1}}return Z}};var I$={meta:{docs:"Disallow number literals that lose precision",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\b(\d{17,}(?:\.\d+)?|\d+\.\d{17,})\b/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let q=G[1];if(Number(q).toString()!==q)Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"eslint/no-loss-of-precision",message:"This number literal will lose precision at runtime",severity:"error"})}}return Z}};var S$={meta:{docs:"Disallow returning values from Promise executor functions",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++)if(X[Y].match(/new\s+Promise\s*\(/)){let G=0,q=!1,U=Y;while(U<X.length){let W=X[U];for(let H of W){if(H==="{")G++,q=!0;if(H==="}"){if(G--,G===0&&q)break}}let K=new RegExp("\\breturn\\s+[^;]");if(q&&W.match(K))Z.push({filePath:J.filePath,line:U+1,column:1,ruleId:"eslint/no-promise-executor-return",message:"Return values from promise executor functions cannot be read",severity:"error"});if(G===0&&q)break;U++}}return Z}};var v$={meta:{docs:"Disallow variable redeclaration",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=new Map;for(let z=0;z<X.length;z++){let Q=X[z],G=/\b(var|let|const)\s+(\w+)/g,q;for(q=G.exec(Q);q!==null;q=G.exec(Q)){let W=q[2];if(Y.get(W)!==void 0)Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-redeclare",message:`'${W}' is already defined`,severity:"error"});else Y.set(W,z)}let U=/\bfunction\s+(\w+)/g;for(q=U.exec(Q);q!==null;q=U.exec(Q)){let W=q[1];if(Y.get(W)!==void 0)Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-redeclare",message:`'${W}' is already defined`,severity:"error"});else Y.set(W,z)}}return Z}};var S1={meta:{docs:"Disallow assignments where both sides are identical",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=new RegExp("\\b(\\w+)\\s*=\\s*(\\w+)\\s*(?:;\\s*)?(?:\\/\\/.*)?$"),G=z.match(Q);if(G&&G[1]===G[2]){Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf(G[1])+1),ruleId:"eslint/no-self-assign",message:`'${G[1]}' is assigned to itself`,severity:"error"});continue}let q=z.match(/([\w.]+)\s*=\s*([\w.]+)/);if(q&&q[1]===q[2]){Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf(q[1])+1),ruleId:"eslint/no-self-assign",message:`'${q[1]}' is assigned to itself`,severity:"error"});continue}let U=z.match(/(\w+\[[^\]]+\])\s*=\s*(\w+\[[^\]]+\])/);if(U){let W=U[1].replace(/\s/g,""),K=U[2].replace(/\s/g,"");if(W===K)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf(U[1])+1),ruleId:"eslint/no-self-assign",message:`'${U[1]}' is assigned to itself`,severity:"error"})}}return Z},fix:($,J)=>{let Z=S1.check($,J);if(Z.length===0)return $;let X=$.split(/\r?\n/),Y=new Set(Z.map((Q)=>Q.line-1));return X.map((Q,G)=>{if(Y.has(G)){let q=Q.trim();if(new RegExp("^\\w+(?:\\.\\w+|\\[[^\\]]+\\])?\\s*=\\s*\\w+(?:\\.\\w+|\\[[^\\]]+\\])?;?\\s*$").test(q))return""}return Q}).filter((Q,G,q)=>{if(Q===""&&Y.has(G)){let U=G>0&&q[G-1].trim()!=="",W=G<q.length-1&&q[G+1]&&q[G+1].trim()!=="";if(!U||!W)return!1}return!0}).join(`
49
+ `)}finishProgressBar($,J){if(!this.enabled||!this.fancy||w0()||!X0.stdout.isTTY){this.activeProgressBar=null;return}if($.current<$.total)$.current=$.total;if(J)$.message=J;this.renderProgressBar($,!0),this.activeProgressBar=null}async clear($={}){if(w0()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let J=await i1(this.config.logDirectory),Z=[];for(let X of J){if(!($.name?new RegExp($.name.replace("*",".*")).test(X):X.startsWith(this.name))||!X.endsWith(".log"))continue;let z=V1(this.config.logDirectory,X);if($.before)try{if((await H1(z)).mtime>=$.before)continue}catch(Q){console.error(`Failed to get stats for file ${z}:`,Q);continue}Z.push(z)}if(Z.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${Z.length} log file(s)...`);for(let X of Z)try{await t1(X),console.warn(`Deleted log file: ${X}`)}catch(Y){console.error(`Failed to delete log file ${X}:`,Y)}console.warn("Log clearing process finished.")}catch(J){console.error("Error during log clearing process:",J)}}}var VU=new Z1("stacks");import{readFileSync as IY,writeFileSync as y2}from"fs";import{isAbsolute as b2,relative as PY,resolve as k2}from"path";import M1 from"process";var B$={meta:{docs:"Enforce return statements in callbacks of array methods",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=new RegExp(`\\.(${["map","filter","find","findIndex","findLast","findLastIndex","every","some","reduce","reduceRight","sort","flatMap"].join("|")})\\s*\\(`,"g");for(let Q=0;Q<X.length;Q++){let G=X[Q],q;for(q=z.exec(G);q!==null;q=z.exec(G)){let U=q[1],W=q.index+q[0].length,K=G.slice(W),H=K.match(/^\s*(?:\(([^)]*)\)|([a-z_$][\w$]*))\s*=>/i),V=K.match(/^\s*function\s*(?:[a-zA-Z_$][\w$]*\s*)?\(/);if(H){let A=K.slice(H[0].length).trim();if(A.startsWith("{")){let _=!1,F=0,B=A,j=Q;while(j<X.length){let D=j===Q?B:X[j];for(let M=0;M<D.length;M++){let E=D[M];if(E==="{")F++;if(E==="}"){if(F--,F===0){if(!_)Z.push({filePath:J.filePath,line:Q+1,column:q.index+1,ruleId:"eslint/array-callback-return",message:`Array method '${U}' callback should return a value`,severity:"error"});break}}}if(D.match(new RegExp("\\breturn\\s+[^;]")))_=!0;if(F===0)break;j++,B=X[j]||""}}}else if(V){let A=!1,_=0,F=Q,B=!1;while(F<X.length){let j=X[F];for(let D=0;D<j.length;D++){let M=j[D];if(M==="{")_++,B=!0;else if(M==="}"){if(_--,_===0&&B){if(!A)Z.push({filePath:J.filePath,line:Q+1,column:q.index+1,ruleId:"eslint/array-callback-return",message:`Array method '${U}' callback should return a value`,severity:"error"});break}}}if(B&&j.match(new RegExp("\\breturn\\s+[^;]")))A=!0;if(_===0&&B)break;F++}}}}return Z}};var w$={meta:{docs:"Require super() calls in constructors of derived classes",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=!1,Q=0,G=0,q=!1;for(let U=0;U<X.length;U++){let W=X[U];if(W.match(/\bclass\s+\w+\s+extends\s+\w+/))Y=!0;if(Y&&W.match(/\bconstructor\s*\(/))z=!0,Q=U+1,G=0,q=!1;if(z){for(let K of W){if(K==="{")G++;if(K==="}")G--}if(W.match(/\bsuper\s*\(/))q=!0;if(G===0&&W.includes("}")){if(!q)Z.push({filePath:J.filePath,line:Q,column:1,ruleId:"eslint/constructor-super",message:"Constructors of derived classes must call super()",severity:"error"});z=!1,Y=!1}}}return Z}};var M$={meta:{docs:'Enforce "for" loop update clause moving counter in the right direction',recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=new RegExp("\\bfor\\s*\\(\\s*(?:(?:let|var|const)\\s*)?(\\w+)\\s*=[^;]+;\\s*(\\w+)\\s*([<>]=?)[^;]+;\\s*(\\w+)(\\+\\+|--|[\\s+-]=)"),G=z.match(Q);if(G){let q=G[1],U=G[2],W=G[3],K=G[4],H=G[5];if(q===U&&U===K){let V=H.includes("+"),A=W.includes("<");if(A&&!V||!A&&V)Z.push({filePath:J.filePath,line:Y+1,column:1,ruleId:"eslint/for-direction",message:"The update clause in this loop moves the variable in the wrong direction",severity:"error"})}}}return Z}};var j$={meta:{docs:"Enforce return statements in getters",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let Q=X[Y].match(/\bget\s+(\w+)\s*\(/);if(Q){let G=Q[1],q=!1,U=0,W=Y;while(W<X.length){let K=X[W];for(let V of K){if(V==="{")U++;if(V==="}"){if(U--,U===0){if(!q)Z.push({filePath:J.filePath,line:Y+1,column:1,ruleId:"eslint/getter-return",message:`Getter '${G}' must return a value`,severity:"error"});break}}}let H=new RegExp("\\breturn\\s+[^;]");if(K.match(H))q=!0;if(U===0)break;W++}}}return Z}};var N$={meta:{docs:"Disallow async functions as Promise executor",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/new\s+Promise\s*\(\s*async\s*(?:\(|function)/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"eslint/no-async-promise-executor",message:"Promise executor functions should not be async",severity:"error"})}return Z}};var T$={meta:{docs:"Disallow comparing against -0",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/([!=]==?)\s*-0\b|\b-0\s*([!=]==?)/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"eslint/no-compare-neg-zero",message:"Do not use the '-0' literal in comparisons",severity:"error"})}return Z}};var E$={meta:{docs:"Disallow assignment operators in conditional expressions",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\b(if|while)\s*\([^)]*\b(\w+)\s*=\s*(?!=)[^)]*\)/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let q=G[0];if(/===|==/.test(q))continue;if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-cond-assign",message:"Expected a conditional expression and instead saw an assignment",severity:"error"})}}return Z}};var D$={meta:{docs:"Disallow reassigning const variables",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=new Map;for(let z=0;z<X.length;z++){let Q=X[z],G=Q.match(/\bconst\s+(\w+)/);if(G)Y.set(G[1],z);let q=/\b(\w+)\s*=(?!=)/g,U;for(U=q.exec(Q);U!==null;U=q.exec(Q)){let W=U[1],K=Q.substring(0,U.index);if(!/\b(?:const|let|var)\s*$/.test(K)&&Y.has(W))Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,U.index+1),ruleId:"eslint/no-const-assign",message:`'${W}' is constant`,severity:"error"})}}return Z}};var R$={meta:{docs:"Disallow constant expressions in conditions",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=[{pattern:/\b(if|while)\s*\(\s*(true|false)\s*\)/g,type:"boolean"},{pattern:/\b(if|while)\s*\(\s*(\d+)\s*\)/g,type:"number"},{pattern:/\b(if|while)\s*\(\s*(['"`][^'"`]*['"`])\s*\)/g,type:"string"}];for(let{pattern:G,type:q}of Q){let U;while((U=G.exec(z))!==null){let W=U[1],K=U[2];if(z.substring(0,U.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,U.index+W.length+2),ruleId:"eslint/no-constant-condition",message:"Unexpected constant condition",severity:"error"})}}}return Z}};var O$={meta:{docs:"Disallow duplicate class members",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=new Set,Q=0;for(let G=0;G<X.length;G++){let q=X[G];if(q.match(/\bclass\s+\w+/))Y=!0,z=new Set,Q=0;if(Y){for(let W of q){if(W==="{")Q++;if(W==="}"){if(Q--,Q===0)Y=!1}}let U=[...q.matchAll(/^\s*(?:(?:public|private|protected|static|readonly|async)\s*)?(?:get|set)?\s*(\w+)\s*\(/g),...q.matchAll(/^\s*(?:(?:public|private|protected|static|readonly)\s*)?(\w+)\s*[:=]/g)];for(let W of U){let K=W[1];if(z.has(K))Z.push({filePath:J.filePath,line:G+1,column:1,ruleId:"eslint/no-dupe-class-members",message:`Duplicate class member '${K}'`,severity:"error"});else z.add(K)}}}return Z}};var S1={meta:{docs:"Disallow duplicate keys in object literals",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=/\{\s*$/,z=/^\s*(?:(['"`])(.+?)\1|(\w+))\s*:/;for(let Q=0;Q<X.length;Q++){let G=X[Q];if(!Y.test(G)&&!G.includes("{"))continue;let q=new Map,U=(G.match(/\{/g)||[]).length-(G.match(/\}/g)||[]).length,W=Q;for(let K=Q+1;K<X.length&&U>0;K++){let H=X[K];U+=(H.match(/\{/g)||[]).length,U-=(H.match(/\}/g)||[]).length;let V=H.match(z);if(V){let A=V[2]||V[3];if(A)if(q.get(A)!==void 0)Z.push({filePath:J.filePath,line:K+1,column:Math.max(1,H.search(/\S/)+1),ruleId:"eslint/no-dupe-keys",message:`Duplicate key '${A}'`,severity:"error"});else q.set(A,K)}if(U===0)break}}return Z},fix:($,J)=>{let Z=S1.check($,J);if(Z.length===0)return $;let X=$.split(/\r?\n/),Y=new Set(Z.map((Q)=>Q.line-1));return X.filter((Q,G)=>!Y.has(G)).join(`
50
+ `)}};var L$={meta:{docs:"Disallow duplicate case labels in switch statements",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=new Set,Q=-1;for(let G=0;G<X.length;G++){let q=X[G],U=q.trim();if(/\bswitch\s*\(/.test(U)){Y=!0,z=new Set,Q=G;continue}if(Y&&U==="}"&&G>Q){let W=X[Q].match(/^\s*/)?.[0].length||0;if((q.match(/^\s*/)?.[0].length||0)<=W+2)Y=!1,z=new Set}if(Y){let W=U.match(/^case\s+(.+?)\s*:/);if(W){let K=W[1].trim();if(z.has(K))Z.push({filePath:J.filePath,line:G+1,column:Math.max(1,q.indexOf("case")+1),ruleId:"eslint/no-duplicate-case",message:`Duplicate case label '${K}'`,severity:"error"});else z.add(K)}}}return Z}};var P$={meta:{docs:"Disallow empty destructuring patterns",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\{\s*\}\s*=/g,G=/\[\s*\]\s*=/g,q;for(q=Q.exec(z);q!==null;q=Q.exec(z)){if(z.substring(0,q.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-empty-pattern",message:"Unexpected empty object pattern",severity:"error"})}for(q=G.exec(z);q!==null;q=G.exec(z)){if(z.substring(0,q.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-empty-pattern",message:"Unexpected empty array pattern",severity:"error"})}}return Z}};var C$={meta:{docs:"Disallow fallthrough of case statements",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=-1,Q=!1;for(let G=0;G<X.length;G++){let U=X[G].trim();if(/\bswitch\s*\(/.test(U)){Y=!0;continue}if(Y){if(/^case\s+/.test(U)||/^default\s*:/.test(U)){if(z>=0&&Q){if(!(/\/\/.*falls?\s*through|\/\*.*falls?\s*through/i.test(X[z])||G>0&&/\/\/.*falls?\s*through|\/\*.*falls?\s*through/i.test(X[G-1])))Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,X[z].indexOf("case")+1),ruleId:"eslint/no-fallthrough",message:"Expected a 'break' statement before 'case'",severity:"error"})}z=G,Q=!0}if(/\b(?:break|return|throw|continue)\b/.test(U))Q=!1;if(U==="}")Y=!1,z=-1,Q=!1}}return Z}};var I$={meta:{docs:"Disallow number literals that lose precision",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\b(\d{17,}(?:\.\d+)?|\d+\.\d{17,})\b/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let q=G[1];if(Number(q).toString()!==q)Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"eslint/no-loss-of-precision",message:"This number literal will lose precision at runtime",severity:"error"})}}return Z}};var S$={meta:{docs:"Disallow returning values from Promise executor functions",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++)if(X[Y].match(/new\s+Promise\s*\(/)){let G=0,q=!1,U=Y;while(U<X.length){let W=X[U];for(let H of W){if(H==="{")G++,q=!0;if(H==="}"){if(G--,G===0&&q)break}}let K=new RegExp("\\breturn\\s+[^;]");if(q&&W.match(K))Z.push({filePath:J.filePath,line:U+1,column:1,ruleId:"eslint/no-promise-executor-return",message:"Return values from promise executor functions cannot be read",severity:"error"});if(G===0&&q)break;U++}}return Z}};var v$={meta:{docs:"Disallow variable redeclaration",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=new Map;for(let z=0;z<X.length;z++){let Q=X[z],G=/\b(var|let|const)\s+(\w+)/g,q;for(q=G.exec(Q);q!==null;q=G.exec(Q)){let W=q[2];if(Y.get(W)!==void 0)Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-redeclare",message:`'${W}' is already defined`,severity:"error"});else Y.set(W,z)}let U=/\bfunction\s+(\w+)/g;for(q=U.exec(Q);q!==null;q=U.exec(Q)){let W=q[1];if(Y.get(W)!==void 0)Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-redeclare",message:`'${W}' is already defined`,severity:"error"});else Y.set(W,z)}}return Z}};var v1={meta:{docs:"Disallow assignments where both sides are identical",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=new RegExp("\\b(\\w+)\\s*=\\s*(\\w+)\\s*(?:;\\s*)?(?:\\/\\/.*)?$"),G=z.match(Q);if(G&&G[1]===G[2]){Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf(G[1])+1),ruleId:"eslint/no-self-assign",message:`'${G[1]}' is assigned to itself`,severity:"error"});continue}let q=z.match(/([\w.]+)\s*=\s*([\w.]+)/);if(q&&q[1]===q[2]){Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf(q[1])+1),ruleId:"eslint/no-self-assign",message:`'${q[1]}' is assigned to itself`,severity:"error"});continue}let U=z.match(/(\w+\[[^\]]+\])\s*=\s*(\w+\[[^\]]+\])/);if(U){let W=U[1].replace(/\s/g,""),K=U[2].replace(/\s/g,"");if(W===K)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf(U[1])+1),ruleId:"eslint/no-self-assign",message:`'${U[1]}' is assigned to itself`,severity:"error"})}}return Z},fix:($,J)=>{let Z=v1.check($,J);if(Z.length===0)return $;let X=$.split(/\r?\n/),Y=new Set(Z.map((Q)=>Q.line-1));return X.map((Q,G)=>{if(Y.has(G)){let q=Q.trim();if(new RegExp("^\\w+(?:\\.\\w+|\\[[^\\]]+\\])?\\s*=\\s*\\w+(?:\\.\\w+|\\[[^\\]]+\\])?;?\\s*$").test(q))return""}return Q}).filter((Q,G,q)=>{if(Q===""&&Y.has(G)){let U=G>0&&q[G-1].trim()!=="",W=G<q.length-1&&q[G+1]&&q[G+1].trim()!=="";if(!U||!W)return!1}return!0}).join(`
51
51
  `)}};var y$={meta:{docs:"Disallow comparisons where both sides are identical",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/([\w.\[\]]+)\s*(===|!==|==|!=|<|>|<=|>=)\s*([\w.\[\]]+)/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let q=G[1].replace(/\s/g,""),U=G[2],W=G[3].replace(/\s/g,"");if(q===W)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-self-compare",message:`Comparing '${G[1]}' to itself is potentially pointless`,severity:"error"})}}return Z}};var b$={meta:{docs:"Disallow sparse arrays (arrays with empty slots)",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\[([^\]]*)\]/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let q=G[1];if(/,\s*,/.test(q))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-sparse-arrays",message:"Unexpected sparse array",severity:"error"})}}return Z},fix:($,J)=>{let Z=$.split(/\r?\n/),X=!1,Y=Z.map((z)=>{let Q=z;return Q=Q.replace(/\[([^\]]*)\]/g,(G,q)=>{if(/,\s*,/.test(q))return X=!0,`[${q.replace(/,(\s*),/g,", undefined,")}]`;return G}),Q});return X?Y.join(`
52
52
  `):$}};var k$={meta:{docs:"Disallow undeclared variables",recommended:!0,wip:!0},check:($,J)=>{return[]}};var f$={meta:{docs:"Disallow unreachable code after return, throw, continue, or break",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(/^\s*(?:return|throw|break|continue)\b/.test(z))for(let G=Y+1;G<X.length;G++){let q=X[G],U=q.trim();if(U===""||U.startsWith("//")||U.startsWith("/*"))continue;if(U==="}"||U.startsWith("}"))break;if(/^(?:case\b|default\s*:)/.test(U))break;Z.push({filePath:J.filePath,line:G+1,column:Math.max(1,q.search(/\S/)+1),ruleId:"eslint/no-unreachable",message:"Unreachable code",severity:"error"});break}}return Z}};var g$={meta:{docs:"Disallow negation of the left operand of relational operators",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/!\s*\w+\s+in\s+/g,G=/!\s*\w+\s+instanceof\s+/g,q;for(q=Q.exec(z);q!==null;q=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:q.index+1,ruleId:"eslint/no-unsafe-negation",message:"Unexpected negation of 'in' operand",severity:"error"});for(q=G.exec(z);q!==null;q=G.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:q.index+1,ruleId:"eslint/no-unsafe-negation",message:"Unexpected negation of 'instanceof' operand",severity:"error"})}return Z},fix:($)=>{let J=$;return J=J.replace(/!\s*(\w+)\s+in\s+/g,"!($1 in "),J=J.replace(/!\s*(\w+)\s+instanceof\s+/g,"!($1 instanceof "),J}};var x$={meta:{docs:"Disallow unnecessary catch clauses",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.match(/catch\s*\(\s*(\w+)\s*\)/);if(!Q)continue;let G=Q[1];for(let q=Y+1;q<Math.min(Y+5,X.length);q++){let U=X[q].trim();if(U===`throw ${G}`||U===`throw ${G};`){let W=!1;for(let K=Y+1;K<q;K++){let H=X[K].trim();if(H!==""&&H!=="{"&&!H.startsWith("//")){W=!0;break}}if(!W)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf("catch")+1),ruleId:"eslint/no-useless-catch",message:"Unnecessary catch clause",severity:"error"});break}if(U==="}")break}}return Z}};var p$={meta:{docs:"Require isNaN() when checking for NaN",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\b([\w.\[\]]+)\s*(===|!==|==|!=)\s*NaN\b|\bNaN\s*(===|!==|==|!=)\s*([\w.\[\]]+)/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let q=G[1]||G[4];Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/use-isnan",message:"Use isNaN() to compare with NaN",severity:"error"})}}return Z},fix:($,J)=>{let Z=$.split(/\r?\n/),X=!1,Y=Z.map((z)=>{let Q=z;return Q=Q.replace(/\b([\w.\[\]]+)\s*===\s*NaN\b/g,(G,q)=>{return X=!0,`isNaN(${q})`}),Q=Q.replace(/\bNaN\s*===\s*([\w.\[\]]+)\b/g,(G,q)=>{return X=!0,`isNaN(${q})`}),Q=Q.replace(/\b([\w.\[\]]+)\s*!==\s*NaN\b/g,(G,q)=>{return X=!0,`!isNaN(${q})`}),Q=Q.replace(/\bNaN\s*!==\s*([\w.\[\]]+)\b/g,(G,q)=>{return X=!0,`!isNaN(${q})`}),Q=Q.replace(/\b([\w.\[\]]+)\s*==\s*NaN\b/g,(G,q)=>{return X=!0,`isNaN(${q})`}),Q=Q.replace(/\bNaN\s*==\s*([\w.\[\]]+)\b/g,(G,q)=>{return X=!0,`isNaN(${q})`}),Q=Q.replace(/\b([\w.\[\]]+)\s*!=\s*NaN\b/g,(G,q)=>{return X=!0,`!isNaN(${q})`}),Q=Q.replace(/\bNaN\s*!=\s*([\w.\[\]]+)\b/g,(G,q)=>{return X=!0,`!isNaN(${q})`}),Q});return X?Y.join(`
53
- `):$}};var jZ=["undefined","object","boolean","number","string","function","symbol","bigint"],h$={meta:{docs:"Enforce comparing typeof expressions against valid strings",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/typeof\s+\w+\s*(?:===|!==|==|!=)\s*(['"`])(\w+)\1/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let U=G[2];if(!jZ.includes(U))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/valid-typeof",message:`Invalid typeof comparison value '${U}'`,severity:"error"})}let q=/(['"`])(\w+)\1\s*(?:===|!==|==|!=)\s*typeof\s+\w+/g;for(G=q.exec(z);G!==null;G=q.exec(z)){let U=G[2];if(!jZ.includes(U))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/valid-typeof",message:`Invalid typeof comparison value '${U}'`,severity:"error"})}}return Z}};var u$={meta:{docs:"Enforce a maximum cyclomatic complexity allowed in a program",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=10,z=!1,Q=0,G="",q=0,U=0;for(let W=0;W<X.length;W++){let K=X[W],H=K.match(/\bfunction\s+(\w+)\s*\(|(\w+)\s*=\s*(?:\([^)]*\)|(\w+))\s*=>/);if(H)z=!0,Q=W+1,G=H[1]||H[2]||H[3]||"anonymous",q=1,U=0;if(z){for(let A of K){if(A==="{")U++;if(A==="}"){if(U--,U===0){if(q>10)Z.push({filePath:J.filePath,line:Q,column:1,ruleId:"eslint/complexity",message:`Function '${G}' has complexity ${q}, exceeds maximum of 10`,severity:"error"});z=!1}}}let V=[/\bif\s*\(/,/\belse\s+if\s*\(/,/\bfor\s*\(/,/\bwhile\s*\(/,/\bcase\s+/,/\bcatch\s*\(/,/\b&&\b/,/\b\|\|\b/,/\?\s*(?:\S.*(?:[\n\r\u2028\u2029]\s*)?)?:/];for(let A of V){let _=K.match(new RegExp(A,"g"));if(_)q+=_.length}}}return Z}};var m$={meta:{docs:"Require default case in switch statements",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=0,Q=!1,G=0;for(let q=0;q<X.length;q++){let U=X[q];if(U.match(/\bswitch\s*\(/))Y=!0,z=q+1,Q=!1,G=0;if(Y){for(let W of U){if(W==="{")G++;if(W==="}"){if(G--,G===0){if(!Q)Z.push({filePath:J.filePath,line:z,column:1,ruleId:"eslint/default-case",message:"Expected a default case",severity:"error"});Y=!1}}}if(U.match(/\bdefault\s*:/))Q=!0}}return Z}};var d$={meta:{docs:"Require === and !== instead of == and !=",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/([^=!])(\s*)(==)(\s*)([^=])/g,G=/([^!])(\s*)(!=)(\s*)([^=])/g,q;for(q=Q.exec(z);q!==null;q=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+2),ruleId:"eslint/eqeqeq",message:"Expected '===' and instead saw '=='",severity:"error"});for(q=G.exec(z);q!==null;q=G.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+2),ruleId:"eslint/eqeqeq",message:"Expected '!==' and instead saw '!='",severity:"error"})}return Z},fix:($)=>{let J=$;return J=J.replace(/([^!])(\s*)(!=)(\s*)([^=])/g,"$1$2!==$4$5"),J=J.replace(/([^=!])(\s*)(==)(\s*)([^=])/g,"$1$2===$4$5"),J}};var o$={meta:{docs:"Enforce a maximum depth that blocks can be nested",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=4,z=0,Q=0,G=0;for(let q=0;q<X.length;q++){let U=X[q];if(U.match(/\b(if|for|while|switch|try|catch|else)\b.*\{/)){if(z++,z>Q)Q=z,G=q+1}else if(U.match(/\{/)&&!U.match(/^.*\}/)){if(X[q-1]?.match(/\b(if|for|while|switch|try|catch|else)\b/)){if(z++,z>Q)Q=z,G=q+1}}if(U.match(/^\s*\}/))z--;if(z>4)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"eslint/max-depth",message:`Blocks are nested too deeply (${z}), maximum allowed is 4`,severity:"error"})}return Z}};var c$={meta:{docs:"Enforce a maximum number of lines of code in a function",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=50,z=!1,Q=0,G="",q=0;for(let U=0;U<X.length;U++){let W=X[U],K=W.match(/\bfunction\s+(\w+)\s*\(|(\w+)\s*=\s*(?:\([^)]*\)|(\w+))\s*=>/);if(K)z=!0,Q=U+1,G=K[1]||K[2]||K[3]||"anonymous",q=0;if(z)for(let H of W){if(H==="{")q++;if(H==="}"){if(q--,q===0){let V=U+1-Q+1;if(V>50)Z.push({filePath:J.filePath,line:Q,column:1,ruleId:"eslint/max-lines-per-function",message:`Function '${G}' has ${V} lines, exceeds maximum of 50`,severity:"error"});z=!1}}}}return Z}};var r$={meta:{docs:"Disallow alert, confirm, and prompt",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\b(alert|confirm|prompt)\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-alert",message:`Unexpected ${G[1]}`,severity:"warning"})}}return Z}};var l$={meta:{docs:"Disallow await inside of loops",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=0,Q=0;for(let G=0;G<X.length;G++){let q=X[G];if(q.match(/\b(for|while|do)\s*\(/))Y=!0,z=0,Q=G;if(Y){for(let U of q){if(U==="{")z++;if(U==="}"){if(z--,z===0)Y=!1}}if(q.match(/\bawait\s+/))Z.push({filePath:J.filePath,line:G+1,column:1,ruleId:"eslint/no-await-in-loop",message:"Unexpected await inside a loop. Consider using Promise.all() instead",severity:"error"})}}return Z}};var a$={meta:{docs:"Disallow use of arguments.caller or arguments.callee",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\barguments\s*\.\s*(caller|callee)\b/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"eslint/no-caller",message:`Avoid arguments.${G[1]}`,severity:"error"})}return Z}};var s$={meta:{docs:"Disallow lexical declarations in case clauses",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=!1;for(let Q=0;Q<X.length;Q++){let G=X[Q];if(G.match(/\bcase\s+(?:\S.*)?:|default\s*:/))Y=!0,z=!0;else z=!1;if(Y&&!z&&(G.match(/\bbreak\b/)||G.match(/\bcase\s+(?:\S.*)?:/)))Y=!1;if(Y&&!z){if(G.match(/\b(let|const|function|class)\s+/))Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"eslint/no-case-declarations",message:"Unexpected lexical declaration in case block",severity:"error"})}}return Z}};var n$={meta:{docs:"Disallow else blocks after return statements in if statements",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(!/^\s*else\b/.test(z))continue;let Q=!1;for(let G=Y-1;G>=0&&G>=Y-10;G--){let q=X[G].trim();if(q.startsWith("return"))Q=!0;if(q==="}"&&Q)break;if(q.includes("{"))break}if(Q)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf("else")+1),ruleId:"eslint/no-else-return",message:"Unnecessary else after return",severity:"warning"})}return Z}};var i$={meta:{docs:"Disallow empty block statements",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\{\s*\}/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let q=z.substring(0,G.index).trim(),U=/(?:if|else|for|while|do|try|catch|finally|function|\})\s*$/.test(q),W=/[=:]$/.test(q)||/return\s*$/.test(q);if(U&&!W)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-empty",message:"Empty block statement",severity:"error"})}}for(let Y=0;Y<X.length-1;Y++){let z=X[Y],Q=X[Y+1];if(/\{\s*$/.test(z.trim()))for(let G=Y+1;G<X.length;G++){let q=X[G].trim();if(q==="")continue;if(q==="}"||q.startsWith("}")){let U=z.substring(0,z.lastIndexOf("{")).trim(),W=/(?:if|else|for|while|do|try|catch|finally|function|\})\s*$/.test(U),K=/[=:]$/.test(U)||/return\s*$/.test(U);if(W&&!K)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.lastIndexOf("{")+1),ruleId:"eslint/no-empty",message:"Empty block statement",severity:"error"})}break}}return Z}};var t$={meta:{docs:"Disallow empty functions",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=[/function\s+\w+\s*\([^)]*\)\s*\{\s*\}/g,/function\s*\([^)]*\)\s*\{\s*\}/g,/\([^)]*\)\s*=>\s*\{\s*\}/g,/\w+\s*\([^)]*\)\s*\{\s*\}/g];for(let G of Q){let q;for(q=G.exec(z);q!==null;q=G.exec(z)){if(z.substring(0,q.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-empty-function",message:"Unexpected empty function",severity:"warning"})}}}return Z}};var e$={meta:{docs:"Disallow use of eval()",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\beval\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-eval",message:"eval can be harmful",severity:"error"})}}return Z}};var dQ=["Object","Array","String","Number","Boolean","Date","RegExp","Function","Math","JSON","Promise","Map","Set","WeakMap","WeakSet","Symbol","Proxy","Reflect","Error","TypeError","RangeError"],$8={meta:{docs:"Disallow extending native types",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];for(let Q of dQ){let G=new RegExp(`\\b${Q}\\.prototype\\.\\w+\\s*=`,"g"),q;for(q=G.exec(z);q!==null;q=G.exec(z)){if(z.substring(0,q.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-extend-native",message:`${Q} prototype is read only, properties should not be added`,severity:"error"})}}}return Z}};var Z8={meta:{docs:"Disallow unnecessary boolean casts",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=[/\bif\s*\(\s*Boolean\s*\(/g,/\bwhile\s*\(\s*Boolean\s*\(/g,/!\s*Boolean\s*\(/g,/\?\s*Boolean\s*\(/g,/&&\s*Boolean\s*\(/g,/\|\|\s*Boolean\s*\(/g,/!!\s*\w+/g];for(let G of Q){let q;for(q=G.exec(z);q!==null;q=G.exec(z)){if(z.substring(0,q.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-extra-boolean-cast",message:"Redundant Boolean call or double negation",severity:"error"})}}}return Z},fix:($)=>{let J=$;return J=J.replace(/\b(if|while)\s*\(\s*Boolean\s*\(([^)]+)\)\s*\)/g,"$1 ($2)"),J=J.replace(/!\s*Boolean\s*\(([^)]+)\)/g,"!$1"),J=J.replace(/!!\s*(\w+)/g,"$1"),J}};var oQ=["Array","Boolean","Date","Error","Function","JSON","Math","Number","Object","RegExp","String","Symbol","undefined","NaN","Infinity","isNaN","isFinite","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","eval","Promise","Proxy","Reflect","Set","Map","WeakSet","WeakMap","ArrayBuffer","DataView","console","window","document","globalThis","global","process"],J8={meta:{docs:"Disallow assignment to native objects or read-only global variables",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];for(let Q of oQ){let G=new RegExp(`\\b${Q}\\s*=\\s*[^=]`,"g"),q;for(q=G.exec(z);q!==null;q=G.exec(z))if(!z.slice(q.index).match(new RegExp(`^${Q}\\s*===?`)))Z.push({filePath:J.filePath,line:Y+1,column:q.index+1,ruleId:"eslint/no-global-assign",message:`Read-only global '${Q}' should not be modified`,severity:"error"})}}return Z}};var X8={meta:{docs:"Disallow implied eval() via setTimeout/setInterval with strings",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\b(setTimeout|setInterval)\s*\(\s*(['"`])/g,G;while((G=Q.exec(z))!==null){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-implied-eval",message:"Implied eval. Consider passing a function instead of a string",severity:"error"})}}return Z}};var Y8={meta:{docs:"Disallow the use of the __iterator__ property",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/__iterator__/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-iterator",message:"Reserved name '__iterator__'",severity:"error"})}}return Z}};var v1={meta:{docs:"Disallow if statements as the only statement in else blocks",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(/^\s*else\s*(?:\{\s*)?$/.test(z)){let G=Y,q=z.includes("{");if(!q){if(Y+1<X.length&&X[Y+1].trim()==="{")G=Y+1,q=!0}if(q)for(let U=G+1;U<X.length;U++){let W=X[U].trim();if(W===""||W.startsWith("//")||W.startsWith("/*"))continue;if(W==="}")break;if(W.startsWith("if ")||W.startsWith("if(")){let K=!0,H=0,V=!1;for(let A=U;A<X.length;A++){let _=X[A];if(H+=(_.match(/\{/g)||[]).length,H-=(_.match(/\}/g)||[]).length,A===U){V=!0;continue}if(H===0){for(let F=A+1;F<X.length;F++){let B=X[F].trim();if(B===""||B.startsWith("//"))continue;if(B==="}"||B.startsWith("}"))break;else K=!1;break}break}}if(V&&K)Z.push({filePath:J.filePath,line:U+1,column:Math.max(1,X[U].indexOf("if")+1),ruleId:"eslint/no-lonely-if",message:"Unexpected if as the only statement in an else block",severity:"warning"})}break}}}return Z},fix:($,J)=>{if(v1.check($,J).length===0)return $;return $}};var z8={meta:{docs:"Disallow new operators outside of assignments or comparisons",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(/^\s*new\s+\w+\s*\(/.test(z)){if(!/[=:]/.test(z.substring(0,z.indexOf("new"))))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf("new")+1),ruleId:"eslint/no-new",message:"Do not use 'new' for side effects",severity:"warning"})}}return Z}};var Q8={meta:{docs:"Disallow new Function() declarations",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\bnew\s+Function\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-new-func",message:"The Function constructor is eval",severity:"error"})}}return Z}};var G8={meta:{docs:"Disallow new operators with String, Number, and Boolean",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\bnew\s+(String|Number|Boolean)\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-new-wrappers",message:`Do not use ${G[1]} as a constructor`,severity:"error"})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=!1,X=J.map((Y)=>{if(Y.trim().startsWith("//")||Y.trim().startsWith("/*"))return Y;return Y.replace(/\bnew\s+(String|Number|Boolean)\s*\(/g,(Q,G)=>{return Z=!0,`${G}(`})});return Z?X.join(`
53
+ `):$}};var jZ=["undefined","object","boolean","number","string","function","symbol","bigint"],h$={meta:{docs:"Enforce comparing typeof expressions against valid strings",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/typeof\s+\w+\s*(?:===|!==|==|!=)\s*(['"`])(\w+)\1/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let U=G[2];if(!jZ.includes(U))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/valid-typeof",message:`Invalid typeof comparison value '${U}'`,severity:"error"})}let q=/(['"`])(\w+)\1\s*(?:===|!==|==|!=)\s*typeof\s+\w+/g;for(G=q.exec(z);G!==null;G=q.exec(z)){let U=G[2];if(!jZ.includes(U))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/valid-typeof",message:`Invalid typeof comparison value '${U}'`,severity:"error"})}}return Z}};var u$={meta:{docs:"Enforce a maximum cyclomatic complexity allowed in a program",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=10,z=!1,Q=0,G="",q=0,U=0;for(let W=0;W<X.length;W++){let K=X[W],H=K.match(/\bfunction\s+(\w+)\s*\(|(\w+)\s*=\s*(?:\([^)]*\)|(\w+))\s*=>/);if(H)z=!0,Q=W+1,G=H[1]||H[2]||H[3]||"anonymous",q=1,U=0;if(z){for(let A of K){if(A==="{")U++;if(A==="}"){if(U--,U===0){if(q>10)Z.push({filePath:J.filePath,line:Q,column:1,ruleId:"eslint/complexity",message:`Function '${G}' has complexity ${q}, exceeds maximum of 10`,severity:"error"});z=!1}}}let V=[/\bif\s*\(/,/\belse\s+if\s*\(/,/\bfor\s*\(/,/\bwhile\s*\(/,/\bcase\s+/,/\bcatch\s*\(/,/\b&&\b/,/\b\|\|\b/,/\?\s*(?:\S.*(?:[\n\r\u2028\u2029]\s*)?)?:/];for(let A of V){let _=K.match(new RegExp(A,"g"));if(_)q+=_.length}}}return Z}};var m$={meta:{docs:"Require default case in switch statements",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=0,Q=!1,G=0;for(let q=0;q<X.length;q++){let U=X[q];if(U.match(/\bswitch\s*\(/))Y=!0,z=q+1,Q=!1,G=0;if(Y){for(let W of U){if(W==="{")G++;if(W==="}"){if(G--,G===0){if(!Q)Z.push({filePath:J.filePath,line:z,column:1,ruleId:"eslint/default-case",message:"Expected a default case",severity:"error"});Y=!1}}}if(U.match(/\bdefault\s*:/))Q=!0}}return Z}};var d$={meta:{docs:"Require === and !== instead of == and !=",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/([^=!])(\s*)(==)(\s*)([^=])/g,G=/([^!])(\s*)(!=)(\s*)([^=])/g,q;for(q=Q.exec(z);q!==null;q=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+2),ruleId:"eslint/eqeqeq",message:"Expected '===' and instead saw '=='",severity:"error"});for(q=G.exec(z);q!==null;q=G.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+2),ruleId:"eslint/eqeqeq",message:"Expected '!==' and instead saw '!='",severity:"error"})}return Z},fix:($)=>{let J=$;return J=J.replace(/([^!])(\s*)(!=)(\s*)([^=])/g,"$1$2!==$4$5"),J=J.replace(/([^=!])(\s*)(==)(\s*)([^=])/g,"$1$2===$4$5"),J}};var o$={meta:{docs:"Enforce a maximum depth that blocks can be nested",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=4,z=0,Q=0,G=0;for(let q=0;q<X.length;q++){let U=X[q];if(U.match(/\b(if|for|while|switch|try|catch|else)\b.*\{/)){if(z++,z>Q)Q=z,G=q+1}else if(U.match(/\{/)&&!U.match(/^.*\}/)){if(X[q-1]?.match(/\b(if|for|while|switch|try|catch|else)\b/)){if(z++,z>Q)Q=z,G=q+1}}if(U.match(/^\s*\}/))z--;if(z>4)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"eslint/max-depth",message:`Blocks are nested too deeply (${z}), maximum allowed is 4`,severity:"error"})}return Z}};var c$={meta:{docs:"Enforce a maximum number of lines of code in a function",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=50,z=!1,Q=0,G="",q=0;for(let U=0;U<X.length;U++){let W=X[U],K=W.match(/\bfunction\s+(\w+)\s*\(|(\w+)\s*=\s*(?:\([^)]*\)|(\w+))\s*=>/);if(K)z=!0,Q=U+1,G=K[1]||K[2]||K[3]||"anonymous",q=0;if(z)for(let H of W){if(H==="{")q++;if(H==="}"){if(q--,q===0){let V=U+1-Q+1;if(V>50)Z.push({filePath:J.filePath,line:Q,column:1,ruleId:"eslint/max-lines-per-function",message:`Function '${G}' has ${V} lines, exceeds maximum of 50`,severity:"error"});z=!1}}}}return Z}};var r$={meta:{docs:"Disallow alert, confirm, and prompt",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\b(alert|confirm|prompt)\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-alert",message:`Unexpected ${G[1]}`,severity:"warning"})}}return Z}};var l$={meta:{docs:"Disallow await inside of loops",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=0,Q=0;for(let G=0;G<X.length;G++){let q=X[G];if(q.match(/\b(for|while|do)\s*\(/))Y=!0,z=0,Q=G;if(Y){for(let U of q){if(U==="{")z++;if(U==="}"){if(z--,z===0)Y=!1}}if(q.match(/\bawait\s+/))Z.push({filePath:J.filePath,line:G+1,column:1,ruleId:"eslint/no-await-in-loop",message:"Unexpected await inside a loop. Consider using Promise.all() instead",severity:"error"})}}return Z}};var a$={meta:{docs:"Disallow use of arguments.caller or arguments.callee",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\barguments\s*\.\s*(caller|callee)\b/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"eslint/no-caller",message:`Avoid arguments.${G[1]}`,severity:"error"})}return Z}};var s$={meta:{docs:"Disallow lexical declarations in case clauses",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=!1;for(let Q=0;Q<X.length;Q++){let G=X[Q];if(G.match(/\bcase\s+(?:\S.*)?:|default\s*:/))Y=!0,z=!0;else z=!1;if(Y&&!z&&(G.match(/\bbreak\b/)||G.match(/\bcase\s+(?:\S.*)?:/)))Y=!1;if(Y&&!z){if(G.match(/\b(let|const|function|class)\s+/))Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"eslint/no-case-declarations",message:"Unexpected lexical declaration in case block",severity:"error"})}}return Z}};var n$={meta:{docs:"Disallow else blocks after return statements in if statements",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(!/^\s*else\b/.test(z))continue;let Q=!1;for(let G=Y-1;G>=0&&G>=Y-10;G--){let q=X[G].trim();if(q.startsWith("return"))Q=!0;if(q==="}"&&Q)break;if(q.includes("{"))break}if(Q)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf("else")+1),ruleId:"eslint/no-else-return",message:"Unnecessary else after return",severity:"warning"})}return Z}};var i$={meta:{docs:"Disallow empty block statements",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\{\s*\}/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let q=z.substring(0,G.index).trim(),U=/(?:if|else|for|while|do|try|catch|finally|function|\})\s*$/.test(q),W=/[=:]$/.test(q)||/return\s*$/.test(q);if(U&&!W)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-empty",message:"Empty block statement",severity:"error"})}}for(let Y=0;Y<X.length-1;Y++){let z=X[Y],Q=X[Y+1];if(/\{\s*$/.test(z.trim()))for(let G=Y+1;G<X.length;G++){let q=X[G].trim();if(q==="")continue;if(q==="}"||q.startsWith("}")){let U=z.substring(0,z.lastIndexOf("{")).trim(),W=/(?:if|else|for|while|do|try|catch|finally|function|\})\s*$/.test(U),K=/[=:]$/.test(U)||/return\s*$/.test(U);if(W&&!K)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.lastIndexOf("{")+1),ruleId:"eslint/no-empty",message:"Empty block statement",severity:"error"})}break}}return Z}};var t$={meta:{docs:"Disallow empty functions",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=[/function\s+\w+\s*\([^)]*\)\s*\{\s*\}/g,/function\s*\([^)]*\)\s*\{\s*\}/g,/\([^)]*\)\s*=>\s*\{\s*\}/g,/\w+\s*\([^)]*\)\s*\{\s*\}/g];for(let G of Q){let q;for(q=G.exec(z);q!==null;q=G.exec(z)){if(z.substring(0,q.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-empty-function",message:"Unexpected empty function",severity:"warning"})}}}return Z}};var e$={meta:{docs:"Disallow use of eval()",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\beval\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-eval",message:"eval can be harmful",severity:"error"})}}return Z}};var dQ=["Object","Array","String","Number","Boolean","Date","RegExp","Function","Math","JSON","Promise","Map","Set","WeakMap","WeakSet","Symbol","Proxy","Reflect","Error","TypeError","RangeError"],$8={meta:{docs:"Disallow extending native types",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];for(let Q of dQ){let G=new RegExp(`\\b${Q}\\.prototype\\.\\w+\\s*=`,"g"),q;for(q=G.exec(z);q!==null;q=G.exec(z)){if(z.substring(0,q.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-extend-native",message:`${Q} prototype is read only, properties should not be added`,severity:"error"})}}}return Z}};var Z8={meta:{docs:"Disallow unnecessary boolean casts",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=[/\bif\s*\(\s*Boolean\s*\(/g,/\bwhile\s*\(\s*Boolean\s*\(/g,/!\s*Boolean\s*\(/g,/\?\s*Boolean\s*\(/g,/&&\s*Boolean\s*\(/g,/\|\|\s*Boolean\s*\(/g,/!!\s*\w+/g];for(let G of Q){let q;for(q=G.exec(z);q!==null;q=G.exec(z)){if(z.substring(0,q.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-extra-boolean-cast",message:"Redundant Boolean call or double negation",severity:"error"})}}}return Z},fix:($)=>{let J=$;return J=J.replace(/\b(if|while)\s*\(\s*Boolean\s*\(([^)]+)\)\s*\)/g,"$1 ($2)"),J=J.replace(/!\s*Boolean\s*\(([^)]+)\)/g,"!$1"),J=J.replace(/!!\s*(\w+)/g,"$1"),J}};var oQ=["Array","Boolean","Date","Error","Function","JSON","Math","Number","Object","RegExp","String","Symbol","undefined","NaN","Infinity","isNaN","isFinite","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","eval","Promise","Proxy","Reflect","Set","Map","WeakSet","WeakMap","ArrayBuffer","DataView","console","window","document","globalThis","global","process"],J8={meta:{docs:"Disallow assignment to native objects or read-only global variables",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];for(let Q of oQ){let G=new RegExp(`\\b${Q}\\s*=\\s*[^=]`,"g"),q;for(q=G.exec(z);q!==null;q=G.exec(z))if(!z.slice(q.index).match(new RegExp(`^${Q}\\s*===?`)))Z.push({filePath:J.filePath,line:Y+1,column:q.index+1,ruleId:"eslint/no-global-assign",message:`Read-only global '${Q}' should not be modified`,severity:"error"})}}return Z}};var X8={meta:{docs:"Disallow implied eval() via setTimeout/setInterval with strings",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\b(setTimeout|setInterval)\s*\(\s*(['"`])/g,G;while((G=Q.exec(z))!==null){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-implied-eval",message:"Implied eval. Consider passing a function instead of a string",severity:"error"})}}return Z}};var Y8={meta:{docs:"Disallow the use of the __iterator__ property",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/__iterator__/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-iterator",message:"Reserved name '__iterator__'",severity:"error"})}}return Z}};var y1={meta:{docs:"Disallow if statements as the only statement in else blocks",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(/^\s*else\s*(?:\{\s*)?$/.test(z)){let G=Y,q=z.includes("{");if(!q){if(Y+1<X.length&&X[Y+1].trim()==="{")G=Y+1,q=!0}if(q)for(let U=G+1;U<X.length;U++){let W=X[U].trim();if(W===""||W.startsWith("//")||W.startsWith("/*"))continue;if(W==="}")break;if(W.startsWith("if ")||W.startsWith("if(")){let K=!0,H=0,V=!1;for(let A=U;A<X.length;A++){let _=X[A];if(H+=(_.match(/\{/g)||[]).length,H-=(_.match(/\}/g)||[]).length,A===U){V=!0;continue}if(H===0){for(let F=A+1;F<X.length;F++){let B=X[F].trim();if(B===""||B.startsWith("//"))continue;if(B==="}"||B.startsWith("}"))break;else K=!1;break}break}}if(V&&K)Z.push({filePath:J.filePath,line:U+1,column:Math.max(1,X[U].indexOf("if")+1),ruleId:"eslint/no-lonely-if",message:"Unexpected if as the only statement in an else block",severity:"warning"})}break}}}return Z},fix:($,J)=>{if(y1.check($,J).length===0)return $;return $}};var z8={meta:{docs:"Disallow new operators outside of assignments or comparisons",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(/^\s*new\s+\w+\s*\(/.test(z)){if(!/[=:]/.test(z.substring(0,z.indexOf("new"))))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf("new")+1),ruleId:"eslint/no-new",message:"Do not use 'new' for side effects",severity:"warning"})}}return Z}};var Q8={meta:{docs:"Disallow new Function() declarations",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\bnew\s+Function\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-new-func",message:"The Function constructor is eval",severity:"error"})}}return Z}};var G8={meta:{docs:"Disallow new operators with String, Number, and Boolean",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\bnew\s+(String|Number|Boolean)\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-new-wrappers",message:`Do not use ${G[1]} as a constructor`,severity:"error"})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=!1,X=J.map((Y)=>{if(Y.trim().startsWith("//")||Y.trim().startsWith("/*"))return Y;return Y.replace(/\bnew\s+(String|Number|Boolean)\s*\(/g,(Q,G)=>{return Z=!0,`${G}(`})});return Z?X.join(`
54
54
  `):$}};var q8={meta:{docs:"Disallow octal literals",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\b0[0-7]+\b/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"eslint/no-octal",message:"Octal literals should not be used",severity:"error"})}return Z}};var U8={meta:{docs:"Disallow reassignment of function parameters",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=new Map;for(let z=0;z<X.length;z++){let Q=X[z],G=[...Q.matchAll(/function\s+(?:(\w+)\s*)?\(([^)]*)\)/g),...Q.matchAll(/(?:const|let|var)?\s*(\w+)\s*=\s*\(([^)]*)\)\s*=>/g),...Q.matchAll(/(?:const|let|var)?\s*(\w+)\s*=\s*(\w+)\s*=>/g)];for(let q of G){let U=q[2]?q[2].split(",").map((K)=>K.trim().split(/[=:]/)[0].trim()):[],W=`line-${z}`;if(U.length>0)Y.set(W,new Set(U.filter((K)=>K&&/^\w+$/.test(K))))}for(let[q,U]of Y.entries())for(let W of U){let K=new RegExp(`\\b${W}\\s*=\\s*[^=]`,"g"),H;for(H=K.exec(Q);H!==null;H=K.exec(Q))if(!Q.slice(H.index).match(/^\w+\s*===?/))Z.push({filePath:J.filePath,line:z+1,column:H.index+1,ruleId:"eslint/no-param-reassign",message:`Assignment to function parameter '${W}'`,severity:"error"})}}return Z}};var W8={meta:{docs:"Disallow use of __proto__",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/__proto__/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-proto",message:"The '__proto__' property is deprecated",severity:"error"})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=!1,X=J.map((Y)=>{if(Y.trim().startsWith("//")||Y.trim().startsWith("/*"))return Y;return Y.replace(/(\w+)\.__proto__/g,(Q,G)=>{return Z=!0,`Object.getPrototypeOf(${G})`})});return Z?X.join(`
55
- `):$}};var K8={meta:{docs:"Disallow assignment operators in return statements",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\breturn\s[^;]*\b\w+\s*=\s*(?!=)/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let q=G[0];if(/===|==/.test(q))continue;if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-return-assign",message:"Return statement should not contain assignment",severity:"error"})}}return Z}};var H8={meta:{docs:"Disallow comma operators",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\)\s*,\s*\w+\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+G[0].indexOf(",")+1),ruleId:"eslint/no-sequences",message:"Unexpected use of comma operator",severity:"warning"})}}return Z}};var V8={meta:{docs:"Disallow variable declarations from shadowing variables declared in the outer scope",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=[new Set];for(let Q=0;Q<X.length;Q++){let G=X[Q];if(G.match(/\bfunction\s+\w+\s*\(|=>\s*\{|\{\s*$/))z.push(new Set);let q=[...G.matchAll(/\b(const|let|var)\s+(\w+)/g),...G.matchAll(/function\s+(\w+)\s*\(/g)];for(let U of q){let W=U[2]||U[1];for(let K=0;K<z.length-1;K++)if(z[K].has(W)){Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"eslint/no-shadow",message:`'${W}' is already declared in the upper scope`,severity:"error"});break}z[z.length-1].add(W)}if(G.match(/^\s*\}\s*$/)){if(z.length>1)z.pop()}}return Z}};var A8={meta:{docs:"Disallow throwing literals as exceptions",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=[{pattern:/\bthrow\s+(['"`][^'"`]*['"`])/g,type:"string"},{pattern:/\bthrow\s+(\d+)/g,type:"number"},{pattern:/\bthrow\s+(true|false|null|undefined)/g,type:"literal"}];for(let{pattern:G,type:q}of Q){let U;while((U=G.exec(z))!==null){if(z.substring(0,U.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,U.index+1),ruleId:"eslint/no-throw-literal",message:`Expected an error object to be thrown, got ${q} literal`,severity:"error"})}}}return Z}};var _8={meta:{docs:"Disallow the use of variables before they are defined",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=new Map;for(let z=0;z<X.length;z++){let Q=X[z],G=[...Q.matchAll(/\b(const|let|var)\s+(\w+)/g),...Q.matchAll(/\bfunction\s+(\w+)\s*\(/g),...Q.matchAll(/\bclass\s+(\w+)/g)];for(let q of G){let U=q[2]||q[1];if(!Y.has(U))Y.set(U,z+1)}}for(let z=0;z<X.length;z++){let Q=X[z];if(Q.match(/\b(const|let|var|function|class)\s+\w+/))continue;let G=Q.matchAll(/\b(\w+)\b/g);for(let q of G){let U=q[1],W=Y.get(U);if(W&&W>z+1)Z.push({filePath:J.filePath,line:z+1,column:q.index+1,ruleId:"eslint/no-use-before-define",message:`'${U}' was used before it was defined`,severity:"error"})}}return Z}};var F8={meta:{docs:"Disallow unnecessary .call() and .apply()",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\.\s*call\s*\(\s*(undefined|null)\s*,/g,G=/\.\s*apply\s*\(\s*(undefined|null)\s*,/g,q;for(q=Q.exec(z);q!==null;q=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:q.index+1,ruleId:"eslint/no-useless-call",message:"Unnecessary '.call()'",severity:"error"});for(q=G.exec(z);q!==null;q=G.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:q.index+1,ruleId:"eslint/no-useless-call",message:"Unnecessary '.apply()'",severity:"error"})}return Z}};var B8={meta:{docs:"Disallow unnecessary concatenation of literals or template literals",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=[/(['"`])([^'"`]*)\1\s*\+\s*\1([^'"`]*)\1/g];for(let G of Q){let q;while((q=G.exec(z))!==null){if(z.substring(0,q.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-useless-concat",message:"Unexpected string concatenation of literals",severity:"warning"})}}}return Z},fix:($)=>{let J=$;return J=J.replace(/(['"`])([^'"`]*)\1\s*\+\s*\1([^'"`]*)\1/g,"$1$2$3$1"),J}};var NZ=["/","(",")","[","]","{","}","<",">",":","@","#","$","%","&","=","+","-","*","?","!",";",",","|","~","`","^"],w8={meta:{docs:"Disallow unnecessary escape characters",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];for(let Q of NZ){let G=`\\${Q}`,q=new RegExp(`(['"\`])[^'"\`]*${G.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}`,"g"),U;while((U=q.exec(z))!==null){let W=U.index,K=z.indexOf(G,W);if(K>W)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,K+1),ruleId:"eslint/no-useless-escape",message:`Unnecessary escape character: \\${Q}`,severity:"warning"})}}}return Z},fix:($)=>{let J=$;for(let Z of NZ){let X=`\\${Z}`;J=J.replace(new RegExp(X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),Z)}return J}};var M8={meta:{docs:"Disallow renaming import, export, and destructured assignments to the same name",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/import\s*\{[^}]*\b(\w+)\s+as\s+\1\b[^}]*\}/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-useless-rename",message:`Renaming import '${G[1]}' to '${G[1]}' is redundant`,severity:"error"});let q=/export\s*\{[^}]*\b(\w+)\s+as\s+\1\b[^}]*\}/g;for(G=q.exec(z);G!==null;G=q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-useless-rename",message:`Renaming export '${G[1]}' to '${G[1]}' is redundant`,severity:"error"});let U=/\{[^}]*\b(\w+)\s*:\s*\1\b[^}]*\}\s*=/g;for(G=U.exec(z);G!==null;G=U.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-useless-rename",message:`Renaming destructured property '${G[1]}' to '${G[1]}' is redundant`,severity:"error"})}return Z},fix:($)=>{let J=$;return J=J.replace(/\b(\w+)\s+as\s+\1\b/g,"$1"),J=J.replace(/\{([^}]*)\b(\w+)\s*:\s*\2\b([^}]*)\}/g,"{$1$2$3}"),J}};var y1={meta:{docs:"Disallow redundant return statements",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(Q==="return"||Q==="return;"){let G=!1;for(let q=Y+1;q<X.length;q++){let U=X[q].trim();if(U===""||U.startsWith("//")||U.startsWith("/*"))continue;if(U==="}"||U.startsWith("}"))G=!0;break}if(G)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf("return")+1),ruleId:"eslint/no-useless-return",message:"Unnecessary return statement",severity:"warning"})}}return Z},fix:($,J)=>{let Z=y1.check($,J);if(Z.length===0)return $;let X=$.split(/\r?\n/),Y=new Set(Z.map((Q)=>Q.line-1));return X.filter((Q,G)=>!Y.has(G)).join(`
55
+ `):$}};var K8={meta:{docs:"Disallow assignment operators in return statements",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\breturn\s[^;]*\b\w+\s*=\s*(?!=)/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let q=G[0];if(/===|==/.test(q))continue;if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-return-assign",message:"Return statement should not contain assignment",severity:"error"})}}return Z}};var H8={meta:{docs:"Disallow comma operators",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\)\s*,\s*\w+\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+G[0].indexOf(",")+1),ruleId:"eslint/no-sequences",message:"Unexpected use of comma operator",severity:"warning"})}}return Z}};var V8={meta:{docs:"Disallow variable declarations from shadowing variables declared in the outer scope",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=[new Set];for(let Q=0;Q<X.length;Q++){let G=X[Q];if(G.match(/\bfunction\s+\w+\s*\(|=>\s*\{|\{\s*$/))z.push(new Set);let q=[...G.matchAll(/\b(const|let|var)\s+(\w+)/g),...G.matchAll(/function\s+(\w+)\s*\(/g)];for(let U of q){let W=U[2]||U[1];for(let K=0;K<z.length-1;K++)if(z[K].has(W)){Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"eslint/no-shadow",message:`'${W}' is already declared in the upper scope`,severity:"error"});break}z[z.length-1].add(W)}if(G.match(/^\s*\}\s*$/)){if(z.length>1)z.pop()}}return Z}};var A8={meta:{docs:"Disallow throwing literals as exceptions",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=[{pattern:/\bthrow\s+(['"`][^'"`]*['"`])/g,type:"string"},{pattern:/\bthrow\s+(\d+)/g,type:"number"},{pattern:/\bthrow\s+(true|false|null|undefined)/g,type:"literal"}];for(let{pattern:G,type:q}of Q){let U;while((U=G.exec(z))!==null){if(z.substring(0,U.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,U.index+1),ruleId:"eslint/no-throw-literal",message:`Expected an error object to be thrown, got ${q} literal`,severity:"error"})}}}return Z}};var _8={meta:{docs:"Disallow the use of variables before they are defined",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=new Map;for(let z=0;z<X.length;z++){let Q=X[z],G=[...Q.matchAll(/\b(const|let|var)\s+(\w+)/g),...Q.matchAll(/\bfunction\s+(\w+)\s*\(/g),...Q.matchAll(/\bclass\s+(\w+)/g)];for(let q of G){let U=q[2]||q[1];if(!Y.has(U))Y.set(U,z+1)}}for(let z=0;z<X.length;z++){let Q=X[z];if(Q.match(/\b(const|let|var|function|class)\s+\w+/))continue;let G=Q.matchAll(/\b(\w+)\b/g);for(let q of G){let U=q[1],W=Y.get(U);if(W&&W>z+1)Z.push({filePath:J.filePath,line:z+1,column:q.index+1,ruleId:"eslint/no-use-before-define",message:`'${U}' was used before it was defined`,severity:"error"})}}return Z}};var F8={meta:{docs:"Disallow unnecessary .call() and .apply()",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\.\s*call\s*\(\s*(undefined|null)\s*,/g,G=/\.\s*apply\s*\(\s*(undefined|null)\s*,/g,q;for(q=Q.exec(z);q!==null;q=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:q.index+1,ruleId:"eslint/no-useless-call",message:"Unnecessary '.call()'",severity:"error"});for(q=G.exec(z);q!==null;q=G.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:q.index+1,ruleId:"eslint/no-useless-call",message:"Unnecessary '.apply()'",severity:"error"})}return Z}};var B8={meta:{docs:"Disallow unnecessary concatenation of literals or template literals",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=[/(['"`])([^'"`]*)\1\s*\+\s*\1([^'"`]*)\1/g];for(let G of Q){let q;while((q=G.exec(z))!==null){if(z.substring(0,q.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,q.index+1),ruleId:"eslint/no-useless-concat",message:"Unexpected string concatenation of literals",severity:"warning"})}}}return Z},fix:($)=>{let J=$;return J=J.replace(/(['"`])([^'"`]*)\1\s*\+\s*\1([^'"`]*)\1/g,"$1$2$3$1"),J}};var NZ=["/","(",")","[","]","{","}","<",">",":","@","#","$","%","&","=","+","-","*","?","!",";",",","|","~","`","^"],w8={meta:{docs:"Disallow unnecessary escape characters",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];for(let Q of NZ){let G=`\\${Q}`,q=new RegExp(`(['"\`])[^'"\`]*${G.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}`,"g"),U;while((U=q.exec(z))!==null){let W=U.index,K=z.indexOf(G,W);if(K>W)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,K+1),ruleId:"eslint/no-useless-escape",message:`Unnecessary escape character: \\${Q}`,severity:"warning"})}}}return Z},fix:($)=>{let J=$;for(let Z of NZ){let X=`\\${Z}`;J=J.replace(new RegExp(X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),Z)}return J}};var M8={meta:{docs:"Disallow renaming import, export, and destructured assignments to the same name",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/import\s*\{[^}]*\b(\w+)\s+as\s+\1\b[^}]*\}/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-useless-rename",message:`Renaming import '${G[1]}' to '${G[1]}' is redundant`,severity:"error"});let q=/export\s*\{[^}]*\b(\w+)\s+as\s+\1\b[^}]*\}/g;for(G=q.exec(z);G!==null;G=q.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-useless-rename",message:`Renaming export '${G[1]}' to '${G[1]}' is redundant`,severity:"error"});let U=/\{[^}]*\b(\w+)\s*:\s*\1\b[^}]*\}\s*=/g;for(G=U.exec(z);G!==null;G=U.exec(z))Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-useless-rename",message:`Renaming destructured property '${G[1]}' to '${G[1]}' is redundant`,severity:"error"})}return Z},fix:($)=>{let J=$;return J=J.replace(/\b(\w+)\s+as\s+\1\b/g,"$1"),J=J.replace(/\{([^}]*)\b(\w+)\s*:\s*\2\b([^}]*)\}/g,"{$1$2$3}"),J}};var b1={meta:{docs:"Disallow redundant return statements",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(Q==="return"||Q==="return;"){let G=!1;for(let q=Y+1;q<X.length;q++){let U=X[q].trim();if(U===""||U.startsWith("//")||U.startsWith("/*"))continue;if(U==="}"||U.startsWith("}"))G=!0;break}if(G)Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf("return")+1),ruleId:"eslint/no-useless-return",message:"Unnecessary return statement",severity:"warning"})}}return Z},fix:($,J)=>{let Z=b1.check($,J);if(Z.length===0)return $;let X=$.split(/\r?\n/),Y=new Set(Z.map((Q)=>Q.line-1));return X.filter((Q,G)=>!Y.has(G)).join(`
56
56
  `)}};var j8={meta:{docs:"Require let or const instead of var",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\bvar\s+/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-var",message:"Unexpected var, use let or const instead",severity:"error"})}}return Z},fix:($,J)=>{return $.split(/\r?\n/).map((Y)=>{if(Y.trim().startsWith("//")||Y.trim().startsWith("/*"))return Y;return Y.replace(/\bvar\s+/g,"let ")}).join(`
57
- `)}};var N8={meta:{docs:"Disallow with statements",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\bwith\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-with",message:"Unexpected use of 'with' statement",severity:"error"})}}return Z}};var T8={meta:{docs:"Require using arrow functions for callbacks",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\.(map|filter|reduce|forEach|some|every|find|findIndex)\s*\(\s*function\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/prefer-arrow-callback",message:"Unexpected function expression, use arrow function instead",severity:"warning"})}}return Z}};var E8={meta:{docs:"Disallow async functions which have no await expression",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++)if(X[Y].match(/\basync\s+(?:function\s+\w+|(?:\(|\w+)\s*(?:\(|=>))/)){let G=!1,q=0,U=!1,W=Y;while(W<X.length){let K=X[W];for(let H of K){if(H==="{")q++,U=!0;if(H==="}"){if(q--,q===0&&U)break}}if(K.match(/\bawait\s+/))G=!0;if(q===0&&U){if(!G)Z.push({filePath:J.filePath,line:Y+1,column:1,ruleId:"eslint/require-await",message:"Async function has no await expression",severity:"error"});break}W++}}return Z}};var TZ=/\.(?:ts|js|tsx|jsx|mts|mjs|cts|cjs)$/;function w($){return{meta:$.meta,check:(J,Z)=>{if(!TZ.test(Z.filePath))return[];return $.check(J,Z)},fix:$.fix?(J,Z)=>{if(!TZ.test(Z.filePath))return J;return $.fix(J,Z)}:void 0}}var EZ=/\.(?:sh|bash|zsh|ksh|dash)$/,DZ=/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/;function V0($){return{meta:$.meta,check:(J,Z)=>{if(!EZ.test(Z.filePath)&&!DZ.test(J))return[];return $.check(J,Z)},fix:$.fix?(J,Z)=>{if(!EZ.test(Z.filePath)&&!DZ.test(J))return J;return $.fix(J,Z)}:void 0}}var RZ=/(?:^|[/\\])package\.json$/;function A0($){return{meta:$.meta,check:(J,Z)=>{if(!RZ.test(Z.filePath))return[];return $.check(J,Z)},fix:$.fix?(J,Z)=>{if(!RZ.test(Z.filePath))return J;return $.fix(J,Z)}:void 0}}var OZ={name:"eslint",rules:{"array-callback-return":w(B$),"constructor-super":w(w$),"for-direction":w(M$),"getter-return":w(j$),"no-async-promise-executor":w(N$),"no-compare-neg-zero":w(T$),"no-cond-assign":w(E$),"no-constant-condition":w(R$),"no-const-assign":w(D$),"no-dupe-class-members":w(O$),"no-dupe-keys":w(I1),"no-duplicate-case":w(L$),"no-empty-pattern":w(P$),"no-fallthrough":w(C$),"no-loss-of-precision":w(I$),"no-promise-executor-return":w(S$),"no-redeclare":w(v$),"no-self-assign":w(S1),"no-self-compare":w(y$),"no-sparse-arrays":w(b$),"no-undef":w(k$),"no-unsafe-negation":w(g$),"no-unreachable":w(f$),"no-useless-catch":w(x$),"use-isnan":w(p$),"valid-typeof":w(h$),"default-case":w(m$),eqeqeq:w(d$),"no-alert":w(r$),"no-await-in-loop":w(l$),"no-caller":w(a$),"no-case-declarations":w(s$),"no-else-return":w(n$),"no-empty":w(i$),"no-empty-function":w(t$),"no-eval":w(e$),"no-extend-native":w($8),"no-global-assign":w(J8),"no-implied-eval":w(X8),"no-iterator":w(Y8),"no-new":w(z8),"no-new-func":w(Q8),"no-new-wrappers":w(G8),"no-octal":w(q8),"no-param-reassign":w(U8),"no-proto":w(W8),"no-return-assign":w(K8),"no-shadow":w(V8),"no-throw-literal":w(A8),"no-use-before-define":w(_8),"no-useless-call":w(F8),"no-with":w(N8),"require-await":w(E8),complexity:w(u$),"max-depth":w(o$),"max-lines-per-function":w(c$),"no-extra-boolean-cast":w(Z8),"no-lonely-if":w(v1),"no-sequences":w(H8),"no-useless-concat":w(B8),"no-useless-escape":w(w8),"no-useless-rename":w(M8),"no-useless-return":w(y1),"no-var":w(j8),"prefer-arrow-callback":w(T8)}};var LZ={meta:{docs:"Disallow return statements in constructors - constructors automatically return the instance"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.indexOf("//");if(!(Q>=0?z.slice(0,Q):z).match(/\bconstructor\s*\(/))continue;let U=0,W=!1,K=-1;for(let H=Y;H<X.length;H++){let V=X[H],A=null,_=!1;for(let F=0;F<V.length;F++){let B=V[F];if(_){_=!1;continue}if(B==="\\"&&A){_=!0;continue}if(!A){if(B==="'")A="single";else if(B==='"')A="double";else if(B==="`")A="template";else if(B==="{")U++,W=!0;else if(B==="}"){if(U--,W&&U===0){K=H;break}}}else if(A==="single"&&B==="'"||A==="double"&&B==='"'||A==="template"&&B==="`")A=null}if(K!==-1)break}if(K===-1)continue;for(let H=Y;H<=K;H++){let V=X[H];if(H===Y)continue;if(/^\s*\/\//.test(V))continue;let A=V.indexOf("//"),_=A>=0?V.slice(0,A):V;if(_=_.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""'),_.match(/\breturn\b/)){let B=_.indexOf("return"),j=B>0?_[B-1]:" ",D=B+6<_.length?_[B+6]:" ";if(/\w/.test(j)||/\w/.test(D))continue;let M=_.slice(B+6).trim();if(M.startsWith("this;")||M==="this")continue;if(M===";"||M==="")continue;let E=V.indexOf("return");Z.push({filePath:J.filePath,line:H+1,column:E+1||1,ruleId:"no-constructor-return",message:"Unexpected return statement in constructor. Constructors should not return values.",severity:"error",help:"Remove the return statement or move the logic outside of the constructor"})}}}return Z}};var PZ={meta:{docs:"Disallow irregular whitespace characters that may cause issues in code"},check:($,J)=>{let Z=[],X=/[\u00A0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/g,Y=$.split(/\r?\n/);for(let z=0;z<Y.length;z++){let Q=Y[z],G;X.lastIndex=0;while((G=X.exec(Q))!==null){let U=G[0].charCodeAt(0),W="irregular whitespace",K={160:"NO-BREAK SPACE",5760:"OGHAM SPACE MARK",6158:"MONGOLIAN VOWEL SEPARATOR",8192:"EN QUAD",8193:"EM QUAD",8194:"EN SPACE",8195:"EM SPACE",8196:"THREE-PER-EM SPACE",8197:"FOUR-PER-EM SPACE",8198:"SIX-PER-EM SPACE",8199:"FIGURE SPACE",8200:"PUNCTUATION SPACE",8201:"THIN SPACE",8202:"HAIR SPACE",8232:"LINE SEPARATOR",8233:"PARAGRAPH SEPARATOR",8239:"NARROW NO-BREAK SPACE",8287:"MEDIUM MATHEMATICAL SPACE",12288:"IDEOGRAPHIC SPACE",65279:"ZERO WIDTH NO-BREAK SPACE"};if(K[U])W=K[U];Z.push({filePath:J.filePath,line:z+1,column:G.index+1,ruleId:"no-irregular-whitespace",message:`Irregular whitespace detected: ${W} (U+${U.toString(16).toUpperCase().padStart(4,"0")})`,severity:"error",help:"Replace irregular whitespace with regular spaces or tabs"})}}return Z},fix:($)=>{return $.replace(/[\u00A0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/g," ")}};var CZ={meta:{docs:"Disallow new operators outside of assignments or comparisons",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(Q.startsWith("//")||Q.startsWith("/*")||Q.startsWith("*"))continue;if(/^\s*new\s+\w+/.test(z)){let q=/^\s*(?:const|let|var|this\.\w+)\s*=\s*new\s+/,U=/^\s*return\s+new\s+/,W=new RegExp("^\\s*new\\s+\\w[^;]*,"),K=/[=:,(]\s*new\s+/;if(!q.test(z)&&!U.test(z)&&!W.test(z)&&!K.test(Q)){let H=z.search(/new\s+/)+1;Z.push({filePath:J.filePath,line:Y+1,column:H,ruleId:"no-new",message:"Do not use 'new' for side effects",severity:"error",help:"Either assign the result to a variable or remove the 'new' operator if the side effect is intentional."})}}}return Z}};var IZ={meta:{docs:"Disallow multiple spaces in regular expressions",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(/^\s*\/\//.test(z))continue;let Q=/\/(?![*/])((?:\\.|[^/\\])+)\/[gimsuvy]*/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let U=G[1];if(/ {2,}/.test(U)){let W=G.index+1;Z.push({filePath:J.filePath,line:Y+1,column:W,ruleId:"no-regex-spaces",message:"Multiple spaces in regular expression",severity:"error",help:"Use quantifiers like {2} instead of multiple spaces for clarity."})}}let q=/new\s+RegExp\s*\(\s*['"`]([^'"`]+)['"`]/g;for(G=q.exec(z);G!==null;G=q.exec(z)){let U=G[1];if(/ {2,}/.test(U)){let W=G.index+1;Z.push({filePath:J.filePath,line:Y+1,column:W,ruleId:"no-regex-spaces",message:"Multiple spaces in regular expression",severity:"error",help:"Use quantifiers like {2} instead of multiple spaces for clarity."})}}}return Z}};var i0={meta:{docs:"Report variables and parameters that are declared/assigned but never used"},check:($,J)=>{if(J.filePath.endsWith("/no-unused-vars.ts"))return[];if(J.filePath.endsWith(".d.ts"))return[];let Z=[],X=J.options||{},Y=typeof X.varsIgnorePattern==="string"?X.varsIgnorePattern:"^_",z=typeof X.argsIgnorePattern==="string"?X.argsIgnorePattern:"^_",Q=new RegExp(Y,"u"),G=new RegExp(z,"u"),q=$.split(/\r?\n/),U=$,W=Array(q.length).fill(!1);(()=>{let M=[],E=!1,R=!1,S=!1,f=!1,O=!1,h="",P=()=>{if(h==="")return!0;if("=([{,;!&|?:+-*/%^~<>".includes(h))return!0;return!1};for(let C=0;C<q.length;C++){W[C]=M.length>0&&M[M.length-1]===-1;let I=q[C];for(let L=0;L<I.length;L++){let T=I[L];if(f){if(T==="*"&&L+1<I.length&&I[L+1]==="/")f=!1,L++;continue}if(O){O=!1;continue}let k=M.length>0&&M[M.length-1]===-1,N=M.length>0&&M[M.length-1]>=0;if(T==="\\"&&(E||R||S||k)){O=!0;continue}if(E){if(T==="'")E=!1;continue}if(R){if(T==='"')R=!1;continue}if(S){if(T==="["){let v=1,g=L+1;while(g<I.length){let x=I[g];if(x==="\\"){g+=2;continue}if(x==="]"){if(v--,v===0)break}g++}L=g;continue}if(T==="/"){S=!1;while(L+1<I.length&&/[gimsuvy]/.test(I[L+1]))L++}continue}if(k){if(T==="`")M.pop();else if(T==="$"&&L+1<I.length&&I[L+1]==="{")M.push(0),L++;continue}if(T==="/"&&L+1<I.length&&I[L+1]==="/")break;if(T==="/"&&L+1<I.length&&I[L+1]==="*"){f=!0,L++;continue}if(N){if(T==="`")M.push(-1),h="";else if(T==="'")E=!0,h="'";else if(T==='"')R=!0,h='"';else if(T==="{")M[M.length-1]++,h="{";else if(T==="}"){let v=M[M.length-1];if(v>0)M[M.length-1]=v-1;else M.pop();h="}"}else if(T==="/"&&P())S=!0;else if(!/\s/.test(T))h=T;continue}if(T==="`")M.push(-1),h="";else if(T==="'")E=!0,h="'";else if(T==='"')R=!0,h='"';else if(T==="/"&&P())S=!0;else if(!/\s/.test(T))h=T}}})();let H=new RegExp("^\\s*(?:const|let|var)\\s+(.+?);?\\s*$");for(let M=0;M<q.length;M++){if(W[M])continue;let E=q[M],R=E.match(H);if(!R)continue;let S=R[1],f=[],O="",h=0,P=0,C=null,I=!1;for(let L=0;L<S.length;L++){let T=S[L];if(I){I=!1,O+=T;continue}if(T==="\\"&&C){I=!0,O+=T;continue}if(!C){if(T==="/"&&S[L+1]==="/")break;if(T==="/"&&S[L+1]==="*"){L+=2;while(L<S.length&&!(S[L]==="*"&&S[L+1]==="/"))L++;L++;continue}if(T==="'")C="single";else if(T==='"')C="double";else if(T==="`")C="template";else if(T==="<")P++;else if(T===">")P--;else if(T==="("||T==="["||T==="{")h++;else if(T===")"||T==="]"||T==="}")h--;else if(T===","&&h===0&&P===0){f.push(O),O="";continue}}else if(C==="single"&&T==="'"||C==="double"&&T==='"'||C==="template"&&T==="`")C=null;O+=T}if(O)f.push(O);for(let L of f){let T=L.trim();if(!T)continue;let k=T.match(/^([$A-Z_][\w$]*)/i),N=[];if(k)N.push(k[1]);else if(T.startsWith("{")||T.startsWith("[")){let v=T[0],g=v==="{"?"}":"]",x=0,u=-1,d=null,p=!1;for(let y=0;y<T.length;y++){let b=T[y];if(p){p=!1;continue}if(b==="\\"&&d){p=!0;continue}if(!d){if(b==="'"||b==='"'||b==="`")d=b==="'"?"single":b==='"'?"double":"template";else if(b===v)x++;else if(b===g){if(x--,x===0){u=y;break}}}else if(d==="single"&&b==="'"||d==="double"&&b==='"'||d==="template"&&b==="`")d=null}if(u>0){let y=T.slice(1,u),b=[],a="",W0=0,c=null,s=!1;for(let r=0;r<y.length;r++){let o=y[r];if(s){s=!1,a+=o;continue}if(o==="\\"&&c){s=!0,a+=o;continue}if(!c){if(o==="'"||o==='"'||o==="`"){c=o==="'"?"single":o==='"'?"double":"template",a+=o;continue}if(o==="("||o==="{"||o==="[")W0++;if(o===")"||o==="}"||o==="]")W0--;if(o===","&&W0===0){b.push(a.trim()),a="";continue}}else if(c==="single"&&o==="'"||c==="double"&&o==='"'||c==="template"&&o==="`")c=null;a+=o}if(a.trim())b.push(a.trim());for(let r of b){if(r.startsWith("...")){let K0=r.slice(3).match(/^([$A-Z_][\w$]*)/i);if(K0)N.push(K0[1]);continue}let o=r.indexOf(":");if(o!==-1){let K0=r.slice(o+1).trim(),_0=0;for(let y0=0;y0<K0.length;y0++){let D0=K0[y0];if(D0==="("||D0==="{"||D0==="[")_0++;else if(D0===")"||D0==="}"||D0==="]")_0--;else if(D0==="="&&_0===0){K0=K0.slice(0,y0).trim();break}}let u0=K0.match(/^([$A-Z_][\w$]*)/i);if(u0)N.push(u0[1])}else{let K0=r,_0=0;for(let y0=0;y0<K0.length;y0++){let D0=K0[y0];if(D0==="("||D0==="{"||D0==="[")_0++;else if(D0===")"||D0==="}"||D0==="]")_0--;else if(D0==="="&&_0===0){K0=K0.slice(0,y0).trim();break}}let u0=K0.match(/^([$A-Z_][\w$]*)/i);if(u0)N.push(u0[1])}}}}for(let v of N){if(Q.test(v))continue;let g=U.indexOf(E),x=U.slice(g+E.length);if(!new RegExp(`\\b${v}\\b`,"g").test(x))Z.push({filePath:J.filePath,line:M+1,column:Math.max(1,E.indexOf(v)+1),ruleId:"pickier/no-unused-vars",message:`'${v}' is assigned a value but never used. Allowed unused vars must match pattern: ${Y}`,severity:"error",help:`Either use this variable in your code, remove it, or prefix it with an underscore (_${v}) to mark it as intentionally unused`})}}}let V=(M)=>{let R=((O)=>{let h="",P=null,C=!1,I=0;for(let L=0;L<O.length;L++){let T=O[L];if(C){C=!1;continue}if(T==="\\"&&P){C=!0;continue}if(!P){if(T==="'")P="single";else if(T==='"')P="double";else if(T==="`")P="template";else if(T==="("||T==="{"||T==="[")I++;else if(T===")"||T==="}"||T==="]")I--;else if(T==="="&&I===0)return h}else if(P==="single"&&T==="'"||P==="double"&&T==='"'||P==="template"&&T==="`")P=null;h+=T}return h})(M);return((O)=>{let h="",P=0;while(P<O.length){let C=O[P];if(C===":"){P++;while(P<O.length&&/\s/.test(O[P]))P++;let I=0,L=0,T=null,k=!1;while(P<O.length){let N=O[P];if(k){k=!1,P++;continue}if(N==="\\"&&T){k=!0,P++;continue}if(!T){if(N==="'")T="single";else if(N==='"')T="double";else if(N==="`")T="template";else if(N==="<")L++;else if(N===">")L--;else if(N==="("||N==="{"||N==="[")I++;else if(N===")"||N==="}"||N==="]")if(I>0)I--;else break;else if(N===","&&I===0&&L===0)break}else if(T==="single"&&N==="'"||T==="double"&&N==='"'||T==="template"&&N==="`")T=null;P++}continue}h+=C,P++}return h})(R).split(/[^$\w]+/).filter((O)=>O&&O!=="undefined")},A=(M,E)=>{let R=!1,S=0,f=0,O=!1,h=0,P=null,C=!1,I=!0,L="",T=!1,k=!1,N=[],v=!1;for(let g=M;g<q.length;g++){let x=q[g],u=x,d=N.length>0&&N[N.length-1]===-1,p=-1,y=null,b=!1;if(!d)for(let c=0;c<x.length-1;c++){let s=x[c],r=x[c+1];if(b){b=!1;continue}if(s==="\\"&&y){b=!0;continue}if(!y){if(s==="'")y="single";else if(s==='"')y="double";else if(s==="`")y="template";else if(s==="/"&&r==="/"){p=c;break}}else if(y==="single"&&s==="'"||y==="double"&&s==='"'||y==="template"&&s==="`")y=null}if(p>=0)u=x.slice(0,p);let a=(c)=>{let s="",r=0,o=null,K0=!1;while(r<c.length){let _0=c[r];if(K0){K0=!1,s+=_0,r++;continue}if(_0==="\\"&&o){K0=!0,s+=_0,r++;continue}if(!o){if(_0==="'")o="single";else if(_0==='"')o="double";else if(_0==="`")o="template";else if(_0==="/"){let u0=r>0?c.slice(0,r).trimEnd():"",y0=new RegExp("[=([{,:;!&|?]$");if(!u0||y0.test(u0)||u0.endsWith("return")){r++;while(r<c.length){if(c[r]==="\\"){r+=2;continue}if(c[r]==="/"){r++;while(r<c.length&&/[gimsuvy]/.test(c[r]))r++;break}r++}continue}}}else if(o==="single"&&_0==="'"||o==="double"&&_0==='"'||o==="template"&&_0==="`")o=null;s+=_0,r++}return s};if(!d)u=a(u);let W0=0;if(!R){let c=-1,s=I?typeof E==="number"?E:0:0;if(I=!1,s>=u.length){let r=u.indexOf("=>");s=r>=0?r+2:0}for(let r=s;r<u.length;r++){let o=u[r];if(C){C=!1;continue}if(o==="\\"&&P){C=!0;continue}if(!P){if(o!==" "&&o!=="\t"&&o!==`
57
+ `)}};var N8={meta:{docs:"Disallow with statements",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\bwith\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/no-with",message:"Unexpected use of 'with' statement",severity:"error"})}}return Z}};var T8={meta:{docs:"Require using arrow functions for callbacks",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=/\.(map|filter|reduce|forEach|some|every|find|findIndex)\s*\(\s*function\s*\(/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){if(z.substring(0,G.index).includes("//"))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,G.index+1),ruleId:"eslint/prefer-arrow-callback",message:"Unexpected function expression, use arrow function instead",severity:"warning"})}}return Z}};var E8={meta:{docs:"Disallow async functions which have no await expression",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++)if(X[Y].match(/\basync\s+(?:function\s+\w+|(?:\(|\w+)\s*(?:\(|=>))/)){let G=!1,q=0,U=!1,W=Y;while(W<X.length){let K=X[W];for(let H of K){if(H==="{")q++,U=!0;if(H==="}"){if(q--,q===0&&U)break}}if(K.match(/\bawait\s+/))G=!0;if(q===0&&U){if(!G)Z.push({filePath:J.filePath,line:Y+1,column:1,ruleId:"eslint/require-await",message:"Async function has no await expression",severity:"error"});break}W++}}return Z}};var TZ=/\.(?:ts|js|tsx|jsx|mts|mjs|cts|cjs)$/;function w($){return{meta:$.meta,check:(J,Z)=>{if(!TZ.test(Z.filePath))return[];return $.check(J,Z)},fix:$.fix?(J,Z)=>{if(!TZ.test(Z.filePath))return J;return $.fix(J,Z)}:void 0}}var EZ=/\.(?:sh|bash|zsh|ksh|dash)$/,DZ=/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/;function V0($){return{meta:$.meta,check:(J,Z)=>{if(!EZ.test(Z.filePath)&&!DZ.test(J))return[];return $.check(J,Z)},fix:$.fix?(J,Z)=>{if(!EZ.test(Z.filePath)&&!DZ.test(J))return J;return $.fix(J,Z)}:void 0}}var RZ=/(?:^|[/\\])package\.json$/;function A0($){return{meta:$.meta,check:(J,Z)=>{if(!RZ.test(Z.filePath))return[];return $.check(J,Z)},fix:$.fix?(J,Z)=>{if(!RZ.test(Z.filePath))return J;return $.fix(J,Z)}:void 0}}var OZ={name:"eslint",rules:{"array-callback-return":w(B$),"constructor-super":w(w$),"for-direction":w(M$),"getter-return":w(j$),"no-async-promise-executor":w(N$),"no-compare-neg-zero":w(T$),"no-cond-assign":w(E$),"no-constant-condition":w(R$),"no-const-assign":w(D$),"no-dupe-class-members":w(O$),"no-dupe-keys":w(S1),"no-duplicate-case":w(L$),"no-empty-pattern":w(P$),"no-fallthrough":w(C$),"no-loss-of-precision":w(I$),"no-promise-executor-return":w(S$),"no-redeclare":w(v$),"no-self-assign":w(v1),"no-self-compare":w(y$),"no-sparse-arrays":w(b$),"no-undef":w(k$),"no-unsafe-negation":w(g$),"no-unreachable":w(f$),"no-useless-catch":w(x$),"use-isnan":w(p$),"valid-typeof":w(h$),"default-case":w(m$),eqeqeq:w(d$),"no-alert":w(r$),"no-await-in-loop":w(l$),"no-caller":w(a$),"no-case-declarations":w(s$),"no-else-return":w(n$),"no-empty":w(i$),"no-empty-function":w(t$),"no-eval":w(e$),"no-extend-native":w($8),"no-global-assign":w(J8),"no-implied-eval":w(X8),"no-iterator":w(Y8),"no-new":w(z8),"no-new-func":w(Q8),"no-new-wrappers":w(G8),"no-octal":w(q8),"no-param-reassign":w(U8),"no-proto":w(W8),"no-return-assign":w(K8),"no-shadow":w(V8),"no-throw-literal":w(A8),"no-use-before-define":w(_8),"no-useless-call":w(F8),"no-with":w(N8),"require-await":w(E8),complexity:w(u$),"max-depth":w(o$),"max-lines-per-function":w(c$),"no-extra-boolean-cast":w(Z8),"no-lonely-if":w(y1),"no-sequences":w(H8),"no-useless-concat":w(B8),"no-useless-escape":w(w8),"no-useless-rename":w(M8),"no-useless-return":w(b1),"no-var":w(j8),"prefer-arrow-callback":w(T8)}};var LZ={meta:{docs:"Disallow return statements in constructors - constructors automatically return the instance"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.indexOf("//");if(!(Q>=0?z.slice(0,Q):z).match(/\bconstructor\s*\(/))continue;let U=0,W=!1,K=-1;for(let H=Y;H<X.length;H++){let V=X[H],A=null,_=!1;for(let F=0;F<V.length;F++){let B=V[F];if(_){_=!1;continue}if(B==="\\"&&A){_=!0;continue}if(!A){if(B==="'")A="single";else if(B==='"')A="double";else if(B==="`")A="template";else if(B==="{")U++,W=!0;else if(B==="}"){if(U--,W&&U===0){K=H;break}}}else if(A==="single"&&B==="'"||A==="double"&&B==='"'||A==="template"&&B==="`")A=null}if(K!==-1)break}if(K===-1)continue;for(let H=Y;H<=K;H++){let V=X[H];if(H===Y)continue;if(/^\s*\/\//.test(V))continue;let A=V.indexOf("//"),_=A>=0?V.slice(0,A):V;if(_=_.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""'),_.match(/\breturn\b/)){let B=_.indexOf("return"),j=B>0?_[B-1]:" ",D=B+6<_.length?_[B+6]:" ";if(/\w/.test(j)||/\w/.test(D))continue;let M=_.slice(B+6).trim();if(M.startsWith("this;")||M==="this")continue;if(M===";"||M==="")continue;let E=V.indexOf("return");Z.push({filePath:J.filePath,line:H+1,column:E+1||1,ruleId:"no-constructor-return",message:"Unexpected return statement in constructor. Constructors should not return values.",severity:"error",help:"Remove the return statement or move the logic outside of the constructor"})}}}return Z}};var PZ={meta:{docs:"Disallow irregular whitespace characters that may cause issues in code"},check:($,J)=>{let Z=[],X=/[\u00A0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/g,Y=$.split(/\r?\n/);for(let z=0;z<Y.length;z++){let Q=Y[z],G;X.lastIndex=0;while((G=X.exec(Q))!==null){let U=G[0].charCodeAt(0),W="irregular whitespace",K={160:"NO-BREAK SPACE",5760:"OGHAM SPACE MARK",6158:"MONGOLIAN VOWEL SEPARATOR",8192:"EN QUAD",8193:"EM QUAD",8194:"EN SPACE",8195:"EM SPACE",8196:"THREE-PER-EM SPACE",8197:"FOUR-PER-EM SPACE",8198:"SIX-PER-EM SPACE",8199:"FIGURE SPACE",8200:"PUNCTUATION SPACE",8201:"THIN SPACE",8202:"HAIR SPACE",8232:"LINE SEPARATOR",8233:"PARAGRAPH SEPARATOR",8239:"NARROW NO-BREAK SPACE",8287:"MEDIUM MATHEMATICAL SPACE",12288:"IDEOGRAPHIC SPACE",65279:"ZERO WIDTH NO-BREAK SPACE"};if(K[U])W=K[U];Z.push({filePath:J.filePath,line:z+1,column:G.index+1,ruleId:"no-irregular-whitespace",message:`Irregular whitespace detected: ${W} (U+${U.toString(16).toUpperCase().padStart(4,"0")})`,severity:"error",help:"Replace irregular whitespace with regular spaces or tabs"})}}return Z},fix:($)=>{return $.replace(/[\u00A0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/g," ")}};var CZ={meta:{docs:"Disallow new operators outside of assignments or comparisons",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(Q.startsWith("//")||Q.startsWith("/*")||Q.startsWith("*"))continue;if(/^\s*new\s+\w+/.test(z)){let q=/^\s*(?:const|let|var|this\.\w+)\s*=\s*new\s+/,U=/^\s*return\s+new\s+/,W=new RegExp("^\\s*new\\s+\\w[^;]*,"),K=/[=:,(]\s*new\s+/;if(!q.test(z)&&!U.test(z)&&!W.test(z)&&!K.test(Q)){let H=z.search(/new\s+/)+1;Z.push({filePath:J.filePath,line:Y+1,column:H,ruleId:"no-new",message:"Do not use 'new' for side effects",severity:"error",help:"Either assign the result to a variable or remove the 'new' operator if the side effect is intentional."})}}}return Z}};var IZ={meta:{docs:"Disallow multiple spaces in regular expressions",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(/^\s*\/\//.test(z))continue;let Q=/\/(?![*/])((?:\\.|[^/\\])+)\/[gimsuvy]*/g,G;for(G=Q.exec(z);G!==null;G=Q.exec(z)){let U=G[1];if(/ {2,}/.test(U)){let W=G.index+1;Z.push({filePath:J.filePath,line:Y+1,column:W,ruleId:"no-regex-spaces",message:"Multiple spaces in regular expression",severity:"error",help:"Use quantifiers like {2} instead of multiple spaces for clarity."})}}let q=/new\s+RegExp\s*\(\s*['"`]([^'"`]+)['"`]/g;for(G=q.exec(z);G!==null;G=q.exec(z)){let U=G[1];if(/ {2,}/.test(U)){let W=G.index+1;Z.push({filePath:J.filePath,line:Y+1,column:W,ruleId:"no-regex-spaces",message:"Multiple spaces in regular expression",severity:"error",help:"Use quantifiers like {2} instead of multiple spaces for clarity."})}}}return Z}};var i0={meta:{docs:"Report variables and parameters that are declared/assigned but never used"},check:($,J)=>{if(J.filePath.endsWith("/no-unused-vars.ts"))return[];if(J.filePath.endsWith(".d.ts"))return[];let Z=[],X=J.options||{},Y=typeof X.varsIgnorePattern==="string"?X.varsIgnorePattern:"^_",z=typeof X.argsIgnorePattern==="string"?X.argsIgnorePattern:"^_",Q=new RegExp(Y,"u"),G=new RegExp(z,"u"),q=$.split(/\r?\n/),U=$,W=Array(q.length).fill(!1);(()=>{let M=[],E=!1,R=!1,S=!1,f=!1,O=!1,h="",P=()=>{if(h==="")return!0;if("=([{,;!&|?:+-*/%^~<>".includes(h))return!0;return!1};for(let C=0;C<q.length;C++){W[C]=M.length>0&&M[M.length-1]===-1;let I=q[C];for(let L=0;L<I.length;L++){let T=I[L];if(f){if(T==="*"&&L+1<I.length&&I[L+1]==="/")f=!1,L++;continue}if(O){O=!1;continue}let k=M.length>0&&M[M.length-1]===-1,N=M.length>0&&M[M.length-1]>=0;if(T==="\\"&&(E||R||S||k)){O=!0;continue}if(E){if(T==="'")E=!1;continue}if(R){if(T==='"')R=!1;continue}if(S){if(T==="["){let v=1,g=L+1;while(g<I.length){let x=I[g];if(x==="\\"){g+=2;continue}if(x==="]"){if(v--,v===0)break}g++}L=g;continue}if(T==="/"){S=!1;while(L+1<I.length&&/[gimsuvy]/.test(I[L+1]))L++}continue}if(k){if(T==="`")M.pop();else if(T==="$"&&L+1<I.length&&I[L+1]==="{")M.push(0),L++;continue}if(T==="/"&&L+1<I.length&&I[L+1]==="/")break;if(T==="/"&&L+1<I.length&&I[L+1]==="*"){f=!0,L++;continue}if(N){if(T==="`")M.push(-1),h="";else if(T==="'")E=!0,h="'";else if(T==='"')R=!0,h='"';else if(T==="{")M[M.length-1]++,h="{";else if(T==="}"){let v=M[M.length-1];if(v>0)M[M.length-1]=v-1;else M.pop();h="}"}else if(T==="/"&&P())S=!0;else if(!/\s/.test(T))h=T;continue}if(T==="`")M.push(-1),h="";else if(T==="'")E=!0,h="'";else if(T==='"')R=!0,h='"';else if(T==="/"&&P())S=!0;else if(!/\s/.test(T))h=T}}})();let H=new RegExp("^\\s*(?:const|let|var)\\s+(.+?);?\\s*$");for(let M=0;M<q.length;M++){if(W[M])continue;let E=q[M],R=E.match(H);if(!R)continue;let S=R[1],f=[],O="",h=0,P=0,C=null,I=!1;for(let L=0;L<S.length;L++){let T=S[L];if(I){I=!1,O+=T;continue}if(T==="\\"&&C){I=!0,O+=T;continue}if(!C){if(T==="/"&&S[L+1]==="/")break;if(T==="/"&&S[L+1]==="*"){L+=2;while(L<S.length&&!(S[L]==="*"&&S[L+1]==="/"))L++;L++;continue}if(T==="'")C="single";else if(T==='"')C="double";else if(T==="`")C="template";else if(T==="<")P++;else if(T===">")P--;else if(T==="("||T==="["||T==="{")h++;else if(T===")"||T==="]"||T==="}")h--;else if(T===","&&h===0&&P===0){f.push(O),O="";continue}}else if(C==="single"&&T==="'"||C==="double"&&T==='"'||C==="template"&&T==="`")C=null;O+=T}if(O)f.push(O);for(let L of f){let T=L.trim();if(!T)continue;let k=T.match(/^([$A-Z_][\w$]*)/i),N=[];if(k)N.push(k[1]);else if(T.startsWith("{")||T.startsWith("[")){let v=T[0],g=v==="{"?"}":"]",x=0,u=-1,d=null,p=!1;for(let y=0;y<T.length;y++){let b=T[y];if(p){p=!1;continue}if(b==="\\"&&d){p=!0;continue}if(!d){if(b==="'"||b==='"'||b==="`")d=b==="'"?"single":b==='"'?"double":"template";else if(b===v)x++;else if(b===g){if(x--,x===0){u=y;break}}}else if(d==="single"&&b==="'"||d==="double"&&b==='"'||d==="template"&&b==="`")d=null}if(u>0){let y=T.slice(1,u),b=[],a="",W0=0,c=null,s=!1;for(let r=0;r<y.length;r++){let o=y[r];if(s){s=!1,a+=o;continue}if(o==="\\"&&c){s=!0,a+=o;continue}if(!c){if(o==="'"||o==='"'||o==="`"){c=o==="'"?"single":o==='"'?"double":"template",a+=o;continue}if(o==="("||o==="{"||o==="[")W0++;if(o===")"||o==="}"||o==="]")W0--;if(o===","&&W0===0){b.push(a.trim()),a="";continue}}else if(c==="single"&&o==="'"||c==="double"&&o==='"'||c==="template"&&o==="`")c=null;a+=o}if(a.trim())b.push(a.trim());for(let r of b){if(r.startsWith("...")){let K0=r.slice(3).match(/^([$A-Z_][\w$]*)/i);if(K0)N.push(K0[1]);continue}let o=r.indexOf(":");if(o!==-1){let K0=r.slice(o+1).trim(),_0=0;for(let y0=0;y0<K0.length;y0++){let D0=K0[y0];if(D0==="("||D0==="{"||D0==="[")_0++;else if(D0===")"||D0==="}"||D0==="]")_0--;else if(D0==="="&&_0===0){K0=K0.slice(0,y0).trim();break}}let u0=K0.match(/^([$A-Z_][\w$]*)/i);if(u0)N.push(u0[1])}else{let K0=r,_0=0;for(let y0=0;y0<K0.length;y0++){let D0=K0[y0];if(D0==="("||D0==="{"||D0==="[")_0++;else if(D0===")"||D0==="}"||D0==="]")_0--;else if(D0==="="&&_0===0){K0=K0.slice(0,y0).trim();break}}let u0=K0.match(/^([$A-Z_][\w$]*)/i);if(u0)N.push(u0[1])}}}}for(let v of N){if(Q.test(v))continue;let g=U.indexOf(E),x=U.slice(g+E.length);if(!new RegExp(`\\b${v}\\b`,"g").test(x))Z.push({filePath:J.filePath,line:M+1,column:Math.max(1,E.indexOf(v)+1),ruleId:"pickier/no-unused-vars",message:`'${v}' is assigned a value but never used. Allowed unused vars must match pattern: ${Y}`,severity:"error",help:`Either use this variable in your code, remove it, or prefix it with an underscore (_${v}) to mark it as intentionally unused`})}}}let V=(M)=>{let R=((O)=>{let h="",P=null,C=!1,I=0;for(let L=0;L<O.length;L++){let T=O[L];if(C){C=!1;continue}if(T==="\\"&&P){C=!0;continue}if(!P){if(T==="'")P="single";else if(T==='"')P="double";else if(T==="`")P="template";else if(T==="("||T==="{"||T==="[")I++;else if(T===")"||T==="}"||T==="]")I--;else if(T==="="&&I===0)return h}else if(P==="single"&&T==="'"||P==="double"&&T==='"'||P==="template"&&T==="`")P=null;h+=T}return h})(M);return((O)=>{let h="",P=0;while(P<O.length){let C=O[P];if(C===":"){P++;while(P<O.length&&/\s/.test(O[P]))P++;let I=0,L=0,T=null,k=!1;while(P<O.length){let N=O[P];if(k){k=!1,P++;continue}if(N==="\\"&&T){k=!0,P++;continue}if(!T){if(N==="'")T="single";else if(N==='"')T="double";else if(N==="`")T="template";else if(N==="<")L++;else if(N===">")L--;else if(N==="("||N==="{"||N==="[")I++;else if(N===")"||N==="}"||N==="]")if(I>0)I--;else break;else if(N===","&&I===0&&L===0)break}else if(T==="single"&&N==="'"||T==="double"&&N==='"'||T==="template"&&N==="`")T=null;P++}continue}h+=C,P++}return h})(R).split(/[^$\w]+/).filter((O)=>O&&O!=="undefined")},A=(M,E)=>{let R=!1,S=0,f=0,O=!1,h=0,P=null,C=!1,I=!0,L="",T=!1,k=!1,N=[],v=!1;for(let g=M;g<q.length;g++){let x=q[g],u=x,d=N.length>0&&N[N.length-1]===-1,p=-1,y=null,b=!1;if(!d)for(let c=0;c<x.length-1;c++){let s=x[c],r=x[c+1];if(b){b=!1;continue}if(s==="\\"&&y){b=!0;continue}if(!y){if(s==="'")y="single";else if(s==='"')y="double";else if(s==="`")y="template";else if(s==="/"&&r==="/"){p=c;break}}else if(y==="single"&&s==="'"||y==="double"&&s==='"'||y==="template"&&s==="`")y=null}if(p>=0)u=x.slice(0,p);let a=(c)=>{let s="",r=0,o=null,K0=!1;while(r<c.length){let _0=c[r];if(K0){K0=!1,s+=_0,r++;continue}if(_0==="\\"&&o){K0=!0,s+=_0,r++;continue}if(!o){if(_0==="'")o="single";else if(_0==='"')o="double";else if(_0==="`")o="template";else if(_0==="/"){let u0=r>0?c.slice(0,r).trimEnd():"",y0=new RegExp("[=([{,:;!&|?]$");if(!u0||y0.test(u0)||u0.endsWith("return")){r++;while(r<c.length){if(c[r]==="\\"){r+=2;continue}if(c[r]==="/"){r++;while(r<c.length&&/[gimsuvy]/.test(c[r]))r++;break}r++}continue}}}else if(o==="single"&&_0==="'"||o==="double"&&_0==='"'||o==="template"&&_0==="`")o=null;s+=_0,r++}return s};if(!d)u=a(u);let W0=0;if(!R){let c=-1,s=I?typeof E==="number"?E:0:0;if(I=!1,s>=u.length){let r=u.indexOf("=>");s=r>=0?r+2:0}for(let r=s;r<u.length;r++){let o=u[r];if(C){C=!1;continue}if(o==="\\"&&P){C=!0;continue}if(!P){if(o!==" "&&o!=="\t"&&o!==`
58
58
  `&&o!=="\r"&&o!=="{"&&o!=="}"&&f===0)L=o;if(o==="'")P="single";else if(o==='"')P="double";else if(o==="`")P="template";else if(o==="<")h++;else if(o===">")h=Math.max(0,h-1);else if(o==="{"){if(f===0){if(O&&h===0){c=r;break}}f++}else if(o==="}"){if(f>0){if(f--,f===0)O=!0}}}else if(P==="single"&&o==="'"||P==="double"&&o==='"'||P==="template"&&o==="`")P=null}if(c===-1){if(f>0&&L===":")continue;for(let r=s;r<u.length;r++)if(u[r]==="{"&&!P){c=r;break}}if(c===-1)continue;R=!0,S=1,W0=c+1,M=g}for(let c=W0;c<u.length;c++){let s=u[c];if(v){v=!1;continue}let r=N.length>0&&N[N.length-1]===-1,o=N.length>0&&N[N.length-1]>=0;if(s==="\\"&&(T||k||r)){v=!0;continue}if(T){if(s==="'")T=!1;continue}if(k){if(s==='"')k=!1;continue}if(r){if(s==="`")N.pop();else if(s==="$"&&c+1<u.length&&u[c+1]==="{")N[N.length-1]=0,c++;continue}if(o){if(s==="/"){let K0=u.slice(0,c).trimEnd();if(!K0||/[=([{,:;!&|?]$/.test(K0)||K0.endsWith("return")){c++;while(c<u.length){if(u[c]==="\\"){c+=2;continue}if(u[c]==="/"){while(c+1<u.length&&/[gimsuvy]/.test(u[c+1]))c++;break}c++}continue}}if(s==="`"){N.push(-1);continue}if(s==="'"){T=!0;continue}if(s==='"'){k=!0;continue}if(s==="{"){N[N.length-1]++;continue}if(s==="}")if(N[N.length-1]>0)N[N.length-1]--;else N[N.length-1]=-1;continue}if(s==="'")T=!0;else if(s==='"')k=!0;else if(s==="`")N.push(-1);else if(s==="{")S++;else if(s==="}"){if(S--,S===0)return{from:M,to:g}}}}return null},_=(M,E)=>{let R={parenDepth:0,braceDepth:0,bracketDepth:0,inTemplate:!1},S=(I)=>{for(let L=0;L<I.length;L++){let T=I[L];if(T==="`")R.inTemplate=!R.inTemplate;else if(T==="(")R.parenDepth++;else if(T===")")R.parenDepth--;else if(T==="{")R.braceDepth++;else if(T==="}")R.braceDepth--;else if(T==="[")R.bracketDepth++;else if(T==="]")R.bracketDepth--}},f=()=>R.parenDepth>0||R.braceDepth>0||R.bracketDepth>0||R.inTemplate,O=(I)=>/(?:\?|:|\.|,|&&|\|\||\?\?|\+|-|\*|\/|%|\*\*)$/.test(I.trimEnd()),h=(I)=>/^(?:\?|:|\.|,|&&|\|\||\?\?|\+|-|\*|\/|%|\*\*)/.test(I.trimStart()),P=q[M].slice(E+2);S(P);let C=M+1;while(C<q.length){let I=C===M+1?P:q[C-1];if(!(!P.trim()||f()||O(I)||h(q[C])))break;P+=`
59
59
  ${q[C]}`,S(q[C]),C++}return P},F=[],B=!1,j=!1,D=!1;for(let M=0;M<q.length;M++){let E=q[M];if(/^\s*\/\//.test(E))continue;if(W[M])continue;let R=E,S=null,f=!1,O=!1;for(let T=0;T<E.length-1;T++){let k=E[T],N=E[T+1];if(O){O=!1;continue}if(k==="\\"&&(S||f)){O=!0;continue}if(!S&&!f){if(k==="'")S="single";else if(k==='"')S="double";else if(k==="`")S="template";else if(k==="/"){let v=E[T-1]||"",g=T>=2?E.slice(T-2,T):"";if(new RegExp("[=([{,:;!?]").test(v)||g==="&&"||g==="||"||/^\s*$/.test(E.slice(0,T)))f=!0;else if(N==="/"){R=E.slice(0,T);break}}}else if(S){if(S==="single"&&k==="'"||S==="double"&&k==='"'||S==="template"&&k==="`")S=null}else if(f&&k==="/")f=!1}let C=((T)=>{let k="",N=0;while(N<T.length){if(T[N]==="/"){let v=N>0?T.slice(0,N).trimEnd():"",g=new RegExp("[=([{,:;!&|?]$");if(!v||g.test(v)||v.endsWith("return")){N++;while(N<T.length){if(T[N]==="\\"){N+=2;continue}if(T[N]==="/"){N++;while(N<T.length&&/[gimsuvy]/.test(T[N]))N++;break}N++}continue}}k+=T[N],N++}return k})(R).replace(/'(?:[^'\\]|\\.)*'/g,"''").replace(/"(?:[^"\\]|\\.)*"/g,'""');{let T="";for(let k=0;k<C.length;k++){let N=C[k];if(D){D=!1;let x=F.length>0&&F[F.length-1]===-1;T+=x?" ":N;continue}let v=F.length>0&&F[F.length-1]===-1,g=F.length>0&&F[F.length-1]>=0;if(N==="\\"&&(B||j||v)){D=!0,T+=v?" ":N;continue}if(B){if(N==="'")B=!1;T+=N;continue}if(j){if(N==='"')j=!1;T+=N;continue}if(v){if(N==="`")F.pop();else if(N==="$"&&k+1<C.length&&C[k+1]==="{")F[F.length-1]=0,T+=" ",k++;else T+=" ";continue}if(g){if(N==="`")F.push(-1),T+=" ";else if(N==="'")B=!0,T+=N;else if(N==='"')j=!0,T+=N;else if(N==="{")F[F.length-1]++,T+=N;else if(N==="}")if(F[F.length-1]>0)F[F.length-1]--,T+=N;else F[F.length-1]=-1,T+=" ";else T+=N;continue}if(N==="`")F.push(-1),T+=" ";else if(N==="'")B=!0,T+=N;else if(N==='"')j=!0,T+=N;else T+=N}C=T}let I=C.match(/\bfunction\b/);if(I){if(E.includes("function scanContent")||E.includes("function findMatching"))continue;if(C.slice(I.index+8).trimStart().startsWith(":"))continue;let k=C.slice(0,I.index).trimEnd();if(k.endsWith(".")||k.endsWith("?."))continue;let N=I.index,v=E.indexOf("(",N);if(v===-1)continue;let g=0,x=-1,u=M,d="";for(let a=M;a<q.length;a++){let W0=a===M?q[a]:q[a],c=a===M?v:0;for(let s=c;s<W0.length;s++)if(W0[s]==="(")g++;else if(W0[s]===")"){if(g--,g===0){if(x=s,u=a,M===a)d=E.slice(v+1,x);else{d=E.slice(v+1);for(let r=M+1;r<a;r++)d+=` ${q[r]}`;d+=` ${W0.slice(0,x)}`}break}}if(x!==-1)break}if(x===-1)continue;let p=V(d),y=A(u,x),b="";if(y)if(y.from===u){let a=q[y.from],W0=a.lastIndexOf("{"),c=W0>=0?a.slice(W0+1):"";if(y.to>y.from)b=`${c}
60
60
  ${q.slice(y.from+1,y.to+1).join(`
@@ -67,10 +67,10 @@ ${q.slice(b.from+1,b.to+1).join(`
67
67
  ${q.slice(b.from+1,b.to+1).join(`
68
68
  `)}`;else d=c}else d=q.slice(b.from,b.to+1).join(`
69
69
  `)}else d=_(M,u);if(!new RegExp(`\\b${N}\\b`,"g").test(d))Z.push({filePath:J.filePath,line:M+1,column:Math.max(1,E.indexOf(N)+1),ruleId:"pickier/no-unused-vars",message:`'${N}' is defined but never used (function parameter). Allowed unused args must match pattern: ${z}`,severity:"error"})}}}return Z},fix:($,J)=>{let Z=i0.check($,J);if(Z.length===0)return $;let X=Z.filter((K)=>K.message.includes("(function parameter)"));if(X.length===0)return $;let Y=$.split(/\r?\n/),z=new Set,Q=/(?:eslint|pickier)-disable-next-line\b([^*\n]*)/;for(let K=0;K<Y.length;K++){let H=Y[K].match(Q);if(!H)continue;let V=H[1].trim();if(V===""||/\bno-unused-vars\b/.test(V)||/\bpickier\/no-unused-vars\b/.test(V))z.add(K+2)}let G=new Map;for(let K of X){if(z.has(K.line))continue;let H=K.message.match(/^'([^']+)'/);if(!H)continue;let V=H[1];if(V.startsWith("_"))continue;let A=G.get(K.line);if(!A)A=new Set,G.set(K.line,A);A.add(V)}if(G.size===0)return $;let q=$.split(/\r?\n/);function U(K){let H=[],V=!1,A=!1,_=!1,F=-1;for(let B=0;B<K.length;B++){let j=K[B];if(_){_=!1;continue}if(j==="\\"&&(V||A||F>=0)){_=!0;continue}if(F>=0){if(j==="`")H.push([F,B]),F=-1;continue}if(V){if(j==="'")V=!1;continue}if(A){if(j==='"')A=!1;continue}if(j==="`")F=B;else if(j==="'")V=!0;else if(j==='"')A=!0}if(F>=0)H.push([F,K.length]);return H}let W=!1;for(let[K,H]of G){let V=K-1,A=q[V];if(A===void 0)continue;let _=U(A),F=(D)=>_.some(([M,E])=>D>M&&D<E),B=[];for(let D of H){let M=D.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),E=new RegExp(`(?<=[(,]\\s*)\\b${M}\\b(?=\\s*[,):=])`,"g"),R;while((R=E.exec(A))!==null){if(F(R.index))continue;B.push({start:R.index,end:R.index+D.length,name:D})}}if(B.length===0)continue;B.sort((D,M)=>M.start-D.start);let j=A;for(let D of B)j=`${j.slice(0,D.start)}_${D.name}${j.slice(D.end)}`;if(j!==A)q[V]=j,W=!0}return W?q.join(`
70
- `):$}};function b1($){let J=$.split(/\r?\n/),Z=Array(J.length).fill(!1),X=[],Y=!1,z=!1,Q=!1,G=!1,q=!1,U="",W=()=>{if(U==="")return!0;return"=([{,;!&|?:+-*/%^~<>".includes(U)};for(let K=0;K<J.length;K++){Z[K]=X.length>0&&X[X.length-1]===-1;let H=J[K];for(let V=0;V<H.length;V++){let A=H[V];if(G){if(A==="*"&&V+1<H.length&&H[V+1]==="/")G=!1,V++;continue}if(q){q=!1;continue}let _=X.length>0&&X[X.length-1]===-1,F=X.length>0&&X[X.length-1]>=0;if(A==="\\"&&(Y||z||Q||_)){q=!0;continue}if(Y){if(A==="'")Y=!1;continue}if(z){if(A==='"')z=!1;continue}if(Q){if(A==="["){let B=1,j=V+1;while(j<H.length){let D=H[j];if(D==="\\"){j+=2;continue}if(D==="]"){if(B--,B===0)break}j++}V=j;continue}if(A==="/"){Q=!1;while(V+1<H.length&&/[gimsuvy]/.test(H[V+1]))V++}continue}if(_){if(A==="`")X.pop();else if(A==="$"&&V+1<H.length&&H[V+1]==="{")X.push(0),V++;continue}if(A==="/"&&V+1<H.length&&H[V+1]==="/")break;if(A==="/"&&V+1<H.length&&H[V+1]==="*"){G=!0,V++;continue}if(F){if(A==="`")X.push(-1),U="";else if(A==="'")Y=!0,U="'";else if(A==='"')z=!0,U='"';else if(A==="{")X[X.length-1]++,U="{";else if(A==="}"){let B=X[X.length-1];if(B>0)X[X.length-1]=B-1;else X.pop();U="}"}else if(A==="/"&&W())Q=!0;else if(!/\s/.test(A))U=A;continue}if(A==="`")X.push(-1),U="";else if(A==="'")Y=!0,U="'";else if(A==='"')z=!0,U='"';else if(A==="/"&&W())Q=!0;else if(!/\s/.test(A))U=A}}return Z}function cQ($,J){let Z=[],X=0,Y=0,z=null,Q=!1;for(let G=0;G<$.length;G++){let q=$[G];if(Q){Q=!1;continue}if(q==="\\"&&z){Q=!0;continue}if(!z){if(q==="'")z="single";else if(q==='"')z="double";else if(q==="`")z="template";else if(q==="("||q==="{"||q==="[")X++;else if(q===")"||q==="}"||q==="]")X--;else if(q===J&&X===0)Z.push($.slice(Y,G)),Y=G+1}else if(z==="single"&&q==="'"||z==="double"&&q==='"'||z==="template"&&q==="`")z=null}return Z.push($.slice(Y)),Z}function rQ($){let J=0;for(let Z=0;Z<$.length;Z++){let X=$[Z];if(X==="{"||X==="("||X==="["||X==="<")J++;else if(X==="}"||X===")"||X==="]"||X===">")J--;else if(X==="="&&J===0&&$[Z+1]!=="="&&$[Z-1]!=="!"&&$[Z-1]!=="<"&&$[Z-1]!==">")return Z}return-1}function lQ($,J){let Z=new RegExp(`\\b${J}\\b`),X=0,Y=null,z=!1;while(X<$.length){let Q=$[X];if(z){z=!1,X++;continue}if(Q==="\\"&&Y){z=!0,X++;continue}if(Y){if(Y==="single"&&Q==="'"||Y==="double"&&Q==='"'||Y==="template"&&Q==="`")Y=null;X++;continue}if(Q==="'"){Y="single",X++;continue}if(Q==='"'){Y="double",X++;continue}if(Q==="`"){Y="template",X++;continue}if(Q==="["||Q==="{"){let G=Q,q=Q==="["?"]":"}",U=1,W=X+1;while(W<$.length&&U>0){let K=$[W];if(K==="\\"){W+=2;continue}if(K===G)U++;else if(K===q)U--;if(U===0)break;W++}if(U===0&&W<$.length){let K=W+1;while(K<$.length&&($[K]===" "||$[K]==="\t"||$[K]==="\r"||$[K]===`
71
- `))K++;if($[K]==="="&&$[K+1]!=="="&&$[K+1]!==">"){let H=$.slice(X+1,W);if(Z.test(H)){let V=new RegExp(`\\b${J}\\b\\s*:`),A=new RegExp(`:\\s*\\b${J}\\b`);if(G==="{"){if(!(V.test(H)&&!A.test(H)&&!new RegExp(`(?:^|[\\s,{])\\s*${J}\\s*(?:,|\\s*=|\\s*})`).test(H)))return!0}else return!0}}}X=W+1;continue}X++}return!1}function SZ($,J){let Z=new RegExp("^\\s*(?:let|var)\\s+(.+?);?\\s*$"),X=$.match(Z);if(!X)return null;let Y=X[1],z=rQ(Y);if(z>=0){let q=Y.indexOf(":");if(q>=0&&q<z)Y=Y.slice(0,q)+Y.slice(z)}let Q=cQ(Y,","),G=[];for(let q of Q){let U=q.trim();if(!U)continue;if(U.match(/^[{[]/))return null;let K=U.match(/^([$A-Z_][\w$]*)/i);if(!K)return null;let H=K[1];if(!/=/.test(U))return null;let A=J.indexOf($),_=J.slice(A+$.length),B=`\\b${H}\\s*(?:${["=","+=","-=","*=","/=","%=","**=","<<=",">>=",">>>=","&=","^=","|="].map((E)=>E.replace(/[|\\^$*+?.(){}[\]]/g,(R)=>`\\${R}`)).join("|")})`,j=new RegExp(B).test(_),D=new RegExp(`(?:^|[^$w])(?:\\+\\+|--)\\s*${H}\\b|\\b${H}\\s*(?:\\+\\+|--)`).test(_),M=lQ(_,H);G.push({name:H,fixable:!j&&!D&&!M})}return G}var D8={meta:{docs:"Suggest 'const' for variables that are never reassigned (heuristic)"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=b1($);for(let z=0;z<X.length;z++){if(Y[z])continue;let Q=X[z],G=SZ(Q,$);if(!G)continue;for(let{name:q,fixable:U}of G){if(!U)continue;let W=Q.search(new RegExp(`\\b${q.replace(/\$/g,"\\$")}\\b`)),K=W!==-1?W:Q.indexOf(q);Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,K+1),ruleId:"prefer-const",message:`'${q}' is never reassigned. Use 'const' instead`,severity:"error",help:`Change 'let ${q}' to 'const ${q}' since the variable is never reassigned. This makes your code more predictable and prevents accidental mutations`})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=new Set,X=/(?:eslint|pickier)-disable-next-line\b([^*\n]*)/;for(let z=0;z<J.length;z++){let Q=J[z].match(X);if(!Q)continue;let G=Q[1].trim();if(G===""||/\bprefer-const\b/.test(G))Z.add(z+2)}let Y=!1;for(let z=0;z<J.length;z++){if(Z.has(z+1))continue;let Q=J[z];if(!/^\s*let\b/.test(Q))continue;let G=SZ(Q,$);if(!G||G.length===0)continue;if(!G.every((U)=>U.fixable))continue;let q=Q.replace(/^(\s*)let(\s+)/,"$1const$2");if(q!==Q)J[z]=q,Y=!0}return Y?J.join(`
70
+ `):$}};function t0($){let J=$.split(/\r?\n/),Z=Array(J.length).fill(!1),X=[],Y=!1,z=!1,Q=!1,G=!1,q=!1,U="",W=()=>{if(U==="")return!0;return"=([{,;!&|?:+-*/%^~<>".includes(U)};for(let K=0;K<J.length;K++){Z[K]=X.length>0&&X[X.length-1]===-1;let H=J[K];for(let V=0;V<H.length;V++){let A=H[V];if(G){if(A==="*"&&V+1<H.length&&H[V+1]==="/")G=!1,V++;continue}if(q){q=!1;continue}let _=X.length>0&&X[X.length-1]===-1,F=X.length>0&&X[X.length-1]>=0;if(A==="\\"&&(Y||z||Q||_)){q=!0;continue}if(Y){if(A==="'")Y=!1;continue}if(z){if(A==='"')z=!1;continue}if(Q){if(A==="["){let B=1,j=V+1;while(j<H.length){let D=H[j];if(D==="\\"){j+=2;continue}if(D==="]"){if(B--,B===0)break}j++}V=j;continue}if(A==="/"){Q=!1;while(V+1<H.length&&/[gimsuvy]/.test(H[V+1]))V++}continue}if(_){if(A==="`")X.pop();else if(A==="$"&&V+1<H.length&&H[V+1]==="{")X.push(0),V++;continue}if(A==="/"&&V+1<H.length&&H[V+1]==="/")break;if(A==="/"&&V+1<H.length&&H[V+1]==="*"){G=!0,V++;continue}if(F){if(A==="`")X.push(-1),U="";else if(A==="'")Y=!0,U="'";else if(A==='"')z=!0,U='"';else if(A==="{")X[X.length-1]++,U="{";else if(A==="}"){let B=X[X.length-1];if(B>0)X[X.length-1]=B-1;else X.pop();U="}"}else if(A==="/"&&W())Q=!0;else if(!/\s/.test(A))U=A;continue}if(A==="`")X.push(-1),U="";else if(A==="'")Y=!0,U="'";else if(A==='"')z=!0,U='"';else if(A==="/"&&W())Q=!0;else if(!/\s/.test(A))U=A}}return Z}function cQ($,J){let Z=[],X=0,Y=0,z=null,Q=!1;for(let G=0;G<$.length;G++){let q=$[G];if(Q){Q=!1;continue}if(q==="\\"&&z){Q=!0;continue}if(!z){if(q==="'")z="single";else if(q==='"')z="double";else if(q==="`")z="template";else if(q==="("||q==="{"||q==="[")X++;else if(q===")"||q==="}"||q==="]")X--;else if(q===J&&X===0)Z.push($.slice(Y,G)),Y=G+1}else if(z==="single"&&q==="'"||z==="double"&&q==='"'||z==="template"&&q==="`")z=null}return Z.push($.slice(Y)),Z}function rQ($){let J=0;for(let Z=0;Z<$.length;Z++){let X=$[Z];if(X==="{"||X==="("||X==="["||X==="<")J++;else if(X==="}"||X===")"||X==="]"||X===">")J--;else if(X==="="&&J===0&&$[Z+1]!=="="&&$[Z-1]!=="!"&&$[Z-1]!=="<"&&$[Z-1]!==">")return Z}return-1}function lQ($,J){let Z=new RegExp(`\\b${J}\\b`),X=0,Y=null,z=!1;while(X<$.length){let Q=$[X];if(z){z=!1,X++;continue}if(Q==="\\"&&Y){z=!0,X++;continue}if(Y){if(Y==="single"&&Q==="'"||Y==="double"&&Q==='"'||Y==="template"&&Q==="`")Y=null;X++;continue}if(Q==="'"){Y="single",X++;continue}if(Q==='"'){Y="double",X++;continue}if(Q==="`"){Y="template",X++;continue}if(Q==="["||Q==="{"){let G=Q,q=Q==="["?"]":"}",U=1,W=X+1;while(W<$.length&&U>0){let K=$[W];if(K==="\\"){W+=2;continue}if(K===G)U++;else if(K===q)U--;if(U===0)break;W++}if(U===0&&W<$.length){let K=W+1;while(K<$.length&&($[K]===" "||$[K]==="\t"||$[K]==="\r"||$[K]===`
71
+ `))K++;if($[K]==="="&&$[K+1]!=="="&&$[K+1]!==">"){let H=$.slice(X+1,W);if(Z.test(H)){let V=new RegExp(`\\b${J}\\b\\s*:`),A=new RegExp(`:\\s*\\b${J}\\b`);if(G==="{"){if(!(V.test(H)&&!A.test(H)&&!new RegExp(`(?:^|[\\s,{])\\s*${J}\\s*(?:,|\\s*=|\\s*})`).test(H)))return!0}else return!0}}}X=W+1;continue}X++}return!1}function SZ($,J){let Z=new RegExp("^\\s*(?:let|var)\\s+(.+?);?\\s*$"),X=$.match(Z);if(!X)return null;let Y=X[1],z=rQ(Y);if(z>=0){let q=Y.indexOf(":");if(q>=0&&q<z)Y=Y.slice(0,q)+Y.slice(z)}let Q=cQ(Y,","),G=[];for(let q of Q){let U=q.trim();if(!U)continue;if(U.match(/^[{[]/))return null;let K=U.match(/^([$A-Z_][\w$]*)/i);if(!K)return null;let H=K[1];if(!/=/.test(U))return null;let A=J.indexOf($),_=J.slice(A+$.length),B=`\\b${H}\\s*(?:${["=","+=","-=","*=","/=","%=","**=","<<=",">>=",">>>=","&=","^=","|="].map((f)=>f.replace(/[|\\^$*+?.(){}[\]]/g,(O)=>`\\${O}`)).join("|")})`,j=new RegExp(B).test(_),D=new RegExp(`(?:^|[^$w])(?:\\+\\+|--)\\s*${H}\\b|\\b${H}\\s*(?:\\+\\+|--)`).test(_),M=lQ(_,H),E=U.indexOf("="),R=E>=0?U.slice(E+1):"",S=new RegExp(B).test(R);G.push({name:H,fixable:!j&&!D&&!M&&!S})}return G}var D8={meta:{docs:"Suggest 'const' for variables that are never reassigned (heuristic)"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=t0($);for(let z=0;z<X.length;z++){if(Y[z])continue;let Q=X[z],G=SZ(Q,$);if(!G)continue;for(let{name:q,fixable:U}of G){if(!U)continue;let W=Q.search(new RegExp(`\\b${q.replace(/\$/g,"\\$")}\\b`)),K=W!==-1?W:Q.indexOf(q);Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,K+1),ruleId:"prefer-const",message:`'${q}' is never reassigned. Use 'const' instead`,severity:"error",help:`Change 'let ${q}' to 'const ${q}' since the variable is never reassigned. This makes your code more predictable and prevents accidental mutations`})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=t0($),X=new Set,Y=/(?:eslint|pickier)-disable-next-line\b([^*\n]*)/;for(let Q=0;Q<J.length;Q++){let G=J[Q].match(Y);if(!G)continue;let q=G[1].trim();if(q===""||/\bprefer-const\b/.test(q))X.add(Q+2)}let z=!1;for(let Q=0;Q<J.length;Q++){if(X.has(Q+1))continue;if(Z[Q])continue;let G=J[Q];if(!/^\s*let\b/.test(G))continue;let q=SZ(G,$);if(!q||q.length===0)continue;if(!q.every((W)=>W.fixable))continue;let U=G.replace(/^(\s*)let(\s+)/,"$1const$2");if(U!==G)J[Q]=U,z=!0}return z?J.join(`
72
72
  `):$}};var vZ={meta:{docs:"Prefer object spread ({...obj}) over Object.assign() for object composition"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(/^\s*\/\//.test(z))continue;let Q=z.indexOf("//"),G=Q>=0?z.slice(0,Q):z,q=G.matchAll(/\bObject\.assign\s*\(/g);for(let U of q){let W=U.index,K=G.slice(0,W),H=(K.match(/'/g)||[]).length,V=(K.match(/"/g)||[]).length,A=(K.match(/`/g)||[]).length;if(H%2!==0||V%2!==0||A%2!==0)continue;let _=W+13,F=G.slice(_),B=-1,j=1,D=0,M=0,E=null,R=!1;for(let f=1;f<F.length;f++){let O=F[f];if(R){R=!1;continue}if(O==="\\"&&E){R=!0;continue}if(!E){if(O==="'")E="single";else if(O==='"')E="double";else if(O==="`")E="template";else if(O==="(")j++;else if(O===")"){if(j--,j===0)break}else if(O==="{")D++;else if(O==="}")D--;else if(O==="[")M++;else if(O==="]")M--;else if(O===","&&j===1&&D===0&&M===0){B=f;break}}else if(E==="single"&&O==="'"||E==="double"&&O==='"'||E==="template"&&O==="`")E=null}if(B===-1)continue;let S=F.slice(1,B).trim();if(S==="{}")Z.push({filePath:J.filePath,line:Y+1,column:W+1,ruleId:"prefer-object-spread",message:"Prefer object spread over Object.assign",severity:"error",help:"Use object spread syntax: {...obj} instead of Object.assign({}, obj)"});else if(S==="{}"||/^\{.*\}$/.test(S))Z.push({filePath:J.filePath,line:Y+1,column:W+1,ruleId:"prefer-object-spread",message:"Prefer object spread over Object.assign for object literals",severity:"error",help:"Use object spread syntax: {...obj1, ...obj2}"})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=[];for(let X=0;X<J.length;X++){let Y=J[X];Y=Y.replace(/\bObject\.assign\s*\(\s*\{\}\s*,\s*([^)]+)\)/g,(z,Q)=>{return`{${Q.split(",").map((q)=>q.trim()).map((q)=>`...${q}`).join(", ")}}`}),Z.push(Y)}return Z.join(`
73
- `)}};function aQ($,J){let Z=!1,X=!1,Y=!1;for(let z=0;z<J;z++){let Q=$[z];if(Q==="\\"){z++;continue}if(Q==="'"&&!X&&!Y)Z=!Z;else if(Q==='"'&&!Z&&!Y)X=!X;else if(Q==="`"&&!Z&&!X)Y=!Y}return Z||X||Y}var R8={meta:{docs:"Prefer template literals over string concatenation",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(Q.startsWith("//")||Q.startsWith("/*")||Q.startsWith("*")||Q.startsWith("import"))continue;let G=/(['"`][^'"`]*['"`])\s*\+\s*([a-z_$][\w$]*)/i,q=/([a-z_$][\w$]*)\s*\+\s*(['"`][^'"`]*['"`])/i,U=Q.match(G)||Q.match(q);if(U){let W=z.indexOf("//"),K=z.indexOf(U[0]);if(W>=0&&K>W)continue;if(aQ(z,K))continue;let H=!!Q.match(q),V=!!Q.match(G);if(H&&!V){if(Q.slice(Q.indexOf(U[0])+U[0].length).startsWith("."))continue}Z.push({filePath:J.filePath,line:Y+1,column:K+1,ruleId:"general/prefer-template",message:"Unexpected string concatenation. Use template literals instead",severity:"warning",help:"Use template literals (backticks) instead of string concatenation. Example: `hello ${name}!` instead of 'hello ' + name + '!'"})}}return Z}};var yZ={name:"general",rules:{"array-callback-return":w(B$),"constructor-super":w(w$),"for-direction":w(M$),"getter-return":w(j$),"no-async-promise-executor":w(N$),"no-compare-neg-zero":w(T$),"no-cond-assign":w(E$),"no-const-assign":w(D$),"no-constant-condition":w(R$),"no-constructor-return":w(LZ),"no-dupe-class-members":w(O$),"no-dupe-keys":w(I1),"no-duplicate-case":w(L$),"no-empty-pattern":w(P$),"no-fallthrough":w(C$),"no-irregular-whitespace":w(PZ),"no-loss-of-precision":w(I$),"no-new":w(CZ),"no-regex-spaces":w(IZ),"no-promise-executor-return":w(S$),"no-redeclare":w(v$),"no-self-assign":w(S1),"no-self-compare":w(y$),"no-sparse-arrays":w(b$),"no-undef":w(k$),"no-unsafe-negation":w(g$),"no-unreachable":w(f$),"no-unused-vars":w(i0),"no-useless-catch":w(x$),"prefer-const":w(D8),"prefer-object-spread":w(vZ),"prefer-template":w(R8),"use-isnan":w(p$),"valid-typeof":w(h$)}};var k1={npm:"registry.npmjs.org",yarn:"registry.yarnpkg.com",verdaccio:"registry.verdaccio.org"};function bZ($){let J=$.split("/").pop()||"";if(J==="package-lock.json")return"npm";if(J==="yarn.lock")return"yarn";if(J==="bun.lockb"||J==="bun.lock")return"bun";return null}function x0($,J){let Z=bZ(J);if(!Z)return!1;if(Z==="npm")try{let X=JSON.parse($);return"lockfileVersion"in X||"dependencies"in X||"packages"in X}catch{return!1}if(Z==="yarn")return $.startsWith("#")||$.includes("__metadata:")||$.includes('resolved "');if(Z==="bun")try{let X=JSON.parse($);return"lockfileVersion"in X||"packages"in X}catch{return!1}return!1}function sQ($){let J=new Map,Z=JSON.parse($);if((Z.lockfileVersion||1)>=2&&Z.packages)for(let[Y,z]of Object.entries(Z.packages)){if(!Y||Y==="")continue;let Q=Y.replace(/^node_modules\//,"").replace(/\/node_modules\//g,"/"),G=Q.split("/node_modules/").pop()||Q;J.set(Y,{name:G,version:z.version||"",resolved:z.resolved,integrity:z.integrity})}else if(Z.dependencies)kZ(Z.dependencies,J,"");return{type:"npm",packages:J}}function kZ($,J,Z){for(let[X,Y]of Object.entries($)){let z=Z?`${Z}/${X}`:X;if(J.set(z,{name:X,version:Y.version||"",resolved:Y.resolved,integrity:Y.integrity}),Y.dependencies)kZ(Y.dependencies,J,z)}}function nQ($){let J=new Map,Z=$.includes("__metadata:"),X=Z?"yarn-berry":"yarn",Y=$.split(`
73
+ `)}};function aQ($,J){let Z=!1,X=!1,Y=!1;for(let z=0;z<J;z++){let Q=$[z];if(Q==="\\"){z++;continue}if(Q==="'"&&!X&&!Y)Z=!Z;else if(Q==='"'&&!Z&&!Y)X=!X;else if(Q==="`"&&!Z&&!X)Y=!Y}return Z||X||Y}var R8={meta:{docs:"Prefer template literals over string concatenation",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(Q.startsWith("//")||Q.startsWith("/*")||Q.startsWith("*")||Q.startsWith("import"))continue;let G=/(['"`][^'"`]*['"`])\s*\+\s*([a-z_$][\w$]*)/i,q=/([a-z_$][\w$]*)\s*\+\s*(['"`][^'"`]*['"`])/i,U=Q.match(G)||Q.match(q);if(U){let W=z.indexOf("//"),K=z.indexOf(U[0]);if(W>=0&&K>W)continue;if(aQ(z,K))continue;let H=!!Q.match(q),V=!!Q.match(G);if(H&&!V){if(Q.slice(Q.indexOf(U[0])+U[0].length).startsWith("."))continue}Z.push({filePath:J.filePath,line:Y+1,column:K+1,ruleId:"general/prefer-template",message:"Unexpected string concatenation. Use template literals instead",severity:"warning",help:"Use template literals (backticks) instead of string concatenation. Example: `hello ${name}!` instead of 'hello ' + name + '!'"})}}return Z}};var yZ={name:"general",rules:{"array-callback-return":w(B$),"constructor-super":w(w$),"for-direction":w(M$),"getter-return":w(j$),"no-async-promise-executor":w(N$),"no-compare-neg-zero":w(T$),"no-cond-assign":w(E$),"no-const-assign":w(D$),"no-constant-condition":w(R$),"no-constructor-return":w(LZ),"no-dupe-class-members":w(O$),"no-dupe-keys":w(S1),"no-duplicate-case":w(L$),"no-empty-pattern":w(P$),"no-fallthrough":w(C$),"no-irregular-whitespace":w(PZ),"no-loss-of-precision":w(I$),"no-new":w(CZ),"no-regex-spaces":w(IZ),"no-promise-executor-return":w(S$),"no-redeclare":w(v$),"no-self-assign":w(v1),"no-self-compare":w(y$),"no-sparse-arrays":w(b$),"no-undef":w(k$),"no-unsafe-negation":w(g$),"no-unreachable":w(f$),"no-unused-vars":w(i0),"no-useless-catch":w(x$),"prefer-const":w(D8),"prefer-object-spread":w(vZ),"prefer-template":w(R8),"use-isnan":w(p$),"valid-typeof":w(h$)}};var k1={npm:"registry.npmjs.org",yarn:"registry.yarnpkg.com",verdaccio:"registry.verdaccio.org"};function bZ($){let J=$.split("/").pop()||"";if(J==="package-lock.json")return"npm";if(J==="yarn.lock")return"yarn";if(J==="bun.lockb"||J==="bun.lock")return"bun";return null}function x0($,J){let Z=bZ(J);if(!Z)return!1;if(Z==="npm")try{let X=JSON.parse($);return"lockfileVersion"in X||"dependencies"in X||"packages"in X}catch{return!1}if(Z==="yarn")return $.startsWith("#")||$.includes("__metadata:")||$.includes('resolved "');if(Z==="bun")try{let X=JSON.parse($);return"lockfileVersion"in X||"packages"in X}catch{return!1}return!1}function sQ($){let J=new Map,Z=JSON.parse($);if((Z.lockfileVersion||1)>=2&&Z.packages)for(let[Y,z]of Object.entries(Z.packages)){if(!Y||Y==="")continue;let Q=Y.replace(/^node_modules\//,"").replace(/\/node_modules\//g,"/"),G=Q.split("/node_modules/").pop()||Q;J.set(Y,{name:G,version:z.version||"",resolved:z.resolved,integrity:z.integrity})}else if(Z.dependencies)kZ(Z.dependencies,J,"");return{type:"npm",packages:J}}function kZ($,J,Z){for(let[X,Y]of Object.entries($)){let z=Z?`${Z}/${X}`:X;if(J.set(z,{name:X,version:Y.version||"",resolved:Y.resolved,integrity:Y.integrity}),Y.dependencies)kZ(Y.dependencies,J,z)}}function nQ($){let J=new Map,Z=$.includes("__metadata:"),X=Z?"yarn-berry":"yarn",Y=$.split(`
74
74
  `),z="",Q={};for(let G of Y){if(G.startsWith("#")||G.trim()==="")continue;if(!G.startsWith(" ")&&G.includes("@")&&G.endsWith(":")){if(z&&(Q.resolved||Q.integrity))J.set(z,Q);if(z=G.slice(0,-1).trim(),z.startsWith('"')&&z.endsWith('"'))z=z.slice(1,-1);let q=z.match(/^(@?[^@]+)@/);Q={name:q?q[1]:z.split("@")[0],version:""}}else if(G.startsWith(" ")||G.startsWith("\t")){let q=G.trim();if(q.startsWith("version")){let U=q.match(/version[:\s]+"?([^"]+)"?/);if(U)Q.version=U[1]}else if(q.startsWith("resolved")){let U=q.match(/resolved[:\s]+"?([^"]+)"?/);if(U)Q.resolved=U[1]}else if(q.startsWith("resolution:")&&Z){let U=q.match(/resolution[:\s]+"?([^"]+)"?/);if(U)Q.resolved=U[1]}else if(q.startsWith("integrity")||q.startsWith("checksum")){let U=q.match(/(integrity|checksum)[:\s]+"?([^"]+)"?/);if(U)Q.integrity=U[2]}}}if(z&&(Q.resolved||Q.integrity))J.set(z,Q);return{type:X,packages:J}}function iQ($){let J=new Map,Z=JSON.parse($);if(Z.packages)for(let[X,Y]of Object.entries(Z.packages)){if(!X||X==="")continue;if(Array.isArray(Y)){let[z,Q,G,q]=Y,U=X,W="";if(typeof z==="string"&&z.includes("@")){let K=z.lastIndexOf("@");if(K>0)U=z.substring(0,K),W=z.substring(K+1)}J.set(X,{name:U,version:W,resolved:Q||void 0,integrity:q||void 0})}else if(typeof Y==="object")J.set(X,{name:Y.name||X.split("@")[0],version:Y.version||"",resolved:Y.resolved,integrity:Y.integrity||Y.hash})}return{type:"bun",packages:J}}function p0($,J){let Z=bZ(J);if(!Z)return null;try{switch(Z){case"npm":return sQ($);case"yarn":return nQ($);case"bun":return iQ($);default:return null}}catch{return null}}function fZ($){try{return new URL($).hostname}catch{return null}}function O8($){try{return new URL($).protocol}catch{return null}}function gZ($){try{let Z=new URL($).pathname,X=Z.indexOf("/-/");if(X===-1)return null;let Y=Z.substring(1,X);if(Y.startsWith("@"))return Y;return Y}catch{return null}}function xZ($){if(!$)return null;let J=$.match(/^(sha\d+)-/);return J?J[1]:null}function pZ($){return $.map((J)=>{let Z=J.toLowerCase();return k1[Z]||J})}var uZ={meta:{docs:"Ensure all packages are from allowed registry hosts",recommended:!0},check($,J){let Z=[];if(!x0($,J.filePath))return Z;let X=p0($,J.filePath);if(!X)return Z;let Y=J.options||{},z=Y.allowedHosts||["npm","yarn"],Q=Y.emptyHostname!==!1,G=pZ(z),q=$.split(`
75
75
  `);for(let[U,W]of X.packages){if(!W.resolved){if(!Q){let H=hZ(q,U);Z.push({filePath:J.filePath,line:H,column:1,ruleId:"lockfile/validate-host",message:`Package "${W.name}" has no resolved URL`,severity:"error",help:"All packages should have a resolved URL from an allowed registry."})}continue}let K=fZ(W.resolved);if(!K)continue;if(!G.includes(K)){let H=hZ(q,U),V=z.map((A)=>k1[A.toLowerCase()]||A).join(", ");Z.push({filePath:J.filePath,line:H,column:1,ruleId:"lockfile/validate-host",message:`Invalid host for package "${W.name}": expected one of [${V}], got "${K}"`,severity:"error",help:`Package is resolving from an unauthorized registry. This could indicate a supply chain attack. Allowed hosts: ${V}`})}}return Z}};function hZ($,J){for(let Z=0;Z<$.length;Z++)if($[Z].includes(J)||$[Z].includes(`"${J}"`))return Z+1;return 1}var mZ={meta:{docs:"Ensure all packages use HTTPS protocol",recommended:!0},check($,J){let Z=[];if(!x0($,J.filePath))return Z;let X=p0($,J.filePath);if(!X)return Z;let Y=$.split(`
76
76
  `);for(let[z,Q]of X.packages){if(!Q.resolved)continue;let G=O8(Q.resolved);if(!G)continue;if(G!=="https:"){let q=tQ(Y,z);Z.push({filePath:J.filePath,line:q,column:1,ruleId:"lockfile/validate-https",message:`Package "${Q.name}" uses insecure protocol: "${G}" instead of "https:"`,severity:"error",help:"All packages should be downloaded over HTTPS to prevent man-in-the-middle attacks."})}}return Z}};function tQ($,J){for(let Z=0;Z<$.length;Z++)if($[Z].includes(J)||$[Z].includes(`"${J}"`))return Z+1;return 1}var dZ={meta:{docs:"Ensure all packages use strong integrity hashes (SHA512)",recommended:!0},check($,J){let Z=[];if(!x0($,J.filePath))return Z;let X=p0($,J.filePath);if(!X)return Z;let Y=J.options||{},z=Y.requiredAlgorithm||"sha512",Q=new Set(Y.exclude||[]),G={sha1:1,sha256:2,sha384:3,sha512:4},q=G[z]||4,U=$.split(`
@@ -79,7 +79,7 @@ ${q.slice(b.from+1,b.to+1).join(`
79
79
  `);for(let[q,U]of X.packages){if(!U.resolved)continue;let W=O8(U.resolved);if(!W)continue;if(!Q.includes(W)){let K=ZG(G,q);Z.push({filePath:J.filePath,line:K,column:1,ruleId:"lockfile/validate-scheme",message:`Package "${U.name}" uses disallowed URL scheme: "${W}"`,severity:"error",help:`Only the following URL schemes are allowed: ${Q.join(", ")}. Using "${W}" could be a security risk.`})}}return Z}};function ZG($,J){for(let Z=0;Z<$.length;Z++)if($[Z].includes(J)||$[Z].includes(`"${J}"`))return Z+1;return 1}var rZ={name:"lockfile",rules:{"validate-host":uZ,"validate-https":mZ,"validate-integrity":dZ,"validate-package-names":oZ,"validate-scheme":cZ}};var lZ={meta:{docs:"Fenced code blocks should be surrounded by blank lines"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z];if(/^(?:`{3,}|~{3,})/.test(Q.trim()))if(!Y){let q=z>0?X[z-1]:"";if(z>0&&q.trim().length>0){if(!/^:::/.test(q.trim()))Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"markdown/blanks-around-fences",message:"Fenced code blocks should be surrounded by blank lines",severity:"error"})}Y=!0}else{let q=z+1<X.length?X[z+1]:"";if(z+1<X.length&&q.trim().length>0){if(!/^:::/.test(q.trim()))Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"markdown/blanks-around-fences",message:"Fenced code blocks should be surrounded by blank lines",severity:"error"})}Y=!1}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=[],X=!1;for(let Y=0;Y<J.length;Y++){let z=J[Y],Q=Y>0?J[Y-1]:"",G=/^(?:`{3,}|~{3,})/.test(z.trim());if(G)if(!X){if(Y>0&&Q.trim().length>0&&!/^:::/.test(Q.trim())&&Z.length>0)Z.push("");X=!0}else X=!1;if(Z.push(z),G&&!X&&Y+1<J.length){let q=J[Y+1];if(q.trim().length>0&&!/^:::/.test(q.trim()))Z.push("")}}return Z.join(`
80
80
  `)}};var aZ={meta:{docs:"Headings should be surrounded by blank lines"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1;for(let z=0;z<X.length;z++){let Q=X[z],G=z>0?X[z-1]:"",q=z+1<X.length?X[z+1]:"";if(/^(?:`{3,}|~{3,})/.test(Q.trim())){Y=!Y;continue}if(Y)continue;let U=/^#{1,6}\s/.test(Q),W=z+1<X.length&&/^(?:=+|-+)\s*$/.test(q)&&Q.trim().length>0;if(U){if(z>0&&G.trim().length>0)Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"markdown/blanks-around-headings",message:"Headings should be surrounded by blank lines",severity:"error"});if(z+1<X.length&&q.trim().length>0&&!/^#{1,6}\s/.test(q))Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"markdown/blanks-around-headings",message:"Headings should be surrounded by blank lines",severity:"error"})}if(W){if(z>0&&G.trim().length>0)Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"markdown/blanks-around-headings",message:"Headings should be surrounded by blank lines",severity:"error"});let K=z+2<X.length?X[z+2]:"";if(z+2<X.length&&K.trim().length>0)Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"markdown/blanks-around-headings",message:"Headings should be surrounded by blank lines",severity:"error"})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=[],X=!1;for(let Y=0;Y<J.length;Y++){let z=J[Y],Q=Y>0?J[Y-1]:"",G=Y+1<J.length?J[Y+1]:"";if(/^(?:`{3,}|~{3,})/.test(z.trim())){X=!X,Z.push(z);continue}if(X){Z.push(z);continue}let q=/^#{1,6}\s/.test(z),U=Y+1<J.length&&/^(?:=+|-+)\s*$/.test(G)&&z.trim().length>0;if(q||U){if(Y>0&&Q.trim().length>0&&Z.length>0)Z.push("")}if(Z.push(z),q){if(Y+1<J.length&&G.trim().length>0&&!/^#{1,6}\s/.test(G))Z.push("")}if(Y>0&&/^(?:=+|-+)\s*$/.test(z)&&J[Y-1].trim().length>0){if((Y+1<J.length?J[Y+1]:"").trim().length>0)Z.push("")}}return Z.join(`
81
81
  `)}};var sZ={meta:{docs:"Lists should be surrounded by blank lines"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=!1;for(let Q=0;Q<X.length;Q++){let G=X[Q],q=Q>0?X[Q-1]:"";if(/^(?:`{3,}|~{3,})/.test(G.trim())){if(z=!z,Y)Y=!1;continue}if(z)continue;let U=/^(?:\s*)(?:[*\-+]|\d+\.)\s+/.test(G),W=Y&&!U&&G.trim().length>0&&/^\s+/.test(G);if(U&&!Y){if(Y=!0,Q>0&&q.trim().length>0)Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"markdown/blanks-around-lists",message:"Lists should be surrounded by blank lines",severity:"error"})}else if(!U&&!W&&Y&&G.trim().length>0){if(Y=!1,/^(?:\s*)(?:[*\-+]|\d+\.)\s+/.test(q))Z.push({filePath:J.filePath,line:Q,column:1,ruleId:"markdown/blanks-around-lists",message:"Lists should be surrounded by blank lines",severity:"error"})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=[],X=!1,Y=!1,z=(Q)=>/^(?:\s*)(?:[*\-+]|\d+\.)\s+/.test(Q);for(let Q=0;Q<J.length;Q++){let G=J[Q],q=Q>0?J[Q-1]:"";if(/^(?:`{3,}|~{3,})/.test(G.trim())){Y=!Y,X=!1,Z.push(G);continue}if(Y){Z.push(G);continue}let U=z(G),W=G.trim().length===0,K=X&&!U&&!W&&/^\s/.test(G);if(U&&!X){if(Q>0&&q.trim().length>0&&Z.length>0)Z.push("");X=!0}else if(!U&&!K&&!W&&X){if(X=!1,Z.length>0)Z.push("")}else if(W){let H=Q+1<J.length?J[Q+1]:"",V=z(H),A=/^\s+\S/.test(H);if(!V&&!A&&X)X=!1}Z.push(G)}return Z.join(`
82
- `)}};function m($){let J=new Set,Z=null,X=0,Y=!1,z=!1;for(let Q=0;Q<$.length;Q++){let G=$[Q],q=G.trim();if(Z===null){let H=q.match(/^(`{3,}|~{3,})(.*)$/);if(H){let V=H[1],A=H[2],_=V[0];if(_==="`"&&A.includes("`"));else{Z=_,X=V.length,J.add(Q),Y=!1,z=!1;continue}}}else{J.add(Q);let H=q.match(/^(`{3,}|~{3,})\s*$/);if(H&&H[1][0]===Z&&H[1].length>=X)Z=null,X=0;continue}let U=G.length-G.trimStart().length,W=/^\t/.test(G);if((U>=4||W)&&q.length>0){if(z||Y||Q===0)J.add(Q),z=!0;Y=z;continue}if(q.length===0){if(z)J.add(Q),Y=!0;else Y=!0;continue}z=!1,Y=!1}return J}function nZ($,J,Z){let X=0,Y=0;while(X<$.length){if($[X]!=="`"){X++;continue}let z=0;while($[X+z]==="`")z++;let Q=X+z,G=-1;while(Q<$.length)if($[Q]==="`"){let q=0;while($[Q+q]==="`")q++;if(q===z){G=Q;break}Q+=q}else Q++;if(G===-1){X+=z;continue}if(Y<X)J($.slice(Y,X));Z($.slice(X,G+z)),X=G+z,Y=X}if(Y<$.length)J($.slice(Y))}function L8($,J){let Z="";return nZ($,(X)=>{Z+=J(X)},(X)=>{Z+=X}),Z}function R7($){let J="";return nZ($,(Z)=>{J+=Z},(Z)=>{J+=" ".repeat(Z.length)}),J}function Z1($){let J=new Set,Z=m($);for(let X=0;X<$.length;X++){if(Z.has(X))continue;let Y=$[X];if(!JG(Y))continue;if(X>0&&!Z.has(X-1)&&/\|/.test($[X-1])&&$[X-1].trim().length>0)J.add(X-1);J.add(X);for(let z=X+1;z<$.length;z++){if(Z.has(z))break;let Q=$[z];if(Q.trim().length===0||!/\|/.test(Q))break;J.add(z)}}return J}function JG($){let J=$.trim();if(!J.includes("|"))return!1;if(!/^[|\s:-]+$/.test(J))return!1;if(!/-{3,}/.test(J))return!1;return!0}var iZ={meta:{docs:"Tables should be surrounded by blank lines"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=!1,Q=Z1(X);for(let G=0;G<X.length;G++){let q=X[G],U=G>0?X[G-1]:"";if(/^(?:`{3,}|~{3,})/.test(q.trim())){if(z=!z,Y)Y=!1;continue}if(z)continue;let W=Q.has(G)&&/\|/.test(q)&&q.trim().length>0;if(W&&!Y){if(Y=!0,G>0&&U.trim().length>0)Z.push({filePath:J.filePath,line:G+1,column:1,ruleId:"markdown/blanks-around-tables",message:"Tables should be surrounded by blank lines",severity:"error"})}else if(!W&&Y){if(Y=!1,q.trim().length>0)Z.push({filePath:J.filePath,line:G+1,column:1,ruleId:"markdown/blanks-around-tables",message:"Tables should be surrounded by blank lines",severity:"error"})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=m(J),X=Z1(J),Y=[],z=!1;for(let G=0;G<J.length;G++){let q=J[G];if(Z.has(G)){Y.push(q);continue}let U=X.has(G)&&/\|/.test(q)&&q.trim().length>0;if(U&&!z){let W=Y.length-1;if(W>=0&&Y[W].trim().length>0)Y.push("");z=!0,Y.push(q);continue}if(!U&&z){if(z=!1,q.trim().length>0)Y.push("")}Y.push(q)}let Q=Y.join(`
82
+ `)}};function m($){let J=new Set,Z=null,X=0,Y=!1,z=!1;for(let Q=0;Q<$.length;Q++){let G=$[Q],q=G.trim();if(Z===null){let H=q.match(/^(`{3,}|~{3,})(.*)$/);if(H){let V=H[1],A=H[2],_=V[0];if(_==="`"&&A.includes("`"));else{Z=_,X=V.length,J.add(Q),Y=!1,z=!1;continue}}}else{J.add(Q);let H=q.match(/^(`{3,}|~{3,})\s*$/);if(H&&H[1][0]===Z&&H[1].length>=X)Z=null,X=0;continue}let U=G.length-G.trimStart().length,W=/^\t/.test(G);if((U>=4||W)&&q.length>0){if(z||Y||Q===0)J.add(Q),z=!0;Y=z;continue}if(q.length===0){if(z)J.add(Q),Y=!0;else Y=!0;continue}z=!1,Y=!1}return J}function nZ($,J,Z){let X=0,Y=0;while(X<$.length){if($[X]!=="`"){X++;continue}let z=0;while($[X+z]==="`")z++;let Q=X+z,G=-1;while(Q<$.length)if($[Q]==="`"){let q=0;while($[Q+q]==="`")q++;if(q===z){G=Q;break}Q+=q}else Q++;if(G===-1){X+=z;continue}if(Y<X)J($.slice(Y,X));Z($.slice(X,G+z)),X=G+z,Y=X}if(Y<$.length)J($.slice(Y))}function L8($,J){let Z="";return nZ($,(X)=>{Z+=J(X)},(X)=>{Z+=X}),Z}function R7($){let J="";return nZ($,(Z)=>{J+=Z},(Z)=>{J+=" ".repeat(Z.length)}),J}function J1($){let J=new Set,Z=m($);for(let X=0;X<$.length;X++){if(Z.has(X))continue;let Y=$[X];if(!JG(Y))continue;if(X>0&&!Z.has(X-1)&&/\|/.test($[X-1])&&$[X-1].trim().length>0)J.add(X-1);J.add(X);for(let z=X+1;z<$.length;z++){if(Z.has(z))break;let Q=$[z];if(Q.trim().length===0||!/\|/.test(Q))break;J.add(z)}}return J}function JG($){let J=$.trim();if(!J.includes("|"))return!1;if(!/^[|\s:-]+$/.test(J))return!1;if(!/-{3,}/.test(J))return!1;return!0}var iZ={meta:{docs:"Tables should be surrounded by blank lines"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=!1,Q=J1(X);for(let G=0;G<X.length;G++){let q=X[G],U=G>0?X[G-1]:"";if(/^(?:`{3,}|~{3,})/.test(q.trim())){if(z=!z,Y)Y=!1;continue}if(z)continue;let W=Q.has(G)&&/\|/.test(q)&&q.trim().length>0;if(W&&!Y){if(Y=!0,G>0&&U.trim().length>0)Z.push({filePath:J.filePath,line:G+1,column:1,ruleId:"markdown/blanks-around-tables",message:"Tables should be surrounded by blank lines",severity:"error"})}else if(!W&&Y){if(Y=!1,q.trim().length>0)Z.push({filePath:J.filePath,line:G+1,column:1,ruleId:"markdown/blanks-around-tables",message:"Tables should be surrounded by blank lines",severity:"error"})}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=m(J),X=J1(J),Y=[],z=!1;for(let G=0;G<J.length;G++){let q=J[G];if(Z.has(G)){Y.push(q);continue}let U=X.has(G)&&/\|/.test(q)&&q.trim().length>0;if(U&&!z){let W=Y.length-1;if(W>=0&&Y[W].trim().length>0)Y.push("");z=!0,Y.push(q);continue}if(!U&&z){if(z=!1,q.trim().length>0)Y.push("")}Y.push(q)}let Q=Y.join(`
83
83
  `);return Q!==$?Q:$}};var tZ={meta:{docs:"Code block style should be consistent"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).style||"consistent",Q=null,G=!1;for(let q=0;q<X.length;q++){let U=X[q];if(/^(?:`{3,}|~{3,})/.test(U)){if(G=!G,z==="indented")Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/code-block-style",message:"Expected indented code block style",severity:"error"});else if(z==="consistent"){if(Q===null)Q="fenced";else if(Q==="indented")Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/code-block-style",message:"Code block style should be consistent throughout document",severity:"error"})}continue}if(G)continue;if(/^(?: {4}|\t)/.test(U)&&U.trim().length>0){let V=(q>0?X[q-1]:"").trim().length===0||q===0;if(V&&z==="fenced")Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/code-block-style",message:"Expected fenced code block style",severity:"error"});else if(V&&z==="consistent"){if(Q===null)Q="indented";else if(Q==="fenced")Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/code-block-style",message:"Code block style should be consistent throughout document",severity:"error"})}}}return Z}};function eZ($){let J=new Set,Z=null,X=0;for(let Y=0;Y<$.length;Y++){let z=$[Y].trim();if(Z===null){let Q=z.match(/^(`{3,}|~{3,})(.*)$/);if(Q){let G=Q[1][0];if(G==="`"&&Q[2].includes("`"))continue;Z=G,X=Q[1].length,J.add(Y)}}else{let Q=z.match(/^(`{3,}|~{3,})\s*$/);if(Q&&Q[1][0]===Z&&Q[1].length>=X)J.add(Y),Z=null,X=0}}return J}var $J={meta:{docs:"Code fence style should be consistent (backtick or tilde)"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=eZ(X),Q=(J.options||{}).style||"consistent",G=null;for(let q of Y){let U=X[q],K=/^`{3,}/.test(U.trim())?"backtick":"tilde";if(Q==="backtick"||Q==="tilde"){if(K!==Q)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/code-fence-style",message:Q==="tilde"?"Expected tilde (~~~) code fence":"Expected backtick (```) code fence",severity:"error"})}else if(Q==="consistent"){if(G===null)G=K;else if(G!==K)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/code-fence-style",message:"Code fence style should be consistent throughout document",severity:"error"})}}return Z},fix:($,J)=>{let X=(J.options||{}).style||"consistent",Y=$.split(/\r?\n/),z=eZ(Y),Q="backtick";if(X==="backtick"||X==="tilde")Q=X;else for(let W of z){Q=/^`{3,}/.test(Y[W].trim())?"backtick":"tilde";break}let G=Q==="backtick"?"`":"~",q=Q==="backtick"?/^(\s*)(~{3,})(.*)$/:/^(\s*)(`{3,})(.*)$/;return Y.map((W,K)=>{if(!z.has(K))return W;return W.replace(q,(H,V,A,_)=>`${V}${G.repeat(A.length)}${_}`)}).join(`
84
84
  `)}};var ZJ={meta:{docs:"Commands in code blocks should not be prefixed with $ unless showing output"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=-1;for(let Q=0;Q<X.length;Q++){let G=X[Q];if(/^(?:`{3,}|~{3,})/.test(G)){if(!Y)Y=!0,z=Q;else Y=!1;continue}if(Y&&/^\$\s+/.test(G.trim())){let q=!0,U=!1;for(let W=z+1;W<Q;W++){let K=X[W].trim();if(K.length>0){if(U=!0,!K.startsWith("$")){q=!1;break}}}if(q&&U)Z.push({filePath:J.filePath,line:Q+1,column:G.indexOf("$")+1,ruleId:"markdown/commands-show-output",message:"Dollar signs used before commands without showing output",severity:"warning"})}}return Z}};var JJ={meta:{docs:"Link text should be meaningful and descriptive"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=["click here","here","link","read more","more","this"],z=!1;for(let Q=0;Q<X.length;Q++){let G=X[Q];if(/^(?:`{3,}|~{3,})/.test(G.trim())){z=!z;continue}if(z)continue;let U=G.replace(/``[^`]+``/g,(W)=>" ".repeat(W.length)).replace(/`[^`]+`/g,(W)=>" ".repeat(W.length)).matchAll(/\[([^\]]+)\]\([^)]+\)/g);for(let W of U){let K=W[1].toLowerCase().trim();if(Y.includes(K)){let H=W.index+1;Z.push({filePath:J.filePath,line:Q+1,column:H,ruleId:"markdown/descriptive-link-text",message:`Link text '${W[1]}' is not descriptive`,severity:"warning"})}}}return Z}};var XG=/(?<!\*)\*(?!\*)([^*]+)\*(?!\*)/,YG=/(?<!_)_(?!_)([^_]+)_(?!_)/,XJ={meta:{docs:"Emphasis style should be consistent (asterisk or underscore)"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).style||"consistent",Q=null,G=m(X);for(let q=0;q<X.length;q++){let U=X[q];if(G.has(q))continue;let W=R7(U),K=W.matchAll(/(?<!\*)\*(?!\*)([^*]+)\*(?!\*)/g);for(let V of K)if(z==="underscore")Z.push({filePath:J.filePath,line:q+1,column:V.index+1,ruleId:"markdown/emphasis-style",message:"Expected underscore (_) for emphasis",severity:"error"});else if(z==="consistent"){if(Q===null)Q="asterisk";else if(Q==="underscore")Z.push({filePath:J.filePath,line:q+1,column:V.index+1,ruleId:"markdown/emphasis-style",message:"Emphasis style should be consistent throughout document",severity:"error"})}let H=W.matchAll(/(?<!_)_(?!_)([^_]+)_(?!_)/g);for(let V of H)if(z==="asterisk")Z.push({filePath:J.filePath,line:q+1,column:V.index+1,ruleId:"markdown/emphasis-style",message:"Expected asterisk (*) for emphasis",severity:"error"});else if(z==="consistent"){if(Q===null)Q="underscore";else if(Q==="asterisk")Z.push({filePath:J.filePath,line:q+1,column:V.index+1,ruleId:"markdown/emphasis-style",message:"Emphasis style should be consistent throughout document",severity:"error"})}}return Z},fix:($,J)=>{let X=(J.options||{}).style||"consistent",Y=$.split(/\r?\n/),z=m(Y),Q="asterisk";if(X==="asterisk")Q="asterisk";else if(X==="underscore")Q="underscore";else if(X==="consistent"){let q=null,U=null;for(let K=0;K<Y.length;K++){if(z.has(K))continue;let H=R7(Y[K]);if(q===null){let V=H.match(XG);if(V)q={line:K,col:V.index}}if(U===null){let V=H.match(YG);if(V)U={line:K,col:V.index}}if(q&&U)break}if(q&&(!U||((K,H)=>K.line!==H.line?K.line-H.line:K.col-H.col)(q,U)<0))Q="asterisk";else if(U)Q="underscore"}let G=!1;for(let q=0;q<Y.length;q++){if(z.has(q))continue;let U=L8(Y[q],(W)=>Q==="asterisk"?W.replace(/(?<!_)_(?!_)([^_]+)_(?!_)/g,"*$1*"):W.replace(/(?<!\*)\*(?!\*)([^*]+)\*(?!\*)/g,"_$1_"));if(U!==Y[q])Y[q]=U,G=!0}return G?Y.join(`
85
85
  `):$}};var YJ={meta:{docs:"Fenced code blocks should have a language specified"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++)if(X[Y].match(/^(?:`{3,}|~{3,})\s*$/)){let G=!0;for(let q=Y-1;q>=0;q--)if(/^(?:`{3,}|~{3,})/.test(X[q])){G=!1;break}if(G)Z.push({filePath:J.filePath,line:Y+1,column:1,ruleId:"markdown/fenced-code-language",message:"Fenced code blocks should have a language specified",severity:"error"})}return Z}};var zJ={meta:{docs:"First line in a file should be a top-level heading"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=-1;for(let q=0;q<X.length;q++)if(X[q].trim().length>0){Y=q;break}if(Y===-1)return Z;let z=X[Y],Q=/^#\s/.test(z),G=Y+1<X.length&&/^=+\s*$/.test(X[Y+1]);if(!Q&&!G)Z.push({filePath:J.filePath,line:Y+1,column:1,ruleId:"markdown/first-line-heading",message:"First line in a file should be a top-level heading",severity:"warning"});return Z}};var QJ={meta:{docs:"Heading levels should only increment by one level at a time"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=m(X),z=0;for(let Q=0;Q<X.length;Q++){if(Y.has(Q))continue;let q=X[Q].match(/^(#{1,6})\s/);if(q){let U=q[1].length;if(z>0&&U>z+1)Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"markdown/heading-increment",message:`Heading level should not skip from h${z} to h${U}`,severity:"error"});z=U}}return Z},fix:($)=>{let J=$.split(/\r?\n/),Z=m(J),X=0,Y=!1;for(let z=0;z<J.length;z++){if(Z.has(z))continue;let G=J[z].match(/^(#{1,6})(\s.*)$/);if(!G)continue;let q=G[1].length,U=X===0?q:Math.min(q,X+1);if(U!==q)J[z]="#".repeat(U)+G[2],Y=!0;X=U}return Y?J.join(`
@@ -110,7 +110,7 @@ ${q.slice(b.from+1,b.to+1).join(`
110
110
  \r
111
111
  `)){let X=$.split(/\r?\n/);Z.push({filePath:J.filePath,line:X.length,column:1,ruleId:"markdown/single-trailing-newline",message:"File should end with a single newline character (not multiple)",severity:"error"})}return Z},fix:($)=>{return`${$.replace(/[\r\n]+$/,"")}
112
112
  `}};var dJ={meta:{docs:"Strong style should be consistent (asterisk or underscore)"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=m(X),Q=(J.options||{}).style||"consistent",G=null;for(let q=0;q<X.length;q++){if(Y.has(q))continue;let U=X[q],W=U.matchAll(/\*\*([^*]+)\*\*/g);for(let H of W)if(Q==="underscore")Z.push({filePath:J.filePath,line:q+1,column:H.index+1,ruleId:"markdown/strong-style",message:"Expected underscore (__) for strong",severity:"error"});else if(Q==="consistent"){if(G===null)G="asterisk";else if(G==="underscore")Z.push({filePath:J.filePath,line:q+1,column:H.index+1,ruleId:"markdown/strong-style",message:"Strong style should be consistent throughout document",severity:"error"})}let K=U.matchAll(/__([^_]+)__/g);for(let H of K)if(Q==="asterisk")Z.push({filePath:J.filePath,line:q+1,column:H.index+1,ruleId:"markdown/strong-style",message:"Expected asterisk (**) for strong",severity:"error"});else if(Q==="consistent"){if(G===null)G="underscore";else if(G==="asterisk")Z.push({filePath:J.filePath,line:q+1,column:H.index+1,ruleId:"markdown/strong-style",message:"Strong style should be consistent throughout document",severity:"error"})}}return Z},fix:($,J)=>{let X=(J.options||{}).style||"consistent",Y=$.split(/\r?\n/),z=m(Y),Q="asterisk";if(X==="asterisk")Q="asterisk";else if(X==="underscore")Q="underscore";else if(X==="consistent"){let q=null,U=null;for(let K=0;K<Y.length;K++){if(z.has(K))continue;if(q===null){let H=Y[K].match(/\*\*([^*]+)\*\*/);if(H)q={line:K,col:H.index}}if(U===null){let H=Y[K].match(/__([^_]+)__/);if(H)U={line:K,col:H.index}}if(q&&U)break}if(q&&(!U||((K,H)=>K.line!==H.line?K.line-H.line:K.col-H.col)(q,U)<0))Q="asterisk";else if(U)Q="underscore"}let G=!1;for(let q=0;q<Y.length;q++){if(z.has(q))continue;let U=Y[q],W=Q==="asterisk"?U.replace(/__([^_]+)__/g,"**$1**"):U.replace(/\*\*([^*]+)\*\*/g,"__$1__");if(W!==U)Y[q]=W,G=!0}return G?Y.join(`
113
- `):$}};var oJ={meta:{docs:"Table rows should have consistent column counts"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=-1,Q=!1,G=Z1(X);for(let q=0;q<X.length;q++){let U=X[q];if(/^(?:`{3,}|~{3,})/.test(U.trim())){if(Q=!Q,Y)Y=!1,z=-1;continue}if(Q)continue;let W=G.has(q)&&/\|/.test(U)&&U.trim().length>0;if(W){let K=GG(U);if(!Y)Y=!0,z=K;else if(K!==z)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/table-column-count",message:`Table row has ${K} column(s), expected ${z}`,severity:"error"})}else if(U.trim().length===0||!W){if(Y)Y=!1,z=-1}}return Z}};function GG($){let J=$.trim();if(J.startsWith("|"))J=J.slice(1);if(J.endsWith("|")&&!J.endsWith("\\|"))J=J.slice(0,-1);if(J==="")return 0;let Z=1,X=!1,Y=0,z=0;while(z<J.length){let Q=J[z];if(Q==="\\"&&J[z+1]==="|"){z+=2;continue}if(Q==="`"){let G=0;while(J[z+G]==="`")G++;if(!X)X=!0,Y=G;else if(G===Y)X=!1,Y=0;z+=G;continue}if(!X&&Q==="|")Z++;z++}return Z}var cJ={meta:{docs:"Table columns should have consistent alignment"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(/[-:]/.test(z)&&/\|/.test(z)){if(z.match(/^[|\s:.-]+$/)){let G=z.split("|").filter((q)=>q.trim().length>0);for(let q of G){let U=q.trim();if(!/^:?-+:?$/.test(U))Z.push({filePath:J.filePath,line:Y+1,column:z.indexOf(q)+1,ruleId:"markdown/table-column-style",message:"Invalid table column separator",severity:"error"})}}}}return Z}};var rJ={meta:{docs:"Table pipe style should be consistent"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).style||"leading_and_trailing",Q=!1,G=Z1(X);for(let q=0;q<X.length;q++){let U=X[q];if(/^(?:`{3,}|~{3,})/.test(U.trim())){Q=!Q;continue}if(Q)continue;if(G.has(q)&&/\|/.test(U)&&U.trim().length>0){let W=U.trim().startsWith("|"),K=U.trim().endsWith("|");if(z==="leading_and_trailing"){if(!W||!K)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should have leading and trailing pipes",severity:"error"})}else if(z==="leading_only"){if(!W||K)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should have leading pipe only",severity:"error"})}else if(z==="trailing_only"){if(W||!K)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should have trailing pipe only",severity:"error"})}else if(z==="no_leading_or_trailing"){if(W||K)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should not have leading or trailing pipes",severity:"error"})}}}return Z}};var lJ={meta:{docs:"Unordered list indentation should be consistent"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).indent||2,Q=!1,G=[];for(let q=0;q<X.length;q++){let U=X[q];if(/^(?:`{3,}|~{3,})/.test(U.trim())){Q=!Q;continue}if(Q)continue;if(U.trim()==="")continue;let W=U.match(/^(\s*)([*\-+])(\s+)/),K=U.match(/^(\s*)(\d+[.)])(\s+)/);if(!W&&!K){let j=U.match(/^(\s*)/)?.[1].length||0;while(G.length>0&&G[G.length-1].contentCol>j)G.pop();continue}let H=W||K,V=H[1].length,A=H[2],_=H[3],F=V+A.length+_.length,B=W?"ul":"ol";while(G.length>0&&V<G[G.length-1].contentCol)G.pop();if(B==="ul"){let j=G.length>0?G[G.length-1]:null;if(!j){if(V!==0&&V%z!==0)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/ul-indent",message:`Unordered list indentation should be ${z} spaces per level. Found ${V} spaces`,severity:"error"})}else if(j.type==="ul"){let D=j.contentCol,M=j.indent+z;if(V!==D&&V!==M)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/ul-indent",message:`Unordered list indentation should be ${z} spaces per level. Found ${V} spaces`,severity:"error"})}}G.push({indent:V,contentCol:F,type:B})}return Z}};var aJ={meta:{docs:"Unordered list style should be consistent"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=m(X),Q=(J.options||{}).style||"consistent",G=null;for(let q=0;q<X.length;q++){let U=X[q];if(Y.has(q))continue;let W=U.match(/^(\s*)([*\-+])\s+/);if(W){let K=W[2];if(Q==="asterisk"&&K!=="*")Z.push({filePath:J.filePath,line:q+1,column:W[1].length+1,ruleId:"markdown/ul-style",message:`Expected asterisk (*) for unordered list, found '${K}'`,severity:"error"});else if(Q==="dash"&&K!=="-")Z.push({filePath:J.filePath,line:q+1,column:W[1].length+1,ruleId:"markdown/ul-style",message:`Expected dash (-) for unordered list, found '${K}'`,severity:"error"});else if(Q==="plus"&&K!=="+")Z.push({filePath:J.filePath,line:q+1,column:W[1].length+1,ruleId:"markdown/ul-style",message:`Expected plus (+) for unordered list, found '${K}'`,severity:"error"});else if(Q==="consistent"){if(G===null)G=K;else if(G!==K)Z.push({filePath:J.filePath,line:q+1,column:W[1].length+1,ruleId:"markdown/ul-style",message:`Unordered list style should be consistent throughout document. Expected '${G}', found '${K}'`,severity:"error"})}}}return Z},fix:($,J)=>{let X=(J.options||{}).style||"consistent",Y=$.split(/\r?\n/),z=m(Y),Q="*";if(X==="asterisk")Q="*";else if(X==="dash")Q="-";else if(X==="plus")Q="+";else if(X==="consistent")for(let q=0;q<Y.length;q++){if(z.has(q))continue;let U=Y[q].match(/^(\s*)([*\-+])\s+/);if(U){Q=U[2];break}}return Y.map((q,U)=>{if(z.has(U))return q;return q.replace(/^(\s*)([*\-+])(\s+)/,`$1${Q}$3`)}).join(`
113
+ `):$}};var oJ={meta:{docs:"Table rows should have consistent column counts"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=-1,Q=!1,G=J1(X);for(let q=0;q<X.length;q++){let U=X[q];if(/^(?:`{3,}|~{3,})/.test(U.trim())){if(Q=!Q,Y)Y=!1,z=-1;continue}if(Q)continue;let W=G.has(q)&&/\|/.test(U)&&U.trim().length>0;if(W){let K=GG(U);if(!Y)Y=!0,z=K;else if(K!==z)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/table-column-count",message:`Table row has ${K} column(s), expected ${z}`,severity:"error"})}else if(U.trim().length===0||!W){if(Y)Y=!1,z=-1}}return Z}};function GG($){let J=$.trim();if(J.startsWith("|"))J=J.slice(1);if(J.endsWith("|")&&!J.endsWith("\\|"))J=J.slice(0,-1);if(J==="")return 0;let Z=1,X=!1,Y=0,z=0;while(z<J.length){let Q=J[z];if(Q==="\\"&&J[z+1]==="|"){z+=2;continue}if(Q==="`"){let G=0;while(J[z+G]==="`")G++;if(!X)X=!0,Y=G;else if(G===Y)X=!1,Y=0;z+=G;continue}if(!X&&Q==="|")Z++;z++}return Z}var cJ={meta:{docs:"Table columns should have consistent alignment"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(/[-:]/.test(z)&&/\|/.test(z)){if(z.match(/^[|\s:.-]+$/)){let G=z.split("|").filter((q)=>q.trim().length>0);for(let q of G){let U=q.trim();if(!/^:?-+:?$/.test(U))Z.push({filePath:J.filePath,line:Y+1,column:z.indexOf(q)+1,ruleId:"markdown/table-column-style",message:"Invalid table column separator",severity:"error"})}}}}return Z}};var rJ={meta:{docs:"Table pipe style should be consistent"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).style||"leading_and_trailing",Q=!1,G=J1(X);for(let q=0;q<X.length;q++){let U=X[q];if(/^(?:`{3,}|~{3,})/.test(U.trim())){Q=!Q;continue}if(Q)continue;if(G.has(q)&&/\|/.test(U)&&U.trim().length>0){let W=U.trim().startsWith("|"),K=U.trim().endsWith("|");if(z==="leading_and_trailing"){if(!W||!K)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should have leading and trailing pipes",severity:"error"})}else if(z==="leading_only"){if(!W||K)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should have leading pipe only",severity:"error"})}else if(z==="trailing_only"){if(W||!K)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should have trailing pipe only",severity:"error"})}else if(z==="no_leading_or_trailing"){if(W||K)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should not have leading or trailing pipes",severity:"error"})}}}return Z}};var lJ={meta:{docs:"Unordered list indentation should be consistent"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),z=(J.options||{}).indent||2,Q=!1,G=[];for(let q=0;q<X.length;q++){let U=X[q];if(/^(?:`{3,}|~{3,})/.test(U.trim())){Q=!Q;continue}if(Q)continue;if(U.trim()==="")continue;let W=U.match(/^(\s*)([*\-+])(\s+)/),K=U.match(/^(\s*)(\d+[.)])(\s+)/);if(!W&&!K){let j=U.match(/^(\s*)/)?.[1].length||0;while(G.length>0&&G[G.length-1].contentCol>j)G.pop();continue}let H=W||K,V=H[1].length,A=H[2],_=H[3],F=V+A.length+_.length,B=W?"ul":"ol";while(G.length>0&&V<G[G.length-1].contentCol)G.pop();if(B==="ul"){let j=G.length>0?G[G.length-1]:null;if(!j){if(V!==0&&V%z!==0)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/ul-indent",message:`Unordered list indentation should be ${z} spaces per level. Found ${V} spaces`,severity:"error"})}else if(j.type==="ul"){let D=j.contentCol,M=j.indent+z;if(V!==D&&V!==M)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"markdown/ul-indent",message:`Unordered list indentation should be ${z} spaces per level. Found ${V} spaces`,severity:"error"})}}G.push({indent:V,contentCol:F,type:B})}return Z}};var aJ={meta:{docs:"Unordered list style should be consistent"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=m(X),Q=(J.options||{}).style||"consistent",G=null;for(let q=0;q<X.length;q++){let U=X[q];if(Y.has(q))continue;let W=U.match(/^(\s*)([*\-+])\s+/);if(W){let K=W[2];if(Q==="asterisk"&&K!=="*")Z.push({filePath:J.filePath,line:q+1,column:W[1].length+1,ruleId:"markdown/ul-style",message:`Expected asterisk (*) for unordered list, found '${K}'`,severity:"error"});else if(Q==="dash"&&K!=="-")Z.push({filePath:J.filePath,line:q+1,column:W[1].length+1,ruleId:"markdown/ul-style",message:`Expected dash (-) for unordered list, found '${K}'`,severity:"error"});else if(Q==="plus"&&K!=="+")Z.push({filePath:J.filePath,line:q+1,column:W[1].length+1,ruleId:"markdown/ul-style",message:`Expected plus (+) for unordered list, found '${K}'`,severity:"error"});else if(Q==="consistent"){if(G===null)G=K;else if(G!==K)Z.push({filePath:J.filePath,line:q+1,column:W[1].length+1,ruleId:"markdown/ul-style",message:`Unordered list style should be consistent throughout document. Expected '${G}', found '${K}'`,severity:"error"})}}}return Z},fix:($,J)=>{let X=(J.options||{}).style||"consistent",Y=$.split(/\r?\n/),z=m(Y),Q="*";if(X==="asterisk")Q="*";else if(X==="dash")Q="-";else if(X==="plus")Q="+";else if(X==="consistent")for(let q=0;q<Y.length;q++){if(z.has(q))continue;let U=Y[q].match(/^(\s*)([*\-+])\s+/);if(U){Q=U[2];break}}return Y.map((q,U)=>{if(z.has(U))return q;return q.replace(/^(\s*)([*\-+])(\s+)/,`$1${Q}$3`)}).join(`
114
114
  `)}};function qG($){let J=$.split(/\r?\n/);if(J[0]?.trim()!=="---")return{text:$,frontmatter:null,frontmatterEndLine:0};for(let Z=1;Z<J.length;Z++)if(J[Z].trim()==="---"){let X=J.slice(0,Z+1);return{text:[...X.map(()=>""),...J.slice(Z+1)].join(`
115
115
  `),frontmatter:X,frontmatterEndLine:Z+1}}return{text:$,frontmatter:null,frontmatterEndLine:0}}function UG($){let J=$.split(/\r?\n/);if(J[0]?.trim()!=="---")return{header:null,body:$};for(let Z=1;Z<J.length;Z++)if(J[Z].trim()==="---")return{header:J.slice(0,Z+1).join(`
116
116
  `),body:J.slice(Z+1).join(`
@@ -119,9 +119,9 @@ ${z}`}:void 0}}var sJ={name:"markdown",rules:{"heading-increment":l(QJ),"heading
119
119
  `),G=Z.slice(X).join(`
120
120
  `),q=`${Q}
121
121
  ${G}`;if(L7(q)!==q)return[{filePath:J.filePath,line:Y+1,column:1,ruleId:"sort-imports",message:"Imports are not sorted/grouped consistently",severity:"warning"}];return[]},fix:($)=>L7($)};var eJ={name:"perfectionist",rules:{"sort-imports":w(P8)}};import{dirname as KG,resolve as HG}from"path";function t($){try{let J=JSON.parse($);if(typeof J!=="object"||J===null||Array.isArray(J))return null;return J}catch{return null}}function VG($,J){let Z=$.split(`
122
- `),X=1,Y=0;for(let z of J){let Q=new RegExp(`"${BG(z)}"\\s*:`);for(let G=Y;G<Z.length;G++)if(Q.test(Z[G])){X=G+1,Y=G+1;break}}return X}function h0($){return KG($)}function I0($,J){return HG($,J)}function $0($){let J="pkg";for(let Z of $)if(/^\d+$/.test(Z))J+=`[${Z}]`;else if(!/^[a-z_$][a-z0-9_$]*$/i.test(Z))J+=`["${Z}"]`;else J+=`.${Z}`;return J}function i($,J){if($.publishConfig?.[J]!==void 0)return[$.publishConfig[J],["publishConfig",J]];return[$[J],[J]]}var AG=new RegExp(`(?:[\\s;]|^)(?:import[\\w,{}\\s*]*from|import\\s*['"*{]|export\\b\\s*(?:[*{]|default|type|function|const|var|let|async function)|import\\.meta\\b)`,"m"),_G=new RegExp("(?:[\\s;]|^)(?:module.exports\\b|exports\\.\\w|require\\s*\\(|global\\.\\w|Object\\.(?:defineProperty|defineProperties|assign)\\s*\\(\\s*exports\\b)","m");function J1($){let J=FG($),Z=AG.test(J),X=_G.test(J);if(Z&&X)return"mixed";if(Z)return"ESM";if(X)return"CJS";return"unknown"}function $X($,J){if($.endsWith(".mjs"))return"ESM";if($.endsWith(".cjs"))return"CJS";return J==="module"?"ESM":"CJS"}function ZX($){if($==="ESM")return".mjs";if($==="CJS")return".cjs";return".js"}function JX($){return $===".mjs"||$===".cjs"}function a0($){return $.endsWith(".js")||$.endsWith(".mjs")||$.endsWith(".cjs")}function XX($){return/^#!\s*\//.test($)}function FG($){return $.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*/g,"")}function U0($,J,Z,X){P7($,J,Z,X)}function P7($,J,Z,X){if(typeof $==="string"){X($,{path:J,isImports:Z});return}if(Array.isArray($)){X($,{path:J,isImports:Z});for(let Y=0;Y<$.length;Y++)P7($[Y],J.concat(String(Y)),Z,X);return}if($!==null&&typeof $==="object"){let Y=Object.keys($);X($,{path:J,isImports:Z},Y);for(let z of Y)P7($[z],J.concat(z),Z,X)}}function n($,J,Z,X,Y,z,Q){return{filePath:$,line:VG(J,Z),column:1,ruleId:X,message:Y,severity:z,...Q&&{help:Q}}}function BG($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var C7={meta:{docs:"Disallow deprecated jsnext:main and jsnext fields",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[];if(Z["jsnext:main"]!=null)X.push(n(J.filePath,$,["jsnext:main"],"publint/deprecated-field-jsnext",'pkg["jsnext:main"] is deprecated. pkg.module should be used instead.',"warning",'The jsnext:main field is no longer recognized by modern bundlers. Use "module" instead.'));if(Z.jsnext!=null)X.push(n(J.filePath,$,["jsnext"],"publint/deprecated-field-jsnext","pkg.jsnext is deprecated. pkg.module should be used instead.","warning",'The jsnext field is no longer recognized by modern bundlers. Use "module" instead.'));return X}};var I7={meta:{docs:'Ensure "default" condition is last in exports objects',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"exports");if(Y==null)return[];return U0(Y,z,!1,(Q,G,q)=>{if(!q||typeof Q!=="object"||Array.isArray(Q))return;if(!("default"in Q))return;if(q[q.length-1]!=="default")X.push(n(J.filePath,$,G.path.concat("default"),"publint/exports-default-should-be-last",`${$0(G.path.concat("default"))} should be the last condition in the object so it doesn't take precedence over the keys following it.`,"error",'Conditions are resolved in order. "default" acts as a fallback and should come last.'))}),X}};var S7={meta:{docs:"Warn against using fallback arrays in exports",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"exports");if(Y==null)return[];return U0(Y,z,!1,(Q,G)=>{if(!Array.isArray(Q))return;X.push(n(J.filePath,$,G.path,"publint/exports-fallback-array-use",`${$0(G.path)} uses fallback arrays which is not recommended. It works differently in some tools and may face inconsistent behaviors.`,"warning","Fallback arrays pick the first parseable value and have no practical use case in Node.js currently."))}),X}};var v7={meta:{docs:"Ensure exports has a root entrypoint when main/module exist",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let[X]=i(Z,"main"),[Y]=i(Z,"module"),[z,Q]=i(Z,"exports");if(X==null&&Y==null||z==null)return[];if(typeof z!=="object"||Array.isArray(z))return[];let G=Object.keys(z);if(G.length===0)return[];if(!G[0]?.startsWith("."))return[];if(G.includes("."))return[];let U=[];if(X)U.push("main");if(Y)U.push("module");return[n(J.filePath,$,Q,"publint/exports-missing-root-entrypoint",`${$0(Q)} is missing the root entrypoint export, which is defined in pkg.${U[0]}. Environments that support "exports" will ignore pkg.${U[0]} as "exports" takes the highest priority.`,"warning",`Add ${$0(Q.concat("."))} to ensure the root entrypoint is accessible.`)]}};var y7={meta:{docs:'Ensure "module" condition precedes "require" in exports',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"exports");if(Y==null)return[];return U0(Y,z,!1,(Q,G,q)=>{if(!q||typeof Q!=="object"||Array.isArray(Q))return;if(!("module"in Q)||!("require"in Q))return;if(q.indexOf("module")>q.indexOf("require"))X.push(n(J.filePath,$,G.path.concat("module"),"publint/exports-module-should-precede-require",`${$0(G.path.concat("module"))} should come before the "require" condition so it can take precedence when used by a bundler.`,"error",'Bundlers prioritize conditions by order. "module" should precede "require" to ensure ESM is preferred.'))}),X}};var b7={meta:{docs:'Ensure "types" condition is first in exports objects',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"exports");if(Y==null)return[];return U0(Y,z,!1,(Q,G,q)=>{if(!q||typeof Q!=="object"||Array.isArray(Q))return;if(!("types"in Q))return;let U=q.indexOf("types");if(U===0)return;if(q.slice(0,U).filter((K)=>{if(K.startsWith("types"))return!1;if(typeof Q[K]==="object"&&Q[K]!==null&&YX(Q[K],"types"))return!1;return!0}).length>0)X.push(n(J.filePath,$,G.path.concat("types"),"publint/exports-types-should-be-first",`${$0(G.path.concat("types"))} should be the first condition in the object so it can be resolved by TypeScript.`,"error",'TypeScript resolves conditions in order. The "types" condition must come first to ensure correct type resolution.'))}),X}};function YX($,J){for(let Z in $){if(Z===J)return!0;if(typeof $[Z]==="object"&&$[Z]!==null&&YX($[Z],J))return!0}return!1}var k7={meta:{docs:'Ensure exports values start with "./"',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"exports");if(Y==null)return[];return U0(Y,z,!1,(Q,G)=>{if(typeof Q!=="string")return;if(Q.startsWith("./"))return;let q=`./${Q.replace(/^[/]+/,"")}`;X.push(n(J.filePath,$,G.path,"publint/exports-value-invalid",`${$0(G.path)} is "${Q}" which is invalid as it does not start with "./". Use "${q}" instead.`,"error",'All exports values must be relative paths starting with "./".'))}),X}};var wG=[{field:"main",expectTypes:["string"]},{field:"module",expectTypes:["string"]},{field:"types",expectTypes:["string"]},{field:"typings",expectTypes:["string"]},{field:"browser",expectTypes:["string","object"]},{field:"bin",expectTypes:["string","object"]},{field:"exports",expectTypes:["string","object"]},{field:"imports",expectTypes:["object"]},{field:"name",expectTypes:["string"]},{field:"version",expectTypes:["string"]},{field:"description",expectTypes:["string"]},{field:"license",expectTypes:["string"]}],f7={meta:{docs:"Ensure package.json fields have correct value types",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[];for(let{field:Y,expectTypes:z}of wG){let[Q,G]=i(Z,Y);if(Q==null)continue;let q=typeof Q;if(!z.includes(q)){let U=z.length===1?z[0]:`${z.slice(0,-1).join(", ")} or ${z[z.length-1]}`;X.push(n(J.filePath,$,G,"publint/field-invalid-value-type",`${$0(G)} has an invalid ${q} type. Expected a ${U} type instead.`,"error",`The "${Y}" field must be of type ${U}.`))}}return X}};var g7={meta:{docs:"Suggest adding exports when module field is present",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let[X,Y]=i(Z,"module"),[z]=i(Z,"exports");if(X!=null&&z==null)return[n(J.filePath,$,Y,"publint/has-module-but-no-exports","pkg.module is used to output ESM, but pkg.exports is not defined. As Node.js doesn't read pkg.module, the ESM output may be skipped. Consider adding pkg.exports to export the ESM output.","warning",'Node.js only reads "exports" for module resolution. Without it, the ESM entry point in "module" is ignored by Node.js.')];return[]}};var x7={meta:{docs:'Ensure "default" condition is last in imports objects',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"imports");if(Y==null||typeof Y!=="object")return[];return U0(Y,z,!0,(Q,G,q)=>{if(!q||typeof Q!=="object"||Array.isArray(Q))return;if(!("default"in Q))return;if(q[q.length-1]!=="default")X.push(n(J.filePath,$,G.path.concat("default"),"publint/imports-default-should-be-last",`${$0(G.path.concat("default"))} should be the last condition in the object so it doesn't take precedence over the keys following it.`,"error",'Conditions are resolved in order. "default" acts as a fallback and should come last.'))}),X}};var p7={meta:{docs:'Ensure imports keys start with "#"',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"imports");if(Y==null||typeof Y!=="object"||Array.isArray(Y))return[];for(let Q of Object.keys(Y))if(!Q.startsWith("#")){let G=`#${Q.replace(/^[/]+/,"")}`,q=z.concat(Q);X.push(n(J.filePath,$,q,"publint/imports-key-invalid",`${$0(q)} is invalid as the imports key does not start with "#". Use "${G}" instead.`,"error",'All imports keys must start with "#" to distinguish them from package specifiers.'))}return X}};var h7={meta:{docs:'Ensure "module" condition precedes "require" in imports',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"imports");if(Y==null||typeof Y!=="object")return[];return U0(Y,z,!0,(Q,G,q)=>{if(!q||typeof Q!=="object"||Array.isArray(Q))return;if(!("module"in Q)||!("require"in Q))return;if(q.indexOf("module")>q.indexOf("require"))X.push(n(J.filePath,$,G.path.concat("module"),"publint/imports-module-should-precede-require",`${$0(G.path.concat("module"))} should come before the "require" condition so it can take precedence when used by a bundler.`,"error",'Bundlers prioritize conditions by order. "module" should precede "require" to ensure ESM is preferred.'))}),X}};var u7={meta:{docs:'Ensure imports values start with "./"',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"imports");if(Y==null||typeof Y!=="object")return[];return U0(Y,z,!0,(Q,G)=>{if(typeof Q!=="string")return;if(!Q.startsWith("."))return;if(Q.startsWith("./"))return;let q=`./${Q.replace(/^[/]+/,"")}`;X.push(n(J.filePath,$,G.path,"publint/imports-value-invalid",`${$0(G.path)} is "${Q}" which is invalid as it does not start with "./". Use "${q}" instead.`,"error",'Relative imports values must start with "./".'))}),X}};var m7={meta:{docs:"Disallow local file references in dependencies",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],Y=["dependencies","optionalDependencies","peerDependencies"];for(let z of Y){let Q=Z[z];if(!Q||typeof Q!=="object")continue;for(let G of Object.keys(Q)){let q=Q[G];if(typeof q==="string"&&(q.startsWith("file:")||q.startsWith("link:")))X.push(n(J.filePath,$,[z,G],"publint/local-dependency",`The "${G}" dependency references "${q}" that will likely not work when installed by end-users.`,"error","Local file references (file: or link:) are not portable and will fail for consumers of the package."))}}return X}};var d7={meta:{docs:'Suggest specifying the "type" field in package.json',recommended:!0},check($,J){let Z=t($);if(!Z)return[];if(Z.type==null)return[n(J.filePath,$,["name"],"publint/use-type",'The package does not specify the "type" field. Node.js may attempt to detect the package type causing a small performance hit. Consider adding "type": "commonjs" or "type": "module".',"warning",'Adding "type" helps Node.js resolve module format without detection overhead.')];return[]}};import{existsSync as MG,readFileSync as jG}from"fs";var o7={meta:{docs:"Ensure bin files have a shebang for executability",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],Y=h0(J.filePath),[z,Q]=i(Z,"bin");if(z==null)return[];if(typeof z==="string")zX(z,Q,Y,X,J.filePath,$);else if(typeof z==="object"){for(let G of Object.keys(z))if(typeof z[G]==="string")zX(z[G],Q.concat(G),Y,X,J.filePath,$)}return X}};function zX($,J,Z,X,Y,z){let Q=I0(Z,$);if(!MG(Q))return;if(!a0($))return;let G;try{G=jG(Q,"utf8")}catch{return}if(!XX(G))X.push(n(Y,z,J,"publint/bin-file-not-executable",`${$0(J)} is "${$}" but the file is not executable. It should start with a shebang, e.g. #!/usr/bin/env node.`,"error","Bin files must start with a shebang (e.g. #!/usr/bin/env node) to be executable."))}import{existsSync as QX,readFileSync as GX}from"fs";var c7={meta:{docs:'Ensure files under "module" condition in exports are ESM',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],Y=h0(J.filePath),[z,Q]=i(Z,"exports");if(z==null)return[];U0(z,Q,!1,(U,W)=>{if(typeof U!=="string")return;if(!W.path.includes("module"))return;if(!U.startsWith("./")&&!U.startsWith("../"))return;if(U.includes("*"))return;let K=I0(Y,U);if(!QX(K))return;if(!a0(U))return;let H;try{H=GX(K,"utf8")}catch{return}if(J1(H)==="CJS")X.push(n(J.filePath,$,W.path,"publint/exports-module-should-be-esm",`${$0(W.path)} should be ESM, but the code is written in CJS.`,"error",'The "module" condition is only used by bundlers and must contain ESM code.'))});let[G,q]=i(Z,"imports");if(G!=null&&typeof G==="object")U0(G,q,!0,(U,W)=>{if(typeof U!=="string")return;if(!W.path.includes("module"))return;if(!U.startsWith("./"))return;if(U.includes("*"))return;let K=I0(Y,U);if(!QX(K))return;if(!a0(U))return;let H;try{H=GX(K,"utf8")}catch{return}if(J1(H)==="CJS")X.push(n(J.filePath,$,W.path,"publint/exports-module-should-be-esm",`${$0(W.path)} should be ESM, but the code is written in CJS.`,"error",'The "module" condition is only used by bundlers and must contain ESM code.'))});return X}};import{existsSync as f1}from"fs";import{dirname as NG,isAbsolute as TG,resolve as EG}from"path";function r7($,J){let Z=J;while(Z.startsWith("./"))Z=Z.slice(2);let X=Z.split("/")[0];if(!X||X===".."||X.startsWith("."))return!1;let Y=TG(J)?NG(J).split("/")[0]||"/":EG($,X);return!f1(Y)}var l7={meta:{docs:"Ensure files referenced in package.json exist",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],Y=h0(J.filePath),z=["main","module","types","typings","unpkg","jsdelivr"];for(let W of z){let[K,H]=i(Z,W);if(K==null||typeof K!=="string")continue;if(r7(Y,K))continue;let V=I0(Y,K);if(!UX(V))X.push(n(J.filePath,$,H,"publint/file-does-not-exist",`${$0(H)} is "${K}" but the file does not exist.`,"error","The referenced file path cannot be found. Check the path for typos."))}let[Q,G]=i(Z,"bin");if(Q!=null){if(typeof Q==="string")qX(Q,G,X,J.filePath,$,Y);else if(typeof Q==="object"){for(let W of Object.keys(Q))if(typeof Q[W]==="string")qX(Q[W],G.concat(W),X,J.filePath,$,Y)}}let[q,U]=i(Z,"exports");if(q!=null)U0(q,U,!1,(W,K)=>{if(typeof W!=="string")return;if(!W.startsWith("./")&&!W.startsWith("../"))return;if(W.includes("*"))return;if(r7(Y,W))return;let H=I0(Y,W);if(!f1(H))X.push(n(J.filePath,$,K.path,"publint/file-does-not-exist",`${$0(K.path)} is "${W}" but the file does not exist.`,"error","The referenced file path cannot be found. Check the path for typos."))});return X}};function qX($,J,Z,X,Y,z){if(r7(z,$))return;let Q=I0(z,$);if(!UX(Q))Z.push(n(X,Y,J,"publint/file-does-not-exist",`${$0(J)} is "${$}" but the file does not exist.`,"error","The referenced file path cannot be found. Check the path for typos."))}function UX($){if(f1($))return!0;if(f1(`${$}.js`))return!0;if(f1(`${$}/index.js`))return!0;return!1}import{existsSync as DG,readFileSync as RG}from"fs";import{extname as OG}from"path";var a7={meta:{docs:"Ensure file code format matches its extension and package type",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],Y=h0(J.filePath),z=Z.type,[Q,G]=i(Z,"main");if(Q!=null&&typeof Q==="string")WX(Q,G,Y,z,X,J.filePath,$);let[q,U]=i(Z,"exports");if(q!=null)U0(q,U,!1,(W,K)=>{if(typeof W!=="string")return;if(!W.startsWith("./")&&!W.startsWith("../"))return;if(W.includes("*"))return;if(K.path.includes("browser"))return;WX(W,K.path,Y,z,X,J.filePath,$)});return X}};function WX($,J,Z,X,Y,z,Q){let G=I0(Z,$);if(!DG(G))return;if(!a0($))return;let q;try{q=RG(G,"utf8")}catch{return}let U=J1(q);if(U==="unknown"||U==="mixed")return;let W=$X(G,X);if(U===W)return;let K=OG(G),H=ZX(U),A=(JX(K)?"FILE_INVALID_EXPLICIT_FORMAT":"FILE_INVALID_FORMAT")==="FILE_INVALID_EXPLICIT_FORMAT"?`${$0(J)} is "${$}" and ends with the ${K} extension, but the code is written in ${U}. Consider using the ${H} extension.`:`${$0(J)} is "${$}" and is written in ${U}, but is interpreted as ${W}. Consider using the ${H} extension.`;Y.push(n(z,Q,J,"publint/file-invalid-format",A,"warning",`The file's code format (${U}) doesn't match the expected format (${W}) based on its extension and package type.`))}import{existsSync as LG,readFileSync as PG}from"fs";var s7={meta:{docs:'Ensure the "module" field points to an ESM file',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let[X,Y]=i(Z,"module");if(X==null||typeof X!=="string")return[];let z=h0(J.filePath),Q=I0(z,X);if(!LG(Q))return[];if(!a0(X))return[];let G;try{G=PG(Q,"utf8")}catch{return[]}if(J1(G)==="CJS")return[n(J.filePath,$,Y,"publint/module-should-be-esm",`${$0(Y)} should be ESM, but the code is written in CJS.`,"error",'The "module" field is intended for ESM output used by bundlers. It should point to an ESM file.')];return[]}};var KX={name:"publint",rules:{"use-type":A0(d7),"local-dependency":A0(m7),"deprecated-field-jsnext":A0(C7),"has-module-but-no-exports":A0(g7),"field-invalid-value-type":A0(f7),"exports-types-should-be-first":A0(b7),"exports-default-should-be-last":A0(I7),"exports-module-should-precede-require":A0(y7),"exports-value-invalid":A0(k7),"exports-missing-root-entrypoint":A0(v7),"exports-fallback-array-use":A0(S7),"imports-key-invalid":A0(p7),"imports-value-invalid":A0(u7),"imports-default-should-be-last":A0(x7),"imports-module-should-precede-require":A0(h7),"file-does-not-exist":A0(l7),"file-invalid-format":A0(a7),"module-should-be-esm":A0(s7),"bin-file-not-executable":A0(o7),"exports-module-should-be-esm":A0(c7)}};var HX={meta:{docs:"Ensure all imports appear before other statements",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=0;for(let Q=0;Q<X.length;Q++){let G=X[Q].trim();if(!G||G.startsWith("//")||G.startsWith("/*")||G.startsWith("*"))continue;let q=G.match(/^\s*import\s+/);if(!q&&G.length>0){if(Y=!0,z===0)z=Q+1}if(Y&&q)Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"import/first",message:"Import statement must appear before other statements",severity:"error"})}return Z}};var VX={meta:{docs:"Disallow duplicate specifier names in a single import declaration"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.match(/^\s*import\s*\{([^}]*)\}\s*from\s*['"][^'"]+['"]/);if(!Q)continue;let q=Q[1].split(",").map((W)=>W.trim()).filter(Boolean).map((W)=>W.split(/\s+as\s+/i)[0].trim()),U=new Set;for(let W of q){if(U.has(W)){Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf(W)+1),ruleId:"pickier/import-dedupe",message:"Expect no duplication in imports",severity:"warning"});break}U.add(W)}}return Z}};import{existsSync as CG,readFileSync as IG}from"fs";import{dirname as SG,resolve as vG}from"path";var AX={meta:{docs:"Ensure named imports correspond to a named export in the remote file",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=SG(J.filePath);for(let z=0;z<X.length;z++){let G=X[z].match(/\bimport\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/);if(G){let q=G[1].split(",").map((H)=>H.trim().split(/\s+as\s+/)[0].trim()),U=G[2];if(!U.startsWith(".")&&!U.startsWith("/"))continue;let W=[".ts",".tsx",".js",".jsx",""],K="";for(let H of W){let V=vG(Y,U+H);if(CG(V)){K=IG(V,"utf8");break}}if(K)for(let H of q){let V=new RegExp(`\\bexport\\s+(?:const|let|var|function|class)\\s+${H}\\b`),A=new RegExp(`\\bexport\\s+\\{[^}]*\\b${H}\\b[^}]*\\}`);if(![V,A].some((B)=>B.test(K)))Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"import/named",message:`'${H}' not found in '${U}'`,severity:"error"})}}}return Z}};import{existsSync as _X,readFileSync as yG}from"fs";import{dirname as FX,resolve as BX}from"path";var wX={meta:{docs:"Ensure imports don't create circular dependencies",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=J.filePath,z=new Set,Q=new Set;function G(U,W){if(Q.has(U))return!0;if(z.has(U))return!1;z.add(U),Q.add(U);try{let K=yG(U,"utf8"),H=q(K,FX(U));for(let V of H)if(G(V,[...W,V]))return!0}catch{}return Q.delete(U),!1}function q(U,W){let K=[],H=/\bimport(?:\s{2,}|\s+\S.*?(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))from\s+['"]([^'"]+)['"]/g,V;for(V=H.exec(U);V!==null;V=H.exec(U)){let A=V[1];if(A.startsWith(".")||A.startsWith("/")){let _=[".ts",".tsx",".js",".jsx",""];for(let F of _){let B=BX(W,A+F);if(_X(B)){K.push(B);break}}}}return K}for(let U=0;U<X.length;U++){let K=X[U].match(/\bimport(?:\s{2,}|\s+\S.*?(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))from\s+['"]([^'"]+)['"]/);if(K){let H=K[1];if(H.startsWith(".")||H.startsWith("/")){let V=[".ts",".tsx",".js",".jsx",""],A="";for(let _ of V){let F=BX(FX(Y),H+_);if(_X(F)){A=F;break}}if(A){if(z.clear(),Q.clear(),Q.add(Y),G(A,[Y,A]))Z.push({filePath:J.filePath,line:U+1,column:1,ruleId:"import/no-cycle",message:"Dependency cycle detected",severity:"error"})}}}}return Z}};var MX={meta:{docs:"Disallow duplicate module imports - all imports from the same module should be combined"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=new Map,z=!1;for(let Q=0;Q<X.length;Q++){let G=X[Q];if(z){let V=G.indexOf("*/");if(V>=0)G=G.slice(V+2),z=!1;else continue}let q=G.indexOf("/*"),U=G.indexOf("//");if(q>=0&&(U===-1||q<U)){let V=G.indexOf("*/",q+2);if(V>=0)G=G.slice(0,q)+G.slice(V+2);else z=!0,G=G.slice(0,q)}if(U>=0)G=G.slice(0,U);let W=G.trim();if(!W)continue;let K=W.match(/^import\s+(?:type\s+)?(?:\{[^}]*\}|[\w$]+(?:\s*,\s*\{[^}]*\})?|\*\s+as\s+[\w$]+)\s+from\s+(['"`])(.+?)\1/);if(K){let V=K[2];if(Y.has(V)){let A=Y.get(V);Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"no-duplicate-imports",message:`'${V}' imported multiple times (also imported on line${A.length>1?"s":""} ${A.join(", ")})`,severity:"error",help:`Combine all imports from '${V}' into a single import statement`}),A.push(Q+1)}else Y.set(V,[Q+1])}let H=W.match(/^export\s+(?:type\s+)?(?:\{[^}]*\}|\*(?:\s+as\s+[\w$]+)?)\s+from\s+(['"`])(.+?)\1/);if(H){let V=H[2],A=`export:${V}`;if(Y.has(A)){let _=Y.get(A);Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"no-duplicate-imports",message:`'${V}' re-exported multiple times (also exported on line${_.length>1?"s":""} ${_.join(", ")})`,severity:"error",help:`Combine all re-exports from '${V}' into a single export statement`}),_.push(Q+1)}else Y.set(A,[Q+1])}}return Z}};var jX={meta:{docs:"Disallow importing from dist directories"},check:($,J)=>{let Z=[],X=new RegExp(`^\\s*import\\s[^;]*?from\\s*['"]([^'"]+)['"]`,"m"),Y=$.split(/\r?\n/);for(let z=0;z<Y.length;z++){let Q=Y[z],G=Q.match(X);if(!G)continue;let q=G[1];if(q==="dist"||(q.startsWith(".")||q.startsWith("/"))&&/(?:^|\/)dist(?:\/.|$)/.test(q))Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,Q.indexOf(q)+1),ruleId:"pickier/no-import-dist",message:`Do not import modules in \`dist\` folder, got ${q}`,severity:"error"})}return Z}};var NX={meta:{docs:"Disallow importing from node_modules by explicit path"},check:($,J)=>{let Z=[],X=new RegExp(`^\\s*import\\s[^;]*?from\\s*['"]([^'"]+)['"]`,"m"),Y=/require\(\s*['"]([^'"]+)['"]\s*\)/,z=$.split(/\r?\n/);for(let Q=0;Q<z.length;Q++){let G=z[Q],q=G.match(X),U=G.match(Y),W=q?.[1]||U?.[1];if(!W)continue;if(W.includes("/node_modules/")){let K=Math.max(1,G.indexOf(W)+1);Z.push({filePath:J.filePath,line:Q+1,column:K,ruleId:"pickier/no-import-node-modules-by-path",message:"Do not import modules in `node_modules` folder by path",severity:"error"})}}return Z}};import{existsSync as bG}from"fs";import{dirname as kG,join as fG,resolve as gG}from"path";var TX={meta:{docs:"Ensure imports point to a file/module that can be resolved",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=kG(J.filePath);for(let z=0;z<X.length;z++){let Q=X[z],G=[...Q.matchAll(/\bimport(?:\s{2,}|\s+\S.*?(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))from\s+['"]([^'"]+)['"]/g),...Q.matchAll(/\bimport\s*\(\s*['"]([^'"]+)['"]\s*\)/g),...Q.matchAll(/\brequire\s*\(\s*['"]([^'"]+)['"]\s*\)/g)];for(let q of G){let U=q[1];if(!U.startsWith(".")&&!U.startsWith("/"))continue;let W=[],K=[".ts",".tsx",".js",".jsx",".mjs",".cjs",""];for(let V of K){let A=gG(Y,U+V);W.push(A),W.push(fG(A,`index${V}`))}if(!W.some((V)=>bG(V)))Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"import/no-unresolved",message:`Unable to resolve path to module '${U}'`,severity:"error"})}}return Z}};function EX($,J,Z){let X=Z.order==="desc"?-1:1,Y=Z.type||"alphabetical",z=Z.ignoreCase?$.toLowerCase():$,Q=Z.ignoreCase?J.toLowerCase():J;if(Y==="line-length")return(z.length-Q.length)*X;if(Y==="natural")return z.localeCompare(Q,void 0,{numeric:!0,sensitivity:"base"})*X;if(Y==="unsorted")return 0;return z.localeCompare(Q)*X}var xG=new RegExp(`^export\\s+\\{[^}]*\\}\\s+from\\s+['"][^'"]+['"];?\\s*$`);function C8($){return xG.test($)}var DX={meta:{docs:"Ensure contiguous export statements are sorted consistently."},check:($,J)=>{let Z=[],X=J.config.pluginRules?.["pickier/sort-exports"]?.[1]||{},Y=$.split(/\r?\n/),z=0;while(z<Y.length){while(z<Y.length&&!C8(Y[z]))z++;if(z>=Y.length)break;let Q=[],G=z;while(G<Y.length){let q=Y[G];if(C8(q)){Q.push({idx:G,line:q}),G++;continue}if(X.partitionByNewLine&&q.trim()==="")break;else break}if(Q.length>1){let q=Q.map((K)=>K.line),U=[...q].sort((K,H)=>EX(K,H,X));if(!q.every((K,H)=>K===U[H])){let K=q.findIndex((V,A)=>V!==U[A]),H=Q[K]?.idx??Q[0].idx;Z.push({filePath:J.filePath,line:H+1,column:1,ruleId:"pickier/sort-exports",message:"Export statements are not sorted.",severity:"warning"})}}z=G+1}return Z},fix:($,J)=>{let Z=J.config.pluginRules?.["pickier/sort-exports"]?.[1]||{},Y=[...$.split(/\r?\n/)],z=0;while(z<Y.length){while(z<Y.length&&!C8(Y[z]))z++;if(z>=Y.length)break;let Q=[],G=z;while(G<Y.length){let q=Y[G];if(C8(q)){Q.push(G),G++;continue}if(Z.partitionByNewLine&&q.trim()==="")break;else break}if(Q.length>1){let q=Q.map((K)=>Y[K]),U=[...q].sort((K,H)=>EX(K,H,Z));if(!q.every((K,H)=>K===U[H]))Q.forEach((K,H)=>{Y[K]=U[H]})}z=G+1}return Y.join(`
123
- `)}};var RX={meta:{docs:"Enforce sorted TypeScript heritage clauses (extends/implements lists)"},check:($,J)=>{let Z=J.options||{},X=Z.type||"alphabetical",Y=Z.order||"asc",z=Z.ignoreCase!==!1,Q=Array.isArray(Z.groups)?Z.groups:[],G=Z.customGroups||{},q=$.split(/\r?\n/),U=[],W=(M)=>Y==="asc"?M:-M,K=(M,E)=>(z?M.toLowerCase():M).localeCompare(z?E.toLowerCase():E),H=(M,E)=>(z?M.toLowerCase():M).localeCompare(z?E.toLowerCase():E,void 0,{numeric:!0}),V=(M,E)=>{if(X==="line-length")return W(M.length-E.length);if(X==="natural")return W(H(M,E));if(X==="unsorted")return 0;return W(K(M,E))},A=Object.fromEntries(Object.entries(G).map(([M,E])=>{let S=(Array.isArray(E)?E:[E]).map((f)=>new RegExp(f));return[M,S]})),_=[];for(let M of Q)if(Array.isArray(M))_.push(...M);else _.push(M);if(!_.includes("unknown"))_.push("unknown");let F=(M)=>{for(let[E,R]of Object.entries(A))if(R.some((S)=>S.test(M)))return E;return"unknown"},B=(M)=>{let E=[],R=0,S="";for(let f=0;f<M.length;f++){let O=M[f];if(O==="<")R++;else if(O===">")R=Math.max(0,R-1);if(O===","&&R===0){E.push(S.trim()),S="";continue}S+=O}if(S.trim())E.push(S.trim());return E},j=(M)=>{let E=M.trim(),R=E.match(/^([A-Z_$][\w$.]*)/i);return R?R[1]:E},D=(M,E)=>{let R=B(E);if(R.length<=1)return;let S=R.map(j),f=S.map(F),O=S.map((P,C)=>({n:P,g:f[C],i:C})).sort((P,C)=>{let I=_.indexOf(P.g),L=_.indexOf(C.g);if(I!==L)return I-L;return V(P.n,C.n)}).map((P)=>P.n);if(!S.every((P,C)=>P===O[C]))U.push({filePath:J.filePath,line:M,column:1,ruleId:"sort-heritage-clauses",message:"Heritage clauses are not sorted",severity:"warning"})};for(let M=0;M<q.length;M++){let E=q[M],R=E.match(/^\s*interface\s+[A-Za-z_$][^{]*\bextends\s+(.+?)\s*\{/);if(R)D(M+1,R[1]);let S=E.match(/^\s*class\s+[A-Za-z_$][^{]*\bimplements\s+(.+?)\s*\{/);if(S)D(M+1,S[1])}return U}};var OX={meta:{docs:"Require object keys to be sorted (ESLint-compatible core rule subset)"},check:()=>{return[]}};var LX={meta:{docs:"Enforce sorted named imports within each import statement"},check:($,J)=>{let Z=J.options||{},X=Z.type||"alphabetical",Y=Z.order||"asc",z=Z.ignoreCase!==!1,Q=Boolean(Z.ignoreAlias),G=$.split(/\r?\n/),q=[],U=(W,K)=>{let H=0;if(X==="line-length")H=W.length-K.length;else{let V=z?W.toLowerCase():W,A=z?K.toLowerCase():K;H=V.localeCompare(A)}return Y==="asc"?H:-H};for(let W=0;W<G.length;W++){let H=G[W].match(/^\s*import\s+\{([^}]*)\}\s+from\s+['"][^'"]+['"]/);if(!H)continue;let A=H[1].split(",").map((j)=>j.trim()).filter(Boolean);if(A.length<=1)continue;let _=A.map((j)=>{let D=j.replace(/^type\s+/,""),M=D.match(/^([\w$]+)\s+as\s+([\w$]+)$/);if(M)return Q?M[2]:M[1];let E=D.match(/^([\w$]+)$/);return E?E[1]:D}),F=[..._].sort(U);if(!_.every((j,D)=>j===F[D]))q.push({filePath:J.filePath,line:W+1,column:1,ruleId:"sort-named-imports",message:"Named imports are not sorted",severity:"warning"})}return q}};var PX={meta:{docs:"Enforce sorted object keys"},check:($,J)=>{let Z=J.options||{},X=Z.type||"alphabetical",Y=Z.order||"asc",z=Z.ignoreCase!==!1,Q=Boolean(Z.partitionByNewLine),G=$.split(/\r?\n/),q=[],U=(K,H)=>{let V=0;if(X==="line-length")V=K.length-H.length;else{let A=z?K.toLowerCase():K,_=z?H.toLowerCase():H;V=A.localeCompare(_)}return Y==="asc"?V:-V},W=0;while(W<G.length){let K=G[W],H=K.indexOf("{");if(H!==-1){let V=K.slice(0,H);if(/=\s*$|\(\s*$|\breturn\s*$/.test(V)){let A=0,_=W,F=W;for(;F<G.length;F++){for(let B of G[F])if(B==="{")A++;else if(B==="}")A--;if(A===0)break}if(F>_){let B=G.slice(_+1,F),j=[],D={startLine:_+2,props:[]},M=()=>{if(D.props.length)j.push(D);D={startLine:0,props:[]}};for(let E=0;E<B.length;E++){let R=B[E];if(Q&&/^\s*$/.test(R)){M();continue}if(/^\s*\.\.\./.test(R))continue;if(/\{|\}/.test(R))continue;let S=R.match(/^\s*['"]?([\w$-]+)['"]?\s*:/);if(S){if(D.startLine===0)D.startLine=_+2+E;D.props.push({key:S[1],line:_+2+E})}}M();for(let E of j){let R=E.props.map((O)=>O.key),S=[...R].sort(U);if(!(R.length<=1||R.every((O,h)=>O===S[h]))&&E.props.length>0){let O=E.props[0];q.push({filePath:J.filePath,line:O.line,column:1,ruleId:"sort-objects",message:"Object keys are not sorted",severity:"warning"})}}W=F+1;continue}}}W++}return q}};var CX={meta:{docs:"Enforce top-level functions to use function declarations"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(/^\s+/.test(z))continue;if(/^\s*(?:\/\/|\/\*)/.test(z))continue;let Q=z.match(/^const\s+([A-Za-z_$][\w$]*)\s*=(.*)$/);if(!Q)continue;let G=Q[2].trim();if(/^\(?[A-Z_$,]*(?:\)\s*)?=>/i.test(G)||/^function\b/.test(G)){let q=z.indexOf("const")+1;Z.push({filePath:J.filePath,line:Y+1,column:q,ruleId:"pickier/top-level-function",message:"Top-level functions should be declared with function keyword",severity:"warning"});continue}if(G.trim().length===0||/[,({]$/.test(G.trim())){let q=X[Y+1]||"";if(/^\s*(?:\(?[A-Za-z_$,]*(?:\)\s*)?=>|function\b)/.test(q)){let U=z.indexOf("const")+1;Z.push({filePath:J.filePath,line:Y+1,column:U,ruleId:"pickier/top-level-function",message:"Top-level functions should be declared with function keyword",severity:"warning"})}}}return Z}};var pG=[[/^(block|inline|inline-block|flex|inline-flex|grid|inline-grid|flow-root|contents|hidden|table|table-caption|table-cell|table-column|table-column-group|table-footer-group|table-header-group|table-row-group|table-row|list-item|subgrid)$/,0],[/^(container|columns|break-after|break-before|break-inside|box-decoration|box-border|box-content|float|clear|isolation|object|overflow|overscroll|position|inset|top|right|bottom|left|start|end|z-|aspect|order)/,1],[/^(static|fixed|absolute|relative|sticky)$/,1],[/^(visible|invisible|collapse)$/,1],[/^(basis|flex-|grow|shrink|order|grid-|col-|row-|auto-cols|auto-rows|gap|justify|items|content|self|place)/,2],[/^(p|px|py|ps|pe|pt|pr|pb|pl|m|mx|my|ms|me|mt|mr|mb|ml|space|indent)-/,3],[/^(-?(p|px|py|ps|pe|pt|pr|pb|pl|m|mx|my|ms|me|mt|mr|mb|ml|space|indent)-)/,3],[/^(w-|h-|min-w|max-w|min-h|max-h|size-)/,4],[/^(font|text|tracking|leading|list|placeholder|vertical|whitespace|break|hyphens|content|truncate|overflow-ellipsis|overflow-clip|line-clamp|underline|overline|line-through|no-underline|uppercase|lowercase|capitalize|normal-case|italic|not-italic|ordinal|slashed-zero|lining-nums|oldstyle-nums|proportional-nums|tabular-nums|diagonal-fractions|stacked-fractions|normal-nums|antialiased|subpixel-antialiased)/,5],[/^(bg-|from-|via-|to-|gradient-)/,6],[/^(border|rounded|outline|ring|divide|accent)/,7],[/^(shadow|opacity|mix-blend|bg-blend)/,8],[/^(blur|brightness|contrast|drop-shadow|grayscale|hue-rotate|invert|saturate|sepia|backdrop)/,9],[/^(border-collapse|border-separate|border-spacing|table-auto|table-fixed|caption)/,10],[/^(transition|duration|ease|delay|animate)/,11],[/^(scale|rotate|translate|skew|origin|transform|perspective)/,12],[/^(appearance|cursor|caret|pointer-events|resize|scroll|snap|touch|select|will-change)/,13],[/^(fill|stroke)/,14],[/^(sr-only|not-sr-only)$/,15]],hG=/^([a-z0-9][-a-z0-9]{0,50}:)+(?!\[)/;function uG($){let J=0;while(J<$.length){if($[J]==="[")break;let Z=$.indexOf(":",J);if(Z===-1)break;if($[Z+1]==="[")break;J=Z+1}return $.slice(J)}function mG($){let J=uG($);if(J.startsWith("!"))J=J.slice(1);for(let[Z,X]of pG)if(Z.test(J))return X;return 99}function dG($){let J=$.match(hG);if(!J)return 0;let Z=J[0].slice(0,-1).split(":"),X={sm:1,md:2,lg:3,xl:4,"2xl":5},Y=10;for(let z of Z)if(X[z]!==void 0)Y+=X[z];else Y+=20;return Y}var IX=new Map;function SX($){let J=IX.get($);if(J)return J;let Z={group:mG($),variant:dG($)};return IX.set($,Z),Z}function n7($){return[...$].sort((J,Z)=>{let X=SX(J),Y=SX(Z),z=X.group,Q=Y.group;if(z!==Q)return z-Q;let G=X.variant,q=Y.variant;if(G!==q)return G-q;return J.localeCompare(Z)})}var oG=/\b(?:class|className|:class)\s*=\s*(?:"([^"]*?)"|'([^']*?)')/g,cG=/\b(?:class|className|:class)\s*=\s*\{`([^`]*?)`\}/g,rG=/\b(?:clsx|cn|tw|cva|tv)\s*\(\s*(?:"([^"]*?)"|'([^']*?)')/g;function lG($){let J=$.replace(/\[[^\]]*\]/g,"");if(/['"`]/.test(J))return!0;if(/[{}()=]/.test(J))return!0;if(/ \? | && | \|\| /.test(J))return!0;if(/\b(?:true|false|null|undefined|function|return|typeof|instanceof)\b/.test(J))return!0;return!1}function vX($){let J=[];if(!$.includes("class")&&!$.includes("clsx")&&!$.includes("cn(")&&!$.includes("tw(")&&!$.includes("cva(")&&!$.includes("tv("))return J;for(let Z of[oG,cG,rG]){Z.lastIndex=0;let X;while((X=Z.exec($))!==null){let Y=X[1]??X[2]??"";if(!Y.trim())continue;if(lG(Y))continue;let z=$.indexOf(Y,X.index);if(z===-1)continue;J.push({value:Y,start:z,end:z+Y.length})}}return J.sort((Z,X)=>Z.start-X.start),J}function yX($){let J=[],Z="",X=0;for(let Y of $)if(Y==="[")X++,Z+=Y;else if(Y==="]")X=Math.max(0,X-1),Z+=Y;else if(/\s/.test(Y)&&X===0){if(Z)J.push(Z),Z=""}else Z+=Y;if(Z)J.push(Z);return J}function bX($){let J=n7($);return $.every((Z,X)=>Z===J[X])}var kX={meta:{docs:"Enforce consistent Tailwind CSS class ordering (layout \u2192 spacing \u2192 typography \u2192 etc.).",recommended:!0},check:($,J)=>{let Z=[],X=vX($);for(let{value:Y,start:z}of X){let Q=yX(Y);if(Q.length<2)continue;if(!bX(Q)){let G=$.slice(0,z),q=(G.match(/\n/g)??[]).length+1,U=G.lastIndexOf(`
124
- `),W=U===-1?z+1:z-U;Z.push({filePath:J.filePath,line:q,column:W,ruleId:"pickier/sort-tailwind-classes",message:`Tailwind classes are not in the recommended order. Expected: "${n7(Q).join(" ")}"`,severity:"warning",help:"Run with --fix to automatically sort Tailwind classes, or reorder them manually."})}}return Z},fix:($)=>{let J=vX($);if(J.length===0)return $;let Z=[...J].reverse(),X=$;for(let{value:Y,start:z,end:Q}of Z){let G=yX(Y);if(G.length<2||bX(G))continue;let q=n7(G).join(" ");X=X.slice(0,z)+q+X.slice(Q)}return X}};var fX={name:"pickier",rules:{"sort-exports":w(DX),"sort-objects":w(PX),"sort-imports":w(P8),"sort-named-imports":w(LX),"sort-heritage-clauses":w(RX),"sort-keys":w(OX),"import-dedupe":w(VX),"import-first":w(HX),"import-named":w(AX),"import-no-cycle":w(wX),"import-no-unresolved":w(TX),"no-import-dist":w(jX),"no-import-node-modules-by-path":w(NX),"no-duplicate-imports":w(MX),"top-level-function":w(CX),"sort-tailwind-classes":kX,"prefer-const":w(D8),"prefer-template":w(R8),"no-unused-vars":w(i0)}};var gX={name:"quality",rules:{"default-case":w(m$),eqeqeq:w(d$),"no-alert":w(r$),"no-await-in-loop":w(l$),"no-caller":w(a$),"no-case-declarations":w(s$),"no-else-return":w(n$),"no-empty":w(i$),"no-empty-function":w(t$),"no-eval":w(e$),"no-extend-native":w($8),"no-global-assign":w(J8),"no-implied-eval":w(X8),"no-iterator":w(Y8),"no-new":w(z8),"no-new-func":w(Q8),"no-new-wrappers":w(G8),"no-octal":w(q8),"no-param-reassign":w(U8),"no-proto":w(W8),"no-return-assign":w(K8),"no-shadow":w(V8),"no-throw-literal":w(A8),"no-use-before-define":w(_8),"no-useless-call":w(F8),"no-with":w(N8),"require-await":w(E8),complexity:w(u$),"max-depth":w(o$),"max-lines-per-function":w(c$),"no-extra-boolean-cast":w(Z8),"no-lonely-if":w(v1),"no-sequences":w(H8),"no-useless-concat":w(B8),"no-useless-escape":w(w8),"no-useless-rename":w(M8),"no-useless-return":w(y1),"no-var":w(j8),"prefer-arrow-callback":w(T8)}};var xX={meta:{docs:"Detects potentially super-linear backtracking patterns in regex literals (heuristic)"},check:($,J)=>{let Z=[],X=/\/[^/\\\n]*(?:\\.[^/\\\n]*)*\//g,Y=(K,H,V)=>{let A=$.slice(0,K),_=(A.match(/\n/g)||[]).length+1,F=K-A.lastIndexOf(`
122
+ `),X=1,Y=0;for(let z of J){let Q=new RegExp(`"${BG(z)}"\\s*:`);for(let G=Y;G<Z.length;G++)if(Q.test(Z[G])){X=G+1,Y=G+1;break}}return X}function h0($){return KG($)}function I0($,J){return HG($,J)}function $0($){let J="pkg";for(let Z of $)if(/^\d+$/.test(Z))J+=`[${Z}]`;else if(!/^[a-z_$][a-z0-9_$]*$/i.test(Z))J+=`["${Z}"]`;else J+=`.${Z}`;return J}function i($,J){if($.publishConfig?.[J]!==void 0)return[$.publishConfig[J],["publishConfig",J]];return[$[J],[J]]}var AG=new RegExp(`(?:[\\s;]|^)(?:import[\\w,{}\\s*]*from|import\\s*['"*{]|export\\b\\s*(?:[*{]|default|type|function|const|var|let|async function)|import\\.meta\\b)`,"m"),_G=new RegExp("(?:[\\s;]|^)(?:module.exports\\b|exports\\.\\w|require\\s*\\(|global\\.\\w|Object\\.(?:defineProperty|defineProperties|assign)\\s*\\(\\s*exports\\b)","m");function X1($){let J=FG($),Z=AG.test(J),X=_G.test(J);if(Z&&X)return"mixed";if(Z)return"ESM";if(X)return"CJS";return"unknown"}function $X($,J){if($.endsWith(".mjs"))return"ESM";if($.endsWith(".cjs"))return"CJS";return J==="module"?"ESM":"CJS"}function ZX($){if($==="ESM")return".mjs";if($==="CJS")return".cjs";return".js"}function JX($){return $===".mjs"||$===".cjs"}function a0($){return $.endsWith(".js")||$.endsWith(".mjs")||$.endsWith(".cjs")}function XX($){return/^#!\s*\//.test($)}function FG($){return $.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*/g,"")}function U0($,J,Z,X){P7($,J,Z,X)}function P7($,J,Z,X){if(typeof $==="string"){X($,{path:J,isImports:Z});return}if(Array.isArray($)){X($,{path:J,isImports:Z});for(let Y=0;Y<$.length;Y++)P7($[Y],J.concat(String(Y)),Z,X);return}if($!==null&&typeof $==="object"){let Y=Object.keys($);X($,{path:J,isImports:Z},Y);for(let z of Y)P7($[z],J.concat(z),Z,X)}}function n($,J,Z,X,Y,z,Q){return{filePath:$,line:VG(J,Z),column:1,ruleId:X,message:Y,severity:z,...Q&&{help:Q}}}function BG($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var C7={meta:{docs:"Disallow deprecated jsnext:main and jsnext fields",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[];if(Z["jsnext:main"]!=null)X.push(n(J.filePath,$,["jsnext:main"],"publint/deprecated-field-jsnext",'pkg["jsnext:main"] is deprecated. pkg.module should be used instead.',"warning",'The jsnext:main field is no longer recognized by modern bundlers. Use "module" instead.'));if(Z.jsnext!=null)X.push(n(J.filePath,$,["jsnext"],"publint/deprecated-field-jsnext","pkg.jsnext is deprecated. pkg.module should be used instead.","warning",'The jsnext field is no longer recognized by modern bundlers. Use "module" instead.'));return X}};var I7={meta:{docs:'Ensure "default" condition is last in exports objects',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"exports");if(Y==null)return[];return U0(Y,z,!1,(Q,G,q)=>{if(!q||typeof Q!=="object"||Array.isArray(Q))return;if(!("default"in Q))return;if(q[q.length-1]!=="default")X.push(n(J.filePath,$,G.path.concat("default"),"publint/exports-default-should-be-last",`${$0(G.path.concat("default"))} should be the last condition in the object so it doesn't take precedence over the keys following it.`,"error",'Conditions are resolved in order. "default" acts as a fallback and should come last.'))}),X}};var S7={meta:{docs:"Warn against using fallback arrays in exports",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"exports");if(Y==null)return[];return U0(Y,z,!1,(Q,G)=>{if(!Array.isArray(Q))return;X.push(n(J.filePath,$,G.path,"publint/exports-fallback-array-use",`${$0(G.path)} uses fallback arrays which is not recommended. It works differently in some tools and may face inconsistent behaviors.`,"warning","Fallback arrays pick the first parseable value and have no practical use case in Node.js currently."))}),X}};var v7={meta:{docs:"Ensure exports has a root entrypoint when main/module exist",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let[X]=i(Z,"main"),[Y]=i(Z,"module"),[z,Q]=i(Z,"exports");if(X==null&&Y==null||z==null)return[];if(typeof z!=="object"||Array.isArray(z))return[];let G=Object.keys(z);if(G.length===0)return[];if(!G[0]?.startsWith("."))return[];if(G.includes("."))return[];let U=[];if(X)U.push("main");if(Y)U.push("module");return[n(J.filePath,$,Q,"publint/exports-missing-root-entrypoint",`${$0(Q)} is missing the root entrypoint export, which is defined in pkg.${U[0]}. Environments that support "exports" will ignore pkg.${U[0]} as "exports" takes the highest priority.`,"warning",`Add ${$0(Q.concat("."))} to ensure the root entrypoint is accessible.`)]}};var y7={meta:{docs:'Ensure "module" condition precedes "require" in exports',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"exports");if(Y==null)return[];return U0(Y,z,!1,(Q,G,q)=>{if(!q||typeof Q!=="object"||Array.isArray(Q))return;if(!("module"in Q)||!("require"in Q))return;if(q.indexOf("module")>q.indexOf("require"))X.push(n(J.filePath,$,G.path.concat("module"),"publint/exports-module-should-precede-require",`${$0(G.path.concat("module"))} should come before the "require" condition so it can take precedence when used by a bundler.`,"error",'Bundlers prioritize conditions by order. "module" should precede "require" to ensure ESM is preferred.'))}),X}};var b7={meta:{docs:'Ensure "types" condition is first in exports objects',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"exports");if(Y==null)return[];return U0(Y,z,!1,(Q,G,q)=>{if(!q||typeof Q!=="object"||Array.isArray(Q))return;if(!("types"in Q))return;let U=q.indexOf("types");if(U===0)return;if(q.slice(0,U).filter((K)=>{if(K.startsWith("types"))return!1;if(typeof Q[K]==="object"&&Q[K]!==null&&YX(Q[K],"types"))return!1;return!0}).length>0)X.push(n(J.filePath,$,G.path.concat("types"),"publint/exports-types-should-be-first",`${$0(G.path.concat("types"))} should be the first condition in the object so it can be resolved by TypeScript.`,"error",'TypeScript resolves conditions in order. The "types" condition must come first to ensure correct type resolution.'))}),X}};function YX($,J){for(let Z in $){if(Z===J)return!0;if(typeof $[Z]==="object"&&$[Z]!==null&&YX($[Z],J))return!0}return!1}var k7={meta:{docs:'Ensure exports values start with "./"',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"exports");if(Y==null)return[];return U0(Y,z,!1,(Q,G)=>{if(typeof Q!=="string")return;if(Q.startsWith("./"))return;let q=`./${Q.replace(/^[/]+/,"")}`;X.push(n(J.filePath,$,G.path,"publint/exports-value-invalid",`${$0(G.path)} is "${Q}" which is invalid as it does not start with "./". Use "${q}" instead.`,"error",'All exports values must be relative paths starting with "./".'))}),X}};var wG=[{field:"main",expectTypes:["string"]},{field:"module",expectTypes:["string"]},{field:"types",expectTypes:["string"]},{field:"typings",expectTypes:["string"]},{field:"browser",expectTypes:["string","object"]},{field:"bin",expectTypes:["string","object"]},{field:"exports",expectTypes:["string","object"]},{field:"imports",expectTypes:["object"]},{field:"name",expectTypes:["string"]},{field:"version",expectTypes:["string"]},{field:"description",expectTypes:["string"]},{field:"license",expectTypes:["string"]}],f7={meta:{docs:"Ensure package.json fields have correct value types",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[];for(let{field:Y,expectTypes:z}of wG){let[Q,G]=i(Z,Y);if(Q==null)continue;let q=typeof Q;if(!z.includes(q)){let U=z.length===1?z[0]:`${z.slice(0,-1).join(", ")} or ${z[z.length-1]}`;X.push(n(J.filePath,$,G,"publint/field-invalid-value-type",`${$0(G)} has an invalid ${q} type. Expected a ${U} type instead.`,"error",`The "${Y}" field must be of type ${U}.`))}}return X}};var g7={meta:{docs:"Suggest adding exports when module field is present",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let[X,Y]=i(Z,"module"),[z]=i(Z,"exports");if(X!=null&&z==null)return[n(J.filePath,$,Y,"publint/has-module-but-no-exports","pkg.module is used to output ESM, but pkg.exports is not defined. As Node.js doesn't read pkg.module, the ESM output may be skipped. Consider adding pkg.exports to export the ESM output.","warning",'Node.js only reads "exports" for module resolution. Without it, the ESM entry point in "module" is ignored by Node.js.')];return[]}};var x7={meta:{docs:'Ensure "default" condition is last in imports objects',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"imports");if(Y==null||typeof Y!=="object")return[];return U0(Y,z,!0,(Q,G,q)=>{if(!q||typeof Q!=="object"||Array.isArray(Q))return;if(!("default"in Q))return;if(q[q.length-1]!=="default")X.push(n(J.filePath,$,G.path.concat("default"),"publint/imports-default-should-be-last",`${$0(G.path.concat("default"))} should be the last condition in the object so it doesn't take precedence over the keys following it.`,"error",'Conditions are resolved in order. "default" acts as a fallback and should come last.'))}),X}};var p7={meta:{docs:'Ensure imports keys start with "#"',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"imports");if(Y==null||typeof Y!=="object"||Array.isArray(Y))return[];for(let Q of Object.keys(Y))if(!Q.startsWith("#")){let G=`#${Q.replace(/^[/]+/,"")}`,q=z.concat(Q);X.push(n(J.filePath,$,q,"publint/imports-key-invalid",`${$0(q)} is invalid as the imports key does not start with "#". Use "${G}" instead.`,"error",'All imports keys must start with "#" to distinguish them from package specifiers.'))}return X}};var h7={meta:{docs:'Ensure "module" condition precedes "require" in imports',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"imports");if(Y==null||typeof Y!=="object")return[];return U0(Y,z,!0,(Q,G,q)=>{if(!q||typeof Q!=="object"||Array.isArray(Q))return;if(!("module"in Q)||!("require"in Q))return;if(q.indexOf("module")>q.indexOf("require"))X.push(n(J.filePath,$,G.path.concat("module"),"publint/imports-module-should-precede-require",`${$0(G.path.concat("module"))} should come before the "require" condition so it can take precedence when used by a bundler.`,"error",'Bundlers prioritize conditions by order. "module" should precede "require" to ensure ESM is preferred.'))}),X}};var u7={meta:{docs:'Ensure imports values start with "./"',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],[Y,z]=i(Z,"imports");if(Y==null||typeof Y!=="object")return[];return U0(Y,z,!0,(Q,G)=>{if(typeof Q!=="string")return;if(!Q.startsWith("."))return;if(Q.startsWith("./"))return;let q=`./${Q.replace(/^[/]+/,"")}`;X.push(n(J.filePath,$,G.path,"publint/imports-value-invalid",`${$0(G.path)} is "${Q}" which is invalid as it does not start with "./". Use "${q}" instead.`,"error",'Relative imports values must start with "./".'))}),X}};var m7={meta:{docs:"Disallow local file references in dependencies",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],Y=["dependencies","optionalDependencies","peerDependencies"];for(let z of Y){let Q=Z[z];if(!Q||typeof Q!=="object")continue;for(let G of Object.keys(Q)){let q=Q[G];if(typeof q==="string"&&(q.startsWith("file:")||q.startsWith("link:")))X.push(n(J.filePath,$,[z,G],"publint/local-dependency",`The "${G}" dependency references "${q}" that will likely not work when installed by end-users.`,"error","Local file references (file: or link:) are not portable and will fail for consumers of the package."))}}return X}};var d7={meta:{docs:'Suggest specifying the "type" field in package.json',recommended:!0},check($,J){let Z=t($);if(!Z)return[];if(Z.type==null)return[n(J.filePath,$,["name"],"publint/use-type",'The package does not specify the "type" field. Node.js may attempt to detect the package type causing a small performance hit. Consider adding "type": "commonjs" or "type": "module".',"warning",'Adding "type" helps Node.js resolve module format without detection overhead.')];return[]}};import{existsSync as MG,readFileSync as jG}from"fs";var o7={meta:{docs:"Ensure bin files have a shebang for executability",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],Y=h0(J.filePath),[z,Q]=i(Z,"bin");if(z==null)return[];if(typeof z==="string")zX(z,Q,Y,X,J.filePath,$);else if(typeof z==="object"){for(let G of Object.keys(z))if(typeof z[G]==="string")zX(z[G],Q.concat(G),Y,X,J.filePath,$)}return X}};function zX($,J,Z,X,Y,z){let Q=I0(Z,$);if(!MG(Q))return;if(!a0($))return;let G;try{G=jG(Q,"utf8")}catch{return}if(!XX(G))X.push(n(Y,z,J,"publint/bin-file-not-executable",`${$0(J)} is "${$}" but the file is not executable. It should start with a shebang, e.g. #!/usr/bin/env node.`,"error","Bin files must start with a shebang (e.g. #!/usr/bin/env node) to be executable."))}import{existsSync as QX,readFileSync as GX}from"fs";var c7={meta:{docs:'Ensure files under "module" condition in exports are ESM',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],Y=h0(J.filePath),[z,Q]=i(Z,"exports");if(z==null)return[];U0(z,Q,!1,(U,W)=>{if(typeof U!=="string")return;if(!W.path.includes("module"))return;if(!U.startsWith("./")&&!U.startsWith("../"))return;if(U.includes("*"))return;let K=I0(Y,U);if(!QX(K))return;if(!a0(U))return;let H;try{H=GX(K,"utf8")}catch{return}if(X1(H)==="CJS")X.push(n(J.filePath,$,W.path,"publint/exports-module-should-be-esm",`${$0(W.path)} should be ESM, but the code is written in CJS.`,"error",'The "module" condition is only used by bundlers and must contain ESM code.'))});let[G,q]=i(Z,"imports");if(G!=null&&typeof G==="object")U0(G,q,!0,(U,W)=>{if(typeof U!=="string")return;if(!W.path.includes("module"))return;if(!U.startsWith("./"))return;if(U.includes("*"))return;let K=I0(Y,U);if(!QX(K))return;if(!a0(U))return;let H;try{H=GX(K,"utf8")}catch{return}if(X1(H)==="CJS")X.push(n(J.filePath,$,W.path,"publint/exports-module-should-be-esm",`${$0(W.path)} should be ESM, but the code is written in CJS.`,"error",'The "module" condition is only used by bundlers and must contain ESM code.'))});return X}};import{existsSync as f1}from"fs";import{dirname as NG,isAbsolute as TG,resolve as EG}from"path";function r7($,J){let Z=J;while(Z.startsWith("./"))Z=Z.slice(2);let X=Z.split("/")[0];if(!X||X===".."||X.startsWith("."))return!1;let Y=TG(J)?NG(J).split("/")[0]||"/":EG($,X);return!f1(Y)}var l7={meta:{docs:"Ensure files referenced in package.json exist",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],Y=h0(J.filePath),z=["main","module","types","typings","unpkg","jsdelivr"];for(let W of z){let[K,H]=i(Z,W);if(K==null||typeof K!=="string")continue;if(r7(Y,K))continue;let V=I0(Y,K);if(!UX(V))X.push(n(J.filePath,$,H,"publint/file-does-not-exist",`${$0(H)} is "${K}" but the file does not exist.`,"error","The referenced file path cannot be found. Check the path for typos."))}let[Q,G]=i(Z,"bin");if(Q!=null){if(typeof Q==="string")qX(Q,G,X,J.filePath,$,Y);else if(typeof Q==="object"){for(let W of Object.keys(Q))if(typeof Q[W]==="string")qX(Q[W],G.concat(W),X,J.filePath,$,Y)}}let[q,U]=i(Z,"exports");if(q!=null)U0(q,U,!1,(W,K)=>{if(typeof W!=="string")return;if(!W.startsWith("./")&&!W.startsWith("../"))return;if(W.includes("*"))return;if(r7(Y,W))return;let H=I0(Y,W);if(!f1(H))X.push(n(J.filePath,$,K.path,"publint/file-does-not-exist",`${$0(K.path)} is "${W}" but the file does not exist.`,"error","The referenced file path cannot be found. Check the path for typos."))});return X}};function qX($,J,Z,X,Y,z){if(r7(z,$))return;let Q=I0(z,$);if(!UX(Q))Z.push(n(X,Y,J,"publint/file-does-not-exist",`${$0(J)} is "${$}" but the file does not exist.`,"error","The referenced file path cannot be found. Check the path for typos."))}function UX($){if(f1($))return!0;if(f1(`${$}.js`))return!0;if(f1(`${$}/index.js`))return!0;return!1}import{existsSync as DG,readFileSync as RG}from"fs";import{extname as OG}from"path";var a7={meta:{docs:"Ensure file code format matches its extension and package type",recommended:!0},check($,J){let Z=t($);if(!Z)return[];let X=[],Y=h0(J.filePath),z=Z.type,[Q,G]=i(Z,"main");if(Q!=null&&typeof Q==="string")WX(Q,G,Y,z,X,J.filePath,$);let[q,U]=i(Z,"exports");if(q!=null)U0(q,U,!1,(W,K)=>{if(typeof W!=="string")return;if(!W.startsWith("./")&&!W.startsWith("../"))return;if(W.includes("*"))return;if(K.path.includes("browser"))return;WX(W,K.path,Y,z,X,J.filePath,$)});return X}};function WX($,J,Z,X,Y,z,Q){let G=I0(Z,$);if(!DG(G))return;if(!a0($))return;let q;try{q=RG(G,"utf8")}catch{return}let U=X1(q);if(U==="unknown"||U==="mixed")return;let W=$X(G,X);if(U===W)return;let K=OG(G),H=ZX(U),A=(JX(K)?"FILE_INVALID_EXPLICIT_FORMAT":"FILE_INVALID_FORMAT")==="FILE_INVALID_EXPLICIT_FORMAT"?`${$0(J)} is "${$}" and ends with the ${K} extension, but the code is written in ${U}. Consider using the ${H} extension.`:`${$0(J)} is "${$}" and is written in ${U}, but is interpreted as ${W}. Consider using the ${H} extension.`;Y.push(n(z,Q,J,"publint/file-invalid-format",A,"warning",`The file's code format (${U}) doesn't match the expected format (${W}) based on its extension and package type.`))}import{existsSync as LG,readFileSync as PG}from"fs";var s7={meta:{docs:'Ensure the "module" field points to an ESM file',recommended:!0},check($,J){let Z=t($);if(!Z)return[];let[X,Y]=i(Z,"module");if(X==null||typeof X!=="string")return[];let z=h0(J.filePath),Q=I0(z,X);if(!LG(Q))return[];if(!a0(X))return[];let G;try{G=PG(Q,"utf8")}catch{return[]}if(X1(G)==="CJS")return[n(J.filePath,$,Y,"publint/module-should-be-esm",`${$0(Y)} should be ESM, but the code is written in CJS.`,"error",'The "module" field is intended for ESM output used by bundlers. It should point to an ESM file.')];return[]}};var KX={name:"publint",rules:{"use-type":A0(d7),"local-dependency":A0(m7),"deprecated-field-jsnext":A0(C7),"has-module-but-no-exports":A0(g7),"field-invalid-value-type":A0(f7),"exports-types-should-be-first":A0(b7),"exports-default-should-be-last":A0(I7),"exports-module-should-precede-require":A0(y7),"exports-value-invalid":A0(k7),"exports-missing-root-entrypoint":A0(v7),"exports-fallback-array-use":A0(S7),"imports-key-invalid":A0(p7),"imports-value-invalid":A0(u7),"imports-default-should-be-last":A0(x7),"imports-module-should-precede-require":A0(h7),"file-does-not-exist":A0(l7),"file-invalid-format":A0(a7),"module-should-be-esm":A0(s7),"bin-file-not-executable":A0(o7),"exports-module-should-be-esm":A0(c7)}};var HX={meta:{docs:"Ensure all imports appear before other statements",recommended:!1},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=!1,z=0;for(let Q=0;Q<X.length;Q++){let G=X[Q].trim();if(!G||G.startsWith("//")||G.startsWith("/*")||G.startsWith("*"))continue;let q=G.match(/^\s*import\s+/);if(!q&&G.length>0){if(Y=!0,z===0)z=Q+1}if(Y&&q)Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"import/first",message:"Import statement must appear before other statements",severity:"error"})}return Z}};var VX={meta:{docs:"Disallow duplicate specifier names in a single import declaration"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.match(/^\s*import\s*\{([^}]*)\}\s*from\s*['"][^'"]+['"]/);if(!Q)continue;let q=Q[1].split(",").map((W)=>W.trim()).filter(Boolean).map((W)=>W.split(/\s+as\s+/i)[0].trim()),U=new Set;for(let W of q){if(U.has(W)){Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf(W)+1),ruleId:"pickier/import-dedupe",message:"Expect no duplication in imports",severity:"warning"});break}U.add(W)}}return Z}};import{existsSync as CG,readFileSync as IG}from"fs";import{dirname as SG,resolve as vG}from"path";var AX={meta:{docs:"Ensure named imports correspond to a named export in the remote file",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=SG(J.filePath);for(let z=0;z<X.length;z++){let G=X[z].match(/\bimport\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/);if(G){let q=G[1].split(",").map((H)=>H.trim().split(/\s+as\s+/)[0].trim()),U=G[2];if(!U.startsWith(".")&&!U.startsWith("/"))continue;let W=[".ts",".tsx",".js",".jsx",""],K="";for(let H of W){let V=vG(Y,U+H);if(CG(V)){K=IG(V,"utf8");break}}if(K)for(let H of q){let V=new RegExp(`\\bexport\\s+(?:const|let|var|function|class)\\s+${H}\\b`),A=new RegExp(`\\bexport\\s+\\{[^}]*\\b${H}\\b[^}]*\\}`);if(![V,A].some((B)=>B.test(K)))Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"import/named",message:`'${H}' not found in '${U}'`,severity:"error"})}}}return Z}};import{existsSync as _X,readFileSync as yG}from"fs";import{dirname as FX,resolve as BX}from"path";var wX={meta:{docs:"Ensure imports don't create circular dependencies",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=J.filePath,z=new Set,Q=new Set;function G(U,W){if(Q.has(U))return!0;if(z.has(U))return!1;z.add(U),Q.add(U);try{let K=yG(U,"utf8"),H=q(K,FX(U));for(let V of H)if(G(V,[...W,V]))return!0}catch{}return Q.delete(U),!1}function q(U,W){let K=[],H=/\bimport(?:\s{2,}|\s+\S.*?(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))from\s+['"]([^'"]+)['"]/g,V;for(V=H.exec(U);V!==null;V=H.exec(U)){let A=V[1];if(A.startsWith(".")||A.startsWith("/")){let _=[".ts",".tsx",".js",".jsx",""];for(let F of _){let B=BX(W,A+F);if(_X(B)){K.push(B);break}}}}return K}for(let U=0;U<X.length;U++){let K=X[U].match(/\bimport(?:\s{2,}|\s+\S.*?(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))from\s+['"]([^'"]+)['"]/);if(K){let H=K[1];if(H.startsWith(".")||H.startsWith("/")){let V=[".ts",".tsx",".js",".jsx",""],A="";for(let _ of V){let F=BX(FX(Y),H+_);if(_X(F)){A=F;break}}if(A){if(z.clear(),Q.clear(),Q.add(Y),G(A,[Y,A]))Z.push({filePath:J.filePath,line:U+1,column:1,ruleId:"import/no-cycle",message:"Dependency cycle detected",severity:"error"})}}}}return Z}};var MX={meta:{docs:"Disallow duplicate module imports - all imports from the same module should be combined"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=new Map,z=!1;for(let Q=0;Q<X.length;Q++){let G=X[Q];if(z){let V=G.indexOf("*/");if(V>=0)G=G.slice(V+2),z=!1;else continue}let q=G.indexOf("/*"),U=G.indexOf("//");if(q>=0&&(U===-1||q<U)){let V=G.indexOf("*/",q+2);if(V>=0)G=G.slice(0,q)+G.slice(V+2);else z=!0,G=G.slice(0,q)}if(U>=0)G=G.slice(0,U);let W=G.trim();if(!W)continue;let K=W.match(/^import\s+(?:type\s+)?(?:\{[^}]*\}|[\w$]+(?:\s*,\s*\{[^}]*\})?|\*\s+as\s+[\w$]+)\s+from\s+(['"`])(.+?)\1/);if(K){let V=K[2];if(Y.has(V)){let A=Y.get(V);Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"no-duplicate-imports",message:`'${V}' imported multiple times (also imported on line${A.length>1?"s":""} ${A.join(", ")})`,severity:"error",help:`Combine all imports from '${V}' into a single import statement`}),A.push(Q+1)}else Y.set(V,[Q+1])}let H=W.match(/^export\s+(?:type\s+)?(?:\{[^}]*\}|\*(?:\s+as\s+[\w$]+)?)\s+from\s+(['"`])(.+?)\1/);if(H){let V=H[2],A=`export:${V}`;if(Y.has(A)){let _=Y.get(A);Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"no-duplicate-imports",message:`'${V}' re-exported multiple times (also exported on line${_.length>1?"s":""} ${_.join(", ")})`,severity:"error",help:`Combine all re-exports from '${V}' into a single export statement`}),_.push(Q+1)}else Y.set(A,[Q+1])}}return Z}};var jX={meta:{docs:"Disallow importing from dist directories"},check:($,J)=>{let Z=[],X=new RegExp(`^\\s*import\\s[^;]*?from\\s*['"]([^'"]+)['"]`,"m"),Y=$.split(/\r?\n/);for(let z=0;z<Y.length;z++){let Q=Y[z],G=Q.match(X);if(!G)continue;let q=G[1];if(q==="dist"||(q.startsWith(".")||q.startsWith("/"))&&/(?:^|\/)dist(?:\/.|$)/.test(q))Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,Q.indexOf(q)+1),ruleId:"pickier/no-import-dist",message:`Do not import modules in \`dist\` folder, got ${q}`,severity:"error"})}return Z}};var NX={meta:{docs:"Disallow importing from node_modules by explicit path"},check:($,J)=>{let Z=[],X=new RegExp(`^\\s*import\\s[^;]*?from\\s*['"]([^'"]+)['"]`,"m"),Y=/require\(\s*['"]([^'"]+)['"]\s*\)/,z=$.split(/\r?\n/);for(let Q=0;Q<z.length;Q++){let G=z[Q],q=G.match(X),U=G.match(Y),W=q?.[1]||U?.[1];if(!W)continue;if(W.includes("/node_modules/")){let K=Math.max(1,G.indexOf(W)+1);Z.push({filePath:J.filePath,line:Q+1,column:K,ruleId:"pickier/no-import-node-modules-by-path",message:"Do not import modules in `node_modules` folder by path",severity:"error"})}}return Z}};import{existsSync as bG}from"fs";import{dirname as kG,join as fG,resolve as gG}from"path";var TX={meta:{docs:"Ensure imports point to a file/module that can be resolved",recommended:!0},check:($,J)=>{let Z=[],X=$.split(/\r?\n/),Y=kG(J.filePath);for(let z=0;z<X.length;z++){let Q=X[z],G=[...Q.matchAll(/\bimport(?:\s{2,}|\s+\S.*?(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))from\s+['"]([^'"]+)['"]/g),...Q.matchAll(/\bimport\s*\(\s*['"]([^'"]+)['"]\s*\)/g),...Q.matchAll(/\brequire\s*\(\s*['"]([^'"]+)['"]\s*\)/g)];for(let q of G){let U=q[1];if(!U.startsWith(".")&&!U.startsWith("/"))continue;let W=[],K=[".ts",".tsx",".js",".jsx",".mjs",".cjs",""];for(let V of K){let A=gG(Y,U+V);W.push(A),W.push(fG(A,`index${V}`))}if(!W.some((V)=>bG(V)))Z.push({filePath:J.filePath,line:z+1,column:1,ruleId:"import/no-unresolved",message:`Unable to resolve path to module '${U}'`,severity:"error"})}}return Z}};function EX($,J,Z){let X=Z.order==="desc"?-1:1,Y=Z.type||"alphabetical",z=Z.ignoreCase?$.toLowerCase():$,Q=Z.ignoreCase?J.toLowerCase():J;if(Y==="line-length")return(z.length-Q.length)*X;if(Y==="natural")return z.localeCompare(Q,void 0,{numeric:!0,sensitivity:"base"})*X;if(Y==="unsorted")return 0;return z.localeCompare(Q)*X}var xG=new RegExp(`^export\\s+\\{[^}]*\\}\\s+from\\s+['"][^'"]+['"];?\\s*$`);function C8($){return xG.test($)}var DX={meta:{docs:"Ensure contiguous export statements are sorted consistently."},check:($,J)=>{let Z=[],X=J.config.pluginRules?.["pickier/sort-exports"]?.[1]||{},Y=$.split(/\r?\n/),z=0;while(z<Y.length){while(z<Y.length&&!C8(Y[z]))z++;if(z>=Y.length)break;let Q=[],G=z;while(G<Y.length){let q=Y[G];if(C8(q)){Q.push({idx:G,line:q}),G++;continue}if(X.partitionByNewLine&&q.trim()==="")break;else break}if(Q.length>1){let q=Q.map((K)=>K.line),U=[...q].sort((K,H)=>EX(K,H,X));if(!q.every((K,H)=>K===U[H])){let K=q.findIndex((V,A)=>V!==U[A]),H=Q[K]?.idx??Q[0].idx;Z.push({filePath:J.filePath,line:H+1,column:1,ruleId:"pickier/sort-exports",message:"Export statements are not sorted.",severity:"warning"})}}z=G+1}return Z},fix:($,J)=>{let Z=J.config.pluginRules?.["pickier/sort-exports"]?.[1]||{},Y=[...$.split(/\r?\n/)],z=0;while(z<Y.length){while(z<Y.length&&!C8(Y[z]))z++;if(z>=Y.length)break;let Q=[],G=z;while(G<Y.length){let q=Y[G];if(C8(q)){Q.push(G),G++;continue}if(Z.partitionByNewLine&&q.trim()==="")break;else break}if(Q.length>1){let q=Q.map((K)=>Y[K]),U=[...q].sort((K,H)=>EX(K,H,Z));if(!q.every((K,H)=>K===U[H]))Q.forEach((K,H)=>{Y[K]=U[H]})}z=G+1}return Y.join(`
123
+ `)}};var RX={meta:{docs:"Enforce sorted TypeScript heritage clauses (extends/implements lists)"},check:($,J)=>{let Z=J.options||{},X=Z.type||"alphabetical",Y=Z.order||"asc",z=Z.ignoreCase!==!1,Q=Array.isArray(Z.groups)?Z.groups:[],G=Z.customGroups||{},q=$.split(/\r?\n/),U=[],W=(M)=>Y==="asc"?M:-M,K=(M,E)=>(z?M.toLowerCase():M).localeCompare(z?E.toLowerCase():E),H=(M,E)=>(z?M.toLowerCase():M).localeCompare(z?E.toLowerCase():E,void 0,{numeric:!0}),V=(M,E)=>{if(X==="line-length")return W(M.length-E.length);if(X==="natural")return W(H(M,E));if(X==="unsorted")return 0;return W(K(M,E))},A=Object.fromEntries(Object.entries(G).map(([M,E])=>{let S=(Array.isArray(E)?E:[E]).map((f)=>new RegExp(f));return[M,S]})),_=[];for(let M of Q)if(Array.isArray(M))_.push(...M);else _.push(M);if(!_.includes("unknown"))_.push("unknown");let F=(M)=>{for(let[E,R]of Object.entries(A))if(R.some((S)=>S.test(M)))return E;return"unknown"},B=(M)=>{let E=[],R=0,S="";for(let f=0;f<M.length;f++){let O=M[f];if(O==="<")R++;else if(O===">")R=Math.max(0,R-1);if(O===","&&R===0){E.push(S.trim()),S="";continue}S+=O}if(S.trim())E.push(S.trim());return E},j=(M)=>{let E=M.trim(),R=E.match(/^([A-Z_$][\w$.]*)/i);return R?R[1]:E},D=(M,E)=>{let R=B(E);if(R.length<=1)return;let S=R.map(j),f=S.map(F),O=S.map((P,C)=>({n:P,g:f[C],i:C})).sort((P,C)=>{let I=_.indexOf(P.g),L=_.indexOf(C.g);if(I!==L)return I-L;return V(P.n,C.n)}).map((P)=>P.n);if(!S.every((P,C)=>P===O[C]))U.push({filePath:J.filePath,line:M,column:1,ruleId:"sort-heritage-clauses",message:"Heritage clauses are not sorted",severity:"warning"})};for(let M=0;M<q.length;M++){let E=q[M],R=E.match(/^\s*interface\s+[A-Za-z_$][^{]*\bextends\s+(.+?)\s*\{/);if(R)D(M+1,R[1]);let S=E.match(/^\s*class\s+[A-Za-z_$][^{]*\bimplements\s+(.+?)\s*\{/);if(S)D(M+1,S[1])}return U}};var OX={meta:{docs:"Require object keys to be sorted (ESLint-compatible core rule subset)"},check:()=>{return[]}};var LX={meta:{docs:"Enforce sorted named imports within each import statement"},check:($,J)=>{let Z=J.options||{},X=Z.type||"alphabetical",Y=Z.order||"asc",z=Z.ignoreCase!==!1,Q=Boolean(Z.ignoreAlias),G=$.split(/\r?\n/),q=[],U=(W,K)=>{let H=0;if(X==="line-length")H=W.length-K.length;else{let V=z?W.toLowerCase():W,A=z?K.toLowerCase():K;H=V.localeCompare(A)}return Y==="asc"?H:-H};for(let W=0;W<G.length;W++){let H=G[W].match(/^\s*import\s+\{([^}]*)\}\s+from\s+['"][^'"]+['"]/);if(!H)continue;let A=H[1].split(",").map((j)=>j.trim()).filter(Boolean);if(A.length<=1)continue;let _=A.map((j)=>{let D=j.replace(/^type\s+/,""),M=D.match(/^([\w$]+)\s+as\s+([\w$]+)$/);if(M)return Q?M[2]:M[1];let E=D.match(/^([\w$]+)$/);return E?E[1]:D}),F=[..._].sort(U);if(!_.every((j,D)=>j===F[D]))q.push({filePath:J.filePath,line:W+1,column:1,ruleId:"sort-named-imports",message:"Named imports are not sorted",severity:"warning"})}return q}};var PX={meta:{docs:"Enforce sorted object keys"},check:($,J)=>{let Z=J.options||{},X=Z.type||"alphabetical",Y=Z.order||"asc",z=Z.ignoreCase!==!1,Q=Boolean(Z.partitionByNewLine),G=$.split(/\r?\n/),q=[],U=(K,H)=>{let V=0;if(X==="line-length")V=K.length-H.length;else{let A=z?K.toLowerCase():K,_=z?H.toLowerCase():H;V=A.localeCompare(_)}return Y==="asc"?V:-V},W=0;while(W<G.length){let K=G[W],H=K.indexOf("{");if(H!==-1){let V=K.slice(0,H);if(/=\s*$|\(\s*$|\breturn\s*$/.test(V)){let A=0,_=W,F=W;for(;F<G.length;F++){for(let B of G[F])if(B==="{")A++;else if(B==="}")A--;if(A===0)break}if(F>_){let B=G.slice(_+1,F),j=[],D={startLine:_+2,props:[]},M=()=>{if(D.props.length)j.push(D);D={startLine:0,props:[]}};for(let E=0;E<B.length;E++){let R=B[E];if(Q&&/^\s*$/.test(R)){M();continue}if(/^\s*\.\.\./.test(R))continue;if(/\{|\}/.test(R))continue;let S=R.match(/^\s*['"]?([\w$-]+)['"]?\s*:/);if(S){if(D.startLine===0)D.startLine=_+2+E;D.props.push({key:S[1],line:_+2+E})}}M();for(let E of j){let R=E.props.map((O)=>O.key),S=[...R].sort(U);if(!(R.length<=1||R.every((O,h)=>O===S[h]))&&E.props.length>0){let O=E.props[0];q.push({filePath:J.filePath,line:O.line,column:1,ruleId:"sort-objects",message:"Object keys are not sorted",severity:"warning"})}}W=F+1;continue}}}W++}return q}};var CX={meta:{docs:"Enforce top-level functions to use function declarations"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(/^\s+/.test(z))continue;if(/^\s*(?:\/\/|\/\*)/.test(z))continue;let Q=z.match(/^const\s+([A-Za-z_$][\w$]*)\s*=(.*)$/);if(!Q)continue;let G=Q[2].trim();if(/^\(?[A-Z_$,]*(?:\)\s*)?=>/i.test(G)||/^function\b/.test(G)){let q=z.indexOf("const")+1;Z.push({filePath:J.filePath,line:Y+1,column:q,ruleId:"pickier/top-level-function",message:"Top-level functions should be declared with function keyword",severity:"warning"});continue}if(G.trim().length===0||/[,({]$/.test(G.trim())){let q=X[Y+1]||"";if(/^\s*(?:\(?[A-Za-z_$,]*(?:\)\s*)?=>|function\b)/.test(q)){let U=z.indexOf("const")+1;Z.push({filePath:J.filePath,line:Y+1,column:U,ruleId:"pickier/top-level-function",message:"Top-level functions should be declared with function keyword",severity:"warning"})}}}return Z}};var pG=[[/^(block|inline|inline-block|flex|inline-flex|grid|inline-grid|flow-root|contents|hidden|table|table-caption|table-cell|table-column|table-column-group|table-footer-group|table-header-group|table-row-group|table-row|list-item|subgrid)$/,0],[/^(container|columns|break-after|break-before|break-inside|box-decoration|box-border|box-content|float|clear|isolation|object|overflow|overscroll|position|inset|top|right|bottom|left|start|end|z-|aspect|order)/,1],[/^(static|fixed|absolute|relative|sticky)$/,1],[/^(visible|invisible|collapse)$/,1],[/^(basis|flex-|grow|shrink|order|grid-|col-|row-|auto-cols|auto-rows|gap|justify|items|content|self|place)/,2],[/^(p|px|py|ps|pe|pt|pr|pb|pl|m|mx|my|ms|me|mt|mr|mb|ml|space|indent)-/,3],[/^(-?(p|px|py|ps|pe|pt|pr|pb|pl|m|mx|my|ms|me|mt|mr|mb|ml|space|indent)-)/,3],[/^(w-|h-|min-w|max-w|min-h|max-h|size-)/,4],[/^(font|text|tracking|leading|list|placeholder|vertical|whitespace|break|hyphens|content|truncate|overflow-ellipsis|overflow-clip|line-clamp|underline|overline|line-through|no-underline|uppercase|lowercase|capitalize|normal-case|italic|not-italic|ordinal|slashed-zero|lining-nums|oldstyle-nums|proportional-nums|tabular-nums|diagonal-fractions|stacked-fractions|normal-nums|antialiased|subpixel-antialiased)/,5],[/^(bg-|from-|via-|to-|gradient-)/,6],[/^(border|rounded|outline|ring|divide|accent)/,7],[/^(shadow|opacity|mix-blend|bg-blend)/,8],[/^(blur|brightness|contrast|drop-shadow|grayscale|hue-rotate|invert|saturate|sepia|backdrop)/,9],[/^(border-collapse|border-separate|border-spacing|table-auto|table-fixed|caption)/,10],[/^(transition|duration|ease|delay|animate)/,11],[/^(scale|rotate|translate|skew|origin|transform|perspective)/,12],[/^(appearance|cursor|caret|pointer-events|resize|scroll|snap|touch|select|will-change)/,13],[/^(fill|stroke)/,14],[/^(sr-only|not-sr-only)$/,15]],hG=/^([a-z0-9][-a-z0-9]{0,50}:)+(?!\[)/;function uG($){let J=0;while(J<$.length){if($[J]==="[")break;let Z=$.indexOf(":",J);if(Z===-1)break;if($[Z+1]==="[")break;J=Z+1}return $.slice(J)}function mG($){let J=uG($);if(J.startsWith("!"))J=J.slice(1);for(let[Z,X]of pG)if(Z.test(J))return X;return 99}function dG($){let J=$.match(hG);if(!J)return 0;let Z=J[0].slice(0,-1).split(":"),X={sm:1,md:2,lg:3,xl:4,"2xl":5},Y=10;for(let z of Z)if(X[z]!==void 0)Y+=X[z];else Y+=20;return Y}var IX=new Map;function SX($){let J=IX.get($);if(J)return J;let Z={group:mG($),variant:dG($)};return IX.set($,Z),Z}function n7($){return[...$].sort((J,Z)=>{let X=SX(J),Y=SX(Z),z=X.group,Q=Y.group;if(z!==Q)return z-Q;let G=X.variant,q=Y.variant;if(G!==q)return G-q;return J.localeCompare(Z)})}var oG=/\b(?:class|className|:class)\s*=\s*(?:"([^"]*?)"|'([^']*?)')/g,cG=/\b(?:class|className|:class)\s*=\s*\{`([^`]*?)`\}/g,rG=/\b(?:clsx|cn|tw|cva|tv)\s*\(\s*(?:"([^"]*?)"|'([^']*?)')/g;function lG($){let J=$.replace(/\[[^\]]*\]/g,"");if(/['"`]/.test(J))return!0;if(/[{}()=]/.test(J))return!0;if(/ \? | && | \|\| /.test(J))return!0;if(/\b(?:true|false|null|undefined|function|return|typeof|instanceof)\b/.test(J))return!0;return!1}function vX($){let J=[];if(!$.includes("class")&&!$.includes("clsx")&&!$.includes("cn(")&&!$.includes("tw(")&&!$.includes("cva(")&&!$.includes("tv("))return J;for(let Z of[oG,cG,rG]){Z.lastIndex=0;let X;while((X=Z.exec($))!==null){let Y=X[1]??X[2]??"";if(!Y.trim())continue;if(lG(Y))continue;let z=$.indexOf(Y,X.index);if(z===-1)continue;J.push({value:Y,start:z,end:z+Y.length})}}return J.sort((Z,X)=>Z.start-X.start),J}function yX($){let J=[],Z="",X=0;for(let Y of $)if(Y==="[")X++,Z+=Y;else if(Y==="]")X=Math.max(0,X-1),Z+=Y;else if(/\s/.test(Y)&&X===0){if(Z)J.push(Z),Z=""}else Z+=Y;if(Z)J.push(Z);return J}function bX($){let J=n7($);return $.every((Z,X)=>Z===J[X])}var kX={meta:{docs:"Enforce consistent Tailwind CSS class ordering (layout \u2192 spacing \u2192 typography \u2192 etc.).",recommended:!0,editsStringContent:!0},check:($,J)=>{let Z=[],X=vX($);for(let{value:Y,start:z}of X){let Q=yX(Y);if(Q.length<2)continue;if(!bX(Q)){let G=$.slice(0,z),q=(G.match(/\n/g)??[]).length+1,U=G.lastIndexOf(`
124
+ `),W=U===-1?z+1:z-U;Z.push({filePath:J.filePath,line:q,column:W,ruleId:"pickier/sort-tailwind-classes",message:`Tailwind classes are not in the recommended order. Expected: "${n7(Q).join(" ")}"`,severity:"warning",help:"Run with --fix to automatically sort Tailwind classes, or reorder them manually."})}}return Z},fix:($)=>{let J=vX($);if(J.length===0)return $;let Z=[...J].reverse(),X=$;for(let{value:Y,start:z,end:Q}of Z){let G=yX(Y);if(G.length<2||bX(G))continue;let q=n7(G).join(" ");X=X.slice(0,z)+q+X.slice(Q)}return X}};var fX={name:"pickier",rules:{"sort-exports":w(DX),"sort-objects":w(PX),"sort-imports":w(P8),"sort-named-imports":w(LX),"sort-heritage-clauses":w(RX),"sort-keys":w(OX),"import-dedupe":w(VX),"import-first":w(HX),"import-named":w(AX),"import-no-cycle":w(wX),"import-no-unresolved":w(TX),"no-import-dist":w(jX),"no-import-node-modules-by-path":w(NX),"no-duplicate-imports":w(MX),"top-level-function":w(CX),"sort-tailwind-classes":kX,"prefer-const":w(D8),"prefer-template":w(R8),"no-unused-vars":w(i0)}};var gX={name:"quality",rules:{"default-case":w(m$),eqeqeq:w(d$),"no-alert":w(r$),"no-await-in-loop":w(l$),"no-caller":w(a$),"no-case-declarations":w(s$),"no-else-return":w(n$),"no-empty":w(i$),"no-empty-function":w(t$),"no-eval":w(e$),"no-extend-native":w($8),"no-global-assign":w(J8),"no-implied-eval":w(X8),"no-iterator":w(Y8),"no-new":w(z8),"no-new-func":w(Q8),"no-new-wrappers":w(G8),"no-octal":w(q8),"no-param-reassign":w(U8),"no-proto":w(W8),"no-return-assign":w(K8),"no-shadow":w(V8),"no-throw-literal":w(A8),"no-use-before-define":w(_8),"no-useless-call":w(F8),"no-with":w(N8),"require-await":w(E8),complexity:w(u$),"max-depth":w(o$),"max-lines-per-function":w(c$),"no-extra-boolean-cast":w(Z8),"no-lonely-if":w(y1),"no-sequences":w(H8),"no-useless-concat":w(B8),"no-useless-escape":w(w8),"no-useless-rename":w(M8),"no-useless-return":w(b1),"no-var":w(j8),"prefer-arrow-callback":w(T8)}};var xX={meta:{docs:"Detects potentially super-linear backtracking patterns in regex literals (heuristic)"},check:($,J)=>{let Z=[],X=/\/[^/\\\n]*(?:\\.[^/\\\n]*)*\//g,Y=(K,H,V)=>{let A=$.slice(0,K),_=(A.match(/\n/g)||[]).length+1,F=K-A.lastIndexOf(`
125
125
  `);Z.push({filePath:J.filePath,line:_,column:F,ruleId:"no-super-linear-backtracking",message:V,severity:"error"})},z=[],Q=/\/\*[\s\S]*?\*\//g,G;while(G=Q.exec($))z.push({start:G.index,end:G.index+G[0].length});let q=/\/\/[^\n]*/g,U;while(U=q.exec($))z.push({start:U.index,end:U.index+U[0].length});let W;while(W=X.exec($)){let K=W[0],H=W.index;if(z.some((B)=>H>=B.start&&H<B.end))continue;if(H>0){let B=$[H-1];if(B===")"||B==="]"||B==="."||/[\w$]/.test(B))continue;let j=K.slice(1,K.lastIndexOf("/"));if(/^\s+\w/.test(j)&&/\w\s*\)/.test(j))continue}let A=K.slice(1,K.lastIndexOf("/")).replace(/\[.*?\]/g,"");if(A.includes(".+?\\s*")||A.includes("\\s*.+?")||A.includes(".*\\s*")||A.includes("\\s*.*")){Y(H,K.length,"The combination of ' .*' or ' .+?' with '\\s*' can cause super-linear backtracking due to exchangeable characters");continue}let F=A.replace(/\s+/g,"");if(/(?:\.\*\??){2,}/.test(F)||/(?:\.\+\??){2,}/.test(F)||/\.\*\??\.\+\?|\.\+\??\.\*\?/.test(F)){Y(H,K.length,"Multiple adjacent unlimited wildcard quantifiers can cause super-linear backtracking");continue}if(/\((?:\?:)?[^)]*?[+*][^)]*\)\s*[+*]/.test(A.replace(/\\[()]/g,"_"))){Y(H,K.length,"Nested unlimited quantifiers detected (e.g., (.+)+) which can cause catastrophic backtracking");continue}}return Z}};function aG($,J){let Z=J-1;while(Z>=0&&($[Z]===" "||$[Z]==="\t"))Z--;let X=Z>=0?$[Z]:"",Y="=(<>!&|?:;,{[+(~^%*/";if(!(Z<0||Y.includes(X)||/\b(?:return|typeof|void|delete|throw|new|in|of|case)\s*$/.test($.slice(Math.max(0,Z-5),Z+1))))return null;let Q=J+1,G=!1,q=!1,U=-1;while(Q<$.length){let _=$[Q];if(q)q=!1;else if(_==="\\")q=!0;else if(_==="["){if(!G)G=!0}else if(_==="]"){if(G)G=!1}else if(_==="/"&&!G){U=Q;break}else if(_===`
126
126
  `)break;Q++}if(U<=J)return null;let W=$.slice(J+1,U),K=U+1;while(K<$.length&&/[gimsuvy]/.test($[K]))K++;if(/\\[1-9]/.test(W))return null;let H=0,V=-1,A=!1;for(let _=0;_<W.length;_++){if(W[_]==="\\"){_++;continue}if(W[_]==="["&&!A){A=!0;continue}if(W[_]==="]"&&A){A=!1;continue}if(A)continue;if(W[_]==="("&&W.slice(_+1,_+3)!=="?:"&&W.slice(_+1,_+3)!=="?="&&W.slice(_+1,_+3)!=="?!"&&W.slice(_+1,_+4)!=="?<="&&W.slice(_+1,_+4)!=="?<!"){if(V<0)V=_;H++}}if(H===0)return null;return{patternStart:J,patternEnd:K,pattern:W,capCount:H,firstCapOffset:V}}function sG($,J,Z){let X=Z;while(X<$.length&&($[X]===" "||$[X]==="\t"))X++;if($[X]==="."){let q=$.slice(X+1,X+20);if(/^test\s*\(/.test(q))return!1;if(/^exec\s*\(/.test(q))return!0}let Y=J-1;while(Y>=0&&($[Y]===" "||$[Y]==="\t"))Y--;if($[Y]==="("){let U=Y-1;while(U>=0&&($[U]===" "||$[U]==="\t"))U--;let W=$.slice(Math.max(0,U-20),U+1);if(/\.match\s*$/.test(W))return!0;if(/\.matchAll\s*$/.test(W))return!0;if(/\.exec\s*$/.test(W))return!0;if(/\.replace\s*$/.test(W))return!0;if(/\.replaceAll\s*$/.test(W))return!0;if(/\.split\s*$/.test(W))return!0;if(/\.search\s*$/.test(W))return!1;if(/\.test\s*$/.test(W))return!1}let z=$.lastIndexOf(`
127
127
  `,J)+1,G=$.slice(z,J).trim().match(/(?:const|let|var)\s+(\w+)\s*=\s*$/);if(G){let q=G[1],U=$.slice(Z),W=new RegExp(`\\b${q}\\.exec\\s*\\(`),K=new RegExp(`\\b${q}\\.test\\s*\\(`),H=new RegExp(`\\.match(?:All)?\\s*\\(\\s*${q}\\s*\\)`),V=new RegExp(`\\.replace(?:All)?\\s*\\(\\s*${q}`),A=W.test(U),_=H.test(U),F=V.test(U),B=K.test(U);if(A||_||F)return!0;if(B)return!1;return!0}return!0}function nG($,J){let Z=J-1;while(Z>=0&&($[Z]===" "||$[Z]==="\t"))Z--;let X=Z>=0?$[Z]:"",Y="=(<>!&|?:;,{[+(~^%*/";if(!(Z<0||Y.includes(X)||/\b(?:return|typeof|void|delete|throw|new|in|of|case)\s*$/.test($.slice(Math.max(0,Z-5),Z+1))))return J+1;let Q=J+1,G=!1,q=!1;while(Q<$.length){let U=$[Q];if(q)q=!1;else if(U==="\\")q=!0;else if(U==="["){if(!G)G=!0}else if(U==="]"){if(G)G=!1}else if(U==="/"&&!G){Q++;while(Q<$.length&&/[gimsuvy]/.test($[Q]))Q++;return Q}else if(U===`
@@ -151,17 +151,17 @@ ${G}`;if(L7(q)!==q)return[{filePath:J.filePath,line:Y+1,column:1,ruleId:"sort-im
151
151
  `)X++;Z("LineComment",q,X);continue}if($[X+1]==="*"){let q=X;X+=2;while(X<Y&&!($[X]==="*"&&$[X+1]==="/"))X++;X=Math.min(Y,X+2),Z("BlockComment",q,X);continue}if(W2(J)){let q=X;X++;while(X<Y){let U=$[X];if(U==="\\"){X+=2;continue}if(U==="/"){X++;break}X++}while(X<Y&&/[a-z]/i.test($[X]))X++;Z("Regex",q,X);continue}Z("Punct",X,X+1),X++;continue}if("(){}[];:,.<>+-*%&|^!?=~".includes(z)){Z("Punct",X,X+1),X++;continue}let Q=X,G=new RegExp("[^\\s(){}[\\];:,.<>+\\-*%&|^!?=~'\"`/]");while(X<Y&&G.test($[X]))X++;if(X>Q)Z("Word",Q,X);else Z("Word",X,X+1),X++}return J}function W2($){if($.length===0)return!0;let J=$[$.length-1],Z=new RegExp("[(!,{;:?=]");return J.type==="Punct"&&Z.test(J.value)||J.type==="Word"&&/^(?:return|throw|case|of|in|instanceof|typeof|void|new)$/.test(J.value)}function v5($,J,Z,X){let Y=0,z=(K)=>K<=" ",Q=(K)=>{while(K<$.length&&$[K]!==`
152
152
  `)K++;return K},G=(K)=>{K+=2;while(K<$.length&&!($[K]==="*"&&$[K+1]==="/"))K++;return Math.min($.length,K+2)},q=(K,H)=>{let V=$.length;if(H==="`"){K++;let A=0;while(K<V){let _=$[K];if(_==="\\"){K+=2;continue}if(_==="`"&&A===0){K++;break}if(_==="$"&&$[K+1]==="{"){A++,K+=2;continue}if(_==="}"&&A>0){A--,K++;continue}if(_==='"'||_==="'"){K=q(K,_);continue}if(_==="/"&&$[K+1]==="/"){K=Q(K+2);continue}if(_==="/"&&$[K+1]==="*"){K=G(K);continue}K++}return K}K++;while(K<V){let A=$[K];if(A==="\\"){K+=2;continue}if(A===H){K++;break}K++}return K},U=(K)=>{let H=K-1;while(H>=0&&z($[H]))H--;let V=H>=0?$[H]:"";if(new RegExp("[(:[{;?,=!&|^~+\\-*%<>]").test(V))return!0;if(V==="")return!0;return!1},W=(K)=>{K++;let H=$.length;while(K<H){let V=$[K];if(V==="\\"){K+=2;continue}if(V==="/"){K++;break}K++}while(K<H&&/[a-z]/i.test($[K]))K++;return K};for(let K=J;K<$.length;K++){let H=$[K];if(H===Z){Y++;continue}if(H===X){if(Y--,Y===0)return K;continue}if(H==='"'||H==="'"||H==="`"){K=q(K,H)-1;continue}if(H==="/"&&$[K+1]==="/"){K=Q(K+2)-1;continue}if(H==="/"&&$[K+1]==="*"){K=G(K)-1;continue}if(H==="/"&&U(K)){K=W(K)-1;continue}}return-1}function y8($,J,Z,X,Y,z,Q){let G=v5($,X,Y,z);if(G<=X)return;let q=$.slice(X+1,G),U=/\r?\n/.test(q),W=I5($),K=[],H=0,V=X+1,A=S5($.slice(X+1,G)),_=0;for(let B of A){let j=X+1+B.start,D=X+1+B.end;if(_=D,B.type==="Punct"){if(B.value===Y)H++;else if(B.value===z&&H>0)H--;else if(B.value===","&&H===0)K.push({start:V,end:j}),V=D}}if(K.push({start:V,end:G}),!U){for(let B of K){let j=$.slice(B.start,B.end);if(/\r?\n/.test(j)){let D=W.indexToLoc(B.start);Z.push({filePath:J,line:D.line,column:D.column,ruleId:Q,message:"Should not have line breaks between items",severity:"warning"});break}}return}let F=q.indexOf(`
153
153
  `);if(F>0){let B=q.slice(0,F),j=(B.match(/,/g)||[]).length,D=q.slice(F+1),M=D.includes(`
154
- `),E=D.includes(",");if(j>=1&&/\S,\s*\S/.test(B)&&!M&&!E){let R=W.indexToLoc(X+1+F+1);Z.push({filePath:J,line:R.line,column:R.column,ruleId:Q,message:"Should not have line breaks between items",severity:"warning"});return}else if(j>=1&&/\S,\s*\S/.test(B)){let R=W.indexToLoc(X+1+B.search(/,\s*\S/));Z.push({filePath:J,line:R.line,column:R.column,ruleId:Q,message:"Should have line breaks between items",severity:"warning"});return}}for(let B of K){let j=$.slice(X+1,B.start);if(!/\n[ \t]*$/.test(j)&&j.trim()!==""){let D=W.indexToLoc(B.start);Z.push({filePath:J,line:D.line,column:D.column,ruleId:Q,message:"Should have line breaks between items",severity:"warning"});break}}}var y5={meta:{docs:"Enforce consistent newlines for list-like constructs (objects, arrays, named imports/exports)"},check:($,J)=>{let Z=[],X="style/consistent-list-newline";for(let Y=0;Y<$.length;Y++){let z=$[Y];if(z==="{"){let Q=Y-1;while(Q>=0&&/[ \t]/.test($[Q]))Q--;if(Q>=0&&$[Q]===")")continue;let G=$.slice(Math.max(0,Y-60),Y);if(/\b(?:function|class|interface|type|enum|try|catch|finally|if|else|for|while|switch)\b[\s\S]*$/.test(G))continue;y8($,J.filePath,Z,Y,"{","}","style/consistent-list-newline")}else if(z==="[")y8($,J.filePath,Z,Y,"[","]","style/consistent-list-newline");else if(z==="i"&&$.startsWith("import",Y)){let Q=$.indexOf("{",Y);if(Q>-1)y8($,J.filePath,Z,Q,"{","}","style/consistent-list-newline")}else if(z==="e"&&$.startsWith("export",Y)){let Q=$.indexOf("{",Y);if(Q>-1)y8($,J.filePath,Z,Q,"{","}","style/consistent-list-newline")}}return Z}};function K2($){let J=$.trim();return J===""||J.startsWith("//")||J.startsWith("/*")}function J9($,J){for(let Z=J;Z<$.length;Z++)if(!K2($[Z]))return Z;return-1}function _1($,J,Z){if($[J].slice(Z).includes("{"))return!0;let Y=J9($,J+1);if(Y>=0){if($[Y].trim().startsWith("{"))return!0}return!1}function b8($,J,Z){let X=$[J].slice(Z);if(/\bif\b|\bfor\b|\bwhile\b|\bdo\b/.test(X))return!0;return!1}var b5={meta:{docs:"Enforce curly brackets similar to src-2: require braces when any branch/body requires them"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let z=0;z<X.length;z++){let Q=X[z],G=Q.match(/^(\s*)if\s*\(([^)]*)\)/);if(G){let U=G[0].length,W=_1(X,z,U),K=b8(X,z,U),H=z,V=W,A=K;while(!0){let _=J9(X,H+1);if(_<0)break;let F=X[_].trim();if(!F.startsWith("else"))break;let B=F.match(/^else\s+if\s*\(([^)]*)\)/);if(B){let j=X[_].indexOf(B[0])+B[0].length;V=V||_1(X,_,j),A=A||b8(X,_,j),H=_;continue}else{let j=X[_].indexOf("else")+4;V=V||_1(X,_,j),A=A||b8(X,_,j),H=_;break}}if(V||A){if(!W)Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,Q.indexOf("if")+1),ruleId:"style/curly",message:"Expect curly brackets",severity:"warning"});let _=z;while(!0){let F=J9(X,_+1);if(F<0)break;let B=X[F],j=B.trim();if(!j.startsWith("else"))break;let D=j.match(/^else\s+if\s*\(([^)]*)\)/);if(D){let M=B.indexOf(D[0])+D[0].length;if(!_1(X,F,M))Z.push({filePath:J.filePath,line:F+1,column:Math.max(1,B.indexOf("else")+1),ruleId:"style/curly",message:"Expect curly brackets",severity:"warning"});_=F;continue}else{let M=B.indexOf("else")+4;if(!_1(X,F,M))Z.push({filePath:J.filePath,line:F+1,column:Math.max(1,B.indexOf("else")+1),ruleId:"style/curly",message:"Expect curly brackets",severity:"warning"});break}}}}let q=Q.match(/^(\s*)(while|do|for|for\s+await)\b/);if(q){let U=q[0].length,W=_1(X,z,U),K=b8(X,z,U);if((W||K)&&!W)Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,Q.indexOf(q[2])+1),ruleId:"style/curly",message:"Expect curly brackets",severity:"warning"})}}let Y=H2($,J.filePath);for(let z of Y)Z.push({filePath:J.filePath,line:z.line,column:z.column,ruleId:"style/curly",message:z.message,severity:"warning"});return Z}};function H2($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim(),G=/^if\s*\(/.test(Q)?"if":/^else\s+if\s*\(/.test(Q)?"else-if":/^else\b/.test(Q)?"else":null;if(!G)continue;let q=0;if(G==="if"){let A=z.match(/if\s*\([^)]*\)/);q=A?z.indexOf(A[0])+A[0].length:z.indexOf("if")+2}else if(G==="else-if"){let A=z.match(/else\s+if\s*\([^)]*\)/);q=A?z.indexOf(A[0])+A[0].length:z.indexOf("else")+4}else q=z.indexOf("else")+4;let U=Y,W=z.indexOf("{",q);if(W<0){let A=function(F){for(let B=F;B<X.length;B++)if(X[B].trim()!=="")return B;return-1}(Y+1);if(A<0)continue;if(W=X[A].indexOf("{"),W<0)continue;U=A}let K=0,H=-1;for(let A=U;A<X.length;A++){let _=X[A],F=A===U?Math.max(0,W):0;for(let B=F;B<_.length;B++){let j=_[B];if(j==="{")K++;else if(j==="}"){if(K--,K===0){H=A;break}}}if(H>=0)break}if(H<0)continue;let V=[];for(let A=U+1;A<H;A++){let _=X[A].trim();if(_===""||/^\/\//.test(_))continue;if(V.push(_),V.length>1)break}if(V.length===1&&H===U+2){let A=V[0],_=/^(?:if|for|while|do|switch|try|catch|else)\b/.test(A),F=/[{}]/.test(A),B=(A.match(/\(/g)||[]).length,j=(A.match(/\)/g)||[]).length,D=B!==j,M=!1;for(let E=Y+1;E<X.length;E++){let R=X[E].trim();if(R===""||R==="}"||/^\/\//.test(R))continue;if(!/^else\b/.test(R))break;let S=X[E].indexOf("else")+4,f=R.match(/^else\s+if\s*\([^)]*\)/);if(f)S=X[E].indexOf(f[0])+f[0].length;let O=E,h=X[E].indexOf("{",S);if(h<0){let I=function(T){for(let k=T;k<X.length;k++)if(X[k].trim()!=="")return k;return-1}(E+1);if(I<0)break;if(h=X[I].indexOf("{"),h<0)continue;O=I}let P=0,C=-1;for(let I=O;I<X.length;I++){let L=X[I],T=I===O?Math.max(0,h):0;for(let k=T;k<L.length;k++){let N=L[k];if(N==="{")P++;else if(N==="}"){if(P--,P===0){C=I;break}}}if(C>=0)break}if(C>=0){let I=0;for(let L=O+1;L<C;L++){let T=X[L].trim();if(T===""||/^\/\//.test(T))continue;if(I++,I>1){M=!0;break}}}if(M)break}if(!M&&G==="if"){let E=function(S){for(let f=S;f<X.length;f++){let O=X[f].trim();if(O!==""&&O!=="}"&&!/^\/\//.test(O))return f}return-1}(H+1);if(E>=0&&/^else\b/.test(X[E].trim())){let R=X[E].indexOf("else")+4,S=X[E].trim().match(/^else\s+if\s*\([^)]*\)/);if(S)R=X[E].indexOf(S[0])+S[0].length;let f=E,O=X[E].indexOf("{",R);if(O<0){let h=function(C){for(let I=C;I<X.length;I++)if(X[I].trim()!=="")return I;return-1}(E+1);if(h>=0)O=X[h].indexOf("{"),f=O>=0?h:f}if(O>=0){let h=0,P=-1;for(let C=f;C<X.length;C++){let I=X[C],L=C===f?Math.max(0,O):0;for(let T=L;T<I.length;T++){let k=I[T];if(k==="{")h++;else if(k==="}"){if(h--,h===0){P=C;break}}}if(P>=0)break}if(P>=0){let C=0;for(let I=f+1;I<P;I++){let L=X[I].trim();if(L===""||/^\/\//.test(L))continue;if(++C>1){M=!0;break}}}}}}if(!_&&!F&&!D&&!M)Z.push({line:U+1,column:Math.max(1,X[U].indexOf("{")+1),message:"Unnecessary curly braces around single statement"})}}return Z}var k5={meta:{docs:"Enforce dot on the property line in chained method calls",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=b1($);for(let z=0;z<X.length;z++){let Q=X[z],G=Q.trim();if(!G||G.startsWith("//")||G.startsWith("*")||G.startsWith("/*"))continue;if(Y[z+1])continue;if(G.endsWith(".")&&z+1<X.length){let q=X[z+1].trim();if(q&&/^[a-zA-Z_$]/.test(q))Z.push({filePath:J.filePath,line:z+1,column:Q.length,ruleId:"style/dot-location",message:"Dot should be on the same line as the property",severity:"warning"})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[],X=b1($);for(let Y=0;Y<J.length;Y++){let z=J[Y];if(z.trim().endsWith(".")&&!X[Y+1]&&Y+1<J.length){let G=J[Y+1],q=G.trim();if(q&&/^[a-zA-Z_$]/.test(q)){Z.push(z.replace(/\.\s*$/,""));let U=G.match(/^(\s*)/)?.[1]||"";J[Y+1]=`${U}.${q}`;continue}}Z.push(z)}return Z.join(`
155
- `)}};function f5($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var g5=["===","!==",">>>","==","!=",">=","<=","&&","||","??","**","<<",">>","+","-","*","/","%","|","&","^",">","<","instanceof","in"],lB=new RegExp(`^(${g5.map(($)=>$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")})\\s`),V2=new Set(["in","instanceof"]),A2=/^(?:instanceof|in)\s/;function k8($){if(A2.test($))return!0;for(let J of g5){if(V2.has(J))continue;if($.startsWith(J)){let Z=$[J.length];if(Z===void 0||Z===" "||Z==="\t")return!0}}return!1}function X9($){let J=$.match(/^(\s*)/);return J?J[1].length:0}var x5={meta:{docs:"Enforce consistent indentation of continuation lines in multiline binary expressions",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;if(!k8(Q))continue;if(f5(z,0))continue;let G=Y-1;while(G>=0){let W=X[G].trim();if(!W||W.startsWith("//")||W.startsWith("*")||W.startsWith("/*")){G--;continue}if(k8(W)){G--;continue}break}if(G<0)continue;let q=X9(X[G])+2,U=X9(z);if(U!==q)Z.push({filePath:J.filePath,line:Y+1,column:U+1,ruleId:"style/indent-binary-ops",message:`Expected indentation of ${q} spaces for binary operator continuation, but found ${U}`,severity:"warning"})}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[];for(let Y=0;Y<Z.length;Y++){let z=Z[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*")){X.push(z);continue}if(!k8(Q)||f5(z,0)){X.push(z);continue}let G=-1;for(let W=X.length-1;W>=0;W--){let K=X[W].trim();if(!K||K.startsWith("//")||K.startsWith("*")||K.startsWith("/*"))continue;if(k8(K))continue;G=W;break}if(G<0){X.push(z);continue}let q=X9(X[G])+2,U=" ".repeat(q)+Q;X.push(U);continue}return X.join(`
154
+ `),E=D.includes(",");if(j>=1&&/\S,\s*\S/.test(B)&&!M&&!E){let R=W.indexToLoc(X+1+F+1);Z.push({filePath:J,line:R.line,column:R.column,ruleId:Q,message:"Should not have line breaks between items",severity:"warning"});return}else if(j>=1&&/\S,\s*\S/.test(B)){let R=W.indexToLoc(X+1+B.search(/,\s*\S/));Z.push({filePath:J,line:R.line,column:R.column,ruleId:Q,message:"Should have line breaks between items",severity:"warning"});return}}for(let B of K){let j=$.slice(X+1,B.start);if(!/\n[ \t]*$/.test(j)&&j.trim()!==""){let D=W.indexToLoc(B.start);Z.push({filePath:J,line:D.line,column:D.column,ruleId:Q,message:"Should have line breaks between items",severity:"warning"});break}}}var y5={meta:{docs:"Enforce consistent newlines for list-like constructs (objects, arrays, named imports/exports)"},check:($,J)=>{let Z=[],X="style/consistent-list-newline";for(let Y=0;Y<$.length;Y++){let z=$[Y];if(z==="{"){let Q=Y-1;while(Q>=0&&/[ \t]/.test($[Q]))Q--;if(Q>=0&&$[Q]===")")continue;let G=$.slice(Math.max(0,Y-60),Y);if(/\b(?:function|class|interface|type|enum|try|catch|finally|if|else|for|while|switch)\b[\s\S]*$/.test(G))continue;y8($,J.filePath,Z,Y,"{","}","style/consistent-list-newline")}else if(z==="[")y8($,J.filePath,Z,Y,"[","]","style/consistent-list-newline");else if(z==="i"&&$.startsWith("import",Y)){let Q=$.indexOf("{",Y);if(Q>-1)y8($,J.filePath,Z,Q,"{","}","style/consistent-list-newline")}else if(z==="e"&&$.startsWith("export",Y)){let Q=$.indexOf("{",Y);if(Q>-1)y8($,J.filePath,Z,Q,"{","}","style/consistent-list-newline")}}return Z}};function K2($){let J=$.trim();return J===""||J.startsWith("//")||J.startsWith("/*")}function J9($,J){for(let Z=J;Z<$.length;Z++)if(!K2($[Z]))return Z;return-1}function F1($,J,Z){if($[J].slice(Z).includes("{"))return!0;let Y=J9($,J+1);if(Y>=0){if($[Y].trim().startsWith("{"))return!0}return!1}function b8($,J,Z){let X=$[J].slice(Z);if(/\bif\b|\bfor\b|\bwhile\b|\bdo\b/.test(X))return!0;return!1}var b5={meta:{docs:"Enforce curly brackets similar to src-2: require braces when any branch/body requires them"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let z=0;z<X.length;z++){let Q=X[z],G=Q.match(/^(\s*)if\s*\(([^)]*)\)/);if(G){let U=G[0].length,W=F1(X,z,U),K=b8(X,z,U),H=z,V=W,A=K;while(!0){let _=J9(X,H+1);if(_<0)break;let F=X[_].trim();if(!F.startsWith("else"))break;let B=F.match(/^else\s+if\s*\(([^)]*)\)/);if(B){let j=X[_].indexOf(B[0])+B[0].length;V=V||F1(X,_,j),A=A||b8(X,_,j),H=_;continue}else{let j=X[_].indexOf("else")+4;V=V||F1(X,_,j),A=A||b8(X,_,j),H=_;break}}if(V||A){if(!W)Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,Q.indexOf("if")+1),ruleId:"style/curly",message:"Expect curly brackets",severity:"warning"});let _=z;while(!0){let F=J9(X,_+1);if(F<0)break;let B=X[F],j=B.trim();if(!j.startsWith("else"))break;let D=j.match(/^else\s+if\s*\(([^)]*)\)/);if(D){let M=B.indexOf(D[0])+D[0].length;if(!F1(X,F,M))Z.push({filePath:J.filePath,line:F+1,column:Math.max(1,B.indexOf("else")+1),ruleId:"style/curly",message:"Expect curly brackets",severity:"warning"});_=F;continue}else{let M=B.indexOf("else")+4;if(!F1(X,F,M))Z.push({filePath:J.filePath,line:F+1,column:Math.max(1,B.indexOf("else")+1),ruleId:"style/curly",message:"Expect curly brackets",severity:"warning"});break}}}}let q=Q.match(/^(\s*)(while|do|for|for\s+await)\b/);if(q){let U=q[0].length,W=F1(X,z,U),K=b8(X,z,U);if((W||K)&&!W)Z.push({filePath:J.filePath,line:z+1,column:Math.max(1,Q.indexOf(q[2])+1),ruleId:"style/curly",message:"Expect curly brackets",severity:"warning"})}}let Y=H2($,J.filePath);for(let z of Y)Z.push({filePath:J.filePath,line:z.line,column:z.column,ruleId:"style/curly",message:z.message,severity:"warning"});return Z}};function H2($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim(),G=/^if\s*\(/.test(Q)?"if":/^else\s+if\s*\(/.test(Q)?"else-if":/^else\b/.test(Q)?"else":null;if(!G)continue;let q=0;if(G==="if"){let A=z.match(/if\s*\([^)]*\)/);q=A?z.indexOf(A[0])+A[0].length:z.indexOf("if")+2}else if(G==="else-if"){let A=z.match(/else\s+if\s*\([^)]*\)/);q=A?z.indexOf(A[0])+A[0].length:z.indexOf("else")+4}else q=z.indexOf("else")+4;let U=Y,W=z.indexOf("{",q);if(W<0){let A=function(F){for(let B=F;B<X.length;B++)if(X[B].trim()!=="")return B;return-1}(Y+1);if(A<0)continue;if(W=X[A].indexOf("{"),W<0)continue;U=A}let K=0,H=-1;for(let A=U;A<X.length;A++){let _=X[A],F=A===U?Math.max(0,W):0;for(let B=F;B<_.length;B++){let j=_[B];if(j==="{")K++;else if(j==="}"){if(K--,K===0){H=A;break}}}if(H>=0)break}if(H<0)continue;let V=[];for(let A=U+1;A<H;A++){let _=X[A].trim();if(_===""||/^\/\//.test(_))continue;if(V.push(_),V.length>1)break}if(V.length===1&&H===U+2){let A=V[0],_=/^(?:if|for|while|do|switch|try|catch|else)\b/.test(A),F=/[{}]/.test(A),B=(A.match(/\(/g)||[]).length,j=(A.match(/\)/g)||[]).length,D=B!==j,M=!1;for(let E=Y+1;E<X.length;E++){let R=X[E].trim();if(R===""||R==="}"||/^\/\//.test(R))continue;if(!/^else\b/.test(R))break;let S=X[E].indexOf("else")+4,f=R.match(/^else\s+if\s*\([^)]*\)/);if(f)S=X[E].indexOf(f[0])+f[0].length;let O=E,h=X[E].indexOf("{",S);if(h<0){let I=function(T){for(let k=T;k<X.length;k++)if(X[k].trim()!=="")return k;return-1}(E+1);if(I<0)break;if(h=X[I].indexOf("{"),h<0)continue;O=I}let P=0,C=-1;for(let I=O;I<X.length;I++){let L=X[I],T=I===O?Math.max(0,h):0;for(let k=T;k<L.length;k++){let N=L[k];if(N==="{")P++;else if(N==="}"){if(P--,P===0){C=I;break}}}if(C>=0)break}if(C>=0){let I=0;for(let L=O+1;L<C;L++){let T=X[L].trim();if(T===""||/^\/\//.test(T))continue;if(I++,I>1){M=!0;break}}}if(M)break}if(!M&&G==="if"){let E=function(S){for(let f=S;f<X.length;f++){let O=X[f].trim();if(O!==""&&O!=="}"&&!/^\/\//.test(O))return f}return-1}(H+1);if(E>=0&&/^else\b/.test(X[E].trim())){let R=X[E].indexOf("else")+4,S=X[E].trim().match(/^else\s+if\s*\([^)]*\)/);if(S)R=X[E].indexOf(S[0])+S[0].length;let f=E,O=X[E].indexOf("{",R);if(O<0){let h=function(C){for(let I=C;I<X.length;I++)if(X[I].trim()!=="")return I;return-1}(E+1);if(h>=0)O=X[h].indexOf("{"),f=O>=0?h:f}if(O>=0){let h=0,P=-1;for(let C=f;C<X.length;C++){let I=X[C],L=C===f?Math.max(0,O):0;for(let T=L;T<I.length;T++){let k=I[T];if(k==="{")h++;else if(k==="}"){if(h--,h===0){P=C;break}}}if(P>=0)break}if(P>=0){let C=0;for(let I=f+1;I<P;I++){let L=X[I].trim();if(L===""||/^\/\//.test(L))continue;if(++C>1){M=!0;break}}}}}}if(!_&&!F&&!D&&!M)Z.push({line:U+1,column:Math.max(1,X[U].indexOf("{")+1),message:"Unnecessary curly braces around single statement"})}}return Z}var k5={meta:{docs:"Enforce dot on the property line in chained method calls",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=t0($);for(let z=0;z<X.length;z++){let Q=X[z],G=Q.trim();if(!G||G.startsWith("//")||G.startsWith("*")||G.startsWith("/*"))continue;if(Y[z+1])continue;if(G.endsWith(".")&&z+1<X.length){let q=X[z+1].trim();if(q&&/^[a-zA-Z_$]/.test(q))Z.push({filePath:J.filePath,line:z+1,column:Q.length,ruleId:"style/dot-location",message:"Dot should be on the same line as the property",severity:"warning"})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[],X=t0($);for(let Y=0;Y<J.length;Y++){let z=J[Y];if(z.trim().endsWith(".")&&!X[Y+1]&&Y+1<J.length){let G=J[Y+1],q=G.trim();if(q&&/^[a-zA-Z_$]/.test(q)){Z.push(z.replace(/\.\s*$/,""));let U=G.match(/^(\s*)/)?.[1]||"";J[Y+1]=`${U}.${q}`;continue}}Z.push(z)}return Z.join(`
155
+ `)}};function f5($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var g5=["===","!==",">>>","==","!=",">=","<=","&&","||","??","**","<<",">>","+","-","*","/","%","|","&","^",">","<","instanceof","in"],sB=new RegExp(`^(${g5.map(($)=>$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")})\\s`),V2=new Set(["in","instanceof"]),A2=/^(?:instanceof|in)\s/;function k8($){if(A2.test($))return!0;for(let J of g5){if(V2.has(J))continue;if($.startsWith(J)){let Z=$[J.length];if(Z===void 0||Z===" "||Z==="\t")return!0}}return!1}function X9($){let J=$.match(/^(\s*)/);return J?J[1].length:0}var x5={meta:{docs:"Enforce consistent indentation of continuation lines in multiline binary expressions",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;if(!k8(Q))continue;if(f5(z,0))continue;let G=Y-1;while(G>=0){let W=X[G].trim();if(!W||W.startsWith("//")||W.startsWith("*")||W.startsWith("/*")){G--;continue}if(k8(W)){G--;continue}break}if(G<0)continue;let q=X9(X[G])+2,U=X9(z);if(U!==q)Z.push({filePath:J.filePath,line:Y+1,column:U+1,ruleId:"style/indent-binary-ops",message:`Expected indentation of ${q} spaces for binary operator continuation, but found ${U}`,severity:"warning"})}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[];for(let Y=0;Y<Z.length;Y++){let z=Z[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*")){X.push(z);continue}if(!k8(Q)||f5(z,0)){X.push(z);continue}let G=-1;for(let W=X.length-1;W>=0;W--){let K=X[W].trim();if(!K||K.startsWith("//")||K.startsWith("*")||K.startsWith("/*"))continue;if(k8(K))continue;G=W;break}if(G<0){X.push(z);continue}let q=X9(X[G])+2,U=" ".repeat(q)+Q;X.push(U);continue}return X.join(`
156
156
  `)}};var p5=new Set(["if","for","while","switch","catch","function","return","typeof","void","delete","throw","new","await","class","import","export","from","of","in","case","default","yield","else","do","try","finally","with","async","super","this","extends","implements","instanceof"]),f8=/([a-zA-Z_$][a-zA-Z0-9_$]*)\s+\(/g;function h5($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var u5={meta:{docs:"Disallow spaces between function name and opening parenthesis in calls",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;f8.lastIndex=0;while((G=f8.exec(z))!==null){let q=G[1],U=G.index;if(h5(z,U))continue;if(p5.has(q))continue;let W=z.slice(0,U).trimEnd();if(W.endsWith("function")||W.endsWith("function*"))continue;if(/\b(?:get|set)\s*$/.test(W))continue;let K=U+q.length;Z.push({filePath:J.filePath,line:Y+1,column:K+1,ruleId:"style/function-call-spacing",message:"Unexpected space between function name and parenthesis",severity:"warning"})}}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[];for(let Y=0;Y<Z.length;Y++){let z=Z[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*")){X.push(z);continue}let G=z,q=[],U;f8.lastIndex=0;while((U=f8.exec(z))!==null){let W=U[1],K=U.index;if(h5(z,K))continue;if(p5.has(W))continue;let H=z.slice(0,K).trimEnd();if(H.endsWith("function")||H.endsWith("function*"))continue;if(/\b(?:get|set)\s*$/.test(H))continue;q.push({index:K,fullMatch:U[0],identifier:W})}for(let W=q.length-1;W>=0;W--){let K=q[W],H=K.index,V=H+K.fullMatch.length;G=`${G.slice(0,H)}${K.identifier}(${G.slice(V)}`}X.push(G)}return X.join(`
157
157
  `)}};var m5=/\bfunction\s*\*/g;function d5($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var o5={meta:{docs:"Enforce spacing around * in generator functions (space after, no space before)",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;m5.lastIndex=0;while((G=m5.exec(z))!==null){let U=G.index;if(d5(z,U))continue;let W=G[0],K=U+W.indexOf("*"),H=K+1;if(W!=="function*")Z.push({filePath:J.filePath,line:Y+1,column:K+1,ruleId:"style/generator-star-spacing",message:"Unexpected space before * in generator function",severity:"warning"});if(H<z.length&&z[H]!==" "&&z[H]!=="\t"&&z[H]!==`
158
158
  `&&z[H]!=="(")Z.push({filePath:J.filePath,line:Y+1,column:H+1,ruleId:"style/generator-star-spacing",message:"Missing space after * in generator function",severity:"warning"})}if(Q.match(/^(?:async\s+)?\*\s*([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/)){let U=z.indexOf("*",z.indexOf(Q.charAt(0)));if(!d5(z,U)){let W=U+1;if(W<z.length&&z[W]!==" "&&z[W]!=="\t")Z.push({filePath:J.filePath,line:Y+1,column:W+1,ruleId:"style/generator-star-spacing",message:"Missing space after * in generator method",severity:"warning"})}}}return Z},fix($,J){let Z=$;return Z=Z.replace(/\bfunction\s+\*/g,"function*"),Z=Z.replace(/\bfunction\*([a-zA-Z_$])/g,"function* $1"),Z=Z.replace(/(^\s*(?:async\s+)?)\*([a-zA-Z_$])/gm,"$1* $2"),Z}};var c5={meta:{docs:"Enforce newline after if when without braces"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(!z.match(/^\s*if\s*\([^)]*\)\s*([^\s{/].*)$/))continue;Z.push({filePath:J.filePath,line:Y+1,column:Math.max(1,z.indexOf("if")+1),ruleId:"style/if-newline",message:"Expect newline after if",severity:"warning"})}return Z}};var _2=["$","unindent","unIndent"],r5={meta:{docs:"Enforce consistent indentation inside unindent-style tagged templates"},check:($,J)=>{let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.match(/^\s*/)?.[0]??"",G=/([$A-Z_][\w$]*)\s*`/gi,q;while(q=G.exec(z)){let U=q[1];if(!_2.includes(U))continue;if(z.slice(q.index+q[0].length).includes("`"))continue;let K=-1;for(let V=Y+1;V<X.length;V++)if(X[V].includes("`")){K=V;break}if(K<0)continue;let H=`${Q} `;for(let V=Y+1;V<K;V++){let A=X[V];if(A.trim()==="")continue;let _=A.match(/^\s*/)?.[0]??"";if(!_.startsWith(H)){Z.push({filePath:J.filePath,line:V+1,column:(_.length||0)+1,ruleId:"style/indent-unindent",message:"Consistent indentation in unindent tag",severity:"warning"});break}}}}return Z}};var F2=/^(\s*)(["']?[a-zA-Z_$][a-zA-Z0-9_$]*["']?\s*(?:\?)?):(\S)/;function l5($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var a5={meta:{docs:"Require space after colon in object properties",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G=z.match(F2);if(G){let U=z.indexOf(":",G[1].length);if(U!==-1&&!l5(z,U)){let W=z[U+1];if(W&&W!==" "&&W!=="\t"&&W!==`
159
159
  `)Z.push({filePath:J.filePath,line:Y+1,column:U+2,ruleId:"style/key-spacing",message:"Missing space after colon in property",severity:"warning"})}}let q=Q.match(/^(["']?[a-zA-Z_$][a-zA-Z0-9_$]*["']?)\s+:/);if(q&&!Q.match(/^\s*(case|default)\b/)){let U=z.indexOf(":",z.indexOf(q[1])+q[1].length);if(U!==-1&&!l5(z,U))Z.push({filePath:J.filePath,line:Y+1,column:U+1,ruleId:"style/key-spacing",message:"Unexpected space before colon in property",severity:"warning"})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X;Y=Y.replace(/^(\s*)(["']?[a-zA-Z_$][a-zA-Z0-9_$]*["']?\s*(?:\?)?):(\S)/,"$1$2: $3"),Z.push(Y)}return Z.join(`
160
160
  `)}};var B2=["if","else","for","while","do","switch","case","return","throw","try","catch","finally","const","let","var","typeof","instanceof","in","of","new","delete","void","yield","await","async","from","import","export","default","class","extends","as","break","continue"],s5=new RegExp(`(?:^|[^\\w$.])(${B2.join("|")})(?=[^\\w$]|$)`,"g");function w2($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var n5={meta:{docs:"Require space before and after keywords",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;s5.lastIndex=0;while((G=s5.exec(z))!==null){let q=G[0].charAt(0)===G[1].charAt(0)?"":G[0].charAt(0),U=G.index+q.length,W=U+G[1].length;if(w2(z,U))continue;if(U>0){let K=z[U-1];if(K===")"||K==="}")Z.push({filePath:J.filePath,line:Y+1,column:U+1,ruleId:"style/keyword-spacing",message:`Missing space before keyword '${G[1]}'`,severity:"warning"})}if(W<z.length){let K=z[W];if(K!==" "&&K!=="\t"&&K!==";"&&K!==","&&K!==":"&&K!=="."){if(K==="("&&(G[1]==="if"||G[1]==="for"||G[1]==="while"||G[1]==="switch"||G[1]==="catch"))Z.push({filePath:J.filePath,line:Y+1,column:W+1,ruleId:"style/keyword-spacing",message:`Missing space after keyword '${G[1]}'`,severity:"warning"})}}}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X;for(let z of["if","for","while","switch","catch"]){let Q=new RegExp(`(\\b${z})\\(`,"g");Y=Y.replace(Q,"$1 (")}for(let z of["else","catch","finally"])Y=Y.replace(new RegExp(`\\)${z}\\b`,"g"),`) ${z}`),Y=Y.replace(new RegExp(`\\}${z}\\b`,"g"),`} ${z}`);Z.push(Y)}return Z.join(`
161
161
  `)}};var i5=/^\s*(?:public|private|protected|static|readonly|abstract|override|async|get|set|\*|#|[a-zA-Z_$])/,t5={meta:{docs:"Require blank line between class members",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=!1,z=0,Q=0,G=-1;for(let q=0;q<X.length;q++){let W=X[q].trim();if(W.match(/\bclass\b/)&&(W.includes("{")||q+1<X.length&&X[q+1].trim()==="{"))Y=!0,Q=z+1;let K=z;for(let H of W){if(H==="{")z++;if(H==="}")z--}if(Y&&z<Q){Y=!1,G=-1;continue}if(!Y)continue;if(K>Q&&z===Q&&W.endsWith("}")){G=q;continue}if(K===Q){if(!W||W.startsWith("//")||W.startsWith("*")||W.startsWith("/*")||W==="}")continue;if(i5.test(W)){if(G!==-1&&q===G+1)Z.push({filePath:J.filePath,line:q+1,column:1,ruleId:"style/lines-between-class-members",message:"Missing blank line between class members",severity:"warning"});if(!W.endsWith("{"))G=q}}}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[],Y=!1,z=0,Q=0,G=-1;for(let q=0;q<Z.length;q++){let U=Z[q],W=U.trim();if(W.match(/\bclass\b/)&&(W.includes("{")||q+1<Z.length&&Z[q+1].trim()==="{"))Y=!0,Q=z+1;let K=z;for(let H of W){if(H==="{")z++;if(H==="}")z--}if(Y&&z<Q){Y=!1,G=-1,X.push(U);continue}if(Y&&K>Q&&z===Q&&W.endsWith("}")){G=q,X.push(U);continue}if(Y&&K===Q&&W&&!W.startsWith("//")&&!W.startsWith("*")&&!W.startsWith("/*")&&W!=="}"&&i5.test(W)){if(G!==-1&&q===G+1)X.push("");if(!W.endsWith("{"))G=q}X.push(U)}return X.join(`
162
- `)}};var e5={meta:{docs:"Limit the number of statements allowed on a single line"},check:($,J)=>{let Z=J.options&&typeof J.options.max==="number"?J.options.max:1,X=[],Y=$.split(/\r?\n/),z=(Q)=>{let G=M2(Q),q=G>=0?Q.slice(0,G):Q,U=0,W=!1,K=!1,H=!1,V=!1,A=!1,_=!1,F=!1,B=0,j="",D=(R)=>{if(R===" "||R==="\t")return;j=R};for(let R=0;R<q.length;R++){let S=q[R];if(_){_=!1;continue}if(S==="\\"){_=!0;continue}if(V){if(A){if(S==="]")A=!1;continue}if(S==="["){A=!0;continue}if(S==="/"){V=!1;while(R+1<q.length&&/[a-z]/i.test(q[R+1]))R++;j="/"}continue}if(!K&&!H&&S==="'"){W=!W,D(W?"'":"x");continue}if(!W&&!H&&S==='"'){K=!K,D(K?'"':"x");continue}if(!W&&!K&&S==="`"){H=!H,D(H?"`":"x");continue}if(W||K||H)continue;if(S==="/"&&$6(j,q,R)){V=!0;continue}if(!F){if(S==="f"&&q.slice(R,R+4).match(/^for\b/)){let f=q.slice(R+3).trimStart(),O=q.length-f.length;if(q[O]==="("){F=!0,B=1,R=O,j="(";continue}}}else if(S==="(")B++;else if(S===")"){if(B--,B<=0)F=!1}else if(S===";"){D(S);continue}if(S===";")U++;D(S)}if(U===0)return 1;return q.trimEnd().endsWith(";")?U:U+1};for(let Q=0;Q<Y.length;Q++){let G=Y[Q];if(/^\s*$/.test(G))continue;let q=z(G);if(q>Z)X.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"max-statements-per-line",message:`This line has ${q} statements. Maximum allowed is ${Z}`,severity:"warning"})}return X}};function M2($){let J=!1,Z=!1,X=!1,Y=!1,z=!1,Q=!1,G="";for(let q=0;q<$.length;q++){let U=$[q];if(Q){Q=!1;continue}if(U==="\\"){Q=!0;continue}if(Y){if(z){if(U==="]")z=!1;continue}if(U==="["){z=!0;continue}if(U==="/"){Y=!1;while(q+1<$.length&&/[a-z]/i.test($[q+1]))q++;G="/"}continue}if(!Z&&!X&&U==="'"){J=!J,G=U;continue}if(!J&&!X&&U==='"'){Z=!Z,G=U;continue}if(!J&&!Z&&U==="`"){X=!X,G=U;continue}if(J||Z||X)continue;if(U==="/"&&$[q+1]==="/")return q;if(U==="/"&&$6(G,$,q)){Y=!0;continue}if(U!==" "&&U!=="\t")G=U}return-1}function $6($,J,Z){if($==="")return!0;if("([{,:;!?&|=<>~^+*%-".includes($))return!0;if(/[A-Za-z_$]/.test($)){if(J.slice(0,Z).trimEnd().match(/(?:^|[^A-Za-z0-9_$])(return|typeof|instanceof|new|delete|void|in|of|yield|await|throw|case)$/))return!0}return!1}function Z6($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var J6={meta:{docs:"Enforce consistent multiline ternary expressions",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G=z.indexOf("?");if(G===-1)continue;if(z[G+1]==="."||z[G+1]==="?")continue;if(Z6(z,G))continue;if(z.indexOf(":",G+1)!==-1)continue;for(let U=Y+1;U<Math.min(Y+10,X.length);U++){let W=X[U].trim();if(W.startsWith(":"))break;let K=W.indexOf(":");if(K>0&&!Z6(X[U],K)){if(W.match(/^\w+\s*:/)||W.match(/^case\b/))continue;Z.push({filePath:J.filePath,line:U+1,column:X[U].indexOf(":")+1,ruleId:"style/multiline-ternary",message:"In multiline ternary, ':' should be at the start of the line",severity:"warning"});break}}}return Z}};var X6=new RegExp("\\bnew\\s+([A-Z][a-zA-Z0-9_$.]+)(?![a-zA-Z0-9_$])(?:\\s*<[^>]*>)?\\s*(?=[^(;\\n]|$)","g");function j2($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var Y6={meta:{docs:"Require parentheses when invoking a constructor with no arguments",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;X6.lastIndex=0;while((G=X6.exec(z))!==null){if(j2(z,G.index))continue;if(z.slice(G.index+G[0].length).startsWith("("))continue;if(G[0].includes("new."))continue;Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"style/new-parens",message:`Missing parentheses invoking constructor '${G[1]}'`,severity:"warning",help:"Add () after the constructor name."})}}return Z},fix($){return $.replace(/\bnew\s+([A-Z][a-zA-Z0-9_$.]+)(?![a-zA-Z0-9_$])(\s*<[^>]*>)?\s*(?=[^(]|$)/g,(J,Z,X)=>{if(J.slice(J.indexOf(Z)+Z.length+(X?.length||0)).trim().startsWith("("))return J;return`new ${Z}${X||""}()`})}};var zw=new RegExp("\\breturn\\s+\\(([^()]*)\\)\\s*[;\\n]","g"),z6=/^[a-zA-Z_$][a-zA-Z0-9_$.[\]'"`]*$/;var Q6={meta:{docs:"Remove redundant parentheses in return statements",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G=new RegExp("^return\\s+\\(([^()]*)\\)\\s*;?\\s*$"),q=Q.match(G);if(q){let U=q[1].trim();if(z6.test(U)||/^['"`]/.test(U)||/^\d/.test(U)||U==="true"||U==="false"||U==="null"||U==="undefined")Z.push({filePath:J.filePath,line:Y+1,column:z.indexOf("(")+1,ruleId:"style/no-extra-parens",message:"Unnecessary parentheses around return value",severity:"warning",help:"Remove the outer parentheses."})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X.trim(),z=new RegExp("^return\\s+\\(([^()]*)\\)\\s*(;?)\\s*$"),Q=Y.match(z);if(Q){let G=Q[1].trim(),q=Q[2];if(z6.test(G)||/^['"`]/.test(G)||/^\d/.test(G)||G==="true"||G==="false"||G==="null"||G==="undefined"){let U=X.match(/^(\s*)/)?.[1]||"";Z.push(`${U}return ${G}${q}`);continue}}Z.push(X)}return Z.join(`
162
+ `)}};var e5={meta:{docs:"Limit the number of statements allowed on a single line"},check:($,J)=>{let Z=J.options&&typeof J.options.max==="number"?J.options.max:1,X=[],Y=$.split(/\r?\n/),z=(Q)=>{let G=M2(Q),q=G>=0?Q.slice(0,G):Q,U=0,W=!1,K=!1,H=!1,V=!1,A=!1,_=!1,F=!1,B=0,j="",D=(R)=>{if(R===" "||R==="\t")return;j=R};for(let R=0;R<q.length;R++){let S=q[R];if(_){_=!1;continue}if(S==="\\"){_=!0;continue}if(V){if(A){if(S==="]")A=!1;continue}if(S==="["){A=!0;continue}if(S==="/"){V=!1;while(R+1<q.length&&/[a-z]/i.test(q[R+1]))R++;j="/"}continue}if(!K&&!H&&S==="'"){W=!W,D(W?"'":"x");continue}if(!W&&!H&&S==='"'){K=!K,D(K?'"':"x");continue}if(!W&&!K&&S==="`"){H=!H,D(H?"`":"x");continue}if(W||K||H)continue;if(S==="/"&&$6(j,q,R)){V=!0;continue}if(!F){if(S==="f"&&q.slice(R,R+4).match(/^for\b/)){let f=q.slice(R+3).trimStart(),O=q.length-f.length;if(q[O]==="("){F=!0,B=1,R=O,j="(";continue}}}else if(S==="(")B++;else if(S===")"){if(B--,B<=0)F=!1}else if(S===";"){D(S);continue}if(S===";")U++;D(S)}if(U===0)return 1;return q.trimEnd().endsWith(";")?U:U+1};for(let Q=0;Q<Y.length;Q++){let G=Y[Q];if(/^\s*$/.test(G))continue;let q=z(G);if(q>Z)X.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"max-statements-per-line",message:`This line has ${q} statements. Maximum allowed is ${Z}`,severity:"warning"})}return X}};function M2($){let J=!1,Z=!1,X=!1,Y=!1,z=!1,Q=!1,G="";for(let q=0;q<$.length;q++){let U=$[q];if(Q){Q=!1;continue}if(U==="\\"){Q=!0;continue}if(Y){if(z){if(U==="]")z=!1;continue}if(U==="["){z=!0;continue}if(U==="/"){Y=!1;while(q+1<$.length&&/[a-z]/i.test($[q+1]))q++;G="/"}continue}if(!Z&&!X&&U==="'"){J=!J,G=U;continue}if(!J&&!X&&U==='"'){Z=!Z,G=U;continue}if(!J&&!Z&&U==="`"){X=!X,G=U;continue}if(J||Z||X)continue;if(U==="/"&&$[q+1]==="/")return q;if(U==="/"&&$6(G,$,q)){Y=!0;continue}if(U!==" "&&U!=="\t")G=U}return-1}function $6($,J,Z){if($==="")return!0;if("([{,:;!?&|=<>~^+*%-".includes($))return!0;if(/[A-Za-z_$]/.test($)){if(J.slice(0,Z).trimEnd().match(/(?:^|[^A-Za-z0-9_$])(return|typeof|instanceof|new|delete|void|in|of|yield|await|throw|case)$/))return!0}return!1}function Z6($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var J6={meta:{docs:"Enforce consistent multiline ternary expressions",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G=z.indexOf("?");if(G===-1)continue;if(z[G+1]==="."||z[G+1]==="?")continue;if(Z6(z,G))continue;if(z.indexOf(":",G+1)!==-1)continue;for(let U=Y+1;U<Math.min(Y+10,X.length);U++){let W=X[U].trim();if(W.startsWith(":"))break;let K=W.indexOf(":");if(K>0&&!Z6(X[U],K)){if(W.match(/^\w+\s*:/)||W.match(/^case\b/))continue;Z.push({filePath:J.filePath,line:U+1,column:X[U].indexOf(":")+1,ruleId:"style/multiline-ternary",message:"In multiline ternary, ':' should be at the start of the line",severity:"warning"});break}}}return Z}};var X6=new RegExp("\\bnew\\s+([A-Z][a-zA-Z0-9_$.]+)(?![a-zA-Z0-9_$])(?:\\s*<[^>]*>)?\\s*(?=[^(;\\n]|$)","g");function j2($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var Y6={meta:{docs:"Require parentheses when invoking a constructor with no arguments",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;X6.lastIndex=0;while((G=X6.exec(z))!==null){if(j2(z,G.index))continue;if(z.slice(G.index+G[0].length).startsWith("("))continue;if(G[0].includes("new."))continue;Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"style/new-parens",message:`Missing parentheses invoking constructor '${G[1]}'`,severity:"warning",help:"Add () after the constructor name."})}}return Z},fix($){return $.replace(/\bnew\s+([A-Z][a-zA-Z0-9_$.]+)(?![a-zA-Z0-9_$])(\s*<[^>]*>)?\s*(?=[^(]|$)/g,(J,Z,X)=>{if(J.slice(J.indexOf(Z)+Z.length+(X?.length||0)).trim().startsWith("("))return J;return`new ${Z}${X||""}()`})}};var Gw=new RegExp("\\breturn\\s+\\(([^()]*)\\)\\s*[;\\n]","g"),z6=/^[a-zA-Z_$][a-zA-Z0-9_$.[\]'"`]*$/;var Q6={meta:{docs:"Remove redundant parentheses in return statements",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G=new RegExp("^return\\s+\\(([^()]*)\\)\\s*;?\\s*$"),q=Q.match(G);if(q){let U=q[1].trim();if(z6.test(U)||/^['"`]/.test(U)||/^\d/.test(U)||U==="true"||U==="false"||U==="null"||U==="undefined")Z.push({filePath:J.filePath,line:Y+1,column:z.indexOf("(")+1,ruleId:"style/no-extra-parens",message:"Unnecessary parentheses around return value",severity:"warning",help:"Remove the outer parentheses."})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X.trim(),z=new RegExp("^return\\s+\\(([^()]*)\\)\\s*(;?)\\s*$"),Q=Y.match(z);if(Q){let G=Q[1].trim(),q=Q[2];if(z6.test(G)||/^['"`]/.test(G)||/^\d/.test(G)||G==="true"||G==="false"||G==="null"||G==="undefined"){let U=X.match(/^(\s*)/)?.[1]||"";Z.push(`${U}return ${G}${q}`);continue}}Z.push(X)}return Z.join(`
163
163
  `)}};var G6=/(\S)\s+(\.)[a-zA-Z_$]/g,q6=/(\S)\s+(\?\.)[a-zA-Z_$]/g;function g8($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var U6={meta:{docs:"Disallow whitespace before . or ?. in property access",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;G6.lastIndex=0;while((G=G6.exec(z))!==null){let q=G[1],U=G.index+G[0].indexOf(".");if(g8(z,G.index))continue;if(U+1<z.length&&z[U+1]===".")continue;if(U>0&&z[U-1]===".")continue;Z.push({filePath:J.filePath,line:Y+1,column:U+1,ruleId:"style/no-whitespace-before-property",message:"Unexpected whitespace before property access dot",severity:"warning"})}q6.lastIndex=0;while((G=q6.exec(z))!==null){let q=G.index+G[0].indexOf("?.");if(g8(z,G.index))continue;Z.push({filePath:J.filePath,line:Y+1,column:q+1,ruleId:"style/no-whitespace-before-property",message:"Unexpected whitespace before optional chaining operator",severity:"warning"})}}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[];for(let Y=0;Y<Z.length;Y++){let z=Z[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*")){X.push(z);continue}let G=z;G=G.replace(/(\S)\s+(\?\.[a-zA-Z_$])/g,(q,U,W,K)=>{if(g8(z,K))return q;return U+W}),G=G.replace(/(\S)\s+(\.[a-zA-Z_$])/g,(q,U,W,K)=>{if(g8(z,K))return q;let H=K+q.indexOf(".");if(H+1<G.length&&G[H+1]===".")return q;return U+W}),X.push(G)}return X.join(`
164
- `)}};function F1($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var W6=/&&/g,K6=/\|\|/g,H6=/\?\?/g,V6=/(?<![&])&(?![&=])/g,A6=/(?<![|])\|(?![|=])/g,_6=/\^(?!=)/g;function N2($){let J=[];W6.lastIndex=0;let Z;while((Z=W6.exec($))!==null)if(!F1($,Z.index))J.push({op:"&&",group:0,index:Z.index});K6.lastIndex=0;while((Z=K6.exec($))!==null)if(!F1($,Z.index))J.push({op:"||",group:1,index:Z.index});H6.lastIndex=0;while((Z=H6.exec($))!==null)if(!F1($,Z.index))J.push({op:"??",group:2,index:Z.index});V6.lastIndex=0;while((Z=V6.exec($))!==null)if(!F1($,Z.index))J.push({op:"&",group:3,index:Z.index});A6.lastIndex=0;while((Z=A6.exec($))!==null)if(!F1($,Z.index))J.push({op:"|",group:4,index:Z.index});_6.lastIndex=0;while((Z=_6.exec($))!==null)if(!F1($,Z.index))J.push({op:"^",group:5,index:Z.index});return J.sort((X,Y)=>X.index-Y.index)}function T2($,J){if(J.length<2)return!0;let Z=[];for(let z of J){let Q=0;for(let G=0;G<z.index;G++)if($[G]==="(")Q++;else if($[G]===")")Q--;Z.push(Q)}let X=new Map;for(let z=0;z<J.length;z++){let Q=J[z].group;if(!X.has(Q))X.set(Q,[]);X.get(Q).push(Z[z])}let Y=[...X.entries()];if(Y.length===2){let[,z]=Y[0],[,Q]=Y[1],G=Math.min(...z),q=Math.max(...z),U=Math.min(...Q),W=Math.max(...Q);if(G>W||U>q)return!0}return!1}var E2=[{groups:[0,1],label:"&& and ||"},{groups:[0,2],label:"&& and ??"},{groups:[1,2],label:"|| and ??"},{groups:[3,4],label:"& and |"},{groups:[3,5],label:"& and ^"},{groups:[4,5],label:"| and ^"}],F6={meta:{docs:"Disallow mixed logical/bitwise operators without parentheses",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G=N2(z);if(G.length<2)continue;let q=new Set(G.map((U)=>U.group));for(let U of E2)if(q.has(U.groups[0])&&q.has(U.groups[1])){let W=G.filter((K)=>K.group===U.groups[0]||K.group===U.groups[1]);if(!T2(z,W)){let K=W.find((H)=>H.group===U.groups[1]);if(K)Z.push({filePath:J.filePath,line:Y+1,column:K.index+1,ruleId:"style/no-mixed-operators",message:`Unexpected mix of ${U.label} without parentheses`,severity:"warning"})}}}return Z}};var B6=/(?<![0-9.])\.\d/g,w6=/\d\.(?!\d|\.|\w)/g;function M6($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var j6={meta:{docs:"Disallow floating decimals like .5 or 2.",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;B6.lastIndex=0;while((G=B6.exec(z))!==null){if(M6(z,G.index))continue;if(G.index>0){let q=z[G.index-1];if(/[a-zA-Z_$)\]]/.test(q))continue}Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"style/no-floating-decimal",message:"Unexpected leading decimal point",severity:"warning",help:"Add a leading 0 before the decimal point: 0.5 instead of .5"})}w6.lastIndex=0;while((G=w6.exec(z))!==null){if(M6(z,G.index))continue;Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"style/no-floating-decimal",message:"Unexpected trailing decimal point",severity:"warning",help:"Add a trailing 0 after the decimal point: 2.0 instead of 2."})}}return Z},fix($){let J=$;return J=J.replace(/(?<![a-zA-Z_$0-9.)\]])\.\d/g,(Z)=>`0${Z}`),J=J.replace(/(\d)\.(?!\d|\.|\w)/g,(Z,X)=>`${X}.0`),J}};var N6={meta:{docs:"Disallow mixed spaces and tabs for indentation",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let Q=X[Y].match(/^(\s*)/)?.[1]||"";if(!Q)continue;let G=Q.includes("\t"),q=Q.includes(" ");if(G&&q)Z.push({filePath:J.filePath,line:Y+1,column:1,ruleId:"style/no-mixed-spaces-and-tabs",message:"Mixed spaces and tabs in indentation",severity:"warning",help:"Use either spaces or tabs for indentation, not both."})}return Z}};var T6={meta:{docs:"Disallow multiple consecutive spaces",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(!z.trim())continue;let Q=z.match(/^(\s*)/)?.[1]||"",G=z.slice(Q.length),q=/ {2,}/g,U;for(U=q.exec(G);U!==null;U=q.exec(G)){let W=Q.length+U.index+1,K=G.slice(0,U.index),H=(K.match(/'/g)||[]).length,V=(K.match(/"/g)||[]).length,A=(K.match(/`/g)||[]).length;if(H%2===1||V%2===1||A%2===1)continue;if(K.includes("//"))continue;if(z.trim().startsWith("*")||z.trim().startsWith("/*"))continue;Z.push({filePath:J.filePath,line:Y+1,column:W,ruleId:"style/no-multi-spaces",message:"Multiple spaces found",severity:"warning",help:"Remove extra spaces. Use single spaces between tokens."})}}return Z}};var E6={meta:{docs:"Disallow multiple consecutive blank lines",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=0,z=-1;for(let Q=0;Q<X.length;Q++)if(X[Q].trim()===""){if(Y++,z===-1)z=Q;if(Y>1&&Q===z+Y-1)Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"style/no-multiple-empty-lines",message:"More than 1 blank line not allowed",severity:"error",help:"Remove extra blank lines. Maximum 1 consecutive blank line allowed."})}else Y=0,z=-1;return Z}};var D6={meta:{docs:"Disallow tab characters (when using spaces for indentation)",recommended:!1},check($,J){let Z=[];if(J.config.format?.indentStyle==="tabs")return Z;let X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let Q=X[Y].indexOf("\t");if(Q!==-1)Z.push({filePath:J.filePath,line:Y+1,column:Q+1,ruleId:"style/no-tabs",message:"Unexpected tab character",severity:"warning",help:"Use spaces for indentation instead of tabs."})}return Z},fix($,J){let Z=J.config.format?.indent??2;return $.replace(/\t/g," ".repeat(Z))}};var R6={meta:{docs:"Disallow trailing whitespace at the end of lines",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.match(/(\s+)$/);if(Q){let G=z.length-Q[1].length+1;Z.push({filePath:J.filePath,line:Y+1,column:G,ruleId:"style/no-trailing-spaces",message:"Trailing spaces not allowed",severity:"error",help:"Remove trailing whitespace from the end of this line."})}}return Z}};function O6($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var L6={meta:{docs:"Require spaces inside curly braces in objects and destructuring",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;for(let G=0;G<z.length;G++){if(z[G]==="{"&&!O6(z,G)){let q=z[G+1];if(q==="}"||q===void 0||q===`
164
+ `)}};function B1($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var W6=/&&/g,K6=/\|\|/g,H6=/\?\?/g,V6=/(?<![&])&(?![&=])/g,A6=/(?<![|])\|(?![|=])/g,_6=/\^(?!=)/g;function N2($){let J=[];W6.lastIndex=0;let Z;while((Z=W6.exec($))!==null)if(!B1($,Z.index))J.push({op:"&&",group:0,index:Z.index});K6.lastIndex=0;while((Z=K6.exec($))!==null)if(!B1($,Z.index))J.push({op:"||",group:1,index:Z.index});H6.lastIndex=0;while((Z=H6.exec($))!==null)if(!B1($,Z.index))J.push({op:"??",group:2,index:Z.index});V6.lastIndex=0;while((Z=V6.exec($))!==null)if(!B1($,Z.index))J.push({op:"&",group:3,index:Z.index});A6.lastIndex=0;while((Z=A6.exec($))!==null)if(!B1($,Z.index))J.push({op:"|",group:4,index:Z.index});_6.lastIndex=0;while((Z=_6.exec($))!==null)if(!B1($,Z.index))J.push({op:"^",group:5,index:Z.index});return J.sort((X,Y)=>X.index-Y.index)}function T2($,J){if(J.length<2)return!0;let Z=[];for(let z of J){let Q=0;for(let G=0;G<z.index;G++)if($[G]==="(")Q++;else if($[G]===")")Q--;Z.push(Q)}let X=new Map;for(let z=0;z<J.length;z++){let Q=J[z].group;if(!X.has(Q))X.set(Q,[]);X.get(Q).push(Z[z])}let Y=[...X.entries()];if(Y.length===2){let[,z]=Y[0],[,Q]=Y[1],G=Math.min(...z),q=Math.max(...z),U=Math.min(...Q),W=Math.max(...Q);if(G>W||U>q)return!0}return!1}var E2=[{groups:[0,1],label:"&& and ||"},{groups:[0,2],label:"&& and ??"},{groups:[1,2],label:"|| and ??"},{groups:[3,4],label:"& and |"},{groups:[3,5],label:"& and ^"},{groups:[4,5],label:"| and ^"}],F6={meta:{docs:"Disallow mixed logical/bitwise operators without parentheses",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G=N2(z);if(G.length<2)continue;let q=new Set(G.map((U)=>U.group));for(let U of E2)if(q.has(U.groups[0])&&q.has(U.groups[1])){let W=G.filter((K)=>K.group===U.groups[0]||K.group===U.groups[1]);if(!T2(z,W)){let K=W.find((H)=>H.group===U.groups[1]);if(K)Z.push({filePath:J.filePath,line:Y+1,column:K.index+1,ruleId:"style/no-mixed-operators",message:`Unexpected mix of ${U.label} without parentheses`,severity:"warning"})}}}return Z}};var B6=/(?<![0-9.])\.\d/g,w6=/\d\.(?!\d|\.|\w)/g;function M6($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var j6={meta:{docs:"Disallow floating decimals like .5 or 2.",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;B6.lastIndex=0;while((G=B6.exec(z))!==null){if(M6(z,G.index))continue;if(G.index>0){let q=z[G.index-1];if(/[a-zA-Z_$)\]]/.test(q))continue}Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"style/no-floating-decimal",message:"Unexpected leading decimal point",severity:"warning",help:"Add a leading 0 before the decimal point: 0.5 instead of .5"})}w6.lastIndex=0;while((G=w6.exec(z))!==null){if(M6(z,G.index))continue;Z.push({filePath:J.filePath,line:Y+1,column:G.index+1,ruleId:"style/no-floating-decimal",message:"Unexpected trailing decimal point",severity:"warning",help:"Add a trailing 0 after the decimal point: 2.0 instead of 2."})}}return Z},fix($){let J=$;return J=J.replace(/(?<![a-zA-Z_$0-9.)\]])\.\d/g,(Z)=>`0${Z}`),J=J.replace(/(\d)\.(?!\d|\.|\w)/g,(Z,X)=>`${X}.0`),J}};var N6={meta:{docs:"Disallow mixed spaces and tabs for indentation",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let Q=X[Y].match(/^(\s*)/)?.[1]||"";if(!Q)continue;let G=Q.includes("\t"),q=Q.includes(" ");if(G&&q)Z.push({filePath:J.filePath,line:Y+1,column:1,ruleId:"style/no-mixed-spaces-and-tabs",message:"Mixed spaces and tabs in indentation",severity:"warning",help:"Use either spaces or tabs for indentation, not both."})}return Z}};var T6={meta:{docs:"Disallow multiple consecutive spaces",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];if(!z.trim())continue;let Q=z.match(/^(\s*)/)?.[1]||"",G=z.slice(Q.length),q=/ {2,}/g,U;for(U=q.exec(G);U!==null;U=q.exec(G)){let W=Q.length+U.index+1,K=G.slice(0,U.index),H=(K.match(/'/g)||[]).length,V=(K.match(/"/g)||[]).length,A=(K.match(/`/g)||[]).length;if(H%2===1||V%2===1||A%2===1)continue;if(K.includes("//"))continue;if(z.trim().startsWith("*")||z.trim().startsWith("/*"))continue;Z.push({filePath:J.filePath,line:Y+1,column:W,ruleId:"style/no-multi-spaces",message:"Multiple spaces found",severity:"warning",help:"Remove extra spaces. Use single spaces between tokens."})}}return Z}};var E6={meta:{docs:"Disallow multiple consecutive blank lines",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/),Y=0,z=-1;for(let Q=0;Q<X.length;Q++)if(X[Q].trim()===""){if(Y++,z===-1)z=Q;if(Y>1&&Q===z+Y-1)Z.push({filePath:J.filePath,line:Q+1,column:1,ruleId:"style/no-multiple-empty-lines",message:"More than 1 blank line not allowed",severity:"error",help:"Remove extra blank lines. Maximum 1 consecutive blank line allowed."})}else Y=0,z=-1;return Z}};var D6={meta:{docs:"Disallow tab characters (when using spaces for indentation)",recommended:!1},check($,J){let Z=[];if(J.config.format?.indentStyle==="tabs")return Z;let X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let Q=X[Y].indexOf("\t");if(Q!==-1)Z.push({filePath:J.filePath,line:Y+1,column:Q+1,ruleId:"style/no-tabs",message:"Unexpected tab character",severity:"warning",help:"Use spaces for indentation instead of tabs."})}return Z},fix($,J){let Z=J.config.format?.indent??2;return $.replace(/\t/g," ".repeat(Z))}};var R6={meta:{docs:"Disallow trailing whitespace at the end of lines",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.match(/(\s+)$/);if(Q){let G=z.length-Q[1].length+1;Z.push({filePath:J.filePath,line:Y+1,column:G,ruleId:"style/no-trailing-spaces",message:"Trailing spaces not allowed",severity:"error",help:"Remove trailing whitespace from the end of this line."})}}return Z}};function O6($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var L6={meta:{docs:"Require spaces inside curly braces in objects and destructuring",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;for(let G=0;G<z.length;G++){if(z[G]==="{"&&!O6(z,G)){let q=z[G+1];if(q==="}"||q===void 0||q===`
165
165
  `)continue;if(G>0&&z[G-1]==="$")continue;if(q!==" "&&q!=="\t")Z.push({filePath:J.filePath,line:Y+1,column:G+2,ruleId:"style/object-curly-spacing",message:"Missing space after '{'",severity:"warning"})}if(z[G]==="}"&&!O6(z,G)){let q=G>0?z[G-1]:void 0;if(q==="{"||q===void 0||q===`
166
166
  `)continue;if(G+1<z.length&&z.slice(G+1).match(/^[^}]*\$\{/))continue;if(q!==" "&&q!=="\t")Z.push({filePath:J.filePath,line:Y+1,column:G+1,ruleId:"style/object-curly-spacing",message:"Missing space before '}'",severity:"warning"})}}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X;Y=Y.replace(/(?<!\$)\{(\S)/g,(z,Q)=>{if(Q==="}")return z;return`{ ${Q}`}),Y=Y.replace(/(\S)\}/g,(z,Q)=>{if(Q==="{"||Q==="$")return z;return`${Q} }`}),Z.push(Y)}return Z.join(`
167
167
  `)}};var P6=/(\&\&|\|\||\?\?|\?|\+|(?<!=)-(?!=)|\*|\/|%|\*\*|\|(?!\|)|&(?!&)|\^|<<|>>>?)\s*$/;function C6($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var I6={meta:{docs:"Enforce operators at the beginning of continued lines",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G=Q.match(P6);if(G&&Y+1<X.length){let q=X[Y+1].trim();if(q&&!q.startsWith("//")&&!q.startsWith("*")){let U=z.lastIndexOf(G[1]);if(!C6(z,U)){if(G[1]==="?"||G[1]===":")continue;Z.push({filePath:J.filePath,line:Y+1,column:U+1,ruleId:"style/operator-linebreak",message:`Operator '${G[1]}' should be at the beginning of the next line`,severity:"warning"})}}}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X=0;X<J.length;X++){let Y=J[X],z=Y.trim();if(!z||z.startsWith("//")||z.startsWith("*")||z.startsWith("/*")||z.endsWith("*/")){Z.push(Y);continue}let Q=z.match(P6);if(Q&&X+1<J.length&&Q[1]!=="?"&&Q[1]!==":"){let G=J[X+1],q=G.trim();if(q&&!q.startsWith("//")&&!q.startsWith("*")){let U=Q[1],W=Y.lastIndexOf(Q[1]);if(C6(Y,W)){Z.push(Y);continue}Z.push(Y.replace(new RegExp(`\\s*${U.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*$`),""));let K=G.match(/^(\s*)/)?.[1]||"";J[X+1]=`${K}${U} ${q}`;continue}}Z.push(Y)}return Z.join(`
@@ -177,7 +177,7 @@ ${G}`;if(L7(q)!==q)return[{filePath:J.filePath,line:Y+1,column:1,ruleId:"sort-im
177
177
  `)Z.push({filePath:J.filePath,line:Y+1,column:q+3,ruleId:"style/spaced-comment",message:"Missing space after '/*'",severity:"warning",help:"Add a space after /* in comments."})}}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X;Y=Y.replace(/(\/\/)([^\s/!])/,"$1 $2"),Y=Y.replace(/(\/\*)([^\s*!])/,"$1 $2"),Z.push(Y)}return Z.join(`
178
178
  `)}};var s6=/^\s*(case\b.+?|default)\s*:/,n6={meta:{docs:"Enforce spacing around colon in switch case/default clauses",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q)continue;let G=Q.match(s6);if(!G)continue;let q=G[1],U=z.indexOf(":",z.indexOf(q)+q.length);if(U===-1)continue;if(U>0&&z[U-1]===" ")Z.push({filePath:J.filePath,line:Y+1,column:U+1,ruleId:"style/switch-colon-spacing",message:"Unexpected space before colon in switch case",severity:"warning"});if(U+1<z.length&&z[U+1]!==" "&&z[U+1]!=="\t"&&z[U+1]!==`
179
179
  `)Z.push({filePath:J.filePath,line:Y+1,column:U+2,ruleId:"style/switch-colon-spacing",message:"Missing space after colon in switch case",severity:"warning"})}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X,z=X.trim();if(s6.test(z))Y=Y.replace(/(case\b.+?|default)\s+:/,"$1:"),Y=Y.replace(/(case\b.+?:|default:)(\S)/,"$1 $2");Z.push(Y)}return Z.join(`
180
- `)}};var i6="${",t6={meta:{docs:"Disallow spaces inside template literal interpolation curly braces",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];for(let Q=z.indexOf(i6,0);Q!==-1;Q=z.indexOf(i6,Q)){let G=Q+2;if(G<z.length&&(z[G]===" "||z[G]==="\t")){if((z.slice(0,Q).match(/`/g)||[]).length%2===1)Z.push({filePath:J.filePath,line:Y+1,column:G+1,ruleId:"style/template-curly-spacing",message:"Unexpected space after '${'",severity:"warning"})}let q=1,U=G;while(U<z.length&&q>0){if(z[U]==="{")q++;if(z[U]==="}")q--;if(q>0)U++}if(q===0&&U>0){let W=z[U-1];if(W===" "||W==="\t"){if((z.slice(0,Q).match(/`/g)||[]).length%2===1)Z.push({filePath:J.filePath,line:Y+1,column:U,ruleId:"style/template-curly-spacing",message:"Unexpected space before '}'",severity:"warning"})}}Q=G}}return Z},fix($){return $.replace(/\$\{\s+([^}]*?)\s+\}/g,"${$1}")}};var B1=/([a-zA-Z_$][a-zA-Z0-9_$]*)\s+`/g;function e6($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var $Y=new Set(["return","case","typeof","void","delete","throw","new","in","of","await","yield","export","default","extends","else","instanceof"]),ZY={meta:{docs:"Disallow space between tag function and template literal",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;B1.lastIndex=0;for(G=B1.exec(z);G!==null;G=B1.exec(z)){let q=G[1],U=G.index;if(e6(z,U))continue;if($Y.has(q))continue;let W=U+q.length;Z.push({filePath:J.filePath,line:Y+1,column:W+1,ruleId:"style/template-tag-spacing",message:"Unexpected space between tag function and template literal",severity:"warning"})}}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[];for(let Y=0;Y<Z.length;Y++){let z=Z[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*")){X.push(z);continue}let G=z,q=[],U;B1.lastIndex=0;for(U=B1.exec(z);U!==null;U=B1.exec(z)){let W=U[1],K=U.index;if(e6(z,K))continue;if($Y.has(W))continue;q.push({index:K,fullMatch:U[0],identifier:W})}for(let W=q.length-1;W>=0;W--){let K=q[W],H=K.index,V=H+K.fullMatch.length;G=G.slice(0,H)+K.identifier+"`"+G.slice(V)}X.push(G)}return X.join(`
180
+ `)}};var i6="${",t6={meta:{docs:"Disallow spaces inside template literal interpolation curly braces",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y];for(let Q=z.indexOf(i6,0);Q!==-1;Q=z.indexOf(i6,Q)){let G=Q+2;if(G<z.length&&(z[G]===" "||z[G]==="\t")){if((z.slice(0,Q).match(/`/g)||[]).length%2===1)Z.push({filePath:J.filePath,line:Y+1,column:G+1,ruleId:"style/template-curly-spacing",message:"Unexpected space after '${'",severity:"warning"})}let q=1,U=G;while(U<z.length&&q>0){if(z[U]==="{")q++;if(z[U]==="}")q--;if(q>0)U++}if(q===0&&U>0){let W=z[U-1];if(W===" "||W==="\t"){if((z.slice(0,Q).match(/`/g)||[]).length%2===1)Z.push({filePath:J.filePath,line:Y+1,column:U,ruleId:"style/template-curly-spacing",message:"Unexpected space before '}'",severity:"warning"})}}Q=G}}return Z},fix($){return $.replace(/\$\{\s+([^}]*?)\s+\}/g,"${$1}")}};var w1=/([a-zA-Z_$][a-zA-Z0-9_$]*)\s+`/g;function e6($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var $Y=new Set(["return","case","typeof","void","delete","throw","new","in","of","await","yield","export","default","extends","else","instanceof"]),ZY={meta:{docs:"Disallow space between tag function and template literal",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;w1.lastIndex=0;for(G=w1.exec(z);G!==null;G=w1.exec(z)){let q=G[1],U=G.index;if(e6(z,U))continue;if($Y.has(q))continue;let W=U+q.length;Z.push({filePath:J.filePath,line:Y+1,column:W+1,ruleId:"style/template-tag-spacing",message:"Unexpected space between tag function and template literal",severity:"warning"})}}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[];for(let Y=0;Y<Z.length;Y++){let z=Z[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*")){X.push(z);continue}let G=z,q=[],U;w1.lastIndex=0;for(U=w1.exec(z);U!==null;U=w1.exec(z)){let W=U[1],K=U.index;if(e6(z,K))continue;if($Y.has(W))continue;q.push({index:K,fullMatch:U[0],identifier:W})}for(let W=q.length-1;W>=0;W--){let K=q[W],H=K.index,V=H+K.fullMatch.length;G=G.slice(0,H)+K.identifier+"`"+G.slice(V)}X.push(G)}return X.join(`
181
181
  `)}};var JY={meta:{docs:"Require parentheses around immediately invoked function expressions (IIFEs)",recommended:!0},check($,J){let Z=[],X=/[^a-zA-Z_$](function\s*\([^)]*\)\s*\{[^}]*\})\s*\(/g,Y;for(Y=X.exec($);Y!==null;Y=X.exec($)){if(Y.index>0&&$[Y.index]==="(")continue;let z=$.slice(0,Y.index).split(`
182
182
  `).length,Q=$.lastIndexOf(`
183
183
  `,Y.index),G=Y.index-Q;Z.push({filePath:J.filePath,line:z,column:G,ruleId:"style/wrap-iife",message:"Wrap immediately invoked function expressions in parentheses",severity:"warning"})}return Z},fix($){return $.replace(/([^a-zA-Z_$(\n])(function\s*\([^)]*\)\s*\{[^}]*\})\s*\(/g,"$1($2)(")}};var XY=/\byield\s*\*/g;function P2($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var YY={meta:{docs:"Enforce spacing around * in yield* expressions (no space before *, space after)",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;XY.lastIndex=0;while((G=XY.exec(z))!==null){let q=G.index;if(P2(z,q))continue;let U=G[0],W=q+U.length-1,K=W+1;if(U!=="yield*")Z.push({filePath:J.filePath,line:Y+1,column:W+1,ruleId:"style/yield-star-spacing",message:"Unexpected space before * in yield expression",severity:"warning"});if(K<z.length&&z[K]!==" "&&z[K]!=="\t"&&z[K]!==`
@@ -189,7 +189,7 @@ ${G}`;if(L7(q)!==q)return[{filePath:J.filePath,line:Y+1,column:1,ruleId:"sort-im
189
189
  `)}};function C2($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var FY=/([a-zA-Z_$][a-zA-Z0-9_$]*\??)\s*:\s*([A-Z][a-zA-Z0-9_$<>[\]|&]*|string|number|boolean|null|undefined|void|never|any|unknown|object|symbol|bigint)/g,BY={meta:{docs:"Require consistent spacing around type annotation colons",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G;FY.lastIndex=0;while((G=FY.exec(z))!==null){if(C2(z,G.index))continue;let q=G[0],U=q.indexOf(":"),W=G.index+U;if(U>0&&q[U-1]===" "&&!q.startsWith("?")){if(!G[1].endsWith("?")||q[U-1]===" "){if(z[W-1]===" "&&!/\?\s*$/.test(G[1]))Z.push({filePath:J.filePath,line:Y+1,column:W+1,ruleId:"ts/type-annotation-spacing",message:"Unexpected space before colon in type annotation",severity:"warning"})}}if(W+1<z.length&&z[W+1]!==" "&&z[W+1]!=="\t")Z.push({filePath:J.filePath,line:Y+1,column:W+2,ruleId:"ts/type-annotation-spacing",message:"Missing space after colon in type annotation",severity:"warning"})}}return Z},fix($){let J=$.split(/\r?\n/),Z=[];for(let X of J){let Y=X;Y=Y.replace(/([a-zA-Z_$][a-zA-Z0-9_$]*\??)\s*:\s*([A-Z][a-zA-Z0-9_$<>[\]|&]*|string|number|boolean|null|undefined|void|never|any|unknown|object|symbol|bigint)/g,"$1: $2"),Z.push(Y)}return Z.join(`
190
190
  `)}};function wY($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var MY=/([A-Za-z_$][A-Za-z0-9_$]*)\s*<(\s+)/g,jY=/(\s+)>(?!=)/g,I2=/([A-Za-z_$][A-Za-z0-9_$]*)\s*<\s+/g,S2=/\s+>(?!=)/g,NY={meta:{docs:"Disallow spaces inside TypeScript generic angle brackets",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;MY.lastIndex=0;let G;while((G=MY.exec(z))!==null){let q=G.index+G[1].length,U=z.indexOf("<",q);if(U===-1)continue;if(wY(z,U))continue;Z.push({filePath:J.filePath,line:Y+1,column:U+2,ruleId:"ts/type-generic-spacing",message:"Unexpected space after '<' in generic type",severity:"warning"})}jY.lastIndex=0;while((G=jY.exec(z))!==null){let q=G.index+G[1].length;if(wY(z,q))continue;let U=z.slice(0,q);if(!/[A-Za-z_$][A-Za-z0-9_$]*\s*</.test(U))continue;Z.push({filePath:J.filePath,line:Y+1,column:q+1,ruleId:"ts/type-generic-spacing",message:"Unexpected space before '>' in generic type",severity:"warning"})}}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[];for(let Y of Z){let z=Y.trim();if(!z||z.startsWith("//")||z.startsWith("*")||z.startsWith("/*")){X.push(Y);continue}let Q=Y;if(Q=Q.replace(I2,(G,q)=>{return`${q}<`}),/[A-Za-z_$][A-Za-z0-9_$]*\s*</.test(Q))Q=Q.replace(S2,">");X.push(Q)}return X.join(`
191
191
  `)}};function v2($,J){let Z=$.slice(0,J);if(Z.includes("//"))return!0;let X=(Z.match(/'/g)||[]).length,Y=(Z.match(/"/g)||[]).length,z=(Z.match(/`/g)||[]).length;return X%2===1||Y%2===1||z%2===1}var TY=/([a-zA-Z_$][a-zA-Z0-9_$?]*):(\S)/g,RY={meta:{docs:"Require space after colon in named tuple members",recommended:!0},check($,J){let Z=[],X=$.split(/\r?\n/);for(let Y=0;Y<X.length;Y++){let z=X[Y],Q=z.trim();if(!Q||Q.startsWith("//")||Q.startsWith("*")||Q.startsWith("/*"))continue;let G=EY(z);for(let q of G){TY.lastIndex=0;let U;while((U=TY.exec(q.text))!==null){let K=q.start+U.index+U[1].length;if(v2(z,K))continue;if(!DY(z))continue;Z.push({filePath:J.filePath,line:Y+1,column:K+2,ruleId:"ts/type-named-tuple-spacing",message:"Missing space after colon in named tuple member",severity:"warning"})}}}return Z},fix($,J){let Z=$.split(/\r?\n/),X=[];for(let Y of Z){let z=Y.trim();if(!z||z.startsWith("//")||z.startsWith("*")||z.startsWith("/*")){X.push(Y);continue}if(!DY(Y)){X.push(Y);continue}let Q=Y,G=EY(Y);for(let q=G.length-1;q>=0;q--){let U=G[q],W=U.text.replace(/([a-zA-Z_$][a-zA-Z0-9_$?]*):(\S)/g,"$1: $2");if(W!==U.text)Q=Q.slice(0,U.start)+W+Q.slice(U.start+U.text.length)}X.push(Q)}return X.join(`
192
- `)}};function EY($){let J=[],Z=0,X=-1;for(let Y=0;Y<$.length;Y++)if($[Y]==="["){if(Z===0)X=Y;Z++}else if($[Y]==="]"){if(Z--,Z===0&&X>=0)J.push({start:X,text:$.slice(X,Y+1)}),X=-1}return J}function DY($){let J=$.trim();return/\btype\s/.test(J)||/:\s*\[/.test(J)||/=\s*\[/.test(J)||/\bas\s/.test(J)||/<[^>]*\[/.test(J)||/\bextends\s/.test(J)||/\bimplements\s/.test(J)}var OY={name:"ts",rules:{"no-require-imports":w(WY),"no-top-level-await":w(KY),"no-ts-export-equal":w(HY),"no-explicit-any":w(GY),"prefer-nullish-coalescing":w(AY),"prefer-optional-chain":w(_Y),"no-floating-promises":w(qY),"no-misused-promises":w(UY),"no-unsafe-assignment":w(VY),"member-delimiter-style":w(QY),"type-annotation-spacing":w(BY),"type-generic-spacing":w(NY),"type-named-tuple-spacing":w(RY)}};var LY={name:"unused-imports",rules:{"no-unused-vars":w(i0),"no-unused-imports":w(i0)}};function Q9(){return[OZ,yZ,gX,fX,zY,uX,OY,sJ,V5,A5,tJ,rZ,KX,LY,eJ]}var G9=null;function SY(){if(!G9)G9=new $1("pickier",{showTags:!1});return G9}function M1(...$){if(v0.TRACE)SY().debug("[pickier:trace]",$)}async function CY($,J,Z){let X,Y=new Promise((z,Q)=>{X=setTimeout(()=>Q(Error(`Timeout after ${J}ms at ${Z}`)),J)});try{let z=await Promise.race([$,Y]);return clearTimeout(X),z}catch(z){throw SY().error(`[pickier:error] ${Z} failed:`,z?.message||z),M1("withTimeout error:",Z,z),z}}function vY($){if($.length===0)return"";let J=new Map;for(let X of $){let Y=J.get(X.filePath)||[];Y.push(X),J.set(X.filePath,Y)}let Z="";for(let[X,Y]of J){Z+=`
192
+ `)}};function EY($){let J=[],Z=0,X=-1;for(let Y=0;Y<$.length;Y++)if($[Y]==="["){if(Z===0)X=Y;Z++}else if($[Y]==="]"){if(Z--,Z===0&&X>=0)J.push({start:X,text:$.slice(X,Y+1)}),X=-1}return J}function DY($){let J=$.trim();return/\btype\s/.test(J)||/:\s*\[/.test(J)||/=\s*\[/.test(J)||/\bas\s/.test(J)||/<[^>]*\[/.test(J)||/\bextends\s/.test(J)||/\bimplements\s/.test(J)}var OY={name:"ts",rules:{"no-require-imports":w(WY),"no-top-level-await":w(KY),"no-ts-export-equal":w(HY),"no-explicit-any":w(GY),"prefer-nullish-coalescing":w(AY),"prefer-optional-chain":w(_Y),"no-floating-promises":w(qY),"no-misused-promises":w(UY),"no-unsafe-assignment":w(VY),"member-delimiter-style":w(QY),"type-annotation-spacing":w(BY),"type-generic-spacing":w(NY),"type-named-tuple-spacing":w(RY)}};var LY={name:"unused-imports",rules:{"no-unused-vars":w(i0),"no-unused-imports":w(i0)}};function Q9(){return[OZ,yZ,gX,fX,zY,uX,OY,sJ,V5,A5,tJ,rZ,KX,LY,eJ]}var G9=null;function SY(){if(!G9)G9=new Z1("pickier",{showTags:!1});return G9}function j1(...$){if(v0.TRACE)SY().debug("[pickier:trace]",$)}async function CY($,J,Z){let X,Y=new Promise((z,Q)=>{X=setTimeout(()=>Q(Error(`Timeout after ${J}ms at ${Z}`)),J)});try{let z=await Promise.race([$,Y]);return clearTimeout(X),z}catch(z){throw SY().error(`[pickier:error] ${Z} failed:`,z?.message||z),j1("withTimeout error:",Z,z),z}}function vY($){if($.length===0)return"";let J=new Map;for(let X of $){let Y=J.get(X.filePath)||[];Y.push(X),J.set(X.filePath,Y)}let Z="";for(let[X,Y]of J){Z+=`
193
193
  ${Z0.bold(`\x1B[4m${X}\x1B[24m`)}
194
194
  `;let z;try{z=IY(X,"utf8")}catch{for(let G of Y){let q=G.severity==="error"?Z0.red("error"):Z0.yellow("warn ");Z+=` ${G.line}:${G.column} ${q} ${G.message} ${Z0.blue(G.ruleId)}
195
195
  `}continue}let Q=z.split(/\r?\n/);for(let G of Y){let q=G.severity==="error"?Z0.red("!"):Z0.yellow("!"),U=Z0.blue(G.ruleId);Z+=`
@@ -204,15 +204,16 @@ ${Z0.bold(`\x1B[4m${X}\x1B[24m`)}
204
204
  `}}return Z}function yY($){if($.length===0)return"";let J=new Map;for(let X of $){let Y=J.get(X.filePath)||[];Y.push(X),J.set(X.filePath,Y)}let Z="";for(let[X,Y]of J){Z+=`
205
205
  ${Z0.bold(`\x1B[4m${X}\x1B[24m`)}
206
206
  `;for(let z of Y){let Q=z.severity==="error"?Z0.red("error"):Z0.yellow("warn "),q=`${z.line}:${z.column}`.padStart(6),U=60,W=z.message.padEnd(60);Z+=`${q} ${Q} ${W} ${Z0.blue(z.ruleId)}
207
- `}}return Z}async function Ij($,J){M1("runFormat:start",{globs:$,options:J});let Z=await g1(J.config),X=$.length?$:["."],Y=x1(X);M1("patterns",Y);let z=new Set((J.ext||Z.format.extensions.join(",")).split(",").map((F)=>{let B=F.trim();return B.startsWith(".")?B:`.${B}`})),Q=v0.TIMEOUT_MS,q=Y.some((F)=>{let B=F.replace(/\/?\*\*(?:\/\*+)?$/,"");return!(b2(B)?B:k2(w1.cwd(),B)).startsWith(w1.cwd())})?[...X1]:Z.ignores,U=p1(q),W=[];if(Y.length===1&&/\*\*\/\*$/.test(Y[0])){let F=Y[0].replace(/\/?\*\*\/\*$/,"");try{let{readdirSync:B,statSync:j}=await import("fs"),{join:D}=await import("path"),M=[F];while(M.length){let E=M.pop(),R=B(E);for(let S of R){let f=D(E,S),O=j(f);if(U(f))continue;if(O.isDirectory())M.push(f);else W.push(f)}}}catch{W=await CY(t0(Y,{dot:!1,ignore:q,onlyFiles:!0,absolute:!0}),Q,"glob")}}else W=await CY(t0(Y,{dot:!1,ignore:q,onlyFiles:!0,absolute:!0}),Q,"glob");M1("globbed entries",W.length);let H=W.filter((F)=>{if(U(F))return!1;let B=F.lastIndexOf(".");if(B<0)return!0;let j=F.slice(B);return z.has(j)});M1("filtered files",H.length);let V=0,A=[];for(let F of H){M1("format start",PY(w1.cwd(),F));let B=IY(F,"utf8"),j=x8(B,Z,F),D=j!==B;if(J.write){if(D)y2(F,j,"utf8")}if(D)A.push(PY(w1.cwd(),F));V++}let _=A.length;if(_>0){for(let F of A)console.log(Z0.gray(` ${F}`));console.log(J.write?Z0.gray(`Formatted ${_} of ${V} file(s).`):Z0.yellow(`${_} of ${V} file(s) need formatting. Run with --write to fix.`))}else if(J.verbose!==void 0?J.verbose:Z.verbose)console.log(Z0.gray(`Checked ${V} files, all formatted.`));return J.check&&_>0?1:0}var U9=null;function e(){if(!U9)U9=new $1("pickier:lint",{showTags:!1});return U9}function j0(...$){if(v0.TRACE)e().error("[pickier:trace]",$)}async function hj($,J,Z="untitled",X){if(X?.aborted)throw Error("AbortError");let Y=T1($),z=E1($),Q=D1(Z,$,J,Y,z);if(X?.aborted)throw Error("AbortError");try{let G=await A9(Z,$,J);for(let q of G){if(X?.aborted)throw Error("AbortError");if(f0(q.ruleId,q.line,Y))continue;if(z.has(q.line)&&u8(q.ruleId))continue;Q.push({filePath:q.filePath,line:q.line,column:q.column,ruleId:q.ruleId,message:q.message,severity:q.severity,...q.help&&{help:q.help}})}}catch{}return Q}async function uj($,J,Z){j0("runLintProgrammatic:start",{globs:$,options:J});let X=await g1(J.config);if(Z?.aborted)throw Error("AbortError");let Y=$.length?$:["."],z=x1(Y),Q=J.ext||X.lint.extensions.join(","),G=new Set(Q.split(",").map((P)=>{let C=P.trim();return C.startsWith(".")?C:`.${C}`})),q=v0.TIMEOUT_MS,W=z.some((P)=>{let C=P.replace(/\/?\*\*\/*\*\*$/,""),I=j1(C)?C:N1(P0.cwd(),C),L=P0.cwd();return I!==L&&!I.startsWith(L+mY)})?[...X1]:X.ignores,K=p1(W),H=[];if(z.length===1&&!/[*?[\]{}()!]/.test(z[0]))try{if(h8(z[0]).isFile())H=[j1(z[0])?z[0]:N1(P0.cwd(),z[0])]}catch{}let A=z.length===1&&/\*\*\/*\*$/.test(z[0]);if(!H.length&&A){let P=z[0].replace(/\/?\*\*\/*\*\*$/,""),C=j1(P)?P:N1(P0.cwd(),P);try{let I=[C];while(I.length){if(Z?.aborted)throw Error("AbortError");let L=I.pop(),T=pY(L);for(let k of T){let N=uY(L,k),v=h8(N);if(K(N))continue;if(v.isDirectory())I.push(N);else H.push(N)}}}catch{H=await u1(t0(z,{dot:!1,ignore:W,onlyFiles:!0,absolute:!0}),q,"glob")}}else if(!H.length)H=await u1(t0(z,{dot:!1,ignore:W,onlyFiles:!0,absolute:!0}),q,"glob");if(Z?.aborted)throw Error("AbortError");let _=0,F=0,B=0,j=0,D=0,M=[];for(let P of H){if(_++,P.replace(/\\/g,"/").includes("/node_modules/")){B++;continue}if(K(P)){j++;continue}if(!H9(P,G)){D++;continue}M.push(P),F++}j0("filter:programmatic",{total:_,included:F,node_modules:B,ignored:j,wrongExt:D});let E=v0.CONCURRENCY,f=(await oY(M,E,async(P)=>{if(Z?.aborted)throw Error("AbortError");let C=hY(P,"utf8"),I=T1(C),L=E1(C),T=D1(P,C,X,I,L);try{let k=await A9(P,C,X);for(let N of k){if(Z?.aborted)throw Error("AbortError");if(f0(N.ruleId,N.line,I))continue;if(L.has(N.line)&&u8(N.ruleId))continue;T.push({filePath:N.filePath,line:N.line,column:N.column,ruleId:N.ruleId,message:N.message,severity:N.severity,...N.help&&{help:N.help}})}}catch{}{let k=new Set;T=T.filter((N)=>{let v=`${N.line}:${N.column}:${N.ruleId}`;if(k.has(v))return!1;return k.add(v),!0})}if(J.fix){let k=/^\s*debugger\b/,N=C;if(X.rules.noDebugger==="error"||X.rules.noDebugger==="warn"){let g=N.split(/\r?\n/),x=[];for(let u of g){if(k.test(u))continue;x.push(u)}N=x.join(`
208
- `)}if(N=cY(P,N,X),N!==C){let g=T1(N),x=E1(N);if(T=D1(P,N,X,g,x),!J.dryRun)W9(P,N,"utf8")}}return T})).flat(),O=f.filter((P)=>P.severity==="error").length,h=f.filter((P)=>P.severity==="warning").length;return{errors:O,warnings:h,issues:f}}function f2($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function g2($){return $.replace(/-([a-z])/g,(J,Z)=>Z.toUpperCase())}function T1($){let J=new Map,Z=new Set,X=new Map,Y=new Map,z=$.split(/\r?\n/),Q=new Set;for(let U=0;U<z.length;U++){let W=z[U].trim(),K=U+1,H=W.match(/^\/\/\s*(?:eslint|pickier)-disable-next-line(?:\s+(\S.*))?$/);if(H){let B=H[1]?.replace(/\s+--\s.*$/,""),j=B?B.split(",").map((D)=>D.trim()).filter(Boolean):["*"];if(j.length>0){let D=K+1,M=J.get(D)||new Set;for(let E of j)M.add(E);J.set(D,M)}continue}let V=W.match(/^\/\*\s*(?:eslint|pickier)-disable(?:\s+([^*]+))?\s*\*\//);if(V){let B=V[1]?.trim().replace(/\s+--\s.*$/,"");if(!B||B==="")X.set(K,new Set(["*"])),Q.add("*");else{let j=B.split(",").map((M)=>M.trim()).filter(Boolean),D=X.get(K)||new Set;for(let M of j)D.add(M),Q.add(M);X.set(K,D)}if(U===0)if(!B||B==="")Z.add("*");else{let j=B.split(",").map((D)=>D.trim()).filter(Boolean);for(let D of j)Z.add(D)}continue}let A=W.match(/^\/\*\s*(?:eslint|pickier)-enable(?:\s+([^*]+))?\s*\*\//);if(A){let B=A[1]?.trim();if(!B||B==="")Y.set(K,new Set(["*"])),Q.clear();else{let j=B.split(",").map((M)=>M.trim()).filter(Boolean),D=Y.get(K)||new Set;for(let M of j)D.add(M),Q.delete(M);Y.set(K,D)}continue}let _=W.match(/^\/\/\s*(?:eslint|pickier)-disable(?:\s+(\S.*))?$/);if(_){let B=_[1]?.trim().replace(/\s+--\s.*$/,"");if(!B||B==="")X.set(K,new Set(["*"])),Q.add("*");else{let j=B.split(",").map((M)=>M.trim()).filter(Boolean),D=X.get(K)||new Set;for(let M of j)D.add(M),Q.add(M);X.set(K,D)}continue}let F=W.match(/^\/\/\s*(?:eslint|pickier)-enable(?:\s+(\S.*))?$/);if(F){let B=F[1]?.trim();if(!B||B==="")Y.set(K,new Set(["*"])),Q.clear();else{let j=B.split(",").map((M)=>M.trim()).filter(Boolean),D=Y.get(K)||new Set;for(let M of j)D.add(M),Q.delete(M);Y.set(K,D)}}}let G=Array.from(X.keys()).sort((U,W)=>U-W),q=Array.from(Y.keys()).sort((U,W)=>U-W);return{nextLine:J,fileLevel:Z,rangeDisable:X,rangeEnable:Y,sortedDisableLines:G,sortedEnableLines:q}}function f0($,J,Z){if(Z instanceof Map){let G=Z.get(J);if(!G||G.size===0)return!1;return h1($,G)}if(Z.fileLevel.size>0){if(h1($,Z.fileLevel))return!0}let X=Z.nextLine.get(J);if(X&&h1($,X))return!0;let Y=!1,z=0,Q=0;while(!0){let G=z<Z.sortedDisableLines.length?Z.sortedDisableLines[z]:Number.POSITIVE_INFINITY,q=Q<Z.sortedEnableLines.length?Z.sortedEnableLines[Q]:Number.POSITIVE_INFINITY,U=Math.min(G,q);if(U>=J)break;if(G===U){let K=Z.rangeDisable.get(G);if(h1($,K))Y=!0;z++;continue}let W=Z.rangeEnable.get(q);if(W.has("*")||h1($,W))Y=!1;Q++}return Y}function h1($,J){if(J.size===0)return!1;if(J.has("*"))return!0;if(J.has($))return!0;let Z=f2($);if(J.has(Z)||J.has(g2($)))return!0;for(let X of J)if(!X.includes("/")){if($.endsWith(`/${X}`))return!0}return!1}function u8($){return $!=="spaced-comment"&&!$.endsWith("/spaced-comment")}function dY($,J){if($.help)return $;let Z=J.includes("/")?J.split("/")[1]:J,X;if(Z.startsWith("no-"))X=`Remove or refactor this ${Z.replace("no-","").replace(/-/g," ")}. Check the rule documentation for more details or disable with: // eslint-disable-next-line ${J}`;else if(Z.startsWith("prefer-"))X=`Consider using ${Z.replace("prefer-","").replace(/-/g," ")} instead. This is a best practice recommendation. Disable with: // eslint-disable-next-line ${J} if needed`;else if(Z.includes("sort")||Z.includes("order"))X=`Reorder these items according to the rule requirements, or use --fix to auto-sort. Disable with: // eslint-disable-next-line ${J}`;else if(Z.includes("indent")||Z.includes("spacing")||Z.includes("newline"))X=`Fix the formatting issue. Run with --fix to automatically format. Disable with: // eslint-disable-next-line ${J}`;else X=`Fix this issue or disable the rule with: // eslint-disable-next-line ${J}. Check the rule documentation for more details`;return{...$,help:X}}async function u1($,J,Z){let X,Y=new Promise((z,Q)=>{X=setTimeout(()=>Q(Error(`Timeout after ${J}ms at ${Z}`)),J)});try{let z=await Promise.race([$,Y]);return clearTimeout(X),z}catch(z){throw e().error(`[pickier:error] ${Z} failed:`,z?.message||z),j0("withTimeout error:",Z,z),z}}async function oY($,J,Z){let X=Array($.length);if($.length===0)return X;let Y=0,z=Math.max(1,Math.min(Math.max(1,J),$.length));async function Q(){while(Y<$.length){let G=Y++;X[G]=await Z($[G],G)}}return await Promise.all(Array.from({length:z},Q)),X}var bY=new WeakMap;function x2($){let J=Q9();if($.plugins&&$.plugins.length>0){let Z=new Set(["pickier","style","regexp","ts"]),X=$.plugins.filter((z)=>typeof z!=="string");J=X.some((z)=>Z.has(z.name))?J:[];for(let z of X)J.push(z)}return J}function p2($,J){let Z={...$.pluginRules||{}};if($.rules?.noUnusedCapturingGroup)Z["regexp/no-unused-capturing-group"]=$.rules.noUnusedCapturingGroup;let X={"antfu/curly":"style/curly","antfu/if-newline":"style/if-newline","antfu/no-top-level-await":"ts/no-top-level-await"};for(let[Y,z]of Object.entries(X))if(Z[Y])Z[z]=Z[Y];for(let Y of Object.keys($.pluginRules||{}))if(!Y.includes("/")){for(let z of J)if(z.rules&&Object.prototype.hasOwnProperty.call(z.rules,Y))Z[`${z.name}/${Y}`]=$.pluginRules[Y]}return Z}function m8($){let J=bY.get($);if(J)return J;let Z=x2($),X=p2($,Z),Y=[],z=[],Q=new Set(["no-debugger"]),G=new Set(["no-debugger"]),q=new Set;for(let W of Z)for(let K in W.rules){let H=`${W.name}/${K}`,V=xY(X,H);if(!V.enabled)continue;if(q.has(K))continue;q.add(K);let A=W.rules[K],_={pluginName:W.name,ruleName:K,fullRuleId:H,rule:A,severity:V.severity,options:V.options};if(typeof A?.check==="function")Y.push(_);else if(V.severity==="error")Y.push(_);if(typeof A?.fix==="function")z.push(_),Q.add(H),G.add(K)}let U={checkRules:Y,fixRules:z,fixableRuleIds:Q,fixableBareRuleNames:G};return bY.set($,U),U}function h2($,J){return/\.(?:sh|bash|zsh|ksh|dash)$/.test($)||/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/.test(J)}function u2($){return/(?:^|[/\\])(?:bun\.lock|bun\.lockb|package-lock\.json|pnpm-lock\.yaml|yarn\.lock|npm-shrinkwrap\.json)$/.test($)}function V9($,J,Z){switch($.pluginName){case"markdown":return J.endsWith(".md");case"shell":return h2(J,Z);case"publint":return/(?:^|[/\\])package\.json$/.test(J);case"lockfile":return u2(J);case"node":case"ts":case"general":case"quality":case"eslint":case"regexp":case"unused-imports":case"perfectionist":return/\.(?:ts|js|tsx|jsx|mts|mjs|cts|cjs)$/.test(J);default:return!0}}async function A9($,J,Z){let X=[],Y=m8(Z),z={filePath:$,config:Z};for(let Q of Y.checkRules){if(!V9(Q,$,J))continue;let{fullRuleId:G,rule:q,severity:U}=Q;if(!q||typeof q.check!=="function"){if(U==="error")X.push({filePath:$,line:1,column:1,ruleId:`${G}-internal`,message:"Rule missing implementation (check function is undefined)",severity:"error"});continue}try{j0("rule:start",G);let W=v0.RULE_TIMEOUT_MS,K={...z,options:Q.options},H=performance.now(),V=await u1(Promise.resolve().then(()=>q.check(J,K)),W,`rule:${G}`),A=performance.now()-H;if(A>W)X.push({filePath:$,line:1,column:1,ruleId:`${G}-internal`,message:`Rule exceeded timeout budget: ${Math.round(A)}ms > ${W}ms`,severity:"error"});j0("rule:end",G,Array.isArray(V)?V.length:0);for(let _ of V){let F=dY(_,G);if(U)X.push({...F,severity:U});else X.push(F)}}catch(W){X.push({filePath:$,line:1,column:1,ruleId:`${G}-internal`,message:`Rule threw: ${W?.message||W}`,severity:"error"})}}return X}function cY($,J,Z){let X=m8(Z),Y={filePath:$,config:Z},z=J,Q=!0,G=0;while(Q&&G++<q9){Q=!1;for(let q of X.fixRules){if(!V9(q,$,z))continue;let U={...Y,options:q.options},W=q.rule.fix(z,U);if(W!==z)z=W,Q=!0}}return z}function m2($,J){let Z=J.format.indent,X=J.format.indentStyle,Y=$.split(/\r?\n/),z=!1;for(let Q=0;Q<Y.length;Q++){let G=Y[Q],q=0;while(q<G.length&&(G.charCodeAt(q)===32||G.charCodeAt(q)===9))q++;if(q===0)continue;let U=G.slice(0,q);if(!K9(U,Z,X,G))continue;let W;if(X==="tabs"){let K=0,H=0;for(let A=0;A<U.length;A++)if(U.charCodeAt(A)===9)H++;else K++;let V=Math.floor(K/Z);W="\t".repeat(H+V)}else{let K=0;for(let V=0;V<U.length;V++)if(U.charCodeAt(V)===9)K+=Z;else K++;let H=Math.floor(K/Z)*Z;W=" ".repeat(H)}if(W!==U)Y[Q]=W+G.slice(q),z=!0}return z?Y.join(`
209
- `):$}function kY($){let J="",Z=0;while(Z<$.length){if($[Z]==="/"&&Z>0){let X=$.slice(0,Z).trimEnd();if(/[=([{,:!&|?]$/.test(X)||/;$/.test(X)||X.endsWith("return")){Z++;while(Z<$.length){if($[Z]==="\\"){Z+=2;continue}if($[Z]==="/"){Z++;while(Z<$.length&&/[gimsuvy]/.test($[Z]))Z++;break}Z++}continue}}J+=$[Z],Z++}return J}function d2($,J,Z){if($==="")return!0;if("([{,:;!?&|=<>~^+*%-".includes($))return!0;if(/[A-Za-z_$]/.test($)){let Y=J.slice(0,Z).trimEnd();if(/(?:^|[^A-Za-z0-9_$])(?:return|typeof|instanceof|new|delete|void|in|of|yield|await|throw|case)$/.test(Y))return!0}return!1}function fY($){let J="",Z=0,X=null,Y=!1;while(Z<$.length){let z=$[Z],Q=$[Z+1];if(Y){J+=z,Y=!1,Z++;continue}if(z==="\\"&&X){Y=!0,J+=z,Z++;continue}if(!X){if(z==='"'){X="double",J+=z,Z++;continue}if(z==="'"){X="single",J+=z,Z++;continue}if(z==="`"){X="template",J+=z,Z++;continue}if(z==="/"&&Q==="/")break;if(z==="/"&&Q==="*"){Z+=2;while(Z<$.length){if($[Z]==="*"&&$[Z+1]==="/"){Z+=2;break}Z++}J+=" ";continue}J+=z,Z++}else{if(X==="double"&&z==='"'||X==="single"&&z==="'"||X==="template"&&z==="`")X=null;J+=z,Z++}}return J}function E1($){let J=new Set,Z="code",X=1,Y=!1,z=!1,Q=!1,G=[];for(let q=0;q<$.length;q++){let U=$[q],W=$[q+1],K=q>0?$[q-1]:"";if(U===`
207
+ `}}return Z}async function vj($,J){j1("runFormat:start",{globs:$,options:J});let Z=await g1(J.config),X=$.length?$:["."],Y=x1(X);j1("patterns",Y);let z=new Set((J.ext||Z.format.extensions.join(",")).split(",").map((F)=>{let B=F.trim();return B.startsWith(".")?B:`.${B}`})),Q=v0.TIMEOUT_MS,q=Y.some((F)=>{let B=F.replace(/\/?\*\*(?:\/\*+)?$/,"");return!(b2(B)?B:k2(M1.cwd(),B)).startsWith(M1.cwd())})?[...Y1]:Z.ignores,U=p1(q),W=[];if(Y.length===1&&/\*\*\/\*$/.test(Y[0])){let F=Y[0].replace(/\/?\*\*\/\*$/,"");try{let{readdirSync:B,statSync:j}=await import("fs"),{join:D}=await import("path"),M=[F];while(M.length){let E=M.pop(),R=B(E);for(let S of R){let f=D(E,S),O=j(f);if(U(f))continue;if(O.isDirectory())M.push(f);else W.push(f)}}}catch{W=await CY(e0(Y,{dot:!1,ignore:q,onlyFiles:!0,absolute:!0}),Q,"glob")}}else W=await CY(e0(Y,{dot:!1,ignore:q,onlyFiles:!0,absolute:!0}),Q,"glob");j1("globbed entries",W.length);let H=W.filter((F)=>{if(U(F))return!1;let B=F.lastIndexOf(".");if(B<0)return!0;let j=F.slice(B);return z.has(j)});j1("filtered files",H.length);let V=0,A=[];for(let F of H){j1("format start",PY(M1.cwd(),F));let B=IY(F,"utf8"),j=x8(B,Z,F),D=j!==B;if(J.write){if(D)y2(F,j,"utf8")}if(D)A.push(PY(M1.cwd(),F));V++}let _=A.length;if(_>0){for(let F of A)console.log(Z0.gray(` ${F}`));console.log(J.write?Z0.gray(`Formatted ${_} of ${V} file(s).`):Z0.yellow(`${_} of ${V} file(s) need formatting. Run with --write to fix.`))}else if(J.verbose!==void 0?J.verbose:Z.verbose)console.log(Z0.gray(`Checked ${V} files, all formatted.`));return J.check&&_>0?1:0}var U9=null;function e(){if(!U9)U9=new Z1("pickier:lint",{showTags:!1});return U9}function j0(...$){if(v0.TRACE)e().error("[pickier:trace]",$)}async function dj($,J,Z="untitled",X){if(X?.aborted)throw Error("AbortError");let Y=E1($),z=D1($),Q=R1(Z,$,J,Y,z);if(X?.aborted)throw Error("AbortError");try{let G=await A9(Z,$,J);for(let q of G){if(X?.aborted)throw Error("AbortError");if(f0(q.ruleId,q.line,Y))continue;if(z.has(q.line)&&u8(q.ruleId))continue;Q.push({filePath:q.filePath,line:q.line,column:q.column,ruleId:q.ruleId,message:q.message,severity:q.severity,...q.help&&{help:q.help}})}}catch{}return Q}async function oj($,J,Z){j0("runLintProgrammatic:start",{globs:$,options:J});let X=await g1(J.config);if(Z?.aborted)throw Error("AbortError");let Y=$.length?$:["."],z=x1(Y),Q=J.ext||X.lint.extensions.join(","),G=new Set(Q.split(",").map((P)=>{let C=P.trim();return C.startsWith(".")?C:`.${C}`})),q=v0.TIMEOUT_MS,W=z.some((P)=>{let C=P.replace(/\/?\*\*\/*\*\*$/,""),I=N1(C)?C:T1(P0.cwd(),C),L=P0.cwd();return I!==L&&!I.startsWith(L+mY)})?[...Y1]:X.ignores,K=p1(W),H=[];if(z.length===1&&!/[*?[\]{}()!]/.test(z[0]))try{if(h8(z[0]).isFile())H=[N1(z[0])?z[0]:T1(P0.cwd(),z[0])]}catch{}let A=z.length===1&&/\*\*\/*\*$/.test(z[0]);if(!H.length&&A){let P=z[0].replace(/\/?\*\*\/*\*\*$/,""),C=N1(P)?P:T1(P0.cwd(),P);try{let I=[C];while(I.length){if(Z?.aborted)throw Error("AbortError");let L=I.pop(),T=pY(L);for(let k of T){let N=uY(L,k),v=h8(N);if(K(N))continue;if(v.isDirectory())I.push(N);else H.push(N)}}}catch{H=await u1(e0(z,{dot:!1,ignore:W,onlyFiles:!0,absolute:!0}),q,"glob")}}else if(!H.length)H=await u1(e0(z,{dot:!1,ignore:W,onlyFiles:!0,absolute:!0}),q,"glob");if(Z?.aborted)throw Error("AbortError");let _=0,F=0,B=0,j=0,D=0,M=[];for(let P of H){if(_++,P.replace(/\\/g,"/").includes("/node_modules/")){B++;continue}if(K(P)){j++;continue}if(!H9(P,G)){D++;continue}M.push(P),F++}j0("filter:programmatic",{total:_,included:F,node_modules:B,ignored:j,wrongExt:D});let E=v0.CONCURRENCY,f=(await oY(M,E,async(P)=>{if(Z?.aborted)throw Error("AbortError");let C=hY(P,"utf8"),I=E1(C),L=D1(C),T=R1(P,C,X,I,L);try{let k=await A9(P,C,X);for(let N of k){if(Z?.aborted)throw Error("AbortError");if(f0(N.ruleId,N.line,I))continue;if(L.has(N.line)&&u8(N.ruleId))continue;T.push({filePath:N.filePath,line:N.line,column:N.column,ruleId:N.ruleId,message:N.message,severity:N.severity,...N.help&&{help:N.help}})}}catch{}{let k=new Set;T=T.filter((N)=>{let v=`${N.line}:${N.column}:${N.ruleId}`;if(k.has(v))return!1;return k.add(v),!0})}if(J.fix){let k=/^\s*debugger\b/,N=C;if(X.rules.noDebugger==="error"||X.rules.noDebugger==="warn"){let g=N.split(/\r?\n/),x=[];for(let u of g){if(k.test(u))continue;x.push(u)}N=x.join(`
208
+ `)}if(N=cY(P,N,X),N!==C){let g=E1(N),x=D1(N);if(T=R1(P,N,X,g,x),!J.dryRun)W9(P,N,"utf8")}}return T})).flat(),O=f.filter((P)=>P.severity==="error").length,h=f.filter((P)=>P.severity==="warning").length;return{errors:O,warnings:h,issues:f}}function f2($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function g2($){return $.replace(/-([a-z])/g,(J,Z)=>Z.toUpperCase())}function E1($){let J=new Map,Z=new Set,X=new Map,Y=new Map,z=$.split(/\r?\n/),Q=new Set;for(let U=0;U<z.length;U++){let W=z[U].trim(),K=U+1,H=W.match(/^\/\/\s*(?:eslint|pickier)-disable-next-line(?:\s+(\S.*))?$/);if(H){let B=H[1]?.replace(/\s+--\s.*$/,""),j=B?B.split(",").map((D)=>D.trim()).filter(Boolean):["*"];if(j.length>0){let D=K+1,M=J.get(D)||new Set;for(let E of j)M.add(E);J.set(D,M)}continue}let V=W.match(/^\/\*\s*(?:eslint|pickier)-disable(?:\s+([^*]+))?\s*\*\//);if(V){let B=V[1]?.trim().replace(/\s+--\s.*$/,"");if(!B||B==="")X.set(K,new Set(["*"])),Q.add("*");else{let j=B.split(",").map((M)=>M.trim()).filter(Boolean),D=X.get(K)||new Set;for(let M of j)D.add(M),Q.add(M);X.set(K,D)}if(U===0)if(!B||B==="")Z.add("*");else{let j=B.split(",").map((D)=>D.trim()).filter(Boolean);for(let D of j)Z.add(D)}continue}let A=W.match(/^\/\*\s*(?:eslint|pickier)-enable(?:\s+([^*]+))?\s*\*\//);if(A){let B=A[1]?.trim();if(!B||B==="")Y.set(K,new Set(["*"])),Q.clear();else{let j=B.split(",").map((M)=>M.trim()).filter(Boolean),D=Y.get(K)||new Set;for(let M of j)D.add(M),Q.delete(M);Y.set(K,D)}continue}let _=W.match(/^\/\/\s*(?:eslint|pickier)-disable(?:\s+(\S.*))?$/);if(_){let B=_[1]?.trim().replace(/\s+--\s.*$/,"");if(!B||B==="")X.set(K,new Set(["*"])),Q.add("*");else{let j=B.split(",").map((M)=>M.trim()).filter(Boolean),D=X.get(K)||new Set;for(let M of j)D.add(M),Q.add(M);X.set(K,D)}continue}let F=W.match(/^\/\/\s*(?:eslint|pickier)-enable(?:\s+(\S.*))?$/);if(F){let B=F[1]?.trim();if(!B||B==="")Y.set(K,new Set(["*"])),Q.clear();else{let j=B.split(",").map((M)=>M.trim()).filter(Boolean),D=Y.get(K)||new Set;for(let M of j)D.add(M),Q.delete(M);Y.set(K,D)}}}let G=Array.from(X.keys()).sort((U,W)=>U-W),q=Array.from(Y.keys()).sort((U,W)=>U-W);return{nextLine:J,fileLevel:Z,rangeDisable:X,rangeEnable:Y,sortedDisableLines:G,sortedEnableLines:q}}function f0($,J,Z){if(Z instanceof Map){let G=Z.get(J);if(!G||G.size===0)return!1;return h1($,G)}if(Z.fileLevel.size>0){if(h1($,Z.fileLevel))return!0}let X=Z.nextLine.get(J);if(X&&h1($,X))return!0;let Y=!1,z=0,Q=0;while(!0){let G=z<Z.sortedDisableLines.length?Z.sortedDisableLines[z]:Number.POSITIVE_INFINITY,q=Q<Z.sortedEnableLines.length?Z.sortedEnableLines[Q]:Number.POSITIVE_INFINITY,U=Math.min(G,q);if(U>=J)break;if(G===U){let K=Z.rangeDisable.get(G);if(h1($,K))Y=!0;z++;continue}let W=Z.rangeEnable.get(q);if(W.has("*")||h1($,W))Y=!1;Q++}return Y}function h1($,J){if(J.size===0)return!1;if(J.has("*"))return!0;if(J.has($))return!0;let Z=f2($);if(J.has(Z)||J.has(g2($)))return!0;for(let X of J)if(!X.includes("/")){if($.endsWith(`/${X}`))return!0}return!1}function u8($){return $!=="spaced-comment"&&!$.endsWith("/spaced-comment")}function dY($,J){if($.help)return $;let Z=J.includes("/")?J.split("/")[1]:J,X;if(Z.startsWith("no-"))X=`Remove or refactor this ${Z.replace("no-","").replace(/-/g," ")}. Check the rule documentation for more details or disable with: // eslint-disable-next-line ${J}`;else if(Z.startsWith("prefer-"))X=`Consider using ${Z.replace("prefer-","").replace(/-/g," ")} instead. This is a best practice recommendation. Disable with: // eslint-disable-next-line ${J} if needed`;else if(Z.includes("sort")||Z.includes("order"))X=`Reorder these items according to the rule requirements, or use --fix to auto-sort. Disable with: // eslint-disable-next-line ${J}`;else if(Z.includes("indent")||Z.includes("spacing")||Z.includes("newline"))X=`Fix the formatting issue. Run with --fix to automatically format. Disable with: // eslint-disable-next-line ${J}`;else X=`Fix this issue or disable the rule with: // eslint-disable-next-line ${J}. Check the rule documentation for more details`;return{...$,help:X}}async function u1($,J,Z){let X,Y=new Promise((z,Q)=>{X=setTimeout(()=>Q(Error(`Timeout after ${J}ms at ${Z}`)),J)});try{let z=await Promise.race([$,Y]);return clearTimeout(X),z}catch(z){throw e().error(`[pickier:error] ${Z} failed:`,z?.message||z),j0("withTimeout error:",Z,z),z}}async function oY($,J,Z){let X=Array($.length);if($.length===0)return X;let Y=0,z=Math.max(1,Math.min(Math.max(1,J),$.length));async function Q(){while(Y<$.length){let G=Y++;X[G]=await Z($[G],G)}}return await Promise.all(Array.from({length:z},Q)),X}var bY=new WeakMap;function x2($){let J=Q9();if($.plugins&&$.plugins.length>0){let Z=new Set(["pickier","style","regexp","ts"]),X=$.plugins.filter((z)=>typeof z!=="string");J=X.some((z)=>Z.has(z.name))?J:[];for(let z of X)J.push(z)}return J}function p2($,J){let Z={...$.pluginRules||{}};if($.rules?.noUnusedCapturingGroup)Z["regexp/no-unused-capturing-group"]=$.rules.noUnusedCapturingGroup;let X={"antfu/curly":"style/curly","antfu/if-newline":"style/if-newline","antfu/no-top-level-await":"ts/no-top-level-await"};for(let[Y,z]of Object.entries(X))if(Z[Y])Z[z]=Z[Y];for(let Y of Object.keys($.pluginRules||{}))if(!Y.includes("/")){for(let z of J)if(z.rules&&Object.prototype.hasOwnProperty.call(z.rules,Y))Z[`${z.name}/${Y}`]=$.pluginRules[Y]}return Z}function m8($){let J=bY.get($);if(J)return J;let Z=x2($),X=p2($,Z),Y=[],z=[],Q=new Set(["no-debugger"]),G=new Set(["no-debugger"]),q=new Set;for(let W of Z)for(let K in W.rules){let H=`${W.name}/${K}`,V=xY(X,H);if(!V.enabled)continue;if(q.has(K))continue;q.add(K);let A=W.rules[K],_={pluginName:W.name,ruleName:K,fullRuleId:H,rule:A,severity:V.severity,options:V.options};if(typeof A?.check==="function")Y.push(_);else if(V.severity==="error")Y.push(_);if(typeof A?.fix==="function")z.push(_),Q.add(H),G.add(K)}let U={checkRules:Y,fixRules:z,fixableRuleIds:Q,fixableBareRuleNames:G};return bY.set($,U),U}function h2($,J){return/\.(?:sh|bash|zsh|ksh|dash)$/.test($)||/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/.test(J)}function u2($){return/(?:^|[/\\])(?:bun\.lock|bun\.lockb|package-lock\.json|pnpm-lock\.yaml|yarn\.lock|npm-shrinkwrap\.json)$/.test($)}function V9($,J,Z){switch($.pluginName){case"markdown":return J.endsWith(".md");case"shell":return h2(J,Z);case"publint":return/(?:^|[/\\])package\.json$/.test(J);case"lockfile":return u2(J);case"node":case"ts":case"general":case"quality":case"eslint":case"regexp":case"unused-imports":case"perfectionist":return/\.(?:ts|js|tsx|jsx|mts|mjs|cts|cjs)$/.test(J);default:return!0}}async function A9($,J,Z){let X=[],Y=m8(Z),z={filePath:$,config:Z};for(let Q of Y.checkRules){if(!V9(Q,$,J))continue;let{fullRuleId:G,rule:q,severity:U}=Q;if(!q||typeof q.check!=="function"){if(U==="error")X.push({filePath:$,line:1,column:1,ruleId:`${G}-internal`,message:"Rule missing implementation (check function is undefined)",severity:"error"});continue}try{j0("rule:start",G);let W=v0.RULE_TIMEOUT_MS,K={...z,options:Q.options},H=performance.now(),V=await u1(Promise.resolve().then(()=>q.check(J,K)),W,`rule:${G}`),A=performance.now()-H;if(A>W)X.push({filePath:$,line:1,column:1,ruleId:`${G}-internal`,message:`Rule exceeded timeout budget: ${Math.round(A)}ms > ${W}ms`,severity:"error"});j0("rule:end",G,Array.isArray(V)?V.length:0);for(let _ of V){let F=dY(_,G);if(U)X.push({...F,severity:U});else X.push(F)}}catch(W){X.push({filePath:$,line:1,column:1,ruleId:`${G}-internal`,message:`Rule threw: ${W?.message||W}`,severity:"error"})}}return X}var m2=/\.(?:[cm]?[jt]sx?|vue|svelte|stx)$/i;function d2($,J,Z){if(!m2.test(Z)||!$.includes("`"))return J;let X=$.split(/\r?\n/),Y=J.split(/\r?\n/);if(X.length!==Y.length)return J;let z=t0($),Q=0;for(let G=0;G<Y.length;G++)if(z[G]&&Y[G]!==X[G])Y[G]=X[G],Q++;return Q>0?Y.join(`
209
+ `):J}function cY($,J,Z){let X=m8(Z),Y={filePath:$,config:Z},z=J,Q=!0,G=0;while(Q&&G++<q9){Q=!1;for(let q of X.fixRules){if(!V9(q,$,z))continue;let U={...Y,options:q.options},W=q.rule.fix(z,U),K=q.rule.meta?.editsStringContent?W:d2(z,W,$);if(K!==z)z=K,Q=!0}}return z}function o2($,J){let Z=J.format.indent,X=J.format.indentStyle,Y=$.split(/\r?\n/),z=!1;for(let Q=0;Q<Y.length;Q++){let G=Y[Q],q=0;while(q<G.length&&(G.charCodeAt(q)===32||G.charCodeAt(q)===9))q++;if(q===0)continue;let U=G.slice(0,q);if(!K9(U,Z,X,G))continue;let W;if(X==="tabs"){let K=0,H=0;for(let A=0;A<U.length;A++)if(U.charCodeAt(A)===9)H++;else K++;let V=Math.floor(K/Z);W="\t".repeat(H+V)}else{let K=0;for(let V=0;V<U.length;V++)if(U.charCodeAt(V)===9)K+=Z;else K++;let H=Math.floor(K/Z)*Z;W=" ".repeat(H)}if(W!==U)Y[Q]=W+G.slice(q),z=!0}return z?Y.join(`
210
+ `):$}function kY($){let J="",Z=0;while(Z<$.length){if($[Z]==="/"&&Z>0){let X=$.slice(0,Z).trimEnd();if(/[=([{,:!&|?]$/.test(X)||/;$/.test(X)||X.endsWith("return")){Z++;while(Z<$.length){if($[Z]==="\\"){Z+=2;continue}if($[Z]==="/"){Z++;while(Z<$.length&&/[gimsuvy]/.test($[Z]))Z++;break}Z++}continue}}J+=$[Z],Z++}return J}function c2($,J,Z){if($==="")return!0;if("([{,:;!?&|=<>~^+*%-".includes($))return!0;if(/[A-Za-z_$]/.test($)){let Y=J.slice(0,Z).trimEnd();if(/(?:^|[^A-Za-z0-9_$])(?:return|typeof|instanceof|new|delete|void|in|of|yield|await|throw|case)$/.test(Y))return!0}return!1}function fY($){let J="",Z=0,X=null,Y=!1;while(Z<$.length){let z=$[Z],Q=$[Z+1];if(Y){J+=z,Y=!1,Z++;continue}if(z==="\\"&&X){Y=!0,J+=z,Z++;continue}if(!X){if(z==='"'){X="double",J+=z,Z++;continue}if(z==="'"){X="single",J+=z,Z++;continue}if(z==="`"){X="template",J+=z,Z++;continue}if(z==="/"&&Q==="/")break;if(z==="/"&&Q==="*"){Z+=2;while(Z<$.length){if($[Z]==="*"&&$[Z+1]==="/"){Z+=2;break}Z++}J+=" ";continue}J+=z,Z++}else{if(X==="double"&&z==='"'||X==="single"&&z==="'"||X==="template"&&z==="`")X=null;J+=z,Z++}}return J}function D1($){let J=new Set,Z="code",X=1,Y=!1,z=!1,Q=!1,G=[];for(let q=0;q<$.length;q++){let U=$[q],W=$[q+1],K=q>0?$[q-1]:"";if(U===`
210
211
  `){if(Q&&Z==="block-comment")J.add(X);else if(!Y&&z&&Z!=="block-comment")J.add(X);else if(!Y&&Z==="block-comment")J.add(X);if(X++,Y=!1,z=!1,Q=Z==="block-comment",Z==="line-comment")Z="code";continue}switch(Z){case"code":if(U==="/"&&W==="/")Z="line-comment",z=!0,q++;else if(U==="/"&&W==="*"){let H=!1;if(q>0){let V=q-1;while(V>0&&($[V]===" "||$[V]==="\t"))V--;let A=$[V];if("=([{,;!&|?:~^%+-".includes(A)&&A!==`
211
212
  `)H=!0;else if(/[a-z]/.test(A)){let _=$.slice(Math.max(0,V-6),V+1);if(/\b(?:return|case|typeof|void|in|of|new|throw|delete)$/.test(_))H=!0}}if(H){Y=!0,q++;while(q<$.length){if($[q]==="\\"){q+=2;continue}if($[q]==="/"){q++;break}if($[q]===`
212
213
  `)break;q++}while(q<$.length&&/[gimsuy]/.test($[q]))q++;q--}else z=!0,Z="block-comment",q++}else if(U==="/"&&W!==void 0){let H=!1;if(q>0){let V=q-1;while(V>0&&($[V]===" "||$[V]==="\t"))V--;let A=$[V];if("=([{,;!&|?:~^%+-".includes(A)||A===`
213
214
  `)H=!0;else if(/[a-z]/.test(A)){let _=$.slice(Math.max(0,V-6),V+1);if(/\b(?:return|case|typeof|void|in|of|new|throw|delete)$/.test(_))H=!0}}if(H){Y=!0,q++;while(q<$.length){if($[q]==="\\"){q+=2;continue}if($[q]==="/"){q++;break}if($[q]===`
214
- `)break;q++}while(q<$.length&&/[gimsuy]/.test($[q]))q++;q--}else Y=!0}else if(U==="'")Z="string-single",Y=!0;else if(U==='"')Z="string-double",Y=!0;else if(U==="`")Z="string-template",Y=!0;else if(U==="{"){if(G.length)G[G.length-1]++;Y=!0}else if(U==="}"){if(G.length)if(G[G.length-1]===0)G.pop(),Z="string-template";else G[G.length-1]--;Y=!0}else if(!/\s/.test(U))Y=!0;break;case"string-single":if(U==="\\"){q++;break}if(U==="'")Z="code";break;case"string-double":if(U==="\\"){q++;break}if(U==='"')Z="code";break;case"string-template":if(U==="\\"){q++;break}if(U==="$"&&W==="{"){G.push(0),Z="code",q++;break}if(U==="`")Z="code";break;case"line-comment":break;case"block-comment":if(U==="*"&&W==="/")Z="code",q++;break}}if(Q&&Z==="block-comment")J.add(X);else if(!Y&&z&&Z!=="block-comment")J.add(X);else if(!Y&&Z==="block-comment")J.add(X);return J}function D1($,J,Z,X,Y){let z=[],Q=J.split(/\r?\n/),G=Z.format.quotes,q=$.split(".").pop()?.toLowerCase()??"",U=q==="md",W=q==="sh"||q==="bash"||q==="zsh"||q==="ksh"||q==="dash"||/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/.test(J),V=(Z.rules?.quotes??Z.pluginRules?.quotes??Z.pluginRules?.["style/quotes"])==="off"||q==="json"||q==="jsonc"||q==="lock"||U||q==="yaml"||q==="yml"||q==="stx"||q==="html"||q==="htm"||q==="vue"||W||$.endsWith("bun.lock"),A=U||q==="yaml"||q==="yml"||q==="json"||q==="jsonc"||W,j=(Z.rules?.indent??Z.pluginRules?.indent??Z.pluginRules?.["style/indent"])!=="off"&&!U&&!(q==="stx"||q==="html"||q==="htm"||q==="vue"),D=!1,M=(I)=>I==="warn"?"warning":I==="error"?"error":void 0,E=M(Z.rules.noDebugger),R=M(Z.rules.noConsole),S=M(Z.rules.noTemplateCurlyInString),f=M(Z.rules.noCondAssign),O=/\bconsole\.log\s*\(/,h=/^\s*debugger\b/,P=new Set;if(q==="md"){let I=!1;for(let L=0;L<Q.length;L++){if(/^(?:`{3,}|~{3,})/.test(Q[L].trim())){I=!I;continue}if(I)P.add(L+1)}}let C=new Set;if(J.includes("`")){let I=!1,L=!1,T=1;for(let k=0;k<J.length;k++){let N=J[k];if(L){if(L=!1,N===`
215
+ `)break;q++}while(q<$.length&&/[gimsuy]/.test($[q]))q++;q--}else Y=!0}else if(U==="'")Z="string-single",Y=!0;else if(U==='"')Z="string-double",Y=!0;else if(U==="`")Z="string-template",Y=!0;else if(U==="{"){if(G.length)G[G.length-1]++;Y=!0}else if(U==="}"){if(G.length)if(G[G.length-1]===0)G.pop(),Z="string-template";else G[G.length-1]--;Y=!0}else if(!/\s/.test(U))Y=!0;break;case"string-single":if(U==="\\"){q++;break}if(U==="'")Z="code";break;case"string-double":if(U==="\\"){q++;break}if(U==='"')Z="code";break;case"string-template":if(U==="\\"){q++;break}if(U==="$"&&W==="{"){G.push(0),Z="code",q++;break}if(U==="`")Z="code";break;case"line-comment":break;case"block-comment":if(U==="*"&&W==="/")Z="code",q++;break}}if(Q&&Z==="block-comment")J.add(X);else if(!Y&&z&&Z!=="block-comment")J.add(X);else if(!Y&&Z==="block-comment")J.add(X);return J}function R1($,J,Z,X,Y){let z=[],Q=J.split(/\r?\n/),G=Z.format.quotes,q=$.split(".").pop()?.toLowerCase()??"",U=q==="md",W=q==="sh"||q==="bash"||q==="zsh"||q==="ksh"||q==="dash"||/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/.test(J),V=(Z.rules?.quotes??Z.pluginRules?.quotes??Z.pluginRules?.["style/quotes"])==="off"||q==="json"||q==="jsonc"||q==="lock"||U||q==="yaml"||q==="yml"||q==="stx"||q==="html"||q==="htm"||q==="vue"||W||$.endsWith("bun.lock"),A=U||q==="yaml"||q==="yml"||q==="json"||q==="jsonc"||W,j=(Z.rules?.indent??Z.pluginRules?.indent??Z.pluginRules?.["style/indent"])!=="off"&&!U&&!(q==="stx"||q==="html"||q==="htm"||q==="vue"),D=!1,M=(I)=>I==="warn"?"warning":I==="error"?"error":void 0,E=M(Z.rules.noDebugger),R=M(Z.rules.noConsole),S=M(Z.rules.noTemplateCurlyInString),f=M(Z.rules.noCondAssign),O=/\bconsole\.log\s*\(/,h=/^\s*debugger\b/,P=new Set;if(q==="md"){let I=!1;for(let L=0;L<Q.length;L++){if(/^(?:`{3,}|~{3,})/.test(Q[L].trim())){I=!I;continue}if(I)P.add(L+1)}}let C=new Set;if(J.includes("`")){let I=!1,L=!1,T=1;for(let k=0;k<J.length;k++){let N=J[k];if(L){if(L=!1,N===`
215
216
  `)T++;continue}if(N==="\\"){L=!0;continue}if(N===`
216
- `){T++;continue}if(N==="`"){I=!I;continue}if(I)C.add(T)}}for(let I=0;I<Q.length;I++){let L=Q[I],T=I+1;if(Y.has(T))continue;if(!V&&!C.has(T)){let v=fY(kY(L)),g=gY(v,G);if(g.length>0&&!D){if(!f0("quotes",T,X))z.push({filePath:$,line:T,column:(g[0]||0)+1,ruleId:"quotes",message:"Inconsistent quote style",severity:"warning",help:`Use ${G} quotes consistently throughout your code. You can change the preferred quote style in your config with format.quotes: '${G==="single"?"double":"single"}'`});D=!0}}let k=0;while(k<L.length&&(L.charCodeAt(k)===32||L.charCodeAt(k)===9))k++;let N=k>0?L.slice(0,k):"";if(j&&N.length>0&&!P.has(T)&&K9(N,Z.format.indent,Z.format.indentStyle,L)){if(!f0("indent",T,X))z.push({filePath:$,line:T,column:1,ruleId:"indent",message:"Incorrect indentation detected",severity:"warning",help:`Use ${Z.format.indentStyle==="spaces"?`${Z.format.indent} spaces`:"tabs"} for indentation. Configure with format.indent and format.indentStyle in your config`})}if(!A&&E&&h.test(L)){if(!f0("no-debugger",T,X))z.push({filePath:$,line:T,column:1,ruleId:"no-debugger",message:"Unexpected debugger statement",severity:E,help:"Remove debugger statements before committing code. Use breakpoints in your IDE instead, or run with --fix to auto-remove"})}if(!A&&R&&!C.has(T)&&O.test(L)){let v=L.indexOf("//"),g=L.indexOf("console.");if(v!==-1&&g>v);else{let x=null;for(let u=0;u<L.length;u++){let d=L[u];if(!x){if(d==='"')x="double";else if(d==="'")x="single";else if(d==="`")x="template";else if(L.slice(u).startsWith("console.")){let p=u+1;if(!f0("no-console",T,X))z.push({filePath:$,line:T,column:p,ruleId:"no-console",message:"Unexpected console call",severity:R,help:"Remove console statements before committing. Use a proper logging library or disable this rule if console output is intentional"});break}}else if(x==="double"&&d==='"'||x==="single"&&d==="'"||x==="template"&&d==="`"){let p=0;for(let y=u-1;y>=0&&L[y]==="\\";y--)p++;if(p%2===0)x=null}}}}if(S&&!C.has(T)){let v=L,g=null,x=!1,u=!1,d="",p="";for(let y=0;y<v.length;y++){let b=v[y];if(x){if(p==="\\"){p=b;continue}if(u){if(b==="]")u=!1}else if(b==="[")u=!0;else if(b==="/"){x=!1;while(y+1<v.length&&/[a-z]/i.test(v[y+1]))y++;d="/"}p=b;continue}if(!g){if(b==='"'){g="double",p=b;continue}if(b==="'"){g="single",p=b;continue}if(b==="`"){g="template",p=b;continue}if(b==="/"&&v[y+1]!=="/"&&v[y+1]!=="*"&&d2(d,v,y)){x=!0,u=!1,p=b;continue}if(b!==" "&&b!=="\t")d=b}else if(g==="double"&&b==='"'||g==="single"&&b==="'"||g==="template"&&b==="`"){if(p!=="\\")g=null}else if(b==="$"&&v[y+1]==="{"&&p!=="\\"&&g!=="template"){if(!f0("no-template-curly-in-string",T,X))z.push({filePath:$,line:T,column:y+1,ruleId:"no-template-curly-in-string",message:"Unexpected template string expression in normal string",severity:S,help:"Change the string quotes from ' or \" to backticks (`) to use template literal interpolation, or escape the $ if you meant to use it literally"});break}p=b}}if(!A&&f&&!C.has(T)){let g=fY(kY(L)).replace(/'[^']*'|"[^"]*"/g,'""'),x=(y)=>/[^=!<>]=(?![=>])/.test(y),u=(y)=>{let b=L.match(y);if(b&&b.index!==void 0)return b.index+b[0].length;return Math.max(1,L.indexOf("(")+1)},d=g.match(/\b(?:if|while)\s*\(([^)]*)\)/);if(d){let y=d[1];if(x(y)){if(!f0("no-cond-assign",T,X))z.push({filePath:$,line:T,column:u(/\b(?:if|while)\s*\(/),ruleId:"no-cond-assign",message:"Unexpected assignment within a conditional expression",severity:f,help:"Use === or == for comparison instead of = (assignment). Wrap intentional assignments in extra parentheses."})}}let p=g.match(/\bfor\s*\(([^)]*)\)/);if(p){let b=p[1].split(";");if(b.length>=2){let a=b[1];if(x(a)){if(!f0("no-cond-assign",T,X))z.push({filePath:$,line:T,column:u(/\bfor\s*\(/),ruleId:"no-cond-assign",message:"Unexpected assignment within a conditional expression",severity:f,help:"Use === or == for comparison instead of = (assignment). Wrap intentional assignments in extra parentheses."})}}}}}return z}function mj($,J,Z){let X=T1(J),Y=E1(J),z=D1($,J,Z,X,Y);try{let Q=m8(Z),G={filePath:$,config:Z};for(let q of Q.checkRules){if(!V9(q,$,J))continue;if(!q.rule||typeof q.rule.check!=="function")continue;let U=q.rule.check(J,{...G,options:q.options});for(let W of U){if(f0(W.ruleId,W.line,X))continue;if(Y.has(W.line)&&u8(W.ruleId))continue;let K=dY(W,q.fullRuleId);z.push(q.severity?{...K,severity:q.severity}:K)}}}catch{}return z}async function dj($,J){j0("runLint:start",{globs:$,options:J});let Z=v0.DIAGNOSTICS;if(Z)e().info("[pickier:diagnostics] Starting lint process...");try{if(Z)e().info("[pickier:diagnostics] Loading config...");let X=await g1(J.config);j0("config:loaded",{reporter:X.lint.reporter,ext:X.lint.extensions.join(",")});let Y=$.length?$:["."],z=x1(Y);if(j0("patterns",z),Z)e().info(`[pickier:diagnostics] Patterns to search: ${z.join(", ")}`);let Q=J.ext||X.lint.extensions.join(","),G=new Set(Q.split(",").map((N)=>{let v=N.trim();return v.startsWith(".")?v:`.${v}`}));if(Z)e().info(`[pickier:diagnostics] File extensions: ${Array.from(G).join(", ")}`);let q=v0.TIMEOUT_MS;if(Z)e().info(`[pickier:diagnostics] Glob timeout: ${q}ms`);let U=z.some((N)=>{let v=N.replace(/\/?\*\*\/*\*\*$/,""),g=j1(v)?v:N1(P0.cwd(),v),x=P0.cwd();return g!==x&&!g.startsWith(x+mY)}),W=U?[...X1]:X.ignores,K=p1(W);if(Z){if(e().info(`[pickier:diagnostics] Globbing outside project: ${U}, ignore patterns: ${W.length}`),U)e().info(`[pickier:diagnostics] Using universal ignores: ${X1.slice(0,5).join(", ")}... (${X1.length} total)`)}let H=[],V=z.length===1&&!/[*?[\]{}()!]/.test(z[0]);if(Z)e().info(`[pickier:diagnostics] Starting file discovery... (nonGlobSingle: ${V})`);if(V)try{if(h8(z[0]).isFile())H=[j1(z[0])?z[0]:N1(P0.cwd(),z[0])]}catch{}let A=z.length===1&&/\*\*\/*\*$/.test(z[0]);if(!H.length&&A){let N=z[0].replace(/\/?\*\*\/*\*\*$/,"");if(Z)e().info(`[pickier:diagnostics] Using fast directory scan for: ${N}`);try{let g=[j1(N)?N:N1(P0.cwd(),N)],x=0;while(g.length){let u=g.pop();if(x++,Z&&x%100===0)e().info(`[pickier:diagnostics] Scanned ${x} directories, ${H.length} files found so far...`);let d=pY(u);for(let p of d){let y=uY(u,p),b=h8(y);if(K(y))continue;if(b.isDirectory())g.push(y);else H.push(y)}}if(Z)e().info(`[pickier:diagnostics] Fast scan complete: ${x} directories, ${H.length} total files`)}catch(v){if(Z)e().info(`[pickier:diagnostics] Fast scan failed: ${v?.message}, falling back to glob`);H=await u1(t0(z,{dot:!1,ignore:W,onlyFiles:!0,absolute:!0}),q,"glob")}}else if(!H.length){if(Z)e().info(`[pickier:diagnostics] Using glob with timeout ${q}ms...`);if(H=await u1(t0(z,{dot:!1,ignore:W,onlyFiles:!0,absolute:!0}),q,"glob"),Z)e().info(`[pickier:diagnostics] glob found ${H.length} files`)}if(j0("globbed entries",H.length),Z)e().info(`[pickier:diagnostics] File discovery complete: ${H.length} files found`);if(H.length>1e4){if(e().warn(`[pickier:warn] Found ${H.length} files. This seems unusually high and may cause memory issues.`),e().warn("[pickier:warn] Consider checking your ignore patterns or being more specific with your glob pattern."),e().warn("[pickier:warn] Common culprits: node_modules, build directories, cache folders, or vendor dependencies."),H.length>1e5)return e().error(`[pickier:error] File count exceeds 100,000 (${H.length}). This will likely cause out-of-memory errors.`),e().error("[pickier:error] Aborting to prevent crash. Please refine your glob pattern or ignore patterns."),1}if(Z)e().info(`[pickier:diagnostics] Filtering ${H.length} files by extension and ignore patterns...`);let _=0,F=0,B=0,j=0,D=0,M=[];for(let N of H){if(_++,Z&&_%1000===0)e().info(`[pickier:diagnostics] Filtering progress: ${_}/${H.length} files checked, ${F} included...`);if(N.replace(/\\/g,"/").includes("/node_modules/")){B++;continue}if(K(N)){j++;continue}if(!H9(N,G)){D++;continue}M.push(N),F++}if(j0("filter:cli",{total:_,included:F,node_modules:B,ignored:j,wrongExt:D}),j0("filtered files",M.length),Z)e().info("[pickier:diagnostics] Filtering complete:"),e().info(`[pickier:diagnostics] Total files found: ${_}`),e().info(`[pickier:diagnostics] Files to lint: ${F}`),e().info(`[pickier:diagnostics] Excluded (node_modules): ${B}`),e().info(`[pickier:diagnostics] Excluded (ignored): ${j}`),e().info(`[pickier:diagnostics] Excluded (wrong extension): ${D}`);if(M.length>5000){if(e().warn(`[pickier:warn] After filtering, ${M.length} files will be linted. This may take a while and use significant memory.`),M.length>50000)return e().error(`[pickier:error] ${M.length} files to lint exceeds safe limit (50,000). This will likely cause out-of-memory errors.`),e().error("[pickier:error] Aborting to prevent crash. Please be more specific with your glob pattern."),e().error("[pickier:error] Example: Instead of '../stx', try '../stx/src' or '../stx/packages/core'"),1}let E=v0.CONCURRENCY;if(Z)e().info(`[pickier:diagnostics] Starting to process ${M.length} files with concurrency ${E}...`);let R=0,S=!!J._formatOnly,h=(await oY(M,E,async(N)=>{if(Z){if(R++,R===1||R%10===0||R===M.length)e().info(`[pickier:diagnostics] Processing file ${R}/${M.length}: ${p8(P0.cwd(),N)}`)}let v=hY(N,"utf8");if(S){let p=x8(v,X,N);if(p!==v)if(!J.dryRun)W9(N,p,"utf8");else return[{filePath:N,line:1,column:1,ruleId:"format",message:"File is not formatted",severity:"error",help:"Run pickier format with --write to apply formatting."}];return[]}let g=T1(v),u=/\.(?:ts|js|tsx|jsx|mts|mjs|cts|cjs)$/.test(N)?E1(v):new Set,d=D1(N,v,X,g,u);try{let p=await A9(N,v,X);for(let y of p){if(f0(y.ruleId,y.line,g))continue;if(u.has(y.line)&&u8(y.ruleId))continue;d.push({filePath:y.filePath,line:y.line,column:y.column,ruleId:y.ruleId,message:y.message,severity:y.severity,...y.help&&{help:y.help}})}}catch{}{let p=new Set;d=d.filter((y)=>{let b=`${y.line}:${y.column}:${y.ruleId}`;if(p.has(b))return!1;return p.add(b),!0})}if(J.fix){let p=/^\s*debugger\b/,y=v;if(X.rules.noDebugger==="error"||X.rules.noDebugger==="warn"){let s=y.split(/\r?\n/),r=[];for(let o of s){if(p.test(o))continue;r.push(o)}y=r.join(`
217
- `)}y=cY(N,y,X);let a=N.split(".").pop()?.toLowerCase()??"";if(a!=="md"&&!(a==="sh"||a==="bash"||a==="zsh"||a==="ksh"||a==="dash")&&a!=="yaml"&&a!=="yml")y=m2(y,X);if(y!==v){let s=T1(y),r=E1(y);if(d=D1(N,y,X,s,r),!J.dryRun)W9(N,y,"utf8");if(J.dryRun&&(J.verbose!==void 0?J.verbose:X.verbose))e().debug(Z0.gray(`dry-run: would apply fixes in ${p8(P0.cwd(),N)}`))}}return j0("scan done",p8(P0.cwd(),N),d.length),d})).flat();if(Z)e().info(`[pickier:diagnostics] Processing complete! Found ${h.length} issues total`);let P=h.filter((N)=>N.severity==="error").length,C=h.filter((N)=>N.severity==="warning").length;if(j0("issues:summary",{errors:P,warnings:C}),Z)e().info(`[pickier:diagnostics] Errors: ${P}, Warnings: ${C}`);let I=J.reporter||X.lint.reporter,L=J.verbose!==void 0?J.verbose:X.verbose;if(I==="json")console.log(JSON.stringify({errors:P,warnings:C,issues:h},null,2));else if(I==="compact")for(let N of h)console.log(`${p8(P0.cwd(),N.filePath)}:${N.line}:${N.column} ${N.severity} ${N.ruleId} ${N.message}`);else if(h.length>0)console.log(L?vY(h):yY(h));if(h.length>0&&I!=="json"){let N=P+C,v=N===1?"problem":"problems",g=P===1?"error":"errors",x=C===1?"warning":"warnings",u=m8(X),d=0,p=0;for(let y of h){let b=y.ruleId;if(u.fixableRuleIds.has(b)||u.fixableBareRuleNames.has(b)){if(y.severity==="error")d++;else if(y.severity==="warning")p++}}if(console.log(),console.log(Z0.red(`\u2716 ${N} ${v} (${P} ${g}, ${C} ${x})`)),d>0||p>0){let y=d===1?"error":"errors",b=p===1?"warning":"warnings";console.log(Z0.gray(` ${d} ${y} and ${p} ${b} potentially fixable with the \`--fix\` option.`))}}if(L&&I!=="json")console.log(Z0.gray(`Scanned ${M.length} files, found ${P} errors and ${C} warnings.`));let T=J.maxWarnings??X.lint.maxWarnings,k=v0.FAIL_ON_WARNINGS;if(P>0)return j0("runLint:end",1),1;if(k&&C>0)return j0("runLint:end",1),1;if(T>=0&&C>T)return j0("runLint:end",1),1;return j0("runLint:end",0),0}catch(X){return e().error("[pickier:error] runLint failed:",X?.message||X),j0("runLint:exception",X),1}}
218
- export{Ij as a,hj as b,uj as c,A9 as d,D1 as e,mj as f,dj as g};
217
+ `){T++;continue}if(N==="`"){I=!I;continue}if(I)C.add(T)}}for(let I=0;I<Q.length;I++){let L=Q[I],T=I+1;if(Y.has(T))continue;if(!V&&!C.has(T)){let v=fY(kY(L)),g=gY(v,G);if(g.length>0&&!D){if(!f0("quotes",T,X))z.push({filePath:$,line:T,column:(g[0]||0)+1,ruleId:"quotes",message:"Inconsistent quote style",severity:"warning",help:`Use ${G} quotes consistently throughout your code. You can change the preferred quote style in your config with format.quotes: '${G==="single"?"double":"single"}'`});D=!0}}let k=0;while(k<L.length&&(L.charCodeAt(k)===32||L.charCodeAt(k)===9))k++;let N=k>0?L.slice(0,k):"";if(j&&N.length>0&&!P.has(T)&&K9(N,Z.format.indent,Z.format.indentStyle,L)){if(!f0("indent",T,X))z.push({filePath:$,line:T,column:1,ruleId:"indent",message:"Incorrect indentation detected",severity:"warning",help:`Use ${Z.format.indentStyle==="spaces"?`${Z.format.indent} spaces`:"tabs"} for indentation. Configure with format.indent and format.indentStyle in your config`})}if(!A&&E&&h.test(L)){if(!f0("no-debugger",T,X))z.push({filePath:$,line:T,column:1,ruleId:"no-debugger",message:"Unexpected debugger statement",severity:E,help:"Remove debugger statements before committing code. Use breakpoints in your IDE instead, or run with --fix to auto-remove"})}if(!A&&R&&!C.has(T)&&O.test(L)){let v=L.indexOf("//"),g=L.indexOf("console.");if(v!==-1&&g>v);else{let x=null;for(let u=0;u<L.length;u++){let d=L[u];if(!x){if(d==='"')x="double";else if(d==="'")x="single";else if(d==="`")x="template";else if(L.slice(u).startsWith("console.")){let p=u+1;if(!f0("no-console",T,X))z.push({filePath:$,line:T,column:p,ruleId:"no-console",message:"Unexpected console call",severity:R,help:"Remove console statements before committing. Use a proper logging library or disable this rule if console output is intentional"});break}}else if(x==="double"&&d==='"'||x==="single"&&d==="'"||x==="template"&&d==="`"){let p=0;for(let y=u-1;y>=0&&L[y]==="\\";y--)p++;if(p%2===0)x=null}}}}if(S&&!C.has(T)){let v=L,g=null,x=!1,u=!1,d="",p="";for(let y=0;y<v.length;y++){let b=v[y];if(x){if(p==="\\"){p=b;continue}if(u){if(b==="]")u=!1}else if(b==="[")u=!0;else if(b==="/"){x=!1;while(y+1<v.length&&/[a-z]/i.test(v[y+1]))y++;d="/"}p=b;continue}if(!g){if(b==='"'){g="double",p=b;continue}if(b==="'"){g="single",p=b;continue}if(b==="`"){g="template",p=b;continue}if(b==="/"&&v[y+1]!=="/"&&v[y+1]!=="*"&&c2(d,v,y)){x=!0,u=!1,p=b;continue}if(b!==" "&&b!=="\t")d=b}else if(g==="double"&&b==='"'||g==="single"&&b==="'"||g==="template"&&b==="`"){if(p!=="\\")g=null}else if(b==="$"&&v[y+1]==="{"&&p!=="\\"&&g!=="template"){if(!f0("no-template-curly-in-string",T,X))z.push({filePath:$,line:T,column:y+1,ruleId:"no-template-curly-in-string",message:"Unexpected template string expression in normal string",severity:S,help:"Change the string quotes from ' or \" to backticks (`) to use template literal interpolation, or escape the $ if you meant to use it literally"});break}p=b}}if(!A&&f&&!C.has(T)){let g=fY(kY(L)).replace(/'[^']*'|"[^"]*"/g,'""'),x=(y)=>/[^=!<>]=(?![=>])/.test(y),u=(y)=>{let b=L.match(y);if(b&&b.index!==void 0)return b.index+b[0].length;return Math.max(1,L.indexOf("(")+1)},d=g.match(/\b(?:if|while)\s*\(([^)]*)\)/);if(d){let y=d[1];if(x(y)){if(!f0("no-cond-assign",T,X))z.push({filePath:$,line:T,column:u(/\b(?:if|while)\s*\(/),ruleId:"no-cond-assign",message:"Unexpected assignment within a conditional expression",severity:f,help:"Use === or == for comparison instead of = (assignment). Wrap intentional assignments in extra parentheses."})}}let p=g.match(/\bfor\s*\(([^)]*)\)/);if(p){let b=p[1].split(";");if(b.length>=2){let a=b[1];if(x(a)){if(!f0("no-cond-assign",T,X))z.push({filePath:$,line:T,column:u(/\bfor\s*\(/),ruleId:"no-cond-assign",message:"Unexpected assignment within a conditional expression",severity:f,help:"Use === or == for comparison instead of = (assignment). Wrap intentional assignments in extra parentheses."})}}}}}return z}function cj($,J,Z){let X=E1(J),Y=D1(J),z=R1($,J,Z,X,Y);try{let Q=m8(Z),G={filePath:$,config:Z};for(let q of Q.checkRules){if(!V9(q,$,J))continue;if(!q.rule||typeof q.rule.check!=="function")continue;let U=q.rule.check(J,{...G,options:q.options});for(let W of U){if(f0(W.ruleId,W.line,X))continue;if(Y.has(W.line)&&u8(W.ruleId))continue;let K=dY(W,q.fullRuleId);z.push(q.severity?{...K,severity:q.severity}:K)}}}catch{}return z}async function rj($,J){j0("runLint:start",{globs:$,options:J});let Z=v0.DIAGNOSTICS;if(Z)e().info("[pickier:diagnostics] Starting lint process...");try{if(Z)e().info("[pickier:diagnostics] Loading config...");let X=await g1(J.config);j0("config:loaded",{reporter:X.lint.reporter,ext:X.lint.extensions.join(",")});let Y=$.length?$:["."],z=x1(Y);if(j0("patterns",z),Z)e().info(`[pickier:diagnostics] Patterns to search: ${z.join(", ")}`);let Q=J.ext||X.lint.extensions.join(","),G=new Set(Q.split(",").map((N)=>{let v=N.trim();return v.startsWith(".")?v:`.${v}`}));if(Z)e().info(`[pickier:diagnostics] File extensions: ${Array.from(G).join(", ")}`);let q=v0.TIMEOUT_MS;if(Z)e().info(`[pickier:diagnostics] Glob timeout: ${q}ms`);let U=z.some((N)=>{let v=N.replace(/\/?\*\*\/*\*\*$/,""),g=N1(v)?v:T1(P0.cwd(),v),x=P0.cwd();return g!==x&&!g.startsWith(x+mY)}),W=U?[...Y1]:X.ignores,K=p1(W);if(Z){if(e().info(`[pickier:diagnostics] Globbing outside project: ${U}, ignore patterns: ${W.length}`),U)e().info(`[pickier:diagnostics] Using universal ignores: ${Y1.slice(0,5).join(", ")}... (${Y1.length} total)`)}let H=[],V=z.length===1&&!/[*?[\]{}()!]/.test(z[0]);if(Z)e().info(`[pickier:diagnostics] Starting file discovery... (nonGlobSingle: ${V})`);if(V)try{if(h8(z[0]).isFile())H=[N1(z[0])?z[0]:T1(P0.cwd(),z[0])]}catch{}let A=z.length===1&&/\*\*\/*\*$/.test(z[0]);if(!H.length&&A){let N=z[0].replace(/\/?\*\*\/*\*\*$/,"");if(Z)e().info(`[pickier:diagnostics] Using fast directory scan for: ${N}`);try{let g=[N1(N)?N:T1(P0.cwd(),N)],x=0;while(g.length){let u=g.pop();if(x++,Z&&x%100===0)e().info(`[pickier:diagnostics] Scanned ${x} directories, ${H.length} files found so far...`);let d=pY(u);for(let p of d){let y=uY(u,p),b=h8(y);if(K(y))continue;if(b.isDirectory())g.push(y);else H.push(y)}}if(Z)e().info(`[pickier:diagnostics] Fast scan complete: ${x} directories, ${H.length} total files`)}catch(v){if(Z)e().info(`[pickier:diagnostics] Fast scan failed: ${v?.message}, falling back to glob`);H=await u1(e0(z,{dot:!1,ignore:W,onlyFiles:!0,absolute:!0}),q,"glob")}}else if(!H.length){if(Z)e().info(`[pickier:diagnostics] Using glob with timeout ${q}ms...`);if(H=await u1(e0(z,{dot:!1,ignore:W,onlyFiles:!0,absolute:!0}),q,"glob"),Z)e().info(`[pickier:diagnostics] glob found ${H.length} files`)}if(j0("globbed entries",H.length),Z)e().info(`[pickier:diagnostics] File discovery complete: ${H.length} files found`);if(H.length>1e4){if(e().warn(`[pickier:warn] Found ${H.length} files. This seems unusually high and may cause memory issues.`),e().warn("[pickier:warn] Consider checking your ignore patterns or being more specific with your glob pattern."),e().warn("[pickier:warn] Common culprits: node_modules, build directories, cache folders, or vendor dependencies."),H.length>1e5)return e().error(`[pickier:error] File count exceeds 100,000 (${H.length}). This will likely cause out-of-memory errors.`),e().error("[pickier:error] Aborting to prevent crash. Please refine your glob pattern or ignore patterns."),1}if(Z)e().info(`[pickier:diagnostics] Filtering ${H.length} files by extension and ignore patterns...`);let _=0,F=0,B=0,j=0,D=0,M=[];for(let N of H){if(_++,Z&&_%1000===0)e().info(`[pickier:diagnostics] Filtering progress: ${_}/${H.length} files checked, ${F} included...`);if(N.replace(/\\/g,"/").includes("/node_modules/")){B++;continue}if(K(N)){j++;continue}if(!H9(N,G)){D++;continue}M.push(N),F++}if(j0("filter:cli",{total:_,included:F,node_modules:B,ignored:j,wrongExt:D}),j0("filtered files",M.length),Z)e().info("[pickier:diagnostics] Filtering complete:"),e().info(`[pickier:diagnostics] Total files found: ${_}`),e().info(`[pickier:diagnostics] Files to lint: ${F}`),e().info(`[pickier:diagnostics] Excluded (node_modules): ${B}`),e().info(`[pickier:diagnostics] Excluded (ignored): ${j}`),e().info(`[pickier:diagnostics] Excluded (wrong extension): ${D}`);if(M.length>5000){if(e().warn(`[pickier:warn] After filtering, ${M.length} files will be linted. This may take a while and use significant memory.`),M.length>50000)return e().error(`[pickier:error] ${M.length} files to lint exceeds safe limit (50,000). This will likely cause out-of-memory errors.`),e().error("[pickier:error] Aborting to prevent crash. Please be more specific with your glob pattern."),e().error("[pickier:error] Example: Instead of '../stx', try '../stx/src' or '../stx/packages/core'"),1}let E=v0.CONCURRENCY;if(Z)e().info(`[pickier:diagnostics] Starting to process ${M.length} files with concurrency ${E}...`);let R=0,S=!!J._formatOnly,h=(await oY(M,E,async(N)=>{if(Z){if(R++,R===1||R%10===0||R===M.length)e().info(`[pickier:diagnostics] Processing file ${R}/${M.length}: ${p8(P0.cwd(),N)}`)}let v=hY(N,"utf8");if(S){let p=x8(v,X,N);if(p!==v)if(!J.dryRun)W9(N,p,"utf8");else return[{filePath:N,line:1,column:1,ruleId:"format",message:"File is not formatted",severity:"error",help:"Run pickier format with --write to apply formatting."}];return[]}let g=E1(v),u=/\.(?:ts|js|tsx|jsx|mts|mjs|cts|cjs)$/.test(N)?D1(v):new Set,d=R1(N,v,X,g,u);try{let p=await A9(N,v,X);for(let y of p){if(f0(y.ruleId,y.line,g))continue;if(u.has(y.line)&&u8(y.ruleId))continue;d.push({filePath:y.filePath,line:y.line,column:y.column,ruleId:y.ruleId,message:y.message,severity:y.severity,...y.help&&{help:y.help}})}}catch{}{let p=new Set;d=d.filter((y)=>{let b=`${y.line}:${y.column}:${y.ruleId}`;if(p.has(b))return!1;return p.add(b),!0})}if(J.fix){let p=/^\s*debugger\b/,y=v;if(X.rules.noDebugger==="error"||X.rules.noDebugger==="warn"){let s=y.split(/\r?\n/),r=[];for(let o of s){if(p.test(o))continue;r.push(o)}y=r.join(`
218
+ `)}y=cY(N,y,X);let a=N.split(".").pop()?.toLowerCase()??"";if(a!=="md"&&!(a==="sh"||a==="bash"||a==="zsh"||a==="ksh"||a==="dash")&&a!=="yaml"&&a!=="yml")y=o2(y,X);if(y!==v){let s=E1(y),r=D1(y);if(d=R1(N,y,X,s,r),!J.dryRun)W9(N,y,"utf8");if(J.dryRun&&(J.verbose!==void 0?J.verbose:X.verbose))e().debug(Z0.gray(`dry-run: would apply fixes in ${p8(P0.cwd(),N)}`))}}return j0("scan done",p8(P0.cwd(),N),d.length),d})).flat();if(Z)e().info(`[pickier:diagnostics] Processing complete! Found ${h.length} issues total`);let P=h.filter((N)=>N.severity==="error").length,C=h.filter((N)=>N.severity==="warning").length;if(j0("issues:summary",{errors:P,warnings:C}),Z)e().info(`[pickier:diagnostics] Errors: ${P}, Warnings: ${C}`);let I=J.reporter||X.lint.reporter,L=J.verbose!==void 0?J.verbose:X.verbose;if(I==="json")console.log(JSON.stringify({errors:P,warnings:C,issues:h},null,2));else if(I==="compact")for(let N of h)console.log(`${p8(P0.cwd(),N.filePath)}:${N.line}:${N.column} ${N.severity} ${N.ruleId} ${N.message}`);else if(h.length>0)console.log(L?vY(h):yY(h));if(h.length>0&&I!=="json"){let N=P+C,v=N===1?"problem":"problems",g=P===1?"error":"errors",x=C===1?"warning":"warnings",u=m8(X),d=0,p=0;for(let y of h){let b=y.ruleId;if(u.fixableRuleIds.has(b)||u.fixableBareRuleNames.has(b)){if(y.severity==="error")d++;else if(y.severity==="warning")p++}}if(console.log(),console.log(Z0.red(`\u2716 ${N} ${v} (${P} ${g}, ${C} ${x})`)),d>0||p>0){let y=d===1?"error":"errors",b=p===1?"warning":"warnings";console.log(Z0.gray(` ${d} ${y} and ${p} ${b} potentially fixable with the \`--fix\` option.`))}}if(L&&I!=="json")console.log(Z0.gray(`Scanned ${M.length} files, found ${P} errors and ${C} warnings.`));let T=J.maxWarnings??X.lint.maxWarnings,k=v0.FAIL_ON_WARNINGS;if(P>0)return j0("runLint:end",1),1;if(k&&C>0)return j0("runLint:end",1),1;if(T>=0&&C>T)return j0("runLint:end",1),1;return j0("runLint:end",0),0}catch(X){return e().error("[pickier:error] runLint failed:",X?.message||X),j0("runLint:exception",X),1}}
219
+ export{vj as a,dj as b,oj as c,A9 as d,R1 as e,cj as f,rj as g};