@mattebox/player 0.8.0 → 0.9.1

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 (102) hide show
  1. package/dist/cdn/mattebox-player.min.js +3 -3
  2. package/dist/controls/cues.d.ts.map +1 -1
  3. package/dist/controls/cues.js +11 -5
  4. package/dist/controls/cues.js.map +1 -1
  5. package/dist/controls/icons.d.ts +5 -30
  6. package/dist/controls/icons.d.ts.map +1 -1
  7. package/dist/controls/icons.js +38 -29
  8. package/dist/controls/icons.js.map +1 -1
  9. package/dist/controls/menu.d.ts +20 -0
  10. package/dist/controls/menu.d.ts.map +1 -1
  11. package/dist/controls/menu.js +83 -14
  12. package/dist/controls/menu.js.map +1 -1
  13. package/dist/element.d.ts +36 -2
  14. package/dist/element.d.ts.map +1 -1
  15. package/dist/element.js +140 -24
  16. package/dist/element.js.map +1 -1
  17. package/dist/elements/audio-menu.d.ts.map +1 -1
  18. package/dist/elements/audio-menu.js +3 -1
  19. package/dist/elements/audio-menu.js.map +1 -1
  20. package/dist/elements/component.d.ts.map +1 -1
  21. package/dist/elements/component.js +10 -0
  22. package/dist/elements/component.js.map +1 -1
  23. package/dist/elements/control-bar.d.ts +2 -0
  24. package/dist/elements/control-bar.d.ts.map +1 -1
  25. package/dist/elements/control-bar.js +23 -7
  26. package/dist/elements/control-bar.js.map +1 -1
  27. package/dist/elements/current-time.d.ts.map +1 -1
  28. package/dist/elements/current-time.js +1 -1
  29. package/dist/elements/current-time.js.map +1 -1
  30. package/dist/elements/drm-badge.js +1 -1
  31. package/dist/elements/duration.d.ts.map +1 -1
  32. package/dist/elements/duration.js +6 -2
  33. package/dist/elements/duration.js.map +1 -1
  34. package/dist/elements/error-screen.js +1 -1
  35. package/dist/elements/live-button.js +1 -1
  36. package/dist/elements/marker-button.d.ts +3 -3
  37. package/dist/elements/marker-button.d.ts.map +1 -1
  38. package/dist/elements/marker-button.js +18 -22
  39. package/dist/elements/marker-button.js.map +1 -1
  40. package/dist/elements/menu-element.d.ts.map +1 -1
  41. package/dist/elements/menu-element.js +2 -1
  42. package/dist/elements/menu-element.js.map +1 -1
  43. package/dist/elements/quality-menu.js +1 -1
  44. package/dist/elements/quality-menu.js.map +1 -1
  45. package/dist/elements/scan-button.js +1 -1
  46. package/dist/elements/seek-bar.d.ts.map +1 -1
  47. package/dist/elements/seek-bar.js +5 -4
  48. package/dist/elements/seek-bar.js.map +1 -1
  49. package/dist/elements/shared.js +3 -3
  50. package/dist/elements/skip-button.js +2 -2
  51. package/dist/elements/skip-button.js.map +1 -1
  52. package/dist/elements/spinner.js +1 -1
  53. package/dist/elements/start-button.d.ts +8 -0
  54. package/dist/elements/start-button.d.ts.map +1 -1
  55. package/dist/elements/start-button.js +18 -2
  56. package/dist/elements/start-button.js.map +1 -1
  57. package/dist/elements/subtitles-menu.d.ts +5 -1
  58. package/dist/elements/subtitles-menu.d.ts.map +1 -1
  59. package/dist/elements/subtitles-menu.js +29 -11
  60. package/dist/elements/subtitles-menu.js.map +1 -1
  61. package/dist/elements/title.d.ts.map +1 -1
  62. package/dist/elements/title.js +3 -1
  63. package/dist/elements/title.js.map +1 -1
  64. package/dist/elements/volume-slider.js +1 -1
  65. package/dist/elements/volume.js +1 -1
  66. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/asyncToGenerator.js +1 -1
  67. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/defineProperty.js +1 -1
  68. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/objectSpread2.js +1 -1
  69. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/toPrimitive.js +1 -1
  70. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/toPropertyKey.js +1 -1
  71. package/dist/es2015/_virtual/{_@oxc-project_runtime@0.152.0 → _@oxc-project_runtime@0.153.0}/helpers/esm/typeof.js +1 -1
  72. package/dist/es2015/controls/chapters.js +1 -1
  73. package/dist/es2015/controls/cues.js +11 -5
  74. package/dist/es2015/controls/icons.js +38 -29
  75. package/dist/es2015/controls/menu.js +89 -17
  76. package/dist/es2015/element.js +144 -30
  77. package/dist/es2015/elements/audio-menu.js +4 -1
  78. package/dist/es2015/elements/component.js +10 -0
  79. package/dist/es2015/elements/control-bar.js +23 -7
  80. package/dist/es2015/elements/current-time.js +1 -1
  81. package/dist/es2015/elements/drm-badge.js +1 -1
  82. package/dist/es2015/elements/duration.js +6 -2
  83. package/dist/es2015/elements/error-screen.js +1 -1
  84. package/dist/es2015/elements/live-button.js +1 -1
  85. package/dist/es2015/elements/marker-button.js +19 -23
  86. package/dist/es2015/elements/menu-element.js +2 -1
  87. package/dist/es2015/elements/quality-menu.js +1 -1
  88. package/dist/es2015/elements/scan-button.js +1 -1
  89. package/dist/es2015/elements/seek-bar.js +5 -4
  90. package/dist/es2015/elements/shared.js +3 -3
  91. package/dist/es2015/elements/skip-button.js +2 -2
  92. package/dist/es2015/elements/spinner.js +1 -1
  93. package/dist/es2015/elements/start-button.js +18 -2
  94. package/dist/es2015/elements/subtitles-menu.js +35 -17
  95. package/dist/es2015/elements/title.js +3 -1
  96. package/dist/es2015/elements/volume-slider.js +1 -1
  97. package/dist/es2015/elements/volume.js +1 -1
  98. package/dist/es2015/presets.js +1 -1
  99. package/dist/es2015/style.js +1 -1
  100. package/dist/style.js +1 -1
  101. package/package.json +4 -5
  102. package/NOTICE +0 -24
@@ -2,7 +2,7 @@ import { el } from "../dom.js";
2
2
  import { Component } from "./component.js";
3
3
  import { style } from "./shared.js";
4
4
  //#region src/elements/error-screen.ts
5
- const STYLE = ":host{color:var(--mbx-text);font:400 15px / 1.4 var(--mbx-font);text-align:center;background:#000000bf;justify-content:center;align-items:center;padding:16px;display:flex;position:absolute;top:0;bottom:0;left:0;right:0}:host([hidden]){display:none}[part~=box]{flex-direction:column;align-items:center;display:flex}[part~=box]>:not([hidden])~:not([hidden]){margin-top:8px}[part~=title]{font-size:18px;font-weight:600}[part~=detail]{color:var(--mbx-error);font-family:monospace;font-size:13px}[part~=retry]{height:36px;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;background:0 0;border:1px solid;padding:0 16px;font-weight:600}[part~=retry]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=retry]:focus:not(:focus-visible){outline:none}";
5
+ const STYLE = ":host{color:var(--mbx-text);font:400 .9375em / 1.4 var(--mbx-font);text-align:center;background:#000000bf;justify-content:center;align-items:center;padding:1.0667em;display:flex;position:absolute;top:0;bottom:0;left:0;right:0}:host([hidden]){display:none}[part~=box]{flex-direction:column;align-items:center;display:flex}[part~=box]>:not([hidden])~:not([hidden]){margin-top:.5333em}[part~=title]{font-size:1.2em;font-weight:600}[part~=detail]{color:var(--mbx-error);font-family:monospace;font-size:.8667em}[part~=retry]{height:2.4em;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;background:0 0;border:1px solid;padding:0 1.0667em;font-weight:600}[part~=retry]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=retry]:focus:not(:focus-visible){outline:none}";
6
6
  var MbxErrorScreen = class extends Component {
7
7
  static get observedAttributes() {
8
8
  return ["label-title", "label-retry"];
@@ -16,7 +16,7 @@ import { live } from "../controls/session.js";
16
16
  * `text`, the name from `label-live` and `label-at-edge`. It sits in the
17
17
  * bar's seek row unless the page says otherwise.
18
18
  */
19
- const STYLE = ":host{display:inline-flex}:host([hidden]){display:none}[part~=button]{height:40px;font:inherit;letter-spacing:.06em;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;align-items:center;padding:0 8px;font-size:12px;font-weight:700;display:inline-flex}[part~=button]:hover{opacity:1}[part~=button]:disabled{cursor:default;opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline:none}[part~=dot]{background:var(--mbx-muted);border-radius:50%;width:10px;height:10px;margin-right:6px;transition:background .2s}:host([at-edge]) [part~=dot]{background:var(--mbx-live);box-shadow:0 0 6px var(--mbx-live)}@media (prefers-reduced-motion:reduce){[part~=dot]{transition:none}}";
19
+ const STYLE = ":host{display:inline-flex}:host([hidden]){display:none}[part~=button]{height:2.5em;font:inherit;letter-spacing:.06em;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;align-items:center;padding:0 .5em;font-size:.75em;font-weight:700;display:inline-flex}[part~=button]:hover{opacity:1}[part~=button]:disabled{cursor:default;opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline:none}[part~=dot]{background:var(--mbx-muted);border-radius:50%;width:.625em;height:.625em;margin-right:.375em;transition:background .2s}:host([at-edge]) [part~=dot]{background:var(--mbx-live);box-shadow:0 0 6px var(--mbx-live)}@media (prefers-reduced-motion:reduce){[part~=dot]{transition:none}}";
20
20
  var MbxLiveButton = class extends Component {
21
21
  static get observedAttributes() {
22
22
  return [
@@ -12,9 +12,9 @@ export declare class MbxMarkerButton extends Component {
12
12
  protected attach(player: PlayerHost): void;
13
13
  protected detach(): void;
14
14
  /**
15
- * Lifts the button above the bar's rows, or above the title's text while
16
- * it shows: each one's box less the padding over its content, which is
17
- * its fade. A hidden title has no box.
15
+ * Lifts the button above the bar's rows: the bar's box less the padding
16
+ * over them, its fade. The title sits on the other side, so the button
17
+ * stays where it is while the title shows.
18
18
  */
19
19
  private fit;
20
20
  protected render(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"marker-button.d.ts","sourceRoot":"","sources":["../../src/elements/marker-button.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAS3C,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,MAAM,CAAoB;IACnD,qEAAqE;IACrE,QAAgB,MAAM,CAAgB;IACtC,gFAAgF;IAChF,QAAgB,OAAO,CAAwB;;IAkBtC,iBAAiB,IAAI,IAAI;cAMf,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cAyBhC,MAAM,IAAI,IAAI;IAKjC;;;;OAIG;IACH,OAAO,CAAC,GAAG;cAWQ,MAAM,IAAI,IAAI;CAelC"}
1
+ {"version":3,"file":"marker-button.d.ts","sourceRoot":"","sources":["../../src/elements/marker-button.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAS3C,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEjD;IAED,iBAAyB,MAAM,CAAoB;IACnD,qEAAqE;IACrE,QAAgB,MAAM,CAAgB;IACtC,gFAAgF;IAChF,QAAgB,OAAO,CAAwB;;IAkBtC,iBAAiB,IAAI,IAAI;cAMf,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;cA6BhC,MAAM,IAAI,IAAI;IAKjC;;;;OAIG;IACH,OAAO,CAAC,GAAG;cAOQ,MAAM,IAAI,IAAI;CAoBlC"}
@@ -1,7 +1,7 @@
1
1
  import { Component } from "./component.js";
2
2
  import { BUTTON_STYLE, style } from "./shared.js";
3
3
  //#region src/elements/marker-button.ts
4
- const STYLE_CSS = ":host{right:calc(var(--mbx-pad,8px) + 8px);bottom:calc(var(--mbx-marker-lift,56px) + 12px);z-index:1;position:absolute}:host([hidden]){display:none}[part~=button]{width:auto;height:40px;color:var(--mbx-text);font:inherit;white-space:nowrap;background:#0009;border:1px solid #ffffff80;padding:0 18px;font-weight:600}[part~=button]:hover{background:#000c}";
4
+ const STYLE_CSS = ":host{right:calc(var(--mbx-pad,.5em) + .5em);bottom:calc(var(--mbx-marker-lift,3.5em) + .75em);z-index:1;transition:transform .3s;position:absolute}:host([idle]){transform:translateY(var(--mbx-marker-lift,3.5em))}:host([hidden]){display:none}[part~=button]{width:auto;height:2.5em;color:var(--mbx-text);font:inherit;white-space:nowrap;background:#0009;border:1px solid #ffffff80;padding:0 1.125em;font-weight:600}[part~=button]:hover{background:#000c}@media (prefers-reduced-motion:reduce){:host{transition:none}}";
5
5
  const WORDS = {
6
6
  "opening-credits": "Skip intro",
7
7
  "closing-credits": "Skip credits"
@@ -44,22 +44,21 @@ var MbxMarkerButton = class extends Component {
44
44
  this.listen(player, ["markerschange"], () => {
45
45
  this.render();
46
46
  });
47
- this.listen(player.video, [
48
- "play",
49
- "pause",
50
- "ended"
51
- ], () => {
52
- this.fit(player);
47
+ this.observe(player, ["upnext"], () => {
48
+ this.render();
53
49
  });
50
+ const idle = () => {
51
+ this.toggleAttribute("idle", player.hasAttribute("idle"));
52
+ };
53
+ this.observe(player, ["idle"], idle);
54
+ idle();
54
55
  if (typeof ResizeObserver !== "undefined") {
55
56
  this.resizer = new ResizeObserver(() => {
56
57
  this.fit(player);
57
58
  });
58
59
  this.resizer.observe(player);
59
- for (const tag of ["mbx-control-bar", "mbx-title"]) {
60
- const node = player.querySelector(tag);
61
- if (node !== null) this.resizer.observe(node);
62
- }
60
+ const bar = player.querySelector("mbx-control-bar");
61
+ if (bar !== null) this.resizer.observe(bar);
63
62
  }
64
63
  this.fit(player);
65
64
  this.render();
@@ -69,23 +68,20 @@ var MbxMarkerButton = class extends Component {
69
68
  this.resizer = null;
70
69
  }
71
70
  /**
72
- * Lifts the button above the bar's rows, or above the title's text while
73
- * it shows: each one's box less the padding over its content, which is
74
- * its fade. A hidden title has no box.
71
+ * Lifts the button above the bar's rows: the bar's box less the padding
72
+ * over them, its fade. The title sits on the other side, so the button
73
+ * stays where it is while the title shows.
75
74
  */
76
75
  fit(player) {
77
- let lift = 0;
78
- for (const tag of ["mbx-control-bar", "mbx-title"]) {
79
- const node = player.querySelector(tag);
80
- if (node === null) continue;
81
- const fade = Number.parseFloat(getComputedStyle(node).paddingTop) || 0;
82
- lift = Math.max(lift, node.getBoundingClientRect().height - fade);
83
- }
84
- this.style.setProperty("--mbx-marker-lift", `${lift}px`);
76
+ const bar = player.querySelector("mbx-control-bar");
77
+ const fade = bar === null ? 0 : Number.parseFloat(getComputedStyle(bar).paddingTop) || 0;
78
+ const lift = bar === null ? 0 : bar.getBoundingClientRect().height - fade;
79
+ this.style.setProperty("--mbx-marker-lift", `${Math.max(0, lift)}px`);
85
80
  }
86
81
  render() {
87
82
  const player = this.player;
88
83
  this.marker = player?.markers.within(player.video.currentTime).find((marker) => marker.kind !== "blocked") ?? null;
84
+ if (this.marker?.kind === "closing-credits" && player?.hasAttribute("upnext") === true) this.marker = null;
89
85
  this.hidden = this.marker === null;
90
86
  if (this.marker === null) return;
91
87
  const kind = this.marker.kind;
@@ -1 +1 @@
1
- {"version":3,"file":"marker-button.js","names":[],"sources":["../../src/elements/marker-button.ts"],"sourcesContent":["/**\n * <mbx-marker-button>: \"Skip intro\" over the picture while playback is in\n * the opening credits, \"Skip credits\" in the closing ones, and \"Skip\" with\n * the marker's own label in any other range the page named. A press moves\n * the playhead to the range's end. Blocked ranges never show it: the\n * player moves past those itself. The words come from\n * `label-opening-credits`, `label-closing-credits` and `label-skip`.\n */\nimport type { Marker } from '../controls/markers.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport STYLE_CSS from './marker-button.css?inline';\nimport { BUTTON_STYLE, style } from './shared.js';\n\nconst WORDS: Readonly<Record<string, string>> = {\n 'opening-credits': 'Skip intro',\n 'closing-credits': 'Skip credits',\n};\n\nexport class MbxMarkerButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label-opening-credits', 'label-closing-credits', 'label-skip'];\n }\n\n declare private readonly button: HTMLButtonElement;\n /** The range the button skips, or null while playback is in none. */\n declare private marker: Marker | null;\n /** Watches the bar and the title: the button sits above whichever is taller. */\n declare private resizer: ResizeObserver | null;\n\n constructor() {\n super();\n this.marker = null;\n this.resizer = null;\n const root = this.attachShadow({ mode: 'open' });\n this.button = document.createElement('button');\n this.button.type = 'button';\n this.button.setAttribute('part', 'button');\n this.button.textContent = 'Skip';\n this.button.addEventListener('click', () => {\n const video = this.player?.video;\n if (video !== undefined && this.marker !== null) video.currentTime = this.marker.end;\n });\n root.append(style(BUTTON_STYLE + STYLE_CSS), this.button);\n }\n\n override connectedCallback(): void {\n // Hidden until playback is in a marker; a constructor may not set attributes.\n this.hidden = true;\n super.connectedCallback();\n }\n\n protected override attach(player: PlayerHost): void {\n this.listen(player.video, ['timeupdate', 'seeking', 'emptied'], () => {\n this.render();\n });\n this.listen(player, ['markerschange'], () => {\n this.render();\n });\n // The title shows while paused, and its text sits above the bar.\n this.listen(player.video, ['play', 'pause', 'ended'], () => {\n this.fit(player);\n });\n if (typeof ResizeObserver !== 'undefined') {\n this.resizer = new ResizeObserver(() => {\n this.fit(player);\n });\n this.resizer.observe(player);\n for (const tag of ['mbx-control-bar', 'mbx-title']) {\n const node = player.querySelector(tag);\n if (node !== null) this.resizer.observe(node);\n }\n }\n this.fit(player);\n this.render();\n }\n\n protected override detach(): void {\n this.resizer?.disconnect();\n this.resizer = null;\n }\n\n /**\n * Lifts the button above the bar's rows, or above the title's text while\n * it shows: each one's box less the padding over its content, which is\n * its fade. A hidden title has no box.\n */\n private fit(player: PlayerHost): void {\n let lift = 0;\n for (const tag of ['mbx-control-bar', 'mbx-title']) {\n const node = player.querySelector(tag);\n if (node === null) continue;\n const fade = Number.parseFloat(getComputedStyle(node).paddingTop) || 0;\n lift = Math.max(lift, node.getBoundingClientRect().height - fade);\n }\n this.style.setProperty('--mbx-marker-lift', `${lift}px`);\n }\n\n protected override render(): void {\n const player = this.player;\n this.marker =\n player?.markers\n .within(player.video.currentTime)\n .find((marker) => marker.kind !== 'blocked') ?? null;\n this.hidden = this.marker === null;\n if (this.marker === null) return;\n const kind = this.marker.kind;\n const skip = this.getAttribute('label-skip') ?? 'Skip';\n this.button.textContent =\n this.getAttribute(`label-${kind}`) ??\n WORDS[kind] ??\n (this.marker.label === undefined ? skip : `${skip} ${this.marker.label}`);\n }\n}\n"],"mappings":";;;AAWA,MAAA,YAAA;AAGA,MAAA,QAAA;CACA,mBAAA;CACA,mBAAA;AACA;AAEA,IAAA,kBAAA,cAAA,UAAA;CACA,WAAA,qBAAA;EACA,OAAA;GAAA;GAAA;GAAA;EAAA;CACA;CAQA,cAAA;EACA,MAAA;EACA,KAAA,SAAA;EACA,KAAA,UAAA;EACA,MAAA,OAAA,KAAA,aAAA,EAAA,MAAA,OAAA,CAAA;EACA,KAAA,SAAA,SAAA,cAAA,QAAA;EACA,KAAA,OAAA,OAAA;EACA,KAAA,OAAA,aAAA,QAAA,QAAA;EACA,KAAA,OAAA,cAAA;EACA,KAAA,OAAA,iBAAA,eAAA;GACA,MAAA,QAAA,KAAA,QAAA;GACA,IAAA,UAAA,KAAA,KAAA,KAAA,WAAA,MAAA,MAAA,cAAA,KAAA,OAAA;EACA,CAAA;EACA,KAAA,OAAA,MAAA,eAAA,SAAA,GAAA,KAAA,MAAA;CACA;CAEA,oBAAA;EAEA,KAAA,SAAA;EACA,MAAA,kBAAA;CACA;CAEA,OAAA,QAAA;EACA,KAAA,OAAA,OAAA,OAAA;GAAA;GAAA;GAAA;EAAA,SAAA;GACA,KAAA,OAAA;EACA,CAAA;EACA,KAAA,OAAA,QAAA,CAAA,eAAA,SAAA;GACA,KAAA,OAAA;EACA,CAAA;EAEA,KAAA,OAAA,OAAA,OAAA;GAAA;GAAA;GAAA;EAAA,SAAA;GACA,KAAA,IAAA,MAAA;EACA,CAAA;EACA,IAAA,OAAA,mBAAA,aAAA;GACA,KAAA,UAAA,IAAA,qBAAA;IACA,KAAA,IAAA,MAAA;GACA,CAAA;GACA,KAAA,QAAA,QAAA,MAAA;GACA,KAAA,MAAA,OAAA,CAAA,mBAAA,WAAA,GAAA;IACA,MAAA,OAAA,OAAA,cAAA,GAAA;IACA,IAAA,SAAA,MAAA,KAAA,QAAA,QAAA,IAAA;GACA;EACA;EACA,KAAA,IAAA,MAAA;EACA,KAAA,OAAA;CACA;CAEA,SAAA;EACA,KAAA,SAAA,WAAA;EACA,KAAA,UAAA;CACA;;;;;;CAOA,IAAA,QAAA;EACA,IAAA,OAAA;EACA,KAAA,MAAA,OAAA,CAAA,mBAAA,WAAA,GAAA;GACA,MAAA,OAAA,OAAA,cAAA,GAAA;GACA,IAAA,SAAA,MAAA;GACA,MAAA,OAAA,OAAA,WAAA,iBAAA,IAAA,CAAA,CAAA,UAAA,KAAA;GACA,OAAA,KAAA,IAAA,MAAA,KAAA,sBAAA,CAAA,CAAA,SAAA,IAAA;EACA;EACA,KAAA,MAAA,YAAA,qBAAA,GAAA,KAAA,GAAA;CACA;CAEA,SAAA;EACA,MAAA,SAAA,KAAA;EACA,KAAA,SACA,QAAA,QACA,OAAA,OAAA,MAAA,WAAA,CAAA,CACA,MAAA,WAAA,OAAA,SAAA,SAAA,KAAA;EACA,KAAA,SAAA,KAAA,WAAA;EACA,IAAA,KAAA,WAAA,MAAA;EACA,MAAA,OAAA,KAAA,OAAA;EACA,MAAA,OAAA,KAAA,aAAA,YAAA,KAAA;EACA,KAAA,OAAA,cACA,KAAA,aAAA,SAAA,MAAA,KACA,MAAA,UACA,KAAA,OAAA,UAAA,KAAA,IAAA,OAAA,GAAA,KAAA,GAAA,KAAA,OAAA;CACA;AACA"}
1
+ {"version":3,"file":"marker-button.js","names":[],"sources":["../../src/elements/marker-button.ts"],"sourcesContent":["/**\n * <mbx-marker-button>: \"Skip intro\" over the picture while playback is in\n * the opening credits, \"Skip credits\" in the closing ones, and \"Skip\" with\n * the marker's own label in any other range the page named. A press moves\n * the playhead to the range's end. Blocked ranges never show it: the\n * player moves past those itself. The words come from\n * `label-opening-credits`, `label-closing-credits` and `label-skip`.\n *\n * While the player carries `upnext`, set by a card that offers the next\n * item, the button leaves the closing credits to it.\n */\nimport type { Marker } from '../controls/markers.js';\nimport type { PlayerHost } from '../host.js';\nimport { Component } from './component.js';\nimport STYLE_CSS from './marker-button.css?inline';\nimport { BUTTON_STYLE, style } from './shared.js';\n\nconst WORDS: Readonly<Record<string, string>> = {\n 'opening-credits': 'Skip intro',\n 'closing-credits': 'Skip credits',\n};\n\nexport class MbxMarkerButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['label-opening-credits', 'label-closing-credits', 'label-skip'];\n }\n\n declare private readonly button: HTMLButtonElement;\n /** The range the button skips, or null while playback is in none. */\n declare private marker: Marker | null;\n /** Watches the bar and the title: the button sits above whichever is taller. */\n declare private resizer: ResizeObserver | null;\n\n constructor() {\n super();\n this.marker = null;\n this.resizer = null;\n const root = this.attachShadow({ mode: 'open' });\n this.button = document.createElement('button');\n this.button.type = 'button';\n this.button.setAttribute('part', 'button');\n this.button.textContent = 'Skip';\n this.button.addEventListener('click', () => {\n const video = this.player?.video;\n if (video !== undefined && this.marker !== null) video.currentTime = this.marker.end;\n });\n root.append(style(BUTTON_STYLE + STYLE_CSS), this.button);\n }\n\n override connectedCallback(): void {\n // Hidden until playback is in a marker; a constructor may not set attributes.\n this.hidden = true;\n super.connectedCallback();\n }\n\n protected override attach(player: PlayerHost): void {\n this.listen(player.video, ['timeupdate', 'seeking', 'emptied'], () => {\n this.render();\n });\n this.listen(player, ['markerschange'], () => {\n this.render();\n });\n // An up next card, from a playlist, takes over the closing credits.\n this.observe(player, ['upnext'], () => {\n this.render();\n });\n // With the bar hidden, the button slides down to where the bar was.\n const idle = (): void => {\n this.toggleAttribute('idle', player.hasAttribute('idle'));\n };\n this.observe(player, ['idle'], idle);\n idle();\n if (typeof ResizeObserver !== 'undefined') {\n this.resizer = new ResizeObserver(() => {\n this.fit(player);\n });\n this.resizer.observe(player);\n const bar = player.querySelector('mbx-control-bar');\n if (bar !== null) this.resizer.observe(bar);\n }\n this.fit(player);\n this.render();\n }\n\n protected override detach(): void {\n this.resizer?.disconnect();\n this.resizer = null;\n }\n\n /**\n * Lifts the button above the bar's rows: the bar's box less the padding\n * over them, its fade. The title sits on the other side, so the button\n * stays where it is while the title shows.\n */\n private fit(player: PlayerHost): void {\n const bar = player.querySelector('mbx-control-bar');\n const fade = bar === null ? 0 : Number.parseFloat(getComputedStyle(bar).paddingTop) || 0;\n const lift = bar === null ? 0 : bar.getBoundingClientRect().height - fade;\n this.style.setProperty('--mbx-marker-lift', `${Math.max(0, lift)}px`);\n }\n\n protected override render(): void {\n const player = this.player;\n this.marker =\n player?.markers\n .within(player.video.currentTime)\n .find((marker) => marker.kind !== 'blocked') ?? null;\n // A playlist's up next card offers the next item over the closing\n // credits, so this button steps aside while the player carries `upnext`.\n if (this.marker?.kind === 'closing-credits' && player?.hasAttribute('upnext') === true) {\n this.marker = null;\n }\n this.hidden = this.marker === null;\n if (this.marker === null) return;\n const kind = this.marker.kind;\n const skip = this.getAttribute('label-skip') ?? 'Skip';\n this.button.textContent =\n this.getAttribute(`label-${kind}`) ??\n WORDS[kind] ??\n (this.marker.label === undefined ? skip : `${skip} ${this.marker.label}`);\n }\n}\n"],"mappings":";;;AAcA,MAAA,YAAA;AAGA,MAAA,QAAA;CACA,mBAAA;CACA,mBAAA;AACA;AAEA,IAAA,kBAAA,cAAA,UAAA;CACA,WAAA,qBAAA;EACA,OAAA;GAAA;GAAA;GAAA;EAAA;CACA;CAQA,cAAA;EACA,MAAA;EACA,KAAA,SAAA;EACA,KAAA,UAAA;EACA,MAAA,OAAA,KAAA,aAAA,EAAA,MAAA,OAAA,CAAA;EACA,KAAA,SAAA,SAAA,cAAA,QAAA;EACA,KAAA,OAAA,OAAA;EACA,KAAA,OAAA,aAAA,QAAA,QAAA;EACA,KAAA,OAAA,cAAA;EACA,KAAA,OAAA,iBAAA,eAAA;GACA,MAAA,QAAA,KAAA,QAAA;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OAAA,MAAA,WAAA,CAAA,CACA,MAAA,WAAA,OAAA,SAAA,SAAA,KAAA;EAGA,IAAA,KAAA,QAAA,SAAA,qBAAA,QAAA,aAAA,QAAA,MAAA,MACA,KAAA,SAAA;EAEA,KAAA,SAAA,KAAA,WAAA;EACA,IAAA,KAAA,WAAA,MAAA;EACA,MAAA,OAAA,KAAA,OAAA;EACA,MAAA,OAAA,KAAA,aAAA,YAAA,KAAA;EACA,KAAA,OAAA,cACA,KAAA,aAAA,SAAA,MAAA,KACA,MAAA,UACA,KAAA,OAAA,UAAA,KAAA,IAAA,OAAA,GAAA,KAAA,GAAA,KAAA,OAAA;CACA;AACA"}
@@ -1 +1 @@
1
- {"version":3,"file":"menu-element.d.ts","sourceRoot":"","sources":["../../src/elements/menu-element.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAGhD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,8BAAsB,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,SAAS,CAAE,SAAQ,SAAS;IAC/E,mBAA2B,IAAI,EAAE,IAAI,CAAC;IACtC,mBAA2B,KAAK,EAAE,MAAM,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC;gBAEjD,MAAM,EAAE,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,aAAa;IAarE,sCAAsC;IACtC,SAAS,CAAC,QAAQ,CAAC,IAAI,IAAI,MAAM;cAEd,MAAM,IAAI,IAAI;cAId,MAAM,IAAI,IAAI;CAGlC;AAED,2DAA2D;AAC3D,wBAAgB,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,MAAM,aAAa,CAAC,CAElF"}
1
+ {"version":3,"file":"menu-element.d.ts","sourceRoot":"","sources":["../../src/elements/menu-element.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAGhD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,8BAAsB,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,SAAS,CAAE,SAAQ,SAAS;IAC/E,mBAA2B,IAAI,EAAE,IAAI,CAAC;IACtC,mBAA2B,KAAK,EAAE,MAAM,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC;gBAEjD,MAAM,EAAE,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,aAAa;IAcrE,sCAAsC;IACtC,SAAS,CAAC,QAAQ,CAAC,IAAI,IAAI,MAAM;cAEd,MAAM,IAAI,IAAI;cAId,MAAM,IAAI,IAAI;CAGlC;AAED,2DAA2D;AAC3D,wBAAgB,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,MAAM,aAAa,CAAC,CAElF"}
@@ -11,11 +11,12 @@ var MenuElement = class extends Component {
11
11
  this.menu = menu({
12
12
  host: this,
13
13
  picture: () => this.player?.video.getBoundingClientRect() ?? null,
14
+ frame: () => this.player,
14
15
  back: (page) => fill(this.getAttribute("label-back") ?? "Back from {page}", { page })
15
16
  });
16
17
  this.slots = iconSlots(states, glyphs);
17
18
  for (const state of states) this.menu.button.append(this.slots[state]);
18
- root.append(style(MENU_STYLE), this.menu.button, this.menu.popup);
19
+ root.append(style(MENU_STYLE), this.menu.button, this.menu.backdrop, this.menu.popup);
19
20
  }
20
21
  detach() {
21
22
  this.menu.close();
@@ -1 +1 @@
1
- {"version":3,"file":"menu-element.js","names":[],"sources":["../../src/elements/menu-element.ts"],"sourcesContent":["/**\n * What the menus share: the primitive in the shadow root, the glyph slots\n * on its button, the name from `label`, the Back item's name from\n * `label-back`, and the popup fitted under the top of the picture. A\n * subclass fills the entries in `render()`, which runs on attach, on every\n * observed attribute, and whenever it asks.\n */\nimport type { IconName } from '../controls/icons.js';\nimport { icon } from '../controls/icons.js';\nimport type { Menu } from '../controls/menu.js';\nimport { menu } from '../controls/menu.js';\nimport { fill } from '../labels.js';\nimport { Component } from './component.js';\nimport { iconSlots, MENU_STYLE, style } from './shared.js';\n\nexport abstract class MenuElement<S extends string = 'default'> extends Component {\n declare protected readonly menu: Menu;\n declare protected readonly slots: Record<S, HTMLSlotElement>;\n\n constructor(states: readonly S[], glyphs: (state: S) => SVGSVGElement) {\n super();\n const root = this.attachShadow({ mode: 'open' });\n this.menu = menu({\n host: this,\n picture: () => this.player?.video.getBoundingClientRect() ?? null,\n back: (page) => fill(this.getAttribute('label-back') ?? 'Back from {page}', { page }),\n });\n this.slots = iconSlots(states, glyphs);\n for (const state of states) this.menu.button.append(this.slots[state]);\n root.append(style(MENU_STYLE), this.menu.button, this.menu.popup);\n }\n\n /** The default name of the button. */\n protected abstract name(): string;\n\n protected override detach(): void {\n this.menu.close();\n }\n\n protected override render(): void {\n this.menu.label(this.getAttribute('label') ?? this.name());\n }\n}\n\n/** A glyph that never changes, for a menu of one state. */\nexport function single(name: IconName): [readonly ['default'], () => SVGSVGElement] {\n return [['default'], () => icon(name)];\n}\n"],"mappings":";;;;;;AAeA,IAAsB,cAAtB,cAAwE,UAAU;CAIhF,YAAY,QAAsB,QAAqC;EACrE,MAAM;EACN,MAAM,OAAO,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;EAC/C,KAAK,OAAO,KAAK;GACf,MAAM;GACN,eAAe,KAAK,QAAQ,MAAM,sBAAsB,KAAK;GAC7D,OAAO,SAAS,KAAK,KAAK,aAAa,YAAY,KAAK,oBAAoB,EAAE,KAAK,CAAC;EACtF,CAAC;EACD,KAAK,QAAQ,UAAU,QAAQ,MAAM;EACrC,KAAK,MAAM,SAAS,QAAQ,KAAK,KAAK,OAAO,OAAO,KAAK,MAAM,MAAM;EACrE,KAAK,OAAO,MAAM,UAAU,GAAG,KAAK,KAAK,QAAQ,KAAK,KAAK,KAAK;CAClE;CAKA,SAAkC;EAChC,KAAK,KAAK,MAAM;CAClB;CAEA,SAAkC;EAChC,KAAK,KAAK,MAAM,KAAK,aAAa,OAAO,KAAK,KAAK,KAAK,CAAC;CAC3D;AACF;;AAGA,SAAgB,OAAO,MAA6D;CAClF,OAAO,CAAC,CAAC,SAAS,SAAS,KAAK,IAAI,CAAC;AACvC"}
1
+ {"version":3,"file":"menu-element.js","names":[],"sources":["../../src/elements/menu-element.ts"],"sourcesContent":["/**\n * What the menus share: the primitive in the shadow root, the glyph slots\n * on its button, the name from `label`, the Back item's name from\n * `label-back`, and the popup fitted under the top of the picture. A\n * subclass fills the entries in `render()`, which runs on attach, on every\n * observed attribute, and whenever it asks.\n */\nimport type { IconName } from '../controls/icons.js';\nimport { icon } from '../controls/icons.js';\nimport type { Menu } from '../controls/menu.js';\nimport { menu } from '../controls/menu.js';\nimport { fill } from '../labels.js';\nimport { Component } from './component.js';\nimport { iconSlots, MENU_STYLE, style } from './shared.js';\n\nexport abstract class MenuElement<S extends string = 'default'> extends Component {\n declare protected readonly menu: Menu;\n declare protected readonly slots: Record<S, HTMLSlotElement>;\n\n constructor(states: readonly S[], glyphs: (state: S) => SVGSVGElement) {\n super();\n const root = this.attachShadow({ mode: 'open' });\n this.menu = menu({\n host: this,\n picture: () => this.player?.video.getBoundingClientRect() ?? null,\n frame: () => this.player,\n back: (page) => fill(this.getAttribute('label-back') ?? 'Back from {page}', { page }),\n });\n this.slots = iconSlots(states, glyphs);\n for (const state of states) this.menu.button.append(this.slots[state]);\n root.append(style(MENU_STYLE), this.menu.button, this.menu.backdrop, this.menu.popup);\n }\n\n /** The default name of the button. */\n protected abstract name(): string;\n\n protected override detach(): void {\n this.menu.close();\n }\n\n protected override render(): void {\n this.menu.label(this.getAttribute('label') ?? this.name());\n }\n}\n\n/** A glyph that never changes, for a menu of one state. */\nexport function single(name: IconName): [readonly ['default'], () => SVGSVGElement] {\n return [['default'], () => icon(name)];\n}\n"],"mappings":";;;;;;AAeA,IAAsB,cAAtB,cAAwE,UAAU;CAIhF,YAAY,QAAsB,QAAqC;EACrE,MAAM;EACN,MAAM,OAAO,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;EAC/C,KAAK,OAAO,KAAK;GACf,MAAM;GACN,eAAe,KAAK,QAAQ,MAAM,sBAAsB,KAAK;GAC7D,aAAa,KAAK;GAClB,OAAO,SAAS,KAAK,KAAK,aAAa,YAAY,KAAK,oBAAoB,EAAE,KAAK,CAAC;EACtF,CAAC;EACD,KAAK,QAAQ,UAAU,QAAQ,MAAM;EACrC,KAAK,MAAM,SAAS,QAAQ,KAAK,KAAK,OAAO,OAAO,KAAK,MAAM,MAAM;EACrE,KAAK,OAAO,MAAM,UAAU,GAAG,KAAK,KAAK,QAAQ,KAAK,KAAK,UAAU,KAAK,KAAK,KAAK;CACtF;CAKA,SAAkC;EAChC,KAAK,KAAK,MAAM;CAClB;CAEA,SAAkC;EAChC,KAAK,KAAK,MAAM,KAAK,aAAa,OAAO,KAAK,KAAK,KAAK,CAAC;CAC3D;AACF;;AAGA,SAAgB,OAAO,MAA6D;CAClF,OAAO,CAAC,CAAC,SAAS,SAAS,KAAK,IAAI,CAAC;AACvC"}
@@ -12,7 +12,7 @@ var MbxQualityMenu = class extends MenuElement {
12
12
  ];
13
13
  }
14
14
  constructor() {
15
- super(...single("settings"));
15
+ super(...single("quality"));
16
16
  this.engine = null;
17
17
  this.playing = void 0;
18
18
  show(this.slots, "default");
@@ -1 +1 @@
1
- {"version":3,"file":"quality-menu.js","names":[],"sources":["../../src/elements/quality-menu.ts"],"sourcesContent":["/**\n * <mbx-quality-menu>: the pin over `engine.quality`, where \"auto\" means\n * none. Hidden without renditions, and for a native session. The name\n * comes from `label`, the word for no pin from `label-auto`. It offers\n * `engine.quality.selectable`, labelled by `qualityNames`. Under Auto, the\n * Auto row names what plays, in its detail.\n */\nimport type { Mattebox } from 'mattebox';\nimport { qualityLabels, qualityNames } from '../controls/quality-names.js';\nimport type { PlayerHost } from '../host.js';\nimport { MenuElement, single } from './menu-element.js';\nimport { show } from './shared.js';\n\nconst AUTO = 'auto';\n\nexport class MbxQualityMenu extends MenuElement {\n static get observedAttributes(): readonly string[] {\n return ['label', 'label-auto', 'label-back'];\n }\n\n declare private engine: Mattebox | null;\n /** The name of what plays, as the Auto row last showed it. */\n declare private playing: string | undefined;\n\n constructor() {\n super(...single('settings'));\n this.engine = null;\n this.playing = undefined;\n show(this.slots, 'default');\n }\n\n protected override name(): string {\n return 'Quality';\n }\n\n protected override attach(player: PlayerHost): void {\n this.follow(player, (engine) => {\n this.engine = engine;\n this.render();\n if (engine === null) return undefined;\n const tick = (): void => {\n this.render();\n };\n // What plays changes as the playhead reaches another rendition's\n // segments, and no event says so: read it on the clock, draw on a change.\n const clock = (): void => {\n if (this.playingName() !== this.playing) this.render();\n };\n player.video.addEventListener('timeupdate', clock);\n const offs = [\n () => player.video.removeEventListener('timeupdate', clock),\n engine.on('tracks:changed', tick),\n engine.on('quality:constraints-unsatisfiable', tick),\n engine.on('quality:pin-unsatisfiable', tick),\n ];\n return () => {\n for (const off of offs) off();\n };\n });\n }\n\n protected override render(): void {\n super.render();\n const engine = this.engine;\n if (engine === null) {\n this.hidden = true;\n return;\n }\n const quality = engine.quality;\n this.playing = this.playingName();\n const items: Array<readonly [string, string, (string | undefined)?]> = [\n [AUTO, this.getAttribute('label-auto') ?? 'Auto', this.playing],\n ...qualityNames(quality.selectable),\n ];\n this.menu.fill([\n {\n name: 'rendition',\n items,\n value: quality.pinned ?? AUTO,\n onSelect: (value) => {\n if (value === AUTO) quality.auto();\n else quality.pin(value);\n this.render();\n },\n },\n ]);\n this.hidden = items.length === 1;\n }\n\n /** The name of the rendition that plays, under Auto only: a pin names itself by its tick. */\n private playingName(): string | undefined {\n const quality = this.engine?.quality;\n if (quality === undefined || quality.pinned !== null) return undefined;\n // Every label, twins too: what plays may be a twin the menu shows once.\n const id = quality.playing?.id;\n return qualityLabels(quality.selectable).find(([candidate]) => candidate === id)?.[1];\n }\n}\n"],"mappings":";;;;AAaA,MAAM,OAAO;AAEb,IAAa,iBAAb,cAAoC,YAAY;CAC9C,WAAW,qBAAwC;EACjD,OAAO;GAAC;GAAS;GAAc;EAAY;CAC7C;CAMA,cAAc;EACZ,MAAM,GAAG,OAAO,UAAU,CAAC;EAC3B,KAAK,SAAS;EACd,KAAK,UAAU,KAAA;EACf,KAAK,KAAK,OAAO,SAAS;CAC5B;CAEA,OAAkC;EAChC,OAAO;CACT;CAEA,OAA0B,QAA0B;EAClD,KAAK,OAAO,SAAS,WAAW;GAC9B,KAAK,SAAS;GACd,KAAK,OAAO;GACZ,IAAI,WAAW,MAAM,OAAO,KAAA;GAC5B,MAAM,aAAmB;IACvB,KAAK,OAAO;GACd;GAGA,MAAM,cAAoB;IACxB,IAAI,KAAK,YAAY,MAAM,KAAK,SAAS,KAAK,OAAO;GACvD;GACA,OAAO,MAAM,iBAAiB,cAAc,KAAK;GACjD,MAAM,OAAO;UACL,OAAO,MAAM,oBAAoB,cAAc,KAAK;IAC1D,OAAO,GAAG,kBAAkB,IAAI;IAChC,OAAO,GAAG,qCAAqC,IAAI;IACnD,OAAO,GAAG,6BAA6B,IAAI;GAC7C;GACA,aAAa;IACX,KAAK,MAAM,OAAO,MAAM,IAAI;GAC9B;EACF,CAAC;CACH;CAEA,SAAkC;EAChC,MAAM,OAAO;EACb,MAAM,SAAS,KAAK;EACpB,IAAI,WAAW,MAAM;GACnB,KAAK,SAAS;GACd;EACF;EACA,MAAM,UAAU,OAAO;EACvB,KAAK,UAAU,KAAK,YAAY;EAChC,MAAM,QAAiE,CACrE;GAAC;GAAM,KAAK,aAAa,YAAY,KAAK;GAAQ,KAAK;EAAO,GAC9D,GAAG,aAAa,QAAQ,UAAU,CACpC;EACA,KAAK,KAAK,KAAK,CACb;GACE,MAAM;GACN;GACA,OAAO,QAAQ,UAAU;GACzB,WAAW,UAAU;IACnB,IAAI,UAAU,MAAM,QAAQ,KAAK;SAC5B,QAAQ,IAAI,KAAK;IACtB,KAAK,OAAO;GACd;EACF,CACF,CAAC;EACD,KAAK,SAAS,MAAM,WAAW;CACjC;;CAGA,cAA0C;EACxC,MAAM,UAAU,KAAK,QAAQ;EAC7B,IAAI,YAAY,KAAA,KAAa,QAAQ,WAAW,MAAM,OAAO,KAAA;EAE7D,MAAM,KAAK,QAAQ,SAAS;EAC5B,OAAO,cAAc,QAAQ,UAAU,CAAC,CAAC,MAAM,CAAC,eAAe,cAAc,EAAE,CAAC,GAAG;CACrF;AACF"}
1
+ {"version":3,"file":"quality-menu.js","names":[],"sources":["../../src/elements/quality-menu.ts"],"sourcesContent":["/**\n * <mbx-quality-menu>: the pin over `engine.quality`, where \"auto\" means\n * none. Hidden without renditions, and for a native session. The name\n * comes from `label`, the word for no pin from `label-auto`. It offers\n * `engine.quality.selectable`, labelled by `qualityNames`. Under Auto, the\n * Auto row names what plays, in its detail.\n */\nimport type { Mattebox } from 'mattebox';\nimport { qualityLabels, qualityNames } from '../controls/quality-names.js';\nimport type { PlayerHost } from '../host.js';\nimport { MenuElement, single } from './menu-element.js';\nimport { show } from './shared.js';\n\nconst AUTO = 'auto';\n\nexport class MbxQualityMenu extends MenuElement {\n static get observedAttributes(): readonly string[] {\n return ['label', 'label-auto', 'label-back'];\n }\n\n declare private engine: Mattebox | null;\n /** The name of what plays, as the Auto row last showed it. */\n declare private playing: string | undefined;\n\n constructor() {\n super(...single('quality'));\n this.engine = null;\n this.playing = undefined;\n show(this.slots, 'default');\n }\n\n protected override name(): string {\n return 'Quality';\n }\n\n protected override attach(player: PlayerHost): void {\n this.follow(player, (engine) => {\n this.engine = engine;\n this.render();\n if (engine === null) return undefined;\n const tick = (): void => {\n this.render();\n };\n // What plays changes as the playhead reaches another rendition's\n // segments, and no event says so: read it on the clock, draw on a change.\n const clock = (): void => {\n if (this.playingName() !== this.playing) this.render();\n };\n player.video.addEventListener('timeupdate', clock);\n const offs = [\n () => player.video.removeEventListener('timeupdate', clock),\n engine.on('tracks:changed', tick),\n engine.on('quality:constraints-unsatisfiable', tick),\n engine.on('quality:pin-unsatisfiable', tick),\n ];\n return () => {\n for (const off of offs) off();\n };\n });\n }\n\n protected override render(): void {\n super.render();\n const engine = this.engine;\n if (engine === null) {\n this.hidden = true;\n return;\n }\n const quality = engine.quality;\n this.playing = this.playingName();\n const items: Array<readonly [string, string, (string | undefined)?]> = [\n [AUTO, this.getAttribute('label-auto') ?? 'Auto', this.playing],\n ...qualityNames(quality.selectable),\n ];\n this.menu.fill([\n {\n name: 'rendition',\n items,\n value: quality.pinned ?? AUTO,\n onSelect: (value) => {\n if (value === AUTO) quality.auto();\n else quality.pin(value);\n this.render();\n },\n },\n ]);\n this.hidden = items.length === 1;\n }\n\n /** The name of the rendition that plays, under Auto only: a pin names itself by its tick. */\n private playingName(): string | undefined {\n const quality = this.engine?.quality;\n if (quality === undefined || quality.pinned !== null) return undefined;\n // Every label, twins too: what plays may be a twin the menu shows once.\n const id = quality.playing?.id;\n return qualityLabels(quality.selectable).find(([candidate]) => candidate === id)?.[1];\n }\n}\n"],"mappings":";;;;AAaA,MAAM,OAAO;AAEb,IAAa,iBAAb,cAAoC,YAAY;CAC9C,WAAW,qBAAwC;EACjD,OAAO;GAAC;GAAS;GAAc;EAAY;CAC7C;CAMA,cAAc;EACZ,MAAM,GAAG,OAAO,SAAS,CAAC;EAC1B,KAAK,SAAS;EACd,KAAK,UAAU,KAAA;EACf,KAAK,KAAK,OAAO,SAAS;CAC5B;CAEA,OAAkC;EAChC,OAAO;CACT;CAEA,OAA0B,QAA0B;EAClD,KAAK,OAAO,SAAS,WAAW;GAC9B,KAAK,SAAS;GACd,KAAK,OAAO;GACZ,IAAI,WAAW,MAAM,OAAO,KAAA;GAC5B,MAAM,aAAmB;IACvB,KAAK,OAAO;GACd;GAGA,MAAM,cAAoB;IACxB,IAAI,KAAK,YAAY,MAAM,KAAK,SAAS,KAAK,OAAO;GACvD;GACA,OAAO,MAAM,iBAAiB,cAAc,KAAK;GACjD,MAAM,OAAO;UACL,OAAO,MAAM,oBAAoB,cAAc,KAAK;IAC1D,OAAO,GAAG,kBAAkB,IAAI;IAChC,OAAO,GAAG,qCAAqC,IAAI;IACnD,OAAO,GAAG,6BAA6B,IAAI;GAC7C;GACA,aAAa;IACX,KAAK,MAAM,OAAO,MAAM,IAAI;GAC9B;EACF,CAAC;CACH;CAEA,SAAkC;EAChC,MAAM,OAAO;EACb,MAAM,SAAS,KAAK;EACpB,IAAI,WAAW,MAAM;GACnB,KAAK,SAAS;GACd;EACF;EACA,MAAM,UAAU,OAAO;EACvB,KAAK,UAAU,KAAK,YAAY;EAChC,MAAM,QAAiE,CACrE;GAAC;GAAM,KAAK,aAAa,YAAY,KAAK;GAAQ,KAAK;EAAO,GAC9D,GAAG,aAAa,QAAQ,UAAU,CACpC;EACA,KAAK,KAAK,KAAK,CACb;GACE,MAAM;GACN;GACA,OAAO,QAAQ,UAAU;GACzB,WAAW,UAAU;IACnB,IAAI,UAAU,MAAM,QAAQ,KAAK;SAC5B,QAAQ,IAAI,KAAK;IACtB,KAAK,OAAO;GACd;EACF,CACF,CAAC;EACD,KAAK,SAAS,MAAM,WAAW;CACjC;;CAGA,cAA0C;EACxC,MAAM,UAAU,KAAK,QAAQ;EAC7B,IAAI,YAAY,KAAA,KAAa,QAAQ,WAAW,MAAM,OAAO,KAAA;EAE7D,MAAM,KAAK,QAAQ,SAAS;EAC5B,OAAO,cAAc,QAAQ,UAAU,CAAC,CAAC,MAAM,CAAC,eAAe,cAAc,EAAE,CAAC,GAAG;CACrF;AACF"}
@@ -19,7 +19,7 @@ import { optional } from "../controls/session.js";
19
19
  * `rate` part shows the rate, "8×". The name comes from `label`,
20
20
  * "Fast forward" or "Rewind".
21
21
  */
22
- const STYLE_CSS = "[part~=button]{position:relative}[part~=rate]{font-variant-numeric:tabular-nums;font-size:10px;font-weight:700;line-height:1;position:absolute;bottom:2px;right:0}[part~=rate][hidden]{display:none}";
22
+ const STYLE_CSS = "[part~=button]{position:relative}[part~=rate]{font-variant-numeric:tabular-nums;font-size:.625em;font-weight:700;line-height:1;position:absolute;bottom:.2em;right:0}[part~=rate][hidden]{display:none}";
23
23
  const RATES = [
24
24
  4,
25
25
  8,
@@ -1 +1 @@
1
- {"version":3,"file":"seek-bar.d.ts","sourceRoot":"","sources":["../../src/elements/seek-bar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAYH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAoE3C,qBAAa,UAAW,SAAQ,SAAS;IACvC,MAAM,KAAK,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAYjD;IAED,iBAAyB,GAAG,CAAS;IACrC,iBAAyB,QAAQ,CAAc;IAC/C,mFAAmF;IACnF,iBAAyB,OAAO,CAAc;IAC9C,iBAAyB,KAAK,CAAc;IAC5C,iBAAyB,IAAI,CAAc;IAC3C,iBAAyB,OAAO,CAAc;IAC9C,iBAAyB,KAAK,CAAc;IAC5C,iBAAyB,IAAI,CAAc;IAC3C,iBAAyB,IAAI,CAAc;IAC3C,iBAAyB,OAAO,CAAc;IAC9C,iBAAyB,WAAW,CAAoB;IACxD,QAAgB,IAAI,CAAO;IAC3B,wEAAwE;IACxE,QAAgB,OAAO,CAAgB;IACvC,qFAAqF;IACrF,QAAgB,MAAM,CAAU;IAChC,kGAAkG;IAClG,QAAgB,KAAK,CAAS;IAC9B,kFAAkF;IAClF,QAAgB,MAAM,CAAgB;IACtC,QAAgB,WAAW,CAAS;IACpC,iEAAiE;IACjE,QAAgB,KAAK,CAAS;IAC9B,QAAgB,QAAQ,CAAS;I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Chapters } from "../controls/chapters.js";
9
9
  import { slider } from "../controls/slider.js";
10
10
  //#region src/elements/seek-bar.ts
11
- const STYLE_CSS = ":host,[part~=slider]{flex:1}[part~=thumb]{width:16px;height:16px;margin:-8px 0 0 -8px;box-shadow:0 1px 3px #0006}[part~=buffered]{position:absolute;top:0;bottom:0;left:0;right:0}[part~=blocked]{pointer-events:none;position:absolute;top:0;bottom:0;left:0;right:0}[part~=blocked-range]{background:var(--mbx-blocked,#000000bf);position:absolute;top:0;bottom:0}[part~=buffered-range]{background:#ffffff4d;position:absolute;top:0;bottom:0}[part~=hover]{background:var(--mbx-text);width:2px;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=edge]{background:var(--mbx-live);width:2px;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=preview]{background:var(--mbx-surface);border-radius:var(--mbx-radius);font-variant-numeric:tabular-nums;white-space:nowrap;pointer-events:none;flex-direction:column;align-items:center;margin-bottom:4px;padding:2px;font-size:13px;display:flex;position:absolute;bottom:100%;transform:translate(-50%)}[part~=preview]>:not([hidden])~:not([hidden]){margin-top:2px}[part~=preview-image]{border-radius:2px;position:relative;overflow:hidden}[part~=preview-frame]{border-radius:2px;display:block}[part~=preview-tile]{transform-origin:0 0;background-repeat:no-repeat;position:absolute;top:0;left:0}[part~=preview-time]{padding:0 4px}[part~=preview-title]{text-overflow:ellipsis;max-width:240px;padding:0 4px;overflow:hidden}[hidden]{display:none}";
11
+ const STYLE_CSS = ":host,[part~=slider]{flex:1}[part~=thumb]{width:1em;height:1em;margin:-.5em 0 0 -.5em;box-shadow:0 1px 3px #0006}[part~=buffered]{position:absolute;top:0;bottom:0;left:0;right:0}[part~=blocked]{pointer-events:none;position:absolute;top:0;bottom:0;left:0;right:0}[part~=blocked-range]{background:var(--mbx-blocked,#000000bf);position:absolute;top:0;bottom:0}[part~=buffered-range]{background:#ffffff4d;position:absolute;top:0;bottom:0}[part~=hover]{background:var(--mbx-text);width:.125em;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=edge]{background:var(--mbx-live);width:.125em;margin-left:-1px;position:absolute;top:0;bottom:0}[part~=preview]{background:var(--mbx-surface);border-radius:var(--mbx-radius);font-variant-numeric:tabular-nums;white-space:nowrap;pointer-events:none;flex-direction:column;align-items:center;margin-bottom:.3077em;padding:.1538em;font-size:.8125em;display:flex;position:absolute;bottom:100%;transform:translate(-50%)}[part~=preview]>:not([hidden])~:not([hidden]){margin-top:.125em}[part~=preview-image]{border-radius:2px;position:relative;overflow:hidden}[part~=preview-frame]{border-radius:2px;display:block}[part~=preview-tile]{transform-origin:0 0;background-repeat:no-repeat;position:absolute;top:0;left:0}[part~=preview-time]{padding:0 .3077em}[part~=preview-title]{text-overflow:ellipsis;max-width:18.4615em;padding:0 .3077em;overflow:hidden}[hidden]{display:none}";
12
12
  const STEP = 5;
13
13
  /** Under `key-mode="preview"`, a target seeks this long after the last key. */
14
14
  const KEY_COMMIT_MS = 1e3;
@@ -26,8 +26,8 @@ const CANCEL_KEYS = [
26
26
  ];
27
27
  const PAGE = 30;
28
28
  const LIVE_WINDOW = 3;
29
- /** What the tile scales down to when the page sets no `--mbx-preview-width`. */
30
- const PREVIEW_WIDTH = 160;
29
+ /** What the tile scales down to, in em, when the page sets no `--mbx-preview-width`. */
30
+ const PREVIEW_WIDTH = 10;
31
31
  /** The buffer goal assumed for a session that reports none. */
32
32
  const BUFFER_GOAL = 30;
33
33
  /** The gap cut at a chapter boundary, in pixels. */
@@ -311,7 +311,8 @@ var MbxSeekBar = class extends Component {
311
311
  /** The width the page asked for through the token, or the default. */
312
312
  previewWidth() {
313
313
  const set = Number.parseFloat(getComputedStyle(this.preview).getPropertyValue("--mbx-preview-width"));
314
- return Number.isFinite(set) && set > 0 ? set : PREVIEW_WIDTH;
314
+ if (Number.isFinite(set) && set > 0) return set;
315
+ return PREVIEW_WIDTH * (Number.parseFloat(getComputedStyle(this).fontSize) || 16);
315
316
  }
316
317
  /** The preview's picture sources from `preview`, in order of preference: frames then tiles by default. */
317
318
  sources() {
@@ -1 +1 @@
1
- {"version":3,"file":"seek-bar.js","names":[],"sources":["../../src/elements/seek-bar.ts"],"sourcesContent":["/**\n * <mbx-seek-bar>: the bar over the slider primitive, with four layers on\n * its track, every one a part: the buffered ranges from `video.buffered`,\n * the played span, the hover position, and for live the edge from\n * `engine.live`. The span it maps is the availability window for live and\n * the duration for VOD; `controls/session.ts` says which.\n *\n * A live stream is seekable only when the window is worth it: at least\n * `live-window` forward buffer goals long, the goal read from the engine.\n * Below that the bar hides. VOD is always seekable. The element sets\n * `live` and `seekable` on the player, which the time and the live button\n * read, and `scrubbing` while a pointer holds the thumb: `playing` or\n * `paused`, the state before the drag, which the play buttons show\n * instead of the drag's own pause.\n *\n * Reads happen on the events the video already fires; the live window has\n * no event of its own and moves with the clock, so `timeupdate` covers it.\n * While a pointer holds the thumb, the played layer follows the pointer.\n * The element carries `dragging` meanwhile. With an I-frame track\n * (`engine.trick.available`), the drag scrubs: the video pauses and shows\n * the I-frame at every position, and the release seeks there. See the\n * engine guide's trick play chapter. `scrub=\"false\"` turns this off.\n * Otherwise the video pauses, `currentTime` is written at most once per\n * frame, so the bar never fights a slow seek, and the release resumes\n * playback if it was playing. Thumbnail tiles never drive a drag: they are\n * previews, not frames of the video.\n *\n * The preview above the pointer carries the time and a picture of that\n * time from the sources `preview` names, in order of preference: `frames`\n * and `tiles`, \"frames tiles\" by default, `none` for no picture. A frame\n * is the decoded I-frame from `engine.trick.frameAt`, when the track\n * decodes in this browser; the last one stays until the next arrives, so\n * the picture never flickers while the engine decodes. A tile comes from\n * `engine.thumbnails`: a rectangle of a sprite, drawn by background\n * position at the sprite's own size. Both scale to `--mbx-preview-width`,\n * so a page sets the size with one token.\n *\n * Chapters divide the track: one gap per chapter boundary, cut through\n * every layer with a mask, so the played and the buffered spans read per\n * chapter, and the preview names the chapter under the pointer. They come\n * from the session, see `controls/chapters.ts`. `chapters` lists what the\n * bar does with them: `divided` and `titles`, both by default, one of\n * them alone, or `none`.\n *\n * `step` is what an arrow key moves the playhead by and `page` what Page\n * Up and Page Down do, in seconds. `key-mode=\"preview\"`, for a TV, makes\n * the keys aim instead of seek: the thumb and the preview show the target,\n * a held key's step grows, and the seek comes on Enter, on leaving the bar,\n * or a second after the last key. Escape or Back drops the target. The\n * control bar's seeking keys, the arrows and fast forward and rewind\n * anywhere in the player, aim the same way: the bar asks through\n * `seekkey`, and the seek bar takes it. The default, `instant`, seeks on\n * every key. The name comes from `label`; what a\n * screen reader hears at a position from `label-of`, \"{current} of\n * {duration}\", and on live from `label-behind`, \"{time} behind live\". It\n * sits in the bar's seek row unless the page says otherwise.\n */\n\nimport type { Thumbnail } from 'mattebox/stages/thumbnails';\nimport type { Chapter } from '../controls/chapters.js';\nimport { chapterAt, chapters, followChapters } from '../controls/chapters.js';\nimport type { Span } from '../controls/ranges.js';\nimport { at, clip, EMPTY, fraction, spans } from '../controls/ranges.js';\nimport { bufferGoal, live, optional, span, wall } from '../controls/session.js';\nimport type { Slider } from '../controls/slider.js';\nimport { slider } from '../controls/slider.js';\nimport { format } from '../controls/time.js';\nimport { el } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { fill } from '../labels.js';\nimport { Component } from './component.js';\nimport STYLE_CSS from './seek-bar.css?inline';\nimport { number, SLIDER_STYLE, seekRow, style } from './shared.js';\n\n/** What a drag does, chosen when the pointer takes the thumb. */\ntype Drag = 'none' | 'seek' | 'scrub';\n\n/** Where the preview's picture comes from: decoded I-frames, or thumbnail tiles. */\ntype Preview = 'frames' | 'tiles';\n\nconst STEP = 5;\n\n/** Under `key-mode=\"preview\"`, a target seeks this long after the last key. */\nconst KEY_COMMIT_MS = 1000;\n/** Key moves closer together than this are one hold, whose step grows. */\nconst REPEAT_GAP_MS = 400;\n/** A held key's step grows by one step every this many moves... */\nconst MOVES_PER_STEP = 8;\n/** ...up to this many steps a move. */\nconst MAX_STEPS = 12;\n\n/** The keys that cancel a target: Escape, and Back as a remote sends it. */\nconst CANCEL_KEYS = ['Escape', 'GoBack', 'BrowserBack'];\nconst PAGE = 30;\nconst LIVE_WINDOW = 3;\n\n/** What the tile scales down to when the page sets no `--mbx-preview-width`. */\nconst PREVIEW_WIDTH = 160;\n\n/** The buffer goal assumed for a session that reports none. */\nconst BUFFER_GOAL = 30;\n\n/** The gap cut at a chapter boundary, in pixels. */\nconst GAP = 2;\n\nconst EVENTS = [\n 'timeupdate',\n 'progress',\n 'durationchange',\n 'loadedmetadata',\n 'seeking',\n 'seeked',\n 'emptied',\n];\n\nconst STYLE = SLIDER_STYLE + STYLE_CSS;\n\nfunction percent(part: number): string {\n return `${part * 100}%`;\n}\n\n/**\n * A mask that cuts a gap at each chapter boundary, as stops along the\n * track: opaque up to a boundary, clear for the gap, opaque after.\n */\nfunction gaps(boundaries: readonly number[], span: Span): string {\n if (boundaries.length === 0) return '';\n const stops: string[] = ['#000 0'];\n for (const time of boundaries) {\n const at = percent(fraction(time, span));\n const before = `calc(${at} - ${GAP / 2}px)`;\n const after = `calc(${at} + ${GAP / 2}px)`;\n stops.push(`#000 ${before}`, `transparent ${before}`, `transparent ${after}`, `#000 ${after}`);\n }\n stops.push('#000 100%');\n return `linear-gradient(to right, ${stops.join(', ')})`;\n}\n\nexport class MbxSeekBar extends Component {\n static get observedAttributes(): readonly string[] {\n return [\n 'label',\n 'label-of',\n 'label-behind',\n 'label-blocked',\n 'live-window',\n 'chapters',\n 'scrub',\n 'preview',\n 'key-mode',\n ];\n }\n\n declare private readonly bar: Slider;\n declare private readonly buffered: HTMLElement;\n /** The ranges the page marked blocked, drawn as a broken line: they never play. */\n declare private readonly blocked: HTMLElement;\n declare private readonly hover: HTMLElement;\n declare private readonly edge: HTMLElement;\n declare private readonly preview: HTMLElement;\n declare private readonly image: HTMLElement;\n declare private readonly tile: HTMLElement;\n declare private readonly time: HTMLElement;\n declare private readonly caption: HTMLElement;\n declare private readonly frameCanvas: HTMLCanvasElement;\n declare private drag: Drag;\n /** The last position of the drag, which a cancelled drag settles at. */\n declare private dragged: number | null;\n /** Whether the video played when a seeking drag began, so the release resumes it. */\n declare private resume: boolean;\n /** Frames asked for, and the newest one on screen, so a late frame never replaces a newer one. */\n declare private asked: number;\n /** Under `key-mode=\"preview\"`: where the keys aim, not yet sought to, or null. */\n declare private target: number | null;\n declare private commitTimer: number;\n /** The moves of the current hold, and when the last one came. */\n declare private moves: number;\n declare private lastMove: number;\n declare private shown: number;\n declare private range: Span;\n /** The chapters as last drawn, so the mask is written only when they change. */\n declare private divided: string;\n declare private list: Chapter[];\n declare private pending: number | null;\n declare private frame: number;\n\n constructor() {\n super();\n this.range = EMPTY;\n this.pending = null;\n this.frame = 0;\n this.divided = '';\n this.list = [];\n this.drag = 'none';\n this.dragged = null;\n this.resume = false;\n this.asked = 0;\n this.shown = 0;\n this.target = null;\n this.commitTimer = 0;\n this.moves = 0;\n this.lastMove = 0;\n const root = this.attachShadow({ mode: 'open' });\n this.bar = slider({\n step: () => this.keyStep(),\n page: () => number(this, 'page', PAGE),\n onInput: (value, key) => {\n if (key && this.previewing()) this.aim(value);\n else this.input(value);\n },\n onDrag: (on) => {\n this.toggleAttribute('dragging', on);\n if (on) this.dragStart();\n else this.dragEnd();\n },\n });\n this.buffered = el('div', 'buffered');\n this.blocked = el('div', 'blocked');\n this.hover = el('div', 'hover');\n this.edge = el('div', 'edge');\n this.hover.hidden = true;\n this.edge.hidden = true;\n // Under the fill, so what is played reads over what is buffered.\n this.bar.track.prepend(this.buffered);\n // Over the fill, inside the track: the chapter gaps cut through it too.\n this.bar.track.append(this.blocked, this.hover, this.edge);\n this.preview = el('div', 'preview');\n this.image = el('div', 'preview-image');\n this.tile = el('div', 'preview-tile');\n this.time = el('span', 'preview-time');\n this.caption = el('span', 'preview-title');\n this.caption.hidden = true;\n this.image.append(this.tile);\n this.image.hidden = true;\n this.frameCanvas = el('canvas', 'preview-frame');\n this.frameCanvas.hidden = true;\n this.preview.append(this.frameCanvas, this.image, this.caption, this.time);\n this.preview.hidden = true;\n this.bar.root.append(this.preview);\n this.bar.root.addEventListener('pointermove', (event) => {\n this.point(event);\n });\n this.bar.root.addEventListener('pointerleave', () => {\n if (this.target === null) this.leave();\n });\n // Focus moving on: the target stands, as if the pause ran out.\n this.bar.root.addEventListener('blur', () => {\n if (this.target !== null) this.commit();\n });\n root.append(style(STYLE), this.bar.root);\n }\n\n override connectedCallback(): void {\n seekRow(this);\n super.connectedCallback();\n }\n\n private isLive(): boolean {\n return live(this.player?.engine ?? null) !== undefined;\n }\n\n /** Whether the chapters do `use`: `divided` the track, or name the preview with their `titles`. */\n private chaptered(use: 'divided' | 'titles'): boolean {\n if (this.list.length === 0) return false;\n const value = this.getAttribute('chapters');\n if (value === null) return true;\n const words = value.split(/\\s+/);\n // A value naming neither, as `on` did, keeps both.\n return (\n words.includes(use) ||\n !words.some((word) => word === 'divided' || word === 'titles' || word === 'none')\n );\n }\n\n /** The gaps at the chapter boundaries, on every layer of the track at once. */\n private paintChapters(): void {\n const boundaries =\n this.chaptered('divided') && this.list.length > 1\n ? this.list.slice(1).map((chapter) => chapter.start)\n : [];\n const mask = gaps(boundaries, this.range);\n const key = `${mask}|${this.range.start}|${this.range.end}`;\n if (key === this.divided) return;\n this.divided = key;\n const track = this.bar.track.style;\n // Both spellings: WebKit before 15.4 knows only the prefixed one.\n track.setProperty('mask-image', mask === '' ? '' : mask);\n track.setProperty('-webkit-mask-image', mask === '' ? '' : mask);\n }\n\n /** What a screen reader hears at a time. */\n private say(time: number): string {\n const engine = this.player?.engine ?? null;\n if (!this.isLive()) {\n const template = this.getAttribute('label-of') ?? '{current} of {duration}';\n return Number.isFinite(this.range.end) && this.range.end > 0\n ? fill(template, { current: format(time), duration: format(this.range.end) })\n : format(time);\n }\n const behind = fill(this.getAttribute('label-behind') ?? '{time} behind live', {\n time: format(this.range.end - time),\n });\n const clock = wall(engine, time);\n return clock === null ? behind : `${clock}, ${behind}`;\n }\n\n /** What the preview shows at a time. */\n private label(time: number): string {\n if (!this.isLive()) return format(time);\n return wall(this.player?.engine ?? null, time) ?? `-${format(this.range.end - time)}`;\n }\n\n /** Scrubs when the session has an I-frame track and the page allows it; seeks otherwise. */\n private dragStart(): void {\n const trick = optional(this.player?.engine ?? null).trick;\n this.dragged = null;\n // The pause below is the drag's, not the viewer's: the player says so,\n // with the state from before, which the play buttons keep showing.\n const before = this.player?.video.paused === false ? 'playing' : 'paused';\n this.player?.setAttribute('scrubbing', before);\n if (trick?.available === true && this.getAttribute('scrub') !== 'false') {\n trick.scrubStart();\n this.drag = 'scrub';\n } else {\n // Paused for the drag, the way the scrub is: the picture follows the\n // pointer, and playback waits for the release.\n const video = this.player?.video;\n this.resume = video !== undefined && !video.paused;\n video?.pause();\n this.drag = 'seek';\n }\n }\n\n /**\n * The pointer let go. A release writes its own input next, in the same\n * task, and that settles the drag. A cancelled drag writes none, so the\n * drag settles at its last position once the task is over.\n */\n private dragEnd(): void {\n queueMicrotask(() => {\n if (this.drag !== 'none') this.settle(this.dragged);\n });\n }\n\n /** Ends the drag at `value`, or where it stands when there is none. */\n private settle(value: number | null): void {\n const drag = this.drag;\n this.drag = 'none';\n this.dragged = null;\n const player = this.player;\n if (player === null) return;\n if (drag === 'scrub') {\n const trick = optional(player.engine).trick;\n if (value === null) trick?.scrubEnd();\n else trick?.scrubEnd(value);\n } else {\n if (value !== null) player.video.currentTime = value;\n if (this.resume) void player.video.play().catch(() => undefined);\n this.resume = false;\n }\n // After the play, which clears `paused` at once, so the start button\n // never shows between the release and the resume.\n player.removeAttribute('scrubbing');\n }\n\n /** Whether keys aim a target with the preview instead of seeking at once. */\n private previewing(): boolean {\n return this.getAttribute('key-mode') === 'preview';\n }\n\n /** The step for a key on the slider itself. */\n private keyStep(): number {\n const base = number(this, 'step', STEP);\n return this.previewing() ? base * this.growth() : base;\n }\n\n /**\n * How many steps a key moves the target under `key-mode=\"preview\"`. It\n * grows while the viewer holds the key, so a long film takes seconds to\n * cross, not minutes; a pause restarts it.\n */\n private growth(): number {\n const now = performance.now();\n if (now - this.lastMove > REPEAT_GAP_MS) this.moves = 0;\n this.moves += 1;\n this.lastMove = now;\n return Math.min(MAX_STEPS, 1 + Math.floor(this.moves / MOVES_PER_STEP));\n }\n\n /**\n * Aims at `value` without seeking: the thumb and the preview show it, and\n * the seek comes on Enter or once the keys pause. A TV decodes slowly, so\n * a seek per key would stutter where the preview already shows the place.\n */\n private aim(value: number): void {\n const time = Math.min(this.range.end, Math.max(this.range.start, value));\n this.target = time;\n this.bar.set(time, this.say(time));\n const span = this.range.end - this.range.start;\n if (span > 0) this.previewAt((time - this.range.start) / span);\n clearTimeout(this.commitTimer);\n this.commitTimer = window.setTimeout(() => {\n this.commit();\n }, KEY_COMMIT_MS);\n }\n\n /** Seeks to the target, if there is one. */\n private commit(): void {\n const target = this.target;\n this.stopAiming();\n const video = this.player?.video;\n if (target !== null && video !== undefined) video.currentTime = target;\n }\n\n /** Drops the target: the thumb goes back to the playhead. */\n private cancel(): void {\n this.stopAiming();\n this.render();\n }\n\n private stopAiming(): void {\n clearTimeout(this.commitTimer);\n this.commitTimer = 0;\n this.target = null;\n this.moves = 0;\n this.leave();\n }\n\n private input(value: number): void {\n const video = this.player?.video;\n if (video === undefined) return;\n this.bar.set(value, this.say(value));\n if (!this.bar.dragging()) {\n // The release, or a key: written now, and it supersedes whatever a\n // frame queued during the drag was about to write.\n this.pending = null;\n if (this.drag !== 'none') this.settle(value);\n else video.currentTime = value;\n return;\n }\n this.dragged = value;\n if (this.drag === 'scrub') {\n // The engine writes `currentTime` on every move; the browser drops a\n // seek a newer one supersedes, so no throttle is needed here.\n optional(this.player?.engine ?? null).trick?.scrubTo(value);\n return;\n }\n this.pending = value;\n if (this.frame === 0) {\n this.frame = requestAnimationFrame(() => {\n this.flush();\n });\n }\n }\n\n private flush(): void {\n this.frame = 0;\n const video = this.player?.video;\n if (this.pending === null || video === undefined) return;\n video.currentTime = this.pending;\n this.pending = null;\n }\n\n /** The width the page asked for through the token, or the default. */\n private previewWidth(): number {\n const set = Number.parseFloat(\n getComputedStyle(this.preview).getPropertyValue('--mbx-preview-width'),\n );\n return Number.isFinite(set) && set > 0 ? set : PREVIEW_WIDTH;\n }\n\n /** The preview's picture sources from `preview`, in order of preference: frames then tiles by default. */\n private sources(): Preview[] {\n const value = this.getAttribute('preview');\n if (value === 'none') return [];\n const own = (value ?? '')\n .split(/\\s+/)\n .filter((word): word is Preview => word === 'frames' || word === 'tiles');\n return own.length > 0 ? own : ['frames', 'tiles'];\n }\n\n /** `tile`, or none, drawn at its size and scaled to fit. */\n private paintTile(tile: Thumbnail | null): void {\n this.image.hidden = tile === null;\n if (tile === null) return;\n const scale = this.previewWidth() / tile.width;\n this.image.style.width = `${tile.width * scale}px`;\n this.image.style.height = `${tile.height * scale}px`;\n this.tile.style.width = `${tile.width}px`;\n this.tile.style.height = `${tile.height}px`;\n this.tile.style.backgroundImage = `url(\"${tile.url}\")`;\n this.tile.style.backgroundPosition = `-${tile.x}px -${tile.y}px`;\n this.tile.style.transform = `scale(${scale})`;\n }\n\n /**\n * The picture in the preview, from the sources `preview` names, the first\n * that answers winning. A decoded frame arrives later than a tile, so\n * while frames lead, the tile stands in until one is on screen, and the\n * last frame stays until the next one arrives. A scrub already shows the\n * position in the video, so the preview shows none meanwhile.\n */\n private paintPicture(when: number): void {\n const sources = this.drag === 'scrub' ? [] : this.sources();\n const api = optional(this.player?.engine ?? null);\n const trick = api.trick;\n // `previews` turns false once the engine knows no frame will come, such\n // as for TS I-frames; the tile shows then, without asking again.\n const frames = sources.includes('frames') && trick?.previews === true;\n const tile = sources.includes('tiles') ? (api.thumbnails?.at(when) ?? null) : null;\n if (tile !== null && (sources[0] === 'tiles' || !frames)) {\n // A frame still decoding for an earlier position must not replace it.\n this.asked += 1;\n this.shown = this.asked;\n this.frameCanvas.hidden = true;\n this.paintTile(tile);\n return;\n }\n if (!frames || trick === undefined) {\n this.frameCanvas.hidden = true;\n this.paintTile(null);\n return;\n }\n this.asked += 1;\n const request = this.asked;\n const width = this.previewWidth();\n // Null for a call a newer one replaced, and while the track's segments\n // load. What is on screen stays then.\n void trick.frameAt(when, { width: Math.round(width * devicePixelRatio) }).then(\n (bitmap) => {\n if (bitmap === null || request < this.shown || this.preview.hidden) return;\n this.shown = request;\n // The engine keeps the bitmap in its cache: drawn, never closed here.\n const canvas = this.frameCanvas;\n canvas.width = bitmap.width;\n canvas.height = bitmap.height;\n canvas.style.width = `${width}px`;\n canvas.style.height = `${(bitmap.height / bitmap.width) * width}px`;\n canvas.getContext('2d')?.drawImage(bitmap, 0, 0);\n canvas.hidden = false;\n this.image.hidden = true;\n },\n () => undefined,\n );\n if (this.frameCanvas.hidden) this.paintTile(tile);\n }\n\n /** The ranges the page marked blocked. */\n private blockedRanges(): Span[] {\n return (this.player?.markers.list ?? []).filter((marker) => marker.kind === 'blocked');\n }\n\n /** One child of `layer` per range, each named `part`, placed along the track. */\n private paintRanges(layer: HTMLElement, ranges: readonly Span[], part: string): void {\n const parts = clip(ranges, this.range);\n while (layer.childElementCount > parts.length) layer.lastElementChild?.remove();\n while (layer.childElementCount < parts.length) layer.append(el('div', part));\n let i = 0;\n for (const child of layer.children) {\n const part = parts[i];\n i += 1;\n if (part === undefined) break;\n const node = child as HTMLElement;\n node.style.left = percent(part[0]);\n node.style.width = percent(part[1] - part[0]);\n }\n }\n\n /** Whether a live window is wide enough to be worth a bar. */\n private worthSeeking(): boolean {\n const goals = number(this, 'live-window', LIVE_WINDOW);\n if (goals === 0) return true;\n const goal = bufferGoal(this.player?.engine ?? null) ?? BUFFER_GOAL;\n return this.range.end - this.range.start >= goals * goal;\n }\n\n /** The hover marker and the preview follow the pointer, clamped to the bar. */\n private point(event: PointerEvent): void {\n const rect = this.bar.rail.getBoundingClientRect();\n if (rect.width === 0 || this.range.end <= this.range.start) return;\n const part = Math.min(1, Math.max(0, (event.clientX - rect.left) / rect.width));\n this.hover.hidden = false;\n this.hover.style.left = percent(part);\n this.previewAt(part);\n }\n\n /** The preview over `part` of the bar: the time, the chapter, and the picture. */\n private previewAt(part: number): void {\n const rect = this.bar.rail.getBoundingClientRect();\n if (rect.width === 0 || this.range.end <= this.range.start) return;\n this.preview.hidden = false;\n const when = at(part, this.range);\n this.time.textContent = this.label(when);\n const chapter = this.chaptered('titles') ? this.list[chapterAt(this.list, when)] : undefined;\n // A blocked range shows no picture: its frames must not play, and a\n // preview would show them.\n const blocked = this.player?.markers.within(when).find((marker) => marker.kind === 'blocked');\n const title = blocked\n ? (blocked.label ?? this.getAttribute('label-blocked') ?? 'Not available')\n : (chapter?.title ?? '');\n this.caption.hidden = title === '';\n this.caption.textContent = title;\n if (blocked) {\n this.image.hidden = true;\n this.frameCanvas.hidden = true;\n } else this.paintPicture(when);\n const whole = this.bar.root.getBoundingClientRect();\n const half = this.preview.offsetWidth / 2;\n const x = rect.left - whole.left + part * rect.width;\n this.preview.style.left = `${Math.min(whole.width - half, Math.max(half, x))}px`;\n }\n\n private leave(): void {\n this.hover.hidden = true;\n this.preview.hidden = true;\n // The next hover starts from the tile, not a frame from elsewhere on the bar.\n this.frameCanvas.hidden = true;\n }\n\n protected override attach(player: PlayerHost): void {\n const tick = (): void => {\n this.render();\n };\n this.listen(player.video, EVENTS, tick);\n this.keep(followChapters(player, tick));\n this.listen(player, ['markerschange'], tick);\n this.listen(player, ['sourcechange'], () => {\n this.drag = 'none';\n this.stopAiming();\n this.render();\n });\n // Under `key-mode=\"preview\"`, the control bar's seeking keys aim: it\n // asks through `seekkey` before it seeks, and a taken event does not.\n this.listen(player, ['seekkey'], (event: Event) => {\n const asked = event as CustomEvent<{ readonly by: number }>;\n if (!this.previewing() || this.hidden || asked.defaultPrevented) return;\n asked.preventDefault();\n this.aim((this.target ?? player.video.currentTime) + asked.detail.by * this.growth());\n });\n // While a target stands, Enter seeks to it and Escape or Back drops it,\n // wherever focus is: on the bar, or anywhere the seeking keys came from.\n // Bubbling, so a focused control has its say first.\n this.listen(player, ['keydown'], (event: Event) => {\n const key = event as KeyboardEvent;\n if (this.target === null || key.defaultPrevented) return;\n // Enter on a button is that button's.\n if (key.key === 'Enter' && !(key.composedPath()[0] instanceof HTMLButtonElement)) {\n this.commit();\n } else if (CANCEL_KEYS.includes(key.key)) {\n this.cancel();\n } else return;\n key.preventDefault();\n });\n this.render();\n }\n\n protected override detach(player: PlayerHost): void {\n cancelAnimationFrame(this.frame);\n this.frame = 0;\n this.pending = null;\n if (this.drag !== 'none') this.settle(null);\n this.stopAiming();\n player.removeAttribute('live');\n player.removeAttribute('seekable');\n player.removeAttribute('scrubbing');\n }\n\n protected override render(): void {\n const player = this.player;\n if (player === null) return;\n const video = player.video;\n const engine = player.engine;\n const api = live(engine);\n const on = api !== undefined;\n this.range = span(video, engine);\n this.list = chapters(video, engine);\n this.bar.label(this.getAttribute('label') ?? 'Seek');\n this.bar.range(this.range.start, this.range.end);\n this.paintRanges(this.buffered, spans(video.buffered), 'buffered-range');\n this.paintRanges(this.blocked, this.blockedRanges(), 'blocked-range');\n this.paintChapters();\n this.edge.hidden = !on;\n if (api !== undefined && api.edge !== null) {\n this.edge.style.left = percent(fraction(api.edge, this.range));\n }\n const seekable = !on || this.worthSeeking();\n this.hidden = !seekable;\n player.toggleAttribute('live', on);\n player.toggleAttribute('seekable', seekable);\n if (!this.bar.dragging() && this.target === null) {\n this.bar.set(video.currentTime, this.say(video.currentTime));\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAuEA,MAAA,YAAA;AASA,MAAA,OAAA;;AAGA,MAAA,gBAAA;;AAEA,MAAA,gBAAA;;AAEA,MAAA,iBAAA;;AAEA,MAAA,YAAA;;AAGA,MAAA,cAAA;CAAA;CAAA;CAAA;AAAA;AACA,MAAA,OAAA;AACA,MAAA,cAAA;;AAGA,MAAA,gBAAA;;AAGA,MAAA,cAAA;;AAGA,MAAA,MAAA;AAEA,MAAA,SAAA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACA;AAEA,MAAA,QAAA,eAAA;AAEA,SAAA,QAAA,MAAA;CACA,OAAA,GAAA,OAAA,IAAA;AACA;;;;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AAA;EACA,KAAA,UAAA;EACA,IAAA,KAAA,SAAA,QAAA,KAAA,OAAA,IAAA;EACA,KAAA,WAAA;EACA,OAAA,gBAAA,MAAA;EACA,OAAA,gBAAA,UAAA;EACA,OAAA,gBAAA,WAAA;CACA;CAEA,SAAA;EACA,MAAA,SAAA,KAAA;EACA,IAAA,WAAA,MAAA;EACA,MAAA,QAAA,OAAA;EACA,MAAA,SAAA,OAAA;EACA,MAAA,MAAA,KAAA,MAAA;EACA,MAAA,KAAA,QAAA,KAAA;EACA,KAAA,QAAA,KAAA,OAAA,MAAA;EACA,KAAA,OAAA,SAAA,OAAA,MAAA;EACA,KAAA,IAAA,MAAA,KAAA,aAAA,OAAA,KAAA,MAAA;EACA,KAAA,IAAA,MAAA,KAAA,MAAA,OAAA,KAAA,MAAA,GAAA;EACA,KAAA,YAAA,KAAA,UAAA,MAAA,MAAA,QAAA,GAAA,gBAAA;EACA,KAAA,YAAA,KAAA,SAAA,KAAA,cAAA,GAAA,eAAA;EACA,KAAA,cAAA;EACA,KAAA,KAAA,SAAA,CAAA;EACA,IAAA,QAAA,KAAA,KAAA,IAAA,SAAA,MACA,KAAA,KAAA,MAAA,OAAA,QAAA,SAAA,IAAA,MAAA,KAAA,KAAA,CAAA;EAEA,MAAA,WAAA,CAAA,MAAA,KAAA,aAAA;EACA,KAAA,SAAA,CAAA;EACA,OAAA,gBAAA,QAAA,EAAA;EACA,OAAA,gBAAA,YAAA,QAAA;EACA,IAAA,CAAA,KAAA,IAAA,SAAA,KAAA,KAAA,WAAA,MACA,KAAA,IAAA,IAAA,MAAA,aAAA,KAAA,IAAA,MAAA,WAAA,CAAA;CAEA;AACA"}
1
+ {"version":3,"file":"seek-bar.js","names":[],"sources":["../../src/elements/seek-bar.ts"],"sourcesContent":["/**\n * <mbx-seek-bar>: the bar over the slider primitive, with four layers on\n * its track, every one a part: the buffered ranges from `video.buffered`,\n * the played span, the hover position, and for live the edge from\n * `engine.live`. The span it maps is the availability window for live and\n * the duration for VOD; `controls/session.ts` says which.\n *\n * A live stream is seekable only when the window is worth it: at least\n * `live-window` forward buffer goals long, the goal read from the engine.\n * Below that the bar hides. VOD is always seekable. The element sets\n * `live` and `seekable` on the player, which the time and the live button\n * read, and `scrubbing` while a pointer holds the thumb: `playing` or\n * `paused`, the state before the drag, which the play buttons show\n * instead of the drag's own pause.\n *\n * Reads happen on the events the video already fires; the live window has\n * no event of its own and moves with the clock, so `timeupdate` covers it.\n * While a pointer holds the thumb, the played layer follows the pointer.\n * The element carries `dragging` meanwhile. With an I-frame track\n * (`engine.trick.available`), the drag scrubs: the video pauses and shows\n * the I-frame at every position, and the release seeks there. See the\n * engine guide's trick play chapter. `scrub=\"false\"` turns this off.\n * Otherwise the video pauses, `currentTime` is written at most once per\n * frame, so the bar never fights a slow seek, and the release resumes\n * playback if it was playing. Thumbnail tiles never drive a drag: they are\n * previews, not frames of the video.\n *\n * The preview above the pointer carries the time and a picture of that\n * time from the sources `preview` names, in order of preference: `frames`\n * and `tiles`, \"frames tiles\" by default, `none` for no picture. A frame\n * is the decoded I-frame from `engine.trick.frameAt`, when the track\n * decodes in this browser; the last one stays until the next arrives, so\n * the picture never flickers while the engine decodes. A tile comes from\n * `engine.thumbnails`: a rectangle of a sprite, drawn by background\n * position at the sprite's own size. Both scale to `--mbx-preview-width`,\n * so a page sets the size with one token.\n *\n * Chapters divide the track: one gap per chapter boundary, cut through\n * every layer with a mask, so the played and the buffered spans read per\n * chapter, and the preview names the chapter under the pointer. They come\n * from the session, see `controls/chapters.ts`. `chapters` lists what the\n * bar does with them: `divided` and `titles`, both by default, one of\n * them alone, or `none`.\n *\n * `step` is what an arrow key moves the playhead by and `page` what Page\n * Up and Page Down do, in seconds. `key-mode=\"preview\"`, for a TV, makes\n * the keys aim instead of seek: the thumb and the preview show the target,\n * a held key's step grows, and the seek comes on Enter, on leaving the bar,\n * or a second after the last key. Escape or Back drops the target. The\n * control bar's seeking keys, the arrows and fast forward and rewind\n * anywhere in the player, aim the same way: the bar asks through\n * `seekkey`, and the seek bar takes it. The default, `instant`, seeks on\n * every key. The name comes from `label`; what a\n * screen reader hears at a position from `label-of`, \"{current} of\n * {duration}\", and on live from `label-behind`, \"{time} behind live\". It\n * sits in the bar's seek row unless the page says otherwise.\n */\n\nimport type { Thumbnail } from 'mattebox/stages/thumbnails';\nimport type { Chapter } from '../controls/chapters.js';\nimport { chapterAt, chapters, followChapters } from '../controls/chapters.js';\nimport type { Span } from '../controls/ranges.js';\nimport { at, clip, EMPTY, fraction, spans } from '../controls/ranges.js';\nimport { bufferGoal, live, optional, span, wall } from '../controls/session.js';\nimport type { Slider } from '../controls/slider.js';\nimport { slider } from '../controls/slider.js';\nimport { format } from '../controls/time.js';\nimport { el } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { fill } from '../labels.js';\nimport { Component } from './component.js';\nimport STYLE_CSS from './seek-bar.css?inline';\nimport { number, SLIDER_STYLE, seekRow, style } from './shared.js';\n\n/** What a drag does, chosen when the pointer takes the thumb. */\ntype Drag = 'none' | 'seek' | 'scrub';\n\n/** Where the preview's picture comes from: decoded I-frames, or thumbnail tiles. */\ntype Preview = 'frames' | 'tiles';\n\nconst STEP = 5;\n\n/** Under `key-mode=\"preview\"`, a target seeks this long after the last key. */\nconst KEY_COMMIT_MS = 1000;\n/** Key moves closer together than this are one hold, whose step grows. */\nconst REPEAT_GAP_MS = 400;\n/** A held key's step grows by one step every this many moves... */\nconst MOVES_PER_STEP = 8;\n/** ...up to this many steps a move. */\nconst MAX_STEPS = 12;\n\n/** The keys that cancel a target: Escape, and Back as a remote sends it. */\nconst CANCEL_KEYS = ['Escape', 'GoBack', 'BrowserBack'];\nconst PAGE = 30;\nconst LIVE_WINDOW = 3;\n\n/** What the tile scales down to, in em, when the page sets no `--mbx-preview-width`. */\nconst PREVIEW_WIDTH = 10;\n\n/** The buffer goal assumed for a session that reports none. */\nconst BUFFER_GOAL = 30;\n\n/** The gap cut at a chapter boundary, in pixels. */\nconst GAP = 2;\n\nconst EVENTS = [\n 'timeupdate',\n 'progress',\n 'durationchange',\n 'loadedmetadata',\n 'seeking',\n 'seeked',\n 'emptied',\n];\n\nconst STYLE = SLIDER_STYLE + STYLE_CSS;\n\nfunction percent(part: number): string {\n return `${part * 100}%`;\n}\n\n/**\n * A mask that cuts a gap at each chapter boundary, as stops along the\n * track: opaque up to a boundary, clear for the gap, opaque after.\n */\nfunction gaps(boundaries: readonly number[], span: Span): string {\n if (boundaries.length === 0) return '';\n const stops: string[] = ['#000 0'];\n for (const time of boundaries) {\n const at = percent(fraction(time, span));\n const before = `calc(${at} - ${GAP / 2}px)`;\n const after = `calc(${at} + ${GAP / 2}px)`;\n stops.push(`#000 ${before}`, `transparent ${before}`, `transparent ${after}`, `#000 ${after}`);\n }\n stops.push('#000 100%');\n return `linear-gradient(to right, ${stops.join(', ')})`;\n}\n\nexport class MbxSeekBar extends Component {\n static get observedAttributes(): readonly string[] {\n return [\n 'label',\n 'label-of',\n 'label-behind',\n 'label-blocked',\n 'live-window',\n 'chapters',\n 'scrub',\n 'preview',\n 'key-mode',\n ];\n }\n\n declare private readonly bar: Slider;\n declare private readonly buffered: HTMLElement;\n /** The ranges the page marked blocked, drawn as a broken line: they never play. */\n declare private readonly blocked: HTMLElement;\n declare private readonly hover: HTMLElement;\n declare private readonly edge: HTMLElement;\n declare private readonly preview: HTMLElement;\n declare private readonly image: HTMLElement;\n declare private readonly tile: HTMLElement;\n declare private readonly time: HTMLElement;\n declare private readonly caption: HTMLElement;\n declare private readonly frameCanvas: HTMLCanvasElement;\n declare private drag: Drag;\n /** The last position of the drag, which a cancelled drag settles at. */\n declare private dragged: number | null;\n /** Whether the video played when a seeking drag began, so the release resumes it. */\n declare private resume: boolean;\n /** Frames asked for, and the newest one on screen, so a late frame never replaces a newer one. */\n declare private asked: number;\n /** Under `key-mode=\"preview\"`: where the keys aim, not yet sought to, or null. */\n declare private target: number | null;\n declare private commitTimer: number;\n /** The moves of the current hold, and when the last one came. */\n declare private moves: number;\n declare private lastMove: number;\n declare private shown: number;\n declare private range: Span;\n /** The chapters as last drawn, so the mask is written only when they change. */\n declare private divided: string;\n declare private list: Chapter[];\n declare private pending: number | null;\n declare private frame: number;\n\n constructor() {\n super();\n this.range = EMPTY;\n this.pending = null;\n this.frame = 0;\n this.divided = '';\n this.list = [];\n this.drag = 'none';\n this.dragged = null;\n this.resume = false;\n this.asked = 0;\n this.shown = 0;\n this.target = null;\n this.commitTimer = 0;\n this.moves = 0;\n this.lastMove = 0;\n const root = this.attachShadow({ mode: 'open' });\n this.bar = slider({\n step: () => this.keyStep(),\n page: () => number(this, 'page', PAGE),\n onInput: (value, key) => {\n if (key && this.previewing()) this.aim(value);\n else this.input(value);\n },\n onDrag: (on) => {\n this.toggleAttribute('dragging', on);\n if (on) this.dragStart();\n else this.dragEnd();\n },\n });\n this.buffered = el('div', 'buffered');\n this.blocked = el('div', 'blocked');\n this.hover = el('div', 'hover');\n this.edge = el('div', 'edge');\n this.hover.hidden = true;\n this.edge.hidden = true;\n // Under the fill, so what is played reads over what is buffered.\n this.bar.track.prepend(this.buffered);\n // Over the fill, inside the track: the chapter gaps cut through it too.\n this.bar.track.append(this.blocked, this.hover, this.edge);\n this.preview = el('div', 'preview');\n this.image = el('div', 'preview-image');\n this.tile = el('div', 'preview-tile');\n this.time = el('span', 'preview-time');\n this.caption = el('span', 'preview-title');\n this.caption.hidden = true;\n this.image.append(this.tile);\n this.image.hidden = true;\n this.frameCanvas = el('canvas', 'preview-frame');\n this.frameCanvas.hidden = true;\n this.preview.append(this.frameCanvas, this.image, this.caption, this.time);\n this.preview.hidden = true;\n this.bar.root.append(this.preview);\n this.bar.root.addEventListener('pointermove', (event) => {\n this.point(event);\n });\n this.bar.root.addEventListener('pointerleave', () => {\n if (this.target === null) this.leave();\n });\n // Focus moving on: the target stands, as if the pause ran out.\n this.bar.root.addEventListener('blur', () => {\n if (this.target !== null) this.commit();\n });\n root.append(style(STYLE), this.bar.root);\n }\n\n override connectedCallback(): void {\n seekRow(this);\n super.connectedCallback();\n }\n\n private isLive(): boolean {\n return live(this.player?.engine ?? null) !== undefined;\n }\n\n /** Whether the chapters do `use`: `divided` the track, or name the preview with their `titles`. */\n private chaptered(use: 'divided' | 'titles'): boolean {\n if (this.list.length === 0) return false;\n const value = this.getAttribute('chapters');\n if (value === null) return true;\n const words = value.split(/\\s+/);\n // A value naming neither, as `on` did, keeps both.\n return (\n words.includes(use) ||\n !words.some((word) => word === 'divided' || word === 'titles' || word === 'none')\n );\n }\n\n /** The gaps at the chapter boundaries, on every layer of the track at once. */\n private paintChapters(): void {\n const boundaries =\n this.chaptered('divided') && this.list.length > 1\n ? this.list.slice(1).map((chapter) => chapter.start)\n : [];\n const mask = gaps(boundaries, this.range);\n const key = `${mask}|${this.range.start}|${this.range.end}`;\n if (key === this.divided) return;\n this.divided = key;\n const track = this.bar.track.style;\n // Both spellings: WebKit before 15.4 knows only the prefixed one.\n track.setProperty('mask-image', mask === '' ? '' : mask);\n track.setProperty('-webkit-mask-image', mask === '' ? '' : mask);\n }\n\n /** What a screen reader hears at a time. */\n private say(time: number): string {\n const engine = this.player?.engine ?? null;\n if (!this.isLive()) {\n const template = this.getAttribute('label-of') ?? '{current} of {duration}';\n return Number.isFinite(this.range.end) && this.range.end > 0\n ? fill(template, { current: format(time), duration: format(this.range.end) })\n : format(time);\n }\n const behind = fill(this.getAttribute('label-behind') ?? '{time} behind live', {\n time: format(this.range.end - time),\n });\n const clock = wall(engine, time);\n return clock === null ? behind : `${clock}, ${behind}`;\n }\n\n /** What the preview shows at a time. */\n private label(time: number): string {\n if (!this.isLive()) return format(time);\n return wall(this.player?.engine ?? null, time) ?? `-${format(this.range.end - time)}`;\n }\n\n /** Scrubs when the session has an I-frame track and the page allows it; seeks otherwise. */\n private dragStart(): void {\n const trick = optional(this.player?.engine ?? null).trick;\n this.dragged = null;\n // The pause below is the drag's, not the viewer's: the player says so,\n // with the state from before, which the play buttons keep showing.\n const before = this.player?.video.paused === false ? 'playing' : 'paused';\n this.player?.setAttribute('scrubbing', before);\n if (trick?.available === true && this.getAttribute('scrub') !== 'false') {\n trick.scrubStart();\n this.drag = 'scrub';\n } else {\n // Paused for the drag, the way the scrub is: the picture follows the\n // pointer, and playback waits for the release.\n const video = this.player?.video;\n this.resume = video !== undefined && !video.paused;\n video?.pause();\n this.drag = 'seek';\n }\n }\n\n /**\n * The pointer let go. A release writes its own input next, in the same\n * task, and that settles the drag. A cancelled drag writes none, so the\n * drag settles at its last position once the task is over.\n */\n private dragEnd(): void {\n queueMicrotask(() => {\n if (this.drag !== 'none') this.settle(this.dragged);\n });\n }\n\n /** Ends the drag at `value`, or where it stands when there is none. */\n private settle(value: number | null): void {\n const drag = this.drag;\n this.drag = 'none';\n this.dragged = null;\n const player = this.player;\n if (player === null) return;\n if (drag === 'scrub') {\n const trick = optional(player.engine).trick;\n if (value === null) trick?.scrubEnd();\n else trick?.scrubEnd(value);\n } else {\n if (value !== null) player.video.currentTime = value;\n if (this.resume) void player.video.play().catch(() => undefined);\n this.resume = false;\n }\n // After the play, which clears `paused` at once, so the start button\n // never shows between the release and the resume.\n player.removeAttribute('scrubbing');\n }\n\n /** Whether keys aim a target with the preview instead of seeking at once. */\n private previewing(): boolean {\n return this.getAttribute('key-mode') === 'preview';\n }\n\n /** The step for a key on the slider itself. */\n private keyStep(): number {\n const base = number(this, 'step', STEP);\n return this.previewing() ? base * this.growth() : base;\n }\n\n /**\n * How many steps a key moves the target under `key-mode=\"preview\"`. It\n * grows while the viewer holds the key, so a long film takes seconds to\n * cross, not minutes; a pause restarts it.\n */\n private growth(): number {\n const now = performance.now();\n if (now - this.lastMove > REPEAT_GAP_MS) this.moves = 0;\n this.moves += 1;\n this.lastMove = now;\n return Math.min(MAX_STEPS, 1 + Math.floor(this.moves / MOVES_PER_STEP));\n }\n\n /**\n * Aims at `value` without seeking: the thumb and the preview show it, and\n * the seek comes on Enter or once the keys pause. A TV decodes slowly, so\n * a seek per key would stutter where the preview already shows the place.\n */\n private aim(value: number): void {\n const time = Math.min(this.range.end, Math.max(this.range.start, value));\n this.target = time;\n this.bar.set(time, this.say(time));\n const span = this.range.end - this.range.start;\n if (span > 0) this.previewAt((time - this.range.start) / span);\n clearTimeout(this.commitTimer);\n this.commitTimer = window.setTimeout(() => {\n this.commit();\n }, KEY_COMMIT_MS);\n }\n\n /** Seeks to the target, if there is one. */\n private commit(): void {\n const target = this.target;\n this.stopAiming();\n const video = this.player?.video;\n if (target !== null && video !== undefined) video.currentTime = target;\n }\n\n /** Drops the target: the thumb goes back to the playhead. */\n private cancel(): void {\n this.stopAiming();\n this.render();\n }\n\n private stopAiming(): void {\n clearTimeout(this.commitTimer);\n this.commitTimer = 0;\n this.target = null;\n this.moves = 0;\n this.leave();\n }\n\n private input(value: number): void {\n const video = this.player?.video;\n if (video === undefined) return;\n this.bar.set(value, this.say(value));\n if (!this.bar.dragging()) {\n // The release, or a key: written now, and it supersedes whatever a\n // frame queued during the drag was about to write.\n this.pending = null;\n if (this.drag !== 'none') this.settle(value);\n else video.currentTime = value;\n return;\n }\n this.dragged = value;\n if (this.drag === 'scrub') {\n // The engine writes `currentTime` on every move; the browser drops a\n // seek a newer one supersedes, so no throttle is needed here.\n optional(this.player?.engine ?? null).trick?.scrubTo(value);\n return;\n }\n this.pending = value;\n if (this.frame === 0) {\n this.frame = requestAnimationFrame(() => {\n this.flush();\n });\n }\n }\n\n private flush(): void {\n this.frame = 0;\n const video = this.player?.video;\n if (this.pending === null || video === undefined) return;\n video.currentTime = this.pending;\n this.pending = null;\n }\n\n /** The width the page asked for through the token, or the default. */\n private previewWidth(): number {\n const set = Number.parseFloat(\n getComputedStyle(this.preview).getPropertyValue('--mbx-preview-width'),\n );\n if (Number.isFinite(set) && set > 0) return set;\n return PREVIEW_WIDTH * (Number.parseFloat(getComputedStyle(this).fontSize) || 16);\n }\n\n /** The preview's picture sources from `preview`, in order of preference: frames then tiles by default. */\n private sources(): Preview[] {\n const value = this.getAttribute('preview');\n if (value === 'none') return [];\n const own = (value ?? '')\n .split(/\\s+/)\n .filter((word): word is Preview => word === 'frames' || word === 'tiles');\n return own.length > 0 ? own : ['frames', 'tiles'];\n }\n\n /** `tile`, or none, drawn at its size and scaled to fit. */\n private paintTile(tile: Thumbnail | null): void {\n this.image.hidden = tile === null;\n if (tile === null) return;\n const scale = this.previewWidth() / tile.width;\n this.image.style.width = `${tile.width * scale}px`;\n this.image.style.height = `${tile.height * scale}px`;\n this.tile.style.width = `${tile.width}px`;\n this.tile.style.height = `${tile.height}px`;\n this.tile.style.backgroundImage = `url(\"${tile.url}\")`;\n this.tile.style.backgroundPosition = `-${tile.x}px -${tile.y}px`;\n this.tile.style.transform = `scale(${scale})`;\n }\n\n /**\n * The picture in the preview, from the sources `preview` names, the first\n * that answers winning. A decoded frame arrives later than a tile, so\n * while frames lead, the tile stands in until one is on screen, and the\n * last frame stays until the next one arrives. A scrub already shows the\n * position in the video, so the preview shows none meanwhile.\n */\n private paintPicture(when: number): void {\n const sources = this.drag === 'scrub' ? [] : this.sources();\n const api = optional(this.player?.engine ?? null);\n const trick = api.trick;\n // `previews` turns false once the engine knows no frame will come, such\n // as for TS I-frames; the tile shows then, without asking again.\n const frames = sources.includes('frames') && trick?.previews === true;\n const tile = sources.includes('tiles') ? (api.thumbnails?.at(when) ?? null) : null;\n if (tile !== null && (sources[0] === 'tiles' || !frames)) {\n // A frame still decoding for an earlier position must not replace it.\n this.asked += 1;\n this.shown = this.asked;\n this.frameCanvas.hidden = true;\n this.paintTile(tile);\n return;\n }\n if (!frames || trick === undefined) {\n this.frameCanvas.hidden = true;\n this.paintTile(null);\n return;\n }\n this.asked += 1;\n const request = this.asked;\n const width = this.previewWidth();\n // Null for a call a newer one replaced, and while the track's segments\n // load. What is on screen stays then.\n void trick.frameAt(when, { width: Math.round(width * devicePixelRatio) }).then(\n (bitmap) => {\n if (bitmap === null || request < this.shown || this.preview.hidden) return;\n this.shown = request;\n // The engine keeps the bitmap in its cache: drawn, never closed here.\n const canvas = this.frameCanvas;\n canvas.width = bitmap.width;\n canvas.height = bitmap.height;\n canvas.style.width = `${width}px`;\n canvas.style.height = `${(bitmap.height / bitmap.width) * width}px`;\n canvas.getContext('2d')?.drawImage(bitmap, 0, 0);\n canvas.hidden = false;\n this.image.hidden = true;\n },\n () => undefined,\n );\n if (this.frameCanvas.hidden) this.paintTile(tile);\n }\n\n /** The ranges the page marked blocked. */\n private blockedRanges(): Span[] {\n return (this.player?.markers.list ?? []).filter((marker) => marker.kind === 'blocked');\n }\n\n /** One child of `layer` per range, each named `part`, placed along the track. */\n private paintRanges(layer: HTMLElement, ranges: readonly Span[], part: string): void {\n const parts = clip(ranges, this.range);\n while (layer.childElementCount > parts.length) layer.lastElementChild?.remove();\n while (layer.childElementCount < parts.length) layer.append(el('div', part));\n let i = 0;\n for (const child of layer.children) {\n const part = parts[i];\n i += 1;\n if (part === undefined) break;\n const node = child as HTMLElement;\n node.style.left = percent(part[0]);\n node.style.width = percent(part[1] - part[0]);\n }\n }\n\n /** Whether a live window is wide enough to be worth a bar. */\n private worthSeeking(): boolean {\n const goals = number(this, 'live-window', LIVE_WINDOW);\n if (goals === 0) return true;\n const goal = bufferGoal(this.player?.engine ?? null) ?? BUFFER_GOAL;\n return this.range.end - this.range.start >= goals * goal;\n }\n\n /** The hover marker and the preview follow the pointer, clamped to the bar. */\n private point(event: PointerEvent): void {\n const rect = this.bar.rail.getBoundingClientRect();\n if (rect.width === 0 || this.range.end <= this.range.start) return;\n const part = Math.min(1, Math.max(0, (event.clientX - rect.left) / rect.width));\n this.hover.hidden = false;\n this.hover.style.left = percent(part);\n this.previewAt(part);\n }\n\n /** The preview over `part` of the bar: the time, the chapter, and the picture. */\n private previewAt(part: number): void {\n const rect = this.bar.rail.getBoundingClientRect();\n if (rect.width === 0 || this.range.end <= this.range.start) return;\n this.preview.hidden = false;\n const when = at(part, this.range);\n this.time.textContent = this.label(when);\n const chapter = this.chaptered('titles') ? this.list[chapterAt(this.list, when)] : undefined;\n // A blocked range shows no picture: its frames must not play, and a\n // preview would show them.\n const blocked = this.player?.markers.within(when).find((marker) => marker.kind === 'blocked');\n const title = blocked\n ? (blocked.label ?? this.getAttribute('label-blocked') ?? 'Not available')\n : (chapter?.title ?? '');\n this.caption.hidden = title === '';\n this.caption.textContent = title;\n if (blocked) {\n this.image.hidden = true;\n this.frameCanvas.hidden = true;\n } else this.paintPicture(when);\n const whole = this.bar.root.getBoundingClientRect();\n const half = this.preview.offsetWidth / 2;\n const x = rect.left - whole.left + part * rect.width;\n this.preview.style.left = `${Math.min(whole.width - half, Math.max(half, x))}px`;\n }\n\n private leave(): void {\n this.hover.hidden = true;\n this.preview.hidden = true;\n // The next hover starts from the tile, not a frame from elsewhere on the bar.\n this.frameCanvas.hidden = true;\n }\n\n protected override attach(player: PlayerHost): void {\n const tick = (): void => {\n this.render();\n };\n this.listen(player.video, EVENTS, tick);\n this.keep(followChapters(player, tick));\n this.listen(player, ['markerschange'], tick);\n this.listen(player, ['sourcechange'], () => {\n this.drag = 'none';\n this.stopAiming();\n this.render();\n });\n // Under `key-mode=\"preview\"`, the control bar's seeking keys aim: it\n // asks through `seekkey` before it seeks, and a taken event does not.\n this.listen(player, ['seekkey'], (event: Event) => {\n const asked = event as CustomEvent<{ readonly by: number }>;\n if (!this.previewing() || this.hidden || asked.defaultPrevented) return;\n asked.preventDefault();\n this.aim((this.target ?? player.video.currentTime) + asked.detail.by * this.growth());\n });\n // While a target stands, Enter seeks to it and Escape or Back drops it,\n // wherever focus is: on the bar, or anywhere the seeking keys came from.\n // Bubbling, so a focused control has its say first.\n this.listen(player, ['keydown'], (event: Event) => {\n const key = event as KeyboardEvent;\n if (this.target === null || key.defaultPrevented) return;\n // Enter on a button is that button's.\n if (key.key === 'Enter' && !(key.composedPath()[0] instanceof HTMLButtonElement)) {\n this.commit();\n } else if (CANCEL_KEYS.includes(key.key)) {\n this.cancel();\n } else return;\n key.preventDefault();\n });\n this.render();\n }\n\n protected override detach(player: PlayerHost): void {\n cancelAnimationFrame(this.frame);\n this.frame = 0;\n this.pending = null;\n if (this.drag !== 'none') this.settle(null);\n this.stopAiming();\n player.removeAttribute('live');\n player.removeAttribute('seekable');\n player.removeAttribute('scrubbing');\n }\n\n protected override render(): void {\n const player = this.player;\n if (player === null) return;\n const video = player.video;\n const engine = player.engine;\n const api = live(engine);\n const on = api !== undefined;\n this.range = span(video, engine);\n this.list = chapters(video, engine);\n this.bar.label(this.getAttribute('label') ?? 'Seek');\n this.bar.range(this.range.start, this.range.end);\n this.paintRanges(this.buffered, spans(video.buffered), 'buffered-range');\n this.paintRanges(this.blocked, this.blockedRanges(), 'blocked-range');\n this.paintChapters();\n this.edge.hidden = !on;\n if (api !== undefined && api.edge !== null) {\n this.edge.style.left = percent(fraction(api.edge, this.range));\n }\n const seekable = !on || this.worthSeeking();\n this.hidden = !seekable;\n player.toggleAttribute('live', on);\n player.toggleAttribute('seekable', seekable);\n if (!this.bar.dragging() && this.target === null) {\n this.bar.set(video.currentTime, this.say(video.currentTime));\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAuEA,MAAA,YAAA;AASA,MAAA,OAAA;;AAGA,MAAA,gBAAA;;AAEA,MAAA,gBAAA;;AAEA,MAAA,iBAAA;;AAEA,MAAA,YAAA;;AAGA,MAAA,cAAA;CAAA;CAAA;CAAA;AAAA;AACA,MAAA,OAAA;AACA,MAAA,cAAA;;AAGA,MAAA,gBAAA;;AAGA,MAAA,cAAA;;AAGA,MAAA,MAAA;AAEA,MAAA,SAAA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACA;AAEA,MAAA,QAAA,eAAA;AAEA,SAAA,QAAA,MAAA;CACA,OAAA,GAAA,OAAA,IAAA;AACA;;;;;AAMA,SAAA,KAAA,YAAA,MAAA;CACA,IAAA,WAAA,WAAA,GAAA,OAAA;CACA,MAAA,QAAA,CAAA,QAAA;CACA,KAAA,MAAA,QAAA,YAAA;EACA,MAAA,KAAA,QAAA,SAAA,MAAA,IAAA,CAAA;EACA,MAAA,S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AAA,gBAAA,UAAA;EACA,OAAA,gBAAA,WAAA;CACA;CAEA,SAAA;EACA,MAAA,SAAA,KAAA;EACA,IAAA,WAAA,MAAA;EACA,MAAA,QAAA,OAAA;EACA,MAAA,SAAA,OAAA;EACA,MAAA,MAAA,KAAA,MAAA;EACA,MAAA,KAAA,QAAA,KAAA;EACA,KAAA,QAAA,KAAA,OAAA,MAAA;EACA,KAAA,OAAA,SAAA,OAAA,MAAA;EACA,KAAA,IAAA,MAAA,KAAA,aAAA,OAAA,KAAA,MAAA;EACA,KAAA,IAAA,MAAA,KAAA,MAAA,OAAA,KAAA,MAAA,GAAA;EACA,KAAA,YAAA,KAAA,UAAA,MAAA,MAAA,QAAA,GAAA,gBAAA;EACA,KAAA,YAAA,KAAA,SAAA,KAAA,cAAA,GAAA,eAAA;EACA,KAAA,cAAA;EACA,KAAA,KAAA,SAAA,CAAA;EACA,IAAA,QAAA,KAAA,KAAA,IAAA,SAAA,MACA,KAAA,KAAA,MAAA,OAAA,QAAA,SAAA,IAAA,MAAA,KAAA,KAAA,CAAA;EAEA,MAAA,WAAA,CAAA,MAAA,KAAA,aAAA;EACA,KAAA,SAAA,CAAA;EACA,OAAA,gBAAA,QAAA,EAAA;EACA,OAAA,gBAAA,YAAA,QAAA;EACA,IAAA,CAAA,KAAA,IAAA,SAAA,KAAA,KAAA,WAAA,MACA,KAAA,IAAA,IAAA,MAAA,aAAA,KAAA,IAAA,MAAA,WAAA,CAAA;CAEA;AACA"}
@@ -7,8 +7,8 @@
7
7
  *
8
8
  * Nothing carries `!important`: a page's `::part()` rule must win.
9
9
  */
10
- const BUTTON_STYLE_CSS = ":host{display:inline-flex}:host([hidden]){display:none}[part~=button]{width:40px;height:40px;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}[part~=button]:hover{opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline:none}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}slot[hidden]{display:none}";
11
- const SLIDER_STYLE_CSS = ":host{display:block}:host([hidden]){display:none}[part~=slider]{border-radius:var(--mbx-radius);cursor:pointer;touch-action:none;height:40px;position:relative}[part~=slider]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=slider]:focus:not(:focus-visible){outline:none}[part~=rail]{position:absolute;top:0;bottom:0;left:8px;right:8px}[part~=track]{background:#ffffff59;border-radius:2px;height:4px;position:absolute;top:50%;left:0;right:0;overflow:hidden;transform:translateY(-50%)}[part~=fill]{background:var(--mbx-accent);position:absolute;top:0;bottom:0;left:0}[part~=thumb]{background:var(--mbx-text);pointer-events:none;border-radius:50%;width:12px;height:12px;margin:-6px 0 0 -6px;position:absolute;top:50%}";
10
+ const BUTTON_STYLE_CSS = ":host{display:inline-flex}:host([hidden]){display:none}[part~=button]{width:2.5em;height:2.5em;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex;position:relative}[part~=button][aria-label]:after{content:attr(aria-label);display:var(--mbx-tooltip,block);background:var(--mbx-surface);border-radius:var(--mbx-radius);white-space:nowrap;pointer-events:none;opacity:0;margin-bottom:.4615em;padding:.3077em .6154em;font-size:.8125em;transition:opacity .1s;position:absolute;bottom:100%;left:50%;transform:translate(-50%)}[part~=button][aria-label]:focus:after{opacity:1;transition-delay:.4s}[part~=button][aria-label]:focus:not(:focus-visible):after{opacity:0;transition-delay:0s}@media (hover:hover){[part~=button][aria-label]:hover:after{opacity:1;transition-delay:.4s}}:host(:last-child) [part~=button][aria-label]:after{left:auto;right:0;transform:none}[part~=button]:hover{opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline:none}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}slot[hidden]{display:none}";
11
+ const SLIDER_STYLE_CSS = ":host{display:block}:host([hidden]){display:none}[part~=slider]{border-radius:var(--mbx-radius);cursor:pointer;touch-action:none;height:2.5em;position:relative}[part~=slider]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=slider]:focus:not(:focus-visible){outline:none}[part~=rail]{position:absolute;top:0;bottom:0;left:.5em;right:.5em}[part~=track]{background:#ffffff59;border-radius:2px;height:.25em;position:absolute;top:50%;left:0;right:0;overflow:hidden;transform:translateY(-50%)}[part~=fill]{background:var(--mbx-accent);position:absolute;top:0;bottom:0;left:0}[part~=thumb]{background:var(--mbx-text);pointer-events:none;border-radius:50%;width:.75em;height:.75em;margin:-.375em 0 0 -.375em;position:absolute;top:50%}";
12
12
  const BUTTON_STYLE = BUTTON_STYLE_CSS;
13
13
  /** The style of a slider: the rail, the track with its fill, and the thumb. */
14
14
  const SLIDER_STYLE = SLIDER_STYLE_CSS;
@@ -19,7 +19,7 @@ function number(node, name, fallback) {
19
19
  return Number.isFinite(value) && value >= 0 ? value : fallback;
20
20
  }
21
21
  /** The style of a menu: the button from BUTTON_STYLE, and the popup above it with its items. */
22
- const MENU_STYLE = ":host{display:inline-flex}:host([hidden]){display:none}[part~=button]{width:40px;height:40px;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}[part~=button]:hover{opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline:none}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}slot[hidden]{display:none}:host{position:relative}[part~=popup]{box-sizing:border-box;overscroll-behavior:contain;border-radius:var(--mbx-radius);background:#101114f2;flex-direction:column;min-width:160px;margin-bottom:8px;padding:6px;font-size:14px;display:flex;position:absolute;bottom:100%;right:0;overflow-y:auto;box-shadow:0 4px 16px #00000080}[part~=popup][hidden]{display:none}[part~=popup][more]{-webkit-mask-image:linear-gradient(#000 calc(100% - 24px),#0000);mask-image:linear-gradient(#000 calc(100% - 24px),#0000)}[part~=section]{flex-direction:column;display:flex}[part~=section]+[part~=section]{border-top:1px solid #ffffff1f;margin-top:6px;padding-top:6px}[part~=section-label]{letter-spacing:.06em;text-transform:uppercase;color:var(--mbx-muted);padding:4px 12px 2px;font-size:11px;font-weight:600}[part~=item]{width:100%;font:inherit;color:inherit;text-align:left;white-space:nowrap;border-radius:var(--mbx-radius);cursor:pointer;background:0 0;border:0;align-items:center;padding:8px 12px 8px 28px;display:flex}[part~=item]:hover{background:#ffffff1f}[part~=item-text]{text-overflow:ellipsis;min-width:0;overflow:hidden}[part~=item-image]{object-fit:cover;background:#ffffff14;border-radius:2px;flex:none;width:64px;height:36px;margin-right:12px}[part~=item-badge]{border:1px solid;border-radius:2px;flex:none;margin-left:8px;padding:0 4px;font-size:.75em;font-weight:600;line-height:1.5}[part~=item-detail]{color:var(--mbx-muted);font-variant-numeric:tabular-nums;margin-left:auto;padding-left:12px}[part~=item]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=item]:focus:not(:focus-visible){outline:none}[part~=page-item]{padding-right:28px;position:relative}[part~=page-item]:after{content:\"\";opacity:.7;border:1.5px solid;border-width:1.5px 1.5px 0 0;width:7px;height:7px;margin-top:-4px;position:absolute;top:50%;right:12px;transform:rotate(45deg)}[part~=back-item]{border-bottom:1px solid #ffffff1f;border-radius:0;margin-bottom:6px;font-weight:600;position:relative}[part~=back-item]:before{content:\"\";opacity:.7;border:0 solid;border-width:1.5px 0 0 1.5px;width:7px;height:7px;margin-top:-4px;position:absolute;top:50%;left:12px;transform:rotate(-45deg)}[part~=checked]{position:relative}[part~=checked]:before{content:\"\";background:var(--mbx-accent);border-radius:50%;width:6px;height:6px;margin-top:-3px;position:absolute;top:50%;left:12px}";
22
+ const MENU_STYLE = ":host{display:inline-flex}:host([hidden]){display:none}[part~=button]{width:2.5em;height:2.5em;font:inherit;color:inherit;border-radius:var(--mbx-radius);cursor:pointer;opacity:.9;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex;position:relative}[part~=button][aria-label]:after{content:attr(aria-label);display:var(--mbx-tooltip,block);background:var(--mbx-surface);border-radius:var(--mbx-radius);white-space:nowrap;pointer-events:none;opacity:0;margin-bottom:.4615em;padding:.3077em .6154em;font-size:.8125em;transition:opacity .1s;position:absolute;bottom:100%;left:50%;transform:translate(-50%)}[part~=button][aria-label]:focus:after{opacity:1;transition-delay:.4s}[part~=button][aria-label]:focus:not(:focus-visible):after{opacity:0;transition-delay:0s}@media (hover:hover){[part~=button][aria-label]:hover:after{opacity:1;transition-delay:.4s}}:host(:last-child) [part~=button][aria-label]:after{left:auto;right:0;transform:none}[part~=button]:hover{opacity:1}[part~=button]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=button]:focus:not(:focus-visible){outline:none}[part~=icon],::slotted(*){fill:currentColor;width:1.75em;height:1.75em}slot[hidden]{display:none}:host{position:relative}[part~=popup]{box-sizing:border-box;overscroll-behavior:contain;border-radius:var(--mbx-radius);background:#1c1c20f2;flex-direction:column;min-width:16em;margin-bottom:.5714em;padding:.4286em;font-size:.875em;display:flex;position:absolute;bottom:100%;right:0;overflow-y:auto;box-shadow:0 4px 16px #00000080}[part~=popup][hidden]{display:none}[part~=section]{flex-direction:column;display:flex}[part~=section]+[part~=section]{border-top:1px solid #ffffff1f;margin-top:.4286em;padding-top:.4286em}[part~=section-label]{letter-spacing:.06em;text-transform:uppercase;color:var(--mbx-muted);padding:.3636em 1.0909em .1818em;font-size:.7857em;font-weight:600}[part~=glyph-item]{padding-left:1em}[part~=glyph-item]>svg{margin-right:.75em}[part~=item]{width:100%;font:inherit;color:inherit;text-align:left;white-space:nowrap;border-radius:var(--mbx-radius);cursor:pointer;background:0 0;border:0;align-items:center;padding:.7857em 1em .7857em 2.2857em;display:flex}[part~=item]:hover{background:#ffffff1f}[part~=item-text]{white-space:normal;-webkit-line-clamp:2;-webkit-box-orient:vertical;min-width:0;max-width:16em;display:-webkit-box;overflow:hidden}[part~=item-image]{object-fit:cover;background:#ffffff14;border-radius:2px;flex:none;width:4.5714em;height:2.5714em;margin-right:.8571em}[part~=item-badge]{border:1px solid;border-radius:2px;flex:none;margin-left:auto;padding:0 .381em;font-size:.75em;font-weight:600;line-height:1.5}[part~=item-glyph]{border:0;padding:0;font-size:1em;display:inline-flex}[part~=item-glyph] svg,[part~=glyph-item]>svg{fill:currentColor;flex:none;width:1.5em;height:1.5em}[part~=badge-text]{clip:rect(0 0 0 0);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}[part~=item-detail]{color:var(--mbx-muted);font-variant-numeric:tabular-nums;margin-left:auto;padding-left:.8571em}[part~=item-badge]~[part~=item-badge],[part~=item-badge]~[part~=item-detail]{margin-left:.7619em}[part~=item]:focus{outline:2px solid var(--mbx-accent);outline-offset:-2px}[part~=item]:focus:not(:focus-visible){outline:none}[part~=page-item]{padding-right:2em;position:relative}[part~=page-item]:after{content:\"\";opacity:.7;border:1.5px solid;border-width:1.5px 1.5px 0 0;width:.5em;height:.5em;margin-top:-.2857em;position:absolute;top:50%;right:.8571em;transform:rotate(45deg)}[part~=title],[part~=back-item]{letter-spacing:.06em;text-transform:uppercase;color:var(--mbx-muted);font-size:.8125em;font-weight:600}[part~=title]{border-bottom:1px solid #ffffff1f;margin:-.5275em -.5275em .5275em;padding:.9231em 1.4066em}[part~=back-item]{border-bottom:1px solid #ffffff1f;border-radius:0;margin-bottom:.5275em;padding:.9231em 1.2308em .9231em 2.4615em;position:relative}[part~=back-item]:before{content:\"\";opacity:.7;border:0 solid;border-width:1.5px 0 0 1.5px;width:.5em;height:.5em;margin-top:-.2857em;position:absolute;top:50%;left:1em;transform:rotate(-45deg)}[part~=checked]{background:#ffffff14;position:relative}[part~=checked]:before{content:\"\";background:var(--mbx-accent);border-radius:50%;width:.4286em;height:.4286em;margin-top:-.2143em;position:absolute;top:50%;left:1em}:host([layout=compact]) [part~=popup]{z-index:1000;padding-bottom:calc(.4286em + env(safe-area-inset-bottom,0px));box-shadow:none;background:#1c1c20;border-radius:.75em .75em 0 0;margin:0;font-size:1em;right:auto}[part~=backdrop]{z-index:999;background:#00000080;position:absolute}[part~=backdrop][hidden]{display:none}";
23
23
  /** Puts a control in the bar's seek row when it is in a bar, unless the page wrote a `slot` of its own. */
24
24
  function seekRow(node) {
25
25
  if (node.parentElement?.localName === "mbx-control-bar" && !node.hasAttribute("slot")) node.slot = "seek";
@@ -5,10 +5,10 @@ import { BUTTON_STYLE, style } from "./shared.js";
5
5
  import { fill } from "../labels.js";
6
6
  //#region src/elements/skip-button.ts
7
7
  const SECONDS = 10;
8
- /** The glyph for a skip amount: the set draws 10 and 30, and a plain arrow says the rest. */
8
+ /** The glyph for a skip amount: the set draws 5, 10, 15 and 30, and a plain arrow says the rest. */
9
9
  function glyphFor(back, amount) {
10
10
  const side = back ? "seek-backward" : "seek-forward";
11
- if (amount === 10 || amount === 30) return `${side}-${amount}`;
11
+ if (amount === 5 || amount === 10 || amount === 15 || amount === 30) return `${side}-${amount}`;
12
12
  return side;
13
13
  }
14
14
  var MbxSkipButton = class extends Component {
@@ -1 +1 @@
1
- {"version":3,"file":"skip-button.js","names":[],"sources":["../../src/elements/skip-button.ts"],"sourcesContent":["/**\n * <mbx-skip-button>: moves the playhead by `seconds`, negative for back,\n * within what the video can reach. The glyph says the amount where the\n * set has one, 10 and 30, and a plain arrow otherwise; `icon` takes a\n * page's own. The name comes from `label`, where `{seconds}` is the\n * amount without its sign: \"Back {seconds} seconds\".\n */\nimport type { IconName } from '../controls/icons.js';\nimport { icon } from '../controls/icons.js';\nimport { setChildren } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { fill } from '../labels.js';\nimport { Component } from './component.js';\nimport { BUTTON_STYLE, style } from './shared.js';\n\nconst SECONDS = 10;\n\n/** The glyph for a skip amount: the set draws 10 and 30, and a plain arrow says the rest. */\nfunction glyphFor(back: boolean, amount: number): IconName {\n const side = back ? 'seek-backward' : 'seek-forward';\n if (amount === 10 || amount === 30) return `${side}-${amount}`;\n return side;\n}\n\nexport class MbxSkipButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['seconds', 'label'];\n }\n\n declare private readonly button: HTMLButtonElement;\n declare private readonly glyph: HTMLSlotElement;\n\n constructor() {\n super();\n const root = this.attachShadow({ mode: 'open' });\n this.button = document.createElement('button');\n this.button.type = 'button';\n this.button.setAttribute('part', 'button');\n this.glyph = document.createElement('slot');\n this.glyph.name = 'icon';\n this.button.append(this.glyph);\n this.button.addEventListener('click', () => {\n this.skip();\n });\n root.append(style(BUTTON_STYLE), this.button);\n }\n\n /** The amount, signed. A value that is not a number is the default. */\n private seconds(): number {\n const value = Number(this.getAttribute('seconds') ?? SECONDS);\n return Number.isFinite(value) ? value : SECONDS;\n }\n\n private skip(): void {\n const video = this.player?.video;\n if (video === undefined) return;\n const ranges = video.seekable;\n const end = Number.isFinite(video.duration)\n ? video.duration\n : ranges.length > 0\n ? ranges.end(ranges.length - 1)\n : video.currentTime;\n video.currentTime = Math.min(end, Math.max(0, video.currentTime + this.seconds()));\n }\n\n protected override attach(_player: PlayerHost): void {\n this.render();\n }\n\n protected override render(): void {\n const seconds = this.seconds();\n const back = seconds < 0;\n const amount = Math.abs(seconds);\n setChildren(this.glyph, icon(glyphFor(back, amount)));\n const template =\n this.getAttribute('label') ?? (back ? 'Back {seconds} seconds' : 'Forward {seconds} seconds');\n this.button.setAttribute('aria-label', fill(template, { seconds: amount }));\n }\n}\n"],"mappings":";;;;;;AAeA,MAAM,UAAU;;AAGhB,SAAS,SAAS,MAAe,QAA0B;CACzD,MAAM,OAAO,OAAO,kBAAkB;CACtC,IAAI,WAAW,MAAM,WAAW,IAAI,OAAO,GAAG,KAAK,GAAG;CACtD,OAAO;AACT;AAEA,IAAa,gBAAb,cAAmC,UAAU;CAC3C,WAAW,qBAAwC;EACjD,OAAO,CAAC,WAAW,OAAO;CAC5B;CAKA,cA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.ts"],"sourcesContent":["/**\n * <mbx-skip-button>: moves the playhead by `seconds`, negative for back,\n * within what the video can reach. The glyph says the amount where the\n * set has one, 5, 10, 15 and 30, and a plain arrow otherwise; `icon` takes a\n * page's own. The name comes from `label`, where `{seconds}` is the\n * amount without its sign: \"Back {seconds} seconds\".\n */\nimport type { IconName } from '../controls/icons.js';\nimport { icon } from '../controls/icons.js';\nimport { setChildren } from '../dom.js';\nimport type { PlayerHost } from '../host.js';\nimport { fill } from '../labels.js';\nimport { Component } from './component.js';\nimport { BUTTON_STYLE, style } from './shared.js';\n\nconst SECONDS = 10;\n\n/** The glyph for a skip amount: the set draws 5, 10, 15 and 30, and a plain arrow says the rest. */\nfunction glyphFor(back: boolean, amount: number): IconName {\n const side = back ? 'seek-backward' : 'seek-forward';\n if (amount === 5 || amount === 10 || amount === 15 || amount === 30) return `${side}-${amount}`;\n return side;\n}\n\nexport class MbxSkipButton extends Component {\n static get observedAttributes(): readonly string[] {\n return ['seconds', 'label'];\n }\n\n declare private readonly button: HTMLButtonElement;\n declare private readonly glyph: HTMLSlotElement;\n\n constructor() {\n super();\n const root = this.attachShadow({ mode: 'open' });\n this.button = document.createElement('button');\n this.button.type = 'button';\n this.button.setAttribute('part', 'button');\n this.glyph = document.createElement('slot');\n this.glyph.name = 'icon';\n this.button.append(this.glyph);\n this.button.addEventListener('click', () => {\n this.skip();\n });\n root.append(style(BUTTON_STYLE), this.button);\n }\n\n /** The amount, signed. A value that is not a number is the default. */\n private seconds(): number {\n const value = Number(this.getAttribute('seconds') ?? SECONDS);\n return Number.isFinite(value) ? value : SECONDS;\n }\n\n private skip(): void {\n const video = this.player?.video;\n if (video === undefined) return;\n const ranges = video.seekable;\n const end = Number.isFinite(video.duration)\n ? video.duration\n : ranges.length > 0\n ? ranges.end(ranges.length - 1)\n : video.currentTime;\n video.currentTime = Math.min(end, Math.max(0, video.currentTime + this.seconds()));\n }\n\n protected override attach(_player: PlayerHost): void {\n this.render();\n }\n\n protected override render(): void {\n const seconds = this.seconds();\n const back = seconds < 0;\n const amount = Math.abs(seconds);\n setChildren(this.glyph, icon(glyphFor(back, amount)));\n const template =\n this.getAttribute('label') ?? (back ? 'Back {seconds} seconds' : 'Forward {seconds} seconds');\n this.button.setAttribute('aria-label', fill(template, { seconds: amount }));\n }\n}\n"],"mappings":";;;;;;AAeA,MAAM,UAAU;;AAGhB,SAAS,SAAS,MAAe,QAA0B;CACzD,MAAM,OAAO,OAAO,kBAAkB;CACtC,IAAI,WAAW,KAAK,WAAW,MAAM,WAAW,MAAM,WAAW,IAAI,OAAO,GAAG,KAAK,GAAG;CACvF,OAAO;AACT;AAEA,IAAa,gBAAb,cAAmC,UAAU;CAC3C,WAAW,qBAAwC;EACjD,OAAO,CAAC,WAAW,OAAO;CAC5B;CAKA,cAAc;EACZ,MAAM;EACN,MAAM,OAAO,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;EAC/C,KAAK,SAAS,SAAS,cAAc,QAAQ;EAC7C,KAAK,OAAO,OAAO;EACnB,KAAK,OAAO,aAAa,QAAQ,QAAQ;EACzC,KAAK,QAAQ,SAAS,cAAc,MAAM;EAC1C,KAAK,MAAM,OAAO;EAClB,KAAK,OAAO,OAAO,KAAK,KAAK;EAC7B,KAAK,OAAO,iBAAiB,eAAe;GAC1C,KAAK,KAAK;EACZ,CAAC;EACD,KAAK,OAAO,MAAM,YAAY,GAAG,KAAK,MAAM;CAC9C;;CAGA,UAA0B;EACxB,MAAM,QAAQ,OAAO,KAAK,aAAa,SAAS,KAAK,OAAO;EAC5D,OAAO,OAAO,SAAS,KAAK,IAAI,QAAQ;CAC1C;CAEA,OAAqB;EACnB,MAAM,QAAQ,KAAK,QAAQ;EAC3B,IAAI,UAAU,KAAA,GAAW;EACzB,MAAM,SAAS,MAAM;EACrB,MAAM,MAAM,OAAO,SAAS,MAAM,QAAQ,IACtC,MAAM,WACN,OAAO,SAAS,IACd,OAAO,IAAI,OAAO,SAAS,CAAC,IAC5B,MAAM;EACZ,MAAM,cAAc,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,MAAM,cAAc,KAAK,QAAQ,CAAC,CAAC;CACnF;CAEA,OAA0B,SAA2B;EACnD,KAAK,OAAO;CACd;CAEA,SAAkC;EAChC,MAAM,UAAU,KAAK,QAAQ;EAC7B,MAAM,OAAO,UAAU;EACvB,MAAM,SAAS,KAAK,IAAI,OAAO;EAC/B,YAAY,KAAK,OAAO,KAAK,SAAS,MAAM,MAAM,CAAC,CAAC;EACpD,MAAM,WACJ,KAAK,aAAa,OAAO,MAAM,OAAO,2BAA2B;EACnE,KAAK,OAAO,aAAa,cAAc,KAAK,UAAU,EAAE,SAAS,OAAO,CAAC,CAAC;CAC5E;AACF"}
@@ -1,7 +1,7 @@
1
1
  import { Component } from "./component.js";
2
2
  import { style } from "./shared.js";
3
3
  //#region src/elements/spinner.ts
4
- const STYLE = ":host{pointer-events:none;width:44px;height:44px;color:var(--mbx-text);filter:drop-shadow(0 1px 3px #00000080);margin:-22px 0 0 -22px;display:none;position:absolute;top:50%;left:50%}:host([waiting]){display:block}:host([hidden]){display:none}[part~=ring]{box-sizing:border-box;border:3px solid #ffffff38;border-top-color:currentColor;border-radius:50%;width:100%;height:100%;animation:.8s linear infinite mbx-turn}[part~=ring][hidden],slot[hidden]{display:none}::slotted(*){width:100%;height:100%}@keyframes mbx-turn{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){[part~=ring]{animation:none}}";
4
+ const STYLE = ":host{pointer-events:none;width:2.75em;height:2.75em;color:var(--mbx-text);filter:drop-shadow(0 1px 3px #00000080);margin:-1.375em 0 0 -1.375em;display:none;position:absolute;top:50%;left:50%}:host([waiting]){display:block}:host([hidden]){display:none}[part~=ring]{box-sizing:border-box;border:3px solid #ffffff38;border-top-color:currentColor;border-radius:50%;width:100%;height:100%;animation:.8s linear infinite mbx-turn}[part~=ring][hidden],slot[hidden]{display:none}::slotted(*){width:100%;height:100%}@keyframes mbx-turn{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){[part~=ring]{animation:none}}";
5
5
  /** What the video fires as it waits and as it goes on. */
6
6
  const EVENTS = [
7
7
  "waiting",