@takazudo/zdtp 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { jsxs as m, jsx as y } from "preact/jsx-runtime";
1
+ import { jsxs as _, jsx as v } from "preact/jsx-runtime";
2
2
  const q = new Set("aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen transparent currentcolor inherit initial unset revert revert-layer".split(" "));
3
3
  function C(l) {
4
4
  return l.startsWith("#") || l.includes("(") || q.has(l.toLowerCase());
@@ -11,93 +11,93 @@ const O = [
11
11
  "selectionFg"
12
12
  ], j = /^--[\w\u0080-\uffff-]+$/u;
13
13
  function A(l) {
14
- let u = "", o = 0;
15
- for (let a = 0; a < l.length; a++) {
16
- const g = l[a];
17
- if (g === '"' || g === "'") {
18
- const f = g;
19
- let r = !1;
20
- for (a++; a < l.length; a++)
21
- if (l[a] === "\\") a++;
22
- else if (l[a] === f) {
23
- r = !0;
14
+ let f = "", o = 0;
15
+ for (let r = 0; r < l.length; r++) {
16
+ const h = l[r];
17
+ if (h === '"' || h === "'") {
18
+ const c = h;
19
+ let a = !1;
20
+ for (r++; r < l.length; r++)
21
+ if (l[r] === "\\") r++;
22
+ else if (l[r] === c) {
23
+ a = !0;
24
24
  break;
25
- } else if (/[\n\r\f]/.test(l[a])) return { syntax: u, safe: !1 };
26
- if (!r) return { syntax: u, safe: !1 };
27
- u += '""';
28
- } else if (g === "/" && l[a + 1] === "*") {
29
- const f = l.indexOf("*/", a + 2);
30
- if (f === -1) return { syntax: u, safe: !1 };
31
- u += " ", a = f + 1;
25
+ } else if (/[\n\r\f]/.test(l[r])) return { syntax: f, safe: !1 };
26
+ if (!a) return { syntax: f, safe: !1 };
27
+ f += '""';
28
+ } else if (h === "/" && l[r + 1] === "*") {
29
+ const c = l.indexOf("*/", r + 2);
30
+ if (c === -1) return { syntax: f, safe: !1 };
31
+ f += " ", r = c + 1;
32
32
  } else {
33
- const f = g.charCodeAt(0);
34
- if (/[;{}\\@]/.test(g) || f <= 8 || f === 11 || f >= 14 && f <= 31 || f === 127)
35
- return { syntax: u, safe: !1 };
36
- if (g === "(" && o++, g === ")" && --o < 0) return { syntax: u, safe: !1 };
37
- u += g;
33
+ const c = h.charCodeAt(0);
34
+ if (/[;{}\\@]/.test(h) || c <= 8 || c === 11 || c >= 14 && c <= 31 || c === 127)
35
+ return { syntax: f, safe: !1 };
36
+ if (h === "(" && o++, h === ")" && --o < 0) return { syntax: f, safe: !1 };
37
+ f += h;
38
38
  }
39
39
  }
40
40
  return {
41
- syntax: u,
42
- safe: o === 0 && !/\b(?:url|(?:-webkit-)?image-set|image|cross-fade|element|paint|src)\s*\(/i.test(u) && !/!\s*important\b/i.test(u)
41
+ syntax: f,
42
+ safe: o === 0 && !/\b(?:url|(?:-webkit-)?image-set|image|cross-fade|element|paint|src)\s*\(/i.test(f) && !/!\s*important\b/i.test(f)
43
43
  };
44
44
  }
45
- function D(l, u) {
45
+ function D(l, f) {
46
46
  const o = /* @__PURE__ */ new Map();
47
- for (const a of l) {
48
- const g = u(a), f = o.get(g) ?? [];
49
- f.push(a), o.set(g, f);
47
+ for (const r of l) {
48
+ const h = f(r), c = o.get(h) ?? [];
49
+ c.push(r), o.set(h, c);
50
50
  }
51
51
  return o;
52
52
  }
53
- function B(l, u = "light") {
53
+ function B(l, f = "light") {
54
54
  const o = {
55
- mode: u,
55
+ mode: f,
56
56
  tabs: [],
57
57
  rows: [],
58
58
  declarations: /* @__PURE__ */ Object.create(null),
59
59
  diagnostics: []
60
- }, a = [], g = l.filter((e) => e.id !== "notes"), f = D(g, (e) => e.id);
61
- function r(e, t, s, n = "error") {
62
- const d = { code: t, severity: n, message: s, ...e ? { rowKey: e.row.key } : {} };
63
- e?.row.diagnostics.some((i) => i.code === t && i.message === s) || (e?.row.diagnostics.push(d), o.diagnostics.push(d));
60
+ }, r = [], h = l.filter((e) => e.id !== "notes"), c = D(h, (e) => e.id);
61
+ function a(e, s, t, n = "error") {
62
+ const d = { code: s, severity: n, message: t, ...e ? { rowKey: e.row.key } : {} };
63
+ e?.row.diagnostics.some((i) => i.code === s && i.message === t) || (e?.row.diagnostics.push(d), o.diagnostics.push(d));
64
64
  }
65
- function _(e, t, s, n, d, i) {
66
- t.rows.push(s), o.rows.push(s), a.push({ row: s, tab: e, tier: d, item: n, baseRole: i, dependencies: [], contextDependent: !1 });
65
+ function m(e, s, t, n, d, i) {
66
+ s.rows.push(t), o.rows.push(t), r.push({ row: t, tab: e, tier: d, item: n, baseRole: i, dependencies: [], contextDependent: !1 });
67
67
  }
68
- g.forEach((e, t) => {
69
- const s = { key: `tab-${t}`, id: e.id, label: e.label, tiers: [] };
70
- o.tabs.push(s), e.tiers.forEach((i, w) => {
71
- const b = {
72
- key: `${s.key}-tier-${w}`,
68
+ h.forEach((e, s) => {
69
+ const t = { key: `tab-${s}`, id: e.id, label: e.label, tiers: [] };
70
+ o.tabs.push(t), e.tiers.forEach((i, w) => {
71
+ const y = {
72
+ key: `${t.key}-tier-${w}`,
73
73
  id: i.id,
74
74
  label: i.label,
75
- palette: !i.semantic && !i.referencesTier && !i.referencesRamps?.length && i.items.length > 0 && i.items.every((h) => h.type.kind === "color"),
75
+ palette: !i.semantic && !i.referencesTier && !i.referencesRamps?.length && i.items.length > 0 && i.items.every((u) => u.type.kind === "color"),
76
76
  preview: i.preview,
77
77
  previewBase: i.previewBase,
78
78
  rows: []
79
79
  };
80
- s.tiers.push(b), i.items.forEach((h, V) => _(e, b, {
81
- key: `${b.key}-item-${V}`,
80
+ t.tiers.push(y), i.items.forEach((u, V) => m(e, y, {
81
+ key: `${y.key}-item-${V}`,
82
82
  tabId: e.id,
83
83
  tierId: i.id,
84
- itemId: h.id,
85
- label: h.label,
86
- cssVar: h.cssVar,
87
- kind: h.type.kind,
84
+ itemId: u.id,
85
+ label: u.label,
86
+ cssVar: u.cssVar,
87
+ kind: u.type.kind,
88
88
  source: "item",
89
- defaultValue: h.default,
90
- declaredValue: h.default,
89
+ defaultValue: u.default,
90
+ declaredValue: u.default,
91
91
  cssValue: null,
92
92
  resolvedValue: null,
93
93
  references: [],
94
94
  diagnostics: []
95
- }, h, i));
95
+ }, u, i));
96
96
  });
97
97
  const n = e.colorExtras;
98
98
  if (!n) return;
99
99
  const d = {
100
- key: `${s.key}-base-roles`,
100
+ key: `${t.key}-base-roles`,
101
101
  id: "base-roles",
102
102
  label: "Base roles",
103
103
  rows: []
@@ -105,8 +105,8 @@ function B(l, u = "light") {
105
105
  for (const i of O) {
106
106
  const w = n.baseRoles[i];
107
107
  if (w === void 0) continue;
108
- const b = n.baseDefaults[i];
109
- _(e, d, {
108
+ const y = n.baseDefaults[i];
109
+ m(e, d, {
110
110
  key: `${d.key}-${i}`,
111
111
  tabId: e.id,
112
112
  tierId: d.id,
@@ -115,147 +115,147 @@ function B(l, u = "light") {
115
115
  cssVar: w,
116
116
  kind: "color",
117
117
  source: "base-role",
118
- defaultValue: b === void 0 ? "" : String(b),
119
- declaredValue: b === void 0 ? "(no declared default)" : `palette[${b}]`,
118
+ defaultValue: y === void 0 ? "" : String(y),
119
+ declaredValue: y === void 0 ? "(no declared default)" : `palette[${y}]`,
120
120
  cssValue: null,
121
121
  resolvedValue: null,
122
122
  references: [],
123
123
  diagnostics: []
124
124
  }, void 0, void 0, i);
125
125
  }
126
- d.rows.length > 0 && s.tiers.push(d);
126
+ d.rows.length > 0 && t.tiers.push(d);
127
127
  });
128
- const v = D(a, (e) => e.row.cssVar);
129
- for (const e of a)
130
- j.test(e.row.cssVar) || r(e, "invalid-variable", `Unsupported CSS custom property name: ${e.row.cssVar}.`), v.get(e.row.cssVar).length > 1 && r(e, "duplicate-variable", `Multiple declarations use ${e.row.cssVar}; none is selected.`), f.get(e.tab.id).length > 1 && r(e, "duplicate-tab", `Multiple tabs use the id ${e.tab.id}.`), e.tier && (e.tab.tiers.filter((t) => t.id === e.tier.id).length > 1 && r(e, "duplicate-tier", `Multiple tiers use the id ${e.tier.id} in tab ${e.tab.id}.`), e.tier.items.filter((t) => t.id === e.item.id).length > 1 && r(e, "duplicate-item", `Multiple items use the id ${e.item.id} in tier ${e.tier.id}.`));
131
- function c(e, t) {
132
- e.directReference = t, e.row.cssValue = `var(${t.row.cssVar})`;
128
+ const k = D(r, (e) => e.row.cssVar);
129
+ for (const e of r)
130
+ j.test(e.row.cssVar) || a(e, "invalid-variable", `Unsupported CSS custom property name: ${e.row.cssVar}.`), k.get(e.row.cssVar).length > 1 && a(e, "duplicate-variable", `Multiple declarations use ${e.row.cssVar}; none is selected.`), c.get(e.tab.id).length > 1 && a(e, "duplicate-tab", `Multiple tabs use the id ${e.tab.id}.`), e.tier && (e.tab.tiers.filter((s) => s.id === e.tier.id).length > 1 && a(e, "duplicate-tier", `Multiple tiers use the id ${e.tier.id} in tab ${e.tab.id}.`), e.tier.items.filter((s) => s.id === e.item.id).length > 1 && a(e, "duplicate-item", `Multiple items use the id ${e.item.id} in tier ${e.tier.id}.`));
131
+ function g(e, s) {
132
+ e.directReference = s, e.row.cssValue = `var(${s.row.cssVar})`;
133
133
  }
134
- function p(e, t, s, n) {
135
- const d = f.get(t) ?? [];
134
+ function p(e, s, t, n) {
135
+ const d = c.get(s) ?? [];
136
136
  if (d.length !== 1) {
137
- r(e, d.length ? "ambiguous-reference" : "missing-reference", `Reference tab ${t} ${d.length ? "is ambiguous" : "does not exist"}.`);
137
+ a(e, d.length ? "ambiguous-reference" : "missing-reference", `Reference tab ${s} ${d.length ? "is ambiguous" : "does not exist"}.`);
138
138
  return;
139
139
  }
140
- const i = d[0].tiers.filter((b) => b.id === s);
140
+ const i = d[0].tiers.filter((y) => y.id === t);
141
141
  if (i.length !== 1) {
142
- r(e, i.length ? "ambiguous-reference" : "missing-reference", `Reference tier ${t}/${s} ${i.length ? "is ambiguous" : "does not exist"}.`);
142
+ a(e, i.length ? "ambiguous-reference" : "missing-reference", `Reference tier ${s}/${t} ${i.length ? "is ambiguous" : "does not exist"}.`);
143
143
  return;
144
144
  }
145
- const w = a.filter((b) => b.tab === d[0] && b.tier === i[0] && b.item?.id === n);
145
+ const w = r.filter((y) => y.tab === d[0] && y.tier === i[0] && y.item?.id === n);
146
146
  if (w.length !== 1) {
147
- r(e, w.length ? "ambiguous-reference" : "missing-reference", `Reference item ${t}/${s}/${n} ${w.length ? "is ambiguous" : "does not exist"}.`);
147
+ a(e, w.length ? "ambiguous-reference" : "missing-reference", `Reference item ${s}/${t}/${n} ${w.length ? "is ambiguous" : "does not exist"}.`);
148
148
  return;
149
149
  }
150
150
  return w[0];
151
151
  }
152
- function $(e) {
153
- return e.tab.tiers.filter((t) => !t.semantic && !t.referencesTier && t.items.length > 0 && t.items.every((s) => s.type.kind === "color"));
152
+ function b(e) {
153
+ return e.tab.tiers.filter((s) => !s.semantic && !s.referencesTier && s.items.length > 0 && s.items.every((t) => t.type.kind === "color"));
154
154
  }
155
- function z(e, t) {
156
- const s = $(e), n = e.tier?.referencesTier ? s.filter((w) => w.id === e.tier.referencesTier) : s;
155
+ function z(e, s) {
156
+ const t = b(e), n = e.tier?.referencesTier ? t.filter((w) => w.id === e.tier.referencesTier) : t;
157
157
  if (n.length !== 1) {
158
- r(e, "unsupported-palette", `A palette index requires one unambiguous declared palette tier; found ${n.length}.`);
158
+ a(e, "unsupported-palette", `A palette index requires one unambiguous declared palette tier; found ${n.length}.`);
159
159
  return;
160
160
  }
161
- if (!Number.isInteger(t) || t < 0 || t >= n[0].items.length) {
162
- r(e, "invalid-palette-index", `Palette index ${t} is outside the declared palette.`);
161
+ if (!Number.isInteger(s) || s < 0 || s >= n[0].items.length) {
162
+ a(e, "invalid-palette-index", `Palette index ${s} is outside the declared palette.`);
163
163
  return;
164
164
  }
165
- const d = n[0].items[t], i = p(e, e.tab.id, n[0].id, d.id);
166
- i && c(e, i);
165
+ const d = n[0].items[s], i = p(e, e.tab.id, n[0].id, d.id);
166
+ i && g(e, i);
167
167
  }
168
- function k(e, t) {
169
- const s = e.tab.colorExtras?.baseDefaults[t];
170
- if (s === void 0) {
171
- r(e, "missing-base-default", `Base role ${t} has no explicit baseDefaults mapping.`);
168
+ function x(e, s) {
169
+ const t = e.tab.colorExtras?.baseDefaults[s];
170
+ if (t === void 0) {
171
+ a(e, "missing-base-default", `Base role ${s} has no explicit baseDefaults mapping.`);
172
172
  return;
173
173
  }
174
- z(e, s);
174
+ z(e, t);
175
175
  }
176
- function S(e, t) {
177
- if (typeof t == "number")
178
- e.row.declaredValue = `palette[${t}]`, z(e, t);
179
- else if (t === "bg" || t === "fg")
180
- e.row.declaredValue = t, k(e, t === "bg" ? "background" : "foreground");
181
- else if (typeof t == "object" && t !== null && "literal" in t) {
182
- const s = typeof t.literal == "string" ? t.literal : t.literal[u];
183
- e.row.declaredValue = s, e.row.cssValue = s;
184
- } else if (typeof t == "object" && t !== null && "ref" in t) {
185
- const { tab: s = e.tab.id, tier: n, item: d } = t.ref;
186
- e.row.declaredValue = `${s}/${n}/${d}`;
187
- const i = p(e, s, n, d);
188
- i && c(e, i);
176
+ function $(e, s) {
177
+ if (typeof s == "number")
178
+ e.row.declaredValue = `palette[${s}]`, z(e, s);
179
+ else if (s === "bg" || s === "fg")
180
+ e.row.declaredValue = s, x(e, s === "bg" ? "background" : "foreground");
181
+ else if (typeof s == "object" && s !== null && "literal" in s) {
182
+ const t = typeof s.literal == "string" ? s.literal : s.literal[f];
183
+ e.row.declaredValue = t, e.row.cssValue = t;
184
+ } else if (typeof s == "object" && s !== null && "ref" in s) {
185
+ const { tab: t = e.tab.id, tier: n, item: d } = s.ref;
186
+ e.row.declaredValue = `${t}/${n}/${d}`;
187
+ const i = p(e, t, n, d);
188
+ i && g(e, i);
189
189
  } else
190
- r(e, "invalid-semantic-default", "Unsupported semantic default mapping.");
190
+ a(e, "invalid-semantic-default", "Unsupported semantic default mapping.");
191
191
  }
192
- for (const e of a) {
192
+ for (const e of r) {
193
193
  if (e.baseRole) {
194
- k(e, e.baseRole);
194
+ x(e, e.baseRole);
195
195
  continue;
196
196
  }
197
- const t = e.tier, s = e.item, n = $(e), d = t.semantic || e.tab.colorExtras && n.some((h) => h.id === t.referencesTier), w = (t.referencesTier === void 0 ? n : n.filter((h) => h.id === t.referencesTier)).flatMap((h) => h.items.filter((V) => V.id === s.default).map(() => h)), b = e.tab.colorExtras?.semanticDefaults;
198
- if (d && b && Object.hasOwn(b, s.id))
199
- S(e, b[s.id]);
197
+ const s = e.tier, t = e.item, n = b(e), d = s.semantic || e.tab.colorExtras && n.some((u) => u.id === s.referencesTier), w = (s.referencesTier === void 0 ? n : n.filter((u) => u.id === s.referencesTier)).flatMap((u) => u.items.filter((V) => V.id === t.default).map(() => u)), y = e.tab.colorExtras?.semanticDefaults;
198
+ if (d && y && Object.hasOwn(y, t.id))
199
+ $(e, y[t.id]);
200
200
  else if (d && w.length > 0)
201
201
  if (w.length > 1)
202
- r(e, "ambiguous-reference", `Default ${s.default} names multiple palette items.`);
202
+ a(e, "ambiguous-reference", `Default ${t.default} names multiple palette items.`);
203
203
  else {
204
- const h = p(e, e.tab.id, w[0].id, s.default);
205
- h && c(e, h);
204
+ const u = p(e, e.tab.id, w[0].id, t.default);
205
+ u && g(e, u);
206
206
  }
207
- else if (d && (s.default === "bg" || s.default === "fg"))
208
- k(e, s.default === "bg" ? "background" : "foreground");
209
- else if (t.referencesTier !== void 0 && !(d && t.referencesRamps?.length) && !(t.semantic && C(s.default))) {
210
- const h = p(e, e.tab.id, t.referencesTier, s.default);
211
- h && c(e, h);
207
+ else if (d && (t.default === "bg" || t.default === "fg"))
208
+ x(e, t.default === "bg" ? "background" : "foreground");
209
+ else if (s.referencesTier !== void 0 && !(d && s.referencesRamps?.length) && !(s.semantic && C(t.default))) {
210
+ const u = p(e, e.tab.id, s.referencesTier, t.default);
211
+ u && g(e, u);
212
212
  } else if (d)
213
- if (t.referencesRamps?.length && !C(s.default)) {
214
- const h = s.default.indexOf(":"), V = h === -1 ? [t.referencesRamps[0]] : t.referencesRamps.filter((N) => N.tier === s.default.slice(0, h));
213
+ if (s.referencesRamps?.length && !C(t.default)) {
214
+ const u = t.default.indexOf(":"), V = u === -1 ? [s.referencesRamps[0]] : s.referencesRamps.filter((R) => R.tier === t.default.slice(0, u));
215
215
  if (V.length !== 1)
216
- r(e, V.length ? "ambiguous-reference" : "missing-reference", `Ramp source for ${s.default} ${V.length ? "is ambiguous" : "does not exist"}.`);
216
+ a(e, V.length ? "ambiguous-reference" : "missing-reference", `Ramp source for ${t.default} ${V.length ? "is ambiguous" : "does not exist"}.`);
217
217
  else {
218
- const N = p(e, V[0].tab ?? e.tab.id, V[0].tier, h === -1 ? s.default : s.default.slice(h + 1));
219
- N && c(e, N);
218
+ const R = p(e, V[0].tab ?? e.tab.id, V[0].tier, u === -1 ? t.default : t.default.slice(u + 1));
219
+ R && g(e, R);
220
220
  }
221
221
  } else
222
- e.row.cssValue = s.default;
222
+ e.row.cssValue = t.default;
223
223
  else
224
- e.row.cssValue = s.default;
224
+ e.row.cssValue = t.default;
225
225
  }
226
- for (const e of a) {
227
- const t = e.row.cssValue;
228
- if (t === null) continue;
229
- const s = A(t);
230
- if (!s.safe) {
231
- r(e, "unsafe-css", "This declaration contains unsupported CSS syntax or a resource-loading function; preview omitted.");
226
+ for (const e of r) {
227
+ const s = e.row.cssValue;
228
+ if (s === null) continue;
229
+ const t = A(s);
230
+ if (!t.safe) {
231
+ a(e, "unsafe-css", "This declaration contains unsupported CSS syntax or a resource-loading function; preview omitted.");
232
232
  continue;
233
233
  }
234
234
  e.directReference && e.dependencies.push(e.directReference);
235
- for (const n of s.syntax.matchAll(/\bvar\(\s*(--[\w\u0080-\uffff-]+)\s*(?=[,)])/giu)) {
236
- const d = v.get(n[1]) ?? [];
237
- d.length > 1 ? r(e, "ambiguous-reference", `CSS reference ${n[1]} has multiple declarations.`) : d.length === 1 ? e.dependencies.push(d[0]) : (e.contextDependent = !0, r(e, "external-reference", `CSS reference ${n[1]} is not in this inventory; its value depends on the host context or fallback.`, "warning"));
235
+ for (const n of t.syntax.matchAll(/\bvar\(\s*(--[\w\u0080-\uffff-]+)\s*(?=[,)])/giu)) {
236
+ const d = k.get(n[1]) ?? [];
237
+ d.length > 1 ? a(e, "ambiguous-reference", `CSS reference ${n[1]} has multiple declarations.`) : d.length === 1 ? e.dependencies.push(d[0]) : (e.contextDependent = !0, a(e, "external-reference", `CSS reference ${n[1]} is not in this inventory; its value depends on the host context or fallback.`, "warning"));
238
238
  }
239
- e.dependencies = [...new Set(e.dependencies)], e.row.references = e.dependencies.map(({ row: n }) => ({ key: n.key, cssVar: n.cssVar, label: n.label })), /(?:^|[^\w-])(?:currentcolor|initial|inherit|unset|revert|revert-layer)(?=$|[^\w-])|\b(?:env|attr)\s*\(/i.test(s.syntax) && (e.contextDependent = !0, r(e, "context-dependent", "This CSS value depends on the surrounding document; no computed preview is claimed.", "warning"));
239
+ e.dependencies = [...new Set(e.dependencies)], e.row.references = e.dependencies.map(({ row: n }) => ({ key: n.key, cssVar: n.cssVar, label: n.label })), /(?:^|[^\w-])(?:currentcolor|initial|inherit|unset|revert|revert-layer)(?=$|[^\w-])|\b(?:env|attr)\s*\(/i.test(t.syntax) && (e.contextDependent = !0, a(e, "context-dependent", "This CSS value depends on the surrounding document; no computed preview is claimed.", "warning"));
240
240
  }
241
- const R = /* @__PURE__ */ new Set(), x = [];
241
+ const N = /* @__PURE__ */ new Set(), S = [];
242
242
  function T(e) {
243
- if (R.has(e)) return;
244
- const t = x.indexOf(e);
245
- if (t !== -1) {
246
- for (const s of x.slice(t)) r(s, "cyclic-reference", "Declared references form a cycle.");
243
+ if (N.has(e)) return;
244
+ const s = S.indexOf(e);
245
+ if (s !== -1) {
246
+ for (const t of S.slice(s)) a(t, "cyclic-reference", "Declared references form a cycle.");
247
247
  return;
248
248
  }
249
- x.push(e);
250
- for (const s of e.dependencies)
251
- T(s), s.row.diagnostics.some((n) => n.severity === "error") ? r(e, "invalid-reference", `Referenced declaration ${s.row.cssVar} is invalid.`) : s.contextDependent && (e.contextDependent = !0, r(e, "context-dependent", `Referenced declaration ${s.row.cssVar} depends on the host context.`, "warning"));
252
- x.pop(), R.add(e), e.row.diagnostics.some((s) => s.severity === "error") ? e.row.cssValue = null : e.contextDependent || (e.row.resolvedValue = e.directReference?.row.resolvedValue ?? e.row.cssValue);
249
+ S.push(e);
250
+ for (const t of e.dependencies)
251
+ T(t), t.row.diagnostics.some((n) => n.severity === "error") ? a(e, "invalid-reference", `Referenced declaration ${t.row.cssVar} is invalid.`) : t.contextDependent && (e.contextDependent = !0, a(e, "context-dependent", `Referenced declaration ${t.row.cssVar} depends on the host context.`, "warning"));
252
+ S.pop(), N.add(e), e.row.diagnostics.some((t) => t.severity === "error") ? e.row.cssValue = null : e.contextDependent || (e.row.resolvedValue = e.directReference?.row.resolvedValue ?? e.row.cssValue);
253
253
  }
254
- for (const e of a) T(e);
255
- return o.declarations = Object.fromEntries(a.filter((e) => e.row.cssValue !== null).map((e) => [e.row.cssVar, e.row.cssValue])), o;
254
+ for (const e of r) T(e);
255
+ return o.declarations = Object.fromEntries(r.filter((e) => e.row.cssValue !== null).map((e) => [e.row.cssVar, e.row.cssValue])), o;
256
256
  }
257
- function L(l, u, o) {
258
- return o?.[l.cssVar] ?? u.preview ?? (l.kind === "color" ? "color" : "text");
257
+ function L(l, f, o) {
258
+ return o?.[l.cssVar] ?? f.preview ?? (l.kind === "color" ? "color" : "text");
259
259
  }
260
260
  const M = `Good typography gives every idea room to breathe. Compare the rhythm of several lines, the shapes of letters, and the distance between words. A token becomes useful when you can see it in context.
261
261
 
@@ -263,142 +263,143 @@ const M = `Good typography gives every idea room to breathe. Compare the rhythm
263
263
  function E(l) {
264
264
  return ["size", "family", "weight", "line-height"].includes(l);
265
265
  }
266
- function I(l, u) {
266
+ function I(l, f) {
267
267
  const o = /* @__PURE__ */ new Set();
268
- let a = l;
269
- for (; a.cssValue !== null && a.resolvedValue !== null && !o.has(a.key); ) {
270
- o.add(a.key);
271
- const g = a.resolvedValue.trim();
272
- if (/^(?:0|\+?(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem))$/i.test(g)) return g;
273
- const f = /^var\(\s*(--[a-zA-Z0-9_-]+)\s*\)$/.exec(g);
274
- if (!f) return null;
275
- const r = u.rows.filter((_) => _.cssVar === f[1]);
276
- if (r.length !== 1) return null;
277
- a = r[0];
268
+ let r = l;
269
+ for (; r.cssValue !== null && r.resolvedValue !== null && !o.has(r.key); ) {
270
+ o.add(r.key);
271
+ const h = r.resolvedValue.trim();
272
+ if (/^(?:0|\+?(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem))$/i.test(h)) return h;
273
+ const c = /^var\(\s*(--[a-zA-Z0-9_-]+)\s*\)$/.exec(h);
274
+ if (!c) return null;
275
+ const a = f.rows.filter((m) => m.cssVar === c[1]);
276
+ if (a.length !== 1) return null;
277
+ r = a[0];
278
278
  }
279
279
  return null;
280
280
  }
281
- function P({ row: l, tier: u, kind: o, model: a, previewText: g }) {
281
+ function P({ row: l, tier: f, kind: o, model: r, previewText: h }) {
282
282
  if (o === "bar") {
283
- const c = I(l, a);
284
- return c === null ? /* @__PURE__ */ y("div", { className: "zdtp-dashboard__preview-unavailable", children: "Ruler unavailable: requires a nonnegative px/rem length or a resolved direct alias." }) : /* @__PURE__ */ m("div", { className: "zdtp-dashboard__ruler-wrap", children: [
285
- /* @__PURE__ */ y("div", { className: "zdtp-dashboard__ruler-caption", children: "Actual size · ticks every 8 CSS px · major ticks every 64 CSS px" }),
286
- /* @__PURE__ */ y("div", { className: "zdtp-dashboard__scroll zdtp-dashboard__ruler-scroll", role: "region", tabIndex: 0, "aria-label": `${l.label} (${l.cssVar}) actual-size ruler`, children: /* @__PURE__ */ m("div", { className: "zdtp-dashboard__ruler", style: { inlineSize: `max(100%, ${c})` }, children: [
287
- /* @__PURE__ */ y("div", { className: "zdtp-dashboard__ruler-origin", children: "0" }),
288
- /* @__PURE__ */ y("span", { className: "zdtp-dashboard__sample zdtp-dashboard__sample--bar", style: { inlineSize: c }, "aria-hidden": "true" })
283
+ const g = I(l, r);
284
+ return g === null ? /* @__PURE__ */ v("div", { className: "zdtp-dashboard__preview-unavailable", children: "Ruler unavailable: requires a nonnegative px/rem length or a resolved direct alias." }) : /* @__PURE__ */ _("div", { className: "zdtp-dashboard__ruler-wrap", children: [
285
+ /* @__PURE__ */ v("div", { className: "zdtp-dashboard__ruler-caption", children: "Actual size · ticks every 8 CSS px · major ticks every 64 CSS px" }),
286
+ /* @__PURE__ */ v("div", { className: "zdtp-dashboard__scroll zdtp-dashboard__ruler-scroll", role: "region", tabIndex: 0, "aria-label": `${l.label} (${l.cssVar}) actual-size ruler`, children: /* @__PURE__ */ _("div", { className: "zdtp-dashboard__ruler", style: { inlineSize: `max(100%, ${g})` }, children: [
287
+ /* @__PURE__ */ v("div", { className: "zdtp-dashboard__ruler-origin", children: "0" }),
288
+ /* @__PURE__ */ v("div", { className: "zdtp-dashboard__specimen", style: { colorScheme: r.mode }, children: /* @__PURE__ */ v("span", { className: "zdtp-dashboard__sample zdtp-dashboard__sample--bar", style: { inlineSize: g }, "aria-hidden": "true" }) })
289
289
  ] }) })
290
290
  ] });
291
291
  }
292
292
  if (l.cssValue === null || l.resolvedValue === null || o === "text" || o === "duration") return null;
293
- const f = l.resolvedValue.trim().toLowerCase();
294
- if (!f || (o === "radius" || o === "size") && (/^(?:auto|none|normal|(?:min|max)-content|stretch|content)$|^fit-content(?:\(|$)/.test(f) || /^[+-]?(?:\d*\.)?\d+(?:ms|s)$/.test(f) || /^[+-]?(?:\d*\.)?\d+$/.test(f) && Number(f) !== 0))
293
+ const c = l.resolvedValue.trim().toLowerCase();
294
+ if (!c || (o === "radius" || o === "size") && (/^(?:auto|none|normal|(?:min|max)-content|stretch|content)$|^fit-content(?:\(|$)/.test(c) || /^[+-]?(?:\d*\.)?\d+(?:ms|s)$/.test(c) || /^[+-]?(?:\d*\.)?\d+$/.test(c) && Number(c) !== 0))
295
295
  return null;
296
- const r = l.cssValue;
297
- let _;
296
+ const a = l.cssValue;
297
+ let m;
298
298
  switch (o) {
299
299
  case "color":
300
- _ = { backgroundColor: r };
300
+ m = { backgroundColor: a };
301
301
  break;
302
302
  case "radius":
303
- _ = { borderRadius: r };
303
+ m = { borderRadius: a };
304
304
  break;
305
305
  case "shadow":
306
- _ = { boxShadow: r };
306
+ m = { boxShadow: a };
307
307
  break;
308
308
  case "size":
309
- _ = { fontSize: r };
309
+ m = { fontSize: a };
310
310
  break;
311
311
  case "family":
312
- _ = { fontFamily: r };
312
+ m = { fontFamily: a };
313
313
  break;
314
314
  case "weight":
315
- _ = { fontWeight: r };
315
+ m = { fontWeight: a };
316
316
  break;
317
317
  case "line-height": {
318
- const c = a.rows.find((p) => p.cssVar === u.previewBase);
319
- _ = { lineHeight: r, ...c?.cssValue !== null && c?.resolvedValue != null ? { fontSize: `var(${c.cssVar})` } : {} };
318
+ const g = r.rows.find((p) => p.cssVar === f.previewBase);
319
+ m = { lineHeight: a, ...g?.cssValue !== null && g?.resolvedValue != null ? { fontSize: `var(${g.cssVar})` } : {} };
320
320
  break;
321
321
  }
322
322
  }
323
- const v = E(o);
324
- return /* @__PURE__ */ y(
323
+ const k = E(o);
324
+ return /* @__PURE__ */ v(
325
325
  "div",
326
326
  {
327
- className: `zdtp-dashboard__preview zdtp-dashboard__preview--${o}${v ? " zdtp-dashboard__preview--typography zdtp-dashboard__scroll" : ""}`,
328
- "aria-hidden": v ? void 0 : "true",
329
- role: v ? "region" : void 0,
330
- tabIndex: v ? 0 : void 0,
331
- "aria-label": v ? `${l.label} (${l.cssVar}) typography specimen` : void 0,
332
- children: /* @__PURE__ */ y("span", { className: `zdtp-dashboard__sample zdtp-dashboard__sample--${o}`, style: _, children: v ? g : "" })
327
+ className: `zdtp-dashboard__preview zdtp-dashboard__preview--${o}${k ? " zdtp-dashboard__preview--typography zdtp-dashboard__scroll" : ""}`,
328
+ "aria-hidden": k ? void 0 : "true",
329
+ role: k ? "region" : void 0,
330
+ tabIndex: k ? 0 : void 0,
331
+ "aria-label": k ? `${l.label} (${l.cssVar}) typography specimen` : void 0,
332
+ children: /* @__PURE__ */ v("div", { className: "zdtp-dashboard__specimen", style: { colorScheme: r.mode }, children: /* @__PURE__ */ v("span", { className: `zdtp-dashboard__sample zdtp-dashboard__sample--${o}`, style: m, children: k ? h : "" }) })
333
333
  }
334
334
  );
335
335
  }
336
336
  function W({
337
337
  tabs: l,
338
- mode: u = "light",
339
- title: o = "Token dashboard",
340
- id: a,
341
- previewOverrides: g,
342
- previewText: f = M
338
+ mode: f = "light",
339
+ chrome: o = "light",
340
+ title: r = "Token dashboard",
341
+ id: h,
342
+ previewOverrides: c,
343
+ previewText: a = M
343
344
  }) {
344
- const r = B(l, u), _ = r.rows.filter((v) => v.diagnostics.length > 0).length;
345
- return /* @__PURE__ */ m("div", { id: a, className: "zdtp-dashboard", role: "region", "aria-label": o, "data-mode": u, children: [
346
- /* @__PURE__ */ m("div", { className: "zdtp-dashboard__header", children: [
347
- /* @__PURE__ */ y("div", { role: "heading", "aria-level": 2, className: "zdtp-dashboard__title", children: o }),
348
- /* @__PURE__ */ m("div", { className: "zdtp-dashboard__summary", children: [
349
- /* @__PURE__ */ m("span", { className: "zdtp-dashboard__count", children: [
350
- r.rows.length,
345
+ const m = B(l, f), k = m.rows.filter((g) => g.diagnostics.length > 0).length;
346
+ return /* @__PURE__ */ _("div", { id: h, className: "zdtp-dashboard", role: "region", "aria-label": r, "data-mode": f, "data-chrome": o, children: [
347
+ /* @__PURE__ */ _("div", { className: "zdtp-dashboard__header", children: [
348
+ /* @__PURE__ */ v("div", { role: "heading", "aria-level": 2, className: "zdtp-dashboard__title", children: r }),
349
+ /* @__PURE__ */ _("div", { className: "zdtp-dashboard__summary", children: [
350
+ /* @__PURE__ */ _("span", { className: "zdtp-dashboard__count", children: [
351
+ m.rows.length,
351
352
  " tokens"
352
353
  ] }),
353
- /* @__PURE__ */ m("span", { children: [
354
+ /* @__PURE__ */ _("span", { children: [
354
355
  "Declared defaults · ",
355
- u,
356
+ f,
356
357
  " mode"
357
358
  ] }),
358
- _ > 0 && /* @__PURE__ */ m("span", { children: [
359
- _,
359
+ k > 0 && /* @__PURE__ */ _("span", { children: [
360
+ k,
360
361
  " with diagnostics"
361
362
  ] })
362
363
  ] })
363
364
  ] }),
364
- /* @__PURE__ */ m("div", { className: "zdtp-dashboard__inventory", style: { ...r.declarations, colorScheme: u }, children: [
365
- r.rows.length === 0 && /* @__PURE__ */ y("div", { className: "zdtp-dashboard__empty", children: "No tokens declared." }),
366
- r.tabs.map((v) => /* @__PURE__ */ m("div", { className: "zdtp-dashboard__tab", role: "group", "aria-label": v.label, children: [
367
- /* @__PURE__ */ m("div", { className: "zdtp-dashboard__tab-header", children: [
368
- /* @__PURE__ */ y("div", { role: "heading", "aria-level": 3, className: "zdtp-dashboard__tab-title", children: v.label }),
369
- /* @__PURE__ */ m("span", { className: "zdtp-dashboard__tab-count", children: [
370
- v.tiers.reduce((c, p) => c + p.rows.length, 0),
365
+ /* @__PURE__ */ _("div", { className: "zdtp-dashboard__inventory", style: m.declarations, children: [
366
+ m.rows.length === 0 && /* @__PURE__ */ v("div", { className: "zdtp-dashboard__empty", children: "No tokens declared." }),
367
+ m.tabs.map((g) => /* @__PURE__ */ _("div", { className: "zdtp-dashboard__tab", role: "group", "aria-label": g.label, children: [
368
+ /* @__PURE__ */ _("div", { className: "zdtp-dashboard__tab-header", children: [
369
+ /* @__PURE__ */ v("div", { role: "heading", "aria-level": 3, className: "zdtp-dashboard__tab-title", children: g.label }),
370
+ /* @__PURE__ */ _("span", { className: "zdtp-dashboard__tab-count", children: [
371
+ g.tiers.reduce((p, b) => p + b.rows.length, 0),
371
372
  " tokens"
372
373
  ] })
373
374
  ] }),
374
- v.tiers.map((c) => /* @__PURE__ */ m("div", { className: "zdtp-dashboard__tier", children: [
375
- /* @__PURE__ */ y("div", { role: "heading", "aria-level": 4, className: "zdtp-dashboard__tier-title", children: c.label }),
376
- /* @__PURE__ */ y("div", { className: c.palette ? "zdtp-dashboard__scroll zdtp-dashboard__palette-scroll" : void 0, role: c.palette ? "region" : void 0, tabIndex: c.palette ? 0 : void 0, "aria-label": c.palette ? `${c.label} palette stops` : void 0, children: /* @__PURE__ */ y("div", { className: `zdtp-dashboard__grid${c.palette ? " zdtp-dashboard__palette" : ""}`, role: "list", "aria-label": c.label, children: c.rows.map((p) => {
377
- const $ = L(p, c, g), z = !c.palette && ($ === "bar" || E($));
378
- return /* @__PURE__ */ m("div", { className: `zdtp-dashboard__token${z ? " zdtp-dashboard__token--wide" : ""}`, role: "listitem", "data-css-var": p.cssVar, children: [
379
- /* @__PURE__ */ y(P, { row: p, tier: c, kind: $, model: r, previewText: f }),
380
- /* @__PURE__ */ m("div", { className: "zdtp-dashboard__token-content", children: [
381
- /* @__PURE__ */ y("div", { className: "zdtp-dashboard__name", children: p.label }),
382
- /* @__PURE__ */ y("div", { className: "zdtp-dashboard__variable", children: p.cssVar }),
383
- /* @__PURE__ */ y("div", { className: "zdtp-dashboard__value", children: p.declaredValue || "(empty)" }),
384
- p.cssValue !== null && p.cssValue !== p.declaredValue && /* @__PURE__ */ m("div", { className: "zdtp-dashboard__reference", children: [
375
+ g.tiers.map((p) => /* @__PURE__ */ _("div", { className: "zdtp-dashboard__tier", children: [
376
+ /* @__PURE__ */ v("div", { role: "heading", "aria-level": 4, className: "zdtp-dashboard__tier-title", children: p.label }),
377
+ /* @__PURE__ */ v("div", { className: p.palette ? "zdtp-dashboard__scroll zdtp-dashboard__palette-scroll" : void 0, role: p.palette ? "region" : void 0, tabIndex: p.palette ? 0 : void 0, "aria-label": p.palette ? `${p.label} palette stops` : void 0, children: /* @__PURE__ */ v("div", { className: `zdtp-dashboard__grid${p.palette ? " zdtp-dashboard__palette" : ""}`, role: "list", "aria-label": p.label, children: p.rows.map((b) => {
378
+ const z = L(b, p, c), x = !p.palette && (z === "bar" || E(z));
379
+ return /* @__PURE__ */ _("div", { className: `zdtp-dashboard__token${x ? " zdtp-dashboard__token--wide" : ""}`, role: "listitem", "data-css-var": b.cssVar, children: [
380
+ /* @__PURE__ */ v(P, { row: b, tier: p, kind: z, model: m, previewText: a }),
381
+ /* @__PURE__ */ _("div", { className: "zdtp-dashboard__token-content", children: [
382
+ /* @__PURE__ */ v("div", { className: "zdtp-dashboard__name", children: b.label }),
383
+ /* @__PURE__ */ v("div", { className: "zdtp-dashboard__variable", children: b.cssVar }),
384
+ /* @__PURE__ */ v("div", { className: "zdtp-dashboard__value", children: b.declaredValue || "(empty)" }),
385
+ b.cssValue !== null && b.cssValue !== b.declaredValue && /* @__PURE__ */ _("div", { className: "zdtp-dashboard__reference", children: [
385
386
  "CSS: ",
386
- p.cssValue
387
+ b.cssValue
387
388
  ] }),
388
- p.references.length > 0 && /* @__PURE__ */ m("div", { className: "zdtp-dashboard__reference", children: [
389
+ b.references.length > 0 && /* @__PURE__ */ _("div", { className: "zdtp-dashboard__reference", children: [
389
390
  "References: ",
390
- p.references.map((k) => k.cssVar).join(", ")
391
+ b.references.map(($) => $.cssVar).join(", ")
391
392
  ] }),
392
- p.diagnostics.map((k, S) => /* @__PURE__ */ m("div", { className: "zdtp-dashboard__diagnostic", "data-diagnostic": k.code, children: [
393
- k.severity === "error" ? "Unavailable" : "Context needed",
393
+ b.diagnostics.map(($, N) => /* @__PURE__ */ _("div", { className: "zdtp-dashboard__diagnostic", "data-diagnostic": $.code, children: [
394
+ $.severity === "error" ? "Unavailable" : "Context needed",
394
395
  ": ",
395
- k.message
396
- ] }, S))
396
+ $.message
397
+ ] }, N))
397
398
  ] })
398
- ] }, p.key);
399
+ ] }, b.key);
399
400
  }) }) })
400
- ] }, c.key))
401
- ] }, v.key))
401
+ ] }, p.key))
402
+ ] }, g.key))
402
403
  ] })
403
404
  ] });
404
405
  }