gradiente 2.4.0 → 2.5.0
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/dist/gradiente.global.iife.js +6 -6
- package/dist/index.d.ts +45 -1
- package/dist/index.js +728 -104
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
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 ee=`(?:${S}%|${S})`,te=`(?:${S}%|${S}|none)`,ne=`(?:${S}(deg|grad|rad|turn)|${S})`;`${S}${S}`;let w=`\\s*,\\s*`;RegExp(`^`+te+`$`);let T=RegExp(`^rgba?\\(\\s*${S}${w}${S}${w}${S}\\s*(?:,\\s*${ee}\\s*)?\\)$`),re=RegExp(`^rgba?\\(\\s*${C}${w}${C}${w}${C}\\s*(?:,\\s*${ee}\\s*)?\\)$`),ie=e=>{let t={mode:`rgb`},n;if(n=e.match(T))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(re))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},ae=(e,t)=>e===void 0?void 0:typeof e==`object`?e.mode===void 0?t?{...e,mode:t}:void 0:e:we(e),E=(e=`rgb`)=>t=>(t=ae(t,e))===void 0?void 0:t.mode===e?t:D[t.mode][e]?D[t.mode][e](t):e===`rgb`?D[t.mode].rgb(t):D.rgb[e](D[t.mode].rgb(t)),D={},oe={},O=[],se={},ce=e=>e,k=e=>(D[e.mode]={...D[e.mode],...e.toMode},Object.keys(e.fromMode||{}).forEach(t=>{D[t]||(D[t]={}),D[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=ce)}),oe[e.mode]=e,(e.parse||[]).forEach(t=>{ue(t,e.mode)}),E(e.mode)),le=e=>oe[e],ue=(e,t)=>{if(typeof e==`string`){if(!t)throw Error(`'mode' required when 'parser' is a string`);se[e]=t}else typeof e==`function`&&O.indexOf(e)<0&&O.push(e)},de=/[^\x00-\x7F]|[a-zA-Z_]/,fe=/[^\x00-\x7F]|[-\w]/,A={Function:`function`,Ident:`ident`,Number:`number`,Percentage:`percentage`,ParenClose:`)`,None:`none`,Hue:`hue`,Alpha:`alpha`},j=0;function pe(e){let t=e[j],n=e[j+1];return t===`-`||t===`+`?/\d/.test(n)||n===`.`&&/\d/.test(e[j+2]):t===`.`?/\d/.test(n):/\d/.test(t)}function me(e){if(j>=e.length)return!1;let t=e[j];if(de.test(t))return!0;if(t===`-`){if(e.length-j<2)return!1;let t=e[j+1];return!!(t===`-`||de.test(t))}return!1}let he={deg:1,rad:180/Math.PI,grad:9/10,turn:360};function ge(e){let t=``;if((e[j]===`-`||e[j]===`+`)&&(t+=e[j++]),t+=_e(e),e[j]===`.`&&/\d/.test(e[j+1])&&(t+=e[j++]+_e(e)),(e[j]===`e`||e[j]===`E`)&&((e[j+1]===`-`||e[j+1]===`+`)&&/\d/.test(e[j+2])?t+=e[j++]+e[j++]+_e(e):/\d/.test(e[j+1])&&(t+=e[j++]+_e(e))),me(e)){let n=ve(e);return n===`deg`||n===`rad`||n===`turn`||n===`grad`?{type:A.Hue,value:t*he[n]}:void 0}return e[j]===`%`?(j++,{type:A.Percentage,value:+t}):{type:A.Number,value:+t}}function _e(e){let t=``;for(;/\d/.test(e[j]);)t+=e[j++];return t}function ve(e){let t=``;for(;j<e.length&&fe.test(e[j]);)t+=e[j++];return t}function ye(e){let t=ve(e);return e[j]===`(`?(j++,{type:A.Function,value:t}):t===`none`?{type:A.None,value:void 0}:{type:A.Ident,value:t}}function be(e=``){let t=e.trim(),n=[],r;for(j=0;j<t.length;){if(r=t[j++],r===`
|
|
2
2
|
`||r===` `||r===` `){for(;j<t.length&&(t[j]===`
|
|
3
3
|
`||t[j]===` `||t[j]===` `);)j++;continue}if(r===`,`)return;if(r===`)`){n.push({type:A.ParenClose});continue}if(r===`+`){if(j--,pe(t)){n.push(ge(t));continue}return}if(r===`-`){if(j--,pe(t)){n.push(ge(t));continue}if(me(t)){n.push({type:A.Ident,value:ve(t)});continue}return}if(r===`.`){if(j--,pe(t)){n.push(ge(t));continue}return}if(r===`/`){for(;j<t.length&&(t[j]===`
|
|
4
|
-
`||t[j]===` `||t[j]===` `);)j++;let e;if(pe(t)&&(e=ge(t),e.type!==A.Hue)){n.push({type:A.Alpha,value:e});continue}if(me(t)&&ve(t)===`none`){n.push({type:A.Alpha,value:{type:A.None,value:void 0}});continue}return}if(/\d/.test(r)){j--,n.push(ge(t));continue}if(de.test(r)){j--,n.push(ye(t));continue}return}return n}function xe(e){e._i=0;let t=e[e._i++];if(!t||t.type!==A.Function||t.value!==`color`||(t=e[e._i++],t.type!==A.Ident))return;let n=se[t.value];if(!n)return;let r={mode:n},i=Se(e,!1);if(!i)return;let a=le(n).channels;for(let e=0,t,n;e<a.length;e++)t=i[e],n=a[e],t.type!==A.None&&(r[n]=t.type===A.Number?t.value:t.value/100,n===`alpha`&&(r[n]=Math.max(0,Math.min(1,r[n]))));return r}function Se(e,t){let n=[],r;for(;e._i<e.length;){if(r=e[e._i++],r.type===A.None||r.type===A.Number||r.type===A.Alpha||r.type===A.Percentage||t&&r.type===A.Hue){n.push(r);continue}if(r.type===A.ParenClose){if(e._i<e.length)return;continue}return}if(!(n.length<3||n.length>4)){if(n.length===4){if(n[3].type!==A.Alpha)return;n[3]=n[3].value}return n.length===3&&n.push({type:A.None,value:void 0}),n.every(e=>e.type!==A.Alpha)?n:void 0}}function Ce(e,t){e._i=0;let n=e[e._i++];if(!n||n.type!==A.Function)return;let r=Se(e,t);if(r)return r.unshift(n.value),r}let we=e=>{if(typeof e!=`string`)return;let t=be(e),n=t?Ce(t,!0):void 0,r,i=0,a=O.length;for(;i<a;)if((r=O[i++](e,n))!==void 0)return r;return t?xe(t):void 0};function Te(e,t){if(!t||t[0]!==`rgb`&&t[0]!==`rgba`)return;let n={mode:`rgb`},[,r,i,a,o]=t;if(!(r.type===A.Hue||i.type===A.Hue||a.type===A.Hue))return r.type!==A.None&&(n.r=r.type===A.Number?r.value/255:r.value/100),i.type!==A.None&&(n.g=i.type===A.Number?i.value/255:i.value/100),a.type!==A.None&&(n.b=a.type===A.Number?a.value/255:a.value/100),o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}let Ee=e=>e===`transparent`?{mode:`rgb`,r:0,g:0,b:0,alpha:0}:void 0,De=(e,t,n)=>e+n*(t-e),Oe=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},M=(e=>t=>{let n=Oe(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)}})(De),N=e=>{let t=!1,n=e.map(e=>e===void 0?1:(t=!0,e));return t?n:e},P={mode:`rgb`,channels:[`r`,`g`,`b`,`alpha`],parse:[Te,x,ie,y,Ee,`srgb`],serialize:`srgb`,interpolate:{r:M,g:M,b:M,alpha:{use:M,fixup:N}},gamut:!0,white:{r:1,g:1,b:1},black:{r:0,g:0,b:0}},ke=(e=0)=>Math.abs(e)**(563/256)*Math.sign(e),Ae=e=>{let t=ke(e.r),n=ke(e.g),r=ke(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},je=e=>Math.abs(e)**(256/563)*Math.sign(e),Me=({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:je(e*2.0415879038107465-t*.5650069742788597-.3447313507783297*n),g:je(e*-.9692436362808798+t*1.8759675015077206+.0415550574071756*n),b:je(e*.0134442806320312-t*.1183623922310184+1.0151749943912058*n)};return r!==void 0&&(i.alpha=r),i},Ne=(e=0)=>{let t=Math.abs(e);return t<=.04045?e/12.92:(Math.sign(e)||1)*((t+.055)/1.055)**2.4},Pe=({r:e,g:t,b:n,alpha:r})=>{let i={mode:`lrgb`,r:Ne(e),g:Ne(t),b:Ne(n)};return r!==void 0&&(i.alpha=r),i},F=e=>{let{r:t,g:n,b:r,alpha:i}=Pe(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},Fe=(e=0)=>{let t=Math.abs(e);return t>.0031308?(Math.sign(e)||1)*(1.055*t**(1/2.4)-.055):e*12.92},Ie=({r:e,g:t,b:n,alpha:r},i=`rgb`)=>{let a={mode:i,r:Fe(e),g:Fe(t),b:Fe(n)};return r!==void 0&&(a.alpha=r),a},I=({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=Ie({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},Le={...P,mode:`a98`,parse:[`a98-rgb`],serialize:`a98-rgb`,fromMode:{rgb:e=>Me(F(e)),xyz65:Me},toMode:{rgb:e=>I(Ae(e)),xyz65:Ae}},L=e=>(e%=360)<0?e+360:e,Re=(e,t)=>e.map((n,r,i)=>{if(n===void 0)return n;let a=L(n);return r===0||e[r-1]===void 0?a:t(a-L(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),[]),R=e=>Re(e,e=>Math.abs(e)<=180?e:e-360*Math.sign(e)),ze=e=>Re(e,e=>Math.abs(e)>=180||e===0?e:e-360*Math.sign(e)),Be=e=>Re(e,e=>e>=0?e:e+360),Ve=e=>Re(e,e=>e<=0?e:e-360),z=[-.14861,1.78277,-.29227,-.90649,1.97294,0],He=Math.PI/180,Ue=180/Math.PI,We=z[3]*z[4],Ge=z[1]*z[4],Ke=z[1]*z[2]-z[0]*z[3],qe=({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=(Ke*n+e*We-t*Ge)/(Ke+We-Ge),a=n-i,o=(z[4]*(t-i)-z[2]*a)/z[3],s={mode:`cubehelix`,l:i,s:i===0||i===1?void 0:Math.sqrt(a*a+o*o)/(z[4]*i*(1-i))};return s.s&&(s.h=Math.atan2(o,a)*Ue-120),r!==void 0&&(s.alpha=r),s},Je=({h:e,s:t,l:n,alpha:r})=>{let i={mode:`rgb`};e=(e===void 0?0:e+120)*He,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*(z[0]*o+z[1]*s),i.g=n+a*(z[2]*o+z[3]*s),i.b=n+a*(z[4]*o+z[5]*s),r!==void 0&&(i.alpha=r),i},Ye=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.s||!t.s)return 0;let n=L(e.h),r=L(t.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.s*t.s)*i},Xe=(e,t)=>{if(e.h===void 0||t.h===void 0)return 0;let n=L(e.h),r=L(t.h);return Math.abs(r-n)>180?n-(r-360*Math.sign(r-n)):r-n},Ze=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.c||!t.c)return 0;let n=L(e.h),r=L(t.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.c*t.c)*i},B=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:qe},toMode:{rgb:Je},interpolate:{h:{use:M,fixup:R},s:M,l:M,alpha:{use:M,fixup:N}},difference:{h:Ye},average:{h:B}},V=({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=L(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(o.alpha=r),o},H=({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},$e=29**3/3**3,et=6**3/29**3,U={X:.3457/.3585,Y:1,Z:.2958/.3585},W={X:.3127/.329,Y:1,Z:.3583/.329},tt=e=>e**3>et?e**3:(116*e-16)/$e,nt=({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:tt(a)*W.X,y:tt(i)*W.Y,z:tt(o)*W.Z};return r!==void 0&&(s.alpha=r),s},rt=e=>I(nt(e)),it=e=>e>et?Math.cbrt(e):($e*e+16)/116,at=({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=it(e/W.X),a=it(t/W.Y),o=it(n/W.Z),s={mode:`lab65`,l:116*a-16,a:500*(i-a),b:200*(a-o)};return r!==void 0&&(s.alpha=r),s},ot=e=>{let t=at(F(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},st=26/180*Math.PI,ct=Math.cos(st),lt=Math.sin(st),ut=100/Math.log(139/100),dt=({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/ut)-1)/.0039},a=(Math.exp(.0435*t*1*1)-1)/.075,o=a*Math.cos(n/180*Math.PI-st),s=a*Math.sin(n/180*Math.PI-st);return i.a=o*ct-s/.83*lt,i.b=o*lt+s/.83*ct,r!==void 0&&(i.alpha=r),i},ft=({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*ct+n*lt,a=.83*(n*ct-t*lt),o=Math.sqrt(i*i+a*a),s={mode:`dlch`,l:ut/1*Math.log(1+.0039*e),c:Math.log(1+.075*o)/(.0435*1*1)};return s.c&&(s.h=L((Math.atan2(a,i)+st)/Math.PI*180)),r!==void 0&&(s.alpha=r),s},pt=e=>dt(V(e,`dlch`)),mt=e=>H(ft(e),`dlab`),ht={mode:`dlab`,parse:[`--din99o-lab`],serialize:`--din99o-lab`,toMode:{lab65:pt,rgb:e=>rt(pt(e))},fromMode:{lab65:mt,rgb:e=>mt(ot(e))},channels:[`l`,`a`,`b`,`alpha`],ranges:{l:[0,100],a:[-40.09,45.501],b:[-40.469,44.344]},interpolate:{l:M,a:M,b:M,alpha:{use:M,fixup:N}}},gt={mode:`dlch`,parse:[`--din99o-lch`],serialize:`--din99o-lch`,toMode:{lab65:dt,dlab:e=>H(e,`dlab`),rgb:e=>rt(dt(e))},fromMode:{lab65:ft,dlab:e=>V(e,`dlch`),rgb:e=>ft(ot(e))},channels:[`l`,`c`,`h`,`alpha`],ranges:{l:[0,100],c:[0,51.484],h:[0,360]},interpolate:{l:M,c:M,h:{use:M,fixup:R},alpha:{use:M,fixup:N}},difference:{h:Ze},average:{h:B}};function _t({h:e,s:t,i:n,alpha:r}){e=L(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 vt({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 yt={mode:`hsi`,toMode:{rgb:_t},parse:[`--hsi`],serialize:`--hsi`,fromMode:{rgb:vt},channels:[`h`,`s`,`i`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,interpolate:{h:{use:M,fixup:R},s:M,i:M,alpha:{use:M,fixup:N}},difference:{h:Ye},average:{h:B}};function bt({h:e,s:t,l:n,alpha:r}){e=L(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 xt({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 St=(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}},Ct=RegExp(`^hsla?\\(\\s*${ne}${w}${C}${w}${C}\\s*(?:,\\s*${ee}\\s*)?\\)$`),wt=e=>{let t=e.match(Ct);if(!t)return;let n={mode:`hsl`};return t[3]===void 0?t[1]!==void 0&&t[2]!==void 0&&(n.h=St(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 Tt(e,t){if(!t||t[0]!==`hsl`&&t[0]!==`hsla`)return;let n={mode:`hsl`},[,r,i,a,o]=t;if(r.type!==A.None){if(r.type===A.Percentage)return;n.h=r.value}if(i.type!==A.None){if(i.type===A.Hue)return;n.s=i.value/100}if(a.type!==A.None){if(a.type===A.Hue)return;n.l=a.value/100}return o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}let Et={mode:`hsl`,toMode:{rgb:bt},fromMode:{rgb:xt},channels:[`h`,`s`,`l`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,parse:[Tt,wt],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:M,fixup:R},s:M,l:M,alpha:{use:M,fixup:N}},difference:{h:Ye},average:{h:B}};function Dt({h:e,s:t,v:n,alpha:r}){e=L(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 Ot({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 kt={mode:`hsv`,toMode:{rgb:Dt},parse:[`--hsv`],serialize:`--hsv`,fromMode:{rgb:Ot},channels:[`h`,`s`,`v`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,interpolate:{h:{use:M,fixup:R},s:M,v:M,alpha:{use:M,fixup:N}},difference:{h:Ye},average:{h:B}};function At({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 Dt({h:e,s:n===1?1:1-t/(1-n),v:1-n,alpha:r})}function jt(e){let t=Ot(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 Mt(e,t){if(!t||t[0]!==`hwb`)return;let n={mode:`hwb`},[,r,i,a,o]=t;if(r.type!==A.None){if(r.type===A.Percentage)return;n.h=r.value}if(i.type!==A.None){if(i.type===A.Hue)return;n.w=i.value/100}if(a.type!==A.None){if(a.type===A.Hue)return;n.b=a.value/100}return o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}let Nt={mode:`hwb`,toMode:{rgb:At},fromMode:{rgb:jt},channels:[`h`,`w`,`b`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,parse:[Mt],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:M,fixup:R},w:M,b:M,alpha:{use:M,fixup:N}},difference:{h:Xe},average:{h:B}},Pt=.1593017578125,Ft=78.84375,It=.8359375,Lt=18.8515625,Rt=18.6875;function zt(e){if(e<0)return 0;let t=e**(1/Ft);return 1e4*(Math.max(0,t-It)/(Lt-Rt*t))**(1/Pt)}function Bt(e){if(e<0)return 0;let t=(e/1e4)**Pt;return((It+Lt*t)/(1+Rt*t))**+Ft}let Vt=e=>Math.max(e/203,0),Ht=({i:e,t,p:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=zt(e+.008609037037932761*t+.11102962500302593*n),a=zt(e-.00860903703793275*t-.11102962500302599*n),o=zt(e+.5600313357106791*t-.32062717498731885*n),s={mode:`xyz65`,x:Vt(2.070152218389422*i-1.3263473389671556*a+.2066510476294051*o),y:Vt(.3647385209748074*i+.680566024947227*a-.0453045459220346*o),z:Vt(-.049747207535812*i-.0492609666966138*a+1.1880659249923042*o)};return r!==void 0&&(s.alpha=r),s},Ut=(e=0)=>Math.max(e*203,0),Wt=({x:e,y:t,z:n,alpha:r})=>{let i=Ut(e),a=Ut(t),o=Ut(n),s=Bt(.3592832590121217*i+.6976051147779502*a-.0358915932320289*o),c=Bt(-.1920808463704995*i+1.1004767970374323*a+.0753748658519118*o),l=Bt(.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},Gt={mode:`itp`,channels:[`i`,`t`,`p`,`alpha`],parse:[`--ictcp`],serialize:`--ictcp`,toMode:{xyz65:Ht,rgb:e=>I(Ht(e))},fromMode:{xyz65:Wt,rgb:e=>Wt(F(e))},ranges:{i:[0,.581],t:[-.369,.272],p:[-.164,.331]},interpolate:{i:M,t:M,p:M,alpha:{use:M,fixup:N}}},Kt=e=>{if(e<0)return 0;let t=(e/1e4)**Pt;return((It+Lt*t)/(1+Rt*t))**134.03437499999998},qt=(e=0)=>Math.max(e*203,0),Jt=({x:e,y:t,z:n,alpha:r})=>{e=qt(e),t=qt(t),n=qt(n);let i=1.15*e-.15*n,a=.66*t+.34*e,o=Kt(.41478972*i+.579999*a+.014648*n),s=Kt(-.20151*i+1.120649*a+.0531008*n),c=Kt(-.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},Yt=16295499532821565e-27,Xt=e=>{if(e<0)return 0;let t=e**(1/134.03437499999998);return 1e4*((It-t)/(Rt*t-Lt))**(1/Pt)},Zt=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+Yt)/(.44+.56*(e+Yt)),a=Xt(i+.13860504*t+.058047316*n),o=Xt(i-.13860504*t-.058047316*n),s=Xt(i-.096019242*t-.8118919*n),c={mode:`xyz65`,x:Zt(1.661373024652174*a-.914523081304348*o+.23136208173913045*s),y:Zt(-.3250758611844533*a+1.571847026732543*o-.21825383453227928*s),z:Zt(-.090982811*a-.31272829*o+1.5227666*s)};return r!==void 0&&(c.alpha=r),c},$t=e=>{let t=Jt(F(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},en=e=>I(Qt(e)),tn={mode:`jab`,channels:[`j`,`a`,`b`,`alpha`],parse:[`--jzazbz`],serialize:`--jzazbz`,fromMode:{rgb:$t,xyz65:Jt},toMode:{rgb:en,xyz65:Qt},ranges:{j:[0,.222],a:[-.109,.129],b:[-.185,.134]},interpolate:{j:M,a:M,b:M,alpha:{use:M,fixup:N}}},nn=({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=L(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(a.alpha=r),a},rn=({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},an={mode:`jch`,parse:[`--jzczhz`],serialize:`--jzczhz`,toMode:{jab:rn,rgb:e=>en(rn(e))},fromMode:{rgb:e=>nn($t(e)),jab:nn},channels:[`j`,`c`,`h`,`alpha`],ranges:{j:[0,.221],c:[0,.19],h:[0,360]},interpolate:{h:{use:M,fixup:R},c:M,j:M,alpha:{use:M,fixup:N}},difference:{h:Ze},average:{h:B}},on=29**3/3**3,sn=6**3/29**3,cn=e=>e**3>sn?e**3:(116*e-16)/on,ln=({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:cn(a)*U.X,y:cn(i)*U.Y,z:cn(o)*U.Z};return r!==void 0&&(s.alpha=r),s},un=({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=Ie({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},dn=e=>un(ln(e)),fn=e=>{let{r:t,g:n,b:r,alpha:i}=Pe(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},pn=e=>e>sn?Math.cbrt(e):(on*e+16)/116,mn=({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=pn(e/U.X),a=pn(t/U.Y),o=pn(n/U.Z),s={mode:`lab`,l:116*a-16,a:500*(i-a),b:200*(a-o)};return r!==void 0&&(s.alpha=r),s},hn=e=>{let t=mn(fn(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t};function gn(e,t){if(!t||t[0]!==`lab`)return;let n={mode:`lab`},[,r,i,a,o]=t;if(!(r.type===A.Hue||i.type===A.Hue||a.type===A.Hue))return r.type!==A.None&&(n.l=Math.min(Math.max(0,r.value),100)),i.type!==A.None&&(n.a=i.type===A.Number?i.value:i.value*125/100),a.type!==A.None&&(n.b=a.type===A.Number?a.value:a.value*125/100),o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}let _n={mode:`lab`,toMode:{xyz50:ln,rgb:dn},fromMode:{xyz50:mn,rgb:hn},channels:[`l`,`a`,`b`,`alpha`],ranges:{l:[0,100],a:[-125,125],b:[-125,125]},parse:[gn],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:M,a:M,b:M,alpha:{use:M,fixup:N}}},vn={..._n,mode:`lab65`,parse:[`--lab-d65`],serialize:`--lab-d65`,toMode:{xyz65:nt,rgb:rt},fromMode:{xyz65:at,rgb:ot},ranges:{l:[0,100],a:[-125,125],b:[-125,125]}};function yn(e,t){if(!t||t[0]!==`lch`)return;let n={mode:`lch`},[,r,i,a,o]=t;if(r.type!==A.None){if(r.type===A.Hue)return;n.l=Math.min(Math.max(0,r.value),100)}if(i.type!==A.None&&(n.c=Math.max(0,i.type===A.Number?i.value:i.value*150/100)),a.type!==A.None){if(a.type===A.Percentage)return;n.h=a.value}return o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}let bn={mode:`lch`,toMode:{lab:H,rgb:e=>dn(H(e))},fromMode:{rgb:e=>V(hn(e)),lab:V},channels:[`l`,`c`,`h`,`alpha`],ranges:{l:[0,100],c:[0,150],h:[0,360]},parse:[yn],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:M,fixup:R},c:M,l:M,alpha:{use:M,fixup:N}},difference:{h:Ze},average:{h:B}},xn={...bn,mode:`lch65`,parse:[`--lch-d65`],serialize:`--lch-d65`,toMode:{lab65:e=>H(e,`lab65`),rgb:e=>rt(H(e,`lab65`))},fromMode:{rgb:e=>V(ot(e),`lch65`),lab65:e=>V(e,`lch65`)},ranges:{l:[0,100],c:[0,150],h:[0,360]}},Sn=({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=L(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(a.alpha=r),a},Cn=({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},wn=(e,t,n)=>4*e/(e+15*t+3*n),Tn=(e,t,n)=>9*t/(e+15*t+3*n),En=wn(U.X,U.Y,U.Z),Dn=Tn(U.X,U.Y,U.Z),On=e=>e<=sn?on*e:116*Math.cbrt(e)-16,kn=({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=On(t/U.Y),a=wn(e,t,n),o=Tn(e,t,n);!isFinite(a)||!isFinite(o)?i=a=o=0:(a=13*i*(a-En),o=13*i*(o-Dn));let s={mode:`luv`,l:i,u:a,v:o};return r!==void 0&&(s.alpha=r),s},An=(e,t,n)=>4*e/(e+15*t+3*n),jn=(e,t,n)=>9*t/(e+15*t+3*n),Mn=An(U.X,U.Y,U.Z),Nn=jn(U.X,U.Y,U.Z),Pn=({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)+Mn,a=n/(13*e)+Nn,o=U.Y*(e<=8?e/on:((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},Fn={mode:`lchuv`,toMode:{luv:Cn,rgb:e=>un(Pn(Cn(e)))},fromMode:{rgb:e=>Sn(kn(fn(e))),luv:Sn},channels:[`l`,`c`,`h`,`alpha`],parse:[`--lchuv`],serialize:`--lchuv`,ranges:{l:[0,100],c:[0,176.956],h:[0,360]},interpolate:{h:{use:M,fixup:R},c:M,l:M,alpha:{use:M,fixup:N}},difference:{h:Ze},average:{h:B}},In={...P,mode:`lrgb`,toMode:{rgb:Ie},fromMode:{rgb:Pe},parse:[`srgb-linear`],serialize:`srgb-linear`},Ln={mode:`luv`,toMode:{xyz50:Pn,rgb:e=>un(Pn(e))},fromMode:{xyz50:kn,rgb:e=>kn(fn(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:M,u:M,v:M,alpha:{use:M,fixup:N}}},Rn=({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},zn=e=>{let t=Rn(Pe(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},Bn=({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},Vn=e=>Ie(Bn(e));function Hn(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 Un(e){let t=.206,n=.03;return(1+t)/(1+n),(e*e+t*e)/(1.170873786407767*(e+n))}function Wn(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 Gn(e,t){let n=Wn(e,t),r=Bn({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 Kn(e,t,n,r,i,a=null){a||=Gn(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,ee=4.0767416621*h-3.3077115913*g+.2309699292*_-1,te=4.0767416621*v-3.3077115913*y+.2309699292*b,ne=4.0767416621*x-3.3077115913*S+.2309699292*C,w=te/(te*te-.5*ee*ne),T=-ee*w,re=-1.2684380046*h+2.6097574011*g-.3413193965*_-1,ie=-1.2684380046*v+2.6097574011*y-.3413193965*b,ae=-1.2684380046*x+2.6097574011*S-.3413193965*C,E=ie/(ie*ie-.5*re*ae),D=-re*E,oe=-.0041960863*h-.7034186147*g+1.707614701*_-1,O=-.0041960863*v-.7034186147*y+1.707614701*b,se=-.0041960863*x-.7034186147*S+1.707614701*C,ce=O/(O*O-.5*oe*se),k=-oe*ce;T=w>=0?T:1e6,D=E>=0?D:1e6,k=ce>=0?k:1e6,o+=Math.min(T,Math.min(D,k))}}}return o}function qn(e,t,n=null){n||=Gn(e,t);let r=n[0],i=n[1];return[i/r,i/(1-r)]}function Jn(e,t,n){let r=Gn(t,n),i=Kn(t,n,e,1,e,r),a=qn(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 Yn(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:Hn(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]=Jn(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=L(Math.atan2(r,n)*180/Math.PI)),i}function Xn(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:Un(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]=Jn(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 Zn={...Et,mode:`okhsl`,channels:[`h`,`s`,`l`,`alpha`],parse:[`--okhsl`],serialize:`--okhsl`,fromMode:{oklab:Yn,rgb:e=>Yn(zn(e))},toMode:{oklab:Xn,rgb:e=>Vn(Xn(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]=qn(a,o),l=.5,u=1-l/s,d=c/(i+t*c),f=d*t,p=d*i,m=Un(f),h=p*m/f,g=Bn({l:m,a:a*h,b:o*h}),_=Math.cbrt(1/Math.max(g.r,g.g,g.b,0));t/=_,i=i/_*Hn(t)/t,t=Hn(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=L(Math.atan2(r,n)*180/Math.PI)),e.alpha!==void 0&&(v.alpha=e.alpha),v}function $n(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]=qn(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=Un(d),m=f*p/d,h=Bn({l:p,a:a*m,b:o*m}),g=Math.cbrt(1/Math.max(h.r,h.g,h.b,0)),_=Un(i*d),v=f*_/d;return t.l=_*g,t.a=v*a*g,t.b=v*o*g,t}let er={...kt,mode:`okhsv`,channels:[`h`,`s`,`v`,`alpha`],parse:[`--okhsv`],serialize:`--okhsv`,fromMode:{oklab:Qn,rgb:e=>Qn(zn(e))},toMode:{oklab:$n,rgb:e=>Vn($n(e))}};function tr(e,t){if(!t||t[0]!==`oklab`)return;let n={mode:`oklab`},[,r,i,a,o]=t;if(!(r.type===A.Hue||i.type===A.Hue||a.type===A.Hue))return r.type!==A.None&&(n.l=Math.min(Math.max(0,r.type===A.Number?r.value:r.value/100),1)),i.type!==A.None&&(n.a=i.type===A.Number?i.value:i.value*.4/100),a.type!==A.None&&(n.b=a.type===A.Number?a.value:a.value*.4/100),o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}let nr={..._n,mode:`oklab`,toMode:{lrgb:Bn,rgb:Vn},fromMode:{lrgb:Rn,rgb:zn},ranges:{l:[0,1],a:[-.4,.4],b:[-.4,.4]},parse:[tr],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 rr(e,t){if(!t||t[0]!==`oklch`)return;let n={mode:`oklch`},[,r,i,a,o]=t;if(r.type!==A.None){if(r.type===A.Hue)return;n.l=Math.min(Math.max(0,r.type===A.Number?r.value:r.value/100),1)}if(i.type!==A.None&&(n.c=Math.max(0,i.type===A.Number?i.value:i.value*.4/100)),a.type!==A.None){if(a.type===A.Percentage)return;n.h=a.value}return o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}let ir={...bn,mode:`oklch`,toMode:{oklab:e=>H(e,`oklab`),rgb:e=>Vn(H(e,`oklab`))},fromMode:{rgb:e=>V(zn(e),`oklch`),oklab:e=>V(e,`oklch`)},parse:[rr],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]}},ar=e=>{let{r:t,g:n,b:r,alpha:i}=Pe(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},or=({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=Ie({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},sr={...P,mode:`p3`,parse:[`display-p3`],serialize:`display-p3`,fromMode:{rgb:e=>or(F(e)),xyz65:or},toMode:{rgb:e=>I(ar(e)),xyz65:ar}},cr=e=>{let t=Math.abs(e);return t>=1/512?Math.sign(e)*t**(1/1.8):16*e},lr=({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:cr(e*1.3457868816471585-t*.2555720873797946-.0511018649755453*n),g:cr(e*-.5446307051249019+t*1.5082477428451466+.0205274474364214*n),b:cr(e*0+t*0+1.2119675456389452*n)};return r!==void 0&&(i.alpha=r),i},ur=(e=0)=>{let t=Math.abs(e);return t>=16/512?Math.sign(e)*t**1.8:e/16},dr=e=>{let t=ur(e.r),n=ur(e.g),r=ur(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},fr={...P,mode:`prophoto`,parse:[`prophoto-rgb`],serialize:`prophoto-rgb`,fromMode:{xyz50:lr,rgb:e=>lr(fn(e))},toMode:{xyz50:dr,rgb:e=>un(dr(e))}},pr=1.09929682680944,mr=e=>{let t=Math.abs(e);return t>.018053968510807?(Math.sign(e)||1)*(pr*t**.45-(pr-1)):4.5*e},hr=({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:mr(e*1.7166511879712683-t*.3556707837763925-.2533662813736599*n),g:mr(e*-.6666843518324893+t*1.6164812366349395+.0157685458139111*n),b:mr(e*.0176398574453108-t*.0427706132578085+.9421031212354739*n)};return r!==void 0&&(i.alpha=r),i},gr=1.09929682680944,_r=(e=0)=>{let t=Math.abs(e);return t<.018053968510807*4.5?e/4.5:(Math.sign(e)||1)*((t+gr-1)/gr)**(1/.45)},vr=e=>{let t=_r(e.r),n=_r(e.g),r=_r(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},yr={...P,mode:`rec2020`,fromMode:{xyz65:hr,rgb:e=>hr(F(e))},toMode:{xyz65:vr,rgb:e=>I(vr(e))},parse:[`rec2020`],serialize:`rec2020`},G=.0037930732552754493,br=Math.cbrt(G),xr=e=>Math.cbrt(e)-br,Sr=e=>{let{r:t,g:n,b:r,alpha:i}=Pe(e),a=xr(.3*t+.622*n+.078*r+G),o=xr(.23*t+.692*n+.078*r+G),s=xr(.2434226892454782*t+.2047674442449682*n+.5518098665095535*r+G),c={mode:`xyb`,x:(a-o)/2,y:(a+o)/2,b:s-(a+o)/2};return i!==void 0&&(c.alpha=i),c},Cr=e=>(e+br)**3,wr={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=Cr(e+t)-G,a=Cr(t-e)-G,o=Cr(n+t)-G,s=Ie({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:Sr},ranges:{x:[-.0154,.0281],y:[0,.8453],b:[-.2778,.388]},interpolate:{x:M,y:M,b:M,alpha:{use:M,fixup:N}}},Tr={mode:`xyz50`,parse:[`xyz-d50`],serialize:`xyz-d50`,toMode:{rgb:un,lab:mn},fromMode:{rgb:fn,lab:ln},channels:[`x`,`y`,`z`,`alpha`],ranges:{x:[0,.964],y:[0,.999],z:[0,.825]},interpolate:{x:M,y:M,z:M,alpha:{use:M,fixup:N}}},Er={mode:`xyz65`,toMode:{rgb:I,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:F,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:M,y:M,z:M,alpha:{use:M,fixup:N}}},Dr={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:M,i:M,q:M,alpha:{use:M,fixup:N}}},Or=(e,t)=>Math.round(e*(t=10**t))/t,kr=((e=4)=>t=>typeof t==`number`?Or(t,e):t)(2),Ar=e=>Math.max(0,Math.min(1,e||0)),jr=e=>Math.round(Ar(e)*255),Mr=E(`rgb`),Nr=e=>{if(e===void 0)return;let t=jr(e.r),n=jr(e.g),r=jr(e.b);return e.alpha===void 0||e.alpha===1?`rgb(${t}, ${n}, ${r})`:`rgba(${t}, ${n}, ${r}, ${kr(Ar(e.alpha))})`},K=e=>Nr(Mr(e)),Pr=(e,t=`rgb`,n=!1)=>{let r=t?le(t).channels:null,i=t?E(t):ae;return a=>{let o=i(a);if(!o)return;let s=(r||le(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=ae(a);return c&&c.mode!==s.mode?E(c.mode)(s):s}},Fr=(e,t,n)=>t===`alpha`?e:(e||0)*(n.alpha===void 0?1:n.alpha),Ir=(e,t,n)=>t!==`alpha`&&n.alpha!==0?(e||0)/(n.alpha===void 0?1:n.alpha):e,Lr=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},Rr=(e=.5)=>t=>e<=0?1:e>=1?0:t**+(Math.log(.5)/Math.log(e)),zr=e=>typeof e==`function`,q=e=>e&&typeof e==`object`,Br=e=>typeof e==`number`,Vr=(e,t=`rgb`,n,r)=>{let i=le(t),a=E(t),o=[],s=[],c={};e.forEach(e=>{Array.isArray(e)?(o.push(a(e[0])),s.push(e[1])):Br(e)||zr(e)?c[s.length]=e:(o.push(a(e)),s.push(void 0))}),Lr(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 zr(n)?r=n:q(n)&&zr(n[t])?r=n[t]:q(n)&&q(n[t])&&n[t].use?r=n[t].use:zr(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&&(Br(f)&&(f=Rr((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})}},J=(e,t=`rgb`,n)=>Vr(e,t,n);((e,t)=>(n,r=`rgb`,i)=>{let a=t?Pr(t,r):void 0,o=Vr(n,r,i,e);return a?e=>a(o(e)):o})(Fr,Ir),k(Le),k(Qe),k(ht),k(gt),k(yt),k(Et),k(kt),k(Nt),k(Gt),k(tn),k(an),k(_n),k(vn),k(bn),k(xn),k(Fn),k(In),k(Ln),k(Zn),k(er),k(nr),k(ir),k(sr),k(fr),k(yr),k(P),k(wr),k(Tr),k(Er),k(Dr);let Hr=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 Ur(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=Gr(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 Wr(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 Gr(e,t,n,r){let i=t[r];if(i===`config`||i===`color-stop`||i===`color-hint`)return Wr(e,t,n,r);if(i===`[`)return qr(e,t,n,r);if(i===`(`)return Yr(e,t,n,r);if(i===`~`)return Xr(e,t,n,r);throw Error(`Unsupported primary token "${i}" at pattern index ${r}`)}function Kr(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 qr(e,t,n,r){if(t[r]!==`[`)throw Error(`Expected "[" at pattern index ${r}`);let i=Kr(t,r,`[`,`]`),a=n,o=r+1;for(;o<i;){if(t[o]===`,`){o+=1;continue}let i=Gr(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 Jr(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 Yr(e,t,n,r){if(t[r]!==`(`)throw Error(`Expected "(" at pattern index ${r}`);let i=Kr(t,r,`(`,`)`),a=Jr(t.slice(r+1,i));for(let t of a){let r=Ur(e,t,n,0);if(r.matched)return{matched:!0,nextInputIndex:r.nextInputIndex,nextPatternIndex:i+1}}return{matched:!1,nextInputIndex:n,nextPatternIndex:r}}function Xr(e,t,n,r){if(t[r]!==`~`)throw Error(`Expected "~" at pattern index ${r}`);let i=n,a=r+1;for(;;){let n=Gr(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=Zr(t,a);return{matched:!0,nextInputIndex:i,nextPatternIndex:o}}function Zr(e,t){let n=e[t];if(n===`config`||n===`color-stop`||n===`color-hint`)return t+1;if(n===`[`)return Kr(e,t,`[`,`]`)+1;if(n===`(`)return Kr(e,t,`(`,`)`)+1;if(n===`~`)return Zr(e,t+1);throw Error(`Unsupported token "${n}" in getPrimaryEndIndex`)}function Qr(e){return ei(e),ri(e),ii(e),!0}function $r(e){try{return Qr(e),!0}catch{return!1}}function ei(e){let t=ai(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 ti(e){try{return ei(e),!0}catch{return!1}}let ni={"^":[`(`,`[`,`!`,`~`,`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 ri(e){let t=ai(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=ni[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 ii(e){let t=ai(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 ai(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 oi(e,t){try{return si(e,t),!0}catch{return!1}}function si(e,t){Qr(t);let n=ai(t).slice(1,-1),r=Ur(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 ci(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}=pi(n),o=fi(a);return si(o,t),{functionName:r,isRepeating:i,inputs:o}}function li(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 ui(e){try{let t=_i(e)[0];return we(t)!==void 0}catch{return!1}}function di(e){return!li(e)&&!ui(e)}function fi(e){let t=e.map(e=>e.trim()).filter(e=>e.length>0);return t.length===0?[]:t.map((e,t)=>t===0&&!ui(e)?{type:`config`,value:e}:ui(e)?{type:`color-stop`,value:e}:li(e)?{type:`color-hint`,value:e}:{type:`config`,value:e})}function pi(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=mi(e,t);if(i===-1)throw Error(`Unclosed function parenthesis`);let a=hi(e.slice(t+1,i));return{functionName:n,isRepeating:r,inputs:a}}function mi(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 hi(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){gi(t,n),n=``;continue}n+=s}return gi(t,n),t}function gi(e,t){let n=t.trim();n.length>0&&e.push(n)}function _i(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 vi=[`oklab`,`lch`,`oklch`,`hsl`,`hwb`,`lab`,`srgb`,`srgb-linear`,`xyz`,`display-p3`,`a98-rgb`,`prophoto-rgb`,`rec2020`],yi=[`shorter`,`longer`,`increasing`,`decreasing`],bi=[`hsl`,`hwb`,`lch`,`oklch`];function xi(e){return yi.includes(e)}function Si(e){return vi.includes(e)}function Ci(e){return bi.includes(e)}var wi=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=_i(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}})}},Ti=class e extends wi{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(ci(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||!Ci(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||!Si(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(xi(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}},Ei=class e extends wi{static DEFAULT_CONFIG={isRepeating:!1,stops:[{type:`color-stop`,value:`red`,position:0},{type:`color-stop`,value:`blue`,position:1}],config:{shape:`ellipse`,size:{kind:`extent`,value:`farthest-corner`},position:{kind:`keywords`,x:`center`,y:`center`}}};type=`radial-gradient`;constructor(t){let n={...e.DEFAULT_CONFIG,...t};n.config.interpolation&&(n.config.interpolation=e._normalizeConfigInterpolation(n.config.interpolation)),super(n)}static fromString(t){return e.fromAbi(ci(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._parseConfigToString(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`)}_parseConfigToString(e){let t=[],n=this._parseRadialConfigToString(e);return n.length>0&&t.push(n),e.interpolation!==void 0&&t.push(this._parseInterpolationToString(e.interpolation)),t.join(` `)}_parseRadialConfigToString(e){let t=[];return this._isDefaultRadialShape(e.shape)||t.push(e.shape),this._isDefaultRadialSize(e.size)||t.push(this._parseRadialSizeToString(e.size)),this._isDefaultRadialPosition(e.position)||t.push(`at ${this._serializePosition(e.position)}`),t.join(` `)}_parseRadialSizeToString(e){if(e.kind===`extent`)return e.value;let t=this._formatLengthPercentage(e.x);return e.y===void 0?t:`${t} ${this._formatLengthPercentage(e.y)}`}_parseInterpolationToString(e){let{colorSpace:t,hue:n}=e;return n===void 0?`in ${t}`:`in ${t} ${n} hue`}_isDefaultRadialShape(e){return e===`ellipse`}_isDefaultRadialSize(e){return e.kind===`extent`&&e.value===`farthest-corner`}_isDefaultRadialPosition(e){return e.kind===`keywords`&&e.x===`center`&&e.y===`center`}_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`},i,a=e=>e===void 0?!1:e.endsWith(`%`)||/^-?\d*\.?\d+[a-zA-Z]+$/.test(e);for(let o of e){if(o.type!==`config`)continue;let e=_i(o.value);for(let o=0;o<e.length;o++){let s=e[o];if(s===`circle`||s===`ellipse`){t=s;continue}if(s===`closest-side`||s===`closest-corner`||s===`farthest-side`||s===`farthest-corner`){n={kind:`extent`,value:s};continue}if(a(s)){let r=e[o+1];if(t===`ellipse`&&a(r)){n={kind:`explicit`,x:this._parseLengthPercentage(s),y:this._parseLengthPercentage(r)},o+=1;continue}n={kind:`explicit`,x:this._parseLengthPercentage(s)};continue}if(s===`at`){let t=e[o+1],n=e[o+2];if(t===`center`&&(n===void 0||n===`in`)){r={kind:`keywords`,x:`center`,y:`center`},o+=1;continue}if((t===`left`||t===`right`)&&(n===void 0||n===`in`)){r={kind:`keywords`,x:t,y:`center`},o+=1;continue}if((t===`top`||t===`bottom`)&&(n===void 0||n===`in`)){r={kind:`keywords`,x:`center`,y:t},o+=1;continue}if((t===`left`||t===`center`||t===`right`)&&(n===`top`||n===`center`||n===`bottom`)){r={kind:`keywords`,x:t,y:n},o+=2;continue}if(a(t)&&a(n)){r={kind:`values`,x:this._parseLengthPercentage(t),y:this._parseLengthPercentage(n)},o+=2;continue}throw Error(`Invalid radial-gradient position: ${t??``} ${n??``}`)}if(s===`in`){let t=e[o+1],n=e[o+2],r=e[o+3];if(!t)throw Error(`Invalid radial-gradient interpolation: missing color space`);if(n!==void 0&&r===`hue`){i=this._normalizeConfigInterpolation({colorSpace:t,hue:n}),o+=3;continue}i=this._normalizeConfigInterpolation({colorSpace:t}),o+=1;continue}}}return{shape:t,size:n,position:r,interpolation:i}}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 _normalizeConfigInterpolation(e){let{colorSpace:t,hue:n}=e;return n===void 0||!Ci(t)?{colorSpace:t}:{colorSpace:t,hue:n}}},Di=class e extends Ei{type=`diamond-gradient`;constructor(e){super(e)}static fromString(t){return e.fromAbi(ci(t))}static fromAbi(t){if(t.functionName!==`diamond-gradient`)throw Error(`Invalid function name for DiamondGradient`);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())}},Oi=class e extends wi{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(ci(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=[];if(!this._isDefaultFrom(this.config.from)){let t=this.config.from;e.push(`from ${t.value}${t.unit}`)}return this._isDefaultPosition(this.config.position)||e.push(`at ${this._serializePosition(this.config.position)}`),this.config.interpolation!==void 0&&e.push(this._serializeInterpolation(this.config.interpolation)),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}`}_serializeInterpolation(e){let{colorSpace:t,hue:n}=e;return n===void 0?`in ${t}`:`in ${t} ${n} hue`}_isDefaultFrom(e){return e.value===0&&e.unit===`deg`}_isDefaultPosition(e){return e.kind===`keywords`&&e.x===`center`&&e.y===`center`}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=_i(e),r=e=>e===void 0?!1:e.endsWith(`%`)||/^-?\d*\.?\d+[a-zA-Z]+$/.test(e);for(let e=0;e<n.length;e++){let i=n[e];if(i===`from`){let r=n[e+1];if(r===void 0)throw Error(`Invalid conic-gradient config: missing angle after from`);t.from=this._parseAngle(r),e+=1;continue}if(i===`at`){let i=n[e+1],a=n[e+2];if(i===void 0)throw Error(`Invalid conic-gradient config: missing position after at`);if(i===`center`&&(a===void 0||a===`in`)){t.position={kind:`keywords`,x:`center`,y:`center`},e+=1;continue}if((i===`left`||i===`right`)&&(a===void 0||a===`in`)){t.position={kind:`keywords`,x:i,y:`center`},e+=1;continue}if((i===`top`||i===`bottom`)&&(a===void 0||a===`in`)){t.position={kind:`keywords`,x:`center`,y:i},e+=1;continue}if((i===`left`||i===`center`||i===`right`)&&(a===`top`||a===`center`||a===`bottom`)){t.position={kind:`keywords`,x:i,y:a},e+=2;continue}if(r(i)&&r(a)){t.position={kind:`values`,x:this._parseLengthPercentage(i),y:this._parseLengthPercentage(a)},e+=2;continue}throw Error(`Invalid conic-gradient position: ${i} ${a??``}`)}if(i===`in`){let r=n[e+1],i=n[e+2],a=n[e+3];if(r===void 0)throw Error(`Invalid conic-gradient interpolation: missing color space`);if(a===`hue`&&(i===`shorter`||i===`longer`||i===`increasing`||i===`decreasing`)){t.interpolation={colorSpace:r,hue:i},e+=3;continue}t.interpolation={colorSpace:r},e+=1;continue}}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]}}};let ki=/^[A-Za-z_][A-Za-z0-9_-]*$/,Ai=[`px`,`em`,`rem`,`vw`,`vh`,`vmin`,`vmax`,`cm`,`mm`,`in`,`pt`,`pc`];var ji=class e{type=`mesh-gradient`;_config;_vertices;_patches;constructor(t){let n=structuredClone(t.config);n.interpolation&&=e._normalizeInterpolation(n.interpolation),this._config=n,this._vertices=structuredClone(t.vertices),this._patches=structuredClone(t.patches),this._validate()}get config(){return structuredClone(this._config)}get vertices(){return structuredClone(this._vertices)}get patches(){return structuredClone(this._patches)}static fromString(t){let{functionName:n,isRepeating:r,inputs:i}=e._parseFunction(t);if(n!==`mesh-gradient`)throw Error(`Invalid function name for MeshGradient`);if(r)throw Error(`MeshGradient does not support repeating gradients`);let a=null,o=[],s=[],c=[];for(let e of i){let t=_i(e),n=t[0];if(n===`grid`){if(a!==null)throw Error(`mesh-gradient can only contain one grid config`);a=this._parseConfig(t);continue}if(n===`vertex`){o.push(this._parseVertex(t));continue}if(n===`patch`){s.push(this._parsePatch(t));continue}if(n===`handle`){c.push(this._parseHandle(t));continue}throw Error(`Unsupported mesh-gradient input: ${e}`)}if(!a)throw Error(`mesh-gradient requires a grid config`);let l=this._attachHandles(s,c);return new e({config:a,vertices:o,patches:l})}static fromAbi(t){if(t.functionName!==`mesh-gradient`)throw Error(`Invalid function name for MeshGradient`);if(t.isRepeating)throw Error(`MeshGradient does not support repeating gradients`);return e.fromString(`${t.functionName}(${t.inputs.map(e=>e.value).join(`, `)})`)}clone(){return new e(this.toJSON())}toJSON(){return{type:this.type,config:this.config,vertices:this.vertices,patches:this.patches}}toString(){let e=[this._serializeConfig(),...this._vertices.map(e=>this._serializeVertex(e)),...this._patches.map(e=>this._serializePatch(e)),...this._patches.flatMap(e=>this._serializeHandles(e))];return`${this.type}(${e.join(`, `)})`}getVertex(e){let t=this._vertices.find(t=>t.id===e);return t?structuredClone(t):null}_serializeConfig(){let e=[`grid`,String(this._config.rows),String(this._config.columns),`method`,this._config.method];return this._config.interpolation&&(e.push(`in`,this._config.interpolation.colorSpace),this._config.interpolation.hue&&e.push(this._config.interpolation.hue,`hue`)),e.join(` `)}_serializeVertex(e){return[`vertex`,e.id,this._formatLengthPercentage(e.x),this._formatLengthPercentage(e.y),e.color].join(` `)}_serializePatch(e){return[`patch`,e.id,e.topLeft,e.topRight,e.bottomRight,e.bottomLeft].join(` `)}_serializeHandles(e){if(!e.handles)return[];let t=[];for(let n of[`top`,`right`,`bottom`,`left`]){let r=e.handles[n];r&&t.push([`handle`,e.id,n,this._formatLengthPercentage(r.from.x),this._formatLengthPercentage(r.from.y),this._formatLengthPercentage(r.to.x),this._formatLengthPercentage(r.to.y)].join(` `))}return t}_formatLengthPercentage(e){return e.kind===`percent`?`${e.value}%`:`${e.value}${e.unit}`}_validate(){if(!Number.isInteger(this._config.rows)||this._config.rows<2)throw Error(`Mesh gradient rows must be an integer >= 2`);if(!Number.isInteger(this._config.columns)||this._config.columns<2)throw Error(`Mesh gradient columns must be an integer >= 2`);if(this._config.method!==`bilinear`&&this._config.method!==`bicubic`)throw Error(`Invalid mesh gradient interpolation method`);if(this._config.interpolation&&!Si(this._config.interpolation.colorSpace))throw Error(`Invalid mesh gradient color space: ${this._config.interpolation.colorSpace}`);let e=this._config.rows*this._config.columns,t=(this._config.rows-1)*(this._config.columns-1);if(this._vertices.length!==e)throw Error(`Mesh gradient expected ${e} vertices for ${this._config.rows}x${this._config.columns} grid, received ${this._vertices.length}`);if(this._patches.length!==t)throw Error(`Mesh gradient expected ${t} patches for ${this._config.rows}x${this._config.columns} grid, received ${this._patches.length}`);let n=new Set;for(let e of this._vertices){if(this._validateId(e.id,`vertex`),n.has(e.id))throw Error(`Duplicate mesh vertex id: ${e.id}`);if(n.add(e.id),this._validateLengthPercentage(e.x,`vertex ${e.id} x`),this._validateLengthPercentage(e.y,`vertex ${e.id} y`),!we(e.color))throw Error(`Invalid mesh vertex color: ${e.color}`)}let r=new Set;for(let e of this._patches){if(this._validateId(e.id,`patch`),r.has(e.id))throw Error(`Duplicate mesh patch id: ${e.id}`);r.add(e.id);let t=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft];if(new Set(t).size!==4)throw Error(`Mesh patch must use 4 unique vertices: ${e.id}`);for(let e of t)if(!n.has(e))throw Error(`Mesh patch references missing vertex: ${e}`);e.handles&&this._validateHandles(e)}if(this._patches.length===0)throw Error(`Mesh gradient requires at least one patch`)}_validateId(e,t){if(!ki.test(e))throw Error(`Invalid mesh ${t} id: ${e}`)}_validateHandles(e){if(e.handles)for(let t of[`top`,`right`,`bottom`,`left`]){let n=e.handles[t];n&&(this._validateLengthPercentage(n.from.x,`patch ${e.id} ${t} handle from x`),this._validateLengthPercentage(n.from.y,`patch ${e.id} ${t} handle from y`),this._validateLengthPercentage(n.to.x,`patch ${e.id} ${t} handle to x`),this._validateLengthPercentage(n.to.y,`patch ${e.id} ${t} handle to y`))}}_validateLengthPercentage(e,t){if(e.kind===`percent`){if(!Number.isFinite(e.value))throw Error(`Invalid mesh ${t}`);return}if(!Number.isFinite(e.value))throw Error(`Invalid mesh ${t}`)}static _parseConfig(e){if(e.length<3)throw Error(`Invalid mesh grid config`);let t=Number(e[1]),n=Number(e[2]),r=`bilinear`,i;for(let t=3;t<e.length;t+=1){let n=e[t];if(n===`method`){let n=e[t+1];if(n!==`bilinear`&&n!==`bicubic`)throw Error(`Invalid mesh gradient method: ${n}`);r=n,t+=1;continue}if(n===`in`){let n=e[t+1],r=e[t+2],a=e[t+3];if(!Si(n))throw Error(`Invalid mesh gradient color space: ${n}`);if(r!==void 0&&a===`hue`&&xi(r)){i=this._normalizeInterpolation({colorSpace:n,hue:r}),t+=3;continue}i={colorSpace:n},t+=1;continue}throw Error(`Unsupported mesh grid config token: ${n}`)}return{rows:t,columns:n,method:r,interpolation:i}}static _parseVertex(e){if(e.length<5)throw Error(`Invalid mesh vertex input`);return{id:e[1],x:this._parseLengthPercentage(e[2]),y:this._parseLengthPercentage(e[3]),color:e.slice(4).join(` `)}}static _parsePatch(e){if(e.length!==6)throw Error(`Invalid mesh patch input`);return{id:e[1],topLeft:e[2],topRight:e[3],bottomRight:e[4],bottomLeft:e[5]}}static _parseHandle(e){if(e.length!==7)throw Error(`Invalid mesh handle input`);let t=e[2];if(t!==`top`&&t!==`right`&&t!==`bottom`&&t!==`left`)throw Error(`Invalid mesh handle side: ${t}`);return{patchId:e[1],side:t,from:{x:this._parseLengthPercentage(e[3]),y:this._parseLengthPercentage(e[4])},to:{x:this._parseLengthPercentage(e[5]),y:this._parseLengthPercentage(e[6])}}}static _attachHandles(e,t){if(t.length===0)return e;let n=new Map(e.map(e=>[e.id,e])),r=e.map(e=>structuredClone(e)),i=new Map(r.map(e=>[e.id,e]));for(let e of t){if(!n.has(e.patchId))throw Error(`Mesh handle references missing patch: ${e.patchId}`);let t=i.get(e.patchId);if(t.handles??={},t.handles[e.side])throw Error(`Duplicate mesh handle for patch ${e.patchId} side ${e.side}`);t.handles[e.side]={from:e.from,to:e.to}}return r}static _parseLengthPercentage(e){if(e.endsWith(`%`)){let t=parseFloat(e);if(!Number.isFinite(t))throw Error(`Invalid mesh length-percentage: ${e}`);return{kind:`percent`,value:t}}let t=e.match(/^(-?\d*\.?\d+)([a-zA-Z]+)$/);if(!t)throw Error(`Invalid mesh length-percentage: ${e}`);let n=t[2];if(!Ai.includes(n))throw Error(`Unsupported mesh length unit: ${t[2]}`);return{kind:`length`,value:parseFloat(t[1]),unit:n}}static _normalizeInterpolation(e){let{colorSpace:t,hue:n}=e;return n===void 0||!Ci(t)?{colorSpace:t}:{colorSpace:t,hue:n}}static _parseFunction(e){let t=e.trim(),n=t.indexOf(`(`);if(n<=0)throw Error(`Expected mesh-gradient function call`);let r=t.slice(0,n).trim(),i=r.startsWith(`repeating-`);i&&(r=r.slice(10));let a=this._findOuterClosingParenIndex(t,n);if(a===-1)throw Error(`Unclosed mesh-gradient function parenthesis`);let o=t.slice(a+1).trim();if(o.length>0&&!o.startsWith(`${r}(`)&&!o.startsWith(`repeating-${r}(`))throw Error(`Unexpected mesh-gradient trailing input: ${o}`);let s=t.slice(n+1,a);return{functionName:r,isRepeating:i,inputs:this._splitTopLevelInputs(s)}}static _findOuterClosingParenIndex(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}static _splitTopLevelInputs(e){let t=[],n=``,r=0;for(let i=0;i<e.length;i+=1){let a=e[i];if(a===`(`){r+=1,n+=a;continue}if(a===`)`){if(--r,r<0)throw Error(`Unbalanced mesh-gradient input parentheses`);n+=a;continue}if(a===`,`&&r===0){this._pushTrimmed(t,n),n=``;continue}n+=a}if(this._pushTrimmed(t,n),r!==0)throw Error(`Unbalanced mesh-gradient input parentheses`);return t}static _pushTrimmed(e,t){let n=t.trim();n.length>0&&e.push(n)}},Mi=class{target=`css`;gradientType=`linear-gradient`;to(e){if(!(e instanceof Ti))throw Error(`Expected LinearGradient`);return e.toString()}},Ni=class{target=`css`;gradientType=`radial-gradient`;to(e){if(!(e instanceof Ei))throw Error(`Expected RadialGradient`);return e.toString()}};function Pi(e,t){return(e%t+t)%t}function Fi(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 K(J([r.value,i.value],`rgb`)(n))}}return r.value}function Ii(e,t,n,r){return Fi(e,n+Pi(t-n,r))}function Li(e,t,n){let r=e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position);if(r.length<2)return r;let i=r[0].position,a=r[r.length-1].position-i;if(a<=0)return r;let o=[],s=0;o.push({type:`color-stop`,value:Ii(r,t,i,a),position:t,_order:s}),s+=1;let c=Math.floor((t-i)/a)-1,l=Math.ceil((n-i)/a)+1;for(let e=c;e<=l;e+=1){let i=e*a;for(let e of r){let r=e.position+i;r<=t||r>=n||(o.push({...e,position:r,_order:s}),s+=1)}}return o.push({type:`color-stop`,value:Ii(r,n,i,a),position:n,_order:s}),o.sort((e,t)=>e.position===t.position?e._order-t._order:e.position-t.position).map(({_order:e,...t})=>t)}function Ri(e){return Li(e,0,1)}function zi(e,t,n,r){return Math.max(...[{x:0,y:0},{x:n,y:0},{x:0,y:r},{x:n,y:r}].map(n=>{let r=(n.x-e.x)/Math.max(t.x,1e-4),i=(n.y-e.y)/Math.max(t.y,1e-4);return Math.sqrt(r*r+i*i)}))}function Bi(e){switch(e){case`longer`:return ze;case`increasing`:return Be;case`decreasing`:return Ve;default:return R}}function Vi(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 Hi(e){if(e.hue!==void 0)return{h:{fixup:Bi(e.hue)}}}function Ui(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 Wi(e){let t=Gi(e);if(!t)throw Error(`Failed to convert interpolated color to rgb.`);return K(t)}let Gi=E(`rgb`);function Y(e,t=64){let n=Ui(e.stops),r=e.config.interpolation;if(n.length<2)return n;if(r===void 0)return e.isRepeating?Ri(n):n;let i=[],a=Vi(r.colorSpace),o=Hi(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=J([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:Wi(o),position:a})}}return e.isRepeating?Ri(i):i}let Ki=E(`rgb`);function qi(e){let t=Ki(e);if(!t)throw Error(`Failed to convert color: ${e}`);return[t.r??0,t.g??0,t.b??0,t.alpha??1]}function Ji(e,t){if(e.kind===`percent`)return e.value/100*t;if(e.unit===`px`)return e.value;throw Error(`Unsupported mesh-gradient length unit: ${e.unit}`)}function Yi(e,t,n){return{id:e.id,x:Ji(e.x,t),y:Ji(e.y,n),color:qi(e.color)}}function Xi(e,t,n){return new Map(e.vertices.map(e=>[e.id,Yi(e,t,n)]))}function Zi(e,t){let n=Qi(e,t);if(n)return n;let r=e.vertices.map(e=>{let n=t.get(e.id);if(!n)throw Error(`Missing mesh vertex: ${e.id}`);return n}).sort((e,t)=>Math.abs(e.y-t.y)>1e-4?e.y-t.y:e.x-t.x),i=[];for(let t=0;t<e.config.rows;t+=1){let n=t*e.config.columns,a=n+e.config.columns;i.push(r.slice(n,a))}return i}function Qi(e,t){let n=Array.from({length:e.config.rows},()=>[]);for(let r of e.vertices){let i=r.id.match(/^v(\d+)(\d+)$/);if(!i)return null;let a=Number(i[1]),o=Number(i[2]);if(!Number.isInteger(o)||!Number.isInteger(a)||o<0||a<0||o>=e.config.rows||a>=e.config.columns)return null;let s=t.get(r.id);if(!s)throw Error(`Missing mesh vertex: ${r.id}`);if(n[o][a])return null;n[o][a]=s}return n.some(t=>t.length!==e.config.columns||t.some(e=>e===void 0))?null:n}function $i(e,t){for(let n=0;n<e.length-1;n+=1)for(let r=0;r<e[n].length-1;r+=1)if(e[n][r].id===t.topLeft&&e[n][r+1].id===t.topRight&&e[n+1][r+1].id===t.bottomRight&&e[n+1][r].id===t.bottomLeft)return{row:n,column:r};throw Error(`Mesh patch does not match adjacent regular grid vertices: ${t.id}`)}function ea(e,t){return Math.min(t-1,Math.max(0,e))}function ta(e,t,n,r,i){let a=i*i,o=a*i;return .5*(2*t+(-e+n)*i+(2*e-5*t+4*n-r)*a+(-e+3*t-3*n+r)*o)}function na(e){return Math.min(1,Math.max(0,e))}function X(e,t,n){return e+(t-e)*n}function ra(e,t,n){return[X(e[0],t[0],n),X(e[1],t[1],n),X(e[2],t[2],n),X(e[3],t[3],n)]}function ia(e,t,n,r,i,a){return ra(ra(e.color,t.color,i),ra(r.color,n.color,i),a)}function aa(e,t,n,r,i){let a=e.length,o=e[0]?.length??0,s=[0,0,0,0];for(let c=0;c<4;c+=1){let l=[];for(let i=-1;i<=2;i+=1){let s=e[ea(t+i,a)],u=s[ea(n-1,o)].color[c],d=s[ea(n,o)].color[c],f=s[ea(n+1,o)].color[c],p=s[ea(n+2,o)].color[c];l.push(ta(u,d,f,p,r))}s[c]=na(ta(l[0],l[1],l[2],l[3],i))}return s}function Z(e,t,n,r,i,a){let o=X(e.x,t.x,i),s=X(e.y,t.y,i),c=X(r.x,n.x,i),l=X(r.y,n.y,i);return{x:X(o,c,a),y:X(s,l,a)}}function oa(e,t,n,r,i,a,o,s,c,l){return e.config.method===`bicubic`?aa(t,n,r,c,l):ia(i,a,o,s,c,l).map(na)}function sa(e,t,n,r,i){let a=r.get(n.topLeft),o=r.get(n.topRight),s=r.get(n.bottomRight),c=r.get(n.bottomLeft);if(!a||!o||!s||!c)throw Error(`Mesh patch references missing vertex: ${n.id}`);let l=$i(t,n),u=[];for(let r=0;r<=i;r+=1){let d=[],f=r/i;for(let u=0;u<=i;u+=1){let p=u/i,m=Z(a,o,s,c,p,f),h=oa(e,t,l.row,l.column,a,o,s,c,p,f);d.push({id:`${n.id}:${u}:${r}`,x:m.x,y:m.y,color:h})}u.push(d)}let d=[];for(let e=0;e<i;e+=1)for(let t=0;t<i;t+=1){let n=u[e][t],r=u[e][t+1],i=u[e+1][t+1],a=u[e+1][t];d.push([n,r,i],[n,i,a])}return d}function Q(e,t,n,r,i,a,o,s,c,l,u,d,f){return{id:f,x:u,y:d,color:oa(e,t,n,r,i,a,o,s,c,l)}}function ca(e,t,n,r,i){let a=[],o=t.length,s=t[0]?.length??0;if(o<2||s<2)return a;for(let n=0;n<s-1;n+=1){let r=t[0][n],o=t[0][n+1],s=t[1][n+1],c=t[1][n];for(let l=0;l<i;l+=1){let u=l/i,d=(l+1)/i,f=Z(r,o,s,c,u,0),p=Z(r,o,s,c,d,0),m=Z(r,o,s,c,u,1),h=Z(r,o,s,c,d,1),g=Math.min(0,(0-f.y)/Math.max(m.y-f.y,1e-4)),_=Math.min(0,(0-p.y)/Math.max(h.y-p.y,1e-4)),v=Q(e,t,0,n,r,o,s,c,u,0,f.x,f.y,`top:${n}:${l}:b0`),y=Q(e,t,0,n,r,o,s,c,d,0,p.x,p.y,`top:${n}:${l}:b1`),b=Q(e,t,0,n,r,o,s,c,u,g,f.x,0,`top:${n}:${l}:p0`),x=Q(e,t,0,n,r,o,s,c,d,_,p.x,0,`top:${n}:${l}:p1`);a.push([b,x,y],[b,y,v])}}for(let n=0;n<s-1;n+=1){let s=o-2,c=t[s][n],l=t[s][n+1],u=t[s+1][n+1],d=t[s+1][n];for(let o=0;o<i;o+=1){let f=o/i,p=(o+1)/i,m=Z(c,l,u,d,f,0),h=Z(c,l,u,d,p,0),g=Z(c,l,u,d,f,1),_=Z(c,l,u,d,p,1),v=Math.max(1,(r-m.y)/Math.max(g.y-m.y,1e-4)),y=Math.max(1,(r-h.y)/Math.max(_.y-h.y,1e-4)),b=Q(e,t,s,n,c,l,u,d,f,1,g.x,g.y,`bottom:${n}:${o}:b0`),x=Q(e,t,s,n,c,l,u,d,p,1,_.x,_.y,`bottom:${n}:${o}:b1`),S=Q(e,t,s,n,c,l,u,d,f,v,g.x,r,`bottom:${n}:${o}:p0`),C=Q(e,t,s,n,c,l,u,d,p,y,_.x,r,`bottom:${n}:${o}:p1`);a.push([b,x,C],[b,C,S])}}for(let n=0;n<o-1;n+=1){let r=t[n][0],o=t[n][1],s=t[n+1][1],c=t[n+1][0];for(let l=0;l<i;l+=1){let u=l/i,d=(l+1)/i,f=Z(r,o,s,c,0,u),p=Z(r,o,s,c,0,d),m=Z(r,o,s,c,1,u),h=Z(r,o,s,c,1,d),g=Math.min(0,(0-f.x)/Math.max(m.x-f.x,1e-4)),_=Math.min(0,(0-p.x)/Math.max(h.x-p.x,1e-4)),v=Q(e,t,n,0,r,o,s,c,0,u,f.x,f.y,`left:${n}:${l}:b0`),y=Q(e,t,n,0,r,o,s,c,0,d,p.x,p.y,`left:${n}:${l}:b1`),b=Q(e,t,n,0,r,o,s,c,g,u,0,f.y,`left:${n}:${l}:p0`),x=Q(e,t,n,0,r,o,s,c,_,d,0,p.y,`left:${n}:${l}:p1`);a.push([b,v,y],[b,y,x])}}for(let r=0;r<o-1;r+=1){let o=s-2,c=t[r][o],l=t[r][o+1],u=t[r+1][o+1],d=t[r+1][o];for(let s=0;s<i;s+=1){let f=s/i,p=(s+1)/i,m=Z(c,l,u,d,0,f),h=Z(c,l,u,d,0,p),g=Z(c,l,u,d,1,f),_=Z(c,l,u,d,1,p),v=Math.max(1,(n-m.x)/Math.max(g.x-m.x,1e-4)),y=Math.max(1,(n-h.x)/Math.max(_.x-h.x,1e-4)),b=Q(e,t,r,o,c,l,u,d,1,f,g.x,g.y,`right:${r}:${s}:b0`),x=Q(e,t,r,o,c,l,u,d,1,p,_.x,_.y,`right:${r}:${s}:b1`),S=Q(e,t,r,o,c,l,u,d,v,f,n,g.y,`right:${r}:${s}:p0`),C=Q(e,t,r,o,c,l,u,d,y,p,n,_.y,`right:${r}:${s}:p1`);a.push([b,S,C],[b,C,x])}}return a}function la(e){return e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position)}function ua(e,t){if(e.length===0)throw Error(`Cannot sample color from empty diamond gradient stops.`);if(e.length===1||t<=e[0].position)return e[0].value;let n=e[e.length-1];if(t>=n.position)return n.value;for(let n=0;n<e.length-1;n+=1){let r=e[n],i=e[n+1];if(t>=r.position&&t<=i.position){let e=i.position-r.position||1,n=(t-r.position)/e;return K(J([r.value,i.value],`rgb`)(n))}}return n.value}function da(e){return e.kind===`keywords`?{x:fa(e.x),y:pa(e.y)}:{x:ma(e.x,100),y:ma(e.y,100)}}function fa(e){return e===`left`?0:e===`right`?100:50}function pa(e){return e===`top`?0:e===`bottom`?100:50}function ma(e,t){if(e.kind===`percent`)return e.value/100*t;if(e.unit===`px`)return e.value;throw Error(`Unsupported diamond-gradient length unit for CSS transformer: ${e.unit}`)}function ha(e,t){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}function ga(e){return[{dx:-e.x,dy:-e.y},{dx:100-e.x,dy:-e.y},{dx:-e.x,dy:100-e.y},{dx:100-e.x,dy:100-e.y}]}function _a(e,t,n,r){let i=Math.max(e,1e-4),a=Math.max(t,1e-4),o=Math.abs(n)/i+Math.abs(r)/a;return{x:i*o,y:a*o}}function va(e,t){return Math.max(...[{x:0,y:0},{x:100,y:0},{x:0,y:100},{x:100,y:100}].map(n=>Math.abs(n.x-e.x)/Math.max(t.x,1e-4)+Math.abs(n.y-e.y)/Math.max(t.y,1e-4)))}function ya(e,t,n){if(e.kind===`explicit`){let n=ma(e.x,100),r=e.y?ma(e.y,100):n;return{x:Math.max(n,1e-4),y:Math.max(t===`circle`?n:r,1e-4)}}let r=n.x,i=100-n.x,a=n.y,o=100-n.y;if(t===`circle`){let t=[{x:0,y:0},{x:100,y:0},{x:0,y:100},{x:100,y:100}].map(e=>ha(n,e));if(e.value===`closest-side`){let e=Math.max(Math.min(r,i,a,o),1e-4);return{x:e,y:e}}if(e.value===`farthest-side`){let e=Math.max(Math.max(r,i,a,o),1e-4);return{x:e,y:e}}if(e.value===`closest-corner`){let e=Math.max(Math.min(...t),1e-4);return{x:e,y:e}}let s=Math.max(Math.max(...t),1e-4);return{x:s,y:s}}let s=Math.min(r,i),c=Math.min(a,o),l=Math.max(r,i),u=Math.max(a,o);if(e.value===`closest-side`)return{x:Math.max(s,1e-4),y:Math.max(c,1e-4)};if(e.value===`farthest-side`)return{x:Math.max(l,1e-4),y:Math.max(u,1e-4)};let d=ga(n);return e.value===`closest-corner`?d.map(e=>_a(s,c,e.dx,e.dy)).reduce((e,t)=>t.x*t.y<e.x*e.y?t:e):d.map(e=>_a(l,u,e.dx,e.dy)).reduce((e,t)=>t.x*t.y>e.x*e.y?t:e)}function $(e){return Number(e.toFixed(3)).toString()}function ba(e,t,n){let r=t.x*n,i=t.y*n;return[`${$(e.x)} ${$(e.y-i)}`,`${$(e.x+r)} ${$(e.y)}`,`${$(e.x)} ${$(e.y+i)}`,`${$(e.x-r)} ${$(e.y)}`].join(` `)}function xa(e){return`url("data:image/svg+xml,${encodeURIComponent(e)}")`}var Sa=class{target=`css`;gradientType=`diamond-gradient`;to(e){if(!(e instanceof Di))throw Error(`Expected DiamondGradient`);let t=da(e.config.position),n=ya(e.config.size,e.config.shape,t),r=va(t,n),i=e.isRepeating?r:1,a=Y(e,96),o=la(e.isRepeating?Li(a,0,r):a),s=ua(o,i),c=[],l=Math.max(96,Math.ceil(96*i));for(let e=l;e>=0;--e){let r=e/l*i,a=ua(o,r),s=ba(t,n,r);c.push(`<polygon points="${s}" fill="${a}"/>`)}return xa([`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none">`,`<rect width="100" height="100" fill="${s}"/>`,...c,`</svg>`].join(``))}},Ca=class{target=`css`;gradientType=`conic-gradient`;to(e){if(!(e instanceof Oi))throw Error(`Expected ConicGradient`);return e.toString()}};function wa(e){return`rgba(${e[0]},${e[1]},${e[2]},${Number(e[3].toFixed(3))})`}function Ta(e,t,n,r,i){let a=(r.y-i.y)*(n.x-i.x)+(i.x-r.x)*(n.y-i.y);if(Math.abs(a)<1e-6)return null;let o=((r.y-i.y)*(e-i.x)+(i.x-r.x)*(t-i.y))/a,s=((i.y-n.y)*(e-i.x)+(n.x-i.x)*(t-i.y))/a,c=1-o-s;return o<-1e-4||s<-1e-4||c<-1e-4?null:[o,s,c]}function Ea(e,t,n,r){let[i,a,o]=e;return[Math.round((t.color[0]*i+n.color[0]*a+r.color[0]*o)*255),Math.round((t.color[1]*i+n.color[1]*a+r.color[1]*o)*255),Math.round((t.color[2]*i+n.color[2]*a+r.color[2]*o)*255),t.color[3]*i+n.color[3]*a+r.color[3]*o]}function Da(e){return`url("data:image/svg+xml,${encodeURIComponent(e)}")`}var Oa=class{target=`css`;gradientType=`mesh-gradient`;to(e){if(!(e instanceof ji))throw Error(`Expected MeshGradient`);let t=Xi(e,96,96),n=Zi(e,t),r=e.config.method===`bicubic`?24:1,i=e.patches.flatMap(i=>sa(e,n,i,t,r)),a=ca(e,n,96,96,r),o=[...i,...a],s=[];for(let e=0;e<96;e+=1)for(let t=0;t<96;t+=1){let n=t+.5,r=e+.5,i=null;for(let[e,t,a]of o){let o=Ta(n,r,e,t,a);if(o){i=Ea(o,e,t,a);break}}i&&s.push(`<rect x="${t}" y="${e}" width="1" height="1" fill="${wa(i)}"/>`)}return Da([`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" preserveAspectRatio="none" shape-rendering="crispEdges">`,...s,`</svg>`].join(``))}};let ka=E(`rgb`);function Aa(e){let t=ka(e);if(!t)throw Error(`Failed to convert color: ${e}`);return K(t)}function ja(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 Ma(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 Na=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}=ja(Y(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,_=Ma(g,m,h)}let v=e.createLinearGradient(u,d,f,p);for(let e of _)v.addColorStop(e.position,Aa(e.value));e.clearRect(0,0,n,r),e.fillStyle=v,e.fillRect(0,0,n,r)}}}};let Pa=E(`rgb`);function Fa(e){let t=Pa(e);if(!t)throw Error(`Failed to convert color: ${e}`);return K(t)}function Ia(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 La(e,t,n){let r=n-t||1;return e.map(e=>({...e,position:(e.position-t)/r}))}function Ra(e,t,n,r){return r===`left`?e.x:r===`right`?t-e.x:r===`top`?e.y:n-e.y}function za(e,t){let n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)}function Ba(e,t,n){return[{dx:-e.x,dy:-e.y},{dx:t-e.x,dy:-e.y},{dx:-e.x,dy:n-e.y},{dx:t-e.x,dy:n-e.y}]}function Va(e,t,n,r){let i=Math.max(e,1e-4),a=Math.max(t,1e-4),o=Math.sqrt(n*n/(i*i)+r*r/(a*a));return{x:i*o,y:a*o}}var Ha=class{target=`canvas-2d`;gradientType=`radial-gradient`;to(e){let t=e;return{draw:(e,n,r)=>{let i=this._resolveCenter(t.config.position,n,r),a=this._resolveRadialRadii(t.config.size,t.config.shape,i,n,r),o=zi(i,a,n,r),s=Y(t,128),{min:c,max:l,stops:u}=Ia(t.isRepeating?Li(s,0,o):s),d=u,f=0,p=t.isRepeating?o:1;if(t.isRepeating?d=La(u,0,o):(c<0||l>1)&&(d=La(u,c,l),f=c,p=l),t.config.shape===`circle`){let t=a.x,o=Math.max(0,t*f),s=Math.max(o+1e-4,t*p),c=e.createRadialGradient(i.x,i.y,o,i.x,i.y,s);for(let e of d)c.addColorStop(e.position,Fa(e.value));e.fillStyle=c,e.fillRect(0,0,n,r);return}let m=Math.max(a.x,a.y),h=a.x/m,g=a.y/m,_=Math.max(0,m*f),v=Math.max(_+1e-4,m*p);e.save(),e.translate(i.x,i.y),e.scale(h,g);let y=e.createRadialGradient(0,0,_,0,0,v);for(let e of d)y.addColorStop(e.position,Fa(e.value));e.fillStyle=y;let b=v+2;e.fillRect(-b/h*2,-b/g*2,b/h*4,b/g*4),e.restore()}}}_resolveCenter(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)}}_resolveKeywordX(e,t){return e===`left`?0:e===`center`?t/2:t}_resolveKeywordY(e,t){return e===`top`?0:e===`center`?t/2:t}_resolveRadialRadii(e,t,n,r,i){if(e.kind===`explicit`){let n=this._resolve(e.x,r),a=e.y?this._resolve(e.y,i):n;return{x:Math.max(n,1e-4),y:Math.max(t===`circle`?n:a,1e-4)}}let a=Ra(n,r,i,`left`),o=Ra(n,r,i,`right`),s=Ra(n,r,i,`top`),c=Ra(n,r,i,`bottom`);if(t===`circle`){let t=[{x:0,y:0},{x:r,y:0},{x:0,y:i},{x:r,y:i}].map(e=>za(n,e));if(e.value===`closest-side`){let e=Math.min(a,o,s,c);return{x:e,y:e}}if(e.value===`farthest-side`){let e=Math.max(a,o,s,c);return{x:e,y:e}}if(e.value===`closest-corner`){let e=Math.min(...t);return{x:e,y:e}}let l=Math.max(...t);return{x:l,y:l}}let l=Math.min(a,o),u=Math.min(s,c),d=Math.max(a,o),f=Math.max(s,c);if(e.value===`closest-side`)return{x:Math.max(l,1e-4),y:Math.max(u,1e-4)};if(e.value===`farthest-side`)return{x:Math.max(d,1e-4),y:Math.max(f,1e-4)};let p=Ba(n,r,i);return e.value===`closest-corner`?p.map(e=>Va(l,u,e.dx,e.dy)).reduce((e,t)=>{let n=e.x*e.y;return t.x*t.y<n?t:e}):p.map(e=>Va(d,f,e.dx,e.dy)).reduce((e,t)=>{let n=e.x*e.y;return t.x*t.y>n?t:e})}_resolve(e,t){return e.kind===`percent`?e.value/100*t:(e.unit,e.value)}};let Ua=E(`rgb`),Wa=1024;function Ga(e){let t=Ua(e);if(!t)throw Error(`Failed to convert color: ${e}`);return[Math.round((t.r??0)*255),Math.round((t.g??0)*255),Math.round((t.b??0)*255),Math.round((t.alpha??1)*255)]}function Ka(e){return e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position)}function qa(e,t){if(e.length===0)throw Error(`Cannot sample color from empty diamond gradient stops.`);if(e.length===1||t<=e[0].position)return Ga(e[0].value);let n=e[e.length-1];if(t>=n.position)return Ga(n.value);for(let n=0;n<e.length-1;n+=1){let r=e[n],i=e[n+1];if(t>=r.position&&t<=i.position){let e=i.position-r.position||1,n=(t-r.position)/e,a=Ga(r.value),o=Ga(i.value);return[Math.round(a[0]+(o[0]-a[0])*n),Math.round(a[1]+(o[1]-a[1])*n),Math.round(a[2]+(o[2]-a[2])*n),Math.round(a[3]+(o[3]-a[3])*n)]}}return Ga(n.value)}function Ja(e,t){let n=new Uint8ClampedArray(Wa*4);for(let r=0;r<Wa;r+=1){let i=qa(e,r/(Wa-1)*t),a=r*4;n[a]=i[0],n[a+1]=i[1],n[a+2]=i[2],n[a+3]=i[3]}return n}function Ya(e,t,n,r){return Math.max(...[{x:0,y:0},{x:n,y:0},{x:0,y:r},{x:n,y:r}].map(n=>Math.abs(n.x-e.x)/Math.max(t.x,1e-4)+Math.abs(n.y-e.y)/Math.max(t.y,1e-4)))}function Xa(e,t){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}function Za(e,t,n){return[{dx:-e.x,dy:-e.y},{dx:t-e.x,dy:-e.y},{dx:-e.x,dy:n-e.y},{dx:t-e.x,dy:n-e.y}]}function Qa(e,t,n,r){let i=Math.max(e,1e-4),a=Math.max(t,1e-4),o=Math.abs(n)/i+Math.abs(r)/a;return{x:i*o,y:a*o}}var $a=class{target=`canvas-2d`;gradientType=`diamond-gradient`;to(e){if(!(e instanceof Di))throw Error(`Expected DiamondGradient`);let t=e;return{draw:(e,n,r)=>{let i=this._resolveCenter(t.config.position,n,r),a=this._resolveDiamondRadii(t.config.size,t.config.shape,i,n,r),o=Ya(i,a,n,r),s=Y(t,128),c=Ja(Ka(t.isRepeating?Li(s,0,o):s),o),l=e.createImageData(n,r),u=l.data;for(let e=0;e<r;e+=1)for(let t=0;t<n;t+=1){let r=Math.abs(t-i.x)/Math.max(a.x,1e-4)+Math.abs(e-i.y)/Math.max(a.y,1e-4),s=Math.min(Wa-1,Math.max(0,Math.round(r/Math.max(o,1e-4)*(Wa-1))))*4,l=(e*n+t)*4;u[l]=c[s],u[l+1]=c[s+1],u[l+2]=c[s+2],u[l+3]=c[s+3]}e.putImageData(l,0,0)}}}_resolveCenter(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)}}_resolveKeywordX(e,t){return e===`left`?0:e===`center`?t/2:t}_resolveKeywordY(e,t){return e===`top`?0:e===`center`?t/2:t}_resolveDiamondRadii(e,t,n,r,i){if(e.kind===`explicit`){let n=this._resolve(e.x,r),a=e.y?this._resolve(e.y,i):n;return{x:Math.max(n,1e-4),y:Math.max(t===`circle`?n:a,1e-4)}}let a=n.x,o=r-n.x,s=n.y,c=i-n.y;if(t===`circle`){let t=[{x:0,y:0},{x:r,y:0},{x:0,y:i},{x:r,y:i}].map(e=>Xa(n,e));if(e.value===`closest-side`){let e=Math.max(Math.min(a,o,s,c),1e-4);return{x:e,y:e}}if(e.value===`farthest-side`){let e=Math.max(Math.max(a,o,s,c),1e-4);return{x:e,y:e}}if(e.value===`closest-corner`){let e=Math.max(Math.min(...t),1e-4);return{x:e,y:e}}let l=Math.max(Math.max(...t),1e-4);return{x:l,y:l}}let l=Math.min(a,o),u=Math.min(s,c),d=Math.max(a,o),f=Math.max(s,c);if(e.value===`closest-side`)return{x:Math.max(l,1e-4),y:Math.max(u,1e-4)};if(e.value===`farthest-side`)return{x:Math.max(d,1e-4),y:Math.max(f,1e-4)};let p=Za(n,r,i);return e.value===`closest-corner`?p.map(e=>Qa(l,u,e.dx,e.dy)).reduce((e,t)=>t.x*t.y<e.x*e.y?t:e):p.map(e=>Qa(d,f,e.dx,e.dy)).reduce((e,t)=>t.x*t.y>e.x*e.y?t:e)}_resolve(e,t){if(e.kind===`percent`)return e.value/100*t;if(e.unit===`px`)return e.value;throw Error(`Unsupported diamond-gradient length unit for Canvas transformer: ${e.unit}`)}};let eo=E(`rgb`);var to=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=Y(t,128),u=this._normalizeStops(l);if(u.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,l=Math.atan2(i,r)+Math.PI/2-c;for(;l<0;)l+=Math.PI*2;for(;l>=Math.PI*2;)l-=Math.PI*2;let d=l/(Math.PI*2),f=this._sampleColor(u,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=eo(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))}};function no(e,t,n,r,i){let a=(r.y-i.y)*(n.x-i.x)+(i.x-r.x)*(n.y-i.y);if(Math.abs(a)<1e-6)return null;let o=((r.y-i.y)*(e-i.x)+(i.x-r.x)*(t-i.y))/a,s=((i.y-n.y)*(e-i.x)+(n.x-i.x)*(t-i.y))/a,c=1-o-s,l=-1e-4;return o<l||s<l||c<l?null:[o,s,c]}function ro(e,t,n,r){let[i,a,o]=e;return[Math.round((t.color[0]*i+n.color[0]*a+r.color[0]*o)*255),Math.round((t.color[1]*i+n.color[1]*a+r.color[1]*o)*255),Math.round((t.color[2]*i+n.color[2]*a+r.color[2]*o)*255),Math.round((t.color[3]*i+n.color[3]*a+r.color[3]*o)*255)]}function io(e,t,n,r,i,a){let o=Math.max(0,Math.floor(Math.min(r.x,i.x,a.x))),s=Math.min(t-1,Math.ceil(Math.max(r.x,i.x,a.x))),c=Math.max(0,Math.floor(Math.min(r.y,i.y,a.y))),l=Math.min(n-1,Math.ceil(Math.max(r.y,i.y,a.y)));for(let n=c;n<=l;n+=1)for(let c=o;c<=s;c+=1){let o=no(c+.5,n+.5,r,i,a);if(!o)continue;let s=ro(o,r,i,a),l=(n*t+c)*4;e[l]=s[0],e[l+1]=s[1],e[l+2]=s[2],e[l+3]=s[3]}}var ao=class{target=`canvas-2d`;gradientType=`mesh-gradient`;to(e){if(!(e instanceof ji))throw Error(`Expected MeshGradient`);let t=e;return{draw:(e,n,r)=>{let i=e.createImageData(n,r),a=Xi(t,n,r),o=Zi(t,a),s=t.config.method===`bicubic`?24:1,c=ca(t,o,n,r,s);for(let e of t.patches){let c=sa(t,o,e,a,s);for(let[e,t,a]of c)io(i.data,n,r,e,t,a)}for(let[e,t,a]of c)io(i.data,n,r,e,t,a);e.putImageData(i,0,0)}}}};let oo=E(`rgb`);function so(e){let t=oo(e);if(!t)throw Error(`Failed to convert color: ${e}`);return[t.r??0,t.g??0,t.b??0,t.alpha??1]}function co(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 lo(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 uo(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 fo(e,t,n){let r=uo(e,e.VERTEX_SHADER,t),i=uo(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 po(e){return e.filter(e=>e.type===`color-stop`).length}function mo(e,t){let n=po(e.stops),r=Math.max(1,n-1);return Math.max(2,Math.floor((t-1)/r))}function ho(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 K(J([r.value,i.value],`rgb`)(n))}}return r.value}function go(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:ho(n,i),position:i})}return r}var _o=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=fo(i,`
|
|
4
|
+
`||t[j]===` `||t[j]===` `);)j++;let e;if(pe(t)&&(e=ge(t),e.type!==A.Hue)){n.push({type:A.Alpha,value:e});continue}if(me(t)&&ve(t)===`none`){n.push({type:A.Alpha,value:{type:A.None,value:void 0}});continue}return}if(/\d/.test(r)){j--,n.push(ge(t));continue}if(de.test(r)){j--,n.push(ye(t));continue}return}return n}function xe(e){e._i=0;let t=e[e._i++];if(!t||t.type!==A.Function||t.value!==`color`||(t=e[e._i++],t.type!==A.Ident))return;let n=se[t.value];if(!n)return;let r={mode:n},i=Se(e,!1);if(!i)return;let a=le(n).channels;for(let e=0,t,n;e<a.length;e++)t=i[e],n=a[e],t.type!==A.None&&(r[n]=t.type===A.Number?t.value:t.value/100,n===`alpha`&&(r[n]=Math.max(0,Math.min(1,r[n]))));return r}function Se(e,t){let n=[],r;for(;e._i<e.length;){if(r=e[e._i++],r.type===A.None||r.type===A.Number||r.type===A.Alpha||r.type===A.Percentage||t&&r.type===A.Hue){n.push(r);continue}if(r.type===A.ParenClose){if(e._i<e.length)return;continue}return}if(!(n.length<3||n.length>4)){if(n.length===4){if(n[3].type!==A.Alpha)return;n[3]=n[3].value}return n.length===3&&n.push({type:A.None,value:void 0}),n.every(e=>e.type!==A.Alpha)?n:void 0}}function Ce(e,t){e._i=0;let n=e[e._i++];if(!n||n.type!==A.Function)return;let r=Se(e,t);if(r)return r.unshift(n.value),r}let we=e=>{if(typeof e!=`string`)return;let t=be(e),n=t?Ce(t,!0):void 0,r,i=0,a=O.length;for(;i<a;)if((r=O[i++](e,n))!==void 0)return r;return t?xe(t):void 0};function Te(e,t){if(!t||t[0]!==`rgb`&&t[0]!==`rgba`)return;let n={mode:`rgb`},[,r,i,a,o]=t;if(!(r.type===A.Hue||i.type===A.Hue||a.type===A.Hue))return r.type!==A.None&&(n.r=r.type===A.Number?r.value/255:r.value/100),i.type!==A.None&&(n.g=i.type===A.Number?i.value/255:i.value/100),a.type!==A.None&&(n.b=a.type===A.Number?a.value/255:a.value/100),o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}let Ee=e=>e===`transparent`?{mode:`rgb`,r:0,g:0,b:0,alpha:0}:void 0,De=(e,t,n)=>e+n*(t-e),Oe=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},M=(e=>t=>{let n=Oe(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)}})(De),N=e=>{let t=!1,n=e.map(e=>e===void 0?1:(t=!0,e));return t?n:e},ke={mode:`rgb`,channels:[`r`,`g`,`b`,`alpha`],parse:[Te,x,ie,y,Ee,`srgb`],serialize:`srgb`,interpolate:{r:M,g:M,b:M,alpha:{use:M,fixup:N}},gamut:!0,white:{r:1,g:1,b:1},black:{r:0,g:0,b:0}},Ae=(e=0)=>Math.abs(e)**(563/256)*Math.sign(e),je=e=>{let t=Ae(e.r),n=Ae(e.g),r=Ae(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},Me=e=>Math.abs(e)**(256/563)*Math.sign(e),Ne=({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:Me(e*2.0415879038107465-t*.5650069742788597-.3447313507783297*n),g:Me(e*-.9692436362808798+t*1.8759675015077206+.0415550574071756*n),b:Me(e*.0134442806320312-t*.1183623922310184+1.0151749943912058*n)};return r!==void 0&&(i.alpha=r),i},Pe=(e=0)=>{let t=Math.abs(e);return t<=.04045?e/12.92:(Math.sign(e)||1)*((t+.055)/1.055)**2.4},Fe=({r:e,g:t,b:n,alpha:r})=>{let i={mode:`lrgb`,r:Pe(e),g:Pe(t),b:Pe(n)};return r!==void 0&&(i.alpha=r),i},P=e=>{let{r:t,g:n,b:r,alpha:i}=Fe(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},Ie=(e=0)=>{let t=Math.abs(e);return t>.0031308?(Math.sign(e)||1)*(1.055*t**(1/2.4)-.055):e*12.92},Le=({r:e,g:t,b:n,alpha:r},i=`rgb`)=>{let a={mode:i,r:Ie(e),g:Ie(t),b:Ie(n)};return r!==void 0&&(a.alpha=r),a},Re=({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=Le({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},ze={...ke,mode:`a98`,parse:[`a98-rgb`],serialize:`a98-rgb`,fromMode:{rgb:e=>Ne(P(e)),xyz65:Ne},toMode:{rgb:e=>Re(je(e)),xyz65:je}},F=e=>(e%=360)<0?e+360:e,Be=(e,t)=>e.map((n,r,i)=>{if(n===void 0)return n;let a=F(n);return r===0||e[r-1]===void 0?a:t(a-F(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),[]),I=e=>Be(e,e=>Math.abs(e)<=180?e:e-360*Math.sign(e)),Ve=e=>Be(e,e=>Math.abs(e)>=180||e===0?e:e-360*Math.sign(e)),He=e=>Be(e,e=>e>=0?e:e+360),Ue=e=>Be(e,e=>e<=0?e:e-360),L=[-.14861,1.78277,-.29227,-.90649,1.97294,0],We=Math.PI/180,Ge=180/Math.PI,Ke=L[3]*L[4],qe=L[1]*L[4],Je=L[1]*L[2]-L[0]*L[3],Ye=({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=(Je*n+e*Ke-t*qe)/(Je+Ke-qe),a=n-i,o=(L[4]*(t-i)-L[2]*a)/L[3],s={mode:`cubehelix`,l:i,s:i===0||i===1?void 0:Math.sqrt(a*a+o*o)/(L[4]*i*(1-i))};return s.s&&(s.h=Math.atan2(o,a)*Ge-120),r!==void 0&&(s.alpha=r),s},Xe=({h:e,s:t,l:n,alpha:r})=>{let i={mode:`rgb`};e=(e===void 0?0:e+120)*We,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*(L[0]*o+L[1]*s),i.g=n+a*(L[2]*o+L[3]*s),i.b=n+a*(L[4]*o+L[5]*s),r!==void 0&&(i.alpha=r),i},Ze=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.s||!t.s)return 0;let n=F(e.h),r=F(t.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.s*t.s)*i},Qe=(e,t)=>{if(e.h===void 0||t.h===void 0)return 0;let n=F(e.h),r=F(t.h);return Math.abs(r-n)>180?n-(r-360*Math.sign(r-n)):r-n},$e=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.c||!t.c)return 0;let n=F(e.h),r=F(t.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.c*t.c)*i},R=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},et={mode:`cubehelix`,channels:[`h`,`s`,`l`,`alpha`],parse:[`--cubehelix`],serialize:`--cubehelix`,ranges:{h:[0,360],s:[0,4.614],l:[0,1]},fromMode:{rgb:Ye},toMode:{rgb:Xe},interpolate:{h:{use:M,fixup:I},s:M,l:M,alpha:{use:M,fixup:N}},difference:{h:Ze},average:{h:R}},z=({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=F(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(o.alpha=r),o},B=({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},tt=29**3/3**3,nt=6**3/29**3,V={X:.3457/.3585,Y:1,Z:.2958/.3585},rt={X:.3127/.329,Y:1,Z:.3583/.329},it=e=>e**3>nt?e**3:(116*e-16)/tt,at=({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:it(a)*rt.X,y:it(i)*rt.Y,z:it(o)*rt.Z};return r!==void 0&&(s.alpha=r),s},ot=e=>Re(at(e)),st=e=>e>nt?Math.cbrt(e):(tt*e+16)/116,ct=({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=st(e/rt.X),a=st(t/rt.Y),o=st(n/rt.Z),s={mode:`lab65`,l:116*a-16,a:500*(i-a),b:200*(a-o)};return r!==void 0&&(s.alpha=r),s},lt=e=>{let t=ct(P(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},ut=26/180*Math.PI,dt=Math.cos(ut),ft=Math.sin(ut),pt=100/Math.log(139/100),mt=({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/pt)-1)/.0039},a=(Math.exp(.0435*t*1*1)-1)/.075,o=a*Math.cos(n/180*Math.PI-ut),s=a*Math.sin(n/180*Math.PI-ut);return i.a=o*dt-s/.83*ft,i.b=o*ft+s/.83*dt,r!==void 0&&(i.alpha=r),i},ht=({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*dt+n*ft,a=.83*(n*dt-t*ft),o=Math.sqrt(i*i+a*a),s={mode:`dlch`,l:pt/1*Math.log(1+.0039*e),c:Math.log(1+.075*o)/(.0435*1*1)};return s.c&&(s.h=F((Math.atan2(a,i)+ut)/Math.PI*180)),r!==void 0&&(s.alpha=r),s},gt=e=>mt(z(e,`dlch`)),_t=e=>B(ht(e),`dlab`),vt={mode:`dlab`,parse:[`--din99o-lab`],serialize:`--din99o-lab`,toMode:{lab65:gt,rgb:e=>ot(gt(e))},fromMode:{lab65:_t,rgb:e=>_t(lt(e))},channels:[`l`,`a`,`b`,`alpha`],ranges:{l:[0,100],a:[-40.09,45.501],b:[-40.469,44.344]},interpolate:{l:M,a:M,b:M,alpha:{use:M,fixup:N}}},yt={mode:`dlch`,parse:[`--din99o-lch`],serialize:`--din99o-lch`,toMode:{lab65:mt,dlab:e=>B(e,`dlab`),rgb:e=>ot(mt(e))},fromMode:{lab65:ht,dlab:e=>z(e,`dlch`),rgb:e=>ht(lt(e))},channels:[`l`,`c`,`h`,`alpha`],ranges:{l:[0,100],c:[0,51.484],h:[0,360]},interpolate:{l:M,c:M,h:{use:M,fixup:I},alpha:{use:M,fixup:N}},difference:{h:$e},average:{h:R}};function bt({h:e,s:t,i:n,alpha:r}){e=F(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 xt({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 St={mode:`hsi`,toMode:{rgb:bt},parse:[`--hsi`],serialize:`--hsi`,fromMode:{rgb:xt},channels:[`h`,`s`,`i`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,interpolate:{h:{use:M,fixup:I},s:M,i:M,alpha:{use:M,fixup:N}},difference:{h:Ze},average:{h:R}};function Ct({h:e,s:t,l:n,alpha:r}){e=F(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 wt({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 Tt=(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}},Et=RegExp(`^hsla?\\(\\s*${ne}${w}${C}${w}${C}\\s*(?:,\\s*${ee}\\s*)?\\)$`),Dt=e=>{let t=e.match(Et);if(!t)return;let n={mode:`hsl`};return t[3]===void 0?t[1]!==void 0&&t[2]!==void 0&&(n.h=Tt(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 Ot(e,t){if(!t||t[0]!==`hsl`&&t[0]!==`hsla`)return;let n={mode:`hsl`},[,r,i,a,o]=t;if(r.type!==A.None){if(r.type===A.Percentage)return;n.h=r.value}if(i.type!==A.None){if(i.type===A.Hue)return;n.s=i.value/100}if(a.type!==A.None){if(a.type===A.Hue)return;n.l=a.value/100}return o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}let kt={mode:`hsl`,toMode:{rgb:Ct},fromMode:{rgb:wt},channels:[`h`,`s`,`l`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,parse:[Ot,Dt],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:M,fixup:I},s:M,l:M,alpha:{use:M,fixup:N}},difference:{h:Ze},average:{h:R}};function At({h:e,s:t,v:n,alpha:r}){e=F(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 jt({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 Mt={mode:`hsv`,toMode:{rgb:At},parse:[`--hsv`],serialize:`--hsv`,fromMode:{rgb:jt},channels:[`h`,`s`,`v`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,interpolate:{h:{use:M,fixup:I},s:M,v:M,alpha:{use:M,fixup:N}},difference:{h:Ze},average:{h:R}};function Nt({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 At({h:e,s:n===1?1:1-t/(1-n),v:1-n,alpha:r})}function Pt(e){let t=jt(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 Ft(e,t){if(!t||t[0]!==`hwb`)return;let n={mode:`hwb`},[,r,i,a,o]=t;if(r.type!==A.None){if(r.type===A.Percentage)return;n.h=r.value}if(i.type!==A.None){if(i.type===A.Hue)return;n.w=i.value/100}if(a.type!==A.None){if(a.type===A.Hue)return;n.b=a.value/100}return o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}let It={mode:`hwb`,toMode:{rgb:Nt},fromMode:{rgb:Pt},channels:[`h`,`w`,`b`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,parse:[Ft],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:M,fixup:I},w:M,b:M,alpha:{use:M,fixup:N}},difference:{h:Qe},average:{h:R}},Lt=.1593017578125,Rt=78.84375,zt=.8359375,Bt=18.8515625,Vt=18.6875;function Ht(e){if(e<0)return 0;let t=e**(1/Rt);return 1e4*(Math.max(0,t-zt)/(Bt-Vt*t))**(1/Lt)}function Ut(e){if(e<0)return 0;let t=(e/1e4)**Lt;return((zt+Bt*t)/(1+Vt*t))**+Rt}let Wt=e=>Math.max(e/203,0),Gt=({i:e,t,p:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Ht(e+.008609037037932761*t+.11102962500302593*n),a=Ht(e-.00860903703793275*t-.11102962500302599*n),o=Ht(e+.5600313357106791*t-.32062717498731885*n),s={mode:`xyz65`,x:Wt(2.070152218389422*i-1.3263473389671556*a+.2066510476294051*o),y:Wt(.3647385209748074*i+.680566024947227*a-.0453045459220346*o),z:Wt(-.049747207535812*i-.0492609666966138*a+1.1880659249923042*o)};return r!==void 0&&(s.alpha=r),s},Kt=(e=0)=>Math.max(e*203,0),qt=({x:e,y:t,z:n,alpha:r})=>{let i=Kt(e),a=Kt(t),o=Kt(n),s=Ut(.3592832590121217*i+.6976051147779502*a-.0358915932320289*o),c=Ut(-.1920808463704995*i+1.1004767970374323*a+.0753748658519118*o),l=Ut(.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},Jt={mode:`itp`,channels:[`i`,`t`,`p`,`alpha`],parse:[`--ictcp`],serialize:`--ictcp`,toMode:{xyz65:Gt,rgb:e=>Re(Gt(e))},fromMode:{xyz65:qt,rgb:e=>qt(P(e))},ranges:{i:[0,.581],t:[-.369,.272],p:[-.164,.331]},interpolate:{i:M,t:M,p:M,alpha:{use:M,fixup:N}}},Yt=e=>{if(e<0)return 0;let t=(e/1e4)**Lt;return((zt+Bt*t)/(1+Vt*t))**134.03437499999998},Xt=(e=0)=>Math.max(e*203,0),Zt=({x:e,y:t,z:n,alpha:r})=>{e=Xt(e),t=Xt(t),n=Xt(n);let i=1.15*e-.15*n,a=.66*t+.34*e,o=Yt(.41478972*i+.579999*a+.014648*n),s=Yt(-.20151*i+1.120649*a+.0531008*n),c=Yt(-.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},Qt=16295499532821565e-27,$t=e=>{if(e<0)return 0;let t=e**(1/134.03437499999998);return 1e4*((zt-t)/(Vt*t-Bt))**(1/Lt)},en=e=>e/203,tn=({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+Qt)/(.44+.56*(e+Qt)),a=$t(i+.13860504*t+.058047316*n),o=$t(i-.13860504*t-.058047316*n),s=$t(i-.096019242*t-.8118919*n),c={mode:`xyz65`,x:en(1.661373024652174*a-.914523081304348*o+.23136208173913045*s),y:en(-.3250758611844533*a+1.571847026732543*o-.21825383453227928*s),z:en(-.090982811*a-.31272829*o+1.5227666*s)};return r!==void 0&&(c.alpha=r),c},nn=e=>{let t=Zt(P(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},rn=e=>Re(tn(e)),an={mode:`jab`,channels:[`j`,`a`,`b`,`alpha`],parse:[`--jzazbz`],serialize:`--jzazbz`,fromMode:{rgb:nn,xyz65:Zt},toMode:{rgb:rn,xyz65:tn},ranges:{j:[0,.222],a:[-.109,.129],b:[-.185,.134]},interpolate:{j:M,a:M,b:M,alpha:{use:M,fixup:N}}},on=({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=F(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(a.alpha=r),a},sn=({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},cn={mode:`jch`,parse:[`--jzczhz`],serialize:`--jzczhz`,toMode:{jab:sn,rgb:e=>rn(sn(e))},fromMode:{rgb:e=>on(nn(e)),jab:on},channels:[`j`,`c`,`h`,`alpha`],ranges:{j:[0,.221],c:[0,.19],h:[0,360]},interpolate:{h:{use:M,fixup:I},c:M,j:M,alpha:{use:M,fixup:N}},difference:{h:$e},average:{h:R}},ln=29**3/3**3,un=6**3/29**3,dn=e=>e**3>un?e**3:(116*e-16)/ln,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+16)/116,a=t/500+i,o=i-n/200,s={mode:`xyz50`,x:dn(a)*V.X,y:dn(i)*V.Y,z:dn(o)*V.Z};return r!==void 0&&(s.alpha=r),s},pn=({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=Le({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},mn=e=>pn(fn(e)),hn=e=>{let{r:t,g:n,b:r,alpha:i}=Fe(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},gn=e=>e>un?Math.cbrt(e):(ln*e+16)/116,_n=({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=gn(e/V.X),a=gn(t/V.Y),o=gn(n/V.Z),s={mode:`lab`,l:116*a-16,a:500*(i-a),b:200*(a-o)};return r!==void 0&&(s.alpha=r),s},vn=e=>{let t=_n(hn(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t};function yn(e,t){if(!t||t[0]!==`lab`)return;let n={mode:`lab`},[,r,i,a,o]=t;if(!(r.type===A.Hue||i.type===A.Hue||a.type===A.Hue))return r.type!==A.None&&(n.l=Math.min(Math.max(0,r.value),100)),i.type!==A.None&&(n.a=i.type===A.Number?i.value:i.value*125/100),a.type!==A.None&&(n.b=a.type===A.Number?a.value:a.value*125/100),o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}let bn={mode:`lab`,toMode:{xyz50:fn,rgb:mn},fromMode:{xyz50:_n,rgb:vn},channels:[`l`,`a`,`b`,`alpha`],ranges:{l:[0,100],a:[-125,125],b:[-125,125]},parse:[yn],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:M,a:M,b:M,alpha:{use:M,fixup:N}}},xn={...bn,mode:`lab65`,parse:[`--lab-d65`],serialize:`--lab-d65`,toMode:{xyz65:at,rgb:ot},fromMode:{xyz65:ct,rgb:lt},ranges:{l:[0,100],a:[-125,125],b:[-125,125]}};function Sn(e,t){if(!t||t[0]!==`lch`)return;let n={mode:`lch`},[,r,i,a,o]=t;if(r.type!==A.None){if(r.type===A.Hue)return;n.l=Math.min(Math.max(0,r.value),100)}if(i.type!==A.None&&(n.c=Math.max(0,i.type===A.Number?i.value:i.value*150/100)),a.type!==A.None){if(a.type===A.Percentage)return;n.h=a.value}return o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}let Cn={mode:`lch`,toMode:{lab:B,rgb:e=>mn(B(e))},fromMode:{rgb:e=>z(vn(e)),lab:z},channels:[`l`,`c`,`h`,`alpha`],ranges:{l:[0,100],c:[0,150],h:[0,360]},parse:[Sn],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:M,fixup:I},c:M,l:M,alpha:{use:M,fixup:N}},difference:{h:$e},average:{h:R}},wn={...Cn,mode:`lch65`,parse:[`--lch-d65`],serialize:`--lch-d65`,toMode:{lab65:e=>B(e,`lab65`),rgb:e=>ot(B(e,`lab65`))},fromMode:{rgb:e=>z(lt(e),`lch65`),lab65:e=>z(e,`lch65`)},ranges:{l:[0,100],c:[0,150],h:[0,360]}},Tn=({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=F(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(a.alpha=r),a},En=({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},Dn=(e,t,n)=>4*e/(e+15*t+3*n),On=(e,t,n)=>9*t/(e+15*t+3*n),kn=Dn(V.X,V.Y,V.Z),An=On(V.X,V.Y,V.Z),jn=e=>e<=un?ln*e:116*Math.cbrt(e)-16,Mn=({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=jn(t/V.Y),a=Dn(e,t,n),o=On(e,t,n);!isFinite(a)||!isFinite(o)?i=a=o=0:(a=13*i*(a-kn),o=13*i*(o-An));let s={mode:`luv`,l:i,u:a,v:o};return r!==void 0&&(s.alpha=r),s},Nn=(e,t,n)=>4*e/(e+15*t+3*n),Pn=(e,t,n)=>9*t/(e+15*t+3*n),Fn=Nn(V.X,V.Y,V.Z),In=Pn(V.X,V.Y,V.Z),Ln=({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)+Fn,a=n/(13*e)+In,o=V.Y*(e<=8?e/ln:((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},Rn={mode:`lchuv`,toMode:{luv:En,rgb:e=>pn(Ln(En(e)))},fromMode:{rgb:e=>Tn(Mn(hn(e))),luv:Tn},channels:[`l`,`c`,`h`,`alpha`],parse:[`--lchuv`],serialize:`--lchuv`,ranges:{l:[0,100],c:[0,176.956],h:[0,360]},interpolate:{h:{use:M,fixup:I},c:M,l:M,alpha:{use:M,fixup:N}},difference:{h:$e},average:{h:R}},zn={...ke,mode:`lrgb`,toMode:{rgb:Le},fromMode:{rgb:Fe},parse:[`srgb-linear`],serialize:`srgb-linear`},Bn={mode:`luv`,toMode:{xyz50:Ln,rgb:e=>pn(Ln(e))},fromMode:{xyz50:Mn,rgb:e=>Mn(hn(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:M,u:M,v:M,alpha:{use:M,fixup:N}}},Vn=({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},Hn=e=>{let t=Vn(Fe(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},Un=({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},Wn=e=>Le(Un(e));function Gn(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 Kn(e){let t=.206,n=.03;return(1+t)/(1+n),(e*e+t*e)/(1.170873786407767*(e+n))}function qn(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 Jn(e,t){let n=qn(e,t),r=Un({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 Yn(e,t,n,r,i,a=null){a||=Jn(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,ee=4.0767416621*h-3.3077115913*g+.2309699292*_-1,te=4.0767416621*v-3.3077115913*y+.2309699292*b,ne=4.0767416621*x-3.3077115913*S+.2309699292*C,w=te/(te*te-.5*ee*ne),T=-ee*w,re=-1.2684380046*h+2.6097574011*g-.3413193965*_-1,ie=-1.2684380046*v+2.6097574011*y-.3413193965*b,ae=-1.2684380046*x+2.6097574011*S-.3413193965*C,E=ie/(ie*ie-.5*re*ae),D=-re*E,oe=-.0041960863*h-.7034186147*g+1.707614701*_-1,O=-.0041960863*v-.7034186147*y+1.707614701*b,se=-.0041960863*x-.7034186147*S+1.707614701*C,ce=O/(O*O-.5*oe*se),k=-oe*ce;T=w>=0?T:1e6,D=E>=0?D:1e6,k=ce>=0?k:1e6,o+=Math.min(T,Math.min(D,k))}}}return o}function Xn(e,t,n=null){n||=Jn(e,t);let r=n[0],i=n[1];return[i/r,i/(1-r)]}function Zn(e,t,n){let r=Jn(t,n),i=Yn(t,n,e,1,e,r),a=Xn(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 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={mode:`okhsl`,l:Gn(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]=Zn(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=F(Math.atan2(r,n)*180/Math.PI)),i}function $n(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:Kn(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]=Zn(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 er={...kt,mode:`okhsl`,channels:[`h`,`s`,`l`,`alpha`],parse:[`--okhsl`],serialize:`--okhsl`,fromMode:{oklab:Qn,rgb:e=>Qn(Hn(e))},toMode:{oklab:$n,rgb:e=>Wn($n(e))}};function tr(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]=Xn(a,o),l=.5,u=1-l/s,d=c/(i+t*c),f=d*t,p=d*i,m=Kn(f),h=p*m/f,g=Un({l:m,a:a*h,b:o*h}),_=Math.cbrt(1/Math.max(g.r,g.g,g.b,0));t/=_,i=i/_*Gn(t)/t,t=Gn(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=F(Math.atan2(r,n)*180/Math.PI)),e.alpha!==void 0&&(v.alpha=e.alpha),v}function nr(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]=Xn(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=Kn(d),m=f*p/d,h=Un({l:p,a:a*m,b:o*m}),g=Math.cbrt(1/Math.max(h.r,h.g,h.b,0)),_=Kn(i*d),v=f*_/d;return t.l=_*g,t.a=v*a*g,t.b=v*o*g,t}let rr={...Mt,mode:`okhsv`,channels:[`h`,`s`,`v`,`alpha`],parse:[`--okhsv`],serialize:`--okhsv`,fromMode:{oklab:tr,rgb:e=>tr(Hn(e))},toMode:{oklab:nr,rgb:e=>Wn(nr(e))}};function ir(e,t){if(!t||t[0]!==`oklab`)return;let n={mode:`oklab`},[,r,i,a,o]=t;if(!(r.type===A.Hue||i.type===A.Hue||a.type===A.Hue))return r.type!==A.None&&(n.l=Math.min(Math.max(0,r.type===A.Number?r.value:r.value/100),1)),i.type!==A.None&&(n.a=i.type===A.Number?i.value:i.value*.4/100),a.type!==A.None&&(n.b=a.type===A.Number?a.value:a.value*.4/100),o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}let ar={...bn,mode:`oklab`,toMode:{lrgb:Un,rgb:Wn},fromMode:{lrgb:Vn,rgb:Hn},ranges:{l:[0,1],a:[-.4,.4],b:[-.4,.4]},parse:[ir],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 or(e,t){if(!t||t[0]!==`oklch`)return;let n={mode:`oklch`},[,r,i,a,o]=t;if(r.type!==A.None){if(r.type===A.Hue)return;n.l=Math.min(Math.max(0,r.type===A.Number?r.value:r.value/100),1)}if(i.type!==A.None&&(n.c=Math.max(0,i.type===A.Number?i.value:i.value*.4/100)),a.type!==A.None){if(a.type===A.Percentage)return;n.h=a.value}return o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}let sr={...Cn,mode:`oklch`,toMode:{oklab:e=>B(e,`oklab`),rgb:e=>Wn(B(e,`oklab`))},fromMode:{rgb:e=>z(Hn(e),`oklch`),oklab:e=>z(e,`oklch`)},parse:[or],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]}},cr=e=>{let{r:t,g:n,b:r,alpha:i}=Fe(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},lr=({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=Le({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},ur={...ke,mode:`p3`,parse:[`display-p3`],serialize:`display-p3`,fromMode:{rgb:e=>lr(P(e)),xyz65:lr},toMode:{rgb:e=>Re(cr(e)),xyz65:cr}},dr=e=>{let t=Math.abs(e);return t>=1/512?Math.sign(e)*t**(1/1.8):16*e},fr=({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:dr(e*1.3457868816471585-t*.2555720873797946-.0511018649755453*n),g:dr(e*-.5446307051249019+t*1.5082477428451466+.0205274474364214*n),b:dr(e*0+t*0+1.2119675456389452*n)};return r!==void 0&&(i.alpha=r),i},pr=(e=0)=>{let t=Math.abs(e);return t>=16/512?Math.sign(e)*t**1.8:e/16},mr=e=>{let t=pr(e.r),n=pr(e.g),r=pr(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},hr={...ke,mode:`prophoto`,parse:[`prophoto-rgb`],serialize:`prophoto-rgb`,fromMode:{xyz50:fr,rgb:e=>fr(hn(e))},toMode:{xyz50:mr,rgb:e=>pn(mr(e))}},gr=1.09929682680944,_r=e=>{let t=Math.abs(e);return t>.018053968510807?(Math.sign(e)||1)*(gr*t**.45-(gr-1)):4.5*e},vr=({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:_r(e*1.7166511879712683-t*.3556707837763925-.2533662813736599*n),g:_r(e*-.6666843518324893+t*1.6164812366349395+.0157685458139111*n),b:_r(e*.0176398574453108-t*.0427706132578085+.9421031212354739*n)};return r!==void 0&&(i.alpha=r),i},yr=1.09929682680944,br=(e=0)=>{let t=Math.abs(e);return t<.018053968510807*4.5?e/4.5:(Math.sign(e)||1)*((t+yr-1)/yr)**(1/.45)},xr=e=>{let t=br(e.r),n=br(e.g),r=br(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},Sr={...ke,mode:`rec2020`,fromMode:{xyz65:vr,rgb:e=>vr(P(e))},toMode:{xyz65:xr,rgb:e=>Re(xr(e))},parse:[`rec2020`],serialize:`rec2020`},H=.0037930732552754493,Cr=Math.cbrt(H),wr=e=>Math.cbrt(e)-Cr,Tr=e=>{let{r:t,g:n,b:r,alpha:i}=Fe(e),a=wr(.3*t+.622*n+.078*r+H),o=wr(.23*t+.692*n+.078*r+H),s=wr(.2434226892454782*t+.2047674442449682*n+.5518098665095535*r+H),c={mode:`xyb`,x:(a-o)/2,y:(a+o)/2,b:s-(a+o)/2};return i!==void 0&&(c.alpha=i),c},Er=e=>(e+Cr)**3,Dr={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=Er(e+t)-H,a=Er(t-e)-H,o=Er(n+t)-H,s=Le({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:Tr},ranges:{x:[-.0154,.0281],y:[0,.8453],b:[-.2778,.388]},interpolate:{x:M,y:M,b:M,alpha:{use:M,fixup:N}}},Or={mode:`xyz50`,parse:[`xyz-d50`],serialize:`xyz-d50`,toMode:{rgb:pn,lab:_n},fromMode:{rgb:hn,lab:fn},channels:[`x`,`y`,`z`,`alpha`],ranges:{x:[0,.964],y:[0,.999],z:[0,.825]},interpolate:{x:M,y:M,z:M,alpha:{use:M,fixup:N}}},kr={mode:`xyz65`,toMode:{rgb:Re,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:P,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:M,y:M,z:M,alpha:{use:M,fixup:N}}},Ar={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:M,i:M,q:M,alpha:{use:M,fixup:N}}},jr=(e,t)=>Math.round(e*(t=10**t))/t,Mr=((e=4)=>t=>typeof t==`number`?jr(t,e):t)(2),Nr=e=>Math.max(0,Math.min(1,e||0)),Pr=e=>Math.round(Nr(e)*255),Fr=E(`rgb`),Ir=e=>{if(e===void 0)return;let t=Pr(e.r),n=Pr(e.g),r=Pr(e.b);return e.alpha===void 0||e.alpha===1?`rgb(${t}, ${n}, ${r})`:`rgba(${t}, ${n}, ${r}, ${Mr(Nr(e.alpha))})`},U=e=>Ir(Fr(e)),Lr=(e,t=`rgb`,n=!1)=>{let r=t?le(t).channels:null,i=t?E(t):ae;return a=>{let o=i(a);if(!o)return;let s=(r||le(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=ae(a);return c&&c.mode!==s.mode?E(c.mode)(s):s}},Rr=(e,t,n)=>t===`alpha`?e:(e||0)*(n.alpha===void 0?1:n.alpha),zr=(e,t,n)=>t!==`alpha`&&n.alpha!==0?(e||0)/(n.alpha===void 0?1:n.alpha):e,Br=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},Vr=(e=.5)=>t=>e<=0?1:e>=1?0:t**+(Math.log(.5)/Math.log(e)),Hr=e=>typeof e==`function`,W=e=>e&&typeof e==`object`,Ur=e=>typeof e==`number`,Wr=(e,t=`rgb`,n,r)=>{let i=le(t),a=E(t),o=[],s=[],c={};e.forEach(e=>{Array.isArray(e)?(o.push(a(e[0])),s.push(e[1])):Ur(e)||Hr(e)?c[s.length]=e:(o.push(a(e)),s.push(void 0))}),Br(s);let l=i.channels.reduce((e,t)=>{let r;return r=W(n)&&W(n[t])&&n[t].fixup?n[t].fixup:W(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 Hr(n)?r=n:W(n)&&Hr(n[t])?r=n[t]:W(n)&&W(n[t])&&n[t].use?r=n[t].use:Hr(i.interpolate[t])?r=i.interpolate[t]:W(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&&(Ur(f)&&(f=Vr((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})}},G=(e,t=`rgb`,n)=>Wr(e,t,n);((e,t)=>(n,r=`rgb`,i)=>{let a=t?Lr(t,r):void 0,o=Wr(n,r,i,e);return a?e=>a(o(e)):o})(Rr,zr),k(ze),k(et),k(vt),k(yt),k(St),k(kt),k(Mt),k(It),k(Jt),k(an),k(cn),k(bn),k(xn),k(Cn),k(wn),k(Rn),k(zn),k(Bn),k(er),k(rr),k(ar),k(sr),k(ur),k(hr),k(Sr),k(ke),k(Dr),k(Or),k(kr),k(Ar);let Gr=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 Kr(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=Jr(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 qr(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 Jr(e,t,n,r){let i=t[r];if(i===`config`||i===`color-stop`||i===`color-hint`)return qr(e,t,n,r);if(i===`[`)return Xr(e,t,n,r);if(i===`(`)return Qr(e,t,n,r);if(i===`~`)return $r(e,t,n,r);throw Error(`Unsupported primary token "${i}" at pattern index ${r}`)}function Yr(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 Xr(e,t,n,r){if(t[r]!==`[`)throw Error(`Expected "[" at pattern index ${r}`);let i=Yr(t,r,`[`,`]`),a=n,o=r+1;for(;o<i;){if(t[o]===`,`){o+=1;continue}let i=Jr(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 Zr(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 Qr(e,t,n,r){if(t[r]!==`(`)throw Error(`Expected "(" at pattern index ${r}`);let i=Yr(t,r,`(`,`)`),a=Zr(t.slice(r+1,i));for(let t of a){let r=Kr(e,t,n,0);if(r.matched)return{matched:!0,nextInputIndex:r.nextInputIndex,nextPatternIndex:i+1}}return{matched:!1,nextInputIndex:n,nextPatternIndex:r}}function $r(e,t,n,r){if(t[r]!==`~`)throw Error(`Expected "~" at pattern index ${r}`);let i=n,a=r+1;for(;;){let n=Jr(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=ei(t,a);return{matched:!0,nextInputIndex:i,nextPatternIndex:o}}function ei(e,t){let n=e[t];if(n===`config`||n===`color-stop`||n===`color-hint`)return t+1;if(n===`[`)return Yr(e,t,`[`,`]`)+1;if(n===`(`)return Yr(e,t,`(`,`)`)+1;if(n===`~`)return ei(e,t+1);throw Error(`Unsupported token "${n}" in getPrimaryEndIndex`)}function ti(e){return ri(e),oi(e),si(e),!0}function ni(e){try{return ti(e),!0}catch{return!1}}function ri(e){let t=ci(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 ii(e){try{return ri(e),!0}catch{return!1}}let ai={"^":[`(`,`[`,`!`,`~`,`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 oi(e){let t=ci(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=ai[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 si(e){let t=ci(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 ci(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 li(e,t){try{return ui(e,t),!0}catch{return!1}}function ui(e,t){ti(t);let n=ci(t).slice(1,-1),r=Kr(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 di(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}=gi(n),o=hi(a);return ui(o,t),{functionName:r,isRepeating:i,inputs:o}}function fi(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 pi(e){try{let t=bi(e)[0];return we(t)!==void 0}catch{return!1}}function mi(e){return!fi(e)&&!pi(e)}function hi(e){let t=e.map(e=>e.trim()).filter(e=>e.length>0);return t.length===0?[]:t.map((e,t)=>t===0&&!pi(e)?{type:`config`,value:e}:pi(e)?{type:`color-stop`,value:e}:fi(e)?{type:`color-hint`,value:e}:{type:`config`,value:e})}function gi(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=_i(e,t);if(i===-1)throw Error(`Unclosed function parenthesis`);let a=vi(e.slice(t+1,i));return{functionName:n,isRepeating:r,inputs:a}}function _i(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 vi(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){yi(t,n),n=``;continue}n+=s}return yi(t,n),t}function yi(e,t){let n=t.trim();n.length>0&&e.push(n)}function bi(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 xi=[`oklab`,`lch`,`oklch`,`hsl`,`hwb`,`lab`,`srgb`,`srgb-linear`,`xyz`,`display-p3`,`a98-rgb`,`prophoto-rgb`,`rec2020`],Si=[`shorter`,`longer`,`increasing`,`decreasing`],Ci=[`hsl`,`hwb`,`lch`,`oklch`];function wi(e){return Si.includes(e)}function Ti(e){return xi.includes(e)}function Ei(e){return Ci.includes(e)}var Di=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=bi(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}})}},Oi=class e extends Di{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(di(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||!Ei(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||!Ti(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(wi(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}},ki=class e extends Di{static DEFAULT_CONFIG={isRepeating:!1,stops:[{type:`color-stop`,value:`red`,position:0},{type:`color-stop`,value:`blue`,position:1}],config:{shape:`ellipse`,size:{kind:`extent`,value:`farthest-corner`},position:{kind:`keywords`,x:`center`,y:`center`}}};type=`radial-gradient`;constructor(t){let n={...e.DEFAULT_CONFIG,...t};n.config.interpolation&&(n.config.interpolation=e._normalizeConfigInterpolation(n.config.interpolation)),super(n)}static fromString(t){return e.fromAbi(di(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._parseConfigToString(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`)}_parseConfigToString(e){let t=[],n=this._parseRadialConfigToString(e);return n.length>0&&t.push(n),e.interpolation!==void 0&&t.push(this._parseInterpolationToString(e.interpolation)),t.join(` `)}_parseRadialConfigToString(e){let t=[];return this._isDefaultRadialShape(e.shape)||t.push(e.shape),this._isDefaultRadialSize(e.size)||t.push(this._parseRadialSizeToString(e.size)),this._isDefaultRadialPosition(e.position)||t.push(`at ${this._serializePosition(e.position)}`),t.join(` `)}_parseRadialSizeToString(e){if(e.kind===`extent`)return e.value;let t=this._formatLengthPercentage(e.x);return e.y===void 0?t:`${t} ${this._formatLengthPercentage(e.y)}`}_parseInterpolationToString(e){let{colorSpace:t,hue:n}=e;return n===void 0?`in ${t}`:`in ${t} ${n} hue`}_isDefaultRadialShape(e){return e===`ellipse`}_isDefaultRadialSize(e){return e.kind===`extent`&&e.value===`farthest-corner`}_isDefaultRadialPosition(e){return e.kind===`keywords`&&e.x===`center`&&e.y===`center`}_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`},i,a=e=>e===void 0?!1:e.endsWith(`%`)||/^-?\d*\.?\d+[a-zA-Z]+$/.test(e);for(let o of e){if(o.type!==`config`)continue;let e=bi(o.value);for(let o=0;o<e.length;o++){let s=e[o];if(s===`circle`||s===`ellipse`){t=s;continue}if(s===`closest-side`||s===`closest-corner`||s===`farthest-side`||s===`farthest-corner`){n={kind:`extent`,value:s};continue}if(a(s)){let r=e[o+1];if(t===`ellipse`&&a(r)){n={kind:`explicit`,x:this._parseLengthPercentage(s),y:this._parseLengthPercentage(r)},o+=1;continue}n={kind:`explicit`,x:this._parseLengthPercentage(s)};continue}if(s===`at`){let t=e[o+1],n=e[o+2];if(t===`center`&&(n===void 0||n===`in`)){r={kind:`keywords`,x:`center`,y:`center`},o+=1;continue}if((t===`left`||t===`right`)&&(n===void 0||n===`in`)){r={kind:`keywords`,x:t,y:`center`},o+=1;continue}if((t===`top`||t===`bottom`)&&(n===void 0||n===`in`)){r={kind:`keywords`,x:`center`,y:t},o+=1;continue}if((t===`left`||t===`center`||t===`right`)&&(n===`top`||n===`center`||n===`bottom`)){r={kind:`keywords`,x:t,y:n},o+=2;continue}if(a(t)&&a(n)){r={kind:`values`,x:this._parseLengthPercentage(t),y:this._parseLengthPercentage(n)},o+=2;continue}throw Error(`Invalid radial-gradient position: ${t??``} ${n??``}`)}if(s===`in`){let t=e[o+1],n=e[o+2],r=e[o+3];if(!t)throw Error(`Invalid radial-gradient interpolation: missing color space`);if(n!==void 0&&r===`hue`){i=this._normalizeConfigInterpolation({colorSpace:t,hue:n}),o+=3;continue}i=this._normalizeConfigInterpolation({colorSpace:t}),o+=1;continue}}}return{shape:t,size:n,position:r,interpolation:i}}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 _normalizeConfigInterpolation(e){let{colorSpace:t,hue:n}=e;return n===void 0||!Ei(t)?{colorSpace:t}:{colorSpace:t,hue:n}}},Ai=class e extends ki{type=`diamond-gradient`;constructor(e){super(e)}static fromString(t){return e.fromAbi(di(t))}static fromAbi(t){if(t.functionName!==`diamond-gradient`)throw Error(`Invalid function name for DiamondGradient`);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())}},ji=class e extends Di{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(di(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=[];if(!this._isDefaultFrom(this.config.from)){let t=this.config.from;e.push(`from ${t.value}${t.unit}`)}return this._isDefaultPosition(this.config.position)||e.push(`at ${this._serializePosition(this.config.position)}`),this.config.interpolation!==void 0&&e.push(this._serializeInterpolation(this.config.interpolation)),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}`}_serializeInterpolation(e){let{colorSpace:t,hue:n}=e;return n===void 0?`in ${t}`:`in ${t} ${n} hue`}_isDefaultFrom(e){return e.value===0&&e.unit===`deg`}_isDefaultPosition(e){return e.kind===`keywords`&&e.x===`center`&&e.y===`center`}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=bi(e),r=e=>e===void 0?!1:e.endsWith(`%`)||/^-?\d*\.?\d+[a-zA-Z]+$/.test(e);for(let e=0;e<n.length;e++){let i=n[e];if(i===`from`){let r=n[e+1];if(r===void 0)throw Error(`Invalid conic-gradient config: missing angle after from`);t.from=this._parseAngle(r),e+=1;continue}if(i===`at`){let i=n[e+1],a=n[e+2];if(i===void 0)throw Error(`Invalid conic-gradient config: missing position after at`);if(i===`center`&&(a===void 0||a===`in`)){t.position={kind:`keywords`,x:`center`,y:`center`},e+=1;continue}if((i===`left`||i===`right`)&&(a===void 0||a===`in`)){t.position={kind:`keywords`,x:i,y:`center`},e+=1;continue}if((i===`top`||i===`bottom`)&&(a===void 0||a===`in`)){t.position={kind:`keywords`,x:`center`,y:i},e+=1;continue}if((i===`left`||i===`center`||i===`right`)&&(a===`top`||a===`center`||a===`bottom`)){t.position={kind:`keywords`,x:i,y:a},e+=2;continue}if(r(i)&&r(a)){t.position={kind:`values`,x:this._parseLengthPercentage(i),y:this._parseLengthPercentage(a)},e+=2;continue}throw Error(`Invalid conic-gradient position: ${i} ${a??``}`)}if(i===`in`){let r=n[e+1],i=n[e+2],a=n[e+3];if(r===void 0)throw Error(`Invalid conic-gradient interpolation: missing color space`);if(a===`hue`&&(i===`shorter`||i===`longer`||i===`increasing`||i===`decreasing`)){t.interpolation={colorSpace:r,hue:i},e+=3;continue}t.interpolation={colorSpace:r},e+=1;continue}}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]}}};let Mi=/^[A-Za-z_][A-Za-z0-9_-]*$/,Ni=[`px`,`em`,`rem`,`vw`,`vh`,`vmin`,`vmax`,`cm`,`mm`,`in`,`pt`,`pc`];var Pi=class e{type=`mesh-gradient`;_config;_vertices;_patches;constructor(t){let n=structuredClone(t.config);n.interpolation&&=e._normalizeInterpolation(n.interpolation),this._config=n,this._vertices=structuredClone(t.vertices),this._patches=structuredClone(t.patches),this._validate()}get config(){return structuredClone(this._config)}get vertices(){return structuredClone(this._vertices)}get patches(){return structuredClone(this._patches)}static fromString(t){let{functionName:n,isRepeating:r,inputs:i}=e._parseFunction(t);if(n!==`mesh-gradient`)throw Error(`Invalid function name for MeshGradient`);if(r)throw Error(`MeshGradient does not support repeating gradients`);let a=null,o=[],s=[],c=[];for(let e of i){let t=bi(e),n=t[0];if(n===`grid`){if(a!==null)throw Error(`mesh-gradient can only contain one grid config`);a=this._parseConfig(t);continue}if(n===`vertex`){o.push(this._parseVertex(t));continue}if(n===`patch`){s.push(this._parsePatch(t));continue}if(n===`handle`){c.push(this._parseHandle(t));continue}throw Error(`Unsupported mesh-gradient input: ${e}`)}if(!a)throw Error(`mesh-gradient requires a grid config`);let l=this._attachHandles(s,c);return new e({config:a,vertices:o,patches:l})}static fromAbi(t){if(t.functionName!==`mesh-gradient`)throw Error(`Invalid function name for MeshGradient`);if(t.isRepeating)throw Error(`MeshGradient does not support repeating gradients`);return e.fromString(`${t.functionName}(${t.inputs.map(e=>e.value).join(`, `)})`)}clone(){return new e(this.toJSON())}toJSON(){return{type:this.type,config:this.config,vertices:this.vertices,patches:this.patches}}toString(){let e=[this._serializeConfig(),...this._vertices.map(e=>this._serializeVertex(e)),...this._patches.map(e=>this._serializePatch(e)),...this._patches.flatMap(e=>this._serializeHandles(e))];return`${this.type}(${e.join(`, `)})`}getVertex(e){let t=this._vertices.find(t=>t.id===e);return t?structuredClone(t):null}_serializeConfig(){let e=[`grid`,String(this._config.rows),String(this._config.columns),`method`,this._config.method];return this._config.interpolation&&(e.push(`in`,this._config.interpolation.colorSpace),this._config.interpolation.hue&&e.push(this._config.interpolation.hue,`hue`)),e.join(` `)}_serializeVertex(e){return[`vertex`,e.id,this._formatLengthPercentage(e.x),this._formatLengthPercentage(e.y),e.color].join(` `)}_serializePatch(e){return[`patch`,e.id,e.topLeft,e.topRight,e.bottomRight,e.bottomLeft].join(` `)}_serializeHandles(e){if(!e.handles)return[];let t=[];for(let n of[`top`,`right`,`bottom`,`left`]){let r=e.handles[n];r&&t.push([`handle`,e.id,n,this._formatLengthPercentage(r.from.x),this._formatLengthPercentage(r.from.y),this._formatLengthPercentage(r.to.x),this._formatLengthPercentage(r.to.y)].join(` `))}return t}_formatLengthPercentage(e){return e.kind===`percent`?`${e.value}%`:`${e.value}${e.unit}`}_validate(){if(!Number.isInteger(this._config.rows)||this._config.rows<2)throw Error(`Mesh gradient rows must be an integer >= 2`);if(!Number.isInteger(this._config.columns)||this._config.columns<2)throw Error(`Mesh gradient columns must be an integer >= 2`);if(this._config.method!==`bilinear`&&this._config.method!==`bicubic`)throw Error(`Invalid mesh gradient interpolation method`);if(this._config.interpolation&&!Ti(this._config.interpolation.colorSpace))throw Error(`Invalid mesh gradient color space: ${this._config.interpolation.colorSpace}`);let e=this._config.rows*this._config.columns,t=(this._config.rows-1)*(this._config.columns-1);if(this._vertices.length!==e)throw Error(`Mesh gradient expected ${e} vertices for ${this._config.rows}x${this._config.columns} grid, received ${this._vertices.length}`);if(this._patches.length!==t)throw Error(`Mesh gradient expected ${t} patches for ${this._config.rows}x${this._config.columns} grid, received ${this._patches.length}`);let n=new Set;for(let e of this._vertices){if(this._validateId(e.id,`vertex`),n.has(e.id))throw Error(`Duplicate mesh vertex id: ${e.id}`);if(n.add(e.id),this._validateLengthPercentage(e.x,`vertex ${e.id} x`),this._validateLengthPercentage(e.y,`vertex ${e.id} y`),!we(e.color))throw Error(`Invalid mesh vertex color: ${e.color}`)}let r=new Set;for(let e of this._patches){if(this._validateId(e.id,`patch`),r.has(e.id))throw Error(`Duplicate mesh patch id: ${e.id}`);r.add(e.id);let t=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft];if(new Set(t).size!==4)throw Error(`Mesh patch must use 4 unique vertices: ${e.id}`);for(let e of t)if(!n.has(e))throw Error(`Mesh patch references missing vertex: ${e}`);e.handles&&this._validateHandles(e)}if(this._patches.length===0)throw Error(`Mesh gradient requires at least one patch`)}_validateId(e,t){if(!Mi.test(e))throw Error(`Invalid mesh ${t} id: ${e}`)}_validateHandles(e){if(e.handles)for(let t of[`top`,`right`,`bottom`,`left`]){let n=e.handles[t];n&&(this._validateLengthPercentage(n.from.x,`patch ${e.id} ${t} handle from x`),this._validateLengthPercentage(n.from.y,`patch ${e.id} ${t} handle from y`),this._validateLengthPercentage(n.to.x,`patch ${e.id} ${t} handle to x`),this._validateLengthPercentage(n.to.y,`patch ${e.id} ${t} handle to y`))}}_validateLengthPercentage(e,t){if(e.kind===`percent`){if(!Number.isFinite(e.value))throw Error(`Invalid mesh ${t}`);return}if(!Number.isFinite(e.value))throw Error(`Invalid mesh ${t}`)}static _parseConfig(e){if(e.length<3)throw Error(`Invalid mesh grid config`);let t=Number(e[1]),n=Number(e[2]),r=`bilinear`,i;for(let t=3;t<e.length;t+=1){let n=e[t];if(n===`method`){let n=e[t+1];if(n!==`bilinear`&&n!==`bicubic`)throw Error(`Invalid mesh gradient method: ${n}`);r=n,t+=1;continue}if(n===`in`){let n=e[t+1],r=e[t+2],a=e[t+3];if(!Ti(n))throw Error(`Invalid mesh gradient color space: ${n}`);if(r!==void 0&&a===`hue`&&wi(r)){i=this._normalizeInterpolation({colorSpace:n,hue:r}),t+=3;continue}i={colorSpace:n},t+=1;continue}throw Error(`Unsupported mesh grid config token: ${n}`)}return{rows:t,columns:n,method:r,interpolation:i}}static _parseVertex(e){if(e.length<5)throw Error(`Invalid mesh vertex input`);return{id:e[1],x:this._parseLengthPercentage(e[2]),y:this._parseLengthPercentage(e[3]),color:e.slice(4).join(` `)}}static _parsePatch(e){if(e.length!==6)throw Error(`Invalid mesh patch input`);return{id:e[1],topLeft:e[2],topRight:e[3],bottomRight:e[4],bottomLeft:e[5]}}static _parseHandle(e){if(e.length!==7)throw Error(`Invalid mesh handle input`);let t=e[2];if(t!==`top`&&t!==`right`&&t!==`bottom`&&t!==`left`)throw Error(`Invalid mesh handle side: ${t}`);return{patchId:e[1],side:t,from:{x:this._parseLengthPercentage(e[3]),y:this._parseLengthPercentage(e[4])},to:{x:this._parseLengthPercentage(e[5]),y:this._parseLengthPercentage(e[6])}}}static _attachHandles(e,t){if(t.length===0)return e;let n=new Map(e.map(e=>[e.id,e])),r=e.map(e=>structuredClone(e)),i=new Map(r.map(e=>[e.id,e]));for(let e of t){if(!n.has(e.patchId))throw Error(`Mesh handle references missing patch: ${e.patchId}`);let t=i.get(e.patchId);if(t.handles??={},t.handles[e.side])throw Error(`Duplicate mesh handle for patch ${e.patchId} side ${e.side}`);t.handles[e.side]={from:e.from,to:e.to}}return r}static _parseLengthPercentage(e){if(e.endsWith(`%`)){let t=parseFloat(e);if(!Number.isFinite(t))throw Error(`Invalid mesh length-percentage: ${e}`);return{kind:`percent`,value:t}}let t=e.match(/^(-?\d*\.?\d+)([a-zA-Z]+)$/);if(!t)throw Error(`Invalid mesh length-percentage: ${e}`);let n=t[2];if(!Ni.includes(n))throw Error(`Unsupported mesh length unit: ${t[2]}`);return{kind:`length`,value:parseFloat(t[1]),unit:n}}static _normalizeInterpolation(e){let{colorSpace:t,hue:n}=e;return n===void 0||!Ei(t)?{colorSpace:t}:{colorSpace:t,hue:n}}static _parseFunction(e){let t=e.trim(),n=t.indexOf(`(`);if(n<=0)throw Error(`Expected mesh-gradient function call`);let r=t.slice(0,n).trim(),i=r.startsWith(`repeating-`);i&&(r=r.slice(10));let a=this._findOuterClosingParenIndex(t,n);if(a===-1)throw Error(`Unclosed mesh-gradient function parenthesis`);let o=t.slice(a+1).trim();if(o.length>0&&!o.startsWith(`${r}(`)&&!o.startsWith(`repeating-${r}(`))throw Error(`Unexpected mesh-gradient trailing input: ${o}`);let s=t.slice(n+1,a);return{functionName:r,isRepeating:i,inputs:this._splitTopLevelInputs(s)}}static _findOuterClosingParenIndex(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}static _splitTopLevelInputs(e){let t=[],n=``,r=0;for(let i=0;i<e.length;i+=1){let a=e[i];if(a===`(`){r+=1,n+=a;continue}if(a===`)`){if(--r,r<0)throw Error(`Unbalanced mesh-gradient input parentheses`);n+=a;continue}if(a===`,`&&r===0){this._pushTrimmed(t,n),n=``;continue}n+=a}if(this._pushTrimmed(t,n),r!==0)throw Error(`Unbalanced mesh-gradient input parentheses`);return t}static _pushTrimmed(e,t){let n=t.trim();n.length>0&&e.push(n)}},Fi=class{target=`css`;gradientType=`linear-gradient`;to(e){if(!(e instanceof Oi))throw Error(`Expected LinearGradient`);return e.toString()}},Ii=class{target=`css`;gradientType=`radial-gradient`;to(e){if(!(e instanceof ki))throw Error(`Expected RadialGradient`);return e.toString()}};function Li(e,t){return(e%t+t)%t}function Ri(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 U(G([r.value,i.value],`rgb`)(n))}}return r.value}function zi(e,t,n,r){return Ri(e,n+Li(t-n,r))}function K(e,t,n){let r=e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position);if(r.length<2)return r;let i=r[0].position,a=r[r.length-1].position-i;if(a<=0)return r;let o=[],s=0;o.push({type:`color-stop`,value:zi(r,t,i,a),position:t,_order:s}),s+=1;let c=Math.floor((t-i)/a)-1,l=Math.ceil((n-i)/a)+1;for(let e=c;e<=l;e+=1){let i=e*a;for(let e of r){let r=e.position+i;r<=t||r>=n||(o.push({...e,position:r,_order:s}),s+=1)}}return o.push({type:`color-stop`,value:zi(r,n,i,a),position:n,_order:s}),o.sort((e,t)=>e.position===t.position?e._order-t._order:e.position-t.position).map(({_order:e,...t})=>t)}function Bi(e){return K(e,0,1)}function Vi(e,t,n,r){return Math.max(...[{x:0,y:0},{x:n,y:0},{x:0,y:r},{x:n,y:r}].map(n=>{let r=(n.x-e.x)/Math.max(t.x,1e-4),i=(n.y-e.y)/Math.max(t.y,1e-4);return Math.sqrt(r*r+i*i)}))}function Hi(e){switch(e){case`longer`:return Ve;case`increasing`:return He;case`decreasing`:return Ue;default:return I}}function Ui(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 Wi(e){if(e.hue!==void 0)return{h:{fixup:Hi(e.hue)}}}function Gi(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 Ki(e){let t=qi(e);if(!t)throw Error(`Failed to convert interpolated color to rgb.`);return U(t)}let qi=E(`rgb`);function q(e,t=64){let n=Gi(e.stops),r=e.config.interpolation;if(n.length<2)return n;if(r===void 0)return e.isRepeating?Bi(n):n;let i=[],a=Ui(r.colorSpace),o=Wi(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=G([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:Ki(o),position:a})}}return e.isRepeating?Bi(i):i}let Ji=E(`rgb`);function Yi(e){let t=Ji(e);if(!t)throw Error(`Failed to convert color: ${e}`);return[t.r??0,t.g??0,t.b??0,t.alpha??1]}function Xi(e,t){if(e.kind===`percent`)return e.value/100*t;if(e.unit===`px`)return e.value;throw Error(`Unsupported mesh-gradient length unit: ${e.unit}`)}function Zi(e,t,n){return{id:e.id,x:Xi(e.x,t),y:Xi(e.y,n),color:Yi(e.color)}}function Qi(e,t,n){return new Map(e.vertices.map(e=>[e.id,Zi(e,t,n)]))}function $i(e,t){let n=ea(e,t);if(n)return n;let r=e.vertices.map(e=>{let n=t.get(e.id);if(!n)throw Error(`Missing mesh vertex: ${e.id}`);return n}).sort((e,t)=>Math.abs(e.y-t.y)>1e-4?e.y-t.y:e.x-t.x),i=[];for(let t=0;t<e.config.rows;t+=1){let n=t*e.config.columns,a=n+e.config.columns;i.push(r.slice(n,a))}return i}function ea(e,t){let n=Array.from({length:e.config.rows},()=>[]);for(let r of e.vertices){let i=r.id.match(/^v(\d+)(\d+)$/);if(!i)return null;let a=Number(i[1]),o=Number(i[2]);if(!Number.isInteger(o)||!Number.isInteger(a)||o<0||a<0||o>=e.config.rows||a>=e.config.columns)return null;let s=t.get(r.id);if(!s)throw Error(`Missing mesh vertex: ${r.id}`);if(n[o][a])return null;n[o][a]=s}return n.some(t=>t.length!==e.config.columns||t.some(e=>e===void 0))?null:n}function ta(e,t){for(let n=0;n<e.length-1;n+=1)for(let r=0;r<e[n].length-1;r+=1)if(e[n][r].id===t.topLeft&&e[n][r+1].id===t.topRight&&e[n+1][r+1].id===t.bottomRight&&e[n+1][r].id===t.bottomLeft)return{row:n,column:r};throw Error(`Mesh patch does not match adjacent regular grid vertices: ${t.id}`)}function na(e,t){return Math.min(t-1,Math.max(0,e))}function ra(e,t,n,r,i){let a=i*i,o=a*i;return .5*(2*t+(-e+n)*i+(2*e-5*t+4*n-r)*a+(-e+3*t-3*n+r)*o)}function ia(e){return Math.min(1,Math.max(0,e))}function J(e,t,n){return e+(t-e)*n}function aa(e,t,n){return[J(e[0],t[0],n),J(e[1],t[1],n),J(e[2],t[2],n),J(e[3],t[3],n)]}function oa(e,t,n,r,i,a){return aa(aa(e.color,t.color,i),aa(r.color,n.color,i),a)}function sa(e,t,n,r,i){let a=e.length,o=e[0]?.length??0,s=[0,0,0,0];for(let c=0;c<4;c+=1){let l=[];for(let i=-1;i<=2;i+=1){let s=e[na(t+i,a)],u=s[na(n-1,o)].color[c],d=s[na(n,o)].color[c],f=s[na(n+1,o)].color[c],p=s[na(n+2,o)].color[c];l.push(ra(u,d,f,p,r))}s[c]=ia(ra(l[0],l[1],l[2],l[3],i))}return s}function Y(e,t,n,r,i,a){let o=J(e.x,t.x,i),s=J(e.y,t.y,i),c=J(r.x,n.x,i),l=J(r.y,n.y,i);return{x:J(o,c,a),y:J(s,l,a)}}function ca(e,t,n,r,i,a,o,s,c,l){return e.config.method===`bicubic`?sa(t,n,r,c,l):oa(i,a,o,s,c,l).map(ia)}function la(e,t,n,r,i){let a=r.get(n.topLeft),o=r.get(n.topRight),s=r.get(n.bottomRight),c=r.get(n.bottomLeft);if(!a||!o||!s||!c)throw Error(`Mesh patch references missing vertex: ${n.id}`);let l=ta(t,n),u=[];for(let r=0;r<=i;r+=1){let d=[],f=r/i;for(let u=0;u<=i;u+=1){let p=u/i,m=Y(a,o,s,c,p,f),h=ca(e,t,l.row,l.column,a,o,s,c,p,f);d.push({id:`${n.id}:${u}:${r}`,x:m.x,y:m.y,color:h})}u.push(d)}let d=[];for(let e=0;e<i;e+=1)for(let t=0;t<i;t+=1){let n=u[e][t],r=u[e][t+1],i=u[e+1][t+1],a=u[e+1][t];d.push([n,r,i],[n,i,a])}return d}function X(e,t,n,r,i,a,o,s,c,l,u,d,f){return{id:f,x:u,y:d,color:ca(e,t,n,r,i,a,o,s,c,l)}}function ua(e,t,n,r,i){let a=[],o=t.length,s=t[0]?.length??0;if(o<2||s<2)return a;for(let n=0;n<s-1;n+=1){let r=t[0][n],o=t[0][n+1],s=t[1][n+1],c=t[1][n];for(let l=0;l<i;l+=1){let u=l/i,d=(l+1)/i,f=Y(r,o,s,c,u,0),p=Y(r,o,s,c,d,0),m=Y(r,o,s,c,u,1),h=Y(r,o,s,c,d,1),g=Math.min(0,(0-f.y)/Math.max(m.y-f.y,1e-4)),_=Math.min(0,(0-p.y)/Math.max(h.y-p.y,1e-4)),v=X(e,t,0,n,r,o,s,c,u,0,f.x,f.y,`top:${n}:${l}:b0`),y=X(e,t,0,n,r,o,s,c,d,0,p.x,p.y,`top:${n}:${l}:b1`),b=X(e,t,0,n,r,o,s,c,u,g,f.x,0,`top:${n}:${l}:p0`),x=X(e,t,0,n,r,o,s,c,d,_,p.x,0,`top:${n}:${l}:p1`);a.push([b,x,y],[b,y,v])}}for(let n=0;n<s-1;n+=1){let s=o-2,c=t[s][n],l=t[s][n+1],u=t[s+1][n+1],d=t[s+1][n];for(let o=0;o<i;o+=1){let f=o/i,p=(o+1)/i,m=Y(c,l,u,d,f,0),h=Y(c,l,u,d,p,0),g=Y(c,l,u,d,f,1),_=Y(c,l,u,d,p,1),v=Math.max(1,(r-m.y)/Math.max(g.y-m.y,1e-4)),y=Math.max(1,(r-h.y)/Math.max(_.y-h.y,1e-4)),b=X(e,t,s,n,c,l,u,d,f,1,g.x,g.y,`bottom:${n}:${o}:b0`),x=X(e,t,s,n,c,l,u,d,p,1,_.x,_.y,`bottom:${n}:${o}:b1`),S=X(e,t,s,n,c,l,u,d,f,v,g.x,r,`bottom:${n}:${o}:p0`),C=X(e,t,s,n,c,l,u,d,p,y,_.x,r,`bottom:${n}:${o}:p1`);a.push([b,x,C],[b,C,S])}}for(let n=0;n<o-1;n+=1){let r=t[n][0],o=t[n][1],s=t[n+1][1],c=t[n+1][0];for(let l=0;l<i;l+=1){let u=l/i,d=(l+1)/i,f=Y(r,o,s,c,0,u),p=Y(r,o,s,c,0,d),m=Y(r,o,s,c,1,u),h=Y(r,o,s,c,1,d),g=Math.min(0,(0-f.x)/Math.max(m.x-f.x,1e-4)),_=Math.min(0,(0-p.x)/Math.max(h.x-p.x,1e-4)),v=X(e,t,n,0,r,o,s,c,0,u,f.x,f.y,`left:${n}:${l}:b0`),y=X(e,t,n,0,r,o,s,c,0,d,p.x,p.y,`left:${n}:${l}:b1`),b=X(e,t,n,0,r,o,s,c,g,u,0,f.y,`left:${n}:${l}:p0`),x=X(e,t,n,0,r,o,s,c,_,d,0,p.y,`left:${n}:${l}:p1`);a.push([b,v,y],[b,y,x])}}for(let r=0;r<o-1;r+=1){let o=s-2,c=t[r][o],l=t[r][o+1],u=t[r+1][o+1],d=t[r+1][o];for(let s=0;s<i;s+=1){let f=s/i,p=(s+1)/i,m=Y(c,l,u,d,0,f),h=Y(c,l,u,d,0,p),g=Y(c,l,u,d,1,f),_=Y(c,l,u,d,1,p),v=Math.max(1,(n-m.x)/Math.max(g.x-m.x,1e-4)),y=Math.max(1,(n-h.x)/Math.max(_.x-h.x,1e-4)),b=X(e,t,r,o,c,l,u,d,1,f,g.x,g.y,`right:${r}:${s}:b0`),x=X(e,t,r,o,c,l,u,d,1,p,_.x,_.y,`right:${r}:${s}:b1`),S=X(e,t,r,o,c,l,u,d,v,f,n,g.y,`right:${r}:${s}:p0`),C=X(e,t,r,o,c,l,u,d,y,p,n,_.y,`right:${r}:${s}:p1`);a.push([b,S,C],[b,C,x])}}return a}function da(e){return e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position)}function fa(e,t){if(e.length===0)throw Error(`Cannot sample color from empty diamond gradient stops.`);if(e.length===1||t<=e[0].position)return e[0].value;let n=e[e.length-1];if(t>=n.position)return n.value;for(let n=0;n<e.length-1;n+=1){let r=e[n],i=e[n+1];if(t>=r.position&&t<=i.position){let e=i.position-r.position||1,n=(t-r.position)/e;return U(G([r.value,i.value],`rgb`)(n))}}return n.value}function pa(e){return e.kind===`keywords`?{x:ma(e.x),y:ha(e.y)}:{x:ga(e.x,100),y:ga(e.y,100)}}function ma(e){return e===`left`?0:e===`right`?100:50}function ha(e){return e===`top`?0:e===`bottom`?100:50}function ga(e,t){if(e.kind===`percent`)return e.value/100*t;if(e.unit===`px`)return e.value;throw Error(`Unsupported diamond-gradient length unit for CSS transformer: ${e.unit}`)}function _a(e,t){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}function va(e){return[{dx:-e.x,dy:-e.y},{dx:100-e.x,dy:-e.y},{dx:-e.x,dy:100-e.y},{dx:100-e.x,dy:100-e.y}]}function ya(e,t,n,r){let i=Math.max(e,1e-4),a=Math.max(t,1e-4),o=Math.abs(n)/i+Math.abs(r)/a;return{x:i*o,y:a*o}}function ba(e,t){return Math.max(...[{x:0,y:0},{x:100,y:0},{x:0,y:100},{x:100,y:100}].map(n=>Math.abs(n.x-e.x)/Math.max(t.x,1e-4)+Math.abs(n.y-e.y)/Math.max(t.y,1e-4)))}function xa(e,t,n){if(e.kind===`explicit`){let n=ga(e.x,100),r=e.y?ga(e.y,100):n;return{x:Math.max(n,1e-4),y:Math.max(t===`circle`?n:r,1e-4)}}let r=n.x,i=100-n.x,a=n.y,o=100-n.y;if(t===`circle`){let t=[{x:0,y:0},{x:100,y:0},{x:0,y:100},{x:100,y:100}].map(e=>_a(n,e));if(e.value===`closest-side`){let e=Math.max(Math.min(r,i,a,o),1e-4);return{x:e,y:e}}if(e.value===`farthest-side`){let e=Math.max(Math.max(r,i,a,o),1e-4);return{x:e,y:e}}if(e.value===`closest-corner`){let e=Math.max(Math.min(...t),1e-4);return{x:e,y:e}}let s=Math.max(Math.max(...t),1e-4);return{x:s,y:s}}let s=Math.min(r,i),c=Math.min(a,o),l=Math.max(r,i),u=Math.max(a,o);if(e.value===`closest-side`)return{x:Math.max(s,1e-4),y:Math.max(c,1e-4)};if(e.value===`farthest-side`)return{x:Math.max(l,1e-4),y:Math.max(u,1e-4)};let d=va(n);return e.value===`closest-corner`?d.map(e=>ya(s,c,e.dx,e.dy)).reduce((e,t)=>t.x*t.y<e.x*e.y?t:e):d.map(e=>ya(l,u,e.dx,e.dy)).reduce((e,t)=>t.x*t.y>e.x*e.y?t:e)}function Z(e){return Number(e.toFixed(3)).toString()}function Sa(e,t,n){let r=t.x*n,i=t.y*n;return[`${Z(e.x)} ${Z(e.y-i)}`,`${Z(e.x+r)} ${Z(e.y)}`,`${Z(e.x)} ${Z(e.y+i)}`,`${Z(e.x-r)} ${Z(e.y)}`].join(` `)}function Ca(e){return`url("data:image/svg+xml,${encodeURIComponent(e)}")`}var wa=class{target=`css`;gradientType=`diamond-gradient`;to(e){if(!(e instanceof Ai))throw Error(`Expected DiamondGradient`);let t=pa(e.config.position),n=xa(e.config.size,e.config.shape,t),r=ba(t,n),i=e.isRepeating?r:1,a=q(e,96),o=da(e.isRepeating?K(a,0,r):a),s=fa(o,i),c=[],l=Math.max(96,Math.ceil(96*i));for(let e=l;e>=0;--e){let r=e/l*i,a=fa(o,r),s=Sa(t,n,r);c.push(`<polygon points="${s}" fill="${a}"/>`)}return Ca([`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none">`,`<rect width="100" height="100" fill="${s}"/>`,...c,`</svg>`].join(``))}},Ta=class{target=`css`;gradientType=`conic-gradient`;to(e){if(!(e instanceof ji))throw Error(`Expected ConicGradient`);return e.toString()}};function Ea(e){return`rgba(${e[0]},${e[1]},${e[2]},${Number(e[3].toFixed(3))})`}function Da(e,t,n,r,i){let a=(r.y-i.y)*(n.x-i.x)+(i.x-r.x)*(n.y-i.y);if(Math.abs(a)<1e-6)return null;let o=((r.y-i.y)*(e-i.x)+(i.x-r.x)*(t-i.y))/a,s=((i.y-n.y)*(e-i.x)+(n.x-i.x)*(t-i.y))/a,c=1-o-s;return o<-1e-4||s<-1e-4||c<-1e-4?null:[o,s,c]}function Oa(e,t,n,r){let[i,a,o]=e;return[Math.round((t.color[0]*i+n.color[0]*a+r.color[0]*o)*255),Math.round((t.color[1]*i+n.color[1]*a+r.color[1]*o)*255),Math.round((t.color[2]*i+n.color[2]*a+r.color[2]*o)*255),t.color[3]*i+n.color[3]*a+r.color[3]*o]}function ka(e){return`url("data:image/svg+xml,${encodeURIComponent(e)}")`}var Aa=class{target=`css`;gradientType=`mesh-gradient`;to(e){if(!(e instanceof Pi))throw Error(`Expected MeshGradient`);let t=Qi(e,96,96),n=$i(e,t),r=e.config.method===`bicubic`?24:1,i=e.patches.flatMap(i=>la(e,n,i,t,r)),a=ua(e,n,96,96,r),o=[...i,...a],s=[];for(let e=0;e<96;e+=1)for(let t=0;t<96;t+=1){let n=t+.5,r=e+.5,i=null;for(let[e,t,a]of o){let o=Da(n,r,e,t,a);if(o){i=Oa(o,e,t,a);break}}i&&s.push(`<rect x="${t}" y="${e}" width="1" height="1" fill="${Ea(i)}"/>`)}return ka([`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" preserveAspectRatio="none" shape-rendering="crispEdges">`,...s,`</svg>`].join(``))}};let ja=E(`rgb`);function Ma(e){let t=ja(e);if(!t)throw Error(`Failed to convert color: ${e}`);return U(t)}function Na(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 Pa(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 Fa=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}=Na(q(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,_=Pa(g,m,h)}let v=e.createLinearGradient(u,d,f,p);for(let e of _)v.addColorStop(e.position,Ma(e.value));e.clearRect(0,0,n,r),e.fillStyle=v,e.fillRect(0,0,n,r)}}}};let Ia=E(`rgb`);function La(e){let t=Ia(e);if(!t)throw Error(`Failed to convert color: ${e}`);return U(t)}function Ra(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 za(e,t,n){let r=n-t||1;return e.map(e=>({...e,position:(e.position-t)/r}))}function Ba(e,t,n,r){return r===`left`?e.x:r===`right`?t-e.x:r===`top`?e.y:n-e.y}function Va(e,t){let n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)}function Ha(e,t,n){return[{dx:-e.x,dy:-e.y},{dx:t-e.x,dy:-e.y},{dx:-e.x,dy:n-e.y},{dx:t-e.x,dy:n-e.y}]}function Ua(e,t,n,r){let i=Math.max(e,1e-4),a=Math.max(t,1e-4),o=Math.sqrt(n*n/(i*i)+r*r/(a*a));return{x:i*o,y:a*o}}var Wa=class{target=`canvas-2d`;gradientType=`radial-gradient`;to(e){let t=e;return{draw:(e,n,r)=>{let i=this._resolveCenter(t.config.position,n,r),a=this._resolveRadialRadii(t.config.size,t.config.shape,i,n,r),o=Vi(i,a,n,r),s=q(t,128),{min:c,max:l,stops:u}=Ra(t.isRepeating?K(s,0,o):s),d=u,f=0,p=t.isRepeating?o:1;if(t.isRepeating?d=za(u,0,o):(c<0||l>1)&&(d=za(u,c,l),f=c,p=l),t.config.shape===`circle`){let t=a.x,o=Math.max(0,t*f),s=Math.max(o+1e-4,t*p),c=e.createRadialGradient(i.x,i.y,o,i.x,i.y,s);for(let e of d)c.addColorStop(e.position,La(e.value));e.fillStyle=c,e.fillRect(0,0,n,r);return}let m=Math.max(a.x,a.y),h=a.x/m,g=a.y/m,_=Math.max(0,m*f),v=Math.max(_+1e-4,m*p);e.save(),e.translate(i.x,i.y),e.scale(h,g);let y=e.createRadialGradient(0,0,_,0,0,v);for(let e of d)y.addColorStop(e.position,La(e.value));e.fillStyle=y;let b=v+2;e.fillRect(-b/h*2,-b/g*2,b/h*4,b/g*4),e.restore()}}}_resolveCenter(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)}}_resolveKeywordX(e,t){return e===`left`?0:e===`center`?t/2:t}_resolveKeywordY(e,t){return e===`top`?0:e===`center`?t/2:t}_resolveRadialRadii(e,t,n,r,i){if(e.kind===`explicit`){let n=this._resolve(e.x,r),a=e.y?this._resolve(e.y,i):n;return{x:Math.max(n,1e-4),y:Math.max(t===`circle`?n:a,1e-4)}}let a=Ba(n,r,i,`left`),o=Ba(n,r,i,`right`),s=Ba(n,r,i,`top`),c=Ba(n,r,i,`bottom`);if(t===`circle`){let t=[{x:0,y:0},{x:r,y:0},{x:0,y:i},{x:r,y:i}].map(e=>Va(n,e));if(e.value===`closest-side`){let e=Math.min(a,o,s,c);return{x:e,y:e}}if(e.value===`farthest-side`){let e=Math.max(a,o,s,c);return{x:e,y:e}}if(e.value===`closest-corner`){let e=Math.min(...t);return{x:e,y:e}}let l=Math.max(...t);return{x:l,y:l}}let l=Math.min(a,o),u=Math.min(s,c),d=Math.max(a,o),f=Math.max(s,c);if(e.value===`closest-side`)return{x:Math.max(l,1e-4),y:Math.max(u,1e-4)};if(e.value===`farthest-side`)return{x:Math.max(d,1e-4),y:Math.max(f,1e-4)};let p=Ha(n,r,i);return e.value===`closest-corner`?p.map(e=>Ua(l,u,e.dx,e.dy)).reduce((e,t)=>{let n=e.x*e.y;return t.x*t.y<n?t:e}):p.map(e=>Ua(d,f,e.dx,e.dy)).reduce((e,t)=>{let n=e.x*e.y;return t.x*t.y>n?t:e})}_resolve(e,t){return e.kind===`percent`?e.value/100*t:(e.unit,e.value)}};let Ga=E(`rgb`),Ka=1024;function qa(e){let t=Ga(e);if(!t)throw Error(`Failed to convert color: ${e}`);return[Math.round((t.r??0)*255),Math.round((t.g??0)*255),Math.round((t.b??0)*255),Math.round((t.alpha??1)*255)]}function Ja(e){return e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position)}function Ya(e,t){if(e.length===0)throw Error(`Cannot sample color from empty diamond gradient stops.`);if(e.length===1||t<=e[0].position)return qa(e[0].value);let n=e[e.length-1];if(t>=n.position)return qa(n.value);for(let n=0;n<e.length-1;n+=1){let r=e[n],i=e[n+1];if(t>=r.position&&t<=i.position){let e=i.position-r.position||1,n=(t-r.position)/e,a=qa(r.value),o=qa(i.value);return[Math.round(a[0]+(o[0]-a[0])*n),Math.round(a[1]+(o[1]-a[1])*n),Math.round(a[2]+(o[2]-a[2])*n),Math.round(a[3]+(o[3]-a[3])*n)]}}return qa(n.value)}function Xa(e,t){let n=new Uint8ClampedArray(Ka*4);for(let r=0;r<Ka;r+=1){let i=Ya(e,r/(Ka-1)*t),a=r*4;n[a]=i[0],n[a+1]=i[1],n[a+2]=i[2],n[a+3]=i[3]}return n}function Za(e,t,n,r){return Math.max(...[{x:0,y:0},{x:n,y:0},{x:0,y:r},{x:n,y:r}].map(n=>Math.abs(n.x-e.x)/Math.max(t.x,1e-4)+Math.abs(n.y-e.y)/Math.max(t.y,1e-4)))}function Qa(e,t){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}function $a(e,t,n){return[{dx:-e.x,dy:-e.y},{dx:t-e.x,dy:-e.y},{dx:-e.x,dy:n-e.y},{dx:t-e.x,dy:n-e.y}]}function eo(e,t,n,r){let i=Math.max(e,1e-4),a=Math.max(t,1e-4),o=Math.abs(n)/i+Math.abs(r)/a;return{x:i*o,y:a*o}}var to=class{target=`canvas-2d`;gradientType=`diamond-gradient`;to(e){if(!(e instanceof Ai))throw Error(`Expected DiamondGradient`);let t=e;return{draw:(e,n,r)=>{let i=this._resolveCenter(t.config.position,n,r),a=this._resolveDiamondRadii(t.config.size,t.config.shape,i,n,r),o=Za(i,a,n,r),s=q(t,128),c=Xa(Ja(t.isRepeating?K(s,0,o):s),o),l=e.createImageData(n,r),u=l.data;for(let e=0;e<r;e+=1)for(let t=0;t<n;t+=1){let r=Math.abs(t-i.x)/Math.max(a.x,1e-4)+Math.abs(e-i.y)/Math.max(a.y,1e-4),s=Math.min(Ka-1,Math.max(0,Math.round(r/Math.max(o,1e-4)*(Ka-1))))*4,l=(e*n+t)*4;u[l]=c[s],u[l+1]=c[s+1],u[l+2]=c[s+2],u[l+3]=c[s+3]}e.putImageData(l,0,0)}}}_resolveCenter(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)}}_resolveKeywordX(e,t){return e===`left`?0:e===`center`?t/2:t}_resolveKeywordY(e,t){return e===`top`?0:e===`center`?t/2:t}_resolveDiamondRadii(e,t,n,r,i){if(e.kind===`explicit`){let n=this._resolve(e.x,r),a=e.y?this._resolve(e.y,i):n;return{x:Math.max(n,1e-4),y:Math.max(t===`circle`?n:a,1e-4)}}let a=n.x,o=r-n.x,s=n.y,c=i-n.y;if(t===`circle`){let t=[{x:0,y:0},{x:r,y:0},{x:0,y:i},{x:r,y:i}].map(e=>Qa(n,e));if(e.value===`closest-side`){let e=Math.max(Math.min(a,o,s,c),1e-4);return{x:e,y:e}}if(e.value===`farthest-side`){let e=Math.max(Math.max(a,o,s,c),1e-4);return{x:e,y:e}}if(e.value===`closest-corner`){let e=Math.max(Math.min(...t),1e-4);return{x:e,y:e}}let l=Math.max(Math.max(...t),1e-4);return{x:l,y:l}}let l=Math.min(a,o),u=Math.min(s,c),d=Math.max(a,o),f=Math.max(s,c);if(e.value===`closest-side`)return{x:Math.max(l,1e-4),y:Math.max(u,1e-4)};if(e.value===`farthest-side`)return{x:Math.max(d,1e-4),y:Math.max(f,1e-4)};let p=$a(n,r,i);return e.value===`closest-corner`?p.map(e=>eo(l,u,e.dx,e.dy)).reduce((e,t)=>t.x*t.y<e.x*e.y?t:e):p.map(e=>eo(d,f,e.dx,e.dy)).reduce((e,t)=>t.x*t.y>e.x*e.y?t:e)}_resolve(e,t){if(e.kind===`percent`)return e.value/100*t;if(e.unit===`px`)return e.value;throw Error(`Unsupported diamond-gradient length unit for Canvas transformer: ${e.unit}`)}};let no=E(`rgb`);var ro=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=q(t,128),u=this._normalizeStops(l);if(u.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,l=Math.atan2(i,r)+Math.PI/2-c;for(;l<0;)l+=Math.PI*2;for(;l>=Math.PI*2;)l-=Math.PI*2;let d=l/(Math.PI*2),f=this._sampleColor(u,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=no(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))}};function io(e,t,n,r,i){let a=(r.y-i.y)*(n.x-i.x)+(i.x-r.x)*(n.y-i.y);if(Math.abs(a)<1e-6)return null;let o=((r.y-i.y)*(e-i.x)+(i.x-r.x)*(t-i.y))/a,s=((i.y-n.y)*(e-i.x)+(n.x-i.x)*(t-i.y))/a,c=1-o-s,l=-1e-4;return o<l||s<l||c<l?null:[o,s,c]}function ao(e,t,n,r){let[i,a,o]=e;return[Math.round((t.color[0]*i+n.color[0]*a+r.color[0]*o)*255),Math.round((t.color[1]*i+n.color[1]*a+r.color[1]*o)*255),Math.round((t.color[2]*i+n.color[2]*a+r.color[2]*o)*255),Math.round((t.color[3]*i+n.color[3]*a+r.color[3]*o)*255)]}function oo(e,t,n,r,i,a){let o=Math.max(0,Math.floor(Math.min(r.x,i.x,a.x))),s=Math.min(t-1,Math.ceil(Math.max(r.x,i.x,a.x))),c=Math.max(0,Math.floor(Math.min(r.y,i.y,a.y))),l=Math.min(n-1,Math.ceil(Math.max(r.y,i.y,a.y)));for(let n=c;n<=l;n+=1)for(let c=o;c<=s;c+=1){let o=io(c+.5,n+.5,r,i,a);if(!o)continue;let s=ao(o,r,i,a),l=(n*t+c)*4;e[l]=s[0],e[l+1]=s[1],e[l+2]=s[2],e[l+3]=s[3]}}var so=class{target=`canvas-2d`;gradientType=`mesh-gradient`;to(e){if(!(e instanceof Pi))throw Error(`Expected MeshGradient`);let t=e;return{draw:(e,n,r)=>{let i=e.createImageData(n,r),a=Qi(t,n,r),o=$i(t,a),s=t.config.method===`bicubic`?24:1,c=ua(t,o,n,r,s);for(let e of t.patches){let c=la(t,o,e,a,s);for(let[e,t,a]of c)oo(i.data,n,r,e,t,a)}for(let[e,t,a]of c)oo(i.data,n,r,e,t,a);e.putImageData(i,0,0)}}}};let co=E(`rgb`);function lo(e){let t=co(e);if(!t)throw Error(`Failed to convert color: ${e}`);return[t.r??0,t.g??0,t.b??0,t.alpha??1]}function uo(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 fo(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 po(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 mo(e,t,n){let r=po(e,e.VERTEX_SHADER,t),i=po(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 ho(e){return e.filter(e=>e.type===`color-stop`).length}function go(e,t){let n=ho(e.stops),r=Math.max(1,n-1);return Math.max(2,Math.floor((t-1)/r))}function _o(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 U(G([r.value,i.value],`rgb`)(n))}}return r.value}function vo(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:_o(n,i),position:i})}return r}var yo=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=mo(i,`
|
|
5
5
|
attribute vec2 a_position;
|
|
6
6
|
varying vec2 v_uv;
|
|
7
7
|
|
|
@@ -57,7 +57,7 @@ var gradiente=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Mo
|
|
|
57
57
|
|
|
58
58
|
gl_FragColor = getGradientColor(t);
|
|
59
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}=
|
|
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}=uo(q(t,go(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=fo(b,v,y)}let S=m/n,C=1-h/r,ee=g/n,te=1-_/r,ne=vo(x,128),w=new Float32Array(128),T=new Float32Array(512);ne.forEach((e,t)=>{let n=lo(e.value);w[t]=e.position,T[t*4+0]=n[0],T[t*4+1]=n[1],T[t*4+2]=n[2],T[t*4+3]=n[3]}),i.uniform2f(i.getUniformLocation(a,`u_start`),S,C),i.uniform2f(i.getUniformLocation(a,`u_end`),ee,te),i.uniform1i(i.getUniformLocation(a,`u_stopCount`),ne.length),i.uniform1fv(i.getUniformLocation(a,`u_positions`),w),i.uniform4fv(i.getUniformLocation(a,`u_colors`),T),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.drawArrays(i.TRIANGLES,0,6)}}}};let bo=E(`rgb`),xo=Math.PI*2;function So(e){let t=bo(e);if(!t)throw Error(`Failed to convert color: ${e}`);return[t.r??0,t.g??0,t.b??0,t.alpha??1]}function Co(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 wo(e,t,n){let r=Co(e,e.VERTEX_SHADER,t),i=Co(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 To(e){return e.filter(e=>e.type===`color-stop`).length}function Eo(e,t){let n=To(e.stops),r=Math.max(1,n-1);return Math.max(2,Math.floor((t-1)/r))}function Do(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 U(G([r.value,i.value],`rgb`)(n))}}return r.value}function Oo(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:Do(n,i),position:i})}return r}function ko(e,t){if(e.kind===`percent`)return e.value/100*t;if(e.kind===`length`){if(e.unit===`px`)return e.value;throw Error(`Unsupported gradient length unit for WebGL conic gradient: ${e.unit}`)}return e}function Ao(e){return e.unit===`rad`?e.value:e.unit===`deg`?e.value/360*xo:e.unit===`turn`?e.value*xo:e.unit===`grad`?e.value/400*xo:e.unit}function jo(e,t){return e===`left`?0:e===`center`?t/2:e===`right`?t:t/2}function Mo(e,t){return e===`top`?0:e===`center`?t/2:e===`bottom`?t:t/2}function No(e,t,n){return e.kind===`keywords`?{x:jo(e.x,t),y:Mo(e.y,n)}:e.kind===`values`?{x:ko(e.x,t),y:ko(e.y,n)}:{x:t/2,y:n/2}}var Po=class{target=`canvas-webgl`;gradientType=`conic-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=wo(i,`
|
|
61
61
|
attribute vec2 a_position;
|
|
62
62
|
varying vec2 v_uv;
|
|
63
63
|
|
|
@@ -115,7 +115,7 @@ var gradiente=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Mo
|
|
|
115
115
|
|
|
116
116
|
gl_FragColor = getGradientColor(t);
|
|
117
117
|
}
|
|
118
|
-
`);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=
|
|
118
|
+
`);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=No(t.config.position,n,r),l=Oo(q(t,Eo(t,128)),128),u=new Float32Array(128),d=new Float32Array(512);l.forEach((e,t)=>{let n=So(e.value);u[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_center`),c.x/n,1-c.y/r),i.uniform1f(i.getUniformLocation(a,`u_startAngle`),Ao(t.config.from)),i.uniform1i(i.getUniformLocation(a,`u_stopCount`),l.length),i.uniform1fv(i.getUniformLocation(a,`u_positions`),u),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)}}}};let Fo=E(`rgb`);function Io(e){let t=Fo(e);if(!t)throw Error(`Failed to convert color: ${e}`);return[t.r??0,t.g??0,t.b??0,t.alpha??1]}function Lo(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 Ro(e,t,n){let r=Lo(e,e.VERTEX_SHADER,t),i=Lo(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 zo(e){return e.filter(e=>e.type===`color-stop`).length}function Bo(e,t){let n=zo(e.stops),r=Math.max(1,n-1);return Math.max(2,Math.floor((t-1)/r))}function Vo(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 U(G([r.value,i.value],`rgb`)(n))}}return r.value}function Ho(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:Vo(n,i),position:i})}return r}function Uo(e,t){if(e.kind===`percent`)return e.value/100*t;if(e.kind===`length`){if(e.unit===`px`)return e.value;throw Error(`Unsupported gradient length unit for WebGL radial gradient: ${e.unit}`)}return e}function Wo(e,t){return e===`left`?0:e===`center`?t/2:e===`right`?t:t/2}function Go(e,t){return e===`top`?0:e===`center`?t/2:e===`bottom`?t:t/2}function Ko(e,t,n){return e.kind===`keywords`?{x:Wo(e.x,t),y:Go(e.y,n)}:e.kind===`values`?{x:Uo(e.x,t),y:Uo(e.y,n)}:{x:t/2,y:n/2}}function qo(e,t,n,r){return r===`left`?e.x:r===`right`?t-e.x:r===`top`?e.y:n-e.y}function Jo(e,t){let n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)}function Yo(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 Xo(e,t,n){return[{dx:-e.x,dy:-e.y},{dx:t-e.x,dy:-e.y},{dx:-e.x,dy:n-e.y},{dx:t-e.x,dy:n-e.y}]}function Zo(e,t,n,r){let i=Math.max(e,1e-4),a=Math.max(t,1e-4),o=Math.sqrt(n*n/(i*i)+r*r/(a*a));return{x:i*o,y:a*o}}function Qo(e,t,n,r,i){if(e.kind===`explicit`){let n=Uo(e.x,r),a=e.y?Uo(e.y,i):n;return{x:Math.max(n,1e-4),y:Math.max(t===`circle`?n:a,1e-4)}}let a=qo(n,r,i,`left`),o=qo(n,r,i,`right`),s=qo(n,r,i,`top`),c=qo(n,r,i,`bottom`);if(t===`circle`){let t=[{x:0,y:0},{x:r,y:0},{x:0,y:i},{x:r,y:i}].map(e=>Jo(n,e));if(e.value===`closest-side`){let e=Math.max(Math.min(a,o,s,c),1e-4);return{x:e,y:e}}if(e.value===`farthest-side`){let e=Math.max(Math.max(a,o,s,c),1e-4);return{x:e,y:e}}if(e.value===`closest-corner`){let e=Math.max(Math.min(...t),1e-4);return{x:e,y:e}}let l=Math.max(Math.max(...t),1e-4);return{x:l,y:l}}let l=Math.min(a,o),u=Math.min(s,c),d=Math.max(a,o),f=Math.max(s,c);if(e.value===`closest-side`)return{x:Math.max(l,1e-4),y:Math.max(u,1e-4)};if(e.value===`farthest-side`)return{x:Math.max(d,1e-4),y:Math.max(f,1e-4)};let p=Xo(n,r,i);return e.value===`closest-corner`?p.map(e=>Zo(l,u,e.dx,e.dy)).reduce((e,t)=>{let n=e.x*e.y;return t.x*t.y<n?t:e}):p.map(e=>Zo(d,f,e.dx,e.dy)).reduce((e,t)=>{let n=e.x*e.y;return t.x*t.y>n?t:e})}var $o=class{target=`canvas-webgl`;gradientType=`radial-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=Ro(i,`
|
|
119
119
|
attribute vec2 a_position;
|
|
120
120
|
varying vec2 v_uv;
|
|
121
121
|
|
|
@@ -171,7 +171,7 @@ var gradiente=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Mo
|
|
|
171
171
|
|
|
172
172
|
gl_FragColor = getGradientColor(t);
|
|
173
173
|
}
|
|
174
|
-
`);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=
|
|
174
|
+
`);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=Ko(t.config.position,n,r),l=Qo(t.config.size,t.config.shape,c,n,r),u=Vi(c,l,n,r),d=q(t,Bo(t,128)),f=Math.min(u,16),p=t.isRepeating?f:1,m=t.isRepeating?K(d,0,f):d,h=Ho(t.isRepeating?Yo(m,0,f):m,128),g=new Float32Array(128),_=new Float32Array(512);h.forEach((e,t)=>{let n=Io(e.value);g[t]=e.position,_[t*4+0]=n[0],_[t*4+1]=n[1],_[t*4+2]=n[2],_[t*4+3]=n[3]}),i.uniform2f(i.getUniformLocation(a,`u_center`),c.x/n,1-c.y/r),i.uniform2f(i.getUniformLocation(a,`u_radius`),l.x/n,l.y/r),i.uniform1f(i.getUniformLocation(a,`u_tMax`),p),i.uniform1i(i.getUniformLocation(a,`u_stopCount`),h.length),i.uniform1fv(i.getUniformLocation(a,`u_positions`),g),i.uniform4fv(i.getUniformLocation(a,`u_colors`),_),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.drawArrays(i.TRIANGLES,0,6)}}}};let es=E(`rgb`);function ts(e){let t=es(e);if(!t)throw Error(`Failed to convert color: ${e}`);return[t.r??0,t.g??0,t.b??0,t.alpha??1]}function ns(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 rs(e,t,n){let r=ns(e,e.VERTEX_SHADER,t),i=ns(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 is(e){return e.filter(e=>e.type===`color-stop`).length}function as(e,t){let n=is(e.stops),r=Math.max(1,n-1);return Math.max(2,Math.floor((t-1)/r))}function os(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 diamond 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 U(G([r.value,i.value],`rgb`)(n))}}return r.value}function ss(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:os(n,i),position:i})}return r}function cs(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 ls(e,t){if(e.kind===`percent`)return e.value/100*t;if(e.unit===`px`)return e.value;throw Error(`Unsupported diamond-gradient length unit for WebGL transformer: ${e.unit}`)}function us(e,t){return e===`left`?0:e===`right`?t:t/2}function ds(e,t){return e===`top`?0:e===`bottom`?t:t/2}function fs(e,t,n){return e.kind===`keywords`?{x:us(e.x,t),y:ds(e.y,n)}:{x:ls(e.x,t),y:ls(e.y,n)}}function ps(e,t){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}function ms(e,t,n){return[{dx:-e.x,dy:-e.y},{dx:t-e.x,dy:-e.y},{dx:-e.x,dy:n-e.y},{dx:t-e.x,dy:n-e.y}]}function hs(e,t,n,r){let i=Math.max(e,1e-4),a=Math.max(t,1e-4),o=Math.abs(n)/i+Math.abs(r)/a;return{x:i*o,y:a*o}}function gs(e,t,n,r,i){if(e.kind===`explicit`){let n=ls(e.x,r),a=e.y?ls(e.y,i):n;return{x:Math.max(n,1e-4),y:Math.max(t===`circle`?n:a,1e-4)}}let a=n.x,o=r-n.x,s=n.y,c=i-n.y;if(t===`circle`){let t=[{x:0,y:0},{x:r,y:0},{x:0,y:i},{x:r,y:i}].map(e=>ps(n,e));if(e.value===`closest-side`){let e=Math.max(Math.min(a,o,s,c),1e-4);return{x:e,y:e}}if(e.value===`farthest-side`){let e=Math.max(Math.max(a,o,s,c),1e-4);return{x:e,y:e}}if(e.value===`closest-corner`){let e=Math.max(Math.min(...t),1e-4);return{x:e,y:e}}let l=Math.max(Math.max(...t),1e-4);return{x:l,y:l}}let l=Math.min(a,o),u=Math.min(s,c),d=Math.max(a,o),f=Math.max(s,c);if(e.value===`closest-side`)return{x:Math.max(l,1e-4),y:Math.max(u,1e-4)};if(e.value===`farthest-side`)return{x:Math.max(d,1e-4),y:Math.max(f,1e-4)};let p=ms(n,r,i);return e.value===`closest-corner`?p.map(e=>hs(l,u,e.dx,e.dy)).reduce((e,t)=>t.x*t.y<e.x*e.y?t:e):p.map(e=>hs(d,f,e.dx,e.dy)).reduce((e,t)=>t.x*t.y>e.x*e.y?t:e)}function _s(e,t,n,r){return Math.max(...[{x:0,y:0},{x:n,y:0},{x:0,y:r},{x:n,y:r}].map(n=>Math.abs(n.x-e.x)/Math.max(t.x,1e-4)+Math.abs(n.y-e.y)/Math.max(t.y,1e-4)))}var vs=class{target=`canvas-webgl`;gradientType=`diamond-gradient`;to(e){if(!(e instanceof Ai))throw Error(`Expected DiamondGradient`);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=rs(i,`
|
|
175
175
|
attribute vec2 a_position;
|
|
176
176
|
varying vec2 v_uv;
|
|
177
177
|
|
|
@@ -227,7 +227,7 @@ var gradiente=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Mo
|
|
|
227
227
|
|
|
228
228
|
gl_FragColor = getGradientColor(t);
|
|
229
229
|
}
|
|
230
|
-
`);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=
|
|
230
|
+
`);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=fs(t.config.position,n,r),l=gs(t.config.size,t.config.shape,c,n,r),u=_s(c,l,n,r),d=q(t,as(t,128)),f=Math.min(u,16),p=t.isRepeating?f:1,m=t.isRepeating?K(d,0,f):d,h=ss(t.isRepeating?cs(m,0,f):m,128),g=new Float32Array(128),_=new Float32Array(512);h.forEach((e,t)=>{let n=ts(e.value);g[t]=e.position,_[t*4+0]=n[0],_[t*4+1]=n[1],_[t*4+2]=n[2],_[t*4+3]=n[3]}),i.uniform2f(i.getUniformLocation(a,`u_center`),c.x/n,1-c.y/r),i.uniform2f(i.getUniformLocation(a,`u_radius`),l.x/n,l.y/r),i.uniform1f(i.getUniformLocation(a,`u_tMax`),p),i.uniform1i(i.getUniformLocation(a,`u_stopCount`),h.length),i.uniform1fv(i.getUniformLocation(a,`u_positions`),g),i.uniform4fv(i.getUniformLocation(a,`u_colors`),_),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.drawArrays(i.TRIANGLES,0,6)}}}};function ys(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 bs(e,t,n){let r=ys(e,e.VERTEX_SHADER,t),i=ys(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 xs(e,t){return e/t*2-1}function Ss(e,t){return 1-e/t*2}var Cs=class{target=`canvas-webgl`;gradientType=`mesh-gradient`;to(e){if(!(e instanceof Pi))throw Error(`Expected MeshGradient`);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=bs(i,`
|
|
231
231
|
attribute vec2 a_position;
|
|
232
232
|
attribute vec4 a_color;
|
|
233
233
|
varying vec4 v_color;
|
|
@@ -243,4 +243,4 @@ var gradiente=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Mo
|
|
|
243
243
|
void main() {
|
|
244
244
|
gl_FragColor = v_color;
|
|
245
245
|
}
|
|
246
|
-
`),o=Xi(t,n,r),s=Zi(t,o),c=t.config.method===`bicubic`?24:1,l=ca(t,s,n,r,c),u=[],d=[];for(let e of t.patches){let i=sa(t,s,e,o,c);for(let e of i)for(let t of e)u.push(ys(t.x,n),bs(t.y,r)),d.push(...t.color)}for(let e of l)for(let t of e)u.push(ys(t.x,n),bs(t.y,r)),d.push(...t.color);let f=i.createBuffer(),p=i.createBuffer();i.useProgram(a),i.bindBuffer(i.ARRAY_BUFFER,f),i.bufferData(i.ARRAY_BUFFER,new Float32Array(u),i.STATIC_DRAW);let m=i.getAttribLocation(a,`a_position`);i.enableVertexAttribArray(m),i.vertexAttribPointer(m,2,i.FLOAT,!1,0,0),i.bindBuffer(i.ARRAY_BUFFER,p),i.bufferData(i.ARRAY_BUFFER,new Float32Array(d),i.STATIC_DRAW);let h=i.getAttribLocation(a,`a_color`);i.enableVertexAttribArray(h),i.vertexAttribPointer(h,4,i.FLOAT,!1,0,0),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.drawArrays(i.TRIANGLES,0,u.length/2)}}}},Ss=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`?Cs.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 Mi),this.add(new Ni),this.add(new Sa),this.add(new Ca),this.add(new Oa),this.add(new Na),this.add(new Ha),this.add(new $a),this.add(new to),this.add(new ao),this.add(new _o),this.add(new Zo),this.add(new gs),this.add(new Mo),this.add(new xs))}static _getKey(e,t){return`${e}:${t}`}},Cs=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){if(typeof e==`string`){let t=this._getFunctionName(e),n=this.get(t);if(!n)throw Error(`No gradient registered for: ${t}`);return n.fromString(e)}let t=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`,Ti),this.add(`radial-gradient`,Ei),this.add(`diamond-gradient`,Di),this.add(`conic-gradient`,Oi),this.add(`mesh-gradient`,ji))}static _getFunctionName(e){let t=e.trim(),n=t.indexOf(`(`);if(n<=0)throw Error(`Expected function opening parenthesis`);let r=t.slice(0,n).trim();return r.startsWith(`repeating-`)&&(r=r.slice(10)),r}};function ws(e){return Cs.create(e)}function Ts(e){return Cs.isValid(e)}function Es(e){return typeof e==`string`?ws(e).toString():e.toString()}function Ds(e,t){let n=typeof t==`string`?ws(t):t;return Ss.to(e,n)}function Os(e,t,n){return Ss.from(e,t,n)}return e.ConicGradient=Oi,e.DiamondGradient=Di,e.GRADIENT_COLOR_SPACE=vi,e.GRADIENT_HUE_INTERPOLATIONS=yi,e.GRADIENT_POLAR_COLOR_SPACES=bi,e.GradientBase=wi,e.GradientFactory=Cs,e.GradientTransformer=Ss,e.LinearGradient=Ti,e.MeshGradient=ji,e.ModuleTransformerConicGradientToCanvas=to,e.ModuleTransformerConicGradientToCanvasWebGL=Mo,e.ModuleTransformerConicGradientToCss=Ca,e.ModuleTransformerDiamondGradientToCanvas=$a,e.ModuleTransformerDiamondGradientToCanvasWebGL=gs,e.ModuleTransformerDiamondGradientToCss=Sa,e.ModuleTransformerLinearGradientToCanvas=Na,e.ModuleTransformerLinearGradientToCanvasWebGL=_o,e.ModuleTransformerLinearGradientToCss=Mi,e.ModuleTransformerMeshGradientToCanvas=ao,e.ModuleTransformerMeshGradientToCanvasWebGL=xs,e.ModuleTransformerMeshGradientToCss=Oa,e.ModuleTransformerRadialGradientToCanvas=Ha,e.ModuleTransformerRadialGradientToCanvasWebGL=Zo,e.ModuleTransformerRadialGradientToCss=Ni,e.PatternTokenKind=Hr,e.RadialGradient=Ei,e.angleValueFromString=u,e.ceilTo=r,e.clamp=a,e.degToRad=d,e.floorTo=n,e.format=Es,e.fromPercent=s,e.gradToRad=m,e.isAngle=l,e.isAngleUnit=c,e.isColorHint=li,e.isColorStop=ui,e.isConfig=di,e.isGradient=Ts,e.isGradientColorSpace=Si,e.isGradientHueInterpolation=xi,e.isGradientPolarColorSpace=Ci,e.isPatternSyntaxValid=ti,e.isPatternValid=$r,e.isValid=oi,e.matchExpression=Ur,e.normalizeAngleDeg=h,e.normalizeAngleRad=g,e.parse=ws,e.parseStringToAbi=ci,e.radToDeg=f,e.roundTo=t,e.splitTopLevelByWhitespace=_i,e.toPercent=o,e.tokenizePattern=ai,e.transformFrom=Os,e.transformTo=Ds,e.truncTo=i,e.turnToRad=p,e.validate=si,e.validatePattern=Qr,e.validatePatternSemantic=ri,e.validatePatternStructure=ii,e.validatePatternSyntax=ei,e})({});
|
|
246
|
+
`),o=Qi(t,n,r),s=$i(t,o),c=t.config.method===`bicubic`?24:1,l=ua(t,s,n,r,c),u=[],d=[];for(let e of t.patches){let i=la(t,s,e,o,c);for(let e of i)for(let t of e)u.push(xs(t.x,n),Ss(t.y,r)),d.push(...t.color)}for(let e of l)for(let t of e)u.push(xs(t.x,n),Ss(t.y,r)),d.push(...t.color);let f=i.createBuffer(),p=i.createBuffer();i.useProgram(a),i.bindBuffer(i.ARRAY_BUFFER,f),i.bufferData(i.ARRAY_BUFFER,new Float32Array(u),i.STATIC_DRAW);let m=i.getAttribLocation(a,`a_position`);i.enableVertexAttribArray(m),i.vertexAttribPointer(m,2,i.FLOAT,!1,0,0),i.bindBuffer(i.ARRAY_BUFFER,p),i.bufferData(i.ARRAY_BUFFER,new Float32Array(d),i.STATIC_DRAW);let h=i.getAttribLocation(a,`a_color`);i.enableVertexAttribArray(h),i.vertexAttribPointer(h,4,i.FLOAT,!1,0,0),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.drawArrays(i.TRIANGLES,0,u.length/2)}}}};let ws=E(`rgb`);function Ts(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`"`,`"`)}function Es(e){return Math.min(1,Math.max(0,e))}function Ds(e){return`${Number((e*100).toFixed(3))}%`}function Os(e){return`${Number(e.toFixed(3))}%`}function ks(e){return e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position)}function As(e){let t=ws(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)}}function js(e){return e.a>=255?`rgb(${e.r} ${e.g} ${e.b})`:`rgba(${e.r}, ${e.g}, ${e.b}, ${Number((e.a/255).toFixed(4))})`}function Ms(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)}}function Ns(e,t){let n=ks(e);if(n.length===0)throw Error(`Cannot sample color from empty gradient stops.`);if(n.length===1)return As(n[0].value);let r=n[0],i=[...n,{...r,position:r.position+1}],a=t;a<r.position&&(a+=1);for(let e=0;e<i.length-1;e+=1){let t=i[e],n=i[e+1];if(a>=t.position&&a<=n.position){let e=n.position-t.position||1,r=(a-t.position)/e;return Ms(As(t.value),As(n.value),r)}}return As(n[n.length-1].value)}function Ps(e){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`}function Fs(e){return ks(q(e,128)).map(e=>`<stop offset="${Ds(Es(e.position))}" stop-color="${Ts(e.value)}"/>`).join(``)}function Is(e){let t=`<defs>${e.gradient}</defs>`;return{id:e.id,href:`#${e.id}`,url:`url(#${e.id})`,type:e.type,gradient:e.gradient,defs:t,svg:`<svg xmlns="http://www.w3.org/2000/svg">${t}</svg>`}}function Ls(e){let t=Math.sin(e),n=-Math.cos(e),r=Math.max(Math.abs(t),Math.abs(n),1e-4),i=t/r,a=n/r;return{x1:50-i*50,y1:50-a*50,x2:50+i*50,y2:50+a*50}}var Rs=class{target=`svg`;gradientType=`linear-gradient`;to(e){if(!(e instanceof Oi))throw Error(`Expected LinearGradient`);let t=`gradiente-linear-gradient`,n=Ls(e.config.angle),r=Fs(e);return Is({id:t,type:`linearGradient`,gradient:[`<linearGradient id="${t}" gradientUnits="objectBoundingBox" x1="${Os(n.x1)}" y1="${Os(n.y1)}" x2="${Os(n.x2)}" y2="${Os(n.y2)}">`,r,`</linearGradient>`].join(``)})}};function zs(e){return e===`left`?0:e===`right`?100:50}function Bs(e){return e===`top`?0:e===`bottom`?100:50}function Vs(e){return e.kind===`percent`||e.unit,e.value}function Hs(e){return e.kind===`keywords`?{x:zs(e.x),y:Bs(e.y)}:{x:Vs(e.x),y:Vs(e.y)}}function Us(e,t){let n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)}function Ws(e,t,n){if(e.kind===`explicit`){let n=Vs(e.x),r=e.y?Vs(e.y):n;return{x:Math.max(n,1e-4),y:Math.max(t===`circle`?n:r,1e-4)}}let r=n.x,i=100-n.x,a=n.y,o=100-n.y;if(t===`circle`){let t=[{x:0,y:0},{x:100,y:0},{x:0,y:100},{x:100,y:100}].map(e=>Us(n,e));if(e.value===`closest-side`){let e=Math.min(r,i,a,o);return{x:e,y:e}}if(e.value===`farthest-side`){let e=Math.max(r,i,a,o);return{x:e,y:e}}if(e.value===`closest-corner`){let e=Math.min(...t);return{x:e,y:e}}let s=Math.max(...t);return{x:s,y:s}}return e.value===`closest-side`?{x:Math.min(r,i),y:Math.min(a,o)}:(e.value,{x:Math.max(r,i),y:Math.max(a,o)})}var Gs=class{target=`svg`;gradientType=`radial-gradient`;to(e){if(!(e instanceof ki))throw Error(`Expected RadialGradient`);let t=`gradiente-radial-gradient`,n=Hs(e.config.position),r=Ws(e.config.size,e.config.shape,n),i=Math.max(r.x,r.y),a=r.x/i,o=r.y/i,s=e.config.shape===`ellipse`?` gradientTransform="translate(${n.x} ${n.y}) scale(${a} ${o}) translate(${-n.x} ${-n.y})"`:``;return Is({id:t,type:`radialGradient`,gradient:[`<radialGradient id="${t}" gradientUnits="objectBoundingBox" cx="${Os(n.x)}" cy="${Os(n.y)}" r="${Os(i)}"${s}>`,Fs(e),`</radialGradient>`].join(``)})}};let Ks=Math.PI*2;function qs(e,t){return e===`left`?0:e===`right`?t:t/2}function Js(e,t){return e===`top`?0:e===`bottom`?t:t/2}function Ys(e,t){return e.kind===`percent`?e.value/100*t:(e.unit,e.value)}function Xs(e,t){return e.kind===`keywords`?{x:qs(e.x,t),y:Js(e.y,t)}:{x:Ys(e.x,t),y:Ys(e.y,t)}}function Zs(e){return e.unit===`deg`?d(e.value):e.unit===`turn`?p(e.value):e.unit===`grad`?m(e.value):e.value}function Qs(e,t){let n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)}function $s(e){return Math.max(...[{x:0,y:0},{x:100,y:0},{x:0,y:100},{x:100,y:100}].map(t=>Qs(e,t)))*1.02}function ec(e,t,n){return{x:e.x+Math.sin(n)*t,y:e.y-Math.cos(n)*t}}function Q(e){return`${Number(e.toFixed(3))}`}var tc=class{target=`svg`;gradientType=`conic-gradient`;to(e){if(!(e instanceof ji))throw Error(`Expected ConicGradient`);let t=`gradiente-conic-gradient`,n=Xs(e.config.position,100),r=Zs(e.config.from),i=q(e,128),a=$s(n),o=[];for(let e=0;e<720;e+=1){let t=e/720,s=(e+1)/720,c=js(Ns(i,t+(s-t)/2)),l=ec(n,a,t*Ks+r),u=ec(n,a,s*Ks+r);o.push([`<path d="M ${Q(n.x)} ${Q(n.y)}`,`L ${Q(l.x)} ${Q(l.y)}`,`A ${Q(a)} ${Q(a)} 0 0 1 ${Q(u.x)} ${Q(u.y)}`,`Z" fill="${c}" stroke="${c}" stroke-width="0.25"/>`].join(` `))}let s=[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100">`,...o,`</svg>`].join(``);return Is({id:t,type:`pattern`,gradient:[`<pattern id="${t}" patternUnits="objectBoundingBox" width="1" height="1" viewBox="0 0 100 100" preserveAspectRatio="none">`,`<image width="100" height="100" href="${Ts(Ps(s))}"/>`,`</pattern>`].join(``)})}};function nc(e){return e===`left`?0:e===`right`?100:100/2}function rc(e){return e===`top`?0:e===`bottom`?100:100/2}function ic(e){if(e.kind===`percent`)return e.value/100*100;if(e.unit===`px`)return e.value;throw Error(`Unsupported diamond-gradient length unit for SVG transformer: ${e.unit}`)}function ac(e){return e.kind===`keywords`?{x:nc(e.x),y:rc(e.y)}:{x:ic(e.x),y:ic(e.y)}}function oc(e,t){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}function sc(e){return[{dx:-e.x,dy:-e.y},{dx:100-e.x,dy:-e.y},{dx:-e.x,dy:100-e.y},{dx:100-e.x,dy:100-e.y}]}function cc(e,t,n,r){let i=Math.max(e,1e-4),a=Math.max(t,1e-4),o=Math.abs(n)/i+Math.abs(r)/a;return{x:i*o,y:a*o}}function lc(e,t,n){if(e.kind===`explicit`){let n=ic(e.x),r=e.y?ic(e.y):n;return{x:Math.max(n,1e-4),y:Math.max(t===`circle`?n:r,1e-4)}}let r=n.x,i=100-n.x,a=n.y,o=100-n.y;if(t===`circle`){let t=[{x:0,y:0},{x:100,y:0},{x:0,y:100},{x:100,y:100}].map(e=>oc(n,e));if(e.value===`closest-side`){let e=Math.max(Math.min(r,i,a,o),1e-4);return{x:e,y:e}}if(e.value===`farthest-side`){let e=Math.max(Math.max(r,i,a,o),1e-4);return{x:e,y:e}}if(e.value===`closest-corner`){let e=Math.max(Math.min(...t),1e-4);return{x:e,y:e}}let s=Math.max(Math.max(...t),1e-4);return{x:s,y:s}}let s=Math.min(r,i),c=Math.min(a,o),l=Math.max(r,i),u=Math.max(a,o);if(e.value===`closest-side`)return{x:Math.max(s,1e-4),y:Math.max(c,1e-4)};if(e.value===`farthest-side`)return{x:Math.max(l,1e-4),y:Math.max(u,1e-4)};let d=sc(n);return e.value===`closest-corner`?d.map(e=>cc(s,c,e.dx,e.dy)).reduce((e,t)=>t.x*t.y<e.x*e.y?t:e):d.map(e=>cc(l,u,e.dx,e.dy)).reduce((e,t)=>t.x*t.y>e.x*e.y?t:e)}function uc(e,t){return Math.max(...[{x:0,y:0},{x:100,y:0},{x:0,y:100},{x:100,y:100}].map(n=>Math.abs(n.x-e.x)/Math.max(t.x,1e-4)+Math.abs(n.y-e.y)/Math.max(t.y,1e-4)))}function dc(e){return e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position)}function $(e){return`${Number(e.toFixed(3))}`}function fc(e,t,n){let r=t.x*n,i=t.y*n;return[`${$(e.x)} ${$(e.y-i)}`,`${$(e.x+r)} ${$(e.y)}`,`${$(e.x)} ${$(e.y+i)}`,`${$(e.x-r)} ${$(e.y)}`].join(` `)}var pc=class{target=`svg`;gradientType=`diamond-gradient`;to(e){if(!(e instanceof Ai))throw Error(`Expected DiamondGradient`);let t=`gradiente-diamond-gradient`,n=ac(e.config.position),r=lc(e.config.size,e.config.shape,n),i=uc(n,r),a=e.isRepeating?i:1,o=q(e,128),s=dc(e.isRepeating?K(o,0,i):o),c=js(Ns(s,a)),l=Math.max(128,Math.ceil(128*a)),u=[];for(let e=l;e>=0;--e){let t=e/l*a,i=js(Ns(s,t)),o=fc(n,r,t);u.push(`<polygon points="${o}" fill="${i}"/>`)}let d=[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100" preserveAspectRatio="none">`,`<rect width="100" height="100" fill="${c}"/>`,...u,`</svg>`].join(``);return Is({id:t,type:`pattern`,gradient:[`<pattern id="${t}" patternUnits="objectBoundingBox" width="1" height="1" viewBox="0 0 100 100" preserveAspectRatio="none">`,`<image width="100" height="100" href="${Ts(Ps(d))}"/>`,`</pattern>`].join(``)})}};function mc(e){return`rgba(${e[0]}, ${e[1]}, ${e[2]}, ${Number(e[3].toFixed(4))})`}function hc(e,t,n){return[Math.round((e.color[0]+t.color[0]+n.color[0])/3*255),Math.round((e.color[1]+t.color[1]+n.color[1])/3*255),Math.round((e.color[2]+t.color[2]+n.color[2])/3*255),(e.color[3]+t.color[3]+n.color[3])/3]}function gc(e){return`${Number(e.toFixed(3))}`}function _c(e){let[t,n,r]=e,i=mc(hc(t,n,r));return`<polygon points="${[`${gc(t.x)} ${gc(t.y)}`,`${gc(n.x)} ${gc(n.y)}`,`${gc(r.x)} ${gc(r.y)}`].join(` `)}" fill="${i}" stroke="${i}" stroke-width="0.08"/>`}var vc=class{target=`svg`;gradientType=`mesh-gradient`;to(e){if(!(e instanceof Pi))throw Error(`Expected MeshGradient`);let t=`gradiente-mesh-gradient`,n=Qi(e,100,100),r=$i(e,n),i=e.config.method===`bicubic`?40:32,a=e.patches.flatMap(t=>la(e,r,t,n,i)),o=ua(e,r,100,100,i),s=[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100" preserveAspectRatio="none">`,...[...a,...o].map(_c),`</svg>`].join(``);return Is({id:t,type:`pattern`,gradient:[`<pattern id="${t}" patternUnits="objectBoundingBox" width="1" height="1" viewBox="0 0 100 100" preserveAspectRatio="none">`,`<image width="100" height="100" href="${Ts(Ps(s))}"/>`,`</pattern>`].join(``)})}},yc=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`?bc.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 Fi),this.add(new Ii),this.add(new wa),this.add(new Ta),this.add(new Aa),this.add(new Fa),this.add(new Wa),this.add(new to),this.add(new ro),this.add(new so),this.add(new yo),this.add(new $o),this.add(new vs),this.add(new Po),this.add(new Cs),this.add(new Rs),this.add(new Gs),this.add(new tc),this.add(new pc),this.add(new vc))}static _getKey(e,t){return`${e}:${t}`}},bc=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){if(typeof e==`string`){let t=this._getFunctionName(e),n=this.get(t);if(!n)throw Error(`No gradient registered for: ${t}`);return n.fromString(e)}let t=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`,Oi),this.add(`radial-gradient`,ki),this.add(`diamond-gradient`,Ai),this.add(`conic-gradient`,ji),this.add(`mesh-gradient`,Pi))}static _getFunctionName(e){let t=e.trim(),n=t.indexOf(`(`);if(n<=0)throw Error(`Expected function opening parenthesis`);let r=t.slice(0,n).trim();return r.startsWith(`repeating-`)&&(r=r.slice(10)),r}};function xc(e){return bc.create(e)}function Sc(e){return bc.isValid(e)}function Cc(e){return typeof e==`string`?xc(e).toString():e.toString()}function wc(e,t){let n=typeof t==`string`?xc(t):t;return yc.to(e,n)}function Tc(e,t,n){return yc.from(e,t,n)}return e.ConicGradient=ji,e.DiamondGradient=Ai,e.GRADIENT_COLOR_SPACE=xi,e.GRADIENT_HUE_INTERPOLATIONS=Si,e.GRADIENT_POLAR_COLOR_SPACES=Ci,e.GradientBase=Di,e.GradientFactory=bc,e.GradientTransformer=yc,e.LinearGradient=Oi,e.MeshGradient=Pi,e.ModuleTransformerConicGradientToCanvas=ro,e.ModuleTransformerConicGradientToCanvasWebGL=Po,e.ModuleTransformerConicGradientToCss=Ta,e.ModuleTransformerConicGradientToSvg=tc,e.ModuleTransformerDiamondGradientToCanvas=to,e.ModuleTransformerDiamondGradientToCanvasWebGL=vs,e.ModuleTransformerDiamondGradientToCss=wa,e.ModuleTransformerDiamondGradientToSvg=pc,e.ModuleTransformerLinearGradientToCanvas=Fa,e.ModuleTransformerLinearGradientToCanvasWebGL=yo,e.ModuleTransformerLinearGradientToCss=Fi,e.ModuleTransformerLinearGradientToSvg=Rs,e.ModuleTransformerMeshGradientToCanvas=so,e.ModuleTransformerMeshGradientToCanvasWebGL=Cs,e.ModuleTransformerMeshGradientToCss=Aa,e.ModuleTransformerMeshGradientToSvg=vc,e.ModuleTransformerRadialGradientToCanvas=Wa,e.ModuleTransformerRadialGradientToCanvasWebGL=$o,e.ModuleTransformerRadialGradientToCss=Ii,e.ModuleTransformerRadialGradientToSvg=Gs,e.PatternTokenKind=Gr,e.RadialGradient=ki,e.angleValueFromString=u,e.ceilTo=r,e.clamp=a,e.degToRad=d,e.floorTo=n,e.format=Cc,e.fromPercent=s,e.gradToRad=m,e.isAngle=l,e.isAngleUnit=c,e.isColorHint=fi,e.isColorStop=pi,e.isConfig=mi,e.isGradient=Sc,e.isGradientColorSpace=Ti,e.isGradientHueInterpolation=wi,e.isGradientPolarColorSpace=Ei,e.isPatternSyntaxValid=ii,e.isPatternValid=ni,e.isValid=li,e.matchExpression=Kr,e.normalizeAngleDeg=h,e.normalizeAngleRad=g,e.parse=xc,e.parseStringToAbi=di,e.radToDeg=f,e.roundTo=t,e.splitTopLevelByWhitespace=bi,e.toPercent=o,e.tokenizePattern=ci,e.transformFrom=Tc,e.transformTo=wc,e.truncTo=i,e.turnToRad=p,e.validate=ui,e.validatePattern=ti,e.validatePatternSemantic=oi,e.validatePatternStructure=si,e.validatePatternSyntax=ri,e})({});
|