@mark1russell7/site-pages 0.5.1 → 0.5.3
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 +6 -0
- package/build/chrome.d.ts +50 -4
- package/build/chrome.d.ts.map +1 -1
- package/build/chrome.js +111 -2
- package/build/chrome.js.map +1 -1
- package/build/explorer/index.d.ts.map +1 -1
- package/build/explorer/index.js +45 -51
- package/build/explorer/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -516,12 +516,18 @@ The entry `@mark1russell7/site-pages/chrome` has small helpers for the script of
|
|
|
516
516
|
| Function | Operation |
|
|
517
517
|
| --- | --- |
|
|
518
518
|
| `h(tag, attrs, ...children)` | Makes an element. The attribute `class` sets the class name. `false`, `null` and `undefined` give no attribute and no child. |
|
|
519
|
+
| `svg(tag, attrs, ...children)` | Makes an SVG element, with the rules of `h`. The attribute `class` sets the attribute `class`. |
|
|
519
520
|
| `byId(id)` | Gives the element with the ID. It throws when the page has no such element. |
|
|
520
521
|
| `setupTheme(button, storageKey)` | Makes a theme button: auto, light, dark, in turn. It sets `data-theme` on the `html` element and keeps the choice in `localStorage`. |
|
|
521
522
|
| `currentTheme()`, `nextTheme(storageKey)`, `applyTheme(theme, storageKey)` | Read the theme, set the next theme, or set one theme. A site with its own button, for example a React component, uses them. |
|
|
522
523
|
| `copyText(button, text, options)` | Copies a text. The button shows "Copied" or "Copy failed" for 1600 ms. |
|
|
523
524
|
| `copyToClipboard(text)` | Copies a text with the Clipboard API, else with `document.execCommand`. It gives `true` after a copy. |
|
|
524
525
|
| `showBuild(element, build, repository)` | Adds "Version 1.2.3, build abc1234 of 2026-11-03" to an element. The commit is a link to GitHub. |
|
|
526
|
+
| `new Segmented(container, choices, current, onChange, axis)` | Makes a radio group with one focus stop. The arrow keys select the next button and move the focus to it. `set(value)` changes the value with no event. |
|
|
527
|
+
| `rovingIndex(key, index, count, axis)` | Gives the index after an arrow key, with a wrap at each end. A tab list or a list of results uses it. |
|
|
528
|
+
|
|
529
|
+
Put the role and the label of the group on the container, for example `<div role="radiogroup" aria-label="Unit">`. The axis `horizontal` uses only the left and right arrows, and `vertical` uses only the up and down arrows. The default `both` uses the four arrows.
|
|
530
|
+
Add the class `sp-choices` of `demo.css` to the container. Then the buttons show as a row, and the button of the value shows as chosen.
|
|
525
531
|
|
|
526
532
|
```ts
|
|
527
533
|
import { byId, copyText, h, setupTheme } from "@mark1russell7/site-pages/chrome";
|
package/build/chrome.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The small helpers of a page in the browser: the element
|
|
3
|
-
* button, the copy button and the build stamp.
|
|
4
|
-
*
|
|
5
|
-
* Node.js code.
|
|
2
|
+
* The small helpers of a page in the browser: the element helpers, the element lookup, the theme
|
|
3
|
+
* button, the copy button and the build stamp. It also has a radio group with one focus stop.
|
|
4
|
+
* This module imports no Node.js module, so a site can bundle it. Import it from
|
|
5
|
+
* `@mark1russell7/site-pages/chrome`, because the package root also has Node.js code.
|
|
6
6
|
*/
|
|
7
7
|
/** A child of `h`: a node or a text. The values `null`, `undefined` and `false` give no child. */
|
|
8
8
|
export type Child = Node | string | null | undefined | false;
|
|
@@ -13,6 +13,12 @@ export type AttributeValue = string | number | boolean | null | undefined;
|
|
|
13
13
|
* `false`, `null` or `undefined` is not set. The attribute `class` sets the class name.
|
|
14
14
|
*/
|
|
15
15
|
export declare function h<K extends keyof HTMLElementTagNameMap>(tag: K, attrs?: Readonly<Record<string, AttributeValue>>, ...children: readonly (Child | readonly Child[])[]): HTMLElementTagNameMap[K];
|
|
16
|
+
/**
|
|
17
|
+
* This function makes an SVG element with attributes and children, with the rules of `h`. The
|
|
18
|
+
* attribute `class` sets the attribute `class`, because the class name of an SVG element is
|
|
19
|
+
* read-only.
|
|
20
|
+
*/
|
|
21
|
+
export declare function svg<K extends keyof SVGElementTagNameMap>(tag: K, attrs?: Readonly<Record<string, AttributeValue>>, ...children: readonly (Child | readonly Child[])[]): SVGElementTagNameMap[K];
|
|
16
22
|
/**
|
|
17
23
|
* This function gives the element with the ID. The page has each ID that the code asks for. Thus
|
|
18
24
|
* a missing ID is an error of the page, and the function throws an `Error`.
|
|
@@ -79,4 +85,44 @@ export interface CopyTextOptions {
|
|
|
79
85
|
* for a short time, then it shows its label again. The function gives the result of the copy.
|
|
80
86
|
*/
|
|
81
87
|
export declare function copyText(button: HTMLButtonElement, text: string, options?: CopyTextOptions): Promise<boolean>;
|
|
88
|
+
/** The arrow keys of a group: `horizontal` (Left and Right), `vertical` (Up and Down) or `both`. */
|
|
89
|
+
/** The arrow keys of a group: left and right, up and down, or the four arrows. */
|
|
90
|
+
export type RovingAxis = "horizontal" | "vertical" | "both";
|
|
91
|
+
/**
|
|
92
|
+
* This function gives the index of the next item after an arrow key, in a group of `count` items. The index
|
|
93
|
+
* wraps at each end. A key that is not an arrow of the axis gives `undefined`, and so does an empty group. An
|
|
94
|
+
* index outside the group goes to the first item on a step forward, and to the last item on a step back.
|
|
95
|
+
*/
|
|
96
|
+
export declare function rovingIndex(key: string, index: number, count: number, axis?: RovingAxis): number | undefined;
|
|
97
|
+
/** A choice of a `Segmented` control. */
|
|
98
|
+
export interface Choice<T extends string> {
|
|
99
|
+
/** The value of the choice. */
|
|
100
|
+
readonly value: T;
|
|
101
|
+
/** The text of the button. */
|
|
102
|
+
readonly label: string;
|
|
103
|
+
/** The tooltip and the accessible name of the button. Without it, the button has neither. */
|
|
104
|
+
readonly title?: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A group of radio buttons with one focus stop. The selected button has `tabIndex` 0, and the others have -1.
|
|
108
|
+
* The arrow keys select the next button, with a wrap at each end, and move the focus to it. The container keeps
|
|
109
|
+
* its own role and label, for example `role="radiogroup"` in the HTML.
|
|
110
|
+
*/
|
|
111
|
+
export declare class Segmented<T extends string> {
|
|
112
|
+
private readonly buttons;
|
|
113
|
+
private readonly choices;
|
|
114
|
+
private readonly onChange;
|
|
115
|
+
private current;
|
|
116
|
+
/**
|
|
117
|
+
* This constructor puts one button for each choice into the container, in place of its children. The listener
|
|
118
|
+
* gets each change by a click or a key, and no event for the choice that is already selected.
|
|
119
|
+
*/
|
|
120
|
+
constructor(container: HTMLElement, choices: readonly Choice<T>[], current: T, onChange: (value: T) => void, axis?: RovingAxis);
|
|
121
|
+
/** The value of the control. */
|
|
122
|
+
get value(): T;
|
|
123
|
+
/** This function sets the value. The listener gets no event. */
|
|
124
|
+
set(value: T): void;
|
|
125
|
+
private choose;
|
|
126
|
+
private show;
|
|
127
|
+
}
|
|
82
128
|
//# sourceMappingURL=chrome.d.ts.map
|
package/build/chrome.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chrome.d.ts","names":[],"sources":["../src/chrome.ts"],"mappings":";;;;;;;YASY,QAAQ;;YAGR;;;;;wBAMI,EAAE,gBAAgB,uBAChC,KAAK,GACL,QAAO,SAAS,eAAe,qBAC5B,oBAAoB,iBAAiB,aACvC,sBAAsB;;;;;
|
|
1
|
+
{"version":3,"file":"chrome.d.ts","names":[],"sources":["../src/chrome.ts"],"mappings":";;;;;;;YASY,QAAQ;;YAGR;;;;;wBAMI,EAAE,gBAAgB,uBAChC,KAAK,GACL,QAAO,SAAS,eAAe,qBAC5B,oBAAoB,iBAAiB,aACvC,sBAAsB;;;;;;wBAeT,IAAI,gBAAgB,sBAClC,KAAK,GACL,QAAO,SAAS,eAAe,qBAC5B,oBAAoB,iBAAiB,aACvC,qBAAqB;;;;;wBA8BR,KAAK,UAAU,cAAc,aAAa,aAAa;;qBAO1D;;YAGD,gBAAgB;;;;;wBAMZ,gBAAgB;;;;;wBAShB,WAAW,OAAO,OAAO;;wBAazB,UAAU,qBAAqB;;;;;;;;;wBAc/B,WAAW,QAAQ,mBAAmB;;iBAUrC;;WAEN;;WAEA;;WAEA;;;;;;;;;wBAUK,UAAU,SAAS,aAAa,OAAO,WAAW;;;;;wBAS5C,gBAAgB,eAAe;;iBA0BpC;;WAEN;;WAEA;;WAEA;;;;;;wBAOW,SAAS,QAAQ,mBAAmB,cAAc,UAAS,kBAAuB;;;YAY5F;;;;;;wBAaI,YAAY,aAAa,eAAe,eAAe,OAAM;;iBAQ5D,OAAO;;WAEb,OAAO;;WAEP;;WAEA;;;;;;;qBAQE,UAAU;mBACJ;mBACA;mBACA;UACT;;;;;EAMR,YAAY,WAAW,aAAa,kBAAkB,OAAO,MAAM,SAAS,GAAG,WAAW,OAAO,YAAY,OAAM;;MAyB/G,SAAS;;EAKb,IAAI,OAAO;UAKH;UAOA"}
|
package/build/chrome.js
CHANGED
|
@@ -5,9 +5,28 @@
|
|
|
5
5
|
*/
|
|
6
6
|
function h(tag, attrs = {}, ...children) {
|
|
7
7
|
const el = document.createElement(tag);
|
|
8
|
+
return fill(el, attrs, children, (value) => {
|
|
9
|
+
el.className = value;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
/** The namespace of the SVG elements. */
|
|
13
|
+
const SVG_NS = "http://www.w3.org/2000/svg";
|
|
14
|
+
/**
|
|
15
|
+
* This function makes an SVG element with attributes and children, with the rules of `h`. The
|
|
16
|
+
* attribute `class` sets the attribute `class`, because the class name of an SVG element is
|
|
17
|
+
* read-only.
|
|
18
|
+
*/
|
|
19
|
+
function svg(tag, attrs = {}, ...children) {
|
|
20
|
+
const el = document.createElementNS(SVG_NS, tag);
|
|
21
|
+
return fill(el, attrs, children, (value) => {
|
|
22
|
+
el.setAttribute("class", value);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/** This function sets the attributes and adds the children of an element of `h` or `svg`. */
|
|
26
|
+
function fill(el, attrs, children, setClass) {
|
|
8
27
|
for (const [name, value] of Object.entries(attrs)) {
|
|
9
28
|
if (value === false || value === null || value === void 0) continue;
|
|
10
|
-
if (name === "class")
|
|
29
|
+
if (name === "class") setClass(String(value));
|
|
11
30
|
else el.setAttribute(name, value === true ? "" : String(value));
|
|
12
31
|
}
|
|
13
32
|
for (const child of children.flat()) {
|
|
@@ -124,6 +143,96 @@ async function copyText(button, text, options = {}) {
|
|
|
124
143
|
}, options.ms ?? 1600);
|
|
125
144
|
return ok;
|
|
126
145
|
}
|
|
127
|
-
|
|
146
|
+
const ROVING_STEPS = {
|
|
147
|
+
horizontal: {
|
|
148
|
+
ArrowRight: 1,
|
|
149
|
+
ArrowLeft: -1
|
|
150
|
+
},
|
|
151
|
+
vertical: {
|
|
152
|
+
ArrowDown: 1,
|
|
153
|
+
ArrowUp: -1
|
|
154
|
+
},
|
|
155
|
+
both: {
|
|
156
|
+
ArrowRight: 1,
|
|
157
|
+
ArrowDown: 1,
|
|
158
|
+
ArrowLeft: -1,
|
|
159
|
+
ArrowUp: -1
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* This function gives the index of the next item after an arrow key, in a group of `count` items. The index
|
|
164
|
+
* wraps at each end. A key that is not an arrow of the axis gives `undefined`, and so does an empty group. An
|
|
165
|
+
* index outside the group goes to the first item on a step forward, and to the last item on a step back.
|
|
166
|
+
*/
|
|
167
|
+
function rovingIndex(key, index, count, axis = "both") {
|
|
168
|
+
const step = ROVING_STEPS[axis][key];
|
|
169
|
+
if (step === void 0 || count <= 0) return void 0;
|
|
170
|
+
if (!Number.isInteger(index) || index < 0 || index >= count) return step > 0 ? 0 : count - 1;
|
|
171
|
+
return (index + step + count) % count;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* A group of radio buttons with one focus stop. The selected button has `tabIndex` 0, and the others have -1.
|
|
175
|
+
* The arrow keys select the next button, with a wrap at each end, and move the focus to it. The container keeps
|
|
176
|
+
* its own role and label, for example `role="radiogroup"` in the HTML.
|
|
177
|
+
*/
|
|
178
|
+
var Segmented = class {
|
|
179
|
+
buttons;
|
|
180
|
+
choices;
|
|
181
|
+
onChange;
|
|
182
|
+
current;
|
|
183
|
+
/**
|
|
184
|
+
* This constructor puts one button for each choice into the container, in place of its children. The listener
|
|
185
|
+
* gets each change by a click or a key, and no event for the choice that is already selected.
|
|
186
|
+
*/
|
|
187
|
+
constructor(container, choices, current, onChange, axis = "both") {
|
|
188
|
+
this.choices = choices;
|
|
189
|
+
this.current = current;
|
|
190
|
+
this.onChange = onChange;
|
|
191
|
+
this.buttons = choices.map((choice) => {
|
|
192
|
+
const button = h("button", {
|
|
193
|
+
type: "button",
|
|
194
|
+
role: "radio",
|
|
195
|
+
"data-value": choice.value,
|
|
196
|
+
title: choice.title,
|
|
197
|
+
"aria-label": choice.title
|
|
198
|
+
}, choice.label);
|
|
199
|
+
button.addEventListener("click", () => this.choose(choice.value, false));
|
|
200
|
+
return button;
|
|
201
|
+
});
|
|
202
|
+
container.replaceChildren(...this.buttons);
|
|
203
|
+
container.addEventListener("keydown", (event) => {
|
|
204
|
+
const index = this.choices.findIndex((c) => c.value === this.current);
|
|
205
|
+
const next = rovingIndex(event.key, index, this.choices.length, axis);
|
|
206
|
+
if (next === void 0) return;
|
|
207
|
+
event.preventDefault();
|
|
208
|
+
this.choose(this.choices[next].value, true);
|
|
209
|
+
});
|
|
210
|
+
this.show();
|
|
211
|
+
}
|
|
212
|
+
/** The value of the control. */
|
|
213
|
+
get value() {
|
|
214
|
+
return this.current;
|
|
215
|
+
}
|
|
216
|
+
/** This function sets the value. The listener gets no event. */
|
|
217
|
+
set(value) {
|
|
218
|
+
this.current = value;
|
|
219
|
+
this.show();
|
|
220
|
+
}
|
|
221
|
+
choose(value, focus) {
|
|
222
|
+
const changed = value !== this.current;
|
|
223
|
+
this.set(value);
|
|
224
|
+
if (focus) this.buttons[this.choices.findIndex((c) => c.value === value)]?.focus();
|
|
225
|
+
if (changed) this.onChange(value);
|
|
226
|
+
}
|
|
227
|
+
show() {
|
|
228
|
+
this.choices.forEach((choice, i) => {
|
|
229
|
+
const button = this.buttons[i];
|
|
230
|
+
const on = choice.value === this.current;
|
|
231
|
+
button.setAttribute("aria-checked", String(on));
|
|
232
|
+
button.tabIndex = on ? 0 : -1;
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
export { Segmented, THEMES, applyTheme, byId, copyText, copyToClipboard, currentTheme, h, nextTheme, rovingIndex, setupTheme, showBuild, svg };
|
|
128
237
|
|
|
129
238
|
//# sourceMappingURL=chrome.js.map
|
package/build/chrome.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chrome.js","names":[],"sources":["../src/chrome.ts"],"sourcesContent":["/// <reference lib=\"dom\" />\n/**\n * The small helpers of a page in the browser: the element helper, the element lookup, the theme\n * button, the copy button and the build stamp. This module imports no Node.js module, so a site can\n * bundle it. Import it from `@mark1russell7/site-pages/chrome`, because the package root also has\n * Node.js code.\n */\n\n/** A child of `h`: a node or a text. The values `null`, `undefined` and `false` give no child. */\nexport type Child = Node | string | null | undefined | false;\n\n/** The value of an attribute of `h`. The value `true` gives an empty attribute. */\nexport type AttributeValue = string | number | boolean | null | undefined;\n\n/**\n * This function makes an element with attributes and children. An attribute with the value\n * `false`, `null` or `undefined` is not set. The attribute `class` sets the class name.\n */\nexport function h<K extends keyof HTMLElementTagNameMap>(\n tag: K,\n attrs: Readonly<Record<string, AttributeValue>> = {},\n ...children: readonly (Child | readonly Child[])[]\n): HTMLElementTagNameMap[K] {\n const el = document.createElement(tag);\n for (const [name, value] of Object.entries(attrs)) {\n if (value === false || value === null || value === undefined) continue;\n if (name === \"class\") el.className = String(value);\n else el.setAttribute(name, value === true ? \"\" : String(value));\n }\n for (const child of children.flat()) {\n if (child === null || child === undefined || child === false) continue;\n el.append(child);\n }\n return el;\n}\n\n/**\n * This function gives the element with the ID. The page has each ID that the code asks for. Thus\n * a missing ID is an error of the page, and the function throws an `Error`.\n */\nexport function byId<T extends HTMLElement = HTMLElement>(id: string): T {\n const el = document.getElementById(id);\n if (el === null) throw new Error(`The page has no element \"${id}\".`);\n return el as T;\n}\n\n/** The themes of the theme button, in the sequence of the clicks. `auto` follows the setting of the system. */\nexport const THEMES: readonly [\"auto\", \"light\", \"dark\"] = [\"auto\", \"light\", \"dark\"];\n\n/** A theme of the page. */\nexport type Theme = (typeof THEMES)[number];\n\n/**\n * This function gives the theme of the page from the attribute `data-theme` of the `html` element.\n * Without the attribute, or with another value, the theme is `auto`.\n */\nexport function currentTheme(): Theme {\n const theme = document.documentElement.dataset[\"theme\"];\n return theme === \"light\" || theme === \"dark\" ? theme : \"auto\";\n}\n\n/**\n * This function sets the theme of the page, and keeps it in `localStorage` under `storageKey`.\n * The theme `auto` removes the attribute `data-theme` and the stored value.\n */\nexport function applyTheme(theme: Theme, storageKey: string): void {\n const root = document.documentElement;\n if (theme === \"auto\") delete root.dataset[\"theme\"];\n else root.dataset[\"theme\"] = theme;\n try {\n if (theme === \"auto\") localStorage.removeItem(storageKey);\n else localStorage.setItem(storageKey, theme);\n } catch {\n // A browser with no storage keeps the theme until the page closes.\n }\n}\n\n/** This function sets the next theme after the current theme (auto, light, dark, auto), and gives it. */\nexport function nextTheme(storageKey: string): Theme {\n const next = THEMES[(THEMES.indexOf(currentTheme()) + 1) % THEMES.length] ?? \"auto\";\n applyTheme(next, storageKey);\n return next;\n}\n\n/**\n * This function makes a theme button. Each click sets the next theme. The text of the button is\n * \"Theme: auto\", \"Theme: light\" or \"Theme: dark\", and its `aria-label` tells the same theme.\n *\n * @remarks Before the first paint, a script in the `head` of the page reads `storageKey` from\n * `localStorage` and sets `data-theme`. Thus a dark page does not show white for a moment. The\n * plugin `siteShell` of the entry `./vite` adds that script.\n */\nexport function setupTheme(button: HTMLButtonElement, storageKey: string): void {\n const show = (theme: Theme): void => {\n button.textContent = `Theme: ${theme}`;\n button.setAttribute(\"aria-label\", `Color theme: ${theme}. Select to change.`);\n };\n show(currentTheme());\n button.addEventListener(\"click\", () => show(nextTheme(storageKey)));\n}\n\n/** The data of a build: `siteShell` writes it, and `showBuild` shows it. */\nexport interface BuildInfo {\n /** The first 7 characters of the commit, or `local` for a build outside CI. */\n readonly sha: string;\n /** The date of the build, as `YYYY-MM-DD`. */\n readonly date: string;\n /** The version of the package. A site without a version does not set it. */\n readonly version?: string | undefined;\n}\n\n/**\n * This function shows the version and the build of the site in an element. The text is \"Version\n * 1.2.3, build abc1234 of 2026-11-03\", and the commit is a link to GitHub. A build with no version\n * starts with \"Build\", and a local build has no link.\n *\n * @param repository - The repository as \"owner/name\".\n */\nexport function showBuild(element: HTMLElement, build: BuildInfo, repository: string): void {\n const commit = build.sha === \"local\" ? \"local\" : h(\"a\", { href: `https://github.com/${repository}/commit/${build.sha}` }, build.sha);\n element.append(build.version === undefined ? \"Build \" : `Version ${build.version}, build `, commit, ` of ${build.date}`);\n}\n\n/**\n * This function copies a text to the clipboard, and gives `true` when the copy is done. It uses\n * the Clipboard API. When that API is not available or refuses, it uses `document.execCommand`.\n */\nexport async function copyToClipboard(text: string): Promise<boolean> {\n try {\n await navigator.clipboard.writeText(text);\n return true;\n } catch {\n // An insecure page has no Clipboard API, and a browser can refuse the copy. The old command is the fallback.\n }\n try {\n const area = document.createElement(\"textarea\");\n area.value = text;\n area.setAttribute(\"readonly\", \"\");\n area.style.position = \"fixed\";\n area.style.opacity = \"0\";\n document.body.append(area);\n area.select();\n try {\n return document.execCommand(\"copy\");\n } finally {\n area.remove();\n }\n } catch {\n return false;\n }\n}\n\n/** The options of `copyText`. */\nexport interface CopyTextOptions {\n /** The text of the button after a copy. The default is \"Copied\". */\n readonly copied?: string;\n /** The text of the button after a failure. The default is \"Copy failed\". */\n readonly failed?: string;\n /** The time in milliseconds until the button shows its label again. The default is 1600. */\n readonly ms?: number;\n}\n\n/**\n * This function copies a text to the clipboard with `copyToClipboard`. The button tells the result\n * for a short time, then it shows its label again. The function gives the result of the copy.\n */\nexport async function copyText(button: HTMLButtonElement, text: string, options: CopyTextOptions = {}): Promise<boolean> {\n const label = button.textContent;\n const ok = await copyToClipboard(text);\n button.textContent = ok ? (options.copied ?? \"Copied\") : (options.failed ?? \"Copy failed\");\n window.setTimeout(() => {\n button.textContent = label;\n }, options.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ference lib=\"dom\" />\n/**\n * The small helpers of a page in the browser: the element helpers, the element lookup, the theme\n * button, the copy button and the build stamp. It also has a radio group with one focus stop.\n * This module imports no Node.js module, so a site can bundle it. Import it from\n * `@mark1russell7/site-pages/chrome`, because the package root also has Node.js code.\n */\n\n/** A child of `h`: a node or a text. The values `null`, `undefined` and `false` give no child. */\nexport type Child = Node | string | null | undefined | false;\n\n/** The value of an attribute of `h`. The value `true` gives an empty attribute. */\nexport type AttributeValue = string | number | boolean | null | undefined;\n\n/**\n * This function makes an element with attributes and children. An attribute with the value\n * `false`, `null` or `undefined` is not set. The attribute `class` sets the class name.\n */\nexport function h<K extends keyof HTMLElementTagNameMap>(\n tag: K,\n attrs: Readonly<Record<string, AttributeValue>> = {},\n ...children: readonly (Child | readonly Child[])[]\n): HTMLElementTagNameMap[K] {\n const el = document.createElement(tag);\n return fill(el, attrs, children, (value) => {\n el.className = value;\n });\n}\n\n/** The namespace of the SVG elements. */\nconst SVG_NS = \"http://www.w3.org/2000/svg\";\n\n/**\n * This function makes an SVG element with attributes and children, with the rules of `h`. The\n * attribute `class` sets the attribute `class`, because the class name of an SVG element is\n * read-only.\n */\nexport function svg<K extends keyof SVGElementTagNameMap>(\n tag: K,\n attrs: Readonly<Record<string, AttributeValue>> = {},\n ...children: readonly (Child | readonly Child[])[]\n): SVGElementTagNameMap[K] {\n const el = document.createElementNS(SVG_NS, tag);\n return fill(el, attrs, children, (value) => {\n el.setAttribute(\"class\", value);\n });\n}\n\n/** This function sets the attributes and adds the children of an element of `h` or `svg`. */\nfunction fill<E extends Element>(\n el: E,\n attrs: Readonly<Record<string, AttributeValue>>,\n children: readonly (Child | readonly Child[])[],\n setClass: (value: string) => void,\n): E {\n for (const [name, value] of Object.entries(attrs)) {\n if (value === false || value === null || value === undefined) continue;\n if (name === \"class\") setClass(String(value));\n else el.setAttribute(name, value === true ? \"\" : String(value));\n }\n for (const child of children.flat()) {\n if (child === null || child === undefined || child === false) continue;\n el.append(child);\n }\n return el;\n}\n\n/**\n * This function gives the element with the ID. The page has each ID that the code asks for. Thus\n * a missing ID is an error of the page, and the function throws an `Error`.\n */\nexport function byId<T extends HTMLElement = HTMLElement>(id: string): T {\n const el = document.getElementById(id);\n if (el === null) throw new Error(`The page has no element \"${id}\".`);\n return el as T;\n}\n\n/** The themes of the theme button, in the sequence of the clicks. `auto` follows the setting of the system. */\nexport const THEMES: readonly [\"auto\", \"light\", \"dark\"] = [\"auto\", \"light\", \"dark\"];\n\n/** A theme of the page. */\nexport type Theme = (typeof THEMES)[number];\n\n/**\n * This function gives the theme of the page from the attribute `data-theme` of the `html` element.\n * Without the attribute, or with another value, the theme is `auto`.\n */\nexport function currentTheme(): Theme {\n const theme = document.documentElement.dataset[\"theme\"];\n return theme === \"light\" || theme === \"dark\" ? theme : \"auto\";\n}\n\n/**\n * This function sets the theme of the page, and keeps it in `localStorage` under `storageKey`.\n * The theme `auto` removes the attribute `data-theme` and the stored value.\n */\nexport function applyTheme(theme: Theme, storageKey: string): void {\n const root = document.documentElement;\n if (theme === \"auto\") delete root.dataset[\"theme\"];\n else root.dataset[\"theme\"] = theme;\n try {\n if (theme === \"auto\") localStorage.removeItem(storageKey);\n else localStorage.setItem(storageKey, theme);\n } catch {\n // A browser with no storage keeps the theme until the page closes.\n }\n}\n\n/** This function sets the next theme after the current theme (auto, light, dark, auto), and gives it. */\nexport function nextTheme(storageKey: string): Theme {\n const next = THEMES[(THEMES.indexOf(currentTheme()) + 1) % THEMES.length] ?? \"auto\";\n applyTheme(next, storageKey);\n return next;\n}\n\n/**\n * This function makes a theme button. Each click sets the next theme. The text of the button is\n * \"Theme: auto\", \"Theme: light\" or \"Theme: dark\", and its `aria-label` tells the same theme.\n *\n * @remarks Before the first paint, a script in the `head` of the page reads `storageKey` from\n * `localStorage` and sets `data-theme`. Thus a dark page does not show white for a moment. The\n * plugin `siteShell` of the entry `./vite` adds that script.\n */\nexport function setupTheme(button: HTMLButtonElement, storageKey: string): void {\n const show = (theme: Theme): void => {\n button.textContent = `Theme: ${theme}`;\n button.setAttribute(\"aria-label\", `Color theme: ${theme}. Select to change.`);\n };\n show(currentTheme());\n button.addEventListener(\"click\", () => show(nextTheme(storageKey)));\n}\n\n/** The data of a build: `siteShell` writes it, and `showBuild` shows it. */\nexport interface BuildInfo {\n /** The first 7 characters of the commit, or `local` for a build outside CI. */\n readonly sha: string;\n /** The date of the build, as `YYYY-MM-DD`. */\n readonly date: string;\n /** The version of the package. A site without a version does not set it. */\n readonly version?: string | undefined;\n}\n\n/**\n * This function shows the version and the build of the site in an element. The text is \"Version\n * 1.2.3, build abc1234 of 2026-11-03\", and the commit is a link to GitHub. A build with no version\n * starts with \"Build\", and a local build has no link.\n *\n * @param repository - The repository as \"owner/name\".\n */\nexport function showBuild(element: HTMLElement, build: BuildInfo, repository: string): void {\n const commit = build.sha === \"local\" ? \"local\" : h(\"a\", { href: `https://github.com/${repository}/commit/${build.sha}` }, build.sha);\n element.append(build.version === undefined ? \"Build \" : `Version ${build.version}, build `, commit, ` of ${build.date}`);\n}\n\n/**\n * This function copies a text to the clipboard, and gives `true` when the copy is done. It uses\n * the Clipboard API. When that API is not available or refuses, it uses `document.execCommand`.\n */\nexport async function copyToClipboard(text: string): Promise<boolean> {\n try {\n await navigator.clipboard.writeText(text);\n return true;\n } catch {\n // An insecure page has no Clipboard API, and a browser can refuse the copy. The old command is the fallback.\n }\n try {\n const area = document.createElement(\"textarea\");\n area.value = text;\n area.setAttribute(\"readonly\", \"\");\n area.style.position = \"fixed\";\n area.style.opacity = \"0\";\n document.body.append(area);\n area.select();\n try {\n return document.execCommand(\"copy\");\n } finally {\n area.remove();\n }\n } catch {\n return false;\n }\n}\n\n/** The options of `copyText`. */\nexport interface CopyTextOptions {\n /** The text of the button after a copy. The default is \"Copied\". */\n readonly copied?: string;\n /** The text of the button after a failure. The default is \"Copy failed\". */\n readonly failed?: string;\n /** The time in milliseconds until the button shows its label again. The default is 1600. */\n readonly ms?: number;\n}\n\n/**\n * This function copies a text to the clipboard with `copyToClipboard`. The button tells the result\n * for a short time, then it shows its label again. The function gives the result of the copy.\n */\nexport async function copyText(button: HTMLButtonElement, text: string, options: CopyTextOptions = {}): Promise<boolean> {\n const label = button.textContent;\n const ok = await copyToClipboard(text);\n button.textContent = ok ? (options.copied ?? \"Copied\") : (options.failed ?? \"Copy failed\");\n window.setTimeout(() => {\n button.textContent = label;\n }, options.ms ?? 1600);\n return ok;\n}\n\n/** The arrow keys of a group: `horizontal` (Left and Right), `vertical` (Up and Down) or `both`. */\n/** The arrow keys of a group: left and right, up and down, or the four arrows. */\nexport type RovingAxis = \"horizontal\" | \"vertical\" | \"both\";\n\nconst ROVING_STEPS: Readonly<Record<RovingAxis, Readonly<Record<string, number>>>> = {\n horizontal: { ArrowRight: 1, ArrowLeft: -1 },\n vertical: { ArrowDown: 1, ArrowUp: -1 },\n both: { ArrowRight: 1, ArrowDown: 1, ArrowLeft: -1, ArrowUp: -1 },\n};\n\n/**\n * This function gives the index of the next item after an arrow key, in a group of `count` items. The index\n * wraps at each end. A key that is not an arrow of the axis gives `undefined`, and so does an empty group. An\n * index outside the group goes to the first item on a step forward, and to the last item on a step back.\n */\nexport function rovingIndex(key: string, index: number, count: number, axis: RovingAxis = \"both\"): number | undefined {\n const step = ROVING_STEPS[axis][key];\n if (step === undefined || count <= 0) return undefined;\n if (!Number.isInteger(index) || index < 0 || index >= count) return step > 0 ? 0 : count - 1;\n return (index + step + count) % count;\n}\n\n/** A choice of a `Segmented` control. */\nexport interface Choice<T extends string> {\n /** The value of the choice. */\n readonly value: T;\n /** The text of the button. */\n readonly label: string;\n /** The tooltip and the accessible name of the button. Without it, the button has neither. */\n readonly title?: string;\n}\n\n/**\n * A group of radio buttons with one focus stop. The selected button has `tabIndex` 0, and the others have -1.\n * The arrow keys select the next button, with a wrap at each end, and move the focus to it. The container keeps\n * its own role and label, for example `role=\"radiogroup\"` in the HTML.\n */\nexport class Segmented<T extends string> {\n private readonly buttons: readonly HTMLButtonElement[];\n private readonly choices: readonly Choice<T>[];\n private readonly onChange: (value: T) => void;\n private current: T;\n\n /**\n * This constructor puts one button for each choice into the container, in place of its children. The listener\n * gets each change by a click or a key, and no event for the choice that is already selected.\n */\n constructor(container: HTMLElement, choices: readonly Choice<T>[], current: T, onChange: (value: T) => void, axis: RovingAxis = \"both\") {\n this.choices = choices;\n this.current = current;\n this.onChange = onChange;\n this.buttons = choices.map((choice) => {\n const button = h(\n \"button\",\n { type: \"button\", role: \"radio\", \"data-value\": choice.value, title: choice.title, \"aria-label\": choice.title },\n choice.label,\n );\n button.addEventListener(\"click\", () => this.choose(choice.value, false));\n return button;\n });\n container.replaceChildren(...this.buttons);\n container.addEventListener(\"keydown\", (event) => {\n const index = this.choices.findIndex((c) => c.value === this.current);\n const next = rovingIndex(event.key, index, this.choices.length, axis);\n if (next === undefined) return;\n event.preventDefault();\n this.choose(this.choices[next]!.value, true);\n });\n this.show();\n }\n\n /** The value of the control. */\n get value(): T {\n return this.current;\n }\n\n /** This function sets the value. The listener gets no event. */\n set(value: T): void {\n this.current = value;\n this.show();\n }\n\n private choose(value: T, focus: boolean): void {\n const changed = value !== this.current;\n this.set(value);\n if (focus) this.buttons[this.choices.findIndex((c) => c.value === value)]?.focus();\n if (changed) this.onChange(value);\n }\n\n private show(): void {\n this.choices.forEach((choice, i) => {\n const button = this.buttons[i]!;\n const on = choice.value === this.current;\n button.setAttribute(\"aria-checked\", String(on));\n button.tabIndex = on ? 0 : -1;\n });\n }\n}\n"],"mappings":";;;;;AAkBA,SAAgB,EACd,KACA,QAAkD,CAAC,GACnD,GAAG,UACuB;CAC1B,MAAM,KAAK,SAAS,cAAc,GAAG;CACrC,OAAO,KAAK,IAAI,OAAO,WAAW,UAAU;EAC1C,GAAG,YAAY;CACjB,CAAC;AACH;;AAGA,MAAM,SAAS;;;;;;AAOf,SAAgB,IACd,KACA,QAAkD,CAAC,GACnD,GAAG,UACsB;CACzB,MAAM,KAAK,SAAS,gBAAgB,QAAQ,GAAG;CAC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utError, parseResponseRecord, quantile, responseCells, sliceResponse, surfaceResponse, whenHolds } from "@mark1russell7/rigor-statistics";
|
|
3
3
|
// src/explorer/model.ts
|
|
4
4
|
/**
|
|
@@ -705,7 +705,6 @@ function numberTable(view, panel) {
|
|
|
705
705
|
* The DOM view of the response explorer. This module draws SVG with no framework. The core in `model.ts` gives each
|
|
706
706
|
* rule and each number, and this module connects the core to the page.
|
|
707
707
|
*/
|
|
708
|
-
const SVG = "http://www.w3.org/2000/svg";
|
|
709
708
|
/** The most faults that the view lists. */
|
|
710
709
|
const MAX_FAULTS = 20;
|
|
711
710
|
/** The width of a chart with no layout, for example in a test. */
|
|
@@ -719,13 +718,6 @@ const MARGIN = {
|
|
|
719
718
|
/** The height of a line of text of an axis, in pixels. */
|
|
720
719
|
const CHAR_WIDTH = 6.4;
|
|
721
720
|
let mounts = 0;
|
|
722
|
-
/** This function makes an SVG element with attributes and children. */
|
|
723
|
-
function s(tag, attrs, ...children) {
|
|
724
|
-
const el = document.createElementNS(SVG, tag);
|
|
725
|
-
for (const [name, value] of Object.entries(attrs)) el.setAttribute(name, String(value));
|
|
726
|
-
el.append(...children);
|
|
727
|
-
return el;
|
|
728
|
-
}
|
|
729
721
|
/** This function gives the plot of a chart. Long level names need room for their turned text. */
|
|
730
722
|
function plotOf(width, height, view) {
|
|
731
723
|
const turned = turnedLevels(view.x, width - MARGIN.left - MARGIN.right);
|
|
@@ -755,19 +747,19 @@ function xAxis(plot, axis) {
|
|
|
755
747
|
const turned = turnedLevels(axis, length);
|
|
756
748
|
const ticks = fittedTicks(axis, length).map((tick) => {
|
|
757
749
|
const x = plot.left + tick.place * length;
|
|
758
|
-
const label = turned ?
|
|
750
|
+
const label = turned ? svg("text", {
|
|
759
751
|
class: "rx-tick",
|
|
760
752
|
x,
|
|
761
753
|
y: plot.bottom + 14,
|
|
762
754
|
"text-anchor": "end",
|
|
763
755
|
transform: `rotate(-35 ${x} ${plot.bottom + 14})`
|
|
764
|
-
}, tick.text) :
|
|
756
|
+
}, tick.text) : svg("text", {
|
|
765
757
|
class: "rx-tick",
|
|
766
758
|
x,
|
|
767
759
|
y: plot.bottom + 15,
|
|
768
760
|
"text-anchor": x + tick.text.length * CHAR_WIDTH / 2 > plot.width ? "end" : "middle"
|
|
769
761
|
}, tick.text);
|
|
770
|
-
return
|
|
762
|
+
return svg("g", {}, svg("line", {
|
|
771
763
|
class: "rx-axis",
|
|
772
764
|
x1: x,
|
|
773
765
|
x2: x,
|
|
@@ -775,13 +767,13 @@ function xAxis(plot, axis) {
|
|
|
775
767
|
y2: plot.bottom + 4
|
|
776
768
|
}), label);
|
|
777
769
|
});
|
|
778
|
-
const name =
|
|
770
|
+
const name = svg("text", {
|
|
779
771
|
class: "rx-axis-name",
|
|
780
772
|
x: (plot.left + plot.right) / 2,
|
|
781
773
|
y: plot.height - 6,
|
|
782
774
|
"text-anchor": "middle"
|
|
783
775
|
}, axis.log ? `${axis.label}, log scale` : axis.label);
|
|
784
|
-
return
|
|
776
|
+
return svg("g", {}, svg("line", {
|
|
785
777
|
class: "rx-axis",
|
|
786
778
|
x1: plot.left,
|
|
787
779
|
x2: plot.right,
|
|
@@ -792,34 +784,36 @@ function xAxis(plot, axis) {
|
|
|
792
784
|
/** This function draws the value axis with its grid lines. */
|
|
793
785
|
function valueAxis(plot, ticks) {
|
|
794
786
|
const length = plot.bottom - plot.top;
|
|
795
|
-
|
|
787
|
+
const lines = ticks.map((tick) => {
|
|
796
788
|
const y = plot.bottom - tick.place * length;
|
|
797
|
-
return
|
|
789
|
+
return svg("g", {}, svg("line", {
|
|
798
790
|
class: "rx-grid",
|
|
799
791
|
x1: plot.left,
|
|
800
792
|
x2: plot.right,
|
|
801
793
|
y1: y,
|
|
802
794
|
y2: y
|
|
803
|
-
}),
|
|
795
|
+
}), svg("text", {
|
|
804
796
|
class: "rx-tick",
|
|
805
797
|
x: plot.left - 6,
|
|
806
798
|
y: y + 4,
|
|
807
799
|
"text-anchor": "end"
|
|
808
800
|
}, tick.text));
|
|
809
|
-
})
|
|
801
|
+
});
|
|
802
|
+
return svg("g", {}, ...lines);
|
|
810
803
|
}
|
|
811
804
|
/** This function draws the vertical axis of a surface. */
|
|
812
805
|
function surfaceAxis(plot, axis) {
|
|
813
806
|
const length = plot.bottom - plot.top;
|
|
814
|
-
|
|
807
|
+
const ticks = axisTicks(axis, Math.max(2, Math.floor(length / 45))).map((tick) => {
|
|
815
808
|
const y = plot.bottom - tick.place * length;
|
|
816
|
-
return
|
|
809
|
+
return svg("text", {
|
|
817
810
|
class: "rx-tick",
|
|
818
811
|
x: plot.left - 6,
|
|
819
812
|
y: y + 4,
|
|
820
813
|
"text-anchor": "end"
|
|
821
814
|
}, tick.text);
|
|
822
|
-
})
|
|
815
|
+
});
|
|
816
|
+
return svg("g", {}, ...ticks);
|
|
823
817
|
}
|
|
824
818
|
/** This function gives the place of a value on the value axis, from 0 to 1. */
|
|
825
819
|
function valuePlace(scale, value) {
|
|
@@ -861,7 +855,7 @@ function connect(svg, cursor, tell) {
|
|
|
861
855
|
}
|
|
862
856
|
/** This function makes the frame of a chart with its text for a screen reader. */
|
|
863
857
|
function chartFrame(plot, label) {
|
|
864
|
-
return
|
|
858
|
+
return svg("svg", {
|
|
865
859
|
class: "rx-svg",
|
|
866
860
|
width: plot.width,
|
|
867
861
|
height: plot.height,
|
|
@@ -878,12 +872,12 @@ function fadedBand(plot, panel, scale, axis, id) {
|
|
|
878
872
|
const curve = panel.slice.curve;
|
|
879
873
|
const px = (at) => plot.left + placeOn(axis, at) * length;
|
|
880
874
|
const py = (value) => plot.bottom - valuePlace(scale, value) * height;
|
|
881
|
-
const stops = curve.map((place) =>
|
|
875
|
+
const stops = curve.map((place) => svg("stop", {
|
|
882
876
|
class: "rx-band-stop",
|
|
883
877
|
offset: placeOn(axis, place.at),
|
|
884
878
|
"stop-opacity": fadeOf(place.nearest).toFixed(3)
|
|
885
879
|
}));
|
|
886
|
-
const gradient =
|
|
880
|
+
const gradient = svg("linearGradient", {
|
|
887
881
|
id,
|
|
888
882
|
gradientUnits: "userSpaceOnUse",
|
|
889
883
|
x1: plot.left,
|
|
@@ -893,7 +887,7 @@ function fadedBand(plot, panel, scale, axis, id) {
|
|
|
893
887
|
}, ...stops);
|
|
894
888
|
const upper = curve.map((place) => [px(place.at), py(place.high)]);
|
|
895
889
|
const lower = curve.map((place) => [px(place.at), py(place.low)]);
|
|
896
|
-
return [
|
|
890
|
+
return [svg("defs", {}, gradient), svg("path", {
|
|
897
891
|
class: "rx-band",
|
|
898
892
|
d: bandPath(upper, lower),
|
|
899
893
|
fill: `url(#${id})`
|
|
@@ -909,7 +903,7 @@ function levelMarks(plot, panel, scale, axis) {
|
|
|
909
903
|
const top = plot.bottom - valuePlace(scale, place.high) * height;
|
|
910
904
|
const bottom = plot.bottom - valuePlace(scale, place.low) * height;
|
|
911
905
|
const y = plot.bottom - valuePlace(scale, place.value) * height;
|
|
912
|
-
return [
|
|
906
|
+
return [svg("rect", {
|
|
913
907
|
class: "rx-whisker",
|
|
914
908
|
x: x - room / 2,
|
|
915
909
|
y: top,
|
|
@@ -917,7 +911,7 @@ function levelMarks(plot, panel, scale, axis) {
|
|
|
917
911
|
height: Math.max(1, bottom - top),
|
|
918
912
|
rx: 4,
|
|
919
913
|
"fill-opacity": (.3 * fadeOf(place.nearest)).toFixed(3)
|
|
920
|
-
}),
|
|
914
|
+
}), svg("line", {
|
|
921
915
|
class: "rx-line",
|
|
922
916
|
x1: x - room / 2,
|
|
923
917
|
x2: x + room / 2,
|
|
@@ -939,19 +933,19 @@ function curveChart(view, panel, width, id, tell) {
|
|
|
939
933
|
const px = (at) => plot.left + placeOn(view.x, at) * length;
|
|
940
934
|
const py = (value) => plot.bottom - valuePlace(scale, value) * height;
|
|
941
935
|
const smooth = view.x.kind === "number";
|
|
942
|
-
const marks = smooth ? [...fadedBand(plot, panel, scale, view.x, id),
|
|
936
|
+
const marks = smooth ? [...fadedBand(plot, panel, scale, view.x, id), svg("path", {
|
|
943
937
|
class: "rx-line",
|
|
944
938
|
d: linePath(curve.map((place) => [px(place.at), py(place.value)]))
|
|
945
939
|
})] : levelMarks(plot, panel, scale, view.x);
|
|
946
940
|
const room = smooth ? 0 : Math.min(30, length / Math.max(1, view.x.levels.length) * .35);
|
|
947
|
-
const dots = panel.slice.points.map((point) =>
|
|
941
|
+
const dots = panel.slice.points.map((point) => svg("circle", {
|
|
948
942
|
class: "rx-dot",
|
|
949
943
|
cx: px(point.at) + jitter(point.id, room),
|
|
950
944
|
cy: py(point.value),
|
|
951
945
|
r: 3.5
|
|
952
946
|
}));
|
|
953
947
|
const ticks = numberTicks(scale.range[0], scale.range[1], scale.log, Math.max(2, Math.floor(height / 50)));
|
|
954
|
-
const rule =
|
|
948
|
+
const rule = svg("line", {
|
|
955
949
|
class: "rx-cursor",
|
|
956
950
|
x1: 0,
|
|
957
951
|
x2: 0,
|
|
@@ -959,16 +953,16 @@ function curveChart(view, panel, width, id, tell) {
|
|
|
959
953
|
y2: plot.bottom,
|
|
960
954
|
visibility: "hidden"
|
|
961
955
|
});
|
|
962
|
-
const ring =
|
|
956
|
+
const ring = svg("circle", {
|
|
963
957
|
class: "rx-ring",
|
|
964
958
|
cx: 0,
|
|
965
959
|
cy: 0,
|
|
966
960
|
r: 5,
|
|
967
961
|
visibility: "hidden"
|
|
968
962
|
});
|
|
969
|
-
const svg = chartFrame(plot, `${panel.title} ${view.measure.label} over ${view.x.label}.`.trim());
|
|
970
|
-
svg.append(valueAxis(plot, ticks), ...marks, ...dots, xAxis(plot, view.x), rule, ring);
|
|
971
|
-
connect(svg, {
|
|
963
|
+
const svg$1 = chartFrame(plot, `${panel.title} ${view.measure.label} over ${view.x.label}.`.trim());
|
|
964
|
+
svg$1.append(valueAxis(plot, ticks), ...marks, ...dots, xAxis(plot, view.x), rule, ring);
|
|
965
|
+
connect(svg$1, {
|
|
972
966
|
columns: curve.length,
|
|
973
967
|
rows: 1,
|
|
974
968
|
at: (x) => {
|
|
@@ -986,7 +980,7 @@ function curveChart(view, panel, width, id, tell) {
|
|
|
986
980
|
return curveText(view.x, place);
|
|
987
981
|
}
|
|
988
982
|
}, tell);
|
|
989
|
-
return svg;
|
|
983
|
+
return svg$1;
|
|
990
984
|
}
|
|
991
985
|
/** This function draws a chart of a surface, or the separate cells of a table. */
|
|
992
986
|
function surfaceChart(view, panel, width, tell) {
|
|
@@ -1011,17 +1005,17 @@ function surfaceChart(view, panel, width, tell) {
|
|
|
1011
1005
|
height: Math.max(.5, lower - upper - gap + (gap === 0 ? .6 : 0))
|
|
1012
1006
|
};
|
|
1013
1007
|
const step = heatStep(band.value, range, view.log);
|
|
1014
|
-
const parts = [
|
|
1008
|
+
const parts = [svg("rect", {
|
|
1015
1009
|
...box,
|
|
1016
1010
|
class: `rx-h${step}`
|
|
1017
1011
|
})];
|
|
1018
1012
|
const veil = veilOf(band.nearest);
|
|
1019
|
-
if (veil > .02) parts.push(
|
|
1013
|
+
if (veil > .02) parts.push(svg("rect", {
|
|
1020
1014
|
...box,
|
|
1021
1015
|
class: "rx-veil",
|
|
1022
1016
|
"fill-opacity": veil.toFixed(3)
|
|
1023
1017
|
}));
|
|
1024
|
-
if (panel.cells && box.width > 34 && box.height > 18) parts.push(
|
|
1018
|
+
if (panel.cells && box.width > 34 && box.height > 18) parts.push(svg("text", {
|
|
1025
1019
|
class: `rx-cell-text ${step > 9 / 2 ? "rx-on-dark" : "rx-on-light"}`,
|
|
1026
1020
|
x: box.x + box.width / 2,
|
|
1027
1021
|
y: box.y + box.height / 2 + 4,
|
|
@@ -1029,13 +1023,13 @@ function surfaceChart(view, panel, width, tell) {
|
|
|
1029
1023
|
}, formatValue(band.value)));
|
|
1030
1024
|
return parts;
|
|
1031
1025
|
}));
|
|
1032
|
-
const dots = panel.surface.points.map((point) =>
|
|
1026
|
+
const dots = panel.surface.points.map((point) => svg("circle", {
|
|
1033
1027
|
class: "rx-dot rx-dot-heat",
|
|
1034
1028
|
cx: plot.left + placeOn(view.x, point.at[0]) * length + jitter(point.id, 6),
|
|
1035
1029
|
cy: plot.bottom - placeOn(axisY, point.at[1]) * height + jitter(`${point.id}y`, 6),
|
|
1036
1030
|
r: 2.5
|
|
1037
1031
|
}));
|
|
1038
|
-
const outline =
|
|
1032
|
+
const outline = svg("rect", {
|
|
1039
1033
|
class: "rx-cell-cursor",
|
|
1040
1034
|
x: 0,
|
|
1041
1035
|
y: 0,
|
|
@@ -1043,13 +1037,13 @@ function surfaceChart(view, panel, width, tell) {
|
|
|
1043
1037
|
height: 0,
|
|
1044
1038
|
visibility: "hidden"
|
|
1045
1039
|
});
|
|
1046
|
-
const svg = chartFrame(plot, `${panel.title} ${view.measure.label} over ${view.x.label} and ${axisY.label}.`.trim());
|
|
1047
|
-
svg.append(...cellMarks, ...dots, surfaceAxis(plot, axisY), xAxis(plot, view.x), outline);
|
|
1040
|
+
const svg$2 = chartFrame(plot, `${panel.title} ${view.measure.label} over ${view.x.label} and ${axisY.label}.`.trim());
|
|
1041
|
+
svg$2.append(...cellMarks, ...dots, surfaceAxis(plot, axisY), xAxis(plot, view.x), outline);
|
|
1048
1042
|
const find = (edges, share) => {
|
|
1049
1043
|
const index = edges.findIndex((edge) => edge > share);
|
|
1050
1044
|
return Math.max(0, (index < 0 ? edges.length : index) - 1);
|
|
1051
1045
|
};
|
|
1052
|
-
connect(svg, {
|
|
1046
|
+
connect(svg$2, {
|
|
1053
1047
|
columns: x.length,
|
|
1054
1048
|
rows: y.length,
|
|
1055
1049
|
at: (px, py) => [find(xEdges, (px - plot.left) / length), y.length - 1 - find(yEdges, (plot.bottom - py) / height)],
|
|
@@ -1063,40 +1057,40 @@ function surfaceChart(view, panel, width, tell) {
|
|
|
1063
1057
|
return cellText(view.x, axisY, x[column], y[j], cells[j]?.[column]);
|
|
1064
1058
|
}
|
|
1065
1059
|
}, tell);
|
|
1066
|
-
return svg;
|
|
1060
|
+
return svg$2;
|
|
1067
1061
|
}
|
|
1068
1062
|
/** This function draws the measured points of a measure with no model. */
|
|
1069
1063
|
function pointsChart(view, panel, width) {
|
|
1070
1064
|
const plot = plotOf(width, 270, view);
|
|
1071
1065
|
const length = plot.right - plot.left;
|
|
1072
1066
|
const height = plot.bottom - plot.top;
|
|
1073
|
-
const svg = chartFrame(plot, `${panel.title} ${view.measure.label}: ${panel.points.length} measured points.`.trim());
|
|
1067
|
+
const svg$3 = chartFrame(plot, `${panel.title} ${view.measure.label}: ${panel.points.length} measured points.`.trim());
|
|
1074
1068
|
if (view.y === null) {
|
|
1075
1069
|
const scale = {
|
|
1076
1070
|
range: valueRange(view),
|
|
1077
1071
|
log: view.log
|
|
1078
1072
|
};
|
|
1079
1073
|
const room = view.x.kind === "levels" ? Math.min(30, length / Math.max(1, view.x.levels.length) * .35) : 0;
|
|
1080
|
-
const dots = panel.points.map((point) =>
|
|
1074
|
+
const dots = panel.points.map((point) => svg("circle", {
|
|
1081
1075
|
class: "rx-dot",
|
|
1082
1076
|
cx: plot.left + placeOn(view.x, point.at[0]) * length + jitter(point.id, room),
|
|
1083
1077
|
cy: plot.bottom - valuePlace(scale, point.value) * height,
|
|
1084
1078
|
r: 3.5
|
|
1085
1079
|
}));
|
|
1086
1080
|
const ticks = numberTicks(scale.range[0], scale.range[1], scale.log, Math.max(2, Math.floor(height / 50)));
|
|
1087
|
-
svg.append(valueAxis(plot, ticks), ...dots, xAxis(plot, view.x));
|
|
1088
|
-
return svg;
|
|
1081
|
+
svg$3.append(valueAxis(plot, ticks), ...dots, xAxis(plot, view.x));
|
|
1082
|
+
return svg$3;
|
|
1089
1083
|
}
|
|
1090
1084
|
const axisY = view.y;
|
|
1091
1085
|
const range = heatRange(view);
|
|
1092
|
-
const dots = panel.points.map((point) =>
|
|
1086
|
+
const dots = panel.points.map((point) => svg("circle", {
|
|
1093
1087
|
class: `rx-h${heatStep(point.value, range, view.log)} rx-ring-dot`,
|
|
1094
1088
|
cx: plot.left + placeOn(view.x, point.at[0]) * length + jitter(point.id, 8),
|
|
1095
1089
|
cy: plot.bottom - placeOn(axisY, point.at[1]) * height + jitter(`${point.id}y`, 8),
|
|
1096
1090
|
r: 5
|
|
1097
1091
|
}));
|
|
1098
|
-
svg.append(...dots, surfaceAxis(plot, axisY), xAxis(plot, view.x));
|
|
1099
|
-
return svg;
|
|
1092
|
+
svg$3.append(...dots, surfaceAxis(plot, axisY), xAxis(plot, view.x));
|
|
1093
|
+
return svg$3;
|
|
1100
1094
|
}
|
|
1101
1095
|
/** This function gives the number of measured points of a panel. */
|
|
1102
1096
|
function pointCount(panel) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/explorer/model.ts","../../src/explorer/view.ts"],"sourcesContent":["/**\n * The pure core of the response explorer: the state, the rules of the controls and the data of a view. This module\n * reads a record of the format `response-records/1` only with `@mark1russell7/rigor-statistics`. It has no DOM and no\n * clock of its own, so a test gives it each input.\n *\n * The rules of the controls follow the rules of a conditional dimension. The functions `axisChoices`, `facetChoices`\n * and `holdControls` offer only combinations that `sliceResponse` and `surfaceResponse` accept. The function `settle`\n * gives the nearest good state for any wanted state.\n */\n\nimport {\n heldOutError,\n parseResponseRecord,\n quantile,\n responseCells,\n sliceResponse,\n surfaceResponse,\n whenHolds,\n type ParsedResponseRecord,\n type ResponseBand,\n type ResponseCurvePoint,\n type ResponseDimension,\n type ResponseHeldOutError,\n type ResponseInputValue,\n type ResponseMeasure,\n type ResponseModel,\n type ResponsePoint,\n type ResponseRecord,\n type ResponseSlice,\n type ResponseSurface,\n type ResponseValue,\n} from \"@mark1russell7/rigor-statistics\";\n\n/** The largest number of values on a continuous axis. It is the default of `ResponseViewOptions.steps`. */\nexport const MAX_STEPS = 33;\n/** The smallest number of values on a continuous axis. A smaller grid shows too little of the response. */\nexport const MIN_STEPS = 5;\n/**\n * The largest number of point reads of one view. The field `nearest` of each place reads each point, so the cost of a\n * view is its number of places times the number of points. This number is a first bound, not a measured time.\n * `SURFACE_BUDGET_MS` corrects the grid when a surface takes too long on the device.\n */\nexport const READ_BUDGET = 400_000;\n/** The time of one surface in milliseconds. A longer surface gives a smaller grid for the next surface. */\nexport const SURFACE_BUDGET_MS = 50;\n/** The largest number of panels of one view. */\nexport const MAX_PANELS = 8;\n/** The largest number of stops of a held continuous dimension. */\nexport const MAX_STOPS = 33;\n/** The most levels that a row of buttons shows. A longer group is a select, so it does not push the chart down the page. */\nexport const MAX_CHIPS = 8;\n/** The distance from a measurement, from 0 to 1, at which a band has its weakest color. */\nexport const FADE_END = 0.5;\n/** The number of steps of the color scale of a surface. The CSS classes `rx-h0` to `rx-h8` give the colors. */\nexport const HEAT_STEPS = 9;\n\n/** The choices of a visitor. */\nexport interface ExplorerState {\n /** The id of the measure. */\n readonly measure: string;\n /** The id of the dimension of the horizontal axis. */\n readonly x: string;\n /** The id of the dimension of the vertical axis of a surface. The value `null` gives a curve. */\n readonly y: string | null;\n /** The id of the dimension with one panel for each of its values. The value `null` gives one panel. */\n readonly facet: string | null;\n /** The held value of each dimension. A dimension on an axis keeps its value for a later view. */\n readonly hold: Readonly<Record<string, ResponseValue>>;\n}\n\n/** The two axes of a view. */\nexport type AxisSlot = \"x\" | \"y\";\n\n/** A dimension that a control offers. */\nexport interface DimensionChoice {\n readonly id: string;\n readonly label: string;\n readonly disabled: boolean;\n /** The reason of a disabled choice. A good choice has an empty string. */\n readonly reason: string;\n}\n\n/** A value that a hold control offers. */\nexport interface HoldOption {\n readonly value: ResponseValue;\n readonly text: string;\n readonly disabled: boolean;\n readonly reason: string;\n}\n\n/** The control of one held dimension. */\nexport interface HoldControl {\n readonly id: string;\n readonly label: string;\n /** The value `levels` gives one button for each level. The value `stops` gives a slider over the measured values. */\n readonly kind: \"levels\" | \"stops\";\n /** The value `false` means that the dimension has no value at the held level of its parent. */\n readonly applies: boolean;\n /** The condition of the dimension, as text. A dimension with no condition has an empty string. */\n readonly note: string;\n readonly options: readonly HoldOption[];\n readonly value: ResponseValue;\n}\n\n/** One axis of a chart. A number axis has a linear or log place. A level axis has one equal band for each level. */\nexport interface AxisSpec {\n readonly id: string;\n readonly label: string;\n readonly kind: \"number\" | \"levels\";\n readonly log: boolean;\n /** The two ends of a number axis. */\n readonly range: readonly [number, number];\n /** The levels of a level axis. */\n readonly levels: readonly ResponseValue[];\n}\n\n/** The fields of each kind of panel. */\ninterface PanelBase {\n /** The name of the panel in a view with panels. The only panel of a view has an empty string. */\n readonly title: string;\n /** The value of the facet dimension in this panel. */\n readonly level: ResponseValue | null;\n}\n\n/** A fitted curve with its band and the measured points. */\nexport interface CurvePanel extends PanelBase {\n readonly kind: \"curve\";\n readonly slice: ResponseSlice;\n}\n\n/** A fitted surface. With `cells`, the view shows separate cells with their values, not a smooth surface. */\nexport interface SurfacePanel extends PanelBase {\n readonly kind: \"surface\";\n readonly cells: boolean;\n readonly surface: ResponseSurface;\n}\n\n/** A measured point of a panel with no model. */\nexport interface PlainPoint {\n readonly id: string;\n /** The value of each varied dimension. */\n readonly at: readonly ResponseValue[];\n readonly value: number;\n}\n\n/** The measured points of a measure with no model. */\nexport interface PointsPanel extends PanelBase {\n readonly kind: \"points\";\n readonly points: readonly PlainPoint[];\n}\n\n/** One panel of a view. */\nexport type ExplorerPanel = CurvePanel | SurfacePanel | PointsPanel;\n\n/** The data of one view. */\nexport interface ExplorerView {\n readonly measure: ResponseMeasure;\n readonly x: AxisSpec;\n readonly y: AxisSpec | null;\n readonly panels: readonly ExplorerPanel[];\n /** The value `true` gives a log value axis. */\n readonly log: boolean;\n /** The held-out error. A measure with no model has none. */\n readonly error: ResponseHeldOutError | null;\n /** The held-out error in plain words. */\n readonly errorText: string;\n /** The kind of the model in plain words. */\n readonly modelText: string;\n /** The size of the grid of a surface in plain words. A curve has an empty string. */\n readonly gridText: string;\n /** The places that the range of the measure moved, in plain words. With no such place, this is an empty string. */\n readonly rangeText: string;\n /** The text of a request that the record refused. A good view has an empty string. */\n readonly problem: string;\n /** The number of values on a continuous axis of this view. */\n readonly steps: number;\n /** The time of this view in milliseconds. */\n readonly elapsedMs: number;\n /** The largest number of steps of the next view. */\n readonly nextCap: number;\n}\n\n/** The inputs of `viewOf`. */\nexport interface ViewOptions {\n /** The largest number of steps. The value of `nextCap` of the last view goes here. */\n readonly stepsCap?: number;\n /** The time of a surface in milliseconds. The default is `SURFACE_BUDGET_MS`. */\n readonly budgetMs?: number;\n /** The clock in milliseconds. The default gives 0, so a view with no clock does not drop its grid. */\n readonly now?: () => number;\n}\n\n/** A rectangle of a table of numbers. */\nexport interface NumberTable {\n readonly columns: readonly string[];\n readonly rows: readonly (readonly string[])[];\n}\n\n/** One tick of an axis. */\nexport interface Tick {\n /** The place on the axis, from 0 to 1. */\n readonly place: number;\n readonly text: string;\n}\n\n/**\n * This function reads a record from JSON text or from parsed data. It does not throw: bad data gives faults with\n * their paths.\n */\nexport function openRecord(value: unknown): ParsedResponseRecord {\n if (typeof value !== \"string\") return parseResponseRecord(value);\n try {\n return parseResponseRecord(JSON.parse(value));\n } catch (error) {\n return { ok: false, faults: [{ path: \"\", message: `this text is not JSON: ${String(error)}.` }] };\n }\n}\n\nconst numberText = new Intl.NumberFormat(\"en-US\", { maximumSignificantDigits: 3 });\n\n/** This function gives the text of a value: a number with three significant digits, or the text of a level. */\nexport function formatValue(value: ResponseInputValue): string {\n if (value === null) return \"none\";\n return typeof value === \"number\" ? numberText.format(value) : value;\n}\n\n/** This function gives the dimension with an id that the state or the record names. */\nfunction dimensionOf(record: ResponseRecord, id: string): ResponseDimension {\n const dimension = record.dimensions.find((d) => d.id === id);\n if (dimension === undefined) throw new RangeError(`The record has no dimension \"${id}\".`);\n return dimension;\n}\n\n/** This function gives the measured values of a dimension, with no `null`. */\nfunction measuredValues(record: ResponseRecord, id: string): ResponseValue[] {\n return record.points.flatMap((p) => {\n const value = p.values[id];\n return value === null || value === undefined ? [] : [value];\n });\n}\n\nconst stopCache = new WeakMap<ResponseRecord, Map<string, readonly ResponseValue[]>>();\n\n/** This function gives the distinct measured values of a continuous dimension, in order. */\nfunction distinctNumbers(record: ResponseRecord, id: string): number[] {\n const numbers = measuredValues(record, id).filter((v) => typeof v === \"number\");\n return [...new Set(numbers)].sort((a, b) => a - b);\n}\n\n/**\n * This function gives the values that a visitor can hold: each level, or the measured values of a continuous dimension.\n * With more than `MAX_STOPS` measured values, it gives that number of quantiles of them.\n */\nexport function stopsOf(record: ResponseRecord, dimension: ResponseDimension): readonly ResponseValue[] {\n if (dimension.kind !== \"continuous\") return dimension.levels;\n let stops = stopCache.get(record);\n if (stops === undefined) stopCache.set(record, (stops = new Map()));\n const known = stops.get(dimension.id);\n if (known !== undefined) return known;\n const distinct = distinctNumbers(record, dimension.id);\n const thin = (): number[] => [...new Set(Array.from({ length: MAX_STOPS }, (_, i) => quantile(distinct, i / (MAX_STOPS - 1), \"nearest-rank\")))];\n const found = distinct.length === 0 ? [dimension.range[0]] : distinct.length > MAX_STOPS ? thin() : distinct;\n stops.set(dimension.id, found);\n return found;\n}\n\n/** This function gives the place of a number on a continuous dimension, from 0 to 1. */\nfunction shareOf(dimension: ResponseDimension & { kind: \"continuous\" }, value: number): number {\n const scale = (v: number): number => (dimension.log === true ? Math.log10(v) : v);\n const [low, high] = dimension.range;\n return (scale(value) - scale(low)) / (scale(high) - scale(low));\n}\n\n/**\n * This function gives the option `tolerance` of a view. A dimension with all its measured values as stops needs none.\n * A thinned dimension needs half of its largest gap, so each measured point matches a stop.\n */\nexport function toleranceOf(record: ResponseRecord): number {\n let tolerance = 0;\n for (const dimension of record.dimensions) {\n if (dimension.kind !== \"continuous\") continue;\n const stops = stopsOf(record, dimension) as readonly number[];\n if (stops.length === distinctNumbers(record, dimension.id).length) continue;\n for (let i = 1; i < stops.length; i++) {\n const gap = shareOf(dimension, stops[i] as number) - shareOf(dimension, stops[i - 1] as number);\n tolerance = Math.max(tolerance, gap / 2);\n }\n }\n return tolerance;\n}\n\n/** This function gives the usual value of a dimension: the measured median, or the most common level in `among`. */\nfunction usualValue(record: ResponseRecord, dimension: ResponseDimension, among?: readonly ResponseValue[]): ResponseValue {\n const values = measuredValues(record, dimension.id);\n if (dimension.kind === \"continuous\") {\n const numbers = values.filter((v) => typeof v === \"number\");\n return numbers.length === 0 ? dimension.range[0] : quantile(numbers, 0.5, \"nearest-rank\");\n }\n const levels: readonly ResponseValue[] = among ?? dimension.levels;\n const count = (level: ResponseValue): number => values.filter((v) => v === level).length;\n return levels.reduce((best, level) => (count(level) > count(best) ? level : best), levels[0] as ResponseValue);\n}\n\n/** This function gives the stop of a dimension that is nearest to a value, or `undefined` for a value of no use. */\nfunction nearestStop(record: ResponseRecord, dimension: ResponseDimension, value: ResponseValue | undefined): ResponseValue | undefined {\n const stops = stopsOf(record, dimension);\n if (value === undefined) return undefined;\n if (dimension.kind !== \"continuous\") return stops.includes(value) ? value : undefined;\n if (typeof value !== \"number\") return undefined;\n const far = (stop: ResponseValue): number => Math.abs(shareOf(dimension, stop as number) - shareOf(dimension, value));\n return stops.reduce((best, stop) => (far(stop) < far(best) ? stop : best));\n}\n\n/** This function gives the levels that the parent of each varied conditional dimension needs. */\nfunction neededLevels(record: ResponseRecord, varied: readonly string[]): Map<string, readonly ResponseValue[]> {\n const needed = new Map<string, readonly ResponseValue[]>();\n for (const id of varied) {\n const when = dimensionOf(record, id).when;\n if (when === undefined) continue;\n const earlier = needed.get(when.dimension);\n needed.set(when.dimension, earlier === undefined ? when.levels : earlier.filter((level) => when.levels.includes(level)));\n }\n return needed;\n}\n\n/** This function gives the condition of a dimension as a phrase of a sentence. */\nfunction whenText(record: ResponseRecord, dimension: ResponseDimension): string {\n const when = dimension.when;\n if (when === undefined) return \"\";\n return `only when ${dimensionOf(record, when.dimension).label} is ${when.levels.map(formatValue).join(\" or \")}`;\n}\n\nconst variedOf = (state: Pick<ExplorerState, \"x\" | \"y\">): string[] => (state.y === null ? [state.x] : [state.x, state.y]);\n\n/** This function gives the values of a dimension in panels, inside the needs of the varied dimensions. */\nfunction panelLevels(record: ResponseRecord, state: Pick<ExplorerState, \"x\" | \"y\">, id: string): readonly ResponseValue[] {\n const stops = stopsOf(record, dimensionOf(record, id));\n const needed = neededLevels(record, variedOf(state)).get(id);\n return needed === undefined ? stops : stops.filter((value) => needed.includes(value));\n}\n\n/** This function gives the reason that a dimension cannot be in panels. A good dimension gives an empty string. */\nfunction facetBlock(record: ResponseRecord, state: Pick<ExplorerState, \"x\" | \"y\" | \"hold\">, dimension: ResponseDimension): string {\n if (variedOf(state).includes(dimension.id)) return \"It is on an axis\";\n const when = dimension.when;\n if (when !== undefined && !variedOf(state).includes(when.dimension) && !when.levels.includes(state.hold[when.dimension] as ResponseValue)) return `It applies ${whenText(record, dimension)}`;\n const count = panelLevels(record, state, dimension.id).length;\n if (count > MAX_PANELS) return `It has ${count} values, and a view has ${MAX_PANELS} panels or fewer`;\n if (count < 2) return \"It has one value here\";\n return \"\";\n}\n\n/** This function gives the reason that a dimension cannot go on an axis. A good dimension gives an empty string. */\nfunction axisBlock(record: ResponseRecord, state: ExplorerState, slot: AxisSlot, dimension: ResponseDimension): string {\n const otherId = slot === \"x\" ? state.y : state.x;\n if (dimension.id === otherId) return \"It is on the other axis\";\n const other = otherId === null ? undefined : dimensionOf(record, otherId);\n if (other?.when?.dimension === dimension.id) return `${other.label} needs it held`;\n const when = dimension.when;\n if (when === undefined) return \"\";\n const parent = dimensionOf(record, when.dimension);\n if (parent.id === otherId) return `It needs ${parent.label} held`;\n const shared = other?.when?.dimension === parent.id ? when.levels.filter((level) => other.when?.levels.includes(level) === true) : when.levels;\n const inView = parent.id === state.facet ? stopsOf(record, parent) : [state.hold[parent.id] as ResponseValue];\n return inView.some((level) => shared.includes(level)) ? \"\" : `It applies ${whenText(record, dimension)}`;\n}\n\n/** This function gives the first dimension with no condition, and a continuous dimension before another kind. */\nfunction firstAxis(record: ResponseRecord): string {\n const plain = record.dimensions.filter((d) => d.when === undefined);\n const chosen = plain.find((d) => d.kind === \"continuous\") ?? plain[0] ?? record.dimensions[0];\n return (chosen as ResponseDimension).id;\n}\n\n/**\n * This function gives the nearest good state for a wanted state. Each unknown or missing field takes its usual value.\n * A parent moves to a level that a varied conditional dimension needs. A combination that a view refuses loses its\n * second axis or its panels.\n */\nexport function settle(record: ResponseRecord, wanted: Partial<ExplorerState> = {}): ExplorerState {\n const known = (id: string | null | undefined): boolean => id !== null && id !== undefined && record.dimensions.some((d) => d.id === id);\n const measure = record.measures.some((m) => m.id === wanted.measure) ? (wanted.measure as string) : (record.measures[0]?.id ?? \"\");\n const x = known(wanted.x) ? (wanted.x as string) : firstAxis(record);\n const parentOf = (id: string): string | undefined => dimensionOf(record, id).when?.dimension;\n let y = known(wanted.y) && wanted.y !== x ? (wanted.y as string) : null;\n if (y !== null && (parentOf(y) === x || parentOf(x) === y || [...neededLevels(record, [x, y]).values()].some((levels) => levels.length === 0))) y = null;\n\n const hold: Record<string, ResponseValue> = {};\n for (const dimension of record.dimensions) hold[dimension.id] = nearestStop(record, dimension, wanted.hold?.[dimension.id]) ?? usualValue(record, dimension);\n\n const facetId = known(wanted.facet) ? (wanted.facet as string) : null;\n const facet = facetId !== null && facetBlock(record, { x, y, hold }, dimensionOf(record, facetId)) === \"\" ? facetId : null;\n for (const [parent, levels] of neededLevels(record, variedOf({ x, y }))) {\n if (parent === facet || levels.includes(hold[parent] as ResponseValue)) continue;\n hold[parent] = usualValue(record, dimensionOf(record, parent), levels);\n }\n return { measure, x, y, facet: facet !== null && facetBlock(record, { x, y, hold }, dimensionOf(record, facet)) === \"\" ? facet : null, hold };\n}\n\n/** This function gives each dimension as a choice for an axis. A disabled choice tells its reason. */\nexport function axisChoices(record: ResponseRecord, state: ExplorerState, slot: AxisSlot): readonly DimensionChoice[] {\n return record.dimensions.map((d) => {\n const reason = axisBlock(record, state, slot, d);\n return { id: d.id, label: d.label, disabled: reason !== \"\", reason };\n });\n}\n\n/** This function gives each dimension as a choice for panels. A disabled choice tells its reason. */\nexport function facetChoices(record: ResponseRecord, state: ExplorerState): readonly DimensionChoice[] {\n return record.dimensions.map((d) => {\n const reason = facetBlock(record, state, d);\n return { id: d.id, label: d.label, disabled: reason !== \"\", reason };\n });\n}\n\n/** This function gives the control of each held dimension. A dimension on an axis or in panels has no control. */\nexport function holdControls(record: ResponseRecord, state: ExplorerState): readonly HoldControl[] {\n const needed = neededLevels(record, variedOf(state));\n const held = record.dimensions.filter((d) => !variedOf(state).includes(d.id) && d.id !== state.facet);\n return held.map((d) => {\n const parent = d.when?.dimension;\n const open = parent === undefined || parent === state.facet || variedOf(state).includes(parent);\n const applies = open || d.when?.levels.includes(state.hold[parent as string] as ResponseValue) === true;\n const levels = needed.get(d.id);\n const options = stopsOf(record, d).map((value): HoldOption => {\n const locked = levels !== undefined && !levels.includes(value);\n const reason = !applies ? `It applies ${whenText(record, d)}` : locked ? \"A varied dimension has no value at this level\" : \"\";\n return { value, text: formatValue(value), disabled: reason !== \"\", reason };\n });\n const note = d.when === undefined ? \"\" : `Applies ${whenText(record, d)}`;\n return { id: d.id, label: d.label, kind: d.kind === \"continuous\" ? \"stops\" : \"levels\", applies, note, options, value: state.hold[d.id] as ResponseValue };\n });\n}\n\n/** This function gives the form of a group of levels. */\nexport function levelForm(count: number): \"chips\" | \"select\" {\n return count > MAX_CHIPS ? \"select\" : \"chips\";\n}\n\n/** This function gives the state with a new measure. */\nexport function setMeasure(record: ResponseRecord, state: ExplorerState, measure: string): ExplorerState {\n return settle(record, { ...state, measure });\n}\n\n/** This function gives the state with a new axis. It does not take a disabled choice. The value `null` removes the y axis. */\nexport function setAxis(record: ResponseRecord, state: ExplorerState, slot: AxisSlot, id: string | null): ExplorerState {\n if (id === null) return slot === \"y\" ? settle(record, { ...state, y: null }) : state;\n if (axisBlock(record, state, slot, dimensionOf(record, id)) !== \"\") return state;\n return settle(record, { ...state, [slot]: id, facet: state.facet === id ? null : state.facet });\n}\n\n/** This function gives the state with new panels. It does not take a disabled choice. The value `null` gives one panel. */\nexport function setFacet(record: ResponseRecord, state: ExplorerState, id: string | null): ExplorerState {\n if (id !== null && facetBlock(record, state, dimensionOf(record, id)) !== \"\") return state;\n return settle(record, { ...state, facet: id });\n}\n\n/** This function gives the state with a new held value. It does not take a disabled value. */\nexport function setHold(record: ResponseRecord, state: ExplorerState, id: string, value: ResponseValue): ExplorerState {\n const control = holdControls(record, state).find((c) => c.id === id);\n const option = control?.options.find((o) => o.value === value);\n if (option === undefined || option.disabled) return state;\n return settle(record, { ...state, hold: { ...state.hold, [id]: value } });\n}\n\n/**\n * This function gives the number of steps of a view, from the number of points, before the call. The field `nearest`\n * reads each point at each place, so the number of places comes from `READ_BUDGET`.\n *\n * @param points - The number of points of the record.\n * @param panels - The number of panels of the view.\n * @param continuous - The number of continuous axes of the view.\n * @param levels - The number of levels of a level axis of a surface, or 1.\n * @param cap - The largest result.\n */\nexport function planSteps(points: number, panels: number, continuous: number, levels: number, cap: number = MAX_STEPS): number {\n const places = READ_BUDGET / (Math.max(1, points) * Math.max(1, panels));\n const room = continuous === 2 ? Math.sqrt(places) : places / Math.max(1, levels);\n return Math.max(MIN_STEPS, Math.min(cap, MAX_STEPS, Math.floor(room)));\n}\n\n/** This function gives the cap of the next view: a smaller grid when this surface took more than the budget. */\nexport function nextStepsCap(steps: number, elapsedMs: number, budgetMs: number): number {\n if (elapsedMs <= budgetMs) return Number.POSITIVE_INFINITY;\n return Math.max(MIN_STEPS, Math.min(steps - 1, Math.floor(steps * Math.sqrt(budgetMs / elapsedMs))));\n}\n\n/** This function gives the axis of a dimension. */\nexport function axisOf(dimension: ResponseDimension): AxisSpec {\n const { id, label, unit } = dimension;\n const name = unit === \"\" ? label : `${label} (${unit})`;\n if (dimension.kind === \"continuous\") return { id, label: name, kind: \"number\", log: dimension.log === true, range: dimension.range, levels: [] };\n return { id, label: name, kind: \"levels\", log: false, range: [0, 1], levels: dimension.levels };\n}\n\n/** This function gives the place of a value on an axis, from 0 to 1. A value outside a number axis goes past the ends. */\nexport function placeOn(axis: AxisSpec, value: ResponseValue): number {\n if (axis.kind === \"levels\") return (axis.levels.indexOf(value) + 0.5) / axis.levels.length;\n const scale = (v: number): number => (axis.log ? Math.log10(v) : v);\n const [low, high] = axis.range;\n return (scale(value as number) - scale(low)) / (scale(high) - scale(low));\n}\n\n/** This function gives true for a point that matches the held values, with the rules of `sliceResponse`. */\nfunction pointMatches(record: ResponseRecord, point: ResponsePoint, measure: string, varied: readonly string[], hold: Readonly<Record<string, ResponseValue>>, tolerance: number): boolean {\n if (typeof point.measures[measure] !== \"number\") return false;\n return record.dimensions.every((d) => {\n const value = point.values[d.id] ?? null;\n if (varied.includes(d.id)) return value !== null;\n const wanted = whenHolds(d, point.values) ? (hold[d.id] as ResponseValue) : null;\n if (typeof value !== \"number\" || typeof wanted !== \"number\" || d.kind !== \"continuous\") return value === wanted;\n return Math.abs(shareOf(d, value) - shareOf(d, wanted)) <= tolerance;\n });\n}\n\n/** This function gives the error of a measure in plain words. */\nexport function errorSentence(measure: ResponseMeasure, model: ResponseModel, error: ResponseHeldOutError): string {\n const unit = measure.unit === \"\" ? \"\" : ` ${measure.unit}`;\n const amount = (value: number): string => (model.scale === \"log\" ? `a factor of ${formatValue(10 ** value)}` : `${formatValue(value)}${unit}`);\n const seen = `On ${error.n} points that each fit did not see, over ${error.folds} folds, the model misses by ${amount(error.mae)} on average.`;\n const base = `A plain mean misses by ${amount(error.baselineMae)}.`;\n if (error.skill === null) return `${seen} ${base}`;\n return error.skill > 0 ? `${seen} ${base} The model removes ${Math.round(error.skill * 100)}% of that miss.` : `${seen} ${base} The model is no better than the mean.`;\n}\n\n/** This function gives the name of a panel. */\nconst panelTitle = (facet: ResponseDimension | undefined, level: ResponseValue | null): string => (facet === undefined || level === null ? \"\" : `${facet.label}: ${formatValue(level)}`);\n\n/** This function gives the panels of a measure with no model: the measured points that match the held values. */\nfunction pointPanels(record: ResponseRecord, state: ExplorerState, levels: readonly (ResponseValue | null)[], facet: ResponseDimension | undefined, tolerance: number): ExplorerPanel[] {\n const varied = variedOf(state);\n return levels.map((level) => {\n const hold = level === null || facet === undefined ? state.hold : { ...state.hold, [facet.id]: level };\n const points = record.points.flatMap((p): PlainPoint[] => {\n if (!pointMatches(record, p, state.measure, varied, hold, tolerance)) return [];\n return [{ id: p.id, at: varied.map((id) => p.values[id] as ResponseValue), value: p.measures[state.measure] as number }];\n });\n return { kind: \"points\", title: panelTitle(facet, level), level, points };\n });\n}\n\n/** This function gives the held values of a request: each dimension that does not vary. */\nfunction requestHold(state: ExplorerState, facet: ResponseDimension | undefined, level: ResponseValue | null): Record<string, ResponseValue> {\n const varied = variedOf(state);\n const hold = Object.fromEntries(Object.entries(state.hold).filter(([id]) => !varied.includes(id)));\n return facet === undefined || level === null ? hold : { ...hold, [facet.id]: level };\n}\n\n/** This function gives the text of the size of a grid. */\nfunction gridSentence(x: readonly ResponseValue[], y: readonly ResponseValue[], cells: boolean, elapsedMs: number, budgetMs: number): string {\n if (cells) return `The grid has ${x.length} by ${y.length} measured levels.`;\n const size = `The grid has ${x.length} by ${y.length} places.`;\n return elapsedMs > budgetMs ? `${size} This surface took ${Math.round(elapsedMs)} ms, so the next grid is smaller.` : size;\n}\n\n/** This function gives the text of the places that a range moved. A view with no such place gives an empty string. */\nfunction rangeSentence(measure: ResponseMeasure, panels: readonly ExplorerPanel[]): string {\n const moved = panels.reduce((count, panel) => count + (panel.kind === \"curve\" ? panel.slice.clipped : panel.kind === \"surface\" ? panel.surface.clipped : 0), 0);\n if (moved === 0 || measure.range === undefined) return \"\";\n return `At ${moved} ${moved === 1 ? \"place\" : \"places\"}, the view stops at the range of the measure, ${measure.range[0]} to ${measure.range[1]}.`;\n}\n\n/** This function gives the steps of a view from its axes and the plan of `planSteps`. */\nfunction stepsOfView(record: ResponseRecord, state: ExplorerState, panels: number, cap: number): number {\n const continuous = variedOf(state).filter((id) => dimensionOf(record, id).kind === \"continuous\").length;\n // A count at 2 steps, less the 2 of each continuous axis, leaves the levels of the other axes.\n const levels = responseCells(record, state.y === null ? state.x : [state.x, state.y], 2) / 2 ** continuous;\n return planSteps(record.points.length, panels, continuous, levels, cap);\n}\n\n/**\n * This function gives the data of a view. It does not throw. A request that the record refuses gives the text in\n * `problem`, and no panels. A measure with no model gives only the measured points, and a table model gives cells.\n * A smooth model that is no better than a plain mean also gives only the measured points. A drawn fit claims knowledge that such a model does not have.\n * A table model keeps its cells at any error, because each cell is the mean of measured points.\n */\nexport function viewOf(record: ResponseRecord, state: ExplorerState, options: ViewOptions = {}): ExplorerView {\n const { budgetMs = SURFACE_BUDGET_MS, stepsCap = MAX_STEPS, now = (): number => 0 } = options;\n const measure = record.measures.find((m) => m.id === state.measure) ?? (record.measures[0] as ResponseMeasure);\n const model = record.models.find((m) => m.measure === measure.id);\n const x = axisOf(dimensionOf(record, state.x));\n const y = state.y === null ? null : axisOf(dimensionOf(record, state.y));\n const facet = state.facet === null ? undefined : dimensionOf(record, state.facet);\n const levels = facet === undefined ? [null] : panelLevels(record, state, facet.id);\n const steps = stepsOfView(record, state, levels.length, stepsCap);\n const tolerance = toleranceOf(record);\n const base = { measure, x, y, log: model?.scale === \"log\", steps, elapsedMs: 0, nextCap: stepsCap, gridText: \"\", rangeText: \"\", problem: \"\" };\n\n if (model === undefined) {\n const modelText = \"This measure has no valid model in the record, so the view shows only the measured points.\";\n return { ...base, panels: pointPanels(record, state, levels, facet, tolerance), error: null, errorText: \"\", modelText };\n }\n const modelText = model.kind === \"table\" ? \"The model is the mean of each measured cell, so the view shows cells and no smooth surface.\" : \"The model is a smooth fit over all the dimensions.\";\n try {\n const heldOut = heldOutError(record, measure.id);\n if (model.kind !== \"table\" && heldOut.skill !== null && heldOut.skill <= 0) {\n const noBetter = \"The model is no better than a plain mean on points that it did not see, so the view shows only the measured points.\";\n return { ...base, panels: pointPanels(record, state, levels, facet, tolerance), error: heldOut, errorText: errorSentence(measure, model, heldOut), modelText: noBetter };\n }\n const start = now();\n const panels = levels.map((level): ExplorerPanel => {\n const hold = requestHold(state, facet, level);\n const title = panelTitle(facet, level);\n if (state.y === null) return { kind: \"curve\", title, level, slice: sliceResponse(record, measure.id, { vary: state.x, hold, steps, tolerance }) };\n const surface = surfaceResponse(record, measure.id, { vary: [state.x, state.y], hold, steps, tolerance });\n return { kind: \"surface\", title, level, cells: model.kind === \"table\" || (x.kind === \"levels\" && y?.kind === \"levels\"), surface };\n });\n const elapsedMs = Math.max(0, now() - start);\n const first = panels[0];\n const surface = first?.kind === \"surface\" ? first : undefined;\n const late = surface !== undefined && !surface.cells ? nextStepsCap(steps, elapsedMs, budgetMs) : Number.POSITIVE_INFINITY;\n const gridText = surface === undefined ? \"\" : gridSentence(surface.surface.x, surface.surface.y, surface.cells, elapsedMs, budgetMs);\n return { ...base, panels, error: heldOut, errorText: errorSentence(measure, model, heldOut), modelText, gridText, rangeText: rangeSentence(measure, panels), elapsedMs, nextCap: Math.min(stepsCap, late) };\n } catch (error) {\n return { ...base, panels: [], error: null, errorText: \"\", modelText, problem: error instanceof Error ? error.message : String(error) };\n }\n}\n\n/** This function gives the strength of the band at a distance from a measurement: 1 at a measurement, 0.15 far away. */\nexport function fadeOf(nearest: number): number {\n return 1 - 0.85 * Math.min(1, nearest / FADE_END);\n}\n\n/** This function gives the share of the neutral veil of a surface cell at a distance from a measurement. */\nexport function veilOf(nearest: number): number {\n return 0.8 * Math.min(1, nearest / FADE_END);\n}\n\n/** This function gives a round step for a range and a tick count: 1, 2 or 5 times a power of 10. */\nfunction roundStep(span: number, count: number): number {\n const raw = span / Math.max(1, count);\n const power = 10 ** Math.floor(Math.log10(raw));\n const share = raw / power;\n return (share <= 1 ? 1 : share <= 2 ? 2 : share <= 5 ? 5 : 10) * power;\n}\n\n/** This function gives round numbers in a range, for approximately `count` ticks. */\nfunction roundNumbers(low: number, high: number, count: number): number[] {\n if (!(high > low)) return [low];\n const step = roundStep(high - low, count);\n const out: number[] = [];\n for (let i = Math.ceil(low / step - 1e-9); i * step <= high + step * 1e-9; i++) out.push(Number((i * step).toPrecision(12)));\n return out;\n}\n\n/** This function gives the values 1, 2 and 5 times each power of 10 in a range, for approximately `count` ticks. */\nfunction logNumbers(low: number, high: number, count: number): number[] {\n const out: number[] = [];\n for (let power = Math.floor(Math.log10(low)); power <= Math.ceil(Math.log10(high)); power++) {\n for (const factor of [1, 2, 5]) {\n const value = Number((factor * 10 ** power).toPrecision(12));\n if (value >= low * (1 - 1e-9) && value <= high * (1 + 1e-9)) out.push(value);\n }\n }\n const powers = out.filter((value) => Number.isInteger(Math.log10(value)));\n return out.length > count && powers.length >= 2 ? powers : out;\n}\n\n/** This function gives the ticks of a number range. A log range with too few round values gives linear round values. */\nexport function numberTicks(low: number, high: number, log: boolean, count: number): readonly Tick[] {\n const scale = (v: number): number => (log ? Math.log10(v) : v);\n const logged = log ? logNumbers(low, high, count) : [];\n const values = logged.length >= 3 ? logged : roundNumbers(low, high, count);\n return values.map((value) => ({ place: high > low ? (scale(value) - scale(low)) / (scale(high) - scale(low)) : 0.5, text: formatValue(value) }));\n}\n\n/** This function gives the ticks of an axis. */\nexport function axisTicks(axis: AxisSpec, count: number): readonly Tick[] {\n if (axis.kind === \"number\") return numberTicks(axis.range[0], axis.range[1], axis.log, count);\n return axis.levels.map((level) => ({ place: placeOn(axis, level), text: formatValue(level) }));\n}\n\n/** This function gives the values of one panel that the value axis must show. */\nfunction panelValues(panel: ExplorerPanel, varied: number): number[] {\n if (panel.kind === \"points\") return varied === 1 ? panel.points.map((p) => p.value) : [];\n if (panel.kind === \"curve\") return [...panel.slice.curve.flatMap((c) => [c.low, c.high]), ...panel.slice.points.map((p) => p.value)];\n return [];\n}\n\n/**\n * This function gives the two ends of the value axis of a curve view. All the panels of a view share them, so two\n * panels compare by eye. A range of one value grows, so the axis keeps a length.\n */\nexport function valueRange(view: ExplorerView): readonly [number, number] {\n const values = view.panels.flatMap((panel) => panelValues(panel, view.y === null ? 1 : 2)).filter((v) => Number.isFinite(v) && (!view.log || v > 0));\n if (values.length === 0) return view.log ? [1, 10] : [0, 1];\n const low = Math.min(...values);\n const high = Math.max(...values);\n if (view.log) {\n const margin = high > low ? (high / low) ** 0.05 : 2;\n return [low / margin, high * margin];\n }\n const margin = high > low ? (high - low) * 0.05 : Math.max(Math.abs(low) * 0.1, 1);\n return [low - margin, high + margin];\n}\n\n/** This function gives each fitted value of a surface view, with the values of a view of plain points. */\nfunction heatValues(view: ExplorerView): number[] {\n return view.panels.flatMap((panel) => {\n if (panel.kind === \"surface\") return panel.surface.cells.flatMap((row) => row.map((cell) => cell.value));\n return panel.kind === \"points\" ? panel.points.map((p) => p.value) : [];\n });\n}\n\n/** This function gives the two ends of the color scale of a surface view. All the panels share them. */\nexport function heatRange(view: ExplorerView): readonly [number, number] {\n const values = heatValues(view).filter((v) => Number.isFinite(v) && (!view.log || v > 0));\n if (values.length === 0) return [0, 1];\n return [Math.min(...values), Math.max(...values)];\n}\n\n/** This function gives the step of the color scale of a value, from 0 to `HEAT_STEPS - 1`. */\nexport function heatStep(value: number, range: readonly [number, number], log: boolean): number {\n const [low, high] = range;\n if (!(high > low)) return Math.floor(HEAT_STEPS / 2);\n const share = log ? (Math.log10(value) - Math.log10(low)) / (Math.log10(high) - Math.log10(low)) : (value - low) / (high - low);\n return Math.max(0, Math.min(HEAT_STEPS - 1, Math.floor(share * HEAT_STEPS)));\n}\n\n/** This function gives the edges of the cells around places on an axis, from 0 to 1. There is one more edge than places. */\nexport function cellEdges(places: readonly number[]): readonly number[] {\n const inner = places.slice(1).map((place, i) => (place + (places[i] as number)) / 2);\n return [0, ...inner, 1];\n}\n\n/** A point of a path, in the pixels of a chart. */\nexport type Pixel = readonly [number, number];\n\n/** This function gives the path of a line through pixels. */\nexport function linePath(pixels: readonly Pixel[]): string {\n return pixels.map(([x, y], i) => `${i === 0 ? \"M\" : \"L\"}${x.toFixed(1)} ${y.toFixed(1)}`).join(\"\");\n}\n\n/** This function gives the closed path of a band between its upper and its lower pixels. */\nexport function bandPath(upper: readonly Pixel[], lower: readonly Pixel[]): string {\n return `${linePath([...upper, ...[...lower].reverse()])}Z`;\n}\n\n/** This function gives the distance from a measurement in plain words. */\nfunction nearText(nearest: number): string {\n return nearest === 0 ? \"A point was measured here.\" : `The nearest measured point is ${Math.round(nearest * 100)}% of an axis away.`;\n}\n\n/** This function gives the text of one place of a band. */\nfunction bandText(band: ResponseBand): string {\n return `fitted ${formatValue(band.value)}, band ${formatValue(band.low)} to ${formatValue(band.high)}. ${nearText(band.nearest)}`;\n}\n\n/** This function gives the text of one place of a curve. */\nexport function curveText(axis: AxisSpec, place: ResponseCurvePoint): string {\n return `${axis.label} ${formatValue(place.at)}: ${bandText(place)}`;\n}\n\n/** This function gives the text of one place of a surface. */\nexport function cellText(x: AxisSpec, y: AxisSpec, atX: ResponseValue, atY: ResponseValue, band: ResponseBand): string {\n return `${x.label} ${formatValue(atX)}, ${y.label} ${formatValue(atY)}: ${bandText(band)}`;\n}\n\n/** This function gives the numbers of a panel: each place of a curve, or the measured points of a surface. */\nexport function numberTable(view: ExplorerView, panel: ExplorerPanel): NumberTable {\n const axes = view.y === null ? [view.x.label] : [view.x.label, view.y.label];\n if (panel.kind === \"curve\") {\n const rows = panel.slice.curve.map((c) => [formatValue(c.at), formatValue(c.value), formatValue(c.low), formatValue(c.high), `${Math.round(c.nearest * 100)}%`]);\n return { columns: [view.x.label, \"Fitted\", \"Low\", \"High\", \"Distance\"], rows };\n }\n const points: readonly { readonly at: readonly ResponseValue[]; readonly value: number }[] = panel.kind === \"points\" ? panel.points : panel.surface.points;\n return { columns: [...axes, \"Measured\"], rows: points.map((p) => [...p.at.map(formatValue), formatValue(p.value)]) };\n}\n","/// <reference lib=\"dom\" />\n/**\n * The DOM view of the response explorer. This module draws SVG with no framework. The core in `model.ts` gives each\n * rule and each number, and this module connects the core to the page.\n */\n\nimport { h, type Child } from \"../chrome.ts\";\nimport {\n axisChoices,\n axisTicks,\n bandPath,\n cellEdges,\n cellText,\n curveText,\n facetChoices,\n fadeOf,\n formatValue,\n heatRange,\n heatStep,\n HEAT_STEPS,\n holdControls,\n levelForm,\n linePath,\n MAX_STEPS,\n numberTable,\n numberTicks,\n openRecord,\n placeOn,\n setAxis,\n setFacet,\n setHold,\n setMeasure,\n settle,\n SURFACE_BUDGET_MS,\n valueRange,\n veilOf,\n viewOf,\n type AxisSpec,\n type CurvePanel,\n type DimensionChoice,\n type ExplorerPanel,\n type ExplorerState,\n type ExplorerView,\n type HoldControl,\n type Pixel,\n type PointsPanel,\n type SurfacePanel,\n type Tick,\n} from \"./model.ts\";\nimport type { ResponseRecord, ResponseValue } from \"@mark1russell7/rigor-statistics\";\n\n/** The options of `mountExplorer`. */\nexport interface ExplorerOptions {\n /** The first state. The explorer corrects a state that a record refuses. */\n readonly initial?: Partial<ExplorerState>;\n /** The time of a surface in milliseconds. The default is `SURFACE_BUDGET_MS`. */\n readonly budgetMs?: number;\n /** The clock in milliseconds. The default is `performance.now`. */\n readonly now?: () => number;\n}\n\n/** The result of `mountExplorer`. */\nexport interface ExplorerHandle {\n /** This method gives the choices of the visitor. It gives `null` for a record with faults. */\n state(): ExplorerState | null;\n /** This method removes the explorer from its host. */\n destroy(): void;\n}\n\nconst SVG = \"http://www.w3.org/2000/svg\";\n/** The most faults that the view lists. */\nconst MAX_FAULTS = 20;\n/** The width of a chart with no layout, for example in a test. */\nconst FALLBACK_WIDTH = 640;\nconst MARGIN = { top: 10, right: 14, bottom: 42, left: 50 };\n/** The height of a line of text of an axis, in pixels. */\nconst CHAR_WIDTH = 6.4;\n\nlet mounts = 0;\n\n/** This function makes an SVG element with attributes and children. */\nfunction s(tag: string, attrs: Readonly<Record<string, string | number>>, ...children: readonly (Node | string)[]): SVGElement {\n const el = document.createElementNS(SVG, tag);\n for (const [name, value] of Object.entries(attrs)) el.setAttribute(name, String(value));\n el.append(...children);\n return el;\n}\n\n/** The plot of a chart: the pixels of its area and of its axes. */\ninterface Plot {\n readonly width: number;\n readonly height: number;\n readonly left: number;\n readonly top: number;\n readonly right: number;\n readonly bottom: number;\n}\n\n/** This function gives the plot of a chart. Long level names need room for their turned text. */\nfunction plotOf(width: number, height: number, view: ExplorerView): Plot {\n const turned = turnedLevels(view.x, width - MARGIN.left - MARGIN.right);\n const longest = Math.max(0, ...view.x.levels.map((level) => formatValue(level).length));\n const bottom = height - MARGIN.bottom - (turned ? Math.min(60, longest * CHAR_WIDTH * 0.7) : 0);\n const left = view.y?.kind === \"levels\" ? Math.min(110, Math.max(MARGIN.left, 12 + Math.max(...view.y.levels.map((level) => formatValue(level).length)) * CHAR_WIDTH)) : MARGIN.left;\n return { width, height, left, top: MARGIN.top, right: width - MARGIN.right, bottom };\n}\n\n/** This function gives true when the levels of an axis do not fit side by side. */\nfunction turnedLevels(axis: AxisSpec, room: number): boolean {\n if (axis.kind !== \"levels\") return false;\n const longest = Math.max(0, ...axis.levels.map((level) => formatValue(level).length));\n return (longest + 1) * CHAR_WIDTH > room / Math.max(1, axis.levels.length);\n}\n\n/** This function gives the ticks of an axis that fit in a length. */\nfunction fittedTicks(axis: AxisSpec, length: number): readonly Tick[] {\n return axisTicks(axis, Math.max(2, Math.floor(length / 70)));\n}\n\n/** This function draws the horizontal axis. */\nfunction xAxis(plot: Plot, axis: AxisSpec): SVGElement {\n const length = plot.right - plot.left;\n const turned = turnedLevels(axis, length);\n const ticks = fittedTicks(axis, length).map((tick) => {\n const x = plot.left + tick.place * length;\n const label = turned\n ? s(\"text\", { class: \"rx-tick\", x, y: plot.bottom + 14, \"text-anchor\": \"end\", transform: `rotate(-35 ${x} ${plot.bottom + 14})` }, tick.text)\n : s(\"text\", { class: \"rx-tick\", x, y: plot.bottom + 15, \"text-anchor\": x + (tick.text.length * CHAR_WIDTH) / 2 > plot.width ? \"end\" : \"middle\" }, tick.text);\n return s(\"g\", {}, s(\"line\", { class: \"rx-axis\", x1: x, x2: x, y1: plot.bottom, y2: plot.bottom + 4 }), label);\n });\n const name = s(\"text\", { class: \"rx-axis-name\", x: (plot.left + plot.right) / 2, y: plot.height - 6, \"text-anchor\": \"middle\" }, axis.log ? `${axis.label}, log scale` : axis.label);\n return s(\"g\", {}, s(\"line\", { class: \"rx-axis\", x1: plot.left, x2: plot.right, y1: plot.bottom, y2: plot.bottom }), ...ticks, name);\n}\n\n/** This function draws the value axis with its grid lines. */\nfunction valueAxis(plot: Plot, ticks: readonly Tick[]): SVGElement {\n const length = plot.bottom - plot.top;\n const lines = ticks.map((tick) => {\n const y = plot.bottom - tick.place * length;\n return s(\"g\", {}, s(\"line\", { class: \"rx-grid\", x1: plot.left, x2: plot.right, y1: y, y2: y }), s(\"text\", { class: \"rx-tick\", x: plot.left - 6, y: y + 4, \"text-anchor\": \"end\" }, tick.text));\n });\n return s(\"g\", {}, ...lines);\n}\n\n/** This function draws the vertical axis of a surface. */\nfunction surfaceAxis(plot: Plot, axis: AxisSpec): SVGElement {\n const length = plot.bottom - plot.top;\n const ticks = axisTicks(axis, Math.max(2, Math.floor(length / 45))).map((tick) => {\n const y = plot.bottom - tick.place * length;\n return s(\"text\", { class: \"rx-tick\", x: plot.left - 6, y: y + 4, \"text-anchor\": \"end\" }, tick.text);\n });\n return s(\"g\", {}, ...ticks);\n}\n\n/** The scale of the value axis of a view. */\ninterface ValueScale {\n readonly range: readonly [number, number];\n readonly log: boolean;\n}\n\n/** This function gives the place of a value on the value axis, from 0 to 1. */\nfunction valuePlace(scale: ValueScale, value: number): number {\n const [low, high] = scale.range;\n if (scale.log) return (Math.log10(Math.max(value, low)) - Math.log10(low)) / (Math.log10(high) - Math.log10(low));\n return (value - low) / (high - low);\n}\n\n/** This function gives a small steady offset for a dot from its id, so the dots of one level do not all overlap. */\nfunction jitter(id: string, room: number): number {\n let hash = 7;\n for (const char of id) hash = (hash * 31 + (char.codePointAt(0) ?? 0)) % 1009;\n return (hash / 1008 - 0.5) * room;\n}\n\n/** The handler of a panel: it moves the mark of the cursor and it gives the text of a place. */\ninterface Cursor {\n /** The number of places across and up. */\n readonly columns: number;\n readonly rows: number;\n /** This method gives the place at a pixel. */\n at(x: number, y: number): readonly [number, number];\n /** This method moves the mark and gives the text of the place. */\n show(column: number, row: number): string;\n}\n\n/** This function connects the pointer and the arrow keys of a chart to its cursor. */\nfunction connect(svg: SVGElement, cursor: Cursor, tell: (text: string) => void): void {\n let column = -1;\n let row = 0;\n const move = (nextColumn: number, nextRow: number): void => {\n column = Math.max(0, Math.min(cursor.columns - 1, nextColumn));\n row = Math.max(0, Math.min(cursor.rows - 1, nextRow));\n tell(cursor.show(column, row));\n };\n svg.addEventListener(\"pointermove\", (event) => {\n const box = svg.getBoundingClientRect();\n const [c, r] = cursor.at((event as PointerEvent).clientX - box.left, (event as PointerEvent).clientY - box.top);\n move(c, r);\n });\n svg.addEventListener(\"keydown\", (event) => {\n const steps: Readonly<Record<string, readonly [number, number]>> = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] };\n const step = steps[(event as KeyboardEvent).key];\n if (step === undefined) return;\n event.preventDefault();\n move(column < 0 ? 0 : column + step[0], row + step[1]);\n });\n}\n\n/** This function makes the frame of a chart with its text for a screen reader. */\nfunction chartFrame(plot: Plot, label: string): SVGElement {\n return s(\"svg\", { class: \"rx-svg\", width: plot.width, height: plot.height, viewBox: `0 0 ${plot.width} ${plot.height}`, role: \"img\", \"aria-label\": label, tabindex: 0 });\n}\n\n/** This function draws a band with one strength for each place along the axis. */\nfunction fadedBand(plot: Plot, panel: CurvePanel, scale: ValueScale, axis: AxisSpec, id: string): SVGElement[] {\n const length = plot.right - plot.left;\n const height = plot.bottom - plot.top;\n const curve = panel.slice.curve;\n const px = (at: ResponseValue): number => plot.left + placeOn(axis, at) * length;\n const py = (value: number): number => plot.bottom - valuePlace(scale, value) * height;\n const stops = curve.map((place) => s(\"stop\", { class: \"rx-band-stop\", offset: placeOn(axis, place.at), \"stop-opacity\": fadeOf(place.nearest).toFixed(3) }));\n const gradient = s(\"linearGradient\", { id, gradientUnits: \"userSpaceOnUse\", x1: plot.left, x2: plot.right, y1: 0, y2: 0 }, ...stops);\n const upper = curve.map((place): Pixel => [px(place.at), py(place.high)]);\n const lower = curve.map((place): Pixel => [px(place.at), py(place.low)]);\n return [s(\"defs\", {}, gradient), s(\"path\", { class: \"rx-band\", d: bandPath(upper, lower), fill: `url(#${id})` })];\n}\n\n/** This function draws a band and a mark at each level of a level axis. */\nfunction levelMarks(plot: Plot, panel: CurvePanel, scale: ValueScale, axis: AxisSpec): SVGElement[] {\n const length = plot.right - plot.left;\n const height = plot.bottom - plot.top;\n const room = Math.min(44, (length / Math.max(1, axis.levels.length)) * 0.5);\n return panel.slice.curve.flatMap((place) => {\n const x = plot.left + placeOn(axis, place.at) * length;\n const top = plot.bottom - valuePlace(scale, place.high) * height;\n const bottom = plot.bottom - valuePlace(scale, place.low) * height;\n const y = plot.bottom - valuePlace(scale, place.value) * height;\n return [\n s(\"rect\", { class: \"rx-whisker\", x: x - room / 2, y: top, width: room, height: Math.max(1, bottom - top), rx: 4, \"fill-opacity\": (0.3 * fadeOf(place.nearest)).toFixed(3) }),\n s(\"line\", { class: \"rx-line\", x1: x - room / 2, x2: x + room / 2, y1: y, y2: y }),\n ];\n });\n}\n\n/** This function draws a chart with a fitted curve, its band and the measured points. */\nfunction curveChart(view: ExplorerView, panel: CurvePanel, width: number, id: string, tell: (text: string) => void): SVGElement {\n const plot = plotOf(width, 270, view);\n const scale: ValueScale = { range: valueRange(view), log: view.log };\n const length = plot.right - plot.left;\n const height = plot.bottom - plot.top;\n const curve = panel.slice.curve;\n const px = (at: ResponseValue): number => plot.left + placeOn(view.x, at) * length;\n const py = (value: number): number => plot.bottom - valuePlace(scale, value) * height;\n const smooth = view.x.kind === \"number\";\n const marks = smooth\n ? [...fadedBand(plot, panel, scale, view.x, id), s(\"path\", { class: \"rx-line\", d: linePath(curve.map((place): Pixel => [px(place.at), py(place.value)])) })]\n : levelMarks(plot, panel, scale, view.x);\n const room = smooth ? 0 : Math.min(30, (length / Math.max(1, view.x.levels.length)) * 0.35);\n const dots = panel.slice.points.map((point) => s(\"circle\", { class: \"rx-dot\", cx: px(point.at) + jitter(point.id, room), cy: py(point.value), r: 3.5 }));\n const ticks = numberTicks(scale.range[0], scale.range[1], scale.log, Math.max(2, Math.floor(height / 50)));\n const rule = s(\"line\", { class: \"rx-cursor\", x1: 0, x2: 0, y1: plot.top, y2: plot.bottom, visibility: \"hidden\" });\n const ring = s(\"circle\", { class: \"rx-ring\", cx: 0, cy: 0, r: 5, visibility: \"hidden\" });\n const svg = chartFrame(plot, `${panel.title} ${view.measure.label} over ${view.x.label}.`.trim());\n svg.append(valueAxis(plot, ticks), ...marks, ...dots, xAxis(plot, view.x), rule, ring);\n connect(\n svg,\n {\n columns: curve.length,\n rows: 1,\n at: (x) => {\n const distance = (place: (typeof curve)[number]): number => Math.abs(px(place.at) - x);\n const nearest = curve.reduce((best, place) => (distance(place) < distance(best) ? place : best));\n return [curve.indexOf(nearest), 0];\n },\n show: (column) => {\n const place = curve[column] as (typeof curve)[number];\n for (const [name, value] of [[\"x1\", px(place.at)], [\"x2\", px(place.at)]] as const) rule.setAttribute(name, String(value));\n ring.setAttribute(\"cx\", String(px(place.at)));\n ring.setAttribute(\"cy\", String(py(place.value)));\n rule.setAttribute(\"visibility\", \"visible\");\n ring.setAttribute(\"visibility\", \"visible\");\n return curveText(view.x, place);\n },\n },\n tell,\n );\n return svg;\n}\n\n/** This function draws a chart of a surface, or the separate cells of a table. */\nfunction surfaceChart(view: ExplorerView, panel: SurfacePanel, width: number, tell: (text: string) => void): SVGElement {\n const axisY = view.y as AxisSpec;\n const plot = plotOf(width, Math.min(380, Math.max(280, width * 0.72)), view);\n const { x, y, cells } = panel.surface;\n const length = plot.right - plot.left;\n const height = plot.bottom - plot.top;\n const xEdges = cellEdges(x.map((value) => placeOn(view.x, value)));\n const yEdges = cellEdges(y.map((value) => placeOn(axisY, value)));\n const range = heatRange(view);\n const gap = panel.cells ? 2 : 0;\n const cellMarks = cells.flatMap((row, j) =>\n row.flatMap((band, i) => {\n const left = plot.left + (xEdges[i] as number) * length;\n const right = plot.left + (xEdges[i + 1] as number) * length;\n const lower = plot.bottom - (yEdges[j] as number) * height;\n const upper = plot.bottom - (yEdges[j + 1] as number) * height;\n const box = { x: left + gap / 2, y: upper + gap / 2, width: Math.max(0.5, right - left - gap + (gap === 0 ? 0.6 : 0)), height: Math.max(0.5, lower - upper - gap + (gap === 0 ? 0.6 : 0)) };\n const step = heatStep(band.value, range, view.log);\n const parts = [s(\"rect\", { ...box, class: `rx-h${step}` })];\n const veil = veilOf(band.nearest);\n if (veil > 0.02) parts.push(s(\"rect\", { ...box, class: \"rx-veil\", \"fill-opacity\": veil.toFixed(3) }));\n if (panel.cells && box.width > 34 && box.height > 18) parts.push(s(\"text\", { class: `rx-cell-text ${step > HEAT_STEPS / 2 ? \"rx-on-dark\" : \"rx-on-light\"}`, x: box.x + box.width / 2, y: box.y + box.height / 2 + 4, \"text-anchor\": \"middle\" }, formatValue(band.value)));\n return parts;\n }),\n );\n const dots = panel.surface.points.map((point) =>\n s(\"circle\", { class: \"rx-dot rx-dot-heat\", cx: plot.left + placeOn(view.x, point.at[0]) * length + jitter(point.id, 6), cy: plot.bottom - placeOn(axisY, point.at[1]) * height + jitter(`${point.id}y`, 6), r: 2.5 }),\n );\n const outline = s(\"rect\", { class: \"rx-cell-cursor\", x: 0, y: 0, width: 0, height: 0, visibility: \"hidden\" });\n const svg = chartFrame(plot, `${panel.title} ${view.measure.label} over ${view.x.label} and ${axisY.label}.`.trim());\n svg.append(...cellMarks, ...dots, surfaceAxis(plot, axisY), xAxis(plot, view.x), outline);\n const find = (edges: readonly number[], share: number): number => {\n const index = edges.findIndex((edge) => edge > share);\n return Math.max(0, (index < 0 ? edges.length : index) - 1);\n };\n connect(\n svg,\n {\n columns: x.length,\n rows: y.length,\n at: (px, py) => [find(xEdges, (px - plot.left) / length), y.length - 1 - find(yEdges, (plot.bottom - py) / height)],\n show: (column, row) => {\n const j = y.length - 1 - row;\n outline.setAttribute(\"x\", String(plot.left + (xEdges[column] as number) * length));\n outline.setAttribute(\"width\", String(((xEdges[column + 1] as number) - (xEdges[column] as number)) * length));\n outline.setAttribute(\"y\", String(plot.bottom - (yEdges[j + 1] as number) * height));\n outline.setAttribute(\"height\", String(((yEdges[j + 1] as number) - (yEdges[j] as number)) * height));\n outline.setAttribute(\"visibility\", \"visible\");\n return cellText(view.x, axisY, x[column] as ResponseValue, y[j] as ResponseValue, cells[j]?.[column] as (typeof cells)[number][number]);\n },\n },\n tell,\n );\n return svg;\n}\n\n/** This function draws the measured points of a measure with no model. */\nfunction pointsChart(view: ExplorerView, panel: PointsPanel, width: number): SVGElement {\n const plot = plotOf(width, 270, view);\n const length = plot.right - plot.left;\n const height = plot.bottom - plot.top;\n const svg = chartFrame(plot, `${panel.title} ${view.measure.label}: ${panel.points.length} measured points.`.trim());\n if (view.y === null) {\n const scale: ValueScale = { range: valueRange(view), log: view.log };\n const room = view.x.kind === \"levels\" ? Math.min(30, (length / Math.max(1, view.x.levels.length)) * 0.35) : 0;\n const dots = panel.points.map((point) => s(\"circle\", { class: \"rx-dot\", cx: plot.left + placeOn(view.x, point.at[0] as ResponseValue) * length + jitter(point.id, room), cy: plot.bottom - valuePlace(scale, point.value) * height, r: 3.5 }));\n const ticks = numberTicks(scale.range[0], scale.range[1], scale.log, Math.max(2, Math.floor(height / 50)));\n svg.append(valueAxis(plot, ticks), ...dots, xAxis(plot, view.x));\n return svg;\n }\n const axisY = view.y;\n const range = heatRange(view);\n const dots = panel.points.map((point) =>\n s(\"circle\", { class: `rx-h${heatStep(point.value, range, view.log)} rx-ring-dot`, cx: plot.left + placeOn(view.x, point.at[0] as ResponseValue) * length + jitter(point.id, 8), cy: plot.bottom - placeOn(axisY, point.at[1] as ResponseValue) * height + jitter(`${point.id}y`, 8), r: 5 }),\n );\n svg.append(...dots, surfaceAxis(plot, axisY), xAxis(plot, view.x));\n return svg;\n}\n\n/** This function gives the number of measured points of a panel. */\nfunction pointCount(panel: ExplorerPanel): number {\n if (panel.kind === \"curve\") return panel.slice.points.length;\n return panel.kind === \"surface\" ? panel.surface.points.length : panel.points.length;\n}\n\n/** This function gives the sentence about the measured points of a panel. */\nfunction pointsText(panel: ExplorerPanel): string {\n const count = pointCount(panel);\n if (count === 0) return \"No measured point has these held values.\";\n return count === 1 ? \"1 measured point has these held values.\" : `${count} measured points have these held values.`;\n}\n\n/** This function draws one panel. */\nfunction panelChart(view: ExplorerView, panel: ExplorerPanel, width: number, id: string, tell: (text: string) => void): SVGElement {\n if (panel.kind === \"curve\") return curveChart(view, panel, width, id, tell);\n return panel.kind === \"surface\" ? surfaceChart(view, panel, width, tell) : pointsChart(view, panel, width);\n}\n\n/** This function makes the legend of a view. */\nfunction legendOf(view: ExplorerView): HTMLElement {\n const item = (mark: HTMLElement, text: string): HTMLElement => h(\"span\", { class: \"rx-key\" }, mark, text);\n const mark = (name: string): HTMLElement => h(\"i\", { class: `rx-mark ${name}`, \"aria-hidden\": \"true\" });\n const parts: Child[] = [];\n const panel = view.panels[0];\n const surface = view.y !== null && panel?.kind !== \"curve\";\n if (panel?.kind === \"curve\") parts.push(item(mark(\"rx-mark-line\"), \"fitted value\"), item(mark(\"rx-mark-band\"), \"band: one held-out error each side. It fades away from the data.\"));\n if (surface) {\n const [low, high] = heatRange(view);\n const ramp = h(\"i\", { class: \"rx-ramp\", \"aria-hidden\": \"true\" }, ...Array.from({ length: HEAT_STEPS }, (_, i) => h(\"b\", { class: `rx-s${i}` })));\n parts.push(h(\"span\", { class: \"rx-key\" }, formatValue(low), ramp, formatValue(high)));\n if (panel?.kind === \"surface\") parts.push(item(mark(\"rx-mark-veil\"), \"gray veil: far from the data\"));\n }\n if (panel !== undefined) parts.push(item(mark(\"rx-mark-dot\"), \"measured point\"));\n return h(\"p\", { class: \"rx-legend\" }, ...parts);\n}\n\n/** This function makes a table of numbers. */\nfunction tableOf(view: ExplorerView, panel: ExplorerPanel): HTMLElement {\n const { columns, rows } = numberTable(view, panel);\n const head = h(\"tr\", {}, ...columns.map((column) => h(\"th\", { scope: \"col\" }, column)));\n const body = rows.map((row) => h(\"tr\", {}, ...row.map((cell) => h(\"td\", {}, cell))));\n const table = h(\"table\", { class: \"rx-table\" }, ...(panel.title === \"\" ? [] : [h(\"caption\", {}, panel.title)]), h(\"thead\", {}, head), h(\"tbody\", {}, ...body));\n return table;\n}\n\n/** This function makes a select of dimensions. The first option is the value `none`, if the control has one. */\nfunction dimensionSelect(label: string, key: string, choices: readonly DimensionChoice[], value: string | null, none: string | null, change: (id: string | null) => void): HTMLElement {\n const options = choices.map((choice) => {\n const text = choice.disabled ? `${choice.label}: ${choice.reason}` : choice.label;\n return h(\"option\", { value: choice.id, disabled: choice.disabled, selected: choice.id === value }, text);\n });\n const select = h(\"select\", { \"data-key\": key }, ...(none === null ? [] : [h(\"option\", { value: \"\", selected: value === null }, none)]), ...options);\n select.addEventListener(\"change\", () => change(select.value === \"\" ? null : select.value));\n return h(\"label\", { class: \"rx-field\" }, h(\"span\", {}, label), select);\n}\n\n/** The fields of a level in a group. */\ninterface LevelOption {\n readonly text: string;\n readonly checked: boolean;\n readonly disabled: boolean;\n readonly reason: string;\n readonly choose: () => void;\n}\n\n/** This function makes a select of levels. A closed select shows the held value and takes one row. */\nfunction levelSelect(label: string, key: string, options: readonly LevelOption[], note: string): HTMLElement {\n const items = options.map((option, i) => {\n const text = option.disabled ? `${option.text}: ${option.reason}` : option.text;\n return h(\"option\", { value: i, disabled: option.disabled, selected: option.checked }, text);\n });\n const select = h(\"select\", { \"data-key\": key }, ...items);\n select.addEventListener(\"change\", () => options[Number(select.value)]?.choose());\n const field = h(\"label\", { class: \"rx-field\" }, h(\"span\", {}, label), select);\n return h(\"div\", { class: \"rx-hold\" }, field, note === \"\" ? null : h(\"p\", { class: \"rx-note\" }, note));\n}\n\n/** This function makes a group of levels. Level buttons are radio inputs, so the keyboard works with no script. */\nfunction levelGroup(label: string, key: string, name: string, options: readonly LevelOption[], note: string): HTMLElement {\n if (levelForm(options.length) === \"select\") return levelSelect(label, key, options, note);\n const chips = options.map((option, i) => {\n const input = h(\"input\", { class: \"rx-radio\", type: \"radio\", name, checked: option.checked, disabled: option.disabled, \"data-key\": `${key}:${i}` });\n input.addEventListener(\"change\", option.choose);\n return h(\"label\", { class: \"rx-chip\", title: option.reason === \"\" ? undefined : option.reason }, input, h(\"span\", {}, option.text));\n });\n const legend = h(\"legend\", { class: \"rx-name\" }, label);\n return h(\"fieldset\", { class: \"rx-hold\" }, legend, h(\"div\", { class: \"rx-chips\" }, ...chips), note === \"\" ? null : h(\"p\", { class: \"rx-note\" }, note));\n}\n\n/** This function makes a slider over the values of a held dimension. */\nfunction stopSlider(control: HoldControl, key: string, change: (value: ResponseValue) => void): HTMLElement {\n const values = control.options.map((option) => option.value);\n const index = Math.max(0, values.indexOf(control.value));\n const output = h(\"output\", { class: \"rx-value\" }, formatValue(control.value));\n const input = h(\"input\", { class: \"rx-slider\", type: \"range\", min: 0, max: values.length - 1, step: 1, value: index, disabled: !control.applies, \"data-key\": key, \"aria-label\": control.label, \"aria-valuetext\": formatValue(control.value) });\n input.addEventListener(\"input\", () => {\n const value = values[Number(input.value)] as ResponseValue;\n output.textContent = formatValue(value);\n input.setAttribute(\"aria-valuetext\", formatValue(value));\n change(value);\n });\n const head = h(\"div\", { class: \"rx-slider-head\" }, h(\"span\", { class: \"rx-name\" }, control.label), output);\n return h(\"div\", { class: \"rx-hold\" }, head, input, control.note === \"\" ? null : h(\"p\", { class: \"rx-note\" }, control.note));\n}\n\n/** This function shows each fault of a bad record, with its path. */\nfunction faultView(faults: readonly { readonly path: string; readonly message: string }[]): HTMLElement {\n const items = faults.slice(0, MAX_FAULTS).map((fault) => h(\"li\", {}, h(\"code\", {}, fault.path === \"\" ? \"(the record)\" : fault.path), ` ${fault.message}`));\n const more = faults.length > MAX_FAULTS ? h(\"p\", {}, `The list shows ${MAX_FAULTS} of ${faults.length} faults.`) : null;\n const title = faults.length === 1 ? \"This record has 1 fault.\" : `This record has ${faults.length} faults.`;\n return h(\"div\", { class: \"rx-faults\", role: \"alert\" }, h(\"p\", { class: \"rx-faults-title\" }, title), h(\"ul\", {}, ...items), more);\n}\n\n/**\n * This function shows a record of the format `response-records/1` in a host element. It reads the record only with\n * `parseResponseRecord`. A bad record shows its faults with their paths, and the function does not throw.\n *\n * @param host - The element of the explorer. The function replaces its children.\n * @param recordJson - The record as JSON text, or as parsed data.\n * @param options - The first state, the time of a surface and the clock.\n */\nexport function mountExplorer(host: HTMLElement, recordJson: unknown, options: ExplorerOptions = {}): ExplorerHandle {\n const parsed = openRecord(recordJson);\n if (!parsed.ok) {\n host.replaceChildren(h(\"div\", { class: \"response-explorer\" }, faultView(parsed.faults)));\n return { state: () => null, destroy: () => host.replaceChildren() };\n }\n return mountRecord(host, parsed.record, options);\n}\n\n/** This function connects a good record to the DOM. */\nfunction mountRecord(host: HTMLElement, record: ResponseRecord, options: ExplorerOptions): ExplorerHandle {\n const { budgetMs = SURFACE_BUDGET_MS, now = (): number => performance.now() } = options;\n const mount = ++mounts;\n let state = settle(record, options.initial);\n let cap = MAX_STEPS;\n let frame = 0;\n let drawnWidth = 0;\n let view: ExplorerView | undefined;\n // The fold of the held values that do not apply stays open or closed when the controls draw again.\n let idleOpen = false;\n\n const controls = h(\"div\", { class: \"rx-controls\" });\n const panels = h(\"div\", { class: \"rx-panels\" });\n const error = h(\"p\", { class: \"rx-error\" });\n const model = h(\"p\", { class: \"rx-note\" });\n const legend = h(\"div\", { class: \"rx-legend-box\" });\n const readout = h(\"p\", { class: \"rx-readout\", \"aria-live\": \"polite\" });\n const numbers = h(\"div\", { class: \"rx-numbers-body\" });\n const details = h(\"details\", { class: \"rx-numbers\" }, h(\"summary\", {}, \"Show the numbers\"), numbers);\n const chart = h(\"div\", { class: \"rx-chart\" }, error, panels, legend, readout, model, details);\n const root = h(\"div\", { class: \"response-explorer\" }, controls, chart);\n\n const tell = (text: string): void => {\n readout.textContent = text;\n };\n\n /** This function fills the table when the visitor opens it, so a closed table costs no time. */\n const drawNumbers = (): void => {\n numbers.replaceChildren(...(details.open && view !== undefined ? view.panels.map((panel) => h(\"div\", { class: \"rx-table-box scroll-cue\" }, tableOf(view as ExplorerView, panel))) : []));\n };\n\n /** This function draws the charts of the last view at the width of the host. */\n const drawCharts = (): void => {\n const current = view;\n if (current === undefined) return;\n const single = current.panels.length === 1;\n const available = panels.clientWidth > 0 ? panels.clientWidth : FALLBACK_WIDTH;\n const columns = single ? 1 : Math.min(current.panels.length, Math.max(1, Math.floor((available + 12) / 272)));\n const width = Math.floor((available - (columns - 1) * 12) / columns);\n drawnWidth = available;\n panels.replaceChildren(\n ...current.panels.map((panel, i) => {\n const title = panel.title === \"\" ? null : h(\"figcaption\", { class: \"rx-panel-title\" }, panel.title);\n const chartBox = panelChart(current, panel, width, `rx-band-${mount}-${i}`, tell);\n return h(\"figure\", { class: \"rx-panel\" }, title, chartBox, h(\"p\", { class: \"rx-note\" }, pointsText(panel)));\n }),\n );\n };\n\n /** This function asks the core for a view, and it draws the view. */\n const drawView = (): void => {\n const next = viewOf(record, state, { stepsCap: cap, budgetMs, now });\n view = next;\n cap = next.nextCap;\n if (next.problem !== \"\") {\n error.textContent = `The record refused this view: ${next.problem}`;\n } else {\n const head = next.error === null ? null : h(\"strong\", {}, \"Held-out error. \");\n error.replaceChildren(...(head === null ? [] : [head]), next.errorText);\n }\n model.textContent = [next.modelText, next.gridText, next.rangeText].filter((text) => text !== \"\").join(\" \");\n legend.replaceChildren(legendOf(next));\n tell(\"Move over a chart, or focus it and use the arrow keys.\");\n drawCharts();\n drawNumbers();\n };\n\n /** This function draws at the next frame. A slider gives many events in one frame. */\n const later = (): void => {\n if (frame !== 0) return;\n frame = requestAnimationFrame(() => {\n frame = 0;\n drawView();\n });\n };\n\n /** This function makes the controls of the state again, and it keeps the focus on the same control. */\n const drawControls = (): void => {\n const focused = document.activeElement instanceof HTMLElement ? document.activeElement.dataset[\"key\"] : undefined;\n const update = (next: ExplorerState): void => {\n state = next;\n drawControls();\n drawView();\n };\n const measures = levelGroup(\n \"Measure\",\n \"measure\",\n `rx-measure-${mount}`,\n record.measures.map((m) => ({ text: m.label, checked: m.id === state.measure, disabled: false, reason: \"\", choose: () => update(setMeasure(record, state, m.id)) })),\n \"\",\n );\n const axes = h(\n \"div\",\n { class: \"rx-axes\" },\n dimensionSelect(\"Across\", \"x\", axisChoices(record, state, \"x\"), state.x, null, (id) => update(setAxis(record, state, \"x\", id))),\n dimensionSelect(\"Up\", \"y\", axisChoices(record, state, \"y\"), state.y, \"None (a curve)\", (id) => update(setAxis(record, state, \"y\", id))),\n dimensionSelect(\"Panels\", \"facet\", facetChoices(record, state), state.facet, \"One panel\", (id) => update(setFacet(record, state, id))),\n );\n const holdOf = (control: HoldControl): HTMLElement => {\n if (control.kind === \"stops\") {\n return stopSlider(control, `hold:${control.id}`, (value) => {\n state = setHold(record, state, control.id, value);\n later();\n });\n }\n const levels = control.options.map((option) => ({ text: option.text, checked: option.value === control.value, disabled: option.disabled, reason: option.reason, choose: () => update(setHold(record, state, control.id, option.value)) }));\n return levelGroup(control.label, `hold:${control.id}`, `rx-${mount}-${control.id}`, levels, control.note);\n };\n // A held value that does not apply at the level of its parent goes in one closed fold, so the visitor sees first the values that change the view.\n const holds = holdControls(record, state);\n const idle = holds.filter((control) => !control.applies);\n const fold = idle.length === 0 ? null : h(\"details\", { class: \"rx-idle\", open: idleOpen }, h(\"summary\", {}, `Held values that do not apply (${idle.length})`), h(\"div\", { class: \"rx-idle-list\" }, ...idle.map(holdOf)));\n fold?.addEventListener(\"toggle\", () => {\n idleOpen = fold.open;\n });\n const held = holds.length === 0 ? [] : [h(\"p\", { class: \"rx-section\" }, \"Held values\"), ...holds.filter((control) => control.applies).map(holdOf), ...(fold === null ? [] : [fold])];\n controls.replaceChildren(measures, axes, ...held);\n if (focused !== undefined) {\n const keyed = [...controls.querySelectorAll<HTMLElement>(\"[data-key]\")].find((el) => el.dataset[\"key\"] === focused);\n keyed?.focus();\n }\n };\n\n details.addEventListener(\"toggle\", drawNumbers);\n host.replaceChildren(root);\n drawControls();\n drawView();\n\n const observer =\n typeof ResizeObserver === \"undefined\"\n ? undefined\n : new ResizeObserver(() => {\n if (panels.clientWidth > 0 && Math.abs(panels.clientWidth - drawnWidth) > 1) drawCharts();\n });\n observer?.observe(panels);\n\n return {\n state: () => state,\n destroy: () => {\n observer?.disconnect();\n if (frame !== 0) cancelAnimationFrame(frame);\n host.replaceChildren();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAkCA,MAAa,YAAY;;AAEzB,MAAa,YAAY;;;;;;AAMzB,MAAa,cAAc;;AAE3B,MAAa,oBAAoB;;AAEjC,MAAa,aAAa;;AAM1B,MAAa,WAAW;;;;;AA6JxB,SAAgB,WAAW,OAAsC;CAC/D,IAAI,OAAO,UAAU,UAAU,OAAO,oBAAoB,KAAK;CAC/D,IAAI;EACF,OAAO,oBAAoB,KAAK,MAAM,KAAK,CAAC;CAC9C,SAAS,OAAO;EACd,OAAO;GAAE,IAAI;GAAO,QAAQ,CAAC;IAAE,MAAM;IAAI,SAAS,0BAA0B,OAAO,KAAK,EAAE;GAAG,CAAC;EAAE;CAClG;AACF;AAEA,MAAM,aAAa,IAAI,KAAK,aAAa,SAAS,EAAE,0BAA0B,EAAE,CAAC;;AAGjF,SAAgB,YAAY,OAAmC;CAC7D,IAAI,UAAU,MAAM,OAAO;CAC3B,OAAO,OAAO,UAAU,WAAW,WAAW,OAAO,KAAK,IAAI;AAChE;;AAGA,SAAS,YAAY,QAAwB,IAA+B;CAC1E,MAAM,YAAY,OAAO,WAAW,MAAM,MAAM,EAAE,OAAO,EAAE;CAC3D,IAAI,cAAc,KAAA,GAAW,MAAM,IAAI,WAAW,gCAAgC,GAAG,GAAG;CACxF,OAAO;AACT;;AAGA,SAAS,eAAe,QAAwB,IAA6B;CAC3E,OAAO,OAAO,OAAO,SAAS,MAAM;EAClC,MAAM,QAAQ,EAAE,OAAO;EACvB,OAAO,UAAU,QAAQ,UAAU,KAAA,IAAY,CAAC,IAAI,CAAC,KAAK;CAC5D,CAAC;AACH;AAEA,MAAM,4BAAY,IAAI,QAA+D;;AAGrF,SAAS,gBAAgB,QAAwB,I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aAAa,GAAG,aAAa;GAAG,GAAG,MAAM,QAAQ,YAAY,QAAQ,OAAO,CAAC,CAAC,IAAI,MAAM;GAAG,GAAI,SAAS,OAAO,CAAC,IAAI,CAAC,IAAI;EAAE;EACnL,SAAS,gBAAgB,UAAU,MAAM,GAAG,IAAI;EAChD,IAAI,YAAY,KAAA,GACA,CAAC,GAAG,SAAS,iBAA8B,YAAY,CAAC,CAAC,CAAC,MAAM,OAAO,GAAG,QAAQ,WAAW,OACvG,CAAC,EAAE,MAAM;CAEjB;CAEA,QAAQ,iBAAiB,UAAU,WAAW;CAC9C,KAAK,gBAAgB,IAAI;CACzB,aAAa;CACb,SAAS;CAET,MAAM,WACJ,OAAO,mBAAmB,cACtB,KAAA,IACA,IAAI,qBAAqB;EACvB,IAAI,OAAO,cAAc,KAAK,KAAK,IAAI,OAAO,cAAc,UAAU,IAAI,GAAG,WAAW;CAC1F,CAAC;CACP,UAAU,QAAQ,MAAM;CAExB,OAAO;EACL,aAAa;EACb,eAAe;GACb,UAAU,WAAW;GACrB,IAAI,UAAU,GAAG,qBAAqB,KAAK;GAC3C,KAAK,gBAAgB;EACvB;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["s","svg"],"sources":["../../src/explorer/model.ts","../../src/explorer/view.ts"],"sourcesContent":["/**\n * The pure core of the response explorer: the state, the rules of the controls and the data of a view. This module\n * reads a record of the format `response-records/1` only with `@mark1russell7/rigor-statistics`. It has no DOM and no\n * clock of its own, so a test gives it each input.\n *\n * The rules of the controls follow the rules of a conditional dimension. The functions `axisChoices`, `facetChoices`\n * and `holdControls` offer only combinations that `sliceResponse` and `surfaceResponse` accept. The function `settle`\n * gives the nearest good state for any wanted state.\n */\n\nimport {\n heldOutError,\n parseResponseRecord,\n quantile,\n responseCells,\n sliceResponse,\n surfaceResponse,\n whenHolds,\n type ParsedResponseRecord,\n type ResponseBand,\n type ResponseCurvePoint,\n type ResponseDimension,\n type ResponseHeldOutError,\n type ResponseInputValue,\n type ResponseMeasure,\n type ResponseModel,\n type ResponsePoint,\n type ResponseRecord,\n type ResponseSlice,\n type ResponseSurface,\n type ResponseValue,\n} from \"@mark1russell7/rigor-statistics\";\n\n/** The largest number of values on a continuous axis. It is the default of `ResponseViewOptions.steps`. */\nexport const MAX_STEPS = 33;\n/** The smallest number of values on a continuous axis. A smaller grid shows too little of the response. */\nexport const MIN_STEPS = 5;\n/**\n * The largest number of point reads of one view. The field `nearest` of each place reads each point, so the cost of a\n * view is its number of places times the number of points. This number is a first bound, not a measured time.\n * `SURFACE_BUDGET_MS` corrects the grid when a surface takes too long on the device.\n */\nexport const READ_BUDGET = 400_000;\n/** The time of one surface in milliseconds. A longer surface gives a smaller grid for the next surface. */\nexport const SURFACE_BUDGET_MS = 50;\n/** The largest number of panels of one view. */\nexport const MAX_PANELS = 8;\n/** The largest number of stops of a held continuous dimension. */\nexport const MAX_STOPS = 33;\n/** The most levels that a row of buttons shows. A longer group is a select, so it does not push the chart down the page. */\nexport const MAX_CHIPS = 8;\n/** The distance from a measurement, from 0 to 1, at which a band has its weakest color. */\nexport const FADE_END = 0.5;\n/** The number of steps of the color scale of a surface. The CSS classes `rx-h0` to `rx-h8` give the colors. */\nexport const HEAT_STEPS = 9;\n\n/** The choices of a visitor. */\nexport interface ExplorerState {\n /** The id of the measure. */\n readonly measure: string;\n /** The id of the dimension of the horizontal axis. */\n readonly x: string;\n /** The id of the dimension of the vertical axis of a surface. The value `null` gives a curve. */\n readonly y: string | null;\n /** The id of the dimension with one panel for each of its values. The value `null` gives one panel. */\n readonly facet: string | null;\n /** The held value of each dimension. A dimension on an axis keeps its value for a later view. */\n readonly hold: Readonly<Record<string, ResponseValue>>;\n}\n\n/** The two axes of a view. */\nexport type AxisSlot = \"x\" | \"y\";\n\n/** A dimension that a control offers. */\nexport interface DimensionChoice {\n readonly id: string;\n readonly label: string;\n readonly disabled: boolean;\n /** The reason of a disabled choice. A good choice has an empty string. */\n readonly reason: string;\n}\n\n/** A value that a hold control offers. */\nexport interface HoldOption {\n readonly value: ResponseValue;\n readonly text: string;\n readonly disabled: boolean;\n readonly reason: string;\n}\n\n/** The control of one held dimension. */\nexport interface HoldControl {\n readonly id: string;\n readonly label: string;\n /** The value `levels` gives one button for each level. The value `stops` gives a slider over the measured values. */\n readonly kind: \"levels\" | \"stops\";\n /** The value `false` means that the dimension has no value at the held level of its parent. */\n readonly applies: boolean;\n /** The condition of the dimension, as text. A dimension with no condition has an empty string. */\n readonly note: string;\n readonly options: readonly HoldOption[];\n readonly value: ResponseValue;\n}\n\n/** One axis of a chart. A number axis has a linear or log place. A level axis has one equal band for each level. */\nexport interface AxisSpec {\n readonly id: string;\n readonly label: string;\n readonly kind: \"number\" | \"levels\";\n readonly log: boolean;\n /** The two ends of a number axis. */\n readonly range: readonly [number, number];\n /** The levels of a level axis. */\n readonly levels: readonly ResponseValue[];\n}\n\n/** The fields of each kind of panel. */\ninterface PanelBase {\n /** The name of the panel in a view with panels. The only panel of a view has an empty string. */\n readonly title: string;\n /** The value of the facet dimension in this panel. */\n readonly level: ResponseValue | null;\n}\n\n/** A fitted curve with its band and the measured points. */\nexport interface CurvePanel extends PanelBase {\n readonly kind: \"curve\";\n readonly slice: ResponseSlice;\n}\n\n/** A fitted surface. With `cells`, the view shows separate cells with their values, not a smooth surface. */\nexport interface SurfacePanel extends PanelBase {\n readonly kind: \"surface\";\n readonly cells: boolean;\n readonly surface: ResponseSurface;\n}\n\n/** A measured point of a panel with no model. */\nexport interface PlainPoint {\n readonly id: string;\n /** The value of each varied dimension. */\n readonly at: readonly ResponseValue[];\n readonly value: number;\n}\n\n/** The measured points of a measure with no model. */\nexport interface PointsPanel extends PanelBase {\n readonly kind: \"points\";\n readonly points: readonly PlainPoint[];\n}\n\n/** One panel of a view. */\nexport type ExplorerPanel = CurvePanel | SurfacePanel | PointsPanel;\n\n/** The data of one view. */\nexport interface ExplorerView {\n readonly measure: ResponseMeasure;\n readonly x: AxisSpec;\n readonly y: AxisSpec | null;\n readonly panels: readonly ExplorerPanel[];\n /** The value `true` gives a log value axis. */\n readonly log: boolean;\n /** The held-out error. A measure with no model has none. */\n readonly error: ResponseHeldOutError | null;\n /** The held-out error in plain words. */\n readonly errorText: string;\n /** The kind of the model in plain words. */\n readonly modelText: string;\n /** The size of the grid of a surface in plain words. A curve has an empty string. */\n readonly gridText: string;\n /** The places that the range of the measure moved, in plain words. With no such place, this is an empty string. */\n readonly rangeText: string;\n /** The text of a request that the record refused. A good view has an empty string. */\n readonly problem: string;\n /** The number of values on a continuous axis of this view. */\n readonly steps: number;\n /** The time of this view in milliseconds. */\n readonly elapsedMs: number;\n /** The largest number of steps of the next view. */\n readonly nextCap: number;\n}\n\n/** The inputs of `viewOf`. */\nexport interface ViewOptions {\n /** The largest number of steps. The value of `nextCap` of the last view goes here. */\n readonly stepsCap?: number;\n /** The time of a surface in milliseconds. The default is `SURFACE_BUDGET_MS`. */\n readonly budgetMs?: number;\n /** The clock in milliseconds. The default gives 0, so a view with no clock does not drop its grid. */\n readonly now?: () => number;\n}\n\n/** A rectangle of a table of numbers. */\nexport interface NumberTable {\n readonly columns: readonly string[];\n readonly rows: readonly (readonly string[])[];\n}\n\n/** One tick of an axis. */\nexport interface Tick {\n /** The place on the axis, from 0 to 1. */\n readonly place: number;\n readonly text: string;\n}\n\n/**\n * This function reads a record from JSON text or from parsed data. It does not throw: bad data gives faults with\n * their paths.\n */\nexport function openRecord(value: unknown): ParsedResponseRecord {\n if (typeof value !== \"string\") return parseResponseRecord(value);\n try {\n return parseResponseRecord(JSON.parse(value));\n } catch (error) {\n return { ok: false, faults: [{ path: \"\", message: `this text is not JSON: ${String(error)}.` }] };\n }\n}\n\nconst numberText = new Intl.NumberFormat(\"en-US\", { maximumSignificantDigits: 3 });\n\n/** This function gives the text of a value: a number with three significant digits, or the text of a level. */\nexport function formatValue(value: ResponseInputValue): string {\n if (value === null) return \"none\";\n return typeof value === \"number\" ? numberText.format(value) : value;\n}\n\n/** This function gives the dimension with an id that the state or the record names. */\nfunction dimensionOf(record: ResponseRecord, id: string): ResponseDimension {\n const dimension = record.dimensions.find((d) => d.id === id);\n if (dimension === undefined) throw new RangeError(`The record has no dimension \"${id}\".`);\n return dimension;\n}\n\n/** This function gives the measured values of a dimension, with no `null`. */\nfunction measuredValues(record: ResponseRecord, id: string): ResponseValue[] {\n return record.points.flatMap((p) => {\n const value = p.values[id];\n return value === null || value === undefined ? [] : [value];\n });\n}\n\nconst stopCache = new WeakMap<ResponseRecord, Map<string, readonly ResponseValue[]>>();\n\n/** This function gives the distinct measured values of a continuous dimension, in order. */\nfunction distinctNumbers(record: ResponseRecord, id: string): number[] {\n const numbers = measuredValues(record, id).filter((v) => typeof v === \"number\");\n return [...new Set(numbers)].sort((a, b) => a - b);\n}\n\n/**\n * This function gives the values that a visitor can hold: each level, or the measured values of a continuous dimension.\n * With more than `MAX_STOPS` measured values, it gives that number of quantiles of them.\n */\nexport function stopsOf(record: ResponseRecord, dimension: ResponseDimension): readonly ResponseValue[] {\n if (dimension.kind !== \"continuous\") return dimension.levels;\n let stops = stopCache.get(record);\n if (stops === undefined) stopCache.set(record, (stops = new Map()));\n const known = stops.get(dimension.id);\n if (known !== undefined) return known;\n const distinct = distinctNumbers(record, dimension.id);\n const thin = (): number[] => [...new Set(Array.from({ length: MAX_STOPS }, (_, i) => quantile(distinct, i / (MAX_STOPS - 1), \"nearest-rank\")))];\n const found = distinct.length === 0 ? [dimension.range[0]] : distinct.length > MAX_STOPS ? thin() : distinct;\n stops.set(dimension.id, found);\n return found;\n}\n\n/** This function gives the place of a number on a continuous dimension, from 0 to 1. */\nfunction shareOf(dimension: ResponseDimension & { kind: \"continuous\" }, value: number): number {\n const scale = (v: number): number => (dimension.log === true ? Math.log10(v) : v);\n const [low, high] = dimension.range;\n return (scale(value) - scale(low)) / (scale(high) - scale(low));\n}\n\n/**\n * This function gives the option `tolerance` of a view. A dimension with all its measured values as stops needs none.\n * A thinned dimension needs half of its largest gap, so each measured point matches a stop.\n */\nexport function toleranceOf(record: ResponseRecord): number {\n let tolerance = 0;\n for (const dimension of record.dimensions) {\n if (dimension.kind !== \"continuous\") continue;\n const stops = stopsOf(record, dimension) as readonly number[];\n if (stops.length === distinctNumbers(record, dimension.id).length) continue;\n for (let i = 1; i < stops.length; i++) {\n const gap = shareOf(dimension, stops[i] as number) - shareOf(dimension, stops[i - 1] as number);\n tolerance = Math.max(tolerance, gap / 2);\n }\n }\n return tolerance;\n}\n\n/** This function gives the usual value of a dimension: the measured median, or the most common level in `among`. */\nfunction usualValue(record: ResponseRecord, dimension: ResponseDimension, among?: readonly ResponseValue[]): ResponseValue {\n const values = measuredValues(record, dimension.id);\n if (dimension.kind === \"continuous\") {\n const numbers = values.filter((v) => typeof v === \"number\");\n return numbers.length === 0 ? dimension.range[0] : quantile(numbers, 0.5, \"nearest-rank\");\n }\n const levels: readonly ResponseValue[] = among ?? dimension.levels;\n const count = (level: ResponseValue): number => values.filter((v) => v === level).length;\n return levels.reduce((best, level) => (count(level) > count(best) ? level : best), levels[0] as ResponseValue);\n}\n\n/** This function gives the stop of a dimension that is nearest to a value, or `undefined` for a value of no use. */\nfunction nearestStop(record: ResponseRecord, dimension: ResponseDimension, value: ResponseValue | undefined): ResponseValue | undefined {\n const stops = stopsOf(record, dimension);\n if (value === undefined) return undefined;\n if (dimension.kind !== \"continuous\") return stops.includes(value) ? value : undefined;\n if (typeof value !== \"number\") return undefined;\n const far = (stop: ResponseValue): number => Math.abs(shareOf(dimension, stop as number) - shareOf(dimension, value));\n return stops.reduce((best, stop) => (far(stop) < far(best) ? stop : best));\n}\n\n/** This function gives the levels that the parent of each varied conditional dimension needs. */\nfunction neededLevels(record: ResponseRecord, varied: readonly string[]): Map<string, readonly ResponseValue[]> {\n const needed = new Map<string, readonly ResponseValue[]>();\n for (const id of varied) {\n const when = dimensionOf(record, id).when;\n if (when === undefined) continue;\n const earlier = needed.get(when.dimension);\n needed.set(when.dimension, earlier === undefined ? when.levels : earlier.filter((level) => when.levels.includes(level)));\n }\n return needed;\n}\n\n/** This function gives the condition of a dimension as a phrase of a sentence. */\nfunction whenText(record: ResponseRecord, dimension: ResponseDimension): string {\n const when = dimension.when;\n if (when === undefined) return \"\";\n return `only when ${dimensionOf(record, when.dimension).label} is ${when.levels.map(formatValue).join(\" or \")}`;\n}\n\nconst variedOf = (state: Pick<ExplorerState, \"x\" | \"y\">): string[] => (state.y === null ? [state.x] : [state.x, state.y]);\n\n/** This function gives the values of a dimension in panels, inside the needs of the varied dimensions. */\nfunction panelLevels(record: ResponseRecord, state: Pick<ExplorerState, \"x\" | \"y\">, id: string): readonly ResponseValue[] {\n const stops = stopsOf(record, dimensionOf(record, id));\n const needed = neededLevels(record, variedOf(state)).get(id);\n return needed === undefined ? stops : stops.filter((value) => needed.includes(value));\n}\n\n/** This function gives the reason that a dimension cannot be in panels. A good dimension gives an empty string. */\nfunction facetBlock(record: ResponseRecord, state: Pick<ExplorerState, \"x\" | \"y\" | \"hold\">, dimension: ResponseDimension): string {\n if (variedOf(state).includes(dimension.id)) return \"It is on an axis\";\n const when = dimension.when;\n if (when !== undefined && !variedOf(state).includes(when.dimension) && !when.levels.includes(state.hold[when.dimension] as ResponseValue)) return `It applies ${whenText(record, dimension)}`;\n const count = panelLevels(record, state, dimension.id).length;\n if (count > MAX_PANELS) return `It has ${count} values, and a view has ${MAX_PANELS} panels or fewer`;\n if (count < 2) return \"It has one value here\";\n return \"\";\n}\n\n/** This function gives the reason that a dimension cannot go on an axis. A good dimension gives an empty string. */\nfunction axisBlock(record: ResponseRecord, state: ExplorerState, slot: AxisSlot, dimension: ResponseDimension): string {\n const otherId = slot === \"x\" ? state.y : state.x;\n if (dimension.id === otherId) return \"It is on the other axis\";\n const other = otherId === null ? undefined : dimensionOf(record, otherId);\n if (other?.when?.dimension === dimension.id) return `${other.label} needs it held`;\n const when = dimension.when;\n if (when === undefined) return \"\";\n const parent = dimensionOf(record, when.dimension);\n if (parent.id === otherId) return `It needs ${parent.label} held`;\n const shared = other?.when?.dimension === parent.id ? when.levels.filter((level) => other.when?.levels.includes(level) === true) : when.levels;\n const inView = parent.id === state.facet ? stopsOf(record, parent) : [state.hold[parent.id] as ResponseValue];\n return inView.some((level) => shared.includes(level)) ? \"\" : `It applies ${whenText(record, dimension)}`;\n}\n\n/** This function gives the first dimension with no condition, and a continuous dimension before another kind. */\nfunction firstAxis(record: ResponseRecord): string {\n const plain = record.dimensions.filter((d) => d.when === undefined);\n const chosen = plain.find((d) => d.kind === \"continuous\") ?? plain[0] ?? record.dimensions[0];\n return (chosen as ResponseDimension).id;\n}\n\n/**\n * This function gives the nearest good state for a wanted state. Each unknown or missing field takes its usual value.\n * A parent moves to a level that a varied conditional dimension needs. A combination that a view refuses loses its\n * second axis or its panels.\n */\nexport function settle(record: ResponseRecord, wanted: Partial<ExplorerState> = {}): ExplorerState {\n const known = (id: string | null | undefined): boolean => id !== null && id !== undefined && record.dimensions.some((d) => d.id === id);\n const measure = record.measures.some((m) => m.id === wanted.measure) ? (wanted.measure as string) : (record.measures[0]?.id ?? \"\");\n const x = known(wanted.x) ? (wanted.x as string) : firstAxis(record);\n const parentOf = (id: string): string | undefined => dimensionOf(record, id).when?.dimension;\n let y = known(wanted.y) && wanted.y !== x ? (wanted.y as string) : null;\n if (y !== null && (parentOf(y) === x || parentOf(x) === y || [...neededLevels(record, [x, y]).values()].some((levels) => levels.length === 0))) y = null;\n\n const hold: Record<string, ResponseValue> = {};\n for (const dimension of record.dimensions) hold[dimension.id] = nearestStop(record, dimension, wanted.hold?.[dimension.id]) ?? usualValue(record, dimension);\n\n const facetId = known(wanted.facet) ? (wanted.facet as string) : null;\n const facet = facetId !== null && facetBlock(record, { x, y, hold }, dimensionOf(record, facetId)) === \"\" ? facetId : null;\n for (const [parent, levels] of neededLevels(record, variedOf({ x, y }))) {\n if (parent === facet || levels.includes(hold[parent] as ResponseValue)) continue;\n hold[parent] = usualValue(record, dimensionOf(record, parent), levels);\n }\n return { measure, x, y, facet: facet !== null && facetBlock(record, { x, y, hold }, dimensionOf(record, facet)) === \"\" ? facet : null, hold };\n}\n\n/** This function gives each dimension as a choice for an axis. A disabled choice tells its reason. */\nexport function axisChoices(record: ResponseRecord, state: ExplorerState, slot: AxisSlot): readonly DimensionChoice[] {\n return record.dimensions.map((d) => {\n const reason = axisBlock(record, state, slot, d);\n return { id: d.id, label: d.label, disabled: reason !== \"\", reason };\n });\n}\n\n/** This function gives each dimension as a choice for panels. A disabled choice tells its reason. */\nexport function facetChoices(record: ResponseRecord, state: ExplorerState): readonly DimensionChoice[] {\n return record.dimensions.map((d) => {\n const reason = facetBlock(record, state, d);\n return { id: d.id, label: d.label, disabled: reason !== \"\", reason };\n });\n}\n\n/** This function gives the control of each held dimension. A dimension on an axis or in panels has no control. */\nexport function holdControls(record: ResponseRecord, state: ExplorerState): readonly HoldControl[] {\n const needed = neededLevels(record, variedOf(state));\n const held = record.dimensions.filter((d) => !variedOf(state).includes(d.id) && d.id !== state.facet);\n return held.map((d) => {\n const parent = d.when?.dimension;\n const open = parent === undefined || parent === state.facet || variedOf(state).includes(parent);\n const applies = open || d.when?.levels.includes(state.hold[parent as string] as ResponseValue) === true;\n const levels = needed.get(d.id);\n const options = stopsOf(record, d).map((value): HoldOption => {\n const locked = levels !== undefined && !levels.includes(value);\n const reason = !applies ? `It applies ${whenText(record, d)}` : locked ? \"A varied dimension has no value at this level\" : \"\";\n return { value, text: formatValue(value), disabled: reason !== \"\", reason };\n });\n const note = d.when === undefined ? \"\" : `Applies ${whenText(record, d)}`;\n return { id: d.id, label: d.label, kind: d.kind === \"continuous\" ? \"stops\" : \"levels\", applies, note, options, value: state.hold[d.id] as ResponseValue };\n });\n}\n\n/** This function gives the form of a group of levels. */\nexport function levelForm(count: number): \"chips\" | \"select\" {\n return count > MAX_CHIPS ? \"select\" : \"chips\";\n}\n\n/** This function gives the state with a new measure. */\nexport function setMeasure(record: ResponseRecord, state: ExplorerState, measure: string): ExplorerState {\n return settle(record, { ...state, measure });\n}\n\n/** This function gives the state with a new axis. It does not take a disabled choice. The value `null` removes the y axis. */\nexport function setAxis(record: ResponseRecord, state: ExplorerState, slot: AxisSlot, id: string | null): ExplorerState {\n if (id === null) return slot === \"y\" ? settle(record, { ...state, y: null }) : state;\n if (axisBlock(record, state, slot, dimensionOf(record, id)) !== \"\") return state;\n return settle(record, { ...state, [slot]: id, facet: state.facet === id ? null : state.facet });\n}\n\n/** This function gives the state with new panels. It does not take a disabled choice. The value `null` gives one panel. */\nexport function setFacet(record: ResponseRecord, state: ExplorerState, id: string | null): ExplorerState {\n if (id !== null && facetBlock(record, state, dimensionOf(record, id)) !== \"\") return state;\n return settle(record, { ...state, facet: id });\n}\n\n/** This function gives the state with a new held value. It does not take a disabled value. */\nexport function setHold(record: ResponseRecord, state: ExplorerState, id: string, value: ResponseValue): ExplorerState {\n const control = holdControls(record, state).find((c) => c.id === id);\n const option = control?.options.find((o) => o.value === value);\n if (option === undefined || option.disabled) return state;\n return settle(record, { ...state, hold: { ...state.hold, [id]: value } });\n}\n\n/**\n * This function gives the number of steps of a view, from the number of points, before the call. The field `nearest`\n * reads each point at each place, so the number of places comes from `READ_BUDGET`.\n *\n * @param points - The number of points of the record.\n * @param panels - The number of panels of the view.\n * @param continuous - The number of continuous axes of the view.\n * @param levels - The number of levels of a level axis of a surface, or 1.\n * @param cap - The largest result.\n */\nexport function planSteps(points: number, panels: number, continuous: number, levels: number, cap: number = MAX_STEPS): number {\n const places = READ_BUDGET / (Math.max(1, points) * Math.max(1, panels));\n const room = continuous === 2 ? Math.sqrt(places) : places / Math.max(1, levels);\n return Math.max(MIN_STEPS, Math.min(cap, MAX_STEPS, Math.floor(room)));\n}\n\n/** This function gives the cap of the next view: a smaller grid when this surface took more than the budget. */\nexport function nextStepsCap(steps: number, elapsedMs: number, budgetMs: number): number {\n if (elapsedMs <= budgetMs) return Number.POSITIVE_INFINITY;\n return Math.max(MIN_STEPS, Math.min(steps - 1, Math.floor(steps * Math.sqrt(budgetMs / elapsedMs))));\n}\n\n/** This function gives the axis of a dimension. */\nexport function axisOf(dimension: ResponseDimension): AxisSpec {\n const { id, label, unit } = dimension;\n const name = unit === \"\" ? label : `${label} (${unit})`;\n if (dimension.kind === \"continuous\") return { id, label: name, kind: \"number\", log: dimension.log === true, range: dimension.range, levels: [] };\n return { id, label: name, kind: \"levels\", log: false, range: [0, 1], levels: dimension.levels };\n}\n\n/** This function gives the place of a value on an axis, from 0 to 1. A value outside a number axis goes past the ends. */\nexport function placeOn(axis: AxisSpec, value: ResponseValue): number {\n if (axis.kind === \"levels\") return (axis.levels.indexOf(value) + 0.5) / axis.levels.length;\n const scale = (v: number): number => (axis.log ? Math.log10(v) : v);\n const [low, high] = axis.range;\n return (scale(value as number) - scale(low)) / (scale(high) - scale(low));\n}\n\n/** This function gives true for a point that matches the held values, with the rules of `sliceResponse`. */\nfunction pointMatches(record: ResponseRecord, point: ResponsePoint, measure: string, varied: readonly string[], hold: Readonly<Record<string, ResponseValue>>, tolerance: number): boolean {\n if (typeof point.measures[measure] !== \"number\") return false;\n return record.dimensions.every((d) => {\n const value = point.values[d.id] ?? null;\n if (varied.includes(d.id)) return value !== null;\n const wanted = whenHolds(d, point.values) ? (hold[d.id] as ResponseValue) : null;\n if (typeof value !== \"number\" || typeof wanted !== \"number\" || d.kind !== \"continuous\") return value === wanted;\n return Math.abs(shareOf(d, value) - shareOf(d, wanted)) <= tolerance;\n });\n}\n\n/** This function gives the error of a measure in plain words. */\nexport function errorSentence(measure: ResponseMeasure, model: ResponseModel, error: ResponseHeldOutError): string {\n const unit = measure.unit === \"\" ? \"\" : ` ${measure.unit}`;\n const amount = (value: number): string => (model.scale === \"log\" ? `a factor of ${formatValue(10 ** value)}` : `${formatValue(value)}${unit}`);\n const seen = `On ${error.n} points that each fit did not see, over ${error.folds} folds, the model misses by ${amount(error.mae)} on average.`;\n const base = `A plain mean misses by ${amount(error.baselineMae)}.`;\n if (error.skill === null) return `${seen} ${base}`;\n return error.skill > 0 ? `${seen} ${base} The model removes ${Math.round(error.skill * 100)}% of that miss.` : `${seen} ${base} The model is no better than the mean.`;\n}\n\n/** This function gives the name of a panel. */\nconst panelTitle = (facet: ResponseDimension | undefined, level: ResponseValue | null): string => (facet === undefined || level === null ? \"\" : `${facet.label}: ${formatValue(level)}`);\n\n/** This function gives the panels of a measure with no model: the measured points that match the held values. */\nfunction pointPanels(record: ResponseRecord, state: ExplorerState, levels: readonly (ResponseValue | null)[], facet: ResponseDimension | undefined, tolerance: number): ExplorerPanel[] {\n const varied = variedOf(state);\n return levels.map((level) => {\n const hold = level === null || facet === undefined ? state.hold : { ...state.hold, [facet.id]: level };\n const points = record.points.flatMap((p): PlainPoint[] => {\n if (!pointMatches(record, p, state.measure, varied, hold, tolerance)) return [];\n return [{ id: p.id, at: varied.map((id) => p.values[id] as ResponseValue), value: p.measures[state.measure] as number }];\n });\n return { kind: \"points\", title: panelTitle(facet, level), level, points };\n });\n}\n\n/** This function gives the held values of a request: each dimension that does not vary. */\nfunction requestHold(state: ExplorerState, facet: ResponseDimension | undefined, level: ResponseValue | null): Record<string, ResponseValue> {\n const varied = variedOf(state);\n const hold = Object.fromEntries(Object.entries(state.hold).filter(([id]) => !varied.includes(id)));\n return facet === undefined || level === null ? hold : { ...hold, [facet.id]: level };\n}\n\n/** This function gives the text of the size of a grid. */\nfunction gridSentence(x: readonly ResponseValue[], y: readonly ResponseValue[], cells: boolean, elapsedMs: number, budgetMs: number): string {\n if (cells) return `The grid has ${x.length} by ${y.length} measured levels.`;\n const size = `The grid has ${x.length} by ${y.length} places.`;\n return elapsedMs > budgetMs ? `${size} This surface took ${Math.round(elapsedMs)} ms, so the next grid is smaller.` : size;\n}\n\n/** This function gives the text of the places that a range moved. A view with no such place gives an empty string. */\nfunction rangeSentence(measure: ResponseMeasure, panels: readonly ExplorerPanel[]): string {\n const moved = panels.reduce((count, panel) => count + (panel.kind === \"curve\" ? panel.slice.clipped : panel.kind === \"surface\" ? panel.surface.clipped : 0), 0);\n if (moved === 0 || measure.range === undefined) return \"\";\n return `At ${moved} ${moved === 1 ? \"place\" : \"places\"}, the view stops at the range of the measure, ${measure.range[0]} to ${measure.range[1]}.`;\n}\n\n/** This function gives the steps of a view from its axes and the plan of `planSteps`. */\nfunction stepsOfView(record: ResponseRecord, state: ExplorerState, panels: number, cap: number): number {\n const continuous = variedOf(state).filter((id) => dimensionOf(record, id).kind === \"continuous\").length;\n // A count at 2 steps, less the 2 of each continuous axis, leaves the levels of the other axes.\n const levels = responseCells(record, state.y === null ? state.x : [state.x, state.y], 2) / 2 ** continuous;\n return planSteps(record.points.length, panels, continuous, levels, cap);\n}\n\n/**\n * This function gives the data of a view. It does not throw. A request that the record refuses gives the text in\n * `problem`, and no panels. A measure with no model gives only the measured points, and a table model gives cells.\n * A smooth model that is no better than a plain mean also gives only the measured points. A drawn fit claims knowledge that such a model does not have.\n * A table model keeps its cells at any error, because each cell is the mean of measured points.\n */\nexport function viewOf(record: ResponseRecord, state: ExplorerState, options: ViewOptions = {}): ExplorerView {\n const { budgetMs = SURFACE_BUDGET_MS, stepsCap = MAX_STEPS, now = (): number => 0 } = options;\n const measure = record.measures.find((m) => m.id === state.measure) ?? (record.measures[0] as ResponseMeasure);\n const model = record.models.find((m) => m.measure === measure.id);\n const x = axisOf(dimensionOf(record, state.x));\n const y = state.y === null ? null : axisOf(dimensionOf(record, state.y));\n const facet = state.facet === null ? undefined : dimensionOf(record, state.facet);\n const levels = facet === undefined ? [null] : panelLevels(record, state, facet.id);\n const steps = stepsOfView(record, state, levels.length, stepsCap);\n const tolerance = toleranceOf(record);\n const base = { measure, x, y, log: model?.scale === \"log\", steps, elapsedMs: 0, nextCap: stepsCap, gridText: \"\", rangeText: \"\", problem: \"\" };\n\n if (model === undefined) {\n const modelText = \"This measure has no valid model in the record, so the view shows only the measured points.\";\n return { ...base, panels: pointPanels(record, state, levels, facet, tolerance), error: null, errorText: \"\", modelText };\n }\n const modelText = model.kind === \"table\" ? \"The model is the mean of each measured cell, so the view shows cells and no smooth surface.\" : \"The model is a smooth fit over all the dimensions.\";\n try {\n const heldOut = heldOutError(record, measure.id);\n if (model.kind !== \"table\" && heldOut.skill !== null && heldOut.skill <= 0) {\n const noBetter = \"The model is no better than a plain mean on points that it did not see, so the view shows only the measured points.\";\n return { ...base, panels: pointPanels(record, state, levels, facet, tolerance), error: heldOut, errorText: errorSentence(measure, model, heldOut), modelText: noBetter };\n }\n const start = now();\n const panels = levels.map((level): ExplorerPanel => {\n const hold = requestHold(state, facet, level);\n const title = panelTitle(facet, level);\n if (state.y === null) return { kind: \"curve\", title, level, slice: sliceResponse(record, measure.id, { vary: state.x, hold, steps, tolerance }) };\n const surface = surfaceResponse(record, measure.id, { vary: [state.x, state.y], hold, steps, tolerance });\n return { kind: \"surface\", title, level, cells: model.kind === \"table\" || (x.kind === \"levels\" && y?.kind === \"levels\"), surface };\n });\n const elapsedMs = Math.max(0, now() - start);\n const first = panels[0];\n const surface = first?.kind === \"surface\" ? first : undefined;\n const late = surface !== undefined && !surface.cells ? nextStepsCap(steps, elapsedMs, budgetMs) : Number.POSITIVE_INFINITY;\n const gridText = surface === undefined ? \"\" : gridSentence(surface.surface.x, surface.surface.y, surface.cells, elapsedMs, budgetMs);\n return { ...base, panels, error: heldOut, errorText: errorSentence(measure, model, heldOut), modelText, gridText, rangeText: rangeSentence(measure, panels), elapsedMs, nextCap: Math.min(stepsCap, late) };\n } catch (error) {\n return { ...base, panels: [], error: null, errorText: \"\", modelText, problem: error instanceof Error ? error.message : String(error) };\n }\n}\n\n/** This function gives the strength of the band at a distance from a measurement: 1 at a measurement, 0.15 far away. */\nexport function fadeOf(nearest: number): number {\n return 1 - 0.85 * Math.min(1, nearest / FADE_END);\n}\n\n/** This function gives the share of the neutral veil of a surface cell at a distance from a measurement. */\nexport function veilOf(nearest: number): number {\n return 0.8 * Math.min(1, nearest / FADE_END);\n}\n\n/** This function gives a round step for a range and a tick count: 1, 2 or 5 times a power of 10. */\nfunction roundStep(span: number, count: number): number {\n const raw = span / Math.max(1, count);\n const power = 10 ** Math.floor(Math.log10(raw));\n const share = raw / power;\n return (share <= 1 ? 1 : share <= 2 ? 2 : share <= 5 ? 5 : 10) * power;\n}\n\n/** This function gives round numbers in a range, for approximately `count` ticks. */\nfunction roundNumbers(low: number, high: number, count: number): number[] {\n if (!(high > low)) return [low];\n const step = roundStep(high - low, count);\n const out: number[] = [];\n for (let i = Math.ceil(low / step - 1e-9); i * step <= high + step * 1e-9; i++) out.push(Number((i * step).toPrecision(12)));\n return out;\n}\n\n/** This function gives the values 1, 2 and 5 times each power of 10 in a range, for approximately `count` ticks. */\nfunction logNumbers(low: number, high: number, count: number): number[] {\n const out: number[] = [];\n for (let power = Math.floor(Math.log10(low)); power <= Math.ceil(Math.log10(high)); power++) {\n for (const factor of [1, 2, 5]) {\n const value = Number((factor * 10 ** power).toPrecision(12));\n if (value >= low * (1 - 1e-9) && value <= high * (1 + 1e-9)) out.push(value);\n }\n }\n const powers = out.filter((value) => Number.isInteger(Math.log10(value)));\n return out.length > count && powers.length >= 2 ? powers : out;\n}\n\n/** This function gives the ticks of a number range. A log range with too few round values gives linear round values. */\nexport function numberTicks(low: number, high: number, log: boolean, count: number): readonly Tick[] {\n const scale = (v: number): number => (log ? Math.log10(v) : v);\n const logged = log ? logNumbers(low, high, count) : [];\n const values = logged.length >= 3 ? logged : roundNumbers(low, high, count);\n return values.map((value) => ({ place: high > low ? (scale(value) - scale(low)) / (scale(high) - scale(low)) : 0.5, text: formatValue(value) }));\n}\n\n/** This function gives the ticks of an axis. */\nexport function axisTicks(axis: AxisSpec, count: number): readonly Tick[] {\n if (axis.kind === \"number\") return numberTicks(axis.range[0], axis.range[1], axis.log, count);\n return axis.levels.map((level) => ({ place: placeOn(axis, level), text: formatValue(level) }));\n}\n\n/** This function gives the values of one panel that the value axis must show. */\nfunction panelValues(panel: ExplorerPanel, varied: number): number[] {\n if (panel.kind === \"points\") return varied === 1 ? panel.points.map((p) => p.value) : [];\n if (panel.kind === \"curve\") return [...panel.slice.curve.flatMap((c) => [c.low, c.high]), ...panel.slice.points.map((p) => p.value)];\n return [];\n}\n\n/**\n * This function gives the two ends of the value axis of a curve view. All the panels of a view share them, so two\n * panels compare by eye. A range of one value grows, so the axis keeps a length.\n */\nexport function valueRange(view: ExplorerView): readonly [number, number] {\n const values = view.panels.flatMap((panel) => panelValues(panel, view.y === null ? 1 : 2)).filter((v) => Number.isFinite(v) && (!view.log || v > 0));\n if (values.length === 0) return view.log ? [1, 10] : [0, 1];\n const low = Math.min(...values);\n const high = Math.max(...values);\n if (view.log) {\n const margin = high > low ? (high / low) ** 0.05 : 2;\n return [low / margin, high * margin];\n }\n const margin = high > low ? (high - low) * 0.05 : Math.max(Math.abs(low) * 0.1, 1);\n return [low - margin, high + margin];\n}\n\n/** This function gives each fitted value of a surface view, with the values of a view of plain points. */\nfunction heatValues(view: ExplorerView): number[] {\n return view.panels.flatMap((panel) => {\n if (panel.kind === \"surface\") return panel.surface.cells.flatMap((row) => row.map((cell) => cell.value));\n return panel.kind === \"points\" ? panel.points.map((p) => p.value) : [];\n });\n}\n\n/** This function gives the two ends of the color scale of a surface view. All the panels share them. */\nexport function heatRange(view: ExplorerView): readonly [number, number] {\n const values = heatValues(view).filter((v) => Number.isFinite(v) && (!view.log || v > 0));\n if (values.length === 0) return [0, 1];\n return [Math.min(...values), Math.max(...values)];\n}\n\n/** This function gives the step of the color scale of a value, from 0 to `HEAT_STEPS - 1`. */\nexport function heatStep(value: number, range: readonly [number, number], log: boolean): number {\n const [low, high] = range;\n if (!(high > low)) return Math.floor(HEAT_STEPS / 2);\n const share = log ? (Math.log10(value) - Math.log10(low)) / (Math.log10(high) - Math.log10(low)) : (value - low) / (high - low);\n return Math.max(0, Math.min(HEAT_STEPS - 1, Math.floor(share * HEAT_STEPS)));\n}\n\n/** This function gives the edges of the cells around places on an axis, from 0 to 1. There is one more edge than places. */\nexport function cellEdges(places: readonly number[]): readonly number[] {\n const inner = places.slice(1).map((place, i) => (place + (places[i] as number)) / 2);\n return [0, ...inner, 1];\n}\n\n/** A point of a path, in the pixels of a chart. */\nexport type Pixel = readonly [number, number];\n\n/** This function gives the path of a line through pixels. */\nexport function linePath(pixels: readonly Pixel[]): string {\n return pixels.map(([x, y], i) => `${i === 0 ? \"M\" : \"L\"}${x.toFixed(1)} ${y.toFixed(1)}`).join(\"\");\n}\n\n/** This function gives the closed path of a band between its upper and its lower pixels. */\nexport function bandPath(upper: readonly Pixel[], lower: readonly Pixel[]): string {\n return `${linePath([...upper, ...[...lower].reverse()])}Z`;\n}\n\n/** This function gives the distance from a measurement in plain words. */\nfunction nearText(nearest: number): string {\n return nearest === 0 ? \"A point was measured here.\" : `The nearest measured point is ${Math.round(nearest * 100)}% of an axis away.`;\n}\n\n/** This function gives the text of one place of a band. */\nfunction bandText(band: ResponseBand): string {\n return `fitted ${formatValue(band.value)}, band ${formatValue(band.low)} to ${formatValue(band.high)}. ${nearText(band.nearest)}`;\n}\n\n/** This function gives the text of one place of a curve. */\nexport function curveText(axis: AxisSpec, place: ResponseCurvePoint): string {\n return `${axis.label} ${formatValue(place.at)}: ${bandText(place)}`;\n}\n\n/** This function gives the text of one place of a surface. */\nexport function cellText(x: AxisSpec, y: AxisSpec, atX: ResponseValue, atY: ResponseValue, band: ResponseBand): string {\n return `${x.label} ${formatValue(atX)}, ${y.label} ${formatValue(atY)}: ${bandText(band)}`;\n}\n\n/** This function gives the numbers of a panel: each place of a curve, or the measured points of a surface. */\nexport function numberTable(view: ExplorerView, panel: ExplorerPanel): NumberTable {\n const axes = view.y === null ? [view.x.label] : [view.x.label, view.y.label];\n if (panel.kind === \"curve\") {\n const rows = panel.slice.curve.map((c) => [formatValue(c.at), formatValue(c.value), formatValue(c.low), formatValue(c.high), `${Math.round(c.nearest * 100)}%`]);\n return { columns: [view.x.label, \"Fitted\", \"Low\", \"High\", \"Distance\"], rows };\n }\n const points: readonly { readonly at: readonly ResponseValue[]; readonly value: number }[] = panel.kind === \"points\" ? panel.points : panel.surface.points;\n return { columns: [...axes, \"Measured\"], rows: points.map((p) => [...p.at.map(formatValue), formatValue(p.value)]) };\n}\n","/// <reference lib=\"dom\" />\n/**\n * The DOM view of the response explorer. This module draws SVG with no framework. The core in `model.ts` gives each\n * rule and each number, and this module connects the core to the page.\n */\n\nimport { h, svg as s, type Child } from \"../chrome.ts\";\nimport {\n axisChoices,\n axisTicks,\n bandPath,\n cellEdges,\n cellText,\n curveText,\n facetChoices,\n fadeOf,\n formatValue,\n heatRange,\n heatStep,\n HEAT_STEPS,\n holdControls,\n levelForm,\n linePath,\n MAX_STEPS,\n numberTable,\n numberTicks,\n openRecord,\n placeOn,\n setAxis,\n setFacet,\n setHold,\n setMeasure,\n settle,\n SURFACE_BUDGET_MS,\n valueRange,\n veilOf,\n viewOf,\n type AxisSpec,\n type CurvePanel,\n type DimensionChoice,\n type ExplorerPanel,\n type ExplorerState,\n type ExplorerView,\n type HoldControl,\n type Pixel,\n type PointsPanel,\n type SurfacePanel,\n type Tick,\n} from \"./model.ts\";\nimport type { ResponseRecord, ResponseValue } from \"@mark1russell7/rigor-statistics\";\n\n/** The options of `mountExplorer`. */\nexport interface ExplorerOptions {\n /** The first state. The explorer corrects a state that a record refuses. */\n readonly initial?: Partial<ExplorerState>;\n /** The time of a surface in milliseconds. The default is `SURFACE_BUDGET_MS`. */\n readonly budgetMs?: number;\n /** The clock in milliseconds. The default is `performance.now`. */\n readonly now?: () => number;\n}\n\n/** The result of `mountExplorer`. */\nexport interface ExplorerHandle {\n /** This method gives the choices of the visitor. It gives `null` for a record with faults. */\n state(): ExplorerState | null;\n /** This method removes the explorer from its host. */\n destroy(): void;\n}\n\n/** The most faults that the view lists. */\nconst MAX_FAULTS = 20;\n/** The width of a chart with no layout, for example in a test. */\nconst FALLBACK_WIDTH = 640;\nconst MARGIN = { top: 10, right: 14, bottom: 42, left: 50 };\n/** The height of a line of text of an axis, in pixels. */\nconst CHAR_WIDTH = 6.4;\n\nlet mounts = 0;\n\n/** The plot of a chart: the pixels of its area and of its axes. */\ninterface Plot {\n readonly width: number;\n readonly height: number;\n readonly left: number;\n readonly top: number;\n readonly right: number;\n readonly bottom: number;\n}\n\n/** This function gives the plot of a chart. Long level names need room for their turned text. */\nfunction plotOf(width: number, height: number, view: ExplorerView): Plot {\n const turned = turnedLevels(view.x, width - MARGIN.left - MARGIN.right);\n const longest = Math.max(0, ...view.x.levels.map((level) => formatValue(level).length));\n const bottom = height - MARGIN.bottom - (turned ? Math.min(60, longest * CHAR_WIDTH * 0.7) : 0);\n const left = view.y?.kind === \"levels\" ? Math.min(110, Math.max(MARGIN.left, 12 + Math.max(...view.y.levels.map((level) => formatValue(level).length)) * CHAR_WIDTH)) : MARGIN.left;\n return { width, height, left, top: MARGIN.top, right: width - MARGIN.right, bottom };\n}\n\n/** This function gives true when the levels of an axis do not fit side by side. */\nfunction turnedLevels(axis: AxisSpec, room: number): boolean {\n if (axis.kind !== \"levels\") return false;\n const longest = Math.max(0, ...axis.levels.map((level) => formatValue(level).length));\n return (longest + 1) * CHAR_WIDTH > room / Math.max(1, axis.levels.length);\n}\n\n/** This function gives the ticks of an axis that fit in a length. */\nfunction fittedTicks(axis: AxisSpec, length: number): readonly Tick[] {\n return axisTicks(axis, Math.max(2, Math.floor(length / 70)));\n}\n\n/** This function draws the horizontal axis. */\nfunction xAxis(plot: Plot, axis: AxisSpec): SVGElement {\n const length = plot.right - plot.left;\n const turned = turnedLevels(axis, length);\n const ticks = fittedTicks(axis, length).map((tick) => {\n const x = plot.left + tick.place * length;\n const label = turned\n ? s(\"text\", { class: \"rx-tick\", x, y: plot.bottom + 14, \"text-anchor\": \"end\", transform: `rotate(-35 ${x} ${plot.bottom + 14})` }, tick.text)\n : s(\"text\", { class: \"rx-tick\", x, y: plot.bottom + 15, \"text-anchor\": x + (tick.text.length * CHAR_WIDTH) / 2 > plot.width ? \"end\" : \"middle\" }, tick.text);\n return s(\"g\", {}, s(\"line\", { class: \"rx-axis\", x1: x, x2: x, y1: plot.bottom, y2: plot.bottom + 4 }), label);\n });\n const name = s(\"text\", { class: \"rx-axis-name\", x: (plot.left + plot.right) / 2, y: plot.height - 6, \"text-anchor\": \"middle\" }, axis.log ? `${axis.label}, log scale` : axis.label);\n return s(\"g\", {}, s(\"line\", { class: \"rx-axis\", x1: plot.left, x2: plot.right, y1: plot.bottom, y2: plot.bottom }), ...ticks, name);\n}\n\n/** This function draws the value axis with its grid lines. */\nfunction valueAxis(plot: Plot, ticks: readonly Tick[]): SVGElement {\n const length = plot.bottom - plot.top;\n const lines = ticks.map((tick) => {\n const y = plot.bottom - tick.place * length;\n return s(\"g\", {}, s(\"line\", { class: \"rx-grid\", x1: plot.left, x2: plot.right, y1: y, y2: y }), s(\"text\", { class: \"rx-tick\", x: plot.left - 6, y: y + 4, \"text-anchor\": \"end\" }, tick.text));\n });\n return s(\"g\", {}, ...lines);\n}\n\n/** This function draws the vertical axis of a surface. */\nfunction surfaceAxis(plot: Plot, axis: AxisSpec): SVGElement {\n const length = plot.bottom - plot.top;\n const ticks = axisTicks(axis, Math.max(2, Math.floor(length / 45))).map((tick) => {\n const y = plot.bottom - tick.place * length;\n return s(\"text\", { class: \"rx-tick\", x: plot.left - 6, y: y + 4, \"text-anchor\": \"end\" }, tick.text);\n });\n return s(\"g\", {}, ...ticks);\n}\n\n/** The scale of the value axis of a view. */\ninterface ValueScale {\n readonly range: readonly [number, number];\n readonly log: boolean;\n}\n\n/** This function gives the place of a value on the value axis, from 0 to 1. */\nfunction valuePlace(scale: ValueScale, value: number): number {\n const [low, high] = scale.range;\n if (scale.log) return (Math.log10(Math.max(value, low)) - Math.log10(low)) / (Math.log10(high) - Math.log10(low));\n return (value - low) / (high - low);\n}\n\n/** This function gives a small steady offset for a dot from its id, so the dots of one level do not all overlap. */\nfunction jitter(id: string, room: number): number {\n let hash = 7;\n for (const char of id) hash = (hash * 31 + (char.codePointAt(0) ?? 0)) % 1009;\n return (hash / 1008 - 0.5) * room;\n}\n\n/** The handler of a panel: it moves the mark of the cursor and it gives the text of a place. */\ninterface Cursor {\n /** The number of places across and up. */\n readonly columns: number;\n readonly rows: number;\n /** This method gives the place at a pixel. */\n at(x: number, y: number): readonly [number, number];\n /** This method moves the mark and gives the text of the place. */\n show(column: number, row: number): string;\n}\n\n/** This function connects the pointer and the arrow keys of a chart to its cursor. */\nfunction connect(svg: SVGElement, cursor: Cursor, tell: (text: string) => void): void {\n let column = -1;\n let row = 0;\n const move = (nextColumn: number, nextRow: number): void => {\n column = Math.max(0, Math.min(cursor.columns - 1, nextColumn));\n row = Math.max(0, Math.min(cursor.rows - 1, nextRow));\n tell(cursor.show(column, row));\n };\n svg.addEventListener(\"pointermove\", (event) => {\n const box = svg.getBoundingClientRect();\n const [c, r] = cursor.at((event as PointerEvent).clientX - box.left, (event as PointerEvent).clientY - box.top);\n move(c, r);\n });\n svg.addEventListener(\"keydown\", (event) => {\n const steps: Readonly<Record<string, readonly [number, number]>> = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] };\n const step = steps[(event as KeyboardEvent).key];\n if (step === undefined) return;\n event.preventDefault();\n move(column < 0 ? 0 : column + step[0], row + step[1]);\n });\n}\n\n/** This function makes the frame of a chart with its text for a screen reader. */\nfunction chartFrame(plot: Plot, label: string): SVGElement {\n return s(\"svg\", { class: \"rx-svg\", width: plot.width, height: plot.height, viewBox: `0 0 ${plot.width} ${plot.height}`, role: \"img\", \"aria-label\": label, tabindex: 0 });\n}\n\n/** This function draws a band with one strength for each place along the axis. */\nfunction fadedBand(plot: Plot, panel: CurvePanel, scale: ValueScale, axis: AxisSpec, id: string): SVGElement[] {\n const length = plot.right - plot.left;\n const height = plot.bottom - plot.top;\n const curve = panel.slice.curve;\n const px = (at: ResponseValue): number => plot.left + placeOn(axis, at) * length;\n const py = (value: number): number => plot.bottom - valuePlace(scale, value) * height;\n const stops = curve.map((place) => s(\"stop\", { class: \"rx-band-stop\", offset: placeOn(axis, place.at), \"stop-opacity\": fadeOf(place.nearest).toFixed(3) }));\n const gradient = s(\"linearGradient\", { id, gradientUnits: \"userSpaceOnUse\", x1: plot.left, x2: plot.right, y1: 0, y2: 0 }, ...stops);\n const upper = curve.map((place): Pixel => [px(place.at), py(place.high)]);\n const lower = curve.map((place): Pixel => [px(place.at), py(place.low)]);\n return [s(\"defs\", {}, gradient), s(\"path\", { class: \"rx-band\", d: bandPath(upper, lower), fill: `url(#${id})` })];\n}\n\n/** This function draws a band and a mark at each level of a level axis. */\nfunction levelMarks(plot: Plot, panel: CurvePanel, scale: ValueScale, axis: AxisSpec): SVGElement[] {\n const length = plot.right - plot.left;\n const height = plot.bottom - plot.top;\n const room = Math.min(44, (length / Math.max(1, axis.levels.length)) * 0.5);\n return panel.slice.curve.flatMap((place) => {\n const x = plot.left + placeOn(axis, place.at) * length;\n const top = plot.bottom - valuePlace(scale, place.high) * height;\n const bottom = plot.bottom - valuePlace(scale, place.low) * height;\n const y = plot.bottom - valuePlace(scale, place.value) * height;\n return [\n s(\"rect\", { class: \"rx-whisker\", x: x - room / 2, y: top, width: room, height: Math.max(1, bottom - top), rx: 4, \"fill-opacity\": (0.3 * fadeOf(place.nearest)).toFixed(3) }),\n s(\"line\", { class: \"rx-line\", x1: x - room / 2, x2: x + room / 2, y1: y, y2: y }),\n ];\n });\n}\n\n/** This function draws a chart with a fitted curve, its band and the measured points. */\nfunction curveChart(view: ExplorerView, panel: CurvePanel, width: number, id: string, tell: (text: string) => void): SVGElement {\n const plot = plotOf(width, 270, view);\n const scale: ValueScale = { range: valueRange(view), log: view.log };\n const length = plot.right - plot.left;\n const height = plot.bottom - plot.top;\n const curve = panel.slice.curve;\n const px = (at: ResponseValue): number => plot.left + placeOn(view.x, at) * length;\n const py = (value: number): number => plot.bottom - valuePlace(scale, value) * height;\n const smooth = view.x.kind === \"number\";\n const marks = smooth\n ? [...fadedBand(plot, panel, scale, view.x, id), s(\"path\", { class: \"rx-line\", d: linePath(curve.map((place): Pixel => [px(place.at), py(place.value)])) })]\n : levelMarks(plot, panel, scale, view.x);\n const room = smooth ? 0 : Math.min(30, (length / Math.max(1, view.x.levels.length)) * 0.35);\n const dots = panel.slice.points.map((point) => s(\"circle\", { class: \"rx-dot\", cx: px(point.at) + jitter(point.id, room), cy: py(point.value), r: 3.5 }));\n const ticks = numberTicks(scale.range[0], scale.range[1], scale.log, Math.max(2, Math.floor(height / 50)));\n const rule = s(\"line\", { class: \"rx-cursor\", x1: 0, x2: 0, y1: plot.top, y2: plot.bottom, visibility: \"hidden\" });\n const ring = s(\"circle\", { class: \"rx-ring\", cx: 0, cy: 0, r: 5, visibility: \"hidden\" });\n const svg = chartFrame(plot, `${panel.title} ${view.measure.label} over ${view.x.label}.`.trim());\n svg.append(valueAxis(plot, ticks), ...marks, ...dots, xAxis(plot, view.x), rule, ring);\n connect(\n svg,\n {\n columns: curve.length,\n rows: 1,\n at: (x) => {\n const distance = (place: (typeof curve)[number]): number => Math.abs(px(place.at) - x);\n const nearest = curve.reduce((best, place) => (distance(place) < distance(best) ? place : best));\n return [curve.indexOf(nearest), 0];\n },\n show: (column) => {\n const place = curve[column] as (typeof curve)[number];\n for (const [name, value] of [[\"x1\", px(place.at)], [\"x2\", px(place.at)]] as const) rule.setAttribute(name, String(value));\n ring.setAttribute(\"cx\", String(px(place.at)));\n ring.setAttribute(\"cy\", String(py(place.value)));\n rule.setAttribute(\"visibility\", \"visible\");\n ring.setAttribute(\"visibility\", \"visible\");\n return curveText(view.x, place);\n },\n },\n tell,\n );\n return svg;\n}\n\n/** This function draws a chart of a surface, or the separate cells of a table. */\nfunction surfaceChart(view: ExplorerView, panel: SurfacePanel, width: number, tell: (text: string) => void): SVGElement {\n const axisY = view.y as AxisSpec;\n const plot = plotOf(width, Math.min(380, Math.max(280, width * 0.72)), view);\n const { x, y, cells } = panel.surface;\n const length = plot.right - plot.left;\n const height = plot.bottom - plot.top;\n const xEdges = cellEdges(x.map((value) => placeOn(view.x, value)));\n const yEdges = cellEdges(y.map((value) => placeOn(axisY, value)));\n const range = heatRange(view);\n const gap = panel.cells ? 2 : 0;\n const cellMarks = cells.flatMap((row, j) =>\n row.flatMap((band, i) => {\n const left = plot.left + (xEdges[i] as number) * length;\n const right = plot.left + (xEdges[i + 1] as number) * length;\n const lower = plot.bottom - (yEdges[j] as number) * height;\n const upper = plot.bottom - (yEdges[j + 1] as number) * height;\n const box = { x: left + gap / 2, y: upper + gap / 2, width: Math.max(0.5, right - left - gap + (gap === 0 ? 0.6 : 0)), height: Math.max(0.5, lower - upper - gap + (gap === 0 ? 0.6 : 0)) };\n const step = heatStep(band.value, range, view.log);\n const parts: SVGElement[] = [s(\"rect\", { ...box, class: `rx-h${step}` })];\n const veil = veilOf(band.nearest);\n if (veil > 0.02) parts.push(s(\"rect\", { ...box, class: \"rx-veil\", \"fill-opacity\": veil.toFixed(3) }));\n if (panel.cells && box.width > 34 && box.height > 18) parts.push(s(\"text\", { class: `rx-cell-text ${step > HEAT_STEPS / 2 ? \"rx-on-dark\" : \"rx-on-light\"}`, x: box.x + box.width / 2, y: box.y + box.height / 2 + 4, \"text-anchor\": \"middle\" }, formatValue(band.value)));\n return parts;\n }),\n );\n const dots = panel.surface.points.map((point) =>\n s(\"circle\", { class: \"rx-dot rx-dot-heat\", cx: plot.left + placeOn(view.x, point.at[0]) * length + jitter(point.id, 6), cy: plot.bottom - placeOn(axisY, point.at[1]) * height + jitter(`${point.id}y`, 6), r: 2.5 }),\n );\n const outline = s(\"rect\", { class: \"rx-cell-cursor\", x: 0, y: 0, width: 0, height: 0, visibility: \"hidden\" });\n const svg = chartFrame(plot, `${panel.title} ${view.measure.label} over ${view.x.label} and ${axisY.label}.`.trim());\n svg.append(...cellMarks, ...dots, surfaceAxis(plot, axisY), xAxis(plot, view.x), outline);\n const find = (edges: readonly number[], share: number): number => {\n const index = edges.findIndex((edge) => edge > share);\n return Math.max(0, (index < 0 ? edges.length : index) - 1);\n };\n connect(\n svg,\n {\n columns: x.length,\n rows: y.length,\n at: (px, py) => [find(xEdges, (px - plot.left) / length), y.length - 1 - find(yEdges, (plot.bottom - py) / height)],\n show: (column, row) => {\n const j = y.length - 1 - row;\n outline.setAttribute(\"x\", String(plot.left + (xEdges[column] as number) * length));\n outline.setAttribute(\"width\", String(((xEdges[column + 1] as number) - (xEdges[column] as number)) * length));\n outline.setAttribute(\"y\", String(plot.bottom - (yEdges[j + 1] as number) * height));\n outline.setAttribute(\"height\", String(((yEdges[j + 1] as number) - (yEdges[j] as number)) * height));\n outline.setAttribute(\"visibility\", \"visible\");\n return cellText(view.x, axisY, x[column] as ResponseValue, y[j] as ResponseValue, cells[j]?.[column] as (typeof cells)[number][number]);\n },\n },\n tell,\n );\n return svg;\n}\n\n/** This function draws the measured points of a measure with no model. */\nfunction pointsChart(view: ExplorerView, panel: PointsPanel, width: number): SVGElement {\n const plot = plotOf(width, 270, view);\n const length = plot.right - plot.left;\n const height = plot.bottom - plot.top;\n const svg = chartFrame(plot, `${panel.title} ${view.measure.label}: ${panel.points.length} measured points.`.trim());\n if (view.y === null) {\n const scale: ValueScale = { range: valueRange(view), log: view.log };\n const room = view.x.kind === \"levels\" ? Math.min(30, (length / Math.max(1, view.x.levels.length)) * 0.35) : 0;\n const dots = panel.points.map((point) => s(\"circle\", { class: \"rx-dot\", cx: plot.left + placeOn(view.x, point.at[0] as ResponseValue) * length + jitter(point.id, room), cy: plot.bottom - valuePlace(scale, point.value) * height, r: 3.5 }));\n const ticks = numberTicks(scale.range[0], scale.range[1], scale.log, Math.max(2, Math.floor(height / 50)));\n svg.append(valueAxis(plot, ticks), ...dots, xAxis(plot, view.x));\n return svg;\n }\n const axisY = view.y;\n const range = heatRange(view);\n const dots = panel.points.map((point) =>\n s(\"circle\", { class: `rx-h${heatStep(point.value, range, view.log)} rx-ring-dot`, cx: plot.left + placeOn(view.x, point.at[0] as ResponseValue) * length + jitter(point.id, 8), cy: plot.bottom - placeOn(axisY, point.at[1] as ResponseValue) * height + jitter(`${point.id}y`, 8), r: 5 }),\n );\n svg.append(...dots, surfaceAxis(plot, axisY), xAxis(plot, view.x));\n return svg;\n}\n\n/** This function gives the number of measured points of a panel. */\nfunction pointCount(panel: ExplorerPanel): number {\n if (panel.kind === \"curve\") return panel.slice.points.length;\n return panel.kind === \"surface\" ? panel.surface.points.length : panel.points.length;\n}\n\n/** This function gives the sentence about the measured points of a panel. */\nfunction pointsText(panel: ExplorerPanel): string {\n const count = pointCount(panel);\n if (count === 0) return \"No measured point has these held values.\";\n return count === 1 ? \"1 measured point has these held values.\" : `${count} measured points have these held values.`;\n}\n\n/** This function draws one panel. */\nfunction panelChart(view: ExplorerView, panel: ExplorerPanel, width: number, id: string, tell: (text: string) => void): SVGElement {\n if (panel.kind === \"curve\") return curveChart(view, panel, width, id, tell);\n return panel.kind === \"surface\" ? surfaceChart(view, panel, width, tell) : pointsChart(view, panel, width);\n}\n\n/** This function makes the legend of a view. */\nfunction legendOf(view: ExplorerView): HTMLElement {\n const item = (mark: HTMLElement, text: string): HTMLElement => h(\"span\", { class: \"rx-key\" }, mark, text);\n const mark = (name: string): HTMLElement => h(\"i\", { class: `rx-mark ${name}`, \"aria-hidden\": \"true\" });\n const parts: Child[] = [];\n const panel = view.panels[0];\n const surface = view.y !== null && panel?.kind !== \"curve\";\n if (panel?.kind === \"curve\") parts.push(item(mark(\"rx-mark-line\"), \"fitted value\"), item(mark(\"rx-mark-band\"), \"band: one held-out error each side. It fades away from the data.\"));\n if (surface) {\n const [low, high] = heatRange(view);\n const ramp = h(\"i\", { class: \"rx-ramp\", \"aria-hidden\": \"true\" }, ...Array.from({ length: HEAT_STEPS }, (_, i) => h(\"b\", { class: `rx-s${i}` })));\n parts.push(h(\"span\", { class: \"rx-key\" }, formatValue(low), ramp, formatValue(high)));\n if (panel?.kind === \"surface\") parts.push(item(mark(\"rx-mark-veil\"), \"gray veil: far from the data\"));\n }\n if (panel !== undefined) parts.push(item(mark(\"rx-mark-dot\"), \"measured point\"));\n return h(\"p\", { class: \"rx-legend\" }, ...parts);\n}\n\n/** This function makes a table of numbers. */\nfunction tableOf(view: ExplorerView, panel: ExplorerPanel): HTMLElement {\n const { columns, rows } = numberTable(view, panel);\n const head = h(\"tr\", {}, ...columns.map((column) => h(\"th\", { scope: \"col\" }, column)));\n const body = rows.map((row) => h(\"tr\", {}, ...row.map((cell) => h(\"td\", {}, cell))));\n const table = h(\"table\", { class: \"rx-table\" }, ...(panel.title === \"\" ? [] : [h(\"caption\", {}, panel.title)]), h(\"thead\", {}, head), h(\"tbody\", {}, ...body));\n return table;\n}\n\n/** This function makes a select of dimensions. The first option is the value `none`, if the control has one. */\nfunction dimensionSelect(label: string, key: string, choices: readonly DimensionChoice[], value: string | null, none: string | null, change: (id: string | null) => void): HTMLElement {\n const options = choices.map((choice) => {\n const text = choice.disabled ? `${choice.label}: ${choice.reason}` : choice.label;\n return h(\"option\", { value: choice.id, disabled: choice.disabled, selected: choice.id === value }, text);\n });\n const select = h(\"select\", { \"data-key\": key }, ...(none === null ? [] : [h(\"option\", { value: \"\", selected: value === null }, none)]), ...options);\n select.addEventListener(\"change\", () => change(select.value === \"\" ? null : select.value));\n return h(\"label\", { class: \"rx-field\" }, h(\"span\", {}, label), select);\n}\n\n/** The fields of a level in a group. */\ninterface LevelOption {\n readonly text: string;\n readonly checked: boolean;\n readonly disabled: boolean;\n readonly reason: string;\n readonly choose: () => void;\n}\n\n/** This function makes a select of levels. A closed select shows the held value and takes one row. */\nfunction levelSelect(label: string, key: string, options: readonly LevelOption[], note: string): HTMLElement {\n const items = options.map((option, i) => {\n const text = option.disabled ? `${option.text}: ${option.reason}` : option.text;\n return h(\"option\", { value: i, disabled: option.disabled, selected: option.checked }, text);\n });\n const select = h(\"select\", { \"data-key\": key }, ...items);\n select.addEventListener(\"change\", () => options[Number(select.value)]?.choose());\n const field = h(\"label\", { class: \"rx-field\" }, h(\"span\", {}, label), select);\n return h(\"div\", { class: \"rx-hold\" }, field, note === \"\" ? null : h(\"p\", { class: \"rx-note\" }, note));\n}\n\n/** This function makes a group of levels. Level buttons are radio inputs, so the keyboard works with no script. */\nfunction levelGroup(label: string, key: string, name: string, options: readonly LevelOption[], note: string): HTMLElement {\n if (levelForm(options.length) === \"select\") return levelSelect(label, key, options, note);\n const chips = options.map((option, i) => {\n const input = h(\"input\", { class: \"rx-radio\", type: \"radio\", name, checked: option.checked, disabled: option.disabled, \"data-key\": `${key}:${i}` });\n input.addEventListener(\"change\", option.choose);\n return h(\"label\", { class: \"rx-chip\", title: option.reason === \"\" ? undefined : option.reason }, input, h(\"span\", {}, option.text));\n });\n const legend = h(\"legend\", { class: \"rx-name\" }, label);\n return h(\"fieldset\", { class: \"rx-hold\" }, legend, h(\"div\", { class: \"rx-chips\" }, ...chips), note === \"\" ? null : h(\"p\", { class: \"rx-note\" }, note));\n}\n\n/** This function makes a slider over the values of a held dimension. */\nfunction stopSlider(control: HoldControl, key: string, change: (value: ResponseValue) => void): HTMLElement {\n const values = control.options.map((option) => option.value);\n const index = Math.max(0, values.indexOf(control.value));\n const output = h(\"output\", { class: \"rx-value\" }, formatValue(control.value));\n const input = h(\"input\", { class: \"rx-slider\", type: \"range\", min: 0, max: values.length - 1, step: 1, value: index, disabled: !control.applies, \"data-key\": key, \"aria-label\": control.label, \"aria-valuetext\": formatValue(control.value) });\n input.addEventListener(\"input\", () => {\n const value = values[Number(input.value)] as ResponseValue;\n output.textContent = formatValue(value);\n input.setAttribute(\"aria-valuetext\", formatValue(value));\n change(value);\n });\n const head = h(\"div\", { class: \"rx-slider-head\" }, h(\"span\", { class: \"rx-name\" }, control.label), output);\n return h(\"div\", { class: \"rx-hold\" }, head, input, control.note === \"\" ? null : h(\"p\", { class: \"rx-note\" }, control.note));\n}\n\n/** This function shows each fault of a bad record, with its path. */\nfunction faultView(faults: readonly { readonly path: string; readonly message: string }[]): HTMLElement {\n const items = faults.slice(0, MAX_FAULTS).map((fault) => h(\"li\", {}, h(\"code\", {}, fault.path === \"\" ? \"(the record)\" : fault.path), ` ${fault.message}`));\n const more = faults.length > MAX_FAULTS ? h(\"p\", {}, `The list shows ${MAX_FAULTS} of ${faults.length} faults.`) : null;\n const title = faults.length === 1 ? \"This record has 1 fault.\" : `This record has ${faults.length} faults.`;\n return h(\"div\", { class: \"rx-faults\", role: \"alert\" }, h(\"p\", { class: \"rx-faults-title\" }, title), h(\"ul\", {}, ...items), more);\n}\n\n/**\n * This function shows a record of the format `response-records/1` in a host element. It reads the record only with\n * `parseResponseRecord`. A bad record shows its faults with their paths, and the function does not throw.\n *\n * @param host - The element of the explorer. The function replaces its children.\n * @param recordJson - The record as JSON text, or as parsed data.\n * @param options - The first state, the time of a surface and the clock.\n */\nexport function mountExplorer(host: HTMLElement, recordJson: unknown, options: ExplorerOptions = {}): ExplorerHandle {\n const parsed = openRecord(recordJson);\n if (!parsed.ok) {\n host.replaceChildren(h(\"div\", { class: \"response-explorer\" }, faultView(parsed.faults)));\n return { state: () => null, destroy: () => host.replaceChildren() };\n }\n return mountRecord(host, parsed.record, options);\n}\n\n/** This function connects a good record to the DOM. */\nfunction mountRecord(host: HTMLElement, record: ResponseRecord, options: ExplorerOptions): ExplorerHandle {\n const { budgetMs = SURFACE_BUDGET_MS, now = (): number => performance.now() } = options;\n const mount = ++mounts;\n let state = settle(record, options.initial);\n let cap = MAX_STEPS;\n let frame = 0;\n let drawnWidth = 0;\n let view: ExplorerView | undefined;\n // The fold of the held values that do not apply stays open or closed when the controls draw again.\n let idleOpen = false;\n\n const controls = h(\"div\", { class: \"rx-controls\" });\n const panels = h(\"div\", { class: \"rx-panels\" });\n const error = h(\"p\", { class: \"rx-error\" });\n const model = h(\"p\", { class: \"rx-note\" });\n const legend = h(\"div\", { class: \"rx-legend-box\" });\n const readout = h(\"p\", { class: \"rx-readout\", \"aria-live\": \"polite\" });\n const numbers = h(\"div\", { class: \"rx-numbers-body\" });\n const details = h(\"details\", { class: \"rx-numbers\" }, h(\"summary\", {}, \"Show the numbers\"), numbers);\n const chart = h(\"div\", { class: \"rx-chart\" }, error, panels, legend, readout, model, details);\n const root = h(\"div\", { class: \"response-explorer\" }, controls, chart);\n\n const tell = (text: string): void => {\n readout.textContent = text;\n };\n\n /** This function fills the table when the visitor opens it, so a closed table costs no time. */\n const drawNumbers = (): void => {\n numbers.replaceChildren(...(details.open && view !== undefined ? view.panels.map((panel) => h(\"div\", { class: \"rx-table-box scroll-cue\" }, tableOf(view as ExplorerView, panel))) : []));\n };\n\n /** This function draws the charts of the last view at the width of the host. */\n const drawCharts = (): void => {\n const current = view;\n if (current === undefined) return;\n const single = current.panels.length === 1;\n const available = panels.clientWidth > 0 ? panels.clientWidth : FALLBACK_WIDTH;\n const columns = single ? 1 : Math.min(current.panels.length, Math.max(1, Math.floor((available + 12) / 272)));\n const width = Math.floor((available - (columns - 1) * 12) / columns);\n drawnWidth = available;\n panels.replaceChildren(\n ...current.panels.map((panel, i) => {\n const title = panel.title === \"\" ? null : h(\"figcaption\", { class: \"rx-panel-title\" }, panel.title);\n const chartBox = panelChart(current, panel, width, `rx-band-${mount}-${i}`, tell);\n return h(\"figure\", { class: \"rx-panel\" }, title, chartBox, h(\"p\", { class: \"rx-note\" }, pointsText(panel)));\n }),\n );\n };\n\n /** This function asks the core for a view, and it draws the view. */\n const drawView = (): void => {\n const next = viewOf(record, state, { stepsCap: cap, budgetMs, now });\n view = next;\n cap = next.nextCap;\n if (next.problem !== \"\") {\n error.textContent = `The record refused this view: ${next.problem}`;\n } else {\n const head = next.error === null ? null : h(\"strong\", {}, \"Held-out error. \");\n error.replaceChildren(...(head === null ? [] : [head]), next.errorText);\n }\n model.textContent = [next.modelText, next.gridText, next.rangeText].filter((text) => text !== \"\").join(\" \");\n legend.replaceChildren(legendOf(next));\n tell(\"Move over a chart, or focus it and use the arrow keys.\");\n drawCharts();\n drawNumbers();\n };\n\n /** This function draws at the next frame. A slider gives many events in one frame. */\n const later = (): void => {\n if (frame !== 0) return;\n frame = requestAnimationFrame(() => {\n frame = 0;\n drawView();\n });\n };\n\n /** This function makes the controls of the state again, and it keeps the focus on the same control. */\n const drawControls = (): void => {\n const focused = document.activeElement instanceof HTMLElement ? document.activeElement.dataset[\"key\"] : undefined;\n const update = (next: ExplorerState): void => {\n state = next;\n drawControls();\n drawView();\n };\n const measures = levelGroup(\n \"Measure\",\n \"measure\",\n `rx-measure-${mount}`,\n record.measures.map((m) => ({ text: m.label, checked: m.id === state.measure, disabled: false, reason: \"\", choose: () => update(setMeasure(record, state, m.id)) })),\n \"\",\n );\n const axes = h(\n \"div\",\n { class: \"rx-axes\" },\n dimensionSelect(\"Across\", \"x\", axisChoices(record, state, \"x\"), state.x, null, (id) => update(setAxis(record, state, \"x\", id))),\n dimensionSelect(\"Up\", \"y\", axisChoices(record, state, \"y\"), state.y, \"None (a curve)\", (id) => update(setAxis(record, state, \"y\", id))),\n dimensionSelect(\"Panels\", \"facet\", facetChoices(record, state), state.facet, \"One panel\", (id) => update(setFacet(record, state, id))),\n );\n const holdOf = (control: HoldControl): HTMLElement => {\n if (control.kind === \"stops\") {\n return stopSlider(control, `hold:${control.id}`, (value) => {\n state = setHold(record, state, control.id, value);\n later();\n });\n }\n const levels = control.options.map((option) => ({ text: option.text, checked: option.value === control.value, disabled: option.disabled, reason: option.reason, choose: () => update(setHold(record, state, control.id, option.value)) }));\n return levelGroup(control.label, `hold:${control.id}`, `rx-${mount}-${control.id}`, levels, control.note);\n };\n // A held value that does not apply at the level of its parent goes in one closed fold, so the visitor sees first the values that change the view.\n const holds = holdControls(record, state);\n const idle = holds.filter((control) => !control.applies);\n const fold = idle.length === 0 ? null : h(\"details\", { class: \"rx-idle\", open: idleOpen }, h(\"summary\", {}, `Held values that do not apply (${idle.length})`), h(\"div\", { class: \"rx-idle-list\" }, ...idle.map(holdOf)));\n fold?.addEventListener(\"toggle\", () => {\n idleOpen = fold.open;\n });\n const held = holds.length === 0 ? [] : [h(\"p\", { class: \"rx-section\" }, \"Held values\"), ...holds.filter((control) => control.applies).map(holdOf), ...(fold === null ? [] : [fold])];\n controls.replaceChildren(measures, axes, ...held);\n if (focused !== undefined) {\n const keyed = [...controls.querySelectorAll<HTMLElement>(\"[data-key]\")].find((el) => el.dataset[\"key\"] === focused);\n keyed?.focus();\n }\n };\n\n details.addEventListener(\"toggle\", drawNumbers);\n host.replaceChildren(root);\n drawControls();\n drawView();\n\n const observer =\n typeof ResizeObserver === \"undefined\"\n ? undefined\n : new ResizeObserver(() => {\n if (panels.clientWidth > 0 && Math.abs(panels.clientWidth - drawnWidth) > 1) drawCharts();\n });\n observer?.observe(panels);\n\n return {\n state: () => state,\n destroy: () => {\n observer?.disconnect();\n if (frame !== 0) cancelAnimationFrame(frame);\n host.replaceChildren();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;AAkCA,MAAa,YAAY;;AAEzB,MAAa,YAAY;;;;;;AAMzB,MAAa,cAAc;;AAE3B,MAAa,oBAAoB;;AAEjC,MAAa,aAAa;;AAM1B,MAAa,WAAW;;;;;AA6JxB,SAAgB,WAAW,OAAsC;CAC/D,IAAI,OAAO,UAAU,UAAU,OAAO,oBAAoB,KAAK;CAC/D,IAAI;EACF,OAAO,oBAAoB,KAAK,MAAM,KAAK,CAAC;CAC9C,SAAS,OAAO;EACd,OAAO;GAAE,IAAI;GAAO,QAAQ,CAAC;IAAE,MAAM;IAAI,SAAS,0BAA0B,OAAO,KAAK,EAAE;GAAG,CAAC;EAAE;CAClG;AACF;AAEA,MAAM,aAAa,IAAI,KAAK,aAAa,SAAS,EAAE,0BAA0B,EAAE,CAAC;;AAGjF,SAAgB,YAAY,OAAmC;CAC7D,IAAI,UAAU,MAAM,OAAO;CAC3B,OAAO,OAAO,UAAU,WAAW,WAAW,OAAO,KAAK,IAAI;AAChE;;AAGA,SAAS,YAAY,QAAwB,IAA+B;CAC1E,MAAM,YAAY,OAAO,WAAW,MAAM,MAAM,EAAE,OAAO,EAAE;CAC3D,IAAI,cAAc,KAAA,GAAW,MAAM,IAAI,WAAW,gCAAgC,GAAG,GAAG;CACxF,OAAO;AACT;;AAGA,SAAS,eAAe,QAAwB,IAA6B;CAC3E,OAAO,OAAO,O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,KAAK,EAAE,OAAO,aAAa,GAAG,aAAa;GAAG,GAAG,MAAM,QAAQ,YAAY,QAAQ,OAAO,CAAC,CAAC,IAAI,MAAM;GAAG,GAAI,SAAS,OAAO,CAAC,IAAI,CAAC,IAAI;EAAE;EACnL,SAAS,gBAAgB,UAAU,MAAM,GAAG,IAAI;EAChD,IAAI,YAAY,KAAA,GACA,CAAC,GAAG,SAAS,iBAA8B,YAAY,CAAC,CAAC,CAAC,MAAM,OAAO,GAAG,QAAQ,WAAW,OACvG,CAAC,EAAE,MAAM;CAEjB;CAEA,QAAQ,iBAAiB,UAAU,WAAW;CAC9C,KAAK,gBAAgB,IAAI;CACzB,aAAa;CACb,SAAS;CAET,MAAM,WACJ,OAAO,mBAAmB,cACtB,KAAA,IACA,IAAI,qBAAqB;EACvB,IAAI,OAAO,cAAc,KAAK,KAAK,IAAI,OAAO,cAAc,UAAU,IAAI,GAAG,WAAW;CAC1F,CAAC;CACP,UAAU,QAAQ,MAAM;CAExB,OAAO;EACL,aAAa;EACb,eAAe;GACb,UAAU,WAAW;GACrB,IAAI,UAAU,GAAG,qBAAqB,KAAK;GAC3C,KAAK,gBAAgB;EACvB;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@mark1russell7/site-pages",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.3",
|
|
5
5
|
"description": "A release timeline page and a live status page for the site of a GitHub repository: JSON data and standalone HTML, made at deploy time.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"github-pages",
|