@takazudo/zdtp 0.4.7 → 0.4.8

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 (35) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/astro/host-adapter.js +42 -42
  3. package/dist/astro/index.js +1 -1
  4. package/dist/autoload-state-CFmRjtD-.js +64 -0
  5. package/dist/config/panel-config.d.ts +21 -0
  6. package/dist/controls/actions-menu-popover.d.ts +3 -2
  7. package/dist/dom-tweaker/dom-tweaker-context.d.ts +21 -0
  8. package/dist/dom-tweaker/dom-tweaker-diff-action-link.d.ts +7 -0
  9. package/dist/dom-tweaker/dom-tweaker-orchestrator.d.ts +17 -0
  10. package/dist/dom-tweaker/dom-tweaker-state.d.ts +18 -0
  11. package/dist/dom-tweaker/dom-tweaker-toggle-button.d.ts +9 -0
  12. package/dist/dom-tweaker/lazy/class-editor-popup.d.ts +14 -0
  13. package/dist/dom-tweaker/lazy/diff-export-modal.d.ts +10 -0
  14. package/dist/dom-tweaker/lazy/edit-session.d.ts +19 -0
  15. package/dist/dom-tweaker/lazy/index.d.ts +24 -0
  16. package/dist/dom-tweaker/lazy/pinned-selection-overlay.d.ts +31 -0
  17. package/dist/dom-tweaker/lazy/style-injection.d.ts +2 -0
  18. package/dist/dom-tweaker/lazy/suggestions.d.ts +32 -0
  19. package/dist/dom-tweaker/lazy/tailwind-runtime.d.ts +20 -0
  20. package/dist/element-path/inspector-overlay.d.ts +10 -9
  21. package/dist/highlight/find-elements.d.ts +4 -3
  22. package/dist/index-DTyUiYcC.js +7457 -0
  23. package/dist/index-DXSiRW1w.js +4141 -0
  24. package/dist/index.global-Cc-vinUf.js +5387 -0
  25. package/dist/index.global-DdZgM26F.js +4 -0
  26. package/dist/index.js +35 -7186
  27. package/dist/{panel-config-Bw7D-25C.js → panel-config-BNLlUc_r.js} +232 -212
  28. package/dist/picker/alt-click-picker.d.ts +51 -0
  29. package/dist/picker/arming-coordinator.d.ts +16 -0
  30. package/dist/picker/index.d.ts +4 -0
  31. package/dist/testing.js +2 -2
  32. package/dist/{tweak-state-CD1y56zR.js → tweak-state-Dti6XMoQ.js} +1 -1
  33. package/dist/zdtp.css +1 -1
  34. package/package.json +4 -2
  35. package/dist/autoload-state-D26ML6sW.js +0 -46
@@ -1,6 +1,6 @@
1
- class w extends Error {
1
+ class b extends Error {
2
2
  constructor(t) {
3
- super(t), this.name = "TierResolverError", Object.setPrototypeOf(this, w.prototype);
3
+ super(t), this.name = "TierResolverError", Object.setPrototypeOf(this, b.prototype);
4
4
  }
5
5
  }
6
6
  function A(e, t) {
@@ -9,55 +9,55 @@ function A(e, t) {
9
9
  function $(e, t) {
10
10
  return e.items.find((n) => n.id === t);
11
11
  }
12
- function Y(e, t, n, a) {
12
+ function Y(e, t, n, i) {
13
13
  const g = A(e, t);
14
14
  if (!g)
15
- throw new w(
15
+ throw new b(
16
16
  `Tier "${t}" not found in tab "${e.id}". Available tiers: ${e.tiers.map((l) => l.id).join(", ")}.`
17
17
  );
18
18
  const c = $(g, n);
19
19
  if (!c)
20
- throw new w(
20
+ throw new b(
21
21
  `Item "${n}" not found in tier "${t}" of tab "${e.id}".`
22
22
  );
23
- const s = a[t]?.[n];
23
+ const a = i[t]?.[n];
24
24
  if (g.referencesTier !== void 0) {
25
25
  const l = g.referencesTier, f = A(e, l);
26
26
  if (!f)
27
- throw new w(
27
+ throw new b(
28
28
  `Tier "${t}" declares referencesTier "${l}" but that tier does not exist in tab "${e.id}".`
29
29
  );
30
- const i = $(f, s ?? n);
31
- if (!i) {
32
- const u = $(f, c.default) ?? $(f, n) ?? f.items[0];
33
- if (!u)
34
- throw new w(
30
+ const o = $(f, a ?? n);
31
+ if (!o) {
32
+ const d = $(f, c.default) ?? $(f, n) ?? f.items[0];
33
+ if (!d)
34
+ throw new b(
35
35
  `Referenced tier "${l}" has no items; cannot resolve fallback for item "${n}" in tier "${t}" of tab "${e.id}".`
36
36
  );
37
- return { kind: "ref", targetCssVar: u.cssVar };
37
+ return { kind: "ref", targetCssVar: d.cssVar };
38
38
  }
39
- return { kind: "ref", targetCssVar: i.cssVar };
39
+ return { kind: "ref", targetCssVar: o.cssVar };
40
40
  }
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 };
41
+ return a !== void 0 ? c.pill && a === c.pill.value ? { kind: "literal", value: c.pill.value } : { kind: "literal", value: a } : c.pill ? { kind: "literal", value: c.pill.customDefault } : { kind: "literal", value: c.default };
42
42
  }
43
43
  function Z(e) {
44
44
  return e.kind === "literal" ? e.value : `var(${e.targetCssVar})`;
45
45
  }
46
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
- if (!a)
49
- throw new w(
50
- `Cross-tab ref target tab "${e.tab}" not found. Available tabs: ${n.map((o) => o.id).join(", ")}.`
47
+ const i = e.tab === void 0 || e.tab === t.id ? t : n.find((s) => s.id === e.tab);
48
+ if (!i)
49
+ throw new b(
50
+ `Cross-tab ref target tab "${e.tab}" not found. Available tabs: ${n.map((s) => s.id).join(", ")}.`
51
51
  );
52
- const g = A(a, e.tier);
52
+ const g = A(i, e.tier);
53
53
  if (!g)
54
- throw new w(
55
- `Cross-tab ref target tier "${e.tier}" not found in tab "${a.id}". Available tiers: ${a.tiers.map((o) => o.id).join(", ")}.`
54
+ throw new b(
55
+ `Cross-tab ref target tier "${e.tier}" not found in tab "${i.id}". Available tiers: ${i.tiers.map((s) => s.id).join(", ")}.`
56
56
  );
57
57
  const c = $(g, e.item);
58
58
  if (!c)
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((o) => o.id).join(", ")}.`
59
+ throw new b(
60
+ `Cross-tab ref target item "${e.item}" not found in tier "${e.tier}" of tab "${i.id}". Available items: ${g.items.map((s) => s.id).join(", ")}.`
61
61
  );
62
62
  return c.cssVar;
63
63
  }
@@ -224,36 +224,36 @@ const N = /* @__PURE__ */ new Set([
224
224
  function z(e) {
225
225
  return e.startsWith("#") || e.includes("(") || N.has(e.toLowerCase());
226
226
  }
227
- function H(e, t, n, a) {
227
+ function H(e, t, n, i) {
228
228
  const g = [], c = e.indexOf(":");
229
229
  if (c !== -1) {
230
- const s = e.slice(0, c), l = e.slice(c + 1), f = t.find((r) => r.tier === s);
230
+ const a = e.slice(0, c), l = e.slice(c + 1), f = t.find((r) => r.tier === a);
231
231
  f && g.push({ tab: f.tab, tier: f.tier, item: l });
232
232
  }
233
- const [o] = t;
234
- g.push({ tab: o.tab, tier: o.tier, item: e });
235
- for (const s of g)
233
+ const [s] = t;
234
+ g.push({ tab: s.tab, tier: s.tier, item: e });
235
+ for (const a of g)
236
236
  try {
237
- return M(s, n, a), { ref: s };
237
+ return M(a, n, i), { ref: a };
238
238
  } catch {
239
239
  }
240
240
  return { ref: g[0] };
241
241
  }
242
- function K(e, t, n, a, g, c) {
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(
242
+ function K(e, t, n, i, g, c) {
243
+ const s = t.get(e.default);
244
+ return s !== void 0 ? s : e.default === "bg" || e.default === "fg" ? e.default : n && n.length > 0 && !z(e.default) ? H(e.default, n, i, 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
  }
248
248
  function V(e, t = [e]) {
249
249
  const n = e.colorExtras;
250
250
  if (!n) return;
251
- const a = e.tiers.find(
252
- (i) => !i.referencesTier && !i.semantic && i.items.length > 0 && i.items[0].type.kind === "color"
251
+ const i = e.tiers.find(
252
+ (o) => !o.referencesTier && !o.semantic && o.items.length > 0 && o.items[0].type.kind === "color"
253
253
  ), g = e.tiers.find(
254
- (i) => a && i.referencesTier === a.id || i.semantic === !0
254
+ (o) => i && o.referencesTier === i.id || o.semantic === !0
255
255
  );
256
- if (!a && !g)
256
+ if (!i && !g)
257
257
  return {
258
258
  id: n.id,
259
259
  label: n.label,
@@ -267,28 +267,28 @@ function V(e, t = [e]) {
267
267
  colorSchemes: n.colorSchemes,
268
268
  panelSettings: n.panelSettings
269
269
  };
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);
270
+ const c = i?.items ?? [], s = c.length, a = 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);
273
273
  const f = {}, r = {};
274
274
  if (g) {
275
- const i = !g.semantic, u = n.semanticDefaults;
276
- for (const d of g.items)
277
- r[d.id] = d.cssVar, f[d.id] = u && d.id in u ? u[d.id] : K(
278
- d,
275
+ const o = !g.semantic, d = n.semanticDefaults;
276
+ for (const u of g.items)
277
+ r[u.id] = u.cssVar, f[u.id] = d && u.id in d ? d[u.id] : K(
278
+ u,
279
279
  l,
280
280
  g.referencesRamps,
281
281
  e,
282
282
  t,
283
- i
283
+ o
284
284
  );
285
285
  }
286
286
  return {
287
287
  id: n.id,
288
288
  label: n.label,
289
- paletteSize: o,
289
+ paletteSize: s,
290
290
  baseRoles: n.baseRoles,
291
- paletteCssVarTemplate: s,
291
+ paletteCssVarTemplate: a,
292
292
  semanticDefaults: f,
293
293
  semanticCssNames: r,
294
294
  baseDefaults: n.baseDefaults,
@@ -316,9 +316,9 @@ function S(e, t) {
316
316
  return !0;
317
317
  }
318
318
  if (Array.isArray(t)) return !1;
319
- const n = Object.keys(e), a = Object.keys(t);
320
- if (n.length !== a.length) return !1;
321
- const g = new Set(a);
319
+ const n = Object.keys(e), i = Object.keys(t);
320
+ if (n.length !== i.length) return !1;
321
+ const g = new Set(i);
322
322
  for (const c of n)
323
323
  if (!g.has(c) || !S(e[c], t[c]))
324
324
  return !1;
@@ -381,19 +381,19 @@ function I(e) {
381
381
  };
382
382
  }
383
383
  function ee(e) {
384
- const t = m(), n = e.storagePrefix, a = t.instances.get(n);
385
- if (a) {
384
+ const t = m(), n = e.storagePrefix, i = t.instances.get(n);
385
+ if (i) {
386
386
  const f = (r) => ({ ...r, applySink: void 0 });
387
- if (S(f(a.suppliedConfig), f(e)))
388
- return t.defaultPrefix = n, a.handle;
387
+ if (S(f(i.suppliedConfig), f(e)))
388
+ return t.defaultPrefix = n, i.handle;
389
389
  throw new Error(
390
390
  `[design-token-panel] configurePanel() was already called with different values for storagePrefix "${n}". Configuration is one-shot per prefix per page lifecycle. To re-configure this prefix, call handle.destroy() first, then configurePanel() again. (Use a distinct storagePrefix for a second panel instance.)`
391
391
  );
392
392
  }
393
393
  const g = t.pendingColorPresets, c = g ? { ...e, colorPresets: g } : { ...e };
394
394
  t.pendingColorPresets = null;
395
- const o = t.instances.size === 0, s = o ? [...t.pendingPostConfigureHooks] : [];
396
- o && (t.pendingPostConfigureHooks.length = 0);
395
+ const s = t.instances.size === 0, a = s ? [...t.pendingPostConfigureHooks] : [];
396
+ s && (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
@@ -401,7 +401,7 @@ function ee(e) {
401
401
  // config keep passing even after setPanelColorPresets mutates `config`.
402
402
  suppliedConfig: { ...e },
403
403
  pendingColorPresets: null,
404
- postConfigureHooks: s,
404
+ postConfigureHooks: a,
405
405
  handle: F(n)
406
406
  };
407
407
  t.instances.set(n, l), t.defaultPrefix = n;
@@ -432,7 +432,7 @@ function ne() {
432
432
  function re(e) {
433
433
  return m().instances.get(e)?.config ?? null;
434
434
  }
435
- function ie() {
435
+ function oe() {
436
436
  const e = m();
437
437
  e.instances.clear(), e.defaultPrefix = null, e.pendingColorPresets = null, e.pendingPostConfigureHooks.length = 0, v().clear();
438
438
  }
@@ -440,7 +440,7 @@ function v() {
440
440
  const e = m();
441
441
  return e.colorSchemeOwners || (e.colorSchemeOwners = /* @__PURE__ */ new Set()), e.colorSchemeOwners;
442
442
  }
443
- function oe(e) {
443
+ function ie(e) {
444
444
  v().add(e);
445
445
  }
446
446
  function se(e) {
@@ -461,10 +461,10 @@ function ce(e) {
461
461
  function ge(e) {
462
462
  return `${e.storagePrefix}-state-v4`;
463
463
  }
464
- function ue(e) {
464
+ function de(e) {
465
465
  return `${e.storagePrefix}-state`;
466
466
  }
467
- function de(e) {
467
+ function ue(e) {
468
468
  return `${e.storagePrefix}-open`;
469
469
  }
470
470
  function pe(e) {
@@ -479,10 +479,10 @@ function me(e) {
479
479
  function he(e) {
480
480
  return `${e.storagePrefix}:visible`;
481
481
  }
482
- function be(e) {
482
+ function we(e) {
483
483
  return `${e.storagePrefix}:autoload`;
484
484
  }
485
- function we(e) {
485
+ function be(e) {
486
486
  return `${e.storagePrefix}-root`;
487
487
  }
488
488
  const J = _.storagePrefix, q = "toggle-design-token-panel";
@@ -493,10 +493,10 @@ const G = "__zdtp:open-state-changed";
493
493
  function $e(e) {
494
494
  return `${G}:${e.storagePrefix}`;
495
495
  }
496
- function Pe(e, t) {
496
+ function Ce(e, t) {
497
497
  return `${e.modalClassPrefix}${t}`;
498
498
  }
499
- function Ce(e) {
499
+ function Pe(e) {
500
500
  return `${e.exportFilenameBase}.json`;
501
501
  }
502
502
  const O = /* @__PURE__ */ Symbol.for("@takazudo/zdtp:global-alias-marker");
@@ -510,8 +510,8 @@ function Ee(e) {
510
510
  );
511
511
  return;
512
512
  }
513
- const a = { ...e };
514
- a[O] = !0, t.zdtp = a;
513
+ const i = { ...e };
514
+ i[O] = !0, t.zdtp = i;
515
515
  }
516
516
  function ve(e) {
517
517
  if (e === null || typeof e != "object" || Array.isArray(e))
@@ -539,19 +539,39 @@ function ve(e) {
539
539
  if (t.applyRouting !== void 0) {
540
540
  if (t.applyRouting === null || typeof t.applyRouting != "object" || Array.isArray(t.applyRouting))
541
541
  throw new Error("[design-token-panel] PanelConfig.applyRouting must be a plain object");
542
- for (const [n, a] of Object.entries(t.applyRouting))
543
- if (typeof a != "string")
542
+ for (const [n, i] of Object.entries(t.applyRouting))
543
+ if (typeof i != "string")
544
544
  throw new Error(
545
545
  `[design-token-panel] PanelConfig.applyRouting[${JSON.stringify(n)}] must be a string`
546
546
  );
547
547
  }
548
+ if (t.domTweaker !== void 0) {
549
+ if (t.domTweaker === null || typeof t.domTweaker != "object" || Array.isArray(t.domTweaker))
550
+ throw new Error("[design-token-panel] PanelConfig.domTweaker must be a plain object");
551
+ const n = t.domTweaker;
552
+ for (const i of Object.keys(n))
553
+ if (i !== "themeCss")
554
+ throw new Error(
555
+ `[design-token-panel] PanelConfig.domTweaker.${i} is not a supported field`
556
+ );
557
+ if (n.themeCss !== void 0) {
558
+ if (typeof n.themeCss != "string")
559
+ throw new Error(
560
+ `[design-token-panel] PanelConfig.domTweaker.themeCss must be a string when set (got ${typeof n.themeCss})`
561
+ );
562
+ if (/@import/i.test(n.themeCss))
563
+ throw new Error(
564
+ "[design-token-panel] PanelConfig.domTweaker.themeCss must not contain @import"
565
+ );
566
+ }
567
+ }
548
568
  if (t.legacyIdRenameMap !== void 0) {
549
569
  if (t.legacyIdRenameMap === null || typeof t.legacyIdRenameMap != "object" || Array.isArray(t.legacyIdRenameMap))
550
570
  throw new Error("[design-token-panel] PanelConfig.legacyIdRenameMap must be a plain object");
551
- for (const [n, a] of Object.entries(t.legacyIdRenameMap))
552
- if (a !== null && typeof a != "string")
571
+ for (const [n, i] of Object.entries(t.legacyIdRenameMap))
572
+ if (i !== null && typeof i != "string")
553
573
  throw new Error(
554
- `[design-token-panel] PanelConfig.legacyIdRenameMap[${JSON.stringify(n)}] must be a string or null (got ${typeof a})`
574
+ `[design-token-panel] PanelConfig.legacyIdRenameMap[${JSON.stringify(n)}] must be a string or null (got ${typeof i})`
555
575
  );
556
576
  }
557
577
  }
@@ -562,14 +582,14 @@ function B(e) {
562
582
  for (const n of e) {
563
583
  if (n === null || typeof n != "object" || Array.isArray(n))
564
584
  throw new Error("[design-token-panel] PanelConfig.tabs: each tab must be a non-null object");
565
- const a = n;
566
- if (typeof a.id != "string" || a.id.length === 0)
585
+ const i = n;
586
+ if (typeof i.id != "string" || i.id.length === 0)
567
587
  throw new Error("[design-token-panel] PanelConfig.tabs: each tab must have a non-empty string id");
568
- if (t.has(a.id))
588
+ if (t.has(i.id))
569
589
  throw new Error(
570
- `[design-token-panel] PanelConfig.tabs: duplicate tab id "${a.id}"`
590
+ `[design-token-panel] PanelConfig.tabs: duplicate tab id "${i.id}"`
571
591
  );
572
- t.add(a.id), W(a.id, a, e);
592
+ t.add(i.id), W(i.id, i, e);
573
593
  }
574
594
  }
575
595
  function U(e) {
@@ -580,14 +600,14 @@ function U(e) {
580
600
  const n = t.literal;
581
601
  if (typeof n == "string") return !0;
582
602
  if (n === null || typeof n != "object" || Array.isArray(n)) return !1;
583
- const a = n;
584
- return typeof a.light == "string" && typeof a.dark == "string";
603
+ const i = n;
604
+ return typeof i.light == "string" && typeof i.dark == "string";
585
605
  }
586
606
  if ("ref" in t) {
587
607
  const n = t.ref;
588
608
  if (n === null || typeof n != "object" || Array.isArray(n)) return !1;
589
- const a = n;
590
- return !(typeof a.tier != "string" || typeof a.item != "string" || a.tab !== void 0 && typeof a.tab != "string");
609
+ const i = n;
610
+ return !(typeof i.tier != "string" || typeof i.item != "string" || i.tab !== void 0 && typeof i.tab != "string");
591
611
  }
592
612
  return !1;
593
613
  }
@@ -596,50 +616,50 @@ function W(e, t, n) {
596
616
  throw new Error(
597
617
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers must be an array`
598
618
  );
599
- const a = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Map();
600
- for (const o of t.tiers) {
601
- if (o === null || typeof o != "object" || Array.isArray(o))
619
+ const i = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Map();
620
+ for (const s of t.tiers) {
621
+ if (s === null || typeof s != "object" || Array.isArray(s))
602
622
  throw new Error(
603
623
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers: each tier must be a non-null object`
604
624
  );
605
- const s = o;
606
- if (typeof s.id != "string" || s.id.length === 0)
625
+ const a = s;
626
+ if (typeof a.id != "string" || a.id.length === 0)
607
627
  throw new Error(
608
628
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers: each tier must have a non-empty string id`
609
629
  );
610
- if (a.has(s.id))
630
+ if (i.has(a.id))
611
631
  throw new Error(
612
- `[design-token-panel] PanelConfig.tabs["${e}"]: duplicate tier id "${s.id}"`
632
+ `[design-token-panel] PanelConfig.tabs["${e}"]: duplicate tier id "${a.id}"`
613
633
  );
614
- if (a.add(s.id), s.semantic !== void 0 && s.semantic !== !0)
634
+ if (i.add(a.id), a.semantic !== void 0 && a.semantic !== !0)
615
635
  throw new Error(
616
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${s.id}"].semantic must be exactly \`true\` when present (got ${JSON.stringify(s.semantic)})`
636
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${a.id}"].semantic must be exactly \`true\` when present (got ${JSON.stringify(a.semantic)})`
617
637
  );
618
- if (!Array.isArray(s.items))
638
+ if (!Array.isArray(a.items))
619
639
  throw new Error(
620
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${s.id}"].items must be an array`
640
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${a.id}"].items must be an array`
621
641
  );
622
642
  let l;
623
- for (const f of s.items) {
643
+ for (const f of a.items) {
624
644
  if (f === null || typeof f != "object" || Array.isArray(f)) continue;
625
- const i = f.type;
626
- if (i === null || typeof i != "object" || Array.isArray(i)) continue;
627
- const u = i.kind;
628
- if (typeof u == "string") {
645
+ const o = f.type;
646
+ if (o === null || typeof o != "object" || Array.isArray(o)) continue;
647
+ const d = o.kind;
648
+ if (typeof d == "string") {
629
649
  if (l === void 0)
630
- l = u;
631
- else if (l !== u)
650
+ l = d;
651
+ else if (l !== d)
632
652
  throw new Error(
633
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${s.id}"]: mixed item kinds — found "${l}" and "${u}" in the same tier (all items must share the same kind)`
653
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${a.id}"]: mixed item kinds — found "${l}" and "${d}" in the same tier (all items must share the same kind)`
634
654
  );
635
655
  }
636
656
  }
637
- l !== void 0 && g.set(s.id, l);
657
+ l !== void 0 && g.set(a.id, l);
638
658
  }
639
659
  const c = /* @__PURE__ */ new Set();
640
- for (const o of t.tiers) {
641
- const s = o, l = s.id;
642
- for (const f of s.items) {
660
+ for (const s of t.tiers) {
661
+ const a = s, l = a.id;
662
+ for (const f of a.items) {
643
663
  if (f === null || typeof f != "object" || Array.isArray(f))
644
664
  throw new Error(
645
665
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].items: each item must be a non-null object`
@@ -661,198 +681,198 @@ function W(e, t, n) {
661
681
  throw new Error(
662
682
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].items["${r.id}"].cssVar must be non-empty after "--"`
663
683
  );
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))
684
+ const o = r.type;
685
+ if (o !== null && typeof o == "object" && !Array.isArray(o) && o.kind === "length" && o.units !== void 0) {
686
+ const d = o.units;
687
+ if (!Array.isArray(d))
668
688
  throw new Error(
669
689
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].items["${r.id}"].type.units must be an array`
670
690
  );
671
- const d = /* @__PURE__ */ new Set();
672
- for (const p of u) {
691
+ const u = /* @__PURE__ */ new Set();
692
+ for (const p of d) {
673
693
  if (typeof p != "string" || p.length === 0)
674
694
  throw new Error(
675
695
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].items["${r.id}"].type.units entries must be non-empty strings (got ${JSON.stringify(p)})`
676
696
  );
677
- if (d.has(p))
697
+ if (u.has(p))
678
698
  throw new Error(
679
699
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].items["${r.id}"].type.units: duplicate unit ${JSON.stringify(p)}`
680
700
  );
681
- d.add(p);
701
+ u.add(p);
682
702
  }
683
703
  }
684
704
  }
685
705
  }
686
- for (const o of t.tiers) {
687
- const s = o, l = s.id;
688
- if (s.referencesTier !== void 0) {
689
- if (typeof s.referencesTier != "string")
706
+ for (const s of t.tiers) {
707
+ const a = s, l = a.id;
708
+ if (a.referencesTier !== void 0) {
709
+ if (typeof a.referencesTier != "string")
690
710
  throw new Error(
691
711
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesTier must be a string`
692
712
  );
693
- const f = s.referencesTier;
694
- if (!a.has(f))
713
+ const f = a.referencesTier;
714
+ if (!i.has(f))
695
715
  throw new Error(
696
716
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesTier: tier "${f}" does not exist in this tab`
697
717
  );
698
- const r = g.get(l), i = g.get(f);
699
- if (r !== void 0 && i !== void 0 && r !== "text" && r !== i)
718
+ const r = g.get(l), o = g.get(f);
719
+ if (r !== void 0 && o !== void 0 && r !== "text" && r !== o)
700
720
  throw new Error(
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")`
721
+ `[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")`
702
722
  );
703
723
  }
704
724
  }
705
- for (const o of t.tiers) {
706
- const s = o, l = s.id;
707
- if (s.referencesRamps === void 0) continue;
708
- if (s.semantic !== !0)
725
+ for (const s of t.tiers) {
726
+ const a = s, l = a.id;
727
+ if (a.referencesRamps === void 0) continue;
728
+ if (a.semantic !== !0)
709
729
  throw new Error(
710
730
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps is only valid on a tier with semantic: true`
711
731
  );
712
- if (!Array.isArray(s.referencesRamps))
732
+ if (!Array.isArray(a.referencesRamps))
713
733
  throw new Error(
714
734
  `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps must be an array`
715
735
  );
716
- const f = g.get(l), r = s.referencesRamps;
717
- for (let i = 0; i < r.length; i++) {
718
- const u = r[i];
719
- if (u === null || typeof u != "object" || Array.isArray(u))
736
+ const f = g.get(l), r = a.referencesRamps;
737
+ for (let o = 0; o < r.length; o++) {
738
+ const d = r[o];
739
+ if (d === null || typeof d != "object" || Array.isArray(d))
720
740
  throw new Error(
721
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${i}] must be a non-null object`
741
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${o}] must be a non-null object`
722
742
  );
723
- const d = u;
724
- if (typeof d.tier != "string" || d.tier.length === 0)
743
+ const u = d;
744
+ if (typeof u.tier != "string" || u.tier.length === 0)
725
745
  throw new Error(
726
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${i}].tier must be a non-empty string`
746
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${o}].tier must be a non-empty string`
727
747
  );
728
- if (d.tab !== void 0 && (typeof d.tab != "string" || d.tab.length === 0))
748
+ if (u.tab !== void 0 && (typeof u.tab != "string" || u.tab.length === 0))
729
749
  throw new Error(
730
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${i}].tab must be a non-empty string when set`
750
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${o}].tab must be a non-empty string when set`
731
751
  );
732
- const p = d.tab === void 0 ? e : d.tab;
752
+ const p = u.tab === void 0 ? e : u.tab;
733
753
  let k;
734
754
  if (p === e)
735
755
  k = t;
736
756
  else {
737
- const b = n.find(
757
+ const w = n.find(
738
758
  (y) => y !== null && typeof y == "object" && !Array.isArray(y) && y.id === p
739
759
  );
740
- if (!b) {
760
+ if (!w) {
741
761
  const y = n.filter((h) => h !== null && typeof h == "object" && !Array.isArray(h)).map((h) => h.id).join(", ");
742
762
  throw new Error(
743
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${i}]: tab "${p}" does not exist. Available tabs: ${y}.`
763
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${o}]: tab "${p}" does not exist. Available tabs: ${y}.`
744
764
  );
745
765
  }
746
- k = b;
766
+ k = w;
747
767
  }
748
- const P = Array.isArray(k.tiers) ? k.tiers : [], j = [];
749
- let C;
750
- for (const b of P) {
751
- if (b === null || typeof b != "object" || Array.isArray(b)) continue;
752
- const y = b;
753
- typeof y.id == "string" && (j.push(y.id), y.id === d.tier && (C = y));
768
+ const C = Array.isArray(k.tiers) ? k.tiers : [], T = [];
769
+ let P;
770
+ for (const w of C) {
771
+ if (w === null || typeof w != "object" || Array.isArray(w)) continue;
772
+ const y = w;
773
+ typeof y.id == "string" && (T.push(y.id), y.id === u.tier && (P = y));
754
774
  }
755
- if (!C)
775
+ if (!P)
756
776
  throw new Error(
757
- `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${i}]: tier "${d.tier}" does not exist in tab "${p}". Available tiers: ${j.join(", ")}.`
777
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${o}]: tier "${u.tier}" does not exist in tab "${p}". Available tiers: ${T.join(", ")}.`
758
778
  );
759
779
  if (f !== void 0) {
760
- const b = Array.isArray(C.items) ? C.items : [];
780
+ const w = Array.isArray(P.items) ? P.items : [];
761
781
  let y;
762
- for (const h of b) {
782
+ for (const h of w) {
763
783
  if (h === null || typeof h != "object" || Array.isArray(h)) continue;
764
784
  const E = h.type;
765
785
  if (E === null || typeof E != "object" || Array.isArray(E)) continue;
766
- const T = E.kind;
767
- if (typeof T == "string") {
768
- y = T;
786
+ const j = E.kind;
787
+ if (typeof j == "string") {
788
+ y = j;
769
789
  break;
770
790
  }
771
791
  }
772
792
  if (y !== void 0 && f !== y)
773
793
  throw new Error(
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)`
794
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${l}"].referencesRamps[${o}]: referencing semantic tier has kind "${f}" but target tier "${u.tier}" in tab "${p}" has kind "${y}" (cross-tab ramp sources must share the semantic tier's kind)`
775
795
  );
776
796
  }
777
797
  }
778
798
  }
779
799
  if (t.colorExtras !== void 0) {
780
- const o = t.colorExtras;
781
- if (o === null || typeof o != "object" || Array.isArray(o))
800
+ const s = t.colorExtras;
801
+ if (s === null || typeof s != "object" || Array.isArray(s))
782
802
  throw new Error(
783
803
  `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras must be a plain object`
784
804
  );
785
805
  for (const r of ["id", "defaultShikiTheme"])
786
- if (typeof o[r] != "string" || o[r].length === 0)
806
+ if (typeof s[r] != "string" || s[r].length === 0)
787
807
  throw new Error(
788
- `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.${r} must be a non-empty string (got ${typeof o[r]})`
808
+ `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.${r} must be a non-empty string (got ${typeof s[r]})`
789
809
  );
790
810
  for (const r of ["colorSchemes", "baseRoles", "baseDefaults"])
791
- if (o[r] === void 0 || o[r] === null || typeof o[r] != "object" || Array.isArray(o[r]))
811
+ if (s[r] === void 0 || s[r] === null || typeof s[r] != "object" || Array.isArray(s[r]))
792
812
  throw new Error(
793
813
  `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.${r} must be a plain object`
794
814
  );
795
- if (o.panelSettings === void 0 || o.panelSettings === null || typeof o.panelSettings != "object" || Array.isArray(o.panelSettings))
815
+ if (s.panelSettings === void 0 || s.panelSettings === null || typeof s.panelSettings != "object" || Array.isArray(s.panelSettings))
796
816
  throw new Error(
797
817
  `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings must be a plain object`
798
818
  );
799
- const s = o.panelSettings;
800
- if (typeof s.colorScheme != "string" || s.colorScheme.length === 0)
819
+ const a = s.panelSettings;
820
+ if (typeof a.colorScheme != "string" || a.colorScheme.length === 0)
801
821
  throw new Error(
802
822
  `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorScheme must be a non-empty string`
803
823
  );
804
- if (s.colorMode !== !1) {
805
- if (s.colorMode === null || typeof s.colorMode != "object" || Array.isArray(s.colorMode))
824
+ if (a.colorMode !== !1) {
825
+ if (a.colorMode === null || typeof a.colorMode != "object" || Array.isArray(a.colorMode))
806
826
  throw new Error(
807
827
  `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode must be false or a plain object`
808
828
  );
809
- const r = s.colorMode;
810
- for (const i of ["lightScheme", "darkScheme"])
811
- if (typeof r[i] != "string" || r[i].length === 0)
829
+ const r = a.colorMode;
830
+ for (const o of ["lightScheme", "darkScheme"])
831
+ if (typeof r[o] != "string" || r[o].length === 0)
812
832
  throw new Error(
813
- `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode.${i} must be a non-empty string`
833
+ `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode.${o} must be a non-empty string`
814
834
  );
815
835
  if (r.defaultMode !== "light" && r.defaultMode !== "dark")
816
836
  throw new Error(
817
837
  `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.panelSettings.colorMode.defaultMode must be "light" or "dark" (got ${JSON.stringify(r.defaultMode)})`
818
838
  );
819
839
  }
820
- if (o.semanticDefaults !== void 0) {
821
- if (o.semanticDefaults === null || typeof o.semanticDefaults != "object" || Array.isArray(o.semanticDefaults))
840
+ if (s.semanticDefaults !== void 0) {
841
+ if (s.semanticDefaults === null || typeof s.semanticDefaults != "object" || Array.isArray(s.semanticDefaults))
822
842
  throw new Error(
823
843
  `[design-token-panel] PanelConfig.tabs["${e}"].colorExtras.semanticDefaults must be a plain object`
824
844
  );
825
- const r = o.semanticDefaults;
826
- for (const [i, u] of Object.entries(r))
827
- if (!U(u))
845
+ const r = s.semanticDefaults;
846
+ for (const [o, d] of Object.entries(r))
847
+ if (!U(d))
828
848
  throw new Error(
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)}`
849
+ `[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(d)}`
830
850
  );
831
851
  }
832
852
  const f = t.tiers.find((r) => {
833
853
  if (r.referencesTier !== void 0 || r.semantic === !0) return !1;
834
- const i = r.items;
835
- if (!Array.isArray(i) || i.length === 0) return !1;
836
- const u = i[0];
837
- if (u === null || typeof u != "object" || Array.isArray(u)) return !1;
838
- const d = u.type;
839
- return d === null || typeof d != "object" || Array.isArray(d) ? !1 : d.kind === "color";
854
+ const o = r.items;
855
+ if (!Array.isArray(o) || o.length === 0) return !1;
856
+ const d = o[0];
857
+ if (d === null || typeof d != "object" || Array.isArray(d)) return !1;
858
+ const u = d.type;
859
+ return u === null || typeof u != "object" || Array.isArray(u) ? !1 : u.kind === "color";
840
860
  });
841
861
  if (f) {
842
- const r = f.id, i = f.items, u = i[0]?.cssVar;
843
- if (u !== void 0) {
844
- const d = u.replace(/\d+$/, "{n}");
845
- if (d.includes("{n}"))
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)
862
+ const r = f.id, o = f.items, d = o[0]?.cssVar;
863
+ if (d !== void 0) {
864
+ const u = d.replace(/\d+$/, "{n}");
865
+ if (u.includes("{n}"))
866
+ for (let p = 0; p < o.length; p++) {
867
+ const k = o[p], C = u.replace("{n}", String(p));
868
+ if (k.cssVar !== C)
849
869
  throw new Error(
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)})`
870
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r}"].items[${p}].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(u)})`
851
871
  );
852
872
  }
853
- else if (i.length > 1)
873
+ else if (o.length > 1)
854
874
  throw new Error(
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")`
875
+ `[design-token-panel] PanelConfig.tabs["${e}"].tiers["${r}"].items[0].cssVar ${JSON.stringify(d)} 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")`
856
876
  );
857
877
  }
858
878
  }
@@ -870,11 +890,11 @@ function W(e, t, n) {
870
890
  throw new Error(
871
891
  '[design-token-panel] PanelConfig.tabs["notes"].notesExtras must be a plain object with { title, html }'
872
892
  );
873
- const o = t.notesExtras;
874
- for (const s of ["title", "html"])
875
- if (typeof o[s] != "string" || o[s].length === 0)
893
+ const s = t.notesExtras;
894
+ for (const a of ["title", "html"])
895
+ if (typeof s[a] != "string" || s[a].length === 0)
876
896
  throw new Error(
877
- `[design-token-panel] PanelConfig.tabs["notes"].notesExtras.${s} must be a non-empty string (got ${typeof o[s]})`
897
+ `[design-token-panel] PanelConfig.tabs["notes"].notesExtras.${a} must be a non-empty string (got ${typeof s[a]})`
878
898
  );
879
899
  } else if (t.notesExtras !== void 0)
880
900
  throw new Error(
@@ -903,8 +923,8 @@ export {
903
923
  q as H,
904
924
  ne as I,
905
925
  re as J,
906
- we as K,
907
- ie as _,
926
+ be as K,
927
+ oe as _,
908
928
  he as a,
909
929
  fe as b,
910
930
  ee as c,
@@ -912,23 +932,23 @@ export {
912
932
  ge as e,
913
933
  ve as f,
914
934
  D as g,
915
- de as h,
935
+ ue as h,
916
936
  Ee as i,
917
937
  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,
938
+ de as k,
939
+ we as l,
940
+ Ce as m,
941
+ se as n,
942
+ le as o,
943
+ Y as p,
944
+ Z as q,
925
945
  Q as r,
926
946
  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
947
+ ye as t,
948
+ me as u,
949
+ X as v,
950
+ ie as w,
951
+ ae as x,
952
+ M as y,
953
+ S as z
934
954
  };