@visulima/pail 4.0.2 → 4.1.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 (83) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/LICENSE.md +346 -0
  3. package/README.md +17 -0
  4. package/dist/error.d.ts +69 -69
  5. package/dist/index.browser.d.ts +446 -445
  6. package/dist/index.browser.js +17 -17
  7. package/dist/index.server.d.ts +582 -582
  8. package/dist/index.server.js +27 -27
  9. package/dist/middleware/elysia.d.ts +44 -42
  10. package/dist/middleware/elysia.js +1 -1
  11. package/dist/middleware/express.d.ts +58 -59
  12. package/dist/middleware/express.js +1 -1
  13. package/dist/middleware/fastify.d.ts +55 -56
  14. package/dist/middleware/fastify.js +1 -1
  15. package/dist/middleware/hono.d.ts +56 -57
  16. package/dist/middleware/hono.js +1 -1
  17. package/dist/middleware/next/handler.d.ts +67 -68
  18. package/dist/middleware/next/handler.js +1 -1
  19. package/dist/middleware/sveltekit.d.ts +72 -73
  20. package/dist/middleware/sveltekit.js +1 -1
  21. package/dist/object-tree.d.ts +44 -44
  22. package/dist/packem_shared/AbstractJsonReporter-BpWRnN0L.js +1 -0
  23. package/dist/packem_shared/AbstractJsonReporter-DxZwImm5.js +1 -0
  24. package/dist/packem_shared/JsonReporter-9IcELa1m.js +2 -0
  25. package/dist/packem_shared/JsonReporter-Dd3kuj8X.js +1 -0
  26. package/dist/packem_shared/{PrettyReporter-DsHfKOU7.js → PrettyReporter-BUWNEg3_.js} +1 -1
  27. package/dist/packem_shared/{PrettyReporter-CcDdPQSt.js → PrettyReporter-DbgD89ck.js} +56 -30
  28. package/dist/packem_shared/abstract-json-reporter.d-B6NoO-hG.d.ts +61 -0
  29. package/dist/packem_shared/{abstract-pretty-reporter-DrLBJ6ds.js → abstract-pretty-reporter-CyfTvmKf.js} +41 -39
  30. package/dist/packem_shared/create-middleware-logger.d-BRkkBMlk.d.ts +47 -0
  31. package/dist/packem_shared/headers-DI58djdG.js +1 -0
  32. package/dist/packem_shared/index-CbkPnylC.js +1 -0
  33. package/dist/packem_shared/serializeError-52C4oiKx-CrnRcq9R.js +1 -0
  34. package/dist/packem_shared/storage-DVcJumyk.js +1 -0
  35. package/dist/packem_shared/types.d-4ge_rME4.d.ts +246 -0
  36. package/dist/packem_shared/{types.d-Cz9S7jZh.d.ts → types.d-BW8kAXUv.d.ts} +95 -95
  37. package/dist/packem_shared/types.d-DGHeA2iJ.d.ts +194 -0
  38. package/dist/packem_shared/useLogger-7p55yvvc.js +1 -0
  39. package/dist/packem_shared/wide-event.d-BMLastMR.d.ts +716 -0
  40. package/dist/packem_shared/write-stream-ytl_vhg_.js +1 -0
  41. package/dist/processor/caller/caller-processor.d.ts +32 -33
  42. package/dist/processor/environment-processor.d.ts +83 -84
  43. package/dist/processor/message-formatter-processor.d.ts +40 -45
  44. package/dist/processor/message-formatter-processor.js +1 -1
  45. package/dist/processor/opentelemetry-processor.d.ts +51 -52
  46. package/dist/processor/redact-processor.d.ts +57 -65
  47. package/dist/processor/sampling-processor.d.ts +90 -91
  48. package/dist/reporter/file/json-file-reporter.d.ts +77 -78
  49. package/dist/reporter/file/json-file-reporter.js +1 -1
  50. package/dist/reporter/http/abstract-http-reporter.d.ts +125 -121
  51. package/dist/reporter/http/abstract-http-reporter.js +2 -2
  52. package/dist/reporter/http/http-reporter.d.ts +33 -34
  53. package/dist/reporter/http/http-reporter.edge-light.d.ts +235 -230
  54. package/dist/reporter/http/http-reporter.edge-light.js +2 -2
  55. package/dist/reporter/json/index.browser.d.ts +62 -61
  56. package/dist/reporter/json/index.browser.js +1 -1
  57. package/dist/reporter/json/index.d.ts +36 -37
  58. package/dist/reporter/json/index.js +1 -1
  59. package/dist/reporter/pretty/index.browser.d.ts +57 -56
  60. package/dist/reporter/pretty/index.browser.js +1 -1
  61. package/dist/reporter/pretty/index.d.ts +133 -133
  62. package/dist/reporter/pretty/index.js +1 -1
  63. package/dist/reporter/simple/simple-reporter.server.d.ts +91 -90
  64. package/dist/reporter/simple/simple-reporter.server.js +7 -7
  65. package/dist/wide-event.d.ts +2 -3
  66. package/dist/wide-event.js +1 -1
  67. package/package.json +58 -37
  68. package/dist/packem_shared/AbstractJsonReporter-Bp_JCrMQ.js +0 -1
  69. package/dist/packem_shared/AbstractJsonReporter-w_bGGiD-.js +0 -1
  70. package/dist/packem_shared/JsonReporter-Sd_lJGS-.js +0 -2
  71. package/dist/packem_shared/JsonReporter-bmem9lcg.js +0 -1
  72. package/dist/packem_shared/abstract-json-reporter.d-wfESoEa-.d.ts +0 -62
  73. package/dist/packem_shared/addKnownErrorConstructor-C1OJTj2D-0FlJMfXz.js +0 -25
  74. package/dist/packem_shared/create-middleware-logger.d-B-JmQ1Sl.d.ts +0 -47
  75. package/dist/packem_shared/headers-DH0H2s8W.js +0 -1
  76. package/dist/packem_shared/index-Q1764hvO.js +0 -1
  77. package/dist/packem_shared/serializeError-C-NFvZ8_-D0CA_Qlx.js +0 -1
  78. package/dist/packem_shared/storage-DaXAlpiO.js +0 -1
  79. package/dist/packem_shared/types.d-bWnqHJKL.d.ts +0 -211
  80. package/dist/packem_shared/types.d-xxE3FOD3.d.ts +0 -229
  81. package/dist/packem_shared/useLogger-DB34CuU5.js +0 -1
  82. package/dist/packem_shared/wide-event.d-D3ATYpoK.d.ts +0 -717
  83. package/dist/packem_shared/write-stream-C7jxLxIT.js +0 -1
@@ -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-Q1764hvO.js";import le from"./packem_shared/JsonReporter-bmem9lcg.js";import{PailError as xe,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 y(i){return i.length<5e3&&!a.test(i)?`"${i}"`:JSON.stringify(i)}function S(i,o){if(i.length>200||o)return i.sort(o);for(let h=1;h<i.length;h++){const N=i[h];let E=h;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 T(i,o,h){i.length<h&&(h=i.length);const N=o===","?"":" ";let E=`"0":${N}${i[0]}`;for(let D=1;D<h;D++)E+=`${o}"${D}":${N}${i[D]}`;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 h;if(s.call(i,o)&&(h=i[o],typeof h!="boolean"))throw new TypeError(`The "${o}" argument must be of type boolean`);return h===void 0?!0:h}function C(i,o){let h;if(s.call(i,o)){if(h=i[o],typeof h!="number")throw new TypeError(`The "${o}" argument must be of type number`);if(!Number.isInteger(h))throw new TypeError(`The "${o}" argument must be an integer`);if(h<1)throw new RangeError(`The "${o}" argument must be >= 1`)}return h===void 0?1/0:h}function R(i){return i===1?"1 item":`${i} items`}function I(i){const o=new Set;for(const h of i)(typeof h=="string"||typeof h=="number")&&o.add(String(h));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 h=>{let N=`Object can not safely be stringified. Received type ${typeof h}`;throw typeof h!="function"&&(N+=` (${h.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 h=k(i),N=F(i,"bigint"),E=A(i),D=typeof E=="function"?E:void 0,V=C(i,"maximumDepth"),b=C(i,"maximumBreadth");function q(O,t,n,f,g,p){let l=t[O];switch(typeof l=="object"&&l!==null&&typeof l.toJSON=="function"&&(l=l.toJSON(O)),l=f.call(t,O,l),typeof l){case"string":return y(l);case"object":{if(l===null)return"null";if(n.indexOf(l)!==-1)return h;let u="",v=",";const w=p;if(Array.isArray(l)){if(l.length===0)return"[]";if(V<n.length+1)return'"[Array]"';n.push(l),g!==""&&(p+=g,u+=`
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
2
  ${p}`,v=`,
3
- ${p}`);const j=Math.min(l.length,b);let _=0;for(;_<j-1;_++){const G=q(String(_),l,n,f,g,p);u+=G!==void 0?G:"null",u+=v}const J=q(String(_),l,n,f,g,p);if(u+=J!==void 0?J:"null",l.length-1>b){const G=l.length-b-1;u+=`${v}"... ${R(G)} not stringified"`}return g!==""&&(u+=`
4
- ${w}`),n.pop(),`[${u}]`}let m=Object.keys(l);const L=m.length;if(L===0)return"{}";if(V<n.length+1)return'"[Object]"';let d="",M="";g!==""&&(p+=g,v=`,
5
- ${p}`,d=" ");const P=Math.min(L,b);E&&!$(l)&&(m=S(m,D)),n.push(l);for(let j=0;j<P;j++){const _=m[j],J=q(_,l,n,f,g,p);J!==void 0&&(u+=`${M}${y(_)}:${d}${J}`,M=v)}if(L>b){const j=L-b;u+=`${M}"...":${d}"${R(j)} not stringified"`,M=v}return g!==""&&M.length>1&&(u=`
6
- ${p}${u}
7
- ${w}`),n.pop(),`{${u}}`}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(O,t,n,f,g,p){switch(typeof t=="object"&&t!==null&&typeof t.toJSON=="function"&&(t=t.toJSON(O)),typeof t){case"string":return y(t);case"object":{if(t===null)return"null";if(n.indexOf(t)!==-1)return h;const l=p;let u="",v=",";if(Array.isArray(t)){if(t.length===0)return"[]";if(V<n.length+1)return'"[Array]"';n.push(t),g!==""&&(p+=g,u+=`
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
8
  ${p}`,v=`,
9
- ${p}`);const L=Math.min(t.length,b);let d=0;for(;d<L-1;d++){const P=Q(String(d),t[d],n,f,g,p);u+=P!==void 0?P:"null",u+=v}const M=Q(String(d),t[d],n,f,g,p);if(u+=M!==void 0?M:"null",t.length-1>b){const P=t.length-b-1;u+=`${v}"... ${R(P)} not stringified"`}return g!==""&&(u+=`
10
- ${l}`),n.pop(),`[${u}]`}n.push(t);let w="";g!==""&&(p+=g,v=`,
11
- ${p}`,w=" ");let m="";for(const L of f){const d=Q(L,t[L],n,f,g,p);d!==void 0&&(u+=`${m}${y(L)}:${w}${d}`,m=v)}return g!==""&&m.length>1&&(u=`
12
- ${p}${u}
13
- ${l}`),n.pop(),`{${u}}`}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 z(O,t,n,f,g){switch(typeof t){case"string":return y(t);case"object":{if(t===null)return"null";if(typeof t.toJSON=="function"){if(t=t.toJSON(O),typeof t!="object")return z(O,t,n,f,g);if(t===null)return"null"}if(n.indexOf(t)!==-1)return h;const p=g;if(Array.isArray(t)){if(t.length===0)return"[]";if(V<n.length+1)return'"[Array]"';n.push(t),g+=f;let d=`
14
- ${g}`;const M=`,
15
- ${g}`,P=Math.min(t.length,b);let j=0;for(;j<P-1;j++){const J=z(String(j),t[j],n,f,g);d+=J!==void 0?J:"null",d+=M}const _=z(String(j),t[j],n,f,g);if(d+=_!==void 0?_:"null",t.length-1>b){const J=t.length-b-1;d+=`${M}"... ${R(J)} not stringified"`}return d+=`
16
- ${p}`,n.pop(),`[${d}]`}let l=Object.keys(t);const u=l.length;if(u===0)return"{}";if(V<n.length+1)return'"[Object]"';g+=f;const v=`,
17
- ${g}`;let w="",m="",L=Math.min(u,b);$(t)&&(w+=T(t,v,b),l=l.slice(t.length),L-=t.length,m=v),E&&(l=S(l,D)),n.push(t);for(let d=0;d<L;d++){const M=l[d],P=z(M,t[M],n,f,g);P!==void 0&&(w+=`${m}${y(M)}: ${P}`,m=v)}if(u>b){const d=u-b;w+=`${m}"...": "${R(d)} not stringified"`,m=v}return m!==""&&(w=`
18
- ${g}${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(O,t,n){switch(typeof t){case"string":return y(t);case"object":{if(t===null)return"null";if(typeof t.toJSON=="function"){if(t=t.toJSON(O),typeof t!="object")return B(O,t,n);if(t===null)return"null"}if(n.indexOf(t)!==-1)return h;let f="";const g=t.length!==void 0;if(g&&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 m=0;for(;m<w-1;m++){const d=B(String(m),t[m],n);f+=d!==void 0?d:"null",f+=","}const L=B(String(m),t[m],n);if(f+=L!==void 0?L:"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 u="",v=Math.min(l,b);g&&$(t)&&(f+=T(t,",",b),p=p.slice(t.length),v-=t.length,u=","),E&&(p=S(p,D)),n.push(t);for(let w=0;w<v;w++){const m=p[w],L=B(m,t[m],n);L!==void 0&&(f+=`${u}${y(m)}:${L}`,u=",")}if(l>b){const w=l-b;f+=`${u}"...":"${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(O,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("",{"":O},[],t,f,"");if(Array.isArray(t))return Q("",O,[],I(t),f,"")}if(f.length!==0)return z("",O,[],f,"")}return B("",O,[])}return te}})(Y,Y.exports)),Y.exports}var ce=ae();class ge{#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 ue{log(e){const{context:s=[],message:r,type:a}=e;oe(a.level)(r,...s)}}class he{#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.#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,y=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=y&&!e.logLevels?y:{...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 he((S,c,$,...T)=>{this.logger(S,c,$,...T)},this.startTimerMessage,this.endTimerMessage),this.counterManager=new ge((S,c,$,...T)=>{this.logger(S,c,$,...T)}),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 ue),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)console[`__${e}`]||(console[`__${e}`]=console[e]),console[e]=this[e]}restoreConsole(){for(const e in this.types)console[`__${e}`]&&(console[e]=console[`__${e}`],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:y}=e[s];this.logger(y,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){const s=e?.types!==void 0,r=s?Z(this.types,e.types):this.types,a=e?.reporters??[],y=a.length>0?[...this.reporters,...a]:[...this.reporters],S=e?.processors??[],c=S.length>0?[...this.processors,...S]:[...this.processors],$=e?.logLevels?{...this.logLevels,...e.logLevels}:this.logLevels;let T;if(e?.scope){const F=K(e.scope).filter(Boolean);T=this.scopeName.length>0?[...this.scopeName,...F]:F}else T=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:y,scope:T,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,new W(A)}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})}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:y,message:S,prefix:c,suffix:$}=r[0];if(y&&(a.context=y),c&&(a.prefix=c),$&&(a.suffix=$),a.message=S,r.length>1){const T=r.slice(1);a.context?a.context=Array.isArray(a.context)?[...a.context,...T]:[a.context,...T]:a.context=T}}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 y=this.types[e],S=this.#o(y.logLevel);if(r||this.logLevels[S]>=this.logLevels[this.generalLogLevel]){let c=this.#n(e,y,...a),$;try{$=JSON.stringify([c.label,c.scope,c.type,c.message,c.prefix,c.suffix,c.context])}catch{$=void 0}const T=this.processors.size>0,k=(C=!1)=>{const R=(this.lastLog.count??0)-this.throttleMin;if(this.lastLog.object&&R>0){const I={...this.lastLog.object};R>1&&(I.repeated=R),this.#r(I,s),this.lastLog.count=1}if(C){for(const I of this.processors)c=I.process(c);if(c.dropped===!0)return;if(this.lastLog.object=c,T)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 C=$;if(this.lastLog.object&&C!==void 0&&C===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;class de{#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}));const s=this.#s;return e.message!==void 0&&(e.message=this.#i(s,e.message,e.context??[])),e}#i(e,s,r=[]){if(typeof s=="string")return e(s,r);if(typeof s=="object"&&s!==null){const a=s,y=Object.keys(a);for(let S=0;S<y.length;S+=1){const c=y[S],$=a[c];(typeof $=="string"||Array.isArray($)||typeof $=="object")&&(a[c]=this.#i(e,$,r))}}return s}}const me=x=>new pe({processors:[new de],reporters:[new le],...x}),we=me();export{xe as PailError,me as createPail,Te as createPailError,we as pail};
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};