@vouchfor/embeds 0.0.0-experiment.de7febc → 0.0.0-experiment.df3f29a

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