uxml-preview 0.5.0 → 0.6.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.
package/dist/index.js CHANGED
@@ -1,93 +1,150 @@
1
- import { loadYoga as tt, PositionType as ne, Direction as be, Edge as q, BoxSizing as nt, FlexDirection as G, Wrap as Y, Justify as P, Align as W, Display as st, Overflow as rt } from "yoga-layout/load";
2
- function J(e) {
1
+ import { loadYoga as pt, PositionType as ue, Direction as De, Edge as te, BoxSizing as ht, FlexDirection as ne, Wrap as oe, Justify as J, Align as P, Display as mt, Overflow as gt } from "yoga-layout/load";
2
+ const Pe = {
3
+ // VisualElement is the base class and carries no class of its own.
4
+ VisualElement: { hasText: !1, classes: [], parts: [] },
5
+ Label: { hasText: !0, classes: ["unity-label"], parts: [] },
6
+ Button: { hasText: !0, classes: ["unity-button"], parts: [] },
7
+ // Image draws a texture, not text. Its picture reaches this renderer through
8
+ // `background-image` in USS, which `resolveAsset` can turn into something a
9
+ // browser will load; a texture assigned from C# has no path to follow here.
10
+ Image: { hasText: !1, classes: ["unity-image"], parts: [] },
11
+ /**
12
+ * Four elements from one tag. The names below are observed in
13
+ * `tests/golden/unity/scrollview-*.json`, not taken from documentation — the
14
+ * middle one, `unity-content-and-vertical-scroll-container`, is not in
15
+ * Unity's manual diagram at all and was found by dumping.
16
+ *
17
+ * The styles are inference, unlike the names: they are how this renderer
18
+ * reproduces the measured geometry, and the three `scrollview-*` golden cases
19
+ * are what decides whether the inference is right.
20
+ */
21
+ ScrollView: {
22
+ hasText: !1,
23
+ classes: ["unity-scroll-view"],
24
+ parts: [
25
+ // Fills the ScrollView's content box, and lays the viewport out beside
26
+ // the vertical scrollbar — hence row.
27
+ {
28
+ name: "unity-content-and-vertical-scroll-container",
29
+ style: { "flex-grow": "1", "flex-direction": "row" }
30
+ },
31
+ // What actually clips. Takes whatever width the scrollbar leaves.
32
+ { name: "unity-content-viewport", style: { "flex-grow": "1", overflow: "hidden" } },
33
+ // `flex-shrink: 0` is the whole reason a ScrollView is not one box:
34
+ // this grows to the content's height instead of being squeezed into the
35
+ // viewport's, so children keep their sizes and the viewport crops them.
36
+ // Without it three 60px children in a 100px view come out 33/34/33.
37
+ { name: "unity-content-container", style: { "flex-shrink": "0" } }
38
+ ]
39
+ }
40
+ }, de = { hasText: !1, classes: [], parts: [] }, yt = "UXML", bt = /* @__PURE__ */ new Set(["Style", "Template", "AttributeOverrides", "Bindings", "Columns"]);
41
+ function ye(e) {
42
+ return bt.has(e.name.local);
43
+ }
44
+ function X(e) {
45
+ var t;
46
+ if (((t = e.derived) == null ? void 0 : t.kind) === "template-container") return { spec: de, fallback: !1 };
47
+ const n = Pe[e.name.local];
48
+ return n !== void 0 ? { spec: n, fallback: !1 } : vt(e) ? { spec: de, fallback: !1 } : { spec: de, fallback: !0 };
49
+ }
50
+ function vt(e) {
51
+ return e.name.local === yt;
52
+ }
53
+ function wt(e) {
54
+ return X(e).spec.classes;
55
+ }
56
+ function kt() {
57
+ return Object.keys(Pe);
58
+ }
59
+ function Z(e) {
3
60
  const n = (t, s) => !Number.isInteger(t) || t < 0 || t > 1114111 || t >= 55296 && t <= 57343 ? s : String.fromCodePoint(t);
4
61
  return e.replace(/&#x([0-9a-f]+);/gi, (t, s) => n(parseInt(s, 16), t)).replace(/&#(\d+);/g, (t, s) => n(Number(s), t)).replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
5
62
  }
6
- function ye(e) {
63
+ function Me(e) {
7
64
  return e !== void 0 && /[A-Za-z0-9_.:-]/.test(e);
8
65
  }
9
- function xe(e) {
66
+ function Ce(e) {
10
67
  return e !== void 0 && /[A-Za-z_]/.test(e);
11
68
  }
12
- function it(e) {
69
+ function xt(e) {
13
70
  return e === " " || e === " " || e === `
14
71
  ` || e === "\r";
15
72
  }
16
- function Re(e) {
73
+ function We(e) {
17
74
  const n = [];
18
75
  let t = 0, s = 0;
19
- const i = () => s++;
20
- function r(a, f, l) {
76
+ const o = () => s++;
77
+ function i(d, m, a) {
21
78
  n.push({
22
79
  kind: "malformed",
23
- message: a,
24
- at: { in: "uxml", span: { start: f, end: l } }
80
+ message: d,
81
+ at: { in: "uxml", span: { start: m, end: a } }
25
82
  });
26
83
  }
27
- function u() {
28
- for (; it(e[t]); ) t++;
29
- }
30
84
  function c() {
85
+ for (; xt(e[t]); ) t++;
86
+ }
87
+ function u() {
31
88
  for (; ; ) {
32
- const a = e.indexOf("<", t);
33
- if (a < 0) {
89
+ const d = e.indexOf("<", t);
90
+ if (d < 0) {
34
91
  t = e.length;
35
92
  return;
36
93
  }
37
- const f = e[a + 1];
38
- if (f === "!") {
39
- if (e.startsWith("<!--", a)) {
40
- const l = e.indexOf("-->", a + 4);
41
- t = l < 0 ? e.length : l + 3;
42
- } else if (e.startsWith("<![CDATA[", a)) {
43
- const l = e.indexOf("]]>", a + 9);
44
- t = l < 0 ? e.length : l + 3;
94
+ const m = e[d + 1];
95
+ if (m === "!") {
96
+ if (e.startsWith("<!--", d)) {
97
+ const a = e.indexOf("-->", d + 4);
98
+ t = a < 0 ? e.length : a + 3;
99
+ } else if (e.startsWith("<![CDATA[", d)) {
100
+ const a = e.indexOf("]]>", d + 9);
101
+ t = a < 0 ? e.length : a + 3;
45
102
  } else {
46
- const l = e.indexOf(">", a);
47
- t = l < 0 ? e.length : l + 1;
103
+ const a = e.indexOf(">", d);
104
+ t = a < 0 ? e.length : a + 1;
48
105
  }
49
106
  continue;
50
107
  }
51
- if (f === "?") {
52
- const l = e.indexOf("?>", a + 2);
53
- t = l < 0 ? e.length : l + 2;
108
+ if (m === "?") {
109
+ const a = e.indexOf("?>", d + 2);
110
+ t = a < 0 ? e.length : a + 2;
54
111
  continue;
55
112
  }
56
- t = a;
113
+ t = d;
57
114
  return;
58
115
  }
59
116
  }
60
- function v() {
61
- const a = t;
62
- for (; ye(e[t]); ) t++;
63
- const f = e.slice(a, t), l = f.indexOf(":");
64
- return l < 0 ? { prefix: null, local: f } : { prefix: f.slice(0, l), local: f.slice(l + 1) };
65
- }
66
- function d() {
67
- const a = t;
68
- for (; ye(e[t]); ) t++;
69
- if (t === a) return null;
70
- const f = e.slice(a, t), l = t;
71
- if (u(), e[t] !== "=")
72
- return t = l, r(`attribute "${f}" has no value`, a, l), { name: f, value: "", span: { start: a, end: l } };
73
- t++, u();
74
- const h = e[t];
75
- if (h !== '"' && h !== "'")
76
- return r(`attribute "${f}" has an unquoted value`, a, t), { name: f, value: "", span: { start: a, end: t } };
117
+ function g() {
118
+ const d = t;
119
+ for (; Me(e[t]); ) t++;
120
+ const m = e.slice(d, t), a = m.indexOf(":");
121
+ return a < 0 ? { prefix: null, local: m } : { prefix: m.slice(0, a), local: m.slice(a + 1) };
122
+ }
123
+ function p() {
124
+ const d = t;
125
+ for (; Me(e[t]); ) t++;
126
+ if (t === d) return null;
127
+ const m = e.slice(d, t), a = t;
128
+ if (c(), e[t] !== "=")
129
+ return t = a, i(`attribute "${m}" has no value`, d, a), { name: m, value: "", span: { start: d, end: a } };
130
+ t++, c();
131
+ const b = e[t];
132
+ if (b !== '"' && b !== "'")
133
+ return i(`attribute "${m}" has an unquoted value`, d, t), { name: m, value: "", span: { start: d, end: t } };
77
134
  t++;
78
- const g = t, p = e.indexOf(h, t);
79
- return p < 0 ? (r(`attribute "${f}" has an unterminated value`, a, e.length), t = e.length, { name: f, value: e.slice(g), span: { start: a, end: t } }) : (t = p + 1, { name: f, value: e.slice(g, p), span: { start: a, end: t } });
135
+ const r = t, w = e.indexOf(b, t);
136
+ return w < 0 ? (i(`attribute "${m}" has an unterminated value`, d, e.length), t = e.length, { name: m, value: e.slice(r), span: { start: d, end: t } }) : (t = w + 1, { name: m, value: e.slice(r, w), span: { start: d, end: t } });
80
137
  }
81
- function o() {
82
- const a = t;
138
+ function l() {
139
+ const d = t;
83
140
  t++;
84
- const f = v(), l = [];
85
- let h = !1;
141
+ const m = g(), a = [];
142
+ let b = !1;
86
143
  for (; ; ) {
87
- u();
144
+ c();
88
145
  const k = e[t];
89
146
  if (k === void 0) {
90
- r("unterminated open tag", a, e.length);
147
+ i("unterminated open tag", d, e.length);
91
148
  break;
92
149
  }
93
150
  if (k === ">") {
@@ -95,60 +152,60 @@ function Re(e) {
95
152
  break;
96
153
  }
97
154
  if (k === "/" && e[t + 1] === ">") {
98
- t += 2, h = !0;
155
+ t += 2, b = !0;
99
156
  break;
100
157
  }
101
- const x = d();
102
- if (x === null) {
158
+ const v = p();
159
+ if (v === null) {
103
160
  t++;
104
161
  continue;
105
162
  }
106
- l.push(x);
163
+ a.push(v);
107
164
  }
108
- const g = { start: a, end: t };
109
- if (h)
165
+ const r = { start: d, end: t };
166
+ if (b)
110
167
  return {
111
- id: i(),
112
- name: f,
113
- attributes: l,
168
+ id: o(),
169
+ name: m,
170
+ attributes: a,
114
171
  children: [],
115
- spans: { openTag: g, inner: { start: t, end: t }, closeTag: null },
172
+ spans: { openTag: r, inner: { start: t, end: t }, closeTag: null },
116
173
  tagDirty: !1,
117
174
  childrenDirty: !1
118
175
  };
119
- const p = t, b = [];
176
+ const w = t, y = [];
120
177
  for (; ; ) {
121
- if (c(), t >= e.length) {
122
- r(`unterminated element <${Ce(f)}>`, a, e.length);
178
+ if (u(), t >= e.length) {
179
+ i(`unterminated element <${_e(m)}>`, d, e.length);
123
180
  break;
124
181
  }
125
182
  const k = e[t + 1];
126
183
  if (k === "/") break;
127
- if (!xe(k)) {
184
+ if (!Ce(k)) {
128
185
  t++;
129
186
  continue;
130
187
  }
131
- b.push(o());
188
+ y.push(l());
132
189
  }
133
- const m = t;
134
- let y = null;
190
+ const h = t;
191
+ let f = null;
135
192
  if (e.startsWith("</", t)) {
136
- const k = e.indexOf(">", t), x = k < 0 ? e.length : k + 1;
137
- k < 0 && r("unterminated end tag", t, x), y = { start: t, end: x }, t = x;
193
+ const k = e.indexOf(">", t), v = k < 0 ? e.length : k + 1;
194
+ k < 0 && i("unterminated end tag", t, v), f = { start: t, end: v }, t = v;
138
195
  }
139
196
  return {
140
- id: i(),
141
- name: f,
142
- attributes: l,
143
- children: b,
144
- spans: { openTag: g, inner: { start: p, end: m }, closeTag: y },
197
+ id: o(),
198
+ name: m,
199
+ attributes: a,
200
+ children: y,
201
+ spans: { openTag: r, inner: { start: w, end: h }, closeTag: f },
145
202
  tagDirty: !1,
146
203
  childrenDirty: !1
147
204
  };
148
205
  }
149
- return c(), t < e.length && xe(e[t + 1]) ? { root: o(), warnings: n } : (r("no root element", 0, 0), {
206
+ return u(), t < e.length && Ce(e[t + 1]) ? { root: l(), warnings: n } : (i("no root element", 0, 0), {
150
207
  root: {
151
- id: i(),
208
+ id: o(),
152
209
  name: { prefix: null, local: "" },
153
210
  attributes: [],
154
211
  children: [],
@@ -159,56 +216,57 @@ function Re(e) {
159
216
  warnings: n
160
217
  });
161
218
  }
162
- function Ce(e) {
219
+ function _e(e) {
163
220
  return e.prefix === null ? e.local : `${e.prefix}:${e.local}`;
164
221
  }
165
- let Me;
166
- function ot(e) {
167
- Me = e;
222
+ let Be;
223
+ function St(e) {
224
+ Be = e;
168
225
  }
169
- const Ue = /* @__PURE__ */ new WeakMap();
170
- function lt(e, n) {
171
- Ue.set(e, n);
226
+ const He = /* @__PURE__ */ new WeakMap();
227
+ function $t(e, n) {
228
+ He.set(e, n);
172
229
  }
173
- function bn(e) {
174
- return Re(e).root.children.filter((t) => t.name.local === "Template").flatMap((t) => {
175
- const s = Le(t, "src");
176
- return s === void 0 || s.length === 0 ? [] : [J(s)];
230
+ function Fn(e) {
231
+ return We(e).root.children.filter((t) => t.name.local === "Template").flatMap((t) => {
232
+ const s = Ve(t, "src");
233
+ return s === void 0 || s.length === 0 ? [] : [Z(s)];
177
234
  });
178
235
  }
179
- const ke = 32;
180
- function Le(e, n) {
236
+ const Re = 32;
237
+ function Ve(e, n) {
181
238
  var t;
182
239
  return (t = e.attributes.find((s) => s.name === n)) == null ? void 0 : t.value;
183
240
  }
184
- function U(e, n) {
185
- const t = Le(e, n);
186
- return t === void 0 ? void 0 : J(t);
241
+ function F(e, n) {
242
+ const t = Ve(e, n);
243
+ return t === void 0 ? void 0 : Z(t);
187
244
  }
188
- function We(e) {
245
+ function qe(e) {
189
246
  const n = /* @__PURE__ */ new Map();
190
247
  for (const t of e.root.children) {
191
248
  if (t.name.local !== "Template") continue;
192
- const s = U(t, "name"), i = U(t, "src");
193
- s === void 0 || s.length === 0 || i === void 0 || i.length === 0 || n.set(s, { name: s, src: i, node: t });
249
+ const s = F(t, "name"), o = F(t, "src");
250
+ s === void 0 || s.length === 0 || o === void 0 || o.length === 0 || n.set(s, { name: s, src: o, node: t });
194
251
  }
195
252
  return n;
196
253
  }
197
- function ze(e, n) {
254
+ function Ye(e, n) {
198
255
  return JSON.stringify([e, n]);
199
256
  }
200
- function at(e) {
257
+ function Tt(e) {
201
258
  return /(?:^|\/)Packages\//i.test(e) || /PackageCache/i.test(e);
202
259
  }
203
- function j(e, n, t, s, i) {
260
+ function V(e, n, t, s, o, i = {}) {
204
261
  e.push({
205
262
  kind: n,
206
263
  message: t,
207
264
  ...s === void 0 ? {} : { node: s.id },
208
- ...i === void 0 ? {} : { sourceDocument: i }
265
+ ...o === void 0 ? {} : { sourceDocument: o },
266
+ ...i
209
267
  });
210
268
  }
211
- function ee(e, n = 0, t = void 0) {
269
+ function le(e, n = 0, t = void 0) {
212
270
  return {
213
271
  ...e,
214
272
  span: {
@@ -218,140 +276,146 @@ function ee(e, n = 0, t = void 0) {
218
276
  ...t === void 0 ? {} : { sourceDocument: t }
219
277
  };
220
278
  }
221
- function _e(e) {
279
+ function Je(e) {
222
280
  return { prefix: e.prefix, local: e.local };
223
281
  }
224
- function Se() {
282
+ function je() {
225
283
  return { start: 0, end: 0 };
226
284
  }
227
- function se(e, n) {
285
+ function fe(e, n) {
228
286
  return { start: e.start + n, end: e.end + n };
229
287
  }
230
- function ct(e, n, t, s, i) {
288
+ function Et(e, n, t, s, o) {
231
289
  return {
232
290
  id: e,
233
291
  name: n,
234
292
  attributes: t,
235
293
  children: s,
236
- spans: { openTag: Se(), inner: Se(), closeTag: null },
294
+ spans: { openTag: je(), inner: je(), closeTag: null },
237
295
  tagDirty: !1,
238
296
  childrenDirty: !1,
239
- ...i === void 0 ? {} : { derived: { kind: "template-container", instance: i } }
297
+ ...o === void 0 ? {} : { derived: { kind: "template-container", instance: o } }
240
298
  };
241
299
  }
242
- function ut(e, n, t) {
243
- const s = e.items.map((i) => i.kind !== "import" || i.resolvedSheet === void 0 ? i.kind === "rule" ? {
244
- ...i,
300
+ function Ot(e, n, t) {
301
+ const s = e.items.map((o) => o.kind !== "import" || o.resolvedSheet === void 0 ? o.kind === "rule" ? {
302
+ ...o,
245
303
  rule: {
246
- ...i.rule,
247
- selectors: i.rule.selectors.map((r) => ({
248
- ...r,
249
- parts: r.parts.map((u) => ({ ...u, simple: [...u.simple] }))
304
+ ...o.rule,
305
+ selectors: o.rule.selectors.map((i) => ({
306
+ ...i,
307
+ parts: i.parts.map((c) => ({ ...c, simple: [...c.simple] }))
250
308
  })),
251
- declarations: i.rule.declarations.map((r) => ({ ...r }))
309
+ declarations: o.rule.declarations.map((i) => ({ ...i }))
252
310
  }
253
- } : { ...i } : { ...i, resolvedSheet: i.resolvedSheet + n });
311
+ } : { ...o } : { ...o, resolvedSheet: o.resolvedSheet + n });
254
312
  return { ...e, items: s, sourceDocumentFrom: t };
255
313
  }
256
- function dt(e, n) {
314
+ function It(e, n) {
257
315
  const t = n.sheetOffsets.get(e.document);
258
316
  if (t !== void 0) return t;
259
- const s = n.sheets.length, i = e.document.sheets.map((u, c) => s + c), r = e.document.sheets.map(() => e.url);
260
- return e.document.sheets.forEach((u, c) => {
261
- for (const v of u.items)
262
- v.kind === "import" && v.resolvedSheet !== void 0 && (r[v.resolvedSheet] = u.origin ?? e.url);
263
- }), n.sheetOffsets.set(e.document, i), e.document.sheets.forEach(
264
- (u, c) => n.sheets.push(ut(u, s, r[c]))
265
- ), i;
266
- }
267
- function je(e, n) {
317
+ const s = n.sheets.length, o = e.document.sheets.map((c, u) => s + u), i = e.document.sheets.map(() => e.url);
318
+ return e.document.sheets.forEach((c, u) => {
319
+ for (const g of c.items)
320
+ g.kind === "import" && g.resolvedSheet !== void 0 && (i[g.resolvedSheet] = c.origin ?? e.url);
321
+ }), n.sheetOffsets.set(e.document, o), e.document.sheets.forEach(
322
+ (c, u) => n.sheets.push(Ot(c, s, i[u]))
323
+ ), o;
324
+ }
325
+ function Ge(e, n) {
268
326
  const t = n.sourceOffsets.get(e);
269
327
  if (t !== void 0) return t;
270
328
  const s = n.sourceLength + 1;
271
329
  return n.sourceOffsets.set(e, s), n.sources.push(`
272
330
  ${e.source}`), n.sourceLength += e.source.length + 1, s;
273
331
  }
274
- function ft(e, n, t, s, i) {
275
- for (const r of e.document.styleRoots ?? []) {
276
- const u = n[r.sheet];
277
- if (u === void 0) continue;
278
- const c = t.nodes.get(r.scope) ?? s.id;
279
- i.styleRoots.push({ sheet: u, scope: c });
332
+ function Dt(e, n, t, s, o) {
333
+ for (const i of e.document.styleRoots ?? []) {
334
+ const c = n[i.sheet];
335
+ if (c === void 0) continue;
336
+ const u = t.nodes.get(i.scope) ?? s.id;
337
+ o.styleRoots.push({ sheet: c, scope: u });
280
338
  }
281
339
  }
282
- function pt(e) {
340
+ function Mt(e) {
283
341
  return e.map((n) => {
284
- const t = U(n, "name"), s = U(n, "slot");
342
+ const t = F(n, "name"), s = F(n, "slot");
285
343
  return `<${n.name.local}${t === void 0 ? "" : ` name="${t}"`}${s === void 0 ? "" : ` slot="${s}"`}>`;
286
344
  });
287
345
  }
288
- function Fe(e, n) {
289
- const t = U(e, "slot-name");
346
+ function Ke(e, n) {
347
+ const t = F(e, "slot-name");
290
348
  t !== void 0 && t.length > 0 && n.add(t);
291
- for (const s of e.children) Fe(s, n);
349
+ for (const s of e.children) Ke(s, n);
292
350
  }
293
- function V(e, n, t, s, i) {
294
- const r = /* @__PURE__ */ new Set();
295
- t !== null && Fe(t.document.root, r), !(r.size === 0 && n.length === 0) && j(
296
- i.warnings,
351
+ function ee(e, n, t, s, o) {
352
+ const i = /* @__PURE__ */ new Set();
353
+ t !== null && Ke(t.document.root, i), !(i.size === 0 && n.length === 0) && V(
354
+ o.warnings,
297
355
  "template-slot-unsupported",
298
- `Template slots are unsupported; defined slot names: ${t === null ? "(unavailable)" : r.size === 0 ? "(none)" : [...r].join(", ")}; children not placed: ${n.length === 0 ? "(none)" : pt(n).join(", ")}`,
356
+ `Template slots are unsupported; defined slot names: ${t === null ? "(unavailable)" : i.size === 0 ? "(none)" : [...i].join(", ")}; children not placed: ${n.length === 0 ? "(none)" : Mt(n).join(", ")}`,
299
357
  e,
300
- s
358
+ s,
359
+ { reason: "not-rendered" }
301
360
  );
302
361
  }
303
- function pe(e, n) {
304
- if (e.name.local !== "Style" && e.name.local !== "Template" && e.name.local !== "AttributeOverrides") {
305
- const t = U(e, "name");
362
+ function $e(e, n) {
363
+ if (!ye(e)) {
364
+ const t = F(e, "name");
306
365
  t !== void 0 && t.length > 0 && n.set(t, (n.get(t) ?? 0) + 1);
307
366
  }
308
- for (const t of e.children) pe(t, n);
367
+ for (const t of e.children) $e(t, n);
309
368
  }
310
- function Pe(e, n, t) {
311
- U(e, "name") === n && t.push(e);
312
- for (const s of e.children) Pe(s, n, t);
369
+ function Xe(e, n, t) {
370
+ F(e, "name") === n && t.push(e);
371
+ for (const s of e.children) Xe(s, n, t);
313
372
  }
314
- function ht(e, n, t, s, i) {
373
+ function Ct(e, n, t, s, o) {
315
374
  if (n.length === 0) return;
316
- const r = /* @__PURE__ */ new Map();
317
- pe(e, r);
318
- for (const u of n) {
319
- const c = U(u, "element-name"), v = U(u, "style");
320
- if (v !== void 0 && j(
321
- i.warnings,
375
+ const i = /* @__PURE__ */ new Map();
376
+ $e(e, i);
377
+ for (const c of n) {
378
+ const u = F(c, "element-name"), g = F(c, "style");
379
+ if (g !== void 0 && V(
380
+ o.warnings,
322
381
  "override-style-ignored",
323
- `AttributeOverrides style for element-name "${c ?? "(missing)"}" was ignored with value "${v}"; Unity ignores style AttributeOverrides, so this matches Unity and is not a preview limitation.`,
324
- u,
325
- s ?? void 0
326
- ), c === void 0 || c.length === 0) continue;
327
- const d = [];
328
- if (Pe(e, c, d), d.length === 0) {
329
- const o = [...r.keys()];
330
- j(
331
- i.warnings,
382
+ `AttributeOverrides style for element-name "${u ?? "(missing)"}" was ignored with value "${g}"`,
383
+ c,
384
+ s ?? void 0,
385
+ {
386
+ reason: "matches-unity",
387
+ ...u === void 0 ? {} : { subject: { kind: "name", name: u } }
388
+ }
389
+ ), u === void 0 || u.length === 0) continue;
390
+ const p = [];
391
+ if (Xe(e, u, p), p.length === 0) {
392
+ const l = [...i.keys()];
393
+ V(
394
+ o.warnings,
332
395
  "override-target-missing",
333
- `AttributeOverrides target "${c}" matched no element; available names: ${o.length === 0 ? "(none)" : o.join(", ")}`,
334
- u,
335
- s ?? void 0
396
+ `AttributeOverrides target "${u}" matched no element; available names: ${l.length === 0 ? "(none)" : l.join(", ")}`,
397
+ c,
398
+ s ?? void 0,
399
+ { reason: "invalid-value", subject: { kind: "name", name: u } }
336
400
  );
337
401
  continue;
338
402
  }
339
- for (const o of d)
340
- for (const a of u.attributes) {
341
- if (a.name === "element-name" || a.name === "style") continue;
342
- const f = o.attributes.find((l) => l.name === a.name);
343
- f === void 0 ? o.attributes.push(ee(a, t, s)) : (f.value = a.value, f.sourceDocument = s);
403
+ for (const l of p)
404
+ for (const d of c.attributes) {
405
+ if (d.name === "element-name" || d.name === "style") continue;
406
+ const m = l.attributes.find((a) => a.name === d.name);
407
+ m === void 0 ? l.attributes.push(le(d, t, s)) : (m.value = d.value, m.sourceDocument = s);
344
408
  }
345
409
  }
346
410
  }
347
- function Be(e) {
348
- return e.name.local === "Template" || e.name.local === "Instance" ? !0 : e.children.some(Be);
411
+ function Ze(e) {
412
+ return e.name.local === "Template" || e.name.local === "Instance" ? !0 : e.children.some(Ze);
349
413
  }
350
- function mt(e, n) {
414
+ function Rt(e, n) {
351
415
  let t = 0;
352
- const s = (i) => {
353
- t = Math.max(t, Number(i.id) + 1);
354
- for (const r of i.children) s(r);
416
+ const s = (o) => {
417
+ t = Math.max(t, Number(o.id) + 1);
418
+ for (const i of o.children) s(i);
355
419
  };
356
420
  return s(e.root), {
357
421
  resolver: n,
@@ -368,101 +432,108 @@ function mt(e, n) {
368
432
  stack: []
369
433
  };
370
434
  }
371
- function gt(e, n, t) {
372
- var v;
373
- const s = ze(e.src, n);
435
+ function jt(e, n, t) {
436
+ var g;
437
+ const s = Ye(e.src, n);
374
438
  if (t.cache.has(s)) return t.cache.get(s) ?? null;
375
- const i = ((v = t.resolver) == null ? void 0 : v.call(t, e.src, n)) ?? null;
376
- if (i === null)
377
- return t.cache.set(s, null), j(
439
+ const o = ((g = t.resolver) == null ? void 0 : g.call(t, e.src, n)) ?? null;
440
+ if (o === null)
441
+ return t.cache.set(s, null), V(
378
442
  t.warnings,
379
443
  "template-src-unresolved",
380
444
  `Template "${e.name}" src "${e.src}" could not be resolved from ${n === null ? "the entry UXML" : `"${n}"`}; attempted resolveImport("${e.src}", ${n === null ? "null" : `"${n}"`}); internal filesystem search paths: none`,
381
445
  e.node,
382
- n ?? void 0
383
- ), at(e.src) && j(
446
+ n ?? void 0,
447
+ { subject: { kind: "import", url: e.src, from: n } }
448
+ ), Tt(e.src) && V(
384
449
  t.warnings,
385
450
  "package-path-not-searched",
386
451
  `Template src "${e.src}" was unresolved; the resolver returned no source and the core does not independently search Unity Packages/Library/PackageCache paths`,
387
452
  e.node,
388
- n ?? void 0
453
+ n ?? void 0,
454
+ { reason: "not-rendered", subject: { kind: "import", url: e.src, from: n } }
389
455
  ), null;
390
- const r = Me;
391
- if (r === void 0)
456
+ const i = Be;
457
+ if (i === void 0)
392
458
  throw new Error("template parser is not registered; import parse from src/index before expansion");
393
- const u = r(
394
- i,
395
- t.resolver === void 0 ? void 0 : (d, o) => t.resolver(d, o ?? e.src)
396
- ), c = {
459
+ const c = i(
460
+ o,
461
+ t.resolver === void 0 ? void 0 : (p, l) => t.resolver(p, l ?? e.src)
462
+ ), u = {
397
463
  url: e.src,
398
464
  from: n,
399
- document: u,
400
- declarations: We(u)
465
+ document: c,
466
+ declarations: qe(c)
401
467
  };
402
- return t.cache.set(s, c), c;
468
+ return t.cache.set(s, u), u;
403
469
  }
404
- function wt(e, n, t) {
405
- var s, i;
470
+ function Nt(e, n, t) {
471
+ var s, o, i, c;
406
472
  if (!t.reportedWarnings.has(e.document)) {
407
473
  t.reportedWarnings.add(e.document);
408
- for (const r of e.document.warnings)
409
- ((s = r.at) == null ? void 0 : s.in) === "uss" ? t.warnings.push({
410
- ...r,
411
- at: { ...r.at, sheet: n[r.at.sheet] ?? r.at.sheet },
412
- sourceDocument: ((i = e.document.sheets[r.at.sheet]) == null ? void 0 : i.origin) ?? e.url
413
- }) : t.warnings.push({ ...r, sourceDocument: e.url });
414
- }
415
- }
416
- function te(e, n, t, s, i, r) {
417
- const u = i ? e.id : n.nextId(), c = s === null ? 0 : n.sourceOffsets.get(s.document) ?? 0, v = c === 0 || s === null ? void 0 : s.url, d = {
418
- id: u,
419
- name: _e(e.name),
420
- attributes: e.attributes.map((o) => ee(o, c, v)),
474
+ for (const u of e.document.warnings)
475
+ ((s = u.at) == null ? void 0 : s.in) === "uss" ? t.warnings.push({
476
+ ...u,
477
+ at: {
478
+ ...u.at,
479
+ sheet: n[u.at.sheet] ?? u.at.sheet,
480
+ url: ((o = e.document.sheets[u.at.sheet]) == null ? void 0 : o.origin) ?? null,
481
+ from: ((i = t.sheets[n[u.at.sheet] ?? u.at.sheet]) == null ? void 0 : i.sourceDocumentFrom) ?? null
482
+ },
483
+ sourceDocument: ((c = e.document.sheets[u.at.sheet]) == null ? void 0 : c.origin) ?? e.url
484
+ }) : t.warnings.push({ ...u, sourceDocument: e.url });
485
+ }
486
+ }
487
+ function ce(e, n, t, s, o, i) {
488
+ const c = o ? e.id : n.nextId(), u = s === null ? 0 : n.sourceOffsets.get(s.document) ?? 0, g = u === 0 || s === null ? void 0 : s.url, p = {
489
+ id: c,
490
+ name: Je(e.name),
491
+ attributes: e.attributes.map((l) => le(l, u, g)),
421
492
  children: [],
422
493
  spans: {
423
- openTag: se(e.spans.openTag, c),
424
- inner: se(e.spans.inner, c),
425
- closeTag: e.spans.closeTag === null ? null : se(e.spans.closeTag, c)
494
+ openTag: fe(e.spans.openTag, u),
495
+ inner: fe(e.spans.inner, u),
496
+ closeTag: e.spans.closeTag === null ? null : fe(e.spans.closeTag, u)
426
497
  },
427
498
  tagDirty: e.tagDirty,
428
499
  childrenDirty: e.childrenDirty,
429
- ...c === 0 || s === null ? {} : {
500
+ ...u === 0 || s === null ? {} : {
430
501
  sourceDocument: s.url,
431
502
  sourceDocumentFrom: s.from,
432
503
  sourceNode: e.id
433
504
  }
434
505
  };
435
- t.nodes.set(e.id, d.id);
436
- for (const o of e.children)
437
- if (!(o.name.local === "Template" || o.name.local === "Style")) {
438
- if (o.name.local === "Instance") {
439
- d.children.push(he(o, n, s, t, r + 1));
506
+ t.nodes.set(e.id, p.id);
507
+ for (const l of e.children)
508
+ if (!(l.name.local === "Template" || l.name.local === "Style")) {
509
+ if (l.name.local === "Instance") {
510
+ p.children.push(Te(l, n, s, t, i + 1));
440
511
  continue;
441
512
  }
442
- o.name.local !== "AttributeOverrides" && U(o, "slot") === void 0 && d.children.push(te(o, n, t, s, i, r));
513
+ l.name.local !== "AttributeOverrides" && F(l, "slot") === void 0 && p.children.push(ce(l, n, t, s, o, i));
443
514
  }
444
- return d;
445
- }
446
- function vt(e, n, t, s) {
447
- je(e.document, t);
448
- const i = { nodes: /* @__PURE__ */ new Map([[e.document.root.id, n.id]]) };
449
- for (const r of e.document.root.children)
450
- if (!(r.name.local === "Template" || r.name.local === "Style")) {
451
- if (r.name.local === "Instance") {
452
- n.children.push(he(r, t, e, i, s + 1));
515
+ return p;
516
+ }
517
+ function At(e, n, t, s) {
518
+ Ge(e.document, t);
519
+ const o = { nodes: /* @__PURE__ */ new Map([[e.document.root.id, n.id]]) };
520
+ for (const i of e.document.root.children)
521
+ if (!(i.name.local === "Template" || i.name.local === "Style")) {
522
+ if (i.name.local === "Instance") {
523
+ n.children.push(Te(i, t, e, o, s + 1));
453
524
  continue;
454
525
  }
455
- r.name.local !== "AttributeOverrides" && U(r, "slot") === void 0 && n.children.push(te(r, t, i, e, !1, s));
526
+ i.name.local !== "AttributeOverrides" && F(i, "slot") === void 0 && n.children.push(ce(i, t, o, e, !1, s));
456
527
  }
457
- return i;
528
+ return o;
458
529
  }
459
- function he(e, n, t, s, i) {
460
- const r = ct(
530
+ function Te(e, n, t, s, o) {
531
+ const i = Et(
461
532
  n.nextId(),
462
533
  { prefix: e.name.prefix, local: "TemplateContainer" },
463
- e.attributes.filter((b) => b.name !== "template").map(
464
- (b) => ee(
465
- b,
534
+ e.attributes.filter((y) => y.name !== "template").map(
535
+ (y) => le(
536
+ y,
466
537
  t === null ? 0 : n.sourceOffsets.get(t.document) ?? 0,
467
538
  t === null || t.url.length === 0 ? null : t.url
468
539
  )
@@ -470,74 +541,80 @@ function he(e, n, t, s, i) {
470
541
  [],
471
542
  e.id
472
543
  );
473
- t !== null && (r.sourceDocument = t.url.length > 0 ? t.url : null, r.sourceDocumentFrom = t.from), s.nodes.set(e.id, r.id);
474
- const u = U(e, "template"), c = e.children.filter((b) => U(b, "slot") !== void 0), v = t === null || t.url.length === 0 ? void 0 : t.url, d = t == null ? void 0 : t.declarations.get(u ?? "");
475
- if (d === void 0)
476
- return V(e, c, null, v, n), j(
544
+ t !== null && (i.sourceDocument = t.url.length > 0 ? t.url : null, i.sourceDocumentFrom = t.from), s.nodes.set(e.id, i.id);
545
+ const c = F(e, "template"), u = e.children.filter((y) => F(y, "slot") !== void 0), g = t === null || t.url.length === 0 ? void 0 : t.url, p = t == null ? void 0 : t.declarations.get(c ?? "");
546
+ if (p === void 0)
547
+ return ee(e, u, null, g, n), V(
477
548
  n.warnings,
478
549
  "template-not-declared",
479
- `Instance${u === void 0 ? "" : ` template "${u}"`} has no matching Template declaration`,
550
+ `Instance${c === void 0 ? "" : ` template "${c}"`} has no matching Template declaration`,
480
551
  e,
481
- v
482
- ), r;
483
- const o = t === null || t.url.length === 0 ? null : t.url, a = {
484
- key: JSON.stringify([d.name, d.src, o]),
485
- label: `${d.name}@${d.src}`
486
- }, f = n.stack.findIndex((b) => b.key === a.key);
487
- if (f >= 0) {
488
- const b = n.cache.get(ze(d.src, o)) ?? null;
489
- V(e, c, b, v, n);
490
- const m = [...n.stack.slice(f), a].map((y) => y.label).join(" -> ");
491
- return j(
552
+ g,
553
+ {
554
+ reason: "invalid-value",
555
+ ...c === void 0 ? {} : { subject: { kind: "name", name: c } }
556
+ }
557
+ ), i;
558
+ const l = t === null || t.url.length === 0 ? null : t.url, d = {
559
+ key: JSON.stringify([p.name, p.src, l]),
560
+ label: `${p.name}@${p.src}`
561
+ }, m = n.stack.findIndex((y) => y.key === d.key);
562
+ if (m >= 0) {
563
+ const y = n.cache.get(Ye(p.src, l)) ?? null;
564
+ ee(e, u, y, g, n);
565
+ const h = [...n.stack.slice(m), d].map((f) => f.label).join(" -> ");
566
+ return V(
492
567
  n.warnings,
493
568
  "template-cycle",
494
- `Template cycle detected: ${m}`,
569
+ `Template cycle detected: ${h}`,
495
570
  e,
496
- v
497
- ), r;
571
+ g,
572
+ { reason: "invalid-value" }
573
+ ), i;
498
574
  }
499
- if (i >= ke)
500
- return V(e, c, null, v, n), j(
575
+ if (o >= Re)
576
+ return ee(e, u, null, g, n), V(
501
577
  n.warnings,
502
578
  "template-depth-exceeded",
503
- `Template expansion exceeded the depth limit ${ke}: ${[
579
+ `Template expansion exceeded the depth limit ${Re}: ${[
504
580
  ...n.stack,
505
- a
506
- ].map((b) => b.label).join(" -> ")}`,
581
+ d
582
+ ].map((y) => y.label).join(" -> ")}`,
507
583
  e,
508
- v
509
- ), r;
510
- const l = gt(d, o, n);
511
- if (l === null)
512
- return V(e, c, null, v, n), r;
513
- je(l.document, n), n.stack.push(a);
514
- const h = vt(l, r, n, i);
584
+ g,
585
+ { reason: "not-rendered" }
586
+ ), i;
587
+ const a = jt(p, l, n);
588
+ if (a === null)
589
+ return ee(e, u, null, g, n), i;
590
+ Ge(a.document, n), n.stack.push(d);
591
+ const b = At(a, i, n, o);
515
592
  n.stack.pop();
516
- const g = dt(l, n);
517
- wt(l, g, n), ft(l, g, h, r, n);
518
- const p = e.children.filter((b) => b.name.local === "AttributeOverrides");
519
- V(e, c, l, v, n), ht(
520
- r,
521
- p,
593
+ const r = It(a, n);
594
+ Nt(a, r, n), Dt(a, r, b, i, n);
595
+ const w = e.children.filter((y) => y.name.local === "AttributeOverrides");
596
+ ee(e, u, a, g, n), Ct(
597
+ i,
598
+ w,
522
599
  t === null ? 0 : n.sourceOffsets.get(t.document) ?? 0,
523
600
  t === null || t.url.length === 0 ? null : t.url,
524
601
  n
525
602
  );
526
- for (const b of e.children)
527
- b.name.local === "AttributeOverrides" || b.name.local === "Style" || U(b, "slot") !== void 0 || r.children.push(te(b, n, s, t, !1, i));
528
- return r;
603
+ for (const y of e.children)
604
+ y.name.local === "AttributeOverrides" || y.name.local === "Style" || F(y, "slot") !== void 0 || i.children.push(ce(y, n, s, t, !1, o));
605
+ return i;
529
606
  }
530
- function bt(e) {
531
- if (!Be(e.root)) return { document: e, warnings: [] };
532
- const n = mt(e, Ue.get(e)), t = n.styleRoots.length, s = {
607
+ function Lt(e) {
608
+ if (!Ze(e.root)) return { document: e, warnings: [] };
609
+ const n = Rt(e, He.get(e)), t = n.styleRoots.length, s = {
533
610
  url: "",
534
611
  from: null,
535
612
  document: e,
536
- declarations: We(e)
537
- }, i = { nodes: /* @__PURE__ */ new Map([[e.root.id, e.root.id]]) }, r = {
613
+ declarations: qe(e)
614
+ }, o = { nodes: /* @__PURE__ */ new Map([[e.root.id, e.root.id]]) }, i = {
538
615
  id: e.root.id,
539
- name: _e(e.root.name),
540
- attributes: e.root.attributes.map((c) => ee(c)),
616
+ name: Je(e.root.name),
617
+ attributes: e.root.attributes.map((u) => le(u)),
541
618
  children: [],
542
619
  spans: {
543
620
  openTag: { ...e.root.spans.openTag },
@@ -547,30 +624,33 @@ function bt(e) {
547
624
  tagDirty: e.root.tagDirty,
548
625
  childrenDirty: e.root.childrenDirty
549
626
  };
550
- for (const c of e.root.children)
551
- if (!(c.name.local === "Template" || c.name.local === "Style")) {
552
- if (c.name.local === "Instance") {
553
- r.children.push(he(c, n, s, i, 0));
627
+ for (const u of e.root.children)
628
+ if (!(u.name.local === "Template" || u.name.local === "Style")) {
629
+ if (u.name.local === "Instance") {
630
+ i.children.push(Te(u, n, s, o, 0));
554
631
  continue;
555
632
  }
556
- c.name.local !== "AttributeOverrides" && U(c, "slot") === void 0 && r.children.push(te(c, n, i, s, !0, 0));
633
+ u.name.local !== "AttributeOverrides" && F(u, "slot") === void 0 && i.children.push(ce(u, n, o, s, !0, 0));
557
634
  }
558
- for (let c = 0; c < t; c++) {
559
- const v = n.styleRoots[c], d = i.nodes.get(v.scope);
560
- d !== void 0 && (n.styleRoots[c] = { ...v, scope: d });
561
- }
562
- const u = /* @__PURE__ */ new Map();
563
- pe(r, u);
564
- for (const [c, v] of u)
565
- v > 1 && j(
635
+ for (let u = 0; u < t; u++) {
636
+ const g = n.styleRoots[u], p = o.nodes.get(g.scope);
637
+ p !== void 0 && (n.styleRoots[u] = { ...g, scope: p });
638
+ }
639
+ const c = /* @__PURE__ */ new Map();
640
+ $e(i, c);
641
+ for (const [u, g] of c)
642
+ g > 1 && V(
566
643
  n.warnings,
567
644
  "duplicate-name-in-tree",
568
- `name "${c}" occurs ${v} times after template expansion`
645
+ `name "${u}" occurs ${g} times after template expansion`,
646
+ void 0,
647
+ void 0,
648
+ { reason: "matches-unity", subject: { kind: "name", name: u } }
569
649
  );
570
650
  return {
571
651
  document: {
572
652
  ...e,
573
- root: r,
653
+ root: i,
574
654
  source: n.sources.join(""),
575
655
  sheets: n.sheets,
576
656
  styleRoots: n.styleRoots
@@ -578,64 +658,7 @@ function bt(e) {
578
658
  warnings: n.warnings
579
659
  };
580
660
  }
581
- const He = {
582
- // VisualElement is the base class and carries no class of its own.
583
- VisualElement: { hasText: !1, classes: [], parts: [] },
584
- Label: { hasText: !0, classes: ["unity-label"], parts: [] },
585
- Button: { hasText: !0, classes: ["unity-button"], parts: [] },
586
- // Image draws a texture, not text. Its picture reaches this renderer through
587
- // `background-image` in USS, which `resolveAsset` can turn into something a
588
- // browser will load; a texture assigned from C# has no path to follow here.
589
- Image: { hasText: !1, classes: ["unity-image"], parts: [] },
590
- /**
591
- * Four elements from one tag. The names below are observed in
592
- * `tests/golden/unity/scrollview-*.json`, not taken from documentation — the
593
- * middle one, `unity-content-and-vertical-scroll-container`, is not in
594
- * Unity's manual diagram at all and was found by dumping.
595
- *
596
- * The styles are inference, unlike the names: they are how this renderer
597
- * reproduces the measured geometry, and the three `scrollview-*` golden cases
598
- * are what decides whether the inference is right.
599
- */
600
- ScrollView: {
601
- hasText: !1,
602
- classes: ["unity-scroll-view"],
603
- parts: [
604
- // Fills the ScrollView's content box, and lays the viewport out beside
605
- // the vertical scrollbar — hence row.
606
- {
607
- name: "unity-content-and-vertical-scroll-container",
608
- style: { "flex-grow": "1", "flex-direction": "row" }
609
- },
610
- // What actually clips. Takes whatever width the scrollbar leaves.
611
- { name: "unity-content-viewport", style: { "flex-grow": "1", overflow: "hidden" } },
612
- // `flex-shrink: 0` is the whole reason a ScrollView is not one box:
613
- // this grows to the content's height instead of being squeezed into the
614
- // viewport's, so children keep their sizes and the viewport crops them.
615
- // Without it three 60px children in a 100px view come out 33/34/33.
616
- { name: "unity-content-container", style: { "flex-shrink": "0" } }
617
- ]
618
- }
619
- }, re = { hasText: !1, classes: [], parts: [] }, yt = "UXML", xt = /* @__PURE__ */ new Set(["Style"]);
620
- function kt(e) {
621
- return xt.has(e.name.local);
622
- }
623
- function H(e) {
624
- var t;
625
- if (((t = e.derived) == null ? void 0 : t.kind) === "template-container") return { spec: re, fallback: !1 };
626
- const n = He[e.name.local];
627
- return n !== void 0 ? { spec: n, fallback: !1 } : St(e) ? { spec: re, fallback: !1 } : { spec: re, fallback: !0 };
628
- }
629
- function St(e) {
630
- return e.name.local === yt;
631
- }
632
- function $t(e) {
633
- return H(e).spec.classes;
634
- }
635
- function Tt() {
636
- return Object.keys(He);
637
- }
638
- const Z = "6000.0.40f1", Ve = `:disabled {
661
+ const ae = "6000.0.40f1", Qe = `:disabled {
639
662
  opacity: 0.5;
640
663
  }
641
664
 
@@ -643,42 +666,246 @@ const Z = "6000.0.40f1", Ve = `:disabled {
643
666
  margin: 1px 3px;
644
667
  -unity-text-align: middle-center;
645
668
  }
646
- `, Ot = 13;
647
- function Et(e) {
648
- return e ? Ot : 0;
649
- }
650
- const Nt = /* @__PURE__ */ new Set([
651
- "color",
652
- "font-size",
653
- "letter-spacing",
654
- "word-spacing",
655
- "visibility",
656
- "white-space",
657
- "-unity-font",
658
- "-unity-font-definition",
659
- "-unity-font-style",
660
- "-unity-paragraph-spacing",
661
- "-unity-text-align",
662
- "-unity-text-outline-color",
663
- "-unity-text-outline-width"
664
- ]);
665
- function Dt(e) {
666
- return e.startsWith("--") || Nt.has(e);
667
- }
668
- function $e(e) {
669
+ `, Ut = 13;
670
+ function zt(e) {
671
+ return e ? Ut : 0;
672
+ }
673
+ const Ft = {
674
+ measuredTextLayout: "Measured layout effect in Unity probes, 2026-10-15/16 (tests/text-cohort/unity and tests/layout/unity); auto-size grew 32x15 to 99x49 on 6000.3.25f1",
675
+ measuredTextPaint: "Measured paint-only effect in Unity probes, 2026-10-15/16 (tests/layout/unity)",
676
+ yoga: "A flexbox style input of Yoga, which UI Toolkit lays out with (CLAUDE.md rule 1); many are compared in the golden set",
677
+ box: "Margin, padding and border widths are part of the box Yoga sizes and places",
678
+ aspectRatio: "Yoga sizes a box from aspect-ratio, which Unity passes through from 6.3",
679
+ all: "Resets every property at once, layout properties included",
680
+ textSize: "Font size sets the measured size of an auto-sized text element",
681
+ textMeasureInferred: "Changes glyph metrics or spacing, which feed the text measurement that sizes an auto-sized text element",
682
+ autoSizeInferred: "Fits the text to the element box rather than the box to the text",
683
+ renderingModeInferred: "Chooses how glyphs are rasterised in the Editor, not how they are measured",
684
+ ellipsisInferred: "Truncates text inside a box that is already sized",
685
+ textAlign: "Places text inside its box; the box does not move (the Step 6 eye check saw it only by looking)",
686
+ textEffectInferred: "Draws around glyphs that are already placed",
687
+ colour: "Colour and corner rounding of a box that is already placed",
688
+ visibility: "Hidden elements keep their space; only display: none removes it",
689
+ transform: "Transforms apply after layout and do not move siblings (Unity Manual, USS transform)",
690
+ background: "Draws inside the box; a VisualElement is not sized by its background",
691
+ overflowInferred: "Clips descendants; with this Yoga version hidden never moved a box (property sheet), and Unity runs Yoga too",
692
+ clipBoxInferred: "Chooses the clipping rectangle, not any box",
693
+ effectInferred: "Post-processes pixels that are already drawn",
694
+ cursor: "Pointer appearance only; nothing is drawn or laid out",
695
+ timeInferred: "Changes values over time; a settled frame, which is what this preview draws, is unaffected"
696
+ }, Pt = {
697
+ /** Row count of each table on the date above. A test holds the data to these. */
698
+ counts: { "6000.0": 95, "6000.3": 99, "6000.6": 102 }
699
+ }, Wt = [
700
+ ["align-content", "6000.0", !1, "layout", "layout", "yoga"],
701
+ ["align-items", "6000.0", !1, "layout", "layout", "yoga"],
702
+ ["align-self", "6000.0", !1, "layout", "layout", "yoga"],
703
+ ["all", "6000.0", !1, "none", "layout", "all"],
704
+ ["animation-play-state", "6000.6", !1, "none", "none", "timeInferred"],
705
+ ["aspect-ratio", "6000.3", !1, "layout", "layout", "aspectRatio"],
706
+ ["backdrop-filter", "6000.6", !1, "none", "paint", "effectInferred"],
707
+ ["background-color", "6000.0", !1, "paint", "paint", "colour"],
708
+ ["background-image", "6000.0", !1, "paint", "paint", "background"],
709
+ ["background-position", "6000.0", !1, "paint", "paint", "background"],
710
+ ["background-position-x", "6000.0", !1, "none", "paint", "background"],
711
+ ["background-position-y", "6000.0", !1, "none", "paint", "background"],
712
+ ["background-repeat", "6000.0", !1, "paint", "paint", "background"],
713
+ ["background-size", "6000.0", !1, "paint", "paint", "background"],
714
+ ["border-bottom-color", "6000.0", !1, "paint", "paint", "colour"],
715
+ ["border-bottom-left-radius", "6000.0", !1, "paint", "paint", "colour"],
716
+ ["border-bottom-right-radius", "6000.0", !1, "paint", "paint", "colour"],
717
+ ["border-bottom-width", "6000.0", !1, "layout", "layout", "box"],
718
+ ["border-color", "6000.0", !1, "paint", "paint", "colour"],
719
+ ["border-left-color", "6000.0", !1, "paint", "paint", "colour"],
720
+ ["border-left-width", "6000.0", !1, "layout", "layout", "box"],
721
+ ["border-radius", "6000.0", !1, "paint", "paint", "colour"],
722
+ ["border-right-color", "6000.0", !1, "paint", "paint", "colour"],
723
+ ["border-right-width", "6000.0", !1, "layout", "layout", "box"],
724
+ ["border-top-color", "6000.0", !1, "paint", "paint", "colour"],
725
+ ["border-top-left-radius", "6000.0", !1, "paint", "paint", "colour"],
726
+ ["border-top-right-radius", "6000.0", !1, "paint", "paint", "colour"],
727
+ ["border-top-width", "6000.0", !1, "layout", "layout", "box"],
728
+ ["border-width", "6000.0", !1, "layout", "layout", "box"],
729
+ ["bottom", "6000.0", !1, "layout", "layout", "yoga"],
730
+ ["color", "6000.0", !0, "paint", "paint", "colour"],
731
+ ["cursor", "6000.0", !1, "paint", "none", "cursor"],
732
+ ["display", "6000.0", !1, "layout", "layout", "yoga"],
733
+ ["filter", "6000.3", !1, "none", "paint", "measuredTextPaint"],
734
+ ["flex", "6000.0", !1, "layout", "layout", "yoga"],
735
+ ["flex-basis", "6000.0", !1, "layout", "layout", "yoga"],
736
+ ["flex-direction", "6000.0", !1, "layout", "layout", "yoga"],
737
+ ["flex-grow", "6000.0", !1, "layout", "layout", "yoga"],
738
+ ["flex-shrink", "6000.0", !1, "layout", "layout", "yoga"],
739
+ ["flex-wrap", "6000.0", !1, "layout", "layout", "yoga"],
740
+ ["font-size", "6000.0", !0, "layout", "layout", "textSize"],
741
+ ["height", "6000.0", !1, "layout", "layout", "yoga"],
742
+ ["justify-content", "6000.0", !1, "layout", "layout", "yoga"],
743
+ ["left", "6000.0", !1, "layout", "layout", "yoga"],
744
+ ["letter-spacing", "6000.0", !0, "layout", "layout", "measuredTextLayout"],
745
+ ["margin", "6000.0", !1, "layout", "layout", "box"],
746
+ ["margin-bottom", "6000.0", !1, "layout", "layout", "box"],
747
+ ["margin-left", "6000.0", !1, "layout", "layout", "box"],
748
+ ["margin-right", "6000.0", !1, "layout", "layout", "box"],
749
+ ["margin-top", "6000.0", !1, "layout", "layout", "box"],
750
+ ["max-height", "6000.0", !1, "layout", "layout", "yoga"],
751
+ ["max-width", "6000.0", !1, "layout", "layout", "yoga"],
752
+ ["min-height", "6000.0", !1, "layout", "layout", "yoga"],
753
+ ["min-width", "6000.0", !1, "layout", "layout", "yoga"],
754
+ ["opacity", "6000.0", !1, "paint", "paint", "colour"],
755
+ // Yoga is told about `hidden`, but at this Yoga version it never moves a box;
756
+ // what shows is the clipping, which is the CSS mapping's.
757
+ ["overflow", "6000.0", !1, "paint", "paint", "overflowInferred"],
758
+ ["padding", "6000.0", !1, "layout", "layout", "box"],
759
+ ["padding-bottom", "6000.0", !1, "layout", "layout", "box"],
760
+ ["padding-left", "6000.0", !1, "layout", "layout", "box"],
761
+ ["padding-right", "6000.0", !1, "layout", "layout", "box"],
762
+ ["padding-top", "6000.0", !1, "layout", "layout", "box"],
763
+ ["position", "6000.0", !1, "layout", "layout", "yoga"],
764
+ ["right", "6000.0", !1, "layout", "layout", "yoga"],
765
+ ["rotate", "6000.0", !1, "paint", "paint", "transform"],
766
+ ["scale", "6000.0", !1, "paint", "paint", "transform"],
767
+ ["text-overflow", "6000.0", !1, "paint", "paint", "measuredTextPaint"],
768
+ ["text-shadow", "6000.0", !0, "none", "paint", "measuredTextPaint"],
769
+ ["top", "6000.0", !1, "layout", "layout", "yoga"],
770
+ ["transform-origin", "6000.0", !1, "paint", "paint", "transform"],
771
+ ["transition", "6000.0", !1, "none", "none", "timeInferred"],
772
+ ["transition-delay", "6000.0", !1, "none", "none", "timeInferred"],
773
+ ["transition-duration", "6000.0", !1, "none", "none", "timeInferred"],
774
+ ["transition-property", "6000.0", !1, "none", "none", "timeInferred"],
775
+ ["transition-timing-function", "6000.0", !1, "none", "none", "timeInferred"],
776
+ ["translate", "6000.0", !1, "paint", "paint", "transform"],
777
+ ["-unity-animation-clip", "6000.6", !1, "none", "none", "timeInferred"],
778
+ ["-unity-background-image-tint-color", "6000.0", !1, "none", "paint", "background"],
779
+ ["-unity-background-scale-mode", "6000.0", !1, "paint", "paint", "background"],
780
+ ["-unity-editor-text-rendering-mode", "6000.0", !0, "none", "paint", "measuredTextPaint"],
781
+ ["-unity-font", "6000.0", !0, "none", "layout", "textMeasureInferred"],
782
+ ["-unity-font-definition", "6000.0", !0, "none", "layout", "measuredTextLayout"],
783
+ ["-unity-font-style", "6000.0", !0, "layout", "layout", "measuredTextLayout"],
784
+ ["-unity-material", "6000.3", !0, "none", "paint", "effectInferred"],
785
+ ["-unity-overflow-clip-box", "6000.0", !1, "none", "paint", "measuredTextPaint"],
786
+ ["-unity-paragraph-spacing", "6000.0", !0, "layout", "layout", "measuredTextLayout"],
787
+ ["-unity-slice-bottom", "6000.0", !1, "none", "paint", "background"],
788
+ ["-unity-slice-left", "6000.0", !1, "none", "paint", "background"],
789
+ ["-unity-slice-right", "6000.0", !1, "none", "paint", "background"],
790
+ ["-unity-slice-scale", "6000.0", !1, "none", "paint", "background"],
791
+ ["-unity-slice-top", "6000.0", !1, "none", "paint", "background"],
792
+ ["-unity-slice-type", "6000.0", !1, "none", "paint", "background"],
793
+ ["-unity-text-align", "6000.0", !0, "paint", "paint", "textAlign"],
794
+ ["-unity-text-auto-size", "6000.3", !0, "none", "layout", "measuredTextLayout"],
795
+ ["-unity-text-generator", "6000.0", !0, "layout", "layout", "measuredTextLayout"],
796
+ ["-unity-text-outline", "6000.0", !1, "none", "paint", "measuredTextPaint"],
797
+ ["-unity-text-outline-color", "6000.0", !0, "none", "paint", "measuredTextPaint"],
798
+ ["-unity-text-outline-width", "6000.0", !0, "none", "paint", "measuredTextPaint"],
799
+ ["-unity-text-overflow-position", "6000.0", !1, "none", "paint", "measuredTextPaint"],
800
+ ["visibility", "6000.0", !0, "paint", "paint", "visibility"],
801
+ ["white-space", "6000.0", !0, "layout", "layout", "measuredTextLayout"],
802
+ ["width", "6000.0", !1, "layout", "layout", "yoga"],
803
+ ["word-spacing", "6000.0", !0, "layout", "layout", "measuredTextLayout"]
804
+ ], et = Wt.map(
805
+ ([e, n, t, s, o, i]) => ({
806
+ name: e,
807
+ since: n,
808
+ inherited: t,
809
+ handling: s,
810
+ unity: o,
811
+ basis: Ft[i],
812
+ inferred: i.endsWith("Inferred")
813
+ })
814
+ ), _t = new Map(et.map((e) => [e.name, e]));
815
+ function Bt(e) {
816
+ return _t.get(e);
817
+ }
818
+ const Ht = {
819
+ "font-family": ["-unity-font-definition"],
820
+ "font-weight": ["-unity-font-style"],
821
+ "font-style": ["-unity-font-style"],
822
+ "text-align": ["-unity-text-align"],
823
+ transform: ["translate", "rotate", "scale"],
824
+ "border-image": ["-unity-slice-left", "-unity-slice-top", "-unity-slice-right", "-unity-slice-bottom"],
825
+ "vertical-align": ["-unity-text-align"],
826
+ font: ["font-size", "-unity-font-definition", "-unity-font-style"],
827
+ inset: ["top", "right", "bottom", "left"],
828
+ "overflow-x": ["overflow"],
829
+ "overflow-y": ["overflow"]
830
+ }, Vt = {
831
+ "-unity-font": "font not loaded by this preview; the browser default is used",
832
+ "-unity-font-definition": "font not loaded by this preview; the browser default is used",
833
+ transition: "not animated by this preview",
834
+ "transition-delay": "not animated by this preview",
835
+ "transition-duration": "not animated by this preview",
836
+ "transition-property": "not animated by this preview",
837
+ "transition-timing-function": "not animated by this preview",
838
+ "animation-play-state": "not animated by this preview",
839
+ "-unity-animation-clip": "not animated by this preview"
840
+ }, qt = `6.${Object.keys(Pt.counts).sort().at(-1).slice(5)}`;
841
+ function Yt(e) {
842
+ return `Unity 6.${e.slice(5)}+`;
843
+ }
844
+ function tt(e, n) {
845
+ if (e.startsWith("--")) return null;
846
+ const t = Bt(e);
847
+ if (t === void 0) {
848
+ const c = Ht[e];
849
+ return {
850
+ message: `${e}: not in the USS property reference up to Unity ${qt}; ignored` + (c === void 0 ? "" : `; USS uses ${c.join(", ")}`),
851
+ reason: "not-uss",
852
+ subject: { kind: "property", property: e, value: n, ...c === void 0 ? {} : { replacements: c } }
853
+ };
854
+ }
855
+ const s = { kind: "property", property: e, value: n };
856
+ if ((e.includes("color") || e === "text-shadow") && /hsla?\(/i.test(n))
857
+ return {
858
+ reason: "invalid-value",
859
+ message: `${e}: Unity 6000.3 stops styling from this element on at this value; 6000.0 draws it black`,
860
+ subject: { ...s, unityEffect: { kind: "unstyled-from-here", versions: ["6000.3"] } }
861
+ };
862
+ if ((e === "transition-timing-function" || e === "transition") && /cubic-bezier\(/i.test(n))
863
+ return {
864
+ reason: "invalid-value",
865
+ message: `${e}: Unity stops styling from this element on at cubic-bezier()`,
866
+ subject: { ...s, unityEffect: { kind: "unstyled-from-here", versions: ["6000.0", "6000.3"] } }
867
+ };
868
+ if (e === "opacity" && n.trim().endsWith("%"))
869
+ return { reason: "invalid-value", message: "opacity: Unity reads 50% as 50 (fully opaque), this preview draws it half-transparent", subject: s };
870
+ if (n.trim() === "inherit")
871
+ return { reason: "invalid-value", message: `${e}: USS has initial but not inherit; Unity resolved color: inherit to transparent`, subject: s };
872
+ const o = t.unity === "layout", i = t.since === "6000.0" ? "" : ` (${Yt(t.since)})`;
873
+ return t.handling === "paint" && o ? {
874
+ message: `${e}${i}: drawn, but left out of text measurement by this preview`,
875
+ reason: "not-rendered",
876
+ subject: { kind: "property", property: e, value: n, since: t.since, affectsLayout: o, applied: "paint" }
877
+ } : t.handling !== "none" ? null : {
878
+ message: `${e}${i}: ${Vt[e] ?? "not drawn by this preview"}` + (e === "filter" && /[\w-]+\(/.test(n) ? "; Unity 6000.0 stops styling from this element on" : ""),
879
+ reason: "not-rendered",
880
+ subject: {
881
+ kind: "property",
882
+ property: e,
883
+ value: n,
884
+ since: t.since,
885
+ affectsLayout: o,
886
+ // Same probes/dumps, measured 2026-10-15: filter functions poison 6000.0 only.
887
+ ...e === "filter" && /[\w-]+\(/.test(n) ? { unityEffect: { kind: "unstyled-from-here", versions: ["6000.0"] } } : {}
888
+ }
889
+ };
890
+ }
891
+ const be = ["hover", "active", "inactive", "focus", "disabled", "enabled", "checked"], Jt = new Set(et.filter((e) => e.inherited).map((e) => e.name));
892
+ function Gt(e) {
893
+ return e.startsWith("--") || Jt.has(e);
894
+ }
895
+ function Ne(e) {
669
896
  const n = [];
670
897
  let t = 0, s = -1;
671
- for (let i = 0; i < e.length; i++) {
672
- const r = e[i];
673
- r === "(" ? t++ : r === ")" && (t = Math.max(0, t - 1)), t === 0 && /\s/.test(r) ? s >= 0 && (n.push(e.slice(s, i)), s = -1) : s < 0 && (s = i);
898
+ for (let o = 0; o < e.length; o++) {
899
+ const i = e[o];
900
+ i === "(" ? t++ : i === ")" && (t = Math.max(0, t - 1)), t === 0 && /\s/.test(i) ? s >= 0 && (n.push(e.slice(s, o)), s = -1) : s < 0 && (s = o);
674
901
  }
675
902
  return s >= 0 && n.push(e.slice(s)), n;
676
903
  }
677
- function At(e) {
678
- const [n, t, s, i] = e;
679
- return n === void 0 ? null : t === void 0 ? [n, n, n, n] : s === void 0 ? [n, t, n, t] : i === void 0 ? [n, t, s, t] : [n, t, s, i];
904
+ function Kt(e) {
905
+ const [n, t, s, o] = e;
906
+ return n === void 0 ? null : t === void 0 ? [n, n, n, n] : s === void 0 ? [n, t, n, t] : o === void 0 ? [n, t, s, t] : [n, t, s, o];
680
907
  }
681
- const It = {
908
+ const Xt = {
682
909
  margin: ["margin-top", "margin-right", "margin-bottom", "margin-left"],
683
910
  padding: ["padding-top", "padding-right", "padding-bottom", "padding-left"],
684
911
  "border-width": [
@@ -701,24 +928,25 @@ const It = {
701
928
  "border-bottom-left-radius"
702
929
  ]
703
930
  };
704
- function Te(e) {
931
+ function Ae(e) {
705
932
  return /^-?(\d+\.?\d*|\.\d+)$/.test(e);
706
933
  }
707
- function Rt(e) {
934
+ function Zt(e) {
708
935
  const [n, t, s] = e;
709
- return n === void 0 ? [] : n === "none" ? [["flex-grow", "0"], ["flex-shrink", "0"], ["flex-basis", "auto"]] : n === "auto" ? [["flex-grow", "1"], ["flex-shrink", "1"], ["flex-basis", "auto"]] : t === void 0 ? Te(n) ? [["flex-grow", n], ["flex-shrink", "1"], ["flex-basis", "0"]] : [["flex-grow", "1"], ["flex-shrink", "1"], ["flex-basis", n]] : s === void 0 ? Te(t) ? [["flex-grow", n], ["flex-shrink", t], ["flex-basis", "0"]] : [["flex-grow", n], ["flex-shrink", "1"], ["flex-basis", t]] : [["flex-grow", n], ["flex-shrink", t], ["flex-basis", s]];
936
+ return n === void 0 ? [] : n === "none" ? [["flex-grow", "0"], ["flex-shrink", "0"], ["flex-basis", "auto"]] : n === "auto" ? [["flex-grow", "1"], ["flex-shrink", "1"], ["flex-basis", "auto"]] : t === void 0 ? Ae(n) ? [["flex-grow", n], ["flex-shrink", "1"], ["flex-basis", "0"]] : [["flex-grow", "1"], ["flex-shrink", "1"], ["flex-basis", n]] : s === void 0 ? Ae(t) ? [["flex-grow", n], ["flex-shrink", t], ["flex-basis", "0"]] : [["flex-grow", n], ["flex-shrink", "1"], ["flex-basis", t]] : [["flex-grow", n], ["flex-shrink", t], ["flex-basis", s]];
710
937
  }
711
- function ie(e, n) {
712
- if (e === "flex") return Rt($e(n));
713
- const t = It[e];
938
+ function pe(e, n) {
939
+ if (e === "flex") return Zt(Ne(n));
940
+ const t = Xt[e];
714
941
  if (t === void 0) return [[e, n]];
715
- const s = At($e(n));
716
- return s === null ? [[e, n]] : t.map((i, r) => [i, s[r]]);
942
+ const s = Kt(Ne(n));
943
+ return s === null ? [[e, n]] : t.map((o, i) => [o, s[i]]);
717
944
  }
718
- const ae = {
945
+ const ve = {
719
946
  "align-content": "flex-start",
720
947
  "align-items": "stretch",
721
948
  "align-self": "auto",
949
+ "aspect-ratio": "auto",
722
950
  "flex-basis": "auto",
723
951
  "flex-direction": "column",
724
952
  "flex-grow": "0",
@@ -751,708 +979,844 @@ const ae = {
751
979
  "padding-right": "0",
752
980
  "padding-top": "0",
753
981
  "font-size": "12px"
754
- }, Ct = ["em", "rem", "vh", "vw", "vmin", "vmax", "pt", "cm", "in"];
755
- function Q(e) {
982
+ }, Qt = ["em", "rem", "vh", "vw", "vmin", "vmax", "pt", "cm", "in"];
983
+ function B(e) {
756
984
  const n = e.trim();
757
- if (n === "") return { length: null, problem: "empty value" };
985
+ if (n === "") return { length: null, problem: "empty value", reason: "invalid-value" };
758
986
  if (n === "auto") return { length: { kind: "auto" } };
759
987
  if (n === "none") return { length: { kind: "none" } };
760
988
  if (n === "initial") return { length: { kind: "auto" } };
761
989
  if (n.startsWith("calc("))
762
- return { length: null, problem: "calc() is not supported in USS" };
990
+ return { length: null, problem: "calc() is not evaluated", reason: "not-uss" };
763
991
  const t = /^(-?(?:\d+\.?\d*|\.\d+))([a-z%]*)$/i.exec(n);
764
- if (t === null) return { length: null, problem: `cannot read "${n}" as a length` };
765
- const s = Number(t[1]), i = t[2].toLowerCase();
766
- return i === "" || i === "px" ? { length: { kind: "px", value: s } } : i === "%" ? { length: { kind: "percent", value: s } } : Ct.includes(i) ? { length: null, problem: `"${i}" is not a USS unit` } : { length: null, problem: `unknown unit "${i}"` };
992
+ if (t === null)
993
+ return { length: null, problem: `cannot read "${n}" as a length`, reason: "invalid-value" };
994
+ const s = Number(t[1]), o = t[2].toLowerCase();
995
+ return o === "" || o === "px" ? { length: { kind: "px", value: s } } : o === "%" ? { length: { kind: "percent", value: s } } : Qt.includes(o) ? { length: null, problem: `unit "${o}" not recognised`, code: "unsupported-unit", reason: "not-uss" } : { length: null, problem: `unknown unit "${o}"`, reason: "invalid-value" };
767
996
  }
768
- function Oe(e) {
997
+ function he(e) {
769
998
  const n = e.trim();
770
999
  return /^-?(\d+\.?\d*|\.\d+)$/.test(n) ? Number(n) : null;
771
1000
  }
772
- let me = null;
773
- async function yn() {
774
- me ?? (me = await tt());
775
- }
776
- function xn() {
777
- return me !== null;
778
- }
779
- let K = 0;
780
- function kn() {
781
- return K;
782
- }
783
- const oe = {
784
- auto: W.Auto,
785
- "flex-start": W.FlexStart,
786
- center: W.Center,
787
- "flex-end": W.FlexEnd,
788
- stretch: W.Stretch,
789
- baseline: W.Baseline,
790
- "space-between": W.SpaceBetween,
791
- "space-around": W.SpaceAround,
792
- "space-evenly": W.SpaceEvenly
793
- }, Mt = {
1001
+ let Ee = null;
1002
+ async function Pn() {
1003
+ Ee ?? (Ee = await pt());
1004
+ }
1005
+ function Wn() {
1006
+ return Ee !== null;
1007
+ }
1008
+ let ie = 0;
1009
+ function _n() {
1010
+ return ie;
1011
+ }
1012
+ const me = {
1013
+ auto: P.Auto,
794
1014
  "flex-start": P.FlexStart,
795
1015
  center: P.Center,
796
1016
  "flex-end": P.FlexEnd,
1017
+ stretch: P.Stretch,
1018
+ baseline: P.Baseline,
797
1019
  "space-between": P.SpaceBetween,
798
1020
  "space-around": P.SpaceAround,
799
1021
  "space-evenly": P.SpaceEvenly
800
- }, Ut = {
801
- column: G.Column,
802
- "column-reverse": G.ColumnReverse,
803
- row: G.Row,
804
- "row-reverse": G.RowReverse
805
- }, Lt = {
806
- nowrap: Y.NoWrap,
807
- wrap: Y.Wrap,
808
- "wrap-reverse": Y.WrapReverse
809
- }, Wt = [
810
- ["left", q.Left],
811
- ["top", q.Top],
812
- ["right", q.Right],
813
- ["bottom", q.Bottom]
1022
+ }, en = {
1023
+ "flex-start": J.FlexStart,
1024
+ center: J.Center,
1025
+ "flex-end": J.FlexEnd,
1026
+ "space-between": J.SpaceBetween,
1027
+ "space-around": J.SpaceAround,
1028
+ "space-evenly": J.SpaceEvenly
1029
+ }, tn = {
1030
+ column: ne.Column,
1031
+ "column-reverse": ne.ColumnReverse,
1032
+ row: ne.Row,
1033
+ "row-reverse": ne.RowReverse
1034
+ }, nn = {
1035
+ nowrap: oe.NoWrap,
1036
+ wrap: oe.Wrap,
1037
+ "wrap-reverse": oe.WrapReverse
1038
+ }, sn = [
1039
+ ["left", te.Left],
1040
+ ["top", te.Top],
1041
+ ["right", te.Right],
1042
+ ["bottom", te.Bottom]
814
1043
  ];
815
- function zt(e, n, t, s) {
816
- const i = me;
817
- if (i === null)
1044
+ function on(e, n, t, s) {
1045
+ const o = Ee;
1046
+ if (o === null)
818
1047
  throw new Error("loadLayoutEngine() must be awaited before rendering");
819
- const r = [], u = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), v = [], d = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
820
- let a = 0, f = !1, l = !1;
821
- const h = (w, S) => {
1048
+ const i = [], c = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), g = [], p = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
1049
+ let d = 0, m = !1, a = !1;
1050
+ const b = (x, $) => {
822
1051
  var T;
823
- return ((T = w.get(S)) == null ? void 0 : T.value) ?? ae[S] ?? "";
1052
+ return ((T = x.get($)) == null ? void 0 : T.value) ?? ve[$] ?? "";
824
1053
  };
825
- function g(w, S) {
826
- r.push({ kind: "unsupported-property", message: w, node: S.id });
827
- }
828
- function p(w, S, T) {
829
- const N = h(w, S);
830
- if (N === "") return null;
831
- const { length: D, problem: A } = Q(N);
832
- return A !== void 0 && g(`${S}: ${A}`, T), D;
833
- }
834
- function b(w) {
835
- if (w !== null)
836
- switch (w.kind) {
1054
+ function r(x, $, T, I) {
1055
+ var O;
1056
+ (I == null ? void 0 : I.origin.kind) !== "inherited" && i.push({
1057
+ kind: "unsupported-property",
1058
+ message: x,
1059
+ node: $.id,
1060
+ ...T,
1061
+ ...I === void 0 ? {} : ((O = s.locate) == null ? void 0 : O.call(s, I.origin)) ?? {}
1062
+ });
1063
+ }
1064
+ function w(x, $, T, I, O, D) {
1065
+ const C = x.get($), R = D && (C == null ? void 0 : C.origin.kind) === "inline";
1066
+ r(
1067
+ `${$}: ${I}${R ? "; Unity drops every inline style in that UXML file" : ""}`,
1068
+ T,
1069
+ {
1070
+ ...O === void 0 ? {} : { reason: R ? "invalid-value" : O },
1071
+ subject: {
1072
+ kind: "property",
1073
+ property: $,
1074
+ value: b(x, $),
1075
+ ...R ? { unityEffect: { kind: "file-inline-dropped", versions: ["6000.0", "6000.3"] } } : {}
1076
+ }
1077
+ },
1078
+ C
1079
+ );
1080
+ }
1081
+ function y(x, $, T) {
1082
+ const I = b(x, $);
1083
+ if (I === "") return null;
1084
+ const { length: O, problem: D, reason: C, code: R } = B(I);
1085
+ return D !== void 0 && w(x, $, T, D, C, R === "unsupported-unit"), O;
1086
+ }
1087
+ function h(x) {
1088
+ if (x !== null)
1089
+ switch (x.kind) {
837
1090
  case "px":
838
- return w.value;
1091
+ return x.value;
839
1092
  case "percent":
840
- return `${w.value}%`;
1093
+ return `${x.value}%`;
841
1094
  case "auto":
842
1095
  return "auto";
843
1096
  case "none":
844
1097
  return;
845
1098
  }
846
1099
  }
847
- function m(w) {
848
- if (w !== null) {
849
- if (w.kind === "px") return w.value;
850
- if (w.kind === "percent") return `${w.value}%`;
851
- }
852
- }
853
- function y(w, S, T) {
854
- w.setBoxSizing(nt.BorderBox), w.setFlexDirection(Ut[h(S, "flex-direction")] ?? G.Column), w.setFlexWrap(Lt[h(S, "flex-wrap")] ?? Y.NoWrap), w.setJustifyContent(Mt[h(S, "justify-content")] ?? P.FlexStart), w.setAlignItems(oe[h(S, "align-items")] ?? W.Stretch), w.setAlignSelf(oe[h(S, "align-self")] ?? W.Auto), w.setAlignContent(oe[h(S, "align-content")] ?? W.FlexStart), w.setFlexGrow(Oe(h(S, "flex-grow")) ?? 0), w.setFlexShrink(Oe(h(S, "flex-shrink")) ?? 1), w.setFlexBasis(b(p(S, "flex-basis", T)));
855
- const N = h(S, "position");
856
- (N === "fixed" || N === "sticky") && g(`position: ${N} is not supported in USS; treated as relative`, T), w.setPositionType(
857
- N === "absolute" ? ne.Absolute : ne.Relative
858
- ), h(S, "display") === "none" && w.setDisplay(st.None);
859
- const D = h(S, "overflow");
860
- D === "hidden" ? w.setOverflow(rt.Hidden) : (D === "auto" || D === "scroll") && g(`overflow: ${D} needs a ScrollView element in USS`, T), w.setWidth(b(p(S, "width", T))), w.setHeight(b(p(S, "height", T))), w.setMinWidth(m(p(S, "min-width", T))), w.setMinHeight(m(p(S, "min-height", T))), w.setMaxWidth(m(p(S, "max-width", T))), w.setMaxHeight(m(p(S, "max-height", T)));
861
- for (const [A, I] of Wt) {
862
- w.setMargin(I, m(p(S, `margin-${A}`, T))), w.setPadding(I, m(p(S, `padding-${A}`, T)));
863
- const _ = m(p(S, `border-${A}-width`, T));
864
- w.setBorder(I, typeof _ == "number" ? _ : void 0), w.setPosition(I, m(p(S, A, T)));
865
- }
866
- }
867
- function k(w) {
868
- var S;
869
- return (S = w.attributes.find((T) => T.name === "text")) == null ? void 0 : S.value;
870
- }
871
- const x = ["text", "label"];
872
- function $(w) {
873
- return x.filter(
874
- (S) => w.attributes.some((T) => T.name === S && T.value.length > 0)
1100
+ function f(x) {
1101
+ if (x !== null) {
1102
+ if (x.kind === "px") return x.value;
1103
+ if (x.kind === "percent") return `${x.value}%`;
1104
+ }
1105
+ }
1106
+ function k(x, $, T) {
1107
+ x.setBoxSizing(ht.BorderBox), x.setFlexDirection(tn[b($, "flex-direction")] ?? ne.Column), x.setFlexWrap(nn[b($, "flex-wrap")] ?? oe.NoWrap), x.setJustifyContent(en[b($, "justify-content")] ?? J.FlexStart), x.setAlignItems(me[b($, "align-items")] ?? P.Stretch), x.setAlignSelf(me[b($, "align-self")] ?? P.Auto), x.setAlignContent(me[b($, "align-content")] ?? P.FlexStart), x.setFlexGrow(he(b($, "flex-grow")) ?? 0), x.setFlexShrink(he(b($, "flex-shrink")) ?? 1), x.setFlexBasis(h(y($, "flex-basis", T)));
1108
+ const I = b($, "position");
1109
+ (I === "fixed" || I === "sticky") && r(`position: ${I} treated as relative`, T, {
1110
+ reason: "not-uss",
1111
+ subject: { kind: "property", property: "position", value: I }
1112
+ }, $.get("position")), x.setPositionType(
1113
+ I === "absolute" ? ue.Absolute : ue.Relative
1114
+ );
1115
+ const O = b($, "display");
1116
+ O === "none" ? x.setDisplay(mt.None) : O !== "flex" && O !== "initial" && r(`display: ${O} laid out as flex`, T, {
1117
+ reason: "invalid-value",
1118
+ subject: { kind: "property", property: "display", value: O }
1119
+ }, $.get("display"));
1120
+ const D = b($, "overflow");
1121
+ D === "hidden" ? x.setOverflow(gt.Hidden) : (D === "auto" || D === "scroll") && r(`overflow: ${D} ignored; nothing scrolls`, T, {
1122
+ reason: "not-uss",
1123
+ subject: { kind: "property", property: "overflow", value: D }
1124
+ }, $.get("overflow")), x.setWidth(h(y($, "width", T))), x.setHeight(h(y($, "height", T)));
1125
+ const C = b($, "aspect-ratio").trim();
1126
+ if (C !== "auto" && C !== "initial") {
1127
+ const R = he(C);
1128
+ R !== null && Number.isFinite(R) ? x.setAspectRatio(R) : w($, "aspect-ratio", T, `cannot read "${C}" as a number`, "invalid-value", !0);
1129
+ }
1130
+ x.setMinWidth(f(y($, "min-width", T))), x.setMinHeight(f(y($, "min-height", T))), x.setMaxWidth(f(y($, "max-width", T))), x.setMaxHeight(f(y($, "max-height", T)));
1131
+ for (const [R, L] of sn) {
1132
+ x.setMargin(L, f(y($, `margin-${R}`, T))), x.setPadding(L, f(y($, `padding-${R}`, T)));
1133
+ const U = f(y($, `border-${R}-width`, T));
1134
+ x.setBorder(L, typeof U == "number" ? U : void 0), x.setPosition(L, f(y($, R, T)));
1135
+ }
1136
+ }
1137
+ function v(x) {
1138
+ var T;
1139
+ const $ = (T = x.attributes.find((I) => I.name === "text")) == null ? void 0 : T.value;
1140
+ return $ === void 0 ? void 0 : Z($);
1141
+ }
1142
+ const S = ["text", "label"];
1143
+ function E(x) {
1144
+ return S.filter(
1145
+ ($) => x.attributes.some((T) => T.name === $ && T.value.length > 0)
875
1146
  );
876
1147
  }
877
- function O(w, S) {
878
- if (kt(w)) return;
879
- const T = n.get(w.id) ?? /* @__PURE__ */ new Map(), N = i.Node.create();
880
- a++, K++, d.set(w, N), v.push(w), y(N, T, w), S !== null && S.insertChild(N, S.getChildCount());
881
- const { spec: D, fallback: A } = H(w), I = k(w), _ = D.hasText && I !== void 0 && I.length > 0;
882
- if (A) {
883
- const R = $(w);
884
- r.push({
1148
+ let M = !1;
1149
+ function A(x, $) {
1150
+ var U;
1151
+ if (ye(x)) {
1152
+ x.name.local === "Bindings" && !M && (M = !0, i.push({
1153
+ kind: "unsupported-control",
1154
+ message: "Data bindings are not evaluated in this preview; bound values show as written",
1155
+ node: x.id,
1156
+ reason: "not-rendered",
1157
+ subject: { kind: "control", type: "Bindings" }
1158
+ }));
1159
+ return;
1160
+ }
1161
+ const T = n.get(x.id) ?? /* @__PURE__ */ new Map(), I = o.Node.create();
1162
+ d++, ie++, p.set(x, I), g.push(x), k(I, T, x), $ !== null && $.insertChild(I, $.getChildCount());
1163
+ const { spec: O, fallback: D } = X(x), C = v(x), R = O.hasText && C !== void 0 && C.length > 0;
1164
+ if (D) {
1165
+ const N = E(x);
1166
+ i.push({
885
1167
  kind: "unsupported-control",
886
- message: `<${w.name.local}> has no renderer in this version and is drawn as a plain VisualElement` + (R.length === 0 ? "" : `; its ${R.join(" and ")} attribute${R.length > 1 ? "s are" : " is"} not drawn, because Unity draws that through a child element`),
887
- node: w.id
1168
+ message: `<${x.name.local}> has no renderer in this version and is drawn as a plain VisualElement` + (N.length === 0 ? "" : `; its ${N.join(" and ")} attribute${N.length > 1 ? "s are" : " is"} not drawn`),
1169
+ node: x.id,
1170
+ reason: "not-rendered",
1171
+ subject: { kind: "control", type: x.name.local }
888
1172
  });
889
1173
  }
890
- if (_) {
891
- w.children.length > 0 && g(
892
- `<${w.name.local}> has both a text attribute and children; children are not drawn`,
893
- w
1174
+ if (R && !T.has("-unity-font-definition") && !T.has("-unity-font")) {
1175
+ const N = /[\u1100-\u11ff\u3130-\u318f\uac00-\ud7af\u3400-\u4dbf\u4e00-\u9fff\u3040-\u30ff]/u.exec(C);
1176
+ if (N !== null) {
1177
+ const j = N[0].codePointAt(0), W = j >= 12352 && j <= 12543 ? "kana" : j >= 13312 && j <= 19903 || j >= 19968 && j <= 40959 ? "han" : "hangul", _ = { hangul: "Hangul", han: "Han (CJK ideographs)", kana: "Kana" }[W];
1178
+ i.push({
1179
+ kind: "unsupported-property",
1180
+ reason: "font-fallback",
1181
+ node: x.id,
1182
+ message: `The editor default font (Inter-Regular SDF) has no glyphs for ${_}; Unity draws it with a fallback font whose height can differ (measured 1–4px taller).`,
1183
+ subject: { kind: "property", property: "-unity-font-definition", value: "", affectsLayout: !0, missingGlyphs: W }
1184
+ });
1185
+ }
1186
+ }
1187
+ if (R) {
1188
+ x.children.some((_) => !ye(_)) && r(
1189
+ `<${x.name.local}> has both a text attribute and children; children are not drawn`,
1190
+ x,
1191
+ { reason: "not-rendered", subject: { kind: "control", type: x.name.local } }
894
1192
  );
895
- const R = p(T, "font-size", w), z = {
896
- fontSize: R !== null && R.kind === "px" ? R.value : 12,
897
- fontStyle: h(T, "-unity-font-style") || "normal",
898
- whiteSpace: h(T, "white-space") || "normal"
899
- };
900
- N.setMeasureFunc(
901
- (M) => s.measureText(
902
- I,
903
- z,
904
- Number.isFinite(M) ? M : 0
1193
+ const N = y(T, "font-size", x), j = {
1194
+ fontSize: N !== null && N.kind === "px" ? N.value : 12,
1195
+ fontStyle: b(T, "-unity-font-style") || "normal",
1196
+ whiteSpace: b(T, "white-space") || "normal",
1197
+ textGenerator: b(T, "-unity-text-generator") === "standard" ? "standard" : "advanced"
1198
+ }, W = (U = s.fonts) == null ? void 0 : U.get(T);
1199
+ W !== void 0 && (j.fontFamily = W.family, W.faceInfo !== void 0 && (j.faceInfo = W.faceInfo));
1200
+ for (const [_, se] of [
1201
+ ["letter-spacing", "letterSpacing"],
1202
+ ["word-spacing", "wordSpacing"],
1203
+ ["-unity-paragraph-spacing", "paragraphSpacing"]
1204
+ ]) {
1205
+ const H = y(T, _, x);
1206
+ (H == null ? void 0 : H.kind) === "px" && (j[se] = H.value);
1207
+ }
1208
+ I.setMeasureFunc(
1209
+ (_) => s.measureText(
1210
+ C,
1211
+ j,
1212
+ Number.isFinite(_) ? _ : 0
905
1213
  )
906
1214
  );
907
1215
  return;
908
1216
  }
909
- let F = N;
910
- if (D.parts.length > 0) {
911
- l || (l = !0, r.push({
1217
+ let L = I;
1218
+ if (O.parts.length > 0) {
1219
+ a || (a = !0, i.push({
912
1220
  kind: "version-dependent",
913
- message: `<${w.name.local}> is drawn with the implicit child elements Unity builds for it, and their geometry was measured on Unity ${Z}. Other versions may differ; see src/controls/theme.ts.`,
914
- node: w.id
1221
+ message: `<${x.name.local}> drawn with built-in child elements measured on Unity ${ae}`,
1222
+ node: x.id,
1223
+ reason: "version-dependent",
1224
+ subject: { kind: "control", type: x.name.local }
915
1225
  }));
916
- const R = [], z = [], M = t.get(w.id);
917
- for (const we of D.parts) {
918
- const ve = (M == null ? void 0 : M.get(we.name)) ?? /* @__PURE__ */ new Map(), X = i.Node.create();
919
- a++, K++, y(X, ve, w), F.insertChild(X, F.getChildCount()), F = X, z.push(X), R.push({
920
- name: we.name,
921
- owner: w.id,
1226
+ const N = [], j = [], W = t.get(x.id);
1227
+ for (const _ of O.parts) {
1228
+ const se = (W == null ? void 0 : W.get(_.name)) ?? /* @__PURE__ */ new Map(), H = o.Node.create();
1229
+ d++, ie++, k(H, se, x), L.insertChild(H, L.getChildCount()), L = H, j.push(H), N.push({
1230
+ name: _.name,
1231
+ owner: x.id,
922
1232
  box: { left: 0, top: 0, width: 0, height: 0 },
923
- style: ve
1233
+ style: se
924
1234
  });
925
1235
  }
926
- c.set(w.id, R), o.set(w.id, z);
927
- }
928
- for (const R of w.children) O(R, F);
929
- }
930
- O(e, null);
931
- const E = d.get(e);
932
- E.setWidth(s.size.width), E.setHeight(s.size.height), E.setPositionType(ne.Relative), E.calculateLayout(s.size.width, s.size.height, be.LTR);
933
- const C = /* @__PURE__ */ new Map();
934
- for (let w = 0; w < 3; w++) {
935
- let S = !1;
936
- for (const [T, N] of c) {
937
- const D = o.get(T);
938
- if (D === void 0) continue;
939
- const A = N.findIndex((M) => M.name === "unity-content-viewport"), I = N.findIndex((M) => M.name === "unity-content-container");
940
- if (A === -1 || I === -1) continue;
941
- const _ = D[A].getComputedLayout(), R = D[I].getComputedLayout().height > _.height + 0.01, z = Et(R);
942
- (C.get(T) ?? 0) !== z && (C.set(T, z), D[A].setMargin(q.Right, z), S = !0);
943
- }
944
- if (!S) break;
945
- E.calculateLayout(s.size.width, s.size.height, be.LTR);
946
- }
947
- function L(w, S, T) {
948
- const N = d.get(w);
949
- if (N === void 0) return;
950
- const D = N.getComputedLayout();
951
- let A = S + D.left, I = T + D.top;
952
- u.set(w.id, { left: A, top: I, width: D.width, height: D.height });
953
- const _ = c.get(w.id), F = o.get(w.id);
954
- _ !== void 0 && F !== void 0 && _.forEach((R, z) => {
955
- const M = F[z].getComputedLayout();
956
- A += M.left, I += M.top, R.box = { left: A, top: I, width: M.width, height: M.height };
1236
+ u.set(x.id, N), l.set(x.id, j);
1237
+ }
1238
+ for (const N of x.children) A(N, L);
1239
+ }
1240
+ A(e, null);
1241
+ const z = p.get(e);
1242
+ z.setWidth(s.size.width), z.setHeight(s.size.height), z.setPositionType(ue.Relative), z.calculateLayout(s.size.width, s.size.height, De.LTR);
1243
+ const q = /* @__PURE__ */ new Map();
1244
+ for (let x = 0; x < 3; x++) {
1245
+ let $ = !1;
1246
+ for (const [T, I] of u) {
1247
+ const O = l.get(T);
1248
+ if (O === void 0) continue;
1249
+ const D = I.findIndex((j) => j.name === "unity-content-viewport"), C = I.findIndex((j) => j.name === "unity-content-container");
1250
+ if (D === -1 || C === -1) continue;
1251
+ const R = O[D].getComputedLayout(), U = O[C].getComputedLayout().height > R.height + 0.01, N = zt(U);
1252
+ (q.get(T) ?? 0) !== N && (q.set(T, N), O[D].setMargin(te.Right, N), $ = !0);
1253
+ }
1254
+ if (!$) break;
1255
+ z.calculateLayout(s.size.width, s.size.height, De.LTR);
1256
+ }
1257
+ function Q(x, $, T) {
1258
+ const I = p.get(x);
1259
+ if (I === void 0) return;
1260
+ const O = I.getComputedLayout();
1261
+ let D = $ + O.left, C = T + O.top;
1262
+ c.set(x.id, { left: D, top: C, width: O.width, height: O.height });
1263
+ const R = u.get(x.id), L = l.get(x.id);
1264
+ R !== void 0 && L !== void 0 && R.forEach((U, N) => {
1265
+ const j = L[N].getComputedLayout();
1266
+ D += j.left, C += j.top, U.box = { left: D, top: C, width: j.width, height: j.height };
957
1267
  });
958
- for (const R of w.children) L(R, A, I);
1268
+ for (const U of x.children) Q(U, D, C);
959
1269
  }
960
- return L(e, 0, 0), {
961
- boxes: u,
962
- parts: c,
963
- painted: v,
964
- warnings: r,
1270
+ return Q(e, 0, 0), {
1271
+ boxes: c,
1272
+ parts: u,
1273
+ painted: g,
1274
+ warnings: i,
965
1275
  dispose() {
966
- f || (f = !0, E.freeRecursive(), K -= a, d.clear(), o.clear());
1276
+ m || (m = !0, z.freeRecursive(), ie -= d, p.clear(), l.clear());
967
1277
  }
968
1278
  };
969
1279
  }
970
- const _t = 1.2;
971
- function jt(e) {
1280
+ const rn = {
1281
+ pointSize: 90,
1282
+ ascentLine: 87.1875,
1283
+ descentLine: -21.73295,
1284
+ lineHeight: 108.9205
1285
+ };
1286
+ function an(e, n, t, s = 0, o = 0) {
1287
+ return Math.ceil(e * n * (t.ascentLine - t.descentLine) / t.pointSize + s * o * n / 100);
1288
+ }
1289
+ function nt(e) {
1290
+ return e === void 0 ? "sans-serif" : `${JSON.stringify(e)}, sans-serif`;
1291
+ }
1292
+ function ln(e) {
972
1293
  var t;
973
1294
  let n = null;
974
1295
  if (e !== void 0) {
975
1296
  const s = e.createElement("canvas");
976
1297
  n = ((t = s.getContext) == null ? void 0 : t.call(s, "2d")) ?? null;
977
1298
  }
978
- return (s, i, r) => {
979
- const u = i.fontSize * _t, c = (l) => {
980
- if (n === null)
981
- return l.length * i.fontSize * 0.5;
982
- const h = i.fontStyle.includes("bold") ? "bold" : "normal", g = i.fontStyle.includes("italic") ? "italic" : "normal";
983
- return n.font = `${g} ${h} ${i.fontSize}px sans-serif`, n.measureText(l).width;
1299
+ return (s, o, i) => {
1300
+ const c = o.fontStyle.includes("bold") ? "bold" : "normal", u = o.fontStyle.includes("italic") ? "italic" : "normal", g = (r) => {
1301
+ n !== null && (n.font = `${u} ${c} ${r}px ${nt(o.fontFamily)}`);
984
1302
  };
985
- if (!(i.whiteSpace !== "nowrap" && i.whiteSpace !== "pre") || r <= 0) {
986
- const l = s.split(`
987
- `);
988
- return { width: l.reduce((g, p) => Math.max(g, c(p)), 0), height: l.length * u };
989
- }
990
- const d = s.split(/\s+/).filter((l) => l.length > 0);
991
- let o = 1, a = 0, f = 0;
992
- for (const l of d) {
993
- const h = c(l), g = a === 0 ? 0 : c(" ");
994
- a > 0 && a + g + h > r ? (f = Math.max(f, a), o++, a = h) : a += g + h;
995
- }
996
- return f = Math.max(f, a), { width: f, height: o * u };
1303
+ let p = o.faceInfo;
1304
+ if (p === void 0 && o.fontFamily !== void 0 && n !== null) {
1305
+ g(90);
1306
+ const r = n.measureText("Mg");
1307
+ Number.isFinite(r.fontBoundingBoxAscent) && Number.isFinite(r.fontBoundingBoxDescent) && (p = { pointSize: 90, ascentLine: r.fontBoundingBoxAscent, descentLine: -r.fontBoundingBoxDescent });
1308
+ }
1309
+ g(o.fontSize);
1310
+ const l = (r) => {
1311
+ const w = [...r].length, y = [...r].filter((k) => k === " ").length, h = Math.max(0, w - 1 - (o.textGenerator === "standard" ? 0 : y));
1312
+ return (n === null ? w * o.fontSize * 0.5 : n.measureText(r).width) + (h * (o.letterSpacing ?? 0) + y * (o.wordSpacing ?? 0)) * o.fontSize / 100;
1313
+ }, d = s.split(`
1314
+ `).map((r) => o.whiteSpace === "pre" || o.whiteSpace === "pre-wrap" ? r : r.replace(/ +/g, " ").trim()), m = o.whiteSpace !== "nowrap" && o.whiteSpace !== "pre" && i > 0;
1315
+ let a = 0, b = 0;
1316
+ for (const r of d) {
1317
+ let w = "";
1318
+ if (a++, !m) {
1319
+ b = Math.max(b, l(r));
1320
+ continue;
1321
+ }
1322
+ for (const y of r.split(/\s+/).filter((h) => h.length > 0)) {
1323
+ const h = w === "" ? y : `${w} ${y}`;
1324
+ w !== "" && l(h) > i ? (b = Math.max(b, l(w)), a++, w = y) : w = h;
1325
+ }
1326
+ b = Math.max(b, l(w));
1327
+ }
1328
+ return { width: b, height: an(
1329
+ a,
1330
+ o.fontSize,
1331
+ p ?? rn,
1332
+ d.length - 1,
1333
+ o.paragraphSpacing ?? 0
1334
+ ) };
997
1335
  };
998
1336
  }
999
- const Ft = /* @__PURE__ */ new Set([
1000
- "box-shadow",
1001
- "filter",
1002
- "backdrop-filter",
1003
- "mix-blend-mode",
1004
- "background-blend-mode",
1005
- "clip-path",
1006
- "mask",
1007
- "outline",
1008
- "line-height",
1009
- "text-transform",
1010
- "text-decoration",
1011
- "z-index",
1012
- "float",
1013
- "clear",
1014
- "border-style"
1015
- ]), Pt = /* @__PURE__ */ new Set([
1016
- "gap",
1017
- "row-gap",
1018
- "column-gap",
1019
- "aspect-ratio",
1020
- "background-size",
1021
- "background-position",
1022
- "background-repeat",
1023
- "overflow-wrap",
1024
- "word-break"
1025
- ]), Ee = ["top", "right", "bottom", "left"], Bt = {
1337
+ const cn = ["top", "right", "bottom", "left"], un = {
1026
1338
  normal: { weight: "normal", style: "normal" },
1027
1339
  bold: { weight: "bold", style: "normal" },
1028
1340
  italic: { weight: "normal", style: "italic" },
1029
1341
  "bold-and-italic": { weight: "bold", style: "italic" }
1030
- }, Ht = {
1342
+ }, dn = {
1031
1343
  upper: "flex-start",
1032
1344
  middle: "center",
1033
1345
  lower: "flex-end"
1034
- }, Vt = {
1346
+ }, fn = {
1035
1347
  left: "flex-start",
1036
1348
  center: "center",
1037
1349
  right: "flex-end"
1038
- }, le = {
1350
+ }, ge = {
1039
1351
  "stretch-to-fill": "100% 100%",
1040
1352
  "scale-and-crop": "cover",
1041
1353
  "scale-to-fit": "contain"
1042
- }, Ne = "stretch-to-fill";
1043
- function qt(e) {
1044
- const n = /^(url|resource)\(\s*(["']?)(.*?)\2\s*\)$/.exec(J(e).trim());
1354
+ }, Le = "stretch-to-fill";
1355
+ function st(e) {
1356
+ const n = /^(url|resource)\(\s*(["']?)(.*?)\2\s*\)$/.exec(Z(e).trim());
1045
1357
  return n === null ? null : { form: n[1], path: n[3] };
1046
1358
  }
1047
- function De(e, n, t = {}) {
1048
- var g;
1049
- const s = {}, i = [], r = (p) => {
1050
- var b;
1051
- return (b = e.get(p)) == null ? void 0 : b.value;
1052
- }, u = (p, b) => {
1053
- i.push({ kind: p, message: b, node: n });
1054
- };
1359
+ function Ue(e, n, t = {}) {
1360
+ var h;
1361
+ const s = {}, o = [], i = (f) => {
1362
+ var k;
1363
+ return (k = e.get(f)) == null ? void 0 : k.value;
1364
+ }, c = (f, k, v = {}) => {
1365
+ var M, A, z;
1366
+ const S = ((M = v.subject) == null ? void 0 : M.kind) === "property" ? v.subject.property : ((A = v.subject) == null ? void 0 : A.kind) === "asset" ? "background-image" : void 0, E = S === void 0 ? void 0 : e.get(S);
1367
+ (E == null ? void 0 : E.origin.kind) !== "inherited" && o.push({
1368
+ kind: f,
1369
+ message: k,
1370
+ node: n,
1371
+ ...v,
1372
+ ...E === void 0 ? {} : ((z = t.locate) == null ? void 0 : z.call(t, E.origin)) ?? {}
1373
+ });
1374
+ }, u = (f, k = i(f)) => ({
1375
+ subject: { kind: "property", property: f, ...k === void 0 ? {} : { value: k } }
1376
+ });
1055
1377
  s["box-sizing"] = "border-box";
1056
- for (const [p] of e)
1057
- Ft.has(p) ? u("unsupported-property", `${p} does not exist in USS and is ignored`) : Pt.has(p) && u(
1058
- "version-dependent",
1059
- `${p} depends on the Unity version; verify it in your project`
1060
- );
1061
- const c = [
1378
+ const g = [
1062
1379
  "background-color",
1063
1380
  "color",
1064
1381
  "opacity",
1065
1382
  "visibility",
1066
- "letter-spacing",
1067
- "word-spacing",
1068
1383
  "white-space",
1069
1384
  "text-overflow",
1070
1385
  "cursor",
1071
1386
  "font-size",
1072
1387
  "transform-origin"
1073
1388
  ];
1074
- for (const p of c) {
1075
- const b = r(p);
1076
- b !== void 0 && (s[p] = b);
1077
- }
1078
- r("display") === "none" && (s.display = "none"), r("overflow") === "hidden" && (s.overflow = "hidden");
1079
- for (const p of Ee) {
1080
- const b = r(`border-${p}-width`);
1081
- if (b !== void 0 && b !== "0") {
1082
- const { length: k, problem: x } = Q(b);
1083
- k === null || k.kind !== "px" ? u(
1389
+ for (const f of g) {
1390
+ const k = i(f);
1391
+ k !== void 0 && (s[f] = k);
1392
+ }
1393
+ const p = B(i("font-size") ?? "12px").length, l = (p == null ? void 0 : p.kind) === "px" ? p.value : 12;
1394
+ for (const f of ["letter-spacing", "word-spacing"]) {
1395
+ const k = B(i(f) ?? "").length;
1396
+ (k == null ? void 0 : k.kind) === "px" && (s[f] = `${k.value * l / 100}px`);
1397
+ }
1398
+ i("display") === "none" && (s.display = "none"), i("overflow") === "hidden" && (s.overflow = "hidden");
1399
+ for (const f of cn) {
1400
+ const k = i(`border-${f}-width`);
1401
+ if (k !== void 0 && k !== "0") {
1402
+ const { length: E, problem: M } = B(k);
1403
+ E === null || E.kind !== "px" ? M === void 0 && c(
1084
1404
  "unsupported-property",
1085
- `border-${p}-width: ${x ?? `"${b}" is not a pixel length`}; ignored`
1086
- ) : (s[`border-${p}-width`] = `${k.value}px`, s[`border-${p}-style`] = "solid");
1405
+ `border-${f}-width: "${k}" is not a pixel length; ignored`,
1406
+ { reason: "invalid-value", ...u(`border-${f}-width`) }
1407
+ ) : (s[`border-${f}-width`] = `${E.value}px`, s[`border-${f}-style`] = "solid");
1087
1408
  }
1088
- const m = r(`border-${p}-color`);
1089
- m !== void 0 && (s[`border-${p}-color`] = m);
1090
- const y = r(`padding-${p}`);
1091
- y !== void 0 && y !== "0" && (s[`padding-${p}`] = y);
1409
+ const v = i(`border-${f}-color`);
1410
+ v !== void 0 && (s[`border-${f}-color`] = v);
1411
+ const S = i(`padding-${f}`);
1412
+ S !== void 0 && S !== "0" && (s[`padding-${f}`] = S);
1092
1413
  }
1093
- for (const p of [
1414
+ for (const f of [
1094
1415
  "top-left",
1095
1416
  "top-right",
1096
1417
  "bottom-right",
1097
1418
  "bottom-left"
1098
1419
  ]) {
1099
- const b = r(`border-${p}-radius`);
1100
- b !== void 0 && (s[`border-${p}-radius`] = b);
1420
+ const k = i(`border-${f}-radius`);
1421
+ k !== void 0 && (s[`border-${f}-radius`] = k);
1101
1422
  }
1102
- const v = r("-unity-font-style");
1103
- if (v !== void 0) {
1104
- const p = Bt[v];
1105
- p === void 0 ? u("unsupported-property", `-unity-font-style: ${v} is not a USS value`) : (s["font-weight"] = p.weight, s["font-style"] = p.style);
1106
- }
1107
- const d = r("-unity-text-align");
1423
+ const d = i("-unity-font-style");
1108
1424
  if (d !== void 0) {
1109
- const [p, b] = d.split("-"), m = Ht[p ?? ""], y = Vt[b ?? ""];
1110
- m === void 0 || y === void 0 ? u("unsupported-property", `-unity-text-align: ${d} is not a USS value`) : (s["align-items"] = m, s["justify-content"] = y);
1111
- }
1112
- const o = [], a = r("translate");
1113
- a !== void 0 && o.push(`translate(${a.replace(/\s+/, ", ")})`);
1114
- const f = r("rotate");
1115
- f !== void 0 && o.push(`rotate(${f})`);
1116
- const l = r("scale");
1117
- l !== void 0 && o.push(`scale(${l.replace(/\s+/, ", ")})`), o.length > 0 && (s.transform = o.join(" "));
1118
- const h = r("background-image");
1119
- if (h !== void 0 && h !== "none") {
1120
- const p = qt(h);
1121
- if (p === null)
1122
- u("asset-unresolved", `background-image: cannot read "${h}" as an asset path`);
1425
+ const f = un[d];
1426
+ f === void 0 ? c("unsupported-property", `-unity-font-style: "${d}" ignored`, {
1427
+ reason: "invalid-value",
1428
+ ...u("-unity-font-style")
1429
+ }) : (s["font-weight"] = f.weight, s["font-style"] = f.style);
1430
+ }
1431
+ const m = i("-unity-text-align");
1432
+ if (m !== void 0) {
1433
+ const [f, k] = m.split("-"), v = dn[f ?? ""], S = fn[k ?? ""];
1434
+ v === void 0 || S === void 0 ? c("unsupported-property", `-unity-text-align: "${m}" ignored`, {
1435
+ reason: "invalid-value",
1436
+ ...u("-unity-text-align")
1437
+ }) : (s["align-items"] = v, s["justify-content"] = S);
1438
+ }
1439
+ const a = [], b = i("translate");
1440
+ b !== void 0 && a.push(`translate(${b.replace(/\s+/, ", ")})`);
1441
+ const r = i("rotate");
1442
+ r !== void 0 && a.push(`rotate(${r})`);
1443
+ const w = i("scale");
1444
+ w !== void 0 && a.push(`scale(${w.replace(/\s+/, ", ")})`), a.length > 0 && (s.transform = a.join(" "));
1445
+ const y = i("background-image");
1446
+ if (y !== void 0 && y !== "none") {
1447
+ const f = st(y);
1448
+ if (f === null)
1449
+ c("unsupported-property", `background-image: "${y}" is not an asset reference; Unity shows its warning icon instead`, {
1450
+ reason: "not-uss",
1451
+ ...u("background-image")
1452
+ });
1123
1453
  else {
1124
- const { form: b, path: m } = p, y = ((g = t.resolveAsset) == null ? void 0 : g.call(t, m, b)) ?? null;
1125
- if (y === null)
1126
- s["background-image"] = "repeating-linear-gradient(45deg, rgba(255,0,255,0.35) 0 6px, rgba(0,0,0,0) 6px 12px)", u("asset-unresolved", `background-image: "${m}" was not resolved`);
1454
+ const { form: k, path: v } = f, S = ((h = t.resolveAsset) == null ? void 0 : h.call(t, v, k)) ?? null;
1455
+ if (S === null)
1456
+ s["background-image"] = "repeating-linear-gradient(45deg, rgba(255,0,255,0.35) 0 6px, rgba(0,0,0,0) 6px 12px)", c("asset-unresolved", `background-image: "${v}" was not resolved`, {
1457
+ subject: { kind: "asset", path: v, form: k }
1458
+ });
1127
1459
  else {
1128
- s["background-image"] = `url("${y}")`, s["background-repeat"] = r("background-repeat") ?? "no-repeat", s["background-position"] = r("background-position") ?? "center";
1129
- const k = r("background-size"), x = r("-unity-background-scale-mode") ?? Ne, $ = le[x];
1130
- $ === void 0 && u(
1460
+ s["background-image"] = `url("${S}")`, s["background-repeat"] = i("background-repeat") ?? "no-repeat", s["background-position"] = i("background-position") ?? "center";
1461
+ const E = i("background-size"), M = i("-unity-background-scale-mode") ?? Le, A = ge[M];
1462
+ A === void 0 && c(
1131
1463
  "unsupported-property",
1132
- `-unity-background-scale-mode: ${x} is not a USS value; expected one of ${Object.keys(le).join(", ")}`
1133
- ), s["background-size"] = k ?? $ ?? le[Ne];
1464
+ `-unity-background-scale-mode: "${M}" ignored; expected one of ${Object.keys(ge).join(", ")}`,
1465
+ { reason: "invalid-value", ...u("-unity-background-scale-mode", M) }
1466
+ ), s["background-size"] = E ?? A ?? ge[Le];
1134
1467
  }
1135
1468
  }
1136
1469
  }
1137
- return r("-unity-background-image-tint-color") !== void 0 && u(
1138
- "unsupported-property",
1139
- "-unity-background-image-tint-color has no CSS equivalent and is not drawn"
1140
- ), Ee.some((p) => r(`-unity-slice-${p}`) !== void 0) && u("unsupported-property", "-unity-slice-* (9-slice) is not drawn in this preview"), r("-unity-font-definition") !== void 0 && u(
1141
- "unsupported-property",
1142
- "-unity-font-definition names a Unity font asset; the browser default is used"
1143
- ), { declarations: s, warnings: i };
1144
- }
1145
- const Gt = "data-uxml-node", Jt = "data-uxml-part", Xt = "data-uxml-part-owner";
1146
- function Yt(e, n, t, s, i, r) {
1147
- const u = [], c = /* @__PURE__ */ new Map();
1148
- function v(f) {
1149
- const l = s.get(f.id), h = (g) => {
1150
- var m;
1151
- const p = ((m = l == null ? void 0 : l.get(g)) == null ? void 0 : m.value) ?? ae[g] ?? "0", { length: b } = Q(p);
1152
- return b !== null && b.kind === "px" ? b.value : 0;
1470
+ return { declarations: s, warnings: o };
1471
+ }
1472
+ const pn = "data-uxml-node", hn = "data-uxml-part", mn = "data-uxml-part-owner";
1473
+ function gn(e, n, t, s, o, i) {
1474
+ const c = [], u = /* @__PURE__ */ new Map();
1475
+ function g(a) {
1476
+ const b = s.get(a.id), r = (w) => {
1477
+ var f;
1478
+ const y = ((f = b == null ? void 0 : b.get(w)) == null ? void 0 : f.value) ?? ve[w] ?? "0", { length: h } = B(y);
1479
+ return h !== null && h.kind === "px" ? h.value : 0;
1153
1480
  };
1154
- return { left: h("border-left-width"), top: h("border-top-width") };
1481
+ return { left: r("border-left-width"), top: r("border-top-width") };
1155
1482
  }
1156
- function d(f) {
1157
- const l = (h) => {
1158
- var b;
1159
- const g = ((b = f.style.get(h)) == null ? void 0 : b.value) ?? ae[h] ?? "0", { length: p } = Q(g);
1160
- return p !== null && p.kind === "px" ? p.value : 0;
1483
+ function p(a) {
1484
+ const b = (r) => {
1485
+ var h;
1486
+ const w = ((h = a.style.get(r)) == null ? void 0 : h.value) ?? ve[r] ?? "0", { length: y } = B(w);
1487
+ return y !== null && y.kind === "px" ? y.value : 0;
1161
1488
  };
1162
- return { left: l("border-left-width"), top: l("border-top-width") };
1163
- }
1164
- function o(f, l, h) {
1165
- var E;
1166
- const g = n.get(f.id);
1167
- if (g === void 0) return null;
1168
- const p = r.document.createElement("div");
1169
- p.setAttribute(Gt, String(f.id));
1170
- const b = s.get(f.id) ?? /* @__PURE__ */ new Map(), m = De(b, f.id, r);
1171
- u.push(...m.warnings);
1172
- const y = l === null ? 0 : g.left - l.left - h.left, k = l === null ? 0 : g.top - l.top - h.top, x = {
1489
+ return { left: b("border-left-width"), top: b("border-top-width") };
1490
+ }
1491
+ function l(a, b, r) {
1492
+ var k, v;
1493
+ const w = B(((k = r.get("letter-spacing")) == null ? void 0 : k.value) ?? "").length;
1494
+ if ((w == null ? void 0 : w.kind) !== "px" || w.value === 0) {
1495
+ a.textContent = b;
1496
+ return;
1497
+ }
1498
+ const y = ((v = r.get("-unity-text-generator")) == null ? void 0 : v.value) === "standard", h = [...b], f = h.pop();
1499
+ for (const S of h.join("").match(/ +|[^ ]+/g) ?? []) {
1500
+ const E = i.document.createElement("span");
1501
+ E.textContent = S, !y && S[0] === " " && (E.style.letterSpacing = "0px"), a.appendChild(E);
1502
+ }
1503
+ if (f !== void 0) {
1504
+ const S = i.document.createElement("span");
1505
+ S.textContent = f, S.style.letterSpacing = "0px", a.appendChild(S);
1506
+ }
1507
+ }
1508
+ function d(a, b, r) {
1509
+ var A, z, q, Q, x;
1510
+ const w = n.get(a.id);
1511
+ if (w === void 0) return null;
1512
+ const y = i.document.createElement("div");
1513
+ y.setAttribute(pn, String(a.id));
1514
+ const h = s.get(a.id) ?? /* @__PURE__ */ new Map(), f = Ue(h, a.id, i);
1515
+ c.push(...f.warnings);
1516
+ const k = b === null ? 0 : w.left - b.left - r.left, v = b === null ? 0 : w.top - b.top - r.top, S = {
1173
1517
  position: "absolute",
1174
- left: `${y}px`,
1175
- top: `${k}px`,
1176
- width: `${g.width}px`,
1177
- height: `${g.height}px`,
1518
+ left: `${k}px`,
1519
+ top: `${v}px`,
1520
+ width: `${w.width}px`,
1521
+ height: `${w.height}px`,
1178
1522
  margin: "0",
1179
- ...m.declarations
1523
+ ...f.declarations
1180
1524
  };
1181
- for (const [C, L] of Object.entries(x))
1182
- p.style.setProperty(C, L);
1183
- const { spec: $ } = H(f), O = (E = f.attributes.find((C) => C.name === "text")) == null ? void 0 : E.value;
1184
- if ($.hasText && O !== void 0 && O.length > 0)
1185
- p.style.setProperty("display", m.declarations.display ?? "flex"), m.declarations["align-items"] === void 0 && p.style.setProperty("align-items", "flex-start"), m.declarations["justify-content"] === void 0 && p.style.setProperty("justify-content", "flex-start"), p.textContent = J(O);
1186
- else {
1187
- let C = p, L = g, w = v(f);
1188
- for (const S of t.get(f.id) ?? []) {
1189
- const T = r.document.createElement("div");
1190
- T.setAttribute(Jt, S.name), T.setAttribute(Xt, String(f.id));
1191
- const N = De(S.style, f.id, r);
1192
- u.push(...N.warnings);
1193
- const D = {
1525
+ for (const [$, T] of Object.entries(S))
1526
+ y.style.setProperty($, T);
1527
+ const { spec: E } = X(a), M = (A = a.attributes.find(($) => $.name === "text")) == null ? void 0 : A.value;
1528
+ if (E.hasText && M !== void 0 && M.length > 0) {
1529
+ y.style.setProperty("display", f.declarations.display ?? "flex"), f.declarations["align-items"] === void 0 && y.style.setProperty("align-items", "flex-start"), f.declarations["justify-content"] === void 0 && y.style.setProperty("justify-content", "flex-start");
1530
+ const $ = (z = i.fonts) == null ? void 0 : z.get(h);
1531
+ $ !== void 0 && (y.style.fontFamily = nt($.family));
1532
+ const T = B(((q = h.get("-unity-paragraph-spacing")) == null ? void 0 : q.value) ?? "").length, I = Z(M), O = B(((Q = h.get("letter-spacing")) == null ? void 0 : Q.value) ?? "").length;
1533
+ if ((T == null ? void 0 : T.kind) === "px" && I.includes(`
1534
+ `)) {
1535
+ const D = B(((x = h.get("font-size")) == null ? void 0 : x.value) ?? "12px").length, C = I.split(`
1536
+ `), R = i.document.createElement("div");
1537
+ R.style.width = "100%", C.forEach((L, U) => {
1538
+ const N = i.document.createElement("div");
1539
+ if (l(N, L, h), N.style.minHeight = "1em", U < C.length - 1 && (N.style.marginBottom = `${T.value * ((D == null ? void 0 : D.kind) === "px" ? D.value : 12) / 100}px`), R.appendChild(N), U < C.length - 1) {
1540
+ const j = i.document.createElement("span");
1541
+ j.textContent = `
1542
+ `, j.style.display = "none", R.appendChild(j);
1543
+ }
1544
+ }), y.appendChild(R);
1545
+ } else if ((O == null ? void 0 : O.kind) === "px" && O.value !== 0) {
1546
+ const D = i.document.createElement("span");
1547
+ D.style.minWidth = "0", l(D, I, h), y.appendChild(D);
1548
+ } else
1549
+ y.textContent = I;
1550
+ } else {
1551
+ let $ = y, T = w, I = g(a);
1552
+ for (const O of t.get(a.id) ?? []) {
1553
+ const D = i.document.createElement("div");
1554
+ D.setAttribute(hn, O.name), D.setAttribute(mn, String(a.id));
1555
+ const C = Ue(O.style, a.id, i);
1556
+ c.push(...C.warnings);
1557
+ const R = {
1194
1558
  position: "absolute",
1195
- left: `${S.box.left - L.left - w.left}px`,
1196
- top: `${S.box.top - L.top - w.top}px`,
1197
- width: `${S.box.width}px`,
1198
- height: `${S.box.height}px`,
1559
+ left: `${O.box.left - T.left - I.left}px`,
1560
+ top: `${O.box.top - T.top - I.top}px`,
1561
+ width: `${O.box.width}px`,
1562
+ height: `${O.box.height}px`,
1199
1563
  margin: "0",
1200
- ...N.declarations
1564
+ ...C.declarations
1201
1565
  };
1202
- for (const [A, I] of Object.entries(D))
1203
- T.style.setProperty(A, I);
1204
- C.appendChild(T), C = T, L = S.box, w = d(S);
1566
+ for (const [L, U] of Object.entries(R))
1567
+ D.style.setProperty(L, U);
1568
+ $.appendChild(D), $ = D, T = O.box, I = p(O);
1205
1569
  }
1206
- for (const S of f.children) {
1207
- const T = o(S, L, w);
1208
- T !== null && C.appendChild(T);
1570
+ for (const O of a.children) {
1571
+ const D = d(O, T, I);
1572
+ D !== null && $.appendChild(D);
1209
1573
  }
1210
1574
  }
1211
- return c.set(f.id, p), p;
1575
+ return u.set(a.id, y), y;
1212
1576
  }
1213
- i.replaceChildren();
1214
- const a = o(e, null, { left: 0, top: 0 });
1215
- return a !== null && (a.style.setProperty("position", "relative"), i.appendChild(a)), { warnings: u, elements: c };
1577
+ o.replaceChildren();
1578
+ const m = d(e, null, { left: 0, top: 0 });
1579
+ return m !== null && (m.style.setProperty("position", "relative"), o.appendChild(m)), { warnings: c, elements: u };
1216
1580
  }
1217
- const Ae = /[A-Za-z0-9_-]/;
1218
- function B(e) {
1581
+ const ze = /[A-Za-z0-9_-]/;
1582
+ function K(e) {
1219
1583
  return e === " " || e === " " || e === `
1220
1584
  ` || e === "\r" || e === "\f";
1221
1585
  }
1222
- function ce(e, n, t) {
1223
- let s = n, i = 0;
1586
+ function we(e, n, t) {
1587
+ let s = n, o = 0;
1224
1588
  for (; s < e.length; ) {
1225
- const r = e[s];
1226
- if (r === '"' || r === "'") {
1227
- const u = e.indexOf(r, s + 1);
1228
- s = u < 0 ? e.length : u + 1;
1589
+ const i = e[s];
1590
+ if (i === '"' || i === "'") {
1591
+ const c = e.indexOf(i, s + 1);
1592
+ s = c < 0 ? e.length : c + 1;
1229
1593
  continue;
1230
1594
  }
1231
- if (r === "/" && e[s + 1] === "*") {
1232
- const u = e.indexOf("*/", s + 2);
1233
- s = u < 0 ? e.length : u + 2;
1595
+ if (i === "/" && e[s + 1] === "*") {
1596
+ const c = e.indexOf("*/", s + 2);
1597
+ s = c < 0 ? e.length : c + 2;
1234
1598
  continue;
1235
1599
  }
1236
- if (r === "(" || r === "[")
1237
- i++;
1238
- else if (r === ")" || r === "]")
1239
- i > 0 && i--;
1240
- else if (i === 0 && t.includes(r))
1600
+ if (i === "(" || i === "[")
1601
+ o++;
1602
+ else if (i === ")" || i === "]")
1603
+ o > 0 && o--;
1604
+ else if (o === 0 && t.includes(i))
1241
1605
  return s;
1242
1606
  s++;
1243
1607
  }
1244
1608
  return e.length;
1245
1609
  }
1246
- function qe(e, n, t) {
1247
- let s = n, i = t;
1248
- for (; s < i && B(e[s]); ) s++;
1249
- for (; i > s && B(e[i - 1]); ) i--;
1250
- return { start: s, end: i };
1251
- }
1252
- function Ge(e, n, t, s) {
1253
- const i = [];
1254
- let r = n;
1255
- for (; r < t; ) {
1256
- for (; r < t && (B(e[r]) || e.startsWith("/*", r)); )
1257
- if (e.startsWith("/*", r)) {
1258
- const o = e.indexOf("*/", r + 2);
1259
- r = o < 0 ? t : o + 2;
1610
+ function ot(e, n, t) {
1611
+ let s = n, o = t;
1612
+ for (; s < o && K(e[s]); ) s++;
1613
+ for (; o > s && K(e[o - 1]); ) o--;
1614
+ return { start: s, end: o };
1615
+ }
1616
+ function it(e, n, t, s) {
1617
+ const o = [];
1618
+ let i = n;
1619
+ for (; i < t; ) {
1620
+ for (; i < t && (K(e[i]) || e.startsWith("/*", i)); )
1621
+ if (e.startsWith("/*", i)) {
1622
+ const l = e.indexOf("*/", i + 2);
1623
+ i = l < 0 ? t : l + 2;
1260
1624
  } else
1261
- r++;
1262
- if (r >= t) break;
1263
- if (e[r] === ";") {
1264
- r++;
1625
+ i++;
1626
+ if (i >= t) break;
1627
+ if (e[i] === ";") {
1628
+ i++;
1265
1629
  continue;
1266
1630
  }
1267
- const u = r, c = ce(e, u, ":;}");
1268
- if (c >= t || e[c] !== ":") {
1269
- const o = Math.min(c, t);
1270
- s == null || s("declaration without a value", u, o), r = o + 1;
1631
+ const c = i, u = we(e, c, ":;}");
1632
+ if (u >= t || e[u] !== ":") {
1633
+ const l = Math.min(u, t);
1634
+ s == null || s("declaration without a value", c, l), i = l + 1;
1271
1635
  continue;
1272
1636
  }
1273
- const v = Math.min(ce(e, c + 1, ";}"), t), d = qe(e, c + 1, v);
1274
- i.push({
1275
- property: e.slice(u, c).trim(),
1276
- value: e.slice(d.start, d.end),
1277
- span: { start: u, end: d.end },
1637
+ const g = Math.min(we(e, u + 1, ";}"), t), p = ot(e, u + 1, g);
1638
+ o.push({
1639
+ property: e.slice(c, u).trim(),
1640
+ value: e.slice(p.start, p.end),
1641
+ span: { start: c, end: p.end },
1278
1642
  dirty: !1
1279
- }), r = v + 1;
1643
+ }), i = g + 1;
1280
1644
  }
1281
- return i;
1645
+ return o;
1282
1646
  }
1283
- function Kt(e) {
1647
+ function yn(e) {
1284
1648
  const n = e.span.end - 1 - e.value.length;
1285
1649
  return n < e.span.start ? null : n;
1286
1650
  }
1287
- function ge(e, n = null, t = 0) {
1288
- const s = [], i = [];
1289
- let r = 0;
1290
- function u(m, y, k) {
1651
+ function Oe(e, n = null, t = 0) {
1652
+ const s = [], o = [];
1653
+ let i = 0;
1654
+ function c(h, f, k) {
1291
1655
  s.push({
1292
1656
  kind: "malformed",
1293
- message: m,
1294
- at: { in: "uss", sheet: t, span: { start: y, end: k } }
1657
+ message: h,
1658
+ at: { in: "uss", sheet: t, span: { start: f, end: k } }
1295
1659
  });
1296
1660
  }
1297
- function c() {
1661
+ function u() {
1298
1662
  for (; ; ) {
1299
- for (; B(e[r]); ) r++;
1300
- if (e.startsWith("/*", r)) {
1301
- const m = e.indexOf("*/", r + 2);
1302
- r = m < 0 ? e.length : m + 2;
1663
+ for (; K(e[i]); ) i++;
1664
+ if (e.startsWith("/*", i)) {
1665
+ const h = e.indexOf("*/", i + 2);
1666
+ i = h < 0 ? e.length : h + 2;
1303
1667
  continue;
1304
1668
  }
1305
1669
  return;
1306
1670
  }
1307
1671
  }
1308
- const v = (m, y) => ce(e, m, y), d = (m, y) => qe(e, m, y);
1309
- function o(m) {
1310
- let y = m + 1, k = 1;
1311
- for (; y < e.length; ) {
1312
- const x = e[y];
1313
- if (x === '"' || x === "'") {
1314
- const $ = e.indexOf(x, y + 1);
1315
- y = $ < 0 ? e.length : $ + 1;
1672
+ const g = (h, f) => we(e, h, f), p = (h, f) => ot(e, h, f);
1673
+ function l(h) {
1674
+ let f = h + 1, k = 1;
1675
+ for (; f < e.length; ) {
1676
+ const v = e[f];
1677
+ if (v === '"' || v === "'") {
1678
+ const S = e.indexOf(v, f + 1);
1679
+ f = S < 0 ? e.length : S + 1;
1316
1680
  continue;
1317
1681
  }
1318
- if (x === "/" && e[y + 1] === "*") {
1319
- const $ = e.indexOf("*/", y + 2);
1320
- y = $ < 0 ? e.length : $ + 2;
1682
+ if (v === "/" && e[f + 1] === "*") {
1683
+ const S = e.indexOf("*/", f + 2);
1684
+ f = S < 0 ? e.length : S + 2;
1321
1685
  continue;
1322
1686
  }
1323
- if (x === "{") k++;
1324
- else if (x === "}" && --k === 0) return y + 1;
1325
- y++;
1687
+ if (v === "{") k++;
1688
+ else if (v === "}" && --k === 0) return f + 1;
1689
+ f++;
1326
1690
  }
1327
1691
  return e.length;
1328
1692
  }
1329
- function a(m) {
1330
- let y = m;
1331
- for (; y < e.length && Ae.test(e[y]); ) y++;
1332
- return y;
1333
- }
1334
- function f(m) {
1335
- const y = e[m], k = y === "(" ? ")" : "]";
1336
- let x = m + 1, $ = 1;
1337
- for (; x < e.length; ) {
1338
- const O = e[x];
1339
- if (O === '"' || O === "'") {
1340
- const E = e.indexOf(O, x + 1);
1341
- x = E < 0 ? e.length : E + 1;
1693
+ function d(h) {
1694
+ let f = h;
1695
+ for (; f < e.length && ze.test(e[f]); ) f++;
1696
+ return f;
1697
+ }
1698
+ function m(h) {
1699
+ const f = e[h], k = f === "(" ? ")" : "]";
1700
+ let v = h + 1, S = 1;
1701
+ for (; v < e.length; ) {
1702
+ const E = e[v];
1703
+ if (E === '"' || E === "'") {
1704
+ const M = e.indexOf(E, v + 1);
1705
+ v = M < 0 ? e.length : M + 1;
1342
1706
  continue;
1343
1707
  }
1344
- if (O === y) $++;
1345
- else if (O === k && --$ === 0) return x + 1;
1346
- x++;
1708
+ if (E === f) S++;
1709
+ else if (E === k && --S === 0) return v + 1;
1710
+ v++;
1347
1711
  }
1348
1712
  return e.length;
1349
1713
  }
1350
- function l(m, y) {
1714
+ function a(h, f) {
1351
1715
  const k = [];
1352
- let x = m;
1353
- for (; x < y; ) {
1354
- const $ = e[x];
1355
- if (B($) || $ === ">" || $ === "+" || $ === "~" || $ === ",") break;
1356
- if ($ === "*")
1357
- k.push({ kind: "universal" }), x++;
1358
- else if ($ === "." || $ === "#") {
1359
- const O = a(x + 1);
1716
+ let v = h;
1717
+ for (; v < f; ) {
1718
+ const S = e[v];
1719
+ if (K(S) || S === ">" || S === "+" || S === "~" || S === ",") break;
1720
+ if (S === "*")
1721
+ k.push({ kind: "universal" }), v++;
1722
+ else if (S === "." || S === "#") {
1723
+ const E = d(v + 1);
1360
1724
  k.push(
1361
- $ === "." ? { kind: "class", name: e.slice(x + 1, O) } : { kind: "name", name: e.slice(x + 1, O) }
1362
- ), x = O;
1363
- } else if ($ === "[") {
1364
- const O = Math.min(f(x), y);
1365
- k.push({ kind: "unknown", text: e.slice(x, O) }), x = O;
1366
- } else if ($ === ":")
1367
- if (e[x + 1] === ":") {
1368
- const O = a(x + 2);
1369
- k.push({ kind: "unknown", text: e.slice(x, O) }), x = O;
1725
+ S === "." ? { kind: "class", name: e.slice(v + 1, E) } : { kind: "name", name: e.slice(v + 1, E) }
1726
+ ), v = E;
1727
+ } else if (S === "[") {
1728
+ const E = Math.min(m(v), f);
1729
+ k.push({ kind: "unknown", text: e.slice(v, E) }), v = E;
1730
+ } else if (S === ":")
1731
+ if (e[v + 1] === ":") {
1732
+ const E = d(v + 2);
1733
+ k.push({ kind: "unknown", text: e.slice(v, E) }), v = E;
1370
1734
  } else {
1371
- const O = a(x + 1);
1372
- if (e[O] === "(") {
1373
- const E = Math.min(f(O), y);
1374
- k.push({ kind: "unknown", text: e.slice(x, E) }), x = E;
1735
+ const E = d(v + 1);
1736
+ if (e[E] === "(") {
1737
+ const M = Math.min(m(E), f);
1738
+ k.push({ kind: "unknown", text: e.slice(v, M) }), v = M;
1375
1739
  } else
1376
- k.push({ kind: "pseudo", name: e.slice(x + 1, O) }), x = O;
1740
+ k.push({ kind: "pseudo", name: e.slice(v + 1, E) }), v = E;
1377
1741
  }
1378
- else if (Ae.test($)) {
1379
- const O = a(x);
1380
- k.push({ kind: "type", name: e.slice(x, O) }), x = O;
1742
+ else if (ze.test(S)) {
1743
+ const E = d(v);
1744
+ k.push({ kind: "type", name: e.slice(v, E) }), v = E;
1381
1745
  } else
1382
- k.push({ kind: "unknown", text: $ }), x++;
1746
+ k.push({ kind: "unknown", text: S }), v++;
1383
1747
  }
1384
- return { simple: k, next: x };
1385
- }
1386
- function h(m, y) {
1387
- const k = d(m, y), x = [];
1388
- let $ = "descendant", O = null, E = k.start;
1389
- for (; E < k.end; ) {
1390
- const C = e[E];
1391
- if (B(C)) {
1392
- E++;
1748
+ return { simple: k, next: v };
1749
+ }
1750
+ function b(h, f) {
1751
+ const k = p(h, f), v = [];
1752
+ let S = "descendant", E = null, M = k.start;
1753
+ for (; M < k.end; ) {
1754
+ const A = e[M];
1755
+ if (K(A)) {
1756
+ M++;
1393
1757
  continue;
1394
1758
  }
1395
- if (C === ">") {
1396
- $ = "child", E++;
1759
+ if (A === ">") {
1760
+ S = "child", M++;
1397
1761
  continue;
1398
1762
  }
1399
- if (C === "+" || C === "~") {
1400
- O = C, E++;
1763
+ if (A === "+" || A === "~") {
1764
+ E = A, M++;
1401
1765
  continue;
1402
1766
  }
1403
- const { simple: L, next: w } = l(E, k.end);
1404
- if (w === E) {
1405
- E++;
1767
+ const { simple: z, next: q } = a(M, k.end);
1768
+ if (q === M) {
1769
+ M++;
1406
1770
  continue;
1407
1771
  }
1408
- O !== null && (L.unshift({ kind: "unknown", text: O }), O = null), x.push({ combinator: $, simple: L }), $ = "descendant", E = w;
1772
+ E !== null && (z.unshift({ kind: "unknown", text: E }), E = null), v.push({ combinator: S, simple: z }), S = "descendant", M = q;
1409
1773
  }
1410
- return { parts: x, span: k };
1774
+ return { parts: v, span: k };
1411
1775
  }
1412
- function g(m, y) {
1776
+ function r(h, f) {
1413
1777
  const k = [];
1414
- let x = m;
1778
+ let v = h;
1415
1779
  for (; ; ) {
1416
- const $ = Math.min(v(x, ","), y);
1417
- if (k.push(h(x, $)), $ >= y) break;
1418
- x = $ + 1;
1780
+ const S = Math.min(g(v, ","), f);
1781
+ if (k.push(b(v, S)), S >= f) break;
1782
+ v = S + 1;
1419
1783
  }
1420
1784
  return k;
1421
1785
  }
1422
- function p() {
1423
- const m = r, y = a(r + 1), k = e.slice(r + 1, y), x = v(y, "{;");
1424
- if (x < e.length && e[x] === "{") {
1425
- const O = o(x);
1426
- return r = O, { kind: "unknown", span: { start: m, end: O } };
1427
- }
1428
- const $ = x < e.length ? x + 1 : e.length;
1429
- if (r = $, k === "import") {
1430
- const O = e.slice(y, $), E = /["']([^"']*)["']/.exec(O);
1431
- return E === null ? (u("@import without a quoted path", m, $), { kind: "unknown", span: { start: m, end: $ } }) : { kind: "import", url: E[1], span: { start: m, end: $ } };
1432
- }
1433
- return { kind: "unknown", span: { start: m, end: $ } };
1434
- }
1435
- function b() {
1436
- const m = r, y = v(m, "{");
1437
- if (y >= e.length)
1438
- return u("rule without a block", m, e.length), r = e.length, { kind: "unknown", span: { start: m, end: e.length } };
1439
- const k = d(m, y), x = o(y);
1440
- (x > e.length || e[x - 1] !== "}") && u("unterminated rule block", m, x);
1441
- const $ = {
1442
- selectors: g(k.start, k.end),
1443
- declarations: Ge(e, y + 1, x - 1, u),
1444
- span: { start: k.start, end: x },
1786
+ function w() {
1787
+ const h = i, f = d(i + 1), k = e.slice(i + 1, f), v = g(f, "{;");
1788
+ if (v < e.length && e[v] === "{") {
1789
+ const E = l(v);
1790
+ return i = E, { kind: "unknown", span: { start: h, end: E } };
1791
+ }
1792
+ const S = v < e.length ? v + 1 : e.length;
1793
+ if (i = S, k === "import") {
1794
+ const E = e.slice(f, S), M = /["']([^"']*)["']/.exec(E);
1795
+ return M === null ? (c("@import without a quoted path", h, S), { kind: "unknown", span: { start: h, end: S } }) : { kind: "import", url: M[1], span: { start: h, end: S } };
1796
+ }
1797
+ return { kind: "unknown", span: { start: h, end: S } };
1798
+ }
1799
+ function y() {
1800
+ const h = i, f = g(h, "{");
1801
+ if (f >= e.length)
1802
+ return c("rule without a block", h, e.length), i = e.length, { kind: "unknown", span: { start: h, end: e.length } };
1803
+ const k = p(h, f), v = l(f);
1804
+ (v > e.length || e[v - 1] !== "}") && c("unterminated rule block", h, v);
1805
+ const S = {
1806
+ selectors: r(k.start, k.end),
1807
+ declarations: it(e, f + 1, v - 1, c),
1808
+ span: { start: k.start, end: v },
1445
1809
  selectorSpan: k,
1446
1810
  selectorDirty: !1,
1447
1811
  declarationsDirty: !1
1448
1812
  };
1449
- return r = x, { kind: "rule", rule: $ };
1813
+ return i = v, { kind: "rule", rule: S };
1450
1814
  }
1451
- for (; c(), !(r >= e.length); )
1452
- i.push(e[r] === "@" ? p() : b());
1453
- return { sheet: { source: e, origin: n, items: i }, warnings: s };
1815
+ for (; u(), !(i >= e.length); )
1816
+ o.push(e[i] === "@" ? w() : y());
1817
+ return { sheet: { source: e, origin: n, items: o }, warnings: s };
1454
1818
  }
1455
- function Zt(e, n, t) {
1819
+ function bn(e, n, t) {
1456
1820
  switch (e.kind) {
1457
1821
  case "universal":
1458
1822
  return !0;
@@ -1468,61 +1832,61 @@ function Zt(e, n, t) {
1468
1832
  return !1;
1469
1833
  }
1470
1834
  }
1471
- function Qt(e, n, t) {
1472
- return e.simple.every((s) => Zt(s, n, t));
1835
+ function vn(e, n, t) {
1836
+ return e.simple.every((s) => bn(s, n, t));
1473
1837
  }
1474
- function ue(e, n, t, s) {
1475
- if (!Qt(e[n], t, s)) return !1;
1838
+ function ke(e, n, t, s) {
1839
+ if (!vn(e[n], t, s)) return !1;
1476
1840
  if (n === 0) return !0;
1477
- const i = s.parentOf(t);
1841
+ const o = s.parentOf(t);
1478
1842
  if (e[n].combinator === "child")
1479
- return i !== null && ue(e, n - 1, i, s);
1480
- for (let r = i; r !== null; r = s.parentOf(r))
1481
- if (ue(e, n - 1, r, s)) return !0;
1843
+ return o !== null && ke(e, n - 1, o, s);
1844
+ for (let i = o; i !== null; i = s.parentOf(i))
1845
+ if (ke(e, n - 1, i, s)) return !0;
1482
1846
  return !1;
1483
1847
  }
1484
- function Je(e, n, t) {
1485
- return e.parts.length === 0 ? !1 : ue(e.parts, e.parts.length - 1, n, t);
1848
+ function xe(e, n, t) {
1849
+ return e.parts.length === 0 ? !1 : ke(e.parts, e.parts.length - 1, n, t);
1486
1850
  }
1487
- function en(e) {
1851
+ function rt(e) {
1488
1852
  const n = [];
1489
1853
  for (const t of e.parts)
1490
1854
  for (const s of t.simple)
1491
1855
  s.kind === "pseudo" && s.name !== "root" && !n.includes(s.name) && n.push(s.name);
1492
1856
  return n;
1493
1857
  }
1494
- function tn(e) {
1858
+ function wn(e) {
1495
1859
  const n = [];
1496
1860
  for (const t of e)
1497
1861
  for (const s of t.parts)
1498
- for (const i of s.simple) {
1499
- if (i.kind !== "name" && i.kind !== "class" || !i.name.startsWith("unity-")) continue;
1500
- const r = i.kind === "name" ? `#${i.name}` : `.${i.name}`;
1501
- n.includes(r) || n.push(r);
1862
+ for (const o of s.simple) {
1863
+ if (o.kind !== "name" && o.kind !== "class" || !o.name.startsWith("unity-")) continue;
1864
+ const i = o.kind === "name" ? `#${o.name}` : `.${o.name}`;
1865
+ n.includes(i) || n.push(i);
1502
1866
  }
1503
1867
  return n;
1504
1868
  }
1505
- function Xe(e) {
1869
+ function at(e) {
1506
1870
  for (const n of e)
1507
1871
  for (const t of n.parts)
1508
1872
  for (const s of t.simple)
1509
1873
  if (s.kind === "unknown") return s.text;
1510
1874
  return null;
1511
1875
  }
1512
- function nn(e) {
1876
+ function kn(e) {
1513
1877
  const n = /* @__PURE__ */ new Map([[e, null]]), t = [e];
1514
1878
  for (; t.length > 0; ) {
1515
1879
  const s = t.pop();
1516
- for (const i of s.children)
1517
- n.set(i, s), t.push(i);
1880
+ for (const o of s.children)
1881
+ n.set(o, s), t.push(o);
1518
1882
  }
1519
1883
  return n;
1520
1884
  }
1521
- function sn(e) {
1885
+ function xn(e) {
1522
1886
  let n = 0, t = 0, s = 0;
1523
- for (const i of e.parts)
1524
- for (const r of i.simple)
1525
- switch (r.kind) {
1887
+ for (const o of e.parts)
1888
+ for (const i of o.simple)
1889
+ switch (i.kind) {
1526
1890
  case "name":
1527
1891
  n++;
1528
1892
  break;
@@ -1536,62 +1900,81 @@ function sn(e) {
1536
1900
  }
1537
1901
  return [n, t, s];
1538
1902
  }
1539
- function Ye(e, n) {
1903
+ function lt(e, n) {
1540
1904
  return e[0] - n[0] || e[1] - n[1] || e[2] - n[2];
1541
1905
  }
1542
- const rn = [Number.MAX_SAFE_INTEGER, 0, 0], on = ge(Ve, null, -1).sheet.items.flatMap(
1906
+ const Sn = [Number.MAX_SAFE_INTEGER, 0, 0], $n = Oe(Qe, null, -1).sheet.items.flatMap(
1543
1907
  (e, n) => e.kind === "rule" ? [{ rule: e.rule, sheet: -1, item: n, builtin: !0 }] : []
1544
1908
  );
1545
- function ln(e) {
1546
- return Ve.slice(e.selectorSpan.start, e.selectorSpan.end).trim();
1909
+ function Tn(e) {
1910
+ return Qe.slice(e.selectorSpan.start, e.selectorSpan.end).trim();
1547
1911
  }
1548
- function an(e, n, t, s) {
1549
- const i = (t == null ? void 0 : t.activeStates) ?? /* @__PURE__ */ new Set(), r = Object.entries((t == null ? void 0 : t.states) ?? {}), u = [];
1550
- for (const [o, a] of r) {
1551
- const f = ge(`${o} {}`, null, -1).sheet.items.find((h) => h.kind === "rule"), l = f === void 0 ? o : Xe(f.rule.selectors);
1552
- if (f === void 0 || l !== null) {
1912
+ function En(e, n, t, s) {
1913
+ const o = (t == null ? void 0 : t.activeStates) ?? /* @__PURE__ */ new Set(), i = Object.entries((t == null ? void 0 : t.states) ?? {}), c = [];
1914
+ for (const [l, d] of i) {
1915
+ const m = Oe(`${l} {}`, null, -1).sheet.items.find((w) => w.kind === "rule"), a = m === void 0 ? l : at(m.rule.selectors);
1916
+ if (m === void 0 || a !== null) {
1553
1917
  s.push({
1554
1918
  kind: "unsupported-selector",
1555
- message: `states key "${o}" is not a usable USS selector; it is ignored`
1919
+ message: `states key "${l}" is not a usable USS selector; it is ignored`,
1920
+ reason: "not-uss",
1921
+ subject: { kind: "states-key", key: l }
1556
1922
  });
1557
1923
  continue;
1558
1924
  }
1559
- u.push({ selectors: f.rule.selectors, states: a });
1560
- }
1561
- const c = /* @__PURE__ */ new Map(), v = (o) => o.attributes.some((a) => a.name === "enabled" && a.value === "false"), d = (o, a) => {
1562
- const f = a || v(o), l = new Set(i);
1563
- f && l.add("disabled");
1564
- for (const h of u)
1565
- if (h.selectors.some((g) => Je(g, { kind: "element", node: o }, n)))
1566
- for (const g of h.states) l.add(g);
1567
- c.set(o, l);
1568
- for (const h of o.children) d(h, f);
1925
+ const b = m.rule.selectors, r = (w) => b.some((y) => xe(y, { kind: "element", node: w }, n)) || w.children.some(r);
1926
+ if (!r(e.root)) {
1927
+ const w = b.some((y) => rt(y).some((h) => be.includes(h)));
1928
+ s.push({
1929
+ kind: "unsupported-selector",
1930
+ reason: "invalid-value",
1931
+ message: `states key "${l}" matches no element` + (w ? ": keys are matched before any state is applied, so a state in the key never matches" : ""),
1932
+ subject: { kind: "states-key", key: l, problem: w ? "state-in-key" : "matches-nothing" }
1933
+ });
1934
+ }
1935
+ for (const w of new Set(d))
1936
+ be.includes(w) || s.push({
1937
+ kind: "unsupported-selector",
1938
+ reason: "invalid-value",
1939
+ message: `states key "${l}" lists unknown state "${w}"; Unity sets no such state`,
1940
+ subject: { kind: "states-key", key: l, problem: "unknown-state", state: w }
1941
+ });
1942
+ c.push({ selectors: b, states: d });
1943
+ }
1944
+ const u = /* @__PURE__ */ new Map(), g = (l) => l.attributes.some((d) => d.name === "enabled" && d.value === "false"), p = (l, d) => {
1945
+ const m = d || g(l), a = new Set(o);
1946
+ m ? a.add("disabled") : a.add("enabled");
1947
+ for (const b of c)
1948
+ if (b.selectors.some((r) => xe(r, { kind: "element", node: l }, n)))
1949
+ for (const r of b.states) a.add(r);
1950
+ u.set(l, a);
1951
+ for (const b of l.children) p(b, m);
1569
1952
  };
1570
- return d(e.root, !1), c;
1953
+ return p(e.root, !1), u;
1571
1954
  }
1572
- function cn(e) {
1955
+ function On(e) {
1573
1956
  const n = [], t = /* @__PURE__ */ new Map();
1574
- e.sheets.forEach((u, c) => {
1575
- u.origin !== null && !t.has(u.origin) && t.set(u.origin, c);
1576
- }), n.push(...on);
1577
- const s = /* @__PURE__ */ new Map(), i = (u, c) => {
1578
- const v = s.get(c) ?? /* @__PURE__ */ new Set();
1579
- if (v.has(u)) return;
1580
- v.add(u), s.set(c, v);
1581
- const d = e.sheets[u];
1582
- d !== void 0 && d.items.forEach((o, a) => {
1583
- if (o.kind === "rule")
1584
- n.push({ rule: o.rule, sheet: u, item: a, scope: c });
1585
- else if (o.kind === "import") {
1586
- const f = o.resolvedSheet ?? t.get(o.url);
1587
- f !== void 0 && i(f, c);
1957
+ e.sheets.forEach((c, u) => {
1958
+ c.origin !== null && !t.has(c.origin) && t.set(c.origin, u);
1959
+ }), n.push(...$n);
1960
+ const s = /* @__PURE__ */ new Map(), o = (c, u) => {
1961
+ const g = s.get(u) ?? /* @__PURE__ */ new Set();
1962
+ if (g.has(c)) return;
1963
+ g.add(c), s.set(u, g);
1964
+ const p = e.sheets[c];
1965
+ p !== void 0 && p.items.forEach((l, d) => {
1966
+ if (l.kind === "rule")
1967
+ n.push({ rule: l.rule, sheet: c, item: d, scope: u });
1968
+ else if (l.kind === "import") {
1969
+ const m = l.resolvedSheet ?? t.get(l.url);
1970
+ m !== void 0 && o(m, u);
1588
1971
  }
1589
1972
  });
1590
- }, r = e.styleRoots ?? (e.sheets.length === 0 ? [] : [{ sheet: 0, scope: e.root.id }]);
1591
- for (const u of r) i(u.sheet, u.scope);
1973
+ }, i = e.styleRoots ?? (e.sheets.length === 0 ? [] : [{ sheet: 0, scope: e.root.id }]);
1974
+ for (const c of i) o(c.sheet, c.scope);
1592
1975
  return n;
1593
1976
  }
1594
- function un(e, n, t) {
1977
+ function In(e, n, t) {
1595
1978
  let s = e;
1596
1979
  for (; s !== null; ) {
1597
1980
  if (s.kind === "element" && s.node.id === n) return !0;
@@ -1599,25 +1982,34 @@ function un(e, n, t) {
1599
1982
  }
1600
1983
  return !1;
1601
1984
  }
1602
- function dn(e) {
1985
+ function Dn(e) {
1603
1986
  return e.selectors.some(
1604
1987
  (n) => n.parts.some((t) => t.simple.some((s) => s.kind === "pseudo" && s.name === "root"))
1605
1988
  );
1606
1989
  }
1607
- function de(e, n) {
1990
+ function re(e, n) {
1991
+ var s;
1992
+ const t = n.rule.selectorSpan;
1993
+ return ((s = e.sheets[n.sheet]) == null ? void 0 : s.source.slice(t.start, t.end)) ?? "";
1994
+ }
1995
+ function Y(e, n) {
1996
+ const t = e.sheets[n], s = e.sheets.find((o) => o.items.some((i) => i.kind === "import" && i.resolvedSheet === n));
1997
+ return { url: (t == null ? void 0 : t.origin) ?? null, from: (t == null ? void 0 : t.sourceDocumentFrom) ?? (s == null ? void 0 : s.origin) ?? null };
1998
+ }
1999
+ function G(e, n) {
1608
2000
  var s;
1609
2001
  const t = (s = e.sheets[n]) == null ? void 0 : s.origin;
1610
2002
  return typeof t == "string" ? { sourceDocument: t } : {};
1611
2003
  }
1612
- function Ke(e, n) {
1613
- const t = nn(e.root), s = [], i = /* @__PURE__ */ new Set(), r = (l) => {
1614
- var g;
1615
- const h = (g = l.attributes.find((p) => p.name === "class")) == null ? void 0 : g.value;
1616
- return h === void 0 ? [] : h.split(/\s+/).filter((p) => p.length > 0);
1617
- }, u = (l, h) => {
1618
- var g;
1619
- return (g = l.attributes.find((p) => p.name === h)) == null ? void 0 : g.value;
1620
- }, c = {
2004
+ function ct(e, n) {
2005
+ const t = kn(e.root), s = [], o = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), c = (r) => {
2006
+ var y;
2007
+ const w = (y = r.attributes.find((h) => h.name === "class")) == null ? void 0 : y.value;
2008
+ return w === void 0 ? [] : w.split(/\s+/).filter((h) => h.length > 0);
2009
+ }, u = (r, w) => {
2010
+ var y;
2011
+ return (y = r.attributes.find((h) => h.name === w)) == null ? void 0 : y.value;
2012
+ }, g = {
1621
2013
  /**
1622
2014
  * The rule the measurement forced.
1623
2015
  *
@@ -1628,146 +2020,228 @@ function Ke(e, n) {
1628
2020
  * owner. That is the hierarchy the dumps show, so descendant selectors like
1629
2021
  * `.panel #unity-content-viewport` behave as they do in Unity.
1630
2022
  */
1631
- parentOf: (l) => {
1632
- if (l.kind === "element") {
1633
- const p = t.get(l.node) ?? null;
1634
- return p === null ? null : { kind: "element", node: p };
2023
+ parentOf: (r) => {
2024
+ if (r.kind === "element") {
2025
+ const h = t.get(r.node) ?? null;
2026
+ return h === null ? null : { kind: "element", node: h };
1635
2027
  }
1636
- if (l.depth === 0) return { kind: "element", node: l.owner };
1637
- const g = H(l.owner).spec.parts[l.depth - 1];
1638
- return { kind: "part", owner: l.owner, name: g.name, depth: l.depth - 1 };
2028
+ if (r.depth === 0) return { kind: "element", node: r.owner };
2029
+ const y = X(r.owner).spec.parts[r.depth - 1];
2030
+ return { kind: "part", owner: r.owner, name: y.name, depth: r.depth - 1 };
1639
2031
  },
1640
- isRoot: (l) => l.kind === "element" && l.node === e.root,
2032
+ isRoot: (r) => r.kind === "element" && r.node === e.root,
1641
2033
  // Unity's parts are VisualElements, so a `VisualElement` rule reaches them.
1642
2034
  // Not measured — `part-type-selector` is the case that will settle it.
1643
- typeNameOf: (l) => l.kind === "element" ? l.node.name.local : "VisualElement",
1644
- idOf: (l) => l.kind === "element" ? u(l.node, "name") : l.name,
2035
+ typeNameOf: (r) => r.kind === "element" ? r.node.name.local : "VisualElement",
2036
+ idOf: (r) => r.kind === "element" ? u(r.node, "name") : r.name,
1645
2037
  // Implicit classes are as real as written ones for matching: in Unity the
1646
2038
  // element genuinely carries them, which is why `.unity-button` in author USS
1647
2039
  // hits a plain `<ui:Button />`. Parts carry classes too in Unity, but which
1648
2040
  // ones is unmeasured, so none are claimed here.
1649
- classesOf: (l) => l.kind === "element" ? [...r(l.node), ...$t(l.node)] : []
1650
- }, v = { ...c, statesOf: () => i }, d = an(e, v, n, s), o = {
1651
- ...c,
2041
+ classesOf: (r) => r.kind === "element" ? [...c(r.node), ...wt(r.node)] : []
2042
+ }, p = { ...g, statesOf: () => i }, l = En(e, p, n, s), d = {
2043
+ ...g,
1652
2044
  // A part inherits its owner's states: `SetEnabled(false)` disables the whole
1653
2045
  // subtree, and a part is inside it.
1654
- statesOf: (l) => d.get(l.kind === "element" ? l.node : l.owner) ?? i
1655
- }, a = [];
1656
- let f = !1;
1657
- for (const l of cn(e)) {
1658
- if (l.builtin === !0) {
1659
- a.push(l);
2046
+ statesOf: (r) => l.get(r.kind === "element" ? r.node : r.owner) ?? i
2047
+ }, m = [];
2048
+ let a = !1;
2049
+ for (const r of On(e)) {
2050
+ if (r.builtin === !0) {
2051
+ m.push(r);
1660
2052
  continue;
1661
2053
  }
1662
- const h = Xe(l.rule.selectors);
1663
- if (h !== null) {
2054
+ const w = at(r.rule.selectors);
2055
+ if (w !== null) {
1664
2056
  s.push({
1665
2057
  kind: "unsupported-selector",
1666
- message: `"${h}" is not supported in USS; the whole rule is ignored`,
1667
- at: { in: "uss", sheet: l.sheet, span: l.rule.selectorSpan },
1668
- ...de(e, l.sheet)
2058
+ message: `"${w}": the whole rule is ignored`,
2059
+ at: { in: "uss", sheet: r.sheet, ...Y(e, r.sheet), span: r.rule.selectorSpan },
2060
+ reason: "not-uss",
2061
+ subject: { kind: "selector", selector: re(e, r), fragment: w },
2062
+ ...G(e, r.sheet)
1669
2063
  });
1670
2064
  continue;
1671
2065
  }
1672
- !f && dn(l.rule) && (f = !0, s.push({
2066
+ !a && Dn(r.rule) && (a = !0, s.push({
1673
2067
  kind: "version-dependent",
1674
- message: ":root in USS names the element the stylesheet was applied to, not the document root as in CSS. Template stylesheets therefore match their generated TemplateContainer.",
1675
- at: { in: "uss", sheet: l.sheet, span: l.rule.selectorSpan },
1676
- ...de(e, l.sheet)
1677
- })), a.push(l);
2068
+ // Not a version difference: USS :root means something else than CSS
2069
+ // :root, and this preview does what Unity does. Kept as a warning so
2070
+ // an author porting CSS is told; the kind stays for compatibility.
2071
+ message: ":root matched the element this stylesheet is attached to — the document root, or the TemplateContainer of a template",
2072
+ at: { in: "uss", sheet: r.sheet, ...Y(e, r.sheet), span: r.rule.selectorSpan },
2073
+ reason: "matches-unity",
2074
+ subject: { kind: "selector", selector: re(e, r), fragment: ":root" },
2075
+ ...G(e, r.sheet)
2076
+ })), m.push(r);
2077
+ }
2078
+ const b = /* @__PURE__ */ new Set();
2079
+ for (const r of m) {
2080
+ if (r.builtin === !0) continue;
2081
+ const w = `${r.sheet}:${r.item}`;
2082
+ if (b.has(w)) continue;
2083
+ b.add(w);
2084
+ const y = /* @__PURE__ */ new Set();
2085
+ for (const h of r.rule.selectors)
2086
+ for (const f of h.parts)
2087
+ for (const k of f.simple)
2088
+ k.kind !== "pseudo" || k.name === "root" || be.includes(k.name) || y.add(k.name);
2089
+ for (const h of y)
2090
+ s.push({
2091
+ kind: "unsupported-selector",
2092
+ message: `":${h}": never matches; Unity sets no such state`,
2093
+ at: { in: "uss", sheet: r.sheet, ...Y(e, r.sheet), span: r.rule.selectorSpan },
2094
+ ...G(e, r.sheet),
2095
+ reason: "not-uss",
2096
+ subject: { kind: "selector", selector: re(e, r), fragment: `:${h}` }
2097
+ });
2098
+ for (const h of r.rule.declarations) {
2099
+ const f = tt(h.property, h.value);
2100
+ if (f === null) continue;
2101
+ const k = {
2102
+ kind: "unsupported-property",
2103
+ ...f,
2104
+ at: { in: "uss", sheet: r.sheet, ...Y(e, r.sheet), span: h.span },
2105
+ ...G(e, r.sheet)
2106
+ };
2107
+ s.push(k), o.set(k, `${r.sheet}:${r.item}`);
2108
+ }
1678
2109
  }
1679
- return { ctx: o, usable: a, warnings: s };
2110
+ return e.sheets.forEach((r, w) => {
2111
+ var y;
2112
+ for (const h of r.items) {
2113
+ if (h.kind !== "unknown") continue;
2114
+ const f = (y = /^@([A-Za-z][\w-]*)/.exec(r.source.slice(h.span.start, h.span.end))) == null ? void 0 : y[1];
2115
+ f === void 0 || f === "import" || s.push({
2116
+ kind: "unsupported-selector",
2117
+ message: `@${f}: block ignored`,
2118
+ at: { in: "uss", sheet: w, ...Y(e, w), span: h.span },
2119
+ ...G(e, w),
2120
+ reason: "not-uss",
2121
+ subject: { kind: "at-rule", name: f }
2122
+ });
2123
+ }
2124
+ }), { ctx: d, usable: m, warnings: s, declarationWarnings: o };
1680
2125
  }
1681
- function fn(e, n) {
1682
- const t = n.attributes.find((i) => i.name === "style");
2126
+ function Ie(e, n) {
2127
+ const t = n.attributes.find((o) => o.name === "style");
1683
2128
  if (t === void 0) return [];
1684
- const s = Kt(t);
1685
- return s === null ? [] : Ge(e.source, s, s + t.value.length);
2129
+ const s = yn(t);
2130
+ return s === null ? [] : it(e.source, s, s + t.value.length);
2131
+ }
2132
+ function Mn(e, n) {
2133
+ let t = null;
2134
+ const s = (o, i) => {
2135
+ var c;
2136
+ typeof o.sourceDocument != "string" && i.set(((c = o.derived) == null ? void 0 : c.instance) ?? o.id, o);
2137
+ for (const u of o.children) s(u, i);
2138
+ return i;
2139
+ };
2140
+ return (o) => {
2141
+ var i;
2142
+ if (o.kind === "rule") {
2143
+ const c = (i = e.sheets[o.sheet]) == null ? void 0 : i.items[o.item], u = (c == null ? void 0 : c.kind) === "rule" ? c.rule.declarations[o.declIndex] : void 0;
2144
+ return u === void 0 ? {} : { nodes: [...n.get(`${o.sheet}:${o.item}`) ?? []], at: { in: "uss", sheet: o.sheet, ...Y(e, o.sheet), span: u.span }, ...G(e, o.sheet) };
2145
+ }
2146
+ if (o.kind === "inline") {
2147
+ if (typeof o.sourceDocument == "string") return { sourceDocument: o.sourceDocument };
2148
+ t ?? (t = s(e.root, /* @__PURE__ */ new Map()));
2149
+ const c = t.get(o.node), u = c === void 0 ? void 0 : Ie(e, c)[o.declIndex];
2150
+ return u === void 0 ? {} : { at: { in: "uxml", span: u.span } };
2151
+ }
2152
+ return {};
2153
+ };
1686
2154
  }
1687
- function Ze(e, n, t, s) {
2155
+ function ut(e, n, t, s, o) {
1688
2156
  const i = [];
1689
- let r = 0;
1690
- const u = (c, v, d, o, a) => {
1691
- i.push({ property: c, value: v, origin: d, rank: o, specificity: a, order: r++, winner: !1 });
2157
+ let c = 0;
2158
+ const u = (g, p, l, d, m) => {
2159
+ i.push({ property: g, value: p, origin: l, rank: d, specificity: m, order: c++, winner: !1 });
1692
2160
  };
1693
2161
  if (n.kind === "part") {
1694
- const c = H(n.owner).spec.parts[n.depth];
1695
- for (const [v, d] of Object.entries((c == null ? void 0 : c.style) ?? {}))
1696
- for (const [o, a] of ie(v, d))
2162
+ const g = X(n.owner).spec.parts[n.depth];
2163
+ for (const [p, l] of Object.entries((g == null ? void 0 : g.style) ?? {}))
2164
+ for (const [d, m] of pe(p, l))
1697
2165
  u(
1698
- o,
1699
- a,
2166
+ d,
2167
+ m,
1700
2168
  {
1701
2169
  kind: "builtin-theme",
1702
2170
  selector: `#${n.name}`,
1703
- property: o,
1704
- unityVersion: Z
2171
+ property: d,
2172
+ unityVersion: ae
1705
2173
  },
1706
2174
  0,
1707
2175
  [0, 0, 0]
1708
2176
  );
1709
2177
  }
1710
- for (const c of t.usable) {
1711
- if (c.scope !== void 0 && !un(n, c.scope, t.ctx)) continue;
1712
- const v = c.scope === void 0 ? t.ctx : {
2178
+ for (const g of t.usable) {
2179
+ if (g.scope !== void 0 && !In(n, g.scope, t.ctx)) continue;
2180
+ const p = g.scope === void 0 ? t.ctx : {
1713
2181
  ...t.ctx,
1714
2182
  // Unity USS :root names the element this particular stylesheet is
1715
2183
  // attached to. Template sheets are attached to each generated
1716
2184
  // TemplateContainer, not to the entry document root.
1717
- isRoot: (a) => a.kind === "element" && a.node.id === c.scope
2185
+ isRoot: (m) => m.kind === "element" && m.node.id === g.scope
1718
2186
  };
1719
- let d = null, o = [];
1720
- for (const a of c.rule.selectors) {
1721
- if (!Je(a, n, v)) continue;
1722
- const f = sn(a);
1723
- (d === null || Ye(f, d) > 0) && (d = f, o = en(a));
1724
- }
1725
- d !== null && (s == null || s.add(c), c.rule.declarations.forEach((a, f) => {
1726
- var l, h, g;
1727
- for (const [p, b] of ie(a.property, a.value)) {
1728
- const m = c.builtin === !0 ? {
1729
- kind: "builtin-theme",
1730
- selector: ln(c.rule),
1731
- property: p,
1732
- unityVersion: Z
1733
- } : {
1734
- kind: "rule",
1735
- sheet: c.sheet,
1736
- item: c.item,
1737
- declIndex: f,
1738
- ...((l = e.sheets[c.sheet]) == null ? void 0 : l.origin) === null || ((h = e.sheets[c.sheet]) == null ? void 0 : h.origin) === void 0 ? {} : { sourceDocument: e.sheets[c.sheet].origin },
1739
- ...((g = e.sheets[c.sheet]) == null ? void 0 : g.sourceDocumentFrom) === void 0 ? {} : { sourceDocumentFrom: e.sheets[c.sheet].sourceDocumentFrom },
1740
- // Omitted rather than set to [] when unconditional, so the
1741
- // common case stays the shape it has always been.
1742
- ...o.length > 0 ? { states: o } : {}
1743
- };
1744
- u(p, b, m, c.builtin === !0 ? 0 : 1, d);
2187
+ let l = null, d = [];
2188
+ for (const m of g.rule.selectors) {
2189
+ if (!xe(m, n, p)) continue;
2190
+ const a = xn(m);
2191
+ (l === null || lt(a, l) > 0) && (l = a, d = rt(m));
2192
+ }
2193
+ if (l !== null) {
2194
+ if (s == null || s.add(g), o !== void 0 && n.kind === "element" && g.builtin !== !0) {
2195
+ const m = `${g.sheet}:${g.item}`, a = o.get(m) ?? [];
2196
+ a.includes(n.node.id) || a.push(n.node.id), o.set(m, a);
1745
2197
  }
1746
- }));
2198
+ g.rule.declarations.forEach((m, a) => {
2199
+ var b, r, w;
2200
+ for (const [y, h] of pe(m.property, m.value)) {
2201
+ const f = g.builtin === !0 ? {
2202
+ kind: "builtin-theme",
2203
+ selector: Tn(g.rule),
2204
+ property: y,
2205
+ unityVersion: ae
2206
+ } : {
2207
+ kind: "rule",
2208
+ sheet: g.sheet,
2209
+ item: g.item,
2210
+ declIndex: a,
2211
+ ...((b = e.sheets[g.sheet]) == null ? void 0 : b.origin) === null || ((r = e.sheets[g.sheet]) == null ? void 0 : r.origin) === void 0 ? {} : { sourceDocument: e.sheets[g.sheet].origin },
2212
+ ...((w = e.sheets[g.sheet]) == null ? void 0 : w.sourceDocumentFrom) === void 0 ? {} : { sourceDocumentFrom: e.sheets[g.sheet].sourceDocumentFrom },
2213
+ // Omitted rather than set to [] when unconditional, so the
2214
+ // common case stays the shape it has always been.
2215
+ ...d.length > 0 ? { states: d } : {}
2216
+ };
2217
+ u(y, h, f, g.builtin === !0 ? 0 : 1, l);
2218
+ }
2219
+ });
2220
+ }
1747
2221
  }
1748
2222
  if (n.kind === "element") {
1749
- const c = n.node;
1750
- fn(e, c).forEach((v, d) => {
1751
- var o;
1752
- for (const [a, f] of ie(v.property, v.value))
2223
+ const g = n.node;
2224
+ Ie(e, g).forEach((p, l) => {
2225
+ var d;
2226
+ for (const [m, a] of pe(p.property, p.value))
1753
2227
  u(
2228
+ m,
1754
2229
  a,
1755
- f,
1756
2230
  {
1757
2231
  kind: "inline",
1758
- node: ((o = c.derived) == null ? void 0 : o.instance) ?? c.sourceNode ?? c.id,
1759
- declIndex: d,
1760
- ...typeof c.sourceDocument == "string" ? { sourceDocument: c.sourceDocument } : {},
1761
- ...c.sourceDocumentFrom === void 0 ? {} : { sourceDocumentFrom: c.sourceDocumentFrom }
2232
+ node: ((d = g.derived) == null ? void 0 : d.instance) ?? g.sourceNode ?? g.id,
2233
+ declIndex: l,
2234
+ ...typeof g.sourceDocument == "string" ? { sourceDocument: g.sourceDocument } : {},
2235
+ ...g.sourceDocumentFrom === void 0 ? {} : { sourceDocumentFrom: g.sourceDocumentFrom }
1762
2236
  },
1763
2237
  1,
1764
- rn
2238
+ Sn
1765
2239
  );
1766
2240
  });
1767
2241
  }
1768
2242
  return i;
1769
2243
  }
1770
- function Qe(e) {
2244
+ function dt(e) {
1771
2245
  const n = /* @__PURE__ */ new Map();
1772
2246
  for (const t of e) {
1773
2247
  const s = n.get(t.property);
@@ -1779,100 +2253,124 @@ function Qe(e) {
1779
2253
  t.rank > s.rank && n.set(t.property, t);
1780
2254
  continue;
1781
2255
  }
1782
- const i = Ye(t.specificity, s.specificity);
1783
- (i > 0 || i === 0 && t.order > s.order) && n.set(t.property, t);
2256
+ const o = lt(t.specificity, s.specificity);
2257
+ (o > 0 || o === 0 && t.order > s.order) && n.set(t.property, t);
1784
2258
  }
1785
2259
  for (const t of n.values()) t.winner = !0;
1786
2260
  return n;
1787
2261
  }
1788
- const pn = /var\(\s*(--[^,)\s]+)\s*(?:,([^)]*))?\)/;
1789
- function fe(e, n, t = /* @__PURE__ */ new Set()) {
1790
- var i;
2262
+ const Cn = /var\(\s*(--[^,)\s]+)\s*(?:,([^)]*))?\)/;
2263
+ function Se(e, n, t = /* @__PURE__ */ new Set()) {
2264
+ var o;
1791
2265
  let s = e;
1792
- for (let r = 0; r < 32; r++) {
1793
- const u = pn.exec(s);
1794
- if (u === null) return s;
1795
- const c = u[1], v = (i = u[2]) == null ? void 0 : i.trim();
1796
- if (t.has(c)) return null;
1797
- const d = /* @__PURE__ */ new Set([...t, c]), o = n.get(c), a = o !== void 0 ? fe(o, n, d) : v !== void 0 && v.length > 0 ? fe(v, n, d) : null;
1798
- if (a === null) return null;
1799
- s = s.slice(0, u.index) + a + s.slice(u.index + u[0].length);
2266
+ for (let i = 0; i < 32; i++) {
2267
+ const c = Cn.exec(s);
2268
+ if (c === null) return s;
2269
+ const u = c[1], g = (o = c[2]) == null ? void 0 : o.trim();
2270
+ if (t.has(u)) return null;
2271
+ const p = /* @__PURE__ */ new Set([...t, u]), l = n.get(u), d = l !== void 0 ? Se(l, n, p) : g !== void 0 && g.length > 0 ? Se(g, n, p) : null;
2272
+ if (d === null) return null;
2273
+ s = s.slice(0, c.index) + d + s.slice(c.index + c[0].length);
1800
2274
  }
1801
2275
  return null;
1802
2276
  }
1803
- function hn(e, n) {
1804
- const t = Ke(e, n), s = [...t.warnings], i = /* @__PURE__ */ new Map();
1805
- let r = !1;
1806
- const u = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set(), v = (o, a, f) => {
1807
- const l = Ze(e, o, t, c);
1808
- !r && l.some((m) => m.origin.kind === "builtin-theme") && (r = !0);
1809
- const h = Qe(l), g = /* @__PURE__ */ new Map();
1810
- for (const [m, y] of a)
1811
- m.startsWith("--") && g.set(m, y.value);
1812
- for (const [m, y] of h)
1813
- m.startsWith("--") && g.set(m, y.value);
1814
- const p = /* @__PURE__ */ new Map();
1815
- for (const [m, y] of a) p.set(m, y);
1816
- for (const [m, y] of h) {
1817
- const k = fe(y.value, g);
1818
- if (k === null) {
2277
+ function Rn(e, n) {
2278
+ const t = ct(e, n), s = [...t.warnings], o = /* @__PURE__ */ new Map();
2279
+ let i = !1;
2280
+ const c = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Map(), p = (a, b, r) => {
2281
+ const w = ut(e, a, t, u, g);
2282
+ !i && w.some((v) => v.origin.kind === "builtin-theme") && (i = !0);
2283
+ const y = dt(w), h = /* @__PURE__ */ new Map();
2284
+ for (const [v, S] of b)
2285
+ v.startsWith("--") && h.set(v, S.value);
2286
+ for (const [v, S] of y)
2287
+ v.startsWith("--") && h.set(v, S.value);
2288
+ const f = /* @__PURE__ */ new Map();
2289
+ for (const [v, S] of b) f.set(v, S);
2290
+ for (const [v, S] of y) {
2291
+ const E = Se(S.value, h);
2292
+ if (E === null) {
1819
2293
  s.push({
1820
2294
  kind: "unsupported-property",
1821
- message: `${m}: var() reference could not be resolved; declaration dropped`,
1822
- node: f
2295
+ message: `${v}: var() reference could not be resolved; declaration dropped`,
2296
+ node: r,
2297
+ reason: "invalid-value",
2298
+ subject: { kind: "property", property: v, value: S.value }
1823
2299
  });
1824
2300
  continue;
1825
2301
  }
1826
- p.set(m, { value: k, origin: y.origin });
2302
+ f.set(v, { value: E, origin: S.origin });
1827
2303
  }
1828
- const b = /* @__PURE__ */ new Map();
1829
- for (const [m, y] of p)
1830
- Dt(m) && b.set(m, {
1831
- value: y.value,
1832
- origin: { kind: "inherited", from: f, origin: y.origin }
2304
+ const k = /* @__PURE__ */ new Map();
2305
+ for (const [v, S] of f)
2306
+ Gt(v) && k.set(v, {
2307
+ value: S.value,
2308
+ origin: { kind: "inherited", from: r, origin: S.origin }
1833
2309
  });
1834
- return { computed: p, forChildren: b };
1835
- }, d = (o, a) => {
1836
- const f = v({ kind: "element", node: o }, a, o.id);
1837
- i.set(o.id, f.computed);
1838
- let l = f.forChildren;
1839
- const h = H(o).spec.parts;
1840
- if (h.length > 0) {
1841
- const g = /* @__PURE__ */ new Map();
1842
- h.forEach((p, b) => {
1843
- const m = v(
1844
- { kind: "part", owner: o, name: p.name, depth: b },
1845
- l,
1846
- o.id
2310
+ return { computed: f, forChildren: k };
2311
+ }, l = /* @__PURE__ */ new Set(), d = (a) => {
2312
+ var w;
2313
+ const b = ((w = a.derived) == null ? void 0 : w.instance) ?? a.sourceNode ?? a.id, r = typeof a.sourceDocument == "string" ? a.sourceDocument : null;
2314
+ Ie(e, a).forEach((y, h) => {
2315
+ const f = tt(y.property, y.value);
2316
+ if (f === null) return;
2317
+ const k = `${a.sourceDocument ?? ""}#${b}#${h}`;
2318
+ l.has(k) || (l.add(k), s.push({
2319
+ kind: "unsupported-property",
2320
+ ...f,
2321
+ node: a.id,
2322
+ // A span is only meaningful in the entry document's own text; a
2323
+ // template's declaration names its file instead.
2324
+ ...r !== null ? { sourceDocument: r } : { at: { in: "uxml", span: y.span } }
2325
+ }));
2326
+ });
2327
+ }, m = (a, b) => {
2328
+ d(a);
2329
+ const r = p({ kind: "element", node: a }, b, a.id);
2330
+ o.set(a.id, r.computed);
2331
+ let w = r.forChildren;
2332
+ const y = X(a).spec.parts;
2333
+ if (y.length > 0) {
2334
+ const h = /* @__PURE__ */ new Map();
2335
+ y.forEach((f, k) => {
2336
+ const v = p(
2337
+ { kind: "part", owner: a, name: f.name, depth: k },
2338
+ w,
2339
+ a.id
1847
2340
  );
1848
- g.set(p.name, m.computed), l = m.forChildren;
1849
- }), u.set(o.id, g);
2341
+ h.set(f.name, v.computed), w = v.forChildren;
2342
+ }), c.set(a.id, h);
1850
2343
  }
1851
- for (const g of o.children) d(g, l);
2344
+ for (const h of a.children) m(h, w);
1852
2345
  };
1853
- d(e.root, /* @__PURE__ */ new Map()), r && s.push({
2346
+ m(e.root, /* @__PURE__ */ new Map()), i && s.push({
1854
2347
  kind: "version-dependent",
1855
- message: `Unity's control defaults were applied, as measured on ${Z} (Unity ships these as a theme stylesheet). Other versions may use different values; see src/controls/theme.ts.`
2348
+ message: `Built-in control defaults applied, as measured on Unity ${ae}`,
2349
+ reason: "version-dependent"
1856
2350
  });
1857
- for (const o of t.usable) {
1858
- if (o.builtin === !0 || c.has(o)) continue;
1859
- const a = tn(o.rule.selectors);
1860
- a.length !== 0 && s.push({
2351
+ for (const a of t.usable) {
2352
+ if (a.builtin === !0 || u.has(a)) continue;
2353
+ const b = wn(a.rule.selectors);
2354
+ b.length !== 0 && s.push({
1861
2355
  kind: "unsupported-selector",
1862
- message: `${a.join(", ")} matched nothing. Those names belong to the elements a control builds for itself, and only controls with a renderer of their own have them — ${Tt().join(", ")}. Anything else is drawn as a plain box and has no parts to style.`,
1863
- at: { in: "uss", sheet: o.sheet, span: o.rule.selectorSpan },
1864
- ...de(e, o.sheet)
2356
+ message: `${b.join(", ")} matched nothing; only ${kt().join(", ")} are drawn with the parts these names refer to`,
2357
+ at: { in: "uss", sheet: a.sheet, ...Y(e, a.sheet), span: a.rule.selectorSpan },
2358
+ reason: "not-rendered",
2359
+ subject: { kind: "selector", selector: re(e, a), fragment: b.join(", ") },
2360
+ ...G(e, a.sheet)
1865
2361
  });
1866
2362
  }
1867
- return { styles: i, partStyles: u, warnings: s };
2363
+ for (const [a, b] of t.declarationWarnings)
2364
+ a.nodes = g.get(b) ?? [];
2365
+ return { styles: o, partStyles: c, warnings: s, matchedNodes: g };
1868
2366
  }
1869
- function Sn(e, n, t, s) {
1870
- const i = Ke(e, s), r = Ze(e, { kind: "element", node: n }, i).filter(
1871
- (u) => u.property === t
2367
+ function Bn(e, n, t, s) {
2368
+ const o = ct(e, s), i = ut(e, { kind: "element", node: n }, o).filter(
2369
+ (c) => c.property === t
1872
2370
  );
1873
- return Qe(r), r;
2371
+ return dt(i), i;
1874
2372
  }
1875
- const $n = [
2373
+ const Hn = [
1876
2374
  {
1877
2375
  id: "text-metrics",
1878
2376
  kind: "unreproducible",
@@ -1892,226 +2390,341 @@ const $n = [
1892
2390
  detail: "The yoga-layout version this package depends on resolves a main-axis percentage against an indefinite parent differently from the Yoga vendored inside Unity 6000.0.40f1. Not configurable: no available setting reproduces Unity's answer without breaking cases that currently match. Fully deterministic and pinned to a case in docs/accuracy.md — this always reproduces the same way, it just cannot be fixed from inside this repository."
1893
2391
  }
1894
2392
  ];
1895
- function mn(e, n) {
1896
- const t = (d) => e.slice(d.start, d.end);
1897
- function s(d) {
1898
- return d.spans.closeTag !== null ? d.spans.closeTag.end : Math.max(d.spans.openTag.end, d.spans.inner.end);
1899
- }
1900
- function i(d) {
1901
- return d.includes('"') ? d.includes("'") ? `"${d.replace(/"/g, "&quot;")}"` : `'${d}'` : `"${d}"`;
1902
- }
1903
- function r(d) {
1904
- const o = d.attributes.map((f) => ` ${f.name}=${i(f.value)}`).join(""), a = Ce(d.name);
1905
- return d.spans.closeTag === null ? `<${a}${o} />` : `<${a}${o}>`;
1906
- }
1907
- function u(d) {
1908
- var l, h;
1909
- const o = t(d.spans.inner), a = ((l = /^[ \t]*\r?\n[ \t]*/.exec(o)) == null ? void 0 : l[0]) ?? "", f = ((h = /\r?\n[ \t]*$/.exec(o)) == null ? void 0 : h[0]) ?? "";
1910
- return { between: a, before: a, after: f };
1911
- }
1912
- function c(d) {
1913
- const { inner: o } = d.spans;
1914
- if (d.children.length === 0) return t(o);
1915
- if (d.childrenDirty) {
1916
- const { between: l, before: h, after: g } = u(d);
1917
- return h + d.children.map(v).join(l) + g;
1918
- }
1919
- let a = "", f = o.start;
1920
- for (const l of d.children)
1921
- a += e.slice(f, l.spans.openTag.start), a += v(l), f = s(l);
1922
- return a + e.slice(f, o.end);
1923
- }
1924
- function v(d) {
1925
- const o = d.tagDirty ? r(d) : t(d.spans.openTag), a = d.spans.closeTag === null ? "" : t(d.spans.closeTag);
1926
- return o + c(d) + a;
1927
- }
1928
- return e.slice(0, n.spans.openTag.start) + v(n) + e.slice(s(n));
1929
- }
1930
- function gn(e) {
1931
- const n = e.source, t = (o) => n.slice(o.start, o.end);
1932
- function s(o) {
1933
- return o.parts.map((a, f) => {
1934
- const l = f === 0 ? "" : a.combinator === "child" ? " > " : " ", h = a.simple.map((g) => {
1935
- switch (g.kind) {
2393
+ function jn(e, n) {
2394
+ const t = (p) => e.slice(p.start, p.end);
2395
+ function s(p) {
2396
+ return p.spans.closeTag !== null ? p.spans.closeTag.end : Math.max(p.spans.openTag.end, p.spans.inner.end);
2397
+ }
2398
+ function o(p) {
2399
+ return p.includes('"') ? p.includes("'") ? `"${p.replace(/"/g, "&quot;")}"` : `'${p}'` : `"${p}"`;
2400
+ }
2401
+ function i(p) {
2402
+ const l = p.attributes.map((m) => ` ${m.name}=${o(m.value)}`).join(""), d = _e(p.name);
2403
+ return p.spans.closeTag === null ? `<${d}${l} />` : `<${d}${l}>`;
2404
+ }
2405
+ function c(p) {
2406
+ var a, b;
2407
+ const l = t(p.spans.inner), d = ((a = /^[ \t]*\r?\n[ \t]*/.exec(l)) == null ? void 0 : a[0]) ?? "", m = ((b = /\r?\n[ \t]*$/.exec(l)) == null ? void 0 : b[0]) ?? "";
2408
+ return { between: d, before: d, after: m };
2409
+ }
2410
+ function u(p) {
2411
+ const { inner: l } = p.spans;
2412
+ if (p.children.length === 0) return t(l);
2413
+ if (p.childrenDirty) {
2414
+ const { between: a, before: b, after: r } = c(p);
2415
+ return b + p.children.map(g).join(a) + r;
2416
+ }
2417
+ let d = "", m = l.start;
2418
+ for (const a of p.children)
2419
+ d += e.slice(m, a.spans.openTag.start), d += g(a), m = s(a);
2420
+ return d + e.slice(m, l.end);
2421
+ }
2422
+ function g(p) {
2423
+ const l = p.tagDirty ? i(p) : t(p.spans.openTag), d = p.spans.closeTag === null ? "" : t(p.spans.closeTag);
2424
+ return l + u(p) + d;
2425
+ }
2426
+ return e.slice(0, n.spans.openTag.start) + g(n) + e.slice(s(n));
2427
+ }
2428
+ function Nn(e) {
2429
+ const n = e.source, t = (l) => n.slice(l.start, l.end);
2430
+ function s(l) {
2431
+ return l.parts.map((d, m) => {
2432
+ const a = m === 0 ? "" : d.combinator === "child" ? " > " : " ", b = d.simple.map((r) => {
2433
+ switch (r.kind) {
1936
2434
  case "universal":
1937
2435
  return "*";
1938
2436
  case "type":
1939
- return g.name;
2437
+ return r.name;
1940
2438
  case "class":
1941
- return `.${g.name}`;
2439
+ return `.${r.name}`;
1942
2440
  case "name":
1943
- return `#${g.name}`;
2441
+ return `#${r.name}`;
1944
2442
  case "pseudo":
1945
- return `:${g.name}`;
2443
+ return `:${r.name}`;
1946
2444
  case "unknown":
1947
- return g.text;
2445
+ return r.text;
1948
2446
  }
1949
2447
  }).join("");
1950
- return l + h;
2448
+ return a + b;
1951
2449
  }).join("");
1952
2450
  }
1953
- function i(o) {
1954
- var p, b;
1955
- const a = o.declarations[0];
1956
- if (a === void 0) return { between: "", before: "", after: "" };
1957
- const f = n.lastIndexOf(`
1958
- `, a.span.start), l = f < 0 ? "" : n.slice(f, a.span.start), h = n.slice(o.selectorSpan.end, o.span.end), g = ((b = (p = /\r?\n[ \t]*\}$/.exec(h)) == null ? void 0 : p[0]) == null ? void 0 : b.replace(/\}$/, "")) ?? "";
1959
- return { between: `;${l}`, before: l, after: `;${g}` };
1960
- }
1961
- function r(o) {
1962
- const a = o.selectorDirty ? o.selectors.map(s).join(", ") : t(o.selectorSpan);
1963
- if (o.declarations.length === 0)
1964
- return a + n.slice(o.selectorSpan.end, o.span.end);
1965
- const f = n.slice(o.selectorSpan.end, o.declarations[0].span.start);
1966
- if (o.declarationsDirty) {
1967
- const { between: g, before: p, after: b } = i(o), m = f.slice(0, f.indexOf("{") + 1), y = o.declarations.map(u).join(g);
1968
- return `${a}${m}${p}${y}${b}}`;
1969
- }
1970
- let l = a, h = o.selectorSpan.end;
1971
- for (const g of o.declarations)
1972
- l += n.slice(h, g.span.start), l += u(g), h = g.span.end;
1973
- return l + n.slice(h, o.span.end);
1974
- }
1975
- function u(o) {
1976
- return o.dirty ? `${o.property}: ${o.value}` : t(o.span);
1977
- }
1978
- function c(o) {
1979
- return o.kind === "rule" ? r(o.rule) : t(o.span);
1980
- }
1981
- let v = "", d = 0;
1982
- for (const o of e.items) {
1983
- const a = o.kind === "rule" ? o.rule.span : o.span;
1984
- v += n.slice(d, a.start), v += c(o), d = a.end;
1985
- }
1986
- return v + n.slice(d);
1987
- }
1988
- ot(
1989
- (e, n) => n === void 0 ? Ie(e) : Ie(e, void 0, { resolveImport: n })
2451
+ function o(l) {
2452
+ var w, y;
2453
+ const d = l.declarations[0];
2454
+ if (d === void 0) return { between: "", before: "", after: "" };
2455
+ const m = n.lastIndexOf(`
2456
+ `, d.span.start), a = m < 0 ? "" : n.slice(m, d.span.start), b = n.slice(l.selectorSpan.end, l.span.end), r = ((y = (w = /\r?\n[ \t]*\}$/.exec(b)) == null ? void 0 : w[0]) == null ? void 0 : y.replace(/\}$/, "")) ?? "";
2457
+ return { between: `;${a}`, before: a, after: `;${r}` };
2458
+ }
2459
+ function i(l) {
2460
+ const d = l.selectorDirty ? l.selectors.map(s).join(", ") : t(l.selectorSpan);
2461
+ if (l.declarations.length === 0)
2462
+ return d + n.slice(l.selectorSpan.end, l.span.end);
2463
+ const m = n.slice(l.selectorSpan.end, l.declarations[0].span.start);
2464
+ if (l.declarationsDirty) {
2465
+ const { between: r, before: w, after: y } = o(l), h = m.slice(0, m.indexOf("{") + 1), f = l.declarations.map(c).join(r);
2466
+ return `${d}${h}${w}${f}${y}}`;
2467
+ }
2468
+ let a = d, b = l.selectorSpan.end;
2469
+ for (const r of l.declarations)
2470
+ a += n.slice(b, r.span.start), a += c(r), b = r.span.end;
2471
+ return a + n.slice(b, l.span.end);
2472
+ }
2473
+ function c(l) {
2474
+ return l.dirty ? `${l.property}: ${l.value}` : t(l.span);
2475
+ }
2476
+ function u(l) {
2477
+ return l.kind === "rule" ? i(l.rule) : t(l.span);
2478
+ }
2479
+ let g = "", p = 0;
2480
+ for (const l of e.items) {
2481
+ const d = l.kind === "rule" ? l.rule.span : l.span;
2482
+ g += n.slice(p, d.start), g += u(l), p = d.end;
2483
+ }
2484
+ return g + n.slice(p);
2485
+ }
2486
+ function An(e, n, t, s) {
2487
+ const o = /* @__PURE__ */ new Map();
2488
+ if (s === void 0) return { fonts: o, warnings: [...n] };
2489
+ const i = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), u = (p, l, d) => {
2490
+ for (; l.kind === "inherited"; ) l = l.origin;
2491
+ const m = t(l);
2492
+ return JSON.stringify([
2493
+ p,
2494
+ m.sourceDocument,
2495
+ m.at,
2496
+ m.at === void 0 ? l.kind === "inline" ? l.node : d : null
2497
+ ]);
2498
+ };
2499
+ for (const [p, l] of e)
2500
+ for (const d of ["-unity-font", "-unity-font-definition"]) {
2501
+ const m = l.get(d);
2502
+ if (m === void 0) continue;
2503
+ const a = st(m.value);
2504
+ if (a === null) continue;
2505
+ const b = JSON.stringify([a.path, a.form]);
2506
+ if (!i.has(b)) {
2507
+ const h = s(a.path, a.form);
2508
+ i.set(b, typeof h == "string" ? { family: h } : h);
2509
+ }
2510
+ const r = i.get(b);
2511
+ let w = m.origin;
2512
+ for (; w.kind === "inherited"; ) w = w.origin;
2513
+ const y = u(d, w, p);
2514
+ c.has(y) || c.set(y, r === null ? {
2515
+ kind: "asset-unresolved",
2516
+ message: `${d}: "${a.path}" was not resolved`,
2517
+ node: w.kind === "inline" ? w.node : p,
2518
+ subject: { kind: "asset", ...a, role: "font" },
2519
+ ...t(w)
2520
+ } : null), d === "-unity-font-definition" && o.delete(l), r !== null && o.set(l, r);
2521
+ }
2522
+ const g = n.filter((p) => {
2523
+ var d;
2524
+ if (p.reason !== "not-rendered" || ((d = p.subject) == null ? void 0 : d.kind) !== "property") return !0;
2525
+ const l = JSON.stringify([
2526
+ p.subject.property,
2527
+ p.sourceDocument,
2528
+ p.at,
2529
+ p.at === void 0 ? p.node : null
2530
+ ]);
2531
+ return !c.has(l);
2532
+ });
2533
+ return { fonts: o, warnings: [...g, ...[...c.values()].filter((p) => p !== null)] };
2534
+ }
2535
+ function Vn(e) {
2536
+ const n = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), s = (c) => {
2537
+ n.set(c.id, c);
2538
+ for (const u of c.children)
2539
+ t.set(u.id, c.id), s(u);
2540
+ };
2541
+ e.document !== void 0 && s(e.document.root);
2542
+ const o = /* @__PURE__ */ new Map(), i = (c) => {
2543
+ var p, l, d, m;
2544
+ const u = o.get(c);
2545
+ if (u !== void 0) return u;
2546
+ let g;
2547
+ for (let a = c; a !== void 0; a = t.get(a)) {
2548
+ const b = (l = (p = e.styles) == null ? void 0 : p.get(a)) == null ? void 0 : l.get("display");
2549
+ if ((b == null ? void 0 : b.value) === "none") {
2550
+ g = { kind: "hidden", by: a, origin: b.origin };
2551
+ break;
2552
+ }
2553
+ }
2554
+ if (g === void 0) {
2555
+ const a = e.boxes.get(c);
2556
+ if (a.width === 0 || a.height === 0) {
2557
+ const b = (d = e.styles) == null ? void 0 : d.get(c), r = ["width", "height"].some((y) => {
2558
+ var h;
2559
+ return /^-?0+(\.0+)?(px|%)?$/.test(((h = b == null ? void 0 : b.get(y)) == null ? void 0 : h.value) ?? "");
2560
+ }), w = ((m = n.get(c)) == null ? void 0 : m.children.filter((y) => e.boxes.has(y.id))) ?? [];
2561
+ g = !r && w.length > 0 && w.every((y) => {
2562
+ const h = i(y.id).kind;
2563
+ return h === "hidden" || h === "emptied";
2564
+ }) ? { kind: "emptied" } : { kind: "collapsed", explicitZero: r };
2565
+ } else g = { kind: "shown" };
2566
+ }
2567
+ return o.set(c, g), g;
2568
+ };
2569
+ for (const c of e.boxes.keys()) i(c);
2570
+ return o;
2571
+ }
2572
+ St(
2573
+ (e, n) => n === void 0 ? Fe(e) : Fe(e, void 0, { resolveImport: n })
1990
2574
  );
1991
- function et(e, n = []) {
2575
+ function ft(e, n = []) {
1992
2576
  var t;
1993
2577
  for (const s of e.children) {
1994
2578
  if (s.name.local === "Style") {
1995
- const i = (t = s.attributes.find((r) => r.name === "src")) == null ? void 0 : t.value;
1996
- i !== void 0 && i.length > 0 && n.push({ url: J(i), scope: e.id });
2579
+ const o = (t = s.attributes.find((i) => i.name === "src")) == null ? void 0 : t.value;
2580
+ o !== void 0 && o.length > 0 && n.push({ url: Z(o), scope: e.id });
1997
2581
  }
1998
- et(s, n);
2582
+ ft(s, n);
1999
2583
  }
2000
2584
  return n;
2001
2585
  }
2002
- function wn(e) {
2586
+ function Ln(e) {
2003
2587
  return e.startsWith("project://") || e.startsWith("/");
2004
2588
  }
2005
- function Ie(e, n, t) {
2006
- var d, o;
2007
- const s = Re(e), i = [...s.warnings], r = [], u = [], c = [];
2008
- for (const { url: a, scope: f } of et(s.root)) {
2009
- const l = ((d = t == null ? void 0 : t.resolveImport) == null ? void 0 : d.call(t, a, null)) ?? null;
2010
- if (l === null) {
2011
- i.push({
2589
+ function Fe(e, n, t) {
2590
+ var p, l, d;
2591
+ const s = We(e), o = [...s.warnings], i = [], c = [], u = [];
2592
+ for (const { url: m, scope: a } of ft(s.root)) {
2593
+ const b = ((p = t == null ? void 0 : t.resolveImport) == null ? void 0 : p.call(t, m, null)) ?? null;
2594
+ if (b === null) {
2595
+ o.push({
2012
2596
  kind: "import-unresolved",
2013
- message: (t == null ? void 0 : t.resolveImport) === void 0 ? `<Style src="${a}"> was not loaded: pass resolveImport to read it, or pass the stylesheet text directly. Until then this document renders unstyled.` : `<Style src="${a}"> could not be resolved`,
2014
- node: s.root.id
2597
+ message: (t == null ? void 0 : t.resolveImport) === void 0 ? `<Style src="${m}"> was not loaded: pass resolveImport to read it, or pass the stylesheet text directly. Until then this document renders unstyled.` : `<Style src="${m}"> could not be resolved`,
2598
+ node: s.root.id,
2599
+ subject: { kind: "import", url: m, from: null }
2015
2600
  });
2016
2601
  continue;
2017
2602
  }
2018
- c.push({ text: l, origin: a, scope: f });
2019
- }
2020
- if (n !== void 0 || c.length > 0) {
2021
- const a = /* @__PURE__ */ new Map(), f = [];
2022
- let l = 0;
2023
- for (const h of c) {
2024
- const g = l++;
2025
- f.push({ text: h.text, origin: h.origin, sheet: g }), u.push({ sheet: g, scope: h.scope });
2603
+ u.push({ text: b, origin: m, scope: a });
2604
+ }
2605
+ if (n !== void 0 || u.length > 0) {
2606
+ const m = /* @__PURE__ */ new Map(), a = [];
2607
+ let b = 0;
2608
+ for (const r of u) {
2609
+ const w = b++;
2610
+ a.push({ text: r.text, origin: r.origin, sheet: w }), c.push({ sheet: w, scope: r.scope });
2026
2611
  }
2027
2612
  if (n !== void 0) {
2028
- const h = l++;
2029
- f.push({ text: n, origin: null, sheet: h }), u.push({ sheet: h, scope: s.root.id });
2030
- }
2031
- for (; f.length > 0; ) {
2032
- const h = f.shift(), g = h.sheet, p = ge(h.text, h.origin, g);
2033
- r.push(p.sheet), i.push(...p.warnings);
2034
- for (const b of p.sheet.items) {
2035
- if (b.kind !== "import") continue;
2036
- const m = wn(b.url) ? b.url : JSON.stringify([b.url, h.origin]);
2037
- if (a.has(m)) {
2038
- const x = a.get(m);
2039
- x != null && (b.resolvedSheet = x);
2613
+ const r = b++;
2614
+ a.push({ text: n, origin: null, sheet: r }), c.push({ sheet: r, scope: s.root.id });
2615
+ }
2616
+ for (; a.length > 0; ) {
2617
+ const r = a.shift(), w = r.sheet, y = Oe(r.text, r.origin, w);
2618
+ i.push(y.sheet), o.push(...y.warnings);
2619
+ for (const h of y.sheet.items) {
2620
+ if (h.kind !== "import") continue;
2621
+ const f = Ln(h.url) ? h.url : JSON.stringify([h.url, r.origin]);
2622
+ if (m.has(f)) {
2623
+ const S = m.get(f);
2624
+ S != null && (h.resolvedSheet = S);
2040
2625
  continue;
2041
2626
  }
2042
- a.set(m, null);
2043
- const y = ((o = t == null ? void 0 : t.resolveImport) == null ? void 0 : o.call(t, b.url, h.origin)) ?? null;
2044
- if (y === null) {
2045
- i.push({
2627
+ m.set(f, null);
2628
+ const k = ((l = t == null ? void 0 : t.resolveImport) == null ? void 0 : l.call(t, h.url, r.origin)) ?? null;
2629
+ if (k === null) {
2630
+ o.push({
2046
2631
  kind: "import-unresolved",
2047
- message: (t == null ? void 0 : t.resolveImport) === void 0 ? `@import "${b.url}" was not loaded: pass resolveImport to read it` : `@import "${b.url}" could not be resolved`,
2048
- at: { in: "uss", sheet: g, span: b.span }
2632
+ message: (t == null ? void 0 : t.resolveImport) === void 0 ? `@import "${h.url}" was not loaded: pass resolveImport to read it` : `@import "${h.url}" could not be resolved`,
2633
+ at: { in: "uss", sheet: w, span: h.span },
2634
+ subject: { kind: "import", url: h.url, from: r.origin }
2049
2635
  });
2050
2636
  continue;
2051
2637
  }
2052
- const k = l++;
2053
- a.set(m, k), b.resolvedSheet = k, f.push({ text: y, origin: b.url, sheet: k });
2638
+ const v = b++;
2639
+ m.set(f, v), h.resolvedSheet = v, a.push({ text: k, origin: h.url, sheet: v });
2054
2640
  }
2055
2641
  }
2056
2642
  }
2057
- const v = { source: e, root: s.root, sheets: r, styleRoots: u, warnings: i };
2058
- return lt(v, t == null ? void 0 : t.resolveImport), v;
2643
+ const g = { source: e, root: s.root, sheets: i, styleRoots: c, warnings: o };
2644
+ for (const m of o)
2645
+ ((d = m.at) == null ? void 0 : d.in) === "uss" && Object.assign(m.at, Y(g, m.at.sheet));
2646
+ return $t(g, t == null ? void 0 : t.resolveImport), g;
2059
2647
  }
2060
- function Tn(e) {
2648
+ function qn(e) {
2061
2649
  const n = e.sheets[0];
2062
2650
  return {
2063
- uxml: mn(e.source, e.root),
2651
+ uxml: jn(e.source, e.root),
2064
2652
  // Only the sheet passed to `parse` round-trips. `@import`ed sheets (Phase 3)
2065
2653
  // are separate files and are not this function's to write.
2066
- uss: n === void 0 ? "" : gn(n)
2654
+ uss: n === void 0 ? "" : Nn(n)
2067
2655
  };
2068
2656
  }
2069
- function On(e, n, t) {
2070
- const s = n.ownerDocument, i = (t == null ? void 0 : t.size) ?? {
2657
+ function Un(e) {
2658
+ const n = /* @__PURE__ */ new Map(), t = [];
2659
+ for (const s of e) {
2660
+ const o = { ...s }, i = o.at === void 0 ? void 0 : JSON.stringify([o.kind, o.message, o.sourceDocument ?? null, o.at]);
2661
+ (i === void 0 ? void 0 : n.get(i)) === void 0 && (i !== void 0 && n.set(i, o), t.push(o));
2662
+ }
2663
+ return t;
2664
+ }
2665
+ function Yn(e, n, t) {
2666
+ const s = n.ownerDocument, o = (t == null ? void 0 : t.size) ?? {
2071
2667
  width: n.clientWidth,
2072
2668
  height: n.clientHeight
2073
- }, r = bt(e), u = r.document, c = hn(u, {
2669
+ }, i = Lt(e), c = i.document, u = Rn(c, {
2074
2670
  ...(t == null ? void 0 : t.activeStates) === void 0 ? {} : { activeStates: t.activeStates },
2075
2671
  ...(t == null ? void 0 : t.states) === void 0 ? {} : { states: t.states }
2076
- }), v = (t == null ? void 0 : t.measureText) ?? jt(s), d = zt(u.root, c.styles, c.partStyles, {
2077
- size: i,
2078
- measureText: v
2672
+ }), g = (t == null ? void 0 : t.measureText) ?? ln(s), p = Mn(c, u.matchedNodes), l = An(u.styles, u.warnings, p, t == null ? void 0 : t.resolveFont), d = on(c.root, u.styles, u.partStyles, {
2673
+ size: o,
2674
+ measureText: g,
2675
+ fonts: l.fonts,
2676
+ locate: p
2079
2677
  });
2080
- let o;
2678
+ let m;
2081
2679
  try {
2082
- o = Yt(u.root, d.boxes, d.parts, c.styles, n, {
2680
+ m = gn(c.root, d.boxes, d.parts, u.styles, n, {
2083
2681
  document: s,
2084
- resolveAsset: t == null ? void 0 : t.resolveAsset
2682
+ fonts: l.fonts,
2683
+ resolveAsset: t == null ? void 0 : t.resolveAsset,
2684
+ locate: p
2085
2685
  });
2086
- } catch (f) {
2087
- throw d.dispose(), f;
2686
+ } catch (b) {
2687
+ throw d.dispose(), b;
2088
2688
  }
2089
2689
  let a = !1;
2090
2690
  return {
2091
- warnings: [...r.warnings, ...c.warnings, ...d.warnings, ...o.warnings],
2092
- elements: o.elements,
2691
+ warnings: Un([
2692
+ ...i.warnings,
2693
+ ...l.warnings,
2694
+ ...d.warnings,
2695
+ ...m.warnings
2696
+ ]),
2697
+ elements: m.elements,
2093
2698
  boxes: d.boxes,
2699
+ document: c,
2700
+ styles: u.styles,
2701
+ partStyles: u.partStyles,
2094
2702
  dispose() {
2095
2703
  a || (a = !0, d.dispose(), n.replaceChildren());
2096
2704
  }
2097
2705
  };
2098
2706
  }
2099
2707
  export {
2100
- $n as KNOWN_DIVERGENCES,
2101
- Gt as NODE_ATTRIBUTE,
2102
- Jt as PART_ATTRIBUTE,
2103
- Xt as PART_OWNER_ATTRIBUTE,
2104
- bn as collectDependencies,
2105
- jt as createDefaultMeasureText,
2106
- bt as expandTemplates,
2107
- Sn as explainProperty,
2108
- Dt as isInherited,
2109
- xn as isLayoutEngineReady,
2110
- kn as liveNodeCount,
2111
- yn as loadLayoutEngine,
2112
- Ie as parse,
2113
- On as render,
2114
- hn as resolveStyles,
2115
- Tn as serialize,
2116
- Tt as supportedControlNames
2708
+ rn as EDITOR_DEFAULT_FACE_INFO,
2709
+ Hn as KNOWN_DIVERGENCES,
2710
+ pn as NODE_ATTRIBUTE,
2711
+ hn as PART_ATTRIBUTE,
2712
+ mn as PART_OWNER_ATTRIBUTE,
2713
+ Re as TEMPLATE_DEPTH_LIMIT,
2714
+ be as USS_STATES,
2715
+ Vn as classifyVisibility,
2716
+ Fn as collectDependencies,
2717
+ ln as createDefaultMeasureText,
2718
+ Lt as expandTemplates,
2719
+ Bn as explainProperty,
2720
+ Gt as isInherited,
2721
+ Wn as isLayoutEngineReady,
2722
+ _n as liveNodeCount,
2723
+ Pn as loadLayoutEngine,
2724
+ Fe as parse,
2725
+ Yn as render,
2726
+ Rn as resolveStyles,
2727
+ qn as serialize,
2728
+ kt as supportedControlNames,
2729
+ an as textHeight
2117
2730
  };