@wistia/kaleidoscope 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/{color-BuPhQjcd.js → color-BwvIDNP5.js} +3 -3
  3. package/dist/{color-BuPhQjcd.js.map → color-BwvIDNP5.js.map} +1 -1
  4. package/dist/{engine-CcU0Q8Jg.d.ts → engine-DI3tsQ5q.d.ts} +2 -2
  5. package/dist/{engine-CcU0Q8Jg.d.ts.map → engine-DI3tsQ5q.d.ts.map} +1 -1
  6. package/dist/{engine-6ocr431e.js → engine-DY848hAQ.js} +703 -428
  7. package/dist/engine-DY848hAQ.js.map +1 -0
  8. package/dist/entries/color.js +3 -3
  9. package/dist/entries/engine.d.ts +1 -1
  10. package/dist/entries/engine.js +2 -2
  11. package/dist/entries/styleRegistry.d.ts +1 -1
  12. package/dist/entries/styleRegistry.js +2 -2
  13. package/dist/entries/validate.d.ts +1 -1
  14. package/dist/entries/validate.js +2 -2
  15. package/dist/entries/vocabulary.d.ts +2 -2
  16. package/dist/entries/vocabulary.js +3 -3
  17. package/dist/{getColorLightnessClassification-Dgr8qirZ.js → getColorLightnessClassification-BkZcKrdi.js} +3 -3
  18. package/dist/getColorLightnessClassification-BkZcKrdi.js.map +1 -0
  19. package/dist/{guards-BPewjm9T.js → guards-Cyl-NUQX.js} +2 -2
  20. package/dist/{guards-BPewjm9T.js.map → guards-Cyl-NUQX.js.map} +1 -1
  21. package/dist/{index-BTumAeju.d.ts → index-L5x6rNF_.d.ts} +13 -9
  22. package/dist/{index-BTumAeju.d.ts.map → index-L5x6rNF_.d.ts.map} +1 -1
  23. package/dist/index.d.ts +5 -5
  24. package/dist/index.js +8 -8
  25. package/dist/{styleRegistry-BqGmp-3z.js → styleRegistry-BQVgtgLT.js} +74 -74
  26. package/dist/styleRegistry-BQVgtgLT.js.map +1 -0
  27. package/dist/{styleRegistry-BsMmbH_0.d.ts → styleRegistry-C7HARIpw.d.ts} +2 -2
  28. package/dist/{styleRegistry-BsMmbH_0.d.ts.map → styleRegistry-C7HARIpw.d.ts.map} +1 -1
  29. package/dist/{styleVocabulary-CDTPCMhZ.js → styleVocabulary-BJuyoSBc.js} +2 -2
  30. package/dist/{styleVocabulary-CDTPCMhZ.js.map → styleVocabulary-BJuyoSBc.js.map} +1 -1
  31. package/dist/{typography-BCKqcNDx.js → typography-BpeDYjMz.js} +8 -3
  32. package/dist/typography-BpeDYjMz.js.map +1 -0
  33. package/dist/{validate-8Ow1tYvz.d.ts → validate-BzIATwDA.d.ts} +2 -2
  34. package/dist/{validate-8Ow1tYvz.d.ts.map → validate-BzIATwDA.d.ts.map} +1 -1
  35. package/dist/{validate-D_VsJM1q.js → validate-DcGjEAHf.js} +75 -37
  36. package/dist/validate-DcGjEAHf.js.map +1 -0
  37. package/package.json +1 -1
  38. package/schema/style-v1.json +70 -21
  39. package/styles/aurora-dark.json +8 -8
  40. package/styles/aurora-light.json +8 -8
  41. package/styles/glass-dark.json +8 -8
  42. package/styles/glass-light.json +8 -8
  43. package/styles/opaque-bright.json +8 -8
  44. package/styles/opaque-heavy.json +8 -8
  45. package/styles/opaque-light.json +8 -8
  46. package/styles/opaque-medium.json +8 -8
  47. package/styles/opaque-minimal.json +8 -8
  48. package/dist/engine-6ocr431e.js.map +0 -1
  49. package/dist/getColorLightnessClassification-Dgr8qirZ.js.map +0 -1
  50. package/dist/styleRegistry-BqGmp-3z.js.map +0 -1
  51. package/dist/typography-BCKqcNDx.js.map +0 -1
  52. package/dist/validate-D_VsJM1q.js.map +0 -1
@@ -1,15 +1,15 @@
1
1
 
2
2
  /*
3
- * @license @wistia/kaleidoscope v0.0.8
3
+ * @license @wistia/kaleidoscope v0.0.9
4
4
  *
5
5
  * Copyright (c) 2026, Wistia, Inc. and its affiliates.
6
6
  *
7
7
  * This source code is unlicensed, all rights reserved.
8
8
  */
9
9
 
10
- import { c as getBestColorForText, d as colorContrastRatiosByShape, f as Color, h as clamp, n as buildBrandedColorScale, o as getBrandLightBackgroundColor, s as getBrandDarkBackgroundColor, t as getColorLightnessClassification, u as adjustColorForProperContrast } from "./getColorLightnessClassification-Dgr8qirZ.js";
11
- import { l as ORNAMENTAL_BORDER_STYLES, n as TYPE_ROLES, o as STACKABLE_ON, s as SURFACE_NAMES } from "./typography-BCKqcNDx.js";
12
- import { n as isOneOf } from "./guards-BPewjm9T.js";
10
+ import { c as getBestColorForText, d as colorContrastRatiosByShape, f as Color, g as clamp, n as buildBrandedColorScale, o as getBrandLightBackgroundColor, p as linearize, s as getBrandDarkBackgroundColor, t as getColorLightnessClassification, u as adjustColorForProperContrast } from "./getColorLightnessClassification-BkZcKrdi.js";
11
+ import { l as ORNAMENTAL_BORDER_STYLES, n as TYPE_ROLES, o as STACKABLE_ON, s as SURFACE_NAMES } from "./typography-BpeDYjMz.js";
12
+ import { n as isOneOf } from "./guards-Cyl-NUQX.js";
13
13
  // src/brandTokens.ts
14
14
  /** The Brand Kit tokens a Style document can reference, each as `$<name>`. */
15
15
  const BRAND_TOKEN_NAMES = [
@@ -161,36 +161,60 @@ const anchorColor = (ref, anchors) => {
161
161
  const anchorOrSingleColor = (value, anchors) => typeof value === "string" && isAnchorRef(value) ? anchorColor(value, anchors) : resolveSingleColor(value, anchors.tokens);
162
162
  /** The scale stepping from an anchor walks: its token's if it's toned, or else its own. */
163
163
  const anchorScale = (ref, anchors) => anchors.scales[anchorName(ref)] ?? scaleOf(anchorColor(ref, anchors));
164
- // src/private/engine/rules/border.ts
165
- /** The page sits on nothing and has no edge, so it carries no border. */
166
- const BORDER_SLOTS = {
167
- surfaces: SURFACE_NAMES.filter((name) => name !== "page"),
168
- initialValues: {
169
- "border-width": "0",
170
- "border-style": "none",
171
- "border-color": "transparent"
164
+ // src/private/engine/kebab.ts
165
+ /** `buttonPrimary` → `button-primary`, as surface names appear in variable names. */
166
+ const kebab = (name) => name.replaceAll(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);
167
+ // src/private/engine/surfaces.ts
168
+ /** What the engine knows about each surface beyond what a Style document says. */
169
+ const SURFACES = {
170
+ page: {
171
+ holdsContent: true,
172
+ interactive: false,
173
+ mayContainForm: false
174
+ },
175
+ panel: {
176
+ holdsContent: true,
177
+ interactive: false,
178
+ mayContainForm: true
179
+ },
180
+ card: {
181
+ holdsContent: true,
182
+ interactive: true,
183
+ mayContainForm: false
184
+ },
185
+ buttonPrimary: {
186
+ holdsContent: false,
187
+ interactive: true,
188
+ mayContainForm: false
189
+ },
190
+ buttonSecondary: {
191
+ holdsContent: false,
192
+ interactive: true,
193
+ mayContainForm: false
172
194
  }
173
195
  };
174
- /** A `width` of 0 keeps the initial values, so the surface has no edge whatever its source. */
175
- const borderSlots = (border, solid, anchors) => {
176
- if (border === void 0 || border.width === 0) return {};
177
- const { offset, source, style, width } = border;
178
- const from = source === "surface" ? solid : anchorColor(source, anchors);
179
- return {
180
- "border-width": `${width}px`,
181
- "border-style": style,
182
- "border-color": stepFrom(from, offset).toHex()
183
- };
184
- };
185
- /** An ornament is a drawn tile rather than a CSS border, and draws whatever the width. */
186
- const borderGaps = ({ border }) => ORNAMENTAL_BORDER_STYLES.some((ornament) => ornament === border?.style) ? [`border.style: ${border?.style}`] : [];
196
+ /** Every surface group, parents before the surfaces that sit on them. */
197
+ const SURFACE_GROUPS = SURFACE_NAMES.flatMap((surface) => {
198
+ const parents = STACKABLE_ON[surface];
199
+ if (parents.length <= 1) return [{
200
+ surface,
201
+ parent: parents[0] ?? null,
202
+ prefix: kebab(surface)
203
+ }];
204
+ return parents.map((parent) => ({
205
+ surface,
206
+ parent,
207
+ prefix: `${kebab(surface)}-on-${kebab(parent)}`
208
+ }));
209
+ });
210
+ // src/private/engine/slots.ts
211
+ const VARIABLE_PREFIX = "--wistia-kaleidoscope-";
212
+ const surfacesWhere = (flag) => SURFACE_NAMES.filter((name) => SURFACES[name][flag]);
213
+ const surfaceVariable = (prefix, slot) => `${VARIABLE_PREFIX}${prefix}-${slot}`;
214
+ const typeVariable = (role, slot) => `${VARIABLE_PREFIX}type-${role}-${slot}`;
187
215
  // src/private/engine/constants/elevation.ts
188
216
  /** What `elevation.source: shade` is before each shadow's alpha. */
189
217
  const SHADE_COLOR = "#000000";
190
- /**
191
- * The shadow each hardness casts at each depth. `soft · low` is from the Phase 1 carousel sandbox;
192
- * the rest are placeholders carried over from the Style Sampler prototype.
193
- */
194
218
  const SHADOWS = {
195
219
  soft: {
196
220
  low: {
@@ -274,68 +298,583 @@ const GLOW_CORES = {
274
298
  alpha: 1
275
299
  }
276
300
  };
277
- // src/private/engine/kebab.ts
278
- /** `buttonPrimary` → `button-primary`, as surface names appear in variable names. */
279
- const kebab = (name) => name.replaceAll(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);
280
- // src/private/engine/surfaces.ts
281
- /** What the engine knows about each surface beyond what a Style document says. */
282
- const SURFACES = {
283
- page: {
284
- holdsContent: true,
285
- interactive: false,
286
- mayContainForm: false,
287
- shadowScale: 1
301
+ /**
302
+ * How much each surface scales its shadow's offsets and blur, since a button is smaller than a
303
+ * panel. The page sits on nothing, so it casts no shadow.
304
+ */
305
+ const SHADOW_SCALES = {
306
+ panel: 1.25,
307
+ card: 1,
308
+ buttonPrimary: .5,
309
+ buttonSecondary: .5
310
+ };
311
+ // src/private/engine/constants/glass.ts
312
+ const GLASS_LIGHT_COLOR = "#ffffff";
313
+ const GLASS_SHADE_COLOR = "#000000";
314
+ const GLASS_SHEEN_ANGLE = "135deg";
315
+ const GLASS_SHEEN_STOPS = [
316
+ 0,
317
+ 45,
318
+ 100
319
+ ];
320
+ /** Panel inputs are the panel's text color at these alphas. Placeholders. */
321
+ const GLASS_INPUT_ALPHA = .08;
322
+ const GLASS_INPUT_FOCUS_ALPHA = .2;
323
+ const BACKDROP_FILTER = "blur(10px) saturate(180%)";
324
+ /** From the Phase 1 carousel sandbox. */
325
+ const DARK_CONTAINER = {
326
+ backdropFilter: BACKDROP_FILTER,
327
+ counterEdge: ["inset -1px -1px 1px 0", .13],
328
+ edge: "inset 0 0 3px 0",
329
+ edgeAlpha: .3,
330
+ groundAlpha: .25,
331
+ hoverGroundAlpha: .25,
332
+ innerShade: [
333
+ "inset 0 4px 20px",
334
+ GLASS_SHADE_COLOR,
335
+ .1
336
+ ],
337
+ liftsParent: false,
338
+ sheen: [
339
+ .25,
340
+ .1,
341
+ .02
342
+ ],
343
+ specular: ["inset 0 7px 2px -6px", "inset 10px 6px 3px -10px"],
344
+ specularAlpha: .55
345
+ };
346
+ /**
347
+ * The design file gives panel and card one fill; a card has a finer edge and a denser hover. A
348
+ * shadow can't scale with its element, so the smaller tiers keep one soft highlight.
349
+ */
350
+ const DARK_CARD = {
351
+ backdropFilter: BACKDROP_FILTER,
352
+ counterEdge: ["inset -1px -1px 1px 0", .11],
353
+ edge: "inset 0 0 2px 0",
354
+ edgeAlpha: .28,
355
+ groundAlpha: .25,
356
+ hoverGroundAlpha: .37,
357
+ innerShade: [
358
+ "inset 0 4px 20px",
359
+ GLASS_SHADE_COLOR,
360
+ .1
361
+ ],
362
+ liftsParent: false,
363
+ sheen: [
364
+ .2,
365
+ .08,
366
+ .02
367
+ ],
368
+ specular: ["inset 0 1px 2px 0"],
369
+ specularAlpha: .25
370
+ };
371
+ const DARK_CONTROL = {
372
+ backdropFilter: null,
373
+ counterEdge: ["inset -1px -1px 1px 0", .09],
374
+ edge: "inset 0 0 2px 0",
375
+ edgeAlpha: .22,
376
+ groundAlpha: .08,
377
+ hoverGroundAlpha: .25,
378
+ innerShade: null,
379
+ liftsParent: true,
380
+ sheen: [
381
+ .15,
382
+ .08,
383
+ .02
384
+ ],
385
+ specular: ["inset 0 1px 2px 0"],
386
+ specularAlpha: .2
387
+ };
388
+ /** The design file has no light glass. A denser ground, and every shadow layer is white. */
389
+ const LIGHT_CONTAINER = {
390
+ ...DARK_CONTAINER,
391
+ counterEdge: ["inset -1px -1px 1px 0", .7],
392
+ edge: "inset 1px 1px 0 0",
393
+ edgeAlpha: .75,
394
+ groundAlpha: .45,
395
+ hoverGroundAlpha: .45,
396
+ innerShade: [
397
+ "inset 0 4px 20px",
398
+ GLASS_LIGHT_COLOR,
399
+ .35
400
+ ],
401
+ specularAlpha: .9
402
+ };
403
+ const LIGHT_CARD = {
404
+ ...DARK_CARD,
405
+ counterEdge: ["inset -1px -1px 1px 0", .6],
406
+ edgeAlpha: .85,
407
+ groundAlpha: .45,
408
+ hoverGroundAlpha: .62,
409
+ innerShade: [
410
+ "inset 0 4px 20px",
411
+ GLASS_LIGHT_COLOR,
412
+ .3
413
+ ],
414
+ specularAlpha: .8
415
+ };
416
+ const LIGHT_CONTROL = {
417
+ ...DARK_CONTROL,
418
+ counterEdge: ["inset -1px -1px 1px 0", .45],
419
+ edgeAlpha: .7,
420
+ groundAlpha: .35,
421
+ hoverGroundAlpha: .6,
422
+ liftsParent: false,
423
+ specularAlpha: .5
424
+ };
425
+ const GLASS_TIER_DEFAULTS = {
426
+ dark: {
427
+ container: DARK_CONTAINER,
428
+ card: DARK_CARD,
429
+ control: DARK_CONTROL
288
430
  },
289
- panel: {
290
- holdsContent: true,
291
- interactive: false,
292
- mayContainForm: true,
293
- shadowScale: 1.25
431
+ light: {
432
+ container: LIGHT_CONTAINER,
433
+ card: LIGHT_CARD,
434
+ control: LIGHT_CONTROL
435
+ }
436
+ };
437
+ const GLASS_TIER_OF_SURFACE = {
438
+ page: "container",
439
+ panel: "container",
440
+ card: "card",
441
+ buttonPrimary: "control",
442
+ buttonSecondary: "control"
443
+ };
444
+ /** Glass over a ground anchor darker than this is dark glass. */
445
+ const GLASS_DARK_BELOW_LUMINANCE = .2;
446
+ // src/private/engine/constants/gradient.ts
447
+ const GLOWS = {
448
+ alpha: .42,
449
+ size: "62% 56%",
450
+ fadeStop: 70,
451
+ darkFillLuminance: .2,
452
+ dark: {
453
+ alpha: .72,
454
+ size: "72% 66%",
455
+ midAlphaFactor: .6,
456
+ midStop: 38,
457
+ fadeStop: 72
294
458
  },
295
- card: {
296
- holdsContent: true,
297
- interactive: true,
298
- mayContainForm: false,
299
- shadowScale: 1
459
+ positions: [
460
+ "14% 16%",
461
+ "86% 22%",
462
+ "62% 92%",
463
+ "10% 80%",
464
+ "48% 50%",
465
+ "94% 66%"
466
+ ]
467
+ };
468
+ const LINEAR_ANGLES = {
469
+ "to-top": 0,
470
+ "to-top-right": 45,
471
+ "to-right": 90,
472
+ "to-bottom-right": 135,
473
+ "to-bottom": 180,
474
+ "to-bottom-left": 225,
475
+ "to-left": 270,
476
+ "to-top-left": 315
477
+ };
478
+ const RADIAL_POSITIONS = {
479
+ center: "50% 50%",
480
+ top: "50% 0%",
481
+ "top-right": "100% 0%",
482
+ right: "100% 50%",
483
+ "bottom-right": "100% 100%",
484
+ bottom: "50% 100%",
485
+ "bottom-left": "0% 100%",
486
+ left: "0% 50%",
487
+ "top-left": "0% 0%"
488
+ };
489
+ /**
490
+ * `near` is `farthest-side`, not `closest-side`: every position but `center` sits on an edge or a
491
+ * corner, where the closest side is zero away, and a circle with no radius paints only its last stop.
492
+ */
493
+ const RADIAL_EXTENTS = {
494
+ near: "farthest-side",
495
+ far: "farthest-corner"
496
+ };
497
+ /**
498
+ * `beams`: crossed lines in the stop colors over the surface's own fill. Each line is a tinted
499
+ * core inside a glow that falls off through `bands`, as px from its center and alpha, all scaled
500
+ * by `opacity`. Two faint pools of the first and last stop sit beneath. Placeholder.
501
+ */
502
+ const BEAMS = {
503
+ lines: [
504
+ {
505
+ angle: 64,
506
+ at: 16,
507
+ stop: 0
508
+ },
509
+ {
510
+ angle: 116,
511
+ at: 34,
512
+ stop: 1
513
+ },
514
+ {
515
+ angle: 76,
516
+ at: 62,
517
+ stop: 2
518
+ },
519
+ {
520
+ angle: 14,
521
+ at: 40,
522
+ stop: 1
523
+ },
524
+ {
525
+ angle: 164,
526
+ at: 58,
527
+ stop: 0
528
+ }
529
+ ],
530
+ bands: [
531
+ [34, 0],
532
+ [18, .07],
533
+ [9, .18],
534
+ [2.5, .34]
535
+ ],
536
+ core: [.8, .55],
537
+ coreTint: .45,
538
+ opacity: .6,
539
+ pools: [{
540
+ first: true,
541
+ alpha: .12,
542
+ geometry: "70% 45% at 50% 100%"
543
+ }, {
544
+ first: false,
545
+ alpha: .096,
546
+ geometry: "50% 35% at 10% 0%"
547
+ }]
548
+ };
549
+ // src/private/engine/constants/motion.ts
550
+ /** How long a surface takes to move between states. Placeholder. */
551
+ const TRANSITION_DURATIONS = {
552
+ none: null,
553
+ quick: "120ms",
554
+ smooth: "240ms"
555
+ };
556
+ /** The properties a state change animates. */
557
+ const TRANSITIONED_PROPERTIES = [
558
+ "background-color",
559
+ "box-shadow",
560
+ "border-color",
561
+ "color"
562
+ ];
563
+ const TRANSITION_EASING = "ease";
564
+ /** How long one drift takes per speed. */
565
+ const DRIFT_DURATIONS = {
566
+ slow: "10s",
567
+ medium: "6s",
568
+ fast: "3s"
569
+ };
570
+ let current = {
571
+ elevation: {
572
+ glowCores: GLOW_CORES,
573
+ shadowScales: SHADOW_SCALES,
574
+ shadows: SHADOWS
300
575
  },
301
- buttonPrimary: {
302
- holdsContent: false,
303
- interactive: true,
304
- mayContainForm: false,
305
- shadowScale: .5
576
+ glass: {
577
+ darkBelowLuminance: GLASS_DARK_BELOW_LUMINANCE,
578
+ inputAlpha: GLASS_INPUT_ALPHA,
579
+ inputFocusAlpha: GLASS_INPUT_FOCUS_ALPHA,
580
+ lightColor: GLASS_LIGHT_COLOR,
581
+ sheenAngle: GLASS_SHEEN_ANGLE,
582
+ sheenStops: GLASS_SHEEN_STOPS,
583
+ tiers: GLASS_TIER_DEFAULTS
306
584
  },
307
- buttonSecondary: {
308
- holdsContent: false,
309
- interactive: true,
310
- mayContainForm: false,
311
- shadowScale: .5
585
+ glows: GLOWS,
586
+ ornament: {
587
+ growth: {
588
+ perPixel: .2,
589
+ perPixelSquared: .025
590
+ },
591
+ maxRadius: 16,
592
+ shapes: {
593
+ scalloped: {
594
+ depth: 3,
595
+ band: 0
596
+ },
597
+ zigzag: {
598
+ depth: 3,
599
+ band: 0
600
+ },
601
+ lace: {
602
+ depth: 6,
603
+ band: .04
604
+ }
605
+ }
606
+ },
607
+ pulse: {
608
+ durations: {
609
+ slow: 2.8,
610
+ medium: 1.6,
611
+ fast: .9
612
+ },
613
+ shadowAlpha: .7,
614
+ shadows: {
615
+ small: {
616
+ y: 1,
617
+ blur: 6,
618
+ spread: 1
619
+ },
620
+ medium: {
621
+ y: 2,
622
+ blur: 14,
623
+ spread: 2
624
+ },
625
+ large: {
626
+ y: 4,
627
+ blur: 24,
628
+ spread: 4
629
+ }
630
+ }
631
+ },
632
+ texture: {
633
+ darkFillLuminance: .2,
634
+ edgeOpacity: {
635
+ dark: .6,
636
+ light: .3
637
+ },
638
+ lightFillLuminance: .9,
639
+ opacity: {
640
+ low: .35,
641
+ medium: .6,
642
+ high: .9
643
+ }
312
644
  }
313
645
  };
314
- /** Every surface group, parents before the surfaces that sit on them. */
315
- const SURFACE_GROUPS = SURFACE_NAMES.flatMap((surface) => {
316
- const parents = STACKABLE_ON[surface];
317
- if (parents.length <= 1) return [{
318
- surface,
319
- parent: parents[0] ?? null,
320
- prefix: kebab(surface)
321
- }];
322
- return parents.map((parent) => ({
323
- surface,
324
- parent,
325
- prefix: `${kebab(surface)}-on-${kebab(parent)}`
326
- }));
327
- });
646
+ /** The tuning treatments read. The defaults, except inside `withEngineTuning`. */
647
+ const engineTuning = () => current;
648
+ // src/private/engine/rules/ornament.ts
649
+ const isOrnament = (style) => ORNAMENTAL_BORDER_STYLES.some((ornament) => ornament === style);
650
+ const round$1 = (value) => Math.round(value * 100) / 100;
651
+ /**
652
+ * How far a filled ornament's base strip reaches each side of the surface's edge, in pixels. Shapes
653
+ * that only meet at the edge are each antialiased there, which leaves a hairline of the background showing through.
654
+ */
655
+ const OVERLAP = 1;
656
+ /** A filled circle as a subpath, centered at `x`, `y`. */
657
+ const dot$1 = (x, y, radius) => `M${round$1(x - radius)} ${round$1(y)}a${round$1(radius)} ${round$1(radius)} 0 1 1 ${round$1(2 * radius)} 0a${round$1(radius)} ${round$1(radius)} 0 1 1 ${round$1(-2 * radius)} 0`;
658
+ const halfDisc = (depth) => `M0 0A${depth} ${depth} 0 0 1 ${2 * depth} 0Z`;
659
+ const tooth = (depth) => `M0 0L${depth} ${-depth}L${2 * depth} 0Z`;
660
+ /** How far lace's scallop rises, its picots and net, as shares of the depth. */
661
+ const LACE = {
662
+ rise: .72,
663
+ picots: 7,
664
+ picotSpread: .8,
665
+ picotLength: .14,
666
+ picotDot: .045,
667
+ spokes: 11,
668
+ innerArc: .5,
669
+ bandDots: 5,
670
+ stroke: .0375
671
+ };
672
+ /**
673
+ * Lace is line art in the border's color: a scallop outline fringed with picots, a fan of spokes
674
+ * and an inner arc within it, a four-petal flower at its center and a row of dots along the edge.
675
+ * The fan radiates from the edge, so it reads the same on a corner's turned repeats.
676
+ */
677
+ const lace = (depth) => {
678
+ const stroke = round$1(LACE.stroke * depth);
679
+ const rise = LACE.rise * depth;
680
+ const radius = (depth * depth + rise * rise) / (2 * rise);
681
+ const below = radius - rise;
682
+ const outline = `M0 0A${round$1(radius)} ${round$1(radius)} 0 0 1 ${2 * depth} 0`;
683
+ const spread = Math.asin(depth / radius) * LACE.picotSpread;
684
+ const picots = Array.from({ length: LACE.picots }, (_, index) => {
685
+ const angle = -spread + 2 * spread * index / (LACE.picots - 1);
686
+ const [x, y] = [Math.sin(angle), -Math.cos(angle)];
687
+ const [startX, startY] = [depth + radius * x, below + radius * y];
688
+ const length = LACE.picotLength * depth;
689
+ const tip = length + LACE.picotDot * depth;
690
+ return {
691
+ line: `M${round$1(startX)} ${round$1(startY)}l${round$1(x * length)} ${round$1(y * length)}`,
692
+ dot: dot$1(startX + x * tip, startY + y * tip, LACE.picotDot * depth)
693
+ };
694
+ });
695
+ const spokes = Array.from({ length: LACE.spokes }, (_, index) => {
696
+ const angle = Math.PI * (index + 1) / (LACE.spokes + 1);
697
+ return `M${depth} 0l${round$1(-Math.cos(angle) * 2 * depth)} ${round$1(-Math.sin(angle) * 2 * depth)}`;
698
+ }).join("");
699
+ const arc = LACE.innerArc * depth;
700
+ const net = `${spokes}M${round$1(depth - arc)} 0A${round$1(arc)} ${round$1(arc)} 0 0 1 ${round$1(depth + arc)} 0`;
701
+ const center = -.36 * depth;
702
+ const petals = [
703
+ [.13, 0],
704
+ [0, .13],
705
+ [-.13, 0],
706
+ [0, -.13]
707
+ ].map(([x, y]) => dot$1(depth + (x ?? 0) * depth, center + (y ?? 0) * depth, .1 * depth)).join("");
708
+ const bandDots = Array.from({ length: LACE.bandDots }, (_, index) => dot$1((index + .5) * 2 * depth / LACE.bandDots, -.1 * depth, .04 * depth)).join("");
709
+ return `<clipPath id='l'><path d='${outline}Z'/></clipPath><g id='b' fill='none' stroke='currentColor' stroke-width='${stroke}' stroke-linecap='round'><path clip-path='url(#l)' stroke-width='${round$1(stroke * .55)}' d='${net}'/><path d='${outline}${picots.map(({ line }) => line).join("")}'/><path fill='currentColor' stroke='none' d='${picots.map(({ dot: tip }) => tip).join("")}${petals}${dot$1(depth, center, .06 * depth)}${bandDots}'/></g>`;
710
+ };
711
+ /** One repeat, `2 * depth` long, standing on the edge at y = 0 and reaching out to y = -depth. */
712
+ const REPEATS = {
713
+ scalloped: (depth) => `<path id='b' d='${halfDisc(depth)}'/>`,
714
+ zigzag: (depth) => `<path id='b' d='${tooth(depth)}'/>`,
715
+ lace
716
+ };
717
+ /** Each corner rotates the top-left one, `#c`, about its own center. */
718
+ const CORNERS = [
719
+ [
720
+ 0,
721
+ 0,
722
+ 0
723
+ ],
724
+ [
725
+ 1,
726
+ 0,
727
+ 90
728
+ ],
729
+ [
730
+ 1,
731
+ 1,
732
+ 180
733
+ ],
734
+ [
735
+ 0,
736
+ 1,
737
+ -90
738
+ ]
739
+ ];
740
+ /**
741
+ * Repeats sit along the corner's arc, `stretch`ed so a whole number of them spans it. On a corner
742
+ * too short for a whole repeat, the repeat shrinks to fit rather than being cut off. A solid
743
+ * repeat reaches inwards far enough to close the gap between its flat base and the arc. The corner
744
+ * is clipped to what lies outside the surface's rounded edge.
745
+ */
746
+ const cornerOf = (radius, depth, band, open) => {
747
+ const length = 2 * depth;
748
+ const arc = Math.PI * radius / 2;
749
+ const count = Math.max(1, Math.round(arc / length));
750
+ const fit = arc / count / length;
751
+ const stretch = round$1(Math.max(1, fit));
752
+ const shrinks = fit < 1;
753
+ const width = shrinks ? round$1(fit) : stretch;
754
+ const height = shrinks ? round$1(fit) : 1;
755
+ const reach = round$1(Math.hypot(radius, stretch * length / 2) - radius + OVERLAP);
756
+ const inner = round$1(Math.max(0, radius - OVERLAP));
757
+ const outer = round$1(radius + depth);
758
+ const banded = round$1(radius + band);
759
+ const repeats = Array.from({ length: count }, (_, index) => {
760
+ return `<use href='#k' transform='rotate(${round$1(270 + (index + .5) * 90 / count)})translate(0 ${-radius})scale(${width} ${height})translate(${-depth} 0)'/>`;
761
+ }).join("");
762
+ const filler = open ? "" : `<rect width='${length}' height='${reach}'/>`;
763
+ const ring = open && band > 0 ? `<path d='M${-radius} 0A${radius} ${radius} 0 0 1 0 ${-radius}V${-banded}A${banded} ${banded} 0 0 0 ${-banded} 0Z'/>` : "";
764
+ return `<clipPath id='o'><path d='M${-outer} ${-outer}H0V${-inner}A${inner} ${inner} 0 0 0 ${-inner} 0H${-outer}Z'/></clipPath><g id='k'><use href='#b'/>${filler}</g><g id='c' clip-path='url(#o)'>${repeats}${ring}</g>`;
765
+ };
766
+ /**
767
+ * Zigzag teeth along the corner's arc, so the corner comes to points like the edges either side:
768
+ * valleys on the arc, each tooth reaching `depth` past it, filled back to the arc.
769
+ */
770
+ const zigzagCornerOf = (radius, depth) => {
771
+ const count = Math.max(1, Math.round(Math.PI * radius / 2 / (2 * depth)));
772
+ const at = (distance, step) => {
773
+ const angle = Math.PI + step * Math.PI / 2 / count;
774
+ return `${round$1(distance * Math.cos(angle))} ${round$1(distance * Math.sin(angle))}`;
775
+ };
776
+ const teeth = Array.from({ length: count }, (_, index) => `L${at(radius + depth, index + .5)}L${at(radius, index + 1)}`).join("");
777
+ const inner = round$1(Math.max(0, radius - OVERLAP));
778
+ return `<path id='c' d='M${at(radius, 0)}${teeth}L0 ${-inner}A${inner} ${inner} 0 0 0 ${-inner} 0Z'/>`;
779
+ };
780
+ /**
781
+ * The `border-image` that draws `ornament` just outside a surface's edge, for a surface rounded by
782
+ * `radius`. `width` makes the ornament more pronounced (see `ORNAMENT_GROWTH`)
783
+ * Each corner is a slice `radius + depth` square, rounded to the next whole pixel. The edges between
784
+ * repeat whole, evenly spaced so that no corners show a clipped, partial scallop/zigzag/lace.
785
+ * The image lies outside the padding box by its outset, according to the ornament's depth, so a
786
+ * consumer draws it on a layer set to `inset: 0`.
787
+ */
788
+ const ornamentBorderImage = (ornament, color, radius, width) => {
789
+ const { growth, shapes } = engineTuning().ornament;
790
+ const { band: share, depth: baseDepth } = shapes[ornament];
791
+ const depth = Math.round(baseDepth * (1 + width * growth.perPixel + width ** 2 * growth.perPixelSquared) * 2) / 2;
792
+ const band = round$1(share * depth);
793
+ const slice = Math.ceil(radius + depth);
794
+ const outset = round$1(slice - radius);
795
+ const size = 2 * slice + 2 * depth;
796
+ const far = size - slice;
797
+ const corners = CORNERS.map(([x, y, angle]) => `<use href='#c' transform='translate(${x === 0 ? slice : far} ${y === 0 ? slice : far})rotate(${angle})'/>`).join("");
798
+ const edges = [
799
+ `translate(${slice} ${outset})`,
800
+ `translate(${round$1(size - outset)} ${slice})rotate(90)`,
801
+ `translate(${far} ${round$1(size - outset)})rotate(180)`,
802
+ `translate(${outset} ${far})rotate(-90)`
803
+ ].map((transform) => `<use href='#e' transform='${transform}'/>`).join("");
804
+ const open = ornament === "lace";
805
+ const laceBand = band > 0 ? `<rect y='${-band}' width='${2 * depth}' height='${band}'/>` : "";
806
+ const edgeBand = open ? laceBand : `<rect y='-1' width='${2 * depth}' height='2'/>`;
807
+ return `url("data:image/svg+xml,${`<svg xmlns='http://www.w3.org/2000/svg' width='${size}' height='${size}' fill='${color.toHex()}' color='${color.toHex()}'><defs>${REPEATS[ornament](depth)}<g id='e'><use href='#b'/>${edgeBand}</g>${ornament === "zigzag" ? zigzagCornerOf(round$1(radius), depth) : cornerOf(round$1(radius), depth, band, open)}</defs>${corners}${edges}</svg>`.replaceAll("<", "%3C").replaceAll(">", "%3E").replaceAll("#", "%23")}") ${slice} / ${slice}px / ${outset}px space`;
808
+ };
809
+ // src/private/engine/rules/border.ts
810
+ /**
811
+ * The page sits on nothing and has no edge, so it carries no border. `border-image` holds an
812
+ * ornament drawn just outside the edge, for a layer over the surface to paint.
813
+ */
814
+ const BORDER_SLOTS = {
815
+ surfaces: SURFACE_NAMES.filter((name) => name !== "page"),
816
+ initialValues: {
817
+ "border-width": "0",
818
+ "border-style": "none",
819
+ "border-color": "transparent",
820
+ "border-image": "none"
821
+ }
822
+ };
823
+ /** An ornament stepped from its surface follows the surface's fill when hovered. */
824
+ const HOVER_BORDER_SLOTS = {
825
+ surfaces: surfacesWhere("interactive"),
826
+ initialValues: { "border-image-hover": "none" }
827
+ };
828
+ /** An anchor source steps along the anchor's scale, so a toned anchor keeps its token's hue. */
829
+ const borderColor = ({ colorOffset, colorSource }, solid, anchors) => colorSource === "surface" ? stepFrom(solid, colorOffset) : stepAlong(anchorScale(colorSource, anchors), anchorColor(colorSource, anchors), colorOffset);
830
+ /**
831
+ * The line along the edge. A `width` of 0 keeps the initial values, so the surface has no line
832
+ * whatever its source. An ornament draws no line: its width makes the ornament larger instead.
833
+ */
834
+ const borderSlots = (border, solid, anchors) => {
835
+ if (border === void 0 || border.width === 0 || isOrnament(border.style)) return {};
836
+ return {
837
+ "border-width": `${border.width}px`,
838
+ "border-style": border.style,
839
+ "border-color": borderColor(border, solid, anchors).toHex()
840
+ };
841
+ };
842
+ /**
843
+ * An ornament stepped 0 from its surface is drawn in the surface's exact fill, so it reads as part
844
+ * of the surface; a step snaps to the scale, which would leave a seam.
845
+ */
846
+ const ornamentColor = (border, fill, anchors) => border.colorSource === "surface" && border.colorOffset === 0 ? fill : borderColor(border, fill, anchors);
847
+ /**
848
+ * An ornament is drawn in the border's color. Stepped from the surface, it follows the surface's
849
+ * fill when hovered; from an anchor, it stays put. A `width` of 0 keeps the initial values, so the
850
+ * surface has no ornament; above it, the ornament grows with the width.
851
+ */
852
+ const ornamentSlots = (border, { hoverSolid, radius, solid }, anchors) => {
853
+ if (border === void 0 || border.width === 0 || !isOrnament(border.style)) return {};
854
+ const { style, width } = border;
855
+ const draw = (fill) => ornamentBorderImage(style, ornamentColor(border, fill, anchors), radius, width);
856
+ const image = draw(solid);
857
+ if (hoverSolid === null) return { "border-image": image };
858
+ return {
859
+ "border-image": image,
860
+ "border-image-hover": border.colorSource === "surface" ? draw(hoverSolid) : image
861
+ };
862
+ };
328
863
  // src/private/engine/rules/elevation.ts
329
864
  const SHADE = new Color(SHADE_COLOR);
330
865
  /** The opaque color of an elevation. Each shadow sets its own alpha. */
331
866
  const elevationColor = (source, anchors) => source === "shade" ? SHADE : anchorOrSingleColor(source, anchors);
867
+ /** The page sits on nothing, so it has nothing to cast a shadow on. */
332
868
  const ELEVATION_SLOTS = {
333
- surfaces: SURFACE_NAMES,
869
+ surfaces: SURFACE_NAMES.filter((surface) => surface !== "page"),
334
870
  initialValues: { "box-shadow": "none" }
335
871
  };
336
872
  const shadowLayer = ({ alpha, blur, x, y }, color) => `${x}px ${y}px ${blur}px ${color.withAlpha(alpha).toRgba()}`;
337
- /** Whole pixels, and an offset that was there stays at least 1px so a small hard shadow survives. */
338
- const scaled = (length, scale) => length === 0 ? 0 : Math.max(1, Math.round(length * scale));
873
+ /**
874
+ * Whole pixels, and an offset that was there stays at least 1px so a small hard shadow survives.
875
+ * A scale of 0 takes the shadow's offsets and blur away entirely.
876
+ */
877
+ const scaled = (length, scale) => length === 0 || scale === 0 ? 0 : Math.max(1, Math.round(length * scale));
339
878
  const scaleShadow = ({ alpha, blur, x, y }, scale) => ({
340
879
  alpha,
341
880
  blur: scaled(blur, scale),
@@ -344,9 +883,10 @@ const scaleShadow = ({ alpha, blur, x, y }, scale) => ({
344
883
  });
345
884
  /** The glow's core stays tight on every surface, since it's what makes the edge read as lit. */
346
885
  const castShadows = (surface, { depth, hardness, source }, anchors) => {
347
- if (depth === "none") return [];
886
+ if (depth === "none" || surface === "page") return [];
887
+ const { glowCores, shadowScales, shadows: table } = engineTuning().elevation;
348
888
  const color = elevationColor(source, anchors);
349
- return [scaleShadow(SHADOWS[hardness][depth], SURFACES[surface].shadowScale), ...hardness === "glow" ? [GLOW_CORES[depth]] : []].map((shadow) => shadowLayer(shadow, color));
889
+ return [scaleShadow(table[hardness][depth], shadowScales[surface]), ...hardness === "glow" ? [glowCores[depth]] : []].map((shadow) => shadowLayer(shadow, color));
350
890
  };
351
891
  /**
352
892
  * The elevation's shadow, if it casts one, scaled to the surface, with any layers the treatment
@@ -356,11 +896,8 @@ const elevationSlots = (surface, elevation, anchors, treatmentLayers = []) => {
356
896
  const layers = [...castShadows(surface, elevation, anchors), ...treatmentLayers];
357
897
  return layers.length === 0 ? {} : { "box-shadow": layers.join(", ") };
358
898
  };
359
- // src/private/engine/slots.ts
360
- const VARIABLE_PREFIX = "--wistia-kaleidoscope-";
361
- const surfacesWhere = (flag) => SURFACE_NAMES.filter((name) => SURFACES[name][flag]);
362
- const surfaceVariable = (prefix, slot) => `${VARIABLE_PREFIX}${prefix}-${slot}`;
363
- const typeVariable = (role, slot) => `${VARIABLE_PREFIX}type-${role}-${slot}`;
899
+ /** The page sits on nothing, so it can't be elevated. */
900
+ const elevationGaps = ({ elevation: { depth } }, surface) => surface === "page" && depth !== "none" ? [`elevation.depth: ${depth}`] : [];
364
901
  // src/private/engine/rules/fill.ts
365
902
  /**
366
903
  * A surface's fill. `background-image` holds layers drawn over `background-color` — glass sheens,
@@ -383,53 +920,6 @@ const HOVER_FILL_SLOTS = {
383
920
  };
384
921
  /** Inverting repaints a surface as a flat fill, so no other treatment can invert. */
385
922
  const fillGaps = ({ backgroundColor: { invert }, treatment }) => treatment === "flat" || invert === "never" ? [] : [`backgroundColor.invert: ${invert}`];
386
- // src/private/engine/constants/motion.ts
387
- /** How long a surface takes to move between states. Placeholder. */
388
- const TRANSITION_DURATIONS = {
389
- none: null,
390
- quick: "120ms",
391
- smooth: "240ms"
392
- };
393
- /** The properties a state change animates. */
394
- const TRANSITIONED_PROPERTIES = [
395
- "background-color",
396
- "box-shadow",
397
- "border-color",
398
- "color"
399
- ];
400
- const TRANSITION_EASING = "ease";
401
- /** How long one drift takes per speed. */
402
- const DRIFT_DURATIONS = {
403
- slow: "10s",
404
- medium: "6s",
405
- fast: "3s"
406
- };
407
- /** How long one pulse takes per speed. Placeholder. */
408
- const PULSE_DURATIONS = {
409
- slow: "2.8s",
410
- medium: "1.6s",
411
- fast: "0.9s"
412
- };
413
- /** The shadow a pulse moves towards per size, in pixels. Placeholder. */
414
- const PULSE_SHADOWS = {
415
- small: {
416
- y: 1,
417
- blur: 6,
418
- spread: 1
419
- },
420
- medium: {
421
- y: 2,
422
- blur: 14,
423
- spread: 2
424
- },
425
- large: {
426
- y: 4,
427
- blur: 24,
428
- spread: 4
429
- }
430
- };
431
- /** How much of the pulse color its shadow shows. Placeholder. */
432
- const PULSE_SHADOW_ALPHA = .7;
433
923
  // src/private/engine/rules/motion.ts
434
924
  const MOTION_SLOTS = {
435
925
  surfaces: SURFACE_NAMES,
@@ -466,11 +956,12 @@ const driftSlots = ({ ambient, speed }) => ambient === "drift" ? { "animation-du
466
956
  const pulseSlots = ({ elevation, motion }, anchors) => {
467
957
  if (motion.ambient !== "pulse") return {};
468
958
  const color = motion.pulseColor === "derive" ? elevationColor(elevation.source, anchors) : anchorOrSingleColor(motion.pulseColor, anchors);
469
- const { blur, spread, y } = PULSE_SHADOWS[motion.pulseSize];
959
+ const { durations, shadowAlpha, shadows } = engineTuning().pulse;
960
+ const { blur, spread, y } = shadows[motion.pulseSize];
470
961
  return {
471
- "pulse-duration": PULSE_DURATIONS[motion.speed],
962
+ "pulse-duration": `${durations[motion.speed]}s`,
472
963
  "pulse-color": color.toRgba(),
473
- "pulse-box-shadow": `0 ${y}px ${blur}px ${spread}px ${color.withAlpha(PULSE_SHADOW_ALPHA).toRgba()}`
964
+ "pulse-box-shadow": `0 ${y}px ${blur}px ${spread}px ${color.withAlpha(shadowAlpha).toRgba()}`
474
965
  };
475
966
  };
476
967
  const motionSlots = (settings, anchors) => ({
@@ -512,7 +1003,16 @@ const RADIUS_SLOTS = {
512
1003
  surfaces: SURFACE_NAMES,
513
1004
  initialValues: { "border-radius": "0" }
514
1005
  };
515
- const radiusSlots = (surface, { source }, anchors) => ({ "border-radius": source === "anchors.dimensions.borderRadius" ? `${Math.round(anchors.borderRadius * RADIUS_FACTORS[surface])}px` : `${anchors.dimension(source)}px` });
1006
+ /**
1007
+ * A browser draws no more than half a surface's shorter side as its radius, and shrinks an
1008
+ * ornament's corners to match, pulling the ornament off the edge. The engine never sees a surface's
1009
+ * size, so an ornamented surface caps its radius instead.
1010
+ */
1011
+ const radiusPixels = (surface, { source }, anchors, border) => {
1012
+ const pixels = source === "anchors.dimensions.borderRadius" ? Math.round(anchors.borderRadius * RADIUS_FACTORS[surface]) : anchors.dimension(source);
1013
+ return border !== void 0 && border.width > 0 && isOrnament(border.style) ? Math.min(pixels, engineTuning().ornament.maxRadius) : pixels;
1014
+ };
1015
+ const radiusSlots = (surface, radius, anchors, border) => ({ "border-radius": `${radiusPixels(surface, radius, anchors, border)}px` });
516
1016
  // src/private/engine/rules/text.ts
517
1017
  const TEXT_SLOTS = {
518
1018
  surfaces: SURFACE_NAMES,
@@ -583,22 +1083,6 @@ const hoverTextSlots = (surface, textColor, text, solidHover) => {
583
1083
  });
584
1084
  return Object.fromEntries(Object.entries(textSlots(surface, readable)).map(([slot, value]) => [`${slot}-hover`, value]));
585
1085
  };
586
- // src/private/engine/constants/texture.ts
587
- /** How opaque each intensity draws a texture's tile. Placeholder. */
588
- const TEXTURE_OPACITY = {
589
- low: .35,
590
- medium: .6,
591
- high: .9
592
- };
593
- /**
594
- * How much of its intensity's opacity a texture keeps near either end. Specks and dots that
595
- * `multiply` or `screen` show far more than `soft-light` does in between, so they draw fainter.
596
- * Placeholder.
597
- */
598
- const TEXTURE_EDGE_OPACITY = {
599
- dark: .6,
600
- light: .3
601
- };
602
1086
  // src/private/engine/rules/texture.ts
603
1087
  /**
604
1088
  * A texture is a tile laid over the fill. `texture-image` is a `background-image` that repeats at
@@ -616,29 +1100,56 @@ const SOFT_STRETCH = "type='linear' slope='2.4' intercept='-0.7'";
616
1100
  /** Every pixel lands on black or white, like screen static. */
617
1101
  const HARD_THRESHOLD = "type='discrete' tableValues='0 1'";
618
1102
  const toneOf = (solid) => {
1103
+ const { darkFillLuminance, lightFillLuminance } = engineTuning().texture;
619
1104
  const luminance = solid.luminance();
620
- if (luminance < .2) return "dark";
621
- return luminance > .9 ? "light" : "mid";
1105
+ if (luminance < darkFillLuminance) return "dark";
1106
+ return luminance > lightFillLuminance ? "light" : "mid";
1107
+ };
1108
+ const BLACK = [
1109
+ 0,
1110
+ 0,
1111
+ 0
1112
+ ];
1113
+ const WHITE = [
1114
+ 1,
1115
+ 1,
1116
+ 1
1117
+ ];
1118
+ const round = (value) => Math.round(value * 1e3) / 1e3;
1119
+ const inkColor = (color) => [
1120
+ round(linearize(color.r)),
1121
+ round(linearize(color.g)),
1122
+ round(linearize(color.b))
1123
+ ];
1124
+ /** How much ink each pixel of gray noise lays down, by the tone of the fill. */
1125
+ const NOISE_ALPHA = {
1126
+ dark: "0.4252 1.4304 0.1444 0 -1",
1127
+ light: "-0.4252 -1.4304 -0.1444 0 1",
1128
+ mid: "0.2126 0.7152 0.0722 0 0"
622
1129
  };
623
1130
  /**
624
- * What the gray noise becomes. On a mid fill it stays opaque gray, so the blend alone decides how it
625
- * shows. Near either end only its dark or light half survives, as black or white specks on a clear
626
- * tile, alpha running from 0 at middle gray.
1131
+ * What the gray noise becomes. On a mid fill without a color of its own it stays opaque gray, so
1132
+ * the blend alone decides how it shows. Otherwise it becomes ink on a clear tile, its alpha taken
1133
+ * from the noise so the grain survives any ink, even black. Near either end only the noise's dark
1134
+ * or light half survives, alpha running from 0 at middle gray. Without a color of its own the ink
1135
+ * is black near white and white near black.
627
1136
  */
628
- const NOISE_INK = {
629
- mid: "<feComponentTransfer><feFuncA type='table' tableValues='1 1'/></feComponentTransfer>",
630
- light: "<feColorMatrix type='matrix' values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.4252 -1.4304 -0.1444 0 1'/>",
631
- dark: "<feColorMatrix type='matrix' values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0.4252 1.4304 0.1444 0 -1'/>"
1137
+ const noiseInk = (tone, color) => {
1138
+ if (tone === "mid" && color === null) return "<feComponentTransfer><feFuncA type='table' tableValues='1 1'/></feComponentTransfer>";
1139
+ const [red, green, blue] = color ?? (tone === "light" ? BLACK : WHITE);
1140
+ return `<feColorMatrix type='matrix' values='0 0 0 0 ${red} 0 0 0 0 ${green} 0 0 0 0 ${blue} ${NOISE_ALPHA[tone]}'/>`;
632
1141
  };
633
- const noise = (size, frequency, stretch, opacity, tone) => svgTile(size, `<filter id='t' x='0' y='0'><feTurbulence type='fractalNoise' baseFrequency='${frequency}' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/><feComponentTransfer><feFuncR ${stretch}/><feFuncG ${stretch}/><feFuncB ${stretch}/></feComponentTransfer>${NOISE_INK[tone]}</filter><rect width='100%' height='100%' filter='url(#t)' opacity='${opacity}'/>`);
1142
+ const noise = (size, frequency, stretch, opacity, tone, color) => svgTile(size, `<filter id='t' x='0' y='0'><feTurbulence type='fractalNoise' baseFrequency='${frequency}' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/><feComponentTransfer><feFuncR ${stretch}/><feFuncG ${stretch}/><feFuncB ${stretch}/></feComponentTransfer>${noiseInk(tone, color)}</filter><rect width='100%' height='100%' filter='url(#t)' opacity='${opacity}'/>`);
634
1143
  const dot = (color, opacity) => svgTile(5, `<radialGradient id='d'><stop offset='.65' stop-color='${color}'/><stop offset='1' stop-color='${color}' stop-opacity='0'/></radialGradient><circle cx='2.5' cy='2.5' r='1.7' fill='url(#d)' opacity='${opacity}'/>`);
635
- const round = (value) => Math.round(value * 1e3) / 1e3;
636
1144
  const TILES = {
637
- grain: (opacity, tone) => noise(160, .9, SOFT_STRETCH, opacity, tone),
638
- static: (opacity, tone) => noise(200, .65, HARD_THRESHOLD, round(opacity * .75), tone),
639
- halftone: (opacity, tone) => dot(tone === "dark" ? "#fff" : "#000", opacity)
1145
+ grain: (opacity, tone, color) => noise(160, .9, SOFT_STRETCH, opacity, tone, color === null ? null : inkColor(color)),
1146
+ static: (opacity, tone, color) => noise(200, .65, HARD_THRESHOLD, round(opacity * .75), tone, color === null ? null : inkColor(color)),
1147
+ halftone: (opacity, tone, color) => dot(color?.toHex() ?? (tone === "dark" ? "#fff" : "#000"), opacity)
1148
+ };
1149
+ const opacityFor = (intensity, tone) => {
1150
+ const { edgeOpacity, opacity } = engineTuning().texture;
1151
+ return tone === "mid" ? opacity[intensity] : round(opacity[intensity] * edgeOpacity[tone]);
640
1152
  };
641
- const opacityFor = (intensity, tone) => tone === "mid" ? TEXTURE_OPACITY[intensity] : round(TEXTURE_OPACITY[intensity] * TEXTURE_EDGE_OPACITY[tone]);
642
1153
  const BLEND_MODES = {
643
1154
  dark: "screen",
644
1155
  light: "multiply",
@@ -646,13 +1157,16 @@ const BLEND_MODES = {
646
1157
  };
647
1158
  /**
648
1159
  * The texture's tile and blend for a fill. Near white it draws only dark specks or dots with
649
- * `multiply`, near black only light ones with `screen`, and `soft-light` in between.
1160
+ * `multiply`, near black only light ones with `screen`, and `soft-light` in between. A texture with
1161
+ * a `color` of its own draws its noise or dots in that color.
650
1162
  */
651
- const textureSlots = ({ intensity, kind }, solid) => {
1163
+ const textureSlots = ({ color, intensity, kind }, solid, anchors) => {
652
1164
  if (kind === "none") return {};
653
1165
  const tone = toneOf(solid);
1166
+ const ink = color === void 0 ? null : anchorOrSingleColor(color, anchors);
1167
+ const opacity = round(opacityFor(intensity, tone) * (ink?.a ?? 1));
654
1168
  return {
655
- "texture-image": TILES[kind](opacityFor(intensity, tone), tone),
1169
+ "texture-image": TILES[kind](opacity, tone, ink),
656
1170
  "texture-blend-mode": BLEND_MODES[tone]
657
1171
  };
658
1172
  };
@@ -694,6 +1208,7 @@ const SURFACE_SLOT_FRAGMENTS = [
694
1208
  CONTENT_HOVER_TEXT_SLOTS,
695
1209
  PANEL_INPUT_SLOTS,
696
1210
  BORDER_SLOTS,
1211
+ HOVER_BORDER_SLOTS,
697
1212
  ELEVATION_SLOTS,
698
1213
  RADIUS_SLOTS,
699
1214
  MOTION_SLOTS,
@@ -784,258 +1299,6 @@ const composite = (top, under) => new Color([
784
1299
  top.b * top.a + under.b * (1 - top.a),
785
1300
  1
786
1301
  ]);
787
- // src/private/engine/constants/glass.ts
788
- const GLASS_LIGHT_COLOR = "#ffffff";
789
- const GLASS_SHADE_COLOR = "#000000";
790
- const GLASS_SHEEN_ANGLE = "135deg";
791
- const GLASS_SHEEN_STOPS = [
792
- 0,
793
- 45,
794
- 100
795
- ];
796
- /** Panel inputs are the panel's text color at these alphas. Placeholders. */
797
- const GLASS_INPUT_ALPHA = .08;
798
- const GLASS_INPUT_FOCUS_ALPHA = .2;
799
- const BACKDROP_FILTER = "blur(10px) saturate(180%)";
800
- /** From the Phase 1 carousel sandbox. */
801
- const DARK_CONTAINER = {
802
- backdropFilter: BACKDROP_FILTER,
803
- counterEdge: ["inset -1px -1px 1px 0", .13],
804
- edge: "inset 0 0 3px 0",
805
- edgeAlpha: .3,
806
- groundAlpha: .25,
807
- hoverGroundAlpha: .25,
808
- innerShade: [
809
- "inset 0 4px 20px",
810
- GLASS_SHADE_COLOR,
811
- .1
812
- ],
813
- liftsParent: false,
814
- sheen: [
815
- .25,
816
- .1,
817
- .02
818
- ],
819
- specular: ["inset 0 7px 2px -6px", "inset 10px 6px 3px -10px"],
820
- specularAlpha: .55
821
- };
822
- /**
823
- * The design file gives panel and card one fill; a card has a finer edge and a denser hover. A
824
- * shadow can't scale with its element, so the smaller tiers keep one soft highlight.
825
- */
826
- const DARK_CARD = {
827
- backdropFilter: BACKDROP_FILTER,
828
- counterEdge: ["inset -1px -1px 1px 0", .11],
829
- edge: "inset 0 0 2px 0",
830
- edgeAlpha: .28,
831
- groundAlpha: .25,
832
- hoverGroundAlpha: .37,
833
- innerShade: [
834
- "inset 0 4px 20px",
835
- GLASS_SHADE_COLOR,
836
- .1
837
- ],
838
- liftsParent: false,
839
- sheen: [
840
- .2,
841
- .08,
842
- .02
843
- ],
844
- specular: ["inset 0 1px 2px 0"],
845
- specularAlpha: .25
846
- };
847
- const DARK_CONTROL = {
848
- backdropFilter: null,
849
- counterEdge: ["inset -1px -1px 1px 0", .09],
850
- edge: "inset 0 0 2px 0",
851
- edgeAlpha: .22,
852
- groundAlpha: .08,
853
- hoverGroundAlpha: .25,
854
- innerShade: null,
855
- liftsParent: true,
856
- sheen: [
857
- .15,
858
- .08,
859
- .02
860
- ],
861
- specular: ["inset 0 1px 2px 0"],
862
- specularAlpha: .2
863
- };
864
- /** The design file has no light glass. A denser ground, and every shadow layer is white. */
865
- const LIGHT_CONTAINER = {
866
- ...DARK_CONTAINER,
867
- counterEdge: ["inset -1px -1px 1px 0", .7],
868
- edge: "inset 1px 1px 0 0",
869
- edgeAlpha: .75,
870
- groundAlpha: .45,
871
- hoverGroundAlpha: .45,
872
- innerShade: [
873
- "inset 0 4px 20px",
874
- GLASS_LIGHT_COLOR,
875
- .35
876
- ],
877
- specularAlpha: .9
878
- };
879
- const LIGHT_CARD = {
880
- ...DARK_CARD,
881
- counterEdge: ["inset -1px -1px 1px 0", .6],
882
- edgeAlpha: .85,
883
- groundAlpha: .45,
884
- hoverGroundAlpha: .62,
885
- innerShade: [
886
- "inset 0 4px 20px",
887
- GLASS_LIGHT_COLOR,
888
- .3
889
- ],
890
- specularAlpha: .8
891
- };
892
- const LIGHT_CONTROL = {
893
- ...DARK_CONTROL,
894
- counterEdge: ["inset -1px -1px 1px 0", .45],
895
- edgeAlpha: .7,
896
- groundAlpha: .35,
897
- hoverGroundAlpha: .6,
898
- liftsParent: false,
899
- specularAlpha: .5
900
- };
901
- const GLASS_TIER_DEFAULTS = {
902
- dark: {
903
- container: DARK_CONTAINER,
904
- card: DARK_CARD,
905
- control: DARK_CONTROL
906
- },
907
- light: {
908
- container: LIGHT_CONTAINER,
909
- card: LIGHT_CARD,
910
- control: LIGHT_CONTROL
911
- }
912
- };
913
- const GLASS_TIER_OF_SURFACE = {
914
- page: "container",
915
- panel: "container",
916
- card: "card",
917
- buttonPrimary: "control",
918
- buttonSecondary: "control"
919
- };
920
- /** Glass over a ground anchor darker than this is dark glass. */
921
- const GLASS_DARK_BELOW_LUMINANCE = .2;
922
- // src/private/engine/constants/gradient.ts
923
- const GLOWS = {
924
- alpha: .42,
925
- size: "62% 56%",
926
- fadeStop: 70,
927
- darkFillLuminance: .2,
928
- dark: {
929
- alpha: .72,
930
- size: "72% 66%",
931
- midAlphaFactor: .6,
932
- midStop: 38,
933
- fadeStop: 72
934
- },
935
- positions: [
936
- "14% 16%",
937
- "86% 22%",
938
- "62% 92%",
939
- "10% 80%",
940
- "48% 50%",
941
- "94% 66%"
942
- ]
943
- };
944
- const LINEAR_ANGLES = {
945
- "to-top": 0,
946
- "to-top-right": 45,
947
- "to-right": 90,
948
- "to-bottom-right": 135,
949
- "to-bottom": 180,
950
- "to-bottom-left": 225,
951
- "to-left": 270,
952
- "to-top-left": 315
953
- };
954
- const RADIAL_POSITIONS = {
955
- center: "50% 50%",
956
- top: "50% 0%",
957
- "top-right": "100% 0%",
958
- right: "100% 50%",
959
- "bottom-right": "100% 100%",
960
- bottom: "50% 100%",
961
- "bottom-left": "0% 100%",
962
- left: "0% 50%",
963
- "top-left": "0% 0%"
964
- };
965
- /**
966
- * `near` is `farthest-side`, not `closest-side`: every position but `center` sits on an edge or a
967
- * corner, where the closest side is zero away, and a circle with no radius paints only its last stop.
968
- */
969
- const RADIAL_EXTENTS = {
970
- near: "farthest-side",
971
- far: "farthest-corner"
972
- };
973
- /**
974
- * `beams`: crossed lines in the stop colors over the surface's own fill. Each line is a tinted
975
- * core inside a glow that falls off through `bands`, as px from its center and alpha, all scaled
976
- * by `opacity`. Two faint pools of the first and last stop sit beneath. Placeholder.
977
- */
978
- const BEAMS = {
979
- lines: [
980
- {
981
- angle: 64,
982
- at: 16,
983
- stop: 0
984
- },
985
- {
986
- angle: 116,
987
- at: 34,
988
- stop: 1
989
- },
990
- {
991
- angle: 76,
992
- at: 62,
993
- stop: 2
994
- },
995
- {
996
- angle: 14,
997
- at: 40,
998
- stop: 1
999
- },
1000
- {
1001
- angle: 164,
1002
- at: 58,
1003
- stop: 0
1004
- }
1005
- ],
1006
- bands: [
1007
- [34, 0],
1008
- [18, .07],
1009
- [9, .18],
1010
- [2.5, .34]
1011
- ],
1012
- core: [.8, .55],
1013
- coreTint: .45,
1014
- opacity: .6,
1015
- pools: [{
1016
- first: true,
1017
- alpha: .12,
1018
- geometry: "70% 45% at 50% 100%"
1019
- }, {
1020
- first: false,
1021
- alpha: .096,
1022
- geometry: "50% 35% at 10% 0%"
1023
- }]
1024
- };
1025
- let current = {
1026
- glass: {
1027
- darkBelowLuminance: GLASS_DARK_BELOW_LUMINANCE,
1028
- inputAlpha: GLASS_INPUT_ALPHA,
1029
- inputFocusAlpha: GLASS_INPUT_FOCUS_ALPHA,
1030
- lightColor: GLASS_LIGHT_COLOR,
1031
- sheenAngle: GLASS_SHEEN_ANGLE,
1032
- sheenStops: GLASS_SHEEN_STOPS,
1033
- tiers: GLASS_TIER_DEFAULTS
1034
- },
1035
- glows: GLOWS
1036
- };
1037
- /** The tuning treatments read. The defaults, except inside `withEngineTuning`. */
1038
- const engineTuning = () => current;
1039
1302
  // src/private/engine/treatments/glassy.ts
1040
1303
  const sheen = ({ sheen: alphas }, glass) => {
1041
1304
  const light = new Color(glass.lightColor);
@@ -1092,8 +1355,15 @@ const glassy = ({ anchors, parent, settings, surface }) => {
1092
1355
  })
1093
1356
  };
1094
1357
  };
1095
- /** Glass has a fixed ground that its parent shows through, so it can't count from its parent. */
1096
- const glassyGaps = ({ backgroundColor: { from }, treatment }) => treatment === "glassy" && from === "parent" ? ["backgroundColor.from: parent"] : [];
1358
+ /**
1359
+ * Glass has a fixed ground that its parent shows through, so it can't count from its parent. The
1360
+ * page has nothing behind it to show through, so it can't be glassy at all.
1361
+ */
1362
+ const glassyGaps = ({ backgroundColor: { from }, treatment }, surface) => {
1363
+ if (treatment !== "glassy") return [];
1364
+ if (surface === "page") return ["treatment: glassy"];
1365
+ return from === "parent" ? ["backgroundColor.from: parent"] : [];
1366
+ };
1097
1367
  // src/private/engine/treatments/gradient.ts
1098
1368
  const glowLayer = (glows, stop, position, onDark) => {
1099
1369
  if (onDark) {
@@ -1252,10 +1522,15 @@ const evaluateSurface = (style, surface, anchors, parent) => {
1252
1522
  ...textSlots(surface, text),
1253
1523
  ...spec.mayContainForm ? panelInputSlots(treated.solid, anchors, tinted?.inputFills) : {},
1254
1524
  ...borderSlots(settings.border, treated.solid, anchors),
1525
+ ...ornamentSlots(settings.border, {
1526
+ hoverSolid: spec.interactive ? hover.solid : null,
1527
+ radius: radiusPixels(surface, settings.radius, anchors, settings.border),
1528
+ solid: treated.solid
1529
+ }, anchors),
1255
1530
  ...elevationSlots(surface, settings.elevation, anchors, tinted?.shadowLayers),
1256
- ...radiusSlots(surface, settings.radius, anchors),
1531
+ ...radiusSlots(surface, settings.radius, anchors, settings.border),
1257
1532
  ...motionSlots(settings, anchors),
1258
- ...textureSlots(settings.texture, treated.solid)
1533
+ ...textureSlots(settings.texture, treated.solid, anchors)
1259
1534
  }
1260
1535
  };
1261
1536
  };
@@ -1286,8 +1561,8 @@ const evaluateSurfaces = (style, anchors) => {
1286
1561
  const GAP_FINDERS = [
1287
1562
  glassyGaps,
1288
1563
  fillGaps,
1289
- borderGaps,
1290
- motionGaps
1564
+ motionGaps,
1565
+ elevationGaps
1291
1566
  ];
1292
1567
  /** The rules in `style` the engine cannot resolve yet, as `<surface>.<setting>: <value>`. */
1293
1568
  const findUnsupportedRules = (style) => SURFACE_NAMES.flatMap((surface) => GAP_FINDERS.flatMap((findGaps) => findGaps(style.surfaces[surface], surface)).map((gap) => `${surface}.${gap}`));
@@ -1377,4 +1652,4 @@ const serializeKaleidoscopeStyles = (variables, selector) => {
1377
1652
  };
1378
1653
  export { BRAND_TOKEN_NAMES as a, VARIABLE_PREFIX as i, getKaleidoscopeStyles as n, DEFAULT_BRAND_TOKENS as o, KALEIDOSCOPE_CONTRACT as r, serializeKaleidoscopeStyles as t };
1379
1654
 
1380
- //# sourceMappingURL=engine-6ocr431e.js.map
1655
+ //# sourceMappingURL=engine-DY848hAQ.js.map