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