@hopeplayer/core 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/dist/HopePlayerElement.d.ts +42 -2
  2. package/dist/HopePlayerElement.d.ts.map +1 -1
  3. package/dist/chunks/NativeEme-CXosVcw8.js +80 -0
  4. package/dist/chunks/NativeEme-CXosVcw8.js.map +1 -0
  5. package/dist/chunks/{accessibility-DeUIoAda.js → accessibility-DFx4CE0H.js} +9 -8
  6. package/dist/chunks/{accessibility-DeUIoAda.js.map → accessibility-DFx4CE0H.js.map} +1 -1
  7. package/dist/chunks/adTriggers-BIAWe8o4.js +419 -0
  8. package/dist/chunks/adTriggers-BIAWe8o4.js.map +1 -0
  9. package/dist/chunks/{ads-CdWbE9aD.js → ads-DlpHPpR9.js} +3 -3
  10. package/dist/chunks/ads-DlpHPpR9.js.map +1 -0
  11. package/dist/chunks/analytics-DEjTAJO9.js +281 -0
  12. package/dist/chunks/analytics-DEjTAJO9.js.map +1 -0
  13. package/dist/chunks/{cast-BQ-suTcF.js → cast-vHyi7oV_.js} +2 -2
  14. package/dist/chunks/{cast-BQ-suTcF.js.map → cast-vHyi7oV_.js.map} +1 -1
  15. package/dist/chunks/dash-CWjy-y7B.js +22 -0
  16. package/dist/chunks/dash-CWjy-y7B.js.map +1 -0
  17. package/dist/chunks/docPip-wybMVP1H.js +82 -0
  18. package/dist/chunks/docPip-wybMVP1H.js.map +1 -0
  19. package/dist/chunks/heatmap-Bb7neaYU.js +92 -0
  20. package/dist/chunks/heatmap-Bb7neaYU.js.map +1 -0
  21. package/dist/chunks/{history-DAbqEhNB.js → history-CwqLXiZi.js} +2 -2
  22. package/dist/chunks/{history-DAbqEhNB.js.map → history-CwqLXiZi.js.map} +1 -1
  23. package/dist/chunks/interactive-CgltIneu.js +189 -0
  24. package/dist/chunks/interactive-CgltIneu.js.map +1 -0
  25. package/dist/chunks/keySystems-CNzjRq6e.js +70 -0
  26. package/dist/chunks/keySystems-CNzjRq6e.js.map +1 -0
  27. package/dist/chunks/{loopSection-CvF4l5uf.js → loopSection-Bwk4W8vz.js} +16 -16
  28. package/dist/chunks/loopSection-Bwk4W8vz.js.map +1 -0
  29. package/dist/chunks/{markers-B04NMI79.js → markers-L69W3kj6.js} +53 -51
  30. package/dist/chunks/markers-L69W3kj6.js.map +1 -0
  31. package/dist/chunks/player-D2_HRzot.js +4351 -0
  32. package/dist/chunks/player-D2_HRzot.js.map +1 -0
  33. package/dist/chunks/{playlist-C6Mh9BE8.js → playlist-CHfStNbQ.js} +29 -21
  34. package/dist/chunks/playlist-CHfStNbQ.js.map +1 -0
  35. package/dist/chunks/plugin-style-CPJELe-i.js +17 -0
  36. package/dist/chunks/plugin-style-CPJELe-i.js.map +1 -0
  37. package/dist/chunks/pluginHost-cN2uGFeG.js +566 -0
  38. package/dist/chunks/pluginHost-cN2uGFeG.js.map +1 -0
  39. package/dist/chunks/redirectScreen-TIqLdvBY.js +239 -0
  40. package/dist/chunks/redirectScreen-TIqLdvBY.js.map +1 -0
  41. package/dist/chunks/{rewardedUnlock-CGhQyWOk.js → rewardedUnlock-DUqYwXTr.js} +2 -2
  42. package/dist/chunks/{rewardedUnlock-CGhQyWOk.js.map → rewardedUnlock-DUqYwXTr.js.map} +1 -1
  43. package/dist/chunks/segments-Ds-c1b5e.js +66 -0
  44. package/dist/chunks/segments-Ds-c1b5e.js.map +1 -0
  45. package/dist/chunks/{skipSegments-BbWzPpXz.js → skipSegments-ByNoF1qZ.js} +2 -2
  46. package/dist/chunks/{skipSegments-BbWzPpXz.js.map → skipSegments-ByNoF1qZ.js.map} +1 -1
  47. package/dist/chunks/{spriteThumbnails-B7oDZFTo.js → spriteThumbnails-Cr9UmkM9.js} +74 -51
  48. package/dist/chunks/spriteThumbnails-Cr9UmkM9.js.map +1 -0
  49. package/dist/chunks/{statsPanel-DSClIwA3.js → statsPanel-D0DtoFgS.js} +2 -2
  50. package/dist/chunks/statsPanel-D0DtoFgS.js.map +1 -0
  51. package/dist/chunks/{sticky-D_eLCNFk.js → sticky-BDStzjBM.js} +27 -26
  52. package/dist/chunks/sticky-BDStzjBM.js.map +1 -0
  53. package/dist/chunks/{story-BLBij82f.js → story-CodA2dfn.js} +2 -2
  54. package/dist/chunks/{story-BLBij82f.js.map → story-CodA2dfn.js.map} +1 -1
  55. package/dist/chunks/transcript-LG7E9UYE.js +186 -0
  56. package/dist/chunks/transcript-LG7E9UYE.js.map +1 -0
  57. package/dist/controls/ContextMenu.d.ts +1 -0
  58. package/dist/controls/ContextMenu.d.ts.map +1 -1
  59. package/dist/controls/ControlBar.d.ts +6 -0
  60. package/dist/controls/ControlBar.d.ts.map +1 -1
  61. package/dist/controls/SeekBar.d.ts +5 -2
  62. package/dist/controls/SeekBar.d.ts.map +1 -1
  63. package/dist/controls/SettingsMenu.d.ts +2 -1
  64. package/dist/controls/SettingsMenu.d.ts.map +1 -1
  65. package/dist/drm/NativeEme.d.ts +23 -0
  66. package/dist/drm/NativeEme.d.ts.map +1 -0
  67. package/dist/drm/keySystems.d.ts +18 -0
  68. package/dist/drm/keySystems.d.ts.map +1 -0
  69. package/dist/hls/SourceManager.d.ts +31 -5
  70. package/dist/hls/SourceManager.d.ts.map +1 -1
  71. package/dist/hls/dashEngine.d.ts +85 -0
  72. package/dist/hls/dashEngine.d.ts.map +1 -0
  73. package/dist/hls/sourceGroups.d.ts.map +1 -1
  74. package/dist/hope-player.js +1 -1
  75. package/dist/i18n/locales/en.d.ts.map +1 -1
  76. package/dist/i18n/locales/tr.d.ts.map +1 -1
  77. package/dist/i18n/types.d.ts +28 -0
  78. package/dist/i18n/types.d.ts.map +1 -1
  79. package/dist/index.d.ts +2 -2
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/keyboard/KeyboardController.d.ts +14 -0
  82. package/dist/keyboard/KeyboardController.d.ts.map +1 -1
  83. package/dist/plugin-api/PluginAds.d.ts +61 -0
  84. package/dist/plugin-api/PluginAds.d.ts.map +1 -0
  85. package/dist/plugin-api/PluginHost.d.ts +6 -0
  86. package/dist/plugin-api/PluginHost.d.ts.map +1 -1
  87. package/dist/plugin-api/types.d.ts +39 -0
  88. package/dist/plugin-api/types.d.ts.map +1 -1
  89. package/dist/plugins/accessibility/Accessibility.d.ts.map +1 -1
  90. package/dist/plugins/ad-triggers/AdTriggers.d.ts +5 -0
  91. package/dist/plugins/ad-triggers/AdTriggers.d.ts.map +1 -1
  92. package/dist/plugins/ads/AdsController.d.ts +2 -0
  93. package/dist/plugins/ads/AdsController.d.ts.map +1 -1
  94. package/dist/plugins/analytics/QoeTracker.d.ts +71 -0
  95. package/dist/plugins/analytics/QoeTracker.d.ts.map +1 -0
  96. package/dist/plugins/analytics/index.d.ts +6 -0
  97. package/dist/plugins/analytics/index.d.ts.map +1 -0
  98. package/dist/plugins/doc-pip/DocumentPip.d.ts +44 -0
  99. package/dist/plugins/doc-pip/DocumentPip.d.ts.map +1 -0
  100. package/dist/plugins/doc-pip/index.d.ts +5 -0
  101. package/dist/plugins/doc-pip/index.d.ts.map +1 -0
  102. package/dist/plugins/heatmap/Heatmap.d.ts +36 -0
  103. package/dist/plugins/heatmap/Heatmap.d.ts.map +1 -0
  104. package/dist/plugins/heatmap/index.d.ts +6 -0
  105. package/dist/plugins/heatmap/index.d.ts.map +1 -0
  106. package/dist/plugins/interactive/Interactive.d.ts +45 -0
  107. package/dist/plugins/interactive/Interactive.d.ts.map +1 -0
  108. package/dist/plugins/interactive/index.d.ts +6 -0
  109. package/dist/plugins/interactive/index.d.ts.map +1 -0
  110. package/dist/plugins/markers/MarkProgress.d.ts +3 -1
  111. package/dist/plugins/markers/MarkProgress.d.ts.map +1 -1
  112. package/dist/plugins/playlist/PlaylistRunner.d.ts +2 -0
  113. package/dist/plugins/playlist/PlaylistRunner.d.ts.map +1 -1
  114. package/dist/plugins/redirect-screen/RedirectScreen.d.ts +3 -1
  115. package/dist/plugins/redirect-screen/RedirectScreen.d.ts.map +1 -1
  116. package/dist/plugins/segments/Segments.d.ts +1 -0
  117. package/dist/plugins/segments/Segments.d.ts.map +1 -1
  118. package/dist/plugins/sprite-thumbnails/SpriteThumbnails.d.ts +9 -0
  119. package/dist/plugins/sprite-thumbnails/SpriteThumbnails.d.ts.map +1 -1
  120. package/dist/plugins/sticky/StickyManager.d.ts +2 -0
  121. package/dist/plugins/sticky/StickyManager.d.ts.map +1 -1
  122. package/dist/plugins/transcript/Transcript.d.ts +65 -0
  123. package/dist/plugins/transcript/Transcript.d.ts.map +1 -0
  124. package/dist/plugins/transcript/index.d.ts +6 -0
  125. package/dist/plugins/transcript/index.d.ts.map +1 -0
  126. package/dist/screens/ErrorScreen.d.ts +1 -1
  127. package/dist/screens/ErrorScreen.d.ts.map +1 -1
  128. package/dist/subtitles/attachTracks.d.ts +6 -0
  129. package/dist/subtitles/attachTracks.d.ts.map +1 -1
  130. package/dist/types/index.d.ts +320 -16
  131. package/dist/types/index.d.ts.map +1 -1
  132. package/dist/utils/plugin-style.d.ts +5 -0
  133. package/dist/utils/plugin-style.d.ts.map +1 -0
  134. package/package.json +2 -1
  135. package/dist/chunks/adTriggers-DXmtF4t2.js +0 -410
  136. package/dist/chunks/adTriggers-DXmtF4t2.js.map +0 -1
  137. package/dist/chunks/ads-CdWbE9aD.js.map +0 -1
  138. package/dist/chunks/loopSection-CvF4l5uf.js.map +0 -1
  139. package/dist/chunks/markers-B04NMI79.js.map +0 -1
  140. package/dist/chunks/player-D7WQxMzr.js +0 -3894
  141. package/dist/chunks/player-D7WQxMzr.js.map +0 -1
  142. package/dist/chunks/playlist-C6Mh9BE8.js.map +0 -1
  143. package/dist/chunks/pluginHost-DjvLmMYZ.js +0 -376
  144. package/dist/chunks/pluginHost-DjvLmMYZ.js.map +0 -1
  145. package/dist/chunks/redirectScreen-5HAVRtxe.js +0 -208
  146. package/dist/chunks/redirectScreen-5HAVRtxe.js.map +0 -1
  147. package/dist/chunks/segments-gCPrWRig.js +0 -63
  148. package/dist/chunks/segments-gCPrWRig.js.map +0 -1
  149. package/dist/chunks/spriteThumbnails-B7oDZFTo.js.map +0 -1
  150. package/dist/chunks/statsPanel-DSClIwA3.js.map +0 -1
  151. package/dist/chunks/sticky-D_eLCNFk.js.map +0 -1
@@ -0,0 +1,566 @@
1
+ var k = Object.defineProperty;
2
+ var A = (d, e, t) => e in d ? k(d, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[e] = t;
3
+ var c = (d, e, t) => A(d, typeof e != "symbol" ? e + "" : e, t);
4
+ import { P as b, c as S } from "./player-D2_HRzot.js";
5
+ const w = 6e4, x = 15e3, $ = 300, C = /* @__PURE__ */ new Set([" ", "k", "j", "l", "ArrowLeft", "ArrowRight", ",", "."]);
6
+ class K {
7
+ constructor(e) {
8
+ c(this, "active", null);
9
+ c(this, "prerolls", []);
10
+ c(this, "mids", []);
11
+ c(this, "pauses", []);
12
+ c(this, "endeds", []);
13
+ c(this, "transforms", []);
14
+ c(this, "prerollDone", !1);
15
+ c(this, "gateRunning", !1);
16
+ c(this, "contentStarted", !1);
17
+ c(this, "lastPos", 0);
18
+ c(this, "seekPending", !1);
19
+ c(this, "pauseTimer", null);
20
+ c(this, "pauseCleanups", []);
21
+ // ── Olaylar ──
22
+ c(this, "onLoadStart", () => {
23
+ this.prerollDone = !1, this.contentStarted = !1, this.lastPos = 0;
24
+ for (const e of this.mids) e.fired.clear();
25
+ this.clearPause();
26
+ });
27
+ c(this, "onPlay", () => {
28
+ const e = this.ctx.video;
29
+ if (this.active || this.gateRunning) {
30
+ e.pause();
31
+ return;
32
+ }
33
+ this.clearPause(), !(this.prerollDone || !this.prerolls.length || this.ctx.isAdPlaying()) && (this.prerollDone = !0, e.pause(), this.runPrerolls());
34
+ });
35
+ c(this, "onPlaying", () => {
36
+ !this.active && !this.ctx.isAdPlaying() && (this.contentStarted = !0);
37
+ });
38
+ c(this, "onSeeking", () => {
39
+ this.seekPending = !0;
40
+ });
41
+ c(this, "onTimeUpdate", () => {
42
+ const e = this.ctx.video, t = e.currentTime, s = this.lastPos;
43
+ this.lastPos = t;
44
+ const n = this.seekPending;
45
+ if (this.seekPending = !1, !(this.active || this.ctx.isAdPlaying() || e.paused || e.seeking || t <= s))
46
+ for (const r of this.mids) {
47
+ const o = r.marks.filter((u) => s < u && u <= t && !r.fired.has(u));
48
+ if (o.length) {
49
+ for (const u of o) r.fired.add(u);
50
+ n && r.seekPast === "skip" || r.fire(o[o.length - 1]);
51
+ }
52
+ }
53
+ });
54
+ c(this, "onPause", () => {
55
+ const e = this.ctx.video;
56
+ if (!this.pauses.length || e.ended || e.seeking || this.active || this.gateRunning || this.ctx.isAdPlaying()) return;
57
+ this.clearPause();
58
+ const t = Math.min(...this.pauses.map((s) => s.delayMs));
59
+ this.pauseTimer = setTimeout(() => {
60
+ if (this.pauseTimer = null, !(!e.paused || e.ended || this.active || this.ctx.isAdPlaying()))
61
+ for (const s of this.pauses)
62
+ try {
63
+ const n = s.run();
64
+ typeof n == "function" && this.pauseCleanups.push(n);
65
+ } catch (n) {
66
+ this.ctx.log(`Plugin "${s.owner}" failed in ads.onPause: ${(n == null ? void 0 : n.message) ?? n}`, { plugin: s.owner });
67
+ }
68
+ }, t);
69
+ });
70
+ c(this, "onEnded", () => {
71
+ this.clearPause();
72
+ for (const e of this.endeds) e.run();
73
+ });
74
+ c(this, "onKeyDown", (e) => {
75
+ (this.active || this.gateRunning) && C.has(e.key) && e.preventDefault();
76
+ });
77
+ this.ctx = e;
78
+ const t = e.video;
79
+ t.addEventListener("loadstart", this.onLoadStart), t.addEventListener("play", this.onPlay, !0), t.addEventListener("playing", this.onPlaying), t.addEventListener("timeupdate", this.onTimeUpdate), t.addEventListener("seeking", this.onSeeking), t.addEventListener("pause", this.onPause), t.addEventListener("ended", this.onEnded, !0), e.element.addEventListener("keydown", this.onKeyDown, !0);
80
+ }
81
+ destroy() {
82
+ var t;
83
+ const e = this.ctx.video;
84
+ e.removeEventListener("loadstart", this.onLoadStart), e.removeEventListener("play", this.onPlay, !0), e.removeEventListener("playing", this.onPlaying), e.removeEventListener("timeupdate", this.onTimeUpdate), e.removeEventListener("seeking", this.onSeeking), e.removeEventListener("pause", this.onPause), e.removeEventListener("ended", this.onEnded, !0), this.ctx.element.removeEventListener("keydown", this.onKeyDown, !0), (t = this.active) == null || t.finish(), this.clearPause();
85
+ }
86
+ /** Eklenti kaldırılınca onun kayıtları ve süren arası. */
87
+ removeOwner(e) {
88
+ var t;
89
+ this.prerolls = this.prerolls.filter((s) => s.owner !== e), this.mids = this.mids.filter((s) => s.owner !== e), this.pauses = this.pauses.filter((s) => s.owner !== e), this.endeds = this.endeds.filter((s) => s.owner !== e), this.transforms = this.transforms.filter((s) => s.owner !== e), ((t = this.active) == null ? void 0 : t.owner) === e && this.active.finish();
90
+ }
91
+ /** IMA isteği öncesi tüm eklentilerin dönüşümleri. */
92
+ transformTag(e, t) {
93
+ let s = e;
94
+ for (const n of this.transforms)
95
+ try {
96
+ const r = n.fn(s, t);
97
+ typeof r == "string" && r && (s = r);
98
+ } catch (r) {
99
+ this.ctx.log(`Plugin "${n.owner}" failed in ads.transformTag: ${(r == null ? void 0 : r.message) ?? r}`, { plugin: n.owner });
100
+ }
101
+ return s;
102
+ }
103
+ /** Bir eklentiye verilen `ads` nesnesi. */
104
+ api(e, t) {
105
+ const s = (n, r) => (n.push(r), () => {
106
+ const o = n.indexOf(r);
107
+ o >= 0 && n.splice(o, 1);
108
+ });
109
+ return {
110
+ requestBreak: (n, r) => this.requestBreak(e, n, r),
111
+ beforeContent: (n) => s(this.prerolls, { owner: e, run: n }),
112
+ atTime: (n, r, o) => {
113
+ const u = (Array.isArray(n) ? n : [n]).filter((p) => Number.isFinite(p) && p >= 0).sort((p, i) => p - i), g = t((p) => r(p), "ads.atTime");
114
+ return s(this.mids, { owner: e, marks: u, fired: /* @__PURE__ */ new Set(), seekPast: (o == null ? void 0 : o.seekPast) ?? "last", fire: g });
115
+ },
116
+ onPause: (n, r) => s(this.pauses, { owner: e, run: () => n(), delayMs: (r == null ? void 0 : r.delayMs) ?? $ }),
117
+ onEnded: (n) => s(this.endeds, { owner: e, run: t(() => n(), "ads.onEnded") }),
118
+ transformTag: (n) => s(this.transforms, { owner: e, fn: n })
119
+ };
120
+ }
121
+ // ── Reklam arası ──
122
+ requestBreak(e, t, s) {
123
+ if (this.active || this.ctx.isAdPlaying()) return Promise.resolve(!1);
124
+ const n = this.ctx.video, r = (s == null ? void 0 : s.type) ?? (n.ended ? "postroll" : this.contentStarted ? "midroll" : "preroll"), o = !n.paused && !n.ended;
125
+ n.paused || n.pause(), this.ctx.blockAds();
126
+ const u = document.createElement("div");
127
+ u.className = "hp-plugin-layer hp-plugin-ad", u.setAttribute("part", `plugin-ad plugin-${e}`), u.dataset.plugin = e, u.dataset.position = "fill", u.toggleAttribute("data-above", !0), u.toggleAttribute("data-interactive", !0);
128
+ for (const p of ["pointerdown", "mousedown", "mouseup", "touchstart", "touchend", "click", "dblclick"]) u.addEventListener(p, (i) => i.stopPropagation());
129
+ this.ctx.videoArea.appendChild(u);
130
+ const g = new AbortController();
131
+ return this.emit("hp:adstart", r, e), new Promise((p) => {
132
+ let i = !1;
133
+ const a = () => {
134
+ i || (i = !0, clearTimeout(l), g.abort(), u.remove(), this.active = null, this.ctx.unblockAds(), this.emit("hp:adend", r, e), o && r !== "postroll" && n.play().catch(() => {
135
+ }), p(!0));
136
+ }, l = setTimeout(() => {
137
+ this.ctx.log(`Plugin "${e}" ad break timed out`, { plugin: e, type: r }), a();
138
+ }, (s == null ? void 0 : s.timeoutMs) ?? w);
139
+ this.active = { owner: e, finish: a };
140
+ const h = (f) => {
141
+ this.ctx.log(`Plugin "${e}" failed in ads.requestBreak: ${(f == null ? void 0 : f.message) ?? f}`, { plugin: e, type: r }), a();
142
+ };
143
+ try {
144
+ Promise.resolve(t({ type: r, layer: u, signal: g.signal, end: a })).then(a, h);
145
+ } catch (f) {
146
+ h(f);
147
+ }
148
+ });
149
+ }
150
+ emit(e, t, s) {
151
+ this.ctx.element.dispatchEvent(new CustomEvent(e, { detail: { type: t, linear: !0, plugin: s } }));
152
+ }
153
+ async runPrerolls() {
154
+ this.gateRunning = !0;
155
+ const e = Promise.all(
156
+ this.prerolls.map(
157
+ (t) => Promise.resolve().then(() => t.run()).catch((s) => this.ctx.log(`Plugin "${t.owner}" failed in ads.beforeContent: ${(s == null ? void 0 : s.message) ?? s}`, { plugin: t.owner }))
158
+ )
159
+ );
160
+ for (await Promise.race([e, new Promise((t) => setTimeout(t, x))]); this.active; ) await new Promise((t) => setTimeout(t, 100));
161
+ this.gateRunning = !1, this.ctx.video.play().catch(() => {
162
+ });
163
+ }
164
+ clearPause() {
165
+ this.pauseTimer && clearTimeout(this.pauseTimer), this.pauseTimer = null;
166
+ for (const e of this.pauseCleanups.splice(0))
167
+ try {
168
+ e();
169
+ } catch {
170
+ }
171
+ }
172
+ }
173
+ const m = (d) => typeof d == "function" ? d() : d;
174
+ function O(d) {
175
+ const e = d.split("+"), t = (e.pop() || "+").toLowerCase(), s = e.map((r) => r.toLowerCase()), n = /^[a-z]$/.test(t);
176
+ return { key: t, shift: s.includes("shift") ? !0 : n ? !1 : null, alt: s.includes("alt"), ctrl: s.includes("ctrl") || s.includes("control"), meta: s.includes("meta") || s.includes("cmd") };
177
+ }
178
+ function D(d, e) {
179
+ return e.key.toLowerCase() === d.key && e.altKey === d.alt && e.ctrlKey === d.ctrl && e.metaKey === d.meta && (d.shift === null || e.shiftKey === d.shift);
180
+ }
181
+ class B {
182
+ constructor(e) {
183
+ c(this, "instances", /* @__PURE__ */ new Map());
184
+ c(this, "shortcutList", []);
185
+ c(this, "syncSeq", 0);
186
+ c(this, "toastEl", null);
187
+ c(this, "toastTimer", null);
188
+ /** Ayar satırı anahtarları. */
189
+ c(this, "keySeq", 0);
190
+ c(this, "ads");
191
+ c(this, "onKeyDown", (e) => {
192
+ if (e.defaultPrevented) return;
193
+ const t = e.composedPath()[0];
194
+ if (!(t instanceof HTMLElement && (t.isContentEditable || /^(input|textarea|select)$/i.test(t.tagName)))) {
195
+ for (const s of this.shortcutList)
196
+ if (D(s.spec, e)) {
197
+ e.preventDefault(), s.handler(e);
198
+ return;
199
+ }
200
+ }
201
+ });
202
+ this.ctx = e, e.element.addEventListener("keydown", this.onKeyDown), this.ads = new K(e);
203
+ }
204
+ /** IMA tag'i eklenti dönüşümlerinden geçirir. */
205
+ transformAdTag(e, t) {
206
+ return this.ads.transformTag(e, t);
207
+ }
208
+ /** Listeye eşitler: kurar, kaldırır, günceller (aynı adlıda sonraki kazanır). */
209
+ async sync(e, t) {
210
+ const s = ++this.syncSeq, n = await Promise.all([...e, ...t].map((o) => this.resolveEntry(o)));
211
+ if (s !== this.syncSeq) return;
212
+ const r = /* @__PURE__ */ new Map();
213
+ for (const o of n) o && r.set(o.plugin.name, o);
214
+ for (const [o, u] of this.instances) r.has(o) || this.dispose(o, u);
215
+ for (const [o, { plugin: u, options: g }] of r) {
216
+ const p = I(g), i = this.instances.get(o);
217
+ if (i && i.plugin === u) {
218
+ if (i.optionsKey === p) continue;
219
+ if (u.update) {
220
+ i.optionsKey = p, this.guard(o, () => u.update(g))();
221
+ continue;
222
+ }
223
+ }
224
+ i && this.dispose(o, i), await this.install(u, g, p);
225
+ }
226
+ }
227
+ /** Dil değişince. */
228
+ refreshLabels() {
229
+ for (const [e, t] of this.instances) {
230
+ for (const s of t.relabel) this.guard(e, s)();
231
+ for (const s of t.localeHandlers) this.guard(e, () => s(this.ctx.locale()))();
232
+ }
233
+ }
234
+ /** `?` listesi için. */
235
+ shortcuts() {
236
+ return this.shortcutList.filter((e) => e.description !== void 0).map((e) => ({ keys: [e.label], description: m(e.description) }));
237
+ }
238
+ has(e) {
239
+ return this.instances.has(e);
240
+ }
241
+ destroy() {
242
+ var e;
243
+ ++this.syncSeq;
244
+ for (const [t, s] of this.instances) this.dispose(t, s);
245
+ this.ctx.element.removeEventListener("keydown", this.onKeyDown), this.ads.destroy(), (e = this.toastEl) == null || e.remove(), this.toastTimer && clearTimeout(this.toastTimer);
246
+ }
247
+ // ── Kurulum ──
248
+ async resolveEntry(e) {
249
+ const [t, s] = Array.isArray(e) ? e : [e, void 0];
250
+ try {
251
+ if (typeof t == "function") {
252
+ const n = await t(), r = "setup" in n ? n : "default" in n ? n.default : n.plugin;
253
+ return r && typeof r.setup == "function" ? { plugin: r, options: s } : null;
254
+ }
255
+ return t && typeof t.setup == "function" && typeof t.name == "string" ? { plugin: t, options: s } : null;
256
+ } catch (n) {
257
+ return this.ctx.log(`Plugin could not be loaded: ${(n == null ? void 0 : n.message) ?? n}`, { plugin: typeof t == "function" ? "loader" : String(t == null ? void 0 : t.name) }), null;
258
+ }
259
+ }
260
+ async install(e, t, s) {
261
+ const n = e.name;
262
+ e.apiVersion && e.apiVersion > b && this.ctx.log(`Plugin "${n}" was written for plugin API v${e.apiVersion}; this player has v${b}`, { plugin: n });
263
+ const r = { plugin: e, optionsKey: s, api: null, disposers: [], relabel: [], localeHandlers: [], cleanup: null, removed: !1 };
264
+ r.api = this.createApi(r), this.instances.set(n, r);
265
+ try {
266
+ const o = await e.setup(r.api, t);
267
+ if (r.removed) {
268
+ typeof o == "function" && this.guard(n, o)();
269
+ return;
270
+ }
271
+ typeof o == "function" && (r.cleanup = o);
272
+ } catch (o) {
273
+ this.report(n, o, "setup"), this.dispose(n, r);
274
+ }
275
+ }
276
+ dispose(e, t) {
277
+ if (!t.removed) {
278
+ t.removed = !0, this.instances.get(e) === t && this.instances.delete(e), t.cleanup && this.guard(e, t.cleanup)();
279
+ for (const s of t.disposers.reverse())
280
+ try {
281
+ s();
282
+ } catch {
283
+ }
284
+ t.disposers = [], this.ads.removeOwner(e);
285
+ for (let s = this.shortcutList.length - 1; s >= 0; s--) this.shortcutList[s].owner === e && this.shortcutList.splice(s, 1);
286
+ }
287
+ }
288
+ report(e, t, s) {
289
+ const n = (t == null ? void 0 : t.message) ?? String(t);
290
+ this.ctx.log(`Plugin "${e}" failed in ${s}: ${n}`, { plugin: e }), console.error(`[hope-player] plugin "${e}" (${s}):`, t);
291
+ }
292
+ /** Eklenti kodu hep bundan çağrılır; hata player'a geçmez. */
293
+ guard(e, t, s = "handler") {
294
+ return (...n) => {
295
+ try {
296
+ const r = t(...n);
297
+ r instanceof Promise && r.catch((o) => this.report(e, o, s));
298
+ } catch (r) {
299
+ this.report(e, r, s);
300
+ }
301
+ };
302
+ }
303
+ // ── PlayerApi ──
304
+ createApi(e) {
305
+ const t = this.ctx, s = e.plugin.name, n = (i) => {
306
+ e.removed ? i() : e.disposers.push(i);
307
+ }, r = (i, a) => this.guard(s, i, a), o = {}, u = this, g = (i, a, l = !1) => {
308
+ const h = i.includes(":") ? t.element : t.video, f = r((T) => {
309
+ l && y(), a(T);
310
+ }, `on(${i})`);
311
+ h.addEventListener(i, f);
312
+ let v = !1;
313
+ const y = () => {
314
+ v || (v = !0, h.removeEventListener(i, f));
315
+ };
316
+ return n(y), y;
317
+ };
318
+ return {
319
+ plugin: s,
320
+ apiVersion: b,
321
+ element: t.element,
322
+ video: t.video,
323
+ get locale() {
324
+ return t.locale();
325
+ },
326
+ labels: t.labels,
327
+ get currentTime() {
328
+ return t.video.currentTime;
329
+ },
330
+ get duration() {
331
+ return t.video.duration;
332
+ },
333
+ get paused() {
334
+ return t.video.paused;
335
+ },
336
+ get isLive() {
337
+ return t.video.duration === 1 / 0;
338
+ },
339
+ get isAdPlaying() {
340
+ return t.isAdPlaying();
341
+ },
342
+ get isFullscreen() {
343
+ return t.isFullscreen();
344
+ },
345
+ get src() {
346
+ return t.currentSrc();
347
+ },
348
+ play: () => t.video.play(),
349
+ pause: () => t.video.pause(),
350
+ seek: (i) => {
351
+ Number.isFinite(i) && (t.video.currentTime = Math.max(0, i));
352
+ },
353
+ on: (i, a) => g(i, a),
354
+ once: (i, a) => g(i, a, !0),
355
+ emit: (i, a) => {
356
+ t.element.dispatchEvent(new CustomEvent(`${s}:${i}`, { detail: a, bubbles: !0, composed: !0 }));
357
+ },
358
+ onSourceChange: (i) => g("loadstart", () => i(t.currentSrc())),
359
+ onLocaleChange: (i) => {
360
+ e.localeHandlers.push(i);
361
+ const a = () => {
362
+ const l = e.localeHandlers.indexOf(i);
363
+ l >= 0 && e.localeHandlers.splice(l, 1);
364
+ };
365
+ return n(a), a;
366
+ },
367
+ onDestroy: (i) => n(r(i, "onDestroy")),
368
+ setTimeout: (i, a) => {
369
+ const l = window.setTimeout(r(i, "setTimeout"), a);
370
+ return n(() => clearTimeout(l)), l;
371
+ },
372
+ setInterval: (i, a) => {
373
+ const l = window.setInterval(r(i, "setInterval"), a);
374
+ return n(() => clearInterval(l)), l;
375
+ },
376
+ ui: {
377
+ addButton: (i) => u.addButton(e, i, n, r),
378
+ addLayer: (i) => u.addLayer(e, i ?? {}, n),
379
+ toast: (i, a) => u.toast(i, a == null ? void 0 : a.durationMs)
380
+ },
381
+ settings: {
382
+ addToggle: (i) => {
383
+ const a = `plugin:${s}:toggle:${++u.keySeq}`, l = () => t.settings.registerToggle({
384
+ key: a,
385
+ label: m(i.label),
386
+ getValueLabel: () => i.get() ? L(t.labels, !0) : L(t.labels, !1),
387
+ onToggle: r(() => i.set(!i.get()), "settings.toggle")
388
+ });
389
+ return l(), e.relabel.push(l), n(() => t.settings.unregisterToggle(a)), P(l, () => t.settings.unregisterToggle(a));
390
+ },
391
+ addSelect: (i) => {
392
+ const a = `plugin:${s}:select:${++u.keySeq}`, l = () => typeof i.options == "function" ? i.options() : i.options, h = () => t.settings.registerSubmenu({
393
+ key: a,
394
+ title: m(i.label),
395
+ getValueLabel: () => {
396
+ const f = l().find((v) => v.value === i.get());
397
+ return f ? m(f.label) : "";
398
+ },
399
+ getItems: () => l().map((f) => ({ label: m(f.label), active: f.value === i.get(), onSelect: r(() => i.set(f.value), "settings.select") }))
400
+ });
401
+ return h(), e.relabel.push(h), n(() => t.settings.unregisterSubmenu(a)), P(h, () => t.settings.unregisterSubmenu(a));
402
+ },
403
+ addSubmenu: (i) => {
404
+ const a = `plugin:${s}:submenu:${++u.keySeq}`, l = () => t.settings.registerSubmenu({
405
+ key: a,
406
+ title: m(i.label),
407
+ getValueLabel: () => i.value ? i.value() : "",
408
+ getItems: () => i.items().map((h) => ({ label: m(h.label), active: !!h.active, onSelect: r(() => h.onSelect(), "settings.submenu") }))
409
+ });
410
+ return l(), e.relabel.push(l), n(() => t.settings.unregisterSubmenu(a)), P(l, () => t.settings.unregisterSubmenu(a));
411
+ }
412
+ },
413
+ keys: {
414
+ add: (i, a, l) => {
415
+ const h = { owner: s, spec: O(i), label: i, description: l, handler: r(a, `keys(${i})`) };
416
+ u.shortcutList.push(h);
417
+ const f = () => {
418
+ const v = u.shortcutList.indexOf(h);
419
+ v >= 0 && u.shortcutList.splice(v, 1);
420
+ };
421
+ return n(f), f;
422
+ }
423
+ },
424
+ i18n: {
425
+ add: (i) => {
426
+ for (const [a, l] of Object.entries(i)) o[a] = { ...o[a], ...l };
427
+ },
428
+ t: (i, a) => {
429
+ var l, h;
430
+ return ((l = o[t.locale()]) == null ? void 0 : l[i]) ?? ((h = o.en) == null ? void 0 : h[i]) ?? a ?? i;
431
+ }
432
+ },
433
+ storage: {
434
+ get: (i, a) => {
435
+ try {
436
+ const l = localStorage.getItem(E(s, i));
437
+ return l === null ? a : JSON.parse(l);
438
+ } catch {
439
+ return a;
440
+ }
441
+ },
442
+ set: (i, a) => {
443
+ try {
444
+ localStorage.setItem(E(s, i), JSON.stringify(a));
445
+ } catch {
446
+ }
447
+ },
448
+ remove: (i) => {
449
+ try {
450
+ localStorage.removeItem(E(s, i));
451
+ } catch {
452
+ }
453
+ }
454
+ },
455
+ ads: (() => {
456
+ const i = u.ads.api(s, r), a = (l) => ((...h) => {
457
+ const f = l(...h);
458
+ return n(f), f;
459
+ });
460
+ return {
461
+ requestBreak: i.requestBreak,
462
+ beforeContent: a(i.beforeContent),
463
+ atTime: a(i.atTime),
464
+ onPause: a(i.onPause),
465
+ onEnded: a(i.onEnded),
466
+ transformTag: a(i.transformTag)
467
+ };
468
+ })(),
469
+ log: (i, a) => t.log(i, { plugin: s, ...a })
470
+ };
471
+ }
472
+ addButton(e, t, s, n) {
473
+ const r = document.createElement("button");
474
+ r.type = "button", r.className = "hp-chip hp-plugin-btn hp:flex hp:items-center hp:justify-center hp:w-[var(--hp-ctrl-btn-size)] hp:h-[var(--hp-ctrl-btn-size)] hp:cursor-pointer hp:shrink-0", r.setAttribute("part", `plugin-button plugin-${e.plugin.name}`), r.dataset.plugin = e.plugin.name;
475
+ let o = t.label, u = !!t.active;
476
+ const g = (l) => {
477
+ var h;
478
+ r.textContent = "", l.trim().startsWith("<") ? (r.insertAdjacentHTML("beforeend", l), (h = r.querySelector("svg")) == null || h.setAttribute("aria-hidden", "true")) : r.appendChild(S(l, "hp:text-[length:var(--hp-ctrl-icon-size)]"));
479
+ }, p = () => r.setAttribute("aria-label", m(o)), i = () => {
480
+ t.active !== void 0 && r.setAttribute("aria-pressed", String(u));
481
+ };
482
+ g(t.icon), p(), i(), e.relabel.push(p);
483
+ const a = {
484
+ el: r,
485
+ get active() {
486
+ return u;
487
+ },
488
+ setLabel: (l) => {
489
+ o = l, p();
490
+ },
491
+ setIcon: g,
492
+ setActive: (l) => {
493
+ u = l, r.setAttribute("aria-pressed", String(l));
494
+ },
495
+ show: () => {
496
+ r.style.display = "";
497
+ },
498
+ hide: () => {
499
+ r.style.display = "none";
500
+ },
501
+ remove: () => r.remove()
502
+ };
503
+ if (t.onClick) {
504
+ const l = n((h) => t.onClick(h, a), "button.onClick");
505
+ r.addEventListener("click", (h) => {
506
+ h.stopPropagation(), l(h);
507
+ });
508
+ }
509
+ return this.ctx.addControlButton(r, t.position ?? "right"), s(() => r.remove()), a;
510
+ }
511
+ addLayer(e, t, s) {
512
+ const n = document.createElement("div");
513
+ n.className = "hp-plugin-layer", n.setAttribute("part", `plugin-layer plugin-${e.plugin.name}`), n.dataset.plugin = e.plugin.name, n.dataset.position = t.position ?? "fill", n.toggleAttribute("data-autohide", !!t.autoHide), n.toggleAttribute("data-interactive", !!t.interactive), n.toggleAttribute("data-above", !!t.above);
514
+ let r = t.visible !== !1;
515
+ n.hidden = !r, t.above ? this.ctx.videoArea.appendChild(n) : this.ctx.videoArea.insertBefore(n, this.ctx.chromeEl);
516
+ let o = null;
517
+ t.css && (o = document.createElement("style"), o.textContent = t.css, n.before(o));
518
+ const u = () => {
519
+ n.remove(), o == null || o.remove();
520
+ };
521
+ if (t.interactive)
522
+ for (const p of ["pointerdown", "mousedown", "mouseup", "touchstart", "touchend", "click", "dblclick"]) n.addEventListener(p, (i) => i.stopPropagation());
523
+ s(u);
524
+ const g = (p) => {
525
+ r = p, n.hidden = !p;
526
+ };
527
+ return {
528
+ el: n,
529
+ get visible() {
530
+ return r;
531
+ },
532
+ show: () => g(!0),
533
+ hide: () => g(!1),
534
+ toggle: (p) => g(p ?? !r),
535
+ remove: u
536
+ };
537
+ }
538
+ toast(e, t = 2500) {
539
+ this.toastEl || (this.toastEl = document.createElement("div"), this.toastEl.className = "hp-plugin-toast", this.toastEl.setAttribute("part", "plugin-toast"), this.toastEl.setAttribute("role", "status"), this.toastEl.setAttribute("aria-live", "polite"), this.ctx.videoArea.appendChild(this.toastEl)), this.toastEl.textContent = e, this.toastEl.setAttribute("data-visible", ""), this.toastTimer && clearTimeout(this.toastTimer), this.toastTimer = setTimeout(() => {
540
+ var s;
541
+ return (s = this.toastEl) == null ? void 0 : s.removeAttribute("data-visible");
542
+ }, Math.max(500, t));
543
+ }
544
+ }
545
+ function P(d, e) {
546
+ return { refresh: d, remove: e };
547
+ }
548
+ function L(d, e) {
549
+ const t = e ? d.a11yOn : d.a11yOff;
550
+ return typeof t == "string" ? t : e ? "On" : "Off";
551
+ }
552
+ function E(d, e) {
553
+ return `hp-plugin:${d}:${e}`;
554
+ }
555
+ function I(d) {
556
+ try {
557
+ return JSON.stringify(d ?? null, (e, t) => typeof t == "function" ? `fn:${t.name ?? ""}` : t);
558
+ } catch {
559
+ return String(Math.random());
560
+ }
561
+ }
562
+ export {
563
+ b as PLUGIN_API_VERSION,
564
+ B as PluginHost
565
+ };
566
+ //# sourceMappingURL=pluginHost-cN2uGFeG.js.map