@umriss-ui/calculation 0.43.0 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +6 -0
- package/dist/calculation.client.js +276 -254
- package/dist/calculation.css +1 -1
- package/dist/calculation.js +2 -2
- package/dist/calculation.model-BTqFvIHM.js +176 -0
- package/dist/index.d.ts +5 -0
- package/docs/llms-full.md +71 -23
- package/package.json +3 -3
- package/dist/calculation.model-CZuohgrp.js +0 -176
|
@@ -1,104 +1,121 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "./calculation.css";
|
|
3
|
-
import { jsx as
|
|
4
|
-
import { useId as Ce, useState as
|
|
5
|
-
import { assess as Me, verdictWeight as
|
|
6
|
-
import { p as
|
|
7
|
-
function
|
|
3
|
+
import { jsx as r, jsxs as $ } from "react/jsx-runtime";
|
|
4
|
+
import { useId as Ce, useState as se, useRef as ke, useCallback as fe, useLayoutEffect as Ae, useEffect as Ee } from "react";
|
|
5
|
+
import { assess as Me, verdictWeight as te, useDensityFor as Te, useFormats as xe, useWording as ye, VisuallyHidden as We, AngleGlyph as Be, Badge as oe, useFreshness as Le, Tooltip as De } from "@umriss-ui/core";
|
|
6
|
+
import { p as Re } from "./calculation.model-BTqFvIHM.js";
|
|
7
|
+
function we(e, t) {
|
|
8
8
|
if (e.decimals !== void 0) return e.decimals;
|
|
9
|
-
const
|
|
10
|
-
if (
|
|
9
|
+
const f = e.format === "percent" ? 1 : e.given ? void 0 : 2;
|
|
10
|
+
if (f === void 0) return;
|
|
11
11
|
const i = e.format === "percent" ? t * 100 : t;
|
|
12
|
-
return i !== 0 &&
|
|
12
|
+
return i !== 0 && qe(i, f) === 0 ? void 0 : f;
|
|
13
13
|
}
|
|
14
14
|
function pe(e, t) {
|
|
15
|
-
const [
|
|
16
|
-
return +`${
|
|
15
|
+
const [f, i = "0"] = String(e).split("e");
|
|
16
|
+
return +`${f}e${Number(i) + t}`;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function qe(e, t) {
|
|
19
19
|
return t === void 0 ? e : Math.sign(e) * pe(Math.round(pe(Math.abs(e), t)), -t) || 0;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
return
|
|
21
|
+
function X(e, t, f = we(e, t)) {
|
|
22
|
+
return qe(e.format === "percent" ? t * 100 : t, f);
|
|
23
23
|
}
|
|
24
24
|
const Fe = (e, t) => e.format === "percent" ? t / 100 : t;
|
|
25
|
-
function
|
|
26
|
-
const [i, ...
|
|
25
|
+
function he(e, t, f) {
|
|
26
|
+
const [i, ...u] = t;
|
|
27
27
|
switch (e) {
|
|
28
28
|
case "sum":
|
|
29
|
-
return t.reduce((n, l, g) =>
|
|
29
|
+
return t.reduce((n, l, g) => f[g] ? n - l : n + l, 0);
|
|
30
30
|
case "difference":
|
|
31
|
-
return
|
|
31
|
+
return u.reduce((n, l) => n - l, i);
|
|
32
32
|
case "product":
|
|
33
|
-
return
|
|
33
|
+
return u.reduce((n, l) => n * l, i);
|
|
34
34
|
case "quotient":
|
|
35
|
-
return i /
|
|
35
|
+
return i / u[0];
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
const
|
|
39
|
-
function
|
|
40
|
-
const t = /* @__PURE__ */ new Map(),
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
38
|
+
const ve = (e, t) => t === void 0 || e !== void 0 && te(e) >= te(t) ? e : t, ge = { good: 0, uncertain: 1, bad: 2 };
|
|
39
|
+
function je(e) {
|
|
40
|
+
const t = /* @__PURE__ */ new Map(), f = (i) => {
|
|
41
|
+
const u = t.get(i);
|
|
42
|
+
if (u) return u;
|
|
43
43
|
const n = e.quantities.get(i);
|
|
44
|
-
let l = null, g, p = !1, s;
|
|
44
|
+
let l = null, g, p = !1, s, S = "good";
|
|
45
45
|
if (n.given) {
|
|
46
|
-
const
|
|
47
|
-
typeof
|
|
46
|
+
const y = n.given.value;
|
|
47
|
+
typeof y == "number" && Number.isFinite(y) ? l = y : g = { kind: "missing", label: n.label }, S = n.given.quality ?? "good";
|
|
48
48
|
} else {
|
|
49
|
-
const
|
|
50
|
-
for (const
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
const y = n.operands.map((v) => ({ operand: v, ...f(v.key) }));
|
|
50
|
+
for (const v of y)
|
|
51
|
+
ge[v.quality] > ge[S] && (S = v.quality);
|
|
52
|
+
for (const { operand: v, verdict: O, worst: k } of y) {
|
|
53
|
+
const w = v.reference ? O : ve(O, k);
|
|
54
|
+
s = ve(s, w);
|
|
53
55
|
}
|
|
54
|
-
g =
|
|
55
|
-
const
|
|
56
|
-
if (!g && n.operator === "quotient" &&
|
|
57
|
-
const
|
|
58
|
-
l =
|
|
59
|
-
const
|
|
56
|
+
g = y.find((v) => v.absence)?.absence;
|
|
57
|
+
const R = y[1];
|
|
58
|
+
if (!g && n.operator === "quotient" && R.value === 0 && (g = { kind: "zero", label: e.quantities.get(R.operand.key).label }), !g) {
|
|
59
|
+
const v = n.operands.map((w) => w.negated === !0);
|
|
60
|
+
l = he(n.operator, y.map((w) => w.value), v);
|
|
61
|
+
const O = he(
|
|
60
62
|
n.operator,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
),
|
|
64
|
-
p =
|
|
63
|
+
y.map((w) => Fe(e.quantities.get(w.operand.key), w.shown)),
|
|
64
|
+
v
|
|
65
|
+
), k = we(n, l);
|
|
66
|
+
p = X(n, O, k) !== X(n, l, k);
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
|
-
const
|
|
69
|
+
const C = { target: n.target, limits: n.limits }, h = n.target !== void 0 || (n.limits?.length ?? 0) > 0 ? Me(l, C) : void 0, P = (n.limits?.length ?? 0) > 0 ? h.verdict : l === null ? "unknown" : void 0, W = {
|
|
68
70
|
value: l,
|
|
69
71
|
absence: g,
|
|
70
|
-
shown: l === null ? null :
|
|
72
|
+
shown: l === null ? null : X(n, l),
|
|
71
73
|
approximate: p,
|
|
72
|
-
assessment:
|
|
73
|
-
verdict:
|
|
74
|
-
worst: s
|
|
74
|
+
assessment: h,
|
|
75
|
+
verdict: P,
|
|
76
|
+
worst: s,
|
|
77
|
+
quality: S
|
|
75
78
|
};
|
|
76
|
-
return t.set(i,
|
|
79
|
+
return t.set(i, W), W;
|
|
77
80
|
};
|
|
78
|
-
for (const i of e.quantities.keys())
|
|
81
|
+
for (const i of e.quantities.keys()) f(i);
|
|
79
82
|
return t;
|
|
80
83
|
}
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
function Ue() {
|
|
85
|
+
try {
|
|
86
|
+
return process.env.NODE_ENV !== "production";
|
|
87
|
+
} catch {
|
|
88
|
+
return !1;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const Ie = Ue(), _e = /* @__PURE__ */ new Set();
|
|
92
|
+
function Pe(e, t) {
|
|
93
|
+
!Ie || _e.has(e) || (_e.add(e), console.warn(`@umriss-ui/calculation: ${t}`));
|
|
94
|
+
}
|
|
95
|
+
const be = 4;
|
|
96
|
+
function Ve(e, t, f) {
|
|
83
97
|
const i = e.operands[t];
|
|
84
98
|
if (i.previous) return;
|
|
85
|
-
const
|
|
86
|
-
if (
|
|
87
|
-
const l =
|
|
99
|
+
const u = e.operator, n = t === 0;
|
|
100
|
+
if (u !== "sum" && u !== "difference") return n ? void 0 : { operator: u, negated: !1 };
|
|
101
|
+
const l = u === "difference" ? !n : i.negated === !0, g = new Set(f.filter((s) => s !== null && s !== 0).map(Math.sign)), p = g.size === 1 ? { operator: "sum", negated: l !== g.has(-1), unsigned: !0 } : { operator: "sum", negated: l };
|
|
88
102
|
return n && !p.negated ? void 0 : p;
|
|
89
103
|
}
|
|
90
|
-
const
|
|
104
|
+
const ze = {
|
|
91
105
|
sum: "calculationSumSymbol",
|
|
92
106
|
difference: "calculationDifferenceSymbol",
|
|
93
107
|
product: "calculationProductSymbol",
|
|
94
108
|
quotient: "calculationQuotientSymbol"
|
|
95
|
-
},
|
|
109
|
+
}, He = {
|
|
96
110
|
sum: "calculationSumWord",
|
|
97
111
|
difference: "calculationDifferenceWord",
|
|
98
112
|
product: "calculationProductWord",
|
|
99
113
|
quotient: "calculationQuotientWord"
|
|
100
114
|
};
|
|
101
|
-
function
|
|
115
|
+
function Qe(e, t) {
|
|
116
|
+
return e === "bad" ? t.qualityBad : e === "uncertain" ? t.qualityUncertain : void 0;
|
|
117
|
+
}
|
|
118
|
+
function ee(e, t) {
|
|
102
119
|
switch (e) {
|
|
103
120
|
case "alarm":
|
|
104
121
|
return t.verdictAlarm;
|
|
@@ -110,314 +127,319 @@ function K(e, t) {
|
|
|
110
127
|
return t.verdictOk;
|
|
111
128
|
}
|
|
112
129
|
}
|
|
113
|
-
function
|
|
130
|
+
function ne(e, t, f) {
|
|
114
131
|
const i = e.negated ? "difference" : e.operator;
|
|
115
|
-
return
|
|
132
|
+
return f[(t ? He : ze)[i]];
|
|
116
133
|
}
|
|
117
|
-
function
|
|
134
|
+
function Ge(e, t) {
|
|
118
135
|
return e.kind === "missing" ? t.calculationMissing(e.label) : t.calculationDivisionByZero(e.label);
|
|
119
136
|
}
|
|
120
|
-
function
|
|
121
|
-
const
|
|
122
|
-
return
|
|
137
|
+
function Ne(e, t, f, i) {
|
|
138
|
+
const u = e.format === "percent" ? i : e.unit, n = f.number(t, e.decimals);
|
|
139
|
+
return u ? `${n} ${u}` : n;
|
|
123
140
|
}
|
|
124
|
-
function
|
|
141
|
+
function Ye(e, t, f, i, u, n, l, g = () => {
|
|
125
142
|
}) {
|
|
126
|
-
const p = e.quantities.get(
|
|
127
|
-
const
|
|
128
|
-
return
|
|
129
|
-
}, h = (
|
|
143
|
+
const p = e.quantities.get(f), s = t.get(f), S = (N, q) => N.shown !== null && q?.unsigned ? Math.abs(N.shown) : N.shown, C = (N, q, _, F) => {
|
|
144
|
+
const z = S(q, F);
|
|
145
|
+
return z === null ? _ ? n.verdictUnknown : n.statAbsentValue : Ne(N, z, u, _ ? n.calculationPercent : "%");
|
|
146
|
+
}, h = (N) => {
|
|
130
147
|
if (i || !p.operator) return {};
|
|
131
148
|
if (p.operands.length === 0) return { names: n.calculationNoOperands };
|
|
132
|
-
if (!
|
|
149
|
+
if (!N && p.operands.length > be)
|
|
133
150
|
return { names: n.calculationOperandCount(p.operands.length) };
|
|
134
|
-
const
|
|
135
|
-
const
|
|
136
|
-
return
|
|
151
|
+
const q = (_) => p.operands.map((F, z) => {
|
|
152
|
+
const j = e.quantities.get(F.key), Q = g(z);
|
|
153
|
+
return Q ? `${ne(Q, N, n)} ${_(j, Q)}` : _(j);
|
|
137
154
|
}).join(" ");
|
|
138
155
|
return {
|
|
139
|
-
names:
|
|
140
|
-
numbers:
|
|
156
|
+
names: q((_) => _.label),
|
|
157
|
+
numbers: q((_, F) => C(_, t.get(_.key), N, F))
|
|
141
158
|
};
|
|
142
|
-
},
|
|
143
|
-
const
|
|
144
|
-
if (
|
|
145
|
-
const _ =
|
|
146
|
-
return
|
|
147
|
-
},
|
|
148
|
-
(l ? `${
|
|
149
|
-
s.verdict !== void 0 && s.verdict !== "unknown" ?
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
159
|
+
}, P = (N) => {
|
|
160
|
+
const q = s.assessment?.deviation;
|
|
161
|
+
if (q === void 0 || p.target === void 0) return;
|
|
162
|
+
const _ = Ne(p, X(p, p.target), u, N ? n.calculationPercent : "%");
|
|
163
|
+
return q > 0 ? n.calculationAboveTarget(_) : q < 0 ? n.calculationBelowTarget(_) : n.calculationOnTarget(_);
|
|
164
|
+
}, W = h(!1).names, y = W === void 0 || p.operands.length === 0 || p.operands.length > be ? W : `= ${W}`, R = h(!0), v = Qe(s.quality, n), O = s.absence ? Ge(s.absence, n) : void 0, k = ` ${n.calculationEquals} `, w = s.approximate ? `${n.calculationApproximately} ${C(p, s, !0, l)}` : C(p, s, !0, l), J = [
|
|
165
|
+
(l ? `${ne(l, !0, n)} ` : "") + p.label + k + [R.names, R.numbers, w].filter(Boolean).join(`,${k}`),
|
|
166
|
+
s.verdict !== void 0 && s.verdict !== "unknown" ? ee(s.verdict, n) : void 0,
|
|
167
|
+
v,
|
|
168
|
+
P(!0),
|
|
169
|
+
O
|
|
170
|
+
].filter(Boolean).join(", "), A = s.shown === null ? void 0 : p.format === "percent" ? "%" : p.unit, V = (N) => N === null ? n.statAbsentValue : u.number(N, p.decimals);
|
|
171
|
+
return { amount: V(S(s, l)), ownAmount: V(s.shown), unit: A, names: y, target: P(!1), quality: v, reason: O, sentence: J, spokenNames: R.names, spokenNumber: w };
|
|
154
172
|
}
|
|
155
|
-
function
|
|
156
|
-
const n =
|
|
157
|
-
(
|
|
158
|
-
);
|
|
159
|
-
return `${g}: ${p.join("; ")}`;
|
|
173
|
+
function Ze(e, t, f, i, u) {
|
|
174
|
+
const n = u ? `${ne(u, !0, i)} ` : "", l = t[0].spokenNames, g = n + e + (l === void 0 ? "" : ` ${i.calculationEquals} ${l}`), p = f.map(
|
|
175
|
+
(S, C) => [`${S.label} ${t[C].spokenNumber}`, t[C].reason].filter(Boolean).join(", ")
|
|
176
|
+
), s = t[0].quality;
|
|
177
|
+
return `${g}: ${p.join("; ")}${s ? `, ${s}` : ""}`;
|
|
160
178
|
}
|
|
161
|
-
const
|
|
162
|
-
frame:
|
|
163
|
-
calculation:
|
|
164
|
-
line:
|
|
165
|
-
assessment:
|
|
166
|
-
disclosure:
|
|
167
|
-
amount:
|
|
168
|
-
list:
|
|
169
|
-
item:
|
|
170
|
-
derivation:
|
|
171
|
-
labelCell:
|
|
172
|
-
names:
|
|
173
|
-
operator:
|
|
174
|
-
unit:
|
|
175
|
-
label:
|
|
176
|
-
approximate:
|
|
177
|
-
target:
|
|
178
|
-
worst:
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
179
|
+
const Je = "_frame_184xf_24 _text_18806_22", Ke = "_calculation_184xf_51", Xe = "_line_184xf_86", et = "_assessment_184xf_98", tt = "_disclosure_184xf_107", nt = "_amount_184xf_90", at = "_list_184xf_128", st = "_item_184xf_129", ot = "_derivation_184xf_130", it = "_labelCell_184xf_90", rt = "_names_184xf_90", lt = "_operator_184xf_90", ct = "_unit_184xf_90", ut = "_label_184xf_90", dt = "_approximate_184xf_360", mt = "_target_184xf_102", ft = "_worst_184xf_102", pt = "_quality_184xf_102", ht = "_head_184xf_539", vt = "_headCell_184xf_546", gt = "_headUnit_184xf_559", _t = "_notes_184xf_566", bt = "_freshness_184xf_580", Nt = "_headLabel_184xf_610", o = {
|
|
180
|
+
frame: Je,
|
|
181
|
+
calculation: Ke,
|
|
182
|
+
line: Xe,
|
|
183
|
+
assessment: et,
|
|
184
|
+
disclosure: tt,
|
|
185
|
+
amount: nt,
|
|
186
|
+
list: at,
|
|
187
|
+
item: st,
|
|
188
|
+
derivation: ot,
|
|
189
|
+
labelCell: it,
|
|
190
|
+
names: rt,
|
|
191
|
+
operator: lt,
|
|
192
|
+
unit: ct,
|
|
193
|
+
label: ut,
|
|
194
|
+
approximate: dt,
|
|
195
|
+
target: mt,
|
|
196
|
+
worst: ft,
|
|
197
|
+
quality: pt,
|
|
198
|
+
head: ht,
|
|
199
|
+
headCell: vt,
|
|
200
|
+
headUnit: gt,
|
|
201
|
+
notes: _t,
|
|
202
|
+
freshness: bt,
|
|
203
|
+
headLabel: Nt
|
|
204
|
+
}, xt = 10, Z = (e) => 4 + 2 * e, yt = (e) => 5 + 2 * e, wt = { ok: "success", unknown: "neutral", warning: "warning", alarm: "danger" }, qt = (...e) => e.filter(Boolean).join(" ");
|
|
205
|
+
function $t({ asOf: e, ages: t }) {
|
|
206
|
+
const f = xe(), i = ye(), u = Le(e, t), n = u.freshness === "lost" ? i.freshnessDisconnected : u.freshness === "stale" ? i.freshnessStale : i.freshnessFresh;
|
|
207
|
+
return /* @__PURE__ */ $("span", { className: o.freshness, "data-freshness": u.freshness, children: [
|
|
189
208
|
n,
|
|
190
|
-
|
|
209
|
+
u.age !== null && ` · ${f.relative(u.age)}`
|
|
191
210
|
] });
|
|
192
211
|
}
|
|
193
|
-
function
|
|
212
|
+
function At({
|
|
194
213
|
model: e,
|
|
195
214
|
ref: t,
|
|
196
|
-
className:
|
|
215
|
+
className: f,
|
|
197
216
|
style: i,
|
|
198
|
-
density:
|
|
217
|
+
density: u,
|
|
199
218
|
"aria-label": n,
|
|
200
219
|
"aria-labelledby": l,
|
|
201
220
|
"aria-describedby": g,
|
|
202
221
|
...p
|
|
203
222
|
}) {
|
|
204
|
-
|
|
223
|
+
!n && !l && Pe("no-name", "A Calculation has no accessible name: give it aria-label or aria-labelledby.");
|
|
224
|
+
const s = e.metrics, S = Te(u, "regular") === "compact", C = xe(), h = ye(), P = Ce(), W = Re(e).map((a) => ({ view: a, results: je(a) })), [y, R] = se(() => /* @__PURE__ */ new Set()), [v, O] = se(null), k = ke(null), w = fe(
|
|
205
225
|
(a) => {
|
|
206
|
-
|
|
226
|
+
k.current = a, typeof t == "function" ? t(a) : t && (t.current = a);
|
|
207
227
|
},
|
|
208
228
|
[t]
|
|
209
|
-
), [
|
|
210
|
-
const a =
|
|
211
|
-
if (!a ||
|
|
212
|
-
|
|
229
|
+
), [ie, J] = se(!1), A = s?.length ?? 0, V = fe(() => {
|
|
230
|
+
const a = k.current, d = a && A > 0 ? getComputedStyle(a.firstElementChild).gridTemplateColumns.split(" ").map(parseFloat) : [], m = Z(A) - 1;
|
|
231
|
+
if (!a || d.length <= m || d.some((x) => !Number.isFinite(x))) {
|
|
232
|
+
J(!1);
|
|
213
233
|
return;
|
|
214
234
|
}
|
|
215
|
-
const
|
|
216
|
-
let
|
|
217
|
-
const
|
|
235
|
+
const E = d.slice(2, m).reduce((x, T) => x + T, 0);
|
|
236
|
+
let c = 0;
|
|
237
|
+
const B = document.createRange();
|
|
218
238
|
for (const x of a.querySelectorAll(`.${o.label}`)) {
|
|
219
|
-
|
|
220
|
-
const
|
|
221
|
-
if (
|
|
222
|
-
const
|
|
223
|
-
|
|
239
|
+
B.selectNodeContents(x);
|
|
240
|
+
const T = [...B.getClientRects()].reduce((L, D) => L + D.width, 0);
|
|
241
|
+
if (T === 0) continue;
|
|
242
|
+
const G = x.parentElement, H = x.getBoundingClientRect().left - G.getBoundingClientRect().left;
|
|
243
|
+
c = Math.max(c, H + T + parseFloat(getComputedStyle(G).paddingRight));
|
|
224
244
|
}
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
}, [
|
|
228
|
-
|
|
229
|
-
const a =
|
|
230
|
-
if (!a ||
|
|
231
|
-
const
|
|
232
|
-
return
|
|
233
|
-
}, [
|
|
234
|
-
const
|
|
235
|
-
const
|
|
236
|
-
return
|
|
237
|
-
}),
|
|
245
|
+
const M = parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
246
|
+
J(a.clientWidth - E < Math.min(c, xt * M));
|
|
247
|
+
}, [A]);
|
|
248
|
+
Ae(() => V()), Ee(() => {
|
|
249
|
+
const a = k.current;
|
|
250
|
+
if (!a || A === 0) return;
|
|
251
|
+
const d = new ResizeObserver(() => V());
|
|
252
|
+
return d.observe(a), () => d.disconnect();
|
|
253
|
+
}, [V, A]);
|
|
254
|
+
const N = (a) => R((d) => {
|
|
255
|
+
const m = new Set(d);
|
|
256
|
+
return m.delete(a) || m.add(a), m;
|
|
257
|
+
}), q = (a, d) => Ve(
|
|
238
258
|
a,
|
|
239
|
-
|
|
240
|
-
|
|
259
|
+
d,
|
|
260
|
+
W.map(({ results: m }) => m.get(a.operands[d].key).shown)
|
|
241
261
|
);
|
|
242
|
-
let
|
|
243
|
-
const
|
|
244
|
-
/* @__PURE__ */
|
|
262
|
+
let _ = !1;
|
|
263
|
+
const F = (a, d) => a.map(({ own: m, text: E }, c) => [
|
|
264
|
+
/* @__PURE__ */ $(
|
|
245
265
|
"span",
|
|
246
266
|
{
|
|
247
267
|
className: o.amount,
|
|
248
268
|
"aria-hidden": "true",
|
|
249
|
-
"data-verdict":
|
|
250
|
-
"data-
|
|
251
|
-
|
|
269
|
+
"data-verdict": m.verdict,
|
|
270
|
+
"data-quality": m.quality === "good" ? void 0 : m.quality,
|
|
271
|
+
"data-later": c > 0 ? "" : void 0,
|
|
272
|
+
style: s ? { "--_calculation-column": Z(c) } : void 0,
|
|
252
273
|
children: [
|
|
253
|
-
|
|
254
|
-
|
|
274
|
+
m.approximate && /* @__PURE__ */ r(De, { content: h.calculationApproximateNote, children: /* @__PURE__ */ r("span", { className: o.approximate, children: "≈" }) }),
|
|
275
|
+
d ? E.ownAmount : E.amount
|
|
255
276
|
]
|
|
256
277
|
},
|
|
257
|
-
`amount-${
|
|
278
|
+
`amount-${c}`
|
|
258
279
|
),
|
|
259
|
-
/* @__PURE__ */
|
|
280
|
+
/* @__PURE__ */ r(
|
|
260
281
|
"span",
|
|
261
282
|
{
|
|
262
283
|
className: o.unit,
|
|
263
284
|
"aria-hidden": "true",
|
|
264
|
-
style: s ? { "--_calculation-column":
|
|
265
|
-
"data-last": s &&
|
|
266
|
-
children: s && !
|
|
285
|
+
style: s ? { "--_calculation-column": yt(c) } : void 0,
|
|
286
|
+
"data-last": s && c === a.length - 1 ? "" : void 0,
|
|
287
|
+
children: s && !d ? void 0 : E.unit
|
|
267
288
|
},
|
|
268
|
-
`unit-${
|
|
289
|
+
`unit-${c}`
|
|
269
290
|
)
|
|
270
|
-
]),
|
|
271
|
-
const
|
|
272
|
-
own:
|
|
273
|
-
text:
|
|
274
|
-
})), { own:
|
|
275
|
-
|
|
276
|
-
const
|
|
277
|
-
(b,
|
|
278
|
-
) : [],
|
|
279
|
-
!
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
!
|
|
283
|
-
].filter(Boolean), de =
|
|
291
|
+
]), z = (a, d) => v === null ? void 0 : a === v ? "use" : d === v ? "operand" : void 0, j = (a, d, m, E) => {
|
|
292
|
+
const c = e.quantities.get(a), B = W.map(({ view: b, results: I }) => ({
|
|
293
|
+
own: I.get(a),
|
|
294
|
+
text: Ye(b, I, a, d, C, h, m.position, (Se) => q(c, Se))
|
|
295
|
+
})), { own: M, text: x } = B[0], T = c.operator !== void 0 && !d, G = a === e.result && !d, H = T && c.operands.length > 0 && (c.interim ? m.flat : G), L = T && !H && c.operands.length > 0, D = L && y.has(a);
|
|
296
|
+
_ ||= L;
|
|
297
|
+
const re = `${P}-${a}`, ae = { depth: H ? m.depth : m.depth + 1, flat: !1, parent: a }, K = T ? c.operands.find((b) => b.previous) : void 0, le = K && m.flat ? j(K.key, !1, { ...m, parent: a, position: void 0 }, `${E}-c`) : [], $e = K && !m.flat ? j(K.key, !1, { ...ae, flat: !0 }, `${E}-c`) : [], ce = T ? c.operands.map(
|
|
298
|
+
(b, I) => b.previous ? null : j(b.key, b.reference, { ...ae, position: q(c, I) }, `${E}-${I}`)
|
|
299
|
+
) : [], Y = L && !D && M.worst !== void 0 && te(M.worst) > te(M.verdict ?? "ok") ? M.worst : void 0, U = d ? void 0 : c.given, Oe = m.position ? ne(m.position, !1, h) : void 0, ue = [
|
|
300
|
+
!d && c.explanation !== void 0 && /* @__PURE__ */ r("span", { children: c.explanation }, "explanation"),
|
|
301
|
+
U?.source !== void 0 && /* @__PURE__ */ r("span", { children: h.calculationSource(U.source) }, "source"),
|
|
302
|
+
U?.asOf !== void 0 && (U.ages !== void 0 ? /* @__PURE__ */ r($t, { asOf: U.asOf, ages: U.ages }, "asOf") : /* @__PURE__ */ r("span", { children: h.asOfAgo(C.dateTime(new Date(U.asOf), !1)) }, "asOf")),
|
|
303
|
+
!d && c.aside !== void 0 && /* @__PURE__ */ r("span", { children: c.aside }, "aside")
|
|
304
|
+
].filter(Boolean), de = G ? "result" : c.interim && !d && m.flat ? "interim" : void 0, me = /* @__PURE__ */ $(
|
|
284
305
|
"div",
|
|
285
306
|
{
|
|
286
307
|
className: o.line,
|
|
287
|
-
style: { "--_calculation-depth":
|
|
288
|
-
"data-inner":
|
|
308
|
+
style: { "--_calculation-depth": m.depth },
|
|
309
|
+
"data-inner": m.depth > 0 ? "" : void 0,
|
|
289
310
|
"data-kind": de,
|
|
290
|
-
"data-foldable":
|
|
291
|
-
"data-reference":
|
|
292
|
-
"data-emphasis":
|
|
293
|
-
"data-rule": !
|
|
294
|
-
"data-mark":
|
|
295
|
-
onPointerEnter: () =>
|
|
296
|
-
onPointerLeave: () =>
|
|
297
|
-
onFocus: () =>
|
|
298
|
-
onBlur: () =>
|
|
299
|
-
onClick:
|
|
300
|
-
window.getSelection()?.toString() ||
|
|
311
|
+
"data-foldable": L ? "" : void 0,
|
|
312
|
+
"data-reference": d ? "" : void 0,
|
|
313
|
+
"data-emphasis": d ? void 0 : c.emphasis,
|
|
314
|
+
"data-rule": !d && c.rule ? "" : void 0,
|
|
315
|
+
"data-mark": z(a, m.parent),
|
|
316
|
+
onPointerEnter: () => O(a),
|
|
317
|
+
onPointerLeave: () => O(null),
|
|
318
|
+
onFocus: () => O(a),
|
|
319
|
+
onBlur: () => O(null),
|
|
320
|
+
onClick: L ? () => {
|
|
321
|
+
window.getSelection()?.toString() || N(a);
|
|
301
322
|
} : void 0,
|
|
302
323
|
children: [
|
|
303
|
-
/* @__PURE__ */
|
|
304
|
-
s ?
|
|
305
|
-
|
|
306
|
-
|
|
324
|
+
/* @__PURE__ */ r(We, { children: [
|
|
325
|
+
s ? Ze(c.label, B.map((b) => b.text), s, h, m.position) : x.sentence,
|
|
326
|
+
B.some((b) => b.own.approximate) && h.calculationApproximateNote,
|
|
327
|
+
Y !== void 0 && h.calculationWorstInside(ee(Y, h))
|
|
307
328
|
].filter(Boolean).join(". ") }),
|
|
308
|
-
/* @__PURE__ */
|
|
309
|
-
|
|
329
|
+
/* @__PURE__ */ $("span", { className: o.labelCell, children: [
|
|
330
|
+
L ? /* @__PURE__ */ r(
|
|
310
331
|
"button",
|
|
311
332
|
{
|
|
312
333
|
type: "button",
|
|
313
334
|
className: o.disclosure,
|
|
314
|
-
"aria-expanded":
|
|
315
|
-
"aria-controls":
|
|
316
|
-
"aria-label": (
|
|
317
|
-
children: /* @__PURE__ */
|
|
335
|
+
"aria-expanded": D,
|
|
336
|
+
"aria-controls": re,
|
|
337
|
+
"aria-label": (D ? h.calculationHideDerivation : h.calculationShowDerivation)(c.label),
|
|
338
|
+
children: /* @__PURE__ */ r(Be, { "data-open": D ? "" : void 0 })
|
|
318
339
|
}
|
|
319
|
-
) : /* @__PURE__ */
|
|
320
|
-
/* @__PURE__ */
|
|
340
|
+
) : /* @__PURE__ */ r("span", { className: o.disclosure, "aria-hidden": "true" }),
|
|
341
|
+
/* @__PURE__ */ r("span", { className: o.label, "aria-hidden": "true", children: c.label })
|
|
321
342
|
] }),
|
|
322
|
-
/* @__PURE__ */
|
|
323
|
-
/* @__PURE__ */
|
|
324
|
-
|
|
325
|
-
/* @__PURE__ */
|
|
343
|
+
/* @__PURE__ */ r("span", { className: o.names, "aria-hidden": "true", children: T && !H && !D ? x.names : void 0 }),
|
|
344
|
+
/* @__PURE__ */ r("span", { className: o.operator, "aria-hidden": "true", children: Oe }),
|
|
345
|
+
F(B, de !== void 0),
|
|
346
|
+
/* @__PURE__ */ $("span", { className: o.assessment, "aria-hidden": "true", children: [
|
|
326
347
|
s ? (
|
|
327
348
|
/* Short: which metric. The sentence carries the full reason. */
|
|
328
349
|
s.map(
|
|
329
|
-
(b,
|
|
350
|
+
(b, I) => B[I].own.absence && /* @__PURE__ */ r(oe, { children: h.calculationMissing(b.unit ?? b.label) }, b.id)
|
|
330
351
|
)
|
|
331
|
-
) : x.reason !== void 0 ? /* @__PURE__ */
|
|
332
|
-
x.target !== void 0 && /* @__PURE__ */
|
|
333
|
-
|
|
352
|
+
) : x.reason !== void 0 ? /* @__PURE__ */ r(oe, { children: x.reason }) : M.verdict !== void 0 && /* @__PURE__ */ r(oe, { tone: wt[M.verdict], children: ee(M.verdict, h) }),
|
|
353
|
+
x.target !== void 0 && /* @__PURE__ */ r("span", { className: o.target, children: x.target }),
|
|
354
|
+
x.quality !== void 0 && /* @__PURE__ */ r("span", { className: o.quality, "data-quality": M.quality, children: x.quality }),
|
|
355
|
+
Y !== void 0 && /* @__PURE__ */ r("span", { className: o.worst, "data-verdict": Y, children: h.calculationWorstInside(ee(Y, h)) })
|
|
334
356
|
] }),
|
|
335
|
-
|
|
357
|
+
ue.length > 0 && /* A click here - on a link in the aside, on a sparkline - is the
|
|
336
358
|
caller's, not a fold. */
|
|
337
|
-
/* @__PURE__ */
|
|
359
|
+
/* @__PURE__ */ r("span", { className: o.notes, onClick: (b) => b.stopPropagation(), children: ue })
|
|
338
360
|
]
|
|
339
361
|
}
|
|
340
362
|
);
|
|
341
|
-
return
|
|
342
|
-
...
|
|
343
|
-
/* @__PURE__ */
|
|
344
|
-
/* @__PURE__ */
|
|
345
|
-
|
|
346
|
-
] },
|
|
363
|
+
return H ? [
|
|
364
|
+
...le,
|
|
365
|
+
/* @__PURE__ */ $("li", { className: o.item, children: [
|
|
366
|
+
/* @__PURE__ */ r("ul", { className: o.list, children: ce }),
|
|
367
|
+
me
|
|
368
|
+
] }, E)
|
|
347
369
|
] : [
|
|
348
|
-
...
|
|
349
|
-
/* @__PURE__ */
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
370
|
+
...le,
|
|
371
|
+
/* @__PURE__ */ $("li", { className: o.item, "data-open": D ? "" : void 0, style: { "--_calculation-depth": m.depth }, children: [
|
|
372
|
+
me,
|
|
373
|
+
L && /* @__PURE__ */ $("ul", { id: re, className: o.derivation, hidden: !D, children: [
|
|
374
|
+
$e,
|
|
353
375
|
ce,
|
|
354
|
-
/* @__PURE__ */
|
|
376
|
+
/* @__PURE__ */ r("li", { className: o.item, "aria-hidden": "true", children: /* @__PURE__ */ $(
|
|
355
377
|
"div",
|
|
356
378
|
{
|
|
357
379
|
className: o.line,
|
|
358
|
-
style: { "--_calculation-depth":
|
|
380
|
+
style: { "--_calculation-depth": ae.depth },
|
|
359
381
|
"data-inner": "",
|
|
360
382
|
"data-closing": "",
|
|
361
|
-
"data-mark":
|
|
383
|
+
"data-mark": v === a ? "use" : void 0,
|
|
362
384
|
children: [
|
|
363
|
-
/* @__PURE__ */
|
|
364
|
-
/* @__PURE__ */
|
|
365
|
-
/* @__PURE__ */
|
|
385
|
+
/* @__PURE__ */ $("span", { className: o.labelCell, children: [
|
|
386
|
+
/* @__PURE__ */ r("span", { className: o.disclosure }),
|
|
387
|
+
/* @__PURE__ */ $("span", { className: o.label, children: [
|
|
366
388
|
"= ",
|
|
367
|
-
|
|
389
|
+
c.label
|
|
368
390
|
] })
|
|
369
391
|
] }),
|
|
370
|
-
/* @__PURE__ */
|
|
371
|
-
/* @__PURE__ */
|
|
372
|
-
|
|
392
|
+
/* @__PURE__ */ r("span", { className: o.names }),
|
|
393
|
+
/* @__PURE__ */ r("span", { className: o.operator }),
|
|
394
|
+
F(B, !0)
|
|
373
395
|
]
|
|
374
396
|
}
|
|
375
397
|
) })
|
|
376
398
|
] })
|
|
377
|
-
] },
|
|
399
|
+
] }, E)
|
|
378
400
|
];
|
|
379
|
-
},
|
|
401
|
+
}, Q = j(e.result, !1, { depth: 0, flat: !0, parent: null }, "r");
|
|
380
402
|
return (
|
|
381
403
|
/* The frame is the surface and the container the layout measures itself
|
|
382
404
|
against; the list inside it is the statement. */
|
|
383
|
-
/* @__PURE__ */
|
|
405
|
+
/* @__PURE__ */ r(
|
|
384
406
|
"div",
|
|
385
407
|
{
|
|
386
408
|
...p,
|
|
387
|
-
ref:
|
|
388
|
-
className:
|
|
409
|
+
ref: w,
|
|
410
|
+
className: qt(o.frame, f),
|
|
389
411
|
style: s ? {
|
|
390
|
-
"--_calculation-figure-tracks": Array(
|
|
391
|
-
"--_calculation-figures-end":
|
|
392
|
-
"--_calculation-assessment-column":
|
|
412
|
+
"--_calculation-figure-tracks": Array(A * 2).fill("auto").join(" "),
|
|
413
|
+
"--_calculation-figures-end": Z(A),
|
|
414
|
+
"--_calculation-assessment-column": Z(A),
|
|
393
415
|
...i
|
|
394
416
|
} : i,
|
|
395
|
-
"data-still":
|
|
396
|
-
"data-metrics": s ?
|
|
397
|
-
"data-two-lines":
|
|
398
|
-
"data-compact":
|
|
399
|
-
children: /* @__PURE__ */
|
|
417
|
+
"data-still": _ ? void 0 : "",
|
|
418
|
+
"data-metrics": s ? A : void 0,
|
|
419
|
+
"data-two-lines": ie ? "" : void 0,
|
|
420
|
+
"data-compact": S ? "" : void 0,
|
|
421
|
+
children: /* @__PURE__ */ $("ul", { className: o.calculation, "aria-label": n, "aria-labelledby": l, "aria-describedby": g, children: [
|
|
400
422
|
s && /* The head names each metric and its unit above its column. Every
|
|
401
423
|
row's sentence names them too, so the head is for the eye. */
|
|
402
|
-
/* @__PURE__ */
|
|
424
|
+
/* @__PURE__ */ r("li", { className: o.item, "aria-hidden": "true", children: /* @__PURE__ */ r("div", { className: o.head, children: s.map((a, d) => /* @__PURE__ */ $(
|
|
403
425
|
"span",
|
|
404
426
|
{
|
|
405
427
|
className: o.headCell,
|
|
406
428
|
"data-unit": a.unit === void 0 ? void 0 : "",
|
|
407
|
-
style: { "--_calculation-column":
|
|
429
|
+
style: { "--_calculation-column": Z(d) },
|
|
408
430
|
children: [
|
|
409
|
-
/* @__PURE__ */
|
|
410
|
-
a.unit !== void 0 && /* @__PURE__ */
|
|
431
|
+
/* @__PURE__ */ r("span", { className: o.headLabel, children: a.label }),
|
|
432
|
+
a.unit !== void 0 && /* @__PURE__ */ r("span", { className: o.headUnit, children: a.unit })
|
|
411
433
|
]
|
|
412
434
|
},
|
|
413
435
|
a.id
|
|
414
436
|
)) }) }),
|
|
415
|
-
|
|
437
|
+
Q
|
|
416
438
|
] })
|
|
417
439
|
}
|
|
418
440
|
)
|
|
419
441
|
);
|
|
420
442
|
}
|
|
421
443
|
export {
|
|
422
|
-
|
|
444
|
+
At as CalculationView
|
|
423
445
|
};
|