@wistia/kaleidoscope 0.0.5 → 0.0.6-beta.8a58a87a.88eb375

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/color-Bvmf2YPw.js +148 -0
  2. package/dist/color-Bvmf2YPw.js.map +1 -0
  3. package/dist/{color-BD12TVX4.d.ts → color-CwLKMi6Y.d.ts} +4 -25
  4. package/dist/color-CwLKMi6Y.d.ts.map +1 -0
  5. package/dist/engine-B00ZVZ0d.d.ts +85 -0
  6. package/dist/engine-B00ZVZ0d.d.ts.map +1 -0
  7. package/dist/engine-WltpPH__.js +962 -0
  8. package/dist/engine-WltpPH__.js.map +1 -0
  9. package/dist/entries/color.d.ts +1 -1
  10. package/dist/entries/color.js +3 -2
  11. package/dist/entries/engine.d.ts +3 -0
  12. package/dist/entries/engine.js +10 -0
  13. package/dist/entries/styleRegistry.d.ts +2 -2
  14. package/dist/entries/styleRegistry.js +2 -3
  15. package/dist/entries/validate.d.ts +1 -1
  16. package/dist/entries/validate.js +2 -3
  17. package/dist/entries/vocabulary.d.ts +1 -1
  18. package/dist/entries/vocabulary.js +3 -2
  19. package/dist/{color-C99gJSgH.js → getColorLightnessClassification-BWOpTeg8.js} +29 -178
  20. package/dist/getColorLightnessClassification-BWOpTeg8.js.map +1 -0
  21. package/dist/guards-COtsVD09.js +24 -0
  22. package/dist/guards-COtsVD09.js.map +1 -0
  23. package/dist/{index-CG6dL9XZ.d.ts → index-BOJCY_MU.d.ts} +4 -32
  24. package/dist/index-BOJCY_MU.d.ts.map +1 -0
  25. package/dist/index.d.ts +6 -5
  26. package/dist/index.js +9 -6
  27. package/dist/styleRegistry-A0nrsHk-.d.ts +15 -0
  28. package/dist/styleRegistry-A0nrsHk-.d.ts.map +1 -0
  29. package/dist/{styleRegistry-BoviV8Ue.js → styleRegistry-BmoXoOaY.js} +70 -71
  30. package/dist/styleRegistry-BmoXoOaY.js.map +1 -0
  31. package/dist/{styleVocabulary-Kl8p6TDk.js → styleVocabulary-CN0ZzrsJ.js} +19 -80
  32. package/dist/styleVocabulary-CN0ZzrsJ.js.map +1 -0
  33. package/dist/typography-doCy9gMO.js +65 -0
  34. package/dist/typography-doCy9gMO.js.map +1 -0
  35. package/dist/{validate-V28YRNxt.d.ts → validate-Bqx__f3d.d.ts} +2 -6
  36. package/dist/validate-Bqx__f3d.d.ts.map +1 -0
  37. package/dist/{validate-C_h6gEXp.js → validate-UdWc-DAs.js} +20 -46
  38. package/dist/validate-UdWc-DAs.js.map +1 -0
  39. package/package.json +21 -16
  40. package/schema/style-v1.json +7 -2
  41. package/styles/aurora-dark.json +3 -2
  42. package/styles/aurora-light.json +3 -2
  43. package/styles/glass-dark.json +16 -15
  44. package/styles/glass-light.json +19 -18
  45. package/styles/opaque-bright.json +3 -2
  46. package/styles/opaque-heavy.json +3 -2
  47. package/styles/opaque-light.json +3 -2
  48. package/styles/opaque-medium.json +3 -2
  49. package/styles/opaque-minimal.json +3 -2
  50. package/CHANGELOG.md +0 -39
  51. package/dist/color-BD12TVX4.d.ts.map +0 -1
  52. package/dist/color-C99gJSgH.js.map +0 -1
  53. package/dist/index-CG6dL9XZ.d.ts.map +0 -1
  54. package/dist/styleRegistry-BoviV8Ue.js.map +0 -1
  55. package/dist/styleRegistry-DNVNmafi.d.ts +0 -35
  56. package/dist/styleRegistry-DNVNmafi.d.ts.map +0 -1
  57. package/dist/styleVocabulary-Kl8p6TDk.js.map +0 -1
  58. package/dist/validate-C_h6gEXp.js.map +0 -1
  59. package/dist/validate-V28YRNxt.d.ts.map +0 -1
@@ -0,0 +1,148 @@
1
+
2
+ /*
3
+ * @license @wistia/kaleidoscope v0.0.6-beta.8a58a87a.88eb375
4
+ *
5
+ * Copyright (c) 2026, Wistia, Inc. and its affiliates.
6
+ *
7
+ * This source code is unlicensed, all rights reserved.
8
+ */
9
+
10
+ import { a as maxChroma, f as Color, h as clamp, m as rgbToOklch, n as buildBrandedColorScale, p as oklchToRgb, r as perceivedLightness, t as getColorLightnessClassification } from "./getColorLightnessClassification-BWOpTeg8.js";
11
+ // src/getBrandedColorScale.ts
12
+ /**
13
+ * Builds a color scale using the derived light/dark background colors based on the given primary color,
14
+ * with the primary color slotted into the scale wherever it fits based on lightness.
15
+ *
16
+ * It's important to include the primary color in the scale because the light/dark derived background colors
17
+ * do not have the same saturation as the primary color, and we want the scale to reflect the vibrancy
18
+ * of the primary color.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * getBrandedColorScale('#2949e5').map((color) => color.toHex());
23
+ * // ['#ebeefd', '#d4dbfa', '#bdc8f7', '#a5b5f4', '#8da2f1', '#748eef',
24
+ * // '#5b7aec', '#4263e8', '#2949e5', '#2539ba', '#213080', '#171f45']
25
+ * // ^ the primary, at its own lightness
26
+ * ```
27
+ */
28
+ const getBrandedColorScale = (primaryColor, { steps = 12 } = {}) => {
29
+ const scale = buildBrandedColorScale(new Color(primaryColor), { steps });
30
+ return Array.from({ length: steps }, (_, index) => scale.atStep(index));
31
+ };
32
+ // src/private/getAccentedBackgroundByLightness.ts
33
+ const STEP_SIZE_IN_LIGHTNESS = .86 / 11;
34
+ /**
35
+ * Move the background color by the given distance to generate an accented background color.
36
+ * This is used when no primary color has been provided, meaning the background color was not derived from the primary color.
37
+ * The size of the steps used by this utility should match the size of the steps used in the
38
+ * corresponding {@link getBackgroundAccentFromPrimaryColor} utility.
39
+ */
40
+ const getAccentedBackgroundByLightness = (backgroundColor, distanceInSteps) => {
41
+ const { chroma, hue, lightness } = rgbToOklch(backgroundColor.r, backgroundColor.g, backgroundColor.b);
42
+ const maxPossibleChroma = maxChroma(lightness, hue);
43
+ const share = chroma < 1e-4 || maxPossibleChroma < 1e-4 ? 0 : Math.min(1, chroma / maxPossibleChroma);
44
+ const atLightness = (candidate) => {
45
+ const [red, green, blue] = oklchToRgb({
46
+ chroma: share * maxChroma(candidate, hue),
47
+ hue,
48
+ lightness: candidate
49
+ });
50
+ return new Color([
51
+ red,
52
+ green,
53
+ blue,
54
+ backgroundColor.a
55
+ ]);
56
+ };
57
+ const band = getColorLightnessClassification(backgroundColor);
58
+ const towards = band === "dark" || band === "veryDark" ? 1 : -1;
59
+ const target = clamp(perceivedLightness(backgroundColor) + towards * distanceInSteps * STEP_SIZE_IN_LIGHTNESS, 0, 1);
60
+ let low = 0;
61
+ let high = 1;
62
+ for (let iteration = 0; iteration < 30; iteration += 1) {
63
+ const middle = (low + high) / 2;
64
+ if (perceivedLightness(atLightness(middle)) < target) low = middle;
65
+ else high = middle;
66
+ }
67
+ return atLightness((low + high) / 2);
68
+ };
69
+ // src/private/getBackgroundAccentFromPrimaryColor.ts
70
+ /**
71
+ * Using a branded color scale based on the primary color,
72
+ * move the given background color by the given distance along the scale
73
+ * to generate an accented version of the background color.
74
+ */
75
+ const getBackgroundAccentFromPrimaryColor = (backgroundColor, stepDistance, primaryColor) => {
76
+ const scale = buildBrandedColorScale(primaryColor);
77
+ const last = scale.steps - 1;
78
+ const colorLightnessClass = getColorLightnessClassification(backgroundColor);
79
+ const towards = colorLightnessClass === "dark" || colorLightnessClass === "veryDark" ? -stepDistance : stepDistance;
80
+ const from = clamp(Math.round(scale.stepOf(backgroundColor)), 0, last);
81
+ return scale.atStep(clamp(from + towards, 0, last));
82
+ };
83
+ // src/private/getAccentedBackground.ts
84
+ /**
85
+ * A background `distance` steps off `background`, always in the direction away from it:
86
+ * darker when the background is light, lighter when it is dark.
87
+ *
88
+ * Gets a an accented color spaced apart from the given background color by the given distance.
89
+ * If a primary color is included, we will derive the accent color using a color scale.
90
+ */
91
+ const getAccentedBackground = ({ backgroundColor, stepDistance, primaryColor }) => primaryColor === void 0 ? getAccentedBackgroundByLightness(backgroundColor, stepDistance) : getBackgroundAccentFromPrimaryColor(backgroundColor, stepDistance, primaryColor);
92
+ // src/getHeavyAccentedBackgroundColor.ts
93
+ /**
94
+ * Get an accented version of a background color that is a two steps lighter/darker.
95
+ * Use this when the color contrast of the accented background color is not significant,
96
+ * such as for card/panel background colors.
97
+ *
98
+ * Accepts an optional primary color, used when the background color has been derived from the primary color,
99
+ * and we want the accented versions of the background color to come from the color scale, see {@link getBrandedColorScale}
100
+
101
+ * See {@link getSlightAccentedBackgroundColor} for a single step away from the background color instead of two.
102
+
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * getHeavyAccentedBackgroundColor('#f5f5f5').toHex(); // '#cbcbcb'
107
+ * getHeavyAccentedBackgroundColor('#f5f5f5', { primaryColor: '#2949e5' }).toHex(); // '#adbbf5'
108
+ * ```
109
+ */
110
+ const getHeavyAccentedBackgroundColor = (_backgroundColor, { primaryColor } = {}) => {
111
+ const backgroundColor = new Color(_backgroundColor);
112
+ return getAccentedBackground({
113
+ backgroundColor,
114
+ stepDistance: 2,
115
+ primaryColor: primaryColor === void 0 ? void 0 : new Color(primaryColor)
116
+ });
117
+ };
118
+ // src/getSlightAccentedBackgroundColor.ts
119
+ const WHITE = "#ffffff";
120
+ /**
121
+ * Get an accented version of a background color that is a single step lighter/darker.
122
+ * Use this when the color contrast of the accented background color is not significant,
123
+ * such as for card/panel background colors.
124
+ *
125
+ * Accepts an optional primary color, used when the background color has been derived from the primary color,
126
+ * and we want the accented versions of the background color to come from the color scale, see {@link getBrandedColorScale}
127
+
128
+ * See {@link getHeavyAccentedBackgroundColor} for two steps away from the background color instead of one.
129
+ *
130
+ * @example
131
+ * ```ts
132
+ * getSlightAccentedBackgroundColor('#f5f5f5').toHex(); // '#e0e0e0'
133
+ * getSlightAccentedBackgroundColor('#f5f5f5', { primaryColor: '#2949e5' }).toHex(); // '#cdd5f9'
134
+ * getSlightAccentedBackgroundColor('#ffffff', { shouldReturnWhiteForWhiteBackground: true }).toHex(); // '#ffffff'
135
+ * ```
136
+ */
137
+ const getSlightAccentedBackgroundColor = (_backgroundColor, { shouldReturnWhiteForWhiteBackground = false, primaryColor } = {}) => {
138
+ const backgroundColor = new Color(_backgroundColor);
139
+ if (shouldReturnWhiteForWhiteBackground && backgroundColor.toHex() === WHITE) return backgroundColor;
140
+ return getAccentedBackground({
141
+ backgroundColor,
142
+ stepDistance: 1,
143
+ primaryColor: primaryColor === void 0 ? void 0 : new Color(primaryColor)
144
+ });
145
+ };
146
+ export { getHeavyAccentedBackgroundColor as n, getBrandedColorScale as r, getSlightAccentedBackgroundColor as t };
147
+
148
+ //# sourceMappingURL=color-Bvmf2YPw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color-Bvmf2YPw.js","names":[],"sources":["../src/getBrandedColorScale.ts","../src/private/getAccentedBackgroundByLightness.ts","../src/private/getBackgroundAccentFromPrimaryColor.ts","../src/private/getAccentedBackground.ts","../src/getHeavyAccentedBackgroundColor.ts","../src/getSlightAccentedBackgroundColor.ts"],"sourcesContent":["import type { ColorInput } from './types';\nimport { Color } from './Color';\nimport {\n buildBrandedColorScale,\n DEFAULT_COLOR_SCALE_STEPS,\n} from './private/buildBrandedColorScale';\n\nexport type BrandColorScaleOptions = {\n /** How many steps the scale is divided into. */\n readonly steps?: number;\n};\n\n/**\n * Builds a color scale using the derived light/dark background colors based on the given primary color,\n * with the primary color slotted into the scale wherever it fits based on lightness.\n *\n * It's important to include the primary color in the scale because the light/dark derived background colors\n * do not have the same saturation as the primary color, and we want the scale to reflect the vibrancy\n * of the primary color.\n *\n * @example\n * ```ts\n * getBrandedColorScale('#2949e5').map((color) => color.toHex());\n * // ['#ebeefd', '#d4dbfa', '#bdc8f7', '#a5b5f4', '#8da2f1', '#748eef',\n * // '#5b7aec', '#4263e8', '#2949e5', '#2539ba', '#213080', '#171f45']\n * // ^ the primary, at its own lightness\n * ```\n */\nexport const getBrandedColorScale = (\n primaryColor: ColorInput,\n { steps = DEFAULT_COLOR_SCALE_STEPS }: BrandColorScaleOptions = {},\n): Color[] => {\n const scale = buildBrandedColorScale(new Color(primaryColor), { steps });\n\n return Array.from({ length: steps }, (_, index) => scale.atStep(index));\n};\n","import type { getBackgroundAccentFromPrimaryColor } from './getBackgroundAccentFromPrimaryColor';\nimport { Color } from '../Color';\nimport { getColorLightnessClassification } from '../getColorLightnessClassification';\nimport { DEFAULT_COLOR_SCALE_STEPS } from './buildBrandedColorScale';\nimport { clamp } from './clamp';\nimport { oklchToRgb, rgbToOklch } from './colorSpace';\nimport { ACHROMATIC_CHROMA, maxChroma } from './maxChroma';\nimport { perceivedLightness } from './perceivedLightness';\n\n/**\n * Get the total distance between the lightest and darkest page background colors, measured in lightness.\n * This determines the actual step size we'll use, which correlates to the size of the step between colors\n * in a branded color scale.\n */\nconst MAX_BACKGROUND_LIGHTNESS = 0.95;\nconst MIN_BACKGROUND_LIGHTNESS = 0.09;\nconst STEP_SIZE_IN_LIGHTNESS =\n (MAX_BACKGROUND_LIGHTNESS - MIN_BACKGROUND_LIGHTNESS) / (DEFAULT_COLOR_SCALE_STEPS - 1);\n\n/**\n * Move the background color by the given distance to generate an accented background color.\n * This is used when no primary color has been provided, meaning the background color was not derived from the primary color.\n * The size of the steps used by this utility should match the size of the steps used in the\n * corresponding {@link getBackgroundAccentFromPrimaryColor} utility.\n */\nexport const getAccentedBackgroundByLightness = (\n backgroundColor: Color,\n distanceInSteps: number,\n): Color => {\n const { chroma, hue, lightness } = rgbToOklch(\n backgroundColor.r,\n backgroundColor.g,\n backgroundColor.b,\n );\n const maxPossibleChroma = maxChroma(lightness, hue);\n\n // If there is no perceptible chroma for this color or for the max possible chroma for this hue/lightness,\n // don't try to add any chroma into the result.\n const share =\n chroma < ACHROMATIC_CHROMA || maxPossibleChroma < ACHROMATIC_CHROMA\n ? 0\n : Math.min(1, chroma / maxPossibleChroma);\n\n const atLightness = (candidate: number): Color => {\n const [red, green, blue] = oklchToRgb({\n chroma: share * maxChroma(candidate, hue),\n hue,\n lightness: candidate,\n });\n\n return new Color([red, green, blue, backgroundColor.a]);\n };\n\n const band = getColorLightnessClassification(backgroundColor);\n const towards = band === 'dark' || band === 'veryDark' ? 1 : -1;\n const target = clamp(\n perceivedLightness(backgroundColor) + towards * distanceInSteps * STEP_SIZE_IN_LIGHTNESS,\n 0,\n 1,\n );\n\n let low = 0;\n let high = 1;\n for (let iteration = 0; iteration < 30; iteration += 1) {\n const middle = (low + high) / 2;\n if (perceivedLightness(atLightness(middle)) < target) {\n low = middle;\n } else {\n high = middle;\n }\n }\n\n return atLightness((low + high) / 2);\n};\n","import type { Color } from '../Color';\nimport { getColorLightnessClassification } from '../getColorLightnessClassification';\nimport { buildBrandedColorScale } from './buildBrandedColorScale';\nimport { clamp } from './clamp';\n\n/**\n * Using a branded color scale based on the primary color,\n * move the given background color by the given distance along the scale\n * to generate an accented version of the background color.\n */\nexport const getBackgroundAccentFromPrimaryColor = (\n backgroundColor: Color,\n stepDistance: number,\n primaryColor: Color,\n): Color => {\n const scale = buildBrandedColorScale(primaryColor);\n const last = scale.steps - 1;\n const colorLightnessClass = getColorLightnessClassification(backgroundColor);\n const towards =\n colorLightnessClass === 'dark' || colorLightnessClass === 'veryDark'\n ? -stepDistance\n : stepDistance;\n const from = clamp(Math.round(scale.stepOf(backgroundColor)), 0, last);\n\n return scale.atStep(clamp(from + towards, 0, last));\n};\n","import type { Color } from '../Color';\nimport { getAccentedBackgroundByLightness } from './getAccentedBackgroundByLightness';\nimport { getBackgroundAccentFromPrimaryColor } from './getBackgroundAccentFromPrimaryColor';\n\nexport type AccentedBackgroundOptions = {\n readonly backgroundColor: Color;\n readonly primaryColor?: Color | undefined;\n readonly stepDistance: number;\n};\n\n/**\n * A background `distance` steps off `background`, always in the direction away from it:\n * darker when the background is light, lighter when it is dark.\n *\n * Gets a an accented color spaced apart from the given background color by the given distance.\n * If a primary color is included, we will derive the accent color using a color scale.\n */\nexport const getAccentedBackground = ({\n backgroundColor,\n stepDistance,\n primaryColor,\n}: AccentedBackgroundOptions): Color =>\n primaryColor === undefined\n ? getAccentedBackgroundByLightness(backgroundColor, stepDistance)\n : getBackgroundAccentFromPrimaryColor(backgroundColor, stepDistance, primaryColor);\n","import type { getBrandedColorScale } from './getBrandedColorScale';\nimport type { getSlightAccentedBackgroundColor } from './getSlightAccentedBackgroundColor';\nimport type { ColorInput } from './types';\nimport { Color } from './Color';\nimport { getAccentedBackground } from './private/getAccentedBackground';\n\nexport type HeavyAccentedBackgroundColorOptions = {\n readonly primaryColor?: ColorInput;\n};\n\n/**\n * Get an accented version of a background color that is a two steps lighter/darker.\n * Use this when the color contrast of the accented background color is not significant,\n * such as for card/panel background colors.\n * \n * Accepts an optional primary color, used when the background color has been derived from the primary color,\n * and we want the accented versions of the background color to come from the color scale, see {@link getBrandedColorScale}\n\n * See {@link getSlightAccentedBackgroundColor} for a single step away from the background color instead of two.\n\n *\n * @example\n * ```ts\n * getHeavyAccentedBackgroundColor('#f5f5f5').toHex(); // '#cbcbcb'\n * getHeavyAccentedBackgroundColor('#f5f5f5', { primaryColor: '#2949e5' }).toHex(); // '#adbbf5'\n * ```\n */\nexport const getHeavyAccentedBackgroundColor = (\n _backgroundColor: ColorInput,\n { primaryColor }: HeavyAccentedBackgroundColorOptions = {},\n): Color => {\n const backgroundColor = new Color(_backgroundColor);\n\n return getAccentedBackground({\n backgroundColor,\n stepDistance: 2,\n primaryColor: primaryColor === undefined ? undefined : new Color(primaryColor),\n });\n};\n","import type { getBrandedColorScale } from './getBrandedColorScale';\nimport type { getHeavyAccentedBackgroundColor } from './getHeavyAccentedBackgroundColor';\nimport type { ColorInput } from './types';\nimport { Color } from './Color';\nimport { getAccentedBackground } from './private/getAccentedBackground';\n\nconst WHITE = '#ffffff';\n\nexport type SlightAccentedBackgroundColorOptions = {\n readonly shouldReturnWhiteForWhiteBackground?: boolean;\n /**\n * Optional primary color, which is used when the background color is derived from the primary color,\n * so we'll calculate the accented background color using a color scale.\n */\n readonly primaryColor?: ColorInput;\n};\n\n/**\n * Get an accented version of a background color that is a single step lighter/darker.\n * Use this when the color contrast of the accented background color is not significant,\n * such as for card/panel background colors.\n * \n * Accepts an optional primary color, used when the background color has been derived from the primary color,\n * and we want the accented versions of the background color to come from the color scale, see {@link getBrandedColorScale}\n\n * See {@link getHeavyAccentedBackgroundColor} for two steps away from the background color instead of one.\n *\n * @example\n * ```ts\n * getSlightAccentedBackgroundColor('#f5f5f5').toHex(); // '#e0e0e0'\n * getSlightAccentedBackgroundColor('#f5f5f5', { primaryColor: '#2949e5' }).toHex(); // '#cdd5f9'\n * getSlightAccentedBackgroundColor('#ffffff', { shouldReturnWhiteForWhiteBackground: true }).toHex(); // '#ffffff'\n * ```\n */\nexport const getSlightAccentedBackgroundColor = (\n _backgroundColor: ColorInput,\n {\n shouldReturnWhiteForWhiteBackground = false,\n primaryColor,\n }: SlightAccentedBackgroundColorOptions = {},\n): Color => {\n const backgroundColor = new Color(_backgroundColor);\n\n if (shouldReturnWhiteForWhiteBackground && backgroundColor.toHex() === WHITE) {\n return backgroundColor;\n }\n\n return getAccentedBackground({\n backgroundColor,\n stepDistance: 1,\n primaryColor: primaryColor === undefined ? undefined : new Color(primaryColor),\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,wBACX,cACA,EAAE,QAAA,OAA8D,CAAC,MACrD;CACZ,MAAM,QAAQ,uBAAuB,IAAI,MAAM,YAAY,GAAG,EAAE,MAAM,CAAC;CAEvE,OAAO,MAAM,KAAK,EAAE,QAAQ,MAAM,IAAI,GAAG,UAAU,MAAM,OAAO,KAAK,CAAC;AACxE;;ACnBA,MAAM,yBACH,MAAA;;;;;;;AAQH,MAAa,oCACX,iBACA,oBACU;CACV,MAAM,EAAE,QAAQ,KAAK,cAAc,WACjC,gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,CAClB;CACA,MAAM,oBAAoB,UAAU,WAAW,GAAG;CAIlD,MAAM,QACJ,SAAA,QAA8B,oBAAA,OAC1B,IACA,KAAK,IAAI,GAAG,SAAS,iBAAiB;CAE5C,MAAM,eAAe,cAA6B;EAChD,MAAM,CAAC,KAAK,OAAO,QAAQ,WAAW;GACpC,QAAQ,QAAQ,UAAU,WAAW,GAAG;GACxC;GACA,WAAW;EACb,CAAC;EAED,OAAO,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BACA,EACE,sCAAsC,OACtC,iBACwC,CAAC,MACjC;CACV,MAAM,kBAAkB,IAAI,MAAM,gBAAgB;CAElD,IAAI,uCAAuC,gBAAgB,MAAM,MAAM,OACrE,OAAO;CAGT,OAAO,sBAAsB;EAC3B;EACA,cAAc;EACd,cAAc,iBAAiB,KAAA,IAAY,KAAA,IAAY,IAAI,MAAM,YAAY;CAC/E,CAAC;AACH"}
@@ -1,5 +1,4 @@
1
1
 
2
- //#region src/colorContrastRatiosByShape.d.ts
3
2
  declare const colorContrastRatiosByShape: {
4
3
  readonly nonText: 3.0;
5
4
  readonly largeText: 3.0;
@@ -8,8 +7,6 @@ declare const colorContrastRatiosByShape: {
8
7
  };
9
8
  /** The kind of content a color has to be legible as, which sets the ratio it has to clear. */
10
9
  type ColorShape = keyof typeof colorContrastRatiosByShape;
11
- //#endregion
12
- //#region src/Color.d.ts
13
10
  /**
14
11
  * An immutable sRGB color with transformation methods like lighten, darken, tint, shade.
15
12
  * Also includes methods to calculate contrast ratio against another color, relative luminance, etc.
@@ -99,8 +96,6 @@ declare class Color {
99
96
  */
100
97
  withLightness(lightness: number): Color;
101
98
  }
102
- //#endregion
103
- //#region src/types.d.ts
104
99
  /** Red, green and blue channels, each in the 0–255 range. */
105
100
  type RgbTuple = [red: number, green: number, blue: number];
106
101
  /** Red, green and blue channels (0–255) plus an alpha channel (0–1). */
@@ -151,8 +146,6 @@ type Lab = {
151
146
  * - `rgb` — naive channel-wise RGB; fastest, and what CSS `color-mix()` does in sRGB
152
147
  */
153
148
  type InterpolationMode = "lab" | "lrgb" | "oklch" | "rgb";
154
- //#endregion
155
- //#region src/adjustColorForProperContrast.d.ts
156
149
  type AdjustColorForProperContrastOptions = {
157
150
  /** What the foreground sits on. Never adjusted. */
158
151
  readonly backgroundColor: ColorInput;
@@ -188,8 +181,6 @@ type AdjustColorForProperContrastOptions = {
188
181
  * ```
189
182
  */
190
183
  declare const adjustColorForProperContrast: ({ backgroundColor, foregroundColor, shape }: AdjustColorForProperContrastOptions) => Color;
191
- //#endregion
192
- //#region src/ColorScale.d.ts
193
184
  type ColorScaleOptions = {
194
185
  /**
195
186
  * Quantize the scale into bands instead of leaving it continuous: a count of equally sized
@@ -244,8 +235,6 @@ declare class ColorScale {
244
235
  correctLightness(correctLightness?: boolean): ColorScale;
245
236
  classes(classes: number | number[]): ColorScale;
246
237
  }
247
- //#endregion
248
- //#region src/getBestColorForText.d.ts
249
238
  type BestColorForTextOptions = {
250
239
  /** Always excluded from the result.*/
251
240
  readonly backgroundColor: ColorInput;
@@ -275,8 +264,6 @@ type BestColorForTextOptions = {
275
264
  * ```
276
265
  */
277
266
  declare const getBestColorForText: ({ backgroundColor, exclude, palette, shape }: BestColorForTextOptions) => Color;
278
- //#endregion
279
- //#region src/getBrandDarkBackgroundColor.d.ts
280
267
  /**
281
268
  * Generates a dark background color from a given primary color, preserving the hue of the primary color.
282
269
  *
@@ -288,8 +275,6 @@ declare const getBestColorForText: ({ backgroundColor, exclude, palette, shape }
288
275
  * @see {@link getBrandLightBackgroundColor} for the light counterpart
289
276
  */
290
277
  declare const getBrandDarkBackgroundColor: (_primaryColor: ColorInput) => Color;
291
- //#endregion
292
- //#region src/getBrandLightBackgroundColor.d.ts
293
278
  /**
294
279
  *
295
280
  * Generates a light background color from a given primary color, preserving the hue of the primary color.
@@ -302,8 +287,6 @@ declare const getBrandDarkBackgroundColor: (_primaryColor: ColorInput) => Color;
302
287
  * @see {@link getBrandDarkBackgroundColor} for the dark counterpart
303
288
  */
304
289
  declare const getBrandLightBackgroundColor: (_primaryColor: ColorInput) => Color;
305
- //#endregion
306
- //#region src/getBrandedColorScale.d.ts
307
290
  type BrandColorScaleOptions = {
308
291
  /** How many steps the scale is divided into. */
309
292
  readonly steps?: number;
@@ -325,8 +308,6 @@ type BrandColorScaleOptions = {
325
308
  * ```
326
309
  */
327
310
  declare const getBrandedColorScale: (primaryColor: ColorInput, { steps }?: BrandColorScaleOptions) => Color[];
328
- //#endregion
329
- //#region src/getColorLightnessClassification.d.ts
330
311
  type ColorLightnessClassification = "dark" | "light" | "midtone" | "veryDark";
331
312
  /**
332
313
  * Classify a color's lightness based on relative luminance.
@@ -340,8 +321,6 @@ type ColorLightnessClassification = "dark" | "light" | "midtone" | "veryDark";
340
321
  * ```
341
322
  */
342
323
  declare const getColorLightnessClassification: (color: ColorInput) => ColorLightnessClassification;
343
- //#endregion
344
- //#region src/getHeavyAccentedBackgroundColor.d.ts
345
324
  type HeavyAccentedBackgroundColorOptions = {
346
325
  readonly primaryColor?: ColorInput;
347
326
  };
@@ -352,7 +331,9 @@ type HeavyAccentedBackgroundColorOptions = {
352
331
  *
353
332
  * Accepts an optional primary color, used when the background color has been derived from the primary color,
354
333
  * and we want the accented versions of the background color to come from the color scale, see {@link getBrandedColorScale}
334
+
355
335
  * See {@link getSlightAccentedBackgroundColor} for a single step away from the background color instead of two.
336
+
356
337
  *
357
338
  * @example
358
339
  * ```ts
@@ -361,8 +342,6 @@ type HeavyAccentedBackgroundColorOptions = {
361
342
  * ```
362
343
  */
363
344
  declare const getHeavyAccentedBackgroundColor: (_backgroundColor: ColorInput, { primaryColor }?: HeavyAccentedBackgroundColorOptions) => Color;
364
- //#endregion
365
- //#region src/getSlightAccentedBackgroundColor.d.ts
366
345
  type SlightAccentedBackgroundColorOptions = {
367
346
  readonly shouldReturnWhiteForWhiteBackground?: boolean;
368
347
  /**
@@ -378,6 +357,7 @@ type SlightAccentedBackgroundColorOptions = {
378
357
  *
379
358
  * Accepts an optional primary color, used when the background color has been derived from the primary color,
380
359
  * and we want the accented versions of the background color to come from the color scale, see {@link getBrandedColorScale}
360
+
381
361
  * See {@link getHeavyAccentedBackgroundColor} for two steps away from the background color instead of one.
382
362
  *
383
363
  * @example
@@ -388,6 +368,5 @@ type SlightAccentedBackgroundColorOptions = {
388
368
  * ```
389
369
  */
390
370
  declare const getSlightAccentedBackgroundColor: (_backgroundColor: ColorInput, { shouldReturnWhiteForWhiteBackground, primaryColor }?: SlightAccentedBackgroundColorOptions) => Color;
391
- //#endregion
392
371
  export { RgbaObject as C, colorContrastRatiosByShape as D, ColorShape as E, RgbTuple as S, Color as T, ColorInput as _, ColorLightnessClassification as a, InterpolationMode as b, getBrandedColorScale as c, BestColorForTextOptions as d, getBestColorForText as f, adjustColorForProperContrast as g, AdjustColorForProperContrastOptions as h, getHeavyAccentedBackgroundColor as i, getBrandLightBackgroundColor as l, ColorScaleOptions as m, getSlightAccentedBackgroundColor as n, getColorLightnessClassification as o, ColorScale as p, HeavyAccentedBackgroundColorOptions as r, BrandColorScaleOptions as s, SlightAccentedBackgroundColorOptions as t, getBrandDarkBackgroundColor as u, ColorTuple as v, RgbaTuple as w, Lab as x, Hsl as y };
393
- //# sourceMappingURL=color-BD12TVX4.d.ts.map
372
+ //# sourceMappingURL=color-CwLKMi6Y.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color-CwLKMi6Y.d.ts","names":[],"sources":["../src/colorContrastRatiosByShape.ts","../src/Color.ts","../src/types.ts","../src/adjustColorForProperContrast.ts","../src/ColorScale.ts","../src/getBestColorForText.ts","../src/getBrandDarkBackgroundColor.ts","../src/getBrandLightBackgroundColor.ts","../src/getBrandedColorScale.ts","../src/getColorLightnessClassification.ts","../src/getHeavyAccentedBackgroundColor.ts","../src/getSlightAccentedBackgroundColor.ts"],"mappings":";A,cAAa;WACX;WACA;WACA;WACA;;;KAIU,0BAA0B;;;;;;;;;;;;cCyEzB;;;;;SAIJ,MAAM,OAAO,aAAa;SAK1B,QAAQ,KAAK,KAAK,iBAAY;SAK9B,QAAQ,KAAK,KAAK,iBAAY;;WAM5B;;WAGA;;WAGA;;WAGA;;;;;;EAOT,YAAY,OAAO;;EASnB;;EAKA;;EAKA;;EAKA;;EAKA,eAAe;EAIf,SAAS;EAIT,SAAS;;EAKT;;;;;EAQA;;;;;;;EAUA,SAAS,OAAO;;;;;;;;;;EAiBhB,QAAQ,gBAAgB;;EAKxB,OAAO,gBAAgB;;EAKvB,KAAK,e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AAgB,wCACjB;KCtBS;WACD;;;;;WAKA,eAAe;;;;;;;;;;;;;;;;;;;cAoBb,mCACX,kBAAkB,cAEhB,qCACA,iBACC,yCACF"}
@@ -0,0 +1,85 @@
1
+
2
+ import { n as StyleDocument } from "./index-BOJCY_MU.js";
3
+ /** The Brand Kit tokens a Style document can reference, each as `$<name>`. */
4
+ declare const BRAND_TOKEN_NAMES: readonly ["primaryColor", "pageBackgroundColor", "borderRadius", "headingFontFamily", "bodyFontFamily", "buttonFontFamily"];
5
+ type BrandTokenName = (typeof BRAND_TOKEN_NAMES)[number];
6
+ /**
7
+ * The Brand Kit values `getKaleidoscopeStyles()` resolves a Style against. Colors are CSS colors,
8
+ * `borderRadius` is in pixels, and the font families are CSS `font-family` values.
9
+ *
10
+ * Every token is optional: a token the Style references but the Brand Kit leaves out takes its
11
+ * {@link DEFAULT_BRAND_TOKENS | default}.
12
+ */
13
+ type BrandTokens = {
14
+ readonly bodyFontFamily?: string;
15
+ readonly borderRadius?: number;
16
+ readonly buttonFontFamily?: string;
17
+ readonly headingFontFamily?: string;
18
+ readonly pageBackgroundColor?: string;
19
+ readonly primaryColor?: string;
20
+ };
21
+ /** What a missing Brand Kit token falls back to: Wistia's own brand. */
22
+ declare const DEFAULT_BRAND_TOKENS: Required<BrandTokens>;
23
+ declare const VARIABLE_PREFIX = "--wistia-kaleidoscope-";
24
+ type VariableName = `${typeof VARIABLE_PREFIX}${string}`;
25
+ /** A `--wistia-kaleidoscope-*` custom property name. */
26
+ type KaleidoscopeVariableName = VariableName;
27
+ /**
28
+ * The record `getKaleidoscopeStyles()` returns: every variable and its value. The type
29
+ * only checks the `--wistia-kaleidoscope-` prefix, so a misspelled name still compiles. The names
30
+ * themselves are defined by {@link KALEIDOSCOPE_CONTRACT} and pinned by its contract test.
31
+ */
32
+ type KaleidoscopeVariables = Readonly<Record<KaleidoscopeVariableName, string>>;
33
+ /**
34
+ * Every variable the engine emits, with the value it takes when a Style doesn't use the rule
35
+ * behind it: the CSS initial value of the property it feeds, or the value that draws nothing.
36
+ * Every Style emits exactly these names, so embeds and hosted pages can rely on each one.
37
+ *
38
+ * Surface variables are `--wistia-kaleidoscope-<surface>-<slot>`. A surface that can sit on several
39
+ * parents is emitted once per parent, as `<surface>-on-<parent>`: `button-primary-on-panel`. Slots
40
+ * are named after the CSS property they feed — `background-color`, `border-radius`, `box-shadow` —
41
+ * with a `-hover` or `-focus` suffix for a state. There are two exceptions: `text-color`,
42
+ * `heading-text-color` and `low-emphasis-text-color` all feed `color`, and a panel's input slots
43
+ * carry an `input-` prefix, as in `input-background-color`.
44
+ *
45
+ * Typography variables are `--wistia-kaleidoscope-type-<role>-<property>`, for the `heading`,
46
+ * `body` and `button` roles.
47
+ */
48
+ declare const KALEIDOSCOPE_CONTRACT: KaleidoscopeVariables;
49
+ /**
50
+ * Resolves a Style against a Brand Kit into the `--wistia-kaleidoscope-*` variables that style an
51
+ * embed or hosted page. The record always holds every name in {@link KALEIDOSCOPE_CONTRACT}.
52
+ *
53
+ * A Brand Kit token the Style references but `brandTokens` leaves out takes its default from
54
+ * `DEFAULT_BRAND_TOKENS`.
55
+ *
56
+ * @throws when the Style uses a rule the engine cannot resolve yet, or references a token that is
57
+ * not a Brand Kit token.
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * const variables = getKaleidoscopeStyles(OPAQUE_MINIMAL, { primaryColor: '#5b4cf0' });
62
+ * variables['--wistia-kaleidoscope-button-primary-on-page-background-color']; // '#5b4cf0'
63
+ * ```
64
+ */
65
+ declare const getKaleidoscopeStyles: (style: StyleDocument, brandTokens?: BrandTokens) => KaleidoscopeVariables;
66
+ /**
67
+ * Writes the record from `getKaleidoscopeStyles()` as a CSS rule, for a server-rendered `<style>`
68
+ * or for injecting at runtime.
69
+ *
70
+ * Text that could leave its declaration, its rule or the `<style>` element is refused rather than
71
+ * escaped. The engine's own values never need it, so such text is a font family from a Brand Kit
72
+ * that should not reach the page, and an escaped version would no longer name a real font.
73
+ *
74
+ * @throws when `selector`, a variable name or a value is unsafe. Callers rendering customer Brand
75
+ * Kits should catch this and fall back.
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * serializeKaleidoscopeStyles(getKaleidoscopeStyles(OPAQUE_MINIMAL), '.my-scope');
80
+ * // '.my-scope {\n --wistia-kaleidoscope-page-background-color: #ffffff;\n …\n}'
81
+ * ```
82
+ */
83
+ declare const serializeKaleidoscopeStyles: (variables: KaleidoscopeVariables, selector: string) => string;
84
+ export { KaleidoscopeVariables as a, BrandTokenName as c, KaleidoscopeVariableName as i, BrandTokens as l, getKaleidoscopeStyles as n, VARIABLE_PREFIX as o, KALEIDOSCOPE_CONTRACT as r, BRAND_TOKEN_NAMES as s, serializeKaleidoscopeStyles as t, DEFAULT_BRAND_TOKENS as u };
85
+ //# sourceMappingURL=engine-B00ZVZ0d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine-B00ZVZ0d.d.ts","names":[],"sources":["../src/brandTokens.ts","../src/private/engine/slots.ts","../src/kaleidoscopeContract.ts","../src/getKaleidoscopeStyles.ts","../src/serializeKaleidoscopeStyles.ts"],"mappings":";;;cACa;KAQD,yBAAyB;;;;;;;;KASzB;WACD;WACA;WACA;WACA;WACA;WACA;;;cAIE,sBAAsB,SAAS;cCvB/B;KACD,yBAAyB;;KCAzB,2BAA2B;;;;;;KAO3B,wBAAwB,SAAS,OAAO;;;;;;;;;;;;;;;;cAiBvC,uBAAuB;;;;;;;;;;;;;;;;;cCAvB,wBACX,OAAO,eACP,cAAa,gBACZ;;;;;;;;;;;;;;;;;;cCgCU,8BACX,WAAW,uBACX"}