@loadmap/react 0.40.0 → 0.42.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/README.md +51 -32
- package/dist/{Loadmap-DbAbcbNc.js → Loadmap-CM8HshXp.js} +1287 -1897
- package/dist/{Loadmap-BMlU1-mr.d.ts → Loadmap-CyxcmVoc.d.ts} +69 -16
- package/dist/camera-RqbxjjVv.js +209 -0
- package/dist/framePanels-BL9_bQ8A.js +24 -0
- package/dist/index.d.ts +128 -37
- package/dist/index.js +5 -2
- package/dist/later-_c1UnFld.js +195 -0
- package/dist/panels-CemD3oVS.js +479 -0
- package/dist/scenarios-D7DDcwS5.js +521 -0
- package/dist/source.d.ts +1 -1
- package/dist/source.js +5 -2
- package/dist/story-mK-TEB6j.js +127 -0
- package/dist/{zoom-DGmIQ7aO.js → zoom-36lBVilV.js} +45 -8
- package/package.json +5 -5
- package/dist/later-DpL22rlH.js +0 -504
|
@@ -1,219 +1,95 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as ease, c as stepDetail, d as storySeconds, f as targets, g as rankLabels, h as handoverText, i as changeSeconds, l as stepSeconds, m as edge, n as between, o as framing, p as whole, r as boxComponent, s as showsComponent, t as SHOTS, u as stepTitle } from "./camera-RqbxjjVv.js";
|
|
2
|
+
import { fmt, monthOf, multiple, multiples, pct } from "@loadmap/core/format";
|
|
3
3
|
import { anchor, directionOf, labelsAt, layout, legPath, localElk, pointAt, structureKey } from "@loadmap/layout";
|
|
4
|
-
import { Suspense, lazy, memo, useCallback, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
4
|
+
import { Children, Suspense, createContext, isValidElement, lazy, memo, use, useCallback, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
5
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { arrange, closing, morph, shapesOf } from "@loadmap/layout/internal";
|
|
7
7
|
import { createSim } from "@loadmap/sim";
|
|
8
|
-
// src/
|
|
9
|
-
/** Badges after the limit: the two next in line. */
|
|
10
|
-
const BADGES = 2;
|
|
11
|
-
const ORDINAL = [
|
|
12
|
-
"",
|
|
13
|
-
"limit",
|
|
14
|
-
"2nd",
|
|
15
|
-
"3rd"
|
|
16
|
-
];
|
|
17
|
-
/** Where a component reaches the target, on the pessimistic edge the ranking uses. */
|
|
18
|
-
const edge = (c) => c.targetRange?.low ?? c.target;
|
|
19
|
-
/**
|
|
20
|
-
* The limit and the next two in line, by component: the multiple at which each reaches the target, the number the
|
|
21
|
-
* headline gives. The next ones only when they reach it within the load's range, so a box far away wears nothing.
|
|
22
|
-
*/
|
|
23
|
-
function rankLabels(ev, model) {
|
|
24
|
-
const out = /* @__PURE__ */ new Map();
|
|
25
|
-
const first = ev.firstLimit;
|
|
26
|
-
if (!first) return out;
|
|
27
|
-
const at = (c) => multiple(edge(c), model.searchMax);
|
|
28
|
-
out.set(first.id, {
|
|
29
|
-
rank: 1,
|
|
30
|
-
text: `LIMIT · ${at(first)}`,
|
|
31
|
-
word: "limit"
|
|
32
|
-
});
|
|
33
|
-
ev.ranked.filter((c) => c !== first && c.util != null).slice(0, BADGES).forEach((c, i) => {
|
|
34
|
-
const x = edge(c);
|
|
35
|
-
if (x == null || !Number.isFinite(x) || x > model.load.max) return;
|
|
36
|
-
const rank = i + 2;
|
|
37
|
-
out.set(c.id, {
|
|
38
|
-
rank,
|
|
39
|
-
text: `${ORDINAL[rank]} · ${at(c)}`,
|
|
40
|
-
word: ORDINAL[rank]
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
return out;
|
|
44
|
-
}
|
|
45
|
-
/** The limit moves from one component to another between these values. */
|
|
46
|
-
const handsOver = (a, b) => !!a.firstLimit && !!b.firstLimit && a.firstLimit.id !== b.firstLimit.id;
|
|
8
|
+
// src/canvasSize.ts
|
|
47
9
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
10
|
+
* Where a canvas changes its arrangement, by its own size in pixels (never the window's): from `wide` the panels' tabs
|
|
11
|
+
* are a rail down its edge, narrower a row over the console; under `compact` the open panel is a sheet on the console;
|
|
12
|
+
* lower than `short` the bars fold to a row each; and a full screen from `pin` wide keeps the panel open. `rail` and
|
|
13
|
+
* `panel` are the widths of the rail and of the panel beside the diagram, `tabs` the height of the row of tabs,
|
|
14
|
+
* `menu` that of the row the menu of a low canvas lies in, `sheet` the least a sheet stands.
|
|
51
15
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
16
|
+
const CANVAS = {
|
|
17
|
+
compact: 520,
|
|
18
|
+
wide: 900,
|
|
19
|
+
short: 420,
|
|
20
|
+
pin: 1280,
|
|
21
|
+
rail: 44,
|
|
22
|
+
panel: 340,
|
|
23
|
+
tabs: 36,
|
|
24
|
+
menu: 40,
|
|
25
|
+
sheet: 160
|
|
26
|
+
};
|
|
27
|
+
function canvasSize(w, h, full = false) {
|
|
28
|
+
return {
|
|
29
|
+
width: w < CANVAS.compact ? "compact" : w < CANVAS.wide ? "regular" : "wide",
|
|
30
|
+
short: h < CANVAS.short,
|
|
31
|
+
pinned: full && w >= CANVAS.pin
|
|
32
|
+
};
|
|
60
33
|
}
|
|
61
|
-
// src/camera.ts
|
|
62
34
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* hands the limit to another component adds `hand`: a flight to the new limit (`HAND_FLY`), whose ring then comes in.
|
|
66
|
-
* `back` is the flight out when the reader pauses.
|
|
35
|
+
* Where the open panel stands: beside the diagram, which keeps its height, or on a compact canvas, too narrow for
|
|
36
|
+
* the two side by side, as a sheet on the console.
|
|
67
37
|
*/
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
in: 1,
|
|
71
|
-
close: .5,
|
|
72
|
-
hand: 1.8,
|
|
73
|
-
out: 1,
|
|
74
|
-
back: .4
|
|
75
|
-
};
|
|
76
|
-
/** The change is held close until the structure has moved and settled. */
|
|
77
|
-
const changeSeconds = (transition) => Math.max(1.6, transition + .7);
|
|
78
|
-
/** A step played, from the flight in to the end of its hold on the whole diagram; `hands` when it moves the limit. */
|
|
79
|
-
const stepSeconds = (st, transition, hands = false) => SHOTS.in + SHOTS.close + changeSeconds(transition) + (hands ? SHOTS.hand : 0) + SHOTS.out + st.seconds;
|
|
80
|
-
/** The whole story played from `start`, the values shown when it starts, from the first shot of the whole diagram. */
|
|
81
|
-
function storySeconds(model, start, transition) {
|
|
82
|
-
let ev = start;
|
|
83
|
-
let t = SHOTS.establish;
|
|
84
|
-
for (const st of model.story) {
|
|
85
|
-
const after = model.evaluate(st.values);
|
|
86
|
-
t += stepSeconds(st, transition, handsOver(ev, after));
|
|
87
|
-
ev = after;
|
|
88
|
-
}
|
|
89
|
-
return t;
|
|
90
|
-
}
|
|
91
|
-
const whole = (s) => ({
|
|
92
|
-
x: 0,
|
|
93
|
-
y: 0,
|
|
94
|
-
w: s.width,
|
|
95
|
-
h: s.height
|
|
96
|
-
});
|
|
97
|
-
/** The component a box stands for: its stages' component, or its own. */
|
|
98
|
-
function boxComponent(ev, n) {
|
|
99
|
-
return n.stages.map((s) => ev.stages[s]?.component).find(Boolean) ?? n.component ?? void 0;
|
|
38
|
+
function placement(size) {
|
|
39
|
+
return size.width === "compact" && !size.pinned ? "sheet" : "side";
|
|
100
40
|
}
|
|
101
|
-
/** Whether a box stands for a component: its own, and for a closed subsystem's box every component inside. */
|
|
102
|
-
const showsComponent = (ev, n, c) => n.subsystem != null ? n.stages.some((s) => ev.stages[s]?.component === c) : boxComponent(ev, n) === c;
|
|
103
41
|
/**
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
* changes state; else the first limit after it.
|
|
42
|
+
* Where the panels' tabs are: at the head of a pinned panel, a rail down the edge of a wide canvas, a row over the
|
|
43
|
+
* console of a narrower one, and one menu at the top of a low one, which has no row to give.
|
|
107
44
|
*/
|
|
108
|
-
function
|
|
109
|
-
|
|
110
|
-
const reshaped = /* @__PURE__ */ new Set();
|
|
111
|
-
for (const id of ids) if (shapes.a.nodes[id] !== shapes.b.nodes[id]) reshaped.add(id);
|
|
112
|
-
const edgesA = new Set(shapes.a.edges.map((e) => e.id));
|
|
113
|
-
const edgesB = new Set(shapes.b.edges.map((e) => e.id));
|
|
114
|
-
for (const e of [...shapes.a.edges, ...shapes.b.edges]) if (edgesA.has(e.id) !== edgesB.has(e.id)) {
|
|
115
|
-
for (const end of [e.from, e.to]) if (ids.has(end)) reshaped.add(end);
|
|
116
|
-
}
|
|
117
|
-
const of = (c) => scene.nodes.filter((n) => c && showsComponent(b, n, c)).map((n) => n.id);
|
|
118
|
-
const order = (s) => scene.nodes.filter((n) => s.has(n.id)).map((n) => n.id);
|
|
119
|
-
if (focus) return order(/* @__PURE__ */ new Set([...of(focus), ...reshaped]));
|
|
120
|
-
if (reshaped.size) return order(reshaped);
|
|
121
|
-
const turned = scene.nodes.filter((n) => {
|
|
122
|
-
const c = boxComponent(b, n);
|
|
123
|
-
return c && a.components[c]?.state !== b.components[c]?.state;
|
|
124
|
-
});
|
|
125
|
-
if (turned.length) return turned.map((n) => n.id);
|
|
126
|
-
return of(b.firstLimit?.id);
|
|
45
|
+
function tabsAt(size) {
|
|
46
|
+
return size.pinned ? "head" : size.short ? "menu" : size.width === "wide" ? "rail" : "row";
|
|
127
47
|
}
|
|
128
|
-
/** The closest the camera comes: the boxes framed never fill more than this share of the board's width. */
|
|
129
|
-
const MAX_ZOOM = 2.5;
|
|
130
|
-
/** Boxes that take more than this share of the board's width are shown on the whole diagram. */
|
|
131
|
-
const WIDE = .8;
|
|
132
48
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
49
|
+
* What a canvas of this size always keeps for itself, a panel open or not: the diagram is arranged for what these
|
|
50
|
+
* leave. Only a new size, a new mode or a bar of another height changes it, so nothing the reader opens lays the
|
|
51
|
+
* diagram out again. A canvas without panels (`panels` false) keeps only its bars.
|
|
136
52
|
*/
|
|
137
|
-
function
|
|
138
|
-
const
|
|
139
|
-
const
|
|
140
|
-
if (!ns.length || !(scene.width > 0 && scene.height > 0)) return all;
|
|
141
|
-
const x0 = Math.min(...ns.map((n) => n.x));
|
|
142
|
-
const y0 = Math.min(...ns.map((n) => n.y));
|
|
143
|
-
const x1 = Math.max(...ns.map((n) => n.x + n.w));
|
|
144
|
-
const y1 = Math.max(...ns.map((n) => n.y + n.h));
|
|
145
|
-
const aspect = scene.width / scene.height;
|
|
146
|
-
let w = Math.max(x1 - x0 + 60, (y1 - y0 + 60) * aspect, scene.width / MAX_ZOOM);
|
|
147
|
-
if (w > WIDE * scene.width && !o.hold) return all;
|
|
148
|
-
w = Math.min(w, scene.width);
|
|
149
|
-
const h = w / aspect;
|
|
150
|
-
const clamp = (v, hi) => Math.max(0, Math.min(hi, v));
|
|
53
|
+
function reserved(size, bars, panels = true) {
|
|
54
|
+
const tabs = panels ? tabsAt(size) : null;
|
|
55
|
+
const right = tabs === "head" ? CANVAS.panel : tabs === "rail" ? CANVAS.rail : 0;
|
|
151
56
|
return {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
57
|
+
top: bars.top,
|
|
58
|
+
right,
|
|
59
|
+
bottom: bars.bottom + (tabs === "row" ? CANVAS.tabs : 0),
|
|
60
|
+
left: 0
|
|
156
61
|
};
|
|
157
62
|
}
|
|
158
|
-
/** Cubic in and out. */
|
|
159
|
-
const ease = (t) => t < .5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2;
|
|
160
63
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
64
|
+
* How far the open panel reaches over a canvas of `w` by `h` pixels: beside the diagram its width, counted from the
|
|
65
|
+
* canvas's edge (so with the rail it stands behind); as a sheet its height over the console and the tabs, half of
|
|
66
|
+
* what the bars leave or all of it (`whole`).
|
|
163
67
|
*/
|
|
164
|
-
function
|
|
165
|
-
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
return {
|
|
171
|
-
x: cx - w / 2,
|
|
172
|
-
y: cy - h / 2,
|
|
173
|
-
w,
|
|
174
|
-
h
|
|
175
|
-
};
|
|
68
|
+
function reach(size, bars, w, h, whole = false) {
|
|
69
|
+
if (size.pinned) return CANVAS.panel;
|
|
70
|
+
const keeps = reserved(size, bars);
|
|
71
|
+
if (placement(size) === "side") return keeps.right + Math.round(Math.min(CANVAS.panel, (w - keeps.right) * .6));
|
|
72
|
+
const room = Math.max(0, h - keeps.top - keeps.bottom);
|
|
73
|
+
return whole ? room : Math.min(room, Math.max(CANVAS.sheet, Math.round(room / 2)));
|
|
176
74
|
}
|
|
177
|
-
/** A label's first words: "Users, × today" says "Users". */
|
|
178
|
-
const short = (label) => label.split(",")[0].trim();
|
|
179
|
-
/** At most this many changed values in a title; the rest are counted. */
|
|
180
|
-
const TITLE_VALUES = 2;
|
|
181
75
|
/**
|
|
182
|
-
*
|
|
183
|
-
*
|
|
76
|
+
* What covers the canvas now: the reserved part, and the open panel over more of it (`panel` is its extent in pixels;
|
|
77
|
+
* 0 while it is closed). Beside the diagram it stands over the rail, so its width counts from the canvas's edge; as a
|
|
78
|
+
* sheet it stands on the console, which stays in view, so its height adds to it. Fit frames the diagram in the rest.
|
|
184
79
|
*/
|
|
185
|
-
function
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
80
|
+
function covered(size, bars, panel, panels = true) {
|
|
81
|
+
const base = reserved(size, bars, panels);
|
|
82
|
+
if (!(panel > 0)) return base;
|
|
83
|
+
return placement(size) === "side" ? {
|
|
84
|
+
...base,
|
|
85
|
+
right: Math.max(base.right, panel)
|
|
86
|
+
} : {
|
|
87
|
+
...base,
|
|
88
|
+
bottom: base.bottom + panel
|
|
193
89
|
};
|
|
194
|
-
const changed = Object.keys(st.values).filter((k) => from[k] !== st.values[k]);
|
|
195
|
-
const parts = changed.slice(0, TITLE_VALUES).map((k) => {
|
|
196
|
-
const label = k === "load" ? model.load.label : model.params.find((x) => x.id === k)?.def.label ?? k;
|
|
197
|
-
const to = st.values[k];
|
|
198
|
-
const was = from[k];
|
|
199
|
-
return typeof to === "boolean" ? `${short(label)} ${say(k, to)}` : `${short(label)} ${say(k, was)} → ${say(k, to)}`;
|
|
200
|
-
});
|
|
201
|
-
if (changed.length > TITLE_VALUES) parts.push(`${changed.length - TITLE_VALUES} more`);
|
|
202
|
-
const what = parts.join(", ") || "Nothing changes";
|
|
203
|
-
return `${i + 1} · ${st.scenario && changed.length ? `${st.scenario}: ${what}` : what}`;
|
|
204
|
-
}
|
|
205
|
-
/** What the framed components show: their utilization now, or before and after the change. */
|
|
206
|
-
function stepDetail(a, b, components) {
|
|
207
|
-
return components.slice(0, 2).map((c) => {
|
|
208
|
-
const was = a.components[c];
|
|
209
|
-
const now = b?.components[c];
|
|
210
|
-
if (!was) return "";
|
|
211
|
-
const u = (x) => x == null ? "off" : pct(x);
|
|
212
|
-
return now ? `${was.name} ${u(was.util)} → ${u(now.util)}` : `${was.name} ${u(was.util)}`;
|
|
213
|
-
}).filter(Boolean).join(" · ");
|
|
214
90
|
}
|
|
215
91
|
// src/Diagram.tsx
|
|
216
|
-
const Detail = lazy(() => import("./later-
|
|
92
|
+
const Detail = lazy(() => import("./later-_c1UnFld.js").then((m) => ({ default: m.Detail })));
|
|
217
93
|
/**
|
|
218
94
|
* What draws the subsystems (frames.tsx): their frames, and what a closed one's box says and does. It comes with the
|
|
219
95
|
* first view that has a subsystem, before that view is laid out, so a page without subsystems never loads it and a
|
|
@@ -258,14 +134,17 @@ function Diagram({ lm, legend = true, onNodeClick, selected = null, canvas = fal
|
|
|
258
134
|
const { scene, engine, reducedMotion } = lm;
|
|
259
135
|
const zoom = lm.zoom || !!canvas;
|
|
260
136
|
const boxed = !!canvas;
|
|
261
|
-
const
|
|
262
|
-
top: 0,
|
|
263
|
-
right: 0,
|
|
264
|
-
bottom: 0,
|
|
265
|
-
left: 0
|
|
266
|
-
|
|
267
|
-
};
|
|
268
|
-
const
|
|
137
|
+
const sides = (i) => ({
|
|
138
|
+
top: i.top ?? 0,
|
|
139
|
+
right: i.right ?? 0,
|
|
140
|
+
bottom: i.bottom ?? 0,
|
|
141
|
+
left: i.left ?? 0
|
|
142
|
+
});
|
|
143
|
+
const given = typeof canvas === "object" ? canvas : {};
|
|
144
|
+
const inset = sides(given);
|
|
145
|
+
const reserve = given.reserve ? sides(given.reserve) : null;
|
|
146
|
+
const key = (i) => i ? `${i.top} ${i.right} ${i.bottom} ${i.left}` : "";
|
|
147
|
+
const insetKey = `${key(inset)}|${key(reserve)}|${given.scrolls ? 1 : 0}`;
|
|
269
148
|
const click = useRef(onNodeClick);
|
|
270
149
|
click.current = onNodeClick;
|
|
271
150
|
const [onClick] = useState(() => (id) => click.current?.(id));
|
|
@@ -335,13 +214,18 @@ function Diagram({ lm, legend = true, onNodeClick, selected = null, canvas = fal
|
|
|
335
214
|
mq?.removeEventListener("change", watch);
|
|
336
215
|
};
|
|
337
216
|
}, [engine]);
|
|
217
|
+
const scrolls = !!given.scrolls;
|
|
338
218
|
const shape = useRef({
|
|
339
219
|
canvas: !!canvas,
|
|
340
|
-
inset
|
|
220
|
+
inset,
|
|
221
|
+
reserve,
|
|
222
|
+
scrolls
|
|
341
223
|
});
|
|
342
224
|
shape.current = {
|
|
343
225
|
canvas: !!canvas,
|
|
344
|
-
inset
|
|
226
|
+
inset,
|
|
227
|
+
reserve,
|
|
228
|
+
scrolls
|
|
345
229
|
};
|
|
346
230
|
const zoomed = useRef(null);
|
|
347
231
|
useEffect(() => {
|
|
@@ -349,7 +233,7 @@ function Diagram({ lm, legend = true, onNodeClick, selected = null, canvas = fal
|
|
|
349
233
|
if (!zoom || !board) return;
|
|
350
234
|
let gone = false;
|
|
351
235
|
if (canvas) engine.expectRoom(true);
|
|
352
|
-
import("./zoom-
|
|
236
|
+
import("./zoom-36lBVilV.js").then(({ mountZoom }) => {
|
|
353
237
|
if (!gone) zoomed.current = mountZoom(board, engine, () => shape.current);
|
|
354
238
|
}).catch(() => engine.expectRoom(false));
|
|
355
239
|
return () => {
|
|
@@ -404,14 +288,14 @@ function Diagram({ lm, legend = true, onNodeClick, selected = null, canvas = fal
|
|
|
404
288
|
}, [engine, reducedMotion]);
|
|
405
289
|
const was = useRef(false);
|
|
406
290
|
useEffect(() => {
|
|
407
|
-
if (was.current && !full) buttonRef.current?.focus();
|
|
291
|
+
if (was.current && !full) (buttonRef.current ?? wrapRef.current?.closest(".lm")?.querySelector(".lm-canvas-bar:not([inert]) .lm-canvas-full, .lm-canvas-over .lm-story"))?.focus();
|
|
408
292
|
was.current = full;
|
|
409
293
|
}, [full]);
|
|
410
294
|
useEffect(() => {
|
|
411
295
|
const wrap = wrapRef.current;
|
|
412
296
|
const bar = barRef.current;
|
|
413
297
|
const root = lm.root;
|
|
414
|
-
if (!full || !scene || !wrap || !bar || !root) return;
|
|
298
|
+
if (!full || boxed || !scene || !wrap || !bar || !root) return;
|
|
415
299
|
const fit = () => {
|
|
416
300
|
const h = heightUnder(root, wrap, bar);
|
|
417
301
|
const w = Math.min(wrap.clientWidth, h * scene.width / scene.height);
|
|
@@ -440,6 +324,7 @@ function Diagram({ lm, legend = true, onNodeClick, selected = null, canvas = fal
|
|
|
440
324
|
};
|
|
441
325
|
}, [
|
|
442
326
|
full,
|
|
327
|
+
boxed,
|
|
443
328
|
scene,
|
|
444
329
|
lm.root
|
|
445
330
|
]);
|
|
@@ -473,11 +358,11 @@ function Diagram({ lm, legend = true, onNodeClick, selected = null, canvas = fal
|
|
|
473
358
|
if (!full || !root || lm.fill) return;
|
|
474
359
|
const f = (e) => {
|
|
475
360
|
if (e.key !== "f" && e.key !== "F" || e.ctrlKey || e.metaKey || e.altKey) return;
|
|
476
|
-
if (typing(e.composedPath()[0] ?? null)
|
|
361
|
+
if (typing(e.composedPath()[0] ?? null)) return;
|
|
477
362
|
e.preventDefault();
|
|
478
363
|
if (e.repeat) return;
|
|
479
364
|
const next = fullScreenMode === "focus" ? "panels" : "focus";
|
|
480
|
-
if (document.activeElement?.closest(".lm-
|
|
365
|
+
if (document.activeElement?.closest(".lm-canvas-tabs, .lm-canvas-panel")) (root.querySelector(".lm-canvas-chrome") ?? modesRef.current?.querySelector(`[data-mode="${next}"]`))?.focus();
|
|
481
366
|
setFullScreenMode(next);
|
|
482
367
|
};
|
|
483
368
|
document.addEventListener("keydown", f);
|
|
@@ -499,7 +384,7 @@ function Diagram({ lm, legend = true, onNodeClick, selected = null, canvas = fal
|
|
|
499
384
|
ref: barRef,
|
|
500
385
|
children: [legend ? /* @__PURE__ */ jsx(Legend, { lm }) : /* @__PURE__ */ jsx("span", {}), /* @__PURE__ */ jsxs("span", {
|
|
501
386
|
className: "lm-tools",
|
|
502
|
-
children: [full && !lm.fill && /* @__PURE__ */ jsx("fieldset", {
|
|
387
|
+
children: [full && !lm.fill && !canvas && /* @__PURE__ */ jsx("fieldset", {
|
|
503
388
|
className: "lm-modes",
|
|
504
389
|
"aria-label": "Full screen shows (F)",
|
|
505
390
|
ref: modesRef,
|
|
@@ -598,6 +483,7 @@ function typing(t) {
|
|
|
598
483
|
"color"
|
|
599
484
|
].includes(t.type);
|
|
600
485
|
}
|
|
486
|
+
/** The flows by colour, and what a dot's other colours mean. */
|
|
601
487
|
function Legend({ lm }) {
|
|
602
488
|
const flows = lm.view.def.flows;
|
|
603
489
|
const merges = Object.values(lm.ev.overload).some((o) => o.merge);
|
|
@@ -1163,666 +1049,817 @@ function Badge({ n, text, was }) {
|
|
|
1163
1049
|
})
|
|
1164
1050
|
});
|
|
1165
1051
|
}
|
|
1166
|
-
// src/
|
|
1167
|
-
let shared = null;
|
|
1052
|
+
// src/canvasCss.ts
|
|
1168
1053
|
/**
|
|
1169
|
-
*
|
|
1170
|
-
*
|
|
1171
|
-
* layout runs on the main thread instead: slower to start, the same result.
|
|
1054
|
+
* The canvas's part of the stylesheet: the box has the height the page gives it (a default one otherwise), and nothing
|
|
1055
|
+
* in it changes that height: the diagram fills it, the bar and the console lie over its top and its bottom.
|
|
1172
1056
|
*/
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
}
|
|
1057
|
+
const CANVAS_CSS = `
|
|
1058
|
+
/* without weight: a page's own .lm-canvas { height } wins, wherever its stylesheet stands */
|
|
1059
|
+
:where(.lm-canvas) { height: clamp(420px, 70dvh, 760px); }
|
|
1060
|
+
.lm-canvas { position: relative; box-sizing: border-box; overflow: hidden; contain: layout; border: 1px solid var(--lm-line); border-radius: var(--lm-radius, 10px); background: var(--lm-surface); }
|
|
1061
|
+
.lm.lm[data-full] > .lm-canvas { display: block; flex: 1 1 0; height: auto; min-height: 0; }
|
|
1062
|
+
/* the spacer that centres a page of parts with the least around it would take a gap under the canvas */
|
|
1063
|
+
.lm.lm[data-full]:has(> .lm-canvas)::after { content: none; }
|
|
1064
|
+
.lm-canvas > .lm-wrap[data-canvas] { position: absolute; inset: 0; }
|
|
1065
|
+
.lm-canvas-bar, .lm-canvas-console { position: absolute; left: 0; right: var(--lm-canvas-right, 0px); z-index: 3; box-sizing: border-box; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 8px 12px; background: var(--lm-surface); }
|
|
1066
|
+
.lm-canvas-bar { top: 0; border-bottom: 1px solid var(--lm-line); }
|
|
1067
|
+
.lm-canvas-console { bottom: 0; border-top: 1px solid var(--lm-line); }
|
|
1068
|
+
/* over the bar for a while, across the whole top: as tall as it needs */
|
|
1069
|
+
.lm-canvas-panel[hidden] { display: none; }
|
|
1070
|
+
/* never more than the diagram can give: a long step scrolls in its strip */
|
|
1071
|
+
.lm-canvas-over { position: absolute; z-index: 5; top: 0; left: 0; right: 0; box-sizing: border-box; display: flex; align-items: center; max-height: 45%; overflow: auto; overscroll-behavior: contain; background: var(--lm-surface); border-bottom: 1px solid var(--lm-line); box-shadow: 0 8px 18px -14px rgb(0 0 0 / .45); }
|
|
1072
|
+
.lm-canvas-over > .lm-story { flex: 1 1 auto; border: 0; border-radius: 0; background: none; }
|
|
1073
|
+
.lm-canvas-over > .lm-canvas-leave { flex: none; margin-right: 12px; }
|
|
1074
|
+
/* the bar's own buttons, at its end */
|
|
1075
|
+
.lm-canvas-tools { display: flex; flex: none; gap: 6px; margin-left: auto; }
|
|
1076
|
+
.lm-canvas-tools .lm-btn { padding: 4px 9px; }
|
|
1077
|
+
.lm-canvas-tools .lm-btn[aria-pressed="true"].lm-canvas-chrome { border-color: var(--lm-fg); box-shadow: inset 0 0 0 1px var(--lm-fg); }
|
|
1078
|
+
.lm-frame .lm-canvas-bar > .lm-legend + .lm-canvas-tools { margin-left: 0; }
|
|
1079
|
+
/* a slot that holds nothing takes no room */
|
|
1080
|
+
.lm-canvas-bar:empty, .lm-canvas-console:empty { display: none; }
|
|
1081
|
+
.lm-canvas[data-width="compact"] :is(.lm-canvas-bar, .lm-canvas-console) { padding: 6px 8px; }
|
|
1082
|
+
.lm-canvas[data-short] .lm-canvas-bar { padding: 4px 8px; }
|
|
1083
|
+
/* on a touch screen two fingers zoom a narrow canvas: Fit alone stays, clear of the boxes */
|
|
1084
|
+
@media (pointer: coarse) { .lm-canvas[data-width="compact"] .lm-zoom .lm-btn:not(:last-child) { display: none; } }
|
|
1085
|
+
/* a page of its own parts has full-screen rules for a phone (the load on two lines, no legend): not the canvas's */
|
|
1086
|
+
.lm.lm[data-full] .lm-canvas .lm-load { display: grid; }
|
|
1087
|
+
.lm.lm[data-full] .lm-canvas .lm-load small { display: block; }
|
|
1088
|
+
.lm.lm[data-full] .lm-canvas .lm-load > label { position: static; width: auto; height: auto; clip-path: none; }
|
|
1089
|
+
.lm.lm[data-full] .lm-canvas .lm-load > output { margin-left: 0; }
|
|
1090
|
+
.lm.lm[data-full] .lm-canvas .lm-headline { flex-basis: auto; }
|
|
1091
|
+
.lm.lm[data-full] .lm-canvas .lm-legend { display: flex; }
|
|
1092
|
+
|
|
1093
|
+
/* the panels: their tabs, and the one that is open. Nothing but the open panel scrolls in a canvas */
|
|
1094
|
+
.lm-canvas-tabs { position: absolute; z-index: 3; display: flex; box-sizing: border-box; background: var(--lm-surface); }
|
|
1095
|
+
.lm-canvas-tabs button { flex: none; font: 500 .8rem var(--lm-font); color: var(--lm-muted); background: none; border: 0; padding: 0 12px; cursor: pointer; white-space: nowrap; }
|
|
1096
|
+
.lm-canvas-tabs button:hover { color: var(--lm-fg); }
|
|
1097
|
+
.lm-canvas-tabs button[aria-expanded="true"] { color: var(--lm-fg); font-weight: 600; box-shadow: inset 0 -2px 0 var(--lm-fg); }
|
|
1098
|
+
.lm-canvas-tabs button:focus-visible, .lm-canvas-menu:focus-visible { outline: 2px solid var(--lm-accent); outline-offset: -2px; }
|
|
1099
|
+
.lm-canvas[data-tabs="row"] .lm-canvas-tabs { left: 0; right: 0; bottom: var(--lm-canvas-bottom); height: 36px; border-top: 1px solid var(--lm-line); overflow-x: auto; scrollbar-width: none; }
|
|
1100
|
+
.lm-canvas[data-tabs="row"] .lm-canvas-tabs::-webkit-scrollbar { display: none; }
|
|
1101
|
+
/* the five share a narrow row */
|
|
1102
|
+
.lm-canvas[data-tabs="row"][data-width="compact"] .lm-canvas-tabs button { flex: 1 1 auto; padding: 0 4px; }
|
|
1103
|
+
.lm-canvas[data-tabs="rail"] .lm-canvas-tabs { top: 0; right: 0; bottom: 0; width: 44px; flex-direction: column; align-items: stretch; padding-top: 6px; border-left: 1px solid var(--lm-line); overflow: hidden; }
|
|
1104
|
+
.lm-canvas[data-tabs="rail"] .lm-canvas-tabs button { padding: 12px 0; display: flex; justify-content: center; }
|
|
1105
|
+
.lm-canvas[data-tabs="rail"] .lm-canvas-tabs button span { writing-mode: vertical-rl; }
|
|
1106
|
+
.lm-canvas[data-tabs="rail"] .lm-canvas-tabs button[aria-expanded="true"] { box-shadow: inset 2px 0 0 var(--lm-fg); }
|
|
1107
|
+
.lm-canvas[data-tabs="head"] .lm-canvas-tabs { top: 0; right: 0; width: var(--lm-canvas-right); height: 40px; border-left: 1px solid var(--lm-line); border-bottom: 1px solid var(--lm-line); overflow-x: auto; scrollbar-width: none; }
|
|
1108
|
+
.lm-canvas[data-tabs="head"] .lm-canvas-tabs::-webkit-scrollbar { display: none; }
|
|
1109
|
+
.lm-canvas-menu { position: absolute; z-index: 4; top: 5px; right: 8px; width: 116px; font: 500 .8rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 4px 6px; }
|
|
1110
|
+
.lm-canvas[data-tabs="menu"] .lm-canvas-bar, .lm-canvas[data-tabs="menu"] .lm-canvas-bar:empty { display: flex; min-height: 40px; padding-right: 132px; }
|
|
1111
|
+
.lm-canvas-panel { position: absolute; z-index: 4; box-sizing: border-box; display: grid; grid-template-rows: auto minmax(0, 1fr); background: var(--lm-surface); outline: 0; }
|
|
1112
|
+
.lm-canvas-panel[data-place="side"] { top: var(--lm-canvas-top); bottom: var(--lm-canvas-under); right: var(--lm-canvas-right); width: calc(var(--lm-canvas-reach) - var(--lm-canvas-right)); border-left: 1px solid var(--lm-line); box-shadow: -8px 0 18px -14px rgb(0 0 0 / .45); }
|
|
1113
|
+
.lm-canvas[data-pinned] .lm-canvas-panel { top: 40px; right: 0; bottom: 0; width: var(--lm-canvas-right); box-shadow: none; }
|
|
1114
|
+
.lm-canvas[data-pinned] .lm-canvas-panel-head { display: none; }
|
|
1115
|
+
.lm-canvas-panel[data-place="sheet"] { left: 0; right: 0; bottom: var(--lm-canvas-under); height: var(--lm-canvas-reach); border-top: 1px solid var(--lm-line); border-radius: 10px 10px 0 0; box-shadow: 0 -8px 18px -14px rgb(0 0 0 / .45); }
|
|
1116
|
+
.lm-canvas-panel-head { display: flex; align-items: center; gap: 6px; padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--lm-line); }
|
|
1117
|
+
.lm-canvas-panel-head h3 { flex: 1 1 auto; min-width: 0; margin: 0; font-size: .86rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
1118
|
+
.lm-canvas-panel-head .lm-btn { padding: 3px 8px; }
|
|
1119
|
+
.lm-canvas-panel-body { display: grid; gap: 14px; align-content: start; min-height: 0; padding: 12px; overflow: auto; overscroll-behavior: contain; container-type: inline-size; }
|
|
1120
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
1121
|
+
.lm-canvas-panel[data-place="side"] { animation: lm-canvas-side .16s ease-out; }
|
|
1122
|
+
.lm-canvas[data-pinned] .lm-canvas-panel { animation: none; }
|
|
1123
|
+
.lm-canvas-panel[data-place="sheet"] { animation: lm-canvas-sheet .16s ease-out; }
|
|
1124
|
+
}
|
|
1125
|
+
@keyframes lm-canvas-side { from { transform: translateX(16px); opacity: 0; } }
|
|
1126
|
+
@keyframes lm-canvas-sheet { from { transform: translateY(16px); opacity: 0; } }
|
|
1127
|
+
|
|
1128
|
+
/* the frame: what <Frame> puts in the two slots. Each is one row of a height nothing the reader does changes */
|
|
1129
|
+
.lm-frame .lm-canvas-bar { flex-wrap: nowrap; overflow: hidden; }
|
|
1130
|
+
.lm-frame .lm-canvas-bar > h2 { flex: 0 5 auto; min-width: 0; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
1131
|
+
.lm-frame .lm-canvas-bar > .lm-scenarios { flex: 0 2 auto; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 2px; }
|
|
1132
|
+
.lm-frame .lm-canvas-bar > .lm-scenarios::-webkit-scrollbar { display: none; }
|
|
1133
|
+
.lm-frame .lm-canvas-bar > .lm-scenarios > * { flex: none; white-space: nowrap; }
|
|
1134
|
+
.lm-frame .lm-canvas-bar > .lm-scenarios button { padding: 4px 10px; }
|
|
1135
|
+
/* named for a screen reader, unseen: the buttons say what they are */
|
|
1136
|
+
.lm-frame .lm-canvas-bar > .lm-scenarios legend, .lm.lm .lm-frame[data-short] .lm-load > label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
|
|
1137
|
+
/* one row whatever is on: an entry that does not fit wraps under it, out of view, whole */
|
|
1138
|
+
.lm-frame .lm-canvas-bar > .lm-legend { flex: 1 1 0; justify-content: flex-end; min-width: 0; height: 1.5em; line-height: 1.5; overflow: hidden; white-space: nowrap; }
|
|
1139
|
+
.lm-canvas-pick { flex: 0 1 auto; min-width: 0; max-width: 100%; font: 500 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 5px 8px; }
|
|
1140
|
+
.lm-frame .lm-canvas-console { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; padding: 6px 12px 8px; }
|
|
1141
|
+
.lm-frame .lm-canvas-console > .lm-load { grid-template: "label track value" / minmax(0, max-content) minmax(120px, 1fr) auto; align-items: start; }
|
|
1142
|
+
.lm-frame .lm-canvas-console > .lm-load > label { max-width: 14em; padding-top: 6px; }
|
|
1143
|
+
.lm-frame .lm-canvas-console > .lm-load > output { padding-top: 5px; }
|
|
1144
|
+
.lm-canvas-verdict { display: flex; align-items: center; gap: 6px 14px; min-width: 0; padding-left: 8px; border-left: 4px solid var(--lm-ok); }
|
|
1145
|
+
.lm-canvas-verdict[data-tier="warn"] { border-color: var(--lm-warn); }
|
|
1146
|
+
.lm-canvas-verdict[data-tier="over"] { border-color: var(--lm-drop); }
|
|
1147
|
+
.lm-frame[data-width="compact"] .lm-canvas-console { padding: 6px 8px; }
|
|
1148
|
+
.lm-frame[data-width="compact"] .lm-canvas-console > .lm-load { grid-template: "label value" "track track" / minmax(0, 1fr) auto; align-items: center; }
|
|
1149
|
+
.lm-frame[data-width="compact"] .lm-canvas-console > .lm-load > :is(label, output) { padding-top: 0; }
|
|
1150
|
+
/* room for the date under the load, with one or not */
|
|
1151
|
+
.lm-frame[data-width="compact"] .lm-canvas-console > .lm-load > output { min-height: 2.1rem; }
|
|
1152
|
+
/* two lines kept whatever the verdict says: the load never changes the console's height */
|
|
1153
|
+
.lm-frame[data-width="compact"]:not([data-short]) .lm-headline { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; height: 2.6em; line-height: 1.3; white-space: normal; }
|
|
1154
|
+
.lm-frame[data-short] .lm-canvas-console { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 12px; padding: 2px 8px; }
|
|
1155
|
+
.lm-frame[data-short] .lm-canvas-console > .lm-load { grid-template: "track value" / minmax(0, 1fr) auto; align-items: start; }
|
|
1156
|
+
.lm-frame[data-short][data-width="compact"] .lm-canvas-console { grid-template-columns: minmax(0, 1fr); gap: 0; }
|
|
1157
|
+
`;
|
|
1158
|
+
// src/styles.ts
|
|
1159
|
+
const LIGHT = `
|
|
1160
|
+
--lm-bg: #eef2f5; --lm-surface: #ffffff; --lm-fg: #17212b; --lm-muted: #5d6d7c; --lm-line: #c6d0da;
|
|
1161
|
+
--lm-accent: #0b6b8f; --lm-accent-soft: #d6e9f0; --lm-alt: #7a4f9a; --lm-alt-soft: #efe5f6;
|
|
1162
|
+
--lm-ok: #2a7f5a; --lm-warn: #b86e00; --lm-drop: #b7392e; --lm-lane: #e3e9ee;
|
|
1163
|
+
--lm-lost-fill: #fbefed; --lm-lost-line: #b7392e;
|
|
1164
|
+
--lm-tier-base: #f4f7fa; --lm-tier: #e8eef3; --lm-tier-head: #dbe3eb; --lm-tier-fg: #34424f; --lm-tier-line: #c6d0da;
|
|
1165
|
+
--lm-s1: #2a78d6; --lm-s2: #eb6834; --lm-s3: #6250d6; --lm-s4: #eda100; color-scheme: light;`;
|
|
1166
|
+
const DARK = `
|
|
1167
|
+
--lm-bg: #0d141b; --lm-surface: #151e27; --lm-fg: #e4ebf1; --lm-muted: #93a3b3; --lm-line: #2a3744;
|
|
1168
|
+
--lm-accent: #5fb7d6; --lm-accent-soft: #163442; --lm-alt: #c39be0; --lm-alt-soft: #2b2236;
|
|
1169
|
+
--lm-ok: #5fc08f; --lm-warn: #e2a24a; --lm-drop: #e26a5c; --lm-lane: #1b2631;
|
|
1170
|
+
--lm-lost-fill: #2b1c1d; --lm-lost-line: #e26a5c;
|
|
1171
|
+
--lm-tier-base: #1b2530; --lm-tier: #24323f; --lm-tier-head: #2c3b4a; --lm-tier-fg: #c3cfda; --lm-tier-line: #33424f;
|
|
1172
|
+
--lm-s1: #3987e5; --lm-s2: #d95926; --lm-s3: #9085e9; --lm-s4: #c98500; color-scheme: dark;`;
|
|
1180
1173
|
/**
|
|
1181
|
-
*
|
|
1182
|
-
*
|
|
1183
|
-
*
|
|
1174
|
+
* Theme tokens and the layout of every piece. Scoped to `.lm`; override any `--lm-*` token to restyle. Two are for the
|
|
1175
|
+
* page around it: `--lm-pad` (the root's padding, 16px) and `--lm-root-bg` (its background, `--lm-bg`), for a card
|
|
1176
|
+
* that has its own, set on the root (`.card > .lm`) so they resolve there and reach no nested board; full screen
|
|
1177
|
+
* keeps both.
|
|
1184
1178
|
*/
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
pending.delete(data.id);
|
|
1218
|
-
if (data.error != null) p.reject(new Error(data.error));
|
|
1219
|
-
else p.resolve(data.graph);
|
|
1220
|
-
};
|
|
1221
|
-
worker.onerror = (e) => {
|
|
1222
|
-
e.preventDefault();
|
|
1223
|
-
fallBack(e.message || "it failed to load or to run");
|
|
1224
|
-
};
|
|
1225
|
-
return worker;
|
|
1226
|
-
};
|
|
1227
|
-
return { layout(graph) {
|
|
1228
|
-
const w = start();
|
|
1229
|
-
if (!w) {
|
|
1230
|
-
tell("no Worker here");
|
|
1231
|
-
return localElk().then((elk) => elk.layout(graph));
|
|
1232
|
-
}
|
|
1233
|
-
return new Promise((resolve, reject) => {
|
|
1234
|
-
const id = next++;
|
|
1235
|
-
pending.set(id, {
|
|
1236
|
-
graph,
|
|
1237
|
-
resolve,
|
|
1238
|
-
reject
|
|
1239
|
-
});
|
|
1240
|
-
w.postMessage({
|
|
1241
|
-
id,
|
|
1242
|
-
graph
|
|
1243
|
-
});
|
|
1244
|
-
});
|
|
1245
|
-
} };
|
|
1246
|
-
}
|
|
1247
|
-
// src/scenarios.tsx
|
|
1248
|
-
/** Scenario identity colours, in declaration order; a fifth and later scenario is drawn muted. */
|
|
1249
|
-
const SERIES = [
|
|
1250
|
-
"var(--lm-s1)",
|
|
1251
|
-
"var(--lm-s2)",
|
|
1252
|
-
"var(--lm-s3)",
|
|
1253
|
-
"var(--lm-s4)"
|
|
1254
|
-
];
|
|
1255
|
-
/** The colour of a scenario by label; values of the reader's own are drawn in the text colour. */
|
|
1256
|
-
function scenarioColor(model, label) {
|
|
1257
|
-
if (label == null) return "var(--lm-fg)";
|
|
1258
|
-
const i = model.scenarios.findIndex((s) => s.label === label);
|
|
1259
|
-
return SERIES[i] ?? "var(--lm-muted)";
|
|
1260
|
-
}
|
|
1261
|
-
const lineName = (l) => l.label ?? "These values";
|
|
1262
|
-
/** A month for a table cell or an axis: "Mar 2031"; "now" for a crossing already reached. */
|
|
1263
|
-
function when(model, x) {
|
|
1264
|
-
const d = model.dateAt(x);
|
|
1265
|
-
return d ? monthOf(d, true) : x != null && x <= 1 && model.growth ? "now" : "";
|
|
1266
|
-
}
|
|
1267
|
-
/** The months of both edges: "Sep 2029–Feb 2030", or one month when they agree. */
|
|
1268
|
-
function whenRange(model, r) {
|
|
1269
|
-
if (!r) return "";
|
|
1270
|
-
const [lo, hi] = [when(model, r.low), when(model, r.high)];
|
|
1271
|
-
return !hi || lo === hi ? lo : `${lo}–${hi}`;
|
|
1179
|
+
const LOADMAP_CSS = `
|
|
1180
|
+
.lm { ${LIGHT}
|
|
1181
|
+
--lm-font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
1182
|
+
--lm-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
1183
|
+
font: 14px/1.45 var(--lm-font); color: var(--lm-fg); background: var(--lm-root-bg, var(--lm-bg));
|
|
1184
|
+
display: grid; gap: 14px; padding: var(--lm-pad, 16px); min-width: 0; box-sizing: border-box; }
|
|
1185
|
+
@media (prefers-color-scheme: dark) { .lm:not([data-theme="light"]) { ${DARK} } }
|
|
1186
|
+
.lm[data-theme="dark"] { ${DARK} }
|
|
1187
|
+
.lm *, .lm *::before, .lm *::after { box-sizing: border-box; }
|
|
1188
|
+
.lm h2 { font-size: 1.3rem; font-weight: 600; margin: 0; text-wrap: balance; }
|
|
1189
|
+
.lm h3 { font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); margin: 0; }
|
|
1190
|
+
.lm button:focus-visible, .lm input:focus-visible, .lm select:focus-visible { outline: 2px solid var(--lm-accent); outline-offset: 2px; }
|
|
1191
|
+
.lm-problems { margin: 0; padding: 10px 12px; font: .8rem/1.5 var(--lm-mono); white-space: pre-wrap; overflow-x: auto; color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-left: 3px solid var(--lm-drop); border-radius: 6px; }
|
|
1192
|
+
.lm-note { margin: 0; font-size: .8rem; color: var(--lm-muted); }
|
|
1193
|
+
.lm-card { background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; padding: 14px 16px; display: grid; gap: 12px; align-content: start; min-width: 0; }
|
|
1194
|
+
|
|
1195
|
+
.lm-wrap { display: grid; gap: 8px; min-width: 0; position: relative; }
|
|
1196
|
+
.lm-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
|
|
1197
|
+
.lm-btn { font: 500 .8rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
|
|
1198
|
+
.lm-board { position: relative; background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; overflow: hidden; margin: 0 auto; width: 100%; }
|
|
1199
|
+
.lm-board svg { display: block; width: 100%; height: auto; font-family: var(--lm-font); }
|
|
1200
|
+
.lm-board canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
|
|
1201
|
+
/* the story's title over the board while it plays: a lower third, at the top when what is framed is low; a strip
|
|
1202
|
+
across the top of a narrow board */
|
|
1203
|
+
.lm-title { position: absolute; left: 12px; bottom: 12px; z-index: 1; display: grid; gap: 1px; max-width: min(34rem, calc(100% - 24px)); padding: 7px 12px 8px; border-left: 4px solid var(--lm-accent); border-radius: 0 6px 6px 0; background: color-mix(in srgb, var(--lm-surface) 92%, transparent); box-shadow: 0 4px 16px rgb(0 0 0 / .12); pointer-events: none; overflow-wrap: anywhere; }
|
|
1204
|
+
.lm-title[data-top] { top: 12px; bottom: auto; }
|
|
1205
|
+
.lm-title b { font-size: .95rem; font-weight: 600; }
|
|
1206
|
+
.lm-title span { font: 500 .8rem var(--lm-mono); color: var(--lm-muted); }
|
|
1207
|
+
@container (max-width: 520px) {
|
|
1208
|
+
.lm-title, .lm-title[data-top] { top: 0; right: 0; bottom: auto; left: 0; max-width: none; padding: 4px 8px; border-radius: 0; box-shadow: none; }
|
|
1209
|
+
.lm-title b { font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
1210
|
+
.lm-title span { display: none; }
|
|
1272
1211
|
}
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1212
|
+
.lm-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .78rem; color: var(--lm-muted); }
|
|
1213
|
+
.lm-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 5px; }
|
|
1214
|
+
.lm-legend i.lm-legend-merge { box-sizing: border-box; border: 1.5px solid var(--lm-muted); }
|
|
1215
|
+
|
|
1216
|
+
/* full screen (the browser's, or a fixed overlay): a column that never scrolls. The diagram as wide as the screen on
|
|
1217
|
+
top; under it the verdict in a line and the panels, compact, in a dock the screen sizes. The load changes what is
|
|
1218
|
+
in them, never their size, so it never moves the board. Focus: the diagram, the story, the verdict and the load */
|
|
1219
|
+
.lm-side, .lm-card > .lm-panel { display: contents; }
|
|
1220
|
+
.lm-panel { display: grid; gap: 14px; min-width: 0; }
|
|
1221
|
+
.lm[data-full] { height: 100vh; height: 100dvh; padding: 16px; background: var(--lm-bg); overflow: hidden; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 10px; position: relative; }
|
|
1222
|
+
.lm[data-full="fill"] { height: 100%; padding: 10px; }
|
|
1223
|
+
.lm[data-full="overlay"] { position: fixed; inset: 0; z-index: 2147483000; width: auto; max-width: none; max-height: none; margin: 0; border: 0; }
|
|
1224
|
+
.lm[data-full] > * { flex: none; }
|
|
1225
|
+
/* a page of its own keeps the rest outside full screen, as <Loadmap> does */
|
|
1226
|
+
.lm[data-full] > :not(.lm-canvas, .lm-head, h2, .lm-scenarios, .lm-loadbar, .lm-story, .lm-wrap, .lm-side) { display: none; }
|
|
1227
|
+
.lm-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; min-width: 0; }
|
|
1228
|
+
.lm-head h2 { font-size: 1.1rem; }
|
|
1229
|
+
.lm-head .lm-loadbar { flex: 1 1 520px; }
|
|
1230
|
+
.lm[data-full] .lm-wrap { gap: 6px; }
|
|
1231
|
+
/* the board as large as fits (--lm-fit, from Diagram), left under the bar, so the legend starts where the board does */
|
|
1232
|
+
.lm[data-full] .lm-board { width: var(--lm-fit, 100%); margin: 0; align-self: start; justify-self: start; }
|
|
1233
|
+
.lm-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
|
|
1234
|
+
.lm-modes { display: inline-flex; margin: 0; padding: 0; min-width: 0; border: 1px solid var(--lm-line); border-radius: 6px; overflow: hidden; }
|
|
1235
|
+
.lm-modes button { font: 500 .8rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 0; padding: 6px 12px; cursor: pointer; }
|
|
1236
|
+
.lm-modes button[aria-pressed="true"] { background: var(--lm-fg); color: var(--lm-surface); }
|
|
1237
|
+
.lm[data-full] .lm-story { padding: 6px 12px; }
|
|
1238
|
+
.lm[data-full] [data-out] { display: none; }
|
|
1239
|
+
|
|
1240
|
+
.lm-headline { flex: 1 1 auto; min-width: 0; margin: 0; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
1241
|
+
.lm-num { font: 600 .95em var(--lm-mono); font-variant-numeric: tabular-nums; }
|
|
1242
|
+
.lm-link { font: 500 .8rem var(--lm-font); color: var(--lm-accent); background: none; border: 0; padding: 2px 4px; cursor: pointer; white-space: nowrap; }
|
|
1243
|
+
|
|
1244
|
+
|
|
1245
|
+
|
|
1246
|
+
/* a page of its own: its .lm-side is a box under the board that scrolls on its own, the board as large as leaves it a
|
|
1247
|
+
third of the screen */
|
|
1248
|
+
.lm[data-full] > .lm-side { display: grid; gap: 14px; align-content: start; flex: 1 1 0; min-height: 33dvh; overflow: auto; overscroll-behavior: contain; container-type: inline-size; }
|
|
1249
|
+
|
|
1250
|
+
/* focus: the board and what runs on it in the middle of the screen */
|
|
1251
|
+
.lm[data-mode="focus"] > .lm-side { display: none; }
|
|
1252
|
+
.lm[data-mode="focus"] > .lm-wrap { margin-top: auto; }
|
|
1253
|
+
.lm[data-mode="focus"] > .lm-story { order: 1; }
|
|
1254
|
+
.lm[data-mode="focus"]::after { content: ""; order: 2; margin-top: auto; }
|
|
1255
|
+
.lm[data-mode="focus"] > .lm-story { border-left-width: 4px; padding: 10px 14px; }
|
|
1256
|
+
.lm[data-mode="focus"] > .lm-story p { font-size: 1.1rem; }
|
|
1257
|
+
|
|
1258
|
+
@media (max-width: 760px) {
|
|
1259
|
+
.lm[data-full] { padding: 10px; gap: 8px; }
|
|
1260
|
+
/* the page has the title, and the legend: here they would leave the diagram no room */
|
|
1261
|
+
.lm[data-full] > h2, .lm[data-full] :is(.lm-head h2, .lm-legend, .lm-story legend) { display: none; }
|
|
1262
|
+
/* the one exception: here the diagram runs top to bottom, and shrunk to the screen it is too small to read, so it
|
|
1263
|
+
pans in a box of its own with the bar on top. The page never scrolls */
|
|
1264
|
+
.lm[data-full] .lm-board { width: 100%; }
|
|
1265
|
+
.lm[data-full] > .lm-wrap { height: 40dvh; overflow: auto; row-gap: 0; overscroll-behavior: contain; }
|
|
1266
|
+
.lm[data-mode="focus"] > .lm-wrap { height: auto; flex: 1 1 0; min-height: 0; margin-top: 0; }
|
|
1267
|
+
.lm[data-full] .lm-bar { position: sticky; top: 0; z-index: 1; padding-bottom: 8px; background: var(--lm-bg); }
|
|
1268
|
+
.lm[data-full] > .lm-story { padding: 6px 10px; gap: 6px 10px; }
|
|
1269
|
+
.lm[data-full] > .lm-story p { font-size: .84rem; }
|
|
1270
|
+
.lm[data-full] .lm-story button { padding: 4px 10px; }
|
|
1271
|
+
.lm[data-full] .lm-headline { flex-basis: 100%; }
|
|
1272
|
+
/* the load in thumb reach: the bar under the board and the story, over the verdict */
|
|
1273
|
+
.lm[data-full] .lm-head { display: contents; }
|
|
1274
|
+
.lm[data-full] .lm-loadbar { order: 2; flex: none; }
|
|
1275
|
+
/* two lines, so the board keeps its room: the scenarios and the load's value, then the track; the label names the
|
|
1276
|
+
slider unseen */
|
|
1277
|
+
.lm[data-full] .lm-load small { display: none; }
|
|
1278
|
+
.lm[data-full] .lm-load { display: contents; }
|
|
1279
|
+
.lm[data-full] :is(.lm-loadbar legend, .lm-load > label) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
|
|
1280
|
+
.lm[data-full] .lm-load > output { margin-left: auto; }
|
|
1281
|
+
.lm[data-full] .lm-load-track { flex: 1 1 100%; }
|
|
1276
1282
|
}
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1283
|
+
|
|
1284
|
+
.lm-verdict { margin: 0; padding: 10px 14px; border-left: 4px solid var(--lm-ok); background: var(--lm-accent-soft); border-radius: 0 6px 6px 0; }
|
|
1285
|
+
.lm-verdict[data-tier="warn"] { border-color: var(--lm-warn); }
|
|
1286
|
+
.lm-verdict[data-tier="over"] { border-color: var(--lm-drop); }
|
|
1287
|
+
.lm-measure { margin: 6px 0 0; padding: 0 14px; font-size: .86rem; color: var(--lm-muted); }
|
|
1288
|
+
|
|
1289
|
+
.lm-strip { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); gap: 14px; align-items: start; }
|
|
1290
|
+
@container (max-width: 860px) { .lm-strip { grid-template-columns: minmax(0, 1fr); } }
|
|
1291
|
+
.lm { container-type: inline-size; }
|
|
1292
|
+
|
|
1293
|
+
.lm-meters { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
|
|
1294
|
+
.lm-meter { padding: 8px 10px; border-radius: 6px; background: var(--lm-bg); min-width: 0; }
|
|
1295
|
+
.lm-meter b { display: block; font: 500 1.15rem var(--lm-mono); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
1296
|
+
.lm-meter span { font-size: .74rem; color: var(--lm-muted); }
|
|
1297
|
+
.lm-meter[data-state="warn"] b { color: var(--lm-warn); } .lm-meter[data-state="over"] b { color: var(--lm-drop); }
|
|
1298
|
+
|
|
1299
|
+
.lm-limits { display: grid; gap: 10px; }
|
|
1300
|
+
.lm-lim, .lm-scale { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr) 10rem; gap: 4px 14px; align-items: center; }
|
|
1301
|
+
@container (max-width: 640px) { .lm-lim, .lm-scale { grid-template-columns: minmax(0, 1fr); } .lm-scale > :first-child, .lm-scale > :last-child { display: none; } }
|
|
1302
|
+
.lm-lim b { display: block; font-weight: 600; font-size: .88rem; }
|
|
1303
|
+
.lm-lim .lm-sub { display: block; font-size: .74rem; color: var(--lm-muted); }
|
|
1304
|
+
.lm-tag { font: 600 .64rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; border-radius: 3px; padding: 1px 5px; margin-left: 6px; vertical-align: 1px; }
|
|
1305
|
+
.lm-tag[data-kind="first"] { color: var(--lm-surface); background: var(--lm-drop); }
|
|
1306
|
+
.lm-tag[data-kind="estimated"] { color: var(--lm-warn); border: 1px solid currentColor; }
|
|
1307
|
+
.lm-tag[data-kind="published"] { color: var(--lm-alt); border: 1px solid currentColor; }
|
|
1308
|
+
.lm-tag[data-kind="none"] { color: var(--lm-muted); border: 1px dashed currentColor; }
|
|
1309
|
+
.lm-tag[data-kind="range"], .lm-tag[data-kind="rank"] { color: var(--lm-muted); border: 1px solid currentColor; }
|
|
1310
|
+
.lm-track { position: relative; height: 16px; background: var(--lm-bg); border-radius: 3px; overflow: hidden; }
|
|
1311
|
+
.lm-fill { position: absolute; inset: 0 auto 0 0; background: var(--lm-ok); transition: width .25s ease; }
|
|
1312
|
+
.lm-fill[data-state="warn"] { background: var(--lm-warn); } .lm-fill[data-state="over"] { background: var(--lm-drop); }
|
|
1313
|
+
.lm-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--lm-fg); opacity: .55; }
|
|
1314
|
+
.lm-val { font: 500 .8rem var(--lm-mono); font-variant-numeric: tabular-nums; }
|
|
1315
|
+
.lm-val small { display: block; font: 400 .72rem var(--lm-font); color: var(--lm-muted); }
|
|
1316
|
+
.lm-scale { font: 400 .7rem var(--lm-mono); color: var(--lm-muted); }
|
|
1317
|
+
.lm-scale div { position: relative; height: 12px; }
|
|
1318
|
+
.lm-scale div span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
|
|
1319
|
+
|
|
1320
|
+
.lm-controls label.lm-range { display: grid; gap: 4px; font-size: .84rem; }
|
|
1321
|
+
.lm-controls label.lm-range > span { display: flex; justify-content: space-between; gap: 8px; }
|
|
1322
|
+
.lm-controls output { font-family: var(--lm-mono); font-variant-numeric: tabular-nums; }
|
|
1323
|
+
.lm-controls input[type=range] { width: 100%; accent-color: var(--lm-accent); }
|
|
1324
|
+
.lm-presets { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
1325
|
+
.lm-presets button { font: 500 .76rem var(--lm-font); background: var(--lm-accent-soft); color: var(--lm-fg); border: 1px solid transparent; border-radius: 5px; padding: 5px 10px; cursor: pointer; }
|
|
1326
|
+
.lm-presets button[aria-pressed="true"] { border-color: var(--lm-accent); }
|
|
1327
|
+
.lm-switch { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 8px; align-items: start; font-size: .84rem; cursor: pointer; }
|
|
1328
|
+
.lm-switch input { margin: 3px 0 0; accent-color: var(--lm-accent); }
|
|
1329
|
+
.lm-switch small, .lm-select small { grid-column: 2; color: var(--lm-muted); font-size: .74rem; line-height: 1.3; }
|
|
1330
|
+
.lm-select { display: grid; gap: 4px; font-size: .84rem; }
|
|
1331
|
+
.lm-select select { width: 100%; min-width: 0; font: 400 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 5px; padding: 5px 8px; }
|
|
1332
|
+
.lm-off { opacity: .45; cursor: default; }
|
|
1333
|
+
|
|
1334
|
+
.lm-facts { margin: 0; padding-left: 1.1em; font-size: .88rem; columns: 2; column-gap: 28px; }
|
|
1335
|
+
@container (max-width: 860px) { .lm-facts { columns: 1; } }
|
|
1336
|
+
.lm-facts li { margin-bottom: 8px; break-inside: avoid; }
|
|
1337
|
+
.lm-prov { font: 600 .66rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; }
|
|
1338
|
+
.lm-prov[data-kind="measured"] { color: var(--lm-ok); } .lm-prov[data-kind="estimated"] { color: var(--lm-warn); }
|
|
1339
|
+
.lm-prov[data-kind="configured"] { color: var(--lm-accent); } .lm-prov[data-kind="published"] { color: var(--lm-alt); }
|
|
1340
|
+
|
|
1341
|
+
/* scenario identity colours (s1–s4) are checked for colour-blind separation on both surfaces; text never wears them */
|
|
1342
|
+
.lm-scenarios { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
|
|
1343
|
+
.lm-scenarios legend { float: left; font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); margin-right: 6px; padding: 0; }
|
|
1344
|
+
.lm-scenarios button { font: 500 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
|
|
1345
|
+
.lm-scenarios button[aria-pressed="true"] { border-color: var(--lm-fg); box-shadow: inset 0 0 0 1px var(--lm-fg); }
|
|
1346
|
+
.lm-scenarios i, .lm-table i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 6px; }
|
|
1347
|
+
.lm-story { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0; min-width: 0; padding: 8px 12px; border: 1px solid var(--lm-line); border-left: 3px solid var(--lm-accent); border-radius: 6px; background: var(--lm-surface); }
|
|
1348
|
+
.lm-story legend { float: left; font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); padding: 0; }
|
|
1349
|
+
.lm-story p { flex: 1 1 240px; display: grid; margin: 0; font: 400 .9rem/1.4 var(--lm-font); color: var(--lm-fg); }
|
|
1350
|
+
.lm-story p > span { grid-area: 1 / 1; }
|
|
1351
|
+
.lm-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
1352
|
+
.lm-story p > span:not([data-shown]), .lm-story em:not([data-shown]) { visibility: hidden; }
|
|
1353
|
+
.lm-story-progress { display: flex; align-items: center; gap: 4px; }
|
|
1354
|
+
.lm-story-progress i { position: relative; width: 28px; height: 4px; border-radius: 2px; background: var(--lm-line); overflow: hidden; }
|
|
1355
|
+
.lm-story-progress i[data-state="done"], .lm-story:not([data-playing]) .lm-story-progress i[data-state="now"] { background: var(--lm-accent); }
|
|
1356
|
+
.lm-story[data-playing] .lm-story-progress i[data-state="now"]::before { content: ""; position: absolute; inset: 0; background: var(--lm-accent); transform-origin: left; animation: lm-step var(--lm-step) linear both; }
|
|
1357
|
+
@keyframes lm-step { from { transform: scaleX(0); } to { transform: scaleX(1); } }
|
|
1358
|
+
.lm-story b { font-weight: 600; color: var(--lm-muted); margin-right: 4px; white-space: nowrap; }
|
|
1359
|
+
.lm-story-nav { display: flex; gap: 6px; }
|
|
1360
|
+
.lm-story em { color: var(--lm-muted); }
|
|
1361
|
+
.lm-story button { font: 500 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
|
|
1362
|
+
.lm-story button[aria-disabled="true"] { opacity: .45; cursor: default; }
|
|
1363
|
+
.lm-own { font-size: .78rem; color: var(--lm-muted); }
|
|
1364
|
+
|
|
1365
|
+
/* the scenarios and the load over the board, in view while the page scrolls; on a phone under the board */
|
|
1366
|
+
.lm-loadbar { position: sticky; top: var(--lm-sticky-top, 0px); z-index: 3; container-type: inline-size; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; padding: 6px 12px 2px; background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; box-shadow: 0 4px 14px -10px rgb(0 0 0 / .4); }
|
|
1367
|
+
.lm-loadbar .lm-scenarios { flex-wrap: nowrap; max-width: 100%; overflow-x: auto; padding: 2px; }
|
|
1368
|
+
.lm-loadbar .lm-scenarios button { flex: none; white-space: nowrap; }
|
|
1369
|
+
.lm-loadbar .lm-load { flex: 1 1 300px; }
|
|
1370
|
+
@container (min-width: 720px) {
|
|
1371
|
+
.lm-loadbar .lm-load { grid-template: "label track value" / minmax(0, max-content) minmax(160px, 1fr) auto; align-items: start; }
|
|
1372
|
+
.lm-loadbar .lm-load > label { max-width: 14em; padding-top: 6px; }
|
|
1297
1373
|
}
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
if (Math.abs(x - 1) < .005) return "same";
|
|
1302
|
-
return `${x > 1 ? "+" : "−"}${pct(Math.abs(x - 1))}`;
|
|
1374
|
+
@container (max-width: 520px) {
|
|
1375
|
+
.lm:not([data-full]) > .lm-loadbar { order: 1; top: auto; bottom: 0; }
|
|
1376
|
+
.lm:not([data-full]) > .lm-side { order: 2; }
|
|
1303
1377
|
}
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
}),
|
|
1348
|
-
/* @__PURE__ */ jsx("td", {
|
|
1349
|
-
className: "lm-text",
|
|
1350
|
-
children: r.firstLimit?.name ?? "—"
|
|
1351
|
-
}),
|
|
1352
|
-
/* @__PURE__ */ jsx("td", {
|
|
1353
|
-
"data-multiple": r.target ?? "",
|
|
1354
|
-
"data-high": r.targetRange?.high ?? "",
|
|
1355
|
-
children: at(r.targetRange)
|
|
1356
|
-
}),
|
|
1357
|
-
/* @__PURE__ */ jsx("td", {
|
|
1358
|
-
"data-multiple": r.full ?? "",
|
|
1359
|
-
"data-high": r.fullRange?.high ?? "",
|
|
1360
|
-
children: at(r.fullRange)
|
|
1361
|
-
})
|
|
1362
|
-
]
|
|
1363
|
-
}, r.label)) })]
|
|
1364
|
-
})
|
|
1365
|
-
}),
|
|
1366
|
-
/* @__PURE__ */ jsxs("h3", { children: [target, ", by component"] }),
|
|
1367
|
-
/* @__PURE__ */ jsx("div", {
|
|
1368
|
-
className: "lm-table-wrap",
|
|
1369
|
-
children: /* @__PURE__ */ jsxs("table", {
|
|
1370
|
-
className: "lm-table",
|
|
1371
|
-
children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("th", {
|
|
1372
|
-
scope: "col",
|
|
1373
|
-
children: "Component"
|
|
1374
|
-
}), c.rows.map((r) => /* @__PURE__ */ jsx("th", {
|
|
1375
|
-
scope: "col",
|
|
1376
|
-
children: r.label
|
|
1377
|
-
}, r.label))] }) }), /* @__PURE__ */ jsx("tbody", { children: model.componentIds.map((id, k) => /* @__PURE__ */ jsxs("tr", {
|
|
1378
|
-
"data-component": id,
|
|
1379
|
-
children: [/* @__PURE__ */ jsx("th", {
|
|
1380
|
-
scope: "row",
|
|
1381
|
-
children: c.rows[0].components[k].name
|
|
1382
|
-
}), c.rows.map((r, i) => {
|
|
1383
|
-
const x = r.components[k];
|
|
1384
|
-
return /* @__PURE__ */ jsxs("td", {
|
|
1385
|
-
"data-multiple": x.target ?? "",
|
|
1386
|
-
children: [x.targetRange == null ? "off" : multiples(x.targetRange, model.searchMax, true), i > 0 && change(x.change) && /* @__PURE__ */ jsx("small", { children: change(x.change) })]
|
|
1387
|
-
}, r.label);
|
|
1388
|
-
})]
|
|
1389
|
-
}, id)) })]
|
|
1390
|
-
})
|
|
1391
|
-
})
|
|
1392
|
-
]
|
|
1393
|
-
});
|
|
1378
|
+
/* the load: its label and value, the track under them, the marks under it */
|
|
1379
|
+
.lm-load { display: grid; grid-template: "label value" "track track" / minmax(0, 1fr) auto; align-items: center; gap: 0 12px; font-size: .84rem; min-width: 0; }
|
|
1380
|
+
.lm-load > label { grid-area: label; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
1381
|
+
.lm-load > output { grid-area: value; text-align: right; font: 600 .95rem/1.2 var(--lm-mono); font-variant-numeric: tabular-nums; }
|
|
1382
|
+
.lm-load small { display: block; font: 400 .7rem var(--lm-mono); color: var(--lm-muted); }
|
|
1383
|
+
.lm-load-track { grid-area: track; position: relative; min-width: 0; padding-bottom: 22px; }
|
|
1384
|
+
.lm-load input { display: block; width: 100%; height: 32px; margin: 0; accent-color: var(--lm-accent); cursor: pointer; }
|
|
1385
|
+
.lm-zones, .lm-marks { position: absolute; left: 8px; right: 8px; top: 30px; }
|
|
1386
|
+
.lm-zones { height: 4px; border-radius: 2px; }
|
|
1387
|
+
.lm-marks button { position: absolute; top: 0; transform: translateX(-50%); min-width: 20px; height: 24px; padding: 7px 2px 0; border: 0; background: none; font: 500 .68rem var(--lm-mono); color: var(--lm-accent); white-space: nowrap; cursor: pointer; }
|
|
1388
|
+
.lm-marks button::before { content: ""; position: absolute; left: 50%; top: 0; width: 2px; height: 6px; margin-left: -1px; background: currentColor; }
|
|
1389
|
+
.lm-marks button:not([data-label]) span { display: none; }
|
|
1390
|
+
.lm-marks [data-kind="target"] { color: var(--lm-warn); }
|
|
1391
|
+
.lm-marks [data-kind="full"] { color: var(--lm-drop); }
|
|
1392
|
+
.lm-marks [aria-pressed="true"] { font-weight: 700; text-decoration: underline; }
|
|
1393
|
+
.lm-key { display: inline-block; width: 14px; height: 2px; border-radius: 1px; vertical-align: 3px; margin-right: 6px; }
|
|
1394
|
+
|
|
1395
|
+
.lm-compare-text { margin: 0; }
|
|
1396
|
+
.lm-table-wrap { overflow-x: auto; }
|
|
1397
|
+
.lm-table { border-collapse: collapse; width: 100%; font-size: .84rem; }
|
|
1398
|
+
.lm-table th, .lm-table td { text-align: left; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--lm-line); vertical-align: top; }
|
|
1399
|
+
.lm-table thead th { font: 600 .7rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; color: var(--lm-muted); }
|
|
1400
|
+
.lm-table tbody th { font-weight: 600; white-space: nowrap; }
|
|
1401
|
+
.lm-table td { font-family: var(--lm-mono); font-variant-numeric: tabular-nums; }
|
|
1402
|
+
.lm-table td.lm-text { font-family: var(--lm-font); }
|
|
1403
|
+
.lm-table td small { display: block; font: 400 .72rem var(--lm-font); color: var(--lm-muted); }
|
|
1404
|
+
.lm-table tr[aria-current] th { text-decoration: underline; text-underline-offset: 3px; }
|
|
1405
|
+
|
|
1406
|
+
.lm-chart { position: relative; min-width: 0; }
|
|
1407
|
+
.lm-chart svg { display: block; overflow: visible; }
|
|
1408
|
+
.lm-chart:focus-visible { outline: 2px solid var(--lm-accent); outline-offset: 2px; }
|
|
1409
|
+
.lm-axis, .lm-axis text { font: 400 11px var(--lm-mono); fill: var(--lm-muted); }
|
|
1410
|
+
.lm-mark { font: 600 11px var(--lm-mono); fill: var(--lm-fg); }
|
|
1411
|
+
.lm-tip { position: absolute; z-index: 2; display: grid; gap: 2px; width: max-content; max-width: min(17rem, calc(100% - 8px)); overflow-wrap: anywhere; padding: 8px 10px; font-size: .78rem; background: var(--lm-surface); color: var(--lm-fg); border: 1px solid var(--lm-line); border-radius: 6px; box-shadow: 0 4px 14px rgb(0 0 0 / .14); pointer-events: none; }
|
|
1412
|
+
.lm-tip strong { font: 600 .82rem var(--lm-mono); font-variant-numeric: tabular-nums; }
|
|
1413
|
+
.lm-tip .lm-sub { color: var(--lm-muted); }
|
|
1414
|
+
.lm-nowrap { white-space: nowrap; }
|
|
1415
|
+
.lm-node { cursor: pointer; outline: none; }
|
|
1416
|
+
.lm-node:focus-visible > :first-child { stroke-width: 3; }
|
|
1417
|
+
|
|
1418
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1419
|
+
.lm-fill { transition: none; }
|
|
1420
|
+
.lm-story[data-playing] .lm-story-progress i[data-state="now"]::before { animation: none; transform: none; }
|
|
1394
1421
|
}
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
const el = ref.current;
|
|
1404
|
-
if (!el) return;
|
|
1405
|
-
const ro = new ResizeObserver(([e]) => {
|
|
1406
|
-
const width = Math.round(e?.contentRect.width ?? el.clientWidth);
|
|
1407
|
-
const height = Math.round(e?.contentRect.height ?? el.clientHeight);
|
|
1408
|
-
if (width > 0) setSize((s) => s.width === width && s.height === height ? s : {
|
|
1409
|
-
width,
|
|
1410
|
-
height
|
|
1411
|
-
});
|
|
1412
|
-
});
|
|
1413
|
-
ro.observe(el);
|
|
1414
|
-
return () => ro.disconnect();
|
|
1415
|
-
}, []);
|
|
1416
|
-
return [ref, size];
|
|
1422
|
+
${CANVAS_CSS}`;
|
|
1423
|
+
/** Adds the stylesheet once per document. */
|
|
1424
|
+
function injectStyles(doc = document) {
|
|
1425
|
+
if (doc.getElementById("loadmap-css")) return;
|
|
1426
|
+
const el = doc.createElement("style");
|
|
1427
|
+
el.id = "loadmap-css";
|
|
1428
|
+
el.textContent = LOADMAP_CSS;
|
|
1429
|
+
doc.head.appendChild(el);
|
|
1417
1430
|
}
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
const
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
}), [model, rest]);
|
|
1431
|
+
// src/Canvas.tsx
|
|
1432
|
+
const Ctx = createContext(null);
|
|
1433
|
+
function slots(what) {
|
|
1434
|
+
const c = use(Ctx);
|
|
1435
|
+
if (!c) throw new Error(`loadmap: ${what} belongs inside <Canvas>`);
|
|
1436
|
+
return c;
|
|
1437
|
+
}
|
|
1438
|
+
/** The size class of the canvas this is drawn in: a part folds by it, never by the window. */
|
|
1439
|
+
function useCanvasSize() {
|
|
1440
|
+
return slots("useCanvasSize()").size;
|
|
1429
1441
|
}
|
|
1430
1442
|
/**
|
|
1431
|
-
* The
|
|
1432
|
-
*
|
|
1443
|
+
* The panels of the canvas this is drawn in: their ids, the one that is open, `show` to open or close one, and
|
|
1444
|
+
* whether they are away for a while (`under`: something lies over the bar).
|
|
1433
1445
|
*/
|
|
1434
|
-
function
|
|
1435
|
-
const
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
return ctx.measureText(text).width;
|
|
1443
|
-
});
|
|
1444
|
-
}, [el]);
|
|
1445
|
-
return measure;
|
|
1446
|
+
function useCanvasPanels() {
|
|
1447
|
+
const { panels, open, show, under } = slots("useCanvasPanels()");
|
|
1448
|
+
return {
|
|
1449
|
+
panels,
|
|
1450
|
+
open,
|
|
1451
|
+
show,
|
|
1452
|
+
under
|
|
1453
|
+
};
|
|
1446
1454
|
}
|
|
1447
|
-
/**
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1455
|
+
/**
|
|
1456
|
+
* An element's size in pixels, read before the first paint and on every change; null until it is there. Not `useSize`
|
|
1457
|
+
* (scenarios.tsx): the diagram waits for these sizes, so they are read in the commit that mounts the element.
|
|
1458
|
+
*/
|
|
1459
|
+
function useBox(el, inner = false) {
|
|
1460
|
+
const [box, setBox] = useState(null);
|
|
1461
|
+
useLayoutEffect(() => {
|
|
1462
|
+
if (!el) {
|
|
1463
|
+
setBox(null);
|
|
1464
|
+
return;
|
|
1465
|
+
}
|
|
1466
|
+
const read = () => {
|
|
1467
|
+
const r = inner ? {
|
|
1468
|
+
width: el.clientWidth,
|
|
1469
|
+
height: el.clientHeight
|
|
1470
|
+
} : el.getBoundingClientRect();
|
|
1471
|
+
setBox((was) => was && was.w === r.width && was.h === r.height ? was : {
|
|
1472
|
+
w: r.width,
|
|
1473
|
+
h: r.height
|
|
1474
|
+
});
|
|
1475
|
+
};
|
|
1476
|
+
read();
|
|
1477
|
+
const ro = new ResizeObserver(read);
|
|
1478
|
+
ro.observe(el);
|
|
1479
|
+
return () => ro.disconnect();
|
|
1480
|
+
}, [el, inner]);
|
|
1481
|
+
return box;
|
|
1459
1482
|
}
|
|
1460
1483
|
/**
|
|
1461
|
-
*
|
|
1462
|
-
*
|
|
1463
|
-
*
|
|
1464
|
-
* and 100 % lines spans where the band crosses them. The shown scenario's components are the thin lines under it.
|
|
1465
|
-
* Hover or arrow keys read every line at one load.
|
|
1484
|
+
* Everything of a loadmap in one box the page sizes: the diagram fills it as a board the reader pans and zooms, a bar
|
|
1485
|
+
* lies over its top and a console over its bottom, and one panel at a time opens from its tabs. The diagram is arranged
|
|
1486
|
+
* for what the bars and the size class always leave; a panel that opens only moves the view.
|
|
1466
1487
|
*/
|
|
1467
|
-
function
|
|
1468
|
-
const
|
|
1469
|
-
const
|
|
1470
|
-
const [
|
|
1471
|
-
const [
|
|
1472
|
-
|
|
1473
|
-
const measure = useAxisMeasure(wrap);
|
|
1474
|
-
const tip = useRef(null);
|
|
1488
|
+
function Canvas({ lm, label, open: given, defaultOpen = null, onOpen, over, scrolls, ref, className, style, children, legend, onNodeClick, selected }) {
|
|
1489
|
+
const [root, setRoot] = useState(null);
|
|
1490
|
+
const [barEl, setBar] = useState(null);
|
|
1491
|
+
const [consoleEl, setConsole] = useState(null);
|
|
1492
|
+
const [overEl, setOver] = useState(null);
|
|
1493
|
+
useImperativeHandle(ref, () => root, [root]);
|
|
1475
1494
|
useLayoutEffect(() => {
|
|
1476
|
-
|
|
1477
|
-
|
|
1495
|
+
if (root) injectStyles(root.ownerDocument);
|
|
1496
|
+
}, [root]);
|
|
1497
|
+
const now = useBox(root, true);
|
|
1498
|
+
const [box, setBox] = useState(null);
|
|
1499
|
+
if (now && now.w > 0 && now.h > 0 && now !== box) setBox(now);
|
|
1500
|
+
const bar = useBox(barEl);
|
|
1501
|
+
const cons = useBox(consoleEl);
|
|
1502
|
+
const lid = useBox(overEl);
|
|
1503
|
+
const under = over != null && over !== false;
|
|
1504
|
+
const all = Children.toArray(children);
|
|
1505
|
+
const of = (type) => (c) => isValidElement(c) && c.type === type;
|
|
1506
|
+
const bars = all.filter(of(Bar));
|
|
1507
|
+
const consoles = all.filter(of(Console));
|
|
1508
|
+
const panels = all.filter(of(Panel));
|
|
1509
|
+
const rest = all.filter((c) => ![
|
|
1510
|
+
Bar,
|
|
1511
|
+
Console,
|
|
1512
|
+
Panel
|
|
1513
|
+
].some((t) => of(t)(c)));
|
|
1514
|
+
const uid = useId();
|
|
1515
|
+
const ids = panels.map((p) => p.props.id);
|
|
1516
|
+
const idsKey = ids.join("\n");
|
|
1517
|
+
const { width, short, pinned } = canvasSize(box?.w ?? 0, box?.h ?? 0, lm.fullScreen);
|
|
1518
|
+
const size = useMemo(() => ({
|
|
1519
|
+
width,
|
|
1520
|
+
short,
|
|
1521
|
+
pinned
|
|
1522
|
+
}), [
|
|
1523
|
+
width,
|
|
1524
|
+
short,
|
|
1525
|
+
pinned
|
|
1526
|
+
]);
|
|
1527
|
+
const [own, setOwn] = useState(defaultOpen);
|
|
1528
|
+
const asked = given === void 0 ? own : given;
|
|
1529
|
+
const open = asked != null && ids.includes(asked) ? asked : size.pinned ? ids[0] ?? null : null;
|
|
1530
|
+
const [whole, setWhole] = useState(false);
|
|
1531
|
+
if (!open && whole) setWhole(false);
|
|
1532
|
+
const back = useRef(null);
|
|
1533
|
+
const at = useRef({
|
|
1534
|
+
root,
|
|
1535
|
+
open,
|
|
1536
|
+
uid
|
|
1478
1537
|
});
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
t: 14,
|
|
1484
|
-
b: dated ? 40 : 26
|
|
1538
|
+
at.current = {
|
|
1539
|
+
root,
|
|
1540
|
+
open,
|
|
1541
|
+
uid
|
|
1485
1542
|
};
|
|
1486
|
-
const
|
|
1487
|
-
|
|
1488
|
-
const
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
let pen = false;
|
|
1496
|
-
for (const [x, u] of s) {
|
|
1497
|
-
if (u == null) {
|
|
1498
|
-
pen = false;
|
|
1499
|
-
continue;
|
|
1500
|
-
}
|
|
1501
|
-
d += `${pen ? "L" : "M"}${lx(x).toFixed(1)} ${ly(u).toFixed(1)}`;
|
|
1502
|
-
pen = true;
|
|
1543
|
+
const change = useRef(onOpen);
|
|
1544
|
+
change.current = onOpen;
|
|
1545
|
+
const show = useCallback((id, from) => {
|
|
1546
|
+
if (id) back.current = from ?? null;
|
|
1547
|
+
else {
|
|
1548
|
+
const { root, open, uid } = at.current;
|
|
1549
|
+
const opener = back.current;
|
|
1550
|
+
back.current = null;
|
|
1551
|
+
if (!from) (opener?.isConnected ? opener : (root?.getRootNode())?.getElementById(tabId(uid, open ?? "")) ?? root?.querySelector(".lm-canvas-menu"))?.focus();
|
|
1503
1552
|
}
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
const
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
}
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1553
|
+
setOwn(id);
|
|
1554
|
+
change.current?.(id);
|
|
1555
|
+
}, []);
|
|
1556
|
+
const ctx = useMemo(() => ({
|
|
1557
|
+
size,
|
|
1558
|
+
bar: setBar,
|
|
1559
|
+
console: setConsole,
|
|
1560
|
+
panels: idsKey ? idsKey.split("\n") : [],
|
|
1561
|
+
open,
|
|
1562
|
+
show,
|
|
1563
|
+
under
|
|
1564
|
+
}), [
|
|
1565
|
+
size,
|
|
1566
|
+
idsKey,
|
|
1567
|
+
open,
|
|
1568
|
+
show,
|
|
1569
|
+
under
|
|
1570
|
+
]);
|
|
1571
|
+
const measured = !!box && (!bars.length || !!bar) && (!consoles.length || !!cons);
|
|
1572
|
+
const unseen = !box && !!now;
|
|
1573
|
+
const [started, setStarted] = useState(false);
|
|
1574
|
+
if (!started && (measured || unseen)) setStarted(true);
|
|
1575
|
+
const has = ids.length > 0;
|
|
1576
|
+
const tabs = has ? tabsAt(size) : null;
|
|
1577
|
+
const heights = {
|
|
1578
|
+
top: Math.max(Math.ceil(bar?.h ?? 0), tabs === "menu" ? CANVAS.menu : 0),
|
|
1579
|
+
bottom: Math.ceil(cons?.h ?? 0)
|
|
1519
1580
|
};
|
|
1520
|
-
const
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1581
|
+
const reserve = reserved(size, heights, has);
|
|
1582
|
+
const far = has && open && box && !under ? reach(size, heights, box.w, box.h, whole) : 0;
|
|
1583
|
+
const base = covered(size, heights, far, has);
|
|
1584
|
+
const inset = under ? {
|
|
1585
|
+
...base,
|
|
1586
|
+
top: Math.max(base.top, Math.ceil(lid?.h ?? 0))
|
|
1587
|
+
} : base;
|
|
1588
|
+
const place = placement(size);
|
|
1589
|
+
const shown = panels.find((p) => p.props.id === open);
|
|
1590
|
+
const vars = {
|
|
1591
|
+
...style,
|
|
1592
|
+
"--lm-canvas-right": `${reserve.right}px`,
|
|
1593
|
+
"--lm-canvas-top": `${heights.top}px`,
|
|
1594
|
+
"--lm-canvas-bottom": `${heights.bottom}px`,
|
|
1595
|
+
"--lm-canvas-under": `${reserve.bottom}px`,
|
|
1596
|
+
"--lm-canvas-reach": `${far}px`
|
|
1526
1597
|
};
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1598
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1599
|
+
className: className ? `lm-canvas ${className}` : "lm-canvas",
|
|
1600
|
+
role: "region",
|
|
1601
|
+
"aria-label": label ?? lm.model.title ?? "Capacity model",
|
|
1602
|
+
"data-width": size.width,
|
|
1603
|
+
"data-short": size.short ? "" : void 0,
|
|
1604
|
+
"data-pinned": size.pinned ? "" : void 0,
|
|
1605
|
+
"data-tabs": tabs ?? void 0,
|
|
1606
|
+
"data-over": under ? "" : void 0,
|
|
1607
|
+
style: vars,
|
|
1608
|
+
ref: setRoot,
|
|
1609
|
+
children: /* @__PURE__ */ jsxs(Ctx, {
|
|
1610
|
+
value: ctx,
|
|
1611
|
+
children: [
|
|
1612
|
+
box && bars,
|
|
1613
|
+
box && under && /* @__PURE__ */ jsx("div", {
|
|
1614
|
+
className: "lm-canvas-over",
|
|
1615
|
+
ref: setOver,
|
|
1616
|
+
children: over
|
|
1617
|
+
}),
|
|
1618
|
+
started && /* @__PURE__ */ jsx(Diagram, {
|
|
1619
|
+
lm,
|
|
1620
|
+
legend,
|
|
1621
|
+
onNodeClick,
|
|
1622
|
+
selected,
|
|
1623
|
+
canvas: {
|
|
1624
|
+
...inset,
|
|
1625
|
+
reserve,
|
|
1626
|
+
scrolls: lm.fullScreen && !lm.fill ? false : scrolls ?? !lm.fill
|
|
1627
|
+
}
|
|
1628
|
+
}),
|
|
1629
|
+
box && consoles,
|
|
1630
|
+
box && rest,
|
|
1631
|
+
box && tabs && !under && /* @__PURE__ */ jsx(Tabs, {
|
|
1632
|
+
uid,
|
|
1633
|
+
panels,
|
|
1634
|
+
open,
|
|
1635
|
+
show,
|
|
1636
|
+
at: tabs,
|
|
1637
|
+
canClose: !size.pinned
|
|
1638
|
+
}),
|
|
1639
|
+
box && shown && /* @__PURE__ */ jsx(PanelBox, {
|
|
1640
|
+
uid,
|
|
1641
|
+
away: under,
|
|
1642
|
+
panel: shown,
|
|
1643
|
+
place,
|
|
1644
|
+
pinned: size.pinned,
|
|
1645
|
+
whole,
|
|
1646
|
+
setWhole,
|
|
1647
|
+
close: () => show(null)
|
|
1648
|
+
})
|
|
1649
|
+
]
|
|
1650
|
+
})
|
|
1651
|
+
});
|
|
1652
|
+
}
|
|
1653
|
+
const tabId = (uid, id) => `${uid}tab-${id}`;
|
|
1654
|
+
const panelId = (uid) => `${uid}panel`;
|
|
1655
|
+
/**
|
|
1656
|
+
* The panels' tabs: a button each, which opens its panel and closes it again (a pinned panel stays). The arrows move
|
|
1657
|
+
* between them. A low canvas has one menu in their place.
|
|
1658
|
+
*/
|
|
1659
|
+
function Tabs({ uid, panels, open, show, at, canClose }) {
|
|
1660
|
+
if (at === "menu") return /* @__PURE__ */ jsxs("select", {
|
|
1661
|
+
className: "lm-canvas-menu",
|
|
1662
|
+
"aria-label": "Open a panel",
|
|
1663
|
+
value: open ?? "",
|
|
1664
|
+
onChange: (e) => show(e.target.value || null, e.currentTarget),
|
|
1665
|
+
children: [/* @__PURE__ */ jsx("option", {
|
|
1666
|
+
value: "",
|
|
1667
|
+
children: "Panels"
|
|
1668
|
+
}), panels.map((p) => /* @__PURE__ */ jsx("option", {
|
|
1669
|
+
value: p.props.id,
|
|
1670
|
+
children: p.props.title
|
|
1671
|
+
}, p.props.id))]
|
|
1672
|
+
});
|
|
1673
|
+
const move = (e) => {
|
|
1674
|
+
if (e.key === "Escape" && open && canClose) {
|
|
1675
|
+
e.stopPropagation();
|
|
1676
|
+
return show(null, e.target);
|
|
1677
|
+
}
|
|
1678
|
+
const by = {
|
|
1679
|
+
ArrowRight: 1,
|
|
1680
|
+
ArrowDown: 1,
|
|
1681
|
+
ArrowLeft: -1,
|
|
1682
|
+
ArrowUp: -1
|
|
1683
|
+
}[e.key];
|
|
1684
|
+
if (!by) return;
|
|
1685
|
+
const all = [...e.currentTarget.querySelectorAll("button")];
|
|
1686
|
+
const i = all.indexOf(e.target);
|
|
1687
|
+
if (i < 0) return;
|
|
1688
|
+
e.preventDefault();
|
|
1689
|
+
all[(i + by + all.length) % all.length]?.focus();
|
|
1540
1690
|
};
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1691
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1692
|
+
className: "lm-canvas-tabs",
|
|
1693
|
+
role: "toolbar",
|
|
1694
|
+
"aria-label": "Panels",
|
|
1695
|
+
"aria-orientation": at === "rail" ? "vertical" : "horizontal",
|
|
1696
|
+
onKeyDown: move,
|
|
1697
|
+
children: panels.map((p) => {
|
|
1698
|
+
const on = p.props.id === open;
|
|
1699
|
+
return /* @__PURE__ */ jsx("button", {
|
|
1700
|
+
type: "button",
|
|
1701
|
+
id: tabId(uid, p.props.id),
|
|
1702
|
+
"aria-expanded": on,
|
|
1703
|
+
"aria-controls": on ? panelId(uid) : void 0,
|
|
1704
|
+
onClick: (e) => on ? canClose && show(null, e.currentTarget) : show(p.props.id, e.currentTarget),
|
|
1705
|
+
children: /* @__PURE__ */ jsx("span", { children: p.props.title })
|
|
1706
|
+
}, p.props.id);
|
|
1707
|
+
})
|
|
1708
|
+
});
|
|
1709
|
+
}
|
|
1710
|
+
/**
|
|
1711
|
+
* The open panel: beside the diagram, or a sheet on the console that stands half or whole. Escape closes it and gives
|
|
1712
|
+
* the keyboard back to its tab; nothing but the panel scrolls in a canvas.
|
|
1713
|
+
*/
|
|
1714
|
+
function PanelBox({ uid, away, panel, place, pinned, whole, setWhole, close }) {
|
|
1715
|
+
const { id, title, children } = panel.props;
|
|
1716
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
1717
|
+
id: panelId(uid),
|
|
1718
|
+
hidden: away,
|
|
1719
|
+
className: "lm-canvas-panel",
|
|
1720
|
+
"data-place": place,
|
|
1721
|
+
"data-panel": id,
|
|
1722
|
+
"aria-labelledby": `${panelId(uid)}-title`,
|
|
1723
|
+
tabIndex: -1,
|
|
1724
|
+
onKeyDown: (e) => {
|
|
1725
|
+
if (e.key !== "Escape" || pinned || e.defaultPrevented) return;
|
|
1726
|
+
if (e.target.closest("select, input, textarea")) return;
|
|
1727
|
+
e.stopPropagation();
|
|
1728
|
+
close();
|
|
1729
|
+
},
|
|
1730
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1731
|
+
className: "lm-canvas-panel-head",
|
|
1732
|
+
children: [
|
|
1733
|
+
/* @__PURE__ */ jsx("h3", {
|
|
1734
|
+
id: `${panelId(uid)}-title`,
|
|
1735
|
+
children: title
|
|
1736
|
+
}),
|
|
1737
|
+
place === "sheet" && /* @__PURE__ */ jsx("button", {
|
|
1738
|
+
type: "button",
|
|
1739
|
+
className: "lm-btn",
|
|
1740
|
+
"aria-pressed": whole,
|
|
1741
|
+
onClick: () => setWhole(!whole),
|
|
1742
|
+
children: whole ? "Half" : "Whole"
|
|
1743
|
+
}),
|
|
1744
|
+
!pinned && /* @__PURE__ */ jsx("button", {
|
|
1745
|
+
type: "button",
|
|
1746
|
+
className: "lm-btn",
|
|
1747
|
+
"aria-label": `Close ${title}`,
|
|
1748
|
+
onClick: close,
|
|
1749
|
+
children: "✕"
|
|
1750
|
+
})
|
|
1751
|
+
]
|
|
1752
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1753
|
+
className: "lm-canvas-panel-body",
|
|
1754
|
+
children
|
|
1755
|
+
})]
|
|
1756
|
+
});
|
|
1757
|
+
}
|
|
1758
|
+
/** Over the canvas's top: what the reader chooses from (the scenarios, the story, the tools). */
|
|
1759
|
+
function Bar({ children }) {
|
|
1760
|
+
const s = slots("<Canvas.Bar>");
|
|
1761
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1762
|
+
className: "lm-canvas-bar",
|
|
1763
|
+
ref: s.bar,
|
|
1764
|
+
inert: s.under,
|
|
1765
|
+
children
|
|
1766
|
+
});
|
|
1767
|
+
}
|
|
1768
|
+
/** Over the canvas's bottom: the load and the answer, always in view. */
|
|
1769
|
+
function Console({ children }) {
|
|
1770
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1771
|
+
className: "lm-canvas-console",
|
|
1772
|
+
ref: slots("<Canvas.Console>").console,
|
|
1773
|
+
children
|
|
1774
|
+
});
|
|
1775
|
+
}
|
|
1776
|
+
/** One of the canvas's panels: a tab that opens it, one at a time. The canvas draws it; by itself it draws nothing. */
|
|
1777
|
+
function Panel(_) {
|
|
1778
|
+
return null;
|
|
1779
|
+
}
|
|
1780
|
+
Canvas.Bar = Bar;
|
|
1781
|
+
Canvas.Console = Console;
|
|
1782
|
+
Canvas.Panel = Panel;
|
|
1783
|
+
// src/elk.ts
|
|
1784
|
+
let shared = null;
|
|
1785
|
+
/**
|
|
1786
|
+
* One ELK worker for every loadmap on the page, started on the first layout. When the worker cannot start or load
|
|
1787
|
+
* (no Worker, a CSP without worker-src, a dev server that pre-bundled this package away from the worker file), every
|
|
1788
|
+
* layout runs on the main thread instead: slower to start, the same result.
|
|
1789
|
+
*/
|
|
1790
|
+
function pageElk() {
|
|
1791
|
+
shared ??= workerElk(() => new Worker(new URL("./elk.worker.js", import.meta.url), {
|
|
1792
|
+
type: "module",
|
|
1793
|
+
name: "loadmap-elk"
|
|
1794
|
+
}));
|
|
1795
|
+
return shared;
|
|
1796
|
+
}
|
|
1797
|
+
/**
|
|
1798
|
+
* ELK in the worker `make` starts, falling back to the main thread: `<Loadmap elk={workerElk(…)}>` for a page whose
|
|
1799
|
+
* bundler inlines the worker (`@loadmap/react/elk.worker.js`), or that serves it from another place. Make it once,
|
|
1800
|
+
* outside a component: each engine starts its own worker.
|
|
1801
|
+
*/
|
|
1802
|
+
function workerElk(make) {
|
|
1803
|
+
let worker = null;
|
|
1804
|
+
let broken = typeof Worker === "undefined";
|
|
1805
|
+
let told = false;
|
|
1806
|
+
let next = 0;
|
|
1807
|
+
const pending = /* @__PURE__ */ new Map();
|
|
1808
|
+
const tell = (why) => {
|
|
1809
|
+
if (told || typeof Worker === "undefined") return;
|
|
1810
|
+
told = true;
|
|
1811
|
+
console.info(`loadmap: the layout runs on the main thread, slower to start: the ELK worker did not start (${why}). A page can hand one in, <Loadmap elk={workerElk(() => new Worker(…))}>; a Content-Security-Policy must allow it (worker-src).`);
|
|
1549
1812
|
};
|
|
1550
|
-
const
|
|
1551
|
-
|
|
1552
|
-
|
|
1813
|
+
const fallBack = (why) => {
|
|
1814
|
+
tell(why);
|
|
1815
|
+
broken = true;
|
|
1816
|
+
worker?.terminate();
|
|
1817
|
+
worker = null;
|
|
1818
|
+
for (const [id, p] of pending) {
|
|
1819
|
+
pending.delete(id);
|
|
1820
|
+
localElk().then((elk) => elk.layout(p.graph)).then(p.resolve, p.reject);
|
|
1821
|
+
}
|
|
1553
1822
|
};
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1823
|
+
const start = () => {
|
|
1824
|
+
if (worker || broken) return worker;
|
|
1825
|
+
try {
|
|
1826
|
+
worker = make();
|
|
1827
|
+
} catch (err) {
|
|
1828
|
+
fallBack(err instanceof Error ? err.message : String(err));
|
|
1829
|
+
return null;
|
|
1830
|
+
}
|
|
1831
|
+
worker.onmessage = ({ data }) => {
|
|
1832
|
+
const p = pending.get(data.id);
|
|
1833
|
+
if (!p) return;
|
|
1834
|
+
pending.delete(data.id);
|
|
1835
|
+
if (data.error != null) p.reject(new Error(data.error));
|
|
1836
|
+
else p.resolve(data.graph);
|
|
1559
1837
|
};
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1838
|
+
worker.onerror = (e) => {
|
|
1839
|
+
e.preventDefault();
|
|
1840
|
+
fallBack(e.message || "it failed to load or to run");
|
|
1563
1841
|
};
|
|
1564
|
-
|
|
1565
|
-
const fitsLeft = x - gap - w >= 0;
|
|
1566
|
-
if (prefer === "right" ? fitsRight : !fitsLeft && fitsRight) return right;
|
|
1567
|
-
if (fitsLeft) return left;
|
|
1568
|
-
return x < W / 2 ? fromLeft : fromRight;
|
|
1569
|
-
};
|
|
1570
|
-
/** A label centred on x, unless that passes an edge. */
|
|
1571
|
-
const centred = (x, w) => x - w / 2 < 0 ? fromLeft : x + w / 2 > W ? fromRight : {
|
|
1572
|
-
x,
|
|
1573
|
-
textAnchor: "middle"
|
|
1842
|
+
return worker;
|
|
1574
1843
|
};
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
/* @__PURE__ */ jsxs("div", {
|
|
1595
|
-
className: "lm-chart",
|
|
1596
|
-
ref: wrap,
|
|
1597
|
-
role: "slider",
|
|
1598
|
-
"aria-label": `Utilization over the load multiple. ${summary}.`,
|
|
1599
|
-
"aria-valuemin": h.from,
|
|
1600
|
-
"aria-valuemax": h.to,
|
|
1601
|
-
"aria-valuenow": hx ?? values.load,
|
|
1602
|
-
"aria-valuetext": hx == null ? `${fmt(values.load)}×` : `${fmt(hx)}×: ${h.lines.map((l) => `${lineName(l)} ${l.envelope[hover][1] == null ? "off" : pct(l.envelope[hover][1])}`).join(", ")}`,
|
|
1603
|
-
tabIndex: 0,
|
|
1604
|
-
onKeyDown: onKey,
|
|
1605
|
-
onBlur: () => setHover(null),
|
|
1606
|
-
children: [/* @__PURE__ */ jsxs("svg", {
|
|
1607
|
-
width: W,
|
|
1608
|
-
height: H,
|
|
1609
|
-
viewBox: `0 0 ${W} ${H}`,
|
|
1610
|
-
"aria-hidden": "true",
|
|
1611
|
-
children: [
|
|
1612
|
-
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("clipPath", {
|
|
1613
|
-
id: clip,
|
|
1614
|
-
children: /* @__PURE__ */ jsx("rect", {
|
|
1615
|
-
x: m.l,
|
|
1616
|
-
y: m.t,
|
|
1617
|
-
width: pw,
|
|
1618
|
-
height: ph + 2
|
|
1619
|
-
})
|
|
1620
|
-
}) }),
|
|
1621
|
-
[
|
|
1622
|
-
0,
|
|
1623
|
-
model.thresholds.target,
|
|
1624
|
-
model.thresholds.full
|
|
1625
|
-
].map((u) => /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("line", {
|
|
1626
|
-
x1: m.l,
|
|
1627
|
-
x2: W - m.r,
|
|
1628
|
-
y1: ly(u),
|
|
1629
|
-
y2: ly(u),
|
|
1630
|
-
stroke: "var(--lm-line)"
|
|
1631
|
-
}), /* @__PURE__ */ jsx("text", {
|
|
1632
|
-
x: m.l - 6,
|
|
1633
|
-
y: ly(u) + 4,
|
|
1634
|
-
textAnchor: "end",
|
|
1635
|
-
className: "lm-axis",
|
|
1636
|
-
children: pct(u)
|
|
1637
|
-
})] }, u)),
|
|
1638
|
-
/* @__PURE__ */ jsx("text", {
|
|
1639
|
-
x: W - m.r,
|
|
1640
|
-
y: ly(model.thresholds.target) - 5,
|
|
1641
|
-
textAnchor: "end",
|
|
1642
|
-
className: "lm-axis",
|
|
1643
|
-
children: "target"
|
|
1644
|
-
}),
|
|
1645
|
-
tickList.map((x) => {
|
|
1646
|
-
const label = `${fmt(x)}×`;
|
|
1647
|
-
const date = dated && x > 1 ? when(model, x) : "";
|
|
1648
|
-
return /* @__PURE__ */ jsxs("g", {
|
|
1649
|
-
className: "lm-axis",
|
|
1650
|
-
children: [/* @__PURE__ */ jsx("line", {
|
|
1651
|
-
x1: lx(x),
|
|
1652
|
-
x2: lx(x),
|
|
1653
|
-
y1: m.t + ph,
|
|
1654
|
-
y2: m.t + ph + 4,
|
|
1655
|
-
stroke: "var(--lm-line)"
|
|
1656
|
-
}), labelled(x) && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("text", {
|
|
1657
|
-
...centred(lx(x), measure(label)),
|
|
1658
|
-
y: m.t + ph + 16,
|
|
1659
|
-
children: label
|
|
1660
|
-
}), date && /* @__PURE__ */ jsx("text", {
|
|
1661
|
-
...centred(lx(x), measure(date)),
|
|
1662
|
-
y: m.t + ph + 30,
|
|
1663
|
-
children: date
|
|
1664
|
-
})] })]
|
|
1665
|
-
}, x);
|
|
1666
|
-
}),
|
|
1667
|
-
/* @__PURE__ */ jsxs("g", {
|
|
1668
|
-
clipPath: `url(#${clip})`,
|
|
1669
|
-
children: [
|
|
1670
|
-
[...h.lines].sort((a, b) => Number(a.selected) - Number(b.selected)).map((l) => l.band ? /* @__PURE__ */ jsx("path", {
|
|
1671
|
-
"data-band": lineName(l),
|
|
1672
|
-
d: area(l.band),
|
|
1673
|
-
fill: scenarioColor(model, l.label),
|
|
1674
|
-
fillOpacity: l.selected ? .2 : .08
|
|
1675
|
-
}, lineName(l)) : null),
|
|
1676
|
-
selected?.components.map((c) => /* @__PURE__ */ jsx("path", {
|
|
1677
|
-
d: path(c.points),
|
|
1678
|
-
fill: "none",
|
|
1679
|
-
stroke: "var(--lm-muted)",
|
|
1680
|
-
strokeOpacity: ".55",
|
|
1681
|
-
strokeWidth: "1"
|
|
1682
|
-
}, c.id)),
|
|
1683
|
-
[...h.lines].sort((a, b) => Number(a.selected) - Number(b.selected)).map((l) => /* @__PURE__ */ jsx("path", {
|
|
1684
|
-
"data-line": lineName(l),
|
|
1685
|
-
d: path(l.envelope),
|
|
1686
|
-
fill: "none",
|
|
1687
|
-
stroke: scenarioColor(model, l.label),
|
|
1688
|
-
strokeWidth: "2",
|
|
1689
|
-
strokeLinejoin: "round",
|
|
1690
|
-
strokeLinecap: "round"
|
|
1691
|
-
}, lineName(l)))
|
|
1692
|
-
]
|
|
1693
|
-
}),
|
|
1694
|
-
/* @__PURE__ */ jsx("line", {
|
|
1695
|
-
x1: loadX,
|
|
1696
|
-
x2: loadX,
|
|
1697
|
-
y1: m.t,
|
|
1698
|
-
y2: m.t + ph,
|
|
1699
|
-
stroke: "var(--lm-fg)",
|
|
1700
|
-
strokeOpacity: ".45"
|
|
1701
|
-
}),
|
|
1702
|
-
/* @__PURE__ */ jsx("text", {
|
|
1703
|
-
...beside(loadX, measure(shown), "right"),
|
|
1704
|
-
y: m.t + 10,
|
|
1705
|
-
className: "lm-axis",
|
|
1706
|
-
children: shown
|
|
1707
|
-
}),
|
|
1708
|
-
h.lines.flatMap((l) => [[
|
|
1709
|
-
"target",
|
|
1710
|
-
l.targetRange,
|
|
1711
|
-
model.thresholds.target
|
|
1712
|
-
], [
|
|
1713
|
-
"full",
|
|
1714
|
-
l.fullRange,
|
|
1715
|
-
model.thresholds.full
|
|
1716
|
-
]].map(([kind, r, u]) => {
|
|
1717
|
-
if (!l.band || !r || !Number.isFinite(r.low) || r.low > h.to) return null;
|
|
1718
|
-
const [x1, x2] = [lx(Math.max(h.from, r.low)), lx(Math.min(h.to, r.high))];
|
|
1719
|
-
const y = ly(u);
|
|
1720
|
-
return /* @__PURE__ */ jsxs("g", {
|
|
1721
|
-
"data-range": kind,
|
|
1722
|
-
"data-scenario": lineName(l),
|
|
1723
|
-
"data-low": r.low,
|
|
1724
|
-
"data-high": r.high,
|
|
1725
|
-
stroke: scenarioColor(model, l.label),
|
|
1726
|
-
strokeWidth: l.selected ? 3 : 2,
|
|
1727
|
-
strokeOpacity: l.selected ? 1 : .6,
|
|
1728
|
-
children: [
|
|
1729
|
-
/* @__PURE__ */ jsx("line", {
|
|
1730
|
-
x1,
|
|
1731
|
-
x2,
|
|
1732
|
-
y1: y,
|
|
1733
|
-
y2: y
|
|
1734
|
-
}),
|
|
1735
|
-
/* @__PURE__ */ jsx("line", {
|
|
1736
|
-
x1,
|
|
1737
|
-
x2: x1,
|
|
1738
|
-
y1: y - 5,
|
|
1739
|
-
y2: y + 5
|
|
1740
|
-
}),
|
|
1741
|
-
Number.isFinite(r.high) && r.high <= h.to && /* @__PURE__ */ jsx("line", {
|
|
1742
|
-
x1: x2,
|
|
1743
|
-
x2,
|
|
1744
|
-
y1: y - 5,
|
|
1745
|
-
y2: y + 5
|
|
1746
|
-
})
|
|
1747
|
-
]
|
|
1748
|
-
}, `${lineName(l)}/${kind}/range`);
|
|
1749
|
-
})),
|
|
1750
|
-
h.lines.flatMap((l) => [[
|
|
1751
|
-
"target",
|
|
1752
|
-
l.target,
|
|
1753
|
-
l.targetRange,
|
|
1754
|
-
model.thresholds.target
|
|
1755
|
-
], [
|
|
1756
|
-
"full",
|
|
1757
|
-
l.full,
|
|
1758
|
-
l.fullRange,
|
|
1759
|
-
model.thresholds.full
|
|
1760
|
-
]].map(([kind, x, r, u]) => x != null && Number.isFinite(x) && x >= h.from && x <= h.to ? /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("circle", {
|
|
1761
|
-
"data-crossing": kind,
|
|
1762
|
-
"data-scenario": lineName(l),
|
|
1763
|
-
"data-multiple": x,
|
|
1764
|
-
cx: lx(x),
|
|
1765
|
-
cy: ly(u),
|
|
1766
|
-
r: "4",
|
|
1767
|
-
fill: scenarioColor(model, l.label),
|
|
1768
|
-
stroke: "var(--lm-surface)",
|
|
1769
|
-
strokeWidth: "2"
|
|
1770
|
-
}), l.selected && mark(r && l0(r) ? multiples(r, model.searchMax, true) : multiple(x, model.searchMax), lx(r && l0(r) ? Math.max(h.from, r.low) : x), ly(u) - 8)] }, `${lineName(l)}/${kind}`) : null)),
|
|
1771
|
-
hx != null && /* @__PURE__ */ jsx("line", {
|
|
1772
|
-
x1: lx(hx),
|
|
1773
|
-
x2: lx(hx),
|
|
1774
|
-
y1: m.t,
|
|
1775
|
-
y2: m.t + ph,
|
|
1776
|
-
stroke: "var(--lm-fg)",
|
|
1777
|
-
strokeOpacity: ".8"
|
|
1778
|
-
}),
|
|
1779
|
-
/* @__PURE__ */ jsx("rect", {
|
|
1780
|
-
x: m.l,
|
|
1781
|
-
y: m.t,
|
|
1782
|
-
width: pw,
|
|
1783
|
-
height: ph,
|
|
1784
|
-
fill: "transparent",
|
|
1785
|
-
onPointerMove: onMove,
|
|
1786
|
-
onPointerDown: onMove,
|
|
1787
|
-
onPointerLeave: () => setHover(null)
|
|
1788
|
-
})
|
|
1789
|
-
]
|
|
1790
|
-
}), hover != null && hx != null && /* @__PURE__ */ jsxs("div", {
|
|
1791
|
-
className: "lm-tip",
|
|
1792
|
-
role: "status",
|
|
1793
|
-
ref: tip,
|
|
1794
|
-
style: {
|
|
1795
|
-
left: lx(hx) + 10,
|
|
1796
|
-
top: m.t
|
|
1797
|
-
},
|
|
1798
|
-
children: [
|
|
1799
|
-
/* @__PURE__ */ jsxs("b", { children: [
|
|
1800
|
-
fmt(hx),
|
|
1801
|
-
"×",
|
|
1802
|
-
when(model, hx) && ` · ${when(model, hx)}`
|
|
1803
|
-
] }),
|
|
1804
|
-
h.lines.map((l) => /* @__PURE__ */ jsxs("span", { children: [
|
|
1805
|
-
/* @__PURE__ */ jsx("b", {
|
|
1806
|
-
className: "lm-key",
|
|
1807
|
-
style: { background: scenarioColor(model, l.label) }
|
|
1808
|
-
}),
|
|
1809
|
-
/* @__PURE__ */ jsx("strong", { children: l.envelope[hover][1] == null ? "off" : pct(l.envelope[hover][1]) }),
|
|
1810
|
-
" ",
|
|
1811
|
-
lineName(l)
|
|
1812
|
-
] }, lineName(l))),
|
|
1813
|
-
selected?.components.map((c) => /* @__PURE__ */ jsxs("span", {
|
|
1814
|
-
className: "lm-sub",
|
|
1815
|
-
children: [
|
|
1816
|
-
/* @__PURE__ */ jsx("strong", { children: c.points[hover][1] == null ? "off" : pct(c.points[hover][1]) }),
|
|
1817
|
-
" ",
|
|
1818
|
-
c.name
|
|
1819
|
-
]
|
|
1820
|
-
}, c.id))
|
|
1821
|
-
]
|
|
1822
|
-
})]
|
|
1823
|
-
})
|
|
1824
|
-
]
|
|
1825
|
-
});
|
|
1844
|
+
return { layout(graph) {
|
|
1845
|
+
const w = start();
|
|
1846
|
+
if (!w) {
|
|
1847
|
+
tell("no Worker here");
|
|
1848
|
+
return localElk().then((elk) => elk.layout(graph));
|
|
1849
|
+
}
|
|
1850
|
+
return new Promise((resolve, reject) => {
|
|
1851
|
+
const id = next++;
|
|
1852
|
+
pending.set(id, {
|
|
1853
|
+
graph,
|
|
1854
|
+
resolve,
|
|
1855
|
+
reject
|
|
1856
|
+
});
|
|
1857
|
+
w.postMessage({
|
|
1858
|
+
id,
|
|
1859
|
+
graph
|
|
1860
|
+
});
|
|
1861
|
+
});
|
|
1862
|
+
} };
|
|
1826
1863
|
}
|
|
1827
1864
|
// src/track.ts
|
|
1828
1865
|
/**
|
|
@@ -1882,246 +1919,77 @@ function labelled(marks, at, width) {
|
|
|
1882
1919
|
}
|
|
1883
1920
|
return out;
|
|
1884
1921
|
}
|
|
1885
|
-
// src/
|
|
1886
|
-
/**
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
})] });
|
|
1922
|
+
// src/bar.tsx
|
|
1923
|
+
/** Scenario identity colours, in declaration order; a fifth and later scenario is drawn muted. */
|
|
1924
|
+
const SERIES = [
|
|
1925
|
+
"var(--lm-s1)",
|
|
1926
|
+
"var(--lm-s2)",
|
|
1927
|
+
"var(--lm-s3)",
|
|
1928
|
+
"var(--lm-s4)"
|
|
1929
|
+
];
|
|
1930
|
+
/** The colour of a scenario by label; values of the reader's own are drawn in the text colour. */
|
|
1931
|
+
function scenarioColor(model, label) {
|
|
1932
|
+
if (label == null) return "var(--lm-fg)";
|
|
1933
|
+
const i = model.scenarios.findIndex((s) => s.label === label);
|
|
1934
|
+
return SERIES[i] ?? "var(--lm-muted)";
|
|
1899
1935
|
}
|
|
1900
|
-
/**
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
range: ""
|
|
1911
|
-
}[kind];
|
|
1912
|
-
if (kind === "range" && !pm) return null;
|
|
1913
|
-
return /* @__PURE__ */ jsx("span", {
|
|
1914
|
-
className: "lm-tag",
|
|
1915
|
-
"data-kind": kind,
|
|
1916
|
-
children: short && kind === "range" ? "±" : [word, short ? "" : pm].filter(Boolean).join(" ")
|
|
1917
|
-
});
|
|
1936
|
+
/** A month for a table cell or an axis: "Mar 2031"; "now" for a crossing already reached. */
|
|
1937
|
+
function when(model, x) {
|
|
1938
|
+
const d = model.dateAt(x);
|
|
1939
|
+
return d ? monthOf(d, true) : x != null && x <= 1 && model.growth ? "now" : "";
|
|
1940
|
+
}
|
|
1941
|
+
/** The months of both edges: "Sep 2029–Feb 2030", or one month when they agree. */
|
|
1942
|
+
function whenRange(model, r) {
|
|
1943
|
+
if (!r) return "";
|
|
1944
|
+
const [lo, hi] = [when(model, r.low), when(model, r.high)];
|
|
1945
|
+
return !hi || lo === hi ? lo : `${lo}–${hi}`;
|
|
1918
1946
|
}
|
|
1919
|
-
/**
|
|
1920
|
-
function
|
|
1921
|
-
const {
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
/* @__PURE__ */ jsx("
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
}),
|
|
1940
|
-
/* @__PURE__ */ jsxs("span", {
|
|
1941
|
-
style: { left: at(model.thresholds.target) },
|
|
1942
|
-
children: [pct(model.thresholds.target), " target"]
|
|
1943
|
-
}),
|
|
1944
|
-
/* @__PURE__ */ jsx("span", {
|
|
1945
|
-
style: { left: at(model.thresholds.full) },
|
|
1946
|
-
children: pct(model.thresholds.full)
|
|
1947
|
-
}),
|
|
1948
|
-
/* @__PURE__ */ jsx("span", {
|
|
1949
|
-
style: {
|
|
1950
|
-
left: "100%",
|
|
1951
|
-
transform: "translateX(-100%)"
|
|
1952
|
-
},
|
|
1953
|
-
children: pct(top)
|
|
1954
|
-
})
|
|
1955
|
-
] }),
|
|
1956
|
-
/* @__PURE__ */ jsx("span", {})
|
|
1957
|
-
]
|
|
1958
|
-
}),
|
|
1959
|
-
/* @__PURE__ */ jsx("div", {
|
|
1960
|
-
className: "lm-limits",
|
|
1961
|
-
children: ev.ranked.map((c) => /* @__PURE__ */ jsxs("div", {
|
|
1962
|
-
className: "lm-lim",
|
|
1963
|
-
"data-component": c.id,
|
|
1964
|
-
children: [
|
|
1965
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1966
|
-
/* @__PURE__ */ jsxs("b", { children: [
|
|
1967
|
-
c.name,
|
|
1968
|
-
c === ev.firstLimit && /* @__PURE__ */ jsx("span", {
|
|
1969
|
-
className: "lm-tag",
|
|
1970
|
-
"data-kind": "first",
|
|
1971
|
-
children: "limit"
|
|
1972
|
-
}),
|
|
1973
|
-
/* @__PURE__ */ jsx(CapTag, { c: c.capacity })
|
|
1974
|
-
] }),
|
|
1975
|
-
/* @__PURE__ */ jsx("span", {
|
|
1976
|
-
className: "lm-sub",
|
|
1977
|
-
children: c.missing != null ? `No published benchmark ${c.missing}.` : c.describe ?? (c.capacity ? `${fmt(c.capacity.value)} ${c.capacity.unit}` : "switched off")
|
|
1978
|
-
}),
|
|
1979
|
-
c.spread && c.util != null && /* @__PURE__ */ jsx("span", {
|
|
1980
|
-
className: "lm-sub lm-spread",
|
|
1981
|
-
children: c.spread.text
|
|
1982
|
-
})
|
|
1983
|
-
] }),
|
|
1984
|
-
/* @__PURE__ */ jsxs("div", {
|
|
1985
|
-
className: "lm-track",
|
|
1986
|
-
role: "img",
|
|
1987
|
-
"aria-label": `${c.name} at ${c.missing != null ? "no published benchmark" : c.util == null ? "off" : pct(c.util)}`,
|
|
1988
|
-
children: [
|
|
1989
|
-
/* @__PURE__ */ jsx("div", {
|
|
1990
|
-
className: "lm-fill",
|
|
1991
|
-
"data-state": c.state,
|
|
1992
|
-
style: { width: `${Math.min(100, (c.util ?? 0) / top * 100)}%` }
|
|
1993
|
-
}),
|
|
1994
|
-
/* @__PURE__ */ jsx("div", {
|
|
1995
|
-
className: "lm-tick",
|
|
1996
|
-
style: { left: at(model.thresholds.target) }
|
|
1997
|
-
}),
|
|
1998
|
-
/* @__PURE__ */ jsx("div", {
|
|
1999
|
-
className: "lm-tick",
|
|
2000
|
-
style: { left: at(model.thresholds.full) }
|
|
2001
|
-
})
|
|
2002
|
-
]
|
|
2003
|
-
}),
|
|
2004
|
-
/* @__PURE__ */ jsxs("div", {
|
|
2005
|
-
className: "lm-val",
|
|
2006
|
-
children: [c.util == null ? "—" : `${pct(c.util)} · ${num(c.demand ?? 0)} ${c.capacity?.unit ?? ""}`, /* @__PURE__ */ jsx("small", { children: c.util == null ? "switched off" : `${pct(model.thresholds.target)} at ${span(c.targetRange, c.target)} · full at ${span(c.fullRange, c.full)}` })]
|
|
2007
|
-
})
|
|
2008
|
-
]
|
|
2009
|
-
}, c.id))
|
|
2010
|
-
})
|
|
2011
|
-
] });
|
|
1947
|
+
/** One button per scenario: a reader switches designs without touching the controls. The load stays. */
|
|
1948
|
+
function Scenarios({ lm }) {
|
|
1949
|
+
const { model } = lm;
|
|
1950
|
+
if (!model.scenarios.length) return null;
|
|
1951
|
+
return /* @__PURE__ */ jsxs("fieldset", {
|
|
1952
|
+
className: "lm-scenarios",
|
|
1953
|
+
children: [
|
|
1954
|
+
/* @__PURE__ */ jsx("legend", { children: "Scenario" }),
|
|
1955
|
+
model.scenarios.map((s) => /* @__PURE__ */ jsxs("button", {
|
|
1956
|
+
type: "button",
|
|
1957
|
+
"aria-pressed": lm.scenario?.label === s.label,
|
|
1958
|
+
onClick: () => lm.setScenario(s.label),
|
|
1959
|
+
children: [/* @__PURE__ */ jsx("i", { style: { background: scenarioColor(model, s.label) } }), s.label]
|
|
1960
|
+
}, s.label)),
|
|
1961
|
+
!lm.scenario && /* @__PURE__ */ jsx("span", {
|
|
1962
|
+
className: "lm-own",
|
|
1963
|
+
children: "your own values"
|
|
1964
|
+
})
|
|
1965
|
+
]
|
|
1966
|
+
});
|
|
2012
1967
|
}
|
|
2013
|
-
/**
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
1968
|
+
/** The size of an element in CSS pixels, kept current: a chart draws at its own size so text stays legible. */
|
|
1969
|
+
function useSize(fallback) {
|
|
1970
|
+
const ref = useRef(null);
|
|
1971
|
+
const [size, setSize] = useState({
|
|
1972
|
+
width: fallback,
|
|
1973
|
+
height: 0
|
|
1974
|
+
});
|
|
2019
1975
|
useEffect(() => {
|
|
2020
|
-
const
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
if (s.kind === "queue") for (const f of model.flowIds.filter((x) => ev.paths[x]?.some((p) => p.stages.includes(s.id)))) {
|
|
2029
|
-
const q = sim.queue(s.id, f);
|
|
2030
|
-
const rules = ev.overload[f] ?? {};
|
|
2031
|
-
items.push({
|
|
2032
|
-
key: `${s.id}/${f}/lag`,
|
|
2033
|
-
value: secs(q.lag),
|
|
2034
|
-
label: `${flowLabel(f)} lag in ${s.label}`,
|
|
2035
|
-
state: q.lag > 60 ? "over" : q.lag > 5 ? "warn" : "ok"
|
|
2036
|
-
});
|
|
2037
|
-
if (rules.merge) items.push({
|
|
2038
|
-
key: `${s.id}/${f}/merge`,
|
|
2039
|
-
value: compact(q.merged),
|
|
2040
|
-
label: `${flowLabel(f)} superseded /s (${rules.merge.reason ?? "newest kept"})`,
|
|
2041
|
-
state: q.merged > .5 ? "warn" : "ok"
|
|
2042
|
-
});
|
|
2043
|
-
if (rules.drop) items.push({
|
|
2044
|
-
key: `${s.id}/${f}/drop`,
|
|
2045
|
-
value: compact(q.dropped),
|
|
2046
|
-
label: `${flowLabel(f)} dropped /s (${rules.drop.reason ?? "too old"})`,
|
|
2047
|
-
state: q.dropped > .5 ? "over" : "ok"
|
|
2048
|
-
});
|
|
2049
|
-
}
|
|
2050
|
-
if (s.kind === "workers") {
|
|
2051
|
-
const b = sim.busy(s.id);
|
|
2052
|
-
items.push({
|
|
2053
|
-
key: `${s.id}/busy`,
|
|
2054
|
-
value: pct(b),
|
|
2055
|
-
label: `${s.label} busy`,
|
|
2056
|
-
state: b > .95 ? "over" : b > .5 ? "warn" : "ok"
|
|
2057
|
-
});
|
|
2058
|
-
if (s.autoscale) items.push({
|
|
2059
|
-
key: `${s.id}/pods`,
|
|
2060
|
-
value: `${s.running} of ${s.pods}`,
|
|
2061
|
-
label: `${s.label} pods running`,
|
|
2062
|
-
state: s.running < s.pods ? "ok" : (ev.components[s.component]?.util ?? 0) > model.thresholds.full ? "over" : "warn"
|
|
1976
|
+
const el = ref.current;
|
|
1977
|
+
if (!el) return;
|
|
1978
|
+
const ro = new ResizeObserver(([e]) => {
|
|
1979
|
+
const width = Math.round(e?.contentRect.width ?? el.clientWidth);
|
|
1980
|
+
const height = Math.round(e?.contentRect.height ?? el.clientHeight);
|
|
1981
|
+
if (width > 0) setSize((s) => s.width === width && s.height === height ? s : {
|
|
1982
|
+
width,
|
|
1983
|
+
height
|
|
2063
1984
|
});
|
|
2064
|
-
}
|
|
2065
|
-
if (s.kind === "cache") items.push({
|
|
2066
|
-
key: `${s.id}/hits`,
|
|
2067
|
-
value: compact(sim.arriving(s.id) * (1 - sim.shed(s.id)) * s.hit),
|
|
2068
|
-
label: `answered at ${s.label} /s (${pct(s.hit)} hits)`,
|
|
2069
|
-
state: "ok"
|
|
2070
|
-
});
|
|
2071
|
-
if ((s.kind === "pass" || s.kind === "limit" || s.kind === "cache" || s.kind === "split") && sim.shed(s.id) > 0) items.push({
|
|
2072
|
-
key: `${s.id}/shed`,
|
|
2073
|
-
value: pct(sim.shed(s.id)),
|
|
2074
|
-
label: `rejected at ${s.label}`,
|
|
2075
|
-
state: "over"
|
|
2076
|
-
});
|
|
2077
|
-
}
|
|
2078
|
-
for (const f of model.flowIds) {
|
|
2079
|
-
const r = ev.retry[f];
|
|
2080
|
-
if (!r || !(r.rate > 0)) continue;
|
|
2081
|
-
const per = r.attempts / r.rate;
|
|
2082
|
-
items.push({
|
|
2083
|
-
key: `${f}/attempts`,
|
|
2084
|
-
value: `${fmt(per)}×`,
|
|
2085
|
-
label: `${flowLabel(f)} attempts per ${model.def.flows[f]?.unit ?? "unit"}`,
|
|
2086
|
-
state: per > 1.05 ? "warn" : "ok"
|
|
2087
|
-
});
|
|
2088
|
-
items.push({
|
|
2089
|
-
key: `${f}/failed`,
|
|
2090
|
-
value: pct(r.failed),
|
|
2091
|
-
label: `${flowLabel(f)} failing after ${r.times} ${r.times === 1 ? "retry" : "retries"}`,
|
|
2092
|
-
state: r.failed > .005 ? "over" : "ok"
|
|
2093
1985
|
});
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
const scenario = model.scenarioOf(lm.values)?.label;
|
|
2099
|
-
const goal = model.expectations.find((e) => e.flow === f && e.p99 != null && (e.scenario == null || e.scenario === scenario) && (e.underTarget == null || lm.values.load <= e.underTarget))?.p99;
|
|
2100
|
-
items.push({
|
|
2101
|
-
key: `${f}/p99`,
|
|
2102
|
-
value: duration(l.p99),
|
|
2103
|
-
label: `${flowLabel(f)} p99`,
|
|
2104
|
-
state: !Number.isFinite(l.p99) || goal != null && l.p99 > goal ? "over" : "ok"
|
|
2105
|
-
});
|
|
2106
|
-
if (l.timedOut != null) items.push({
|
|
2107
|
-
key: `${f}/late`,
|
|
2108
|
-
value: pct(l.timedOut),
|
|
2109
|
-
label: `${flowLabel(f)} timed out`,
|
|
2110
|
-
state: l.timedOut > .005 ? "over" : l.timedOut > 0 ? "warn" : "ok"
|
|
2111
|
-
});
|
|
2112
|
-
}
|
|
2113
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("h3", { children: "Live" }), /* @__PURE__ */ jsx("div", {
|
|
2114
|
-
className: "lm-meters",
|
|
2115
|
-
children: items.map((m) => /* @__PURE__ */ jsxs("div", {
|
|
2116
|
-
className: "lm-meter",
|
|
2117
|
-
"data-state": m.state,
|
|
2118
|
-
children: [/* @__PURE__ */ jsx("b", { children: m.value }), /* @__PURE__ */ jsx("span", {
|
|
2119
|
-
title: m.label,
|
|
2120
|
-
children: m.label
|
|
2121
|
-
})]
|
|
2122
|
-
}, m.key))
|
|
2123
|
-
})] });
|
|
1986
|
+
ro.observe(el);
|
|
1987
|
+
return () => ro.disconnect();
|
|
1988
|
+
}, []);
|
|
1989
|
+
return [ref, size];
|
|
2124
1990
|
}
|
|
1991
|
+
/** "±30 %" for a capacity with a range; "−30 %" for a best case, which a range only lowers. */
|
|
1992
|
+
const plusMinus = (c) => c?.within ? `${c.ceiling ? "−" : "±"}${pct(c.within)}` : "";
|
|
2125
1993
|
/** A preset's values are the shown ones. */
|
|
2126
1994
|
const isOn = (lm, p) => Object.entries(p.values).every(([k, x]) => lm.values[k] === x);
|
|
2127
1995
|
/**
|
|
@@ -2225,692 +2093,305 @@ function LoadBar({ lm }) {
|
|
|
2225
2093
|
children: [/* @__PURE__ */ jsx(Scenarios, { lm }), /* @__PURE__ */ jsx(LoadRange, { lm })]
|
|
2226
2094
|
});
|
|
2227
2095
|
}
|
|
2228
|
-
/**
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
]
|
|
2311
|
-
}, id);
|
|
2312
|
-
})
|
|
2313
|
-
]
|
|
2314
|
-
});
|
|
2315
|
-
}
|
|
2316
|
-
/** What the model assumes: every capacity with its provenance, every fit, and anything the page adds. */
|
|
2317
|
-
function Assumptions({ lm, extra = [] }) {
|
|
2318
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
2319
|
-
className: "lm-card",
|
|
2320
|
-
children: [/* @__PURE__ */ jsx("h3", { children: "What this assumes" }), /* @__PURE__ */ jsxs("ul", {
|
|
2321
|
-
className: "lm-facts",
|
|
2322
|
-
children: [extra.map((x, i) => /* @__PURE__ */ jsx("li", { children: x }, i)), lm.ev.assumptions.map((a) => /* @__PURE__ */ jsx("li", { children: describe(a) }, a.kind === "capacity" ? `c:${a.component}` : `${a.kind}:${a.name}`))]
|
|
2323
|
-
})]
|
|
2324
|
-
});
|
|
2325
|
-
}
|
|
2326
|
-
function describe(a) {
|
|
2327
|
-
if (a.kind === "capacity") {
|
|
2328
|
-
const c = a.capacity;
|
|
2329
|
-
if (c.missing != null) return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2330
|
-
/* @__PURE__ */ jsxs("b", { children: [a.name, ":"] }),
|
|
2331
|
-
" no capacity:",
|
|
2332
|
-
" ",
|
|
2333
|
-
/* @__PURE__ */ jsx("span", {
|
|
2334
|
-
className: "lm-prov",
|
|
2335
|
-
"data-kind": "published",
|
|
2336
|
-
children: "no published benchmark"
|
|
2337
|
-
}),
|
|
2338
|
-
" ",
|
|
2339
|
-
c.missing,
|
|
2340
|
-
".",
|
|
2341
|
-
unread(c.unread)
|
|
2342
|
-
] });
|
|
2343
|
-
if (c.ref) return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Published, {
|
|
2344
|
-
name: a.name,
|
|
2345
|
-
c
|
|
2346
|
-
}), unread(c.unread)] });
|
|
2347
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2348
|
-
/* @__PURE__ */ jsxs("b", { children: [a.name, ":"] }),
|
|
2349
|
-
" ",
|
|
2350
|
-
c.unit === "share" ? pct(c.value) : `${fmt(c.value)} ${c.unit}`,
|
|
2351
|
-
c.within ? ` ${plusMinus(c)}` : "",
|
|
2352
|
-
",",
|
|
2353
|
-
" ",
|
|
2354
|
-
/* @__PURE__ */ jsx("span", {
|
|
2355
|
-
className: "lm-prov",
|
|
2356
|
-
"data-kind": c.provenance,
|
|
2357
|
-
children: c.provenance
|
|
2358
|
-
}),
|
|
2359
|
-
c.source ? ` (${c.source})` : "",
|
|
2360
|
-
".",
|
|
2361
|
-
unread(c.unread)
|
|
2362
|
-
] });
|
|
2363
|
-
}
|
|
2364
|
-
if (a.kind === "connection") return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2365
|
-
/* @__PURE__ */ jsxs("b", { children: [a.name, ":"] }),
|
|
2366
|
-
" ",
|
|
2367
|
-
a.text
|
|
2368
|
-
] });
|
|
2369
|
-
if (a.kind === "measurement") {
|
|
2370
|
-
const { label, unit, value, missing, source } = a.measurement;
|
|
2371
|
-
const name = label ?? a.name;
|
|
2372
|
-
if (missing != null) return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("b", { children: [name, ":"] }), unread(missing)] });
|
|
2373
|
-
return describe({
|
|
2374
|
-
kind: "capacity",
|
|
2375
|
-
component: "",
|
|
2376
|
-
name,
|
|
2377
|
-
capacity: {
|
|
2378
|
-
value,
|
|
2379
|
-
unit,
|
|
2380
|
-
provenance: "measured",
|
|
2381
|
-
source
|
|
2382
|
-
}
|
|
2383
|
-
});
|
|
2384
|
-
}
|
|
2385
|
-
const f = a.fit;
|
|
2386
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2387
|
-
/* @__PURE__ */ jsxs("b", { children: [a.name, ":"] }),
|
|
2388
|
-
" ",
|
|
2389
|
-
f.y,
|
|
2390
|
-
" = ",
|
|
2391
|
-
sig(f.a),
|
|
2392
|
-
" + ",
|
|
2393
|
-
sig(f.b),
|
|
2394
|
-
" × ",
|
|
2395
|
-
f.x,
|
|
2396
|
-
", r² ",
|
|
2397
|
-
f.r2.toFixed(3),
|
|
2398
|
-
" over ",
|
|
2399
|
-
f.n,
|
|
2400
|
-
" points,",
|
|
2401
|
-
" ",
|
|
2402
|
-
/* @__PURE__ */ jsx("span", {
|
|
2403
|
-
className: "lm-prov",
|
|
2404
|
-
"data-kind": "measured",
|
|
2405
|
-
children: "measured"
|
|
2406
|
-
}),
|
|
2407
|
-
f.source ? ` (${f.source})` : "",
|
|
2408
|
-
".",
|
|
2409
|
-
unread(f.unread)
|
|
2410
|
-
] });
|
|
2411
|
-
}
|
|
2412
|
-
/** A snapshot that gave no value: the line says the written one stands in. */
|
|
2413
|
-
const unread = (why) => why == null ? "" : ` No data from the snapshot (${why}).`;
|
|
2414
|
-
/** A published figure with what it is, its conditions and where it comes from: a vendor's run, not this system. */
|
|
2415
|
-
function Published({ name, c }) {
|
|
2416
|
-
const r = c.ref;
|
|
2417
|
-
const runs = r.versions.join(", ");
|
|
2418
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2419
|
-
/* @__PURE__ */ jsxs("b", { children: [name, ":"] }),
|
|
2420
|
-
" ",
|
|
2421
|
-
fmt(c.value),
|
|
2422
|
-
" ",
|
|
2423
|
-
c.unit,
|
|
2424
|
-
c.within ? ` ${plusMinus(c)}` : "",
|
|
2425
|
-
",",
|
|
2426
|
-
" ",
|
|
2427
|
-
/* @__PURE__ */ jsx("span", {
|
|
2428
|
-
className: "lm-prov",
|
|
2429
|
-
"data-kind": "published",
|
|
2430
|
-
children: r.measure === "limit" ? "published limit" : "published"
|
|
2431
|
-
}),
|
|
2432
|
-
": ",
|
|
2433
|
-
r.name,
|
|
2434
|
-
", ",
|
|
2435
|
-
r.what,
|
|
2436
|
-
", ",
|
|
2437
|
-
r.scope,
|
|
2438
|
-
" (",
|
|
2439
|
-
r.conditions.join("; "),
|
|
2440
|
-
"); ",
|
|
2441
|
-
r.name,
|
|
2442
|
-
" ",
|
|
2443
|
-
runs,
|
|
2444
|
-
r.version && r.version !== runs ? `, you run ${r.version}` : "",
|
|
2445
|
-
"; ",
|
|
2446
|
-
sourceText(r),
|
|
2447
|
-
" (",
|
|
2448
|
-
/^https:\/\//.test(r.source.url) ? /* @__PURE__ */ jsx("a", {
|
|
2449
|
-
href: r.source.url,
|
|
2450
|
-
target: "_blank",
|
|
2451
|
-
rel: "noopener noreferrer",
|
|
2452
|
-
children: "source"
|
|
2453
|
-
}) : r.source.url,
|
|
2454
|
-
", catalog ",
|
|
2455
|
-
r.edition,
|
|
2456
|
-
").",
|
|
2457
|
-
r.measure === "limit" ? "" : " A best case elsewhere, not a measurement of this system."
|
|
2458
|
-
] });
|
|
2459
|
-
}
|
|
2460
|
-
/** Exact below 1,000 (3.9 cores), compact above (12k req/s). */
|
|
2461
|
-
const num = (x) => Math.abs(x) >= 1e3 ? compact(x) : fmt(x);
|
|
2462
|
-
const sig = (x) => Number(x.toPrecision(3)).toString();
|
|
2463
|
-
// src/story.tsx
|
|
2464
|
-
/**
|
|
2465
|
-
* The model's story, a step at a time: the step's text, where it is, play, back and next. ← and → move through it
|
|
2466
|
-
* while the bar has the keyboard focus (the sliders keep their own arrows). The text keeps the room of the longest
|
|
2467
|
-
* step, so stepping through it never moves what is below. While it plays, the bar shows the step played from the
|
|
2468
|
-
* moment the camera heads for it, before its values change.
|
|
2469
|
-
*/
|
|
2470
|
-
function Story({ lm }) {
|
|
2471
|
-
const bar = useRef(null);
|
|
2472
|
-
const { story } = lm.model;
|
|
2473
|
-
if (!story.length) return null;
|
|
2474
|
-
const i = lm.cue?.step ?? lm.step;
|
|
2475
|
-
const last = story.length - 1;
|
|
2476
|
-
const go = (to) => {
|
|
2477
|
-
const next = Math.max(0, Math.min(last, to));
|
|
2478
|
-
if (next !== i || lm.storyPlaying) lm.setStep(next);
|
|
2479
|
-
};
|
|
2480
|
-
const keys = (e) => {
|
|
2481
|
-
if (e.key === "ArrowRight") go(i == null ? 0 : i + 1);
|
|
2482
|
-
else if (e.key === "ArrowLeft" && i != null) go(i - 1);
|
|
2483
|
-
else return;
|
|
2484
|
-
e.preventDefault();
|
|
2485
|
-
};
|
|
2486
|
-
const playing = lm.storyPlaying;
|
|
2487
|
-
return /* @__PURE__ */ jsxs("fieldset", {
|
|
2488
|
-
className: "lm-story",
|
|
2489
|
-
onKeyDown: keys,
|
|
2490
|
-
ref: bar,
|
|
2491
|
-
tabIndex: -1,
|
|
2492
|
-
"data-playing": playing || void 0,
|
|
2493
|
-
children: [
|
|
2494
|
-
/* @__PURE__ */ jsx("legend", { children: "Story" }),
|
|
2495
|
-
/* @__PURE__ */ jsx("span", {
|
|
2496
|
-
className: "lm-sr",
|
|
2497
|
-
"aria-live": "polite",
|
|
2498
|
-
children: i == null ? `A walk through this model in ${story.length} steps.` : `${i + 1} of ${story.length}. ${story[i].text}${lm.stepChanged ? " You changed the values since." : ""}`
|
|
2499
|
-
}),
|
|
2500
|
-
/* @__PURE__ */ jsxs("p", {
|
|
2501
|
-
"aria-hidden": "true",
|
|
2502
|
-
children: [/* @__PURE__ */ jsxs("span", {
|
|
2503
|
-
"data-shown": i == null || void 0,
|
|
2504
|
-
children: [
|
|
2505
|
-
"A walk through this model in ",
|
|
2506
|
-
story.length,
|
|
2507
|
-
" steps."
|
|
2508
|
-
]
|
|
2509
|
-
}), story.map((st, k) => /* @__PURE__ */ jsxs("span", {
|
|
2510
|
-
"data-shown": k === i || void 0,
|
|
2511
|
-
children: [
|
|
2512
|
-
/* @__PURE__ */ jsxs("b", { children: [
|
|
2513
|
-
k + 1,
|
|
2514
|
-
" of ",
|
|
2515
|
-
story.length
|
|
2516
|
-
] }),
|
|
2517
|
-
" ",
|
|
2518
|
-
st.text,
|
|
2519
|
-
/* @__PURE__ */ jsx("em", {
|
|
2520
|
-
"data-shown": k === i && lm.stepChanged || void 0,
|
|
2521
|
-
children: " You changed the values since."
|
|
2522
|
-
})
|
|
2523
|
-
]
|
|
2524
|
-
}, k))]
|
|
2525
|
-
}),
|
|
2526
|
-
i != null && /* @__PURE__ */ jsx("span", {
|
|
2527
|
-
className: "lm-story-progress",
|
|
2528
|
-
"aria-hidden": "true",
|
|
2529
|
-
children: story.map((st, k) => /* @__PURE__ */ jsx("i", {
|
|
2530
|
-
"data-state": k < i ? "done" : k === i ? "now" : void 0,
|
|
2531
|
-
style: k === i ? { "--lm-step": `${lm.cue?.seconds ?? stepSeconds(st, lm.engine.transition)}s` } : void 0
|
|
2532
|
-
}, k === i ? `${k}-${playing}` : k))
|
|
2533
|
-
}),
|
|
2534
|
-
/* @__PURE__ */ jsxs("span", {
|
|
2535
|
-
className: "lm-story-nav",
|
|
2536
|
-
children: [
|
|
2537
|
-
/* @__PURE__ */ jsx("button", {
|
|
2538
|
-
type: "button",
|
|
2539
|
-
onClick: () => lm.setStoryPlaying(!playing),
|
|
2540
|
-
"aria-pressed": playing,
|
|
2541
|
-
children: playing ? "❚❚ Pause" : "▶ Play"
|
|
2542
|
-
}),
|
|
2543
|
-
i != null && /* @__PURE__ */ jsx("button", {
|
|
2544
|
-
type: "button",
|
|
2545
|
-
onClick: () => go(i - 1),
|
|
2546
|
-
"aria-disabled": i === 0,
|
|
2547
|
-
children: "Back"
|
|
2548
|
-
}),
|
|
2549
|
-
/* @__PURE__ */ jsx("button", {
|
|
2550
|
-
type: "button",
|
|
2551
|
-
onClick: () => go(i == null ? 0 : i + 1),
|
|
2552
|
-
"aria-disabled": i === last,
|
|
2553
|
-
children: i == null ? "Start" : "Next"
|
|
2554
|
-
}),
|
|
2555
|
-
i != null && lm.stepChanged && /* @__PURE__ */ jsx("button", {
|
|
2556
|
-
type: "button",
|
|
2557
|
-
onClick: () => {
|
|
2558
|
-
lm.setStep(i);
|
|
2559
|
-
bar.current?.focus();
|
|
2560
|
-
},
|
|
2561
|
-
children: "Show again"
|
|
2562
|
-
}),
|
|
2563
|
-
i != null && /* @__PURE__ */ jsx("button", {
|
|
2564
|
-
type: "button",
|
|
2565
|
-
onClick: () => lm.setStep(null),
|
|
2566
|
-
"aria-label": "Leave the story",
|
|
2567
|
-
children: "Done"
|
|
2568
|
-
})
|
|
2569
|
-
]
|
|
2570
|
-
})
|
|
2571
|
-
]
|
|
2572
|
-
});
|
|
2573
|
-
}
|
|
2574
|
-
// src/styles.ts
|
|
2575
|
-
const LIGHT = `
|
|
2576
|
-
--lm-bg: #eef2f5; --lm-surface: #ffffff; --lm-fg: #17212b; --lm-muted: #5d6d7c; --lm-line: #c6d0da;
|
|
2577
|
-
--lm-accent: #0b6b8f; --lm-accent-soft: #d6e9f0; --lm-alt: #7a4f9a; --lm-alt-soft: #efe5f6;
|
|
2578
|
-
--lm-ok: #2a7f5a; --lm-warn: #b86e00; --lm-drop: #b7392e; --lm-lane: #e3e9ee;
|
|
2579
|
-
--lm-lost-fill: #fbefed; --lm-lost-line: #b7392e;
|
|
2580
|
-
--lm-tier-base: #f4f7fa; --lm-tier: #e8eef3; --lm-tier-head: #dbe3eb; --lm-tier-fg: #34424f; --lm-tier-line: #c6d0da;
|
|
2581
|
-
--lm-s1: #2a78d6; --lm-s2: #eb6834; --lm-s3: #6250d6; --lm-s4: #eda100; color-scheme: light;`;
|
|
2582
|
-
const DARK = `
|
|
2583
|
-
--lm-bg: #0d141b; --lm-surface: #151e27; --lm-fg: #e4ebf1; --lm-muted: #93a3b3; --lm-line: #2a3744;
|
|
2584
|
-
--lm-accent: #5fb7d6; --lm-accent-soft: #163442; --lm-alt: #c39be0; --lm-alt-soft: #2b2236;
|
|
2585
|
-
--lm-ok: #5fc08f; --lm-warn: #e2a24a; --lm-drop: #e26a5c; --lm-lane: #1b2631;
|
|
2586
|
-
--lm-lost-fill: #2b1c1d; --lm-lost-line: #e26a5c;
|
|
2587
|
-
--lm-tier-base: #1b2530; --lm-tier: #24323f; --lm-tier-head: #2c3b4a; --lm-tier-fg: #c3cfda; --lm-tier-line: #33424f;
|
|
2588
|
-
--lm-s1: #3987e5; --lm-s2: #d95926; --lm-s3: #9085e9; --lm-s4: #c98500; color-scheme: dark;`;
|
|
2589
|
-
/**
|
|
2590
|
-
* Theme tokens and the layout of every piece. Scoped to `.lm`; override any `--lm-*` token to restyle. Two are for the
|
|
2591
|
-
* page around it: `--lm-pad` (the root's padding, 16px) and `--lm-root-bg` (its background, `--lm-bg`), for a card
|
|
2592
|
-
* that has its own, set on the root (`.card > .lm`) so they resolve there and reach no nested board; full screen
|
|
2593
|
-
* keeps both.
|
|
2594
|
-
*/
|
|
2595
|
-
const LOADMAP_CSS = `
|
|
2596
|
-
.lm { ${LIGHT}
|
|
2597
|
-
--lm-font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
2598
|
-
--lm-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
2599
|
-
font: 14px/1.45 var(--lm-font); color: var(--lm-fg); background: var(--lm-root-bg, var(--lm-bg));
|
|
2600
|
-
display: grid; gap: 14px; padding: var(--lm-pad, 16px); min-width: 0; box-sizing: border-box; }
|
|
2601
|
-
@media (prefers-color-scheme: dark) { .lm:not([data-theme="light"]) { ${DARK} } }
|
|
2602
|
-
.lm[data-theme="dark"] { ${DARK} }
|
|
2603
|
-
.lm *, .lm *::before, .lm *::after { box-sizing: border-box; }
|
|
2604
|
-
.lm h2 { font-size: 1.3rem; font-weight: 600; margin: 0; text-wrap: balance; }
|
|
2605
|
-
.lm h3 { font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); margin: 0; }
|
|
2606
|
-
.lm button:focus-visible, .lm input:focus-visible, .lm select:focus-visible { outline: 2px solid var(--lm-accent); outline-offset: 2px; }
|
|
2607
|
-
.lm-problems { margin: 0; padding: 10px 12px; font: .8rem/1.5 var(--lm-mono); white-space: pre-wrap; overflow-x: auto; color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-left: 3px solid var(--lm-drop); border-radius: 6px; }
|
|
2608
|
-
.lm-note { margin: 0; font-size: .8rem; color: var(--lm-muted); }
|
|
2609
|
-
.lm-card { background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; padding: 14px 16px; display: grid; gap: 12px; align-content: start; min-width: 0; }
|
|
2610
|
-
|
|
2611
|
-
.lm-wrap { display: grid; gap: 8px; min-width: 0; position: relative; }
|
|
2612
|
-
.lm-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
|
|
2613
|
-
.lm-btn { font: 500 .8rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
|
|
2614
|
-
.lm-board { position: relative; background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; overflow: hidden; margin: 0 auto; width: 100%; }
|
|
2615
|
-
.lm-board svg { display: block; width: 100%; height: auto; font-family: var(--lm-font); }
|
|
2616
|
-
.lm-board canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
|
|
2617
|
-
/* the story's title over the board while it plays: a lower third, at the top when what is framed is low; a strip
|
|
2618
|
-
across the top of a narrow board */
|
|
2619
|
-
.lm-title { position: absolute; left: 12px; bottom: 12px; z-index: 1; display: grid; gap: 1px; max-width: min(34rem, calc(100% - 24px)); padding: 7px 12px 8px; border-left: 4px solid var(--lm-accent); border-radius: 0 6px 6px 0; background: color-mix(in srgb, var(--lm-surface) 92%, transparent); box-shadow: 0 4px 16px rgb(0 0 0 / .12); pointer-events: none; overflow-wrap: anywhere; }
|
|
2620
|
-
.lm-title[data-top] { top: 12px; bottom: auto; }
|
|
2621
|
-
.lm-title b { font-size: .95rem; font-weight: 600; }
|
|
2622
|
-
.lm-title span { font: 500 .8rem var(--lm-mono); color: var(--lm-muted); }
|
|
2623
|
-
@container (max-width: 520px) {
|
|
2624
|
-
.lm-title, .lm-title[data-top] { top: 0; right: 0; bottom: auto; left: 0; max-width: none; padding: 4px 8px; border-radius: 0; box-shadow: none; }
|
|
2625
|
-
.lm-title b { font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
2626
|
-
.lm-title span { display: none; }
|
|
2627
|
-
}
|
|
2628
|
-
.lm-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .78rem; color: var(--lm-muted); }
|
|
2629
|
-
.lm-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 5px; }
|
|
2630
|
-
.lm-legend i.lm-legend-merge { box-sizing: border-box; border: 1.5px solid var(--lm-muted); }
|
|
2631
|
-
|
|
2632
|
-
/* full screen (the browser's, or a fixed overlay): a column that never scrolls. The diagram as wide as the screen on
|
|
2633
|
-
top; under it the verdict in a line and the panels, compact, in a dock the screen sizes. The load changes what is
|
|
2634
|
-
in them, never their size, so it never moves the board. Focus: the diagram, the story, the verdict and the load */
|
|
2635
|
-
.lm-side, .lm-card > .lm-panel { display: contents; }
|
|
2636
|
-
.lm-panel { display: grid; gap: 14px; min-width: 0; }
|
|
2637
|
-
.lm[data-full] { height: 100vh; height: 100dvh; padding: 16px; background: var(--lm-bg); overflow: hidden; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 10px; position: relative; }
|
|
2638
|
-
.lm[data-full="fill"] { height: 100%; padding: 10px; }
|
|
2639
|
-
.lm[data-full="overlay"] { position: fixed; inset: 0; z-index: 2147483000; width: auto; max-width: none; max-height: none; margin: 0; border: 0; }
|
|
2640
|
-
.lm[data-full] > * { flex: none; }
|
|
2641
|
-
/* a page of its own keeps the rest outside full screen, as <Loadmap> does */
|
|
2642
|
-
.lm[data-full] > :not(.lm-head, h2, .lm-scenarios, .lm-loadbar, .lm-story, .lm-wrap, .lm-line, .lm-dock, .lm-side) { display: none; }
|
|
2643
|
-
.lm-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; min-width: 0; }
|
|
2644
|
-
.lm-head h2 { font-size: 1.1rem; }
|
|
2645
|
-
.lm-head .lm-loadbar { flex: 1 1 520px; }
|
|
2646
|
-
.lm[data-full] .lm-wrap { gap: 6px; }
|
|
2647
|
-
/* the board as large as fits (--lm-fit, from Diagram), left under the bar, so the legend starts where the board does */
|
|
2648
|
-
.lm[data-full] .lm-board { width: var(--lm-fit, 100%); margin: 0; align-self: start; justify-self: start; }
|
|
2649
|
-
.lm-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
|
|
2650
|
-
.lm-modes { display: inline-flex; margin: 0; padding: 0; min-width: 0; border: 1px solid var(--lm-line); border-radius: 6px; overflow: hidden; }
|
|
2651
|
-
.lm-modes button { font: 500 .8rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 0; padding: 6px 12px; cursor: pointer; }
|
|
2652
|
-
.lm-modes button[aria-pressed="true"] { background: var(--lm-fg); color: var(--lm-surface); }
|
|
2653
|
-
.lm[data-full] .lm-story { padding: 6px 12px; }
|
|
2654
|
-
.lm[data-full] [data-out] { display: none; }
|
|
2655
|
-
|
|
2656
|
-
.lm-line { display: flex; align-items: center; gap: 6px 14px; min-width: 0; padding: 6px 12px; border-left: 4px solid var(--lm-ok); background: var(--lm-accent-soft); border-radius: 0 6px 6px 0; }
|
|
2657
|
-
.lm-line[data-tier="warn"] { border-color: var(--lm-warn); }
|
|
2658
|
-
.lm-line[data-tier="over"] { border-color: var(--lm-drop); }
|
|
2659
|
-
.lm-headline { flex: 1 1 auto; min-width: 0; margin: 0; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
2660
|
-
.lm-num { font: 600 .95em var(--lm-mono); font-variant-numeric: tabular-nums; }
|
|
2661
|
-
.lm-link { font: 500 .8rem var(--lm-font); color: var(--lm-accent); background: none; border: 0; padding: 2px 4px; cursor: pointer; white-space: nowrap; }
|
|
2662
|
-
|
|
2663
|
-
.lm-dock { display: flex; gap: 10px; min-width: 0; }
|
|
2664
|
-
.lm[data-full] > .lm-dock { flex: 1 1 0; min-height: clamp(200px, 26dvh, 340px); }
|
|
2665
|
-
.lm-tabs { display: none; margin: 0; padding: 0; border: 0; min-width: 0; }
|
|
2666
|
-
.lm-mini { position: relative; flex: 1 1 0; min-width: 0; min-height: 0; display: grid; container-type: inline-size; }
|
|
2667
|
-
.lm-mini[data-mini="controls"] { flex-grow: 1.25; }
|
|
2668
|
-
.lm-mini[data-mini="limits"] { flex-grow: 1.45; }
|
|
2669
|
-
.lm-mini[data-mini="live"] { flex-grow: .8; }
|
|
2670
|
-
.lm-mini[data-mini="headroom"] { flex-grow: .9; }
|
|
2671
|
-
.lm-mini[data-mini="compare"] { flex-grow: 1.3; }
|
|
2672
|
-
.lm-mini > .lm-card { min-height: 0; overflow: hidden; padding: 10px 12px; gap: 6px; align-content: start; }
|
|
2673
|
-
.lm-mini [data-clip] { visibility: hidden; }
|
|
2674
|
-
.lm-more { position: absolute; top: 6px; right: 6px; font: 500 .8rem var(--lm-font); color: var(--lm-accent); background: var(--lm-surface); border: 0; border-radius: 4px; padding: 2px 6px; cursor: pointer; }
|
|
2675
|
-
.lm-more[data-more]:not([data-more=""])::before { content: attr(data-more) " "; }
|
|
2676
|
-
.lm-mini .lm-meters { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px; }
|
|
2677
|
-
.lm-mini .lm-meter { display: flex; align-items: baseline; gap: 8px; padding: 3px 8px; }
|
|
2678
|
-
.lm-mini .lm-meter b { flex: none; font-size: .9rem; }
|
|
2679
|
-
.lm-mini .lm-meter span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
2680
|
-
/* one grid for every row, so the bars line up whatever the names */
|
|
2681
|
-
.lm-mini-limits { display: grid; grid-template-columns: minmax(0, max-content) minmax(48px, 1fr) auto auto; gap: 6px 10px; }
|
|
2682
|
-
.lm-mini-lim { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: center; font-size: .8rem; }
|
|
2683
|
-
.lm-mini-lim .lm-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
2684
|
-
.lm-mini-lim .lm-tag { margin-left: 5px; }
|
|
2685
|
-
.lm-mini-lim .lm-track { height: 9px; }
|
|
2686
|
-
.lm-mini-lim .lm-val { white-space: nowrap; }
|
|
2687
|
-
.lm-mini-lim .lm-sub { font: 400 .74rem var(--lm-mono); color: var(--lm-muted); }
|
|
2688
|
-
.lm-mini .lm-controls { gap: 6px; column-gap: 16px; }
|
|
2689
|
-
.lm-mini .lm-controls small, .lm-mini .lm-controls > h3:not(:first-child) { display: none; }
|
|
2690
|
-
.lm-mini .lm-controls label.lm-range { grid-template-columns: minmax(0, 1fr) minmax(90px, 1.2fr); align-items: center; gap: 10px; font-size: .8rem; }
|
|
2691
|
-
.lm-mini .lm-select { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: .8rem; }
|
|
2692
|
-
.lm-mini .lm-select select { width: auto; padding: 1px 6px; font-size: .78rem; }
|
|
2693
|
-
.lm-mini .lm-switch { font-size: .8rem; }
|
|
2694
|
-
.lm-mini .lm-switch input { margin-top: 2px; }
|
|
2695
|
-
.lm-mini .lm-presets { gap: 4px; }
|
|
2696
|
-
.lm-mini .lm-presets button { padding: 2px 8px; font-size: .72rem; }
|
|
2697
|
-
@container (min-width: 420px) {
|
|
2698
|
-
.lm-mini .lm-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
2699
|
-
.lm-mini .lm-controls > :is(h3, .lm-presets) { grid-column: 1 / -1; }
|
|
2700
|
-
}
|
|
2701
|
-
.lm-mini .lm-compare > :not(h3:first-child, .lm-table-wrap:nth-child(3)) { display: none; }
|
|
2702
|
-
.lm-mini .lm-table { font-size: .76rem; }
|
|
2703
|
-
.lm-mini .lm-table th, .lm-mini .lm-table td { padding: 3px 8px 3px 0; }
|
|
2704
|
-
.lm-mini .lm-table small { display: none; }
|
|
2705
|
-
.lm-mini .lm-table thead th { white-space: nowrap; font-size: .6rem; }
|
|
2706
|
-
.lm-mini > .lm-card:has(> .lm-spark) { grid-template-rows: auto minmax(0, 1fr) auto; align-content: stretch; }
|
|
2707
|
-
.lm-spark { position: relative; min-height: 0; }
|
|
2708
|
-
.lm-spark svg { position: absolute; inset: 0; display: block; overflow: hidden; }
|
|
2709
|
-
.lm-spark-th { stroke: var(--lm-muted); stroke-dasharray: 4 3; }
|
|
2710
|
-
.lm-spark-load { stroke: var(--lm-fg); opacity: .45; }
|
|
2711
|
-
.lm-spark-text { margin: 0; font-size: .76rem; color: var(--lm-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
2712
|
-
|
|
2713
|
-
/* the drawer: the page's own panel, alone, over the right of the board */
|
|
2714
|
-
.lm[data-full] > .lm-drawer:not([data-drawer]) { display: none; }
|
|
2715
|
-
.lm[data-full] > .lm-drawer[data-drawer] { display: grid; gap: 14px; align-content: start; position: absolute; top: 16px; right: 16px; bottom: 16px; z-index: 4; width: min(640px, calc(100% - 32px)); overflow: auto; overscroll-behavior: contain; padding: 14px; background: var(--lm-bg); border: 1px solid var(--lm-line); border-radius: 10px; box-shadow: -8px 0 30px rgb(0 0 0 / .2); container-type: inline-size; }
|
|
2716
|
-
.lm-side[data-drawer] :is(.lm-panel, .lm-strip, .lm-charts, .lm-card):not([data-drawn]):not(.lm-panel *) { display: none; }
|
|
2717
|
-
.lm-side[data-drawer] .lm-strip { grid-template-columns: minmax(0, 1fr); }
|
|
2718
|
-
.lm-drawer-bar { display: flex; justify-content: flex-end; }
|
|
2719
|
-
|
|
2720
|
-
/* a page of its own: its .lm-side is a box under the board that scrolls on its own, the board as large as leaves it a
|
|
2721
|
-
third of the screen */
|
|
2722
|
-
.lm[data-full] > .lm-side:not(.lm-drawer) { display: grid; gap: 14px; align-content: start; flex: 1 1 0; min-height: 33dvh; overflow: auto; overscroll-behavior: contain; container-type: inline-size; }
|
|
2723
|
-
|
|
2724
|
-
/* focus: the board and what runs on it in the middle of the screen */
|
|
2725
|
-
.lm[data-mode="focus"] > .lm-side:not(.lm-drawer) { display: none; }
|
|
2726
|
-
.lm[data-mode="focus"] > .lm-wrap { margin-top: auto; }
|
|
2727
|
-
.lm[data-mode="focus"] > :is(.lm-story, .lm-line) { order: 1; }
|
|
2728
|
-
.lm[data-mode="focus"]::after { content: ""; order: 2; margin-top: auto; }
|
|
2729
|
-
.lm[data-mode="focus"] > .lm-story { border-left-width: 4px; padding: 10px 14px; }
|
|
2730
|
-
.lm[data-mode="focus"] > .lm-story p { font-size: 1.1rem; }
|
|
2731
|
-
|
|
2732
|
-
@media (max-width: 760px) {
|
|
2733
|
-
.lm[data-full] { padding: 10px; gap: 8px; }
|
|
2734
|
-
/* the page has the title, and the legend: here they would leave the diagram no room */
|
|
2735
|
-
.lm[data-full] > h2, .lm[data-full] :is(.lm-head h2, .lm-legend, .lm-story legend) { display: none; }
|
|
2736
|
-
/* the one exception: here the diagram runs top to bottom, and shrunk to the screen it is too small to read, so it
|
|
2737
|
-
pans in a box of its own with the bar on top. The page never scrolls */
|
|
2738
|
-
.lm[data-full] .lm-board { width: 100%; }
|
|
2739
|
-
.lm[data-full] > .lm-wrap { height: 40dvh; overflow: auto; row-gap: 0; overscroll-behavior: contain; }
|
|
2740
|
-
.lm[data-mode="focus"] > .lm-wrap { height: auto; flex: 1 1 0; min-height: 0; margin-top: 0; }
|
|
2741
|
-
.lm[data-full] .lm-bar { position: sticky; top: 0; z-index: 1; padding-bottom: 8px; background: var(--lm-bg); }
|
|
2742
|
-
.lm[data-full] .lm-line { flex-wrap: wrap; }
|
|
2743
|
-
.lm[data-full] > .lm-story { padding: 6px 10px; gap: 6px 10px; }
|
|
2744
|
-
.lm[data-full] > .lm-story p { font-size: .84rem; }
|
|
2745
|
-
.lm[data-full] .lm-story button { padding: 4px 10px; }
|
|
2746
|
-
.lm[data-full] .lm-headline { flex-basis: 100%; }
|
|
2747
|
-
.lm-dock { flex-direction: column; min-height: 0; gap: 6px; }
|
|
2748
|
-
/* the load bar takes some of the dock's room: the load is no longer in a card */
|
|
2749
|
-
.lm[data-full] > .lm-dock { min-height: clamp(170px, 22dvh, 340px); }
|
|
2750
|
-
.lm-tabs { display: flex; flex: none; gap: 2px; border-bottom: 1px solid var(--lm-line); overflow: hidden; }
|
|
2751
|
-
.lm-tabs button { font: 500 .78rem var(--lm-font); color: var(--lm-muted); background: none; border: 0; border-bottom: 2px solid transparent; padding: 6px 8px; cursor: pointer; white-space: nowrap; }
|
|
2752
|
-
.lm-tabs button[aria-pressed="true"] { color: var(--lm-fg); border-color: var(--lm-fg); }
|
|
2753
|
-
.lm-mini:not([data-active]) { display: none; }
|
|
2754
|
-
.lm[data-full] > .lm-side[data-drawer] { inset: 8px; width: auto; }
|
|
2755
|
-
/* the load in thumb reach: the bar under the board and the story, over the verdict */
|
|
2756
|
-
.lm[data-full] .lm-head { display: contents; }
|
|
2757
|
-
.lm[data-full] .lm-loadbar { order: 2; flex: none; }
|
|
2758
|
-
/* two lines, so the board keeps its room: the scenarios and the load's value, then the track; the label names the
|
|
2759
|
-
slider unseen */
|
|
2760
|
-
.lm[data-full] .lm-load small { display: none; }
|
|
2761
|
-
.lm[data-full] .lm-load { display: contents; }
|
|
2762
|
-
.lm[data-full] :is(.lm-loadbar legend, .lm-load > label) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
|
|
2763
|
-
.lm[data-full] .lm-load > output { margin-left: auto; }
|
|
2764
|
-
.lm[data-full] .lm-load-track { flex: 1 1 100%; }
|
|
2765
|
-
.lm[data-full] > :is(.lm-line, .lm-dock) { order: 3; }
|
|
2766
|
-
}
|
|
2767
|
-
|
|
2768
|
-
.lm-verdict { margin: 0; padding: 10px 14px; border-left: 4px solid var(--lm-ok); background: var(--lm-accent-soft); border-radius: 0 6px 6px 0; }
|
|
2769
|
-
.lm-verdict[data-tier="warn"] { border-color: var(--lm-warn); }
|
|
2770
|
-
.lm-verdict[data-tier="over"] { border-color: var(--lm-drop); }
|
|
2771
|
-
.lm-measure { margin: 6px 0 0; padding: 0 14px; font-size: .86rem; color: var(--lm-muted); }
|
|
2772
|
-
|
|
2773
|
-
.lm-strip { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); gap: 14px; align-items: start; }
|
|
2774
|
-
@container (max-width: 860px) { .lm-strip { grid-template-columns: minmax(0, 1fr); } }
|
|
2775
|
-
.lm { container-type: inline-size; }
|
|
2776
|
-
|
|
2777
|
-
.lm-meters { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
|
|
2778
|
-
.lm-meter { padding: 8px 10px; border-radius: 6px; background: var(--lm-bg); min-width: 0; }
|
|
2779
|
-
.lm-meter b { display: block; font: 500 1.15rem var(--lm-mono); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
2780
|
-
.lm-meter span { font-size: .74rem; color: var(--lm-muted); }
|
|
2781
|
-
.lm-meter[data-state="warn"] b { color: var(--lm-warn); } .lm-meter[data-state="over"] b { color: var(--lm-drop); }
|
|
2782
|
-
|
|
2783
|
-
.lm-limits { display: grid; gap: 10px; }
|
|
2784
|
-
.lm-lim, .lm-scale { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr) 10rem; gap: 4px 14px; align-items: center; }
|
|
2785
|
-
@container (max-width: 640px) { .lm-lim, .lm-scale { grid-template-columns: minmax(0, 1fr); } .lm-scale > :first-child, .lm-scale > :last-child { display: none; } }
|
|
2786
|
-
.lm-lim b { display: block; font-weight: 600; font-size: .88rem; }
|
|
2787
|
-
.lm-lim .lm-sub { display: block; font-size: .74rem; color: var(--lm-muted); }
|
|
2788
|
-
.lm-tag { font: 600 .64rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; border-radius: 3px; padding: 1px 5px; margin-left: 6px; vertical-align: 1px; }
|
|
2789
|
-
.lm-tag[data-kind="first"] { color: var(--lm-surface); background: var(--lm-drop); }
|
|
2790
|
-
.lm-tag[data-kind="estimated"] { color: var(--lm-warn); border: 1px solid currentColor; }
|
|
2791
|
-
.lm-tag[data-kind="published"] { color: var(--lm-alt); border: 1px solid currentColor; }
|
|
2792
|
-
.lm-tag[data-kind="none"] { color: var(--lm-muted); border: 1px dashed currentColor; }
|
|
2793
|
-
.lm-tag[data-kind="range"], .lm-tag[data-kind="rank"] { color: var(--lm-muted); border: 1px solid currentColor; }
|
|
2794
|
-
.lm-track { position: relative; height: 16px; background: var(--lm-bg); border-radius: 3px; overflow: hidden; }
|
|
2795
|
-
.lm-fill { position: absolute; inset: 0 auto 0 0; background: var(--lm-ok); transition: width .25s ease; }
|
|
2796
|
-
.lm-fill[data-state="warn"] { background: var(--lm-warn); } .lm-fill[data-state="over"] { background: var(--lm-drop); }
|
|
2797
|
-
.lm-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--lm-fg); opacity: .55; }
|
|
2798
|
-
.lm-val { font: 500 .8rem var(--lm-mono); font-variant-numeric: tabular-nums; }
|
|
2799
|
-
.lm-val small { display: block; font: 400 .72rem var(--lm-font); color: var(--lm-muted); }
|
|
2800
|
-
.lm-scale { font: 400 .7rem var(--lm-mono); color: var(--lm-muted); }
|
|
2801
|
-
.lm-scale div { position: relative; height: 12px; }
|
|
2802
|
-
.lm-scale div span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
|
|
2803
|
-
|
|
2804
|
-
.lm-controls label.lm-range { display: grid; gap: 4px; font-size: .84rem; }
|
|
2805
|
-
.lm-controls label.lm-range > span { display: flex; justify-content: space-between; gap: 8px; }
|
|
2806
|
-
.lm-controls output { font-family: var(--lm-mono); font-variant-numeric: tabular-nums; }
|
|
2807
|
-
.lm-controls input[type=range] { width: 100%; accent-color: var(--lm-accent); }
|
|
2808
|
-
.lm-presets { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
2809
|
-
.lm-presets button { font: 500 .76rem var(--lm-font); background: var(--lm-accent-soft); color: var(--lm-fg); border: 1px solid transparent; border-radius: 5px; padding: 5px 10px; cursor: pointer; }
|
|
2810
|
-
.lm-presets button[aria-pressed="true"] { border-color: var(--lm-accent); }
|
|
2811
|
-
.lm-switch { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 8px; align-items: start; font-size: .84rem; cursor: pointer; }
|
|
2812
|
-
.lm-switch input { margin: 3px 0 0; accent-color: var(--lm-accent); }
|
|
2813
|
-
.lm-switch small, .lm-select small { grid-column: 2; color: var(--lm-muted); font-size: .74rem; line-height: 1.3; }
|
|
2814
|
-
.lm-select { display: grid; gap: 4px; font-size: .84rem; }
|
|
2815
|
-
.lm-select select { width: 100%; min-width: 0; font: 400 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 5px; padding: 5px 8px; }
|
|
2816
|
-
.lm-off { opacity: .45; cursor: default; }
|
|
2817
|
-
|
|
2818
|
-
.lm-facts { margin: 0; padding-left: 1.1em; font-size: .88rem; columns: 2; column-gap: 28px; }
|
|
2819
|
-
@container (max-width: 860px) { .lm-facts { columns: 1; } }
|
|
2820
|
-
.lm-facts li { margin-bottom: 8px; break-inside: avoid; }
|
|
2821
|
-
.lm-prov { font: 600 .66rem var(--lm-font); text-transform: uppercase; letter-spacing: .06em; }
|
|
2822
|
-
.lm-prov[data-kind="measured"] { color: var(--lm-ok); } .lm-prov[data-kind="estimated"] { color: var(--lm-warn); }
|
|
2823
|
-
.lm-prov[data-kind="configured"] { color: var(--lm-accent); } .lm-prov[data-kind="published"] { color: var(--lm-alt); }
|
|
2824
|
-
|
|
2825
|
-
/* scenario identity colours (s1–s4) are checked for colour-blind separation on both surfaces; text never wears them */
|
|
2826
|
-
.lm-scenarios { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
|
|
2827
|
-
.lm-scenarios legend { float: left; font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); margin-right: 6px; padding: 0; }
|
|
2828
|
-
.lm-scenarios button { font: 500 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
|
|
2829
|
-
.lm-scenarios button[aria-pressed="true"] { border-color: var(--lm-fg); box-shadow: inset 0 0 0 1px var(--lm-fg); }
|
|
2830
|
-
.lm-scenarios i, .lm-table i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 6px; }
|
|
2831
|
-
.lm-story { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0; min-width: 0; padding: 8px 12px; border: 1px solid var(--lm-line); border-left: 3px solid var(--lm-accent); border-radius: 6px; background: var(--lm-surface); }
|
|
2832
|
-
.lm-story legend { float: left; font: 600 .74rem var(--lm-font); text-transform: uppercase; letter-spacing: .08em; color: var(--lm-muted); padding: 0; }
|
|
2833
|
-
.lm-story p { flex: 1 1 240px; display: grid; margin: 0; font: 400 .9rem/1.4 var(--lm-font); color: var(--lm-fg); }
|
|
2834
|
-
.lm-story p > span { grid-area: 1 / 1; }
|
|
2835
|
-
.lm-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
2836
|
-
.lm-story p > span:not([data-shown]), .lm-story em:not([data-shown]) { visibility: hidden; }
|
|
2837
|
-
.lm-story-progress { display: flex; align-items: center; gap: 4px; }
|
|
2838
|
-
.lm-story-progress i { position: relative; width: 28px; height: 4px; border-radius: 2px; background: var(--lm-line); overflow: hidden; }
|
|
2839
|
-
.lm-story-progress i[data-state="done"], .lm-story:not([data-playing]) .lm-story-progress i[data-state="now"] { background: var(--lm-accent); }
|
|
2840
|
-
.lm-story[data-playing] .lm-story-progress i[data-state="now"]::before { content: ""; position: absolute; inset: 0; background: var(--lm-accent); transform-origin: left; animation: lm-step var(--lm-step) linear both; }
|
|
2841
|
-
@keyframes lm-step { from { transform: scaleX(0); } to { transform: scaleX(1); } }
|
|
2842
|
-
.lm-story b { font-weight: 600; color: var(--lm-muted); margin-right: 4px; white-space: nowrap; }
|
|
2843
|
-
.lm-story-nav { display: flex; gap: 6px; }
|
|
2844
|
-
.lm-story em { color: var(--lm-muted); }
|
|
2845
|
-
.lm-story button { font: 500 .84rem var(--lm-font); color: var(--lm-fg); background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
|
|
2846
|
-
.lm-story button[aria-disabled="true"] { opacity: .45; cursor: default; }
|
|
2847
|
-
.lm-own { font-size: .78rem; color: var(--lm-muted); }
|
|
2848
|
-
|
|
2849
|
-
/* the scenarios and the load over the board, in view while the page scrolls; on a phone under the board */
|
|
2850
|
-
.lm-loadbar { position: sticky; top: var(--lm-sticky-top, 0px); z-index: 3; container-type: inline-size; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px; padding: 6px 12px 2px; background: var(--lm-surface); border: 1px solid var(--lm-line); border-radius: 8px; box-shadow: 0 4px 14px -10px rgb(0 0 0 / .4); }
|
|
2851
|
-
.lm-loadbar .lm-scenarios { flex-wrap: nowrap; max-width: 100%; overflow-x: auto; padding: 2px; }
|
|
2852
|
-
.lm-loadbar .lm-scenarios button { flex: none; white-space: nowrap; }
|
|
2853
|
-
.lm-loadbar .lm-load { flex: 1 1 300px; }
|
|
2854
|
-
@container (min-width: 720px) {
|
|
2855
|
-
.lm-loadbar .lm-load { grid-template: "label track value" / minmax(0, max-content) minmax(160px, 1fr) auto; align-items: start; }
|
|
2856
|
-
.lm-loadbar .lm-load > label { max-width: 14em; padding-top: 6px; }
|
|
2096
|
+
/** A model has a design to change: a parameter beside the load, or a preset that sets no load. */
|
|
2097
|
+
const hasDesign = (lm) => lm.model.params.length > 1 || lm.ev.presets.some((p) => !("load" in p.values));
|
|
2098
|
+
// src/verdictLine.tsx
|
|
2099
|
+
/**
|
|
2100
|
+
* The verdict in one line, from the same evaluation as the sentence: the load, how far the target holds, the first
|
|
2101
|
+
* limit and how sure its capacity is, what is past capacity. The sentence is its tooltip and opens under "Why".
|
|
2102
|
+
*/
|
|
2103
|
+
function VerdictLine({ lm, verdict = true, extra = 0, open, why = true, assumptions }) {
|
|
2104
|
+
const { ev, model, values } = lm;
|
|
2105
|
+
const first = ev.firstLimit;
|
|
2106
|
+
const range = ev.target;
|
|
2107
|
+
const target = `${pct(model.thresholds.target)} target`;
|
|
2108
|
+
const c = first?.capacity;
|
|
2109
|
+
const kind = c?.ref ? "published" : c?.provenance === "estimated" ? "estimated" : "range";
|
|
2110
|
+
const sure = !c ? "" : kind === "range" ? plusMinus(c) : `${kind === "published" ? "pub" : "est"}${c.within ? ` ${plusMinus(c)}` : ""}`;
|
|
2111
|
+
const over = ev.ranked.filter((x) => (x.util ?? 0) > model.thresholds.full);
|
|
2112
|
+
const when = range ? whenRange(model, range) : "";
|
|
2113
|
+
const estimated = ev.assumptions.filter((a) => a.kind === "capacity" && a.capacity.provenance === "estimated").length;
|
|
2114
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2115
|
+
verdict && /* @__PURE__ */ jsx("p", {
|
|
2116
|
+
className: "lm-headline",
|
|
2117
|
+
title: ev.verdict.text,
|
|
2118
|
+
"aria-live": "polite",
|
|
2119
|
+
children: !first || !range ? ev.verdict.text : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2120
|
+
/* @__PURE__ */ jsxs("b", {
|
|
2121
|
+
className: "lm-num",
|
|
2122
|
+
children: [fmt(values.load), "×"]
|
|
2123
|
+
}),
|
|
2124
|
+
" ·",
|
|
2125
|
+
" ",
|
|
2126
|
+
values.load < range.low ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2127
|
+
"the ",
|
|
2128
|
+
target,
|
|
2129
|
+
" holds to ",
|
|
2130
|
+
/* @__PURE__ */ jsx("b", {
|
|
2131
|
+
className: "lm-num",
|
|
2132
|
+
children: multiples(range, model.searchMax, true)
|
|
2133
|
+
}),
|
|
2134
|
+
when && ` (${when})`
|
|
2135
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2136
|
+
"past the ",
|
|
2137
|
+
target,
|
|
2138
|
+
" from ",
|
|
2139
|
+
/* @__PURE__ */ jsx("b", {
|
|
2140
|
+
className: "lm-num",
|
|
2141
|
+
children: multiple(range.low, model.searchMax)
|
|
2142
|
+
})
|
|
2143
|
+
] }),
|
|
2144
|
+
" ",
|
|
2145
|
+
"· limited by ",
|
|
2146
|
+
/* @__PURE__ */ jsx("b", { children: first.name }),
|
|
2147
|
+
sure && /* @__PURE__ */ jsx("span", {
|
|
2148
|
+
className: "lm-tag",
|
|
2149
|
+
"data-kind": kind,
|
|
2150
|
+
children: sure
|
|
2151
|
+
}),
|
|
2152
|
+
over.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2153
|
+
" ",
|
|
2154
|
+
"· ",
|
|
2155
|
+
/* @__PURE__ */ jsx("b", { children: over.map((x) => x.name).join(", ") }),
|
|
2156
|
+
" past capacity"
|
|
2157
|
+
] })
|
|
2158
|
+
] })
|
|
2159
|
+
}),
|
|
2160
|
+
open && verdict && why && /* @__PURE__ */ jsx("button", {
|
|
2161
|
+
type: "button",
|
|
2162
|
+
className: "lm-link",
|
|
2163
|
+
onClick: (e) => open("verdict", e.currentTarget),
|
|
2164
|
+
children: "Why ›"
|
|
2165
|
+
}),
|
|
2166
|
+
open && assumptions && /* @__PURE__ */ jsxs("button", {
|
|
2167
|
+
type: "button",
|
|
2168
|
+
className: "lm-link",
|
|
2169
|
+
onClick: (e) => open("assumptions", e.currentTarget),
|
|
2170
|
+
children: [
|
|
2171
|
+
"What this assumes · ",
|
|
2172
|
+
ev.assumptions.length + extra,
|
|
2173
|
+
estimated > 0 && ` (${estimated} estimated)`,
|
|
2174
|
+
" ›"
|
|
2175
|
+
]
|
|
2176
|
+
})
|
|
2177
|
+
] });
|
|
2857
2178
|
}
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2179
|
+
// src/frame.tsx
|
|
2180
|
+
const Body = lazy(() => import("./framePanels-BL9_bQ8A.js").then((m) => ({ default: m.FramePanelBody })));
|
|
2181
|
+
/** A frame's panels, in the order of their tabs: one opens at a time. */
|
|
2182
|
+
const FRAME_PANELS = [
|
|
2183
|
+
"limits",
|
|
2184
|
+
"controls",
|
|
2185
|
+
"headroom",
|
|
2186
|
+
"live",
|
|
2187
|
+
"assumptions"
|
|
2188
|
+
];
|
|
2189
|
+
/** What each tab says. */
|
|
2190
|
+
const TITLES = {
|
|
2191
|
+
limits: "Limits",
|
|
2192
|
+
controls: "Design",
|
|
2193
|
+
headroom: "Headroom",
|
|
2194
|
+
live: "Live",
|
|
2195
|
+
assumptions: "Assumes"
|
|
2196
|
+
};
|
|
2197
|
+
/**
|
|
2198
|
+
* The scenarios as one control: a canvas too narrow or too low for a row of buttons still names the one that is on.
|
|
2199
|
+
* A reader who changed a value sees "your own values" until they pick a scenario again.
|
|
2200
|
+
*/
|
|
2201
|
+
function ScenarioPick({ lm }) {
|
|
2202
|
+
const { model } = lm;
|
|
2203
|
+
if (!model.scenarios.length) return null;
|
|
2204
|
+
return /* @__PURE__ */ jsxs("select", {
|
|
2205
|
+
className: "lm-canvas-pick",
|
|
2206
|
+
"aria-label": "Scenario",
|
|
2207
|
+
value: lm.scenario?.label ?? "",
|
|
2208
|
+
onChange: (e) => e.target.value && lm.setScenario(e.target.value),
|
|
2209
|
+
children: [!lm.scenario && /* @__PURE__ */ jsx("option", {
|
|
2210
|
+
value: "",
|
|
2211
|
+
children: "your own values"
|
|
2212
|
+
}), model.scenarios.map((s) => /* @__PURE__ */ jsx("option", {
|
|
2213
|
+
value: s.label,
|
|
2214
|
+
children: s.label
|
|
2215
|
+
}, s.label))]
|
|
2216
|
+
});
|
|
2861
2217
|
}
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
.
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
.
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
.
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
.lm
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
.
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
.lm-fill { transition: none; }
|
|
2904
|
-
.lm-story[data-playing] .lm-story-progress i[data-state="now"]::before { animation: none; transform: none; }
|
|
2218
|
+
/**
|
|
2219
|
+
* What the bar over a canvas holds: the title, the scenarios and the flows' legend. A compact or a short canvas folds
|
|
2220
|
+
* the scenarios into one control, the title gives way first where the row is short of room, and the legend shows on a
|
|
2221
|
+
* wide one. One row always:
|
|
2222
|
+
* nothing the reader does changes its height.
|
|
2223
|
+
*/
|
|
2224
|
+
function BarParts({ lm, title, legend = true, onStory }) {
|
|
2225
|
+
const size = useCanvasSize();
|
|
2226
|
+
const tight = size.width === "compact" || size.short;
|
|
2227
|
+
const heading = title === false ? null : title ?? lm.model.title;
|
|
2228
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2229
|
+
heading && /* @__PURE__ */ jsx("h2", { children: heading }),
|
|
2230
|
+
tight ? /* @__PURE__ */ jsx(ScenarioPick, { lm }) : /* @__PURE__ */ jsx(Scenarios, { lm }),
|
|
2231
|
+
onStory && lm.model.story.length > 0 && /* @__PURE__ */ jsx("button", {
|
|
2232
|
+
type: "button",
|
|
2233
|
+
className: "lm-btn lm-canvas-play",
|
|
2234
|
+
onClick: onStory,
|
|
2235
|
+
children: "▶ Story"
|
|
2236
|
+
}),
|
|
2237
|
+
legend && size.width === "wide" && !size.short && /* @__PURE__ */ jsx(Legend, { lm }),
|
|
2238
|
+
!lm.fill && /* @__PURE__ */ jsxs("span", {
|
|
2239
|
+
className: "lm-canvas-tools",
|
|
2240
|
+
children: [lm.fullScreen && /* @__PURE__ */ jsx("button", {
|
|
2241
|
+
type: "button",
|
|
2242
|
+
className: "lm-btn lm-canvas-chrome",
|
|
2243
|
+
"aria-pressed": lm.fullScreenMode === "panels",
|
|
2244
|
+
"aria-keyshortcuts": "F",
|
|
2245
|
+
title: "Show the panels (F)",
|
|
2246
|
+
onClick: () => lm.setFullScreenMode(lm.fullScreenMode === "panels" ? "focus" : "panels"),
|
|
2247
|
+
children: "Panels"
|
|
2248
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
2249
|
+
type: "button",
|
|
2250
|
+
className: "lm-btn lm-canvas-full",
|
|
2251
|
+
"aria-pressed": lm.fullScreen,
|
|
2252
|
+
"aria-label": lm.fullScreen ? "Close full screen" : "Full screen",
|
|
2253
|
+
title: lm.fullScreen ? "Close full screen" : "Full screen",
|
|
2254
|
+
onClick: lm.toggleFullScreen,
|
|
2255
|
+
children: lm.fullScreen ? "✕" : "⤢"
|
|
2256
|
+
})]
|
|
2257
|
+
})
|
|
2258
|
+
] });
|
|
2905
2259
|
}
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2260
|
+
/**
|
|
2261
|
+
* What the console under a canvas holds: the load, and under it the verdict in one line. Where the line has room,
|
|
2262
|
+
* "Why" opens the limits and the count of assumptions opens them.
|
|
2263
|
+
*/
|
|
2264
|
+
function ConsoleParts({ lm, extra = 0 }) {
|
|
2265
|
+
const size = useCanvasSize();
|
|
2266
|
+
const { panels, show, under } = useCanvasPanels();
|
|
2267
|
+
const links = size.width === "wide" && !size.short && !under;
|
|
2268
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(LoadRange, { lm }), /* @__PURE__ */ jsx("div", {
|
|
2269
|
+
className: "lm-canvas-verdict",
|
|
2270
|
+
"data-tier": lm.ev.verdict.tier,
|
|
2271
|
+
children: /* @__PURE__ */ jsx(VerdictLine, {
|
|
2272
|
+
lm,
|
|
2273
|
+
extra,
|
|
2274
|
+
open: links ? (p, from) => show(p === "verdict" ? "limits" : "assumptions", from) : void 0,
|
|
2275
|
+
why: panels.includes("limits"),
|
|
2276
|
+
assumptions: panels.includes("assumptions")
|
|
2277
|
+
})
|
|
2278
|
+
})] });
|
|
2279
|
+
}
|
|
2280
|
+
/**
|
|
2281
|
+
* A loadmap whole in one canvas: the bar over its top, the diagram, and the console with the load and the verdict under
|
|
2282
|
+
* it. The three that always show; the panels open from here.
|
|
2283
|
+
*/
|
|
2284
|
+
function Frame({ lm, title, legend = true, panels = FRAME_PANELS, open, defaultOpen, onOpen, assumptions, headroom = true, compare = true, scrolls, className, style, onNodeClick, selected, children }) {
|
|
2285
|
+
const least = lm.fullScreen && lm.fullScreenMode === "focus";
|
|
2286
|
+
const shown = least ? [] : panels.filter((p) => p !== "controls" || hasDesign(lm));
|
|
2287
|
+
const own = Children.toArray(children).filter((c) => !least || !(isValidElement(c) && c.type === Canvas.Panel));
|
|
2288
|
+
const live = lm.step != null || lm.storyPlaying;
|
|
2289
|
+
const [told, setTold] = useState(live);
|
|
2290
|
+
const [seen, setSeen] = useState(lm.step != null);
|
|
2291
|
+
if (live && !told) setTold(true);
|
|
2292
|
+
if (told && lm.step != null && !seen) setSeen(true);
|
|
2293
|
+
if (told && !live && seen) {
|
|
2294
|
+
setTold(false);
|
|
2295
|
+
setSeen(false);
|
|
2296
|
+
}
|
|
2297
|
+
const leave = () => {
|
|
2298
|
+
setTold(false);
|
|
2299
|
+
setSeen(false);
|
|
2300
|
+
};
|
|
2301
|
+
const [StoryBar, setStoryBar] = useState(null);
|
|
2302
|
+
const failed = useRef(() => {});
|
|
2303
|
+
failed.current = () => {
|
|
2304
|
+
lm.setStoryPlaying(false);
|
|
2305
|
+
lm.setStep(null);
|
|
2306
|
+
leave();
|
|
2307
|
+
};
|
|
2308
|
+
useEffect(() => {
|
|
2309
|
+
if (!told || StoryBar) return;
|
|
2310
|
+
let on = true;
|
|
2311
|
+
import("./story-mK-TEB6j.js").then((n) => n.n).then((m) => on && setStoryBar(() => m.Story), () => on && failed.current());
|
|
2312
|
+
return () => {
|
|
2313
|
+
on = false;
|
|
2314
|
+
};
|
|
2315
|
+
}, [told, StoryBar]);
|
|
2316
|
+
const drawn = told && !!StoryBar;
|
|
2317
|
+
const box = useRef(null);
|
|
2318
|
+
const was = useRef(told);
|
|
2319
|
+
const from = useRef(null);
|
|
2320
|
+
useEffect(() => {
|
|
2321
|
+
const root = box.current;
|
|
2322
|
+
const doc = root?.ownerDocument;
|
|
2323
|
+
if (!root || !doc) return;
|
|
2324
|
+
const play = root.querySelector(".lm-canvas-play");
|
|
2325
|
+
const at = doc.activeElement;
|
|
2326
|
+
if (told && !was.current) from.current = at === play ? "button" : null;
|
|
2327
|
+
if (drawn && from.current === "button" && (at === play || at === doc.body)) {
|
|
2328
|
+
root.querySelector(".lm-canvas-over .lm-story")?.focus({ preventScroll: true });
|
|
2329
|
+
from.current = "moved";
|
|
2330
|
+
}
|
|
2331
|
+
if (!told && was.current) {
|
|
2332
|
+
if (from.current && at === doc.body) play?.focus({ preventScroll: true });
|
|
2333
|
+
from.current = null;
|
|
2334
|
+
}
|
|
2335
|
+
was.current = told;
|
|
2336
|
+
}, [told, drawn]);
|
|
2337
|
+
return /* @__PURE__ */ jsxs(Canvas, {
|
|
2338
|
+
ref: box,
|
|
2339
|
+
lm,
|
|
2340
|
+
scrolls,
|
|
2341
|
+
over: told ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2342
|
+
StoryBar && /* @__PURE__ */ jsx(StoryBar, { lm }),
|
|
2343
|
+
!live && /* @__PURE__ */ jsx("button", {
|
|
2344
|
+
type: "button",
|
|
2345
|
+
className: "lm-btn lm-canvas-leave",
|
|
2346
|
+
"aria-label": "Leave the story",
|
|
2347
|
+
onClick: leave,
|
|
2348
|
+
children: "Done"
|
|
2349
|
+
}),
|
|
2350
|
+
lm.fullScreen && !lm.fill && /* @__PURE__ */ jsx("button", {
|
|
2351
|
+
type: "button",
|
|
2352
|
+
className: "lm-btn lm-canvas-leave",
|
|
2353
|
+
"aria-label": "Close full screen",
|
|
2354
|
+
title: "Close full screen",
|
|
2355
|
+
onClick: lm.toggleFullScreen,
|
|
2356
|
+
children: "✕"
|
|
2357
|
+
})
|
|
2358
|
+
] }) : void 0,
|
|
2359
|
+
legend: false,
|
|
2360
|
+
open,
|
|
2361
|
+
defaultOpen,
|
|
2362
|
+
onOpen,
|
|
2363
|
+
className: className ? `lm-frame ${className}` : "lm-frame",
|
|
2364
|
+
style,
|
|
2365
|
+
onNodeClick,
|
|
2366
|
+
selected,
|
|
2367
|
+
children: [
|
|
2368
|
+
/* @__PURE__ */ jsx(Canvas.Bar, { children: /* @__PURE__ */ jsx(BarParts, {
|
|
2369
|
+
lm,
|
|
2370
|
+
title,
|
|
2371
|
+
legend,
|
|
2372
|
+
onStory: () => lm.setStoryPlaying(true)
|
|
2373
|
+
}) }),
|
|
2374
|
+
/* @__PURE__ */ jsx(Canvas.Console, { children: /* @__PURE__ */ jsx(ConsoleParts, {
|
|
2375
|
+
lm,
|
|
2376
|
+
extra: assumptions?.length
|
|
2377
|
+
}) }),
|
|
2378
|
+
own,
|
|
2379
|
+
shown.map((p) => /* @__PURE__ */ jsx(Canvas.Panel, {
|
|
2380
|
+
id: p,
|
|
2381
|
+
title: TITLES[p],
|
|
2382
|
+
children: /* @__PURE__ */ jsx(Suspense, {
|
|
2383
|
+
fallback: null,
|
|
2384
|
+
children: /* @__PURE__ */ jsx(Body, {
|
|
2385
|
+
lm,
|
|
2386
|
+
id: p,
|
|
2387
|
+
assumptions,
|
|
2388
|
+
headroom,
|
|
2389
|
+
compare
|
|
2390
|
+
})
|
|
2391
|
+
})
|
|
2392
|
+
}, p))
|
|
2393
|
+
]
|
|
2394
|
+
});
|
|
2914
2395
|
}
|
|
2915
2396
|
// src/engine.ts
|
|
2916
2397
|
const TOKENS = [
|
|
@@ -3868,7 +3349,7 @@ function useLoadmap(model, whole, o = {}) {
|
|
|
3868
3349
|
document.addEventListener("fullscreenchange", f);
|
|
3869
3350
|
return () => document.removeEventListener("fullscreenchange", f);
|
|
3870
3351
|
}, [root]);
|
|
3871
|
-
const start = o.fullScreenMode ?? "panels";
|
|
3352
|
+
const start = o.chrome ? o.chrome === "least" ? "focus" : "panels" : o.fullScreenMode ?? "panels";
|
|
3872
3353
|
const [modeState, setModeState] = useState({
|
|
3873
3354
|
start,
|
|
3874
3355
|
mode: start
|
|
@@ -3979,8 +3460,6 @@ function canvasMeasure(fontFamily) {
|
|
|
3979
3460
|
};
|
|
3980
3461
|
}
|
|
3981
3462
|
// src/Loadmap.tsx
|
|
3982
|
-
const Dock = lazy(() => import("./later-DpL22rlH.js").then((m) => ({ default: m.Dock })));
|
|
3983
|
-
const VerdictLine = lazy(() => import("./later-DpL22rlH.js").then((m) => ({ default: m.VerdictLine })));
|
|
3984
3463
|
/** What the page's own switch says, on `<html>`: `data-theme`, or a `dark` or `light` class; null when it says nothing. */
|
|
3985
3464
|
function pageTheme() {
|
|
3986
3465
|
if (typeof document === "undefined") return null;
|
|
@@ -4045,152 +3524,63 @@ function LoadmapRoot({ lm, theme = "auto", children }) {
|
|
|
4045
3524
|
children
|
|
4046
3525
|
});
|
|
4047
3526
|
}
|
|
4048
|
-
/**
|
|
4049
|
-
const LOADMAP_PANELS =
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
"limits",
|
|
4053
|
-
"
|
|
4054
|
-
"
|
|
4055
|
-
"
|
|
4056
|
-
"
|
|
4057
|
-
|
|
3527
|
+
/** A loadmap's panels, in the order of their tabs: one opens at a time, beside the diagram. */
|
|
3528
|
+
const LOADMAP_PANELS = FRAME_PANELS;
|
|
3529
|
+
/** The names `fullScreen` took while the panels were cards under the diagram, and the tab each is in now. */
|
|
3530
|
+
const BEFORE = {
|
|
3531
|
+
verdict: "limits",
|
|
3532
|
+
live: "live",
|
|
3533
|
+
limits: "limits",
|
|
3534
|
+
controls: "controls",
|
|
3535
|
+
headroom: "headroom",
|
|
3536
|
+
compare: "headroom",
|
|
3537
|
+
assumptions: "assumptions"
|
|
3538
|
+
};
|
|
3539
|
+
/** The tabs a list of names stands for, old names or new, in the tabs' own order. */
|
|
3540
|
+
function panelsOf(names) {
|
|
3541
|
+
const on = new Set(names.map((n) => BEFORE[n]));
|
|
3542
|
+
return LOADMAP_PANELS.filter((p) => on.has(p));
|
|
3543
|
+
}
|
|
3544
|
+
const warned = /* @__PURE__ */ new Set();
|
|
3545
|
+
/** Says once that a prop has another name now. */
|
|
3546
|
+
function renamed(old, now) {
|
|
3547
|
+
if (warned.has(old)) return;
|
|
3548
|
+
warned.add(old);
|
|
3549
|
+
console.warn(`loadmap: \`${old}\` is \`${now}\` now, and goes in a later version.`);
|
|
3550
|
+
}
|
|
4058
3551
|
/**
|
|
4059
|
-
* The whole
|
|
4060
|
-
*
|
|
3552
|
+
* The whole piece in one box the page sizes (by default `clamp(420px, 70dvh, 760px)` high): the title, the scenarios
|
|
3553
|
+
* and the story over the diagram, the load and the verdict under it, and the limits, the design, the headroom, the
|
|
3554
|
+
* live meters and the assumptions in panels that open from their tabs. Full screen is the same box at the screen's
|
|
3555
|
+
* size.
|
|
4061
3556
|
*/
|
|
4062
|
-
function Loadmap({ model, view, theme, title, assumptions, headroom = true, compare = true,
|
|
3557
|
+
function Loadmap({ model, view, theme, title, assumptions, headroom = true, compare = true, panels, open, defaultOpen, onOpen, scrolls, fullScreen, onNodeClick, selected, children, ref, ...o }) {
|
|
4063
3558
|
const lm = useLoadmap(model, view, o);
|
|
4064
3559
|
useImperativeHandle(ref, () => handleOf(lm), [lm]);
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
const
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
const
|
|
4071
|
-
|
|
4072
|
-
const full = lm.fullScreen;
|
|
4073
|
-
const focus = full && lm.fullScreenMode === "focus";
|
|
4074
|
-
const [drawer, setDrawer] = useState(null);
|
|
4075
|
-
if (drawer && !full) setDrawer(null);
|
|
4076
|
-
const close = useRef(null);
|
|
4077
|
-
useEffect(() => {
|
|
4078
|
-
if (drawer) close.current?.focus();
|
|
4079
|
-
}, [drawer]);
|
|
4080
|
-
const open = (p, from) => setDrawer({
|
|
4081
|
-
panel: p,
|
|
4082
|
-
from
|
|
4083
|
-
});
|
|
4084
|
-
const shut = () => {
|
|
4085
|
-
drawer?.from.focus();
|
|
4086
|
-
setDrawer(null);
|
|
4087
|
-
};
|
|
4088
|
-
useEffect(() => {
|
|
4089
|
-
if (!drawer) return;
|
|
4090
|
-
const f = (e) => {
|
|
4091
|
-
if (e.key !== "Escape") return;
|
|
4092
|
-
e.stopPropagation();
|
|
4093
|
-
drawer.from.focus();
|
|
4094
|
-
setDrawer(null);
|
|
4095
|
-
};
|
|
4096
|
-
document.addEventListener("keydown", f, true);
|
|
4097
|
-
return () => document.removeEventListener("keydown", f, true);
|
|
4098
|
-
}, [drawer]);
|
|
4099
|
-
const drawn = (...panels) => drawer && panels.includes(drawer.panel) ? "" : void 0;
|
|
4100
|
-
const panel = (id, children) => /* @__PURE__ */ jsx("div", {
|
|
4101
|
-
className: "lm-panel",
|
|
4102
|
-
"data-panel": id,
|
|
4103
|
-
"data-out": out(id),
|
|
4104
|
-
"data-drawn": drawn(id),
|
|
4105
|
-
children: (!full || drawer?.panel === id) && children
|
|
4106
|
-
});
|
|
4107
|
-
const heading = title !== false && /* @__PURE__ */ jsx("h2", { children: title ?? model.title });
|
|
4108
|
-
const verdict = listed("verdict");
|
|
4109
|
-
const line = focus ? verdict : verdict || listed("assumptions");
|
|
4110
|
-
return /* @__PURE__ */ jsxs(LoadmapRoot, {
|
|
3560
|
+
if (fullScreen) renamed("fullScreen", "panels");
|
|
3561
|
+
if (o.fullScreenMode) renamed("fullScreenMode", "chrome");
|
|
3562
|
+
const listed = panels ?? (fullScreen ? panelsOf(fullScreen) : LOADMAP_PANELS);
|
|
3563
|
+
const old = !panels && fullScreen ? fullScreen : null;
|
|
3564
|
+
const chart = headroom && (!old || old.includes("headroom"));
|
|
3565
|
+
const side = compare && model.scenarios.length > 1 && (!old || old.includes("compare"));
|
|
3566
|
+
return /* @__PURE__ */ jsx(LoadmapRoot, {
|
|
4111
3567
|
lm,
|
|
4112
3568
|
theme,
|
|
4113
|
-
children:
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
fallback: null,
|
|
4129
|
-
children: /* @__PURE__ */ jsx(VerdictLine, {
|
|
4130
|
-
lm,
|
|
4131
|
-
verdict,
|
|
4132
|
-
extra: assumptions?.length,
|
|
4133
|
-
open,
|
|
4134
|
-
assumptions: !focus && listed("assumptions")
|
|
4135
|
-
})
|
|
4136
|
-
})
|
|
4137
|
-
}),
|
|
4138
|
-
full && !focus && /* @__PURE__ */ jsx(Suspense, {
|
|
4139
|
-
fallback: null,
|
|
4140
|
-
children: /* @__PURE__ */ jsx(Dock, {
|
|
4141
|
-
lm,
|
|
4142
|
-
panels: LOADMAP_PANELS.filter(listed),
|
|
4143
|
-
open
|
|
4144
|
-
})
|
|
4145
|
-
}),
|
|
4146
|
-
/* @__PURE__ */ jsxs("div", {
|
|
4147
|
-
className: "lm-side lm-drawer",
|
|
4148
|
-
"data-out": out("verdict", "live", "limits", "controls", ...charts, "assumptions"),
|
|
4149
|
-
"data-drawer": drawer?.panel,
|
|
4150
|
-
...drawer && {
|
|
4151
|
-
role: "dialog",
|
|
4152
|
-
"aria-label": "The whole panel"
|
|
4153
|
-
},
|
|
4154
|
-
children: [
|
|
4155
|
-
drawer && /* @__PURE__ */ jsx("div", {
|
|
4156
|
-
className: "lm-drawer-bar",
|
|
4157
|
-
"data-drawn": "",
|
|
4158
|
-
children: /* @__PURE__ */ jsx("button", {
|
|
4159
|
-
type: "button",
|
|
4160
|
-
className: "lm-btn",
|
|
4161
|
-
onClick: shut,
|
|
4162
|
-
ref: close,
|
|
4163
|
-
children: "✕ Back to full screen"
|
|
4164
|
-
})
|
|
4165
|
-
}),
|
|
4166
|
-
panel("verdict", /* @__PURE__ */ jsx(Verdict, { lm })),
|
|
4167
|
-
charts.length > 0 && /* @__PURE__ */ jsxs("div", {
|
|
4168
|
-
className: charts.length > 1 ? "lm-charts lm-strip" : "lm-charts",
|
|
4169
|
-
"data-out": out(...charts),
|
|
4170
|
-
"data-drawn": drawn(...charts),
|
|
4171
|
-
children: [headroom && panel("headroom", /* @__PURE__ */ jsx(HeadroomChart, { lm })), side && panel("compare", /* @__PURE__ */ jsx(Compare, { lm }))]
|
|
4172
|
-
}),
|
|
4173
|
-
/* @__PURE__ */ jsxs("div", {
|
|
4174
|
-
className: "lm-strip lm-live",
|
|
4175
|
-
"data-out": out("live", "limits", "controls"),
|
|
4176
|
-
"data-drawn": drawn("live", "limits", "controls"),
|
|
4177
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
4178
|
-
className: "lm-card",
|
|
4179
|
-
"data-out": out("live", "limits"),
|
|
4180
|
-
"data-drawn": drawn("live", "limits"),
|
|
4181
|
-
children: [panel("live", /* @__PURE__ */ jsx(Meters, { lm })), panel("limits", /* @__PURE__ */ jsx(Limits, { lm }))]
|
|
4182
|
-
}), design && panel("controls", /* @__PURE__ */ jsx(Controls, {
|
|
4183
|
-
lm,
|
|
4184
|
-
load: false
|
|
4185
|
-
}))]
|
|
4186
|
-
}),
|
|
4187
|
-
panel("assumptions", /* @__PURE__ */ jsx(Assumptions, {
|
|
4188
|
-
lm,
|
|
4189
|
-
extra: assumptions
|
|
4190
|
-
}))
|
|
4191
|
-
]
|
|
4192
|
-
})
|
|
4193
|
-
]
|
|
3569
|
+
children: /* @__PURE__ */ jsx(Frame, {
|
|
3570
|
+
lm,
|
|
3571
|
+
title,
|
|
3572
|
+
panels: chart || side ? listed : listed.filter((p) => p !== "headroom"),
|
|
3573
|
+
open,
|
|
3574
|
+
defaultOpen,
|
|
3575
|
+
onOpen,
|
|
3576
|
+
assumptions,
|
|
3577
|
+
scrolls,
|
|
3578
|
+
headroom: chart,
|
|
3579
|
+
compare: side,
|
|
3580
|
+
onNodeClick,
|
|
3581
|
+
selected,
|
|
3582
|
+
children
|
|
3583
|
+
})
|
|
4194
3584
|
});
|
|
4195
3585
|
}
|
|
4196
3586
|
function handleOf(lm) {
|
|
@@ -4233,4 +3623,4 @@ function handleOf(lm) {
|
|
|
4233
3623
|
} : null
|
|
4234
3624
|
};
|
|
4235
3625
|
}
|
|
4236
|
-
export {
|
|
3626
|
+
export { Diagram as C, injectStyles as S, CANVAS as T, workerElk as _, panelsOf as a, useCanvasSize as b, LoadBar as c, isOn as d, plusMinus as f, whenRange as g, when as h, handleOf as i, LoadRange as l, useSize as m, Loadmap as n, usePageTheme as o, scenarioColor as p, LoadmapRoot as r, useLoadmap as s, LOADMAP_PANELS as t, Scenarios as u, Canvas as v, Legend as w, LOADMAP_CSS as x, useCanvasPanels as y };
|