saturon 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/Color.d.ts +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/math.js +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/utils.d.ts +22 -5
- package/dist/utils.js +29 -1
- package/package.json +1 -1
- package/dist/tests/Color.test.d.ts +0 -17
- package/dist/tests/Color.test.js +0 -1545
- package/dist/tests/wpt.test.d.ts +0 -1
- package/dist/tests/wpt.test.js +0 -2107
package/README.md
CHANGED
|
@@ -108,7 +108,7 @@ console.log(ictcp.to("rgb")); // → rgb(6 7 90)
|
|
|
108
108
|
|
|
109
109
|
## 📚 Documentation
|
|
110
110
|
|
|
111
|
-
Full documentation is available at [saturon.
|
|
111
|
+
Full documentation is available at [saturon.js.org](https://saturon.js.org).
|
|
112
112
|
|
|
113
113
|
## 📜 License
|
|
114
114
|
|
package/dist/Color.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare class Color<M extends ColorModel = ColorModel> {
|
|
|
31
31
|
* @param color - Color string to analyze.
|
|
32
32
|
* @param strict - Whether to validate full round-trip conversion.
|
|
33
33
|
*/
|
|
34
|
-
static type(color: string, strict?: boolean): "
|
|
34
|
+
static type(color: string, strict?: boolean): "hex-color" | "rgb" | "xyz-d65" | "xyz-d50" | "lab" | "oklab" | "srgb" | "srgb-linear" | "display-p3" | "rec2020" | "a98-rgb" | "prophoto-rgb" | "xyz" | "hsl" | "hwb" | "lch" | "oklch" | "named-color" | "color-mix" | "transparent" | "currentColor" | "system-color" | "contrast-color" | "device-cmyk" | "light-dark" | undefined;
|
|
35
35
|
/**
|
|
36
36
|
* Validates a color string, optionally for a specific type.
|
|
37
37
|
*
|
package/dist/index.umd.js
CHANGED
|
@@ -1040,7 +1040,7 @@ var Saturon = (() => {
|
|
|
1040
1040
|
w /= 100;
|
|
1041
1041
|
b /= 100;
|
|
1042
1042
|
if (w + b >= 1) {
|
|
1043
|
-
const gray = w / (w + b);
|
|
1043
|
+
const gray = w / (w + b) * 255;
|
|
1044
1044
|
return [gray, gray, gray];
|
|
1045
1045
|
}
|
|
1046
1046
|
const rgb = HSL_to_RGB([h, 100, 50]).map((c) => c / 255);
|
package/dist/index.umd.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Saturon=(()=>{var Ce=Object.defineProperty;var Ke=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var We=Object.prototype.hasOwnProperty;var Je=(e,t)=>{for(var r in t)Ce(e,r,{get:t[r],enumerable:!0})},Qe=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ue(t))!We.call(e,o)&&o!==r&&Ce(e,o,{get:()=>t[o],enumerable:!(n=Ke(t,o))||n.enumerable});return e};var et=e=>Qe(Ce({},"__esModule",{value:!0}),e);var rt={};Je(rt,{Color:()=>P});var tt={AccentColor:[[0,120,215],[10,132,255]],AccentColorText:[[255,255,255],[255,255,255]],ActiveText:[[255,0,0],[255,100,100]],ButtonBorder:[[169,169,169],[90,90,90]],ButtonFace:[[240,240,240],[60,60,60]],ButtonText:[[0,0,0],[255,255,255]],Canvas:[[255,255,255],[30,30,30]],CanvasText:[[0,0,0],[255,255,255]],Field:[[255,255,255],[45,45,45]],FieldText:[[0,0,0],[255,255,255]],GrayText:[[128,128,128],[169,169,169]],Highlight:[[0,120,215],[80,80,80]],HighlightText:[[255,255,255],[0,0,0]],LinkText:[[0,0,255],[0,128,255]],Mark:[[255,255,0],[255,200,0]],MarkText:[[0,0,0],[0,0,0]],SelectedItem:[[0,120,215],[0,120,215]],SelectedItemText:[[255,255,255],[255,255,255]],VisitedText:[[128,0,128],[200,120,255]]},ee={theme:"light",systemColors:tt,defaults:{fit:"clip"}};var me=new Map;function ce(e,t){let r=Array.isArray(e[0])?e.length:1,n=Array.isArray(e[0])?e:[e],o=Array.isArray(t[0])?t:t.map(i=>[i]),a=o[0].length,s=o[0].map((i,d)=>o.map(u=>u[d])),c=n.map(i=>s.map(d=>i.reduce((u,f,h)=>u+f*(d[h]||0),0)));return r===1?c[0]:a===1?c.map(i=>i[0]):c}function xe(e){return e.trim().replace(/\s+/g," ").replace(/\( /g,"(").replace(/ \)/g,")").replace(/\s*,\s*/g,", ").replace(/ ,/g,",").replace(/calc\(NaN\)/g,"0").replace(/[A-Z]/g,t=>String.fromCharCode(t.charCodeAt(0)+32))}function oe(e,t){let r=t,n="",o=0;if(e[r]!=="(")for(;r<e.length&&/[a-zA-Z0-9-%#]/.test(e[r]);)n+=e[r],r++;if(e[r]==="("){for(n+="(",r++,o=1;r<e.length&&o>0;){let a=e[r];a==="("?o++:a===")"&&o--,o>0&&(n+=a),r++}n+=")"}return{expression:n,end:r}}function le(e,t,r={}){let{method:n=ee.defaults.fit,precision:o}=r,{components:a}=D[t],s=Object.values(a).reduce((i,d)=>(i[d.index]=d,i),[]),c;if(n==="none")c=e;else if(n==="clip")c=e.slice(0,3).map((i,d)=>{let u=s[d];if(!u)throw new Error(`Missing component properties for index ${d}.`);if(u.value==="angle")return(i%360+360)%360;let[f,h]=Array.isArray(u.value)?u.value:[0,100];return Math.min(h,Math.max(f,i))});else{let i=Ae[n];if(!i)throw new Error(`Invalid gamut clipping method: must be ${Object.keys(Ae).join(", ")} or "none".`);c=i(e,t)}return c.slice(0,3).map((i,d)=>{let u;if(typeof o=="number"||o===null)u=o;else if(typeof o>"u")u=s[d]?.precision??3;else throw new TypeError(`Invalid precision value: ${o}.`);return u===null?i:Number(i.toFixed(u))})}function Oe(e,t){let r=(l,v,p={},T=!1,N=!1)=>{let y=(B,x,U)=>{let ne=parseFloat(B);if(isNaN(ne))throw new Error(`Invalid percentage value: '${B}'.`);return v==="percentage"?ne:x<0&&U>0?ne/100*(U-x)/2:ne/100*(U-x)+x},z=B=>{let x=parseFloat(B);if(isNaN(x))throw new Error(`Invalid angle value: '${B}'.`);return B.slice(-3)==="deg"?x:B.slice(-3)==="rad"?x*(180/m):B.slice(-4)==="grad"?x*.9:B.slice(-4)==="turn"?x*360:x},j=(B,x,U)=>{let ne=M=>{let Y=[];for(let g=0;g<M.length;){let Z=M[g];if(/\s/.test(Z)){g++;continue}if(M.slice(g,g+2)==="**"){Y.push({type:"operator",value:"**"}),g+=2;continue}if(/[0-9]/.test(Z)||Z==="."&&/[0-9]/.test(M[g+1]||"")){let se="";for(;g<M.length&&/[0-9.]/.test(M[g]);)se+=M[g++];if(g<M.length&&/[eE]/.test(M[g]))for(se+=M[g++],/[+-]/.test(M[g])&&(se+=M[g++]);g<M.length&&/[0-9]/.test(M[g]);)se+=M[g++];Y.push({type:"number",value:parseFloat(se)});continue}if(/[a-zA-Z_]/.test(Z)){let se="";for(;g<M.length&&/[a-zA-Z0-9_]/.test(M[g]);)se+=M[g++];Y.push({type:"identifier",value:se});continue}if("+-*/%(),".includes(Z)){Y.push({type:"operator",value:Z}),g++;continue}throw new Error(`Unexpected character: ${Z}`)}return Y},J=M=>{let Y=0,g=()=>Y<M.length?M[Y]:null,Z=()=>{if(Y>=M.length)throw new Error("Unexpected end of input");return M[Y++]},se=R=>{let re=g();if(!re||re.value!==R)throw new Error(`Expected "${R}" but got "${re?re.value:"end of input"}`);Z()},He=()=>{let R=g();if(!R)throw new Error("Unexpected end of input");if(R.type==="number")return Z(),{type:"number",value:R.value};if(R.type==="identifier"){if(Z(),g()&&g().value==="("){Z();let re=[];if(g()&&g().value!==")")for(re.push(be());g()&&g().value===",";)Z(),re.push(be());return se(")"),{type:"call",func:R.value,args:re}}return{type:"var",name:R.value}}if(R.value==="("){Z();let re=be();return se(")"),re}throw new Error(`Unexpected token: ${R.value}`)},Be=()=>g()&&(g().value==="+"||g().value==="-")?{type:"unary",op:Z().value,arg:Be()}:He(),Le=()=>{let R=Be();for(;g()&&g().value==="**";)R={type:"binary",op:Z().value,left:R,right:Be()};return R},Se=()=>{let R=Le();for(;g()&&["*","/","%"].includes(String(g().value));)R={type:"binary",op:Z().value,left:R,right:Le()};return R},be=()=>{let R=Se();for(;g()&&(g().value==="+"||g().value==="-");)R={type:"binary",op:Z().value,left:R,right:Se()};return R},Ve=be();if(Y<M.length)throw new Error(`Extra tokens after expression: ${M.slice(Y).map(R=>R.value).join(" ")}`);return Ve},Q=(M,Y)=>{switch(M.type){case"number":return M.value;case"var":{let g=Y[M.name];if(g===void 0)throw new Error(`Unknown variable: ${M.name}`);if(typeof g=="function")throw new Error(`Expected variable but found function: ${M.name}`);return g}case"binary":{let g=Q(M.left,Y),Z=Q(M.right,Y);switch(M.op){case"+":return g+Z;case"-":return g-Z;case"*":return g*Z;case"/":return g/Z;case"%":return g%Z;case"**":return g**Z;default:throw new Error(`Unknown binary operator: ${M.op}`)}}case"unary":{let g=Q(M.arg,Y);switch(M.op){case"+":return+g;case"-":return-g;default:throw new Error(`Unknown unary operator: ${M.op}`)}}case"call":{let g=Y[M.func];if(typeof g!="function")throw new Error(`Unknown function: ${M.func}`);return g(...M.args.map(Z=>Q(Z,Y)))}default:throw new Error(`Unknown AST node type: ${M.type}`)}},F=B.slice(5,-1).trim();if(F==="infinity")return U;if(F==="-infinity")return x;if(F==="NaN")return 0;F=F.replace(/(\d+(\.\d+)?)%/g,M=>{if(N===!0)throw new Error("<angle> and <percentage> values are converted to <number> in relative syntax.");let Y=y(M,x,U);return Y!==void 0?String(Y):"0"}),F=F.replace(/(\d+(\.\d+)?)(deg|rad|grad|turn)/g,(M,Y,g,Z)=>{if(N===!0)throw new Error("<angle> and <percentage> values are converted to <number> in relative syntax.");return String(z(`${parseFloat(Y)}${Z}`))});let Ee={...p,pi:m,e:w,tau:m*2,pow:$,sqrt:L,sin:q,cos:C,tan:b,asin:E,acos:S,atan:_,atan2:W,exp:O,log:A,log10:I,log2:G,abs:k,min:V,max:he,hypot:fe,round:ge,ceil:de,floor:ie,sign:ye,trunc:ve,random:we};try{let M=ne(F),Y=J(M);return Q(Y,Ee)}catch(M){throw new Error(`Evaluation error: ${M}`)}},X=()=>{if(/^-?(?:\d+|\d*\.\d+)(?:deg|rad|grad|turn)$/.test(l))return z(l);if(/^-?(?:\d+|\d*\.\d+)$/.test(l))return parseFloat(l);let[B,x]=[0,360];if(l[l.length-1]==="%"){if(T&&h===!0)throw new Error("The legacy color syntax does not allow percentages for <angle> components.");if(N===!0)throw new Error("The relative color syntax doesn't allow percentages for <angle> components.");return y(l,B,x)}if(l.slice(0,5)==="calc(")return j(l,B,x);throw new Error(`Invalid angle value: '${l}'. Must be a number, a number with a unit (deg, rad, grad, turn), or a percentage.`)},te=()=>{if(/^-?(?:\d+|\d*\.\d+)$/.test(l)){if(T&&h===!0)throw new Error("The legacy color syntax does not allow numbers for <percentage> components.");return parseFloat(l)}let[B,x]=[0,100];if(l[l.length-1]==="%")return y(l,B,x);if(l.slice(0,5)==="calc(")return j(l,B,x);throw new Error(`Invalid percentage value: '${l}'. Must be a percentage or a number.`)},K=()=>{if(/^-?(?:\d+|\d*\.\d+)$/.test(l))return parseFloat(l);let[B,x]=v;if(l[l.length-1]==="%")return y(l,B,x);if(l.slice(0,5)==="calc(")return j(l,B,x);throw new Error(`Invalid number value: '${l}'. Must be a number${N===!1?" or a percentage":""}.`)};if(l==="none")return 0;if(l in p)return p[l];if(v==="angle")return X();if(v==="percentage")return te();if(Array.isArray(v))return K();throw new Error(`Unable to parse component token: ${l}`)},n=l=>{let{fn:v,space:p,fromOrigin:T,c1:N,c2:y,c3:z,alpha:j,commaSeparated:X}=l,{components:te,supportsLegacy:K}=t;if(te.alpha={index:3,value:[0,1],precision:3},X&&K!==!0)throw new Error(`<${v}()> does not support comma-separated syntax.`);let B=Object.entries(te).sort((x,U)=>x[1].index-U[1].index);if(T){let x;if(v==="color")x=p;else if(v in D)x=v;else for(let J in D)if(D[J].alphaVariant===v){x=J;break}let U=P.from(T).in(x).toObject({fit:"none",precision:null});return[N,y,z,j].map((J,Q)=>{let[,F]=B[Q];return r(J,F.value,U,X,!0)}).slice(0,4)}else{let x=[],U=[],ne=[N,y,z,j];for(let J=0;J<B.length;J++){let[,Q]=B[J],F=ne[J];if(X&&F==="none")throw new Error(`${v}() cannot use "none" in comma-separated syntax.`);if(Q.index!==3&&Q.value!=="angle"&&Q.value!=="percentage"&&F.slice(0,5)!=="calc("&&U.push(F.trim()[F.length-1]==="%"),F){let Ee=r(F,Q.value,{},X);x[Q.index]=Ee}}if(X&&U.length>1){let J=U.every(Boolean),Q=U.every(F=>!F);if(!J&&!Q)throw new Error(`${v}()'s <number> components must all be numbers or all percentages.`)}return x.slice(0,4)}},o=l=>{let v=(B,x="/")=>{if(l[B]!==void 0){if(l[B]===x)return{value:l[B+1],hasAlpha:!0};throw new Error("Invalid alpha separator")}return{value:"1",hasAlpha:!1}},p,T,N,y,z,j,X,te=!1,K;if(l[0]==="color")if(p="color",l[1]==="from"){T=l[3],N=l[2],y=l[4],z=l[5],j=l[6];let{value:B,hasAlpha:x}=v(7);K=x?9:7,X=B}else{T=l[1],N=null,y=l[2],z=l[3],j=l[4];let{value:B,hasAlpha:x}=v(5);K=x?7:5,X=B}else if(p=l[0],T=null,l[1]==="from"){N=l[2],y=l[3],z=l[4],j=l[5];let{value:B,hasAlpha:x}=v(6);K=x?8:6,X=B}else if(N=null,y=l[1],l[2]===","&&l[4]===","){te=!0,z=l[3],j=l[5];let{value:B,hasAlpha:x}=v(6,",");if(K=x?8:6,x&&l[6]!==",")throw new Error("Comma optional syntax requires no commas at all.");X=B}else{z=l[2],j=l[3];let{value:B,hasAlpha:x}=v(4);K=x?6:4,X=B}if(l.length!==K)throw new Error(`Invalid number of tokens for ${p}(): expected ${K} but got ${l.length}.`);return{fn:p,space:T,fromOrigin:N,c1:y,c2:z,c3:j,alpha:X,commaSeparated:te}},a=l=>{let v=[],p=0,T="";for(;p<l.length&&l[p]!=="(";)T+=l[p],p++;T=T.trim(),v.push(T);let N=l.indexOf("(")+1,y=l.slice(N,-1).trim();if(p=0,y.slice(0,5)==="from "){for(v.push("from"),p+=5;p<y.length&&y[p]===" ";)p++;let z=p;for(;p<y.length&&y[p]!==" ";)p++;let j=y.slice(z,p);if(j.includes("(")){let{expression:X,end:te}=oe(y,z);v.push(X),p=te}else v.push(j);for(;p<y.length&&y[p]===" ";)p++}if(v[0]==="color"&&p<y.length){let z=p;for(;p<y.length&&y[p]!==" ";)p++;for(v.push(y.slice(z,p));p<y.length&&y[p]===" ";)p++}for(;p<y.length;){let z=y[p];if(z===",")v.push(","),p++,y[p]===" "&&p++;else if(z==="/")v.push("/"),p++,y[p]===" "&&p++;else if(z===" ")p++;else if(/[a-zA-Z#]/.test(z)){let j=p,X="";for(;p<y.length&&/[a-zA-Z0-9-%#]/.test(y[p]);)X+=y[p],p++;if(p<y.length&&y[p]==="("){let{expression:te,end:K}=oe(y,j);v.push(te),p=K}else v.push(X)}else if(/[\d.-]/.test(z)){let j="";for(;p<y.length&&/[\d.eE+-]/.test(y[p]);)j+=y[p],p++;if(p<y.length&&y[p]==="%")j+="%",p++,v.push(j);else if(p<y.length&&/[a-zA-Z]/.test(y[p])){let X="";for(;p<y.length&&/[a-zA-Z]/.test(y[p]);)X+=y[p],p++;v.push(j+X)}else v.push(j)}else throw new Error(`Unexpected character: ${z}`)}return v},s=(l,v)=>{let p="color(from ";if(l.slice(0,11)!==p||l[l.length-1]!==")")return!1;let T=l.slice(p.length,-1).trim(),{expression:N,end:y}=oe(T,0);if(!N)return!1;let j=T.slice(y).trim().split(/\s+/);return j.length<1?!1:j[0]===v},{components:c,bridge:i,fromBridge:d,toBridge:u,alphaVariant:f,supportsLegacy:h}=t,{PI:m,E:w,pow:$,sqrt:L,sin:q,cos:C,tan:b,asin:E,acos:S,atan:_,atan2:W,exp:O,log:A,log10:I,log2:G,abs:k,min:V,max:he,hypot:fe,round:ge,ceil:de,floor:ie,sign:ye,trunc:ve,random:we}=Math;return{isValid:l=>{let{alphaVariant:v=e}=t;if(e in pe){let p=l.slice(0,`color(${e} `.length)===`color(${e} `,T=l.slice(0,10)==="color(from"&&s(l,e);return(p||T)&&l[l.length-1]===")"}return(l.slice(0,`${e}(`.length)===`${e}(`||l.slice(0,`${v}(`.length)===`${v}(`)&&l[l.length-1]===")"},bridge:i,toBridge:l=>[...u(l.slice(0,3)),l[3]??1],parse:l=>{let v=a(l),p=o(v),T=n(p);return[...T.slice(0,3),T[3]??1]},fromBridge:l=>[...d(l),l[3]??1],format:([l,v,p,T=1],N={})=>{let{legacy:y=!1,fit:z=ee.defaults.fit,precision:j,units:X=!1}=N,te=le([l,v,p],e,{method:z,precision:j}),K=Number(V(he(T,0),1).toFixed(3)).toString(),B=te.map((x,U)=>{if((X||y)&&c){let ne=Object.values(c).find(J=>J.index===U);if(ne?.value==="percentage")return`${x}%`;if(ne?.value==="angle"&&X)return`${x}deg`}return x.toString()});return e in pe?`color(${e} ${B.join(" ")}${T!==1?` / ${K}`:""})`:y&&h?T===1?`${e}(${B.join(", ")})`:`${f||e}(${B.join(", ")}, ${K})`:`${e}(${B.join(" ")}${T!==1?` / ${K}`:""})`}}}function ae(e,t){let{fromLinear:r=s=>s,toLinear:n=s=>s,toBridgeMatrix:o,fromBridgeMatrix:a}=t;return{supportsLegacy:!1,targetGamut:t.targetGamut===null?null:e,components:Object.fromEntries(t.components.map((s,c)=>[s,{index:c,value:[0,1],precision:5}])),bridge:t.bridge,toBridge:s=>ce(o,s.map(c=>n(c))),fromBridge:s=>ce(a,s).map(c=>r(c))}}var H={D50_to_D65:[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]],D65_to_d50:[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]],SRGB_to_XYZD65:[[506752/1228815,87881/245763,12673/70218],[87098/409605,175762/245763,12673/175545],[7918/409605,87881/737289,1001167/1053270]],XYZD65_to_SRGB:[[12831/3959,-329/214,-1974/3959],[-851781/878810,1648619/878810,36519/878810],[705/12673,-2585/12673,705/667]],P3_to_XYZD65:[[608311/1250200,189793/714400,198249/1000160],[35783/156275,247089/357200,198249/2500400],[0/1,32229/714400,5220557/5000800]],XYZD65_to_P3:[[446124/178915,-333277/357830,-72051/178915],[-14852/17905,63121/35810,423/17905],[11844/330415,-50337/660830,316169/330415]],REC2020_to_XYZD65:[[63426534/99577255,20160776/139408157,47086771/278816314],[26158966/99577255,472592308/697040785,8267143/139408157],[0/1,19567812/697040785,295819943/278816314]],XYZD65_to_REC2020:[[30757411/17917100,-6372589/17917100,-4539589/17917100],[-19765991/29648200,47925759/29648200,467509/29648200],[792561/44930125,-1921689/44930125,42328811/44930125]],A98_to_XYZD65:[[573536/994567,263643/1420810,187206/994567],[591459/1989134,6239551/9945670,374412/4972835],[53769/1989134,351524/4972835,4929758/4972835]],ProPhoto_to_XYZD50:[[.7977666449006423,.13518129740053308,.0313477341283922],[.2880748288194013,.711835234241873,8993693872564e-17],[0,0,.8251046025104602]],XYZD50_to_ProPhoto:[[1.3457868816471583,-.25557208737979464,-.05110186497554526],[-.5446307051249019,1.5082477428451468,.02052744743642139],[0,0,1.2119675456389452]],XYZD65_to_A98:[[1829569/896150,-506331/896150,-308931/896150],[-851781/878810,1648619/878810,36519/878810],[16779/1248040,-147721/1248040,1266979/1248040]],LMS_to_XYZD65:[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],XYZD65_to_LMS:[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],LMS_to_OKLAB:[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],OKLAB_to_LMS:[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]]},Te={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,"ease-in-cubic":e=>e*e*e,"ease-out-cubic":e=>--e*e*e+1,"ease-in-out-cubic":e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2},Ae={"chroma-reduction":(e,t)=>{let r=new P(t,e),{targetGamut:n}=D[t];if(n===null||(n===void 0&&(n="srgb"),r.inGamut(n,1e-5)))return e;let[o,,a]=r.in("oklch").toArray({fit:"none",precision:null}),s=Math.min(1,Math.max(0,o)),c=0,i=1,d=1e-6,u=[];for(;i-c>d;){let h=(c+i)/2,m=new P("oklch",[s,h,a]);if(m.inGamut(n,1e-5))c=h;else{let w=le(m.toArray({fit:"none",precision:null}).slice(0,3),t,{method:"clip"}),$=new P(t,w);if(m.deltaEOK($)<2)return u=w,u;i=h}}return u=new P("oklch",[s,c,a]).in(t).toArray({fit:"none",precision:null}),u},"css-gamut-map":(e,t)=>{let{targetGamut:r}=D[t];if(r===null)return e;r===void 0&&(r="srgb");let n=new P(t,e),[o,a,s]=n.in("oklch").toArray({fit:"none",precision:null});if(o>=1)return new P("oklab",[1,0,0]).in(t).toArray({fit:"none",precision:null});if(o<=0)return new P("oklab",[0,0,0]).in(t).toArray({fit:"none",precision:null});if(n.inGamut(r,1e-5))return e;let c=.02,i=1e-4,d=new P("oklch",[o,a,s]),u=le(d.in(t).toArray({fit:"none",precision:null}).slice(0,3),t,{method:"clip"}),f=new P(t,u);if(d.deltaEOK(f)<c)return u;let m=0,w=a,$=!0;for(;w-m>i;){let L=(m+w)/2,q=new P("oklch",[o,L,s]);if($&&q.inGamut(r,1e-5))m=L;else{let C=le(q.in(t).toArray({fit:"none",precision:null}).slice(0,3),t,{method:"clip"});u=C;let b=new P(t,C),E=q.deltaEOK(b);if(E<c){if(c-E<i)return u;$=!1,m=L}else w=L}}return u}};function je(e){let t=e.map(r=>{let n=r/255,o=n<0?-1:1,a=Math.abs(n);return a<=.04045?n/12.92:o*((a+.055)/1.055)**2.4});return ce(H.SRGB_to_XYZD65,t)}function Ze(e){return ce(H.XYZD65_to_SRGB,e).map(n=>{let o=n<0?-1:1,a=Math.abs(n);return a>.0031308?o*(1.055*a**(1/2.4)-.055):12.92*n}).map(n=>n*255)}function $e([e,t,r]){t/=100,r/=100;let n=o=>{let a=(o+e/30)%12,s=t*Math.min(r,1-r);return r-s*Math.max(-1,Math.min(a-3,9-a,1))};return[n(0)*255,n(8)*255,n(4)*255]}function De(e){let[t,r,n]=e.map(u=>u/255),o=Math.max(t,r,n),a=Math.min(t,r,n),s=(o+a)/2,c=0,i=0,d=o-a;return d!==0&&(i=d/(1-Math.abs(2*s-1)),c=o===t?(r-n)/d+(r<n?6:0):o===r?(n-t)/d+2:(t-r)/d+4,c*=60),[c%360,i*100,s*100]}function ze([e,t,r]){if(t/=100,r/=100,t+r>=1){let o=t/(t+r);return[o,o,o]}return $e([e,100,50]).map(o=>o/255).map(o=>(o*(1-t-r)+t)*255)}function Ie(e){let[t,r,n]=e.map(i=>i/255),o=Math.max(t,r,n),a=Math.min(t,r,n),s=0,c=o-a;return c===0?s=0:(s=o===t?(r-n)/c+(r<n?6:0):o===r?(n-t)/c+2:(t-r)/c+4,s=s*60%360),[s,a*100,(1-o)*100]}function ke([e,t,r]){let n=[.9642956764295677,1,.8251046025104602],o=24389/27,a=216/24389,s=(e+16)/116,c=t/500+s,i=s-r/200;return[c**3>a?c**3:(116*c-16)/o,e>o*a?s**3:e/o,i**3>a?i**3:(116*i-16)/o].map((u,f)=>u*n[f])}function Xe(e){let t=[.9642956764295677,1,.8251046025104602],r=24389/27,n=216/24389,o=e.map((i,d)=>i/t[d]),[a,s,c]=o.map(i=>i>n?Math.cbrt(i):(r*i+16)/116);return[116*s-16,500*(a-s),200*(s-c)]}function Ye([e,t,r]){return[e,t*Math.cos(r*Math.PI/180),t*Math.sin(r*Math.PI/180)]}function Re([e,t,r]){let n=Math.hypot(t,r),o=Math.atan2(r,t)*180/Math.PI;return o<0&&(o+=360),[e,n,o]}function Pe(e){let{LMS_to_XYZD65:t,OKLAB_to_LMS:r}=H,n=ce(r,e);return ce(t,n.map(o=>o**3))}function qe(e){let{XYZD65_to_LMS:t,LMS_to_OKLAB:r}=H,n=ce(t,e);return ce(r,n.map(Math.cbrt))}function Ne([e,t,r]){return[e,t*Math.cos(r*Math.PI/180),t*Math.sin(r*Math.PI/180)]}function Fe([e,t,r]){let n=Math.hypot(t,r),o=Math.atan2(r,t)*180/Math.PI;return o<0&&(o+=360),[e,n,o]}var Me={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},pe={srgb:ae("srgb",{components:["r","g","b"],bridge:"xyz-d65",toLinear:e=>{let t=e<0?-1:1,r=Math.abs(e);return r<=.04045?t*(r/12.92):t*Math.pow((r+.055)/1.055,2.4)},fromLinear:e=>{let t=e<0?-1:1,r=Math.abs(e);return r>.0031308?t*(1.055*Math.pow(r,1/2.4)-.055):t*(12.92*r)},toBridgeMatrix:H.SRGB_to_XYZD65,fromBridgeMatrix:H.XYZD65_to_SRGB}),"srgb-linear":ae("srgb-linear",{components:["r","g","b"],bridge:"xyz-d65",toBridgeMatrix:H.SRGB_to_XYZD65,fromBridgeMatrix:H.XYZD65_to_SRGB}),"display-p3":ae("display-p3",{components:["r","g","b"],bridge:"xyz-d65",toLinear:e=>{let t=e<0?-1:1,r=Math.abs(e);return r<=.04045?t*(r/12.92):t*Math.pow((r+.055)/1.055,2.4)},fromLinear:e=>{let t=e<0?-1:1,r=Math.abs(e);return r>.0031308?t*(1.055*Math.pow(r,1/2.4)-.055):t*(12.92*r)},toBridgeMatrix:H.P3_to_XYZD65,fromBridgeMatrix:H.XYZD65_to_P3}),rec2020:ae("rec2020",{components:["r","g","b"],bridge:"xyz-d65",toLinear:e=>{let t=1.09929682680944,r=.018053968510807,n=e<0?-1:1,o=Math.abs(e);return o<r*4.5?n*(o/4.5):n*Math.pow((o+t-1)/t,1/.45)},fromLinear:e=>{let t=1.09929682680944,r=.018053968510807,n=e<0?-1:1,o=Math.abs(e);return o>r?n*(t*Math.pow(o,.45)-(t-1)):n*(4.5*o)},toBridgeMatrix:H.REC2020_to_XYZD65,fromBridgeMatrix:H.XYZD65_to_REC2020}),"a98-rgb":ae("a98-rgb",{components:["r","g","b"],bridge:"xyz-d65",toLinear:e=>{let t=e<0?-1:1,r=Math.abs(e);return t*Math.pow(r,563/256)},fromLinear:e=>{let t=e<0?-1:1,r=Math.abs(e);return t*Math.pow(r,256/563)},toBridgeMatrix:H.A98_to_XYZD65,fromBridgeMatrix:H.XYZD65_to_A98}),"prophoto-rgb":ae("prophoto-rgb",{components:["r","g","b"],bridge:"xyz-d50",toLinear:e=>{let r=e<0?-1:1,n=Math.abs(e);return n<=.03125?r*(n/16):r*Math.pow(n,1.8)},fromLinear:e=>{let t=.001953125,r=e<0?-1:1,n=Math.abs(e);return n>=t?r*Math.pow(n,1/1.8):r*(16*n)},toBridgeMatrix:H.ProPhoto_to_XYZD50,fromBridgeMatrix:H.XYZD50_to_ProPhoto}),"xyz-d65":ae("xyz-d65",{targetGamut:null,components:["x","y","z"],bridge:"xyz-d65",toBridgeMatrix:[[1,0,0],[0,1,0],[0,0,1]],fromBridgeMatrix:[[1,0,0],[0,1,0],[0,0,1]]}),"xyz-d50":ae("xyz-d50",{targetGamut:null,components:["x","y","z"],bridge:"xyz-d65",toBridgeMatrix:H.D50_to_D65,fromBridgeMatrix:H.D65_to_d50}),xyz:ae("xyz",{targetGamut:null,components:["x","y","z"],bridge:"xyz-d65",toBridgeMatrix:[[1,0,0],[0,1,0],[0,0,1]],fromBridgeMatrix:[[1,0,0],[0,1,0],[0,0,1]]})},D={rgb:{supportsLegacy:!0,alphaVariant:"rgba",components:{r:{index:0,value:[0,255],precision:0},g:{index:1,value:[0,255],precision:0},b:{index:2,value:[0,255],precision:0}},bridge:"xyz-d65",toBridge:je,fromBridge:Ze},hsl:{supportsLegacy:!0,alphaVariant:"hsla",components:{h:{index:0,value:"angle",precision:0},s:{index:1,value:"percentage",precision:0},l:{index:2,value:"percentage",precision:0}},bridge:"rgb",toBridge:$e,fromBridge:De},hwb:{components:{h:{index:0,value:"angle",precision:0},w:{index:1,value:"percentage",precision:0},b:{index:2,value:"percentage",precision:0}},bridge:"rgb",toBridge:ze,fromBridge:Ie},lab:{targetGamut:null,components:{l:{index:0,value:"percentage",precision:5},a:{index:1,value:[-125,125],precision:5},b:{index:2,value:[-125,125],precision:5}},bridge:"xyz-d50",toBridge:ke,fromBridge:Xe},lch:{targetGamut:null,components:{l:{index:0,value:"percentage",precision:5},c:{index:1,value:[0,150],precision:5},h:{index:2,value:"angle",precision:5}},bridge:"lab",toBridge:Ye,fromBridge:Re},oklab:{targetGamut:null,components:{l:{index:0,value:[0,1],precision:5},a:{index:1,value:[-.4,.4],precision:5},b:{index:2,value:[-.4,.4],precision:5}},bridge:"xyz-d65",toBridge:Pe,fromBridge:qe},oklch:{targetGamut:null,components:{l:{index:0,value:[0,1],precision:5},c:{index:1,value:[0,.4],precision:5},h:{index:2,value:"angle",precision:5}},bridge:"oklab",toBridge:Ne,fromBridge:Fe},...pe},_e=Object.fromEntries(Object.entries(D).map(([e,t])=>[e,Oe(e,t)])),Ge={"hex-color":{isValid:e=>e[0]==="#",bridge:"rgb",toBridge:e=>e,parse:e=>{let t=e.slice(1);if(![3,4,6,8].includes(t.length))throw new Error("Invalid hex color length.");for(let c of t){let i=c.charCodeAt(0),d=i>=48&&i<=57,u=i>=97&&i<=102,f=i>=65&&i<=70;if(!(d||u||f))throw new Error("Invalid hex color character.")}let r=c=>parseInt(c.length===1?c+c:c,16),[n,o,a,s=255]=t.length<=4?t.split("").map(r):[t.slice(0,2),t.slice(2,4),t.slice(4,6),t.slice(6,8)].map(c=>parseInt(c||"ff",16));return[n,o,a,s/255]},fromBridge:e=>e,format:([e,t,r,n=1])=>{let o=s=>s.toString(16).padStart(2,"0");return`#${[e,t,r].map(s=>o(Math.round(Math.max(0,Math.min(255,s))))).join("")}${n<1?o(Math.round(n*255)):""}`}},..._e,"named-color":{isValid:e=>Object.keys(Me).some(t=>t===e),bridge:"rgb",toBridge:e=>e,parse:e=>{let t=Me[e];if(!t)throw new Error(`Invalid named-color: ${e}.`);return[...t,1]},fromBridge:e=>e,format:e=>{let[t,r,n]=e.map((o,a)=>a<3?Math.round(Math.min(255,Math.max(0,o))):o);for(let[o,[a,s,c]]of Object.entries(Me))if(t===a&&r===s&&n===c)return o}},"color-mix":{isValid:e=>e.slice(0,10)==="color-mix("&&e[e.length-1]===")",bridge:"rgb",toBridge:e=>e,parse:e=>{let t=b=>{let E=b.trim(),S,_=E,W=_.match(/^(\d+)%\s+/);if(W){let G=parseInt(W[1],10);S=Math.min(1,Math.max(0,G/100)),_=_.slice(W[0].length).trim()}let O="",A="";if(/^[a-z]/i.test(_)){let{expression:G,end:k}=oe(_,0);if(G)O=G,A=_.slice(k).trim();else{let V=_.match(/^([^\s]+)(.*)$/);O=V?V[1]:_,A=V?V[2].trim():""}}else{let G=_.match(/^([^\s]+)(.*)$/);O=G?G[1]:_,A=G?G[2].trim():""}if(S===void 0){let G=A.match(/^(-?(?:\d+\.?\d*|\.\d+))%/);if(G){if(S=parseInt(G[1],10)/100,A=A.slice(G[0].length).trim(),S<0)throw new Error("Percentages less than 0 are not valid.");if(S>1)throw new Error("Percentages greater than 100 are not valid.")}else if(A.slice(0,5)==="calc("){let{expression:k,end:V}=oe(A,0);if(!k)throw new Error("Malformed calc() weight expression.");A=A.slice(V).trim()}}if(A.length>0)throw new Error(`Unexpected extra tokens after color: '${A}'.`);return{color:P.from(O),weight:S}},r=(b,E)=>{if(b===void 0&&typeof E=="number")b=1-E;else if(typeof b=="number"&&E===void 0)E=1-b;else if(b===void 0&&E===void 0)b=E=.5;else if(b=b,E=E,b+E<=0)throw new Error("Sum of percengates cannot be 0%.");let S=b+E,_;return S>1?(b/=S,E/=S):(b/=S,E/=S,_=S),{amount:E,alphaMultiplier:_}},n="color-mix",{expression:o}=oe(e,n.length);if(!o)throw new Error("Malformed color-mix expression.");let a=o.slice(1,-1).trim(),s=[],c=0,i="";for(;c<a.length;){let b=a[c];if(b===","){s.push(i.trim()),i="",c++;continue}if(b==="("||/[a-zA-Z]/.test(b)){let{expression:E,end:S}=oe(a,c);if(E){i+=E,c=S;continue}}i+=b,c++}if(s.push(i.trim()),s.length!==3)throw new Error("color-mix must have three comma-separated parts.");let u=s[0].match(/^in\s+([a-z0-9-]+)(?:\s+(shorter|longer|increasing|decreasing)\s+hue)?$/);if(!u)throw new Error("Invalid model and hue format.");let f=u[1],h=u[2];if(f==="rgb")throw new Error('RGB model is not allowed in color-mix(). Use "srgb" instead.');if(h){let b=D[f].components;if(!b)throw new Error(`Unknown color model: ${f}.`);if(!Object.values(b).some(S=>S.value==="angle"))throw new Error(`Hue interpolation not supported in ${f} space.`)}else h="shorter";let{color:m,weight:w}=t(s[1]),{color:$,weight:L}=t(s[2]),{amount:q,alphaMultiplier:C=1}=r(w,L);return m.with({alpha:b=>b*C}).in(f).mix($.with({alpha:b=>b*C}),{amount:q,hue:h}).in("rgb").toArray({fit:"none",precision:null})}},transparent:{isValid:e=>e==="transparent",bridge:"rgb",toBridge:e=>e,parse:e=>[0,0,0,0]}},ue={...Ge,currentColor:{isValid:e=>e==="currentcolor",bridge:"rgb",toBridge:e=>e,parse:e=>[0,0,0,1]},"system-color":{isValid:e=>Object.keys(ee.systemColors).some(t=>t.toLowerCase()===e),bridge:"rgb",toBridge:e=>e,parse:e=>{let{systemColors:t}=ee,r=Object.keys(t).find(o=>o.toLowerCase()===e);return[...t[r][ee.theme==="light"?0:1],1]}},"contrast-color":{isValid:e=>e.slice(0,15)==="contrast-color("&&e[e.length-1]===")",bridge:"rgb",toBridge:e=>e,parse:e=>{let t=e.slice(15,-1),[,r]=P.from(t).in("xyz-d65").toArray({fit:"none",precision:null});return r>.5?[0,0,0,1]:[255,255,255,1]}},"device-cmyk":{isValid:e=>e.slice(0,12)==="device-cmyk("&&e[e.length-1]===")",bridge:"rgb",toBridge:e=>e,parse:e=>{let t="device-cmyk",r=e.indexOf(t);if(r===-1)throw new Error("Invalid device-cmyk syntax");let{expression:n}=oe(e,r+t.length);if(!n)throw new Error("Malformed device-cmyk expression");let o=n.slice(1,-1).trim(),a=[],s=0;for(;s<o.length;){let C=o[s];if(C===" "){s++;continue}if(C==="("||/[a-zA-Z-]/.test(C)){let{expression:b,end:E}=oe(o,s);if(b){a.push(b),s=E;continue}}if(/[\d.+-]/.test(C)){let b="";for(;s<o.length&&/[\d.eE+-]/.test(o[s]);)b+=o[s],s++;if(s<o.length&&o[s]==="%")b+="%",s++;else if(s<o.length&&/[a-zA-Z]/.test(o[s]))for(;s<o.length&&/[a-zA-Z]/.test(o[s]);)b+=o[s],s++;a.push(b);continue}if(C===","||C==="/"){a.push(C),s++;continue}throw new Error(`Unexpected character: ${C}`)}let c=C=>C[C.length-1]==="%"?parseFloat(C)/100:parseFloat(C);if(a.length>=2&&a[1]===","){let C=a.filter(b=>b!==",");if(C.length===4||C.length===5){let[b,E,S,_,W=1]=C.map(c),O=1-Math.min(1,b*(1-_)+_),A=1-Math.min(1,E*(1-_)+_),I=1-Math.min(1,S*(1-_)+_);return[O*255,A*255,I*255,W]}throw new Error("Invalid number of components for comma-separated device-cmyk")}let i=0,d=[];for(;i<a.length&&d.length<4&&a[i]!=="/"&&a[i]!==",";)d.push(a[i]),i++;if(d.length!==4)throw new Error("Invalid number of components for space-separated device-cmyk");let[u,f,h,m]=d.map(c),w=1;if(i<a.length&&a[i]==="/"){if(i++,i>=a.length)throw new Error("Missing alpha value");w=c(a[i]),i++}if(i<a.length&&a[i]===","){i++;let C=a.slice(i).join(" ");return P.from(C).in("rgb").toArray({fit:"none",precision:null})}let $=1-Math.min(1,u*(1-m)+m),L=1-Math.min(1,f*(1-m)+m),q=1-Math.min(1,h*(1-m)+m);return[$*255,L*255,q*255,w]},fromBridge:e=>e,format:([e,t,r,n=1],o={})=>{let{legacy:a=!1,precision:s=3,fit:c=ee.defaults.fit}=o,[i,d,u]=le([e,t,r],"rgb",{method:c}),f=i/255,h=d/255,m=u/255,w=1-Math.max(f,h,m),$=_=>Number(s===null?_:_.toFixed(s)).toString(),L=$(w===1?0:(1-f-w)/(1-w)),q=$(w===1?0:(1-h-w)/(1-w)),C=$(w===1?0:(1-m-w)/(1-w)),b=$(w),E=Number(n.toFixed(3)).toString();if(a)return`device-cmyk(${L}, ${q}, ${C}, ${b}${n<1?`, ${E}`:""})`;let S=_e.rgb.format?.([i,d,u,n],o);return`device-cmyk(${L} ${q} ${C} ${b}${n<1?` / ${E}`:""}, ${S})`}},"light-dark":{isValid:e=>e.slice(0,11)==="light-dark("&&e[e.length-1]===")",bridge:"rgb",toBridge:e=>e,parse:e=>{let t="light-dark",r=e.indexOf(t);if(r===-1)throw new Error("Not a <light-dark()> expression");let{expression:n}=oe(e,r+t.length);if(!n)throw new Error("Malformed <light-dark()> expression");let o=n.slice(1,-1).trim(),a=[],s="",c=0;for(;c<o.length;){let f=o[c];if(f===","){a.push(s.trim()),s="",c++;continue}if(f==="("||/[a-zA-Z]/.test(f)){let{expression:h,end:m}=oe(o,c);if(h){s+=h,c=m;continue}}s+=f,c++}if(a.push(s.trim()),a.length!==2)throw new Error("Invalid light-dark format");let[i,d]=a,{theme:u}=ee;return P.from(u==="light"?i:d).toArray({fit:"none",precision:null})}}};var P=class e{model;coords;constructor(t,r=[0,0,0,0]){if(!(t in D))throw new Error(`Unsupported color model: '${t}'`);if([3,4].includes(r.length)===!1)throw new Error("Coordinates array must have 3 or 4 elements.");let n=r.slice();n.length===3&&n.push(1),this.model=t,this.coords=n}static from(t){let r=xe(t);for(let n in ue){let o=n,{parse:a,bridge:s,toBridge:c,isValid:i}=ue[o];if(!i(r))continue;let d=a(r),u=o in D?d:c(d),f=o in D?o:s;return new e(f,u)}throw new Error(`Unsupported or invalid color format: '${t}'.`)}static type(t,r=!1){let n=xe(t);for(let o in ue){let a=o,{isValid:s,bridge:c,parse:i,toBridge:d}=ue[a];if(s(n)){if(!r)return a;try{let u=i(n),f=a in D?u:d(u),h=o in D?o:c;return typeof new e(h,f)=="object"?a:void 0}catch{return}}}}static isValid(t,r){try{if(r){let n=r?.trim().toLowerCase(),o=xe(t),{isValid:a,bridge:s,parse:c,toBridge:i}=ue[n];if(!a(o))return!1;let d=c(o),u=n in D?d:i(d),f=n in D?n:s;return!!new e(f,u)}return!!e.from(t)}catch{return!1}}static random(t={}){let r=Object.keys(D),n=t.model??r[Math.floor(Math.random()*r.length)],{components:o}=D[n],a=new Set([...Object.keys(o),"alpha"]);for(let c of["limits","bias","base","deviation"]){let i=t[c];if(i){for(let d of Object.keys(i))if(!a.has(d))throw new Error(`Invalid component "${d}" for model "${n}". Valid components: ${[...a].join(", ")}`)}}let s=[];for(let[c,i]of Object.entries(o)){let d=t.base?.[c],u=t.deviation?.[c],f;if(d!=null&&u!=null){let h=Math.random()||1e-9,m=Math.random()||1e-9;f=d+Math.sqrt(-2*Math.log(h))*Math.cos(2*Math.PI*m)*u}else{let[h,m]=i.value==="angle"?[0,360]:i.value==="percentage"?[0,100]:i.value,w=t.limits?.[c];if(w){let[q,C]=w;h=Math.max(h,q),m=Math.min(m,C)}let $=Math.random(),L=t.bias?.[c];L&&($=L($)),f=h+$*(m-h)}if(i.value==="angle")f=(f%360+360)%360;else if(i.value==="percentage")f=Math.min(100,Math.max(0,f));else if(Array.isArray(i.value)){let[h,m]=i.value;f=Math.min(m,Math.max(h,f))}else throw new Error(`Invalid component value definition for "${c}".`);s[i.index]=f}return new e(n,s)}to(t,r={}){let n=t.toLowerCase(),{legacy:o=!1,fit:a=ee.defaults.fit,precision:s,units:c=!1}=r,i=ue[n];if(!i)throw new Error(`Unsupported color type: '${n}'.`);let{fromBridge:d,bridge:u,format:f}=i;if(!d||!f)throw new Error(`Invalid output type: '${n}'.`);let h=m=>f(m,{legacy:o,fit:a,precision:s,units:c});return n===this.model?h(this.coords):n in D?h(this.in(n).toArray({fit:"none",precision:null})):h(d(this.in(u).toArray({fit:"none",precision:null})))}in(t){let r=this.model,n=t.trim().toLowerCase();if(n===r)return new e(n,[...this.coords]);let o=me.get("graph"),a=me.get("paths");if(!o){o={};for(let[u,f]of Object.entries(D)){let{bridge:h}=f;o[u]=[...o[u]||[],h],o[h]=[...o[h]||[],u]}me.set("graph",o)}a||(a=new Map,me.set("paths",a));let s=`${r}-${n}`,c=this.coords.slice(0,3);if(!a.has(s)){let u=[r],f={[r]:null};for(let m=0;m<u.length;m++){let w=u[m];if(w===n)break;for(let $ of o[w]||[])$ in f||(f[$]=w,u.push($))}let h=[];for(let m=n;m;m=f[m])h.push(m);if(h.reverse(),!h.length||h[0]!==r)throw new Error(`Cannot convert from ${r} to ${n}. No path found.`);a.set(s,h)}let i=[...c],d=a.get(s);for(let u=0;u<d.length-1;u++){let f=d[u],h=d[u+1],m=D[f],w=D[h];if(m.toBridge&&m.bridge===h)i=m.toBridge(i);else if(w.fromBridge&&w.bridge===f)i=w.fromBridge(i);else throw new Error(`No conversion found between ${f} and ${h}.`)}return new e(n,[...i.slice(0,3),this.coords[3]??1])}toString(t={}){let{format:r}=ue[this.model],{legacy:n=!1,fit:o=ee.defaults.fit,precision:a,units:s=!1}=t;return r?.(this.coords,{legacy:n,fit:o,precision:a,units:s})}toObject(t={}){let r=this.toArray(t),{components:n}=D[this.model];if(!n)throw new Error(`Model ${this.model} does not have defined components.`);let o={...n,alpha:{index:3,value:[0,1],precision:3}},a={};for(let[s,{index:c}]of Object.entries(o))a[s]=r[c];return a}toArray(t={}){let{fit:r=ee.defaults.fit,precision:n}=t,{model:o,coords:a}=this,{components:s}=D[o];if(!s)throw new Error(`Model ${o} does not have defined components.`);let c={...s,alpha:{index:3,value:[0,1],precision:3}},i=(f,h)=>{let m=Object.values(c)[h]?.value,[w,$]=Array.isArray(m)?m:m==="angle"?[0,360]:[0,100];return Number.isNaN(f)?0:f===1/0?$:f===-1/0?w:typeof f=="number"?f:0},d=a.slice(0,3).map(i);return[...le(d,o,{method:r,precision:n}).slice(0,3),a[3]]}with(t){let{model:r}=this,n=this.toArray({fit:"none",precision:null}),{components:o}=D[r];if(!o)throw new Error(`Model ${r} does not have defined components.`);let a={...o,alpha:{index:3,value:[0,1],precision:3}},s=Object.keys(a),c;if(typeof t=="function"?c=t(Object.fromEntries(s.map(u=>[u,n[a[u].index]]))):c=t,Array.isArray(c)){let d=n.map((u,f)=>{let h=c[f],{value:m}=Object.values(a).find(L=>L.index===f);if(typeof h!="number")return u;let[w,$]=Array.isArray(m)?m:m==="angle"?[0,360]:[0,100];return Number.isNaN(h)?0:h===1/0?$:h===-1/0?w:h});return new e(r,[...d.slice(0,3),n[3]])}let i=[...n];for(let d of s){if(!(d in c))continue;let{index:u,value:f}=a[d],h=n[u],m=c[d],w=typeof m=="function"?m(h):m;if(typeof w=="number"){let[$,L]=Array.isArray(f)?f:f==="angle"?[0,360]:[0,100];Number.isNaN(w)?w=0:w===1/0?w=L:w===-1/0&&(w=$)}i[u]=w}return new e(r,[...i.slice(0,3),i[3]??n[3]])}mix(t,r={}){let{model:n}=this,o=this.toArray({fit:"none",precision:null}),{components:a}=D[n];if(!a)throw new Error(`Model ${n} does not have defined components.`);let{hue:s="shorter",amount:c=.5,easing:i="linear",gamma:d=1}=r,u={...a,alpha:{index:3,value:[0,1],precision:3}},f=(O,A)=>{let I=((A-O)%360+360)%360;return I>180?I-360:I},h=(O,A)=>f(O,A)>=0?f(O,A)-360:f(O,A)+360,m=(O,A,I,G)=>{let k=V=>(V%360+360)%360;switch(G){case"shorter":return k(O+I*f(O,A));case"longer":return k(O+I*h(O,A));case"increasing":return k(O*(1-I)+(A<O?A+360:A)*I);case"decreasing":return k(O*(1-I)+(A>O?A-360:A)*I);default:throw new Error(`Invalid hue interpolation method: ${G}`)}},w=Math.max(0,Math.min(1,c)),$=typeof i=="function"?i:Te[i],L=Math.pow($(w),1/d),q=typeof t=="string"?e.from(t):t,C=o.slice(0,3),b=q.in(n).toArray({fit:"none",precision:null}).slice(0,3),E=o[3],S=q.coords[3],_=Object.entries(u).find(([O])=>O==="h")?.[1].index;if(w===0)return new e(n,[...C,E]);if(w===1)return new e(n,[...b,S]);if(E<1||S<1){let O=C.map((G,k)=>{let V=b[k];if(k===_)return m(G,V,L,s);let he=G*E,fe=V*S;return he*(1-L)+fe*L}),A=E*(1-L)+S*L,I=A>0?O.map((G,k)=>k===_?G:G/A):C.map((G,k)=>k===_?O[k]:0);return new e(n,[...I,A])}let W=C.map((O,A)=>{let I=Object.values(u).find(k=>k.index===A);if(!I)return O;let G=b[A];return I.value==="angle"?m(O,G,L,s):O+(G-O)*L});return new e(n,[...W,1])}within(t,r=ee.defaults.fit){let n=t.trim().toLowerCase();if(!(n in pe))throw new Error(`Unsupported color gamut: '${n}'.`);let o=this.in(n).toArray({fit:r,precision:null});return new e(n,o).in(this.model)}contrast(t){let r=typeof t=="string"?e.from(t):t,[,n]=this.in("xyz-d65").toArray({fit:"none",precision:null}),[,o]=r.in("xyz-d65").toArray({fit:"none",precision:null});return(Math.max(n,o)+.05)/(Math.min(n,o)+.05)}deltaEOK(t){let r={fit:"none",precision:null},[n,o,a]=this.in("oklab").toArray(r),[s,c,i]=(typeof t=="string"?e.from(t):t).in("oklab").toArray(r),d=n-s,u=o-c,f=a-i;return Math.sqrt(d**2+u**2+f**2)*100}deltaE76(t){let r={fit:"none",precision:null},[n,o,a]=this.in("lab").toArray(r),[s,c,i]=(typeof t=="string"?e.from(t):t).in("lab").toArray(r),d=n-s,u=o-c,f=a-i;return Math.hypot(d,u,f)}deltaE94(t){let r={fit:"none",precision:null},[n,o,a]=this.in("lab").toArray(r),[s,c,i]=(typeof t=="string"?e.from(t):t).in("lab").toArray(r),d=n-s,u=o-c,f=a-i,h=Math.sqrt(o*o+a*a),m=Math.sqrt(c*c+i*i),w=h-m,$=Math.sqrt(Math.max(0,u*u+f*f-w*w)),L=1,q=1,C=1,b=.045,E=.015,S=1+b*h,_=1+E*h;return Math.sqrt((d/L)**2+(w/(q*S))**2+($/(C*_))**2)}deltaE2000(t){let r={fit:"none",precision:null},[n,o,a]=this.in("lab").toArray(r),[s,c,i]=(typeof t=="string"?e.from(t):t).in("lab").toArray(r),d=Math.PI,u=d/180,f=180/d,h=Math.sqrt(o**2+a**2),m=Math.sqrt(c**2+i**2),w=(h+m)/2,$=Math.pow(25,7),L=Math.pow(w,7),q=.5*(1-Math.sqrt(L/(L+$))),C=(1+q)*o,b=(1+q)*c,E=Math.sqrt(C**2+a**2),S=Math.sqrt(b**2+i**2),_=Math.atan2(a,C),W=Math.atan2(i,b);_<0&&(_+=2*d),W<0&&(W+=2*d),_*=f,W*=f;let O=s-n,A=S-E,I=W-_,G=Math.abs(I),k=0;E*S!==0&&(G<=180?k=I:I>180?k=I-360:k=I+360);let V=2*Math.sqrt(E*S)*Math.sin(k*u/2),he=(n+s)/2,fe=(E+S)/2,ge=Math.pow(fe,7),de=_+W,ie=0;E===0&&S===0?ie=de:G<=180?ie=de/2:de<360?ie=(de+360)/2:ie=(de-360)/2;let ye=(he-50)**2,ve=1+.015*ye/Math.sqrt(20+ye),we=1+.045*fe,l=1;l-=.17*Math.cos((ie-30)*u),l+=.24*Math.cos(2*ie*u),l+=.32*Math.cos((3*ie+6)*u),l-=.2*Math.cos((4*ie-63)*u);let v=1+.015*fe*l,p=30*Math.exp(-1*((ie-275)/25)**2),T=2*Math.sqrt(ge/(ge+$)),N=-1*Math.sin(2*p*u)*T,y=(O/ve)**2;return y+=(A/we)**2,y+=(V/v)**2,y+=N*(A/we)*(V/v),Math.sqrt(y)}equals(t,r=1e-5){let n=typeof t=="string"?e.from(t):t;if(n.model===this.model)return this.coords.every((s,c)=>Math.abs(s-n.coords[c])<=r);let o=this.in("xyz-d65").toArray({fit:"none",precision:null}),a=n.in("xyz-d65").toArray({fit:"none",precision:null});return o.every((s,c)=>Math.abs(s-a[c])<=r)}inGamut(t,r=1e-5){let n=t.trim().toLowerCase();if(!(n in pe))throw new Error(`Unsupported color gamut: '${n}'.`);let{components:o,targetGamut:a}=D[n];if(!a)return!0;let s=this.in(n).toArray({fit:"none",precision:null});return Object.values(o).every(({index:c,value:i})=>{let d=s[c],[u,f]=Array.isArray(i)?i:i==="angle"?[0,360]:[0,100];return d>=u-r&&d<=f+r})}};return et(rt);})();
|
|
1
|
+
"use strict";var Saturon=(()=>{var Ce=Object.defineProperty;var Ue=Object.getOwnPropertyDescriptor;var We=Object.getOwnPropertyNames;var Je=Object.prototype.hasOwnProperty;var Qe=(e,t)=>{for(var r in t)Ce(e,r,{get:t[r],enumerable:!0})},et=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of We(t))!Je.call(e,o)&&o!==r&&Ce(e,o,{get:()=>t[o],enumerable:!(n=Ue(t,o))||n.enumerable});return e};var tt=e=>et(Ce({},"__esModule",{value:!0}),e);var rt={};Qe(rt,{Color:()=>P});var Oe={AccentColor:[[0,120,215],[10,132,255]],AccentColorText:[[255,255,255],[255,255,255]],ActiveText:[[255,0,0],[255,100,100]],ButtonBorder:[[169,169,169],[90,90,90]],ButtonFace:[[240,240,240],[60,60,60]],ButtonText:[[0,0,0],[255,255,255]],Canvas:[[255,255,255],[30,30,30]],CanvasText:[[0,0,0],[255,255,255]],Field:[[255,255,255],[45,45,45]],FieldText:[[0,0,0],[255,255,255]],GrayText:[[128,128,128],[169,169,169]],Highlight:[[0,120,215],[80,80,80]],HighlightText:[[255,255,255],[0,0,0]],LinkText:[[0,0,255],[0,128,255]],Mark:[[255,255,0],[255,200,0]],MarkText:[[0,0,0],[0,0,0]],SelectedItem:[[0,120,215],[0,120,215]],SelectedItemText:[[255,255,255],[255,255,255]],VisitedText:[[128,0,128],[200,120,255]]},ee={theme:"light",systemColors:Oe,defaults:{fit:"clip"}};var me=new Map;function ce(e,t){let r=Array.isArray(e[0])?e.length:1,n=Array.isArray(e[0])?e:[e],o=Array.isArray(t[0])?t:t.map(i=>[i]),a=o[0].length,s=o[0].map((i,d)=>o.map(u=>u[d])),c=n.map(i=>s.map(d=>i.reduce((u,f,h)=>u+f*(d[h]||0),0)));return r===1?c[0]:a===1?c.map(i=>i[0]):c}function xe(e){return e.trim().replace(/\s+/g," ").replace(/\( /g,"(").replace(/ \)/g,")").replace(/\s*,\s*/g,", ").replace(/ ,/g,",").replace(/calc\(NaN\)/g,"0").replace(/[A-Z]/g,t=>String.fromCharCode(t.charCodeAt(0)+32))}function oe(e,t){let r=t,n="",o=0;if(e[r]!=="(")for(;r<e.length&&/[a-zA-Z0-9-%#]/.test(e[r]);)n+=e[r],r++;if(e[r]==="("){for(n+="(",r++,o=1;r<e.length&&o>0;){let a=e[r];a==="("?o++:a===")"&&o--,o>0&&(n+=a),r++}n+=")"}return{expression:n,end:r}}function le(e,t,r={}){let{method:n=ee.defaults.fit,precision:o}=r,{components:a}=Z[t],s=Object.values(a).reduce((i,d)=>(i[d.index]=d,i),[]),c;if(n==="none")c=e;else if(n==="clip")c=e.slice(0,3).map((i,d)=>{let u=s[d];if(!u)throw new Error(`Missing component properties for index ${d}.`);if(u.value==="angle")return(i%360+360)%360;let[f,h]=Array.isArray(u.value)?u.value:[0,100];return Math.min(h,Math.max(f,i))});else{let i=Ae[n];if(!i)throw new Error(`Invalid gamut clipping method: must be ${Object.keys(Ae).join(", ")} or "none".`);c=i(e,t)}return c.slice(0,3).map((i,d)=>{let u;if(typeof o=="number"||o===null)u=o;else if(typeof o>"u")u=s[d]?.precision??3;else throw new TypeError(`Invalid precision value: ${o}.`);return u===null?i:Number(i.toFixed(u))})}function je(e,t){let r=(l,v,p={},G=!1,N=!1)=>{let y=(B,x,U)=>{let ne=parseFloat(B);if(isNaN(ne))throw new Error(`Invalid percentage value: '${B}'.`);return v==="percentage"?ne:x<0&&U>0?ne/100*(U-x)/2:ne/100*(U-x)+x},D=B=>{let x=parseFloat(B);if(isNaN(x))throw new Error(`Invalid angle value: '${B}'.`);return B.slice(-3)==="deg"?x:B.slice(-3)==="rad"?x*(180/m):B.slice(-4)==="grad"?x*.9:B.slice(-4)==="turn"?x*360:x},k=(B,x,U)=>{let ne=M=>{let R=[];for(let g=0;g<M.length;){let T=M[g];if(/\s/.test(T)){g++;continue}if(M.slice(g,g+2)==="**"){R.push({type:"operator",value:"**"}),g+=2;continue}if(/[0-9]/.test(T)||T==="."&&/[0-9]/.test(M[g+1]||"")){let se="";for(;g<M.length&&/[0-9.]/.test(M[g]);)se+=M[g++];if(g<M.length&&/[eE]/.test(M[g]))for(se+=M[g++],/[+-]/.test(M[g])&&(se+=M[g++]);g<M.length&&/[0-9]/.test(M[g]);)se+=M[g++];R.push({type:"number",value:parseFloat(se)});continue}if(/[a-zA-Z_]/.test(T)){let se="";for(;g<M.length&&/[a-zA-Z0-9_]/.test(M[g]);)se+=M[g++];R.push({type:"identifier",value:se});continue}if("+-*/%(),".includes(T)){R.push({type:"operator",value:T}),g++;continue}throw new Error(`Unexpected character: ${T}`)}return R},J=M=>{let R=0,g=()=>R<M.length?M[R]:null,T=()=>{if(R>=M.length)throw new Error("Unexpected end of input");return M[R++]},se=Y=>{let re=g();if(!re||re.value!==Y)throw new Error(`Expected "${Y}" but got "${re?re.value:"end of input"}`);T()},Ve=()=>{let Y=g();if(!Y)throw new Error("Unexpected end of input");if(Y.type==="number")return T(),{type:"number",value:Y.value};if(Y.type==="identifier"){if(T(),g()&&g().value==="("){T();let re=[];if(g()&&g().value!==")")for(re.push(be());g()&&g().value===",";)T(),re.push(be());return se(")"),{type:"call",func:Y.value,args:re}}return{type:"var",name:Y.value}}if(Y.value==="("){T();let re=be();return se(")"),re}throw new Error(`Unexpected token: ${Y.value}`)},Be=()=>g()&&(g().value==="+"||g().value==="-")?{type:"unary",op:T().value,arg:Be()}:Ve(),Le=()=>{let Y=Be();for(;g()&&g().value==="**";)Y={type:"binary",op:T().value,left:Y,right:Be()};return Y},Se=()=>{let Y=Le();for(;g()&&["*","/","%"].includes(String(g().value));)Y={type:"binary",op:T().value,left:Y,right:Le()};return Y},be=()=>{let Y=Se();for(;g()&&(g().value==="+"||g().value==="-");)Y={type:"binary",op:T().value,left:Y,right:Se()};return Y},Ke=be();if(R<M.length)throw new Error(`Extra tokens after expression: ${M.slice(R).map(Y=>Y.value).join(" ")}`);return Ke},Q=(M,R)=>{switch(M.type){case"number":return M.value;case"var":{let g=R[M.name];if(g===void 0)throw new Error(`Unknown variable: ${M.name}`);if(typeof g=="function")throw new Error(`Expected variable but found function: ${M.name}`);return g}case"binary":{let g=Q(M.left,R),T=Q(M.right,R);switch(M.op){case"+":return g+T;case"-":return g-T;case"*":return g*T;case"/":return g/T;case"%":return g%T;case"**":return g**T;default:throw new Error(`Unknown binary operator: ${M.op}`)}}case"unary":{let g=Q(M.arg,R);switch(M.op){case"+":return+g;case"-":return-g;default:throw new Error(`Unknown unary operator: ${M.op}`)}}case"call":{let g=R[M.func];if(typeof g!="function")throw new Error(`Unknown function: ${M.func}`);return g(...M.args.map(T=>Q(T,R)))}default:throw new Error(`Unknown AST node type: ${M.type}`)}},F=B.slice(5,-1).trim();if(F==="infinity")return U;if(F==="-infinity")return x;if(F==="NaN")return 0;F=F.replace(/(\d+(\.\d+)?)%/g,M=>{if(N===!0)throw new Error("<angle> and <percentage> values are converted to <number> in relative syntax.");let R=y(M,x,U);return R!==void 0?String(R):"0"}),F=F.replace(/(\d+(\.\d+)?)(deg|rad|grad|turn)/g,(M,R,g,T)=>{if(N===!0)throw new Error("<angle> and <percentage> values are converted to <number> in relative syntax.");return String(D(`${parseFloat(R)}${T}`))});let Ee={...p,pi:m,e:w,tau:m*2,pow:$,sqrt:L,sin:q,cos:C,tan:b,asin:E,acos:S,atan:_,atan2:W,exp:O,log:A,log10:z,log2:j,abs:I,min:V,max:he,hypot:fe,round:ge,ceil:de,floor:ie,sign:ye,trunc:ve,random:we};try{let M=ne(F),R=J(M);return Q(R,Ee)}catch(M){throw new Error(`Evaluation error: ${M}`)}},X=()=>{if(/^-?(?:\d+|\d*\.\d+)(?:deg|rad|grad|turn)$/.test(l))return D(l);if(/^-?(?:\d+|\d*\.\d+)$/.test(l))return parseFloat(l);let[B,x]=[0,360];if(l[l.length-1]==="%"){if(G&&h===!0)throw new Error("The legacy color syntax does not allow percentages for <angle> components.");if(N===!0)throw new Error("The relative color syntax doesn't allow percentages for <angle> components.");return y(l,B,x)}if(l.slice(0,5)==="calc(")return k(l,B,x);throw new Error(`Invalid angle value: '${l}'. Must be a number, a number with a unit (deg, rad, grad, turn), or a percentage.`)},te=()=>{if(/^-?(?:\d+|\d*\.\d+)$/.test(l)){if(G&&h===!0)throw new Error("The legacy color syntax does not allow numbers for <percentage> components.");return parseFloat(l)}let[B,x]=[0,100];if(l[l.length-1]==="%")return y(l,B,x);if(l.slice(0,5)==="calc(")return k(l,B,x);throw new Error(`Invalid percentage value: '${l}'. Must be a percentage or a number.`)},K=()=>{if(/^-?(?:\d+|\d*\.\d+)$/.test(l))return parseFloat(l);let[B,x]=v;if(l[l.length-1]==="%")return y(l,B,x);if(l.slice(0,5)==="calc(")return k(l,B,x);throw new Error(`Invalid number value: '${l}'. Must be a number${N===!1?" or a percentage":""}.`)};if(l==="none")return 0;if(l in p)return p[l];if(v==="angle")return X();if(v==="percentage")return te();if(Array.isArray(v))return K();throw new Error(`Unable to parse component token: ${l}`)},n=l=>{let{fn:v,space:p,fromOrigin:G,c1:N,c2:y,c3:D,alpha:k,commaSeparated:X}=l,{components:te,supportsLegacy:K}=t;if(te.alpha={index:3,value:[0,1],precision:3},X&&K!==!0)throw new Error(`<${v}()> does not support comma-separated syntax.`);let B=Object.entries(te).sort((x,U)=>x[1].index-U[1].index);if(G){let x;if(v==="color")x=p;else if(v in Z)x=v;else for(let J in Z)if(Z[J].alphaVariant===v){x=J;break}let U=P.from(G).in(x).toObject({fit:"none",precision:null});return[N,y,D,k].map((J,Q)=>{let[,F]=B[Q];return r(J,F.value,U,X,!0)}).slice(0,4)}else{let x=[],U=[],ne=[N,y,D,k];for(let J=0;J<B.length;J++){let[,Q]=B[J],F=ne[J];if(X&&F==="none")throw new Error(`${v}() cannot use "none" in comma-separated syntax.`);if(Q.index!==3&&Q.value!=="angle"&&Q.value!=="percentage"&&F.slice(0,5)!=="calc("&&U.push(F.trim()[F.length-1]==="%"),F){let Ee=r(F,Q.value,{},X);x[Q.index]=Ee}}if(X&&U.length>1){let J=U.every(Boolean),Q=U.every(F=>!F);if(!J&&!Q)throw new Error(`${v}()'s <number> components must all be numbers or all percentages.`)}return x.slice(0,4)}},o=l=>{let v=(B,x="/")=>{if(l[B]!==void 0){if(l[B]===x)return{value:l[B+1],hasAlpha:!0};throw new Error("Invalid alpha separator")}return{value:"1",hasAlpha:!1}},p,G,N,y,D,k,X,te=!1,K;if(l[0]==="color")if(p="color",l[1]==="from"){G=l[3],N=l[2],y=l[4],D=l[5],k=l[6];let{value:B,hasAlpha:x}=v(7);K=x?9:7,X=B}else{G=l[1],N=null,y=l[2],D=l[3],k=l[4];let{value:B,hasAlpha:x}=v(5);K=x?7:5,X=B}else if(p=l[0],G=null,l[1]==="from"){N=l[2],y=l[3],D=l[4],k=l[5];let{value:B,hasAlpha:x}=v(6);K=x?8:6,X=B}else if(N=null,y=l[1],l[2]===","&&l[4]===","){te=!0,D=l[3],k=l[5];let{value:B,hasAlpha:x}=v(6,",");if(K=x?8:6,x&&l[6]!==",")throw new Error("Comma optional syntax requires no commas at all.");X=B}else{D=l[2],k=l[3];let{value:B,hasAlpha:x}=v(4);K=x?6:4,X=B}if(l.length!==K)throw new Error(`Invalid number of tokens for ${p}(): expected ${K} but got ${l.length}.`);return{fn:p,space:G,fromOrigin:N,c1:y,c2:D,c3:k,alpha:X,commaSeparated:te}},a=l=>{let v=[],p=0,G="";for(;p<l.length&&l[p]!=="(";)G+=l[p],p++;G=G.trim(),v.push(G);let N=l.indexOf("(")+1,y=l.slice(N,-1).trim();if(p=0,y.slice(0,5)==="from "){for(v.push("from"),p+=5;p<y.length&&y[p]===" ";)p++;let D=p;for(;p<y.length&&y[p]!==" ";)p++;let k=y.slice(D,p);if(k.includes("(")){let{expression:X,end:te}=oe(y,D);v.push(X),p=te}else v.push(k);for(;p<y.length&&y[p]===" ";)p++}if(v[0]==="color"&&p<y.length){let D=p;for(;p<y.length&&y[p]!==" ";)p++;for(v.push(y.slice(D,p));p<y.length&&y[p]===" ";)p++}for(;p<y.length;){let D=y[p];if(D===",")v.push(","),p++,y[p]===" "&&p++;else if(D==="/")v.push("/"),p++,y[p]===" "&&p++;else if(D===" ")p++;else if(/[a-zA-Z#]/.test(D)){let k=p,X="";for(;p<y.length&&/[a-zA-Z0-9-%#]/.test(y[p]);)X+=y[p],p++;if(p<y.length&&y[p]==="("){let{expression:te,end:K}=oe(y,k);v.push(te),p=K}else v.push(X)}else if(/[\d.-]/.test(D)){let k="";for(;p<y.length&&/[\d.eE+-]/.test(y[p]);)k+=y[p],p++;if(p<y.length&&y[p]==="%")k+="%",p++,v.push(k);else if(p<y.length&&/[a-zA-Z]/.test(y[p])){let X="";for(;p<y.length&&/[a-zA-Z]/.test(y[p]);)X+=y[p],p++;v.push(k+X)}else v.push(k)}else throw new Error(`Unexpected character: ${D}`)}return v},s=(l,v)=>{let p="color(from ";if(l.slice(0,11)!==p||l[l.length-1]!==")")return!1;let G=l.slice(p.length,-1).trim(),{expression:N,end:y}=oe(G,0);if(!N)return!1;let k=G.slice(y).trim().split(/\s+/);return k.length<1?!1:k[0]===v},{components:c,bridge:i,fromBridge:d,toBridge:u,alphaVariant:f,supportsLegacy:h}=t,{PI:m,E:w,pow:$,sqrt:L,sin:q,cos:C,tan:b,asin:E,acos:S,atan:_,atan2:W,exp:O,log:A,log10:z,log2:j,abs:I,min:V,max:he,hypot:fe,round:ge,ceil:de,floor:ie,sign:ye,trunc:ve,random:we}=Math;return{isValid:l=>{let{alphaVariant:v=e}=t;if(e in pe){let p=l.slice(0,`color(${e} `.length)===`color(${e} `,G=l.slice(0,10)==="color(from"&&s(l,e);return(p||G)&&l[l.length-1]===")"}return(l.slice(0,`${e}(`.length)===`${e}(`||l.slice(0,`${v}(`.length)===`${v}(`)&&l[l.length-1]===")"},bridge:i,toBridge:l=>[...u(l.slice(0,3)),l[3]??1],parse:l=>{let v=a(l),p=o(v),G=n(p);return[...G.slice(0,3),G[3]??1]},fromBridge:l=>[...d(l),l[3]??1],format:([l,v,p,G=1],N={})=>{let{legacy:y=!1,fit:D=ee.defaults.fit,precision:k,units:X=!1}=N,te=le([l,v,p],e,{method:D,precision:k}),K=Number(V(he(G,0),1).toFixed(3)).toString(),B=te.map((x,U)=>{if((X||y)&&c){let ne=Object.values(c).find(J=>J.index===U);if(ne?.value==="percentage")return`${x}%`;if(ne?.value==="angle"&&X)return`${x}deg`}return x.toString()});return e in pe?`color(${e} ${B.join(" ")}${G!==1?` / ${K}`:""})`:y&&h?G===1?`${e}(${B.join(", ")})`:`${f||e}(${B.join(", ")}, ${K})`:`${e}(${B.join(" ")}${G!==1?` / ${K}`:""})`}}}function ae(e,t){let{fromLinear:r=s=>s,toLinear:n=s=>s,toBridgeMatrix:o,fromBridgeMatrix:a}=t;return{supportsLegacy:!1,targetGamut:t.targetGamut===null?null:e,components:Object.fromEntries(t.components.map((s,c)=>[s,{index:c,value:[0,1],precision:5}])),bridge:t.bridge,toBridge:s=>ce(o,s.map(c=>n(c))),fromBridge:s=>ce(a,s).map(c=>r(c))}}var H={D50_to_D65:[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]],D65_to_d50:[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]],SRGB_to_XYZD65:[[506752/1228815,87881/245763,12673/70218],[87098/409605,175762/245763,12673/175545],[7918/409605,87881/737289,1001167/1053270]],XYZD65_to_SRGB:[[12831/3959,-329/214,-1974/3959],[-851781/878810,1648619/878810,36519/878810],[705/12673,-2585/12673,705/667]],P3_to_XYZD65:[[608311/1250200,189793/714400,198249/1000160],[35783/156275,247089/357200,198249/2500400],[0/1,32229/714400,5220557/5000800]],XYZD65_to_P3:[[446124/178915,-333277/357830,-72051/178915],[-14852/17905,63121/35810,423/17905],[11844/330415,-50337/660830,316169/330415]],REC2020_to_XYZD65:[[63426534/99577255,20160776/139408157,47086771/278816314],[26158966/99577255,472592308/697040785,8267143/139408157],[0/1,19567812/697040785,295819943/278816314]],XYZD65_to_REC2020:[[30757411/17917100,-6372589/17917100,-4539589/17917100],[-19765991/29648200,47925759/29648200,467509/29648200],[792561/44930125,-1921689/44930125,42328811/44930125]],A98_to_XYZD65:[[573536/994567,263643/1420810,187206/994567],[591459/1989134,6239551/9945670,374412/4972835],[53769/1989134,351524/4972835,4929758/4972835]],ProPhoto_to_XYZD50:[[.7977666449006423,.13518129740053308,.0313477341283922],[.2880748288194013,.711835234241873,8993693872564e-17],[0,0,.8251046025104602]],XYZD50_to_ProPhoto:[[1.3457868816471583,-.25557208737979464,-.05110186497554526],[-.5446307051249019,1.5082477428451468,.02052744743642139],[0,0,1.2119675456389452]],XYZD65_to_A98:[[1829569/896150,-506331/896150,-308931/896150],[-851781/878810,1648619/878810,36519/878810],[16779/1248040,-147721/1248040,1266979/1248040]],LMS_to_XYZD65:[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],XYZD65_to_LMS:[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],LMS_to_OKLAB:[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],OKLAB_to_LMS:[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]]},ke={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,"ease-in-cubic":e=>e*e*e,"ease-out-cubic":e=>--e*e*e+1,"ease-in-out-cubic":e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2},Ae={"chroma-reduction":(e,t)=>{let r=new P(t,e),{targetGamut:n}=Z[t];if(n===null||(n===void 0&&(n="srgb"),r.inGamut(n,1e-5)))return e;let[o,,a]=r.in("oklch").toArray({fit:"none",precision:null}),s=Math.min(1,Math.max(0,o)),c=0,i=1,d=1e-6,u=[];for(;i-c>d;){let h=(c+i)/2,m=new P("oklch",[s,h,a]);if(m.inGamut(n,1e-5))c=h;else{let w=le(m.toArray({fit:"none",precision:null}).slice(0,3),t,{method:"clip"}),$=new P(t,w);if(m.deltaEOK($)<2)return u=w,u;i=h}}return u=new P("oklch",[s,c,a]).in(t).toArray({fit:"none",precision:null}),u},"css-gamut-map":(e,t)=>{let{targetGamut:r}=Z[t];if(r===null)return e;r===void 0&&(r="srgb");let n=new P(t,e),[o,a,s]=n.in("oklch").toArray({fit:"none",precision:null});if(o>=1)return new P("oklab",[1,0,0]).in(t).toArray({fit:"none",precision:null});if(o<=0)return new P("oklab",[0,0,0]).in(t).toArray({fit:"none",precision:null});if(n.inGamut(r,1e-5))return e;let c=.02,i=1e-4,d=new P("oklch",[o,a,s]),u=le(d.in(t).toArray({fit:"none",precision:null}).slice(0,3),t,{method:"clip"}),f=new P(t,u);if(d.deltaEOK(f)<c)return u;let m=0,w=a,$=!0;for(;w-m>i;){let L=(m+w)/2,q=new P("oklch",[o,L,s]);if($&&q.inGamut(r,1e-5))m=L;else{let C=le(q.in(t).toArray({fit:"none",precision:null}).slice(0,3),t,{method:"clip"});u=C;let b=new P(t,C),E=q.deltaEOK(b);if(E<c){if(c-E<i)return u;$=!1,m=L}else w=L}}return u}};function Te(e){let t=e.map(r=>{let n=r/255,o=n<0?-1:1,a=Math.abs(n);return a<=.04045?n/12.92:o*((a+.055)/1.055)**2.4});return ce(H.SRGB_to_XYZD65,t)}function Ze(e){return ce(H.XYZD65_to_SRGB,e).map(n=>{let o=n<0?-1:1,a=Math.abs(n);return a>.0031308?o*(1.055*a**(1/2.4)-.055):12.92*n}).map(n=>n*255)}function $e([e,t,r]){t/=100,r/=100;let n=o=>{let a=(o+e/30)%12,s=t*Math.min(r,1-r);return r-s*Math.max(-1,Math.min(a-3,9-a,1))};return[n(0)*255,n(8)*255,n(4)*255]}function De(e){let[t,r,n]=e.map(u=>u/255),o=Math.max(t,r,n),a=Math.min(t,r,n),s=(o+a)/2,c=0,i=0,d=o-a;return d!==0&&(i=d/(1-Math.abs(2*s-1)),c=o===t?(r-n)/d+(r<n?6:0):o===r?(n-t)/d+2:(t-r)/d+4,c*=60),[c%360,i*100,s*100]}function ze([e,t,r]){if(t/=100,r/=100,t+r>=1){let o=t/(t+r)*255;return[o,o,o]}return $e([e,100,50]).map(o=>o/255).map(o=>(o*(1-t-r)+t)*255)}function Ie(e){let[t,r,n]=e.map(i=>i/255),o=Math.max(t,r,n),a=Math.min(t,r,n),s=0,c=o-a;return c===0?s=0:(s=o===t?(r-n)/c+(r<n?6:0):o===r?(n-t)/c+2:(t-r)/c+4,s=s*60%360),[s,a*100,(1-o)*100]}function Xe([e,t,r]){let n=[.9642956764295677,1,.8251046025104602],o=24389/27,a=216/24389,s=(e+16)/116,c=t/500+s,i=s-r/200;return[c**3>a?c**3:(116*c-16)/o,e>o*a?s**3:e/o,i**3>a?i**3:(116*i-16)/o].map((u,f)=>u*n[f])}function Re(e){let t=[.9642956764295677,1,.8251046025104602],r=24389/27,n=216/24389,o=e.map((i,d)=>i/t[d]),[a,s,c]=o.map(i=>i>n?Math.cbrt(i):(r*i+16)/116);return[116*s-16,500*(a-s),200*(s-c)]}function Ye([e,t,r]){return[e,t*Math.cos(r*Math.PI/180),t*Math.sin(r*Math.PI/180)]}function Pe([e,t,r]){let n=Math.hypot(t,r),o=Math.atan2(r,t)*180/Math.PI;return o<0&&(o+=360),[e,n,o]}function qe(e){let{LMS_to_XYZD65:t,OKLAB_to_LMS:r}=H,n=ce(r,e);return ce(t,n.map(o=>o**3))}function Ne(e){let{XYZD65_to_LMS:t,LMS_to_OKLAB:r}=H,n=ce(t,e);return ce(r,n.map(Math.cbrt))}function Fe([e,t,r]){return[e,t*Math.cos(r*Math.PI/180),t*Math.sin(r*Math.PI/180)]}function He([e,t,r]){let n=Math.hypot(t,r),o=Math.atan2(r,t)*180/Math.PI;return o<0&&(o+=360),[e,n,o]}var Me={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},pe={srgb:ae("srgb",{components:["r","g","b"],bridge:"xyz-d65",toLinear:e=>{let t=e<0?-1:1,r=Math.abs(e);return r<=.04045?t*(r/12.92):t*Math.pow((r+.055)/1.055,2.4)},fromLinear:e=>{let t=e<0?-1:1,r=Math.abs(e);return r>.0031308?t*(1.055*Math.pow(r,1/2.4)-.055):t*(12.92*r)},toBridgeMatrix:H.SRGB_to_XYZD65,fromBridgeMatrix:H.XYZD65_to_SRGB}),"srgb-linear":ae("srgb-linear",{components:["r","g","b"],bridge:"xyz-d65",toBridgeMatrix:H.SRGB_to_XYZD65,fromBridgeMatrix:H.XYZD65_to_SRGB}),"display-p3":ae("display-p3",{components:["r","g","b"],bridge:"xyz-d65",toLinear:e=>{let t=e<0?-1:1,r=Math.abs(e);return r<=.04045?t*(r/12.92):t*Math.pow((r+.055)/1.055,2.4)},fromLinear:e=>{let t=e<0?-1:1,r=Math.abs(e);return r>.0031308?t*(1.055*Math.pow(r,1/2.4)-.055):t*(12.92*r)},toBridgeMatrix:H.P3_to_XYZD65,fromBridgeMatrix:H.XYZD65_to_P3}),rec2020:ae("rec2020",{components:["r","g","b"],bridge:"xyz-d65",toLinear:e=>{let t=1.09929682680944,r=.018053968510807,n=e<0?-1:1,o=Math.abs(e);return o<r*4.5?n*(o/4.5):n*Math.pow((o+t-1)/t,1/.45)},fromLinear:e=>{let t=1.09929682680944,r=.018053968510807,n=e<0?-1:1,o=Math.abs(e);return o>r?n*(t*Math.pow(o,.45)-(t-1)):n*(4.5*o)},toBridgeMatrix:H.REC2020_to_XYZD65,fromBridgeMatrix:H.XYZD65_to_REC2020}),"a98-rgb":ae("a98-rgb",{components:["r","g","b"],bridge:"xyz-d65",toLinear:e=>{let t=e<0?-1:1,r=Math.abs(e);return t*Math.pow(r,563/256)},fromLinear:e=>{let t=e<0?-1:1,r=Math.abs(e);return t*Math.pow(r,256/563)},toBridgeMatrix:H.A98_to_XYZD65,fromBridgeMatrix:H.XYZD65_to_A98}),"prophoto-rgb":ae("prophoto-rgb",{components:["r","g","b"],bridge:"xyz-d50",toLinear:e=>{let r=e<0?-1:1,n=Math.abs(e);return n<=.03125?r*(n/16):r*Math.pow(n,1.8)},fromLinear:e=>{let t=.001953125,r=e<0?-1:1,n=Math.abs(e);return n>=t?r*Math.pow(n,1/1.8):r*(16*n)},toBridgeMatrix:H.ProPhoto_to_XYZD50,fromBridgeMatrix:H.XYZD50_to_ProPhoto}),"xyz-d65":ae("xyz-d65",{targetGamut:null,components:["x","y","z"],bridge:"xyz-d65",toBridgeMatrix:[[1,0,0],[0,1,0],[0,0,1]],fromBridgeMatrix:[[1,0,0],[0,1,0],[0,0,1]]}),"xyz-d50":ae("xyz-d50",{targetGamut:null,components:["x","y","z"],bridge:"xyz-d65",toBridgeMatrix:H.D50_to_D65,fromBridgeMatrix:H.D65_to_d50}),xyz:ae("xyz",{targetGamut:null,components:["x","y","z"],bridge:"xyz-d65",toBridgeMatrix:[[1,0,0],[0,1,0],[0,0,1]],fromBridgeMatrix:[[1,0,0],[0,1,0],[0,0,1]]})},Z={rgb:{supportsLegacy:!0,alphaVariant:"rgba",components:{r:{index:0,value:[0,255],precision:0},g:{index:1,value:[0,255],precision:0},b:{index:2,value:[0,255],precision:0}},bridge:"xyz-d65",toBridge:Te,fromBridge:Ze},hsl:{supportsLegacy:!0,alphaVariant:"hsla",components:{h:{index:0,value:"angle",precision:0},s:{index:1,value:"percentage",precision:0},l:{index:2,value:"percentage",precision:0}},bridge:"rgb",toBridge:$e,fromBridge:De},hwb:{components:{h:{index:0,value:"angle",precision:0},w:{index:1,value:"percentage",precision:0},b:{index:2,value:"percentage",precision:0}},bridge:"rgb",toBridge:ze,fromBridge:Ie},lab:{targetGamut:null,components:{l:{index:0,value:"percentage",precision:5},a:{index:1,value:[-125,125],precision:5},b:{index:2,value:[-125,125],precision:5}},bridge:"xyz-d50",toBridge:Xe,fromBridge:Re},lch:{targetGamut:null,components:{l:{index:0,value:"percentage",precision:5},c:{index:1,value:[0,150],precision:5},h:{index:2,value:"angle",precision:5}},bridge:"lab",toBridge:Ye,fromBridge:Pe},oklab:{targetGamut:null,components:{l:{index:0,value:[0,1],precision:5},a:{index:1,value:[-.4,.4],precision:5},b:{index:2,value:[-.4,.4],precision:5}},bridge:"xyz-d65",toBridge:qe,fromBridge:Ne},oklch:{targetGamut:null,components:{l:{index:0,value:[0,1],precision:5},c:{index:1,value:[0,.4],precision:5},h:{index:2,value:"angle",precision:5}},bridge:"oklab",toBridge:Fe,fromBridge:He},...pe},_e=Object.fromEntries(Object.entries(Z).map(([e,t])=>[e,je(e,t)])),Ge={"hex-color":{isValid:e=>e[0]==="#",bridge:"rgb",toBridge:e=>e,parse:e=>{let t=e.slice(1);if(![3,4,6,8].includes(t.length))throw new Error("Invalid hex color length.");for(let c of t){let i=c.charCodeAt(0),d=i>=48&&i<=57,u=i>=97&&i<=102,f=i>=65&&i<=70;if(!(d||u||f))throw new Error("Invalid hex color character.")}let r=c=>parseInt(c.length===1?c+c:c,16),[n,o,a,s=255]=t.length<=4?t.split("").map(r):[t.slice(0,2),t.slice(2,4),t.slice(4,6),t.slice(6,8)].map(c=>parseInt(c||"ff",16));return[n,o,a,s/255]},fromBridge:e=>e,format:([e,t,r,n=1])=>{let o=s=>s.toString(16).padStart(2,"0");return`#${[e,t,r].map(s=>o(Math.round(Math.max(0,Math.min(255,s))))).join("")}${n<1?o(Math.round(n*255)):""}`}},..._e,"named-color":{isValid:e=>Object.keys(Me).some(t=>t===e),bridge:"rgb",toBridge:e=>e,parse:e=>{let t=Me[e];if(!t)throw new Error(`Invalid named-color: ${e}.`);return[...t,1]},fromBridge:e=>e,format:e=>{let[t,r,n]=e.map((o,a)=>a<3?Math.round(Math.min(255,Math.max(0,o))):o);for(let[o,[a,s,c]]of Object.entries(Me))if(t===a&&r===s&&n===c)return o}},"color-mix":{isValid:e=>e.slice(0,10)==="color-mix("&&e[e.length-1]===")",bridge:"rgb",toBridge:e=>e,parse:e=>{let t=b=>{let E=b.trim(),S,_=E,W=_.match(/^(\d+)%\s+/);if(W){let j=parseInt(W[1],10);S=Math.min(1,Math.max(0,j/100)),_=_.slice(W[0].length).trim()}let O="",A="";if(/^[a-z]/i.test(_)){let{expression:j,end:I}=oe(_,0);if(j)O=j,A=_.slice(I).trim();else{let V=_.match(/^([^\s]+)(.*)$/);O=V?V[1]:_,A=V?V[2].trim():""}}else{let j=_.match(/^([^\s]+)(.*)$/);O=j?j[1]:_,A=j?j[2].trim():""}if(S===void 0){let j=A.match(/^(-?(?:\d+\.?\d*|\.\d+))%/);if(j){if(S=parseInt(j[1],10)/100,A=A.slice(j[0].length).trim(),S<0)throw new Error("Percentages less than 0 are not valid.");if(S>1)throw new Error("Percentages greater than 100 are not valid.")}else if(A.slice(0,5)==="calc("){let{expression:I,end:V}=oe(A,0);if(!I)throw new Error("Malformed calc() weight expression.");A=A.slice(V).trim()}}if(A.length>0)throw new Error(`Unexpected extra tokens after color: '${A}'.`);return{color:P.from(O),weight:S}},r=(b,E)=>{if(b===void 0&&typeof E=="number")b=1-E;else if(typeof b=="number"&&E===void 0)E=1-b;else if(b===void 0&&E===void 0)b=E=.5;else if(b=b,E=E,b+E<=0)throw new Error("Sum of percengates cannot be 0%.");let S=b+E,_;return S>1?(b/=S,E/=S):(b/=S,E/=S,_=S),{amount:E,alphaMultiplier:_}},n="color-mix",{expression:o}=oe(e,n.length);if(!o)throw new Error("Malformed color-mix expression.");let a=o.slice(1,-1).trim(),s=[],c=0,i="";for(;c<a.length;){let b=a[c];if(b===","){s.push(i.trim()),i="",c++;continue}if(b==="("||/[a-zA-Z]/.test(b)){let{expression:E,end:S}=oe(a,c);if(E){i+=E,c=S;continue}}i+=b,c++}if(s.push(i.trim()),s.length!==3)throw new Error("color-mix must have three comma-separated parts.");let u=s[0].match(/^in\s+([a-z0-9-]+)(?:\s+(shorter|longer|increasing|decreasing)\s+hue)?$/);if(!u)throw new Error("Invalid model and hue format.");let f=u[1],h=u[2];if(f==="rgb")throw new Error('RGB model is not allowed in color-mix(). Use "srgb" instead.');if(h){let b=Z[f].components;if(!b)throw new Error(`Unknown color model: ${f}.`);if(!Object.values(b).some(S=>S.value==="angle"))throw new Error(`Hue interpolation not supported in ${f} space.`)}else h="shorter";let{color:m,weight:w}=t(s[1]),{color:$,weight:L}=t(s[2]),{amount:q,alphaMultiplier:C=1}=r(w,L);return m.with({alpha:b=>b*C}).in(f).mix($.with({alpha:b=>b*C}),{amount:q,hue:h}).in("rgb").toArray({fit:"none",precision:null})}},transparent:{isValid:e=>e==="transparent",bridge:"rgb",toBridge:e=>e,parse:e=>[0,0,0,0]}},ue={...Ge,currentColor:{isValid:e=>e==="currentcolor",bridge:"rgb",toBridge:e=>e,parse:e=>[0,0,0,1]},"system-color":{isValid:e=>Object.keys(ee.systemColors).some(t=>t.toLowerCase()===e),bridge:"rgb",toBridge:e=>e,parse:e=>{let{systemColors:t}=ee,r=Object.keys(t).find(o=>o.toLowerCase()===e);return[...t[r][ee.theme==="light"?0:1],1]}},"contrast-color":{isValid:e=>e.slice(0,15)==="contrast-color("&&e[e.length-1]===")",bridge:"rgb",toBridge:e=>e,parse:e=>{let t=e.slice(15,-1),[,r]=P.from(t).in("xyz-d65").toArray({fit:"none",precision:null});return r>.5?[0,0,0,1]:[255,255,255,1]}},"device-cmyk":{isValid:e=>e.slice(0,12)==="device-cmyk("&&e[e.length-1]===")",bridge:"rgb",toBridge:e=>e,parse:e=>{let t="device-cmyk",r=e.indexOf(t);if(r===-1)throw new Error("Invalid device-cmyk syntax");let{expression:n}=oe(e,r+t.length);if(!n)throw new Error("Malformed device-cmyk expression");let o=n.slice(1,-1).trim(),a=[],s=0;for(;s<o.length;){let C=o[s];if(C===" "){s++;continue}if(C==="("||/[a-zA-Z-]/.test(C)){let{expression:b,end:E}=oe(o,s);if(b){a.push(b),s=E;continue}}if(/[\d.+-]/.test(C)){let b="";for(;s<o.length&&/[\d.eE+-]/.test(o[s]);)b+=o[s],s++;if(s<o.length&&o[s]==="%")b+="%",s++;else if(s<o.length&&/[a-zA-Z]/.test(o[s]))for(;s<o.length&&/[a-zA-Z]/.test(o[s]);)b+=o[s],s++;a.push(b);continue}if(C===","||C==="/"){a.push(C),s++;continue}throw new Error(`Unexpected character: ${C}`)}let c=C=>C[C.length-1]==="%"?parseFloat(C)/100:parseFloat(C);if(a.length>=2&&a[1]===","){let C=a.filter(b=>b!==",");if(C.length===4||C.length===5){let[b,E,S,_,W=1]=C.map(c),O=1-Math.min(1,b*(1-_)+_),A=1-Math.min(1,E*(1-_)+_),z=1-Math.min(1,S*(1-_)+_);return[O*255,A*255,z*255,W]}throw new Error("Invalid number of components for comma-separated device-cmyk")}let i=0,d=[];for(;i<a.length&&d.length<4&&a[i]!=="/"&&a[i]!==",";)d.push(a[i]),i++;if(d.length!==4)throw new Error("Invalid number of components for space-separated device-cmyk");let[u,f,h,m]=d.map(c),w=1;if(i<a.length&&a[i]==="/"){if(i++,i>=a.length)throw new Error("Missing alpha value");w=c(a[i]),i++}if(i<a.length&&a[i]===","){i++;let C=a.slice(i).join(" ");return P.from(C).in("rgb").toArray({fit:"none",precision:null})}let $=1-Math.min(1,u*(1-m)+m),L=1-Math.min(1,f*(1-m)+m),q=1-Math.min(1,h*(1-m)+m);return[$*255,L*255,q*255,w]},fromBridge:e=>e,format:([e,t,r,n=1],o={})=>{let{legacy:a=!1,precision:s=3,fit:c=ee.defaults.fit}=o,[i,d,u]=le([e,t,r],"rgb",{method:c}),f=i/255,h=d/255,m=u/255,w=1-Math.max(f,h,m),$=_=>Number(s===null?_:_.toFixed(s)).toString(),L=$(w===1?0:(1-f-w)/(1-w)),q=$(w===1?0:(1-h-w)/(1-w)),C=$(w===1?0:(1-m-w)/(1-w)),b=$(w),E=Number(n.toFixed(3)).toString();if(a)return`device-cmyk(${L}, ${q}, ${C}, ${b}${n<1?`, ${E}`:""})`;let S=_e.rgb.format?.([i,d,u,n],o);return`device-cmyk(${L} ${q} ${C} ${b}${n<1?` / ${E}`:""}, ${S})`}},"light-dark":{isValid:e=>e.slice(0,11)==="light-dark("&&e[e.length-1]===")",bridge:"rgb",toBridge:e=>e,parse:e=>{let t="light-dark",r=e.indexOf(t);if(r===-1)throw new Error("Not a <light-dark()> expression");let{expression:n}=oe(e,r+t.length);if(!n)throw new Error("Malformed <light-dark()> expression");let o=n.slice(1,-1).trim(),a=[],s="",c=0;for(;c<o.length;){let f=o[c];if(f===","){a.push(s.trim()),s="",c++;continue}if(f==="("||/[a-zA-Z]/.test(f)){let{expression:h,end:m}=oe(o,c);if(h){s+=h,c=m;continue}}s+=f,c++}if(a.push(s.trim()),a.length!==2)throw new Error("Invalid light-dark format");let[i,d]=a,{theme:u}=ee;return P.from(u==="light"?i:d).toArray({fit:"none",precision:null})}}};var P=class e{model;coords;constructor(t,r=[0,0,0,0]){if(!(t in Z))throw new Error(`Unsupported color model: '${t}'`);if([3,4].includes(r.length)===!1)throw new Error("Coordinates array must have 3 or 4 elements.");let n=r.slice();n.length===3&&n.push(1),this.model=t,this.coords=n}static from(t){let r=xe(t);for(let n in ue){let o=n,{parse:a,bridge:s,toBridge:c,isValid:i}=ue[o];if(!i(r))continue;let d=a(r),u=o in Z?d:c(d),f=o in Z?o:s;return new e(f,u)}throw new Error(`Unsupported or invalid color format: '${t}'.`)}static type(t,r=!1){let n=xe(t);for(let o in ue){let a=o,{isValid:s,bridge:c,parse:i,toBridge:d}=ue[a];if(s(n)){if(!r)return a;try{let u=i(n),f=a in Z?u:d(u),h=o in Z?o:c;return typeof new e(h,f)=="object"?a:void 0}catch{return}}}}static isValid(t,r){try{if(r){let n=r?.trim().toLowerCase(),o=xe(t),{isValid:a,bridge:s,parse:c,toBridge:i}=ue[n];if(!a(o))return!1;let d=c(o),u=n in Z?d:i(d),f=n in Z?n:s;return!!new e(f,u)}return!!e.from(t)}catch{return!1}}static random(t={}){let r=Object.keys(Z),n=t.model??r[Math.floor(Math.random()*r.length)],{components:o}=Z[n],a=new Set([...Object.keys(o),"alpha"]);for(let c of["limits","bias","base","deviation"]){let i=t[c];if(i){for(let d of Object.keys(i))if(!a.has(d))throw new Error(`Invalid component "${d}" for model "${n}". Valid components: ${[...a].join(", ")}`)}}let s=[];for(let[c,i]of Object.entries(o)){let d=t.base?.[c],u=t.deviation?.[c],f;if(d!=null&&u!=null){let h=Math.random()||1e-9,m=Math.random()||1e-9;f=d+Math.sqrt(-2*Math.log(h))*Math.cos(2*Math.PI*m)*u}else{let[h,m]=i.value==="angle"?[0,360]:i.value==="percentage"?[0,100]:i.value,w=t.limits?.[c];if(w){let[q,C]=w;h=Math.max(h,q),m=Math.min(m,C)}let $=Math.random(),L=t.bias?.[c];L&&($=L($)),f=h+$*(m-h)}if(i.value==="angle")f=(f%360+360)%360;else if(i.value==="percentage")f=Math.min(100,Math.max(0,f));else if(Array.isArray(i.value)){let[h,m]=i.value;f=Math.min(m,Math.max(h,f))}else throw new Error(`Invalid component value definition for "${c}".`);s[i.index]=f}return new e(n,s)}to(t,r={}){let n=t.toLowerCase(),{legacy:o=!1,fit:a=ee.defaults.fit,precision:s,units:c=!1}=r,i=ue[n];if(!i)throw new Error(`Unsupported color type: '${n}'.`);let{fromBridge:d,bridge:u,format:f}=i;if(!d||!f)throw new Error(`Invalid output type: '${n}'.`);let h=m=>f(m,{legacy:o,fit:a,precision:s,units:c});return n===this.model?h(this.coords):n in Z?h(this.in(n).toArray({fit:"none",precision:null})):h(d(this.in(u).toArray({fit:"none",precision:null})))}in(t){let r=this.model,n=t.trim().toLowerCase();if(n===r)return new e(n,[...this.coords]);let o=me.get("graph"),a=me.get("paths");if(!o){o={};for(let[u,f]of Object.entries(Z)){let{bridge:h}=f;o[u]=[...o[u]||[],h],o[h]=[...o[h]||[],u]}me.set("graph",o)}a||(a=new Map,me.set("paths",a));let s=`${r}-${n}`,c=this.coords.slice(0,3);if(!a.has(s)){let u=[r],f={[r]:null};for(let m=0;m<u.length;m++){let w=u[m];if(w===n)break;for(let $ of o[w]||[])$ in f||(f[$]=w,u.push($))}let h=[];for(let m=n;m;m=f[m])h.push(m);if(h.reverse(),!h.length||h[0]!==r)throw new Error(`Cannot convert from ${r} to ${n}. No path found.`);a.set(s,h)}let i=[...c],d=a.get(s);for(let u=0;u<d.length-1;u++){let f=d[u],h=d[u+1],m=Z[f],w=Z[h];if(m.toBridge&&m.bridge===h)i=m.toBridge(i);else if(w.fromBridge&&w.bridge===f)i=w.fromBridge(i);else throw new Error(`No conversion found between ${f} and ${h}.`)}return new e(n,[...i.slice(0,3),this.coords[3]??1])}toString(t={}){let{format:r}=ue[this.model],{legacy:n=!1,fit:o=ee.defaults.fit,precision:a,units:s=!1}=t;return r?.(this.coords,{legacy:n,fit:o,precision:a,units:s})}toObject(t={}){let r=this.toArray(t),{components:n}=Z[this.model];if(!n)throw new Error(`Model ${this.model} does not have defined components.`);let o={...n,alpha:{index:3,value:[0,1],precision:3}},a={};for(let[s,{index:c}]of Object.entries(o))a[s]=r[c];return a}toArray(t={}){let{fit:r=ee.defaults.fit,precision:n}=t,{model:o,coords:a}=this,{components:s}=Z[o];if(!s)throw new Error(`Model ${o} does not have defined components.`);let c={...s,alpha:{index:3,value:[0,1],precision:3}},i=(f,h)=>{let m=Object.values(c)[h]?.value,[w,$]=Array.isArray(m)?m:m==="angle"?[0,360]:[0,100];return Number.isNaN(f)?0:f===1/0?$:f===-1/0?w:typeof f=="number"?f:0},d=a.slice(0,3).map(i);return[...le(d,o,{method:r,precision:n}).slice(0,3),a[3]]}with(t){let{model:r}=this,n=this.toArray({fit:"none",precision:null}),{components:o}=Z[r];if(!o)throw new Error(`Model ${r} does not have defined components.`);let a={...o,alpha:{index:3,value:[0,1],precision:3}},s=Object.keys(a),c;if(typeof t=="function"?c=t(Object.fromEntries(s.map(u=>[u,n[a[u].index]]))):c=t,Array.isArray(c)){let d=n.map((u,f)=>{let h=c[f],{value:m}=Object.values(a).find(L=>L.index===f);if(typeof h!="number")return u;let[w,$]=Array.isArray(m)?m:m==="angle"?[0,360]:[0,100];return Number.isNaN(h)?0:h===1/0?$:h===-1/0?w:h});return new e(r,[...d.slice(0,3),n[3]])}let i=[...n];for(let d of s){if(!(d in c))continue;let{index:u,value:f}=a[d],h=n[u],m=c[d],w=typeof m=="function"?m(h):m;if(typeof w=="number"){let[$,L]=Array.isArray(f)?f:f==="angle"?[0,360]:[0,100];Number.isNaN(w)?w=0:w===1/0?w=L:w===-1/0&&(w=$)}i[u]=w}return new e(r,[...i.slice(0,3),i[3]??n[3]])}mix(t,r={}){let{model:n}=this,o=this.toArray({fit:"none",precision:null}),{components:a}=Z[n];if(!a)throw new Error(`Model ${n} does not have defined components.`);let{hue:s="shorter",amount:c=.5,easing:i="linear",gamma:d=1}=r,u={...a,alpha:{index:3,value:[0,1],precision:3}},f=(O,A)=>{let z=((A-O)%360+360)%360;return z>180?z-360:z},h=(O,A)=>f(O,A)>=0?f(O,A)-360:f(O,A)+360,m=(O,A,z,j)=>{let I=V=>(V%360+360)%360;switch(j){case"shorter":return I(O+z*f(O,A));case"longer":return I(O+z*h(O,A));case"increasing":return I(O*(1-z)+(A<O?A+360:A)*z);case"decreasing":return I(O*(1-z)+(A>O?A-360:A)*z);default:throw new Error(`Invalid hue interpolation method: ${j}`)}},w=Math.max(0,Math.min(1,c)),$=typeof i=="function"?i:ke[i],L=Math.pow($(w),1/d),q=typeof t=="string"?e.from(t):t,C=o.slice(0,3),b=q.in(n).toArray({fit:"none",precision:null}).slice(0,3),E=o[3],S=q.coords[3],_=Object.entries(u).find(([O])=>O==="h")?.[1].index;if(w===0)return new e(n,[...C,E]);if(w===1)return new e(n,[...b,S]);if(E<1||S<1){let O=C.map((j,I)=>{let V=b[I];if(I===_)return m(j,V,L,s);let he=j*E,fe=V*S;return he*(1-L)+fe*L}),A=E*(1-L)+S*L,z=A>0?O.map((j,I)=>I===_?j:j/A):C.map((j,I)=>I===_?O[I]:0);return new e(n,[...z,A])}let W=C.map((O,A)=>{let z=Object.values(u).find(I=>I.index===A);if(!z)return O;let j=b[A];return z.value==="angle"?m(O,j,L,s):O+(j-O)*L});return new e(n,[...W,1])}within(t,r=ee.defaults.fit){let n=t.trim().toLowerCase();if(!(n in pe))throw new Error(`Unsupported color gamut: '${n}'.`);let o=this.in(n).toArray({fit:r,precision:null});return new e(n,o).in(this.model)}contrast(t){let r=typeof t=="string"?e.from(t):t,[,n]=this.in("xyz-d65").toArray({fit:"none",precision:null}),[,o]=r.in("xyz-d65").toArray({fit:"none",precision:null});return(Math.max(n,o)+.05)/(Math.min(n,o)+.05)}deltaEOK(t){let r={fit:"none",precision:null},[n,o,a]=this.in("oklab").toArray(r),[s,c,i]=(typeof t=="string"?e.from(t):t).in("oklab").toArray(r),d=n-s,u=o-c,f=a-i;return Math.sqrt(d**2+u**2+f**2)*100}deltaE76(t){let r={fit:"none",precision:null},[n,o,a]=this.in("lab").toArray(r),[s,c,i]=(typeof t=="string"?e.from(t):t).in("lab").toArray(r),d=n-s,u=o-c,f=a-i;return Math.hypot(d,u,f)}deltaE94(t){let r={fit:"none",precision:null},[n,o,a]=this.in("lab").toArray(r),[s,c,i]=(typeof t=="string"?e.from(t):t).in("lab").toArray(r),d=n-s,u=o-c,f=a-i,h=Math.sqrt(o*o+a*a),m=Math.sqrt(c*c+i*i),w=h-m,$=Math.sqrt(Math.max(0,u*u+f*f-w*w)),L=1,q=1,C=1,b=.045,E=.015,S=1+b*h,_=1+E*h;return Math.sqrt((d/L)**2+(w/(q*S))**2+($/(C*_))**2)}deltaE2000(t){let r={fit:"none",precision:null},[n,o,a]=this.in("lab").toArray(r),[s,c,i]=(typeof t=="string"?e.from(t):t).in("lab").toArray(r),d=Math.PI,u=d/180,f=180/d,h=Math.sqrt(o**2+a**2),m=Math.sqrt(c**2+i**2),w=(h+m)/2,$=Math.pow(25,7),L=Math.pow(w,7),q=.5*(1-Math.sqrt(L/(L+$))),C=(1+q)*o,b=(1+q)*c,E=Math.sqrt(C**2+a**2),S=Math.sqrt(b**2+i**2),_=Math.atan2(a,C),W=Math.atan2(i,b);_<0&&(_+=2*d),W<0&&(W+=2*d),_*=f,W*=f;let O=s-n,A=S-E,z=W-_,j=Math.abs(z),I=0;E*S!==0&&(j<=180?I=z:z>180?I=z-360:I=z+360);let V=2*Math.sqrt(E*S)*Math.sin(I*u/2),he=(n+s)/2,fe=(E+S)/2,ge=Math.pow(fe,7),de=_+W,ie=0;E===0&&S===0?ie=de:j<=180?ie=de/2:de<360?ie=(de+360)/2:ie=(de-360)/2;let ye=(he-50)**2,ve=1+.015*ye/Math.sqrt(20+ye),we=1+.045*fe,l=1;l-=.17*Math.cos((ie-30)*u),l+=.24*Math.cos(2*ie*u),l+=.32*Math.cos((3*ie+6)*u),l-=.2*Math.cos((4*ie-63)*u);let v=1+.015*fe*l,p=30*Math.exp(-1*((ie-275)/25)**2),G=2*Math.sqrt(ge/(ge+$)),N=-1*Math.sin(2*p*u)*G,y=(O/ve)**2;return y+=(A/we)**2,y+=(V/v)**2,y+=N*(A/we)*(V/v),Math.sqrt(y)}equals(t,r=1e-5){let n=typeof t=="string"?e.from(t):t;if(n.model===this.model)return this.coords.every((s,c)=>Math.abs(s-n.coords[c])<=r);let o=this.in("xyz-d65").toArray({fit:"none",precision:null}),a=n.in("xyz-d65").toArray({fit:"none",precision:null});return o.every((s,c)=>Math.abs(s-a[c])<=r)}inGamut(t,r=1e-5){let n=t.trim().toLowerCase();if(!(n in pe))throw new Error(`Unsupported color gamut: '${n}'.`);let{components:o,targetGamut:a}=Z[n];if(!a)return!0;let s=this.in(n).toArray({fit:"none",precision:null});return Object.values(o).every(({index:c,value:i})=>{let d=s[c],[u,f]=Array.isArray(i)?i:i==="angle"?[0,360]:[0,100];return d>=u-r&&d<=f+r})}};return tt(rt);})();
|
package/dist/math.js
CHANGED
|
@@ -275,7 +275,7 @@ export function HWB_to_RGB([h, w, b]) {
|
|
|
275
275
|
w /= 100;
|
|
276
276
|
b /= 100;
|
|
277
277
|
if (w + b >= 1) {
|
|
278
|
-
const gray = w / (w + b);
|
|
278
|
+
const gray = (w / (w + b)) * 255;
|
|
279
279
|
return [gray, gray, gray];
|
|
280
280
|
}
|
|
281
281
|
const rgb = HSL_to_RGB([h, 100, 50]).map((c) => c / 255);
|
package/dist/types.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export type SystemColor = keyof typeof systemColors;
|
|
|
36
36
|
export type OutputType = {
|
|
37
37
|
[K in ColorType]: (typeof colorTypes)[K] extends {
|
|
38
38
|
fromBridge?: (components: number[]) => number[];
|
|
39
|
+
format?: (coords: number[]) => string | undefined;
|
|
39
40
|
} ? K : never;
|
|
40
41
|
}[ColorType];
|
|
41
42
|
/** Represents a converter for `<color>`s. */
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Color } from "./Color.js";
|
|
2
|
-
import type { ColorConverter, ColorModelConverter, ColorModel, ColorSpaceConverter, ComponentDefinition, FitFunction, FitMethod, FormattingOptions, Plugin, Config } from "./types.js";
|
|
2
|
+
import type { ColorBase, ColorConverter, ColorFunction, ColorModelConverter, ColorModel, ColorSpace, ColorSpaceConverter, ColorType, ComponentDefinition, FitFunction, FitMethod, FormattingOptions, NamedColor, Plugin, Config, OutputType, SystemColor } from "./types.js";
|
|
3
3
|
/** Global cache for internal Color operations. */
|
|
4
4
|
export declare const cache: Map<any, any>;
|
|
5
5
|
/** Registered plugin functions for the Color class. */
|
|
@@ -29,6 +29,26 @@ export declare function configure(options: Partial<Config>): void;
|
|
|
29
29
|
* @throws If no plugins are provided or a plugin is not a function.
|
|
30
30
|
*/
|
|
31
31
|
export declare function use(...pluginFns: Plugin[]): void;
|
|
32
|
+
declare const getterRegistry: {
|
|
33
|
+
readonly "color-types": () => ColorType[];
|
|
34
|
+
readonly "color-bases": () => ColorBase[];
|
|
35
|
+
readonly "color-functions": () => ColorFunction[];
|
|
36
|
+
readonly "color-models": () => ColorModel[];
|
|
37
|
+
readonly "color-spaces": () => ColorSpace[];
|
|
38
|
+
readonly "named-colors": () => NamedColor[];
|
|
39
|
+
readonly "system-colors": () => SystemColor[];
|
|
40
|
+
readonly "output-types": () => OutputType[];
|
|
41
|
+
readonly plugins: () => string[];
|
|
42
|
+
readonly "fit-methods": () => FitMethod[];
|
|
43
|
+
};
|
|
44
|
+
type Getter = keyof typeof getterRegistry;
|
|
45
|
+
/**
|
|
46
|
+
* Retrieve a list of registered items of a specified type.
|
|
47
|
+
*
|
|
48
|
+
* @param type - The getter type, e.g. "color-types".
|
|
49
|
+
* @returns The array returned by the getter.
|
|
50
|
+
*/
|
|
51
|
+
export declare function get<T extends Getter>(type: T): ReturnType<(typeof getterRegistry)[T]>;
|
|
32
52
|
declare const converterRegistry: {
|
|
33
53
|
readonly "color-type": {
|
|
34
54
|
readonly fn: (name: string, value: ColorConverter) => void;
|
|
@@ -50,12 +70,9 @@ declare const converterRegistry: {
|
|
|
50
70
|
};
|
|
51
71
|
};
|
|
52
72
|
type ConverterType = keyof typeof converterRegistry;
|
|
53
|
-
type ConverterValueMap = {
|
|
54
|
-
[K in ConverterType]: Parameters<(typeof converterRegistry)[K]["fn"]>[1];
|
|
55
|
-
};
|
|
56
73
|
type ConverterEntry<T extends ConverterType> = {
|
|
57
74
|
name: string;
|
|
58
|
-
value:
|
|
75
|
+
value: Parameters<(typeof converterRegistry)[T]["fn"]>[1];
|
|
59
76
|
};
|
|
60
77
|
/**
|
|
61
78
|
* Bulk register multiple converters of a specified type.
|
package/dist/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Color } from "./Color.js";
|
|
2
|
-
import { config } from "./config.js";
|
|
2
|
+
import { config, systemColors } from "./config.js";
|
|
3
3
|
import { colorBases, colorModels, colorFunctions, colorSpaces, colorTypes, namedColors } from "./converters.js";
|
|
4
4
|
import { fitMethods } from "./math.js";
|
|
5
5
|
/** Global cache for internal Color operations. */
|
|
@@ -76,6 +76,34 @@ export function use(...pluginFns) {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
+
const getterRegistry = {
|
|
80
|
+
"color-types": () => Object.keys(colorTypes),
|
|
81
|
+
"color-bases": () => Object.keys(colorBases),
|
|
82
|
+
"color-functions": () => Object.keys(colorFunctions),
|
|
83
|
+
"color-models": () => Object.keys(colorModels),
|
|
84
|
+
"color-spaces": () => Object.keys(colorSpaces),
|
|
85
|
+
"named-colors": () => Object.keys(namedColors),
|
|
86
|
+
"system-colors": () => Object.keys(systemColors),
|
|
87
|
+
"output-types": () => {
|
|
88
|
+
return Object.keys(colorTypes).filter((key) => {
|
|
89
|
+
const type = colorTypes[key];
|
|
90
|
+
return (typeof type["fromBridge"] === "function" &&
|
|
91
|
+
typeof type["format"] === "function");
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
plugins: () => Object.keys(plugins),
|
|
95
|
+
"fit-methods": () => ["none", "clip", ...Object.keys(fitMethods)],
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Retrieve a list of registered items of a specified type.
|
|
99
|
+
*
|
|
100
|
+
* @param type - The getter type, e.g. "color-types".
|
|
101
|
+
* @returns The array returned by the getter.
|
|
102
|
+
*/
|
|
103
|
+
export function get(type) {
|
|
104
|
+
const fn = getterRegistry[type];
|
|
105
|
+
return fn();
|
|
106
|
+
}
|
|
79
107
|
const converterRegistry = {
|
|
80
108
|
/* eslint-disable no-unused-vars */
|
|
81
109
|
"color-type": { fn: registerColorType },
|
package/package.json
CHANGED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ColorModel } from "../types.js";
|
|
2
|
-
declare module "../Color.js" {
|
|
3
|
-
interface Color<M extends ColorModel = ColorModel> {
|
|
4
|
-
/**
|
|
5
|
-
* Lightens the color by the given amount.
|
|
6
|
-
* @param amount - The amount to lighten the color by.
|
|
7
|
-
* @returns A new `Color` instance with increased brightness.
|
|
8
|
-
*/
|
|
9
|
-
lighten(amount: number): Color<"hsl">;
|
|
10
|
-
/**
|
|
11
|
-
* Darkens the color by the given amount.
|
|
12
|
-
* @param amount - The amount to darken the color by.
|
|
13
|
-
* @returns A new `Color` instance with decreased brightness.
|
|
14
|
-
*/
|
|
15
|
-
darken(amount: number): Color<"hsl">;
|
|
16
|
-
}
|
|
17
|
-
}
|