rpg-engine 0.20.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/dist/adventures/index.d.ts +1 -1
  2. package/dist/adventures/index.js +1 -1
  3. package/dist/adventures/source.d.ts +3 -0
  4. package/dist/adventures/source.js +11 -49
  5. package/dist/campaign/create-campaign.d.ts +1 -1
  6. package/dist/campaign/create-campaign.js +3 -2
  7. package/dist/campaign/find-campaign.d.ts +2 -0
  8. package/dist/campaign/find-campaign.js +2 -0
  9. package/dist/campaign/host-files.js +4 -1
  10. package/dist/campaign/index.d.ts +3 -2
  11. package/dist/campaign/index.js +3 -2
  12. package/dist/campaign/port.d.ts +6 -0
  13. package/dist/campaign/port.js +24 -0
  14. package/dist/campaign/settings.d.ts +17 -0
  15. package/dist/campaign/settings.js +26 -3
  16. package/dist/cli/cli.js +15 -0
  17. package/dist/commands/book.d.ts +16 -35
  18. package/dist/commands/book.js +86 -62
  19. package/dist/commands/config/config.js +16 -2
  20. package/dist/commands/config/dashboard.d.ts +6 -2
  21. package/dist/commands/config/dashboard.js +45 -8
  22. package/dist/commands/config/shown.js +4 -0
  23. package/dist/commands/config/words.d.ts +3 -1
  24. package/dist/commands/config/words.js +29 -2
  25. package/dist/commands/image.d.ts +5 -0
  26. package/dist/commands/image.js +6 -3
  27. package/dist/commands/mode.d.ts +1 -1
  28. package/dist/commands/package/data.d.ts +35 -0
  29. package/dist/commands/package/data.js +144 -0
  30. package/dist/commands/package/here.d.ts +7 -2
  31. package/dist/commands/package/here.js +23 -11
  32. package/dist/commands/package/install.js +14 -15
  33. package/dist/commands/package/language.d.ts +15 -0
  34. package/dist/commands/package/language.js +109 -0
  35. package/dist/commands/package/package.js +20 -10
  36. package/dist/commands/package/result.d.ts +19 -0
  37. package/dist/commands/package/theme.d.ts +13 -0
  38. package/dist/commands/package/theme.js +67 -0
  39. package/dist/commands/package/uninstall.d.ts +4 -1
  40. package/dist/commands/package/uninstall.js +29 -9
  41. package/dist/commands/scene/close.d.ts +1 -1
  42. package/dist/commands/scene/close.js +15 -8
  43. package/dist/commands/scene/scene.js +6 -1
  44. package/dist/commands/shared/books/adventures.d.ts +1 -4
  45. package/dist/commands/shared/books/adventures.js +3 -32
  46. package/dist/commands/shared/books/words.js +3 -2
  47. package/dist/commands/shared/campaign/book.d.ts +21 -8
  48. package/dist/commands/shared/campaign/book.js +65 -42
  49. package/dist/commands/shared/campaign/git.d.ts +25 -0
  50. package/dist/commands/shared/campaign/git.js +104 -0
  51. package/dist/commands/shared/campaign/saves.js +7 -3
  52. package/dist/commands/shared/campaign/world.js +2 -1
  53. package/dist/commands/shared/packages/catalog.d.ts +3 -3
  54. package/dist/commands/shared/packages/catalog.js +118 -43
  55. package/dist/commands/shared/packages/unpacked.d.ts +50 -0
  56. package/dist/commands/shared/packages/unpacked.js +146 -0
  57. package/dist/commands/status.d.ts +1 -0
  58. package/dist/commands/status.js +8 -4
  59. package/dist/core/archive.d.ts +13 -0
  60. package/dist/core/archive.js +76 -0
  61. package/dist/core/context.d.ts +4 -0
  62. package/dist/core/context.js +1 -0
  63. package/dist/core/store.d.ts +5 -1
  64. package/dist/core/store.js +15 -2
  65. package/dist/core/version.d.ts +2 -0
  66. package/dist/core/version.js +5 -0
  67. package/dist/dashboard/api.js +24 -1
  68. package/dist/dashboard/app.js +7 -2
  69. package/dist/dashboard/guide/ar.md +11 -9
  70. package/dist/dashboard/guide/cs.md +11 -9
  71. package/dist/dashboard/guide/da.md +12 -10
  72. package/dist/dashboard/guide/de.md +13 -11
  73. package/dist/dashboard/guide/el.md +11 -9
  74. package/dist/dashboard/guide/en.md +10 -8
  75. package/dist/dashboard/guide/es.md +11 -9
  76. package/dist/dashboard/guide/fi.md +11 -9
  77. package/dist/dashboard/guide/fr.md +11 -9
  78. package/dist/dashboard/guide/he.md +11 -9
  79. package/dist/dashboard/guide/hi.md +11 -9
  80. package/dist/dashboard/guide/hu.md +11 -9
  81. package/dist/dashboard/guide/is.md +11 -9
  82. package/dist/dashboard/guide/it.md +11 -9
  83. package/dist/dashboard/guide/ja.md +12 -10
  84. package/dist/dashboard/guide/ko.md +11 -9
  85. package/dist/dashboard/guide/nb.md +12 -10
  86. package/dist/dashboard/guide/nl.md +11 -9
  87. package/dist/dashboard/guide/pl.md +11 -9
  88. package/dist/dashboard/guide/pt.md +11 -9
  89. package/dist/dashboard/guide/ro.md +11 -9
  90. package/dist/dashboard/guide/ru.md +12 -10
  91. package/dist/dashboard/guide/sv.md +11 -9
  92. package/dist/dashboard/guide/tr.md +11 -9
  93. package/dist/dashboard/guide/uk.md +12 -10
  94. package/dist/dashboard/guide/zh.md +11 -9
  95. package/dist/dashboard/i18n/ar.json +58 -5
  96. package/dist/dashboard/i18n/cs.json +58 -5
  97. package/dist/dashboard/i18n/da.json +58 -5
  98. package/dist/dashboard/i18n/de.json +58 -5
  99. package/dist/dashboard/i18n/el.json +58 -5
  100. package/dist/dashboard/i18n/es.json +58 -5
  101. package/dist/dashboard/i18n/fi.json +58 -5
  102. package/dist/dashboard/i18n/fr.json +58 -5
  103. package/dist/dashboard/i18n/he.json +58 -5
  104. package/dist/dashboard/i18n/hi.json +58 -5
  105. package/dist/dashboard/i18n/hu.json +58 -5
  106. package/dist/dashboard/i18n/is.json +58 -5
  107. package/dist/dashboard/i18n/it.json +58 -5
  108. package/dist/dashboard/i18n/ja.json +58 -5
  109. package/dist/dashboard/i18n/ko.json +58 -5
  110. package/dist/dashboard/i18n/nb.json +58 -5
  111. package/dist/dashboard/i18n/nl.json +58 -5
  112. package/dist/dashboard/i18n/pl.json +58 -5
  113. package/dist/dashboard/i18n/pt.json +58 -5
  114. package/dist/dashboard/i18n/ro.json +58 -5
  115. package/dist/dashboard/i18n/ru.json +58 -5
  116. package/dist/dashboard/i18n/sv.json +58 -5
  117. package/dist/dashboard/i18n/tr.json +58 -5
  118. package/dist/dashboard/i18n/uk.json +58 -5
  119. package/dist/dashboard/i18n/zh.json +58 -5
  120. package/dist/dashboard/journal/book.js +3 -2
  121. package/dist/dashboard/journal/journal.js +8 -5
  122. package/dist/dashboard/kit.js +1 -1
  123. package/dist/dashboard/packages/catalog.js +31 -14
  124. package/dist/dashboard/packages/engine.js +46 -2
  125. package/dist/dashboard/packages/installed.js +13 -0
  126. package/dist/dashboard/packages/outcomes.js +21 -0
  127. package/dist/dashboard/packages/packages.js +41 -18
  128. package/dist/dashboard/packages/rows.js +3 -1
  129. package/dist/dashboard/parts/icons.js +3 -0
  130. package/dist/dashboard/parts/labels.js +7 -0
  131. package/dist/dashboard/parts/picture.js +89 -0
  132. package/dist/dashboard/parts/refusals.js +8 -1
  133. package/dist/dashboard/parts/widgets.js +2 -1
  134. package/dist/dashboard/play/scene.js +8 -5
  135. package/dist/dashboard/settings/settings.js +55 -18
  136. package/dist/dashboard/sheet/party.js +5 -2
  137. package/dist/dashboard/sheet/sheet.js +2 -1
  138. package/dist/dashboard/shell/notices.js +2 -2
  139. package/dist/dashboard/shell/system-style.js +132 -15
  140. package/dist/dashboard/shell/tooltip.js +224 -0
  141. package/dist/dashboard/style.css +497 -193
  142. package/dist/dashboard/world/lore.js +4 -3
  143. package/dist/dashboard/world/place-card.js +2 -1
  144. package/dist/git/git.d.ts +12 -0
  145. package/dist/git/git.js +175 -0
  146. package/dist/git/ignore.d.ts +2 -0
  147. package/dist/git/ignore.js +16 -0
  148. package/dist/git/index.d.ts +2 -0
  149. package/dist/git/index.js +2 -0
  150. package/dist/importer/index.d.ts +1 -1
  151. package/dist/importer/index.js +1 -1
  152. package/dist/languages/index.d.ts +1 -1
  153. package/dist/languages/index.js +1 -1
  154. package/dist/languages/pack.d.ts +4 -1
  155. package/dist/languages/pack.js +18 -6
  156. package/dist/packages/engine.d.ts +7 -0
  157. package/dist/packages/engine.js +32 -1
  158. package/dist/packages/index.d.ts +1 -1
  159. package/dist/packages/index.js +1 -1
  160. package/dist/server/bell-listener.d.ts +2 -1
  161. package/dist/server/bell-listener.js +10 -41
  162. package/dist/server/dashboard/engine.d.ts +18 -0
  163. package/dist/server/dashboard/engine.js +31 -0
  164. package/dist/server/dashboard/files.d.ts +11 -3
  165. package/dist/server/dashboard/files.js +66 -17
  166. package/dist/server/dashboard/index.d.ts +18 -2
  167. package/dist/server/dashboard/index.js +62 -23
  168. package/dist/server/dashboard/news.d.ts +3 -2
  169. package/dist/server/dashboard/news.js +19 -5
  170. package/dist/server/dashboard/pictures.d.ts +7 -0
  171. package/dist/server/dashboard/pictures.js +62 -0
  172. package/dist/server/dashboard/ports.d.ts +17 -2
  173. package/dist/server/dashboard/ports.js +60 -4
  174. package/dist/server/dashboard/writes.d.ts +5 -3
  175. package/dist/server/dashboard/writes.js +45 -14
  176. package/dist/server/mcp.d.ts +3 -2
  177. package/dist/server/mcp.js +55 -11
  178. package/dist/testing/index.js +1 -0
  179. package/dist/themes/css.d.ts +1 -1
  180. package/dist/themes/css.js +101 -2
  181. package/dist/themes/index.d.ts +2 -1
  182. package/dist/themes/index.js +4 -2
  183. package/dist/themes/installed.d.ts +14 -0
  184. package/dist/themes/installed.js +28 -0
  185. package/dist/themes/theme.d.ts +38 -0
  186. package/dist/themes/theme.js +192 -13
  187. package/instructions/core.md +4 -3
  188. package/instructions/dashboard-guide.md +2 -1
  189. package/instructions/mentor-hints.md +1 -1
  190. package/instructions/mentor-tutorial.md +1 -1
  191. package/instructions/party.md +1 -1
  192. package/instructions/play.md +2 -2
  193. package/package.json +1 -1
  194. package/systems/free/instructions/outcomes-told.md +1 -1
@@ -9,7 +9,7 @@ import { DieSwatch, Icon } from "../parts/icons.js";
9
9
  import { customLabel, itemLabel, leveledItemLabel, phraseLabel, rateParts, settingLabel, valueLabel } from "../parts/labels.js";
10
10
  import { PageHead } from "../shell/pages.js";
11
11
  import { byHandPref, conditionsPref, readChoice, soundPref, tokenSymbolsPref, useChoice, usePref, usePrefChange, writeChoice } from "../shell/prefs.js";
12
- import { applyGameStyle, gameStyle, systemStylePref } from "../shell/system-style.js";
12
+ import { applyGameStyle, gameStyle, installedStyle, systemStylePref } from "../shell/system-style.js";
13
13
  import { pickTheme, shownTheme } from "../shell/theme.js";
14
14
  import { arrowStep, t } from "../text.js";
15
15
  import { LanguageChoice, languageLine } from "./language-choice.js";
@@ -24,6 +24,12 @@ const groups = [
24
24
  { names: ["lines", "veils"] },
25
25
  { names: ["orders"] },
26
26
  { names: ["pictures", "pictures-by", "language"] },
27
+ // Only where the campaign's folder is a git repository (D-576).
28
+ // What a public repository would show of the player (D-576).
29
+ {
30
+ names: ["git", "git-saves", "git-sessions"],
31
+ note: () => t("Keep the repository private. It holds the log of your sessions and your user's name on this computer; with the chats in, everything you wrote to the master too."),
32
+ },
27
33
  ];
28
34
  /** The Settings section; with `several` player characters, what a value means says so where it speaks of one character (D-480 (2)). */
29
35
  export function SettingsView({ version, several = false }) {
@@ -59,7 +65,10 @@ export function SettingsView({ version, several = false }) {
59
65
  ...group.names.flatMap((name) => settings.filter((setting) => setting.name === name)),
60
66
  ...(group.system ? settings.filter((setting) => !known.has(setting.name)) : []),
61
67
  ];
62
- return (_jsxs("section", { class: "settings-group", children: [_jsx("h3", { children: groupTitle(index) }), shown.map((setting) => (_jsx(SettingRow, { setting: setting, off: offBy(setting, settings), several: several, parts: settings.find((one) => one.name === customParts[setting.name]), onChange: change }, setting.name)))] }, group.names[0]));
68
+ if (shown.length === 0) {
69
+ return null;
70
+ }
71
+ return (_jsxs("section", { class: "settings-group", children: [_jsx("h3", { children: groupTitle(index) }), group.note !== undefined && _jsx("p", { class: "settings-group-note", children: group.note() }), shown.map((setting) => (_jsx(SettingRow, { setting: setting, off: offBy(setting, settings), several: several, parts: settings.find((one) => one.name === customParts[setting.name]), onChange: change }, setting.name)))] }, group.names[0]));
63
72
  }), _jsx(WidgetSettings, { onChange: change }), _jsx(PageSettings, {})] }));
64
73
  }
65
74
  /**
@@ -307,7 +316,7 @@ function TextSetting({ setting, label, onChange }) {
307
316
  }
308
317
  /** What the player should know of a setting on this computer, as how to have pictures: its lines, its steps in order, the commands to copy, and a line after. */
309
318
  function SettingNote({ note }) {
310
- const blocks = [...noteBlocks(t(note.text, note.values)), ...(note.also === undefined ? [] : [t(note.also, note.values)])];
319
+ const blocks = [...noteBlocks(t(note.text, note.values)), ...(note.also ?? []).map((line) => t(line, note.values))];
311
320
  return (_jsxs("div", { class: note.fix ? "setting-note fix" : "setting-note", children: [_jsx(Icon, { name: "info" }), _jsx("div", { class: "setting-note-text", children: blocks.map((block, index) => typeof block === "string" ? _jsx("p", { children: withCommands(block) }, index) : (_jsx("ol", { children: block.map((step) => _jsx("li", { children: withCommands(step) }, step)) }, index))) })] }));
312
321
  }
313
322
  /** A note's lines, those numbered as steps together. */
@@ -348,31 +357,58 @@ export function Command({ text }) {
348
357
  return (_jsxs("span", { class: "setting-command", children: [_jsx("code", { children: text.split(" ").flatMap((word, index) => [index === 0 ? "" : " ", _jsx("span", { class: "command-word", children: word }, index)]) }), _jsx("button", { type: "button", class: "setting-copy", "aria-label": t("Copy {command}", { command: text }), onClick: () => void copy(), children: copied ? t("Copied") : t("Copy") })] }));
349
358
  }
350
359
  /**
351
- * Under the theme, the game's style, when the campaign's system has one, a theme or a page style (D-528): its own or the page's, kept in this browser for that
352
- * system; the page's alone when its theme does not pass the check of legibility.
360
+ * Under the theme, the game's style, when the campaign's system has one, a theme or a page style (D-528), or this computer has themes installed (D-574): the
361
+ * game's, each installed theme by its name, or the page's, kept in this browser for that system; the game's left out when its theme does not pass the check
362
+ * of legibility, which the page's then says. Under it, for a theme shown with a style sheet of its own, whether the page adds it.
353
363
  */
354
364
  function gameStyleRows() {
355
365
  const style = gameStyle();
356
- if (style.system === undefined || (!style.shows && !style.refused)) {
366
+ const installed = style.themes.length > 0;
367
+ if (style.system === undefined || (!style.shows && !style.refused && !installed)) {
357
368
  return [];
358
369
  }
359
370
  const choice = systemStylePref(style.system);
360
- const name = t("Game style");
361
- if (!style.shows) {
362
- const means = t("This game's style does not pass the page's check of legibility: the page keeps its own.");
363
- return [{ key: "game-style", name, about: t("the colours, faces and pictures of the game system"), options: [{ value: "page", label: t("The page's"), means }], value: "page", pick: () => undefined }];
364
- }
365
- return [{
371
+ const refusedMeans = style.refused && !style.shows ? { means: t("This game's style does not pass the page's check of legibility: the page keeps its own.") } : {};
372
+ const about = !installed
373
+ ? style.name === undefined ? t("the colours, faces and pictures of the game system") : t("the colours, faces and pictures of {name}, from the game system", { name: style.name })
374
+ : style.shows
375
+ ? t("the colours, faces and pictures: the game system's, a theme you installed, or the page's own")
376
+ : t("the colours, faces and pictures: a theme you installed, or the page's own");
377
+ const options = [
378
+ ...(style.shows ? [{ value: "game", label: t("The game's") }] : []),
379
+ ...style.themes.map((one) => ({ value: installedStyle(one.id), label: one.name })),
380
+ { value: "page", label: t("The page's"), ...refusedMeans },
381
+ ];
382
+ const own = style.ownStyle;
383
+ return [
384
+ {
366
385
  key: "game-style",
367
- name,
368
- about: style.name === undefined ? t("the colours, faces and pictures of the game system") : t("the colours, faces and pictures of {name}, from the game system", { name: style.name }),
369
- options: [{ value: "game", label: t("The game's") }, { value: "page", label: t("The page's") }],
386
+ name: t("Game style"),
387
+ about,
388
+ options,
370
389
  value: readChoice(choice),
371
390
  pick: (value) => {
372
391
  writeChoice(choice, value);
373
392
  applyGameStyle();
374
393
  },
375
- }];
394
+ // The names of the installed themes go under the row's, with room for them.
395
+ ...(installed ? { under: true } : {}),
396
+ },
397
+ // The own style sheet of the theme shown, which the page adds unchecked: off, the theme keeps its colours, faces and pictures (D-575).
398
+ ...(own === undefined ? [] : [{
399
+ key: "theme-style",
400
+ name: t("Theme's own style"),
401
+ about: t("what the theme adds to the page's look beyond its colours, faces and pictures; the page does not check it, so it may read less well"),
402
+ // Settings never take it, whatever it does: this switch stays in reach.
403
+ note: t("Settings never show it, so you can always turn it off here."),
404
+ options: [{ value: "on", label: t("On") }, { value: "off", label: t("Off") }],
405
+ value: readChoice(own),
406
+ pick: (value) => {
407
+ writeChoice(own, value);
408
+ applyGameStyle();
409
+ },
410
+ }]),
411
+ ];
376
412
  }
377
413
  /** A name as a part of an element's id, without spaces: "dice sound" is dice-sound. */
378
414
  function idOf(name) {
@@ -471,7 +507,8 @@ function PageSettings() {
471
507
  return (_jsxs("section", { class: "settings-group", children: [_jsx("h3", { children: t("This page") }), _jsx("p", { class: "setting-about", children: t("Kept in this browser alone.") }), rows.map((row) => {
472
508
  const id = `page-${row.key}`;
473
509
  const chosen = row.options.find((option) => option.value === row.value);
474
- return (_jsxs("div", { class: row.under === true ? "setting under" : "setting", children: [_jsxs("div", { class: "setting-what", children: [_jsx("span", { class: "setting-name", id: id, children: row.name }), _jsx("span", { class: "setting-about", id: `${id}-about`, children: row.about })] }), _jsx(Segmented, { label: id, described: chosen?.means === undefined ? `${id}-about` : `${id}-about ${id}-means`, options: row.options, value: row.value, onPick: row.pick }), chosen?.means !== undefined && (_jsx("div", { class: "setting-after", children: _jsxs("p", { class: "setting-means", id: `${id}-means`, children: [_jsxs("strong", { children: [chosen.label, ":"] }), " ", chosen.means] }) }))] }, row.key));
510
+ const described = [`${id}-about`, ...(chosen?.means === undefined ? [] : [`${id}-means`]), ...(row.note === undefined ? [] : [`${id}-note`])].join(" ");
511
+ return (_jsxs("div", { class: row.under === true ? "setting under" : "setting", children: [_jsxs("div", { class: "setting-what", children: [_jsx("span", { class: "setting-name", id: id, children: row.name }), _jsx("span", { class: "setting-about", id: `${id}-about`, children: row.about })] }), _jsx(Segmented, { label: id, described: described, options: row.options, value: row.value, onPick: row.pick }), (chosen?.means !== undefined || row.note !== undefined) && (_jsxs("div", { class: "setting-after", children: [chosen?.means !== undefined && (_jsxs("p", { class: "setting-means", id: `${id}-means`, children: [_jsxs("strong", { children: [chosen.label, ":"] }), " ", chosen.means] })), row.note !== undefined && _jsx("p", { class: "setting-means", id: `${id}-note`, children: row.note })] }))] }, row.key));
475
512
  })] }));
476
513
  }
477
514
  /**
@@ -547,7 +584,7 @@ function Segmented({ label, described, options, value, onPick }) {
547
584
  }
548
585
  /** A group of the campaign's settings by its place, in the page's language. */
549
586
  function groupTitle(index) {
550
- return [t("The game"), t("Learning the game"), t("The master's style"), t("Dice and measures"), t("Limits"), t("Your companions"), t("Pictures and language")][index] ?? "";
587
+ return [t("The game"), t("Learning the game"), t("The master's style"), t("Dice and measures"), t("Limits"), t("Your companions"), t("Pictures and language"), t("Git")][index] ?? "";
551
588
  }
552
589
  /** What a list's field suggests, as an example. */
553
590
  function exampleOf(name) {
@@ -38,9 +38,12 @@ export function PartyStrip({ party, chosen, scene, waiting = new Map() }) {
38
38
  : counter && _jsx(Bar, { value: counter, label: fieldLabel(counter.field) }), _jsx(Effects, { effects: besideWord(member.effects, status.person), most: 2 })] }, member.name));
39
39
  }) }));
40
40
  }
41
- /** A party member's token with the pip of their state (D-419), in the strip and the sheet's band; never in the rolls. Their class in its tooltip (D-409). */
41
+ /**
42
+ * A party member's token with the pip of their state (D-419), in the strip and the sheet's band; never in the rolls. Their class in its tooltip in the strip
43
+ * (D-409); none on the sheet's band, large, which writes name and class beside it and has the picture's control on its rim.
44
+ */
42
45
  export function MemberToken({ member, large, status, choices }) {
43
- return (_jsxs("span", { class: "token-holder", "data-tip": member.headline === undefined ? undefined : `${member.name} · ${member.headline}`, children: [_jsx(Token, { member: member, large: large, side: sideOf(member.role), status: status, dying: downTint(status) }), choices === true && (_jsx("span", { class: "choices-pip", "aria-hidden": "true", children: _jsx(Icon, { name: "up" }) }))] }));
46
+ return (_jsxs("span", { class: "token-holder", "data-tip": member.headline === undefined || large === true ? undefined : `${member.name} · ${member.headline}`, children: [_jsx(Token, { member: member, large: large, side: sideOf(member.role), status: status, dying: downTint(status) }), choices === true && (_jsx("span", { class: "choices-pip", "aria-hidden": "true", children: _jsx(Icon, { name: "up" }) }))] }));
44
47
  }
45
48
  /** The side of one of the party by their role; anyone else has none. */
46
49
  export function sideOf(role) {
@@ -12,6 +12,7 @@ import { fieldLabel, groupLabels, itemLabel, phraseLabel, readableIds, rollLabel
12
12
  import { arrangedGroups, groupLayout, orderedValues, widgetOf } from "../parts/layout.js";
13
13
  import { knowersOf, Markdown, plainLine } from "../parts/markdown.js";
14
14
  import { MoodFace, moodLabel } from "../parts/mood.js";
15
+ import { PictureSpot } from "../parts/picture.js";
15
16
  import { besideWord, memberStatus } from "../parts/status.js";
16
17
  import { Effects, ProgressBar, ValueDrawing } from "../parts/widgets.js";
17
18
  import { ChoicesNotice } from "../play/choices.js";
@@ -37,7 +38,7 @@ export function MemberSheet({ member, headline, layered, sheet, cards, text, kno
37
38
  const shownApart = personFields([...person, ...boxes]);
38
39
  // The player character's story has its own card: the rest of the page's text is its description (D-386).
39
40
  const described = story !== undefined && story.trim() !== "" && text.startsWith(story) ? text.slice(story.length).trimStart() : text;
40
- return (_jsxs("section", { class: "sheet", "aria-label": member.name, children: [_jsxs("header", { class: "band", children: [_jsxs("div", { class: "identity", children: [_jsx(MemberToken, { member: member, large: true, status: status }), _jsxs("div", { class: "who", children: [_jsx("h2", { children: member.name }), (headline !== undefined && headline !== "") || member.mood !== undefined
41
+ return (_jsxs("section", { class: "sheet", "aria-label": member.name, children: [_jsxs("header", { class: "band", children: [_jsxs("div", { class: "identity", children: [_jsx(PictureSpot, { page: member.name, has: member.image !== undefined, children: _jsx(MemberToken, { member: member, large: true, status: status }) }), _jsxs("div", { class: "who", children: [_jsx("h2", { children: member.name }), (headline !== undefined && headline !== "") || member.mood !== undefined
41
42
  ? (_jsxs("p", { class: "headline", children: [headline, headline !== undefined && headline !== "" && member.mood !== undefined && " · ", member.mood !== undefined && (_jsxs("span", { class: "mood-word", children: [_jsx(MoodFace, { mood: member.mood }), moodLabel(member.mood)] }))] }))
42
43
  : null, member.place && (_jsxs("p", { class: "place", children: [_jsx(Icon, { name: "place" }), memberPlaceLabel(member.place)] })), layered === true && _jsx(ChangedLine, {})] })] }), choices.map((set) => _jsx(ChoicesNotice, { set: set }, set.id)), person.map((shown) => _jsx(PersonPanel, { shown: shown }, shown.widget.id)), _jsx(ValueLine, { values: member.counters.filter((value) => !shownApart.has(value.field)), fields: fields, boxes: boxes }), _jsx(Effects, { effects: besideWord(member.effects, status.person) })] }), _jsxs("div", { class: "sheet-body", children: [rail.length > 0 && _jsx("div", { class: "rail", children: rail.map(group) }), _jsxs("div", { class: "sheet-main", children: [_jsx(FixedColumns, { cards: others.map((shown) => ({ key: shown.name, node: group(shown) })) }), _jsxs("div", { class: "wide-cards", children: [story !== undefined && (_jsxs(Card, { name: backstoryCard, title: t("Backstory"), icon: cardIcons.backstory, layout: "lore", preview: plainLine(story) ?? t("Not written yet"), children: [story.trim() !== "" && _jsx(Markdown, { text: story }), _jsx(StoryBox, { story: story, who: member.name })] })), described.trim() !== "" && (_jsx(Card, { name: descriptionCard, title: t("Description"), icon: cardIcons.description, layout: "lore", preview: plainLine(described), children: _jsx(Markdown, { text: described, secretKnowers: knowersOf(knownBy) }) }))] }), _jsx(WidgetCards, { place: "page", page: "sheet", who: member.name, view: member })] })] })] }));
43
44
  }
@@ -1,11 +1,11 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "preact/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
2
2
  import { Icon } from "../parts/icons.js";
3
3
  import { languageName } from "../settings/languages.js";
4
4
  import { pageLocale, pageTranslation, t } from "../text.js";
5
5
  export function Notices({ notices }) {
6
6
  return notices.length === 0 ? null : (_jsx("div", { class: "notices", children: notices.map((notice) => {
7
7
  // The role on the words alone, always the same node: a count beside them is read where it is, never heard at each step.
8
- return (_jsxs("p", { class: `notice ${notice.kind}`, children: [_jsx(Icon, { name: notice.kind === "info" ? "info" : "alert" }), _jsx("span", { role: notice.kind === "problem" ? "alert" : "status", children: notice.text }), notice.count !== undefined && (_jsxs(_Fragment, { children: [_jsx("span", { class: "count", dir: "ltr", children: `${notice.count.done}/${notice.count.of}` }), _jsx("span", { class: "bar", "aria-hidden": "true", style: { "--done": `${Math.round((100 * notice.count.done) / Math.max(notice.count.of, 1))}%` } })] }))] }, notice.key ?? notice.text));
8
+ return (_jsxs("p", { class: `notice ${notice.kind}`, children: [_jsx(Icon, { name: notice.kind === "info" ? "info" : "alert" }), _jsxs("span", { class: "notice-words", children: [_jsx("span", { role: notice.kind === "problem" ? "alert" : "status", children: notice.text }), notice.link !== undefined && _jsx("a", { class: "notice-link", href: notice.link.href, children: notice.link.text })] }), notice.count !== undefined && (_jsxs(_Fragment, { children: [_jsx("span", { class: "count", dir: "ltr", children: `${notice.count.done}/${notice.count.of}` }), _jsx("span", { class: "bar", "aria-hidden": "true", style: { "--done": `${Math.round((100 * notice.count.done) / Math.max(notice.count.of, 1))}%` } })] })), notice.hide !== undefined && (_jsx("button", { type: "button", class: "icon-button notice-hide tip-left", "aria-label": notice.hide.label, "data-tip": notice.hide.label, onClick: notice.hide.onHide, children: _jsx(Icon, { name: "close" }) }))] }, notice.key ?? notice.text));
9
9
  }) }));
10
10
  }
11
11
  /** What the page says of an import under way (D-491 (11)): what it is doing, and how far; nothing without one. */
@@ -1,19 +1,51 @@
1
+ // The game's style on the page (D-528, D-574): the theme of the campaign's system, its CSS of custom properties in the layer theme, its icons, and the free
2
+ // style sheet of the system's page module over the page's; or a theme installed on this computer, its CSS and icons alone; or the page's own. This browser
3
+ // remembers the choice for each system. A theme's own style sheet comes last, in the layer theme-style, while the player keeps it on, for each theme (D-575).
4
+ import { readAddress } from "../address.js";
1
5
  import { readChoice } from "./prefs.js";
2
6
  /** The event that tells the page the game's style changed: what draws an icon draws it again. */
3
7
  export const gameStyleChanged = "rpg-engine:game-style";
4
- /** Whether the page shows the game's style, by system: the game's, or the page's own. */
8
+ /** The value of the choice that shows an installed theme, by its id. */
9
+ export function installedStyle(id) {
10
+ return `theme:${id}`;
11
+ }
12
+ /**
13
+ * Which style the page shows, by system: the game's, while it has one to show; an installed theme, while it is installed; or the page's own. One no longer
14
+ * offered goes back to the first: the game's, else the page's.
15
+ */
5
16
  export function systemStylePref(system) {
6
- return { key: `rpg-engine.game-style.${system}`, initial: "game", values: ["game", "page"] };
17
+ const shows = gameShows();
18
+ return {
19
+ key: `rpg-engine.game-style.${system}`,
20
+ initial: shows ? "game" : "page",
21
+ values: [...(shows ? ["game"] : []), ...(theme.themes ?? []).map((one) => installedStyle(one.id)), "page"],
22
+ };
7
23
  }
8
- /** The game's style as last read, for Settings: its system and its theme's name; whether it has anything to show, or its theme was refused. */
24
+ /**
25
+ * The game's style as last read, for Settings: its system and its theme's name; whether it has anything to show, or its theme was refused; the themes
26
+ * installed; and the choice that keeps the own style sheet of the theme shown on, when it has one.
27
+ */
9
28
  export function gameStyle() {
10
- return { system: theme.system, name: theme.name, shows: theme.css !== undefined || freeStyle !== undefined, refused: theme.refused === true };
29
+ const own = shownOwnStyle();
30
+ return {
31
+ system: theme.system,
32
+ name: theme.name,
33
+ shows: gameShows(),
34
+ refused: theme.refused === true,
35
+ themes: (theme.themes ?? []).map(({ id, name }) => ({ id, name })),
36
+ ...(own === undefined ? {} : { ownStyle: own.choice }),
37
+ };
38
+ }
39
+ /** The installed theme the page shows for the campaign's system, by its id; undefined when it shows the game's style or its own. */
40
+ export function shownInstalledTheme() {
41
+ return chosen().installed?.id;
11
42
  }
12
- /** The lines of an icon the game's style draws anew, while it is on; undefined for the page's own. */
43
+ /** The lines of an icon the style shown draws anew; undefined for the page's own. */
13
44
  export function themedIcon(name) {
14
- return styleOn() ? theme.icons?.[name] : undefined;
45
+ const style = chosen();
46
+ return style.installed !== undefined ? style.installed.icons[name] : style.game ? theme.icons?.[name] : undefined;
15
47
  }
16
- /** Takes the theme of the campaign's system as read, and the free style sheet of its page module; the page shows them while the game's style is on. */
48
+ /** Takes the theme of the campaign's system as read, with the themes installed, and the free style sheet of its page module; the page shows the one chosen. */
17
49
  export function takeSystemStyle(read, pageStyle) {
18
50
  const same = JSON.stringify(read) === JSON.stringify(theme) && pageStyle === freeStyle;
19
51
  theme = read;
@@ -22,18 +54,20 @@ export function takeSystemStyle(read, pageStyle) {
22
54
  applyGameStyle();
23
55
  }
24
56
  }
25
- /** Shows the game's style or the page's own, as the player keeps it for the campaign's system: after a change of that choice, or of what the system gives. */
57
+ /** Shows the style the player keeps for the campaign's system: after a change of that choice, or of what the system and this computer give. */
26
58
  export function applyGameStyle() {
27
59
  if (typeof document === "undefined") {
28
60
  return;
29
61
  }
30
- const on = styleOn();
62
+ const style = chosen();
31
63
  themeSheet ??= new CSSStyleSheet();
32
64
  freeSheet ??= new CSSStyleSheet();
33
- themeSheet.replaceSync(on ? theme.css ?? "" : "");
34
- freeSheet.replaceSync(on ? freeStyle ?? "" : "");
35
- const others = document.adoptedStyleSheets.filter((sheet) => sheet !== themeSheet && sheet !== freeSheet);
36
- document.adoptedStyleSheets = [...others, themeSheet, freeSheet];
65
+ themeSheet.replaceSync(style.installed?.css ?? (style.game ? theme.css ?? "" : ""));
66
+ // The free style of the system's page module goes with its own theme alone: never under another's colours.
67
+ freeSheet.replaceSync(style.game ? freeStyle ?? "" : "");
68
+ adopt();
69
+ watchAddress();
70
+ showOwnStyle();
37
71
  document.querySelectorAll(".title-too-wide").forEach((title) => title.classList.remove("title-too-wide"));
38
72
  watchTitles();
39
73
  fitTitles();
@@ -43,12 +77,93 @@ let theme = {};
43
77
  let freeStyle;
44
78
  let themeSheet;
45
79
  let freeSheet;
80
+ // The link to the own style sheet of the theme shown, and its address.
81
+ let ownLink;
82
+ let ownAddress;
83
+ /** The page's sheets of the game's style, after the page's own: the theme's custom properties, the system's free style. */
84
+ function adopt() {
85
+ const ours = [themeSheet, freeSheet].filter((sheet) => sheet !== undefined);
86
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets.filter((sheet) => !ours.includes(sheet)), ...ours];
87
+ }
88
+ /** The own style sheet of the theme shown, when it has one: its address, and the choice that keeps it on, by the theme. */
89
+ function shownOwnStyle() {
90
+ const style = chosen();
91
+ const address = style.installed?.style ?? (style.game ? theme.style : undefined);
92
+ const key = style.installed?.id ?? `game.${theme.system ?? ""}`;
93
+ return address === undefined ? undefined : { address, choice: { key: `rpg-engine.theme-style.${key}`, initial: "on", values: ["on", "off"] } };
94
+ }
95
+ /**
96
+ * Shows a theme's own style sheet, from its address, or none: a link to the server's sheet of one line that imports it into the layer theme-style, so that
97
+ * no brace of it closes that layer and its url() come from its folder. The new one shows before the old goes; one that fails is asked again at the next change.
98
+ */
99
+ function takeOwnStyle(address) {
100
+ if (address === ownAddress) {
101
+ return;
102
+ }
103
+ ownAddress = address;
104
+ const gone = ownLink;
105
+ ownLink = undefined;
106
+ if (address === undefined) {
107
+ gone?.remove();
108
+ return;
109
+ }
110
+ const link = document.createElement("link");
111
+ link.rel = "stylesheet";
112
+ link.href = address;
113
+ link.addEventListener("load", () => {
114
+ gone?.remove();
115
+ fitTitles();
116
+ });
117
+ link.addEventListener("error", () => {
118
+ gone?.remove();
119
+ if (ownLink === link) {
120
+ link.remove();
121
+ ownLink = undefined;
122
+ ownAddress = undefined;
123
+ }
124
+ });
125
+ ownLink = link;
126
+ document.head.append(link);
127
+ }
128
+ /** Whether the page shows Settings, which never take a theme's own style sheet: whatever it does, the switch that turns it off stays in reach. */
129
+ function inSettings() {
130
+ return readAddress(window.location.hash).section === "settings";
131
+ }
132
+ /** Takes the own style sheet off on the way into Settings, and back on the way out. */
133
+ function watchAddress() {
134
+ if (watchingAddress) {
135
+ return;
136
+ }
137
+ watchingAddress = true;
138
+ window.addEventListener("hashchange", showOwnStyle);
139
+ }
140
+ /** Shows the own style sheet of the theme shown while the player keeps it on, out of Settings. */
141
+ function showOwnStyle() {
142
+ const own = shownOwnStyle();
143
+ takeOwnStyle(own !== undefined && readChoice(own.choice) === "on" && !inSettings() ? own.address : undefined);
144
+ }
145
+ let watchingAddress = false;
46
146
  let watching = false;
47
147
  let fitting = false;
48
148
  // The card titles the theme's face may make too wide, and the campaign's name.
49
149
  const titles = ":is(summary, .card-head) :is(h2, h3, .rolls-title), .titles h1";
150
+ /** Whether the game's own style has anything to show: its theme, or the free style of its page module. */
151
+ function gameShows() {
152
+ return theme.css !== undefined || freeStyle !== undefined;
153
+ }
154
+ /** The style the player keeps for the campaign's system: the game's, an installed theme, or neither, the page's own. */
155
+ function chosen() {
156
+ if (theme.system === undefined) {
157
+ return { game: false };
158
+ }
159
+ const value = readChoice(systemStylePref(theme.system));
160
+ const installed = theme.themes?.find((one) => installedStyle(one.id) === value);
161
+ return installed === undefined ? { game: value === "game" } : { game: false, installed };
162
+ }
163
+ /** Whether a style other than the page's own is on, whose faces may make a title too wide. */
50
164
  function styleOn() {
51
- return theme.system !== undefined && gameStyle().shows && readChoice(systemStylePref(theme.system)) === "game";
165
+ const style = chosen();
166
+ return style.game || style.installed !== undefined;
52
167
  }
53
168
  /**
54
169
  * Each title the theme's face makes wider than its card goes back to the text's face, that title alone (D-528 (4)): measured as the page changes, as its
@@ -76,7 +191,9 @@ function fitTitles() {
76
191
  fitting = false;
77
192
  for (const title of document.querySelectorAll(titles)) {
78
193
  const head = title.closest("summary, .card-head") ?? title;
79
- if (!title.classList.contains("title-too-wide") && (title.scrollWidth > title.clientWidth + 1 || head.scrollWidth > head.clientWidth + 1)) {
194
+ // The campaign's name is cut by its link, not by its title.
195
+ const cut = title.querySelector(":scope > .title-home") ?? title;
196
+ if (!title.classList.contains("title-too-wide") && (cut.scrollWidth > cut.clientWidth + 1 || head.scrollWidth > head.clientWidth + 1)) {
80
197
  title.classList.add("title-too-wide");
81
198
  }
82
199
  }
@@ -0,0 +1,224 @@
1
+ // The page's one tooltip (T-228): what a control's `data-tip` says, shown in the top layer over every card, list and dialog, so that no box that scrolls or
2
+ // clips cuts it, and placed beside its control inside the window. After a moment under a pointer, at once when the keyboard reaches it, never at a touch;
3
+ // Escape or a press hides it. It is for the eye: what it says is already the control's name for a screen reader. It reaches into the packages' shadow roots.
4
+ // How far from its control, and from the window's edges.
5
+ const gap = 8;
6
+ const margin = 8;
7
+ // Moving from one tip to the next within this time shows the next at once.
8
+ const followTime = 300;
9
+ let tip;
10
+ // Whose tip shows, or waits for its moment, and how it was reached.
11
+ let target;
12
+ let reachedBy;
13
+ let timer;
14
+ // A control pressed or dismissed with Escape shows no tip until the pointer leaves it.
15
+ let quiet;
16
+ let hiddenAt = 0;
17
+ const watcher = typeof MutationObserver === "undefined" ? undefined : new MutationObserver(() => follow());
18
+ /** Starts the page's tooltips, once, at the page's start. */
19
+ export function startTooltips() {
20
+ document.addEventListener("pointerover", onPointerOver, true);
21
+ document.addEventListener("pointerout", onPointerOut, true);
22
+ document.addEventListener("pointerdown", onPress, true);
23
+ document.addEventListener("focusin", onFocusIn, true);
24
+ document.addEventListener("focusout", onFocusOut, true);
25
+ document.addEventListener("keydown", onKey, true);
26
+ document.addEventListener("scroll", onScroll, { capture: true, passive: true });
27
+ window.addEventListener("resize", onScroll, { passive: true });
28
+ }
29
+ function onPointerOver(event) {
30
+ if (event.pointerType === "touch") {
31
+ return;
32
+ }
33
+ const found = tipped(event.composedPath());
34
+ if (found !== quiet) {
35
+ quiet = undefined;
36
+ }
37
+ if (found === undefined || found === quiet) {
38
+ if (reachedBy !== "focus") {
39
+ hide();
40
+ }
41
+ return;
42
+ }
43
+ if (found !== target || reachedBy !== "pointer") {
44
+ const shownNow = tip?.classList.contains("shown") === true || performance.now() - hiddenAt < followTime;
45
+ wait(found, shownNow ? 0 : waitTime());
46
+ }
47
+ }
48
+ // The pointer leaving the window.
49
+ function onPointerOut(event) {
50
+ if (event.relatedTarget === null && reachedBy === "pointer") {
51
+ hide();
52
+ }
53
+ }
54
+ function onPress(event) {
55
+ const found = tipped(event.composedPath());
56
+ if (found !== undefined) {
57
+ quiet = found;
58
+ }
59
+ hide();
60
+ }
61
+ function onFocusIn(event) {
62
+ const focused = event.composedPath()[0];
63
+ if (focused instanceof Element && hasTip(focused) && focused !== quiet && focused.matches(":focus-visible")) {
64
+ show(focused, "focus");
65
+ }
66
+ else if (reachedBy === "focus") {
67
+ hide();
68
+ }
69
+ }
70
+ function onFocusOut(event) {
71
+ // Dismissed with Escape, it shows again when the keyboard comes back to it.
72
+ if (quiet === event.composedPath()[0]) {
73
+ quiet = undefined;
74
+ }
75
+ if (reachedBy === "focus") {
76
+ hide();
77
+ }
78
+ }
79
+ // Escape hides the tip shown (WCAG 1.4.13), and lets the key go on to what else it closes.
80
+ function onKey(event) {
81
+ if (event.key === "Escape" && target !== undefined) {
82
+ quiet = target;
83
+ hide();
84
+ }
85
+ }
86
+ // The tip follows its control as the page or a list scrolls, and goes with it out of sight; the pointer, left behind, shows the next as it goes over it.
87
+ function onScroll() {
88
+ place();
89
+ }
90
+ /** The nearest control with a tip along an event's path, across shadow roots. */
91
+ function tipped(path) {
92
+ return path.find((step) => step instanceof Element && hasTip(step));
93
+ }
94
+ function hasTip(element) {
95
+ return (element.getAttribute("data-tip") ?? "") !== "";
96
+ }
97
+ function wait(element, time) {
98
+ clearTimeout(timer);
99
+ if (time === 0) {
100
+ show(element, "pointer");
101
+ return;
102
+ }
103
+ hide();
104
+ target = element;
105
+ reachedBy = "pointer";
106
+ timer = setTimeout(() => show(element, "pointer"), time);
107
+ }
108
+ function show(element, how) {
109
+ clearTimeout(timer);
110
+ const shown = tipElement();
111
+ target = element;
112
+ reachedBy = how;
113
+ shown.textContent = element.getAttribute("data-tip");
114
+ shown.dir = getComputedStyle(element).direction === "rtl" ? "rtl" : "ltr";
115
+ watcher?.disconnect();
116
+ watcher?.observe(element, { attributes: true, attributeFilter: ["data-tip"] });
117
+ // Shown again, so that it stands over a dialog opened since; its side and state set before, as showing it reads its style, which it comes from.
118
+ if (shown.classList.contains("shown")) {
119
+ closeLayer(shown);
120
+ }
121
+ shown.dataset.side = askedSide(element);
122
+ shown.classList.add("shown");
123
+ openLayer(shown);
124
+ place();
125
+ }
126
+ function hide() {
127
+ clearTimeout(timer);
128
+ watcher?.disconnect();
129
+ target = undefined;
130
+ reachedBy = undefined;
131
+ if (tip?.classList.contains("shown") === true) {
132
+ tip.classList.remove("shown");
133
+ closeLayer(tip);
134
+ hiddenAt = performance.now();
135
+ }
136
+ }
137
+ // Its control's words changed while it shows, as a picture's while it is sent; or went.
138
+ function follow() {
139
+ if (target === undefined || tip === undefined) {
140
+ return;
141
+ }
142
+ if (!hasTip(target)) {
143
+ hide();
144
+ return;
145
+ }
146
+ tip.textContent = target.getAttribute("data-tip");
147
+ place();
148
+ }
149
+ /** Over its control, or under it (`.tip-below`), or on its start side (`.tip-left`), as asked; where there is no room, the other way; inside the window. */
150
+ function place() {
151
+ if (target === undefined || tip === undefined || !tip.classList.contains("shown")) {
152
+ return;
153
+ }
154
+ const box = target.getBoundingClientRect();
155
+ const windowWidth = document.documentElement.clientWidth;
156
+ const windowHeight = window.innerHeight;
157
+ // Its control gone, or scrolled out of sight.
158
+ if (!target.isConnected || (box.width === 0 && box.height === 0) || box.bottom < 0 || box.top > windowHeight) {
159
+ hide();
160
+ return;
161
+ }
162
+ const width = tip.offsetWidth;
163
+ const height = tip.offsetHeight;
164
+ const rtl = tip.dir === "rtl";
165
+ const asked = askedSide(target);
166
+ const startLeft = rtl ? box.right + gap : box.left - gap - width;
167
+ const roomAbove = box.top - gap - height >= margin;
168
+ const roomBelow = box.bottom + gap + height <= windowHeight - margin;
169
+ const roomStart = startLeft >= margin && startLeft + width <= windowWidth - margin;
170
+ const side = asked === "start" && roomStart ? "start" : asked === "below" ? (roomBelow || !roomAbove ? "below" : "above") : roomAbove || !roomBelow ? "above" : "below";
171
+ const left = side === "start" ? startLeft : box.left + box.width / 2 - width / 2;
172
+ const top = side === "start" ? box.top + box.height / 2 - height / 2 : side === "above" ? box.top - gap - height : box.bottom + gap;
173
+ tip.dataset.side = side;
174
+ // Inline and !important, as no style sheet's rule outweighs them, a theme's own either (D-575).
175
+ tip.style.setProperty("left", `${Math.round(within(left, margin, windowWidth - margin - width))}px`, "important");
176
+ tip.style.setProperty("top", `${Math.round(within(top, margin, windowHeight - margin - height))}px`, "important");
177
+ }
178
+ function askedSide(element) {
179
+ return element.classList.contains("tip-left") ? "start" : element.classList.contains("tip-below") ? "below" : "above";
180
+ }
181
+ function within(value, low, high) {
182
+ return Math.max(low, Math.min(value, high));
183
+ }
184
+ // The one tip of the page, made at its first need, hidden from a screen reader: the control says it already.
185
+ function tipElement() {
186
+ if (tip === undefined) {
187
+ tip = document.createElement("div");
188
+ tip.className = "page-tip";
189
+ tip.setAttribute("aria-hidden", "true");
190
+ if (supportsPopover(tip)) {
191
+ tip.popover = "manual";
192
+ }
193
+ else {
194
+ tip.hidden = true;
195
+ }
196
+ document.body.append(tip);
197
+ }
198
+ return tip;
199
+ }
200
+ function openLayer(element) {
201
+ if (supportsPopover(element)) {
202
+ element.showPopover();
203
+ }
204
+ else {
205
+ element.hidden = false;
206
+ }
207
+ }
208
+ function closeLayer(element) {
209
+ if (!supportsPopover(element)) {
210
+ element.hidden = true;
211
+ }
212
+ else if (element.matches(":popover-open")) {
213
+ element.hidePopover();
214
+ }
215
+ }
216
+ function supportsPopover(element) {
217
+ return typeof element.showPopover === "function";
218
+ }
219
+ // The moment a pointer rests on a control before its tip shows: the page's --wait, never more than a second, whatever a theme's own sheet says (D-575).
220
+ function waitTime() {
221
+ const value = getComputedStyle(document.documentElement).getPropertyValue("--wait").trim();
222
+ const time = Number.parseFloat(value);
223
+ return Number.isNaN(time) ? 500 : Math.min(Math.max(value.endsWith("ms") ? time : time * 1000, 0), 1000);
224
+ }