@liforma/client 0.4.12 → 0.4.13
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/CHANGELOG.md +11 -0
- package/dist/next/index.js +394 -369
- package/dist/next/index.js.map +1 -1
- package/dist/next/thumbnail.js +1 -1
- package/dist/next/thumbnail.js.map +1 -1
- package/dist/next/v2/embed/iframeHost.d.ts +4 -8
- package/dist/next/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/next/v2/embed/protocol.d.ts +29 -2
- package/dist/next/v2/embed/protocol.d.ts.map +1 -1
- package/dist/next/v2/experience.d.ts +11 -0
- package/dist/next/v2/experience.d.ts.map +1 -1
- package/dist/npm/index.js +206 -181
- package/dist/npm/index.js.map +1 -1
- package/dist/npm/thumbnail/index.js +1 -1
- package/dist/npm/thumbnail/index.js.map +1 -1
- package/dist/npm/v2/embed/iframeHost.d.ts +4 -8
- package/dist/npm/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/npm/v2/embed/protocol.d.ts +29 -2
- package/dist/npm/v2/embed/protocol.d.ts.map +1 -1
- package/dist/npm/v2/experience.d.ts +11 -0
- package/dist/npm/v2/experience.d.ts.map +1 -1
- package/dist/react/component/experienceComponentRuntime.d.ts +3 -0
- package/dist/react/component/experienceComponentRuntime.d.ts.map +1 -1
- package/dist/react/component/experienceComponentTypes.d.ts +9 -0
- package/dist/react/component/experienceComponentTypes.d.ts.map +1 -1
- package/dist/react/index.js +514 -473
- package/dist/react/index.js.map +1 -1
- package/dist/react/react/Experience.d.ts.map +1 -1
- package/dist/react/thumbnail.js +1 -1
- package/dist/react/thumbnail.js.map +1 -1
- package/dist/react/v2/embed/iframeHost.d.ts +4 -8
- package/dist/react/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/react/v2/embed/protocol.d.ts +29 -2
- package/dist/react/v2/embed/protocol.d.ts.map +1 -1
- package/dist/react/v2/experience.d.ts +11 -0
- package/dist/react/v2/experience.d.ts.map +1 -1
- package/dist/sdk/v2/client.js +2 -2
- package/dist/sdk/v2/client.js.map +1 -1
- package/dist/sdk/v2/thumbnail.js +1 -1
- package/dist/sdk/v2/thumbnail.js.map +1 -1
- package/dist/svelte/Experience.svelte +22 -0
- package/dist/svelte/Experience.svelte.d.ts +1 -0
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -257,6 +257,9 @@ function P(e = () => ({}), t = () => ({})) {
|
|
|
257
257
|
interaction: d.interaction,
|
|
258
258
|
closeButton: d.closeButton,
|
|
259
259
|
returnUrl: f,
|
|
260
|
+
...d.theatreButton ? { theatreButton: !0 } : {},
|
|
261
|
+
...d.theatre === void 0 ? {} : { theatre: d.theatre },
|
|
262
|
+
onTheatreChange: (e) => t().onTheatreChange?.(e),
|
|
260
263
|
showClose: !!(o().onClose || f || d.closeButton === !0 || d.closeButton && typeof d.closeButton == "object" && d.closeButton.visible !== !1),
|
|
261
264
|
onPlayerStatusChange: (t) => {
|
|
262
265
|
if (e.destroyed) return;
|
|
@@ -347,7 +350,7 @@ function L(e, t) {
|
|
|
347
350
|
//#endregion
|
|
348
351
|
//#region src/react/Experience.tsx
|
|
349
352
|
var ne = e(function(e, a) {
|
|
350
|
-
let { returnUrl: c, fit: l, stage: u, pipBackground: p, pipShadow: m, startButton: h, theme: g, showFeedback: y, interaction: b,
|
|
353
|
+
let { returnUrl: c, fit: l, stage: u, pipBackground: p, pipShadow: m, startButton: h, theme: g, showFeedback: y, interaction: b, theatreButton: x, theatre: S, onTheatreChange: C, closeButton: w, onReady: T, onStarted: E, onUserTranscript: D, onUserSpeechStarted: O, onUserSpeechEnded: ee, onCharacterSpeechStarted: j, onCharacterSpeechEnded: M, onCharacterFocusChanged: N, onConversationUpdate: F, onMessage: te, onListeningState: I, onActivityChange: ne, onFeedback: re, onFeedbackFailed: ie, onConversationProcessorError: R, onPlayerStatusChange: z, onStateUpdate: ae, onClose: B, onError: oe } = e, se = o({}), ce = o({
|
|
351
354
|
fit: l,
|
|
352
355
|
stage: u,
|
|
353
356
|
pipBackground: p,
|
|
@@ -356,10 +359,13 @@ var ne = e(function(e, a) {
|
|
|
356
359
|
theme: g,
|
|
357
360
|
showFeedback: y,
|
|
358
361
|
interaction: b,
|
|
359
|
-
closeButton:
|
|
360
|
-
returnUrl: c
|
|
361
|
-
|
|
362
|
-
|
|
362
|
+
closeButton: w,
|
|
363
|
+
returnUrl: c,
|
|
364
|
+
theatreButton: x,
|
|
365
|
+
theatre: S,
|
|
366
|
+
onTheatreChange: C
|
|
367
|
+
}), V = o(P(() => se.current, () => ce.current)), H = o(null), [le, ue] = s(!1), [U, de] = s(null), W = o(null), G = o(null), fe = v(e);
|
|
368
|
+
ce.current = {
|
|
363
369
|
fit: l,
|
|
364
370
|
stage: u,
|
|
365
371
|
pipBackground: p,
|
|
@@ -368,39 +374,42 @@ var ne = e(function(e, a) {
|
|
|
368
374
|
theme: g,
|
|
369
375
|
showFeedback: y,
|
|
370
376
|
interaction: b,
|
|
371
|
-
closeButton:
|
|
372
|
-
returnUrl: c
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
377
|
+
closeButton: w,
|
|
378
|
+
returnUrl: c,
|
|
379
|
+
theatreButton: x,
|
|
380
|
+
theatre: S,
|
|
381
|
+
onTheatreChange: C
|
|
382
|
+
}, se.current = {
|
|
383
|
+
onReady: T,
|
|
384
|
+
onStarted: E,
|
|
385
|
+
onUserTranscript: D,
|
|
386
|
+
onUserSpeechStarted: O,
|
|
387
|
+
onUserSpeechEnded: ee,
|
|
388
|
+
onCharacterSpeechStarted: j,
|
|
389
|
+
onCharacterSpeechEnded: M,
|
|
390
|
+
onCharacterFocusChanged: N,
|
|
391
|
+
onConversationUpdate: F,
|
|
392
|
+
onMessage: te,
|
|
393
|
+
onListeningState: I,
|
|
394
|
+
onActivityChange: ne,
|
|
395
|
+
onFeedback: re,
|
|
396
|
+
onFeedbackFailed: ie,
|
|
397
|
+
onConversationProcessorError: R,
|
|
398
|
+
onPlayerStatusChange: z,
|
|
399
|
+
onStateUpdate: ae,
|
|
400
|
+
onClose: B,
|
|
401
|
+
onError: oe
|
|
402
|
+
};
|
|
403
|
+
let pe = t((e) => {
|
|
404
|
+
W.current = e, ue(e !== null);
|
|
396
405
|
}, []);
|
|
397
406
|
return r(a, () => ({
|
|
398
407
|
ready: () => {
|
|
399
|
-
let e =
|
|
408
|
+
let e = H.current;
|
|
400
409
|
return !e || e.destroyed ? Promise.reject(k()) : e.ready.promise;
|
|
401
410
|
},
|
|
402
411
|
started: () => {
|
|
403
|
-
let e =
|
|
412
|
+
let e = H.current;
|
|
404
413
|
return !e || e.destroyed ? Promise.reject(k()) : e.started.promise;
|
|
405
414
|
},
|
|
406
415
|
speech: {
|
|
@@ -424,24 +433,27 @@ var ne = e(function(e, a) {
|
|
|
424
433
|
setStage: (e) => V.current.withSession((t) => t.setStage(e)),
|
|
425
434
|
setPipBackground: (e) => V.current.withSession((t) => t.setPipBackground(e)),
|
|
426
435
|
setPipShadow: (e) => V.current.withSession((t) => t.setPipShadow(e)),
|
|
436
|
+
setTheatre: (e) => {
|
|
437
|
+
V.current.getActiveInstance()?.setTheatre(e);
|
|
438
|
+
},
|
|
427
439
|
conversion: (e) => V.current.withSession((t) => t.conversion(e)),
|
|
428
440
|
engage: () => V.current.withSession((e) => e.engage()),
|
|
429
441
|
end: () => V.current.withSession((e) => e.end())
|
|
430
442
|
}), []), i(() => {
|
|
431
|
-
if (!
|
|
432
|
-
let t =
|
|
443
|
+
if (!le || !W.current) return;
|
|
444
|
+
let t = W.current, n = V.current, r;
|
|
433
445
|
try {
|
|
434
446
|
r = { options: _(e) };
|
|
435
447
|
} catch (e) {
|
|
436
448
|
r = { error: A(e) };
|
|
437
449
|
}
|
|
438
|
-
let i = n.activateGeneration(t, r, c,
|
|
439
|
-
return
|
|
440
|
-
n.cancelGeneration(i),
|
|
450
|
+
let i = n.activateGeneration(t, r, c, de);
|
|
451
|
+
return H.current = i, () => {
|
|
452
|
+
n.cancelGeneration(i), H.current === i && (H.current = null);
|
|
441
453
|
};
|
|
442
454
|
}, [
|
|
443
|
-
|
|
444
|
-
|
|
455
|
+
le,
|
|
456
|
+
fe,
|
|
445
457
|
c
|
|
446
458
|
]), n(() => {
|
|
447
459
|
let e = V.current.getActiveInstance();
|
|
@@ -457,7 +469,11 @@ var ne = e(function(e, a) {
|
|
|
457
469
|
let e = V.current.getActiveInstance();
|
|
458
470
|
e && e.setPipShadow(m);
|
|
459
471
|
}, [m]), n(() => {
|
|
460
|
-
|
|
472
|
+
if (!x) return;
|
|
473
|
+
let e = V.current.getActiveInstance();
|
|
474
|
+
e && e.setTheatre(S === !0);
|
|
475
|
+
}, [x, S]), n(() => {
|
|
476
|
+
let e = G.current;
|
|
461
477
|
if (!e || (e.replaceChildren(), !U)) return;
|
|
462
478
|
let t = L(e, U);
|
|
463
479
|
return () => t.remove();
|
|
@@ -470,7 +486,7 @@ var ne = e(function(e, a) {
|
|
|
470
486
|
minHeight: "inherit"
|
|
471
487
|
},
|
|
472
488
|
children: [/* @__PURE__ */ d("div", {
|
|
473
|
-
ref:
|
|
489
|
+
ref: G,
|
|
474
490
|
className: "liforma-experience-error-host",
|
|
475
491
|
"aria-hidden": U ? void 0 : !0,
|
|
476
492
|
style: {
|
|
@@ -480,7 +496,7 @@ var ne = e(function(e, a) {
|
|
|
480
496
|
pointerEvents: U ? "auto" : "none"
|
|
481
497
|
}
|
|
482
498
|
}), /* @__PURE__ */ d("div", {
|
|
483
|
-
ref:
|
|
499
|
+
ref: pe,
|
|
484
500
|
className: "liforma-experience-host",
|
|
485
501
|
style: {
|
|
486
502
|
position: "absolute",
|
|
@@ -514,16 +530,16 @@ function ae(e, t) {
|
|
|
514
530
|
return r.observe(e), () => r.disconnect();
|
|
515
531
|
}
|
|
516
532
|
var B = /-(256x256|400x450|800x450|836x971|1672x941|167x94)$/i;
|
|
517
|
-
function
|
|
533
|
+
function oe(e) {
|
|
518
534
|
return e?.trim().replace(/\/$/, "") || "https://cdn.liforma.ai";
|
|
519
535
|
}
|
|
520
|
-
function
|
|
536
|
+
function se(e) {
|
|
521
537
|
return /^https?:\/\//i.test(e) || e.startsWith("//");
|
|
522
538
|
}
|
|
523
|
-
function
|
|
539
|
+
function ce(e) {
|
|
524
540
|
return e.startsWith("//") ? `https:${e}` : e;
|
|
525
541
|
}
|
|
526
|
-
function
|
|
542
|
+
function V(e) {
|
|
527
543
|
let t = e.indexOf("?");
|
|
528
544
|
return t === -1 ? {
|
|
529
545
|
pathname: e,
|
|
@@ -533,51 +549,51 @@ function se(e) {
|
|
|
533
549
|
search: e.slice(t)
|
|
534
550
|
};
|
|
535
551
|
}
|
|
536
|
-
function
|
|
552
|
+
function H(e, t, n = "") {
|
|
537
553
|
return `${e}${t.startsWith("/") ? t : `/${t}`}${n}`;
|
|
538
554
|
}
|
|
539
|
-
function
|
|
555
|
+
function le(e, t, n) {
|
|
540
556
|
let r = e.trim();
|
|
541
557
|
if (!r) return r;
|
|
542
|
-
let i =
|
|
543
|
-
if (
|
|
544
|
-
let { pathname: a, search: o } =
|
|
558
|
+
let i = oe(n);
|
|
559
|
+
if (se(r)) return z(ce(r), t);
|
|
560
|
+
let { pathname: a, search: o } = V(r.replace(/\\/g, "/")), s = a;
|
|
545
561
|
if (!s.startsWith("/")) s = `/locations/${s.replace(/^locations\//i, "")}`;
|
|
546
|
-
else if (!/^\/locations\//i.test(s)) return /^\/avatars\//i.test(s) ?
|
|
547
|
-
if (/\.webp$/i.test(s) && !B.test(s.replace(/\.webp$/i, ""))) return
|
|
562
|
+
else if (!/^\/locations\//i.test(s)) return /^\/avatars\//i.test(s) ? H(i, s, o) : r;
|
|
563
|
+
if (/\.webp$/i.test(s) && !B.test(s.replace(/\.webp$/i, ""))) return H(i, s, o);
|
|
548
564
|
let c = s.replace(/^\/locations\//i, "").replace(/\.webp$/i, "");
|
|
549
565
|
return c = c.replace(B, ""), `${i}/locations/${c}-${t}.webp${o}`;
|
|
550
566
|
}
|
|
551
|
-
function
|
|
567
|
+
function ue(e, t) {
|
|
552
568
|
let n = e.trim();
|
|
553
569
|
if (!n) return n;
|
|
554
|
-
let r =
|
|
555
|
-
if (
|
|
556
|
-
let { pathname: i, search: a } =
|
|
570
|
+
let r = oe(t);
|
|
571
|
+
if (se(n)) return ce(n);
|
|
572
|
+
let { pathname: i, search: a } = V(n.replace(/\\/g, "/")), o = i;
|
|
557
573
|
if (!o.startsWith("/")) if (/^avatars\//i.test(o)) o = `/${o}`;
|
|
558
574
|
else if (/^[^/]+$/.test(o) && !a) return `${r}/avatars/${o}/256/${o}_neutral.webp`;
|
|
559
575
|
else return n;
|
|
560
576
|
if (!/^\/avatars\//i.test(o)) return n;
|
|
561
577
|
let s = o.replace(/^\/avatars\//i, "").replace(/\/+$/, "");
|
|
562
|
-
return s && !s.includes("/") && !a ? `${r}/avatars/${s}/256/${s}_neutral.webp` :
|
|
578
|
+
return s && !s.includes("/") && !a ? `${r}/avatars/${s}/256/${s}_neutral.webp` : H(r, o, a);
|
|
563
579
|
}
|
|
564
580
|
//#endregion
|
|
565
581
|
//#region src/thumbnail/toGalleryThumbUrl.ts
|
|
566
|
-
var
|
|
582
|
+
var U = /(\/avatars\/[^/]+\/)(\d+)(\/)/i, de = /_CH(\.webp)/i;
|
|
567
583
|
function W(e) {
|
|
568
584
|
return /\/locations\//i.test(e) || /^locations\//i.test(e) ? !0 : /^https?:\/\//i.test(e) || e.startsWith("//") || /^\/?avatars\//i.test(e) || e.startsWith("/") ? !1 : e.includes("/");
|
|
569
585
|
}
|
|
570
|
-
function
|
|
586
|
+
function G(e, t = "256x256", n) {
|
|
571
587
|
let r = e.trim();
|
|
572
588
|
if (!r) return r;
|
|
573
|
-
if (W(r)) return
|
|
574
|
-
let i =
|
|
575
|
-
return i = i.replace(
|
|
589
|
+
if (W(r)) return le(r, t, n);
|
|
590
|
+
let i = ue(r, n);
|
|
591
|
+
return i = i.replace(U, (e, t, n, r) => n === "256" ? `${t}${n}${r}` : `${t}256${r}`), i.replace(de, "_neutral$1");
|
|
576
592
|
}
|
|
577
|
-
function
|
|
593
|
+
function fe(e) {
|
|
578
594
|
let t = e.avatarImage?.trim() || e.galleryThumb?.avatarImage?.trim() || "";
|
|
579
595
|
if (!t) return null;
|
|
580
|
-
let n = e.backgroundImage?.trim() || e.galleryThumb?.backgroundImage?.trim() || "", r = e.foregroundImage?.trim() || e.galleryThumb?.foregroundImage?.trim() || "", i = e.fallbackImage?.trim() || "", a = e.locationPlateSize ?? "256x256", o =
|
|
596
|
+
let n = e.backgroundImage?.trim() || e.galleryThumb?.backgroundImage?.trim() || "", r = e.foregroundImage?.trim() || e.galleryThumb?.foregroundImage?.trim() || "", i = e.fallbackImage?.trim() || "", a = e.locationPlateSize ?? "256x256", o = oe(e.cdnBaseUrl), s = e.normalize !== !1, c = (e) => !s && /^https?:\/\//i.test(e.trim()) ? e.trim() : G(e, a, o), l = (e) => !s && /^https?:\/\//i.test(e.trim()) ? e.trim() : le(e, a, o);
|
|
581
597
|
return {
|
|
582
598
|
avatarImage: c(t),
|
|
583
599
|
...n ? { backgroundImage: l(n) } : {},
|
|
@@ -587,7 +603,7 @@ function pe(e) {
|
|
|
587
603
|
}
|
|
588
604
|
//#endregion
|
|
589
605
|
//#region src/shims/localStack.ts
|
|
590
|
-
function
|
|
606
|
+
function pe() {
|
|
591
607
|
if (globalThis.__LIFORMA_STACK === "local") return !0;
|
|
592
608
|
if (typeof location > "u") return !1;
|
|
593
609
|
try {
|
|
@@ -598,83 +614,83 @@ function me() {
|
|
|
598
614
|
}
|
|
599
615
|
//#endregion
|
|
600
616
|
//#region src/thumbnail/hostedLaunchUrl.ts
|
|
601
|
-
var
|
|
602
|
-
function
|
|
617
|
+
var me = "https://player.liforma.ai", he = "http://localhost:3002";
|
|
618
|
+
function ge(e) {
|
|
603
619
|
return e.href?.trim() ? "anchor" : e.hasClickHandler ? "button" : e.experienceId?.trim() ? "anchor" : "presentational";
|
|
604
620
|
}
|
|
605
|
-
function
|
|
621
|
+
function _e(e) {
|
|
606
622
|
let t = e?.trim();
|
|
607
|
-
return t ? t.replace(/\/$/, "") :
|
|
623
|
+
return t ? t.replace(/\/$/, "") : pe() ? he : me;
|
|
608
624
|
}
|
|
609
|
-
function
|
|
610
|
-
let t = e.experienceId.trim(), n =
|
|
625
|
+
function ve(e) {
|
|
626
|
+
let t = e.experienceId.trim(), n = _e(e.playerBaseUrl), r = new URL(`${n}/${encodeURIComponent(t)}`), i = e.returnUrl?.trim();
|
|
611
627
|
return i && r.searchParams.set("returnUrl", i), r.toString();
|
|
612
628
|
}
|
|
613
|
-
function
|
|
629
|
+
function ye(e) {
|
|
614
630
|
let t = e.href?.trim();
|
|
615
631
|
if (t) return t;
|
|
616
632
|
let n = e.experienceId?.trim();
|
|
617
633
|
if (!n) return;
|
|
618
634
|
let r = e.returnUrl?.trim();
|
|
619
|
-
return !r && e.useCurrentPageAsReturnUrl && typeof window < "u" && (r = window.location.href),
|
|
635
|
+
return !r && e.useCurrentPageAsReturnUrl && typeof window < "u" && (r = window.location.href), ve({
|
|
620
636
|
experienceId: n,
|
|
621
637
|
...r ? { returnUrl: r } : {},
|
|
622
638
|
playerBaseUrl: e.playerBaseUrl
|
|
623
639
|
});
|
|
624
640
|
}
|
|
625
|
-
function
|
|
641
|
+
function be() {
|
|
626
642
|
return typeof window > "u" ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
|
|
627
643
|
}
|
|
628
|
-
var
|
|
644
|
+
var K = 0, xe = [];
|
|
645
|
+
function Se() {
|
|
646
|
+
return be() ? 4 : Infinity;
|
|
647
|
+
}
|
|
629
648
|
function Ce() {
|
|
630
|
-
return
|
|
649
|
+
return be() ? 160 : 0;
|
|
631
650
|
}
|
|
632
651
|
function we() {
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
let e = Ce();
|
|
637
|
-
for (; G < e && Se.length > 0;) {
|
|
638
|
-
let e = Se.shift();
|
|
652
|
+
let e = Se();
|
|
653
|
+
for (; K < e && xe.length > 0;) {
|
|
654
|
+
let e = xe.shift();
|
|
639
655
|
if (!e || e.cancelled) continue;
|
|
640
|
-
|
|
641
|
-
let t =
|
|
656
|
+
K += 1, e.start();
|
|
657
|
+
let t = Ce();
|
|
642
658
|
if (t <= 0) {
|
|
643
|
-
|
|
659
|
+
K = Math.max(0, K - 1);
|
|
644
660
|
continue;
|
|
645
661
|
}
|
|
646
662
|
window.setTimeout(() => {
|
|
647
|
-
|
|
663
|
+
K = Math.max(0, K - 1), we();
|
|
648
664
|
}, t);
|
|
649
665
|
}
|
|
650
666
|
}
|
|
651
|
-
function
|
|
652
|
-
if (!
|
|
667
|
+
function Te(e) {
|
|
668
|
+
if (!be()) return e(), () => {};
|
|
653
669
|
let t = {
|
|
654
670
|
start: e,
|
|
655
671
|
cancelled: !1
|
|
656
672
|
};
|
|
657
|
-
return
|
|
673
|
+
return xe.push(t), we(), () => {
|
|
658
674
|
t.cancelled = !0;
|
|
659
675
|
};
|
|
660
676
|
}
|
|
661
677
|
//#endregion
|
|
662
678
|
//#region src/thumbnail/lazyLoad.ts
|
|
663
|
-
function
|
|
664
|
-
return
|
|
679
|
+
function Ee() {
|
|
680
|
+
return be() ? "96px 0px" : "280px 0px";
|
|
665
681
|
}
|
|
666
|
-
function
|
|
682
|
+
function De(e) {
|
|
667
683
|
let t = e.trim().split(/\s+/)[0] ?? "0px", n = Number.parseFloat(t);
|
|
668
684
|
return Number.isFinite(n) ? Math.abs(n) : 280;
|
|
669
685
|
}
|
|
670
|
-
function
|
|
686
|
+
function q(e, t) {
|
|
671
687
|
if (typeof window > "u") return !1;
|
|
672
688
|
let n = e.getBoundingClientRect();
|
|
673
689
|
return n.bottom >= -t && n.top <= window.innerHeight + t;
|
|
674
690
|
}
|
|
675
|
-
function
|
|
676
|
-
let { onVisibleChange: n } = t, r = t.rootMargin ??
|
|
677
|
-
o || (s?.(), s =
|
|
691
|
+
function Oe(e, t) {
|
|
692
|
+
let { onVisibleChange: n } = t, r = t.rootMargin ?? Ee(), i = De(r), a = !1, o = !1, s = null, c = () => {
|
|
693
|
+
o || (s?.(), s = Te(() => {
|
|
678
694
|
s = null, o = !0, n(!0);
|
|
679
695
|
}));
|
|
680
696
|
}, l = (e) => {
|
|
@@ -696,46 +712,46 @@ function ke(e, t) {
|
|
|
696
712
|
rootMargin: r,
|
|
697
713
|
threshold: 0
|
|
698
714
|
});
|
|
699
|
-
return u.observe(e),
|
|
715
|
+
return u.observe(e), q(e, i) && l(!0), () => {
|
|
700
716
|
s?.(), s = null, u.disconnect();
|
|
701
717
|
};
|
|
702
718
|
}
|
|
703
719
|
//#endregion
|
|
704
720
|
//#region src/thumbnail/scrollParallax.ts
|
|
705
|
-
function
|
|
721
|
+
function ke() {
|
|
706
722
|
return typeof window > "u" || window.matchMedia("(prefers-reduced-motion: reduce)").matches ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
|
|
707
723
|
}
|
|
708
|
-
function
|
|
724
|
+
function Ae(e, t) {
|
|
709
725
|
return ((e.top + e.height / 2) / Math.max(t, 1) - .5) * 2;
|
|
710
726
|
}
|
|
711
|
-
var
|
|
727
|
+
var J = /* @__PURE__ */ new Set(), je = !1, Me = 0;
|
|
712
728
|
function Ne() {
|
|
713
|
-
if (
|
|
729
|
+
if (Me = 0, J.size === 0 || typeof window > "u") return;
|
|
714
730
|
let e = window.innerHeight;
|
|
715
|
-
for (let t of
|
|
731
|
+
for (let t of J) {
|
|
716
732
|
if (t.pointerActive?.()) continue;
|
|
717
733
|
let n = t.element.getBoundingClientRect();
|
|
718
|
-
n.bottom < -64 || n.top > e + 64 || t.onParallax(
|
|
734
|
+
n.bottom < -64 || n.top > e + 64 || t.onParallax(Ae(n, e));
|
|
719
735
|
}
|
|
720
736
|
}
|
|
721
737
|
function Pe() {
|
|
722
|
-
|
|
738
|
+
Me === 0 && (Me = requestAnimationFrame(Ne));
|
|
723
739
|
}
|
|
724
740
|
function Fe() {
|
|
725
|
-
|
|
741
|
+
je || typeof window > "u" || (je = !0, window.addEventListener("scroll", Pe, { passive: !0 }), window.addEventListener("resize", Pe, { passive: !0 }));
|
|
726
742
|
}
|
|
727
743
|
function Ie() {
|
|
728
|
-
|
|
744
|
+
J.size > 0 || !je || typeof window > "u" || (je = !1, Me !== 0 && (cancelAnimationFrame(Me), Me = 0), window.removeEventListener("scroll", Pe), window.removeEventListener("resize", Pe));
|
|
729
745
|
}
|
|
730
746
|
function Le(e, t) {
|
|
731
|
-
if (!
|
|
747
|
+
if (!ke()) return () => {};
|
|
732
748
|
let n = {
|
|
733
749
|
element: e,
|
|
734
750
|
onParallax: t.onParallax,
|
|
735
751
|
pointerActive: t.pointerActive
|
|
736
752
|
};
|
|
737
|
-
return
|
|
738
|
-
|
|
753
|
+
return J.add(n), Fe(), n.pointerActive?.() || t.onParallax(Ae(e.getBoundingClientRect(), window.innerHeight)), () => {
|
|
754
|
+
J.delete(n), Ie();
|
|
739
755
|
};
|
|
740
756
|
}
|
|
741
757
|
//#endregion
|
|
@@ -757,7 +773,7 @@ function Re(e) {
|
|
|
757
773
|
a = !0, e.pointerType === "mouse" && (r = !0), o();
|
|
758
774
|
}, u = () => {
|
|
759
775
|
let s = a;
|
|
760
|
-
a = !1, r = !1, i && s ? (t =
|
|
776
|
+
a = !1, r = !1, i && s ? (t = Ae(e.getBoundingClientRect(), window.innerHeight), n = 0) : i || (t = 0, n = 0), o();
|
|
761
777
|
}, d = (e) => {
|
|
762
778
|
e.pointerType === "mouse" && (r = !0, o());
|
|
763
779
|
}, f = () => {
|
|
@@ -769,7 +785,7 @@ function Re(e) {
|
|
|
769
785
|
}
|
|
770
786
|
//#endregion
|
|
771
787
|
//#region src/thumbnail/styles.ts
|
|
772
|
-
var ze = ":host {\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n}\n\n.liforma-et {\n --liforma-et-parallax-x: 0;\n --liforma-et-parallax-y: 0;\n --liforma-et-bg-scale: 1;\n --liforma-et-fg-scale: 1;\n --liforma-et-avatar-scale: 1;\n --liforma-et-bg-shift: 0px;\n --liforma-et-fg-shift: 0px;\n --liforma-et-avatar-shift: 0px;\n --liforma-et-reveal-duration: 420ms;\n\n box-sizing: border-box;\n position: relative;\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: 0
|
|
788
|
+
var ze = ":host {\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n}\n\n.liforma-et {\n --liforma-et-parallax-x: 0;\n --liforma-et-parallax-y: 0;\n --liforma-et-bg-scale: 1;\n --liforma-et-fg-scale: 1;\n --liforma-et-avatar-scale: 1;\n --liforma-et-bg-shift: 0px;\n --liforma-et-fg-shift: 0px;\n --liforma-et-avatar-shift: 0px;\n --liforma-et-reveal-duration: 420ms;\n\n box-sizing: border-box;\n position: relative;\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: 0;\n overflow: hidden;\n background: #111;\n color: inherit;\n text-decoration: none;\n cursor: inherit;\n -webkit-tap-highlight-color: transparent;\n}\n\na.liforma-et,\nbutton.liforma-et {\n cursor: pointer;\n}\n\nbutton.liforma-et {\n font: inherit;\n appearance: none;\n}\n\n.liforma-et__placeholder {\n position: absolute;\n inset: 0;\n z-index: 0;\n background:\n radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.06), transparent 58%),\n linear-gradient(180deg, #1a1a1a 0%, #101010 100%);\n opacity: 1;\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n.liforma-et--revealed .liforma-et__placeholder {\n opacity: 0;\n}\n\n.liforma-et__media {\n opacity: 0;\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n.liforma-et__media--ready {\n opacity: 1;\n}\n\n.liforma-et__background {\n position: absolute;\n inset: 0;\n z-index: 1;\n width: 100%;\n height: 100%;\n object-fit: cover;\n object-position: center center;\n transform: translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-bg-shift)),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-bg-shift))\n )\n scale(var(--liforma-et-bg-scale));\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n.liforma-et__avatar {\n position: relative;\n z-index: 2;\n display: block;\n width: 100%;\n height: 100%;\n object-fit: contain;\n object-position: center bottom;\n transform: scale(var(--liforma-et-avatar-scale))\n translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-avatar-shift)),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-avatar-shift))\n );\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n/* Gallery plates are typically square in a square tile — contain vs cover is a no-op\n without a zoom. Scale the whole scene from the upper third so Face matches\n player fit (location + avatar crop together). */\n.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.85;\n --liforma-et-bg-scale: 1.85;\n --liforma-et-fg-scale: 1.85;\n}\n\n.liforma-et--fit-face .liforma-et__avatar,\n.liforma-et--fit-face .liforma-et__background,\n.liforma-et--fit-face .liforma-et__foreground {\n transform-origin: 50% 18%;\n}\n\n.liforma-et--fit-face .liforma-et__avatar {\n object-fit: cover;\n object-position: 50% 18%;\n}\n\n/* Bust / medium: less zoom than face so upper chest stays in frame (player 3.75H window). */\n.liforma-et--fit-medium {\n --liforma-et-avatar-scale: 1.35;\n --liforma-et-bg-scale: 1.35;\n --liforma-et-fg-scale: 1.35;\n}\n\n.liforma-et--fit-medium .liforma-et__avatar,\n.liforma-et--fit-medium .liforma-et__background,\n.liforma-et--fit-medium .liforma-et__foreground {\n transform-origin: 50% 28%;\n}\n\n.liforma-et--fit-medium .liforma-et__avatar {\n object-fit: cover;\n object-position: 50% 28%;\n}\n\n.liforma-et__foreground {\n position: absolute;\n inset: 0;\n z-index: 3;\n width: 100%;\n height: 100%;\n object-fit: cover;\n object-position: center center;\n pointer-events: none;\n transform: translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-fg-shift) * -1),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-fg-shift) * -1)\n )\n scale(var(--liforma-et-fg-scale));\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n.liforma-et--parallax {\n --liforma-et-bg-scale: 1.08;\n --liforma-et-fg-scale: 1.05;\n --liforma-et-avatar-scale: 1.08;\n --liforma-et-bg-shift: 10px;\n --liforma-et-fg-shift: 4px;\n --liforma-et-avatar-shift: 4px;\n}\n\n/* Promote layers only while parallax is active — avoids N compositor surfaces on galleries. */\n.liforma-et--parallax .liforma-et__background,\n.liforma-et--parallax .liforma-et__foreground,\n.liforma-et--parallax .liforma-et__avatar {\n will-change: transform;\n}\n\n.liforma-et--parallax.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.95;\n --liforma-et-bg-scale: 1.95;\n --liforma-et-fg-scale: 1.95;\n --liforma-et-avatar-shift: 0px;\n}\n\n.liforma-et--parallax.liforma-et--fit-medium {\n --liforma-et-avatar-scale: 1.42;\n --liforma-et-bg-scale: 1.42;\n --liforma-et-fg-scale: 1.42;\n --liforma-et-avatar-shift: 0px;\n}\n\n.liforma-et--scroll-parallax .liforma-et__background,\n.liforma-et--scroll-parallax .liforma-et__foreground,\n.liforma-et--scroll-parallax .liforma-et__avatar {\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .liforma-et {\n --liforma-et-reveal-duration: 0ms;\n }\n\n .liforma-et--parallax {\n --liforma-et-bg-scale: 1;\n --liforma-et-fg-scale: 1;\n --liforma-et-avatar-scale: 1;\n --liforma-et-bg-shift: 0px;\n --liforma-et-fg-shift: 0px;\n --liforma-et-avatar-shift: 0px;\n }\n\n .liforma-et--parallax.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.85;\n --liforma-et-bg-scale: 1.85;\n --liforma-et-fg-scale: 1.85;\n }\n\n .liforma-et__background,\n .liforma-et__foreground,\n .liforma-et__avatar {\n transition: none;\n }\n}", Be = !1;
|
|
773
789
|
function Ve(e) {
|
|
774
790
|
if (typeof document > "u" || Be) return;
|
|
775
791
|
if (document.querySelector("style[data-liforma-et]")) {
|
|
@@ -785,7 +801,7 @@ function He(e, t) {
|
|
|
785
801
|
return `${e} liforma-et__media${t ? " liforma-et__media--ready" : ""}`;
|
|
786
802
|
}
|
|
787
803
|
function Ue(e) {
|
|
788
|
-
let { galleryThumb: t, avatarImage: r, backgroundImage: i, foregroundImage: c, alt: l, experienceId: p, href: m, target: h, rel: g, onClick: _, returnUrl: v, playerBaseUrl: y, parallax: b = !0, fit: x = "full", lazy: S = !0, className: C = "", fallbackImage: w, normalizeUrls: T = !0, cdnBaseUrl: E } = e, D = o(null), O = o(!1), [k, A] = s(0), [ee, j] = s(0), M = R(k, ee), N = a(() =>
|
|
804
|
+
let { galleryThumb: t, avatarImage: r, backgroundImage: i, foregroundImage: c, alt: l, experienceId: p, href: m, target: h, rel: g, onClick: _, returnUrl: v, playerBaseUrl: y, parallax: b = !0, fit: x = "full", lazy: S = !0, className: C = "", fallbackImage: w, normalizeUrls: T = !0, cdnBaseUrl: E } = e, D = o(null), O = o(!1), [k, A] = s(0), [ee, j] = s(0), M = R(k, ee), N = a(() => fe({
|
|
789
805
|
galleryThumb: t,
|
|
790
806
|
avatarImage: r,
|
|
791
807
|
backgroundImage: i,
|
|
@@ -803,15 +819,15 @@ function Ue(e) {
|
|
|
803
819
|
T,
|
|
804
820
|
M,
|
|
805
821
|
E
|
|
806
|
-
]), P =
|
|
822
|
+
]), P = ge({
|
|
807
823
|
href: m,
|
|
808
824
|
hasClickHandler: typeof _ == "function",
|
|
809
825
|
experienceId: p
|
|
810
|
-
}), F = P === "anchor" && !m?.trim() && !!p?.trim(), te = !!N?.backgroundImage, I = b !== !1, [L, ne] = s(!S), [ie, z] = s(!1), [B,
|
|
826
|
+
}), F = P === "anchor" && !m?.trim() && !!p?.trim(), te = !!N?.backgroundImage, I = b !== !1, [L, ne] = s(!S), [ie, z] = s(!1), [B, oe] = s(!1), [se, ce] = s(0), [V, H] = s(0), [le, ue] = s(!1), [U, de] = s(!1), [W, G] = s(!1), [pe, me] = s(!1), [he, _e] = s(), ve = N ? le && N.fallbackImage ? N.fallbackImage : N.avatarImage : "";
|
|
811
827
|
n(() => {
|
|
812
828
|
Ve(ze);
|
|
813
829
|
}, []), n(() => {
|
|
814
|
-
|
|
830
|
+
_e(ye({
|
|
815
831
|
href: m,
|
|
816
832
|
experienceId: p,
|
|
817
833
|
returnUrl: v,
|
|
@@ -825,24 +841,24 @@ function Ue(e) {
|
|
|
825
841
|
y,
|
|
826
842
|
F
|
|
827
843
|
]), n(() => {
|
|
828
|
-
de(!1),
|
|
844
|
+
de(!1), G(!1), me(!1), ue(!1);
|
|
829
845
|
}, [
|
|
830
846
|
N?.backgroundImage,
|
|
831
847
|
N?.foregroundImage,
|
|
832
|
-
|
|
848
|
+
ve
|
|
833
849
|
]), n(() => {
|
|
834
850
|
let e = D.current;
|
|
835
851
|
if (e) return ae(e, (e, t) => {
|
|
836
852
|
A(e), j(t);
|
|
837
853
|
});
|
|
838
|
-
}, [P,
|
|
854
|
+
}, [P, he]), n(() => {
|
|
839
855
|
let e = D.current;
|
|
840
856
|
if (e) {
|
|
841
857
|
if (!S) {
|
|
842
858
|
ne(!0);
|
|
843
859
|
return;
|
|
844
860
|
}
|
|
845
|
-
return
|
|
861
|
+
return Oe(e, { onVisibleChange: (e) => {
|
|
846
862
|
e && ne(!0);
|
|
847
863
|
} });
|
|
848
864
|
}
|
|
@@ -850,12 +866,12 @@ function Ue(e) {
|
|
|
850
866
|
S,
|
|
851
867
|
N,
|
|
852
868
|
P,
|
|
853
|
-
|
|
869
|
+
he
|
|
854
870
|
]), n(() => {
|
|
855
871
|
let e = D.current;
|
|
856
872
|
if (!(!e || !I)) return Le(e, {
|
|
857
873
|
onParallax: (e) => {
|
|
858
|
-
|
|
874
|
+
oe(!0), O.current || (ce(e), H(0));
|
|
859
875
|
},
|
|
860
876
|
pointerActive: () => O.current
|
|
861
877
|
});
|
|
@@ -863,25 +879,25 @@ function Ue(e) {
|
|
|
863
879
|
I,
|
|
864
880
|
N,
|
|
865
881
|
P,
|
|
866
|
-
|
|
882
|
+
he
|
|
867
883
|
]);
|
|
868
|
-
let
|
|
884
|
+
let be = (e) => {
|
|
869
885
|
if (!I || B) return;
|
|
870
886
|
let t = e.currentTarget.getBoundingClientRect();
|
|
871
|
-
t.width <= 0 || t.height <= 0 || (
|
|
872
|
-
},
|
|
887
|
+
t.width <= 0 || t.height <= 0 || (ce(((e.clientX - t.left) / t.width - .5) * 2), H(((e.clientY - t.top) / t.height - .5) * 2));
|
|
888
|
+
}, K = (e) => {
|
|
873
889
|
let t = O.current;
|
|
874
|
-
O.current = !1, z(!1), B && t ? (
|
|
875
|
-
},
|
|
890
|
+
O.current = !1, z(!1), B && t ? (ce(Ae(e.getBoundingClientRect(), window.innerHeight)), H(0)) : B || (ce(0), H(0));
|
|
891
|
+
}, xe = (e) => {
|
|
876
892
|
if (!I) return;
|
|
877
893
|
O.current = !0, e.pointerType === "mouse" && z(!0);
|
|
878
894
|
let t = e.currentTarget, n = () => {
|
|
879
|
-
|
|
895
|
+
K(t), window.removeEventListener("pointerup", n), window.removeEventListener("pointercancel", n);
|
|
880
896
|
};
|
|
881
897
|
window.addEventListener("pointerup", n), window.addEventListener("pointercancel", n);
|
|
882
|
-
},
|
|
898
|
+
}, Se = (e) => {
|
|
883
899
|
if (_?.(e), !e.defaultPrevented && F && !v?.trim()) {
|
|
884
|
-
let t =
|
|
900
|
+
let t = ye({
|
|
885
901
|
experienceId: p,
|
|
886
902
|
playerBaseUrl: y,
|
|
887
903
|
useCurrentPageAsReturnUrl: !0
|
|
@@ -890,103 +906,103 @@ function Ue(e) {
|
|
|
890
906
|
}
|
|
891
907
|
};
|
|
892
908
|
if (!N) return null;
|
|
893
|
-
let
|
|
909
|
+
let Ce = I && (ie || B), we = L && (W || U || pe), Te = [
|
|
894
910
|
"liforma-et",
|
|
895
911
|
te ? "liforma-et--scene" : "",
|
|
896
912
|
re(x),
|
|
897
|
-
|
|
913
|
+
Ce ? "liforma-et--parallax" : "",
|
|
898
914
|
B ? "liforma-et--scroll-parallax" : "",
|
|
899
|
-
L && !
|
|
900
|
-
|
|
915
|
+
L && !we ? "liforma-et--loading" : "",
|
|
916
|
+
we ? "liforma-et--revealed" : "",
|
|
901
917
|
C
|
|
902
|
-
].filter(Boolean).join(" "),
|
|
903
|
-
"--liforma-et-parallax-x":
|
|
904
|
-
"--liforma-et-parallax-y":
|
|
905
|
-
},
|
|
918
|
+
].filter(Boolean).join(" "), Ee = {
|
|
919
|
+
"--liforma-et-parallax-x": se,
|
|
920
|
+
"--liforma-et-parallax-y": V
|
|
921
|
+
}, De = (e, t) => {
|
|
906
922
|
e.complete && t(!0);
|
|
907
|
-
},
|
|
923
|
+
}, q = /* @__PURE__ */ f(u, { children: [
|
|
908
924
|
/* @__PURE__ */ d("span", {
|
|
909
925
|
className: "liforma-et__placeholder",
|
|
910
926
|
"aria-hidden": "true"
|
|
911
927
|
}),
|
|
912
928
|
L && N.backgroundImage ? /* @__PURE__ */ d("img", {
|
|
913
|
-
className: He("liforma-et__background",
|
|
929
|
+
className: He("liforma-et__background", U),
|
|
914
930
|
src: N.backgroundImage,
|
|
915
931
|
alt: "",
|
|
916
932
|
decoding: "async",
|
|
917
933
|
ref: (e) => {
|
|
918
|
-
e &&
|
|
934
|
+
e && De(e, de);
|
|
919
935
|
},
|
|
920
936
|
onLoad: () => de(!0),
|
|
921
937
|
onError: () => de(!0)
|
|
922
938
|
}) : null,
|
|
923
|
-
L &&
|
|
939
|
+
L && ve ? /* @__PURE__ */ d("img", {
|
|
924
940
|
className: He("liforma-et__avatar", W),
|
|
925
|
-
src:
|
|
941
|
+
src: ve,
|
|
926
942
|
alt: "",
|
|
927
943
|
decoding: "async",
|
|
928
944
|
ref: (e) => {
|
|
929
|
-
e &&
|
|
945
|
+
e && De(e, G);
|
|
930
946
|
},
|
|
931
|
-
onLoad: () =>
|
|
947
|
+
onLoad: () => G(!0),
|
|
932
948
|
onError: () => {
|
|
933
|
-
N.fallbackImage ?
|
|
949
|
+
N.fallbackImage ? ue(!0) : G(!0);
|
|
934
950
|
}
|
|
935
951
|
}) : null,
|
|
936
952
|
L && N.foregroundImage ? /* @__PURE__ */ d("img", {
|
|
937
|
-
className: He("liforma-et__foreground",
|
|
953
|
+
className: He("liforma-et__foreground", pe),
|
|
938
954
|
src: N.foregroundImage,
|
|
939
955
|
alt: "",
|
|
940
956
|
decoding: "async",
|
|
941
957
|
ref: (e) => {
|
|
942
|
-
e &&
|
|
958
|
+
e && De(e, me);
|
|
943
959
|
},
|
|
944
|
-
onLoad: () =>
|
|
945
|
-
onError: () =>
|
|
960
|
+
onLoad: () => me(!0),
|
|
961
|
+
onError: () => me(!0)
|
|
946
962
|
}) : null
|
|
947
|
-
] }),
|
|
948
|
-
onPointerDown:
|
|
949
|
-
onPointerUp: (e) =>
|
|
950
|
-
onPointerCancel: (e) =>
|
|
963
|
+
] }), ke = {
|
|
964
|
+
onPointerDown: xe,
|
|
965
|
+
onPointerUp: (e) => K(e.currentTarget),
|
|
966
|
+
onPointerCancel: (e) => K(e.currentTarget),
|
|
951
967
|
onPointerEnter: (e) => {
|
|
952
968
|
I && e.pointerType === "mouse" && z(!0);
|
|
953
969
|
},
|
|
954
|
-
onPointerMove:
|
|
970
|
+
onPointerMove: be,
|
|
955
971
|
onPointerLeave: () => {
|
|
956
|
-
O.current || (z(!1), B || (
|
|
972
|
+
O.current || (z(!1), B || (ce(0), H(0)));
|
|
957
973
|
}
|
|
958
|
-
},
|
|
974
|
+
}, J = (e) => {
|
|
959
975
|
D.current = e;
|
|
960
976
|
};
|
|
961
|
-
return P === "anchor" &&
|
|
962
|
-
ref:
|
|
963
|
-
className:
|
|
964
|
-
style:
|
|
965
|
-
href:
|
|
977
|
+
return P === "anchor" && he ? /* @__PURE__ */ d("a", {
|
|
978
|
+
ref: J,
|
|
979
|
+
className: Te,
|
|
980
|
+
style: Ee,
|
|
981
|
+
href: he,
|
|
966
982
|
target: h,
|
|
967
983
|
rel: g,
|
|
968
984
|
"aria-label": l,
|
|
969
|
-
onClick:
|
|
970
|
-
...
|
|
971
|
-
children:
|
|
985
|
+
onClick: Se,
|
|
986
|
+
...ke,
|
|
987
|
+
children: q
|
|
972
988
|
}) : P === "button" ? /* @__PURE__ */ d("button", {
|
|
973
989
|
type: "button",
|
|
974
|
-
ref:
|
|
975
|
-
className:
|
|
976
|
-
style:
|
|
990
|
+
ref: J,
|
|
991
|
+
className: Te,
|
|
992
|
+
style: Ee,
|
|
977
993
|
"aria-label": l,
|
|
978
|
-
onClick:
|
|
979
|
-
...
|
|
980
|
-
children:
|
|
994
|
+
onClick: Se,
|
|
995
|
+
...ke,
|
|
996
|
+
children: q
|
|
981
997
|
}) : /* @__PURE__ */ d("div", {
|
|
982
|
-
ref:
|
|
983
|
-
className:
|
|
984
|
-
style:
|
|
998
|
+
ref: J,
|
|
999
|
+
className: Te,
|
|
1000
|
+
style: Ee,
|
|
985
1001
|
role: l ? "img" : void 0,
|
|
986
1002
|
"aria-label": l || void 0,
|
|
987
1003
|
"aria-hidden": l ? void 0 : !0,
|
|
988
|
-
...
|
|
989
|
-
children:
|
|
1004
|
+
...ke,
|
|
1005
|
+
children: q
|
|
990
1006
|
});
|
|
991
1007
|
}
|
|
992
1008
|
//#endregion
|
|
@@ -1013,7 +1029,7 @@ function Ye() {
|
|
|
1013
1029
|
return t ? t.replace(/\/$/, "") : null;
|
|
1014
1030
|
}
|
|
1015
1031
|
function Xe() {
|
|
1016
|
-
return Ye() || (
|
|
1032
|
+
return Ye() || (pe() ? Je : qe);
|
|
1017
1033
|
}
|
|
1018
1034
|
//#endregion
|
|
1019
1035
|
//#region src/v2/api/fetchExperiencePreview.ts
|
|
@@ -1428,13 +1444,13 @@ var Mt = new Set([1, 2]);
|
|
|
1428
1444
|
function Nt(e) {
|
|
1429
1445
|
return typeof e == "number" && Mt.has(e);
|
|
1430
1446
|
}
|
|
1431
|
-
var Pt = new Set(/* @__PURE__ */ "close.stateUpdate.commandResult.userTranscript.characterSpeechStarted.characterSpeechEnded.characterFocusChanged.conversationUpdate.listeningState.userSpeechStarted.userSpeechEnded.modeChange.activityChange.feedback.feedbackFailed.message.started.embedReady.widgetReady.widgetExpand.widgetCollapse.widgetAudioSettings.widgetDragStart.widgetDragMove.widgetDragEnd.fullWindow.interactionChange".split("."));
|
|
1447
|
+
var Pt = new Set(/* @__PURE__ */ "close.stateUpdate.commandResult.userTranscript.characterSpeechStarted.characterSpeechEnded.characterFocusChanged.conversationUpdate.listeningState.userSpeechStarted.userSpeechEnded.modeChange.activityChange.feedback.feedbackFailed.message.started.embedReady.widgetReady.widgetExpand.widgetCollapse.widgetAudioSettings.widgetDragStart.widgetDragMove.widgetDragEnd.fullWindow.theatre.interactionChange".split("."));
|
|
1432
1448
|
function Ft(e) {
|
|
1433
1449
|
if (!e || typeof e != "object") return null;
|
|
1434
1450
|
let t = e;
|
|
1435
1451
|
if (!Nt(t.schemaVersion) || !t.type || !Pt.has(t.type)) return null;
|
|
1436
1452
|
if (t.type === "embedReady" || t.type === "widgetReady" || t.type === "widgetExpand" || t.type === "widgetCollapse") return t;
|
|
1437
|
-
if (t.type === "fullWindow") {
|
|
1453
|
+
if (t.type === "fullWindow" || t.type === "theatre") {
|
|
1438
1454
|
let e = t.payload;
|
|
1439
1455
|
return !e || typeof e != "object" || typeof e.active != "boolean" ? null : t;
|
|
1440
1456
|
}
|
|
@@ -1458,7 +1474,7 @@ function Ft(e) {
|
|
|
1458
1474
|
function It(e, t, n) {
|
|
1459
1475
|
let r = e.trim();
|
|
1460
1476
|
if (!r) throw Error("createLaunchMessage requires a non-empty launch string.");
|
|
1461
|
-
let i = n?.startButton, a = n?.theme, o = n?.showFeedback, s = n?.interaction;
|
|
1477
|
+
let i = n?.startButton, a = n?.theme, o = n?.showFeedback, s = n?.interaction, c = n?.theatreButton, l = n?.theatre;
|
|
1462
1478
|
return {
|
|
1463
1479
|
type: "launch",
|
|
1464
1480
|
schemaVersion: 2,
|
|
@@ -1468,7 +1484,9 @@ function It(e, t, n) {
|
|
|
1468
1484
|
...i ? { startButton: i } : {},
|
|
1469
1485
|
...a ? { theme: a } : {},
|
|
1470
1486
|
...o === void 0 ? {} : { showFeedback: o },
|
|
1471
|
-
...s ? { interaction: s } : {}
|
|
1487
|
+
...s ? { interaction: s } : {},
|
|
1488
|
+
...c ? { theatreButton: !0 } : {},
|
|
1489
|
+
...l === void 0 ? {} : { theatre: l }
|
|
1472
1490
|
}
|
|
1473
1491
|
};
|
|
1474
1492
|
}
|
|
@@ -1492,10 +1510,17 @@ function zt() {
|
|
|
1492
1510
|
payload: {}
|
|
1493
1511
|
};
|
|
1494
1512
|
}
|
|
1513
|
+
function Bt(e) {
|
|
1514
|
+
return {
|
|
1515
|
+
type: "setTheatre",
|
|
1516
|
+
schemaVersion: 2,
|
|
1517
|
+
payload: { active: e }
|
|
1518
|
+
};
|
|
1519
|
+
}
|
|
1495
1520
|
//#endregion
|
|
1496
1521
|
//#region src/v2/embed/fullWindowHost.ts
|
|
1497
|
-
var
|
|
1498
|
-
function
|
|
1522
|
+
var Vt = "2147483000";
|
|
1523
|
+
function Ht(e) {
|
|
1499
1524
|
let { style: t } = e;
|
|
1500
1525
|
return {
|
|
1501
1526
|
position: t.position,
|
|
@@ -1513,11 +1538,11 @@ function Vt(e) {
|
|
|
1513
1538
|
maxHeight: t.maxHeight
|
|
1514
1539
|
};
|
|
1515
1540
|
}
|
|
1516
|
-
function
|
|
1541
|
+
function Ut(e) {
|
|
1517
1542
|
let { style: t } = e;
|
|
1518
|
-
t.position = "fixed", t.top = "0", t.right = "0", t.bottom = "0", t.left = "0", t.inset = "0", t.width = "100vw", t.width = "100dvw", t.height = "100vh", t.height = "100dvh", t.zIndex =
|
|
1543
|
+
t.position = "fixed", t.top = "0", t.right = "0", t.bottom = "0", t.left = "0", t.inset = "0", t.width = "100vw", t.width = "100dvw", t.height = "100vh", t.height = "100dvh", t.zIndex = Vt, t.margin = "0", t.borderRadius = "0", t.maxWidth = "none", t.maxHeight = "none", e.dataset.liformaFullWindow = "1";
|
|
1519
1544
|
}
|
|
1520
|
-
function
|
|
1545
|
+
function Wt(e, t) {
|
|
1521
1546
|
if (delete e.dataset.liformaFullWindow, !t) {
|
|
1522
1547
|
e.style.position = "", e.style.top = "", e.style.right = "", e.style.bottom = "", e.style.left = "", e.style.inset = "", e.style.width = "", e.style.height = "", e.style.zIndex = "", e.style.margin = "", e.style.borderRadius = "", e.style.maxWidth = "", e.style.maxHeight = "";
|
|
1523
1548
|
return;
|
|
@@ -1527,20 +1552,20 @@ function Ut(e, t) {
|
|
|
1527
1552
|
}
|
|
1528
1553
|
//#endregion
|
|
1529
1554
|
//#region src/v2/embed/iframeHost.ts
|
|
1530
|
-
function
|
|
1555
|
+
function Gt(e) {
|
|
1531
1556
|
return e;
|
|
1532
1557
|
}
|
|
1533
1558
|
function Z() {
|
|
1534
1559
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? `cmd_${crypto.randomUUID().replace(/-/g, "").slice(0, 12)}` : `cmd_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
|
|
1535
1560
|
}
|
|
1536
|
-
var
|
|
1537
|
-
function
|
|
1561
|
+
var Kt = 3e4;
|
|
1562
|
+
function qt(e) {
|
|
1538
1563
|
let t = e.container;
|
|
1539
1564
|
getComputedStyle(t).position === "static" && (t.style.position = "relative");
|
|
1540
1565
|
let n = document.createElement("iframe");
|
|
1541
|
-
n.src = e.src, n.title = "Liforma experience", n.setAttribute("allow", "microphone; autoplay; clipboard-read; clipboard-write"), n.style.cssText = e.transparent ? "display:block;position:absolute;inset:0;width:100%;height:100%;border:0;background:transparent;" : "display:block;position:absolute;inset:0;width:100%;height:100%;border:0;background:#030508;", e.transparent && n.setAttribute("allowtransparency", "true");
|
|
1542
|
-
let r = !1, i = !1, a = null, o =
|
|
1543
|
-
i !==
|
|
1566
|
+
n.src = e.src, n.title = "Liforma experience", n.setAttribute("allow", "microphone; autoplay; clipboard-read; clipboard-write; fullscreen"), n.setAttribute("allowfullscreen", ""), n.style.cssText = e.transparent ? "display:block;position:absolute;inset:0;width:100%;height:100%;border:0;background:transparent;" : "display:block;position:absolute;inset:0;width:100%;height:100%;border:0;background:#030508;", e.transparent && n.setAttribute("allowtransparency", "true");
|
|
1567
|
+
let r = !1, i = !1, a = null, o = null, s = (r) => {
|
|
1568
|
+
i !== r && (i = r, r ? (a = Ht(n), o = document.body.style.overflow, document.body.append(n), Ut(n), document.body.style.overflow = "hidden") : (t.append(n), Wt(n, a), a = null, o !== null && (document.body.style.overflow = o, o = null)), e.onFullWindowChange?.(r));
|
|
1544
1569
|
}, c = /* @__PURE__ */ new Map(), l = null, u = 0, d = 0, f = [], p = null, m = null, h = new Promise((e, t) => {
|
|
1545
1570
|
p = e, m = t;
|
|
1546
1571
|
}), g = () => {
|
|
@@ -1611,7 +1636,7 @@ function Kt(e) {
|
|
|
1611
1636
|
e.onUserSpeechEnded?.(i.payload);
|
|
1612
1637
|
break;
|
|
1613
1638
|
case "modeChange":
|
|
1614
|
-
e.onActivityChange?.(
|
|
1639
|
+
e.onActivityChange?.(Gt(i.payload.mode));
|
|
1615
1640
|
break;
|
|
1616
1641
|
case "activityChange":
|
|
1617
1642
|
e.onActivityChange?.(i.payload.activity);
|
|
@@ -1655,6 +1680,9 @@ function Kt(e) {
|
|
|
1655
1680
|
case "fullWindow":
|
|
1656
1681
|
s(i.payload.active);
|
|
1657
1682
|
break;
|
|
1683
|
+
case "theatre":
|
|
1684
|
+
e.onTheatreChange?.(i.payload.active);
|
|
1685
|
+
break;
|
|
1658
1686
|
case "interactionChange":
|
|
1659
1687
|
e.onInteractionChange?.(i.payload.interaction);
|
|
1660
1688
|
break;
|
|
@@ -1712,6 +1740,9 @@ function Kt(e) {
|
|
|
1712
1740
|
postWidgetToggleAudioSettings() {
|
|
1713
1741
|
S(zt());
|
|
1714
1742
|
},
|
|
1743
|
+
postSetTheatre(e) {
|
|
1744
|
+
S(Bt(e));
|
|
1745
|
+
},
|
|
1715
1746
|
speak(e) {
|
|
1716
1747
|
return C({
|
|
1717
1748
|
type: "speak",
|
|
@@ -1832,7 +1863,7 @@ function Kt(e) {
|
|
|
1832
1863
|
audio: e.audio,
|
|
1833
1864
|
byteLength: e.byteLength
|
|
1834
1865
|
}
|
|
1835
|
-
},
|
|
1866
|
+
}, Kt, [e.audio]);
|
|
1836
1867
|
},
|
|
1837
1868
|
speechUtteranceSetTranscript(e) {
|
|
1838
1869
|
return C({
|
|
@@ -1994,7 +2025,7 @@ function Kt(e) {
|
|
|
1994
2025
|
}
|
|
1995
2026
|
//#endregion
|
|
1996
2027
|
//#region src/v2/embed/readyGate.ts
|
|
1997
|
-
function
|
|
2028
|
+
function Jt(e) {
|
|
1998
2029
|
let t, n = !1, r = !1, i = () => {
|
|
1999
2030
|
r || !n || t === void 0 || (r = !0, e(t));
|
|
2000
2031
|
};
|
|
@@ -2009,9 +2040,9 @@ function qt(e) {
|
|
|
2009
2040
|
}
|
|
2010
2041
|
//#endregion
|
|
2011
2042
|
//#region src/v2/sdkRelease.ts
|
|
2012
|
-
var
|
|
2043
|
+
var Yt = `sdk@${{
|
|
2013
2044
|
name: "@liforma/client",
|
|
2014
|
-
version: "0.4.
|
|
2045
|
+
version: "0.4.13",
|
|
2015
2046
|
type: "module",
|
|
2016
2047
|
description: "Liforma browser SDK — Experience sessions, speech API, and Svelte embed component.",
|
|
2017
2048
|
license: "MIT",
|
|
@@ -2230,50 +2261,50 @@ var Jt = `sdk@${{
|
|
|
2230
2261
|
vitest: "^4.1.10",
|
|
2231
2262
|
wrangler: "^4.101.0"
|
|
2232
2263
|
}
|
|
2233
|
-
}.version}`,
|
|
2234
|
-
function
|
|
2264
|
+
}.version}`, Xt = "https://player.liforma.ai/embed", Zt = "http://localhost:3002/embed";
|
|
2265
|
+
function Qt() {
|
|
2235
2266
|
let e = globalThis.__LIFORMA_PLAYER_EMBED_URL;
|
|
2236
2267
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
2237
2268
|
if (typeof document > "u") return null;
|
|
2238
2269
|
let t = (document.querySelector("script[data-liforma-sdk][src*=\"client.js\"]") ?? document.querySelector("script[src*=\"/sdk/v2/client.js\"]"))?.getAttribute("data-player-embed-url")?.trim();
|
|
2239
2270
|
return t ? t.replace(/\/$/, "") : null;
|
|
2240
2271
|
}
|
|
2241
|
-
function
|
|
2242
|
-
let e =
|
|
2243
|
-
return e ? e.endsWith("/embed") ? e : `${e}/embed` :
|
|
2272
|
+
function $t() {
|
|
2273
|
+
let e = Qt();
|
|
2274
|
+
return e ? e.endsWith("/embed") ? e : `${e}/embed` : pe() ? Zt : Xt;
|
|
2244
2275
|
}
|
|
2245
|
-
function
|
|
2276
|
+
function en(e, t) {
|
|
2246
2277
|
return e?.trim() || t?.trim() || void 0;
|
|
2247
2278
|
}
|
|
2248
|
-
function
|
|
2249
|
-
let d = (e ??
|
|
2279
|
+
function tn(e, t, n, r, i, a, o, s, c, l, u) {
|
|
2280
|
+
let d = (e ?? $t()).replace(/\/$/, ""), f = d.endsWith("/embed") ? d : `${d}/embed`, p = new URL(f), m = n?.trim();
|
|
2250
2281
|
m && p.searchParams.set("backdropId", m);
|
|
2251
2282
|
let h = r?.trim();
|
|
2252
|
-
return h && p.searchParams.set("avatarId", h), (i === "face" || i === "medium") && p.searchParams.set("fit", i), c === "pip" && p.searchParams.set("stage", "pip"), l === "set" && p.searchParams.set("pipBackground", "set"), u === !1 && p.searchParams.set("pipShadow", "0"), a === "widget" && p.searchParams.set("ui", "widget"), o && p.searchParams.set("close", "1"), t && p.searchParams.set("debug", "true"), (s === 2 || s === 3 || s === 4) && p.searchParams.set("cast", String(s)),
|
|
2283
|
+
return h && p.searchParams.set("avatarId", h), (i === "face" || i === "medium") && p.searchParams.set("fit", i), c === "pip" && p.searchParams.set("stage", "pip"), l === "set" && p.searchParams.set("pipBackground", "set"), u === !1 && p.searchParams.set("pipShadow", "0"), a === "widget" && p.searchParams.set("ui", "widget"), o && p.searchParams.set("close", "1"), t && p.searchParams.set("debug", "true"), (s === 2 || s === 3 || s === 4) && p.searchParams.set("cast", String(s)), nn(p.toString());
|
|
2253
2284
|
}
|
|
2254
|
-
function
|
|
2285
|
+
function nn(e) {
|
|
2255
2286
|
if (typeof location > "u") return e;
|
|
2256
2287
|
let t = new URL(e);
|
|
2257
2288
|
return t.searchParams.set("parentOrigin", location.origin), t.toString();
|
|
2258
2289
|
}
|
|
2259
|
-
function
|
|
2290
|
+
function rn(e) {
|
|
2260
2291
|
return new URL(e).origin;
|
|
2261
2292
|
}
|
|
2262
2293
|
//#endregion
|
|
2263
2294
|
//#region src/v2/experienceEvents.ts
|
|
2264
|
-
function
|
|
2295
|
+
function an() {
|
|
2265
2296
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? `evt_${crypto.randomUUID().replace(/-/g, "").slice(0, 12)}` : `evt_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
|
|
2266
2297
|
}
|
|
2267
|
-
function
|
|
2298
|
+
function on(e, t, n) {
|
|
2268
2299
|
return {
|
|
2269
|
-
id:
|
|
2300
|
+
id: an(),
|
|
2270
2301
|
type: e,
|
|
2271
2302
|
sessionId: t,
|
|
2272
2303
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2273
2304
|
data: n
|
|
2274
2305
|
};
|
|
2275
2306
|
}
|
|
2276
|
-
function
|
|
2307
|
+
function sn() {
|
|
2277
2308
|
return {
|
|
2278
2309
|
ready: /* @__PURE__ */ new Set(),
|
|
2279
2310
|
started: /* @__PURE__ */ new Set(),
|
|
@@ -2294,39 +2325,39 @@ function on() {
|
|
|
2294
2325
|
conversationProcessorError: /* @__PURE__ */ new Set()
|
|
2295
2326
|
};
|
|
2296
2327
|
}
|
|
2297
|
-
function
|
|
2328
|
+
function cn(e, t, n) {
|
|
2298
2329
|
return e[t].add(n), () => e[t].delete(n);
|
|
2299
2330
|
}
|
|
2300
|
-
function
|
|
2331
|
+
function ln(e, t, n) {
|
|
2301
2332
|
for (let r of e[t]) r(n);
|
|
2302
2333
|
}
|
|
2303
|
-
function
|
|
2334
|
+
function un(e) {
|
|
2304
2335
|
for (let t of Object.keys(e)) e[t].clear();
|
|
2305
2336
|
}
|
|
2306
2337
|
//#endregion
|
|
2307
2338
|
//#region src/v2/speech/types.ts
|
|
2308
|
-
function
|
|
2339
|
+
function dn(e) {
|
|
2309
2340
|
return "data" in e && "format" in e && e.format != null && !("track" in e);
|
|
2310
2341
|
}
|
|
2311
|
-
function
|
|
2342
|
+
function fn(e) {
|
|
2312
2343
|
return "url" in e && typeof e.url == "string";
|
|
2313
2344
|
}
|
|
2314
|
-
function
|
|
2345
|
+
function pn(e) {
|
|
2315
2346
|
if (!("track" in e)) return !1;
|
|
2316
2347
|
let t = e.track;
|
|
2317
2348
|
return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
|
|
2318
2349
|
}
|
|
2319
|
-
function
|
|
2320
|
-
return !
|
|
2350
|
+
function mn(e) {
|
|
2351
|
+
return !dn(e) && !fn(e) && !pn(e) && "encoding" in e && typeof e.encoding == "string";
|
|
2321
2352
|
}
|
|
2322
|
-
var
|
|
2353
|
+
var hn = [
|
|
2323
2354
|
8e3,
|
|
2324
2355
|
16e3,
|
|
2325
2356
|
22050,
|
|
2326
2357
|
24e3,
|
|
2327
2358
|
44100,
|
|
2328
2359
|
48e3
|
|
2329
|
-
],
|
|
2360
|
+
], gn = {
|
|
2330
2361
|
MAX_CHUNK_BYTES: 64 * 1024,
|
|
2331
2362
|
RECOMMENDED_CHUNK_MS_MIN: 20,
|
|
2332
2363
|
RECOMMENDED_CHUNK_MS_MAX: 200,
|
|
@@ -2337,14 +2368,14 @@ var mn = [
|
|
|
2337
2368
|
MAX_UTTERANCE_DURATION_MS: 9e4,
|
|
2338
2369
|
MAX_PENDING_WRITES: 8,
|
|
2339
2370
|
DEFAULT_WRITE_TIMEOUT_MS: 5e3
|
|
2340
|
-
},
|
|
2371
|
+
}, _n = class extends Error {
|
|
2341
2372
|
operation;
|
|
2342
2373
|
requiredCapability;
|
|
2343
2374
|
name = "UnsupportedSpeechOperationError";
|
|
2344
2375
|
constructor(e, t) {
|
|
2345
2376
|
super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
|
|
2346
2377
|
}
|
|
2347
|
-
},
|
|
2378
|
+
}, vn = class extends Error {
|
|
2348
2379
|
name = "SpeechUtteranceClosedError";
|
|
2349
2380
|
constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
|
|
2350
2381
|
super(e);
|
|
@@ -2354,72 +2385,72 @@ var mn = [
|
|
|
2354
2385
|
constructor(e, t) {
|
|
2355
2386
|
super(e, t);
|
|
2356
2387
|
}
|
|
2357
|
-
},
|
|
2388
|
+
}, yn = class extends Error {
|
|
2358
2389
|
name = "SpeechBufferTimeoutError";
|
|
2359
2390
|
constructor(e = "Timed out waiting for speech buffer capacity.") {
|
|
2360
2391
|
super(e);
|
|
2361
2392
|
}
|
|
2362
2393
|
};
|
|
2363
|
-
function
|
|
2394
|
+
function bn(e = "none") {
|
|
2364
2395
|
return {
|
|
2365
2396
|
mode: e,
|
|
2366
2397
|
trackedDurationMs: 0,
|
|
2367
2398
|
fallbackDurationMs: 0
|
|
2368
2399
|
};
|
|
2369
2400
|
}
|
|
2370
|
-
function bn(e) {
|
|
2371
|
-
return mn.includes(e);
|
|
2372
|
-
}
|
|
2373
2401
|
function xn(e) {
|
|
2402
|
+
return hn.includes(e);
|
|
2403
|
+
}
|
|
2404
|
+
function Sn(e) {
|
|
2374
2405
|
if (e.encoding !== "pcm_s16le") throw new Q(`Unsupported audio encoding: ${e.encoding}`);
|
|
2375
2406
|
if (e.channels !== 1) throw new Q(`Unsupported channel count: ${e.channels}`);
|
|
2376
|
-
if (!
|
|
2407
|
+
if (!xn(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
2377
2408
|
}
|
|
2378
|
-
function
|
|
2379
|
-
if (
|
|
2380
|
-
|
|
2409
|
+
function Cn(e) {
|
|
2410
|
+
if (dn(e)) {
|
|
2411
|
+
Sn(e.format);
|
|
2381
2412
|
return;
|
|
2382
2413
|
}
|
|
2383
|
-
if (
|
|
2414
|
+
if (fn(e)) {
|
|
2384
2415
|
if (!e.url.trim()) throw new Q("Audio URL must be non-empty.");
|
|
2385
|
-
if (e.sampleRate !== void 0 && !
|
|
2416
|
+
if (e.sampleRate !== void 0 && !xn(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
2386
2417
|
return;
|
|
2387
2418
|
}
|
|
2388
|
-
if (
|
|
2419
|
+
if (pn(e)) {
|
|
2389
2420
|
if (e.track.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
2390
|
-
if (e.sampleRate !== void 0 && !
|
|
2421
|
+
if (e.sampleRate !== void 0 && !xn(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
2391
2422
|
return;
|
|
2392
2423
|
}
|
|
2393
|
-
if (
|
|
2424
|
+
if (mn(e)) {
|
|
2394
2425
|
let t = e.encoding.trim().toLowerCase();
|
|
2395
2426
|
if (!t) throw new Q("Encoded audio MIME type is required.");
|
|
2396
2427
|
if (t === "pcm_s16le") throw new Q("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
|
|
2397
|
-
if (e.sampleRate !== void 0 && !
|
|
2428
|
+
if (e.sampleRate !== void 0 && !xn(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
2398
2429
|
return;
|
|
2399
2430
|
}
|
|
2400
2431
|
throw new Q("Unsupported speech.play audio shape.");
|
|
2401
2432
|
}
|
|
2402
|
-
function
|
|
2403
|
-
if (e.format) return
|
|
2433
|
+
function wn(e) {
|
|
2434
|
+
if (e.format) return Sn(e.format), e.format;
|
|
2404
2435
|
if (e.track) {
|
|
2405
2436
|
let t = {
|
|
2406
2437
|
encoding: "pcm_s16le",
|
|
2407
2438
|
sampleRate: e.sampleRate ?? 24e3,
|
|
2408
2439
|
channels: 1
|
|
2409
2440
|
};
|
|
2410
|
-
return
|
|
2441
|
+
return Sn(t), t;
|
|
2411
2442
|
}
|
|
2412
2443
|
throw new Q("createUtterance requires format or track.");
|
|
2413
2444
|
}
|
|
2414
|
-
function
|
|
2445
|
+
function Tn(e) {
|
|
2415
2446
|
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
2416
2447
|
}
|
|
2417
|
-
function
|
|
2448
|
+
function En(e) {
|
|
2418
2449
|
return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
|
|
2419
2450
|
}
|
|
2420
2451
|
//#endregion
|
|
2421
2452
|
//#region src/byo/pcm.ts
|
|
2422
|
-
function
|
|
2453
|
+
function Dn(e) {
|
|
2423
2454
|
let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
|
|
2424
2455
|
for (let t = 0; t < e.length; t++) {
|
|
2425
2456
|
let r = Math.max(-1, Math.min(1, e[t]));
|
|
@@ -2429,11 +2460,11 @@ function En(e) {
|
|
|
2429
2460
|
}
|
|
2430
2461
|
//#endregion
|
|
2431
2462
|
//#region src/byo/resample.ts
|
|
2432
|
-
function
|
|
2463
|
+
function On(e, t, n, r, i) {
|
|
2433
2464
|
let a = -.5 * e + 1.5 * t - 1.5 * n + .5 * r, o = e - 2.5 * t + 2 * n - .5 * r, s = -.5 * e + .5 * n, c = t;
|
|
2434
2465
|
return ((a * i + o) * i + s) * i + c;
|
|
2435
2466
|
}
|
|
2436
|
-
function
|
|
2467
|
+
function kn(e, t) {
|
|
2437
2468
|
if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
|
|
2438
2469
|
if (e === t) return {
|
|
2439
2470
|
fromRate: e,
|
|
@@ -2456,7 +2487,7 @@ function On(e, t) {
|
|
|
2456
2487
|
let a = [];
|
|
2457
2488
|
for (; i + 2 < r.length - 1;) {
|
|
2458
2489
|
let e = Math.floor(i), t = i - e, o = Math.max(0, e - 1), s = Math.min(r.length - 1, e + 1), c = Math.min(r.length - 1, e + 2);
|
|
2459
|
-
a.push(
|
|
2490
|
+
a.push(On(r[o], r[e], r[s], r[c], t)), i += n;
|
|
2460
2491
|
}
|
|
2461
2492
|
let o = Math.max(0, Math.floor(i) - 1);
|
|
2462
2493
|
return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
|
|
@@ -2468,7 +2499,7 @@ function On(e, t) {
|
|
|
2468
2499
|
}
|
|
2469
2500
|
//#endregion
|
|
2470
2501
|
//#region src/byo/audioCapture.ts
|
|
2471
|
-
var
|
|
2502
|
+
var An = "liforma-pcm-capture", jn = `
|
|
2472
2503
|
class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
2473
2504
|
process(inputs) {
|
|
2474
2505
|
const ch = inputs[0] && inputs[0][0];
|
|
@@ -2480,29 +2511,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
|
2480
2511
|
return true;
|
|
2481
2512
|
}
|
|
2482
2513
|
}
|
|
2483
|
-
registerProcessor('${
|
|
2484
|
-
`,
|
|
2485
|
-
function Mn() {
|
|
2486
|
-
return jn ||= URL.createObjectURL(new Blob([An], { type: "application/javascript" })), jn;
|
|
2487
|
-
}
|
|
2514
|
+
registerProcessor('${An}', LiformaPcmCaptureProcessor);
|
|
2515
|
+
`, Mn = null;
|
|
2488
2516
|
function Nn() {
|
|
2517
|
+
return Mn ||= URL.createObjectURL(new Blob([jn], { type: "application/javascript" })), Mn;
|
|
2518
|
+
}
|
|
2519
|
+
function Pn() {
|
|
2489
2520
|
return window.AudioContext || window.webkitAudioContext || null;
|
|
2490
2521
|
}
|
|
2491
|
-
async function
|
|
2492
|
-
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o =
|
|
2522
|
+
async function Fn(e) {
|
|
2523
|
+
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = Pn();
|
|
2493
2524
|
if (!o) throw Error("Web Audio is required for audio capture");
|
|
2494
2525
|
let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
|
|
2495
2526
|
l.gain.value = 0;
|
|
2496
|
-
let u = s.sampleRate, d =
|
|
2527
|
+
let u = s.sampleRate, d = kn(u, n), f = !1, p = !1, m = (e) => {
|
|
2497
2528
|
if (f || i && !i()) return;
|
|
2498
2529
|
let t = d.push(e);
|
|
2499
|
-
t.length !== 0 && r(
|
|
2530
|
+
t.length !== 0 && r(Dn(t));
|
|
2500
2531
|
}, h = () => void 0;
|
|
2501
2532
|
return await (async () => {
|
|
2502
2533
|
if (typeof s.audioWorklet?.addModule != "function") return !1;
|
|
2503
2534
|
try {
|
|
2504
|
-
await s.audioWorklet.addModule(
|
|
2505
|
-
let e = new AudioWorkletNode(s,
|
|
2535
|
+
await s.audioWorklet.addModule(Nn());
|
|
2536
|
+
let e = new AudioWorkletNode(s, An, {
|
|
2506
2537
|
numberOfInputs: 1,
|
|
2507
2538
|
numberOfOutputs: 1,
|
|
2508
2539
|
outputChannelCount: [1]
|
|
@@ -2552,7 +2583,7 @@ async function Pn(e) {
|
|
|
2552
2583
|
}
|
|
2553
2584
|
//#endregion
|
|
2554
2585
|
//#region src/v2/speech/captureMediaStreamTrack.ts
|
|
2555
|
-
async function
|
|
2586
|
+
async function In(e) {
|
|
2556
2587
|
let { track: t, utterance: n, sampleRate: r, signal: i } = e;
|
|
2557
2588
|
if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Q("MediaStreamTrack is not available in this environment.");
|
|
2558
2589
|
if (t.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
@@ -2561,18 +2592,18 @@ async function Fn(e) {
|
|
|
2561
2592
|
s || (s = !0, c?.stop(), c = null);
|
|
2562
2593
|
};
|
|
2563
2594
|
try {
|
|
2564
|
-
c = await
|
|
2595
|
+
c = await Fn({
|
|
2565
2596
|
mediaStream: a,
|
|
2566
2597
|
targetSampleRate: r,
|
|
2567
2598
|
shouldSend: () => !s && !i?.aborted,
|
|
2568
2599
|
onPcm: (e) => {
|
|
2569
2600
|
if (s || i?.aborted) return;
|
|
2570
|
-
let t =
|
|
2601
|
+
let t = Tn(e);
|
|
2571
2602
|
o = o.then(async () => {
|
|
2572
2603
|
if (s || i?.aborted) return;
|
|
2573
2604
|
let e = 0;
|
|
2574
2605
|
for (; e < t.byteLength;) {
|
|
2575
|
-
let r = Math.min(e +
|
|
2606
|
+
let r = Math.min(e + gn.MAX_CHUNK_BYTES, t.byteLength);
|
|
2576
2607
|
if ((r - e) % 2 == 1 && --r, r <= e) break;
|
|
2577
2608
|
let i = t.subarray(e, r);
|
|
2578
2609
|
e = r, i.byteLength !== 0 && await n.write(i);
|
|
@@ -2596,10 +2627,10 @@ async function Fn(e) {
|
|
|
2596
2627
|
}
|
|
2597
2628
|
//#endregion
|
|
2598
2629
|
//#region src/v2/speech/speechController.ts
|
|
2599
|
-
async function
|
|
2600
|
-
if (
|
|
2601
|
-
if (
|
|
2602
|
-
let t =
|
|
2630
|
+
async function Ln(e, t) {
|
|
2631
|
+
if (pn(e)) throw new Q("MediaStreamTrack play is handled on the host before embed.");
|
|
2632
|
+
if (dn(e)) {
|
|
2633
|
+
let t = Tn(e.data);
|
|
2603
2634
|
if (t.byteLength & 1) throw new Q("PCM byte length must be even.");
|
|
2604
2635
|
return {
|
|
2605
2636
|
kind: "pcm",
|
|
@@ -2607,17 +2638,17 @@ async function In(e, t) {
|
|
|
2607
2638
|
format: e.format
|
|
2608
2639
|
};
|
|
2609
2640
|
}
|
|
2610
|
-
if (
|
|
2641
|
+
if (fn(e)) return {
|
|
2611
2642
|
kind: "url",
|
|
2612
2643
|
url: e.url.trim(),
|
|
2613
2644
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
2614
2645
|
};
|
|
2615
|
-
if (!
|
|
2646
|
+
if (!mn(e)) throw new Q("Unsupported speech.play audio shape.");
|
|
2616
2647
|
let n;
|
|
2617
2648
|
if (typeof Blob < "u" && e.data instanceof Blob) {
|
|
2618
2649
|
if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2619
2650
|
n = new Uint8Array(await e.data.arrayBuffer());
|
|
2620
|
-
} else n =
|
|
2651
|
+
} else n = Tn(e.data);
|
|
2621
2652
|
return {
|
|
2622
2653
|
kind: "encoded",
|
|
2623
2654
|
data: n.slice().buffer,
|
|
@@ -2625,10 +2656,10 @@ async function In(e, t) {
|
|
|
2625
2656
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
2626
2657
|
};
|
|
2627
2658
|
}
|
|
2628
|
-
function
|
|
2659
|
+
function Rn() {
|
|
2629
2660
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? `utt_${crypto.randomUUID().replace(/-/g, "").slice(0, 12)}` : `utt_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
|
|
2630
2661
|
}
|
|
2631
|
-
function
|
|
2662
|
+
function zn(e, t = "completed") {
|
|
2632
2663
|
return {
|
|
2633
2664
|
utteranceId: e.speechId,
|
|
2634
2665
|
characterId: e.characterId,
|
|
@@ -2642,13 +2673,13 @@ function Rn(e, t = "completed") {
|
|
|
2642
2673
|
}
|
|
2643
2674
|
};
|
|
2644
2675
|
}
|
|
2645
|
-
function
|
|
2676
|
+
function Bn(e) {
|
|
2646
2677
|
return e instanceof Error ? e : new Q(String(e));
|
|
2647
2678
|
}
|
|
2648
|
-
function
|
|
2679
|
+
function Vn(e) {
|
|
2649
2680
|
return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
|
|
2650
2681
|
}
|
|
2651
|
-
var
|
|
2682
|
+
var Hn = class {
|
|
2652
2683
|
id;
|
|
2653
2684
|
characterId;
|
|
2654
2685
|
result;
|
|
@@ -2677,29 +2708,29 @@ var Vn = class {
|
|
|
2677
2708
|
queue: e.queue,
|
|
2678
2709
|
...e.transcript === void 0 ? {} : { transcript: e.transcript }
|
|
2679
2710
|
}).catch((e) => {
|
|
2680
|
-
throw this.fail(
|
|
2711
|
+
throw this.fail(Bn(e)), Bn(e);
|
|
2681
2712
|
}), this.signal?.addEventListener("abort", () => {
|
|
2682
2713
|
this.cancel();
|
|
2683
2714
|
}, { once: !0 });
|
|
2684
2715
|
}
|
|
2685
2716
|
async write(e, t) {
|
|
2686
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2687
|
-
let n =
|
|
2717
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new vn();
|
|
2718
|
+
let n = Tn(e);
|
|
2688
2719
|
if (n.byteLength & 1) throw new Q("PCM chunk byte length must be even (complete s16 samples).");
|
|
2689
|
-
if (n.byteLength >
|
|
2720
|
+
if (n.byteLength > gn.MAX_CHUNK_BYTES) throw new Q(`PCM chunk exceeds MAX_CHUNK_BYTES (${gn.MAX_CHUNK_BYTES}).`);
|
|
2690
2721
|
if (n.byteLength === 0) return;
|
|
2691
|
-
let r = t?.timeoutMs ??
|
|
2722
|
+
let r = t?.timeoutMs ?? gn.DEFAULT_WRITE_TIMEOUT_MS;
|
|
2692
2723
|
await this.acquireWriteSlot(r);
|
|
2693
2724
|
let i = n.byteLength / 2 / this.sampleRate * 1e3;
|
|
2694
|
-
if (this.bufferedMs + i >
|
|
2725
|
+
if (this.bufferedMs + i > gn.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new Q("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
|
|
2695
2726
|
let a = async () => {
|
|
2696
|
-
if (this.closed || this.settled) throw new
|
|
2727
|
+
if (this.closed || this.settled) throw new vn();
|
|
2697
2728
|
let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
|
|
2698
2729
|
utteranceId: this.id,
|
|
2699
2730
|
audio: t.buffer,
|
|
2700
2731
|
byteLength: t.byteLength
|
|
2701
2732
|
}), a = await Promise.race([i, new Promise((e, t) => {
|
|
2702
|
-
setTimeout(() => t(new
|
|
2733
|
+
setTimeout(() => t(new yn()), r);
|
|
2703
2734
|
})]);
|
|
2704
2735
|
this.bufferedMs = Math.max(0, a.bufferedMs);
|
|
2705
2736
|
}, o = this.writeChain.then(a, a);
|
|
@@ -2711,7 +2742,7 @@ var Vn = class {
|
|
|
2711
2742
|
}
|
|
2712
2743
|
}
|
|
2713
2744
|
async setTranscript(e) {
|
|
2714
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2745
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new vn();
|
|
2715
2746
|
await this.requireHost().speechUtteranceSetTranscript({
|
|
2716
2747
|
utteranceId: this.id,
|
|
2717
2748
|
transcript: e
|
|
@@ -2728,7 +2759,7 @@ var Vn = class {
|
|
|
2728
2759
|
});
|
|
2729
2760
|
return this.resolve(t), t;
|
|
2730
2761
|
} catch (e) {
|
|
2731
|
-
let t =
|
|
2762
|
+
let t = Bn(e);
|
|
2732
2763
|
throw this.fail(t), t;
|
|
2733
2764
|
}
|
|
2734
2765
|
}
|
|
@@ -2746,11 +2777,11 @@ var Vn = class {
|
|
|
2746
2777
|
characterId: this.characterId,
|
|
2747
2778
|
status: "cancelled",
|
|
2748
2779
|
durationMs: 0,
|
|
2749
|
-
animation:
|
|
2780
|
+
animation: bn("none")
|
|
2750
2781
|
};
|
|
2751
2782
|
return this.resolve(t), t;
|
|
2752
2783
|
} catch (e) {
|
|
2753
|
-
let t =
|
|
2784
|
+
let t = Bn(e);
|
|
2754
2785
|
throw this.fail(t), t;
|
|
2755
2786
|
}
|
|
2756
2787
|
}
|
|
@@ -2763,19 +2794,19 @@ var Vn = class {
|
|
|
2763
2794
|
return e;
|
|
2764
2795
|
}
|
|
2765
2796
|
resolve(e) {
|
|
2766
|
-
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new
|
|
2797
|
+
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new vn()));
|
|
2767
2798
|
}
|
|
2768
2799
|
fail(e) {
|
|
2769
2800
|
this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
|
|
2770
2801
|
}
|
|
2771
2802
|
async acquireWriteSlot(e) {
|
|
2772
|
-
if (this.pendingWriteCount <
|
|
2803
|
+
if (this.pendingWriteCount < gn.MAX_PENDING_WRITES) {
|
|
2773
2804
|
this.pendingWriteCount += 1;
|
|
2774
2805
|
return;
|
|
2775
2806
|
}
|
|
2776
2807
|
await new Promise((t, n) => {
|
|
2777
2808
|
let r = setTimeout(() => {
|
|
2778
|
-
n(new
|
|
2809
|
+
n(new yn());
|
|
2779
2810
|
}, e);
|
|
2780
2811
|
this.pendingWriteWaiters.push({
|
|
2781
2812
|
resolve: () => {
|
|
@@ -2794,13 +2825,13 @@ var Vn = class {
|
|
|
2794
2825
|
for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
|
|
2795
2826
|
}
|
|
2796
2827
|
};
|
|
2797
|
-
function
|
|
2828
|
+
function Un(e) {
|
|
2798
2829
|
let t = null, n = (t, n) => {
|
|
2799
|
-
if (!e.getCapabilities()[n]) throw new
|
|
2830
|
+
if (!e.getCapabilities()[n]) throw new _n(t, n);
|
|
2800
2831
|
}, r = {
|
|
2801
2832
|
async speak(r) {
|
|
2802
2833
|
if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
|
|
2803
|
-
let i =
|
|
2834
|
+
let i = En(r.queue ?? "append");
|
|
2804
2835
|
i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
|
|
2805
2836
|
let a = e.getIframeHost();
|
|
2806
2837
|
if (!a) throw new Q("Speech session is not attached.");
|
|
@@ -2820,41 +2851,41 @@ function Hn(e) {
|
|
|
2820
2851
|
return;
|
|
2821
2852
|
}
|
|
2822
2853
|
t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
|
|
2823
|
-
t.removeEventListener("abort", s), n(
|
|
2854
|
+
t.removeEventListener("abort", s), n(zn(e, "completed"));
|
|
2824
2855
|
}, (a) => {
|
|
2825
|
-
if (t.removeEventListener("abort", s),
|
|
2856
|
+
if (t.removeEventListener("abort", s), Vn(a)) {
|
|
2826
2857
|
n({
|
|
2827
2858
|
utteranceId: "utt_interrupted",
|
|
2828
2859
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2829
2860
|
status: "interrupted",
|
|
2830
2861
|
durationMs: 0,
|
|
2831
2862
|
transcript: r.text,
|
|
2832
|
-
animation:
|
|
2863
|
+
animation: bn("none")
|
|
2833
2864
|
});
|
|
2834
2865
|
return;
|
|
2835
2866
|
}
|
|
2836
|
-
i(
|
|
2867
|
+
i(Bn(a));
|
|
2837
2868
|
});
|
|
2838
2869
|
});
|
|
2839
2870
|
}
|
|
2840
2871
|
try {
|
|
2841
|
-
return
|
|
2872
|
+
return zn(await o, "completed");
|
|
2842
2873
|
} catch (t) {
|
|
2843
|
-
if (
|
|
2874
|
+
if (Vn(t)) return {
|
|
2844
2875
|
utteranceId: "utt_interrupted",
|
|
2845
2876
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2846
2877
|
status: "interrupted",
|
|
2847
2878
|
durationMs: 0,
|
|
2848
2879
|
transcript: r.text,
|
|
2849
|
-
animation:
|
|
2880
|
+
animation: bn("none")
|
|
2850
2881
|
};
|
|
2851
|
-
throw
|
|
2882
|
+
throw Bn(t);
|
|
2852
2883
|
}
|
|
2853
2884
|
},
|
|
2854
2885
|
async play(i) {
|
|
2855
|
-
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"),
|
|
2886
|
+
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), Cn(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2856
2887
|
let a = i.queue ?? "append";
|
|
2857
|
-
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)),
|
|
2888
|
+
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), pn(i.audio)) {
|
|
2858
2889
|
let e = i.audio.sampleRate ?? 24e3;
|
|
2859
2890
|
return r.createUtterance({
|
|
2860
2891
|
format: {
|
|
@@ -2870,7 +2901,7 @@ function Hn(e) {
|
|
|
2870
2901
|
}
|
|
2871
2902
|
let o = e.getIframeHost();
|
|
2872
2903
|
if (!o) throw new Q("Speech session is not attached.");
|
|
2873
|
-
let s = await
|
|
2904
|
+
let s = await Ln(i.audio, i.signal);
|
|
2874
2905
|
return o.speechPlay({
|
|
2875
2906
|
source: s,
|
|
2876
2907
|
characterId: i.characterId,
|
|
@@ -2882,13 +2913,13 @@ function Hn(e) {
|
|
|
2882
2913
|
},
|
|
2883
2914
|
createUtterance(r) {
|
|
2884
2915
|
e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
|
|
2885
|
-
let i =
|
|
2916
|
+
let i = wn(r);
|
|
2886
2917
|
if (r.track && r.track.kind !== "audio") throw new Q("createUtterance track must be an audio MediaStreamTrack.");
|
|
2887
2918
|
let a = r.queue ?? "replace-active";
|
|
2888
2919
|
if (a !== "replace-active" && a !== "replace-all") throw new Q("createUtterance queue must be replace-active or replace-all.");
|
|
2889
2920
|
e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
|
|
2890
|
-
let o = new
|
|
2891
|
-
id:
|
|
2921
|
+
let o = new Hn({
|
|
2922
|
+
id: Rn(),
|
|
2892
2923
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2893
2924
|
format: i,
|
|
2894
2925
|
queue: a,
|
|
@@ -2900,7 +2931,7 @@ function Hn(e) {
|
|
|
2900
2931
|
t === o && (t = null);
|
|
2901
2932
|
}), r.track && (async () => {
|
|
2902
2933
|
try {
|
|
2903
|
-
if (await
|
|
2934
|
+
if (await In({
|
|
2904
2935
|
track: r.track,
|
|
2905
2936
|
utterance: o,
|
|
2906
2937
|
sampleRate: i.sampleRate,
|
|
@@ -2928,16 +2959,16 @@ function Hn(e) {
|
|
|
2928
2959
|
}
|
|
2929
2960
|
//#endregion
|
|
2930
2961
|
//#region src/v2/types/sessionInteraction.ts
|
|
2931
|
-
function
|
|
2962
|
+
function Wn(e) {
|
|
2932
2963
|
let t = e?.trim();
|
|
2933
2964
|
return t === "full" || t === "face" || t === "medium" ? t : void 0;
|
|
2934
2965
|
}
|
|
2935
2966
|
//#endregion
|
|
2936
2967
|
//#region src/v2/experience.ts
|
|
2937
|
-
function
|
|
2968
|
+
function Gn(e) {
|
|
2938
2969
|
return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
|
|
2939
2970
|
}
|
|
2940
|
-
var
|
|
2971
|
+
var Kn = class e {
|
|
2941
2972
|
bootstrap;
|
|
2942
2973
|
conversationProcessor;
|
|
2943
2974
|
iframeHost = null;
|
|
@@ -2954,19 +2985,20 @@ var Gn = class e {
|
|
|
2954
2985
|
pendingStage = null;
|
|
2955
2986
|
pendingPipBackground = null;
|
|
2956
2987
|
pendingPipShadow = null;
|
|
2988
|
+
pendingTheatre = null;
|
|
2957
2989
|
lastInteraction = null;
|
|
2958
2990
|
closeHandlers = [];
|
|
2959
|
-
eventRegistry =
|
|
2991
|
+
eventRegistry = sn();
|
|
2960
2992
|
readyEnvelope = null;
|
|
2961
2993
|
startedEnvelope = null;
|
|
2962
2994
|
sessionMintedEnvelope = null;
|
|
2963
2995
|
conversationCache = [];
|
|
2964
2996
|
speech;
|
|
2965
2997
|
constructor(e) {
|
|
2966
|
-
this.bootstrap = e, this.conversationProcessor = e.conversationProcessor ?? null, this.resolvedSession = e.kind === "launch" ? e.session ?? null : null, this.launchToken = e.kind === "launch" ? e.launch : null, this.speech =
|
|
2998
|
+
this.bootstrap = e, this.conversationProcessor = e.conversationProcessor ?? null, this.resolvedSession = e.kind === "launch" ? e.session ?? null : null, this.launchToken = e.kind === "launch" ? e.launch : null, this.speech = Un({
|
|
2967
2999
|
getIframeHost: () => this.iframeHost,
|
|
2968
3000
|
assertSessionStarted: () => this.assertSessionStarted(),
|
|
2969
|
-
getCapabilities: () =>
|
|
3001
|
+
getCapabilities: () => qn(this.resolvedSession),
|
|
2970
3002
|
getActiveCharacterId: () => "character_unknown",
|
|
2971
3003
|
onProcessorInterrupt: () => {
|
|
2972
3004
|
this.processorAbortController?.abort(), this.processorAbortController = null;
|
|
@@ -3049,7 +3081,7 @@ var Gn = class e {
|
|
|
3049
3081
|
return null;
|
|
3050
3082
|
}
|
|
3051
3083
|
on(e, t) {
|
|
3052
|
-
let n =
|
|
3084
|
+
let n = cn(this.eventRegistry, e, t);
|
|
3053
3085
|
return e === "ready" && this.readyEnvelope && queueMicrotask(() => t(this.readyEnvelope)), e === "started" && this.startedEnvelope && queueMicrotask(() => t(this.startedEnvelope)), e === "sessionMinted" && this.sessionMintedEnvelope && queueMicrotask(() => t(this.sessionMintedEnvelope)), n;
|
|
3054
3086
|
}
|
|
3055
3087
|
async attach(e) {
|
|
@@ -3063,13 +3095,13 @@ var Gn = class e {
|
|
|
3063
3095
|
if (this.closed) throw Error("Session has ended.");
|
|
3064
3096
|
if (this.attached && this.iframeHost) return this.createPlayerFacade();
|
|
3065
3097
|
this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
|
|
3066
|
-
let t = this.bootstrap.embedBaseUrl ??
|
|
3098
|
+
let t = this.bootstrap.embedBaseUrl ?? $t(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = tn(t, n, r ? void 0 : en(this.bootstrap.backdropId, this.bootstrap.locationId), r ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, Gn(e), this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.castSize, e.stage, e.pipBackground, e.pipShadow), a = rn(i), o = null, s = new Promise((e) => {
|
|
3067
3099
|
o = e;
|
|
3068
3100
|
}), c = null, l = new Promise((e) => {
|
|
3069
3101
|
c = e;
|
|
3070
|
-
}), u =
|
|
3102
|
+
}), u = Jt((e) => {
|
|
3071
3103
|
this.readyEnvelope ||= (this.resolvedSession = e, this.emitWrapped("ready", { session: e }));
|
|
3072
|
-
}), d = this.bootstrap.onUserTranscript, f =
|
|
3104
|
+
}), d = this.bootstrap.onUserTranscript, f = qt({
|
|
3073
3105
|
container: e.container,
|
|
3074
3106
|
src: i,
|
|
3075
3107
|
playerOrigin: a,
|
|
@@ -3132,7 +3164,8 @@ var Gn = class e {
|
|
|
3132
3164
|
onWidgetAudioSettings: (t) => e.onWidgetAudioSettings?.(t),
|
|
3133
3165
|
onWidgetDragStart: (t) => e.onWidgetDragStart?.(t),
|
|
3134
3166
|
onWidgetDragMove: (t) => e.onWidgetDragMove?.(t),
|
|
3135
|
-
onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t)
|
|
3167
|
+
onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t),
|
|
3168
|
+
onTheatreChange: (t) => e.onTheatreChange?.(t)
|
|
3136
3169
|
});
|
|
3137
3170
|
this.iframeHost = f;
|
|
3138
3171
|
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), wt(this.bootstrap.sessionEndpoint, {
|
|
@@ -3171,7 +3204,7 @@ var Gn = class e {
|
|
|
3171
3204
|
operation: "attach",
|
|
3172
3205
|
message: e instanceof Error ? e.message : String(e),
|
|
3173
3206
|
stack: e instanceof Error ? e.stack : void 0,
|
|
3174
|
-
release:
|
|
3207
|
+
release: Yt
|
|
3175
3208
|
});
|
|
3176
3209
|
} catch {}
|
|
3177
3210
|
throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), e;
|
|
@@ -3187,12 +3220,16 @@ var Gn = class e {
|
|
|
3187
3220
|
startButton: e.startButton,
|
|
3188
3221
|
theme: e.theme,
|
|
3189
3222
|
showFeedback: e.showFeedback,
|
|
3190
|
-
interaction: e.interaction
|
|
3223
|
+
interaction: e.interaction,
|
|
3224
|
+
...e.theatreButton ? { theatreButton: !0 } : {},
|
|
3225
|
+
...e.theatre === void 0 ? {} : { theatre: e.theatre }
|
|
3191
3226
|
}), u.setValue(_)) : f.postLaunch(g, void 0, {
|
|
3192
3227
|
startButton: e.startButton,
|
|
3193
3228
|
theme: e.theme,
|
|
3194
3229
|
showFeedback: e.showFeedback,
|
|
3195
|
-
interaction: e.interaction
|
|
3230
|
+
interaction: e.interaction,
|
|
3231
|
+
...e.theatreButton ? { theatreButton: !0 } : {},
|
|
3232
|
+
...e.theatre === void 0 ? {} : { theatre: e.theatre }
|
|
3196
3233
|
}), await Promise.race([s, new Promise((e, t) => {
|
|
3197
3234
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player loading UI.")), 12e4);
|
|
3198
3235
|
})]).catch((e) => {
|
|
@@ -3203,7 +3240,7 @@ var Gn = class e {
|
|
|
3203
3240
|
operation: "attach",
|
|
3204
3241
|
message: e instanceof Error ? e.message : String(e),
|
|
3205
3242
|
stack: e instanceof Error ? e.stack : void 0,
|
|
3206
|
-
release:
|
|
3243
|
+
release: Yt
|
|
3207
3244
|
});
|
|
3208
3245
|
} catch {}
|
|
3209
3246
|
throw e;
|
|
@@ -3217,11 +3254,11 @@ var Gn = class e {
|
|
|
3217
3254
|
operation: "attach",
|
|
3218
3255
|
message: e instanceof Error ? e.message : String(e),
|
|
3219
3256
|
stack: e instanceof Error ? e.stack : void 0,
|
|
3220
|
-
release:
|
|
3257
|
+
release: Yt
|
|
3221
3258
|
});
|
|
3222
3259
|
} catch {}
|
|
3223
3260
|
throw e;
|
|
3224
|
-
}), this.attached = !0, this.pendingFit && await f.setFit(this.pendingFit), this.pendingStage && await f.setStage(this.pendingStage), this.pendingPipBackground && await f.setPipBackground(this.pendingPipBackground), this.pendingPipShadow !== null && await f.setPipShadow(this.pendingPipShadow), this.createPlayerFacade();
|
|
3261
|
+
}), this.attached = !0, this.pendingFit && await f.setFit(this.pendingFit), this.pendingStage && await f.setStage(this.pendingStage), this.pendingPipBackground && await f.setPipBackground(this.pendingPipBackground), this.pendingPipShadow !== null && await f.setPipShadow(this.pendingPipShadow), this.pendingTheatre !== null && f.postSetTheatre(this.pendingTheatre), this.createPlayerFacade();
|
|
3225
3262
|
}
|
|
3226
3263
|
async startListening() {
|
|
3227
3264
|
this.assertSessionStarted(), await this.iframeHost.startListening();
|
|
@@ -3235,6 +3272,10 @@ var Gn = class e {
|
|
|
3235
3272
|
getConversation() {
|
|
3236
3273
|
return this.conversationCache;
|
|
3237
3274
|
}
|
|
3275
|
+
setTheatre(e) {
|
|
3276
|
+
if (this.closed) throw Error("Session has ended.");
|
|
3277
|
+
this.pendingTheatre = e, this.iframeHost?.postSetTheatre(e);
|
|
3278
|
+
}
|
|
3238
3279
|
setWidgetChrome(e) {
|
|
3239
3280
|
this.iframeHost?.postWidgetSetChrome(e);
|
|
3240
3281
|
}
|
|
@@ -3245,7 +3286,7 @@ var Gn = class e {
|
|
|
3245
3286
|
this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
|
|
3246
3287
|
}
|
|
3247
3288
|
async setFit(e) {
|
|
3248
|
-
let t =
|
|
3289
|
+
let t = Wn(e);
|
|
3249
3290
|
if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
|
|
3250
3291
|
if (this.closed) throw Error("Session has ended.");
|
|
3251
3292
|
this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
|
|
@@ -3295,7 +3336,7 @@ var Gn = class e {
|
|
|
3295
3336
|
this.close();
|
|
3296
3337
|
}
|
|
3297
3338
|
destroy() {
|
|
3298
|
-
this.closed || (this.closed = !0, this.processorAbortController?.abort(), this.processorAbortController = null, this.endpointAbortController?.abort(), this.endpointAbortController = null, this.attachInFlight = null, this.iframeHost?.destroy(), this.iframeHost = null,
|
|
3339
|
+
this.closed || (this.closed = !0, this.processorAbortController?.abort(), this.processorAbortController = null, this.endpointAbortController?.abort(), this.endpointAbortController = null, this.attachInFlight = null, this.iframeHost?.destroy(), this.iframeHost = null, un(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.lastInteraction = null, this.attached = !1);
|
|
3299
3340
|
}
|
|
3300
3341
|
resolveMintInteraction() {
|
|
3301
3342
|
return this.bootstrap.kind === "launch" ? {} : {
|
|
@@ -3307,8 +3348,8 @@ var Gn = class e {
|
|
|
3307
3348
|
return this.resolvedSession?.id ?? "";
|
|
3308
3349
|
}
|
|
3309
3350
|
emitWrapped(e, t) {
|
|
3310
|
-
let n =
|
|
3311
|
-
return
|
|
3351
|
+
let n = on(e, this.getSessionId(), t);
|
|
3352
|
+
return ln(this.eventRegistry, e, n), n;
|
|
3312
3353
|
}
|
|
3313
3354
|
queueProcessorTurn(e) {
|
|
3314
3355
|
if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
|
|
@@ -3367,7 +3408,7 @@ var Gn = class e {
|
|
|
3367
3408
|
};
|
|
3368
3409
|
}
|
|
3369
3410
|
};
|
|
3370
|
-
function
|
|
3411
|
+
function qn(e) {
|
|
3371
3412
|
return e ? {
|
|
3372
3413
|
textSpeech: e.capabilities.speech.output,
|
|
3373
3414
|
externalSpeechAudio: e.capabilities.speech.externalAudio
|
|
@@ -3378,41 +3419,41 @@ function Kn(e) {
|
|
|
3378
3419
|
}
|
|
3379
3420
|
//#endregion
|
|
3380
3421
|
//#region src/widget/dockGeometry.ts
|
|
3381
|
-
var
|
|
3382
|
-
function
|
|
3422
|
+
var Jn = "(min-width: 768px)", Yn = 24, Xn = .5, Zn = 1200, Qn = .85, $n = 9 / 16;
|
|
3423
|
+
function er() {
|
|
3383
3424
|
if (typeof window > "u") return 800;
|
|
3384
3425
|
let e = window.screen?.availHeight;
|
|
3385
3426
|
return typeof e == "number" && e > 0 ? e : window.innerHeight;
|
|
3386
3427
|
}
|
|
3387
|
-
function
|
|
3388
|
-
let i = Math.max(160, Math.min(t - n * 2, t *
|
|
3389
|
-
return s > a && (s = a, o = s /
|
|
3428
|
+
function tr(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = Yn, r = typeof window < "u" ? er() : 800) {
|
|
3429
|
+
let i = Math.max(160, Math.min(t - n * 2, t * Qn)), a = Math.max(120, e - n * 2), o = Math.min(r * Xn, Zn, i), s = o * $n;
|
|
3430
|
+
return s > a && (s = a, o = s / $n, o > i && (o = i, s = o * $n)), {
|
|
3390
3431
|
width: Math.round(s),
|
|
3391
3432
|
height: Math.round(o)
|
|
3392
3433
|
};
|
|
3393
3434
|
}
|
|
3394
|
-
function
|
|
3435
|
+
function nr(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = Yn) {
|
|
3395
3436
|
return {
|
|
3396
3437
|
left: Math.max(r, t - e.width - r),
|
|
3397
3438
|
top: Math.max(r, n - e.height - r)
|
|
3398
3439
|
};
|
|
3399
3440
|
}
|
|
3400
|
-
function
|
|
3441
|
+
function rr(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = Yn) {
|
|
3401
3442
|
let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
|
|
3402
3443
|
return {
|
|
3403
3444
|
left: Math.min(Math.max(a, e), o),
|
|
3404
3445
|
top: Math.min(Math.max(a, t), s)
|
|
3405
3446
|
};
|
|
3406
3447
|
}
|
|
3407
|
-
function
|
|
3408
|
-
return e(
|
|
3448
|
+
function ir(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
|
|
3449
|
+
return e(Jn).matches;
|
|
3409
3450
|
}
|
|
3410
3451
|
//#endregion
|
|
3411
3452
|
//#region src/widget/mountExperienceWidget.ts
|
|
3412
|
-
function
|
|
3453
|
+
function ar(e) {
|
|
3413
3454
|
return e === "bottom-right" || e === "bottom-left" ? e : "static";
|
|
3414
3455
|
}
|
|
3415
|
-
function
|
|
3456
|
+
function or(e) {
|
|
3416
3457
|
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
3417
3458
|
let t = typeof e == "string" ? e.trim() : "";
|
|
3418
3459
|
return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
|
|
@@ -3420,10 +3461,10 @@ function ar(e) {
|
|
|
3420
3461
|
function $(e) {
|
|
3421
3462
|
return e === "expanded" || e === "docked";
|
|
3422
3463
|
}
|
|
3423
|
-
var
|
|
3424
|
-
function
|
|
3464
|
+
var sr = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 0 0-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 0 0-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 0 0-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 0 0-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 0 0 1.066-2.573c-.94-1.543.826-3.31 2.37-2.37c1 .608 2.296.07 2.572-1.065\"/><path d=\"M9 12a3 3 0 1 0 6 0a3 3 0 0 0-6 0\"/></svg>", cr = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\"><path fill=\"currentColor\" d=\"M18.3 5.71a1 1 0 0 0-1.41 0L12 10.59 7.11 5.7A1 1 0 0 0 5.7 7.11L10.59 12l-4.9 4.89a1 1 0 1 0 1.42 1.42L12 13.41l4.89 4.9a1 1 0 0 0 1.42-1.42L13.41 12l4.9-4.89a1 1 0 0 0-.01-1.4Z\"/></svg>", lr = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M18 10h-4V6m6-2l-6 6m-8 4h4v4m0-4l-6 6\"/></svg>", ur = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M16 4h4v4m-6 2l6-6M8 20H4v-4m0 4l6-6\"/></svg>";
|
|
3465
|
+
function dr(e, t, n) {
|
|
3425
3466
|
Ve(ze);
|
|
3426
|
-
let r =
|
|
3467
|
+
let r = fe({
|
|
3427
3468
|
galleryThumb: t.galleryThumb,
|
|
3428
3469
|
avatarImage: t.avatarImage,
|
|
3429
3470
|
backgroundImage: t.backgroundImage,
|
|
@@ -3451,7 +3492,7 @@ function ur(e, t, n) {
|
|
|
3451
3492
|
}
|
|
3452
3493
|
return e.replaceChildren(i), n?.parallax === !1 ? () => {} : Re(i);
|
|
3453
3494
|
}
|
|
3454
|
-
function
|
|
3495
|
+
function fr(e) {
|
|
3455
3496
|
return e.startButton ? {
|
|
3456
3497
|
...e.startButton,
|
|
3457
3498
|
label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
|
|
@@ -3463,7 +3504,7 @@ function dr(e) {
|
|
|
3463
3504
|
variant: "primary"
|
|
3464
3505
|
};
|
|
3465
3506
|
}
|
|
3466
|
-
function
|
|
3507
|
+
function pr(e) {
|
|
3467
3508
|
let t = !1, n = () => {
|
|
3468
3509
|
t || e();
|
|
3469
3510
|
}, r = () => {
|
|
@@ -3483,12 +3524,12 @@ function fr(e) {
|
|
|
3483
3524
|
t = !0, window.removeEventListener("load", r), i?.();
|
|
3484
3525
|
};
|
|
3485
3526
|
}
|
|
3486
|
-
function
|
|
3527
|
+
function mr(e, t) {
|
|
3487
3528
|
Ke(We);
|
|
3488
3529
|
let n = t.experienceId?.trim();
|
|
3489
3530
|
if (!n) throw Error("ExperienceWidget requires experienceId.");
|
|
3490
|
-
let r = t.prefetch ?? "onExpand", i =
|
|
3491
|
-
a.className = "liforma-ew", a.dataset.state = "collapsed", a.dataset.prefetch = r, a.dataset.position = i, a.style.setProperty("--liforma-ew-max-w", t.expandedMaxWidth ?? "100%"), a.style.setProperty("--liforma-ew-max-h", t.expandedMaxHeight ?? "100%"), i !== "static" && a.style.setProperty("--liforma-ew-offset",
|
|
3531
|
+
let r = t.prefetch ?? "onExpand", i = ar(t.position), a = document.createElement("div");
|
|
3532
|
+
a.className = "liforma-ew", a.dataset.state = "collapsed", a.dataset.prefetch = r, a.dataset.position = i, a.style.setProperty("--liforma-ew-max-w", t.expandedMaxWidth ?? "100%"), a.style.setProperty("--liforma-ew-max-h", t.expandedMaxHeight ?? "100%"), i !== "static" && a.style.setProperty("--liforma-ew-offset", or(t.offset));
|
|
3492
3533
|
let o = document.createElement("button");
|
|
3493
3534
|
o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
|
|
3494
3535
|
let s = document.createElement("div");
|
|
@@ -3508,11 +3549,11 @@ function pr(e, t) {
|
|
|
3508
3549
|
let m = document.createElement("span");
|
|
3509
3550
|
m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
|
|
3510
3551
|
let h = document.createElement("button");
|
|
3511
|
-
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML =
|
|
3552
|
+
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = lr, h.setAttribute("aria-label", "Reduce");
|
|
3512
3553
|
let g = document.createElement("button");
|
|
3513
|
-
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML =
|
|
3554
|
+
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = sr, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
|
|
3514
3555
|
let _ = document.createElement("button");
|
|
3515
|
-
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML =
|
|
3556
|
+
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = cr, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
|
|
3516
3557
|
let v = document.createElement("div");
|
|
3517
3558
|
v.className = "liforma-ew__stage";
|
|
3518
3559
|
let y = document.createElement("div");
|
|
@@ -3531,58 +3572,58 @@ function pr(e, t) {
|
|
|
3531
3572
|
p
|
|
3532
3573
|
]) e.style.removeProperty("left"), e.style.removeProperty("top"), e.style.removeProperty("width"), e.style.removeProperty("height"), e.style.removeProperty("right"), e.style.removeProperty("bottom");
|
|
3533
3574
|
p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging");
|
|
3534
|
-
},
|
|
3575
|
+
}, oe = (e, t, n, r) => {
|
|
3535
3576
|
let i = (i) => {
|
|
3536
3577
|
i.style.left = `${e}px`, i.style.top = `${t}px`, i.style.width = `${n}px`, i.style.height = `${r}px`, i.style.right = "auto", i.style.bottom = "auto";
|
|
3537
3578
|
};
|
|
3538
3579
|
i(f), i(l);
|
|
3539
3580
|
let a = p.offsetWidth || 120;
|
|
3540
3581
|
p.style.left = `${e + n - a - 10}px`, p.style.top = `${t + 10}px`, p.style.right = "auto", p.style.bottom = "auto", p.style.width = "auto", p.style.height = "auto";
|
|
3541
|
-
},
|
|
3582
|
+
}, se = (e, t) => {
|
|
3542
3583
|
if (R() !== "docked") return;
|
|
3543
|
-
let n =
|
|
3544
|
-
N = r.left, P = r.top,
|
|
3545
|
-
},
|
|
3584
|
+
let n = tr(), r = rr(e - te, t - I, n);
|
|
3585
|
+
N = r.left, P = r.top, oe(r.left, r.top, n.width, n.height);
|
|
3586
|
+
}, ce = (e, t) => {
|
|
3546
3587
|
if (R() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
|
|
3547
|
-
let n =
|
|
3548
|
-
N = a.left, P = a.top,
|
|
3549
|
-
},
|
|
3550
|
-
L === "toolbar" && (F === null || e.pointerId !== F || (e.preventDefault(),
|
|
3551
|
-
},
|
|
3588
|
+
let n = tr(), r = N ?? f.getBoundingClientRect().left, i = P ?? f.getBoundingClientRect().top, a = rr(r + e, i + t, n);
|
|
3589
|
+
N = a.left, P = a.top, oe(a.left, a.top, n.width, n.height);
|
|
3590
|
+
}, V = (e) => {
|
|
3591
|
+
L === "toolbar" && (F === null || e.pointerId !== F || (e.preventDefault(), se(e.clientX, e.clientY)));
|
|
3592
|
+
}, H = (e) => {
|
|
3552
3593
|
if (F === null || e && e.pointerId !== F) return;
|
|
3553
3594
|
let t = L;
|
|
3554
|
-
F = null, L = null, p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging"), t === "toolbar" && ne && (ne = !1, window.removeEventListener("pointermove",
|
|
3555
|
-
},
|
|
3556
|
-
if (S || R() !== "docked" || !
|
|
3595
|
+
F = null, L = null, p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging"), t === "toolbar" && ne && (ne = !1, window.removeEventListener("pointermove", V), window.removeEventListener("pointerup", H), window.removeEventListener("pointercancel", H));
|
|
3596
|
+
}, le = (e, t, n) => {
|
|
3597
|
+
if (S || R() !== "docked" || !ir() || F !== null) return;
|
|
3557
3598
|
F = n, L = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
3558
3599
|
let r = f.getBoundingClientRect();
|
|
3559
|
-
te = e - r.left, I = t - r.top, ne || (ne = !0, window.addEventListener("pointermove",
|
|
3560
|
-
},
|
|
3561
|
-
if (S || R() !== "docked" || !
|
|
3600
|
+
te = e - r.left, I = t - r.top, ne || (ne = !0, window.addEventListener("pointermove", V), window.addEventListener("pointerup", H), window.addEventListener("pointercancel", H));
|
|
3601
|
+
}, ue = (e) => {
|
|
3602
|
+
if (S || R() !== "docked" || !ir() || F !== null) return;
|
|
3562
3603
|
F = e.pointerId, L = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
3563
3604
|
let t = f.getBoundingClientRect();
|
|
3564
3605
|
N = t.left, P = t.top;
|
|
3565
|
-
},
|
|
3566
|
-
L === "player" && (F === null || e.pointerId !== F ||
|
|
3606
|
+
}, U = (e) => {
|
|
3607
|
+
L === "player" && (F === null || e.pointerId !== F || ce(e.dx, e.dy));
|
|
3567
3608
|
}, de = (e) => {
|
|
3568
|
-
L === "player" && (F === null || e.pointerId !== F ||
|
|
3609
|
+
L === "player" && (F === null || e.pointerId !== F || H());
|
|
3569
3610
|
}, W = () => {
|
|
3570
|
-
let e =
|
|
3611
|
+
let e = ir(), t = R();
|
|
3571
3612
|
if (!e || t !== "expanded" && t !== "docked") {
|
|
3572
3613
|
h.hidden = !0;
|
|
3573
3614
|
return;
|
|
3574
3615
|
}
|
|
3575
|
-
h.hidden = !1, t === "docked" ? (h.innerHTML =
|
|
3576
|
-
},
|
|
3577
|
-
let t =
|
|
3578
|
-
n =
|
|
3579
|
-
},
|
|
3616
|
+
h.hidden = !1, t === "docked" ? (h.innerHTML = ur, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = lr, h.setAttribute("aria-label", "Reduce"));
|
|
3617
|
+
}, G = (e) => {
|
|
3618
|
+
let t = tr(), n = e && N !== null && P !== null ? rr(N, P, t) : nr(t);
|
|
3619
|
+
n = rr(n.left, n.top, t), N = n.left, P = n.top, oe(n.left, n.top, t.width, t.height), W();
|
|
3620
|
+
}, fe = () => {
|
|
3580
3621
|
a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
|
|
3581
3622
|
requestAnimationFrame(() => {
|
|
3582
3623
|
S || !$(a.dataset.state) || a.classList.add("liforma-ew--session-revealed");
|
|
3583
3624
|
});
|
|
3584
3625
|
});
|
|
3585
|
-
},
|
|
3626
|
+
}, pe = (e) => {
|
|
3586
3627
|
if (ae(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !D) {
|
|
3587
3628
|
a.classList.remove("liforma-ew--layout-settling");
|
|
3588
3629
|
return;
|
|
@@ -3592,54 +3633,54 @@ function pr(e, t) {
|
|
|
3592
3633
|
a.classList.remove("liforma-ew--layout-settling");
|
|
3593
3634
|
return;
|
|
3594
3635
|
}
|
|
3595
|
-
a.classList.remove("liforma-ew--layout-settling"),
|
|
3636
|
+
a.classList.remove("liforma-ew--layout-settling"), fe();
|
|
3596
3637
|
}, 220);
|
|
3597
|
-
},
|
|
3638
|
+
}, me = () => (a.classList.add("liforma-ew--session-concealing"), a.classList.remove("liforma-ew--session-revealed"), new Promise((e) => {
|
|
3598
3639
|
z(), j = setTimeout(() => {
|
|
3599
3640
|
j = null, a.classList.remove("liforma-ew--session-concealing"), e();
|
|
3600
3641
|
}, 280);
|
|
3601
|
-
})),
|
|
3642
|
+
})), he = {
|
|
3602
3643
|
galleryThumb: t.galleryThumb,
|
|
3603
3644
|
avatarImage: t.avatarImage,
|
|
3604
3645
|
backgroundImage: t.backgroundImage,
|
|
3605
3646
|
foregroundImage: t.foregroundImage,
|
|
3606
3647
|
fallbackImage: t.fallbackImage
|
|
3607
|
-
},
|
|
3648
|
+
}, ge = (e) => {
|
|
3608
3649
|
if (!e) {
|
|
3609
3650
|
y.hidden = !0, y.textContent = "";
|
|
3610
3651
|
return;
|
|
3611
3652
|
}
|
|
3612
3653
|
y.hidden = !1, y.textContent = e;
|
|
3613
|
-
},
|
|
3654
|
+
}, _e = (e) => {
|
|
3614
3655
|
if (!e) {
|
|
3615
3656
|
c.hidden = !0, c.textContent = "";
|
|
3616
3657
|
return;
|
|
3617
3658
|
}
|
|
3618
3659
|
c.hidden = !1, c.textContent = e, s.contains(c) || s.append(c);
|
|
3660
|
+
}, ve = () => {
|
|
3661
|
+
C = !0, o.disabled = !1, _e(null), r === "onExpand" && t.onPrefetchReady?.();
|
|
3619
3662
|
}, ye = () => {
|
|
3620
|
-
C = !0, o.disabled = !1, ve(null), r === "onExpand" && t.onPrefetchReady?.();
|
|
3621
|
-
}, be = () => {
|
|
3622
3663
|
w = !0, a.dataset.warm = "true", l.hidden = !1, D || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
|
|
3623
|
-
},
|
|
3664
|
+
}, be = (e) => {
|
|
3624
3665
|
A?.(), A = null;
|
|
3625
|
-
let t =
|
|
3666
|
+
let t = dr(s, e, { parallax: ie });
|
|
3626
3667
|
return t ? (A = t, !0) : !1;
|
|
3627
|
-
},
|
|
3628
|
-
if (
|
|
3629
|
-
|
|
3668
|
+
}, K = () => {
|
|
3669
|
+
if (be(he)) {
|
|
3670
|
+
ve();
|
|
3630
3671
|
return;
|
|
3631
3672
|
}
|
|
3632
|
-
|
|
3673
|
+
_e("Loading…"), Qe(n, { signal: re.signal }).then((e) => {
|
|
3633
3674
|
if (!S) {
|
|
3634
|
-
if (!
|
|
3635
|
-
|
|
3675
|
+
if (!be({ galleryThumb: e.galleryThumb })) throw Error("Experience preview is missing gallery thumb images.");
|
|
3676
|
+
ve();
|
|
3636
3677
|
}
|
|
3637
3678
|
}).catch((e) => {
|
|
3638
3679
|
if (S || re.signal.aborted) return;
|
|
3639
3680
|
let n = e instanceof Error ? e : Error(String(e));
|
|
3640
|
-
|
|
3681
|
+
_e("Preview unavailable"), o.disabled = !0, t.onError?.(n), console.error("[ExperienceWidget]", n);
|
|
3641
3682
|
});
|
|
3642
|
-
},
|
|
3683
|
+
}, xe = () => ({
|
|
3643
3684
|
experienceId: n,
|
|
3644
3685
|
ui: "widget",
|
|
3645
3686
|
...t.sessionEndpoint ? { sessionEndpoint: t.sessionEndpoint } : {},
|
|
@@ -3652,89 +3693,89 @@ function pr(e, t) {
|
|
|
3652
3693
|
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
|
|
3653
3694
|
...t.alreadyConverted?.length ? { alreadyConverted: t.alreadyConverted } : {},
|
|
3654
3695
|
...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
|
|
3655
|
-
}),
|
|
3696
|
+
}), Se = () => ({
|
|
3656
3697
|
...t.fit ? { fit: t.fit } : {},
|
|
3657
|
-
startButton:
|
|
3698
|
+
startButton: fr(t),
|
|
3658
3699
|
...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback },
|
|
3659
3700
|
...t.interaction ? { interaction: t.interaction } : {}
|
|
3660
|
-
}),
|
|
3661
|
-
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), B(), a.dataset.state = "expanded",
|
|
3662
|
-
},
|
|
3663
|
-
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked",
|
|
3664
|
-
},
|
|
3701
|
+
}), Ce = (e = !0) => {
|
|
3702
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), B(), a.dataset.state = "expanded", ge(null), typeof document < "u" && (k = document.body.style.overflow, document.body.style.overflow = "hidden"), W(), e && t.onExpanded?.();
|
|
3703
|
+
}, we = () => {
|
|
3704
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked", ge(null), typeof document < "u" && (document.body.style.overflow = k), G(!0), W(), b?.setWidgetChrome("docked");
|
|
3705
|
+
}, Te = (e) => {
|
|
3665
3706
|
e.on("started", () => {
|
|
3666
|
-
S || (D = !0, a.dataset.live = "true",
|
|
3707
|
+
S || (D = !0, a.dataset.live = "true", ge(null), t.onStarted?.(), $(a.dataset.state) && fe());
|
|
3667
3708
|
}), e.on("feedback", (e) => {
|
|
3668
3709
|
S || t.onFeedback?.(e);
|
|
3669
3710
|
}), e.on("feedbackFailed", (e) => {
|
|
3670
3711
|
S || t.onFeedbackFailed?.(e);
|
|
3671
3712
|
});
|
|
3713
|
+
}, Ee = () => {
|
|
3714
|
+
ae(), u.hidden = !0, p.hidden = !0, B(), a.dataset.state = "collapsed", a.classList.remove("liforma-ew--session-revealed"), a.classList.remove("liforma-ew--session-concealing"), g.setAttribute("aria-pressed", "false"), o.hidden = !1, o.tabIndex = 0, o.removeAttribute("aria-hidden"), C && (o.disabled = !1), ge(null), typeof document < "u" && (document.body.style.overflow = k), W();
|
|
3672
3715
|
}, De = () => {
|
|
3673
|
-
ae(), u.hidden = !0, p.hidden = !0, B(), a.dataset.state = "collapsed", a.classList.remove("liforma-ew--session-revealed"), a.classList.remove("liforma-ew--session-concealing"), g.setAttribute("aria-pressed", "false"), o.hidden = !1, o.tabIndex = 0, o.removeAttribute("aria-hidden"), C && (o.disabled = !1), _e(null), typeof document < "u" && (document.body.style.overflow = k), W();
|
|
3674
|
-
}, Oe = () => {
|
|
3675
3716
|
z(), ae(), O += 1, x = !1, w = !1, T = !1, E = !1, D = !1;
|
|
3676
3717
|
let e = b;
|
|
3677
3718
|
b = null, e?.destroy(), v.replaceChildren(), l.replaceChildren(), l.hidden = !0, delete a.dataset.warm, delete a.dataset.live, a.classList.remove("liforma-ew--session-revealed");
|
|
3678
|
-
},
|
|
3719
|
+
}, q = () => {
|
|
3679
3720
|
if (!S && $(a.dataset.state)) {
|
|
3680
|
-
if (
|
|
3721
|
+
if (H(), x = !1, b && E) {
|
|
3681
3722
|
let e = b;
|
|
3682
3723
|
(async () => {
|
|
3683
|
-
D && (await
|
|
3724
|
+
D && (await me(), S || b !== e) || (w && e.setWidgetChrome("collapsed"), Ee(), D ? (a.dataset.live = "true", o.tabIndex = 0, o.removeAttribute("aria-hidden"), o.disabled = !1) : w && ye(), t.onCollapsed?.(), t.onClose?.());
|
|
3684
3725
|
})();
|
|
3685
3726
|
return;
|
|
3686
3727
|
}
|
|
3687
|
-
|
|
3728
|
+
De(), Ee(), t.onCollapsed?.(), t.onClose?.();
|
|
3688
3729
|
}
|
|
3689
|
-
},
|
|
3690
|
-
S ||
|
|
3691
|
-
|
|
3730
|
+
}, Oe = () => {
|
|
3731
|
+
S || ir() && R() === "expanded" && pe(() => {
|
|
3732
|
+
we();
|
|
3692
3733
|
});
|
|
3693
|
-
},
|
|
3694
|
-
S || R() === "docked" && (
|
|
3695
|
-
B(),
|
|
3734
|
+
}, ke = () => {
|
|
3735
|
+
S || R() === "docked" && (H(), pe(() => {
|
|
3736
|
+
B(), Ce(!1), b?.setWidgetChrome("expanded");
|
|
3696
3737
|
}));
|
|
3697
|
-
},
|
|
3698
|
-
!b || !D || (z(), a.classList.remove("liforma-ew--session-revealed"),
|
|
3699
|
-
}, q = () => {
|
|
3700
|
-
!b || !E || D || (z(), a.classList.remove("liforma-ew--session-revealed"), we(), x = !1, w || b.setWidgetChrome("expanded"));
|
|
3701
|
-
}, Me = (e) => {
|
|
3702
|
-
S || e !== O && !D || (z(), a.classList.remove("liforma-ew--session-revealed"), we(), x = !1, D && pe());
|
|
3738
|
+
}, Ae = () => {
|
|
3739
|
+
!b || !D || (z(), a.classList.remove("liforma-ew--session-revealed"), Ce(), b.setWidgetChrome("expanded"), x = !1, fe());
|
|
3703
3740
|
}, J = () => {
|
|
3741
|
+
!b || !E || D || (z(), a.classList.remove("liforma-ew--session-revealed"), Ce(), x = !1, w || b.setWidgetChrome("expanded"));
|
|
3742
|
+
}, je = (e) => {
|
|
3743
|
+
S || e !== O && !D || (z(), a.classList.remove("liforma-ew--session-revealed"), Ce(), x = !1, D && fe());
|
|
3744
|
+
}, Me = () => {
|
|
3704
3745
|
if (S || T || w || b || $(a.dataset.state)) return;
|
|
3705
3746
|
T = !0;
|
|
3706
3747
|
let e = O;
|
|
3707
3748
|
l.hidden = !1, (async () => {
|
|
3708
3749
|
try {
|
|
3709
|
-
let t = await
|
|
3750
|
+
let t = await Kn.startSession(xe());
|
|
3710
3751
|
if (S || e !== O) {
|
|
3711
3752
|
t.destroy();
|
|
3712
3753
|
return;
|
|
3713
3754
|
}
|
|
3714
|
-
b = t,
|
|
3755
|
+
b = t, Te(t);
|
|
3715
3756
|
let n = await t.attach({
|
|
3716
3757
|
container: l,
|
|
3717
|
-
...
|
|
3758
|
+
...Se(),
|
|
3718
3759
|
onWidgetReady: () => {
|
|
3719
|
-
S || e !== O || (T = !1, E = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") :
|
|
3760
|
+
S || e !== O || (T = !1, E = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") : ye());
|
|
3720
3761
|
},
|
|
3721
3762
|
onWidgetExpand: () => {
|
|
3722
|
-
|
|
3763
|
+
je(e);
|
|
3723
3764
|
},
|
|
3724
3765
|
onWidgetAudioSettings: (e) => {
|
|
3725
3766
|
S || Ie(e);
|
|
3726
3767
|
},
|
|
3727
3768
|
onWidgetDragStart: (e) => {
|
|
3728
|
-
S ||
|
|
3769
|
+
S || ue(e);
|
|
3729
3770
|
},
|
|
3730
3771
|
onWidgetDragMove: (e) => {
|
|
3731
|
-
S ||
|
|
3772
|
+
S || U(e);
|
|
3732
3773
|
},
|
|
3733
3774
|
onWidgetDragEnd: (e) => {
|
|
3734
3775
|
S || de(e);
|
|
3735
3776
|
},
|
|
3736
3777
|
onPlayerStatusChange: (e) => {
|
|
3737
|
-
S || e === "error" && $(a.dataset.state) &&
|
|
3778
|
+
S || e === "error" && $(a.dataset.state) && ge("Could not load the experience.");
|
|
3738
3779
|
}
|
|
3739
3780
|
});
|
|
3740
3781
|
if (S || e !== O) {
|
|
@@ -3742,7 +3783,7 @@ function pr(e, t) {
|
|
|
3742
3783
|
return;
|
|
3743
3784
|
}
|
|
3744
3785
|
n.on("close", () => {
|
|
3745
|
-
S ||
|
|
3786
|
+
S || q();
|
|
3746
3787
|
});
|
|
3747
3788
|
} catch (n) {
|
|
3748
3789
|
if (S || e !== O) return;
|
|
@@ -3754,40 +3795,40 @@ function pr(e, t) {
|
|
|
3754
3795
|
}, Ne = () => {
|
|
3755
3796
|
if (S || x || !C || $(a.dataset.state)) return;
|
|
3756
3797
|
if (b && D) {
|
|
3757
|
-
|
|
3798
|
+
Ae();
|
|
3758
3799
|
return;
|
|
3759
3800
|
}
|
|
3760
3801
|
if (b && E) {
|
|
3761
|
-
|
|
3802
|
+
J();
|
|
3762
3803
|
return;
|
|
3763
3804
|
}
|
|
3764
3805
|
let e = ++O;
|
|
3765
3806
|
x = !0, w = !1, T = !1, E = !1, D = !1, delete a.dataset.warm, delete a.dataset.live, l.hidden = !0, l.replaceChildren(), b &&= (b.destroy(), null), (async () => {
|
|
3766
3807
|
try {
|
|
3767
|
-
|
|
3768
|
-
let t = await
|
|
3808
|
+
Ce();
|
|
3809
|
+
let t = await Kn.startSession(xe());
|
|
3769
3810
|
if (S || e !== O) {
|
|
3770
3811
|
t.destroy();
|
|
3771
3812
|
return;
|
|
3772
3813
|
}
|
|
3773
|
-
b = t,
|
|
3814
|
+
b = t, Te(t);
|
|
3774
3815
|
let n = await t.attach({
|
|
3775
3816
|
container: v,
|
|
3776
|
-
...
|
|
3817
|
+
...Se(),
|
|
3777
3818
|
onWidgetAudioSettings: (e) => {
|
|
3778
3819
|
S || Ie(e);
|
|
3779
3820
|
},
|
|
3780
3821
|
onWidgetDragStart: (e) => {
|
|
3781
|
-
S ||
|
|
3822
|
+
S || ue(e);
|
|
3782
3823
|
},
|
|
3783
3824
|
onWidgetDragMove: (e) => {
|
|
3784
|
-
S ||
|
|
3825
|
+
S || U(e);
|
|
3785
3826
|
},
|
|
3786
3827
|
onWidgetDragEnd: (e) => {
|
|
3787
3828
|
S || de(e);
|
|
3788
3829
|
},
|
|
3789
3830
|
onPlayerStatusChange: (e) => {
|
|
3790
|
-
S || (e === "error" ?
|
|
3831
|
+
S || (e === "error" ? ge("Could not load the experience.") : $(a.dataset.state) && ge(null));
|
|
3791
3832
|
}
|
|
3792
3833
|
});
|
|
3793
3834
|
if (S || e !== O) {
|
|
@@ -3795,12 +3836,12 @@ function pr(e, t) {
|
|
|
3795
3836
|
return;
|
|
3796
3837
|
}
|
|
3797
3838
|
E = !0, t.setWidgetChrome("expanded"), n.on("close", () => {
|
|
3798
|
-
S ||
|
|
3839
|
+
S || q();
|
|
3799
3840
|
});
|
|
3800
3841
|
} catch (n) {
|
|
3801
3842
|
if (S || e !== O) return;
|
|
3802
3843
|
let r = n instanceof Error ? n : Error(String(n));
|
|
3803
|
-
|
|
3844
|
+
ge(r.message), t.onError?.(r), console.error("[ExperienceWidget]", r);
|
|
3804
3845
|
} finally {
|
|
3805
3846
|
e === O && (x = !1);
|
|
3806
3847
|
}
|
|
@@ -3808,88 +3849,88 @@ function pr(e, t) {
|
|
|
3808
3849
|
}, Pe = () => {
|
|
3809
3850
|
if (!(S || $(a.dataset.state))) {
|
|
3810
3851
|
if (b && D) {
|
|
3811
|
-
|
|
3852
|
+
Ae();
|
|
3812
3853
|
return;
|
|
3813
3854
|
}
|
|
3814
3855
|
if (b && E) {
|
|
3815
|
-
|
|
3856
|
+
J();
|
|
3816
3857
|
return;
|
|
3817
3858
|
}
|
|
3818
3859
|
if (T || b) {
|
|
3819
|
-
|
|
3860
|
+
Ce();
|
|
3820
3861
|
return;
|
|
3821
3862
|
}
|
|
3822
3863
|
Ne();
|
|
3823
3864
|
}
|
|
3824
3865
|
}, Fe = (e) => {
|
|
3825
3866
|
if (e.stopPropagation(), R() === "expanded") {
|
|
3826
|
-
|
|
3867
|
+
Oe();
|
|
3827
3868
|
return;
|
|
3828
3869
|
}
|
|
3829
|
-
R() === "docked" &&
|
|
3870
|
+
R() === "docked" && ke();
|
|
3830
3871
|
}, Ie = (e) => {
|
|
3831
3872
|
g.setAttribute("aria-pressed", e ? "true" : "false");
|
|
3832
3873
|
}, Le = (e) => {
|
|
3833
3874
|
e.stopPropagation(), $(a.dataset.state) && b?.toggleAudioSettings();
|
|
3834
3875
|
}, Re = (e) => {
|
|
3835
|
-
R() === "docked" &&
|
|
3876
|
+
R() === "docked" && ir() && (e.target?.closest("button") || (e.preventDefault(), le(e.clientX, e.clientY, e.pointerId)));
|
|
3836
3877
|
}, ze = (e) => {
|
|
3837
|
-
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(),
|
|
3878
|
+
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), q());
|
|
3838
3879
|
}, Be = () => {
|
|
3839
3880
|
if (!S) {
|
|
3840
3881
|
if (R() === "docked") {
|
|
3841
|
-
if (!
|
|
3842
|
-
|
|
3882
|
+
if (!ir()) {
|
|
3883
|
+
ke();
|
|
3843
3884
|
return;
|
|
3844
3885
|
}
|
|
3845
|
-
D ?
|
|
3846
|
-
|
|
3847
|
-
}) :
|
|
3886
|
+
D ? pe(() => {
|
|
3887
|
+
G(!0);
|
|
3888
|
+
}) : G(!0);
|
|
3848
3889
|
return;
|
|
3849
3890
|
}
|
|
3850
3891
|
W();
|
|
3851
3892
|
}
|
|
3852
|
-
}, Ve = typeof window < "u" ? window.matchMedia(
|
|
3893
|
+
}, Ve = typeof window < "u" ? window.matchMedia(Jn) : null, He = () => {
|
|
3853
3894
|
if (!S) {
|
|
3854
|
-
if (R() === "docked" && !
|
|
3855
|
-
|
|
3895
|
+
if (R() === "docked" && !ir()) {
|
|
3896
|
+
ke();
|
|
3856
3897
|
return;
|
|
3857
3898
|
}
|
|
3858
3899
|
W();
|
|
3859
3900
|
}
|
|
3860
3901
|
};
|
|
3861
|
-
return o.addEventListener("click", Pe), d.addEventListener("click",
|
|
3862
|
-
e.stopPropagation(),
|
|
3863
|
-
}), h.addEventListener("click", Fe), g.addEventListener("click", Le), p.addEventListener("pointerdown", Re), window.addEventListener("keydown", ze), window.addEventListener("resize", Be), Ve?.addEventListener("change", He),
|
|
3864
|
-
S ||
|
|
3865
|
-
}) : r === "idle" && (ee =
|
|
3866
|
-
S ||
|
|
3902
|
+
return o.addEventListener("click", Pe), d.addEventListener("click", q), _.addEventListener("click", (e) => {
|
|
3903
|
+
e.stopPropagation(), q();
|
|
3904
|
+
}), h.addEventListener("click", Fe), g.addEventListener("click", Le), p.addEventListener("pointerdown", Re), window.addEventListener("keydown", ze), window.addEventListener("resize", Be), Ve?.addEventListener("change", He), K(), W(), r === "eager" ? queueMicrotask(() => {
|
|
3905
|
+
S || Me();
|
|
3906
|
+
}) : r === "idle" && (ee = pr(() => {
|
|
3907
|
+
S || Me();
|
|
3867
3908
|
})), {
|
|
3868
3909
|
root: a,
|
|
3869
3910
|
expand: Pe,
|
|
3870
|
-
collapse:
|
|
3871
|
-
dock:
|
|
3872
|
-
maximize:
|
|
3911
|
+
collapse: q,
|
|
3912
|
+
dock: Oe,
|
|
3913
|
+
maximize: ke,
|
|
3873
3914
|
prefetch() {
|
|
3874
3915
|
if (r === "onExpand") {
|
|
3875
|
-
|
|
3916
|
+
Me();
|
|
3876
3917
|
return;
|
|
3877
3918
|
}
|
|
3878
|
-
|
|
3919
|
+
Me();
|
|
3879
3920
|
},
|
|
3880
3921
|
destroy() {
|
|
3881
|
-
S || (S = !0,
|
|
3922
|
+
S || (S = !0, H(), ee?.(), ee = null, re.abort(), A?.(), A = null, window.removeEventListener("keydown", ze), window.removeEventListener("resize", Be), Ve?.removeEventListener("change", He), De(), Ee(), e.replaceChildren());
|
|
3882
3923
|
}
|
|
3883
3924
|
};
|
|
3884
3925
|
}
|
|
3885
3926
|
//#endregion
|
|
3886
3927
|
//#region src/react/ExperienceWidget.tsx
|
|
3887
|
-
function
|
|
3928
|
+
function hr(e) {
|
|
3888
3929
|
let t = o(null), { experienceId: r, alt: i, galleryThumb: a, avatarImage: s, backgroundImage: c, foregroundImage: l, fallbackImage: u, prefetch: f = "onExpand", parallax: p = !0, position: m = "static", offset: h, sessionEndpoint: g, locale: _, secondaryLocale: v, learningLocale: y, language: b, mode: x, speechInputMode: S, speechOnly: C, fit: w, embedBaseUrl: T, expandedMaxWidth: E, expandedMaxHeight: D, startButtonLabel: O, startButton: k, showFeedback: A, className: ee = "", onExpanded: j, onCollapsed: M, onStarted: N, onClose: P, onError: F, onPrefetchReady: te, onFeedback: I, onFeedbackFailed: L } = e, ne = m === "bottom-right" || m === "bottom-left";
|
|
3889
3930
|
return n(() => {
|
|
3890
3931
|
let e = t.current;
|
|
3891
3932
|
if (!e || !r.trim()) return;
|
|
3892
|
-
let n =
|
|
3933
|
+
let n = mr(e, {
|
|
3893
3934
|
experienceId: r,
|
|
3894
3935
|
alt: i,
|
|
3895
3936
|
galleryThumb: a,
|
|
@@ -3972,6 +4013,6 @@ function mr(e) {
|
|
|
3972
4013
|
});
|
|
3973
4014
|
}
|
|
3974
4015
|
//#endregion
|
|
3975
|
-
export { ne as Experience, Ue as ExperienceThumbnail,
|
|
4016
|
+
export { ne as Experience, Ue as ExperienceThumbnail, hr as ExperienceWidget };
|
|
3976
4017
|
|
|
3977
4018
|
//# sourceMappingURL=index.js.map
|