-
Notifications
You must be signed in to change notification settings - Fork 1
/
DynamicColors.js
14 lines (14 loc) · 25.3 KB
/
DynamicColors.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/**
* **Dynamic Colors** from KPVERSE
*
* v1.1.5
*
* Updated on August 6, 2023.
*
* Copyright © 2023-present, Kartavya Patel. All rights reserved.
*
* @author Kartavya Patel <[email protected]>
*
* @license {@link https://github.com/patelka2211/dynamic-colors/blob/main/LICENSE MIT}
*/
!function(){"use strict";var t,r,n;function e(r){t=r}function o(t){n=t}function i(t){if(3===(t=t.replace("#","")).length||6===t.length){3===t.length&&(t=t.split("").map((function(t){return t+t})).join(""));var r=["r","g","b"].map((function(){var r=2*arguments[1];return parseInt(t.slice(r,r+2),16)}));return{r:r[0],g:r[1],b:r[2]}}}function a(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var e,o,i,a,u=[],c=!0,s=!1;try{if(i=(n=n.call(t)).next,0===r){if(Object(n)!==n)return;c=!1}else for(;!(c=(e=i.call(n)).done)&&(u.push(e.value),u.length!==r);c=!0);}catch(t){s=!0,o=t}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw o}}return u}}(t,r)||h(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(t,r){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},u(t,r)}function c(t){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,e=s(t);if(r){var o=s(this).constructor;n=Reflect.construct(e,arguments,o)}else n=e.apply(this,arguments);return function(t,r){if(r&&("object"===l(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,n)}}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},s(t)}function l(t){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},l(t)}function f(t){return function(t){if(Array.isArray(t))return p(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||h(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(t,r){if(t){if("string"==typeof t)return p(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?p(t,r):void 0}}function p(t,r){(null==r||r>t.length)&&(r=t.length);for(var n=0,e=new Array(r);n<r;n++)e[n]=t[n];return e}function F(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")}function y(t,r){for(var n=0;n<r.length;n++){var e=r[n];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,v(e.key),e)}}function d(t,r,n){return r&&y(t.prototype,r),n&&y(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function v(t){var r=function(t,r){if("object"!==l(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var e=n.call(t,r||"default");if("object"!==l(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"===l(r)?r:String(r)}function m(t,r){return(null==t?void 0:t.toUpperCase())===(null==r?void 0:r.toUpperCase())}function b(t){try{return function(t){var r,n=(65280&t)>>8,e=255&t,o=[((16711680&t)>>16).toString(16),n.toString(16),e.toString(16)],i=function(t,r){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=h(t))||r&&t&&"number"==typeof t.length){n&&(t=n);var e=0,o=function(){};return{s:o,n:function(){return e>=t.length?{done:!0}:{done:!1,value:t[e++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}(o.entries());try{for(i.s();!(r=i.n()).done;){var u=a(r.value,2),c=u[0],s=u[1],l=c,f=s;1===f.length&&(o[l]="0"+f)}}catch(t){i.e(t)}finally{i.f()}return"#"+o.join("")}(t)}catch(t){return"#000000"}}function g(t,r,n){var e,o=null!==(e=t.props.overrides.tonalGroups)&&void 0!==e?e:{},i=Object(o)[r];return X.is1p&&!t.props.isBaseline||!i?function(t){var r={};return[100,99,98,95,90,80,70,60,50,40,35,30,25,20,10,0].forEach((function(n){r["luminance".concat(n)]=b(t.tone(n))})),r}(n):i}function E(t,r){var n=new Map;return[100,99,98,95,90,80,70,60,50,40,35,30,25,20,10,0].forEach((function(e){n.set("".concat(t,"-").concat(e),r["luminance".concat(e)])})),n}function w(t){var r=(t+16)/116,n=24389/27,e=r*r*r>216/24389,o=[(e?r*r*r:(116*r-16)/n)*U[0],(8<t?r*r*r:t/n)*U[1],(e?r*r*r:(116*r-16)/n)*U[2]];return D(o[0],o[1],o[2])}function C(t,r,n,e,o){return null!==(t=null==e?void 0:e[r])&&void 0!==t?t:o.get(n)}function M(t){return.0031308>=t?12.92*t:1.055*Math.pow(t,1/2.4)-.055}function D(t,r,n){return t/=100,r/=100,n/=100,function(t){return(-16777216|(255&t[0])<<16|(255&t[1])<<8|255&t[2])>>>0}([Math.round(B(255,255*M(3.2406*t+-1.5372*r+-.4986*n))),Math.round(B(255,255*M(-.9689*t+1.8758*r+.0415*n))),Math.round(B(255,255*M(.0557*t+-.204*r+1.057*n)))])}function k(t,r,n){var e=n*Math.PI/180,o=1/.0228*Math.log(1+.0228*r*z.fLRoot);return new L(n,r,t,4/z.c*Math.sqrt(t/100)*(z.aw+4)*z.fLRoot,50*Math.sqrt(r/Math.sqrt(t/100)*z.c/(z.aw+4)),(1+100*.007)*t/(1+.007*t),o*Math.cos(e),o*Math.sin(e))}function A(t){var r=Math.pow((0===t.chroma||0===t.j?0:t.chroma/Math.sqrt(t.j/100))/Math.pow(1.64-Math.pow(.29,z.n),.73),1/.9),n=t.hue*Math.PI/180,e=z.aw*Math.pow(t.j/100,1/z.c/z.z)/z.nbb,o=Math.sin(n),i=Math.cos(n),a=23*(e+.305)*r/(5e4/13*(Math.cos(n+2)+3.8)*5.75*z.nc*z.ncb+11*r*i+108*r*o),u=a*i,c=a*o,s=(460*e+451*u+288*c)/1403,l=(460*e-891*u-261*c)/1403,f=(460*e-220*u-6300*c)/1403,h=100/z.fl*j(s)*Math.pow(Math.max(0,27.13*Math.abs(s)/(400-Math.abs(s))),1/.42)/z.rgbD[0],p=100/z.fl*j(l)*Math.pow(Math.max(0,27.13*Math.abs(l)/(400-Math.abs(l))),1/.42)/z.rgbD[1],F=100/z.fl*j(f)*Math.pow(Math.max(0,27.13*Math.abs(f)/(400-Math.abs(f))),1/.42)/z.rgbD[2];return D(1.86206786*h-1.01125463*p+.14918677*F,.38752654*h+.62144744*p-.00897398*F,-.0158415*h-.03412294*p+1.04996444*F)}function B(t,r){return Math.min(Math.max(r,0),t)}function S(t){return 0>t?t%360+360:360<=t?t%360:t}function T(t,r,n){if(1>r||0>=Math.round(n)||100<=Math.round(n))return w(n);t=S(t);for(var e=r,o=r,i=0,a=!0,u=null;.4<=Math.abs(i-e);){for(var c=t,s=o,l=n,f=0,h=100,p=void 0,F=1e3,y=1e3,d=null;.01<Math.abs(f-h);){var v=A(k(p=f+(h-f)/2,s,c)),m=P(v),b=Math.abs(l-m);if(.2>b){var g=N(v),E=g.distance(k(g.j,g.chroma,c));1>=E&&E<=y&&(F=b,y=E,d=g)}if(0===F&&0===y)break;m<l?f=p:h=p}var C=d;if(a){if(null!=C)return A(C);a=!1}else null===C?e=o:(u=C,i=o);o=i+(e-i)/2}return null===u?w(n):A(u)}function I(t,r){var n=N(r),e=P(r);t.internalHue=n.hue,t.internalChroma=n.chroma,t.internalTone=e}function P(t){var r=21.26*O(((16711680&t)>>16)/255)+71.52*O(((65280&t)>>8)/255)+7.22*O((255&t)/255);return(r/=100)<=216/24389?24389/27*r:116*Math.pow(r,1/3)-16}function j(t){return 0>t?-1:0===t?0:1}function O(t){return.04045>=t?t/12.92:Math.pow((t+.055)/1.055,2.4)}function N(t){var r=100*O(((16711680&t)>>16)/255),n=100*O(((65280&t)>>8)/255),e=100*O((255&t)/255),o=.41233895*r+.35762064*n+.18051042*e,i=.2126*r+.7152*n+.0722*e,a=.01932141*r+.11916382*n+.95034478*e,u=z.rgbD[0]*(.401288*o+.650173*i-.051461*a),c=z.rgbD[1]*(-.250268*o+1.204414*i+.045854*a),s=z.rgbD[2]*(-.002079*o+.048952*i+.953127*a),l=Math.pow(z.fl*Math.abs(u)/100,.42),f=Math.pow(z.fl*Math.abs(c)/100,.42),h=Math.pow(z.fl*Math.abs(s)/100,.42),p=400*j(u)*l/(l+27.13),F=400*j(c)*f/(f+27.13),y=400*j(s)*h/(h+27.13),d=(11*p+-12*F+y)/11,v=(p+F-2*y)/9,m=180*Math.atan2(v,d)/Math.PI,b=0>m?m+360:360<=m?m-360:m,g=b*Math.PI/180,E=100*Math.pow((40*p+20*F+y)/20*z.nbb/z.aw,z.c*z.z),w=Math.pow(5e4/13*.25*(Math.cos((20.14>b?b+360:b)*Math.PI/180+2)+3.8)*z.nc*z.ncb*Math.sqrt(d*d+v*v)/((20*p+20*F+21*y)/20+.305),.9)*Math.pow(1.64-Math.pow(.29,z.n),.73),C=w*Math.sqrt(E/100),M=1/.0228*Math.log(1+.0228*C*z.fLRoot);return new L(b,C,E,4/z.c*Math.sqrt(E/100)*(z.aw+4)*z.fLRoot,50*Math.sqrt(w*z.c/(z.aw+4)),(1+100*.007)*E/(1+.007*E),M*Math.cos(g),M*Math.sin(g))}function V(t){var r=X.is3p,n=new W(function(t){var r=3===(t=t.replace("#","")).length,n=6===t.length,e=8===t.length;if(!r&&!n&&!e)throw Error("unexpected hex "+t);var o=0,i=0,a=0;return r?(o=parseInt(t.slice(0,1).repeat(2),16),i=parseInt(t.slice(1,2).repeat(2),16),a=parseInt(t.slice(2,3).repeat(2),16)):n?(o=parseInt(t.slice(0,2),16),i=parseInt(t.slice(2,4),16),a=parseInt(t.slice(4,6),16)):e&&(o=parseInt(t.slice(2,4),16),i=parseInt(t.slice(4,6),16),a=parseInt(t.slice(6,8),16)),(-16777216|(255&o)<<16|(255&i)<<8|255&a)>>>0}(t));return new R({tones:n,seed:t,is3p:r,overrides:{},blend:!1,isBaseline:!1})}var x={light:{background:"#FFFFFF",surface:"#FFFFFF"},dark:{},neutral:{},neutralVariant:{},primary:{},secondary:{},tertiary:{},error:{}};[[100,"#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF"],[99,"#FDFCFB","#FAFDFB","#FAFBFF","#F7FCFF","#F2FFEE","#FFFBF9"],[98,"#FAF9F9","#F8FAF8","#F8F9FF","#E3FFF6","#E8FFE7","#FFF8F6"],[95,"#F2F2F2","#EFF2EF","#ECF3FE","#DFF3FF","#E7F8ED","#FCEEEE"],[90,"#E3E3E3","#E1E3E1","#D3E3FD","#C2E7FF","#C4EED0","#F9DEDC"],[80,"#C7C7C7","#C4C7C5","#A8C7FA","#7FCFFF","#6DD58C","#F2B8B5"],[70,"#ABABAB","#A9ACAA","#7CACF8","#5AB3F0","#37BE5F","#EC928E"],[60,"#8F8F8F","#8E918F","#4C8DF6","#3998D3","#1EA446","#E46962"],[50,"#757575","#747775","#1B6EF3","#047DB7","#198639","#DC362E"],[40,"#5E5E5E","#5C5F5E","#0B57D0","#00639B","#146C2E","#B3261E"],[35,"#525252","#4F5351","#155298","#005E4E","#006024","#833D3B"],[30,"#474747","#444746","#0842A0","#004A77","#0F5223","#8C1D18"],[25,"#3A3C3C","#393C3B","#003B77","#004438","#004618","#662726"],[20,"#303030","#2D312F","#062E6F","#003355","#0A3818","#601410"],[10,"#1F1F1F","#191D1C","#041E49","#001D35","#072711","#410E0B"],[0,"#000000","#000000","#000000","#000000","#000000","#000000"]].forEach((function(t){var r="luminance".concat(t[0]);x.neutral[r]=t[1],x.neutralVariant[r]=t[2],x.primary[r]=t[3],x.secondary[r]=t[4],x.tertiary[r]=t[5],x.error[r]=t[6]}));var G={light:{},dark:{},neutral:{},neutralVariant:{},primary:{},secondary:{},tertiary:{}};G.error=x.error,[[100,"#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF","#FFFFFF"],[99,"#FFFBFE","#FFFBFE","#FFFBFE","#FFFBFE","#FFFBFA"],[98,"#FDF8FC","#FEF7FF","#FEF7FF","#FEF7FF","#FFF8F9"],[95,"#F4EFF4","#F5EEFA","#F6EDFF","#F6EDFF","#FFECF1"],[90,"#E6E1E5","#E7E0EC","#EADDFF","#E8DEF8","#FFD8E4"],[80,"#C9C5CA","#CAC4D0","#D0BCFF","#CCC2DC","#EFB8C8"],[70,"#AEAAAE","#AEA9B4","#B69DF8","#B0A7C0","#D29DAC"],[60,"#939094","#938F99","#9A82DB","#958DA5","#B58392"],[50,"#787579","#79747E","#7F67BE","#7A7289","#986977"],[40,"#605D62","#605D66","#6750A4","#625B71","#7D5260"],[35,"#545255","#54515A","#5B4497","#564F65","#704653"],[30,"#484649","#49454F","#4F378B","#4A4458","#633B48"],[25,"#3D3B3E","#3D3A43","#432B7E","#3E384D","#57303D"],[20,"#313033","#322F37","#381E72","#332D41","#492532"],[10,"#1C1B1F","#1D1A22","#21005D","#1D192B","#31111D"],[0,"#000000","#000000","#000000","#000000","#000000"]].forEach((function(t){var r="luminance".concat(t[0]);G.neutral[r]=t[1],G.neutralVariant[r]=t[2],G.primary[r]=t[3],G.secondary[r]=t[4],G.tertiary[r]=t[5]}));var R=function(t){function r(){return F(this,r),n.apply(this,arguments)}!function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&u(t,r)}(r,t);var n=c(r);return d(r)}(function(){function t(r){F(this,t),this.props=r}return d(t,[{key:"isBaseline",get:function(){return function(t){function r(t,r,e){var o;n&&((o=m(r.luminance0,e.luminance0))&&(o=m(r.luminance10,e.luminance10)),[20,30,40,50,60,70,80,90,95,98,100].forEach((function(t){o&&(o=m(r["luminance".concat(t)],e["luminance".concat(t)]))})),n=o)}var n=!0,e=function(t){var r,n;return"Roboto"===(null===(n=null===(r=null==t?void 0:t.styles)||void 0===r?void 0:r.headline1)||void 0===n?void 0:n.fontFamilyName)}(t)?G:x;return["primary","secondary","tertiary","neutral","neutralVariant","error"].forEach((function(n){r(0,t[n],e[n])})),n}(this.save())}},{key:"is3p",get:function(){return this.props.is3p}},{key:"imageUrl",get:function(){return this.props.imageUrl}},{key:"light",get:function(){var t,r,n,e,o,i,a,u,c,s,l,f,h,p,F,y,d,v,m,b,g,E,w,M,D,k,A,B,S,T,I=this.props.isBaseline?null===(t=X.is1p?x:G)||void 0===t?void 0:t.light:null!==(n=null===(r=this.props.overrides)||void 0===r?void 0:r.light)&&void 0!==n?n:{},P=this.palettes,j={};return[[e,"primary","P-40"],[o,"onPrimary","P-100"],[i,"primaryContainer","P-90"],[a,"onPrimaryContainer","P-10"],[u,"secondary","S-40"],[c,"onSecondary","S-100"],[s,"secondaryContainer","S-90"],[l,"onSecondaryContainer","S-10"],[f,"tertiary","T-40"],[h,"onTertiary","T-100"],[p,"tertiaryContainer","T-90"],[F,"onTertiaryContainer","T-10"],[y,"error","E-40"],[d,"errorContainer","E-90"],[v,"onError","E-100"],[m,"onErrorContainer","E-10"],[b,"background","N-99"],[g,"onBackground","N-10"],[E,"surface","N-99"],[w,"onSurface","N-10"],[M,"surfaceVariant","NV-90"],[D,"onSurfaceVariant","NV-30"],[k,"outline","NV-50"],[A,"inverseOnSurface","N-95"],[B,"inverseSurface","N-20"],[S,"inversePrimary","P-80"],[T,"shadow","N-0"]].forEach((function(t){j[t[1]]=C(t[0],t[1],t[2],I,P)})),j}},{key:"dark",get:function(){var t,r,n,e,o,i,a,u,c,s,l,f,h,p,F,y,d,v,m,b,g,E,w,M,D,k,A,B,S,T,I=this.props.isBaseline?null===(t=X.is1p?x:G)||void 0===t?void 0:t.dark:null!==(n=null===(r=this.props.overrides)||void 0===r?void 0:r.dark)&&void 0!==n?n:{},P=this.palettes,j={};return[[e,"primary","P-80"],[o,"onPrimary","P-20"],[i,"primaryContainer","P-30"],[a,"onPrimaryContainer","P-90"],[u,"secondary","S-80"],[c,"onSecondary","S-20"],[s,"secondaryContainer","S-30"],[l,"onSecondaryContainer","S-90"],[f,"tertiary","T-80"],[h,"onTertiary","T-20"],[p,"tertiaryContainer","T-30"],[F,"onTertiaryContainer","T-90"],[y,"error","E-80"],[d,"errorContainer","E-30"],[v,"onError","E-20"],[m,"onErrorContainer","E-90"],[b,"background","N-10"],[g,"onBackground","N-90"],[E,"surface","N-10"],[w,"onSurface","N-90"],[M,"surfaceVariant","NV-30"],[D,"onSurfaceVariant","NV-80"],[k,"outline","NV-60"],[A,"inverseOnSurface","N-10"],[B,"inverseSurface","N-90"],[S,"inversePrimary","P-40"],[T,"shadow","N-0"]].forEach((function(t){j[t[1]]=C(t[0],t[1],t[2],I,P)})),j}},{key:"tonalGroups",get:function(){var t=this,r={};return["primary","secondary","tertiary","neutral","neutralVariant","error"].forEach((function(n){r[n]=t["".concat(n,"Group")]})),Object.assign(r,this.props.overrides.tonalGroups)}},{key:"primaryGroup",get:function(){return g(this,"primary",this.props.tones.a1)}},{key:"secondaryGroup",get:function(){return g(this,"secondary",this.props.tones.a2)}},{key:"tertiaryGroup",get:function(){return g(this,"tertiary",this.props.tones.a3)}},{key:"neutralGroup",get:function(){return g(this,"neutral",this.props.tones.n1)}},{key:"neutralVariantGroup",get:function(){return g(this,"neutralVariant",this.props.tones.n2)}},{key:"errorGroup",get:function(){return g(this,"error",this.props.tones.error)}},{key:"primary",get:function(){return E("P",this.primaryGroup)}},{key:"secondary",get:function(){return E("S",this.secondaryGroup)}},{key:"tertiary",get:function(){return E("T",this.tertiaryGroup)}},{key:"neutral",get:function(){return E("N",this.neutralGroup)}},{key:"neutralVariant",get:function(){return E("NV",this.neutralVariantGroup)}},{key:"error",get:function(){return E("E",this.errorGroup)}},{key:"palettes",get:function(){var t=this,r=[];return["primary","secondary","tertiary","neutral","neutralVariant","error"].forEach((function(n){r=r.concat(Array.from(t[n].entries()))})),new Map(r)}},{key:"seedValue",get:function(){return this.props.seed}},{key:"source",get:function(){var t,r,n,e,o,i,a=this,u=this.palettes,c=this.props.overrides.source,s={seed:this.seedValue,imageUrl:this.imageUrl};return[[t,"primary","P"],[r,"secondary","S"],[n,"tertiary","T"],[e,"neutral","N"],[o,"neutralVariant","NV"],[i,"error","E"]].forEach((function(t){s[t[1]]=function(t,r,n){return null!==(t=null==c?void 0:c[r])&&void 0!==t?t:n}(t[0],t[1],function(t,r,n){return(null!=n?n:t.palettes).get("".concat(r,"-40"))}(a,t[2],u))})),Object.assign(Object.assign({},c),s)}},{key:"customColors",get:function(){var t,r;return f(null!==(r=null===(t=this.props.overrides)||void 0===t?void 0:t.customColors)&&void 0!==r?r:[])}},{key:"save",value:function(){return{light:this.light,dark:this.dark}}}]),t}()),_=function(){function t(r,n){var e=arguments,o=this;F(this,t),["hue","chroma"].forEach((function(t,r){o[t]=e[r]})),this.cache=new Map}return d(t,[{key:"tone",value:function(t){var r=this.cache.get(t);return void 0===r&&(r=new q(this.hue,this.chroma,t).toInt(),this.cache.set(t,r)),r}}]),t}(),q=function(){function t(){var r=arguments,n=this;F(this,t),["internalHue","internalChroma","internalTone"].forEach((function(t,e){n[t]=r[e]})),I(this,this.toInt())}return d(t,[{key:"toInt",value:function(){return T(S(this.internalHue),this.internalChroma,B(100,this.internalTone))}},{key:"hue",get:function(){return this.internalHue},set:function(t){I(this,T(S(S(t)),this.internalChroma,B(100,this.internalTone)))}},{key:"chroma",get:function(){return this.internalChroma},set:function(t){I(this,T(S(this.internalHue),t,B(100,this.internalTone)))}},{key:"tone",get:function(){return this.internalTone},set:function(t){I(this,T(S(this.internalHue),this.internalChroma,B(100,t)))}}]),t}(),L=function(){function t(){var r=arguments,n=this;F(this,t),["hue","chroma","j","q","s","jstar","astar","bstar"].forEach((function(t,e){n[t]=r[e]}))}return d(t,[{key:"distance",value:function(t){var r=this.jstar-t.jstar,n=this.astar-t.astar,e=this.bstar-t.bstar;return 1.41*Math.pow(Math.sqrt(r*r+n*n+e*e),.63)}}]),t}(),H=d((function t(){var r=arguments,n=this;F(this,t),["n","aw","nbb","ncb","c","nc","rgbD","fl","fLRoot","z"].forEach((function(t,e){n[t]=r[e]}))})),U=[95.047,100,108.883],z=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:U,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:200/Math.PI*100*Math.pow(66/116,3)/100,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:50,e=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4],i=.401288*t[0]+.650173*t[1]+-.051461*t[2],a=-.250268*t[0]+1.204414*t[1]+.045854*t[2],u=-.002079*t[0]+.048952*t[1]+.953127*t[2],c=.8+e/10;if(.9<=c)var s=10*(c-.9),l=.59*(1-s)+.69*s;else{var f=10*(c-.8);l=.525*(1-f)+.59*f}var h=o?1:c*(1-1/3.6*Math.exp((-r-42)/92)),p=[100/i*(h=1<h?1:0>h?0:h)+1-h,100/a*h+1-h,100/u*h+1-h],F=1/(5*r+1),y=F*F*F*F,d=1-y,v=y*r+.1*d*d*Math.cbrt(5*r),m=(8<n?100*Math.pow((n+16)/116,3):n/(24389/27)*100)/t[1],b=.725/Math.pow(m,.2),g=[Math.pow(v*p[0]*i/100,.42),Math.pow(v*p[1]*a/100,.42),Math.pow(v*p[2]*u/100,.42)],E=[400*g[0]/(g[0]+27.13),400*g[1]/(g[1]+27.13),400*g[2]/(g[2]+27.13)];return new H(m,(2*E[0]+E[1]+.05*E[2])*b,b,b,l,c,p,v,Math.pow(v,.25),1.48+Math.sqrt(m))}(),W=d((function t(r){var n=this;F(this,t);var e=function(t){var r=N(t);return new q(r.hue,r.chroma,P(t))}(r),o=e.hue;[["a1",o,Math.max(48,e.chroma)],["a2",o,16],["a3",o+60,24],["n1",o,4],["n2",o,8],["error",25,84]].forEach((function(t){n[t[0]]=new _(t[1],t[2])}))})),X=new(function(){function t(){F(this,t)}return d(t,[{key:"internal",get:function(){return!1}},{key:"is3p",get:function(){return!this.internal}},{key:"is1p",get:function(){return this.internal}},{key:"enableDsp",get:function(){return!this.is1p}},{key:"enableAndroid",get:function(){return this.is1p}},{key:"enableWebExport",get:function(){return this.is3p}},{key:"enableExtendedColors",get:function(){return!0}},{key:"enableColorShift",get:function(){return this.is1p}}]),t}());function $(t,n){var e=function(t){if(/\#[a-fA-F0-9]{6}/.test(t)){var r=V(t);return{light:r.light,dark:r.dark}}return{light:{},dark:{}}}(n)[r],o="*{";for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){o+="--".concat(t,"-").concat(a,":").concat(e[a],";");var u=i(e[a]);void 0!==u&&(o+="--".concat(t,"-").concat(a,"-rgb:").concat(u.r,",").concat(u.g,",").concat(u.b,";"))}return o+="}"}X.enableDsp,X.enableAndroid,X.enableWebExport,X.enableColorShift;var J=[];var K=[];function Q(t){return t.replace("-dc","")}function Y(t){var r=K.includes(t);return r&&console.warn("Warning: The 'DynamicColors instance' named '".concat(Q(t),"' is protected and cannot be removed.")),r}function Z(t){return"".concat(t,"-dc")}var tt=function(){function t(t,r){this.id=void 0,this.styleTag=document.createElement("style");var n,e=Z(t);if(null!==document.getElementById(e))throw Error("Unable to create another 'DynamicColors' instance with the name '".concat(t,"'.\n\nTo modify the color of the tag with the name '").concat(t,"', please use the 'setColor' method on the existing instance."));this.styleTag.setAttribute("id",e),document.head.appendChild(this.styleTag),this.id=e,this.setColor(r),n=this,J.push(n)}return t.prototype.setColor=function(t){var n=function(t){if(/^#[0-9A-Fa-f]{6}$/i.test(t))return t.toLowerCase()}(t);if(!n)throw Error('"'.concat(t,'" is not valid HEX color. Only 7 length HEX color is accepted. For example: "#2596D1" or "#ffffff".'));void 0!==this.id&&(this.styleTag.innerHTML=$(this.id,n),this.styleTag.setAttribute("dc-color",n),this.styleTag.setAttribute("dc-theme",r))},Object.defineProperty(t.prototype,"dcColor",{get:function(){return this.styleTag.getAttribute("dc-color")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dcID",{get:function(){return this.id},enumerable:!1,configurable:!0}),t.prototype.restrictRemove=function(){var t;void 0!==this.id&&(Y(t=this.id)||K.push(t))},t.prototype.allowRemove=function(){var t;void 0!==this.id&&(Y(t=this.id)&&K.splice(K.indexOf(t),1))},t.prototype.clear=function(){this.styleTag.innerHTML="",this.styleTag.removeAttribute("dc-color"),this.styleTag.removeAttribute("dc-theme")},t}();function rt(t){var r;return(void 0===t.dcID||!Y(t.dcID))&&(!!J.includes(t)&&(J.splice(J.indexOf(t),1),void 0!==t.dcID&&(null===(r=document.getElementById(t.dcID))||void 0===r||r.remove()),!0))}var nt=function(t,r,n,e){return new(n||(n=Promise))((function(o,i){function a(t){try{c(e.next(t))}catch(t){i(t)}}function u(t){try{c(e.throw(t))}catch(t){i(t)}}function c(t){var r;t.done?o(t.value):(r=t.value,r instanceof n?r:new n((function(t){t(r)}))).then(a,u)}c((e=e.apply(t,r||[])).next())}))},et=function(t,r){var n,e,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,e&&(o=2&u[0]?e.return:u[0]?e.throw||((o=e.return)&&o.call(e),0):e.next)&&!(o=o.call(e,u[1])).done)return o;switch(e=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,e=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(t,a)}catch(t){u=[6,t],e=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}};function ot(t){r!==t&&(r=t,J.forEach((function(t){var r=t.dcColor;null!==r&&t.setColor(r)})))}function it(t){ot(t.matches?"dark":"light")}function at(t){e(t),ot(t),null==n||n.removeEventListener("change",it),o(void 0)}function ut(){return"light"!==t&&at("light"),"light"}function ct(){if(void 0===window.matchMedia)return ut();if("auto"===t)return(null==n?void 0:n.matches)?"dark":"light";e("auto"),o(window.matchMedia("(prefers-color-scheme: dark)"));var r=(null==n?void 0:n.matches)?"dark":"light";return ot(r),null==n||n.addEventListener("change",it),r}function st(){return"dark"!==t&&at("dark"),"dark"}ct();var lt=Object.freeze({__proto__:null,VERSION:"1.1.5",create:function(t,r){return new tt(t,r)},getCurrentOSTheme:function(){return r},getCurrentUITheme:function(){return t},getInstanceByName:function(t){return J.filter((function(r){var n=r.dcID;return void 0!==n&&Q(n)===t}))[0]},isInstance:function(t){return t instanceof tt},remove:function(t){var r;return nt(this,void 0,void 0,(function(){var n,e;return et(this,(function(o){return t instanceof tt?[2,rt(t)]:Y(n=Z(t))?[2,!1]:(e=J.map((function(t){return t.dcID}))).includes(n)?(J.splice(e.indexOf(n),1),null===(r=document.getElementById(n))||void 0===r||r.remove(),[2,!0]):[2,!1]}))}))},setAutoTheme:ct,setDarkTheme:st,setLightTheme:ut,themeCycle:function(){return"auto"===t?ut():"dark"===t?ct():"light"===t&&st(),t}});window.DynamicColors=lt}();