@visulima/pail 4.1.0 → 5.0.0

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.
Files changed (69) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/LICENSE.md +5 -811
  3. package/dist/error.js +3 -3
  4. package/dist/index.browser.d.ts +2 -4
  5. package/dist/index.browser.js +19 -19
  6. package/dist/index.server.d.ts +2 -3
  7. package/dist/index.server.js +27 -28
  8. package/dist/middleware/elysia.js +1 -1
  9. package/dist/middleware/express.js +1 -1
  10. package/dist/middleware/fastify.js +1 -1
  11. package/dist/middleware/hono.js +1 -1
  12. package/dist/middleware/next/handler.d.ts +0 -1
  13. package/dist/middleware/next/handler.js +1 -1
  14. package/dist/middleware/sveltekit.js +1 -1
  15. package/dist/object-tree.js +2 -2
  16. package/dist/packem_shared/AbstractJsonReporter-DPsVS6w5.js +1 -0
  17. package/dist/packem_shared/AbstractJsonReporter-elZG6xkO.js +1 -0
  18. package/dist/packem_shared/JsonReporter-CY90KVxK.js +2 -0
  19. package/dist/packem_shared/JsonReporter-DX9fJfwQ.js +1 -0
  20. package/dist/packem_shared/{PailError-CbU1Ogfa.js → PailError-BgUh0gyX.js} +3 -3
  21. package/dist/packem_shared/PrettyReporter-B3yHM4Cb.js +47 -0
  22. package/dist/packem_shared/PrettyReporter-ClyBiPyQ.js +5 -0
  23. package/dist/packem_shared/abstract-pretty-reporter-C1W1vIw-.js +36 -0
  24. package/dist/packem_shared/headers-BjUW0cAm.js +1 -0
  25. package/dist/packem_shared/{index-CbkPnylC.js → index-pjyHJq0E.js} +1 -1
  26. package/dist/packem_shared/pailMiddleware-lhLj-hzE.js +1 -0
  27. package/dist/packem_shared/serializeError-Kr3JL9UN-zwOuO-gY.js +1 -0
  28. package/dist/packem_shared/storage-DP9QMOmG.js +1 -0
  29. package/dist/packem_shared/{types.d-DGHeA2iJ.d.ts → types.d-DNoig6eq.d.ts} +37 -3
  30. package/dist/packem_shared/{types.d-BW8kAXUv.d.ts → types.d-OiMbrp8C.d.ts} +37 -2
  31. package/dist/packem_shared/{useLogger-7p55yvvc.js → useLogger-HtOIBW7n.js} +1 -1
  32. package/dist/packem_shared/write-console-log-based-on-level-CG0mniaO.js +1 -0
  33. package/dist/packem_shared/write-stream-D2XwCKdN.js +1 -0
  34. package/dist/processor/caller/caller-processor.js +1 -1
  35. package/dist/processor/environment-processor.js +1 -1
  36. package/dist/processor/message-formatter-processor.js +1 -1
  37. package/dist/processor/opentelemetry-processor.js +1 -1
  38. package/dist/processor/redact-processor.d.ts +58 -0
  39. package/dist/processor/redact-processor.js +1 -1
  40. package/dist/processor/sampling-processor.js +1 -1
  41. package/dist/reporter/file/json-file-reporter.js +2 -2
  42. package/dist/reporter/http/abstract-http-reporter.js +2 -2
  43. package/dist/reporter/http/http-reporter.edge-light.d.ts +0 -2
  44. package/dist/reporter/http/http-reporter.edge-light.js +2 -2
  45. package/dist/reporter/http/http-reporter.js +1 -1
  46. package/dist/reporter/json/index.browser.d.ts +1 -3
  47. package/dist/reporter/json/index.browser.js +1 -1
  48. package/dist/reporter/json/index.js +1 -1
  49. package/dist/reporter/pretty/index.browser.d.ts +1 -3
  50. package/dist/reporter/pretty/index.browser.js +1 -1
  51. package/dist/reporter/pretty/index.d.ts +41 -5
  52. package/dist/reporter/pretty/index.js +1 -1
  53. package/dist/reporter/simple/simple-reporter.server.d.ts +40 -5
  54. package/dist/reporter/simple/simple-reporter.server.js +7 -7
  55. package/dist/wide-event.js +1 -1
  56. package/package.json +3 -3
  57. package/dist/packem_shared/AbstractJsonReporter-BpWRnN0L.js +0 -1
  58. package/dist/packem_shared/AbstractJsonReporter-DxZwImm5.js +0 -1
  59. package/dist/packem_shared/JsonReporter-9IcELa1m.js +0 -2
  60. package/dist/packem_shared/JsonReporter-Dd3kuj8X.js +0 -1
  61. package/dist/packem_shared/PrettyReporter-BUWNEg3_.js +0 -5
  62. package/dist/packem_shared/PrettyReporter-DbgD89ck.js +0 -70
  63. package/dist/packem_shared/abstract-pretty-reporter-CyfTvmKf.js +0 -59
  64. package/dist/packem_shared/headers-DI58djdG.js +0 -1
  65. package/dist/packem_shared/pailMiddleware-B5DJoBYl.js +0 -1
  66. package/dist/packem_shared/serializeError-52C4oiKx-CrnRcq9R.js +0 -1
  67. package/dist/packem_shared/storage-DVcJumyk.js +0 -1
  68. package/dist/packem_shared/write-console-log-based-on-level-BqjxV016.js +0 -1
  69. package/dist/packem_shared/write-stream-ytl_vhg_.js +0 -1
package/dist/error.js CHANGED
@@ -1,5 +1,5 @@
1
- class e extends Error{status;why;fix;link;constructor(s){const t=typeof s=="string"?{message:s}:s;super(t.message,t.cause===void 0?void 0:{cause:t.cause}),this.name="PailError",this.status=t.status??500,this.why=t.why,this.fix=t.fix,this.link=t.link}toJSON(){const s={message:this.message,name:this.name,status:this.status};return this.why&&(s.why=this.why),this.fix&&(s.fix=this.fix),this.link&&(s.link=this.link),this.stack&&(s.stack=this.stack),this.cause!==void 0&&(s.cause=this.cause instanceof Error?{message:this.cause.message,name:this.cause.name,stack:this.cause.stack}:this.cause),s}toString(){let s=`${this.name} [${String(this.status)}]: ${this.message}`;if(this.why&&(s+=`
1
+ class e extends Error{status;why;fix;link;constructor(s){const i=typeof s=="string"?{message:s}:s;super(i.message,i.cause===void 0?void 0:{cause:i.cause}),this.name="PailError",this.status=i.status??500,this.why=i.why,this.fix=i.fix,this.link=i.link}toJSON(){const s={message:this.message,name:this.name,status:this.status};return this.why&&(s.why=this.why),this.fix&&(s.fix=this.fix),this.link&&(s.link=this.link),this.stack&&(s.stack=this.stack),this.cause!==void 0&&(s.cause=this.cause instanceof Error?{message:this.cause.message,name:this.cause.name,stack:this.cause.stack}:this.cause),s}toString(){let s=`${this.name} [${String(this.status)}]: ${this.message}`;if(this.why&&(s+=`
2
2
  Why: ${this.why}`),this.fix&&(s+=`
3
3
  Fix: ${this.fix}`),this.link&&(s+=`
4
- Link: ${this.link}`),this.cause!==void 0){const t=this.cause instanceof Error?this.cause.message:String(this.cause);s+=`
5
- Cause: ${t}`}return s}}const a=i=>new e(i);export{e as PailError,a as createPailError};
4
+ Link: ${this.link}`),this.cause!==void 0){const i=this.cause instanceof Error?this.cause.message:String(this.cause);s+=`
5
+ Cause: ${i}`}return s}}const a=t=>new e(t);export{e as PailError,a as createPailError};
@@ -1,9 +1,7 @@
1
1
  import { s as stringify } from "./packem_shared/index.d-T71KjNAr.js";
2
- import { LiteralUnion } from 'type-fest';
3
- import { C as ConstructorOptions, M as Meta, D as DefaultLogTypes, L as LoggerTypesConfig, P as Processor, E as ExtendedRfc5424LogLevels, b as Reporter, c as LoggerFunction } from "./packem_shared/types.d-DGHeA2iJ.js";
4
- export type { d as DefaultLoggerTypes, e as LoggerConfiguration, a as LoggerTypesAwareReporter, f as StreamAwareReporter } from "./packem_shared/types.d-DGHeA2iJ.js";
2
+ import { C as ConstructorOptions, M as Meta, D as DefaultLogTypes, L as LiteralUnion, a as LoggerTypesConfig, P as Processor, E as ExtendedRfc5424LogLevels, c as Reporter, d as LoggerFunction } from "./packem_shared/types.d-DNoig6eq.js";
3
+ export type { e as DefaultLoggerTypes, f as LoggerConfiguration, b as LoggerTypesAwareReporter, g as StreamAwareReporter } from "./packem_shared/types.d-DNoig6eq.js";
5
4
  import '@visulima/colorize';
6
- import '@visulima/interactive-manager';
7
5
  /**
8
6
  * Pail Browser Implementation.
9
7
  *
@@ -1,19 +1,19 @@
1
- import{a as se,E as re,L as ie}from"./packem_shared/constants-DKfCaSUR.js";import{t as oe}from"./packem_shared/write-console-log-based-on-level-BqjxV016.js";import{g as X,O as ne}from"./packem_shared/index-CbkPnylC.js";import le from"./packem_shared/JsonReporter-Dd3kuj8X.js";import{PailError as Oe,createPailError as Te}from"./packem_shared/PailError-CbU1Ogfa.js";var Y={exports:{}},H;function ae(){return H||(H=1,(function(x,e){const{hasOwnProperty:s}=Object.prototype,r=U();r.configure=U,r.stringify=r,r.default=r,e.stringify=r,e.configure=U,x.exports=r;const a=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;function m(i){return i.length<5e3&&!a.test(i)?`"${i}"`:JSON.stringify(i)}function L(i,o){if(i.length>200||o)return i.sort(o);for(let u=1;u<i.length;u++){const N=i[u];let E=u;for(;E!==0&&i[E-1]>N;)i[E]=i[E-1],E--;i[E]=N}return i}const c=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function $(i){return c.call(i)!==void 0&&i.length!==0}function O(i,o,u){i.length<u&&(u=i.length);const N=o===","?"":" ";let E=`"0":${N}${i[0]}`;for(let C=1;C<u;C++)E+=`${o}"${C}":${N}${i[C]}`;return E}function k(i){if(s.call(i,"circularValue")){const o=i.circularValue;if(typeof o=="string")return`"${o}"`;if(o==null)return o;if(o===Error||o===TypeError)return{toString(){throw new TypeError("Converting circular structure to JSON")}};throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return'"[Circular]"'}function A(i){let o;if(s.call(i,"deterministic")&&(o=i.deterministic,typeof o!="boolean"&&typeof o!="function"))throw new TypeError('The "deterministic" argument must be of type boolean or comparator function');return o===void 0?!0:o}function F(i,o){let u;if(s.call(i,o)&&(u=i[o],typeof u!="boolean"))throw new TypeError(`The "${o}" argument must be of type boolean`);return u===void 0?!0:u}function D(i,o){let u;if(s.call(i,o)){if(u=i[o],typeof u!="number")throw new TypeError(`The "${o}" argument must be of type number`);if(!Number.isInteger(u))throw new TypeError(`The "${o}" argument must be an integer`);if(u<1)throw new RangeError(`The "${o}" argument must be >= 1`)}return u===void 0?1/0:u}function R(i){return i===1?"1 item":`${i} items`}function z(i){const o=new Set;for(const u of i)(typeof u=="string"||typeof u=="number")&&o.add(String(u));return o}function ee(i){if(s.call(i,"strict")){const o=i.strict;if(typeof o!="boolean")throw new TypeError('The "strict" argument must be of type boolean');if(o)return u=>{let N=`Object can not safely be stringified. Received type ${typeof u}`;throw typeof u!="function"&&(N+=` (${u.toString()})`),new Error(N)}}}function U(i){i={...i};const o=ee(i);o&&(i.bigint===void 0&&(i.bigint=!1),"circularValue"in i||(i.circularValue=Error));const u=k(i),N=F(i,"bigint"),E=A(i),C=typeof E=="function"?E:void 0,V=D(i,"maximumDepth"),b=D(i,"maximumBreadth");function q(T,t,n,f,h,p){let l=t[T];switch(typeof l=="object"&&l!==null&&typeof l.toJSON=="function"&&(l=l.toJSON(T)),l=f.call(t,T,l),typeof l){case"string":return m(l);case"object":{if(l===null)return"null";if(n.indexOf(l)!==-1)return u;let g="",v=",";const w=p;if(Array.isArray(l)){if(l.length===0)return"[]";if(V<n.length+1)return'"[Array]"';n.push(l),h!==""&&(p+=h,g+=`
2
- ${p}`,v=`,
3
- ${p}`);const j=Math.min(l.length,b);let P=0;for(;P<j-1;P++){const G=q(String(P),l,n,f,h,p);g+=G!==void 0?G:"null",g+=v}const _=q(String(P),l,n,f,h,p);if(g+=_!==void 0?_:"null",l.length-1>b){const G=l.length-b-1;g+=`${v}"... ${R(G)} not stringified"`}return h!==""&&(g+=`
4
- ${w}`),n.pop(),`[${g}]`}let y=Object.keys(l);const S=y.length;if(S===0)return"{}";if(V<n.length+1)return'"[Object]"';let d="",M="";h!==""&&(p+=h,v=`,
5
- ${p}`,d=" ");const J=Math.min(S,b);E&&!$(l)&&(y=L(y,C)),n.push(l);for(let j=0;j<J;j++){const P=y[j],_=q(P,l,n,f,h,p);_!==void 0&&(g+=`${M}${m(P)}:${d}${_}`,M=v)}if(S>b){const j=S-b;g+=`${M}"...":${d}"${R(j)} not stringified"`,M=v}return h!==""&&M.length>1&&(g=`
6
- ${p}${g}
7
- ${w}`),n.pop(),`{${g}}`}case"number":return isFinite(l)?String(l):o?o(l):"null";case"boolean":return l===!0?"true":"false";case"undefined":return;case"bigint":if(N)return String(l);default:return o?o(l):void 0}}function Q(T,t,n,f,h,p){switch(typeof t=="object"&&t!==null&&typeof t.toJSON=="function"&&(t=t.toJSON(T)),typeof t){case"string":return m(t);case"object":{if(t===null)return"null";if(n.indexOf(t)!==-1)return u;const l=p;let g="",v=",";if(Array.isArray(t)){if(t.length===0)return"[]";if(V<n.length+1)return'"[Array]"';n.push(t),h!==""&&(p+=h,g+=`
8
- ${p}`,v=`,
9
- ${p}`);const S=Math.min(t.length,b);let d=0;for(;d<S-1;d++){const J=Q(String(d),t[d],n,f,h,p);g+=J!==void 0?J:"null",g+=v}const M=Q(String(d),t[d],n,f,h,p);if(g+=M!==void 0?M:"null",t.length-1>b){const J=t.length-b-1;g+=`${v}"... ${R(J)} not stringified"`}return h!==""&&(g+=`
10
- ${l}`),n.pop(),`[${g}]`}n.push(t);let w="";h!==""&&(p+=h,v=`,
11
- ${p}`,w=" ");let y="";for(const S of f){const d=Q(S,t[S],n,f,h,p);d!==void 0&&(g+=`${y}${m(S)}:${w}${d}`,y=v)}return h!==""&&y.length>1&&(g=`
12
- ${p}${g}
13
- ${l}`),n.pop(),`{${g}}`}case"number":return isFinite(t)?String(t):o?o(t):"null";case"boolean":return t===!0?"true":"false";case"undefined":return;case"bigint":if(N)return String(t);default:return o?o(t):void 0}}function I(T,t,n,f,h){switch(typeof t){case"string":return m(t);case"object":{if(t===null)return"null";if(typeof t.toJSON=="function"){if(t=t.toJSON(T),typeof t!="object")return I(T,t,n,f,h);if(t===null)return"null"}if(n.indexOf(t)!==-1)return u;const p=h;if(Array.isArray(t)){if(t.length===0)return"[]";if(V<n.length+1)return'"[Array]"';n.push(t),h+=f;let d=`
14
- ${h}`;const M=`,
15
- ${h}`,J=Math.min(t.length,b);let j=0;for(;j<J-1;j++){const _=I(String(j),t[j],n,f,h);d+=_!==void 0?_:"null",d+=M}const P=I(String(j),t[j],n,f,h);if(d+=P!==void 0?P:"null",t.length-1>b){const _=t.length-b-1;d+=`${M}"... ${R(_)} not stringified"`}return d+=`
16
- ${p}`,n.pop(),`[${d}]`}let l=Object.keys(t);const g=l.length;if(g===0)return"{}";if(V<n.length+1)return'"[Object]"';h+=f;const v=`,
17
- ${h}`;let w="",y="",S=Math.min(g,b);$(t)&&(w+=O(t,v,b),l=l.slice(t.length),S-=t.length,y=v),E&&(l=L(l,C)),n.push(t);for(let d=0;d<S;d++){const M=l[d],J=I(M,t[M],n,f,h);J!==void 0&&(w+=`${y}${m(M)}: ${J}`,y=v)}if(g>b){const d=g-b;w+=`${y}"...": "${R(d)} not stringified"`,y=v}return y!==""&&(w=`
18
- ${h}${w}
19
- ${p}`),n.pop(),`{${w}}`}case"number":return isFinite(t)?String(t):o?o(t):"null";case"boolean":return t===!0?"true":"false";case"undefined":return;case"bigint":if(N)return String(t);default:return o?o(t):void 0}}function B(T,t,n){switch(typeof t){case"string":return m(t);case"object":{if(t===null)return"null";if(typeof t.toJSON=="function"){if(t=t.toJSON(T),typeof t!="object")return B(T,t,n);if(t===null)return"null"}if(n.indexOf(t)!==-1)return u;let f="";const h=t.length!==void 0;if(h&&Array.isArray(t)){if(t.length===0)return"[]";if(V<n.length+1)return'"[Array]"';n.push(t);const w=Math.min(t.length,b);let y=0;for(;y<w-1;y++){const d=B(String(y),t[y],n);f+=d!==void 0?d:"null",f+=","}const S=B(String(y),t[y],n);if(f+=S!==void 0?S:"null",t.length-1>b){const d=t.length-b-1;f+=`,"... ${R(d)} not stringified"`}return n.pop(),`[${f}]`}let p=Object.keys(t);const l=p.length;if(l===0)return"{}";if(V<n.length+1)return'"[Object]"';let g="",v=Math.min(l,b);h&&$(t)&&(f+=O(t,",",b),p=p.slice(t.length),v-=t.length,g=","),E&&(p=L(p,C)),n.push(t);for(let w=0;w<v;w++){const y=p[w],S=B(y,t[y],n);S!==void 0&&(f+=`${g}${m(y)}:${S}`,g=",")}if(l>b){const w=l-b;f+=`${g}"...":"${R(w)} not stringified"`}return n.pop(),`{${f}}`}case"number":return isFinite(t)?String(t):o?o(t):"null";case"boolean":return t===!0?"true":"false";case"undefined":return;case"bigint":if(N)return String(t);default:return o?o(t):void 0}}function te(T,t,n){if(arguments.length>1){let f="";if(typeof n=="number"?f=" ".repeat(Math.min(n,10)):typeof n=="string"&&(f=n.slice(0,10)),t!=null){if(typeof t=="function")return q("",{"":T},[],t,f,"");if(Array.isArray(t))return Q("",T,[],z(t),f,"")}if(f.length!==0)return I("",T,[],f,"")}return B("",T,[])}return te}})(Y,Y.exports)),Y.exports}var ce=ae();class he{#t=new Map;#e;constructor(e){this.#e=e}count(e="default"){const s=this.#t.get(e)??0;this.#t.set(e,s+1),this.#e("log",!1,!1,{message:`${e}: ${String(s+1)}`,prefix:e})}countReset(e="default"){this.#t.has(e)?this.#t.delete(e):this.#e("warn",!1,!1,{message:`Count for ${e} does not exist`,prefix:e})}}class ge{log(e){const{context:s=[],message:r,type:a}=e;oe(a.level)(r,...s)}}class ue{#t=new Map;#e=new Set;#s;#i;#r;constructor(e,s,r){this.#r=e,this.#s=s,this.#i=r}time(e="default"){this.#e.has(e)?this.#r("warn",!1,!1,{message:`Timer '${e}' already exists`,prefix:e}):(this.#e.add(e),this.#t.set(e,Date.now()),this.#r("start",!1,!1,{message:this.#s,prefix:e}))}timeLog(e,...s){if(!e&&this.#e.size>0&&(e=[...this.#e].pop()),e&&this.#t.has(e)){const r=Date.now()-this.#t.get(e);this.#r("info",!1,!1,{context:s,message:r<1e3?`${String(r)} ms`:`${(r/1e3).toFixed(2)} s`,prefix:e})}else this.#r("warn",!1,!1,{context:s,message:"Timer not found",prefix:e})}timeEnd(e){if(!e&&this.#e.size>0&&(e=[...this.#e].pop()),e&&this.#t.has(e)){const s=Date.now()-this.#t.get(e);this.#t.delete(e),this.#e.delete(e),this.#r("stop",!1,!1,{message:`${this.#i} ${s<1e3?`${String(s)} ms`:`${(s/1e3).toFixed(2)} s`}`,prefix:e})}else this.#r("warn",!1,!1,{message:"Timer not found",prefix:e})}}const K=x=>x===void 0?[]:Array.isArray(x)?x:[x],Z=(x,e)=>{const s={...x};return Object.keys(e).forEach(r=>{s[r]={...s[r],...e[r]}}),s},fe=x=>{let e=!1;return function(...s){if(!e){e=!0;try{const r=x.apply(this,s);return e=!1,r}catch(r){throw e=!1,r}}}};class W{timerManager;counterManager;lastLog;logLevels;disabled;paused;messageQueue;scopeName;types;longestLabel;processors;generalLogLevel;reporters;throttle;throttleMin;stringify;groups;startTimerMessage;endTimerMessage;rawReporter;force={};#t=new Set;#e;#s;constructor(e){this.throttle=e.throttle??1e3,this.throttleMin=e.throttleMin??5;const s=e.parentLongestLabel,r=e.parentTypes,a=e.parentStringify,m=e.parentLogLevels;this.stringify=a??ce.configure({strict:!0}),this.startTimerMessage=e.messages?.timerStart??"Initialized timer...",this.endTimerMessage=e.messages?.timerEnd??"Timer run for:",r&&s?(this.types=r,this.longestLabel=s):(this.types=Z(ie,e.types??{}),this.longestLabel=X(this.types)),this.logLevels=m&&!e.logLevels?m:{...se,...e.logLevels},this.generalLogLevel=this.#o(e.logLevel),this.reporters=new Set,this.processors=new Set,this.disabled=e.disabled??!1,this.paused=!1,this.messageQueue=[],this.scopeName=K(e.scope).filter(Boolean),this.timerManager=new ue((L,c,$,...O)=>{this.logger(L,c,$,...O)},this.startTimerMessage,this.endTimerMessage),this.counterManager=new he((L,c,$,...O)=>{this.logger(L,c,$,...O)}),this.groups=[],this.lastLog={},this.logger=fe(this.logger.bind(this)),this.#i(),Array.isArray(e.reporters)&&this.registerReporters(e.reporters),this.rawReporter=this.extendReporter(e.rawReporter??new ge),Array.isArray(e.processors)&&this.registerProcessors(e.processors)}#i(){for(const e in this.types)this[e]=this.logger.bind(this,e,!1,!1);for(const e in this.types)this.force[e]=this.logger.bind(this,e,!1,!0);this.raw=this.raw.bind(this)}wrapConsole(){for(const e in this.types)Object.hasOwn(console,`__${e}`)||(console[`__${e}`]=console[e]),console[e]=this[e]}restoreConsole(){for(const e in this.types)if(Object.hasOwn(console,`__${e}`)){const s=console[`__${e}`];s===void 0?delete console[e]:console[e]=s,delete console[`__${e}`]}}wrapException(){this.#e||this.#s||(this.#e=e=>{this.error(e)},this.#s=e=>{this.error(e)},process.on("uncaughtException",this.#e),process.on("unhandledRejection",this.#s))}restoreException(){this.#e&&(process.off("uncaughtException",this.#e),this.#e=void 0),this.#s&&(process.off("unhandledRejection",this.#s),this.#s=void 0)}disable(){this.disabled=!0}enable(){this.disabled=!1}isEnabled(){return!this.disabled}pause(){this.paused=!0}resume(){this.paused=!1;const e=this.messageQueue.splice(0);for(let s=0;s<e.length;s+=1){const{messageObject:r,raw:a,type:m}=e[s];this.logger(m,a,!1,...r)}}scope(...e){if(e.length===0)throw new Error("No scope name was defined.");return this.child({scope:e})}unscope(){this.scopeName=[]}child(e){return new W(this.buildChildOptions(e))}time(e="default"){this.timerManager.time(e)}timeLog(e,...s){this.timerManager.timeLog(e,...s)}timeEnd(e){this.timerManager.timeEnd(e)}group(e="console.group"){globalThis.window===void 0?this.groups.push(e):console.group(e)}groupEnd(){globalThis.window===void 0?this.groups.pop():console.groupEnd()}count(e="default"){this.counterManager.count(e)}countReset(e="default"){this.counterManager.countReset(e)}clear(){console.clear()}raw(e,...s){this.disabled||this.logger("log",!0,!1,{context:s,message:e})}buildChildOptions(e){const s=e?.types!==void 0,r=s?Z(this.types,e.types):this.types,a=e?.reporters??[],m=a.length>0?[...this.reporters,...a]:[...this.reporters],L=e?.processors??[],c=L.length>0?[...this.processors,...L]:[...this.processors],$=e?.logLevels?{...this.logLevels,...e.logLevels}:this.logLevels;let O;if(e?.scope){const F=K(e.scope).filter(Boolean);O=this.scopeName.length>0?[...this.scopeName,...F]:F}else O=this.scopeName.length>0?this.scopeName:[];const k=e?.messages?{timerEnd:this.endTimerMessage,timerStart:this.startTimerMessage,...e.messages}:{timerEnd:this.endTimerMessage,timerStart:this.startTimerMessage},A={disabled:e?.disabled??this.disabled,logLevel:e?.logLevel??this.generalLogLevel,logLevels:$,messages:k,processors:c,rawReporter:e?.rawReporter??this.rawReporter,reporters:m,scope:O,throttle:e?.throttle??this.throttle,throttleMin:e?.throttleMin??this.throttleMin};return s?(A.parentTypes=r,A.parentLongestLabel=X(r)):(A.parentTypes=this.types,A.parentLongestLabel=this.longestLabel),e?.logLevels||(A.parentLogLevels=this.logLevels),e?.messages||(A.parentMessages={timerEnd:this.endTimerMessage,timerStart:this.startTimerMessage}),A.parentStringify=this.stringify,A}extendReporter(e){return typeof e.setLoggerTypes=="function"&&e.setLoggerTypes(this.types),typeof e.setStringify=="function"&&e.setStringify(this.stringify),e}registerReporters(e){for(let s=0;s<e.length;s+=1)this.reporters.add(this.extendReporter(e[s]))}registerProcessors(e){for(let s=0;s<e.length;s+=1){const r=e[s];typeof r.setStringify=="function"&&r.setStringify(this.stringify),this.processors.add(r)}}#r(e,s){if(s)this.rawReporter.log(Object.freeze(e));else for(const r of this.reporters)r.log(Object.freeze(e))}#o(e){let s="debug";return e!==void 0&&Object.hasOwn(this.logLevels,e)?s=e:e!==void 0&&!this.#t.has(e)&&(this.#t.add(e),console.warn(`[pail] Unknown log level "${String(e)}". Valid levels: ${Object.keys(this.logLevels).join(", ")}. Falling back to "debug".`)),s}#n(e,s,...r){const a={badge:void 0,context:void 0,error:void 0,label:void 0,message:re,prefix:void 0,repeated:void 0,scope:void 0,suffix:void 0};if(a.type={level:s.logLevel,name:e},a.groups=this.groups,a.scope=this.scopeName,a.date=new Date,r.length>0&&r[0]instanceof Error)a.error=r[0],r.length>1&&(a.context=r.slice(1));else if(r.length>0&&typeof r[0]=="object"&&r[0]!==null&&"message"in r[0]){const{context:m,message:L,prefix:c,suffix:$}=r[0];if(m&&(a.context=m),c&&(a.prefix=c),$&&(a.suffix=$),a.message=L,r.length>1){const O=r.slice(1);a.context?a.context=Array.isArray(a.context)?[...a.context,...O]:[a.context,...O]:a.context=O}}else r.length>1?(a.message=r[0],a.context=r.slice(1)):r.length===1?a.message=r[0]:a.message=void 0;return s.logLevel==="trace"&&(a.traceError=new Error("Trace")),s.badge&&(a.badge=s.badge),s.label&&(a.label=s.label),a}logger(e,s,r,...a){if(this.disabled)return;if(this.paused){this.messageQueue.push({messageObject:a,raw:s,type:e});return}const m=this.types[e],L=this.#o(m.logLevel);if(r||this.logLevels[L]>=this.logLevels[this.generalLogLevel]){let c=this.#n(e,m,...a),$;try{$=JSON.stringify([c.label,c.scope,c.type,c.message,c.prefix,c.suffix,c.context])}catch{$=void 0}const O=this.processors.size>0,k=(D=!1)=>{const R=(this.lastLog.count??0)-this.throttleMin;if(this.lastLog.object&&R>0){const z={...this.lastLog.object};R>1&&(z.repeated=R),this.#r(z,s),this.lastLog.count=1}if(D){for(const z of this.processors)c=z.process(c);if(c.dropped===!0)return;if(this.lastLog.object=c,O)try{this.lastLog.signature=JSON.stringify([c.label,c.scope,c.type,c.message,c.prefix,c.suffix,c.context])}catch{this.lastLog.signature=void 0}else this.lastLog.signature=$;this.#r(c,s)}};clearTimeout(this.lastLog.timeout);const A=c.date instanceof Date?c.date:new Date(c.date),F=this.lastLog.time?A.getTime()-this.lastLog.time.getTime():0;if(this.lastLog.time=A,F<this.throttle)try{const D=$;if(this.lastLog.object&&D!==void 0&&D===this.lastLog.signature&&(this.lastLog.count=(this.lastLog.count??0)+1,this.lastLog.count>this.throttleMin)){this.lastLog.timeout=setTimeout(k,this.throttle);return}}catch{}k(!0)}}}const pe=W,de='"[Circular]"';class ye{#t;#e;#s;constructor(e={}){this.#e=e.formatters}setStringify(e){this.#t=e}process(e){this.#s===void 0&&(this.#s=ne({formatters:this.#e,stringify:r=>this.#i(r)}));const s=this.#s;return e.message!==void 0&&(e.message=this.#r(s,e.message,e.context??[])),e}#i(e){if(this.#t===void 0)try{return JSON.stringify(e)}catch{return de}try{return this.#t(e)}catch(s){return JSON.stringify(`[unserializable: ${s instanceof Error?s.message:String(s)}]`)}}#r(e,s,r=[]){if(typeof s=="string")return e(s,r);if(typeof s=="object"&&s!==null){const a=s,m=Object.keys(a);for(let L=0;L<m.length;L+=1){const c=m[L],$=a[c];(typeof $=="string"||Array.isArray($)||typeof $=="object")&&(a[c]=this.#r(e,$,r))}}return s}}const me=x=>new pe({processors:[new ye],reporters:[new le],...x}),Se=me();export{Oe as PailError,me as createPail,Te as createPailError,Se as pail};
1
+ import{L as re,a as se,E as ie}from"./packem_shared/constants-DKfCaSUR.js";import{w as ne}from"./packem_shared/write-console-log-based-on-level-CG0mniaO.js";import{g as X,q as oe}from"./packem_shared/index-pjyHJq0E.js";import fe from"./packem_shared/JsonReporter-DX9fJfwQ.js";import{PailError as Oe,createPailError as Me}from"./packem_shared/PailError-BgUh0gyX.js";var U={exports:{}},Z;function ge(){return Z||(Z=1,(function(T,e){const{hasOwnProperty:r}=Object.prototype,s=Y();s.configure=Y,s.stringify=s,s.default=s,e.stringify=s,e.configure=Y,T.exports=s;const g=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;function y(i){return i.length<5e3&&!g.test(i)?`"${i}"`:JSON.stringify(i)}function x(i,n){if(i.length>200||n)return i.sort(n);for(let u=1;u<i.length;u++){const N=i[u];let E=u;for(;E!==0&&i[E-1]>N;)i[E]=i[E-1],E--;i[E]=N}return i}const l=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function b(i){return l.call(i)!==void 0&&i.length!==0}function O(i,n,u){i.length<u&&(u=i.length);const N=n===","?"":" ";let E=`"0":${N}${i[0]}`;for(let V=1;V<u;V++)E+=`${n}"${V}":${N}${i[V]}`;return E}function I(i){if(r.call(i,"circularValue")){const n=i.circularValue;if(typeof n=="string")return`"${n}"`;if(n==null)return n;if(n===Error||n===TypeError)return{toString(){throw new TypeError("Converting circular structure to JSON")}};throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return'"[Circular]"'}function A(i){let n;if(r.call(i,"deterministic")&&(n=i.deterministic,typeof n!="boolean"&&typeof n!="function"))throw new TypeError('The "deterministic" argument must be of type boolean or comparator function');return n===void 0?!0:n}function z(i,n){let u;if(r.call(i,n)&&(u=i[n],typeof u!="boolean"))throw new TypeError(`The "${n}" argument must be of type boolean`);return u===void 0?!0:u}function D(i,n){let u;if(r.call(i,n)){if(u=i[n],typeof u!="number")throw new TypeError(`The "${n}" argument must be of type number`);if(!Number.isInteger(u))throw new TypeError(`The "${n}" argument must be an integer`);if(u<1)throw new RangeError(`The "${n}" argument must be >= 1`)}return u===void 0?1/0:u}function P(i){return i===1?"1 item":`${i} items`}function q(i){const n=new Set;for(const u of i)(typeof u=="string"||typeof u=="number")&&n.add(String(u));return n}function ee(i){if(r.call(i,"strict")){const n=i.strict;if(typeof n!="boolean")throw new TypeError('The "strict" argument must be of type boolean');if(n)return u=>{let N=`Object can not safely be stringified. Received type ${typeof u}`;throw typeof u!="function"&&(N+=` (${u.toString()})`),new Error(N)}}}function Y(i){i={...i};const n=ee(i);n&&(i.bigint===void 0&&(i.bigint=!1),"circularValue"in i||(i.circularValue=Error));const u=I(i),N=z(i,"bigint"),E=A(i),V=typeof E=="function"?E:void 0,F=D(i,"maximumDepth"),L=D(i,"maximumBreadth");function Q(M,t,o,a,h,p){let f=t[M];switch(typeof f=="object"&&f!==null&&typeof f.toJSON=="function"&&(f=f.toJSON(M)),f=a.call(t,M,f),typeof f){case"string":return y(f);case"object":{if(f===null)return"null";if(o.indexOf(f)!==-1)return u;let c="",S=",";const $=p;if(Array.isArray(f)){if(f.length===0)return"[]";if(F<o.length+1)return'"[Array]"';o.push(f),h!==""&&(p+=h,c+=`
2
+ ${p}`,S=`,
3
+ ${p}`);const R=Math.min(f.length,L);let v=0;for(;v<R-1;v++){const H=Q(String(v),f,o,a,h,p);c+=H!==void 0?H:"null",c+=S}const J=Q(String(v),f,o,a,h,p);if(c+=J!==void 0?J:"null",f.length-1>L){const H=f.length-L-1;c+=`${S}"... ${P(H)} not stringified"`}return h!==""&&(c+=`
4
+ ${$}`),o.pop(),`[${c}]`}let m=Object.keys(f);const w=m.length;if(w===0)return"{}";if(F<o.length+1)return'"[Object]"';let d="",j="";h!==""&&(p+=h,S=`,
5
+ ${p}`,d=" ");const C=Math.min(w,L);E&&!b(f)&&(m=x(m,V)),o.push(f);for(let R=0;R<C;R++){const v=m[R],J=Q(v,f,o,a,h,p);J!==void 0&&(c+=`${j}${y(v)}:${d}${J}`,j=S)}if(w>L){const R=w-L;c+=`${j}"...":${d}"${P(R)} not stringified"`,j=S}return h!==""&&j.length>1&&(c=`
6
+ ${p}${c}
7
+ ${$}`),o.pop(),`{${c}}`}case"number":return isFinite(f)?String(f):n?n(f):"null";case"boolean":return f===!0?"true":"false";case"undefined":return;case"bigint":if(N)return String(f);default:return n?n(f):void 0}}function G(M,t,o,a,h,p){switch(typeof t=="object"&&t!==null&&typeof t.toJSON=="function"&&(t=t.toJSON(M)),typeof t){case"string":return y(t);case"object":{if(t===null)return"null";if(o.indexOf(t)!==-1)return u;const f=p;let c="",S=",";if(Array.isArray(t)){if(t.length===0)return"[]";if(F<o.length+1)return'"[Array]"';o.push(t),h!==""&&(p+=h,c+=`
8
+ ${p}`,S=`,
9
+ ${p}`);const w=Math.min(t.length,L);let d=0;for(;d<w-1;d++){const C=G(String(d),t[d],o,a,h,p);c+=C!==void 0?C:"null",c+=S}const j=G(String(d),t[d],o,a,h,p);if(c+=j!==void 0?j:"null",t.length-1>L){const C=t.length-L-1;c+=`${S}"... ${P(C)} not stringified"`}return h!==""&&(c+=`
10
+ ${f}`),o.pop(),`[${c}]`}o.push(t);let $="";h!==""&&(p+=h,S=`,
11
+ ${p}`,$=" ");let m="";for(const w of a){const d=G(w,t[w],o,a,h,p);d!==void 0&&(c+=`${m}${y(w)}:${$}${d}`,m=S)}return h!==""&&m.length>1&&(c=`
12
+ ${p}${c}
13
+ ${f}`),o.pop(),`{${c}}`}case"number":return isFinite(t)?String(t):n?n(t):"null";case"boolean":return t===!0?"true":"false";case"undefined":return;case"bigint":if(N)return String(t);default:return n?n(t):void 0}}function B(M,t,o,a,h){switch(typeof t){case"string":return y(t);case"object":{if(t===null)return"null";if(typeof t.toJSON=="function"){if(t=t.toJSON(M),typeof t!="object")return B(M,t,o,a,h);if(t===null)return"null"}if(o.indexOf(t)!==-1)return u;const p=h;if(Array.isArray(t)){if(t.length===0)return"[]";if(F<o.length+1)return'"[Array]"';o.push(t),h+=a;let d=`
14
+ ${h}`;const j=`,
15
+ ${h}`,C=Math.min(t.length,L);let R=0;for(;R<C-1;R++){const J=B(String(R),t[R],o,a,h);d+=J!==void 0?J:"null",d+=j}const v=B(String(R),t[R],o,a,h);if(d+=v!==void 0?v:"null",t.length-1>L){const J=t.length-L-1;d+=`${j}"... ${P(J)} not stringified"`}return d+=`
16
+ ${p}`,o.pop(),`[${d}]`}let f=Object.keys(t);const c=f.length;if(c===0)return"{}";if(F<o.length+1)return'"[Object]"';h+=a;const S=`,
17
+ ${h}`;let $="",m="",w=Math.min(c,L);b(t)&&($+=O(t,S,L),f=f.slice(t.length),w-=t.length,m=S),E&&(f=x(f,V)),o.push(t);for(let d=0;d<w;d++){const j=f[d],C=B(j,t[j],o,a,h);C!==void 0&&($+=`${m}${y(j)}: ${C}`,m=S)}if(c>L){const d=c-L;$+=`${m}"...": "${P(d)} not stringified"`,m=S}return m!==""&&($=`
18
+ ${h}${$}
19
+ ${p}`),o.pop(),`{${$}}`}case"number":return isFinite(t)?String(t):n?n(t):"null";case"boolean":return t===!0?"true":"false";case"undefined":return;case"bigint":if(N)return String(t);default:return n?n(t):void 0}}function K(M,t,o){switch(typeof t){case"string":return y(t);case"object":{if(t===null)return"null";if(typeof t.toJSON=="function"){if(t=t.toJSON(M),typeof t!="object")return K(M,t,o);if(t===null)return"null"}if(o.indexOf(t)!==-1)return u;let a="";const h=t.length!==void 0;if(h&&Array.isArray(t)){if(t.length===0)return"[]";if(F<o.length+1)return'"[Array]"';o.push(t);const $=Math.min(t.length,L);let m=0;for(;m<$-1;m++){const d=K(String(m),t[m],o);a+=d!==void 0?d:"null",a+=","}const w=K(String(m),t[m],o);if(a+=w!==void 0?w:"null",t.length-1>L){const d=t.length-L-1;a+=`,"... ${P(d)} not stringified"`}return o.pop(),`[${a}]`}let p=Object.keys(t);const f=p.length;if(f===0)return"{}";if(F<o.length+1)return'"[Object]"';let c="",S=Math.min(f,L);h&&b(t)&&(a+=O(t,",",L),p=p.slice(t.length),S-=t.length,c=","),E&&(p=x(p,V)),o.push(t);for(let $=0;$<S;$++){const m=p[$],w=K(m,t[m],o);w!==void 0&&(a+=`${c}${y(m)}:${w}`,c=",")}if(f>L){const $=f-L;a+=`${c}"...":"${P($)} not stringified"`}return o.pop(),`{${a}}`}case"number":return isFinite(t)?String(t):n?n(t):"null";case"boolean":return t===!0?"true":"false";case"undefined":return;case"bigint":if(N)return String(t);default:return n?n(t):void 0}}function te(M,t,o){if(arguments.length>1){let a="";if(typeof o=="number"?a=" ".repeat(Math.min(o,10)):typeof o=="string"&&(a=o.slice(0,10)),t!=null){if(typeof t=="function")return Q("",{"":M},[],t,a,"");if(Array.isArray(t))return G("",M,[],q(t),a,"")}if(a.length!==0)return B("",M,[],a,"")}return K("",M,[])}return te}})(U,U.exports)),U.exports}var le=ge();class he{#t=new Map;#e;constructor(e){this.#e=e}count(e="default"){const r=this.#t.get(e)??0;this.#t.set(e,r+1),this.#e("log",!1,!1,{message:`${e}: ${String(r+1)}`,prefix:e})}countReset(e="default"){this.#t.has(e)?this.#t.delete(e):this.#e("warn",!1,!1,{message:`Count for ${e} does not exist`,prefix:e})}}class ce{log(e){const{context:r=[],message:s,type:g}=e;ne(g.level)(s,...r)}}class ue{#t=new Map;#e=new Set;#r;#i;#s;constructor(e,r,s){this.#s=e,this.#r=r,this.#i=s}time(e="default"){this.#e.has(e)?this.#s("warn",!1,!1,{message:`Timer '${e}' already exists`,prefix:e}):(this.#e.add(e),this.#t.set(e,Date.now()),this.#s("start",!1,!1,{message:this.#r,prefix:e}))}timeLog(e,...r){if(!e&&this.#e.size>0&&(e=[...this.#e].pop()),e&&this.#t.has(e)){const s=Date.now()-this.#t.get(e);this.#s("info",!1,!1,{context:r,message:s<1e3?`${String(s)} ms`:`${(s/1e3).toFixed(2)} s`,prefix:e})}else this.#s("warn",!1,!1,{context:r,message:"Timer not found",prefix:e})}timeEnd(e){if(!e&&this.#e.size>0&&(e=[...this.#e].pop()),e&&this.#t.has(e)){const r=Date.now()-this.#t.get(e);this.#t.delete(e),this.#e.delete(e),this.#s("stop",!1,!1,{message:`${this.#i} ${r<1e3?`${String(r)} ms`:`${(r/1e3).toFixed(2)} s`}`,prefix:e})}else this.#s("warn",!1,!1,{message:"Timer not found",prefix:e})}}const _=T=>T===void 0?[]:Array.isArray(T)?T:[T],k=(T,e)=>{const r={...T};return Object.keys(e).forEach(s=>{r[s]={...r[s],...e[s]}}),r},ae=T=>{let e=!1;return function(...r){if(!e){e=!0;try{const s=T.apply(this,r);return e=!1,s}catch(s){throw e=!1,s}}}};class W{timerManager;counterManager;lastLog;logLevels;disabled;paused;messageQueue;scopeName;types;longestLabel;processors;generalLogLevel;reporters;throttle;throttleMin;stringify;groups;startTimerMessage;endTimerMessage;rawReporter;force={};#t=new Set;#e;#r;constructor(e){this.throttle=e.throttle??1e3,this.throttleMin=e.throttleMin??5;const r=e.parentLongestLabel,s=e.parentTypes,g=e.parentStringify,y=e.parentLogLevels;this.stringify=g??le.configure({strict:!0}),this.startTimerMessage=e.messages?.timerStart??"Initialized timer...",this.endTimerMessage=e.messages?.timerEnd??"Timer run for:",s&&r?(this.types=s,this.longestLabel=r):(this.types=k(re,e.types??{}),this.longestLabel=X(this.types)),this.logLevels=y&&!e.logLevels?y:{...se,...e.logLevels},this.generalLogLevel=this.#n(e.logLevel),this.reporters=new Set,this.processors=new Set,this.disabled=e.disabled??!1,this.paused=!1,this.messageQueue=[],this.scopeName=_(e.scope).filter(Boolean),this.timerManager=new ue((x,l,b,...O)=>{this.logger(x,l,b,...O)},this.startTimerMessage,this.endTimerMessage),this.counterManager=new he((x,l,b,...O)=>{this.logger(x,l,b,...O)}),this.groups=[],this.lastLog={},this.logger=ae(this.logger.bind(this)),this.#i(),Array.isArray(e.reporters)&&this.registerReporters(e.reporters),this.rawReporter=this.extendReporter(e.rawReporter??new ce),Array.isArray(e.processors)&&this.registerProcessors(e.processors)}#i(){for(const e in this.types)this[e]=this.logger.bind(this,e,!1,!1);for(const e in this.types)this.force[e]=this.logger.bind(this,e,!1,!0);this.raw=this.raw.bind(this)}wrapConsole(){for(const e in this.types)Object.hasOwn(console,`__${e}`)||(console[`__${e}`]=console[e]),console[e]=this[e]}restoreConsole(){for(const e in this.types)if(Object.hasOwn(console,`__${e}`)){const r=console[`__${e}`];r===void 0?delete console[e]:console[e]=r,delete console[`__${e}`]}}wrapException(){this.#e||this.#r||(this.#e=e=>{this.error(e)},this.#r=e=>{this.error(e)},process.on("uncaughtException",this.#e),process.on("unhandledRejection",this.#r))}restoreException(){this.#e&&(process.off("uncaughtException",this.#e),this.#e=void 0),this.#r&&(process.off("unhandledRejection",this.#r),this.#r=void 0)}disable(){this.disabled=!0}enable(){this.disabled=!1}isEnabled(){return!this.disabled}pause(){this.paused=!0}resume(){this.paused=!1;const e=this.messageQueue.splice(0);for(let r=0;r<e.length;r+=1){const{messageObject:s,raw:g,type:y}=e[r];this.logger(y,g,!1,...s)}}scope(...e){if(e.length===0)throw new Error("No scope name was defined.");return this.child({scope:e})}unscope(){this.scopeName=[]}child(e){return new W(this.buildChildOptions(e))}time(e="default"){this.timerManager.time(e)}timeLog(e,...r){this.timerManager.timeLog(e,...r)}timeEnd(e){this.timerManager.timeEnd(e)}group(e="console.group"){globalThis.window===void 0?this.groups.push(e):console.group(e)}groupEnd(){globalThis.window===void 0?this.groups.pop():console.groupEnd()}count(e="default"){this.counterManager.count(e)}countReset(e="default"){this.counterManager.countReset(e)}clear(){console.clear()}raw(e,...r){this.disabled||this.logger("log",!0,!1,{context:r,message:e})}buildChildOptions(e){const r=e?.types!==void 0,s=r?k(this.types,e.types):this.types,g=e?.reporters??[],y=g.length>0?[...this.reporters,...g]:[...this.reporters],x=e?.processors??[],l=x.length>0?[...this.processors,...x]:[...this.processors],b=e?.logLevels?{...this.logLevels,...e.logLevels}:this.logLevels;let O;if(e?.scope){const z=_(e.scope).filter(Boolean);O=this.scopeName.length>0?[...this.scopeName,...z]:z}else O=this.scopeName.length>0?this.scopeName:[];const I=e?.messages?{timerEnd:this.endTimerMessage,timerStart:this.startTimerMessage,...e.messages}:{timerEnd:this.endTimerMessage,timerStart:this.startTimerMessage},A={disabled:e?.disabled??this.disabled,logLevel:e?.logLevel??this.generalLogLevel,logLevels:b,messages:I,processors:l,rawReporter:e?.rawReporter??this.rawReporter,reporters:y,scope:O,throttle:e?.throttle??this.throttle,throttleMin:e?.throttleMin??this.throttleMin};return r?(A.parentTypes=s,A.parentLongestLabel=X(s)):(A.parentTypes=this.types,A.parentLongestLabel=this.longestLabel),e?.logLevels||(A.parentLogLevels=this.logLevels),e?.messages||(A.parentMessages={timerEnd:this.endTimerMessage,timerStart:this.startTimerMessage}),A.parentStringify=this.stringify,A}extendReporter(e){return typeof e.setLoggerTypes=="function"&&e.setLoggerTypes(this.types),typeof e.setStringify=="function"&&e.setStringify(this.stringify),e}registerReporters(e){for(let r=0;r<e.length;r+=1)this.reporters.add(this.extendReporter(e[r]))}registerProcessors(e){for(let r=0;r<e.length;r+=1){const s=e[r];typeof s.setStringify=="function"&&s.setStringify(this.stringify),this.processors.add(s)}}#s(e,r){if(r)this.rawReporter.log(Object.freeze(e));else for(const s of this.reporters)s.log(Object.freeze(e))}#n(e){let r="debug";return e!==void 0&&Object.hasOwn(this.logLevels,e)?r=e:e!==void 0&&!this.#t.has(e)&&(this.#t.add(e),console.warn(`[pail] Unknown log level "${String(e)}". Valid levels: ${Object.keys(this.logLevels).join(", ")}. Falling back to "debug".`)),r}#o(e,r,...s){const g={badge:void 0,context:void 0,error:void 0,label:void 0,message:ie,prefix:void 0,repeated:void 0,scope:void 0,suffix:void 0};if(g.type={level:r.logLevel,name:e},g.groups=this.groups,g.scope=this.scopeName,g.date=new Date,s.length>0&&s[0]instanceof Error)g.error=s[0],s.length>1&&(g.context=s.slice(1));else if(s.length>0&&typeof s[0]=="object"&&s[0]!==null&&"message"in s[0]){const{context:y,message:x,prefix:l,suffix:b}=s[0];if(y&&(g.context=y),l&&(g.prefix=l),b&&(g.suffix=b),g.message=x,s.length>1){const O=s.slice(1);g.context?g.context=Array.isArray(g.context)?[...g.context,...O]:[g.context,...O]:g.context=O}}else s.length>1?(g.message=s[0],g.context=s.slice(1)):s.length===1?g.message=s[0]:g.message=void 0;return r.logLevel==="trace"&&(g.traceError=new Error("Trace")),r.badge&&(g.badge=r.badge),r.label&&(g.label=r.label),g}logger(e,r,s,...g){if(this.disabled)return;if(this.paused){this.messageQueue.push({messageObject:g,raw:r,type:e});return}const y=this.types[e],x=this.#n(y.logLevel);if(s||this.logLevels[x]>=this.logLevels[this.generalLogLevel]){let l=this.#o(e,y,...g),b;try{b=JSON.stringify([l.label,l.scope,l.type,l.message,l.prefix,l.suffix,l.context])}catch{b=void 0}const O=this.processors.size>0,I=(D=!1)=>{const P=(this.lastLog.count??0)-this.throttleMin;if(this.lastLog.object&&P>0){const q={...this.lastLog.object};P>1&&(q.repeated=P),this.#s(q,r),this.lastLog.count=1}if(D){for(const q of this.processors)l=q.process(l);if(l.dropped===!0)return;if(this.lastLog.object=l,O)try{this.lastLog.signature=JSON.stringify([l.label,l.scope,l.type,l.message,l.prefix,l.suffix,l.context])}catch{this.lastLog.signature=void 0}else this.lastLog.signature=b;this.#s(l,r)}};clearTimeout(this.lastLog.timeout);const A=l.date instanceof Date?l.date:new Date(l.date),z=this.lastLog.time?A.getTime()-this.lastLog.time.getTime():0;if(this.lastLog.time=A,z<this.throttle)try{const D=b;if(this.lastLog.object&&D!==void 0&&D===this.lastLog.signature&&(this.lastLog.count=(this.lastLog.count??0)+1,this.lastLog.count>this.throttleMin)){this.lastLog.timeout=setTimeout(I,this.throttle);return}}catch{}I(!0)}}}const pe=W,de='"[Circular]"';class me{#t;#e;#r;constructor(e={}){this.#e=e.formatters}setStringify(e){this.#t=e}process(e){this.#r===void 0&&(this.#r=oe({formatters:this.#e,stringify:s=>this.#i(s)}));const r=this.#r;return e.message!==void 0&&(e.message=this.#s(r,e.message,e.context??[])),e}#i(e){if(this.#t===void 0)try{return JSON.stringify(e)}catch{return de}try{return this.#t(e)}catch(r){return JSON.stringify(`[unserializable: ${r instanceof Error?r.message:String(r)}]`)}}#s(e,r,s=[]){if(typeof r=="string")return e(r,s);if(typeof r=="object"&&r!==null){const g=r,y=Object.keys(g);for(let x=0;x<y.length;x+=1){const l=y[x],b=g[l];(typeof b=="string"||Array.isArray(b)||typeof b=="object")&&(g[l]=this.#s(e,b,s))}}return r}}const ye=T=>new pe({processors:[new me],reporters:[new fe],...T}),we=ye();export{Oe as PailError,ye as createPail,Me as createPailError,we as pail};
@@ -1,7 +1,6 @@
1
1
  import { InteractiveManager } from '@visulima/interactive-manager';
2
- import { LiteralUnion } from 'type-fest';
3
- import { M as Meta, D as DefaultLogTypes, L as LoggerTypesConfig, P as Processor, E as ExtendedRfc5424LogLevels, R as Reporter, a as LoggerFunction, C as ConstructorOptions, S as ServerConstructorOptions } from "./packem_shared/types.d-BW8kAXUv.js";
4
- export type { b as DefaultLoggerTypes, c as LoggerConfiguration, d as LoggerTypesAwareReporter, e as StreamAwareReporter } from "./packem_shared/types.d-BW8kAXUv.js";
2
+ import { M as Meta, D as DefaultLogTypes, L as LiteralUnion, a as LoggerTypesConfig, P as Processor, E as ExtendedRfc5424LogLevels, R as Reporter, b as LoggerFunction, C as ConstructorOptions, S as ServerConstructorOptions } from "./packem_shared/types.d-OiMbrp8C.js";
3
+ export type { c as DefaultLoggerTypes, d as LoggerConfiguration, e as LoggerTypesAwareReporter, f as StreamAwareReporter } from "./packem_shared/types.d-OiMbrp8C.js";
5
4
  import '@visulima/colorize';
6
5
  type Replacer = (number | string)[] | null | undefined | ((key: string, value: unknown) => string | number | boolean | null | object);
7
6
  declare function stringify(value: undefined | symbol | ((...args: unknown[]) => unknown), replacer?: Replacer, space?: string | number): undefined;
@@ -1,32 +1,31 @@
1
- import{createRequire as ir}from"node:module";import{InteractiveManager as qe,InteractiveStreamHook as ve}from"@visulima/interactive-manager";import{g as de,E as Ve,a as xe,L as Je,Y as se,r as Ie,b as Ne,A as Ue,c as Ye,d as We,e as ze,f as K,h as He,V as Qe,G as ne,S as Xe}from"./packem_shared/abstract-pretty-reporter-CyfTvmKf.js";import Pe from"@visulima/colorize";import{PailError as pr,createPailError as mr}from"./packem_shared/PailError-CbU1Ogfa.js";const Fe=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const{stdout:ye,stderr:we,env:z}=Fe,Ke="\x1B",pe="\x1B[",Ze=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Z=Ze,et=(r,e,t,s)=>{if(t==="length"||t==="prototype"||t==="arguments"||t==="caller")return;const i=Object.getOwnPropertyDescriptor(r,t),n=Object.getOwnPropertyDescriptor(e,t);!tt(i,n)&&s||Object.defineProperty(r,t,n)},tt=function(r,e){return r===void 0||r.configurable||r.writable===e.writable&&r.enumerable===e.enumerable&&r.configurable===e.configurable&&(r.writable||r.value===e.value)},rt=(r,e)=>{const t=Object.getPrototypeOf(e);t!==Object.getPrototypeOf(r)&&Object.setPrototypeOf(r,t)},st=(r,e)=>`/* Wrapped ${r}*/
2
- ${e}`,it=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),ot=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),nt=(r,e,t)=>{const s=t===""?"":`with ${t.trim()}() `,i=st.bind(null,s,e.toString());Object.defineProperty(i,"name",ot);const{writable:n,enumerable:l,configurable:a}=it;Object.defineProperty(r,"toString",{value:i,writable:n,enumerable:l,configurable:a})};function at(r,e,{ignoreNonConfigurable:t=!1}={}){const{name:s}=r;for(const i of Reflect.ownKeys(e))et(r,e,i,t);return rt(r,e),nt(r,e,s),r}const ie=new WeakMap,Ce=(r,e={})=>{if(typeof r!="function")throw new TypeError("Expected a function");let t,s=0;const i=r.displayName||r.name||"<anonymous>",n=function(...l){if(ie.set(n,++s),s===1)t=r.apply(this,l),r=void 0;else if(e.throw===!0)throw new Error(`Function \`${i}\` can only be called once`);return t};return at(n,r),ie.set(n,s),n};Ce.callCount=r=>{if(!ie.has(r))throw new Error(`The given function \`${r.name}\` is not wrapped by the \`onetime\` package`);return ie.get(r)};const U=[];U.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&U.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&U.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");const te=r=>!!r&&!0&&typeof r.removeListener=="function"&&typeof r.emit=="function"&&typeof r.reallyExit=="function"&&typeof r.listeners=="function"&&typeof r.kill=="function"&&typeof r.pid=="number"&&typeof r.on=="function",ae=Symbol.for("signal-exit emitter"),le=globalThis,lt=Object.defineProperty.bind(Object);class ct{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(le[ae])return le[ae];lt(le,ae,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){const s=this.listeners[e],i=s.indexOf(t);i!==-1&&(i===0&&s.length===1?s.length=0:s.splice(i,1))}emit(e,t,s){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(const n of this.listeners[e])i=n(t,s)===!0||i;return e==="exit"&&(i=this.emit("afterExit",t,s)||i),i}}let Re=class{};const ft=r=>({onExit(e,t){return r.onExit(e,t)},load(){return r.load()},unload(){return r.unload()}});let ut=class extends Re{onExit(){return()=>{}}load(){}unload(){}},ht=class extends Re{#r=me.platform==="win32"?"SIGINT":"SIGHUP";#e=new ct;#t;#i;#s;#n={};#o=!1;constructor(e){super(),this.#t=e,this.#n={};for(const t of U)this.#n[t]=()=>{const s=this.#t.listeners(t);let{count:i}=this.#e;const n=e;if(typeof n.__signal_exit_emitter__=="object"&&typeof n.__signal_exit_emitter__.count=="number"&&(i+=n.__signal_exit_emitter__.count),s.length===i){this.unload();const l=this.#e.emit("exit",null,t),a=t==="SIGHUP"?this.#r:t;l||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#i=e.emit}onExit(e,t){if(!te(this.#t))return()=>{};this.#o===!1&&this.load();const s=t?.alwaysLast?"afterExit":"exit";return this.#e.on(s,e),()=>{this.#e.removeListener(s,e),this.#e.listeners.exit.length===0&&this.#e.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#e.count+=1;for(const e of U)try{const t=this.#n[e];t&&this.#t.on(e,t)}catch{}this.#t.emit=(e,...t)=>this.#l(e,...t),this.#t.reallyExit=e=>this.#a(e)}}unload(){this.#o&&(this.#o=!1,U.forEach(e=>{const t=this.#n[e];if(!t)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,t)}catch{}}),this.#t.emit=this.#i,this.#t.reallyExit=this.#s,this.#e.count-=1)}#a(e){return te(this.#t)?(this.#t.exitCode=e||0,this.#e.emit("exit",this.#t.exitCode,null),this.#s.call(this.#t,this.#t.exitCode)):0}#l(e,...t){const s=this.#i;if(e==="exit"&&te(this.#t)){typeof t[0]=="number"&&(this.#t.exitCode=t[0]);const i=s.call(this.#t,e,...t);return this.#e.emit("exit",this.#t.exitCode,null),i}else return s.call(this.#t,e,...t)}};const me=globalThis.process,{onExit:gt}=ft(te(me)?new ht(me):new ut),Le=Z.stderr.isTTY?Z.stderr:Z.stdout.isTTY?Z.stdout:void 0;Le&&Ce(()=>{gt(()=>{Le.write("\x1B[?25h")},{alwaysLast:!0})});const dt=typeof globalThis<"u"&&typeof globalThis.window=="object"&&globalThis.window.document!==void 0,pt=/^(?:msys|cygwin)$/,De=process,ke=De?.env??{},mt=!dt&&(De?.platform==="win32"||ke.OSTYPE!==void 0&&pt.test(ke.OSTYPE));var bt=(r=>(r[r.Default=0]="Default",r[r.BlinkingBlock=1]="BlinkingBlock",r[r.SteadyBlock=2]="SteadyBlock",r[r.BlinkingUnderline=3]="BlinkingUnderline",r[r.SteadyUnderline=4]="SteadyUnderline",r[r.BlinkingBar=5]="BlinkingBar",r[r.SteadyBar=6]="SteadyBar",r))(bt||{}),re=(r=>(r[r.ToEnd=0]="ToEnd",r[r.ToBeginning=1]="ToBeginning",r[r.EntireScreen=2]="EntireScreen",r[r.EntireScreenAndScrollback=3]="EntireScreenAndScrollback",r))(re||{});const ce=r=>{const e=r>=0&&r<=3?r:0;return`${pe}${e===0?"":String(e)}J`};var yt=(r=>(r[r.ToEnd=0]="ToEnd",r[r.ToBeginning=1]="ToBeginning",r[r.EntireLine=2]="EntireLine",r))(yt||{});const Te=mt?`${ce(re.EntireScreen)}${pe}0f`:`${ce(re.EntireScreen)}${ce(re.EntireScreenAndScrollback)}${pe}H${Ke}c`;var ee={exports:{}},Ee;function wt(){return Ee||(Ee=1,(function(r,e){const{hasOwnProperty:t}=Object.prototype,s=C();s.configure=C,s.stringify=s,s.default=s,e.stringify=s,e.configure=C,r.exports=s;const i=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;function n(f){return f.length<5e3&&!i.test(f)?`"${f}"`:JSON.stringify(f)}function l(f,u){if(f.length>200||u)return f.sort(u);for(let h=1;h<f.length;h++){const I=f[h];let _=h;for(;_!==0&&f[_-1]>I;)f[_]=f[_-1],_--;f[_]=I}return f}const a=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function g(f){return a.call(f)!==void 0&&f.length!==0}function m(f,u,h){f.length<h&&(h=f.length);const I=u===","?"":" ";let _=`"0":${I}${f[0]}`;for(let O=1;O<h;O++)_+=`${u}"${O}":${I}${f[O]}`;return _}function y(f){if(t.call(f,"circularValue")){const u=f.circularValue;if(typeof u=="string")return`"${u}"`;if(u==null)return u;if(u===Error||u===TypeError)return{toString(){throw new TypeError("Converting circular structure to JSON")}};throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return'"[Circular]"'}function c(f){let u;if(t.call(f,"deterministic")&&(u=f.deterministic,typeof u!="boolean"&&typeof u!="function"))throw new TypeError('The "deterministic" argument must be of type boolean or comparator function');return u===void 0?!0:u}function S(f,u){let h;if(t.call(f,u)&&(h=f[u],typeof h!="boolean"))throw new TypeError(`The "${u}" argument must be of type boolean`);return h===void 0?!0:h}function d(f,u){let h;if(t.call(f,u)){if(h=f[u],typeof h!="number")throw new TypeError(`The "${u}" argument must be of type number`);if(!Number.isInteger(h))throw new TypeError(`The "${u}" argument must be an integer`);if(h<1)throw new RangeError(`The "${u}" argument must be >= 1`)}return h===void 0?1/0:h}function v(f){return f===1?"1 item":`${f} items`}function D(f){const u=new Set;for(const h of f)(typeof h=="string"||typeof h=="number")&&u.add(String(h));return u}function J(f){if(t.call(f,"strict")){const u=f.strict;if(typeof u!="boolean")throw new TypeError('The "strict" argument must be of type boolean');if(u)return h=>{let I=`Object can not safely be stringified. Received type ${typeof h}`;throw typeof h!="function"&&(I+=` (${h.toString()})`),new Error(I)}}}function C(f){f={...f};const u=J(f);u&&(f.bigint===void 0&&(f.bigint=!1),"circularValue"in f||(f.circularValue=Error));const h=y(f),I=S(f,"bigint"),_=c(f),O=typeof _=="function"?_:void 0,B=d(f,"maximumDepth"),T=d(f,"maximumBreadth");function H(N,o,p,$,w,L){let b=o[N];switch(typeof b=="object"&&b!==null&&typeof b.toJSON=="function"&&(b=b.toJSON(N)),b=$.call(o,N,b),typeof b){case"string":return n(b);case"object":{if(b===null)return"null";if(p.indexOf(b)!==-1)return h;let x="",M=",";const j=L;if(Array.isArray(b)){if(b.length===0)return"[]";if(B<p.length+1)return'"[Array]"';p.push(b),w!==""&&(L+=w,x+=`
3
- ${L}`,M=`,
4
- ${L}`);const R=Math.min(b.length,T);let q=0;for(;q<R-1;q++){const X=H(String(q),b,p,$,w,L);x+=X!==void 0?X:"null",x+=M}const V=H(String(q),b,p,$,w,L);if(x+=V!==void 0?V:"null",b.length-1>T){const X=b.length-T-1;x+=`${M}"... ${v(X)} not stringified"`}return w!==""&&(x+=`
5
- ${j}`),p.pop(),`[${x}]`}let E=Object.keys(b);const A=E.length;if(A===0)return"{}";if(B<p.length+1)return'"[Object]"';let k="",P="";w!==""&&(L+=w,M=`,
6
- ${L}`,k=" ");const G=Math.min(A,T);_&&!g(b)&&(E=l(E,O)),p.push(b);for(let R=0;R<G;R++){const q=E[R],V=H(q,b,p,$,w,L);V!==void 0&&(x+=`${P}${n(q)}:${k}${V}`,P=M)}if(A>T){const R=A-T;x+=`${P}"...":${k}"${v(R)} not stringified"`,P=M}return w!==""&&P.length>1&&(x=`
7
- ${L}${x}
8
- ${j}`),p.pop(),`{${x}}`}case"number":return isFinite(b)?String(b):u?u(b):"null";case"boolean":return b===!0?"true":"false";case"undefined":return;case"bigint":if(I)return String(b);default:return u?u(b):void 0}}function Q(N,o,p,$,w,L){switch(typeof o=="object"&&o!==null&&typeof o.toJSON=="function"&&(o=o.toJSON(N)),typeof o){case"string":return n(o);case"object":{if(o===null)return"null";if(p.indexOf(o)!==-1)return h;const b=L;let x="",M=",";if(Array.isArray(o)){if(o.length===0)return"[]";if(B<p.length+1)return'"[Array]"';p.push(o),w!==""&&(L+=w,x+=`
9
- ${L}`,M=`,
10
- ${L}`);const A=Math.min(o.length,T);let k=0;for(;k<A-1;k++){const G=Q(String(k),o[k],p,$,w,L);x+=G!==void 0?G:"null",x+=M}const P=Q(String(k),o[k],p,$,w,L);if(x+=P!==void 0?P:"null",o.length-1>T){const G=o.length-T-1;x+=`${M}"... ${v(G)} not stringified"`}return w!==""&&(x+=`
11
- ${b}`),p.pop(),`[${x}]`}p.push(o);let j="";w!==""&&(L+=w,M=`,
12
- ${L}`,j=" ");let E="";for(const A of $){const k=Q(A,o[A],p,$,w,L);k!==void 0&&(x+=`${E}${n(A)}:${j}${k}`,E=M)}return w!==""&&E.length>1&&(x=`
13
- ${L}${x}
14
- ${b}`),p.pop(),`{${x}}`}case"number":return isFinite(o)?String(o):u?u(o):"null";case"boolean":return o===!0?"true":"false";case"undefined":return;case"bigint":if(I)return String(o);default:return u?u(o):void 0}}function Y(N,o,p,$,w){switch(typeof o){case"string":return n(o);case"object":{if(o===null)return"null";if(typeof o.toJSON=="function"){if(o=o.toJSON(N),typeof o!="object")return Y(N,o,p,$,w);if(o===null)return"null"}if(p.indexOf(o)!==-1)return h;const L=w;if(Array.isArray(o)){if(o.length===0)return"[]";if(B<p.length+1)return'"[Array]"';p.push(o),w+=$;let k=`
15
- ${w}`;const P=`,
16
- ${w}`,G=Math.min(o.length,T);let R=0;for(;R<G-1;R++){const V=Y(String(R),o[R],p,$,w);k+=V!==void 0?V:"null",k+=P}const q=Y(String(R),o[R],p,$,w);if(k+=q!==void 0?q:"null",o.length-1>T){const V=o.length-T-1;k+=`${P}"... ${v(V)} not stringified"`}return k+=`
17
- ${L}`,p.pop(),`[${k}]`}let b=Object.keys(o);const x=b.length;if(x===0)return"{}";if(B<p.length+1)return'"[Object]"';w+=$;const M=`,
18
- ${w}`;let j="",E="",A=Math.min(x,T);g(o)&&(j+=m(o,M,T),b=b.slice(o.length),A-=o.length,E=M),_&&(b=l(b,O)),p.push(o);for(let k=0;k<A;k++){const P=b[k],G=Y(P,o[P],p,$,w);G!==void 0&&(j+=`${E}${n(P)}: ${G}`,E=M)}if(x>T){const k=x-T;j+=`${E}"...": "${v(k)} not stringified"`,E=M}return E!==""&&(j=`
19
- ${w}${j}
20
- ${L}`),p.pop(),`{${j}}`}case"number":return isFinite(o)?String(o):u?u(o):"null";case"boolean":return o===!0?"true":"false";case"undefined":return;case"bigint":if(I)return String(o);default:return u?u(o):void 0}}function W(N,o,p){switch(typeof o){case"string":return n(o);case"object":{if(o===null)return"null";if(typeof o.toJSON=="function"){if(o=o.toJSON(N),typeof o!="object")return W(N,o,p);if(o===null)return"null"}if(p.indexOf(o)!==-1)return h;let $="";const w=o.length!==void 0;if(w&&Array.isArray(o)){if(o.length===0)return"[]";if(B<p.length+1)return'"[Array]"';p.push(o);const j=Math.min(o.length,T);let E=0;for(;E<j-1;E++){const k=W(String(E),o[E],p);$+=k!==void 0?k:"null",$+=","}const A=W(String(E),o[E],p);if($+=A!==void 0?A:"null",o.length-1>T){const k=o.length-T-1;$+=`,"... ${v(k)} not stringified"`}return p.pop(),`[${$}]`}let L=Object.keys(o);const b=L.length;if(b===0)return"{}";if(B<p.length+1)return'"[Object]"';let x="",M=Math.min(b,T);w&&g(o)&&($+=m(o,",",T),L=L.slice(o.length),M-=o.length,x=","),_&&(L=l(L,O)),p.push(o);for(let j=0;j<M;j++){const E=L[j],A=W(E,o[E],p);A!==void 0&&($+=`${x}${n(E)}:${A}`,x=",")}if(b>T){const j=b-T;$+=`${x}"...":"${v(j)} not stringified"`}return p.pop(),`{${$}}`}case"number":return isFinite(o)?String(o):u?u(o):"null";case"boolean":return o===!0?"true":"false";case"undefined":return;case"bigint":if(I)return String(o);default:return u?u(o):void 0}}function Ge(N,o,p){if(arguments.length>1){let $="";if(typeof p=="number"?$=" ".repeat(Math.min(p,10)):typeof p=="string"&&($=p.slice(0,10)),o!=null){if(typeof o=="function")return H("",{"":N},[],o,$,"");if(Array.isArray(o))return Q("",N,[],D(o),$,"")}if($.length!==0)return Y("",N,[],$,"")}return W("",N,[])}return Ge}})(ee,ee.exports)),ee.exports}var xt=wt();class St{#r=new Map;#e;constructor(e){this.#e=e}count(e="default"){const t=this.#r.get(e)??0;this.#r.set(e,t+1),this.#e("log",!1,!1,{message:`${e}: ${String(t+1)}`,prefix:e})}countReset(e="default"){this.#r.has(e)?this.#r.delete(e):this.#e("warn",!1,!1,{message:`Count for ${e} does not exist`,prefix:e})}}const $t=new Set(["alert","critical","emergency","error"]),vt=r=>{const e=console;return $t.has(r)?e.__error??console.error:r==="warning"?e.__warn??console.warn:r==="trace"?e.__trace??console.trace:e.__log??console.log};class Lt{log(e){const{context:t=[],message:s,type:i}=e;vt(i.level)(s,...t)}}class kt{#r=new Map;#e=new Set;#t;#i;#s;constructor(e,t,s){this.#s=e,this.#t=t,this.#i=s}time(e="default"){this.#e.has(e)?this.#s("warn",!1,!1,{message:`Timer '${e}' already exists`,prefix:e}):(this.#e.add(e),this.#r.set(e,Date.now()),this.#s("start",!1,!1,{message:this.#t,prefix:e}))}timeLog(e,...t){if(!e&&this.#e.size>0&&(e=[...this.#e].pop()),e&&this.#r.has(e)){const s=Date.now()-this.#r.get(e);this.#s("info",!1,!1,{context:t,message:s<1e3?`${String(s)} ms`:`${(s/1e3).toFixed(2)} s`,prefix:e})}else this.#s("warn",!1,!1,{context:t,message:"Timer not found",prefix:e})}timeEnd(e){if(!e&&this.#e.size>0&&(e=[...this.#e].pop()),e&&this.#r.has(e)){const t=Date.now()-this.#r.get(e);this.#r.delete(e),this.#e.delete(e),this.#s("stop",!1,!1,{message:`${this.#i} ${t<1e3?`${String(t)} ms`:`${(t/1e3).toFixed(2)} s`}`,prefix:e})}else this.#s("warn",!1,!1,{message:"Timer not found",prefix:e})}}const Oe=r=>r===void 0?[]:Array.isArray(r)?r:[r],Me=(r,e)=>{const t={...r};return Object.keys(e).forEach(s=>{t[s]={...t[s],...e[s]}}),t},Tt=r=>{let e=!1;return function(...t){if(!e){e=!0;try{const s=r.apply(this,t);return e=!1,s}catch(s){throw e=!1,s}}}};class Se{timerManager;counterManager;lastLog;logLevels;disabled;paused;messageQueue;scopeName;types;longestLabel;processors;generalLogLevel;reporters;throttle;throttleMin;stringify;groups;startTimerMessage;endTimerMessage;rawReporter;force={};#r=new Set;#e;#t;constructor(e){this.throttle=e.throttle??1e3,this.throttleMin=e.throttleMin??5;const t=e.parentLongestLabel,s=e.parentTypes,i=e.parentStringify,n=e.parentLogLevels;this.stringify=i??xt.configure({strict:!0}),this.startTimerMessage=e.messages?.timerStart??"Initialized timer...",this.endTimerMessage=e.messages?.timerEnd??"Timer run for:",s&&t?(this.types=s,this.longestLabel=t):(this.types=Me(Je,e.types??{}),this.longestLabel=de(this.types)),this.logLevels=n&&!e.logLevels?n:{...Ve,...e.logLevels},this.generalLogLevel=this.#n(e.logLevel),this.reporters=new Set,this.processors=new Set,this.disabled=e.disabled??!1,this.paused=!1,this.messageQueue=[],this.scopeName=Oe(e.scope).filter(Boolean),this.timerManager=new kt((l,a,g,...m)=>{this.logger(l,a,g,...m)},this.startTimerMessage,this.endTimerMessage),this.counterManager=new St((l,a,g,...m)=>{this.logger(l,a,g,...m)}),this.groups=[],this.lastLog={},this.logger=Tt(this.logger.bind(this)),this.#i(),Array.isArray(e.reporters)&&this.registerReporters(e.reporters),this.rawReporter=this.extendReporter(e.rawReporter??new Lt),Array.isArray(e.processors)&&this.registerProcessors(e.processors)}#i(){for(const e in this.types)this[e]=this.logger.bind(this,e,!1,!1);for(const e in this.types)this.force[e]=this.logger.bind(this,e,!1,!0);this.raw=this.raw.bind(this)}wrapConsole(){for(const e in this.types)Object.hasOwn(console,`__${e}`)||(console[`__${e}`]=console[e]),console[e]=this[e]}restoreConsole(){for(const e in this.types)if(Object.hasOwn(console,`__${e}`)){const t=console[`__${e}`];t===void 0?delete console[e]:console[e]=t,delete console[`__${e}`]}}wrapException(){this.#e||this.#t||(this.#e=e=>{this.error(e)},this.#t=e=>{this.error(e)},process.on("uncaughtException",this.#e),process.on("unhandledRejection",this.#t))}restoreException(){this.#e&&(process.off("uncaughtException",this.#e),this.#e=void 0),this.#t&&(process.off("unhandledRejection",this.#t),this.#t=void 0)}disable(){this.disabled=!0}enable(){this.disabled=!1}isEnabled(){return!this.disabled}pause(){this.paused=!0}resume(){this.paused=!1;const e=this.messageQueue.splice(0);for(let t=0;t<e.length;t+=1){const{messageObject:s,raw:i,type:n}=e[t];this.logger(n,i,!1,...s)}}scope(...e){if(e.length===0)throw new Error("No scope name was defined.");return this.child({scope:e})}unscope(){this.scopeName=[]}child(e){return new Se(this.buildChildOptions(e))}time(e="default"){this.timerManager.time(e)}timeLog(e,...t){this.timerManager.timeLog(e,...t)}timeEnd(e){this.timerManager.timeEnd(e)}group(e="console.group"){globalThis.window===void 0?this.groups.push(e):console.group(e)}groupEnd(){globalThis.window===void 0?this.groups.pop():console.groupEnd()}count(e="default"){this.counterManager.count(e)}countReset(e="default"){this.counterManager.countReset(e)}clear(){console.clear()}raw(e,...t){this.disabled||this.logger("log",!0,!1,{context:t,message:e})}buildChildOptions(e){const t=e?.types!==void 0,s=t?Me(this.types,e.types):this.types,i=e?.reporters??[],n=i.length>0?[...this.reporters,...i]:[...this.reporters],l=e?.processors??[],a=l.length>0?[...this.processors,...l]:[...this.processors],g=e?.logLevels?{...this.logLevels,...e.logLevels}:this.logLevels;let m;if(e?.scope){const S=Oe(e.scope).filter(Boolean);m=this.scopeName.length>0?[...this.scopeName,...S]:S}else m=this.scopeName.length>0?this.scopeName:[];const y=e?.messages?{timerEnd:this.endTimerMessage,timerStart:this.startTimerMessage,...e.messages}:{timerEnd:this.endTimerMessage,timerStart:this.startTimerMessage},c={disabled:e?.disabled??this.disabled,logLevel:e?.logLevel??this.generalLogLevel,logLevels:g,messages:y,processors:a,rawReporter:e?.rawReporter??this.rawReporter,reporters:n,scope:m,throttle:e?.throttle??this.throttle,throttleMin:e?.throttleMin??this.throttleMin};return t?(c.parentTypes=s,c.parentLongestLabel=de(s)):(c.parentTypes=this.types,c.parentLongestLabel=this.longestLabel),e?.logLevels||(c.parentLogLevels=this.logLevels),e?.messages||(c.parentMessages={timerEnd:this.endTimerMessage,timerStart:this.startTimerMessage}),c.parentStringify=this.stringify,c}extendReporter(e){return typeof e.setLoggerTypes=="function"&&e.setLoggerTypes(this.types),typeof e.setStringify=="function"&&e.setStringify(this.stringify),e}registerReporters(e){for(let t=0;t<e.length;t+=1)this.reporters.add(this.extendReporter(e[t]))}registerProcessors(e){for(let t=0;t<e.length;t+=1){const s=e[t];typeof s.setStringify=="function"&&s.setStringify(this.stringify),this.processors.add(s)}}#s(e,t){if(t)this.rawReporter.log(Object.freeze(e));else for(const s of this.reporters)s.log(Object.freeze(e))}#n(e){let t="debug";return e!==void 0&&Object.hasOwn(this.logLevels,e)?t=e:e!==void 0&&!this.#r.has(e)&&(this.#r.add(e),console.warn(`[pail] Unknown log level "${String(e)}". Valid levels: ${Object.keys(this.logLevels).join(", ")}. Falling back to "debug".`)),t}#o(e,t,...s){const i={badge:void 0,context:void 0,error:void 0,label:void 0,message:xe,prefix:void 0,repeated:void 0,scope:void 0,suffix:void 0};if(i.type={level:t.logLevel,name:e},i.groups=this.groups,i.scope=this.scopeName,i.date=new Date,s.length>0&&s[0]instanceof Error)i.error=s[0],s.length>1&&(i.context=s.slice(1));else if(s.length>0&&typeof s[0]=="object"&&s[0]!==null&&"message"in s[0]){const{context:n,message:l,prefix:a,suffix:g}=s[0];if(n&&(i.context=n),a&&(i.prefix=a),g&&(i.suffix=g),i.message=l,s.length>1){const m=s.slice(1);i.context?i.context=Array.isArray(i.context)?[...i.context,...m]:[i.context,...m]:i.context=m}}else s.length>1?(i.message=s[0],i.context=s.slice(1)):s.length===1?i.message=s[0]:i.message=void 0;return t.logLevel==="trace"&&(i.traceError=new Error("Trace")),t.badge&&(i.badge=t.badge),t.label&&(i.label=t.label),i}logger(e,t,s,...i){if(this.disabled)return;if(this.paused){this.messageQueue.push({messageObject:i,raw:t,type:e});return}const n=this.types[e],l=this.#n(n.logLevel);if(s||this.logLevels[l]>=this.logLevels[this.generalLogLevel]){let a=this.#o(e,n,...i),g;try{g=JSON.stringify([a.label,a.scope,a.type,a.message,a.prefix,a.suffix,a.context])}catch{g=void 0}const m=this.processors.size>0,y=(d=!1)=>{const v=(this.lastLog.count??0)-this.throttleMin;if(this.lastLog.object&&v>0){const D={...this.lastLog.object};v>1&&(D.repeated=v),this.#s(D,t),this.lastLog.count=1}if(d){for(const D of this.processors)a=D.process(a);if(a.dropped===!0)return;if(this.lastLog.object=a,m)try{this.lastLog.signature=JSON.stringify([a.label,a.scope,a.type,a.message,a.prefix,a.suffix,a.context])}catch{this.lastLog.signature=void 0}else this.lastLog.signature=g;this.#s(a,t)}};clearTimeout(this.lastLog.timeout);const c=a.date instanceof Date?a.date:new Date(a.date),S=this.lastLog.time?c.getTime()-this.lastLog.time.getTime():0;if(this.lastLog.time=c,S<this.throttle)try{const d=g;if(this.lastLog.object&&d!==void 0&&d===this.lastLog.signature&&(this.lastLog.count=(this.lastLog.count??0)+1,this.lastLog.count>this.throttleMin)){this.lastLog.timeout=setTimeout(y,this.throttle);return}}catch{}y(!0)}}}let Et=class{#r;#e;#t;#i=!1;#s;constructor(e={}){this.#r=ye,this.#e=we,this.#s=e}setStdout(e){this.#r=e}setStderr(e){this.#e=e}setInteractiveManager(e){this.#t=e}setIsInteractive(e){this.#i=e}log(e){const{context:t,groups:s,message:i,type:n}=e,l=[];if(i!==xe){const y=typeof i=="string"?i:se(i,this.#s);l.push(y)}t&&l.push(...t.map(y=>typeof y=="object"?` ${se(y,this.#s)}`:` ${String(y)}`));const a=Ie(n.level)?"stderr":"stdout",g=a==="stderr"?this.#e:this.#r,m=s.map(()=>" ").join("");this.#i&&this.#t!==void 0&&g.isTTY?this.#t.update(a,(m+l.join("")).split(`
21
- `),0):Ne(m+l.join(""),g)}};class $e extends Se{constructor(e){const t=e.parentStderr,s=e.parentStdout,{interactive:i,processors:n,rawReporter:l,reporters:a,stderr:g,stdout:m}=e,y=t??g,c=s??m,S=e.parentLongestLabel,d=e.parentTypes,{parentLogLevels:v,parentMessages:D,parentStringify:J}=e,C={disabled:e.disabled,logLevel:e.logLevel,logLevels:e.logLevels,messages:e.messages,processors:[],rawReporter:e.rawReporter,reporters:[],scope:e.scope,throttle:e.throttle,throttleMin:e.throttleMin},f="types"in e;d&&S&&!f?(C.parentTypes=d,C.parentLongestLabel=S):f&&e.types!==void 0&&(C.types=e.types),J&&(C.parentStringify=J),v&&!e.logLevels&&(C.parentLogLevels=v),D&&!e.messages&&(C.parentMessages=D),super(C),this.options=e,this.interactive=i??!1,this.stdout=c,this.stderr=y,this.interactive&&this.stdout&&this.stderr&&(this.interactiveManager=new qe(new ve(this.stdout),new ve(this.stderr))),Array.isArray(a)&&this.registerReporters(a),this.rawReporter=this.extendReporter(l??new Et),Array.isArray(n)&&this.registerProcessors(n)}options;stdout;stderr;interactiveManager;interactive;scope(...e){if(e.length===0)throw new Error("No scope name was defined.");return this.child({scope:e})}child(e){const t=this.buildChildOptions(e);return t.interactive=e?.interactive??this.interactive,t.stderr=e?.stderr??this.stderr,t.stdout=e?.stdout??this.stdout,e?.stdout||(t.parentStdout=this.stdout),e?.stderr||(t.parentStderr=this.stderr),new $e(t)}getInteractiveManager(){return this.interactiveManager}wrapStd(){this.#r(this.stdout,"log"),this.#r(this.stderr,"error")}restoreStd(){this.#e(this.stdout),this.#e(this.stderr)}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}clear(){this.stdout?.write(Te),this.stderr?.write(Te)}extendReporter(e){return typeof e.setStdout=="function"&&e.setStdout(this.stdout),typeof e.setStderr=="function"&&e.setStderr(this.stderr),typeof e.setLoggerTypes=="function"&&e.setLoggerTypes(this.types),typeof e.setStringify=="function"&&e.setStringify(this.stringify),typeof e.setIsInteractive=="function"&&e.setIsInteractive(this.interactive),this.interactive&&typeof e.setInteractiveManager=="function"&&e.setInteractiveManager(this.interactiveManager),e}#r(e,t){e&&(e.__write||(e.__write=e.write),e.write=s=>{this[t](String(s).trim())})}#e(e){e&&e.__write&&(e.write=e.__write,delete e.__write)}}const Ot=$e;let fe;const Mt=()=>(fe!==void 0||(fe=new Map([["aliceblue","#f0f8ff"],["antiquewhite","#faebd7"],["aqua","#00ffff"],["aquamarine","#7fffd4"],["azure","#f0ffff"],["beige","#f5f5dc"],["bisque","#ffe4c4"],["black","#000000"],["blanchedalmond","#ffebcd"],["blue","#0000ff"],["blueviolet","#8a2be2"],["brown","#a52a2a"],["burlywood","#deb887"],["cadetblue","#5f9ea0"],["chartreuse","#7fff00"],["chocolate","#d2691e"],["coral","#ff7f50"],["cornflowerblue","#6495ed"],["cornsilk","#fff8dc"],["crimson","#dc143c"],["cyan","#00ffff"],["darkblue","#00008b"],["darkcyan","#008b8b"],["darkgoldenrod","#b8860b"],["darkgray","#a9a9a9"],["darkgreen","#006400"],["darkgrey","#a9a9a9"],["darkkhaki","#bdb76b"],["darkmagenta","#8b008b"],["darkolivegreen","#556b2f"],["darkorange","#ff8c00"],["darkorchid","#9932cc"],["darkred","#8b0000"],["darksalmon","#e9967a"],["darkseagreen","#8fbc8f"],["darkslateblue","#483d8b"],["darkslategray","#2f4f4f"],["darkslategrey","#2f4f4f"],["darkturquoise","#00ced1"],["darkviolet","#9400d3"],["deeppink","#ff1493"],["deepskyblue","#00bfff"],["dimgray","#696969"],["dimgrey","#696969"],["dodgerblue","#1e90ff"],["firebrick","#b22222"],["floralwhite","#fffaf0"],["forestgreen","#228b22"],["fuchsia","#ff00ff"],["gainsboro","#dcdcdc"],["ghostwhite","#f8f8ff"],["gold","#ffd700"],["goldenrod","#daa520"],["gray","#808080"],["green","#008000"],["greenyellow","#adff2f"],["grey","#808080"],["honeydew","#f0fff0"],["hotpink","#ff69b4"],["indianred","#cd5c5c"],["indigo","#4b0082"],["ivory","#fffff0"],["khaki","#f0e68c"],["lavender","#e6e6fa"],["lavenderblush","#fff0f5"],["lawngreen","#7cfc00"],["lemonchiffon","#fffacd"],["lightblue","#add8e6"],["lightcoral","#f08080"],["lightcyan","#e0ffff"],["lightgoldenrodyellow","#fafad2"],["lightgray","#d3d3d3"],["lightgreen","#90ee90"],["lightgrey","#d3d3d3"],["lightpink","#ffb6c1"],["lightsalmon","#ffa07a"],["lightseagreen","#20b2aa"],["lightskyblue","#87cefa"],["lightslategray","#778899"],["lightslategrey","#778899"],["lightsteelblue","#b0c4de"],["lightyellow","#ffffe0"],["lime","#00ff00"],["limegreen","#32cd32"],["linen","#faf0e6"],["magenta","#ff00ff"],["maroon","#800000"],["mediumaquamarine","#66cdaa"],["mediumblue","#0000cd"],["mediumorchid","#ba55d3"],["mediumpurple","#9370db"],["mediumseagreen","#3cb371"],["mediumslateblue","#7b68ee"],["mediumspringgreen","#00fa9a"],["mediumturquoise","#48d1cc"],["mediumvioletred","#c71585"],["midnightblue","#191970"],["mintcream","#f5fffa"],["mistyrose","#ffe4e1"],["moccasin","#ffe4b5"],["navajowhite","#ffdead"],["navy","#000080"],["oldlace","#fdf5e6"],["olive","#808000"],["olivedrab","#6b8e23"],["orange","#ffa500"],["orangered","#ff4500"],["orchid","#da70d6"],["palegoldenrod","#eee8aa"],["palegreen","#98fb98"],["paleturquoise","#afeeee"],["palevioletred","#db7093"],["papayawhip","#ffefd5"],["peachpuff","#ffdab9"],["peru","#cd853f"],["pink","#ffc0cb"],["plum","#dda0dd"],["powderblue","#b0e0e6"],["purple","#800080"],["rebeccapurple","#663399"],["red","#ff0000"],["rosybrown","#bc8f8f"],["royalblue","#4169e1"],["saddlebrown","#8b4513"],["salmon","#fa8072"],["sandybrown","#f4a460"],["seagreen","#2e8b57"],["seashell","#fff5ee"],["sienna","#a0522d"],["silver","#c0c0c0"],["skyblue","#87ceeb"],["slateblue","#6a5acd"],["slategray","#708090"],["slategrey","#708090"],["snow","#fffafa"],["springgreen","#00ff7f"],["steelblue","#4682b4"],["tan","#d2b48c"],["teal","#008080"],["thistle","#d8bfd8"],["tomato","#ff6347"],["turquoise","#40e0d0"],["violet","#ee82ee"],["wheat","#f5deb3"],["white","#ffffff"],["whitesmoke","#f5f5f5"],["yellow","#ffff00"],["yellowgreen","#9acd32"]])),fe),jt=/^#([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})?$/i,_t=/^#([\dA-F])([\dA-F])([\dA-F])([\dA-F])?$/i,At=/^rgba?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,Bt=/^hsla?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,be=()=>({__proto__:null,backgroundColor:null,color:null,fontStyle:null,fontWeight:null,textDecorationColor:null,textDecorationLine:[]}),je=/\s+/,oe=r=>{const e=Mt();e.has(r)&&(r=e.get(r));const t=jt.exec(r);if(t)return[Number.parseInt(t[1],16),Number.parseInt(t[2],16),Number.parseInt(t[3],16)];const s=_t.exec(r);if(s)return[Number.parseInt(`${s[1]}${s[1]}`,16),Number.parseInt(`${s[2]}${s[2]}`,16),Number.parseInt(`${s[3]}${s[3]}`,16)];const i=At.exec(r);if(i)return[Math.round(Math.max(0,Math.min(255,Number(i[1])))),Math.round(Math.max(0,Math.min(255,Number(i[2])))),Math.round(Math.max(0,Math.min(255,Number(i[3]))))];const n=Bt.exec(r);if(n){let l=Number(n[1])%360;l<0&&(l+=360);const a=Math.max(0,Math.min(100,Number(n[2])))/100,g=Math.max(0,Math.min(100,Number(n[3])))/100,m=(1-Math.abs(2*g-1))*a,y=m*(1-Math.abs(l/60%2-1)),c=g-m/2;let S,d,v;return l<60?{0:S,1:d,2:v}=[m,y,0]:l<120?{0:S,1:d,2:v}=[y,m,0]:l<180?{0:S,1:d,2:v}=[0,m,y]:l<240?{0:S,1:d,2:v}=[0,y,m]:l<300?{0:S,1:d,2:v}=[y,0,m]:{0:S,1:d,2:v}=[m,0,y],[Math.round((S+c)*255),Math.round((d+c)*255),Math.round((v+c)*255)]}return null},ue=(r,e)=>typeof r=="string"||typeof e=="string"?r===e:r?.[0]===e?.[0]&&r?.[1]===e?.[1]&&r?.[2]===e?.[2],It=r=>{if(typeof r!="string")return be();const e=be(),t=[];let s=!1,i=null,n=0,l="";for(const a of r){if(a==="(")n+=1;else if(n>0)a===")"&&(n-=1);else if(s){if(a===";"){const g=l.trim();g!==""&&t.push([i,g]),i=null,l="",s=!1;continue}}else if(a===":"){i=l.trim(),l="",s=!0;continue}l+=a}if(s&&n===0){const a=l.trim();a!==""&&t.push([i,a]),i=null,l=""}for(const{0:a,1:g}of t)switch(a){case"background-color":{g!=null&&(e.backgroundColor=g);break}case"color":{g!=null&&(e.color=g);break}case"font-style":{["italic","oblique","oblique 14deg"].includes(g)&&(e.fontStyle="italic");break}case"font-weight":{g==="bold"&&(e.fontWeight=g);break}case"text-decoration":{e.textDecorationColor=null,e.textDecorationLine=[];const m=g.split(je);for(const y of m){const c=oe(y);c!=null?e.textDecorationColor=c:["line-through","overline","underline"].includes(y)&&e.textDecorationLine.push(y)}break}case"text-decoration-color":{const m=oe(g);m!=null&&(e.textDecorationColor=m);break}case"text-decoration-line":{e.textDecorationLine=[];const m=g.split(je);for(const y of m)["line-through","overline","underline"].includes(y)&&e.textDecorationLine.push(y);break}}return e},Nt=(r,e)=>{e=e??be();let t="";if(!ue(r.backgroundColor,e.backgroundColor))if(r.backgroundColor==null)t+="\x1B[49m";else switch(r.backgroundColor){case"black":{t+="\x1B[40m";break}case"blue":{t+="\x1B[44m";break}case"cyan":{t+="\x1B[46m";break}case"green":{t+="\x1B[42m";break}case"magenta":{t+="\x1B[45m";break}case"red":{t+="\x1B[41m";break}case"white":{t+="\x1B[47m";break}case"yellow":{t+="\x1B[43m";break}default:if(Array.isArray(r.backgroundColor)){const{0:s,1:i,2:n}=r.backgroundColor;t+=`\x1B[48;2;${String(s)};${String(i)};${String(n)}m`}else{const s=oe(r.backgroundColor);if(s===null)t+="\x1B[49m";else{const{0:i,1:n,2:l}=s;t+=`\x1B[48;2;${String(i)};${String(n)};${String(l)}m`}}}if(!ue(r.color,e.color))if(r.color==null)t+="\x1B[39m";else switch(r.color){case"black":{t+="\x1B[30m";break}case"blue":{t+="\x1B[34m";break}case"cyan":{t+="\x1B[36m";break}case"green":{t+="\x1B[32m";break}case"magenta":{t+="\x1B[35m";break}case"red":{t+="\x1B[31m";break}case"white":{t+="\x1B[37m";break}case"yellow":{t+="\x1B[33m";break}default:if(Array.isArray(r.color)){const{0:s,1:i,2:n}=r.color;t+=`\x1B[38;2;${String(s)};${String(i)};${String(n)}m`}else{const s=oe(r.color);if(s===null)t+="\x1B[39m";else{const{0:i,1:n,2:l}=s;t+=`\x1B[38;2;${String(i)};${String(n)};${String(l)}m`}}}if(r.fontWeight!==e.fontWeight&&(t+=r.fontWeight==="bold"?"\x1B[1m":"\x1B[22m"),r.fontStyle!==e.fontStyle&&(t+=r.fontStyle==="italic"?"\x1B[3m":"\x1B[23m"),!ue(r.textDecorationColor,e.textDecorationColor))if(r.textDecorationColor==null)t+="\x1B[59m";else{const{0:s,1:i,2:n}=r.textDecorationColor;t+=`\x1B[58;2;${String(s)};${String(i)};${String(n)}m`}return r.textDecorationLine.includes("line-through")!==e.textDecorationLine.includes("line-through")&&(t+=r.textDecorationLine.includes("line-through")?"\x1B[9m":"\x1B[29m"),r.textDecorationLine.includes("overline")!==e.textDecorationLine.includes("overline")&&(t+=r.textDecorationLine.includes("overline")?"\x1B[53m":"\x1B[55m"),r.textDecorationLine.includes("underline")!==e.textDecorationLine.includes("underline")&&(t+=r.textDecorationLine.includes("underline")?"\x1B[4m":"\x1B[24m"),t},Pt=r=>{try{return JSON.stringify(r)}catch{return'"[Circular]"'}},_e="%".codePointAt(0),Ct="s".codePointAt(0),Rt="d".codePointAt(0),Dt="f".codePointAt(0),Gt="i".codePointAt(0),Ft="O".codePointAt(0),qt="o".codePointAt(0),Vt="j".codePointAt(0),Jt="c".codePointAt(0),Ae=(r,e=[],t={})=>{if(typeof r!="string"&&typeof r!="object"||r===null)throw new TypeError(`fmt must be a string or object, got ${r===null?"null":typeof r}`);const s=t.stringify??Pt,i=1;if(typeof r=="object"){const c=e.length+i;if(c===1)return"{}";const S=Array.from({length:c});S[0]=s(r);for(let d=1;d<c;d+=1)S[d]=s(e[d-i]);return S.join(" ")}if(e.length===0)return r;let n="",l=1-i,a=-1,g=!1,m;const y=t.colors??globalThis.window===void 0;for(let c=0;c<r.length;){if(r.codePointAt(c)===_e&&c+1<r.length){a=a>-1?a:0;const S=r.codePointAt(c+1);switch(S){case Jt:{if(a<c&&(n+=r.slice(a,c)),y){const d=It(e[l]),v=Nt(d,m);n+=v,v!==""&&(g=!0,m=d)}a=c+2,c+=1;break}case Rt:case Dt:{const d=e[l];if(l>=e.length||d==null)break;a<c&&(n+=r.slice(a,c)),n+=(typeof d=="symbol"?Number.NaN:Number(d)).toString(),a=c+2,c+=1;break}case Gt:{const d=e[l];if(l>=e.length||d==null)break;a<c&&(n+=r.slice(a,c)),n+=Math.floor(typeof d=="symbol"?Number.NaN:Number(d)).toString(),a=c+2,c+=1;break}case Vt:case Ft:case qt:{if(l>=e.length||e[l]===void 0)break;a<c&&(n+=r.slice(a,c));const d=e[l],v=typeof d;if(v==="string"){n+=`'${d}'`,a=c+2,c+=1;break}if(v==="function"){n+=d.name?`[Function: ${d.name}]`:"[Function: <anonymous>]",a=c+2,c+=1;break}n+=s(d),a=c+2,c+=1;break}case _e:{a<c&&(n+=r.slice(a,c)),n+="%",a=c+2,c+=1,l-=1;break}case Ct:{if(l>=e.length)break;a<c&&(n+=r.slice(a,c));const d=e[l];n+=typeof d=="object"&&d!==null?s(d):String(d),a=c+2,c+=1;break}default:typeof t.formatters?.[S]=="function"?(a<c&&(n+=r.slice(a,c)),n+=t.formatters[S](e[l]),a=c+2,c+=1):l-=1}l+=1}c+=1}if(a===-1&&!(t.appendExtraArguments&&l<e.length))return r;if(a===-1?n=r:a<r.length&&(n+=r.slice(a)),a!==-1&&g&&(n+="\x1B[0m"),t.appendExtraArguments&&l<e.length)for(let c=Math.max(l,0);c<e.length;c+=1){const S=e[c];n+=` ${typeof S=="object"&&S!==null?s(S):String(S)}`}return n},Ut=(r={})=>{const e={};typeof r.formatters=="object"&&Object.entries(r.formatters).forEach(([i,n])=>{if(i.length===0)throw new Error(`Formatter %${i} has no characters`);if(i.length>1)throw new Error(`Formatter %${i} has more than one character`);if(typeof n!="function")throw new TypeError(`Formatter for %${i} is not a function`);const l=i.codePointAt(0);if(l===void 0)throw new Error(`${i}.codePointAt(0) failed to return a value, please report this issue`);e[l]=n});const t={...r};delete t.formatters;const s=Object.freeze({...t,formatters:e});return(i,n=[],l)=>l===void 0?Ae(i,n,s):Ae(i,n,{...t,...l,formatters:e})},Yt='"[Circular]"';class Wt{#r;#e;#t;constructor(e={}){this.#e=e.formatters}setStringify(e){this.#r=e}process(e){this.#t===void 0&&(this.#t=Ut({formatters:this.#e,stringify:s=>this.#i(s)}));const t=this.#t;return e.message!==void 0&&(e.message=this.#s(t,e.message,e.context??[])),e}#i(e){if(this.#r===void 0)try{return JSON.stringify(e)}catch{return Yt}try{return this.#r(e)}catch(t){return JSON.stringify(`[unserializable: ${t instanceof Error?t.message:String(t)}]`)}}#s(e,t,s=[]){if(typeof t=="string")return e(t,s);if(typeof t=="object"&&t!==null){const i=t,n=Object.keys(i);for(let l=0;l<n.length;l+=1){const a=n[l],g=i[a];(typeof g=="string"||Array.isArray(g)||typeof g=="object")&&(i[a]=this.#s(e,g,s))}}return t}}const{bgGrey:zt,cyan:Ht,green:Qt,greenBright:Xt,grey:F,red:he,underline:Be,white:Kt}=Pe,Zt=/[\\/]pail[\\/]dist/,ge=r=>!Zt.test(r);class er extends Ue{#r;#e;#t;#i=!1;#s;#n;#o;#a=!1;#l="";#c="";constructor(e={}){const{error:t,inspect:s,...i}=e;super({uppercase:{label:!0,...i.uppercase},...i}),this.#s={...Ye,...s},this.#n={...t,color:{fileLine:Qt,hint:Ht,marker:he,message:he,method:Xt,title:he}},this.#r=ye,this.#e=we,this.#f()}setLoggerTypes(e){super.setLoggerTypes(e),this.#f()}setStdout(e){this.#r=e,this.#o=void 0,this.#a=!1}setStderr(e){this.#e=e}setInteractiveManager(e){this.#t=e}setIsInteractive(e){this.#i=e}log(e){this._log(this._formatMessage(e),e.type.level)}#f(){this.#l=We(this.loggerTypes),this.#c=de(this.loggerTypes)}#u(){return!this.#a&&typeof this.#r.on=="function"&&(this.#a=!0,this.#r.on("resize",()=>{this.#o=void 0})),this.#o===void 0&&(this.#o=ze().columns),this.#o}_formatMessage(e){let t=this.#u();typeof this.styles.messageLength=="number"&&(t=this.styles.messageLength);const{badge:s,context:i,date:n,error:l,file:a,groups:g,label:m,message:y,prefix:c,repeated:S,scope:d,suffix:v,traceError:D,type:J}=e,{color:C}=this.loggerTypes[J.name],f=C?Pe[C]:Kt,u=g.map(()=>" ").join(""),h=[];if(g.length>0&&h.push(`${u+F(`[${g.at(-1)??""}]`)} `),n&&h.push(`${F(this.styles.dateFormatter(typeof n=="string"?new Date(n):n))} `),s)h.push(f(s));else{const O=this.#l;O.length>0&&h.push(`${F(".".repeat(O.length))} `)}const I=this.#c;if(m){const O=K(I),B=K(m);h.push(`${f(He(m,this.styles))} `,F(".".repeat(Math.max(0,O-B))))}else h.push(F(".".repeat(I.length+2)));S&&h.push(`${zt.white(`[${String(S)}x]`)} `),Array.isArray(d)&&d.length>0&&h.push(` ${F(`[${d.join(" > ")}]`)} `),c&&h.push(`${F(`${Array.isArray(d)&&d.length>0?". ":" "}[${this.styles.underline.prefix?Be(c):c}]`)} `);const _=K(h.join(" "));if(a){const O=(a.name??"")+(a.line?`:${String(a.line)}`:""),B=K(O);if(B+_+2>t)h.push(F(` ${O}`));else{const T=Math.max(0,t-_-B-2);h.push(F(`${".".repeat(T)} ${O}`))}}else h.push(F(".".repeat(Math.max(0,t-_-1))));if(h.length>0&&h.push(`
1
+ import{createRequire as _t}from"node:module";import{InteractiveManager as Ne,InteractiveStreamHook as ye}from"@visulima/interactive-manager";import{L as Pe,g as fe,E as _e,a as ue,Y as re,i as Me,w as ve,A as Ce,d as De,b as Ie,t as Fe,c as ee,f as Ve,z as qe,e as ie,v as ze}from"./packem_shared/abstract-pretty-reporter-C1W1vIw-.js";import Ae from"@visulima/colorize";import{PailError as Jt,createPailError as Gt}from"./packem_shared/PailError-BgUh0gyX.js";const Re=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{stdout:he,stderr:de,env:K}=Re,Je="\x1B",J="\x1B[",Ge=";",Oe=typeof globalThis<"u"&&typeof globalThis.window=="object"&&globalThis.window.document!==void 0,We=/^(?:msys|cygwin)$/,ke=process,ce=ke?.env??{};!Oe&&ce.TERM_PROGRAM;const Ye=!Oe&&(ke?.platform==="win32"||ce.OSTYPE!==void 0&&We.test(ce.OSTYPE)),He=(r,e)=>`${J}${String(e+1)}${Ge}${String(r+1)}H`;var Ke=(r=>(r[r.Default=0]="Default",r[r.BlinkingBlock=1]="BlinkingBlock",r[r.SteadyBlock=2]="SteadyBlock",r[r.BlinkingUnderline=3]="BlinkingUnderline",r[r.SteadyUnderline=4]="SteadyUnderline",r[r.BlinkingBar=5]="BlinkingBar",r[r.SteadyBar=6]="SteadyBar",r))(Ke||{}),W=(r=>(r[r.ToEnd=0]="ToEnd",r[r.ToBeginning=1]="ToBeginning",r[r.EntireScreen=2]="EntireScreen",r[r.EntireScreenAndScrollback=3]="EntireScreenAndScrollback",r))(W||{});const U=r=>{const e=r>=0&&r<=3?r:0;return`${J}${e===0?"":String(e)}J`};var Be=(r=>(r[r.ToEnd=0]="ToEnd",r[r.ToBeginning=1]="ToBeginning",r[r.EntireLine=2]="EntireLine",r))(Be||{});const Ue=r=>{const e=r>=0&&r<=2?r:0;return`${J}${e===0?"":String(e)}K`};He(0,0)+U(W.ToEnd);`${Ue(Be.EntireLine)}${J}`;`${J}${U(W.EntireScreen)}`;const be=Ye?`${U(W.EntireScreen)}${J}0f`:`${U(W.EntireScreen)}${U(W.EntireScreenAndScrollback)}${J}H${Je}c`;var te={exports:{}},Se;function Qe(){return Se||(Se=1,(function(r,e){const{hasOwnProperty:t}=Object.prototype,s=C();s.configure=C,s.stringify=s,s.default=s,e.stringify=s,e.configure=C,r.exports=s;const n=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;function l(c){return c.length<5e3&&!n.test(c)?`"${c}"`:JSON.stringify(c)}function a(c,g){if(c.length>200||g)return c.sort(g);for(let h=1;h<c.length;h++){const N=c[h];let B=h;for(;B!==0&&c[B-1]>N;)c[B]=c[B-1],B--;c[B]=N}return c}const o=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function d(c){return o.call(c)!==void 0&&c.length!==0}function m(c,g,h){c.length<h&&(h=c.length);const N=g===","?"":" ";let B=`"0":${N}${c[0]}`;for(let A=1;A<h;A++)B+=`${g}"${A}":${N}${c[A]}`;return B}function b(c){if(t.call(c,"circularValue")){const g=c.circularValue;if(typeof g=="string")return`"${g}"`;if(g==null)return g;if(g===Error||g===TypeError)return{toString(){throw new TypeError("Converting circular structure to JSON")}};throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return'"[Circular]"'}function f(c){let g;if(t.call(c,"deterministic")&&(g=c.deterministic,typeof g!="boolean"&&typeof g!="function"))throw new TypeError('The "deterministic" argument must be of type boolean or comparator function');return g===void 0?!0:g}function $(c,g){let h;if(t.call(c,g)&&(h=c[g],typeof h!="boolean"))throw new TypeError(`The "${g}" argument must be of type boolean`);return h===void 0?!0:h}function u(c,g){let h;if(t.call(c,g)){if(h=c[g],typeof h!="number")throw new TypeError(`The "${g}" argument must be of type number`);if(!Number.isInteger(h))throw new TypeError(`The "${g}" argument must be an integer`);if(h<1)throw new RangeError(`The "${g}" argument must be >= 1`)}return h===void 0?1/0:h}function L(c){return c===1?"1 item":`${c} items`}function I(c){const g=new Set;for(const h of c)(typeof h=="string"||typeof h=="number")&&g.add(String(h));return g}function G(c){if(t.call(c,"strict")){const g=c.strict;if(typeof g!="boolean")throw new TypeError('The "strict" argument must be of type boolean');if(g)return h=>{let N=`Object can not safely be stringified. Received type ${typeof h}`;throw typeof h!="function"&&(N+=` (${h.toString()})`),new Error(N)}}}function C(c){c={...c};const g=G(c);g&&(c.bigint===void 0&&(c.bigint=!1),"circularValue"in c||(c.circularValue=Error));const h=b(c),N=$(c,"bigint"),B=f(c),A=typeof B=="function"?B:void 0,R=u(c,"maximumDepth"),M=u(c,"maximumBreadth");function Q(P,i,p,x,S,T){let y=i[P];switch(typeof y=="object"&&y!==null&&typeof y.toJSON=="function"&&(y=y.toJSON(P)),y=x.call(i,P,y),typeof y){case"string":return l(y);case"object":{if(y===null)return"null";if(p.indexOf(y)!==-1)return h;let w="",O=",";const k=T;if(Array.isArray(y)){if(y.length===0)return"[]";if(R<p.length+1)return'"[Array]"';p.push(y),S!==""&&(T+=S,w+=`
2
+ ${T}`,O=`,
3
+ ${T}`);const D=Math.min(y.length,M);let q=0;for(;q<D-1;q++){const Z=Q(String(q),y,p,x,S,T);w+=Z!==void 0?Z:"null",w+=O}const z=Q(String(q),y,p,x,S,T);if(w+=z!==void 0?z:"null",y.length-1>M){const Z=y.length-M-1;w+=`${O}"... ${L(Z)} not stringified"`}return S!==""&&(w+=`
4
+ ${k}`),p.pop(),`[${w}]`}let v=Object.keys(y);const j=v.length;if(j===0)return"{}";if(R<p.length+1)return'"[Object]"';let E="",_="";S!==""&&(T+=S,O=`,
5
+ ${T}`,E=" ");const F=Math.min(j,M);B&&!d(y)&&(v=a(v,A)),p.push(y);for(let D=0;D<F;D++){const q=v[D],z=Q(q,y,p,x,S,T);z!==void 0&&(w+=`${_}${l(q)}:${E}${z}`,_=O)}if(j>M){const D=j-M;w+=`${_}"...":${E}"${L(D)} not stringified"`,_=O}return S!==""&&_.length>1&&(w=`
6
+ ${T}${w}
7
+ ${k}`),p.pop(),`{${w}}`}case"number":return isFinite(y)?String(y):g?g(y):"null";case"boolean":return y===!0?"true":"false";case"undefined":return;case"bigint":if(N)return String(y);default:return g?g(y):void 0}}function X(P,i,p,x,S,T){switch(typeof i=="object"&&i!==null&&typeof i.toJSON=="function"&&(i=i.toJSON(P)),typeof i){case"string":return l(i);case"object":{if(i===null)return"null";if(p.indexOf(i)!==-1)return h;const y=T;let w="",O=",";if(Array.isArray(i)){if(i.length===0)return"[]";if(R<p.length+1)return'"[Array]"';p.push(i),S!==""&&(T+=S,w+=`
8
+ ${T}`,O=`,
9
+ ${T}`);const j=Math.min(i.length,M);let E=0;for(;E<j-1;E++){const F=X(String(E),i[E],p,x,S,T);w+=F!==void 0?F:"null",w+=O}const _=X(String(E),i[E],p,x,S,T);if(w+=_!==void 0?_:"null",i.length-1>M){const F=i.length-M-1;w+=`${O}"... ${L(F)} not stringified"`}return S!==""&&(w+=`
10
+ ${y}`),p.pop(),`[${w}]`}p.push(i);let k="";S!==""&&(T+=S,O=`,
11
+ ${T}`,k=" ");let v="";for(const j of x){const E=X(j,i[j],p,x,S,T);E!==void 0&&(w+=`${v}${l(j)}:${k}${E}`,v=O)}return S!==""&&v.length>1&&(w=`
12
+ ${T}${w}
13
+ ${y}`),p.pop(),`{${w}}`}case"number":return isFinite(i)?String(i):g?g(i):"null";case"boolean":return i===!0?"true":"false";case"undefined":return;case"bigint":if(N)return String(i);default:return g?g(i):void 0}}function Y(P,i,p,x,S){switch(typeof i){case"string":return l(i);case"object":{if(i===null)return"null";if(typeof i.toJSON=="function"){if(i=i.toJSON(P),typeof i!="object")return Y(P,i,p,x,S);if(i===null)return"null"}if(p.indexOf(i)!==-1)return h;const T=S;if(Array.isArray(i)){if(i.length===0)return"[]";if(R<p.length+1)return'"[Array]"';p.push(i),S+=x;let E=`
14
+ ${S}`;const _=`,
15
+ ${S}`,F=Math.min(i.length,M);let D=0;for(;D<F-1;D++){const z=Y(String(D),i[D],p,x,S);E+=z!==void 0?z:"null",E+=_}const q=Y(String(D),i[D],p,x,S);if(E+=q!==void 0?q:"null",i.length-1>M){const z=i.length-M-1;E+=`${_}"... ${L(z)} not stringified"`}return E+=`
16
+ ${T}`,p.pop(),`[${E}]`}let y=Object.keys(i);const w=y.length;if(w===0)return"{}";if(R<p.length+1)return'"[Object]"';S+=x;const O=`,
17
+ ${S}`;let k="",v="",j=Math.min(w,M);d(i)&&(k+=m(i,O,M),y=y.slice(i.length),j-=i.length,v=O),B&&(y=a(y,A)),p.push(i);for(let E=0;E<j;E++){const _=y[E],F=Y(_,i[_],p,x,S);F!==void 0&&(k+=`${v}${l(_)}: ${F}`,v=O)}if(w>M){const E=w-M;k+=`${v}"...": "${L(E)} not stringified"`,v=O}return v!==""&&(k=`
18
+ ${S}${k}
19
+ ${T}`),p.pop(),`{${k}}`}case"number":return isFinite(i)?String(i):g?g(i):"null";case"boolean":return i===!0?"true":"false";case"undefined":return;case"bigint":if(N)return String(i);default:return g?g(i):void 0}}function H(P,i,p){switch(typeof i){case"string":return l(i);case"object":{if(i===null)return"null";if(typeof i.toJSON=="function"){if(i=i.toJSON(P),typeof i!="object")return H(P,i,p);if(i===null)return"null"}if(p.indexOf(i)!==-1)return h;let x="";const S=i.length!==void 0;if(S&&Array.isArray(i)){if(i.length===0)return"[]";if(R<p.length+1)return'"[Array]"';p.push(i);const k=Math.min(i.length,M);let v=0;for(;v<k-1;v++){const E=H(String(v),i[v],p);x+=E!==void 0?E:"null",x+=","}const j=H(String(v),i[v],p);if(x+=j!==void 0?j:"null",i.length-1>M){const E=i.length-M-1;x+=`,"... ${L(E)} not stringified"`}return p.pop(),`[${x}]`}let T=Object.keys(i);const y=T.length;if(y===0)return"{}";if(R<p.length+1)return'"[Object]"';let w="",O=Math.min(y,M);S&&d(i)&&(x+=m(i,",",M),T=T.slice(i.length),O-=i.length,w=","),B&&(T=a(T,A)),p.push(i);for(let k=0;k<O;k++){const v=T[k],j=H(v,i[v],p);j!==void 0&&(x+=`${w}${l(v)}:${j}`,w=",")}if(y>M){const k=y-M;x+=`${w}"...":"${L(k)} not stringified"`}return p.pop(),`{${x}}`}case"number":return isFinite(i)?String(i):g?g(i):"null";case"boolean":return i===!0?"true":"false";case"undefined":return;case"bigint":if(N)return String(i);default:return g?g(i):void 0}}function je(P,i,p){if(arguments.length>1){let x="";if(typeof p=="number"?x=" ".repeat(Math.min(p,10)):typeof p=="string"&&(x=p.slice(0,10)),i!=null){if(typeof i=="function")return Q("",{"":P},[],i,x,"");if(Array.isArray(i))return X("",P,[],I(i),x,"")}if(x.length!==0)return Y("",P,[],x,"")}return H("",P,[])}return je}})(te,te.exports)),te.exports}var Xe=Qe();class Ze{#t=new Map;#e;constructor(e){this.#e=e}count(e="default"){const t=this.#t.get(e)??0;this.#t.set(e,t+1),this.#e("log",!1,!1,{message:`${e}: ${String(t+1)}`,prefix:e})}countReset(e="default"){this.#t.has(e)?this.#t.delete(e):this.#e("warn",!1,!1,{message:`Count for ${e} does not exist`,prefix:e})}}const et=new Set(["alert","critical","emergency","error"]),tt=r=>{const e=console;return et.has(r)?e.__error??console.error:r==="warning"?e.__warn??console.warn:r==="trace"?e.__trace??console.trace:e.__log??console.log};let rt=class{log(e){const{context:t=[],message:s,type:n}=e;tt(n.level)(s,...t)}};class st{#t=new Map;#e=new Set;#r;#i;#s;constructor(e,t,s){this.#s=e,this.#r=t,this.#i=s}time(e="default"){this.#e.has(e)?this.#s("warn",!1,!1,{message:`Timer '${e}' already exists`,prefix:e}):(this.#e.add(e),this.#t.set(e,Date.now()),this.#s("start",!1,!1,{message:this.#r,prefix:e}))}timeLog(e,...t){if(!e&&this.#e.size>0&&(e=[...this.#e].pop()),e&&this.#t.has(e)){const s=Date.now()-this.#t.get(e);this.#s("info",!1,!1,{context:t,message:s<1e3?`${String(s)} ms`:`${(s/1e3).toFixed(2)} s`,prefix:e})}else this.#s("warn",!1,!1,{context:t,message:"Timer not found",prefix:e})}timeEnd(e){if(!e&&this.#e.size>0&&(e=[...this.#e].pop()),e&&this.#t.has(e)){const t=Date.now()-this.#t.get(e);this.#t.delete(e),this.#e.delete(e),this.#s("stop",!1,!1,{message:`${this.#i} ${t<1e3?`${String(t)} ms`:`${(t/1e3).toFixed(2)} s`}`,prefix:e})}else this.#s("warn",!1,!1,{message:"Timer not found",prefix:e})}}const we=r=>r===void 0?[]:Array.isArray(r)?r:[r],$e=(r,e)=>{const t={...r};return Object.keys(e).forEach(s=>{t[s]={...t[s],...e[s]}}),t},it=r=>{let e=!1;return function(...t){if(!e){e=!0;try{const s=r.apply(this,t);return e=!1,s}catch(s){throw e=!1,s}}}};class pe{timerManager;counterManager;lastLog;logLevels;disabled;paused;messageQueue;scopeName;types;longestLabel;processors;generalLogLevel;reporters;throttle;throttleMin;stringify;groups;startTimerMessage;endTimerMessage;rawReporter;force={};#t=new Set;#e;#r;constructor(e){this.throttle=e.throttle??1e3,this.throttleMin=e.throttleMin??5;const t=e.parentLongestLabel,s=e.parentTypes,n=e.parentStringify,l=e.parentLogLevels;this.stringify=n??Xe.configure({strict:!0}),this.startTimerMessage=e.messages?.timerStart??"Initialized timer...",this.endTimerMessage=e.messages?.timerEnd??"Timer run for:",s&&t?(this.types=s,this.longestLabel=t):(this.types=$e(Pe,e.types??{}),this.longestLabel=fe(this.types)),this.logLevels=l&&!e.logLevels?l:{..._e,...e.logLevels},this.generalLogLevel=this.#n(e.logLevel),this.reporters=new Set,this.processors=new Set,this.disabled=e.disabled??!1,this.paused=!1,this.messageQueue=[],this.scopeName=we(e.scope).filter(Boolean),this.timerManager=new st((a,o,d,...m)=>{this.logger(a,o,d,...m)},this.startTimerMessage,this.endTimerMessage),this.counterManager=new Ze((a,o,d,...m)=>{this.logger(a,o,d,...m)}),this.groups=[],this.lastLog={},this.logger=it(this.logger.bind(this)),this.#i(),Array.isArray(e.reporters)&&this.registerReporters(e.reporters),this.rawReporter=this.extendReporter(e.rawReporter??new rt),Array.isArray(e.processors)&&this.registerProcessors(e.processors)}#i(){for(const e in this.types)this[e]=this.logger.bind(this,e,!1,!1);for(const e in this.types)this.force[e]=this.logger.bind(this,e,!1,!0);this.raw=this.raw.bind(this)}wrapConsole(){for(const e in this.types)Object.hasOwn(console,`__${e}`)||(console[`__${e}`]=console[e]),console[e]=this[e]}restoreConsole(){for(const e in this.types)if(Object.hasOwn(console,`__${e}`)){const t=console[`__${e}`];t===void 0?delete console[e]:console[e]=t,delete console[`__${e}`]}}wrapException(){this.#e||this.#r||(this.#e=e=>{this.error(e)},this.#r=e=>{this.error(e)},process.on("uncaughtException",this.#e),process.on("unhandledRejection",this.#r))}restoreException(){this.#e&&(process.off("uncaughtException",this.#e),this.#e=void 0),this.#r&&(process.off("unhandledRejection",this.#r),this.#r=void 0)}disable(){this.disabled=!0}enable(){this.disabled=!1}isEnabled(){return!this.disabled}pause(){this.paused=!0}resume(){this.paused=!1;const e=this.messageQueue.splice(0);for(let t=0;t<e.length;t+=1){const{messageObject:s,raw:n,type:l}=e[t];this.logger(l,n,!1,...s)}}scope(...e){if(e.length===0)throw new Error("No scope name was defined.");return this.child({scope:e})}unscope(){this.scopeName=[]}child(e){return new pe(this.buildChildOptions(e))}time(e="default"){this.timerManager.time(e)}timeLog(e,...t){this.timerManager.timeLog(e,...t)}timeEnd(e){this.timerManager.timeEnd(e)}group(e="console.group"){globalThis.window===void 0?this.groups.push(e):console.group(e)}groupEnd(){globalThis.window===void 0?this.groups.pop():console.groupEnd()}count(e="default"){this.counterManager.count(e)}countReset(e="default"){this.counterManager.countReset(e)}clear(){console.clear()}raw(e,...t){this.disabled||this.logger("log",!0,!1,{context:t,message:e})}buildChildOptions(e){const t=e?.types!==void 0,s=t?$e(this.types,e.types):this.types,n=e?.reporters??[],l=n.length>0?[...this.reporters,...n]:[...this.reporters],a=e?.processors??[],o=a.length>0?[...this.processors,...a]:[...this.processors],d=e?.logLevels?{...this.logLevels,...e.logLevels}:this.logLevels;let m;if(e?.scope){const $=we(e.scope).filter(Boolean);m=this.scopeName.length>0?[...this.scopeName,...$]:$}else m=this.scopeName.length>0?this.scopeName:[];const b=e?.messages?{timerEnd:this.endTimerMessage,timerStart:this.startTimerMessage,...e.messages}:{timerEnd:this.endTimerMessage,timerStart:this.startTimerMessage},f={disabled:e?.disabled??this.disabled,logLevel:e?.logLevel??this.generalLogLevel,logLevels:d,messages:b,processors:o,rawReporter:e?.rawReporter??this.rawReporter,reporters:l,scope:m,throttle:e?.throttle??this.throttle,throttleMin:e?.throttleMin??this.throttleMin};return t?(f.parentTypes=s,f.parentLongestLabel=fe(s)):(f.parentTypes=this.types,f.parentLongestLabel=this.longestLabel),e?.logLevels||(f.parentLogLevels=this.logLevels),e?.messages||(f.parentMessages={timerEnd:this.endTimerMessage,timerStart:this.startTimerMessage}),f.parentStringify=this.stringify,f}extendReporter(e){return typeof e.setLoggerTypes=="function"&&e.setLoggerTypes(this.types),typeof e.setStringify=="function"&&e.setStringify(this.stringify),e}registerReporters(e){for(let t=0;t<e.length;t+=1)this.reporters.add(this.extendReporter(e[t]))}registerProcessors(e){for(let t=0;t<e.length;t+=1){const s=e[t];typeof s.setStringify=="function"&&s.setStringify(this.stringify),this.processors.add(s)}}#s(e,t){if(t)this.rawReporter.log(Object.freeze(e));else for(const s of this.reporters)s.log(Object.freeze(e))}#n(e){let t="debug";return e!==void 0&&Object.hasOwn(this.logLevels,e)?t=e:e!==void 0&&!this.#t.has(e)&&(this.#t.add(e),console.warn(`[pail] Unknown log level "${String(e)}". Valid levels: ${Object.keys(this.logLevels).join(", ")}. Falling back to "debug".`)),t}#o(e,t,...s){const n={badge:void 0,context:void 0,error:void 0,label:void 0,message:ue,prefix:void 0,repeated:void 0,scope:void 0,suffix:void 0};if(n.type={level:t.logLevel,name:e},n.groups=this.groups,n.scope=this.scopeName,n.date=new Date,s.length>0&&s[0]instanceof Error)n.error=s[0],s.length>1&&(n.context=s.slice(1));else if(s.length>0&&typeof s[0]=="object"&&s[0]!==null&&"message"in s[0]){const{context:l,message:a,prefix:o,suffix:d}=s[0];if(l&&(n.context=l),o&&(n.prefix=o),d&&(n.suffix=d),n.message=a,s.length>1){const m=s.slice(1);n.context?n.context=Array.isArray(n.context)?[...n.context,...m]:[n.context,...m]:n.context=m}}else s.length>1?(n.message=s[0],n.context=s.slice(1)):s.length===1?n.message=s[0]:n.message=void 0;return t.logLevel==="trace"&&(n.traceError=new Error("Trace")),t.badge&&(n.badge=t.badge),t.label&&(n.label=t.label),n}logger(e,t,s,...n){if(this.disabled)return;if(this.paused){this.messageQueue.push({messageObject:n,raw:t,type:e});return}const l=this.types[e],a=this.#n(l.logLevel);if(s||this.logLevels[a]>=this.logLevels[this.generalLogLevel]){let o=this.#o(e,l,...n),d;try{d=JSON.stringify([o.label,o.scope,o.type,o.message,o.prefix,o.suffix,o.context])}catch{d=void 0}const m=this.processors.size>0,b=(u=!1)=>{const L=(this.lastLog.count??0)-this.throttleMin;if(this.lastLog.object&&L>0){const I={...this.lastLog.object};L>1&&(I.repeated=L),this.#s(I,t),this.lastLog.count=1}if(u){for(const I of this.processors)o=I.process(o);if(o.dropped===!0)return;if(this.lastLog.object=o,m)try{this.lastLog.signature=JSON.stringify([o.label,o.scope,o.type,o.message,o.prefix,o.suffix,o.context])}catch{this.lastLog.signature=void 0}else this.lastLog.signature=d;this.#s(o,t)}};clearTimeout(this.lastLog.timeout);const f=o.date instanceof Date?o.date:new Date(o.date),$=this.lastLog.time?f.getTime()-this.lastLog.time.getTime():0;if(this.lastLog.time=f,$<this.throttle)try{const u=d;if(this.lastLog.object&&u!==void 0&&u===this.lastLog.signature&&(this.lastLog.count=(this.lastLog.count??0)+1,this.lastLog.count>this.throttleMin)){this.lastLog.timeout=setTimeout(b,this.throttle);return}}catch{}b(!0)}}}class nt{#t;#e;#r;#i=!1;#s;constructor(e={}){this.#t=he,this.#e=de,this.#s=e}setStdout(e){this.#t=e}setStderr(e){this.#e=e}setInteractiveManager(e){this.#r=e}setIsInteractive(e){this.#i=e}log(e){const{context:t,groups:s,message:n,type:l}=e,a=[];if(n!==ue){const b=typeof n=="string"?n:re(n,this.#s);a.push(b)}t&&a.push(...t.map(b=>typeof b=="object"?` ${re(b,this.#s)}`:` ${String(b)}`));const o=Me(l.level)?"stderr":"stdout",d=o==="stderr"?this.#e:this.#t,m=s.map(()=>" ").join("");this.#i&&this.#r!==void 0&&d.isTTY?this.#r.update(o,(m+a.join("")).split(`
20
+ `),0):ve(m+a.join(""),d)}}class me extends pe{constructor(e){const t=e.parentStderr,s=e.parentStdout,{interactive:n,processors:l,rawReporter:a,reporters:o,stderr:d,stdout:m}=e,b=t??d,f=s??m,$=e.parentLongestLabel,u=e.parentTypes,{parentLogLevels:L,parentMessages:I,parentStringify:G}=e,C={disabled:e.disabled,logLevel:e.logLevel,logLevels:e.logLevels,messages:e.messages,processors:[],rawReporter:e.rawReporter,reporters:[],scope:e.scope,throttle:e.throttle,throttleMin:e.throttleMin},c="types"in e;u&&$&&!c?(C.parentTypes=u,C.parentLongestLabel=$):c&&e.types!==void 0&&(C.types=e.types),G&&(C.parentStringify=G),L&&!e.logLevels&&(C.parentLogLevels=L),I&&!e.messages&&(C.parentMessages=I),super(C),this.options=e,this.interactive=n??!1,this.stdout=f,this.stderr=b,this.interactive&&this.stdout&&this.stderr&&(this.interactiveManager=new Ne(new ye(this.stdout),new ye(this.stderr))),Array.isArray(o)&&this.registerReporters(o),this.rawReporter=this.extendReporter(a??new nt),Array.isArray(l)&&this.registerProcessors(l)}options;stdout;stderr;interactiveManager;interactive;scope(...e){if(e.length===0)throw new Error("No scope name was defined.");return this.child({scope:e})}child(e){const t=this.buildChildOptions(e);return t.interactive=e?.interactive??this.interactive,t.stderr=e?.stderr??this.stderr,t.stdout=e?.stdout??this.stdout,e?.stdout||(t.parentStdout=this.stdout),e?.stderr||(t.parentStderr=this.stderr),new me(t)}getInteractiveManager(){return this.interactiveManager}wrapStd(){this.#t(this.stdout,"log"),this.#t(this.stderr,"error")}restoreStd(){this.#e(this.stdout),this.#e(this.stderr)}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}clear(){this.stdout?.write(be),this.stderr?.write(be)}extendReporter(e){return typeof e.setStdout=="function"&&e.setStdout(this.stdout),typeof e.setStderr=="function"&&e.setStderr(this.stderr),typeof e.setLoggerTypes=="function"&&e.setLoggerTypes(this.types),typeof e.setStringify=="function"&&e.setStringify(this.stringify),typeof e.setIsInteractive=="function"&&e.setIsInteractive(this.interactive),this.interactive&&typeof e.setInteractiveManager=="function"&&e.setInteractiveManager(this.interactiveManager),e}#t(e,t){e&&(e.__write||(e.__write=e.write),e.write=s=>{this[t](String(s).trim())})}#e(e){e&&e.__write&&(e.write=e.__write,delete e.__write)}}const ot=me;let ne;const lt=()=>(ne!==void 0||(ne=new Map([["aliceblue","#f0f8ff"],["antiquewhite","#faebd7"],["aqua","#00ffff"],["aquamarine","#7fffd4"],["azure","#f0ffff"],["beige","#f5f5dc"],["bisque","#ffe4c4"],["black","#000000"],["blanchedalmond","#ffebcd"],["blue","#0000ff"],["blueviolet","#8a2be2"],["brown","#a52a2a"],["burlywood","#deb887"],["cadetblue","#5f9ea0"],["chartreuse","#7fff00"],["chocolate","#d2691e"],["coral","#ff7f50"],["cornflowerblue","#6495ed"],["cornsilk","#fff8dc"],["crimson","#dc143c"],["cyan","#00ffff"],["darkblue","#00008b"],["darkcyan","#008b8b"],["darkgoldenrod","#b8860b"],["darkgray","#a9a9a9"],["darkgreen","#006400"],["darkgrey","#a9a9a9"],["darkkhaki","#bdb76b"],["darkmagenta","#8b008b"],["darkolivegreen","#556b2f"],["darkorange","#ff8c00"],["darkorchid","#9932cc"],["darkred","#8b0000"],["darksalmon","#e9967a"],["darkseagreen","#8fbc8f"],["darkslateblue","#483d8b"],["darkslategray","#2f4f4f"],["darkslategrey","#2f4f4f"],["darkturquoise","#00ced1"],["darkviolet","#9400d3"],["deeppink","#ff1493"],["deepskyblue","#00bfff"],["dimgray","#696969"],["dimgrey","#696969"],["dodgerblue","#1e90ff"],["firebrick","#b22222"],["floralwhite","#fffaf0"],["forestgreen","#228b22"],["fuchsia","#ff00ff"],["gainsboro","#dcdcdc"],["ghostwhite","#f8f8ff"],["gold","#ffd700"],["goldenrod","#daa520"],["gray","#808080"],["green","#008000"],["greenyellow","#adff2f"],["grey","#808080"],["honeydew","#f0fff0"],["hotpink","#ff69b4"],["indianred","#cd5c5c"],["indigo","#4b0082"],["ivory","#fffff0"],["khaki","#f0e68c"],["lavender","#e6e6fa"],["lavenderblush","#fff0f5"],["lawngreen","#7cfc00"],["lemonchiffon","#fffacd"],["lightblue","#add8e6"],["lightcoral","#f08080"],["lightcyan","#e0ffff"],["lightgoldenrodyellow","#fafad2"],["lightgray","#d3d3d3"],["lightgreen","#90ee90"],["lightgrey","#d3d3d3"],["lightpink","#ffb6c1"],["lightsalmon","#ffa07a"],["lightseagreen","#20b2aa"],["lightskyblue","#87cefa"],["lightslategray","#778899"],["lightslategrey","#778899"],["lightsteelblue","#b0c4de"],["lightyellow","#ffffe0"],["lime","#00ff00"],["limegreen","#32cd32"],["linen","#faf0e6"],["magenta","#ff00ff"],["maroon","#800000"],["mediumaquamarine","#66cdaa"],["mediumblue","#0000cd"],["mediumorchid","#ba55d3"],["mediumpurple","#9370db"],["mediumseagreen","#3cb371"],["mediumslateblue","#7b68ee"],["mediumspringgreen","#00fa9a"],["mediumturquoise","#48d1cc"],["mediumvioletred","#c71585"],["midnightblue","#191970"],["mintcream","#f5fffa"],["mistyrose","#ffe4e1"],["moccasin","#ffe4b5"],["navajowhite","#ffdead"],["navy","#000080"],["oldlace","#fdf5e6"],["olive","#808000"],["olivedrab","#6b8e23"],["orange","#ffa500"],["orangered","#ff4500"],["orchid","#da70d6"],["palegoldenrod","#eee8aa"],["palegreen","#98fb98"],["paleturquoise","#afeeee"],["palevioletred","#db7093"],["papayawhip","#ffefd5"],["peachpuff","#ffdab9"],["peru","#cd853f"],["pink","#ffc0cb"],["plum","#dda0dd"],["powderblue","#b0e0e6"],["purple","#800080"],["rebeccapurple","#663399"],["red","#ff0000"],["rosybrown","#bc8f8f"],["royalblue","#4169e1"],["saddlebrown","#8b4513"],["salmon","#fa8072"],["sandybrown","#f4a460"],["seagreen","#2e8b57"],["seashell","#fff5ee"],["sienna","#a0522d"],["silver","#c0c0c0"],["skyblue","#87ceeb"],["slateblue","#6a5acd"],["slategray","#708090"],["slategrey","#708090"],["snow","#fffafa"],["springgreen","#00ff7f"],["steelblue","#4682b4"],["tan","#d2b48c"],["teal","#008080"],["thistle","#d8bfd8"],["tomato","#ff6347"],["turquoise","#40e0d0"],["violet","#ee82ee"],["wheat","#f5deb3"],["white","#ffffff"],["whitesmoke","#f5f5f5"],["yellow","#ffff00"],["yellowgreen","#9acd32"]])),ne),at=/^#([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})([\dA-F]{2})?$/i,ft=/^#([\dA-F])([\dA-F])([\dA-F])([\dA-F])?$/i,ct=/^rgba?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,gt=/^hsla?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))%\s*(,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*)?\)$/,ge=()=>({__proto__:null,backgroundColor:null,color:null,fontStyle:null,fontWeight:null,textDecorationColor:null,textDecorationLine:[]}),Le=/\s+/,se=r=>{const e=lt();e.has(r)&&(r=e.get(r));const t=at.exec(r);if(t)return[Number.parseInt(t[1],16),Number.parseInt(t[2],16),Number.parseInt(t[3],16)];const s=ft.exec(r);if(s)return[Number.parseInt(`${s[1]}${s[1]}`,16),Number.parseInt(`${s[2]}${s[2]}`,16),Number.parseInt(`${s[3]}${s[3]}`,16)];const n=ct.exec(r);if(n)return[Math.round(Math.max(0,Math.min(255,Number(n[1])))),Math.round(Math.max(0,Math.min(255,Number(n[2])))),Math.round(Math.max(0,Math.min(255,Number(n[3]))))];const l=gt.exec(r);if(l){let a=Number(l[1])%360;a<0&&(a+=360);const o=Math.max(0,Math.min(100,Number(l[2])))/100,d=Math.max(0,Math.min(100,Number(l[3])))/100,m=(1-Math.abs(2*d-1))*o,b=m*(1-Math.abs(a/60%2-1)),f=d-m/2;let $,u,L;return a<60?{0:$,1:u,2:L}=[m,b,0]:a<120?{0:$,1:u,2:L}=[b,m,0]:a<180?{0:$,1:u,2:L}=[0,m,b]:a<240?{0:$,1:u,2:L}=[0,b,m]:a<300?{0:$,1:u,2:L}=[b,0,m]:{0:$,1:u,2:L}=[m,0,b],[Math.round(($+f)*255),Math.round((u+f)*255),Math.round((L+f)*255)]}return null},oe=(r,e)=>typeof r=="string"||typeof e=="string"?r===e:r?.[0]===e?.[0]&&r?.[1]===e?.[1]&&r?.[2]===e?.[2],ht=r=>{if(typeof r!="string")return ge();const e=ge(),t=[];let s=!1,n=null,l=0,a="";for(const o of r){if(o==="(")l+=1;else if(l>0)o===")"&&(l-=1);else if(s){if(o===";"){const d=a.trim();d!==""&&t.push([n,d]),n=null,a="",s=!1;continue}}else if(o===":"){n=a.trim(),a="",s=!0;continue}a+=o}if(s&&l===0){const o=a.trim();o!==""&&t.push([n,o]),n=null,a=""}for(const{0:o,1:d}of t)switch(o){case"background-color":{d!=null&&(e.backgroundColor=d);break}case"color":{d!=null&&(e.color=d);break}case"font-style":{["italic","oblique","oblique 14deg"].includes(d)&&(e.fontStyle="italic");break}case"font-weight":{d==="bold"&&(e.fontWeight=d);break}case"text-decoration":{e.textDecorationColor=null,e.textDecorationLine=[];const m=d.split(Le);for(const b of m){const f=se(b);f!=null?e.textDecorationColor=f:["line-through","overline","underline"].includes(b)&&e.textDecorationLine.push(b)}break}case"text-decoration-color":{const m=se(d);m!=null&&(e.textDecorationColor=m);break}case"text-decoration-line":{e.textDecorationLine=[];const m=d.split(Le);for(const b of m)["line-through","overline","underline"].includes(b)&&e.textDecorationLine.push(b);break}}return e},dt=(r,e)=>{e=e??ge();let t="";if(!oe(r.backgroundColor,e.backgroundColor))if(r.backgroundColor==null)t+="\x1B[49m";else switch(r.backgroundColor){case"black":{t+="\x1B[40m";break}case"blue":{t+="\x1B[44m";break}case"cyan":{t+="\x1B[46m";break}case"green":{t+="\x1B[42m";break}case"magenta":{t+="\x1B[45m";break}case"red":{t+="\x1B[41m";break}case"white":{t+="\x1B[47m";break}case"yellow":{t+="\x1B[43m";break}default:if(Array.isArray(r.backgroundColor)){const{0:s,1:n,2:l}=r.backgroundColor;t+=`\x1B[48;2;${String(s)};${String(n)};${String(l)}m`}else{const s=se(r.backgroundColor);if(s===null)t+="\x1B[49m";else{const{0:n,1:l,2:a}=s;t+=`\x1B[48;2;${String(n)};${String(l)};${String(a)}m`}}}if(!oe(r.color,e.color))if(r.color==null)t+="\x1B[39m";else switch(r.color){case"black":{t+="\x1B[30m";break}case"blue":{t+="\x1B[34m";break}case"cyan":{t+="\x1B[36m";break}case"green":{t+="\x1B[32m";break}case"magenta":{t+="\x1B[35m";break}case"red":{t+="\x1B[31m";break}case"white":{t+="\x1B[37m";break}case"yellow":{t+="\x1B[33m";break}default:if(Array.isArray(r.color)){const{0:s,1:n,2:l}=r.color;t+=`\x1B[38;2;${String(s)};${String(n)};${String(l)}m`}else{const s=se(r.color);if(s===null)t+="\x1B[39m";else{const{0:n,1:l,2:a}=s;t+=`\x1B[38;2;${String(n)};${String(l)};${String(a)}m`}}}if(r.fontWeight!==e.fontWeight&&(t+=r.fontWeight==="bold"?"\x1B[1m":"\x1B[22m"),r.fontStyle!==e.fontStyle&&(t+=r.fontStyle==="italic"?"\x1B[3m":"\x1B[23m"),!oe(r.textDecorationColor,e.textDecorationColor))if(r.textDecorationColor==null)t+="\x1B[59m";else{const{0:s,1:n,2:l}=r.textDecorationColor;t+=`\x1B[58;2;${String(s)};${String(n)};${String(l)}m`}return r.textDecorationLine.includes("line-through")!==e.textDecorationLine.includes("line-through")&&(t+=r.textDecorationLine.includes("line-through")?"\x1B[9m":"\x1B[29m"),r.textDecorationLine.includes("overline")!==e.textDecorationLine.includes("overline")&&(t+=r.textDecorationLine.includes("overline")?"\x1B[53m":"\x1B[55m"),r.textDecorationLine.includes("underline")!==e.textDecorationLine.includes("underline")&&(t+=r.textDecorationLine.includes("underline")?"\x1B[4m":"\x1B[24m"),t},ut=r=>{try{return JSON.stringify(r)}catch{return'"[Circular]"'}},xe="%".codePointAt(0),pt="s".codePointAt(0),mt="d".codePointAt(0),yt="f".codePointAt(0),bt="i".codePointAt(0),St="O".codePointAt(0),wt="o".codePointAt(0),$t="j".codePointAt(0),Lt="c".codePointAt(0),Te=(r,e=[],t={})=>{if(typeof r!="string"&&typeof r!="object"||r===null)throw new TypeError(`fmt must be a string or object, got ${r===null?"null":typeof r}`);const s=t.stringify??ut,n=1;if(typeof r=="object"){const f=e.length+n;if(f===1)return"{}";const $=Array.from({length:f});$[0]=s(r);for(let u=1;u<f;u+=1)$[u]=s(e[u-n]);return $.join(" ")}if(e.length===0)return r;let l="",a=1-n,o=-1,d=!1,m;const b=t.colors??globalThis.window===void 0;for(let f=0;f<r.length;){if(r.codePointAt(f)===xe&&f+1<r.length){o=o>-1?o:0;const $=r.codePointAt(f+1);switch($){case Lt:{if(o<f&&(l+=r.slice(o,f)),b){const u=ht(e[a]),L=dt(u,m);l+=L,L!==""&&(d=!0,m=u)}o=f+2,f+=1;break}case mt:case yt:{const u=e[a];if(a>=e.length||u==null)break;o<f&&(l+=r.slice(o,f)),l+=(typeof u=="symbol"?Number.NaN:Number(u)).toString(),o=f+2,f+=1;break}case bt:{const u=e[a];if(a>=e.length||u==null)break;o<f&&(l+=r.slice(o,f)),l+=Math.floor(typeof u=="symbol"?Number.NaN:Number(u)).toString(),o=f+2,f+=1;break}case $t:case St:case wt:{if(a>=e.length||e[a]===void 0)break;o<f&&(l+=r.slice(o,f));const u=e[a],L=typeof u;if(L==="string"){l+=`'${u}'`,o=f+2,f+=1;break}if(L==="function"){l+=u.name?`[Function: ${u.name}]`:"[Function: <anonymous>]",o=f+2,f+=1;break}l+=s(u),o=f+2,f+=1;break}case xe:{o<f&&(l+=r.slice(o,f)),l+="%",o=f+2,f+=1,a-=1;break}case pt:{if(a>=e.length)break;o<f&&(l+=r.slice(o,f));const u=e[a];l+=typeof u=="object"&&u!==null?s(u):String(u),o=f+2,f+=1;break}default:typeof t.formatters?.[$]=="function"?(o<f&&(l+=r.slice(o,f)),l+=t.formatters[$](e[a]),o=f+2,f+=1):a-=1}a+=1}f+=1}if(o===-1&&!(t.appendExtraArguments&&a<e.length))return r;if(o===-1?l=r:o<r.length&&(l+=r.slice(o)),o!==-1&&d&&(l+="\x1B[0m"),t.appendExtraArguments&&a<e.length)for(let f=Math.max(a,0);f<e.length;f+=1){const $=e[f];l+=` ${typeof $=="object"&&$!==null?s($):String($)}`}return l},xt=(r={})=>{const e={};typeof r.formatters=="object"&&Object.entries(r.formatters).forEach(([n,l])=>{if(n.length===0)throw new Error(`Formatter %${n} has no characters`);if(n.length>1)throw new Error(`Formatter %${n} has more than one character`);if(typeof l!="function")throw new TypeError(`Formatter for %${n} is not a function`);const a=n.codePointAt(0);if(a===void 0)throw new Error(`${n}.codePointAt(0) failed to return a value, please report this issue`);e[a]=l});const t={...r};delete t.formatters;const s=Object.freeze({...t,formatters:e});return(n,l=[],a)=>a===void 0?Te(n,l,s):Te(n,l,{...t,...a,formatters:e})},Tt='"[Circular]"';class Et{#t;#e;#r;constructor(e={}){this.#e=e.formatters}setStringify(e){this.#t=e}process(e){this.#r===void 0&&(this.#r=xt({formatters:this.#e,stringify:s=>this.#i(s)}));const t=this.#r;return e.message!==void 0&&(e.message=this.#s(t,e.message,e.context??[])),e}#i(e){if(this.#t===void 0)try{return JSON.stringify(e)}catch{return Tt}try{return this.#t(e)}catch(t){return JSON.stringify(`[unserializable: ${t instanceof Error?t.message:String(t)}]`)}}#s(e,t,s=[]){if(typeof t=="string")return e(t,s);if(typeof t=="object"&&t!==null){const n=t,l=Object.keys(n);for(let a=0;a<l.length;a+=1){const o=l[a],d=n[o];(typeof d=="string"||Array.isArray(d)||typeof d=="object")&&(n[o]=this.#s(e,d,s))}}return t}}const{bgGrey:Mt,cyan:vt,green:At,greenBright:Ot,grey:V,red:le,underline:Ee,white:kt}=Ae,Bt=/[\\/]pail[\\/]dist/,ae=r=>!Bt.test(r);class jt extends Ce{#t;#e;#r;#i=!1;#s;#n;#o;#l=!1;#a="";#f="";constructor(e={}){const{error:t,inspect:s,...n}=e;super({uppercase:{label:!0,...n.uppercase},...n}),this.#s={...De,...s},this.#n={...t,color:{fileLine:At,hint:vt,marker:le,message:le,method:Ot,title:le}},this.#t=he,this.#e=de,this.#c()}setLoggerTypes(e){super.setLoggerTypes(e),this.#c()}setStdout(e){this.#t=e,this.#o=void 0,this.#l=!1}setStderr(e){this.#e=e}setInteractiveManager(e){this.#r=e}setIsInteractive(e){this.#i=e}log(e){this._log(this._formatMessage(e),e.type.level)}#c(){this.#a=Ie(this.loggerTypes),this.#f=fe(this.loggerTypes)}#g(){return!this.#l&&typeof this.#t.on=="function"&&(this.#l=!0,this.#t.on("resize",()=>{this.#o=void 0})),this.#o===void 0&&(this.#o=Fe().columns),this.#o}_formatMessage(e){let t=this.#g();typeof this.styles.messageLength=="number"&&(t=this.styles.messageLength);const{badge:s,context:n,date:l,error:a,file:o,groups:d,label:m,message:b,prefix:f,repeated:$,scope:u,suffix:L,traceError:I,type:G}=e,{color:C}=this.loggerTypes[G.name],c=C?Ae[C]:kt,g=d.map(()=>" ").join(""),h=[];if(d.length>0&&h.push(`${g+V(`[${d.at(-1)??""}]`)} `),l&&h.push(`${V(this.styles.dateFormatter(typeof l=="string"?new Date(l):l))} `),s)h.push(c(s));else{const A=this.#a;A.length>0&&h.push(`${V(".".repeat(A.length))} `)}const N=this.#f;if(m){const A=ee(N),R=ee(m);h.push(`${c(Ve(m,this.styles))} `,V(".".repeat(Math.max(0,A-R))))}else h.push(V(".".repeat(N.length+2)));$&&h.push(`${Mt.white(`[${String($)}x]`)} `),Array.isArray(u)&&u.length>0&&h.push(` ${V(`[${u.join(" > ")}]`)} `),f&&h.push(`${V(`${Array.isArray(u)&&u.length>0?". ":" "}[${this.styles.underline.prefix?Ee(f):f}]`)} `);const B=ee(h.join(" "));if(o){const A=(o.name??"")+(o.line?`:${String(o.line)}`:""),R=ee(A);if(R+B+2>t)h.push(V(` ${A}`));else{const M=Math.max(0,t-B-R-2);h.push(V(`${".".repeat(M)} ${A}`))}}else h.push(V(".".repeat(Math.max(0,t-B-1))));if(h.length>0&&h.push(`
22
21
 
23
- `),y!==xe){const O=typeof y=="string"?y:se(y,this.#s);h.push(u+Qe(O,{trim:!1,width:t-3,wrapMode:Xe.STRICT_WIDTH}))}if(i){let O=!1;h.push(...i.map(B=>{if(B instanceof Error)return O=!0,`
22
+ `),b!==ue){const A=typeof b=="string"?b:re(b,this.#s);h.push(g+qe(A,{trim:!1,width:t-3,wrapMode:ze.PRESERVE_WORDS}))}if(n){let A=!1;h.push(...n.map(R=>{if(R instanceof Error)return A=!0,`
24
23
 
25
- ${ne(B,{...this.#n,filterStacktrace:ge,prefix:u})}`;if(typeof B=="object")return` ${se(B,this.#s)}`;const T=(O?`
24
+ ${ie(R,{...this.#n,filterStacktrace:ae,prefix:g})}`;if(typeof R=="object")return` ${re(R,this.#s)}`;const M=(A?`
26
25
 
27
- `:" ")+String(B);return O=!1,T}))}return l&&h.push(ne(l,{...this.#n,filterStacktrace:ge,prefix:u})),D&&h.push(`
26
+ `:" ")+String(R);return A=!1,M}))}return a&&h.push(ie(a,{...this.#n,filterStacktrace:ae,prefix:g})),I&&h.push(`
28
27
 
29
- ${ne(D,{...this.#n,filterStacktrace:ge,hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0,hideMessage:!0,prefix:u})}`),v&&h.push(`
30
- `,u+F(this.styles.underline.suffix?Be(v):v)),h.join("")}_log(e,t){const s=Ie(t)?"stderr":"stdout",i=s==="stderr"?this.#e:this.#r;this.#i&&this.#t!==void 0&&i.isTTY?this.#t.update(s,e.split(`
31
- `),0):Ne(`${e}
32
- `,i)}}const tr=()=>z.NODE_ENV==="debug"||z.DEBUG!==void 0?"debug":z.NODE_ENV==="test"?"warning":"informational",rr=r=>{let e=tr();return z.PAIL_LOG_LEVEL!==void 0&&(e=z.PAIL_LOG_LEVEL),new Ot({logLevel:e,processors:[new Wt],reporters:[new er],stderr:we,stdout:ye,...r})},hr=rr();export{pr as PailError,rr as createPail,mr as createPailError,hr as pail};
28
+ ${ie(I,{...this.#n,filterStacktrace:ae,hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0,hideMessage:!0,prefix:g})}`),L&&h.push(`
29
+ `,g+V(this.styles.underline.suffix?Ee(L):L)),h.join("")}_log(e,t){const s=Me(t)?"stderr":"stdout",n=s==="stderr"?this.#e:this.#t;this.#i&&this.#r!==void 0&&n.isTTY?this.#r.update(s,e.split(`
30
+ `),0):ve(`${e}
31
+ `,n)}}const Rt=()=>K.NODE_ENV==="debug"||K.DEBUG!==void 0?"debug":K.NODE_ENV==="test"?"warning":"informational",Nt=r=>{let e=Rt();return K.PAIL_LOG_LEVEL!==void 0&&(e=K.PAIL_LOG_LEVEL),new ot({logLevel:e,processors:[new Et],reporters:[new jt],stderr:de,stdout:he,...r})},Vt=Nt();export{Jt as PailError,Nt as createPail,Gt as createPailError,Vt as pail};
@@ -1 +1 @@
1
- import{createRequire as p}from"node:module";import{e as y,c as w}from"../packem_shared/headers-DI58djdG.js";let h;const f=e=>(h??=p(import.meta.url))(e),i=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=e=>{if(typeof i<"u"&&i.versions&&i.versions.node){const[s,n]=i.versions.node.split(".").map(Number);if(s>22||s===22&&n>=3||s===20&&n>=16)return i.getBuiltinModule(e)}return f(e)},{AsyncLocalStorage:m}=_("node:async_hooks"),g=new m,c=new WeakSet;let d;const b=e=>{try{return g.enterWith(e),d=void 0,!0}catch(s){return d=s instanceof Error?s.message:String(s),!1}},k=()=>{const e=g.getStore();if(!e||!c.has(e))throw d!==void 0?new Error(`[pail] useLogger() is unavailable here: AsyncLocalStorage.enterWith() was rejected by this runtime with "${d}". Use the \`log\` property on the Elysia handler context instead.`):new Error("[pail] useLogger() called outside of Elysia pail plugin context.");return e},v=(e,s)=>{const n=new WeakMap,l=new WeakSet;return e.derive({as:"global"},({request:r})=>{const o=new URL(r.url),t=r.headers.get("x-request-id")??crypto.randomUUID(),u=y(r.headers),a=w(s,{headers:u,method:r.method,path:o.pathname,requestId:t});return n.set(r,a),a.skipped||(c.add(a.logger),b(a.logger)),{log:a.logger}}).onAfterHandle({as:"global"},async({request:r,set:o})=>{const t=n.get(r);!t?.skipped&&t&&!l.has(r)&&(l.add(r),t.finish({status:o.status??200}),c.delete(t.logger))}).onError({as:"global"},async({error:r,request:o})=>{const t=n.get(o);!t?.skipped&&t&&!l.has(o)&&(l.add(o),t.finish({error:r}),c.delete(t.logger))})};export{v as pailPlugin,k as useLogger};
1
+ import{createRequire as h}from"node:module";import{e as y,c as w}from"../packem_shared/headers-BjUW0cAm.js";let p;const f=e=>(p??=h(import.meta.url))(e),i=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,m=e=>{if(typeof i<"u"&&i.versions&&i.versions.node){const[o,n]=i.versions.node.split(".").map(Number);if(o>22||o===22&&n>=3||o===20&&n>=16)return i.getBuiltinModule(e)}return f(e)},{AsyncLocalStorage:_}=m("node:async_hooks"),g=new _,c=new WeakSet;let d;const b=e=>{try{return g.enterWith(e),d=void 0,!0}catch(o){return d=o instanceof Error?o.message:String(o),!1}},S=()=>{const e=g.getStore();if(!e||!c.has(e))throw d!==void 0?new Error(`[pail] useLogger() is unavailable here: AsyncLocalStorage.enterWith() was rejected by this runtime with "${d}". Use the \`log\` property on the Elysia handler context instead.`):new Error("[pail] useLogger() called outside of Elysia pail plugin context.");return e},j=(e,o)=>{const n=new WeakMap,l=new WeakSet;return e.derive({as:"global"},({request:t})=>{const s=new URL(t.url),r=t.headers.get("x-request-id")??crypto.randomUUID(),u=y(t.headers),a=w(o,{headers:u,method:t.method,path:s.pathname,requestId:r});return n.set(t,a),a.skipped||(c.add(a.logger),b(a.logger)),{log:a.logger}}).onAfterHandle({as:"global"},async({request:t,set:s})=>{const r=n.get(t);!r?.skipped&&r&&!l.has(t)&&(l.add(t),r.finish({status:s.status??200}),c.delete(r.logger))}).onError({as:"global"},async({error:t,request:s})=>{const r=n.get(s);!r?.skipped&&r&&!l.has(s)&&(l.add(s),r.finish({error:t}),c.delete(r.logger))})};export{j as pailPlugin,S as useLogger};
@@ -1 +1 @@
1
- import{a as p,c as u}from"../packem_shared/headers-DI58djdG.js";import{c}from"../packem_shared/storage-DVcJumyk.js";const o=c("Express middleware context. Make sure pail middleware is registered before your route handlers."),f=()=>o.useLogger(),w=t=>(e,r,s)=>{const d=e.headers["x-request-id"]??crypto.randomUUID(),i=(e.originalUrl??e.url??"/").split("?")[0],g=p(e.headers),{finish:l,logger:a,skipped:n}=u(t,{headers:g,method:e.method,path:i,requestId:d});if(n){s();return}e.log=a,r.on("finish",()=>{l({status:r.statusCode})}),o.storage.run(a,()=>{s()})};export{w as pailMiddleware,f as useLogger};
1
+ import{a as n,c as p}from"../packem_shared/headers-BjUW0cAm.js";import{c as h}from"../packem_shared/storage-DP9QMOmG.js";const s=h("Express middleware context. Make sure pail middleware is registered before your route handlers."),w=()=>s.useLogger(),U=t=>(e,r,o)=>{const d=e.headers["x-request-id"]??crypto.randomUUID(),i=(e.originalUrl??e.url??"/").split("?")[0],g=n(e.headers),{finish:l,logger:a,skipped:c}=p(t,{headers:g,method:e.method,path:i,requestId:d});if(c){o();return}e.log=a,r.on("finish",()=>{l({status:r.statusCode})}),s.storage.run(a,()=>{o()})};export{U as pailMiddleware,w as useLogger};
@@ -1 +1 @@
1
- import{a as h,c as f}from"../packem_shared/headers-DI58djdG.js";import{c as l}from"../packem_shared/storage-DVcJumyk.js";const i=l("Fastify middleware context. Make sure pail plugin is registered before your route handlers."),y=()=>i.useLogger(),w=(o,g)=>{const t=new WeakMap,s=new WeakSet;o.addHook("onRequest",(e,d,r)=>{const a=e.headers["x-request-id"]??crypto.randomUUID(),c=h(e.headers),{finish:u,logger:n,skipped:p}=f(g,{headers:c,method:e.method,path:e.url.split("?")[0],requestId:a});if(p){r();return}e.log=n,t.set(e,{finish:u}),i.storage.run(n,()=>{r()})}),o.addHook("onResponse",async(e,d)=>{const r=t.get(e);!r||s.has(e)||(s.add(e),r.finish({status:d.statusCode}))}),o.addHook("onError",async(e,d,r)=>{const a=t.get(e);!a||s.has(e)||(s.add(e),a.finish({error:r}))})};export{w as pailPlugin,y as useLogger};
1
+ import{a as h,c as m}from"../packem_shared/headers-BjUW0cAm.js";import{c as u}from"../packem_shared/storage-DP9QMOmG.js";const i=u("Fastify middleware context. Make sure pail plugin is registered before your route handlers."),y=()=>i.useLogger(),H=(r,g)=>{const s=new WeakMap,t=new WeakSet;r.addHook("onRequest",(e,d,o)=>{const a=e.headers["x-request-id"]??crypto.randomUUID(),c=h(e.headers),{finish:p,logger:n,skipped:l}=m(g,{headers:c,method:e.method,path:e.url.split("?")[0],requestId:a});if(l){o();return}e.log=n,s.set(e,{finish:p}),i.storage.run(n,()=>{o()})}),r.addHook("onResponse",async(e,d)=>{const o=s.get(e);!o||t.has(e)||(t.add(e),o.finish({status:d.statusCode}))}),r.addHook("onError",async(e,d,o)=>{const a=s.get(e);!a||t.has(e)||(t.add(e),a.finish({error:o}))})};export{H as pailPlugin,y as useLogger};
@@ -1 +1 @@
1
- import{e as c,c as g}from"../packem_shared/headers-DI58djdG.js";const l=t=>{const r=t.get("log");if(!r)throw new Error("[pail] useLogger() called but pail middleware is not registered.");return r},p=t=>async(r,a)=>{const o=r.req.header("x-request-id")??crypto.randomUUID(),i=c(r.req.raw.headers),{finish:s,logger:d,skipped:n}=g(t,{headers:i,method:r.req.method,path:r.req.path,requestId:o});if(n){await a();return}r.set("log",d);try{await a(),s({status:r.res.status})}catch(e){throw s({error:e instanceof Error?e:new Error(String(e))}),e}};export{p as pailMiddleware,l as useLogger};
1
+ import{e as g,c as l}from"../packem_shared/headers-BjUW0cAm.js";const c=t=>{const e=t.get("log");if(!e)throw new Error("[pail] useLogger() called but pail middleware is not registered.");return e},p=t=>async(e,a)=>{const s=e.req.header("x-request-id")??crypto.randomUUID(),d=g(e.req.raw.headers),{finish:o,logger:i,skipped:n}=l(t,{headers:d,method:e.req.method,path:e.req.path,requestId:s});if(n){await a();return}e.set("log",i);try{await a(),o({status:e.res.status})}catch(r){throw o({error:r instanceof Error?r:new Error(String(r))}),r}};export{p as pailMiddleware,c as useLogger};
@@ -1,6 +1,5 @@
1
1
  import { P as PailMiddlewareOptions } from "../../packem_shared/create-middleware-logger.d-BRkkBMlk.js";
2
2
  import { W as WideEvent } from "../../packem_shared/wide-event.d-BMLastMR.js";
3
- import 'node:async_hooks';
4
3
  import "../../packem_shared/types.d-4ge_rME4.js";
5
4
  import '@visulima/colorize';
6
5
  import '@visulima/interactive-manager';
@@ -1 +1 @@
1
- import{e as m,c as l}from"../../packem_shared/headers-DI58djdG.js";import{pailStorage as w}from"../../packem_shared/useLogger-7p55yvvc.js";import{useLogger as N}from"../../packem_shared/useLogger-7p55yvvc.js";import{pailMiddleware as S}from"../../packem_shared/pailMiddleware-B5DJoBYl.js";const q=u=>s=>async(...a)=>{const[o]=a,f=o instanceof Request;let n="UNKNOWN",i="/",c=crypto.randomUUID(),d={};if(f){const e=o,t=new URL(e.url);n=e.method,i=t.pathname,d=m(e.headers);const r=e.headers.get("x-request-id");r&&(c=r)}const{finish:p,logger:h,skipped:g}=l(u,{headers:d,method:n,path:i,requestId:c});if(g)return s(...a);try{const e=await w.run(h,()=>s(...a)),t=e instanceof Response?e.status:200;return p({status:t}),e}catch(e){const t=e instanceof Error?e:new Error(String(e)),r=t.status??t.statusCode??500;throw p({error:t,status:r}),e}};export{q as createWithPail,S as pailMiddleware,N as useLogger};
1
+ import{e as h,c as g}from"../../packem_shared/headers-BjUW0cAm.js";import{pailStorage as w}from"../../packem_shared/useLogger-HtOIBW7n.js";import{useLogger as U}from"../../packem_shared/useLogger-HtOIBW7n.js";import{pailMiddleware as L}from"../../packem_shared/pailMiddleware-lhLj-hzE.js";const R=f=>(o=>async(...s)=>{const[a]=s,l=a instanceof Request;let n="UNKNOWN",c="/",i=crypto.randomUUID(),u={};if(l){const e=a,t=new URL(e.url);n=e.method,c=t.pathname,u=h(e.headers);const r=e.headers.get("x-request-id");r&&(i=r)}const{finish:d,logger:p,skipped:m}=g(f,{headers:u,method:n,path:c,requestId:i});if(m)return o(...s);try{const e=await w.run(p,()=>o(...s)),t=e instanceof Response?e.status:200;return d({status:t}),e}catch(e){const t=e instanceof Error?e:new Error(String(e)),r=t.status??t.statusCode??500;throw d({error:t,status:r}),e}});export{R as createWithPail,L as pailMiddleware,U as useLogger};
@@ -1 +1 @@
1
- import{e as g,c as i}from"../packem_shared/headers-DI58djdG.js";import{c as u}from"../packem_shared/storage-DVcJumyk.js";const n=u("SvelteKit handle hook context. Make sure pailHandle is added to your hooks.server.ts."),k=()=>n.useLogger(),h=r=>async({event:e,resolve:a})=>{const d=e.request.headers.get("x-request-id")??crypto.randomUUID(),l=g(e.request.headers),{finish:t,logger:s,skipped:c}=i(r,{headers:l,method:e.request.method,path:e.url.pathname,requestId:d});return c?a(e):(e.locals.log=s,n.storage.run(s,async()=>{try{const o=await a(e);return t({status:o.status}),o}catch(o){throw t({error:o instanceof Error?o:new Error(String(o))}),o}}))},p=()=>({error:r,event:e})=>{const a=e.locals.log;a&&r instanceof Error&&a.error(r.message,r)},q=r=>({handle:h(r),handleError:p()});export{q as createPailHooks,h as pailHandle,p as pailHandleError,k as useLogger};
1
+ import{e as l,c as i}from"../packem_shared/headers-BjUW0cAm.js";import{c as u}from"../packem_shared/storage-DP9QMOmG.js";const n=u("SvelteKit handle hook context. Make sure pailHandle is added to your hooks.server.ts."),H=()=>n.useLogger(),h=e=>async({event:r,resolve:s})=>{const c=r.request.headers.get("x-request-id")??crypto.randomUUID(),d=l(r.request.headers),{finish:t,logger:a,skipped:g}=i(e,{headers:d,method:r.request.method,path:r.url.pathname,requestId:c});return g?s(r):(r.locals.log=a,n.storage.run(a,async()=>{try{const o=await s(r);return t({status:o.status}),o}catch(o){throw t({error:o instanceof Error?o:new Error(String(o))}),o}}))},p=()=>({error:e,event:r})=>{const s=r.locals.log;s&&e instanceof Error&&s.error(e.message,e)},k=e=>({handle:h(e),handleError:p()});export{k as createPailHooks,h as pailHandle,p as pailHandleError,H as useLogger};
@@ -1,2 +1,2 @@
1
- const w=n=>{const o={breakCircularWith:" (circular ref.)",joined:!0,keyNeighbour:"├─ ",keyNoNeighbour:"└─ ",renderFn:r=>{if(["boolean","number","string"].includes(typeof r))return String(r)},separator:": ",sortFn:void 0,spacerNeighbour:"│ ",spacerNoNeighbour:" ",...n};if(typeof o.joined!="boolean")throw new TypeError('Option "joined" must be a boolean');if(typeof o.spacerNoNeighbour!="string")throw new TypeError('Option "spacerNoNeighbour" must be a string');if(typeof o.spacerNeighbour!="string")throw new TypeError('Option "spacerNeighbour" must be a string');if(typeof o.keyNoNeighbour!="string")throw new TypeError('Option "keyNoNeighbour" must be a string');if(typeof o.keyNeighbour!="string")throw new TypeError('Option "keyNeighbour" must be a string');if(typeof o.separator!="string")throw new TypeError('Option "separator" must be a string');if(typeof o.renderFn!="function")throw new TypeError('Option "renderFn" must be a function');if(o.sortFn!==void 0&&typeof o.sortFn!="function")throw new TypeError('Option "sortFn" must be a function or undefined');if(o.breakCircularWith!==null&&typeof o.breakCircularWith!="string")throw new TypeError('Option "breakCircularWith" must be a string or null');return o},k=(n,o)=>{const r=w(o),s=[],b=r.renderFn(n);b!==void 0&&s.push(b);const g=e=>r.sortFn===void 0?e:e.toSorted((t,u)=>r.sortFn?.(u,t)??0),a=[],i=g(Object.keys(n)).map(e=>[e]),p=[n];for(;i.length>0;){const e=i.pop()??[],t=p[e.length-1][e.at(-1)??""],u=r.breakCircularWith!==null&&p.slice(0,e.length).includes(t);a[e.length-1]=i.length>0&&(i.at(-1)?.length??0)===e.length;const l=a.slice(0,e.length-1).map(h=>h?r.spacerNeighbour:r.spacerNoNeighbour).join(""),y=a[e.length-1]?r.keyNeighbour:r.keyNoNeighbour,f=e.at(-1)??"",c=r.renderFn(t),N=c===void 0?"":`${r.separator}${c}`,d=u?r.breakCircularWith??"":"";s.push(`${l}${y}${f}${N}${d}`),t!==null&&typeof t=="object"&&!Array.isArray(t)&&!u&&(i.push(...g(Object.keys(t)).map(h=>[...e,h])),p[e.length]=t)}return r.joined?s.join(`
2
- `):s};export{k as default,k as renderObjectTree};
1
+ const k=n=>{const o={breakCircularWith:" (circular ref.)",joined:!0,keyNeighbour:"├─ ",keyNoNeighbour:"└─ ",renderFn:r=>{if(["boolean","number","string"].includes(typeof r))return String(r)},separator:": ",sortFn:void 0,spacerNeighbour:"│ ",spacerNoNeighbour:" ",...n};if(typeof o.joined!="boolean")throw new TypeError('Option "joined" must be a boolean');if(typeof o.spacerNoNeighbour!="string")throw new TypeError('Option "spacerNoNeighbour" must be a string');if(typeof o.spacerNeighbour!="string")throw new TypeError('Option "spacerNeighbour" must be a string');if(typeof o.keyNoNeighbour!="string")throw new TypeError('Option "keyNoNeighbour" must be a string');if(typeof o.keyNeighbour!="string")throw new TypeError('Option "keyNeighbour" must be a string');if(typeof o.separator!="string")throw new TypeError('Option "separator" must be a string');if(typeof o.renderFn!="function")throw new TypeError('Option "renderFn" must be a function');if(o.sortFn!==void 0&&typeof o.sortFn!="function")throw new TypeError('Option "sortFn" must be a function or undefined');if(o.breakCircularWith!==null&&typeof o.breakCircularWith!="string")throw new TypeError('Option "breakCircularWith" must be a string or null');return o},w=(n,o)=>{const r=k(o),s=[],h=r.renderFn(n);h!==void 0&&s.push(h);const b=e=>r.sortFn===void 0?e:e.toSorted((t,u)=>r.sortFn?.(u,t)??0),a=[],i=b(Object.keys(n)).map(e=>[e]),c=[n];for(;i.length>0;){const e=i.pop()??[],t=c[e.length-1][e.at(-1)??""],u=r.breakCircularWith!==null&&c.slice(0,e.length).includes(t);a[e.length-1]=i.length>0&&(i.at(-1)?.length??0)===e.length;const l=a.slice(0,e.length-1).map(p=>p?r.spacerNeighbour:r.spacerNoNeighbour).join(""),y=a[e.length-1]?r.keyNeighbour:r.keyNoNeighbour,f=e.at(-1)??"",g=r.renderFn(t),d=g===void 0?"":`${r.separator}${g}`,N=u?r.breakCircularWith??"":"";s.push(`${l}${y}${f}${d}${N}`),t!==null&&typeof t=="object"&&!Array.isArray(t)&&!u&&(i.push(...b(Object.keys(t)).map(p=>[...e,p])),c[e.length]=t)}return r.joined?s.join(`
2
+ `):s};export{w as default,w as renderObjectTree};
@@ -0,0 +1 @@
1
+ import{g as c}from"./serializeError-Kr3JL9UN-zwOuO-gY.js";import{E as g}from"./constants-ep2nsfdy.js";class u{stringify;errorOptions;constructor(t={}){this.errorOptions=t.error??{}}setStringify(t){this.stringify=t}log(t){const{context:o,error:l,file:e,message:f,type:m,...r}=t;if(r.label&&(r.label=r.label.trim()),e&&(r.file=`${e.name??""}:${String(e.line)}${e.column?`:${String(e.column)}`:""}`),r.message=f===g?void 0:f,l&&(r.error=c(l,this.errorOptions)),o){const s=[];for(let n=0;n<o.length;n+=1){const i=o[n];i!==g&&(i instanceof Error?s.push(c(i,this.errorOptions)):s.push(i))}r.context=s}this._log(this.stringify(r),m.level)}}export{u as AbstractJsonReporter};
@@ -0,0 +1 @@
1
+ import{E as m}from"./constants-DKfCaSUR.js";const g=Object.create({},{cause:{enumerable:!1,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},errors:{enumerable:!1,value:void 0,writable:!0},message:{enumerable:!1,value:void 0,writable:!0},name:{enumerable:!1,value:void 0,writable:!0},stack:{enumerable:!1,value:void 0,writable:!0}}),d=e=>{if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return r===null||r===Object.prototype||Object.getPrototypeOf(r)===null},p=new WeakSet,v=e=>{if(Object.hasOwn(e,"name")&&typeof e.name=="string"&&e.name!=="")return e.name;const r=e.constructor?.name;return typeof r=="string"&&r!==""?r:e.name},O=e=>{const r=Object.getOwnPropertyNames(e);for(const n of r){const t=Object.getOwnPropertyDescriptor(e,n);t&&(t.enumerable||Object.defineProperty(e,n,{...t,enumerable:!0}),t.value&&typeof t.value=="object"&&!Array.isArray(t.value)&&(Object.getPrototypeOf(t.value)===Object.prototype||Object.getPrototypeOf(t.value)===null)&&O(t.value))}},h=e=>{p.add(e);const r=e.toJSON();return p.delete(e),Object.isExtensible(r)&&O(r),r},s=(e,r,n,t,o=new Set)=>{if(e&&e instanceof Uint8Array&&e.constructor.name==="Buffer")return"[object Buffer]";if(e!==null&&typeof e=="object"&&"pipe"in e&&typeof e.pipe=="function")return"[object Stream]";if(e instanceof Error)return r.has(e)?"[Circular]":(n+=1,f(e,t,r,n));if(t.useToJSON&&e!==null&&typeof e=="object"&&"toJSON"in e&&typeof e.toJSON=="function")return e.toJSON();if(e instanceof Date)return e.toISOString();if(e instanceof RegExp)return e.toString();if(typeof URL<"u"&&e instanceof URL)return e.href;if(e instanceof Map){const u=[];for(const[a,i]of e.entries())u.push([s(a,r,n,t,o),s(i,r,n,t,o)]);return{__dataType:"Map",value:u}}if(e instanceof Set){const u=[];for(const a of e.values())u.push(s(a,r,n,t,o));return{__dataType:"Set",value:u}}if(typeof e=="function")return`[Function: ${e.name||"anonymous"}]`;if(typeof e=="bigint")return`${String(e)}n`;if(d(e)){if(o.has(e))return"[Circular]";if(t.maxDepth!==void 0&&t.maxDepth!==Number.POSITIVE_INFINITY&&n+1>=t.maxDepth)return{};n+=1,o.add(e);const u={};for(const a in e)u[a]=s(e[a],r,n,t,o);return o.delete(e),u}try{return e}catch{return"[Not Available]"}},f=(e,r,n,t)=>{if(n.add(e),r.maxDepth===0)return{};if(r.useToJSON&&typeof e.toJSON=="function"&&!p.has(e))return h(e);const o=Object.create(g);if(Object.defineProperty(o,"name",{configurable:!0,enumerable:!0,value:v(e),writable:!0}),Object.defineProperty(o,"message",{configurable:!0,enumerable:!0,value:e.message,writable:!0}),Object.defineProperty(o,"stack",{configurable:!0,enumerable:!0,value:e.stack,writable:!0}),Array.isArray(e.errors)){const a=[];for(const i of e.errors){if(!(i instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(n.has(i))return Object.defineProperty(o,"errors",{configurable:!0,enumerable:!0,value:[],writable:!0}),o;a.push(f(i,r,n,t))}Object.defineProperty(o,"errors",{configurable:!0,enumerable:!0,value:a,writable:!0})}const u=e.cause;if(u!=null)if(u instanceof Error)n.has(u)?Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:"[Circular]",writable:!0}):Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:f(u,r,n,t),writable:!0});else{const a=s(u,n,t,r);Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:a,writable:!0})}for(const a in e){if(a==="name"||a==="message"||a==="stack"||a==="cause"||a==="errors")continue;const i=e[a],c=s(i,n,t,r);Object.defineProperty(o,a,{configurable:!0,enumerable:!0,value:c,writable:!0})}if(Array.isArray(r.exclude)&&r.exclude.length>0)for(const a of r.exclude)try{delete o[a]}catch{}return o},y=(e,r={})=>f(e,{exclude:r.exclude??[],maxDepth:r.maxDepth??Number.POSITIVE_INFINITY,useToJSON:r.useToJSON??!1},new Set,0);class S{stringify;errorOptions;constructor(r={}){this.errorOptions=r.error??{}}setStringify(r){this.stringify=r}log(r){const{context:n,error:t,file:o,message:u,type:a,...i}=r;if(i.label&&(i.label=i.label.trim()),o&&(i.file=`${o.name??""}:${String(o.line)}${o.column?`:${String(o.column)}`:""}`),i.message=u===m?void 0:u,t&&(i.error=y(t,this.errorOptions)),n){const c=[];for(let b=0;b<n.length;b+=1){const l=n[b];l!==m&&(l instanceof Error?c.push(y(l,this.errorOptions)):c.push(l))}i.context=c}this._log(this.stringify(i),a.level)}}export{S as AbstractJsonReporter};
@@ -0,0 +1,2 @@
1
+ import{createRequire as p}from"node:module";import{AbstractJsonReporter as o}from"./AbstractJsonReporter-DPsVS6w5.js";import{i as a,w as d}from"./write-stream-D2XwCKdN.js";const r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{stdout:i,stderr:c}=r;class h extends o{#e;#t;constructor(e={}){super(e),this.#e=i,this.#t=c}setStdout(e){this.#e=e}setStderr(e){this.#t=e}_log(e,t){const s=a(t)?this.#t:this.#e;d(`${e}
2
+ `,s)}}export{h as default};