use-material-you
Version:
React hook to create dynamic schemes and variants based on M3/material-color-utilities
393 lines • 70.3 kB
JavaScript
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Et=require("react");function zt(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const gt=zt(Et);/**
* @license
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function N(t){return t<0?-1:t===0?0:1}function st(t,e,r){return(1-r)*t+r*e}function _t(t,e,r){return r<t?t:r>e?e:r}function ht(t,e,r){return r<t?t:r>e?e:r}function kt(t){return t=t%360,t<0&&(t=t+360),t}function W(t){return t=t%360,t<0&&(t=t+360),t}function pt(t,e){const r=t[0]*e[0][0]+t[1]*e[0][1]+t[2]*e[0][2],n=t[0]*e[1][0]+t[1]*e[1][1]+t[2]*e[1][2],a=t[0]*e[2][0]+t[1]*e[2][1]+t[2]*e[2][2];return[r,n,a]}/**
* @license
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/const Ft=[[.41233895,.35762064,.18051042],[.2126,.7152,.0722],[.01932141,.11916382,.95034478]],Nt=[[3.2413774792388685,-1.5376652402851851,-.49885366846268053],[-.9691452513005321,1.8758853451067872,.04156585616912061],[.05562093689691305,-.20395524564742123,1.0571799111220335]],Bt=[95.047,100,108.883];function lt(t,e,r){return(255<<24|(t&255)<<16|(e&255)<<8|r&255)>>>0}function Dt(t){const e=nt(t[0]),r=nt(t[1]),n=nt(t[2]);return lt(e,r,n)}function bt(t){return t>>16&255}function Pt(t){return t>>8&255}function Mt(t){return t&255}function Vt(t,e,r){const n=Nt,a=n[0][0]*t+n[0][1]*e+n[0][2]*r,i=n[1][0]*t+n[1][1]*e+n[1][2]*r,u=n[2][0]*t+n[2][1]*e+n[2][2]*r,l=nt(a),m=nt(i),M=nt(u);return lt(l,m,M)}function qt(t){const e=Z(bt(t)),r=Z(Pt(t)),n=Z(Mt(t));return pt([e,r,n],Ft)}function Ht(t){const e=Z(bt(t)),r=Z(Pt(t)),n=Z(Mt(t)),a=Ft,i=a[0][0]*e+a[0][1]*r+a[0][2]*n,u=a[1][0]*e+a[1][1]*r+a[1][2]*n,l=a[2][0]*e+a[2][1]*r+a[2][2]*n,m=Bt,M=i/m[0],d=u/m[1],w=l/m[2],f=it(M),c=it(d),s=it(w),h=116*c-16,y=500*(f-c),p=200*(c-s);return[h,y,p]}function Ut(t){const e=tt(t),r=nt(e);return lt(r,r,r)}function Tt(t){const e=qt(t)[1];return 116*it(e/100)-16}function tt(t){return 100*Gt((t+16)/116)}function yt(t){return it(t/100)*116-16}function Z(t){const e=t/255;return e<=.040449936?e/12.92*100:Math.pow((e+.055)/1.055,2.4)*100}function nt(t){const e=t/100;let r=0;return e<=.0031308?r=e*12.92:r=1.055*Math.pow(e,1/2.4)-.055,_t(0,255,Math.round(r*255))}function Yt(){return Bt}function it(t){const e=.008856451679035631,r=24389/27;return t>e?Math.pow(t,1/3):(r*t+16)/116}function Gt(t){const e=.008856451679035631,r=24389/27,n=t*t*t;return n>e?n:(116*t-16)/r}/**
* @license
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class X{static make(e=Yt(),r=200/Math.PI*tt(50)/100,n=50,a=2,i=!1){const u=e,l=u[0]*.401288+u[1]*.650173+u[2]*-.051461,m=u[0]*-.250268+u[1]*1.204414+u[2]*.045854,M=u[0]*-.002079+u[1]*.048952+u[2]*.953127,d=.8+a/10,w=d>=.9?st(.59,.69,(d-.9)*10):st(.525,.59,(d-.8)*10);let f=i?1:d*(1-1/3.6*Math.exp((-r-42)/92));f=f>1?1:f<0?0:f;const c=d,s=[f*(100/l)+1-f,f*(100/m)+1-f,f*(100/M)+1-f],h=1/(5*r+1),y=h*h*h*h,p=1-y,A=y*r+.1*p*p*Math.cbrt(5*r),b=tt(n)/e[1],R=1.48+Math.sqrt(b),g=.725/Math.pow(b,.2),T=g,C=[Math.pow(A*s[0]*l/100,.42),Math.pow(A*s[1]*m/100,.42),Math.pow(A*s[2]*M/100,.42)],F=[400*C[0]/(C[0]+27.13),400*C[1]/(C[1]+27.13),400*C[2]/(C[2]+27.13)],B=(2*F[0]+F[1]+.05*F[2])*g;return new X(b,B,g,T,w,c,s,A,Math.pow(A,.25),R)}constructor(e,r,n,a,i,u,l,m,M,d){this.n=e,this.aw=r,this.nbb=n,this.ncb=a,this.c=i,this.nc=u,this.rgbD=l,this.fl=m,this.fLRoot=M,this.z=d}}X.DEFAULT=X.make();/**
* @license
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class Y{constructor(e,r,n,a,i,u,l,m,M){this.hue=e,this.chroma=r,this.j=n,this.q=a,this.m=i,this.s=u,this.jstar=l,this.astar=m,this.bstar=M}distance(e){const r=this.jstar-e.jstar,n=this.astar-e.astar,a=this.bstar-e.bstar,i=Math.sqrt(r*r+n*n+a*a);return 1.41*Math.pow(i,.63)}static fromInt(e){return Y.fromIntInViewingConditions(e,X.DEFAULT)}static fromIntInViewingConditions(e,r){const n=(e&16711680)>>16,a=(e&65280)>>8,i=e&255,u=Z(n),l=Z(a),m=Z(i),M=.41233895*u+.35762064*l+.18051042*m,d=.2126*u+.7152*l+.0722*m,w=.01932141*u+.11916382*l+.95034478*m,f=.401288*M+.650173*d-.051461*w,c=-.250268*M+1.204414*d+.045854*w,s=-.002079*M+.048952*d+.953127*w,h=r.rgbD[0]*f,y=r.rgbD[1]*c,p=r.rgbD[2]*s,A=Math.pow(r.fl*Math.abs(h)/100,.42),b=Math.pow(r.fl*Math.abs(y)/100,.42),R=Math.pow(r.fl*Math.abs(p)/100,.42),g=N(h)*400*A/(A+27.13),T=N(y)*400*b/(b+27.13),C=N(p)*400*R/(R+27.13),F=(11*g+-12*T+C)/11,B=(g+T-2*C)/9,x=(20*g+20*T+21*C)/20,z=(40*g+20*T+C)/20,O=Math.atan2(B,F)*180/Math.PI,v=O<0?O+360:O>=360?O-360:O,j=v*Math.PI/180,G=z*r.nbb,K=100*Math.pow(G/r.aw,r.c*r.z),U=4/r.c*Math.sqrt(K/100)*(r.aw+4)*r.fLRoot,et=v<20.14?v+360:v,ft=.25*(Math.cos(et*Math.PI/180+2)+3.8),dt=5e4/13*ft*r.nc*r.ncb*Math.sqrt(F*F+B*B)/(x+.305),ut=Math.pow(dt,.9)*Math.pow(1.64-Math.pow(.29,r.n),.73),At=ut*Math.sqrt(K/100),wt=At*r.fLRoot,St=50*Math.sqrt(ut*r.c/(r.aw+4)),Ot=(1+100*.007)*K/(1+.007*K),Ct=1/.0228*Math.log(1+.0228*wt),Lt=Ct*Math.cos(j),vt=Ct*Math.sin(j);return new Y(v,At,K,U,wt,St,Ot,Lt,vt)}static fromJch(e,r,n){return Y.fromJchInViewingConditions(e,r,n,X.DEFAULT)}static fromJchInViewingConditions(e,r,n,a){const i=4/a.c*Math.sqrt(e/100)*(a.aw+4)*a.fLRoot,u=r*a.fLRoot,l=r/Math.sqrt(e/100),m=50*Math.sqrt(l*a.c/(a.aw+4)),M=n*Math.PI/180,d=(1+100*.007)*e/(1+.007*e),w=1/.0228*Math.log(1+.0228*u),f=w*Math.cos(M),c=w*Math.sin(M);return new Y(n,r,e,i,u,m,d,f,c)}static fromUcs(e,r,n){return Y.fromUcsInViewingConditions(e,r,n,X.DEFAULT)}static fromUcsInViewingConditions(e,r,n,a){const i=r,u=n,l=Math.sqrt(i*i+u*u),M=(Math.exp(l*.0228)-1)/.0228/a.fLRoot;let d=Math.atan2(u,i)*(180/Math.PI);d<0&&(d+=360);const w=e/(1-(e-100)*.007);return Y.fromJchInViewingConditions(w,M,d,a)}toInt(){return this.viewed(X.DEFAULT)}viewed(e){const r=this.chroma===0||this.j===0?0:this.chroma/Math.sqrt(this.j/100),n=Math.pow(r/Math.pow(1.64-Math.pow(.29,e.n),.73),1/.9),a=this.hue*Math.PI/180,i=.25*(Math.cos(a+2)+3.8),u=e.aw*Math.pow(this.j/100,1/e.c/e.z),l=i*(5e4/13)*e.nc*e.ncb,m=u/e.nbb,M=Math.sin(a),d=Math.cos(a),w=23*(m+.305)*n/(23*l+11*n*d+108*n*M),f=w*d,c=w*M,s=(460*m+451*f+288*c)/1403,h=(460*m-891*f-261*c)/1403,y=(460*m-220*f-6300*c)/1403,p=Math.max(0,27.13*Math.abs(s)/(400-Math.abs(s))),A=N(s)*(100/e.fl)*Math.pow(p,1/.42),b=Math.max(0,27.13*Math.abs(h)/(400-Math.abs(h))),R=N(h)*(100/e.fl)*Math.pow(b,1/.42),g=Math.max(0,27.13*Math.abs(y)/(400-Math.abs(y))),T=N(y)*(100/e.fl)*Math.pow(g,1/.42),C=A/e.rgbD[0],F=R/e.rgbD[1],B=T/e.rgbD[2],x=1.86206786*C-1.01125463*F+.14918677*B,z=.38752654*C+.62144744*F-.00897398*B,L=-.0158415*C-.03412294*F+1.04996444*B;return Vt(x,z,L)}static fromXyzInViewingConditions(e,r,n,a){const i=.401288*e+.650173*r-.051461*n,u=-.250268*e+1.204414*r+.045854*n,l=-.002079*e+.048952*r+.953127*n,m=a.rgbD[0]*i,M=a.rgbD[1]*u,d=a.rgbD[2]*l,w=Math.pow(a.fl*Math.abs(m)/100,.42),f=Math.pow(a.fl*Math.abs(M)/100,.42),c=Math.pow(a.fl*Math.abs(d)/100,.42),s=N(m)*400*w/(w+27.13),h=N(M)*400*f/(f+27.13),y=N(d)*400*c/(c+27.13),p=(11*s+-12*h+y)/11,A=(s+h-2*y)/9,b=(20*s+20*h+21*y)/20,R=(40*s+20*h+y)/20,T=Math.atan2(A,p)*180/Math.PI,C=T<0?T+360:T>=360?T-360:T,F=C*Math.PI/180,B=R*a.nbb,x=100*Math.pow(B/a.aw,a.c*a.z),z=4/a.c*Math.sqrt(x/100)*(a.aw+4)*a.fLRoot,L=C<20.14?C+360:C,O=1/4*(Math.cos(L*Math.PI/180+2)+3.8),j=5e4/13*O*a.nc*a.ncb*Math.sqrt(p*p+A*A)/(b+.305),G=Math.pow(j,.9)*Math.pow(1.64-Math.pow(.29,a.n),.73),K=G*Math.sqrt(x/100),U=K*a.fLRoot,et=50*Math.sqrt(G*a.c/(a.aw+4)),ft=(1+100*.007)*x/(1+.007*x),mt=Math.log(1+.0228*U)/.0228,dt=mt*Math.cos(F),ut=mt*Math.sin(F);return new Y(C,K,x,z,U,et,ft,dt,ut)}xyzInViewingConditions(e){const r=this.chroma===0||this.j===0?0:this.chroma/Math.sqrt(this.j/100),n=Math.pow(r/Math.pow(1.64-Math.pow(.29,e.n),.73),1/.9),a=this.hue*Math.PI/180,i=.25*(Math.cos(a+2)+3.8),u=e.aw*Math.pow(this.j/100,1/e.c/e.z),l=i*(5e4/13)*e.nc*e.ncb,m=u/e.nbb,M=Math.sin(a),d=Math.cos(a),w=23*(m+.305)*n/(23*l+11*n*d+108*n*M),f=w*d,c=w*M,s=(460*m+451*f+288*c)/1403,h=(460*m-891*f-261*c)/1403,y=(460*m-220*f-6300*c)/1403,p=Math.max(0,27.13*Math.abs(s)/(400-Math.abs(s))),A=N(s)*(100/e.fl)*Math.pow(p,1/.42),b=Math.max(0,27.13*Math.abs(h)/(400-Math.abs(h))),R=N(h)*(100/e.fl)*Math.pow(b,1/.42),g=Math.max(0,27.13*Math.abs(y)/(400-Math.abs(y))),T=N(y)*(100/e.fl)*Math.pow(g,1/.42),C=A/e.rgbD[0],F=R/e.rgbD[1],B=T/e.rgbD[2],x=1.86206786*C-1.01125463*F+.14918677*B,z=.38752654*C+.62144744*F-.00897398*B,L=-.0158415*C-.03412294*F+1.04996444*B;return[x,z,L]}}/**
* @license
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class D{static sanitizeRadians(e){return(e+Math.PI*8)%(Math.PI*2)}static trueDelinearized(e){const r=e/100;let n=0;return r<=.0031308?n=r*12.92:n=1.055*Math.pow(r,1/2.4)-.055,n*255}static chromaticAdaptation(e){const r=Math.pow(Math.abs(e),.42);return N(e)*400*r/(r+27.13)}static hueOf(e){const r=pt(e,D.SCALED_DISCOUNT_FROM_LINRGB),n=D.chromaticAdaptation(r[0]),a=D.chromaticAdaptation(r[1]),i=D.chromaticAdaptation(r[2]),u=(11*n+-12*a+i)/11,l=(n+a-2*i)/9;return Math.atan2(l,u)}static areInCyclicOrder(e,r,n){const a=D.sanitizeRadians(r-e),i=D.sanitizeRadians(n-e);return a<i}static intercept(e,r,n){return(r-e)/(n-e)}static lerpPoint(e,r,n){return[e[0]+(n[0]-e[0])*r,e[1]+(n[1]-e[1])*r,e[2]+(n[2]-e[2])*r]}static setCoordinate(e,r,n,a){const i=D.intercept(e[a],r,n[a]);return D.lerpPoint(e,i,n)}static isBounded(e){return 0<=e&&e<=100}static nthVertex(e,r){const n=D.Y_FROM_LINRGB[0],a=D.Y_FROM_LINRGB[1],i=D.Y_FROM_LINRGB[2],u=r%4<=1?0:100,l=r%2===0?0:100;if(r<4){const m=u,M=l,d=(e-m*a-M*i)/n;return D.isBounded(d)?[d,m,M]:[-1,-1,-1]}else if(r<8){const m=u,M=l,d=(e-M*n-m*i)/a;return D.isBounded(d)?[M,d,m]:[-1,-1,-1]}else{const m=u,M=l,d=(e-m*n-M*a)/i;return D.isBounded(d)?[m,M,d]:[-1,-1,-1]}}static bisectToSegment(e,r){let n=[-1,-1,-1],a=n,i=0,u=0,l=!1,m=!0;for(let M=0;M<12;M++){const d=D.nthVertex(e,M);if(d[0]<0)continue;const w=D.hueOf(d);if(!l){n=d,a=d,i=w,u=w,l=!0;continue}(m||D.areInCyclicOrder(i,w,u))&&(m=!1,D.areInCyclicOrder(i,r,w)?(a=d,u=w):(n=d,i=w))}return[n,a]}static midpoint(e,r){return[(e[0]+r[0])/2,(e[1]+r[1])/2,(e[2]+r[2])/2]}static criticalPlaneBelow(e){return Math.floor(e-.5)}static criticalPlaneAbove(e){return Math.ceil(e-.5)}static bisectToLimit(e,r){const n=D.bisectToSegment(e,r);let a=n[0],i=D.hueOf(a),u=n[1];for(let l=0;l<3;l++)if(a[l]!==u[l]){let m=-1,M=255;a[l]<u[l]?(m=D.criticalPlaneBelow(D.trueDelinearized(a[l])),M=D.criticalPlaneAbove(D.trueDelinearized(u[l]))):(m=D.criticalPlaneAbove(D.trueDelinearized(a[l])),M=D.criticalPlaneBelow(D.trueDelinearized(u[l])));for(let d=0;d<8&&!(Math.abs(M-m)<=1);d++){const w=Math.floor((m+M)/2),f=D.CRITICAL_PLANES[w],c=D.setCoordinate(a,f,u,l),s=D.hueOf(c);D.areInCyclicOrder(i,r,s)?(u=c,M=w):(a=c,i=s,m=w)}}return D.midpoint(a,u)}static inverseChromaticAdaptation(e){const r=Math.abs(e),n=Math.max(0,27.13*r/(400-r));return N(e)*Math.pow(n,1/.42)}static findResultByJ(e,r,n){let a=Math.sqrt(n)*11;const i=X.DEFAULT,u=1/Math.pow(1.64-Math.pow(.29,i.n),.73),m=.25*(Math.cos(e+2)+3.8)*(5e4/13)*i.nc*i.ncb,M=Math.sin(e),d=Math.cos(e);for(let w=0;w<5;w++){const f=a/100,c=r===0||a===0?0:r/Math.sqrt(f),s=Math.pow(c*u,1/.9),y=i.aw*Math.pow(f,1/i.c/i.z)/i.nbb,p=23*(y+.305)*s/(23*m+11*s*d+108*s*M),A=p*d,b=p*M,R=(460*y+451*A+288*b)/1403,g=(460*y-891*A-261*b)/1403,T=(460*y-220*A-6300*b)/1403,C=D.inverseChromaticAdaptation(R),F=D.inverseChromaticAdaptation(g),B=D.inverseChromaticAdaptation(T),x=pt([C,F,B],D.LINRGB_FROM_SCALED_DISCOUNT);if(x[0]<0||x[1]<0||x[2]<0)return 0;const z=D.Y_FROM_LINRGB[0],L=D.Y_FROM_LINRGB[1],O=D.Y_FROM_LINRGB[2],v=z*x[0]+L*x[1]+O*x[2];if(v<=0)return 0;if(w===4||Math.abs(v-n)<.002)return x[0]>100.01||x[1]>100.01||x[2]>100.01?0:Dt(x);a=a-(v-n)*a/(2*v)}return 0}static solveToInt(e,r,n){if(r<1e-4||n<1e-4||n>99.9999)return Ut(n);e=W(e);const a=e/180*Math.PI,i=tt(n),u=D.findResultByJ(a,r,i);if(u!==0)return u;const l=D.bisectToLimit(i,a);return Dt(l)}static solveToCam(e,r,n){return Y.fromInt(D.solveToInt(e,r,n))}}D.SCALED_DISCOUNT_FROM_LINRGB=[[.001200833568784504,.002389694492170889,.0002795742885861124],[.0005891086651375999,.0029785502573438758,.0003270666104008398],[.00010146692491640572,.0005364214359186694,.0032979401770712076]];D.LINRGB_FROM_SCALED_DISCOUNT=[[1373.2198709594231,-1100.4251190754821,-7.278681089101213],[-271.815969077903,559.6580465940733,-32.46047482791194],[1.9622899599665666,-57.173814538844006,308.7233197812385]];D.Y_FROM_LINRGB=[.2126,.7152,.0722];D.CRITICAL_PLANES=[.015176349177441876,.045529047532325624,.07588174588720938,.10623444424209313,.13658714259697685,.16693984095186062,.19729253930674434,.2276452376616281,.2579979360165119,.28835063437139563,.3188300904430532,.350925934958123,.3848314933096426,.42057480301049466,.458183274052838,.4976837250274023,.5391024159806381,.5824650784040898,.6277969426914107,.6751227633498623,.7244668422128921,.775853049866786,.829304845476233,.8848452951698498,.942497089126609,1.0022825574869039,1.0642236851973577,1.1283421258858297,1.1946592148522128,1.2631959812511864,1.3339731595349034,1.407011200216447,1.4823302800086415,1.5599503113873272,1.6398909516233677,1.7221716113234105,1.8068114625156377,1.8938294463134073,1.9832442801866852,2.075074464868551,2.1693382909216234,2.2660538449872063,2.36523901573795,2.4669114995532007,2.5710888059345764,2.6777882626779785,2.7870270208169257,2.898822059350997,3.0131901897720907,3.1301480604002863,3.2497121605402226,3.3718988244681087,3.4967242352587946,3.624204428461639,3.754355295633311,3.887192587735158,4.022731918402185,4.160988767090289,4.301978482107941,4.445716283538092,4.592217266055746,4.741496401646282,4.893568542229298,5.048448422192488,5.20615066083972,5.3666897647573375,5.5300801301023865,5.696336044816294,5.865471690767354,6.037501145825082,6.212438385869475,6.390297286737924,6.571091626112461,6.7548350853498045,6.941541251256611,7.131223617812143,7.323895587840543,7.5195704746346665,7.7182615035334345,7.919981813454504,8.124744458384042,8.332562408825165,8.543448553206703,8.757415699253682,8.974476575321063,9.194643831691977,9.417930041841839,9.644347703669503,9.873909240696694,10.106627003236781,10.342513269534024,10.58158024687427,10.8238400726681,11.069304815507364,11.317986476196008,11.569896988756009,11.825048221409341,12.083451977536606,12.345119996613247,12.610063955123938,12.878295467455942,13.149826086772048,13.42466730586372,13.702830557985108,13.984327217668513,14.269168601521828,14.55736596900856,14.848930523210871,15.143873411576273,15.44220572664832,15.743938506781891,16.04908273684337,16.35764934889634,16.66964922287304,16.985093187232053,17.30399201960269,17.62635644741625,17.95219714852476,18.281524751807332,18.614349837764564,18.95068293910138,19.290534541298456,19.633915083172692,19.98083495742689,20.331304511189067,20.685334046541502,21.042933821039977,21.404114048223256,21.76888489811322,22.137256497705877,22.50923893145328,22.884842241736916,23.264076429332462,23.6469514538663,24.033477234264016,24.42366364919083,24.817520537484558,25.21505769858089,25.61628489293138,26.021211842414342,26.429848230738664,26.842203703840827,27.258287870275353,27.678110301598522,28.10168053274597,28.529008062403893,28.96010235337422,29.39497283293396,29.83362889318845,30.276079891419332,30.722335150426627,31.172403958865512,31.62629557157785,32.08401920991837,32.54558406207592,33.010999283389665,33.4802739966603,33.953417292456834,34.430438229418264,34.911345834551085,35.39614910352207,35.88485700094671,36.37747846067349,36.87402238606382,37.37449765026789,37.87891309649659,38.38727753828926,38.89959975977785,39.41588851594697,39.93615253289054,40.460400508064545,40.98864111053629,41.520882981230194,42.05713473317016,42.597404951718396,43.141702194811224,43.6900349931913,44.24241185063697,44.798841244188324,45.35933162437017,45.92389141541209,46.49252901546552,47.065252796817916,47.64207110610409,48.22299226451468,48.808024568002054,49.3971762874833,49.9904556690408,50.587870934119984,51.189430279724725,51.79514187861014,52.40501387947288,53.0190544071392,53.637271562750364,54.259673423945976,54.88626804504493,55.517063457223934,56.15206766869424,56.79128866487574,57.43473440856916,58.08241284012621,58.734331877617365,59.39049941699807,60.05092333227251,60.715611475655585,61.38457167773311,62.057811747619894,62.7353394731159,63.417162620860914,64.10328893648692,64.79372614476921,65.48848194977529,66.18756403501224,66.89098006357258,67.59873767827808,68.31084450182222,69.02730813691093,69.74813616640164,70.47333615344107,71.20291564160104,71.93688215501312,72.67524319850172,73.41800625771542,74.16517879925733,74.9167682708136,75.67278210128072,76.43322770089146,77.1981124613393,77.96744375590167,78.74122893956174,79.51947534912904,80.30219030335869,81.08938110306934,81.88105503125999,82.67721935322541,83.4778813166706,84.28304815182372,85.09272707154808,85.90692527145302,86.72564993000343,87.54890820862819,88.3767072518277,89.2090541872801,90.04595612594655,90.88742016217518,91.73345337380438,92.58406282226491,93.43925555268066,94.29903859396902,95.16341895893969,96.03240364439274,96.9059996312159,97.78421388448044,98.6670533535366,99.55452497210776];/**
* @license
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class _{static from(e,r,n){return new _(D.solveToInt(e,r,n))}static fromInt(e){return new _(e)}toInt(){return this.argb}get hue(){return this.internalHue}set hue(e){this.setInternalState(D.solveToInt(e,this.internalChroma,this.internalTone))}get chroma(){return this.internalChroma}set chroma(e){this.setInternalState(D.solveToInt(this.internalHue,e,this.internalTone))}get tone(){return this.internalTone}set tone(e){this.setInternalState(D.solveToInt(this.internalHue,this.internalChroma,e))}constructor(e){this.argb=e;const r=Y.fromInt(e);this.internalHue=r.hue,this.internalChroma=r.chroma,this.internalTone=Tt(e),this.argb=e}setInternalState(e){const r=Y.fromInt(e);this.internalHue=r.hue,this.internalChroma=r.chroma,this.internalTone=Tt(e),this.argb=e}inViewingConditions(e){const n=Y.fromInt(this.toInt()).xyzInViewingConditions(e),a=Y.fromXyzInViewingConditions(n[0],n[1],n[2],X.make());return _.from(a.hue,a.chroma,yt(n[1]))}}/**
* @license
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class E{static ratioOfTones(e,r){return e=ht(0,100,e),r=ht(0,100,r),E.ratioOfYs(tt(e),tt(r))}static ratioOfYs(e,r){const n=e>r?e:r,a=n===r?e:r;return(n+5)/(a+5)}static lighter(e,r){if(e<0||e>100)return-1;const n=tt(e),a=r*(n+5)-5,i=E.ratioOfYs(a,n),u=Math.abs(i-r);if(i<r&&u>.04)return-1;const l=yt(a)+.4;return l<0||l>100?-1:l}static darker(e,r){if(e<0||e>100)return-1;const n=tt(e),a=(n+5)/r-5,i=E.ratioOfYs(n,a),u=Math.abs(i-r);if(i<r&&u>.04)return-1;const l=yt(a)-.4;return l<0||l>100?-1:l}static lighterUnsafe(e,r){const n=E.lighter(e,r);return n<0?100:n}static darkerUnsafe(e,r){const n=E.darker(e,r);return n<0?0:n}}/**
* @license
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class ct{static isDisliked(e){const r=Math.round(e.hue)>=90&&Math.round(e.hue)<=111,n=Math.round(e.chroma)>16,a=Math.round(e.tone)<65;return r&&n&&a}static fixIfDisliked(e){return ct.isDisliked(e)?_.from(e.hue,e.chroma,70):e}}/**
* @license
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class P{static fromPalette(e){return new P(e.name??"",e.palette,e.tone,e.isBackground??!1,e.background,e.secondBackground,e.contrastCurve,e.toneDeltaPair)}constructor(e,r,n,a,i,u,l,m){if(this.name=e,this.palette=r,this.tone=n,this.isBackground=a,this.background=i,this.secondBackground=u,this.contrastCurve=l,this.toneDeltaPair=m,this.hctCache=new Map,!i&&u)throw new Error(`Color ${e} has secondBackgrounddefined, but background is not defined.`);if(!i&&l)throw new Error(`Color ${e} has contrastCurvedefined, but background is not defined.`);if(i&&!l)throw new Error(`Color ${e} has backgrounddefined, but contrastCurve is not defined.`)}getArgb(e){return this.getHct(e).toInt()}getHct(e){const r=this.hctCache.get(e);if(r!=null)return r;const n=this.getTone(e),a=this.palette(e).getHct(n);return this.hctCache.size>4&&this.hctCache.clear(),this.hctCache.set(e,a),a}getTone(e){const r=e.contrastLevel<0;if(this.toneDeltaPair){const n=this.toneDeltaPair(e),a=n.roleA,i=n.roleB,u=n.delta,l=n.polarity,m=n.stayTogether,d=this.background(e).getTone(e),w=l==="nearer"||l==="lighter"&&!e.isDark||l==="darker"&&e.isDark,f=w?a:i,c=w?i:a,s=this.name===f.name,h=e.isDark?1:-1,y=f.contrastCurve.get(e.contrastLevel),p=c.contrastCurve.get(e.contrastLevel),A=f.tone(e);let b=E.ratioOfTones(d,A)>=y?A:P.foregroundTone(d,y);const R=c.tone(e);let g=E.ratioOfTones(d,R)>=p?R:P.foregroundTone(d,p);return r&&(b=P.foregroundTone(d,y),g=P.foregroundTone(d,p)),(g-b)*h>=u||(g=ht(0,100,b+u*h),(g-b)*h>=u||(b=ht(0,100,g-u*h))),50<=b&&b<60?h>0?(b=60,g=Math.max(g,b+u*h)):(b=49,g=Math.min(g,b+u*h)):50<=g&&g<60&&(m?h>0?(b=60,g=Math.max(g,b+u*h)):(b=49,g=Math.min(g,b+u*h)):h>0?g=60:g=49),s?b:g}else{let n=this.tone(e);if(this.background==null)return n;const a=this.background(e).getTone(e),i=this.contrastCurve.get(e.contrastLevel);if(E.ratioOfTones(a,n)>=i||(n=P.foregroundTone(a,i)),r&&(n=P.foregroundTone(a,i)),this.isBackground&&50<=n&&n<60&&(E.ratioOfTones(49,a)>=i?n=49:n=60),this.secondBackground){const[u,l]=[this.background,this.secondBackground],[m,M]=[u(e).getTone(e),l(e).getTone(e)],[d,w]=[Math.max(m,M),Math.min(m,M)];if(E.ratioOfTones(d,n)>=i&&E.ratioOfTones(w,n)>=i)return n;const f=E.lighter(d,i),c=E.darker(w,i),s=[];return f!==-1&&s.push(f),c!==-1&&s.push(c),P.tonePrefersLightForeground(m)||P.tonePrefersLightForeground(M)?f<0?100:f:s.length===1?s[0]:c<0?0:c}return n}}static foregroundTone(e,r){const n=E.lighterUnsafe(e,r),a=E.darkerUnsafe(e,r),i=E.ratioOfTones(n,e),u=E.ratioOfTones(a,e);if(P.tonePrefersLightForeground(e)){const m=Math.abs(i-u)<.1&&i<r&&u<r;return i>=r||i>=u||m?n:a}else return u>=r||u>=i?a:n}static tonePrefersLightForeground(e){return Math.round(e)<60}static toneAllowsLightForeground(e){return Math.round(e)<=49}static enableLightForeground(e){return P.tonePrefersLightForeground(e)&&!P.toneAllowsLightForeground(e)?49:e}}/**
* @license
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class k{static fromInt(e){const r=_.fromInt(e);return k.fromHct(r)}static fromHct(e){return new k(e.hue,e.chroma,e)}static fromHueAndChroma(e,r){const n=new Kt(e,r).create();return new k(e,r,n)}constructor(e,r,n){this.hue=e,this.chroma=r,this.keyColor=n,this.cache=new Map}tone(e){let r=this.cache.get(e);return r===void 0&&(r=_.from(this.hue,this.chroma,e).toInt(),this.cache.set(e,r)),r}getHct(e){return _.fromInt(this.tone(e))}}class Kt{constructor(e,r){this.hue=e,this.requestedChroma=r,this.chromaCache=new Map,this.maxChromaValue=200}create(){let a=0,i=100;for(;a<i;){const u=Math.floor((a+i)/2),l=this.maxChroma(u)<this.maxChroma(u+1);if(this.maxChroma(u)>=this.requestedChroma-.01)if(Math.abs(a-50)<Math.abs(i-50))i=u;else{if(a===u)return _.from(this.hue,this.requestedChroma,a);a=u}else l?a=u+1:i=u}return _.from(this.hue,this.requestedChroma,a)}maxChroma(e){if(this.chromaCache.has(e))return this.chromaCache.get(e);const r=_.from(this.hue,this.maxChromaValue,e).chroma;return this.chromaCache.set(e,r),r}}/**
* @license
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class I{constructor(e,r,n,a){this.low=e,this.normal=r,this.medium=n,this.high=a}get(e){return e<=-1?this.low:e<0?st(this.low,this.normal,(e- -1)/1):e<.5?st(this.normal,this.medium,(e-0)/.5):e<1?st(this.medium,this.high,(e-.5)/.5):this.high}}/**
* @license
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class H{constructor(e,r,n,a,i){this.roleA=e,this.roleB=r,this.delta=n,this.polarity=a,this.stayTogether=i}}/**
* @license
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var q;(function(t){t[t.MONOCHROME=0]="MONOCHROME",t[t.NEUTRAL=1]="NEUTRAL",t[t.TONAL_SPOT=2]="TONAL_SPOT",t[t.VIBRANT=3]="VIBRANT",t[t.EXPRESSIVE=4]="EXPRESSIVE",t[t.FIDELITY=5]="FIDELITY",t[t.CONTENT=6]="CONTENT",t[t.RAINBOW=7]="RAINBOW",t[t.FRUIT_SALAD=8]="FRUIT_SALAD"})(q||(q={}));/**
* @license
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function ot(t){return t.variant===q.FIDELITY||t.variant===q.CONTENT}function S(t){return t.variant===q.MONOCHROME}function jt(t,e,r,n){let a=r,i=_.from(t,e,r);if(i.chroma<e){let u=i.chroma;for(;i.chroma<e;){a+=n?-1:1;const l=_.from(t,e,a);if(u>l.chroma||Math.abs(l.chroma-e)<.4)break;const m=Math.abs(l.chroma-e),M=Math.abs(i.chroma-e);m<M&&(i=l),u=Math.max(u,l.chroma)}}return a}class o{static highestSurface(e){return e.isDark?o.surfaceBright:o.surfaceDim}}o.contentAccentToneDelta=15;o.primaryPaletteKeyColor=P.fromPalette({name:"primary_palette_key_color",palette:t=>t.primaryPalette,tone:t=>t.primaryPalette.keyColor.tone});o.secondaryPaletteKeyColor=P.fromPalette({name:"secondary_palette_key_color",palette:t=>t.secondaryPalette,tone:t=>t.secondaryPalette.keyColor.tone});o.tertiaryPaletteKeyColor=P.fromPalette({name:"tertiary_palette_key_color",palette:t=>t.tertiaryPalette,tone:t=>t.tertiaryPalette.keyColor.tone});o.neutralPaletteKeyColor=P.fromPalette({name:"neutral_palette_key_color",palette:t=>t.neutralPalette,tone:t=>t.neutralPalette.keyColor.tone});o.neutralVariantPaletteKeyColor=P.fromPalette({name:"neutral_variant_palette_key_color",palette:t=>t.neutralVariantPalette,tone:t=>t.neutralVariantPalette.keyColor.tone});o.background=P.fromPalette({name:"background",palette:t=>t.neutralPalette,tone:t=>t.isDark?6:98,isBackground:!0});o.onBackground=P.fromPalette({name:"on_background",palette:t=>t.neutralPalette,tone:t=>t.isDark?90:10,background:t=>o.background,contrastCurve:new I(3,3,4.5,7)});o.surface=P.fromPalette({name:"surface",palette:t=>t.neutralPalette,tone:t=>t.isDark?6:98,isBackground:!0});o.surfaceDim=P.fromPalette({name:"surface_dim",palette:t=>t.neutralPalette,tone:t=>t.isDark?6:new I(87,87,80,75).get(t.contrastLevel),isBackground:!0});o.surfaceBright=P.fromPalette({name:"surface_bright",palette:t=>t.neutralPalette,tone:t=>t.isDark?new I(24,24,29,34).get(t.contrastLevel):98,isBackground:!0});o.surfaceContainerLowest=P.fromPalette({name:"surface_container_lowest",palette:t=>t.neutralPalette,tone:t=>t.isDark?new I(4,4,2,0).get(t.contrastLevel):100,isBackground:!0});o.surfaceContainerLow=P.fromPalette({name:"surface_container_low",palette:t=>t.neutralPalette,tone:t=>t.isDark?new I(10,10,11,12).get(t.contrastLevel):new I(96,96,96,95).get(t.contrastLevel),isBackground:!0});o.surfaceContainer=P.fromPalette({name:"surface_container",palette:t=>t.neutralPalette,tone:t=>t.isDark?new I(12,12,16,20).get(t.contrastLevel):new I(94,94,92,90).get(t.contrastLevel),isBackground:!0});o.surfaceContainerHigh=P.fromPalette({name:"surface_container_high",palette:t=>t.neutralPalette,tone:t=>t.isDark?new I(17,17,21,25).get(t.contrastLevel):new I(92,92,88,85).get(t.contrastLevel),isBackground:!0});o.surfaceContainerHighest=P.fromPalette({name:"surface_container_highest",palette:t=>t.neutralPalette,tone:t=>t.isDark?new I(22,22,26,30).get(t.contrastLevel):new I(90,90,84,80).get(t.contrastLevel),isBackground:!0});o.onSurface=P.fromPalette({name:"on_surface",palette:t=>t.neutralPalette,tone:t=>t.isDark?90:10,background:t=>o.highestSurface(t),contrastCurve:new I(4.5,7,11,21)});o.surfaceVariant=P.fromPalette({name:"surface_variant",palette:t=>t.neutralVariantPalette,tone:t=>t.isDark?30:90,isBackground:!0});o.onSurfaceVariant=P.fromPalette({name:"on_surface_variant",palette:t=>t.neutralVariantPalette,tone:t=>t.isDark?80:30,background:t=>o.highestSurface(t),contrastCurve:new I(3,4.5,7,11)});o.inverseSurface=P.fromPalette({name:"inverse_surface",palette:t=>t.neutralPalette,tone:t=>t.isDark?90:20});o.inverseOnSurface=P.fromPalette({name:"inverse_on_surface",palette:t=>t.neutralPalette,tone:t=>t.isDark?20:95,background:t=>o.inverseSurface,contrastCurve:new I(4.5,7,11,21)});o.outline=P.fromPalette({name:"outline",palette:t=>t.neutralVariantPalette,tone:t=>t.isDark?60:50,background:t=>o.highestSurface(t),contrastCurve:new I(1.5,3,4.5,7)});o.outlineVariant=P.fromPalette({name:"outline_variant",palette:t=>t.neutralVariantPalette,tone:t=>t.isDark?30:80,background:t=>o.highestSurface(t),contrastCurve:new I(1,1,3,4.5)});o.shadow=P.fromPalette({name:"shadow",palette:t=>t.neutralPalette,tone:t=>0});o.scrim=P.fromPalette({name:"scrim",palette:t=>t.neutralPalette,tone:t=>0});o.surfaceTint=P.fromPalette({name:"surface_tint",palette:t=>t.primaryPalette,tone:t=>t.isDark?80:40,isBackground:!0});o.primary=P.fromPalette({name:"primary",palette:t=>t.primaryPalette,tone:t=>S(t)?t.isDark?100:0:t.isDark?80:40,isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new I(3,4.5,7,7),toneDeltaPair:t=>new H(o.primaryContainer,o.primary,10,"nearer",!1)});o.onPrimary=P.fromPalette({name:"on_primary",palette:t=>t.primaryPalette,tone:t=>S(t)?t.isDark?10:90:t.isDark?20:100,background:t=>o.primary,contrastCurve:new I(4.5,7,11,21)});o.primaryContainer=P.fromPalette({name:"primary_container",palette:t=>t.primaryPalette,tone:t=>ot(t)?t.sourceColorHct.tone:S(t)?t.isDark?85:25:t.isDark?30:90,isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new I(1,1,3,4.5),toneDeltaPair:t=>new H(o.primaryContainer,o.primary,10,"nearer",!1)});o.onPrimaryContainer=P.fromPalette({name:"on_primary_container",palette:t=>t.primaryPalette,tone:t=>ot(t)?P.foregroundTone(o.primaryContainer.tone(t),4.5):S(t)?t.isDark?0:100:t.isDark?90:30,background:t=>o.primaryContainer,contrastCurve:new I(3,4.5,7,11)});o.inversePrimary=P.fromPalette({name:"inverse_primary",palette:t=>t.primaryPalette,tone:t=>t.isDark?40:80,background:t=>o.inverseSurface,contrastCurve:new I(3,4.5,7,7)});o.secondary=P.fromPalette({name:"secondary",palette:t=>t.secondaryPalette,tone:t=>t.isDark?80:40,isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new I(3,4.5,7,7),toneDeltaPair:t=>new H(o.secondaryContainer,o.secondary,10,"nearer",!1)});o.onSecondary=P.fromPalette({name:"on_secondary",palette:t=>t.secondaryPalette,tone:t=>S(t)?t.isDark?10:100:t.isDark?20:100,background:t=>o.secondary,contrastCurve:new I(4.5,7,11,21)});o.secondaryContainer=P.fromPalette({name:"secondary_container",palette:t=>t.secondaryPalette,tone:t=>{const e=t.isDark?30:90;return S(t)?t.isDark?30:85:ot(t)?jt(t.secondaryPalette.hue,t.secondaryPalette.chroma,e,!t.isDark):e},isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new I(1,1,3,4.5),toneDeltaPair:t=>new H(o.secondaryContainer,o.secondary,10,"nearer",!1)});o.onSecondaryContainer=P.fromPalette({name:"on_secondary_container",palette:t=>t.secondaryPalette,tone:t=>S(t)?t.isDark?90:10:ot(t)?P.foregroundTone(o.secondaryContainer.tone(t),4.5):t.isDark?90:30,background:t=>o.secondaryContainer,contrastCurve:new I(3,4.5,7,11)});o.tertiary=P.fromPalette({name:"tertiary",palette:t=>t.tertiaryPalette,tone:t=>S(t)?t.isDark?90:25:t.isDark?80:40,isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new I(3,4.5,7,7),toneDeltaPair:t=>new H(o.tertiaryContainer,o.tertiary,10,"nearer",!1)});o.onTertiary=P.fromPalette({name:"on_tertiary",palette:t=>t.tertiaryPalette,tone:t=>S(t)?t.isDark?10:90:t.isDark?20:100,background:t=>o.tertiary,contrastCurve:new I(4.5,7,11,21)});o.tertiaryContainer=P.fromPalette({name:"tertiary_container",palette:t=>t.tertiaryPalette,tone:t=>{if(S(t))return t.isDark?60:49;if(!ot(t))return t.isDark?30:90;const e=t.tertiaryPalette.getHct(t.sourceColorHct.tone);return ct.fixIfDisliked(e).tone},isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new I(1,1,3,4.5),toneDeltaPair:t=>new H(o.tertiaryContainer,o.tertiary,10,"nearer",!1)});o.onTertiaryContainer=P.fromPalette({name:"on_tertiary_container",palette:t=>t.tertiaryPalette,tone:t=>S(t)?t.isDark?0:100:ot(t)?P.foregroundTone(o.tertiaryContainer.tone(t),4.5):t.isDark?90:30,background:t=>o.tertiaryContainer,contrastCurve:new I(3,4.5,7,11)});o.error=P.fromPalette({name:"error",palette:t=>t.errorPalette,tone:t=>t.isDark?80:40,isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new I(3,4.5,7,7),toneDeltaPair:t=>new H(o.errorContainer,o.error,10,"nearer",!1)});o.onError=P.fromPalette({name:"on_error",palette:t=>t.errorPalette,tone:t=>t.isDark?20:100,background:t=>o.error,contrastCurve:new I(4.5,7,11,21)});o.errorContainer=P.fromPalette({name:"error_container",palette:t=>t.errorPalette,tone:t=>t.isDark?30:90,isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new I(1,1,3,4.5),toneDeltaPair:t=>new H(o.errorContainer,o.error,10,"nearer",!1)});o.onErrorContainer=P.fromPalette({name:"on_error_container",palette:t=>t.errorPalette,tone:t=>S(t)?t.isDark?90:10:t.isDark?90:30,background:t=>o.errorContainer,contrastCurve:new I(3,4.5,7,11)});o.primaryFixed=P.fromPalette({name:"primary_fixed",palette:t=>t.primaryPalette,tone:t=>S(t)?40:90,isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new I(1,1,3,4.5),toneDeltaPair:t=>new H(o.primaryFixed,o.primaryFixedDim,10,"lighter",!0)});o.primaryFixedDim=P.fromPalette({name:"primary_fixed_dim",palette:t=>t.primaryPalette,tone:t=>S(t)?30:80,isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new I(1,1,3,4.5),toneDeltaPair:t=>new H(o.primaryFixed,o.primaryFixedDim,10,"lighter",!0)});o.onPrimaryFixed=P.fromPalette({name:"on_primary_fixed",palette:t=>t.primaryPalette,tone:t=>S(t)?100:10,background:t=>o.primaryFixedDim,secondBackground:t=>o.primaryFixed,contrastCurve:new I(4.5,7,11,21)});o.onPrimaryFixedVariant=P.fromPalette({name:"on_primary_fixed_variant",palette:t=>t.primaryPalette,tone:t=>S(t)?90:30,background:t=>o.primaryFixedDim,secondBackground:t=>o.primaryFixed,contrastCurve:new I(3,4.5,7,11)});o.secondaryFixed=P.fromPalette({name:"secondary_fixed",palette:t=>t.secondaryPalette,tone:t=>S(t)?80:90,isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new I(1,1,3,4.5),toneDeltaPair:t=>new H(o.secondaryFixed,o.secondaryFixedDim,10,"lighter",!0)});o.secondaryFixedDim=P.fromPalette({name:"secondary_fixed_dim",palette:t=>t.secondaryPalette,tone:t=>S(t)?70:80,isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new I(1,1,3,4.5),toneDeltaPair:t=>new H(o.secondaryFixed,o.secondaryFixedDim,10,"lighter",!0)});o.onSecondaryFixed=P.fromPalette({name:"on_secondary_fixed",palette:t=>t.secondaryPalette,tone:t=>10,background:t=>o.secondaryFixedDim,secondBackground:t=>o.secondaryFixed,contrastCurve:new I(4.5,7,11,21)});o.onSecondaryFixedVariant=P.fromPalette({name:"on_secondary_fixed_variant",palette:t=>t.secondaryPalette,tone:t=>S(t)?25:30,background:t=>o.secondaryFixedDim,secondBackground:t=>o.secondaryFixed,contrastCurve:new I(3,4.5,7,11)});o.tertiaryFixed=P.fromPalette({name:"tertiary_fixed",palette:t=>t.tertiaryPalette,tone:t=>S(t)?40:90,isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new I(1,1,3,4.5),toneDeltaPair:t=>new H(o.tertiaryFixed,o.tertiaryFixedDim,10,"lighter",!0)});o.tertiaryFixedDim=P.fromPalette({name:"tertiary_fixed_dim",palette:t=>t.tertiaryPalette,tone:t=>S(t)?30:80,isBackground:!0,background:t=>o.highestSurface(t),contrastCurve:new I(1,1,3,4.5),toneDeltaPair:t=>new H(o.tertiaryFixed,o.tertiaryFixedDim,10,"lighter",!0)});o.onTertiaryFixed=P.fromPalette({name:"on_tertiary_fixed",palette:t=>t.tertiaryPalette,tone:t=>S(t)?100:10,background:t=>o.tertiaryFixedDim,secondBackground:t=>o.tertiaryFixed,contrastCurve:new I(4.5,7,11,21)});o.onTertiaryFixedVariant=P.fromPalette({name:"on_tertiary_fixed_variant",palette:t=>t.tertiaryPalette,tone:t=>S(t)?90:30,background:t=>o.tertiaryFixedDim,secondBackground:t=>o.tertiaryFixed,contrastCurve:new I(3,4.5,7,11)});/**
* @license
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class V{constructor(e){this.sourceColorArgb=e.sourceColorArgb,this.variant=e.variant,this.contrastLevel=e.contrastLevel,this.isDark=e.isDark,this.sourceColorHct=_.fromInt(e.sourceColorArgb),this.primaryPalette=e.primaryPalette,this.secondaryPalette=e.secondaryPalette,this.tertiaryPalette=e.tertiaryPalette,this.neutralPalette=e.neutralPalette,this.neutralVariantPalette=e.neutralVariantPalette,this.errorPalette=k.fromHueAndChroma(25,84)}static getRotatedHue(e,r,n){const a=e.hue;if(r.length!==n.length)throw new Error(`mismatch between hue length ${r.length} & rotations ${n.length}`);if(n.length===1)return W(e.hue+n[0]);const i=r.length;for(let u=0;u<=i-2;u++){const l=r[u],m=r[u+1];if(l<a&&a<m)return W(a+n[u])}return a}getArgb(e){return e.getArgb(this)}getHct(e){return e.getHct(this)}get primaryPaletteKeyColor(){return this.getArgb(o.primaryPaletteKeyColor)}get secondaryPaletteKeyColor(){return this.getArgb(o.secondaryPaletteKeyColor)}get tertiaryPaletteKeyColor(){return this.getArgb(o.tertiaryPaletteKeyColor)}get neutralPaletteKeyColor(){return this.getArgb(o.neutralPaletteKeyColor)}get neutralVariantPaletteKeyColor(){return this.getArgb(o.neutralVariantPaletteKeyColor)}get background(){return this.getArgb(o.background)}get onBackground(){return this.getArgb(o.onBackground)}get surface(){return this.getArgb(o.surface)}get surfaceDim(){return this.getArgb(o.surfaceDim)}get surfaceBright(){return this.getArgb(o.surfaceBright)}get surfaceContainerLowest(){return this.getArgb(o.surfaceContainerLowest)}get surfaceContainerLow(){return this.getArgb(o.surfaceContainerLow)}get surfaceContainer(){return this.getArgb(o.surfaceContainer)}get surfaceContainerHigh(){return this.getArgb(o.surfaceContainerHigh)}get surfaceContainerHighest(){return this.getArgb(o.surfaceContainerHighest)}get onSurface(){return this.getArgb(o.onSurface)}get surfaceVariant(){return this.getArgb(o.surfaceVariant)}get onSurfaceVariant(){return this.getArgb(o.onSurfaceVariant)}get inverseSurface(){return this.getArgb(o.inverseSurface)}get inverseOnSurface(){return this.getArgb(o.inverseOnSurface)}get outline(){return this.getArgb(o.outline)}get outlineVariant(){return this.getArgb(o.outlineVariant)}get shadow(){return this.getArgb(o.shadow)}get scrim(){return this.getArgb(o.scrim)}get surfaceTint(){return this.getArgb(o.surfaceTint)}get primary(){return this.getArgb(o.primary)}get onPrimary(){return this.getArgb(o.onPrimary)}get primaryContainer(){return this.getArgb(o.primaryContainer)}get onPrimaryContainer(){return this.getArgb(o.onPrimaryContainer)}get inversePrimary(){return this.getArgb(o.inversePrimary)}get secondary(){return this.getArgb(o.secondary)}get onSecondary(){return this.getArgb(o.onSecondary)}get secondaryContainer(){return this.getArgb(o.secondaryContainer)}get onSecondaryContainer(){return this.getArgb(o.onSecondaryContainer)}get tertiary(){return this.getArgb(o.tertiary)}get onTertiary(){return this.getArgb(o.onTertiary)}get tertiaryContainer(){return this.getArgb(o.tertiaryContainer)}get onTertiaryContainer(){return this.getArgb(o.onTertiaryContainer)}get error(){return this.getArgb(o.error)}get onError(){return this.getArgb(o.onError)}get errorContainer(){return this.getArgb(o.errorContainer)}get onErrorContainer(){return this.getArgb(o.onErrorContainer)}get primaryFixed(){return this.getArgb(o.primaryFixed)}get primaryFixedDim(){return this.getArgb(o.primaryFixedDim)}get onPrimaryFixed(){return this.getArgb(o.onPrimaryFixed)}get onPrimaryFixedVariant(){return this.getArgb(o.onPrimaryFixedVariant)}get secondaryFixed(){return this.getArgb(o.secondaryFixed)}get secondaryFixedDim(){return this.getArgb(o.secondaryFixedDim)}get onSecondaryFixed(){return this.getArgb(o.onSecondaryFixed)}get onSecondaryFixedVariant(){return this.getArgb(o.onSecondaryFixedVariant)}get tertiaryFixed(){return this.getArgb(o.tertiaryFixed)}get tertiaryFixedDim(){return this.getArgb(o.tertiaryFixedDim)}get onTertiaryFixed(){return this.getArgb(o.onTertiaryFixed)}get onTertiaryFixedVariant(){return this.getArgb(o.onTertiaryFixedVariant)}}/**
* @license
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class at{constructor(e){this.input=e,this.hctsByTempCache=[],this.hctsByHueCache=[],this.tempsByHctCache=new Map,this.inputRelativeTemperatureCache=-1,this.complementCache=null}get hctsByTemp(){if(this.hctsByTempCache.length>0)return this.hctsByTempCache;const e=this.hctsByHue.concat([this.input]),r=this.tempsByHct;return e.sort((n,a)=>r.get(n)-r.get(a)),this.hctsByTempCache=e,e}get warmest(){return this.hctsByTemp[this.hctsByTemp.length-1]}get coldest(){return this.hctsByTemp[0]}analogous(e=5,r=12){const n=Math.round(this.input.hue),a=this.hctsByHue[n];let i=this.relativeTemperature(a);const u=[a];let l=0;for(let s=0;s<360;s++){const h=kt(n+s),y=this.hctsByHue[h],p=this.relativeTemperature(y),A=Math.abs(p-i);i=p,l+=A}let m=1;const M=l/r;let d=0;for(i=this.relativeTemperature(a);u.length<r;){const s=kt(n+m),h=this.hctsByHue[s],y=this.relativeTemperature(h),p=Math.abs(y-i);d+=p;const A=u.length*M;let b=d>=A,R=1;for(;b&&u.length<r;){u.push(h);const g=(u.length+R)*M;b=d>=g,R++}if(i=y,m++,m>360){for(;u.length<r;)u.push(h);break}}const w=[this.input],f=Math.floor((e-1)/2);for(let s=1;s<f+1;s++){let h=0-s;for(;h<0;)h=u.length+h;h>=u.length&&(h=h%u.length),w.splice(0,0,u[h])}const c=e-f-1;for(let s=1;s<c+1;s++){let h=s;for(;h<0;)h=u.length+h;h>=u.length&&(h=h%u.length),w.push(u[h])}return w}get complement(){if(this.complementCache!=null)return this.complementCache;const e=this.coldest.hue,r=this.tempsByHct.get(this.coldest),n=this.warmest.hue,i=this.tempsByHct.get(this.warmest)-r,u=at.isBetween(this.input.hue,e,n),l=u?n:e,m=u?e:n,M=1;let d=1e3,w=this.hctsByHue[Math.round(this.input.hue)];const f=1-this.inputRelativeTemperature;for(let c=0;c<=360;c+=1){const s=W(l+M*c);if(!at.isBetween(s,l,m))continue;const h=this.hctsByHue[Math.round(s)],y=(this.tempsByHct.get(h)-r)/i,p=Math.abs(f-y);p<d&&(d=p,w=h)}return this.complementCache=w,this.complementCache}relativeTemperature(e){const r=this.tempsByHct.get(this.warmest)-this.tempsByHct.get(this.coldest),n=this.tempsByHct.get(e)-this.tempsByHct.get(this.coldest);return r===0?.5:n/r}get inputRelativeTemperature(){return this.inputRelativeTemperatureCache>=0?this.inputRelativeTemperatureCache:(this.inputRelativeTemperatureCache=this.relativeTemperature(this.input),this.inputRelativeTemperatureCache)}get tempsByHct(){if(this.tempsByHctCache.size>0)return this.tempsByHctCache;const e=this.hctsByHue.concat([this.input]),r=new Map;for(const n of e)r.set(n,at.rawTemperature(n));return this.tempsByHctCache=r,r}get hctsByHue(){if(this.hctsByHueCache.length>0)return this.hctsByHueCache;const e=[];for(let r=0;r<=360;r+=1){const n=_.from(r,this.input.chroma,this.input.tone);e.push(n)}return this.hctsByHueCache=e,this.hctsByHueCache}static isBetween(e,r,n){return r<n?r<=e&&e<=n:r<=e||e<=n}static rawTemperature(e){const r=Ht(e.toInt()),n=W(Math.atan2(r[2],r[1])*180/Math.PI),a=Math.sqrt(r[1]*r[1]+r[2]*r[2]);return-.5+.02*Math.pow(a,1.07)*Math.cos(W(n-50)*Math.PI/180)}}/**
* @license
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class Wt extends V{constructor(e,r,n){super({sourceColorArgb:e.toInt(),variant:q.CONTENT,contrastLevel:n,isDark:r,primaryPalette:k.fromHueAndChroma(e.hue,e.chroma),secondaryPalette:k.fromHueAndChroma(e.hue,Math.max(e.chroma-32,e.chroma*.5)),tertiaryPalette:k.fromInt(ct.fixIfDisliked(new at(e).analogous(3,6)[2]).toInt()),neutralPalette:k.fromHueAndChroma(e.hue,e.chroma/8),neutralVariantPalette:k.fromHueAndChroma(e.hue,e.chroma/8+4)})}}/**
* @license
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class $ extends V{constructor(e,r,n){super({sourceColorArgb:e.toInt(),variant:q.EXPRESSIVE,contrastLevel:n,isDark:r,primaryPalette:k.fromHueAndChroma(W(e.hue+240),40),secondaryPalette:k.fromHueAndChroma(V.getRotatedHue(e,$.hues,$.secondaryRotations),24),tertiaryPalette:k.fromHueAndChroma(V.getRotatedHue(e,$.hues,$.tertiaryRotations),32),neutralPalette:k.fromHueAndChroma(e.hue+15,8),neutralVariantPalette:k.fromHueAndChroma(e.hue+15,12)})}}$.hues=[0,21,51,121,151,191,271,321,360];$.secondaryRotations=[45,95,45,20,45,90,45,45,45];$.tertiaryRotations=[120,120,20,45,20,15,20,120,120];/**
* @license
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class It extends V{constructor(e,r,n){super({sourceColorArgb:e.toInt(),variant:q.FIDELITY,contrastLevel:n,isDark:r,primaryPalette:k.fromHueAndChroma(e.hue,e.chroma),secondaryPalette:k.fromHueAndChroma(e.hue,Math.max(e.chroma-32,e.chroma*.5)),tertiaryPalette:k.fromInt(ct.fixIfDisliked(new at(e).complement).toInt()),neutralPalette:k.fromHueAndChroma(e.hue,e.chroma/8),neutralVariantPalette:k.fromHueAndChroma(e.hue,e.chroma/8+4)})}}/**
* @license
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class Xt extends V{constructor(e,r,n){super({sourceColorArgb:e.toInt(),variant:q.FRUIT_SALAD,contrastLevel:n,isDark:r,primaryPalette:k.fromHueAndChroma(W(e.hue-50),48),secondaryPalette:k.fromHueAndChroma(W(e.hue-50),36),tertiaryPalette:k.fromHueAndChroma(e.hue,36),neutralPalette:k.fromHueAndChroma(e.hue,10),neutralVariantPalette:k.fromHueAndChroma(e.hue,16)})}}/**
* @license
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class Jt extends V{constructor(e,r,n){super({sourceColorArgb:e.toInt(),variant:q.MONOCHROME,contrastLevel:n,isDark:r,primaryPalette:k.fromHueAndChroma(e.hue,0),secondaryPalette:k.fromHueAndChroma(e.hue,0),tertiaryPalette:k.fromHueAndChroma(e.hue,0),neutralPalette:k.fromHueAndChroma(e.hue,0),neutralVariantPalette:k.fromHueAndChroma(e.hue,0)})}}/**
* @license
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class $t extends V{constructor(e,r,n){super({sourceColorArgb:e.toInt(),variant:q.NEUTRAL,contrastLevel:n,isDark:r,primaryPalette:k.fromHueAndChroma(e.hue,12),secondaryPalette:k.fromHueAndChroma(e.hue,8),tertiaryPalette:k.fromHueAndChroma(e.hue,16),neutralPalette:k.fromHueAndChroma(e.hue,2),neutralVariantPalette:k.fromHueAndChroma(e.hue,2)})}}/**
* @license
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class Qt extends V{constructor(e,r,n){super({sourceColorArgb:e.toInt(),variant:q.RAINBOW,contrastLevel:n,isDark:r,primaryPalette:k.fromHueAndChroma(e.hue,48),secondaryPalette:k.fromHueAndChroma(e.hue,16),tertiaryPalette:k.fromHueAndChroma(W(e.hue+60),24),neutralPalette:k.fromHueAndChroma(e.hue,0),neutralVariantPalette:k.fromHueAndChroma(e.hue,0)})}}/**
* @license
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class Zt extends V{constructor(e,r,n){super({sourceColorArgb:e.toInt(),variant:q.TONAL_SPOT,contrastLevel:n,isDark:r,primaryPalette:k.fromHueAndChroma(e.hue,36),secondaryPalette:k.fromHueAndChroma(e.hue,16),tertiaryPalette:k.fromHueAndChroma(W(e.hue+60),24),neutralPalette:k.fromHueAndChroma(e.hue,6),neutralVariantPalette:k.fromHueAndChroma(e.hue,8)})}}/**
* @license
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/class Q extends V{constructor(e,r,n){super({sourceColorArgb:e.toInt(),variant:q.VIBRANT,contrastLevel:n,isDark:r,primaryPalette:k.fromHueAndChroma(e.hue,200),secondaryPalette:k.fromHueAndChroma(V.getRotatedHue(e,Q.hues,Q.secondaryRotations),24),tertiaryPalette:k.fromHueAndChroma(V.getRotatedHue(e,Q.hues,Q.tertiaryRotations),32),neutralPalette:k.fromHueAndChroma(e.hue,10),neutralVariantPalette:k.fromHueAndChroma(e.hue,12)})}}Q.hues=[0,41,61,101,131,181,251,301,360];Q.secondaryRotations=[18,15,10,12,15,18,15,12,12];Q.tertiaryRotations=[35,30,20,25,30,35,30,25,25];/**
* @license
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function te(t){const e=bt(t),r=Pt(t),n=Mt(t),a=[e.toString(16),r.toString(16),n.toString(16)];for(const[i,u]of a.entries())u.length===1&&(a[i]="0"+u);return"#"+a.join("")}function ee(t){t=t.replace("#","");const e=t.length===3,r=t.length===6,n=t.length===8;if(!e&&!r&&!n)throw new Error("unexpected hex "+t);let a=0,i=0,u=0;return e?(a=J(t.slice(0,1).repeat(2)),i=J(t.slice(1,2).repeat(2)),u=J(t.slice(2,3).repeat(2))):r?(a=J(t.slice(0,2)),i=J(t.slice(2,4)),u=J(t.slice(4,6))):n&&(a=J(t.slice(2,4)),i=J(t.slice(4,6)),u=J(t.slice(6,8))),(255<<24|(a&255)<<16|(i&255)<<8|u&255)>>>0}function J(t){return parseInt(t,16)}const re={default:0,medium:.5,high:1,reduced:-1};function ne(t,e,r,n,a){switch(e){case"monochrome":return new Jt(t,r,n);case"neutral":return new $t(t,r,n);case"tonal_spot":return new Zt(t,r,n);case"vibrant":return new Q(t,r,n);case"expressive":return new $(t,r,n);case"fidelity":return new It(t,r,n);case"content":return new Wt(t,r,n);case"rainbow":return new Qt(t,r,n);case"fruit_salad":return new Xt(t,r,n);case"image_fidelity":const i=new It(t,r,n);return new V({sourceColorArgb:i.sourceColorArgb,variant:i.variant,isDark:i.isDark,contrastLevel:i.contrastLevel,primaryPalette:k.fromInt(a[0]??i.primaryPaletteKeyColor),secondaryPalette:k.fromInt(a[1]??i.secondaryPaletteKeyColor),tertiaryPalette:k.fromInt(a[2]??i.tertiaryPaletteKeyColor),neutralPalette:i.neutralPalette,neutralVariantPalette:i.neutralVariantPalette})}}const ae=["primary","onPrimary","primaryContainer","onPrimaryContainer","secondary","onSecondary","secondaryContainer","onSecondaryContainer","tertiary","onTertiary","tertiaryContainer","onTertiaryContainer","error","onError","errorContainer","onErrorContainer","background","onBackground","surface","onSurface","surfaceVariant","onSurfaceVariant","outline","outlineVariant","shadow","scrim","inverseSurface","inverseOnSurface","inversePrimary"];var rt={naturalOrder:function(e,r){return e<r?-1:e>r?1:0},sum:function(e){return e.reduce(function(r,n){return r+n},0)},max:function(e){return Math.max.apply(null,e)}},oe=function(){function t(r){this.colors=r}var e=t.prototype;return e.palette=function(){return this.colors},e.map=function(n){return n},t}(),se=function(){var t=5,e=8-t,r=1e3,n=.75;function a(f,c,s){return(f<<2*t)+(c<<t)+s}function i(f){var c=[],s=!1;function h(){c.sort(f),s=!0}return{push:function(p){c.push(p),s=!1},peek:function(p){return s||h(),p===void 0&&(p=c.length-1),c[p]},pop:function(){return s||h(),c.pop()},size:function(){return c.length},map:function(p){return c.map(p)},debug:function(){return s||h(),c}}}function u(f,c,s,h,y,p,A){var b=this;b.r1=f,b.r2=c,b.g1=s,b.g2=h,b.b1=y,b.b2=p,b.histo=A}u.prototype={volume:function(c){var s=this;return(!s._volume||c)&&(s._volume=(s.r2-s.r1+1)*(s.g2-s.g1+1)*(s.b2-s.b1+1)),s._volume},count:function(c){var s=this,h=s.histo;if(!s._count_set||c){var y=0,p,A,b,R;for(p=s.r1;p<=s.r2;p++)for(A=s.g1;A<=s.g2;A++)for(b=s.b1;b<=s.b2;b++)R=a(p,A,b),y+=h[R]||0;s._count=y,s._count_set=!0}return s._count},copy:function(){var c=this;return new u(c.r1,c.r2,c.g1,c.g2,c.b1,c.b2,c.histo)},avg:function(c){var s=this,h=s.histo;if(!s._avg||c){var y=0,p=1<<8-t,A=0,b=0,R=0,g,T,C,F,B;if(s.r1===s.r2&&s.g1===s.g2&&s.b1===s.b2)s._avg=[s.r1<<e,s.g1<<e,s.b1<<e];else{for(T=s.r1;T<=s.r2;T++)for(C=s.g1;C<=s.g2;C++)for(F=s.b1;F<=s.b2;F++)B=a(T,C,F),g=h[B]||0,y+=g,A+=g*(T+.5)*p,b+=g*(C+.5)*p,R+=g*(F+.5)*p;y?s._avg=[~~(A/y),~~(b/y),~~(R/y)]:s._avg=[~~(p*(s.r1+s.r2+1)/2),~~(p*(s.g1+s.g2+1)/2),~~(p*(s.b1+s.b2+1)/2)]}}return s._avg},contains:function(c){var s=this,h=c[0]>>e;return gval=c[1]>>e,bval=c[2]>>e,h>=s.r1&&h<=s.r2&&gval>=s.g1&&gval<=s.g2&&bval>=s.b1&&bval<=s.b2}};function l(){this.vboxes=new i(function(f,c){return rt.naturalOrder(f.vbox.count()*f.vbox.volume(),c.vbox.count()*c.vbox.volume())})}l.prototype={push:function(c){this.vboxes.push({vbox:c,color:c.avg()})},palette:function(){return this.vboxes.map(function(c){return c.color})},size:function(){return this.vboxes.size()},map:function(c){for(var s=this.vboxes,h=0;h<s.size();h++)if(s.peek(h).vbox.contains(c))return s.peek(h).color;return this.nearest(c)},nearest:function(c){for(var s=this.vboxes,h,y,p,A=0;A<s.size();A++)y=Math.sqrt(Math.pow(c[0]-s.peek(A).color[0],2)+Math.pow(c[1]-s.peek(A).color[1],2)+Math.pow(c[2]-s.peek(A).color[2],2)),(y<h||h===void 0)&&(h=y,p=s.peek(A).color);return p},forcebw:function(){var c=this.vboxes;c.sort(function(p,A){return rt.naturalOrder(rt.sum(p.color),rt.sum(A.color))});var s=c[0].color;s[0]<5&&s[1]<5&&s[2]<5&&(c[0].color=[0,0,0]);var h=c.length-1,y=c[h].color;y[0]>251&&y[1]>251&&y[2]>251&&(c[h].color=[255,255,255])}};function m(f){var c=1<<3*t,s=new Array(c),h,y,p,A;return f.forEach(function(b){y=b[0]>>e,p=b[1]>>e,A=b[2]>>e,h=a(y,p,A),s[h]=(s[h]||0)+1}),s}function M(f,c){var s=1e6,h=0,y=1e6,p=0,A=1e6,b=0,R,g,T;return f.forEach(function(C){R=C[0]>>e,g=C[1]>>e,T=C[2]>>e,R<s?s=R:R>h&&(h=R),g<y?y=g:g>p&&(p=g),T<A?A=T:T>b&&(b=T)}),new u(s,h,y,p,A,b,c)}function d(f,c){if(!c.count())return;var s=c.r2-c.r1+1,h=c.g2-c.g1+1,y=c.b2-c.b1+1,p=rt.max([s,h,y]);if(c.count()==1)return[c.copy()];var A=0,b=[],R=[],g,T,C,F,B;if(p==s)for(g=c.r1;g<=c.r2;g++){for(F=0,T=c.g1;T<=c.g2;T++)for(C=c.b1;C<=c.b2;C++)B=a(g,T,C),F+=f[B]||0;A+=F,b[g]=A}else if(p==h)for(g=c.g1;g<=c.g2;g++){for(F=0,T=c.r1;T<=c.r2;T++)for(C=c.b1;C<=c.b2;C++)B=a(T,g,C),F+=f[B]||0;A+=F,b[g]=A}else for(g=c.b1;g<=c.b2;g++){for(F=0,T=c.r1;T<=c.r2;T++)for(C=c.g1;C<=c.g2;C++)B=a(T,C,g),F+=f[B]||0;A+=F,b[g]=A}b.forEach(function(z,L){R[L]=A-z});function x(z){var L=z+"1",O=z+"2",v,j,G,K,U,et=0;for(g=c[L];g<=c[O];g++)if(b[g]>A/2){for(G=c.copy(),K=c.copy(),v=g-c[L],j=c[O]-g,v<=j?U=Math.min(c[O]-1,~~(g+j/2)):U=Math.max(c[L],~~(g-1-v/2));!b[U];)U++;for(et=R[U];!et&&b[U-1];)et=R[--U];return G[O]=U,K[L]=G[O]+1,[G,K]}}return p==s?x("r"):p==h?x("g"):x("b")}function w(f,c){if(!Number.isInteger(c)||c<1||c>256)throw new Error("Invalid maximum color count. It must be an integer between 1 and 256.");if(!f.length||c<2||c>256||!f.length||c<2||c>256)return!1;for(var s=[],h=new Set,y=0;y<f.length;y++){var p=f[y],A=p.join(",");h.has(A)||(h.add(A),s.push(p))}if(s.length<=c)return new oe(s);var b=m(f);b.forEach(function(){});var R=M(f,b),g=new i(function(B,x){return rt.naturalOrder(B.count(),x.count())});g.push(R);function T(B,x){for(var z=B.size(),L=0,O;L<r;){if(z>=x||L++>r)return;if(O=B.pop(),!O.count()){B.push(O),L++;continue}var v=d(b,O),j=v[0],G=v[1];if(!j)return;B.push(j),G&&(B.push(G),z++)}}T(g,n*c);for(var C=new i(function(B,x){return rt.naturalOrder(B.count()*B.volume(),x.count()*x.volume())});g.size();)C.push(g.pop());T(C,c);for(var F=new l;C.size();)F.push(C.pop());return F}return{quantize:w}}(),ie=se.quantize;function Rt(t,e=3){const r=[];for(let n=0;n<t.length;n+=4){const a=t[n],i=t[n+1],u=t[n+2];t[n+3]<255||r.push([a,i,u])}try{const n=ie(r,e);return n?n.palette().map(([i,u,l])=>lt(i,u,l)).slice(0,e):[]}catch(n){return console.error(n),[]}}async function ce(t,e=3,r){const n=r&&r.length>0&&r.length<9,a=await new Promise((i,u)=>{const l=document.createElement("canvas"),m=l.getContext("2d",{willReadFrequently:n});if(!m){u(new Error("Could not get canvas context"));return}const M=()=>{if(l.width=t.width,l.height=t.height,m.drawImage(t,0,0),n){const p=t.width/3,A=t.height/3,b=[];for(const R of r){const g=Math.floor((R-1)/3),C=(R-1)%3*p,F=g*A,B=m.getImageData(C,F,p,A).data;for(let x=0;x<B.length;x++)b.push(B[x])}i(new Uint8ClampedArray(b));return}let w=[0,0,t.width,t.height];const f=t.dataset.area;f&&/^\d+(\s*,\s*\d+){3}$/.test(f)&&(w=f.split(/\s*,\s*/).map(p=>parseInt(p,10)));const[c,s,h,y]=w;i(m.getImageData(c,s,h,y).data)},d=()=>{u(new Error("Image load failed"))};t.complete?M():(t.onload=M,t.onerror=d)});return Rt(a,e)}function ue(){return typeof window!="object"?!1:!!window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}function he(t){return"#"+t.replace(/^rgba?\(|\s+|\)$/g,"").split(",").map(e=>parseFloat(e)).map((e,r)=>r===3?Math.round(e*255):e).map(e=>e.toString(16)).map(e=>e.length===1?"0"+e:e).join("")}const le=/(http|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])/,fe=/^rgba?/i;async function xt({source:t,...e}){const r=e.variant??"fidelity",n=re[e.contrastLevel??"default"],a=e.isDark??ue();let i,u=[];if(typeof t=="number")i=t;else if(le.test(t)){const w=await(e.imageFetcher??(()=>{if(typeof window>"u"||typeof document>"u")throw new Error("Image URLs can only be processed on the client-side unless a custom `imageFetcher` is provided.");return async f=>{const s=await(await fetch(f)).blob(),h=document.createElement("img");h.src=URL.createObjectURL(s);try{return await ce(h,3,e.grid)}finally{URL.revokeObjectURL(h.src)}}})())(t);i=w[0],u=w}else{let d=t;fe.test(t)&&(d=he(t)),d.startsWith("#")&&(i=ee(d))}if(i===void 0)return null;const l=_.fromInt(i),m=ne(l,r,a,n,u);return ae.reduce((d,w)=>(d[w]=te(m[w]),d),{})}function me(t,e){const[r,n]=gt.useState(""),[a,i]=gt.useState(null),u=JSON.stringify(e);return gt.useEffect(()=>{let l=!1;return n("loading"),xt({source:t,...e}).then(m=>{l||(i(m),n(m?"done":""))}).catch(m=>{l||(n("error"),i(null))}),()=>{l=!0}},[t,u]),[a,r]}exports.findDominantColorsFromPixelData=Rt;exports.getMaterialYouScheme=xt;exports.useMaterialYou=me;
//# sourceMappingURL=index.cjs.js.map