@vouchfor/embeds 0.0.0-experiment.8b3403f → 0.0.0-experiment.8b8f3c7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. package/dist/es/embeds.js +1012 -1091
  2. package/dist/es/embeds.js.map +1 -1
  3. package/dist/es/src/components/DialogEmbed/DialogOverlay.d.ts +20 -0
  4. package/dist/es/src/components/DialogEmbed/DialogPortal.d.ts +36 -0
  5. package/dist/es/src/components/DialogEmbed/index.d.ts +38 -0
  6. package/dist/es/{components/Embed → src/components/PlayerEmbed}/controllers/event-forwarder.d.ts +6 -5
  7. package/dist/es/{components/Embed → src/components/PlayerEmbed}/controllers/fetcher.d.ts +5 -4
  8. package/dist/es/src/components/PlayerEmbed/controllers/tracking/index.d.ts +36 -0
  9. package/dist/es/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +17 -0
  10. package/dist/es/src/components/PlayerEmbed/index.d.ts +77 -0
  11. package/dist/es/src/components/PlayerEmbed/tests/data.d.ts +3 -0
  12. package/dist/es/src/index.d.ts +2 -0
  13. package/dist/es/src/utils/env.d.ts +12 -0
  14. package/dist/iife/dialog-embed/embed.iife.js +1757 -0
  15. package/dist/iife/dialog-embed/embed.iife.js.map +1 -0
  16. package/dist/iife/embeds.iife.js +765 -430
  17. package/dist/iife/embeds.iife.js.map +1 -1
  18. package/dist/iife/player-embed/embed.iife.js +1619 -0
  19. package/dist/iife/player-embed/embed.iife.js.map +1 -0
  20. package/package.json +44 -31
  21. package/src/components/DialogEmbed/Dialog.stories.ts +91 -0
  22. package/src/components/DialogEmbed/DialogOverlay.ts +131 -0
  23. package/src/components/DialogEmbed/DialogPortal.ts +126 -0
  24. package/src/components/DialogEmbed/index.ts +97 -0
  25. package/src/components/PlayerEmbed/MultiEmbed.stories.ts +135 -0
  26. package/src/components/{Embed/Embed.stories.ts → PlayerEmbed/PlayerEmbed.stories.ts} +43 -16
  27. package/src/components/{Embed → PlayerEmbed}/controllers/event-forwarder.ts +6 -5
  28. package/src/components/PlayerEmbed/controllers/fetcher.ts +152 -0
  29. package/src/components/PlayerEmbed/controllers/tracking/index.ts +224 -0
  30. package/src/components/PlayerEmbed/controllers/tracking/utils.ts +95 -0
  31. package/src/components/{Embed → PlayerEmbed}/index.ts +93 -27
  32. package/src/components/PlayerEmbed/tests/PlayerEmbed.spec.ts +80 -0
  33. package/src/components/PlayerEmbed/tests/data.ts +183 -0
  34. package/src/index.ts +2 -1
  35. package/src/utils/env.ts +15 -29
  36. package/dist/es/components/Embed/controllers/tracking.d.ts +0 -28
  37. package/dist/es/components/Embed/index.d.ts +0 -64
  38. package/dist/es/index.d.ts +0 -1
  39. package/dist/es/utils/env.d.ts +0 -18
  40. package/src/components/Embed/controllers/fetcher.ts +0 -113
  41. package/src/components/Embed/controllers/tracking.ts +0 -261
  42. /package/dist/es/{utils → src/utils}/events.d.ts +0 -0
package/dist/es/embeds.js CHANGED
@@ -1,1070 +1,555 @@
1
- import { property as A, state as Mt, customElement as Qt } from "lit/decorators.js";
2
- import { ifDefined as mt } from "lit/directives/if-defined.js";
3
- import { createRef as Lt, ref as Dt } from "lit/directives/ref.js";
4
- import { Task as te } from "@lit/task";
1
+ import { css, LitElement, html } from "lit";
2
+ import { property, state, customElement } from "lit/decorators.js";
3
+ import { ifDefined } from "lit/directives/if-defined.js";
4
+ import { createRef, ref } from "lit/directives/ref.js";
5
+ import { Task } from "@lit/task";
6
+ import { v4 } from "uuid";
7
+ import { TEMPLATE_VERSION } from "@vouchfor/canvas-video";
5
8
  import "@vouchfor/media-player";
6
- /**
7
- * @license
8
- * Copyright 2019 Google LLC
9
- * SPDX-License-Identifier: BSD-3-Clause
10
- */
11
- const F = window, _t = F.ShadowRoot && (F.ShadyCSS === void 0 || F.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, jt = Symbol(), gt = /* @__PURE__ */ new WeakMap();
12
- let ee = class {
13
- constructor(t, e, i) {
14
- if (this._$cssResult$ = !0, i !== jt)
15
- throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
16
- this.cssText = t, this.t = e;
17
- }
18
- get styleSheet() {
19
- let t = this.o;
20
- const e = this.t;
21
- if (_t && t === void 0) {
22
- const i = e !== void 0 && e.length === 1;
23
- i && (t = gt.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), i && gt.set(e, t));
24
- }
25
- return t;
26
- }
27
- toString() {
28
- return this.cssText;
29
- }
30
- };
31
- const ie = (n) => new ee(typeof n == "string" ? n : n + "", void 0, jt), se = (n, t) => {
32
- _t ? n.adoptedStyleSheets = t.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet) : t.forEach((e) => {
33
- const i = document.createElement("style"), s = F.litNonce;
34
- s !== void 0 && i.setAttribute("nonce", s), i.textContent = e.cssText, n.appendChild(i);
35
- });
36
- }, ft = _t ? (n) => n : (n) => n instanceof CSSStyleSheet ? ((t) => {
37
- let e = "";
38
- for (const i of t.cssRules)
39
- e += i.cssText;
40
- return ie(e);
41
- })(n) : n;
42
- /**
43
- * @license
44
- * Copyright 2017 Google LLC
45
- * SPDX-License-Identifier: BSD-3-Clause
46
- */
47
- var et;
48
- const K = window, At = K.trustedTypes, ne = At ? At.emptyScript : "", yt = K.reactiveElementPolyfillSupport, dt = { toAttribute(n, t) {
49
- switch (t) {
50
- case Boolean:
51
- n = n ? ne : null;
52
- break;
53
- case Object:
54
- case Array:
55
- n = n == null ? n : JSON.stringify(n);
56
- }
57
- return n;
58
- }, fromAttribute(n, t) {
59
- let e = n;
60
- switch (t) {
61
- case Boolean:
62
- e = n !== null;
63
- break;
64
- case Number:
65
- e = n === null ? null : Number(n);
66
- break;
67
- case Object:
68
- case Array:
69
- try {
70
- e = JSON.parse(n);
71
- } catch {
72
- e = null;
73
- }
74
- }
75
- return e;
76
- } }, Bt = (n, t) => t !== n && (t == t || n == n), it = { attribute: !0, type: String, converter: dt, reflect: !1, hasChanged: Bt }, ct = "finalized";
77
- let T = class extends HTMLElement {
78
- constructor() {
79
- super(), this._$Ei = /* @__PURE__ */ new Map(), this.isUpdatePending = !1, this.hasUpdated = !1, this._$El = null, this.u();
80
- }
81
- static addInitializer(t) {
82
- var e;
83
- this.finalize(), ((e = this.h) !== null && e !== void 0 ? e : this.h = []).push(t);
84
- }
85
- static get observedAttributes() {
86
- this.finalize();
87
- const t = [];
88
- return this.elementProperties.forEach((e, i) => {
89
- const s = this._$Ep(i, e);
90
- s !== void 0 && (this._$Ev.set(s, i), t.push(s));
91
- }), t;
92
- }
93
- static createProperty(t, e = it) {
94
- if (e.state && (e.attribute = !1), this.finalize(), this.elementProperties.set(t, e), !e.noAccessor && !this.prototype.hasOwnProperty(t)) {
95
- const i = typeof t == "symbol" ? Symbol() : "__" + t, s = this.getPropertyDescriptor(t, i, e);
96
- s !== void 0 && Object.defineProperty(this.prototype, t, s);
97
- }
98
- }
99
- static getPropertyDescriptor(t, e, i) {
100
- return { get() {
101
- return this[e];
102
- }, set(s) {
103
- const o = this[t];
104
- this[e] = s, this.requestUpdate(t, o, i);
105
- }, configurable: !0, enumerable: !0 };
106
- }
107
- static getPropertyOptions(t) {
108
- return this.elementProperties.get(t) || it;
109
- }
110
- static finalize() {
111
- if (this.hasOwnProperty(ct))
112
- return !1;
113
- this[ct] = !0;
114
- const t = Object.getPrototypeOf(this);
115
- if (t.finalize(), t.h !== void 0 && (this.h = [...t.h]), this.elementProperties = new Map(t.elementProperties), this._$Ev = /* @__PURE__ */ new Map(), this.hasOwnProperty("properties")) {
116
- const e = this.properties, i = [...Object.getOwnPropertyNames(e), ...Object.getOwnPropertySymbols(e)];
117
- for (const s of i)
118
- this.createProperty(s, e[s]);
119
- }
120
- return this.elementStyles = this.finalizeStyles(this.styles), !0;
121
- }
122
- static finalizeStyles(t) {
123
- const e = [];
124
- if (Array.isArray(t)) {
125
- const i = new Set(t.flat(1 / 0).reverse());
126
- for (const s of i)
127
- e.unshift(ft(s));
128
- } else
129
- t !== void 0 && e.push(ft(t));
130
- return e;
131
- }
132
- static _$Ep(t, e) {
133
- const i = e.attribute;
134
- return i === !1 ? void 0 : typeof i == "string" ? i : typeof t == "string" ? t.toLowerCase() : void 0;
135
- }
136
- u() {
137
- var t;
138
- this._$E_ = new Promise((e) => this.enableUpdating = e), this._$AL = /* @__PURE__ */ new Map(), this._$Eg(), this.requestUpdate(), (t = this.constructor.h) === null || t === void 0 || t.forEach((e) => e(this));
139
- }
140
- addController(t) {
141
- var e, i;
142
- ((e = this._$ES) !== null && e !== void 0 ? e : this._$ES = []).push(t), this.renderRoot !== void 0 && this.isConnected && ((i = t.hostConnected) === null || i === void 0 || i.call(t));
143
- }
144
- removeController(t) {
145
- var e;
146
- (e = this._$ES) === null || e === void 0 || e.splice(this._$ES.indexOf(t) >>> 0, 1);
147
- }
148
- _$Eg() {
149
- this.constructor.elementProperties.forEach((t, e) => {
150
- this.hasOwnProperty(e) && (this._$Ei.set(e, this[e]), delete this[e]);
151
- });
152
- }
153
- createRenderRoot() {
154
- var t;
155
- const e = (t = this.shadowRoot) !== null && t !== void 0 ? t : this.attachShadow(this.constructor.shadowRootOptions);
156
- return se(e, this.constructor.elementStyles), e;
157
- }
158
- connectedCallback() {
159
- var t;
160
- this.renderRoot === void 0 && (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (t = this._$ES) === null || t === void 0 || t.forEach((e) => {
161
- var i;
162
- return (i = e.hostConnected) === null || i === void 0 ? void 0 : i.call(e);
163
- });
164
- }
165
- enableUpdating(t) {
166
- }
167
- disconnectedCallback() {
168
- var t;
169
- (t = this._$ES) === null || t === void 0 || t.forEach((e) => {
170
- var i;
171
- return (i = e.hostDisconnected) === null || i === void 0 ? void 0 : i.call(e);
172
- });
173
- }
174
- attributeChangedCallback(t, e, i) {
175
- this._$AK(t, i);
176
- }
177
- _$EO(t, e, i = it) {
178
- var s;
179
- const o = this.constructor._$Ep(t, i);
180
- if (o !== void 0 && i.reflect === !0) {
181
- const r = (((s = i.converter) === null || s === void 0 ? void 0 : s.toAttribute) !== void 0 ? i.converter : dt).toAttribute(e, i.type);
182
- this._$El = t, r == null ? this.removeAttribute(o) : this.setAttribute(o, r), this._$El = null;
183
- }
184
- }
185
- _$AK(t, e) {
186
- var i;
187
- const s = this.constructor, o = s._$Ev.get(t);
188
- if (o !== void 0 && this._$El !== o) {
189
- const r = s.getPropertyOptions(o), d = typeof r.converter == "function" ? { fromAttribute: r.converter } : ((i = r.converter) === null || i === void 0 ? void 0 : i.fromAttribute) !== void 0 ? r.converter : dt;
190
- this._$El = o, this[o] = d.fromAttribute(e, r.type), this._$El = null;
191
- }
192
- }
193
- requestUpdate(t, e, i) {
194
- let s = !0;
195
- t !== void 0 && (((i = i || this.constructor.getPropertyOptions(t)).hasChanged || Bt)(this[t], e) ? (this._$AL.has(t) || this._$AL.set(t, e), i.reflect === !0 && this._$El !== t && (this._$EC === void 0 && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(t, i))) : s = !1), !this.isUpdatePending && s && (this._$E_ = this._$Ej());
196
- }
197
- async _$Ej() {
198
- this.isUpdatePending = !0;
199
- try {
200
- await this._$E_;
201
- } catch (e) {
202
- Promise.reject(e);
203
- }
204
- const t = this.scheduleUpdate();
205
- return t != null && await t, !this.isUpdatePending;
206
- }
207
- scheduleUpdate() {
208
- return this.performUpdate();
209
- }
210
- performUpdate() {
211
- var t;
212
- if (!this.isUpdatePending)
213
- return;
214
- this.hasUpdated, this._$Ei && (this._$Ei.forEach((s, o) => this[o] = s), this._$Ei = void 0);
215
- let e = !1;
216
- const i = this._$AL;
217
- try {
218
- e = this.shouldUpdate(i), e ? (this.willUpdate(i), (t = this._$ES) === null || t === void 0 || t.forEach((s) => {
219
- var o;
220
- return (o = s.hostUpdate) === null || o === void 0 ? void 0 : o.call(s);
221
- }), this.update(i)) : this._$Ek();
222
- } catch (s) {
223
- throw e = !1, this._$Ek(), s;
224
- }
225
- e && this._$AE(i);
226
- }
227
- willUpdate(t) {
228
- }
229
- _$AE(t) {
230
- var e;
231
- (e = this._$ES) === null || e === void 0 || e.forEach((i) => {
232
- var s;
233
- return (s = i.hostUpdated) === null || s === void 0 ? void 0 : s.call(i);
234
- }), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
235
- }
236
- _$Ek() {
237
- this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
238
- }
239
- get updateComplete() {
240
- return this.getUpdateComplete();
241
- }
242
- getUpdateComplete() {
243
- return this._$E_;
244
- }
245
- shouldUpdate(t) {
246
- return !0;
247
- }
248
- update(t) {
249
- this._$EC !== void 0 && (this._$EC.forEach((e, i) => this._$EO(i, this[i], e)), this._$EC = void 0), this._$Ek();
250
- }
251
- updated(t) {
252
- }
253
- firstUpdated(t) {
254
- }
255
- };
256
- T[ct] = !0, T.elementProperties = /* @__PURE__ */ new Map(), T.elementStyles = [], T.shadowRootOptions = { mode: "open" }, yt == null || yt({ ReactiveElement: T }), ((et = K.reactiveElementVersions) !== null && et !== void 0 ? et : K.reactiveElementVersions = []).push("1.6.2");
257
- /**
258
- * @license
259
- * Copyright 2017 Google LLC
260
- * SPDX-License-Identifier: BSD-3-Clause
261
- */
262
- var st;
263
- const G = window, x = G.trustedTypes, Et = x ? x.createPolicy("lit-html", { createHTML: (n) => n }) : void 0, ut = "$lit$", E = `lit$${(Math.random() + "").slice(9)}$`, zt = "?" + E, re = `<${zt}>`, U = document, J = () => U.createComment(""), D = (n) => n === null || typeof n != "object" && typeof n != "function", qt = Array.isArray, oe = (n) => qt(n) || typeof (n == null ? void 0 : n[Symbol.iterator]) == "function", nt = `[
264
- \f\r]`, k = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, wt = /-->/g, bt = />/g, b = RegExp(`>|${nt}(?:([^\\s"'>=/]+)(${nt}*=${nt}*(?:[^
265
- \f\r"'\`<>=]|("|')|))|$)`, "g"), St = /'/g, Pt = /"/g, Wt = /^(?:script|style|textarea|title)$/i, j = Symbol.for("lit-noChange"), v = Symbol.for("lit-nothing"), Ct = /* @__PURE__ */ new WeakMap(), P = U.createTreeWalker(U, 129, null, !1);
266
- function Zt(n, t) {
267
- if (!Array.isArray(n) || !n.hasOwnProperty("raw"))
268
- throw Error("invalid template strings array");
269
- return Et !== void 0 ? Et.createHTML(t) : t;
270
- }
271
- const le = (n, t) => {
272
- const e = n.length - 1, i = [];
273
- let s, o = t === 2 ? "<svg>" : "", r = k;
274
- for (let d = 0; d < e; d++) {
275
- const l = n[d];
276
- let a, u, h = -1, c = 0;
277
- for (; c < l.length && (r.lastIndex = c, u = r.exec(l), u !== null); )
278
- c = r.lastIndex, r === k ? u[1] === "!--" ? r = wt : u[1] !== void 0 ? r = bt : u[2] !== void 0 ? (Wt.test(u[2]) && (s = RegExp("</" + u[2], "g")), r = b) : u[3] !== void 0 && (r = b) : r === b ? u[0] === ">" ? (r = s ?? k, h = -1) : u[1] === void 0 ? h = -2 : (h = r.lastIndex - u[2].length, a = u[1], r = u[3] === void 0 ? b : u[3] === '"' ? Pt : St) : r === Pt || r === St ? r = b : r === wt || r === bt ? r = k : (r = b, s = void 0);
279
- const p = r === b && n[d + 1].startsWith("/>") ? " " : "";
280
- o += r === k ? l + re : h >= 0 ? (i.push(a), l.slice(0, h) + ut + l.slice(h) + E + p) : l + E + (h === -2 ? (i.push(void 0), d) : p);
281
- }
282
- return [Zt(n, o + (n[e] || "<?>") + (t === 2 ? "</svg>" : "")), i];
283
- };
284
- let pt = class Ft {
285
- constructor({ strings: t, _$litType$: e }, i) {
286
- let s;
287
- this.parts = [];
288
- let o = 0, r = 0;
289
- const d = t.length - 1, l = this.parts, [a, u] = le(t, e);
290
- if (this.el = Ft.createElement(a, i), P.currentNode = this.el.content, e === 2) {
291
- const h = this.el.content, c = h.firstChild;
292
- c.remove(), h.append(...c.childNodes);
293
- }
294
- for (; (s = P.nextNode()) !== null && l.length < d; ) {
295
- if (s.nodeType === 1) {
296
- if (s.hasAttributes()) {
297
- const h = [];
298
- for (const c of s.getAttributeNames())
299
- if (c.endsWith(ut) || c.startsWith(E)) {
300
- const p = u[r++];
301
- if (h.push(c), p !== void 0) {
302
- const y = s.getAttribute(p.toLowerCase() + ut).split(E), m = /([.?@])?(.*)/.exec(p);
303
- l.push({ type: 1, index: o, name: m[2], strings: y, ctor: m[1] === "." ? he : m[1] === "?" ? ce : m[1] === "@" ? ue : Q });
304
- } else
305
- l.push({ type: 6, index: o });
306
- }
307
- for (const c of h)
308
- s.removeAttribute(c);
309
- }
310
- if (Wt.test(s.tagName)) {
311
- const h = s.textContent.split(E), c = h.length - 1;
312
- if (c > 0) {
313
- s.textContent = x ? x.emptyScript : "";
314
- for (let p = 0; p < c; p++)
315
- s.append(h[p], J()), P.nextNode(), l.push({ type: 2, index: ++o });
316
- s.append(h[c], J());
317
- }
318
- }
319
- } else if (s.nodeType === 8)
320
- if (s.data === zt)
321
- l.push({ type: 2, index: o });
322
- else {
323
- let h = -1;
324
- for (; (h = s.data.indexOf(E, h + 1)) !== -1; )
325
- l.push({ type: 7, index: o }), h += E.length - 1;
326
- }
327
- o++;
328
- }
329
- }
330
- static createElement(t, e) {
331
- const i = U.createElement("template");
332
- return i.innerHTML = t, i;
333
- }
334
- };
335
- function H(n, t, e = n, i) {
336
- var s, o, r, d;
337
- if (t === j)
338
- return t;
339
- let l = i !== void 0 ? (s = e._$Co) === null || s === void 0 ? void 0 : s[i] : e._$Cl;
340
- const a = D(t) ? void 0 : t._$litDirective$;
341
- return (l == null ? void 0 : l.constructor) !== a && ((o = l == null ? void 0 : l._$AO) === null || o === void 0 || o.call(l, !1), a === void 0 ? l = void 0 : (l = new a(n), l._$AT(n, e, i)), i !== void 0 ? ((r = (d = e)._$Co) !== null && r !== void 0 ? r : d._$Co = [])[i] = l : e._$Cl = l), l !== void 0 && (t = H(n, l._$AS(n, t.values), l, i)), t;
342
- }
343
- let ae = class {
344
- constructor(t, e) {
345
- this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = e;
346
- }
347
- get parentNode() {
348
- return this._$AM.parentNode;
349
- }
350
- get _$AU() {
351
- return this._$AM._$AU;
352
- }
353
- u(t) {
354
- var e;
355
- const { el: { content: i }, parts: s } = this._$AD, o = ((e = t == null ? void 0 : t.creationScope) !== null && e !== void 0 ? e : U).importNode(i, !0);
356
- P.currentNode = o;
357
- let r = P.nextNode(), d = 0, l = 0, a = s[0];
358
- for (; a !== void 0; ) {
359
- if (d === a.index) {
360
- let u;
361
- a.type === 2 ? u = new Kt(r, r.nextSibling, this, t) : a.type === 1 ? u = new a.ctor(r, a.name, a.strings, this, t) : a.type === 6 && (u = new pe(r, this, t)), this._$AV.push(u), a = s[++l];
362
- }
363
- d !== (a == null ? void 0 : a.index) && (r = P.nextNode(), d++);
364
- }
365
- return P.currentNode = U, o;
366
- }
367
- v(t) {
368
- let e = 0;
369
- for (const i of this._$AV)
370
- i !== void 0 && (i.strings !== void 0 ? (i._$AI(t, i, e), e += i.strings.length - 2) : i._$AI(t[e])), e++;
371
- }
372
- }, Kt = class Gt {
373
- constructor(t, e, i, s) {
374
- var o;
375
- this.type = 2, this._$AH = v, this._$AN = void 0, this._$AA = t, this._$AB = e, this._$AM = i, this.options = s, this._$Cp = (o = s == null ? void 0 : s.isConnected) === null || o === void 0 || o;
376
- }
377
- get _$AU() {
378
- var t, e;
379
- return (e = (t = this._$AM) === null || t === void 0 ? void 0 : t._$AU) !== null && e !== void 0 ? e : this._$Cp;
380
- }
381
- get parentNode() {
382
- let t = this._$AA.parentNode;
383
- const e = this._$AM;
384
- return e !== void 0 && (t == null ? void 0 : t.nodeType) === 11 && (t = e.parentNode), t;
385
- }
386
- get startNode() {
387
- return this._$AA;
388
- }
389
- get endNode() {
390
- return this._$AB;
391
- }
392
- _$AI(t, e = this) {
393
- t = H(this, t, e), D(t) ? t === v || t == null || t === "" ? (this._$AH !== v && this._$AR(), this._$AH = v) : t !== this._$AH && t !== j && this._(t) : t._$litType$ !== void 0 ? this.g(t) : t.nodeType !== void 0 ? this.$(t) : oe(t) ? this.T(t) : this._(t);
394
- }
395
- k(t) {
396
- return this._$AA.parentNode.insertBefore(t, this._$AB);
397
- }
398
- $(t) {
399
- this._$AH !== t && (this._$AR(), this._$AH = this.k(t));
400
- }
401
- _(t) {
402
- this._$AH !== v && D(this._$AH) ? this._$AA.nextSibling.data = t : this.$(U.createTextNode(t)), this._$AH = t;
403
- }
404
- g(t) {
405
- var e;
406
- const { values: i, _$litType$: s } = t, o = typeof s == "number" ? this._$AC(t) : (s.el === void 0 && (s.el = pt.createElement(Zt(s.h, s.h[0]), this.options)), s);
407
- if (((e = this._$AH) === null || e === void 0 ? void 0 : e._$AD) === o)
408
- this._$AH.v(i);
409
- else {
410
- const r = new ae(o, this), d = r.u(this.options);
411
- r.v(i), this.$(d), this._$AH = r;
412
- }
413
- }
414
- _$AC(t) {
415
- let e = Ct.get(t.strings);
416
- return e === void 0 && Ct.set(t.strings, e = new pt(t)), e;
417
- }
418
- T(t) {
419
- qt(this._$AH) || (this._$AH = [], this._$AR());
420
- const e = this._$AH;
421
- let i, s = 0;
422
- for (const o of t)
423
- s === e.length ? e.push(i = new Gt(this.k(J()), this.k(J()), this, this.options)) : i = e[s], i._$AI(o), s++;
424
- s < e.length && (this._$AR(i && i._$AB.nextSibling, s), e.length = s);
425
- }
426
- _$AR(t = this._$AA.nextSibling, e) {
427
- var i;
428
- for ((i = this._$AP) === null || i === void 0 || i.call(this, !1, !0, e); t && t !== this._$AB; ) {
429
- const s = t.nextSibling;
430
- t.remove(), t = s;
431
- }
432
- }
433
- setConnected(t) {
434
- var e;
435
- this._$AM === void 0 && (this._$Cp = t, (e = this._$AP) === null || e === void 0 || e.call(this, t));
436
- }
437
- }, Q = class {
438
- constructor(t, e, i, s, o) {
439
- this.type = 1, this._$AH = v, this._$AN = void 0, this.element = t, this.name = e, this._$AM = s, this.options = o, i.length > 2 || i[0] !== "" || i[1] !== "" ? (this._$AH = Array(i.length - 1).fill(new String()), this.strings = i) : this._$AH = v;
440
- }
441
- get tagName() {
442
- return this.element.tagName;
443
- }
444
- get _$AU() {
445
- return this._$AM._$AU;
446
- }
447
- _$AI(t, e = this, i, s) {
448
- const o = this.strings;
449
- let r = !1;
450
- if (o === void 0)
451
- t = H(this, t, e, 0), r = !D(t) || t !== this._$AH && t !== j, r && (this._$AH = t);
452
- else {
453
- const d = t;
454
- let l, a;
455
- for (t = o[0], l = 0; l < o.length - 1; l++)
456
- a = H(this, d[i + l], e, l), a === j && (a = this._$AH[l]), r || (r = !D(a) || a !== this._$AH[l]), a === v ? t = v : t !== v && (t += (a ?? "") + o[l + 1]), this._$AH[l] = a;
457
- }
458
- r && !s && this.j(t);
459
- }
460
- j(t) {
461
- t === v ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
462
- }
463
- }, he = class extends Q {
464
- constructor() {
465
- super(...arguments), this.type = 3;
466
- }
467
- j(t) {
468
- this.element[this.name] = t === v ? void 0 : t;
469
- }
470
- };
471
- const de = x ? x.emptyScript : "";
472
- let ce = class extends Q {
473
- constructor() {
474
- super(...arguments), this.type = 4;
475
- }
476
- j(t) {
477
- t && t !== v ? this.element.setAttribute(this.name, de) : this.element.removeAttribute(this.name);
478
- }
479
- }, ue = class extends Q {
480
- constructor(t, e, i, s, o) {
481
- super(t, e, i, s, o), this.type = 5;
482
- }
483
- _$AI(t, e = this) {
484
- var i;
485
- if ((t = (i = H(this, t, e, 0)) !== null && i !== void 0 ? i : v) === j)
486
- return;
487
- const s = this._$AH, o = t === v && s !== v || t.capture !== s.capture || t.once !== s.once || t.passive !== s.passive, r = t !== v && (s === v || o);
488
- o && this.element.removeEventListener(this.name, this, s), r && this.element.addEventListener(this.name, this, t), this._$AH = t;
489
- }
490
- handleEvent(t) {
491
- var e, i;
492
- typeof this._$AH == "function" ? this._$AH.call((i = (e = this.options) === null || e === void 0 ? void 0 : e.host) !== null && i !== void 0 ? i : this.element, t) : this._$AH.handleEvent(t);
493
- }
494
- };
495
- class pe {
496
- constructor(t, e, i) {
497
- this.element = t, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = i;
498
- }
499
- get _$AU() {
500
- return this._$AM._$AU;
501
- }
502
- _$AI(t) {
503
- H(this, t);
504
- }
505
- }
506
- const Ut = G.litHtmlPolyfillSupport;
507
- Ut == null || Ut(pt, Kt), ((st = G.litHtmlVersions) !== null && st !== void 0 ? st : G.litHtmlVersions = []).push("2.8.0");
508
- /**
509
- * @license
510
- * Copyright 2017 Google LLC
511
- * SPDX-License-Identifier: BSD-3-Clause
512
- */
513
- var rt;
514
- const X = window, N = X.trustedTypes, Rt = N ? N.createPolicy("lit-html", { createHTML: (n) => n }) : void 0, vt = "$lit$", w = `lit$${(Math.random() + "").slice(9)}$`, Jt = "?" + w, ve = `<${Jt}>`, R = document, B = () => R.createComment(""), z = (n) => n === null || typeof n != "object" && typeof n != "function", Xt = Array.isArray, _e = (n) => Xt(n) || typeof (n == null ? void 0 : n[Symbol.iterator]) == "function", ot = `[
515
- \f\r]`, O = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, Tt = /-->/g, xt = />/g, S = RegExp(`>|${ot}(?:([^\\s"'>=/]+)(${ot}*=${ot}*(?:[^
516
- \f\r"'\`<>=]|("|')|))|$)`, "g"), Ht = /'/g, Nt = /"/g, Yt = /^(?:script|style|textarea|title)$/i, $e = (n) => (t, ...e) => ({ _$litType$: n, strings: t, values: e }), me = $e(1), I = Symbol.for("lit-noChange"), _ = Symbol.for("lit-nothing"), It = /* @__PURE__ */ new WeakMap(), C = R.createTreeWalker(R, 129, null, !1), ge = (n, t) => {
517
- const e = n.length - 1, i = [];
518
- let s, o = t === 2 ? "<svg>" : "", r = O;
519
- for (let l = 0; l < e; l++) {
520
- const a = n[l];
521
- let u, h, c = -1, p = 0;
522
- for (; p < a.length && (r.lastIndex = p, h = r.exec(a), h !== null); )
523
- p = r.lastIndex, r === O ? h[1] === "!--" ? r = Tt : h[1] !== void 0 ? r = xt : h[2] !== void 0 ? (Yt.test(h[2]) && (s = RegExp("</" + h[2], "g")), r = S) : h[3] !== void 0 && (r = S) : r === S ? h[0] === ">" ? (r = s ?? O, c = -1) : h[1] === void 0 ? c = -2 : (c = r.lastIndex - h[2].length, u = h[1], r = h[3] === void 0 ? S : h[3] === '"' ? Nt : Ht) : r === Nt || r === Ht ? r = S : r === Tt || r === xt ? r = O : (r = S, s = void 0);
524
- const y = r === S && n[l + 1].startsWith("/>") ? " " : "";
525
- o += r === O ? a + ve : c >= 0 ? (i.push(u), a.slice(0, c) + vt + a.slice(c) + w + y) : a + w + (c === -2 ? (i.push(void 0), l) : y);
526
- }
527
- const d = o + (n[e] || "<?>") + (t === 2 ? "</svg>" : "");
528
- if (!Array.isArray(n) || !n.hasOwnProperty("raw"))
529
- throw Error("invalid template strings array");
530
- return [Rt !== void 0 ? Rt.createHTML(d) : d, i];
531
- };
532
- class q {
533
- constructor({ strings: t, _$litType$: e }, i) {
534
- let s;
535
- this.parts = [];
536
- let o = 0, r = 0;
537
- const d = t.length - 1, l = this.parts, [a, u] = ge(t, e);
538
- if (this.el = q.createElement(a, i), C.currentNode = this.el.content, e === 2) {
539
- const h = this.el.content, c = h.firstChild;
540
- c.remove(), h.append(...c.childNodes);
541
- }
542
- for (; (s = C.nextNode()) !== null && l.length < d; ) {
543
- if (s.nodeType === 1) {
544
- if (s.hasAttributes()) {
545
- const h = [];
546
- for (const c of s.getAttributeNames())
547
- if (c.endsWith(vt) || c.startsWith(w)) {
548
- const p = u[r++];
549
- if (h.push(c), p !== void 0) {
550
- const y = s.getAttribute(p.toLowerCase() + vt).split(w), m = /([.?@])?(.*)/.exec(p);
551
- l.push({ type: 1, index: o, name: m[2], strings: y, ctor: m[1] === "." ? Ae : m[1] === "?" ? Ee : m[1] === "@" ? we : tt });
552
- } else
553
- l.push({ type: 6, index: o });
554
- }
555
- for (const c of h)
556
- s.removeAttribute(c);
557
- }
558
- if (Yt.test(s.tagName)) {
559
- const h = s.textContent.split(w), c = h.length - 1;
560
- if (c > 0) {
561
- s.textContent = N ? N.emptyScript : "";
562
- for (let p = 0; p < c; p++)
563
- s.append(h[p], B()), C.nextNode(), l.push({ type: 2, index: ++o });
564
- s.append(h[c], B());
565
- }
566
- }
567
- } else if (s.nodeType === 8)
568
- if (s.data === Jt)
569
- l.push({ type: 2, index: o });
570
- else {
571
- let h = -1;
572
- for (; (h = s.data.indexOf(w, h + 1)) !== -1; )
573
- l.push({ type: 7, index: o }), h += w.length - 1;
574
- }
575
- o++;
576
- }
577
- }
578
- static createElement(t, e) {
579
- const i = R.createElement("template");
580
- return i.innerHTML = t, i;
581
- }
582
- }
583
- function V(n, t, e = n, i) {
584
- var s, o, r, d;
585
- if (t === I)
586
- return t;
587
- let l = i !== void 0 ? (s = e._$Co) === null || s === void 0 ? void 0 : s[i] : e._$Cl;
588
- const a = z(t) ? void 0 : t._$litDirective$;
589
- return (l == null ? void 0 : l.constructor) !== a && ((o = l == null ? void 0 : l._$AO) === null || o === void 0 || o.call(l, !1), a === void 0 ? l = void 0 : (l = new a(n), l._$AT(n, e, i)), i !== void 0 ? ((r = (d = e)._$Co) !== null && r !== void 0 ? r : d._$Co = [])[i] = l : e._$Cl = l), l !== void 0 && (t = V(n, l._$AS(n, t.values), l, i)), t;
590
- }
591
- class fe {
592
- constructor(t, e) {
593
- this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = e;
594
- }
595
- get parentNode() {
596
- return this._$AM.parentNode;
597
- }
598
- get _$AU() {
599
- return this._$AM._$AU;
600
- }
601
- u(t) {
602
- var e;
603
- const { el: { content: i }, parts: s } = this._$AD, o = ((e = t == null ? void 0 : t.creationScope) !== null && e !== void 0 ? e : R).importNode(i, !0);
604
- C.currentNode = o;
605
- let r = C.nextNode(), d = 0, l = 0, a = s[0];
606
- for (; a !== void 0; ) {
607
- if (d === a.index) {
608
- let u;
609
- a.type === 2 ? u = new W(r, r.nextSibling, this, t) : a.type === 1 ? u = new a.ctor(r, a.name, a.strings, this, t) : a.type === 6 && (u = new be(r, this, t)), this._$AV.push(u), a = s[++l];
610
- }
611
- d !== (a == null ? void 0 : a.index) && (r = C.nextNode(), d++);
612
- }
613
- return C.currentNode = R, o;
614
- }
615
- v(t) {
616
- let e = 0;
617
- for (const i of this._$AV)
618
- i !== void 0 && (i.strings !== void 0 ? (i._$AI(t, i, e), e += i.strings.length - 2) : i._$AI(t[e])), e++;
619
- }
620
- }
621
- class W {
622
- constructor(t, e, i, s) {
623
- var o;
624
- this.type = 2, this._$AH = _, this._$AN = void 0, this._$AA = t, this._$AB = e, this._$AM = i, this.options = s, this._$Cp = (o = s == null ? void 0 : s.isConnected) === null || o === void 0 || o;
625
- }
626
- get _$AU() {
627
- var t, e;
628
- return (e = (t = this._$AM) === null || t === void 0 ? void 0 : t._$AU) !== null && e !== void 0 ? e : this._$Cp;
629
- }
630
- get parentNode() {
631
- let t = this._$AA.parentNode;
632
- const e = this._$AM;
633
- return e !== void 0 && (t == null ? void 0 : t.nodeType) === 11 && (t = e.parentNode), t;
634
- }
635
- get startNode() {
636
- return this._$AA;
637
- }
638
- get endNode() {
639
- return this._$AB;
640
- }
641
- _$AI(t, e = this) {
642
- t = V(this, t, e), z(t) ? t === _ || t == null || t === "" ? (this._$AH !== _ && this._$AR(), this._$AH = _) : t !== this._$AH && t !== I && this._(t) : t._$litType$ !== void 0 ? this.g(t) : t.nodeType !== void 0 ? this.$(t) : _e(t) ? this.T(t) : this._(t);
643
- }
644
- k(t) {
645
- return this._$AA.parentNode.insertBefore(t, this._$AB);
646
- }
647
- $(t) {
648
- this._$AH !== t && (this._$AR(), this._$AH = this.k(t));
649
- }
650
- _(t) {
651
- this._$AH !== _ && z(this._$AH) ? this._$AA.nextSibling.data = t : this.$(R.createTextNode(t)), this._$AH = t;
652
- }
653
- g(t) {
654
- var e;
655
- const { values: i, _$litType$: s } = t, o = typeof s == "number" ? this._$AC(t) : (s.el === void 0 && (s.el = q.createElement(s.h, this.options)), s);
656
- if (((e = this._$AH) === null || e === void 0 ? void 0 : e._$AD) === o)
657
- this._$AH.v(i);
658
- else {
659
- const r = new fe(o, this), d = r.u(this.options);
660
- r.v(i), this.$(d), this._$AH = r;
661
- }
662
- }
663
- _$AC(t) {
664
- let e = It.get(t.strings);
665
- return e === void 0 && It.set(t.strings, e = new q(t)), e;
666
- }
667
- T(t) {
668
- Xt(this._$AH) || (this._$AH = [], this._$AR());
669
- const e = this._$AH;
670
- let i, s = 0;
671
- for (const o of t)
672
- s === e.length ? e.push(i = new W(this.k(B()), this.k(B()), this, this.options)) : i = e[s], i._$AI(o), s++;
673
- s < e.length && (this._$AR(i && i._$AB.nextSibling, s), e.length = s);
674
- }
675
- _$AR(t = this._$AA.nextSibling, e) {
676
- var i;
677
- for ((i = this._$AP) === null || i === void 0 || i.call(this, !1, !0, e); t && t !== this._$AB; ) {
678
- const s = t.nextSibling;
679
- t.remove(), t = s;
680
- }
681
- }
682
- setConnected(t) {
683
- var e;
684
- this._$AM === void 0 && (this._$Cp = t, (e = this._$AP) === null || e === void 0 || e.call(this, t));
685
- }
686
- }
687
- class tt {
688
- constructor(t, e, i, s, o) {
689
- this.type = 1, this._$AH = _, this._$AN = void 0, this.element = t, this.name = e, this._$AM = s, this.options = o, i.length > 2 || i[0] !== "" || i[1] !== "" ? (this._$AH = Array(i.length - 1).fill(new String()), this.strings = i) : this._$AH = _;
690
- }
691
- get tagName() {
692
- return this.element.tagName;
693
- }
694
- get _$AU() {
695
- return this._$AM._$AU;
696
- }
697
- _$AI(t, e = this, i, s) {
698
- const o = this.strings;
699
- let r = !1;
700
- if (o === void 0)
701
- t = V(this, t, e, 0), r = !z(t) || t !== this._$AH && t !== I, r && (this._$AH = t);
702
- else {
703
- const d = t;
704
- let l, a;
705
- for (t = o[0], l = 0; l < o.length - 1; l++)
706
- a = V(this, d[i + l], e, l), a === I && (a = this._$AH[l]), r || (r = !z(a) || a !== this._$AH[l]), a === _ ? t = _ : t !== _ && (t += (a ?? "") + o[l + 1]), this._$AH[l] = a;
707
- }
708
- r && !s && this.j(t);
709
- }
710
- j(t) {
711
- t === _ ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
712
- }
713
- }
714
- class Ae extends tt {
715
- constructor() {
716
- super(...arguments), this.type = 3;
717
- }
718
- j(t) {
719
- this.element[this.name] = t === _ ? void 0 : t;
720
- }
721
- }
722
- const ye = N ? N.emptyScript : "";
723
- class Ee extends tt {
724
- constructor() {
725
- super(...arguments), this.type = 4;
726
- }
727
- j(t) {
728
- t && t !== _ ? this.element.setAttribute(this.name, ye) : this.element.removeAttribute(this.name);
729
- }
730
- }
731
- class we extends tt {
732
- constructor(t, e, i, s, o) {
733
- super(t, e, i, s, o), this.type = 5;
734
- }
735
- _$AI(t, e = this) {
736
- var i;
737
- if ((t = (i = V(this, t, e, 0)) !== null && i !== void 0 ? i : _) === I)
738
- return;
739
- const s = this._$AH, o = t === _ && s !== _ || t.capture !== s.capture || t.once !== s.once || t.passive !== s.passive, r = t !== _ && (s === _ || o);
740
- o && this.element.removeEventListener(this.name, this, s), r && this.element.addEventListener(this.name, this, t), this._$AH = t;
741
- }
742
- handleEvent(t) {
743
- var e, i;
744
- typeof this._$AH == "function" ? this._$AH.call((i = (e = this.options) === null || e === void 0 ? void 0 : e.host) !== null && i !== void 0 ? i : this.element, t) : this._$AH.handleEvent(t);
745
- }
746
- }
747
- class be {
748
- constructor(t, e, i) {
749
- this.element = t, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = i;
750
- }
751
- get _$AU() {
752
- return this._$AM._$AU;
753
- }
754
- _$AI(t) {
755
- V(this, t);
756
- }
757
- }
758
- const Vt = X.litHtmlPolyfillSupport;
759
- Vt == null || Vt(q, W), ((rt = X.litHtmlVersions) !== null && rt !== void 0 ? rt : X.litHtmlVersions = []).push("2.7.4");
760
- const Se = (n, t, e) => {
761
- var i, s;
762
- const o = (i = e == null ? void 0 : e.renderBefore) !== null && i !== void 0 ? i : t;
763
- let r = o._$litPart$;
764
- if (r === void 0) {
765
- const d = (s = e == null ? void 0 : e.renderBefore) !== null && s !== void 0 ? s : null;
766
- o._$litPart$ = r = new W(t.insertBefore(B(), d), d, void 0, e ?? {});
767
- }
768
- return r._$AI(n), r;
769
- };
770
- /**
771
- * @license
772
- * Copyright 2017 Google LLC
773
- * SPDX-License-Identifier: BSD-3-Clause
774
- */
775
- var lt, at;
776
- class L extends T {
777
- constructor() {
778
- super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
779
- }
780
- createRenderRoot() {
781
- var t, e;
782
- const i = super.createRenderRoot();
783
- return (t = (e = this.renderOptions).renderBefore) !== null && t !== void 0 || (e.renderBefore = i.firstChild), i;
784
- }
785
- update(t) {
786
- const e = this.render();
787
- this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this._$Do = Se(e, this.renderRoot, this.renderOptions);
788
- }
789
- connectedCallback() {
790
- var t;
791
- super.connectedCallback(), (t = this._$Do) === null || t === void 0 || t.setConnected(!0);
792
- }
793
- disconnectedCallback() {
794
- var t;
795
- super.disconnectedCallback(), (t = this._$Do) === null || t === void 0 || t.setConnected(!1);
796
- }
797
- render() {
798
- return I;
799
- }
800
- }
801
- L.finalized = !0, L._$litElement$ = !0, (lt = globalThis.litElementHydrateSupport) === null || lt === void 0 || lt.call(globalThis, { LitElement: L });
802
- const kt = globalThis.litElementPolyfillSupport;
803
- kt == null || kt({ LitElement: L });
804
- ((at = globalThis.litElementVersions) !== null && at !== void 0 ? at : globalThis.litElementVersions = []).push("3.3.2");
805
- function Pe(n, t, e) {
806
- function i(s) {
807
- e.dispatchEvent(new CustomEvent(s.type, s));
808
- }
809
- return t.addEventListener(n, i), () => {
810
- t.removeEventListener(n, i);
9
+ import { styleMap } from "lit/directives/style-map.js";
10
+ import { classMap } from "lit/directives/class-map.js";
11
+ import "@a11y/focus-trap";
12
+ function forwardEvent(type2, fromElement, toElement) {
13
+ function forwarder(event) {
14
+ toElement.dispatchEvent(new CustomEvent(event.type, event));
15
+ }
16
+ fromElement.addEventListener(type2, forwarder);
17
+ return () => {
18
+ fromElement.removeEventListener(type2, forwarder);
811
19
  };
812
20
  }
813
- class Ce {
814
- constructor(t, e) {
815
- this._events = [], this._cleanup = [], this._forwardElementRef = Lt(), this.host = t, this._events = e, t.addController(this);
21
+ class EventForwardController {
22
+ constructor(host, events) {
23
+ this._events = [];
24
+ this._cleanup = [];
25
+ this._forwardElementRef = createRef();
26
+ this.host = host;
27
+ this._events = events;
28
+ host.addController(this);
816
29
  }
817
30
  register() {
818
- return Dt(this._forwardElementRef);
31
+ return ref(this._forwardElementRef);
819
32
  }
820
33
  hostConnected() {
821
34
  requestAnimationFrame(() => {
822
- this._events.forEach((t) => {
823
- this._forwardElementRef.value && this._cleanup.push(Pe(t, this._forwardElementRef.value, this.host));
35
+ this._events.forEach((event) => {
36
+ if (this._forwardElementRef.value) {
37
+ this._cleanup.push(forwardEvent(event, this._forwardElementRef.value, this.host));
38
+ }
824
39
  });
825
40
  });
826
41
  }
827
42
  hostDisconnected() {
828
- this._cleanup.forEach((t) => {
829
- t();
830
- }), this._cleanup = [];
43
+ this._cleanup.forEach((fn) => {
44
+ fn();
45
+ });
46
+ this._cleanup = [];
831
47
  }
832
48
  }
833
- const ht = "https://vouchfor.com", Ue = "https://d2rxhdlm2q91uk.cloudfront.net", Re = "https://d1ix11aj5kfygl.cloudfront.net", Te = "https://d157jlwnudd93d.cloudfront.net", xe = "https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws.com/dev", He = "https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging", Ne = "https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod", Ie = "https://embed-dev.vouchfor.com/v2", Ve = "https://embed-staging.vouchfor.com/v2", ke = "https://embed.vouchfor.com/v2", Oe = "https://dev.vouchfor.com", Me = "https://staging.vouchfor.com", Le = "https://app.vouchfor.com";
834
- function Y(n) {
835
- if (!["dev", "staging", "prod"].includes(n))
836
- throw new Error(`Unknown environment: ${n}`);
837
- if (n === "dev")
49
+ const devVideoUrl = "https://d2rxhdlm2q91uk.cloudfront.net";
50
+ const stagingVideoUrl = "https://d1ix11aj5kfygl.cloudfront.net";
51
+ const prodVideoUrl = "https://d157jlwnudd93d.cloudfront.net";
52
+ const devPublicApiUrl = "https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws.com/dev";
53
+ const stagingPublicApiUrl = "https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging";
54
+ const prodPublicApiUrl = "https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod";
55
+ const localEmbedApiUrl = "http://localhost:6060/v2";
56
+ const devEmbedApiUrl = "https://embed-dev.vouchfor.com/v2";
57
+ const stagingEmbedApiUrl = "https://embed-staging.vouchfor.com/v2";
58
+ const prodEmbedApiUrl = "https://embed.vouchfor.com/v2";
59
+ function getEnvUrls(env) {
60
+ if (!["local", "dev", "staging", "prod"].includes(env)) {
61
+ throw new Error(`Unknown environment: ${env}`);
62
+ }
63
+ if (env === "local") {
64
+ return {
65
+ videoUrl: devVideoUrl,
66
+ publicApiUrl: devPublicApiUrl,
67
+ embedApiUrl: localEmbedApiUrl
68
+ };
69
+ }
70
+ if (env === "dev") {
838
71
  return {
839
- marketingUrl: ht,
840
- videoUrl: Ue,
841
- publicApiUrl: xe,
842
- embedApiUrl: Ie,
843
- publicRecorderUrl: Oe
72
+ videoUrl: devVideoUrl,
73
+ publicApiUrl: devPublicApiUrl,
74
+ embedApiUrl: devEmbedApiUrl
844
75
  };
845
- if (n === "staging")
76
+ }
77
+ if (env === "staging") {
846
78
  return {
847
- marketingUrl: ht,
848
- videoUrl: Re,
849
- publicApiUrl: He,
850
- embedApiUrl: Ve,
851
- publicRecorderUrl: Me
79
+ videoUrl: stagingVideoUrl,
80
+ publicApiUrl: stagingPublicApiUrl,
81
+ embedApiUrl: stagingEmbedApiUrl
852
82
  };
853
- if (n === "prod")
83
+ }
84
+ if (env === "prod") {
854
85
  return {
855
- marketingUrl: ht,
856
- videoUrl: Te,
857
- publicApiUrl: Ne,
858
- embedApiUrl: ke,
859
- publicRecorderUrl: Le
86
+ videoUrl: prodVideoUrl,
87
+ publicApiUrl: prodPublicApiUrl,
88
+ embedApiUrl: prodEmbedApiUrl
860
89
  };
90
+ }
861
91
  }
862
- class De {
863
- constructor(t) {
864
- this._fetching = !1, this.getVouch = async (e, i, s) => {
865
- const { embedApiUrl: o } = Y(e), r = await fetch(`${o}/vouches/${s}`, {
866
- method: "GET",
867
- headers: [["X-Api-Key", i]]
868
- }).then((d) => (this.host.dispatchEvent(new CustomEvent("vouch:loaded", { detail: s })), d.json()));
869
- return fetch(`${o}/vouches/${s}`, {
92
+ class FetcherController {
93
+ constructor(host) {
94
+ this._fetching = false;
95
+ this.getVouch = async (env, apiKey, vouchId) => {
96
+ var _a;
97
+ const { embedApiUrl } = getEnvUrls(env);
98
+ const cacheCheck = v4();
99
+ const res = await fetch(`${embedApiUrl}/vouches/${vouchId}`, {
870
100
  method: "GET",
871
101
  headers: [
872
- ["X-Api-Key", i],
873
- ["Cache-Control", "max-age=0"]
102
+ ["X-Api-Key", apiKey],
103
+ ["X-Cache-Check", cacheCheck]
874
104
  ]
875
- }), r;
876
- }, this.getTemplate = async (e, i, s) => {
877
- const { embedApiUrl: o } = Y(e), r = await fetch(`${o}/templates/${s}`, {
878
- method: "GET",
879
- headers: [["X-Api-Key", i]]
880
- }).then((d) => d.json());
881
- return fetch(`${o}/templates/${s}`, {
105
+ });
106
+ const vouch = await res.json();
107
+ this.host.dispatchEvent(new CustomEvent("vouch:loaded", { detail: vouch == null ? void 0 : vouch.id }));
108
+ const resCacheCheck = (_a = res == null ? void 0 : res.headers) == null ? void 0 : _a.get("X-Cache-Check");
109
+ if (resCacheCheck !== cacheCheck) {
110
+ fetch(`${embedApiUrl}/vouches/${vouchId}`, {
111
+ method: "GET",
112
+ headers: [
113
+ ["X-Api-Key", apiKey],
114
+ ["Cache-Control", "max-age=0"]
115
+ ]
116
+ });
117
+ }
118
+ return vouch;
119
+ };
120
+ this.getTemplate = async (env, apiKey, templateId) => {
121
+ var _a;
122
+ const { embedApiUrl } = getEnvUrls(env);
123
+ const cacheCheck = v4();
124
+ const res = await fetch(`${embedApiUrl}/templates/${templateId}`, {
882
125
  method: "GET",
883
126
  headers: [
884
- ["X-Api-Key", i],
885
- ["Cache-Control", "max-age=0"]
127
+ ["X-Api-Key", apiKey],
128
+ ["X-Cache-Check", cacheCheck]
886
129
  ]
887
- }), r;
888
- }, this.host = t, new te(
130
+ });
131
+ const template = await res.json();
132
+ const resCacheCheck = (_a = res == null ? void 0 : res.headers) == null ? void 0 : _a.get("X-Cache-Check");
133
+ if (resCacheCheck !== cacheCheck) {
134
+ fetch(`${embedApiUrl}/templates/${templateId}`, {
135
+ method: "GET",
136
+ headers: [
137
+ ["X-Api-Key", apiKey],
138
+ ["Cache-Control", "max-age=0"]
139
+ ]
140
+ });
141
+ }
142
+ return template;
143
+ };
144
+ this.host = host;
145
+ new Task(
889
146
  this.host,
890
- async ([e, i, s, o, r]) => {
891
- var d, l, a, u;
147
+ async ([env, apiKey, data, vouchId, templateId]) => {
148
+ var _a, _b, _c, _d;
892
149
  try {
893
- if (t.vouch = void 0, t.template = void 0, s) {
894
- let h;
895
- r && (this.fetching = !0, h = await this.getTemplate(e, i, r)), t.vouch = s, t.template = h ?? ((l = (d = s == null ? void 0 : s.settings) == null ? void 0 : d.template) == null ? void 0 : l.instance);
896
- } else if (o) {
897
- this.fetching = !0;
898
- const [h, c] = await Promise.all([
899
- this.getVouch(e, i, o),
900
- r ? this.getTemplate(e, i, r) : null
150
+ host.vouch = void 0;
151
+ host.template = void 0;
152
+ if (data) {
153
+ let template;
154
+ if (templateId) {
155
+ this.fetching = true;
156
+ template = await this.getTemplate(env, apiKey, templateId);
157
+ }
158
+ this._vouch = data;
159
+ host.template = template ?? ((_b = (_a = data == null ? void 0 : data.settings) == null ? void 0 : _a.template) == null ? void 0 : _b.instance);
160
+ } else if (vouchId) {
161
+ this.fetching = true;
162
+ const [vouch, template] = await Promise.all([
163
+ this.getVouch(env, apiKey, vouchId),
164
+ templateId ? this.getTemplate(env, apiKey, templateId) : null
901
165
  ]);
902
- t.vouch = h, t.template = c ?? ((u = (a = h == null ? void 0 : h.settings) == null ? void 0 : a.template) == null ? void 0 : u.instance);
166
+ this._vouch = vouch;
167
+ host.template = template ?? ((_d = (_c = vouch == null ? void 0 : vouch.settings) == null ? void 0 : _c.template) == null ? void 0 : _d.instance);
903
168
  }
904
169
  } finally {
905
- this.fetching = !1;
170
+ this.fetching = false;
906
171
  }
907
172
  },
908
- () => [t.env, t.apiKey, t.data, t.vouchId, t.templateId]
173
+ () => [host.env, host.apiKey, host.data, host.vouchId, host.templateId]
174
+ );
175
+ new Task(
176
+ this.host,
177
+ ([vouch, questions]) => {
178
+ host.vouch = vouch ? {
179
+ ...vouch,
180
+ questions: {
181
+ items: vouch == null ? void 0 : vouch.questions.items.filter((_, index) => !(questions == null ? void 0 : questions.length) || (questions == null ? void 0 : questions.includes(index + 1)))
182
+ }
183
+ } : void 0;
184
+ },
185
+ () => [this._vouch, host.questions]
909
186
  );
910
187
  }
911
- set fetching(t) {
912
- this._fetching !== t && (this._fetching = t, this.host.requestUpdate());
188
+ set fetching(value) {
189
+ if (this._fetching !== value) {
190
+ this._fetching = value;
191
+ this.host.requestUpdate();
192
+ }
913
193
  }
914
194
  get fetching() {
915
195
  return this._fetching;
916
196
  }
917
197
  }
918
- let Z;
919
- const je = new Uint8Array(16);
920
- function Be() {
921
- if (!Z && (Z = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !Z))
922
- throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
923
- return Z(je);
198
+ const name = "@vouchfor/embeds";
199
+ const version = "0.0.0-experiment.8b8f3c7";
200
+ const license = "MIT";
201
+ const author = "Aaron Williams";
202
+ const main = "dist/es/embeds.js";
203
+ const module = "dist/es/embeds.js";
204
+ const type = "module";
205
+ const types = "dist/es/src/index.d.ts";
206
+ const exports = {
207
+ ".": "./dist/es/embeds.js"
208
+ };
209
+ const files = [
210
+ "dist",
211
+ "src"
212
+ ];
213
+ const publishConfig = {
214
+ tag: "experiment",
215
+ access: "public"
216
+ };
217
+ const engines = {
218
+ node: ">=18.18.0"
219
+ };
220
+ const scripts = {
221
+ build: "rm -rf dist && tsc && yarn build:self",
222
+ "build:deps": "yarn --cwd ../media-player build",
223
+ "build:self": "vite build --mode iife && vite build --mode es && node scripts/build.cjs",
224
+ "build:package": "yarn build",
225
+ "build:storybook": "yarn prebuild && storybook build",
226
+ "generate:manifest": "wca src --outFile custom-elements.json",
227
+ lint: "eslint . --quiet",
228
+ "lint:fix": "eslint . --fix",
229
+ "lint:staged": "lint-staged",
230
+ prepublishOnly: "yarn build",
231
+ size: "size-limit",
232
+ storybook: "yarn prebuild && storybook dev -p 6007",
233
+ prebuild: "yarn build:deps && yarn generate:manifest",
234
+ test: "rm -rf test/lib && yarn prebuild && vite build --mode test && web-test-runner",
235
+ "test:ci": "yarn test --config web-test-runner.ci.config.js",
236
+ "test:watch": "yarn test --watch"
237
+ };
238
+ const dependencies = {
239
+ "@a11y/focus-trap": "^1.0.5",
240
+ "@lit/task": "^1.0.0",
241
+ "@vouchfor/canvas-video": "0.0.0-experiment.8b8f3c7",
242
+ "@vouchfor/media-player": "0.0.0-experiment.8b8f3c7",
243
+ uuid: "^9.0.1"
244
+ };
245
+ const peerDependencies = {
246
+ lit: "^3.1.2"
247
+ };
248
+ const devDependencies = {
249
+ "@esm-bundle/chai": "^4.3.4-fix.0",
250
+ "@open-wc/testing": "^4.0.0",
251
+ "@storybook/addon-essentials": "^8.0.4",
252
+ "@storybook/addon-links": "^8.0.4",
253
+ "@storybook/blocks": "^8.0.4",
254
+ "@storybook/web-components": "^8.0.4",
255
+ "@storybook/web-components-vite": "^8.0.4",
256
+ "@svgr/core": "^8.1.0",
257
+ "@types/flat": "^5.0.5",
258
+ "@types/mocha": "^10.0.6",
259
+ "@vouchfor/eslint-config": "^1.0.1",
260
+ "@vouchfor/prettier-config": "^1.0.1",
261
+ "@vouchfor/video-utils": "0.0.0-experiment.8b8f3c7",
262
+ "@web/dev-server-esbuild": "^1.0.2",
263
+ "@web/test-runner": "^0.18.1",
264
+ "@web/test-runner-browserstack": "^0.7.1",
265
+ "@web/test-runner-mocha": "^0.9.0",
266
+ "@web/test-runner-playwright": "^0.11.0",
267
+ glob: "^10.3.10",
268
+ "lint-staged": "^15.2.2",
269
+ lit: "^3.1.2",
270
+ lodash: "^4.17.21",
271
+ react: "^18.2.0",
272
+ "react-dom": "^18.2.0",
273
+ "rollup-plugin-tla": "^0.0.2",
274
+ sinon: "^17.0.1",
275
+ storybook: "^8.0.4",
276
+ svgson: "^5.3.1",
277
+ typescript: "^5.4.3",
278
+ vite: "^5.2.2",
279
+ "vite-plugin-commonjs": "^0.10.1",
280
+ "vite-plugin-dts": "^3.7.3",
281
+ "web-component-analyzer": "^2.0.0"
282
+ };
283
+ const packageJson = {
284
+ name,
285
+ version,
286
+ license,
287
+ author,
288
+ main,
289
+ module,
290
+ type,
291
+ types,
292
+ exports,
293
+ files,
294
+ publishConfig,
295
+ engines,
296
+ scripts,
297
+ "lint-staged": {
298
+ "**/*.{ts,tsx,js}": "eslint --fix --quiet",
299
+ "**/*.{md,json,yml}": "prettier --write"
300
+ },
301
+ dependencies,
302
+ peerDependencies,
303
+ devDependencies
304
+ };
305
+ function createVisitor(env) {
306
+ const { publicApiUrl } = getEnvUrls(env);
307
+ const visitorId = v4();
308
+ navigator.sendBeacon(`${publicApiUrl}/api/visitor`, JSON.stringify({ visitorId }));
309
+ return visitorId;
924
310
  }
925
- const $ = [];
926
- for (let n = 0; n < 256; ++n)
927
- $.push((n + 256).toString(16).slice(1));
928
- function ze(n, t = 0) {
929
- return $[n[t + 0]] + $[n[t + 1]] + $[n[t + 2]] + $[n[t + 3]] + "-" + $[n[t + 4]] + $[n[t + 5]] + "-" + $[n[t + 6]] + $[n[t + 7]] + "-" + $[n[t + 8]] + $[n[t + 9]] + "-" + $[n[t + 10]] + $[n[t + 11]] + $[n[t + 12]] + $[n[t + 13]] + $[n[t + 14]] + $[n[t + 15]];
311
+ function getUids(env) {
312
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
313
+ if (typeof window === "undefined") {
314
+ return {
315
+ client: null,
316
+ tab: null,
317
+ request: v4()
318
+ };
319
+ }
320
+ let visitorId = (_b = (_a = window.localStorage) == null ? void 0 : _a.getItem) == null ? void 0 : _b.call(_a, "vouch-uid-visitor");
321
+ let clientId = (_d = (_c = window.localStorage) == null ? void 0 : _c.getItem) == null ? void 0 : _d.call(_c, "vouch-uid-client");
322
+ let tabId = (_f = (_e = window.sessionStorage) == null ? void 0 : _e.getItem) == null ? void 0 : _f.call(_e, "vouch-uid-tab");
323
+ const requestId = v4();
324
+ if (!visitorId) {
325
+ visitorId = createVisitor(env);
326
+ (_h = (_g = window.localStorage) == null ? void 0 : _g.setItem) == null ? void 0 : _h.call(_g, "vouch-uid-visitor", visitorId);
327
+ }
328
+ if (!clientId) {
329
+ clientId = v4();
330
+ (_j = (_i = window.localStorage) == null ? void 0 : _i.setItem) == null ? void 0 : _j.call(_i, "vouch-uid-client", clientId);
331
+ }
332
+ if (!tabId) {
333
+ tabId = v4();
334
+ (_l = (_k = window.sessionStorage) == null ? void 0 : _k.setItem) == null ? void 0 : _l.call(_k, "vouch-uid-tab", tabId);
335
+ }
336
+ return {
337
+ client: clientId,
338
+ tab: tabId,
339
+ request: requestId,
340
+ visitor: visitorId
341
+ };
930
342
  }
931
- const qe = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Ot = {
932
- randomUUID: qe
933
- };
934
- function M(n, t, e) {
935
- if (Ot.randomUUID && !t && !n)
936
- return Ot.randomUUID();
937
- n = n || {};
938
- const i = n.random || (n.rng || Be)();
939
- if (i[6] = i[6] & 15 | 64, i[8] = i[8] & 63 | 128, t) {
940
- e = e || 0;
941
- for (let s = 0; s < 16; ++s)
942
- t[e + s] = i[s];
943
- return t;
343
+ function findVouchId(payload, vouch) {
344
+ if (payload && "vouchId" in payload) {
345
+ return payload.vouchId;
944
346
  }
945
- return ze(i);
347
+ return (vouch == null ? void 0 : vouch.id) ?? null;
946
348
  }
947
- const We = 2e3;
948
- class Ze {
949
- constructor(t) {
950
- this._tabId = void 0, this._clientId = void 0, this._visitorId = void 0, this._hasPlayed = !1, this._hasLoaded = {}, this._answersViewed = {}, this._streamedTime = {}, this._streamedPrevTimestamp = {}, this._createVisitor = (e) => {
951
- var s, o;
952
- const { publicApiUrl: i } = Y(this.host.env);
953
- return (o = (s = window.localStorage) == null ? void 0 : s.setItem) == null || o.call(s, "vouch-uid-visitor", e), navigator.sendBeacon(`${i}/api/visitor`, JSON.stringify({ visitorId: e })), e;
954
- }, this._getReportingMetadata = () => {
955
- var o, r;
956
- const [e, i] = ((r = (o = Intl.DateTimeFormat().resolvedOptions().timeZone) == null ? void 0 : o.split) == null ? void 0 : r.call(o, "/")) ?? [], s = {};
957
- return [...new URLSearchParams(location.search).entries()].forEach(([d, l]) => {
958
- if (/utm/.test(d)) {
959
- const a = d.toLowerCase().replace(/[-_][a-z0-9]/g, (u) => u.slice(-1).toUpperCase());
960
- s[a] = l;
349
+ function getReportingMetadata(source = "embedded_player") {
350
+ var _a, _b;
351
+ const [country, region] = ((_b = (_a = Intl.DateTimeFormat().resolvedOptions().timeZone) == null ? void 0 : _a.split) == null ? void 0 : _b.call(_a, "/")) ?? [];
352
+ const utmParams = {};
353
+ [...new URLSearchParams(location.search).entries()].forEach(([key, value]) => {
354
+ if (/utm/.test(key)) {
355
+ const param = key.toLowerCase().replace(/[-_][a-z0-9]/g, (group) => group.slice(-1).toUpperCase());
356
+ utmParams[param] = value;
357
+ }
358
+ });
359
+ return {
360
+ source,
361
+ time: /* @__PURE__ */ new Date(),
362
+ region,
363
+ country,
364
+ screenHeight: window.screen.height,
365
+ screenWidth: window.screen.width,
366
+ referrer: document.referrer,
367
+ currentUrl: location.href,
368
+ embedType: "media-player-embed",
369
+ embedVersion: packageJson.version,
370
+ templateVersion: TEMPLATE_VERSION,
371
+ ...utmParams
372
+ };
373
+ }
374
+ const MINIMUM_SEND_THRESHOLD = 1;
375
+ class TrackingController {
376
+ constructor(host) {
377
+ this._batchedEvents = [];
378
+ this._hasPlayed = false;
379
+ this._hasLoaded = {};
380
+ this._answersViewed = {};
381
+ this._streamStartTime = {};
382
+ this._streamLatestTime = {};
383
+ this._currentlyPlayingVideo = null;
384
+ this._createTrackingEvent = (event, payload) => {
385
+ const vouchId = findVouchId(payload, this.host.vouch);
386
+ if (!vouchId || this.host.disableTracking) {
387
+ return;
388
+ }
389
+ this._batchedEvents.push({
390
+ event,
391
+ payload: {
392
+ ...payload,
393
+ vouchId,
394
+ time: (/* @__PURE__ */ new Date()).toISOString()
961
395
  }
962
- }), {
963
- source: this.host.trackingSource,
964
- time: /* @__PURE__ */ new Date(),
965
- region: i,
966
- country: e,
967
- screenHeight: window.screen.height,
968
- screenWidth: window.screen.width,
969
- referrer: document.referrer,
970
- currentUrl: location.href,
971
- ...s
972
- };
973
- }, this._sendTrackingEvent = (e, i) => {
974
- const { publicApiUrl: s } = Y(this.host.env), { client: o, tab: r, request: d, visitor: l } = this._getUids();
396
+ });
397
+ };
398
+ this._sendTrackingEvent = () => {
399
+ if (this._batchedEvents.length <= 0) {
400
+ return;
401
+ }
402
+ const { publicApiUrl } = getEnvUrls(this.host.env);
403
+ const { client, tab, request, visitor } = getUids(this.host.env);
975
404
  navigator.sendBeacon(
976
- `${s}/api/events`,
405
+ `${publicApiUrl}/api/batchevents`,
977
406
  JSON.stringify({
978
- event: e,
979
- payload: i,
407
+ payload: {
408
+ events: this._batchedEvents
409
+ },
980
410
  context: {
981
- "x-uid-client": o,
982
- "x-uid-tab": r,
983
- "x-uid-request": d,
984
- "x-uid-visitor": l,
985
- "x-reporting-metadata": this._getReportingMetadata()
411
+ "x-uid-client": client,
412
+ "x-uid-tab": tab,
413
+ "x-uid-request": request,
414
+ "x-uid-visitor": visitor,
415
+ "x-reporting-metadata": getReportingMetadata(this.host.trackingSource)
986
416
  }
987
417
  })
988
418
  );
989
- }, this._handleVouchLoaded = ({ detail: e }) => {
990
- e && (this._hasLoaded[e] || (this._sendTrackingEvent("VOUCH_LOADED", {
991
- vouchId: e
992
- }), this._hasLoaded[e] = !0));
993
- }, this._handlePlay = () => {
994
- const e = this._findVouchId();
995
- e && (this._hasPlayed || (this._sendTrackingEvent("VIDEO_PLAYED", {
996
- vouchId: e,
997
- streamStart: this.host.currentTime
998
- }), this._hasPlayed = !0));
999
- }, this._handleVideoPlay = ({ detail: { id: e, node: i } }) => {
1000
- const s = this._findVouchId();
1001
- s && (this._answersViewed[e] || (this._sendTrackingEvent("VOUCH_RESPONSE_VIEWED", {
1002
- vouchId: s,
1003
- answerId: e
1004
- }), this._answersViewed[e] = !0), this._streamedTime[e] = i.currentTime, this._streamedPrevTimestamp[e] = Date.now());
1005
- }, this._handleVideoTimeUpdate = ({ detail: { id: e, node: i } }) => {
1006
- var r, d;
1007
- const s = this._findVouchId();
1008
- if (!s)
419
+ this._batchedEvents = [];
420
+ };
421
+ this._streamEnded = () => {
422
+ if (this._currentlyPlayingVideo) {
423
+ const { id, key } = this._currentlyPlayingVideo;
424
+ if (this._streamLatestTime[key] > this._streamStartTime[key] + MINIMUM_SEND_THRESHOLD) {
425
+ this._createTrackingEvent("VIDEO_STREAMED", {
426
+ answerId: id,
427
+ streamStart: this._streamStartTime[key],
428
+ streamEnd: this._streamLatestTime[key]
429
+ });
430
+ }
431
+ delete this._streamStartTime[key];
432
+ delete this._streamLatestTime[key];
433
+ }
434
+ };
435
+ this._handleVouchLoaded = ({ detail: vouchId }) => {
436
+ if (!vouchId) {
1009
437
  return;
1010
- const o = Date.now();
1011
- !this.host.paused && // Only fire the video seeked event when this video is the active one
1012
- e === ((d = (r = this.host.scene) == null ? void 0 : r.video) == null ? void 0 : d.id) && // Throttle the frequency that we send streamed events while playing
1013
- o - this._streamedPrevTimestamp[e] > We && (this._sendTrackingEvent("VIDEO_STREAMED", {
1014
- vouchId: s,
1015
- answerId: e,
1016
- streamStart: this._streamedTime[e],
1017
- streamEnd: i.currentTime
1018
- }), this._streamedTime[e] = i.currentTime, this._streamedPrevTimestamp[e] = o);
1019
- }, this._handleVideoPause = ({ detail: { id: e, node: i } }) => {
1020
- const s = this._findVouchId();
1021
- s && (this._sendTrackingEvent("VIDEO_STREAMED", {
1022
- vouchId: s,
1023
- answerId: e,
1024
- streamStart: this._streamedTime[e],
1025
- streamEnd: i.currentTime
1026
- }), delete this._streamedTime[e], delete this._streamedPrevTimestamp[e]);
1027
- }, this.host = t, t.addController(this);
1028
- }
1029
- _findVouchId() {
1030
- if (this.host.data)
1031
- return "uuid" in this.host.data ? this.host.data.uuid : this.host.data.id;
1032
- }
1033
- _getUids() {
1034
- var o, r, d, l, a, u, h, c, p, y, m, $t;
1035
- if (typeof window > "u")
1036
- return {
1037
- client: null,
1038
- tab: null,
1039
- request: M()
1040
- };
1041
- const t = this._visitorId || ((r = (o = window.localStorage) == null ? void 0 : o.getItem) == null ? void 0 : r.call(o, "vouch-uid-visitor")) || this._createVisitor(M()), e = this._clientId || ((l = (d = window.localStorage) == null ? void 0 : d.getItem) == null ? void 0 : l.call(d, "vouch-uid-client")) || M(), i = this._tabId || ((u = (a = window.sessionStorage) == null ? void 0 : a.getItem) == null ? void 0 : u.call(a, "vouch-uid-tab")) || M(), s = M();
1042
- return t !== this._visitorId && (this._visitorId = t, (c = (h = window.localStorage) == null ? void 0 : h.setItem) == null || c.call(h, "vouch-uid-visitor", t)), e !== this._clientId && (this._clientId = e, (y = (p = window.localStorage) == null ? void 0 : p.setItem) == null || y.call(p, "vouch-uid-client", e)), i !== this._tabId && (this._tabId = i, ($t = (m = window.sessionStorage) == null ? void 0 : m.setItem) == null || $t.call(m, "vouch-uid-tab", i)), {
1043
- client: e,
1044
- tab: i,
1045
- request: s,
1046
- visitor: t
438
+ }
439
+ if (!this._hasLoaded[vouchId]) {
440
+ this._createTrackingEvent("VOUCH_LOADED", { vouchId });
441
+ this._hasLoaded[vouchId] = true;
442
+ }
443
+ };
444
+ this._handlePlay = () => {
445
+ if (!this._hasPlayed) {
446
+ this._createTrackingEvent("VIDEO_PLAYED", {
447
+ streamStart: this.host.currentTime
448
+ });
449
+ this._hasPlayed = true;
450
+ }
451
+ };
452
+ this._handleVideoPlay = ({ detail: { id, key } }) => {
453
+ if (!this._answersViewed[key]) {
454
+ this._createTrackingEvent("VOUCH_RESPONSE_VIEWED", {
455
+ answerId: id
456
+ });
457
+ this._answersViewed[key] = true;
458
+ }
459
+ };
460
+ this._handleVideoTimeUpdate = ({ detail: { id, key, node } }) => {
461
+ var _a, _b;
462
+ if (
463
+ // We only want to count any time that the video is actually playing
464
+ !this.host.paused && // Only update the latest time if this event fires for the currently active video
465
+ id === ((_b = (_a = this.host.scene) == null ? void 0 : _a.video) == null ? void 0 : _b.id)
466
+ ) {
467
+ this._currentlyPlayingVideo = { id, key, node };
468
+ this._streamLatestTime[key] = node.currentTime;
469
+ if (!this._streamStartTime[key]) {
470
+ this._streamStartTime[key] = node.currentTime;
471
+ this._streamLatestTime[key] = node.currentTime;
472
+ }
473
+ }
1047
474
  };
475
+ this._handleVideoPause = ({ detail: { id, key } }) => {
476
+ if (this._streamLatestTime[key] > this._streamStartTime[key] + MINIMUM_SEND_THRESHOLD) {
477
+ this._createTrackingEvent("VIDEO_STREAMED", {
478
+ answerId: id,
479
+ streamStart: this._streamStartTime[key],
480
+ streamEnd: this._streamLatestTime[key]
481
+ });
482
+ }
483
+ delete this._streamStartTime[key];
484
+ delete this._streamLatestTime[key];
485
+ };
486
+ this._pageUnloading = () => {
487
+ this._streamEnded();
488
+ this._sendTrackingEvent();
489
+ };
490
+ this._handleVisibilityChange = () => {
491
+ if (document.visibilityState === "hidden") {
492
+ this._pageUnloading();
493
+ }
494
+ };
495
+ this._handlePageHide = () => {
496
+ this._pageUnloading();
497
+ };
498
+ this.host = host;
499
+ host.addController(this);
1048
500
  }
1049
501
  hostConnected() {
1050
502
  requestAnimationFrame(() => {
1051
- var t, e, i, s;
1052
- 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);
503
+ var _a, _b, _c, _d;
504
+ if ("onvisibilitychange" in document) {
505
+ document.addEventListener("visibilitychange", this._handleVisibilityChange);
506
+ } else {
507
+ window.addEventListener("pagehide", this._handlePageHide);
508
+ }
509
+ this.host.addEventListener("vouch:loaded", this._handleVouchLoaded);
510
+ (_a = this.host.mediaPlayer) == null ? void 0 : _a.addEventListener("play", this._handlePlay);
511
+ (_b = this.host.mediaPlayer) == null ? void 0 : _b.addEventListener("video:play", this._handleVideoPlay);
512
+ (_c = this.host.mediaPlayer) == null ? void 0 : _c.addEventListener("video:pause", this._handleVideoPause);
513
+ (_d = this.host.mediaPlayer) == null ? void 0 : _d.addEventListener("video:timeupdate", this._handleVideoTimeUpdate);
1053
514
  });
1054
515
  }
1055
516
  hostDisconnected() {
1056
- var t, e, i, s;
1057
- 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);
517
+ var _a, _b, _c, _d;
518
+ this._pageUnloading();
519
+ if ("onvisibilitychange" in document) {
520
+ document.removeEventListener("visibilitychange", this._handleVisibilityChange);
521
+ } else {
522
+ window.removeEventListener("pagehide", this._handlePageHide);
523
+ }
524
+ this.host.removeEventListener("vouch:loaded", this._handleVouchLoaded);
525
+ (_a = this.host.mediaPlayer) == null ? void 0 : _a.removeEventListener("play", this._handlePlay);
526
+ (_b = this.host.mediaPlayer) == null ? void 0 : _b.removeEventListener("video:play", this._handleVideoPlay);
527
+ (_c = this.host.mediaPlayer) == null ? void 0 : _c.removeEventListener("video:pause", this._handleVideoPause);
528
+ (_d = this.host.mediaPlayer) == null ? void 0 : _d.removeEventListener("video:timeupdate", this._handleVideoTimeUpdate);
1058
529
  }
1059
530
  }
1060
- var Fe = Object.defineProperty, Ke = Object.getOwnPropertyDescriptor, f = (n, t, e, i) => {
1061
- for (var s = i > 1 ? void 0 : i ? Ke(t, e) : t, o = n.length - 1, r; o >= 0; o--)
1062
- (r = n[o]) && (s = (i ? r(t, e, s) : r(s)) || s);
1063
- return i && s && Fe(t, e, s), s;
531
+ var __defProp$3 = Object.defineProperty;
532
+ var __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor;
533
+ var __decorateClass$3 = (decorators, target, key, kind) => {
534
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target;
535
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
536
+ if (decorator = decorators[i])
537
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
538
+ if (kind && result)
539
+ __defProp$3(target, key, result);
540
+ return result;
1064
541
  };
1065
- let g = class extends L {
542
+ let PlayerEmbed = class extends LitElement {
1066
543
  constructor() {
1067
- super(...arguments), this._mediaPlayerRef = Lt(), this.env = "prod", this.apiKey = "", this.trackingSource = "embed", this.preload = "auto", this.autoplay = !1, this.aspectRatio = 0, this.eventController = new Ce(this, [
544
+ super(...arguments);
545
+ this.env = "prod";
546
+ this.apiKey = "";
547
+ this.disableTracking = false;
548
+ this.trackingSource = "embedded_player";
549
+ this.preload = "auto";
550
+ this.autoplay = false;
551
+ this.aspectRatio = 0;
552
+ this.eventController = new EventForwardController(this, [
1068
553
  "durationchange",
1069
554
  "ended",
1070
555
  "error",
@@ -1075,12 +560,15 @@ let g = class extends L {
1075
560
  "playing",
1076
561
  "ratechange",
1077
562
  "scenechange",
563
+ "scenesupdate",
1078
564
  "seeking",
1079
565
  "seeked",
1080
566
  "timeupdate",
1081
567
  "volumechange",
568
+ "processing",
1082
569
  "waiting",
1083
570
  "video:loadeddata",
571
+ "video:seeking",
1084
572
  "video:seeked",
1085
573
  "video:play",
1086
574
  "video:playing",
@@ -1089,146 +577,579 @@ let g = class extends L {
1089
577
  "video:timeupdate",
1090
578
  "video:ended",
1091
579
  "video:error"
1092
- ]), this._fetcherController = new De(this), this._trackingController = new Ze(this);
580
+ ]);
581
+ this._fetcherController = new FetcherController(this);
582
+ this._trackingController = new TrackingController(this);
583
+ this._mediaPlayerRef = createRef();
1093
584
  }
1094
585
  get fetching() {
1095
586
  return this._fetcherController.fetching;
1096
587
  }
1097
588
  get waiting() {
1098
- var n;
1099
- return (n = this._mediaPlayerRef.value) == null ? void 0 : n.waiting;
589
+ var _a;
590
+ return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.waiting;
591
+ }
592
+ get initialised() {
593
+ var _a;
594
+ return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.initialised;
1100
595
  }
1101
596
  get seeking() {
1102
- var n;
1103
- return (n = this._mediaPlayerRef.value) == null ? void 0 : n.seeking;
597
+ var _a;
598
+ return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.seeking;
1104
599
  }
1105
600
  get paused() {
1106
- var n;
1107
- return (n = this._mediaPlayerRef.value) == null ? void 0 : n.paused;
601
+ var _a;
602
+ return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.paused;
1108
603
  }
1109
604
  get captions() {
1110
- var n;
1111
- return (n = this._mediaPlayerRef.value) == null ? void 0 : n.captions;
605
+ var _a;
606
+ return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.captions;
1112
607
  }
1113
608
  get fullscreen() {
1114
- var n;
1115
- return (n = this._mediaPlayerRef.value) == null ? void 0 : n.fullscreen;
609
+ var _a;
610
+ return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.fullscreen;
1116
611
  }
1117
612
  get duration() {
1118
- var n;
1119
- return (n = this._mediaPlayerRef.value) == null ? void 0 : n.duration;
613
+ var _a;
614
+ return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.duration;
1120
615
  }
1121
- set currentTime(n) {
1122
- this._mediaPlayerRef.value && (this._mediaPlayerRef.value.currentTime = n);
616
+ set currentTime(value) {
617
+ if (this._mediaPlayerRef.value) {
618
+ this._mediaPlayerRef.value.currentTime = value;
619
+ }
1123
620
  }
1124
621
  get currentTime() {
1125
- var n;
1126
- return ((n = this._mediaPlayerRef.value) == null ? void 0 : n.currentTime) ?? 0;
622
+ var _a;
623
+ return ((_a = this._mediaPlayerRef.value) == null ? void 0 : _a.currentTime) ?? 0;
1127
624
  }
1128
- set playbackRate(n) {
1129
- this._mediaPlayerRef.value && (this._mediaPlayerRef.value.playbackRate = n);
625
+ set playbackRate(value) {
626
+ if (this._mediaPlayerRef.value) {
627
+ this._mediaPlayerRef.value.playbackRate = value;
628
+ }
1130
629
  }
1131
630
  get playbackRate() {
1132
- var n;
1133
- return ((n = this._mediaPlayerRef.value) == null ? void 0 : n.playbackRate) ?? 1;
631
+ var _a;
632
+ return ((_a = this._mediaPlayerRef.value) == null ? void 0 : _a.playbackRate) ?? 1;
1134
633
  }
1135
- set volume(n) {
1136
- this._mediaPlayerRef.value && (this._mediaPlayerRef.value.volume = n);
634
+ set volume(value) {
635
+ if (this._mediaPlayerRef.value) {
636
+ this._mediaPlayerRef.value.volume = value;
637
+ }
1137
638
  }
1138
639
  get volume() {
1139
- var n;
1140
- return ((n = this._mediaPlayerRef.value) == null ? void 0 : n.volume) ?? 1;
640
+ var _a;
641
+ return ((_a = this._mediaPlayerRef.value) == null ? void 0 : _a.volume) ?? 1;
1141
642
  }
1142
- set muted(n) {
1143
- this._mediaPlayerRef.value && (this._mediaPlayerRef.value.muted = n);
643
+ set muted(value) {
644
+ if (this._mediaPlayerRef.value) {
645
+ this._mediaPlayerRef.value.muted = value;
646
+ }
1144
647
  }
1145
648
  get muted() {
1146
- var n;
1147
- return ((n = this._mediaPlayerRef.value) == null ? void 0 : n.muted) ?? !1;
649
+ var _a;
650
+ return ((_a = this._mediaPlayerRef.value) == null ? void 0 : _a.muted) ?? false;
1148
651
  }
1149
652
  get scene() {
1150
- var n;
1151
- return ((n = this._mediaPlayerRef.value) == null ? void 0 : n.scene) ?? null;
653
+ var _a;
654
+ return ((_a = this._mediaPlayerRef.value) == null ? void 0 : _a.scene) ?? null;
1152
655
  }
1153
656
  get scenes() {
1154
- var n;
1155
- return ((n = this._mediaPlayerRef.value) == null ? void 0 : n.scenes) ?? [];
657
+ var _a;
658
+ return ((_a = this._mediaPlayerRef.value) == null ? void 0 : _a.scenes) ?? [];
659
+ }
660
+ get sceneConfig() {
661
+ var _a;
662
+ return ((_a = this._mediaPlayerRef.value) == null ? void 0 : _a.sceneConfig) ?? null;
1156
663
  }
1157
664
  get videoState() {
1158
- var n;
1159
- return (n = this._mediaPlayerRef.value) == null ? void 0 : n.videoState;
665
+ var _a;
666
+ return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.videoState;
1160
667
  }
1161
668
  get mediaPlayer() {
1162
669
  return this._mediaPlayerRef.value;
1163
670
  }
1164
671
  play() {
1165
- var n;
1166
- (n = this._mediaPlayerRef.value) == null || n.play();
672
+ var _a;
673
+ (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.play();
1167
674
  }
1168
675
  pause() {
1169
- var n;
1170
- (n = this._mediaPlayerRef.value) == null || n.pause();
676
+ var _a;
677
+ (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.pause();
678
+ }
679
+ reset(time = 0, play = false) {
680
+ var _a;
681
+ (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.reset(time, play);
682
+ }
683
+ setScene(index) {
684
+ var _a;
685
+ (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.setScene(index);
686
+ }
687
+ _renderStyles() {
688
+ if (!this.aspectRatio) {
689
+ return html`
690
+ <style>
691
+ :host {
692
+ width: 100%;
693
+ height: 100%;
694
+ }
695
+ </style>
696
+ `;
697
+ }
698
+ if (typeof this.aspectRatio === "number") {
699
+ return html`
700
+ <style>
701
+ :host {
702
+ aspect-ratio: ${this.aspectRatio};
703
+ }
704
+ </style>
705
+ `;
706
+ }
707
+ return null;
1171
708
  }
1172
- setScene(n) {
1173
- var t;
1174
- (t = this._mediaPlayerRef.value) == null || t.setScene(n);
709
+ willUpdate(changedProperties) {
710
+ if (changedProperties.has("vouchId") && this.vouchId !== changedProperties.get("vouchId")) {
711
+ this.reset(0, false);
712
+ }
1175
713
  }
1176
714
  render() {
1177
- return me`
1178
- <vmp-new-media-player
1179
- ${Dt(this._mediaPlayerRef)}
715
+ return html`
716
+ ${this._renderStyles()}
717
+ <vmp-media-player
718
+ ${ref(this._mediaPlayerRef)}
1180
719
  ${this.eventController.register()}
1181
720
  ?autoplay=${this.autoplay}
1182
721
  ?loading=${this.fetching}
1183
722
  .data=${this.vouch}
1184
723
  .template=${this.template}
1185
- aspectRatio=${mt(this.aspectRatio)}
1186
- preload=${mt(this.preload)}
724
+ aspectRatio=${ifDefined(this.aspectRatio)}
725
+ preload=${ifDefined(this.preload)}
726
+ language=${ifDefined(this.language)}
1187
727
  .controls=${this.controls}
1188
- ></vmp-new-media-player>
728
+ ></vmp-media-player>
729
+ `;
730
+ }
731
+ };
732
+ PlayerEmbed.styles = [
733
+ css`
734
+ :host {
735
+ display: flex;
736
+ }
737
+ `
738
+ ];
739
+ __decorateClass$3([
740
+ property({ type: Object })
741
+ ], PlayerEmbed.prototype, "data", 2);
742
+ __decorateClass$3([
743
+ property({ type: String })
744
+ ], PlayerEmbed.prototype, "vouchId", 2);
745
+ __decorateClass$3([
746
+ property({ type: String })
747
+ ], PlayerEmbed.prototype, "templateId", 2);
748
+ __decorateClass$3([
749
+ property({ type: Array })
750
+ ], PlayerEmbed.prototype, "questions", 2);
751
+ __decorateClass$3([
752
+ property({ type: String })
753
+ ], PlayerEmbed.prototype, "env", 2);
754
+ __decorateClass$3([
755
+ property({ type: String })
756
+ ], PlayerEmbed.prototype, "apiKey", 2);
757
+ __decorateClass$3([
758
+ property({ type: Boolean })
759
+ ], PlayerEmbed.prototype, "disableTracking", 2);
760
+ __decorateClass$3([
761
+ property({ type: String })
762
+ ], PlayerEmbed.prototype, "trackingSource", 2);
763
+ __decorateClass$3([
764
+ property({ type: Array })
765
+ ], PlayerEmbed.prototype, "controls", 2);
766
+ __decorateClass$3([
767
+ property({ type: String })
768
+ ], PlayerEmbed.prototype, "preload", 2);
769
+ __decorateClass$3([
770
+ property({ type: Boolean })
771
+ ], PlayerEmbed.prototype, "autoplay", 2);
772
+ __decorateClass$3([
773
+ property({ type: Number })
774
+ ], PlayerEmbed.prototype, "aspectRatio", 2);
775
+ __decorateClass$3([
776
+ property({ type: String })
777
+ ], PlayerEmbed.prototype, "language", 2);
778
+ __decorateClass$3([
779
+ state()
780
+ ], PlayerEmbed.prototype, "vouch", 2);
781
+ __decorateClass$3([
782
+ state()
783
+ ], PlayerEmbed.prototype, "template", 2);
784
+ PlayerEmbed = __decorateClass$3([
785
+ customElement("vouch-embed-player")
786
+ ], PlayerEmbed);
787
+ var __defProp$2 = Object.defineProperty;
788
+ var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
789
+ var __decorateClass$2 = (decorators, target, key, kind) => {
790
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target;
791
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
792
+ if (decorator = decorators[i])
793
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
794
+ if (kind && result)
795
+ __defProp$2(target, key, result);
796
+ return result;
797
+ };
798
+ let DialogOverlay = class extends LitElement {
799
+ constructor() {
800
+ super(...arguments);
801
+ this.open = false;
802
+ this.aspectRatio = 0;
803
+ }
804
+ render() {
805
+ return html`
806
+ <div
807
+ class=${classMap({
808
+ container: true,
809
+ hidden: !this.open
810
+ })}
811
+ >
812
+ <div
813
+ class="background"
814
+ @click=${() => this.dispatchEvent(new CustomEvent("overlay:click", { bubbles: true, composed: true }))}
815
+ ></div>
816
+ <focus-trap>
817
+ <div
818
+ class=${classMap({
819
+ "video-frame": true,
820
+ grow: this.aspectRatio === 0
821
+ })}
822
+ style=${styleMap({
823
+ aspectRatio: this.aspectRatio
824
+ })}
825
+ >
826
+ <slot></slot>
827
+ <vmp-icon-button
828
+ icon="close"
829
+ rounded="full"
830
+ weight="heavy"
831
+ @click=${() => this.dispatchEvent(new CustomEvent("close:click", { bubbles: true, composed: true }))}
832
+ ></vmp-icon-button>
833
+ </div>
834
+ </focus-trap>
835
+ </div>
1189
836
  `;
1190
837
  }
1191
838
  };
1192
- f([
1193
- A({ type: Object, attribute: "data" })
1194
- ], g.prototype, "data", 2);
1195
- f([
1196
- A({ type: String })
1197
- ], g.prototype, "vouchId", 2);
1198
- f([
1199
- A({ type: String })
1200
- ], g.prototype, "templateId", 2);
1201
- f([
1202
- A({ type: String })
1203
- ], g.prototype, "env", 2);
1204
- f([
1205
- A({ type: String })
1206
- ], g.prototype, "apiKey", 2);
1207
- f([
1208
- A({ type: String })
1209
- ], g.prototype, "trackingSource", 2);
1210
- f([
1211
- A({ type: Array })
1212
- ], g.prototype, "controls", 2);
1213
- f([
1214
- A({ type: String })
1215
- ], g.prototype, "preload", 2);
1216
- f([
1217
- A({ type: Boolean })
1218
- ], g.prototype, "autoplay", 2);
1219
- f([
1220
- A({ type: Number })
1221
- ], g.prototype, "aspectRatio", 2);
1222
- f([
1223
- Mt()
1224
- ], g.prototype, "vouch", 2);
1225
- f([
1226
- Mt()
1227
- ], g.prototype, "template", 2);
1228
- g = f([
1229
- Qt("vouch-embed")
1230
- ], g);
839
+ DialogOverlay.styles = [
840
+ css`
841
+ :host {
842
+ --vouch-media-player-border-radius: var(--vu-media-player-border-radius, 12px);
843
+ --overlay-background-color: var(--vu-overlay-background-color, black);
844
+ --overlay-background-opacity: var(--vu-overlay-background-opacity, 0.4);
845
+
846
+ --dialog-width: var(--vu-dialog-width, 890px);
847
+ --dialog-height: var(--vu-dialog-height, 500px);
848
+ }
849
+
850
+ .container {
851
+ position: fixed;
852
+ display: flex;
853
+ inset: 0;
854
+ opacity: 1;
855
+ z-index: 2147483647;
856
+ align-items: center;
857
+ justify-content: center;
858
+ transition: opacity 100ms ease-in;
859
+ }
860
+
861
+ .hidden {
862
+ opacity: 0;
863
+ pointer-events: none;
864
+ }
865
+
866
+ .background {
867
+ position: absolute;
868
+ inset: 0;
869
+ opacity: var(--overlay-background-opacity);
870
+ background-color: var(--overlay-background-color);
871
+ }
872
+
873
+ focus-trap {
874
+ display: flex;
875
+ align-items: center;
876
+ justify-content: center;
877
+ margin: 40px;
878
+ width: var(--dialog-width);
879
+ height: var(--dialog-height);
880
+ max-width: calc(100% - 80px);
881
+ max-height: calc(100% - 80px);
882
+ }
883
+
884
+ .video-frame {
885
+ position: relative;
886
+ display: flex;
887
+ align-items: center;
888
+ justify-content: center;
889
+ max-width: 100%;
890
+ max-height: 100%;
891
+ }
892
+
893
+ .video-frame.grow {
894
+ width: 100%;
895
+ height: 100%;
896
+ }
897
+
898
+ vmp-icon-button {
899
+ position: absolute;
900
+ top: 0;
901
+ right: 0;
902
+ margin: 10px;
903
+ }
904
+ `
905
+ ];
906
+ __decorateClass$2([
907
+ property({ type: Boolean })
908
+ ], DialogOverlay.prototype, "open", 2);
909
+ __decorateClass$2([
910
+ property({ type: Number })
911
+ ], DialogOverlay.prototype, "aspectRatio", 2);
912
+ DialogOverlay = __decorateClass$2([
913
+ customElement("vouch-embed-dialog-overlay")
914
+ ], DialogOverlay);
915
+ var __defProp$1 = Object.defineProperty;
916
+ var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
917
+ var __decorateClass$1 = (decorators, target, key, kind) => {
918
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target;
919
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
920
+ if (decorator = decorators[i])
921
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
922
+ if (kind && result)
923
+ __defProp$1(target, key, result);
924
+ return result;
925
+ };
926
+ let DialogPortal = class extends LitElement {
927
+ constructor() {
928
+ super(...arguments);
929
+ this.env = "prod";
930
+ this.apiKey = "";
931
+ this.disableTracking = false;
932
+ this.trackingSource = "embedded_player";
933
+ this.preload = "none";
934
+ this.disableAutoplay = false;
935
+ this.aspectRatio = 0;
936
+ this._mediaPlayerRef = createRef();
937
+ this.open = false;
938
+ this._handleToggle = ({ detail }) => {
939
+ var _a, _b, _c;
940
+ if (this.id === detail) {
941
+ this.open = !this.open;
942
+ if (this.open) {
943
+ if (!this.disableAutoplay && ((_a = this._mediaPlayerRef) == null ? void 0 : _a.value)) {
944
+ this._mediaPlayerRef.value.muted = false;
945
+ this._mediaPlayerRef.value.play();
946
+ }
947
+ } else {
948
+ (_c = (_b = this._mediaPlayerRef) == null ? void 0 : _b.value) == null ? void 0 : _c.pause();
949
+ }
950
+ }
951
+ };
952
+ this._handleClose = () => {
953
+ var _a, _b;
954
+ this.open = false;
955
+ (_b = (_a = this._mediaPlayerRef) == null ? void 0 : _a.value) == null ? void 0 : _b.pause();
956
+ };
957
+ this._handleDocumentKeyUp = (e) => {
958
+ if (e.key === "Escape") {
959
+ this._handleClose();
960
+ }
961
+ };
962
+ }
963
+ connectedCallback() {
964
+ super.connectedCallback();
965
+ document.addEventListener("dialogembed:click", this._handleToggle);
966
+ document.addEventListener("keyup", this._handleDocumentKeyUp);
967
+ document.addEventListener("close:click", this._handleClose);
968
+ document.addEventListener("overlay:click", this._handleClose);
969
+ }
970
+ disconnectedCallback() {
971
+ super.disconnectedCallback();
972
+ document.removeEventListener("dialogembed:click", this._handleToggle);
973
+ document.removeEventListener("keyup", this._handleDocumentKeyUp);
974
+ document.removeEventListener("close:click", this._handleClose);
975
+ document.removeEventListener("overlay:click", this._handleClose);
976
+ }
977
+ createRenderRoot() {
978
+ const newNode = document.createElement("div");
979
+ document.body.appendChild(newNode);
980
+ return newNode;
981
+ }
982
+ render() {
983
+ return html`
984
+ <vouch-embed-dialog-overlay ?open=${this.open} aspectRatio=${this.aspectRatio}>
985
+ <vouch-embed-player
986
+ ${ref(this._mediaPlayerRef)}
987
+ style=${styleMap({
988
+ maxWidth: "100%",
989
+ maxHeight: "100%"
990
+ })}
991
+ ?autoplay=${false}
992
+ vouchId=${ifDefined(this.vouchId)}
993
+ templateId=${ifDefined(this.templateId)}
994
+ .questions=${this.questions}
995
+ .controls=${this.controls}
996
+ env=${ifDefined(this.env)}
997
+ apiKey=${ifDefined(this.apiKey)}
998
+ ?disableTracking=${this.disableTracking}
999
+ trackingSource=${ifDefined(this.trackingSource)}
1000
+ preload=${ifDefined(this.preload)}
1001
+ aspectRatio=${this.aspectRatio}
1002
+ ></vouch-embed-player>
1003
+ </vouch-embed-dialog-overlay>
1004
+ `;
1005
+ }
1006
+ };
1007
+ __decorateClass$1([
1008
+ property({ type: String })
1009
+ ], DialogPortal.prototype, "vouchId", 2);
1010
+ __decorateClass$1([
1011
+ property({ type: String })
1012
+ ], DialogPortal.prototype, "templateId", 2);
1013
+ __decorateClass$1([
1014
+ property({ type: Array })
1015
+ ], DialogPortal.prototype, "questions", 2);
1016
+ __decorateClass$1([
1017
+ property({ type: String })
1018
+ ], DialogPortal.prototype, "env", 2);
1019
+ __decorateClass$1([
1020
+ property({ type: String })
1021
+ ], DialogPortal.prototype, "apiKey", 2);
1022
+ __decorateClass$1([
1023
+ property({ type: Boolean })
1024
+ ], DialogPortal.prototype, "disableTracking", 2);
1025
+ __decorateClass$1([
1026
+ property({ type: String })
1027
+ ], DialogPortal.prototype, "trackingSource", 2);
1028
+ __decorateClass$1([
1029
+ property({ type: Array })
1030
+ ], DialogPortal.prototype, "controls", 2);
1031
+ __decorateClass$1([
1032
+ property({ type: String })
1033
+ ], DialogPortal.prototype, "preload", 2);
1034
+ __decorateClass$1([
1035
+ property({ type: Boolean })
1036
+ ], DialogPortal.prototype, "disableAutoplay", 2);
1037
+ __decorateClass$1([
1038
+ property({ type: Number })
1039
+ ], DialogPortal.prototype, "aspectRatio", 2);
1040
+ __decorateClass$1([
1041
+ state()
1042
+ ], DialogPortal.prototype, "open", 2);
1043
+ DialogPortal = __decorateClass$1([
1044
+ customElement("vouch-embed-dialog-portal")
1045
+ ], DialogPortal);
1046
+ var __defProp = Object.defineProperty;
1047
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
1048
+ var __decorateClass = (decorators, target, key, kind) => {
1049
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
1050
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
1051
+ if (decorator = decorators[i])
1052
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1053
+ if (kind && result)
1054
+ __defProp(target, key, result);
1055
+ return result;
1056
+ };
1057
+ let DialogEmbed = class extends LitElement {
1058
+ constructor() {
1059
+ super(...arguments);
1060
+ this.env = "prod";
1061
+ this.apiKey = "";
1062
+ this.disableTracking = false;
1063
+ this.trackingSource = "embedded_player";
1064
+ this.preload = "none";
1065
+ this.disableAutoplay = false;
1066
+ this.aspectRatio = 0;
1067
+ this._id = v4();
1068
+ this._handleRootClick = () => {
1069
+ this.dispatchEvent(new CustomEvent("dialogembed:click", { detail: this._id, bubbles: true, composed: true }));
1070
+ };
1071
+ }
1072
+ connectedCallback() {
1073
+ super.connectedCallback();
1074
+ this.addEventListener("click", this._handleRootClick);
1075
+ }
1076
+ disconnectedCallback() {
1077
+ super.disconnectedCallback();
1078
+ this.removeEventListener("click", this._handleRootClick);
1079
+ }
1080
+ render() {
1081
+ return html`
1082
+ <slot>
1083
+ <vmp-button size="large">Play</vmp-button>
1084
+ </slot>
1085
+ <vouch-embed-dialog-portal
1086
+ id=${this._id}
1087
+ ?autoplay=${false}
1088
+ vouchId=${ifDefined(this.vouchId)}
1089
+ templateId=${ifDefined(this.templateId)}
1090
+ .questions=${this.questions}
1091
+ .controls=${this.controls}
1092
+ env=${ifDefined(this.env)}
1093
+ apiKey=${ifDefined(this.apiKey)}
1094
+ ?disableTracking=${this.disableTracking}
1095
+ trackingSource=${ifDefined(this.trackingSource)}
1096
+ preload=${ifDefined(this.preload)}
1097
+ aspectRatio=${this.aspectRatio}
1098
+ ></vouch-embed-dialog-portal>
1099
+ `;
1100
+ }
1101
+ };
1102
+ DialogEmbed.styles = [
1103
+ css`
1104
+ :host {
1105
+ --vu-button-padding: 10px 20px;
1106
+ --vu-button-background: #287179;
1107
+ --vu-button-background-hover: #4faab2;
1108
+
1109
+ display: flex;
1110
+ width: fit-content;
1111
+ height: fit-content;
1112
+ }
1113
+ `
1114
+ ];
1115
+ __decorateClass([
1116
+ property({ type: String })
1117
+ ], DialogEmbed.prototype, "vouchId", 2);
1118
+ __decorateClass([
1119
+ property({ type: String })
1120
+ ], DialogEmbed.prototype, "templateId", 2);
1121
+ __decorateClass([
1122
+ property({ type: Array })
1123
+ ], DialogEmbed.prototype, "questions", 2);
1124
+ __decorateClass([
1125
+ property({ type: String })
1126
+ ], DialogEmbed.prototype, "env", 2);
1127
+ __decorateClass([
1128
+ property({ type: String })
1129
+ ], DialogEmbed.prototype, "apiKey", 2);
1130
+ __decorateClass([
1131
+ property({ type: Boolean })
1132
+ ], DialogEmbed.prototype, "disableTracking", 2);
1133
+ __decorateClass([
1134
+ property({ type: String })
1135
+ ], DialogEmbed.prototype, "trackingSource", 2);
1136
+ __decorateClass([
1137
+ property({ type: Array })
1138
+ ], DialogEmbed.prototype, "controls", 2);
1139
+ __decorateClass([
1140
+ property({ type: String })
1141
+ ], DialogEmbed.prototype, "preload", 2);
1142
+ __decorateClass([
1143
+ property({ type: Boolean })
1144
+ ], DialogEmbed.prototype, "disableAutoplay", 2);
1145
+ __decorateClass([
1146
+ property({ type: Number })
1147
+ ], DialogEmbed.prototype, "aspectRatio", 2);
1148
+ DialogEmbed = __decorateClass([
1149
+ customElement("vouch-embed-dialog")
1150
+ ], DialogEmbed);
1231
1151
  export {
1232
- g as Embed
1152
+ DialogEmbed,
1153
+ PlayerEmbed
1233
1154
  };
1234
1155
  //# sourceMappingURL=embeds.js.map