libaribhtml5 0.1.9 → 0.2.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.
@@ -39,59 +39,59 @@ function uq(A) {
39
39
  A.__ARIB_HTML5_ROMSOUND__ = !0;
40
40
  const q = A.HTMLMediaElement?.prototype, e = A.Element?.prototype;
41
41
  if (!q || !e) return;
42
- const t = cq(A.navigator), i = (l) => R(l) ?? String(l), r = (l) => l instanceof A.HTMLMediaElement || !!(A.HTMLSourceElement && l instanceof A.HTMLSourceElement), n = "data-arib-romsound", o = e.getAttribute, c = e.setAttribute, s = e.removeAttribute, y = (l) => o.call(l, n), E = (l, d) => {
42
+ const t = cq(A.navigator), i = (c) => R(c) ?? String(c), r = (c) => c instanceof A.HTMLMediaElement || !!(A.HTMLSourceElement && c instanceof A.HTMLSourceElement), o = "data-arib-romsound", n = e.getAttribute, l = e.setAttribute, s = e.removeAttribute, p = (c) => n.call(c, o), E = (c, d) => {
43
43
  const u = String(d), B = R(u);
44
- return B ? c.call(l, n, u) : s.call(l, n), B ?? u;
45
- }, m = (l, d) => !t || !R(d) ? !1 : (E(l, d), s.call(l, "src"), !0);
46
- e.getAttribute = function(l) {
47
- if (l.toLowerCase() === "src" && r(this)) {
48
- const d = y(this);
44
+ return B ? l.call(c, o, u) : s.call(c, o), B ?? u;
45
+ }, m = (c, d) => !t || !R(d) ? !1 : (E(c, d), s.call(c, "src"), !0);
46
+ e.getAttribute = function(c) {
47
+ if (c.toLowerCase() === "src" && r(this)) {
48
+ const d = p(this);
49
49
  if (d !== null) return d;
50
50
  }
51
- return o.call(this, l);
52
- }, e.setAttribute = function(l, d) {
53
- if (l.toLowerCase() === "src" && r(this) && m(this, d))
51
+ return n.call(this, c);
52
+ }, e.setAttribute = function(c, d) {
53
+ if (c.toLowerCase() === "src" && r(this) && m(this, d))
54
54
  return;
55
- const u = l.toLowerCase() === "src" && r(this) ? E(this, d) : String(d);
56
- c.call(this, l, String(u));
55
+ const u = c.toLowerCase() === "src" && r(this) ? E(this, d) : String(d);
56
+ l.call(this, c, String(u));
57
57
  };
58
58
  const v = e.setAttributeNS;
59
- e.setAttributeNS = function(l, d, u) {
59
+ e.setAttributeNS = function(c, d, u) {
60
60
  if (d.toLowerCase() === "src" && r(this) && m(this, u))
61
61
  return;
62
62
  const B = d.toLowerCase() === "src" && r(this) ? E(this, u) : String(u);
63
- v.call(this, l, d, String(B));
64
- }, e.removeAttribute = function(l) {
65
- l.toLowerCase() === "src" && r(this) && s.call(this, n), s.call(this, l);
63
+ v.call(this, c, d, String(B));
64
+ }, e.removeAttribute = function(c) {
65
+ c.toLowerCase() === "src" && r(this) && s.call(this, o), s.call(this, c);
66
66
  };
67
- const M = (l) => {
68
- if (!l) return;
69
- const d = Object.getOwnPropertyDescriptor(l, "src");
70
- return !d?.get || !d.set || Object.defineProperty(l, "src", {
67
+ const b = (c) => {
68
+ if (!c) return;
69
+ const d = Object.getOwnPropertyDescriptor(c, "src");
70
+ return !d?.get || !d.set || Object.defineProperty(c, "src", {
71
71
  configurable: !0,
72
72
  enumerable: d.enumerable,
73
73
  get() {
74
- return r(this) ? y(this) ?? d.get.call(this) : d.get.call(this);
74
+ return r(this) ? p(this) ?? d.get.call(this) : d.get.call(this);
75
75
  },
76
76
  set(u) {
77
77
  r(this) && m(this, u) || d.set.call(this, r(this) ? E(this, u) : i(u));
78
78
  }
79
79
  }), d;
80
- }, V = M(q);
81
- M(A.HTMLSourceElement?.prototype);
82
- const p = q.play;
80
+ }, V = b(q);
81
+ b(A.HTMLSourceElement?.prototype);
82
+ const y = q.play;
83
83
  q.play = function() {
84
- const l = y(this) ?? o.call(this, "src"), d = R(l);
84
+ const c = p(this) ?? n.call(this, "src"), d = R(c);
85
85
  if (t) {
86
- const u = this.querySelector?.(`source[${n}]`), B = u ? R(y(u)) : null;
86
+ const u = this.querySelector?.(`source[${o}]`), B = u ? R(p(u)) : null;
87
87
  if (d || B) return Promise.resolve();
88
88
  }
89
- return d && V?.set?.call(this, d), p.call(this);
89
+ return d && V?.set?.call(this, d), y.call(this);
90
90
  };
91
- const g = (l, d) => {
92
- if (!l) return;
93
- const u = Object.getOwnPropertyDescriptor(l, d);
94
- !u?.get || !u.set || Object.defineProperty(l, d, {
91
+ const g = (c, d) => {
92
+ if (!c) return;
93
+ const u = Object.getOwnPropertyDescriptor(c, d);
94
+ !u?.get || !u.set || Object.defineProperty(c, d, {
95
95
  configurable: !0,
96
96
  enumerable: u.enumerable,
97
97
  get: u.get,
@@ -102,50 +102,50 @@ function uq(A) {
102
102
  };
103
103
  g(e, "innerHTML"), g(e, "outerHTML"), g(A.ShadowRoot?.prototype, "innerHTML");
104
104
  const a = e.insertAdjacentHTML;
105
- e.insertAdjacentHTML = function(l, d) {
106
- a.call(this, l, C(String(d)));
105
+ e.insertAdjacentHTML = function(c, d) {
106
+ a.call(this, c, C(String(d)));
107
107
  };
108
108
  const h = A.Range?.prototype;
109
109
  if (h) {
110
- const l = h.createContextualFragment;
110
+ const c = h.createContextualFragment;
111
111
  h.createContextualFragment = function(d) {
112
- return l.call(this, C(String(d)));
112
+ return c.call(this, C(String(d)));
113
113
  };
114
114
  }
115
115
  const T = A.DOMParser?.prototype;
116
116
  if (T) {
117
- const l = T.parseFromString;
117
+ const c = T.parseFromString;
118
118
  T.parseFromString = function(d, u) {
119
- return l.call(this, C(String(d)), u);
119
+ return c.call(this, C(String(d)), u);
120
120
  };
121
121
  }
122
122
  const k = A.Document?.prototype;
123
123
  if (k) {
124
- const l = k.write, d = k.writeln;
124
+ const c = k.write, d = k.writeln;
125
125
  k.write = function(...u) {
126
- l.apply(this, u.map((B) => C(String(B))));
126
+ c.apply(this, u.map((B) => C(String(B))));
127
127
  }, k.writeln = function(...u) {
128
128
  d.apply(this, u.map((B) => C(String(B))));
129
129
  };
130
130
  }
131
- const w = (l) => {
131
+ const w = (c) => {
132
132
  const d = [];
133
- r(l) && d.push(l), (l instanceof A.Element || l === A.document) && d.push(...l.querySelectorAll(
133
+ r(c) && d.push(c), (c instanceof A.Element || c === A.document) && d.push(...c.querySelectorAll(
134
134
  'audio[src^="romsound://"], video[src^="romsound://"], source[src^="romsound://"], audio[data-arib-romsound], video[data-arib-romsound], source[data-arib-romsound]'
135
135
  ));
136
136
  for (const u of d) {
137
- const X = y(u) ?? o.call(u, "src"), Q = R(X);
137
+ const X = p(u) ?? n.call(u, "src"), Q = R(X);
138
138
  if (Q) {
139
139
  if (t) {
140
140
  s.call(u, "src"), u instanceof A.HTMLMediaElement && (s.call(u, "autoplay"), u.pause());
141
141
  continue;
142
142
  }
143
- u instanceof A.HTMLMediaElement && V?.set ? V.get?.call(u) !== Q && V.set.call(u, Q) : o.call(u, "src") !== Q && c.call(u, "src", Q);
143
+ u instanceof A.HTMLMediaElement && V?.set ? V.get?.call(u) !== Q && V.set.call(u, Q) : n.call(u, "src") !== Q && l.call(u, "src", Q);
144
144
  }
145
145
  }
146
146
  };
147
- new A.MutationObserver((l) => {
148
- for (const d of l) {
147
+ new A.MutationObserver((c) => {
148
+ for (const d of c) {
149
149
  d.type === "attributes" && w(d.target);
150
150
  for (const u of d.addedNodes) w(u);
151
151
  }
@@ -193,8 +193,8 @@ function mq(A, q) {
193
193
  return e.now();
194
194
  }
195
195
  }, i = function(...r) {
196
- const n = r.length === 0 ? [t()] : r;
197
- return new.target ? Reflect.construct(e, n, new.target) : new e(t()).toString();
196
+ const o = r.length === 0 ? [t()] : r;
197
+ return new.target ? Reflect.construct(e, o, new.target) : new e(t()).toString();
198
198
  };
199
199
  Object.setPrototypeOf(i, e), Object.defineProperty(i, "prototype", {
200
200
  value: e.prototype
@@ -227,83 +227,83 @@ function H(A, q, e = q) {
227
227
  const t = new URL(A, q);
228
228
  if (t.origin !== q.origin || !/^https?:$/.test(t.protocol)) return t;
229
229
  if (!t.pathname.startsWith(q.pathname)) {
230
- const i = t.pathname.replace(/^\/+/, ""), r = e.pathname.startsWith(q.pathname) ? e.pathname.slice(q.pathname.length).replace(/^\/+|\/+$/g, "") : "", n = r && (i === r || i.startsWith(`${r}/`));
231
- t.pathname = `${n ? q.pathname : e.pathname}${i}`;
230
+ const i = t.pathname.replace(/^\/+/, ""), r = e.pathname.startsWith(q.pathname) ? e.pathname.slice(q.pathname.length).replace(/^\/+|\/+$/g, "") : "", o = r && (i === r || i.startsWith(`${r}/`));
231
+ t.pathname = `${o ? q.pathname : e.pathname}${i}`;
232
232
  }
233
233
  return t;
234
234
  }
235
235
  function vq(A, q, e) {
236
236
  const t = e ?? {
237
- async store(V, p) {
237
+ async store(V, y) {
238
238
  const g = await A.fetch(V, {
239
239
  cache: "reload",
240
240
  credentials: "same-origin",
241
- signal: p.signal
241
+ signal: y.signal
242
242
  });
243
243
  if (!g.ok) throw new Error(`Broadcast resource returned HTTP ${g.status}`);
244
244
  await g.arrayBuffer();
245
245
  }
246
246
  }, i = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
247
- let n = !1;
248
- const o = (V) => q(V).href, c = (V, p, g) => A.queueMicrotask(() => p(V, g)), s = (V, p) => {
247
+ let o = !1;
248
+ const n = (V) => q(V).href, l = (V, y, g) => A.queueMicrotask(() => y(V, g)), s = (V, y) => {
249
249
  for (const g of V.paths)
250
- for (const a of i.get(g) ?? []) c(g, a, p);
251
- }, y = (V) => {
250
+ for (const a of i.get(g) ?? []) l(g, a, y);
251
+ }, p = (V) => {
252
252
  try {
253
253
  Promise.resolve(t.release?.(V)).catch(() => {
254
254
  });
255
255
  } catch {
256
256
  }
257
257
  }, E = (V) => {
258
- V.generation += 1, V.controller?.abort(), V.controller = void 0, r.delete(V.url), y(V.url);
259
- }, m = (V, p) => {
258
+ V.generation += 1, V.controller?.abort(), V.controller = void 0, r.delete(V.url), p(V.url);
259
+ }, m = (V, y) => {
260
260
  V.controller?.abort();
261
261
  const g = new A.AbortController(), a = ++V.generation;
262
262
  V.controller = g, V.state = "loading", Promise.resolve(t.store(V.url, { signal: g.signal })).then(
263
263
  () => {
264
- n || g.signal.aborted || V.generation !== a || (V.controller = void 0, V.state = "stored", s(V, p));
264
+ o || g.signal.aborted || V.generation !== a || (V.controller = void 0, V.state = "stored", s(V, y));
265
265
  },
266
266
  () => {
267
- n || g.signal.aborted || V.generation !== a || (V.controller = void 0, V.state = "failed", s(V, "store_failed"));
267
+ o || g.signal.aborted || V.generation !== a || (V.controller = void 0, V.state = "failed", s(V, "store_failed"));
268
268
  }
269
269
  );
270
- }, v = (V, p) => typeof p != "function" || n ? !1 : (i.has(V) || i.set(V, /* @__PURE__ */ new Set()), i.get(V)?.add(p), r.get(o(V))?.state === "stored" && c(V, p, "store_finished"), !0), M = (V) => {
270
+ }, v = (V, y) => typeof y != "function" || o ? !1 : (i.has(V) || i.set(V, /* @__PURE__ */ new Set()), i.get(V)?.add(y), r.get(n(V))?.state === "stored" && l(V, y, "store_finished"), !0), b = (V) => {
271
271
  if (V === void 0) {
272
272
  for (const g of [...r.values()]) E(g);
273
273
  return !0;
274
274
  }
275
- const p = r.get(o(V));
276
- return p && E(p), !0;
275
+ const y = r.get(n(V));
276
+ return y && E(y), !0;
277
277
  };
278
278
  return {
279
279
  addListener: v,
280
- removeListener(V, p) {
281
- return p ? (i.get(V)?.delete(p), i.get(V)?.size === 0 && i.delete(V)) : i.delete(V), !0;
280
+ removeListener(V, y) {
281
+ return y ? (i.get(V)?.delete(y), i.get(V)?.size === 0 && i.delete(V)) : i.delete(V), !0;
282
282
  },
283
- store(V, p) {
284
- if (n) return !1;
285
- const g = o(V);
283
+ store(V, y) {
284
+ if (o) return !1;
285
+ const g = n(V);
286
286
  let a = r.get(g);
287
287
  return a || (a = {
288
288
  url: g,
289
289
  paths: /* @__PURE__ */ new Set(),
290
290
  state: "failed",
291
291
  generation: 0
292
- }, r.set(g, a)), a.paths.add(V), p && v(V, p), a.state === "stored" || a.state !== "loading" && m(a, "store_finished"), !0;
292
+ }, r.set(g, a)), a.paths.add(V), y && v(V, y), a.state === "stored" || a.state !== "loading" && m(a, "store_finished"), !0;
293
293
  },
294
- release: M,
295
- change(V, p) {
296
- const g = r.get(o(V));
297
- g && (p === "deleted" ? (s(g, "deleted"), E(g)) : m(g, "updated"));
294
+ release: b,
295
+ change(V, y) {
296
+ const g = r.get(n(V));
297
+ g && (y === "deleted" ? (s(g, "deleted"), E(g)) : m(g, "updated"));
298
298
  },
299
299
  dispose() {
300
- n || (M(), n = !0, i.clear());
300
+ o || (b(), o = !0, i.clear());
301
301
  }
302
302
  };
303
303
  }
304
- const Mq = "libaribhtml5", bq = "0.1.9", kq = { name: "huggy" }, wq = { modelName: "Huggy ARIB HTML5 Receiver" }, I = {
305
- name: Mq,
306
- version: bq,
304
+ const bq = "libaribhtml5", Mq = "0.2.0", kq = { name: "huggy" }, wq = { modelName: "Huggy ARIB HTML5 Receiver" }, I = {
305
+ name: bq,
306
+ version: Mq,
307
307
  author: kq,
308
308
  aribReceiver: wq
309
309
  }, Cq = /* @__PURE__ */ new Set(["zipcode", "prefecture", "regioncode"]), Rq = Object.freeze({
@@ -407,7 +407,7 @@ const f = {
407
407
  scheduling: 4,
408
408
  cas: 3
409
409
  }, S = 8191, J = 16, j = 160;
410
- function b(A) {
410
+ function M(A) {
411
411
  const q = new TypeError(A);
412
412
  return q.code = "INVALID_PARAM_ERR", q;
413
413
  }
@@ -417,22 +417,22 @@ function jq(A) {
417
417
  }
418
418
  function x(A) {
419
419
  if (!A || typeof A != "object")
420
- throw b("Permission managed area must be an object");
420
+ throw M("Permission managed area must be an object");
421
421
  const q = A;
422
422
  if (q.permissionBitmaps !== null && !Array.isArray(q.permissionBitmaps))
423
- throw b("permissionBitmaps must be an array or null");
423
+ throw M("permissionBitmaps must be an array or null");
424
424
  if (q.managedUrls !== null && !Array.isArray(q.managedUrls))
425
- throw b("managedUrls must be an array or null");
425
+ throw M("managedUrls must be an array or null");
426
426
  const e = q.permissionBitmaps === null ? null : [...q.permissionBitmaps], t = q.managedUrls === null ? null : [...q.managedUrls];
427
427
  for (const i of e ?? [])
428
428
  if (!Number.isInteger(i) || i < 0 || i > 65535)
429
- throw b("permission_bitmap must be a 16-bit integer");
429
+ throw M("permission_bitmap must be a 16-bit integer");
430
430
  for (const i of t ?? [])
431
431
  if (typeof i != "string" || new TextEncoder().encode(i).length > 255)
432
- throw b("managed_URL must be a string");
432
+ throw M("managed_URL must be a string");
433
433
  return { permissionBitmaps: e, managedUrls: t };
434
434
  }
435
- function N(A) {
435
+ function O(A) {
436
436
  const q = A.reduce(
437
437
  (t, i) => t + (i.permissionBitmaps?.length ?? 0),
438
438
  0
@@ -441,9 +441,9 @@ function N(A) {
441
441
  0
442
442
  );
443
443
  if (q > J)
444
- throw b(`At most ${J} permission bitmaps are supported`);
444
+ throw M(`At most ${J} permission bitmaps are supported`);
445
445
  if (e > j)
446
- throw b(`At most ${j} managed URLs are supported`);
446
+ throw M(`At most ${j} managed URLs are supported`);
447
447
  }
448
448
  function L(A) {
449
449
  if (A === null || A.length === 0) return S;
@@ -457,7 +457,7 @@ function L(A) {
457
457
  function xq(A, q) {
458
458
  return A.origin === q.origin && A.pathname.startsWith(q.pathname);
459
459
  }
460
- function Nq(A, q, e) {
460
+ function Oq(A, q, e) {
461
461
  let t;
462
462
  try {
463
463
  t = new URL(A, e);
@@ -468,7 +468,7 @@ function Nq(A, q, e) {
468
468
  const i = t.pathname.replace(/\/+$/, "") || "/", r = q.pathname;
469
469
  return i !== "/" && r !== i && !r.startsWith(`${i}/`) ? null : t.origin.length + i.length;
470
470
  }
471
- class Oq {
471
+ class Nq {
472
472
  broadcastBaseUrl;
473
473
  documentUrl;
474
474
  baseAreas;
@@ -479,7 +479,7 @@ class Oq {
479
479
  /** Apply a new MH-AIT descriptor without discarding areas added by the application. */
480
480
  update(q) {
481
481
  const e = q?.map(x);
482
- N([...e ?? [], ...this.addedAreas]), this.baseAreas = e;
482
+ O([...e ?? [], ...this.addedAreas]), this.baseAreas = e;
483
483
  }
484
484
  hasDescriptor() {
485
485
  return this.baseAreas !== void 0 || this.addedAreas.length > 0;
@@ -492,17 +492,17 @@ class Oq {
492
492
  }
493
493
  addPermissionManagedArea(q) {
494
494
  if (!q || typeof q != "object")
495
- throw b("Permission managed area must be an object");
495
+ throw M("Permission managed area must be an object");
496
496
  const e = q;
497
497
  if (e.permission !== null && !Array.isArray(e.permission))
498
- throw b("permission must be an array or null");
498
+ throw M("permission must be an array or null");
499
499
  if (e.urls !== null && !Array.isArray(e.urls))
500
- throw b("urls must be an array or null");
500
+ throw M("urls must be an array or null");
501
501
  const t = x({
502
502
  permissionBitmaps: e.permission === null || e.permission.length === 0 ? null : e.permission,
503
503
  managedUrls: e.urls === null || e.urls.length === 0 ? null : e.urls
504
504
  });
505
- N([...this.baseAreas ?? [], ...this.addedAreas, t]), this.addedAreas.push(jq(t));
505
+ O([...this.baseAreas ?? [], ...this.addedAreas, t]), this.addedAreas.push(jq(t));
506
506
  }
507
507
  evaluate(q) {
508
508
  let e;
@@ -517,17 +517,17 @@ class Oq {
517
517
  if (this.baseAreas === void 0 && this.addedAreas.length === 0)
518
518
  return { withinBoundary: !0, permissionBits: S };
519
519
  let i = -1, r = 0;
520
- for (const n of t) {
521
- const o = n.managedUrls;
522
- if (o === null || o.length === 0) {
523
- i < 0 ? (i = 0, r = L(n.permissionBitmaps)) : i === 0 && (r &= L(n.permissionBitmaps));
520
+ for (const o of t) {
521
+ const n = o.managedUrls;
522
+ if (n === null || n.length === 0) {
523
+ i < 0 ? (i = 0, r = L(o.permissionBitmaps)) : i === 0 && (r &= L(o.permissionBitmaps));
524
524
  continue;
525
525
  }
526
- for (const c of o) {
527
- const s = Nq(c, e, this.documentUrl);
526
+ for (const l of n) {
527
+ const s = Oq(l, e, this.documentUrl);
528
528
  if (s === null || s < i) continue;
529
- const y = L(n.permissionBitmaps);
530
- s > i ? (i = s, r = y) : r &= y;
529
+ const p = L(o.permissionBitmaps);
530
+ s > i ? (i = s, r = p) : r &= p;
531
531
  }
532
532
  }
533
533
  return i < 0 ? { withinBoundary: !1, permissionBits: 0 } : { withinBoundary: !0, permissionBits: r };
@@ -541,48 +541,48 @@ function Zq(A, q) {
541
541
  if (q) return;
542
542
  const e = (r) => {
543
543
  try {
544
- const n = new URL(String(r), A.location.href);
545
- return /^https?:$/.test(n.protocol) && n.origin !== A.location.origin;
544
+ const o = new URL(String(r), A.location.href);
545
+ return /^https?:$/.test(o.protocol) && o.origin !== A.location.origin;
546
546
  } catch {
547
547
  return !1;
548
548
  }
549
549
  }, t = A.XMLHttpRequest?.prototype;
550
550
  if (t) {
551
- const r = /* @__PURE__ */ new WeakSet(), n = t.open, o = t.send;
551
+ const r = /* @__PURE__ */ new WeakSet(), o = t.open, n = t.send;
552
552
  Object.defineProperty(t, "open", {
553
553
  configurable: !0,
554
554
  writable: !0,
555
- value: function(c, s, ...y) {
556
- return e(s) ? r.add(this) : r.delete(this), Reflect.apply(n, this, [c, s, ...y]);
555
+ value: function(l, s, ...p) {
556
+ return e(s) ? r.add(this) : r.delete(this), Reflect.apply(o, this, [l, s, ...p]);
557
557
  }
558
558
  }), Object.defineProperty(t, "send", {
559
559
  configurable: !0,
560
560
  writable: !0,
561
- value: function(c) {
562
- if (!r.has(this)) return o.call(this, c);
561
+ value: function(l) {
562
+ if (!r.has(this)) return n.call(this, l);
563
563
  A.queueMicrotask(() => this.dispatchEvent(new A.ProgressEvent("error")));
564
564
  }
565
565
  });
566
566
  }
567
567
  const i = A.fetch?.bind(A);
568
- if (i && (A.fetch = (r, n) => {
569
- const o = r instanceof A.Request ? r.url : r;
570
- return e(o) ? Promise.reject(new TypeError("External network is offline")) : i(r, n);
568
+ if (i && (A.fetch = (r, o) => {
569
+ const n = r instanceof A.Request ? r.url : r;
570
+ return e(n) ? Promise.reject(new TypeError("External network is offline")) : i(r, o);
571
571
  }), typeof A.navigator.sendBeacon == "function") {
572
572
  const r = A.navigator.sendBeacon.bind(A.navigator);
573
573
  Object.defineProperty(A.navigator, "sendBeacon", {
574
574
  configurable: !0,
575
- value: (n, o) => e(n) ? !1 : r(n, o)
575
+ value: (o, n) => e(o) ? !1 : r(o, n)
576
576
  });
577
577
  }
578
578
  }
579
579
  const Kq = (A, q, e = 1) => Math.abs(A.left - q.left) <= e && Math.abs(A.top - q.top) <= e && Math.abs(A.width - q.width) <= e && Math.abs(A.height - q.height) <= e, zq = (A) => A.hasAttribute("width") || A.hasAttribute("height") || A.style.getPropertyValue("width") !== "" || A.style.getPropertyValue("height") !== "", F = (A) => {
580
580
  const q = A.ownerDocument;
581
581
  let e = A, t = A.getBoundingClientRect(), i = A, r = !zq(A) && (t.width <= 0 || t.height <= 0 || Math.abs(t.width - 300) <= 1 && Math.abs(t.height - 150) <= 1);
582
- for (let n = A.parentElement; n && n !== q.body && n !== q.documentElement; n = n.parentElement) {
583
- const o = n.getBoundingClientRect(), c = n.children.length === 1 && n.firstElementChild === i, s = Kq(o, t);
584
- if (!c || o.width <= 0 || o.height <= 0 || !s && !r) break;
585
- e = n, t = o, i = n, r = !1;
582
+ for (let o = A.parentElement; o && o !== q.body && o !== q.documentElement; o = o.parentElement) {
583
+ const n = o.getBoundingClientRect(), l = o.children.length === 1 && o.firstElementChild === i, s = Kq(n, t);
584
+ if (!l || n.width <= 0 || n.height <= 0 || !s && !r) break;
585
+ e = o, t = n, i = o, r = !1;
586
586
  }
587
587
  return { element: e, rect: t };
588
588
  };
@@ -593,28 +593,28 @@ class Hq {
593
593
  constructor(q) {
594
594
  this.target = q;
595
595
  }
596
- set(q, e) {
597
- if (this.setPlaceholder(q, e), !e) {
596
+ set(q, e, t = !0) {
597
+ if (this.setPlaceholder(q, e), !e || !t) {
598
598
  this.restoreBackgrounds();
599
599
  return;
600
600
  }
601
- const t = /* @__PURE__ */ new Set();
601
+ const i = /* @__PURE__ */ new Set();
602
602
  for (let n = q.parentElement; n && n !== this.target.document.body && n !== this.target.document.documentElement; n = n.parentElement) {
603
- const o = this.target.getComputedStyle(n);
604
- !this.backgrounds.has(n) && this.hasTransparentBackground(o) || t.add(n);
603
+ const l = this.target.getComputedStyle(n);
604
+ !this.backgrounds.has(n) && this.hasTransparentBackground(l) || i.add(n);
605
605
  }
606
- const i = F(q).rect, r = (n) => {
607
- const o = n.getBoundingClientRect(), c = 1;
608
- return o.width > 0 && o.height > 0 && o.left <= i.left + c && o.top <= i.top + c && o.right >= i.right - c && o.bottom >= i.bottom - c;
606
+ const r = F(q).rect, o = (n) => {
607
+ const l = n.getBoundingClientRect(), s = 1;
608
+ return l.width > 0 && l.height > 0 && l.left <= r.left + s && l.top <= r.top + s && l.right >= r.right - s && l.bottom >= r.bottom - s;
609
609
  };
610
610
  for (const n of this.target.document.querySelectorAll("body *")) {
611
611
  if (n === q || n.contains(q) || q.contains(n)) continue;
612
- const o = this.target.getComputedStyle(n);
613
- !this.backgrounds.has(n) && this.hasTransparentBackground(o) || r(n) && t.add(n);
612
+ const l = this.target.getComputedStyle(n);
613
+ !this.backgrounds.has(n) && this.hasTransparentBackground(l) || o(n) && i.add(n);
614
614
  }
615
615
  for (const n of [...this.backgrounds.keys()])
616
- t.has(n) || this.restoreBackground(n);
617
- for (const n of t) {
616
+ i.has(n) || this.restoreBackground(n);
617
+ for (const n of i) {
618
618
  if (this.backgrounds.has(n)) {
619
619
  this.captureApplicationBackgroundChanges(n), this.clearBackground(n);
620
620
  continue;
@@ -669,18 +669,11 @@ class Hq {
669
669
  }
670
670
  placeholderElements(q) {
671
671
  const e = [q], t = F(q), i = t.rect, r = 1;
672
- let n = q;
673
- for (const o of this.target.document.querySelectorAll("body *")) {
674
- if (o === q || o.tagName.toLowerCase() !== "object") continue;
675
- const c = o.getAttribute("type")?.toLowerCase() ?? "";
676
- if (!c.includes("shockwave-flash") && !c.includes("silverlight")) continue;
677
- const s = o.getBoundingClientRect();
678
- Math.abs(s.left - i.left) <= r && Math.abs(s.top - i.top) <= r && Math.abs(s.width - i.width) <= r && Math.abs(s.height - i.height) <= r && e.push(o);
679
- }
680
- for (let o = q.parentElement; o && o !== this.target.document.body && o !== this.target.document.documentElement; o = o.parentElement) {
681
- const c = o.getBoundingClientRect();
682
- if (!(o.children.length === 1 && o.firstElementChild === n && (o === t.element || Math.abs(c.left - i.left) <= r && Math.abs(c.top - i.top) <= r && Math.abs(c.width - i.width) <= r && Math.abs(c.height - i.height) <= r))) break;
683
- e.push(o), n = o;
672
+ let o = q;
673
+ for (let n = q.parentElement; n && n !== this.target.document.body && n !== this.target.document.documentElement; n = n.parentElement) {
674
+ const l = n.getBoundingClientRect();
675
+ if (!(n.children.length === 1 && n.firstElementChild === o && (n === t.element || Math.abs(l.left - i.left) <= r && Math.abs(l.top - i.top) <= r && Math.abs(l.width - i.width) <= r && Math.abs(l.height - i.height) <= r))) break;
676
+ e.push(n), o = n;
684
677
  }
685
678
  return e;
686
679
  }
@@ -738,7 +731,7 @@ class Hq {
738
731
  this.restoreBackground(q);
739
732
  }
740
733
  }
741
- const Yq = 'object[type="video/x-arib2-broadcast"], object[data-arib-type="video/x-arib2-broadcast"]', O = [
734
+ const Yq = '[data-arib-object="video/x-arib2-broadcast"], object[type="video/x-arib2-broadcast"]', N = [
742
735
  "animationstart",
743
736
  "animationend",
744
737
  "animationcancel",
@@ -778,7 +771,7 @@ class Xq {
778
771
  startObserving() {
779
772
  if (!(this.observing || this.disposed)) {
780
773
  this.observing = !0, this.mutationObserver = new this.target.MutationObserver(this.schedule), this.observeDocumentMutations(), this.resizeObserver?.observe(this.target.document.documentElement), this.target.addEventListener("resize", this.schedule);
781
- for (const q of O)
774
+ for (const q of N)
782
775
  this.target.document.addEventListener(q, this.schedule, !0);
783
776
  this.target.document.addEventListener("load", this.schedule, !0), queueMicrotask(this.schedule);
784
777
  }
@@ -795,7 +788,7 @@ class Xq {
795
788
  dispose(q, e) {
796
789
  if (!this.disposed) {
797
790
  this.disposed = !0, this.mediaPlaneFrame !== null && this.target.cancelAnimationFrame(this.mediaPlaneFrame), this.mediaPlaneFrame = null, this.mutationObserver?.disconnect(), this.resizeObserver?.disconnect(), this.target.removeEventListener("resize", this.schedule), this.target.document.removeEventListener("load", this.schedule, !0);
798
- for (const t of O)
791
+ for (const t of N)
799
792
  this.target.document.removeEventListener(t, this.schedule, !0);
800
793
  this.applicationCanvasStyle?.remove(), this.applicationCanvasStyle = null, e?.(), this.unmountMediaPlane(q);
801
794
  }
@@ -809,12 +802,12 @@ class Xq {
809
802
  let i = this.target.getComputedStyle(e ?? this.target.document.documentElement).backgroundColor;
810
803
  const r = e?.getBoundingClientRect();
811
804
  if (r && r.width > 0 && r.height > 0)
812
- for (const o of this.target.document.querySelectorAll("body *")) {
813
- const c = this.target.getComputedStyle(o);
814
- if (c.backgroundColor === "rgba(0, 0, 0, 0)" || c.backgroundColor === "transparent") continue;
815
- const s = o.getBoundingClientRect();
805
+ for (const n of this.target.document.querySelectorAll("body *")) {
806
+ const l = this.target.getComputedStyle(n);
807
+ if (l.backgroundColor === "rgba(0, 0, 0, 0)" || l.backgroundColor === "transparent") continue;
808
+ const s = n.getBoundingClientRect();
816
809
  if (!(s.width <= 0 || s.height <= 0 || s.left > r.left + 1 || s.top > r.top + 1 || s.right < r.right - 1 || s.bottom < r.bottom - 1)) {
817
- i = c.backgroundColor;
810
+ i = l.backgroundColor;
818
811
  break;
819
812
  }
820
813
  }
@@ -844,7 +837,14 @@ class Xq {
844
837
  observeDocumentMutations() {
845
838
  !this.observing || this.disposed || this.mutationObserver === null || this.mutationObserver.observe(this.target.document.documentElement, {
846
839
  attributes: !0,
847
- attributeFilter: ["class", "style", "type", "data-arib-type", "name", "value"],
840
+ attributeFilter: [
841
+ "class",
842
+ "style",
843
+ "type",
844
+ "data-arib-object",
845
+ "name",
846
+ "value"
847
+ ],
848
848
  childList: !0,
849
849
  subtree: !0
850
850
  });
@@ -861,11 +861,11 @@ class Xq {
861
861
  q !== this.observedMediaObject && (this.observedMediaObject && this.resizeObserver?.unobserve(this.observedMediaObject), this.observedMediaObject = q, q && this.resizeObserver?.observe(q));
862
862
  }
863
863
  logicalViewport() {
864
- const q = this.target.document.querySelector('meta[name="viewport"]')?.content ?? "", e = (o) => {
865
- const c = Number(q.match(new RegExp(`(?:^|[,;])\\s*${o}\\s*=\\s*(\\d+)`, "i"))?.[1]);
866
- return Number.isSafeInteger(c) && c > 0 ? c : null;
867
- }, t = e("width"), i = e("height"), r = t ?? (i === null ? 3840 : Math.round(i * 16 / 9)), n = i ?? (t === null ? 2160 : Math.round(t * 9 / 16));
868
- return { width: r, height: n };
864
+ const q = this.target.document.querySelector('meta[name="viewport"]')?.content ?? "", e = (n) => {
865
+ const l = Number(q.match(new RegExp(`(?:^|[,;])\\s*${n}\\s*=\\s*(\\d+)`, "i"))?.[1]);
866
+ return Number.isSafeInteger(l) && l > 0 ? l : null;
867
+ }, t = e("width"), i = e("height"), r = t ?? (i === null ? 3840 : Math.round(i * 16 / 9)), o = i ?? (t === null ? 2160 : Math.round(t * 9 / 16));
868
+ return { width: r, height: o };
869
869
  }
870
870
  reportScreenSize() {
871
871
  const q = this.logicalViewport(), e = JSON.stringify(q);
@@ -889,6 +889,30 @@ class Xq {
889
889
  unmountMediaPlane(q) {
890
890
  this.activeMediaObject ? this.externalMediaHole.set(this.activeMediaObject, !1) : this.externalMediaHole.restore(), this.adapter && this.callMediaPlaneAdapter(() => this.adapter?.unmountMediaPlane(q)), this.activeMediaObject = null;
891
891
  }
892
+ /** A foreground surface must not cover opaque application dialogs above its slot. */
893
+ isCoveredByApplication(q, e) {
894
+ const t = this.target.document;
895
+ if (typeof t.elementsFromPoint != "function") return !1;
896
+ const i = t.elementsFromPoint(e.x + e.width / 2, e.y + e.height / 2), r = i.indexOf(q);
897
+ if (r < 0) return !1;
898
+ for (const o of i.slice(0, r)) {
899
+ if (o.contains(q) || q.contains(o)) continue;
900
+ const n = this.target.getComputedStyle(o);
901
+ if (!n.backgroundColor.startsWith("rgb(") || n.clipPath !== "none" || n.borderRadius !== "0px") continue;
902
+ let l = !0;
903
+ for (let p = o; p; p = p.parentElement) {
904
+ const E = this.target.getComputedStyle(p);
905
+ if (Number(E.opacity) < 1 || E.visibility !== "visible") {
906
+ l = !1;
907
+ break;
908
+ }
909
+ }
910
+ if (!l) continue;
911
+ const s = o.getBoundingClientRect();
912
+ if (s.left <= e.left && s.top <= e.top && s.right >= e.right && s.bottom >= e.bottom) return !0;
913
+ }
914
+ return !1;
915
+ }
892
916
  reportMediaPlane() {
893
917
  this.reportScreenSize(), this.target.document.readyState !== "loading" && this.reportStageStyle();
894
918
  const q = this.findMediaObject();
@@ -906,32 +930,35 @@ class Xq {
906
930
  screenWidth: m.width,
907
931
  screenHeight: m.height,
908
932
  layer: { documentOrder: -1, stackingPath: [] }
909
- }, M = JSON.stringify(v);
910
- M !== this.lastMediaPlane && (this.lastMediaPlane = M, this.postRuntime("media-plane", v));
933
+ }, b = JSON.stringify(v);
934
+ b !== this.lastMediaPlane && (this.lastMediaPlane = b, this.postRuntime("media-plane", v));
911
935
  return;
912
936
  }
913
937
  this.observeMediaObject(q), this.installBroadcastObjectApi(q);
914
- const e = F(q), t = e.rect, i = this.target.getComputedStyle(q), r = q.querySelector('param[name="video_src"]')?.value, n = q.querySelector('param[name="audio_src"]')?.value, o = this.logicalViewport(), c = this.externalMediaHole.describeStackingPath(q), s = {
938
+ const e = F(q), t = e.rect, i = this.target.getComputedStyle(q), r = q.querySelector('param[name="video_src"]')?.value, o = q.querySelector('param[name="audio_src"]')?.value, n = this.logicalViewport(), l = this.externalMediaHole.describeStackingPath(q), s = {
915
939
  slotId: this.slotIdFor(q),
916
- visible: i.display !== "none" && i.visibility !== "hidden" && t.width > 0 && t.height > 0 && c.every((E) => E.display !== "none" && E.visibility !== "hidden" && E.opacity > 0),
940
+ visible: i.display !== "none" && i.visibility !== "hidden" && t.width > 0 && t.height > 0 && l.every((E) => E.display !== "none" && E.visibility !== "hidden" && E.opacity > 0),
917
941
  x: t.x,
918
942
  y: t.y,
919
943
  width: t.width,
920
944
  height: t.height,
921
- screenWidth: o.width,
922
- screenHeight: o.height,
945
+ screenWidth: n.width,
946
+ screenHeight: n.height,
923
947
  videoSource: r,
924
- audioSource: n,
948
+ audioSource: o,
925
949
  layer: {
926
950
  documentOrder: Array.from(this.target.document.querySelectorAll("*")).indexOf(q),
927
- stackingPath: c,
951
+ stackingPath: l,
928
952
  externalPlacement: e.element !== q && Number.parseInt(this.target.getComputedStyle(e.element).zIndex, 10) > 0 ? "above-application" : "behind-application"
929
953
  }
930
- }, y = JSON.stringify(s);
931
- q !== this.activeMediaObject ? (this.activeMediaObject && this.unmountMediaPlane("slot-removed"), this.activeMediaObject = q, this.adapter && this.callMediaPlaneAdapter(() => this.adapter?.mountMediaPlane(q, s))) : y !== this.lastMediaPlane && this.adapter && this.callMediaPlaneAdapter(() => this.adapter?.updateMediaPlane(q, s)), this.externalMediaHole.set(
954
+ };
955
+ this.adapter?.renderMode === "external" && s.visible && s.layer.externalPlacement === "above-application" && this.isCoveredByApplication(q, t) && (s.visible = !1);
956
+ const p = JSON.stringify(s);
957
+ q !== this.activeMediaObject ? (this.activeMediaObject && this.unmountMediaPlane("slot-removed"), this.activeMediaObject = q, this.adapter && this.callMediaPlaneAdapter(() => this.adapter?.mountMediaPlane(q, s))) : p !== this.lastMediaPlane && this.adapter && this.callMediaPlaneAdapter(() => this.adapter?.updateMediaPlane(q, s)), this.externalMediaHole.set(
932
958
  q,
933
- (this.adapter?.renderMode ?? "external") === "external"
934
- ), y !== this.lastMediaPlane && (this.lastMediaPlane = y, this.postRuntime("media-plane", s));
959
+ (this.adapter?.renderMode ?? "external") === "external",
960
+ s.layer.externalPlacement !== "above-application"
961
+ ), p !== this.lastMediaPlane && (this.lastMediaPlane = p, this.postRuntime("media-plane", s));
935
962
  }
936
963
  }
937
964
  class _q {
@@ -1022,7 +1049,7 @@ class $q {
1022
1049
  };
1023
1050
  ownerApplication;
1024
1051
  constructor(q) {
1025
- this.target = q.target, this.resolveRuntimeUrl = q.resolveRuntimeUrl, this.allowExternalNetwork = q.allowExternalNetwork, this.postRuntime = q.postRuntime, this.applicationInformation = { ...q.application }, this.boundary = new Oq(
1052
+ this.target = q.target, this.resolveRuntimeUrl = q.resolveRuntimeUrl, this.allowExternalNetwork = q.allowExternalNetwork, this.postRuntime = q.postRuntime, this.applicationInformation = { ...q.application }, this.boundary = new Nq(
1026
1053
  q.broadcastBaseUrl,
1027
1054
  this.target.location.href,
1028
1055
  this.applicationInformation.permissionManagedAreas
@@ -1179,17 +1206,29 @@ function ee(A, q) {
1179
1206
  e ? Object.defineProperty(A, "userAgent", e) : Reflect.deleteProperty(A, "userAgent");
1180
1207
  };
1181
1208
  }
1182
- function te(A, q = {}) {
1209
+ function te(A) {
1210
+ const q = A.document.querySelectorAll(
1211
+ 'object[type="video/x-arib2-broadcast"]'
1212
+ );
1213
+ for (const e of q) {
1214
+ const t = A.document.createElement("video");
1215
+ for (const i of Array.from(e.attributes))
1216
+ i.name.toLowerCase() !== "type" && t.setAttribute(i.name, i.value);
1217
+ for (t.setAttribute("data-arib-object", "video/x-arib2-broadcast"); e.firstChild !== null; ) t.append(e.firstChild);
1218
+ e.replaceWith(t);
1219
+ }
1220
+ }
1221
+ function Ae(A, q = {}) {
1183
1222
  if (!A.__ARIB_HTML5_RUNTIME__) {
1184
1223
  A.__ARIB_HTML5_RUNTIME__ = "installing";
1185
1224
  try {
1186
- Ae(A, q), A.__ARIB_HTML5_RUNTIME__ = !0;
1225
+ ie(A, q), A.__ARIB_HTML5_RUNTIME__ = !0;
1187
1226
  } catch (e) {
1188
1227
  throw delete A.__ARIB_HTML5_RUNTIME__, e;
1189
1228
  }
1190
1229
  }
1191
1230
  }
1192
- function Ae(A, q) {
1231
+ function ie(A, q) {
1193
1232
  const e = q.userAgent === void 0 ? null : ee(A.navigator, q.userAgent);
1194
1233
  mq(A, q.now), uq(A), fq(A);
1195
1234
  const t = z(
@@ -1201,43 +1240,43 @@ function Ae(A, q) {
1201
1240
  const i = Bq(A.location.href, t), r = (a) => {
1202
1241
  const h = new URL(String(a ?? ""), A.location.href);
1203
1242
  return H(h, t, i);
1204
- }, n = A.crypto.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`, o = (a, h = {}) => {
1243
+ }, o = A.crypto.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`, n = (a, h = {}) => {
1205
1244
  A.parent?.postMessage({
1206
1245
  type: "arib-runtime",
1207
- runtimeId: n,
1246
+ runtimeId: o,
1208
1247
  event: a,
1209
1248
  ...h
1210
1249
  }, "*");
1211
- }, c = new $q({
1250
+ }, l = new $q({
1212
1251
  target: A,
1213
1252
  broadcastBaseUrl: t,
1214
1253
  resolveRuntimeUrl: r,
1215
1254
  allowExternalNetwork: q.allowExternalNetwork ?? !1,
1216
1255
  application: q.application,
1217
- postRuntime: o
1256
+ postRuntime: n
1218
1257
  }), s = (a) => {
1219
- c.requirePermission(a);
1258
+ l.requirePermission(a);
1220
1259
  };
1221
1260
  Zq(A, q.allowExternalNetwork);
1222
1261
  for (const [a, h] of Object.entries(qe)) A[a] = h;
1223
- const y = /* @__PURE__ */ new Set(), E = /* @__PURE__ */ new Set(), m = vq(
1262
+ const p = /* @__PURE__ */ new Set(), E = /* @__PURE__ */ new Set(), m = vq(
1224
1263
  A,
1225
1264
  (a) => r(a),
1226
1265
  q.resourceStore
1227
1266
  );
1228
1267
  let v = null;
1229
- const M = new _q({
1268
+ const b = new _q({
1230
1269
  requirePermission: () => s(f.broadcastMedia),
1231
- postRuntime: o
1270
+ postRuntime: n
1232
1271
  });
1233
1272
  let V;
1234
1273
  A.addEventListener("message", (a) => {
1235
- if (!(a.source !== A.parent || a.origin !== A.location.origin) && !(a.data?.type !== "arib-host" || a.data.runtimeId !== n) && !M.handleHostMessage(a.data)) {
1274
+ if (!(a.source !== A.parent || a.origin !== A.location.origin) && !(a.data?.type !== "arib-host" || a.data.runtimeId !== o) && !b.handleHostMessage(a.data)) {
1236
1275
  if (a.data.event === "program-info") {
1237
1276
  try {
1238
1277
  v = a.data.value === null ? null : D(a.data.value);
1239
1278
  } catch (h) {
1240
- o("error", { message: `Invalid program information: ${String(h)}` });
1279
+ n("error", { message: `Invalid program information: ${String(h)}` });
1241
1280
  return;
1242
1281
  }
1243
1282
  for (const h of E) queueMicrotask(h);
@@ -1245,17 +1284,17 @@ function Ae(A, q) {
1245
1284
  }
1246
1285
  if (a.data.event === "application-information") {
1247
1286
  try {
1248
- const h = c.updateApplicationInformation(
1287
+ const h = l.updateApplicationInformation(
1249
1288
  a.data.value ?? {}
1250
1289
  );
1251
- V.schedule(), h || o("application-boundary-exit", { url: A.location.href });
1290
+ V.schedule(), h || n("application-boundary-exit", { url: A.location.href });
1252
1291
  } catch (h) {
1253
- o("error", { message: `Invalid application information: ${String(h)}` });
1292
+ n("error", { message: `Invalid application information: ${String(h)}` });
1254
1293
  }
1255
1294
  return;
1256
1295
  }
1257
1296
  if (a.data.event === "receiver-input-state") {
1258
- c.setHostInputActive(!!a.data.active);
1297
+ l.setHostInputActive(!!a.data.active);
1259
1298
  return;
1260
1299
  }
1261
1300
  if (a.data.event === "resource-change") {
@@ -1265,18 +1304,18 @@ function Ae(A, q) {
1265
1304
  }
1266
1305
  if (a.data.event === "stream-event") {
1267
1306
  const h = a.data.value;
1268
- for (const T of [...y])
1307
+ for (const T of [...p])
1269
1308
  Wq(h, T.selector) && T.callback(h);
1270
1309
  }
1271
1310
  }
1272
1311
  });
1273
- const p = Sq(
1312
+ const y = Sq(
1274
1313
  t.href,
1275
1314
  q.systemInformation
1276
1315
  );
1277
- Qq(A.localStorage, p), P(A.navigator, "receiverDevice", {
1316
+ Qq(A.localStorage, y), P(A.navigator, "receiverDevice", {
1278
1317
  confirmIPNetwork: () => q.allowExternalNetwork ?? !1,
1279
- getSystemInformation: () => (s(f.broadcastResources), { ...p }),
1318
+ getSystemInformation: () => (s(f.broadcastResources), { ...y }),
1280
1319
  getDeviceIdentifier: (a, h) => {
1281
1320
  s(f.deviceIdentifier), queueMicrotask(() => {
1282
1321
  Gq(a, q.getDeviceIdentifier).then(
@@ -1295,12 +1334,12 @@ function Ae(A, q) {
1295
1334
  removeCacheEventListener: (a, h) => (s(f.broadcastResources), m.removeListener(a, h))
1296
1335
  },
1297
1336
  streamEvent: {
1298
- addGeneralEventMessageListener: (a, h) => (s(f.broadcastResources), typeof h != "function" ? !1 : (y.add({ selector: a, callback: h }), !0)),
1337
+ addGeneralEventMessageListener: (a, h) => (s(f.broadcastResources), typeof h != "function" ? !1 : (p.add({ selector: a, callback: h }), !0)),
1299
1338
  removeGeneralEventMessageListener: (a, h) => {
1300
1339
  if (s(f.broadcastResources), !a)
1301
- return y.clear(), !0;
1302
- for (const T of [...y])
1303
- Jq(T.selector, a) && (!h || h === T.callback) && y.delete(T);
1340
+ return p.clear(), !0;
1341
+ for (const T of [...p])
1342
+ Jq(T.selector, a) && (!h || h === T.callback) && p.delete(T);
1304
1343
  return !0;
1305
1344
  },
1306
1345
  addEventIDUpdateListener: (a) => (s(f.broadcastResources), typeof a != "function" ? !1 : (E.add(a), !0)),
@@ -1323,7 +1362,7 @@ function Ae(A, q) {
1323
1362
  const k = JSON.parse(T);
1324
1363
  return h.split(",").map((w) => k[w] ?? null);
1325
1364
  }
1326
- return Iq(a, h, p);
1365
+ return Iq(a, h, y);
1327
1366
  },
1328
1367
  writePersistentArray: (a, h, T) => {
1329
1368
  s(f.persistentStorage);
@@ -1336,19 +1375,19 @@ function Ae(A, q) {
1336
1375
  }), V = new Xq({
1337
1376
  target: A,
1338
1377
  adapter: q.mediaPlaneAdapter,
1339
- canUseBroadcastMedia: () => c.permits(
1378
+ canUseBroadcastMedia: () => l.permits(
1340
1379
  f.broadcastMedia
1341
1380
  ),
1342
- installBroadcastObjectApi: M.installBroadcastObjectApi,
1343
- postRuntime: o
1381
+ installBroadcastObjectApi: b.installBroadcastObjectApi,
1382
+ postRuntime: n
1344
1383
  });
1345
1384
  const g = () => {
1346
- c.startDocument(), V.startDocument();
1385
+ te(A), l.startDocument(), V.startDocument();
1347
1386
  };
1348
- o("installed", { url: A.location.href }), A.document.readyState === "loading" ? A.document.addEventListener("DOMContentLoaded", g, { once: !0 }) : queueMicrotask(g), c.startNavigationCapture(), V.startObserving(), A.addEventListener("pagehide", () => {
1349
- V.dispose("document-unload", () => m.dispose()), c.dispose(), e?.(), o("unloading", { url: A.location.href });
1387
+ n("installed", { url: A.location.href }), A.document.readyState === "loading" ? A.document.addEventListener("DOMContentLoaded", g, { once: !0 }) : queueMicrotask(g), l.startNavigationCapture(), V.startObserving(), A.addEventListener("pagehide", () => {
1388
+ V.dispose("document-unload", () => m.dispose()), l.dispose(), e?.(), n("unloading", { url: A.location.href });
1350
1389
  }), A.addEventListener("error", (a) => {
1351
- o("error", {
1390
+ n("error", {
1352
1391
  message: a.message
1353
1392
  });
1354
1393
  });
@@ -1393,7 +1432,7 @@ class me {
1393
1432
  })) : this.media.remove();
1394
1433
  }
1395
1434
  }
1396
- class ie {
1435
+ class re {
1397
1436
  renderMode = "external";
1398
1437
  surface;
1399
1438
  keepVisible;
@@ -1435,35 +1474,35 @@ class ie {
1435
1474
  });
1436
1475
  }
1437
1476
  }
1438
- function re(A, q) {
1477
+ function ne(A, q) {
1439
1478
  const e = A.contentWindow;
1440
1479
  if (!e || !Number.isInteger(q)) return !1;
1441
1480
  try {
1442
1481
  const t = e, i = e.document, r = i.activeElement ?? i.body ?? i.documentElement ?? i;
1443
- for (const n of ["keydown", "keyup"]) {
1444
- const o = new t.KeyboardEvent(n, {
1482
+ for (const o of ["keydown", "keyup"]) {
1483
+ const n = new t.KeyboardEvent(o, {
1445
1484
  bubbles: !0,
1446
1485
  cancelable: !0,
1447
1486
  view: e
1448
1487
  });
1449
- Object.defineProperties(o, {
1488
+ Object.defineProperties(n, {
1450
1489
  keyCode: { value: q },
1451
1490
  which: { value: q }
1452
- }), r.dispatchEvent(o);
1491
+ }), r.dispatchEvent(n);
1453
1492
  }
1454
1493
  return !0;
1455
1494
  } catch {
1456
1495
  return !1;
1457
1496
  }
1458
1497
  }
1459
- function ne(A) {
1498
+ function oe(A) {
1460
1499
  return {
1461
1500
  ...A,
1462
1501
  program: A.program ? D(A.program) : void 0
1463
1502
  };
1464
1503
  }
1465
- async function oe(A, q, e) {
1466
- const t = ne(A);
1504
+ async function ae(A, q, e) {
1505
+ const t = oe(A);
1467
1506
  if (!q)
1468
1507
  return e?.({ request: t, reason: "unsupported" }), !1;
1469
1508
  try {
@@ -1472,7 +1511,7 @@ async function oe(A, q, e) {
1472
1511
  return e?.({ request: t, reason: "error", error: i }), !1;
1473
1512
  }
1474
1513
  }
1475
- class ae {
1514
+ class se {
1476
1515
  state = {
1477
1516
  visible: !0,
1478
1517
  inputActive: !1
@@ -1505,18 +1544,18 @@ class ae {
1505
1544
  return this.delivered.has(e) ? null : (this.delivered.add(e), { ...q, requiresUserAction: !0 });
1506
1545
  }
1507
1546
  }
1508
- function se(A) {
1547
+ function Ve(A) {
1509
1548
  const q = Number(A.width), e = Number(A.height);
1510
1549
  return !Number.isSafeInteger(q) || q <= 0 || !Number.isSafeInteger(e) || e <= 0 ? null : { width: q, height: e };
1511
1550
  }
1512
- function Ve(A) {
1551
+ function le(A) {
1513
1552
  const q = String(A ?? "");
1514
1553
  return q && q !== "rgba(0, 0, 0, 0)" && q !== "transparent" ? q : null;
1515
1554
  }
1516
- function le(A) {
1555
+ function ce(A) {
1517
1556
  return Array.isArray(A) ? [...new Set(A.map(Number).filter((q) => Number.isInteger(q) && q >= 0 && q <= 65535))] : [];
1518
1557
  }
1519
- function ce(A) {
1558
+ function de(A) {
1520
1559
  const q = Number(A.organizationId), e = Number(A.applicationId), t = {
1521
1560
  organizationId: q,
1522
1561
  applicationId: e,
@@ -1534,7 +1573,7 @@ function K(A) {
1534
1573
  externalPlacement: q.externalPlacement === "above-application" ? "above-application" : "behind-application"
1535
1574
  };
1536
1575
  }
1537
- function de(A, q) {
1576
+ function he(A, q) {
1538
1577
  return A.visible ? {
1539
1578
  slotId: String(A.slotId ?? ""),
1540
1579
  visible: !0,
@@ -1559,16 +1598,16 @@ function de(A, q) {
1559
1598
  layer: K(A.layer)
1560
1599
  };
1561
1600
  }
1562
- function he(A) {
1601
+ function ue(A) {
1563
1602
  if (A === null) return null;
1564
1603
  if (!Number.isInteger(A) || A < 0 || A > 16777215)
1565
1604
  throw new RangeError("LCT backgroundColorRgb must be a 24-bit integer or null");
1566
1605
  return `#${A.toString(16).padStart(6, "0")}`;
1567
1606
  }
1568
- function ue(A, q) {
1607
+ function ge(A, q) {
1569
1608
  return A ?? q ?? "#000";
1570
1609
  }
1571
- class ge {
1610
+ class pe {
1572
1611
  iframe;
1573
1612
  viewport;
1574
1613
  resizeObserver;
@@ -1585,7 +1624,7 @@ class ge {
1585
1624
  return { width: this.logicalWidth, height: this.logicalHeight };
1586
1625
  }
1587
1626
  setLctBackgroundColor(q) {
1588
- this.lctBackgroundColor = he(q), this.applyBackgroundColor();
1627
+ this.lctBackgroundColor = ue(q), this.applyBackgroundColor();
1589
1628
  }
1590
1629
  setStageBackgroundColor(q) {
1591
1630
  this.stageBackgroundColor = q, this.applyBackgroundColor();
@@ -1607,13 +1646,13 @@ class ge {
1607
1646
  this.resizeObserver.disconnect();
1608
1647
  }
1609
1648
  applyBackgroundColor() {
1610
- this.viewport.style.backgroundColor = ue(
1649
+ this.viewport.style.backgroundColor = ge(
1611
1650
  this.lctBackgroundColor,
1612
1651
  this.stageBackgroundColor
1613
1652
  );
1614
1653
  }
1615
1654
  }
1616
- class pe {
1655
+ class ye {
1617
1656
  ownerWindow;
1618
1657
  iframe;
1619
1658
  origin;
@@ -1708,7 +1747,7 @@ class Te {
1708
1747
  bmlGreg;
1709
1748
  userAgent;
1710
1749
  onViewerParticipation;
1711
- viewerParticipation = new ae();
1750
+ viewerParticipation = new se();
1712
1751
  canvas;
1713
1752
  runtimeSession;
1714
1753
  captionComponentTags = [];
@@ -1722,7 +1761,7 @@ class Te {
1722
1761
  constructor(q) {
1723
1762
  if (this.iframe = q.iframe, this.viewport = q.viewport, this.videoSurface = q.videoSurface, Z(this.iframe), this.ownerWindow = this.iframe.ownerDocument.defaultView ?? window, this.origin = this.ownerWindow.location.origin, this.onStatus = q.onStatus, this.onLifecycle = q.onLifecycle, this.applicationLoadTimeoutMs = q.applicationLoadTimeoutMs ?? 5e3, !Number.isFinite(this.applicationLoadTimeoutMs) || this.applicationLoadTimeoutMs < 0)
1724
1763
  throw new TypeError("applicationLoadTimeoutMs must be a finite non-negative number");
1725
- this.onUrlChange = q.onUrlChange, this.onMediaPlane = q.onMediaPlane, this.onVideoPlane = q.onVideoPlane, this.mediaPlaneAdapter = q.mediaPlaneAdapter ?? (q.videoSurface ? new ie({
1764
+ this.onUrlChange = q.onUrlChange, this.onMediaPlane = q.onMediaPlane, this.onVideoPlane = q.onVideoPlane, this.mediaPlaneAdapter = q.mediaPlaneAdapter ?? (q.videoSurface ? new re({
1726
1765
  surface: q.videoSurface,
1727
1766
  keepVisible: q.keepVideoVisible
1728
1767
  }) : void 0);
@@ -1743,10 +1782,10 @@ class Te {
1743
1782
  this.ownerWindow.location.href
1744
1783
  ), this.broadcastBaseUrl.origin !== this.origin)
1745
1784
  throw new Error(`Broadcast base URL must be same-origin: ${this.broadcastBaseUrl.href}`);
1746
- this.resourceStore = q.resourceStore, this.onOpenProgramGuide = q.onOpenProgramGuide, this.onCaptionSubscription = q.onCaptionSubscription, this.onReplaceApplication = q.onReplaceApplication, this.onExitManagedState = q.onExitManagedState, this.onLaunchDataBroadcastingBrowser = q.onLaunchDataBroadcastingBrowser, this.onProgramGuideUnavailable = q.onProgramGuideUnavailable, this.systemInformation = q.systemInformation, this.getDeviceIdentifier = q.getDeviceIdentifier, this.bmlGreg = [...q.bmlGreg ?? []], this.userAgent = q.userAgent, this.onViewerParticipation = q.onViewerParticipation, this.ownerWindow.addEventListener("message", this.handleRuntimeMessage), this.iframe.addEventListener("load", this.handleFrameLoad), this.canvas = new ge({
1785
+ this.resourceStore = q.resourceStore, this.onOpenProgramGuide = q.onOpenProgramGuide, this.onCaptionSubscription = q.onCaptionSubscription, this.onReplaceApplication = q.onReplaceApplication, this.onExitManagedState = q.onExitManagedState, this.onLaunchDataBroadcastingBrowser = q.onLaunchDataBroadcastingBrowser, this.onProgramGuideUnavailable = q.onProgramGuideUnavailable, this.systemInformation = q.systemInformation, this.getDeviceIdentifier = q.getDeviceIdentifier, this.bmlGreg = [...q.bmlGreg ?? []], this.userAgent = q.userAgent, this.onViewerParticipation = q.onViewerParticipation, this.ownerWindow.addEventListener("message", this.handleRuntimeMessage), this.iframe.addEventListener("load", this.handleFrameLoad), this.canvas = new pe({
1747
1786
  iframe: this.iframe,
1748
1787
  viewport: this.viewport
1749
- }), this.runtimeSession = new pe({
1788
+ }), this.runtimeSession = new ye({
1750
1789
  ownerWindow: this.ownerWindow,
1751
1790
  iframe: this.iframe,
1752
1791
  origin: this.origin,
@@ -1755,7 +1794,7 @@ class Te {
1755
1794
  });
1756
1795
  }
1757
1796
  installRuntime(q) {
1758
- this.mediaPlaneEnabled = !this.destroyed && !this.applicationExited, te(q, {
1797
+ this.mediaPlaneEnabled = !this.destroyed && !this.applicationExited, Ae(q, {
1759
1798
  allowExternalNetwork: this.allowExternalNetwork,
1760
1799
  broadcastBaseUrl: this.broadcastBaseUrl.href,
1761
1800
  resourceStore: this.resourceStore,
@@ -1810,7 +1849,7 @@ class Te {
1810
1849
  this.assertAlive(), !this.applicationExited && (this.applicationExited = !0, this.viewerParticipation.setPresentation({ visible: !1, inputActive: !1 }), this.runtimeSession.clearPendingStreamEvents(), this.runtimeSession.clearWatchdog(), this.invalidateRuntime("application-exit"), this.iframe.style.display = "none", this.iframe.src = "about:blank", this.onUrlChange?.(""), this.onStatus?.(q), this.onLifecycle?.({ type: "exited" }));
1811
1850
  }
1812
1851
  dispatchKey(q) {
1813
- return this.assertAlive(), this.viewerParticipation.presentation.inputActive ? re(this.iframe, q) ? !0 : (this.onStatus?.("キー入力を送信できません"), !1) : !1;
1852
+ return this.assertAlive(), this.viewerParticipation.presentation.inputActive ? ne(this.iframe, q) ? !0 : (this.onStatus?.("キー入力を送信できません"), !1) : !1;
1814
1853
  }
1815
1854
  /** Transfer or release receiver-key ownership for the broadcast application. */
1816
1855
  setApplicationInputActive(q) {
@@ -1858,7 +1897,7 @@ class Te {
1858
1897
  openProgramGuide(q = {
1859
1898
  destination: "program-guide"
1860
1899
  }) {
1861
- return this.assertAlive(), oe(
1900
+ return this.assertAlive(), ae(
1862
1901
  q,
1863
1902
  this.onOpenProgramGuide,
1864
1903
  this.reportProgramGuideUnavailable
@@ -1971,12 +2010,12 @@ class Te {
1971
2010
  return;
1972
2011
  case "stage-style": {
1973
2012
  this.canvas.setStageBackgroundColor(
1974
- Ve(e.backgroundColor)
2013
+ le(e.backgroundColor)
1975
2014
  );
1976
2015
  return;
1977
2016
  }
1978
2017
  case "screen-size": {
1979
- const t = se(e);
2018
+ const t = Ve(e);
1980
2019
  t && this.canvas.applyScreenSize(t.width, t.height);
1981
2020
  return;
1982
2021
  }
@@ -1985,7 +2024,7 @@ class Te {
1985
2024
  this.applyMediaPlane(e);
1986
2025
  return;
1987
2026
  case "caption-subscription": {
1988
- const t = le(e.componentTags);
2027
+ const t = ce(e.componentTags);
1989
2028
  this.onCaptionSubscription?.({ componentTags: t });
1990
2029
  return;
1991
2030
  }
@@ -1996,7 +2035,7 @@ class Te {
1996
2035
  });
1997
2036
  return;
1998
2037
  case "replace-application": {
1999
- const t = ce(e);
2038
+ const t = de(e);
2000
2039
  if (!t) {
2001
2040
  this.onStatus?.("不正なアプリケーション切替要求を拒否しました");
2002
2041
  return;
@@ -2043,7 +2082,7 @@ class Te {
2043
2082
  }
2044
2083
  };
2045
2084
  applyMediaPlane(q) {
2046
- const e = this.canvas.logicalSize, t = de(q, {
2085
+ const e = this.canvas.logicalSize, t = he(q, {
2047
2086
  screenWidth: e.width,
2048
2087
  screenHeight: e.height
2049
2088
  });
@@ -2072,11 +2111,8 @@ class Te {
2072
2111
  function U(A) {
2073
2112
  return `/${(A || "/data-broadcast/").replace(/^\/+|\/+$/g, "")}/`;
2074
2113
  }
2075
- function ye(A) {
2076
- return A.replace(/<object\b[^>]*>/gi, (q) => /\btype\s*=\s*(?:["']video\/x-arib2-broadcast["']|video\/x-arib2-broadcast)(?:\s|\/?>)/i.test(q) ? q.replace(
2077
- /\s+type\s*=\s*(?:["']video\/x-arib2-broadcast["']|video\/x-arib2-broadcast)/i,
2078
- ' data-arib-type="video/x-arib2-broadcast"'
2079
- ).replace(/\s+data\s*=\s*(["'])(.*?)\1/i, " data-arib-data=$1$2$1") : q);
2114
+ function Be(A) {
2115
+ return A;
2080
2116
  }
2081
2117
  function G(A, q, e) {
2082
2118
  if (A.startsWith(e)) return A;
@@ -2087,27 +2123,27 @@ function Ee(A, q, e) {
2087
2123
  const t = U(q), i = U(e ?? q);
2088
2124
  return A.replace(
2089
2125
  /(\b(?:href|src|action|poster)\s*=\s*)(?:(['"])(\/[^/][^"']*)\2|(\/[^\s>]*))/gi,
2090
- (r, n, o, c, s) => {
2091
- const y = c ?? s;
2092
- if (!y || y.startsWith(t)) return r;
2093
- const E = G(y, t, i);
2094
- return o ? `${n}${o}${E}${o}` : `${n}${E}`;
2126
+ (r, o, n, l, s) => {
2127
+ const p = l ?? s;
2128
+ if (!p || p.startsWith(t)) return r;
2129
+ const E = G(p, t, i);
2130
+ return n ? `${o}${n}${E}${n}` : `${o}${E}`;
2095
2131
  }
2096
2132
  );
2097
2133
  }
2098
- function Be(A, q = {}) {
2134
+ function ve(A, q = {}) {
2099
2135
  const e = U(q.basePath), t = U(q.scopePath ?? q.basePath);
2100
2136
  return A.replace(
2101
2137
  /url\(\s*(["']?)(\/[^/)][^)]*)\1\s*\)/gi,
2102
- (i, r, n) => n.startsWith(e) ? i : `url(${r}${G(n, e, t)}${r})`
2138
+ (i, r, o) => o.startsWith(e) ? i : `url(${r}${G(o, e, t)}${r})`
2103
2139
  ).replace(
2104
2140
  /(@import\s+)(["'])(\/[^/][^"']*)\2/gi,
2105
- (i, r, n, o) => o.startsWith(e) ? i : `${r}${n}${G(o, e, t)}${n}`
2141
+ (i, r, o, n) => n.startsWith(e) ? i : `${r}${o}${G(n, e, t)}${o}`
2106
2142
  );
2107
2143
  }
2108
- function ve(A, q = {}) {
2144
+ function be(A, q = {}) {
2109
2145
  const e = Ee(
2110
- C(ye(A)),
2146
+ C(A),
2111
2147
  q.basePath,
2112
2148
  q.scopePath
2113
2149
  );
@@ -2207,7 +2243,7 @@ class Me {
2207
2243
  this.completedRevision >= e.revision ? e.resolve() : this.waiters.push(e);
2208
2244
  }
2209
2245
  }
2210
- class be {
2246
+ class ke {
2211
2247
  workerUrl;
2212
2248
  scopeUrl;
2213
2249
  uniqueBasenameFallback;
@@ -2287,13 +2323,13 @@ class be {
2287
2323
  async performRequestWithRegistration(q, e, t = []) {
2288
2324
  const i = q.active ?? q.waiting ?? q.installing;
2289
2325
  if (!i) throw new Error("Broadcast VFS worker is unavailable");
2290
- return new Promise((r, n) => {
2291
- const o = new MessageChannel(), c = window.setTimeout(() => {
2292
- o.port1.close(), n(new Error("Broadcast VFS worker did not respond"));
2326
+ return new Promise((r, o) => {
2327
+ const n = new MessageChannel(), l = window.setTimeout(() => {
2328
+ n.port1.close(), o(new Error("Broadcast VFS worker did not respond"));
2293
2329
  }, 5e3);
2294
- o.port1.onmessage = (s) => {
2295
- window.clearTimeout(c), o.port1.close(), s.data?.ok ? r(s.data) : n(new Error(s.data?.error || "Broadcast VFS worker error"));
2296
- }, i.postMessage(e, [o.port2, ...t]);
2330
+ n.port1.onmessage = (s) => {
2331
+ window.clearTimeout(l), n.port1.close(), s.data?.ok ? r(s.data) : o(new Error(s.data?.error || "Broadcast VFS worker error"));
2332
+ }, i.postMessage(e, [n.port2, ...t]);
2297
2333
  });
2298
2334
  }
2299
2335
  waitForActivation(q) {
@@ -2309,16 +2345,16 @@ class be {
2309
2345
  }
2310
2346
  export {
2311
2347
  f as ARIB_PERMISSION_BITS,
2312
- Oq as AribApplicationBoundaryPolicy,
2348
+ Nq as AribApplicationBoundaryPolicy,
2313
2349
  Te as AribReceiverHost,
2314
- ie as BehindIframeMediaPlaneAdapter,
2350
+ re as BehindIframeMediaPlaneAdapter,
2315
2351
  Me as BroadcastVfsSession,
2316
2352
  Tq as DEFAULT_BROADCAST_BASE_PATH,
2317
2353
  Y as DEFAULT_RECEIVER_DEVICE_IDENTIFIER,
2318
2354
  me as DomObjectMediaPlaneAdapter,
2319
2355
  Fq as RECEIVER_IRD_ID_TYPE,
2320
2356
  Rq as RECEIVER_SYSTEM_IDENTITY,
2321
- be as ServiceWorkerBroadcastVfs,
2357
+ ke as ServiceWorkerBroadcastVfs,
2322
2358
  D as cloneProgramInfo,
2323
2359
  Sq as createReceiverSystemInformation,
2324
2360
  C as deferRomSoundMarkup,
@@ -2327,17 +2363,17 @@ export {
2327
2363
  fq as installAribSymbolFont,
2328
2364
  mq as installBroadcastClock,
2329
2365
  uq as installRomSoundProtocol,
2330
- te as installRuntime,
2366
+ Ae as installRuntime,
2331
2367
  z as normalizeBroadcastBaseUrl,
2332
- he as normalizeLctBackgroundColor,
2368
+ ue as normalizeLctBackgroundColor,
2333
2369
  Ee as prefixBroadcastRootAttributes,
2334
- ve as prepareBroadcastHtml,
2335
- Be as prepareBroadcastStylesheet,
2370
+ be as prepareBroadcastHtml,
2371
+ ve as prepareBroadcastStylesheet,
2336
2372
  Iq as readReceiverInformationArray,
2337
2373
  H as resolveBroadcastUrl,
2338
2374
  Gq as resolveReceiverDeviceIdentifier,
2339
2375
  R as resolveRomSoundUrl,
2340
- ye as rewriteBroadcastObjectMarkup,
2376
+ Be as rewriteBroadcastObjectMarkup,
2341
2377
  Wq as runtimeEventMatchesSelector,
2342
2378
  Qq as synchronizeReceiverCompatibilityStorage
2343
2379
  };