var V=Object.defineProperty;var $=t=>{throw TypeError(t)};var _=(t,e,r)=>e in t?V(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var b=(t,e,r)=>_(t,typeof e!="symbol"?e+"":e,r),E=(t,e,r)=>e.has(t)||$("Cannot "+r);var c=(t,e,r)=>(E(t,e,"read from private field"),r?r.call(t):e.get(t)),v=(t,e,r)=>e.has(t)?$("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),k=(t,e,r,n)=>(E(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r);const I=(t=0)=>e=>`\x1B[${e+t}m`,P=(t=0)=>e=>`\x1B[${38+t};5;${e}m`,D=(t=0)=>(e,r,n)=>`\x1B[${38+t};2;${e};${r};${n}m`,l={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(l.modifier);const q=Object.keys(l.color),H=Object.keys(l.bgColor);[...q,...H];function J(){const t=new Map;for(const[e,r]of Object.entries(l)){for(const[n,o]of Object.entries(r))l[n]={open:`\x1B[${o[0]}m`,close:`\x1B[${o[1]}m`},r[n]=l[n],t.set(o[0],o[1]);Object.defineProperty(l,e,{value:r,enumerable:!1})}return Object.defineProperty(l,"codes",{value:t,enumerable:!1}),l.color.close="\x1B[39m",l.bgColor.close="\x1B[49m",l.color.ansi=I(),l.color.ansi256=P(),l.color.ansi16m=D(),l.bgColor.ansi=I(10),l.bgColor.ansi256=P(10),l.bgColor.ansi16m=D(10),Object.defineProperties(l,{rgbToAnsi256:{value(e,r,n){return e===r&&r===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(e){const r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!r)return[0,0,0];let[n]=r;n.length===3&&(n=[...n].map(s=>s+s).join(""));const o=Number.parseInt(n,16);return[o>>16&255,o>>8&255,o&255]},enumerable:!1},hexToAnsi256:{value:e=>l.rgbToAnsi256(...l.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let r,n,o;if(e>=232)r=((e-232)*10+8)/255,n=r,o=r;else{e-=16;const h=e%36;r=Math.floor(e/36)/5,n=Math.floor(h/6)/5,o=h%6/5}const s=Math.max(r,n,o)*2;if(s===0)return 30;let i=30+(Math.round(o)<<2|Math.round(n)<<1|Math.round(r));return s===2&&(i+=60),i},enumerable:!1},rgbToAnsi:{value:(e,r,n)=>l.ansi256ToAnsi(l.rgbToAnsi256(e,r,n)),enumerable:!1},hexToAnsi:{value:e=>l.ansi256ToAnsi(l.hexToAnsi256(e)),enumerable:!1}}),l}const u=J(),C=(()=>{if(navigator.userAgentData){const t=navigator.userAgentData.brands.find(({brand:e})=>e==="Chromium");if(t&&t.version>93)return 3}return/\b(Chrome|Chromium)\//.test(navigator.userAgent)?1:0})(),G=C!==0&&{level:C,hasBasic:!0,has256:C>=2,has16m:C>=3},Q={stdout:G,stderr:G};function X(t,e,r){let n=t.indexOf(e);if(n===-1)return t;const o=e.length;let s=0,i="";do i+=t.slice(s,n)+e+r,s=n+o,n=t.indexOf(e,s);while(n!==-1);return i+=t.slice(s),i}function Z(t,e,r,n){let o=0,s="";do{const i=t[n-1]==="\r";s+=t.slice(o,i?n-1:n)+e+(i?`\r
`:`
`)+r,o=n+1,n=t.indexOf(`
`,o)}while(n!==-1);return s+=t.slice(o),s}const{stdout:L,stderr:z}=Q,j=Symbol("GENERATOR"),d=Symbol("STYLER"),p=Symbol("IS_EMPTY"),Y=["ansi","ansi","ansi256","ansi16m"],m=Object.create(null),ee=(t,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const r=L?L.level:0;t.level=e.level===void 0?r:e.level},te=t=>{const e=(...r)=>r.join(" ");return ee(e,t),Object.setPrototypeOf(e,O.prototype),e};function O(t){return te(t)}Object.setPrototypeOf(O.prototype,Function.prototype);for(const[t,e]of Object.entries(u))m[t]={get(){const r=S(this,F(e.open,e.close,this[d]),this[p]);return Object.defineProperty(this,t,{value:r}),r}};m.visible={get(){const t=S(this,this[d],!0);return Object.defineProperty(this,"visible",{value:t}),t}};const M=(t,e,r,...n)=>t==="rgb"?e==="ansi16m"?u[r].ansi16m(...n):e==="ansi256"?u[r].ansi256(u.rgbToAnsi256(...n)):u[r].ansi(u.rgbToAnsi(...n)):t==="hex"?M("rgb",e,r,...u.hexToRgb(...n)):u[r][t](...n),re=["rgb","hex","ansi256"];for(const t of re){m[t]={get(){const{level:r}=this;return function(...n){const o=F(M(t,Y[r],"color",...n),u.color.close,this[d]);return S(this,o,this[p])}}};const e="bg"+t[0].toUpperCase()+t.slice(1);m[e]={get(){const{level:r}=this;return function(...n){const o=F(M(t,Y[r],"bgColor",...n),u.bgColor.close,this[d]);return S(this,o,this[p])}}}}const ne=Object.defineProperties(()=>{},{...m,level:{enumerable:!0,get(){return this[j].level},set(t){this[j].level=t}}}),F=(t,e,r)=>{let n,o;return r===void 0?(n=t,o=e):(n=r.openAll+t,o=e+r.closeAll),{open:t,close:e,openAll:n,closeAll:o,parent:r}},S=(t,e,r)=>{const n=(...o)=>oe(n,o.length===1?""+o[0]:o.join(" "));return Object.setPrototypeOf(n,ne),n[j]=t,n[d]=e,n[p]=r,n},oe=(t,e)=>{if(t.level<=0||!e)return t[p]?"":e;let r=t[d];if(r===void 0)return e;const{openAll:n,closeAll:o}=r;if(e.includes("\x1B"))for(;r!==void 0;)e=X(e,r.close,r.open),r=r.parent;const s=e.indexOf(`
`);return s!==-1&&(e=Z(e,o,n,s)),n+e+o};Object.defineProperties(O.prototype,m);const a=O();O({level:z?z.level:0});let K;try{K=window}catch{}const le=K!==void 0?"onscreen":"offscreen",U=()=>le==="offscreen",se={0:"debug",1:"info",2:"warn",3:"error"};var f,A,w,g;const y=class y{constructor(e={level:1,timestamp:!0,cacheSize:y.DefaultCacheSize}){v(this,f,[]);v(this,A);v(this,w,e=>{c(this,f).push(e);const r=c(this,f).length-(c(this,A).cacheSize??y.DefaultCacheSize);r>0&&c(this,f).splice(0,r)});v(this,g,(e,r,n,o)=>{const s=U()?"service-worker":"options-page",i=U()?"🧵":"⚙️";return(h,...x)=>{const N=typeof h=="string",R=new Date().toLocaleTimeString();if(c(this,w).call(this,{timeLabel:R,level:r,msg:h,context:s,args:x}),r<e.level)return;N&&(h=o(h??""));let B=`${i}`;e.timestamp&&(B+=` ${a.gray(R)}`),B+=" |",N?n(`${B} ${h}`,...x):n(B,h,...x)}});b(this,"debug");b(this,"info");b(this,"warn");b(this,"error");b(this,"getCache",()=>[...c(this,f)]);k(this,A,e),this.debug=c(this,g).call(this,e,0,console.debug.bind(console),a.gray.bind(a)),this.info=c(this,g).call(this,e,1,console.info.bind(console),a.reset.bind(a)),this.warn=c(this,g).call(this,e,2,console.warn.bind(console),a.yellow.bind(a)),this.error=c(this,g).call(this,e,3,console.error.bind(console),a.red.bind(a))}};f=new WeakMap,A=new WeakMap,w=new WeakMap,g=new WeakMap,b(y,"DefaultCacheSize",128);let T=y;const W=1,ie=new T({level:W,timestamp:!0,cacheSize:T.DefaultCacheSize});ie.info(`Log level is set to ${a.magenta(se[W])}`);export{a as c,U as i,ie as l};
