@udixio/theme 1.0.0-beta.8 → 1.0.0-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("awilix"),e=require("@material/material-color-utilities"),r=require("path"),n=function(){function t(t){var e=t.colorManagerService;this.colorManagerService=void 0,this.colorManagerService=e}var e=t.prototype;return e.getColors=function(){return this.colorManagerService.getAll()},e.addColor=function(t,e){return this.colorManagerService.createOrUpdate(t,e)},e.addColors=function(t){var e=this;Array.isArray(t)||(t=[t]),t.forEach((function(t){"function"==typeof t&&(t=t(e)),t.fromPalettes&&(Array.isArray(t.fromPalettes)||(t.fromPalettes=[t.fromPalettes]),t.fromPalettes.map((function(t){e.colorManagerService.addFromPalette(t)}))),t.colors&&Object.keys(t.colors).map((function(r){return e.addColor(r,t.colors[r])}))}))},e.getColor=function(t){return this.colorManagerService.get(t)},e.removeColor=function(t){return this.colorManagerService.remove(t)},e.updateColor=function(t,e){return this.colorManagerService.createOrUpdate(t,e)},t}();function o(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function i(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function u(t){o(a,n,i,u,c,"next",t)}function c(t){o(a,n,i,u,c,"throw",t)}u(void 0)}))}}function a(){return a=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)({}).hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},a.apply(null,arguments)}function u(){u=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=Object.create((e&&e.prototype instanceof y?e:y).prototype),a=new H(n||[]);return o(i,"_invoke",{value:E(t,r,a)}),i}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var g="suspendedStart",p="suspendedYield",v="executing",d="completed",m={};function y(){}function C(){}function w(){}var k={};l(k,a,(function(){return this}));var P=Object.getPrototypeOf,b=P&&P(P(M([])));b&&b!==r&&n.call(b,a)&&(k=b);var D=w.prototype=y.prototype=Object.create(k);function S(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function r(o,i,a,u){var c=h(t[o],t,i);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,u)}))}u(c.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function E(e,r,n){var o=g;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===d){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var u=n.delegate;if(u){var c=T(u,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===g)throw o=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var s=h(e,r,n);if("normal"===s.type){if(o=n.done?d:p,s.arg===m)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=d,n.method="throw",n.arg=s.arg)}}}function T(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,T(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=h(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,m;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,m):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function H(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function M(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(typeof e+" is not iterable")}return C.prototype=w,o(D,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:C,configurable:!0}),C.displayName=l(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===C||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,l(t,s,"GeneratorFunction")),t.prototype=Object.create(D),t},e.awrap=function(t){return{__await:t}},S(x.prototype),l(x.prototype,c,(function(){return this})),e.AsyncIterator=x,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new x(f(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},S(D),l(D,s,"Generator"),l(D,a,(function(){return this})),l(D,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=M,H.prototype={constructor:H,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(L),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return u.type="throw",u.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],u=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:M(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}function c(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}var s,l=function(){function t(t,e,r,n){this.low=void 0,this.normal=void 0,this.medium=void 0,this.high=void 0,this.low=t,this.normal=e,this.medium=r,this.high=n}return t.prototype.get=function(t){return t<=-1?this.low:t<0?e.lerp(this.low,this.normal,(t- -1)/1):t<.5?e.lerp(this.normal,this.medium,(t-0)/.5):t<1?e.lerp(this.medium,this.high,(t-.5)/.5):this.high},t}(),f=function(){function t(t,e,r,n,o,i,a,u){if(this.name=void 0,this.palette=void 0,this.tone=void 0,this.isBackground=void 0,this.background=void 0,this.secondBackground=void 0,this.contrastCurve=void 0,this.toneDeltaPair=void 0,this.hctCache=new Map,this.name=t,this.palette=e,this.tone=r,this.isBackground=n,this.background=o,this.secondBackground=i,this.contrastCurve=a,this.toneDeltaPair=u,!o&&i)throw new Error("Color "+t+" has secondBackgrounddefined, but background is not defined.");if(!o&&a)throw new Error("Color "+t+" has contrastCurvedefined, but background is not defined.");if(o&&!a)throw new Error("Color "+t+" has backgrounddefined, but contrastCurve is not defined.")}t.fromPalette=function(e){var r,n;return new t(null!=(r=e.name)?r:"",e.palette,e.tone,null!=(n=e.isBackground)&&n,e.background,e.secondBackground,e.contrastCurve,e.toneDeltaPair)},t.foregroundTone=function(r,n){var o=e.Contrast.lighterUnsafe(r,n),i=e.Contrast.darkerUnsafe(r,n),a=e.Contrast.ratioOfTones(o,r),u=e.Contrast.ratioOfTones(i,r);if(t.tonePrefersLightForeground(r)){var c=Math.abs(a-u)<.1&&a<n&&u<n;return a>=n||a>=u||c?o:i}return u>=n||u>=a?i:o},t.tonePrefersLightForeground=function(t){return Math.round(t)<60},t.toneAllowsLightForeground=function(t){return Math.round(t)<=49},t.enableLightForeground=function(e){return t.tonePrefersLightForeground(e)&&!t.toneAllowsLightForeground(e)?49:e};var r=t.prototype;return r.getArgb=function(t){return this.getHct(t).toInt()},r.getHct=function(t){var e=this.hctCache.get(t);if(null!=e)return e;var r=this.getTone(t),n=this.palette(t).getHct(r);return this.hctCache.size>4&&this.hctCache.clear(),this.hctCache.set(t,n),n},r.getTone=function(r){var n=r.contrastLevel<0;if(this.toneDeltaPair){var o=this.toneDeltaPair(r),i=o.roleA,a=o.roleB,u=o.delta,c=o.polarity,s=o.stayTogether,l=this.background(r).getTone(r),f="nearer"===c||"lighter"===c&&!r.isDark||"darker"===c&&r.isDark,h=f?i:a,g=f?a:i,p=this.name===h.name,v=r.isDark?1:-1,d=h.contrastCurve.get(r.contrastLevel),m=g.contrastCurve.get(r.contrastLevel),y=h.tone(r),C=e.Contrast.ratioOfTones(l,y)>=d?y:t.foregroundTone(l,d),w=g.tone(r),k=e.Contrast.ratioOfTones(l,w)>=m?w:t.foregroundTone(l,m);return n&&(C=t.foregroundTone(l,d),k=t.foregroundTone(l,m)),(k-C)*v>=u||((k=e.clampDouble(0,100,C+u*v))-C)*v>=u||(C=e.clampDouble(0,100,k-u*v)),50<=C&&C<60?v>0?(C=60,k=Math.max(k,C+u*v)):(C=49,k=Math.min(k,C+u*v)):50<=k&&k<60&&(s?v>0?(C=60,k=Math.max(k,C+u*v)):(C=49,k=Math.min(k,C+u*v)):k=v>0?60:49),p?C:k}var P=this.tone(r);if(null==this.background)return P;var b=this.background(r).getTone(r),D=this.contrastCurve.get(r.contrastLevel);if(e.Contrast.ratioOfTones(b,P)>=D||(P=t.foregroundTone(b,D)),n&&(P=t.foregroundTone(b,D)),this.isBackground&&50<=P&&P<60&&(P=e.Contrast.ratioOfTones(49,b)>=D?49:60),this.secondBackground){var S=[this.background,this.secondBackground],x=S[1],E=[(0,S[0])(r).getTone(r),x(r).getTone(r)],T=E[0],O=E[1],L=[Math.max(T,O),Math.min(T,O)],H=L[0],M=L[1];if(e.Contrast.ratioOfTones(H,P)>=D&&e.Contrast.ratioOfTones(M,P)>=D)return P;var A=e.Contrast.lighter(H,D),B=e.Contrast.darker(M,D),j=[];return-1!==A&&j.push(A),-1!==B&&j.push(B),t.tonePrefersLightForeground(T)||t.tonePrefersLightForeground(O)?A<0?100:A:1===j.length?j[0]:B<0?0:B}return P},t}(),h=function(t,e,r,n,o){this.roleA=void 0,this.roleB=void 0,this.delta=void 0,this.polarity=void 0,this.stayTogether=void 0,this.roleA=t,this.roleB=e,this.delta=r,this.polarity=n,this.stayTogether=o},g=function(){function t(t,e,r){this.option=void 0,this.schemeService=void 0,this.colorService=void 0,this.dynamicColor=null,this.option=t,this.schemeService=e,this.colorService=r}var r=t.prototype;return r.update=function(t){this.dynamicColor=null,this.option=a({},this.option,t)},r.getHex=function(){return e.hexFromArgb(this.getArgb())},r.getArgb=function(){return this.getDynamicColor().getArgb(this.schemeService.get())},r.getRgb=function(){return{r:(t=this.getArgb())>>16&255,g:t>>8&255,b:255&t};var t},r.getName=function(){return this.option.name.replace(/([A-Z])/g,"_$1").toLowerCase()},r.getDynamicColor=function(){return this.dynamicColor||(this.dynamicColor=f.fromPalette(a({},this.option,{name:this.getName()}))),this.dynamicColor},t}(),p=function(t,e){return e instanceof n?t.isDark?e.getColor("surfaceBright").getDynamicColor():e.getColor("surfaceDim").getDynamicColor():t.isDark?e.get("surfaceBright").getDynamicColor():e.get("surfaceDim").getDynamicColor()},v=function(){function t(t){var e=t.schemeService;this.colorMap=new Map,this.schemeService=void 0,this.schemeService=e}var e=t.prototype;return e.createOrUpdate=function(t,e){var r=this.colorMap.get(t);if(r)r.update(a({},e,{name:t})),this.colorMap.set(t,r);else{var n=e.palette,o=e.tone;if(!n||!o)throw new Error("Palette "+t+" does not exist");r=new g(a({},e,{palette:n,tone:o,name:t}),this.schemeService,this),this.colorMap.set(t,r)}return r},e.remove=function(t){return this.colorMap.delete(t)},e.get=function(t){var e=this.colorMap.get(t);if(e)return e;throw new Error("Color "+t+" does not exist")},e.getAll=function(){return this.colorMap},e.addFromPalette=function(t){var e,r=this,n=t,o=(e=t).charAt(0).toUpperCase()+e.slice(1),i="on"+o,a=n+"Container",u="on"+o+"Container",c="inverse"+o,s=n+"Fixed",f=n+"FixedDim",g="on"+o+"Fixed",v="on"+o+"FixedVariant";this.createOrUpdate(n,{palette:function(e){return e.getPalette(t)},tone:function(t){return t.isDark?80:40},isBackground:!0,background:function(t){return p(t,r)},contrastCurve:new l(3,4.5,7,11),toneDeltaPair:function(t){return new h(r.get(a).getDynamicColor(),r.get(n).getDynamicColor(),15,"nearer",!1)}}),this.createOrUpdate(i,{palette:function(e){return e.getPalette(t)},tone:function(t){return t.isDark?20:100},background:function(t){return r.get(n).getDynamicColor()},contrastCurve:new l(4.5,7,11,21)}),this.createOrUpdate(a,{palette:function(e){return e.getPalette(t)},tone:function(t){return t.isDark?30:90},isBackground:!0,background:function(t){return p(t,r)},contrastCurve:new l(1,1,3,7),toneDeltaPair:function(t){return new h(r.get(a).getDynamicColor(),r.get(n).getDynamicColor(),15,"nearer",!1)}}),this.createOrUpdate(u,{palette:function(e){return e.getPalette(t)},tone:function(t){return t.isDark?90:10},background:function(t){return r.get(a).getDynamicColor()},contrastCurve:new l(4.5,7,11,21)}),this.createOrUpdate(c,{palette:function(e){return e.getPalette(t)},tone:function(t){return t.isDark?40:80},background:function(t){return r.get("inverseSurface").getDynamicColor()},contrastCurve:new l(3,4.5,7,11)}),this.createOrUpdate(s,{palette:function(e){return e.getPalette(t)},tone:function(t){return 90},isBackground:!0,background:function(t){return p(t,r)},contrastCurve:new l(1,1,3,7),toneDeltaPair:function(t){return new h(r.get(s).getDynamicColor(),r.get(f).getDynamicColor(),10,"lighter",!0)}}),this.createOrUpdate(f,{palette:function(e){return e.getPalette(t)},tone:function(t){return 80},isBackground:!0,background:function(t){return p(t,r)},contrastCurve:new l(1,1,3,7),toneDeltaPair:function(t){return new h(r.get(s).getDynamicColor(),r.get(f).getDynamicColor(),10,"lighter",!0)}}),this.createOrUpdate(g,{palette:function(e){return e.getPalette(t)},tone:function(t){return 10},background:function(t){return r.get(f).getDynamicColor()},secondBackground:function(t){return r.get(s).getDynamicColor()},contrastCurve:new l(4.5,7,11,21)}),this.createOrUpdate(v,{palette:function(e){return e.getPalette(t)},tone:function(t){return 30},background:function(t){return r.get(f).getDynamicColor()},secondBackground:function(t){return r.get(s).getDynamicColor()},contrastCurve:new l(3,4.5,7,11)})},t}(),d={colorManagerService:t.asClass(v).singleton(),colorService:t.asClass(n).singleton()},m=function(){function t(t){this.options=void 0,this.options=t}var r,n;return t.prototype.getPalette=function(t){if(!this.options)throw new Error("Scheme options is not set");var e=this.options.palettes.get(t);if(!e)throw new Error("Palette "+t+" not found");return e},r=t,(n=[{key:"contrastLevel",get:function(){if(!this.options)throw new Error("Scheme options is not set");return this.options.contrastLevel}},{key:"isDark",get:function(){if(!this.options)throw new Error("Scheme options is not set");return this.options.isDark}},{key:"sourceColorHct",get:function(){if(!this.options)throw new Error("Scheme options is not set");return e.Hct.fromInt(this.options.sourceColorArgb)}}])&&function(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,c(n.key),n)}}(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r}(),y=function(){function t(){this.schemeEntity=void 0,this.options=void 0}var r=t.prototype;return r.createOrUpdate=function(t){var r,n;this.options=a({},this.options,t,{sourcesColorHex:a({},null==(r=this.options)?void 0:r.sourcesColorHex,t.sourcesColorHex),palettes:a({},null==(n=this.options)?void 0:n.palettes,t.palettes)});var o=new Map;if(!this.options.sourcesColorHex.primary)throw new Error("Primary source color is not set");var i=e.argbFromHex(this.options.sourcesColorHex.primary),u=e.Hct.fromInt(i);if(this.options.palettes){for(var c=0,s=Object.entries(this.options.palettes);c<s.length;c++){var l=s[c],f=l[0],h=l[1],g=h.sourceColorkey,p=h.tonalPalette,v=void 0;if(g){var d=e.argbFromHex(this.options.sourcesColorHex[g]);v=p(e.Hct.fromInt(d))}else v=p(u);o.set(f,v)}this.schemeEntity=new m(a({},this.options,{palettes:o,sourceColorArgb:i}))}},r.get=function(){if(!this.schemeEntity)throw new Error("Scheme is not created");return this.schemeEntity},t}(),C=function(){function t(t){var e=t.schemeService,r=t.variantService;this.schemeService=void 0,this.variantService=void 0,this.schemeService=e,this.variantService=r}var e=t.prototype;return e.create=function(t){this.schemeService.createOrUpdate(a({},t,{sourcesColorHex:{primary:t.sourceColorHex}})),this.variantService.set(t.variant)},e.update=function(t){var e=a({},t);t.sourceColorHex&&(e.sourcesColorHex={primary:t.sourceColorHex}),this.schemeService.createOrUpdate(e),t.variant&&this.variantService.set(t.variant)},e.addCustomPalette=function(t,e){this.variantService.addCustomPalette(t,e)},t}(),w=function(){function t(t){var e=t.schemeService;this.customPalettes={},this.variantEntity=void 0,this.schemeService=void 0,this.schemeService=e}var r=t.prototype;return r.addCustomPalette=function(t,e){this.customPalettes[t]=e,this.update()},r.set=function(t){this.variantEntity=t,t.palettes.error||(t.palettes.error=function(){return e.TonalPalette.fromHueAndChroma(25,84)}),this.update()},r.update=function(){var t=this;if(this.variantEntity){var e={};Object.keys(this.variantEntity.palettes).forEach((function(r){e[r]={tonalPalette:t.variantEntity.palettes[r]}})),this.variantEntity.customPalettes&&Object.keys(this.customPalettes).forEach((function(r){e[r]={sourceColorkey:r,tonalPalette:t.variantEntity.customPalettes}})),this.schemeService.createOrUpdate({sourcesColorHex:this.customPalettes,palettes:e})}},t}(),k={schemeService:t.asClass(y).singleton(),variantService:t.asClass(w).singleton(),themeService:t.asClass(C).singleton()},P=function(t){var e=t.colorService,r=t.themeService,n=t.pluginService;this.colorService=void 0,this.themeService=void 0,this.pluginService=void 0,this.pluginService=n,this.colorService=e,this.themeService=r},b={appService:t.asClass(P).singleton()},D=function(t){return{fromPalettes:["primary","secondary","tertiary"],colors:{background:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?6:98},isBackground:!0},onBackground:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?90:10},background:function(e){return t.getColor("background").getDynamicColor()},contrastCurve:new l(3,3,4.5,7)},surface:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?6:98},isBackground:!0},surfaceDim:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?6:87},isBackground:!0},surfaceBright:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?24:98},isBackground:!0},surfaceContainerLowest:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?4:100},isBackground:!0},surfaceContainerLow:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?10:96},isBackground:!0},surfaceContainer:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?12:94},isBackground:!0},surfaceContainerHigh:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?17:92},isBackground:!0},surfaceContainerHighest:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?22:90},isBackground:!0},onSurface:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?90:10},background:function(e){return p(e,t)},contrastCurve:new l(4.5,7,11,21)},surfaceVariant:{palette:function(t){return t.getPalette("neutralVariant")},tone:function(t){return t.isDark?30:90},isBackground:!0},onSurfaceVariant:{palette:function(t){return t.getPalette("neutralVariant")},tone:function(t){return t.isDark?80:30},background:function(e){return p(e,t)},contrastCurve:new l(3,4.5,7,11)},inverseSurface:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?90:20}},inverseOnSurface:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?20:95},background:function(e){return t.getColor("inverseSurface").getDynamicColor()},contrastCurve:new l(4.5,7,11,21)},outline:{palette:function(t){return t.getPalette("neutralVariant")},tone:function(t){return t.isDark?60:50},background:function(e){return p(e,t)},contrastCurve:new l(1.5,3,4.5,7)},outlineVariant:{palette:function(t){return t.getPalette("neutralVariant")},tone:function(t){return t.isDark?30:80},background:function(e){return p(e,t)},contrastCurve:new l(1,1,3,7)},shadow:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return 0}},scrim:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return 0}},surfaceTint:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?80:40},isBackground:!0},secondaryContainer:{tone:function(t){var r=t.isDark?30:90;return function(t,r,n,o){var i=n,a=e.Hct.from(t,r,n);if(a.chroma<r)for(var u=a.chroma;a.chroma<r;){var c=e.Hct.from(t,r,i+=o?-1:1);if(u>c.chroma)break;if(Math.abs(c.chroma-r)<.4)break;Math.abs(c.chroma-r)<Math.abs(a.chroma-r)&&(a=c),u=Math.max(u,c.chroma)}return i}(t.getPalette("secondary").hue,t.getPalette("secondary").chroma,r,!t.isDark)}},onSecondaryContainer:{tone:function(e){return f.foregroundTone(t.getColor("secondaryContainer").getDynamicColor().tone(e),4.5)}},tertiaryContainer:{palette:function(t){return t.getPalette("tertiary")},tone:function(t){var r=t.getPalette("tertiary").getHct(t.sourceColorHct.tone);return e.DislikeAnalyzer.fixIfDisliked(r).tone}},onTertiaryContainer:{palette:function(t){return t.getPalette("tertiary")},tone:function(e){return f.foregroundTone(t.getColor("tertiaryContainer").getDynamicColor().tone(e),4.5)}},error:{palette:function(t){return t.getPalette("error")},tone:function(t){return t.isDark?80:40},isBackground:!0,background:function(e){return p(e,t)},contrastCurve:new l(3,4.5,7,11),toneDeltaPair:function(e){return new h(t.getColor("errorContainer").getDynamicColor(),t.getColor("error").getDynamicColor(),15,"nearer",!1)}},onError:{palette:function(t){return t.getPalette("error")},tone:function(t){return t.isDark?20:100},background:function(e){return t.getColor("error").getDynamicColor()},contrastCurve:new l(4.5,7,11,21)},errorContainer:{palette:function(t){return t.getPalette("error")},tone:function(t){return t.isDark?30:90},isBackground:!0,background:function(e){return p(e,t)},contrastCurve:new l(1,1,3,7),toneDeltaPair:function(e){return new h(t.getColor("errorContainer").getDynamicColor(),t.getColor("error").getDynamicColor(),15,"nearer",!1)}},onErrorContainer:{palette:function(t){return t.getPalette("error")},tone:function(t){return t.isDark?90:10},background:function(e){return t.getColor("errorContainer").getDynamicColor()},contrastCurve:new l(4.5,7,11,21)},onTertiaryFixed:{palette:function(t){return t.getPalette("tertiary")},tone:function(t){return 10},background:function(e){return t.getColor("tertiaryFixedDim").getDynamicColor()},secondBackground:function(e){return t.getColor("tertiaryFixed").getDynamicColor()},contrastCurve:new l(4.5,7,11,21)},onTertiaryFixedVariant:{palette:function(t){return t.getPalette("tertiary")},tone:function(t){return 30},background:function(e){return t.getColor("tertiaryFixedDim").getDynamicColor()},secondBackground:function(e){return t.getColor("tertiaryFixed").getDynamicColor()},contrastCurve:new l(3,4.5,7,11)}}}},S=function(t,r,n){var o=t.hue;if(r.length!==n.length)throw new Error("mismatch between hue length "+r.length+" & rotations "+n.length);if(1===n.length)return e.sanitizeDegreesDouble(t.hue+n[0]);for(var i=r.length,a=0;a<=i-2;a++)if(r[a]<o&&o<r[a+1])return e.sanitizeDegreesDouble(o+n[a]);return o},x=function(){};s=x,x.tonalSpot={palettes:{primary:function(t){return e.TonalPalette.fromHueAndChroma(t.hue,36)},secondary:function(t){return e.TonalPalette.fromHueAndChroma(t.hue,16)},tertiary:function(t){return e.TonalPalette.fromHueAndChroma(e.sanitizeDegreesDouble(t.hue+60),24)},neutral:function(t){return e.TonalPalette.fromHueAndChroma(t.hue,6)},neutralVariant:function(t){return e.TonalPalette.fromHueAndChroma(t.hue,8)}},customPalettes:function(t){return e.TonalPalette.fromHueAndChroma(t.hue,16)}},x.vibrant={palettes:{primary:function(t){return e.TonalPalette.fromHueAndChroma(t.hue,200)},secondary:function(t){return e.TonalPalette.fromHueAndChroma(S(t,s.hues,s.secondaryRotations),24)},tertiary:function(t){return e.TonalPalette.fromHueAndChroma(S(t,s.hues,s.tertiaryRotations),32)},neutral:function(t){return e.TonalPalette.fromHueAndChroma(t.hue,6)},neutralVariant:function(t){return e.TonalPalette.fromHueAndChroma(t.hue,8)}},customPalettes:function(t){return e.TonalPalette.fromHueAndChroma(S(t,s.hues,s.secondaryRotations),24)}},x.hues=[0,41,61,101,131,181,251,301,360],x.secondaryRotations=[18,15,10,12,15,18,15,12,12],x.tertiaryRotations=[35,30,20,25,30,35,30,25,25];var E=function(){function t(t){var e=t.appService;this.configPath="./theme.config.ts",this.appService=void 0,this.appService=e}var e=t.prototype;return e.loadConfig=function(){var t=i(u().mark((function t(){var e,r,n,o,i,a,c,s,l,f,h,g,p;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=(e=this.appService).themeService,n=e.colorService,o=e.pluginService,t.next=3,this.getConfig();case 3:l=(i=t.sent).palettes,f=i.colors,g=void 0===(h=i.useDefaultColors)||h,p=i.plugins,r.create({contrastLevel:void 0===(a=i.contrastLevel)?0:a,isDark:void 0!==(c=i.isDark)&&c,sourceColorHex:i.sourceColor,variant:void 0===(s=i.variant)?x.tonalSpot:s}),l&&Object.entries(l).forEach((function(t){return r.addCustomPalette(t[0],t[1])})),g&&n.addColors(D),f&&n.addColors(f),p&&(p.forEach((function(t){return o.addPlugin(t)})),o.loadPlugins(this.appService));case 21:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.getConfig=function(){var t=i(u().mark((function t(){var e;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=r.resolve(this.configPath),t.next=3,import(e);case 3:return t.abrupt("return",t.sent.default);case 6:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),t}(),T={configService:t.asClass(E).singleton()},O={pluginService:t.asClass(function(){function t(){this.pluginInstances=new Map,this.pluginConstructors=new Map}var e=t.prototype;return e.addPlugin=function(t){this.pluginConstructors.set(t.name,t)},e.loadPlugins=function(t){var e=this;this.pluginConstructors.forEach((function(r){e.pluginInstances.set(r.name,new r(t))}))},e.getPlugin=function(t){return this.pluginInstances.get(t.name)},t}()).singleton()};function L(t,e){return e.forEach((function(e){Object.entries(e).forEach((function(e){t.register(e[0],e[1])}))})),t}var H=t.createContainer({injectionMode:t.InjectionMode.PROXY});function M(){return M=i(u().mark((function t(e){var r;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=H.resolve("configService"),e&&(r.configPath=e),t.next=4,r.loadConfig();case 4:return t.abrupt("return",H.resolve("appService"));case 5:case"end":return t.stop()}}),t)}))),M.apply(this,arguments)}L(H,[T,b,O,d,k]),exports.AppContainer=H,exports.AppModule=b,exports.AppService=P,exports.ColorEntity=g,exports.ColorManagerService=v,exports.ColorModule=d,exports.ColorService=n,exports.ConfigService=E,exports.ContrastCurve=l,exports.DynamicColor=f,exports.SchemeEntity=m,exports.SchemeService=y,exports.ThemeModule=k,exports.ThemeService=C,exports.ToneDeltaPair=h,exports.VariantEntity=function(t,e){void 0===t&&(t={}),this.palettes=void 0,this.customPalettes=void 0,this.palettes=t,this.customPalettes=e},exports.VariantModel=x,exports.VariantService=w,exports.bootstrap=function(){return H.resolve("appService")},exports.bootstrapFromConfig=function(t){return M.apply(this,arguments)},exports.defaultColors=D,exports.defineConfig=function(t){if(!t||"object"!=typeof t)throw new Error("The configuration is missing or not an object");if(!("sourceColor"in t))throw new Error("Invalid configuration");return t},exports.getRotatedHue=S,exports.highestSurface=p,exports.importContainer=L;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("awilix"),e=require("@material/material-color-utilities"),r=require("path"),n=function(){function t(t){var e=t.colorManagerService;this.colorManagerService=void 0,this.colorManagerService=e}var e=t.prototype;return e.getColors=function(){return this.colorManagerService.getAll()},e.addColor=function(t,e){return this.colorManagerService.createOrUpdate(t,e)},e.addColors=function(t){var e=this;Array.isArray(t)||(t=[t]),t.forEach((function(t){"function"==typeof t&&(t=t(e)),t.fromPalettes&&(Array.isArray(t.fromPalettes)||(t.fromPalettes=[t.fromPalettes]),t.fromPalettes.map((function(t){e.colorManagerService.addFromPalette(t)}))),t.colors&&Object.keys(t.colors).map((function(r){return e.addColor(r,t.colors[r])}))}))},e.getColor=function(t){return this.colorManagerService.get(t)},e.removeColor=function(t){return this.colorManagerService.remove(t)},e.updateColor=function(t,e){return this.colorManagerService.createOrUpdate(t,e)},t}();function o(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function i(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function u(t){o(a,n,i,u,c,"next",t)}function c(t){o(a,n,i,u,c,"throw",t)}u(void 0)}))}}function a(){return a=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)({}).hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},a.apply(null,arguments)}function u(){u=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=Object.create((e&&e.prototype instanceof y?e:y).prototype),a=new H(n||[]);return o(i,"_invoke",{value:E(t,r,a)}),i}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var g="suspendedStart",p="suspendedYield",d="executing",v="completed",m={};function y(){}function C(){}function w(){}var k={};l(k,a,(function(){return this}));var P=Object.getPrototypeOf,b=P&&P(P(M([])));b&&b!==r&&n.call(b,a)&&(k=b);var D=w.prototype=y.prototype=Object.create(k);function S(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function r(o,i,a,u){var c=h(t[o],t,i);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,u)}))}u(c.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function E(e,r,n){var o=g;return function(i,a){if(o===d)throw Error("Generator is already running");if(o===v){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var u=n.delegate;if(u){var c=T(u,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===g)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var s=h(e,r,n);if("normal"===s.type){if(o=n.done?v:p,s.arg===m)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=v,n.method="throw",n.arg=s.arg)}}}function T(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,T(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=h(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,m;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,m):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function H(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function M(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(typeof e+" is not iterable")}return C.prototype=w,o(D,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:C,configurable:!0}),C.displayName=l(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===C||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,l(t,s,"GeneratorFunction")),t.prototype=Object.create(D),t},e.awrap=function(t){return{__await:t}},S(x.prototype),l(x.prototype,c,(function(){return this})),e.AsyncIterator=x,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new x(f(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},S(D),l(D,s,"Generator"),l(D,a,(function(){return this})),l(D,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=M,H.prototype={constructor:H,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(L),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return u.type="throw",u.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],u=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:M(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}function c(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}var s,l=function(){function t(t,e,r,n){this.low=void 0,this.normal=void 0,this.medium=void 0,this.high=void 0,this.low=t,this.normal=e,this.medium=r,this.high=n}return t.prototype.get=function(t){return t<=-1?this.low:t<0?e.lerp(this.low,this.normal,(t- -1)/1):t<.5?e.lerp(this.normal,this.medium,(t-0)/.5):t<1?e.lerp(this.medium,this.high,(t-.5)/.5):this.high},t}(),f=function(){function t(t,e,r,n,o,i,a,u){if(this.name=void 0,this.palette=void 0,this.tone=void 0,this.isBackground=void 0,this.background=void 0,this.secondBackground=void 0,this.contrastCurve=void 0,this.toneDeltaPair=void 0,this.hctCache=new Map,this.name=t,this.palette=e,this.tone=r,this.isBackground=n,this.background=o,this.secondBackground=i,this.contrastCurve=a,this.toneDeltaPair=u,!o&&i)throw new Error("Color "+t+" has secondBackgrounddefined, but background is not defined.");if(!o&&a)throw new Error("Color "+t+" has contrastCurvedefined, but background is not defined.");if(o&&!a)throw new Error("Color "+t+" has backgrounddefined, but contrastCurve is not defined.")}t.fromPalette=function(e){var r,n;return new t(null!=(r=e.name)?r:"",e.palette,e.tone,null!=(n=e.isBackground)&&n,e.background,e.secondBackground,e.contrastCurve,e.toneDeltaPair)},t.foregroundTone=function(r,n){var o=e.Contrast.lighterUnsafe(r,n),i=e.Contrast.darkerUnsafe(r,n),a=e.Contrast.ratioOfTones(o,r),u=e.Contrast.ratioOfTones(i,r);if(t.tonePrefersLightForeground(r)){var c=Math.abs(a-u)<.1&&a<n&&u<n;return a>=n||a>=u||c?o:i}return u>=n||u>=a?i:o},t.tonePrefersLightForeground=function(t){return Math.round(t)<60},t.toneAllowsLightForeground=function(t){return Math.round(t)<=49},t.enableLightForeground=function(e){return t.tonePrefersLightForeground(e)&&!t.toneAllowsLightForeground(e)?49:e};var r=t.prototype;return r.getArgb=function(t){return this.getHct(t).toInt()},r.getHct=function(t){var e=this.hctCache.get(t);if(null!=e)return e;var r=this.getTone(t),n=this.palette(t).getHct(r);return this.hctCache.size>4&&this.hctCache.clear(),this.hctCache.set(t,n),n},r.getTone=function(r){var n=r.contrastLevel<0;if(this.toneDeltaPair){var o=this.toneDeltaPair(r),i=o.roleA,a=o.roleB,u=o.delta,c=o.polarity,s=o.stayTogether,l=this.background(r).getTone(r),f="nearer"===c||"lighter"===c&&!r.isDark||"darker"===c&&r.isDark,h=f?i:a,g=f?a:i,p=this.name===h.name,d=r.isDark?1:-1,v=h.contrastCurve.get(r.contrastLevel),m=g.contrastCurve.get(r.contrastLevel),y=h.tone(r),C=e.Contrast.ratioOfTones(l,y)>=v?y:t.foregroundTone(l,v),w=g.tone(r),k=e.Contrast.ratioOfTones(l,w)>=m?w:t.foregroundTone(l,m);return n&&(C=t.foregroundTone(l,v),k=t.foregroundTone(l,m)),(k-C)*d>=u||((k=e.clampDouble(0,100,C+u*d))-C)*d>=u||(C=e.clampDouble(0,100,k-u*d)),50<=C&&C<60?d>0?(C=60,k=Math.max(k,C+u*d)):(C=49,k=Math.min(k,C+u*d)):50<=k&&k<60&&(s?d>0?(C=60,k=Math.max(k,C+u*d)):(C=49,k=Math.min(k,C+u*d)):k=d>0?60:49),p?C:k}var P=this.tone(r);if(null==this.background)return P;var b=this.background(r).getTone(r),D=this.contrastCurve.get(r.contrastLevel);if(e.Contrast.ratioOfTones(b,P)>=D||(P=t.foregroundTone(b,D)),n&&(P=t.foregroundTone(b,D)),this.isBackground&&50<=P&&P<60&&(P=e.Contrast.ratioOfTones(49,b)>=D?49:60),this.secondBackground){var S=[this.background,this.secondBackground],x=S[1],E=[(0,S[0])(r).getTone(r),x(r).getTone(r)],T=E[0],O=E[1],L=[Math.max(T,O),Math.min(T,O)],H=L[0],M=L[1];if(e.Contrast.ratioOfTones(H,P)>=D&&e.Contrast.ratioOfTones(M,P)>=D)return P;var A=e.Contrast.lighter(H,D),B=e.Contrast.darker(M,D),j=[];return-1!==A&&j.push(A),-1!==B&&j.push(B),t.tonePrefersLightForeground(T)||t.tonePrefersLightForeground(O)?A<0?100:A:1===j.length?j[0]:B<0?0:B}return P},t}(),h=function(t,e,r,n,o){this.roleA=void 0,this.roleB=void 0,this.delta=void 0,this.polarity=void 0,this.stayTogether=void 0,this.roleA=t,this.roleB=e,this.delta=r,this.polarity=n,this.stayTogether=o},g=function(){function t(t,e,r){this.option=void 0,this.schemeService=void 0,this.colorService=void 0,this.dynamicColor=null,this.option=t,this.schemeService=e,this.colorService=r}var r=t.prototype;return r.update=function(t){this.dynamicColor=null,this.option=a({},this.option,t)},r.getHex=function(){return e.hexFromArgb(this.getArgb())},r.getArgb=function(){return this.getDynamicColor().getArgb(this.schemeService.get())},r.getRgb=function(){return{r:(t=this.getArgb())>>16&255,g:t>>8&255,b:255&t};var t},r.getName=function(){return this.option.name.replace(/([A-Z])/g,"_$1").toLowerCase()},r.getDynamicColor=function(){return this.dynamicColor||(this.dynamicColor=f.fromPalette(a({},this.option,{name:this.getName()}))),this.dynamicColor},t}(),p=function(t,e){return e instanceof n?t.isDark?e.getColor("surfaceBright").getDynamicColor():e.getColor("surfaceDim").getDynamicColor():t.isDark?e.get("surfaceBright").getDynamicColor():e.get("surfaceDim").getDynamicColor()},d=function(){function t(t){var e=t.schemeService;this.colorMap=new Map,this.schemeService=void 0,this.schemeService=e}var e=t.prototype;return e.createOrUpdate=function(t,e){var r=this.colorMap.get(t);if(r)r.update(a({},e,{name:t})),this.colorMap.set(t,r);else{var n=e.palette,o=e.tone;if(!n||!o)throw new Error("Palette "+t+" does not exist");r=new g(a({},e,{palette:n,tone:o,name:t}),this.schemeService,this),this.colorMap.set(t,r)}return r},e.remove=function(t){return this.colorMap.delete(t)},e.get=function(t){var e=this.colorMap.get(t);if(e)return e;throw new Error("Color "+t+" does not exist")},e.getAll=function(){return this.colorMap},e.addFromPalette=function(t){var e,r=this,n=t,o=(e=t).charAt(0).toUpperCase()+e.slice(1),i="on"+o,a=n+"Container",u="on"+o+"Container",c="inverse"+o,s=n+"Fixed",f=n+"FixedDim",g="on"+o+"Fixed",d="on"+o+"FixedVariant";this.createOrUpdate(n,{palette:function(e){return e.getPalette(t)},tone:function(t){return t.isDark?80:40},isBackground:!0,background:function(t){return p(t,r)},contrastCurve:new l(3,4.5,7,11),toneDeltaPair:function(t){return new h(r.get(a).getDynamicColor(),r.get(n).getDynamicColor(),15,"nearer",!1)}}),this.createOrUpdate(i,{palette:function(e){return e.getPalette(t)},tone:function(t){return t.isDark?20:100},background:function(t){return r.get(n).getDynamicColor()},contrastCurve:new l(4.5,7,11,21)}),this.createOrUpdate(a,{palette:function(e){return e.getPalette(t)},tone:function(t){return t.isDark?30:90},isBackground:!0,background:function(t){return p(t,r)},contrastCurve:new l(1,1,3,7),toneDeltaPair:function(t){return new h(r.get(a).getDynamicColor(),r.get(n).getDynamicColor(),15,"nearer",!1)}}),this.createOrUpdate(u,{palette:function(e){return e.getPalette(t)},tone:function(t){return t.isDark?90:10},background:function(t){return r.get(a).getDynamicColor()},contrastCurve:new l(4.5,7,11,21)}),this.createOrUpdate(c,{palette:function(e){return e.getPalette(t)},tone:function(t){return t.isDark?40:80},background:function(t){return r.get("inverseSurface").getDynamicColor()},contrastCurve:new l(3,4.5,7,11)}),this.createOrUpdate(s,{palette:function(e){return e.getPalette(t)},tone:function(t){return 90},isBackground:!0,background:function(t){return p(t,r)},contrastCurve:new l(1,1,3,7),toneDeltaPair:function(t){return new h(r.get(s).getDynamicColor(),r.get(f).getDynamicColor(),10,"lighter",!0)}}),this.createOrUpdate(f,{palette:function(e){return e.getPalette(t)},tone:function(t){return 80},isBackground:!0,background:function(t){return p(t,r)},contrastCurve:new l(1,1,3,7),toneDeltaPair:function(t){return new h(r.get(s).getDynamicColor(),r.get(f).getDynamicColor(),10,"lighter",!0)}}),this.createOrUpdate(g,{palette:function(e){return e.getPalette(t)},tone:function(t){return 10},background:function(t){return r.get(f).getDynamicColor()},secondBackground:function(t){return r.get(s).getDynamicColor()},contrastCurve:new l(4.5,7,11,21)}),this.createOrUpdate(d,{palette:function(e){return e.getPalette(t)},tone:function(t){return 30},background:function(t){return r.get(f).getDynamicColor()},secondBackground:function(t){return r.get(s).getDynamicColor()},contrastCurve:new l(3,4.5,7,11)})},t}(),v={colorManagerService:t.asClass(d).singleton(),colorService:t.asClass(n).singleton()},m=function(){function t(t){this.options=void 0,this.options=t}var r,n;return t.prototype.getPalette=function(t){if(!this.options)throw new Error("Scheme options is not set");var e=this.options.palettes.get(t);if(!e)throw new Error("Palette "+t+" not found");return e},r=t,(n=[{key:"contrastLevel",get:function(){if(!this.options)throw new Error("Scheme options is not set");return this.options.contrastLevel}},{key:"isDark",get:function(){if(!this.options)throw new Error("Scheme options is not set");return this.options.isDark}},{key:"sourceColorHct",get:function(){if(!this.options)throw new Error("Scheme options is not set");return e.Hct.fromInt(this.options.sourceColorArgb)}}])&&function(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,c(n.key),n)}}(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r}(),y=function(){function t(){this.schemeEntity=void 0,this.options=void 0}var r=t.prototype;return r.createOrUpdate=function(t){var r,n;this.options=a({},this.options,t,{sourcesColorHex:a({},null==(r=this.options)?void 0:r.sourcesColorHex,t.sourcesColorHex),palettes:a({},null==(n=this.options)?void 0:n.palettes,t.palettes)});var o=new Map;if(!this.options.sourcesColorHex.primary)throw new Error("Primary source color is not set");var i=e.argbFromHex(this.options.sourcesColorHex.primary),u=e.Hct.fromInt(i);if(this.options.palettes){for(var c=0,s=Object.entries(this.options.palettes);c<s.length;c++){var l=s[c],f=l[0],h=l[1],g=h.sourceColorkey,p=h.tonalPalette,d=void 0;if(g){var v=e.argbFromHex(this.options.sourcesColorHex[g]);d=p(e.Hct.fromInt(v))}else d=p(u);o.set(f,d)}this.schemeEntity=new m(a({},this.options,{palettes:o,sourceColorArgb:i}))}},r.get=function(){if(!this.schemeEntity)throw new Error("Scheme is not created");return this.schemeEntity},t}(),C=function(){function t(t){var e=t.schemeService,r=t.variantService;this.schemeService=void 0,this.variantService=void 0,this.schemeService=e,this.variantService=r}var e=t.prototype;return e.create=function(t){this.schemeService.createOrUpdate(a({},t,{sourcesColorHex:{primary:t.sourceColorHex}})),this.variantService.set(t.variant)},e.update=function(t){var e=a({},t);t.sourceColorHex&&(e.sourcesColorHex={primary:t.sourceColorHex}),this.schemeService.createOrUpdate(e),t.variant&&this.variantService.set(t.variant)},e.addCustomPalette=function(t,e){this.variantService.addCustomPalette(t,e)},t}(),w=function(){function t(t){var e=t.schemeService;this.customPalettes={},this.variantEntity=void 0,this.schemeService=void 0,this.schemeService=e}var r=t.prototype;return r.addCustomPalette=function(t,e){this.customPalettes[t]=e,this.update()},r.set=function(t){this.variantEntity=t,t.palettes.error||(t.palettes.error=function(){return e.TonalPalette.fromHueAndChroma(25,84)}),this.update()},r.update=function(){var t=this;if(this.variantEntity){var e={};Object.keys(this.variantEntity.palettes).forEach((function(r){e[r]={tonalPalette:t.variantEntity.palettes[r]}})),this.variantEntity.customPalettes&&Object.keys(this.customPalettes).forEach((function(r){e[r]={sourceColorkey:r,tonalPalette:t.variantEntity.customPalettes}})),this.schemeService.createOrUpdate({sourcesColorHex:this.customPalettes,palettes:e})}},t}(),k={schemeService:t.asClass(y).singleton(),variantService:t.asClass(w).singleton(),themeService:t.asClass(C).singleton()},P=function(t){var e=t.colorService,r=t.themeService,n=t.pluginService;this.colorService=void 0,this.themeService=void 0,this.pluginService=void 0,this.pluginService=n,this.colorService=e,this.themeService=r},b={appService:t.asClass(P).singleton()},D=function(t){return{fromPalettes:["primary","secondary","tertiary"],colors:{background:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?6:98},isBackground:!0},onBackground:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?90:10},background:function(e){return t.getColor("background").getDynamicColor()},contrastCurve:new l(3,3,4.5,7)},surface:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?6:98},isBackground:!0},surfaceDim:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?6:87},isBackground:!0},surfaceBright:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?24:98},isBackground:!0},surfaceContainerLowest:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?4:100},isBackground:!0},surfaceContainerLow:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?10:96},isBackground:!0},surfaceContainer:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?12:94},isBackground:!0},surfaceContainerHigh:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?17:92},isBackground:!0},surfaceContainerHighest:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?22:90},isBackground:!0},onSurface:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?90:10},background:function(e){return p(e,t)},contrastCurve:new l(4.5,7,11,21)},surfaceVariant:{palette:function(t){return t.getPalette("neutralVariant")},tone:function(t){return t.isDark?30:90},isBackground:!0},onSurfaceVariant:{palette:function(t){return t.getPalette("neutralVariant")},tone:function(t){return t.isDark?80:30},background:function(e){return p(e,t)},contrastCurve:new l(3,4.5,7,11)},inverseSurface:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?90:20}},inverseOnSurface:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?20:95},background:function(e){return t.getColor("inverseSurface").getDynamicColor()},contrastCurve:new l(4.5,7,11,21)},outline:{palette:function(t){return t.getPalette("neutralVariant")},tone:function(t){return t.isDark?60:50},background:function(e){return p(e,t)},contrastCurve:new l(1.5,3,4.5,7)},outlineVariant:{palette:function(t){return t.getPalette("neutralVariant")},tone:function(t){return t.isDark?30:80},background:function(e){return p(e,t)},contrastCurve:new l(1,1,3,7)},shadow:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return 0}},scrim:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return 0}},surfaceTint:{palette:function(t){return t.getPalette("neutral")},tone:function(t){return t.isDark?80:40},isBackground:!0},secondaryContainer:{tone:function(t){var r=t.isDark?30:90;return function(t,r,n,o){var i=n,a=e.Hct.from(t,r,n);if(a.chroma<r)for(var u=a.chroma;a.chroma<r;){var c=e.Hct.from(t,r,i+=o?-1:1);if(u>c.chroma)break;if(Math.abs(c.chroma-r)<.4)break;Math.abs(c.chroma-r)<Math.abs(a.chroma-r)&&(a=c),u=Math.max(u,c.chroma)}return i}(t.getPalette("secondary").hue,t.getPalette("secondary").chroma,r,!t.isDark)}},onSecondaryContainer:{tone:function(e){return f.foregroundTone(t.getColor("secondaryContainer").getDynamicColor().tone(e),4.5)}},tertiaryContainer:{palette:function(t){return t.getPalette("tertiary")},tone:function(t){var r=t.getPalette("tertiary").getHct(t.sourceColorHct.tone);return e.DislikeAnalyzer.fixIfDisliked(r).tone}},onTertiaryContainer:{palette:function(t){return t.getPalette("tertiary")},tone:function(e){return f.foregroundTone(t.getColor("tertiaryContainer").getDynamicColor().tone(e),4.5)}},error:{palette:function(t){return t.getPalette("error")},tone:function(t){return t.isDark?80:40},isBackground:!0,background:function(e){return p(e,t)},contrastCurve:new l(3,4.5,7,11),toneDeltaPair:function(e){return new h(t.getColor("errorContainer").getDynamicColor(),t.getColor("error").getDynamicColor(),15,"nearer",!1)}},onError:{palette:function(t){return t.getPalette("error")},tone:function(t){return t.isDark?20:100},background:function(e){return t.getColor("error").getDynamicColor()},contrastCurve:new l(4.5,7,11,21)},errorContainer:{palette:function(t){return t.getPalette("error")},tone:function(t){return t.isDark?30:90},isBackground:!0,background:function(e){return p(e,t)},contrastCurve:new l(1,1,3,7),toneDeltaPair:function(e){return new h(t.getColor("errorContainer").getDynamicColor(),t.getColor("error").getDynamicColor(),15,"nearer",!1)}},onErrorContainer:{palette:function(t){return t.getPalette("error")},tone:function(t){return t.isDark?90:10},background:function(e){return t.getColor("errorContainer").getDynamicColor()},contrastCurve:new l(4.5,7,11,21)},onTertiaryFixed:{palette:function(t){return t.getPalette("tertiary")},tone:function(t){return 10},background:function(e){return t.getColor("tertiaryFixedDim").getDynamicColor()},secondBackground:function(e){return t.getColor("tertiaryFixed").getDynamicColor()},contrastCurve:new l(4.5,7,11,21)},onTertiaryFixedVariant:{palette:function(t){return t.getPalette("tertiary")},tone:function(t){return 30},background:function(e){return t.getColor("tertiaryFixedDim").getDynamicColor()},secondBackground:function(e){return t.getColor("tertiaryFixed").getDynamicColor()},contrastCurve:new l(3,4.5,7,11)}}}},S=function(t,r,n){var o=t.hue;if(r.length!==n.length)throw new Error("mismatch between hue length "+r.length+" & rotations "+n.length);if(1===n.length)return e.sanitizeDegreesDouble(t.hue+n[0]);for(var i=r.length,a=0;a<=i-2;a++)if(r[a]<o&&o<r[a+1])return e.sanitizeDegreesDouble(o+n[a]);return o},x=function(){};s=x,x.tonalSpot={palettes:{primary:function(t){return e.TonalPalette.fromHueAndChroma(t.hue,36)},secondary:function(t){return e.TonalPalette.fromHueAndChroma(t.hue,16)},tertiary:function(t){return e.TonalPalette.fromHueAndChroma(e.sanitizeDegreesDouble(t.hue+60),24)},neutral:function(t){return e.TonalPalette.fromHueAndChroma(t.hue,6)},neutralVariant:function(t){return e.TonalPalette.fromHueAndChroma(t.hue,8)}},customPalettes:function(t){return e.TonalPalette.fromHueAndChroma(t.hue,16)}},x.vibrant={palettes:{primary:function(t){return e.TonalPalette.fromHueAndChroma(t.hue,200)},secondary:function(t){return e.TonalPalette.fromHueAndChroma(S(t,s.hues,s.secondaryRotations),24)},tertiary:function(t){return e.TonalPalette.fromHueAndChroma(S(t,s.hues,s.tertiaryRotations),32)},neutral:function(t){return e.TonalPalette.fromHueAndChroma(t.hue,6)},neutralVariant:function(t){return e.TonalPalette.fromHueAndChroma(t.hue,8)}},customPalettes:function(t){return e.TonalPalette.fromHueAndChroma(S(t,s.hues,s.secondaryRotations),24)}},x.hues=[0,41,61,101,131,181,251,301,360],x.secondaryRotations=[18,15,10,12,15,18,15,12,12],x.tertiaryRotations=[35,30,20,25,30,35,30,25,25];var E=function(){function t(t){var e=t.appService;this.configPath="./theme.config.ts",this.appService=void 0,this.appService=e}var e=t.prototype;return e.loadConfig=function(){var t=i(u().mark((function t(){var e,r,n,o,i,a,c,s,l,f,h,g,p;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=(e=this.appService).themeService,n=e.colorService,o=e.pluginService,t.next=3,this.getConfig();case 3:l=(i=t.sent).palettes,f=i.colors,g=void 0===(h=i.useDefaultColors)||h,p=i.plugins,r.create({contrastLevel:void 0===(a=i.contrastLevel)?0:a,isDark:void 0!==(c=i.isDark)&&c,sourceColorHex:i.sourceColor,variant:void 0===(s=i.variant)?x.tonalSpot:s}),l&&Object.entries(l).forEach((function(t){return r.addCustomPalette(t[0],t[1])})),g&&n.addColors(D),f&&n.addColors(f),p&&(p.forEach((function(t){Array.isArray(t)?o.addPlugin(t[0],t[1]):o.addPlugin(t,{})})),o.loadPlugins(this.appService));case 21:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.getConfig=function(){var t=i(u().mark((function t(){var e;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=r.resolve(this.configPath),t.next=3,import(e);case 3:return t.abrupt("return",t.sent.default);case 6:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),t}(),T={configService:t.asClass(E).singleton()},O={pluginService:t.asClass(function(){function t(){this.pluginInstances=new Map,this.pluginConstructors=new Map}var e=t.prototype;return e.addPlugin=function(t,e){this.pluginConstructors.set(t.name,[t,e])},e.loadPlugins=function(t){var e=this;this.pluginConstructors.forEach((function(r){var n=r[0];e.pluginInstances.set(n.name,new n(t,r[1]))}))},e.getPlugin=function(t){var e=this.pluginInstances.get(t.name);if(!e)throw new Error("Plugin "+t.name+" not found");return e},t}()).singleton()};function L(t,e){return e.forEach((function(e){Object.entries(e).forEach((function(e){t.register(e[0],e[1])}))})),t}var H=t.createContainer({injectionMode:t.InjectionMode.PROXY});function M(){return M=i(u().mark((function t(e){var r;return u().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=H.resolve("configService"),e&&(r.configPath=e),t.next=4,r.loadConfig();case 4:return t.abrupt("return",H.resolve("appService"));case 5:case"end":return t.stop()}}),t)}))),M.apply(this,arguments)}L(H,[T,b,O,v,k]),exports.AppContainer=H,exports.AppModule=b,exports.AppService=P,exports.ColorEntity=g,exports.ColorManagerService=d,exports.ColorModule=v,exports.ColorService=n,exports.ConfigService=E,exports.ContrastCurve=l,exports.DynamicColor=f,exports.SchemeEntity=m,exports.SchemeService=y,exports.ThemeModule=k,exports.ThemeService=C,exports.ToneDeltaPair=h,exports.VariantEntity=function(t,e){void 0===t&&(t={}),this.palettes=void 0,this.customPalettes=void 0,this.palettes=t,this.customPalettes=e},exports.VariantModel=x,exports.VariantService=w,exports.bootstrap=function(){return H.resolve("appService")},exports.bootstrapFromConfig=function(t){return M.apply(this,arguments)},exports.defaultColors=D,exports.defineConfig=function(t){if(!t||"object"!=typeof t)throw new Error("The configuration is missing or not an object");if(!("sourceColor"in t))throw new Error("Invalid configuration");return t},exports.getRotatedHue=S,exports.highestSurface=p,exports.importContainer=L;
2
2
  //# sourceMappingURL=theme.cjs.production.min.js.map