import e from"node:os";import t from"node:process";import n from"node:tty";const r=(e=0)=>t=>`\u001B[${t+e}m`,i=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,a=(e=0)=>(t,n,r)=>`\u001B[${38+e};2;${t};${n};${r}m`,o={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(o.modifier);const s=Object.keys(o.color),c=Object.keys(o.bgColor);[...s,...c];function l(){let e=new Map;for(let[t,n]of Object.entries(o)){for(let[t,r]of Object.entries(n))o[t]={open:`\u001B[${r[0]}m`,close:`\u001B[${r[1]}m`},n[t]=o[t],e.set(r[0],r[1]);Object.defineProperty(o,t,{value:n,enumerable:!1})}return Object.defineProperty(o,`codes`,{value:e,enumerable:!1}),o.color.close=`\x1B[39m`,o.bgColor.close=`\x1B[49m`,o.color.ansi=r(),o.color.ansi256=i(),o.color.ansi16m=a(),o.bgColor.ansi=r(10),o.bgColor.ansi256=i(10),o.bgColor.ansi16m=a(10),Object.defineProperties(o,{rgbToAnsi256:{value(e,t,n){return e===t&&t===n?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(n/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>o.rgbToAnsi256(...o.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>o.ansi256ToAnsi(o.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>o.ansi256ToAnsi(o.hexToAnsi256(e)),enumerable:!1}}),o}const u=l();function d(e,n=globalThis.Deno?globalThis.Deno.args:t.argv){let r=e.startsWith(`-`)?``:e.length===1?`-`:`--`,i=n.indexOf(r+e),a=n.indexOf(`--`);return i!==-1&&(a===-1||i<a)}const{env:f}=t;let p;d(`no-color`)||d(`no-colors`)||d(`color=false`)||d(`color=never`)?p=0:(d(`color`)||d(`colors`)||d(`color=true`)||d(`color=always`))&&(p=1);function m(){if(`FORCE_COLOR`in f)return f.FORCE_COLOR===`true`?1:f.FORCE_COLOR===`false`?0:f.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(f.FORCE_COLOR,10),3)}function h(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function g(n,{streamIsTTY:r,sniffFlags:i=!0}={}){let a=m();a!==void 0&&(p=a);let o=i?p:a;if(o===0)return 0;if(i){if(d(`color=16m`)||d(`color=full`)||d(`color=truecolor`))return 3;if(d(`color=256`))return 2}if(`TF_BUILD`in f&&`AGENT_NAME`in f)return 1;if(n&&!r&&o===void 0)return 0;let s=o||0;if(f.TERM===`dumb`)return s;if(t.platform===`win32`){let t=e.release().split(`.`);return Number(t[0])>=10&&Number(t[2])>=10586?Number(t[2])>=14931?3:2:1}if(`CI`in f)return[`GITHUB_ACTIONS`,`GITEA_ACTIONS`,`CIRCLECI`].some(e=>e in f)?3:[`TRAVIS`,`APPVEYOR`,`GITLAB_CI`,`BUILDKITE`,`DRONE`].some(e=>e in f)||f.CI_NAME===`codeship`?1:s;if(`TEAMCITY_VERSION`in f)return+!!/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(f.TEAMCITY_VERSION);if(f.COLORTERM===`truecolor`||f.TERM===`xterm-kitty`)return 3;if(`TERM_PROGRAM`in f){let e=Number.parseInt((f.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(f.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(f.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(f.TERM)||`COLORTERM`in f?1:s}function _(e,t={}){return h(g(e,{streamIsTTY:e&&e.isTTY,...t}))}const v={stdout:_({isTTY:n.isatty(1)}),stderr:_({isTTY:n.isatty(2)})};function y(e,t,n){let r=e.indexOf(t);if(r===-1)return e;let i=t.length,a=0,o=``;do o+=e.slice(a,r)+t+n,a=r+i,r=e.indexOf(t,a);while(r!==-1);return o+=e.slice(a),o}function b(e,t,n,r){let i=0,a=``;do{let o=e[r-1]===`\r`;a+=e.slice(i,o?r-1:r)+t+(o?`\r
`:`
`)+n,i=r+1,r=e.indexOf(`
`,i)}while(r!==-1);return a+=e.slice(i),a}const{stdout:x,stderr:S}=v,C=Symbol(`GENERATOR`),w=Symbol(`STYLER`),T=Symbol(`IS_EMPTY`),E=[`ansi`,`ansi`,`ansi256`,`ansi16m`],D=Object.create(null),O=(e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let n=x?x.level:0;e.level=t.level===void 0?n:t.level};var k=class{constructor(e){return A(e)}};const A=e=>{let t=(...e)=>e.join(` `);return O(t,e),Object.setPrototypeOf(t,j.prototype),t};function j(e){return A(e)}Object.setPrototypeOf(j.prototype,Function.prototype);for(let[e,t]of Object.entries(u))D[e]={get(){let n=F(this,P(t.open,t.close,this[w]),this[T]);return Object.defineProperty(this,e,{value:n}),n}};D.visible={get(){let e=F(this,this[w],!0);return Object.defineProperty(this,`visible`,{value:e}),e}};const M=(e,t,n,...r)=>e===`rgb`?t===`ansi16m`?u[n].ansi16m(...r):t===`ansi256`?u[n].ansi256(u.rgbToAnsi256(...r)):u[n].ansi(u.rgbToAnsi(...r)):e===`hex`?M(`rgb`,t,n,...u.hexToRgb(...r)):u[n][e](...r);for(let e of[`rgb`,`hex`,`ansi256`]){D[e]={get(){let{level:t}=this;return function(...n){let r=P(M(e,E[t],`color`,...n),u.color.close,this[w]);return F(this,r,this[T])}}};let t=`bg`+e[0].toUpperCase()+e.slice(1);D[t]={get(){let{level:t}=this;return function(...n){let r=P(M(e,E[t],`bgColor`,...n),u.bgColor.close,this[w]);return F(this,r,this[T])}}}}const N=Object.defineProperties(()=>{},{...D,level:{enumerable:!0,get(){return this[C].level},set(e){this[C].level=e}}}),P=(e,t,n)=>{let r,i;return n===void 0?(r=e,i=t):(r=n.openAll+e,i=t+n.closeAll),{open:e,close:t,openAll:r,closeAll:i,parent:n}},F=(e,t,n)=>{let r=(...e)=>I(r,e.length===1?``+e[0]:e.join(` `));return Object.setPrototypeOf(r,N),r[C]=e,r[w]=t,r[T]=n,r},I=(e,t)=>{if(e.level<=0||!t)return e[T]?``:t;let n=e[w];if(n===void 0)return t;let{openAll:r,closeAll:i}=n;if(t.includes(`\x1B`))for(;n!==void 0;)t=y(t,n.close,n.open),n=n.parent;let a=t.indexOf(`
`);return a!==-1&&(t=b(t,i,r,a)),r+t+i};Object.defineProperties(j.prototype,D);const L=j();j({level:S?S.level:0});export{L as n,k as t};
//# sourceMappingURL=source-DkXWTsmk.js.map