@hopeplayer/core 1.0.10 → 1.0.12

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 (56) hide show
  1. package/dist/HopePlayerElement.d.ts +44 -0
  2. package/dist/HopePlayerElement.d.ts.map +1 -1
  3. package/dist/chunks/index-Br_RybXV.js +835 -0
  4. package/dist/chunks/index-Br_RybXV.js.map +1 -0
  5. package/dist/chunks/{index-DJZjHaLs.js → index-C3s21eZa.js} +2 -2
  6. package/dist/chunks/{index-DJZjHaLs.js.map → index-C3s21eZa.js.map} +1 -1
  7. package/dist/chunks/{index-Bqs23yk7.js → index-D2aXO0eh.js} +744 -399
  8. package/dist/chunks/index-D2aXO0eh.js.map +1 -0
  9. package/dist/chunks/{index-BJxXxr0g.js → index-DBwvWiuK.js} +2 -2
  10. package/dist/chunks/{index-BJxXxr0g.js.map → index-DBwvWiuK.js.map} +1 -1
  11. package/dist/chunks/index-DCXX1ZJG.js +108 -0
  12. package/dist/chunks/index-DCXX1ZJG.js.map +1 -0
  13. package/dist/chunks/{index-CJ3wYSlU.js → index-_-pYIxvh.js} +2 -2
  14. package/dist/chunks/{index-CJ3wYSlU.js.map → index-_-pYIxvh.js.map} +1 -1
  15. package/dist/chunks/{index-DN077Bbe.js → index-adiWYyto.js} +2 -2
  16. package/dist/chunks/{index-DN077Bbe.js.map → index-adiWYyto.js.map} +1 -1
  17. package/dist/chunks/{index-i8eKCN8V.js → index-nvfNBIM_.js} +2 -2
  18. package/dist/chunks/{index-i8eKCN8V.js.map → index-nvfNBIM_.js.map} +1 -1
  19. package/dist/controls/ControlBar.d.ts +28 -0
  20. package/dist/controls/ControlBar.d.ts.map +1 -1
  21. package/dist/controls/VolumePanel.d.ts +0 -2
  22. package/dist/controls/VolumePanel.d.ts.map +1 -1
  23. package/dist/debug/ErrorLog.d.ts +29 -0
  24. package/dist/debug/ErrorLog.d.ts.map +1 -0
  25. package/dist/hls/SourceManager.d.ts +9 -0
  26. package/dist/hls/SourceManager.d.ts.map +1 -1
  27. package/dist/hope-player.js +1 -1
  28. package/dist/i18n/locales/en.d.ts.map +1 -1
  29. package/dist/i18n/locales/tr.d.ts.map +1 -1
  30. package/dist/i18n/types.d.ts +17 -0
  31. package/dist/i18n/types.d.ts.map +1 -1
  32. package/dist/index.d.ts +2 -1
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/keyboard/KeyboardController.d.ts +2 -0
  35. package/dist/keyboard/KeyboardController.d.ts.map +1 -1
  36. package/dist/plugins/ads/AdSurfaceGuard.d.ts +39 -0
  37. package/dist/plugins/ads/AdSurfaceGuard.d.ts.map +1 -0
  38. package/dist/plugins/ads/AdsController.d.ts +101 -1
  39. package/dist/plugins/ads/AdsController.d.ts.map +1 -1
  40. package/dist/plugins/ads/PrerollGate.d.ts +51 -0
  41. package/dist/plugins/ads/PrerollGate.d.ts.map +1 -0
  42. package/dist/plugins/ads/preconnect.d.ts +2 -0
  43. package/dist/plugins/ads/preconnect.d.ts.map +1 -0
  44. package/dist/plugins/debug/DebugPanel.d.ts +37 -0
  45. package/dist/plugins/debug/DebugPanel.d.ts.map +1 -0
  46. package/dist/plugins/debug/index.d.ts +5 -0
  47. package/dist/plugins/debug/index.d.ts.map +1 -0
  48. package/dist/subtitles/CaptionRenderer.d.ts +6 -0
  49. package/dist/subtitles/CaptionRenderer.d.ts.map +1 -1
  50. package/dist/subtitles/attachTracks.d.ts.map +1 -1
  51. package/dist/types/index.d.ts +50 -1
  52. package/dist/types/index.d.ts.map +1 -1
  53. package/package.json +1 -1
  54. package/dist/chunks/index-Bqs23yk7.js.map +0 -1
  55. package/dist/chunks/index-glxDu2eJ.js +0 -531
  56. package/dist/chunks/index-glxDu2eJ.js.map +0 -1
@@ -1,531 +0,0 @@
1
- var g = Object.defineProperty;
2
- var A = (a, e, t) => e in a ? g(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
- var n = (a, e, t) => A(a, typeof e != "symbol" ? e + "" : e, t);
4
- const v = "https://imasdk.googleapis.com/js/sdkloader/ima3.js";
5
- let p = null;
6
- function E() {
7
- var a;
8
- return (a = window.google) != null && a.ima ? Promise.resolve(window.google.ima) : p || (p = new Promise((e, t) => {
9
- const i = document.createElement("script");
10
- i.src = v, i.async = !0, i.onload = () => {
11
- var s;
12
- (s = window.google) != null && s.ima ? e(window.google.ima) : t(new Error("IMA SDK yüklendi ama window.google.ima yok"));
13
- }, i.onerror = () => t(new Error("IMA SDK yüklenemedi (reklam engelleyici olabilir)")), document.head.appendChild(i);
14
- }), p);
15
- }
16
- function T() {
17
- var i;
18
- const e = (i = window.adTaxonomy) == null ? void 0 : i.keyValues;
19
- if (!e || typeof e != "object") return "";
20
- const t = [];
21
- for (const [s, r] of Object.entries(e))
22
- r == null || r === "" || t.push(`${s}=${r}`);
23
- return t.join("&");
24
- }
25
- function k(a, e = {}) {
26
- const t = encodeURIComponent(document.referrer || window.location.href), i = encodeURIComponent(window.location.href), s = Date.now();
27
- let r = a;
28
- const l = {
29
- referrer_url: t,
30
- description_url: i,
31
- timestamp: s
32
- };
33
- for (const [o, c] of Object.entries(l)) {
34
- const h = `[${o}]`;
35
- if (r.includes(h))
36
- r = r.replace(h, String(c));
37
- else if (!new URLSearchParams(r.split("?")[1]).has(o)) {
38
- const d = r.includes("?") ? "&" : "?";
39
- r += `${d}${o}=${c}`;
40
- }
41
- }
42
- try {
43
- const o = new URL(r);
44
- if (o.pathname.includes("/vmap/")) return a;
45
- const h = [];
46
- e.includeRefreshCount && h.push(`adrefreshCount=${e.adRefreshCount ?? 0}`);
47
- const d = T();
48
- if (d && h.push(d), h.length) {
49
- const u = o.searchParams.get("cust_params");
50
- o.searchParams.set("cust_params", u ? `${u}&${h.join("&")}` : h.join("&"));
51
- }
52
- return o.toString();
53
- } catch {
54
- return r;
55
- }
56
- }
57
- class C {
58
- constructor(e) {
59
- n(this, "adRetryCount", 0);
60
- n(this, "chain", {});
61
- n(this, "retryTimer", null);
62
- this.config = e;
63
- }
64
- get isPending() {
65
- return this.retryTimer !== null;
66
- }
67
- reset() {
68
- this.adRetryCount = 0, this.chain = {}, this.cancelPending();
69
- }
70
- cancelPending() {
71
- this.retryTimer && (clearTimeout(this.retryTimer), this.retryTimer = null);
72
- }
73
- /** Devre dışı/kapsam dışı/limit dolduysa onGiveUp; aksi halde (jitter'lı) gecikmeden sonra onRetry. */
74
- retry(e, t, i, s) {
75
- if (!this.config.enabled) {
76
- s("retry-disabled");
77
- return;
78
- }
79
- if ((this.config.retryScope ?? "preroll") === "preroll" && e !== "Preroll") {
80
- s("retry-disabled");
81
- return;
82
- }
83
- const l = this.resolveMaxRetry();
84
- if (this.adRetryCount >= l) {
85
- this.reset(), s("retry-limit");
86
- return;
87
- }
88
- this.cancelPending(), this.adRetryCount++;
89
- const o = this.getChainState(e, t);
90
- o.attemptsOnCurrent++;
91
- const c = this.config.maxAttemptsPerTag ?? 1 / 0;
92
- o.attemptsOnCurrent > c && o.index < o.tags.length - 1 && (o.index++, o.attemptsOnCurrent = 1);
93
- const h = o.tags[o.index], d = this.adRetryCount;
94
- this.retryTimer = setTimeout(() => {
95
- this.retryTimer = null, i(h, d);
96
- }, this.applyJitter(this.resolveRetryDelay()));
97
- }
98
- getChainState(e, t) {
99
- const i = this.chain[e];
100
- if (i) return i;
101
- const s = (Array.isArray(t) ? t : [t]).filter((l) => !!l), r = { tags: s.length ? s : [t], index: 0, attemptsOnCurrent: 0 };
102
- return this.chain[e] = r, r;
103
- }
104
- resolveRetryDelay() {
105
- const e = this.config.retryDelayPattern;
106
- if (!Array.isArray(e) || e.length === 0) return this.config.retryDelay ?? 800;
107
- for (const t of e) {
108
- const [i, s] = this.normalizeEntry(t);
109
- if (this.adRetryCount <= i) return s;
110
- }
111
- return this.normalizeEntry(e[e.length - 1])[1];
112
- }
113
- resolveMaxRetry() {
114
- const e = this.config.retryDelayPattern;
115
- return Array.isArray(e) && e.length > 0 ? this.normalizeEntry(e[e.length - 1])[0] : this.config.maxRetry ?? 10;
116
- }
117
- normalizeEntry(e) {
118
- return Array.isArray(e) ? e : [e.upTo, e.delay];
119
- }
120
- applyJitter(e) {
121
- const t = this.config.jitter ?? 0;
122
- if (!t) return e;
123
- const i = 1 + (Math.random() * 2 - 1) * t;
124
- return Math.max(0, Math.round(e * i));
125
- }
126
- }
127
- function f(a, e) {
128
- var t;
129
- try {
130
- (t = a == null ? void 0 : a.settings) != null && t.setPrivacySettings && (a.settings.setPrivacySettings({ nonPersonalizedAds: !0 }), console.warn(`[HopePlayer consent] non-personalized ads zorlandı (${e})`));
131
- } catch (i) {
132
- console.warn("[HopePlayer consent] setPrivacySettings hatası:", i);
133
- }
134
- }
135
- function M(a, e) {
136
- if (a.consentAware) {
137
- try {
138
- typeof window.__uspapi == "function" && window.__uspapi("getUSPData", 1, (t, i) => {
139
- !i || !(t != null && t.uspString) || t.uspString.charAt(2) === "Y" && f(e, "USP/CCPA opt-out");
140
- });
141
- } catch (t) {
142
- console.warn("[HopePlayer consent] __uspapi okuma hatası:", t);
143
- }
144
- try {
145
- typeof window.__tcfapi == "function" && window.__tcfapi("getTCData", 2, (t, i) => {
146
- var l, o, c, h;
147
- if (!i || !t || t.gdprApplies !== !0) return;
148
- const s = (o = (l = t.vendor) == null ? void 0 : l.consents) == null ? void 0 : o[755], r = (h = (c = t.purpose) == null ? void 0 : c.consents) == null ? void 0 : h[1];
149
- (s === !1 || r === !1) && f(e, "TCF yetersiz onay");
150
- });
151
- } catch (t) {
152
- console.warn("[HopePlayer consent] __tcfapi okuma hatası:", t);
153
- }
154
- }
155
- }
156
- function P(a) {
157
- try {
158
- const e = atob(a), t = new Uint8Array(e.length);
159
- for (let d = 0; d < e.length; d++) t[d] = e.charCodeAt(d);
160
- if (t[0] !== 252 || t[13] !== 5) return null;
161
- const s = (t[14] << 24 | t[15] << 16 | t[16] << 8 | t[17]) >>> 0;
162
- if (t[18] >> 7 & 1) return { type: "cancel", spliceEventId: s };
163
- const l = t[19] >> 7 & 1, o = t[19] >> 6 & 1, c = t[19] >> 5 & 1;
164
- let h = null;
165
- if (o) {
166
- let d = 20;
167
- const u = t[d] >> 7 & 1;
168
- if (d += u ? 5 : 1, c) {
169
- const m = t[d] >> 7 & 1, y = (t[d] & 1) * Math.pow(2, 32) + t[d + 1] * Math.pow(2, 24) + t[d + 2] * Math.pow(2, 16) + t[d + 3] * Math.pow(2, 8) + t[d + 4];
170
- h = { autoReturn: m, seconds: y / 9e4 };
171
- }
172
- }
173
- return { type: l ? "out" : "in", spliceEventId: s, breakDuration: h, programSplice: !!o };
174
- } catch {
175
- return null;
176
- }
177
- }
178
- function S(a, e) {
179
- if (a === "EXT-X-CUE-OUT")
180
- return { type: "out", duration: parseFloat(e) || null };
181
- if (a === "EXT-X-CUE-IN")
182
- return { type: "in" };
183
- if (a === "EXT-X-DATERANGE") {
184
- const t = e.match(/SCTE35-OUT=0x([0-9A-Fa-f]+)/), i = e.match(/SCTE35-IN=0x([0-9A-Fa-f]+)/), s = e.match(/PLANNED-DURATION=([\d.]+)/), r = e.match(/CLASS="([^"]+)"/);
185
- if (t)
186
- return { type: "out", duration: s ? parseFloat(s[1]) : null, class: r ? r[1] : null, raw: t[1] };
187
- if (i) return { type: "in", raw: i[1] };
188
- }
189
- return a === "EXT-OATCLS-SCTE35" ? P(e) : null;
190
- }
191
- class L {
192
- constructor(e, t) {
193
- n(this, "inAdBreak", !1);
194
- n(this, "adBreakTimer", null);
195
- n(this, "processedEventIds", /* @__PURE__ */ new Set());
196
- n(this, "trackListeners", /* @__PURE__ */ new Map());
197
- n(this, "onAddTrack", (e) => {
198
- e.track instanceof TextTrack && this.listenTrack(e.track);
199
- });
200
- this.videoEl = e, this.callbacks = t, this.attachExistingTracks(), e.textTracks.addEventListener("addtrack", this.onAddTrack);
201
- }
202
- destroy() {
203
- this.videoEl.textTracks.removeEventListener("addtrack", this.onAddTrack);
204
- for (const [e, t] of this.trackListeners)
205
- e.removeEventListener("cuechange", t);
206
- this.trackListeners.clear(), this.adBreakTimer && clearTimeout(this.adBreakTimer), this.processedEventIds.clear();
207
- }
208
- attachExistingTracks() {
209
- for (let e = 0; e < this.videoEl.textTracks.length; e++)
210
- this.listenTrack(this.videoEl.textTracks[e]);
211
- }
212
- listenTrack(e) {
213
- if (e.kind !== "metadata" || this.trackListeners.has(e)) return;
214
- e.mode = "hidden";
215
- const t = () => {
216
- const i = e.activeCues;
217
- if (i)
218
- for (let s = 0; s < i.length; s++) this.processCue(i[s]);
219
- };
220
- e.addEventListener("cuechange", t), this.trackListeners.set(e, t);
221
- }
222
- processCue(e) {
223
- const t = e;
224
- let i = null, s = "";
225
- if (t.value && typeof t.value == "object")
226
- i = t.value.key ?? null, s = t.value.data ?? t.value.value ?? "";
227
- else if (typeof t.text == "string") {
228
- const l = t.text.match(/^(EXT[^:]+):?(.*)$/);
229
- l && (i = l[1], s = l[2] ?? "");
230
- }
231
- if (!i) return;
232
- const r = S(i, s);
233
- r && this.handleSignal(r);
234
- }
235
- handleSignal(e) {
236
- var t;
237
- if (e.spliceEventId !== void 0) {
238
- if (this.processedEventIds.has(e.spliceEventId)) return;
239
- this.processedEventIds.add(e.spliceEventId), setTimeout(() => this.processedEventIds.delete(e.spliceEventId), 300 * 1e3);
240
- }
241
- if (e.type === "cancel") {
242
- this.endAdBreak(!0);
243
- return;
244
- }
245
- e.type === "out" && !this.inAdBreak ? this.startAdBreak(((t = e.breakDuration) == null ? void 0 : t.seconds) ?? e.duration ?? null) : e.type === "in" && this.inAdBreak && this.endAdBreak(!1);
246
- }
247
- startAdBreak(e) {
248
- this.inAdBreak || (this.inAdBreak = !0, this.callbacks.onAdBreakStart(e), e && e > 0 && (this.adBreakTimer = setTimeout(() => {
249
- this.inAdBreak && this.endAdBreak(!0);
250
- }, (e + 5) * 1e3)));
251
- }
252
- endAdBreak(e = !1) {
253
- this.inAdBreak && (this.inAdBreak = !1, this.adBreakTimer && (clearTimeout(this.adBreakTimer), this.adBreakTimer = null), this.callbacks.onAdBreakEnd());
254
- }
255
- }
256
- function B(a, e) {
257
- return e === "Preroll" ? a.adTagPreroll : e === "Midroll" ? a.adTagMidroll : a.adTagPostroll;
258
- }
259
- class w {
260
- constructor(e, t) {
261
- n(this, "ima", null);
262
- n(this, "adDisplayContainer", null);
263
- n(this, "adsLoader", null);
264
- n(this, "adsManager", null);
265
- n(this, "retry");
266
- n(this, "currentBreakType", "Preroll");
267
- n(this, "vmapRequested", !1);
268
- n(this, "postrollPending", !1);
269
- n(this, "postrollShown", !1);
270
- n(this, "lastMidrollTime", 0);
271
- n(this, "displayContainerInitialized", !1);
272
- /**
273
- * Reklam sırasında toolbar oynat/duraklat + ses buraya yönlenir (IMA reklamı ayrı bir video'da oynatır).
274
- * Durum hem bizim çağrılarımızdan hem IMA'nın kendi PAUSED/RESUMED event'lerinden senkron tutulur.
275
- */
276
- n(this, "adPaused", !1);
277
- n(this, "adVolumeBeforeMute", 1);
278
- n(this, "prebidIdSuffix");
279
- n(this, "prebidInstances", {});
280
- n(this, "scte35Manager", null);
281
- n(this, "scte35BreakActive", !1);
282
- n(this, "scte35BreakTimeout", null);
283
- /**
284
- * initialize() yalnızca 'play'e değil, player'a ilk dokunuşa da bağlı: preroll kullanıcı oynatmadan
285
- * adsManager.start()'a ulaşabiliyor ve initialize() önce çağrılmazsa IMA AdError 400 veriyor.
286
- */
287
- n(this, "initializeDisplayContainerOnce", () => {
288
- var e;
289
- this.displayContainerInitialized || (this.displayContainerInitialized = !0, (e = this.adDisplayContainer) == null || e.initialize());
290
- });
291
- n(this, "onTimeUpdateForMidroll", () => {
292
- const e = this.options.midrollIntervalSeconds ?? 0;
293
- if (e <= 0 || !this.options.adTagMidroll) return;
294
- const t = this.ctx.videoEl.currentTime;
295
- t > 60 && t - this.lastMidrollTime >= e && (this.lastMidrollTime = t, this.requestAd("Midroll", this.options.adTagMidroll));
296
- });
297
- n(this, "onContentEnded", () => {
298
- this.postrollShown || !this.options.adTagPostroll || (this.postrollPending = !0, this.postrollShown = !0, this.requestAd("Postroll", this.options.adTagPostroll));
299
- });
300
- n(this, "onAdsManagerLoaded", (e) => {
301
- if (!this.ima) return;
302
- this.adsManager = e.getAdsManager(this.ctx.videoEl, {
303
- restoreCustomPlaybackStateOnAdBreakComplete: !0,
304
- // VAST çözüldükten sonra creative'in yüklenmesi için üst sınır.
305
- loadVideoTimeout: this.options.loadVideoTimeoutMs ?? 1e4,
306
- enablePreloading: !0,
307
- // false: IMA'nın KENDİ styled linear ad UI'ı (skip/sayaç
308
- // kutusu) yerine bizim ControlBar'ımız (ad mode) kullanılıyor —
309
- // ikisi üst üste binmesin diye.
310
- useStyledLinearAds: !1,
311
- useStyledNonLinearAds: !0
312
- });
313
- const t = this.ima.AdEvent;
314
- this.adsManager.addEventListener(t.Type.CONTENT_PAUSE_REQUESTED, this.onContentPauseRequested), this.adsManager.addEventListener(t.Type.CONTENT_RESUME_REQUESTED, this.onContentResumeRequested), this.adsManager.addEventListener(t.Type.ALL_ADS_COMPLETED, this.onAllAdsCompleted), this.adsManager.addEventListener(this.ima.AdErrorEvent.Type.AD_ERROR, this.onAdsManagerError), this.adsManager.addEventListener(t.Type.PAUSED, this.onAdPaused), this.adsManager.addEventListener(t.Type.RESUMED, this.onAdResumed);
315
- try {
316
- this.adsManager.init(this.ctx.videoEl.clientWidth || 640, this.ctx.videoEl.clientHeight || 360, this.ima.ViewMode.NORMAL), this.adsManager.start();
317
- } catch (i) {
318
- this.giveUpOrRetry(this.currentBreakType, String(i));
319
- }
320
- });
321
- n(this, "onAdPaused", () => {
322
- var e, t;
323
- this.adPaused = !0, (t = (e = this.ctx).onAdPlayStateChange) == null || t.call(e);
324
- });
325
- n(this, "onAdResumed", () => {
326
- var e, t;
327
- this.adPaused = !1, (t = (e = this.ctx).onAdPlayStateChange) == null || t.call(e);
328
- });
329
- n(this, "onContentPauseRequested", () => {
330
- this.ctx.videoEl.pause(), this.adPaused = !1, this.ctx.hideChrome(), this.ctx.adLayerEl.classList.remove("hp:hidden"), this.ctx.adLayerEl.classList.add("hp:block"), this.retry.reset(), this.scte35BreakActive && this.scte35BreakTimeout && (clearTimeout(this.scte35BreakTimeout), this.scte35BreakTimeout = null), this.ctx.hostEl.dispatchEvent(new CustomEvent("hp:adstart", { detail: { type: this.breakTypeLower() } }));
331
- });
332
- n(this, "onContentResumeRequested", () => {
333
- this.hideAdLayer(), this.ctx.hostEl.dispatchEvent(new CustomEvent("hp:adend", { detail: { type: this.breakTypeLower() } })), this.scte35BreakActive = !1, this.currentBreakType === "Preroll" && this.maybeRequestVmapAfterPreroll(), this.currentBreakType !== "Postroll" && this.ctx.videoEl.play().catch(() => {
334
- });
335
- });
336
- n(this, "onAllAdsCompleted", () => {
337
- var e;
338
- (e = this.adsManager) == null || e.destroy(), this.adsManager = null;
339
- });
340
- n(this, "onAdsLoaderError", (e) => {
341
- var t, i, s, r;
342
- if ((t = this.adsManager) == null || t.destroy(), this.adsManager = null, this.scte35BreakActive) {
343
- this.endScte35Break();
344
- return;
345
- }
346
- this.giveUpOrRetry(this.currentBreakType, (r = (s = (i = e.getError) == null ? void 0 : i.call(e)) == null ? void 0 : s.getMessage) == null ? void 0 : r.call(s));
347
- });
348
- n(this, "onAdsManagerError", (e) => {
349
- var t, i, s, r;
350
- if ((t = this.adsManager) == null || t.destroy(), this.adsManager = null, this.scte35BreakActive) {
351
- this.endScte35Break();
352
- return;
353
- }
354
- this.giveUpOrRetry(this.currentBreakType, (r = (s = (i = e.getError) == null ? void 0 : i.call(e)) == null ? void 0 : s.getMessage) == null ? void 0 : r.call(s));
355
- });
356
- this.ctx = e, this.options = t, this.retry = new C(t.retry ?? {}), this.prebidIdSuffix = e.hostEl.id || Math.random().toString(36).slice(2, 8);
357
- }
358
- async install() {
359
- var i, s;
360
- let e;
361
- try {
362
- e = await E();
363
- } catch (r) {
364
- this.ctx.hostEl.dispatchEvent(new CustomEvent("hp:aderror", { detail: { message: String(r) } }));
365
- return;
366
- }
367
- this.ima = e;
368
- try {
369
- e.settings.setLocale(this.ctx.locale);
370
- } catch {
371
- }
372
- try {
373
- e.settings.setNumRedirects(this.options.numRedirects ?? 15);
374
- } catch {
375
- }
376
- try {
377
- e.settings.setDisableCustomPlaybackForIOS10Plus(!0);
378
- } catch {
379
- }
380
- try {
381
- (i = e.ImaSdkSettings) != null && i.VpaidMode && e.settings.setVpaidMode(e.ImaSdkSettings.VpaidMode.INSECURE);
382
- } catch {
383
- }
384
- M(this.options, this.ima), this.adDisplayContainer = new e.AdDisplayContainer(this.ctx.adLayerEl, this.ctx.videoEl), this.adsLoader = new e.AdsLoader(this.adDisplayContainer), this.adsLoader.addEventListener(e.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED, this.onAdsManagerLoaded), this.adsLoader.addEventListener(e.AdErrorEvent.Type.AD_ERROR, this.onAdsLoaderError), this.ctx.videoEl.addEventListener("play", this.initializeDisplayContainerOnce);
385
- const t = typeof navigator < "u" && "userActivation" in navigator && navigator.userActivation.hasBeenActive;
386
- (!this.ctx.videoEl.paused || t) && this.initializeDisplayContainerOnce(), this.options.adTagPostroll && this.ctx.videoEl.addEventListener("ended", this.onContentEnded), this.options.adTagMidroll && !this.options.adTagVmap && this.options.midrollIntervalSeconds && this.ctx.videoEl.addEventListener("timeupdate", this.onTimeUpdateForMidroll), this.requestInitialPrerollOrVmap(), (s = this.options.live) != null && s.scte35 && this.options.live.adTagLive && (this.scte35Manager = new L(this.ctx.videoEl, {
387
- onAdBreakStart: (r) => this.onScte35AdBreakStart(r),
388
- onAdBreakEnd: () => this.onScte35AdBreakEnd()
389
- }));
390
- }
391
- /** requestOnPlay yoksa preroll/VMAP hemen istenir; varsa kullanıcı oynatana kadar ertelenir. */
392
- requestInitialPrerollOrVmap() {
393
- const e = () => {
394
- this.options.adTagPreroll ? this.requestAd("Preroll", this.options.adTagPreroll) : this.options.adTagVmap && (this.vmapRequested = !0, this.requestAd("Preroll", this.options.adTagVmap, 0, !0));
395
- };
396
- if (!this.options.requestOnPlay || !this.ctx.videoEl.paused) {
397
- e();
398
- return;
399
- }
400
- this.ctx.videoEl.addEventListener("play", e, { once: !0 });
401
- }
402
- /** Playlist/story item değişiminde: önceki item'ın reklam durumunu sıfırla. */
403
- resetForNewItem(e) {
404
- this.retry.reset(), this.vmapRequested = !1, this.postrollShown = !1, this.postrollPending = !1, this.lastMidrollTime = 0, e !== void 0 && (this.options.adTagPreroll = e), this.options.adTagPreroll ? this.requestAd("Preroll", this.options.adTagPreroll) : this.options.adTagVmap && (this.vmapRequested = !0, this.requestAd("Preroll", this.options.adTagVmap, 0, !0));
405
- }
406
- destroy() {
407
- var e, t, i, s;
408
- this.ctx.videoEl.removeEventListener("play", this.initializeDisplayContainerOnce), this.ctx.videoEl.removeEventListener("ended", this.onContentEnded), this.ctx.videoEl.removeEventListener("timeupdate", this.onTimeUpdateForMidroll), this.retry.cancelPending(), (e = this.adsManager) == null || e.destroy(), (t = this.adsLoader) == null || t.destroy(), (i = this.adDisplayContainer) == null || i.destroy(), (s = this.scte35Manager) == null || s.destroy(), this.scte35BreakTimeout && clearTimeout(this.scte35BreakTimeout);
409
- }
410
- /** SCTE-35 OUT sinyali: IMA'ya reklam iste (normal midroll gibi) + IMA cevap vermezse N ms sonra vazgeç. */
411
- onScte35AdBreakStart(e) {
412
- var i;
413
- this.scte35BreakActive = !0, this.requestAd("Midroll", this.options.live.adTagLive);
414
- const t = ((i = this.options.live) == null ? void 0 : i.breakTimeoutMs) ?? 1e4;
415
- this.scte35BreakTimeout && clearTimeout(this.scte35BreakTimeout), this.scte35BreakTimeout = setTimeout(() => {
416
- this.endScte35Break();
417
- }, t);
418
- }
419
- /** SCTE-35 IN sinyali: yayıncının sinyaline güvenilir — reklam hâlâ oynuyor olsa bile içeriğe dönülür. */
420
- onScte35AdBreakEnd() {
421
- this.endScte35Break();
422
- }
423
- endScte35Break() {
424
- var e;
425
- this.scte35BreakActive && (this.scte35BreakActive = !1, this.scte35BreakTimeout && (clearTimeout(this.scte35BreakTimeout), this.scte35BreakTimeout = null), (e = this.adsManager) == null || e.destroy(), this.adsManager = null, this.hideAdLayer(), this.ctx.videoEl.paused && this.ctx.videoEl.play().catch(() => {
426
- }));
427
- }
428
- /** Preroll: options.prebid, Midroll: options.prebid.midroll. Postroll'da prebid yok. */
429
- getPrebidConfigFor(e) {
430
- var i;
431
- const t = this.options.prebid;
432
- return t ? e === "Preroll" ? t.enabled ? t : null : e === "Midroll" && (i = t.midroll) != null && i.enabled ? { ...t, ...t.midroll } : null : null;
433
- }
434
- async getOrCreatePrebidInstance(e, t) {
435
- var o;
436
- const i = this.prebidInstances[e];
437
- if (i) return i;
438
- const { VideoPrebid: s } = await import("./VideoPrebid-CpckFzSq.js"), r = e === "Midroll" ? "hope-video-midroll" : "hope-video-preroll", l = new s({
439
- ...t,
440
- adUnitCode: `${t.adUnitCode || r}-${this.prebidIdSuffix}`,
441
- consentManagement: (o = this.options.prebid) == null ? void 0 : o.consentManagement
442
- });
443
- return this.prebidInstances[e] = l, l;
444
- }
445
- async requestAd(e, t, i = 0, s = !1) {
446
- var c;
447
- if (!this.adsLoader || !this.ima) return;
448
- this.currentBreakType = e;
449
- const r = Array.isArray(t) ? t[0] : t;
450
- let l = s ? r : k(r, { includeRefreshCount: !!((c = this.options.retry) != null && c.enabled), adRefreshCount: i });
451
- if (!s && i === 0) {
452
- const h = this.getPrebidConfigFor(e);
453
- if (h) {
454
- const d = await this.getOrCreatePrebidInstance(e, h);
455
- d.isAvailable() && (l = await d.runAuction(l));
456
- }
457
- }
458
- if (!this.adsLoader || !this.ima) return;
459
- const o = new this.ima.AdsRequest();
460
- o.adTagUrl = l, o.linearAdSlotWidth = this.ctx.videoEl.clientWidth || 640, o.linearAdSlotHeight = this.ctx.videoEl.clientHeight || 360, o.vastLoadTimeout = this.options.vastLoadTimeoutMs ?? 1e4;
461
- try {
462
- this.adsLoader.requestAds(o);
463
- } catch (h) {
464
- this.giveUpOrRetry(e, String(h));
465
- }
466
- }
467
- /** Toolbar'daki oynat/duraklat butonunun (reklam modunda) hedefi — content videoEl yerine bu çağrılır. */
468
- toggleAdPlayPause() {
469
- this.adsManager && (this.adPaused ? this.adsManager.resume() : this.adsManager.pause(), this.adPaused = !this.adPaused);
470
- }
471
- isAdPaused() {
472
- return this.adPaused;
473
- }
474
- getAdVolume() {
475
- var e;
476
- return ((e = this.adsManager) == null ? void 0 : e.getVolume()) ?? 1;
477
- }
478
- setAdVolume(e) {
479
- var t;
480
- (t = this.adsManager) == null || t.setVolume(Math.min(1, Math.max(0, e)));
481
- }
482
- isAdMuted() {
483
- return this.getAdVolume() === 0;
484
- }
485
- /** VolumePanel'deki `onToggleMute` ile AYNI desen: 0 ↔ son bilinen (ya da varsayılan 0.5) ses seviyesi arasında geçiş. */
486
- toggleAdMute() {
487
- if (!this.adsManager) return;
488
- const e = this.adsManager.getVolume();
489
- e > 0 ? (this.adVolumeBeforeMute = e, this.adsManager.setVolume(0)) : this.adsManager.setVolume(this.adVolumeBeforeMute > 0 ? this.adVolumeBeforeMute : 0.5);
490
- }
491
- giveUpOrRetry(e, t) {
492
- if (this.scte35BreakActive) {
493
- this.endScte35Break();
494
- return;
495
- }
496
- const i = B(this.options, e);
497
- if (!i) {
498
- this.resumeContentAfterGiveUp(e, t);
499
- return;
500
- }
501
- this.retry.retry(
502
- e,
503
- i,
504
- (s, r) => this.requestAd(e, s, r),
505
- () => this.resumeContentAfterGiveUp(e, t)
506
- );
507
- }
508
- resumeContentAfterGiveUp(e, t) {
509
- this.hideAdLayer(), this.ctx.hostEl.dispatchEvent(new CustomEvent("hp:aderror", { detail: { message: t ?? "ad-error" } })), e === "Preroll" && this.maybeRequestVmapAfterPreroll(), e !== "Postroll" && this.ctx.videoEl.paused && this.ctx.videoEl.play().catch(() => {
510
- });
511
- }
512
- /** VMAP split: preroll (başarılı ya da vazgeçilerek) bitince, VMAP TAM OLARAK BİR KEZ, değiştirilmeden istenir. */
513
- maybeRequestVmapAfterPreroll() {
514
- this.vmapRequested || !this.options.adTagVmap || (this.vmapRequested = !0, this.requestAd("Midroll", this.options.adTagVmap, 0, !0));
515
- }
516
- hideAdLayer() {
517
- this.ctx.adLayerEl.classList.add("hp:hidden"), this.ctx.adLayerEl.classList.remove("hp:block"), this.ctx.showChrome();
518
- }
519
- breakTypeLower() {
520
- return this.currentBreakType.toLowerCase();
521
- }
522
- }
523
- async function b(a, e) {
524
- const t = new w(a, e);
525
- return await t.install(), t;
526
- }
527
- export {
528
- w as AdsController,
529
- b as installAds
530
- };
531
- //# sourceMappingURL=index-glxDu2eJ.js.map