gradiente 2.1.0 → 2.1.2
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/LICENSE +21 -0
- package/README.md +110 -93
- package/dist/gradiente.global.iife.js +60 -0
- package/dist/{index.mjs → index.js} +1 -4
- package/package.json +65 -54
- /package/dist/{index.d.mts → index.d.ts} +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Flowscape UI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,94 +1,111 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
|
|
3
|
-
<img src="https://raw.githubusercontent.com/Flowscape-UI/gradiente/fff32510afe7e3e1b7b2f73dbf7246843a06d859/assets/logo.svg" alt="gradiente logo" />
|
|
4
|
-
|
|
5
|
-
<h1>gradiente</h1>
|
|
6
|
-
|
|
7
|
-
<p>Minimalist & lightweight engine for sophisticated web gradients</p>
|
|
8
|
-
|
|
9
|
-
<img src="https://raw.githubusercontent.com/Flowscape-UI/gradiente/d8429051f700698f664d8d2392cfa58a604f8e83/assets/flowscape-badge.svg" alt="npm version" />
|
|
10
|
-
<br />
|
|
11
|
-
|
|
12
|
-
<a href="https://www.npmjs.com/package/gradiente">
|
|
13
|
-
<img src="https://img.shields.io/npm/v/gradiente.svg?style=flat-square&labelColor=d84f4c&color=black" alt="npm version">
|
|
14
|
-
</a>
|
|
15
|
-
<a href="https://bundlephobia.com/result?p=gradiente">
|
|
16
|
-
<img src="https://img.shields.io/bundlephobia/minzip/gradiente?style=flat-square&labelColor=d84f4c&color=black" alt="bundle size"/>
|
|
17
|
-
</a>
|
|
18
|
-
<a href="https://github.com/Flowscape-UI/gradiente/blob/main/LICENSE">
|
|
19
|
-
<img src="https://img.shields.io/github/license/Flowscape-UI/gradiente?style=flat-square&labelColor=d84f4c&color=black" alt="license"/>
|
|
20
|
-
</a>
|
|
21
|
-
</div>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
# Gradiente
|
|
25
|
-
|
|
26
|
-
**Gradiente** is a lightweight gradient parser and transformer for modern rendering systems.
|
|
27
|
-
|
|
28
|
-
Parse CSS gradients → work with structured data → render anywhere.
|
|
29
|
-
|
|
30
|
-
> Gradients as data, not strings.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
## Install
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
npm install gradiente
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
##
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<img src="https://raw.githubusercontent.com/Flowscape-UI/gradiente/fff32510afe7e3e1b7b2f73dbf7246843a06d859/assets/logo.svg" alt="gradiente logo" />
|
|
4
|
+
|
|
5
|
+
<h1>gradiente</h1>
|
|
6
|
+
|
|
7
|
+
<p>Minimalist & lightweight engine for sophisticated web gradients</p>
|
|
8
|
+
|
|
9
|
+
<img src="https://raw.githubusercontent.com/Flowscape-UI/gradiente/d8429051f700698f664d8d2392cfa58a604f8e83/assets/flowscape-badge.svg" alt="npm version" />
|
|
10
|
+
<br />
|
|
11
|
+
|
|
12
|
+
<a href="https://www.npmjs.com/package/gradiente">
|
|
13
|
+
<img src="https://img.shields.io/npm/v/gradiente.svg?style=flat-square&labelColor=d84f4c&color=black" alt="npm version">
|
|
14
|
+
</a>
|
|
15
|
+
<a href="https://bundlephobia.com/result?p=gradiente">
|
|
16
|
+
<img src="https://img.shields.io/bundlephobia/minzip/gradiente?style=flat-square&labelColor=d84f4c&color=black" alt="bundle size"/>
|
|
17
|
+
</a>
|
|
18
|
+
<a href="https://github.com/Flowscape-UI/gradiente/blob/main/LICENSE">
|
|
19
|
+
<img src="https://img.shields.io/github/license/Flowscape-UI/gradiente?style=flat-square&labelColor=d84f4c&color=black" alt="license"/>
|
|
20
|
+
</a>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# Gradiente
|
|
25
|
+
|
|
26
|
+
**Gradiente** is a lightweight gradient parser and transformer for modern rendering systems.
|
|
27
|
+
|
|
28
|
+
Parse CSS gradients → work with structured data → render anywhere.
|
|
29
|
+
|
|
30
|
+
> Gradients as data, not strings.
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## Install
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm install gradiente
|
|
37
|
+
bun add gradiente
|
|
38
|
+
pnpm add gradiente
|
|
39
|
+
yarn add gradiente
|
|
40
|
+
|
|
41
|
+
# HTML - add this in your <head> or <body> tag
|
|
42
|
+
<script src="https://cdn.jsdelivr.net/npm/gradiente/dist/gradiente.global.iife.js"></script>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## Example
|
|
47
|
+
# Basic usage
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { parse, transformTo } from "gradiente";
|
|
51
|
+
|
|
52
|
+
const gradient = parse("linear-gradient(red, blue)");
|
|
53
|
+
const css = transformTo("css", gradient);
|
|
54
|
+
const canvas = transformTo("canvas", gradient);
|
|
55
|
+
|
|
56
|
+
canvas.draw(ctx, 300, 300);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
# Usage in plain HTML
|
|
60
|
+
|
|
61
|
+
```html
|
|
62
|
+
<script src="https://cdn.jsdelivr.net/npm/gradiente/dist/gradiente.global.iife.js"></script>
|
|
63
|
+
|
|
64
|
+
<script>
|
|
65
|
+
const gradient = gradiente.parse("linear-gradient(red, blue)");
|
|
66
|
+
console.log(gradient.toString());
|
|
67
|
+
</script>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The full documentation is published on [gradiente docs](https://flowscape-ui.github.io/gradiente/). Some quick entry points:
|
|
71
|
+
|
|
72
|
+
- [Getting started](https://flowscape-ui.github.io/gradiente/getting-started.html)
|
|
73
|
+
- [API References](https://flowscape-ui.github.io/gradiente/core-api/working-with-gradients.html)
|
|
74
|
+
- [Custom Gradients](https://flowscape-ui.github.io/gradiente/core-api/custom-gradients.html)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
## What it does
|
|
78
|
+
|
|
79
|
+
- Parses gradients into structured objects
|
|
80
|
+
- Normalizes angles, positions, and stops
|
|
81
|
+
- Transforms gradients to different targets:
|
|
82
|
+
- CSS
|
|
83
|
+
- Canvas
|
|
84
|
+
- (more coming)
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Built for
|
|
89
|
+
|
|
90
|
+
* design tools
|
|
91
|
+
* visual editors
|
|
92
|
+
* canvas engines
|
|
93
|
+
* WebGL / Pixi / Konva
|
|
94
|
+
* custom rendering pipelines
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Philosophy
|
|
99
|
+
|
|
100
|
+
Gradiente treats gradients as a graphics primitive.
|
|
101
|
+
|
|
102
|
+
Not a string to preserve -
|
|
103
|
+
but data you can transform and render anywhere.
|
|
104
|
+
|
|
105
|
+
## Contributing
|
|
106
|
+
|
|
107
|
+
Contributions of all kinds (feedback, ideas, bug fixes, documentation) are welcome.
|
|
108
|
+
|
|
109
|
+
Please open a GitHub issue/discussion before putting in any work that’s not straightforward.
|
|
110
|
+
|
|
94
111
|
More in [CONTRIBUTING.md](../../CONTRIBUTING.md).
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var gradiente=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e,t){let n=10**t;return Math.round(e*n)/n}function n(e,t){let n=10**t;return Math.floor(e*n)/n}function r(e,t){let n=10**t;return Math.ceil(e*n)/n}function i(e,t){let n=10**t;return Math.trunc(e*n)/n}function a(e,t,n){return Math.min(Math.max(e,t),n)}function o(e){return e/100}function s(e){return e*100}function c(e){return e===`deg`||e===`rad`||e===`turn`||e===`grad`}function l(e){try{return typeof u(e)==`number`}catch{return!1}}function u(e){let t=e.match(/^([+-]?(?:\d+\.?\d*|\.\d+))(deg|rad|turn|grad)$/);if(t===null)throw Error(`Invalid angle value: "${e}"`);if(!c(t[2]))throw Error(`Unsupported angle unit: "${t[2]}"`);if(!Number.isFinite(+t[1]))throw SyntaxError(`Invalid angle value: "${t[1]}"`);let n=Number(t[1]);switch(t[2]){case`deg`:return d(n);case`rad`:return n;case`turn`:return p(n);case`grad`:return m(n)}}function d(e){return e*Math.PI/180}function f(e){return e*180/Math.PI}function p(e){return e*Math.PI*2}function m(e){return e*Math.PI/200}function h(e,n=3){return t((e%360+360)%360,n)}function g(e,n=6){let r=Math.PI*2;return t((e%r+r)%r,n)}let _=(e,t)=>{if(typeof e==`number`){if(t===3)return{mode:`rgb`,r:(e>>8&15|e>>4&240)/255,g:(e>>4&15|e&240)/255,b:(e&15|e<<4&240)/255};if(t===4)return{mode:`rgb`,r:(e>>12&15|e>>8&240)/255,g:(e>>8&15|e>>4&240)/255,b:(e>>4&15|e&240)/255,alpha:(e&15|e<<4&240)/255};if(t===6)return{mode:`rgb`,r:(e>>16&255)/255,g:(e>>8&255)/255,b:(e&255)/255};if(t===8)return{mode:`rgb`,r:(e>>24&255)/255,g:(e>>16&255)/255,b:(e>>8&255)/255,alpha:(e&255)/255}}},v={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},y=e=>_(v[e.toLowerCase()],6),b=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,x=e=>{let t;return(t=e.match(b))?_(parseInt(t[1],16),t[1].length):void 0},S=`([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)`;`${S}`;let C=`${S}%`;`${S}`;let w=`(?:${S}%|${S})`,T=`(?:${S}%|${S}|none)`,ee=`(?:${S}(deg|grad|rad|turn)|${S})`;`${S}${S}`;let E=`\\s*,\\s*`;RegExp(`^`+T+`$`);let D=RegExp(`^rgba?\\(\\s*${S}${E}${S}${E}${S}\\s*(?:,\\s*${w}\\s*)?\\)$`),te=RegExp(`^rgba?\\(\\s*${C}${E}${C}${E}${C}\\s*(?:,\\s*${w}\\s*)?\\)$`),ne=e=>{let t={mode:`rgb`},n;if(n=e.match(D))n[1]!==void 0&&(t.r=n[1]/255),n[2]!==void 0&&(t.g=n[2]/255),n[3]!==void 0&&(t.b=n[3]/255);else if(n=e.match(te))n[1]!==void 0&&(t.r=n[1]/100),n[2]!==void 0&&(t.g=n[2]/100),n[3]!==void 0&&(t.b=n[3]/100);else return;return n[4]===void 0?n[5]!==void 0&&(t.alpha=Math.max(0,Math.min(1,+n[5]))):t.alpha=Math.max(0,Math.min(1,n[4]/100)),t},re=(e,t)=>e===void 0?void 0:typeof e==`object`?e.mode===void 0?t?{...e,mode:t}:void 0:e:xe(e),O=(e=`rgb`)=>t=>(t=re(t,e))===void 0?void 0:t.mode===e?t:k[t.mode][e]?k[t.mode][e](t):e===`rgb`?k[t.mode].rgb(t):k.rgb[e](k[t.mode].rgb(t)),k={},ie={},A=[],ae={},oe=e=>e,j=e=>(k[e.mode]={...k[e.mode],...e.toMode},Object.keys(e.fromMode||{}).forEach(t=>{k[t]||(k[t]={}),k[t][e.mode]=e.fromMode[t]}),e.ranges||={},e.difference||={},e.channels.forEach(t=>{if(e.ranges[t]===void 0&&(e.ranges[t]=[0,1]),!e.interpolate[t])throw Error(`Missing interpolator for: ${t}`);typeof e.interpolate[t]==`function`&&(e.interpolate[t]={use:e.interpolate[t]}),e.interpolate[t].fixup||(e.interpolate[t].fixup=oe)}),ie[e.mode]=e,(e.parse||[]).forEach(t=>{ce(t,e.mode)}),O(e.mode)),se=e=>ie[e],ce=(e,t)=>{if(typeof e==`string`){if(!t)throw Error(`'mode' required when 'parser' is a string`);ae[e]=t}else typeof e==`function`&&A.indexOf(e)<0&&A.push(e)},le=/[^\x00-\x7F]|[a-zA-Z_]/,ue=/[^\x00-\x7F]|[-\w]/,M={Function:`function`,Ident:`ident`,Number:`number`,Percentage:`percentage`,ParenClose:`)`,None:`none`,Hue:`hue`,Alpha:`alpha`},N=0;function de(e){let t=e[N],n=e[N+1];return t===`-`||t===`+`?/\d/.test(n)||n===`.`&&/\d/.test(e[N+2]):t===`.`?/\d/.test(n):/\d/.test(t)}function fe(e){if(N>=e.length)return!1;let t=e[N];if(le.test(t))return!0;if(t===`-`){if(e.length-N<2)return!1;let t=e[N+1];return!!(t===`-`||le.test(t))}return!1}let pe={deg:1,rad:180/Math.PI,grad:9/10,turn:360};function P(e){let t=``;if((e[N]===`-`||e[N]===`+`)&&(t+=e[N++]),t+=me(e),e[N]===`.`&&/\d/.test(e[N+1])&&(t+=e[N++]+me(e)),(e[N]===`e`||e[N]===`E`)&&((e[N+1]===`-`||e[N+1]===`+`)&&/\d/.test(e[N+2])?t+=e[N++]+e[N++]+me(e):/\d/.test(e[N+1])&&(t+=e[N++]+me(e))),fe(e)){let n=he(e);return n===`deg`||n===`rad`||n===`turn`||n===`grad`?{type:M.Hue,value:t*pe[n]}:void 0}return e[N]===`%`?(N++,{type:M.Percentage,value:+t}):{type:M.Number,value:+t}}function me(e){let t=``;for(;/\d/.test(e[N]);)t+=e[N++];return t}function he(e){let t=``;for(;N<e.length&&ue.test(e[N]);)t+=e[N++];return t}function ge(e){let t=he(e);return e[N]===`(`?(N++,{type:M.Function,value:t}):t===`none`?{type:M.None,value:void 0}:{type:M.Ident,value:t}}function _e(e=``){let t=e.trim(),n=[],r;for(N=0;N<t.length;){if(r=t[N++],r===`
|
|
2
|
+
`||r===` `||r===` `){for(;N<t.length&&(t[N]===`
|
|
3
|
+
`||t[N]===` `||t[N]===` `);)N++;continue}if(r===`,`)return;if(r===`)`){n.push({type:M.ParenClose});continue}if(r===`+`){if(N--,de(t)){n.push(P(t));continue}return}if(r===`-`){if(N--,de(t)){n.push(P(t));continue}if(fe(t)){n.push({type:M.Ident,value:he(t)});continue}return}if(r===`.`){if(N--,de(t)){n.push(P(t));continue}return}if(r===`/`){for(;N<t.length&&(t[N]===`
|
|
4
|
+
`||t[N]===` `||t[N]===` `);)N++;let e;if(de(t)&&(e=P(t),e.type!==M.Hue)){n.push({type:M.Alpha,value:e});continue}if(fe(t)&&he(t)===`none`){n.push({type:M.Alpha,value:{type:M.None,value:void 0}});continue}return}if(/\d/.test(r)){N--,n.push(P(t));continue}if(le.test(r)){N--,n.push(ge(t));continue}return}return n}function ve(e){e._i=0;let t=e[e._i++];if(!t||t.type!==M.Function||t.value!==`color`||(t=e[e._i++],t.type!==M.Ident))return;let n=ae[t.value];if(!n)return;let r={mode:n},i=ye(e,!1);if(!i)return;let a=se(n).channels;for(let e=0,t,n;e<a.length;e++)t=i[e],n=a[e],t.type!==M.None&&(r[n]=t.type===M.Number?t.value:t.value/100,n===`alpha`&&(r[n]=Math.max(0,Math.min(1,r[n]))));return r}function ye(e,t){let n=[],r;for(;e._i<e.length;){if(r=e[e._i++],r.type===M.None||r.type===M.Number||r.type===M.Alpha||r.type===M.Percentage||t&&r.type===M.Hue){n.push(r);continue}if(r.type===M.ParenClose){if(e._i<e.length)return;continue}return}if(!(n.length<3||n.length>4)){if(n.length===4){if(n[3].type!==M.Alpha)return;n[3]=n[3].value}return n.length===3&&n.push({type:M.None,value:void 0}),n.every(e=>e.type!==M.Alpha)?n:void 0}}function be(e,t){e._i=0;let n=e[e._i++];if(!n||n.type!==M.Function)return;let r=ye(e,t);if(r)return r.unshift(n.value),r}let xe=e=>{if(typeof e!=`string`)return;let t=_e(e),n=t?be(t,!0):void 0,r,i=0,a=A.length;for(;i<a;)if((r=A[i++](e,n))!==void 0)return r;return t?ve(t):void 0};function Se(e,t){if(!t||t[0]!==`rgb`&&t[0]!==`rgba`)return;let n={mode:`rgb`},[,r,i,a,o]=t;if(!(r.type===M.Hue||i.type===M.Hue||a.type===M.Hue))return r.type!==M.None&&(n.r=r.type===M.Number?r.value/255:r.value/100),i.type!==M.None&&(n.g=i.type===M.Number?i.value/255:i.value/100),a.type!==M.None&&(n.b=a.type===M.Number?a.value/255:a.value/100),o.type!==M.None&&(n.alpha=Math.min(1,Math.max(0,o.type===M.Number?o.value:o.value/100))),n}let Ce=e=>e===`transparent`?{mode:`rgb`,r:0,g:0,b:0,alpha:0}:void 0,we=(e,t,n)=>e+n*(t-e),Te=e=>{let t=[];for(let n=0;n<e.length-1;n++){let r=e[n],i=e[n+1];r===void 0&&i===void 0?t.push(void 0):r!==void 0&&i!==void 0?t.push([r,i]):t.push(r===void 0?[i,i]:[r,r])}return t},F=(e=>t=>{let n=Te(t);return t=>{let r=t*n.length,i=t>=1?n.length-1:Math.max(Math.floor(r),0),a=n[i];return a===void 0?void 0:e(a[0],a[1],r-i)}})(we),I=e=>{let t=!1,n=e.map(e=>e===void 0?1:(t=!0,e));return t?n:e},L={mode:`rgb`,channels:[`r`,`g`,`b`,`alpha`],parse:[Se,x,ne,y,Ce,`srgb`],serialize:`srgb`,interpolate:{r:F,g:F,b:F,alpha:{use:F,fixup:I}},gamut:!0,white:{r:1,g:1,b:1},black:{r:0,g:0,b:0}},Ee=(e=0)=>Math.abs(e)**(563/256)*Math.sign(e),De=e=>{let t=Ee(e.r),n=Ee(e.g),r=Ee(e.b),i={mode:`xyz65`,x:.5766690429101305*t+.1855582379065463*n+.1882286462349947*r,y:.297344975250536*t+.6273635662554661*n+.0752914584939979*r,z:.0270313613864123*t+.0706888525358272*n+.9913375368376386*r};return e.alpha!==void 0&&(i.alpha=e.alpha),i},Oe=e=>Math.abs(e)**(256/563)*Math.sign(e),ke=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`a98`,r:Oe(e*2.0415879038107465-t*.5650069742788597-.3447313507783297*n),g:Oe(e*-.9692436362808798+t*1.8759675015077206+.0415550574071756*n),b:Oe(e*.0134442806320312-t*.1183623922310184+1.0151749943912058*n)};return r!==void 0&&(i.alpha=r),i},Ae=(e=0)=>{let t=Math.abs(e);return t<=.04045?e/12.92:(Math.sign(e)||1)*((t+.055)/1.055)**2.4},R=({r:e,g:t,b:n,alpha:r})=>{let i={mode:`lrgb`,r:Ae(e),g:Ae(t),b:Ae(n)};return r!==void 0&&(i.alpha=r),i},z=e=>{let{r:t,g:n,b:r,alpha:i}=R(e),a={mode:`xyz65`,x:.4123907992659593*t+.357584339383878*n+.1804807884018343*r,y:.2126390058715102*t+.715168678767756*n+.0721923153607337*r,z:.0193308187155918*t+.119194779794626*n+.9505321522496607*r};return i!==void 0&&(a.alpha=i),a},je=(e=0)=>{let t=Math.abs(e);return t>.0031308?(Math.sign(e)||1)*(1.055*t**(1/2.4)-.055):e*12.92},B=({r:e,g:t,b:n,alpha:r},i=`rgb`)=>{let a={mode:i,r:je(e),g:je(t),b:je(n)};return r!==void 0&&(a.alpha=r),a},V=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=B({r:e*3.2409699419045226-t*1.537383177570094-.4986107602930034*n,g:e*-.9692436362808796+t*1.8759675015077204+.0415550574071756*n,b:e*.0556300796969936-t*.2039769588889765+1.0569715142428784*n});return r!==void 0&&(i.alpha=r),i},Me={...L,mode:`a98`,parse:[`a98-rgb`],serialize:`a98-rgb`,fromMode:{rgb:e=>ke(z(e)),xyz65:ke},toMode:{rgb:e=>V(De(e)),xyz65:De}},H=e=>(e%=360)<0?e+360:e,Ne=(e,t)=>e.map((n,r,i)=>{if(n===void 0)return n;let a=H(n);return r===0||e[r-1]===void 0?a:t(a-H(i[r-1]))}).reduce((e,t)=>!e.length||t===void 0||e[e.length-1]===void 0?(e.push(t),e):(e.push(t+e[e.length-1]),e),[]),U=e=>Ne(e,e=>Math.abs(e)<=180?e:e-360*Math.sign(e)),Pe=e=>Ne(e,e=>Math.abs(e)>=180||e===0?e:e-360*Math.sign(e)),Fe=e=>Ne(e,e=>e>=0?e:e+360),Ie=e=>Ne(e,e=>e<=0?e:e-360),W=[-.14861,1.78277,-.29227,-.90649,1.97294,0],Le=Math.PI/180,Re=180/Math.PI,ze=W[3]*W[4],Be=W[1]*W[4],Ve=W[1]*W[2]-W[0]*W[3],He=({r:e,g:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(Ve*n+e*ze-t*Be)/(Ve+ze-Be),a=n-i,o=(W[4]*(t-i)-W[2]*a)/W[3],s={mode:`cubehelix`,l:i,s:i===0||i===1?void 0:Math.sqrt(a*a+o*o)/(W[4]*i*(1-i))};return s.s&&(s.h=Math.atan2(o,a)*Re-120),r!==void 0&&(s.alpha=r),s},Ue=({h:e,s:t,l:n,alpha:r})=>{let i={mode:`rgb`};e=(e===void 0?0:e+120)*Le,n===void 0&&(n=0);let a=t===void 0?0:t*n*(1-n),o=Math.cos(e),s=Math.sin(e);return i.r=n+a*(W[0]*o+W[1]*s),i.g=n+a*(W[2]*o+W[3]*s),i.b=n+a*(W[4]*o+W[5]*s),r!==void 0&&(i.alpha=r),i},We=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.s||!t.s)return 0;let n=H(e.h),r=H(t.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.s*t.s)*i},Ge=(e,t)=>{if(e.h===void 0||t.h===void 0)return 0;let n=H(e.h),r=H(t.h);return Math.abs(r-n)>180?n-(r-360*Math.sign(r-n)):r-n},Ke=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.c||!t.c)return 0;let n=H(e.h),r=H(t.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.c*t.c)*i},G=e=>{let t=e.reduce((e,t)=>{if(t!==void 0){let n=t*Math.PI/180;e.sin+=Math.sin(n),e.cos+=Math.cos(n)}return e},{sin:0,cos:0}),n=Math.atan2(t.sin,t.cos)*180/Math.PI;return n<0?360+n:n},qe={mode:`cubehelix`,channels:[`h`,`s`,`l`,`alpha`],parse:[`--cubehelix`],serialize:`--cubehelix`,ranges:{h:[0,360],s:[0,4.614],l:[0,1]},fromMode:{rgb:He},toMode:{rgb:Ue},interpolate:{h:{use:F,fixup:U},s:F,l:F,alpha:{use:F,fixup:I}},difference:{h:We},average:{h:G}},K=({l:e,a:t,b:n,alpha:r},i=`lch`)=>{t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.sqrt(t*t+n*n),o={mode:i,l:e,c:a};return a&&(o.h=H(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(o.alpha=r),o},q=({l:e,c:t,h:n,alpha:r},i=`lab`)=>{n===void 0&&(n=0);let a={mode:i,l:e,a:t?t*Math.cos(n/180*Math.PI):0,b:t?t*Math.sin(n/180*Math.PI):0};return r!==void 0&&(a.alpha=r),a},Je=29**3/3**3,Ye=6**3/29**3,J={X:.3457/.3585,Y:1,Z:.2958/.3585},Y={X:.3127/.329,Y:1,Z:.3583/.329},Xe=e=>e**3>Ye?e**3:(116*e-16)/Je,Ze=({l:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(e+16)/116,a=t/500+i,o=i-n/200,s={mode:`xyz65`,x:Xe(a)*Y.X,y:Xe(i)*Y.Y,z:Xe(o)*Y.Z};return r!==void 0&&(s.alpha=r),s},Qe=e=>V(Ze(e)),$e=e=>e>Ye?Math.cbrt(e):(Je*e+16)/116,et=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=$e(e/Y.X),a=$e(t/Y.Y),o=$e(n/Y.Z),s={mode:`lab65`,l:116*a-16,a:500*(i-a),b:200*(a-o)};return r!==void 0&&(s.alpha=r),s},tt=e=>{let t=et(z(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},nt=26/180*Math.PI,rt=Math.cos(nt),it=Math.sin(nt),at=100/Math.log(139/100),ot=({l:e,c:t,h:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`lab65`,l:(Math.exp(e*1/at)-1)/.0039},a=(Math.exp(.0435*t*1*1)-1)/.075,o=a*Math.cos(n/180*Math.PI-nt),s=a*Math.sin(n/180*Math.PI-nt);return i.a=o*rt-s/.83*it,i.b=o*it+s/.83*rt,r!==void 0&&(i.alpha=r),i},st=({l:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=t*rt+n*it,a=.83*(n*rt-t*it),o=Math.sqrt(i*i+a*a),s={mode:`dlch`,l:at/1*Math.log(1+.0039*e),c:Math.log(1+.075*o)/(.0435*1*1)};return s.c&&(s.h=H((Math.atan2(a,i)+nt)/Math.PI*180)),r!==void 0&&(s.alpha=r),s},ct=e=>ot(K(e,`dlch`)),lt=e=>q(st(e),`dlab`),ut={mode:`dlab`,parse:[`--din99o-lab`],serialize:`--din99o-lab`,toMode:{lab65:ct,rgb:e=>Qe(ct(e))},fromMode:{lab65:lt,rgb:e=>lt(tt(e))},channels:[`l`,`a`,`b`,`alpha`],ranges:{l:[0,100],a:[-40.09,45.501],b:[-40.469,44.344]},interpolate:{l:F,a:F,b:F,alpha:{use:F,fixup:I}}},dt={mode:`dlch`,parse:[`--din99o-lch`],serialize:`--din99o-lch`,toMode:{lab65:ot,dlab:e=>q(e,`dlab`),rgb:e=>Qe(ot(e))},fromMode:{lab65:st,dlab:e=>K(e,`dlch`),rgb:e=>st(tt(e))},channels:[`l`,`c`,`h`,`alpha`],ranges:{l:[0,100],c:[0,51.484],h:[0,360]},interpolate:{l:F,c:F,h:{use:F,fixup:U},alpha:{use:F,fixup:I}},difference:{h:Ke},average:{h:G}};function ft({h:e,s:t,i:n,alpha:r}){e=H(e===void 0?0:e),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.abs(e/60%2-1),a;switch(Math.floor(e/60)){case 0:a={r:n*(1+t*(3/(2-i)-1)),g:n*(1+t*(3*(1-i)/(2-i)-1)),b:n*(1-t)};break;case 1:a={r:n*(1+t*(3*(1-i)/(2-i)-1)),g:n*(1+t*(3/(2-i)-1)),b:n*(1-t)};break;case 2:a={r:n*(1-t),g:n*(1+t*(3/(2-i)-1)),b:n*(1+t*(3*(1-i)/(2-i)-1))};break;case 3:a={r:n*(1-t),g:n*(1+t*(3*(1-i)/(2-i)-1)),b:n*(1+t*(3/(2-i)-1))};break;case 4:a={r:n*(1+t*(3*(1-i)/(2-i)-1)),g:n*(1-t),b:n*(1+t*(3/(2-i)-1))};break;case 5:a={r:n*(1+t*(3/(2-i)-1)),g:n*(1-t),b:n*(1+t*(3*(1-i)/(2-i)-1))};break;default:a={r:n*(1-t),g:n*(1-t),b:n*(1-t)}}return a.mode=`rgb`,r!==void 0&&(a.alpha=r),a}function pt({r:e,g:t,b:n,alpha:r}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.max(e,t,n),a=Math.min(e,t,n),o={mode:`hsi`,s:e+t+n===0?0:1-3*a/(e+t+n),i:(e+t+n)/3};return i-a!==0&&(o.h=(i===e?(t-n)/(i-a)+(t<n)*6:i===t?(n-e)/(i-a)+2:(e-t)/(i-a)+4)*60),r!==void 0&&(o.alpha=r),o}let mt={mode:`hsi`,toMode:{rgb:ft},parse:[`--hsi`],serialize:`--hsi`,fromMode:{rgb:pt},channels:[`h`,`s`,`i`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,interpolate:{h:{use:F,fixup:U},s:F,i:F,alpha:{use:F,fixup:I}},difference:{h:We},average:{h:G}};function ht({h:e,s:t,l:n,alpha:r}){e=H(e===void 0?0:e),t===void 0&&(t=0),n===void 0&&(n=0);let i=n+t*(n<.5?n:1-n),a=i-(i-n)*2*Math.abs(e/60%2-1),o;switch(Math.floor(e/60)){case 0:o={r:i,g:a,b:2*n-i};break;case 1:o={r:a,g:i,b:2*n-i};break;case 2:o={r:2*n-i,g:i,b:a};break;case 3:o={r:2*n-i,g:a,b:i};break;case 4:o={r:a,g:2*n-i,b:i};break;case 5:o={r:i,g:2*n-i,b:a};break;default:o={r:2*n-i,g:2*n-i,b:2*n-i}}return o.mode=`rgb`,r!==void 0&&(o.alpha=r),o}function gt({r:e,g:t,b:n,alpha:r}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.max(e,t,n),a=Math.min(e,t,n),o={mode:`hsl`,s:i===a?0:(i-a)/(1-Math.abs(i+a-1)),l:.5*(i+a)};return i-a!==0&&(o.h=(i===e?(t-n)/(i-a)+(t<n)*6:i===t?(n-e)/(i-a)+2:(e-t)/(i-a)+4)*60),r!==void 0&&(o.alpha=r),o}let _t=(e,t)=>{switch(t){case`deg`:return+e;case`rad`:return e/Math.PI*180;case`grad`:return e/10*9;case`turn`:return e*360}},vt=RegExp(`^hsla?\\(\\s*${ee}${E}${C}${E}${C}\\s*(?:,\\s*${w}\\s*)?\\)$`),yt=e=>{let t=e.match(vt);if(!t)return;let n={mode:`hsl`};return t[3]===void 0?t[1]!==void 0&&t[2]!==void 0&&(n.h=_t(t[1],t[2])):n.h=+t[3],t[4]!==void 0&&(n.s=Math.min(Math.max(0,t[4]/100),1)),t[5]!==void 0&&(n.l=Math.min(Math.max(0,t[5]/100),1)),t[6]===void 0?t[7]!==void 0&&(n.alpha=Math.max(0,Math.min(1,+t[7]))):n.alpha=Math.max(0,Math.min(1,t[6]/100)),n};function bt(e,t){if(!t||t[0]!==`hsl`&&t[0]!==`hsla`)return;let n={mode:`hsl`},[,r,i,a,o]=t;if(r.type!==M.None){if(r.type===M.Percentage)return;n.h=r.value}if(i.type!==M.None){if(i.type===M.Hue)return;n.s=i.value/100}if(a.type!==M.None){if(a.type===M.Hue)return;n.l=a.value/100}return o.type!==M.None&&(n.alpha=Math.min(1,Math.max(0,o.type===M.Number?o.value:o.value/100))),n}let xt={mode:`hsl`,toMode:{rgb:ht},fromMode:{rgb:gt},channels:[`h`,`s`,`l`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,parse:[bt,yt],serialize:e=>`hsl(${e.h===void 0?`none`:e.h} ${e.s===void 0?`none`:e.s*100+`%`} ${e.l===void 0?`none`:e.l*100+`%`}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{h:{use:F,fixup:U},s:F,l:F,alpha:{use:F,fixup:I}},difference:{h:We},average:{h:G}};function St({h:e,s:t,v:n,alpha:r}){e=H(e===void 0?0:e),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.abs(e/60%2-1),a;switch(Math.floor(e/60)){case 0:a={r:n,g:n*(1-t*i),b:n*(1-t)};break;case 1:a={r:n*(1-t*i),g:n,b:n*(1-t)};break;case 2:a={r:n*(1-t),g:n,b:n*(1-t*i)};break;case 3:a={r:n*(1-t),g:n*(1-t*i),b:n};break;case 4:a={r:n*(1-t*i),g:n*(1-t),b:n};break;case 5:a={r:n,g:n*(1-t),b:n*(1-t*i)};break;default:a={r:n*(1-t),g:n*(1-t),b:n*(1-t)}}return a.mode=`rgb`,r!==void 0&&(a.alpha=r),a}function Ct({r:e,g:t,b:n,alpha:r}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.max(e,t,n),a=Math.min(e,t,n),o={mode:`hsv`,s:i===0?0:1-a/i,v:i};return i-a!==0&&(o.h=(i===e?(t-n)/(i-a)+(t<n)*6:i===t?(n-e)/(i-a)+2:(e-t)/(i-a)+4)*60),r!==void 0&&(o.alpha=r),o}let wt={mode:`hsv`,toMode:{rgb:St},parse:[`--hsv`],serialize:`--hsv`,fromMode:{rgb:Ct},channels:[`h`,`s`,`v`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,interpolate:{h:{use:F,fixup:U},s:F,v:F,alpha:{use:F,fixup:I}},difference:{h:We},average:{h:G}};function Tt({h:e,w:t,b:n,alpha:r}){if(t===void 0&&(t=0),n===void 0&&(n=0),t+n>1){let e=t+n;t/=e,n/=e}return St({h:e,s:n===1?1:1-t/(1-n),v:1-n,alpha:r})}function Et(e){let t=Ct(e);if(t===void 0)return;let n=t.s===void 0?0:t.s,r=t.v===void 0?0:t.v,i={mode:`hwb`,w:(1-n)*r,b:1-r};return t.h!==void 0&&(i.h=t.h),t.alpha!==void 0&&(i.alpha=t.alpha),i}function Dt(e,t){if(!t||t[0]!==`hwb`)return;let n={mode:`hwb`},[,r,i,a,o]=t;if(r.type!==M.None){if(r.type===M.Percentage)return;n.h=r.value}if(i.type!==M.None){if(i.type===M.Hue)return;n.w=i.value/100}if(a.type!==M.None){if(a.type===M.Hue)return;n.b=a.value/100}return o.type!==M.None&&(n.alpha=Math.min(1,Math.max(0,o.type===M.Number?o.value:o.value/100))),n}let Ot={mode:`hwb`,toMode:{rgb:Tt},fromMode:{rgb:Et},channels:[`h`,`w`,`b`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,parse:[Dt],serialize:e=>`hwb(${e.h===void 0?`none`:e.h} ${e.w===void 0?`none`:e.w*100+`%`} ${e.b===void 0?`none`:e.b*100+`%`}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{h:{use:F,fixup:U},w:F,b:F,alpha:{use:F,fixup:I}},difference:{h:Ge},average:{h:G}},kt=.1593017578125,At=78.84375,jt=.8359375,Mt=18.8515625,Nt=18.6875;function Pt(e){if(e<0)return 0;let t=e**(1/At);return 1e4*(Math.max(0,t-jt)/(Mt-Nt*t))**(1/kt)}function Ft(e){if(e<0)return 0;let t=(e/1e4)**kt;return((jt+Mt*t)/(1+Nt*t))**+At}let It=e=>Math.max(e/203,0),Lt=({i:e,t,p:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Pt(e+.008609037037932761*t+.11102962500302593*n),a=Pt(e-.00860903703793275*t-.11102962500302599*n),o=Pt(e+.5600313357106791*t-.32062717498731885*n),s={mode:`xyz65`,x:It(2.070152218389422*i-1.3263473389671556*a+.2066510476294051*o),y:It(.3647385209748074*i+.680566024947227*a-.0453045459220346*o),z:It(-.049747207535812*i-.0492609666966138*a+1.1880659249923042*o)};return r!==void 0&&(s.alpha=r),s},Rt=(e=0)=>Math.max(e*203,0),zt=({x:e,y:t,z:n,alpha:r})=>{let i=Rt(e),a=Rt(t),o=Rt(n),s=Ft(.3592832590121217*i+.6976051147779502*a-.0358915932320289*o),c=Ft(-.1920808463704995*i+1.1004767970374323*a+.0753748658519118*o),l=Ft(.0070797844607477*i+.0748396662186366*a+.8433265453898765*o),u={mode:`itp`,i:.5*s+.5*c,t:1.61376953125*s-3.323486328125*c+1.709716796875*l,p:4.378173828125*s-4.24560546875*c-.132568359375*l};return r!==void 0&&(u.alpha=r),u},Bt={mode:`itp`,channels:[`i`,`t`,`p`,`alpha`],parse:[`--ictcp`],serialize:`--ictcp`,toMode:{xyz65:Lt,rgb:e=>V(Lt(e))},fromMode:{xyz65:zt,rgb:e=>zt(z(e))},ranges:{i:[0,.581],t:[-.369,.272],p:[-.164,.331]},interpolate:{i:F,t:F,p:F,alpha:{use:F,fixup:I}}},Vt=e=>{if(e<0)return 0;let t=(e/1e4)**kt;return((jt+Mt*t)/(1+Nt*t))**134.03437499999998},Ht=(e=0)=>Math.max(e*203,0),Ut=({x:e,y:t,z:n,alpha:r})=>{e=Ht(e),t=Ht(t),n=Ht(n);let i=1.15*e-.15*n,a=.66*t+.34*e,o=Vt(.41478972*i+.579999*a+.014648*n),s=Vt(-.20151*i+1.120649*a+.0531008*n),c=Vt(-.0166008*i+.2648*a+.6684799*n),l=(o+s)/2,u={mode:`jab`,j:.44*l/(1-.56*l)-16295499532821565e-27,a:3.524*o-4.066708*s+.542708*c,b:.199076*o+1.096799*s-1.295875*c};return r!==void 0&&(u.alpha=r),u},Wt=16295499532821565e-27,Gt=e=>{if(e<0)return 0;let t=e**(1/134.03437499999998);return 1e4*((jt-t)/(Nt*t-Mt))**(1/kt)},Kt=e=>e/203,qt=({j:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(e+Wt)/(.44+.56*(e+Wt)),a=Gt(i+.13860504*t+.058047316*n),o=Gt(i-.13860504*t-.058047316*n),s=Gt(i-.096019242*t-.8118919*n),c={mode:`xyz65`,x:Kt(1.661373024652174*a-.914523081304348*o+.23136208173913045*s),y:Kt(-.3250758611844533*a+1.571847026732543*o-.21825383453227928*s),z:Kt(-.090982811*a-.31272829*o+1.5227666*s)};return r!==void 0&&(c.alpha=r),c},Jt=e=>{let t=Ut(z(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},Yt=e=>V(qt(e)),Xt={mode:`jab`,channels:[`j`,`a`,`b`,`alpha`],parse:[`--jzazbz`],serialize:`--jzazbz`,fromMode:{rgb:Jt,xyz65:Ut},toMode:{rgb:Yt,xyz65:qt},ranges:{j:[0,.222],a:[-.109,.129],b:[-.185,.134]},interpolate:{j:F,a:F,b:F,alpha:{use:F,fixup:I}}},Zt=({j:e,a:t,b:n,alpha:r})=>{t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.sqrt(t*t+n*n),a={mode:`jch`,j:e,c:i};return i&&(a.h=H(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(a.alpha=r),a},Qt=({j:e,c:t,h:n,alpha:r})=>{n===void 0&&(n=0);let i={mode:`jab`,j:e,a:t?t*Math.cos(n/180*Math.PI):0,b:t?t*Math.sin(n/180*Math.PI):0};return r!==void 0&&(i.alpha=r),i},$t={mode:`jch`,parse:[`--jzczhz`],serialize:`--jzczhz`,toMode:{jab:Qt,rgb:e=>Yt(Qt(e))},fromMode:{rgb:e=>Zt(Jt(e)),jab:Zt},channels:[`j`,`c`,`h`,`alpha`],ranges:{j:[0,.221],c:[0,.19],h:[0,360]},interpolate:{h:{use:F,fixup:U},c:F,j:F,alpha:{use:F,fixup:I}},difference:{h:Ke},average:{h:G}},en=29**3/3**3,tn=6**3/29**3,nn=e=>e**3>tn?e**3:(116*e-16)/en,rn=({l:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(e+16)/116,a=t/500+i,o=i-n/200,s={mode:`xyz50`,x:nn(a)*J.X,y:nn(i)*J.Y,z:nn(o)*J.Z};return r!==void 0&&(s.alpha=r),s},an=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=B({r:e*3.1341359569958707-t*1.6173863321612538-.4906619460083532*n,g:e*-.978795502912089+t*1.916254567259524+.03344273116131949*n,b:e*.07195537988411677-t*.2289768264158322+1.405386058324125*n});return r!==void 0&&(i.alpha=r),i},on=e=>an(rn(e)),sn=e=>{let{r:t,g:n,b:r,alpha:i}=R(e),a={mode:`xyz50`,x:.436065742824811*t+.3851514688337912*n+.14307845442264197*r,y:.22249319175623702*t+.7168870538238823*n+.06061979053616537*r,z:.013923904500943465*t+.09708128566574634*n+.7140993584005155*r};return i!==void 0&&(a.alpha=i),a},cn=e=>e>tn?Math.cbrt(e):(en*e+16)/116,ln=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=cn(e/J.X),a=cn(t/J.Y),o=cn(n/J.Z),s={mode:`lab`,l:116*a-16,a:500*(i-a),b:200*(a-o)};return r!==void 0&&(s.alpha=r),s},un=e=>{let t=ln(sn(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t};function dn(e,t){if(!t||t[0]!==`lab`)return;let n={mode:`lab`},[,r,i,a,o]=t;if(!(r.type===M.Hue||i.type===M.Hue||a.type===M.Hue))return r.type!==M.None&&(n.l=Math.min(Math.max(0,r.value),100)),i.type!==M.None&&(n.a=i.type===M.Number?i.value:i.value*125/100),a.type!==M.None&&(n.b=a.type===M.Number?a.value:a.value*125/100),o.type!==M.None&&(n.alpha=Math.min(1,Math.max(0,o.type===M.Number?o.value:o.value/100))),n}let fn={mode:`lab`,toMode:{xyz50:rn,rgb:on},fromMode:{xyz50:ln,rgb:un},channels:[`l`,`a`,`b`,`alpha`],ranges:{l:[0,100],a:[-125,125],b:[-125,125]},parse:[dn],serialize:e=>`lab(${e.l===void 0?`none`:e.l} ${e.a===void 0?`none`:e.a} ${e.b===void 0?`none`:e.b}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{l:F,a:F,b:F,alpha:{use:F,fixup:I}}},pn={...fn,mode:`lab65`,parse:[`--lab-d65`],serialize:`--lab-d65`,toMode:{xyz65:Ze,rgb:Qe},fromMode:{xyz65:et,rgb:tt},ranges:{l:[0,100],a:[-125,125],b:[-125,125]}};function mn(e,t){if(!t||t[0]!==`lch`)return;let n={mode:`lch`},[,r,i,a,o]=t;if(r.type!==M.None){if(r.type===M.Hue)return;n.l=Math.min(Math.max(0,r.value),100)}if(i.type!==M.None&&(n.c=Math.max(0,i.type===M.Number?i.value:i.value*150/100)),a.type!==M.None){if(a.type===M.Percentage)return;n.h=a.value}return o.type!==M.None&&(n.alpha=Math.min(1,Math.max(0,o.type===M.Number?o.value:o.value/100))),n}let hn={mode:`lch`,toMode:{lab:q,rgb:e=>on(q(e))},fromMode:{rgb:e=>K(un(e)),lab:K},channels:[`l`,`c`,`h`,`alpha`],ranges:{l:[0,100],c:[0,150],h:[0,360]},parse:[mn],serialize:e=>`lch(${e.l===void 0?`none`:e.l} ${e.c===void 0?`none`:e.c} ${e.h===void 0?`none`:e.h}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{h:{use:F,fixup:U},c:F,l:F,alpha:{use:F,fixup:I}},difference:{h:Ke},average:{h:G}},gn={...hn,mode:`lch65`,parse:[`--lch-d65`],serialize:`--lch-d65`,toMode:{lab65:e=>q(e,`lab65`),rgb:e=>Qe(q(e,`lab65`))},fromMode:{rgb:e=>K(tt(e),`lch65`),lab65:e=>K(e,`lch65`)},ranges:{l:[0,100],c:[0,150],h:[0,360]}},_n=({l:e,u:t,v:n,alpha:r})=>{t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.sqrt(t*t+n*n),a={mode:`lchuv`,l:e,c:i};return i&&(a.h=H(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(a.alpha=r),a},vn=({l:e,c:t,h:n,alpha:r})=>{n===void 0&&(n=0);let i={mode:`luv`,l:e,u:t?t*Math.cos(n/180*Math.PI):0,v:t?t*Math.sin(n/180*Math.PI):0};return r!==void 0&&(i.alpha=r),i},yn=(e,t,n)=>4*e/(e+15*t+3*n),bn=(e,t,n)=>9*t/(e+15*t+3*n),xn=yn(J.X,J.Y,J.Z),Sn=bn(J.X,J.Y,J.Z),Cn=e=>e<=tn?en*e:116*Math.cbrt(e)-16,wn=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Cn(t/J.Y),a=yn(e,t,n),o=bn(e,t,n);!isFinite(a)||!isFinite(o)?i=a=o=0:(a=13*i*(a-xn),o=13*i*(o-Sn));let s={mode:`luv`,l:i,u:a,v:o};return r!==void 0&&(s.alpha=r),s},Tn=(e,t,n)=>4*e/(e+15*t+3*n),En=(e,t,n)=>9*t/(e+15*t+3*n),Dn=Tn(J.X,J.Y,J.Z),On=En(J.X,J.Y,J.Z),kn=({l:e,u:t,v:n,alpha:r})=>{if(e===void 0&&(e=0),e===0)return{mode:`xyz50`,x:0,y:0,z:0};t===void 0&&(t=0),n===void 0&&(n=0);let i=t/(13*e)+Dn,a=n/(13*e)+On,o=J.Y*(e<=8?e/en:((e+16)/116)**3),s={mode:`xyz50`,x:9*i*o/(4*a),y:o,z:o*(12-3*i-20*a)/(4*a)};return r!==void 0&&(s.alpha=r),s},An={mode:`lchuv`,toMode:{luv:vn,rgb:e=>an(kn(vn(e)))},fromMode:{rgb:e=>_n(wn(sn(e))),luv:_n},channels:[`l`,`c`,`h`,`alpha`],parse:[`--lchuv`],serialize:`--lchuv`,ranges:{l:[0,100],c:[0,176.956],h:[0,360]},interpolate:{h:{use:F,fixup:U},c:F,l:F,alpha:{use:F,fixup:I}},difference:{h:Ke},average:{h:G}},jn={...L,mode:`lrgb`,toMode:{rgb:B},fromMode:{rgb:R},parse:[`srgb-linear`],serialize:`srgb-linear`},Mn={mode:`luv`,toMode:{xyz50:kn,rgb:e=>an(kn(e))},fromMode:{xyz50:wn,rgb:e=>wn(sn(e))},channels:[`l`,`u`,`v`,`alpha`],parse:[`--luv`],serialize:`--luv`,ranges:{l:[0,100],u:[-84.936,175.042],v:[-125.882,87.243]},interpolate:{l:F,u:F,v:F,alpha:{use:F,fixup:I}}},Nn=({r:e,g:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.cbrt(.412221469470763*e+.5363325372617348*t+.0514459932675022*n),a=Math.cbrt(.2119034958178252*e+.6806995506452344*t+.1073969535369406*n),o=Math.cbrt(.0883024591900564*e+.2817188391361215*t+.6299787016738222*n),s={mode:`oklab`,l:.210454268309314*i+.7936177747023054*a-.0040720430116193*o,a:1.9779985324311684*i-2.42859224204858*a+.450593709617411*o,b:.0259040424655478*i+.7827717124575296*a-.8086757549230774*o};return r!==void 0&&(s.alpha=r),s},Pn=e=>{let t=Nn(R(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},Fn=({l:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(e+.3963377773761749*t+.2158037573099136*n)**3,a=(e-.1055613458156586*t-.0638541728258133*n)**3,o=(e-.0894841775298119*t-1.2914855480194092*n)**3,s={mode:`lrgb`,r:4.076741636075957*i-3.3077115392580616*a+.2309699031821044*o,g:-1.2684379732850317*i+2.6097573492876887*a-.3413193760026573*o,b:-.0041960761386756*i-.7034186179359362*a+1.7076146940746117*o};return r!==void 0&&(s.alpha=r),s},In=e=>B(Fn(e));function Ln(e){let t=.206,n=.03,r=(1+t)/(1+n);return .5*(r*e-t+Math.sqrt((r*e-t)*(r*e-t)+4*n*r*e))}function Rn(e){let t=.206,n=.03;return(1+t)/(1+n),(e*e+t*e)/(1.170873786407767*(e+n))}function zn(e,t){let n,r,i,a,o,s,c,l;-1.88170328*e-.80936493*t>1?(n=1.19086277,r=1.76576728,i=.59662641,a=.75515197,o=.56771245,s=4.0767416621,c=-3.3077115913,l=.2309699292):1.81444104*e-1.19445276*t>1?(n=.73956515,r=-.45954404,i=.08285427,a=.1254107,o=.14503204,s=-1.2684380046,c=2.6097574011,l=-.3413193965):(n=1.35733652,r=-.00915799,i=-1.1513021,a=-.50559606,o=.00692167,s=-.0041960863,c=-.7034186147,l=1.707614701);let u=n+r*e+i*t+a*e*e+o*e*t,d=.3963377774*e+.2158037573*t,f=-.1055613458*e-.0638541728*t,p=-.0894841775*e-1.291485548*t;{let e=1+u*d,t=1+u*f,n=1+u*p,r=e*e*e,i=t*t*t,a=n*n*n,o=3*d*e*e,m=3*f*t*t,h=3*p*n*n,g=6*d*d*e,_=6*f*f*t,v=6*p*p*n,y=s*r+c*i+l*a,b=s*o+c*m+l*h,x=s*g+c*_+l*v;u-=y*b/(b*b-.5*y*x)}return u}function Bn(e,t){let n=zn(e,t),r=Fn({l:1,a:n*e,b:n*t}),i=Math.cbrt(1/Math.max(r.r,r.g,r.b));return[i,i*n]}function Vn(e,t,n,r,i,a=null){a||=Bn(e,t);let o;if((n-i)*a[1]-(a[0]-i)*r<=0)o=a[1]*i/(r*a[0]+a[1]*(i-n));else{o=a[1]*(i-1)/(r*(a[0]-1)+a[1]*(i-n));{let a=n-i,s=r,c=.3963377774*e+.2158037573*t,l=-.1055613458*e-.0638541728*t,u=-.0894841775*e-1.291485548*t,d=a+s*c,f=a+s*l,p=a+s*u;{let e=i*(1-o)+o*n,t=o*r,a=e+t*c,s=e+t*l,m=e+t*u,h=a*a*a,g=s*s*s,_=m*m*m,v=3*d*a*a,y=3*f*s*s,b=3*p*m*m,x=6*d*d*a,S=6*f*f*s,C=6*p*p*m,w=4.0767416621*h-3.3077115913*g+.2309699292*_-1,T=4.0767416621*v-3.3077115913*y+.2309699292*b,ee=4.0767416621*x-3.3077115913*S+.2309699292*C,E=T/(T*T-.5*w*ee),D=-w*E,te=-1.2684380046*h+2.6097574011*g-.3413193965*_-1,ne=-1.2684380046*v+2.6097574011*y-.3413193965*b,re=-1.2684380046*x+2.6097574011*S-.3413193965*C,O=ne/(ne*ne-.5*te*re),k=-te*O,ie=-.0041960863*h-.7034186147*g+1.707614701*_-1,A=-.0041960863*v-.7034186147*y+1.707614701*b,ae=-.0041960863*x-.7034186147*S+1.707614701*C,oe=A/(A*A-.5*ie*ae),j=-ie*oe;D=E>=0?D:1e6,k=O>=0?k:1e6,j=oe>=0?j:1e6,o+=Math.min(D,Math.min(k,j))}}}return o}function Hn(e,t,n=null){n||=Bn(e,t);let r=n[0],i=n[1];return[i/r,i/(1-r)]}function Un(e,t,n){let r=Bn(t,n),i=Vn(t,n,e,1,e,r),a=Hn(t,n,r),o=.11516993+1/(7.4477897+4.1590124*n+t*(-2.19557347+1.75198401*n+t*(-2.13704948-10.02301043*n+t*(-4.24894561+5.38770819*n+4.69891013*t)))),s=.11239642+1/(1.6132032-.68124379*n+t*(.40370612+.90148123*n+t*(-.27087943+.6122399*n+t*(.00299215-.45399568*n-.14661872*t)))),c=i/Math.min(e*a[0],(1-e)*a[1]),l=e*o,u=(1-e)*s,d=.9*c*Math.sqrt(Math.sqrt(1/(1/(l*l*l*l)+1/(u*u*u*u))));return l=e*.4,u=(1-e)*.8,[Math.sqrt(1/(1/(l*l)+1/(u*u))),d,i]}function Wn(e){let t=e.l===void 0?0:e.l,n=e.a===void 0?0:e.a,r=e.b===void 0?0:e.b,i={mode:`okhsl`,l:Ln(t)};e.alpha!==void 0&&(i.alpha=e.alpha);let a=Math.sqrt(n*n+r*r);if(!a)return i.s=0,i;let[o,s,c]=Un(t,n/a,r/a),l;if(a<s){let e=.8*o,t=1-e/s;l=(a-0)/(e+t*(a-0))*.8}else{let e=s,t=.2*s*s*1.25*1.25/o,n=1-t/(c-s);l=.8+.2*((a-e)/(t+n*(a-e)))}return l&&(i.s=l,i.h=H(Math.atan2(r,n)*180/Math.PI)),i}function Gn(e){let t=e.h===void 0?0:e.h,n=e.s===void 0?0:e.s,r=e.l===void 0?0:e.l,i={mode:`oklab`,l:Rn(r)};if(e.alpha!==void 0&&(i.alpha=e.alpha),!n||r===1)return i.a=i.b=0,i;let a=Math.cos(t/180*Math.PI),o=Math.sin(t/180*Math.PI),[s,c,l]=Un(i.l,a,o),u,d,f,p;n<.8?(u=1.25*n,d=0,f=.8*s,p=1-f/c):(u=5*(n-.8),d=c,f=.2*c*c*1.25*1.25/s,p=1-f/(l-c));let m=d+u*f/(1-p*u);return i.a=m*a,i.b=m*o,i}let Kn={...xt,mode:`okhsl`,channels:[`h`,`s`,`l`,`alpha`],parse:[`--okhsl`],serialize:`--okhsl`,fromMode:{oklab:Wn,rgb:e=>Wn(Pn(e))},toMode:{oklab:Gn,rgb:e=>In(Gn(e))}};function qn(e){let t=e.l===void 0?0:e.l,n=e.a===void 0?0:e.a,r=e.b===void 0?0:e.b,i=Math.sqrt(n*n+r*r),a=i?n/i:1,o=i?r/i:1,[s,c]=Hn(a,o),l=.5,u=1-l/s,d=c/(i+t*c),f=d*t,p=d*i,m=Rn(f),h=p*m/f,g=Fn({l:m,a:a*h,b:o*h}),_=Math.cbrt(1/Math.max(g.r,g.g,g.b,0));t/=_,i=i/_*Ln(t)/t,t=Ln(t);let v={mode:`okhsv`,s:i?(l+c)*p/(c*l+c*u*p):0,v:t?t/f:0};return v.s&&(v.h=H(Math.atan2(r,n)*180/Math.PI)),e.alpha!==void 0&&(v.alpha=e.alpha),v}function Jn(e){let t={mode:`oklab`};e.alpha!==void 0&&(t.alpha=e.alpha);let n=e.h===void 0?0:e.h,r=e.s===void 0?0:e.s,i=e.v===void 0?0:e.v,a=Math.cos(n/180*Math.PI),o=Math.sin(n/180*Math.PI),[s,c]=Hn(a,o),l=.5,u=1-l/s,d=1-r*l/(l+c-c*u*r),f=r*c*l/(l+c-c*u*r),p=Rn(d),m=f*p/d,h=Fn({l:p,a:a*m,b:o*m}),g=Math.cbrt(1/Math.max(h.r,h.g,h.b,0)),_=Rn(i*d),v=f*_/d;return t.l=_*g,t.a=v*a*g,t.b=v*o*g,t}let Yn={...wt,mode:`okhsv`,channels:[`h`,`s`,`v`,`alpha`],parse:[`--okhsv`],serialize:`--okhsv`,fromMode:{oklab:qn,rgb:e=>qn(Pn(e))},toMode:{oklab:Jn,rgb:e=>In(Jn(e))}};function Xn(e,t){if(!t||t[0]!==`oklab`)return;let n={mode:`oklab`},[,r,i,a,o]=t;if(!(r.type===M.Hue||i.type===M.Hue||a.type===M.Hue))return r.type!==M.None&&(n.l=Math.min(Math.max(0,r.type===M.Number?r.value:r.value/100),1)),i.type!==M.None&&(n.a=i.type===M.Number?i.value:i.value*.4/100),a.type!==M.None&&(n.b=a.type===M.Number?a.value:a.value*.4/100),o.type!==M.None&&(n.alpha=Math.min(1,Math.max(0,o.type===M.Number?o.value:o.value/100))),n}let Zn={...fn,mode:`oklab`,toMode:{lrgb:Fn,rgb:In},fromMode:{lrgb:Nn,rgb:Pn},ranges:{l:[0,1],a:[-.4,.4],b:[-.4,.4]},parse:[Xn],serialize:e=>`oklab(${e.l===void 0?`none`:e.l} ${e.a===void 0?`none`:e.a} ${e.b===void 0?`none`:e.b}${e.alpha<1?` / ${e.alpha}`:``})`};function Qn(e,t){if(!t||t[0]!==`oklch`)return;let n={mode:`oklch`},[,r,i,a,o]=t;if(r.type!==M.None){if(r.type===M.Hue)return;n.l=Math.min(Math.max(0,r.type===M.Number?r.value:r.value/100),1)}if(i.type!==M.None&&(n.c=Math.max(0,i.type===M.Number?i.value:i.value*.4/100)),a.type!==M.None){if(a.type===M.Percentage)return;n.h=a.value}return o.type!==M.None&&(n.alpha=Math.min(1,Math.max(0,o.type===M.Number?o.value:o.value/100))),n}let $n={...hn,mode:`oklch`,toMode:{oklab:e=>q(e,`oklab`),rgb:e=>In(q(e,`oklab`))},fromMode:{rgb:e=>K(Pn(e),`oklch`),oklab:e=>K(e,`oklch`)},parse:[Qn],serialize:e=>`oklch(${e.l===void 0?`none`:e.l} ${e.c===void 0?`none`:e.c} ${e.h===void 0?`none`:e.h}${e.alpha<1?` / ${e.alpha}`:``})`,ranges:{l:[0,1],c:[0,.4],h:[0,360]}},er=e=>{let{r:t,g:n,b:r,alpha:i}=R(e),a={mode:`xyz65`,x:.486570948648216*t+.265667693169093*n+.1982172852343625*r,y:.2289745640697487*t+.6917385218365062*n+.079286914093745*r,z:0*t+.0451133818589026*n+1.043944368900976*r};return i!==void 0&&(a.alpha=i),a},tr=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=B({r:e*2.4934969119414263-t*.9313836179191242-.402710784450717*n,g:e*-.8294889695615749+t*1.7626640603183465+.0236246858419436*n,b:e*.0358458302437845-t*.0761723892680418+.9568845240076871*n},`p3`);return r!==void 0&&(i.alpha=r),i},nr={...L,mode:`p3`,parse:[`display-p3`],serialize:`display-p3`,fromMode:{rgb:e=>tr(z(e)),xyz65:tr},toMode:{rgb:e=>V(er(e)),xyz65:er}},rr=e=>{let t=Math.abs(e);return t>=1/512?Math.sign(e)*t**(1/1.8):16*e},ir=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`prophoto`,r:rr(e*1.3457868816471585-t*.2555720873797946-.0511018649755453*n),g:rr(e*-.5446307051249019+t*1.5082477428451466+.0205274474364214*n),b:rr(e*0+t*0+1.2119675456389452*n)};return r!==void 0&&(i.alpha=r),i},ar=(e=0)=>{let t=Math.abs(e);return t>=16/512?Math.sign(e)*t**1.8:e/16},or=e=>{let t=ar(e.r),n=ar(e.g),r=ar(e.b),i={mode:`xyz50`,x:.7977666449006423*t+.1351812974005331*n+.0313477341283922*r,y:.2880748288194013*t+.7118352342418731*n+899369387256e-16*r,z:0*t+0*n+.8251046025104602*r};return e.alpha!==void 0&&(i.alpha=e.alpha),i},sr={...L,mode:`prophoto`,parse:[`prophoto-rgb`],serialize:`prophoto-rgb`,fromMode:{xyz50:ir,rgb:e=>ir(sn(e))},toMode:{xyz50:or,rgb:e=>an(or(e))}},cr=1.09929682680944,lr=e=>{let t=Math.abs(e);return t>.018053968510807?(Math.sign(e)||1)*(cr*t**.45-(cr-1)):4.5*e},ur=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`rec2020`,r:lr(e*1.7166511879712683-t*.3556707837763925-.2533662813736599*n),g:lr(e*-.6666843518324893+t*1.6164812366349395+.0157685458139111*n),b:lr(e*.0176398574453108-t*.0427706132578085+.9421031212354739*n)};return r!==void 0&&(i.alpha=r),i},dr=1.09929682680944,fr=(e=0)=>{let t=Math.abs(e);return t<.018053968510807*4.5?e/4.5:(Math.sign(e)||1)*((t+dr-1)/dr)**(1/.45)},pr=e=>{let t=fr(e.r),n=fr(e.g),r=fr(e.b),i={mode:`xyz65`,x:.6369580483012911*t+.1446169035862083*n+.1688809751641721*r,y:.262700212011267*t+.6779980715188708*n+.059301716469862*r,z:0*t+.0280726930490874*n+1.0609850577107909*r};return e.alpha!==void 0&&(i.alpha=e.alpha),i},mr={...L,mode:`rec2020`,fromMode:{xyz65:ur,rgb:e=>ur(z(e))},toMode:{xyz65:pr,rgb:e=>V(pr(e))},parse:[`rec2020`],serialize:`rec2020`},X=.0037930732552754493,hr=Math.cbrt(X),gr=e=>Math.cbrt(e)-hr,_r=e=>{let{r:t,g:n,b:r,alpha:i}=R(e),a=gr(.3*t+.622*n+.078*r+X),o=gr(.23*t+.692*n+.078*r+X),s=gr(.2434226892454782*t+.2047674442449682*n+.5518098665095535*r+X),c={mode:`xyb`,x:(a-o)/2,y:(a+o)/2,b:s-(a+o)/2};return i!==void 0&&(c.alpha=i),c},vr=e=>(e+hr)**3,yr={mode:`xyb`,channels:[`x`,`y`,`b`,`alpha`],parse:[`--xyb`],serialize:`--xyb`,toMode:{rgb:({x:e,y:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=vr(e+t)-X,a=vr(t-e)-X,o=vr(n+t)-X,s=B({r:11.031566904639861*i-9.866943908131562*a-.16462299650829934*o,g:-3.2541473810744237*i+4.418770377582723*a-.16462299650829934*o,b:-3.6588512867136815*i+2.7129230459360922*a+1.9459282407775895*o});return r!==void 0&&(s.alpha=r),s}},fromMode:{rgb:_r},ranges:{x:[-.0154,.0281],y:[0,.8453],b:[-.2778,.388]},interpolate:{x:F,y:F,b:F,alpha:{use:F,fixup:I}}},br={mode:`xyz50`,parse:[`xyz-d50`],serialize:`xyz-d50`,toMode:{rgb:an,lab:ln},fromMode:{rgb:sn,lab:rn},channels:[`x`,`y`,`z`,`alpha`],ranges:{x:[0,.964],y:[0,.999],z:[0,.825]},interpolate:{x:F,y:F,z:F,alpha:{use:F,fixup:I}}},xr={mode:`xyz65`,toMode:{rgb:V,xyz50:e=>{let{x:t,y:n,z:r,alpha:i}=e;t===void 0&&(t=0),n===void 0&&(n=0),r===void 0&&(r=0);let a={mode:`xyz50`,x:1.0479298208405488*t+.0229467933410191*n-.0501922295431356*r,y:.0296278156881593*t+.990434484573249*n-.0170738250293851*r,z:-.0092430581525912*t+.0150551448965779*n+.7518742899580008*r};return i!==void 0&&(a.alpha=i),a}},fromMode:{rgb:z,xyz50:e=>{let{x:t,y:n,z:r,alpha:i}=e;t===void 0&&(t=0),n===void 0&&(n=0),r===void 0&&(r=0);let a={mode:`xyz65`,x:.9554734527042182*t-.0230985368742614*n+.0632593086610217*r,y:-.0283697069632081*t+1.0099954580058226*n+.021041398966943*r,z:.0123140016883199*t-.0205076964334779*n+1.3303659366080753*r};return i!==void 0&&(a.alpha=i),a}},ranges:{x:[0,.95],y:[0,1],z:[0,1.088]},channels:[`x`,`y`,`z`,`alpha`],parse:[`xyz`,`xyz-d65`],serialize:`xyz-d65`,interpolate:{x:F,y:F,z:F,alpha:{use:F,fixup:I}}},Sr={mode:`yiq`,toMode:{rgb:({y:e,i:t,q:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`rgb`,r:e+.95608445*t+.6208885*n,g:e-.27137664*t-.6486059*n,b:e-1.10561724*t+1.70250126*n};return r!==void 0&&(i.alpha=r),i}},fromMode:{rgb:({r:e,g:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`yiq`,y:.29889531*e+.58662247*t+.11448223*n,i:.59597799*e-.2741761*t-.32180189*n,q:.21147017*e-.52261711*t+.31114694*n};return r!==void 0&&(i.alpha=r),i}},channels:[`y`,`i`,`q`,`alpha`],parse:[`--yiq`],serialize:`--yiq`,ranges:{i:[-.595,.595],q:[-.522,.522]},interpolate:{y:F,i:F,q:F,alpha:{use:F,fixup:I}}},Cr=(e,t)=>Math.round(e*(t=10**t))/t,wr=((e=4)=>t=>typeof t==`number`?Cr(t,e):t)(2),Tr=e=>Math.max(0,Math.min(1,e||0)),Er=e=>Math.round(Tr(e)*255),Dr=O(`rgb`),Or=e=>{if(e===void 0)return;let t=Er(e.r),n=Er(e.g),r=Er(e.b);return e.alpha===void 0||e.alpha===1?`rgb(${t}, ${n}, ${r})`:`rgba(${t}, ${n}, ${r}, ${wr(Tr(e.alpha))})`},Z=e=>Or(Dr(e)),kr=(e,t=`rgb`,n=!1)=>{let r=t?se(t).channels:null,i=t?O(t):re;return a=>{let o=i(a);if(!o)return;let s=(r||se(o.mode).channels).reduce((n,r)=>{let i=e(o[r],r,o,t);return i!==void 0&&!isNaN(i)&&(n[r]=i),n},{mode:o.mode});if(!n)return s;let c=re(a);return c&&c.mode!==s.mode?O(c.mode)(s):s}},Ar=(e,t,n)=>t===`alpha`?e:(e||0)*(n.alpha===void 0?1:n.alpha),jr=(e,t,n)=>t!==`alpha`&&n.alpha!==0?(e||0)/(n.alpha===void 0?1:n.alpha):e,Mr=e=>{e[0]===void 0&&(e[0]=0),e[e.length-1]===void 0&&(e[e.length-1]=1);let t=1,n,r,i,a;for(;t<e.length;){if(e[t]===void 0){for(r=t,i=e[t-1],n=t;e[n]===void 0;)n++;for(a=(e[n]-i)/(n-t+1);t<n;)e[t]=i+(t+1-r)*a,t++}else e[t]<e[t-1]&&(e[t]=e[t-1]);t++}return e},Nr=(e=.5)=>t=>e<=0?1:e>=1?0:t**+(Math.log(.5)/Math.log(e)),Pr=e=>typeof e==`function`,Q=e=>e&&typeof e==`object`,Fr=e=>typeof e==`number`,Ir=(e,t=`rgb`,n,r)=>{let i=se(t),a=O(t),o=[],s=[],c={};e.forEach(e=>{Array.isArray(e)?(o.push(a(e[0])),s.push(e[1])):Fr(e)||Pr(e)?c[s.length]=e:(o.push(a(e)),s.push(void 0))}),Mr(s);let l=i.channels.reduce((e,t)=>{let r;return r=Q(n)&&Q(n[t])&&n[t].fixup?n[t].fixup:Q(i.interpolate[t])&&i.interpolate[t].fixup?i.interpolate[t].fixup:e=>e,e[t]=r(o.map(e=>e[t])),e},{});if(r){let e=o.map((e,n)=>i.channels.reduce((e,t)=>(e[t]=l[t][n],e),{mode:t}));l=i.channels.reduce((n,i)=>(n[i]=e.map(e=>{let n=r(e[i],i,e,t);return isNaN(n)?void 0:n}),n),{})}let u=i.channels.reduce((e,t)=>{let r;return Pr(n)?r=n:Q(n)&&Pr(n[t])?r=n[t]:Q(n)&&Q(n[t])&&n[t].use?r=n[t].use:Pr(i.interpolate[t])?r=i.interpolate[t]:Q(i.interpolate[t])&&(r=i.interpolate[t].use),e[t]=r(l[t]),e},{}),d=o.length-1;return e=>{if(e=Math.min(Math.max(0,e),1),e<=s[0])return o[0];if(e>s[d])return o[d];let n=0;for(;s[n]<e;)n++;let r=s[n-1],a=s[n]-r,l=(e-r)/a,f=c[n]||c[0];f!==void 0&&(Fr(f)&&(f=Nr((f-r)/a)),l=f(l));let p=(n-1+l)/d;return i.channels.reduce((e,t)=>{let n=u[t](p);return n!==void 0&&(e[t]=n),e},{mode:t})}},Lr=(e,t=`rgb`,n)=>Ir(e,t,n);((e,t)=>(n,r=`rgb`,i)=>{let a=t?kr(t,r):void 0,o=Ir(n,r,i,e);return a?e=>a(o(e)):o})(Ar,jr),j(Me),j(qe),j(ut),j(dt),j(mt),j(xt),j(wt),j(Ot),j(Bt),j(Xt),j($t),j(fn),j(pn),j(hn),j(gn),j(An),j(jn),j(Mn),j(Kn),j(Yn),j(Zn),j($n),j(nr),j(sr),j(mr),j(L),j(yr),j(br),j(xr),j(Sr);let Rr=function(e){return e.START=`^`,e.END=`.`,e.GROUP_OPEN=`(`,e.GROUP_CLOSE=`)`,e.COMMA=`,`,e.SEQUENCE_OPEN=`[`,e.SEQUENCE_CLOSE=`]`,e.OR=`|`,e.AND=`&`,e.NOT=`!`,e.REPEAT=`~`,e.CONFIG=`config`,e.COLOR_STOP=`color-stop`,e.COLOR_HINT=`color-hint`,e}({});function zr(e,t,n,r){let i=n,a=r;for(;a<t.length;){let o=t[a];if(o===`.`||o===`)`||o===`]`||o===`|`)break;if(o===`,`){a+=1;continue}let s=Vr(e,t,i,a);if(!s.matched)return{matched:!1,nextInputIndex:n,nextPatternIndex:r};i=s.nextInputIndex,a=s.nextPatternIndex}return{matched:!0,nextInputIndex:i,nextPatternIndex:a}}function Br(e,t,n,r){let i=t[r],a=e[n];if(i!==`config`&&i!==`color-stop`&&i!==`color-hint`)throw Error(`Expected entity token at pattern index ${r}`);return!a||a.type!==i?{matched:!1,nextInputIndex:n,nextPatternIndex:r}:{matched:!0,nextInputIndex:n+1,nextPatternIndex:r+1}}function Vr(e,t,n,r){let i=t[r];if(i===`config`||i===`color-stop`||i===`color-hint`)return Br(e,t,n,r);if(i===`[`)return Ur(e,t,n,r);if(i===`(`)return Gr(e,t,n,r);if(i===`~`)return Kr(e,t,n,r);throw Error(`Unsupported primary token "${i}" at pattern index ${r}`)}function Hr(e,t,n,r){if(e[t]!==n)throw Error(`Expected "${n}" at pattern index ${t}, got "${e[t]}"`);let i=0;for(let a=t;a<e.length;a+=1){let t=e[a];if(t===n){i+=1;continue}if(t===r&&(--i,i===0))return a}throw Error(`Unclosed token pair "${n}${r}"`)}function Ur(e,t,n,r){if(t[r]!==`[`)throw Error(`Expected "[" at pattern index ${r}`);let i=Hr(t,r,`[`,`]`),a=n,o=r+1;for(;o<i;){if(t[o]===`,`){o+=1;continue}let i=Vr(e,t,a,o);if(!i.matched)return{matched:!1,nextInputIndex:n,nextPatternIndex:r};a=i.nextInputIndex,o=i.nextPatternIndex}return{matched:!0,nextInputIndex:a,nextPatternIndex:i+1}}function Wr(e){let t=[],n=[],r=0,i=0;for(let a=0;a<e.length;a+=1){let o=e[a];if(o===`(`){r+=1,n.push(o);continue}if(o===`)`){--r,n.push(o);continue}if(o===`[`){i+=1,n.push(o);continue}if(o===`]`){--i,n.push(o);continue}if(o===`|`&&r===0&&i===0){t.push(n),n=[];continue}n.push(o)}return n.length>0&&t.push(n),t}function Gr(e,t,n,r){if(t[r]!==`(`)throw Error(`Expected "(" at pattern index ${r}`);let i=Hr(t,r,`(`,`)`),a=Wr(t.slice(r+1,i));for(let t of a){let r=zr(e,t,n,0);if(r.matched)return{matched:!0,nextInputIndex:r.nextInputIndex,nextPatternIndex:i+1}}return{matched:!1,nextInputIndex:n,nextPatternIndex:r}}function Kr(e,t,n,r){if(t[r]!==`~`)throw Error(`Expected "~" at pattern index ${r}`);let i=n,a=r+1;for(;;){let n=Vr(e,t,i,a);if(!n.matched)break;if(n.nextInputIndex===i)throw Error(`Repeat expression did not consume input`);i=n.nextInputIndex}let o=qr(t,a);return{matched:!0,nextInputIndex:i,nextPatternIndex:o}}function qr(e,t){let n=e[t];if(n===`config`||n===`color-stop`||n===`color-hint`)return t+1;if(n===`[`)return Hr(e,t,`[`,`]`)+1;if(n===`(`)return Hr(e,t,`(`,`)`)+1;if(n===`~`)return qr(e,t+1);throw Error(`Unsupported token "${n}" in getPrimaryEndIndex`)}function Jr(e){return Xr(e),$r(e),ei(e),!0}function Yr(e){try{return Jr(e),!0}catch{return!1}}function Xr(e){let t=ti(e);if(t.length===0)throw Error(`Pattern cannot be empty`);if(t[0]!==`^`)throw Error(`Pattern must start with ^`);if(t[t.length-1]!==`.`)throw Error(`Pattern must end with "."`);let n=0,r=0;for(let e=0;e<t.length;e+=1){let i=t[e];if(i===`(`){n+=1;continue}if(i===`)`){if(--n,n<0)throw Error(`Unexpected ")" at token index ${e}`);continue}if(i===`[`){r+=1;continue}if(i===`]`){if(--r,r<0)throw Error(`Unexpected "]" at token index ${e}`);continue}}if(n!==0)throw Error(`Unclosed group "()" in pattern`);if(r!==0)throw Error(`Unclosed sequence "[]" in pattern`);return!0}function Zr(e){try{return Xr(e),!0}catch{return!1}}let Qr={"^":[`(`,`[`,`!`,`~`,`config`,`color-stop`,`color-hint`],"(":[`(`,`[`,`!`,`~`,`config`,`color-stop`,`color-hint`],"[":[`(`,`[`,`!`,`~`,`config`,`color-stop`,`color-hint`],"|":[`(`,`[`,`!`,`~`,`config`,`color-stop`,`color-hint`],"&":[`(`,`[`,`!`,`~`,`config`,`color-stop`,`color-hint`],"!":[`(`,`[`,`!`,`~`,`config`,`color-stop`,`color-hint`],"~":[`(`,`[`,`!`,`~`,`config`,`color-stop`,`color-hint`],",":[`(`,`[`,`!`,`~`,`config`,`color-stop`,`color-hint`],config:[`,`,`|`,`&`,`)`,`]`,`.`],"color-stop":[`,`,`|`,`&`,`)`,`]`,`.`],"color-hint":[`,`,`|`,`&`,`)`,`]`,`.`],")":[`,`,`|`,`&`,`)`,`]`,`.`],"]":[`,`,`|`,`&`,`)`,`]`,`.`],".":[]};function $r(e){let t=ti(e);if(t.length===0)throw Error(`Pattern cannot be empty`);for(let e=0;e<t.length-1;e+=1){let n=t[e],r=t[e+1],i=Qr[n];if(!i)throw Error(`No semantic transition rule defined for token "${n}"`);if(!i.includes(r))throw Error(`Token "${r}" is not allowed after "${n}" at index ${e+1}`)}return!0}function ei(e){let t=ti(e);for(let e=0;e<t.length;e+=1){let n=t[e],r=t[e+1],i=t[e-1];if(n===`(`&&r===`)`)throw Error(`Empty group "()" is not allowed at token index ${e}`);if(n===`[`&&r===`]`)throw Error(`Empty sequence "[]" is not allowed at token index ${e}`);if(n===`,`){if(i===void 0||r===void 0)throw Error(`Unexpected "," at token index ${e}`);if(i===`[`)throw Error(`Sequence cannot start with "," at token index ${e}`);if(r===`]`)throw Error(`Sequence cannot end with "," at token index ${e}`);if(i===`,`||r===`,`)throw Error(`Unexpected consecutive "," at token index ${e}`)}}return!0}function ti(e){let t=e.trim(),n=[],r=0;for(;r<t.length;){let e=t.slice(r),i=t[r];if(/\s/.test(i)){r+=1;continue}if(e.startsWith(`color-stop`)){n.push(`color-stop`),r+=10;continue}if(e.startsWith(`color-hint`)){n.push(`color-hint`),r+=10;continue}if(e.startsWith(`config`)){n.push(`config`),r+=6;continue}if(i===`^`||i===`.`||i===`(`||i===`)`||i===`[`||i===`]`||i===`,`||i===`|`||i===`&`||i===`!`||i===`~`){n.push(i),r+=1;continue}throw Error(`Unexpected token near "${e}" at index ${r}`)}return n}function ni(e,t){try{return ri(e,t),!0}catch{return!1}}function ri(e,t){Jr(t);let n=ti(t).slice(1,-1),r=zr(e,n,0,0);if(!r.matched)throw Error(`Input does not match pattern`);if(r.nextInputIndex!==e.length)throw Error(`Pattern did not consume all inputs`);if(r.nextPatternIndex!==n.length)throw Error(`Input ended before pattern was fully matched`);return!0}function ii(e,t=`^[([config,color-stop,([color-hint,color-stop]|color-stop)]|color-stop),~([color-hint,color-stop]|color-stop)].`){let n=e.trim();if(n.length===0)throw Error(`Expected function call, received empty string`);let{functionName:r,isRepeating:i,inputs:a}=li(n),o=ci(a);return ri(o,t),{functionName:r,isRepeating:i,inputs:o}}function ai(e){return/^-?\d*\.?\d+(%|deg|rad|turn|grad|px|em|rem|vh|vw|vmin|vmax|cm|mm|in|pt|pc|q)?$/i.test(e.trim())}function oi(e){try{let t=$(e)[0];return xe(t)!==void 0}catch{return!1}}function si(e){return!ai(e)&&!oi(e)}function ci(e){let t=e.map(e=>e.trim()).filter(e=>e.length>0);return t.length===0?[]:t.map((e,t)=>t===0&&!oi(e)?{type:`config`,value:e}:oi(e)?{type:`color-stop`,value:e}:ai(e)?{type:`color-hint`,value:e}:{type:`config`,value:e})}function li(e){let t=e.indexOf(`(`);if(t<=0)throw Error(`Expected function opening parenthesis`);let n=e.slice(0,t).trim();if(n.length===0)throw Error(`Expected function name before "("`);let r=n.startsWith(`repeating-`);r&&(n=n.slice(10));let i=ui(e,t);if(i===-1)throw Error(`Unclosed function parenthesis`);let a=di(e.slice(t+1,i));return{functionName:n,isRepeating:r,inputs:a}}function ui(e,t){let n=0;for(let r=t;r<e.length;r+=1){let t=e[r];if(t===`(`){n+=1;continue}if(t===`)`){if(--n,n===0)return r;if(n<0)return-1}}return-1}function di(e){let t=[],n=``,r=0,i=0,a=0;for(let o=0;o<e.length;o+=1){let s=e[o];if(s===`(`){r+=1,n+=s;continue}if(s===`)`){--r,n+=s;continue}if(s===`{`){i+=1,n+=s;continue}if(s===`}`){--i,n+=s;continue}if(s===`[`){a+=1,n+=s;continue}if(s===`]`){--a,n+=s;continue}if(s===`,`&&r===0&&i===0&&a===0){fi(t,n),n=``;continue}n+=s}return fi(t,n),t}function fi(e,t){let n=t.trim();n.length>0&&e.push(n)}function $(e){let t=e.trim(),n=[],r=``,i=0,a=0,o=0;for(let e=0;e<t.length;e+=1){let s=t[e];if(s===`(`){i+=1,r+=s;continue}if(s===`)`){--i,r+=s;continue}if(s===`{`){a+=1,r+=s;continue}if(s===`}`){--a,r+=s;continue}if(s===`[`){o+=1,r+=s;continue}if(s===`]`){--o,r+=s;continue}if(/\s/.test(s)&&i===0&&a===0&&o===0){r.trim().length>0&&(n.push(r.trim()),r=``);continue}r+=s}return r.trim().length>0&&n.push(r.trim()),n}let pi=[`oklab`,`lch`,`oklch`,`hsl`,`hwb`,`lab`,`srgb`,`srgb-linear`,`xyz`,`display-p3`,`a98-rgb`,`prophoto-rgb`,`rec2020`],mi=[`shorter`,`longer`,`increasing`,`decreasing`],hi=[`hsl`,`hwb`,`lch`,`oklch`];function gi(e){return mi.includes(e)}function _i(e){return pi.includes(e)}function vi(e){return hi.includes(e)}var yi=class{_isRepeating;_config;_stops;constructor(e){this._isRepeating=e.isRepeating,this._config=this._cloneConfig(e.config),this._stops=this._getSortedStops(this._cloneStops(e.stops)),this._validateConfig(this._config),this._validateStops(this._stops)}get isRepeating(){return this._isRepeating}get config(){return this._cloneConfig(this._config)}get stops(){return this._cloneStops(this._stops)}toJSON(){return{type:this.type,isRepeating:this.isRepeating,config:this._cloneConfig(this.config),stops:this._cloneStops(this.stops)}}addStop(e){let t=[...this._cloneStops(this._stops),...this._cloneStops([e])],n=this._getSortedStops(t);this._validateStops(n),this._stops=n}static fromString(e){throw Error(`Not implimented`)}static fromAbi(e){throw Error(`Not implimented`)}removeStop(e){if(!Number.isInteger(e))throw TypeError(`Gradient stop index must be an integer`);if(e<0||e>=this._stops.length)throw RangeError(`Gradient stop index is out of bounds`);if(this._stops.filter(e=>e.type===`color-stop`).length<=this._minColorStopsCount())throw Error(`Color stop count should be greather than ${this._minColorStopsCount()}`);let t=e+1>this._stops.length-1?this._stops.length-1:e+1,n=e-1>=0?e-1:0;e!==t&&this._stops[t].type===`color-hint`&&this._stops.splice(t,1),this._stops.splice(e,1),e!==n&&this._stops[n].type===`color-hint`&&this._stops.splice(n,1)}equals(e){if(this.type!==e.type||this.isRepeating!==e.isRepeating||JSON.stringify(this.config)!==JSON.stringify(e.config)||this.stops.length!==e.stops.length)return!1;for(let t=0;t<this.stops.length;t++){let n=this.stops[t],r=e.stops[t];if(n.type!==r.type||n.value!==r.value||n.position!==r.position)return!1}return!0}_minColorStopsCount(){return 0}_getSortedStops(e){return e.map((e,t)=>({stop:e,index:t})).sort((e,t)=>e.stop.position===t.stop.position?e.index-t.index:e.stop.position-t.stop.position).map(e=>e.stop)}_validateStops(e){this._validateStopsShape(e),this._validateStopsSequence(e)}_validateStopsShape(e){if(!Array.isArray(e))throw TypeError(`Gradient stops must be an array`);for(let t of e){if(typeof t!=`object`||!t)throw TypeError(`Gradient stop must be an object`);if(t.type!==`color-stop`&&t.type!==`color-hint`)throw TypeError(`Invalid gradient stop type: ${String(t.type)}`);if(typeof t.value!=`string`)throw TypeError(`Gradient stop value must be a string`);if(typeof t.position!=`number`||Number.isNaN(t.position))throw TypeError(`Gradient stop position must be a valid number`)}}_validateStopsSequence(e){if(e.length<this._minColorStopsCount())throw TypeError(`Gradient must contain at least ${this._minColorStopsCount()} stop`);if(e[0].type!==`color-stop`)throw TypeError(`Gradient stop sequence must start with a color-stop`);if(e[e.length-1].type===`color-hint`)throw TypeError(`Gradient stop sequence cannot end with a color-hint`);for(let t=1;t<e.length;t++){let n=e[t-1],r=e[t];if(n.type===`color-hint`&&r.type!==`color-stop`)throw TypeError(`A color-hint must be followed by a color-stop`)}}_cloneStops(e){return structuredClone(e)}_cloneConfig(e){return structuredClone(e)}_buildSerializedStopTokens(){let e=[];for(let t=0;t<this.stops.length;t++){let n=this.stops[t];if(n.type===`color-hint`){e.push({type:`color-hint`,position:n.position});continue}let r=this.stops[t+1];if(r&&r.type===`color-stop`&&r.value===n.value){e.push({type:`color-stop`,value:n.value,positions:[n.position,r.position]}),t+=1;continue}e.push({type:`color-stop`,value:n.value,positions:[n.position]})}return e}_canOmitAllStopPositions(e){let t=e.filter(e=>e.type===`color-stop`);if(e.some(e=>e.type===`color-hint`)||t.some(e=>e.positions.length!==1)||t.length<=1)return!1;for(let e=0;e<t.length;e++){let n=e/(t.length-1),r=t[e].positions[0];if(Math.abs(r-n)>1e-6)return!1}return!0}_serializeStopsCompact(){let e=this._buildSerializedStopTokens();return this._canOmitAllStopPositions(e)?e.map(e=>{if(e.type!==`color-stop`)throw Error(`Unexpected color-hint token in compact stop serialization`);return e.value}):e.map(e=>e.type===`color-hint`?`${this._formatPercent(e.position)}%`:e.positions.length===2?`${e.value} ${this._formatPercent(e.positions[0])}% ${this._formatPercent(e.positions[1])}%`:`${e.value} ${this._formatPercent(e.positions[0])}%`)}_formatPercent(e){return t(e*100,3)}static _normalizeAbiInputsToStops(e){let t=[];for(let n of e){if(n.type===`color-hint`){t.push({type:`color-hint`,value:n.value,position:this._parsePosition(n.value)});continue}if(n.type===`color-stop`){let e=this._parseColorStopInput(n.value);t.push(...e);continue}throw SyntaxError(`Unsupported linear gradient ABI input type: "${n.type}"`)}return this._resolvePendingStops(t)}static _parsePosition(e){let t=e.trim().toLowerCase().match(/^([+-]?(?:\d+\.?\d*|\.\d+))%$/);if(t===null)throw SyntaxError(`Invalid gradient stop position: "${e}"`);let n=Number(t[1]);if(!Number.isFinite(n))throw SyntaxError(`Invalid gradient stop position: "${e}"`);return n/100}static _parseColorStopInput(e){let t=$(e);if(t.length===0)throw SyntaxError(`Color-stop input cannot be empty`);let n=[];for(;t.length>0;){let e=t[t.length-1];if(!/%$/.test(e)||(n.unshift(this._parsePosition(e)),t.pop(),n.length===2))break}let r=t.join(` `).trim();if(r.length===0)throw SyntaxError(`Color-stop is missing color value: "${e}"`);return n.length===0?[{type:`color-stop`,value:r}]:n.length===1?[{type:`color-stop`,value:r,position:n[0]}]:[{type:`color-stop`,value:r,position:n[0]},{type:`color-stop`,value:r,position:n[1]}]}static _resolvePendingStops(e){if(e.length===0)throw SyntaxError(`Linear gradient must contain at least one stop`);let t=e.map(e=>({...e})),n=t.findIndex(e=>e.type===`color-stop`),r=[...t].reverse().findIndex(e=>e.type===`color-stop`);if(n===-1)throw SyntaxError(`Linear gradient must contain at least one color-stop`);let i=t.length-1-r;t[n].position===void 0&&(t[n].position=0),t[i].position===void 0&&(t[i].position=1);let a=-1;for(let e=0;e<t.length;e++){let n=t[e];if(n.position!==void 0){if(a!==-1){let r=t[a],i=n,o=e-a;for(let e=1;e<o;e++){let n=t[a+e];n.position===void 0&&(n.position=r.position+(i.position-r.position)*e/o)}}a=e}}return t.map(e=>{if(e.position===void 0)throw SyntaxError(`Failed to resolve gradient stop position`);return{type:e.type,value:e.value,position:e.position}})}},bi=class e extends yi{type=`linear-gradient`;constructor(t){t.config.angle=g(t.config.angle),t.config.interpolation&&(t.config.interpolation=e._normalizeConfigInterpolation(t.config.interpolation)),super(t)}static normalizeConfig(t){let n=e._tokenizeConfigInput(t),r=new Set;for(let e of n){if(r.has(e.type))throw SyntaxError(`Duplicate linear gradient config token: "${e.type}"`);r.add(e.type)}let i=n.find(e=>e.type===`angle`),a=n.find(e=>e.type===`colorSpace`),o=n.find(e=>e.type===`hue`),s={angle:3.141593,interpolation:{hue:`shorter`,colorSpace:`oklab`}};if(i){let e=i.value;if(e.startsWith(`to `)){let t=e.trim().toLowerCase().split(/\s+/).filter(Boolean);if(t.length===0)throw SyntaxError(`Linear gradient angle keyword cannot be empty`);if(t[0]!==`to`)throw SyntaxError(`Linear gradient keyword direction must start with "to"`);let n=t.slice(1);if(n.length===0||n.length>2)throw SyntaxError(`Linear gradient keyword direction must contain one or two direction tokens`);let r=new Set([`top`,`right`,`bottom`,`left`]);for(let e of n)if(!r.has(e))throw SyntaxError(`Invalid linear gradient direction token: "${e}"`);if(new Set(n).size!==n.length)throw SyntaxError(`Linear gradient keyword direction cannot contain duplicate tokens`);let i=n.includes(`top`),a=n.includes(`right`),o=n.includes(`bottom`),c=n.includes(`left`);if(i&&o||c&&a)throw SyntaxError(`Linear gradient keyword direction contains conflicting tokens`);if(i&&c)s.angle=d(315);else if(i&&a)s.angle=d(45);else if(o&&c)s.angle=d(225);else if(o&&a)s.angle=d(135);else if(i)s.angle=d(0);else if(a)s.angle=d(90);else if(o)s.angle=d(180);else if(c)s.angle=d(270);else throw SyntaxError(`Unsupported linear gradient keyword direction: "${e}"`)}else s.angle=g(u(e))}return a&&(s.interpolation.colorSpace=a.value),o&&(s.interpolation.hue=o.value),s}static fromString(t){return e.fromAbi(ii(t))}static fromAbi(t){let n={angle:3.141592};if(t.inputs[0].type===`config`){let r=t.inputs[0].value.trim().toLowerCase();if(r.length===0)throw SyntaxError(`Linear gradient config cannot be empty`);n=e.normalizeConfig(r)}let r=t.inputs[0]?.type===`config`?t.inputs.slice(1):t.inputs,i=e._normalizeAbiInputsToStops(r);return new e({isRepeating:t.isRepeating,config:n,stops:i})}clone(){return new e(this.toJSON())}toString(){return`${this.isRepeating?`repeating-${this.type}`:this.type}(${[this._parseConfigToString(this.config),...this._serializeStopsCompact()].filter(Boolean).join(`, `)})`}_validateConfig(e){}static _normalizeConfigInterpolation(e){let{colorSpace:t,hue:n}=e;return n===void 0||!vi(t)?{colorSpace:t}:{colorSpace:t,hue:n}}_parseConfigToString(e){let{angle:t,interpolation:n}=e,r=[],i=this._parseAngleToString(t);return i.length>0&&r.push(i),n!==void 0&&r.push(this._parseInterpolationToString(n)),r.join(` `)}_parseAngleToString(e){let t=h(f(e),3);switch(t){case 0:return`to top`;case 45:return`to top right`;case 90:return`to right`;case 135:return`to bottom right`;case 180:return``;case 225:return`to bottom left`;case 270:return`to left`;case 315:return`to top left`;default:return`${t}deg`}}_parseInterpolationToString(e){let{colorSpace:t,hue:n}=e;return n===void 0?`in ${t}`:`in ${t} ${n} hue`}static _tokenizeConfigInput(e){let t=e.trim().toLowerCase();if(t.length===0)throw SyntaxError(`Linear gradient config cannot be empty`);let n=t.split(/\s+/),r=[];for(let e=0;e<n.length;e+=1){let t=n[e];if(t===`in`){let t=n[e+1];if(t===void 0||!_i(t))throw SyntaxError(`Expected color space after "in"`);r.push({type:`colorSpace`,value:t}),e+=1;continue}if(l(t)){r.push({type:`angle`,value:t});continue}if(t===`to`){let t=[],i=n[e+1],a=n[e+2];i!==void 0&&t.push(i),(a===`left`||a===`right`)&&t.push(a);let o=`to ${t.join(` `)}`;r.push({type:`angle`,value:o}),e+=t.length;continue}if(gi(t)){if(n[e+1]!==`hue`)throw SyntaxError(`Expected "hue" after "${t}"`);r.push({type:`hue`,value:t}),e+=1;continue}throw SyntaxError(`Unknown linear gradient config token: "${t}"`)}return r}},xi=class e extends yi{type=`radial-gradient`;constructor(e){super(e)}static fromString(t){return e.fromAbi(ii(t))}static fromAbi(t){if(t.functionName!==`radial-gradient`)throw Error(`Invalid function name for RadialGradient`);let n=this._parseConfig(t.inputs),r=t.inputs[0]?.type===`config`?t.inputs.slice(1):t.inputs,i=this._normalizeAbiInputsToStops(r);return new e({isRepeating:t.isRepeating,config:n,stops:i})}clone(){return new e(this.toJSON())}toString(){return`${this.isRepeating?`repeating-${this.type}`:this.type}(${[this._serializeRadialConfig(this.config),...this._serializeStopsCompact()].filter(Boolean).join(`, `)})`}_validateConfig(e){if(e.shape!==`circle`&&e.shape!==`ellipse`)throw Error(`Invalid shape`);if(!e.position)throw Error(`Position is required`);if(!e.size)throw Error(`Size is required`)}_serializeRadialConfig(e){let t=[];if(t.push(e.shape),e.size.kind===`extent`)t.push(e.size.value);else{let n=this._formatLengthPercentage(e.size.x),r=e.size.y?` ${this._formatLengthPercentage(e.size.y)}`:``;t.push(`${n}${r}`)}if(t.push(`at ${this._serializePosition(e.position)}`),e.interpolation)if(e.interpolation.kind===`rectangular`)t.push(`in ${e.interpolation.space}`);else{let n=`in ${e.interpolation.space}`;e.interpolation.hueMethod&&(n+=` ${e.interpolation.hueMethod} hue`),t.push(n)}return t.join(` `)}_serializePosition(e){if(e.kind===`keywords`)return`${e.x} ${e.y}`;let t=this._formatLengthPercentage(e.x),n=e.y?this._formatLengthPercentage(e.y):``;return n===``?t:`${t} ${n}`}_formatLengthPercentage(e){return e.kind===`percent`?`${e.value}%`:`${e.value}${e.unit}`}static _parseConfig(e){let t=`ellipse`,n={kind:`extent`,value:`farthest-corner`},r={kind:`keywords`,x:`center`,y:`center`};for(let i of e){if(i.type!==`config`)continue;let e=$(i.value);for(let i=0;i<e.length;i++){let a=e[i];if(a===`circle`||a===`ellipse`){t=a;continue}if(a===`closest-side`||a===`closest-corner`||a===`farthest-side`||a===`farthest-corner`){n={kind:`extent`,value:a};continue}if(a===`at`){let t=e[i+1],n=e[i+2];r=(t===`left`||t===`center`||t===`right`)&&(n===`top`||n===`center`||n===`bottom`)?{kind:`keywords`,x:t,y:n}:{kind:`values`,x:this._parseLengthPercentage(t),y:this._parseLengthPercentage(n)},i+=2;continue}}}return{shape:t,size:n,position:r}}static _parseLengthPercentage(e){if(e.endsWith(`%`))return{kind:`percent`,value:parseFloat(e)};let t=e.match(/^(-?\d*\.?\d+)([a-zA-Z]+)$/);if(!t)throw Error(`Invalid length-percentage: ${e}`);return{kind:`length`,value:parseFloat(t[1]),unit:t[2]}}},Si=class e extends yi{type=`conic-gradient`;constructor(e){super(e)}clone(){return new e(this.toJSON())}toString(){return`${this.isRepeating?`repeating-${this.type}`:this.type}(${[this._serializeConfig(),...this._serializeStopsCompact()].filter(Boolean).join(`, `)})`}static fromString(e){return this.fromAbi(ii(e))}static fromAbi(t){if(t.functionName!==`conic-gradient`)throw Error(`Invalid function name for ConicGradient`);let n=t.inputs.find(e=>e.type===`config`),r=t.inputs.filter(e=>e.type!==`config`),i=this._parseConfig(n?.value),a=this._normalizeAbiInputsToStops(r);return new e({isRepeating:t.isRepeating,config:i,stops:a})}_validateConfig(e){}_serializeConfig(){let e=[],t=this.config.from;if(e.push(`from ${t.value}${t.unit}`),e.push(`at ${this._serializePosition(this.config.position)}`),this.config.interpolation){let t=this.config.interpolation;if(t.kind===`rectangular`)e.push(`in ${t.space}`);else{let n=`in ${t.space}`;t.hueMethod&&(n+=` ${t.hueMethod} hue`),e.push(n)}}return e.join(` `)}_serializePosition(e){if(e.kind===`keywords`)return`${e.x} ${e.y}`;let t=this._formatLengthPercentage(e.x),n=e.y?this._formatLengthPercentage(e.y):``;return n===``?t:`${t} ${n}`}_formatLengthPercentage(e){return e.kind===`percent`?`${e.value}%`:`${e.value}${e.unit}`}static _parseConfig(e){let t={from:{kind:`angle`,value:0,unit:`deg`},position:{kind:`keywords`,x:`center`,y:`center`}};if(!e)return t;let n=$(e);for(let e=0;e<n.length;e++){let r=n[e];if(r===`from`){t.from=this._parseAngle(n[e+1]),e+=1;continue}if(r===`at`){let r=n[e+1],i=n[e+2];(r===`left`||r===`center`||r===`right`)&&(i===`top`||i===`center`||i===`bottom`)?t.position={kind:`keywords`,x:r,y:i}:t.position={kind:`values`,x:this._parseLengthPercentage(r),y:this._parseLengthPercentage(i)},e+=2;continue}if(r===`in`){let r=n[e+1],i=n[e+2];if(n[e+3]===`hue`&&(i===`shorter`||i===`longer`||i===`increasing`||i===`decreasing`)){t.interpolation={kind:`polar`,space:r,hueMethod:i},e+=3;continue}t.interpolation={kind:`rectangular`,space:r},e+=1}}return t}static _parseLengthPercentage(e){if(e.endsWith(`%`))return{kind:`percent`,value:parseFloat(e)};let t=e.match(/^(-?\d*\.?\d+)([a-zA-Z]+)$/);if(!t)throw Error(`Invalid length-percentage: ${e}`);return{kind:`length`,value:parseFloat(t[1]),unit:t[2]}}static _parseAngle(e){let t=e.match(/^(-?\d*\.?\d+)(deg|rad|turn|grad)$/);if(!t)throw Error(`Invalid angle: ${e}`);return{kind:`angle`,value:Number(t[1]),unit:t[2]}}},Ci=class{target=`css`;gradientType=`linear-gradient`;to(e){if(!(e instanceof bi))throw Error(`Expected LinearGradient`);return e.toString()}},wi=class{target=`css`;gradientType=`radial-gradient`;to(e){if(!(e instanceof xi))throw Error(`Expected RadialGradient`);return e.toString()}},Ti=class{target=`css`;gradientType=`conic-gradient`;to(e){if(!(e instanceof Si))throw Error(`Expected ConicGradient`);return e.toString()}};function Ei(e,t){return(e%t+t)%t}function Di(e,t){let n=e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position);if(n.length===0)throw Error(`Cannot sample color from empty stops.`);if(t<=n[0].position)return n[0].value;let r=n[n.length-1];if(t>=r.position)return r.value;for(let e=0;e<n.length-1;e+=1){let r=n[e],i=n[e+1];if(t>=r.position&&t<=i.position){let e=i.position-r.position||1,n=(t-r.position)/e;return Z(Lr([r.value,i.value],`rgb`)(n))}}return r.value}function Oi(e,t,n,r){return Di(e,n+Ei(t-n,r))}function ki(e){let t=e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position);if(t.length<2)return t;let n=t[0].position,r=t[t.length-1].position-n;if(r<=0)return t;let i=[],a=0;i.push({type:`color-stop`,value:Oi(t,0,n,r),position:0,_order:a}),a+=1;let o=Math.floor((0-n)/r)-1,s=Math.ceil((1-n)/r)+1;for(let e=o;e<=s;e+=1){let n=e*r;for(let e of t){let t=e.position+n;t<=0||t>=1||(i.push({...e,position:t,_order:a}),a+=1)}}return i.push({type:`color-stop`,value:Oi(t,1,n,r),position:1,_order:a}),i.sort((e,t)=>e.position===t.position?e._order-t._order:e.position-t.position).map(({_order:e,...t})=>t)}function Ai(e){switch(e){case`longer`:return Pe;case`increasing`:return Fe;case`decreasing`:return Ie;default:return U}}function ji(e){switch(e){case`a98-rgb`:return`a98`;case`display-p3`:return`p3`;case`prophoto-rgb`:return`prophoto`;case`xyz`:return`xyz65`;case`srgb`:case`srgb-linear`:return`rgb`;default:return e}}function Mi(e){if(e.hue!==void 0)return{h:{fixup:Ai(e.hue)}}}function Ni(e){let t=e.filter(e=>e.type===`color-stop`);return t.length===0?[]:t.length===1?[{...t[0],position:t[0].position??0}]:t.map((e,n)=>e.position==null?n===0?{...e,position:0}:n===t.length-1?{...e,position:1}:{...e,position:n/(t.length-1)}:e)}function Pi(e){let t=Fi(e);if(!t)throw Error(`Failed to convert interpolated color to rgb.`);return Z(t)}let Fi=O(`rgb`);function Ii(e,t=64){let n=Ni(e.stops),r=e.config.interpolation;if(n.length<2)return n;if(r===void 0)return e.isRepeating?ki(n):n;let i=[],a=ji(r.colorSpace),o=Mi(r);for(let e=0;e<n.length-1;e+=1){let r=n[e],s=n[e+1],c=r.position,l=s.position,u=Lr([r.value,s.value],a,o);for(let n=0;n<=t;n+=1){if(e>0&&n===0)continue;let r=n/t,a=c+(l-c)*r,o=u(r);i.push({type:`color-stop`,value:Pi(o),position:a})}}return e.isRepeating?ki(i):i}let Li=O(`rgb`);function Ri(e){let t=Li(e);if(!t)throw Error(`Failed to convert color: ${e}`);return Z(t)}function zi(e){let t=e.filter(e=>e.type===`color-stop`&&e.position!=null);return t.length?{min:Math.min(...t.map(e=>e.position)),max:Math.max(...t.map(e=>e.position)),stops:t}:{min:0,max:1,stops:[]}}function Bi(e,t,n){let r=n-t||1;return e.filter(e=>e.type===`color-stop`&&e.position!=null).map(e=>({...e,position:(e.position-t)/r}))}var Vi=class{target=`canvas-2d`;gradientType=`linear-gradient`;to(e){let t=e;return{draw:(e,n,r)=>{let i=t.config.angle,a=Math.sin(i),o=-Math.cos(i),s=n/2,c=r/2,l=Math.abs(n*a)+Math.abs(r*o),u=s-a*l/2,d=c-o*l/2,f=s+a*l/2,p=c+o*l/2,{min:m,max:h,stops:g}=zi(Ii(t)),_=g;if(m<0||h>1){let e=f-u,t=p-d,n=u,r=d;u=n+e*m,d=r+t*m,f=n+e*h,p=r+t*h,_=Bi(g,m,h)}let v=e.createLinearGradient(u,d,f,p);for(let e of _)v.addColorStop(e.position,Ri(e.value));e.clearRect(0,0,n,r),e.fillStyle=v,e.fillRect(0,0,n,r)}}}};let Hi=O(`rgb`);function Ui(e){let t=Hi(e);if(!t)throw Error(`Failed to convert color: ${e}`);return Z(t)}function Wi(e){let t=e.filter(e=>e.type===`color-stop`&&e.position!=null);return t.length?{min:Math.min(...t.map(e=>e.position)),max:Math.max(...t.map(e=>e.position)),stops:t}:{min:0,max:1,stops:[]}}function Gi(e,t,n){let r=n-t||1;return e.map(e=>({...e,position:(e.position-t)/r}))}var Ki=class{target=`canvas-2d`;gradientType=`radial-gradient`;to(e){let t=e;return{draw:(e,n,r)=>{let i=t.config.position,a=n/2,o=r/2;i.kind===`values`&&(a=this._resolve(i.x,n),o=this._resolve(i.y,r));let s=Math.max(a,n-a),c=Math.max(o,r-o),l=Math.sqrt(s*s+c*c),{min:u,max:d,stops:f}=Wi(t.stops),p=0,m=l,h=f;u>=0&&(u<0||d>1)?(p=l*u,m=l*d,h=Gi(f,u,d)):d>1&&(m=l*d,h=Gi(f,u,d));let g=e.createRadialGradient(a,o,p,a,o,m);for(let e of h)g.addColorStop(e.position,Ui(e.value));e.fillStyle=g,e.fillRect(0,0,n,r)}}}_resolve(e,t){return e.kind===`percent`?e.value/100*t:(e.unit,e.value)}};let qi=O(`rgb`);var Ji=class{target=`canvas-2d`;gradientType=`conic-gradient`;to(e){let t=e;return{draw:(e,n,r)=>{let i=e.createImageData(n,r),a=i.data,{x:o,y:s}=this._resolvePosition(t.config.position,n,r),c=this._toRad(t.config.from),l=this._normalizeStops(t.stops);if(l.length===0){e.putImageData(i,0,0);return}for(let e=0;e<r;e++)for(let t=0;t<n;t++){let r=t-o,i=e-s,u=Math.atan2(i,r)+Math.PI/2-c;for(;u<0;)u+=Math.PI*2;for(;u>=Math.PI*2;)u-=Math.PI*2;let d=u/(Math.PI*2),f=this._sampleColor(l,d),p=(e*n+t)*4;a[p]=f.r,a[p+1]=f.g,a[p+2]=f.b,a[p+3]=f.a}e.putImageData(i,0,0)}}}_resolvePosition(e,t,n){return e.kind===`keywords`?{x:this._resolveKeywordX(e.x,t),y:this._resolveKeywordY(e.y,n)}:{x:this._resolve(e.x,t),y:this._resolve(e.y,n)}}_resolve(e,t){return e.kind===`percent`?e.value/100*t:(e.unit,e.value)}_resolveKeywordX(e,t){return e===`left`?0:e===`right`?t:t/2}_resolveKeywordY(e,t){return e===`top`?0:e===`bottom`?t:t/2}_toRad(e){return e.unit===`deg`?d(e.value):e.unit===`turn`?p(e.value):e.unit===`grad`?m(e.value):e.value}_normalizeStops(e){return e.filter(e=>e.type===`color-stop`&&e.position!=null).map(e=>({position:this._clamp01(e.position),color:this._parseColor(e.value)})).sort((e,t)=>e.position-t.position)}_sampleColor(e,t){if(e.length===1)return e[0].color;let n=e[0],r=[...e,{...n,position:n.position+1}],i=t;i<n.position&&(i+=1);for(let e=0;e<r.length-1;e++){let t=r[e],n=r[e+1];if(i>=t.position&&i<=n.position){let e=n.position-t.position||1,r=(i-t.position)/e;return this._mixColor(t.color,n.color,r)}}return e[e.length-1].color}_mixColor(e,t,n){return{r:Math.round(e.r+(t.r-e.r)*n),g:Math.round(e.g+(t.g-e.g)*n),b:Math.round(e.b+(t.b-e.b)*n),a:Math.round(e.a+(t.a-e.a)*n)}}_parseColor(e){let t=qi(e);if(!t)throw Error(`Failed to convert color: ${e}`);return{r:Math.round((t.r??0)*255),g:Math.round((t.g??0)*255),b:Math.round((t.b??0)*255),a:Math.round((t.alpha??1)*255)}}_clamp01(e){return Math.max(0,Math.min(1,e))}};let Yi=O(`rgb`);function Xi(e){let t=Yi(e);if(!t)throw Error(`Failed to convert color: ${e}`);return[t.r??0,t.g??0,t.b??0,t.alpha??1]}function Zi(e){let t=e.filter(e=>e.type===`color-stop`&&e.position!=null);return t.length?{min:Math.min(...t.map(e=>e.position)),max:Math.max(...t.map(e=>e.position)),stops:t}:{min:0,max:1,stops:[]}}function Qi(e,t,n){let r=n-t||1;return e.filter(e=>e.type===`color-stop`&&e.position!=null).map(e=>({...e,position:(e.position-t)/r}))}function $i(e,t,n){let r=e.createShader(t);if(!r)throw Error(`Failed to create WebGL shader.`);if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){let t=e.getShaderInfoLog(r);throw e.deleteShader(r),Error(`WebGL shader compile error: ${t}`)}return r}function ea(e,t,n){let r=$i(e,e.VERTEX_SHADER,t),i=$i(e,e.FRAGMENT_SHADER,n),a=e.createProgram();if(!a)throw Error(`Failed to create WebGL program.`);if(e.attachShader(a,r),e.attachShader(a,i),e.linkProgram(a),!e.getProgramParameter(a,e.LINK_STATUS)){let t=e.getProgramInfoLog(a);throw e.deleteProgram(a),Error(`WebGL program link error: ${t}`)}return a}function ta(e){return e.filter(e=>e.type===`color-stop`).length}function na(e,t){let n=ta(e.stops),r=Math.max(1,n-1);return Math.max(2,Math.floor((t-1)/r))}function ra(e,t){let n=e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position);if(n.length===0)throw Error(`Cannot sample color from empty gradient stops.`);if(t<=n[0].position)return n[0].value;let r=n[n.length-1];if(t>=r.position)return r.value;for(let e=0;e<n.length-1;e+=1){let r=n[e],i=n[e+1];if(t>=r.position&&t<=i.position){let e=i.position-r.position||1,n=(t-r.position)/e;return Z(Lr([r.value,i.value],`rgb`)(n))}}return r.value}function ia(e,t){let n=e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position);if(n.length<=t)return n;let r=[];for(let e=0;e<t;e+=1){let i=e/(t-1);r.push({type:`color-stop`,value:ra(n,i),position:i})}return r}var aa=class{target=`canvas-webgl`;gradientType=`linear-gradient`;to(e){let t=e;return{draw:(e,n,r)=>{let i=e.getContext(`webgl`);if(!i)throw Error(`WebGL is not supported.`);e.width=n,e.height=r,i.viewport(0,0,n,r);let a=ea(i,`
|
|
5
|
+
attribute vec2 a_position;
|
|
6
|
+
varying vec2 v_uv;
|
|
7
|
+
|
|
8
|
+
void main() {
|
|
9
|
+
v_uv = a_position * 0.5 + 0.5;
|
|
10
|
+
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
11
|
+
}
|
|
12
|
+
`,`
|
|
13
|
+
precision mediump float;
|
|
14
|
+
|
|
15
|
+
varying vec2 v_uv;
|
|
16
|
+
|
|
17
|
+
uniform vec2 u_start;
|
|
18
|
+
uniform vec2 u_end;
|
|
19
|
+
uniform int u_stopCount;
|
|
20
|
+
uniform float u_positions[128];
|
|
21
|
+
uniform vec4 u_colors[128];
|
|
22
|
+
|
|
23
|
+
vec4 getGradientColor(float t) {
|
|
24
|
+
vec4 result = u_colors[0];
|
|
25
|
+
|
|
26
|
+
for (int i = 0; i < 127; i++) {
|
|
27
|
+
if (i >= u_stopCount - 1) {
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
float currentPosition = u_positions[i];
|
|
32
|
+
float nextPosition = u_positions[i + 1];
|
|
33
|
+
|
|
34
|
+
if (t <= currentPosition) {
|
|
35
|
+
return u_colors[i];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (t >= currentPosition && t <= nextPosition) {
|
|
39
|
+
float localT = (t - currentPosition) / max(nextPosition - currentPosition, 0.00001);
|
|
40
|
+
return mix(u_colors[i], u_colors[i + 1], localT);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
result = u_colors[i + 1];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
void main() {
|
|
50
|
+
vec2 axis = u_end - u_start;
|
|
51
|
+
vec2 point = v_uv;
|
|
52
|
+
|
|
53
|
+
float axisLengthSquared = dot(axis, axis);
|
|
54
|
+
float t = dot(point - u_start, axis) / axisLengthSquared;
|
|
55
|
+
|
|
56
|
+
t = clamp(t, 0.0, 1.0);
|
|
57
|
+
|
|
58
|
+
gl_FragColor = getGradientColor(t);
|
|
59
|
+
}
|
|
60
|
+
`);i.useProgram(a);let o=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),i.STATIC_DRAW);let s=i.getAttribLocation(a,`a_position`);i.enableVertexAttribArray(s),i.vertexAttribPointer(s,2,i.FLOAT,!1,0,0);let c=t.config.angle,l=Math.sin(c),u=-Math.cos(c),d=n/2,f=r/2,p=Math.abs(n*l)+Math.abs(r*u),m=d-l*p/2,h=f-u*p/2,g=d+l*p/2,_=f+u*p/2,{min:v,max:y,stops:b}=Zi(Ii(t,na(t,128))),x=b;if(v<0||y>1){let e=g-m,t=_-h,n=m,r=h;m=n+e*v,h=r+t*v,g=n+e*y,_=r+t*y,x=Qi(b,v,y)}let S=m/n,C=1-h/r,w=g/n,T=1-_/r,ee=ia(x,128),E=new Float32Array(128),D=new Float32Array(512);ee.forEach((e,t)=>{let n=Xi(e.value);E[t]=e.position,D[t*4+0]=n[0],D[t*4+1]=n[1],D[t*4+2]=n[2],D[t*4+3]=n[3]}),i.uniform2f(i.getUniformLocation(a,`u_start`),S,C),i.uniform2f(i.getUniformLocation(a,`u_end`),w,T),i.uniform1i(i.getUniformLocation(a,`u_stopCount`),ee.length),i.uniform1fv(i.getUniformLocation(a,`u_positions`),E),i.uniform4fv(i.getUniformLocation(a,`u_colors`),D),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.drawArrays(i.TRIANGLES,0,6)}}}},oa=class{static _modules=new Map;static _initialized=!1;static add(e){this._ensureInitialized(),this._modules.set(this._getKey(e.target,e.gradientType),e)}static get(e,t){return this._ensureInitialized(),this._modules.get(this._getKey(e,t))??null}static remove(e,t){return this._ensureInitialized(),this._modules.delete(this._getKey(e,t))}static to(e,t){let n=typeof t==`string`?sa.create(t):t,r=this.get(e,n.type);if(!r)throw Error(`No transformer registered for target "${e}" and gradient "${n.type}"`);return r.to(n)}static from(e,t,n){let r=this.get(e,t);if(!r||!r.from)throw Error(`No reverse transformer registered for target "${e}" and gradient "${t}"`);return r.from(n)}static _ensureInitialized(){this._initialized||(this._initialized=!0,this.add(new Ci),this.add(new wi),this.add(new Ti),this.add(new Vi),this.add(new Ki),this.add(new Ji),this.add(new aa))}static _getKey(e,t){return`${e}:${t}`}},sa=class{static _registry=new Map;static _initialized=!1;static add(e,t){this._ensureInitialized(),this._registry.set(e,t)}static get(e){return this._ensureInitialized(),this._registry.get(e)??null}static remove(e){return this._registry.delete(e)}static create(e){let t=typeof e==`string`?ii(e):e,n=this.get(t.functionName);if(!n)throw Error(`No gradient registered for: ${t.functionName}`);return n.fromAbi(t)}static isValid(e){try{return this.create(e),!0}catch{return!1}}static _ensureInitialized(){this._initialized||(this._initialized=!0,this.add(`linear-gradient`,bi),this.add(`radial-gradient`,xi),this.add(`conic-gradient`,Si))}};function ca(e){return sa.create(e)}function la(e){return sa.isValid(e)}function ua(e){return typeof e==`string`?ca(e).toString():e.toString()}function da(e,t){let n=typeof t==`string`?ca(t):t;return oa.to(e,n)}function fa(e,t,n){return oa.from(e,t,n)}return e.ConicGradient=Si,e.GRADIENT_COLOR_SPACE=pi,e.GRADIENT_HUE_INTERPOLATIONS=mi,e.GRADIENT_POLAR_COLOR_SPACES=hi,e.GradientBase=yi,e.GradientFactory=sa,e.GradientTransformer=oa,e.LinearGradient=bi,e.ModuleTransformerConicGradientToCanvas=Ji,e.ModuleTransformerConicGradientToCss=Ti,e.ModuleTransformerLinearGradientToCanvas=Vi,e.ModuleTransformerLinearGradientToCanvasWebGL=aa,e.ModuleTransformerLinearGradientToCss=Ci,e.ModuleTransformerRadialGradientToCanvas=Ki,e.ModuleTransformerRadialGradientToCss=wi,e.PatternTokenKind=Rr,e.RadialGradient=xi,e.angleValueFromString=u,e.ceilTo=r,e.clamp=a,e.degToRad=d,e.floorTo=n,e.format=ua,e.fromPercent=s,e.gradToRad=m,e.isAngle=l,e.isAngleUnit=c,e.isColorHint=ai,e.isColorStop=oi,e.isConfig=si,e.isGradient=la,e.isGradientColorSpace=_i,e.isGradientHueInterpolation=gi,e.isGradientPolarColorSpace=vi,e.isPatternSyntaxValid=Zr,e.isPatternValid=Yr,e.isValid=ni,e.matchExpression=zr,e.normalizeAngleDeg=h,e.normalizeAngleRad=g,e.parse=ca,e.parseStringToAbi=ii,e.radToDeg=f,e.roundTo=t,e.splitTopLevelByWhitespace=$,e.toPercent=o,e.tokenizePattern=ti,e.transformFrom=fa,e.transformTo=da,e.truncTo=i,e.turnToRad=p,e.validate=ri,e.validatePattern=Jr,e.validatePatternSemantic=$r,e.validatePatternStructure=ei,e.validatePatternSyntax=Xr,e})({});
|
|
@@ -1007,10 +1007,7 @@ var LinearGradient = class LinearGradient extends GradientBase {
|
|
|
1007
1007
|
type = "linear-gradient";
|
|
1008
1008
|
constructor(config) {
|
|
1009
1009
|
config.config.angle = normalizeAngleRad(config.config.angle);
|
|
1010
|
-
if (config.config.interpolation)
|
|
1011
|
-
config.config.interpolation = LinearGradient._normalizeConfigInterpolation(config.config.interpolation);
|
|
1012
|
-
console.log(config);
|
|
1013
|
-
}
|
|
1010
|
+
if (config.config.interpolation) config.config.interpolation = LinearGradient._normalizeConfigInterpolation(config.config.interpolation);
|
|
1014
1011
|
super(config);
|
|
1015
1012
|
}
|
|
1016
1013
|
static normalizeConfig(value) {
|
package/package.json
CHANGED
|
@@ -1,54 +1,65 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "gradiente",
|
|
3
|
-
"type": "module",
|
|
4
|
-
"version": "2.1.
|
|
5
|
-
"description": "Lightweight gradient toolkit for modern rendering systems.",
|
|
6
|
-
"author": "Nice Arti <nikcrav@gmail.com>",
|
|
7
|
-
"license": "MIT",
|
|
8
|
-
"homepage": "https://flowscape-ui.github.io/gradiente/",
|
|
9
|
-
"keywords": [
|
|
10
|
-
"gradiente",
|
|
11
|
-
"gradient",
|
|
12
|
-
"gradients",
|
|
13
|
-
"flowscape",
|
|
14
|
-
"color"
|
|
15
|
-
],
|
|
16
|
-
"repository": {
|
|
17
|
-
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/Flowscape-UI/gradiente.git"
|
|
19
|
-
},
|
|
20
|
-
"bugs": {
|
|
21
|
-
"url": "https://github.com/Flowscape-UI/gradiente/issues"
|
|
22
|
-
},
|
|
23
|
-
"exports": {
|
|
24
|
-
".":
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "gradiente",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "2.1.2",
|
|
5
|
+
"description": "Lightweight gradient toolkit for modern rendering systems.",
|
|
6
|
+
"author": "Nice Arti <nikcrav@gmail.com>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"homepage": "https://flowscape-ui.github.io/gradiente/",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"gradiente",
|
|
11
|
+
"gradient",
|
|
12
|
+
"gradients",
|
|
13
|
+
"flowscape",
|
|
14
|
+
"color"
|
|
15
|
+
],
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/Flowscape-UI/gradiente.git"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/Flowscape-UI/gradiente/issues"
|
|
22
|
+
},
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js",
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./global": {
|
|
30
|
+
"default": "./dist/gradiente.global.js"
|
|
31
|
+
},
|
|
32
|
+
"./package.json": "./package.json"
|
|
33
|
+
},
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"module": "./dist/index.js",
|
|
36
|
+
"browser": "./dist/index.js",
|
|
37
|
+
"unpkg": "./dist/gradiente.global.iife.js",
|
|
38
|
+
"jsdelivr": "./dist/gradiente.global.iife.js",
|
|
39
|
+
"files": [
|
|
40
|
+
"dist"
|
|
41
|
+
],
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsdown",
|
|
44
|
+
"dev": "tsdown --watch",
|
|
45
|
+
"test": "vitest",
|
|
46
|
+
"typecheck": "tsc --noEmit",
|
|
47
|
+
"release": "bumpp",
|
|
48
|
+
"prepublishOnly": "pnpm run build",
|
|
49
|
+
"lint": "eslint .",
|
|
50
|
+
"lint:fix": "eslint . --fix"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@eslint/js": "^10.0.1",
|
|
54
|
+
"@types/culori": "^4.0.1",
|
|
55
|
+
"@types/node": "^25.5.0",
|
|
56
|
+
"bumpp": "^11.0.1",
|
|
57
|
+
"tsdown": "^0.21.7",
|
|
58
|
+
"typescript": "^6.0.2",
|
|
59
|
+
"typescript-eslint": "^8.58.2",
|
|
60
|
+
"vitest": "^4.1.5"
|
|
61
|
+
},
|
|
62
|
+
"dependencies": {
|
|
63
|
+
"culori": "^4.0.2"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
File without changes
|