@udixio/theme 1.0.0-beta.3 → 1.0.0-beta.30

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.
Files changed (97) hide show
  1. package/dist/app.container.d.ts +5 -0
  2. package/dist/app.module.d.ts +2 -2
  3. package/dist/app.service.d.ts +9 -3
  4. package/dist/color/color.interface.d.ts +1 -2
  5. package/dist/color/color.module.d.ts +2 -2
  6. package/dist/color/entities/color.entity.d.ts +6 -1
  7. package/dist/color/entities/index.d.ts +1 -0
  8. package/dist/color/index.d.ts +5 -0
  9. package/dist/color/models/default-color.model.d.ts +2 -3
  10. package/dist/color/models/index.d.ts +1 -0
  11. package/dist/color/services/color-manager.service.d.ts +18 -0
  12. package/dist/color/services/color.service.d.ts +21 -0
  13. package/dist/color/services/index.d.ts +2 -0
  14. package/dist/config/config.interface.d.ts +13 -0
  15. package/dist/config/config.module.d.ts +2 -0
  16. package/dist/config/config.service.d.ts +12 -0
  17. package/dist/config/index.d.ts +3 -0
  18. package/dist/index.d.ts +11 -0
  19. package/dist/main.d.ts +6 -1
  20. package/dist/material-color-utilities/index.d.ts +1 -0
  21. package/dist/plugin/index.d.ts +3 -0
  22. package/dist/plugin/plugin.module.d.ts +2 -0
  23. package/dist/plugin/plugin.service.d.ts +8 -0
  24. package/dist/plugin/pluginAbstract.d.ts +18 -0
  25. package/dist/plugins/font/font.plugin.d.ts +49 -0
  26. package/dist/plugins/font/index.d.ts +1 -0
  27. package/dist/plugins/tailwind/index.d.ts +3 -0
  28. package/dist/plugins/tailwind/main.d.ts +13 -0
  29. package/dist/plugins/tailwind/plugins-tailwind/font.d.ts +5 -0
  30. package/dist/plugins/tailwind/plugins-tailwind/index.d.ts +2 -0
  31. package/dist/plugins/tailwind/plugins-tailwind/state.d.ts +4 -0
  32. package/dist/plugins/tailwind/plugins-tailwind/themer.d.ts +10 -0
  33. package/dist/plugins/tailwind/tailwind.plugin.d.ts +18 -0
  34. package/dist/theme/entities/index.d.ts +2 -0
  35. package/dist/theme/entities/variant.entity.d.ts +2 -1
  36. package/dist/theme/index.d.ts +4 -0
  37. package/dist/theme/models/index.d.ts +1 -0
  38. package/dist/theme/services/index.d.ts +3 -0
  39. package/dist/theme/services/scheme.service.d.ts +7 -2
  40. package/dist/theme/services/theme.service.d.ts +16 -7
  41. package/dist/theme/services/variant.service.d.ts +8 -2
  42. package/dist/theme/theme.module.d.ts +2 -2
  43. package/dist/theme.cjs.development.js +1416 -906
  44. package/dist/theme.cjs.development.js.map +1 -1
  45. package/dist/theme.cjs.production.min.js +1 -1
  46. package/dist/theme.cjs.production.min.js.map +1 -1
  47. package/dist/theme.esm.js +1383 -907
  48. package/dist/theme.esm.js.map +1 -1
  49. package/package.json +21 -22
  50. package/src/app.container.ts +46 -0
  51. package/src/app.module.ts +5 -8
  52. package/src/app.service.spec.ts +1 -1
  53. package/src/app.service.ts +20 -8
  54. package/src/color/color.interface.ts +1 -3
  55. package/src/color/color.module.ts +8 -10
  56. package/src/color/entities/color.entity.ts +13 -1
  57. package/src/color/entities/index.ts +1 -0
  58. package/src/color/index.ts +5 -0
  59. package/src/color/models/default-color.model.ts +205 -202
  60. package/src/color/models/index.ts +1 -0
  61. package/src/color/{color-manager.service.ts → services/color-manager.service.ts} +23 -15
  62. package/src/color/{color.service.spec.ts → services/color.service.spec.ts} +1 -1
  63. package/src/color/services/color.service.ts +75 -0
  64. package/src/color/services/index.ts +2 -0
  65. package/src/config/config.interface.ts +14 -0
  66. package/src/config/config.module.ts +7 -0
  67. package/src/config/config.service.ts +101 -0
  68. package/src/config/index.ts +3 -0
  69. package/src/index.ts +11 -0
  70. package/src/main.ts +13 -7
  71. package/src/material-color-utilities/index.ts +1 -0
  72. package/src/plugin/index.ts +3 -0
  73. package/src/plugin/plugin.module.ts +7 -0
  74. package/src/plugin/plugin.service.ts +42 -0
  75. package/src/plugin/pluginAbstract.ts +44 -0
  76. package/src/plugins/font/font.plugin.ts +203 -0
  77. package/src/plugins/font/index.ts +1 -0
  78. package/src/plugins/tailwind/index.ts +3 -0
  79. package/src/plugins/tailwind/main.ts +16 -0
  80. package/src/plugins/tailwind/plugins-tailwind/font.ts +69 -0
  81. package/src/plugins/tailwind/plugins-tailwind/index.ts +2 -0
  82. package/src/plugins/tailwind/plugins-tailwind/state.ts +88 -0
  83. package/src/plugins/tailwind/plugins-tailwind/themer.ts +137 -0
  84. package/src/plugins/tailwind/tailwind.plugin.ts +72 -0
  85. package/src/theme/entities/index.ts +2 -0
  86. package/src/theme/entities/variant.entity.ts +2 -1
  87. package/src/theme/index.ts +4 -0
  88. package/src/theme/models/index.ts +1 -0
  89. package/src/theme/models/variant.model.ts +7 -0
  90. package/src/theme/services/index.ts +3 -0
  91. package/src/theme/services/scheme.service.ts +39 -11
  92. package/src/theme/services/theme.service.ts +30 -14
  93. package/src/theme/services/variant.service.ts +40 -5
  94. package/src/theme/theme.module.ts +8 -9
  95. package/dist/color/color-manager.service.d.ts +0 -15
  96. package/dist/color/color.service.d.ts +0 -14
  97. package/src/color/color.service.ts +0 -58
package/dist/theme.esm.js CHANGED
@@ -1,33 +1,68 @@
1
- import { NestFactory } from '@nestjs/core';
2
- import { __decorate, __metadata } from 'tslib';
3
- import { Injectable, Module } from '@nestjs/common';
4
- import { lerp, Contrast, clampDouble, hexFromArgb, Hct, argbFromHex, DislikeAnalyzer, TonalPalette } from '@material/material-color-utilities';
5
- import mergeDeep from 'merge-deep';
1
+ import { asClass, createContainer, InjectionMode } from 'awilix';
2
+ import { lerp, Contrast, clampDouble, hexFromArgb, Hct, argbFromHex, TonalPalette, DislikeAnalyzer, sanitizeDegreesDouble } from '@material/material-color-utilities';
3
+ import { resolve } from 'node:path';
4
+ import { existsSync } from 'node:fs';
5
+ import plugin from 'tailwindcss/plugin';
6
6
 
7
- function asyncGeneratorStep(n, t, e, r, o, a, c) {
8
- try {
9
- var i = n[a](c),
10
- u = i.value;
11
- } catch (n) {
12
- return void e(n);
7
+ var ColorService = /*#__PURE__*/function () {
8
+ function ColorService(_ref) {
9
+ var colorManagerService = _ref.colorManagerService;
10
+ this.colorManagerService = void 0;
11
+ this.colorManagerService = colorManagerService;
13
12
  }
14
- i.done ? t(u) : Promise.resolve(u).then(r, o);
15
- }
16
- function _asyncToGenerator(n) {
17
- return function () {
18
- var t = this,
19
- e = arguments;
20
- return new Promise(function (r, o) {
21
- var a = n.apply(t, e);
22
- function _next(n) {
23
- asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
13
+ var _proto = ColorService.prototype;
14
+ _proto.getColors = function getColors() {
15
+ return this.colorManagerService.getAll();
16
+ }
17
+ // getColors() {
18
+ // const colors: Record<string, string> = {};
19
+ //
20
+ // for (const [key, value] of this.colorManagerService.getAll()) {
21
+ // colors[key] = hexFromArgb(value.getArgb(this.schemeService.get()));
22
+ // }
23
+ //
24
+ // return colors;
25
+ // }
26
+ ;
27
+ _proto.addColor = function addColor(key, color) {
28
+ return this.colorManagerService.createOrUpdate(key, color);
29
+ };
30
+ _proto.addColors = function addColors(args) {
31
+ var _this = this;
32
+ if (!Array.isArray(args)) args = [args];
33
+ args.forEach(function (args) {
34
+ if (typeof args === 'function') {
35
+ args = args(_this);
36
+ }
37
+ if (args.fromPalettes) {
38
+ if (!Array.isArray(args.fromPalettes)) args.fromPalettes = [args.fromPalettes];
39
+ args.fromPalettes.map(function (paletteKey) {
40
+ _this.colorManagerService.addFromPalette(paletteKey);
41
+ });
24
42
  }
25
- function _throw(n) {
26
- asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
43
+ if (args.colors) {
44
+ Object.keys(args.colors).map(function (key) {
45
+ return _this.addColor(key, args.colors[key]);
46
+ });
27
47
  }
28
- _next(void 0);
29
48
  });
30
49
  };
50
+ _proto.getColor = function getColor(key) {
51
+ return this.colorManagerService.get(key);
52
+ };
53
+ _proto.removeColor = function removeColor(key) {
54
+ return this.colorManagerService.remove(key);
55
+ };
56
+ _proto.updateColor = function updateColor(key, newColor) {
57
+ return this.colorManagerService.createOrUpdate(key, newColor);
58
+ };
59
+ return ColorService;
60
+ }();
61
+
62
+ function _arrayLikeToArray(r, a) {
63
+ (null == a || a > r.length) && (a = r.length);
64
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
65
+ return n;
31
66
  }
32
67
  function _defineProperties(e, r) {
33
68
  for (var t = 0; t < r.length; t++) {
@@ -40,6 +75,23 @@ function _createClass(e, r, t) {
40
75
  writable: !1
41
76
  }), e;
42
77
  }
78
+ function _createForOfIteratorHelperLoose(r, e) {
79
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
80
+ if (t) return (t = t.call(r)).next.bind(t);
81
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
82
+ t && (r = t);
83
+ var o = 0;
84
+ return function () {
85
+ return o >= r.length ? {
86
+ done: !0
87
+ } : {
88
+ done: !1,
89
+ value: r[o++]
90
+ };
91
+ };
92
+ }
93
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
94
+ }
43
95
  function _extends() {
44
96
  return _extends = Object.assign ? Object.assign.bind() : function (n) {
45
97
  for (var e = 1; e < arguments.length; e++) {
@@ -49,306 +101,13 @@ function _extends() {
49
101
  return n;
50
102
  }, _extends.apply(null, arguments);
51
103
  }
52
- function _regeneratorRuntime() {
53
- _regeneratorRuntime = function () {
54
- return e;
55
- };
56
- var t,
57
- e = {},
58
- r = Object.prototype,
59
- n = r.hasOwnProperty,
60
- o = Object.defineProperty || function (t, e, r) {
61
- t[e] = r.value;
62
- },
63
- i = "function" == typeof Symbol ? Symbol : {},
64
- a = i.iterator || "@@iterator",
65
- c = i.asyncIterator || "@@asyncIterator",
66
- u = i.toStringTag || "@@toStringTag";
67
- function define(t, e, r) {
68
- return Object.defineProperty(t, e, {
69
- value: r,
70
- enumerable: !0,
71
- configurable: !0,
72
- writable: !0
73
- }), t[e];
74
- }
75
- try {
76
- define({}, "");
77
- } catch (t) {
78
- define = function (t, e, r) {
79
- return t[e] = r;
80
- };
81
- }
82
- function wrap(t, e, r, n) {
83
- var i = e && e.prototype instanceof Generator ? e : Generator,
84
- a = Object.create(i.prototype),
85
- c = new Context(n || []);
86
- return o(a, "_invoke", {
87
- value: makeInvokeMethod(t, r, c)
88
- }), a;
89
- }
90
- function tryCatch(t, e, r) {
91
- try {
92
- return {
93
- type: "normal",
94
- arg: t.call(e, r)
95
- };
96
- } catch (t) {
97
- return {
98
- type: "throw",
99
- arg: t
100
- };
101
- }
102
- }
103
- e.wrap = wrap;
104
- var h = "suspendedStart",
105
- l = "suspendedYield",
106
- f = "executing",
107
- s = "completed",
108
- y = {};
109
- function Generator() {}
110
- function GeneratorFunction() {}
111
- function GeneratorFunctionPrototype() {}
112
- var p = {};
113
- define(p, a, function () {
114
- return this;
115
- });
116
- var d = Object.getPrototypeOf,
117
- v = d && d(d(values([])));
118
- v && v !== r && n.call(v, a) && (p = v);
119
- var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
120
- function defineIteratorMethods(t) {
121
- ["next", "throw", "return"].forEach(function (e) {
122
- define(t, e, function (t) {
123
- return this._invoke(e, t);
124
- });
125
- });
126
- }
127
- function AsyncIterator(t, e) {
128
- function invoke(r, o, i, a) {
129
- var c = tryCatch(t[r], t, o);
130
- if ("throw" !== c.type) {
131
- var u = c.arg,
132
- h = u.value;
133
- return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
134
- invoke("next", t, i, a);
135
- }, function (t) {
136
- invoke("throw", t, i, a);
137
- }) : e.resolve(h).then(function (t) {
138
- u.value = t, i(u);
139
- }, function (t) {
140
- return invoke("throw", t, i, a);
141
- });
142
- }
143
- a(c.arg);
144
- }
145
- var r;
146
- o(this, "_invoke", {
147
- value: function (t, n) {
148
- function callInvokeWithMethodAndArg() {
149
- return new e(function (e, r) {
150
- invoke(t, n, e, r);
151
- });
152
- }
153
- return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
154
- }
155
- });
156
- }
157
- function makeInvokeMethod(e, r, n) {
158
- var o = h;
159
- return function (i, a) {
160
- if (o === f) throw Error("Generator is already running");
161
- if (o === s) {
162
- if ("throw" === i) throw a;
163
- return {
164
- value: t,
165
- done: !0
166
- };
167
- }
168
- for (n.method = i, n.arg = a;;) {
169
- var c = n.delegate;
170
- if (c) {
171
- var u = maybeInvokeDelegate(c, n);
172
- if (u) {
173
- if (u === y) continue;
174
- return u;
175
- }
176
- }
177
- if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
178
- if (o === h) throw o = s, n.arg;
179
- n.dispatchException(n.arg);
180
- } else "return" === n.method && n.abrupt("return", n.arg);
181
- o = f;
182
- var p = tryCatch(e, r, n);
183
- if ("normal" === p.type) {
184
- if (o = n.done ? s : l, p.arg === y) continue;
185
- return {
186
- value: p.arg,
187
- done: n.done
188
- };
189
- }
190
- "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
191
- }
192
- };
193
- }
194
- function maybeInvokeDelegate(e, r) {
195
- var n = r.method,
196
- o = e.iterator[n];
197
- if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
198
- var i = tryCatch(o, e.iterator, r.arg);
199
- if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
200
- var a = i.arg;
201
- 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, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
202
- }
203
- function pushTryEntry(t) {
204
- var e = {
205
- tryLoc: t[0]
206
- };
207
- 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
208
- }
209
- function resetTryEntry(t) {
210
- var e = t.completion || {};
211
- e.type = "normal", delete e.arg, t.completion = e;
212
- }
213
- function Context(t) {
214
- this.tryEntries = [{
215
- tryLoc: "root"
216
- }], t.forEach(pushTryEntry, this), this.reset(!0);
217
- }
218
- function values(e) {
219
- if (e || "" === e) {
220
- var r = e[a];
221
- if (r) return r.call(e);
222
- if ("function" == typeof e.next) return e;
223
- if (!isNaN(e.length)) {
224
- var o = -1,
225
- i = function next() {
226
- for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
227
- return next.value = t, next.done = !0, next;
228
- };
229
- return i.next = i;
230
- }
231
- }
232
- throw new TypeError(typeof e + " is not iterable");
233
- }
234
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
235
- value: GeneratorFunctionPrototype,
236
- configurable: !0
237
- }), o(GeneratorFunctionPrototype, "constructor", {
238
- value: GeneratorFunction,
239
- configurable: !0
240
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
241
- var e = "function" == typeof t && t.constructor;
242
- return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
243
- }, e.mark = function (t) {
244
- return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
245
- }, e.awrap = function (t) {
246
- return {
247
- __await: t
248
- };
249
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
250
- return this;
251
- }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
252
- void 0 === i && (i = Promise);
253
- var a = new AsyncIterator(wrap(t, r, n, o), i);
254
- return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
255
- return t.done ? t.value : a.next();
256
- });
257
- }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
258
- return this;
259
- }), define(g, "toString", function () {
260
- return "[object Generator]";
261
- }), e.keys = function (t) {
262
- var e = Object(t),
263
- r = [];
264
- for (var n in e) r.push(n);
265
- return r.reverse(), function next() {
266
- for (; r.length;) {
267
- var t = r.pop();
268
- if (t in e) return next.value = t, next.done = !1, next;
269
- }
270
- return next.done = !0, next;
271
- };
272
- }, e.values = values, Context.prototype = {
273
- constructor: Context,
274
- reset: function (e) {
275
- 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(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
276
- },
277
- stop: function () {
278
- this.done = !0;
279
- var t = this.tryEntries[0].completion;
280
- if ("throw" === t.type) throw t.arg;
281
- return this.rval;
282
- },
283
- dispatchException: function (e) {
284
- if (this.done) throw e;
285
- var r = this;
286
- function handle(n, o) {
287
- return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
288
- }
289
- for (var o = this.tryEntries.length - 1; o >= 0; --o) {
290
- var i = this.tryEntries[o],
291
- a = i.completion;
292
- if ("root" === i.tryLoc) return handle("end");
293
- if (i.tryLoc <= this.prev) {
294
- var c = n.call(i, "catchLoc"),
295
- u = n.call(i, "finallyLoc");
296
- if (c && u) {
297
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
298
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
299
- } else if (c) {
300
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
301
- } else {
302
- if (!u) throw Error("try statement without catch or finally");
303
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
304
- }
305
- }
306
- }
307
- },
308
- abrupt: function (t, e) {
309
- for (var r = this.tryEntries.length - 1; r >= 0; --r) {
310
- var o = this.tryEntries[r];
311
- if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
312
- var i = o;
313
- break;
314
- }
315
- }
316
- i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
317
- var a = i ? i.completion : {};
318
- return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
319
- },
320
- complete: function (t, e) {
321
- if ("throw" === t.type) throw t.arg;
322
- 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), y;
323
- },
324
- finish: function (t) {
325
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
326
- var r = this.tryEntries[e];
327
- if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
328
- }
329
- },
330
- catch: function (t) {
331
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
332
- var r = this.tryEntries[e];
333
- if (r.tryLoc === t) {
334
- var n = r.completion;
335
- if ("throw" === n.type) {
336
- var o = n.arg;
337
- resetTryEntry(r);
338
- }
339
- return o;
340
- }
341
- }
342
- throw Error("illegal catch attempt");
343
- },
344
- delegateYield: function (e, r, n) {
345
- return this.delegate = {
346
- iterator: values(e),
347
- resultName: r,
348
- nextLoc: n
349
- }, "next" === this.method && (this.arg = t), y;
350
- }
351
- }, e;
104
+ function _inheritsLoose(t, o) {
105
+ t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
106
+ }
107
+ function _setPrototypeOf(t, e) {
108
+ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
109
+ return t.__proto__ = e, t;
110
+ }, _setPrototypeOf(t, e);
352
111
  }
353
112
  function _toPrimitive(t, r) {
354
113
  if ("object" != typeof t || !t) return t;
@@ -364,6 +123,13 @@ function _toPropertyKey(t) {
364
123
  var i = _toPrimitive(t, "string");
365
124
  return "symbol" == typeof i ? i : i + "";
366
125
  }
126
+ function _unsupportedIterableToArray(r, a) {
127
+ if (r) {
128
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
129
+ var t = {}.toString.call(r).slice(8, -1);
130
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
131
+ }
132
+ }
367
133
 
368
134
  /**
369
135
  * @license
@@ -431,67 +197,6 @@ var ContrastCurve = /*#__PURE__*/function () {
431
197
  return ContrastCurve;
432
198
  }();
433
199
 
434
- /**
435
- * @license
436
- * Copyright 2023 Google LLC
437
- *
438
- * Licensed under the Apache License, Version 2.0 (the "License");
439
- * you may not use this file except in compliance with the License.
440
- * You may obtain a copy of the License at
441
- *
442
- * http://www.apache.org/licenses/LICENSE-2.0
443
- *
444
- * Unless required by applicable law or agreed to in writing, software
445
- * distributed under the License is distributed on an "AS IS" BASIS,
446
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
447
- * See the License for the specific language governing permissions and
448
- * limitations under the License.
449
- */
450
- /**
451
- * Documents a constraint between two DynamicColors, in which their tones must
452
- * have a certain distance from each other.
453
- *
454
- * Prefer a DynamicColor with a background, this is for special cases when
455
- * designers want tonal distance, literally contrast, between two colors that
456
- * don't have a background / foreground relationship or a contrast guarantee.
457
- */
458
- var ToneDeltaPair =
459
- /**
460
- * Documents a constraint in tone distance between two DynamicColors.
461
- *
462
- * The polarity is an adjective that describes "A", compared to "B".
463
- *
464
- * For instance, ToneDeltaPair(A, B, 15, 'darker', stayTogether) states that
465
- * A's tone should be at least 15 darker than B's.
466
- *
467
- * 'nearer' and 'farther' describes closeness to the surface roles. For
468
- * instance, ToneDeltaPair(A, B, 10, 'nearer', stayTogether) states that A
469
- * should be 10 lighter than B in light mode, and 10 darker than B in dark
470
- * mode.
471
- *
472
- * @param roleA The first role in a pair.
473
- * @param roleB The second role in a pair.
474
- * @param delta Required difference between tones. Absolute value, negative
475
- * values have undefined behavior.
476
- * @param polarity The relative relation between tones of roleA and roleB,
477
- * as described above.
478
- * @param stayTogether Whether these two roles should stay on the same side of
479
- * the "awkward zone" (T50-59). This is necessary for certain cases where
480
- * one role has two backgrounds.
481
- */
482
- function ToneDeltaPair(roleA, roleB, delta, polarity, stayTogether) {
483
- this.roleA = void 0;
484
- this.roleB = void 0;
485
- this.delta = void 0;
486
- this.polarity = void 0;
487
- this.stayTogether = void 0;
488
- this.roleA = roleA;
489
- this.roleB = roleB;
490
- this.delta = delta;
491
- this.polarity = polarity;
492
- this.stayTogether = stayTogether;
493
- };
494
-
495
200
  /**
496
201
  * @license
497
202
  * Copyright 2022 Google LLC
@@ -828,6 +533,74 @@ var DynamicColor = /*#__PURE__*/function () {
828
533
  return DynamicColor;
829
534
  }();
830
535
 
536
+ /**
537
+ * @license
538
+ * Copyright 2023 Google LLC
539
+ *
540
+ * Licensed under the Apache License, Version 2.0 (the "License");
541
+ * you may not use this file except in compliance with the License.
542
+ * You may obtain a copy of the License at
543
+ *
544
+ * http://www.apache.org/licenses/LICENSE-2.0
545
+ *
546
+ * Unless required by applicable law or agreed to in writing, software
547
+ * distributed under the License is distributed on an "AS IS" BASIS,
548
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
549
+ * See the License for the specific language governing permissions and
550
+ * limitations under the License.
551
+ */
552
+ /**
553
+ * Documents a constraint between two DynamicColors, in which their tones must
554
+ * have a certain distance from each other.
555
+ *
556
+ * Prefer a DynamicColor with a background, this is for special cases when
557
+ * designers want tonal distance, literally contrast, between two colors that
558
+ * don't have a background / foreground relationship or a contrast guarantee.
559
+ */
560
+ var ToneDeltaPair =
561
+ /**
562
+ * Documents a constraint in tone distance between two DynamicColors.
563
+ *
564
+ * The polarity is an adjective that describes "A", compared to "B".
565
+ *
566
+ * For instance, ToneDeltaPair(A, B, 15, 'darker', stayTogether) states that
567
+ * A's tone should be at least 15 darker than B's.
568
+ *
569
+ * 'nearer' and 'farther' describes closeness to the surface roles. For
570
+ * instance, ToneDeltaPair(A, B, 10, 'nearer', stayTogether) states that A
571
+ * should be 10 lighter than B in light mode, and 10 darker than B in dark
572
+ * mode.
573
+ *
574
+ * @param roleA The first role in a pair.
575
+ * @param roleB The second role in a pair.
576
+ * @param delta Required difference between tones. Absolute value, negative
577
+ * values have undefined behavior.
578
+ * @param polarity The relative relation between tones of roleA and roleB,
579
+ * as described above.
580
+ * @param stayTogether Whether these two roles should stay on the same side of
581
+ * the "awkward zone" (T50-59). This is necessary for certain cases where
582
+ * one role has two backgrounds.
583
+ */
584
+ function ToneDeltaPair(roleA, roleB, delta, polarity, stayTogether) {
585
+ this.roleA = void 0;
586
+ this.roleB = void 0;
587
+ this.delta = void 0;
588
+ this.polarity = void 0;
589
+ this.stayTogether = void 0;
590
+ this.roleA = roleA;
591
+ this.roleB = roleB;
592
+ this.delta = delta;
593
+ this.polarity = polarity;
594
+ this.stayTogether = stayTogether;
595
+ };
596
+
597
+ function argbToRgb(argb) {
598
+ return {
599
+ r: argb >> 16 & 0xff,
600
+ g: argb >> 8 & 0xff,
601
+ b: argb & 0xff
602
+ };
603
+ }
831
604
  var ColorEntity = /*#__PURE__*/function () {
832
605
  function ColorEntity(option, schemeService, colorService) {
833
606
  this.option = void 0;
@@ -849,6 +622,9 @@ var ColorEntity = /*#__PURE__*/function () {
849
622
  _proto.getArgb = function getArgb() {
850
623
  return this.getDynamicColor().getArgb(this.schemeService.get());
851
624
  };
625
+ _proto.getRgb = function getRgb() {
626
+ return argbToRgb(this.getArgb());
627
+ };
852
628
  _proto.getName = function getName() {
853
629
  return this.option.name.replace(/([A-Z])/g, '_$1').toLowerCase();
854
630
  };
@@ -863,95 +639,21 @@ var ColorEntity = /*#__PURE__*/function () {
863
639
  return ColorEntity;
864
640
  }();
865
641
 
866
- var SchemeEntity = /*#__PURE__*/function () {
867
- function SchemeEntity(options) {
868
- this.options = void 0;
869
- this.options = options;
642
+ function capitalizeFirstLetter(string) {
643
+ return string.charAt(0).toUpperCase() + string.slice(1);
644
+ }
645
+ var highestSurface = function highestSurface(s, colorService) {
646
+ if (colorService instanceof ColorService) {
647
+ return s.isDark ? colorService.getColor('surfaceBright').getDynamicColor() : colorService.getColor('surfaceDim').getDynamicColor();
648
+ } else {
649
+ return s.isDark ? colorService.get('surfaceBright').getDynamicColor() : colorService.get('surfaceDim').getDynamicColor();
870
650
  }
871
- var _proto = SchemeEntity.prototype;
872
- _proto.getPalette = function getPalette(key) {
873
- if (!this.options) {
874
- throw new Error('Scheme options is not set');
875
- }
876
- var palette = this.options.palettes.get(key);
877
- if (!palette) {
878
- throw new Error("Palette " + key + " not found");
879
- }
880
- return palette;
881
- };
882
- return _createClass(SchemeEntity, [{
883
- key: "contrastLevel",
884
- get: function get() {
885
- if (!this.options) {
886
- throw new Error('Scheme options is not set');
887
- }
888
- return this.options.contrastLevel;
889
- }
890
- }, {
891
- key: "isDark",
892
- get: function get() {
893
- if (!this.options) {
894
- throw new Error('Scheme options is not set');
895
- }
896
- return this.options.isDark;
897
- }
898
- }, {
899
- key: "sourceColorHct",
900
- get: function get() {
901
- if (!this.options) {
902
- throw new Error('Scheme options is not set');
903
- }
904
- return Hct.fromInt(this.options.sourceColorArgb);
905
- }
906
- }]);
907
- }();
908
-
909
- var SchemeService = /*#__PURE__*/function () {
910
- function SchemeService() {
911
- this.schemeEntity = void 0;
912
- this.options = void 0;
913
- }
914
- var _proto = SchemeService.prototype;
915
- _proto.createOrUpdate = function createOrUpdate(options) {
916
- this.options = mergeDeep(options, this.options);
917
- var palettes = new Map();
918
- var sourceColorArgb = argbFromHex(this.options.sourceColorHex);
919
- var sourceColorHct = Hct.fromInt(sourceColorArgb);
920
- if (!this.options.palettes) {
921
- return;
922
- }
923
- for (var _i = 0, _Object$entries = Object.entries(this.options.palettes); _i < _Object$entries.length; _i++) {
924
- var _Object$entries$_i = _Object$entries[_i],
925
- key = _Object$entries$_i[0],
926
- paletteFunction = _Object$entries$_i[1];
927
- var palette = paletteFunction(sourceColorHct);
928
- palettes.set(key, palette);
929
- }
930
- this.schemeEntity = new SchemeEntity(_extends({}, this.options, {
931
- palettes: palettes,
932
- sourceColorArgb: sourceColorArgb
933
- }));
934
- };
935
- _proto.get = function get() {
936
- if (!this.schemeEntity) {
937
- throw new Error('Scheme is not created');
938
- }
939
- return this.schemeEntity;
940
- };
941
- return SchemeService;
942
- }();
943
- SchemeService = /*#__PURE__*/__decorate([/*#__PURE__*/Injectable()], SchemeService);
944
-
945
- function capitalizeFirstLetter(string) {
946
- return string.charAt(0).toUpperCase() + string.slice(1);
947
- }
948
- var highestSurface = function highestSurface(s, colorManagerService) {
949
- return s.isDark ? colorManagerService.get('surfaceBright').getDynamicColor() : colorManagerService.get('surfaceDim').getDynamicColor();
950
651
  };
951
652
  var ColorManagerService = /*#__PURE__*/function () {
952
- function ColorManagerService(schemeService) {
953
- this.schemeService = void 0;
653
+ function ColorManagerService(_ref) {
654
+ var schemeService = _ref.schemeService;
954
655
  this.colorMap = new Map();
656
+ this.schemeService = void 0;
955
657
  this.schemeService = schemeService;
956
658
  }
957
659
  var _proto = ColorManagerService.prototype;
@@ -1017,7 +719,7 @@ var ColorManagerService = /*#__PURE__*/function () {
1017
719
  },
1018
720
  contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
1019
721
  toneDeltaPair: function toneDeltaPair(s) {
1020
- return new ToneDeltaPair(_this.get(colorKeyContainer).getDynamicColor(), _this.get(colorKey).getDynamicColor(), 15, 'nearer', false);
722
+ return new ToneDeltaPair(_this.get(colorKeyContainer).getDynamicColor(), _this.get(colorKey).getDynamicColor(), 10, 'nearer', false);
1021
723
  }
1022
724
  });
1023
725
  this.createOrUpdate(onColorKey, {
@@ -1045,7 +747,7 @@ var ColorManagerService = /*#__PURE__*/function () {
1045
747
  },
1046
748
  contrastCurve: new ContrastCurve(1, 1, 3, 7),
1047
749
  toneDeltaPair: function toneDeltaPair(s) {
1048
- return new ToneDeltaPair(_this.get(colorKeyContainer).getDynamicColor(), _this.get(colorKey).getDynamicColor(), 15, 'nearer', false);
750
+ return new ToneDeltaPair(_this.get(colorKeyContainer).getDynamicColor(), _this.get(colorKey).getDynamicColor(), 10, 'nearer', false);
1049
751
  }
1050
752
  });
1051
753
  this.createOrUpdate(onColorKeyContainer, {
@@ -1137,7 +839,226 @@ var ColorManagerService = /*#__PURE__*/function () {
1137
839
  };
1138
840
  return ColorManagerService;
1139
841
  }();
1140
- ColorManagerService = /*#__PURE__*/__decorate([/*#__PURE__*/Injectable(), /*#__PURE__*/__metadata("design:paramtypes", [SchemeService])], ColorManagerService);
842
+
843
+ var ColorModule = {
844
+ colorManagerService: /*#__PURE__*/asClass(ColorManagerService).singleton(),
845
+ colorService: /*#__PURE__*/asClass(ColorService).singleton()
846
+ };
847
+
848
+ var SchemeEntity = /*#__PURE__*/function () {
849
+ function SchemeEntity(options) {
850
+ this.options = void 0;
851
+ this.options = options;
852
+ }
853
+ var _proto = SchemeEntity.prototype;
854
+ _proto.getPalette = function getPalette(key) {
855
+ if (!this.options) {
856
+ throw new Error('Scheme options is not set');
857
+ }
858
+ var palette = this.options.palettes.get(key);
859
+ if (!palette) {
860
+ throw new Error("Palette " + key + " not found");
861
+ }
862
+ return palette;
863
+ };
864
+ return _createClass(SchemeEntity, [{
865
+ key: "contrastLevel",
866
+ get: function get() {
867
+ if (!this.options) {
868
+ throw new Error('Scheme options is not set');
869
+ }
870
+ return this.options.contrastLevel;
871
+ }
872
+ }, {
873
+ key: "isDark",
874
+ get: function get() {
875
+ if (!this.options) {
876
+ throw new Error('Scheme options is not set');
877
+ }
878
+ return this.options.isDark;
879
+ }
880
+ }, {
881
+ key: "sourceColorHct",
882
+ get: function get() {
883
+ if (!this.options) {
884
+ throw new Error('Scheme options is not set');
885
+ }
886
+ return Hct.fromInt(this.options.sourceColorArgb);
887
+ }
888
+ }]);
889
+ }();
890
+
891
+ var SchemeService = /*#__PURE__*/function () {
892
+ function SchemeService() {
893
+ this.schemeEntity = void 0;
894
+ this.options = void 0;
895
+ }
896
+ var _proto = SchemeService.prototype;
897
+ _proto.createOrUpdate = function createOrUpdate(options) {
898
+ var _this$options, _this$options2;
899
+ this.options = _extends({}, this.options, options, {
900
+ sourcesColorHex: _extends({}, (_this$options = this.options) == null ? void 0 : _this$options.sourcesColorHex, options.sourcesColorHex),
901
+ palettes: _extends({}, (_this$options2 = this.options) == null ? void 0 : _this$options2.palettes, options.palettes)
902
+ });
903
+ var palettes = new Map();
904
+ if (!this.options.sourcesColorHex.primary) {
905
+ throw new Error('Primary source color is not set');
906
+ }
907
+ var sourceColorArgb = argbFromHex(this.options.sourcesColorHex.primary);
908
+ var sourceColorHct = Hct.fromInt(sourceColorArgb);
909
+ if (!this.options.palettes) {
910
+ return;
911
+ }
912
+ for (var _i = 0, _Object$entries = Object.entries(this.options.palettes); _i < _Object$entries.length; _i++) {
913
+ var _Object$entries$_i = _Object$entries[_i],
914
+ key = _Object$entries$_i[0],
915
+ _Object$entries$_i$ = _Object$entries$_i[1],
916
+ sourceColorkey = _Object$entries$_i$.sourceColorkey,
917
+ paletteFunction = _Object$entries$_i$.tonalPalette;
918
+ var palette = void 0;
919
+ if (!sourceColorkey) {
920
+ palette = paletteFunction(sourceColorHct);
921
+ } else {
922
+ var _sourceColorArgb = argbFromHex(this.options.sourcesColorHex[sourceColorkey]);
923
+ var _sourceColorHct = Hct.fromInt(_sourceColorArgb);
924
+ palette = paletteFunction(_sourceColorHct);
925
+ }
926
+ palettes.set(key, palette);
927
+ }
928
+ this.schemeEntity = new SchemeEntity(_extends({}, this.options, {
929
+ palettes: palettes,
930
+ sourceColorArgb: sourceColorArgb
931
+ }));
932
+ };
933
+ _proto.get = function get() {
934
+ if (!this.schemeEntity) {
935
+ throw new Error('Scheme is not created');
936
+ }
937
+ return this.schemeEntity;
938
+ };
939
+ return SchemeService;
940
+ }();
941
+
942
+ var ThemeService = /*#__PURE__*/function () {
943
+ function ThemeService(_ref) {
944
+ var schemeService = _ref.schemeService,
945
+ variantService = _ref.variantService;
946
+ this.schemeService = void 0;
947
+ this.variantService = void 0;
948
+ this.schemeService = schemeService;
949
+ this.variantService = variantService;
950
+ // this.addPalette({key: "primary", addDefaultColors: true})
951
+ // this.addPalette({key: "secondary", addDefaultColors: true})
952
+ // this.addPalette({key: "tertiary", addDefaultColors: true})
953
+ // this.addPalette({key: "error", palette: TonalPalette.fromHueAndChroma(25.0, 84.0)})
954
+ // this.addPalette({key: "neutral"})
955
+ // this.addPalette({key: "neutralVariant"})
956
+ }
957
+ // addPalette({key, palette, addDefaultColors}: {key: string; palette: TonalPalette; addDefaultColors: boolean}) {
958
+ // this.themeOptions.palettes.set(key, palette);
959
+ // if (addDefaultColors){
960
+ // this.colorService.addPalette(key)
961
+ // }
962
+ // }
963
+ // create(args: ThemeOptions): SchemeService {
964
+ // return new SchemeService(args, this.colorService)
965
+ // }
966
+ //
967
+ // update(options: Partial<ThemeOptions>): SchemeService {
968
+ // Object.assign(this.themeOptions, options);
969
+ // return this.theme();
970
+ // }
971
+ var _proto = ThemeService.prototype;
972
+ _proto.create = function create(options) {
973
+ this.schemeService.createOrUpdate(_extends({}, options, {
974
+ sourcesColorHex: {
975
+ primary: options.sourceColorHex
976
+ }
977
+ }));
978
+ this.variantService.set(options.variant);
979
+ };
980
+ _proto.update = function update(options) {
981
+ var themeOptions = _extends({}, options);
982
+ if (options.sourceColorHex) themeOptions.sourcesColorHex = {
983
+ primary: options.sourceColorHex
984
+ };
985
+ this.schemeService.createOrUpdate(themeOptions);
986
+ if (options.variant) this.variantService.set(options.variant);
987
+ };
988
+ _proto.addCustomPalette = function addCustomPalette(key, colorHex) {
989
+ this.variantService.addCustomPalette(key, colorHex);
990
+ };
991
+ return ThemeService;
992
+ }();
993
+
994
+ var VariantService = /*#__PURE__*/function () {
995
+ function VariantService(_ref) {
996
+ var schemeService = _ref.schemeService;
997
+ this.customPalettes = {};
998
+ this.variantEntity = void 0;
999
+ this.schemeService = void 0;
1000
+ this.schemeService = schemeService;
1001
+ }
1002
+ var _proto = VariantService.prototype;
1003
+ _proto.addCustomPalette = function addCustomPalette(key, colorHex) {
1004
+ this.customPalettes[key] = colorHex;
1005
+ this.update();
1006
+ };
1007
+ _proto.set = function set(variantEntity) {
1008
+ this.variantEntity = variantEntity;
1009
+ if (!variantEntity.palettes.error) {
1010
+ variantEntity.palettes.error = function () {
1011
+ return TonalPalette.fromHueAndChroma(25.0, 84.0);
1012
+ };
1013
+ }
1014
+ this.update();
1015
+ };
1016
+ _proto.update = function update() {
1017
+ var _this = this;
1018
+ if (!this.variantEntity) return;
1019
+ var palettes = {};
1020
+ Object.keys(this.variantEntity.palettes).forEach(function (key) {
1021
+ palettes[key] = {
1022
+ tonalPalette: _this.variantEntity.palettes[key]
1023
+ };
1024
+ });
1025
+ if (this.variantEntity.customPalettes) {
1026
+ Object.keys(this.customPalettes).forEach(function (key) {
1027
+ palettes[key] = {
1028
+ sourceColorkey: key,
1029
+ tonalPalette: _this.variantEntity.customPalettes
1030
+ };
1031
+ });
1032
+ }
1033
+ this.schemeService.createOrUpdate({
1034
+ sourcesColorHex: this.customPalettes,
1035
+ palettes: palettes
1036
+ });
1037
+ };
1038
+ return VariantService;
1039
+ }();
1040
+
1041
+ var ThemeModule = {
1042
+ schemeService: /*#__PURE__*/asClass(SchemeService).singleton(),
1043
+ variantService: /*#__PURE__*/asClass(VariantService).singleton(),
1044
+ themeService: /*#__PURE__*/asClass(ThemeService).singleton()
1045
+ };
1046
+
1047
+ var AppService = function AppService(_ref) {
1048
+ var colorService = _ref.colorService,
1049
+ themeService = _ref.themeService,
1050
+ pluginService = _ref.pluginService;
1051
+ this.colorService = void 0;
1052
+ this.themeService = void 0;
1053
+ this.pluginService = void 0;
1054
+ this.pluginService = pluginService;
1055
+ this.colorService = colorService;
1056
+ this.themeService = themeService;
1057
+ };
1058
+
1059
+ var AppModule = {
1060
+ appService: /*#__PURE__*/asClass(AppService).singleton()
1061
+ };
1141
1062
 
1142
1063
  function findDesiredChromaByTone(hue, chroma, tone, byDecreasingTone) {
1143
1064
  var answer = tone;
@@ -1163,485 +1084,1040 @@ function findDesiredChromaByTone(hue, chroma, tone, byDecreasingTone) {
1163
1084
  }
1164
1085
  return answer;
1165
1086
  }
1166
- var defaultColors = function defaultColors(colorManagerService) {
1087
+ var defaultColors = function defaultColors(colorService) {
1167
1088
  return {
1168
- background: {
1169
- palette: function palette(s) {
1170
- return s.getPalette('neutral');
1089
+ fromPalettes: ['primary', 'secondary', 'tertiary'],
1090
+ colors: {
1091
+ background: {
1092
+ palette: function palette(s) {
1093
+ return s.getPalette('neutral');
1094
+ },
1095
+ tone: function tone(s) {
1096
+ return s.isDark ? 6 : 98;
1097
+ },
1098
+ isBackground: true
1099
+ },
1100
+ onBackground: {
1101
+ palette: function palette(s) {
1102
+ return s.getPalette('neutral');
1103
+ },
1104
+ tone: function tone(s) {
1105
+ return s.isDark ? 90 : 10;
1106
+ },
1107
+ background: function background(s) {
1108
+ return colorService.getColor('background').getDynamicColor();
1109
+ },
1110
+ contrastCurve: new ContrastCurve(3, 3, 4.5, 7)
1111
+ },
1112
+ surface: {
1113
+ palette: function palette(s) {
1114
+ return s.getPalette('neutral');
1115
+ },
1116
+ tone: function tone(s) {
1117
+ return s.isDark ? 6 : 98;
1118
+ },
1119
+ isBackground: true
1120
+ },
1121
+ surfaceDim: {
1122
+ palette: function palette(s) {
1123
+ return s.getPalette('neutral');
1124
+ },
1125
+ tone: function tone(s) {
1126
+ return s.isDark ? 6 : 87;
1127
+ },
1128
+ isBackground: true
1129
+ },
1130
+ surfaceBright: {
1131
+ palette: function palette(s) {
1132
+ return s.getPalette('neutral');
1133
+ },
1134
+ tone: function tone(s) {
1135
+ return s.isDark ? 24 : 98;
1136
+ },
1137
+ isBackground: true
1138
+ },
1139
+ surfaceContainerLowest: {
1140
+ palette: function palette(s) {
1141
+ return s.getPalette('neutral');
1142
+ },
1143
+ tone: function tone(s) {
1144
+ return s.isDark ? 4 : 100;
1145
+ },
1146
+ isBackground: true
1147
+ },
1148
+ surfaceContainerLow: {
1149
+ palette: function palette(s) {
1150
+ return s.getPalette('neutral');
1151
+ },
1152
+ tone: function tone(s) {
1153
+ return s.isDark ? 10 : 96;
1154
+ },
1155
+ isBackground: true
1156
+ },
1157
+ surfaceContainer: {
1158
+ palette: function palette(s) {
1159
+ return s.getPalette('neutral');
1160
+ },
1161
+ tone: function tone(s) {
1162
+ return s.isDark ? 12 : 94;
1163
+ },
1164
+ isBackground: true
1165
+ },
1166
+ surfaceContainerHigh: {
1167
+ palette: function palette(s) {
1168
+ return s.getPalette('neutral');
1169
+ },
1170
+ tone: function tone(s) {
1171
+ return s.isDark ? 17 : 92;
1172
+ },
1173
+ isBackground: true
1174
+ },
1175
+ surfaceContainerHighest: {
1176
+ palette: function palette(s) {
1177
+ return s.getPalette('neutral');
1178
+ },
1179
+ tone: function tone(s) {
1180
+ return s.isDark ? 22 : 90;
1181
+ },
1182
+ isBackground: true
1183
+ },
1184
+ onSurface: {
1185
+ palette: function palette(s) {
1186
+ return s.getPalette('neutral');
1187
+ },
1188
+ tone: function tone(s) {
1189
+ return s.isDark ? 90 : 10;
1190
+ },
1191
+ background: function background(s) {
1192
+ return highestSurface(s, colorService);
1193
+ },
1194
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
1195
+ },
1196
+ surfaceVariant: {
1197
+ palette: function palette(s) {
1198
+ return s.getPalette('neutralVariant');
1199
+ },
1200
+ tone: function tone(s) {
1201
+ return s.isDark ? 30 : 90;
1202
+ },
1203
+ isBackground: true
1204
+ },
1205
+ onSurfaceVariant: {
1206
+ palette: function palette(s) {
1207
+ return s.getPalette('neutralVariant');
1208
+ },
1209
+ tone: function tone(s) {
1210
+ return s.isDark ? 80 : 30;
1211
+ },
1212
+ background: function background(s) {
1213
+ return highestSurface(s, colorService);
1214
+ },
1215
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
1216
+ },
1217
+ inverseSurface: {
1218
+ palette: function palette(s) {
1219
+ return s.getPalette('neutral');
1220
+ },
1221
+ tone: function tone(s) {
1222
+ return s.isDark ? 90 : 20;
1223
+ }
1171
1224
  },
1172
- tone: function tone(s) {
1173
- return s.isDark ? 6 : 98;
1225
+ inverseOnSurface: {
1226
+ palette: function palette(s) {
1227
+ return s.getPalette('neutral');
1228
+ },
1229
+ tone: function tone(s) {
1230
+ return s.isDark ? 20 : 95;
1231
+ },
1232
+ background: function background(s) {
1233
+ return colorService.getColor('inverseSurface').getDynamicColor();
1234
+ },
1235
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
1236
+ },
1237
+ outline: {
1238
+ palette: function palette(s) {
1239
+ return s.getPalette('neutralVariant');
1240
+ },
1241
+ tone: function tone(s) {
1242
+ return s.isDark ? 60 : 50;
1243
+ },
1244
+ background: function background(s) {
1245
+ return highestSurface(s, colorService);
1246
+ },
1247
+ contrastCurve: new ContrastCurve(1.5, 3, 4.5, 7)
1248
+ },
1249
+ outlineVariant: {
1250
+ palette: function palette(s) {
1251
+ return s.getPalette('neutralVariant');
1252
+ },
1253
+ tone: function tone(s) {
1254
+ return s.isDark ? 30 : 80;
1255
+ },
1256
+ background: function background(s) {
1257
+ return highestSurface(s, colorService);
1258
+ },
1259
+ contrastCurve: new ContrastCurve(1, 1, 3, 7)
1260
+ },
1261
+ shadow: {
1262
+ palette: function palette(s) {
1263
+ return s.getPalette('neutral');
1264
+ },
1265
+ tone: function tone(s) {
1266
+ return 0;
1267
+ }
1174
1268
  },
1175
- isBackground: true
1176
- },
1177
- onBackground: {
1178
- palette: function palette(s) {
1179
- return s.getPalette('neutral');
1269
+ scrim: {
1270
+ palette: function palette(s) {
1271
+ return s.getPalette('neutral');
1272
+ },
1273
+ tone: function tone(s) {
1274
+ return 0;
1275
+ }
1180
1276
  },
1181
- tone: function tone(s) {
1182
- return s.isDark ? 90 : 10;
1277
+ surfaceTint: {
1278
+ palette: function palette(s) {
1279
+ return s.getPalette('neutral');
1280
+ },
1281
+ tone: function tone(s) {
1282
+ return s.isDark ? 80 : 40;
1283
+ },
1284
+ isBackground: true
1285
+ },
1286
+ secondaryContainer: {
1287
+ tone: function tone(s) {
1288
+ var initialTone = s.isDark ? 30 : 90;
1289
+ return findDesiredChromaByTone(s.getPalette('secondary').hue, s.getPalette('secondary').chroma, initialTone, !s.isDark);
1290
+ }
1183
1291
  },
1184
- background: function background(s) {
1185
- return colorManagerService.get('background').getDynamicColor();
1292
+ onSecondaryContainer: {
1293
+ tone: function tone(s) {
1294
+ return DynamicColor.foregroundTone(colorService.getColor('secondaryContainer').getDynamicColor().tone(s), 4.5);
1295
+ }
1186
1296
  },
1187
- contrastCurve: new ContrastCurve(3, 3, 4.5, 7)
1188
- },
1189
- surface: {
1190
- palette: function palette(s) {
1191
- return s.getPalette('neutral');
1297
+ tertiaryContainer: {
1298
+ palette: function palette(s) {
1299
+ return s.getPalette('tertiary');
1300
+ },
1301
+ tone: function tone(s) {
1302
+ var proposedHct = s.getPalette('tertiary').getHct(s.sourceColorHct.tone);
1303
+ return DislikeAnalyzer.fixIfDisliked(proposedHct).tone;
1304
+ }
1192
1305
  },
1193
- tone: function tone(s) {
1194
- return s.isDark ? 6 : 98;
1306
+ onTertiaryContainer: {
1307
+ palette: function palette(s) {
1308
+ return s.getPalette('tertiary');
1309
+ },
1310
+ tone: function tone(s) {
1311
+ return DynamicColor.foregroundTone(colorService.getColor('tertiaryContainer').getDynamicColor().tone(s), 4.5);
1312
+ }
1195
1313
  },
1196
- isBackground: true
1197
- },
1198
- surfaceDim: {
1199
- palette: function palette(s) {
1200
- return s.getPalette('neutral');
1314
+ error: {
1315
+ palette: function palette(s) {
1316
+ return s.getPalette('error');
1317
+ },
1318
+ tone: function tone(s) {
1319
+ return s.isDark ? 80 : 40;
1320
+ },
1321
+ isBackground: true,
1322
+ background: function background(s) {
1323
+ return highestSurface(s, colorService);
1324
+ },
1325
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
1326
+ toneDeltaPair: function toneDeltaPair(s) {
1327
+ return new ToneDeltaPair(colorService.getColor('errorContainer').getDynamicColor(), colorService.getColor('error').getDynamicColor(), 15, 'nearer', false);
1328
+ }
1201
1329
  },
1202
- tone: function tone(s) {
1203
- return s.isDark ? 6 : 87;
1330
+ onError: {
1331
+ palette: function palette(s) {
1332
+ return s.getPalette('error');
1333
+ },
1334
+ tone: function tone(s) {
1335
+ return s.isDark ? 20 : 100;
1336
+ },
1337
+ background: function background(s) {
1338
+ return colorService.getColor('error').getDynamicColor();
1339
+ },
1340
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
1341
+ },
1342
+ errorContainer: {
1343
+ palette: function palette(s) {
1344
+ return s.getPalette('error');
1345
+ },
1346
+ tone: function tone(s) {
1347
+ return s.isDark ? 30 : 90;
1348
+ },
1349
+ isBackground: true,
1350
+ background: function background(s) {
1351
+ return highestSurface(s, colorService);
1352
+ },
1353
+ contrastCurve: new ContrastCurve(1, 1, 3, 7),
1354
+ toneDeltaPair: function toneDeltaPair(s) {
1355
+ return new ToneDeltaPair(colorService.getColor('errorContainer').getDynamicColor(), colorService.getColor('error').getDynamicColor(), 15, 'nearer', false);
1356
+ }
1204
1357
  },
1205
- isBackground: true
1358
+ onErrorContainer: {
1359
+ palette: function palette(s) {
1360
+ return s.getPalette('error');
1361
+ },
1362
+ tone: function tone(s) {
1363
+ return s.isDark ? 90 : 10;
1364
+ },
1365
+ background: function background(s) {
1366
+ return colorService.getColor('errorContainer').getDynamicColor();
1367
+ },
1368
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
1369
+ },
1370
+ onTertiaryFixed: {
1371
+ palette: function palette(s) {
1372
+ return s.getPalette('tertiary');
1373
+ },
1374
+ tone: function tone(s) {
1375
+ return 10.0;
1376
+ },
1377
+ background: function background(s) {
1378
+ return colorService.getColor('tertiaryFixedDim').getDynamicColor();
1379
+ },
1380
+ secondBackground: function secondBackground(s) {
1381
+ return colorService.getColor('tertiaryFixed').getDynamicColor();
1382
+ },
1383
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
1384
+ },
1385
+ onTertiaryFixedVariant: {
1386
+ palette: function palette(s) {
1387
+ return s.getPalette('tertiary');
1388
+ },
1389
+ tone: function tone(s) {
1390
+ return 30.0;
1391
+ },
1392
+ background: function background(s) {
1393
+ return colorService.getColor('tertiaryFixedDim').getDynamicColor();
1394
+ },
1395
+ secondBackground: function secondBackground(s) {
1396
+ return colorService.getColor('tertiaryFixed').getDynamicColor();
1397
+ },
1398
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
1399
+ }
1400
+ }
1401
+ };
1402
+ };
1403
+
1404
+ var getRotatedHue = function getRotatedHue(sourceColor, hues, rotations) {
1405
+ var sourceHue = sourceColor.hue;
1406
+ if (hues.length !== rotations.length) {
1407
+ throw new Error("mismatch between hue length " + hues.length + " & rotations " + rotations.length);
1408
+ }
1409
+ if (rotations.length === 1) {
1410
+ return sanitizeDegreesDouble(sourceColor.hue + rotations[0]);
1411
+ }
1412
+ var size = hues.length;
1413
+ for (var i = 0; i <= size - 2; i++) {
1414
+ var thisHue = hues[i];
1415
+ var nextHue = hues[i + 1];
1416
+ if (thisHue < sourceHue && sourceHue < nextHue) {
1417
+ return sanitizeDegreesDouble(sourceHue + rotations[i]);
1418
+ }
1419
+ }
1420
+ // If this statement executes, something is wrong, there should have been a
1421
+ // rotation found using the arrays.
1422
+ return sourceHue;
1423
+ };
1424
+ var VariantEntity = function VariantEntity(palettes, customPalettes) {
1425
+ if (palettes === void 0) {
1426
+ palettes = {};
1427
+ }
1428
+ this.palettes = void 0;
1429
+ this.customPalettes = void 0;
1430
+ this.palettes = palettes;
1431
+ this.customPalettes = customPalettes;
1432
+ };
1433
+
1434
+ var _VariantModel;
1435
+ var VariantModel = function VariantModel() {};
1436
+ _VariantModel = VariantModel;
1437
+ VariantModel.tonalSpot = {
1438
+ palettes: {
1439
+ primary: function primary(sourceColorHct) {
1440
+ return TonalPalette.fromHueAndChroma(sourceColorHct.hue, 36.0);
1206
1441
  },
1207
- surfaceBright: {
1208
- palette: function palette(s) {
1209
- return s.getPalette('neutral');
1210
- },
1211
- tone: function tone(s) {
1212
- return s.isDark ? 24 : 98;
1213
- },
1214
- isBackground: true
1442
+ secondary: function secondary(sourceColorHct) {
1443
+ return TonalPalette.fromHueAndChroma(sourceColorHct.hue, 16.0);
1215
1444
  },
1216
- surfaceContainerLowest: {
1217
- palette: function palette(s) {
1218
- return s.getPalette('neutral');
1219
- },
1220
- tone: function tone(s) {
1221
- return s.isDark ? 4 : 100;
1222
- },
1223
- isBackground: true
1445
+ tertiary: function tertiary(sourceColorHct) {
1446
+ return TonalPalette.fromHueAndChroma(sanitizeDegreesDouble(sourceColorHct.hue + 60.0), 24.0);
1224
1447
  },
1225
- surfaceContainerLow: {
1226
- palette: function palette(s) {
1227
- return s.getPalette('neutral');
1228
- },
1229
- tone: function tone(s) {
1230
- return s.isDark ? 10 : 96;
1231
- },
1232
- isBackground: true
1448
+ neutral: function neutral(sourceColorHct) {
1449
+ return TonalPalette.fromHueAndChroma(sourceColorHct.hue, 6.0);
1233
1450
  },
1234
- surfaceContainer: {
1235
- palette: function palette(s) {
1236
- return s.getPalette('neutral');
1237
- },
1238
- tone: function tone(s) {
1239
- return s.isDark ? 12 : 94;
1240
- },
1241
- isBackground: true
1451
+ neutralVariant: function neutralVariant(sourceColorHct) {
1452
+ return TonalPalette.fromHueAndChroma(sourceColorHct.hue, 8.0);
1453
+ }
1454
+ },
1455
+ customPalettes: function customPalettes(colorHct) {
1456
+ return TonalPalette.fromHueAndChroma(colorHct.hue, 16);
1457
+ }
1458
+ };
1459
+ VariantModel.vibrant = {
1460
+ palettes: {
1461
+ primary: function primary(sourceColorHct) {
1462
+ return TonalPalette.fromHueAndChroma(sourceColorHct.hue, 200.0);
1242
1463
  },
1243
- surfaceContainerHigh: {
1244
- palette: function palette(s) {
1245
- return s.getPalette('neutral');
1246
- },
1247
- tone: function tone(s) {
1248
- return s.isDark ? 17 : 92;
1249
- },
1250
- isBackground: true
1464
+ secondary: function secondary(sourceColorHct) {
1465
+ return TonalPalette.fromHueAndChroma(getRotatedHue(sourceColorHct, _VariantModel.hues, _VariantModel.secondaryRotations), 24.0);
1251
1466
  },
1252
- surfaceContainerHighest: {
1253
- palette: function palette(s) {
1254
- return s.getPalette('neutral');
1255
- },
1256
- tone: function tone(s) {
1257
- return s.isDark ? 22 : 90;
1258
- },
1259
- isBackground: true
1467
+ tertiary: function tertiary(sourceColorHct) {
1468
+ return TonalPalette.fromHueAndChroma(getRotatedHue(sourceColorHct, _VariantModel.hues, _VariantModel.tertiaryRotations), 32.0);
1260
1469
  },
1261
- onSurface: {
1262
- palette: function palette(s) {
1263
- return s.getPalette('neutral');
1264
- },
1265
- tone: function tone(s) {
1266
- return s.isDark ? 90 : 10;
1267
- },
1268
- background: function background(s) {
1269
- return highestSurface(s, colorManagerService);
1270
- },
1271
- contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
1272
- },
1273
- surfaceVariant: {
1274
- palette: function palette(s) {
1275
- return s.getPalette('neutralVariant');
1276
- },
1277
- tone: function tone(s) {
1278
- return s.isDark ? 30 : 90;
1279
- },
1280
- isBackground: true
1281
- },
1282
- onSurfaceVariant: {
1283
- palette: function palette(s) {
1284
- return s.getPalette('neutralVariant');
1285
- },
1286
- tone: function tone(s) {
1287
- return s.isDark ? 80 : 30;
1288
- },
1289
- background: function background(s) {
1290
- return highestSurface(s, colorManagerService);
1291
- },
1292
- contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
1470
+ neutral: function neutral(sourceColorHct) {
1471
+ return TonalPalette.fromHueAndChroma(sourceColorHct.hue, 6.0);
1293
1472
  },
1294
- inverseSurface: {
1295
- palette: function palette(s) {
1296
- return s.getPalette('neutral');
1297
- },
1298
- tone: function tone(s) {
1299
- return s.isDark ? 90 : 20;
1473
+ neutralVariant: function neutralVariant(sourceColorHct) {
1474
+ return TonalPalette.fromHueAndChroma(sourceColorHct.hue, 8.0);
1475
+ }
1476
+ },
1477
+ customPalettes: function customPalettes(colorHct) {
1478
+ return TonalPalette.fromHueAndChroma(getRotatedHue(colorHct, _VariantModel.hues, _VariantModel.secondaryRotations), 24.0);
1479
+ }
1480
+ };
1481
+ VariantModel.hues = [0.0, 41.0, 61.0, 101.0, 131.0, 181.0, 251.0, 301.0, 360.0];
1482
+ VariantModel.secondaryRotations = [18.0, 15.0, 10.0, 12.0, 15.0, 18.0, 15.0, 12.0, 12.0];
1483
+ VariantModel.tertiaryRotations = [35.0, 30.0, 20.0, 25.0, 30.0, 35.0, 30.0, 25.0, 25.0];
1484
+
1485
+ function defineConfig(configObject) {
1486
+ if (!configObject || typeof configObject !== 'object') {
1487
+ throw new Error('The configuration is missing or not an object');
1488
+ }
1489
+ if (!('sourceColor' in configObject)) {
1490
+ throw new Error('Invalid configuration');
1491
+ }
1492
+ return configObject;
1493
+ }
1494
+ var ConfigService = /*#__PURE__*/function () {
1495
+ function ConfigService(_ref) {
1496
+ var appService = _ref.appService;
1497
+ this.configPath = './theme.config';
1498
+ this.appService = void 0;
1499
+ this.appService = appService;
1500
+ }
1501
+ var _proto = ConfigService.prototype;
1502
+ _proto.loadConfig = function loadConfig(config) {
1503
+ var _this$appService = this.appService,
1504
+ themeService = _this$appService.themeService,
1505
+ colorService = _this$appService.colorService,
1506
+ pluginService = _this$appService.pluginService;
1507
+ var _ref2 = config != null ? config : this.getConfig(),
1508
+ sourceColor = _ref2.sourceColor,
1509
+ _ref2$contrastLevel = _ref2.contrastLevel,
1510
+ contrastLevel = _ref2$contrastLevel === void 0 ? 0 : _ref2$contrastLevel,
1511
+ _ref2$isDark = _ref2.isDark,
1512
+ isDark = _ref2$isDark === void 0 ? false : _ref2$isDark,
1513
+ _ref2$variant = _ref2.variant,
1514
+ variant = _ref2$variant === void 0 ? VariantModel.tonalSpot : _ref2$variant,
1515
+ palettes = _ref2.palettes,
1516
+ colors = _ref2.colors,
1517
+ _ref2$useDefaultColor = _ref2.useDefaultColors,
1518
+ useDefaultColors = _ref2$useDefaultColor === void 0 ? true : _ref2$useDefaultColor,
1519
+ plugins = _ref2.plugins;
1520
+ themeService.create({
1521
+ contrastLevel: contrastLevel,
1522
+ isDark: isDark,
1523
+ sourceColorHex: sourceColor,
1524
+ variant: variant
1525
+ });
1526
+ if (palettes) {
1527
+ Object.entries(palettes).forEach(function (_ref3) {
1528
+ var key = _ref3[0],
1529
+ value = _ref3[1];
1530
+ return themeService.addCustomPalette(key, value);
1531
+ });
1532
+ }
1533
+ if (useDefaultColors) {
1534
+ colorService.addColors(defaultColors);
1535
+ }
1536
+ if (colors) {
1537
+ colorService.addColors(colors);
1538
+ }
1539
+ if (plugins) {
1540
+ plugins.forEach(function (plugin) {
1541
+ pluginService.addPlugin(plugin);
1542
+ });
1543
+ pluginService.loadPlugins(this.appService);
1544
+ }
1545
+ };
1546
+ _proto.getConfig = function getConfig() {
1547
+ if (typeof process !== 'undefined' && process.release && process.release.name === 'node') {
1548
+ var base = resolve(this.configPath);
1549
+ var extensions = ['.js', '.ts', '.jms', '.jcs'];
1550
+ var configImport = null;
1551
+ for (var _i = 0, _extensions = extensions; _i < _extensions.length; _i++) {
1552
+ var ext = _extensions[_i];
1553
+ var path = base + ext;
1554
+ if (existsSync(path)) {
1555
+ configImport = require(path);
1556
+ break;
1557
+ }
1300
1558
  }
1301
- },
1302
- inverseOnSurface: {
1303
- palette: function palette(s) {
1304
- return s.getPalette('neutral');
1305
- },
1306
- tone: function tone(s) {
1307
- return s.isDark ? 20 : 95;
1308
- },
1309
- background: function background(s) {
1310
- return colorManagerService.get('inverseSurface').getDynamicColor();
1311
- },
1312
- contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
1313
- },
1314
- outline: {
1315
- palette: function palette(s) {
1316
- return s.getPalette('neutralVariant');
1317
- },
1318
- tone: function tone(s) {
1319
- return s.isDark ? 60 : 50;
1320
- },
1321
- background: function background(s) {
1322
- return highestSurface(s, colorManagerService);
1323
- },
1324
- contrastCurve: new ContrastCurve(1.5, 3, 4.5, 7)
1325
- },
1326
- outlineVariant: {
1327
- palette: function palette(s) {
1328
- return s.getPalette('neutralVariant');
1329
- },
1330
- tone: function tone(s) {
1331
- return s.isDark ? 30 : 80;
1559
+ if (!configImport) {
1560
+ throw new Error('Configuration file not found');
1561
+ }
1562
+ var config;
1563
+ if ('default' in configImport) {
1564
+ config = configImport["default"];
1565
+ } else {
1566
+ config = configImport;
1567
+ }
1568
+ return config;
1569
+ } else {
1570
+ throw new Error('You must provide configuration object when using this library in a browser.');
1571
+ }
1572
+ };
1573
+ return ConfigService;
1574
+ }();
1575
+
1576
+ var ConfigModule = {
1577
+ configService: /*#__PURE__*/asClass(ConfigService).singleton()
1578
+ };
1579
+
1580
+ var PluginService = /*#__PURE__*/function () {
1581
+ function PluginService() {
1582
+ this.plugins = new Map();
1583
+ }
1584
+ var _proto = PluginService.prototype;
1585
+ _proto.addPlugin = function addPlugin(plugin) {
1586
+ this.plugins.set(plugin.name, plugin);
1587
+ };
1588
+ _proto.loadPlugins = function loadPlugins(appService) {
1589
+ var _this = this;
1590
+ var plugins = new Map(this.plugins);
1591
+ var size = 0;
1592
+ do {
1593
+ size = plugins.size;
1594
+ plugins.forEach(function (plugin, key) {
1595
+ var deps = plugin.dependencies.filter(function (dep) {
1596
+ return !_this.plugins.has(new dep().name);
1597
+ });
1598
+ if (deps.length === 0) {
1599
+ _this.plugins.set(plugin.name, plugin.init(appService));
1600
+ plugins["delete"](key);
1601
+ }
1602
+ });
1603
+ } while (plugins.size != 0 && plugins.size < size);
1604
+ if (plugins.size > 0) throw new Error("Some plugins couldn't be loaded due to missing dependencies: " + Array.from(plugins.keys()));
1605
+ };
1606
+ _proto.getPlugin = function getPlugin(plugin) {
1607
+ var pluginInstance = this.plugins.get(new plugin().name);
1608
+ if (!pluginInstance) throw new Error("Plugin " + plugin.name + " not found");
1609
+ return pluginInstance;
1610
+ };
1611
+ return PluginService;
1612
+ }();
1613
+
1614
+ var PluginModule = {
1615
+ pluginService: /*#__PURE__*/asClass(PluginService).singleton()
1616
+ };
1617
+
1618
+ function importContainer(container, services) {
1619
+ services.forEach(function (service) {
1620
+ Object.entries(service).forEach(function (_ref) {
1621
+ var name = _ref[0],
1622
+ serviceClass = _ref[1];
1623
+ container.register(name, serviceClass);
1624
+ });
1625
+ });
1626
+ return container;
1627
+ }
1628
+ var AppContainer = /*#__PURE__*/createContainer({
1629
+ injectionMode: InjectionMode.PROXY
1630
+ });
1631
+ importContainer(AppContainer, [ConfigModule, AppModule, PluginModule, ColorModule, ThemeModule]);
1632
+
1633
+ function bootstrap() {
1634
+ return AppContainer.resolve('appService');
1635
+ }
1636
+ function bootstrapFromConfig(args) {
1637
+ var configService = AppContainer.resolve('configService');
1638
+ if (args != null && args.path) configService.configPath = args.path;
1639
+ configService.loadConfig(args == null ? void 0 : args.config);
1640
+ return AppContainer.resolve('appService');
1641
+ }
1642
+
1643
+ var PluginAbstract = /*#__PURE__*/function () {
1644
+ function PluginAbstract(options) {
1645
+ this.options = void 0;
1646
+ this.pluginInstance = void 0;
1647
+ this.options = options;
1648
+ }
1649
+ var _proto = PluginAbstract.prototype;
1650
+ _proto.init = function init(appService) {
1651
+ this.pluginInstance = new this.pluginClass(appService, this.options);
1652
+ this.pluginInstance.onInit();
1653
+ return this;
1654
+ };
1655
+ _proto.getInstance = function getInstance() {
1656
+ if (!this.pluginInstance) {
1657
+ throw new Error("Plugin " + this.name + " is not initialized");
1658
+ }
1659
+ return this.pluginInstance;
1660
+ };
1661
+ return PluginAbstract;
1662
+ }();
1663
+ var PluginImplAbstract = function PluginImplAbstract(appService, options) {
1664
+ this.appService = void 0;
1665
+ this.options = void 0;
1666
+ this.appService = appService;
1667
+ this.options = options;
1668
+ this.onInit();
1669
+ };
1670
+
1671
+ var FontFamily;
1672
+ (function (FontFamily) {
1673
+ FontFamily["Expressive"] = "expressive";
1674
+ FontFamily["Neutral"] = "neutral";
1675
+ })(FontFamily || (FontFamily = {}));
1676
+ var FontPlugin = /*#__PURE__*/function (_PluginAbstract) {
1677
+ function FontPlugin() {
1678
+ var _this;
1679
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1680
+ args[_key] = arguments[_key];
1681
+ }
1682
+ _this = _PluginAbstract.call.apply(_PluginAbstract, [this].concat(args)) || this;
1683
+ _this.dependencies = [];
1684
+ _this.name = 'font';
1685
+ _this.pluginClass = FontPluginImpl;
1686
+ return _this;
1687
+ }
1688
+ _inheritsLoose(FontPlugin, _PluginAbstract);
1689
+ return FontPlugin;
1690
+ }(PluginAbstract);
1691
+ var FontPluginImpl = /*#__PURE__*/function (_PluginImplAbstract) {
1692
+ function FontPluginImpl() {
1693
+ var _this2;
1694
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
1695
+ args[_key2] = arguments[_key2];
1696
+ }
1697
+ _this2 = _PluginImplAbstract.call.apply(_PluginImplAbstract, [this].concat(args)) || this;
1698
+ _this2._fontFamily = void 0;
1699
+ _this2._fontStyles = void 0;
1700
+ return _this2;
1701
+ }
1702
+ _inheritsLoose(FontPluginImpl, _PluginImplAbstract);
1703
+ var _proto = FontPluginImpl.prototype;
1704
+ _proto.getFonts = function getFonts() {
1705
+ return {
1706
+ fontStyles: this.fontStyles,
1707
+ fontFamily: this.fontFamily
1708
+ };
1709
+ };
1710
+ _proto.onInit = function onInit() {
1711
+ var _this$options$fontFam,
1712
+ _this$options,
1713
+ _this$options$fontFam2,
1714
+ _this$options2,
1715
+ _this3 = this;
1716
+ this.fontFamily = {
1717
+ expressive: (_this$options$fontFam = (_this$options = this.options) == null || (_this$options = _this$options.fontFamily) == null ? void 0 : _this$options.expressive) != null ? _this$options$fontFam : ['Roboto', 'sans-serif'],
1718
+ neutral: (_this$options$fontFam2 = (_this$options2 = this.options) == null || (_this$options2 = _this$options2.fontFamily) == null ? void 0 : _this$options2.neutral) != null ? _this$options$fontFam2 : ['Roboto', 'sans-serif']
1719
+ };
1720
+ this.fontStyles = {
1721
+ display: {
1722
+ large: {
1723
+ fontWeight: 400,
1724
+ fontSize: 3.5625,
1725
+ lineHeight: 4,
1726
+ letterSpacing: -0.015625,
1727
+ fontFamily: FontFamily.Expressive
1728
+ },
1729
+ medium: {
1730
+ fontWeight: 400,
1731
+ fontSize: 2.8125,
1732
+ lineHeight: 3.25,
1733
+ fontFamily: FontFamily.Expressive
1734
+ },
1735
+ small: {
1736
+ fontWeight: 400,
1737
+ fontSize: 2.25,
1738
+ lineHeight: 2.75,
1739
+ fontFamily: FontFamily.Expressive
1740
+ }
1332
1741
  },
1333
- background: function background(s) {
1334
- return highestSurface(s, colorManagerService);
1742
+ headline: {
1743
+ large: {
1744
+ fontWeight: 400,
1745
+ fontSize: 2,
1746
+ lineHeight: 2.5,
1747
+ fontFamily: FontFamily.Expressive
1748
+ },
1749
+ medium: {
1750
+ fontWeight: 400,
1751
+ fontSize: 1.75,
1752
+ lineHeight: 2.25,
1753
+ fontFamily: FontFamily.Expressive
1754
+ },
1755
+ small: {
1756
+ fontWeight: 400,
1757
+ fontSize: 1.5,
1758
+ lineHeight: 2,
1759
+ fontFamily: FontFamily.Expressive
1760
+ }
1335
1761
  },
1336
- contrastCurve: new ContrastCurve(1, 1, 3, 7)
1337
- },
1338
- shadow: {
1339
- palette: function palette(s) {
1340
- return s.getPalette('neutral');
1762
+ title: {
1763
+ large: {
1764
+ fontWeight: 400,
1765
+ fontSize: 1.375,
1766
+ lineHeight: 1.75,
1767
+ fontFamily: FontFamily.Neutral
1768
+ },
1769
+ medium: {
1770
+ fontWeight: 500,
1771
+ fontSize: 1,
1772
+ lineHeight: 1.5,
1773
+ fontFamily: FontFamily.Neutral,
1774
+ letterSpacing: 0.009375
1775
+ },
1776
+ small: {
1777
+ fontWeight: 500,
1778
+ fontSize: 0.875,
1779
+ lineHeight: 1.25,
1780
+ fontFamily: FontFamily.Neutral,
1781
+ letterSpacing: 0.00625
1782
+ }
1341
1783
  },
1342
- tone: function tone(s) {
1343
- return 0;
1344
- }
1345
- },
1346
- scrim: {
1347
- palette: function palette(s) {
1348
- return s.getPalette('neutral');
1784
+ label: {
1785
+ large: {
1786
+ fontWeight: 500,
1787
+ fontSize: 0.875,
1788
+ lineHeight: 1.25,
1789
+ fontFamily: FontFamily.Neutral,
1790
+ letterSpacing: 0.00625
1791
+ },
1792
+ medium: {
1793
+ fontWeight: 500,
1794
+ fontSize: 0.75,
1795
+ lineHeight: 1,
1796
+ fontFamily: FontFamily.Neutral,
1797
+ letterSpacing: 0.03125
1798
+ },
1799
+ small: {
1800
+ fontWeight: 500,
1801
+ fontSize: 0.6875,
1802
+ lineHeight: 1,
1803
+ fontFamily: FontFamily.Neutral,
1804
+ letterSpacing: 0.03125
1805
+ }
1349
1806
  },
1350
- tone: function tone(s) {
1351
- return 0;
1807
+ body: {
1808
+ large: {
1809
+ fontWeight: 400,
1810
+ fontSize: 1,
1811
+ lineHeight: 1.5625,
1812
+ fontFamily: FontFamily.Neutral,
1813
+ letterSpacing: 0.03125
1814
+ },
1815
+ medium: {
1816
+ fontWeight: 400,
1817
+ fontSize: 0.875,
1818
+ lineHeight: 1.25,
1819
+ fontFamily: FontFamily.Neutral,
1820
+ letterSpacing: 0.015625
1821
+ },
1822
+ small: {
1823
+ fontWeight: 400,
1824
+ fontSize: 0.75,
1825
+ lineHeight: 1,
1826
+ fontFamily: FontFamily.Neutral,
1827
+ letterSpacing: 0.025
1828
+ }
1352
1829
  }
1830
+ };
1831
+ if (this.options && this.options.fontStyles) Object.entries(this.options.fontStyles).forEach(function (_ref) {
1832
+ var key = _ref[0],
1833
+ fontParam = _ref[1];
1834
+ var fontRole = key;
1835
+ Object.entries(fontParam).forEach(function (_ref2) {
1836
+ var size = _ref2[0],
1837
+ fontStyle = _ref2[1];
1838
+ var fontSize = size;
1839
+ if (fontStyle) {
1840
+ _this3.fontStyles[fontRole][fontSize] = _extends({}, _this3.fontStyles[fontRole][fontSize], fontStyle);
1841
+ }
1842
+ });
1843
+ });
1844
+ };
1845
+ return _createClass(FontPluginImpl, [{
1846
+ key: "fontFamily",
1847
+ get: function get() {
1848
+ if (!this._fontFamily) throw new Error('Font family not initialized');
1849
+ return this._fontFamily;
1353
1850
  },
1354
- surfaceTint: {
1355
- palette: function palette(s) {
1356
- return s.getPalette('neutral');
1357
- },
1358
- tone: function tone(s) {
1359
- return s.isDark ? 80 : 40;
1360
- },
1361
- isBackground: true
1362
- },
1363
- secondaryContainer: {
1364
- tone: function tone(s) {
1365
- var initialTone = s.isDark ? 30 : 90;
1366
- return findDesiredChromaByTone(s.getPalette('secondary').hue, s.getPalette('secondary').chroma, initialTone, !s.isDark);
1367
- }
1851
+ set: function set(value) {
1852
+ this._fontFamily = value;
1853
+ }
1854
+ }, {
1855
+ key: "fontStyles",
1856
+ get: function get() {
1857
+ if (!this._fontStyles) throw new Error('Font styles not initialized');
1858
+ return this._fontStyles;
1368
1859
  },
1369
- onSecondaryContainer: {
1370
- tone: function tone(s) {
1371
- return DynamicColor.foregroundTone(colorManagerService.get('secondaryContainer').getDynamicColor().tone(s), 4.5);
1860
+ set: function set(value) {
1861
+ this._fontStyles = value;
1862
+ }
1863
+ }]);
1864
+ }(PluginImplAbstract);
1865
+
1866
+ var state = function state(colorkeys) {
1867
+ return plugin(function (pluginArgs) {
1868
+ addAllNewComponents(pluginArgs, {
1869
+ statePrefix: 'state',
1870
+ disabledStyles: {
1871
+ textOpacity: 0.38,
1872
+ backgroundOpacity: 0.12
1873
+ },
1874
+ transition: {
1875
+ duration: 150
1372
1876
  }
1373
- },
1374
- tertiaryContainer: {
1375
- palette: function palette(s) {
1376
- return s.getPalette('tertiary');
1377
- },
1378
- tone: function tone(s) {
1379
- var proposedHct = s.getPalette('tertiary').getHct(s.sourceColorHct.tone);
1380
- return DislikeAnalyzer.fixIfDisliked(proposedHct).tone;
1877
+ }, colorkeys);
1878
+ }, {});
1879
+ };
1880
+ var addAllNewComponents = function addAllNewComponents(_ref, _ref2, colorKeys) {
1881
+ var addComponents = _ref.addComponents;
1882
+ var statePrefix = _ref2.statePrefix,
1883
+ disabledStyles = _ref2.disabledStyles,
1884
+ transition = _ref2.transition;
1885
+ var newComponents = {};
1886
+ for (var _i = 0, _arr = [false, true]; _i < _arr.length; _i++) {
1887
+ var isGroup = _arr[_i];
1888
+ var group = isGroup ? 'group-' : '';
1889
+ for (var _iterator = _createForOfIteratorHelperLoose(colorKeys), _step; !(_step = _iterator()).done;) {
1890
+ var _newComponents$classN;
1891
+ var colorName = _step.value;
1892
+ var className = "." + group + statePrefix + "-" + colorName;
1893
+ newComponents[className] = (_newComponents$classN = {}, _newComponents$classN["@apply " + group + "hover:bg-" + colorName + "/[0.08]"] = {}, _newComponents$classN["@apply " + group + "active:bg-" + colorName + "/[0.12]"] = {}, _newComponents$classN["@apply " + group + "focus-visible:bg-" + colorName + "/[0.12]"] = {}, _newComponents$classN);
1894
+ if (transition) {
1895
+ newComponents[className]["@apply transition-colors"] = {};
1896
+ newComponents[className]["@apply duration-" + transition.duration] = {};
1381
1897
  }
1382
- },
1383
- onTertiaryContainer: {
1384
- palette: function palette(s) {
1385
- return s.getPalette('tertiary');
1386
- },
1387
- tone: function tone(s) {
1388
- return DynamicColor.foregroundTone(colorManagerService.get('tertiaryContainer').getDynamicColor().tone(s), 4.5);
1898
+ if (disabledStyles) {
1899
+ newComponents[className]["@apply " + group + "disabled:text-on-surface/[" + disabledStyles.textOpacity + "]"] = {};
1900
+ newComponents[className]["@apply " + group + "disabled:bg-on-surface/[" + disabledStyles.backgroundOpacity + "]"] = {};
1389
1901
  }
1390
- },
1391
- error: {
1392
- palette: function palette(s) {
1393
- return s.getPalette('error');
1394
- },
1395
- tone: function tone(s) {
1396
- return s.isDark ? 80 : 40;
1397
- },
1398
- isBackground: true,
1399
- background: function background(s) {
1400
- return highestSurface(s, colorManagerService);
1401
- },
1402
- contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
1403
- toneDeltaPair: function toneDeltaPair(s) {
1404
- return new ToneDeltaPair(colorManagerService.get('errorContainer').getDynamicColor(), colorManagerService.get('error').getDynamicColor(), 15, 'nearer', false);
1405
- }
1406
- },
1407
- onError: {
1408
- palette: function palette(s) {
1409
- return s.getPalette('error');
1410
- },
1411
- tone: function tone(s) {
1412
- return s.isDark ? 20 : 100;
1413
- },
1414
- background: function background(s) {
1415
- return colorManagerService.get('error').getDynamicColor();
1416
- },
1417
- contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
1418
- },
1419
- errorContainer: {
1420
- palette: function palette(s) {
1421
- return s.getPalette('error');
1422
- },
1423
- tone: function tone(s) {
1424
- return s.isDark ? 30 : 90;
1425
- },
1426
- isBackground: true,
1427
- background: function background(s) {
1428
- return highestSurface(s, colorManagerService);
1429
- },
1430
- contrastCurve: new ContrastCurve(1, 1, 3, 7),
1431
- toneDeltaPair: function toneDeltaPair(s) {
1432
- return new ToneDeltaPair(colorManagerService.get('errorContainer').getDynamicColor(), colorManagerService.get('error').getDynamicColor(), 15, 'nearer', false);
1902
+ }
1903
+ }
1904
+ for (var _iterator2 = _createForOfIteratorHelperLoose(colorKeys), _step2; !(_step2 = _iterator2()).done;) {
1905
+ var _colorName = _step2.value;
1906
+ for (var _i2 = 0, _arr2 = ['hover', 'active', 'focus', 'disabled']; _i2 < _arr2.length; _i2++) {
1907
+ var stateName = _arr2[_i2];
1908
+ var _className = "." + stateName + "-" + statePrefix + "-" + _colorName;
1909
+ if (stateName === 'active' || stateName === 'focus') {
1910
+ var _newComponents$_class;
1911
+ newComponents[_className] = (_newComponents$_class = {}, _newComponents$_class["@apply bg-" + _colorName + "/[0.12]"] = {}, _newComponents$_class);
1912
+ } else if (stateName === 'hover') {
1913
+ var _newComponents$_class2;
1914
+ newComponents[_className] = (_newComponents$_class2 = {}, _newComponents$_class2["@apply bg-" + _colorName + "/[0.08]"] = {}, _newComponents$_class2);
1915
+ } else if (stateName === 'disabled') {
1916
+ var _newComponents$_class3, _newComponents$_class4;
1917
+ newComponents[_className] = (_newComponents$_class3 = {}, _newComponents$_class3["@apply text-on-surface/[" + disabledStyles.textOpacity + "]"] = {}, _newComponents$_class3);
1918
+ newComponents[_className] = (_newComponents$_class4 = {}, _newComponents$_class4["@apply bg-on-surface/[" + disabledStyles.backgroundOpacity + "]"] = {}, _newComponents$_class4);
1433
1919
  }
1434
- },
1435
- onErrorContainer: {
1436
- palette: function palette(s) {
1437
- return s.getPalette('error');
1438
- },
1439
- tone: function tone(s) {
1440
- return s.isDark ? 90 : 10;
1441
- },
1442
- background: function background(s) {
1443
- return colorManagerService.get('errorContainer').getDynamicColor();
1444
- },
1445
- contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
1446
- },
1447
- onTertiaryFixed: {
1448
- palette: function palette(s) {
1449
- return s.getPalette('tertiary');
1450
- },
1451
- tone: function tone(s) {
1452
- return 10.0;
1453
- },
1454
- background: function background(s) {
1455
- return colorManagerService.get('tertiaryFixedDim').getDynamicColor();
1456
- },
1457
- secondBackground: function secondBackground(s) {
1458
- return colorManagerService.get('tertiaryFixed').getDynamicColor();
1459
- },
1460
- contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
1461
- },
1462
- onTertiaryFixedVariant: {
1463
- palette: function palette(s) {
1464
- return s.getPalette('tertiary');
1465
- },
1466
- tone: function tone(s) {
1467
- return 30.0;
1468
- },
1469
- background: function background(s) {
1470
- return colorManagerService.get('tertiaryFixedDim').getDynamicColor();
1471
- },
1472
- secondBackground: function secondBackground(s) {
1473
- return colorManagerService.get('tertiaryFixed').getDynamicColor();
1474
- },
1475
- contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
1476
1920
  }
1477
- };
1921
+ }
1922
+ addComponents(newComponents);
1478
1923
  };
1479
1924
 
1480
- var ColorService = /*#__PURE__*/function () {
1481
- function ColorService(colorManagerService) {
1482
- this.colorManagerService = void 0;
1483
- this.colorManagerService = colorManagerService;
1484
- }
1485
- var _proto = ColorService.prototype;
1486
- _proto.getAllColors = function getAllColors() {
1487
- return this.colorManagerService.getAll();
1488
- }
1489
- // getColors() {
1490
- // const colors: Record<string, string> = {};
1491
- //
1492
- // for (const [key, value] of this.colorManagerService.getAll()) {
1493
- // colors[key] = hexFromArgb(value.getArgb(this.schemeService.get()));
1494
- // }
1495
- //
1496
- // return colors;
1497
- // }
1498
- ;
1499
- _proto.addBaseColors = function addBaseColors() {
1500
- var _this = this;
1501
- this.colorManagerService.addFromPalette('primary');
1502
- this.colorManagerService.addFromPalette('secondary');
1503
- this.colorManagerService.addFromPalette('tertiary');
1504
- var colors = defaultColors(this.colorManagerService);
1505
- Object.keys(colors).map(function (key) {
1506
- var color = colors[key];
1507
- if (!color) return;
1508
- return _this.colorManagerService.createOrUpdate(key, color);
1509
- });
1925
+ function createSubTheme(_ref) {
1926
+ var name = _ref.name,
1927
+ darkMode = _ref.darkMode,
1928
+ isDarkTheme = _ref.isDarkTheme,
1929
+ colors = _ref.colors;
1930
+ var theme = {
1931
+ name: isDarkTheme ? name + 'Dark' : name,
1932
+ selectors: isDarkTheme && darkMode === 'class' ? ['.dark-mode .theme-' + name, '.dark-mode.theme-' + name, '[data-theme="dark"] .theme-' + name, '[data-theme="dark"].theme-' + name] : ['.theme-' + name, ".theme-" + name + " .light-mode", ".theme-" + name + " [data-theme=\"light\"]", ".light-mode .theme-" + name, ".light-mode.theme-" + name, "[data-theme=\"light\"] .theme-" + name, "[data-theme=\"light\"].theme-" + name],
1933
+ mediaQuery: isDarkTheme && darkMode === 'media' ? '@media (prefers-color-scheme: dark)' : undefined,
1934
+ extend: {
1935
+ colors: colors
1936
+ }
1510
1937
  };
1511
- _proto.addColor = function addColor(key, color) {
1512
- return this.colorManagerService.createOrUpdate(key, color);
1938
+ return theme;
1939
+ }
1940
+ var themer = function themer(args) {
1941
+ var _args$appService = args.appService,
1942
+ themeService = _args$appService.themeService,
1943
+ colorService = _args$appService.colorService;
1944
+ var options = {
1945
+ defaultTheme: {
1946
+ extend: {
1947
+ colors: {}
1948
+ }
1949
+ },
1950
+ themes: [{
1951
+ name: 'darkTheme',
1952
+ extend: {
1953
+ colors: {}
1954
+ }
1955
+ }]
1513
1956
  };
1514
- _proto.addColors = function addColors(colors) {
1515
- var _this2 = this;
1516
- return Object.keys(colors).map(function (key) {
1517
- return _this2.addColor(key, colors[key]);
1957
+ Object.entries(args.colors).forEach(function (_ref2) {
1958
+ var key = _ref2[0],
1959
+ value = _ref2[1];
1960
+ options.defaultTheme.extend.colors[key] = value.light;
1961
+ options.themes[0].extend.colors[key] = value.dark;
1962
+ });
1963
+ options.themes[0].selectors = args.darkMode === 'class' ? ['.dark-mode', '[data-theme="dark"]'] : undefined;
1964
+ options.themes[0].mediaQuery = args.darkMode === 'media' ? '@media (prefers-color-scheme: dark)' : undefined;
1965
+ if (args.subThemes) {
1966
+ Object.entries(args.subThemes).forEach(function (_ref3) {
1967
+ var key = _ref3[0],
1968
+ value = _ref3[1];
1969
+ themeService.update({
1970
+ sourceColorHex: value
1971
+ });
1972
+ for (var _i = 0, _arr = [true, false]; _i < _arr.length; _i++) {
1973
+ var isDarkTheme = _arr[_i];
1974
+ var colors = {};
1975
+ themeService.update({
1976
+ isDark: isDarkTheme
1977
+ });
1978
+ for (var _iterator = _createForOfIteratorHelperLoose(colorService.getColors().entries()), _step; !(_step = _iterator()).done;) {
1979
+ var _step$value = _step.value,
1980
+ _key = _step$value[0],
1981
+ _value = _step$value[1];
1982
+ var newKey = _key.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
1983
+ colors[newKey] = _value.getHex();
1984
+ }
1985
+ options.themes.push(createSubTheme({
1986
+ name: key,
1987
+ isDarkTheme: isDarkTheme,
1988
+ darkMode: args.darkMode,
1989
+ colors: colors
1990
+ }));
1991
+ }
1518
1992
  });
1519
- };
1520
- _proto.getColor = function getColor(key) {
1521
- return this.colorManagerService.get(key);
1522
- };
1523
- _proto.removeColor = function removeColor(key) {
1524
- return this.colorManagerService.remove(key);
1525
- };
1526
- _proto.updateColor = function updateColor(key, newColor) {
1527
- return this.colorManagerService.createOrUpdate(key, newColor);
1528
- };
1529
- return ColorService;
1530
- }();
1531
- ColorService = /*#__PURE__*/__decorate([/*#__PURE__*/Injectable(), /*#__PURE__*/__metadata("design:paramtypes", [ColorManagerService])], ColorService);
1532
-
1533
- var VariantService = /*#__PURE__*/function () {
1534
- function VariantService(schemeService) {
1535
- this.schemeService = void 0;
1536
- this.schemeService = schemeService;
1537
1993
  }
1538
- var _proto = VariantService.prototype;
1539
- _proto.set = function set(variantEntity) {
1540
- if (!variantEntity.palettes.error) {
1541
- variantEntity.palettes.error = function () {
1542
- return TonalPalette.fromHueAndChroma(25.0, 84.0);
1994
+ return require('tailwindcss-themer')(options);
1995
+ };
1996
+
1997
+ var font = function font(fontStyles, responsiveBreakPoints) {
1998
+ var createUtilities = function createUtilities(_ref) {
1999
+ var theme = _ref.theme;
2000
+ var pixelUnit = 'rem';
2001
+ var newUtilities = {};
2002
+ var baseTextStyle = function baseTextStyle(sizeValue) {
2003
+ return {
2004
+ fontSize: sizeValue.fontSize + pixelUnit,
2005
+ fontWeight: sizeValue.fontWeight,
2006
+ lineHeight: sizeValue.lineHeight + pixelUnit,
2007
+ letterSpacing: sizeValue.letterSpacing ? sizeValue.letterSpacing + pixelUnit : null,
2008
+ fontFamily: theme('fontFamily.' + sizeValue.fontFamily)
1543
2009
  };
2010
+ };
2011
+ var responsiveTextStyle = function responsiveTextStyle(sizeValue, breakPointName, breakPointRatio) {
2012
+ var _ref2;
2013
+ return _ref2 = {}, _ref2["@media (min-width: " + theme('screens.' + breakPointName, {}) + ")"] = {
2014
+ fontSize: sizeValue.fontSize * breakPointRatio + pixelUnit,
2015
+ lineHeight: sizeValue.lineHeight * breakPointRatio + pixelUnit
2016
+ }, _ref2;
2017
+ };
2018
+ for (var _i = 0, _Object$entries = Object.entries(fontStyles); _i < _Object$entries.length; _i++) {
2019
+ var _Object$entries$_i = _Object$entries[_i],
2020
+ roleName = _Object$entries$_i[0],
2021
+ roleValue = _Object$entries$_i[1];
2022
+ var _loop = function _loop() {
2023
+ var _Object$entries2$_i = _Object$entries2[_i2],
2024
+ sizeName = _Object$entries2$_i[0],
2025
+ sizeValue = _Object$entries2$_i[1];
2026
+ newUtilities['.text-' + roleName + '-' + sizeName] = _extends({}, baseTextStyle(sizeValue), Object.entries(responsiveBreakPoints).reduce(function (acc, _ref3) {
2027
+ var breakPointName = _ref3[0],
2028
+ breakPointRatio = _ref3[1];
2029
+ acc = _extends({}, acc, responsiveTextStyle(sizeValue, breakPointName, breakPointRatio));
2030
+ return acc;
2031
+ }, {}));
2032
+ };
2033
+ for (var _i2 = 0, _Object$entries2 = Object.entries(roleValue); _i2 < _Object$entries2.length; _i2++) {
2034
+ _loop();
2035
+ }
1544
2036
  }
1545
- this.schemeService.createOrUpdate(variantEntity);
2037
+ return newUtilities;
1546
2038
  };
1547
- return VariantService;
1548
- }();
1549
- VariantService = /*#__PURE__*/__decorate([/*#__PURE__*/Injectable(), /*#__PURE__*/__metadata("design:paramtypes", [SchemeService])], VariantService);
2039
+ return plugin(function (_ref4) {
2040
+ var addUtilities = _ref4.addUtilities,
2041
+ theme = _ref4.theme;
2042
+ var newUtilities = createUtilities({
2043
+ theme: theme
2044
+ });
2045
+ addUtilities(newUtilities);
2046
+ });
2047
+ };
1550
2048
 
1551
- var ThemeService = /*#__PURE__*/function () {
1552
- function ThemeService(schemeService, variantService) {
1553
- this.schemeService = void 0;
1554
- this.variantService = void 0;
1555
- this.schemeService = schemeService;
1556
- this.variantService = variantService;
1557
- // this.addPalette({key: "primary", addDefaultColors: true})
1558
- // this.addPalette({key: "secondary", addDefaultColors: true})
1559
- // this.addPalette({key: "tertiary", addDefaultColors: true})
1560
- // this.addPalette({key: "error", palette: TonalPalette.fromHueAndChroma(25.0, 84.0)})
1561
- // this.addPalette({key: "neutral"})
1562
- // this.addPalette({key: "neutralVariant"})
2049
+ var TailwindPlugin = /*#__PURE__*/function (_PluginAbstract) {
2050
+ function TailwindPlugin() {
2051
+ var _this;
2052
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2053
+ args[_key] = arguments[_key];
2054
+ }
2055
+ _this = _PluginAbstract.call.apply(_PluginAbstract, [this].concat(args)) || this;
2056
+ _this.dependencies = [FontPlugin];
2057
+ _this.name = 'tailwind';
2058
+ _this.pluginClass = TailwindImplPlugin;
2059
+ return _this;
1563
2060
  }
1564
- // addPalette({key, palette, addDefaultColors}: {key: string; palette: TonalPalette; addDefaultColors: boolean}) {
1565
- // this.themeOptions.palettes.set(key, palette);
1566
- // if (addDefaultColors){
1567
- // this.colorService.addPalette(key)
1568
- // }
1569
- // }
1570
- // create(args: ThemeOptions): SchemeService {
1571
- // return new SchemeService(args, this.colorService)
1572
- // }
1573
- //
1574
- // update(options: Partial<ThemeOptions>): SchemeService {
1575
- // Object.assign(this.themeOptions, options);
1576
- // return this.theme();
1577
- // }
1578
- var _proto = ThemeService.prototype;
1579
- _proto.create = function create(options) {
1580
- this.schemeService.createOrUpdate(options);
1581
- };
1582
- _proto.addVariant = function addVariant(variant) {
1583
- this.variantService.set(variant);
2061
+ _inheritsLoose(TailwindPlugin, _PluginAbstract);
2062
+ return TailwindPlugin;
2063
+ }(PluginAbstract);
2064
+ var TailwindImplPlugin = /*#__PURE__*/function (_PluginImplAbstract) {
2065
+ function TailwindImplPlugin() {
2066
+ return _PluginImplAbstract.apply(this, arguments) || this;
2067
+ }
2068
+ _inheritsLoose(TailwindImplPlugin, _PluginImplAbstract);
2069
+ var _proto = TailwindImplPlugin.prototype;
2070
+ _proto.onInit = function onInit() {
2071
+ var _this$options, _this$options$darkMod, _this$options2, _this$options2$respon;
2072
+ (_this$options$darkMod = (_this$options = this.options).darkMode) != null ? _this$options$darkMod : _this$options.darkMode = 'class';
2073
+ (_this$options2$respon = (_this$options2 = this.options).responsiveBreakPoints) != null ? _this$options2$respon : _this$options2.responsiveBreakPoints = {
2074
+ lg: 1.125
2075
+ };
1584
2076
  };
1585
- _proto.update = function update(options) {
1586
- this.schemeService.createOrUpdate(options);
2077
+ _proto.getTheme = function getTheme() {
2078
+ var colors = {};
2079
+ for (var _i = 0, _arr = [false, true]; _i < _arr.length; _i++) {
2080
+ var isDark = _arr[_i];
2081
+ this.appService.themeService.update({
2082
+ isDark: isDark
2083
+ });
2084
+ for (var _iterator = _createForOfIteratorHelperLoose(this.appService.colorService.getColors().entries()), _step; !(_step = _iterator()).done;) {
2085
+ var _colors$newKey;
2086
+ var _step$value = _step.value,
2087
+ key = _step$value[0],
2088
+ value = _step$value[1];
2089
+ var newKey = key.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
2090
+ (_colors$newKey = colors[newKey]) != null ? _colors$newKey : colors[newKey] = {
2091
+ light: '',
2092
+ dark: ''
2093
+ };
2094
+ colors[newKey][isDark ? 'dark' : 'light'] = value.getHex();
2095
+ }
2096
+ }
2097
+ var _this$appService$plug = this.appService.pluginService.getPlugin(FontPlugin).getInstance().getFonts(),
2098
+ fontStyles = _this$appService$plug.fontStyles,
2099
+ fontFamily = _this$appService$plug.fontFamily;
2100
+ return {
2101
+ colors: {},
2102
+ fontFamily: fontFamily,
2103
+ plugins: [state(Object.keys(colors)), font(fontStyles, this.options.responsiveBreakPoints), themer({
2104
+ colors: colors,
2105
+ darkMode: this.options.darkMode,
2106
+ subThemes: this.options.subThemes,
2107
+ appService: this.appService
2108
+ })]
2109
+ };
1587
2110
  };
1588
- return ThemeService;
1589
- }();
1590
- ThemeService = /*#__PURE__*/__decorate([/*#__PURE__*/Injectable(), /*#__PURE__*/__metadata("design:paramtypes", [SchemeService, VariantService])], ThemeService);
2111
+ return TailwindImplPlugin;
2112
+ }(PluginImplAbstract);
1591
2113
 
1592
- var AppService = function AppService(colorService, themeService) {
1593
- this.colorService = void 0;
1594
- this.themeService = void 0;
1595
- this.colorService = colorService;
1596
- this.themeService = themeService;
2114
+ var createTheme = function createTheme() {
2115
+ var app = bootstrapFromConfig();
2116
+ var plugin = app.pluginService.getPlugin(TailwindPlugin).getInstance();
2117
+ return _extends({}, plugin.getTheme(), {
2118
+ appService: app
2119
+ });
1597
2120
  };
1598
- AppService = /*#__PURE__*/__decorate([/*#__PURE__*/Injectable(), /*#__PURE__*/__metadata("design:paramtypes", [ColorService, ThemeService])], AppService);
1599
-
1600
- var ThemeModule = function ThemeModule() {};
1601
- ThemeModule = /*#__PURE__*/__decorate([/*#__PURE__*/Module({
1602
- providers: [SchemeService, ThemeService, VariantService],
1603
- exports: [ThemeService, SchemeService]
1604
- })], ThemeModule);
1605
-
1606
- var ColorModule = function ColorModule() {};
1607
- ColorModule = /*#__PURE__*/__decorate([/*#__PURE__*/Module({
1608
- imports: [ThemeModule],
1609
- providers: [ColorService, ColorManagerService],
1610
- exports: [ColorService]
1611
- })], ColorModule);
1612
-
1613
- var AppModule = function AppModule() {};
1614
- AppModule = /*#__PURE__*/__decorate([/*#__PURE__*/Module({
1615
- imports: [ColorModule, ThemeModule],
1616
- providers: [AppService]
1617
- })], AppModule);
1618
-
1619
- function main() {
1620
- return _main.apply(this, arguments);
1621
- }
1622
- function _main() {
1623
- _main = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1624
- var app, appService, close;
1625
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1626
- while (1) switch (_context.prev = _context.next) {
1627
- case 0:
1628
- _context.next = 2;
1629
- return NestFactory.create(AppModule);
1630
- case 2:
1631
- app = _context.sent;
1632
- appService = app.get(AppService);
1633
- close = function close() {
1634
- return app.close();
1635
- };
1636
- return _context.abrupt("return", [appService, close]);
1637
- case 6:
1638
- case "end":
1639
- return _context.stop();
1640
- }
1641
- }, _callee);
1642
- }));
1643
- return _main.apply(this, arguments);
1644
- }
1645
2121
 
1646
- export { main };
2122
+ export { AppContainer, AppModule, AppService, ColorEntity, ColorManagerService, ColorModule, ColorService, ConfigModule, ConfigService, ContrastCurve, DynamicColor, FontFamily, FontPlugin, PluginAbstract, PluginImplAbstract, PluginModule, PluginService, SchemeEntity, SchemeService, TailwindPlugin, ThemeModule, ThemeService, ToneDeltaPair, VariantEntity, VariantModel, VariantService, bootstrap, bootstrapFromConfig, createTheme, defaultColors, defineConfig, getRotatedHue, highestSurface, importContainer, state, themer };
1647
2123
  //# sourceMappingURL=theme.esm.js.map