@021.is/brand-studio 0.3.0

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.
@@ -0,0 +1,3327 @@
1
+ // src/color/roles.ts
2
+ var ROLE = {
3
+ primary: "primary",
4
+ onPrimary: "onPrimary",
5
+ primaryContainer: "primaryContainer",
6
+ onPrimaryContainer: "onPrimaryContainer",
7
+ inversePrimary: "inversePrimary",
8
+ secondary: "secondary",
9
+ onSecondary: "onSecondary",
10
+ secondaryContainer: "secondaryContainer",
11
+ onSecondaryContainer: "onSecondaryContainer",
12
+ tertiary: "tertiary",
13
+ onTertiary: "onTertiary",
14
+ tertiaryContainer: "tertiaryContainer",
15
+ onTertiaryContainer: "onTertiaryContainer",
16
+ error: "error",
17
+ onError: "onError",
18
+ errorContainer: "errorContainer",
19
+ onErrorContainer: "onErrorContainer",
20
+ background: "background",
21
+ onBackground: "onBackground",
22
+ surface: "surface",
23
+ onSurface: "onSurface",
24
+ surfaceVariant: "surfaceVariant",
25
+ onSurfaceVariant: "onSurfaceVariant",
26
+ surfaceContainerLowest: "surfaceContainerLowest",
27
+ surfaceContainerLow: "surfaceContainerLow",
28
+ surfaceContainer: "surfaceContainer",
29
+ surfaceContainerHigh: "surfaceContainerHigh",
30
+ surfaceContainerHighest: "surfaceContainerHighest",
31
+ surfaceDim: "surfaceDim",
32
+ surfaceBright: "surfaceBright",
33
+ surfaceTint: "surfaceTint",
34
+ inverseSurface: "inverseSurface",
35
+ inverseOnSurface: "inverseOnSurface",
36
+ outline: "outline",
37
+ outlineVariant: "outlineVariant",
38
+ shadow: "shadow",
39
+ scrim: "scrim"
40
+ };
41
+ var ROLE_ORDER = Object.values(ROLE);
42
+ var ROLE_GROUPS = [
43
+ {
44
+ title: "Primary",
45
+ pairs: [
46
+ [ROLE.primary, ROLE.onPrimary],
47
+ [ROLE.primaryContainer, ROLE.onPrimaryContainer]
48
+ ]
49
+ },
50
+ {
51
+ title: "Secondary",
52
+ pairs: [
53
+ [ROLE.secondary, ROLE.onSecondary],
54
+ [ROLE.secondaryContainer, ROLE.onSecondaryContainer]
55
+ ]
56
+ },
57
+ {
58
+ title: "Tertiary",
59
+ pairs: [
60
+ [ROLE.tertiary, ROLE.onTertiary],
61
+ [ROLE.tertiaryContainer, ROLE.onTertiaryContainer]
62
+ ]
63
+ },
64
+ {
65
+ title: "Error",
66
+ pairs: [
67
+ [ROLE.error, ROLE.onError],
68
+ [ROLE.errorContainer, ROLE.onErrorContainer]
69
+ ]
70
+ },
71
+ {
72
+ title: "Surfaces",
73
+ pairs: [
74
+ [ROLE.background, ROLE.onBackground],
75
+ [ROLE.surface, ROLE.onSurface],
76
+ [ROLE.surfaceVariant, ROLE.onSurfaceVariant],
77
+ [ROLE.surfaceContainerLow, ROLE.onSurface],
78
+ [ROLE.surfaceContainer, ROLE.onSurface],
79
+ [ROLE.surfaceContainerHigh, ROLE.onSurface],
80
+ [ROLE.inverseSurface, ROLE.inverseOnSurface]
81
+ ]
82
+ }
83
+ ];
84
+
85
+ // node_modules/@material/material-color-utilities/utils/math_utils.js
86
+ function signum(num) {
87
+ if (num < 0) {
88
+ return -1;
89
+ } else if (num === 0) {
90
+ return 0;
91
+ } else {
92
+ return 1;
93
+ }
94
+ }
95
+ function lerp(start, stop, amount) {
96
+ return (1 - amount) * start + amount * stop;
97
+ }
98
+ function clampInt(min, max, input) {
99
+ if (input < min) {
100
+ return min;
101
+ } else if (input > max) {
102
+ return max;
103
+ }
104
+ return input;
105
+ }
106
+ function clampDouble(min, max, input) {
107
+ if (input < min) {
108
+ return min;
109
+ } else if (input > max) {
110
+ return max;
111
+ }
112
+ return input;
113
+ }
114
+ function sanitizeDegreesInt(degrees) {
115
+ degrees = degrees % 360;
116
+ if (degrees < 0) {
117
+ degrees = degrees + 360;
118
+ }
119
+ return degrees;
120
+ }
121
+ function sanitizeDegreesDouble(degrees) {
122
+ degrees = degrees % 360;
123
+ if (degrees < 0) {
124
+ degrees = degrees + 360;
125
+ }
126
+ return degrees;
127
+ }
128
+ function matrixMultiply(row, matrix) {
129
+ const a = row[0] * matrix[0][0] + row[1] * matrix[0][1] + row[2] * matrix[0][2];
130
+ const b = row[0] * matrix[1][0] + row[1] * matrix[1][1] + row[2] * matrix[1][2];
131
+ const c = row[0] * matrix[2][0] + row[1] * matrix[2][1] + row[2] * matrix[2][2];
132
+ return [a, b, c];
133
+ }
134
+
135
+ // node_modules/@material/material-color-utilities/utils/color_utils.js
136
+ var SRGB_TO_XYZ = [
137
+ [0.41233895, 0.35762064, 0.18051042],
138
+ [0.2126, 0.7152, 0.0722],
139
+ [0.01932141, 0.11916382, 0.95034478]
140
+ ];
141
+ var XYZ_TO_SRGB = [
142
+ [
143
+ 3.2413774792388685,
144
+ -1.5376652402851851,
145
+ -0.49885366846268053
146
+ ],
147
+ [
148
+ -0.9691452513005321,
149
+ 1.8758853451067872,
150
+ 0.04156585616912061
151
+ ],
152
+ [
153
+ 0.05562093689691305,
154
+ -0.20395524564742123,
155
+ 1.0571799111220335
156
+ ]
157
+ ];
158
+ var WHITE_POINT_D65 = [95.047, 100, 108.883];
159
+ function argbFromRgb(red, green, blue) {
160
+ return (255 << 24 | (red & 255) << 16 | (green & 255) << 8 | blue & 255) >>> 0;
161
+ }
162
+ function argbFromLinrgb(linrgb) {
163
+ const r = delinearized(linrgb[0]);
164
+ const g = delinearized(linrgb[1]);
165
+ const b = delinearized(linrgb[2]);
166
+ return argbFromRgb(r, g, b);
167
+ }
168
+ function redFromArgb(argb) {
169
+ return argb >> 16 & 255;
170
+ }
171
+ function greenFromArgb(argb) {
172
+ return argb >> 8 & 255;
173
+ }
174
+ function blueFromArgb(argb) {
175
+ return argb & 255;
176
+ }
177
+ function argbFromXyz(x, y, z) {
178
+ const matrix = XYZ_TO_SRGB;
179
+ const linearR = matrix[0][0] * x + matrix[0][1] * y + matrix[0][2] * z;
180
+ const linearG = matrix[1][0] * x + matrix[1][1] * y + matrix[1][2] * z;
181
+ const linearB = matrix[2][0] * x + matrix[2][1] * y + matrix[2][2] * z;
182
+ const r = delinearized(linearR);
183
+ const g = delinearized(linearG);
184
+ const b = delinearized(linearB);
185
+ return argbFromRgb(r, g, b);
186
+ }
187
+ function xyzFromArgb(argb) {
188
+ const r = linearized(redFromArgb(argb));
189
+ const g = linearized(greenFromArgb(argb));
190
+ const b = linearized(blueFromArgb(argb));
191
+ return matrixMultiply([r, g, b], SRGB_TO_XYZ);
192
+ }
193
+ function labFromArgb(argb) {
194
+ const linearR = linearized(redFromArgb(argb));
195
+ const linearG = linearized(greenFromArgb(argb));
196
+ const linearB = linearized(blueFromArgb(argb));
197
+ const matrix = SRGB_TO_XYZ;
198
+ const x = matrix[0][0] * linearR + matrix[0][1] * linearG + matrix[0][2] * linearB;
199
+ const y = matrix[1][0] * linearR + matrix[1][1] * linearG + matrix[1][2] * linearB;
200
+ const z = matrix[2][0] * linearR + matrix[2][1] * linearG + matrix[2][2] * linearB;
201
+ const whitePoint = WHITE_POINT_D65;
202
+ const xNormalized = x / whitePoint[0];
203
+ const yNormalized = y / whitePoint[1];
204
+ const zNormalized = z / whitePoint[2];
205
+ const fx = labF(xNormalized);
206
+ const fy = labF(yNormalized);
207
+ const fz = labF(zNormalized);
208
+ const l = 116 * fy - 16;
209
+ const a = 500 * (fx - fy);
210
+ const b = 200 * (fy - fz);
211
+ return [l, a, b];
212
+ }
213
+ function argbFromLstar(lstar) {
214
+ const y = yFromLstar(lstar);
215
+ const component = delinearized(y);
216
+ return argbFromRgb(component, component, component);
217
+ }
218
+ function lstarFromArgb(argb) {
219
+ const y = xyzFromArgb(argb)[1];
220
+ return 116 * labF(y / 100) - 16;
221
+ }
222
+ function yFromLstar(lstar) {
223
+ return 100 * labInvf((lstar + 16) / 116);
224
+ }
225
+ function lstarFromY(y) {
226
+ return labF(y / 100) * 116 - 16;
227
+ }
228
+ function linearized(rgbComponent) {
229
+ const normalized = rgbComponent / 255;
230
+ if (normalized <= 0.040449936) {
231
+ return normalized / 12.92 * 100;
232
+ } else {
233
+ return Math.pow((normalized + 0.055) / 1.055, 2.4) * 100;
234
+ }
235
+ }
236
+ function delinearized(rgbComponent) {
237
+ const normalized = rgbComponent / 100;
238
+ let delinearized2 = 0;
239
+ if (normalized <= 31308e-7) {
240
+ delinearized2 = normalized * 12.92;
241
+ } else {
242
+ delinearized2 = 1.055 * Math.pow(normalized, 1 / 2.4) - 0.055;
243
+ }
244
+ return clampInt(0, 255, Math.round(delinearized2 * 255));
245
+ }
246
+ function whitePointD65() {
247
+ return WHITE_POINT_D65;
248
+ }
249
+ function labF(t) {
250
+ const e = 216 / 24389;
251
+ const kappa = 24389 / 27;
252
+ if (t > e) {
253
+ return Math.pow(t, 1 / 3);
254
+ } else {
255
+ return (kappa * t + 16) / 116;
256
+ }
257
+ }
258
+ function labInvf(ft) {
259
+ const e = 216 / 24389;
260
+ const kappa = 24389 / 27;
261
+ const ft3 = ft * ft * ft;
262
+ if (ft3 > e) {
263
+ return ft3;
264
+ } else {
265
+ return (116 * ft - 16) / kappa;
266
+ }
267
+ }
268
+
269
+ // node_modules/@material/material-color-utilities/hct/viewing_conditions.js
270
+ var ViewingConditions = class _ViewingConditions {
271
+ /**
272
+ * Create ViewingConditions from a simple, physically relevant, set of
273
+ * parameters.
274
+ *
275
+ * @param whitePoint White point, measured in the XYZ color space.
276
+ * default = D65, or sunny day afternoon
277
+ * @param adaptingLuminance The luminance of the adapting field. Informally,
278
+ * how bright it is in the room where the color is viewed. Can be
279
+ * calculated from lux by multiplying lux by 0.0586. default = 11.72,
280
+ * or 200 lux.
281
+ * @param backgroundLstar The lightness of the area surrounding the color.
282
+ * measured by L* in L*a*b*. default = 50.0
283
+ * @param surround A general description of the lighting surrounding the
284
+ * color. 0 is pitch dark, like watching a movie in a theater. 1.0 is a
285
+ * dimly light room, like watching TV at home at night. 2.0 means there
286
+ * is no difference between the lighting on the color and around it.
287
+ * default = 2.0
288
+ * @param discountingIlluminant Whether the eye accounts for the tint of the
289
+ * ambient lighting, such as knowing an apple is still red in green light.
290
+ * default = false, the eye does not perform this process on
291
+ * self-luminous objects like displays.
292
+ */
293
+ static make(whitePoint = whitePointD65(), adaptingLuminance = 200 / Math.PI * yFromLstar(50) / 100, backgroundLstar = 50, surround = 2, discountingIlluminant = false) {
294
+ const xyz = whitePoint;
295
+ const rW = xyz[0] * 0.401288 + xyz[1] * 0.650173 + xyz[2] * -0.051461;
296
+ const gW = xyz[0] * -0.250268 + xyz[1] * 1.204414 + xyz[2] * 0.045854;
297
+ const bW = xyz[0] * -2079e-6 + xyz[1] * 0.048952 + xyz[2] * 0.953127;
298
+ const f = 0.8 + surround / 10;
299
+ const c = f >= 0.9 ? lerp(0.59, 0.69, (f - 0.9) * 10) : lerp(0.525, 0.59, (f - 0.8) * 10);
300
+ let d = discountingIlluminant ? 1 : f * (1 - 1 / 3.6 * Math.exp((-adaptingLuminance - 42) / 92));
301
+ d = d > 1 ? 1 : d < 0 ? 0 : d;
302
+ const nc = f;
303
+ const rgbD = [
304
+ d * (100 / rW) + 1 - d,
305
+ d * (100 / gW) + 1 - d,
306
+ d * (100 / bW) + 1 - d
307
+ ];
308
+ const k = 1 / (5 * adaptingLuminance + 1);
309
+ const k4 = k * k * k * k;
310
+ const k4F = 1 - k4;
311
+ const fl = k4 * adaptingLuminance + 0.1 * k4F * k4F * Math.cbrt(5 * adaptingLuminance);
312
+ const n = yFromLstar(backgroundLstar) / whitePoint[1];
313
+ const z = 1.48 + Math.sqrt(n);
314
+ const nbb = 0.725 / Math.pow(n, 0.2);
315
+ const ncb = nbb;
316
+ const rgbAFactors = [
317
+ Math.pow(fl * rgbD[0] * rW / 100, 0.42),
318
+ Math.pow(fl * rgbD[1] * gW / 100, 0.42),
319
+ Math.pow(fl * rgbD[2] * bW / 100, 0.42)
320
+ ];
321
+ const rgbA = [
322
+ 400 * rgbAFactors[0] / (rgbAFactors[0] + 27.13),
323
+ 400 * rgbAFactors[1] / (rgbAFactors[1] + 27.13),
324
+ 400 * rgbAFactors[2] / (rgbAFactors[2] + 27.13)
325
+ ];
326
+ const aw = (2 * rgbA[0] + rgbA[1] + 0.05 * rgbA[2]) * nbb;
327
+ return new _ViewingConditions(n, aw, nbb, ncb, c, nc, rgbD, fl, Math.pow(fl, 0.25), z);
328
+ }
329
+ /**
330
+ * Parameters are intermediate values of the CAM16 conversion process. Their
331
+ * names are shorthand for technical color science terminology, this class
332
+ * would not benefit from documenting them individually. A brief overview
333
+ * is available in the CAM16 specification, and a complete overview requires
334
+ * a color science textbook, such as Fairchild's Color Appearance Models.
335
+ */
336
+ constructor(n, aw, nbb, ncb, c, nc, rgbD, fl, fLRoot, z) {
337
+ this.n = n;
338
+ this.aw = aw;
339
+ this.nbb = nbb;
340
+ this.ncb = ncb;
341
+ this.c = c;
342
+ this.nc = nc;
343
+ this.rgbD = rgbD;
344
+ this.fl = fl;
345
+ this.fLRoot = fLRoot;
346
+ this.z = z;
347
+ }
348
+ };
349
+ ViewingConditions.DEFAULT = ViewingConditions.make();
350
+
351
+ // node_modules/@material/material-color-utilities/hct/cam16.js
352
+ var Cam16 = class _Cam16 {
353
+ /**
354
+ * All of the CAM16 dimensions can be calculated from 3 of the dimensions, in
355
+ * the following combinations:
356
+ * - {j or q} and {c, m, or s} and hue
357
+ * - jstar, astar, bstar
358
+ * Prefer using a static method that constructs from 3 of those dimensions.
359
+ * This constructor is intended for those methods to use to return all
360
+ * possible dimensions.
361
+ *
362
+ * @param hue
363
+ * @param chroma informally, colorfulness / color intensity. like saturation
364
+ * in HSL, except perceptually accurate.
365
+ * @param j lightness
366
+ * @param q brightness; ratio of lightness to white point's lightness
367
+ * @param m colorfulness
368
+ * @param s saturation; ratio of chroma to white point's chroma
369
+ * @param jstar CAM16-UCS J coordinate
370
+ * @param astar CAM16-UCS a coordinate
371
+ * @param bstar CAM16-UCS b coordinate
372
+ */
373
+ constructor(hue, chroma, j, q, m, s, jstar, astar, bstar) {
374
+ this.hue = hue;
375
+ this.chroma = chroma;
376
+ this.j = j;
377
+ this.q = q;
378
+ this.m = m;
379
+ this.s = s;
380
+ this.jstar = jstar;
381
+ this.astar = astar;
382
+ this.bstar = bstar;
383
+ }
384
+ /**
385
+ * CAM16 instances also have coordinates in the CAM16-UCS space, called J*,
386
+ * a*, b*, or jstar, astar, bstar in code. CAM16-UCS is included in the CAM16
387
+ * specification, and is used to measure distances between colors.
388
+ */
389
+ distance(other) {
390
+ const dJ = this.jstar - other.jstar;
391
+ const dA = this.astar - other.astar;
392
+ const dB = this.bstar - other.bstar;
393
+ const dEPrime = Math.sqrt(dJ * dJ + dA * dA + dB * dB);
394
+ const dE = 1.41 * Math.pow(dEPrime, 0.63);
395
+ return dE;
396
+ }
397
+ /**
398
+ * @param argb ARGB representation of a color.
399
+ * @return CAM16 color, assuming the color was viewed in default viewing
400
+ * conditions.
401
+ */
402
+ static fromInt(argb) {
403
+ return _Cam16.fromIntInViewingConditions(argb, ViewingConditions.DEFAULT);
404
+ }
405
+ /**
406
+ * @param argb ARGB representation of a color.
407
+ * @param viewingConditions Information about the environment where the color
408
+ * was observed.
409
+ * @return CAM16 color.
410
+ */
411
+ static fromIntInViewingConditions(argb, viewingConditions) {
412
+ const red = (argb & 16711680) >> 16;
413
+ const green = (argb & 65280) >> 8;
414
+ const blue = argb & 255;
415
+ const redL = linearized(red);
416
+ const greenL = linearized(green);
417
+ const blueL = linearized(blue);
418
+ const x = 0.41233895 * redL + 0.35762064 * greenL + 0.18051042 * blueL;
419
+ const y = 0.2126 * redL + 0.7152 * greenL + 0.0722 * blueL;
420
+ const z = 0.01932141 * redL + 0.11916382 * greenL + 0.95034478 * blueL;
421
+ const rC = 0.401288 * x + 0.650173 * y - 0.051461 * z;
422
+ const gC = -0.250268 * x + 1.204414 * y + 0.045854 * z;
423
+ const bC = -2079e-6 * x + 0.048952 * y + 0.953127 * z;
424
+ const rD = viewingConditions.rgbD[0] * rC;
425
+ const gD = viewingConditions.rgbD[1] * gC;
426
+ const bD = viewingConditions.rgbD[2] * bC;
427
+ const rAF = Math.pow(viewingConditions.fl * Math.abs(rD) / 100, 0.42);
428
+ const gAF = Math.pow(viewingConditions.fl * Math.abs(gD) / 100, 0.42);
429
+ const bAF = Math.pow(viewingConditions.fl * Math.abs(bD) / 100, 0.42);
430
+ const rA = signum(rD) * 400 * rAF / (rAF + 27.13);
431
+ const gA = signum(gD) * 400 * gAF / (gAF + 27.13);
432
+ const bA = signum(bD) * 400 * bAF / (bAF + 27.13);
433
+ const a = (11 * rA + -12 * gA + bA) / 11;
434
+ const b = (rA + gA - 2 * bA) / 9;
435
+ const u = (20 * rA + 20 * gA + 21 * bA) / 20;
436
+ const p2 = (40 * rA + 20 * gA + bA) / 20;
437
+ const atan2 = Math.atan2(b, a);
438
+ const atanDegrees = atan2 * 180 / Math.PI;
439
+ const hue = atanDegrees < 0 ? atanDegrees + 360 : atanDegrees >= 360 ? atanDegrees - 360 : atanDegrees;
440
+ const hueRadians = hue * Math.PI / 180;
441
+ const ac = p2 * viewingConditions.nbb;
442
+ const j = 100 * Math.pow(ac / viewingConditions.aw, viewingConditions.c * viewingConditions.z);
443
+ const q = 4 / viewingConditions.c * Math.sqrt(j / 100) * (viewingConditions.aw + 4) * viewingConditions.fLRoot;
444
+ const huePrime = hue < 20.14 ? hue + 360 : hue;
445
+ const eHue = 0.25 * (Math.cos(huePrime * Math.PI / 180 + 2) + 3.8);
446
+ const p1 = 5e4 / 13 * eHue * viewingConditions.nc * viewingConditions.ncb;
447
+ const t = p1 * Math.sqrt(a * a + b * b) / (u + 0.305);
448
+ const alpha = Math.pow(t, 0.9) * Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73);
449
+ const c = alpha * Math.sqrt(j / 100);
450
+ const m = c * viewingConditions.fLRoot;
451
+ const s = 50 * Math.sqrt(alpha * viewingConditions.c / (viewingConditions.aw + 4));
452
+ const jstar = (1 + 100 * 7e-3) * j / (1 + 7e-3 * j);
453
+ const mstar = 1 / 0.0228 * Math.log(1 + 0.0228 * m);
454
+ const astar = mstar * Math.cos(hueRadians);
455
+ const bstar = mstar * Math.sin(hueRadians);
456
+ return new _Cam16(hue, c, j, q, m, s, jstar, astar, bstar);
457
+ }
458
+ /**
459
+ * @param j CAM16 lightness
460
+ * @param c CAM16 chroma
461
+ * @param h CAM16 hue
462
+ */
463
+ static fromJch(j, c, h) {
464
+ return _Cam16.fromJchInViewingConditions(j, c, h, ViewingConditions.DEFAULT);
465
+ }
466
+ /**
467
+ * @param j CAM16 lightness
468
+ * @param c CAM16 chroma
469
+ * @param h CAM16 hue
470
+ * @param viewingConditions Information about the environment where the color
471
+ * was observed.
472
+ */
473
+ static fromJchInViewingConditions(j, c, h, viewingConditions) {
474
+ const q = 4 / viewingConditions.c * Math.sqrt(j / 100) * (viewingConditions.aw + 4) * viewingConditions.fLRoot;
475
+ const m = c * viewingConditions.fLRoot;
476
+ const alpha = c / Math.sqrt(j / 100);
477
+ const s = 50 * Math.sqrt(alpha * viewingConditions.c / (viewingConditions.aw + 4));
478
+ const hueRadians = h * Math.PI / 180;
479
+ const jstar = (1 + 100 * 7e-3) * j / (1 + 7e-3 * j);
480
+ const mstar = 1 / 0.0228 * Math.log(1 + 0.0228 * m);
481
+ const astar = mstar * Math.cos(hueRadians);
482
+ const bstar = mstar * Math.sin(hueRadians);
483
+ return new _Cam16(h, c, j, q, m, s, jstar, astar, bstar);
484
+ }
485
+ /**
486
+ * @param jstar CAM16-UCS lightness.
487
+ * @param astar CAM16-UCS a dimension. Like a* in L*a*b*, it is a Cartesian
488
+ * coordinate on the Y axis.
489
+ * @param bstar CAM16-UCS b dimension. Like a* in L*a*b*, it is a Cartesian
490
+ * coordinate on the X axis.
491
+ */
492
+ static fromUcs(jstar, astar, bstar) {
493
+ return _Cam16.fromUcsInViewingConditions(jstar, astar, bstar, ViewingConditions.DEFAULT);
494
+ }
495
+ /**
496
+ * @param jstar CAM16-UCS lightness.
497
+ * @param astar CAM16-UCS a dimension. Like a* in L*a*b*, it is a Cartesian
498
+ * coordinate on the Y axis.
499
+ * @param bstar CAM16-UCS b dimension. Like a* in L*a*b*, it is a Cartesian
500
+ * coordinate on the X axis.
501
+ * @param viewingConditions Information about the environment where the color
502
+ * was observed.
503
+ */
504
+ static fromUcsInViewingConditions(jstar, astar, bstar, viewingConditions) {
505
+ const a = astar;
506
+ const b = bstar;
507
+ const m = Math.sqrt(a * a + b * b);
508
+ const M = (Math.exp(m * 0.0228) - 1) / 0.0228;
509
+ const c = M / viewingConditions.fLRoot;
510
+ let h = Math.atan2(b, a) * (180 / Math.PI);
511
+ if (h < 0) {
512
+ h += 360;
513
+ }
514
+ const j = jstar / (1 - (jstar - 100) * 7e-3);
515
+ return _Cam16.fromJchInViewingConditions(j, c, h, viewingConditions);
516
+ }
517
+ /**
518
+ * @return ARGB representation of color, assuming the color was viewed in
519
+ * default viewing conditions, which are near-identical to the default
520
+ * viewing conditions for sRGB.
521
+ */
522
+ toInt() {
523
+ return this.viewed(ViewingConditions.DEFAULT);
524
+ }
525
+ /**
526
+ * @param viewingConditions Information about the environment where the color
527
+ * will be viewed.
528
+ * @return ARGB representation of color
529
+ */
530
+ viewed(viewingConditions) {
531
+ const alpha = this.chroma === 0 || this.j === 0 ? 0 : this.chroma / Math.sqrt(this.j / 100);
532
+ const t = Math.pow(alpha / Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73), 1 / 0.9);
533
+ const hRad = this.hue * Math.PI / 180;
534
+ const eHue = 0.25 * (Math.cos(hRad + 2) + 3.8);
535
+ const ac = viewingConditions.aw * Math.pow(this.j / 100, 1 / viewingConditions.c / viewingConditions.z);
536
+ const p1 = eHue * (5e4 / 13) * viewingConditions.nc * viewingConditions.ncb;
537
+ const p2 = ac / viewingConditions.nbb;
538
+ const hSin = Math.sin(hRad);
539
+ const hCos = Math.cos(hRad);
540
+ const gamma = 23 * (p2 + 0.305) * t / (23 * p1 + 11 * t * hCos + 108 * t * hSin);
541
+ const a = gamma * hCos;
542
+ const b = gamma * hSin;
543
+ const rA = (460 * p2 + 451 * a + 288 * b) / 1403;
544
+ const gA = (460 * p2 - 891 * a - 261 * b) / 1403;
545
+ const bA = (460 * p2 - 220 * a - 6300 * b) / 1403;
546
+ const rCBase = Math.max(0, 27.13 * Math.abs(rA) / (400 - Math.abs(rA)));
547
+ const rC = signum(rA) * (100 / viewingConditions.fl) * Math.pow(rCBase, 1 / 0.42);
548
+ const gCBase = Math.max(0, 27.13 * Math.abs(gA) / (400 - Math.abs(gA)));
549
+ const gC = signum(gA) * (100 / viewingConditions.fl) * Math.pow(gCBase, 1 / 0.42);
550
+ const bCBase = Math.max(0, 27.13 * Math.abs(bA) / (400 - Math.abs(bA)));
551
+ const bC = signum(bA) * (100 / viewingConditions.fl) * Math.pow(bCBase, 1 / 0.42);
552
+ const rF = rC / viewingConditions.rgbD[0];
553
+ const gF = gC / viewingConditions.rgbD[1];
554
+ const bF = bC / viewingConditions.rgbD[2];
555
+ const x = 1.86206786 * rF - 1.01125463 * gF + 0.14918677 * bF;
556
+ const y = 0.38752654 * rF + 0.62144744 * gF - 897398e-8 * bF;
557
+ const z = -0.0158415 * rF - 0.03412294 * gF + 1.04996444 * bF;
558
+ const argb = argbFromXyz(x, y, z);
559
+ return argb;
560
+ }
561
+ /// Given color expressed in XYZ and viewed in [viewingConditions], convert to
562
+ /// CAM16.
563
+ static fromXyzInViewingConditions(x, y, z, viewingConditions) {
564
+ const rC = 0.401288 * x + 0.650173 * y - 0.051461 * z;
565
+ const gC = -0.250268 * x + 1.204414 * y + 0.045854 * z;
566
+ const bC = -2079e-6 * x + 0.048952 * y + 0.953127 * z;
567
+ const rD = viewingConditions.rgbD[0] * rC;
568
+ const gD = viewingConditions.rgbD[1] * gC;
569
+ const bD = viewingConditions.rgbD[2] * bC;
570
+ const rAF = Math.pow(viewingConditions.fl * Math.abs(rD) / 100, 0.42);
571
+ const gAF = Math.pow(viewingConditions.fl * Math.abs(gD) / 100, 0.42);
572
+ const bAF = Math.pow(viewingConditions.fl * Math.abs(bD) / 100, 0.42);
573
+ const rA = signum(rD) * 400 * rAF / (rAF + 27.13);
574
+ const gA = signum(gD) * 400 * gAF / (gAF + 27.13);
575
+ const bA = signum(bD) * 400 * bAF / (bAF + 27.13);
576
+ const a = (11 * rA + -12 * gA + bA) / 11;
577
+ const b = (rA + gA - 2 * bA) / 9;
578
+ const u = (20 * rA + 20 * gA + 21 * bA) / 20;
579
+ const p2 = (40 * rA + 20 * gA + bA) / 20;
580
+ const atan2 = Math.atan2(b, a);
581
+ const atanDegrees = atan2 * 180 / Math.PI;
582
+ const hue = atanDegrees < 0 ? atanDegrees + 360 : atanDegrees >= 360 ? atanDegrees - 360 : atanDegrees;
583
+ const hueRadians = hue * Math.PI / 180;
584
+ const ac = p2 * viewingConditions.nbb;
585
+ const J = 100 * Math.pow(ac / viewingConditions.aw, viewingConditions.c * viewingConditions.z);
586
+ const Q = 4 / viewingConditions.c * Math.sqrt(J / 100) * (viewingConditions.aw + 4) * viewingConditions.fLRoot;
587
+ const huePrime = hue < 20.14 ? hue + 360 : hue;
588
+ const eHue = 1 / 4 * (Math.cos(huePrime * Math.PI / 180 + 2) + 3.8);
589
+ const p1 = 5e4 / 13 * eHue * viewingConditions.nc * viewingConditions.ncb;
590
+ const t = p1 * Math.sqrt(a * a + b * b) / (u + 0.305);
591
+ const alpha = Math.pow(t, 0.9) * Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73);
592
+ const C = alpha * Math.sqrt(J / 100);
593
+ const M = C * viewingConditions.fLRoot;
594
+ const s = 50 * Math.sqrt(alpha * viewingConditions.c / (viewingConditions.aw + 4));
595
+ const jstar = (1 + 100 * 7e-3) * J / (1 + 7e-3 * J);
596
+ const mstar = Math.log(1 + 0.0228 * M) / 0.0228;
597
+ const astar = mstar * Math.cos(hueRadians);
598
+ const bstar = mstar * Math.sin(hueRadians);
599
+ return new _Cam16(hue, C, J, Q, M, s, jstar, astar, bstar);
600
+ }
601
+ /// XYZ representation of CAM16 seen in [viewingConditions].
602
+ xyzInViewingConditions(viewingConditions) {
603
+ const alpha = this.chroma === 0 || this.j === 0 ? 0 : this.chroma / Math.sqrt(this.j / 100);
604
+ const t = Math.pow(alpha / Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73), 1 / 0.9);
605
+ const hRad = this.hue * Math.PI / 180;
606
+ const eHue = 0.25 * (Math.cos(hRad + 2) + 3.8);
607
+ const ac = viewingConditions.aw * Math.pow(this.j / 100, 1 / viewingConditions.c / viewingConditions.z);
608
+ const p1 = eHue * (5e4 / 13) * viewingConditions.nc * viewingConditions.ncb;
609
+ const p2 = ac / viewingConditions.nbb;
610
+ const hSin = Math.sin(hRad);
611
+ const hCos = Math.cos(hRad);
612
+ const gamma = 23 * (p2 + 0.305) * t / (23 * p1 + 11 * t * hCos + 108 * t * hSin);
613
+ const a = gamma * hCos;
614
+ const b = gamma * hSin;
615
+ const rA = (460 * p2 + 451 * a + 288 * b) / 1403;
616
+ const gA = (460 * p2 - 891 * a - 261 * b) / 1403;
617
+ const bA = (460 * p2 - 220 * a - 6300 * b) / 1403;
618
+ const rCBase = Math.max(0, 27.13 * Math.abs(rA) / (400 - Math.abs(rA)));
619
+ const rC = signum(rA) * (100 / viewingConditions.fl) * Math.pow(rCBase, 1 / 0.42);
620
+ const gCBase = Math.max(0, 27.13 * Math.abs(gA) / (400 - Math.abs(gA)));
621
+ const gC = signum(gA) * (100 / viewingConditions.fl) * Math.pow(gCBase, 1 / 0.42);
622
+ const bCBase = Math.max(0, 27.13 * Math.abs(bA) / (400 - Math.abs(bA)));
623
+ const bC = signum(bA) * (100 / viewingConditions.fl) * Math.pow(bCBase, 1 / 0.42);
624
+ const rF = rC / viewingConditions.rgbD[0];
625
+ const gF = gC / viewingConditions.rgbD[1];
626
+ const bF = bC / viewingConditions.rgbD[2];
627
+ const x = 1.86206786 * rF - 1.01125463 * gF + 0.14918677 * bF;
628
+ const y = 0.38752654 * rF + 0.62144744 * gF - 897398e-8 * bF;
629
+ const z = -0.0158415 * rF - 0.03412294 * gF + 1.04996444 * bF;
630
+ return [x, y, z];
631
+ }
632
+ };
633
+
634
+ // node_modules/@material/material-color-utilities/hct/hct_solver.js
635
+ var HctSolver = class _HctSolver {
636
+ /**
637
+ * Sanitizes a small enough angle in radians.
638
+ *
639
+ * @param angle An angle in radians; must not deviate too much
640
+ * from 0.
641
+ * @return A coterminal angle between 0 and 2pi.
642
+ */
643
+ static sanitizeRadians(angle) {
644
+ return (angle + Math.PI * 8) % (Math.PI * 2);
645
+ }
646
+ /**
647
+ * Delinearizes an RGB component, returning a floating-point
648
+ * number.
649
+ *
650
+ * @param rgbComponent 0.0 <= rgb_component <= 100.0, represents
651
+ * linear R/G/B channel
652
+ * @return 0.0 <= output <= 255.0, color channel converted to
653
+ * regular RGB space
654
+ */
655
+ static trueDelinearized(rgbComponent) {
656
+ const normalized = rgbComponent / 100;
657
+ let delinearized2 = 0;
658
+ if (normalized <= 31308e-7) {
659
+ delinearized2 = normalized * 12.92;
660
+ } else {
661
+ delinearized2 = 1.055 * Math.pow(normalized, 1 / 2.4) - 0.055;
662
+ }
663
+ return delinearized2 * 255;
664
+ }
665
+ static chromaticAdaptation(component) {
666
+ const af = Math.pow(Math.abs(component), 0.42);
667
+ return signum(component) * 400 * af / (af + 27.13);
668
+ }
669
+ /**
670
+ * Returns the hue of a linear RGB color in CAM16.
671
+ *
672
+ * @param linrgb The linear RGB coordinates of a color.
673
+ * @return The hue of the color in CAM16, in radians.
674
+ */
675
+ static hueOf(linrgb) {
676
+ const scaledDiscount = matrixMultiply(linrgb, _HctSolver.SCALED_DISCOUNT_FROM_LINRGB);
677
+ const rA = _HctSolver.chromaticAdaptation(scaledDiscount[0]);
678
+ const gA = _HctSolver.chromaticAdaptation(scaledDiscount[1]);
679
+ const bA = _HctSolver.chromaticAdaptation(scaledDiscount[2]);
680
+ const a = (11 * rA + -12 * gA + bA) / 11;
681
+ const b = (rA + gA - 2 * bA) / 9;
682
+ return Math.atan2(b, a);
683
+ }
684
+ static areInCyclicOrder(a, b, c) {
685
+ const deltaAB = _HctSolver.sanitizeRadians(b - a);
686
+ const deltaAC = _HctSolver.sanitizeRadians(c - a);
687
+ return deltaAB < deltaAC;
688
+ }
689
+ /**
690
+ * Solves the lerp equation.
691
+ *
692
+ * @param source The starting number.
693
+ * @param mid The number in the middle.
694
+ * @param target The ending number.
695
+ * @return A number t such that lerp(source, target, t) = mid.
696
+ */
697
+ static intercept(source, mid, target) {
698
+ return (mid - source) / (target - source);
699
+ }
700
+ static lerpPoint(source, t, target) {
701
+ return [
702
+ source[0] + (target[0] - source[0]) * t,
703
+ source[1] + (target[1] - source[1]) * t,
704
+ source[2] + (target[2] - source[2]) * t
705
+ ];
706
+ }
707
+ /**
708
+ * Intersects a segment with a plane.
709
+ *
710
+ * @param source The coordinates of point A.
711
+ * @param coordinate The R-, G-, or B-coordinate of the plane.
712
+ * @param target The coordinates of point B.
713
+ * @param axis The axis the plane is perpendicular with. (0: R, 1:
714
+ * G, 2: B)
715
+ * @return The intersection point of the segment AB with the plane
716
+ * R=coordinate, G=coordinate, or B=coordinate
717
+ */
718
+ static setCoordinate(source, coordinate, target, axis) {
719
+ const t = _HctSolver.intercept(source[axis], coordinate, target[axis]);
720
+ return _HctSolver.lerpPoint(source, t, target);
721
+ }
722
+ static isBounded(x) {
723
+ return 0 <= x && x <= 100;
724
+ }
725
+ /**
726
+ * Returns the nth possible vertex of the polygonal intersection.
727
+ *
728
+ * @param y The Y value of the plane.
729
+ * @param n The zero-based index of the point. 0 <= n <= 11.
730
+ * @return The nth possible vertex of the polygonal intersection
731
+ * of the y plane and the RGB cube, in linear RGB coordinates, if
732
+ * it exists. If this possible vertex lies outside of the cube,
733
+ * [-1.0, -1.0, -1.0] is returned.
734
+ */
735
+ static nthVertex(y, n) {
736
+ const kR = _HctSolver.Y_FROM_LINRGB[0];
737
+ const kG = _HctSolver.Y_FROM_LINRGB[1];
738
+ const kB = _HctSolver.Y_FROM_LINRGB[2];
739
+ const coordA = n % 4 <= 1 ? 0 : 100;
740
+ const coordB = n % 2 === 0 ? 0 : 100;
741
+ if (n < 4) {
742
+ const g = coordA;
743
+ const b = coordB;
744
+ const r = (y - g * kG - b * kB) / kR;
745
+ if (_HctSolver.isBounded(r)) {
746
+ return [r, g, b];
747
+ } else {
748
+ return [-1, -1, -1];
749
+ }
750
+ } else if (n < 8) {
751
+ const b = coordA;
752
+ const r = coordB;
753
+ const g = (y - r * kR - b * kB) / kG;
754
+ if (_HctSolver.isBounded(g)) {
755
+ return [r, g, b];
756
+ } else {
757
+ return [-1, -1, -1];
758
+ }
759
+ } else {
760
+ const r = coordA;
761
+ const g = coordB;
762
+ const b = (y - r * kR - g * kG) / kB;
763
+ if (_HctSolver.isBounded(b)) {
764
+ return [r, g, b];
765
+ } else {
766
+ return [-1, -1, -1];
767
+ }
768
+ }
769
+ }
770
+ /**
771
+ * Finds the segment containing the desired color.
772
+ *
773
+ * @param y The Y value of the color.
774
+ * @param targetHue The hue of the color.
775
+ * @return A list of two sets of linear RGB coordinates, each
776
+ * corresponding to an endpoint of the segment containing the
777
+ * desired color.
778
+ */
779
+ static bisectToSegment(y, targetHue) {
780
+ let left = [-1, -1, -1];
781
+ let right = left;
782
+ let leftHue = 0;
783
+ let rightHue = 0;
784
+ let initialized = false;
785
+ let uncut = true;
786
+ for (let n = 0; n < 12; n++) {
787
+ const mid = _HctSolver.nthVertex(y, n);
788
+ if (mid[0] < 0) {
789
+ continue;
790
+ }
791
+ const midHue = _HctSolver.hueOf(mid);
792
+ if (!initialized) {
793
+ left = mid;
794
+ right = mid;
795
+ leftHue = midHue;
796
+ rightHue = midHue;
797
+ initialized = true;
798
+ continue;
799
+ }
800
+ if (uncut || _HctSolver.areInCyclicOrder(leftHue, midHue, rightHue)) {
801
+ uncut = false;
802
+ if (_HctSolver.areInCyclicOrder(leftHue, targetHue, midHue)) {
803
+ right = mid;
804
+ rightHue = midHue;
805
+ } else {
806
+ left = mid;
807
+ leftHue = midHue;
808
+ }
809
+ }
810
+ }
811
+ return [left, right];
812
+ }
813
+ static midpoint(a, b) {
814
+ return [
815
+ (a[0] + b[0]) / 2,
816
+ (a[1] + b[1]) / 2,
817
+ (a[2] + b[2]) / 2
818
+ ];
819
+ }
820
+ static criticalPlaneBelow(x) {
821
+ return Math.floor(x - 0.5);
822
+ }
823
+ static criticalPlaneAbove(x) {
824
+ return Math.ceil(x - 0.5);
825
+ }
826
+ /**
827
+ * Finds a color with the given Y and hue on the boundary of the
828
+ * cube.
829
+ *
830
+ * @param y The Y value of the color.
831
+ * @param targetHue The hue of the color.
832
+ * @return The desired color, in linear RGB coordinates.
833
+ */
834
+ static bisectToLimit(y, targetHue) {
835
+ const segment = _HctSolver.bisectToSegment(y, targetHue);
836
+ let left = segment[0];
837
+ let leftHue = _HctSolver.hueOf(left);
838
+ let right = segment[1];
839
+ for (let axis = 0; axis < 3; axis++) {
840
+ if (left[axis] !== right[axis]) {
841
+ let lPlane = -1;
842
+ let rPlane = 255;
843
+ if (left[axis] < right[axis]) {
844
+ lPlane = _HctSolver.criticalPlaneBelow(_HctSolver.trueDelinearized(left[axis]));
845
+ rPlane = _HctSolver.criticalPlaneAbove(_HctSolver.trueDelinearized(right[axis]));
846
+ } else {
847
+ lPlane = _HctSolver.criticalPlaneAbove(_HctSolver.trueDelinearized(left[axis]));
848
+ rPlane = _HctSolver.criticalPlaneBelow(_HctSolver.trueDelinearized(right[axis]));
849
+ }
850
+ for (let i = 0; i < 8; i++) {
851
+ if (Math.abs(rPlane - lPlane) <= 1) {
852
+ break;
853
+ } else {
854
+ const mPlane = Math.floor((lPlane + rPlane) / 2);
855
+ const midPlaneCoordinate = _HctSolver.CRITICAL_PLANES[mPlane];
856
+ const mid = _HctSolver.setCoordinate(left, midPlaneCoordinate, right, axis);
857
+ const midHue = _HctSolver.hueOf(mid);
858
+ if (_HctSolver.areInCyclicOrder(leftHue, targetHue, midHue)) {
859
+ right = mid;
860
+ rPlane = mPlane;
861
+ } else {
862
+ left = mid;
863
+ leftHue = midHue;
864
+ lPlane = mPlane;
865
+ }
866
+ }
867
+ }
868
+ }
869
+ }
870
+ return _HctSolver.midpoint(left, right);
871
+ }
872
+ static inverseChromaticAdaptation(adapted) {
873
+ const adaptedAbs = Math.abs(adapted);
874
+ const base = Math.max(0, 27.13 * adaptedAbs / (400 - adaptedAbs));
875
+ return signum(adapted) * Math.pow(base, 1 / 0.42);
876
+ }
877
+ /**
878
+ * Finds a color with the given hue, chroma, and Y.
879
+ *
880
+ * @param hueRadians The desired hue in radians.
881
+ * @param chroma The desired chroma.
882
+ * @param y The desired Y.
883
+ * @return The desired color as a hexadecimal integer, if found; 0
884
+ * otherwise.
885
+ */
886
+ static findResultByJ(hueRadians, chroma, y) {
887
+ let j = Math.sqrt(y) * 11;
888
+ const viewingConditions = ViewingConditions.DEFAULT;
889
+ const tInnerCoeff = 1 / Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73);
890
+ const eHue = 0.25 * (Math.cos(hueRadians + 2) + 3.8);
891
+ const p1 = eHue * (5e4 / 13) * viewingConditions.nc * viewingConditions.ncb;
892
+ const hSin = Math.sin(hueRadians);
893
+ const hCos = Math.cos(hueRadians);
894
+ for (let iterationRound = 0; iterationRound < 5; iterationRound++) {
895
+ const jNormalized = j / 100;
896
+ const alpha = chroma === 0 || j === 0 ? 0 : chroma / Math.sqrt(jNormalized);
897
+ const t = Math.pow(alpha * tInnerCoeff, 1 / 0.9);
898
+ const ac = viewingConditions.aw * Math.pow(jNormalized, 1 / viewingConditions.c / viewingConditions.z);
899
+ const p2 = ac / viewingConditions.nbb;
900
+ const gamma = 23 * (p2 + 0.305) * t / (23 * p1 + 11 * t * hCos + 108 * t * hSin);
901
+ const a = gamma * hCos;
902
+ const b = gamma * hSin;
903
+ const rA = (460 * p2 + 451 * a + 288 * b) / 1403;
904
+ const gA = (460 * p2 - 891 * a - 261 * b) / 1403;
905
+ const bA = (460 * p2 - 220 * a - 6300 * b) / 1403;
906
+ const rCScaled = _HctSolver.inverseChromaticAdaptation(rA);
907
+ const gCScaled = _HctSolver.inverseChromaticAdaptation(gA);
908
+ const bCScaled = _HctSolver.inverseChromaticAdaptation(bA);
909
+ const linrgb = matrixMultiply([rCScaled, gCScaled, bCScaled], _HctSolver.LINRGB_FROM_SCALED_DISCOUNT);
910
+ if (linrgb[0] < 0 || linrgb[1] < 0 || linrgb[2] < 0) {
911
+ return 0;
912
+ }
913
+ const kR = _HctSolver.Y_FROM_LINRGB[0];
914
+ const kG = _HctSolver.Y_FROM_LINRGB[1];
915
+ const kB = _HctSolver.Y_FROM_LINRGB[2];
916
+ const fnj = kR * linrgb[0] + kG * linrgb[1] + kB * linrgb[2];
917
+ if (fnj <= 0) {
918
+ return 0;
919
+ }
920
+ if (iterationRound === 4 || Math.abs(fnj - y) < 2e-3) {
921
+ if (linrgb[0] > 100.01 || linrgb[1] > 100.01 || linrgb[2] > 100.01) {
922
+ return 0;
923
+ }
924
+ return argbFromLinrgb(linrgb);
925
+ }
926
+ j = j - (fnj - y) * j / (2 * fnj);
927
+ }
928
+ return 0;
929
+ }
930
+ /**
931
+ * Finds an sRGB color with the given hue, chroma, and L*, if
932
+ * possible.
933
+ *
934
+ * @param hueDegrees The desired hue, in degrees.
935
+ * @param chroma The desired chroma.
936
+ * @param lstar The desired L*.
937
+ * @return A hexadecimal representing the sRGB color. The color
938
+ * has sufficiently close hue, chroma, and L* to the desired
939
+ * values, if possible; otherwise, the hue and L* will be
940
+ * sufficiently close, and chroma will be maximized.
941
+ */
942
+ static solveToInt(hueDegrees, chroma, lstar) {
943
+ if (chroma < 1e-4 || lstar < 1e-4 || lstar > 99.9999) {
944
+ return argbFromLstar(lstar);
945
+ }
946
+ hueDegrees = sanitizeDegreesDouble(hueDegrees);
947
+ const hueRadians = hueDegrees / 180 * Math.PI;
948
+ const y = yFromLstar(lstar);
949
+ const exactAnswer = _HctSolver.findResultByJ(hueRadians, chroma, y);
950
+ if (exactAnswer !== 0) {
951
+ return exactAnswer;
952
+ }
953
+ const linrgb = _HctSolver.bisectToLimit(y, hueRadians);
954
+ return argbFromLinrgb(linrgb);
955
+ }
956
+ /**
957
+ * Finds an sRGB color with the given hue, chroma, and L*, if
958
+ * possible.
959
+ *
960
+ * @param hueDegrees The desired hue, in degrees.
961
+ * @param chroma The desired chroma.
962
+ * @param lstar The desired L*.
963
+ * @return An CAM16 object representing the sRGB color. The color
964
+ * has sufficiently close hue, chroma, and L* to the desired
965
+ * values, if possible; otherwise, the hue and L* will be
966
+ * sufficiently close, and chroma will be maximized.
967
+ */
968
+ static solveToCam(hueDegrees, chroma, lstar) {
969
+ return Cam16.fromInt(_HctSolver.solveToInt(hueDegrees, chroma, lstar));
970
+ }
971
+ };
972
+ HctSolver.SCALED_DISCOUNT_FROM_LINRGB = [
973
+ [
974
+ 0.001200833568784504,
975
+ 0.002389694492170889,
976
+ 2795742885861124e-19
977
+ ],
978
+ [
979
+ 5891086651375999e-19,
980
+ 0.0029785502573438758,
981
+ 3270666104008398e-19
982
+ ],
983
+ [
984
+ 10146692491640572e-20,
985
+ 5364214359186694e-19,
986
+ 0.0032979401770712076
987
+ ]
988
+ ];
989
+ HctSolver.LINRGB_FROM_SCALED_DISCOUNT = [
990
+ [
991
+ 1373.2198709594231,
992
+ -1100.4251190754821,
993
+ -7.278681089101213
994
+ ],
995
+ [
996
+ -271.815969077903,
997
+ 559.6580465940733,
998
+ -32.46047482791194
999
+ ],
1000
+ [
1001
+ 1.9622899599665666,
1002
+ -57.173814538844006,
1003
+ 308.7233197812385
1004
+ ]
1005
+ ];
1006
+ HctSolver.Y_FROM_LINRGB = [0.2126, 0.7152, 0.0722];
1007
+ HctSolver.CRITICAL_PLANES = [
1008
+ 0.015176349177441876,
1009
+ 0.045529047532325624,
1010
+ 0.07588174588720938,
1011
+ 0.10623444424209313,
1012
+ 0.13658714259697685,
1013
+ 0.16693984095186062,
1014
+ 0.19729253930674434,
1015
+ 0.2276452376616281,
1016
+ 0.2579979360165119,
1017
+ 0.28835063437139563,
1018
+ 0.3188300904430532,
1019
+ 0.350925934958123,
1020
+ 0.3848314933096426,
1021
+ 0.42057480301049466,
1022
+ 0.458183274052838,
1023
+ 0.4976837250274023,
1024
+ 0.5391024159806381,
1025
+ 0.5824650784040898,
1026
+ 0.6277969426914107,
1027
+ 0.6751227633498623,
1028
+ 0.7244668422128921,
1029
+ 0.775853049866786,
1030
+ 0.829304845476233,
1031
+ 0.8848452951698498,
1032
+ 0.942497089126609,
1033
+ 1.0022825574869039,
1034
+ 1.0642236851973577,
1035
+ 1.1283421258858297,
1036
+ 1.1946592148522128,
1037
+ 1.2631959812511864,
1038
+ 1.3339731595349034,
1039
+ 1.407011200216447,
1040
+ 1.4823302800086415,
1041
+ 1.5599503113873272,
1042
+ 1.6398909516233677,
1043
+ 1.7221716113234105,
1044
+ 1.8068114625156377,
1045
+ 1.8938294463134073,
1046
+ 1.9832442801866852,
1047
+ 2.075074464868551,
1048
+ 2.1693382909216234,
1049
+ 2.2660538449872063,
1050
+ 2.36523901573795,
1051
+ 2.4669114995532007,
1052
+ 2.5710888059345764,
1053
+ 2.6777882626779785,
1054
+ 2.7870270208169257,
1055
+ 2.898822059350997,
1056
+ 3.0131901897720907,
1057
+ 3.1301480604002863,
1058
+ 3.2497121605402226,
1059
+ 3.3718988244681087,
1060
+ 3.4967242352587946,
1061
+ 3.624204428461639,
1062
+ 3.754355295633311,
1063
+ 3.887192587735158,
1064
+ 4.022731918402185,
1065
+ 4.160988767090289,
1066
+ 4.301978482107941,
1067
+ 4.445716283538092,
1068
+ 4.592217266055746,
1069
+ 4.741496401646282,
1070
+ 4.893568542229298,
1071
+ 5.048448422192488,
1072
+ 5.20615066083972,
1073
+ 5.3666897647573375,
1074
+ 5.5300801301023865,
1075
+ 5.696336044816294,
1076
+ 5.865471690767354,
1077
+ 6.037501145825082,
1078
+ 6.212438385869475,
1079
+ 6.390297286737924,
1080
+ 6.571091626112461,
1081
+ 6.7548350853498045,
1082
+ 6.941541251256611,
1083
+ 7.131223617812143,
1084
+ 7.323895587840543,
1085
+ 7.5195704746346665,
1086
+ 7.7182615035334345,
1087
+ 7.919981813454504,
1088
+ 8.124744458384042,
1089
+ 8.332562408825165,
1090
+ 8.543448553206703,
1091
+ 8.757415699253682,
1092
+ 8.974476575321063,
1093
+ 9.194643831691977,
1094
+ 9.417930041841839,
1095
+ 9.644347703669503,
1096
+ 9.873909240696694,
1097
+ 10.106627003236781,
1098
+ 10.342513269534024,
1099
+ 10.58158024687427,
1100
+ 10.8238400726681,
1101
+ 11.069304815507364,
1102
+ 11.317986476196008,
1103
+ 11.569896988756009,
1104
+ 11.825048221409341,
1105
+ 12.083451977536606,
1106
+ 12.345119996613247,
1107
+ 12.610063955123938,
1108
+ 12.878295467455942,
1109
+ 13.149826086772048,
1110
+ 13.42466730586372,
1111
+ 13.702830557985108,
1112
+ 13.984327217668513,
1113
+ 14.269168601521828,
1114
+ 14.55736596900856,
1115
+ 14.848930523210871,
1116
+ 15.143873411576273,
1117
+ 15.44220572664832,
1118
+ 15.743938506781891,
1119
+ 16.04908273684337,
1120
+ 16.35764934889634,
1121
+ 16.66964922287304,
1122
+ 16.985093187232053,
1123
+ 17.30399201960269,
1124
+ 17.62635644741625,
1125
+ 17.95219714852476,
1126
+ 18.281524751807332,
1127
+ 18.614349837764564,
1128
+ 18.95068293910138,
1129
+ 19.290534541298456,
1130
+ 19.633915083172692,
1131
+ 19.98083495742689,
1132
+ 20.331304511189067,
1133
+ 20.685334046541502,
1134
+ 21.042933821039977,
1135
+ 21.404114048223256,
1136
+ 21.76888489811322,
1137
+ 22.137256497705877,
1138
+ 22.50923893145328,
1139
+ 22.884842241736916,
1140
+ 23.264076429332462,
1141
+ 23.6469514538663,
1142
+ 24.033477234264016,
1143
+ 24.42366364919083,
1144
+ 24.817520537484558,
1145
+ 25.21505769858089,
1146
+ 25.61628489293138,
1147
+ 26.021211842414342,
1148
+ 26.429848230738664,
1149
+ 26.842203703840827,
1150
+ 27.258287870275353,
1151
+ 27.678110301598522,
1152
+ 28.10168053274597,
1153
+ 28.529008062403893,
1154
+ 28.96010235337422,
1155
+ 29.39497283293396,
1156
+ 29.83362889318845,
1157
+ 30.276079891419332,
1158
+ 30.722335150426627,
1159
+ 31.172403958865512,
1160
+ 31.62629557157785,
1161
+ 32.08401920991837,
1162
+ 32.54558406207592,
1163
+ 33.010999283389665,
1164
+ 33.4802739966603,
1165
+ 33.953417292456834,
1166
+ 34.430438229418264,
1167
+ 34.911345834551085,
1168
+ 35.39614910352207,
1169
+ 35.88485700094671,
1170
+ 36.37747846067349,
1171
+ 36.87402238606382,
1172
+ 37.37449765026789,
1173
+ 37.87891309649659,
1174
+ 38.38727753828926,
1175
+ 38.89959975977785,
1176
+ 39.41588851594697,
1177
+ 39.93615253289054,
1178
+ 40.460400508064545,
1179
+ 40.98864111053629,
1180
+ 41.520882981230194,
1181
+ 42.05713473317016,
1182
+ 42.597404951718396,
1183
+ 43.141702194811224,
1184
+ 43.6900349931913,
1185
+ 44.24241185063697,
1186
+ 44.798841244188324,
1187
+ 45.35933162437017,
1188
+ 45.92389141541209,
1189
+ 46.49252901546552,
1190
+ 47.065252796817916,
1191
+ 47.64207110610409,
1192
+ 48.22299226451468,
1193
+ 48.808024568002054,
1194
+ 49.3971762874833,
1195
+ 49.9904556690408,
1196
+ 50.587870934119984,
1197
+ 51.189430279724725,
1198
+ 51.79514187861014,
1199
+ 52.40501387947288,
1200
+ 53.0190544071392,
1201
+ 53.637271562750364,
1202
+ 54.259673423945976,
1203
+ 54.88626804504493,
1204
+ 55.517063457223934,
1205
+ 56.15206766869424,
1206
+ 56.79128866487574,
1207
+ 57.43473440856916,
1208
+ 58.08241284012621,
1209
+ 58.734331877617365,
1210
+ 59.39049941699807,
1211
+ 60.05092333227251,
1212
+ 60.715611475655585,
1213
+ 61.38457167773311,
1214
+ 62.057811747619894,
1215
+ 62.7353394731159,
1216
+ 63.417162620860914,
1217
+ 64.10328893648692,
1218
+ 64.79372614476921,
1219
+ 65.48848194977529,
1220
+ 66.18756403501224,
1221
+ 66.89098006357258,
1222
+ 67.59873767827808,
1223
+ 68.31084450182222,
1224
+ 69.02730813691093,
1225
+ 69.74813616640164,
1226
+ 70.47333615344107,
1227
+ 71.20291564160104,
1228
+ 71.93688215501312,
1229
+ 72.67524319850172,
1230
+ 73.41800625771542,
1231
+ 74.16517879925733,
1232
+ 74.9167682708136,
1233
+ 75.67278210128072,
1234
+ 76.43322770089146,
1235
+ 77.1981124613393,
1236
+ 77.96744375590167,
1237
+ 78.74122893956174,
1238
+ 79.51947534912904,
1239
+ 80.30219030335869,
1240
+ 81.08938110306934,
1241
+ 81.88105503125999,
1242
+ 82.67721935322541,
1243
+ 83.4778813166706,
1244
+ 84.28304815182372,
1245
+ 85.09272707154808,
1246
+ 85.90692527145302,
1247
+ 86.72564993000343,
1248
+ 87.54890820862819,
1249
+ 88.3767072518277,
1250
+ 89.2090541872801,
1251
+ 90.04595612594655,
1252
+ 90.88742016217518,
1253
+ 91.73345337380438,
1254
+ 92.58406282226491,
1255
+ 93.43925555268066,
1256
+ 94.29903859396902,
1257
+ 95.16341895893969,
1258
+ 96.03240364439274,
1259
+ 96.9059996312159,
1260
+ 97.78421388448044,
1261
+ 98.6670533535366,
1262
+ 99.55452497210776
1263
+ ];
1264
+
1265
+ // node_modules/@material/material-color-utilities/hct/hct.js
1266
+ var Hct = class _Hct {
1267
+ static from(hue, chroma, tone) {
1268
+ return new _Hct(HctSolver.solveToInt(hue, chroma, tone));
1269
+ }
1270
+ /**
1271
+ * @param argb ARGB representation of a color.
1272
+ * @return HCT representation of a color in default viewing conditions
1273
+ */
1274
+ static fromInt(argb) {
1275
+ return new _Hct(argb);
1276
+ }
1277
+ toInt() {
1278
+ return this.argb;
1279
+ }
1280
+ /**
1281
+ * A number, in degrees, representing ex. red, orange, yellow, etc.
1282
+ * Ranges from 0 <= hue < 360.
1283
+ */
1284
+ get hue() {
1285
+ return this.internalHue;
1286
+ }
1287
+ /**
1288
+ * @param newHue 0 <= newHue < 360; invalid values are corrected.
1289
+ * Chroma may decrease because chroma has a different maximum for any given
1290
+ * hue and tone.
1291
+ */
1292
+ set hue(newHue) {
1293
+ this.setInternalState(HctSolver.solveToInt(newHue, this.internalChroma, this.internalTone));
1294
+ }
1295
+ get chroma() {
1296
+ return this.internalChroma;
1297
+ }
1298
+ /**
1299
+ * @param newChroma 0 <= newChroma < ?
1300
+ * Chroma may decrease because chroma has a different maximum for any given
1301
+ * hue and tone.
1302
+ */
1303
+ set chroma(newChroma) {
1304
+ this.setInternalState(HctSolver.solveToInt(this.internalHue, newChroma, this.internalTone));
1305
+ }
1306
+ /** Lightness. Ranges from 0 to 100. */
1307
+ get tone() {
1308
+ return this.internalTone;
1309
+ }
1310
+ /**
1311
+ * @param newTone 0 <= newTone <= 100; invalid valids are corrected.
1312
+ * Chroma may decrease because chroma has a different maximum for any given
1313
+ * hue and tone.
1314
+ */
1315
+ set tone(newTone) {
1316
+ this.setInternalState(HctSolver.solveToInt(this.internalHue, this.internalChroma, newTone));
1317
+ }
1318
+ constructor(argb) {
1319
+ this.argb = argb;
1320
+ const cam = Cam16.fromInt(argb);
1321
+ this.internalHue = cam.hue;
1322
+ this.internalChroma = cam.chroma;
1323
+ this.internalTone = lstarFromArgb(argb);
1324
+ this.argb = argb;
1325
+ }
1326
+ setInternalState(argb) {
1327
+ const cam = Cam16.fromInt(argb);
1328
+ this.internalHue = cam.hue;
1329
+ this.internalChroma = cam.chroma;
1330
+ this.internalTone = lstarFromArgb(argb);
1331
+ this.argb = argb;
1332
+ }
1333
+ /**
1334
+ * Translates a color into different [ViewingConditions].
1335
+ *
1336
+ * Colors change appearance. They look different with lights on versus off,
1337
+ * the same color, as in hex code, on white looks different when on black.
1338
+ * This is called color relativity, most famously explicated by Josef Albers
1339
+ * in Interaction of Color.
1340
+ *
1341
+ * In color science, color appearance models can account for this and
1342
+ * calculate the appearance of a color in different settings. HCT is based on
1343
+ * CAM16, a color appearance model, and uses it to make these calculations.
1344
+ *
1345
+ * See [ViewingConditions.make] for parameters affecting color appearance.
1346
+ */
1347
+ inViewingConditions(vc) {
1348
+ const cam = Cam16.fromInt(this.toInt());
1349
+ const viewedInVc = cam.xyzInViewingConditions(vc);
1350
+ const recastInVc = Cam16.fromXyzInViewingConditions(viewedInVc[0], viewedInVc[1], viewedInVc[2], ViewingConditions.make());
1351
+ const recastHct = _Hct.from(recastInVc.hue, recastInVc.chroma, lstarFromY(viewedInVc[1]));
1352
+ return recastHct;
1353
+ }
1354
+ };
1355
+
1356
+ // node_modules/@material/material-color-utilities/contrast/contrast.js
1357
+ var Contrast = class _Contrast {
1358
+ /**
1359
+ * Returns a contrast ratio, which ranges from 1 to 21.
1360
+ *
1361
+ * @param toneA Tone between 0 and 100. Values outside will be clamped.
1362
+ * @param toneB Tone between 0 and 100. Values outside will be clamped.
1363
+ */
1364
+ static ratioOfTones(toneA, toneB) {
1365
+ toneA = clampDouble(0, 100, toneA);
1366
+ toneB = clampDouble(0, 100, toneB);
1367
+ return _Contrast.ratioOfYs(yFromLstar(toneA), yFromLstar(toneB));
1368
+ }
1369
+ static ratioOfYs(y1, y2) {
1370
+ const lighter = y1 > y2 ? y1 : y2;
1371
+ const darker = lighter === y2 ? y1 : y2;
1372
+ return (lighter + 5) / (darker + 5);
1373
+ }
1374
+ /**
1375
+ * Returns a tone >= tone parameter that ensures ratio parameter.
1376
+ * Return value is between 0 and 100.
1377
+ * Returns -1 if ratio cannot be achieved with tone parameter.
1378
+ *
1379
+ * @param tone Tone return value must contrast with.
1380
+ * Range is 0 to 100. Invalid values will result in -1 being returned.
1381
+ * @param ratio Contrast ratio of return value and tone.
1382
+ * Range is 1 to 21, invalid values have undefined behavior.
1383
+ */
1384
+ static lighter(tone, ratio) {
1385
+ if (tone < 0 || tone > 100) {
1386
+ return -1;
1387
+ }
1388
+ const darkY = yFromLstar(tone);
1389
+ const lightY = ratio * (darkY + 5) - 5;
1390
+ const realContrast = _Contrast.ratioOfYs(lightY, darkY);
1391
+ const delta = Math.abs(realContrast - ratio);
1392
+ if (realContrast < ratio && delta > 0.04) {
1393
+ return -1;
1394
+ }
1395
+ const returnValue = lstarFromY(lightY) + 0.4;
1396
+ if (returnValue < 0 || returnValue > 100) {
1397
+ return -1;
1398
+ }
1399
+ return returnValue;
1400
+ }
1401
+ /**
1402
+ * Returns a tone <= tone parameter that ensures ratio parameter.
1403
+ * Return value is between 0 and 100.
1404
+ * Returns -1 if ratio cannot be achieved with tone parameter.
1405
+ *
1406
+ * @param tone Tone return value must contrast with.
1407
+ * Range is 0 to 100. Invalid values will result in -1 being returned.
1408
+ * @param ratio Contrast ratio of return value and tone.
1409
+ * Range is 1 to 21, invalid values have undefined behavior.
1410
+ */
1411
+ static darker(tone, ratio) {
1412
+ if (tone < 0 || tone > 100) {
1413
+ return -1;
1414
+ }
1415
+ const lightY = yFromLstar(tone);
1416
+ const darkY = (lightY + 5) / ratio - 5;
1417
+ const realContrast = _Contrast.ratioOfYs(lightY, darkY);
1418
+ const delta = Math.abs(realContrast - ratio);
1419
+ if (realContrast < ratio && delta > 0.04) {
1420
+ return -1;
1421
+ }
1422
+ const returnValue = lstarFromY(darkY) - 0.4;
1423
+ if (returnValue < 0 || returnValue > 100) {
1424
+ return -1;
1425
+ }
1426
+ return returnValue;
1427
+ }
1428
+ /**
1429
+ * Returns a tone >= tone parameter that ensures ratio parameter.
1430
+ * Return value is between 0 and 100.
1431
+ * Returns 100 if ratio cannot be achieved with tone parameter.
1432
+ *
1433
+ * This method is unsafe because the returned value is guaranteed to be in
1434
+ * bounds for tone, i.e. between 0 and 100. However, that value may not reach
1435
+ * the ratio with tone. For example, there is no color lighter than T100.
1436
+ *
1437
+ * @param tone Tone return value must contrast with.
1438
+ * Range is 0 to 100. Invalid values will result in 100 being returned.
1439
+ * @param ratio Desired contrast ratio of return value and tone parameter.
1440
+ * Range is 1 to 21, invalid values have undefined behavior.
1441
+ */
1442
+ static lighterUnsafe(tone, ratio) {
1443
+ const lighterSafe = _Contrast.lighter(tone, ratio);
1444
+ return lighterSafe < 0 ? 100 : lighterSafe;
1445
+ }
1446
+ /**
1447
+ * Returns a tone >= tone parameter that ensures ratio parameter.
1448
+ * Return value is between 0 and 100.
1449
+ * Returns 100 if ratio cannot be achieved with tone parameter.
1450
+ *
1451
+ * This method is unsafe because the returned value is guaranteed to be in
1452
+ * bounds for tone, i.e. between 0 and 100. However, that value may not reach
1453
+ * the [ratio with [tone]. For example, there is no color darker than T0.
1454
+ *
1455
+ * @param tone Tone return value must contrast with.
1456
+ * Range is 0 to 100. Invalid values will result in 0 being returned.
1457
+ * @param ratio Desired contrast ratio of return value and tone parameter.
1458
+ * Range is 1 to 21, invalid values have undefined behavior.
1459
+ */
1460
+ static darkerUnsafe(tone, ratio) {
1461
+ const darkerSafe = _Contrast.darker(tone, ratio);
1462
+ return darkerSafe < 0 ? 0 : darkerSafe;
1463
+ }
1464
+ };
1465
+
1466
+ // node_modules/@material/material-color-utilities/dislike/dislike_analyzer.js
1467
+ var DislikeAnalyzer = class _DislikeAnalyzer {
1468
+ /**
1469
+ * Returns true if a color is disliked.
1470
+ *
1471
+ * @param hct A color to be judged.
1472
+ * @return Whether the color is disliked.
1473
+ *
1474
+ * Disliked is defined as a dark yellow-green that is not neutral.
1475
+ */
1476
+ static isDisliked(hct) {
1477
+ const huePasses = Math.round(hct.hue) >= 90 && Math.round(hct.hue) <= 111;
1478
+ const chromaPasses = Math.round(hct.chroma) > 16;
1479
+ const tonePasses = Math.round(hct.tone) < 65;
1480
+ return huePasses && chromaPasses && tonePasses;
1481
+ }
1482
+ /**
1483
+ * If a color is disliked, lighten it to make it likable.
1484
+ *
1485
+ * @param hct A color to be judged.
1486
+ * @return A new color if the original color is disliked, or the original
1487
+ * color if it is acceptable.
1488
+ */
1489
+ static fixIfDisliked(hct) {
1490
+ if (_DislikeAnalyzer.isDisliked(hct)) {
1491
+ return Hct.from(hct.hue, hct.chroma, 70);
1492
+ }
1493
+ return hct;
1494
+ }
1495
+ };
1496
+
1497
+ // node_modules/@material/material-color-utilities/dynamiccolor/dynamic_color.js
1498
+ var DynamicColor = class _DynamicColor {
1499
+ /**
1500
+ * Create a DynamicColor defined by a TonalPalette and HCT tone.
1501
+ *
1502
+ * @param args Functions with DynamicScheme as input. Must provide a palette
1503
+ * and tone. May provide a background DynamicColor and ToneDeltaConstraint.
1504
+ */
1505
+ static fromPalette(args) {
1506
+ return new _DynamicColor(args.name ?? "", args.palette, args.tone, args.isBackground ?? false, args.background, args.secondBackground, args.contrastCurve, args.toneDeltaPair);
1507
+ }
1508
+ /**
1509
+ * The base constructor for DynamicColor.
1510
+ *
1511
+ * _Strongly_ prefer using one of the convenience constructors. This class is
1512
+ * arguably too flexible to ensure it can support any scenario. Functional
1513
+ * arguments allow overriding without risks that come with subclasses.
1514
+ *
1515
+ * For example, the default behavior of adjust tone at max contrast
1516
+ * to be at a 7.0 ratio with its background is principled and
1517
+ * matches accessibility guidance. That does not mean it's the desired
1518
+ * approach for _every_ design system, and every color pairing,
1519
+ * always, in every case.
1520
+ *
1521
+ * @param name The name of the dynamic color. Defaults to empty.
1522
+ * @param palette Function that provides a TonalPalette given
1523
+ * DynamicScheme. A TonalPalette is defined by a hue and chroma, so this
1524
+ * replaces the need to specify hue/chroma. By providing a tonal palette, when
1525
+ * contrast adjustments are made, intended chroma can be preserved.
1526
+ * @param tone Function that provides a tone, given a DynamicScheme.
1527
+ * @param isBackground Whether this dynamic color is a background, with
1528
+ * some other color as the foreground. Defaults to false.
1529
+ * @param background The background of the dynamic color (as a function of a
1530
+ * `DynamicScheme`), if it exists.
1531
+ * @param secondBackground A second background of the dynamic color (as a
1532
+ * function of a `DynamicScheme`), if it
1533
+ * exists.
1534
+ * @param contrastCurve A `ContrastCurve` object specifying how its contrast
1535
+ * against its background should behave in various contrast levels options.
1536
+ * @param toneDeltaPair A `ToneDeltaPair` object specifying a tone delta
1537
+ * constraint between two colors. One of them must be the color being
1538
+ * constructed.
1539
+ */
1540
+ constructor(name, palette, tone, isBackground, background, secondBackground, contrastCurve, toneDeltaPair) {
1541
+ this.name = name;
1542
+ this.palette = palette;
1543
+ this.tone = tone;
1544
+ this.isBackground = isBackground;
1545
+ this.background = background;
1546
+ this.secondBackground = secondBackground;
1547
+ this.contrastCurve = contrastCurve;
1548
+ this.toneDeltaPair = toneDeltaPair;
1549
+ this.hctCache = /* @__PURE__ */ new Map();
1550
+ if (!background && secondBackground) {
1551
+ throw new Error(`Color ${name} has secondBackgrounddefined, but background is not defined.`);
1552
+ }
1553
+ if (!background && contrastCurve) {
1554
+ throw new Error(`Color ${name} has contrastCurvedefined, but background is not defined.`);
1555
+ }
1556
+ if (background && !contrastCurve) {
1557
+ throw new Error(`Color ${name} has backgrounddefined, but contrastCurve is not defined.`);
1558
+ }
1559
+ }
1560
+ /**
1561
+ * Return a ARGB integer (i.e. a hex code).
1562
+ *
1563
+ * @param scheme Defines the conditions of the user interface, for example,
1564
+ * whether or not it is dark mode or light mode, and what the desired
1565
+ * contrast level is.
1566
+ */
1567
+ getArgb(scheme) {
1568
+ return this.getHct(scheme).toInt();
1569
+ }
1570
+ /**
1571
+ * Return a color, expressed in the HCT color space, that this
1572
+ * DynamicColor is under the conditions in scheme.
1573
+ *
1574
+ * @param scheme Defines the conditions of the user interface, for example,
1575
+ * whether or not it is dark mode or light mode, and what the desired
1576
+ * contrast level is.
1577
+ */
1578
+ getHct(scheme) {
1579
+ const cachedAnswer = this.hctCache.get(scheme);
1580
+ if (cachedAnswer != null) {
1581
+ return cachedAnswer;
1582
+ }
1583
+ const tone = this.getTone(scheme);
1584
+ const answer = this.palette(scheme).getHct(tone);
1585
+ if (this.hctCache.size > 4) {
1586
+ this.hctCache.clear();
1587
+ }
1588
+ this.hctCache.set(scheme, answer);
1589
+ return answer;
1590
+ }
1591
+ /**
1592
+ * Return a tone, T in the HCT color space, that this DynamicColor is under
1593
+ * the conditions in scheme.
1594
+ *
1595
+ * @param scheme Defines the conditions of the user interface, for example,
1596
+ * whether or not it is dark mode or light mode, and what the desired
1597
+ * contrast level is.
1598
+ */
1599
+ getTone(scheme) {
1600
+ const decreasingContrast = scheme.contrastLevel < 0;
1601
+ if (this.toneDeltaPair) {
1602
+ const toneDeltaPair = this.toneDeltaPair(scheme);
1603
+ const roleA = toneDeltaPair.roleA;
1604
+ const roleB = toneDeltaPair.roleB;
1605
+ const delta = toneDeltaPair.delta;
1606
+ const polarity = toneDeltaPair.polarity;
1607
+ const stayTogether = toneDeltaPair.stayTogether;
1608
+ const bg = this.background(scheme);
1609
+ const bgTone = bg.getTone(scheme);
1610
+ const aIsNearer = polarity === "nearer" || polarity === "lighter" && !scheme.isDark || polarity === "darker" && scheme.isDark;
1611
+ const nearer = aIsNearer ? roleA : roleB;
1612
+ const farther = aIsNearer ? roleB : roleA;
1613
+ const amNearer = this.name === nearer.name;
1614
+ const expansionDir = scheme.isDark ? 1 : -1;
1615
+ const nContrast = nearer.contrastCurve.get(scheme.contrastLevel);
1616
+ const fContrast = farther.contrastCurve.get(scheme.contrastLevel);
1617
+ const nInitialTone = nearer.tone(scheme);
1618
+ let nTone = Contrast.ratioOfTones(bgTone, nInitialTone) >= nContrast ? nInitialTone : _DynamicColor.foregroundTone(bgTone, nContrast);
1619
+ const fInitialTone = farther.tone(scheme);
1620
+ let fTone = Contrast.ratioOfTones(bgTone, fInitialTone) >= fContrast ? fInitialTone : _DynamicColor.foregroundTone(bgTone, fContrast);
1621
+ if (decreasingContrast) {
1622
+ nTone = _DynamicColor.foregroundTone(bgTone, nContrast);
1623
+ fTone = _DynamicColor.foregroundTone(bgTone, fContrast);
1624
+ }
1625
+ if ((fTone - nTone) * expansionDir >= delta) ; else {
1626
+ fTone = clampDouble(0, 100, nTone + delta * expansionDir);
1627
+ if ((fTone - nTone) * expansionDir >= delta) ; else {
1628
+ nTone = clampDouble(0, 100, fTone - delta * expansionDir);
1629
+ }
1630
+ }
1631
+ if (50 <= nTone && nTone < 60) {
1632
+ if (expansionDir > 0) {
1633
+ nTone = 60;
1634
+ fTone = Math.max(fTone, nTone + delta * expansionDir);
1635
+ } else {
1636
+ nTone = 49;
1637
+ fTone = Math.min(fTone, nTone + delta * expansionDir);
1638
+ }
1639
+ } else if (50 <= fTone && fTone < 60) {
1640
+ if (stayTogether) {
1641
+ if (expansionDir > 0) {
1642
+ nTone = 60;
1643
+ fTone = Math.max(fTone, nTone + delta * expansionDir);
1644
+ } else {
1645
+ nTone = 49;
1646
+ fTone = Math.min(fTone, nTone + delta * expansionDir);
1647
+ }
1648
+ } else {
1649
+ if (expansionDir > 0) {
1650
+ fTone = 60;
1651
+ } else {
1652
+ fTone = 49;
1653
+ }
1654
+ }
1655
+ }
1656
+ return amNearer ? nTone : fTone;
1657
+ } else {
1658
+ let answer = this.tone(scheme);
1659
+ if (this.background == null) {
1660
+ return answer;
1661
+ }
1662
+ const bgTone = this.background(scheme).getTone(scheme);
1663
+ const desiredRatio = this.contrastCurve.get(scheme.contrastLevel);
1664
+ if (Contrast.ratioOfTones(bgTone, answer) >= desiredRatio) ; else {
1665
+ answer = _DynamicColor.foregroundTone(bgTone, desiredRatio);
1666
+ }
1667
+ if (decreasingContrast) {
1668
+ answer = _DynamicColor.foregroundTone(bgTone, desiredRatio);
1669
+ }
1670
+ if (this.isBackground && 50 <= answer && answer < 60) {
1671
+ if (Contrast.ratioOfTones(49, bgTone) >= desiredRatio) {
1672
+ answer = 49;
1673
+ } else {
1674
+ answer = 60;
1675
+ }
1676
+ }
1677
+ if (this.secondBackground) {
1678
+ const [bg1, bg2] = [this.background, this.secondBackground];
1679
+ const [bgTone1, bgTone2] = [bg1(scheme).getTone(scheme), bg2(scheme).getTone(scheme)];
1680
+ const [upper, lower] = [Math.max(bgTone1, bgTone2), Math.min(bgTone1, bgTone2)];
1681
+ if (Contrast.ratioOfTones(upper, answer) >= desiredRatio && Contrast.ratioOfTones(lower, answer) >= desiredRatio) {
1682
+ return answer;
1683
+ }
1684
+ const lightOption = Contrast.lighter(upper, desiredRatio);
1685
+ const darkOption = Contrast.darker(lower, desiredRatio);
1686
+ const availables = [];
1687
+ if (lightOption !== -1)
1688
+ availables.push(lightOption);
1689
+ if (darkOption !== -1)
1690
+ availables.push(darkOption);
1691
+ const prefersLight = _DynamicColor.tonePrefersLightForeground(bgTone1) || _DynamicColor.tonePrefersLightForeground(bgTone2);
1692
+ if (prefersLight) {
1693
+ return lightOption < 0 ? 100 : lightOption;
1694
+ }
1695
+ if (availables.length === 1) {
1696
+ return availables[0];
1697
+ }
1698
+ return darkOption < 0 ? 0 : darkOption;
1699
+ }
1700
+ return answer;
1701
+ }
1702
+ }
1703
+ /**
1704
+ * Given a background tone, find a foreground tone, while ensuring they reach
1705
+ * a contrast ratio that is as close to [ratio] as possible.
1706
+ *
1707
+ * @param bgTone Tone in HCT. Range is 0 to 100, undefined behavior when it
1708
+ * falls outside that range.
1709
+ * @param ratio The contrast ratio desired between bgTone and the return
1710
+ * value.
1711
+ */
1712
+ static foregroundTone(bgTone, ratio) {
1713
+ const lighterTone = Contrast.lighterUnsafe(bgTone, ratio);
1714
+ const darkerTone = Contrast.darkerUnsafe(bgTone, ratio);
1715
+ const lighterRatio = Contrast.ratioOfTones(lighterTone, bgTone);
1716
+ const darkerRatio = Contrast.ratioOfTones(darkerTone, bgTone);
1717
+ const preferLighter = _DynamicColor.tonePrefersLightForeground(bgTone);
1718
+ if (preferLighter) {
1719
+ const negligibleDifference = Math.abs(lighterRatio - darkerRatio) < 0.1 && lighterRatio < ratio && darkerRatio < ratio;
1720
+ return lighterRatio >= ratio || lighterRatio >= darkerRatio || negligibleDifference ? lighterTone : darkerTone;
1721
+ } else {
1722
+ return darkerRatio >= ratio || darkerRatio >= lighterRatio ? darkerTone : lighterTone;
1723
+ }
1724
+ }
1725
+ /**
1726
+ * Returns whether [tone] prefers a light foreground.
1727
+ *
1728
+ * People prefer white foregrounds on ~T60-70. Observed over time, and also
1729
+ * by Andrew Somers during research for APCA.
1730
+ *
1731
+ * T60 used as to create the smallest discontinuity possible when skipping
1732
+ * down to T49 in order to ensure light foregrounds.
1733
+ * Since `tertiaryContainer` in dark monochrome scheme requires a tone of
1734
+ * 60, it should not be adjusted. Therefore, 60 is excluded here.
1735
+ */
1736
+ static tonePrefersLightForeground(tone) {
1737
+ return Math.round(tone) < 60;
1738
+ }
1739
+ /**
1740
+ * Returns whether [tone] can reach a contrast ratio of 4.5 with a lighter
1741
+ * color.
1742
+ */
1743
+ static toneAllowsLightForeground(tone) {
1744
+ return Math.round(tone) <= 49;
1745
+ }
1746
+ /**
1747
+ * Adjust a tone such that white has 4.5 contrast, if the tone is
1748
+ * reasonably close to supporting it.
1749
+ */
1750
+ static enableLightForeground(tone) {
1751
+ if (_DynamicColor.tonePrefersLightForeground(tone) && !_DynamicColor.toneAllowsLightForeground(tone)) {
1752
+ return 49;
1753
+ }
1754
+ return tone;
1755
+ }
1756
+ };
1757
+
1758
+ // node_modules/@material/material-color-utilities/palettes/tonal_palette.js
1759
+ var TonalPalette = class _TonalPalette {
1760
+ /**
1761
+ * @param argb ARGB representation of a color
1762
+ * @return Tones matching that color's hue and chroma.
1763
+ */
1764
+ static fromInt(argb) {
1765
+ const hct = Hct.fromInt(argb);
1766
+ return _TonalPalette.fromHct(hct);
1767
+ }
1768
+ /**
1769
+ * @param hct Hct
1770
+ * @return Tones matching that color's hue and chroma.
1771
+ */
1772
+ static fromHct(hct) {
1773
+ return new _TonalPalette(hct.hue, hct.chroma, hct);
1774
+ }
1775
+ /**
1776
+ * @param hue HCT hue
1777
+ * @param chroma HCT chroma
1778
+ * @return Tones matching hue and chroma.
1779
+ */
1780
+ static fromHueAndChroma(hue, chroma) {
1781
+ const keyColor = new KeyColor(hue, chroma).create();
1782
+ return new _TonalPalette(hue, chroma, keyColor);
1783
+ }
1784
+ constructor(hue, chroma, keyColor) {
1785
+ this.hue = hue;
1786
+ this.chroma = chroma;
1787
+ this.keyColor = keyColor;
1788
+ this.cache = /* @__PURE__ */ new Map();
1789
+ }
1790
+ /**
1791
+ * @param tone HCT tone, measured from 0 to 100.
1792
+ * @return ARGB representation of a color with that tone.
1793
+ */
1794
+ tone(tone) {
1795
+ let argb = this.cache.get(tone);
1796
+ if (argb === void 0) {
1797
+ argb = Hct.from(this.hue, this.chroma, tone).toInt();
1798
+ this.cache.set(tone, argb);
1799
+ }
1800
+ return argb;
1801
+ }
1802
+ /**
1803
+ * @param tone HCT tone.
1804
+ * @return HCT representation of a color with that tone.
1805
+ */
1806
+ getHct(tone) {
1807
+ return Hct.fromInt(this.tone(tone));
1808
+ }
1809
+ };
1810
+ var KeyColor = class {
1811
+ constructor(hue, requestedChroma) {
1812
+ this.hue = hue;
1813
+ this.requestedChroma = requestedChroma;
1814
+ this.chromaCache = /* @__PURE__ */ new Map();
1815
+ this.maxChromaValue = 200;
1816
+ }
1817
+ /**
1818
+ * Creates a key color from a [hue] and a [chroma].
1819
+ * The key color is the first tone, starting from T50, matching the given hue
1820
+ * and chroma.
1821
+ *
1822
+ * @return Key color [Hct]
1823
+ */
1824
+ create() {
1825
+ const pivotTone = 50;
1826
+ const toneStepSize = 1;
1827
+ const epsilon = 0.01;
1828
+ let lowerTone = 0;
1829
+ let upperTone = 100;
1830
+ while (lowerTone < upperTone) {
1831
+ const midTone = Math.floor((lowerTone + upperTone) / 2);
1832
+ const isAscending = this.maxChroma(midTone) < this.maxChroma(midTone + toneStepSize);
1833
+ const sufficientChroma = this.maxChroma(midTone) >= this.requestedChroma - epsilon;
1834
+ if (sufficientChroma) {
1835
+ if (Math.abs(lowerTone - pivotTone) < Math.abs(upperTone - pivotTone)) {
1836
+ upperTone = midTone;
1837
+ } else {
1838
+ if (lowerTone === midTone) {
1839
+ return Hct.from(this.hue, this.requestedChroma, lowerTone);
1840
+ }
1841
+ lowerTone = midTone;
1842
+ }
1843
+ } else {
1844
+ if (isAscending) {
1845
+ lowerTone = midTone + toneStepSize;
1846
+ } else {
1847
+ upperTone = midTone;
1848
+ }
1849
+ }
1850
+ }
1851
+ return Hct.from(this.hue, this.requestedChroma, lowerTone);
1852
+ }
1853
+ // Find the maximum chroma for a given tone
1854
+ maxChroma(tone) {
1855
+ if (this.chromaCache.has(tone)) {
1856
+ return this.chromaCache.get(tone);
1857
+ }
1858
+ const chroma = Hct.from(this.hue, this.maxChromaValue, tone).chroma;
1859
+ this.chromaCache.set(tone, chroma);
1860
+ return chroma;
1861
+ }
1862
+ };
1863
+
1864
+ // node_modules/@material/material-color-utilities/dynamiccolor/contrast_curve.js
1865
+ var ContrastCurve = class {
1866
+ /**
1867
+ * Creates a `ContrastCurve` object.
1868
+ *
1869
+ * @param low Value for contrast level -1.0
1870
+ * @param normal Value for contrast level 0.0
1871
+ * @param medium Value for contrast level 0.5
1872
+ * @param high Value for contrast level 1.0
1873
+ */
1874
+ constructor(low, normal, medium, high) {
1875
+ this.low = low;
1876
+ this.normal = normal;
1877
+ this.medium = medium;
1878
+ this.high = high;
1879
+ }
1880
+ /**
1881
+ * Returns the value at a given contrast level.
1882
+ *
1883
+ * @param contrastLevel The contrast level. 0.0 is the default (normal); -1.0
1884
+ * is the lowest; 1.0 is the highest.
1885
+ * @return The value. For contrast ratios, a number between 1.0 and 21.0.
1886
+ */
1887
+ get(contrastLevel) {
1888
+ if (contrastLevel <= -1) {
1889
+ return this.low;
1890
+ } else if (contrastLevel < 0) {
1891
+ return lerp(this.low, this.normal, (contrastLevel - -1) / 1);
1892
+ } else if (contrastLevel < 0.5) {
1893
+ return lerp(this.normal, this.medium, (contrastLevel - 0) / 0.5);
1894
+ } else if (contrastLevel < 1) {
1895
+ return lerp(this.medium, this.high, (contrastLevel - 0.5) / 0.5);
1896
+ } else {
1897
+ return this.high;
1898
+ }
1899
+ }
1900
+ };
1901
+
1902
+ // node_modules/@material/material-color-utilities/dynamiccolor/tone_delta_pair.js
1903
+ var ToneDeltaPair = class {
1904
+ /**
1905
+ * Documents a constraint in tone distance between two DynamicColors.
1906
+ *
1907
+ * The polarity is an adjective that describes "A", compared to "B".
1908
+ *
1909
+ * For instance, ToneDeltaPair(A, B, 15, 'darker', stayTogether) states that
1910
+ * A's tone should be at least 15 darker than B's.
1911
+ *
1912
+ * 'nearer' and 'farther' describes closeness to the surface roles. For
1913
+ * instance, ToneDeltaPair(A, B, 10, 'nearer', stayTogether) states that A
1914
+ * should be 10 lighter than B in light mode, and 10 darker than B in dark
1915
+ * mode.
1916
+ *
1917
+ * @param roleA The first role in a pair.
1918
+ * @param roleB The second role in a pair.
1919
+ * @param delta Required difference between tones. Absolute value, negative
1920
+ * values have undefined behavior.
1921
+ * @param polarity The relative relation between tones of roleA and roleB,
1922
+ * as described above.
1923
+ * @param stayTogether Whether these two roles should stay on the same side of
1924
+ * the "awkward zone" (T50-59). This is necessary for certain cases where
1925
+ * one role has two backgrounds.
1926
+ */
1927
+ constructor(roleA, roleB, delta, polarity, stayTogether) {
1928
+ this.roleA = roleA;
1929
+ this.roleB = roleB;
1930
+ this.delta = delta;
1931
+ this.polarity = polarity;
1932
+ this.stayTogether = stayTogether;
1933
+ }
1934
+ };
1935
+
1936
+ // node_modules/@material/material-color-utilities/dynamiccolor/variant.js
1937
+ var Variant;
1938
+ (function(Variant2) {
1939
+ Variant2[Variant2["MONOCHROME"] = 0] = "MONOCHROME";
1940
+ Variant2[Variant2["NEUTRAL"] = 1] = "NEUTRAL";
1941
+ Variant2[Variant2["TONAL_SPOT"] = 2] = "TONAL_SPOT";
1942
+ Variant2[Variant2["VIBRANT"] = 3] = "VIBRANT";
1943
+ Variant2[Variant2["EXPRESSIVE"] = 4] = "EXPRESSIVE";
1944
+ Variant2[Variant2["FIDELITY"] = 5] = "FIDELITY";
1945
+ Variant2[Variant2["CONTENT"] = 6] = "CONTENT";
1946
+ Variant2[Variant2["RAINBOW"] = 7] = "RAINBOW";
1947
+ Variant2[Variant2["FRUIT_SALAD"] = 8] = "FRUIT_SALAD";
1948
+ })(Variant || (Variant = {}));
1949
+
1950
+ // node_modules/@material/material-color-utilities/dynamiccolor/material_dynamic_colors.js
1951
+ function isFidelity(scheme) {
1952
+ return scheme.variant === Variant.FIDELITY || scheme.variant === Variant.CONTENT;
1953
+ }
1954
+ function isMonochrome(scheme) {
1955
+ return scheme.variant === Variant.MONOCHROME;
1956
+ }
1957
+ function findDesiredChromaByTone(hue, chroma, tone, byDecreasingTone) {
1958
+ let answer = tone;
1959
+ let closestToChroma = Hct.from(hue, chroma, tone);
1960
+ if (closestToChroma.chroma < chroma) {
1961
+ let chromaPeak = closestToChroma.chroma;
1962
+ while (closestToChroma.chroma < chroma) {
1963
+ answer += byDecreasingTone ? -1 : 1;
1964
+ const potentialSolution = Hct.from(hue, chroma, answer);
1965
+ if (chromaPeak > potentialSolution.chroma) {
1966
+ break;
1967
+ }
1968
+ if (Math.abs(potentialSolution.chroma - chroma) < 0.4) {
1969
+ break;
1970
+ }
1971
+ const potentialDelta = Math.abs(potentialSolution.chroma - chroma);
1972
+ const currentDelta = Math.abs(closestToChroma.chroma - chroma);
1973
+ if (potentialDelta < currentDelta) {
1974
+ closestToChroma = potentialSolution;
1975
+ }
1976
+ chromaPeak = Math.max(chromaPeak, potentialSolution.chroma);
1977
+ }
1978
+ }
1979
+ return answer;
1980
+ }
1981
+ var MaterialDynamicColors = class _MaterialDynamicColors {
1982
+ static highestSurface(s) {
1983
+ return s.isDark ? _MaterialDynamicColors.surfaceBright : _MaterialDynamicColors.surfaceDim;
1984
+ }
1985
+ };
1986
+ MaterialDynamicColors.contentAccentToneDelta = 15;
1987
+ MaterialDynamicColors.primaryPaletteKeyColor = DynamicColor.fromPalette({
1988
+ name: "primary_palette_key_color",
1989
+ palette: (s) => s.primaryPalette,
1990
+ tone: (s) => s.primaryPalette.keyColor.tone
1991
+ });
1992
+ MaterialDynamicColors.secondaryPaletteKeyColor = DynamicColor.fromPalette({
1993
+ name: "secondary_palette_key_color",
1994
+ palette: (s) => s.secondaryPalette,
1995
+ tone: (s) => s.secondaryPalette.keyColor.tone
1996
+ });
1997
+ MaterialDynamicColors.tertiaryPaletteKeyColor = DynamicColor.fromPalette({
1998
+ name: "tertiary_palette_key_color",
1999
+ palette: (s) => s.tertiaryPalette,
2000
+ tone: (s) => s.tertiaryPalette.keyColor.tone
2001
+ });
2002
+ MaterialDynamicColors.neutralPaletteKeyColor = DynamicColor.fromPalette({
2003
+ name: "neutral_palette_key_color",
2004
+ palette: (s) => s.neutralPalette,
2005
+ tone: (s) => s.neutralPalette.keyColor.tone
2006
+ });
2007
+ MaterialDynamicColors.neutralVariantPaletteKeyColor = DynamicColor.fromPalette({
2008
+ name: "neutral_variant_palette_key_color",
2009
+ palette: (s) => s.neutralVariantPalette,
2010
+ tone: (s) => s.neutralVariantPalette.keyColor.tone
2011
+ });
2012
+ MaterialDynamicColors.background = DynamicColor.fromPalette({
2013
+ name: "background",
2014
+ palette: (s) => s.neutralPalette,
2015
+ tone: (s) => s.isDark ? 6 : 98,
2016
+ isBackground: true
2017
+ });
2018
+ MaterialDynamicColors.onBackground = DynamicColor.fromPalette({
2019
+ name: "on_background",
2020
+ palette: (s) => s.neutralPalette,
2021
+ tone: (s) => s.isDark ? 90 : 10,
2022
+ background: (s) => MaterialDynamicColors.background,
2023
+ contrastCurve: new ContrastCurve(3, 3, 4.5, 7)
2024
+ });
2025
+ MaterialDynamicColors.surface = DynamicColor.fromPalette({
2026
+ name: "surface",
2027
+ palette: (s) => s.neutralPalette,
2028
+ tone: (s) => s.isDark ? 6 : 98,
2029
+ isBackground: true
2030
+ });
2031
+ MaterialDynamicColors.surfaceDim = DynamicColor.fromPalette({
2032
+ name: "surface_dim",
2033
+ palette: (s) => s.neutralPalette,
2034
+ tone: (s) => s.isDark ? 6 : new ContrastCurve(87, 87, 80, 75).get(s.contrastLevel),
2035
+ isBackground: true
2036
+ });
2037
+ MaterialDynamicColors.surfaceBright = DynamicColor.fromPalette({
2038
+ name: "surface_bright",
2039
+ palette: (s) => s.neutralPalette,
2040
+ tone: (s) => s.isDark ? new ContrastCurve(24, 24, 29, 34).get(s.contrastLevel) : 98,
2041
+ isBackground: true
2042
+ });
2043
+ MaterialDynamicColors.surfaceContainerLowest = DynamicColor.fromPalette({
2044
+ name: "surface_container_lowest",
2045
+ palette: (s) => s.neutralPalette,
2046
+ tone: (s) => s.isDark ? new ContrastCurve(4, 4, 2, 0).get(s.contrastLevel) : 100,
2047
+ isBackground: true
2048
+ });
2049
+ MaterialDynamicColors.surfaceContainerLow = DynamicColor.fromPalette({
2050
+ name: "surface_container_low",
2051
+ palette: (s) => s.neutralPalette,
2052
+ tone: (s) => s.isDark ? new ContrastCurve(10, 10, 11, 12).get(s.contrastLevel) : new ContrastCurve(96, 96, 96, 95).get(s.contrastLevel),
2053
+ isBackground: true
2054
+ });
2055
+ MaterialDynamicColors.surfaceContainer = DynamicColor.fromPalette({
2056
+ name: "surface_container",
2057
+ palette: (s) => s.neutralPalette,
2058
+ tone: (s) => s.isDark ? new ContrastCurve(12, 12, 16, 20).get(s.contrastLevel) : new ContrastCurve(94, 94, 92, 90).get(s.contrastLevel),
2059
+ isBackground: true
2060
+ });
2061
+ MaterialDynamicColors.surfaceContainerHigh = DynamicColor.fromPalette({
2062
+ name: "surface_container_high",
2063
+ palette: (s) => s.neutralPalette,
2064
+ tone: (s) => s.isDark ? new ContrastCurve(17, 17, 21, 25).get(s.contrastLevel) : new ContrastCurve(92, 92, 88, 85).get(s.contrastLevel),
2065
+ isBackground: true
2066
+ });
2067
+ MaterialDynamicColors.surfaceContainerHighest = DynamicColor.fromPalette({
2068
+ name: "surface_container_highest",
2069
+ palette: (s) => s.neutralPalette,
2070
+ tone: (s) => s.isDark ? new ContrastCurve(22, 22, 26, 30).get(s.contrastLevel) : new ContrastCurve(90, 90, 84, 80).get(s.contrastLevel),
2071
+ isBackground: true
2072
+ });
2073
+ MaterialDynamicColors.onSurface = DynamicColor.fromPalette({
2074
+ name: "on_surface",
2075
+ palette: (s) => s.neutralPalette,
2076
+ tone: (s) => s.isDark ? 90 : 10,
2077
+ background: (s) => MaterialDynamicColors.highestSurface(s),
2078
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
2079
+ });
2080
+ MaterialDynamicColors.surfaceVariant = DynamicColor.fromPalette({
2081
+ name: "surface_variant",
2082
+ palette: (s) => s.neutralVariantPalette,
2083
+ tone: (s) => s.isDark ? 30 : 90,
2084
+ isBackground: true
2085
+ });
2086
+ MaterialDynamicColors.onSurfaceVariant = DynamicColor.fromPalette({
2087
+ name: "on_surface_variant",
2088
+ palette: (s) => s.neutralVariantPalette,
2089
+ tone: (s) => s.isDark ? 80 : 30,
2090
+ background: (s) => MaterialDynamicColors.highestSurface(s),
2091
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
2092
+ });
2093
+ MaterialDynamicColors.inverseSurface = DynamicColor.fromPalette({
2094
+ name: "inverse_surface",
2095
+ palette: (s) => s.neutralPalette,
2096
+ tone: (s) => s.isDark ? 90 : 20
2097
+ });
2098
+ MaterialDynamicColors.inverseOnSurface = DynamicColor.fromPalette({
2099
+ name: "inverse_on_surface",
2100
+ palette: (s) => s.neutralPalette,
2101
+ tone: (s) => s.isDark ? 20 : 95,
2102
+ background: (s) => MaterialDynamicColors.inverseSurface,
2103
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
2104
+ });
2105
+ MaterialDynamicColors.outline = DynamicColor.fromPalette({
2106
+ name: "outline",
2107
+ palette: (s) => s.neutralVariantPalette,
2108
+ tone: (s) => s.isDark ? 60 : 50,
2109
+ background: (s) => MaterialDynamicColors.highestSurface(s),
2110
+ contrastCurve: new ContrastCurve(1.5, 3, 4.5, 7)
2111
+ });
2112
+ MaterialDynamicColors.outlineVariant = DynamicColor.fromPalette({
2113
+ name: "outline_variant",
2114
+ palette: (s) => s.neutralVariantPalette,
2115
+ tone: (s) => s.isDark ? 30 : 80,
2116
+ background: (s) => MaterialDynamicColors.highestSurface(s),
2117
+ contrastCurve: new ContrastCurve(1, 1, 3, 4.5)
2118
+ });
2119
+ MaterialDynamicColors.shadow = DynamicColor.fromPalette({
2120
+ name: "shadow",
2121
+ palette: (s) => s.neutralPalette,
2122
+ tone: (s) => 0
2123
+ });
2124
+ MaterialDynamicColors.scrim = DynamicColor.fromPalette({
2125
+ name: "scrim",
2126
+ palette: (s) => s.neutralPalette,
2127
+ tone: (s) => 0
2128
+ });
2129
+ MaterialDynamicColors.surfaceTint = DynamicColor.fromPalette({
2130
+ name: "surface_tint",
2131
+ palette: (s) => s.primaryPalette,
2132
+ tone: (s) => s.isDark ? 80 : 40,
2133
+ isBackground: true
2134
+ });
2135
+ MaterialDynamicColors.primary = DynamicColor.fromPalette({
2136
+ name: "primary",
2137
+ palette: (s) => s.primaryPalette,
2138
+ tone: (s) => {
2139
+ if (isMonochrome(s)) {
2140
+ return s.isDark ? 100 : 0;
2141
+ }
2142
+ return s.isDark ? 80 : 40;
2143
+ },
2144
+ isBackground: true,
2145
+ background: (s) => MaterialDynamicColors.highestSurface(s),
2146
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 7),
2147
+ toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.primaryContainer, MaterialDynamicColors.primary, 10, "nearer", false)
2148
+ });
2149
+ MaterialDynamicColors.onPrimary = DynamicColor.fromPalette({
2150
+ name: "on_primary",
2151
+ palette: (s) => s.primaryPalette,
2152
+ tone: (s) => {
2153
+ if (isMonochrome(s)) {
2154
+ return s.isDark ? 10 : 90;
2155
+ }
2156
+ return s.isDark ? 20 : 100;
2157
+ },
2158
+ background: (s) => MaterialDynamicColors.primary,
2159
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
2160
+ });
2161
+ MaterialDynamicColors.primaryContainer = DynamicColor.fromPalette({
2162
+ name: "primary_container",
2163
+ palette: (s) => s.primaryPalette,
2164
+ tone: (s) => {
2165
+ if (isFidelity(s)) {
2166
+ return s.sourceColorHct.tone;
2167
+ }
2168
+ if (isMonochrome(s)) {
2169
+ return s.isDark ? 85 : 25;
2170
+ }
2171
+ return s.isDark ? 30 : 90;
2172
+ },
2173
+ isBackground: true,
2174
+ background: (s) => MaterialDynamicColors.highestSurface(s),
2175
+ contrastCurve: new ContrastCurve(1, 1, 3, 4.5),
2176
+ toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.primaryContainer, MaterialDynamicColors.primary, 10, "nearer", false)
2177
+ });
2178
+ MaterialDynamicColors.onPrimaryContainer = DynamicColor.fromPalette({
2179
+ name: "on_primary_container",
2180
+ palette: (s) => s.primaryPalette,
2181
+ tone: (s) => {
2182
+ if (isFidelity(s)) {
2183
+ return DynamicColor.foregroundTone(MaterialDynamicColors.primaryContainer.tone(s), 4.5);
2184
+ }
2185
+ if (isMonochrome(s)) {
2186
+ return s.isDark ? 0 : 100;
2187
+ }
2188
+ return s.isDark ? 90 : 30;
2189
+ },
2190
+ background: (s) => MaterialDynamicColors.primaryContainer,
2191
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
2192
+ });
2193
+ MaterialDynamicColors.inversePrimary = DynamicColor.fromPalette({
2194
+ name: "inverse_primary",
2195
+ palette: (s) => s.primaryPalette,
2196
+ tone: (s) => s.isDark ? 40 : 80,
2197
+ background: (s) => MaterialDynamicColors.inverseSurface,
2198
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 7)
2199
+ });
2200
+ MaterialDynamicColors.secondary = DynamicColor.fromPalette({
2201
+ name: "secondary",
2202
+ palette: (s) => s.secondaryPalette,
2203
+ tone: (s) => s.isDark ? 80 : 40,
2204
+ isBackground: true,
2205
+ background: (s) => MaterialDynamicColors.highestSurface(s),
2206
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 7),
2207
+ toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.secondaryContainer, MaterialDynamicColors.secondary, 10, "nearer", false)
2208
+ });
2209
+ MaterialDynamicColors.onSecondary = DynamicColor.fromPalette({
2210
+ name: "on_secondary",
2211
+ palette: (s) => s.secondaryPalette,
2212
+ tone: (s) => {
2213
+ if (isMonochrome(s)) {
2214
+ return s.isDark ? 10 : 100;
2215
+ } else {
2216
+ return s.isDark ? 20 : 100;
2217
+ }
2218
+ },
2219
+ background: (s) => MaterialDynamicColors.secondary,
2220
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
2221
+ });
2222
+ MaterialDynamicColors.secondaryContainer = DynamicColor.fromPalette({
2223
+ name: "secondary_container",
2224
+ palette: (s) => s.secondaryPalette,
2225
+ tone: (s) => {
2226
+ const initialTone = s.isDark ? 30 : 90;
2227
+ if (isMonochrome(s)) {
2228
+ return s.isDark ? 30 : 85;
2229
+ }
2230
+ if (!isFidelity(s)) {
2231
+ return initialTone;
2232
+ }
2233
+ return findDesiredChromaByTone(s.secondaryPalette.hue, s.secondaryPalette.chroma, initialTone, s.isDark ? false : true);
2234
+ },
2235
+ isBackground: true,
2236
+ background: (s) => MaterialDynamicColors.highestSurface(s),
2237
+ contrastCurve: new ContrastCurve(1, 1, 3, 4.5),
2238
+ toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.secondaryContainer, MaterialDynamicColors.secondary, 10, "nearer", false)
2239
+ });
2240
+ MaterialDynamicColors.onSecondaryContainer = DynamicColor.fromPalette({
2241
+ name: "on_secondary_container",
2242
+ palette: (s) => s.secondaryPalette,
2243
+ tone: (s) => {
2244
+ if (isMonochrome(s)) {
2245
+ return s.isDark ? 90 : 10;
2246
+ }
2247
+ if (!isFidelity(s)) {
2248
+ return s.isDark ? 90 : 30;
2249
+ }
2250
+ return DynamicColor.foregroundTone(MaterialDynamicColors.secondaryContainer.tone(s), 4.5);
2251
+ },
2252
+ background: (s) => MaterialDynamicColors.secondaryContainer,
2253
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
2254
+ });
2255
+ MaterialDynamicColors.tertiary = DynamicColor.fromPalette({
2256
+ name: "tertiary",
2257
+ palette: (s) => s.tertiaryPalette,
2258
+ tone: (s) => {
2259
+ if (isMonochrome(s)) {
2260
+ return s.isDark ? 90 : 25;
2261
+ }
2262
+ return s.isDark ? 80 : 40;
2263
+ },
2264
+ isBackground: true,
2265
+ background: (s) => MaterialDynamicColors.highestSurface(s),
2266
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 7),
2267
+ toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.tertiaryContainer, MaterialDynamicColors.tertiary, 10, "nearer", false)
2268
+ });
2269
+ MaterialDynamicColors.onTertiary = DynamicColor.fromPalette({
2270
+ name: "on_tertiary",
2271
+ palette: (s) => s.tertiaryPalette,
2272
+ tone: (s) => {
2273
+ if (isMonochrome(s)) {
2274
+ return s.isDark ? 10 : 90;
2275
+ }
2276
+ return s.isDark ? 20 : 100;
2277
+ },
2278
+ background: (s) => MaterialDynamicColors.tertiary,
2279
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
2280
+ });
2281
+ MaterialDynamicColors.tertiaryContainer = DynamicColor.fromPalette({
2282
+ name: "tertiary_container",
2283
+ palette: (s) => s.tertiaryPalette,
2284
+ tone: (s) => {
2285
+ if (isMonochrome(s)) {
2286
+ return s.isDark ? 60 : 49;
2287
+ }
2288
+ if (!isFidelity(s)) {
2289
+ return s.isDark ? 30 : 90;
2290
+ }
2291
+ const proposedHct = s.tertiaryPalette.getHct(s.sourceColorHct.tone);
2292
+ return DislikeAnalyzer.fixIfDisliked(proposedHct).tone;
2293
+ },
2294
+ isBackground: true,
2295
+ background: (s) => MaterialDynamicColors.highestSurface(s),
2296
+ contrastCurve: new ContrastCurve(1, 1, 3, 4.5),
2297
+ toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.tertiaryContainer, MaterialDynamicColors.tertiary, 10, "nearer", false)
2298
+ });
2299
+ MaterialDynamicColors.onTertiaryContainer = DynamicColor.fromPalette({
2300
+ name: "on_tertiary_container",
2301
+ palette: (s) => s.tertiaryPalette,
2302
+ tone: (s) => {
2303
+ if (isMonochrome(s)) {
2304
+ return s.isDark ? 0 : 100;
2305
+ }
2306
+ if (!isFidelity(s)) {
2307
+ return s.isDark ? 90 : 30;
2308
+ }
2309
+ return DynamicColor.foregroundTone(MaterialDynamicColors.tertiaryContainer.tone(s), 4.5);
2310
+ },
2311
+ background: (s) => MaterialDynamicColors.tertiaryContainer,
2312
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
2313
+ });
2314
+ MaterialDynamicColors.error = DynamicColor.fromPalette({
2315
+ name: "error",
2316
+ palette: (s) => s.errorPalette,
2317
+ tone: (s) => s.isDark ? 80 : 40,
2318
+ isBackground: true,
2319
+ background: (s) => MaterialDynamicColors.highestSurface(s),
2320
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 7),
2321
+ toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.errorContainer, MaterialDynamicColors.error, 10, "nearer", false)
2322
+ });
2323
+ MaterialDynamicColors.onError = DynamicColor.fromPalette({
2324
+ name: "on_error",
2325
+ palette: (s) => s.errorPalette,
2326
+ tone: (s) => s.isDark ? 20 : 100,
2327
+ background: (s) => MaterialDynamicColors.error,
2328
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
2329
+ });
2330
+ MaterialDynamicColors.errorContainer = DynamicColor.fromPalette({
2331
+ name: "error_container",
2332
+ palette: (s) => s.errorPalette,
2333
+ tone: (s) => s.isDark ? 30 : 90,
2334
+ isBackground: true,
2335
+ background: (s) => MaterialDynamicColors.highestSurface(s),
2336
+ contrastCurve: new ContrastCurve(1, 1, 3, 4.5),
2337
+ toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.errorContainer, MaterialDynamicColors.error, 10, "nearer", false)
2338
+ });
2339
+ MaterialDynamicColors.onErrorContainer = DynamicColor.fromPalette({
2340
+ name: "on_error_container",
2341
+ palette: (s) => s.errorPalette,
2342
+ tone: (s) => {
2343
+ if (isMonochrome(s)) {
2344
+ return s.isDark ? 90 : 10;
2345
+ }
2346
+ return s.isDark ? 90 : 30;
2347
+ },
2348
+ background: (s) => MaterialDynamicColors.errorContainer,
2349
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
2350
+ });
2351
+ MaterialDynamicColors.primaryFixed = DynamicColor.fromPalette({
2352
+ name: "primary_fixed",
2353
+ palette: (s) => s.primaryPalette,
2354
+ tone: (s) => isMonochrome(s) ? 40 : 90,
2355
+ isBackground: true,
2356
+ background: (s) => MaterialDynamicColors.highestSurface(s),
2357
+ contrastCurve: new ContrastCurve(1, 1, 3, 4.5),
2358
+ toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.primaryFixed, MaterialDynamicColors.primaryFixedDim, 10, "lighter", true)
2359
+ });
2360
+ MaterialDynamicColors.primaryFixedDim = DynamicColor.fromPalette({
2361
+ name: "primary_fixed_dim",
2362
+ palette: (s) => s.primaryPalette,
2363
+ tone: (s) => isMonochrome(s) ? 30 : 80,
2364
+ isBackground: true,
2365
+ background: (s) => MaterialDynamicColors.highestSurface(s),
2366
+ contrastCurve: new ContrastCurve(1, 1, 3, 4.5),
2367
+ toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.primaryFixed, MaterialDynamicColors.primaryFixedDim, 10, "lighter", true)
2368
+ });
2369
+ MaterialDynamicColors.onPrimaryFixed = DynamicColor.fromPalette({
2370
+ name: "on_primary_fixed",
2371
+ palette: (s) => s.primaryPalette,
2372
+ tone: (s) => isMonochrome(s) ? 100 : 10,
2373
+ background: (s) => MaterialDynamicColors.primaryFixedDim,
2374
+ secondBackground: (s) => MaterialDynamicColors.primaryFixed,
2375
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
2376
+ });
2377
+ MaterialDynamicColors.onPrimaryFixedVariant = DynamicColor.fromPalette({
2378
+ name: "on_primary_fixed_variant",
2379
+ palette: (s) => s.primaryPalette,
2380
+ tone: (s) => isMonochrome(s) ? 90 : 30,
2381
+ background: (s) => MaterialDynamicColors.primaryFixedDim,
2382
+ secondBackground: (s) => MaterialDynamicColors.primaryFixed,
2383
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
2384
+ });
2385
+ MaterialDynamicColors.secondaryFixed = DynamicColor.fromPalette({
2386
+ name: "secondary_fixed",
2387
+ palette: (s) => s.secondaryPalette,
2388
+ tone: (s) => isMonochrome(s) ? 80 : 90,
2389
+ isBackground: true,
2390
+ background: (s) => MaterialDynamicColors.highestSurface(s),
2391
+ contrastCurve: new ContrastCurve(1, 1, 3, 4.5),
2392
+ toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.secondaryFixed, MaterialDynamicColors.secondaryFixedDim, 10, "lighter", true)
2393
+ });
2394
+ MaterialDynamicColors.secondaryFixedDim = DynamicColor.fromPalette({
2395
+ name: "secondary_fixed_dim",
2396
+ palette: (s) => s.secondaryPalette,
2397
+ tone: (s) => isMonochrome(s) ? 70 : 80,
2398
+ isBackground: true,
2399
+ background: (s) => MaterialDynamicColors.highestSurface(s),
2400
+ contrastCurve: new ContrastCurve(1, 1, 3, 4.5),
2401
+ toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.secondaryFixed, MaterialDynamicColors.secondaryFixedDim, 10, "lighter", true)
2402
+ });
2403
+ MaterialDynamicColors.onSecondaryFixed = DynamicColor.fromPalette({
2404
+ name: "on_secondary_fixed",
2405
+ palette: (s) => s.secondaryPalette,
2406
+ tone: (s) => 10,
2407
+ background: (s) => MaterialDynamicColors.secondaryFixedDim,
2408
+ secondBackground: (s) => MaterialDynamicColors.secondaryFixed,
2409
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
2410
+ });
2411
+ MaterialDynamicColors.onSecondaryFixedVariant = DynamicColor.fromPalette({
2412
+ name: "on_secondary_fixed_variant",
2413
+ palette: (s) => s.secondaryPalette,
2414
+ tone: (s) => isMonochrome(s) ? 25 : 30,
2415
+ background: (s) => MaterialDynamicColors.secondaryFixedDim,
2416
+ secondBackground: (s) => MaterialDynamicColors.secondaryFixed,
2417
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
2418
+ });
2419
+ MaterialDynamicColors.tertiaryFixed = DynamicColor.fromPalette({
2420
+ name: "tertiary_fixed",
2421
+ palette: (s) => s.tertiaryPalette,
2422
+ tone: (s) => isMonochrome(s) ? 40 : 90,
2423
+ isBackground: true,
2424
+ background: (s) => MaterialDynamicColors.highestSurface(s),
2425
+ contrastCurve: new ContrastCurve(1, 1, 3, 4.5),
2426
+ toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.tertiaryFixed, MaterialDynamicColors.tertiaryFixedDim, 10, "lighter", true)
2427
+ });
2428
+ MaterialDynamicColors.tertiaryFixedDim = DynamicColor.fromPalette({
2429
+ name: "tertiary_fixed_dim",
2430
+ palette: (s) => s.tertiaryPalette,
2431
+ tone: (s) => isMonochrome(s) ? 30 : 80,
2432
+ isBackground: true,
2433
+ background: (s) => MaterialDynamicColors.highestSurface(s),
2434
+ contrastCurve: new ContrastCurve(1, 1, 3, 4.5),
2435
+ toneDeltaPair: (s) => new ToneDeltaPair(MaterialDynamicColors.tertiaryFixed, MaterialDynamicColors.tertiaryFixedDim, 10, "lighter", true)
2436
+ });
2437
+ MaterialDynamicColors.onTertiaryFixed = DynamicColor.fromPalette({
2438
+ name: "on_tertiary_fixed",
2439
+ palette: (s) => s.tertiaryPalette,
2440
+ tone: (s) => isMonochrome(s) ? 100 : 10,
2441
+ background: (s) => MaterialDynamicColors.tertiaryFixedDim,
2442
+ secondBackground: (s) => MaterialDynamicColors.tertiaryFixed,
2443
+ contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
2444
+ });
2445
+ MaterialDynamicColors.onTertiaryFixedVariant = DynamicColor.fromPalette({
2446
+ name: "on_tertiary_fixed_variant",
2447
+ palette: (s) => s.tertiaryPalette,
2448
+ tone: (s) => isMonochrome(s) ? 90 : 30,
2449
+ background: (s) => MaterialDynamicColors.tertiaryFixedDim,
2450
+ secondBackground: (s) => MaterialDynamicColors.tertiaryFixed,
2451
+ contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
2452
+ });
2453
+
2454
+ // node_modules/@material/material-color-utilities/dynamiccolor/dynamic_scheme.js
2455
+ var DynamicScheme = class {
2456
+ constructor(args) {
2457
+ this.sourceColorArgb = args.sourceColorArgb;
2458
+ this.variant = args.variant;
2459
+ this.contrastLevel = args.contrastLevel;
2460
+ this.isDark = args.isDark;
2461
+ this.sourceColorHct = Hct.fromInt(args.sourceColorArgb);
2462
+ this.primaryPalette = args.primaryPalette;
2463
+ this.secondaryPalette = args.secondaryPalette;
2464
+ this.tertiaryPalette = args.tertiaryPalette;
2465
+ this.neutralPalette = args.neutralPalette;
2466
+ this.neutralVariantPalette = args.neutralVariantPalette;
2467
+ this.errorPalette = TonalPalette.fromHueAndChroma(25, 84);
2468
+ }
2469
+ /**
2470
+ * Support design spec'ing Dynamic Color by schemes that specify hue
2471
+ * rotations that should be applied at certain breakpoints.
2472
+ * @param sourceColor the source color of the theme, in HCT.
2473
+ * @param hues The "breakpoints", i.e. the hues at which a rotation should
2474
+ * be apply.
2475
+ * @param rotations The rotation that should be applied when source color's
2476
+ * hue is >= the same index in hues array, and <= the hue at the next index
2477
+ * in hues array.
2478
+ */
2479
+ static getRotatedHue(sourceColor, hues, rotations) {
2480
+ const sourceHue = sourceColor.hue;
2481
+ if (hues.length !== rotations.length) {
2482
+ throw new Error(`mismatch between hue length ${hues.length} & rotations ${rotations.length}`);
2483
+ }
2484
+ if (rotations.length === 1) {
2485
+ return sanitizeDegreesDouble(sourceColor.hue + rotations[0]);
2486
+ }
2487
+ const size = hues.length;
2488
+ for (let i = 0; i <= size - 2; i++) {
2489
+ const thisHue = hues[i];
2490
+ const nextHue = hues[i + 1];
2491
+ if (thisHue < sourceHue && sourceHue < nextHue) {
2492
+ return sanitizeDegreesDouble(sourceHue + rotations[i]);
2493
+ }
2494
+ }
2495
+ return sourceHue;
2496
+ }
2497
+ getArgb(dynamicColor) {
2498
+ return dynamicColor.getArgb(this);
2499
+ }
2500
+ getHct(dynamicColor) {
2501
+ return dynamicColor.getHct(this);
2502
+ }
2503
+ get primaryPaletteKeyColor() {
2504
+ return this.getArgb(MaterialDynamicColors.primaryPaletteKeyColor);
2505
+ }
2506
+ get secondaryPaletteKeyColor() {
2507
+ return this.getArgb(MaterialDynamicColors.secondaryPaletteKeyColor);
2508
+ }
2509
+ get tertiaryPaletteKeyColor() {
2510
+ return this.getArgb(MaterialDynamicColors.tertiaryPaletteKeyColor);
2511
+ }
2512
+ get neutralPaletteKeyColor() {
2513
+ return this.getArgb(MaterialDynamicColors.neutralPaletteKeyColor);
2514
+ }
2515
+ get neutralVariantPaletteKeyColor() {
2516
+ return this.getArgb(MaterialDynamicColors.neutralVariantPaletteKeyColor);
2517
+ }
2518
+ get background() {
2519
+ return this.getArgb(MaterialDynamicColors.background);
2520
+ }
2521
+ get onBackground() {
2522
+ return this.getArgb(MaterialDynamicColors.onBackground);
2523
+ }
2524
+ get surface() {
2525
+ return this.getArgb(MaterialDynamicColors.surface);
2526
+ }
2527
+ get surfaceDim() {
2528
+ return this.getArgb(MaterialDynamicColors.surfaceDim);
2529
+ }
2530
+ get surfaceBright() {
2531
+ return this.getArgb(MaterialDynamicColors.surfaceBright);
2532
+ }
2533
+ get surfaceContainerLowest() {
2534
+ return this.getArgb(MaterialDynamicColors.surfaceContainerLowest);
2535
+ }
2536
+ get surfaceContainerLow() {
2537
+ return this.getArgb(MaterialDynamicColors.surfaceContainerLow);
2538
+ }
2539
+ get surfaceContainer() {
2540
+ return this.getArgb(MaterialDynamicColors.surfaceContainer);
2541
+ }
2542
+ get surfaceContainerHigh() {
2543
+ return this.getArgb(MaterialDynamicColors.surfaceContainerHigh);
2544
+ }
2545
+ get surfaceContainerHighest() {
2546
+ return this.getArgb(MaterialDynamicColors.surfaceContainerHighest);
2547
+ }
2548
+ get onSurface() {
2549
+ return this.getArgb(MaterialDynamicColors.onSurface);
2550
+ }
2551
+ get surfaceVariant() {
2552
+ return this.getArgb(MaterialDynamicColors.surfaceVariant);
2553
+ }
2554
+ get onSurfaceVariant() {
2555
+ return this.getArgb(MaterialDynamicColors.onSurfaceVariant);
2556
+ }
2557
+ get inverseSurface() {
2558
+ return this.getArgb(MaterialDynamicColors.inverseSurface);
2559
+ }
2560
+ get inverseOnSurface() {
2561
+ return this.getArgb(MaterialDynamicColors.inverseOnSurface);
2562
+ }
2563
+ get outline() {
2564
+ return this.getArgb(MaterialDynamicColors.outline);
2565
+ }
2566
+ get outlineVariant() {
2567
+ return this.getArgb(MaterialDynamicColors.outlineVariant);
2568
+ }
2569
+ get shadow() {
2570
+ return this.getArgb(MaterialDynamicColors.shadow);
2571
+ }
2572
+ get scrim() {
2573
+ return this.getArgb(MaterialDynamicColors.scrim);
2574
+ }
2575
+ get surfaceTint() {
2576
+ return this.getArgb(MaterialDynamicColors.surfaceTint);
2577
+ }
2578
+ get primary() {
2579
+ return this.getArgb(MaterialDynamicColors.primary);
2580
+ }
2581
+ get onPrimary() {
2582
+ return this.getArgb(MaterialDynamicColors.onPrimary);
2583
+ }
2584
+ get primaryContainer() {
2585
+ return this.getArgb(MaterialDynamicColors.primaryContainer);
2586
+ }
2587
+ get onPrimaryContainer() {
2588
+ return this.getArgb(MaterialDynamicColors.onPrimaryContainer);
2589
+ }
2590
+ get inversePrimary() {
2591
+ return this.getArgb(MaterialDynamicColors.inversePrimary);
2592
+ }
2593
+ get secondary() {
2594
+ return this.getArgb(MaterialDynamicColors.secondary);
2595
+ }
2596
+ get onSecondary() {
2597
+ return this.getArgb(MaterialDynamicColors.onSecondary);
2598
+ }
2599
+ get secondaryContainer() {
2600
+ return this.getArgb(MaterialDynamicColors.secondaryContainer);
2601
+ }
2602
+ get onSecondaryContainer() {
2603
+ return this.getArgb(MaterialDynamicColors.onSecondaryContainer);
2604
+ }
2605
+ get tertiary() {
2606
+ return this.getArgb(MaterialDynamicColors.tertiary);
2607
+ }
2608
+ get onTertiary() {
2609
+ return this.getArgb(MaterialDynamicColors.onTertiary);
2610
+ }
2611
+ get tertiaryContainer() {
2612
+ return this.getArgb(MaterialDynamicColors.tertiaryContainer);
2613
+ }
2614
+ get onTertiaryContainer() {
2615
+ return this.getArgb(MaterialDynamicColors.onTertiaryContainer);
2616
+ }
2617
+ get error() {
2618
+ return this.getArgb(MaterialDynamicColors.error);
2619
+ }
2620
+ get onError() {
2621
+ return this.getArgb(MaterialDynamicColors.onError);
2622
+ }
2623
+ get errorContainer() {
2624
+ return this.getArgb(MaterialDynamicColors.errorContainer);
2625
+ }
2626
+ get onErrorContainer() {
2627
+ return this.getArgb(MaterialDynamicColors.onErrorContainer);
2628
+ }
2629
+ get primaryFixed() {
2630
+ return this.getArgb(MaterialDynamicColors.primaryFixed);
2631
+ }
2632
+ get primaryFixedDim() {
2633
+ return this.getArgb(MaterialDynamicColors.primaryFixedDim);
2634
+ }
2635
+ get onPrimaryFixed() {
2636
+ return this.getArgb(MaterialDynamicColors.onPrimaryFixed);
2637
+ }
2638
+ get onPrimaryFixedVariant() {
2639
+ return this.getArgb(MaterialDynamicColors.onPrimaryFixedVariant);
2640
+ }
2641
+ get secondaryFixed() {
2642
+ return this.getArgb(MaterialDynamicColors.secondaryFixed);
2643
+ }
2644
+ get secondaryFixedDim() {
2645
+ return this.getArgb(MaterialDynamicColors.secondaryFixedDim);
2646
+ }
2647
+ get onSecondaryFixed() {
2648
+ return this.getArgb(MaterialDynamicColors.onSecondaryFixed);
2649
+ }
2650
+ get onSecondaryFixedVariant() {
2651
+ return this.getArgb(MaterialDynamicColors.onSecondaryFixedVariant);
2652
+ }
2653
+ get tertiaryFixed() {
2654
+ return this.getArgb(MaterialDynamicColors.tertiaryFixed);
2655
+ }
2656
+ get tertiaryFixedDim() {
2657
+ return this.getArgb(MaterialDynamicColors.tertiaryFixedDim);
2658
+ }
2659
+ get onTertiaryFixed() {
2660
+ return this.getArgb(MaterialDynamicColors.onTertiaryFixed);
2661
+ }
2662
+ get onTertiaryFixedVariant() {
2663
+ return this.getArgb(MaterialDynamicColors.onTertiaryFixedVariant);
2664
+ }
2665
+ };
2666
+
2667
+ // node_modules/@material/material-color-utilities/temperature/temperature_cache.js
2668
+ var TemperatureCache = class _TemperatureCache {
2669
+ constructor(input) {
2670
+ this.input = input;
2671
+ this.hctsByTempCache = [];
2672
+ this.hctsByHueCache = [];
2673
+ this.tempsByHctCache = /* @__PURE__ */ new Map();
2674
+ this.inputRelativeTemperatureCache = -1;
2675
+ this.complementCache = null;
2676
+ }
2677
+ get hctsByTemp() {
2678
+ if (this.hctsByTempCache.length > 0) {
2679
+ return this.hctsByTempCache;
2680
+ }
2681
+ const hcts = this.hctsByHue.concat([this.input]);
2682
+ const temperaturesByHct = this.tempsByHct;
2683
+ hcts.sort((a, b) => temperaturesByHct.get(a) - temperaturesByHct.get(b));
2684
+ this.hctsByTempCache = hcts;
2685
+ return hcts;
2686
+ }
2687
+ get warmest() {
2688
+ return this.hctsByTemp[this.hctsByTemp.length - 1];
2689
+ }
2690
+ get coldest() {
2691
+ return this.hctsByTemp[0];
2692
+ }
2693
+ /**
2694
+ * A set of colors with differing hues, equidistant in temperature.
2695
+ *
2696
+ * In art, this is usually described as a set of 5 colors on a color wheel
2697
+ * divided into 12 sections. This method allows provision of either of those
2698
+ * values.
2699
+ *
2700
+ * Behavior is undefined when [count] or [divisions] is 0.
2701
+ * When divisions < count, colors repeat.
2702
+ *
2703
+ * [count] The number of colors to return, includes the input color.
2704
+ * [divisions] The number of divisions on the color wheel.
2705
+ */
2706
+ analogous(count = 5, divisions = 12) {
2707
+ const startHue = Math.round(this.input.hue);
2708
+ const startHct = this.hctsByHue[startHue];
2709
+ let lastTemp = this.relativeTemperature(startHct);
2710
+ const allColors = [startHct];
2711
+ let absoluteTotalTempDelta = 0;
2712
+ for (let i = 0; i < 360; i++) {
2713
+ const hue = sanitizeDegreesInt(startHue + i);
2714
+ const hct = this.hctsByHue[hue];
2715
+ const temp = this.relativeTemperature(hct);
2716
+ const tempDelta = Math.abs(temp - lastTemp);
2717
+ lastTemp = temp;
2718
+ absoluteTotalTempDelta += tempDelta;
2719
+ }
2720
+ let hueAddend = 1;
2721
+ const tempStep = absoluteTotalTempDelta / divisions;
2722
+ let totalTempDelta = 0;
2723
+ lastTemp = this.relativeTemperature(startHct);
2724
+ while (allColors.length < divisions) {
2725
+ const hue = sanitizeDegreesInt(startHue + hueAddend);
2726
+ const hct = this.hctsByHue[hue];
2727
+ const temp = this.relativeTemperature(hct);
2728
+ const tempDelta = Math.abs(temp - lastTemp);
2729
+ totalTempDelta += tempDelta;
2730
+ const desiredTotalTempDeltaForIndex = allColors.length * tempStep;
2731
+ let indexSatisfied = totalTempDelta >= desiredTotalTempDeltaForIndex;
2732
+ let indexAddend = 1;
2733
+ while (indexSatisfied && allColors.length < divisions) {
2734
+ allColors.push(hct);
2735
+ const desiredTotalTempDeltaForIndex2 = (allColors.length + indexAddend) * tempStep;
2736
+ indexSatisfied = totalTempDelta >= desiredTotalTempDeltaForIndex2;
2737
+ indexAddend++;
2738
+ }
2739
+ lastTemp = temp;
2740
+ hueAddend++;
2741
+ if (hueAddend > 360) {
2742
+ while (allColors.length < divisions) {
2743
+ allColors.push(hct);
2744
+ }
2745
+ break;
2746
+ }
2747
+ }
2748
+ const answers = [this.input];
2749
+ const increaseHueCount = Math.floor((count - 1) / 2);
2750
+ for (let i = 1; i < increaseHueCount + 1; i++) {
2751
+ let index = 0 - i;
2752
+ while (index < 0) {
2753
+ index = allColors.length + index;
2754
+ }
2755
+ if (index >= allColors.length) {
2756
+ index = index % allColors.length;
2757
+ }
2758
+ answers.splice(0, 0, allColors[index]);
2759
+ }
2760
+ const decreaseHueCount = count - increaseHueCount - 1;
2761
+ for (let i = 1; i < decreaseHueCount + 1; i++) {
2762
+ let index = i;
2763
+ while (index < 0) {
2764
+ index = allColors.length + index;
2765
+ }
2766
+ if (index >= allColors.length) {
2767
+ index = index % allColors.length;
2768
+ }
2769
+ answers.push(allColors[index]);
2770
+ }
2771
+ return answers;
2772
+ }
2773
+ /**
2774
+ * A color that complements the input color aesthetically.
2775
+ *
2776
+ * In art, this is usually described as being across the color wheel.
2777
+ * History of this shows intent as a color that is just as cool-warm as the
2778
+ * input color is warm-cool.
2779
+ */
2780
+ get complement() {
2781
+ if (this.complementCache != null) {
2782
+ return this.complementCache;
2783
+ }
2784
+ const coldestHue = this.coldest.hue;
2785
+ const coldestTemp = this.tempsByHct.get(this.coldest);
2786
+ const warmestHue = this.warmest.hue;
2787
+ const warmestTemp = this.tempsByHct.get(this.warmest);
2788
+ const range = warmestTemp - coldestTemp;
2789
+ const startHueIsColdestToWarmest = _TemperatureCache.isBetween(this.input.hue, coldestHue, warmestHue);
2790
+ const startHue = startHueIsColdestToWarmest ? warmestHue : coldestHue;
2791
+ const endHue = startHueIsColdestToWarmest ? coldestHue : warmestHue;
2792
+ const directionOfRotation = 1;
2793
+ let smallestError = 1e3;
2794
+ let answer = this.hctsByHue[Math.round(this.input.hue)];
2795
+ const complementRelativeTemp = 1 - this.inputRelativeTemperature;
2796
+ for (let hueAddend = 0; hueAddend <= 360; hueAddend += 1) {
2797
+ const hue = sanitizeDegreesDouble(startHue + directionOfRotation * hueAddend);
2798
+ if (!_TemperatureCache.isBetween(hue, startHue, endHue)) {
2799
+ continue;
2800
+ }
2801
+ const possibleAnswer = this.hctsByHue[Math.round(hue)];
2802
+ const relativeTemp = (this.tempsByHct.get(possibleAnswer) - coldestTemp) / range;
2803
+ const error = Math.abs(complementRelativeTemp - relativeTemp);
2804
+ if (error < smallestError) {
2805
+ smallestError = error;
2806
+ answer = possibleAnswer;
2807
+ }
2808
+ }
2809
+ this.complementCache = answer;
2810
+ return this.complementCache;
2811
+ }
2812
+ /**
2813
+ * Temperature relative to all colors with the same chroma and tone.
2814
+ * Value on a scale from 0 to 1.
2815
+ */
2816
+ relativeTemperature(hct) {
2817
+ const range = this.tempsByHct.get(this.warmest) - this.tempsByHct.get(this.coldest);
2818
+ const differenceFromColdest = this.tempsByHct.get(hct) - this.tempsByHct.get(this.coldest);
2819
+ if (range === 0) {
2820
+ return 0.5;
2821
+ }
2822
+ return differenceFromColdest / range;
2823
+ }
2824
+ /** Relative temperature of the input color. See [relativeTemperature]. */
2825
+ get inputRelativeTemperature() {
2826
+ if (this.inputRelativeTemperatureCache >= 0) {
2827
+ return this.inputRelativeTemperatureCache;
2828
+ }
2829
+ this.inputRelativeTemperatureCache = this.relativeTemperature(this.input);
2830
+ return this.inputRelativeTemperatureCache;
2831
+ }
2832
+ /** A Map with keys of HCTs in [hctsByTemp], values of raw temperature. */
2833
+ get tempsByHct() {
2834
+ if (this.tempsByHctCache.size > 0) {
2835
+ return this.tempsByHctCache;
2836
+ }
2837
+ const allHcts = this.hctsByHue.concat([this.input]);
2838
+ const temperaturesByHct = /* @__PURE__ */ new Map();
2839
+ for (const e of allHcts) {
2840
+ temperaturesByHct.set(e, _TemperatureCache.rawTemperature(e));
2841
+ }
2842
+ this.tempsByHctCache = temperaturesByHct;
2843
+ return temperaturesByHct;
2844
+ }
2845
+ /**
2846
+ * HCTs for all hues, with the same chroma/tone as the input.
2847
+ * Sorted ascending, hue 0 to 360.
2848
+ */
2849
+ get hctsByHue() {
2850
+ if (this.hctsByHueCache.length > 0) {
2851
+ return this.hctsByHueCache;
2852
+ }
2853
+ const hcts = [];
2854
+ for (let hue = 0; hue <= 360; hue += 1) {
2855
+ const colorAtHue = Hct.from(hue, this.input.chroma, this.input.tone);
2856
+ hcts.push(colorAtHue);
2857
+ }
2858
+ this.hctsByHueCache = hcts;
2859
+ return this.hctsByHueCache;
2860
+ }
2861
+ /** Determines if an angle is between two other angles, rotating clockwise. */
2862
+ static isBetween(angle, a, b) {
2863
+ if (a < b) {
2864
+ return a <= angle && angle <= b;
2865
+ }
2866
+ return a <= angle || angle <= b;
2867
+ }
2868
+ /**
2869
+ * Value representing cool-warm factor of a color.
2870
+ * Values below 0 are considered cool, above, warm.
2871
+ *
2872
+ * Color science has researched emotion and harmony, which art uses to select
2873
+ * colors. Warm-cool is the foundation of analogous and complementary colors.
2874
+ * See:
2875
+ * - Li-Chen Ou's Chapter 19 in Handbook of Color Psychology (2015).
2876
+ * - Josef Albers' Interaction of Color chapters 19 and 21.
2877
+ *
2878
+ * Implementation of Ou, Woodcock and Wright's algorithm, which uses
2879
+ * L*a*b* / LCH color space.
2880
+ * Return value has these properties:
2881
+ * - Values below 0 are cool, above 0 are warm.
2882
+ * - Lower bound: -0.52 - (chroma ^ 1.07 / 20). L*a*b* chroma is infinite.
2883
+ * Assuming max of 130 chroma, -9.66.
2884
+ * - Upper bound: -0.52 + (chroma ^ 1.07 / 20). L*a*b* chroma is infinite.
2885
+ * Assuming max of 130 chroma, 8.61.
2886
+ */
2887
+ static rawTemperature(color) {
2888
+ const lab = labFromArgb(color.toInt());
2889
+ const hue = sanitizeDegreesDouble(Math.atan2(lab[2], lab[1]) * 180 / Math.PI);
2890
+ const chroma = Math.sqrt(lab[1] * lab[1] + lab[2] * lab[2]);
2891
+ const temperature = -0.5 + 0.02 * Math.pow(chroma, 1.07) * Math.cos(sanitizeDegreesDouble(hue - 50) * Math.PI / 180);
2892
+ return temperature;
2893
+ }
2894
+ };
2895
+
2896
+ // node_modules/@material/material-color-utilities/scheme/scheme_content.js
2897
+ var SchemeContent = class extends DynamicScheme {
2898
+ constructor(sourceColorHct, isDark, contrastLevel) {
2899
+ super({
2900
+ sourceColorArgb: sourceColorHct.toInt(),
2901
+ variant: Variant.CONTENT,
2902
+ contrastLevel,
2903
+ isDark,
2904
+ primaryPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, sourceColorHct.chroma),
2905
+ secondaryPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, Math.max(sourceColorHct.chroma - 32, sourceColorHct.chroma * 0.5)),
2906
+ tertiaryPalette: TonalPalette.fromInt(DislikeAnalyzer.fixIfDisliked(new TemperatureCache(sourceColorHct).analogous(3, 6)[2]).toInt()),
2907
+ neutralPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, sourceColorHct.chroma / 8),
2908
+ neutralVariantPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, sourceColorHct.chroma / 8 + 4)
2909
+ });
2910
+ }
2911
+ };
2912
+
2913
+ // node_modules/@material/material-color-utilities/scheme/scheme_expressive.js
2914
+ var SchemeExpressive = class _SchemeExpressive extends DynamicScheme {
2915
+ constructor(sourceColorHct, isDark, contrastLevel) {
2916
+ super({
2917
+ sourceColorArgb: sourceColorHct.toInt(),
2918
+ variant: Variant.EXPRESSIVE,
2919
+ contrastLevel,
2920
+ isDark,
2921
+ primaryPalette: TonalPalette.fromHueAndChroma(sanitizeDegreesDouble(sourceColorHct.hue + 240), 40),
2922
+ secondaryPalette: TonalPalette.fromHueAndChroma(DynamicScheme.getRotatedHue(sourceColorHct, _SchemeExpressive.hues, _SchemeExpressive.secondaryRotations), 24),
2923
+ tertiaryPalette: TonalPalette.fromHueAndChroma(DynamicScheme.getRotatedHue(sourceColorHct, _SchemeExpressive.hues, _SchemeExpressive.tertiaryRotations), 32),
2924
+ neutralPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue + 15, 8),
2925
+ neutralVariantPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue + 15, 12)
2926
+ });
2927
+ }
2928
+ };
2929
+ SchemeExpressive.hues = [
2930
+ 0,
2931
+ 21,
2932
+ 51,
2933
+ 121,
2934
+ 151,
2935
+ 191,
2936
+ 271,
2937
+ 321,
2938
+ 360
2939
+ ];
2940
+ SchemeExpressive.secondaryRotations = [
2941
+ 45,
2942
+ 95,
2943
+ 45,
2944
+ 20,
2945
+ 45,
2946
+ 90,
2947
+ 45,
2948
+ 45,
2949
+ 45
2950
+ ];
2951
+ SchemeExpressive.tertiaryRotations = [
2952
+ 120,
2953
+ 120,
2954
+ 20,
2955
+ 45,
2956
+ 20,
2957
+ 15,
2958
+ 20,
2959
+ 120,
2960
+ 120
2961
+ ];
2962
+
2963
+ // node_modules/@material/material-color-utilities/scheme/scheme_fidelity.js
2964
+ var SchemeFidelity = class extends DynamicScheme {
2965
+ constructor(sourceColorHct, isDark, contrastLevel) {
2966
+ super({
2967
+ sourceColorArgb: sourceColorHct.toInt(),
2968
+ variant: Variant.FIDELITY,
2969
+ contrastLevel,
2970
+ isDark,
2971
+ primaryPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, sourceColorHct.chroma),
2972
+ secondaryPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, Math.max(sourceColorHct.chroma - 32, sourceColorHct.chroma * 0.5)),
2973
+ tertiaryPalette: TonalPalette.fromInt(DislikeAnalyzer.fixIfDisliked(new TemperatureCache(sourceColorHct).complement).toInt()),
2974
+ neutralPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, sourceColorHct.chroma / 8),
2975
+ neutralVariantPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, sourceColorHct.chroma / 8 + 4)
2976
+ });
2977
+ }
2978
+ };
2979
+
2980
+ // node_modules/@material/material-color-utilities/scheme/scheme_monochrome.js
2981
+ var SchemeMonochrome = class extends DynamicScheme {
2982
+ constructor(sourceColorHct, isDark, contrastLevel) {
2983
+ super({
2984
+ sourceColorArgb: sourceColorHct.toInt(),
2985
+ variant: Variant.MONOCHROME,
2986
+ contrastLevel,
2987
+ isDark,
2988
+ primaryPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, 0),
2989
+ secondaryPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, 0),
2990
+ tertiaryPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, 0),
2991
+ neutralPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, 0),
2992
+ neutralVariantPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, 0)
2993
+ });
2994
+ }
2995
+ };
2996
+
2997
+ // node_modules/@material/material-color-utilities/scheme/scheme_neutral.js
2998
+ var SchemeNeutral = class extends DynamicScheme {
2999
+ constructor(sourceColorHct, isDark, contrastLevel) {
3000
+ super({
3001
+ sourceColorArgb: sourceColorHct.toInt(),
3002
+ variant: Variant.NEUTRAL,
3003
+ contrastLevel,
3004
+ isDark,
3005
+ primaryPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, 12),
3006
+ secondaryPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, 8),
3007
+ tertiaryPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, 16),
3008
+ neutralPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, 2),
3009
+ neutralVariantPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, 2)
3010
+ });
3011
+ }
3012
+ };
3013
+
3014
+ // node_modules/@material/material-color-utilities/scheme/scheme_tonal_spot.js
3015
+ var SchemeTonalSpot = class extends DynamicScheme {
3016
+ constructor(sourceColorHct, isDark, contrastLevel) {
3017
+ super({
3018
+ sourceColorArgb: sourceColorHct.toInt(),
3019
+ variant: Variant.TONAL_SPOT,
3020
+ contrastLevel,
3021
+ isDark,
3022
+ primaryPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, 36),
3023
+ secondaryPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, 16),
3024
+ tertiaryPalette: TonalPalette.fromHueAndChroma(sanitizeDegreesDouble(sourceColorHct.hue + 60), 24),
3025
+ neutralPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, 6),
3026
+ neutralVariantPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, 8)
3027
+ });
3028
+ }
3029
+ };
3030
+
3031
+ // node_modules/@material/material-color-utilities/scheme/scheme_vibrant.js
3032
+ var SchemeVibrant = class _SchemeVibrant extends DynamicScheme {
3033
+ constructor(sourceColorHct, isDark, contrastLevel) {
3034
+ super({
3035
+ sourceColorArgb: sourceColorHct.toInt(),
3036
+ variant: Variant.VIBRANT,
3037
+ contrastLevel,
3038
+ isDark,
3039
+ primaryPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, 200),
3040
+ secondaryPalette: TonalPalette.fromHueAndChroma(DynamicScheme.getRotatedHue(sourceColorHct, _SchemeVibrant.hues, _SchemeVibrant.secondaryRotations), 24),
3041
+ tertiaryPalette: TonalPalette.fromHueAndChroma(DynamicScheme.getRotatedHue(sourceColorHct, _SchemeVibrant.hues, _SchemeVibrant.tertiaryRotations), 32),
3042
+ neutralPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, 10),
3043
+ neutralVariantPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, 12)
3044
+ });
3045
+ }
3046
+ };
3047
+ SchemeVibrant.hues = [
3048
+ 0,
3049
+ 41,
3050
+ 61,
3051
+ 101,
3052
+ 131,
3053
+ 181,
3054
+ 251,
3055
+ 301,
3056
+ 360
3057
+ ];
3058
+ SchemeVibrant.secondaryRotations = [
3059
+ 18,
3060
+ 15,
3061
+ 10,
3062
+ 12,
3063
+ 15,
3064
+ 18,
3065
+ 15,
3066
+ 12,
3067
+ 12
3068
+ ];
3069
+ SchemeVibrant.tertiaryRotations = [
3070
+ 35,
3071
+ 30,
3072
+ 20,
3073
+ 25,
3074
+ 30,
3075
+ 35,
3076
+ 30,
3077
+ 25,
3078
+ 25
3079
+ ];
3080
+
3081
+ // node_modules/@material/material-color-utilities/utils/string_utils.js
3082
+ function hexFromArgb(argb) {
3083
+ const r = redFromArgb(argb);
3084
+ const g = greenFromArgb(argb);
3085
+ const b = blueFromArgb(argb);
3086
+ const outParts = [r.toString(16), g.toString(16), b.toString(16)];
3087
+ for (const [i, part] of outParts.entries()) {
3088
+ if (part.length === 1) {
3089
+ outParts[i] = "0" + part;
3090
+ }
3091
+ }
3092
+ return "#" + outParts.join("");
3093
+ }
3094
+ function argbFromHex(hex) {
3095
+ hex = hex.replace("#", "");
3096
+ const isThree = hex.length === 3;
3097
+ const isSix = hex.length === 6;
3098
+ const isEight = hex.length === 8;
3099
+ if (!isThree && !isSix && !isEight) {
3100
+ throw new Error("unexpected hex " + hex);
3101
+ }
3102
+ let r = 0;
3103
+ let g = 0;
3104
+ let b = 0;
3105
+ if (isThree) {
3106
+ r = parseIntHex(hex.slice(0, 1).repeat(2));
3107
+ g = parseIntHex(hex.slice(1, 2).repeat(2));
3108
+ b = parseIntHex(hex.slice(2, 3).repeat(2));
3109
+ } else if (isSix) {
3110
+ r = parseIntHex(hex.slice(0, 2));
3111
+ g = parseIntHex(hex.slice(2, 4));
3112
+ b = parseIntHex(hex.slice(4, 6));
3113
+ } else if (isEight) {
3114
+ r = parseIntHex(hex.slice(2, 4));
3115
+ g = parseIntHex(hex.slice(4, 6));
3116
+ b = parseIntHex(hex.slice(6, 8));
3117
+ }
3118
+ return (255 << 24 | (r & 255) << 16 | (g & 255) << 8 | b & 255) >>> 0;
3119
+ }
3120
+ function parseIntHex(value) {
3121
+ return parseInt(value, 16);
3122
+ }
3123
+
3124
+ // src/color/generateScheme.ts
3125
+ var SchemeVariant = {
3126
+ TonalSpot: "tonalSpot",
3127
+ Vibrant: "vibrant",
3128
+ Expressive: "expressive",
3129
+ Fidelity: "fidelity",
3130
+ Content: "content",
3131
+ Neutral: "neutral",
3132
+ Monochrome: "monochrome"
3133
+ };
3134
+ var VARIANT_CTOR = {
3135
+ [SchemeVariant.TonalSpot]: SchemeTonalSpot,
3136
+ [SchemeVariant.Vibrant]: SchemeVibrant,
3137
+ [SchemeVariant.Expressive]: SchemeExpressive,
3138
+ [SchemeVariant.Fidelity]: SchemeFidelity,
3139
+ [SchemeVariant.Content]: SchemeContent,
3140
+ [SchemeVariant.Neutral]: SchemeNeutral,
3141
+ [SchemeVariant.Monochrome]: SchemeMonochrome
3142
+ };
3143
+ function buildScheme(spec, isDark) {
3144
+ const Ctor = VARIANT_CTOR[spec.variant ?? SchemeVariant.TonalSpot];
3145
+ const base = new Ctor(Hct.fromInt(argbFromHex(spec.seed)), isDark, spec.contrastLevel ?? 0);
3146
+ if (!spec.secondary && !spec.tertiary && !spec.neutral) return base;
3147
+ return new DynamicScheme({
3148
+ sourceColorArgb: base.sourceColorArgb,
3149
+ variant: base.variant,
3150
+ isDark,
3151
+ contrastLevel: spec.contrastLevel ?? 0,
3152
+ primaryPalette: base.primaryPalette,
3153
+ secondaryPalette: spec.secondary ? TonalPalette.fromInt(argbFromHex(spec.secondary)) : base.secondaryPalette,
3154
+ tertiaryPalette: spec.tertiary ? TonalPalette.fromInt(argbFromHex(spec.tertiary)) : base.tertiaryPalette,
3155
+ neutralPalette: spec.neutral ? TonalPalette.fromInt(argbFromHex(spec.neutral)) : base.neutralPalette,
3156
+ neutralVariantPalette: spec.neutral ? TonalPalette.fromInt(argbFromHex(spec.neutral)) : base.neutralVariantPalette
3157
+ });
3158
+ }
3159
+ function readScheme(scheme) {
3160
+ const out = {};
3161
+ for (const role of ROLE_ORDER) {
3162
+ const dc = MaterialDynamicColors[role];
3163
+ if (dc && typeof dc.getArgb === "function") {
3164
+ out[role] = hexFromArgb(dc.getArgb(scheme));
3165
+ }
3166
+ }
3167
+ return out;
3168
+ }
3169
+ function generateScheme(spec) {
3170
+ const light = { ...readScheme(buildScheme(spec, false)), ...spec.overrides?.light ?? {} };
3171
+ const dark = { ...readScheme(buildScheme(spec, true)), ...spec.overrides?.dark ?? {} };
3172
+ return { light, dark };
3173
+ }
3174
+
3175
+ // src/color/cssVars.ts
3176
+ function cssVarName(role) {
3177
+ return `--md-${role.replace(/([A-Z])/g, "-$1").toLowerCase()}`;
3178
+ }
3179
+ function schemeVars(colors) {
3180
+ const out = {};
3181
+ for (const [role, hex] of Object.entries(colors)) {
3182
+ out[cssVarName(role)] = hex;
3183
+ }
3184
+ return out;
3185
+ }
3186
+ function declBlock(colors) {
3187
+ return Object.entries(colors).map(([role, hex]) => ` ${cssVarName(role)}: ${hex};`).join("\n");
3188
+ }
3189
+ function schemeToCssText(scheme, opts = {}) {
3190
+ const light = opts.lightSelector ?? ":where([data-brand-studio])";
3191
+ const dark = opts.darkSelector ?? ":where(.dark [data-brand-studio], [data-brand-studio].dark)";
3192
+ return `${light}{
3193
+ ${declBlock(scheme.light)}
3194
+ }
3195
+ ${dark}{
3196
+ ${declBlock(scheme.dark)}
3197
+ }`;
3198
+ }
3199
+
3200
+ // src/color/contrast.ts
3201
+ function hexToRgb(hex) {
3202
+ const h = hex.replace("#", "");
3203
+ const full = h.length === 3 ? h.split("").map((c) => c + c).join("") : h.slice(0, 6);
3204
+ const num = Number.parseInt(full, 16);
3205
+ return [num >> 16 & 255, num >> 8 & 255, num & 255];
3206
+ }
3207
+ function channelLin(c) {
3208
+ const s = c / 255;
3209
+ return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
3210
+ }
3211
+ function relativeLuminance(hex) {
3212
+ const [r, g, b] = hexToRgb(hex);
3213
+ return 0.2126 * channelLin(r) + 0.7152 * channelLin(g) + 0.0722 * channelLin(b);
3214
+ }
3215
+ function contrastRatio(a, b) {
3216
+ const la = relativeLuminance(a);
3217
+ const lb = relativeLuminance(b);
3218
+ const [hi, lo] = la > lb ? [la, lb] : [lb, la];
3219
+ return (hi + 0.05) / (lo + 0.05);
3220
+ }
3221
+ var ContrastTier = {
3222
+ AAA: "AAA",
3223
+ AA: "AA",
3224
+ AALarge: "AA-LG",
3225
+ Fail: "fail"
3226
+ };
3227
+ function contrastBadge(ratio) {
3228
+ const label = `${ratio.toFixed(1)}:1`;
3229
+ if (ratio >= 7) return { label, tier: ContrastTier.AAA };
3230
+ if (ratio >= 4.5) return { label, tier: ContrastTier.AA };
3231
+ if (ratio >= 3) return { label, tier: ContrastTier.AALarge };
3232
+ return { label, tier: ContrastTier.Fail };
3233
+ }
3234
+ /*! Bundled license information:
3235
+
3236
+ @material/material-color-utilities/utils/math_utils.js:
3237
+ @material/material-color-utilities/utils/color_utils.js:
3238
+ @material/material-color-utilities/hct/viewing_conditions.js:
3239
+ @material/material-color-utilities/hct/cam16.js:
3240
+ @material/material-color-utilities/hct/hct_solver.js:
3241
+ @material/material-color-utilities/hct/hct.js:
3242
+ @material/material-color-utilities/blend/blend.js:
3243
+ @material/material-color-utilities/palettes/tonal_palette.js:
3244
+ @material/material-color-utilities/palettes/core_palette.js:
3245
+ @material/material-color-utilities/quantize/lab_point_provider.js:
3246
+ @material/material-color-utilities/quantize/quantizer_wsmeans.js:
3247
+ @material/material-color-utilities/quantize/quantizer_map.js:
3248
+ @material/material-color-utilities/quantize/quantizer_wu.js:
3249
+ @material/material-color-utilities/quantize/quantizer_celebi.js:
3250
+ @material/material-color-utilities/scheme/scheme.js:
3251
+ @material/material-color-utilities/scheme/scheme_android.js:
3252
+ @material/material-color-utilities/score/score.js:
3253
+ @material/material-color-utilities/utils/string_utils.js:
3254
+ @material/material-color-utilities/utils/image_utils.js:
3255
+ @material/material-color-utilities/utils/theme_utils.js:
3256
+ @material/material-color-utilities/index.js:
3257
+ (**
3258
+ * @license
3259
+ * Copyright 2021 Google LLC
3260
+ *
3261
+ * Licensed under the Apache License, Version 2.0 (the "License");
3262
+ * you may not use this file except in compliance with the License.
3263
+ * You may obtain a copy of the License at
3264
+ *
3265
+ * http://www.apache.org/licenses/LICENSE-2.0
3266
+ *
3267
+ * Unless required by applicable law or agreed to in writing, software
3268
+ * distributed under the License is distributed on an "AS IS" BASIS,
3269
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3270
+ * See the License for the specific language governing permissions and
3271
+ * limitations under the License.
3272
+ *)
3273
+
3274
+ @material/material-color-utilities/contrast/contrast.js:
3275
+ @material/material-color-utilities/dynamiccolor/dynamic_color.js:
3276
+ @material/material-color-utilities/dynamiccolor/variant.js:
3277
+ @material/material-color-utilities/dynamiccolor/material_dynamic_colors.js:
3278
+ @material/material-color-utilities/dynamiccolor/dynamic_scheme.js:
3279
+ @material/material-color-utilities/scheme/scheme_expressive.js:
3280
+ @material/material-color-utilities/scheme/scheme_fruit_salad.js:
3281
+ @material/material-color-utilities/scheme/scheme_monochrome.js:
3282
+ @material/material-color-utilities/scheme/scheme_neutral.js:
3283
+ @material/material-color-utilities/scheme/scheme_rainbow.js:
3284
+ @material/material-color-utilities/scheme/scheme_tonal_spot.js:
3285
+ @material/material-color-utilities/scheme/scheme_vibrant.js:
3286
+ (**
3287
+ * @license
3288
+ * Copyright 2022 Google LLC
3289
+ *
3290
+ * Licensed under the Apache License, Version 2.0 (the "License");
3291
+ * you may not use this file except in compliance with the License.
3292
+ * You may obtain a copy of the License at
3293
+ *
3294
+ * http://www.apache.org/licenses/LICENSE-2.0
3295
+ *
3296
+ * Unless required by applicable law or agreed to in writing, software
3297
+ * distributed under the License is distributed on an "AS IS" BASIS,
3298
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3299
+ * See the License for the specific language governing permissions and
3300
+ * limitations under the License.
3301
+ *)
3302
+
3303
+ @material/material-color-utilities/dislike/dislike_analyzer.js:
3304
+ @material/material-color-utilities/dynamiccolor/contrast_curve.js:
3305
+ @material/material-color-utilities/dynamiccolor/tone_delta_pair.js:
3306
+ @material/material-color-utilities/temperature/temperature_cache.js:
3307
+ @material/material-color-utilities/scheme/scheme_content.js:
3308
+ @material/material-color-utilities/scheme/scheme_fidelity.js:
3309
+ (**
3310
+ * @license
3311
+ * Copyright 2023 Google LLC
3312
+ *
3313
+ * Licensed under the Apache License, Version 2.0 (the "License");
3314
+ * you may not use this file except in compliance with the License.
3315
+ * You may obtain a copy of the License at
3316
+ *
3317
+ * http://www.apache.org/licenses/LICENSE-2.0
3318
+ *
3319
+ * Unless required by applicable law or agreed to in writing, software
3320
+ * distributed under the License is distributed on an "AS IS" BASIS,
3321
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3322
+ * See the License for the specific language governing permissions and
3323
+ * limitations under the License.
3324
+ *)
3325
+ */
3326
+
3327
+ export { ContrastTier, ROLE, ROLE_GROUPS, ROLE_ORDER, SchemeVariant, contrastBadge, contrastRatio, cssVarName, generateScheme, relativeLuminance, schemeToCssText, schemeVars };