@takazudo/zdtp 0.4.5 → 0.4.7

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.
@@ -9,7 +9,7 @@ function A(e, t) {
9
9
  function $(e, t) {
10
10
  return e.items.find((n) => n.id === t);
11
11
  }
12
- function W(e, t, n, a) {
12
+ function Y(e, t, n, a) {
13
13
  const g = A(e, t);
14
14
  if (!g)
15
15
  throw new w(
@@ -27,8 +27,8 @@ function W(e, t, n, a) {
27
27
  throw new w(
28
28
  `Tier "${t}" declares referencesTier "${l}" but that tier does not exist in tab "${e.id}".`
29
29
  );
30
- const o = $(f, s ?? n);
31
- if (!o) {
30
+ const i = $(f, s ?? n);
31
+ if (!i) {
32
32
  const u = $(f, c.default) ?? $(f, n) ?? f.items[0];
33
33
  if (!u)
34
34
  throw new w(
@@ -36,35 +36,35 @@ function W(e, t, n, a) {
36
36
  );
37
37
  return { kind: "ref", targetCssVar: u.cssVar };
38
38
  }
39
- return { kind: "ref", targetCssVar: o.cssVar };
39
+ return { kind: "ref", targetCssVar: i.cssVar };
40
40
  }
41
41
  return s !== void 0 ? c.pill && s === c.pill.value ? { kind: "literal", value: c.pill.value } : { kind: "literal", value: s } : c.pill ? { kind: "literal", value: c.pill.customDefault } : { kind: "literal", value: c.default };
42
42
  }
43
- function Y(e) {
43
+ function Z(e) {
44
44
  return e.kind === "literal" ? e.value : `var(${e.targetCssVar})`;
45
45
  }
46
- function D(e, t, n = [t]) {
47
- const a = e.tab === void 0 || e.tab === t.id ? t : n.find((i) => i.id === e.tab);
46
+ function M(e, t, n = [t]) {
47
+ const a = e.tab === void 0 || e.tab === t.id ? t : n.find((o) => o.id === e.tab);
48
48
  if (!a)
49
49
  throw new w(
50
- `Cross-tab ref target tab "${e.tab}" not found. Available tabs: ${n.map((i) => i.id).join(", ")}.`
50
+ `Cross-tab ref target tab "${e.tab}" not found. Available tabs: ${n.map((o) => o.id).join(", ")}.`
51
51
  );
52
52
  const g = A(a, e.tier);
53
53
  if (!g)
54
54
  throw new w(
55
- `Cross-tab ref target tier "${e.tier}" not found in tab "${a.id}". Available tiers: ${a.tiers.map((i) => i.id).join(", ")}.`
55
+ `Cross-tab ref target tier "${e.tier}" not found in tab "${a.id}". Available tiers: ${a.tiers.map((o) => o.id).join(", ")}.`
56
56
  );
57
57
  const c = $(g, e.item);
58
58
  if (!c)
59
59
  throw new w(
60
- `Cross-tab ref target item "${e.item}" not found in tier "${e.tier}" of tab "${a.id}". Available items: ${g.items.map((i) => i.id).join(", ")}.`
60
+ `Cross-tab ref target item "${e.item}" not found in tier "${e.tier}" of tab "${a.id}". Available items: ${g.items.map((o) => o.id).join(", ")}.`
61
61
  );
62
62
  return c.cssVar;
63
63
  }
64
- function I(e, t) {
64
+ function X(e, t) {
65
65
  return e.paletteCssVarTemplate.replace("{n}", String(t));
66
66
  }
67
- const M = /* @__PURE__ */ new Set([
67
+ const N = /* @__PURE__ */ new Set([
68
68
  "aliceblue",
69
69
  "antiquewhite",
70
70
  "aqua",
@@ -221,27 +221,27 @@ const M = /* @__PURE__ */ new Set([
221
221
  "revert",
222
222
  "revert-layer"
223
223
  ]);
224
- function H(e) {
225
- return e.startsWith("#") || e.includes("(") || M.has(e.toLowerCase());
224
+ function z(e) {
225
+ return e.startsWith("#") || e.includes("(") || N.has(e.toLowerCase());
226
226
  }
227
- function N(e, t, n, a) {
227
+ function H(e, t, n, a) {
228
228
  const g = [], c = e.indexOf(":");
229
229
  if (c !== -1) {
230
230
  const s = e.slice(0, c), l = e.slice(c + 1), f = t.find((r) => r.tier === s);
231
231
  f && g.push({ tab: f.tab, tier: f.tier, item: l });
232
232
  }
233
- const [i] = t;
234
- g.push({ tab: i.tab, tier: i.tier, item: e });
233
+ const [o] = t;
234
+ g.push({ tab: o.tab, tier: o.tier, item: e });
235
235
  for (const s of g)
236
236
  try {
237
- return D(s, n, a), { ref: s };
237
+ return M(s, n, a), { ref: s };
238
238
  } catch {
239
239
  }
240
240
  return { ref: g[0] };
241
241
  }
242
242
  function K(e, t, n, a, g, c) {
243
- const i = t.get(e.default);
244
- return i !== void 0 ? i : e.default === "bg" || e.default === "fg" ? e.default : n && n.length > 0 && !H(e.default) ? N(e.default, n, a, g) : c ? (console.warn(
243
+ const o = t.get(e.default);
244
+ return o !== void 0 ? o : e.default === "bg" || e.default === "fg" ? e.default : n && n.length > 0 && !z(e.default) ? H(e.default, n, a, g) : c ? (console.warn(
245
245
  `[design-token-panel] semantic item "${e.id}" default "${e.default}" names no palette item; falling back to palette index 0`
246
246
  ), 0) : { literal: e.default };
247
247
  }
@@ -249,9 +249,9 @@ function V(e, t = [e]) {
249
249
  const n = e.colorExtras;
250
250
  if (!n) return;
251
251
  const a = e.tiers.find(
252
- (o) => !o.referencesTier && !o.semantic && o.items.length > 0 && o.items[0].type.kind === "color"
252
+ (i) => !i.referencesTier && !i.semantic && i.items.length > 0 && i.items[0].type.kind === "color"
253
253
  ), g = e.tiers.find(
254
- (o) => a && o.referencesTier === a.id || o.semantic === !0
254
+ (i) => a && i.referencesTier === a.id || i.semantic === !0
255
255
  );
256
256
  if (!a && !g)
257
257
  return {
@@ -267,12 +267,12 @@ function V(e, t = [e]) {
267
267
  colorSchemes: n.colorSchemes,
268
268
  panelSettings: n.panelSettings
269
269
  };
270
- const c = a?.items ?? [], i = c.length, s = c[0] ? c[0].cssVar.replace(/\d+$/, "{n}") : "--zudo-stub-p{n}", l = /* @__PURE__ */ new Map();
271
- for (let o = 0; o < c.length; o++)
272
- l.set(c[o].id, o);
270
+ const c = a?.items ?? [], o = c.length, s = c[0] ? c[0].cssVar.replace(/\d+$/, "{n}") : "--zudo-stub-p{n}", l = /* @__PURE__ */ new Map();
271
+ for (let i = 0; i < c.length; i++)
272
+ l.set(c[i].id, i);
273
273
  const f = {}, r = {};
274
274
  if (g) {
275
- const o = !g.semantic, u = n.semanticDefaults;
275
+ const i = !g.semantic, u = n.semanticDefaults;
276
276
  for (const d of g.items)
277
277
  r[d.id] = d.cssVar, f[d.id] = u && d.id in u ? u[d.id] : K(
278
278
  d,
@@ -280,13 +280,13 @@ function V(e, t = [e]) {
280
280
  g.referencesRamps,
281
281
  e,
282
282
  t,
283
- o
283
+ i
284
284
  );
285
285
  }
286
286
  return {
287
287
  id: n.id,
288
288
  label: n.label,
289
- paletteSize: i,
289
+ paletteSize: o,
290
290
  baseRoles: n.baseRoles,
291
291
  paletteCssVarTemplate: s,
292
292
  semanticDefaults: f,
@@ -297,12 +297,12 @@ function V(e, t = [e]) {
297
297
  panelSettings: n.panelSettings
298
298
  };
299
299
  }
300
- function X(e) {
300
+ function Q(e) {
301
301
  const t = e.find((n) => n.id === "color");
302
302
  if (t)
303
303
  return V(t, e);
304
304
  }
305
- function z(e) {
305
+ function L(e) {
306
306
  const t = e.find((n) => n.id === "color-secondary");
307
307
  return t ? V(t, e) ?? null : null;
308
308
  }
@@ -324,7 +324,7 @@ function S(e, t) {
324
324
  return !1;
325
325
  return !0;
326
326
  }
327
- const O = {
327
+ const _ = {
328
328
  storagePrefix: "zudo-design-token-panel",
329
329
  consoleNamespace: "zudo",
330
330
  modalClassPrefix: "zudo-design-token-panel-modal",
@@ -337,7 +337,7 @@ const O = {
337
337
  applyEndpoint: void 0,
338
338
  applyRouting: void 0
339
339
  }, R = /* @__PURE__ */ Symbol.for("@takazudo/zdtp:singleton");
340
- function y() {
340
+ function m() {
341
341
  const e = globalThis;
342
342
  let t = e[R];
343
343
  return t || (t = {
@@ -353,17 +353,17 @@ function F(e) {
353
353
  return {
354
354
  instanceId: e,
355
355
  open() {
356
- y().lifecycleHooks.open?.(e);
356
+ m().lifecycleHooks.open?.(e);
357
357
  },
358
358
  close() {
359
- y().lifecycleHooks.close?.(e);
359
+ m().lifecycleHooks.close?.(e);
360
360
  },
361
361
  toggle() {
362
- y().lifecycleHooks.toggle?.(e);
362
+ m().lifecycleHooks.toggle?.(e);
363
363
  },
364
364
  destroy() {
365
- y().lifecycleHooks.destroy?.(e);
366
- const t = y();
365
+ m().lifecycleHooks.destroy?.(e);
366
+ const t = m();
367
367
  if (t.instances.delete(e), t.defaultPrefix === e) {
368
368
  const n = [...t.instances.keys()];
369
369
  t.defaultPrefix = n.length > 0 ? n[n.length - 1] : null;
@@ -371,8 +371,8 @@ function F(e) {
371
371
  }
372
372
  };
373
373
  }
374
- function Q(e) {
375
- y().lifecycleHooks = {
374
+ function I(e) {
375
+ m().lifecycleHooks = {
376
376
  configured: e.configured,
377
377
  open: e.open,
378
378
  close: e.close,
@@ -380,8 +380,8 @@ function Q(e) {
380
380
  destroy: e.destroy
381
381
  };
382
382
  }
383
- function Z(e) {
384
- const t = y(), n = e.storagePrefix, a = t.instances.get(n);
383
+ function ee(e) {
384
+ const t = m(), n = e.storagePrefix, a = t.instances.get(n);
385
385
  if (a) {
386
386
  const f = (r) => ({ ...r, applySink: void 0 });
387
387
  if (S(f(a.suppliedConfig), f(e)))
@@ -392,8 +392,8 @@ function Z(e) {
392
392
  }
393
393
  const g = t.pendingColorPresets, c = g ? { ...e, colorPresets: g } : { ...e };
394
394
  t.pendingColorPresets = null;
395
- const i = t.instances.size === 0, s = i ? [...t.pendingPostConfigureHooks] : [];
396
- i && (t.pendingPostConfigureHooks.length = 0);
395
+ const o = t.instances.size === 0, s = o ? [...t.pendingPostConfigureHooks] : [];
396
+ o && (t.pendingPostConfigureHooks.length = 0);
397
397
  const l = {
398
398
  config: c,
399
399
  // Snapshot the as-supplied config before any runtime merges. Used by the
@@ -410,96 +410,110 @@ function Z(e) {
410
410
  return t.lifecycleHooks.configured?.(n), l.handle;
411
411
  }
412
412
  function x() {
413
- const e = y();
413
+ const e = m();
414
414
  return e.defaultPrefix === null ? null : e.instances.get(e.defaultPrefix) ?? null;
415
415
  }
416
- function ee(e) {
416
+ function te(e) {
417
417
  const t = x();
418
418
  if (t === null) {
419
- const n = y();
419
+ const n = m();
420
420
  if (n.pendingPostConfigureHooks.includes(e)) return;
421
421
  n.pendingPostConfigureHooks.push(e);
422
422
  return;
423
423
  }
424
424
  t.postConfigureHooks.includes(e) || (t.postConfigureHooks.push(e), e());
425
425
  }
426
- function _() {
427
- return x()?.config ?? O;
426
+ function D() {
427
+ return x()?.config ?? _;
428
428
  }
429
- function te() {
430
- return [...y().instances.values()].map((e) => e.config);
429
+ function ne() {
430
+ return [...m().instances.values()].map((e) => e.config);
431
431
  }
432
- function ne(e) {
433
- return y().instances.get(e)?.config ?? null;
432
+ function re(e) {
433
+ return m().instances.get(e)?.config ?? null;
434
434
  }
435
- function re() {
436
- const e = y();
435
+ function ie() {
436
+ const e = m();
437
437
  e.instances.clear(), e.defaultPrefix = null, e.pendingColorPresets = null, e.pendingPostConfigureHooks.length = 0, v().clear();
438
438
  }
439
439
  function v() {
440
- const e = y();
440
+ const e = m();
441
441
  return e.colorSchemeOwners || (e.colorSchemeOwners = /* @__PURE__ */ new Set()), e.colorSchemeOwners;
442
442
  }
443
- function ie(e) {
443
+ function oe(e) {
444
444
  v().add(e);
445
445
  }
446
- function oe(e) {
446
+ function se(e) {
447
447
  v().delete(e);
448
448
  }
449
- function se(e) {
449
+ function ae(e) {
450
450
  return v().has(e);
451
451
  }
452
- function ae(e = _()) {
453
- return z(e.tabs);
454
- }
455
- function le(e) {
456
- return `${e.storagePrefix}-state-v2`;
452
+ function le(e = D()) {
453
+ return L(e.tabs);
457
454
  }
458
455
  function fe(e) {
459
- return `${e.storagePrefix}-state-v3`;
456
+ return `${e.storagePrefix}-state-v2`;
460
457
  }
461
458
  function ce(e) {
462
- return `${e.storagePrefix}-state-v4`;
459
+ return `${e.storagePrefix}-state-v3`;
463
460
  }
464
461
  function ge(e) {
465
- return `${e.storagePrefix}-state`;
462
+ return `${e.storagePrefix}-state-v4`;
466
463
  }
467
464
  function ue(e) {
468
- return `${e.storagePrefix}-open`;
465
+ return `${e.storagePrefix}-state`;
469
466
  }
470
467
  function de(e) {
471
- return `${e.storagePrefix}-position`;
468
+ return `${e.storagePrefix}-open`;
472
469
  }
473
470
  function pe(e) {
474
- return `${e.storagePrefix}-size`;
471
+ return `${e.storagePrefix}-position`;
475
472
  }
476
473
  function ye(e) {
477
- return `${e.storagePrefix}-density`;
474
+ return `${e.storagePrefix}-size`;
478
475
  }
479
476
  function me(e) {
480
- return `${e.storagePrefix}:visible`;
477
+ return `${e.storagePrefix}-density`;
481
478
  }
482
479
  function he(e) {
483
- return `${e.storagePrefix}:autoload`;
480
+ return `${e.storagePrefix}:visible`;
484
481
  }
485
482
  function be(e) {
486
- return `${e.storagePrefix}-root`;
483
+ return `${e.storagePrefix}:autoload`;
487
484
  }
488
- const q = O.storagePrefix, L = "toggle-design-token-panel";
489
485
  function we(e) {
490
- return e.storagePrefix === q ? L : e.toggleEvent ?? `toggle-${e.storagePrefix}`;
486
+ return `${e.storagePrefix}-root`;
491
487
  }
492
- const J = "__zdtp:open-state-changed";
488
+ const J = _.storagePrefix, q = "toggle-design-token-panel";
493
489
  function ke(e) {
494
- return `${J}:${e.storagePrefix}`;
490
+ return e.storagePrefix === J ? q : e.toggleEvent ?? `toggle-${e.storagePrefix}`;
495
491
  }
496
- function $e(e, t) {
492
+ const G = "__zdtp:open-state-changed";
493
+ function $e(e) {
494
+ return `${G}:${e.storagePrefix}`;
495
+ }
496
+ function Pe(e, t) {
497
497
  return `${e.modalClassPrefix}${t}`;
498
498
  }
499
499
  function Ce(e) {
500
500
  return `${e.exportFilenameBase}.json`;
501
501
  }
502
- function Pe(e) {
502
+ const O = /* @__PURE__ */ Symbol.for("@takazudo/zdtp:global-alias-marker");
503
+ function Ee(e) {
504
+ if (typeof window > "u") return;
505
+ const t = window, n = t.zdtp;
506
+ if (n !== void 0) {
507
+ if ((typeof n == "object" || typeof n == "function") && n !== null && n[O] === !0) return;
508
+ console.warn(
509
+ "[design-token-panel] window.zdtp already exists and was not installed by this package. Skipping the zdtp.show() / zdtp.hide() / zdtp.toggle() global alias to avoid clobbering it. Use window[consoleNamespace].* or the configurePanel(cfg) handle instead."
510
+ );
511
+ return;
512
+ }
513
+ const a = { ...e };
514
+ a[O] = !0, t.zdtp = a;
515
+ }
516
+ function ve(e) {
503
517
  if (e === null || typeof e != "object" || Array.isArray(e))
504
518
  throw new Error("[design-token-panel] PanelConfig must be a non-null object");
505
519
  const t = e;
@@ -555,10 +569,10 @@ function B(e) {
555
569
  throw new Error(
556
570
  `[design-token-panel] PanelConfig.tabs: duplicate tab id "${a.id}"`
557
571
  );
558
- t.add(a.id), U(a.id, a, e);
572
+ t.add(a.id), W(a.id, a, e);
559
573
  }
560
574
  }
561
- function G(e) {
575
+ function U(e) {
562
576
  if (typeof e == "number" || e === "bg" || e === "fg") return !0;
563
577
  if (e === null || typeof e != "object" || Array.isArray(e)) return !1;
564
578
  const t = e;
@@ -577,18 +591,18 @@ function G(e) {
577
591
  }
578
592
  return !1;
579
593
  }
580
- function U(e, t, n) {
594
+ function W(e, t, n) {
581
595
  if (!Array.isArray(t.tiers))
582
596
  throw new Error(
583
597
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers must be an array`
584
598
  );
585
599
  const a = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Map();
586
- for (const i of t.tiers) {
587
- if (i === null || typeof i != "object" || Array.isArray(i))
600
+ for (const o of t.tiers) {
601
+ if (o === null || typeof o != "object" || Array.isArray(o))
588
602
  throw new Error(
589
603
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers: each tier must be a non-null object`
590
604
  );
591
- const s = i;
605
+ const s = o;
592
606
  if (typeof s.id != "string" || s.id.length === 0)
593
607
  throw new Error(
594
608
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers: each tier must have a non-empty string id`
@@ -608,9 +622,9 @@ function U(e, t, n) {
608
622
  let l;
609
623
  for (const f of s.items) {
610
624
  if (f === null || typeof f != "object" || Array.isArray(f)) continue;
611
- const o = f.type;
612
- if (o === null || typeof o != "object" || Array.isArray(o)) continue;
613
- const u = o.kind;
625
+ const i = f.type;
626
+ if (i === null || typeof i != "object" || Array.isArray(i)) continue;
627
+ const u = i.kind;
614
628
  if (typeof u == "string") {
615
629
  if (l === void 0)
616
630
  l = u;
@@ -623,8 +637,8 @@ function U(e, t, n) {
623
637
  l !== void 0 && g.set(s.id, l);
624
638
  }
625
639
  const c = /* @__PURE__ */ new Set();
626
- for (const i of t.tiers) {
627
- const s = i, l = s.id;
640
+ for (const o of t.tiers) {
641
+ const s = o, l = s.id;
628
642
  for (const f of s.items) {
629
643
  if (f === null || typeof f != "object" || Array.isArray(f))
630
644
  throw new Error(
@@ -647,10 +661,30 @@ function U(e, t, n) {
647
661
  throw new Error(
648
662
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].items["${r.id}"].cssVar must be non-empty after "--"`
649
663
  );
664
+ const i = r.type;
665
+ if (i !== null && typeof i == "object" && !Array.isArray(i) && i.kind === "length" && i.units !== void 0) {
666
+ const u = i.units;
667
+ if (!Array.isArray(u))
668
+ throw new Error(
669
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].items["${r.id}"].type.units must be an array`
670
+ );
671
+ const d = /* @__PURE__ */ new Set();
672
+ for (const p of u) {
673
+ if (typeof p != "string" || p.length === 0)
674
+ throw new Error(
675
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].items["${r.id}"].type.units entries must be non-empty strings (got ${JSON.stringify(p)})`
676
+ );
677
+ if (d.has(p))
678
+ throw new Error(
679
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].items["${r.id}"].type.units: duplicate unit ${JSON.stringify(p)}`
680
+ );
681
+ d.add(p);
682
+ }
683
+ }
650
684
  }
651
685
  }
652
- for (const i of t.tiers) {
653
- const s = i, l = s.id;
686
+ for (const o of t.tiers) {
687
+ const s = o, l = s.id;
654
688
  if (s.referencesTier !== void 0) {
655
689
  if (typeof s.referencesTier != "string")
656
690
  throw new Error(
@@ -661,15 +695,15 @@ function U(e, t, n) {
661
695
  throw new Error(
662
696
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesTier: tier "${f}" does not exist in this tab`
663
697
  );
664
- const r = g.get(l), o = g.get(f);
665
- if (r !== void 0 && o !== void 0 && r !== "text" && r !== o)
698
+ const r = g.get(l), i = g.get(f);
699
+ if (r !== void 0 && i !== void 0 && r !== "text" && r !== i)
666
700
  throw new Error(
667
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesTier: referencing tier has kind "${r}" but referenced tier "${f}" has kind "${o}" (cross-kind reference is only allowed when the referencing tier has kind "text")`
701
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesTier: referencing tier has kind "${r}" but referenced tier "${f}" has kind "${i}" (cross-kind reference is only allowed when the referencing tier has kind "text")`
668
702
  );
669
703
  }
670
704
  }
671
- for (const i of t.tiers) {
672
- const s = i, l = s.id;
705
+ for (const o of t.tiers) {
706
+ const s = o, l = s.id;
673
707
  if (s.referencesRamps === void 0) continue;
674
708
  if (s.semantic !== !0)
675
709
  throw new Error(
@@ -680,89 +714,89 @@ function U(e, t, n) {
680
714
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps must be an array`
681
715
  );
682
716
  const f = g.get(l), r = s.referencesRamps;
683
- for (let o = 0; o < r.length; o++) {
684
- const u = r[o];
717
+ for (let i = 0; i < r.length; i++) {
718
+ const u = r[i];
685
719
  if (u === null || typeof u != "object" || Array.isArray(u))
686
720
  throw new Error(
687
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${o}] must be a non-null object`
721
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${i}] must be a non-null object`
688
722
  );
689
723
  const d = u;
690
724
  if (typeof d.tier != "string" || d.tier.length === 0)
691
725
  throw new Error(
692
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${o}].tier must be a non-empty string`
726
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${i}].tier must be a non-empty string`
693
727
  );
694
728
  if (d.tab !== void 0 && (typeof d.tab != "string" || d.tab.length === 0))
695
729
  throw new Error(
696
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${o}].tab must be a non-empty string when set`
730
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${i}].tab must be a non-empty string when set`
697
731
  );
698
- const m = d.tab === void 0 ? e : d.tab;
732
+ const p = d.tab === void 0 ? e : d.tab;
699
733
  let k;
700
- if (m === e)
734
+ if (p === e)
701
735
  k = t;
702
736
  else {
703
737
  const b = n.find(
704
- (p) => p !== null && typeof p == "object" && !Array.isArray(p) && p.id === m
738
+ (y) => y !== null && typeof y == "object" && !Array.isArray(y) && y.id === p
705
739
  );
706
740
  if (!b) {
707
- const p = n.filter((h) => h !== null && typeof h == "object" && !Array.isArray(h)).map((h) => h.id).join(", ");
741
+ const y = n.filter((h) => h !== null && typeof h == "object" && !Array.isArray(h)).map((h) => h.id).join(", ");
708
742
  throw new Error(
709
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${o}]: tab "${m}" does not exist. Available tabs: ${p}.`
743
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${i}]: tab "${p}" does not exist. Available tabs: ${y}.`
710
744
  );
711
745
  }
712
746
  k = b;
713
747
  }
714
- const C = Array.isArray(k.tiers) ? k.tiers : [], j = [];
715
- let P;
716
- for (const b of C) {
748
+ const P = Array.isArray(k.tiers) ? k.tiers : [], j = [];
749
+ let C;
750
+ for (const b of P) {
717
751
  if (b === null || typeof b != "object" || Array.isArray(b)) continue;
718
- const p = b;
719
- typeof p.id == "string" && (j.push(p.id), p.id === d.tier && (P = p));
752
+ const y = b;
753
+ typeof y.id == "string" && (j.push(y.id), y.id === d.tier && (C = y));
720
754
  }
721
- if (!P)
755
+ if (!C)
722
756
  throw new Error(
723
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${o}]: tier "${d.tier}" does not exist in tab "${m}". Available tiers: ${j.join(", ")}.`
757
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${i}]: tier "${d.tier}" does not exist in tab "${p}". Available tiers: ${j.join(", ")}.`
724
758
  );
725
759
  if (f !== void 0) {
726
- const b = Array.isArray(P.items) ? P.items : [];
727
- let p;
760
+ const b = Array.isArray(C.items) ? C.items : [];
761
+ let y;
728
762
  for (const h of b) {
729
763
  if (h === null || typeof h != "object" || Array.isArray(h)) continue;
730
764
  const E = h.type;
731
765
  if (E === null || typeof E != "object" || Array.isArray(E)) continue;
732
766
  const T = E.kind;
733
767
  if (typeof T == "string") {
734
- p = T;
768
+ y = T;
735
769
  break;
736
770
  }
737
771
  }
738
- if (p !== void 0 && f !== p)
772
+ if (y !== void 0 && f !== y)
739
773
  throw new Error(
740
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${o}]: referencing semantic tier has kind "${f}" but target tier "${d.tier}" in tab "${m}" has kind "${p}" (cross-tab ramp sources must share the semantic tier's kind)`
774
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${i}]: referencing semantic tier has kind "${f}" but target tier "${d.tier}" in tab "${p}" has kind "${y}" (cross-tab ramp sources must share the semantic tier's kind)`
741
775
  );
742
776
  }
743
777
  }
744
778
  }
745
779
  if (t.colorExtras !== void 0) {
746
- const i = t.colorExtras;
747
- if (i === null || typeof i != "object" || Array.isArray(i))
780
+ const o = t.colorExtras;
781
+ if (o === null || typeof o != "object" || Array.isArray(o))
748
782
  throw new Error(
749
783
  `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras must be a plain object`
750
784
  );
751
785
  for (const r of ["id", "defaultShikiTheme"])
752
- if (typeof i[r] != "string" || i[r].length === 0)
786
+ if (typeof o[r] != "string" || o[r].length === 0)
753
787
  throw new Error(
754
- `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.${r} must be a non-empty string (got ${typeof i[r]})`
788
+ `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.${r} must be a non-empty string (got ${typeof o[r]})`
755
789
  );
756
790
  for (const r of ["colorSchemes", "baseRoles", "baseDefaults"])
757
- if (i[r] === void 0 || i[r] === null || typeof i[r] != "object" || Array.isArray(i[r]))
791
+ if (o[r] === void 0 || o[r] === null || typeof o[r] != "object" || Array.isArray(o[r]))
758
792
  throw new Error(
759
793
  `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.${r} must be a plain object`
760
794
  );
761
- if (i.panelSettings === void 0 || i.panelSettings === null || typeof i.panelSettings != "object" || Array.isArray(i.panelSettings))
795
+ if (o.panelSettings === void 0 || o.panelSettings === null || typeof o.panelSettings != "object" || Array.isArray(o.panelSettings))
762
796
  throw new Error(
763
797
  `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings must be a plain object`
764
798
  );
765
- const s = i.panelSettings;
799
+ const s = o.panelSettings;
766
800
  if (typeof s.colorScheme != "string" || s.colorScheme.length === 0)
767
801
  throw new Error(
768
802
  `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorScheme must be a non-empty string`
@@ -773,104 +807,128 @@ function U(e, t, n) {
773
807
  `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode must be false or a plain object`
774
808
  );
775
809
  const r = s.colorMode;
776
- for (const o of ["lightScheme", "darkScheme"])
777
- if (typeof r[o] != "string" || r[o].length === 0)
810
+ for (const i of ["lightScheme", "darkScheme"])
811
+ if (typeof r[i] != "string" || r[i].length === 0)
778
812
  throw new Error(
779
- `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode.${o} must be a non-empty string`
813
+ `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode.${i} must be a non-empty string`
780
814
  );
781
815
  if (r.defaultMode !== "light" && r.defaultMode !== "dark")
782
816
  throw new Error(
783
817
  `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode.defaultMode must be "light" or "dark" (got ${JSON.stringify(r.defaultMode)})`
784
818
  );
785
819
  }
786
- if (i.semanticDefaults !== void 0) {
787
- if (i.semanticDefaults === null || typeof i.semanticDefaults != "object" || Array.isArray(i.semanticDefaults))
820
+ if (o.semanticDefaults !== void 0) {
821
+ if (o.semanticDefaults === null || typeof o.semanticDefaults != "object" || Array.isArray(o.semanticDefaults))
788
822
  throw new Error(
789
823
  `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.semanticDefaults must be a plain object`
790
824
  );
791
- const r = i.semanticDefaults;
792
- for (const [o, u] of Object.entries(r))
793
- if (!G(u))
825
+ const r = o.semanticDefaults;
826
+ for (const [i, u] of Object.entries(r))
827
+ if (!U(u))
794
828
  throw new Error(
795
- `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.semanticDefaults["${o}"] must be a valid SemanticValue (number | 'bg' | 'fg' | { literal: string } | { literal: { light, dark } } | { ref: { tier, item, tab? } }), got ${JSON.stringify(u)}`
829
+ `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.semanticDefaults["${i}"] must be a valid SemanticValue (number | 'bg' | 'fg' | { literal: string } | { literal: { light, dark } } | { ref: { tier, item, tab? } }), got ${JSON.stringify(u)}`
796
830
  );
797
831
  }
798
832
  const f = t.tiers.find((r) => {
799
833
  if (r.referencesTier !== void 0 || r.semantic === !0) return !1;
800
- const o = r.items;
801
- if (!Array.isArray(o) || o.length === 0) return !1;
802
- const u = o[0];
834
+ const i = r.items;
835
+ if (!Array.isArray(i) || i.length === 0) return !1;
836
+ const u = i[0];
803
837
  if (u === null || typeof u != "object" || Array.isArray(u)) return !1;
804
838
  const d = u.type;
805
839
  return d === null || typeof d != "object" || Array.isArray(d) ? !1 : d.kind === "color";
806
840
  });
807
841
  if (f) {
808
- const r = f.id, o = f.items, u = o[0]?.cssVar;
842
+ const r = f.id, i = f.items, u = i[0]?.cssVar;
809
843
  if (u !== void 0) {
810
844
  const d = u.replace(/\d+$/, "{n}");
811
845
  if (d.includes("{n}"))
812
- for (let m = 0; m < o.length; m++) {
813
- const k = o[m], C = d.replace("{n}", String(m));
814
- if (k.cssVar !== C)
846
+ for (let p = 0; p < i.length; p++) {
847
+ const k = i[p], P = d.replace("{n}", String(p));
848
+ if (k.cssVar !== P)
815
849
  throw new Error(
816
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r}"].items[${m}].cssVar is ${JSON.stringify(k.cssVar)} but expected ${JSON.stringify(C)} — palette item cssVars must share one prefix and be numbered 0..n-1 in tier order (template derived from first item: ${JSON.stringify(d)})`
850
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r}"].items[${p}].cssVar is ${JSON.stringify(k.cssVar)} but expected ${JSON.stringify(P)} — palette item cssVars must share one prefix and be numbered 0..n-1 in tier order (template derived from first item: ${JSON.stringify(d)})`
817
851
  );
818
852
  }
819
- else if (o.length > 1)
853
+ else if (i.length > 1)
820
854
  throw new Error(
821
855
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r}"].items[0].cssVar ${JSON.stringify(u)} has no trailing digit — palette item cssVars must share one prefix and be numbered 0..n-1 in tier order (e.g. "--pal-0" … "--pal-15")`
822
856
  );
823
857
  }
824
858
  }
825
859
  }
860
+ if (e === "notes") {
861
+ if (t.tiers.length > 0)
862
+ throw new Error(
863
+ '[design-token-panel] PanelConfig.tabs["notes"].tiers must be empty — the notes tab does not hold token tiers'
864
+ );
865
+ if (t.colorExtras !== void 0)
866
+ throw new Error(
867
+ '[design-token-panel] PanelConfig.tabs["notes"].colorExtras must not be set — the notes tab does not carry token config'
868
+ );
869
+ if (t.notesExtras === void 0 || t.notesExtras === null || typeof t.notesExtras != "object" || Array.isArray(t.notesExtras))
870
+ throw new Error(
871
+ '[design-token-panel] PanelConfig.tabs["notes"].notesExtras must be a plain object with { title, html }'
872
+ );
873
+ const o = t.notesExtras;
874
+ for (const s of ["title", "html"])
875
+ if (typeof o[s] != "string" || o[s].length === 0)
876
+ throw new Error(
877
+ `[design-token-panel] PanelConfig.tabs["notes"].notesExtras.${s} must be a non-empty string (got ${typeof o[s]})`
878
+ );
879
+ } else if (t.notesExtras !== void 0)
880
+ throw new Error(
881
+ `[design-token-panel] PanelConfig.tabs["${e}"].notesExtras must only be set on a tab with id "notes"`
882
+ );
826
883
  }
827
- function Ee(e = _()) {
884
+ function Ae(e = D()) {
828
885
  return e.applyRouting ?? {};
829
886
  }
830
- function ve(e) {
887
+ function Se(e) {
831
888
  const t = x();
832
889
  if (t === null) {
833
- y().pendingColorPresets = e;
890
+ m().pendingColorPresets = e;
834
891
  return;
835
892
  }
836
893
  t.config = { ...t.config, colorPresets: e };
837
894
  }
838
895
  export {
839
- te as A,
840
- ne as B,
841
- be as C,
842
- L as D,
843
- X as E,
844
- oe as F,
845
- pe as G,
846
- ye as H,
847
- ie as I,
848
- se as J,
849
- re as _,
850
- me as a,
851
- le as b,
852
- Z as c,
853
- fe as d,
854
- ce as e,
855
- Pe as f,
856
- _ as g,
857
- ue as h,
858
- de as i,
859
- ge as j,
860
- he as k,
861
- S as l,
862
- D as m,
863
- Ce as n,
864
- $e as o,
865
- W as p,
866
- Y as q,
867
- I as r,
868
- ve as s,
869
- ae as t,
870
- Ee as u,
871
- V as v,
872
- ke as w,
873
- Q as x,
874
- ee as y,
875
- we as z
896
+ Pe as A,
897
+ Ae as B,
898
+ V as C,
899
+ $e as D,
900
+ I as E,
901
+ te as F,
902
+ ke as G,
903
+ q as H,
904
+ ne as I,
905
+ re as J,
906
+ we as K,
907
+ ie as _,
908
+ he as a,
909
+ fe as b,
910
+ ee as c,
911
+ ce as d,
912
+ ge as e,
913
+ ve as f,
914
+ D as g,
915
+ de as h,
916
+ Ee as i,
917
+ pe as j,
918
+ ue as k,
919
+ be as l,
920
+ se as m,
921
+ le as n,
922
+ Y as o,
923
+ Z as p,
924
+ ye as q,
925
+ Q as r,
926
+ Se as s,
927
+ me as t,
928
+ X as u,
929
+ oe as v,
930
+ ae as w,
931
+ M as x,
932
+ S as y,
933
+ Ce as z
876
934
  };