function Lt(e){return{href:e.href,protocol:e.protocol,username:e.username,password:e.password,host:e.host,hostname:e.hostname,port:e.port,pathname:e.pathname,search:e.search,searchParams:[...e.searchParams].map(([t,r])=>({key:t,value:r})),hash:e.hash,origin:e.origin}}const U={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]};function H(e,t,r,n=!1){const s=String(t),c=(h,u)=>`\x1B[${u[0]}m${h}\x1B[${u[1]}m`,a=(h,u)=>u!=null&&typeof u=="string"?c(h,U[u]):u!=null&&Array.isArray(u)?u.reduce((y,m)=>a(y,m),h):u!=null&&u[h.trim()]!=null?a(h,u[h.trim()]):u!=null&&u["*"]!=null?a(h,u["*"]):h,f=null;return s.replace(/{{(.+?)}}/g,(h,u)=>{const y=r[u]!=null?String(r[u]):n?"":h;return e.stylePrettyLogs?a(y,e?.prettyLogStyles?.[u]??f)+c("",U.reset):y})}function j(e,t=2,r=0){return e!=null&&isNaN(e)?"":(e=e!=null?e+r:e,t===2?e==null?"--":e<10?"0"+e:e.toString():e==null?"---":e<10?"00"+e:e<100?"0"+e:e.toString())}function tt(e,t){if(t==null)return{text:"",template:e.prettyLogTemplate,placeholders:{}};let r=e.prettyLogTemplate;const n={};r.includes("{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}}")?r=r.replace("{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}}","{{dateIsoStr}}"):e.prettyLogTimeZone==="UTC"?(n.yyyy=t.date?.getUTCFullYear()??"----",n.mm=j(t.date?.getUTCMonth(),2,1),n.dd=j(t.date?.getUTCDate(),2),n.hh=j(t.date?.getUTCHours(),2),n.MM=j(t.date?.getUTCMinutes(),2),n.ss=j(t.date?.getUTCSeconds(),2),n.ms=j(t.date?.getUTCMilliseconds(),3)):(n.yyyy=t.date?.getFullYear()??"----",n.mm=j(t.date?.getMonth(),2,1),n.dd=j(t.date?.getDate(),2),n.hh=j(t.date?.getHours(),2),n.MM=j(t.date?.getMinutes(),2),n.ss=j(t.date?.getSeconds(),2),n.ms=j(t.date?.getMilliseconds(),3));const s=e.prettyLogTimeZone==="UTC"?t.date:t.date!=null?new Date(t.date.getTime()-t.date.getTimezoneOffset()*6e4):void 0;n.rawIsoStr=s?.toISOString()??"",n.dateIsoStr=s?.toISOString().replace("T"," ").replace("Z","")??"",n.logLevelName=t.logLevelName,n.fileNameWithLine=t.path?.fileNameWithLine??"",n.filePathWithLine=t.path?.filePathWithLine??"",n.fullFilePath=t.path?.fullFilePath??"";let c=e.parentNames?.join(e.prettyErrorParentNamesSeparator);c=c!=null&&t.name!=null?c+e.prettyErrorParentNamesSeparator:void 0;const a=t.name!=null||c!=null?`${c??""}${t.name??""}`:"";return n.name=a,n.nameWithDelimiterPrefix=a.length>0?e.prettyErrorLoggerNameDelimiter+a:"",n.nameWithDelimiterSuffix=a.length>0?a+e.prettyErrorLoggerNameDelimiter:"",e.overwrite?.addPlaceholders!=null&&e.overwrite.addPlaceholders(t,n),{text:H(e,r,n),template:r,placeholders:n}}const et=[/(?:^|[\\/])node_modules[\\/].*tslog/i,/(?:^|[\\/])deps[\\/].*tslog/i,/tslog[\\/]+src[\\/]+internal[\\/]/i,/tslog[\\/]+src[\\/]BaseLogger/i,/tslog[\\/]+src[\\/]index/i];function Nt(e){const t=typeof e?.stack=="string"?e.stack:void 0;return t==null||t.length===0?[]:t.split(`
`).map(r=>r.trimEnd())}function jt(e){return e.filter(t=>t.length>0&&!/^\s*Error\b/.test(t))}function Pt(e,t){const r=[];for(const n of e){const s=t(n);s!=null&&r.push(s)}return r}function Ct(e,t=et){for(let r=0;r<e.length;r+=1){const n=e[r],s=n.filePath??"",c=n.fullFilePath??"";if(!t.some(a=>a.test(s)||a.test(c)))return r}return 0}function Tt(e){return jt(Nt(e))}function R(e,t){return Pt(Tt(e),t)}function X(e,t){return e<0?0:e>=t?Math.max(0,t-1):e}function Q(){return[...et]}const At=5;function Bt(e,t={}){const r=t.maxDepth??At,n=[],s=new Set;let c=e,a=0;for(;c!=null&&a<r;){const f=c?.cause;if(f==null||s.has(f))break;s.add(f),n.push(rt(f)),c=f,a+=1}return n}function rt(e){if(e instanceof Error)return e;const t=new Error(typeof e=="string"?e:JSON.stringify(e));return typeof e=="object"&&e!=null&&Object.assign(t,e),t}function nt(e){const t=new Set;return JSON.stringify(e,(r,n)=>{if(typeof n=="object"&&n!==null){if(t.has(n))return"[Circular]";t.add(n)}return typeof n=="bigint"?`${n}`:typeof n>"u"?"[undefined]":n})}function P(e,t){const r={seen:[],stylize:it};return t!=null&&lt(r,t),M(r.showHidden)&&(r.showHidden=!1),M(r.depth)&&(r.depth=2),M(r.colors)&&(r.colors=!0),M(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=Dt),x(r,e,r.depth)}P.colors=U;P.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function Mt(e){return typeof e=="boolean"}function M(e){return e===void 0}function it(e){return e}function Dt(e,t){const r=P.styles[t];return r!=null&&P?.colors?.[r]?.[0]!=null&&P?.colors?.[r]?.[1]!=null?"\x1B["+P.colors[r][0]+"m"+e+"\x1B["+P.colors[r][1]+"m":e}function $(e){return typeof e=="function"}function ot(e){return typeof e=="string"}function Ft(e){return typeof e=="number"}function st(e){return e===null}function at(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function v(e){return W(e)&&J(e)==="[object RegExp]"}function W(e){return typeof e=="object"&&e!==null}function K(e){return W(e)&&(J(e)==="[object Error]"||e instanceof Error)}function q(e){return W(e)&&J(e)==="[object Date]"}function J(e){return Object.prototype.toString.call(e)}function _t(e){const t={};return e.forEach(r=>{t[r]=!0}),t}function It(e,t,r,n,s){const c=[];for(let a=0,f=t.length;a<f;++a)at(t,String(a))?c.push(G(e,t,r,n,String(a),!0)):c.push("");return s.forEach(a=>{a.match(/^\d+$/)||c.push(G(e,t,r,n,a,!0))}),c}function V(e){return"["+Error.prototype.toString.call(e)+"]"}function x(e,t,r=0){if(e.customInspect&&t!=null&&$(t)&&t?.inspect!==P&&!(t?.constructor&&t?.constructor.prototype===t)){if(typeof t.inspect!="function"&&t.toString!=null)return t.toString();let y=t?.inspect(r,e);return ot(y)||(y=x(e,y,r)),y}const n=A(e,t);if(n)return n;let s=Object.keys(t);const c=_t(s);try{e.showHidden&&Object.getOwnPropertyNames&&(s=Object.getOwnPropertyNames(t))}catch{}if(K(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return V(t);if(s.length===0)if($(e.stylize)){if($(t)){const y=t.name?": "+t.name:"";return e.stylize("[Function"+y+"]","special")}if(v(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(q(t))return e.stylize(Date.prototype.toISOString.call(t),"date");if(K(t))return V(t)}else return t;let a="",f=!1,h=[`{
`,`
}`];if(Array.isArray(t)&&(f=!0,h=[`[
`,`
]`]),$(t)&&(a=" [Function"+(t.name?": "+t.name:"")+"]"),v(t)&&(a=" "+RegExp.prototype.toString.call(t)),q(t)&&(a=" "+Date.prototype.toUTCString.call(t)),K(t)&&(a=" "+V(t)),s.length===0&&(!f||t.length==0))return h[0]+a+h[1];if(r<0)return v(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);let u;return f?u=It(e,t,r,c,s):u=s.map(y=>G(e,t,r,c,y,f)),e.seen.pop(),$t(u,a,h)}function G(e,t,r,n,s,c){let a,f,h={value:void 0};try{h.value=t[s]}catch{}try{Object.getOwnPropertyDescriptor&&(h=Object.getOwnPropertyDescriptor(t,s)||h)}catch{}if(h.get?h.set?f=e.stylize("[Getter/Setter]","special"):f=e.stylize("[Getter]","special"):h.set&&(f=e.stylize("[Setter]","special")),at(n,s)||(a="["+s+"]"),f||(e.seen.indexOf(h.value)<0?(st(r)?f=x(e,h.value,void 0):f=x(e,h.value,r-1),f.indexOf(`
`)>-1&&(c?f=f.split(`
`).map(u=>"  "+u).join(`
`).substr(2):f=`
`+f.split(`
`).map(u=>"   "+u).join(`
`))):f=e.stylize("[Circular]","special")),M(a)){if(c&&s.match(/^\d+$/))return f;a=JSON.stringify(""+s),a.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,"\\'").replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+f}function A(e,t){if(M(t))return e.stylize("undefined","undefined");if(ot(t)){const r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,"\\'")+"'";return e.stylize(r,"string")}if(Ft(t))return e.stylize(""+t,"number");if(Mt(t))return e.stylize(""+t,"boolean");if(st(t))return e.stylize("null","null")}function $t(e,t,r){return r[0]+(t===""?"":t+`
`)+"  "+e.join(`,
  `)+" "+r[1]}function lt(e,t){const r={...e};if(!t||!W(t))return e;const n={...t},s=Object.keys(t);let c=s.length;for(;c--;)r[s[c]]=n[s[c]];return r}function xt(e,...t){const r={seen:[],stylize:it};e!=null&&lt(r,e);const n=t[0];let s=0,c="",a="";if(typeof n=="string"){if(t.length===1)return n;let f,h=0;for(let u=0;u<n.length-1;u++)if(n.charCodeAt(u)===37){const y=n.charCodeAt(++u);if(s+1!==t.length){switch(y){case 115:{const m=t[++s];typeof m=="number"||typeof m=="bigint"?f=A(r,m):typeof m!="object"||m===null?f=String(m):f=P(m,{...e,compact:3,colors:!1,depth:0});break}case 106:f=nt(t[++s]);break;case 100:{const m=t[++s];typeof m=="bigint"?f=A(r,m):typeof m=="symbol"?f="NaN":f=A(r,m);break}case 79:f=P(t[++s],e);break;case 111:f=P(t[++s],{...e,showHidden:!0,showProxy:!0,depth:4});break;case 105:{const m=t[++s];typeof m=="bigint"?f=A(r,m):typeof m=="symbol"?f="NaN":f=A(r,parseInt(f));break}case 102:{const m=t[++s];typeof m=="symbol"?f="NaN":f=A(r,parseInt(m));break}case 99:s+=1,f="";break;case 37:c+=n.slice(h,u),h=u+1;continue;default:continue}h!==u-1&&(c+=n.slice(h,u-1)),c+=f,h=u+1}else y===37&&(c+=n.slice(h,u),h=u+1)}h!==0&&(s++,a=" ",h<n.length&&(c+=n.slice(h)))}for(;s<t.length;){const f=t[s];c+=a,c+=typeof f!="string"?P(f,e):f,a=" ",s++}return c}function Wt(){try{const e=globalThis?.process;if(typeof e?.cwd=="function")return e.cwd()}catch{}try{const e=globalThis?.Deno;if(typeof e?.cwd=="function")return e.cwd()}catch{}}function ct(){return typeof window<"u"&&typeof document<"u"}function zt(){if(!ct())return!1;const t=globalThis?.navigator?.userAgent??"";return/firefox/i.test(t)||globalThis?.CSS?.supports?.("color","#000")?!0:/safari/i.test(t)&&!/chrome/i.test(t)}function Rt(){const e=bt(),t=dt(e),r=e.name==="browser"||e.name==="worker",n=r?[...Q(),/node_modules[\\/].*tslog/i]:[...Q(),/node:(?:internal|vm)/i,/\binternal[\\/]/i];let s;const c={getMeta(i,o,l,g,p,d){return Object.assign({},t,{name:p,parentNames:d,date:new Date,logLevelId:i,logLevelName:o,path:g?void 0:c.getCallerStackFrame(l)})},getCallerStackFrame(i,o=new Error){const l=R(o,b=>a(b));if(l.length===0)return{};const g=Ct(l,n),p=Number.isFinite(i)&&i>=0,d=X(p?i:g,l.length);return l[d]??{}},getErrorTrace(i){return R(i,o=>a(o))},isError(i){return St(i)},isBuffer(i){return typeof Buffer<"u"&&typeof Buffer.isBuffer=="function"?Buffer.isBuffer(i):!1},prettyFormatLogObj(i,o){return i.reduce((l,g)=>(c.isError(g)?l.errors.push(c.prettyFormatErrorObj(g,o)):l.args.push(g),l),{args:[],errors:[]})},prettyFormatErrorObj(i,o){const l=u(c.getErrorTrace(i),o),g=Bt(i).map((d,b)=>{const w=`Caused by (${b+1}): ${d.name??"Error"}${d.message?`: ${d.message}`:""}`,O=u(R(d,S=>a(S)),o);return[w,...O].join(`
`)}),p={errorName:` ${i.name} `,errorMessage:y(i),errorStack:[...l,...g].join(`
`)};return H(o,o.prettyErrorTemplate,p)},transportFormatted(i,o,l,g,p){const d=p.stylePrettyLogs!==!1,b=(l.length>0&&o.length>0?`
`:"")+l.join(`
`),w=N(i),O=d?i:w;if(m(d)){p.prettyInspectOptions.colors=!1;const k=Z(p.prettyInspectOptions,o),E=g!=null?T(p,g):{text:w,styles:[]},L=E.text.length>0&&E.styles.length>0,D=(L?E.text:w)+k+b;L?console.log(D,...E.styles):console.log(D);return}p.prettyInspectOptions.colors=d;const S=Z(p.prettyInspectOptions,o);console.log(O+S+b)},transportJSON(i){console.log(nt(i))}};return Ot()==="test"&&(c.__resetWorkingDirectoryCacheForTests=()=>{s=void 0}),c;function a(i){return r?h(i):f(i)}function f(i){if(typeof i!="string"||i.length===0)return;const o=i.trim();if(!o.includes(" at ")&&!o.startsWith("at "))return;const l=o.replace(/^at\s+/,"");let g,p=l;const d=l.match(/^(.*?)\s+\((.*)\)$/);d&&(g=d[1],p=d[2]);const b=p.replace(/^\(/,"").replace(/\)$/,""),w=b.replace(/\?.*$/,"");let O,S,k=w;const E=w.split(":");E.length>=3&&/^\d+$/.test(E[E.length-1]??"")?(S=E.pop(),O=E.pop(),k=E.join(":")):E.length>=2&&/^\d+$/.test(E[E.length-1]??"")&&(O=E.pop(),k=E.join(":"));let L=k.replace(/^file:\/\//,"");const _=ht();_!=null&&L.startsWith(_)&&(L=L.slice(_.length),L=L.replace(/^[\\/]/,"")),L.length===0&&(L=k);const D=yt(L),I=D.length>0?D:L,Y=I.split(/\\|\//),z=Y[Y.length-1],Et=z&&O?`${z}:${O}`:void 0,kt=I&&O?`${I}:${O}`:void 0;return{fullFilePath:b,fileName:z,fileNameWithLine:Et,fileColumn:S,fileLine:O,filePath:I,filePathWithLine:kt,method:g}}function h(i){const o=globalThis.location?.origin;if(i==null)return;const l=i.match(Ut);if(!l)return;const g=l[1]?.replace(/\?.*$/,"");if(g==null)return;const p=g.split("/"),d=l[2],b=l[3],w=p[p.length-1];return{fullFilePath:o?`${o}${g}`:g,fileName:w,fileNameWithLine:w&&d?`${w}:${d}`:void 0,fileColumn:b,fileLine:d,filePath:g,filePathWithLine:d?`${g}:${d}`:void 0,method:void 0}}function u(i,o){return i.map(l=>H(o,o.prettyErrorStackTemplate,{...l},!0))}function y(i){return Object.getOwnPropertyNames(i).filter(o=>o!=="stack"&&o!=="cause").reduce((o,l)=>{const g=i[l];return typeof g=="function"||o.push(String(g)),o},[]).join(", ")}function m(i){return i&&(e.name==="browser"||e.name==="worker")&&zt()}function N(i){return i.replace(vt,"")}function T(i,o){if(o==null)return{text:"",styles:[]};const{template:l,placeholders:g}=tt(i,o),p=[],d=[];let b=0;const w=/{{(.+?)}}/g;let O;for(;(O=w.exec(l))!=null;){O.index>b&&p.push(l.slice(b,O.index));const S=O[1],k=g[S]!=null?String(g[S]):"",E=B(i.prettyLogStyles?.[S],k),L=ft(E);L.length>0?(p.push(`%c${k}%c`),d.push(L,"")):p.push(k),b=w.lastIndex}return b<l.length&&p.push(l.slice(b)),{text:p.join(""),styles:d}}function B(i,o){if(i==null)return[];if(typeof i=="string")return[i];if(Array.isArray(i))return i.flatMap(l=>B(l,o));if(typeof i=="object"){const l=o.trim(),g=i[l]??i["*"];return g==null?[]:B(g,o)}return[]}function ft(i){const o=new Set,l=[];for(const g of i){const p=ut(g);p!=null&&p.length>0&&!o.has(p)&&(o.add(p),l.push(p))}return l.join("; ")}function ut(i){const o=Kt[i];if(o!=null)return`color: ${o}`;const l=Vt[i];if(l!=null)return`background-color: ${l}`;switch(i){case"bold":return"font-weight: bold";case"dim":return"opacity: 0.75";case"italic":return"font-style: italic";case"underline":return"text-decoration: underline";case"overline":return"text-decoration: overline";case"inverse":return"filter: invert(1)";case"hidden":return"visibility: hidden";case"strikethrough":return"text-decoration: line-through";default:return}}function ht(){return s===void 0&&(s=Wt()??null),s??void 0}function gt(){return e.name==="node"||e.name==="deno"||e.name==="bun"}function pt(){return e.name==="node"||e.name==="deno"||e.name==="bun"}function dt(i){if(i.name==="browser"||i.name==="worker")return{runtime:i.name,browser:i.userAgent};const o={runtime:i.name};return pt()&&(o.runtimeVersion=i.version??"unknown"),gt()&&(o.hostname=i.hostname??"unknown"),o}function Z(i,o){try{return xt(i,...o)}catch{return o.map(mt).join(" ")}}function mt(i){if(typeof i=="string")return i;try{return JSON.stringify(i)}catch{return String(i)}}function yt(i){if(typeof i!="string"||i.length===0)return i;const o=i.replace(/\\+/g,"\\").replace(/\\/g,"/"),l=o.startsWith("//"),g=o.startsWith("/")&&!l,p=o.match(/^[A-Za-z]:/),d=p?p[0]:"",w=(d?o.slice(d.length):o).split("/"),O=[];for(const k of w)if(!(k===""||k===".")){if(k===".."){O.length>0&&O.pop();continue}O.push(k)}let S=O.join("/");return l?S=`//${S}`:g?S=`/${S}`:d!==""&&(S=`${d}${S.length>0?`/${S}`:""}`),S.length===0?i:S}function bt(){if(ct())return{name:"browser",userAgent:globalThis.navigator?.userAgent};const i=globalThis;if(typeof i.importScripts=="function")return{name:"worker",userAgent:i.navigator?.userAgent};const o=globalThis;if(o.Bun!=null){const l=o.Bun.version;return{name:"bun",version:l!=null?`bun/${l}`:void 0,hostname:F(o.process,o.Deno,o.Bun,o.location)}}if(o.Deno!=null){const l=wt(o.Deno),g=o.Deno?.version?.deno;return{name:"deno",version:g!=null?`deno/${g}`:void 0,hostname:l??F(o.process,o.Deno,o.Bun,o.location)}}return o.process?.versions?.node!=null||o.process?.version!=null?{name:"node",version:o.process?.versions?.node??o.process?.version,hostname:F(o.process,o.Deno,o.Bun,o.location)}:o.process!=null?{name:"node",version:"unknown",hostname:F(o.process,o.Deno,o.Bun,o.location)}:{name:"unknown"}}function F(i,o,l,g){const p=i?.env?.HOSTNAME??i?.env?.HOST??i?.env?.COMPUTERNAME;if(p!=null&&p.length>0)return p;const d=l?.env?.HOSTNAME??l?.env?.HOST??l?.env?.COMPUTERNAME;if(d!=null&&d.length>0)return d;try{const b=o?.env?.get;if(typeof b=="function"){const w=b("HOSTNAME");if(w!=null&&w.length>0)return w}}catch{}if(g?.hostname!=null&&g.hostname.length>0)return g.hostname}function wt(i){try{if(typeof i?.hostname=="function"){const l=i.hostname();if(l!=null&&l.length>0)return l}}catch{}const o=globalThis.location?.hostname;if(o!=null&&o.length>0)return o}function Ot(){return globalThis?.process?.env?.NODE_ENV}function St(i){if(i instanceof Error)return!0;if(i!=null&&typeof i=="object"){const o=Object.prototype.toString.call(i);if(/\[object .*Error\]/.test(o))return!0;const l=i.name;if(typeof l=="string"&&l.endsWith("Error"))return!0}return!1}}const vt=/\u001b\[[0-9;]*m/g,Kt={black:"#000000",red:"#ef5350",green:"#66bb6a",yellow:"#fdd835",blue:"#42a5f5",magenta:"#ab47bc",cyan:"#26c6da",white:"#fafafa",blackBright:"#424242",redBright:"#ff7043",greenBright:"#81c784",yellowBright:"#ffe082",blueBright:"#64b5f6",magentaBright:"#ce93d8",cyanBright:"#4dd0e1",whiteBright:"#ffffff"},Vt={bgBlack:"#000000",bgRed:"#ef5350",bgGreen:"#66bb6a",bgYellow:"#fdd835",bgBlue:"#42a5f5",bgMagenta:"#ab47bc",bgCyan:"#26c6da",bgWhite:"#fafafa",bgBlackBright:"#424242",bgRedBright:"#ff7043",bgGreenBright:"#81c784",bgYellowBright:"#ffe082",bgBlueBright:"#64b5f6",bgMagentaBright:"#ce93d8",bgCyanBright:"#4dd0e1",bgWhiteBright:"#ffffff"},Ut=/(?:(?:file|https?|global code|[^@]+)@)?(?:file:)?((?:\/[^:/]+){2,})(?::(\d+))?(?::(\d+))?/,C=Rt();class Ht{constructor(t,r,n=Number.NaN){this.logObj=r,this.stackDepthLevel=n,this.runtime=C,this.maxErrorCauseDepth=5,this.settings={type:t?.type??"pretty",name:t?.name,parentNames:t?.parentNames,minLevel:t?.minLevel??0,argumentsArrayName:t?.argumentsArrayName,hideLogPositionForProduction:t?.hideLogPositionForProduction??!1,prettyLogTemplate:t?.prettyLogTemplate??"{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}}	{{logLevelName}}	{{filePathWithLine}}{{nameWithDelimiterPrefix}}	",prettyErrorTemplate:t?.prettyErrorTemplate??`
{{errorName}} {{errorMessage}}
error stack:
{{errorStack}}`,prettyErrorStackTemplate:t?.prettyErrorStackTemplate??`  • {{fileName}}	{{method}}
	{{filePathWithLine}}`,prettyErrorParentNamesSeparator:t?.prettyErrorParentNamesSeparator??":",prettyErrorLoggerNameDelimiter:t?.prettyErrorLoggerNameDelimiter??"	",stylePrettyLogs:t?.stylePrettyLogs??!0,prettyLogTimeZone:t?.prettyLogTimeZone??"UTC",prettyLogStyles:t?.prettyLogStyles??{logLevelName:{"*":["bold","black","bgWhiteBright","dim"],SILLY:["bold","white"],TRACE:["bold","whiteBright"],DEBUG:["bold","green"],INFO:["bold","blue"],WARN:["bold","yellow"],ERROR:["bold","red"],FATAL:["bold","redBright"]},dateIsoStr:"white",filePathWithLine:"white",name:["white","bold"],nameWithDelimiterPrefix:["white","bold"],nameWithDelimiterSuffix:["white","bold"],errorName:["bold","bgRedBright","whiteBright"],fileName:["yellow"],fileNameWithLine:"white"},prettyInspectOptions:t?.prettyInspectOptions??{colors:!0,compact:!1,depth:1/0},metaProperty:t?.metaProperty??"_meta",maskPlaceholder:t?.maskPlaceholder??"[***]",maskValuesOfKeys:t?.maskValuesOfKeys??["password"],maskValuesOfKeysCaseInsensitive:t?.maskValuesOfKeysCaseInsensitive??!1,maskValuesRegEx:t?.maskValuesRegEx,prefix:[...t?.prefix??[]],attachedTransports:[...t?.attachedTransports??[]],overwrite:{mask:t?.overwrite?.mask,toLogObj:t?.overwrite?.toLogObj,addMeta:t?.overwrite?.addMeta,addPlaceholders:t?.overwrite?.addPlaceholders,formatMeta:t?.overwrite?.formatMeta,formatLogObj:t?.overwrite?.formatLogObj,transportFormatted:t?.overwrite?.transportFormatted,transportJSON:t?.overwrite?.transportJSON}},this.captureStackForMeta=this._shouldCaptureStack()}log(t,r,...n){if(t<this.settings.minLevel)return;const s=this._resolveLogArguments(n),c=[...this.settings.prefix,...s],a=this.settings.overwrite?.mask!=null?this.settings.overwrite?.mask(c):this.settings.maskValuesOfKeys!=null&&this.settings.maskValuesOfKeys.length>0?this._mask(c):c,f=this.logObj!=null?this._recursiveCloneAndExecuteFunctions(this.logObj):void 0,h=this.settings.overwrite?.toLogObj!=null?this.settings.overwrite?.toLogObj(a,f):this._toLogObj(a,f),u=this.settings.overwrite?.addMeta!=null?this.settings.overwrite?.addMeta(h,t,r):this._addMetaToLogObj(h,t,r),y=u?.[this.settings.metaProperty];let m,N;if(this.settings.overwrite?.formatMeta!=null&&(m=this.settings.overwrite?.formatMeta(u?.[this.settings.metaProperty])),this.settings.overwrite?.formatLogObj!=null&&(N=this.settings.overwrite?.formatLogObj(a,this.settings)),this.settings.type==="pretty"&&(m=m??this._prettyFormatLogObjMeta(u?.[this.settings.metaProperty]),N=N??C.prettyFormatLogObj(a,this.settings)),m!=null&&N!=null)if(this.settings.overwrite?.transportFormatted!=null){const T=this.settings.overwrite.transportFormatted,B=T.length;B<4?T(m,N.args,N.errors):B===4?T(m,N.args,N.errors,y):T(m,N.args,N.errors,y,this.settings)}else C.transportFormatted(m,N.args,N.errors,y,this.settings);else this.settings.overwrite?.transportJSON!=null?this.settings.overwrite.transportJSON(u):this.settings.type!=="hidden"&&C.transportJSON(u);return this.settings.attachedTransports!=null&&this.settings.attachedTransports.length>0&&this.settings.attachedTransports.forEach(T=>{T(u)}),u}attachTransport(t){this.settings.attachedTransports.push(t)}getSubLogger(t,r){const n={...this.settings,...t,parentNames:this.settings?.parentNames!=null&&this.settings?.name!=null?[...this.settings.parentNames,this.settings.name]:this.settings?.name!=null?[this.settings.name]:void 0,prefix:[...this.settings.prefix,...t?.prefix??[]]};return new this.constructor(n,r??this.logObj,this.stackDepthLevel)}_mask(t){const r=this._getMaskKeys();return t?.map(n=>this._recursiveCloneAndMaskValuesOfKeys(n,r))}_getMaskKeys(){const t=this.settings.maskValuesOfKeys??[],r=t.map(String).join("|");if(this.settings.maskValuesOfKeysCaseInsensitive===!0){if(this.maskKeysCache?.source===t&&this.maskKeysCache.caseInsensitive===!0&&this.maskKeysCache.signature===r)return this.maskKeysCache.normalized;const n=t.map(s=>typeof s=="string"?s.toLowerCase():String(s).toLowerCase());return this.maskKeysCache={source:t,caseInsensitive:!0,normalized:n,signature:r},n}return this.maskKeysCache={source:t,caseInsensitive:!1,normalized:t,signature:r},t}_resolveLogArguments(t){if(t.length===1&&typeof t[0]=="function"){const r=t[0];if(r.length===0){const n=r();return Array.isArray(n)?n:[n]}}return t}_recursiveCloneAndMaskValuesOfKeys(t,r,n=[]){if(n.includes(t))return{...t};if(typeof t=="object"&&t!==null&&n.push(t),C.isError(t)||C.isBuffer(t))return t;if(t instanceof Map)return new Map(t);if(t instanceof Set)return new Set(t);if(Array.isArray(t))return t.map(s=>this._recursiveCloneAndMaskValuesOfKeys(s,r,n));if(t instanceof Date)return new Date(t.getTime());if(t instanceof URL)return Lt(t);if(t!==null&&typeof t=="object"){const s=C.isError(t)?this._cloneError(t):Object.create(Object.getPrototypeOf(t));return Object.getOwnPropertyNames(t).reduce((c,a)=>{const f=this.settings?.maskValuesOfKeysCaseInsensitive!==!0?a:typeof a=="string"?a.toLowerCase():String(a).toLowerCase();return c[a]=r.includes(f)?this.settings.maskPlaceholder:(()=>{try{return this._recursiveCloneAndMaskValuesOfKeys(t[a],r,n)}catch{return null}})(),c},s)}else{if(typeof t=="string"){let s=t;for(const c of this.settings?.maskValuesRegEx||[])s=s.replace(c,this.settings?.maskPlaceholder||"");return s}return t}}_recursiveCloneAndExecuteFunctions(t,r=[]){return this.isObjectOrArray(t)&&r.includes(t)?this.shallowCopy(t):(this.isObjectOrArray(t)&&r.push(t),Array.isArray(t)?t.map(n=>this._recursiveCloneAndExecuteFunctions(n,r)):t instanceof Date?new Date(t.getTime()):this.isObject(t)?Object.getOwnPropertyNames(t).reduce((n,s)=>{const c=Object.getOwnPropertyDescriptor(t,s);if(c){Object.defineProperty(n,s,c);const a=t[s];n[s]=typeof a=="function"?a():this._recursiveCloneAndExecuteFunctions(a,r)}return n},Object.create(Object.getPrototypeOf(t))):t)}isObjectOrArray(t){return typeof t=="object"&&t!==null}isObject(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}shallowCopy(t){return Array.isArray(t)?[...t]:{...t}}_toLogObj(t,r={}){return t=t?.map(n=>C.isError(n)?this._toErrorObject(n):n),this.settings.argumentsArrayName==null?t.length===1&&!Array.isArray(t[0])&&C.isBuffer(t[0])!==!0&&!(t[0]instanceof Date)?r=typeof t[0]=="object"&&t[0]!=null?{...t[0],...r}:{0:t[0],...r}:r={...r,...t}:r={...r,[this.settings.argumentsArrayName]:t},r}_cloneError(t){const r=new t.constructor;return Object.getOwnPropertyNames(t).forEach(n=>{r[n]=t[n]}),r}_toErrorObject(t,r=0,n=new Set){n.has(t)||n.add(t);const s={nativeError:t,name:t.name??"Error",message:t.message,stack:C.getErrorTrace(t)};if(r>=this.maxErrorCauseDepth)return s;const c=t.cause;if(c!=null){const a=rt(c);n.has(a)||(s.cause=this._toErrorObject(a,r+1,n))}return s}_addMetaToLogObj(t,r,n){return{...t,[this.settings.metaProperty]:C.getMeta(r,n,this.stackDepthLevel,!this.captureStackForMeta,this.settings.name,this.settings.parentNames)}}_shouldCaptureStack(){if(this.settings.hideLogPositionForProduction)return!1;if(this.settings.type==="json")return!0;const t=this.settings.prettyLogTemplate??"";return!!/{{\s*(file(Name|Path|Line|PathWithLine|NameWithLine)|fullFilePath)\s*}}/.test(t)}_prettyFormatLogObjMeta(t){return tt(this.settings,t).text}}class Gt extends Ht{constructor(t,r){const n=typeof window<"u"&&typeof document<"u",s={...t??{}};n&&(s.stylePrettyLogs=t?.stylePrettyLogs??!0),super(s,r,Number.NaN)}log(t,r,...n){return super.log(t,r,...n)}silly(...t){return super.log(0,"SILLY",...t)}trace(...t){return super.log(1,"TRACE",...t)}debug(...t){return super.log(2,"DEBUG",...t)}info(...t){return super.log(3,"INFO",...t)}warn(...t){return super.log(4,"WARN",...t)}error(...t){return super.log(5,"ERROR",...t)}fatal(...t){return super.log(6,"FATAL",...t)}getSubLogger(t,r){return super.getSubLogger(t,r)}}export{Gt as L};
