@vouchfor/embeds 0.0.0-experiment.ab40ec5 → 0.0.0-experiment.ace6cf6

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.
@@ -9,9 +9,9 @@ declare class TrackingController implements ReactiveController {
9
9
  private _hasPlayed;
10
10
  private _hasLoaded;
11
11
  private _answersViewed;
12
- private _streamedTime;
12
+ private _streamStartTime;
13
13
  private _streamLatestTime;
14
- private _streamedPrevTimestamp;
14
+ private _currentlyPlayingVideo;
15
15
  constructor(host: EmbedHost);
16
16
  private _findVouchId;
17
17
  private _createVisitor;
@@ -21,7 +21,6 @@ declare class TrackingController implements ReactiveController {
21
21
  private _handleVouchLoaded;
22
22
  private _handlePlay;
23
23
  private _handleVideoPlay;
24
- private _handleVideoSeeking;
25
24
  private _handleVideoTimeUpdate;
26
25
  private _handleVideoPause;
27
26
  hostConnected(): void;
package/dist/es/embeds.js CHANGED
@@ -48,7 +48,7 @@ const ce = (r) => new le(typeof r == "string" ? r : r + "", void 0, Wt), de = (r
48
48
  * Copyright 2017 Google LLC
49
49
  * SPDX-License-Identifier: BSD-3-Clause
50
50
  */
51
- const { is: pe, defineProperty: ue, getOwnPropertyDescriptor: _e, getOwnPropertyNames: $e, getOwnPropertySymbols: me, getPrototypeOf: fe } = Object, E = globalThis, yt = E.trustedTypes, ge = yt ? yt.emptyScript : "", rt = E.reactiveElementPolyfillSupport, k = (r, t) => r, dt = { toAttribute(r, t) {
51
+ const { is: pe, defineProperty: ue, getOwnPropertyDescriptor: _e, getOwnPropertyNames: $e, getOwnPropertySymbols: me, getPrototypeOf: fe } = Object, E = globalThis, yt = E.trustedTypes, ge = yt ? yt.emptyScript : "", rt = E.reactiveElementPolyfillSupport, I = (r, t) => r, dt = { toAttribute(r, t) {
52
52
  switch (t) {
53
53
  case Boolean:
54
54
  r = r ? ge : null;
@@ -78,7 +78,7 @@ const { is: pe, defineProperty: ue, getOwnPropertyDescriptor: _e, getOwnProperty
78
78
  return e;
79
79
  } }, qt = (r, t) => !pe(r, t), At = { attribute: !0, type: String, converter: dt, reflect: !1, hasChanged: qt };
80
80
  Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), E.litPropertyMetadata ?? (E.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
81
- let M = class extends HTMLElement {
81
+ let L = class extends HTMLElement {
82
82
  static addInitializer(t) {
83
83
  this._$Ei(), (this.l ?? (this.l = [])).push(t);
84
84
  }
@@ -108,15 +108,15 @@ let M = class extends HTMLElement {
108
108
  return this.elementProperties.get(t) ?? At;
109
109
  }
110
110
  static _$Ei() {
111
- if (this.hasOwnProperty(k("elementProperties")))
111
+ if (this.hasOwnProperty(I("elementProperties")))
112
112
  return;
113
113
  const t = fe(this);
114
114
  t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
115
115
  }
116
116
  static finalize() {
117
- if (this.hasOwnProperty(k("finalized")))
117
+ if (this.hasOwnProperty(I("finalized")))
118
118
  return;
119
- if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(k("properties"))) {
119
+ if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(I("properties"))) {
120
120
  const e = this.properties, i = [...$e(e), ...me(e)];
121
121
  for (const s of i)
122
122
  this.createProperty(s, e[s]);
@@ -289,14 +289,14 @@ let M = class extends HTMLElement {
289
289
  firstUpdated(t) {
290
290
  }
291
291
  };
292
- M.elementStyles = [], M.shadowRootOptions = { mode: "open" }, M[k("elementProperties")] = /* @__PURE__ */ new Map(), M[k("finalized")] = /* @__PURE__ */ new Map(), rt == null || rt({ ReactiveElement: M }), (E.reactiveElementVersions ?? (E.reactiveElementVersions = [])).push("2.0.2");
292
+ L.elementStyles = [], L.shadowRootOptions = { mode: "open" }, L[I("elementProperties")] = /* @__PURE__ */ new Map(), L[I("finalized")] = /* @__PURE__ */ new Map(), rt == null || rt({ ReactiveElement: L }), (E.reactiveElementVersions ?? (E.reactiveElementVersions = [])).push("2.0.2");
293
293
  /**
294
294
  * @license
295
295
  * Copyright 2017 Google LLC
296
296
  * SPDX-License-Identifier: BSD-3-Clause
297
297
  */
298
298
  const V = globalThis, Y = V.trustedTypes, Et = Y ? Y.createPolicy("lit-html", { createHTML: (r) => r }) : void 0, Xt = "$lit$", y = `lit$${(Math.random() + "").slice(9)}$`, Kt = "?" + y, ve = `<${Kt}>`, U = document, Q = () => U.createComment(""), B = (r) => r === null || typeof r != "object" && typeof r != "function", Jt = Array.isArray, ye = (r) => Jt(r) || typeof (r == null ? void 0 : r[Symbol.iterator]) == "function", nt = `[
299
- \f\r]`, L = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, St = /-->/g, bt = />/g, b = RegExp(`>|${nt}(?:([^\\s"'>=/]+)(${nt}*=${nt}*(?:[^
299
+ \f\r]`, M = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, St = /-->/g, bt = />/g, b = RegExp(`>|${nt}(?:([^\\s"'>=/]+)(${nt}*=${nt}*(?:[^
300
300
  \f\r"'\`<>=]|("|')|))|$)`, "g"), wt = /'/g, Pt = /"/g, Ft = /^(?:script|style|textarea|title)$/i, W = Symbol.for("lit-noChange"), _ = Symbol.for("lit-nothing"), Ct = /* @__PURE__ */ new WeakMap(), C = U.createTreeWalker(U, 129);
301
301
  function Gt(r, t) {
302
302
  if (!Array.isArray(r) || !r.hasOwnProperty("raw"))
@@ -305,14 +305,14 @@ function Gt(r, t) {
305
305
  }
306
306
  const Ae = (r, t) => {
307
307
  const e = r.length - 1, i = [];
308
- let s, n = t === 2 ? "<svg>" : "", o = L;
308
+ let s, n = t === 2 ? "<svg>" : "", o = M;
309
309
  for (let a = 0; a < e; a++) {
310
310
  const h = r[a];
311
311
  let c, d, l = -1, p = 0;
312
312
  for (; p < h.length && (o.lastIndex = p, d = o.exec(h), d !== null); )
313
- p = o.lastIndex, o === L ? d[1] === "!--" ? o = St : d[1] !== void 0 ? o = bt : d[2] !== void 0 ? (Ft.test(d[2]) && (s = RegExp("</" + d[2], "g")), o = b) : d[3] !== void 0 && (o = b) : o === b ? d[0] === ">" ? (o = s ?? L, l = -1) : d[1] === void 0 ? l = -2 : (l = o.lastIndex - d[2].length, c = d[1], o = d[3] === void 0 ? b : d[3] === '"' ? Pt : wt) : o === Pt || o === wt ? o = b : o === St || o === bt ? o = L : (o = b, s = void 0);
313
+ p = o.lastIndex, o === M ? d[1] === "!--" ? o = St : d[1] !== void 0 ? o = bt : d[2] !== void 0 ? (Ft.test(d[2]) && (s = RegExp("</" + d[2], "g")), o = b) : d[3] !== void 0 && (o = b) : o === b ? d[0] === ">" ? (o = s ?? M, l = -1) : d[1] === void 0 ? l = -2 : (l = o.lastIndex - d[2].length, c = d[1], o = d[3] === void 0 ? b : d[3] === '"' ? Pt : wt) : o === Pt || o === wt ? o = b : o === St || o === bt ? o = M : (o = b, s = void 0);
314
314
  const u = o === b && r[a + 1].startsWith("/>") ? " " : "";
315
- n += o === L ? h + ve : l >= 0 ? (i.push(c), h.slice(0, l) + Xt + h.slice(l) + y + u) : h + y + (l === -2 ? a : u);
315
+ n += o === M ? h + ve : l >= 0 ? (i.push(c), h.slice(0, l) + Xt + h.slice(l) + y + u) : h + y + (l === -2 ? a : u);
316
316
  }
317
317
  return [Gt(r, n + (r[e] || "<?>") + (t === 2 ? "</svg>" : "")), i];
318
318
  };
@@ -571,10 +571,10 @@ const Te = (r) => new Ce(typeof r == "string" ? r : r + "", void 0, te), Ue = (r
571
571
  * Copyright 2017 Google LLC
572
572
  * SPDX-License-Identifier: BSD-3-Clause
573
573
  */
574
- const { is: Re, defineProperty: xe, getOwnPropertyDescriptor: He, getOwnPropertyNames: Oe, getOwnPropertySymbols: Ne, getPrototypeOf: Me } = Object, S = globalThis, Rt = S.trustedTypes, Le = Rt ? Rt.emptyScript : "", ht = S.reactiveElementPolyfillSupport, D = (r, t) => r, ut = { toAttribute(r, t) {
574
+ const { is: Re, defineProperty: xe, getOwnPropertyDescriptor: He, getOwnPropertyNames: Oe, getOwnPropertySymbols: Ne, getPrototypeOf: Le } = Object, S = globalThis, Rt = S.trustedTypes, Me = Rt ? Rt.emptyScript : "", ht = S.reactiveElementPolyfillSupport, D = (r, t) => r, ut = { toAttribute(r, t) {
575
575
  switch (t) {
576
576
  case Boolean:
577
- r = r ? Le : null;
577
+ r = r ? Me : null;
578
578
  break;
579
579
  case Object:
580
580
  case Array:
@@ -633,7 +633,7 @@ class x extends HTMLElement {
633
633
  static _$Ei() {
634
634
  if (this.hasOwnProperty(D("elementProperties")))
635
635
  return;
636
- const t = Me(this);
636
+ const t = Le(this);
637
637
  t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
638
638
  }
639
639
  static finalize() {
@@ -818,9 +818,9 @@ x.elementStyles = [], x.shadowRootOptions = { mode: "open" }, x[D("elementProper
818
818
  * Copyright 2017 Google LLC
819
819
  * SPDX-License-Identifier: BSD-3-Clause
820
820
  */
821
- const z = globalThis, tt = z.trustedTypes, Ht = tt ? tt.createPolicy("lit-html", { createHTML: (r) => r }) : void 0, ie = "$lit$", A = `lit$${(Math.random() + "").slice(9)}$`, se = "?" + A, Ie = `<${se}>`, R = document, q = () => R.createComment(""), X = (r) => r === null || typeof r != "object" && typeof r != "function", re = Array.isArray, ke = (r) => re(r) || typeof (r == null ? void 0 : r[Symbol.iterator]) == "function", at = `[
822
- \f\r]`, I = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, Ot = /-->/g, Nt = />/g, w = RegExp(`>|${at}(?:([^\\s"'>=/]+)(${at}*=${at}*(?:[^
823
- \f\r"'\`<>=]|("|')|))|$)`, "g"), Mt = /'/g, Lt = /"/g, ne = /^(?:script|style|textarea|title)$/i, Ve = (r) => (t, ...e) => ({ _$litType$: r, strings: t, values: e }), De = Ve(1), O = Symbol.for("lit-noChange"), $ = Symbol.for("lit-nothing"), It = /* @__PURE__ */ new WeakMap(), T = R.createTreeWalker(R, 129);
821
+ const z = globalThis, tt = z.trustedTypes, Ht = tt ? tt.createPolicy("lit-html", { createHTML: (r) => r }) : void 0, ie = "$lit$", A = `lit$${(Math.random() + "").slice(9)}$`, se = "?" + A, ke = `<${se}>`, R = document, q = () => R.createComment(""), X = (r) => r === null || typeof r != "object" && typeof r != "function", re = Array.isArray, Ie = (r) => re(r) || typeof (r == null ? void 0 : r[Symbol.iterator]) == "function", at = `[
822
+ \f\r]`, k = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, Ot = /-->/g, Nt = />/g, w = RegExp(`>|${at}(?:([^\\s"'>=/]+)(${at}*=${at}*(?:[^
823
+ \f\r"'\`<>=]|("|')|))|$)`, "g"), Lt = /'/g, Mt = /"/g, ne = /^(?:script|style|textarea|title)$/i, Ve = (r) => (t, ...e) => ({ _$litType$: r, strings: t, values: e }), De = Ve(1), O = Symbol.for("lit-noChange"), $ = Symbol.for("lit-nothing"), kt = /* @__PURE__ */ new WeakMap(), T = R.createTreeWalker(R, 129);
824
824
  function oe(r, t) {
825
825
  if (!Array.isArray(r) || !r.hasOwnProperty("raw"))
826
826
  throw Error("invalid template strings array");
@@ -828,14 +828,14 @@ function oe(r, t) {
828
828
  }
829
829
  const ze = (r, t) => {
830
830
  const e = r.length - 1, i = [];
831
- let s, n = t === 2 ? "<svg>" : "", o = I;
831
+ let s, n = t === 2 ? "<svg>" : "", o = k;
832
832
  for (let a = 0; a < e; a++) {
833
833
  const h = r[a];
834
834
  let c, d, l = -1, p = 0;
835
835
  for (; p < h.length && (o.lastIndex = p, d = o.exec(h), d !== null); )
836
- p = o.lastIndex, o === I ? d[1] === "!--" ? o = Ot : d[1] !== void 0 ? o = Nt : d[2] !== void 0 ? (ne.test(d[2]) && (s = RegExp("</" + d[2], "g")), o = w) : d[3] !== void 0 && (o = w) : o === w ? d[0] === ">" ? (o = s ?? I, l = -1) : d[1] === void 0 ? l = -2 : (l = o.lastIndex - d[2].length, c = d[1], o = d[3] === void 0 ? w : d[3] === '"' ? Lt : Mt) : o === Lt || o === Mt ? o = w : o === Ot || o === Nt ? o = I : (o = w, s = void 0);
836
+ p = o.lastIndex, o === k ? d[1] === "!--" ? o = Ot : d[1] !== void 0 ? o = Nt : d[2] !== void 0 ? (ne.test(d[2]) && (s = RegExp("</" + d[2], "g")), o = w) : d[3] !== void 0 && (o = w) : o === w ? d[0] === ">" ? (o = s ?? k, l = -1) : d[1] === void 0 ? l = -2 : (l = o.lastIndex - d[2].length, c = d[1], o = d[3] === void 0 ? w : d[3] === '"' ? Mt : Lt) : o === Mt || o === Lt ? o = w : o === Ot || o === Nt ? o = k : (o = w, s = void 0);
837
837
  const u = o === w && r[a + 1].startsWith("/>") ? " " : "";
838
- n += o === I ? h + Ie : l >= 0 ? (i.push(c), h.slice(0, l) + ie + h.slice(l) + A + u) : h + A + (l === -2 ? a : u);
838
+ n += o === k ? h + ke : l >= 0 ? (i.push(c), h.slice(0, l) + ie + h.slice(l) + A + u) : h + A + (l === -2 ? a : u);
839
839
  }
840
840
  return [oe(r, n + (r[e] || "<?>") + (t === 2 ? "</svg>" : "")), i];
841
841
  };
@@ -940,7 +940,7 @@ class J {
940
940
  return this._$AB;
941
941
  }
942
942
  _$AI(t, e = this) {
943
- t = N(this, t, e), X(t) ? t === $ || t == null || t === "" ? (this._$AH !== $ && this._$AR(), this._$AH = $) : t !== this._$AH && t !== O && this._(t) : t._$litType$ !== void 0 ? this.g(t) : t.nodeType !== void 0 ? this.$(t) : ke(t) ? this.T(t) : this._(t);
943
+ t = N(this, t, e), X(t) ? t === $ || t == null || t === "" ? (this._$AH !== $ && this._$AR(), this._$AH = $) : t !== this._$AH && t !== O && this._(t) : t._$litType$ !== void 0 ? this.g(t) : t.nodeType !== void 0 ? this.$(t) : Ie(t) ? this.T(t) : this._(t);
944
944
  }
945
945
  k(t) {
946
946
  return this._$AA.parentNode.insertBefore(t, this._$AB);
@@ -962,8 +962,8 @@ class J {
962
962
  }
963
963
  }
964
964
  _$AC(t) {
965
- let e = It.get(t.strings);
966
- return e === void 0 && It.set(t.strings, e = new K(t)), e;
965
+ let e = kt.get(t.strings);
966
+ return e === void 0 && kt.set(t.strings, e = new K(t)), e;
967
967
  }
968
968
  T(t) {
969
969
  re(this._$AH) || (this._$AH = [], this._$AR());
@@ -1128,19 +1128,19 @@ class Fe {
1128
1128
  }), this._cleanup = [];
1129
1129
  }
1130
1130
  }
1131
- const kt = "https://d2rxhdlm2q91uk.cloudfront.net", Ge = "https://d1ix11aj5kfygl.cloudfront.net", Ze = "https://d157jlwnudd93d.cloudfront.net", Vt = "https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws.com/dev", Ye = "https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging", Qe = "https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod", ti = "http://localhost:6060/v2", ei = "https://embed-dev.vouchfor.com/v2", ii = "https://embed-staging.vouchfor.com/v2", si = "https://embed.vouchfor.com/v2";
1131
+ const It = "https://d2rxhdlm2q91uk.cloudfront.net", Ge = "https://d1ix11aj5kfygl.cloudfront.net", Ze = "https://d157jlwnudd93d.cloudfront.net", Vt = "https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws.com/dev", Ye = "https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging", Qe = "https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod", ti = "http://localhost:6060/v2", ei = "https://embed-dev.vouchfor.com/v2", ii = "https://embed-staging.vouchfor.com/v2", si = "https://embed.vouchfor.com/v2";
1132
1132
  function et(r) {
1133
1133
  if (!["local", "dev", "staging", "prod"].includes(r))
1134
1134
  throw new Error(`Unknown environment: ${r}`);
1135
1135
  if (r === "local")
1136
1136
  return {
1137
- videoUrl: kt,
1137
+ videoUrl: It,
1138
1138
  publicApiUrl: Vt,
1139
1139
  embedApiUrl: ti
1140
1140
  };
1141
1141
  if (r === "dev")
1142
1142
  return {
1143
- videoUrl: kt,
1143
+ videoUrl: It,
1144
1144
  publicApiUrl: Vt,
1145
1145
  embedApiUrl: ei
1146
1146
  };
@@ -1223,10 +1223,10 @@ class ri {
1223
1223
  return this._fetching;
1224
1224
  }
1225
1225
  }
1226
- const ni = 1e4;
1226
+ const ni = 10;
1227
1227
  class oi {
1228
1228
  constructor(t) {
1229
- this._tabId = void 0, this._clientId = void 0, this._visitorId = void 0, this._hasPlayed = !1, this._hasLoaded = {}, this._answersViewed = {}, this._streamedTime = {}, this._streamLatestTime = {}, this._streamedPrevTimestamp = {}, this._createVisitor = (e) => {
1229
+ this._tabId = void 0, this._clientId = void 0, this._visitorId = void 0, this._hasPlayed = !1, this._hasLoaded = {}, this._answersViewed = {}, this._streamStartTime = {}, this._streamLatestTime = {}, this._currentlyPlayingVideo = null, this._createVisitor = (e) => {
1230
1230
  var s, n;
1231
1231
  const { publicApiUrl: i } = et(this.host.env);
1232
1232
  return (n = (s = window.localStorage) == null ? void 0 : s.setItem) == null || n.call(s, "vouch-uid-visitor", e), navigator.sendBeacon(`${i}/api/visitor`, JSON.stringify({ visitorId: e })), e;
@@ -1250,67 +1250,48 @@ class oi {
1250
1250
  ...s
1251
1251
  };
1252
1252
  }, this._sendTrackingEvent = (e, i) => {
1253
- const { publicApiUrl: s } = et(this.host.env), { client: n, tab: o, request: a, visitor: h } = this._getUids();
1254
- this.host.disableTracking || navigator.sendBeacon(
1255
- `${s}/api/events`,
1253
+ if (!this._findVouchId() || this.host.disableTracking)
1254
+ return;
1255
+ const { publicApiUrl: n } = et(this.host.env), { client: o, tab: a, request: h, visitor: c } = this._getUids();
1256
+ navigator.sendBeacon(
1257
+ `${n}/api/events`,
1256
1258
  JSON.stringify({
1257
1259
  event: e,
1258
1260
  payload: i,
1259
1261
  context: {
1260
- "x-uid-client": n,
1261
- "x-uid-tab": o,
1262
- "x-uid-request": a,
1263
- "x-uid-visitor": h,
1262
+ "x-uid-client": o,
1263
+ "x-uid-tab": a,
1264
+ "x-uid-request": h,
1265
+ "x-uid-visitor": c,
1264
1266
  "x-reporting-metadata": this._getReportingMetadata()
1265
1267
  }
1266
1268
  })
1267
1269
  );
1268
1270
  }, this._handleVouchLoaded = ({ detail: e }) => {
1269
- e && (this._hasLoaded[e] || (this._sendTrackingEvent("VOUCH_LOADED", {
1270
- vouchId: e
1271
- }), this._hasLoaded[e] = !0));
1271
+ e && (this._hasLoaded[e] || (this._sendTrackingEvent("VOUCH_LOADED"), this._hasLoaded[e] = !0));
1272
1272
  }, this._handlePlay = () => {
1273
- const e = this._findVouchId();
1274
- e && (this._hasPlayed || (this._sendTrackingEvent("VIDEO_PLAYED", {
1275
- vouchId: e,
1273
+ this._hasPlayed || (this._sendTrackingEvent("VIDEO_PLAYED", {
1276
1274
  streamStart: this.host.currentTime
1277
- }), this._hasPlayed = !0));
1275
+ }), this._hasPlayed = !0);
1278
1276
  }, this._handleVideoPlay = ({ detail: { id: e, key: i, node: s } }) => {
1279
- const n = this._findVouchId();
1280
- n && (this._answersViewed[i] || (this._sendTrackingEvent("VOUCH_RESPONSE_VIEWED", {
1281
- vouchId: n,
1277
+ this._answersViewed[i] || (this._sendTrackingEvent("VOUCH_RESPONSE_VIEWED", {
1282
1278
  answerId: e
1283
- }), this._answersViewed[i] = !0), this._streamedTime[i] = s.currentTime, this._streamLatestTime[i] = s.currentTime, this._streamedPrevTimestamp[i] = Date.now());
1284
- }, this._handleVideoSeeking = ({ detail: { id: e, key: i } }) => {
1285
- const s = this._findVouchId();
1286
- s && (this._streamLatestTime[i] && this._sendTrackingEvent("VIDEO_STREAMED", {
1287
- vouchId: s,
1288
- answerId: e,
1289
- streamStart: this._streamedTime[i],
1290
- streamEnd: this._streamLatestTime[i]
1291
- }), delete this._streamedTime[i], delete this._streamLatestTime[i], delete this._streamedPrevTimestamp[i]);
1279
+ }), this._answersViewed[i] = !0), this._streamStartTime[i] = s.currentTime, this._streamLatestTime[i] = s.currentTime;
1292
1280
  }, this._handleVideoTimeUpdate = ({ detail: { id: e, key: i, node: s } }) => {
1293
- var a, h;
1294
- const n = this._findVouchId();
1295
- if (!n)
1296
- return;
1297
- const o = Date.now();
1298
- s.currentTime && !s.paused && !this.host.paused && // Only fire the video seeked event when this video is the active one
1299
- e === ((h = (a = this.host.scene) == null ? void 0 : a.video) == null ? void 0 : h.id) && // Throttle the frequency that we send streamed events while playing
1300
- o - this._streamedPrevTimestamp[i] > ni && (this._sendTrackingEvent("VIDEO_STREAMED", {
1301
- vouchId: n,
1281
+ var n, o;
1282
+ this.host.paused || (this._currentlyPlayingVideo = { id: e, key: i, node: s }, this._streamLatestTime[i] = s.currentTime), !s.paused && !this.host.paused && // Only fire the video seeked event when this video is the active one
1283
+ e === ((o = (n = this.host.scene) == null ? void 0 : n.video) == null ? void 0 : o.id) && // Throttle the frequency that we send streamed events while playing
1284
+ this._streamLatestTime[i] - this._streamStartTime[i] > ni && (this._sendTrackingEvent("VIDEO_STREAMED", {
1302
1285
  answerId: e,
1303
- streamStart: this._streamedTime[i],
1304
- streamEnd: s.currentTime
1305
- }), this._streamedTime[i] = s.currentTime, this._streamedPrevTimestamp[i] = o), this._streamLatestTime[i] = s.currentTime;
1306
- }, this._handleVideoPause = ({ detail: { id: e, key: i, node: s } }) => {
1307
- const n = this._findVouchId();
1308
- n && (s.currentTime > this._streamedTime[i] && this._sendTrackingEvent("VIDEO_STREAMED", {
1309
- vouchId: n,
1286
+ streamStart: this._streamStartTime[i],
1287
+ streamEnd: this._streamLatestTime[i]
1288
+ }), this._streamStartTime[i] = s.currentTime);
1289
+ }, this._handleVideoPause = ({ detail: { id: e, key: i } }) => {
1290
+ this._streamLatestTime[i] > this._streamStartTime[i] && this._sendTrackingEvent("VIDEO_STREAMED", {
1310
1291
  answerId: e,
1311
- streamStart: this._streamedTime[i],
1312
- streamEnd: s.currentTime
1313
- }), delete this._streamedTime[i], delete this._streamLatestTime[i], delete this._streamedPrevTimestamp[i]);
1292
+ streamStart: this._streamStartTime[i],
1293
+ streamEnd: this._streamLatestTime[i]
1294
+ }), this._currentlyPlayingVideo = null, delete this._streamStartTime[i], delete this._streamLatestTime[i];
1314
1295
  }, this.host = t, t.addController(this);
1315
1296
  }
1316
1297
  _findVouchId() {
@@ -1335,13 +1316,21 @@ class oi {
1335
1316
  }
1336
1317
  hostConnected() {
1337
1318
  requestAnimationFrame(() => {
1338
- var t, e, i, s, n;
1339
- this.host.addEventListener("vouch:loaded", this._handleVouchLoaded), (t = this.host.mediaPlayer) == null || t.addEventListener("play", this._handlePlay), (e = this.host.mediaPlayer) == null || e.addEventListener("video:play", this._handleVideoPlay), (i = this.host.mediaPlayer) == null || i.addEventListener("video:seeking", this._handleVideoSeeking), (s = this.host.mediaPlayer) == null || s.addEventListener("video:pause", this._handleVideoPause), (n = this.host.mediaPlayer) == null || n.addEventListener("video:timeupdate", this._handleVideoTimeUpdate);
1319
+ var t, e, i, s;
1320
+ this.host.addEventListener("vouch:loaded", this._handleVouchLoaded), (t = this.host.mediaPlayer) == null || t.addEventListener("play", this._handlePlay), (e = this.host.mediaPlayer) == null || e.addEventListener("video:play", this._handleVideoPlay), (i = this.host.mediaPlayer) == null || i.addEventListener("video:pause", this._handleVideoPause), (s = this.host.mediaPlayer) == null || s.addEventListener("video:timeupdate", this._handleVideoTimeUpdate);
1340
1321
  });
1341
1322
  }
1342
1323
  hostDisconnected() {
1343
- var t, e, i, s, n;
1344
- this.host.removeEventListener("vouch:loaded", this._handleVouchLoaded), (t = this.host.mediaPlayer) == null || t.removeEventListener("play", this._handlePlay), (e = this.host.mediaPlayer) == null || e.removeEventListener("video:play", this._handleVideoPlay), (i = this.host.mediaPlayer) == null || i.removeEventListener("video:seeking", this._handleVideoSeeking), (s = this.host.mediaPlayer) == null || s.removeEventListener("video:pause", this._handleVideoPause), (n = this.host.mediaPlayer) == null || n.removeEventListener("video:timeupdate", this._handleVideoTimeUpdate);
1324
+ var t, e, i, s;
1325
+ if (this._currentlyPlayingVideo) {
1326
+ const { id: n, key: o } = this._currentlyPlayingVideo;
1327
+ this._streamLatestTime[o] > this._streamStartTime[o] && this._sendTrackingEvent("VIDEO_STREAMED", {
1328
+ answerId: n,
1329
+ streamStart: this._streamStartTime[o],
1330
+ streamEnd: this._streamLatestTime[o]
1331
+ });
1332
+ }
1333
+ this.host.removeEventListener("vouch:loaded", this._handleVouchLoaded), (t = this.host.mediaPlayer) == null || t.removeEventListener("play", this._handlePlay), (e = this.host.mediaPlayer) == null || e.removeEventListener("video:play", this._handleVideoPlay), (i = this.host.mediaPlayer) == null || i.removeEventListener("video:pause", this._handleVideoPause), (s = this.host.mediaPlayer) == null || s.removeEventListener("video:timeupdate", this._handleVideoTimeUpdate);
1345
1334
  }
1346
1335
  }
1347
1336
  var hi = Object.defineProperty, ai = Object.getOwnPropertyDescriptor, f = (r, t, e, i) => {