vizmatic 0.4.0 → 0.5.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.
Files changed (147) hide show
  1. package/PROMPT.md +75 -531
  2. package/README.md +85 -1052
  3. package/ROADMAP.md +49 -67
  4. package/SCIENCE.md +250 -0
  5. package/assets/THIRD_PARTY_LICENSES.md +40 -1
  6. package/assets/fonts/InstrumentSerif-Italic.ttf +0 -0
  7. package/assets/fonts/InstrumentSerif-Regular.ttf +0 -0
  8. package/assets/licenses/raster-codecs-MIT.txt +74 -0
  9. package/dist/chunk-3F2VQ7NW.js +1 -0
  10. package/dist/{chunk-FEIPTPBZ.js → chunk-4XE64I2U.js} +53 -463
  11. package/dist/chunk-JHHPLALU.js +79 -0
  12. package/dist/chunk-LTX44BAE.js +112 -0
  13. package/dist/chunk-MLKGABMK.js +9 -0
  14. package/dist/chunk-PSBF4TEK.js +1 -0
  15. package/dist/chunk-RPAHMKAR.js +605 -0
  16. package/dist/chunk-RWF4VBUL.js +3617 -0
  17. package/dist/chunk-WHT6HRMX.js +4201 -0
  18. package/dist/cli.js +369 -12
  19. package/dist/index.cjs +7413 -1810
  20. package/dist/index.d.cts +900 -599
  21. package/dist/index.d.ts +900 -599
  22. package/dist/index.js +5019 -3278
  23. package/dist/math-LXB4FH4E.js +7 -0
  24. package/dist/math-QVCETQDQ.js +1 -0
  25. package/dist/scene-browser-assets.d.ts +38 -0
  26. package/dist/scene-browser-assets.js +53 -0
  27. package/dist/scene-browser-chunks/chunk-5MVLYGXM.js +70 -0
  28. package/dist/scene-browser-chunks/chunk-ASXKN3NU.js +1 -0
  29. package/dist/scene-browser-chunks/chunk-CM5Y5LZP.js +1 -0
  30. package/dist/scene-browser-chunks/chunk-DP7NB4EW.js +6 -0
  31. package/dist/scene-browser-chunks/emscripten-module.browser-M5AEKJGE.js +1 -0
  32. package/dist/scene-browser-chunks/ffi-FL6ORJU3.js +1 -0
  33. package/dist/scene-browser-chunks/module-ES6BEMUI-JD5S5VKR.js +1 -0
  34. package/dist/scene-browser-chunks/module-asyncify-2EFITU5U-HWPFJFJC.js +1 -0
  35. package/dist/scene-browser-chunks/scene-browser-layout-M3XSXMV4.js +27 -0
  36. package/dist/scene-browser.d.ts +117 -0
  37. package/dist/scene-browser.js +220 -0
  38. package/dist/scene-cli.js +1 -1
  39. package/dist/scene-runtime.cjs +168 -103
  40. package/dist/scene-runtime.d.cts +3 -2
  41. package/dist/scene-runtime.d.ts +3 -2
  42. package/dist/scene-runtime.js +3 -1
  43. package/dist/server-2FYHZ4UO.js +331 -0
  44. package/dist/stage-browser/browser.d.ts +2482 -0
  45. package/dist/stage-browser/chunk-SQE76S5B.js +1 -0
  46. package/dist/stage-browser/chunk-VZNL6JY2.js +59 -0
  47. package/dist/stage-browser/dagre.esm-N2NIVIAZ.js +6 -0
  48. package/dist/stage-browser/math-4WFNHVV2.js +18 -0
  49. package/dist/stage-browser/stage.js +19 -0
  50. package/dist/stage-export.cjs +4950 -0
  51. package/dist/stage-export.d.cts +112 -0
  52. package/dist/stage-export.d.ts +112 -0
  53. package/dist/stage-export.js +544 -0
  54. package/dist/stage.cjs +9745 -0
  55. package/dist/stage.d.cts +1678 -0
  56. package/dist/stage.d.ts +1678 -0
  57. package/dist/stage.js +5404 -0
  58. package/dist/svg-import-Djj2q7Pc.d.cts +742 -0
  59. package/dist/svg-import-Djj2q7Pc.d.ts +742 -0
  60. package/dist/video-CcHW1qhV.d.cts +532 -0
  61. package/dist/video-CcHW1qhV.d.ts +532 -0
  62. package/examples/README.md +18 -0
  63. package/examples/agent-pipeline.tsx +4 -4
  64. package/examples/animated-pipeline.tsx +1 -5
  65. package/examples/attention-head.tsx +12 -12
  66. package/examples/aurora-incident.tsx +4 -3
  67. package/examples/building-blocks.tsx +8 -9
  68. package/examples/catalog-charts.tsx +4 -4
  69. package/examples/catalog-content.tsx +7 -9
  70. package/examples/catalog-convolution-kernel.tsx +116 -0
  71. package/examples/catalog-data.tsx +2 -8
  72. package/examples/catalog-dataflow.tsx +5 -9
  73. package/examples/catalog-dense.tsx +80 -0
  74. package/examples/catalog-deployment.tsx +5 -11
  75. package/examples/catalog-diagrams.tsx +13 -16
  76. package/examples/catalog-drawing.tsx +7 -7
  77. package/examples/catalog-flows.tsx +4 -4
  78. package/examples/catalog-foundations.tsx +11 -11
  79. package/examples/catalog-gaussian-blur.tsx +146 -0
  80. package/examples/catalog-image-tensors.tsx +115 -0
  81. package/examples/catalog-ml.tsx +36 -31
  82. package/examples/catalog-numeric-matrices.tsx +93 -0
  83. package/examples/catalog-photo-blur.tsx +209 -0
  84. package/examples/catalog-science-ai.tsx +130 -0
  85. package/examples/catalog-science-chemistry.tsx +103 -0
  86. package/examples/catalog-science-math.tsx +93 -0
  87. package/examples/catalog-science-physics.tsx +84 -0
  88. package/examples/catalog-sequence.tsx +59 -38
  89. package/examples/data-pipeline-lineage-presentation.tsx +5 -0
  90. package/examples/data-pipeline-lineage.tsx +85 -0
  91. package/examples/daybreak-launch.tsx +1 -0
  92. package/examples/desired-quadrant.tsx +7 -8
  93. package/examples/engineering-dashboard-presentation.tsx +13 -0
  94. package/examples/engineering-dashboard.tsx +160 -0
  95. package/examples/engineering-flow.tsx +2 -4
  96. package/examples/eval-dashboard.tsx +6 -6
  97. package/examples/films/attention.ts +278 -0
  98. package/examples/films/cache-miss.ts +431 -0
  99. package/examples/films/catalog.json +132 -0
  100. package/examples/films/central-limit.ts +269 -0
  101. package/examples/films/complex-maps.ts +273 -0
  102. package/examples/films/deck-example.ts +224 -0
  103. package/examples/films/euler-circle.ts +179 -0
  104. package/examples/films/fourier-epicycles.ts +265 -0
  105. package/examples/films/gradient-descent.ts +345 -0
  106. package/examples/films/linear-maps.ts +175 -0
  107. package/examples/films/lorenz.ts +207 -0
  108. package/examples/films/pythagoras.ts +185 -0
  109. package/examples/films/taylor-series.ts +159 -0
  110. package/examples/films/vizmatic-title.ts +117 -0
  111. package/examples/llm-serving-stack-presentation.tsx +5 -0
  112. package/examples/llm-serving-stack.tsx +94 -0
  113. package/examples/model-garden.tsx +1 -0
  114. package/examples/model-router.tsx +6 -6
  115. package/examples/nccl-all-gather.tsx +3 -3
  116. package/examples/nccl-all-reduce.tsx +3 -3
  117. package/examples/nccl-all-to-all.tsx +1 -1
  118. package/examples/nccl-broadcast.tsx +1 -1
  119. package/examples/nccl-reduce-scatter.tsx +5 -5
  120. package/examples/orthogonal-routing.tsx +4 -4
  121. package/examples/pareto-frontier.tsx +9 -10
  122. package/examples/presentation-frame.tsx +6 -6
  123. package/examples/production-system-map-presentation.tsx +5 -0
  124. package/examples/production-system-map.tsx +130 -0
  125. package/examples/rag-graph.tsx +7 -7
  126. package/examples/release-card.tsx +5 -5
  127. package/examples/spec-anatomy.tsx +5 -5
  128. package/examples/system-architecture.tsx +19 -32
  129. package/examples/theme-system.tsx +1 -1
  130. package/examples/token-matrix.tsx +4 -2
  131. package/examples/transparent-badge.tsx +1 -2
  132. package/examples/videos/README.md +36 -2
  133. package/examples/videos/calculus-tangent.tsx +101 -0
  134. package/examples/videos/catalyst-pathway.tsx +56 -0
  135. package/examples/videos/causal-attention.tsx +91 -0
  136. package/examples/videos/convolution-kernel.tsx +34 -0
  137. package/examples/videos/gaussian-blur.tsx +32 -0
  138. package/examples/videos/image-to-matrix.tsx +22 -0
  139. package/examples/videos/matrix-multiplication.tsx +128 -0
  140. package/examples/videos/photo-gaussian-blur.tsx +39 -0
  141. package/examples/videos/wave-interference.tsx +80 -0
  142. package/examples/vizmatic-bare.d.ts +1 -0
  143. package/examples/vizmatic-hero.tsx +9 -18
  144. package/examples/website-workflow.tsx +7 -7
  145. package/examples/weekend-field-notes.tsx +3 -2
  146. package/package.json +65 -11
  147. package/dist/chunk-TH3F4SDB.js +0 -79
@@ -0,0 +1,605 @@
1
+ // src/density.ts
2
+ var DENSITY_NAMES = ["dense", "compact", "comfortable", "presentation"];
3
+ var DEFAULT_DENSITY = "dense";
4
+ function half(value) {
5
+ return Math.round(value * 2) / 2;
6
+ }
7
+ function quarter(value) {
8
+ return Math.round(value * 4) / 4;
9
+ }
10
+ var curves = {
11
+ dense: {
12
+ // Small type holds its size for legibility. Large type compresses more,
13
+ // since big headlines are what make a figure read as a slide.
14
+ f: (size) => Math.max(9, half(size <= 14 ? size * 0.9 : 12.6 + (size - 14) * 0.75)),
15
+ s: (size) => quarter(size * 0.6),
16
+ w: (width) => Math.max(0.75, quarter(width * 0.6)),
17
+ r: (radius) => Math.min(5, half(radius * 0.5)),
18
+ g: (size) => quarter(size * 0.8),
19
+ arrow: 5.5,
20
+ scale: 0.86
21
+ },
22
+ compact: {
23
+ f: (size) => Math.max(9.5, half(size <= 14 ? size * 0.95 : 13.3 + (size - 14) * 0.88)),
24
+ s: (size) => quarter(size * 0.8),
25
+ w: (width) => Math.max(0.9, quarter(width * 0.75)),
26
+ r: (radius) => Math.min(7, half(radius * 0.7)),
27
+ g: (size) => quarter(size * 0.9),
28
+ arrow: 5.5,
29
+ scale: 0.93
30
+ },
31
+ comfortable: {
32
+ f: (size) => size,
33
+ s: (size) => size,
34
+ w: (width) => width,
35
+ r: (radius) => Math.min(10, radius),
36
+ g: (size) => size,
37
+ arrow: 5,
38
+ scale: 1
39
+ },
40
+ presentation: {
41
+ f: (size) => half(size * 1.5),
42
+ s: (size) => quarter(size * 1.4),
43
+ w: (width) => quarter(width * 1.4),
44
+ r: (radius) => half(radius * 1.2),
45
+ g: (size) => quarter(size * 1.5),
46
+ arrow: 4.5,
47
+ scale: 1.5
48
+ }
49
+ };
50
+ function numericCurve(scale) {
51
+ return {
52
+ f: (size) => Math.max(8, half(size * scale)),
53
+ s: (size) => quarter(size * Math.pow(scale, 1.2)),
54
+ w: (width) => Math.max(0.6, quarter(width * scale)),
55
+ r: (radius) => half(radius * scale),
56
+ g: (size) => quarter(size * scale),
57
+ arrow: 5,
58
+ scale
59
+ };
60
+ }
61
+ function buildTokens(name, curve) {
62
+ const { f, s, w, r, g } = curve;
63
+ return {
64
+ name,
65
+ scale: curve.scale,
66
+ type: { micro: f(10), small: f(11), body: f(13), label: f(14), heading: f(16), subtitle: f(20), title: f(28), metric: f(24) },
67
+ space: { hair: s(2), xs: s(4), sm: s(8), md: s(12), lg: s(16), xl: s(24), canvas: s(40) },
68
+ stroke: { hair: w(1), line: w(1.5), strong: w(2), heavy: w(3) },
69
+ radius: { sm: r(4), md: r(8), lg: r(12) },
70
+ arrow: curve.arrow,
71
+ f,
72
+ s,
73
+ w,
74
+ r,
75
+ g
76
+ };
77
+ }
78
+ var tokenCache = /* @__PURE__ */ new Map();
79
+ function assertDensity(density) {
80
+ if (typeof density === "number" ? !Number.isFinite(density) || density <= 0 : !DENSITY_NAMES.includes(density)) {
81
+ throw new Error(`Unknown density ${JSON.stringify(density)}. Use ${DENSITY_NAMES.join(", ")}, or a positive number.`);
82
+ }
83
+ }
84
+ function parseDensity(value) {
85
+ const parsed = typeof value === "string" && value.trim() !== "" && !Number.isNaN(Number(value)) ? Number(value) : value;
86
+ assertDensity(parsed);
87
+ return parsed;
88
+ }
89
+ function densityTokens(density = DEFAULT_DENSITY) {
90
+ const cached = tokenCache.get(density);
91
+ if (cached) return cached;
92
+ assertDensity(density);
93
+ const tokens = typeof density === "number" ? buildTokens("custom", numericCurve(density)) : buildTokens(density, curves[density]);
94
+ tokenCache.set(density, tokens);
95
+ return tokens;
96
+ }
97
+ var sharedKey = /* @__PURE__ */ Symbol.for("vizmatic.density");
98
+ var globals = globalThis;
99
+ var shared = globals[sharedKey] ??= { resolvers: /* @__PURE__ */ new Set() };
100
+ function setDefaultDensity(density) {
101
+ if (density !== void 0) assertDensity(density);
102
+ shared.ambient = density;
103
+ }
104
+ function setDensityResolver(resolver) {
105
+ shared.resolvers.add(resolver);
106
+ }
107
+ function currentRenderDensity() {
108
+ for (const resolver of shared.resolvers) {
109
+ const density = resolver();
110
+ if (density !== void 0) return density;
111
+ }
112
+ return void 0;
113
+ }
114
+ function densityOf(c) {
115
+ return densityTokens(c?.density ?? currentRenderDensity() ?? shared.ambient ?? DEFAULT_DENSITY);
116
+ }
117
+ function withDensity(c, density) {
118
+ assertDensity(density);
119
+ return { ...c, density };
120
+ }
121
+
122
+ // src/theme.ts
123
+ import parseCssColor from "parse-css-color";
124
+ var darkColors = {
125
+ // Canvas backgrounds
126
+ bg: "#0b0c10",
127
+ bgCard: "#13151a",
128
+ bgCardAlt: "#191c22",
129
+ bgHover: "#21252c",
130
+ bgSubtle: "#0f1014",
131
+ // The single accent. Everything else is semantic.
132
+ primary: "#2f8fc4",
133
+ primaryLight: "#5cc4f0",
134
+ primaryDark: "#1f6f9e",
135
+ secondary: "#2f8fc4",
136
+ // Blue: supporting elements
137
+ secondaryLight: "#5cc4f0",
138
+ secondaryDark: "#1f6f9e",
139
+ positive: "#4f9e4a",
140
+ // Green: output and success
141
+ positiveLight: "#8fe08a",
142
+ positiveDark: "#3a7a36",
143
+ warning: "#b98a2e",
144
+ // Gold: warnings
145
+ warningLight: "#f2b84b",
146
+ warningDark: "#8a6620",
147
+ critical: "#c94a4a",
148
+ // Red: errors and bottlenecks
149
+ criticalLight: "#ff6b6b",
150
+ criticalDark: "#9c3535",
151
+ info: "#2fa394",
152
+ // Teal: informational
153
+ infoLight: "#4fd8c4",
154
+ infoDark: "#237d72",
155
+ accent: "#c7618f",
156
+ // Pink: rare highlights
157
+ accentLight: "#ff8fc0",
158
+ violet: "#7f6bd0",
159
+ // Violet: categorical use only
160
+ violetLight: "#b49cff",
161
+ violetDark: "#5f4cab",
162
+ neutral: "#363a43",
163
+ // Infrastructure and background
164
+ neutralLight: "#4a4f5a",
165
+ neutralDark: "#22252c",
166
+ // Text
167
+ textPrimary: "#f2efe6",
168
+ textSecondary: "#a5a7ad",
169
+ textMuted: "#95989f",
170
+ textOnColor: "#ffffff",
171
+ // Borders
172
+ border: "#2c3038",
173
+ borderSubtle: "#1f2228",
174
+ borderLight: "#3d424c",
175
+ shadow: "rgba(0, 0, 0, 0)"
176
+ };
177
+ var lightColors = {
178
+ // Canvas backgrounds
179
+ bg: "#f7f3ea",
180
+ bgCard: "#fbf8f1",
181
+ bgCardAlt: "#efe9db",
182
+ bgHover: "#e7e0cf",
183
+ bgSubtle: "#f2ede1",
184
+ primary: "#1f6fb2",
185
+ primaryLight: "#1f6fb2",
186
+ primaryDark: "#165689",
187
+ secondary: "#1f6fb2",
188
+ secondaryLight: "#1f6fb2",
189
+ secondaryDark: "#165689",
190
+ positive: "#3f8a35",
191
+ positiveLight: "#357a2c",
192
+ positiveDark: "#2c6524",
193
+ warning: "#a8740a",
194
+ warningLight: "#8a5f07",
195
+ warningDark: "#7a5406",
196
+ critical: "#c62f2f",
197
+ criticalLight: "#b92a2a",
198
+ criticalDark: "#962222",
199
+ info: "#0b7d70",
200
+ infoLight: "#0b7468",
201
+ infoDark: "#095e55",
202
+ accent: "#c2387e",
203
+ accentLight: "#b03271",
204
+ violet: "#6a4bc4",
205
+ violetLight: "#6246b6",
206
+ violetDark: "#4f3896",
207
+ neutral: "#cdc5b3",
208
+ neutralLight: "#a29c8d",
209
+ neutralDark: "#e2dbca",
210
+ // Text
211
+ textPrimary: "#1d1b16",
212
+ textSecondary: "#5e5a50",
213
+ textMuted: "#696459",
214
+ textOnColor: "#ffffff",
215
+ // Borders
216
+ border: "#d9d2c1",
217
+ borderSubtle: "#e6dfd0",
218
+ borderLight: "#c4bba6",
219
+ shadow: "rgba(0, 0, 0, 0)"
220
+ };
221
+ var defaultStyleTokens = {
222
+ preset: "default",
223
+ fontSans: "Inter",
224
+ fontMono: "JetBrains Mono",
225
+ fontSerif: "Instrument Serif"
226
+ };
227
+ var engineeringColors = {
228
+ ...lightColors,
229
+ bg: "#f4f4f5",
230
+ bgCard: "#ffffff",
231
+ bgCardAlt: "#ececee",
232
+ bgHover: "#e4e4e7",
233
+ bgSubtle: "#eeeeef",
234
+ primary: "#632ca6",
235
+ primaryLight: "#6d28d9",
236
+ primaryDark: "#4c1d95",
237
+ violet: "#632ca6",
238
+ violetLight: "#6d28d9",
239
+ violetDark: "#4c1d95",
240
+ secondary: "#124fc7",
241
+ secondaryLight: "#1556d1",
242
+ secondaryDark: "#123d96",
243
+ positive: "#087a55",
244
+ positiveLight: "#0a8060",
245
+ positiveDark: "#05543c",
246
+ warning: "#c96c00",
247
+ warningLight: "#d97800",
248
+ warningDark: "#9a4f00",
249
+ critical: "#b83232",
250
+ criticalLight: "#c43d3d",
251
+ criticalDark: "#8f2626",
252
+ info: "#0b7185",
253
+ infoLight: "#0d7d92",
254
+ infoDark: "#075565",
255
+ accent: "#a83c76",
256
+ accentLight: "#b74583",
257
+ neutral: "#52525b",
258
+ neutralLight: "#71717a",
259
+ neutralDark: "#3f3f46",
260
+ textPrimary: "#101012",
261
+ textSecondary: "#3f3f46",
262
+ textMuted: "#68686f",
263
+ textOnColor: "#ffffff",
264
+ border: "#3f3f46",
265
+ borderSubtle: "#d4d4d8",
266
+ borderLight: "#a1a1aa",
267
+ shadow: "rgba(0, 0, 0, 0)"
268
+ };
269
+ function getThemeColors(mode, preset = "default", options = {}) {
270
+ const colors2 = preset === "engineering" ? { ...engineeringColors, preset, fontSans: "Inter", fontMono: "JetBrains Mono", fontSerif: "Instrument Serif" } : { ...mode === "light" ? lightColors : darkColors, ...defaultStyleTokens };
271
+ return options.density !== void 0 ? withDensity(colors2, options.density) : colors2;
272
+ }
273
+ var colors = {
274
+ ...darkColors,
275
+ ...defaultStyleTokens
276
+ };
277
+ var flat = (color) => `linear-gradient(135deg, ${color}, ${color})`;
278
+ var gradients = {
279
+ purple: flat("#5f4cab"),
280
+ blue: flat("#1f6f9e"),
281
+ green: flat("#2f7a3a"),
282
+ warm: flat("#8a6620"),
283
+ cyan: flat("#1d7a6e"),
284
+ pink: flat("#a04672"),
285
+ sunset: flat("#9c5526"),
286
+ ocean: flat("#1d5f86"),
287
+ dark: flat("#22252c")
288
+ };
289
+ var toneGradients = {
290
+ blue: gradients.blue,
291
+ purple: gradients.purple,
292
+ green: gradients.green,
293
+ warm: gradients.warm,
294
+ cyan: gradients.cyan,
295
+ pink: gradients.pink,
296
+ red: gradients.warm,
297
+ critical: gradients.warm,
298
+ neutral: gradients.dark,
299
+ sunset: gradients.sunset,
300
+ ocean: gradients.ocean,
301
+ dark: gradients.dark
302
+ };
303
+ function getToneGradient(tone) {
304
+ return toneGradients[tone];
305
+ }
306
+ function getToneColor(tone, c) {
307
+ return {
308
+ blue: c.secondaryLight,
309
+ purple: c.violetLight,
310
+ green: c.positiveLight,
311
+ warm: c.warningLight,
312
+ cyan: c.infoLight,
313
+ pink: c.accentLight,
314
+ red: c.criticalLight,
315
+ critical: c.criticalLight,
316
+ neutral: c.textSecondary,
317
+ sunset: c.warningLight,
318
+ ocean: c.infoLight,
319
+ dark: c.textSecondary
320
+ }[tone];
321
+ }
322
+ function getReadableToneColor(tone, c, background = c.bgCard, backdrop = c.bgCard) {
323
+ const semanticColor = {
324
+ blue: "secondary",
325
+ purple: "violet",
326
+ green: "positive",
327
+ warm: "warning",
328
+ cyan: "info",
329
+ pink: "accent",
330
+ red: "critical",
331
+ critical: "critical",
332
+ neutral: "neutral",
333
+ sunset: "warning",
334
+ ocean: "info",
335
+ dark: "neutral"
336
+ };
337
+ const color = getReadableColor(semanticColor[tone], c);
338
+ return colorContrast(color, background, backdrop) >= 4.5 ? color : getReadableTextColor(background, c, backdrop);
339
+ }
340
+ function getToneFill(tone, c) {
341
+ if (c.preset !== "engineering") return withColorAlpha(getToneColor(tone, c), 22 / 255);
342
+ return {
343
+ blue: "#cddcfa",
344
+ purple: "#dfcff8",
345
+ green: "#d5ede4",
346
+ warm: "#fde7ce",
347
+ cyan: "#d7edf1",
348
+ pink: "#f3d9e7",
349
+ red: "#f4d7d7",
350
+ critical: "#f4d7d7",
351
+ neutral: "#e4e4e7",
352
+ sunset: "#fde1d6",
353
+ ocean: "#d8e2f6",
354
+ dark: "#dedee2"
355
+ }[tone];
356
+ }
357
+ var typography = {
358
+ title: { fontSize: 28, fontWeight: 700, fontFamily: "Inter" },
359
+ subtitle: { fontSize: 20, fontWeight: 600, fontFamily: "Inter" },
360
+ label: { fontSize: 16, fontWeight: 600, fontFamily: "Inter" },
361
+ body: { fontSize: 14, fontWeight: 400, fontFamily: "Inter" },
362
+ small: { fontSize: 12, fontWeight: 500, fontFamily: "Inter" },
363
+ tiny: { fontSize: 11, fontWeight: 500, fontFamily: "Inter" },
364
+ code: { fontSize: 13, fontWeight: 400, fontFamily: "JetBrains Mono" },
365
+ annotation: { fontSize: 12, fontWeight: 500, fontFamily: "Inter", fontStyle: "italic" }
366
+ };
367
+ function hasShadow(c) {
368
+ const parsed = parseCssColor(c.shadow);
369
+ return !!parsed && parsed.alpha > 0;
370
+ }
371
+ function typeOf(c, variant) {
372
+ const base = typography[variant];
373
+ return {
374
+ ...base,
375
+ fontSize: densityOf(c).f(base.fontSize),
376
+ // Bold headings at small sizes read as shouting, so they settle at semibold.
377
+ fontWeight: Math.min(base.fontWeight, 600)
378
+ };
379
+ }
380
+ var canvas = {
381
+ standard: { width: 800, height: 500 },
382
+ wide: { width: 1e3, height: 400 },
383
+ square: { width: 600, height: 600 },
384
+ tall: { width: 600, height: 800 }
385
+ };
386
+ function getStyles(c) {
387
+ return {
388
+ canvas: {
389
+ width: "100%",
390
+ height: "100%",
391
+ display: "flex",
392
+ flexDirection: "column",
393
+ backgroundColor: c.bg,
394
+ fontFamily: c.fontSans,
395
+ padding: 40
396
+ },
397
+ card: {
398
+ display: "flex",
399
+ flexDirection: "column",
400
+ backgroundColor: c.bgCard,
401
+ borderRadius: 8,
402
+ border: `1px solid ${c.borderSubtle}`,
403
+ padding: 20
404
+ },
405
+ pill: {
406
+ display: "flex",
407
+ alignItems: "center",
408
+ justifyContent: "center",
409
+ borderRadius: 999,
410
+ padding: "6px 16px",
411
+ fontSize: 13,
412
+ fontWeight: 600,
413
+ fontFamily: "Inter"
414
+ }
415
+ };
416
+ }
417
+ var styles = {
418
+ canvas: {
419
+ width: "100%",
420
+ height: "100%",
421
+ display: "flex",
422
+ flexDirection: "column",
423
+ backgroundColor: colors.bg,
424
+ fontFamily: "Inter",
425
+ padding: 40
426
+ },
427
+ card: {
428
+ display: "flex",
429
+ flexDirection: "column",
430
+ backgroundColor: colors.bgCard,
431
+ borderRadius: 8,
432
+ border: `1px solid ${colors.borderSubtle}`,
433
+ padding: 20
434
+ },
435
+ pill: {
436
+ display: "flex",
437
+ alignItems: "center",
438
+ justifyContent: "center",
439
+ borderRadius: 999,
440
+ padding: "6px 16px",
441
+ fontSize: 13,
442
+ fontWeight: 600,
443
+ fontFamily: "Inter"
444
+ }
445
+ };
446
+ function getColor(name, c) {
447
+ if (c) return c[name];
448
+ return colors[name];
449
+ }
450
+ function getReadableColor(name, c) {
451
+ const variants = {
452
+ primary: [c.primaryLight, c.primary, c.primaryDark],
453
+ secondary: [c.secondaryLight, c.secondary, c.secondaryDark],
454
+ positive: [c.positiveLight, c.positive, c.positiveDark],
455
+ warning: [c.warningLight, c.warning, c.warningDark],
456
+ critical: [c.criticalLight, c.critical, c.criticalDark],
457
+ info: [c.infoLight, c.info, c.infoDark],
458
+ accent: [c.accentLight, c.accent, "#be185d"],
459
+ violet: [c.violetLight, c.violet, c.violetDark],
460
+ neutral: [c.textSecondary, c.neutralLight, c.neutral, c.neutralDark]
461
+ };
462
+ return variants[name].reduce((best, candidate) => colorContrast(candidate, c.bgCard) > colorContrast(best, c.bgCard) ? candidate : best);
463
+ }
464
+ function parseColor(color) {
465
+ const parsed = parseCssColor(color);
466
+ if (!parsed || parsed.values.length < 3) return void 0;
467
+ if (parsed.type !== "hsl") {
468
+ return {
469
+ channels: [parsed.values[0] ?? 0, parsed.values[1] ?? 0, parsed.values[2] ?? 0],
470
+ alpha: parsed.alpha
471
+ };
472
+ }
473
+ const hue = ((parsed.values[0] ?? 0) % 360 + 360) % 360;
474
+ const saturation = (parsed.values[1] ?? 0) / 100;
475
+ const lightness = (parsed.values[2] ?? 0) / 100;
476
+ const chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
477
+ const segment = hue / 60;
478
+ const intermediate = chroma * (1 - Math.abs(segment % 2 - 1));
479
+ let channels;
480
+ if (segment < 1) channels = [chroma, intermediate, 0];
481
+ else if (segment < 2) channels = [intermediate, chroma, 0];
482
+ else if (segment < 3) channels = [0, chroma, intermediate];
483
+ else if (segment < 4) channels = [0, intermediate, chroma];
484
+ else if (segment < 5) channels = [intermediate, 0, chroma];
485
+ else channels = [chroma, 0, intermediate];
486
+ const offset = lightness - chroma / 2;
487
+ return {
488
+ channels: channels.map((channel) => Math.round((channel + offset) * 255)),
489
+ alpha: parsed.alpha
490
+ };
491
+ }
492
+ function withColorAlpha(color, opacity) {
493
+ if (typeof color !== "string" || !Number.isFinite(opacity)) return "transparent";
494
+ const parsed = parseColor(color);
495
+ if (!parsed) return "transparent";
496
+ const alpha = Math.min(1, Math.max(0, parsed.alpha * Math.min(1, Math.max(0, opacity))));
497
+ const hex = color.trim();
498
+ if (/^#[\da-f]{6}$/i.test(hex)) {
499
+ return `${hex}${Math.round(alpha * 255).toString(16).padStart(2, "0")}`;
500
+ }
501
+ return `rgba(${parsed.channels.join(", ")}, ${Number(alpha.toFixed(6))})`;
502
+ }
503
+ function colorLuminance(color, backdrop) {
504
+ const parsed = parseColor(color);
505
+ if (!parsed) return void 0;
506
+ let channels = parsed.channels;
507
+ if (parsed.alpha < 1) {
508
+ const backdropColor = backdrop ? parseColor(backdrop) : void 0;
509
+ if (!backdropColor) return void 0;
510
+ channels = channels.map((channel, index) => Math.round(
511
+ channel * parsed.alpha + backdropColor.channels[index] * (1 - parsed.alpha)
512
+ ));
513
+ }
514
+ const [r, g, b] = channels.map((channel) => {
515
+ const normalized = channel / 255;
516
+ return normalized <= 0.04045 ? normalized / 12.92 : ((normalized + 0.055) / 1.055) ** 2.4;
517
+ });
518
+ return 0.2126 * r + 0.7152 * g + 0.0722 * b;
519
+ }
520
+ function compositeColor(foreground, background) {
521
+ const front = parseColor(foreground), back = parseColor(background);
522
+ if (!front || !back) throw new Error("Color compositing requires valid CSS colors");
523
+ const alpha = front.alpha + back.alpha * (1 - front.alpha);
524
+ if (alpha === 0) return "transparent";
525
+ const channels = front.channels.map((value, index) => Math.round(
526
+ (value * front.alpha + back.channels[index] * back.alpha * (1 - front.alpha)) / alpha
527
+ ));
528
+ return alpha === 1 ? `rgb(${channels.join(", ")})` : `rgba(${channels.join(", ")}, ${Number(alpha.toFixed(6))})`;
529
+ }
530
+ function colorContrast(left, right, rightBackdrop) {
531
+ const leftLuminance = colorLuminance(left);
532
+ const rightLuminance = colorLuminance(right, rightBackdrop);
533
+ if (leftLuminance == null || rightLuminance == null) return 0;
534
+ return (Math.max(leftLuminance, rightLuminance) + 0.05) / (Math.min(leftLuminance, rightLuminance) + 0.05);
535
+ }
536
+ function getReadableTextColor(background, c, backdrop = c.bgCard) {
537
+ if (colorLuminance(background, backdrop) == null) return c.textPrimary;
538
+ const candidates = [c.textPrimary, c.textOnColor, c.bg, "#000000"];
539
+ const readable = candidates.find((candidate) => colorContrast(candidate, background, backdrop) >= 4.5);
540
+ if (readable) return readable;
541
+ return candidates.reduce((best, candidate) => colorContrast(candidate, background, backdrop) > colorContrast(best, background, backdrop) ? candidate : best);
542
+ }
543
+ function getGradient(name) {
544
+ const map = {
545
+ primary: gradients.blue,
546
+ violet: gradients.purple,
547
+ secondary: gradients.blue,
548
+ positive: gradients.green,
549
+ warning: gradients.warm,
550
+ critical: gradients.warm,
551
+ info: gradients.cyan,
552
+ accent: gradients.pink,
553
+ neutral: gradients.dark
554
+ };
555
+ return map[name];
556
+ }
557
+ function heatColor(value) {
558
+ const v = Math.max(0, Math.min(1, value));
559
+ if (v < 0.5) return lerpColor("#1b2430", "#1f6f9e", v / 0.5);
560
+ if (v < 0.8) return lerpColor("#1f6f9e", "#c89a3c", (v - 0.5) / 0.3);
561
+ return lerpColor("#c89a3c", "#d9573f", (v - 0.8) / 0.2);
562
+ }
563
+ function lerpColor(a, b, t) {
564
+ const ah = parseInt(a.slice(1), 16);
565
+ const bh = parseInt(b.slice(1), 16);
566
+ const ar = ah >> 16 & 255, ag = ah >> 8 & 255, ab = ah & 255;
567
+ const br = bh >> 16 & 255, bg = bh >> 8 & 255, bb = bh & 255;
568
+ const rr = Math.round(ar + (br - ar) * t);
569
+ const rg = Math.round(ag + (bg - ag) * t);
570
+ const rb = Math.round(ab + (bb - ab) * t);
571
+ return `#${(rr << 16 | rg << 8 | rb).toString(16).padStart(6, "0")}`;
572
+ }
573
+
574
+ export {
575
+ DENSITY_NAMES,
576
+ DEFAULT_DENSITY,
577
+ assertDensity,
578
+ parseDensity,
579
+ densityTokens,
580
+ setDefaultDensity,
581
+ setDensityResolver,
582
+ densityOf,
583
+ withDensity,
584
+ getThemeColors,
585
+ colors,
586
+ gradients,
587
+ toneGradients,
588
+ getToneGradient,
589
+ getToneColor,
590
+ getReadableToneColor,
591
+ getToneFill,
592
+ typography,
593
+ hasShadow,
594
+ typeOf,
595
+ canvas,
596
+ getStyles,
597
+ styles,
598
+ getColor,
599
+ getReadableColor,
600
+ withColorAlpha,
601
+ compositeColor,
602
+ getReadableTextColor,
603
+ getGradient,
604
+ heatColor
605
+ };