hdr-canvas 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/hdr-canvas.cjs +19 -0
- package/dist/hdr-canvas.cjs.map +1 -1
- package/dist/hdr-canvas.d.ts +3 -1
- package/dist/hdr-canvas.js +18 -1
- package/dist/hdr-canvas.js.map +1 -1
- package/dist/hdr-canvas.min.js +1 -1
- package/dist/hdr-canvas.min.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
package/dist/hdr-canvas.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
var HDRCanvas=function(e){"use strict";function t(e,t){let r=e.length;Array.isArray(e[0])||(e=[e]),Array.isArray(t[0])||(t=t.map((e=>[e])));let a=t[0].length,n=t[0].map(((e,r)=>t.map((e=>e[r])))),o=e.map((e=>n.map((t=>{let r=0;if(!Array.isArray(e)){for(let a of t)r+=e*a;return r}for(let a=0;a<e.length;a++)r+=e[a]*(t[a]||0);return r}))));return 1===r&&(o=o[0]),1===a?o.map((e=>e[0])):o}function r(e){return"string"===a(e)}function a(e){return(Object.prototype.toString.call(e).match(/^\[object\s+(.*?)\]$/)[1]||"").toLowerCase()}function n(e,{precision:t,unit:r}){return o(e)?"none":i(e,t)+(r??"")}function o(e){return Number.isNaN(e)||e instanceof Number&&e?.none}function s(e){return o(e)?0:e}function i(e,t){if(0===e)return 0;let r=~~e,a=0;r&&t&&(a=1+~~Math.log10(Math.abs(r)));const n=10**(t-a);return Math.floor(e*n+.5)/n}const c={deg:1,grad:.9,rad:180/Math.PI,turn:360};function l(e){if(!e)return;e=e.trim();const t=/^-?[\d.]+$/,r=/%|deg|g?rad|turn$/,a=/\/?\s*(none|[-\w.]+(?:%|deg|g?rad|turn)?)/g;let n=e.match(/^([a-z]+)\((.+?)\)$/i);if(n){let e=[];return n[2].replace(a,((a,n)=>{let o=n.match(r),s=n;if(o){let e=o[0],t=s.slice(0,-e.length);"%"===e?(s=new Number(t/100),s.type="<percentage>"):(s=new Number(t*c[e]),s.type="<angle>",s.unit=e)}else t.test(s)?(s=new Number(s),s.type="<number>"):"none"===s&&(s=new Number(NaN),s.none=!0);a.startsWith("/")&&(s=s instanceof Number?s:new Number(s),s.alpha=!0),"object"==typeof s&&s instanceof Number&&(s.raw=n),e.push(s)})),{name:n[1].toLowerCase(),rawName:n[1],rawArgs:n[2],args:e}}}function h(e){return e[e.length-1]}function u(e,t,r){return isNaN(e)?t:isNaN(t)?e:e+(t-e)*r}function d(e,t,r){return(r-e)/(t-e)}function m(e,t,r){return u(t[0],t[1],d(e[0],e[1],r))}function p(e){return e.map((e=>e.split("|").map((e=>{let t=(e=e.trim()).match(/^(<[a-z]+>)\[(-?[.\d]+),\s*(-?[.\d]+)\]?$/);if(t){let e=new String(t[1]);return e.range=[+t[2],+t[3]],e}return e}))))}function f(e,t,r){return Math.max(Math.min(r,t),e)}function g(e,t){return Math.sign(e)===Math.sign(t)?e:-e}function b(e,t){return g(Math.abs(e)**t,e)}function M(e,t){return 0===t?0:e/t}function w(e,t,r=0,a=e.length){for(;r<a;){const n=r+a>>1;e[n]<t?r=n+1:a=n}return r}var y=Object.freeze({__proto__:null,bisectLeft:w,clamp:f,copySign:g,interpolate:u,interpolateInv:d,isNone:o,isString:r,last:h,mapRange:m,multiplyMatrices:t,parseCoordGrammar:p,parseFunction:l,serializeNumber:n,skipNone:s,spow:b,toPrecision:i,type:a,zdiv:M});const v=new class{add(e,t,r){if("string"==typeof arguments[0])(Array.isArray(e)?e:[e]).forEach((function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)}),this);else for(var e in arguments[0])this.add(e,arguments[0][e],arguments[1])}run(e,t){this[e]=this[e]||[],this[e].forEach((function(e){e.call(t&&t.context?t.context:t,t)}))}};var C={gamut_mapping:"css",precision:5,deltaE:"76",verbose:"test"!==globalThis?.process?.env?.NODE_ENV?.toLowerCase(),warn:function(e){this.verbose&&globalThis?.console?.warn?.(e)}};const R={D50:[.3457/.3585,1,.2958/.3585],D65:[.3127/.329,1,.3583/.329]};function S(e){return Array.isArray(e)?e:R[e]}function _(e,r,a,n={}){if(e=S(e),r=S(r),!e||!r)throw new TypeError(`Missing white point to convert ${e?"":"from"}${e||r?"":"/"}${r?"":"to"}`);if(e===r)return a;let o={W1:e,W2:r,XYZ:a,options:n};if(v.run("chromatic-adaptation-start",o),o.M||(o.W1===R.D65&&o.W2===R.D50?o.M=[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]]:o.W1===R.D50&&o.W2===R.D65&&(o.M=[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]])),v.run("chromatic-adaptation-end",o),o.M)return t(o.M,o.XYZ);throw new TypeError("Only Bradford CAT with white points D50 and D65 supported for now.")}const B=new Set(["<number>","<percentage>","<angle>"]);function E(e,t,r,a){let n=Object.entries(e.coords).map((([e,n],o)=>{let s,i=t.coordGrammar[o],c=a[o],l=c?.type;if(s=c.none?i.find((e=>B.has(e))):i.find((e=>e==l)),!s){let t=n.name||e;throw new TypeError(`${l??c.raw} not allowed for ${t} in ${r}()`)}let h=s.range;"<percentage>"===l&&(h||=[0,1]);let u=n.range||n.refRange;return h&&u&&(a[o]=m(h,u,a[o])),s}));return n}function L(e,{meta:t}={}){let r={str:String(e)?.trim()};if(v.run("parse-start",r),r.color)return r.color;if(r.parsed=l(r.str),r.parsed){let e=r.parsed.name;if("color"===e){let e=r.parsed.args.shift(),a=e.startsWith("--")?e.substring(2):`--${e}`,n=[e,a],o=r.parsed.rawArgs.indexOf("/")>0?r.parsed.args.pop():1;for(let a of N.all){let s=a.getFormat("color");if(s&&(n.includes(s.id)||s.ids?.filter((e=>n.includes(e))).length)){const n=Object.keys(a.coords).map(((e,t)=>r.parsed.args[t]||0));let i;return s.coordGrammar&&(i=E(a,s,"color",n)),t&&Object.assign(t,{formatId:"color",types:i}),s.id.startsWith("--")&&!e.startsWith("--")&&C.warn(`${a.name} is a non-standard space and not currently supported in the CSS spec. Use prefixed color(${s.id}) instead of color(${e}).`),e.startsWith("--")&&!s.id.startsWith("--")&&C.warn(`${a.name} is a standard space and supported in the CSS spec. Use color(${s.id}) instead of prefixed color(${e}).`),{spaceId:a.id,coords:n,alpha:o}}}let s="",i=e in N.registry?e:a;if(i in N.registry){let e=N.registry[i].formats?.color?.id;e&&(s=`Did you mean color(${e})?`)}throw new TypeError(`Cannot parse color(${e}). `+(s||"Missing a plugin?"))}for(let a of N.all){let n=a.getFormat(e);if(n&&"function"===n.type){let o=1;(n.lastAlpha||h(r.parsed.args).alpha)&&(o=r.parsed.args.pop());let s,i=r.parsed.args;return n.coordGrammar&&(s=E(a,n,e,i)),t&&Object.assign(t,{formatId:n.name,types:s}),{spaceId:a.id,coords:i,alpha:o}}}}else for(let e of N.all)for(let a in e.formats){let n=e.formats[a];if("custom"!==n.type)continue;if(n.test&&!n.test(r.str))continue;let o=n.parse(r.str);if(o)return o.alpha??=1,t&&(t.formatId=a),o}throw new TypeError(`Could not parse ${e} as a color. Missing a plugin?`)}function A(e){if(Array.isArray(e))return e.map(A);if(!e)throw new TypeError("Empty color reference");r(e)&&(e=L(e));let t=e.space||e.spaceId;return t instanceof N||(e.space=N.get(t)),void 0===e.alpha&&(e.alpha=1),e}class N{constructor(e){this.id=e.id,this.name=e.name,this.base=e.base?N.get(e.base):null,this.aliases=e.aliases,this.base&&(this.fromBase=e.fromBase,this.toBase=e.toBase);let t=e.coords??this.base.coords;for(let e in t)"name"in t[e]||(t[e].name=e);this.coords=t;let r=e.white??this.base.white??"D65";this.white=S(r),this.formats=e.formats??{};for(let e in this.formats){let t=this.formats[e];t.type||="function",t.name||=e}this.formats.color?.id||(this.formats.color={...this.formats.color??{},id:e.cssId||this.id}),e.gamutSpace?this.gamutSpace="self"===e.gamutSpace?this:N.get(e.gamutSpace):this.isPolar?this.gamutSpace=this.base:this.gamutSpace=this,this.gamutSpace.isUnbounded&&(this.inGamut=(e,t)=>!0),this.referred=e.referred,Object.defineProperty(this,"path",{value:x(this).reverse(),writable:!1,enumerable:!0,configurable:!0}),v.run("colorspace-init-end",this)}inGamut(e,{epsilon:t=75e-6}={}){if(!this.equals(this.gamutSpace))return e=this.to(this.gamutSpace,e),this.gamutSpace.inGamut(e,{epsilon:t});let r=Object.values(this.coords);return e.every(((e,a)=>{let n=r[a];if("angle"!==n.type&&n.range){if(Number.isNaN(e))return!0;let[r,a]=n.range;return(void 0===r||e>=r-t)&&(void 0===a||e<=a+t)}return!0}))}get isUnbounded(){return Object.values(this.coords).every((e=>!("range"in e)))}get cssId(){return this.formats?.color?.id||this.id}get isPolar(){for(let e in this.coords)if("angle"===this.coords[e].type)return!0;return!1}getFormat(e){if("object"==typeof e)return e=I(e,this);let t;return t="default"===e?Object.values(this.formats)[0]:this.formats[e],t?(t=I(t,this),t):null}equals(e){return!!e&&(this===e||this.id===e||this.id===e.id)}to(e,t){if(1===arguments.length){const r=A(e);[e,t]=[r.space,r.coords]}if(e=N.get(e),this.equals(e))return t;t=t.map((e=>Number.isNaN(e)?0:e));let r,a,n=this.path,o=e.path;for(let e=0;e<n.length&&n[e].equals(o[e]);e++)r=n[e],a=e;if(!r)throw new Error(`Cannot convert between color spaces ${this} and ${e}: no connection space was found`);for(let e=n.length-1;e>a;e--)t=n[e].toBase(t);for(let e=a+1;e<o.length;e++)t=o[e].fromBase(t);return t}from(e,t){if(1===arguments.length){const r=A(e);[e,t]=[r.space,r.coords]}return(e=N.get(e)).to(this,t)}toString(){return`${this.name} (${this.id})`}getMinCoords(){let e=[];for(let t in this.coords){let r=this.coords[t],a=r.range||r.refRange;e.push(a?.min??0)}return e}static registry={};static get all(){return[...new Set(Object.values(N.registry))]}static register(e,t){if(1===arguments.length&&(e=(t=arguments[0]).id),t=this.get(t),this.registry[e]&&this.registry[e]!==t)throw new Error(`Duplicate color space registration: '${e}'`);if(this.registry[e]=t,1===arguments.length&&t.aliases)for(let e of t.aliases)this.register(e,t);return t}static get(e,...t){if(!e||e instanceof N)return e;if("string"===a(e)){let t=N.registry[e.toLowerCase()];if(!t)throw new TypeError(`No color space found with id = "${e}"`);return t}if(t.length)return N.get(...t);throw new TypeError(`${e} is not a valid color space`)}static resolveCoord(e,t){let r,n,o=a(e);if("string"===o?e.includes(".")?[r,n]=e.split("."):[r,n]=[,e]:Array.isArray(e)?[r,n]=e:(r=e.space,n=e.coordId),r=N.get(r),r||(r=t),!r)throw new TypeError(`Cannot resolve coordinate reference ${e}: No color space specified and relative references are not allowed here`);if(o=a(n),"number"===o||"string"===o&&n>=0){let e=Object.entries(r.coords)[n];if(e)return{space:r,id:e[0],index:n,...e[1]}}r=N.get(r);let s=n.toLowerCase(),i=0;for(let e in r.coords){let t=r.coords[e];if(e.toLowerCase()===s||t.name?.toLowerCase()===s)return{space:r,id:e,index:i,...t};i++}throw new TypeError(`No "${n}" coordinate found in ${r.name}. Its coordinates are: ${Object.keys(r.coords).join(", ")}`)}static DEFAULT_FORMAT={type:"functions",name:"color"}}function x(e){let t=[e];for(let r=e;r=r.base;)t.push(r);return t}function I(e,{coords:t}={}){if(e.coords&&!e.coordGrammar){e.type||="function",e.name||="color",e.coordGrammar=p(e.coords);let r=Object.entries(t).map((([t,r],a)=>{let n=e.coordGrammar[a][0],o=r.range||r.refRange,s=n.range,i="";return"<percentage>"==n?(s=[0,100],i="%"):"<angle>"==n&&(i="deg"),{fromRange:o,toRange:s,suffix:i}}));e.serializeCoords=(e,t)=>e.map(((e,a)=>{let{fromRange:o,toRange:s,suffix:i}=r[a];return o&&s&&(e=m(o,s,e)),e=n(e,{precision:t,unit:i})}))}return e}var P=new N({id:"xyz-d65",name:"XYZ D65",coords:{x:{name:"X"},y:{name:"Y"},z:{name:"Z"}},white:"D65",formats:{color:{ids:["xyz-d65","xyz"]}},aliases:["xyz"]});class k extends N{constructor(e){e.coords||(e.coords={r:{range:[0,1],name:"Red"},g:{range:[0,1],name:"Green"},b:{range:[0,1],name:"Blue"}}),e.base||(e.base=P),e.toXYZ_M&&e.fromXYZ_M&&(e.toBase??=r=>{let a=t(e.toXYZ_M,r);return this.white!==this.base.white&&(a=_(this.white,this.base.white,a)),a},e.fromBase??=r=>(r=_(this.base.white,this.white,r),t(e.fromXYZ_M,r))),e.referred??="display",super(e)}}function D(e,t){return e=A(e),!t||e.space.equals(t)?e.coords.slice():(t=N.get(t)).from(e)}function O(e,t){e=A(e);let{space:r,index:a}=N.resolveCoord(t,e.space);return D(e,r)[a]}function z(e,t,r){return e=A(e),t=N.get(t),e.coords=t.to(e.space,r),e}function j(e,t,r){if(e=A(e),2===arguments.length&&"object"===a(arguments[1])){let t=arguments[1];for(let r in t)j(e,r,t[r])}else{"function"==typeof r&&(r=r(O(e,t)));let{space:a,index:n}=N.resolveCoord(t,e.space),o=D(e,a);o[n]=r,z(e,a,o)}return e}z.returns="color",j.returns="color";var T=new N({id:"xyz-d50",name:"XYZ D50",white:"D50",base:P,fromBase:e=>_(P.white,"D50",e),toBase:e=>_("D50",P.white,e)});const H=216/24389,$=24/116,q=24389/27;let W=R.D50;var F=new N({id:"lab",name:"Lab",coords:{l:{refRange:[0,100],name:"Lightness"},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:W,base:T,fromBase(e){let t=e.map(((e,t)=>e/W[t])).map((e=>e>H?Math.cbrt(e):(q*e+16)/116));return[116*t[1]-16,500*(t[0]-t[1]),200*(t[1]-t[2])]},toBase(e){let t=[];return t[1]=(e[0]+16)/116,t[0]=e[1]/500+t[1],t[2]=t[1]-e[2]/200,[t[0]>$?Math.pow(t[0],3):(116*t[0]-16)/q,e[0]>8?Math.pow((e[0]+16)/116,3):e[0]/q,t[2]>$?Math.pow(t[2],3):(116*t[2]-16)/q].map(((e,t)=>e*W[t]))},formats:{lab:{coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}});function G(e){return(e%360+360)%360}var X=new N({id:"lch",name:"LCH",coords:{l:{refRange:[0,100],name:"Lightness"},c:{refRange:[0,150],name:"Chroma"},h:{refRange:[0,360],type:"angle",name:"Hue"}},base:F,fromBase(e){let t,[r,a,n]=e;return t=Math.abs(a)<.02&&Math.abs(n)<.02?NaN:180*Math.atan2(n,a)/Math.PI,[r,Math.sqrt(a**2+n**2),G(t)]},toBase(e){let[t,r,a]=e;return r<0&&(r=0),isNaN(a)&&(a=0),[t,r*Math.cos(a*Math.PI/180),r*Math.sin(a*Math.PI/180)]},formats:{lch:{coords:["<number> | <percentage>","<number> | <percentage>","<number> | <angle>"]}}});const Y=25**7,Z=Math.PI,U=180/Z,J=Z/180;function Q(e){const t=e*e;return t*t*t*e}function K(e,t,{kL:r=1,kC:a=1,kH:n=1}={}){[e,t]=A([e,t]);let[o,s,i]=F.from(e),c=X.from(F,[o,s,i])[1],[l,h,u]=F.from(t),d=X.from(F,[l,h,u])[1];c<0&&(c=0),d<0&&(d=0);let m=Q((c+d)/2),p=.5*(1-Math.sqrt(m/(m+Y))),f=(1+p)*s,g=(1+p)*h,b=Math.sqrt(f**2+i**2),M=Math.sqrt(g**2+u**2),w=0===f&&0===i?0:Math.atan2(i,f),y=0===g&&0===u?0:Math.atan2(u,g);w<0&&(w+=2*Z),y<0&&(y+=2*Z),w*=U,y*=U;let v,R=l-o,S=M-b,_=y-w,B=w+y,E=Math.abs(_);b*M==0?v=0:E<=180?v=_:_>180?v=_-360:_<-180?v=_+360:C.warn("the unthinkable has happened");let L,N=2*Math.sqrt(M*b)*Math.sin(v*J/2),x=(o+l)/2,I=(b+M)/2,P=Q(I);L=b*M==0?B:E<=180?B/2:B<360?(B+360)/2:(B-360)/2;let k=(x-50)**2,D=1+.015*k/Math.sqrt(20+k),O=1+.045*I,z=1;z-=.17*Math.cos((L-30)*J),z+=.24*Math.cos(2*L*J),z+=.32*Math.cos((3*L+6)*J),z-=.2*Math.cos((4*L-63)*J);let j=1+.015*I*z,T=30*Math.exp(-1*((L-275)/25)**2),H=2*Math.sqrt(P/(P+Y)),$=(R/(r*D))**2;return $+=(S/(a*O))**2,$+=(N/(n*j))**2,$+=-1*Math.sin(2*T*J)*H*(S/(a*O))*(N/(n*j)),Math.sqrt($)}const V=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],ee=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],te=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],re=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]];var ae=new N({id:"oklab",name:"Oklab",coords:{l:{refRange:[0,1],name:"Lightness"},a:{refRange:[-.4,.4]},b:{refRange:[-.4,.4]}},white:"D65",base:P,fromBase(e){let r=t(V,e).map((e=>Math.cbrt(e)));return t(te,r)},toBase(e){let r=t(re,e).map((e=>e**3));return t(ee,r)},formats:{oklab:{coords:["<percentage> | <number>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}});function ne(e,t){[e,t]=A([e,t]);let[r,a,n]=ae.from(e),[o,s,i]=ae.from(t),c=r-o,l=a-s,h=n-i;return Math.sqrt(c**2+l**2+h**2)}const oe=75e-6;function se(e,t,{epsilon:r=oe}={}){e=A(e),t||(t=e.space),t=N.get(t);let a=e.coords;return t!==e.space&&(a=t.from(e)),t.inGamut(a,{epsilon:r})}function ie(e){return{space:e.space,coords:e.coords.slice(),alpha:e.alpha}}function ce(e,t,r="lab"){let a=(r=N.get(r)).from(e),n=r.from(t);return Math.sqrt(a.reduce(((e,t,r)=>{let a=n[r];return isNaN(t)||isNaN(a)?e:e+(a-t)**2}),0))}const le=Math.PI/180;var he=new N({id:"xyz-abs-d65",cssId:"--xyz-abs-d65",name:"Absolute XYZ D65",coords:{x:{refRange:[0,9504.7],name:"Xa"},y:{refRange:[0,1e4],name:"Ya"},z:{refRange:[0,10888.3],name:"Za"}},base:P,fromBase:e=>e.map((e=>Math.max(203*e,0))),toBase:e=>e.map((e=>Math.max(e/203,0)))});const ue=1.15,de=.66,me=2610/16384,pe=16384/2610,fe=.8359375,ge=2413/128,be=18.6875,Me=1.7*2523/32,we=32/(1.7*2523),ye=-.56,ve=16295499532821565e-27,Ce=[[.41478972,.579999,.014648],[-.20151,1.120649,.0531008],[-.0166008,.2648,.6684799]],Re=[[1.9242264357876067,-1.0047923125953657,.037651404030618],[.35031676209499907,.7264811939316552,-.06538442294808501],[-.09098281098284752,-.3127282905230739,1.5227665613052603]],Se=[[.5,.5,0],[3.524,-4.066708,.542708],[.199076,1.096799,-1.295875]],_e=[[1,.1386050432715393,.05804731615611886],[.9999999999999999,-.1386050432715393,-.05804731615611886],[.9999999999999998,-.09601924202631895,-.8118918960560388]];var Be=new N({id:"jzazbz",name:"Jzazbz",coords:{jz:{refRange:[0,1],name:"Jz"},az:{refRange:[-.5,.5]},bz:{refRange:[-.5,.5]}},base:he,fromBase(e){let[r,a,n]=e,o=t(Ce,[ue*r-(ue-1)*n,de*a-(de-1)*r,n]).map((function(e){return((fe+ge*(e/1e4)**me)/(1+be*(e/1e4)**me))**Me})),[s,i,c]=t(Se,o);return[(1+ye)*s/(1+ye*s)-ve,i,c]},toBase(e){let[r,a,n]=e,o=t(_e,[(r+ve)/(1+ye-ye*(r+ve)),a,n]).map((function(e){return 1e4*((fe-e**we)/(be*e**we-ge))**pe})),[s,i,c]=t(Re,o),l=(s+(ue-1)*c)/ue;return[l,(i+(de-1)*l)/de,c]},formats:{color:{coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}}),Ee=new N({id:"jzczhz",name:"JzCzHz",coords:{jz:{refRange:[0,1],name:"Jz"},cz:{refRange:[0,1],name:"Chroma"},hz:{refRange:[0,360],type:"angle",name:"Hue"}},base:Be,fromBase(e){let t,[r,a,n]=e;const o=2e-4;return t=Math.abs(a)<o&&Math.abs(n)<o?NaN:180*Math.atan2(n,a)/Math.PI,[r,Math.sqrt(a**2+n**2),G(t)]},toBase:e=>[e[0],e[1]*Math.cos(e[2]*Math.PI/180),e[1]*Math.sin(e[2]*Math.PI/180)]});const Le=.8359375,Ae=2413/128,Ne=18.6875,xe=2610/16384,Ie=2523/32,Pe=16384/2610,ke=32/2523,De=[[.3592832590121217,.6976051147779502,-.035891593232029],[-.1920808463704993,1.100476797037432,.0753748658519118],[.0070797844607479,.0748396662186362,.8433265453898765]],Oe=[[.5,.5,0],[6610/4096,-13613/4096,7003/4096],[17933/4096,-17390/4096,-543/4096]],ze=[[.9999999999999998,.0086090370379328,.111029625003026],[.9999999999999998,-.0086090370379328,-.1110296250030259],[.9999999999999998,.5600313357106791,-.3206271749873188]],je=[[2.0701522183894223,-1.3263473389671563,.2066510476294053],[.3647385209748072,.6805660249472273,-.0453045459220347],[-.0497472075358123,-.0492609666966131,1.1880659249923042]];var Te=new N({id:"ictcp",name:"ICTCP",coords:{i:{refRange:[0,1],name:"I"},ct:{refRange:[-.5,.5],name:"CT"},cp:{refRange:[-.5,.5],name:"CP"}},base:he,fromBase:e=>function(e){let r=e.map((function(e){return((Le+Ae*(e/1e4)**xe)/(1+Ne*(e/1e4)**xe))**Ie}));return t(Oe,r)}(t(De,e)),toBase(e){let r=function(e){let r=t(ze,e),a=r.map((function(e){return 1e4*(Math.max(e**ke-Le,0)/(Ae-Ne*e**ke))**Pe}));return a}(e);return t(je,r)}});const He=R.D65,$e=.42,qe=1/$e,We=2*Math.PI,Fe=[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],Ge=[[1.8620678550872327,-1.0112546305316843,.14918677544445175],[.38752654323613717,.6214474419314753,-.008973985167612518],[-.015841498849333856,-.03412293802851557,1.0499644368778496]],Xe=[[460,451,288],[460,-891,-261],[460,-220,-6300]],Ye={dark:[.8,.525,.8],dim:[.9,.59,.9],average:[1,.69,1]},Ze={h:[20.14,90,164.25,237.53,380.14],e:[.8,.7,1,1.2,.8],H:[0,100,200,300,400]},Ue=180/Math.PI,Je=Math.PI/180;function Qe(e,t){const r=e.map((e=>{const r=b(t*Math.abs(e)*.01,$e);return 400*g(r,e)/(r+27.13)}));return r}function Ke(e,r,a,n,o){const s={};s.discounting=o,s.refWhite=e,s.surround=n;const i=e.map((e=>100*e));s.la=r,s.yb=a;const c=i[1],l=t(Fe,i),h=(n=Ye[s.surround])[0];s.c=n[1],s.nc=n[2];const d=(1/(5*s.la+1))**4;s.fl=d*s.la+.1*(1-d)*(1-d)*Math.cbrt(5*s.la),s.flRoot=s.fl**.25,s.n=s.yb/c,s.z=1.48+Math.sqrt(s.n),s.nbb=.725*s.n**-.2,s.ncb=s.nbb;const m=Math.max(Math.min(h*(1-1/3.6*Math.exp((-s.la-42)/92)),1),0);s.dRgb=l.map((e=>u(1,c/e,m))),s.dRgbInv=s.dRgb.map((e=>1/e));const p=l.map(((e,t)=>e*s.dRgb[t])),f=Qe(p,s.fl);return s.aW=s.nbb*(2*f[0]+f[1]+.05*f[2]),s}const Ve=Ke(He,64/Math.PI*.2,20,"average",!1);function et(e,r){if(!(void 0!==e.J^void 0!==e.Q))throw new Error("Conversion requires one and only one: 'J' or 'Q'");if(!(void 0!==e.C^void 0!==e.M^void 0!==e.s))throw new Error("Conversion requires one and only one: 'C', 'M' or 's'");if(!(void 0!==e.h^void 0!==e.H))throw new Error("Conversion requires one and only one: 'h' or 'H'");if(0===e.J||0===e.Q)return[0,0,0];let a=0;a=void 0!==e.h?G(e.h)*Je:function(e){let t=(e%400+400)%400;const r=Math.floor(.01*t);t%=100;const[a,n]=Ze.h.slice(r,r+2),[o,s]=Ze.e.slice(r,r+2);return G((t*(s*a-o*n)-100*a*s)/(t*(s-o)-100*s))}(e.H)*Je;const n=Math.cos(a),o=Math.sin(a);let s=0;void 0!==e.J?s=.1*b(e.J,.5):void 0!==e.Q&&(s=.25*r.c*e.Q/((r.aW+4)*r.flRoot));let i=0;void 0!==e.C?i=e.C/s:void 0!==e.M?i=e.M/r.flRoot/s:void 0!==e.s&&(i=4e-4*e.s**2*(r.aW+4)/r.c);const c=b(i*Math.pow(1.64-Math.pow(.29,r.n),-.73),10/9),l=.25*(Math.cos(a+2)+3.8),h=r.aW*b(s,2/r.c/r.z),u=5e4/13*r.nc*r.ncb*l,d=h/r.nbb,m=23*(d+.305)*M(c,23*u+c*(11*n+108*o)),p=function(e,t){const r=100/t*27.13**qe;return e.map((e=>{const t=Math.abs(e);return g(r*b(t/(400-t),qe),e)}))}(t(Xe,[d,m*n,m*o]).map((e=>1*e/1403)),r.fl);return t(Ge,p.map(((e,t)=>e*r.dRgbInv[t]))).map((e=>e/100))}function tt(e,r){const a=e.map((e=>100*e)),n=Qe(t(Fe,a).map(((e,t)=>e*r.dRgb[t])),r.fl),o=n[0]+(-12*n[1]+n[2])/11,s=(n[0]+n[1]-2*n[2])/9,i=(Math.atan2(s,o)%We+We)%We,c=.25*(Math.cos(i+2)+3.8),l=b(5e4/13*r.nc*r.ncb*M(c*Math.sqrt(o**2+s**2),n[0]+n[1]+1.05*n[2]+.305),.9)*Math.pow(1.64-Math.pow(.29,r.n),.73),h=b(r.nbb*(2*n[0]+n[1]+.05*n[2])/r.aW,.5*r.c*r.z),u=100*b(h,2),d=4/r.c*h*(r.aW+4)*r.flRoot,m=l*h,p=m*r.flRoot,f=G(i*Ue),g=function(e){let t=G(e);t<=Ze.h[0]&&(t+=360);const r=w(Ze.h,t)-1,[a,n]=Ze.h.slice(r,r+2),[o,s]=Ze.e.slice(r,r+2),i=(t-a)/o;return Ze.H[r]+100*i/(i+(n-t)/s)}(f);return{J:u,C:m,h:f,s:50*b(r.c*l/(r.aW+4),.5),Q:d,M:p,H:g}}var rt=new N({id:"cam16-jmh",cssId:"--cam16-jmh",name:"CAM16-JMh",coords:{j:{refRange:[0,100],name:"J"},m:{refRange:[0,105],name:"Colorfulness"},h:{refRange:[0,360],type:"angle",name:"Hue"}},base:P,fromBase(e){const t=tt(e,Ve);return[t.J,t.M,t.h]},toBase:e=>et({J:e[0],M:e[1],h:e[2]},Ve)});const at=R.D65,nt=216/24389,ot=24389/27;function st(e){return e>8?Math.pow((e+16)/116,3):e/ot}function it(e,t){const r=116*((a=e[1])>nt?Math.cbrt(a):(ot*a+16)/116)-16;var a;if(0===r)return[0,0,0];const n=tt(e,ct);return[G(n.h),n.C,r]}const ct=Ke(at,200/Math.PI*st(50),100*st(50),"average",!1);var lt=new N({id:"hct",name:"HCT",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},c:{refRange:[0,145],name:"Colorfulness"},t:{refRange:[0,100],name:"Tone"}},base:P,fromBase:e=>it(e),toBase:e=>function(e,t){let[r,a,n]=e,o=[],s=0;if(0===n)return[0,0,0];let i=st(n);s=n>0?.00379058511492914*n**2+.608983189401032*n+.9155088574762233:9514440756550361e-21*n**2+.08693057439788597*n-21.928975842194614;let c=0,l=1/0;for(;c<=15;){o=et({J:s,C:a,h:r},t);const e=Math.abs(o[1]-i);if(e<l){if(e<=2e-12)return o;l=e}s-=(o[1]-i)*s/(2*o[1]),c+=1}return et({J:s,C:a,h:r},t)}(e,ct),formats:{color:{id:"--hct",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});const ht=Math.PI/180,ut=[1,.007,.0228];function dt(e){e[1]<0&&(e=lt.fromBase(lt.toBase(e)));const t=Math.log(Math.max(1+ut[2]*e[1]*ct.flRoot,1))/ut[2],r=e[0]*ht,a=t*Math.cos(r),n=t*Math.sin(r);return[e[2],a,n]}var mt={deltaE76:function(e,t){return ce(e,t,"lab")},deltaECMC:function(e,t,{l:r=2,c:a=1}={}){[e,t]=A([e,t]);let[n,o,s]=F.from(e),[,i,c]=X.from(F,[n,o,s]),[l,h,u]=F.from(t),d=X.from(F,[l,h,u])[1];i<0&&(i=0),d<0&&(d=0);let m=n-l,p=i-d,f=(o-h)**2+(s-u)**2-p**2,g=.511;n>=16&&(g=.040975*n/(1+.01765*n));let b,M=.0638*i/(1+.0131*i)+.638;Number.isNaN(c)&&(c=0),b=c>=164&&c<=345?.56+Math.abs(.2*Math.cos((c+168)*le)):.36+Math.abs(.4*Math.cos((c+35)*le));let w=Math.pow(i,4),y=Math.sqrt(w/(w+1900)),v=(m/(r*g))**2;return v+=(p/(a*M))**2,v+=f/(M*(y*b+1-y))**2,Math.sqrt(v)},deltaE2000:K,deltaEJz:function(e,t){[e,t]=A([e,t]);let[r,a,n]=Ee.from(e),[o,s,i]=Ee.from(t),c=r-o,l=a-s;Number.isNaN(n)&&Number.isNaN(i)?(n=0,i=0):Number.isNaN(n)?n=i:Number.isNaN(i)&&(i=n);let h=n-i,u=2*Math.sqrt(a*s)*Math.sin(h/2*(Math.PI/180));return Math.sqrt(c**2+l**2+u**2)},deltaEITP:function(e,t){[e,t]=A([e,t]);let[r,a,n]=Te.from(e),[o,s,i]=Te.from(t);return 720*Math.sqrt((r-o)**2+.25*(a-s)**2+(n-i)**2)},deltaEOK:ne,deltaEHCT:function(e,t){[e,t]=A([e,t]);let[r,a,n]=dt(lt.from(e)),[o,s,i]=dt(lt.from(t));return Math.sqrt((r-o)**2+(a-s)**2+(n-i)**2)}};const pt={hct:{method:"hct.c",jnd:2,deltaEMethod:"hct",blackWhiteClamp:{}},"hct-tonal":{method:"hct.c",jnd:0,deltaEMethod:"hct",blackWhiteClamp:{channel:"hct.t",min:0,max:100}}};function ft(e,{method:t=C.gamut_mapping,space:a,deltaEMethod:n="",jnd:s=2,blackWhiteClamp:i={}}={}){if(e=A(e),r(arguments[1])?a=arguments[1]:a||(a=e.space),se(e,a=N.get(a),{epsilon:0}))return e;let c;if("css"===t)c=function(e,{space:t}={}){const r=.02,a=1e-4;e=A(e),t||(t=e.space);t=N.get(t);const n=N.get("oklch");if(t.isUnbounded)return bt(e,t);const o=bt(e,n);let s=o.coords[0];if(s>=1){const r=bt(gt.WHITE,t);return r.alpha=e.alpha,bt(r,t)}if(s<=0){const r=bt(gt.BLACK,t);return r.alpha=e.alpha,bt(r,t)}if(se(o,t,{epsilon:0}))return bt(o,t);function i(e){const r=bt(e,t),a=Object.values(t.coords);return r.coords=r.coords.map(((e,t)=>{if("range"in a[t]){const[r,n]=a[t].range;return f(r,e,n)}return e})),r}let c=0,l=o.coords[1],h=!0,u=ie(o),d=i(u),m=ne(d,u);if(m<r)return d;for(;l-c>a;){const e=(c+l)/2;if(u.coords[1]=e,h&&se(u,t,{epsilon:0}))c=e;else if(d=i(u),m=ne(d,u),m<r){if(r-m<a)break;h=!1,c=e}else l=e}return d}(e,{space:a});else{if("clip"===t||se(e,a))c=bt(e,a);else{Object.prototype.hasOwnProperty.call(pt,t)&&({method:t,jnd:s,deltaEMethod:n,blackWhiteClamp:i}=pt[t]);let r=K;if(""!==n)for(let e in mt)if("deltae"+n.toLowerCase()===e.toLowerCase()){r=mt[e];break}let l=ft(bt(e,a),{method:"clip",space:a});if(r(e,l)>s){if(3===Object.keys(i).length){let t=N.resolveCoord(i.channel),r=O(bt(e,t.space),t.id);if(o(r)&&(r=0),r>=i.max)return bt({space:"xyz-d65",coords:R.D65},e.space);if(r<=i.min)return bt({space:"xyz-d65",coords:[0,0,0]},e.space)}let n=N.resolveCoord(t),l=n.space,h=n.id,u=bt(e,l);u.coords.forEach(((e,t)=>{o(e)&&(u.coords[t]=0)}));let d=(n.range||n.refRange)[0],m=function(e){const t=e?Math.floor(Math.log10(Math.abs(e))):0;return Math.max(parseFloat("1e"+(t-2)),1e-6)}(s),p=d,f=O(u,h);for(;f-p>m;){let e=ie(u);e=ft(e,{space:a,method:"clip"}),r(u,e)-s<m?p=O(u,h):f=O(u,h),j(u,h,(p+f)/2)}c=bt(u,a)}else c=l}if("clip"===t||!se(c,a,{epsilon:0})){let e=Object.values(a.coords).map((e=>e.range||[]));c.coords=c.coords.map(((t,r)=>{let[a,n]=e[r];return void 0!==a&&(t=Math.max(a,t)),void 0!==n&&(t=Math.min(t,n)),t}))}}return a!==e.space&&(c=bt(c,e.space)),e.coords=c.coords,e}ft.returns="color";const gt={WHITE:{space:ae,coords:[1,0,0]},BLACK:{space:ae,coords:[0,0,0]}};function bt(e,t,{inGamut:r}={}){e=A(e);let a=(t=N.get(t)).from(e),n={space:t,coords:a,alpha:e.alpha};return r&&(n=ft(n,!0===r?void 0:r)),n}function Mt(e,{precision:t=C.precision,format:r="default",inGamut:a=!0,...o}={}){let s,i=r;r=(e=A(e)).space.getFormat(r)??e.space.getFormat("default")??N.DEFAULT_FORMAT;let c=e.coords.slice();if(a||=r.toGamut,a&&!se(e)&&(c=ft(ie(e),!0===a?void 0:a).coords),"custom"===r.type){if(o.precision=t,!r.serialize)throw new TypeError(`format ${i} can only be used to parse colors, not for serialization`);s=r.serialize(c,e.alpha,o)}else{let a=r.name||"color";r.serializeCoords?c=r.serializeCoords(c,t):null!==t&&(c=c.map((e=>n(e,{precision:t}))));let o=[...c];if("color"===a){let t=r.id||r.ids?.[0]||e.space.id;o.unshift(t)}let i=e.alpha;null!==t&&(i=n(i,{precision:t}));let l=e.alpha>=1||r.noAlpha?"":`${r.commas?",":" /"} ${i}`;s=`${a}(${o.join(r.commas?", ":" ")}${l})`}return s}bt.returns="color";var wt=new k({id:"rec2020-linear",cssId:"--rec2020-linear",name:"Linear REC.2020",white:"D65",toXYZ_M:[[.6369580483012914,.14461690358620832,.1688809751641721],[.2627002120112671,.6779980715188708,.05930171646986196],[0,.028072693049087428,1.060985057710791]],fromXYZ_M:[[1.716651187971268,-.355670783776392,-.25336628137366],[-.666684351832489,1.616481236634939,.0157685458139111],[.017639857445311,-.042770613257809,.942103121235474]]});const yt=1.09929682680944,vt=.018053968510807;var Ct=new k({id:"rec2020",name:"REC.2020",base:wt,toBase:e=>e.map((function(e){return e<4.5*vt?e/4.5:Math.pow((e+yt-1)/yt,1/.45)})),fromBase:e=>e.map((function(e){return e>=vt?yt*Math.pow(e,.45)-(yt-1):4.5*e}))});var Rt=new k({id:"p3-linear",cssId:"--display-p3-linear",name:"Linear P3",white:"D65",toXYZ_M:[[.4865709486482162,.26566769316909306,.1982172852343625],[.2289745640697488,.6917385218365064,.079286914093745],[0,.04511338185890264,1.043944368900976]],fromXYZ_M:[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]]});const St=[[3.2409699419045226,-1.537383177570094,-.4986107602930034],[-.9692436362808796,1.8759675015077202,.04155505740717559],[.05563007969699366,-.20397695888897652,1.0569715142428786]];var _t=new k({id:"srgb-linear",name:"Linear sRGB",white:"D65",toXYZ_M:[[.41239079926595934,.357584339383878,.1804807884018343],[.21263900587151027,.715168678767756,.07219231536073371],[.01933081871559182,.11919477979462598,.9505321522496607]],fromXYZ_M:St}),Bt={aliceblue:[240/255,248/255,1],antiquewhite:[250/255,235/255,215/255],aqua:[0,1,1],aquamarine:[127/255,1,212/255],azure:[240/255,1,1],beige:[245/255,245/255,220/255],bisque:[1,228/255,196/255],black:[0,0,0],blanchedalmond:[1,235/255,205/255],blue:[0,0,1],blueviolet:[138/255,43/255,226/255],brown:[165/255,42/255,42/255],burlywood:[222/255,184/255,135/255],cadetblue:[95/255,158/255,160/255],chartreuse:[127/255,1,0],chocolate:[210/255,105/255,30/255],coral:[1,127/255,80/255],cornflowerblue:[100/255,149/255,237/255],cornsilk:[1,248/255,220/255],crimson:[220/255,20/255,60/255],cyan:[0,1,1],darkblue:[0,0,139/255],darkcyan:[0,139/255,139/255],darkgoldenrod:[184/255,134/255,11/255],darkgray:[169/255,169/255,169/255],darkgreen:[0,100/255,0],darkgrey:[169/255,169/255,169/255],darkkhaki:[189/255,183/255,107/255],darkmagenta:[139/255,0,139/255],darkolivegreen:[85/255,107/255,47/255],darkorange:[1,140/255,0],darkorchid:[.6,50/255,.8],darkred:[139/255,0,0],darksalmon:[233/255,150/255,122/255],darkseagreen:[143/255,188/255,143/255],darkslateblue:[72/255,61/255,139/255],darkslategray:[47/255,79/255,79/255],darkslategrey:[47/255,79/255,79/255],darkturquoise:[0,206/255,209/255],darkviolet:[148/255,0,211/255],deeppink:[1,20/255,147/255],deepskyblue:[0,191/255,1],dimgray:[105/255,105/255,105/255],dimgrey:[105/255,105/255,105/255],dodgerblue:[30/255,144/255,1],firebrick:[178/255,34/255,34/255],floralwhite:[1,250/255,240/255],forestgreen:[34/255,139/255,34/255],fuchsia:[1,0,1],gainsboro:[220/255,220/255,220/255],ghostwhite:[248/255,248/255,1],gold:[1,215/255,0],goldenrod:[218/255,165/255,32/255],gray:[128/255,128/255,128/255],green:[0,128/255,0],greenyellow:[173/255,1,47/255],grey:[128/255,128/255,128/255],honeydew:[240/255,1,240/255],hotpink:[1,105/255,180/255],indianred:[205/255,92/255,92/255],indigo:[75/255,0,130/255],ivory:[1,1,240/255],khaki:[240/255,230/255,140/255],lavender:[230/255,230/255,250/255],lavenderblush:[1,240/255,245/255],lawngreen:[124/255,252/255,0],lemonchiffon:[1,250/255,205/255],lightblue:[173/255,216/255,230/255],lightcoral:[240/255,128/255,128/255],lightcyan:[224/255,1,1],lightgoldenrodyellow:[250/255,250/255,210/255],lightgray:[211/255,211/255,211/255],lightgreen:[144/255,238/255,144/255],lightgrey:[211/255,211/255,211/255],lightpink:[1,182/255,193/255],lightsalmon:[1,160/255,122/255],lightseagreen:[32/255,178/255,170/255],lightskyblue:[135/255,206/255,250/255],lightslategray:[119/255,136/255,.6],lightslategrey:[119/255,136/255,.6],lightsteelblue:[176/255,196/255,222/255],lightyellow:[1,1,224/255],lime:[0,1,0],limegreen:[50/255,205/255,50/255],linen:[250/255,240/255,230/255],magenta:[1,0,1],maroon:[128/255,0,0],mediumaquamarine:[.4,205/255,170/255],mediumblue:[0,0,205/255],mediumorchid:[186/255,85/255,211/255],mediumpurple:[147/255,112/255,219/255],mediumseagreen:[60/255,179/255,113/255],mediumslateblue:[123/255,104/255,238/255],mediumspringgreen:[0,250/255,154/255],mediumturquoise:[72/255,209/255,.8],mediumvioletred:[199/255,21/255,133/255],midnightblue:[25/255,25/255,112/255],mintcream:[245/255,1,250/255],mistyrose:[1,228/255,225/255],moccasin:[1,228/255,181/255],navajowhite:[1,222/255,173/255],navy:[0,0,128/255],oldlace:[253/255,245/255,230/255],olive:[128/255,128/255,0],olivedrab:[107/255,142/255,35/255],orange:[1,165/255,0],orangered:[1,69/255,0],orchid:[218/255,112/255,214/255],palegoldenrod:[238/255,232/255,170/255],palegreen:[152/255,251/255,152/255],paleturquoise:[175/255,238/255,238/255],palevioletred:[219/255,112/255,147/255],papayawhip:[1,239/255,213/255],peachpuff:[1,218/255,185/255],peru:[205/255,133/255,63/255],pink:[1,192/255,203/255],plum:[221/255,160/255,221/255],powderblue:[176/255,224/255,230/255],purple:[128/255,0,128/255],rebeccapurple:[.4,.2,.6],red:[1,0,0],rosybrown:[188/255,143/255,143/255],royalblue:[65/255,105/255,225/255],saddlebrown:[139/255,69/255,19/255],salmon:[250/255,128/255,114/255],sandybrown:[244/255,164/255,96/255],seagreen:[46/255,139/255,87/255],seashell:[1,245/255,238/255],sienna:[160/255,82/255,45/255],silver:[192/255,192/255,192/255],skyblue:[135/255,206/255,235/255],slateblue:[106/255,90/255,205/255],slategray:[112/255,128/255,144/255],slategrey:[112/255,128/255,144/255],snow:[1,250/255,250/255],springgreen:[0,1,127/255],steelblue:[70/255,130/255,180/255],tan:[210/255,180/255,140/255],teal:[0,128/255,128/255],thistle:[216/255,191/255,216/255],tomato:[1,99/255,71/255],turquoise:[64/255,224/255,208/255],violet:[238/255,130/255,238/255],wheat:[245/255,222/255,179/255],white:[1,1,1],whitesmoke:[245/255,245/255,245/255],yellow:[1,1,0],yellowgreen:[154/255,205/255,50/255]};let Et=Array(3).fill("<percentage> | <number>[0, 255]"),Lt=Array(3).fill("<number>[0, 255]");var At=new k({id:"srgb",name:"sRGB",base:_t,fromBase:e=>e.map((e=>{let t=e<0?-1:1,r=e*t;return r>.0031308?t*(1.055*r**(1/2.4)-.055):12.92*e})),toBase:e=>e.map((e=>{let t=e<0?-1:1,r=e*t;return r<=.04045?e/12.92:t*((r+.055)/1.055)**2.4})),formats:{rgb:{coords:Et},rgb_number:{name:"rgb",commas:!0,coords:Lt,noAlpha:!0},color:{},rgba:{coords:Et,commas:!0,lastAlpha:!0},rgba_number:{name:"rgba",commas:!0,coords:Lt},hex:{type:"custom",toGamut:!0,test:e=>/^#([a-f0-9]{3,4}){1,2}$/i.test(e),parse(e){e.length<=5&&(e=e.replace(/[a-f0-9]/gi,"$&$&"));let t=[];return e.replace(/[a-f0-9]{2}/gi,(e=>{t.push(parseInt(e,16)/255)})),{spaceId:"srgb",coords:t.slice(0,3),alpha:t.slice(3)[0]}},serialize:(e,t,{collapse:r=!0}={})=>{t<1&&e.push(t),e=e.map((e=>Math.round(255*e)));let a=r&&e.every((e=>e%17==0)),n=e.map((e=>a?(e/17).toString(16):e.toString(16).padStart(2,"0"))).join("");return"#"+n}},keyword:{type:"custom",test:e=>/^[a-z]+$/i.test(e),parse(e){let t={spaceId:"srgb",coords:null,alpha:1};if("transparent"===(e=e.toLowerCase())?(t.coords=Bt.black,t.alpha=0):t.coords=Bt[e],t.coords)return t}}}}),Nt=new k({id:"p3",cssId:"display-p3",name:"P3",base:Rt,fromBase:At.fromBase,toBase:At.toBase});let xt;if(C.display_space=At,"undefined"!=typeof CSS&&CSS.supports)for(let e of[F,Ct,Nt]){let t=e.getMinCoords(),r=Mt({space:e,coords:t,alpha:1});if(CSS.supports("color",r)){C.display_space=e;break}}function It(e){return O(e,[P,"y"])}function Pt(e,t){j(e,[P,"y"],t)}var kt=Object.freeze({__proto__:null,getLuminance:It,register:function(e){Object.defineProperty(e.prototype,"luminance",{get(){return It(this)},set(e){Pt(this,e)}})},setLuminance:Pt});const Dt=.022,Ot=1.414;function zt(e){return e>=Dt?e:e+(Dt-e)**Ot}function jt(e){let t=e<0?-1:1,r=Math.abs(e);return t*Math.pow(r,2.4)}const Tt=216/24389,Ht=24/116,$t=24389/27;let qt=R.D65;var Wt=new N({id:"lab-d65",name:"Lab D65",coords:{l:{refRange:[0,100],name:"Lightness"},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:qt,base:P,fromBase(e){let t=e.map(((e,t)=>e/qt[t])).map((e=>e>Tt?Math.cbrt(e):($t*e+16)/116));return[116*t[1]-16,500*(t[0]-t[1]),200*(t[1]-t[2])]},toBase(e){let t=[];return t[1]=(e[0]+16)/116,t[0]=e[1]/500+t[1],t[2]=t[1]-e[2]/200,[t[0]>Ht?Math.pow(t[0],3):(116*t[0]-16)/$t,e[0]>8?Math.pow((e[0]+16)/116,3):e[0]/$t,t[2]>Ht?Math.pow(t[2],3):(116*t[2]-16)/$t].map(((e,t)=>e*qt[t]))},formats:{"lab-d65":{coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}});const Ft=.5*Math.pow(5,.5)+.5;var Gt=Object.freeze({__proto__:null,contrastAPCA:function(e,t){let r,a,n,o,s,i;t=A(t),e=A(e),t=bt(t,"srgb"),[o,s,i]=t.coords;let c=.2126729*jt(o)+.7151522*jt(s)+.072175*jt(i);e=bt(e,"srgb"),[o,s,i]=e.coords;let l=.2126729*jt(o)+.7151522*jt(s)+.072175*jt(i),h=zt(c),u=zt(l),d=u>h;return Math.abs(u-h)<5e-4?a=0:d?(r=u**.56-h**.57,a=1.14*r):(r=u**.65-h**.62,a=1.14*r),n=Math.abs(a)<.1?0:a>0?a-.027:a+.027,100*n},contrastDeltaPhi:function(e,t){e=A(e),t=A(t);let r=O(e,[Wt,"l"]),a=O(t,[Wt,"l"]),n=Math.abs(Math.pow(r,Ft)-Math.pow(a,Ft)),o=Math.pow(n,1/Ft)*Math.SQRT2-40;return o<7.5?0:o},contrastLstar:function(e,t){e=A(e),t=A(t);let r=O(e,[F,"l"]),a=O(t,[F,"l"]);return Math.abs(r-a)},contrastMichelson:function(e,t){e=A(e),t=A(t);let r=Math.max(It(e),0),a=Math.max(It(t),0);a>r&&([r,a]=[a,r]);let n=r+a;return 0===n?0:(r-a)/n},contrastWCAG21:function(e,t){e=A(e),t=A(t);let r=Math.max(It(e),0),a=Math.max(It(t),0);return a>r&&([r,a]=[a,r]),(r+.05)/(a+.05)},contrastWeber:function(e,t){e=A(e),t=A(t);let r=Math.max(It(e),0),a=Math.max(It(t),0);return a>r&&([r,a]=[a,r]),0===a?5e4:(r-a)/a}});function Xt(e){let[t,r,a]=D(e,P),n=t+15*r+3*a;return[4*t/n,9*r/n]}function Yt(e){let[t,r,a]=D(e,P),n=t+r+a;return[t/n,r/n]}var Zt=Object.freeze({__proto__:null,register:function(e){Object.defineProperty(e.prototype,"uv",{get(){return Xt(this)}}),Object.defineProperty(e.prototype,"xy",{get(){return Yt(this)}})},uv:Xt,xy:Yt});function Ut(e,t,a={}){r(a)&&(a={method:a});let{method:n=C.deltaE,...o}=a;for(let r in mt)if("deltae"+n.toLowerCase()===r.toLowerCase())return mt[r](e,t,o);throw new TypeError(`Unknown deltaE method: ${n}`)}var Jt=Object.freeze({__proto__:null,darken:function(e,t=.25){return j(e,[N.get("oklch","lch"),"l"],(e=>e*(1-t)))},lighten:function(e,t=.25){return j(e,[N.get("oklch","lch"),"l"],(e=>e*(1+t)))}});function Qt(e,t,r=.5,n={}){return[e,t]=[A(e),A(t)],"object"===a(r)&&([r,n]=[.5,r]),Vt(e,t,n)(r)}function Kt(e,t,r={}){let a;er(e)&&([a,r]=[e,t],[e,t]=a.rangeArgs.colors);let{maxDeltaE:n,deltaEMethod:o,steps:s=2,maxSteps:i=1e3,...c}=r;a||([e,t]=[A(e),A(t)],a=Vt(e,t,c));let l=Ut(e,t),h=n>0?Math.max(s,Math.ceil(l/n)+1):s,u=[];if(void 0!==i&&(h=Math.min(h,i)),1===h)u=[{p:.5,color:a(.5)}];else{let e=1/(h-1);u=Array.from({length:h},((t,r)=>{let n=r*e;return{p:n,color:a(n)}}))}if(n>0){let e=u.reduce(((e,t,r)=>{if(0===r)return 0;let a=Ut(t.color,u[r-1].color,o);return Math.max(e,a)}),0);for(;e>n;){e=0;for(let t=1;t<u.length&&u.length<i;t++){let r=u[t-1],n=u[t],o=(n.p+r.p)/2,s=a(o);e=Math.max(e,Ut(s,r.color),Ut(s,n.color)),u.splice(t,0,{p:o,color:a(o)}),t++}}}return u=u.map((e=>e.color)),u}function Vt(e,t,r={}){if(er(e)){let[r,a]=[e,t];return Vt(...r.rangeArgs.colors,{...r.rangeArgs.options,...a})}let{space:a,outputSpace:n,progression:o,premultiplied:s}=r;e=A(e),t=A(t),e=ie(e),t=ie(t);let i={colors:[e,t],options:r};if(a=a?N.get(a):N.registry[C.interpolationSpace]||e.space,n=n?N.get(n):a,e=bt(e,a),t=bt(t,a),e=ft(e),t=ft(t),a.coords.h&&"angle"===a.coords.h.type){let n=r.hue=r.hue||"shorter",o=[a,"h"],[s,i]=[O(e,o),O(t,o)];isNaN(s)&&!isNaN(i)?s=i:isNaN(i)&&!isNaN(s)&&(i=s),[s,i]=function(e,t){if("raw"===e)return t;let[r,a]=t.map(G),n=a-r;return"increasing"===e?n<0&&(a+=360):"decreasing"===e?n>0&&(r+=360):"longer"===e?-180<n&&n<180&&(n>0?r+=360:a+=360):"shorter"===e&&(n>180?r+=360:n<-180&&(a+=360)),[r,a]}(n,[s,i]),j(e,o,s),j(t,o,i)}return s&&(e.coords=e.coords.map((t=>t*e.alpha)),t.coords=t.coords.map((e=>e*t.alpha))),Object.assign((r=>{r=o?o(r):r;let i=e.coords.map(((e,a)=>u(e,t.coords[a],r))),c=u(e.alpha,t.alpha,r),l={space:a,coords:i,alpha:c};return s&&(l.coords=l.coords.map((e=>e/c))),n!==a&&(l=bt(l,n)),l}),{rangeArgs:i})}function er(e){return"function"===a(e)&&!!e.rangeArgs}C.interpolationSpace="lab";var tr=Object.freeze({__proto__:null,isRange:er,mix:Qt,range:Vt,register:function(e){e.defineFunction("mix",Qt,{returns:"color"}),e.defineFunction("range",Vt,{returns:"function<color>"}),e.defineFunction("steps",Kt,{returns:"array<color>"})},steps:Kt}),rr=new N({id:"hsl",name:"HSL",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},s:{range:[0,100],name:"Saturation"},l:{range:[0,100],name:"Lightness"}},base:At,fromBase:e=>{let t=Math.max(...e),r=Math.min(...e),[a,n,o]=e,[s,i,c]=[NaN,0,(r+t)/2],l=t-r;if(0!==l){switch(i=0===c||1===c?0:(t-c)/Math.min(c,1-c),t){case a:s=(n-o)/l+(n<o?6:0);break;case n:s=(o-a)/l+2;break;case o:s=(a-n)/l+4}s*=60}return i<0&&(s+=180,i=Math.abs(i)),s>=360&&(s-=360),[s,100*i,100*c]},toBase:e=>{let[t,r,a]=e;function n(e){let n=(e+t/30)%12,o=r*Math.min(a,1-a);return a-o*Math.max(-1,Math.min(n-3,9-n,1))}return t%=360,t<0&&(t+=360),r/=100,a/=100,[n(0),n(8),n(4)]},formats:{hsl:{coords:["<number> | <angle>","<percentage>","<percentage>"]},hsla:{coords:["<number> | <angle>","<percentage>","<percentage>"],commas:!0,lastAlpha:!0}}}),ar=new N({id:"hsv",name:"HSV",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},s:{range:[0,100],name:"Saturation"},v:{range:[0,100],name:"Value"}},base:rr,fromBase(e){let[t,r,a]=e;r/=100,a/=100;let n=a+r*Math.min(a,1-a);return[t,0===n?0:200*(1-a/n),100*n]},toBase(e){let[t,r,a]=e;r/=100,a/=100;let n=a*(1-r/2);return[t,0===n||1===n?0:(a-n)/Math.min(n,1-n)*100,100*n]},formats:{color:{id:"--hsv",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}}),nr=new N({id:"hwb",name:"HWB",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},w:{range:[0,100],name:"Whiteness"},b:{range:[0,100],name:"Blackness"}},base:ar,fromBase(e){let[t,r,a]=e;return[t,a*(100-r)/100,100-a]},toBase(e){let[t,r,a]=e;r/=100,a/=100;let n=r+a;if(n>=1){return[t,0,100*(r/n)]}let o=1-a;return[t,100*(0===o?0:1-r/o),100*o]},formats:{hwb:{coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});var or=new k({id:"a98rgb-linear",cssId:"--a98-rgb-linear",name:"Linear Adobe® 98 RGB compatible",white:"D65",toXYZ_M:[[.5766690429101305,.1855582379065463,.1882286462349947],[.29734497525053605,.6273635662554661,.07529145849399788],[.02703136138641234,.07068885253582723,.9913375368376388]],fromXYZ_M:[[2.0415879038107465,-.5650069742788596,-.34473135077832956],[-.9692436362808795,1.8759675015077202,.04155505740717557],[.013444280632031142,-.11836239223101838,1.0151749943912054]]}),sr=new k({id:"a98rgb",cssId:"a98-rgb",name:"Adobe® 98 RGB compatible",base:or,toBase:e=>e.map((e=>Math.pow(Math.abs(e),563/256)*Math.sign(e))),fromBase:e=>e.map((e=>Math.pow(Math.abs(e),256/563)*Math.sign(e)))});var ir=new k({id:"prophoto-linear",cssId:"--prophoto-rgb-linear",name:"Linear ProPhoto",white:"D50",base:T,toXYZ_M:[[.7977666449006423,.13518129740053308,.0313477341283922],[.2880748288194013,.711835234241873,8993693872564e-17],[0,0,.8251046025104602]],fromXYZ_M:[[1.3457868816471583,-.25557208737979464,-.05110186497554526],[-.5446307051249019,1.5082477428451468,.02052744743642139],[0,0,1.2119675456389452]]});const cr=1/512;var lr=new k({id:"prophoto",cssId:"prophoto-rgb",name:"ProPhoto",base:ir,toBase:e=>e.map((e=>e<.03125?e/16:e**1.8)),fromBase:e=>e.map((e=>e>=cr?e**(1/1.8):16*e))}),hr=new N({id:"oklch",name:"Oklch",coords:{l:{refRange:[0,1],name:"Lightness"},c:{refRange:[0,.4],name:"Chroma"},h:{refRange:[0,360],type:"angle",name:"Hue"}},white:"D65",base:ae,fromBase(e){let t,[r,a,n]=e;const o=2e-4;return t=Math.abs(a)<o&&Math.abs(n)<o?NaN:180*Math.atan2(n,a)/Math.PI,[r,Math.sqrt(a**2+n**2),G(t)]},toBase(e){let t,r,[a,n,o]=e;return isNaN(o)?(t=0,r=0):(t=n*Math.cos(o*Math.PI/180),r=n*Math.sin(o*Math.PI/180)),[a,t,r]},formats:{oklch:{coords:["<percentage> | <number>","<number> | <percentage>[0,1]","<number> | <angle>"]}}});let ur=R.D65;const dr=216/24389,mr=24389/27,[pr,fr]=Xt({space:P,coords:ur});var gr=new N({id:"luv",name:"Luv",coords:{l:{refRange:[0,100],name:"Lightness"},u:{refRange:[-215,215]},v:{refRange:[-215,215]}},white:ur,base:P,fromBase(e){let t=[s(e[0]),s(e[1]),s(e[2])],r=t[1],[a,n]=Xt({space:P,coords:t});if(!Number.isFinite(a)||!Number.isFinite(n))return[0,0,0];let o=r<=dr?mr*r:116*Math.cbrt(r)-16;return[o,13*o*(a-pr),13*o*(n-fr)]},toBase(e){let[t,r,a]=e;if(0===t||o(t))return[0,0,0];r=s(r),a=s(a);let n=r/(13*t)+pr,i=a/(13*t)+fr,c=t<=8?t/mr:Math.pow((t+16)/116,3);return[c*(9*n/(4*i)),c,c*((12-3*n-20*i)/(4*i))]},formats:{color:{id:"--luv",coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}}),br=new N({id:"lchuv",name:"LChuv",coords:{l:{refRange:[0,100],name:"Lightness"},c:{refRange:[0,220],name:"Chroma"},h:{refRange:[0,360],type:"angle",name:"Hue"}},base:gr,fromBase(e){let t,[r,a,n]=e;return t=Math.abs(a)<.02&&Math.abs(n)<.02?NaN:180*Math.atan2(n,a)/Math.PI,[r,Math.sqrt(a**2+n**2),G(t)]},toBase(e){let[t,r,a]=e;return r<0&&(r=0),isNaN(a)&&(a=0),[t,r*Math.cos(a*Math.PI/180),r*Math.sin(a*Math.PI/180)]},formats:{color:{id:"--lchuv",coords:["<number> | <percentage>","<number> | <percentage>","<number> | <angle>"]}}});const Mr=216/24389,wr=24389/27,yr=St[0][0],vr=St[0][1],Cr=St[0][2],Rr=St[1][0],Sr=St[1][1],_r=St[1][2],Br=St[2][0],Er=St[2][1],Lr=St[2][2];function Ar(e,t,r){const a=t/(Math.sin(r)-e*Math.cos(r));return a<0?1/0:a}function Nr(e){const t=Math.pow(e+16,3)/1560896,r=t>Mr?t:e/wr,a=r*(284517*yr-94839*Cr),n=r*(838422*Cr+769860*vr+731718*yr),o=r*(632260*Cr-126452*vr),s=r*(284517*Rr-94839*_r),i=r*(838422*_r+769860*Sr+731718*Rr),c=r*(632260*_r-126452*Sr),l=r*(284517*Br-94839*Lr),h=r*(838422*Lr+769860*Er+731718*Br),u=r*(632260*Lr-126452*Er);return{r0s:a/o,r0i:n*e/o,r1s:a/(o+126452),r1i:(n-769860)*e/(o+126452),g0s:s/c,g0i:i*e/c,g1s:s/(c+126452),g1i:(i-769860)*e/(c+126452),b0s:l/u,b0i:h*e/u,b1s:l/(u+126452),b1i:(h-769860)*e/(u+126452)}}function xr(e,t){const r=t/360*Math.PI*2,a=Ar(e.r0s,e.r0i,r),n=Ar(e.r1s,e.r1i,r),o=Ar(e.g0s,e.g0i,r),s=Ar(e.g1s,e.g1i,r),i=Ar(e.b0s,e.b0i,r),c=Ar(e.b1s,e.b1i,r);return Math.min(a,n,o,s,i,c)}var Ir=new N({id:"hsluv",name:"HSLuv",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},s:{range:[0,100],name:"Saturation"},l:{range:[0,100],name:"Lightness"}},base:br,gamutSpace:At,fromBase(e){let t,[r,a,n]=[s(e[0]),s(e[1]),s(e[2])];if(r>99.9999999)t=0,r=100;else if(r<1e-8)t=0,r=0;else{t=a/xr(Nr(r),n)*100}return[n,t,r]},toBase(e){let t,[r,a,n]=[s(e[0]),s(e[1]),s(e[2])];if(n>99.9999999)n=100,t=0;else if(n<1e-8)n=0,t=0;else{t=xr(Nr(n),r)/100*a}return[n,t,r]},formats:{color:{id:"--hsluv",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});function Pr(e,t){return Math.abs(t)/Math.sqrt(Math.pow(e,2)+1)}function kr(e){let t=Pr(e.r0s,e.r0i),r=Pr(e.r1s,e.r1i),a=Pr(e.g0s,e.g0i),n=Pr(e.g1s,e.g1i),o=Pr(e.b0s,e.b0i),s=Pr(e.b1s,e.b1i);return Math.min(t,r,a,n,o,s)}St[0][0],St[0][1],St[0][2],St[1][0],St[1][1],St[1][2],St[2][0],St[2][1],St[2][2];var Dr=new N({id:"hpluv",name:"HPLuv",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},s:{range:[0,100],name:"Saturation"},l:{range:[0,100],name:"Lightness"}},base:br,gamutSpace:"self",fromBase(e){let t,[r,a,n]=[s(e[0]),s(e[1]),s(e[2])];if(r>99.9999999)t=0,r=100;else if(r<1e-8)t=0,r=0;else{t=a/kr(Nr(r))*100}return[n,t,r]},toBase(e){let t,[r,a,n]=[s(e[0]),s(e[1]),s(e[2])];if(n>99.9999999)n=100,t=0;else if(n<1e-8)n=0,t=0;else{t=kr(Nr(n))/100*a}return[n,t,r]},formats:{color:{id:"--hpluv",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});const Or=2610/16384,zr=16384/2610,jr=32/2523,Tr=.8359375,Hr=2413/128,$r=18.6875;var qr=new k({id:"rec2100pq",cssId:"rec2100-pq",name:"REC.2100-PQ",base:wt,toBase:e=>e.map((function(e){return 1e4*(Math.max(e**jr-Tr,0)/(Hr-$r*e**jr))**zr/203})),fromBase:e=>e.map((function(e){let t=Math.max(203*e/1e4,0);return((Tr+Hr*t**Or)/(1+$r*t**Or))**78.84375}))});const Wr=.17883277,Fr=.28466892,Gr=.55991073,Xr=3.7743;var Yr=new k({id:"rec2100hlg",cssId:"rec2100-hlg",name:"REC.2100-HLG",referred:"scene",base:wt,toBase:e=>e.map((function(e){return e<=.5?e**2/3*Xr:(Math.exp((e-Gr)/Wr)+Fr)/12*Xr})),fromBase:e=>e.map((function(e){return(e/=Xr)<=1/12?Math.sqrt(3*e):Wr*Math.log(12*e-Fr)+Gr}))});const Zr={};function Ur({id:e,toCone_M:t,fromCone_M:r}){Zr[e]=arguments[0]}function Jr(e,r,a="Bradford"){let n=Zr[a],[o,s,i]=t(n.toCone_M,e),[c,l,h]=t(n.toCone_M,r),u=t([[c/o,0,0],[0,l/s,0],[0,0,h/i]],n.toCone_M);return t(n.fromCone_M,u)}v.add("chromatic-adaptation-start",(e=>{e.options.method&&(e.M=Jr(e.W1,e.W2,e.options.method))})),v.add("chromatic-adaptation-end",(e=>{e.M||(e.M=Jr(e.W1,e.W2,e.options.method))})),Ur({id:"von Kries",toCone_M:[[.40024,.7076,-.08081],[-.2263,1.16532,.0457],[0,0,.91822]],fromCone_M:[[1.8599363874558397,-1.1293816185800916,.21989740959619328],[.3611914362417676,.6388124632850422,-6370596838649899e-21],[0,0,1.0890636230968613]]}),Ur({id:"Bradford",toCone_M:[[.8951,.2664,-.1614],[-.7502,1.7135,.0367],[.0389,-.0685,1.0296]],fromCone_M:[[.9869929054667121,-.14705425642099013,.15996265166373122],[.4323052697233945,.5183602715367774,.049291228212855594],[-.00852866457517732,.04004282165408486,.96848669578755]]}),Ur({id:"CAT02",toCone_M:[[.7328,.4296,-.1624],[-.7036,1.6975,.0061],[.003,.0136,.9834]],fromCone_M:[[1.0961238208355142,-.27886900021828726,.18274517938277307],[.4543690419753592,.4735331543074117,.07209780371722911],[-.009627608738429355,-.00569803121611342,1.0153256399545427]]}),Ur({id:"CAT16",toCone_M:[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],fromCone_M:[[1.862067855087233,-1.0112546305316845,.14918677544445172],[.3875265432361372,.6214474419314753,-.008973985167612521],[-.01584149884933386,-.03412293802851557,1.0499644368778496]]}),Object.assign(R,{A:[1.0985,1,.35585],C:[.98074,1,1.18232],D55:[.95682,1,.92149],D75:[.94972,1,1.22638],E:[1,1,1],F2:[.99186,1,.67393],F7:[.95041,1,1.08747],F11:[1.00962,1,.6435]}),R.ACES=[.32168/.33767,1,.34065/.33767];var Qr=new k({id:"acescg",cssId:"--acescg",name:"ACEScg",coords:{r:{range:[0,65504],name:"Red"},g:{range:[0,65504],name:"Green"},b:{range:[0,65504],name:"Blue"}},referred:"scene",white:R.ACES,toXYZ_M:[[.6624541811085053,.13400420645643313,.1561876870049078],[.27222871678091454,.6740817658111484,.05368951740793705],[-.005574649490394108,.004060733528982826,1.0103391003129971]],fromXYZ_M:[[1.6410233796943257,-.32480329418479,-.23642469523761225],[-.6636628587229829,1.6153315916573379,.016756347685530137],[.011721894328375376,-.008284441996237409,.9883948585390215]]});const Kr=2**-16,Vr=-.35828683,ea=(Math.log2(65504)+9.72)/17.52;var ta=new k({id:"acescc",cssId:"--acescc",name:"ACEScc",coords:{r:{range:[Vr,ea],name:"Red"},g:{range:[Vr,ea],name:"Green"},b:{range:[Vr,ea],name:"Blue"}},referred:"scene",base:Qr,toBase:e=>e.map((function(e){return e<=-.3013698630136986?2*(2**(17.52*e-9.72)-Kr):e<ea?2**(17.52*e-9.72):65504})),fromBase:e=>e.map((function(e){return e<=0?(Math.log2(Kr)+9.72)/17.52:e<Kr?(Math.log2(Kr+.5*e)+9.72)/17.52:(Math.log2(e)+9.72)/17.52}))}),ra=Object.freeze({__proto__:null,A98RGB:sr,A98RGB_Linear:or,ACEScc:ta,ACEScg:Qr,CAM16_JMh:rt,HCT:lt,HPLuv:Dr,HSL:rr,HSLuv:Ir,HSV:ar,HWB:nr,ICTCP:Te,JzCzHz:Ee,Jzazbz:Be,LCH:X,LCHuv:br,Lab:F,Lab_D65:Wt,Luv:gr,OKLCH:hr,OKLab:ae,P3:Nt,P3_Linear:Rt,ProPhoto:lr,ProPhoto_Linear:ir,REC_2020:Ct,REC_2020_Linear:wt,REC_2100_HLG:Yr,REC_2100_PQ:qr,XYZ_ABS_D65:he,XYZ_D50:T,XYZ_D65:P,sRGB:At,sRGB_Linear:_t});class aa{constructor(...e){let t,r,a,n;1===e.length&&(t=A(e[0])),t?(r=t.space||t.spaceId,a=t.coords,n=t.alpha):[r,a,n]=e,Object.defineProperty(this,"space",{value:N.get(r),writable:!1,enumerable:!0,configurable:!0}),this.coords=a?a.slice():[0,0,0],this.alpha=n>1||void 0===n?1:n<0?0:n;for(let e=0;e<this.coords.length;e++)"NaN"===this.coords[e]&&(this.coords[e]=NaN);for(let e in this.space.coords)Object.defineProperty(this,e,{get:()=>this.get(e),set:t=>this.set(e,t)})}get spaceId(){return this.space.id}clone(){return new aa(this.space,this.coords,this.alpha)}toJSON(){return{spaceId:this.spaceId,coords:this.coords,alpha:this.alpha}}display(...e){let t=function(e,{space:t=C.display_space,...r}={}){let a=Mt(e,r);if("undefined"==typeof CSS||CSS.supports("color",a)||!C.display_space)a=new String(a),a.color=e;else{let n=e;if((e.coords.some(o)||o(e.alpha))&&!(xt??=CSS.supports("color","hsl(none 50% 50%)"))&&(n=ie(e),n.coords=n.coords.map(s),n.alpha=s(n.alpha),a=Mt(n,r),CSS.supports("color",a)))return a=new String(a),a.color=n,a;n=bt(n,t),a=new String(Mt(n,r)),a.color=n}return a}(this,...e);return t.color=new aa(t.color),t}static get(e,...t){return e instanceof aa?e:new aa(e,...t)}static defineFunction(e,t,r=t){let{instance:a=!0,returns:n}=r,o=function(...e){let r=t(...e);if("color"===n)r=aa.get(r);else if("function<color>"===n){let e=r;r=function(...t){let r=e(...t);return aa.get(r)},Object.assign(r,e)}else"array<color>"===n&&(r=r.map((e=>aa.get(e))));return r};e in aa||(aa[e]=o),a&&(aa.prototype[e]=function(...e){return o(this,...e)})}static defineFunctions(e){for(let t in e)aa.defineFunction(t,e[t],e[t])}static extend(e){if(e.register)e.register(aa);else for(let t in e)aa.defineFunction(t,e[t])}}aa.defineFunctions({get:O,getAll:D,set:j,setAll:z,to:bt,equals:function(e,t){return e=A(e),t=A(t),e.space===t.space&&e.alpha===t.alpha&&e.coords.every(((e,r)=>e===t.coords[r]))},inGamut:se,toGamut:ft,distance:ce,toString:Mt}),Object.assign(aa,{util:y,hooks:v,WHITES:R,Space:N,spaces:N.registry,parse:L,defaults:C});for(let e of Object.keys(ra))N.register(ra[e]);for(let e in N.registry)na(e,N.registry[e]);function na(e,t){let r=e.replace(/-/g,"_");Object.defineProperty(aa.prototype,r,{get(){let r=this.getAll(e);return"undefined"==typeof Proxy?r:new Proxy(r,{has:(e,r)=>{try{return N.resolveCoord([t,r]),!0}catch(e){}return Reflect.has(e,r)},get:(e,r,a)=>{if(r&&"symbol"!=typeof r&&!(r in e)){let{index:a}=N.resolveCoord([t,r]);if(a>=0)return e[a]}return Reflect.get(e,r,a)},set:(r,a,n,o)=>{if(a&&"symbol"!=typeof a&&!(a in r)||a>=0){let{index:o}=N.resolveCoord([t,a]);if(o>=0)return r[o]=n,this.setAll(e,r),!0}return Reflect.set(r,a,n,o)}})},set(t){this.setAll(e,t)},configurable:!0,enumerable:!0})}v.add("colorspace-init-end",(e=>{na(e.id,e),e.aliases?.forEach((t=>{na(t,e)}))})),aa.extend(mt),aa.extend({deltaE:Ut}),Object.assign(aa,{deltaEMethods:mt}),aa.extend(Jt),aa.extend({contrast:function(e,t,a={}){r(a)&&(a={algorithm:a});let{algorithm:n,...o}=a;if(!n){let e=Object.keys(Gt).map((e=>e.replace(/^contrast/,""))).join(", ");throw new TypeError(`contrast() function needs a contrast algorithm. Please specify one of: ${e}`)}e=A(e),t=A(t);for(let r in Gt)if("contrast"+n.toLowerCase()===r.toLowerCase())return Gt[r](e,t,o);throw new TypeError(`Unknown contrast algorithm: ${n}`)}}),aa.extend(Zt),aa.extend(kt),aa.extend(tr),aa.extend(Gt);class oa{constructor(e,t,r){this.colorSpace=null==r?oa.DEFAULT_COLORSPACE:r,this.height=t,this.width=e,this.data=new Uint16Array(t*e*4)}fill(e){if(4==e.length){for(let t=0;t<this.data.length;t+=4)this.data[t]=e[0],this.data[t+1]=e[1],this.data[t+2]=e[2],this.data[t+3]=e[3];return this}}getPixel(e,t){const r=4*(t*this.width+e);return this.data.slice(r,r+4)}setPixel(e,t,r){const a=4*(t*this.width+e);this.data[a+0]=r[0],this.data[a+1]=r[1],this.data[a+2]=r[2],this.data[a+3]=r[3]}static scaleUint8ToUint16(e){return e<<8|e}getImageData(){return void 0===this.data||null===this.data?null:new ImageData(this.data,this.width,this.height,{colorSpace:this.colorSpace})}static convertPixelToRec2100_hlg(e){const t=oa.COLORSPACES["rec2100-hlg"],r=new aa("srgb",Array.from(e.slice(0,3)).map((e=>e/255)),e[3]/255).to(t),a=r.coords.map((e=>Math.round(e*oa.SDR_MULTIPLIER)));return a.push(r.alpha*oa.SDR_MULTIPLIER),Uint16Array.from(a)}static convertArrayToRec2100_hlg(e){const t=new Uint16Array(e.length);for(let r=0;r<e.length;r+=4){const a=e.slice(r,r+4),n=oa.convertPixelToRec2100_hlg(a);t.set(n,r)}return t}pixelCallback(e){for(let t=0;t<this.data.length;t+=4)this.data.set(e(this.data[t],this.data[t+1],this.data[t+2],this.data[t+3]),t)}static async loadSDRImageData(e){return fetch(e).then((e=>e.blob())).then((e=>createImageBitmap(e))).then((e=>{const{width:t,height:r}=e,a=new OffscreenCanvas(t,r).getContext("2d");return null==a||a.drawImage(e,0,0),a})).then((e=>null==e?void 0:e.getImageData(0,0,null==e?void 0:e.canvas.width,null==e?void 0:e.canvas.height)))}static fromImageData(e){const t=new oa(e.width,e.height);if("srgb"==e.colorSpace)t.data=oa.convertArrayToRec2100_hlg(e.data);else{if(e.colorSpace!=oa.DEFAULT_COLORSPACE)throw new Error(`ColorSpace ${e.colorSpace} isn't supported!`);t.data=e.data}return t}static async fromURL(e){return oa.loadSDRImageData(e).then((e=>{if(void 0!==e)return oa.fromImageData(e)}))}setImageData(e){if(this.width=e.width,this.height=e.height,"srgb"==e.colorSpace)this.data=oa.convertArrayToRec2100_hlg(e.data);else{if(e.colorSpace!=oa.DEFAULT_COLORSPACE)throw new Error(`ColorSpace ${e.colorSpace} isn't supported!`);this.data=e.data}this.colorSpace=oa.DEFAULT_COLORSPACE}clone(){const e=new oa(this.width,this.height,this.colorSpace);return e.data=this.data.slice(),e}}oa.DEFAULT_COLORSPACE="rec2100-hlg",oa.SDR_MULTIPLIER=65535,oa.COLORSPACES={"rec2100-hlg":"rec2100hlg","display-p3":"p3",srgb:"sRGB","rec2100-pq":"rec2100pq"};const sa={colorSpace:oa.DEFAULT_COLORSPACE,pixelFormat:"float16"};return e.Uint16Image=oa,e.checkHDR=function(){try{const e=screen.colorDepth/3,t=e>8,r=window.matchMedia("(dynamic-range: high)").matches;return!(!(window.matchMedia("(color-gamut: rec2020)").matches||window.matchMedia("(color-gamut: p3)").matches)||!r)&&(e===Math.round(e)&&!!t)}catch(e){return console.error("Bad window.screen test",e),!1}},e.checkHDRCanvas=function(){try{const e=document.createElement("canvas");if(!e.getContext)return!1;return null!==e.getContext("2d",{colorSpace:"rec2100-pq",pixelFormat:"float16"})}catch(e){return console.error("Bad canvas ColorSpace test",e),!1}},e.initHDRCanvas=function(e){return e.configureHighDynamicRange({mode:"extended"}),e.getContext("2d",sa)},e}({});
|
1
|
+
var HDRCanvas=function(e){"use strict";function t(e,t){let r=e.length;Array.isArray(e[0])||(e=[e]),Array.isArray(t[0])||(t=t.map((e=>[e])));let a=t[0].length,n=t[0].map(((e,r)=>t.map((e=>e[r])))),o=e.map((e=>n.map((t=>{let r=0;if(!Array.isArray(e)){for(let a of t)r+=e*a;return r}for(let a=0;a<e.length;a++)r+=e[a]*(t[a]||0);return r}))));return 1===r&&(o=o[0]),1===a?o.map((e=>e[0])):o}function r(e){return"string"===a(e)}function a(e){return(Object.prototype.toString.call(e).match(/^\[object\s+(.*?)\]$/)[1]||"").toLowerCase()}function n(e,{precision:t,unit:r}){return o(e)?"none":i(e,t)+(r??"")}function o(e){return Number.isNaN(e)||e instanceof Number&&e?.none}function s(e){return o(e)?0:e}function i(e,t){if(0===e)return 0;let r=~~e,a=0;r&&t&&(a=1+~~Math.log10(Math.abs(r)));const n=10**(t-a);return Math.floor(e*n+.5)/n}const c={deg:1,grad:.9,rad:180/Math.PI,turn:360};function l(e){if(!e)return;e=e.trim();const t=/^-?[\d.]+$/,r=/%|deg|g?rad|turn$/,a=/\/?\s*(none|[-\w.]+(?:%|deg|g?rad|turn)?)/g;let n=e.match(/^([a-z]+)\((.+?)\)$/i);if(n){let e=[];return n[2].replace(a,((a,n)=>{let o=n.match(r),s=n;if(o){let e=o[0],t=s.slice(0,-e.length);"%"===e?(s=new Number(t/100),s.type="<percentage>"):(s=new Number(t*c[e]),s.type="<angle>",s.unit=e)}else t.test(s)?(s=new Number(s),s.type="<number>"):"none"===s&&(s=new Number(NaN),s.none=!0);a.startsWith("/")&&(s=s instanceof Number?s:new Number(s),s.alpha=!0),"object"==typeof s&&s instanceof Number&&(s.raw=n),e.push(s)})),{name:n[1].toLowerCase(),rawName:n[1],rawArgs:n[2],args:e}}}function h(e){return e[e.length-1]}function u(e,t,r){return isNaN(e)?t:isNaN(t)?e:e+(t-e)*r}function d(e,t,r){return(r-e)/(t-e)}function m(e,t,r){return u(t[0],t[1],d(e[0],e[1],r))}function p(e){return e.map((e=>e.split("|").map((e=>{let t=(e=e.trim()).match(/^(<[a-z]+>)\[(-?[.\d]+),\s*(-?[.\d]+)\]?$/);if(t){let e=new String(t[1]);return e.range=[+t[2],+t[3]],e}return e}))))}function f(e,t,r){return Math.max(Math.min(r,t),e)}function g(e,t){return Math.sign(e)===Math.sign(t)?e:-e}function b(e,t){return g(Math.abs(e)**t,e)}function M(e,t){return 0===t?0:e/t}function w(e,t,r=0,a=e.length){for(;r<a;){const n=r+a>>1;e[n]<t?r=n+1:a=n}return r}var y=Object.freeze({__proto__:null,bisectLeft:w,clamp:f,copySign:g,interpolate:u,interpolateInv:d,isNone:o,isString:r,last:h,mapRange:m,multiplyMatrices:t,parseCoordGrammar:p,parseFunction:l,serializeNumber:n,skipNone:s,spow:b,toPrecision:i,type:a,zdiv:M});const C=new class{add(e,t,r){if("string"==typeof arguments[0])(Array.isArray(e)?e:[e]).forEach((function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)}),this);else for(var e in arguments[0])this.add(e,arguments[0][e],arguments[1])}run(e,t){this[e]=this[e]||[],this[e].forEach((function(e){e.call(t&&t.context?t.context:t,t)}))}};var v={gamut_mapping:"css",precision:5,deltaE:"76",verbose:"test"!==globalThis?.process?.env?.NODE_ENV?.toLowerCase(),warn:function(e){this.verbose&&globalThis?.console?.warn?.(e)}};const R={D50:[.3457/.3585,1,.2958/.3585],D65:[.3127/.329,1,.3583/.329]};function _(e){return Array.isArray(e)?e:R[e]}function S(e,r,a,n={}){if(e=_(e),r=_(r),!e||!r)throw new TypeError(`Missing white point to convert ${e?"":"from"}${e||r?"":"/"}${r?"":"to"}`);if(e===r)return a;let o={W1:e,W2:r,XYZ:a,options:n};if(C.run("chromatic-adaptation-start",o),o.M||(o.W1===R.D65&&o.W2===R.D50?o.M=[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]]:o.W1===R.D50&&o.W2===R.D65&&(o.M=[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]])),C.run("chromatic-adaptation-end",o),o.M)return t(o.M,o.XYZ);throw new TypeError("Only Bradford CAT with white points D50 and D65 supported for now.")}const x=new Set(["<number>","<percentage>","<angle>"]);function B(e,t,r,a){let n=Object.entries(e.coords).map((([e,n],o)=>{let s,i=t.coordGrammar[o],c=a[o],l=c?.type;if(s=c.none?i.find((e=>x.has(e))):i.find((e=>e==l)),!s){let t=n.name||e;throw new TypeError(`${l??c.raw} not allowed for ${t} in ${r}()`)}let h=s.range;"<percentage>"===l&&(h||=[0,1]);let u=n.range||n.refRange;return h&&u&&(a[o]=m(h,u,a[o])),s}));return n}function E(e,{meta:t}={}){let r={str:String(e)?.trim()};if(C.run("parse-start",r),r.color)return r.color;if(r.parsed=l(r.str),r.parsed){let e=r.parsed.name;if("color"===e){let e=r.parsed.args.shift(),a=e.startsWith("--")?e.substring(2):`--${e}`,n=[e,a],o=r.parsed.rawArgs.indexOf("/")>0?r.parsed.args.pop():1;for(let a of A.all){let s=a.getFormat("color");if(s&&(n.includes(s.id)||s.ids?.filter((e=>n.includes(e))).length)){const n=Object.keys(a.coords).map(((e,t)=>r.parsed.args[t]||0));let i;return s.coordGrammar&&(i=B(a,s,"color",n)),t&&Object.assign(t,{formatId:"color",types:i}),s.id.startsWith("--")&&!e.startsWith("--")&&v.warn(`${a.name} is a non-standard space and not currently supported in the CSS spec. Use prefixed color(${s.id}) instead of color(${e}).`),e.startsWith("--")&&!s.id.startsWith("--")&&v.warn(`${a.name} is a standard space and supported in the CSS spec. Use color(${s.id}) instead of prefixed color(${e}).`),{spaceId:a.id,coords:n,alpha:o}}}let s="",i=e in A.registry?e:a;if(i in A.registry){let e=A.registry[i].formats?.color?.id;e&&(s=`Did you mean color(${e})?`)}throw new TypeError(`Cannot parse color(${e}). `+(s||"Missing a plugin?"))}for(let a of A.all){let n=a.getFormat(e);if(n&&"function"===n.type){let o=1;(n.lastAlpha||h(r.parsed.args).alpha)&&(o=r.parsed.args.pop());let s,i=r.parsed.args;return n.coordGrammar&&(s=B(a,n,e,i)),t&&Object.assign(t,{formatId:n.name,types:s}),{spaceId:a.id,coords:i,alpha:o}}}}else for(let e of A.all)for(let a in e.formats){let n=e.formats[a];if("custom"!==n.type)continue;if(n.test&&!n.test(r.str))continue;let o=n.parse(r.str);if(o)return o.alpha??=1,t&&(t.formatId=a),o}throw new TypeError(`Could not parse ${e} as a color. Missing a plugin?`)}function L(e){if(Array.isArray(e))return e.map(L);if(!e)throw new TypeError("Empty color reference");r(e)&&(e=E(e));let t=e.space||e.spaceId;return t instanceof A||(e.space=A.get(t)),void 0===e.alpha&&(e.alpha=1),e}class A{constructor(e){this.id=e.id,this.name=e.name,this.base=e.base?A.get(e.base):null,this.aliases=e.aliases,this.base&&(this.fromBase=e.fromBase,this.toBase=e.toBase);let t=e.coords??this.base.coords;for(let e in t)"name"in t[e]||(t[e].name=e);this.coords=t;let r=e.white??this.base.white??"D65";this.white=_(r),this.formats=e.formats??{};for(let e in this.formats){let t=this.formats[e];t.type||="function",t.name||=e}this.formats.color?.id||(this.formats.color={...this.formats.color??{},id:e.cssId||this.id}),e.gamutSpace?this.gamutSpace="self"===e.gamutSpace?this:A.get(e.gamutSpace):this.isPolar?this.gamutSpace=this.base:this.gamutSpace=this,this.gamutSpace.isUnbounded&&(this.inGamut=(e,t)=>!0),this.referred=e.referred,Object.defineProperty(this,"path",{value:N(this).reverse(),writable:!1,enumerable:!0,configurable:!0}),C.run("colorspace-init-end",this)}inGamut(e,{epsilon:t=75e-6}={}){if(!this.equals(this.gamutSpace))return e=this.to(this.gamutSpace,e),this.gamutSpace.inGamut(e,{epsilon:t});let r=Object.values(this.coords);return e.every(((e,a)=>{let n=r[a];if("angle"!==n.type&&n.range){if(Number.isNaN(e))return!0;let[r,a]=n.range;return(void 0===r||e>=r-t)&&(void 0===a||e<=a+t)}return!0}))}get isUnbounded(){return Object.values(this.coords).every((e=>!("range"in e)))}get cssId(){return this.formats?.color?.id||this.id}get isPolar(){for(let e in this.coords)if("angle"===this.coords[e].type)return!0;return!1}getFormat(e){if("object"==typeof e)return e=I(e,this);let t;return t="default"===e?Object.values(this.formats)[0]:this.formats[e],t?(t=I(t,this),t):null}equals(e){return!!e&&(this===e||this.id===e||this.id===e.id)}to(e,t){if(1===arguments.length){const r=L(e);[e,t]=[r.space,r.coords]}if(e=A.get(e),this.equals(e))return t;t=t.map((e=>Number.isNaN(e)?0:e));let r,a,n=this.path,o=e.path;for(let e=0;e<n.length&&n[e].equals(o[e]);e++)r=n[e],a=e;if(!r)throw new Error(`Cannot convert between color spaces ${this} and ${e}: no connection space was found`);for(let e=n.length-1;e>a;e--)t=n[e].toBase(t);for(let e=a+1;e<o.length;e++)t=o[e].fromBase(t);return t}from(e,t){if(1===arguments.length){const r=L(e);[e,t]=[r.space,r.coords]}return(e=A.get(e)).to(this,t)}toString(){return`${this.name} (${this.id})`}getMinCoords(){let e=[];for(let t in this.coords){let r=this.coords[t],a=r.range||r.refRange;e.push(a?.min??0)}return e}static registry={};static get all(){return[...new Set(Object.values(A.registry))]}static register(e,t){if(1===arguments.length&&(e=(t=arguments[0]).id),t=this.get(t),this.registry[e]&&this.registry[e]!==t)throw new Error(`Duplicate color space registration: '${e}'`);if(this.registry[e]=t,1===arguments.length&&t.aliases)for(let e of t.aliases)this.register(e,t);return t}static get(e,...t){if(!e||e instanceof A)return e;if("string"===a(e)){let t=A.registry[e.toLowerCase()];if(!t)throw new TypeError(`No color space found with id = "${e}"`);return t}if(t.length)return A.get(...t);throw new TypeError(`${e} is not a valid color space`)}static resolveCoord(e,t){let r,n,o=a(e);if("string"===o?e.includes(".")?[r,n]=e.split("."):[r,n]=[,e]:Array.isArray(e)?[r,n]=e:(r=e.space,n=e.coordId),r=A.get(r),r||(r=t),!r)throw new TypeError(`Cannot resolve coordinate reference ${e}: No color space specified and relative references are not allowed here`);if(o=a(n),"number"===o||"string"===o&&n>=0){let e=Object.entries(r.coords)[n];if(e)return{space:r,id:e[0],index:n,...e[1]}}r=A.get(r);let s=n.toLowerCase(),i=0;for(let e in r.coords){let t=r.coords[e];if(e.toLowerCase()===s||t.name?.toLowerCase()===s)return{space:r,id:e,index:i,...t};i++}throw new TypeError(`No "${n}" coordinate found in ${r.name}. Its coordinates are: ${Object.keys(r.coords).join(", ")}`)}static DEFAULT_FORMAT={type:"functions",name:"color"}}function N(e){let t=[e];for(let r=e;r=r.base;)t.push(r);return t}function I(e,{coords:t}={}){if(e.coords&&!e.coordGrammar){e.type||="function",e.name||="color",e.coordGrammar=p(e.coords);let r=Object.entries(t).map((([t,r],a)=>{let n=e.coordGrammar[a][0],o=r.range||r.refRange,s=n.range,i="";return"<percentage>"==n?(s=[0,100],i="%"):"<angle>"==n&&(i="deg"),{fromRange:o,toRange:s,suffix:i}}));e.serializeCoords=(e,t)=>e.map(((e,a)=>{let{fromRange:o,toRange:s,suffix:i}=r[a];return o&&s&&(e=m(o,s,e)),e=n(e,{precision:t,unit:i})}))}return e}var P=new A({id:"xyz-d65",name:"XYZ D65",coords:{x:{name:"X"},y:{name:"Y"},z:{name:"Z"}},white:"D65",formats:{color:{ids:["xyz-d65","xyz"]}},aliases:["xyz"]});class k extends A{constructor(e){e.coords||(e.coords={r:{range:[0,1],name:"Red"},g:{range:[0,1],name:"Green"},b:{range:[0,1],name:"Blue"}}),e.base||(e.base=P),e.toXYZ_M&&e.fromXYZ_M&&(e.toBase??=r=>{let a=t(e.toXYZ_M,r);return this.white!==this.base.white&&(a=S(this.white,this.base.white,a)),a},e.fromBase??=r=>(r=S(this.base.white,this.white,r),t(e.fromXYZ_M,r))),e.referred??="display",super(e)}}function D(e,t){return e=L(e),!t||e.space.equals(t)?e.coords.slice():(t=A.get(t)).from(e)}function O(e,t){e=L(e);let{space:r,index:a}=A.resolveCoord(t,e.space);return D(e,r)[a]}function z(e,t,r){return e=L(e),t=A.get(t),e.coords=t.to(e.space,r),e}function j(e,t,r){if(e=L(e),2===arguments.length&&"object"===a(arguments[1])){let t=arguments[1];for(let r in t)j(e,r,t[r])}else{"function"==typeof r&&(r=r(O(e,t)));let{space:a,index:n}=A.resolveCoord(t,e.space),o=D(e,a);o[n]=r,z(e,a,o)}return e}z.returns="color",j.returns="color";var T=new A({id:"xyz-d50",name:"XYZ D50",white:"D50",base:P,fromBase:e=>S(P.white,"D50",e),toBase:e=>S("D50",P.white,e)});const H=216/24389,$=24/116,q=24389/27;let W=R.D50;var G=new A({id:"lab",name:"Lab",coords:{l:{refRange:[0,100],name:"Lightness"},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:W,base:T,fromBase(e){let t=e.map(((e,t)=>e/W[t])).map((e=>e>H?Math.cbrt(e):(q*e+16)/116));return[116*t[1]-16,500*(t[0]-t[1]),200*(t[1]-t[2])]},toBase(e){let t=[];return t[1]=(e[0]+16)/116,t[0]=e[1]/500+t[1],t[2]=t[1]-e[2]/200,[t[0]>$?Math.pow(t[0],3):(116*t[0]-16)/q,e[0]>8?Math.pow((e[0]+16)/116,3):e[0]/q,t[2]>$?Math.pow(t[2],3):(116*t[2]-16)/q].map(((e,t)=>e*W[t]))},formats:{lab:{coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}});function F(e){return(e%360+360)%360}var X=new A({id:"lch",name:"LCH",coords:{l:{refRange:[0,100],name:"Lightness"},c:{refRange:[0,150],name:"Chroma"},h:{refRange:[0,360],type:"angle",name:"Hue"}},base:G,fromBase(e){let t,[r,a,n]=e;return t=Math.abs(a)<.02&&Math.abs(n)<.02?NaN:180*Math.atan2(n,a)/Math.PI,[r,Math.sqrt(a**2+n**2),F(t)]},toBase(e){let[t,r,a]=e;return r<0&&(r=0),isNaN(a)&&(a=0),[t,r*Math.cos(a*Math.PI/180),r*Math.sin(a*Math.PI/180)]},formats:{lch:{coords:["<number> | <percentage>","<number> | <percentage>","<number> | <angle>"]}}});const Y=25**7,Z=Math.PI,U=180/Z,J=Z/180;function Q(e){const t=e*e;return t*t*t*e}function K(e,t,{kL:r=1,kC:a=1,kH:n=1}={}){[e,t]=L([e,t]);let[o,s,i]=G.from(e),c=X.from(G,[o,s,i])[1],[l,h,u]=G.from(t),d=X.from(G,[l,h,u])[1];c<0&&(c=0),d<0&&(d=0);let m=Q((c+d)/2),p=.5*(1-Math.sqrt(m/(m+Y))),f=(1+p)*s,g=(1+p)*h,b=Math.sqrt(f**2+i**2),M=Math.sqrt(g**2+u**2),w=0===f&&0===i?0:Math.atan2(i,f),y=0===g&&0===u?0:Math.atan2(u,g);w<0&&(w+=2*Z),y<0&&(y+=2*Z),w*=U,y*=U;let C,R=l-o,_=M-b,S=y-w,x=w+y,B=Math.abs(S);b*M==0?C=0:B<=180?C=S:S>180?C=S-360:S<-180?C=S+360:v.warn("the unthinkable has happened");let E,A=2*Math.sqrt(M*b)*Math.sin(C*J/2),N=(o+l)/2,I=(b+M)/2,P=Q(I);E=b*M==0?x:B<=180?x/2:x<360?(x+360)/2:(x-360)/2;let k=(N-50)**2,D=1+.015*k/Math.sqrt(20+k),O=1+.045*I,z=1;z-=.17*Math.cos((E-30)*J),z+=.24*Math.cos(2*E*J),z+=.32*Math.cos((3*E+6)*J),z-=.2*Math.cos((4*E-63)*J);let j=1+.015*I*z,T=30*Math.exp(-1*((E-275)/25)**2),H=2*Math.sqrt(P/(P+Y)),$=(R/(r*D))**2;return $+=(_/(a*O))**2,$+=(A/(n*j))**2,$+=-1*Math.sin(2*T*J)*H*(_/(a*O))*(A/(n*j)),Math.sqrt($)}const V=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],ee=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],te=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],re=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]];var ae=new A({id:"oklab",name:"Oklab",coords:{l:{refRange:[0,1],name:"Lightness"},a:{refRange:[-.4,.4]},b:{refRange:[-.4,.4]}},white:"D65",base:P,fromBase(e){let r=t(V,e).map((e=>Math.cbrt(e)));return t(te,r)},toBase(e){let r=t(re,e).map((e=>e**3));return t(ee,r)},formats:{oklab:{coords:["<percentage> | <number>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}});function ne(e,t){[e,t]=L([e,t]);let[r,a,n]=ae.from(e),[o,s,i]=ae.from(t),c=r-o,l=a-s,h=n-i;return Math.sqrt(c**2+l**2+h**2)}const oe=75e-6;function se(e,t,{epsilon:r=oe}={}){e=L(e),t||(t=e.space),t=A.get(t);let a=e.coords;return t!==e.space&&(a=t.from(e)),t.inGamut(a,{epsilon:r})}function ie(e){return{space:e.space,coords:e.coords.slice(),alpha:e.alpha}}function ce(e,t,r="lab"){let a=(r=A.get(r)).from(e),n=r.from(t);return Math.sqrt(a.reduce(((e,t,r)=>{let a=n[r];return isNaN(t)||isNaN(a)?e:e+(a-t)**2}),0))}const le=Math.PI/180;var he=new A({id:"xyz-abs-d65",cssId:"--xyz-abs-d65",name:"Absolute XYZ D65",coords:{x:{refRange:[0,9504.7],name:"Xa"},y:{refRange:[0,1e4],name:"Ya"},z:{refRange:[0,10888.3],name:"Za"}},base:P,fromBase:e=>e.map((e=>Math.max(203*e,0))),toBase:e=>e.map((e=>Math.max(e/203,0)))});const ue=1.15,de=.66,me=2610/16384,pe=16384/2610,fe=.8359375,ge=2413/128,be=18.6875,Me=1.7*2523/32,we=32/(1.7*2523),ye=-.56,Ce=16295499532821565e-27,ve=[[.41478972,.579999,.014648],[-.20151,1.120649,.0531008],[-.0166008,.2648,.6684799]],Re=[[1.9242264357876067,-1.0047923125953657,.037651404030618],[.35031676209499907,.7264811939316552,-.06538442294808501],[-.09098281098284752,-.3127282905230739,1.5227665613052603]],_e=[[.5,.5,0],[3.524,-4.066708,.542708],[.199076,1.096799,-1.295875]],Se=[[1,.1386050432715393,.05804731615611886],[.9999999999999999,-.1386050432715393,-.05804731615611886],[.9999999999999998,-.09601924202631895,-.8118918960560388]];var xe=new A({id:"jzazbz",name:"Jzazbz",coords:{jz:{refRange:[0,1],name:"Jz"},az:{refRange:[-.5,.5]},bz:{refRange:[-.5,.5]}},base:he,fromBase(e){let[r,a,n]=e,o=t(ve,[ue*r-(ue-1)*n,de*a-(de-1)*r,n]).map((function(e){return((fe+ge*(e/1e4)**me)/(1+be*(e/1e4)**me))**Me})),[s,i,c]=t(_e,o);return[(1+ye)*s/(1+ye*s)-Ce,i,c]},toBase(e){let[r,a,n]=e,o=t(Se,[(r+Ce)/(1+ye-ye*(r+Ce)),a,n]).map((function(e){return 1e4*((fe-e**we)/(be*e**we-ge))**pe})),[s,i,c]=t(Re,o),l=(s+(ue-1)*c)/ue;return[l,(i+(de-1)*l)/de,c]},formats:{color:{coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}}),Be=new A({id:"jzczhz",name:"JzCzHz",coords:{jz:{refRange:[0,1],name:"Jz"},cz:{refRange:[0,1],name:"Chroma"},hz:{refRange:[0,360],type:"angle",name:"Hue"}},base:xe,fromBase(e){let t,[r,a,n]=e;const o=2e-4;return t=Math.abs(a)<o&&Math.abs(n)<o?NaN:180*Math.atan2(n,a)/Math.PI,[r,Math.sqrt(a**2+n**2),F(t)]},toBase:e=>[e[0],e[1]*Math.cos(e[2]*Math.PI/180),e[1]*Math.sin(e[2]*Math.PI/180)]});const Ee=.8359375,Le=2413/128,Ae=18.6875,Ne=2610/16384,Ie=2523/32,Pe=16384/2610,ke=32/2523,De=[[.3592832590121217,.6976051147779502,-.035891593232029],[-.1920808463704993,1.100476797037432,.0753748658519118],[.0070797844607479,.0748396662186362,.8433265453898765]],Oe=[[.5,.5,0],[6610/4096,-13613/4096,7003/4096],[17933/4096,-17390/4096,-543/4096]],ze=[[.9999999999999998,.0086090370379328,.111029625003026],[.9999999999999998,-.0086090370379328,-.1110296250030259],[.9999999999999998,.5600313357106791,-.3206271749873188]],je=[[2.0701522183894223,-1.3263473389671563,.2066510476294053],[.3647385209748072,.6805660249472273,-.0453045459220347],[-.0497472075358123,-.0492609666966131,1.1880659249923042]];var Te=new A({id:"ictcp",name:"ICTCP",coords:{i:{refRange:[0,1],name:"I"},ct:{refRange:[-.5,.5],name:"CT"},cp:{refRange:[-.5,.5],name:"CP"}},base:he,fromBase:e=>function(e){let r=e.map((function(e){return((Ee+Le*(e/1e4)**Ne)/(1+Ae*(e/1e4)**Ne))**Ie}));return t(Oe,r)}(t(De,e)),toBase(e){let r=function(e){let r=t(ze,e),a=r.map((function(e){return 1e4*(Math.max(e**ke-Ee,0)/(Le-Ae*e**ke))**Pe}));return a}(e);return t(je,r)}});const He=R.D65,$e=.42,qe=1/$e,We=2*Math.PI,Ge=[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],Fe=[[1.8620678550872327,-1.0112546305316843,.14918677544445175],[.38752654323613717,.6214474419314753,-.008973985167612518],[-.015841498849333856,-.03412293802851557,1.0499644368778496]],Xe=[[460,451,288],[460,-891,-261],[460,-220,-6300]],Ye={dark:[.8,.525,.8],dim:[.9,.59,.9],average:[1,.69,1]},Ze={h:[20.14,90,164.25,237.53,380.14],e:[.8,.7,1,1.2,.8],H:[0,100,200,300,400]},Ue=180/Math.PI,Je=Math.PI/180;function Qe(e,t){const r=e.map((e=>{const r=b(t*Math.abs(e)*.01,$e);return 400*g(r,e)/(r+27.13)}));return r}function Ke(e,r,a,n,o){const s={};s.discounting=o,s.refWhite=e,s.surround=n;const i=e.map((e=>100*e));s.la=r,s.yb=a;const c=i[1],l=t(Ge,i),h=(n=Ye[s.surround])[0];s.c=n[1],s.nc=n[2];const d=(1/(5*s.la+1))**4;s.fl=d*s.la+.1*(1-d)*(1-d)*Math.cbrt(5*s.la),s.flRoot=s.fl**.25,s.n=s.yb/c,s.z=1.48+Math.sqrt(s.n),s.nbb=.725*s.n**-.2,s.ncb=s.nbb;const m=Math.max(Math.min(h*(1-1/3.6*Math.exp((-s.la-42)/92)),1),0);s.dRgb=l.map((e=>u(1,c/e,m))),s.dRgbInv=s.dRgb.map((e=>1/e));const p=l.map(((e,t)=>e*s.dRgb[t])),f=Qe(p,s.fl);return s.aW=s.nbb*(2*f[0]+f[1]+.05*f[2]),s}const Ve=Ke(He,64/Math.PI*.2,20,"average",!1);function et(e,r){if(!(void 0!==e.J^void 0!==e.Q))throw new Error("Conversion requires one and only one: 'J' or 'Q'");if(!(void 0!==e.C^void 0!==e.M^void 0!==e.s))throw new Error("Conversion requires one and only one: 'C', 'M' or 's'");if(!(void 0!==e.h^void 0!==e.H))throw new Error("Conversion requires one and only one: 'h' or 'H'");if(0===e.J||0===e.Q)return[0,0,0];let a=0;a=void 0!==e.h?F(e.h)*Je:function(e){let t=(e%400+400)%400;const r=Math.floor(.01*t);t%=100;const[a,n]=Ze.h.slice(r,r+2),[o,s]=Ze.e.slice(r,r+2);return F((t*(s*a-o*n)-100*a*s)/(t*(s-o)-100*s))}(e.H)*Je;const n=Math.cos(a),o=Math.sin(a);let s=0;void 0!==e.J?s=.1*b(e.J,.5):void 0!==e.Q&&(s=.25*r.c*e.Q/((r.aW+4)*r.flRoot));let i=0;void 0!==e.C?i=e.C/s:void 0!==e.M?i=e.M/r.flRoot/s:void 0!==e.s&&(i=4e-4*e.s**2*(r.aW+4)/r.c);const c=b(i*Math.pow(1.64-Math.pow(.29,r.n),-.73),10/9),l=.25*(Math.cos(a+2)+3.8),h=r.aW*b(s,2/r.c/r.z),u=5e4/13*r.nc*r.ncb*l,d=h/r.nbb,m=23*(d+.305)*M(c,23*u+c*(11*n+108*o)),p=function(e,t){const r=100/t*27.13**qe;return e.map((e=>{const t=Math.abs(e);return g(r*b(t/(400-t),qe),e)}))}(t(Xe,[d,m*n,m*o]).map((e=>1*e/1403)),r.fl);return t(Fe,p.map(((e,t)=>e*r.dRgbInv[t]))).map((e=>e/100))}function tt(e,r){const a=e.map((e=>100*e)),n=Qe(t(Ge,a).map(((e,t)=>e*r.dRgb[t])),r.fl),o=n[0]+(-12*n[1]+n[2])/11,s=(n[0]+n[1]-2*n[2])/9,i=(Math.atan2(s,o)%We+We)%We,c=.25*(Math.cos(i+2)+3.8),l=b(5e4/13*r.nc*r.ncb*M(c*Math.sqrt(o**2+s**2),n[0]+n[1]+1.05*n[2]+.305),.9)*Math.pow(1.64-Math.pow(.29,r.n),.73),h=b(r.nbb*(2*n[0]+n[1]+.05*n[2])/r.aW,.5*r.c*r.z),u=100*b(h,2),d=4/r.c*h*(r.aW+4)*r.flRoot,m=l*h,p=m*r.flRoot,f=F(i*Ue),g=function(e){let t=F(e);t<=Ze.h[0]&&(t+=360);const r=w(Ze.h,t)-1,[a,n]=Ze.h.slice(r,r+2),[o,s]=Ze.e.slice(r,r+2),i=(t-a)/o;return Ze.H[r]+100*i/(i+(n-t)/s)}(f);return{J:u,C:m,h:f,s:50*b(r.c*l/(r.aW+4),.5),Q:d,M:p,H:g}}var rt=new A({id:"cam16-jmh",cssId:"--cam16-jmh",name:"CAM16-JMh",coords:{j:{refRange:[0,100],name:"J"},m:{refRange:[0,105],name:"Colorfulness"},h:{refRange:[0,360],type:"angle",name:"Hue"}},base:P,fromBase(e){const t=tt(e,Ve);return[t.J,t.M,t.h]},toBase:e=>et({J:e[0],M:e[1],h:e[2]},Ve)});const at=R.D65,nt=216/24389,ot=24389/27;function st(e){return e>8?Math.pow((e+16)/116,3):e/ot}function it(e,t){const r=116*((a=e[1])>nt?Math.cbrt(a):(ot*a+16)/116)-16;var a;if(0===r)return[0,0,0];const n=tt(e,ct);return[F(n.h),n.C,r]}const ct=Ke(at,200/Math.PI*st(50),100*st(50),"average",!1);var lt=new A({id:"hct",name:"HCT",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},c:{refRange:[0,145],name:"Colorfulness"},t:{refRange:[0,100],name:"Tone"}},base:P,fromBase:e=>it(e),toBase:e=>function(e,t){let[r,a,n]=e,o=[],s=0;if(0===n)return[0,0,0];let i=st(n);s=n>0?.00379058511492914*n**2+.608983189401032*n+.9155088574762233:9514440756550361e-21*n**2+.08693057439788597*n-21.928975842194614;let c=0,l=1/0;for(;c<=15;){o=et({J:s,C:a,h:r},t);const e=Math.abs(o[1]-i);if(e<l){if(e<=2e-12)return o;l=e}s-=(o[1]-i)*s/(2*o[1]),c+=1}return et({J:s,C:a,h:r},t)}(e,ct),formats:{color:{id:"--hct",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});const ht=Math.PI/180,ut=[1,.007,.0228];function dt(e){e[1]<0&&(e=lt.fromBase(lt.toBase(e)));const t=Math.log(Math.max(1+ut[2]*e[1]*ct.flRoot,1))/ut[2],r=e[0]*ht,a=t*Math.cos(r),n=t*Math.sin(r);return[e[2],a,n]}var mt={deltaE76:function(e,t){return ce(e,t,"lab")},deltaECMC:function(e,t,{l:r=2,c:a=1}={}){[e,t]=L([e,t]);let[n,o,s]=G.from(e),[,i,c]=X.from(G,[n,o,s]),[l,h,u]=G.from(t),d=X.from(G,[l,h,u])[1];i<0&&(i=0),d<0&&(d=0);let m=n-l,p=i-d,f=(o-h)**2+(s-u)**2-p**2,g=.511;n>=16&&(g=.040975*n/(1+.01765*n));let b,M=.0638*i/(1+.0131*i)+.638;Number.isNaN(c)&&(c=0),b=c>=164&&c<=345?.56+Math.abs(.2*Math.cos((c+168)*le)):.36+Math.abs(.4*Math.cos((c+35)*le));let w=Math.pow(i,4),y=Math.sqrt(w/(w+1900)),C=(m/(r*g))**2;return C+=(p/(a*M))**2,C+=f/(M*(y*b+1-y))**2,Math.sqrt(C)},deltaE2000:K,deltaEJz:function(e,t){[e,t]=L([e,t]);let[r,a,n]=Be.from(e),[o,s,i]=Be.from(t),c=r-o,l=a-s;Number.isNaN(n)&&Number.isNaN(i)?(n=0,i=0):Number.isNaN(n)?n=i:Number.isNaN(i)&&(i=n);let h=n-i,u=2*Math.sqrt(a*s)*Math.sin(h/2*(Math.PI/180));return Math.sqrt(c**2+l**2+u**2)},deltaEITP:function(e,t){[e,t]=L([e,t]);let[r,a,n]=Te.from(e),[o,s,i]=Te.from(t);return 720*Math.sqrt((r-o)**2+.25*(a-s)**2+(n-i)**2)},deltaEOK:ne,deltaEHCT:function(e,t){[e,t]=L([e,t]);let[r,a,n]=dt(lt.from(e)),[o,s,i]=dt(lt.from(t));return Math.sqrt((r-o)**2+(a-s)**2+(n-i)**2)}};const pt={hct:{method:"hct.c",jnd:2,deltaEMethod:"hct",blackWhiteClamp:{}},"hct-tonal":{method:"hct.c",jnd:0,deltaEMethod:"hct",blackWhiteClamp:{channel:"hct.t",min:0,max:100}}};function ft(e,{method:t=v.gamut_mapping,space:a,deltaEMethod:n="",jnd:s=2,blackWhiteClamp:i={}}={}){if(e=L(e),r(arguments[1])?a=arguments[1]:a||(a=e.space),se(e,a=A.get(a),{epsilon:0}))return e;let c;if("css"===t)c=function(e,{space:t}={}){const r=.02,a=1e-4;e=L(e),t||(t=e.space);t=A.get(t);const n=A.get("oklch");if(t.isUnbounded)return bt(e,t);const o=bt(e,n);let s=o.coords[0];if(s>=1){const r=bt(gt.WHITE,t);return r.alpha=e.alpha,bt(r,t)}if(s<=0){const r=bt(gt.BLACK,t);return r.alpha=e.alpha,bt(r,t)}if(se(o,t,{epsilon:0}))return bt(o,t);function i(e){const r=bt(e,t),a=Object.values(t.coords);return r.coords=r.coords.map(((e,t)=>{if("range"in a[t]){const[r,n]=a[t].range;return f(r,e,n)}return e})),r}let c=0,l=o.coords[1],h=!0,u=ie(o),d=i(u),m=ne(d,u);if(m<r)return d;for(;l-c>a;){const e=(c+l)/2;if(u.coords[1]=e,h&&se(u,t,{epsilon:0}))c=e;else if(d=i(u),m=ne(d,u),m<r){if(r-m<a)break;h=!1,c=e}else l=e}return d}(e,{space:a});else{if("clip"===t||se(e,a))c=bt(e,a);else{Object.prototype.hasOwnProperty.call(pt,t)&&({method:t,jnd:s,deltaEMethod:n,blackWhiteClamp:i}=pt[t]);let r=K;if(""!==n)for(let e in mt)if("deltae"+n.toLowerCase()===e.toLowerCase()){r=mt[e];break}let l=ft(bt(e,a),{method:"clip",space:a});if(r(e,l)>s){if(3===Object.keys(i).length){let t=A.resolveCoord(i.channel),r=O(bt(e,t.space),t.id);if(o(r)&&(r=0),r>=i.max)return bt({space:"xyz-d65",coords:R.D65},e.space);if(r<=i.min)return bt({space:"xyz-d65",coords:[0,0,0]},e.space)}let n=A.resolveCoord(t),l=n.space,h=n.id,u=bt(e,l);u.coords.forEach(((e,t)=>{o(e)&&(u.coords[t]=0)}));let d=(n.range||n.refRange)[0],m=function(e){const t=e?Math.floor(Math.log10(Math.abs(e))):0;return Math.max(parseFloat("1e"+(t-2)),1e-6)}(s),p=d,f=O(u,h);for(;f-p>m;){let e=ie(u);e=ft(e,{space:a,method:"clip"}),r(u,e)-s<m?p=O(u,h):f=O(u,h),j(u,h,(p+f)/2)}c=bt(u,a)}else c=l}if("clip"===t||!se(c,a,{epsilon:0})){let e=Object.values(a.coords).map((e=>e.range||[]));c.coords=c.coords.map(((t,r)=>{let[a,n]=e[r];return void 0!==a&&(t=Math.max(a,t)),void 0!==n&&(t=Math.min(t,n)),t}))}}return a!==e.space&&(c=bt(c,e.space)),e.coords=c.coords,e}ft.returns="color";const gt={WHITE:{space:ae,coords:[1,0,0]},BLACK:{space:ae,coords:[0,0,0]}};function bt(e,t,{inGamut:r}={}){e=L(e);let a=(t=A.get(t)).from(e),n={space:t,coords:a,alpha:e.alpha};return r&&(n=ft(n,!0===r?void 0:r)),n}function Mt(e,{precision:t=v.precision,format:r="default",inGamut:a=!0,...o}={}){let s,i=r;r=(e=L(e)).space.getFormat(r)??e.space.getFormat("default")??A.DEFAULT_FORMAT;let c=e.coords.slice();if(a||=r.toGamut,a&&!se(e)&&(c=ft(ie(e),!0===a?void 0:a).coords),"custom"===r.type){if(o.precision=t,!r.serialize)throw new TypeError(`format ${i} can only be used to parse colors, not for serialization`);s=r.serialize(c,e.alpha,o)}else{let a=r.name||"color";r.serializeCoords?c=r.serializeCoords(c,t):null!==t&&(c=c.map((e=>n(e,{precision:t}))));let o=[...c];if("color"===a){let t=r.id||r.ids?.[0]||e.space.id;o.unshift(t)}let i=e.alpha;null!==t&&(i=n(i,{precision:t}));let l=e.alpha>=1||r.noAlpha?"":`${r.commas?",":" /"} ${i}`;s=`${a}(${o.join(r.commas?", ":" ")}${l})`}return s}bt.returns="color";var wt=new k({id:"rec2020-linear",cssId:"--rec2020-linear",name:"Linear REC.2020",white:"D65",toXYZ_M:[[.6369580483012914,.14461690358620832,.1688809751641721],[.2627002120112671,.6779980715188708,.05930171646986196],[0,.028072693049087428,1.060985057710791]],fromXYZ_M:[[1.716651187971268,-.355670783776392,-.25336628137366],[-.666684351832489,1.616481236634939,.0157685458139111],[.017639857445311,-.042770613257809,.942103121235474]]});const yt=1.09929682680944,Ct=.018053968510807;var vt=new k({id:"rec2020",name:"REC.2020",base:wt,toBase:e=>e.map((function(e){return e<4.5*Ct?e/4.5:Math.pow((e+yt-1)/yt,1/.45)})),fromBase:e=>e.map((function(e){return e>=Ct?yt*Math.pow(e,.45)-(yt-1):4.5*e}))});var Rt=new k({id:"p3-linear",cssId:"--display-p3-linear",name:"Linear P3",white:"D65",toXYZ_M:[[.4865709486482162,.26566769316909306,.1982172852343625],[.2289745640697488,.6917385218365064,.079286914093745],[0,.04511338185890264,1.043944368900976]],fromXYZ_M:[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]]});const _t=[[3.2409699419045226,-1.537383177570094,-.4986107602930034],[-.9692436362808796,1.8759675015077202,.04155505740717559],[.05563007969699366,-.20397695888897652,1.0569715142428786]];var St=new k({id:"srgb-linear",name:"Linear sRGB",white:"D65",toXYZ_M:[[.41239079926595934,.357584339383878,.1804807884018343],[.21263900587151027,.715168678767756,.07219231536073371],[.01933081871559182,.11919477979462598,.9505321522496607]],fromXYZ_M:_t}),xt={aliceblue:[240/255,248/255,1],antiquewhite:[250/255,235/255,215/255],aqua:[0,1,1],aquamarine:[127/255,1,212/255],azure:[240/255,1,1],beige:[245/255,245/255,220/255],bisque:[1,228/255,196/255],black:[0,0,0],blanchedalmond:[1,235/255,205/255],blue:[0,0,1],blueviolet:[138/255,43/255,226/255],brown:[165/255,42/255,42/255],burlywood:[222/255,184/255,135/255],cadetblue:[95/255,158/255,160/255],chartreuse:[127/255,1,0],chocolate:[210/255,105/255,30/255],coral:[1,127/255,80/255],cornflowerblue:[100/255,149/255,237/255],cornsilk:[1,248/255,220/255],crimson:[220/255,20/255,60/255],cyan:[0,1,1],darkblue:[0,0,139/255],darkcyan:[0,139/255,139/255],darkgoldenrod:[184/255,134/255,11/255],darkgray:[169/255,169/255,169/255],darkgreen:[0,100/255,0],darkgrey:[169/255,169/255,169/255],darkkhaki:[189/255,183/255,107/255],darkmagenta:[139/255,0,139/255],darkolivegreen:[85/255,107/255,47/255],darkorange:[1,140/255,0],darkorchid:[.6,50/255,.8],darkred:[139/255,0,0],darksalmon:[233/255,150/255,122/255],darkseagreen:[143/255,188/255,143/255],darkslateblue:[72/255,61/255,139/255],darkslategray:[47/255,79/255,79/255],darkslategrey:[47/255,79/255,79/255],darkturquoise:[0,206/255,209/255],darkviolet:[148/255,0,211/255],deeppink:[1,20/255,147/255],deepskyblue:[0,191/255,1],dimgray:[105/255,105/255,105/255],dimgrey:[105/255,105/255,105/255],dodgerblue:[30/255,144/255,1],firebrick:[178/255,34/255,34/255],floralwhite:[1,250/255,240/255],forestgreen:[34/255,139/255,34/255],fuchsia:[1,0,1],gainsboro:[220/255,220/255,220/255],ghostwhite:[248/255,248/255,1],gold:[1,215/255,0],goldenrod:[218/255,165/255,32/255],gray:[128/255,128/255,128/255],green:[0,128/255,0],greenyellow:[173/255,1,47/255],grey:[128/255,128/255,128/255],honeydew:[240/255,1,240/255],hotpink:[1,105/255,180/255],indianred:[205/255,92/255,92/255],indigo:[75/255,0,130/255],ivory:[1,1,240/255],khaki:[240/255,230/255,140/255],lavender:[230/255,230/255,250/255],lavenderblush:[1,240/255,245/255],lawngreen:[124/255,252/255,0],lemonchiffon:[1,250/255,205/255],lightblue:[173/255,216/255,230/255],lightcoral:[240/255,128/255,128/255],lightcyan:[224/255,1,1],lightgoldenrodyellow:[250/255,250/255,210/255],lightgray:[211/255,211/255,211/255],lightgreen:[144/255,238/255,144/255],lightgrey:[211/255,211/255,211/255],lightpink:[1,182/255,193/255],lightsalmon:[1,160/255,122/255],lightseagreen:[32/255,178/255,170/255],lightskyblue:[135/255,206/255,250/255],lightslategray:[119/255,136/255,.6],lightslategrey:[119/255,136/255,.6],lightsteelblue:[176/255,196/255,222/255],lightyellow:[1,1,224/255],lime:[0,1,0],limegreen:[50/255,205/255,50/255],linen:[250/255,240/255,230/255],magenta:[1,0,1],maroon:[128/255,0,0],mediumaquamarine:[.4,205/255,170/255],mediumblue:[0,0,205/255],mediumorchid:[186/255,85/255,211/255],mediumpurple:[147/255,112/255,219/255],mediumseagreen:[60/255,179/255,113/255],mediumslateblue:[123/255,104/255,238/255],mediumspringgreen:[0,250/255,154/255],mediumturquoise:[72/255,209/255,.8],mediumvioletred:[199/255,21/255,133/255],midnightblue:[25/255,25/255,112/255],mintcream:[245/255,1,250/255],mistyrose:[1,228/255,225/255],moccasin:[1,228/255,181/255],navajowhite:[1,222/255,173/255],navy:[0,0,128/255],oldlace:[253/255,245/255,230/255],olive:[128/255,128/255,0],olivedrab:[107/255,142/255,35/255],orange:[1,165/255,0],orangered:[1,69/255,0],orchid:[218/255,112/255,214/255],palegoldenrod:[238/255,232/255,170/255],palegreen:[152/255,251/255,152/255],paleturquoise:[175/255,238/255,238/255],palevioletred:[219/255,112/255,147/255],papayawhip:[1,239/255,213/255],peachpuff:[1,218/255,185/255],peru:[205/255,133/255,63/255],pink:[1,192/255,203/255],plum:[221/255,160/255,221/255],powderblue:[176/255,224/255,230/255],purple:[128/255,0,128/255],rebeccapurple:[.4,.2,.6],red:[1,0,0],rosybrown:[188/255,143/255,143/255],royalblue:[65/255,105/255,225/255],saddlebrown:[139/255,69/255,19/255],salmon:[250/255,128/255,114/255],sandybrown:[244/255,164/255,96/255],seagreen:[46/255,139/255,87/255],seashell:[1,245/255,238/255],sienna:[160/255,82/255,45/255],silver:[192/255,192/255,192/255],skyblue:[135/255,206/255,235/255],slateblue:[106/255,90/255,205/255],slategray:[112/255,128/255,144/255],slategrey:[112/255,128/255,144/255],snow:[1,250/255,250/255],springgreen:[0,1,127/255],steelblue:[70/255,130/255,180/255],tan:[210/255,180/255,140/255],teal:[0,128/255,128/255],thistle:[216/255,191/255,216/255],tomato:[1,99/255,71/255],turquoise:[64/255,224/255,208/255],violet:[238/255,130/255,238/255],wheat:[245/255,222/255,179/255],white:[1,1,1],whitesmoke:[245/255,245/255,245/255],yellow:[1,1,0],yellowgreen:[154/255,205/255,50/255]};let Bt=Array(3).fill("<percentage> | <number>[0, 255]"),Et=Array(3).fill("<number>[0, 255]");var Lt=new k({id:"srgb",name:"sRGB",base:St,fromBase:e=>e.map((e=>{let t=e<0?-1:1,r=e*t;return r>.0031308?t*(1.055*r**(1/2.4)-.055):12.92*e})),toBase:e=>e.map((e=>{let t=e<0?-1:1,r=e*t;return r<=.04045?e/12.92:t*((r+.055)/1.055)**2.4})),formats:{rgb:{coords:Bt},rgb_number:{name:"rgb",commas:!0,coords:Et,noAlpha:!0},color:{},rgba:{coords:Bt,commas:!0,lastAlpha:!0},rgba_number:{name:"rgba",commas:!0,coords:Et},hex:{type:"custom",toGamut:!0,test:e=>/^#([a-f0-9]{3,4}){1,2}$/i.test(e),parse(e){e.length<=5&&(e=e.replace(/[a-f0-9]/gi,"$&$&"));let t=[];return e.replace(/[a-f0-9]{2}/gi,(e=>{t.push(parseInt(e,16)/255)})),{spaceId:"srgb",coords:t.slice(0,3),alpha:t.slice(3)[0]}},serialize:(e,t,{collapse:r=!0}={})=>{t<1&&e.push(t),e=e.map((e=>Math.round(255*e)));let a=r&&e.every((e=>e%17==0)),n=e.map((e=>a?(e/17).toString(16):e.toString(16).padStart(2,"0"))).join("");return"#"+n}},keyword:{type:"custom",test:e=>/^[a-z]+$/i.test(e),parse(e){let t={spaceId:"srgb",coords:null,alpha:1};if("transparent"===(e=e.toLowerCase())?(t.coords=xt.black,t.alpha=0):t.coords=xt[e],t.coords)return t}}}}),At=new k({id:"p3",cssId:"display-p3",name:"P3",base:Rt,fromBase:Lt.fromBase,toBase:Lt.toBase});let Nt;if(v.display_space=Lt,"undefined"!=typeof CSS&&CSS.supports)for(let e of[G,vt,At]){let t=e.getMinCoords(),r=Mt({space:e,coords:t,alpha:1});if(CSS.supports("color",r)){v.display_space=e;break}}function It(e){return O(e,[P,"y"])}function Pt(e,t){j(e,[P,"y"],t)}var kt=Object.freeze({__proto__:null,getLuminance:It,register:function(e){Object.defineProperty(e.prototype,"luminance",{get(){return It(this)},set(e){Pt(this,e)}})},setLuminance:Pt});const Dt=.022,Ot=1.414;function zt(e){return e>=Dt?e:e+(Dt-e)**Ot}function jt(e){let t=e<0?-1:1,r=Math.abs(e);return t*Math.pow(r,2.4)}const Tt=216/24389,Ht=24/116,$t=24389/27;let qt=R.D65;var Wt=new A({id:"lab-d65",name:"Lab D65",coords:{l:{refRange:[0,100],name:"Lightness"},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:qt,base:P,fromBase(e){let t=e.map(((e,t)=>e/qt[t])).map((e=>e>Tt?Math.cbrt(e):($t*e+16)/116));return[116*t[1]-16,500*(t[0]-t[1]),200*(t[1]-t[2])]},toBase(e){let t=[];return t[1]=(e[0]+16)/116,t[0]=e[1]/500+t[1],t[2]=t[1]-e[2]/200,[t[0]>Ht?Math.pow(t[0],3):(116*t[0]-16)/$t,e[0]>8?Math.pow((e[0]+16)/116,3):e[0]/$t,t[2]>Ht?Math.pow(t[2],3):(116*t[2]-16)/$t].map(((e,t)=>e*qt[t]))},formats:{"lab-d65":{coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}});const Gt=.5*Math.pow(5,.5)+.5;var Ft=Object.freeze({__proto__:null,contrastAPCA:function(e,t){let r,a,n,o,s,i;t=L(t),e=L(e),t=bt(t,"srgb"),[o,s,i]=t.coords;let c=.2126729*jt(o)+.7151522*jt(s)+.072175*jt(i);e=bt(e,"srgb"),[o,s,i]=e.coords;let l=.2126729*jt(o)+.7151522*jt(s)+.072175*jt(i),h=zt(c),u=zt(l),d=u>h;return Math.abs(u-h)<5e-4?a=0:d?(r=u**.56-h**.57,a=1.14*r):(r=u**.65-h**.62,a=1.14*r),n=Math.abs(a)<.1?0:a>0?a-.027:a+.027,100*n},contrastDeltaPhi:function(e,t){e=L(e),t=L(t);let r=O(e,[Wt,"l"]),a=O(t,[Wt,"l"]),n=Math.abs(Math.pow(r,Gt)-Math.pow(a,Gt)),o=Math.pow(n,1/Gt)*Math.SQRT2-40;return o<7.5?0:o},contrastLstar:function(e,t){e=L(e),t=L(t);let r=O(e,[G,"l"]),a=O(t,[G,"l"]);return Math.abs(r-a)},contrastMichelson:function(e,t){e=L(e),t=L(t);let r=Math.max(It(e),0),a=Math.max(It(t),0);a>r&&([r,a]=[a,r]);let n=r+a;return 0===n?0:(r-a)/n},contrastWCAG21:function(e,t){e=L(e),t=L(t);let r=Math.max(It(e),0),a=Math.max(It(t),0);return a>r&&([r,a]=[a,r]),(r+.05)/(a+.05)},contrastWeber:function(e,t){e=L(e),t=L(t);let r=Math.max(It(e),0),a=Math.max(It(t),0);return a>r&&([r,a]=[a,r]),0===a?5e4:(r-a)/a}});function Xt(e){let[t,r,a]=D(e,P),n=t+15*r+3*a;return[4*t/n,9*r/n]}function Yt(e){let[t,r,a]=D(e,P),n=t+r+a;return[t/n,r/n]}var Zt=Object.freeze({__proto__:null,register:function(e){Object.defineProperty(e.prototype,"uv",{get(){return Xt(this)}}),Object.defineProperty(e.prototype,"xy",{get(){return Yt(this)}})},uv:Xt,xy:Yt});function Ut(e,t,a={}){r(a)&&(a={method:a});let{method:n=v.deltaE,...o}=a;for(let r in mt)if("deltae"+n.toLowerCase()===r.toLowerCase())return mt[r](e,t,o);throw new TypeError(`Unknown deltaE method: ${n}`)}var Jt=Object.freeze({__proto__:null,darken:function(e,t=.25){return j(e,[A.get("oklch","lch"),"l"],(e=>e*(1-t)))},lighten:function(e,t=.25){return j(e,[A.get("oklch","lch"),"l"],(e=>e*(1+t)))}});function Qt(e,t,r=.5,n={}){return[e,t]=[L(e),L(t)],"object"===a(r)&&([r,n]=[.5,r]),Vt(e,t,n)(r)}function Kt(e,t,r={}){let a;er(e)&&([a,r]=[e,t],[e,t]=a.rangeArgs.colors);let{maxDeltaE:n,deltaEMethod:o,steps:s=2,maxSteps:i=1e3,...c}=r;a||([e,t]=[L(e),L(t)],a=Vt(e,t,c));let l=Ut(e,t),h=n>0?Math.max(s,Math.ceil(l/n)+1):s,u=[];if(void 0!==i&&(h=Math.min(h,i)),1===h)u=[{p:.5,color:a(.5)}];else{let e=1/(h-1);u=Array.from({length:h},((t,r)=>{let n=r*e;return{p:n,color:a(n)}}))}if(n>0){let e=u.reduce(((e,t,r)=>{if(0===r)return 0;let a=Ut(t.color,u[r-1].color,o);return Math.max(e,a)}),0);for(;e>n;){e=0;for(let t=1;t<u.length&&u.length<i;t++){let r=u[t-1],n=u[t],o=(n.p+r.p)/2,s=a(o);e=Math.max(e,Ut(s,r.color),Ut(s,n.color)),u.splice(t,0,{p:o,color:a(o)}),t++}}}return u=u.map((e=>e.color)),u}function Vt(e,t,r={}){if(er(e)){let[r,a]=[e,t];return Vt(...r.rangeArgs.colors,{...r.rangeArgs.options,...a})}let{space:a,outputSpace:n,progression:o,premultiplied:s}=r;e=L(e),t=L(t),e=ie(e),t=ie(t);let i={colors:[e,t],options:r};if(a=a?A.get(a):A.registry[v.interpolationSpace]||e.space,n=n?A.get(n):a,e=bt(e,a),t=bt(t,a),e=ft(e),t=ft(t),a.coords.h&&"angle"===a.coords.h.type){let n=r.hue=r.hue||"shorter",o=[a,"h"],[s,i]=[O(e,o),O(t,o)];isNaN(s)&&!isNaN(i)?s=i:isNaN(i)&&!isNaN(s)&&(i=s),[s,i]=function(e,t){if("raw"===e)return t;let[r,a]=t.map(F),n=a-r;return"increasing"===e?n<0&&(a+=360):"decreasing"===e?n>0&&(r+=360):"longer"===e?-180<n&&n<180&&(n>0?r+=360:a+=360):"shorter"===e&&(n>180?r+=360:n<-180&&(a+=360)),[r,a]}(n,[s,i]),j(e,o,s),j(t,o,i)}return s&&(e.coords=e.coords.map((t=>t*e.alpha)),t.coords=t.coords.map((e=>e*t.alpha))),Object.assign((r=>{r=o?o(r):r;let i=e.coords.map(((e,a)=>u(e,t.coords[a],r))),c=u(e.alpha,t.alpha,r),l={space:a,coords:i,alpha:c};return s&&(l.coords=l.coords.map((e=>e/c))),n!==a&&(l=bt(l,n)),l}),{rangeArgs:i})}function er(e){return"function"===a(e)&&!!e.rangeArgs}v.interpolationSpace="lab";var tr=Object.freeze({__proto__:null,isRange:er,mix:Qt,range:Vt,register:function(e){e.defineFunction("mix",Qt,{returns:"color"}),e.defineFunction("range",Vt,{returns:"function<color>"}),e.defineFunction("steps",Kt,{returns:"array<color>"})},steps:Kt}),rr=new A({id:"hsl",name:"HSL",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},s:{range:[0,100],name:"Saturation"},l:{range:[0,100],name:"Lightness"}},base:Lt,fromBase:e=>{let t=Math.max(...e),r=Math.min(...e),[a,n,o]=e,[s,i,c]=[NaN,0,(r+t)/2],l=t-r;if(0!==l){switch(i=0===c||1===c?0:(t-c)/Math.min(c,1-c),t){case a:s=(n-o)/l+(n<o?6:0);break;case n:s=(o-a)/l+2;break;case o:s=(a-n)/l+4}s*=60}return i<0&&(s+=180,i=Math.abs(i)),s>=360&&(s-=360),[s,100*i,100*c]},toBase:e=>{let[t,r,a]=e;function n(e){let n=(e+t/30)%12,o=r*Math.min(a,1-a);return a-o*Math.max(-1,Math.min(n-3,9-n,1))}return t%=360,t<0&&(t+=360),r/=100,a/=100,[n(0),n(8),n(4)]},formats:{hsl:{coords:["<number> | <angle>","<percentage>","<percentage>"]},hsla:{coords:["<number> | <angle>","<percentage>","<percentage>"],commas:!0,lastAlpha:!0}}}),ar=new A({id:"hsv",name:"HSV",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},s:{range:[0,100],name:"Saturation"},v:{range:[0,100],name:"Value"}},base:rr,fromBase(e){let[t,r,a]=e;r/=100,a/=100;let n=a+r*Math.min(a,1-a);return[t,0===n?0:200*(1-a/n),100*n]},toBase(e){let[t,r,a]=e;r/=100,a/=100;let n=a*(1-r/2);return[t,0===n||1===n?0:(a-n)/Math.min(n,1-n)*100,100*n]},formats:{color:{id:"--hsv",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}}),nr=new A({id:"hwb",name:"HWB",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},w:{range:[0,100],name:"Whiteness"},b:{range:[0,100],name:"Blackness"}},base:ar,fromBase(e){let[t,r,a]=e;return[t,a*(100-r)/100,100-a]},toBase(e){let[t,r,a]=e;r/=100,a/=100;let n=r+a;if(n>=1){return[t,0,100*(r/n)]}let o=1-a;return[t,100*(0===o?0:1-r/o),100*o]},formats:{hwb:{coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});var or=new k({id:"a98rgb-linear",cssId:"--a98-rgb-linear",name:"Linear Adobe® 98 RGB compatible",white:"D65",toXYZ_M:[[.5766690429101305,.1855582379065463,.1882286462349947],[.29734497525053605,.6273635662554661,.07529145849399788],[.02703136138641234,.07068885253582723,.9913375368376388]],fromXYZ_M:[[2.0415879038107465,-.5650069742788596,-.34473135077832956],[-.9692436362808795,1.8759675015077202,.04155505740717557],[.013444280632031142,-.11836239223101838,1.0151749943912054]]}),sr=new k({id:"a98rgb",cssId:"a98-rgb",name:"Adobe® 98 RGB compatible",base:or,toBase:e=>e.map((e=>Math.pow(Math.abs(e),563/256)*Math.sign(e))),fromBase:e=>e.map((e=>Math.pow(Math.abs(e),256/563)*Math.sign(e)))});var ir=new k({id:"prophoto-linear",cssId:"--prophoto-rgb-linear",name:"Linear ProPhoto",white:"D50",base:T,toXYZ_M:[[.7977666449006423,.13518129740053308,.0313477341283922],[.2880748288194013,.711835234241873,8993693872564e-17],[0,0,.8251046025104602]],fromXYZ_M:[[1.3457868816471583,-.25557208737979464,-.05110186497554526],[-.5446307051249019,1.5082477428451468,.02052744743642139],[0,0,1.2119675456389452]]});const cr=1/512;var lr=new k({id:"prophoto",cssId:"prophoto-rgb",name:"ProPhoto",base:ir,toBase:e=>e.map((e=>e<.03125?e/16:e**1.8)),fromBase:e=>e.map((e=>e>=cr?e**(1/1.8):16*e))}),hr=new A({id:"oklch",name:"Oklch",coords:{l:{refRange:[0,1],name:"Lightness"},c:{refRange:[0,.4],name:"Chroma"},h:{refRange:[0,360],type:"angle",name:"Hue"}},white:"D65",base:ae,fromBase(e){let t,[r,a,n]=e;const o=2e-4;return t=Math.abs(a)<o&&Math.abs(n)<o?NaN:180*Math.atan2(n,a)/Math.PI,[r,Math.sqrt(a**2+n**2),F(t)]},toBase(e){let t,r,[a,n,o]=e;return isNaN(o)?(t=0,r=0):(t=n*Math.cos(o*Math.PI/180),r=n*Math.sin(o*Math.PI/180)),[a,t,r]},formats:{oklch:{coords:["<percentage> | <number>","<number> | <percentage>[0,1]","<number> | <angle>"]}}});let ur=R.D65;const dr=216/24389,mr=24389/27,[pr,fr]=Xt({space:P,coords:ur});var gr=new A({id:"luv",name:"Luv",coords:{l:{refRange:[0,100],name:"Lightness"},u:{refRange:[-215,215]},v:{refRange:[-215,215]}},white:ur,base:P,fromBase(e){let t=[s(e[0]),s(e[1]),s(e[2])],r=t[1],[a,n]=Xt({space:P,coords:t});if(!Number.isFinite(a)||!Number.isFinite(n))return[0,0,0];let o=r<=dr?mr*r:116*Math.cbrt(r)-16;return[o,13*o*(a-pr),13*o*(n-fr)]},toBase(e){let[t,r,a]=e;if(0===t||o(t))return[0,0,0];r=s(r),a=s(a);let n=r/(13*t)+pr,i=a/(13*t)+fr,c=t<=8?t/mr:Math.pow((t+16)/116,3);return[c*(9*n/(4*i)),c,c*((12-3*n-20*i)/(4*i))]},formats:{color:{id:"--luv",coords:["<number> | <percentage>","<number> | <percentage>[-1,1]","<number> | <percentage>[-1,1]"]}}}),br=new A({id:"lchuv",name:"LChuv",coords:{l:{refRange:[0,100],name:"Lightness"},c:{refRange:[0,220],name:"Chroma"},h:{refRange:[0,360],type:"angle",name:"Hue"}},base:gr,fromBase(e){let t,[r,a,n]=e;return t=Math.abs(a)<.02&&Math.abs(n)<.02?NaN:180*Math.atan2(n,a)/Math.PI,[r,Math.sqrt(a**2+n**2),F(t)]},toBase(e){let[t,r,a]=e;return r<0&&(r=0),isNaN(a)&&(a=0),[t,r*Math.cos(a*Math.PI/180),r*Math.sin(a*Math.PI/180)]},formats:{color:{id:"--lchuv",coords:["<number> | <percentage>","<number> | <percentage>","<number> | <angle>"]}}});const Mr=216/24389,wr=24389/27,yr=_t[0][0],Cr=_t[0][1],vr=_t[0][2],Rr=_t[1][0],_r=_t[1][1],Sr=_t[1][2],xr=_t[2][0],Br=_t[2][1],Er=_t[2][2];function Lr(e,t,r){const a=t/(Math.sin(r)-e*Math.cos(r));return a<0?1/0:a}function Ar(e){const t=Math.pow(e+16,3)/1560896,r=t>Mr?t:e/wr,a=r*(284517*yr-94839*vr),n=r*(838422*vr+769860*Cr+731718*yr),o=r*(632260*vr-126452*Cr),s=r*(284517*Rr-94839*Sr),i=r*(838422*Sr+769860*_r+731718*Rr),c=r*(632260*Sr-126452*_r),l=r*(284517*xr-94839*Er),h=r*(838422*Er+769860*Br+731718*xr),u=r*(632260*Er-126452*Br);return{r0s:a/o,r0i:n*e/o,r1s:a/(o+126452),r1i:(n-769860)*e/(o+126452),g0s:s/c,g0i:i*e/c,g1s:s/(c+126452),g1i:(i-769860)*e/(c+126452),b0s:l/u,b0i:h*e/u,b1s:l/(u+126452),b1i:(h-769860)*e/(u+126452)}}function Nr(e,t){const r=t/360*Math.PI*2,a=Lr(e.r0s,e.r0i,r),n=Lr(e.r1s,e.r1i,r),o=Lr(e.g0s,e.g0i,r),s=Lr(e.g1s,e.g1i,r),i=Lr(e.b0s,e.b0i,r),c=Lr(e.b1s,e.b1i,r);return Math.min(a,n,o,s,i,c)}var Ir=new A({id:"hsluv",name:"HSLuv",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},s:{range:[0,100],name:"Saturation"},l:{range:[0,100],name:"Lightness"}},base:br,gamutSpace:Lt,fromBase(e){let t,[r,a,n]=[s(e[0]),s(e[1]),s(e[2])];if(r>99.9999999)t=0,r=100;else if(r<1e-8)t=0,r=0;else{t=a/Nr(Ar(r),n)*100}return[n,t,r]},toBase(e){let t,[r,a,n]=[s(e[0]),s(e[1]),s(e[2])];if(n>99.9999999)n=100,t=0;else if(n<1e-8)n=0,t=0;else{t=Nr(Ar(n),r)/100*a}return[n,t,r]},formats:{color:{id:"--hsluv",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});function Pr(e,t){return Math.abs(t)/Math.sqrt(Math.pow(e,2)+1)}function kr(e){let t=Pr(e.r0s,e.r0i),r=Pr(e.r1s,e.r1i),a=Pr(e.g0s,e.g0i),n=Pr(e.g1s,e.g1i),o=Pr(e.b0s,e.b0i),s=Pr(e.b1s,e.b1i);return Math.min(t,r,a,n,o,s)}_t[0][0],_t[0][1],_t[0][2],_t[1][0],_t[1][1],_t[1][2],_t[2][0],_t[2][1],_t[2][2];var Dr=new A({id:"hpluv",name:"HPLuv",coords:{h:{refRange:[0,360],type:"angle",name:"Hue"},s:{range:[0,100],name:"Saturation"},l:{range:[0,100],name:"Lightness"}},base:br,gamutSpace:"self",fromBase(e){let t,[r,a,n]=[s(e[0]),s(e[1]),s(e[2])];if(r>99.9999999)t=0,r=100;else if(r<1e-8)t=0,r=0;else{t=a/kr(Ar(r))*100}return[n,t,r]},toBase(e){let t,[r,a,n]=[s(e[0]),s(e[1]),s(e[2])];if(n>99.9999999)n=100,t=0;else if(n<1e-8)n=0,t=0;else{t=kr(Ar(n))/100*a}return[n,t,r]},formats:{color:{id:"--hpluv",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});const Or=2610/16384,zr=16384/2610,jr=32/2523,Tr=.8359375,Hr=2413/128,$r=18.6875;var qr=new k({id:"rec2100pq",cssId:"rec2100-pq",name:"REC.2100-PQ",base:wt,toBase:e=>e.map((function(e){return 1e4*(Math.max(e**jr-Tr,0)/(Hr-$r*e**jr))**zr/203})),fromBase:e=>e.map((function(e){let t=Math.max(203*e/1e4,0);return((Tr+Hr*t**Or)/(1+$r*t**Or))**78.84375}))});const Wr=.17883277,Gr=.28466892,Fr=.55991073,Xr=3.7743;var Yr=new k({id:"rec2100hlg",cssId:"rec2100-hlg",name:"REC.2100-HLG",referred:"scene",base:wt,toBase:e=>e.map((function(e){return e<=.5?e**2/3*Xr:(Math.exp((e-Fr)/Wr)+Gr)/12*Xr})),fromBase:e=>e.map((function(e){return(e/=Xr)<=1/12?Math.sqrt(3*e):Wr*Math.log(12*e-Gr)+Fr}))});const Zr={};function Ur({id:e,toCone_M:t,fromCone_M:r}){Zr[e]=arguments[0]}function Jr(e,r,a="Bradford"){let n=Zr[a],[o,s,i]=t(n.toCone_M,e),[c,l,h]=t(n.toCone_M,r),u=t([[c/o,0,0],[0,l/s,0],[0,0,h/i]],n.toCone_M);return t(n.fromCone_M,u)}C.add("chromatic-adaptation-start",(e=>{e.options.method&&(e.M=Jr(e.W1,e.W2,e.options.method))})),C.add("chromatic-adaptation-end",(e=>{e.M||(e.M=Jr(e.W1,e.W2,e.options.method))})),Ur({id:"von Kries",toCone_M:[[.40024,.7076,-.08081],[-.2263,1.16532,.0457],[0,0,.91822]],fromCone_M:[[1.8599363874558397,-1.1293816185800916,.21989740959619328],[.3611914362417676,.6388124632850422,-6370596838649899e-21],[0,0,1.0890636230968613]]}),Ur({id:"Bradford",toCone_M:[[.8951,.2664,-.1614],[-.7502,1.7135,.0367],[.0389,-.0685,1.0296]],fromCone_M:[[.9869929054667121,-.14705425642099013,.15996265166373122],[.4323052697233945,.5183602715367774,.049291228212855594],[-.00852866457517732,.04004282165408486,.96848669578755]]}),Ur({id:"CAT02",toCone_M:[[.7328,.4296,-.1624],[-.7036,1.6975,.0061],[.003,.0136,.9834]],fromCone_M:[[1.0961238208355142,-.27886900021828726,.18274517938277307],[.4543690419753592,.4735331543074117,.07209780371722911],[-.009627608738429355,-.00569803121611342,1.0153256399545427]]}),Ur({id:"CAT16",toCone_M:[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],fromCone_M:[[1.862067855087233,-1.0112546305316845,.14918677544445172],[.3875265432361372,.6214474419314753,-.008973985167612521],[-.01584149884933386,-.03412293802851557,1.0499644368778496]]}),Object.assign(R,{A:[1.0985,1,.35585],C:[.98074,1,1.18232],D55:[.95682,1,.92149],D75:[.94972,1,1.22638],E:[1,1,1],F2:[.99186,1,.67393],F7:[.95041,1,1.08747],F11:[1.00962,1,.6435]}),R.ACES=[.32168/.33767,1,.34065/.33767];var Qr=new k({id:"acescg",cssId:"--acescg",name:"ACEScg",coords:{r:{range:[0,65504],name:"Red"},g:{range:[0,65504],name:"Green"},b:{range:[0,65504],name:"Blue"}},referred:"scene",white:R.ACES,toXYZ_M:[[.6624541811085053,.13400420645643313,.1561876870049078],[.27222871678091454,.6740817658111484,.05368951740793705],[-.005574649490394108,.004060733528982826,1.0103391003129971]],fromXYZ_M:[[1.6410233796943257,-.32480329418479,-.23642469523761225],[-.6636628587229829,1.6153315916573379,.016756347685530137],[.011721894328375376,-.008284441996237409,.9883948585390215]]});const Kr=2**-16,Vr=-.35828683,ea=(Math.log2(65504)+9.72)/17.52;var ta=new k({id:"acescc",cssId:"--acescc",name:"ACEScc",coords:{r:{range:[Vr,ea],name:"Red"},g:{range:[Vr,ea],name:"Green"},b:{range:[Vr,ea],name:"Blue"}},referred:"scene",base:Qr,toBase:e=>e.map((function(e){return e<=-.3013698630136986?2*(2**(17.52*e-9.72)-Kr):e<ea?2**(17.52*e-9.72):65504})),fromBase:e=>e.map((function(e){return e<=0?(Math.log2(Kr)+9.72)/17.52:e<Kr?(Math.log2(Kr+.5*e)+9.72)/17.52:(Math.log2(e)+9.72)/17.52}))}),ra=Object.freeze({__proto__:null,A98RGB:sr,A98RGB_Linear:or,ACEScc:ta,ACEScg:Qr,CAM16_JMh:rt,HCT:lt,HPLuv:Dr,HSL:rr,HSLuv:Ir,HSV:ar,HWB:nr,ICTCP:Te,JzCzHz:Be,Jzazbz:xe,LCH:X,LCHuv:br,Lab:G,Lab_D65:Wt,Luv:gr,OKLCH:hr,OKLab:ae,P3:At,P3_Linear:Rt,ProPhoto:lr,ProPhoto_Linear:ir,REC_2020:vt,REC_2020_Linear:wt,REC_2100_HLG:Yr,REC_2100_PQ:qr,XYZ_ABS_D65:he,XYZ_D50:T,XYZ_D65:P,sRGB:Lt,sRGB_Linear:St});class aa{constructor(...e){let t,r,a,n;1===e.length&&(t=L(e[0])),t?(r=t.space||t.spaceId,a=t.coords,n=t.alpha):[r,a,n]=e,Object.defineProperty(this,"space",{value:A.get(r),writable:!1,enumerable:!0,configurable:!0}),this.coords=a?a.slice():[0,0,0],this.alpha=n>1||void 0===n?1:n<0?0:n;for(let e=0;e<this.coords.length;e++)"NaN"===this.coords[e]&&(this.coords[e]=NaN);for(let e in this.space.coords)Object.defineProperty(this,e,{get:()=>this.get(e),set:t=>this.set(e,t)})}get spaceId(){return this.space.id}clone(){return new aa(this.space,this.coords,this.alpha)}toJSON(){return{spaceId:this.spaceId,coords:this.coords,alpha:this.alpha}}display(...e){let t=function(e,{space:t=v.display_space,...r}={}){let a=Mt(e,r);if("undefined"==typeof CSS||CSS.supports("color",a)||!v.display_space)a=new String(a),a.color=e;else{let n=e;if((e.coords.some(o)||o(e.alpha))&&!(Nt??=CSS.supports("color","hsl(none 50% 50%)"))&&(n=ie(e),n.coords=n.coords.map(s),n.alpha=s(n.alpha),a=Mt(n,r),CSS.supports("color",a)))return a=new String(a),a.color=n,a;n=bt(n,t),a=new String(Mt(n,r)),a.color=n}return a}(this,...e);return t.color=new aa(t.color),t}static get(e,...t){return e instanceof aa?e:new aa(e,...t)}static defineFunction(e,t,r=t){let{instance:a=!0,returns:n}=r,o=function(...e){let r=t(...e);if("color"===n)r=aa.get(r);else if("function<color>"===n){let e=r;r=function(...t){let r=e(...t);return aa.get(r)},Object.assign(r,e)}else"array<color>"===n&&(r=r.map((e=>aa.get(e))));return r};e in aa||(aa[e]=o),a&&(aa.prototype[e]=function(...e){return o(this,...e)})}static defineFunctions(e){for(let t in e)aa.defineFunction(t,e[t],e[t])}static extend(e){if(e.register)e.register(aa);else for(let t in e)aa.defineFunction(t,e[t])}}aa.defineFunctions({get:O,getAll:D,set:j,setAll:z,to:bt,equals:function(e,t){return e=L(e),t=L(t),e.space===t.space&&e.alpha===t.alpha&&e.coords.every(((e,r)=>e===t.coords[r]))},inGamut:se,toGamut:ft,distance:ce,toString:Mt}),Object.assign(aa,{util:y,hooks:C,WHITES:R,Space:A,spaces:A.registry,parse:E,defaults:v});for(let e of Object.keys(ra))A.register(ra[e]);for(let e in A.registry)na(e,A.registry[e]);function na(e,t){let r=e.replace(/-/g,"_");Object.defineProperty(aa.prototype,r,{get(){let r=this.getAll(e);return"undefined"==typeof Proxy?r:new Proxy(r,{has:(e,r)=>{try{return A.resolveCoord([t,r]),!0}catch(e){}return Reflect.has(e,r)},get:(e,r,a)=>{if(r&&"symbol"!=typeof r&&!(r in e)){let{index:a}=A.resolveCoord([t,r]);if(a>=0)return e[a]}return Reflect.get(e,r,a)},set:(r,a,n,o)=>{if(a&&"symbol"!=typeof a&&!(a in r)||a>=0){let{index:o}=A.resolveCoord([t,a]);if(o>=0)return r[o]=n,this.setAll(e,r),!0}return Reflect.set(r,a,n,o)}})},set(t){this.setAll(e,t)},configurable:!0,enumerable:!0})}C.add("colorspace-init-end",(e=>{na(e.id,e),e.aliases?.forEach((t=>{na(t,e)}))})),aa.extend(mt),aa.extend({deltaE:Ut}),Object.assign(aa,{deltaEMethods:mt}),aa.extend(Jt),aa.extend({contrast:function(e,t,a={}){r(a)&&(a={algorithm:a});let{algorithm:n,...o}=a;if(!n){let e=Object.keys(Ft).map((e=>e.replace(/^contrast/,""))).join(", ");throw new TypeError(`contrast() function needs a contrast algorithm. Please specify one of: ${e}`)}e=L(e),t=L(t);for(let r in Ft)if("contrast"+n.toLowerCase()===r.toLowerCase())return Ft[r](e,t,o);throw new TypeError(`Unknown contrast algorithm: ${n}`)}}),aa.extend(Zt),aa.extend(kt),aa.extend(tr),aa.extend(Ft);class oa{constructor(e,t,r){this.colorSpace=null==r?oa.DEFAULT_COLORSPACE:r,this.height=t,this.width=e,this.data=new Uint16Array(t*e*4)}fill(e){if(4==e.length){for(let t=0;t<this.data.length;t+=4)this.data[t]=e[0],this.data[t+1]=e[1],this.data[t+2]=e[2],this.data[t+3]=e[3];return this}}getPixel(e,t){const r=4*(t*this.width+e);return this.data.slice(r,r+4)}setPixel(e,t,r){const a=4*(t*this.width+e);this.data[a+0]=r[0],this.data[a+1]=r[1],this.data[a+2]=r[2],this.data[a+3]=r[3]}static scaleUint8ToUint16(e){return e<<8|e}getImageData(){return void 0===this.data||null===this.data?null:new ImageData(this.data,this.width,this.height,{colorSpace:this.colorSpace})}static convertPixelToRec2100_hlg(e){const t=oa.COLORSPACES["rec2100-hlg"],r=new aa("srgb",Array.from(e.slice(0,3)).map((e=>e/255)),e[3]/255).to(t),a=r.coords.map((e=>Math.round(e*oa.SDR_MULTIPLIER)));return a.push(r.alpha*oa.SDR_MULTIPLIER),Uint16Array.from(a)}static convertArrayToRec2100_hlg(e){const t=new Uint16Array(e.length);for(let r=0;r<e.length;r+=4){const a=e.slice(r,r+4),n=oa.convertPixelToRec2100_hlg(a);t.set(n,r)}return t}pixelCallback(e){for(let t=0;t<this.data.length;t+=4)this.data.set(e(this.data[t],this.data[t+1],this.data[t+2],this.data[t+3]),t)}static async loadSDRImageData(e){return fetch(e).then((e=>e.blob())).then((e=>createImageBitmap(e))).then((e=>{const{width:t,height:r}=e,a=new OffscreenCanvas(t,r).getContext("2d");return null==a||a.drawImage(e,0,0),a})).then((e=>null==e?void 0:e.getImageData(0,0,null==e?void 0:e.canvas.width,null==e?void 0:e.canvas.height)))}static fromImageData(e){const t=new oa(e.width,e.height);if("srgb"==e.colorSpace)t.data=oa.convertArrayToRec2100_hlg(e.data);else{if(e.colorSpace!=oa.DEFAULT_COLORSPACE)throw new Error(`ColorSpace ${e.colorSpace} isn't supported!`);t.data=e.data}return t}static async fromURL(e){return oa.loadSDRImageData(e).then((e=>{if(void 0!==e)return oa.fromImageData(e)}))}setImageData(e){if(this.width=e.width,this.height=e.height,"srgb"==e.colorSpace)this.data=oa.convertArrayToRec2100_hlg(e.data);else{if(e.colorSpace!=oa.DEFAULT_COLORSPACE)throw new Error(`ColorSpace ${e.colorSpace} isn't supported!`);this.data=e.data}this.colorSpace=oa.DEFAULT_COLORSPACE}clone(){const e=new oa(this.width,this.height,this.colorSpace);return e.data=this.data.slice(),e}}oa.DEFAULT_COLORSPACE="rec2100-hlg",oa.SDR_MULTIPLIER=65535,oa.COLORSPACES={"rec2100-hlg":"rec2100hlg","display-p3":"p3",srgb:"sRGB","rec2100-pq":"rec2100pq"};const sa={colorSpace:oa.DEFAULT_COLORSPACE,pixelFormat:"float16"};return e.Uint16Image=oa,e.checkHDR=function(){try{const e=screen.colorDepth/3,t=e>8,r=window.matchMedia("(dynamic-range: high)").matches;return!(!(window.matchMedia("(color-gamut: rec2020)").matches||window.matchMedia("(color-gamut: p3)").matches)||!r)&&(e===Math.round(e)&&!!t)}catch(e){return console.error("Bad window.screen test",e),!1}},e.checkHDRCanvas=function(){try{const e=document.createElement("canvas");if(!e.getContext)return!1;return null!==e.getContext("2d",{colorSpace:"rec2100-pq",pixelFormat:"float16"})}catch(e){return console.error("Bad canvas ColorSpace test",e),!1}},e.defaultGetContextHDR=function(){HTMLCanvasElement.prototype._getContext=HTMLCanvasElement.prototype.getContext,HTMLCanvasElement.prototype.getContext=function(e,t){return t=void 0!==t?Object.assign({},t,sa):sa,this._getContext(e,t)}},e.initHDRCanvas=function(e){return e.configureHighDynamicRange({mode:"extended"}),e.getContext("2d",sa)},e.resetGetContext=function(){"function"==typeof HTMLCanvasElement.prototype._getContext&&(HTMLCanvasElement.prototype.getContext=HTMLCanvasElement.prototype._getContext)},e}({});
|
2
2
|
//# sourceMappingURL=hdr-canvas.min.js.map
|