@vouchfor/embeds 0.0.0-experiment.e7e20dd → 0.0.0-experiment.e8b5a87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/es/embeds.js CHANGED
@@ -1,25 +1,23 @@
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';
8
- import '@vouchfor/media-player';
9
- import { styleMap } from 'lit/directives/style-map.js';
10
- import { classMap } from 'lit/directives/class-map.js';
11
- import '@a11y/focus-trap';
12
-
13
- function forwardEvent(type, fromElement, toElement) {
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";
8
+ import "@vouchfor/media-player";
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) {
14
13
  function forwarder(event) {
15
14
  toElement.dispatchEvent(new CustomEvent(event.type, event));
16
15
  }
17
- fromElement.addEventListener(type, forwarder);
16
+ fromElement.addEventListener(type2, forwarder);
18
17
  return () => {
19
- fromElement.removeEventListener(type, forwarder);
18
+ fromElement.removeEventListener(type2, forwarder);
20
19
  };
21
20
  }
22
-
23
21
  class EventForwardController {
24
22
  constructor(host, events) {
25
23
  this._events = [];
@@ -48,7 +46,6 @@ class EventForwardController {
48
46
  this._cleanup = [];
49
47
  }
50
48
  }
51
-
52
49
  const devVideoUrl = "https://d2rxhdlm2q91uk.cloudfront.net";
53
50
  const stagingVideoUrl = "https://d1ix11aj5kfygl.cloudfront.net";
54
51
  const prodVideoUrl = "https://d157jlwnudd93d.cloudfront.net";
@@ -92,11 +89,11 @@ function getEnvUrls(env) {
92
89
  };
93
90
  }
94
91
  }
95
-
96
92
  class FetcherController {
97
93
  constructor(host) {
98
94
  this._fetching = false;
99
95
  this.getVouch = async (env, apiKey, vouchId) => {
96
+ var _a;
100
97
  const { embedApiUrl } = getEnvUrls(env);
101
98
  const cacheCheck = v4();
102
99
  const res = await fetch(`${embedApiUrl}/vouches/${vouchId}`, {
@@ -107,8 +104,8 @@ class FetcherController {
107
104
  ]
108
105
  });
109
106
  const vouch = await res.json();
110
- this.host.dispatchEvent(new CustomEvent("vouch:loaded", { detail: vouch?.id }));
111
- const resCacheCheck = res?.headers?.get("X-Cache-Check");
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");
112
109
  if (resCacheCheck !== cacheCheck) {
113
110
  fetch(`${embedApiUrl}/vouches/${vouchId}`, {
114
111
  method: "GET",
@@ -121,6 +118,7 @@ class FetcherController {
121
118
  return vouch;
122
119
  };
123
120
  this.getTemplate = async (env, apiKey, templateId) => {
121
+ var _a;
124
122
  const { embedApiUrl } = getEnvUrls(env);
125
123
  const cacheCheck = v4();
126
124
  const res = await fetch(`${embedApiUrl}/templates/${templateId}`, {
@@ -131,7 +129,7 @@ class FetcherController {
131
129
  ]
132
130
  });
133
131
  const template = await res.json();
134
- const resCacheCheck = res?.headers?.get("X-Cache-Check");
132
+ const resCacheCheck = (_a = res == null ? void 0 : res.headers) == null ? void 0 : _a.get("X-Cache-Check");
135
133
  if (resCacheCheck !== cacheCheck) {
136
134
  fetch(`${embedApiUrl}/templates/${templateId}`, {
137
135
  method: "GET",
@@ -147,6 +145,7 @@ class FetcherController {
147
145
  new Task(
148
146
  this.host,
149
147
  async ([env, apiKey, data, vouchId, templateId]) => {
148
+ var _a, _b, _c, _d;
150
149
  try {
151
150
  host.vouch = void 0;
152
151
  host.template = void 0;
@@ -157,7 +156,7 @@ class FetcherController {
157
156
  template = await this.getTemplate(env, apiKey, templateId);
158
157
  }
159
158
  this._vouch = data;
160
- host.template = template ?? data?.settings?.template?.instance;
159
+ host.template = template ?? ((_b = (_a = data == null ? void 0 : data.settings) == null ? void 0 : _a.template) == null ? void 0 : _b.instance);
161
160
  } else if (vouchId) {
162
161
  this.fetching = true;
163
162
  const [vouch, template] = await Promise.all([
@@ -165,7 +164,7 @@ class FetcherController {
165
164
  templateId ? this.getTemplate(env, apiKey, templateId) : null
166
165
  ]);
167
166
  this._vouch = vouch;
168
- host.template = template ?? vouch?.settings?.template?.instance;
167
+ host.template = template ?? ((_d = (_c = vouch == null ? void 0 : vouch.settings) == null ? void 0 : _c.template) == null ? void 0 : _d.instance);
169
168
  }
170
169
  } finally {
171
170
  this.fetching = false;
@@ -179,7 +178,7 @@ class FetcherController {
179
178
  host.vouch = vouch ? {
180
179
  ...vouch,
181
180
  questions: {
182
- items: vouch?.questions.items.filter((_, index) => !questions?.length || questions?.includes(index + 1))
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)))
183
182
  }
184
183
  } : void 0;
185
184
  },
@@ -196,9 +195,8 @@ class FetcherController {
196
195
  return this._fetching;
197
196
  }
198
197
  }
199
-
200
198
  const name = "@vouchfor/embeds";
201
- const version = "0.0.0-experiment.e7e20dd";
199
+ const version = "0.0.0-experiment.e8b5a87";
202
200
  const license = "MIT";
203
201
  const author = "Aaron Williams";
204
202
  const main = "dist/es/embeds.js";
@@ -206,104 +204,103 @@ const module = "dist/es/embeds.js";
206
204
  const type = "module";
207
205
  const types = "dist/es/src/index.d.ts";
208
206
  const exports = {
209
- ".": "./dist/es/embeds.js"
207
+ ".": "./dist/es/embeds.js"
210
208
  };
211
209
  const files = [
212
- "dist",
213
- "src"
210
+ "dist",
211
+ "src"
214
212
  ];
215
213
  const publishConfig = {
216
- tag: "experiment",
217
- access: "public"
214
+ tag: "experiment",
215
+ access: "public"
218
216
  };
219
217
  const engines = {
220
- node: ">=18.18.0"
218
+ node: ">=18.18.0"
221
219
  };
222
220
  const scripts = {
223
- build: "rm -rf dist && tsc && yarn build:self",
224
- "build:deps": "yarn --cwd ../media-player build",
225
- "build:self": "vite build --mode iife && vite build --mode es && node scripts/build.cjs",
226
- "build:package": "yarn build",
227
- "build:storybook": "yarn prebuild && storybook build",
228
- "generate:manifest": "wca src --outFile custom-elements.json",
229
- lint: "eslint . --quiet",
230
- "lint:fix": "eslint . --fix",
231
- "lint:staged": "lint-staged",
232
- prepublishOnly: "yarn build",
233
- size: "size-limit",
234
- storybook: "yarn prebuild && storybook dev -p 6007",
235
- prebuild: "yarn build:deps && yarn generate:manifest",
236
- test: "rm -rf test/lib && yarn prebuild && vite build --mode test && web-test-runner",
237
- "test:ci": "yarn test --config web-test-runner.ci.config.js"
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"
238
236
  };
239
237
  const dependencies = {
240
- "@a11y/focus-trap": "^1.0.5",
241
- "@lit/task": "^1.0.0",
242
- "@vouchfor/canvas-video": "0.0.0-experiment.e7e20dd",
243
- "@vouchfor/media-player": "0.0.0-experiment.e7e20dd",
244
- uuid: "^9.0.1"
238
+ "@a11y/focus-trap": "^1.0.5",
239
+ "@lit/task": "^1.0.0",
240
+ "@vouchfor/canvas-video": "0.0.0-experiment.e8b5a87",
241
+ "@vouchfor/media-player": "0.0.0-experiment.e8b5a87",
242
+ uuid: "^9.0.1"
245
243
  };
246
244
  const peerDependencies = {
247
- lit: "^3.1.2"
245
+ lit: "^3.1.2"
248
246
  };
249
247
  const devDependencies = {
250
- "@esm-bundle/chai": "^4.3.4-fix.0",
251
- "@open-wc/testing": "^4.0.0",
252
- "@storybook/addon-essentials": "^8.0.2",
253
- "@storybook/addon-links": "^8.0.2",
254
- "@storybook/blocks": "^8.0.2",
255
- "@storybook/web-components": "^8.0.2",
256
- "@storybook/web-components-vite": "^8.0.2",
257
- "@svgr/core": "^8.1.0",
258
- "@types/flat": "^5.0.5",
259
- "@types/mocha": "^10.0.6",
260
- "@vouchfor/eslint-config": "^1.0.1",
261
- "@vouchfor/prettier-config": "^1.0.1",
262
- "@vouchfor/video-utils": "0.0.0-experiment.e7e20dd",
263
- "@web/dev-server-esbuild": "^1.0.2",
264
- "@web/test-runner": "^0.18.1",
265
- "@web/test-runner-browserstack": "^0.7.1",
266
- "@web/test-runner-mocha": "^0.9.0",
267
- "@web/test-runner-playwright": "^0.11.0",
268
- glob: "^10.3.10",
269
- "lint-staged": "^15.2.2",
270
- lit: "^3.1.2",
271
- lodash: "^4.17.21",
272
- react: "^18.2.0",
273
- "react-dom": "^18.2.0",
274
- "rollup-plugin-tla": "^0.0.2",
275
- sinon: "^17.0.1",
276
- storybook: "^8.0.2",
277
- svgson: "^5.3.1",
278
- typescript: "^5.4.3",
279
- vite: "^5.2.2",
280
- "vite-plugin-commonjs": "^0.10.1",
281
- "vite-plugin-dts": "^3.7.3",
282
- "web-component-analyzer": "^2.0.0"
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.e8b5a87",
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"
283
281
  };
284
282
  const packageJson = {
285
- name: name,
286
- version: version,
287
- license: license,
288
- author: author,
289
- main: main,
290
- module: module,
291
- type: type,
292
- types: types,
293
- exports: exports,
294
- files: files,
295
- publishConfig: publishConfig,
296
- engines: engines,
297
- scripts: scripts,
298
- "lint-staged": {
299
- "**/*.{ts,tsx,js}": "eslint --fix --quiet",
300
- "**/*.{md,json,yml}": "prettier --write"
301
- },
302
- dependencies: dependencies,
303
- peerDependencies: peerDependencies,
304
- devDependencies: devDependencies
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
305
303
  };
306
-
307
304
  function createVisitor(env) {
308
305
  const { publicApiUrl } = getEnvUrls(env);
309
306
  const visitorId = v4();
@@ -311,6 +308,7 @@ function createVisitor(env) {
311
308
  return visitorId;
312
309
  }
313
310
  function getUids(env) {
311
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
314
312
  if (typeof window === "undefined") {
315
313
  return {
316
314
  client: null,
@@ -318,21 +316,21 @@ function getUids(env) {
318
316
  request: v4()
319
317
  };
320
318
  }
321
- let visitorId = window.localStorage?.getItem?.("vouch-uid-visitor");
322
- let clientId = window.localStorage?.getItem?.("vouch-uid-client");
323
- let tabId = window.sessionStorage?.getItem?.("vouch-uid-tab");
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");
324
322
  const requestId = v4();
325
323
  if (!visitorId) {
326
324
  visitorId = createVisitor(env);
327
- window.localStorage?.setItem?.("vouch-uid-visitor", visitorId);
325
+ (_h = (_g = window.localStorage) == null ? void 0 : _g.setItem) == null ? void 0 : _h.call(_g, "vouch-uid-visitor", visitorId);
328
326
  }
329
327
  if (!clientId) {
330
328
  clientId = v4();
331
- window.localStorage?.setItem?.("vouch-uid-client", clientId);
329
+ (_j = (_i = window.localStorage) == null ? void 0 : _i.setItem) == null ? void 0 : _j.call(_i, "vouch-uid-client", clientId);
332
330
  }
333
331
  if (!tabId) {
334
332
  tabId = v4();
335
- window.sessionStorage?.setItem?.("vouch-uid-tab", tabId);
333
+ (_l = (_k = window.sessionStorage) == null ? void 0 : _k.setItem) == null ? void 0 : _l.call(_k, "vouch-uid-tab", tabId);
336
334
  }
337
335
  return {
338
336
  client: clientId,
@@ -345,10 +343,11 @@ function findVouchId(payload, vouch) {
345
343
  if (payload && "vouchId" in payload) {
346
344
  return payload.vouchId;
347
345
  }
348
- return vouch?.id ?? null;
346
+ return (vouch == null ? void 0 : vouch.id) ?? null;
349
347
  }
350
348
  function getReportingMetadata(source = "embedded_player") {
351
- const [country, region] = Intl.DateTimeFormat().resolvedOptions().timeZone?.split?.("/") ?? [];
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, "/")) ?? [];
352
351
  const utmParams = {};
353
352
  [...new URLSearchParams(location.search).entries()].forEach(([key, value]) => {
354
353
  if (/utm/.test(key)) {
@@ -371,7 +370,6 @@ function getReportingMetadata(source = "embedded_player") {
371
370
  ...utmParams
372
371
  };
373
372
  }
374
-
375
373
  const MINIMUM_SEND_THRESHOLD = 1;
376
374
  class TrackingController {
377
375
  constructor(host) {
@@ -459,10 +457,11 @@ class TrackingController {
459
457
  }
460
458
  };
461
459
  this._handleVideoTimeUpdate = ({ detail: { id, key, node } }) => {
460
+ var _a, _b;
462
461
  if (
463
462
  // We only want to count any time that the video is actually playing
464
463
  !this.host.paused && // Only update the latest time if this event fires for the currently active video
465
- id === this.host.scene?.video?.id
464
+ id === ((_b = (_a = this.host.scene) == null ? void 0 : _a.video) == null ? void 0 : _b.id)
466
465
  ) {
467
466
  this._currentlyPlayingVideo = { id, key, node };
468
467
  this._streamLatestTime[key] = node.currentTime;
@@ -500,19 +499,21 @@ class TrackingController {
500
499
  }
501
500
  hostConnected() {
502
501
  requestAnimationFrame(() => {
502
+ var _a, _b, _c, _d;
503
503
  if ("onvisibilitychange" in document) {
504
504
  document.addEventListener("visibilitychange", this._handleVisibilityChange);
505
505
  } else {
506
506
  window.addEventListener("pagehide", this._handlePageHide);
507
507
  }
508
508
  this.host.addEventListener("vouch:loaded", this._handleVouchLoaded);
509
- this.host.mediaPlayer?.addEventListener("play", this._handlePlay);
510
- this.host.mediaPlayer?.addEventListener("video:play", this._handleVideoPlay);
511
- this.host.mediaPlayer?.addEventListener("video:pause", this._handleVideoPause);
512
- this.host.mediaPlayer?.addEventListener("video:timeupdate", this._handleVideoTimeUpdate);
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);
513
513
  });
514
514
  }
515
515
  hostDisconnected() {
516
+ var _a, _b, _c, _d;
516
517
  this._pageUnloading();
517
518
  if ("onvisibilitychange" in document) {
518
519
  document.removeEventListener("visibilitychange", this._handleVisibilityChange);
@@ -520,13 +521,12 @@ class TrackingController {
520
521
  window.removeEventListener("pagehide", this._handlePageHide);
521
522
  }
522
523
  this.host.removeEventListener("vouch:loaded", this._handleVouchLoaded);
523
- this.host.mediaPlayer?.removeEventListener("play", this._handlePlay);
524
- this.host.mediaPlayer?.removeEventListener("video:play", this._handleVideoPlay);
525
- this.host.mediaPlayer?.removeEventListener("video:pause", this._handleVideoPause);
526
- this.host.mediaPlayer?.removeEventListener("video:timeupdate", this._handleVideoTimeUpdate);
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);
527
528
  }
528
529
  }
529
-
530
530
  var __defProp$3 = Object.defineProperty;
531
531
  var __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor;
532
532
  var __decorateClass$3 = (decorators, target, key, kind) => {
@@ -576,8 +576,6 @@ let PlayerEmbed = class extends LitElement {
576
576
  "video:error"
577
577
  ]);
578
578
  this._fetcherController = new FetcherController(this);
579
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
580
- // @ts-ignore
581
579
  this._trackingController = new TrackingController(this);
582
580
  this._mediaPlayerRef = createRef();
583
581
  }
@@ -585,25 +583,32 @@ let PlayerEmbed = class extends LitElement {
585
583
  return this._fetcherController.fetching;
586
584
  }
587
585
  get waiting() {
588
- return this._mediaPlayerRef.value?.waiting;
586
+ var _a;
587
+ return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.waiting;
589
588
  }
590
589
  get initialised() {
591
- return this._mediaPlayerRef.value?.initialised;
590
+ var _a;
591
+ return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.initialised;
592
592
  }
593
593
  get seeking() {
594
- return this._mediaPlayerRef.value?.seeking;
594
+ var _a;
595
+ return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.seeking;
595
596
  }
596
597
  get paused() {
597
- return this._mediaPlayerRef.value?.paused;
598
+ var _a;
599
+ return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.paused;
598
600
  }
599
601
  get captions() {
600
- return this._mediaPlayerRef.value?.captions;
602
+ var _a;
603
+ return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.captions;
601
604
  }
602
605
  get fullscreen() {
603
- return this._mediaPlayerRef.value?.fullscreen;
606
+ var _a;
607
+ return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.fullscreen;
604
608
  }
605
609
  get duration() {
606
- return this._mediaPlayerRef.value?.duration;
610
+ var _a;
611
+ return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.duration;
607
612
  }
608
613
  set currentTime(value) {
609
614
  if (this._mediaPlayerRef.value) {
@@ -611,7 +616,8 @@ let PlayerEmbed = class extends LitElement {
611
616
  }
612
617
  }
613
618
  get currentTime() {
614
- return this._mediaPlayerRef.value?.currentTime ?? 0;
619
+ var _a;
620
+ return ((_a = this._mediaPlayerRef.value) == null ? void 0 : _a.currentTime) ?? 0;
615
621
  }
616
622
  set playbackRate(value) {
617
623
  if (this._mediaPlayerRef.value) {
@@ -619,7 +625,8 @@ let PlayerEmbed = class extends LitElement {
619
625
  }
620
626
  }
621
627
  get playbackRate() {
622
- return this._mediaPlayerRef.value?.playbackRate ?? 1;
628
+ var _a;
629
+ return ((_a = this._mediaPlayerRef.value) == null ? void 0 : _a.playbackRate) ?? 1;
623
630
  }
624
631
  set volume(value) {
625
632
  if (this._mediaPlayerRef.value) {
@@ -627,7 +634,8 @@ let PlayerEmbed = class extends LitElement {
627
634
  }
628
635
  }
629
636
  get volume() {
630
- return this._mediaPlayerRef.value?.volume ?? 1;
637
+ var _a;
638
+ return ((_a = this._mediaPlayerRef.value) == null ? void 0 : _a.volume) ?? 1;
631
639
  }
632
640
  set muted(value) {
633
641
  if (this._mediaPlayerRef.value) {
@@ -635,34 +643,43 @@ let PlayerEmbed = class extends LitElement {
635
643
  }
636
644
  }
637
645
  get muted() {
638
- return this._mediaPlayerRef.value?.muted ?? false;
646
+ var _a;
647
+ return ((_a = this._mediaPlayerRef.value) == null ? void 0 : _a.muted) ?? false;
639
648
  }
640
649
  get scene() {
641
- return this._mediaPlayerRef.value?.scene ?? null;
650
+ var _a;
651
+ return ((_a = this._mediaPlayerRef.value) == null ? void 0 : _a.scene) ?? null;
642
652
  }
643
653
  get scenes() {
644
- return this._mediaPlayerRef.value?.scenes ?? [];
654
+ var _a;
655
+ return ((_a = this._mediaPlayerRef.value) == null ? void 0 : _a.scenes) ?? [];
645
656
  }
646
657
  get sceneConfig() {
647
- return this._mediaPlayerRef.value?.sceneConfig ?? null;
658
+ var _a;
659
+ return ((_a = this._mediaPlayerRef.value) == null ? void 0 : _a.sceneConfig) ?? null;
648
660
  }
649
661
  get videoState() {
650
- return this._mediaPlayerRef.value?.videoState;
662
+ var _a;
663
+ return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.videoState;
651
664
  }
652
665
  get mediaPlayer() {
653
666
  return this._mediaPlayerRef.value;
654
667
  }
655
668
  play() {
656
- this._mediaPlayerRef.value?.play();
669
+ var _a;
670
+ (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.play();
657
671
  }
658
672
  pause() {
659
- this._mediaPlayerRef.value?.pause();
673
+ var _a;
674
+ (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.pause();
660
675
  }
661
676
  reset(time = 0, play = false) {
662
- this._mediaPlayerRef.value?.reset(time, play);
677
+ var _a;
678
+ (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.reset(time, play);
663
679
  }
664
680
  setScene(index) {
665
- this._mediaPlayerRef.value?.setScene(index);
681
+ var _a;
682
+ (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.setScene(index);
666
683
  }
667
684
  _renderStyles() {
668
685
  if (!this.aspectRatio) {
@@ -755,7 +772,6 @@ __decorateClass$3([
755
772
  PlayerEmbed = __decorateClass$3([
756
773
  customElement("vouch-embed-player")
757
774
  ], PlayerEmbed);
758
-
759
775
  var __defProp$2 = Object.defineProperty;
760
776
  var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
761
777
  var __decorateClass$2 = (decorators, target, key, kind) => {
@@ -884,7 +900,6 @@ __decorateClass$2([
884
900
  DialogOverlay = __decorateClass$2([
885
901
  customElement("vouch-embed-dialog-overlay")
886
902
  ], DialogOverlay);
887
-
888
903
  var __defProp$1 = Object.defineProperty;
889
904
  var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
890
905
  var __decorateClass$1 = (decorators, target, key, kind) => {
@@ -909,22 +924,23 @@ let DialogPortal = class extends LitElement {
909
924
  this._mediaPlayerRef = createRef();
910
925
  this.open = false;
911
926
  this._handleToggle = ({ detail }) => {
927
+ var _a, _b, _c;
912
928
  if (this.id === detail) {
913
929
  this.open = !this.open;
914
930
  if (this.open) {
915
- if (!this.disableAutoplay && this._mediaPlayerRef?.value) {
931
+ if (!this.disableAutoplay && ((_a = this._mediaPlayerRef) == null ? void 0 : _a.value)) {
916
932
  this._mediaPlayerRef.value.muted = false;
917
933
  this._mediaPlayerRef.value.play();
918
934
  }
919
935
  } else {
920
- this._mediaPlayerRef?.value?.pause();
936
+ (_c = (_b = this._mediaPlayerRef) == null ? void 0 : _b.value) == null ? void 0 : _c.pause();
921
937
  }
922
938
  }
923
939
  };
924
- // We could do the same thing on close and check for the correct ID but it doesn't really matter
925
940
  this._handleClose = () => {
941
+ var _a, _b;
926
942
  this.open = false;
927
- this._mediaPlayerRef?.value?.pause();
943
+ (_b = (_a = this._mediaPlayerRef) == null ? void 0 : _a.value) == null ? void 0 : _b.pause();
928
944
  };
929
945
  this._handleDocumentKeyUp = (e) => {
930
946
  if (e.key === "Escape") {
@@ -1015,7 +1031,6 @@ __decorateClass$1([
1015
1031
  DialogPortal = __decorateClass$1([
1016
1032
  customElement("vouch-embed-dialog-portal")
1017
1033
  ], DialogPortal);
1018
-
1019
1034
  var __defProp = Object.defineProperty;
1020
1035
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
1021
1036
  var __decorateClass = (decorators, target, key, kind) => {
@@ -1121,6 +1136,8 @@ __decorateClass([
1121
1136
  DialogEmbed = __decorateClass([
1122
1137
  customElement("vouch-embed-dialog")
1123
1138
  ], DialogEmbed);
1124
-
1125
- export { DialogEmbed, PlayerEmbed };
1139
+ export {
1140
+ DialogEmbed,
1141
+ PlayerEmbed
1142
+ };
1126
1143
  //# sourceMappingURL=embeds.js.map