@visulima/colorize 1.3.3 → 1.4.1

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,44 @@
1
+ ## @visulima/colorize [1.4.1](https://github.com/visulima/visulima/compare/@visulima/colorize@1.4.0...@visulima/colorize@1.4.1) (2024-05-24)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * changed pathe to @visulima/path ([#410](https://github.com/visulima/visulima/issues/410)) ([bfe1287](https://github.com/visulima/visulima/commit/bfe1287aff6d28d5dca302fd4d58c1f6234ce0bb))
7
+
8
+
9
+ ### Styles
10
+
11
+ * cs fixes ([7bf5b91](https://github.com/visulima/visulima/commit/7bf5b91383b612598d955fe23505c94f22a8d277))
12
+
13
+
14
+ ### Miscellaneous Chores
15
+
16
+ * changed semantic-release-npm to pnpm ([b6d100a](https://github.com/visulima/visulima/commit/b6d100a2bf3fd026577be48726a37754947f0973))
17
+ * **deps:** updated dev deps ([d91ac38](https://github.com/visulima/visulima/commit/d91ac389cea85a6c6bdc8de97905252a6c467abc))
18
+ * fixed wrong named folders to integration, added TEST_PROD_BUILD ([1b826f5](https://github.com/visulima/visulima/commit/1b826f5baf8285847199de9ede8fbdbadf201ad6))
19
+ * update bench dependencies ([d03bf14](https://github.com/visulima/visulima/commit/d03bf14a137074d980e3e56c72d12662751a4ec6))
20
+ * update dev dependencies ([068bdbf](https://github.com/visulima/visulima/commit/068bdbfe0b371b5cc7e5ac071dc3310a3b8cea98))
21
+ * update dev dependencies ([09c4854](https://github.com/visulima/visulima/commit/09c4854e221fa8b808dfe66d7196d8db2a39b366))
22
+ * updated dev dependencies ([2e08f23](https://github.com/visulima/visulima/commit/2e08f23ba4f23ff4c64a36807b53242e9497c073))
23
+ * updated dev dependencies ([abd319c](https://github.com/visulima/visulima/commit/abd319c23576aa1dc751ac874e806bddbc977d51))
24
+ * updated dev dependencies ([0767afe](https://github.com/visulima/visulima/commit/0767afe9be83da6698c1343724400171f952599e))
25
+ * updated dev dependencies ([d7791e3](https://github.com/visulima/visulima/commit/d7791e327917e438757636573b1e5549a97bba7b))
26
+ * updated dev dependencies ([6005345](https://github.com/visulima/visulima/commit/60053456717a3889fc77b4fb5b05d50a662475b2))
27
+ * updated devDependencies ([e5f936c](https://github.com/visulima/visulima/commit/e5f936c24ce8dd1f04f7ea53736f53165f6bb780))
28
+
29
+
30
+
31
+ ### Dependencies
32
+
33
+ * **@visulima/path:** upgraded to 1.0.1
34
+
35
+ ## @visulima/colorize [1.4.0](https://github.com/visulima/visulima/compare/@visulima/colorize@1.3.3...@visulima/colorize@1.4.0) (2024-04-10)
36
+
37
+
38
+ ### Features
39
+
40
+ * add detection of color spaces support: TrueColor, 256 colors, 16 colors, no color ([#391](https://github.com/visulima/visulima/issues/391)) ([f35525c](https://github.com/visulima/visulima/commit/f35525c2a23558405408977745dd59aba9c58a3f))
41
+
1
42
  ## @visulima/colorize [1.3.3](https://github.com/visulima/visulima/compare/@visulima/colorize@1.3.2...@visulima/colorize@1.3.3) (2024-04-09)
2
43
 
3
44
 
package/README.md CHANGED
@@ -33,7 +33,19 @@ For instance, you can use `green` to make `` green`Hello World!` `` pop, `` red`
33
33
  ## Why Colorize?
34
34
 
35
35
  - Supports both **ESM** and **CommonJS**
36
- - [Standard API](#base-colors) like **chalk**
36
+ - **TypeScript** support out of the box
37
+ - Supports **Deno**, **Next.JS** runtimes and **Browser** (not only chrome) (currently multi nesting is not supported)
38
+ - [Standard API](#base-colors) compatible with **Chalk**, switch from **Chalk** to **Colorize** without changing your code
39
+
40
+ ```diff
41
+ - import chalk from 'chalk';
42
+ + import chalk, { red } from '@visulima/colorize';
43
+
44
+ chalk.red.bold('Error!'); // <- Chalk like syntax works fine with Colorize
45
+ red.bold('Error!'); // <- the same result with Colorize
46
+ red.bold`Error!`; // <- the same result with Colorize
47
+ ```
48
+
37
49
  - Default import
38
50
  - `import colorize from '@visulima/colorize'` or `const colorize = require('@visulima/colorize')`
39
51
  - [Named import](#named-import)
@@ -42,17 +54,19 @@ For instance, you can use `green` to make `` green`Hello World!` `` pop, `` red`
42
54
  - [Template literals](#template-literals) `` red`text` ``
43
55
  - String styling with [tagged template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates), see [template-literals](#tagged-template-literals)
44
56
  - [Nested **template strings**](#nested-syntax) `` red`R ${green`G`} R` ``
45
- - [ANSI 256 colors](#256-colors) and [Truecolor](#truecolor) (**RGB**, **HEX**) `` rgb(224, 17, 95)`Ruby` ``, `` hex('#96C')`Amethyst` ``
57
+ - [Base ANSI styles](#base-colors) `dim` **`bold`** _`italic`_ <u>`underline`</u> <s>`strikethrough`</s>
58
+ - [Base ANSI 16 colors](#base-colors) `` red`Error!` `` `` redBright`Error!` `` `` bgRed`Error!` `` `` bgRedBright`Error!` ``
59
+ - [ANSI 256 colors](#256-colors) and [TrueColor](#truecolor) (**RGB**, **HEX**) `` rgb(224, 17, 95)`Ruby` ``, `` hex('#96C')`Amethyst` ``
60
+ - [TrueColor](#truecolor) (**RGB**, **HEX**) `` rgb(224, 17, 95)`Ruby` ``, `` hex('#96C')`Amethyst` ``
61
+ - [Fallback](#fallback) to supported [color space](#color-support): TrueColor → 256 colors → 16 colors → no colors
46
62
  - [ANSI codes](#escape-codes) as `open` and `close` property for each style `` `Hello ${red.open}World${red.close}!` ``
47
63
  - [Strip ANSI codes](#strip) method `colorize.strip()`
48
64
  - [Correct style break](#new-line) at the `end of line` when used `\n` in string
49
65
  - Supports the [environment variables](#cli-vars) `NO_COLOR` `FORCE_COLOR` and flags `--no-color` `--color`
50
- - Supports **Deno**, **Next.JS** runtimes and **Browser** (not only chrome) (currently multi nesting is not supported)
51
66
  - Expressive API
52
67
  - Doesn't extend `String.prototype`
53
68
  - Up to **x3 faster** than **chalk**, [see benchmarks](#benchmark)
54
69
  - **Auto detects** color support
55
- - **TypeScript** support out of the box
56
70
  - Clean and focused
57
71
  - [String Gradient´s](#gradient)
58
72
 
@@ -167,31 +181,6 @@ if (typeof navigator !== "undefined" && typeof window !== "undefined" && !consol
167
181
  }
168
182
  ```
169
183
 
170
- ### API
171
-
172
- Colors and styles have standard names used by many popular libraries, such
173
- as [chalk][chalk], [colorette][colorette], [kleur][kleur].
174
-
175
- | Foreground colors | Background colors | Styles |
176
- | :-------------------- | :------------------------ | ----------------------------------------------------------------------- |
177
- | `black` | `bgBlack` | `dim` |
178
- | `red` | `bgRed` | **`bold`** |
179
- | `green` | `bgGreen` | _`italic`_ |
180
- | `yellow` | `bgYellow` | <u>`underline`</u> |
181
- | `blue` | `bgBlue` | <s>`strikethrough`</s> (alias `strike`) |
182
- | `magenta` | `bgMagenta` | <s>`doubleUnderline`</s> (_not included, because not widely supported_) |
183
- | `cyan` | `bgCyan` | <s>`overline`</s> (_not included, because not widely supported_) |
184
- | `white` | `bgWhite` | <s>`frame`</s> (_not included, because not widely supported_) |
185
- | `gray` (alias `grey`) | `bgGray` (alias `bgGrey`) | <s>`encircle`</s> (_not included, because not widely supported_) |
186
- | `blackBright` | `bgBlackBright` | `inverse` |
187
- | `redBright` | `bgRedBright` | `visible` |
188
- | `greenBright` | `bgGreenBright` | `hidden` |
189
- | `yellowBright` | `bgYellowBright` | `reset` |
190
- | `blueBright` | `bgBlueBright` | |
191
- | `magentaBright` | `bgMagentaBright` | |
192
- | `cyanBright` | `bgCyanBright` | |
193
- | `whiteBright` | `bgWhiteBright` | |
194
-
195
184
  ### Named import
196
185
 
197
186
  The `@visulima/colorize` supports both the `default import` and `named import`.
@@ -346,7 +335,7 @@ Multiline nested template strings:
346
335
  ```typescript
347
336
  import { red, green, hex, visible, inverse } from "@visulima/colorize";
348
337
 
349
- // defined a truecolor as the constant
338
+ // defined a TrueColor as the constant
350
339
  const orange = hex("#FFAB40");
351
340
 
352
341
  // normal colors
@@ -367,6 +356,33 @@ DISK: ${orange`${(disk.used / disk.total) * 100}%`}
367
356
  Output:\
368
357
  ![multiline nested](__assets__/multi-nested.png)
369
358
 
359
+ <a id="base-colors" name="base-colors"></a>
360
+
361
+ ## Base ANSI 16 colors and styles
362
+
363
+ Colors and styles have standard names used by many popular libraries, such
364
+ as [chalk][chalk], [colorette][colorette], [kleur][kleur].
365
+
366
+ | Foreground colors | Background colors | Styles |
367
+ | :-------------------- | :------------------------ | ----------------------------------------------------------------------- |
368
+ | `black` | `bgBlack` | `dim` |
369
+ | `red` | `bgRed` | **`bold`** |
370
+ | `green` | `bgGreen` | _`italic`_ |
371
+ | `yellow` | `bgYellow` | <u>`underline`</u> |
372
+ | `blue` | `bgBlue` | <s>`strikethrough`</s> (alias `strike`) |
373
+ | `magenta` | `bgMagenta` | <s>`doubleUnderline`</s> (_not included, because not widely supported_) |
374
+ | `cyan` | `bgCyan` | <s>`overline`</s> (_not included, because not widely supported_) |
375
+ | `white` | `bgWhite` | <s>`frame`</s> (_not included, because not widely supported_) |
376
+ | `gray` (alias `grey`) | `bgGray` (alias `bgGrey`) | <s>`encircle`</s> (_not included, because not widely supported_) |
377
+ | `blackBright` | `bgBlackBright` | `inverse` |
378
+ | `redBright` | `bgRedBright` | `visible` |
379
+ | `greenBright` | `bgGreenBright` | `hidden` |
380
+ | `yellowBright` | `bgYellowBright` | `reset` |
381
+ | `blueBright` | `bgBlueBright` | |
382
+ | `magentaBright` | `bgMagentaBright` | |
383
+ | `cyanBright` | `bgCyanBright` | |
384
+ | `whiteBright` | `bgWhiteBright` | |
385
+
370
386
  ## ANSI 256 colors
371
387
 
372
388
  The pre-defined set of 256 colors.
@@ -395,6 +411,34 @@ Background function: `bgAnsi256(code)` has short alias `bg(code)`
395
411
 
396
412
  See [ANSI color codes](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit).
397
413
 
414
+ ### Fallback
415
+
416
+ If a terminal supports only 16 colors then ANSI 256 colors will be interpolated into base 16 colors.
417
+
418
+ #### Usage Example
419
+
420
+ ```typescript
421
+ import { bold, ansi256, fg, bgAnsi256, bg } from "@visulima/colorize";
422
+
423
+ // foreground color
424
+ ansi256(96)`Bright Cyan`;
425
+ fg(96)`Bright Cyan`; // alias for ansi256
426
+
427
+ // background color
428
+ bgAnsi256(105)`Bright Magenta`;
429
+ bg(105)`Bright Magenta`; // alias for bgAnsi256
430
+
431
+ // function is chainable
432
+ ansi256(96).bold`bold Bright Cyan`;
433
+
434
+ // function is avaliable in each style
435
+ bold.ansi256(96).underline`bold underline Bright Cyan`;
436
+
437
+ // you can combine the functions and styles in any order
438
+ bgAnsi256(105).ansi256(96)`cyan text on magenta background`;
439
+ bg(105).fg(96)`cyan text on magenta background`;
440
+ ```
441
+
398
442
  ```typescript
399
443
  import { bold, ansi256, fg, bgAnsi256, bg } from "@visulima/colorize";
400
444
 
@@ -441,6 +485,14 @@ bgRgb(224, 17, 95)`Ruby`;
441
485
  bold.hex("#E0115F").bgHex("#96C")`ruby bold text on amethyst background`;
442
486
  ```
443
487
 
488
+ ## Fallback
489
+
490
+ If a terminal does not support ANSI colors, the library will automatically fall back to the next supported color space.
491
+
492
+ > TrueColor —> 256 colors —> 16 colors —> no colors (black & white)
493
+
494
+ If you use the `hex()`, `rgb()` or `ansis256()` functions in a terminal not supported TrueColor or 256 colors, then colors will be interpolated.
495
+
444
496
  <!--
445
497
  Copy of a readme example from https://github.com/webdiscus/ansis
446
498
 
@@ -517,18 +569,18 @@ If you're on Windows, do yourself a favor and use [Windows Terminal](https://git
517
569
 
518
570
  ## Comparison of most popular libraries
519
571
 
520
- | Library<br>**\*\***\_\_**\*\***<br> - name<br> - named import | Code size | Naming colors | ANSI 256<br>colors | True-<br>color | Chained<br>syntax | Nested<br>template strings | New<br>Line | Supports<br>CLI params |
521
- | :---------------------------------------------------------------- | :----------------------------------------------------------------------------- | :----------------------------------------: | :----------------: | :------------: | :---------------: | :------------------------: | :---------: | :------------------------------------------------------: |
522
- | [`@visulima/colorize`][npm-url]<br><nobr>`✅ named import`</nobr> | ![npm bundle size](https://img.shields.io/bundlephobia/min/@visulima/colorize) | **standard**<br>`16` colors | ✅ | ✅ | ✅ | ✅ | ✅ | `NO_COLOR`<br>`FORCE_COLOR`<br>`--no-color`<br>`--color` |
523
- | [`ansi-colors`][ansi-colors]<br><nobr>`❌ named import`</nobr> | ![npm bundle size](https://img.shields.io/bundlephobia/min/ansi-colors) | **standard**<br>`16` colors | ❌ | ❌ | ✅ | ❌ | ✅ | only<br>`FORCE_COLOR` |
524
- | [`ansis`][ansis]<br><nobr>`✅ named import`</nobr> | ![npm bundle size](https://img.shields.io/bundlephobia/min/ansis) | **standard**<br>`16` colors | ✅ | ✅ | ✅ | ✅ | ✅ | `NO_COLOR`<br>`FORCE_COLOR`<br>`--no-color`<br>`--color` |
525
- | [`chalk`][chalk]<br><nobr>`❌ named import`</nobr> | ![npm bundle size](https://img.shields.io/bundlephobia/min/chalk) | **standard**<br>`16` colors | ✅ | ✅ | ✅ | ❌ | ✅ | `NO_COLOR`<br>`FORCE_COLOR`<br>`--no-color`<br>`--color` |
526
- | [`cli-color`][cli-color]<br><nobr>`❌ named import`</nobr> | ![npm bundle size](https://img.shields.io/bundlephobia/min/cli-color) | **standard**<br>`16` colors | ✅ | ❌ | ✅ | ❌ | ❌ | only<br>`NO_COLOR` |
527
- | [`colorette`][colorette]<br><nobr>`✅ named import`</nobr> | ![npm bundle size](https://img.shields.io/bundlephobia/min/colorette) | **standard**<br>`16` colors | ❌ | ❌ | ❌ | ❌ | ❌ | `NO_COLOR`<br>`FORCE_COLOR`<br>`--no-color`<br>`--color` |
528
- | [`colors-cli`][colors-cli]<br><nobr>`❌ named import`</nobr> | ![npm bundle size](https://img.shields.io/bundlephobia/min/colors-cli) | <nobr>_non-standard_</nobr><br>`16` colors | ✅ | ❌ | ✅ | ❌ | ✅ | only<br>`--no-color`<br>`--color` |
529
- | [`colors.js`][colors.js]<br><nobr>`❌ named import`</nobr> | ![npm bundle size](https://img.shields.io/bundlephobia/min/colors.js) | <nobr>_non-standard_</nobr><br>`16` colors | ❌ | ❌ | ✅ | ❌ | ✅ | only<br>`FORCE_COLOR`<br>`--no-color`<br>`--color` |
530
- | [`kleur`][kleur]<br><nobr>`✅ named import`</nobr> | ![npm bundle size](https://img.shields.io/bundlephobia/min/kleur) | **standard**<br>`8` colors | ❌ | ❌ | ✅ | ❌ | ❌ | only<br>`NO_COLOR`<br>`FORCE_COLOR` |
531
- | [`picocolors`][picocolors]<br><nobr>`❌ named import`</nobr> | ![npm bundle size](https://img.shields.io/bundlephobia/min/picocolors) | **standard**<br>`8` colors | ❌ | ❌ | ❌ | ❌ | ❌ | `NO_COLOR`<br>`FORCE_COLOR`<br>`--no-color`<br>`--color` |
572
+ | Library<br>**\*\***\_\_**\*\***<br> - name<br> - named import | Code size | Naming colors | ANSI 256<br>colors | True-<br>color | Chained<br>syntax | Nested<br>template strings | New<br>Line | Supports<br>CLI params<br>ENV vars | Fallbacks |
573
+ | :---------------------------------------------------------------- | :----------------------------------------------------------------------------- | :----------------------------------------: | :----------------: | :------------: | :---------------: | :------------------------: | :---------: | :------------------------------------------------------: | ---------------------------------- |
574
+ | [`@visulima/colorize`][npm-url]<br><nobr>`✅ named import`</nobr> | ![npm bundle size](https://img.shields.io/bundlephobia/min/@visulima/colorize) | **standard**<br>`16` colors | ✅ | ✅ | ✅ | ✅ | ✅ | `NO_COLOR`<br>`FORCE_COLOR`<br>`--no-color`<br>`--color` | 256 color<br>16 colors<br>no color |
575
+ | [`ansi-colors`][ansi-colors]<br><nobr>`❌ named import`</nobr> | ![npm bundle size](https://img.shields.io/bundlephobia/min/ansi-colors) | **standard**<br>`16` colors | ❌ | ❌ | ✅ | ❌ | ✅ | only<br>`FORCE_COLOR` | ❌ |
576
+ | [`ansis`][ansis]<br><nobr>`✅ named import`</nobr> | ![npm bundle size](https://img.shields.io/bundlephobia/min/ansis) | **standard**<br>`16` colors | ✅ | ✅ | ✅ | ✅ | ✅ | `NO_COLOR`<br>`FORCE_COLOR`<br>`--no-color`<br>`--color` | 256 color<br>16 colors<br>no color |
577
+ | [`chalk`][chalk]<br><nobr>`❌ named import`</nobr> | ![npm bundle size](https://img.shields.io/bundlephobia/min/chalk) | **standard**<br>`16` colors | ✅ | ✅ | ✅ | ❌ | ✅ | `NO_COLOR`<br>`FORCE_COLOR`<br>`--no-color`<br>`--color` | 256 color<br>16 colors<br>no color |
578
+ | [`cli-color`][cli-color]<br><nobr>`❌ named import`</nobr> | ![npm bundle size](https://img.shields.io/bundlephobia/min/cli-color) | **standard**<br>`16` colors | ✅ | ❌ | ✅ | ❌ | ❌ | only<br>`NO_COLOR` | 16 colors<br>no color |
579
+ | [`colorette`][colorette]<br><nobr>`✅ named import`</nobr> | ![npm bundle size](https://img.shields.io/bundlephobia/min/colorette) | **standard**<br>`16` colors | ❌ | ❌ | ❌ | ❌ | ❌ | `NO_COLOR`<br>`FORCE_COLOR`<br>`--no-color`<br>`--color` | no color |
580
+ | [`colors-cli`][colors-cli]<br><nobr>`❌ named import`</nobr> | ![npm bundle size](https://img.shields.io/bundlephobia/min/colors-cli) | <nobr>_non-standard_</nobr><br>`16` colors | ✅ | ❌ | ✅ | ❌ | ✅ | only<br>`--no-color`<br>`--color` | no color |
581
+ | [`colors.js`][colors.js]<br><nobr>`❌ named import`</nobr> | ![npm bundle size](https://img.shields.io/bundlephobia/min/colors.js) | <nobr>_non-standard_</nobr><br>`16` colors | ❌ | ❌ | ✅ | ❌ | ✅ | only<br>`FORCE_COLOR`<br>`--no-color`<br>`--color` | no color |
582
+ | [`kleur`][kleur]<br><nobr>`✅ named import`</nobr> | ![npm bundle size](https://img.shields.io/bundlephobia/min/kleur) | **standard**<br>`8` colors | ❌ | ❌ | ✅ | ❌ | ❌ | only<br>`NO_COLOR`<br>`FORCE_COLOR` | no color |
583
+ | [`picocolors`][picocolors]<br><nobr>`❌ named import`</nobr> | ![npm bundle size](https://img.shields.io/bundlephobia/min/picocolors) | **standard**<br>`8` colors | ❌ | ❌ | ❌ | ❌ | ❌ | `NO_COLOR`<br>`FORCE_COLOR`<br>`--no-color`<br>`--color` | no color |
532
584
 
533
585
  > **Note**
534
586
  >
package/dist/gradient.cjs CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  var isAnsiColorSupported = require('@visulima/is-ansi-color-supported');
4
4
 
5
- function S({onlyFirst:r=!1}={}){let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(e,r?void 0:"g")}var g=(r,e,t)=>e>r?e:r>t?t:r;var f=r=>{let e=r.replace("#","");if(e.length===3)e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2];else if(e.length!==6)return [0,0,0];let t=Number.parseInt(e,16);return [t>>16&255,t>>8&255,t&255]};var l=isAnsiColorSupported.isStdoutColorSupported()>0?(r,e)=>({close:"\x1B["+e+"m",open:"\x1B["+r+"m"}):()=>({close:"",open:""}),V=r=>l("38;5;"+r,39),E=r=>l("48;5;"+r,49),z=(r,e,t)=>l("38;2;"+r+";"+e+";"+t,39),M=(r,e,t)=>l("48;2;"+r+";"+e+";"+t,49),R={bold:l(1,22),dim:l(2,22),hidden:l(8,28),inverse:l(7,27),italic:l(3,23),overline:l(53,55),reset:l(0,0),strike:l(9,29),strikethrough:l(9,29),underline:l(4,24),visible:{close:"",open:""}},k={bgBlack:l(40,49),bgBlackBright:l(100,49),bgBlue:l(44,49),bgBlueBright:l(104,49),bgCyan:l(46,49),bgCyanBright:l(106,49),bgGray:l(100,49),bgGreen:l(42,49),bgGreenBright:l(102,49),bgGrey:l(100,49),bgMagenta:l(45,49),bgMagentaBright:l(105,49),bgRed:l(41,49),bgRedBright:l(101,49),bgWhite:l(47,49),bgWhiteBright:l(107,49),bgYellow:l(43,49),bgYellowBright:l(103,49),black:l(30,39),blackBright:l(90,39),blue:l(34,39),blueBright:l(94,39),cyan:l(36,39),cyanBright:l(96,39),gray:l(90,39),green:l(32,39),greenBright:l(92,39),grey:l(90,39),magenta:l(35,39),magentaBright:l(95,39),red:l(31,39),redBright:l(91,39),white:l(37,39),whiteBright:l(97,39),yellow:l(33,39),yellowBright:l(93,39)},w={bg:r=>E(g(r,0,255)),bgHex:r=>M(...f(r)),bgRgb:(r,e,t)=>M(g(r,0,255),g(e,0,255),g(t,0,255)),fg:r=>V(g(r,0,255)),hex:r=>z(...f(r)),rgb:(r,e,t)=>z(g(r,0,255),g(e,0,255),g(t,0,255))};var H=(r,e,t)=>{if(e==="")return r;let n=r.indexOf(e);if(n<0)return r;let o=e.length,s=0,i="";for(;~n;)i+=r.slice(s,n)+t,s=n+o,n=r.indexOf(e,s);return i+r.slice(s)};var h={},B=null,L=(r,e,t)=>{if(!r)return "";let n=r.raw==null?r+"":String.raw(r,...e);if(n.includes("\x1B"))for(let o=t;o;o=o.props)n=H(n,o.close,o.open);return n.includes(`
6
- `)&&(n=n.replace(/(\r*\n)/g,t.closeStack+"$1"+t.openStack)),t.openStack+n+t.closeStack},x=({props:r},{close:e,open:t})=>{let n=(r?.openStack??"")+t,o=e+(r?.closeStack??""),s=(i,...u)=>L(i,u,s.props);return Object.setPrototypeOf(s,B),s.props={close:e,closeStack:o,open:t,openStack:n,props:r},s.open=n,s.close=o,s},Z=function(){let r=e=>e+"";r.strip=e=>e.replaceAll(S(),"");for(let e in k)h[e]={get(){let t=x(this,k[e]);return Object.defineProperty(this,e,{value:t}),t}};for(let e in R)h[e]={get(){let t=x(this,R[e]);return Object.defineProperty(this,e,{value:t}),t}};return B=Object.defineProperties({},h),Object.setPrototypeOf(r,B),r};for(let r in w)h[r]={get(){return (...e)=>x(this,w[r](...e))}};h.ansi256=h.fg;h.bgAnsi256=h.bg;var I=Z;var v={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};var G=(r,e)=>{let t=r.length;if(e=Number.parseInt(e.toString(),10),Number.isNaN(e)||e<2)throw new Error("Invalid number of steps (< 2)");if(e<t)throw new Error("Number of steps cannot be inferior to number of stops");let n=[];for(let s=1;s<t;s++){let i=(e-1)*(r[s].position-r[s-1].position);n.push(Math.max(1,Math.round(i)));}let o=1;for(let s=t-1;s--;)o+=n[s];for(;o!==e;)if(o<e){let s=Math.min(...n);n[n.indexOf(s)]++,o++;}else {let s=Math.max(...n);n[n.indexOf(s)]--,o--;}return n};var P=(r,e,t)=>{let n=0,o=0,s=0,i=Math.floor(r/60),u=r/60-i,a=t*(1-e),p=t*(1-u*e),b=t*(1-(1-u)*e);return i%6===0?(n=t,o=b,s=a):i%6===1?(n=p,o=t,s=a):i%6===2?(n=a,o=t,s=b):i%6===3?(n=a,o=p,s=t):i%6===4?(n=b,o=a,s=t):i%6===5&&(n=t,o=a,s=p),{b:Math.round(s*255),g:Math.round(o*255),r:Math.round(n*255)}};var O=({b:r,g:e,r:t})=>{let n,o,s,i=0,u=0;t/=255,e/=255,r/=255;let a=Math.max(t,e,r),p=a-Math.min(t,e,r),b=c=>(a-c)/6/p+1/2;return p!==0&&(u=p/a,n=b(t),o=b(e),s=b(r),a===t?i=s-o:a===e?i=.3333333333333333+n-s:a===r&&(i=.6666666666666666+o-n),i<0?i+=1:i>1&&(i-=1)),{h:i*360,s:u,v:a}};var W={b:256,g:256,r:256},X={h:360,s:1,v:1},D=(r,e,t)=>{let n={};for(let o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=t===0?0:(e[o]-r[o])/t);return n},N=(r,e,t,n)=>{let o={};for(let s in e)Object.prototype.hasOwnProperty.call(e,s)&&(o[s]=r[s]*t+e[s],o[s]=o[s]<0?o[s]+n[s]:n[s]===1?o[s]:o[s]%n[s]);return o},C=(r,e,t)=>{let n={b:r.color[2],g:r.color[1],r:r.color[0]},o={b:e.color[2],g:e.color[1],r:e.color[0]},s=D(n,o,t),i=[{...n}];for(let u=1;u<t;u++){let a=N(s,n,u,W);i.push({b:Math.floor(a.b),g:Math.floor(a.g),r:Math.floor(a.r)});}return i},A=(r,e,t,n)=>{let o=O({b:r.color[2],g:r.color[1],r:r.color[0]}),s=O({b:e.color[2],g:e.color[1],r:e.color[0]});if(o.s===0||s.s===0)return C(r,e,t);let i;if(typeof n=="boolean")i=n;else {let b=o.h<s.h&&s.h-o.h<180||o.h>s.h&&o.h-s.h>180;i=n==="long"&&b||n==="short"&&!b;}let u=D(o,s,t),a=[{b:r.color[2],g:r.color[1],r:r.color[0]}],p;o.h<=s.h&&!i||o.h>=s.h&&i?p=s.h-o.h:i?p=360-s.h+o.h:p=360-o.h+s.h,u.h=(-1)**(i?1:0)*Math.abs(p)/t;for(let b=1;b<t;b++){let c=N(u,o,b,X);a.push(P(c.h,c.s,c.v));}return a};var y=class r{#e;stops;constructor(e,t){if(this.#e=e,this.stops=[],t.length<2)throw new Error("Invalid number of stops (< 2)");let n=t[0].position!==void 0,o=t.length,s=-1,i=!1;for(let[u,a]of t.entries()){let p={},b=a.position!==void 0;if(n!==b)throw new Error("Cannot mix positioned and non-positioned color stops");if(b){let c=a,d=c.color!==void 0;if(!d&&(i||u===0||u===o-1))throw new Error("Cannot define two consecutive position-only stops");i=!d;let m;if(d&&(Array.isArray(c.color)?m=c.color:typeof c.color=="string"?m=c.color.includes("#")?f(c.color):v[c.color]:c.color.r!==void 0&&c.color.g!==void 0&&c.color.b&&(m=[c.color.r,c.color.g,c.color.b])),p={color:m,colorLess:!d,position:c.position},p.position<0||p.position>1)throw new Error("Color stops positions must be between 0 and 1");if(p.position<s)throw new Error("Color stops positions are not ordered");s=p.position;}else if(Array.isArray(a))p={color:a,position:u/(o-1)};else if(typeof a=="string")p={color:a.includes("#")?f(a):v[a],position:u/(o-1)};else if(a.r!==void 0&&a.g!==void 0&&a.b!==void 0)p={color:[a.r,a.g,a.b],position:u/(o-1)};else throw new Error("Invalid color stop");this.stops.push(p);}this.stops[0].position!==0&&(this.stops.unshift({color:this.stops[0].color,position:0}),o++),this.stops[o-1].position!==1&&this.stops.push({color:this.stops[o-1].color,position:1});}reverse(){let e=[];for(let t of this.stops){let n={...t};n.position=1-t.position,e.push(n);}return new r(this.#e,e.reverse())}loop(){let e=[],t=[];for(let n of this.stops)e.push({color:n.color,position:(n.position||0)/2});for(let n of this.stops.slice(0,-1))t.push({color:n.color,position:1-(n.position||0)/2});return new r(this.#e,[...e,...t.reverse()])}rgb(e){let t=G(this.stops,e),n=[];this.stops.forEach((o,s)=>{if(o.colorLess){let i=C(this.stops[s-1],this.stops[s+1],2);o.color=[i[1].r,i[1].g,i[1].b];}});for(let o=0,s=this.stops.length;o<s-1;o++){let i=C(this.stops[o],this.stops[o+1],t[o]);n.splice(n.length,0,...i.map(u=>this.#e.rgb(u.r,u.g,u.b)));}return n.push(this.#e.rgb(...this.stops.at(-1).color)),n}hsv(e,t=!1){let n=G(this.stops,e),o=[];this.stops.forEach((s,i)=>{if(s.colorLess){let u=A(this.stops[i-1],this.stops[i+1],2,t);s.color=[u[1].r,u[1].g,u[1].b];}});for(let s=0,i=this.stops.length;s<i-1;s++){let u=A(this.stops[s],this.stops[s+1],n[s],t);o.splice(o.length,0,...u.map(a=>this.#e.rgb(a.r,a.g,a.b)));}return o.push(this.#e.rgb(...this.stops.at(-1).color)),o}};var j=new I,T=/\s/g,ye=(r,e)=>{let{hsvSpin:t="short",interpolation:n="rgb"}=e??{},o=new y(j,r);return e?.loop?o=o.loop():e?.reverse&&(o=o.reverse()),s=>{let i=Math.max(s.replaceAll(T,"").length,o.stops.length),u=n==="rgb"?o.rgb(i):o.hsv(i,t),a="";for(let p of s)if(T.test(p))a+=p;else {let b=u.shift();a+=b(p);}return a}},Ce=(r,e)=>{let{hsvSpin:t="short",interpolation:n="rgb"}=e??{},o=new y(j,r);return e?.loop?o=o.loop():e?.reverse&&(o=o.reverse()),s=>{let i=s.split(`
7
- `),u=Reflect.apply(Math.max,null,[...i.map(b=>b.length),o.stops.length]),a=n==="rgb"?o.rgb(u):o.hsv(u,t),p=[];for(let b of i){let c=[...a],d="";for(let m of b)d+=T.test(m)?m:c.shift()(m);p.push(d);}return p.join(`
5
+ function B({onlyFirst:r=!1}={}){let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(e,r?void 0:"g")}var h=(r,e,o)=>e>r?e:r>o?o:r;var S=r=>{let[,e]=/([a-f\d]{3,6})/i.exec(r)??[],o=e?e.length:0;if(o===3)e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2];else if(o!==6)return [0,0,0];let n=Number.parseInt(e,16);return [n>>16&255,n>>8&255,n&255]};var v=(r,e,o)=>r===e&&e===o?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/51)+6*Math.round(e/51)+Math.round(o/51),R=r=>{let e,o,n;if(r<8)return 30+r;if(r<16)return 90+(r-8);if(r>=232)e=o=n=((r-232)*10+8)/255;else {r-=16;let i=r%36;e=Math.floor(r/36)/5,o=Math.floor(i/6)/5,n=i%6/5;}let t=Math.max(e,o,n)*2;if(t===0)return 30;let s=30+(Math.round(n)<<2|Math.round(o)<<1|Math.round(e));return t===2?s+60:s},G=(r,e,o)=>R(v(r,e,o));var c=39,m=49,T=isAnsiColorSupported.isStdoutColorSupported(),Z={close:"",open:""},l=T>0?(r,e)=>({close:"\x1B["+e+"m",open:"\x1B["+r+"m"}):()=>Z,L=r=>(e,o,n)=>r(v(Number(e),Number(o),Number(n))),E=r=>e=>{let[o,n,t]=S(e);return r(o,n,t)},A=r=>l("38;5;"+r,c),O=r=>l("48;5;"+r,m),x=(r,e,o)=>l("38;2;"+r+";"+e+";"+o,c),k=(r,e,o)=>l("48;2;"+r+";"+e+";"+o,m);T===1?(A=r=>l(R(Number(r)),c),O=r=>l(R(Number(r))+10,m),x=(r,e,o)=>l(G(Number(r),Number(e),Number(o)),c),k=(r,e,o)=>l(G(Number(r),Number(e),Number(o))+10,m)):T===2&&(x=L(A),k=L(O));var M={bold:l(1,22),dim:l(2,22),hidden:l(8,28),inverse:l(7,27),italic:l(3,23),overline:l(53,55),reset:l(0,0),strike:l(9,29),strikethrough:l(9,29),underline:l(4,24),visible:Z},z={bgBlack:l(40,m),bgBlackBright:l(100,m),bgBlue:l(44,m),bgBlueBright:l(104,m),bgCyan:l(46,m),bgCyanBright:l(106,m),bgGray:l(100,m),bgGreen:l(42,m),bgGreenBright:l(102,m),bgGrey:l(100,m),bgMagenta:l(45,m),bgMagentaBright:l(105,m),bgRed:l(41,m),bgRedBright:l(101,m),bgWhite:l(47,m),bgWhiteBright:l(107,m),bgYellow:l(43,m),bgYellowBright:l(103,m),black:l(30,c),blackBright:l(90,c),blue:l(34,c),blueBright:l(94,c),cyan:l(36,c),cyanBright:l(96,c),gray:l(90,c),green:l(32,c),greenBright:l(92,c),grey:l(90,c),magenta:l(35,c),magentaBright:l(95,c),red:l(31,c),redBright:l(91,c),white:l(37,c),whiteBright:l(97,c),yellow:l(33,c),yellowBright:l(93,c)},H={bg:r=>O(h(r,0,255)),bgHex:E(k),bgRgb:(r,e,o)=>k(h(r,0,255),h(e,0,255),h(o,0,255)),fg:r=>A(h(r,0,255)),hex:E(x),rgb:(r,e,o)=>x(h(r,0,255),h(e,0,255),h(o,0,255))};var F=(r,e,o)=>{if(e==="")return r;let n=r.indexOf(e);if(n<0)return r;let t=e.length,s=0,i="";for(;~n;)i+=r.slice(s,n)+o,s=n+t,n=r.indexOf(e,s);return i+r.slice(s)};var d={},N=null,Q=(r,e,o)=>{if(!r)return "";let n=r.raw==null?r+"":String.raw(r,...e);if(n.includes("\x1B"))for(let t=o;t;t=t.props)n=F(n,t.close,t.open);return n.includes(`
6
+ `)&&(n=n.replace(/(\r*\n)/g,o.closeStack+"$1"+o.openStack)),o.openStack+n+o.closeStack},I=({props:r},{close:e,open:o})=>{let n=(r?.openStack??"")+o,t=e+(r?.closeStack??""),s=(i,...u)=>Q(i,u,s.props);return Object.setPrototypeOf(s,N),s.props={close:e,closeStack:t,open:o,openStack:n,props:r},s.open=n,s.close=t,s},U=function(){let r=e=>e+"";r.strip=e=>e.replaceAll(B(),"");for(let e in z)d[e]={get(){let o=I(this,z[e]);return Object.defineProperty(this,e,{value:o}),o}};for(let e in M)d[e]={get(){let o=I(this,M[e]);return Object.defineProperty(this,e,{value:o}),o}};return N=Object.defineProperties({},d),Object.setPrototypeOf(r,N),r};for(let r in H)d[r]={get(){return (...e)=>I(this,H[r](...e))}};d.ansi256=d.fg;d.bgAnsi256=d.bg;var W=U;var D={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};var P=(r,e)=>{let o=r.length;if(e=Number.parseInt(e.toString(),10),Number.isNaN(e)||e<2)throw new Error("Invalid number of steps (< 2)");if(e<o)throw new Error("Number of steps cannot be inferior to number of stops");let n=[];for(let s=1;s<o;s++){let i=(e-1)*(r[s].position-r[s-1].position);n.push(Math.max(1,Math.round(i)));}let t=1;for(let s=o-1;s--;)t+=n[s];for(;t!==e;)if(t<e){let s=Math.min(...n);n[n.indexOf(s)]++,t++;}else {let s=Math.max(...n);n[n.indexOf(s)]--,t--;}return n};var X=(r,e,o)=>{let n=0,t=0,s=0,i=Math.floor(r/60),u=r/60-i,a=o*(1-e),p=o*(1-u*e),b=o*(1-(1-u)*e);return i%6===0?(n=o,t=b,s=a):i%6===1?(n=p,t=o,s=a):i%6===2?(n=a,t=o,s=b):i%6===3?(n=a,t=p,s=o):i%6===4?(n=b,t=a,s=o):i%6===5&&(n=o,t=a,s=p),{b:Math.round(s*255),g:Math.round(t*255),r:Math.round(n*255)}};var j=({b:r,g:e,r:o})=>{let n,t,s,i=0,u=0;o/=255,e/=255,r/=255;let a=Math.max(o,e,r),p=a-Math.min(o,e,r),b=g=>(a-g)/6/p+1/2;return p!==0&&(u=p/a,n=b(o),t=b(e),s=b(r),a===o?i=s-t:a===e?i=.3333333333333333+n-s:a===r&&(i=.6666666666666666+t-n),i<0?i+=1:i>1&&(i-=1)),{h:i*360,s:u,v:a}};var _={b:256,g:256,r:256},ee={h:360,s:1,v:1},Y=(r,e,o)=>{let n={};for(let t in r)Object.prototype.hasOwnProperty.call(r,t)&&(n[t]=o===0?0:(e[t]-r[t])/o);return n},$=(r,e,o,n)=>{let t={};for(let s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=r[s]*o+e[s],t[s]=t[s]<0?t[s]+n[s]:n[s]===1?t[s]:t[s]%n[s]);return t},w=(r,e,o)=>{let n={b:r.color[2],g:r.color[1],r:r.color[0]},t={b:e.color[2],g:e.color[1],r:e.color[0]},s=Y(n,t,o),i=[{...n}];for(let u=1;u<o;u++){let a=$(s,n,u,_);i.push({b:Math.floor(a.b),g:Math.floor(a.g),r:Math.floor(a.r)});}return i},V=(r,e,o,n)=>{let t=j({b:r.color[2],g:r.color[1],r:r.color[0]}),s=j({b:e.color[2],g:e.color[1],r:e.color[0]});if(t.s===0||s.s===0)return w(r,e,o);let i;if(typeof n=="boolean")i=n;else {let b=t.h<s.h&&s.h-t.h<180||t.h>s.h&&t.h-s.h>180;i=n==="long"&&b||n==="short"&&!b;}let u=Y(t,s,o),a=[{b:r.color[2],g:r.color[1],r:r.color[0]}],p;t.h<=s.h&&!i||t.h>=s.h&&i?p=s.h-t.h:i?p=360-s.h+t.h:p=360-t.h+s.h,u.h=(-1)**(i?1:0)*Math.abs(p)/o;for(let b=1;b<o;b++){let g=$(u,t,b,ee);a.push(X(g.h,g.s,g.v));}return a};var C=class r{#e;stops;constructor(e,o){if(this.#e=e,this.stops=[],o.length<2)throw new Error("Invalid number of stops (< 2)");let n=o[0].position!==void 0,t=o.length,s=-1,i=!1;for(let[u,a]of o.entries()){let p={},b=a.position!==void 0;if(n!==b)throw new Error("Cannot mix positioned and non-positioned color stops");if(b){let g=a,y=g.color!==void 0;if(!y&&(i||u===0||u===t-1))throw new Error("Cannot define two consecutive position-only stops");i=!y;let f;if(y&&(Array.isArray(g.color)?f=g.color:typeof g.color=="string"?f=g.color.includes("#")?S(g.color):D[g.color]:g.color.r!==void 0&&g.color.g!==void 0&&g.color.b&&(f=[g.color.r,g.color.g,g.color.b])),p={color:f,colorLess:!y,position:g.position},p.position<0||p.position>1)throw new Error("Color stops positions must be between 0 and 1");if(p.position<s)throw new Error("Color stops positions are not ordered");s=p.position;}else if(Array.isArray(a))p={color:a,position:u/(t-1)};else if(typeof a=="string")p={color:a.includes("#")?S(a):D[a],position:u/(t-1)};else if(a.r!==void 0&&a.g!==void 0&&a.b!==void 0)p={color:[a.r,a.g,a.b],position:u/(t-1)};else throw new Error("Invalid color stop");this.stops.push(p);}this.stops[0].position!==0&&(this.stops.unshift({color:this.stops[0].color,position:0}),t++),this.stops[t-1].position!==1&&this.stops.push({color:this.stops[t-1].color,position:1});}reverse(){let e=[];for(let o of this.stops){let n={...o};n.position=1-o.position,e.push(n);}return new r(this.#e,e.reverse())}loop(){let e=[],o=[];for(let n of this.stops)e.push({color:n.color,position:(n.position||0)/2});for(let n of this.stops.slice(0,-1))o.push({color:n.color,position:1-(n.position||0)/2});return new r(this.#e,[...e,...o.reverse()])}rgb(e){let o=P(this.stops,e),n=[];this.stops.forEach((t,s)=>{if(t.colorLess){let i=w(this.stops[s-1],this.stops[s+1],2);t.color=[i[1].r,i[1].g,i[1].b];}});for(let t=0,s=this.stops.length;t<s-1;t++){let i=w(this.stops[t],this.stops[t+1],o[t]);n.splice(n.length,0,...i.map(u=>this.#e.rgb(u.r,u.g,u.b)));}return n.push(this.#e.rgb(...this.stops.at(-1).color)),n}hsv(e,o=!1){let n=P(this.stops,e),t=[];this.stops.forEach((s,i)=>{if(s.colorLess){let u=V(this.stops[i-1],this.stops[i+1],2,o);s.color=[u[1].r,u[1].g,u[1].b];}});for(let s=0,i=this.stops.length;s<i-1;s++){let u=V(this.stops[s],this.stops[s+1],n[s],o);t.splice(t.length,0,...u.map(a=>this.#e.rgb(a.r,a.g,a.b)));}return t.push(this.#e.rgb(...this.stops.at(-1).color)),t}};var J=new W,q=/\s/g,Ae=(r,e)=>{let{hsvSpin:o="short",interpolation:n="rgb"}=e??{},t=new C(J,r);return e?.loop?t=t.loop():e?.reverse&&(t=t.reverse()),s=>{let i=Math.max(s.replaceAll(q,"").length,t.stops.length),u=n==="rgb"?t.rgb(i):t.hsv(i,o),a="";for(let p of s)if(q.test(p))a+=p;else {let b=u.shift();a+=b(p);}return a}},Oe=(r,e)=>{let{hsvSpin:o="short",interpolation:n="rgb"}=e??{},t=new C(J,r);return e?.loop?t=t.loop():e?.reverse&&(t=t.reverse()),s=>{let i=s.split(`
7
+ `),u=Reflect.apply(Math.max,null,[...i.map(b=>b.length),t.stops.length]),a=n==="rgb"?t.rgb(u):t.hsv(u,o),p=[];for(let b of i){let g=[...a],y="";for(let f of b)y+=q.test(f)?f:g.shift()(f);p.push(y);}return p.join(`
8
8
  `)}};
9
9
 
10
- exports.GradientBuilder = y;
11
- exports.gradient = ye;
12
- exports.multilineGradient = Ce;
10
+ exports.GradientBuilder = C;
11
+ exports.gradient = Ae;
12
+ exports.multilineGradient = Oe;
13
13
  //# sourceMappingURL=out.js.map
14
14
  //# sourceMappingURL=gradient.cjs.map