const Y=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),j=(o=0)=>e=>`\x1B[${e+o}m`,x=(o=0)=>e=>`\x1B[${38+o};5;${e}m`,A=(o=0)=>(e,t,r)=>`\x1B[${38+o};2;${e};${t};${r}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 f=Object.keys(l.color),d=Object.keys(l.bgColor);[...f,...d];function P(){const o=new Map;for(const[e,t]of Object.entries(l)){for(const[r,n]of Object.entries(t))l[r]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},t[r]=l[r],o.set(n[0],n[1]);Object.defineProperty(l,e,{value:t,enumerable:!1})}return Object.defineProperty(l,"codes",{value:o,enumerable:!1}),l.color.close="\x1B[39m",l.bgColor.close="\x1B[49m",l.color.ansi=j(),l.color.ansi256=x(),l.color.ansi16m=A(),l.bgColor.ansi=j(10),l.bgColor.ansi256=x(10),l.bgColor.ansi16m=A(10),Object.defineProperties(l,{rgbToAnsi256:{value(e,t,r){return e===t&&t===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(r/255*5)},enumerable:!1},hexToRgb:{value(e){const t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[r]=t;r.length===3&&(r=[...r].map(i=>i+i).join(""));const n=Number.parseInt(r,16);return[n>>16&255,n>>8&255,n&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 t,r,n;if(e>=232)t=((e-232)*10+8)/255,r=t,n=t;else{e-=16;const B=e%36;t=Math.floor(e/36)/5,r=Math.floor(B/6)/5,n=B%6/5}const i=Math.max(t,r,n)*2;if(i===0)return 30;let a=30+(Math.round(n)<<2|Math.round(r)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,r)=>l.ansi256ToAnsi(l.rgbToAnsi256(e,t,r)),enumerable:!1},hexToAnsi:{value:e=>l.ansi256ToAnsi(l.hexToAnsi256(e)),enumerable:!1}}),l}const s=P(),T=(()=>{if(navigator.userAgentData){const o=navigator.userAgentData.brands.find(({brand:e})=>e==="Chromium");if(o&&o.version>93)return 3}return/\b(Chrome|Chromium)\//.test(navigator.userAgent)?1:0})(),C=T!==0&&{level:T},w={stdout:C,stderr:C};function S(o,e,t){let r=o.indexOf(e);if(r===-1)return o;const n=e.length;let i=0,a="";do a+=o.slice(i,r)+e+t,i=r+n,r=o.indexOf(e,i);while(r!==-1);return a+=o.slice(i),a}function k(o,e,t,r){let n=0,i="";do{const a=o[r-1]==="\r";i+=o.slice(n,a?r-1:r)+e+(a?`\r
`:`
`)+t,n=r+1,r=o.indexOf(`
`,n)}while(r!==-1);return i+=o.slice(n),i}const{stdout:m,stderr:p}=w,v=Symbol("GENERATOR"),c=Symbol("STYLER"),b=Symbol("IS_EMPTY"),M=["ansi","ansi","ansi256","ansi16m"],u=Object.create(null),_=(o,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 t=m?m.level:0;o.level=e.level===void 0?t:e.level},$=o=>{const e=(...t)=>t.join(" ");return _(e,o),Object.setPrototypeOf(e,g.prototype),e};function g(o){return $(o)}Object.setPrototypeOf(g.prototype,Function.prototype);for(const[o,e]of Object.entries(s))u[o]={get(){const t=h(this,O(e.open,e.close,this[c]),this[b]);return Object.defineProperty(this,o,{value:t}),t}};u.visible={get(){const o=h(this,this[c],!0);return Object.defineProperty(this,"visible",{value:o}),o}};const y=(o,e,t,...r)=>o==="rgb"?e==="ansi16m"?s[t].ansi16m(...r):e==="ansi256"?s[t].ansi256(s.rgbToAnsi256(...r)):s[t].ansi(s.rgbToAnsi(...r)):o==="hex"?y("rgb",e,t,...s.hexToRgb(...r)):s[t][o](...r),R=["rgb","hex","ansi256"];for(const o of R){u[o]={get(){const{level:t}=this;return function(...r){const n=O(y(o,M[t],"color",...r),s.color.close,this[c]);return h(this,n,this[b])}}};const e="bg"+o[0].toUpperCase()+o.slice(1);u[e]={get(){const{level:t}=this;return function(...r){const n=O(y(o,M[t],"bgColor",...r),s.bgColor.close,this[c]);return h(this,n,this[b])}}}}const G=Object.defineProperties(()=>{},{...u,level:{enumerable:!0,get(){return this[v].level},set(o){this[v].level=o}}}),O=(o,e,t)=>{let r,n;return t===void 0?(r=o,n=e):(r=t.openAll+o,n=e+t.closeAll),{open:o,close:e,openAll:r,closeAll:n,parent:t}},h=(o,e,t)=>{const r=(...n)=>E(r,n.length===1?""+n[0]:n.join(" "));return Object.setPrototypeOf(r,G),r[v]=o,r[c]=e,r[b]=t,r},E=(o,e)=>{if(o.level<=0||!e)return o[b]?"":e;let t=o[c];if(t===void 0)return e;const{openAll:r,closeAll:n}=t;if(e.includes("\x1B"))for(;t!==void 0;)e=S(e,t.close,t.open),t=t.parent;const i=e.indexOf(`
`);return i!==-1&&(e=k(e,n,r,i)),r+e+n};Object.defineProperties(g.prototype,u);const N=g();g({level:p?p.level:0});const I=Object.freeze(Object.defineProperty({__proto__:null,backgroundColorNames:d,backgroundColors:d,default:N,foregroundColorNames:f,foregroundColors:f,supportsColor:m,supportsColorStderr:p},Symbol.toStringTag,{value:"Module"}));export{N as G,I as a,Y as i};
