@vouchfor/embeds 0.0.0-experiment.a913709 → 0.0.0-experiment.a965a35

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