@umriss-ui/calculation 0.6.1 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,242 +1,242 @@
1
1
  import "./calculation.css";
2
- import { jsx as g, jsxs as P } from "react/jsx-runtime";
3
- import { Children as qe, isValidElement as z, Fragment as xe, useId as ke, useState as re, useRef as Me, useCallback as Te, useLayoutEffect as Ee, useEffect as Ae } from "react";
4
- import { assess as Re, verdictWeight as se, useFormats as Ne, useWording as Oe, VisuallyHidden as Ie, AngleGlyph as Pe, Badge as le, useFreshness as je, Tooltip as De } from "@umriss-ui/core";
5
- function Be(t) {
2
+ import { jsx as b, jsxs as R } from "react/jsx-runtime";
3
+ import { Children as ke, isValidElement as K, Fragment as Me, useId as Te, useState as re, useRef as Ee, useCallback as Ae, useLayoutEffect as Re, useEffect as De } from "react";
4
+ import { assess as Ie, verdictWeight as oe, useDensityFor as Pe, useFormats as Oe, useWording as Se, VisuallyHidden as je, AngleGlyph as Be, Badge as le, useFreshness as Le, Tooltip as Fe } from "@umriss-ui/core";
5
+ function We(t) {
6
6
  return t.decimals !== void 0 ? t.decimals : t.format === "percent" ? 1 : t.given ? void 0 : 2;
7
7
  }
8
- function Le(t, e) {
8
+ function Ue(t, e) {
9
9
  return e === void 0 ? t : Math.sign(t) * Number(Math.abs(t).toFixed(e)) || 0;
10
10
  }
11
- function ae(t, e) {
12
- return Le(t.format === "percent" ? e * 100 : e, Be(t));
11
+ function se(t, e) {
12
+ return Ue(t.format === "percent" ? e * 100 : e, We(t));
13
13
  }
14
- const We = (t, e) => t.format === "percent" ? e / 100 : e;
15
- function ve(t, e, p) {
16
- const [r, ...l] = e;
14
+ const Qe = (t, e) => t.format === "percent" ? e / 100 : e;
15
+ function ge(t, e, p) {
16
+ const [o, ...i] = e;
17
17
  switch (t) {
18
18
  case "sum":
19
- return e.reduce((a, i, N) => p[N] ? a - i : a + i, 0);
19
+ return e.reduce((n, c, S) => p[S] ? n - c : n + c, 0);
20
20
  case "difference":
21
- return l.reduce((a, i) => a - i, r);
21
+ return i.reduce((n, c) => n - c, o);
22
22
  case "product":
23
- return l.reduce((a, i) => a * i, r);
23
+ return i.reduce((n, c) => n * c, o);
24
24
  case "quotient":
25
- return r / l[0];
25
+ return o / i[0];
26
26
  }
27
27
  }
28
- const ge = (t, e) => e === void 0 || t !== void 0 && se(t) >= se(e) ? t : e;
29
- function Fe(t) {
30
- const e = /* @__PURE__ */ new Map(), p = (r) => {
31
- var c, m, $;
32
- const l = e.get(r);
33
- if (l) return l;
34
- const a = t.quantities.get(r);
35
- let i = null, N, f = !1, b;
36
- if (a.given) {
37
- const o = a.given.value;
38
- typeof o == "number" && Number.isFinite(o) ? i = o : N = { kind: "missing", label: a.label };
28
+ const be = (t, e) => e === void 0 || t !== void 0 && oe(t) >= oe(e) ? t : e;
29
+ function Ve(t) {
30
+ const e = /* @__PURE__ */ new Map(), p = (o) => {
31
+ var r, u, $;
32
+ const i = e.get(o);
33
+ if (i) return i;
34
+ const n = t.quantities.get(o);
35
+ let c = null, S, l = !1, y;
36
+ if (n.given) {
37
+ const s = n.given.value;
38
+ typeof s == "number" && Number.isFinite(s) ? c = s : S = { kind: "missing", label: n.label };
39
39
  } else {
40
- const o = a.operands.map((y) => ({ operand: y, ...p(y.key) }));
41
- for (const { operand: y, verdict: M, worst: q } of o) {
42
- const x = y.reference ? M : ge(M, q);
43
- b = ge(b, x);
40
+ const s = n.operands.map((v) => ({ operand: v, ...p(v.key) }));
41
+ for (const { operand: v, verdict: k, worst: M } of s) {
42
+ const x = v.reference ? k : be(k, M);
43
+ y = be(y, x);
44
44
  }
45
- N = (c = o.find((y) => y.absence)) == null ? void 0 : c.absence;
46
- const _ = o[1];
47
- if (!N && a.operator === "quotient" && _.value === 0 && (N = { kind: "zero", label: t.quantities.get(_.operand.key).label }), !N) {
48
- const y = a.operands.map((q) => q.negated === !0);
49
- i = ve(a.operator, o.map((q) => q.value), y);
50
- const M = ve(
51
- a.operator,
52
- o.map((q) => We(t.quantities.get(q.operand.key), q.shown)),
53
- y
45
+ S = (r = s.find((v) => v.absence)) == null ? void 0 : r.absence;
46
+ const w = s[1];
47
+ if (!S && n.operator === "quotient" && w.value === 0 && (S = { kind: "zero", label: t.quantities.get(w.operand.key).label }), !S) {
48
+ const v = n.operands.map((M) => M.negated === !0);
49
+ c = ge(n.operator, s.map((M) => M.value), v);
50
+ const k = ge(
51
+ n.operator,
52
+ s.map((M) => Qe(t.quantities.get(M.operand.key), M.shown)),
53
+ v
54
54
  );
55
- f = ae(a, M) !== ae(a, i);
55
+ l = se(n, k) !== se(n, c);
56
56
  }
57
57
  }
58
- const j = { target: a.target, limits: a.limits }, U = a.target !== void 0 || (((m = a.limits) == null ? void 0 : m.length) ?? 0) > 0 ? Re(i, j) : void 0, D = ((($ = a.limits) == null ? void 0 : $.length) ?? 0) > 0 ? U.verdict : i === null ? "unknown" : void 0, E = {
59
- value: i,
60
- absence: N,
61
- shown: i === null ? null : ae(a, i),
62
- approximate: f,
63
- assessment: U,
64
- verdict: D,
65
- worst: b
58
+ const A = { target: n.target, limits: n.limits }, L = n.target !== void 0 || (((u = n.limits) == null ? void 0 : u.length) ?? 0) > 0 ? Ie(c, A) : void 0, V = ((($ = n.limits) == null ? void 0 : $.length) ?? 0) > 0 ? L.verdict : c === null ? "unknown" : void 0, F = {
59
+ value: c,
60
+ absence: S,
61
+ shown: c === null ? null : se(n, c),
62
+ approximate: l,
63
+ assessment: L,
64
+ verdict: V,
65
+ worst: y
66
66
  };
67
- return e.set(r, E), E;
67
+ return e.set(o, F), F;
68
68
  };
69
- for (const r of t.quantities.keys()) p(r);
69
+ for (const o of t.quantities.keys()) p(o);
70
70
  return e;
71
71
  }
72
- const Ue = () => null, Qe = () => null, ze = () => null, Ve = () => null, Ge = () => null, be = () => null, He = () => null, Ke = () => null, Ye = () => null, Je = () => null, Ze = () => null, ce = () => null, Xe = /* @__PURE__ */ new Map([
73
- [Qe, "sum"],
74
- [ze, "difference"],
75
- [Ve, "product"],
76
- [Ge, "quotient"]
77
- ]), $e = {
72
+ const ze = () => null, Ge = () => null, He = () => null, Ke = () => null, Ye = () => null, $e = () => null, Je = () => null, Ze = () => null, Xe = () => null, et = () => null, tt = () => null, ce = () => null, nt = /* @__PURE__ */ new Map([
73
+ [Ge, "sum"],
74
+ [He, "difference"],
75
+ [Ke, "product"],
76
+ [Ye, "quotient"]
77
+ ]), _e = {
78
78
  sum: "Sum",
79
79
  difference: "Difference",
80
80
  product: "Product",
81
81
  quotient: "Quotient"
82
82
  }, ue = /* @__PURE__ */ new Map([
83
- [Ke, { name: "Plus", operator: "sum" }],
84
- [Ye, { name: "Minus", operator: "sum", negated: !0 }],
85
- [Je, { name: "Times", operator: "product" }],
86
- [Ze, { name: "DividedBy", operator: "quotient" }]
87
- ]), de = "<Given>, <Sum>, <Difference>, <Product>, <Quotient> or <Chain>", _e = "a calculation with metrics only adds and subtracts - <Sum>, <Difference>, <Plus>, <Minus>.", et = ["unit", "format", "decimals"];
88
- function w(t) {
83
+ [Ze, { name: "Plus", operator: "sum" }],
84
+ [Xe, { name: "Minus", operator: "sum", negated: !0 }],
85
+ [et, { name: "Times", operator: "product" }],
86
+ [tt, { name: "DividedBy", operator: "quotient" }]
87
+ ]), de = "<Given>, <Sum>, <Difference>, <Product>, <Quotient> or <Chain>", ye = "a calculation with metrics only adds and subtracts - <Sum>, <Difference>, <Plus>, <Minus>.", st = ["unit", "format", "decimals"];
88
+ function O(t) {
89
89
  throw new Error(`@umriss-ui/calculation: ${t}`);
90
90
  }
91
91
  function ee(t) {
92
- return qe.toArray(t).flatMap(
93
- (e) => z(e) && e.type === xe ? ee(e.props.children) : [e]
92
+ return ke.toArray(t).flatMap(
93
+ (e) => K(e) && e.type === Me ? ee(e.props.children) : [e]
94
94
  );
95
95
  }
96
96
  function ne(t) {
97
- if (!z(t)) return JSON.stringify(t);
97
+ if (!K(t)) return JSON.stringify(t);
98
98
  const e = t.type;
99
99
  return typeof e == "string" ? `<${e}>` : `<${e.displayName ?? e.name ?? "anonymous"}>`;
100
100
  }
101
- const pe = (t, e, p) => `${t}/${z(e) && e.key || p}`;
102
- function tt(t, e) {
101
+ const fe = (t, e, p) => `${t}/${K(e) && e.key || p}`;
102
+ function at(t, e) {
103
103
  const p = ee(t);
104
- if (p.length !== 1 && w(`<Calculation> takes exactly one child, the result; it was given ${p.length}.`), e !== void 0) {
105
- e.length === 0 && w("<Calculation>: metrics is empty; leave it out for a calculation with one number per quantity.");
106
- const c = /* @__PURE__ */ new Set();
107
- for (const { id: m } of e)
108
- c.has(m) && w(`<Calculation>: the metric id "${m}" is used twice.`), c.add(m);
104
+ if (p.length !== 1 && O(`<Calculation> takes exactly one child, the result; it was given ${p.length}.`), e !== void 0) {
105
+ e.length === 0 && O("<Calculation>: metrics is empty; leave it out for a calculation with one number per quantity.");
106
+ const r = /* @__PURE__ */ new Set();
107
+ for (const { id: u } of e)
108
+ r.has(u) && O(`<Calculation>: the metric id "${u}" is used twice.`), r.add(u);
109
109
  }
110
- const r = e == null ? void 0 : e.map((c) => `"${c.id}"`).join(", "), l = (c, m) => {
111
- const $ = typeof c == "object" && c !== null;
110
+ const o = e == null ? void 0 : e.map((r) => `"${r.id}"`).join(", "), i = (r, u) => {
111
+ const $ = typeof r == "object" && r !== null;
112
112
  if (e === void 0) {
113
- $ && w(`${m}: value is an object by metric, but the calculation has no metrics.`);
113
+ $ && O(`${u}: value is an object by metric, but the calculation has no metrics.`);
114
114
  return;
115
115
  }
116
- $ || w(`${m}: with metrics, value is an object with a number for each metric - ${r}.`);
117
- for (const { id: o } of e)
118
- o in c || w(`${m}: value has no number for the metric "${o}"; write null where it is absent. The metrics: ${r}.`);
119
- for (const o of Object.keys(c))
120
- e.some((_) => _.id === o) || w(`${m}: value has a number for "${o}", which is no metric. The metrics: ${r}.`);
121
- }, a = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), N = [], f = (c, m, $) => {
122
- const { id: o, ..._ } = m;
116
+ $ || O(`${u}: with metrics, value is an object with a number for each metric - ${o}.`);
117
+ for (const { id: s } of e)
118
+ s in r || O(`${u}: value has no number for the metric "${s}"; write null where it is absent. The metrics: ${o}.`);
119
+ for (const s of Object.keys(r))
120
+ e.some((w) => w.id === s) || O(`${u}: value has a number for "${s}", which is no metric. The metrics: ${o}.`);
121
+ }, n = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), S = [], l = (r, u, $) => {
122
+ const { id: s, ...w } = u;
123
123
  if (e !== void 0) {
124
- for (const M of et)
125
- m[M] !== void 0 && w(`${$}: ${M} belongs to the metric once the calculation has metrics, not to a quantity.`);
126
- (m.target !== void 0 || m.limits !== void 0) && w(`${$}: target and limits are not assessed in a calculation with metrics.`);
124
+ for (const k of st)
125
+ u[k] !== void 0 && O(`${$}: ${k} belongs to the metric once the calculation has metrics, not to a quantity.`);
126
+ (u.target !== void 0 || u.limits !== void 0) && O(`${$}: target and limits are not assessed in a calculation with metrics.`);
127
127
  }
128
- o !== void 0 && (i.has(o) && w(`${$}: the id "${o}" is used twice.`), i.set(o, c));
129
- const y = { ..._, key: c, id: o, operands: [] };
130
- return a.set(c, y), y;
131
- }, b = (c, m, $) => {
132
- if (z(c) && c.type === be) {
133
- const o = { key: "", reference: !0 };
134
- return N.push({ operand: o, to: c.props.to, where: $ }), o;
128
+ s !== void 0 && (c.has(s) && O(`${$}: the id "${s}" is used twice.`), c.set(s, r));
129
+ const v = { ...w, key: r, id: s, operands: [] };
130
+ return n.set(r, v), v;
131
+ }, y = (r, u, $) => {
132
+ if (K(r) && r.type === $e) {
133
+ const s = { key: "", reference: !0 };
134
+ return S.push({ operand: s, to: r.props.to, where: $ }), s;
135
135
  }
136
- return { key: j(c, m, $), reference: !1 };
137
- }, j = (c, m, $) => {
138
- if ((!z(c) || c.type === be || ue.has(c.type) || c.type === ce) && w(`${$}: ${ne(c)} cannot stand here; a quantity must be ${de}.`), c.type === He) return U(c.props.children, m, $);
139
- const o = Xe.get(c.type);
140
- c.type !== Ue && o === void 0 && w(
141
- `${$}: ${ne(c)} is not an element of the calculation. A calculation reads its children's props and cannot look inside a component of your own; write ${de} or <Ref> directly, or return them from .map.`
136
+ return { key: A(r, u, $), reference: !1 };
137
+ }, A = (r, u, $) => {
138
+ if ((!K(r) || r.type === $e || ue.has(r.type) || r.type === ce) && O(`${$}: ${ne(r)} cannot stand here; a quantity must be ${de}.`), r.type === Je) return L(r.props.children, u, $);
139
+ const s = nt.get(r.type);
140
+ r.type !== ze && s === void 0 && O(
141
+ `${$}: ${ne(r)} is not an element of the calculation. A calculation reads its children's props and cannot look inside a component of your own; write ${de} or <Ref> directly, or return them from .map.`
142
142
  );
143
- const { children: _, value: y, source: M, asOf: q, ages: x, ...B } = c.props, h = `${$} › ${B.label}`;
144
- e !== void 0 && (o === "product" || o === "quotient") && w(`${h}: <${$e[o]}> - ${_e}`);
145
- const O = f(m, B, h);
146
- if (o === void 0)
147
- return l(y, h), O.given = { value: y, source: M, asOf: q, ages: x }, m;
148
- O.operator = o;
149
- const n = ee(_), s = n.length;
150
- return (o === "quotient" ? s !== 2 : o !== "sum" && s < 2) && w(
151
- `${h}: <${$e[o]}> takes ${o === "quotient" ? "exactly two operands" : "two or more operands"}; it was given ${s}.`
152
- ), O.operands = n.map((u, C) => b(u, pe(m, u, C), h)), m;
153
- }, U = (c, m, $) => {
154
- const o = `${$} › <Chain>`, [_, ...y] = ee(c);
155
- (_ === void 0 || z(_) && (ue.has(_.type) || _.type === ce)) && w(`${o}: a chain starts with a quantity that has no operator - ${de} or <Ref>.`);
156
- let M = b(_, pe(m, _, 0), o), q = ne(_), x = [], B;
157
- return y.forEach((h, O) => {
158
- const n = pe(m, h, O + 1);
159
- if (z(h) && h.type === ce) {
160
- const I = h.props, G = `${o} › ${I.label}`;
161
- x.length === 0 && w(`${G}: an <Interim> needs an operand since the named value before it, ${q}.`);
162
- const J = f(n, I, G);
163
- J.interim = !0, J.operator = x[0].line.operator, J.operands = [M, ...x.map((te) => te.operand)], M = { key: n, reference: !1, previous: !0 }, q = `<Interim label="${I.label}">`, x = [], B = n;
143
+ const { children: w, value: v, source: k, asOf: M, ages: x, ...D } = r.props, g = `${$} › ${D.label}`;
144
+ e !== void 0 && (s === "product" || s === "quotient") && O(`${g}: <${_e[s]}> - ${ye}`);
145
+ const C = l(u, D, g);
146
+ if (s === void 0)
147
+ return i(v, g), C.given = { value: v, source: k, asOf: M, ages: x }, u;
148
+ C.operator = s;
149
+ const _ = ee(w), N = _.length;
150
+ return (s === "quotient" ? N !== 2 : s !== "sum" && N < 2) && O(
151
+ `${g}: <${_e[s]}> takes ${s === "quotient" ? "exactly two operands" : "two or more operands"}; it was given ${N}.`
152
+ ), C.operands = _.map((a, d) => y(a, fe(u, a, d), g)), u;
153
+ }, L = (r, u, $) => {
154
+ const s = `${$} › <Chain>`, [w, ...v] = ee(r);
155
+ (w === void 0 || K(w) && (ue.has(w.type) || w.type === ce)) && O(`${s}: a chain starts with a quantity that has no operator - ${de} or <Ref>.`);
156
+ let k = y(w, fe(u, w, 0), s), M = ne(w), x = [], D;
157
+ return v.forEach((g, C) => {
158
+ const _ = fe(u, g, C + 1);
159
+ if (K(g) && g.type === ce) {
160
+ const U = g.props, G = `${s} › ${U.label}`;
161
+ x.length === 0 && O(`${G}: an <Interim> needs an operand since the named value before it, ${M}.`);
162
+ const H = l(_, U, G);
163
+ H.interim = !0, H.operator = x[0].line.operator, H.operands = [k, ...x.map((te) => te.operand)], k = { key: _, reference: !1, previous: !0 }, M = `<Interim label="${U.label}">`, x = [], D = _;
164
164
  return;
165
165
  }
166
- const s = z(h) ? ue.get(h.type) : void 0;
167
- s === void 0 && w(`${o}: ${ne(h)} needs an operator in a chain - <Plus>, <Minus>, <Times> or <DividedBy> - or is an <Interim>.`), e !== void 0 && s.operator !== "sum" && w(`${o}: <${s.name}> - ${_e}`);
168
- const u = s.operator !== "sum", C = x.find((I) => I.line.operator !== "sum");
169
- (u && x.length > 0 || C) && w(
170
- `${o}: <${(C ?? { line: s }).line.name}> stands alone between two named values - directly after the first quantity or an <Interim>, and directly before an <Interim>.`
166
+ const N = K(g) ? ue.get(g.type) : void 0;
167
+ N === void 0 && O(`${s}: ${ne(g)} needs an operator in a chain - <Plus>, <Minus>, <Times> or <DividedBy> - or is an <Interim>.`), e !== void 0 && N.operator !== "sum" && O(`${s}: <${N.name}> - ${ye}`);
168
+ const a = N.operator !== "sum", d = x.find((U) => U.line.operator !== "sum");
169
+ (a && x.length > 0 || d) && O(
170
+ `${s}: <${(d ?? { line: N }).line.name}> stands alone between two named values - directly after the first quantity or an <Interim>, and directly before an <Interim>.`
171
171
  );
172
- const { children: d, ...T } = h.props, A = ee(d), k = () => w(`${o}: <${s.name}> takes either a label and a value, or exactly one quantity as its child.`);
173
- if (A.length > 0) {
174
- (A.length > 1 || Object.values(T).some((G) => G !== void 0)) && k();
175
- const I = b(A[0], n, o);
176
- I.negated = s.negated, x.push({ operand: I, line: s });
172
+ const { children: h, ...T } = g.props, f = ee(h), I = () => O(`${s}: <${N.name}> takes either a label and a value, or exactly one quantity as its child.`);
173
+ if (f.length > 0) {
174
+ (f.length > 1 || Object.values(T).some((G) => G !== void 0)) && I();
175
+ const U = y(f[0], _, s);
176
+ U.negated = N.negated, x.push({ operand: U, line: N });
177
177
  return;
178
178
  }
179
- T.label === void 0 && k();
180
- const { value: R, source: V, asOf: Q, ages: L, ...W } = T, K = `${o} › ${T.label}`, Y = f(n, { ...W, label: T.label }, K);
181
- l(R, K), Y.given = { value: R, source: V, asOf: Q, ages: L }, x.push({ operand: { key: n, reference: !1, negated: s.negated }, line: s });
182
- }), (x.length > 0 || B === void 0) && w(`${o}: a chain ends with an <Interim>, which names its value.`), B;
183
- }, D = j(p[0], "0", "<Calculation>"), E = a.get(D);
184
- (E.emphasis !== void 0 || E.rule !== void 0) && w(`<Calculation> › ${E.label}: emphasis and rule do not stand on the Result, which is already the heaviest line.`);
185
- for (const { operand: c, to: m, where: $ } of N) {
186
- const o = i.get(m);
187
- if (o === void 0) {
188
- const _ = [...i.keys()].map((y) => `"${y}"`).join(", ");
189
- w(`${$}: <Ref to="${m}"> names no quantity. ${_ ? `The ids that exist: ${_}.` : "No quantity has an id."}`);
179
+ T.label === void 0 && I();
180
+ const { value: P, source: E, asOf: j, ages: Y, ...z } = T, B = `${s} › ${T.label}`, W = l(_, { ...z, label: T.label }, B);
181
+ i(P, B), W.given = { value: P, source: E, asOf: j, ages: Y }, x.push({ operand: { key: _, reference: !1, negated: N.negated }, line: N });
182
+ }), (x.length > 0 || D === void 0) && O(`${s}: a chain ends with an <Interim>, which names its value.`), D;
183
+ }, V = A(p[0], "0", "<Calculation>"), F = n.get(V);
184
+ (F.emphasis !== void 0 || F.rule !== void 0) && O(`<Calculation> › ${F.label}: emphasis and rule do not stand on the Result, which is already the heaviest line.`);
185
+ for (const { operand: r, to: u, where: $ } of S) {
186
+ const s = c.get(u);
187
+ if (s === void 0) {
188
+ const w = [...c.keys()].map((v) => `"${v}"`).join(", ");
189
+ O(`${$}: <Ref to="${u}"> names no quantity. ${w ? `The ids that exist: ${w}.` : "No quantity has an id."}`);
190
190
  }
191
- c.key = o;
191
+ r.key = s;
192
192
  }
193
- return at(a), { result: D, quantities: a, metrics: e };
193
+ return it(n), { result: V, quantities: n, metrics: e };
194
194
  }
195
- function nt(t) {
195
+ function ot(t) {
196
196
  return t.metrics ? t.metrics.map((e) => {
197
197
  const p = /* @__PURE__ */ new Map();
198
- for (const [r, l] of t.quantities) {
199
- const a = l.given && { ...l.given, value: l.given.value[e.id] };
200
- p.set(r, { ...l, unit: e.unit, decimals: e.decimals, given: a });
198
+ for (const [o, i] of t.quantities) {
199
+ const n = i.given && { ...i.given, value: i.given.value[e.id] };
200
+ p.set(o, { ...i, unit: e.unit, decimals: e.decimals, given: n });
201
201
  }
202
202
  return { result: t.result, quantities: p };
203
203
  }) : [t];
204
204
  }
205
- function at(t) {
206
- const e = /* @__PURE__ */ new Set(), p = [], r = (l) => {
207
- if (e.has(l)) return;
208
- const a = p.indexOf(l);
209
- if (a !== -1) {
210
- const i = [...p.slice(a), l].map((N) => t.get(N).label);
211
- w(`the calculation goes round in a circle through references: ${i.join(" → ")}.`);
205
+ function it(t) {
206
+ const e = /* @__PURE__ */ new Set(), p = [], o = (i) => {
207
+ if (e.has(i)) return;
208
+ const n = p.indexOf(i);
209
+ if (n !== -1) {
210
+ const c = [...p.slice(n), i].map((S) => t.get(S).label);
211
+ O(`the calculation goes round in a circle through references: ${c.join(" → ")}.`);
212
212
  }
213
- p.push(l);
214
- for (const i of t.get(l).operands) r(i.key);
215
- p.pop(), e.add(l);
213
+ p.push(i);
214
+ for (const c of t.get(i).operands) o(c.key);
215
+ p.pop(), e.add(i);
216
216
  };
217
- for (const l of t.keys()) r(l);
217
+ for (const i of t.keys()) o(i);
218
218
  }
219
- const ye = 4;
220
- function ot(t, e, p) {
221
- const r = t.operands[e];
222
- if (r.previous) return;
223
- const l = t.operator, a = e === 0;
224
- if (l !== "sum" && l !== "difference") return a ? void 0 : { operator: l, negated: !1 };
225
- const i = l === "difference" ? !a : r.negated === !0, N = new Set(p.filter((b) => b !== null && b !== 0).map(Math.sign)), f = N.size === 1 ? { operator: "sum", negated: i !== N.has(-1), unsigned: !0 } : { operator: "sum", negated: i };
226
- return a && !f.negated ? void 0 : f;
219
+ const we = 4;
220
+ function rt(t, e, p) {
221
+ const o = t.operands[e];
222
+ if (o.previous) return;
223
+ const i = t.operator, n = e === 0;
224
+ if (i !== "sum" && i !== "difference") return n ? void 0 : { operator: i, negated: !1 };
225
+ const c = i === "difference" ? !n : o.negated === !0, S = new Set(p.filter((y) => y !== null && y !== 0).map(Math.sign)), l = S.size === 1 ? { operator: "sum", negated: c !== S.has(-1), unsigned: !0 } : { operator: "sum", negated: c };
226
+ return n && !l.negated ? void 0 : l;
227
227
  }
228
- const st = {
228
+ const lt = {
229
229
  sum: "calculationSumSymbol",
230
230
  difference: "calculationDifferenceSymbol",
231
231
  product: "calculationProductSymbol",
232
232
  quotient: "calculationQuotientSymbol"
233
- }, it = {
233
+ }, ct = {
234
234
  sum: "calculationSumWord",
235
235
  difference: "calculationDifferenceWord",
236
236
  product: "calculationProductWord",
237
237
  quotient: "calculationQuotientWord"
238
238
  };
239
- function oe(t, e) {
239
+ function ae(t, e) {
240
240
  switch (t) {
241
241
  case "alarm":
242
242
  return e.verdictAlarm;
@@ -249,310 +249,311 @@ function oe(t, e) {
249
249
  }
250
250
  }
251
251
  function ie(t, e, p) {
252
- const r = t.negated ? "difference" : t.operator;
253
- return p[(e ? it : st)[r]];
252
+ const o = t.negated ? "difference" : t.operator;
253
+ return p[(e ? ct : lt)[o]];
254
254
  }
255
- function rt(t, e) {
255
+ function ut(t, e) {
256
256
  return t.kind === "missing" ? e.calculationMissing(t.label) : e.calculationDivisionByZero(t.label);
257
257
  }
258
- function we(t, e, p, r) {
259
- const l = t.format === "percent" ? r : t.unit, a = p.number(e, t.decimals);
260
- return l ? `${a} ${l}` : a;
258
+ function Ne(t, e, p, o) {
259
+ const i = t.format === "percent" ? o : t.unit, n = p.number(e, t.decimals);
260
+ return i ? `${n} ${i}` : n;
261
261
  }
262
- function lt(t, e, p, r, l, a, i, N = () => {
262
+ function dt(t, e, p, o, i, n, c, S = () => {
263
263
  }) {
264
- const f = t.quantities.get(p), b = e.get(p), j = (h, O) => h.shown !== null && (O != null && O.unsigned) ? Math.abs(h.shown) : h.shown, U = (h, O, n, s) => {
265
- const u = j(O, s);
266
- return u === null ? n ? a.verdictUnknown : a.statAbsentValue : we(h, u, l, n ? a.calculationPercent : "%");
267
- }, D = (h) => {
268
- if (r || !f.operator) return {};
269
- if (f.operands.length === 0) return { names: a.calculationNoOperands };
270
- if (!h && f.operands.length > ye)
271
- return { names: a.calculationOperandCount(f.operands.length) };
272
- const O = (n) => f.operands.map((s, u) => {
273
- const C = t.quantities.get(s.key), d = N(u);
274
- return d ? `${ie(d, h, a)} ${n(C, d)}` : n(C);
264
+ const l = t.quantities.get(p), y = e.get(p), A = (g, C) => g.shown !== null && (C != null && C.unsigned) ? Math.abs(g.shown) : g.shown, L = (g, C, _, N) => {
265
+ const a = A(C, N);
266
+ return a === null ? _ ? n.verdictUnknown : n.statAbsentValue : Ne(g, a, i, _ ? n.calculationPercent : "%");
267
+ }, V = (g) => {
268
+ if (o || !l.operator) return {};
269
+ if (l.operands.length === 0) return { names: n.calculationNoOperands };
270
+ if (!g && l.operands.length > we)
271
+ return { names: n.calculationOperandCount(l.operands.length) };
272
+ const C = (_) => l.operands.map((N, a) => {
273
+ const d = t.quantities.get(N.key), h = S(a);
274
+ return h ? `${ie(h, g, n)} ${_(d, h)}` : _(d);
275
275
  }).join(" ");
276
276
  return {
277
- names: O((n) => n.label),
278
- numbers: O((n, s) => U(n, e.get(n.key), h, s))
277
+ names: C((_) => _.label),
278
+ numbers: C((_, N) => L(_, e.get(_.key), g, N))
279
279
  };
280
- }, E = (h) => {
281
- var s;
282
- const O = (s = b.assessment) == null ? void 0 : s.deviation;
283
- if (O === void 0 || f.target === void 0) return;
284
- const n = we(f, ae(f, f.target), l, h ? a.calculationPercent : "%");
285
- return O > 0 ? a.calculationAboveTarget(n) : O < 0 ? a.calculationBelowTarget(n) : a.calculationOnTarget(n);
286
- }, c = D(!1).names, m = c === void 0 || f.operands.length === 0 || f.operands.length > ye ? c : `= ${c}`, $ = D(!0), o = b.absence ? rt(b.absence, a) : void 0, _ = ` ${a.calculationEquals} `, y = b.approximate ? `${a.calculationApproximately} ${U(f, b, !0, i)}` : U(f, b, !0, i), q = [
287
- (i ? `${ie(i, !0, a)} ` : "") + f.label + _ + [$.names, $.numbers, y].filter(Boolean).join(`,${_}`),
288
- b.verdict !== void 0 && b.verdict !== "unknown" ? oe(b.verdict, a) : void 0,
289
- E(!0),
290
- o
291
- ].filter(Boolean).join(", "), x = b.shown === null ? void 0 : f.format === "percent" ? "%" : f.unit, B = (h) => h === null ? a.statAbsentValue : l.number(h, f.decimals);
292
- return { amount: B(j(b, i)), ownAmount: B(b.shown), unit: x, names: m, target: E(!1), reason: o, sentence: q, spokenNames: $.names, spokenNumber: y };
280
+ }, F = (g) => {
281
+ var N;
282
+ const C = (N = y.assessment) == null ? void 0 : N.deviation;
283
+ if (C === void 0 || l.target === void 0) return;
284
+ const _ = Ne(l, se(l, l.target), i, g ? n.calculationPercent : "%");
285
+ return C > 0 ? n.calculationAboveTarget(_) : C < 0 ? n.calculationBelowTarget(_) : n.calculationOnTarget(_);
286
+ }, r = V(!1).names, u = r === void 0 || l.operands.length === 0 || l.operands.length > we ? r : `= ${r}`, $ = V(!0), s = y.absence ? ut(y.absence, n) : void 0, w = ` ${n.calculationEquals} `, v = y.approximate ? `${n.calculationApproximately} ${L(l, y, !0, c)}` : L(l, y, !0, c), M = [
287
+ (c ? `${ie(c, !0, n)} ` : "") + l.label + w + [$.names, $.numbers, v].filter(Boolean).join(`,${w}`),
288
+ y.verdict !== void 0 && y.verdict !== "unknown" ? ae(y.verdict, n) : void 0,
289
+ F(!0),
290
+ s
291
+ ].filter(Boolean).join(", "), x = y.shown === null ? void 0 : l.format === "percent" ? "%" : l.unit, D = (g) => g === null ? n.statAbsentValue : i.number(g, l.decimals);
292
+ return { amount: D(A(y, c)), ownAmount: D(y.shown), unit: x, names: u, target: F(!1), reason: s, sentence: M, spokenNames: $.names, spokenNumber: v };
293
293
  }
294
- function ct(t, e, p, r, l) {
295
- const a = l ? `${ie(l, !0, r)} ` : "", i = e[0].spokenNames, N = a + t + (i === void 0 ? "" : ` ${r.calculationEquals} ${i}`), f = p.map(
296
- (b, j) => [`${b.label} ${e[j].spokenNumber}`, e[j].reason].filter(Boolean).join(", ")
294
+ function ft(t, e, p, o, i) {
295
+ const n = i ? `${ie(i, !0, o)} ` : "", c = e[0].spokenNames, S = n + t + (c === void 0 ? "" : ` ${o.calculationEquals} ${c}`), l = p.map(
296
+ (y, A) => [`${y.label} ${e[A].spokenNumber}`, e[A].reason].filter(Boolean).join(", ")
297
297
  );
298
- return `${N}: ${f.join("; ")}`;
298
+ return `${S}: ${l.join("; ")}`;
299
299
  }
300
- const ut = "_frame_18d3p_24 _text_r8i8z_23", dt = "_calculation_18d3p_46", pt = "_disclosure_18d3p_60", ft = "_list_18d3p_64", mt = "_item_18d3p_65", ht = "_derivation_18d3p_66", vt = "_line_18d3p_116", gt = "_labelCell_18d3p_158", bt = "_names_18d3p_159", $t = "_operator_18d3p_160", _t = "_amount_18d3p_161", yt = "_unit_18d3p_162", wt = "_assessment_18d3p_163", Nt = "_label_18d3p_158", Ot = "_approximate_18d3p_281", St = "_target_18d3p_309", Ct = "_worst_18d3p_310", qt = "_head_18d3p_433", xt = "_headCell_18d3p_440", kt = "_headUnit_18d3p_453", Mt = "_notes_18d3p_460", Tt = "_freshness_18d3p_474", Et = "_headLabel_18d3p_504", v = {
301
- frame: ut,
302
- calculation: dt,
303
- disclosure: pt,
304
- list: ft,
305
- item: mt,
306
- derivation: ht,
307
- line: vt,
308
- labelCell: gt,
309
- names: bt,
310
- operator: $t,
311
- amount: _t,
312
- unit: yt,
313
- assessment: wt,
314
- label: Nt,
315
- approximate: Ot,
316
- target: St,
317
- worst: Ct,
318
- head: qt,
319
- headCell: xt,
320
- headUnit: kt,
321
- notes: Mt,
322
- freshness: Tt,
323
- headLabel: Et
324
- }, At = 10, X = (t) => 4 + 2 * t, Rt = (t) => 5 + 2 * t, It = { ok: "success", unknown: "neutral", warning: "warning", alarm: "danger" }, Pt = (...t) => t.filter(Boolean).join(" ");
325
- function jt({ asOf: t, ages: e }) {
326
- const p = Ne(), r = Oe(), l = je(t, e), a = l.freshness === "lost" ? r.freshnessDisconnected : l.freshness === "stale" ? r.freshnessStale : r.freshnessFresh;
327
- return /* @__PURE__ */ P("span", { className: v.freshness, "data-freshness": l.freshness, children: [
328
- a,
329
- l.age !== null && ` · ${p.relative(l.age)}`
300
+ const pt = "_frame_is340_24 _text_1krlf_23", mt = "_calculation_is340_51", ht = "_line_is340_86", vt = "_assessment_is340_98", gt = "_disclosure_is340_107", bt = "_amount_is340_90", $t = "_list_is340_128", _t = "_item_is340_129", yt = "_derivation_is340_130", wt = "_labelCell_is340_90", Nt = "_names_is340_90", Ot = "_operator_is340_90", St = "_unit_is340_90", Ct = "_label_is340_90", qt = "_approximate_is340_345", xt = "_target_is340_102", kt = "_worst_is340_102", Mt = "_head_is340_497", Tt = "_headCell_is340_504", Et = "_headUnit_is340_517", At = "_notes_is340_524", Rt = "_freshness_is340_538", Dt = "_headLabel_is340_568", m = {
301
+ frame: pt,
302
+ calculation: mt,
303
+ line: ht,
304
+ assessment: vt,
305
+ disclosure: gt,
306
+ amount: bt,
307
+ list: $t,
308
+ item: _t,
309
+ derivation: yt,
310
+ labelCell: wt,
311
+ names: Nt,
312
+ operator: Ot,
313
+ unit: St,
314
+ label: Ct,
315
+ approximate: qt,
316
+ target: xt,
317
+ worst: kt,
318
+ head: Mt,
319
+ headCell: Tt,
320
+ headUnit: Et,
321
+ notes: At,
322
+ freshness: Rt,
323
+ headLabel: Dt
324
+ }, It = 10, X = (t) => 4 + 2 * t, Pt = (t) => 5 + 2 * t, jt = { ok: "success", unknown: "neutral", warning: "warning", alarm: "danger" }, Bt = (...t) => t.filter(Boolean).join(" ");
325
+ function Lt({ asOf: t, ages: e }) {
326
+ const p = Oe(), o = Se(), i = Le(t, e), n = i.freshness === "lost" ? o.freshnessDisconnected : i.freshness === "stale" ? o.freshnessStale : o.freshnessFresh;
327
+ return /* @__PURE__ */ R("span", { className: m.freshness, "data-freshness": i.freshness, children: [
328
+ n,
329
+ i.age !== null && ` · ${p.relative(i.age)}`
330
330
  ] });
331
331
  }
332
- function Wt({ children: t, className: e, style: p, metrics: r, ...l }) {
333
- const a = Ne(), i = Oe(), N = ke(), f = tt(t, r), b = nt(f).map((n) => ({ view: n, results: Fe(n) })), [j, U] = re(() => /* @__PURE__ */ new Set()), [D, E] = re(null), c = Me(null), [m, $] = re(!1), o = (r == null ? void 0 : r.length) ?? 0, _ = Te(() => {
334
- const n = c.current, s = n && o > 0 ? getComputedStyle(n.firstElementChild).gridTemplateColumns.split(" ").map(parseFloat) : [], u = X(o) - 1;
335
- if (!n || s.length <= u || s.some((k) => !Number.isFinite(k))) {
336
- $(!1);
332
+ function Qt({ children: t, className: e, style: p, metrics: o, density: i, ...n }) {
333
+ const c = Pe(i, "regular") === "compact", S = Oe(), l = Se(), y = Te(), A = at(t, o), L = ot(A).map((a) => ({ view: a, results: Ve(a) })), [V, F] = re(() => /* @__PURE__ */ new Set()), [r, u] = re(null), $ = Ee(null), [s, w] = re(!1), v = (o == null ? void 0 : o.length) ?? 0, k = Ae(() => {
334
+ const a = $.current, d = a && v > 0 ? getComputedStyle(a.firstElementChild).gridTemplateColumns.split(" ").map(parseFloat) : [], h = X(v) - 1;
335
+ if (!a || d.length <= h || d.some((E) => !Number.isFinite(E))) {
336
+ w(!1);
337
337
  return;
338
338
  }
339
- const C = s.slice(2, u).reduce((k, R) => k + R, 0);
340
- let d = 0;
341
- const T = document.createRange();
342
- for (const k of n.querySelectorAll(`.${v.label}`)) {
343
- T.selectNodeContents(k);
344
- const R = [...T.getClientRects()].reduce((L, W) => L + W.width, 0);
345
- if (R === 0) continue;
346
- const V = k.parentElement, Q = k.getBoundingClientRect().left - V.getBoundingClientRect().left;
347
- d = Math.max(d, Q + R + parseFloat(getComputedStyle(V).paddingRight));
339
+ const T = d.slice(2, h).reduce((E, j) => E + j, 0);
340
+ let f = 0;
341
+ const I = document.createRange();
342
+ for (const E of a.querySelectorAll(`.${m.label}`)) {
343
+ I.selectNodeContents(E);
344
+ const j = [...I.getClientRects()].reduce((B, W) => B + W.width, 0);
345
+ if (j === 0) continue;
346
+ const Y = E.parentElement, z = E.getBoundingClientRect().left - Y.getBoundingClientRect().left;
347
+ f = Math.max(f, z + j + parseFloat(getComputedStyle(Y).paddingRight));
348
348
  }
349
- const A = parseFloat(getComputedStyle(document.documentElement).fontSize);
350
- $(n.clientWidth - C < Math.min(d, At * A));
351
- }, [o]);
352
- Ee(() => _()), Ae(() => {
353
- const n = c.current;
354
- if (!n || o === 0) return;
355
- const s = new ResizeObserver(() => _());
356
- return s.observe(n), () => s.disconnect();
357
- }, [_, o]);
358
- const y = (n) => U((s) => {
359
- const u = new Set(s);
360
- return u.delete(n) || u.add(n), u;
361
- }), M = (n, s) => ot(
362
- n,
363
- s,
364
- b.map(({ results: u }) => u.get(n.operands[s].key).shown)
349
+ const P = parseFloat(getComputedStyle(document.documentElement).fontSize);
350
+ w(a.clientWidth - T < Math.min(f, It * P));
351
+ }, [v]);
352
+ Re(() => k()), De(() => {
353
+ const a = $.current;
354
+ if (!a || v === 0) return;
355
+ const d = new ResizeObserver(() => k());
356
+ return d.observe(a), () => d.disconnect();
357
+ }, [k, v]);
358
+ const M = (a) => F((d) => {
359
+ const h = new Set(d);
360
+ return h.delete(a) || h.add(a), h;
361
+ }), x = (a, d) => rt(
362
+ a,
363
+ d,
364
+ L.map(({ results: h }) => h.get(a.operands[d].key).shown)
365
365
  );
366
- let q = !1;
367
- const x = (n, s) => n.map(({ own: u, text: C }, d) => [
368
- /* @__PURE__ */ P(
366
+ let D = !1;
367
+ const g = (a, d) => a.map(({ own: h, text: T }, f) => [
368
+ /* @__PURE__ */ R(
369
369
  "span",
370
370
  {
371
- className: v.amount,
371
+ className: m.amount,
372
372
  "aria-hidden": "true",
373
- "data-verdict": u.verdict,
374
- "data-later": d > 0 ? "" : void 0,
375
- style: r ? { "--column": X(d) } : void 0,
373
+ "data-verdict": h.verdict,
374
+ "data-later": f > 0 ? "" : void 0,
375
+ style: o ? { "--column": X(f) } : void 0,
376
376
  children: [
377
- u.approximate && /* @__PURE__ */ g(De, { content: i.calculationApproximateNote, children: /* @__PURE__ */ g("span", { className: v.approximate, children: "≈" }) }),
378
- s ? C.ownAmount : C.amount
377
+ h.approximate && /* @__PURE__ */ b(Fe, { content: l.calculationApproximateNote, children: /* @__PURE__ */ b("span", { className: m.approximate, children: "≈" }) }),
378
+ d ? T.ownAmount : T.amount
379
379
  ]
380
380
  },
381
- `amount-${d}`
381
+ `amount-${f}`
382
382
  ),
383
- /* @__PURE__ */ g(
383
+ /* @__PURE__ */ b(
384
384
  "span",
385
385
  {
386
- className: v.unit,
386
+ className: m.unit,
387
387
  "aria-hidden": "true",
388
- style: r ? { "--column": Rt(d) } : void 0,
389
- "data-last": r && d === n.length - 1 ? "" : void 0,
390
- children: r && !s ? void 0 : C.unit
388
+ style: o ? { "--column": Pt(f) } : void 0,
389
+ "data-last": o && f === a.length - 1 ? "" : void 0,
390
+ children: o && !d ? void 0 : T.unit
391
391
  },
392
- `unit-${d}`
392
+ `unit-${f}`
393
393
  )
394
- ]), B = (n, s) => D === null ? void 0 : n === D ? "use" : s === D ? "operand" : void 0, h = (n, s, u, C) => {
395
- const d = f.quantities.get(n), T = b.map(({ view: S, results: H }) => ({
396
- own: H.get(n),
397
- text: lt(S, H, n, s, a, i, u.position, (Ce) => M(d, Ce))
398
- })), { own: A, text: k } = T[0], R = d.operator !== void 0 && !s, V = n === f.result && !s, Q = R && d.operands.length > 0 && (d.interim ? u.flat : V), L = R && !Q && d.operands.length > 0, W = L && j.has(n);
399
- q || (q = L);
400
- const K = `${N}-${n}`, Y = { depth: Q ? u.depth : u.depth + 1, flat: !1, parent: n }, I = R ? d.operands.find((S) => S.previous) : void 0, G = I && u.flat ? h(I.key, !1, { ...u, parent: n, position: void 0 }, `${C}-c`) : [], J = I && !u.flat ? h(I.key, !1, { ...Y, flat: !0 }, `${C}-c`) : [], te = R ? d.operands.map(
401
- (S, H) => S.previous ? null : h(S.key, S.reference, { ...Y, position: M(d, H) }, `${C}-${H}`)
402
- ) : [], Z = L && !W && A.worst !== void 0 && se(A.worst) > se(A.verdict ?? "ok") ? A.worst : void 0, F = s ? void 0 : d.given, Se = u.position ? ie(u.position, !1, i) : void 0, fe = [
403
- !s && d.explanation !== void 0 && /* @__PURE__ */ g("span", { children: d.explanation }, "explanation"),
404
- (F == null ? void 0 : F.source) !== void 0 && /* @__PURE__ */ g("span", { children: i.calculationSource(F.source) }, "source"),
405
- (F == null ? void 0 : F.asOf) !== void 0 && (F.ages !== void 0 ? /* @__PURE__ */ g(jt, { asOf: F.asOf, ages: F.ages }, "asOf") : /* @__PURE__ */ g("span", { children: i.asOfAgo(a.dateTime(new Date(F.asOf), !1)) }, "asOf")),
406
- !s && d.aside !== void 0 && /* @__PURE__ */ g("span", { children: d.aside }, "aside")
407
- ].filter(Boolean), me = V ? "result" : d.interim && !s && u.flat ? "interim" : void 0, he = /* @__PURE__ */ P(
394
+ ]), C = (a, d) => r === null ? void 0 : a === r ? "use" : d === r ? "operand" : void 0, _ = (a, d, h, T) => {
395
+ const f = A.quantities.get(a), I = L.map(({ view: q, results: J }) => ({
396
+ own: J.get(a),
397
+ text: dt(q, J, a, d, S, l, h.position, (xe) => x(f, xe))
398
+ })), { own: P, text: E } = I[0], j = f.operator !== void 0 && !d, Y = a === A.result && !d, z = j && f.operands.length > 0 && (f.interim ? h.flat : Y), B = j && !z && f.operands.length > 0, W = B && V.has(a);
399
+ D || (D = B);
400
+ const U = `${y}-${a}`, G = { depth: z ? h.depth : h.depth + 1, flat: !1, parent: a }, H = j ? f.operands.find((q) => q.previous) : void 0, te = H && h.flat ? _(H.key, !1, { ...h, parent: a, position: void 0 }, `${T}-c`) : [], Ce = H && !h.flat ? _(H.key, !1, { ...G, flat: !0 }, `${T}-c`) : [], pe = j ? f.operands.map(
401
+ (q, J) => q.previous ? null : _(q.key, q.reference, { ...G, position: x(f, J) }, `${T}-${J}`)
402
+ ) : [], Z = B && !W && P.worst !== void 0 && oe(P.worst) > oe(P.verdict ?? "ok") ? P.worst : void 0, Q = d ? void 0 : f.given, qe = h.position ? ie(h.position, !1, l) : void 0, me = [
403
+ !d && f.explanation !== void 0 && /* @__PURE__ */ b("span", { children: f.explanation }, "explanation"),
404
+ (Q == null ? void 0 : Q.source) !== void 0 && /* @__PURE__ */ b("span", { children: l.calculationSource(Q.source) }, "source"),
405
+ (Q == null ? void 0 : Q.asOf) !== void 0 && (Q.ages !== void 0 ? /* @__PURE__ */ b(Lt, { asOf: Q.asOf, ages: Q.ages }, "asOf") : /* @__PURE__ */ b("span", { children: l.asOfAgo(S.dateTime(new Date(Q.asOf), !1)) }, "asOf")),
406
+ !d && f.aside !== void 0 && /* @__PURE__ */ b("span", { children: f.aside }, "aside")
407
+ ].filter(Boolean), he = Y ? "result" : f.interim && !d && h.flat ? "interim" : void 0, ve = /* @__PURE__ */ R(
408
408
  "div",
409
409
  {
410
- className: v.line,
411
- style: { "--depth": u.depth },
412
- "data-inner": u.depth > 0 ? "" : void 0,
413
- "data-kind": me,
414
- "data-foldable": L ? "" : void 0,
415
- "data-reference": s ? "" : void 0,
416
- "data-emphasis": s ? void 0 : d.emphasis,
417
- "data-rule": !s && d.rule ? "" : void 0,
418
- "data-mark": B(n, u.parent),
419
- onPointerEnter: () => E(n),
420
- onPointerLeave: () => E(null),
421
- onFocus: () => E(n),
422
- onBlur: () => E(null),
423
- onClick: L ? () => {
424
- var S;
425
- (S = window.getSelection()) != null && S.toString() || y(n);
410
+ className: m.line,
411
+ style: { "--depth": h.depth },
412
+ "data-inner": h.depth > 0 ? "" : void 0,
413
+ "data-kind": he,
414
+ "data-foldable": B ? "" : void 0,
415
+ "data-reference": d ? "" : void 0,
416
+ "data-emphasis": d ? void 0 : f.emphasis,
417
+ "data-rule": !d && f.rule ? "" : void 0,
418
+ "data-mark": C(a, h.parent),
419
+ onPointerEnter: () => u(a),
420
+ onPointerLeave: () => u(null),
421
+ onFocus: () => u(a),
422
+ onBlur: () => u(null),
423
+ onClick: B ? () => {
424
+ var q;
425
+ (q = window.getSelection()) != null && q.toString() || M(a);
426
426
  } : void 0,
427
427
  children: [
428
- /* @__PURE__ */ g(Ie, { children: [
429
- r ? ct(d.label, T.map((S) => S.text), r, i, u.position) : k.sentence,
430
- T.some((S) => S.own.approximate) && i.calculationApproximateNote,
431
- Z !== void 0 && i.calculationWorstInside(oe(Z, i))
428
+ /* @__PURE__ */ b(je, { children: [
429
+ o ? ft(f.label, I.map((q) => q.text), o, l, h.position) : E.sentence,
430
+ I.some((q) => q.own.approximate) && l.calculationApproximateNote,
431
+ Z !== void 0 && l.calculationWorstInside(ae(Z, l))
432
432
  ].filter(Boolean).join(". ") }),
433
- /* @__PURE__ */ P("span", { className: v.labelCell, children: [
434
- L ? /* @__PURE__ */ g(
433
+ /* @__PURE__ */ R("span", { className: m.labelCell, children: [
434
+ B ? /* @__PURE__ */ b(
435
435
  "button",
436
436
  {
437
437
  type: "button",
438
- className: v.disclosure,
438
+ className: m.disclosure,
439
439
  "aria-expanded": W,
440
- "aria-controls": K,
441
- "aria-label": (W ? i.calculationHideDerivation : i.calculationShowDerivation)(d.label),
442
- children: /* @__PURE__ */ g(Pe, { "data-open": W ? "" : void 0 })
440
+ "aria-controls": U,
441
+ "aria-label": (W ? l.calculationHideDerivation : l.calculationShowDerivation)(f.label),
442
+ children: /* @__PURE__ */ b(Be, { "data-open": W ? "" : void 0 })
443
443
  }
444
- ) : /* @__PURE__ */ g("span", { className: v.disclosure, "aria-hidden": "true" }),
445
- /* @__PURE__ */ g("span", { className: v.label, "aria-hidden": "true", children: d.label })
444
+ ) : /* @__PURE__ */ b("span", { className: m.disclosure, "aria-hidden": "true" }),
445
+ /* @__PURE__ */ b("span", { className: m.label, "aria-hidden": "true", children: f.label })
446
446
  ] }),
447
- /* @__PURE__ */ g("span", { className: v.names, "aria-hidden": "true", children: R && !Q && !W ? k.names : void 0 }),
448
- /* @__PURE__ */ g("span", { className: v.operator, "aria-hidden": "true", children: Se }),
449
- x(T, me !== void 0),
450
- /* @__PURE__ */ P("span", { className: v.assessment, "aria-hidden": "true", children: [
451
- r ? (
447
+ /* @__PURE__ */ b("span", { className: m.names, "aria-hidden": "true", children: j && !z && !W ? E.names : void 0 }),
448
+ /* @__PURE__ */ b("span", { className: m.operator, "aria-hidden": "true", children: qe }),
449
+ g(I, he !== void 0),
450
+ /* @__PURE__ */ R("span", { className: m.assessment, "aria-hidden": "true", children: [
451
+ o ? (
452
452
  /* Short: which metric. The sentence carries the full reason. */
453
- r.map(
454
- (S, H) => T[H].own.absence && /* @__PURE__ */ g(le, { children: i.calculationMissing(S.unit ?? S.label) }, S.id)
453
+ o.map(
454
+ (q, J) => I[J].own.absence && /* @__PURE__ */ b(le, { children: l.calculationMissing(q.unit ?? q.label) }, q.id)
455
455
  )
456
- ) : k.reason !== void 0 ? /* @__PURE__ */ g(le, { children: k.reason }) : A.verdict !== void 0 && /* @__PURE__ */ g(le, { tone: It[A.verdict], children: oe(A.verdict, i) }),
457
- k.target !== void 0 && /* @__PURE__ */ g("span", { className: v.target, children: k.target }),
458
- Z !== void 0 && /* @__PURE__ */ g("span", { className: v.worst, "data-verdict": Z, children: i.calculationWorstInside(oe(Z, i)) })
456
+ ) : E.reason !== void 0 ? /* @__PURE__ */ b(le, { children: E.reason }) : P.verdict !== void 0 && /* @__PURE__ */ b(le, { tone: jt[P.verdict], children: ae(P.verdict, l) }),
457
+ E.target !== void 0 && /* @__PURE__ */ b("span", { className: m.target, children: E.target }),
458
+ Z !== void 0 && /* @__PURE__ */ b("span", { className: m.worst, "data-verdict": Z, children: l.calculationWorstInside(ae(Z, l)) })
459
459
  ] }),
460
- fe.length > 0 && /* A click here - on a link in the aside, on a sparkline - is the
460
+ me.length > 0 && /* A click here - on a link in the aside, on a sparkline - is the
461
461
  caller's, not a fold. */
462
- /* @__PURE__ */ g("span", { className: v.notes, onClick: (S) => S.stopPropagation(), children: fe })
462
+ /* @__PURE__ */ b("span", { className: m.notes, onClick: (q) => q.stopPropagation(), children: me })
463
463
  ]
464
464
  }
465
465
  );
466
- return Q ? [
467
- ...G,
468
- /* @__PURE__ */ P("li", { className: v.item, children: [
469
- /* @__PURE__ */ g("ul", { className: v.list, children: te }),
470
- he
471
- ] }, C)
466
+ return z ? [
467
+ ...te,
468
+ /* @__PURE__ */ R("li", { className: m.item, children: [
469
+ /* @__PURE__ */ b("ul", { className: m.list, children: pe }),
470
+ ve
471
+ ] }, T)
472
472
  ] : [
473
- ...G,
474
- /* @__PURE__ */ P("li", { className: v.item, "data-open": W ? "" : void 0, style: { "--depth": u.depth }, children: [
475
- he,
476
- L && /* @__PURE__ */ P("ul", { id: K, className: v.derivation, hidden: !W, children: [
477
- J,
478
- te,
479
- /* @__PURE__ */ g("li", { className: v.item, "aria-hidden": "true", children: /* @__PURE__ */ P(
473
+ ...te,
474
+ /* @__PURE__ */ R("li", { className: m.item, "data-open": W ? "" : void 0, style: { "--depth": h.depth }, children: [
475
+ ve,
476
+ B && /* @__PURE__ */ R("ul", { id: U, className: m.derivation, hidden: !W, children: [
477
+ Ce,
478
+ pe,
479
+ /* @__PURE__ */ b("li", { className: m.item, "aria-hidden": "true", children: /* @__PURE__ */ R(
480
480
  "div",
481
481
  {
482
- className: v.line,
483
- style: { "--depth": Y.depth },
482
+ className: m.line,
483
+ style: { "--depth": G.depth },
484
484
  "data-inner": "",
485
485
  "data-closing": "",
486
- "data-mark": D === n ? "use" : void 0,
486
+ "data-mark": r === a ? "use" : void 0,
487
487
  children: [
488
- /* @__PURE__ */ P("span", { className: v.labelCell, children: [
489
- /* @__PURE__ */ g("span", { className: v.disclosure }),
490
- /* @__PURE__ */ P("span", { className: v.label, children: [
488
+ /* @__PURE__ */ R("span", { className: m.labelCell, children: [
489
+ /* @__PURE__ */ b("span", { className: m.disclosure }),
490
+ /* @__PURE__ */ R("span", { className: m.label, children: [
491
491
  "= ",
492
- d.label
492
+ f.label
493
493
  ] })
494
494
  ] }),
495
- /* @__PURE__ */ g("span", { className: v.names }),
496
- /* @__PURE__ */ g("span", { className: v.operator }),
497
- x(T, !0)
495
+ /* @__PURE__ */ b("span", { className: m.names }),
496
+ /* @__PURE__ */ b("span", { className: m.operator }),
497
+ g(I, !0)
498
498
  ]
499
499
  }
500
500
  ) })
501
501
  ] })
502
- ] }, C)
502
+ ] }, T)
503
503
  ];
504
- }, O = h(f.result, !1, { depth: 0, flat: !0, parent: null }, "r");
504
+ }, N = _(A.result, !1, { depth: 0, flat: !0, parent: null }, "r");
505
505
  return (
506
506
  /* The frame is the surface and the container the layout measures itself
507
507
  against; the list inside it is the statement. */
508
- /* @__PURE__ */ g(
508
+ /* @__PURE__ */ b(
509
509
  "div",
510
510
  {
511
- ref: c,
512
- className: Pt(v.frame, e),
513
- style: r ? {
514
- "--figure-tracks": Array(o * 2).fill("auto").join(" "),
515
- "--figures-end": X(o),
516
- "--assessment-column": X(o),
511
+ ref: $,
512
+ className: Bt(m.frame, e),
513
+ style: o ? {
514
+ "--figure-tracks": Array(v * 2).fill("auto").join(" "),
515
+ "--figures-end": X(v),
516
+ "--assessment-column": X(v),
517
517
  ...p
518
518
  } : p,
519
- "data-still": q ? void 0 : "",
520
- "data-metrics": r ? o : void 0,
521
- "data-two-lines": m ? "" : void 0,
522
- children: /* @__PURE__ */ P("ul", { className: v.calculation, ...l, children: [
523
- r && /* The head names each metric and its unit above its column. Every
519
+ "data-still": D ? void 0 : "",
520
+ "data-metrics": o ? v : void 0,
521
+ "data-two-lines": s ? "" : void 0,
522
+ "data-compact": c ? "" : void 0,
523
+ children: /* @__PURE__ */ R("ul", { className: m.calculation, ...n, children: [
524
+ o && /* The head names each metric and its unit above its column. Every
524
525
  row's sentence names them too, so the head is for the eye. */
525
- /* @__PURE__ */ g("li", { className: v.item, "aria-hidden": "true", children: /* @__PURE__ */ g("div", { className: v.head, children: r.map((n, s) => /* @__PURE__ */ P(
526
+ /* @__PURE__ */ b("li", { className: m.item, "aria-hidden": "true", children: /* @__PURE__ */ b("div", { className: m.head, children: o.map((a, d) => /* @__PURE__ */ R(
526
527
  "span",
527
528
  {
528
- className: v.headCell,
529
- "data-unit": n.unit === void 0 ? void 0 : "",
530
- style: { "--column": X(s) },
529
+ className: m.headCell,
530
+ "data-unit": a.unit === void 0 ? void 0 : "",
531
+ style: { "--column": X(d) },
531
532
  children: [
532
- /* @__PURE__ */ g("span", { className: v.headLabel, children: n.label }),
533
- n.unit !== void 0 && /* @__PURE__ */ g("span", { className: v.headUnit, children: n.unit })
533
+ /* @__PURE__ */ b("span", { className: m.headLabel, children: a.label }),
534
+ a.unit !== void 0 && /* @__PURE__ */ b("span", { className: m.headUnit, children: a.unit })
534
535
  ]
535
536
  },
536
- n.id
537
+ a.id
537
538
  )) }) }),
538
- O
539
+ N
539
540
  ] })
540
541
  }
541
542
  )
542
543
  );
543
544
  }
544
545
  export {
545
- Wt as Calculation,
546
- He as Chain,
547
- ze as Difference,
548
- Ze as DividedBy,
549
- Ue as Given,
546
+ Qt as Calculation,
547
+ Je as Chain,
548
+ He as Difference,
549
+ tt as DividedBy,
550
+ ze as Given,
550
551
  ce as Interim,
551
- Ye as Minus,
552
- Ke as Plus,
553
- Ve as Product,
554
- Ge as Quotient,
555
- be as Ref,
556
- Qe as Sum,
557
- Je as Times
552
+ Xe as Minus,
553
+ Ze as Plus,
554
+ Ke as Product,
555
+ Ye as Quotient,
556
+ $e as Ref,
557
+ Ge as Sum,
558
+ et as Times
558
559
  };