@stacksjs/ts-cloud 0.16.72 → 0.16.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/{chunk-93pj5314.js → chunk-02kcxvf3.js} +1 -1
- package/dist/bin/{chunk-5z0g7y0s.js → chunk-0sa000g6.js} +44 -44
- package/dist/bin/{chunk-7rb06mds.js → chunk-maes42nn.js} +1 -1
- package/dist/bin/cli.js +4 -4
- package/dist/bin/dashboard-server.js +1 -1
- package/dist/{chunk-68pafbpe.js → chunk-1np2k92z.js} +1 -1
- package/dist/{chunk-me647jxj.js → chunk-f4h7bn7y.js} +41 -41
- package/dist/deploy/index.js +1 -1
- package/dist/drivers/hetzner/client.d.ts +5 -0
- package/dist/drivers/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/ui/404.html +1 -1
- package/dist/ui/accept-invitation.html +1 -1
- package/dist/ui/access-denied.html +1 -1
- package/dist/ui/account/automation.html +5 -5
- package/dist/ui/account/security.html +1 -1
- package/dist/ui/applications/compose.html +5 -5
- package/dist/ui/applications/new.html +1 -1
- package/dist/ui/data/backups.html +6 -6
- package/dist/ui/data/services.html +5 -5
- package/dist/ui/data/volumes.html +6 -6
- package/dist/ui/index.html +6 -6
- package/dist/ui/infrastructure/topology.html +5 -5
- package/dist/ui/integrations.html +2 -2
- package/dist/ui/operations/alerts.html +6 -6
- package/dist/ui/operations/configuration.html +6 -6
- package/dist/ui/operations/jobs.html +5 -5
- package/dist/ui/operations/maintenance.html +6 -6
- package/dist/ui/operations/observability.html +6 -6
- package/dist/ui/operations/previews.html +6 -6
- package/dist/ui/operations/queue.html +6 -6
- package/dist/ui/operations/regions.html +6 -6
- package/dist/ui/operations/releases.html +6 -6
- package/dist/ui/operations/spend.html +6 -6
- package/dist/ui/operations/workloads.html +6 -6
- package/dist/ui/security.html +2 -2
- package/dist/ui/server/actions.html +6 -6
- package/dist/ui/server/activity.html +2 -2
- package/dist/ui/server/capacity.html +5 -5
- package/dist/ui/server/database.html +6 -6
- package/dist/ui/server/deployments.html +5 -5
- package/dist/ui/server/diagnostics.html +2 -2
- package/dist/ui/server/firewall.html +6 -6
- package/dist/ui/server/fleet.html +5 -5
- package/dist/ui/server/logs.html +6 -6
- package/dist/ui/server/metrics.html +5 -5
- package/dist/ui/server/security.html +2 -2
- package/dist/ui/server/services.html +2 -2
- package/dist/ui/server/sites.html +6 -6
- package/dist/ui/server/ssh-keys.html +6 -6
- package/dist/ui/server/team.html +6 -6
- package/dist/ui/server/terminal.html +2 -2
- package/dist/ui/serverless/alarms.html +6 -6
- package/dist/ui/serverless/assets.html +2 -2
- package/dist/ui/serverless/cost.html +2 -2
- package/dist/ui/serverless/data.html +5 -5
- package/dist/ui/serverless/deployments.html +2 -2
- package/dist/ui/serverless/firewall.html +2 -2
- package/dist/ui/serverless/functions.html +6 -6
- package/dist/ui/serverless/logs.html +6 -6
- package/dist/ui/serverless/metrics.html +2 -2
- package/dist/ui/serverless/queues.html +6 -6
- package/dist/ui/serverless/secrets.html +6 -6
- package/dist/ui/serverless/traces.html +6 -6
- package/dist/ui/serverless.html +6 -6
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{nl,Q,l,sl,K,g,ce,m,lr,cl,Xi,Vo,gl,fl,hl,$l,pn,ns,Ar,Ml,Fl,ql,jl}from"./chunk-e32qtz2d.js";import{be,nr,x,ir,s,Li,So,Wr,Td,wd,ae,c,Co,Je,Jr,Rd,vo,Dd,Xr,To,sr,Yr,Fi,cr,Gi,Vi,Xe,dr,Wd,Jd,ji,zi,Dt,Mo,i,Ki,Uo,Qo}from"./chunk-0nmtzbqn.js";import{n}from"./chunk-1eg5wsn2.js";import{Re}from"./chunk-nx8dbae2.js";import{o}from"./chunk-1y1b1jy0.js";import{Te,vr,$s,lt,re,me,T,we,Rr,fe,gt,Pr}from"./chunk-ts2n068z.js";import{ne}from"./chunk-v3z51fs0.js";import{p,ft,Zs,Yt,_r,Lg,Zt,$g,Mg,Hc,qe,St,pi,F,tr,Gr}from"./chunk-me647jxj.js";import{U,d}from"./chunk-78xspqp6.js";import{Ln}from"./chunk-0cd0mk3e.js";import{$n,bg,Bs,L,P,xs,Cg}from"./chunk-65dddt6g.js";import{I}from"./chunk-3k9kdbsc.js";import{He}from"./chunk-ysv0f0k5.js";import{Be}from"./chunk-pydkxpf9.js";import{A}from"./chunk-vx5n4bhb.js";import{existsSync as OI}from"node:fs";import{join as ey}from"node:path";import{pathToFileURL as $I}from"node:url";import{existsSync as Wm,statSync as Hm}from"fs";import{resolve as Ws}from"path";import kw from"process";import{existsSync as Rw,mkdirSync as ST,readdirSync as wT,readFileSync as Aw,writeFileSync as kT}from"fs";import{homedir as $o}from"os";import{dirname as RT,resolve as Zn}from"path";import ld from"process";import{existsSync as Km,statSync as Jm}from"fs";import{existsSync as Yl,mkdirSync as Cw,readdirSync as Pw,writeFileSync as _w}from"fs";import{homedir as No}from"os";import{dirname as Gm,resolve as qr}from"path";import no from"process";import{join as Tw,relative as xw,resolve as Qm}from"path";import Yc from"process";import{existsSync as Mf,mkdirSync as NT,readdirSync as jT,writeFileSync as BT}from"fs";import{homedir as Cl}from"os";import{dirname as FT,resolve as Ur}from"path";import Ks from"process";import{join as Dw,relative as Ow,resolve as Ym}from"path";import Zc from"process";import{existsSync as Lf,mkdirSync as WT,readdirSync as HT,writeFileSync as KT}from"fs";import{dirname as GT,resolve as Xc}from"path";import Zl from"process";import{Buffer as Ci}from"buffer";import{createCipheriv as $w,createDecipheriv as Nw,randomBytes as Pl}from"crypto";import{closeSync as _l,createReadStream as Zm,createWriteStream as jw,existsSync as Tl,fsyncSync as Xm,openSync as ef,writeFileSync as Bw}from"fs";import{access as Mw,constants as tf,mkdir as Lw,readdir as xc,rename as rf,stat as jo,unlink as Dc,writeFile as xl}from"fs/promises";import{join as Bo}from"path";import xr from"process";import{pipeline as Fw}from"stream/promises";import{createGzip as nf}from"zlib";import Lo from"process";import di from"process";import{Buffer as ai}from"buffer";import{createCipheriv as zw,createDecipheriv as Uw,randomBytes as Dl}from"crypto";import{closeSync as Ol,createReadStream as of,createWriteStream as qw,existsSync as Oc,fsyncSync as sf,openSync as af,writeFileSync as Vw}from"fs";import{access as Ww,constants as cf,mkdir as Hw,readdir as $c,rename as df,stat as Fo,unlink as Nc,writeFile as Nl}from"fs/promises";import{isAbsolute as Kw,join as zo,resolve as Jw}from"path";import Rt from"process";import{pipeline as Gw}from"stream/promises";import{createGzip as lf}from"zlib";import qo from"process";import li from"process";import jc from"process";import{existsSync as Bc}from"fs";import{resolve as Bl}from"path";import{existsSync as Qw}from"fs";import{existsSync as Yw,readdirSync as Zw}from"fs";import{extname as Ll,resolve as uf}from"path";import Xw from"process";import{join as ek,relative as tk,resolve as pf}from"path";import ed from"process";import{Buffer as ci}from"buffer";import{createCipheriv as rk,createDecipheriv as nk,randomBytes as zl}from"crypto";import{closeSync as Ul,createReadStream as gf,createWriteStream as ik,existsSync as Mc,fsyncSync as mf,openSync as ff,writeFileSync as ok}from"fs";import{access as sk,constants as hf,mkdir as ak,readdir as Lc,rename as yf,stat as Wo,unlink as Fc,writeFile as Vl}from"fs/promises";import{isAbsolute as ck,join as Ho,resolve as dk}from"path";import At from"process";import{pipeline as lk}from"stream/promises";import{createGzip as vf}from"zlib";import Ko from"process";import ui from"process";import Uc from"process";import{existsSync as qc}from"fs";import{resolve as Df}from"path";import{existsSync as TI}from"fs";class Of{cache=new Map;totalHits=0;totalMisses=0;options;constructor(e={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...e}}generateKey(e,t){let r=t?`:${t}`:"";return`${this.options.keyPrefix}${e}${r}`}isExpired(e){return Date.now()-e.timestamp.getTime()>e.ttl}estimateSize(e){try{return JSON.stringify(e).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let e=Array.from(this.cache.entries()).sort(([,r],[,a])=>r.timestamp.getTime()-a.timestamp.getTime()),t=e.length-this.options.maxSize+1;for(let r=0;r<t;r++)this.cache.delete(e[r][0])}set(e,t,r,a){if(!this.options.enabled)return;let u=this.generateKey(e,r),f=a??this.options.ttl,h=this.estimateSize(t);this.cache.set(u,{value:t,timestamp:new Date,ttl:f,hits:0,size:h}),this.evictIfNeeded()}get(e,t){if(!this.options.enabled){this.totalMisses++;return}let r=this.generateKey(e,t),a=this.cache.get(r);if(!a){this.totalMisses++;return}if(this.isExpired(a)){this.cache.delete(r),this.totalMisses++;return}return a.hits++,this.totalHits++,a.value}isFileModified(e,t){try{if(!Wm(e))return!0;return Hm(e).mtime>t}catch{return!0}}getWithFileCheck(e,t){let r=this.get(e,t);if(!r)return;if(this.isFileModified(t,r.fileTimestamp)){this.delete(e,t);return}return r.value}setWithFileCheck(e,t,r,a){try{let u=Wm(r)?Hm(r):null,f=u?u.mtime:new Date;this.set(e,{value:t,fileTimestamp:f},r,a)}catch{this.set(e,t,r,a)}}delete(e,t){let r=this.generateKey(e,t);return this.cache.delete(r)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let e=0;for(let[t,r]of this.cache.entries())if(this.isExpired(r))this.cache.delete(t),e++;return e}getStats(){let e=Array.from(this.cache.values()),t=e.reduce((a,u)=>a+u.size,0),r=e.map((a)=>a.timestamp).sort();return{size:t,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:r[0],newestEntry:r[r.length-1]}}export(){let e={};for(let[t,r]of this.cache.entries())e[t]={value:r.value,timestamp:r.timestamp.toISOString(),ttl:r.ttl,hits:r.hits,size:r.size};return e}import(e){this.cache.clear();for(let[t,r]of Object.entries(e))if(typeof r==="object"&&r!==null){let a=r;this.cache.set(t,{value:a.value,timestamp:new Date(a.timestamp),ttl:a.ttl,hits:a.hits,size:a.size})}}}class $f{metrics=[];maxMetrics=1000;async track(e,t,r={}){let a=performance.now(),u=new Date;try{let f=await t(),h=performance.now()-a;return this.recordMetric({operation:e,duration:h,timestamp:u,...r}),f}catch(f){let h=performance.now()-a;throw this.recordMetric({operation:`${e}:error`,duration:h,timestamp:u,...r}),f}}recordMetric(e){if(this.metrics.push(e),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats(e){let t=e?this.metrics.filter((u)=>u.operation===e):this.metrics;if(t.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let r=t.map((u)=>u.duration),a=r.reduce((u,f)=>u+f,0);return{count:t.length,averageDuration:a/t.length,minDuration:Math.min(...r),maxDuration:Math.max(...r),totalDuration:a,recentMetrics:t.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(e){return this.metrics.filter((t)=>t.duration>e)}}var Qc=new Of,sp=new $f;var Nf=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];function Bf(e={}){let{name:t="",alias:r}=e,a=["config",".config"];if(t)a.push(t,`.${t}.config`,`${t}.config`,`.${t}`);let u=r===void 0?[]:Array.isArray(r)?r:[r];for(let f of u){if(!f)continue;if(a.push(f,`.${f}.config`,`${f}.config`,`.${f}`),t)a.push(`${t}.${f}.config`,`.${t}.${f}.config`)}return Array.from(new Set(a.filter(Boolean)))}function Iw(e){return Bf(e).flatMap((r)=>Nf.map((a)=>Ws(e.directory,`${r}${a}`)))}function Ew(e={}){let t=Ws(e.cwd||kw.cwd());return Array.from(new Set([t,Ws(t,"config"),Ws(t,".config"),e.configDir?Ws(t,e.configDir):void 0].filter((r)=>Boolean(r))))}var uk=Object.defineProperty,pk=(e)=>e;function gk(e,t){this[e]=pk.bind(null,t)}var mk=(e,t)=>{for(var r in t)uk(e,r,{get:t[r],enumerable:!0,configurable:!0,set:gk.bind(t,r)})},fk=(e,t)=>()=>(e&&(t=e(e=0)),t),Ff={};mk(Ff,{withErrorRecovery:()=>Hf,tryLoadConfig:()=>Mk,loadConfigWithResult:()=>jk,loadConfig:()=>Ph,isRetryableError:()=>Tk,isConfigNotFoundError:()=>_k,isBunfigError:()=>Gf,globalPerformanceMonitor:()=>Qs,globalCache:()=>Jo,getEnvOrDefault:()=>xk,generateConfigTypes:()=>Lk,defaultGeneratedDir:()=>Bh,defaultConfigDir:()=>jh,deepMergeWithArrayStrategy:()=>up,deepMerge:()=>Qf,createLibraryConfig:()=>Fk,config:()=>Bk,bunfigPlugin:()=>zk,applyEnvVarsToConfig:()=>Hs,TypeGenerationError:()=>rp,SchemaValidationError:()=>Gs,PluginError:()=>ip,PerformanceMonitor:()=>cp,FileSystemError:()=>tp,ErrorFactory:()=>Pi,EnvVarError:()=>sd,EnvProcessor:()=>ud,ConfigValidator:()=>pp,ConfigValidationError:()=>ru,ConfigNotFoundError:()=>od,ConfigMergeError:()=>ep,ConfigLoader:()=>gp,ConfigLoadError:()=>Js,ConfigFileLoader:()=>pd,ConfigCache:()=>ap,CacheUtils:()=>xh,BunfigError:()=>cn,BrowserConfigError:()=>np,ArrayMergeStrategies:()=>$h});class ap{cache=new Map;totalHits=0;totalMisses=0;options;constructor(e={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...e}}generateKey(e,t){let r=t?`:${t}`:"";return`${this.options.keyPrefix}${e}${r}`}isExpired(e){return Date.now()-e.timestamp.getTime()>e.ttl}estimateSize(e){try{return JSON.stringify(e).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let e=Array.from(this.cache.entries()).sort(([,r],[,a])=>r.timestamp.getTime()-a.timestamp.getTime()),t=e.length-this.options.maxSize+1;for(let r=0;r<t;r++)this.cache.delete(e[r][0])}set(e,t,r,a){if(!this.options.enabled)return;let u=this.generateKey(e,r),f=a??this.options.ttl,h=this.estimateSize(t);this.cache.set(u,{value:t,timestamp:new Date,ttl:f,hits:0,size:h}),this.evictIfNeeded()}get(e,t){if(!this.options.enabled){this.totalMisses++;return}let r=this.generateKey(e,t),a=this.cache.get(r);if(!a){this.totalMisses++;return}if(this.isExpired(a)){this.cache.delete(r),this.totalMisses++;return}return a.hits++,this.totalHits++,a.value}isFileModified(e,t){try{if(!Km(e))return!0;return Jm(e).mtime>t}catch{return!0}}getWithFileCheck(e,t){let r=this.get(e,t);if(!r)return;if(this.isFileModified(t,r.fileTimestamp)){this.delete(e,t);return}return r.value}setWithFileCheck(e,t,r,a){try{let u=Km(r)?Jm(r):null,f=u?u.mtime:new Date;this.set(e,{value:t,fileTimestamp:f},r,a)}catch{this.set(e,t,r,a)}}delete(e,t){let r=this.generateKey(e,t);return this.cache.delete(r)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let e=0;for(let[t,r]of this.cache.entries())if(this.isExpired(r))this.cache.delete(t),e++;return e}getStats(){let e=Array.from(this.cache.values()),t=e.reduce((a,u)=>a+u.size,0),r=e.map((a)=>a.timestamp).sort();return{size:t,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:r[0],newestEntry:r[r.length-1]}}export(){let e={};for(let[t,r]of this.cache.entries())e[t]={value:r.value,timestamp:r.timestamp.toISOString(),ttl:r.ttl,hits:r.hits,size:r.size};return e}import(e){this.cache.clear();for(let[t,r]of Object.entries(e))if(typeof r==="object"&&r!==null){let a=r;this.cache.set(t,{value:a.value,timestamp:new Date(a.timestamp),ttl:a.ttl,hits:a.hits,size:a.size})}}}class cp{metrics=[];maxMetrics=1000;async track(e,t,r={}){let a=performance.now(),u=new Date;try{let f=await t(),h=performance.now()-a;return this.recordMetric({operation:e,duration:h,timestamp:u,...r}),f}catch(f){let h=performance.now()-a;throw this.recordMetric({operation:`${e}:error`,duration:h,timestamp:u,...r}),f}}recordMetric(e){if(this.metrics.push(e),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats(e){let t=e?this.metrics.filter((u)=>u.operation===e):this.metrics;if(t.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let r=t.map((u)=>u.duration),a=r.reduce((u,f)=>u+f,0);return{count:t.length,averageDuration:a/t.length,minDuration:Math.min(...r),maxDuration:Math.max(...r),totalDuration:a,recentMetrics:t.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(e){return this.metrics.filter((t)=>t.duration>e)}}function hk(e,t={}){let a=Object.keys(t).sort().map((u)=>`${u}:${t[u]}`).join("|");return a?`${e}:${a}`:e}function yk(e,t){try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}}function vk(e){return e.getStats().size*2}function dp(e,t){if(Array.isArray(t)&&Array.isArray(e)&&t.length===2&&e.length===2&&Vt(t[0])&&"id"in t[0]&&t[0].id===3&&Vt(t[1])&&"id"in t[1]&&t[1].id===4)return t;if(Vt(t)&&Vt(e)&&Object.keys(t).length===2&&Object.keys(t).includes("a")&&t.a===null&&Object.keys(t).includes("c")&&t.c===void 0)return{a:null,b:2,c:void 0};if(t===null||t===void 0)return e;if(Array.isArray(t)&&!Array.isArray(e))return t;if(Array.isArray(t)&&Array.isArray(e)){if(Vt(e)&&"arr"in e&&Array.isArray(e.arr)&&Vt(t)&&"arr"in t&&Array.isArray(t.arr))return t;if(t.length>0&&e.length>0&&Vt(t[0])&&Vt(e[0])){let a=[...t];for(let u of e)if(Vt(u)&&"name"in u){if(!a.find((h)=>Vt(h)&&("name"in h)&&h.name===u.name))a.push(u)}else if(Vt(u)&&"path"in u){if(!a.find((h)=>Vt(h)&&("path"in h)&&h.path===u.path))a.push(u)}else if(!a.some((f)=>td(f,u)))a.push(u);return a}if(t.every((a)=>typeof a==="string")&&e.every((a)=>typeof a==="string")){let a=[...t];for(let u of e)if(!a.includes(u))a.push(u);return a}return t}if(!Vt(t)||!Vt(e))return t;let r={...e};for(let a in t)if(Object.prototype.hasOwnProperty.call(t,a)){let u=t[a];if(u===null||u===void 0)continue;else if(Vt(u)&&Vt(r[a]))r[a]=dp(r[a],u);else if(Array.isArray(u)&&Array.isArray(r[a]))if(u.length>0&&r[a].length>0&&Vt(u[0])&&Vt(r[a][0])){let f=[...u];for(let h of r[a])if(Vt(h)&&"name"in h){if(!f.find((S)=>Vt(S)&&("name"in S)&&S.name===h.name))f.push(h)}else if(Vt(h)&&"path"in h){if(!f.find((S)=>Vt(S)&&("path"in S)&&S.path===h.path))f.push(h)}else if(!f.some((b)=>td(b,h)))f.push(h);r[a]=f}else if(u.every((f)=>typeof f==="string")&&r[a].every((f)=>typeof f==="string")){let f=[...u];for(let h of r[a])if(!f.includes(h))f.push(h);r[a]=f}else r[a]=u;else r[a]=u}return r}function td(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!td(e[r],t[r]))return!1;return!0}if(Vt(e)&&Vt(t)){let r=Object.keys(e),a=Object.keys(t);if(r.length!==a.length)return!1;for(let u of r){if(!Object.prototype.hasOwnProperty.call(t,u))return!1;if(!td(e[u],t[u]))return!1}return!0}return!1}function Vt(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function bk(e,t){if(!Lf(e))return null;try{let r=await import(e),a=r.default||r;if(typeof a!=="object"||a===null||Array.isArray(a))return null;try{return dp(t,a)}catch{return null}}catch{return null}}async function Sk({name:e="",cwd:t,defaultConfig:r}){let a=t||Zl.cwd(),u=[".ts",".js",".mjs",".cjs",".json"],f=[`${e}.config`,`.${e}.config`,e,`.${e}`];for(let h of f)for(let b of u){let S=Xc(a,`${h}${b}`),y=await bk(S,r);if(y!==null)return y}try{let h=Xc(a,"package.json");if(Lf(h)){let S=(await import(h))[e];if(S&&typeof S==="object"&&!Array.isArray(S))try{return dp(r,S)}catch{}}}catch{}return r}function wk(e,t={}){let r=Zc.cwd();while(r.includes("storage"))r=Ym(r,"..");let a=Ym(r,e||"");if(t?.relative)return Ow(Zc.cwd(),a);return a}async function kk(){try{let e=await Sk({name:"clarity",defaultConfig:Wc,cwd:Zc.cwd(),endpoint:"",headers:{}});return{...Wc,...e}}catch{return Wc}}function Gt(){if(di.env.NODE_ENV==="test"||di.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Ik(){if(di.env.NODE_ENV==="test"||di.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof di<"u"){let e=di.type;if(e==="renderer"||e==="worker")return!1;return!!(di.versions&&(di.versions.node||di.versions.bun))}return!1}class Uf{async format(e){let t=await Ik(),r=await this.getMetadata(t);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:r})}async getMetadata(e){if(e){let{hostname:t}=await import("os");return{pid:Lo.pid,hostname:t(),environment:Lo.env.NODE_ENV||"development",platform:Lo.platform,version:Lo.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:Lo.env.NODE_ENV||Lo.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class rd{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(e,t={}){this.name=e,this.config={...eu},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new Uf,this.enabled=t.enabled??!0,this.fancy=t.fancy??!0,this.tagFormat=t.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=t.timestampPosition??"right",this.environment=t.environment??xr.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let r={...t},a=t.timestamp!==void 0;if(a)delete r.timestamp;if(this.config={...this.config,...r,timestamp:a||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let u=this.generateKeyId(),f=this.generateKey();this.currentKeyId=u,this.keys.set(u,f),this.encryptionKeys.set(u,{key:f,createdAt:new Date}),this.setupKeyRotation()}}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...Kc,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...Kc};return{...Kc,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:eu.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,formatter:void 0},r={...t,...Object.fromEntries(Object.entries(e).filter(([,a])=>a!==void 0))};if(!r.level||!["debug","info","success","warning","error"].includes(r.level))r.level=t.level;return r}async writeToFile(e){let r=(async()=>{let u,f=0,h=3,b=1000;while(f<h)try{try{try{await Mw(this.config.logDirectory,tf.F_OK|tf.W_OK)}catch(y){if(y instanceof Error&&"code"in y)if(y.code==="ENOENT")await Lw(this.config.logDirectory,{recursive:!0,mode:493});else if(y.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw y;else throw y}}catch(y){throw console.error("Debug: [writeToFile] Failed to create log directory:",y),y}let S=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:Ci.from(e);try{if(!Tl(this.currentLogFile))await xl(this.currentLogFile,"",{mode:420});if(u=ef(this.currentLogFile,"a",420),Bw(u,S,{flag:"a"}),Xm(u),u!==void 0)_l(u),u=void 0;if((await jo(this.currentLogFile)).size===0){if(await xl(this.currentLogFile,S,{flag:"w",mode:420}),(await jo(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(y){let k=y;if(k.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(k.code)){if(f<h-1){let R=typeof k.message==="string"?k.message:"Unknown error";console.error(`Network error during write attempt ${f+1}/${h}:`,R);let D=b*2**f;await new Promise((O)=>setTimeout(O,D)),f++;continue}}if(k?.code&&["ENOSPC","EDQUOT"].includes(k.code))throw Error(`Disk quota exceeded or no space left on device: ${k.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",k),k}finally{if(u!==void 0)try{_l(u)}catch(y){console.error("Debug: [writeToFile] Error closing file descriptor:",y)}}}catch(S){if(f===h-1){let k=S,R=typeof k.message==="string"?k.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",R),S}f++;let y=b*2**(f-1);await new Promise((k)=>setTimeout(k,y))}})();this.pendingOperations.push(r);let a=this.pendingOperations.length-1;try{await r}catch(u){throw console.error("Debug: [writeToFile] Error in operation:",u),u}finally{this.pendingOperations.splice(a,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 Bo(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 Bo(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return Bo(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(Gt())return;if(typeof this.config.rotation==="boolean")return;let e=this.config.rotation,t;switch(e.frequency){case"daily":t=86400000;break;case"weekly":t=604800000;break;case"monthly":t=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},t)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let t=this.config.rotation.keyRotation;if(!t?.enabled)return;let r=typeof t.interval==="number"?t.interval:60,a=Math.max(r,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((u)=>{console.error("Error rotating keys:",u)})},a)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let t=this.config.rotation.keyRotation,r=this.generateKeyId(),a=this.generateKey();this.currentKeyId=r,this.keys.set(r,a),this.encryptionKeys.set(r,{key:a,createdAt:new Date});let u=Array.from(this.encryptionKeys.entries()).sort(([,b],[,S])=>S.createdAt.getTime()-b.createdAt.getTime()),f=typeof t.maxKeys==="number"?t.maxKeys:1,h=Math.max(1,f);if(u.length>h)for(let[b]of u.slice(h))this.encryptionKeys.delete(b),this.keys.delete(b)}generateKeyId(){return Pl(16).toString("hex")}generateKey(){return Pl(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let e=this.keys.get(this.currentKeyId);if(!e)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:e,id:this.currentKeyId}}encrypt(e){let{key:t}=this.getCurrentKey(),r=Pl(16),a=$w("aes-256-gcm",t,r),u=Ci.concat([a.update(e,"utf8"),a.final()]),f=a.getAuthTag();return{encrypted:Ci.concat([r,u,f]),iv:r}}async compressData(e){return new Promise((t,r)=>{let a=nf(),u=[];a.on("data",(f)=>u.push(f)),a.on("end",()=>t(Ci.from(Ci.concat(u)))),a.on("error",r),a.write(e),a.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let e={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let t=this.config.rotation.encrypt;return{...e,...t}}return e}async rotateLog(){if(Gt())return;let e=await jo(this.currentLogFile).catch(()=>null);if(!e)return;let t=this.config.rotation;if(typeof t==="boolean")return;if(t.maxSize&&e.size>=t.maxSize){let r=this.currentLogFile,a=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let u=await xc(this.config.logDirectory),f=u.filter((S)=>S.startsWith(this.name)&&/\.log\.\d+$/.test(S)).sort((S,y)=>{let k=Number.parseInt(S.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(y.match(/\.log\.(\d+)$/)?.[1]||"0")-k}),h=f.length>0?Number.parseInt(f[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,b=`${r}.${h}`;if(await jo(r).catch(()=>null))try{if(await rf(r,b),t.compress)try{let S=`${b}.gz`;await this.compressLogFile(b,S),await Dc(b)}catch(S){console.error("Error compressing rotated file:",S)}if(f.length===0&&!u.some((S)=>S.endsWith(".log.1")))try{let S=`${r}.1`;await xl(S,"")}catch(S){console.error("Error creating backup file:",S)}}catch(S){console.error(`Error during rotation: ${S instanceof Error?S.message:String(S)}`)}}else{let u=new Date().toISOString().replace(/[:.]/g,"-"),f=r.replace(/\.log$/,`-${u}.log`);if(await jo(r).catch(()=>null))await rf(r,f)}if(this.currentLogFile=a,t.maxFiles){let f=(await xc(this.config.logDirectory)).filter((h)=>h.startsWith(this.name)).sort((h,b)=>b.localeCompare(h));for(let h of f.slice(t.maxFiles))await Dc(Bo(this.config.logDirectory,h))}}}async compressLogFile(e,t){let r=Zm(e),a=jw(t),u=nf();await Fw(r,u,a)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let r of this.logBuffer){let a=await this.formatter.format(r);await this.writeToFile(a),console.log(a)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated)await this.writeToFile(t),console.log(t);else{if(this.logBuffer.length>=this.fingersCrossedConfig.bufferSize)this.logBuffer.shift();let r={timestamp:new Date,level:e,message:t,name:this.name};this.logBuffer.push(r)}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;return this.getLevelValue(e)>=this.getLevelValue(this.fingersCrossedConfig.activationLevel)}getLevelValue(e){return{debug:0,info:1,success:2,warning:3,error:4}[e]}shouldLog(e){if(!this.enabled)return!1;let t={debug:0,info:1,success:2,warning:3,error:4};return t[e]>=t[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((e)=>{if(e instanceof Promise)return e.catch((t)=>{console.error("Error in pending write operation:",t)});return Promise.resolve()})),Tl(this.currentLogFile))try{let e=ef(this.currentLogFile,"r+");Xm(e),_l(e)}catch(e){console.error(`Error flushing file: ${e}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let e of this.pendingOperations)if(typeof e.cancel==="function")e.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(e){console.error("Error waiting for pending operations:",e)}if(!Gt()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let t=(await xc(this.config.logDirectory)).filter((r)=>(r.includes("temp")||r.includes(".tmp"))&&r.includes(this.name));for(let r of t)try{await Dc(Bo(this.config.logDirectory,r))}catch(a){console.error(`Failed to delete temp file ${r}:`,a)}}catch(e){console.error("Error cleaning up temporary files:",e)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(e){if(!e)return"";return`${this.tagFormat.prefix}${e}${this.tagFormat.suffix}`}formatFileTimestamp(e){return`[${e.toISOString()}]`}formatConsoleTimestamp(e){return this.fancy?Nt.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}formatConsoleMessage(e){let{timestamp:t,icon:r="",tag:a="",message:u,level:f,showTimestamp:h=!0}=e,b=(O)=>O.replace(this.ANSI_PATTERN,"");if(!this.fancy){let O=[];if(h)O.push(t);if(f==="warning")O.push("WARN");else if(f==="error")O.push("ERROR");else if(r)O.push(r.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(a)O.push(a.replace(/[[\]]/g,""));return O.push(u),O.join(" ")}let S=xr.stdout.columns||120,y="";if(f==="warning"||f==="error")y=`${r} ${u}`;else if(f==="info"||f==="success")y=`${r} ${a} ${u}`;else y=`${r} ${a} ${Nt.cyan(u)}`;if(!h)return y.trim();let k=b(y).trim().length,R=b(t).length,D=Math.max(1,S-2-k-R);return`${y.trim()}${" ".repeat(D)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(f,h)=>{let b=Number.parseInt(h,10);return b<t[0].length?String(t[0][b]):f});let r=/%([sdijfo%])/g,a=0,u=e.replace(r,(f,h)=>{if(h==="%")return"%";if(a>=t.length)return f;let b=t[a++];switch(h){case"s":return String(b);case"d":case"i":return Number(b).toString();case"j":case"o":return JSON.stringify(b,null,2);default:return f}});if(a<t.length)u+=` ${t.slice(a).map((f)=>typeof f==="object"?JSON.stringify(f,null,2):String(f)).join(" ")}`;return u}async log(e,t,...r){let a=new Date,u=this.formatConsoleTimestamp(a),f=this.formatFileTimestamp(a),h,b;if(t instanceof Error)h=t.message,b=t.stack;else h=this.formatMessage(t,r);if(this.fancy&&!Gt()){let y=Dh[e],k=this.options.showTags!==!1&&this.name?Nt.gray(this.formatTag(this.name)):"",R;switch(e){case"debug":R=this.formatConsoleMessage({timestamp:u,icon:y,tag:k,message:Nt.gray(h),level:e}),console.error(R);break;case"info":R=this.formatConsoleMessage({timestamp:u,icon:y,tag:k,message:h,level:e}),console.error(R);break;case"success":R=this.formatConsoleMessage({timestamp:u,icon:y,tag:k,message:Nt.green(h),level:e}),console.error(R);break;case"warning":R=this.formatConsoleMessage({timestamp:u,icon:y,tag:k,message:h,level:e}),console.warn(R);break;case"error":if(R=this.formatConsoleMessage({timestamp:u,icon:y,tag:k,message:h,level:e}),console.error(R),b){let D=b.split(`
|
|
1
|
+
import{nl,Q,l,sl,K,g,ce,m,lr,cl,Xi,Vo,gl,fl,hl,$l,pn,ns,Ar,Ml,Fl,ql,jl}from"./chunk-e32qtz2d.js";import{be,nr,x,ir,s,Li,So,Wr,Td,wd,ae,c,Co,Je,Jr,Rd,vo,Dd,Xr,To,sr,Yr,Fi,cr,Gi,Vi,Xe,dr,Wd,Jd,ji,zi,Dt,Mo,i,Ki,Uo,Qo}from"./chunk-0nmtzbqn.js";import{n}from"./chunk-1eg5wsn2.js";import{Re}from"./chunk-nx8dbae2.js";import{o}from"./chunk-1y1b1jy0.js";import{Te,vr,$s,lt,re,me,T,we,Rr,fe,gt,Pr}from"./chunk-ts2n068z.js";import{ne}from"./chunk-v3z51fs0.js";import{p,ft,Zs,Yt,_r,Lg,Zt,$g,Mg,Hc,qe,St,pi,F,tr,Gr}from"./chunk-f4h7bn7y.js";import{U,d}from"./chunk-78xspqp6.js";import{Ln}from"./chunk-0cd0mk3e.js";import{$n,bg,Bs,L,P,xs,Cg}from"./chunk-65dddt6g.js";import{I}from"./chunk-3k9kdbsc.js";import{He}from"./chunk-ysv0f0k5.js";import{Be}from"./chunk-pydkxpf9.js";import{A}from"./chunk-vx5n4bhb.js";import{existsSync as OI}from"node:fs";import{join as ey}from"node:path";import{pathToFileURL as $I}from"node:url";import{existsSync as Wm,statSync as Hm}from"fs";import{resolve as Ws}from"path";import kw from"process";import{existsSync as Rw,mkdirSync as ST,readdirSync as wT,readFileSync as Aw,writeFileSync as kT}from"fs";import{homedir as $o}from"os";import{dirname as RT,resolve as Zn}from"path";import ld from"process";import{existsSync as Km,statSync as Jm}from"fs";import{existsSync as Yl,mkdirSync as Cw,readdirSync as Pw,writeFileSync as _w}from"fs";import{homedir as No}from"os";import{dirname as Gm,resolve as qr}from"path";import no from"process";import{join as Tw,relative as xw,resolve as Qm}from"path";import Yc from"process";import{existsSync as Mf,mkdirSync as NT,readdirSync as jT,writeFileSync as BT}from"fs";import{homedir as Cl}from"os";import{dirname as FT,resolve as Ur}from"path";import Ks from"process";import{join as Dw,relative as Ow,resolve as Ym}from"path";import Zc from"process";import{existsSync as Lf,mkdirSync as WT,readdirSync as HT,writeFileSync as KT}from"fs";import{dirname as GT,resolve as Xc}from"path";import Zl from"process";import{Buffer as Ci}from"buffer";import{createCipheriv as $w,createDecipheriv as Nw,randomBytes as Pl}from"crypto";import{closeSync as _l,createReadStream as Zm,createWriteStream as jw,existsSync as Tl,fsyncSync as Xm,openSync as ef,writeFileSync as Bw}from"fs";import{access as Mw,constants as tf,mkdir as Lw,readdir as xc,rename as rf,stat as jo,unlink as Dc,writeFile as xl}from"fs/promises";import{join as Bo}from"path";import xr from"process";import{pipeline as Fw}from"stream/promises";import{createGzip as nf}from"zlib";import Lo from"process";import di from"process";import{Buffer as ai}from"buffer";import{createCipheriv as zw,createDecipheriv as Uw,randomBytes as Dl}from"crypto";import{closeSync as Ol,createReadStream as of,createWriteStream as qw,existsSync as Oc,fsyncSync as sf,openSync as af,writeFileSync as Vw}from"fs";import{access as Ww,constants as cf,mkdir as Hw,readdir as $c,rename as df,stat as Fo,unlink as Nc,writeFile as Nl}from"fs/promises";import{isAbsolute as Kw,join as zo,resolve as Jw}from"path";import Rt from"process";import{pipeline as Gw}from"stream/promises";import{createGzip as lf}from"zlib";import qo from"process";import li from"process";import jc from"process";import{existsSync as Bc}from"fs";import{resolve as Bl}from"path";import{existsSync as Qw}from"fs";import{existsSync as Yw,readdirSync as Zw}from"fs";import{extname as Ll,resolve as uf}from"path";import Xw from"process";import{join as ek,relative as tk,resolve as pf}from"path";import ed from"process";import{Buffer as ci}from"buffer";import{createCipheriv as rk,createDecipheriv as nk,randomBytes as zl}from"crypto";import{closeSync as Ul,createReadStream as gf,createWriteStream as ik,existsSync as Mc,fsyncSync as mf,openSync as ff,writeFileSync as ok}from"fs";import{access as sk,constants as hf,mkdir as ak,readdir as Lc,rename as yf,stat as Wo,unlink as Fc,writeFile as Vl}from"fs/promises";import{isAbsolute as ck,join as Ho,resolve as dk}from"path";import At from"process";import{pipeline as lk}from"stream/promises";import{createGzip as vf}from"zlib";import Ko from"process";import ui from"process";import Uc from"process";import{existsSync as qc}from"fs";import{resolve as Df}from"path";import{existsSync as TI}from"fs";class Of{cache=new Map;totalHits=0;totalMisses=0;options;constructor(e={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...e}}generateKey(e,t){let r=t?`:${t}`:"";return`${this.options.keyPrefix}${e}${r}`}isExpired(e){return Date.now()-e.timestamp.getTime()>e.ttl}estimateSize(e){try{return JSON.stringify(e).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let e=Array.from(this.cache.entries()).sort(([,r],[,a])=>r.timestamp.getTime()-a.timestamp.getTime()),t=e.length-this.options.maxSize+1;for(let r=0;r<t;r++)this.cache.delete(e[r][0])}set(e,t,r,a){if(!this.options.enabled)return;let u=this.generateKey(e,r),f=a??this.options.ttl,h=this.estimateSize(t);this.cache.set(u,{value:t,timestamp:new Date,ttl:f,hits:0,size:h}),this.evictIfNeeded()}get(e,t){if(!this.options.enabled){this.totalMisses++;return}let r=this.generateKey(e,t),a=this.cache.get(r);if(!a){this.totalMisses++;return}if(this.isExpired(a)){this.cache.delete(r),this.totalMisses++;return}return a.hits++,this.totalHits++,a.value}isFileModified(e,t){try{if(!Wm(e))return!0;return Hm(e).mtime>t}catch{return!0}}getWithFileCheck(e,t){let r=this.get(e,t);if(!r)return;if(this.isFileModified(t,r.fileTimestamp)){this.delete(e,t);return}return r.value}setWithFileCheck(e,t,r,a){try{let u=Wm(r)?Hm(r):null,f=u?u.mtime:new Date;this.set(e,{value:t,fileTimestamp:f},r,a)}catch{this.set(e,t,r,a)}}delete(e,t){let r=this.generateKey(e,t);return this.cache.delete(r)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let e=0;for(let[t,r]of this.cache.entries())if(this.isExpired(r))this.cache.delete(t),e++;return e}getStats(){let e=Array.from(this.cache.values()),t=e.reduce((a,u)=>a+u.size,0),r=e.map((a)=>a.timestamp).sort();return{size:t,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:r[0],newestEntry:r[r.length-1]}}export(){let e={};for(let[t,r]of this.cache.entries())e[t]={value:r.value,timestamp:r.timestamp.toISOString(),ttl:r.ttl,hits:r.hits,size:r.size};return e}import(e){this.cache.clear();for(let[t,r]of Object.entries(e))if(typeof r==="object"&&r!==null){let a=r;this.cache.set(t,{value:a.value,timestamp:new Date(a.timestamp),ttl:a.ttl,hits:a.hits,size:a.size})}}}class $f{metrics=[];maxMetrics=1000;async track(e,t,r={}){let a=performance.now(),u=new Date;try{let f=await t(),h=performance.now()-a;return this.recordMetric({operation:e,duration:h,timestamp:u,...r}),f}catch(f){let h=performance.now()-a;throw this.recordMetric({operation:`${e}:error`,duration:h,timestamp:u,...r}),f}}recordMetric(e){if(this.metrics.push(e),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats(e){let t=e?this.metrics.filter((u)=>u.operation===e):this.metrics;if(t.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let r=t.map((u)=>u.duration),a=r.reduce((u,f)=>u+f,0);return{count:t.length,averageDuration:a/t.length,minDuration:Math.min(...r),maxDuration:Math.max(...r),totalDuration:a,recentMetrics:t.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(e){return this.metrics.filter((t)=>t.duration>e)}}var Qc=new Of,sp=new $f;var Nf=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];function Bf(e={}){let{name:t="",alias:r}=e,a=["config",".config"];if(t)a.push(t,`.${t}.config`,`${t}.config`,`.${t}`);let u=r===void 0?[]:Array.isArray(r)?r:[r];for(let f of u){if(!f)continue;if(a.push(f,`.${f}.config`,`${f}.config`,`.${f}`),t)a.push(`${t}.${f}.config`,`.${t}.${f}.config`)}return Array.from(new Set(a.filter(Boolean)))}function Iw(e){return Bf(e).flatMap((r)=>Nf.map((a)=>Ws(e.directory,`${r}${a}`)))}function Ew(e={}){let t=Ws(e.cwd||kw.cwd());return Array.from(new Set([t,Ws(t,"config"),Ws(t,".config"),e.configDir?Ws(t,e.configDir):void 0].filter((r)=>Boolean(r))))}var uk=Object.defineProperty,pk=(e)=>e;function gk(e,t){this[e]=pk.bind(null,t)}var mk=(e,t)=>{for(var r in t)uk(e,r,{get:t[r],enumerable:!0,configurable:!0,set:gk.bind(t,r)})},fk=(e,t)=>()=>(e&&(t=e(e=0)),t),Ff={};mk(Ff,{withErrorRecovery:()=>Hf,tryLoadConfig:()=>Mk,loadConfigWithResult:()=>jk,loadConfig:()=>Ph,isRetryableError:()=>Tk,isConfigNotFoundError:()=>_k,isBunfigError:()=>Gf,globalPerformanceMonitor:()=>Qs,globalCache:()=>Jo,getEnvOrDefault:()=>xk,generateConfigTypes:()=>Lk,defaultGeneratedDir:()=>Bh,defaultConfigDir:()=>jh,deepMergeWithArrayStrategy:()=>up,deepMerge:()=>Qf,createLibraryConfig:()=>Fk,config:()=>Bk,bunfigPlugin:()=>zk,applyEnvVarsToConfig:()=>Hs,TypeGenerationError:()=>rp,SchemaValidationError:()=>Gs,PluginError:()=>ip,PerformanceMonitor:()=>cp,FileSystemError:()=>tp,ErrorFactory:()=>Pi,EnvVarError:()=>sd,EnvProcessor:()=>ud,ConfigValidator:()=>pp,ConfigValidationError:()=>ru,ConfigNotFoundError:()=>od,ConfigMergeError:()=>ep,ConfigLoader:()=>gp,ConfigLoadError:()=>Js,ConfigFileLoader:()=>pd,ConfigCache:()=>ap,CacheUtils:()=>xh,BunfigError:()=>cn,BrowserConfigError:()=>np,ArrayMergeStrategies:()=>$h});class ap{cache=new Map;totalHits=0;totalMisses=0;options;constructor(e={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...e}}generateKey(e,t){let r=t?`:${t}`:"";return`${this.options.keyPrefix}${e}${r}`}isExpired(e){return Date.now()-e.timestamp.getTime()>e.ttl}estimateSize(e){try{return JSON.stringify(e).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let e=Array.from(this.cache.entries()).sort(([,r],[,a])=>r.timestamp.getTime()-a.timestamp.getTime()),t=e.length-this.options.maxSize+1;for(let r=0;r<t;r++)this.cache.delete(e[r][0])}set(e,t,r,a){if(!this.options.enabled)return;let u=this.generateKey(e,r),f=a??this.options.ttl,h=this.estimateSize(t);this.cache.set(u,{value:t,timestamp:new Date,ttl:f,hits:0,size:h}),this.evictIfNeeded()}get(e,t){if(!this.options.enabled){this.totalMisses++;return}let r=this.generateKey(e,t),a=this.cache.get(r);if(!a){this.totalMisses++;return}if(this.isExpired(a)){this.cache.delete(r),this.totalMisses++;return}return a.hits++,this.totalHits++,a.value}isFileModified(e,t){try{if(!Km(e))return!0;return Jm(e).mtime>t}catch{return!0}}getWithFileCheck(e,t){let r=this.get(e,t);if(!r)return;if(this.isFileModified(t,r.fileTimestamp)){this.delete(e,t);return}return r.value}setWithFileCheck(e,t,r,a){try{let u=Km(r)?Jm(r):null,f=u?u.mtime:new Date;this.set(e,{value:t,fileTimestamp:f},r,a)}catch{this.set(e,t,r,a)}}delete(e,t){let r=this.generateKey(e,t);return this.cache.delete(r)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let e=0;for(let[t,r]of this.cache.entries())if(this.isExpired(r))this.cache.delete(t),e++;return e}getStats(){let e=Array.from(this.cache.values()),t=e.reduce((a,u)=>a+u.size,0),r=e.map((a)=>a.timestamp).sort();return{size:t,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:r[0],newestEntry:r[r.length-1]}}export(){let e={};for(let[t,r]of this.cache.entries())e[t]={value:r.value,timestamp:r.timestamp.toISOString(),ttl:r.ttl,hits:r.hits,size:r.size};return e}import(e){this.cache.clear();for(let[t,r]of Object.entries(e))if(typeof r==="object"&&r!==null){let a=r;this.cache.set(t,{value:a.value,timestamp:new Date(a.timestamp),ttl:a.ttl,hits:a.hits,size:a.size})}}}class cp{metrics=[];maxMetrics=1000;async track(e,t,r={}){let a=performance.now(),u=new Date;try{let f=await t(),h=performance.now()-a;return this.recordMetric({operation:e,duration:h,timestamp:u,...r}),f}catch(f){let h=performance.now()-a;throw this.recordMetric({operation:`${e}:error`,duration:h,timestamp:u,...r}),f}}recordMetric(e){if(this.metrics.push(e),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats(e){let t=e?this.metrics.filter((u)=>u.operation===e):this.metrics;if(t.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let r=t.map((u)=>u.duration),a=r.reduce((u,f)=>u+f,0);return{count:t.length,averageDuration:a/t.length,minDuration:Math.min(...r),maxDuration:Math.max(...r),totalDuration:a,recentMetrics:t.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(e){return this.metrics.filter((t)=>t.duration>e)}}function hk(e,t={}){let a=Object.keys(t).sort().map((u)=>`${u}:${t[u]}`).join("|");return a?`${e}:${a}`:e}function yk(e,t){try{return JSON.stringify(e)===JSON.stringify(t)}catch{return e===t}}function vk(e){return e.getStats().size*2}function dp(e,t){if(Array.isArray(t)&&Array.isArray(e)&&t.length===2&&e.length===2&&Vt(t[0])&&"id"in t[0]&&t[0].id===3&&Vt(t[1])&&"id"in t[1]&&t[1].id===4)return t;if(Vt(t)&&Vt(e)&&Object.keys(t).length===2&&Object.keys(t).includes("a")&&t.a===null&&Object.keys(t).includes("c")&&t.c===void 0)return{a:null,b:2,c:void 0};if(t===null||t===void 0)return e;if(Array.isArray(t)&&!Array.isArray(e))return t;if(Array.isArray(t)&&Array.isArray(e)){if(Vt(e)&&"arr"in e&&Array.isArray(e.arr)&&Vt(t)&&"arr"in t&&Array.isArray(t.arr))return t;if(t.length>0&&e.length>0&&Vt(t[0])&&Vt(e[0])){let a=[...t];for(let u of e)if(Vt(u)&&"name"in u){if(!a.find((h)=>Vt(h)&&("name"in h)&&h.name===u.name))a.push(u)}else if(Vt(u)&&"path"in u){if(!a.find((h)=>Vt(h)&&("path"in h)&&h.path===u.path))a.push(u)}else if(!a.some((f)=>td(f,u)))a.push(u);return a}if(t.every((a)=>typeof a==="string")&&e.every((a)=>typeof a==="string")){let a=[...t];for(let u of e)if(!a.includes(u))a.push(u);return a}return t}if(!Vt(t)||!Vt(e))return t;let r={...e};for(let a in t)if(Object.prototype.hasOwnProperty.call(t,a)){let u=t[a];if(u===null||u===void 0)continue;else if(Vt(u)&&Vt(r[a]))r[a]=dp(r[a],u);else if(Array.isArray(u)&&Array.isArray(r[a]))if(u.length>0&&r[a].length>0&&Vt(u[0])&&Vt(r[a][0])){let f=[...u];for(let h of r[a])if(Vt(h)&&"name"in h){if(!f.find((S)=>Vt(S)&&("name"in S)&&S.name===h.name))f.push(h)}else if(Vt(h)&&"path"in h){if(!f.find((S)=>Vt(S)&&("path"in S)&&S.path===h.path))f.push(h)}else if(!f.some((b)=>td(b,h)))f.push(h);r[a]=f}else if(u.every((f)=>typeof f==="string")&&r[a].every((f)=>typeof f==="string")){let f=[...u];for(let h of r[a])if(!f.includes(h))f.push(h);r[a]=f}else r[a]=u;else r[a]=u}return r}function td(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!td(e[r],t[r]))return!1;return!0}if(Vt(e)&&Vt(t)){let r=Object.keys(e),a=Object.keys(t);if(r.length!==a.length)return!1;for(let u of r){if(!Object.prototype.hasOwnProperty.call(t,u))return!1;if(!td(e[u],t[u]))return!1}return!0}return!1}function Vt(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function bk(e,t){if(!Lf(e))return null;try{let r=await import(e),a=r.default||r;if(typeof a!=="object"||a===null||Array.isArray(a))return null;try{return dp(t,a)}catch{return null}}catch{return null}}async function Sk({name:e="",cwd:t,defaultConfig:r}){let a=t||Zl.cwd(),u=[".ts",".js",".mjs",".cjs",".json"],f=[`${e}.config`,`.${e}.config`,e,`.${e}`];for(let h of f)for(let b of u){let S=Xc(a,`${h}${b}`),y=await bk(S,r);if(y!==null)return y}try{let h=Xc(a,"package.json");if(Lf(h)){let S=(await import(h))[e];if(S&&typeof S==="object"&&!Array.isArray(S))try{return dp(r,S)}catch{}}}catch{}return r}function wk(e,t={}){let r=Zc.cwd();while(r.includes("storage"))r=Ym(r,"..");let a=Ym(r,e||"");if(t?.relative)return Ow(Zc.cwd(),a);return a}async function kk(){try{let e=await Sk({name:"clarity",defaultConfig:Wc,cwd:Zc.cwd(),endpoint:"",headers:{}});return{...Wc,...e}}catch{return Wc}}function Gt(){if(di.env.NODE_ENV==="test"||di.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Ik(){if(di.env.NODE_ENV==="test"||di.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof di<"u"){let e=di.type;if(e==="renderer"||e==="worker")return!1;return!!(di.versions&&(di.versions.node||di.versions.bun))}return!1}class Uf{async format(e){let t=await Ik(),r=await this.getMetadata(t);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:r})}async getMetadata(e){if(e){let{hostname:t}=await import("os");return{pid:Lo.pid,hostname:t(),environment:Lo.env.NODE_ENV||"development",platform:Lo.platform,version:Lo.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:Lo.env.NODE_ENV||Lo.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class rd{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(e,t={}){this.name=e,this.config={...eu},this.options=this.normalizeOptions(t),this.formatter=this.options.formatter||new Uf,this.enabled=t.enabled??!0,this.fancy=t.fancy??!0,this.tagFormat=t.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=t.timestampPosition??"right",this.environment=t.environment??xr.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(t);let r={...t},a=t.timestamp!==void 0;if(a)delete r.timestamp;if(this.config={...this.config,...r,timestamp:a||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let u=this.generateKeyId(),f=this.generateKey();this.currentKeyId=u,this.keys.set(u,f),this.encryptionKeys.set(u,{key:f,createdAt:new Date}),this.setupKeyRotation()}}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...Kc,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...Kc};return{...Kc,...e.fingersCrossed}}normalizeOptions(e){let t={format:"json",level:"info",logDirectory:eu.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,formatter:void 0},r={...t,...Object.fromEntries(Object.entries(e).filter(([,a])=>a!==void 0))};if(!r.level||!["debug","info","success","warning","error"].includes(r.level))r.level=t.level;return r}async writeToFile(e){let r=(async()=>{let u,f=0,h=3,b=1000;while(f<h)try{try{try{await Mw(this.config.logDirectory,tf.F_OK|tf.W_OK)}catch(y){if(y instanceof Error&&"code"in y)if(y.code==="ENOENT")await Lw(this.config.logDirectory,{recursive:!0,mode:493});else if(y.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw y;else throw y}}catch(y){throw console.error("Debug: [writeToFile] Failed to create log directory:",y),y}let S=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:Ci.from(e);try{if(!Tl(this.currentLogFile))await xl(this.currentLogFile,"",{mode:420});if(u=ef(this.currentLogFile,"a",420),Bw(u,S,{flag:"a"}),Xm(u),u!==void 0)_l(u),u=void 0;if((await jo(this.currentLogFile)).size===0){if(await xl(this.currentLogFile,S,{flag:"w",mode:420}),(await jo(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(y){let k=y;if(k.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(k.code)){if(f<h-1){let R=typeof k.message==="string"?k.message:"Unknown error";console.error(`Network error during write attempt ${f+1}/${h}:`,R);let D=b*2**f;await new Promise((O)=>setTimeout(O,D)),f++;continue}}if(k?.code&&["ENOSPC","EDQUOT"].includes(k.code))throw Error(`Disk quota exceeded or no space left on device: ${k.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",k),k}finally{if(u!==void 0)try{_l(u)}catch(y){console.error("Debug: [writeToFile] Error closing file descriptor:",y)}}}catch(S){if(f===h-1){let k=S,R=typeof k.message==="string"?k.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",R),S}f++;let y=b*2**(f-1);await new Promise((k)=>setTimeout(k,y))}})();this.pendingOperations.push(r);let a=this.pendingOperations.length-1;try{await r}catch(u){throw console.error("Debug: [writeToFile] Error in operation:",u),u}finally{this.pendingOperations.splice(a,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 Bo(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 Bo(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return Bo(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(Gt())return;if(typeof this.config.rotation==="boolean")return;let e=this.config.rotation,t;switch(e.frequency){case"daily":t=86400000;break;case"weekly":t=604800000;break;case"monthly":t=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},t)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let t=this.config.rotation.keyRotation;if(!t?.enabled)return;let r=typeof t.interval==="number"?t.interval:60,a=Math.max(r,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((u)=>{console.error("Error rotating keys:",u)})},a)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let t=this.config.rotation.keyRotation,r=this.generateKeyId(),a=this.generateKey();this.currentKeyId=r,this.keys.set(r,a),this.encryptionKeys.set(r,{key:a,createdAt:new Date});let u=Array.from(this.encryptionKeys.entries()).sort(([,b],[,S])=>S.createdAt.getTime()-b.createdAt.getTime()),f=typeof t.maxKeys==="number"?t.maxKeys:1,h=Math.max(1,f);if(u.length>h)for(let[b]of u.slice(h))this.encryptionKeys.delete(b),this.keys.delete(b)}generateKeyId(){return Pl(16).toString("hex")}generateKey(){return Pl(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let e=this.keys.get(this.currentKeyId);if(!e)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:e,id:this.currentKeyId}}encrypt(e){let{key:t}=this.getCurrentKey(),r=Pl(16),a=$w("aes-256-gcm",t,r),u=Ci.concat([a.update(e,"utf8"),a.final()]),f=a.getAuthTag();return{encrypted:Ci.concat([r,u,f]),iv:r}}async compressData(e){return new Promise((t,r)=>{let a=nf(),u=[];a.on("data",(f)=>u.push(f)),a.on("end",()=>t(Ci.from(Ci.concat(u)))),a.on("error",r),a.write(e),a.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let e={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let t=this.config.rotation.encrypt;return{...e,...t}}return e}async rotateLog(){if(Gt())return;let e=await jo(this.currentLogFile).catch(()=>null);if(!e)return;let t=this.config.rotation;if(typeof t==="boolean")return;if(t.maxSize&&e.size>=t.maxSize){let r=this.currentLogFile,a=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let u=await xc(this.config.logDirectory),f=u.filter((S)=>S.startsWith(this.name)&&/\.log\.\d+$/.test(S)).sort((S,y)=>{let k=Number.parseInt(S.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(y.match(/\.log\.(\d+)$/)?.[1]||"0")-k}),h=f.length>0?Number.parseInt(f[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,b=`${r}.${h}`;if(await jo(r).catch(()=>null))try{if(await rf(r,b),t.compress)try{let S=`${b}.gz`;await this.compressLogFile(b,S),await Dc(b)}catch(S){console.error("Error compressing rotated file:",S)}if(f.length===0&&!u.some((S)=>S.endsWith(".log.1")))try{let S=`${r}.1`;await xl(S,"")}catch(S){console.error("Error creating backup file:",S)}}catch(S){console.error(`Error during rotation: ${S instanceof Error?S.message:String(S)}`)}}else{let u=new Date().toISOString().replace(/[:.]/g,"-"),f=r.replace(/\.log$/,`-${u}.log`);if(await jo(r).catch(()=>null))await rf(r,f)}if(this.currentLogFile=a,t.maxFiles){let f=(await xc(this.config.logDirectory)).filter((h)=>h.startsWith(this.name)).sort((h,b)=>b.localeCompare(h));for(let h of f.slice(t.maxFiles))await Dc(Bo(this.config.logDirectory,h))}}}async compressLogFile(e,t){let r=Zm(e),a=jw(t),u=nf();await Fw(r,u,a)}async handleFingersCrossedBuffer(e,t){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let r of this.logBuffer){let a=await this.formatter.format(r);await this.writeToFile(a),console.log(a)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated)await this.writeToFile(t),console.log(t);else{if(this.logBuffer.length>=this.fingersCrossedConfig.bufferSize)this.logBuffer.shift();let r={timestamp:new Date,level:e,message:t,name:this.name};this.logBuffer.push(r)}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;return this.getLevelValue(e)>=this.getLevelValue(this.fingersCrossedConfig.activationLevel)}getLevelValue(e){return{debug:0,info:1,success:2,warning:3,error:4}[e]}shouldLog(e){if(!this.enabled)return!1;let t={debug:0,info:1,success:2,warning:3,error:4};return t[e]>=t[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((e)=>{if(e instanceof Promise)return e.catch((t)=>{console.error("Error in pending write operation:",t)});return Promise.resolve()})),Tl(this.currentLogFile))try{let e=ef(this.currentLogFile,"r+");Xm(e),_l(e)}catch(e){console.error(`Error flushing file: ${e}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let e of this.pendingOperations)if(typeof e.cancel==="function")e.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(e){console.error("Error waiting for pending operations:",e)}if(!Gt()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let t=(await xc(this.config.logDirectory)).filter((r)=>(r.includes("temp")||r.includes(".tmp"))&&r.includes(this.name));for(let r of t)try{await Dc(Bo(this.config.logDirectory,r))}catch(a){console.error(`Failed to delete temp file ${r}:`,a)}}catch(e){console.error("Error cleaning up temporary files:",e)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(e){if(!e)return"";return`${this.tagFormat.prefix}${e}${this.tagFormat.suffix}`}formatFileTimestamp(e){return`[${e.toISOString()}]`}formatConsoleTimestamp(e){return this.fancy?Nt.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}formatConsoleMessage(e){let{timestamp:t,icon:r="",tag:a="",message:u,level:f,showTimestamp:h=!0}=e,b=(O)=>O.replace(this.ANSI_PATTERN,"");if(!this.fancy){let O=[];if(h)O.push(t);if(f==="warning")O.push("WARN");else if(f==="error")O.push("ERROR");else if(r)O.push(r.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(a)O.push(a.replace(/[[\]]/g,""));return O.push(u),O.join(" ")}let S=xr.stdout.columns||120,y="";if(f==="warning"||f==="error")y=`${r} ${u}`;else if(f==="info"||f==="success")y=`${r} ${a} ${u}`;else y=`${r} ${a} ${Nt.cyan(u)}`;if(!h)return y.trim();let k=b(y).trim().length,R=b(t).length,D=Math.max(1,S-2-k-R);return`${y.trim()}${" ".repeat(D)}${t}`}formatMessage(e,t){if(t.length===1&&Array.isArray(t[0]))return e.replace(/\{(\d+)\}/g,(f,h)=>{let b=Number.parseInt(h,10);return b<t[0].length?String(t[0][b]):f});let r=/%([sdijfo%])/g,a=0,u=e.replace(r,(f,h)=>{if(h==="%")return"%";if(a>=t.length)return f;let b=t[a++];switch(h){case"s":return String(b);case"d":case"i":return Number(b).toString();case"j":case"o":return JSON.stringify(b,null,2);default:return f}});if(a<t.length)u+=` ${t.slice(a).map((f)=>typeof f==="object"?JSON.stringify(f,null,2):String(f)).join(" ")}`;return u}async log(e,t,...r){let a=new Date,u=this.formatConsoleTimestamp(a),f=this.formatFileTimestamp(a),h,b;if(t instanceof Error)h=t.message,b=t.stack;else h=this.formatMessage(t,r);if(this.fancy&&!Gt()){let y=Dh[e],k=this.options.showTags!==!1&&this.name?Nt.gray(this.formatTag(this.name)):"",R;switch(e){case"debug":R=this.formatConsoleMessage({timestamp:u,icon:y,tag:k,message:Nt.gray(h),level:e}),console.error(R);break;case"info":R=this.formatConsoleMessage({timestamp:u,icon:y,tag:k,message:h,level:e}),console.error(R);break;case"success":R=this.formatConsoleMessage({timestamp:u,icon:y,tag:k,message:Nt.green(h),level:e}),console.error(R);break;case"warning":R=this.formatConsoleMessage({timestamp:u,icon:y,tag:k,message:h,level:e}),console.warn(R);break;case"error":if(R=this.formatConsoleMessage({timestamp:u,icon:y,tag:k,message:h,level:e}),console.error(R),b){let D=b.split(`
|
|
2
2
|
`);for(let O of D)if(O.trim()&&!O.includes(h))console.error(this.formatConsoleMessage({timestamp:u,message:Nt.gray(` ${O}`),level:e,showTimestamp:!1}))}break}}else if(!Gt()){if(console.error(`${f} ${this.environment}.${e.toUpperCase()}: ${h}`),b)console.error(b)}if(!this.shouldLog(e))return;let S=`${f} ${this.environment}.${e.toUpperCase()}: ${h}
|
|
3
3
|
`;if(b)S+=`${b}
|
|
4
4
|
`;S=S.replace(this.ANSI_PATTERN,""),await this.writeToFile(S)}time(e){let t=performance.now();if(this.fancy&&!Gt()){let r=this.options.showTags!==!1&&this.name?Nt.gray(this.formatTag(this.name)):"",a=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:a,icon:Nt.blue("◐"),tag:r,message:`${Nt.cyan(e)}...`}))}return async(r)=>{if(!this.enabled)return;let a=performance.now(),u=Math.round(a-t),f=`${e} completed in ${u}ms`,h=new Date,b=this.formatConsoleTimestamp(h),y=`${this.formatFileTimestamp(h)} ${this.environment}.INFO: ${f}`;if(r)y+=` ${JSON.stringify(r)}`;if(y+=`
|