@liforma/client 0.4.12 → 0.4.14
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 +23 -0
- package/README.md +4 -4
- package/dist/next/index.js +585 -491
- package/dist/next/index.js.map +1 -1
- package/dist/next/react/ExperienceThumbnail.d.ts.map +1 -1
- package/dist/next/thumbnail/index.d.ts +1 -0
- package/dist/next/thumbnail/index.d.ts.map +1 -1
- package/dist/next/thumbnail/locationPlate.d.ts +3 -3
- package/dist/next/thumbnail/locationPlate.d.ts.map +1 -1
- package/dist/next/thumbnail/plateDelivery.d.ts +18 -0
- package/dist/next/thumbnail/plateDelivery.d.ts.map +1 -0
- package/dist/next/thumbnail/plateDelivery.test.d.ts +2 -0
- package/dist/next/thumbnail/plateDelivery.test.d.ts.map +1 -0
- package/dist/next/thumbnail/toGalleryThumbUrl.d.ts +1 -1
- package/dist/next/thumbnail.js +147 -91
- 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 +14 -0
- package/dist/next/v2/experience.d.ts.map +1 -1
- package/dist/next/v2/shims/embedBaseUrl.d.ts +4 -1
- package/dist/next/v2/shims/embedBaseUrl.d.ts.map +1 -1
- package/dist/npm/index.js +223 -185
- package/dist/npm/index.js.map +1 -1
- package/dist/npm/thumbnail/index.d.ts +1 -0
- package/dist/npm/thumbnail/index.d.ts.map +1 -1
- package/dist/npm/thumbnail/index.js +106 -70
- package/dist/npm/thumbnail/index.js.map +1 -1
- package/dist/npm/thumbnail/locationPlate.d.ts +3 -3
- package/dist/npm/thumbnail/locationPlate.d.ts.map +1 -1
- package/dist/npm/thumbnail/plateDelivery.d.ts +18 -0
- package/dist/npm/thumbnail/plateDelivery.d.ts.map +1 -0
- package/dist/npm/thumbnail/toGalleryThumbUrl.d.ts +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 +14 -0
- package/dist/npm/v2/experience.d.ts.map +1 -1
- package/dist/npm/v2/liforma-experience-thumbnail.d.ts.map +1 -1
- package/dist/npm/v2/shims/embedBaseUrl.d.ts +4 -1
- package/dist/npm/v2/shims/embedBaseUrl.d.ts.map +1 -1
- package/dist/react/component/experienceComponentLaunch.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 +12 -0
- package/dist/react/component/experienceComponentTypes.d.ts.map +1 -1
- package/dist/react/index.js +689 -573
- package/dist/react/index.js.map +1 -1
- package/dist/react/react/Experience.d.ts.map +1 -1
- package/dist/react/react/ExperienceThumbnail.d.ts.map +1 -1
- package/dist/react/thumbnail/index.d.ts +1 -0
- package/dist/react/thumbnail/index.d.ts.map +1 -1
- package/dist/react/thumbnail/locationPlate.d.ts +3 -3
- package/dist/react/thumbnail/locationPlate.d.ts.map +1 -1
- package/dist/react/thumbnail/plateDelivery.d.ts +18 -0
- package/dist/react/thumbnail/plateDelivery.d.ts.map +1 -0
- package/dist/react/thumbnail/plateDelivery.test.d.ts +2 -0
- package/dist/react/thumbnail/plateDelivery.test.d.ts.map +1 -0
- package/dist/react/thumbnail/toGalleryThumbUrl.d.ts +1 -1
- package/dist/react/thumbnail.js +147 -91
- 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 +14 -0
- package/dist/react/v2/experience.d.ts.map +1 -1
- package/dist/react/v2/shims/embedBaseUrl.d.ts +4 -1
- package/dist/react/v2/shims/embedBaseUrl.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 +3 -3
- package/dist/sdk/v2/thumbnail.js.map +1 -1
- package/dist/svelte/Experience.svelte +30 -0
- package/dist/svelte/Experience.svelte.d.ts +1 -0
- package/dist/svelte/ExperienceThumbnail.svelte +49 -8
- package/package.json +4 -1
package/dist/react/index.js
CHANGED
|
@@ -31,6 +31,8 @@ function _(e) {
|
|
|
31
31
|
embedBaseUrl: e.embedBaseUrl,
|
|
32
32
|
debug: e.debug,
|
|
33
33
|
speechOnly: e.speechOnly,
|
|
34
|
+
previewBackground: e.previewBackground,
|
|
35
|
+
previewForeground: e.previewForeground,
|
|
34
36
|
conversationProcessor: e.conversationProcessor
|
|
35
37
|
};
|
|
36
38
|
if (t && e.experienceId && e.sessionEndpoint) return {
|
|
@@ -49,6 +51,8 @@ function _(e) {
|
|
|
49
51
|
mode: e.mode,
|
|
50
52
|
speechInputMode: e.speechInputMode,
|
|
51
53
|
speechOnly: e.speechOnly,
|
|
54
|
+
previewBackground: e.previewBackground,
|
|
55
|
+
previewForeground: e.previewForeground,
|
|
52
56
|
attribution: e.attribution,
|
|
53
57
|
alreadyConverted: e.alreadyConverted,
|
|
54
58
|
conversationProcessor: e.conversationProcessor
|
|
@@ -68,6 +72,8 @@ function _(e) {
|
|
|
68
72
|
mode: e.mode,
|
|
69
73
|
speechInputMode: e.speechInputMode,
|
|
70
74
|
speechOnly: e.speechOnly,
|
|
75
|
+
previewBackground: e.previewBackground,
|
|
76
|
+
previewForeground: e.previewForeground,
|
|
71
77
|
attribution: e.attribution,
|
|
72
78
|
alreadyConverted: e.alreadyConverted,
|
|
73
79
|
conversationProcessor: e.conversationProcessor
|
|
@@ -257,6 +263,9 @@ function P(e = () => ({}), t = () => ({})) {
|
|
|
257
263
|
interaction: d.interaction,
|
|
258
264
|
closeButton: d.closeButton,
|
|
259
265
|
returnUrl: f,
|
|
266
|
+
...d.theatreButton ? { theatreButton: !0 } : {},
|
|
267
|
+
...d.theatre === void 0 ? {} : { theatre: d.theatre },
|
|
268
|
+
onTheatreChange: (e) => t().onTheatreChange?.(e),
|
|
260
269
|
showClose: !!(o().onClose || f || d.closeButton === !0 || d.closeButton && typeof d.closeButton == "object" && d.closeButton.visible !== !1),
|
|
261
270
|
onPlayerStatusChange: (t) => {
|
|
262
271
|
if (e.destroyed) return;
|
|
@@ -347,7 +356,7 @@ function L(e, t) {
|
|
|
347
356
|
//#endregion
|
|
348
357
|
//#region src/react/Experience.tsx
|
|
349
358
|
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,
|
|
359
|
+
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: ae, onStateUpdate: oe, onClose: z, onError: se } = e, ce = o({}), le = o({
|
|
351
360
|
fit: l,
|
|
352
361
|
stage: u,
|
|
353
362
|
pipBackground: p,
|
|
@@ -356,10 +365,13 @@ var ne = e(function(e, a) {
|
|
|
356
365
|
theme: g,
|
|
357
366
|
showFeedback: y,
|
|
358
367
|
interaction: b,
|
|
359
|
-
closeButton:
|
|
360
|
-
returnUrl: c
|
|
361
|
-
|
|
362
|
-
|
|
368
|
+
closeButton: w,
|
|
369
|
+
returnUrl: c,
|
|
370
|
+
theatreButton: x,
|
|
371
|
+
theatre: S,
|
|
372
|
+
onTheatreChange: C
|
|
373
|
+
}), B = o(P(() => ce.current, () => le.current)), V = o(null), [ue, de] = s(!1), [fe, pe] = s(null), H = o(null), me = o(null), he = v(e);
|
|
374
|
+
le.current = {
|
|
363
375
|
fit: l,
|
|
364
376
|
stage: u,
|
|
365
377
|
pipBackground: p,
|
|
@@ -368,100 +380,110 @@ var ne = e(function(e, a) {
|
|
|
368
380
|
theme: g,
|
|
369
381
|
showFeedback: y,
|
|
370
382
|
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
|
-
|
|
383
|
+
closeButton: w,
|
|
384
|
+
returnUrl: c,
|
|
385
|
+
theatreButton: x,
|
|
386
|
+
theatre: S,
|
|
387
|
+
onTheatreChange: C
|
|
388
|
+
}, ce.current = {
|
|
389
|
+
onReady: T,
|
|
390
|
+
onStarted: E,
|
|
391
|
+
onUserTranscript: D,
|
|
392
|
+
onUserSpeechStarted: O,
|
|
393
|
+
onUserSpeechEnded: ee,
|
|
394
|
+
onCharacterSpeechStarted: j,
|
|
395
|
+
onCharacterSpeechEnded: M,
|
|
396
|
+
onCharacterFocusChanged: N,
|
|
397
|
+
onConversationUpdate: F,
|
|
398
|
+
onMessage: te,
|
|
399
|
+
onListeningState: I,
|
|
400
|
+
onActivityChange: ne,
|
|
401
|
+
onFeedback: re,
|
|
402
|
+
onFeedbackFailed: ie,
|
|
403
|
+
onConversationProcessorError: R,
|
|
404
|
+
onPlayerStatusChange: ae,
|
|
405
|
+
onStateUpdate: oe,
|
|
406
|
+
onClose: z,
|
|
407
|
+
onError: se
|
|
408
|
+
};
|
|
409
|
+
let ge = t((e) => {
|
|
410
|
+
H.current = e, de(e !== null);
|
|
396
411
|
}, []);
|
|
397
412
|
return r(a, () => ({
|
|
398
413
|
ready: () => {
|
|
399
|
-
let e =
|
|
414
|
+
let e = V.current;
|
|
400
415
|
return !e || e.destroyed ? Promise.reject(k()) : e.ready.promise;
|
|
401
416
|
},
|
|
402
417
|
started: () => {
|
|
403
|
-
let e =
|
|
418
|
+
let e = V.current;
|
|
404
419
|
return !e || e.destroyed ? Promise.reject(k()) : e.started.promise;
|
|
405
420
|
},
|
|
406
421
|
speech: {
|
|
407
|
-
speak: (e) =>
|
|
408
|
-
play: (e) =>
|
|
422
|
+
speak: (e) => B.current.withSession((t) => t.speech.speak(e)),
|
|
423
|
+
play: (e) => B.current.withSession((t) => t.speech.play(e)),
|
|
409
424
|
createUtterance: (e) => {
|
|
410
|
-
let t =
|
|
425
|
+
let t = B.current.getActiveInstance();
|
|
411
426
|
if (!t) throw Error("Session has not started. Wait for the player start button and the started event before using speech APIs.");
|
|
412
427
|
return t.speech.createUtterance(e);
|
|
413
428
|
},
|
|
414
|
-
interrupt: (e) =>
|
|
429
|
+
interrupt: (e) => B.current.withSession((t) => t.speech.interrupt(e))
|
|
415
430
|
},
|
|
416
|
-
startListening: () =>
|
|
417
|
-
stopListening: () =>
|
|
418
|
-
listenOnce: (e) =>
|
|
419
|
-
getSession: () =>
|
|
420
|
-
getManifest: () =>
|
|
421
|
-
getConversation: () =>
|
|
422
|
-
focusCharacter: (e) =>
|
|
423
|
-
setFit: (e) =>
|
|
424
|
-
setStage: (e) =>
|
|
425
|
-
setPipBackground: (e) =>
|
|
426
|
-
setPipShadow: (e) =>
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
431
|
+
startListening: () => B.current.withSession((e) => e.startListening()),
|
|
432
|
+
stopListening: () => B.current.withSession((e) => e.stopListening()),
|
|
433
|
+
listenOnce: (e) => B.current.withSession((t) => t.listenOnce(e)),
|
|
434
|
+
getSession: () => B.current.getActiveInstance()?.getSession() ?? null,
|
|
435
|
+
getManifest: () => B.current.getActiveInstance()?.getManifest() ?? null,
|
|
436
|
+
getConversation: () => B.current.getActiveInstance()?.getConversation() ?? [],
|
|
437
|
+
focusCharacter: (e) => B.current.withSession((t) => t.focusCharacter(e)),
|
|
438
|
+
setFit: (e) => B.current.withSession((t) => t.setFit(e)),
|
|
439
|
+
setStage: (e) => B.current.withSession((t) => t.setStage(e)),
|
|
440
|
+
setPipBackground: (e) => B.current.withSession((t) => t.setPipBackground(e)),
|
|
441
|
+
setPipShadow: (e) => B.current.withSession((t) => t.setPipShadow(e)),
|
|
442
|
+
setTheatre: (e) => {
|
|
443
|
+
B.current.getActiveInstance()?.setTheatre(e);
|
|
444
|
+
},
|
|
445
|
+
conversion: (e) => B.current.withSession((t) => t.conversion(e)),
|
|
446
|
+
engage: () => B.current.withSession((e) => e.engage()),
|
|
447
|
+
end: () => B.current.withSession((e) => e.end())
|
|
430
448
|
}), []), i(() => {
|
|
431
|
-
if (!
|
|
432
|
-
let t =
|
|
449
|
+
if (!ue || !H.current) return;
|
|
450
|
+
let t = H.current, n = B.current, r;
|
|
433
451
|
try {
|
|
434
452
|
r = { options: _(e) };
|
|
435
453
|
} catch (e) {
|
|
436
454
|
r = { error: A(e) };
|
|
437
455
|
}
|
|
438
|
-
let i = n.activateGeneration(t, r, c,
|
|
439
|
-
return
|
|
440
|
-
n.cancelGeneration(i),
|
|
456
|
+
let i = n.activateGeneration(t, r, c, pe);
|
|
457
|
+
return V.current = i, () => {
|
|
458
|
+
n.cancelGeneration(i), V.current === i && (V.current = null);
|
|
441
459
|
};
|
|
442
460
|
}, [
|
|
443
|
-
|
|
444
|
-
|
|
461
|
+
ue,
|
|
462
|
+
he,
|
|
445
463
|
c
|
|
446
464
|
]), n(() => {
|
|
447
|
-
let e =
|
|
465
|
+
let e = B.current.getActiveInstance();
|
|
448
466
|
e && e.setFit(l ?? "full");
|
|
449
467
|
}, [l]), n(() => {
|
|
450
|
-
let e =
|
|
468
|
+
let e = B.current.getActiveInstance();
|
|
451
469
|
e && e.setStage(u ?? "fill");
|
|
452
470
|
}, [u]), n(() => {
|
|
453
|
-
let e =
|
|
471
|
+
let e = B.current.getActiveInstance();
|
|
454
472
|
e && e.setPipBackground(p ?? "none");
|
|
455
473
|
}, [p]), n(() => {
|
|
456
474
|
if (m === void 0) return;
|
|
457
|
-
let e =
|
|
475
|
+
let e = B.current.getActiveInstance();
|
|
458
476
|
e && e.setPipShadow(m);
|
|
459
477
|
}, [m]), n(() => {
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
478
|
+
if (!x) return;
|
|
479
|
+
let e = B.current.getActiveInstance();
|
|
480
|
+
e && e.setTheatre(S === !0);
|
|
481
|
+
}, [x, S]), n(() => {
|
|
482
|
+
let e = me.current;
|
|
483
|
+
if (!e || (e.replaceChildren(), !fe)) return;
|
|
484
|
+
let t = L(e, fe);
|
|
463
485
|
return () => t.remove();
|
|
464
|
-
}, [
|
|
486
|
+
}, [fe]), /* @__PURE__ */ f("div", {
|
|
465
487
|
className: "liforma-experience-shell",
|
|
466
488
|
style: {
|
|
467
489
|
position: "relative",
|
|
@@ -470,17 +492,17 @@ var ne = e(function(e, a) {
|
|
|
470
492
|
minHeight: "inherit"
|
|
471
493
|
},
|
|
472
494
|
children: [/* @__PURE__ */ d("div", {
|
|
473
|
-
ref:
|
|
495
|
+
ref: me,
|
|
474
496
|
className: "liforma-experience-error-host",
|
|
475
|
-
"aria-hidden":
|
|
497
|
+
"aria-hidden": fe ? void 0 : !0,
|
|
476
498
|
style: {
|
|
477
499
|
position: "absolute",
|
|
478
500
|
inset: 0,
|
|
479
501
|
zIndex: 20,
|
|
480
|
-
pointerEvents:
|
|
502
|
+
pointerEvents: fe ? "auto" : "none"
|
|
481
503
|
}
|
|
482
504
|
}), /* @__PURE__ */ d("div", {
|
|
483
|
-
ref:
|
|
505
|
+
ref: ge,
|
|
484
506
|
className: "liforma-experience-host",
|
|
485
507
|
style: {
|
|
486
508
|
position: "absolute",
|
|
@@ -497,15 +519,15 @@ function re(e) {
|
|
|
497
519
|
}
|
|
498
520
|
//#endregion
|
|
499
521
|
//#region src/thumbnail/locationPlate.ts
|
|
500
|
-
var ie = /(-)(\d+x\d+)(\.webp)(\?|$)/i;
|
|
522
|
+
var ie = /(-)(\d+x\d+)(\.(?:webp|avif))(\?|$)/i;
|
|
501
523
|
function R(e, t) {
|
|
502
|
-
return !Number.isFinite(e) || !Number.isFinite(t) || e < 1 || t < 1 || e <= t ? "256x256" : e > 800 || t > 450 ? "1672x941" : "800x450";
|
|
524
|
+
return !Number.isFinite(e) || !Number.isFinite(t) || e < 1 || t < 1 || e <= t ? "256x256" : t <= 225 ? "400x225" : e > 800 || t > 450 ? "1672x941" : "800x450";
|
|
503
525
|
}
|
|
504
|
-
function
|
|
526
|
+
function ae(e, t) {
|
|
505
527
|
let n = e.trim();
|
|
506
528
|
return n && n.replace(ie, (e, n, r, i, a) => `${n}${t}${i}${a}`);
|
|
507
529
|
}
|
|
508
|
-
function
|
|
530
|
+
function oe(e, t) {
|
|
509
531
|
let n = () => {
|
|
510
532
|
t(e.clientWidth, e.clientHeight);
|
|
511
533
|
};
|
|
@@ -513,17 +535,17 @@ function ae(e, t) {
|
|
|
513
535
|
let r = new ResizeObserver(n);
|
|
514
536
|
return r.observe(e), () => r.disconnect();
|
|
515
537
|
}
|
|
516
|
-
var
|
|
517
|
-
function
|
|
538
|
+
var z = /-(256x256|400x225|400x450|800x450|836x971|1672x941|167x94)$/i;
|
|
539
|
+
function se(e) {
|
|
518
540
|
return e?.trim().replace(/\/$/, "") || "https://cdn.liforma.ai";
|
|
519
541
|
}
|
|
520
|
-
function
|
|
542
|
+
function ce(e) {
|
|
521
543
|
return /^https?:\/\//i.test(e) || e.startsWith("//");
|
|
522
544
|
}
|
|
523
|
-
function
|
|
545
|
+
function le(e) {
|
|
524
546
|
return e.startsWith("//") ? `https:${e}` : e;
|
|
525
547
|
}
|
|
526
|
-
function
|
|
548
|
+
function B(e) {
|
|
527
549
|
let t = e.indexOf("?");
|
|
528
550
|
return t === -1 ? {
|
|
529
551
|
pathname: e,
|
|
@@ -533,51 +555,51 @@ function se(e) {
|
|
|
533
555
|
search: e.slice(t)
|
|
534
556
|
};
|
|
535
557
|
}
|
|
536
|
-
function
|
|
558
|
+
function V(e, t, n = "") {
|
|
537
559
|
return `${e}${t.startsWith("/") ? t : `/${t}`}${n}`;
|
|
538
560
|
}
|
|
539
|
-
function
|
|
561
|
+
function ue(e, t, n) {
|
|
540
562
|
let r = e.trim();
|
|
541
563
|
if (!r) return r;
|
|
542
|
-
let i =
|
|
543
|
-
if (
|
|
544
|
-
let { pathname: a, search: o } =
|
|
564
|
+
let i = se(n);
|
|
565
|
+
if (ce(r)) return ae(le(r), t);
|
|
566
|
+
let { pathname: a, search: o } = B(r.replace(/\\/g, "/")), s = a;
|
|
545
567
|
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) && !
|
|
568
|
+
else if (!/^\/locations\//i.test(s)) return /^\/avatars\//i.test(s) ? V(i, s, o) : r;
|
|
569
|
+
if (/\.webp$/i.test(s) && !z.test(s.replace(/\.webp$/i, ""))) return V(i, s, o);
|
|
548
570
|
let c = s.replace(/^\/locations\//i, "").replace(/\.webp$/i, "");
|
|
549
|
-
return c = c.replace(
|
|
571
|
+
return c = c.replace(z, ""), `${i}/locations/${c}-${t}.webp${o}`;
|
|
550
572
|
}
|
|
551
|
-
function
|
|
573
|
+
function de(e, t) {
|
|
552
574
|
let n = e.trim();
|
|
553
575
|
if (!n) return n;
|
|
554
|
-
let r =
|
|
555
|
-
if (
|
|
556
|
-
let { pathname: i, search: a } =
|
|
576
|
+
let r = se(t);
|
|
577
|
+
if (ce(n)) return le(n);
|
|
578
|
+
let { pathname: i, search: a } = B(n.replace(/\\/g, "/")), o = i;
|
|
557
579
|
if (!o.startsWith("/")) if (/^avatars\//i.test(o)) o = `/${o}`;
|
|
558
580
|
else if (/^[^/]+$/.test(o) && !a) return `${r}/avatars/${o}/256/${o}_neutral.webp`;
|
|
559
581
|
else return n;
|
|
560
582
|
if (!/^\/avatars\//i.test(o)) return n;
|
|
561
583
|
let s = o.replace(/^\/avatars\//i, "").replace(/\/+$/, "");
|
|
562
|
-
return s && !s.includes("/") && !a ? `${r}/avatars/${s}/256/${s}_neutral.webp` :
|
|
584
|
+
return s && !s.includes("/") && !a ? `${r}/avatars/${s}/256/${s}_neutral.webp` : V(r, o, a);
|
|
563
585
|
}
|
|
564
586
|
//#endregion
|
|
565
587
|
//#region src/thumbnail/toGalleryThumbUrl.ts
|
|
566
|
-
var
|
|
567
|
-
function
|
|
588
|
+
var fe = /(\/avatars\/[^/]+\/)(\d+)(\/)/i, pe = /_CH(\.webp)/i;
|
|
589
|
+
function H(e) {
|
|
568
590
|
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
591
|
}
|
|
570
|
-
function
|
|
592
|
+
function me(e, t = "256x256", n) {
|
|
571
593
|
let r = e.trim();
|
|
572
594
|
if (!r) return r;
|
|
573
|
-
if (
|
|
574
|
-
let i =
|
|
575
|
-
return i = i.replace(
|
|
595
|
+
if (H(r)) return ue(r, t, n);
|
|
596
|
+
let i = de(r, n);
|
|
597
|
+
return i = i.replace(fe, (e, t, n, r) => n === "256" ? `${t}${n}${r}` : `${t}256${r}`), i.replace(pe, "_neutral$1");
|
|
576
598
|
}
|
|
577
|
-
function
|
|
599
|
+
function he(e) {
|
|
578
600
|
let t = e.avatarImage?.trim() || e.galleryThumb?.avatarImage?.trim() || "";
|
|
579
601
|
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 =
|
|
602
|
+
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 = se(e.cdnBaseUrl), s = e.normalize !== !1, c = (e) => !s && /^https?:\/\//i.test(e.trim()) ? e.trim() : me(e, a, o), l = (e) => !s && /^https?:\/\//i.test(e.trim()) ? e.trim() : ue(e, a, o);
|
|
581
603
|
return {
|
|
582
604
|
avatarImage: c(t),
|
|
583
605
|
...n ? { backgroundImage: l(n) } : {},
|
|
@@ -587,7 +609,7 @@ function pe(e) {
|
|
|
587
609
|
}
|
|
588
610
|
//#endregion
|
|
589
611
|
//#region src/shims/localStack.ts
|
|
590
|
-
function
|
|
612
|
+
function ge() {
|
|
591
613
|
if (globalThis.__LIFORMA_STACK === "local") return !0;
|
|
592
614
|
if (typeof location > "u") return !1;
|
|
593
615
|
try {
|
|
@@ -598,16 +620,16 @@ function me() {
|
|
|
598
620
|
}
|
|
599
621
|
//#endregion
|
|
600
622
|
//#region src/thumbnail/hostedLaunchUrl.ts
|
|
601
|
-
var
|
|
602
|
-
function
|
|
623
|
+
var _e = "https://player.liforma.ai", ve = "http://localhost:3002";
|
|
624
|
+
function U(e) {
|
|
603
625
|
return e.href?.trim() ? "anchor" : e.hasClickHandler ? "button" : e.experienceId?.trim() ? "anchor" : "presentational";
|
|
604
626
|
}
|
|
605
|
-
function
|
|
627
|
+
function W(e) {
|
|
606
628
|
let t = e?.trim();
|
|
607
|
-
return t ? t.replace(/\/$/, "") :
|
|
629
|
+
return t ? t.replace(/\/$/, "") : ge() ? ve : _e;
|
|
608
630
|
}
|
|
609
631
|
function ye(e) {
|
|
610
|
-
let t = e.experienceId.trim(), n =
|
|
632
|
+
let t = e.experienceId.trim(), n = W(e.playerBaseUrl), r = new URL(`${n}/${encodeURIComponent(t)}`), i = e.returnUrl?.trim();
|
|
611
633
|
return i && r.searchParams.set("returnUrl", i), r.toString();
|
|
612
634
|
}
|
|
613
635
|
function be(e) {
|
|
@@ -625,26 +647,26 @@ function be(e) {
|
|
|
625
647
|
function xe() {
|
|
626
648
|
return typeof window > "u" ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
|
|
627
649
|
}
|
|
628
|
-
var
|
|
629
|
-
function
|
|
650
|
+
var Se = 0, Ce = [];
|
|
651
|
+
function we() {
|
|
630
652
|
return xe() ? 4 : Infinity;
|
|
631
653
|
}
|
|
632
|
-
function
|
|
654
|
+
function G() {
|
|
633
655
|
return xe() ? 160 : 0;
|
|
634
656
|
}
|
|
635
657
|
function Te() {
|
|
636
|
-
let e =
|
|
637
|
-
for (;
|
|
638
|
-
let e =
|
|
658
|
+
let e = we();
|
|
659
|
+
for (; Se < e && Ce.length > 0;) {
|
|
660
|
+
let e = Ce.shift();
|
|
639
661
|
if (!e || e.cancelled) continue;
|
|
640
|
-
|
|
641
|
-
let t =
|
|
662
|
+
Se += 1, e.start();
|
|
663
|
+
let t = G();
|
|
642
664
|
if (t <= 0) {
|
|
643
|
-
|
|
665
|
+
Se = Math.max(0, Se - 1);
|
|
644
666
|
continue;
|
|
645
667
|
}
|
|
646
668
|
window.setTimeout(() => {
|
|
647
|
-
|
|
669
|
+
Se = Math.max(0, Se - 1), Te();
|
|
648
670
|
}, t);
|
|
649
671
|
}
|
|
650
672
|
}
|
|
@@ -654,7 +676,7 @@ function Ee(e) {
|
|
|
654
676
|
start: e,
|
|
655
677
|
cancelled: !1
|
|
656
678
|
};
|
|
657
|
-
return
|
|
679
|
+
return Ce.push(t), Te(), () => {
|
|
658
680
|
t.cancelled = !0;
|
|
659
681
|
};
|
|
660
682
|
}
|
|
@@ -769,7 +791,7 @@ function Re(e) {
|
|
|
769
791
|
}
|
|
770
792
|
//#endregion
|
|
771
793
|
//#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
|
|
794
|
+
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
795
|
function Ve(e) {
|
|
774
796
|
if (typeof document > "u" || Be) return;
|
|
775
797
|
if (document.querySelector("style[data-liforma-et]")) {
|
|
@@ -780,12 +802,47 @@ function Ve(e) {
|
|
|
780
802
|
t.setAttribute("data-liforma-et", ""), t.textContent = e, document.head.appendChild(t), Be = !0;
|
|
781
803
|
}
|
|
782
804
|
//#endregion
|
|
805
|
+
//#region src/thumbnail/plateDelivery.ts
|
|
806
|
+
var He = "data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=", Ue = null;
|
|
807
|
+
function We(e) {
|
|
808
|
+
let t = e.trim();
|
|
809
|
+
if (!t || t.startsWith("blob:") || t.startsWith("data:")) return !1;
|
|
810
|
+
let n = t.split(/[?#]/)[0] ?? t, r = /\/avatars\//i.test(n), i = /\/locations\//i.test(n);
|
|
811
|
+
return !r && !i || /\.depth\.webp$/i.test(n) ? !1 : /\.webp$/i.test(n);
|
|
812
|
+
}
|
|
813
|
+
function Ge(e) {
|
|
814
|
+
if (!We(e)) return null;
|
|
815
|
+
let t = e.search(/[?#]/);
|
|
816
|
+
if (t < 0) return e.replace(/\.webp$/i, ".avif");
|
|
817
|
+
let n = e.slice(0, t), r = e.slice(t);
|
|
818
|
+
return `${n.replace(/\.webp$/i, ".avif")}${r}`;
|
|
819
|
+
}
|
|
820
|
+
function Ke() {
|
|
821
|
+
return typeof Image > "u" ? Promise.resolve(!1) : (Ue ||= new Promise((e) => {
|
|
822
|
+
let t = new Image();
|
|
823
|
+
t.onload = () => e(t.naturalWidth > 0 && t.naturalHeight > 0), t.onerror = () => e(!1), t.src = He;
|
|
824
|
+
}), Ue);
|
|
825
|
+
}
|
|
826
|
+
function qe(e, t) {
|
|
827
|
+
return t ? Ge(e) ?? e : e;
|
|
828
|
+
}
|
|
829
|
+
function Je(e) {
|
|
830
|
+
let t = e.trim(), n = t.search(/[?#]/), r = n < 0 ? t : t.slice(0, n);
|
|
831
|
+
if (!/\.avif$/i.test(r)) return null;
|
|
832
|
+
let i = r.replace(/\.avif$/i, ".webp");
|
|
833
|
+
return n < 0 ? i : `${i}${t.slice(n)}`;
|
|
834
|
+
}
|
|
835
|
+
function Ye(e) {
|
|
836
|
+
let t = e.trim();
|
|
837
|
+
return /-400x225\.(webp|avif)(?:$|[?#])/i.test(t) ? t.replace(/-400x225\.(webp|avif)/i, "-800x450.$1") : null;
|
|
838
|
+
}
|
|
839
|
+
//#endregion
|
|
783
840
|
//#region src/react/ExperienceThumbnail.tsx
|
|
784
|
-
function
|
|
841
|
+
function Xe(e, t) {
|
|
785
842
|
return `${e} liforma-et__media${t ? " liforma-et__media--ready" : ""}`;
|
|
786
843
|
}
|
|
787
|
-
function
|
|
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(() =>
|
|
844
|
+
function Ze(e) {
|
|
845
|
+
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(() => he({
|
|
789
846
|
galleryThumb: t,
|
|
790
847
|
avatarImage: r,
|
|
791
848
|
backgroundImage: i,
|
|
@@ -803,15 +860,17 @@ function Ue(e) {
|
|
|
803
860
|
T,
|
|
804
861
|
M,
|
|
805
862
|
E
|
|
806
|
-
]), P =
|
|
863
|
+
]), P = U({
|
|
807
864
|
href: m,
|
|
808
865
|
hasClickHandler: typeof _ == "function",
|
|
809
866
|
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, V] = s(!1), [
|
|
867
|
+
}), F = P === "anchor" && !m?.trim() && !!p?.trim(), te = !!N?.backgroundImage, I = b !== !1, [L, ne] = s(!S), [ie, ae] = s(!1), [z, se] = s(!1), [ce, le] = s(!1), [B, V] = s(!1), [ue, de] = s(!1), [fe, pe] = s(!1), [H, me] = s(!1), [ge, _e] = s(0), [ve, W] = s(0), [ye, xe] = s(!1), [Se, Ce] = s(!1), [we, G] = s(!1), [Te, Ee] = s(!1), [De, Oe] = s(), K = N ? ye && N.fallbackImage ? N.fallbackImage : N.avatarImage : "";
|
|
811
868
|
n(() => {
|
|
812
|
-
Ve(ze)
|
|
869
|
+
Ve(ze), Ke().then((e) => {
|
|
870
|
+
ae(e), se(!0);
|
|
871
|
+
});
|
|
813
872
|
}, []), n(() => {
|
|
814
|
-
|
|
873
|
+
Oe(be({
|
|
815
874
|
href: m,
|
|
816
875
|
experienceId: p,
|
|
817
876
|
returnUrl: v,
|
|
@@ -825,17 +884,17 @@ function Ue(e) {
|
|
|
825
884
|
y,
|
|
826
885
|
F
|
|
827
886
|
]), n(() => {
|
|
828
|
-
|
|
887
|
+
Ce(!1), G(!1), Ee(!1), xe(!1), le(!1), V(!1), de(!1);
|
|
829
888
|
}, [
|
|
830
889
|
N?.backgroundImage,
|
|
831
890
|
N?.foregroundImage,
|
|
832
|
-
|
|
891
|
+
K
|
|
833
892
|
]), n(() => {
|
|
834
893
|
let e = D.current;
|
|
835
|
-
if (e) return
|
|
894
|
+
if (e) return oe(e, (e, t) => {
|
|
836
895
|
A(e), j(t);
|
|
837
896
|
});
|
|
838
|
-
}, [P,
|
|
897
|
+
}, [P, De]), n(() => {
|
|
839
898
|
let e = D.current;
|
|
840
899
|
if (e) {
|
|
841
900
|
if (!S) {
|
|
@@ -850,12 +909,12 @@ function Ue(e) {
|
|
|
850
909
|
S,
|
|
851
910
|
N,
|
|
852
911
|
P,
|
|
853
|
-
|
|
912
|
+
De
|
|
854
913
|
]), n(() => {
|
|
855
914
|
let e = D.current;
|
|
856
915
|
if (!(!e || !I)) return Le(e, {
|
|
857
916
|
onParallax: (e) => {
|
|
858
|
-
|
|
917
|
+
me(!0), O.current || (_e(e), W(0));
|
|
859
918
|
},
|
|
860
919
|
pointerActive: () => O.current
|
|
861
920
|
});
|
|
@@ -863,23 +922,23 @@ function Ue(e) {
|
|
|
863
922
|
I,
|
|
864
923
|
N,
|
|
865
924
|
P,
|
|
866
|
-
|
|
925
|
+
De
|
|
867
926
|
]);
|
|
868
|
-
let
|
|
869
|
-
if (!I ||
|
|
927
|
+
let Ae = (e) => {
|
|
928
|
+
if (!I || H) return;
|
|
870
929
|
let t = e.currentTarget.getBoundingClientRect();
|
|
871
|
-
t.width <= 0 || t.height <= 0 || (
|
|
872
|
-
},
|
|
930
|
+
t.width <= 0 || t.height <= 0 || (_e(((e.clientX - t.left) / t.width - .5) * 2), W(((e.clientY - t.top) / t.height - .5) * 2));
|
|
931
|
+
}, q = (e) => {
|
|
873
932
|
let t = O.current;
|
|
874
|
-
O.current = !1,
|
|
875
|
-
},
|
|
933
|
+
O.current = !1, pe(!1), H && t ? (_e(je(e.getBoundingClientRect(), window.innerHeight)), W(0)) : H || (_e(0), W(0));
|
|
934
|
+
}, Me = (e) => {
|
|
876
935
|
if (!I) return;
|
|
877
|
-
O.current = !0, e.pointerType === "mouse" &&
|
|
936
|
+
O.current = !0, e.pointerType === "mouse" && pe(!0);
|
|
878
937
|
let t = e.currentTarget, n = () => {
|
|
879
|
-
|
|
938
|
+
q(t), window.removeEventListener("pointerup", n), window.removeEventListener("pointercancel", n);
|
|
880
939
|
};
|
|
881
940
|
window.addEventListener("pointerup", n), window.addEventListener("pointercancel", n);
|
|
882
|
-
},
|
|
941
|
+
}, J = (e) => {
|
|
883
942
|
if (_?.(e), !e.defaultPrevented && F && !v?.trim()) {
|
|
884
943
|
let t = be({
|
|
885
944
|
experienceId: p,
|
|
@@ -890,134 +949,153 @@ function Ue(e) {
|
|
|
890
949
|
}
|
|
891
950
|
};
|
|
892
951
|
if (!N) return null;
|
|
893
|
-
let
|
|
952
|
+
let Ne = I && (fe || H), Pe = L && z && (we || Se || Te), Fe = [
|
|
894
953
|
"liforma-et",
|
|
895
954
|
te ? "liforma-et--scene" : "",
|
|
896
955
|
re(x),
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
L && !
|
|
900
|
-
|
|
956
|
+
Ne ? "liforma-et--parallax" : "",
|
|
957
|
+
H ? "liforma-et--scroll-parallax" : "",
|
|
958
|
+
L && !Pe ? "liforma-et--loading" : "",
|
|
959
|
+
Pe ? "liforma-et--revealed" : "",
|
|
901
960
|
C
|
|
902
|
-
].filter(Boolean).join(" "),
|
|
903
|
-
"--liforma-et-parallax-x":
|
|
904
|
-
"--liforma-et-parallax-y":
|
|
905
|
-
},
|
|
961
|
+
].filter(Boolean).join(" "), Ie = {
|
|
962
|
+
"--liforma-et-parallax-x": ge,
|
|
963
|
+
"--liforma-et-parallax-y": ve
|
|
964
|
+
}, Re = (e, t) => {
|
|
906
965
|
e.complete && t(!0);
|
|
907
|
-
},
|
|
966
|
+
}, Be = /* @__PURE__ */ f(u, { children: [
|
|
908
967
|
/* @__PURE__ */ d("span", {
|
|
909
968
|
className: "liforma-et__placeholder",
|
|
910
969
|
"aria-hidden": "true"
|
|
911
970
|
}),
|
|
912
|
-
L && N.backgroundImage ? /* @__PURE__ */ d("img", {
|
|
913
|
-
className:
|
|
914
|
-
src: N.backgroundImage,
|
|
971
|
+
L && z && N.backgroundImage ? /* @__PURE__ */ d("img", {
|
|
972
|
+
className: Xe("liforma-et__background", Se),
|
|
973
|
+
src: qe(N.backgroundImage, ie),
|
|
915
974
|
alt: "",
|
|
916
975
|
decoding: "async",
|
|
917
976
|
ref: (e) => {
|
|
918
|
-
e &&
|
|
977
|
+
e && Re(e, Ce);
|
|
919
978
|
},
|
|
920
|
-
onLoad: () =>
|
|
921
|
-
onError: () =>
|
|
979
|
+
onLoad: () => Ce(!0),
|
|
980
|
+
onError: (e) => {
|
|
981
|
+
let t = e.currentTarget, n = Ye(t.src);
|
|
982
|
+
if (n && !ce) {
|
|
983
|
+
le(!0), t.src = n;
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
Ce(!0);
|
|
987
|
+
}
|
|
922
988
|
}) : null,
|
|
923
|
-
L &&
|
|
924
|
-
className:
|
|
925
|
-
src:
|
|
989
|
+
L && z && K ? /* @__PURE__ */ d("img", {
|
|
990
|
+
className: Xe("liforma-et__avatar", we),
|
|
991
|
+
src: qe(K, ie),
|
|
926
992
|
alt: "",
|
|
927
993
|
decoding: "async",
|
|
928
994
|
ref: (e) => {
|
|
929
|
-
e &&
|
|
995
|
+
e && Re(e, G);
|
|
930
996
|
},
|
|
931
|
-
onLoad: () =>
|
|
932
|
-
onError: () => {
|
|
933
|
-
|
|
997
|
+
onLoad: () => G(!0),
|
|
998
|
+
onError: (e) => {
|
|
999
|
+
let t = e.currentTarget, n = Je(t.src);
|
|
1000
|
+
if (n && !ue) {
|
|
1001
|
+
de(!0), t.src = n;
|
|
1002
|
+
return;
|
|
1003
|
+
}
|
|
1004
|
+
N.fallbackImage ? xe(!0) : G(!0);
|
|
934
1005
|
}
|
|
935
1006
|
}) : null,
|
|
936
|
-
L && N.foregroundImage ? /* @__PURE__ */ d("img", {
|
|
937
|
-
className:
|
|
938
|
-
src: N.foregroundImage,
|
|
1007
|
+
L && z && N.foregroundImage ? /* @__PURE__ */ d("img", {
|
|
1008
|
+
className: Xe("liforma-et__foreground", Te),
|
|
1009
|
+
src: qe(N.foregroundImage, ie),
|
|
939
1010
|
alt: "",
|
|
940
1011
|
decoding: "async",
|
|
941
1012
|
ref: (e) => {
|
|
942
|
-
e &&
|
|
1013
|
+
e && Re(e, Ee);
|
|
943
1014
|
},
|
|
944
|
-
onLoad: () =>
|
|
945
|
-
onError: () =>
|
|
1015
|
+
onLoad: () => Ee(!0),
|
|
1016
|
+
onError: (e) => {
|
|
1017
|
+
let t = e.currentTarget, n = Ye(t.src);
|
|
1018
|
+
if (n && !B) {
|
|
1019
|
+
V(!0), t.src = n;
|
|
1020
|
+
return;
|
|
1021
|
+
}
|
|
1022
|
+
Ee(!0);
|
|
1023
|
+
}
|
|
946
1024
|
}) : null
|
|
947
|
-
] }),
|
|
948
|
-
onPointerDown:
|
|
949
|
-
onPointerUp: (e) =>
|
|
950
|
-
onPointerCancel: (e) =>
|
|
1025
|
+
] }), He = {
|
|
1026
|
+
onPointerDown: Me,
|
|
1027
|
+
onPointerUp: (e) => q(e.currentTarget),
|
|
1028
|
+
onPointerCancel: (e) => q(e.currentTarget),
|
|
951
1029
|
onPointerEnter: (e) => {
|
|
952
|
-
I && e.pointerType === "mouse" &&
|
|
1030
|
+
I && e.pointerType === "mouse" && pe(!0);
|
|
953
1031
|
},
|
|
954
|
-
onPointerMove:
|
|
1032
|
+
onPointerMove: Ae,
|
|
955
1033
|
onPointerLeave: () => {
|
|
956
|
-
O.current || (
|
|
1034
|
+
O.current || (pe(!1), H || (_e(0), W(0)));
|
|
957
1035
|
}
|
|
958
|
-
},
|
|
1036
|
+
}, Ue = (e) => {
|
|
959
1037
|
D.current = e;
|
|
960
1038
|
};
|
|
961
|
-
return P === "anchor" &&
|
|
962
|
-
ref:
|
|
963
|
-
className:
|
|
964
|
-
style:
|
|
965
|
-
href:
|
|
1039
|
+
return P === "anchor" && De ? /* @__PURE__ */ d("a", {
|
|
1040
|
+
ref: Ue,
|
|
1041
|
+
className: Fe,
|
|
1042
|
+
style: Ie,
|
|
1043
|
+
href: De,
|
|
966
1044
|
target: h,
|
|
967
1045
|
rel: g,
|
|
968
1046
|
"aria-label": l,
|
|
969
|
-
onClick:
|
|
970
|
-
...
|
|
971
|
-
children:
|
|
1047
|
+
onClick: J,
|
|
1048
|
+
...He,
|
|
1049
|
+
children: Be
|
|
972
1050
|
}) : P === "button" ? /* @__PURE__ */ d("button", {
|
|
973
1051
|
type: "button",
|
|
974
|
-
ref:
|
|
975
|
-
className:
|
|
976
|
-
style:
|
|
1052
|
+
ref: Ue,
|
|
1053
|
+
className: Fe,
|
|
1054
|
+
style: Ie,
|
|
977
1055
|
"aria-label": l,
|
|
978
|
-
onClick:
|
|
979
|
-
...
|
|
980
|
-
children:
|
|
1056
|
+
onClick: J,
|
|
1057
|
+
...He,
|
|
1058
|
+
children: Be
|
|
981
1059
|
}) : /* @__PURE__ */ d("div", {
|
|
982
|
-
ref:
|
|
983
|
-
className:
|
|
984
|
-
style:
|
|
1060
|
+
ref: Ue,
|
|
1061
|
+
className: Fe,
|
|
1062
|
+
style: Ie,
|
|
985
1063
|
role: l ? "img" : void 0,
|
|
986
1064
|
"aria-label": l || void 0,
|
|
987
1065
|
"aria-hidden": l ? void 0 : !0,
|
|
988
|
-
...
|
|
989
|
-
children:
|
|
1066
|
+
...He,
|
|
1067
|
+
children: Be
|
|
990
1068
|
});
|
|
991
1069
|
}
|
|
992
1070
|
//#endregion
|
|
993
1071
|
//#region src/widget/styles.ts
|
|
994
|
-
var We = "\n.liforma-ew {\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}\n\n/* Optional self-positioned FAB (position=bottom-right|bottom-left).\n * Cap at 50vmin so small phones don't get an oversized thumb (desktop 224px stays). */\n.liforma-ew[data-position='bottom-right'],\n.liforma-ew[data-position='bottom-left'] {\n position: fixed;\n width: min(var(--liforma-ew-fab-size, 224px), 50vmin);\n height: min(var(--liforma-ew-fab-size, 224px), 50vmin);\n bottom: var(--liforma-ew-offset, 16px);\n z-index: 2147482900;\n}\n\n.liforma-ew[data-position='bottom-right'] {\n right: var(--liforma-ew-offset, 16px);\n left: auto;\n}\n\n.liforma-ew[data-position='bottom-left'] {\n left: var(--liforma-ew-offset, 16px);\n right: auto;\n}\n\n/* While open, collapse the FAB box so a corner hole / thumb never remains. */\n.liforma-ew[data-position='bottom-right'][data-state='expanded'],\n.liforma-ew[data-position='bottom-right'][data-state='docked'],\n.liforma-ew[data-position='bottom-left'][data-state='expanded'],\n.liforma-ew[data-position='bottom-left'][data-state='docked'] {\n width: 0;\n height: 0;\n min-width: 0;\n min-height: 0;\n overflow: visible;\n pointer-events: none;\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__warm,\n.liforma-ew[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-state='expanded'] .liforma-ew__overlay,\n.liforma-ew[data-state='expanded'] .liforma-ew__toolbar,\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar {\n pointer-events: auto;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__overlay {\n pointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel {\n pointer-events: auto;\n}\n\n.liforma-ew__hit {\n box-sizing: border-box;\n display: block;\n width: 100%;\n height: 100%;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n cursor: pointer;\n font: inherit;\n appearance: none;\n -webkit-tap-highlight-color: transparent;\n transform: scale(1);\n transform-origin: center center;\n transition:\n transform 180ms ease,\n filter 180ms ease;\n will-change: transform;\n}\n\n/* Author display must not defeat the HTML hidden attribute. */\n.liforma-ew__hit[hidden] {\n display: none !important;\n}\n\n.liforma-ew__hit:focus-visible {\n outline: 2px solid #5b8def;\n outline-offset: 3px;\n border-radius: 0.75rem;\n}\n\n@media (hover: hover) and (pointer: fine) {\n /* Scale the thumb whenever the collapsed FAB is hovered — including via the warm iframe hit layer. */\n .liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover,\n .liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-ew__hit {\n transform: scale(1.06);\n }\n\n .liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover .liforma-et,\n .liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-et {\n box-shadow: 0 12px 36px rgba(0, 0, 0, 0.34);\n }\n}\n\n.liforma-ew__face {\n width: 100%;\n height: 100%;\n min-height: 0;\n position: relative;\n}\n\n.liforma-ew__face-status {\n position: absolute;\n inset: 0;\n z-index: 1;\n display: grid;\n place-items: center;\n padding: 0.5rem;\n text-align: center;\n font: 600 0.75rem/1.3 system-ui, sans-serif;\n color: #e8ecf4;\n background: rgba(10, 12, 18, 0.72);\n border-radius: 0.75rem;\n pointer-events: none;\n}\n\n.liforma-ew__face-status[hidden] {\n display: none !important;\n}\n\n.liforma-ew__hit:disabled {\n cursor: default;\n opacity: 0.85;\n}\n\n.liforma-ew__face .liforma-et {\n border-radius: 0.75rem;\n box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);\n transition: box-shadow 180ms ease;\n}\n\n.liforma-ew__warm {\n box-sizing: border-box;\n position: absolute;\n inset: 0;\n z-index: 2;\n border-radius: 0.75rem;\n overflow: hidden;\n background: transparent;\n pointer-events: none;\n opacity: 1;\n transition: opacity 1000ms ease;\n}\n\n/*\n * Collapsed: keep the warm iframe as an invisible hit target only.\n * Painting it over the thumb causes a “ghost enlarge” (face scales under a static iframe).\n */\n.liforma-ew[data-state='collapsed'] .liforma-ew__warm {\n opacity: 0;\n transition: none;\n}\n\n.liforma-ew[data-warm='true'] .liforma-ew__warm {\n pointer-events: auto;\n}\n\n.liforma-ew[data-warm='true']:not([data-live='true']) .liforma-ew__hit {\n pointer-events: none;\n}\n\n.liforma-ew[data-live='true'][data-state='collapsed'] .liforma-ew__hit {\n pointer-events: auto;\n}\n\n.liforma-ew[data-live='true'] .liforma-ew__warm,\n.liforma-ew[data-live='true'] .liforma-ew__stage {\n /* Hidden under the thumb / until post-resize fade-in (matches cold avatar reveal). */\n opacity: 0;\n}\n\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='expanded'] .liforma-ew__warm,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='expanded'] .liforma-ew__stage,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='docked'] .liforma-ew__stage {\n opacity: 1;\n}\n\n.liforma-ew--session-concealing .liforma-ew__warm,\n.liforma-ew--session-concealing .liforma-ew__stage {\n transition-duration: 280ms;\n}\n\n/* Instant hide while dock/maximize geometry settles (player morph resize ~160ms). */\n.liforma-ew--layout-settling .liforma-ew__warm,\n.liforma-ew--layout-settling .liforma-ew__stage {\n opacity: 0 !important;\n transition: none !important;\n}\n\n.liforma-ew[data-live='true'][data-state='collapsed'] .liforma-ew__warm {\n /* Keep the live iframe under the thumb; FAB click resumes the shell. */\n pointer-events: none;\n opacity: 0;\n /* Instant hide when collapsed so the FAB never shows a resized live mesh. */\n transition: none;\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__warm {\n position: fixed;\n /* Match overlay panel inset so the warm iframe fills the conversation shell. */\n inset: clamp(12px, 3vw, 28px);\n z-index: 2147483001;\n width: auto;\n height: auto;\n border-radius: 16px;\n pointer-events: auto;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__warm {\n position: fixed;\n inset: auto;\n z-index: 2147483001;\n border-radius: 16px;\n pointer-events: auto;\n /* left/top/width/height set inline from dock geometry */\n}\n\n.liforma-ew__toolbar {\n display: none;\n position: fixed;\n z-index: 2147483002;\n pointer-events: auto;\n box-sizing: border-box;\n align-items: center;\n gap: 0.35rem;\n padding: 0.35rem 0.4rem;\n border-radius: 999px;\n background: rgba(12, 14, 20, 0.72);\n backdrop-filter: blur(8px);\n -webkit-backdrop-filter: blur(8px);\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__toolbar {\n display: flex;\n top: calc(clamp(12px, 3vw, 28px) + 10px);\n right: calc(clamp(12px, 3vw, 28px) + 10px);\n left: auto;\n cursor: default;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar {\n display: flex;\n /* left/top set inline to track the panel; strip remains a drag handle */\n cursor: grab;\n touch-action: none;\n user-select: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel,\n.liforma-ew[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-state='docked'] .liforma-ew__stage {\n /* Player also reports surface drags via postMessage when docked. */\n cursor: grab;\n touch-action: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar.liforma-ew__toolbar--dragging,\n.liforma-ew--dock-dragging,\n.liforma-ew--dock-dragging .liforma-ew__toolbar,\n.liforma-ew--dock-dragging .liforma-ew__panel,\n.liforma-ew--dock-dragging .liforma-ew__warm,\n.liforma-ew--dock-dragging .liforma-ew__stage {\n cursor: grabbing;\n}\n\n\n.liforma-ew__toolbar[hidden] {\n display: none !important;\n}\n\n.liforma-ew__icon-btn {\n appearance: none;\n box-sizing: border-box;\n display: inline-grid;\n place-items: center;\n width: 2rem;\n height: 2rem;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: 999px;\n color: #f5f7fb;\n background: transparent;\n cursor: pointer;\n}\n\n.liforma-ew__icon-btn:hover {\n background: rgba(255, 255, 255, 0.12);\n}\n\n.liforma-ew__icon-btn[aria-pressed='true'] {\n background: rgba(255, 255, 255, 0.2);\n}\n\n.liforma-ew__icon-btn:focus-visible {\n outline: 2px solid #5b8def;\n outline-offset: 2px;\n}\n\n.liforma-ew__icon-btn svg {\n width: 1.05rem;\n height: 1.05rem;\n display: block;\n}\n\n.liforma-ew__drag-grip {\n display: none;\n width: 0.85rem;\n height: 1.25rem;\n margin: 0 0.15rem 0 0.25rem;\n background:\n radial-gradient(circle, currentColor 1.1px, transparent 1.2px) 0 0 / 0.35rem 0.35rem,\n radial-gradient(circle, currentColor 1.1px, transparent 1.2px) 0.35rem 0 / 0.35rem 0.35rem;\n background-repeat: repeat-y;\n opacity: 0.55;\n color: #f5f7fb;\n pointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__drag-grip {\n display: block;\n}\n\n.liforma-ew__dock-toggle[hidden] {\n display: none !important;\n}\n\n.liforma-ew__overlay {\n position: fixed;\n inset: 0;\n z-index: 2147483000;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: clamp(12px, 3vw, 28px);\n box-sizing: border-box;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__overlay {\n padding: 0;\n align-items: stretch;\n justify-content: stretch;\n pointer-events: none;\n background: transparent;\n}\n\n.liforma-ew__overlay[hidden] {\n display: none !important;\n}\n\n.liforma-ew__backdrop {\n position: absolute;\n inset: 0;\n border: 0;\n padding: 0;\n margin: 0;\n background: rgba(6, 8, 14, 0.62);\n cursor: pointer;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__backdrop {\n display: none !important;\n}\n\n.liforma-ew__panel {\n position: relative;\n z-index: 1;\n display: flex;\n flex-direction: column;\n /* Fill the overlay so player loading / start UI centers in the visible window. */\n width: var(--liforma-ew-max-w, 100%);\n height: var(--liforma-ew-max-h, 100%);\n max-width: 100%;\n max-height: 100%;\n border-radius: 16px;\n overflow: hidden;\n background: #030508;\n box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);\n /* Warm iframe sits above as a sibling; keep panel as chrome shell. */\n pointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel {\n position: fixed;\n inset: auto;\n max-width: none;\n max-height: none;\n pointer-events: auto;\n /* left/top/width/height set inline from dock geometry */\n}\n\n.liforma-ew:not([data-warm='true']) .liforma-ew__panel {\n pointer-events: auto;\n}\n\n.liforma-ew__stage {\n position: relative;\n flex: 1;\n min-height: 0;\n width: 100%;\n height: 100%;\n background: #030508;\n opacity: 1;\n transition: opacity 1000ms ease;\n}\n\n.liforma-ew__status {\n position: absolute;\n inset: 0;\n z-index: 1;\n display: grid;\n place-items: center;\n padding: 1.5rem;\n text-align: center;\n color: #d7dde8;\n font: 500 0.9375rem/1.45 system-ui, sans-serif;\n background: rgba(3, 5, 8, 0.92);\n pointer-events: none;\n}\n\n.liforma-ew__status[hidden] {\n display: none !important;\n}\n\n/* Mobile expanded: ~90% viewport, no reduce control. */\n@media (max-width: 767px) {\n .liforma-ew[data-state='expanded'] .liforma-ew__overlay {\n padding: 5vh 5vw;\n }\n\n .liforma-ew[data-state='expanded'] .liforma-ew__panel {\n width: 90vw;\n height: 90vh;\n max-width: 90vw;\n max-height: 90vh;\n }\n\n .liforma-ew[data-state='expanded'] .liforma-ew__warm {\n inset: 5vh 5vw;\n }\n\n .liforma-ew[data-state='expanded'] .liforma-ew__toolbar {\n top: calc(5vh + 10px);\n right: calc(5vw + 10px);\n }\n\n .liforma-ew__dock-toggle {\n display: none !important;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .liforma-ew__hit {\n transition: none;\n will-change: auto;\n }\n\n .liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover,\n .liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-ew__hit {\n transform: none;\n }\n\n .liforma-ew__face .liforma-et {\n box-shadow: none;\n transition: none;\n }\n\n .liforma-ew__warm,\n .liforma-ew__stage {\n transition: none;\n }\n}\n", Ge = "liforma-experience-widget-styles";
|
|
995
|
-
function
|
|
1072
|
+
var Qe = "\n.liforma-ew {\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}\n\n/* Optional self-positioned FAB (position=bottom-right|bottom-left).\n * Cap at 50vmin so small phones don't get an oversized thumb (desktop 224px stays). */\n.liforma-ew[data-position='bottom-right'],\n.liforma-ew[data-position='bottom-left'] {\n position: fixed;\n width: min(var(--liforma-ew-fab-size, 224px), 50vmin);\n height: min(var(--liforma-ew-fab-size, 224px), 50vmin);\n bottom: var(--liforma-ew-offset, 16px);\n z-index: 2147482900;\n}\n\n.liforma-ew[data-position='bottom-right'] {\n right: var(--liforma-ew-offset, 16px);\n left: auto;\n}\n\n.liforma-ew[data-position='bottom-left'] {\n left: var(--liforma-ew-offset, 16px);\n right: auto;\n}\n\n/* While open, collapse the FAB box so a corner hole / thumb never remains. */\n.liforma-ew[data-position='bottom-right'][data-state='expanded'],\n.liforma-ew[data-position='bottom-right'][data-state='docked'],\n.liforma-ew[data-position='bottom-left'][data-state='expanded'],\n.liforma-ew[data-position='bottom-left'][data-state='docked'] {\n width: 0;\n height: 0;\n min-width: 0;\n min-height: 0;\n overflow: visible;\n pointer-events: none;\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__warm,\n.liforma-ew[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-state='expanded'] .liforma-ew__overlay,\n.liforma-ew[data-state='expanded'] .liforma-ew__toolbar,\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar {\n pointer-events: auto;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__overlay {\n pointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel {\n pointer-events: auto;\n}\n\n.liforma-ew__hit {\n box-sizing: border-box;\n display: block;\n width: 100%;\n height: 100%;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n cursor: pointer;\n font: inherit;\n appearance: none;\n -webkit-tap-highlight-color: transparent;\n transform: scale(1);\n transform-origin: center center;\n transition:\n transform 180ms ease,\n filter 180ms ease;\n will-change: transform;\n}\n\n/* Author display must not defeat the HTML hidden attribute. */\n.liforma-ew__hit[hidden] {\n display: none !important;\n}\n\n.liforma-ew__hit:focus-visible {\n outline: 2px solid #5b8def;\n outline-offset: 3px;\n border-radius: 0.75rem;\n}\n\n@media (hover: hover) and (pointer: fine) {\n /* Scale the thumb whenever the collapsed FAB is hovered — including via the warm iframe hit layer. */\n .liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover,\n .liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-ew__hit {\n transform: scale(1.06);\n }\n\n .liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover .liforma-et,\n .liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-et {\n box-shadow: 0 12px 36px rgba(0, 0, 0, 0.34);\n }\n}\n\n.liforma-ew__face {\n width: 100%;\n height: 100%;\n min-height: 0;\n position: relative;\n}\n\n.liforma-ew__face-status {\n position: absolute;\n inset: 0;\n z-index: 1;\n display: grid;\n place-items: center;\n padding: 0.5rem;\n text-align: center;\n font: 600 0.75rem/1.3 system-ui, sans-serif;\n color: #e8ecf4;\n background: rgba(10, 12, 18, 0.72);\n border-radius: 0.75rem;\n pointer-events: none;\n}\n\n.liforma-ew__face-status[hidden] {\n display: none !important;\n}\n\n.liforma-ew__hit:disabled {\n cursor: default;\n opacity: 0.85;\n}\n\n.liforma-ew__face .liforma-et {\n border-radius: 0.75rem;\n box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);\n transition: box-shadow 180ms ease;\n}\n\n.liforma-ew__warm {\n box-sizing: border-box;\n position: absolute;\n inset: 0;\n z-index: 2;\n border-radius: 0.75rem;\n overflow: hidden;\n background: transparent;\n pointer-events: none;\n opacity: 1;\n transition: opacity 1000ms ease;\n}\n\n/*\n * Collapsed: keep the warm iframe as an invisible hit target only.\n * Painting it over the thumb causes a “ghost enlarge” (face scales under a static iframe).\n */\n.liforma-ew[data-state='collapsed'] .liforma-ew__warm {\n opacity: 0;\n transition: none;\n}\n\n.liforma-ew[data-warm='true'] .liforma-ew__warm {\n pointer-events: auto;\n}\n\n.liforma-ew[data-warm='true']:not([data-live='true']) .liforma-ew__hit {\n pointer-events: none;\n}\n\n.liforma-ew[data-live='true'][data-state='collapsed'] .liforma-ew__hit {\n pointer-events: auto;\n}\n\n.liforma-ew[data-live='true'] .liforma-ew__warm,\n.liforma-ew[data-live='true'] .liforma-ew__stage {\n /* Hidden under the thumb / until post-resize fade-in (matches cold avatar reveal). */\n opacity: 0;\n}\n\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='expanded'] .liforma-ew__warm,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='expanded'] .liforma-ew__stage,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='docked'] .liforma-ew__stage {\n opacity: 1;\n}\n\n.liforma-ew--session-concealing .liforma-ew__warm,\n.liforma-ew--session-concealing .liforma-ew__stage {\n transition-duration: 280ms;\n}\n\n/* Instant hide while dock/maximize geometry settles (player morph resize ~160ms). */\n.liforma-ew--layout-settling .liforma-ew__warm,\n.liforma-ew--layout-settling .liforma-ew__stage {\n opacity: 0 !important;\n transition: none !important;\n}\n\n.liforma-ew[data-live='true'][data-state='collapsed'] .liforma-ew__warm {\n /* Keep the live iframe under the thumb; FAB click resumes the shell. */\n pointer-events: none;\n opacity: 0;\n /* Instant hide when collapsed so the FAB never shows a resized live mesh. */\n transition: none;\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__warm {\n position: fixed;\n /* Match overlay panel inset so the warm iframe fills the conversation shell. */\n inset: clamp(12px, 3vw, 28px);\n z-index: 2147483001;\n width: auto;\n height: auto;\n border-radius: 16px;\n pointer-events: auto;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__warm {\n position: fixed;\n inset: auto;\n z-index: 2147483001;\n border-radius: 16px;\n pointer-events: auto;\n /* left/top/width/height set inline from dock geometry */\n}\n\n.liforma-ew__toolbar {\n display: none;\n position: fixed;\n z-index: 2147483002;\n pointer-events: auto;\n box-sizing: border-box;\n align-items: center;\n gap: 0.35rem;\n padding: 0.35rem 0.4rem;\n border-radius: 999px;\n background: rgba(12, 14, 20, 0.72);\n backdrop-filter: blur(8px);\n -webkit-backdrop-filter: blur(8px);\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__toolbar {\n display: flex;\n top: calc(clamp(12px, 3vw, 28px) + 10px);\n right: calc(clamp(12px, 3vw, 28px) + 10px);\n left: auto;\n cursor: default;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar {\n display: flex;\n /* left/top set inline to track the panel; strip remains a drag handle */\n cursor: grab;\n touch-action: none;\n user-select: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel,\n.liforma-ew[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-state='docked'] .liforma-ew__stage {\n /* Player also reports surface drags via postMessage when docked. */\n cursor: grab;\n touch-action: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar.liforma-ew__toolbar--dragging,\n.liforma-ew--dock-dragging,\n.liforma-ew--dock-dragging .liforma-ew__toolbar,\n.liforma-ew--dock-dragging .liforma-ew__panel,\n.liforma-ew--dock-dragging .liforma-ew__warm,\n.liforma-ew--dock-dragging .liforma-ew__stage {\n cursor: grabbing;\n}\n\n\n.liforma-ew__toolbar[hidden] {\n display: none !important;\n}\n\n.liforma-ew__icon-btn {\n appearance: none;\n box-sizing: border-box;\n display: inline-grid;\n place-items: center;\n width: 2rem;\n height: 2rem;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: 999px;\n color: #f5f7fb;\n background: transparent;\n cursor: pointer;\n}\n\n.liforma-ew__icon-btn:hover {\n background: rgba(255, 255, 255, 0.12);\n}\n\n.liforma-ew__icon-btn[aria-pressed='true'] {\n background: rgba(255, 255, 255, 0.2);\n}\n\n.liforma-ew__icon-btn:focus-visible {\n outline: 2px solid #5b8def;\n outline-offset: 2px;\n}\n\n.liforma-ew__icon-btn svg {\n width: 1.05rem;\n height: 1.05rem;\n display: block;\n}\n\n.liforma-ew__drag-grip {\n display: none;\n width: 0.85rem;\n height: 1.25rem;\n margin: 0 0.15rem 0 0.25rem;\n background:\n radial-gradient(circle, currentColor 1.1px, transparent 1.2px) 0 0 / 0.35rem 0.35rem,\n radial-gradient(circle, currentColor 1.1px, transparent 1.2px) 0.35rem 0 / 0.35rem 0.35rem;\n background-repeat: repeat-y;\n opacity: 0.55;\n color: #f5f7fb;\n pointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__drag-grip {\n display: block;\n}\n\n.liforma-ew__dock-toggle[hidden] {\n display: none !important;\n}\n\n.liforma-ew__overlay {\n position: fixed;\n inset: 0;\n z-index: 2147483000;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: clamp(12px, 3vw, 28px);\n box-sizing: border-box;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__overlay {\n padding: 0;\n align-items: stretch;\n justify-content: stretch;\n pointer-events: none;\n background: transparent;\n}\n\n.liforma-ew__overlay[hidden] {\n display: none !important;\n}\n\n.liforma-ew__backdrop {\n position: absolute;\n inset: 0;\n border: 0;\n padding: 0;\n margin: 0;\n background: rgba(6, 8, 14, 0.62);\n cursor: pointer;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__backdrop {\n display: none !important;\n}\n\n.liforma-ew__panel {\n position: relative;\n z-index: 1;\n display: flex;\n flex-direction: column;\n /* Fill the overlay so player loading / start UI centers in the visible window. */\n width: var(--liforma-ew-max-w, 100%);\n height: var(--liforma-ew-max-h, 100%);\n max-width: 100%;\n max-height: 100%;\n border-radius: 16px;\n overflow: hidden;\n background: #030508;\n box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);\n /* Warm iframe sits above as a sibling; keep panel as chrome shell. */\n pointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel {\n position: fixed;\n inset: auto;\n max-width: none;\n max-height: none;\n pointer-events: auto;\n /* left/top/width/height set inline from dock geometry */\n}\n\n.liforma-ew:not([data-warm='true']) .liforma-ew__panel {\n pointer-events: auto;\n}\n\n.liforma-ew__stage {\n position: relative;\n flex: 1;\n min-height: 0;\n width: 100%;\n height: 100%;\n background: #030508;\n opacity: 1;\n transition: opacity 1000ms ease;\n}\n\n.liforma-ew__status {\n position: absolute;\n inset: 0;\n z-index: 1;\n display: grid;\n place-items: center;\n padding: 1.5rem;\n text-align: center;\n color: #d7dde8;\n font: 500 0.9375rem/1.45 system-ui, sans-serif;\n background: rgba(3, 5, 8, 0.92);\n pointer-events: none;\n}\n\n.liforma-ew__status[hidden] {\n display: none !important;\n}\n\n/* Mobile expanded: ~90% viewport, no reduce control. */\n@media (max-width: 767px) {\n .liforma-ew[data-state='expanded'] .liforma-ew__overlay {\n padding: 5vh 5vw;\n }\n\n .liforma-ew[data-state='expanded'] .liforma-ew__panel {\n width: 90vw;\n height: 90vh;\n max-width: 90vw;\n max-height: 90vh;\n }\n\n .liforma-ew[data-state='expanded'] .liforma-ew__warm {\n inset: 5vh 5vw;\n }\n\n .liforma-ew[data-state='expanded'] .liforma-ew__toolbar {\n top: calc(5vh + 10px);\n right: calc(5vw + 10px);\n }\n\n .liforma-ew__dock-toggle {\n display: none !important;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .liforma-ew__hit {\n transition: none;\n will-change: auto;\n }\n\n .liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover,\n .liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-ew__hit {\n transform: none;\n }\n\n .liforma-ew__face .liforma-et {\n box-shadow: none;\n transition: none;\n }\n\n .liforma-ew__warm,\n .liforma-ew__stage {\n transition: none;\n }\n}\n", $e = "liforma-experience-widget-styles";
|
|
1073
|
+
function et(e = Qe) {
|
|
996
1074
|
if (typeof document > "u") return;
|
|
997
|
-
let t = document.getElementById(
|
|
1075
|
+
let t = document.getElementById($e);
|
|
998
1076
|
if (t) {
|
|
999
1077
|
t.textContent = e;
|
|
1000
1078
|
return;
|
|
1001
1079
|
}
|
|
1002
1080
|
let n = document.createElement("style");
|
|
1003
|
-
n.id =
|
|
1081
|
+
n.id = $e, n.textContent = e, document.head.append(n);
|
|
1004
1082
|
}
|
|
1005
1083
|
//#endregion
|
|
1006
1084
|
//#region src/shims/apiBaseUrl.ts
|
|
1007
|
-
var
|
|
1008
|
-
function
|
|
1085
|
+
var tt = "https://api.liforma.ai", nt = "http://localhost:3001";
|
|
1086
|
+
function rt() {
|
|
1009
1087
|
let e = globalThis.__LIFORMA_API_BASE_URL;
|
|
1010
1088
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
1011
1089
|
if (typeof document > "u") return null;
|
|
1012
1090
|
let t = (document.querySelector("script[data-liforma-sdk][src*=\"client.js\"]") ?? document.querySelector("script[src*=\"/sdk/v2/client.js\"]"))?.getAttribute("data-api-base-url")?.trim();
|
|
1013
1091
|
return t ? t.replace(/\/$/, "") : null;
|
|
1014
1092
|
}
|
|
1015
|
-
function
|
|
1016
|
-
return
|
|
1093
|
+
function it() {
|
|
1094
|
+
return rt() || (ge() ? nt : tt);
|
|
1017
1095
|
}
|
|
1018
1096
|
//#endregion
|
|
1019
1097
|
//#region src/v2/api/fetchExperiencePreview.ts
|
|
1020
|
-
function
|
|
1098
|
+
function at(e) {
|
|
1021
1099
|
if (!e || typeof e != "object") return null;
|
|
1022
1100
|
let t = e, n = typeof t.avatarImage == "string" ? t.avatarImage.trim() : "";
|
|
1023
1101
|
return n ? {
|
|
@@ -1026,10 +1104,10 @@ function Ze(e) {
|
|
|
1026
1104
|
...typeof t.foregroundImage == "string" && t.foregroundImage.trim() ? { foregroundImage: t.foregroundImage.trim() } : {}
|
|
1027
1105
|
} : null;
|
|
1028
1106
|
}
|
|
1029
|
-
async function
|
|
1107
|
+
async function ot(e, t) {
|
|
1030
1108
|
let n = e.trim();
|
|
1031
1109
|
if (!n) throw Error("Experience preview requires experienceId.");
|
|
1032
|
-
let r = (t?.apiBaseUrl ??
|
|
1110
|
+
let r = (t?.apiBaseUrl ?? it()).replace(/\/$/, ""), i = await fetch(`${r}/v1/experiences/${encodeURIComponent(n)}/preview`, {
|
|
1033
1111
|
method: "GET",
|
|
1034
1112
|
headers: { Accept: "application/json" },
|
|
1035
1113
|
signal: t?.signal
|
|
@@ -1049,7 +1127,7 @@ async function Qe(e, t) {
|
|
|
1049
1127
|
throw Error("Experience preview returned invalid JSON.");
|
|
1050
1128
|
}
|
|
1051
1129
|
if (!a || typeof a != "object") throw Error("Experience preview returned an invalid payload.");
|
|
1052
|
-
let o = a, s = typeof o.experienceId == "string" ? o.experienceId.trim() : n, c = typeof o.title == "string" ? o.title.trim() : "", l =
|
|
1130
|
+
let o = a, s = typeof o.experienceId == "string" ? o.experienceId.trim() : n, c = typeof o.title == "string" ? o.title.trim() : "", l = at(o.galleryThumb);
|
|
1053
1131
|
if (!l) throw Error("Experience preview is missing gallery thumb images.");
|
|
1054
1132
|
return {
|
|
1055
1133
|
experienceId: s || n,
|
|
@@ -1059,7 +1137,7 @@ async function Qe(e, t) {
|
|
|
1059
1137
|
}
|
|
1060
1138
|
//#endregion
|
|
1061
1139
|
//#region src/v2/errors/LiformaError.ts
|
|
1062
|
-
var
|
|
1140
|
+
var st = class extends Error {
|
|
1063
1141
|
code;
|
|
1064
1142
|
requestId;
|
|
1065
1143
|
status;
|
|
@@ -1068,16 +1146,16 @@ var $e = class extends Error {
|
|
|
1068
1146
|
super(e, t?.cause === void 0 ? void 0 : { cause: t.cause }), this.name = "LiformaError", this.code = t?.code?.trim() || "UNKNOWN", this.requestId = t?.requestId?.trim() || void 0, this.status = t?.status, this.details = t?.details;
|
|
1069
1147
|
}
|
|
1070
1148
|
};
|
|
1071
|
-
function
|
|
1149
|
+
function ct(e) {
|
|
1072
1150
|
if (!(!e || typeof e != "object" || Array.isArray(e))) return e;
|
|
1073
1151
|
}
|
|
1074
|
-
function
|
|
1152
|
+
function lt(e, t, n) {
|
|
1075
1153
|
let r = n?.get("Liforma-Request-Id")?.trim() || void 0, i;
|
|
1076
1154
|
try {
|
|
1077
1155
|
i = JSON.parse(t);
|
|
1078
1156
|
} catch {}
|
|
1079
|
-
let a = i?.error && typeof i.error == "object" ? i.error : void 0, o = a?.code ?? i?.code, s = a?.message ?? i?.message, c = a?.requestId ?? i?.requestId ?? r, l = typeof o == "string" && o.trim() ? o.trim() : "HTTP_ERROR", u = typeof s == "string" && s.trim() ? s.trim() : t.trim().slice(0, 500) || `Request failed (${e})`, d = typeof c == "string" && c.trim() ? c.trim() : r, { code: f, message: p, requestId: m, ...h } =
|
|
1080
|
-
return new
|
|
1157
|
+
let a = i?.error && typeof i.error == "object" ? i.error : void 0, o = a?.code ?? i?.code, s = a?.message ?? i?.message, c = a?.requestId ?? i?.requestId ?? r, l = typeof o == "string" && o.trim() ? o.trim() : "HTTP_ERROR", u = typeof s == "string" && s.trim() ? s.trim() : t.trim().slice(0, 500) || `Request failed (${e})`, d = typeof c == "string" && c.trim() ? c.trim() : r, { code: f, message: p, requestId: m, ...h } = ct(a) ?? ct(i) ?? {};
|
|
1158
|
+
return new st(u, {
|
|
1081
1159
|
code: l,
|
|
1082
1160
|
requestId: d,
|
|
1083
1161
|
status: e,
|
|
@@ -1086,13 +1164,13 @@ function tt(e, t, n) {
|
|
|
1086
1164
|
}
|
|
1087
1165
|
//#endregion
|
|
1088
1166
|
//#region src/v2/api/captureAttribution.ts
|
|
1089
|
-
var
|
|
1167
|
+
var ut = 128, dt = /[\u0000-\u001f\u007f]/g;
|
|
1090
1168
|
function Y(e) {
|
|
1091
1169
|
if (!e) return;
|
|
1092
|
-
let t = e.replace(
|
|
1093
|
-
if (t) return t.slice(0,
|
|
1170
|
+
let t = e.replace(dt, "").trim();
|
|
1171
|
+
if (t) return t.slice(0, ut);
|
|
1094
1172
|
}
|
|
1095
|
-
function
|
|
1173
|
+
function ft(e) {
|
|
1096
1174
|
let t = new URLSearchParams((e ?? "").startsWith("?") ? (e ?? "").slice(1) : e ?? "");
|
|
1097
1175
|
return {
|
|
1098
1176
|
...Y(t.get("utm_source")) ? { utmSource: Y(t.get("utm_source")) } : {},
|
|
@@ -1102,7 +1180,7 @@ function it(e) {
|
|
|
1102
1180
|
...Y(t.get("utm_term")) ? { utmTerm: Y(t.get("utm_term")) } : {}
|
|
1103
1181
|
};
|
|
1104
1182
|
}
|
|
1105
|
-
function
|
|
1183
|
+
function pt(e) {
|
|
1106
1184
|
if (e === !1) return;
|
|
1107
1185
|
if (e && typeof e == "object") {
|
|
1108
1186
|
let t = {
|
|
@@ -1116,7 +1194,7 @@ function at(e) {
|
|
|
1116
1194
|
return Object.keys(t).length ? t : void 0;
|
|
1117
1195
|
}
|
|
1118
1196
|
if (typeof window > "u") return;
|
|
1119
|
-
let t =
|
|
1197
|
+
let t = ft(window.location?.search), n = Y(document.referrer || void 0), r = {
|
|
1120
1198
|
...t,
|
|
1121
1199
|
...n ? { referrer: n } : {}
|
|
1122
1200
|
};
|
|
@@ -1124,19 +1202,19 @@ function at(e) {
|
|
|
1124
1202
|
}
|
|
1125
1203
|
//#endregion
|
|
1126
1204
|
//#region src/v2/api/sessionEndpointRequest.ts
|
|
1127
|
-
function
|
|
1205
|
+
function mt(e) {
|
|
1128
1206
|
let t = e.locale?.trim();
|
|
1129
1207
|
if (t) return t;
|
|
1130
1208
|
let n = e.language?.trim();
|
|
1131
1209
|
if (n) return n;
|
|
1132
1210
|
if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
|
|
1133
1211
|
}
|
|
1134
|
-
function
|
|
1212
|
+
function ht(e) {
|
|
1135
1213
|
let t = e.secondaryLocale?.trim(), n = e.learningLocale?.trim();
|
|
1136
1214
|
if (t && n && t !== n) throw Error("secondaryLocale and learningLocale disagree; pass only one or make them equal.");
|
|
1137
1215
|
return t || n || void 0;
|
|
1138
1216
|
}
|
|
1139
|
-
function
|
|
1217
|
+
function gt(e, t) {
|
|
1140
1218
|
let n = e.trim();
|
|
1141
1219
|
if (!n) throw Error("sessionEndpoint must not be empty.");
|
|
1142
1220
|
if (typeof location > "u") throw Error("sessionEndpoint is only available in a browser.");
|
|
@@ -1144,7 +1222,7 @@ function ct(e, t) {
|
|
|
1144
1222
|
if (r.origin !== location.origin) throw Error("sessionEndpoint must be same-origin.");
|
|
1145
1223
|
let i = t.experienceId.trim();
|
|
1146
1224
|
if (!i) throw Error("sessionEndpoint requires experienceId.");
|
|
1147
|
-
let a =
|
|
1225
|
+
let a = mt(t), o = ht(t), s = t.idempotencyKey?.trim();
|
|
1148
1226
|
return {
|
|
1149
1227
|
url: r.toString(),
|
|
1150
1228
|
init: {
|
|
@@ -1163,7 +1241,7 @@ function ct(e, t) {
|
|
|
1163
1241
|
...t.speechInputMode ? { speechInputMode: t.speechInputMode } : {},
|
|
1164
1242
|
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
|
|
1165
1243
|
...(() => {
|
|
1166
|
-
let e =
|
|
1244
|
+
let e = pt(t.attribution);
|
|
1167
1245
|
return e ? { attribution: e } : {};
|
|
1168
1246
|
})(),
|
|
1169
1247
|
...t.alreadyConverted?.length ? { alreadyConverted: [...t.alreadyConverted] } : {}
|
|
@@ -1173,16 +1251,16 @@ function ct(e, t) {
|
|
|
1173
1251
|
}
|
|
1174
1252
|
//#endregion
|
|
1175
1253
|
//#region src/v2/types/sessionLaunch.ts
|
|
1176
|
-
function
|
|
1254
|
+
function _t(e) {
|
|
1177
1255
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
1178
1256
|
}
|
|
1179
1257
|
function X(e) {
|
|
1180
1258
|
return typeof e == "boolean";
|
|
1181
1259
|
}
|
|
1182
|
-
function
|
|
1183
|
-
if (!
|
|
1260
|
+
function vt(e) {
|
|
1261
|
+
if (!_t(e)) return null;
|
|
1184
1262
|
let t = e.speech, n = e.conversation, r = e.avatar, i = e.tools;
|
|
1185
|
-
return !
|
|
1263
|
+
return !_t(t) || !_t(n) || !_t(r) || !_t(i) || !X(t.input) || !X(t.output) || !X(t.externalAudio) || !X(n.managed) || !X(r.enabled) || !X(i.enabled) ? null : {
|
|
1186
1264
|
speech: {
|
|
1187
1265
|
input: t.input,
|
|
1188
1266
|
output: t.output,
|
|
@@ -1193,8 +1271,8 @@ function ut(e) {
|
|
|
1193
1271
|
tools: { enabled: i.enabled }
|
|
1194
1272
|
};
|
|
1195
1273
|
}
|
|
1196
|
-
function
|
|
1197
|
-
return !
|
|
1274
|
+
function yt(e) {
|
|
1275
|
+
return !_t(e) || !X(e.avatar) || !X(e.speechInput) || !X(e.speechOutput) || !X(e.tools) || !X(e.externalAudio) ? null : {
|
|
1198
1276
|
speech: {
|
|
1199
1277
|
input: e.speechInput,
|
|
1200
1278
|
output: e.speechOutput,
|
|
@@ -1205,12 +1283,12 @@ function dt(e) {
|
|
|
1205
1283
|
tools: { enabled: e.tools }
|
|
1206
1284
|
};
|
|
1207
1285
|
}
|
|
1208
|
-
function
|
|
1209
|
-
return
|
|
1286
|
+
function bt(e) {
|
|
1287
|
+
return vt(e) ?? yt(e);
|
|
1210
1288
|
}
|
|
1211
|
-
function
|
|
1212
|
-
if (!
|
|
1213
|
-
let t = typeof e.id == "string" ? e.id.trim() : "", n = typeof e.experienceId == "string" ? e.experienceId.trim() : "", r = typeof e.experienceRevisionId == "string" ? e.experienceRevisionId.trim() : "", i = typeof e.expiresAt == "string" ? e.expiresAt.trim() : "", a = typeof e.locale == "string" ? e.locale.trim() : "", o = typeof e.secondaryLocale == "string" && e.secondaryLocale.trim() ? e.secondaryLocale.trim() : void 0, s = e.mode === "conversation" || e.mode === "presenter" ? e.mode : null, c =
|
|
1289
|
+
function xt(e) {
|
|
1290
|
+
if (!_t(e)) throw Error("Session Launch response is missing session.");
|
|
1291
|
+
let t = typeof e.id == "string" ? e.id.trim() : "", n = typeof e.experienceId == "string" ? e.experienceId.trim() : "", r = typeof e.experienceRevisionId == "string" ? e.experienceRevisionId.trim() : "", i = typeof e.expiresAt == "string" ? e.expiresAt.trim() : "", a = typeof e.locale == "string" ? e.locale.trim() : "", o = typeof e.secondaryLocale == "string" && e.secondaryLocale.trim() ? e.secondaryLocale.trim() : void 0, s = e.mode === "conversation" || e.mode === "presenter" ? e.mode : null, c = bt(e.capabilities), l = St(e.localeVoiceFallbacks), u = e.status === "active" || e.status === "ended" ? e.status : void 0, d = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt.trim() : void 0;
|
|
1214
1292
|
if (!t || !n || !r || !i || !a || !s || !c) throw Error("Session Launch response has an invalid session object.");
|
|
1215
1293
|
return {
|
|
1216
1294
|
id: t,
|
|
@@ -1226,11 +1304,11 @@ function pt(e) {
|
|
|
1226
1304
|
...d ? { createdAt: d } : {}
|
|
1227
1305
|
};
|
|
1228
1306
|
}
|
|
1229
|
-
function
|
|
1307
|
+
function St(e) {
|
|
1230
1308
|
if (!Array.isArray(e) || e.length === 0) return;
|
|
1231
1309
|
let t = [];
|
|
1232
1310
|
for (let n of e) {
|
|
1233
|
-
if (!
|
|
1311
|
+
if (!_t(n)) continue;
|
|
1234
1312
|
let e = n.axis === "locale" || n.axis === "secondaryLocale" ? n.axis : null, r = typeof n.requested == "string" ? n.requested.trim() : "", i = typeof n.resolved == "string" ? n.resolved.trim() : "";
|
|
1235
1313
|
!e || !r || !i || n.reason !== "voice_unsupported" || t.push({
|
|
1236
1314
|
axis: e,
|
|
@@ -1241,104 +1319,104 @@ function mt(e) {
|
|
|
1241
1319
|
}
|
|
1242
1320
|
return t.length > 0 ? t : void 0;
|
|
1243
1321
|
}
|
|
1244
|
-
function
|
|
1322
|
+
function Ct(e) {
|
|
1245
1323
|
let t = e.localeVoiceFallbacks;
|
|
1246
1324
|
if (t?.length) for (let e of t) {
|
|
1247
1325
|
let t = e.axis === "secondaryLocale" ? "secondaryLocale" : "locale";
|
|
1248
1326
|
console.warn(`[liforma] Session ${t} fell back to ${e.resolved} because the voice does not support ${e.requested}.`);
|
|
1249
1327
|
}
|
|
1250
1328
|
}
|
|
1251
|
-
function
|
|
1252
|
-
if (!
|
|
1329
|
+
function wt(e) {
|
|
1330
|
+
if (!_t(e)) throw Error("Session Launch response must be a JSON object.");
|
|
1253
1331
|
let t = typeof e.launch == "string" ? e.launch.trim() : "";
|
|
1254
1332
|
if (!t) throw Error("Session Launch response is missing launch.");
|
|
1255
|
-
let n =
|
|
1256
|
-
return
|
|
1333
|
+
let n = xt(e.session);
|
|
1334
|
+
return Ct(n), {
|
|
1257
1335
|
session: n,
|
|
1258
1336
|
launch: t
|
|
1259
1337
|
};
|
|
1260
1338
|
}
|
|
1261
1339
|
//#endregion
|
|
1262
1340
|
//#region src/v2/api/mintPublicSession.ts
|
|
1263
|
-
function
|
|
1341
|
+
function Tt() {
|
|
1264
1342
|
try {
|
|
1265
1343
|
if (typeof globalThis.location?.origin == "string" && globalThis.location.origin) return globalThis.location.origin;
|
|
1266
1344
|
} catch {}
|
|
1267
1345
|
}
|
|
1268
|
-
function
|
|
1346
|
+
function Et(e) {
|
|
1269
1347
|
return e ? e.trim().toUpperCase().replace(/-/g, "_") : "";
|
|
1270
1348
|
}
|
|
1271
|
-
function
|
|
1272
|
-
let n =
|
|
1349
|
+
function Dt(e, t) {
|
|
1350
|
+
let n = Tt(), r = Et(t.code), i = t.message.trim(), a = t.details ?? {};
|
|
1273
1351
|
if (r === "ORIGIN_NOT_ALLOWED" || /^Origin not allowed/i.test(i) && n) {
|
|
1274
1352
|
if (i.includes(e) && i.includes("allowed origin")) return t;
|
|
1275
1353
|
let r = typeof a.origin == "string" && a.origin || n || "(unknown origin)";
|
|
1276
|
-
return new
|
|
1354
|
+
return new st(`Your origin ${r} is not an allowed origin for experience ${e}. If you own this experience, sign in to the Liforma developer portal (app.liforma.ai), open Workspace → Settings → Origins, add ${r} to the list of allowed origins, and ensure “Allow public client-only embeds” is enabled.`, {
|
|
1277
1355
|
code: "ORIGIN_NOT_ALLOWED",
|
|
1278
1356
|
requestId: t.requestId,
|
|
1279
1357
|
status: t.status,
|
|
1280
1358
|
details: a
|
|
1281
1359
|
});
|
|
1282
1360
|
}
|
|
1283
|
-
return r === "BROWSER_EMBEDS_DISABLED" || /^Browser embeds are not enabled/i.test(i) ? i.includes("Allow public client-only embeds") ? t : new
|
|
1361
|
+
return r === "BROWSER_EMBEDS_DISABLED" || /^Browser embeds are not enabled/i.test(i) ? i.includes("Allow public client-only embeds") ? t : new st(`Browser embeds are not enabled for experience ${e}. If you own this experience, sign in to the Liforma developer portal (app.liforma.ai), open Workspace → Settings → Origins, and enable “Allow public client-only embeds”.`, {
|
|
1284
1362
|
code: "BROWSER_EMBEDS_DISABLED",
|
|
1285
1363
|
requestId: t.requestId,
|
|
1286
1364
|
status: t.status,
|
|
1287
1365
|
details: a
|
|
1288
|
-
}) : r === "EXPERIENCE_UNAVAILABLE" || /^Experience is not available\.?$/i.test(i) || /^Unknown experience\.?$/i.test(i) ? i.includes("No playable experience found") ? t : new
|
|
1366
|
+
}) : r === "EXPERIENCE_UNAVAILABLE" || /^Experience is not available\.?$/i.test(i) || /^Unknown experience\.?$/i.test(i) ? i.includes("No playable experience found") ? t : new st(`No playable experience found for “${e}”. Check that the experience id is correct (it should look like exp_…), and that the experience exists and is published in the Liforma developer portal (app.liforma.ai). Deleted, archived, and unpublished experiences cannot be started from a browser embed.`, {
|
|
1289
1367
|
code: "EXPERIENCE_UNAVAILABLE",
|
|
1290
1368
|
requestId: t.requestId,
|
|
1291
1369
|
status: t.status,
|
|
1292
1370
|
details: a
|
|
1293
1371
|
}) : t;
|
|
1294
1372
|
}
|
|
1295
|
-
function
|
|
1373
|
+
function Ot(e) {
|
|
1296
1374
|
let t = e?.locale?.trim();
|
|
1297
1375
|
if (t) return t;
|
|
1298
1376
|
let n = e?.language?.trim();
|
|
1299
1377
|
if (n) return n;
|
|
1300
1378
|
if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
|
|
1301
1379
|
}
|
|
1302
|
-
function
|
|
1380
|
+
function kt(e) {
|
|
1303
1381
|
let t = e?.secondaryLocale?.trim(), n = e?.learningLocale?.trim();
|
|
1304
|
-
if (t && n && t !== n) throw new
|
|
1382
|
+
if (t && n && t !== n) throw new st("secondaryLocale and learningLocale disagree; pass only one or make them equal.", { code: "INVALID_BODY" });
|
|
1305
1383
|
return t || n || void 0;
|
|
1306
1384
|
}
|
|
1307
|
-
function
|
|
1308
|
-
let n = { experienceId: e }, r =
|
|
1385
|
+
function At(e, t) {
|
|
1386
|
+
let n = { experienceId: e }, r = Ot(t);
|
|
1309
1387
|
r && (n.locale = r);
|
|
1310
|
-
let i =
|
|
1388
|
+
let i = kt(t);
|
|
1311
1389
|
i && (n.secondaryLocale = i), t?.mode && (n.mode = t.mode), t?.speechInputMode && (n.speechInputMode = t.speechInputMode), t?.speechOnly !== void 0 && (n.speechOnly = t.speechOnly);
|
|
1312
|
-
let a =
|
|
1390
|
+
let a = pt(t?.attribution);
|
|
1313
1391
|
return a && (n.attribution = a), t?.alreadyConverted?.length && (n.alreadyConverted = [...t.alreadyConverted]), n;
|
|
1314
1392
|
}
|
|
1315
|
-
async function
|
|
1316
|
-
let n =
|
|
1393
|
+
async function jt(e, t) {
|
|
1394
|
+
let n = it(), r = t?.idempotencyKey?.trim(), i = await fetch(`${n}/v1/browser-sessions`, {
|
|
1317
1395
|
method: "POST",
|
|
1318
1396
|
headers: {
|
|
1319
1397
|
"Content-Type": "application/json",
|
|
1320
1398
|
...r ? { "Idempotency-Key": r } : {}
|
|
1321
1399
|
},
|
|
1322
|
-
body: JSON.stringify(
|
|
1400
|
+
body: JSON.stringify(At(e, t))
|
|
1323
1401
|
});
|
|
1324
1402
|
if (!i.ok) {
|
|
1325
1403
|
let t = await i.text();
|
|
1326
|
-
throw
|
|
1404
|
+
throw Dt(e, lt(i.status, t, i.headers));
|
|
1327
1405
|
}
|
|
1328
1406
|
let a;
|
|
1329
1407
|
try {
|
|
1330
1408
|
a = await i.json();
|
|
1331
1409
|
} catch {
|
|
1332
|
-
throw new
|
|
1410
|
+
throw new st("Browser session mint returned invalid JSON.", {
|
|
1333
1411
|
code: "INVALID_RESPONSE",
|
|
1334
1412
|
status: i.status,
|
|
1335
1413
|
requestId: i.headers.get("Liforma-Request-Id") ?? void 0
|
|
1336
1414
|
});
|
|
1337
1415
|
}
|
|
1338
|
-
return
|
|
1416
|
+
return wt(a);
|
|
1339
1417
|
}
|
|
1340
|
-
async function
|
|
1341
|
-
let n =
|
|
1418
|
+
async function Mt(e, t) {
|
|
1419
|
+
let n = gt(e, t), r = new AbortController(), i = () => r.abort(t.signal?.reason);
|
|
1342
1420
|
t.signal?.aborted ? i() : t.signal?.addEventListener("abort", i, { once: !0 });
|
|
1343
1421
|
let a = globalThis.setTimeout(() => r.abort(new DOMException("Session endpoint timed out.", "TimeoutError")), t.timeoutMs ?? 3e4), o;
|
|
1344
1422
|
try {
|
|
@@ -1351,9 +1429,9 @@ async function wt(e, t) {
|
|
|
1351
1429
|
}
|
|
1352
1430
|
if (!o.ok) {
|
|
1353
1431
|
let e = await o.text();
|
|
1354
|
-
throw
|
|
1432
|
+
throw lt(o.status, e, o.headers);
|
|
1355
1433
|
}
|
|
1356
|
-
if (!o.headers.get("content-type")?.toLowerCase().includes("application/json")) throw new
|
|
1434
|
+
if (!o.headers.get("content-type")?.toLowerCase().includes("application/json")) throw new st("Session endpoint must return a JSON Session Launch response.", {
|
|
1357
1435
|
code: "INVALID_RESPONSE",
|
|
1358
1436
|
status: o.status,
|
|
1359
1437
|
requestId: o.headers.get("Liforma-Request-Id") ?? void 0
|
|
@@ -1362,20 +1440,20 @@ async function wt(e, t) {
|
|
|
1362
1440
|
try {
|
|
1363
1441
|
s = await o.json();
|
|
1364
1442
|
} catch {
|
|
1365
|
-
throw new
|
|
1443
|
+
throw new st("Session endpoint returned invalid JSON.", {
|
|
1366
1444
|
code: "INVALID_RESPONSE",
|
|
1367
1445
|
status: o.status,
|
|
1368
1446
|
requestId: o.headers.get("Liforma-Request-Id") ?? void 0
|
|
1369
1447
|
});
|
|
1370
1448
|
}
|
|
1371
|
-
return
|
|
1449
|
+
return wt(s);
|
|
1372
1450
|
}
|
|
1373
1451
|
//#endregion
|
|
1374
1452
|
//#region src/v2/conversationProcessor.ts
|
|
1375
|
-
function
|
|
1453
|
+
function Nt(e) {
|
|
1376
1454
|
return typeof e != "object" || !e ? !1 : typeof e[Symbol.asyncIterator] == "function";
|
|
1377
1455
|
}
|
|
1378
|
-
function
|
|
1456
|
+
function Pt(e) {
|
|
1379
1457
|
if (typeof e == "string") {
|
|
1380
1458
|
let t = e.trim();
|
|
1381
1459
|
if (!t) throw Error("conversationProcessor returned empty text.");
|
|
@@ -1389,24 +1467,24 @@ function Et(e) {
|
|
|
1389
1467
|
...e.behavior ? { behavior: e.behavior } : {}
|
|
1390
1468
|
};
|
|
1391
1469
|
}
|
|
1392
|
-
async function
|
|
1470
|
+
async function Ft(e, t) {
|
|
1393
1471
|
let n = await e(t);
|
|
1394
|
-
return
|
|
1472
|
+
return Nt(n) ? {
|
|
1395
1473
|
kind: "stream",
|
|
1396
1474
|
stream: n
|
|
1397
1475
|
} : {
|
|
1398
1476
|
kind: "complete",
|
|
1399
|
-
speech:
|
|
1477
|
+
speech: Pt(n)
|
|
1400
1478
|
};
|
|
1401
1479
|
}
|
|
1402
1480
|
//#endregion
|
|
1403
1481
|
//#region src/v2/embed/playerReachability.ts
|
|
1404
|
-
var
|
|
1405
|
-
function
|
|
1482
|
+
var It = "3002";
|
|
1483
|
+
function Lt(e) {
|
|
1406
1484
|
let t = new URL(e);
|
|
1407
|
-
return t.hostname === "localhost" || t.hostname === "127.0.0.1" ? `Cannot connect to the Liforma player at ${e} — nothing is listening on port ${t.port ||
|
|
1485
|
+
return t.hostname === "localhost" || t.hostname === "127.0.0.1" ? `Cannot connect to the Liforma player at ${e} — nothing is listening on port ${t.port || It}. Start the player dev server in player.liforma.ai (npm run dev).` : `Cannot connect to the Liforma player at ${e}. The embed did not load; check your network connection and player URL configuration.`;
|
|
1408
1486
|
}
|
|
1409
|
-
async function
|
|
1487
|
+
async function Rt(e, t) {
|
|
1410
1488
|
try {
|
|
1411
1489
|
await fetch(e, {
|
|
1412
1490
|
method: "GET",
|
|
@@ -1414,27 +1492,27 @@ async function At(e, t) {
|
|
|
1414
1492
|
signal: AbortSignal.timeout(8e3)
|
|
1415
1493
|
});
|
|
1416
1494
|
} catch {
|
|
1417
|
-
throw Error(
|
|
1495
|
+
throw Error(Lt(t));
|
|
1418
1496
|
}
|
|
1419
1497
|
}
|
|
1420
|
-
function
|
|
1498
|
+
function zt(e, t, n, r) {
|
|
1421
1499
|
try {
|
|
1422
1500
|
r && r.length > 0 ? e.postMessage(t, n, r) : e.postMessage(t, n);
|
|
1423
1501
|
} catch (e) {
|
|
1424
|
-
throw e instanceof DOMException && e.name === "SecurityError" ? Error(
|
|
1502
|
+
throw e instanceof DOMException && e.name === "SecurityError" ? Error(Lt(n), { cause: e }) : e;
|
|
1425
1503
|
}
|
|
1426
1504
|
}
|
|
1427
|
-
var
|
|
1428
|
-
function
|
|
1429
|
-
return typeof e == "number" &&
|
|
1505
|
+
var Bt = new Set([1, 2]);
|
|
1506
|
+
function Vt(e) {
|
|
1507
|
+
return typeof e == "number" && Bt.has(e);
|
|
1430
1508
|
}
|
|
1431
|
-
var
|
|
1432
|
-
function
|
|
1509
|
+
var Ht = 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("."));
|
|
1510
|
+
function Ut(e) {
|
|
1433
1511
|
if (!e || typeof e != "object") return null;
|
|
1434
1512
|
let t = e;
|
|
1435
|
-
if (!
|
|
1513
|
+
if (!Vt(t.schemaVersion) || !t.type || !Ht.has(t.type)) return null;
|
|
1436
1514
|
if (t.type === "embedReady" || t.type === "widgetReady" || t.type === "widgetExpand" || t.type === "widgetCollapse") return t;
|
|
1437
|
-
if (t.type === "fullWindow") {
|
|
1515
|
+
if (t.type === "fullWindow" || t.type === "theatre") {
|
|
1438
1516
|
let e = t.payload;
|
|
1439
1517
|
return !e || typeof e != "object" || typeof e.active != "boolean" ? null : t;
|
|
1440
1518
|
}
|
|
@@ -1455,10 +1533,10 @@ function Ft(e) {
|
|
|
1455
1533
|
let n = t.payload;
|
|
1456
1534
|
return !n || typeof n != "object" ? null : t;
|
|
1457
1535
|
}
|
|
1458
|
-
function
|
|
1536
|
+
function Wt(e, t, n) {
|
|
1459
1537
|
let r = e.trim();
|
|
1460
1538
|
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;
|
|
1539
|
+
let i = n?.startButton, a = n?.theme, o = n?.showFeedback, s = n?.interaction, c = n?.theatreButton, l = n?.theatre;
|
|
1462
1540
|
return {
|
|
1463
1541
|
type: "launch",
|
|
1464
1542
|
schemaVersion: 2,
|
|
@@ -1468,34 +1546,43 @@ function It(e, t, n) {
|
|
|
1468
1546
|
...i ? { startButton: i } : {},
|
|
1469
1547
|
...a ? { theme: a } : {},
|
|
1470
1548
|
...o === void 0 ? {} : { showFeedback: o },
|
|
1471
|
-
...s ? { interaction: s } : {}
|
|
1549
|
+
...s ? { interaction: s } : {},
|
|
1550
|
+
...c ? { theatreButton: !0 } : {},
|
|
1551
|
+
...l === void 0 ? {} : { theatre: l }
|
|
1472
1552
|
}
|
|
1473
1553
|
};
|
|
1474
1554
|
}
|
|
1475
|
-
function
|
|
1555
|
+
function Gt() {
|
|
1476
1556
|
return {
|
|
1477
1557
|
type: "parentHello",
|
|
1478
1558
|
schemaVersion: 2
|
|
1479
1559
|
};
|
|
1480
1560
|
}
|
|
1481
|
-
function
|
|
1561
|
+
function Kt(e) {
|
|
1482
1562
|
return {
|
|
1483
1563
|
type: "widgetSetChrome",
|
|
1484
1564
|
schemaVersion: 2,
|
|
1485
1565
|
payload: { mode: e }
|
|
1486
1566
|
};
|
|
1487
1567
|
}
|
|
1488
|
-
function
|
|
1568
|
+
function qt() {
|
|
1489
1569
|
return {
|
|
1490
1570
|
type: "widgetToggleAudioSettings",
|
|
1491
1571
|
schemaVersion: 2,
|
|
1492
1572
|
payload: {}
|
|
1493
1573
|
};
|
|
1494
1574
|
}
|
|
1575
|
+
function Jt(e) {
|
|
1576
|
+
return {
|
|
1577
|
+
type: "setTheatre",
|
|
1578
|
+
schemaVersion: 2,
|
|
1579
|
+
payload: { active: e }
|
|
1580
|
+
};
|
|
1581
|
+
}
|
|
1495
1582
|
//#endregion
|
|
1496
1583
|
//#region src/v2/embed/fullWindowHost.ts
|
|
1497
|
-
var
|
|
1498
|
-
function
|
|
1584
|
+
var Yt = "2147483000";
|
|
1585
|
+
function Xt(e) {
|
|
1499
1586
|
let { style: t } = e;
|
|
1500
1587
|
return {
|
|
1501
1588
|
position: t.position,
|
|
@@ -1513,11 +1600,11 @@ function Vt(e) {
|
|
|
1513
1600
|
maxHeight: t.maxHeight
|
|
1514
1601
|
};
|
|
1515
1602
|
}
|
|
1516
|
-
function
|
|
1603
|
+
function Zt(e) {
|
|
1517
1604
|
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 =
|
|
1605
|
+
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 = Yt, t.margin = "0", t.borderRadius = "0", t.maxWidth = "none", t.maxHeight = "none", e.dataset.liformaFullWindow = "1";
|
|
1519
1606
|
}
|
|
1520
|
-
function
|
|
1607
|
+
function Qt(e, t) {
|
|
1521
1608
|
if (delete e.dataset.liformaFullWindow, !t) {
|
|
1522
1609
|
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
1610
|
return;
|
|
@@ -1527,20 +1614,20 @@ function Ut(e, t) {
|
|
|
1527
1614
|
}
|
|
1528
1615
|
//#endregion
|
|
1529
1616
|
//#region src/v2/embed/iframeHost.ts
|
|
1530
|
-
function
|
|
1617
|
+
function $t(e) {
|
|
1531
1618
|
return e;
|
|
1532
1619
|
}
|
|
1533
1620
|
function Z() {
|
|
1534
1621
|
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
1622
|
}
|
|
1536
|
-
var
|
|
1537
|
-
function
|
|
1623
|
+
var en = 3e4;
|
|
1624
|
+
function tn(e) {
|
|
1538
1625
|
let t = e.container;
|
|
1539
1626
|
getComputedStyle(t).position === "static" && (t.style.position = "relative");
|
|
1540
1627
|
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 !==
|
|
1628
|
+
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"), n.setAttribute("fetchpriority", "high"), "fetchPriority" in n && (n.fetchPriority = "high");
|
|
1629
|
+
let r = !1, i = !1, a = null, o = null, s = (r) => {
|
|
1630
|
+
i !== r && (i = r, r ? (a = Xt(n), o = document.body.style.overflow, document.body.append(n), Zt(n), document.body.style.overflow = "hidden") : (t.append(n), Qt(n, a), a = null, o !== null && (document.body.style.overflow = o, o = null)), e.onFullWindowChange?.(r));
|
|
1544
1631
|
}, c = /* @__PURE__ */ new Map(), l = null, u = 0, d = 0, f = [], p = null, m = null, h = new Promise((e, t) => {
|
|
1545
1632
|
p = e, m = t;
|
|
1546
1633
|
}), g = () => {
|
|
@@ -1551,10 +1638,10 @@ function Kt(e) {
|
|
|
1551
1638
|
let i = Date.now();
|
|
1552
1639
|
if (d > 0 && i - d < 250) return;
|
|
1553
1640
|
d = i, g();
|
|
1554
|
-
let a =
|
|
1641
|
+
let a = Wt(t.launch, t.session, t.chrome), o = () => {
|
|
1555
1642
|
if (r) return;
|
|
1556
1643
|
let t = n.contentWindow;
|
|
1557
|
-
t &&
|
|
1644
|
+
t && zt(t, a, e.playerOrigin);
|
|
1558
1645
|
};
|
|
1559
1646
|
o();
|
|
1560
1647
|
for (let e = 1; e <= 12; e += 1) f.push(window.setTimeout(o, e * 75));
|
|
@@ -1562,17 +1649,17 @@ function Kt(e) {
|
|
|
1562
1649
|
r || !l || _(l);
|
|
1563
1650
|
}, y = () => {
|
|
1564
1651
|
if (u += 1, u === 1) {
|
|
1565
|
-
|
|
1652
|
+
Rt(e.src, e.playerOrigin).then(() => p?.(), (e) => m?.(e instanceof Error ? e : Error(String(e))));
|
|
1566
1653
|
return;
|
|
1567
1654
|
}
|
|
1568
1655
|
d = 0, v();
|
|
1569
1656
|
}, b = () => {
|
|
1570
|
-
u > 0 || m?.(Error(
|
|
1657
|
+
u > 0 || m?.(Error(Lt(e.playerOrigin)));
|
|
1571
1658
|
};
|
|
1572
1659
|
n.addEventListener("load", y), n.addEventListener("error", b);
|
|
1573
1660
|
let x = (t) => {
|
|
1574
1661
|
if (r || t.source !== n.contentWindow || t.origin !== e.playerOrigin) return;
|
|
1575
|
-
let i =
|
|
1662
|
+
let i = Ut(t.data);
|
|
1576
1663
|
if (i) switch (i.type) {
|
|
1577
1664
|
case "close":
|
|
1578
1665
|
e.onClose?.(i.payload);
|
|
@@ -1611,7 +1698,7 @@ function Kt(e) {
|
|
|
1611
1698
|
e.onUserSpeechEnded?.(i.payload);
|
|
1612
1699
|
break;
|
|
1613
1700
|
case "modeChange":
|
|
1614
|
-
e.onActivityChange?.(
|
|
1701
|
+
e.onActivityChange?.($t(i.payload.mode));
|
|
1615
1702
|
break;
|
|
1616
1703
|
case "activityChange":
|
|
1617
1704
|
e.onActivityChange?.(i.payload.activity);
|
|
@@ -1655,6 +1742,9 @@ function Kt(e) {
|
|
|
1655
1742
|
case "fullWindow":
|
|
1656
1743
|
s(i.payload.active);
|
|
1657
1744
|
break;
|
|
1745
|
+
case "theatre":
|
|
1746
|
+
e.onTheatreChange?.(i.payload.active);
|
|
1747
|
+
break;
|
|
1658
1748
|
case "interactionChange":
|
|
1659
1749
|
e.onInteractionChange?.(i.payload.interaction);
|
|
1660
1750
|
break;
|
|
@@ -1667,8 +1757,8 @@ function Kt(e) {
|
|
|
1667
1757
|
let S = (t, i) => {
|
|
1668
1758
|
if (r) return;
|
|
1669
1759
|
let a = n.contentWindow;
|
|
1670
|
-
if (!a) throw Error(
|
|
1671
|
-
|
|
1760
|
+
if (!a) throw Error(Lt(e.playerOrigin));
|
|
1761
|
+
zt(a, t, e.playerOrigin, i);
|
|
1672
1762
|
}, C = (e, t = 12e4, n) => {
|
|
1673
1763
|
let r = e.type !== "parentHello" && e.payload && "correlationId" in e.payload ? e.payload.correlationId : Z();
|
|
1674
1764
|
return e.type !== "parentHello" && e.payload && "correlationId" in e.payload || e.type !== "parentHello" && e.payload && (e.payload.correlationId = r), new Promise((i, a) => {
|
|
@@ -1685,7 +1775,7 @@ function Kt(e) {
|
|
|
1685
1775
|
return h;
|
|
1686
1776
|
},
|
|
1687
1777
|
postParentHello() {
|
|
1688
|
-
S(
|
|
1778
|
+
S(Gt());
|
|
1689
1779
|
},
|
|
1690
1780
|
postLaunch(e, t, n) {
|
|
1691
1781
|
r || (l = {
|
|
@@ -1707,10 +1797,13 @@ function Kt(e) {
|
|
|
1707
1797
|
throw Error("postManifest is deprecated; use postLaunch with an opaque launch string from SessionLaunchResponse.");
|
|
1708
1798
|
},
|
|
1709
1799
|
postWidgetSetChrome(e) {
|
|
1710
|
-
S(
|
|
1800
|
+
S(Kt(e));
|
|
1711
1801
|
},
|
|
1712
1802
|
postWidgetToggleAudioSettings() {
|
|
1713
|
-
S(
|
|
1803
|
+
S(qt());
|
|
1804
|
+
},
|
|
1805
|
+
postSetTheatre(e) {
|
|
1806
|
+
S(Jt(e));
|
|
1714
1807
|
},
|
|
1715
1808
|
speak(e) {
|
|
1716
1809
|
return C({
|
|
@@ -1832,7 +1925,7 @@ function Kt(e) {
|
|
|
1832
1925
|
audio: e.audio,
|
|
1833
1926
|
byteLength: e.byteLength
|
|
1834
1927
|
}
|
|
1835
|
-
},
|
|
1928
|
+
}, en, [e.audio]);
|
|
1836
1929
|
},
|
|
1837
1930
|
speechUtteranceSetTranscript(e) {
|
|
1838
1931
|
return C({
|
|
@@ -1994,7 +2087,7 @@ function Kt(e) {
|
|
|
1994
2087
|
}
|
|
1995
2088
|
//#endregion
|
|
1996
2089
|
//#region src/v2/embed/readyGate.ts
|
|
1997
|
-
function
|
|
2090
|
+
function nn(e) {
|
|
1998
2091
|
let t, n = !1, r = !1, i = () => {
|
|
1999
2092
|
r || !n || t === void 0 || (r = !0, e(t));
|
|
2000
2093
|
};
|
|
@@ -2009,9 +2102,9 @@ function qt(e) {
|
|
|
2009
2102
|
}
|
|
2010
2103
|
//#endregion
|
|
2011
2104
|
//#region src/v2/sdkRelease.ts
|
|
2012
|
-
var
|
|
2105
|
+
var rn = `sdk@${{
|
|
2013
2106
|
name: "@liforma/client",
|
|
2014
|
-
version: "0.4.
|
|
2107
|
+
version: "0.4.14",
|
|
2015
2108
|
type: "module",
|
|
2016
2109
|
description: "Liforma browser SDK — Experience sessions, speech API, and Svelte embed component.",
|
|
2017
2110
|
license: "MIT",
|
|
@@ -2172,6 +2265,8 @@ var Jt = `sdk@${{
|
|
|
2172
2265
|
"generate:location-discontinuities": "node scripts/generate-location-discontinuities.mjs",
|
|
2173
2266
|
"build:locations": "node scripts/build-locations.mjs",
|
|
2174
2267
|
"publish:locations": "node scripts/publish-locations.mjs",
|
|
2268
|
+
"publish:location-400x225": "node scripts/build-location-400x225.mjs",
|
|
2269
|
+
"test:location-400x225": "node scripts/test-location-400x225.mjs",
|
|
2175
2270
|
"verify:locations": "node scripts/verify-location-sources.mjs",
|
|
2176
2271
|
"publish:models": "node scripts/publish-models.mjs",
|
|
2177
2272
|
"publish:models:krea-int8": "node scripts/_upload-model-prefix.mjs text-to-image/lf-t2i-turbo-int8",
|
|
@@ -2201,6 +2296,7 @@ var Jt = `sdk@${{
|
|
|
2201
2296
|
"preview:test": "npm run build && npm run preview"
|
|
2202
2297
|
},
|
|
2203
2298
|
dependencies: {
|
|
2299
|
+
"@jsquash/avif": "^1.3.0",
|
|
2204
2300
|
"@jsquash/webp": "^1.5.0",
|
|
2205
2301
|
zod: "^4.4.3"
|
|
2206
2302
|
},
|
|
@@ -2230,50 +2326,54 @@ var Jt = `sdk@${{
|
|
|
2230
2326
|
vitest: "^4.1.10",
|
|
2231
2327
|
wrangler: "^4.101.0"
|
|
2232
2328
|
}
|
|
2233
|
-
}.version}`,
|
|
2234
|
-
function
|
|
2329
|
+
}.version}`, an = "https://player.liforma.ai/embed", on = "http://localhost:3002/embed";
|
|
2330
|
+
function sn() {
|
|
2235
2331
|
let e = globalThis.__LIFORMA_PLAYER_EMBED_URL;
|
|
2236
2332
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
2237
2333
|
if (typeof document > "u") return null;
|
|
2238
2334
|
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
2335
|
return t ? t.replace(/\/$/, "") : null;
|
|
2240
2336
|
}
|
|
2241
|
-
function
|
|
2242
|
-
let e =
|
|
2243
|
-
return e ? e.endsWith("/embed") ? e : `${e}/embed` :
|
|
2337
|
+
function cn() {
|
|
2338
|
+
let e = sn();
|
|
2339
|
+
return e ? e.endsWith("/embed") ? e : `${e}/embed` : ge() ? on : an;
|
|
2244
2340
|
}
|
|
2245
|
-
function
|
|
2341
|
+
function ln(e, t) {
|
|
2246
2342
|
return e?.trim() || t?.trim() || void 0;
|
|
2247
2343
|
}
|
|
2248
|
-
function
|
|
2249
|
-
let
|
|
2250
|
-
|
|
2251
|
-
let
|
|
2252
|
-
|
|
2344
|
+
function un(e, t, n, r, i, a, o, s, c, l, u, d, f) {
|
|
2345
|
+
let p = (e ?? cn()).replace(/\/$/, ""), m = p.endsWith("/embed") ? p : `${p}/embed`, h = new URL(m), g = n?.trim();
|
|
2346
|
+
g && h.searchParams.set("backdropId", g);
|
|
2347
|
+
let _ = r?.trim();
|
|
2348
|
+
_ && h.searchParams.set("avatarId", _);
|
|
2349
|
+
let v = d?.trim();
|
|
2350
|
+
v && h.searchParams.set("previewBg", v);
|
|
2351
|
+
let y = f?.trim();
|
|
2352
|
+
return y && h.searchParams.set("previewFg", y), (i === "face" || i === "medium") && h.searchParams.set("fit", i), c === "pip" && h.searchParams.set("stage", "pip"), l === "set" && h.searchParams.set("pipBackground", "set"), u === !1 && h.searchParams.set("pipShadow", "0"), a === "widget" && h.searchParams.set("ui", "widget"), o && h.searchParams.set("close", "1"), t && h.searchParams.set("debug", "true"), (s === 2 || s === 3 || s === 4) && h.searchParams.set("cast", String(s)), dn(h.toString());
|
|
2253
2353
|
}
|
|
2254
|
-
function
|
|
2354
|
+
function dn(e) {
|
|
2255
2355
|
if (typeof location > "u") return e;
|
|
2256
2356
|
let t = new URL(e);
|
|
2257
2357
|
return t.searchParams.set("parentOrigin", location.origin), t.toString();
|
|
2258
2358
|
}
|
|
2259
|
-
function
|
|
2359
|
+
function fn(e) {
|
|
2260
2360
|
return new URL(e).origin;
|
|
2261
2361
|
}
|
|
2262
2362
|
//#endregion
|
|
2263
2363
|
//#region src/v2/experienceEvents.ts
|
|
2264
|
-
function
|
|
2364
|
+
function pn() {
|
|
2265
2365
|
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
2366
|
}
|
|
2267
|
-
function
|
|
2367
|
+
function mn(e, t, n) {
|
|
2268
2368
|
return {
|
|
2269
|
-
id:
|
|
2369
|
+
id: pn(),
|
|
2270
2370
|
type: e,
|
|
2271
2371
|
sessionId: t,
|
|
2272
2372
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2273
2373
|
data: n
|
|
2274
2374
|
};
|
|
2275
2375
|
}
|
|
2276
|
-
function
|
|
2376
|
+
function hn() {
|
|
2277
2377
|
return {
|
|
2278
2378
|
ready: /* @__PURE__ */ new Set(),
|
|
2279
2379
|
started: /* @__PURE__ */ new Set(),
|
|
@@ -2294,39 +2394,39 @@ function on() {
|
|
|
2294
2394
|
conversationProcessorError: /* @__PURE__ */ new Set()
|
|
2295
2395
|
};
|
|
2296
2396
|
}
|
|
2297
|
-
function
|
|
2397
|
+
function gn(e, t, n) {
|
|
2298
2398
|
return e[t].add(n), () => e[t].delete(n);
|
|
2299
2399
|
}
|
|
2300
|
-
function
|
|
2400
|
+
function _n(e, t, n) {
|
|
2301
2401
|
for (let r of e[t]) r(n);
|
|
2302
2402
|
}
|
|
2303
|
-
function
|
|
2403
|
+
function vn(e) {
|
|
2304
2404
|
for (let t of Object.keys(e)) e[t].clear();
|
|
2305
2405
|
}
|
|
2306
2406
|
//#endregion
|
|
2307
2407
|
//#region src/v2/speech/types.ts
|
|
2308
|
-
function
|
|
2408
|
+
function yn(e) {
|
|
2309
2409
|
return "data" in e && "format" in e && e.format != null && !("track" in e);
|
|
2310
2410
|
}
|
|
2311
|
-
function
|
|
2411
|
+
function bn(e) {
|
|
2312
2412
|
return "url" in e && typeof e.url == "string";
|
|
2313
2413
|
}
|
|
2314
|
-
function
|
|
2414
|
+
function xn(e) {
|
|
2315
2415
|
if (!("track" in e)) return !1;
|
|
2316
2416
|
let t = e.track;
|
|
2317
2417
|
return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
|
|
2318
2418
|
}
|
|
2319
|
-
function
|
|
2320
|
-
return !
|
|
2419
|
+
function Sn(e) {
|
|
2420
|
+
return !yn(e) && !bn(e) && !xn(e) && "encoding" in e && typeof e.encoding == "string";
|
|
2321
2421
|
}
|
|
2322
|
-
var
|
|
2422
|
+
var Cn = [
|
|
2323
2423
|
8e3,
|
|
2324
2424
|
16e3,
|
|
2325
2425
|
22050,
|
|
2326
2426
|
24e3,
|
|
2327
2427
|
44100,
|
|
2328
2428
|
48e3
|
|
2329
|
-
],
|
|
2429
|
+
], wn = {
|
|
2330
2430
|
MAX_CHUNK_BYTES: 64 * 1024,
|
|
2331
2431
|
RECOMMENDED_CHUNK_MS_MIN: 20,
|
|
2332
2432
|
RECOMMENDED_CHUNK_MS_MAX: 200,
|
|
@@ -2337,14 +2437,14 @@ var mn = [
|
|
|
2337
2437
|
MAX_UTTERANCE_DURATION_MS: 9e4,
|
|
2338
2438
|
MAX_PENDING_WRITES: 8,
|
|
2339
2439
|
DEFAULT_WRITE_TIMEOUT_MS: 5e3
|
|
2340
|
-
},
|
|
2440
|
+
}, Tn = class extends Error {
|
|
2341
2441
|
operation;
|
|
2342
2442
|
requiredCapability;
|
|
2343
2443
|
name = "UnsupportedSpeechOperationError";
|
|
2344
2444
|
constructor(e, t) {
|
|
2345
2445
|
super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
|
|
2346
2446
|
}
|
|
2347
|
-
},
|
|
2447
|
+
}, En = class extends Error {
|
|
2348
2448
|
name = "SpeechUtteranceClosedError";
|
|
2349
2449
|
constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
|
|
2350
2450
|
super(e);
|
|
@@ -2354,72 +2454,72 @@ var mn = [
|
|
|
2354
2454
|
constructor(e, t) {
|
|
2355
2455
|
super(e, t);
|
|
2356
2456
|
}
|
|
2357
|
-
},
|
|
2457
|
+
}, Dn = class extends Error {
|
|
2358
2458
|
name = "SpeechBufferTimeoutError";
|
|
2359
2459
|
constructor(e = "Timed out waiting for speech buffer capacity.") {
|
|
2360
2460
|
super(e);
|
|
2361
2461
|
}
|
|
2362
2462
|
};
|
|
2363
|
-
function
|
|
2463
|
+
function On(e = "none") {
|
|
2364
2464
|
return {
|
|
2365
2465
|
mode: e,
|
|
2366
2466
|
trackedDurationMs: 0,
|
|
2367
2467
|
fallbackDurationMs: 0
|
|
2368
2468
|
};
|
|
2369
2469
|
}
|
|
2370
|
-
function
|
|
2371
|
-
return
|
|
2470
|
+
function kn(e) {
|
|
2471
|
+
return Cn.includes(e);
|
|
2372
2472
|
}
|
|
2373
|
-
function
|
|
2473
|
+
function An(e) {
|
|
2374
2474
|
if (e.encoding !== "pcm_s16le") throw new Q(`Unsupported audio encoding: ${e.encoding}`);
|
|
2375
2475
|
if (e.channels !== 1) throw new Q(`Unsupported channel count: ${e.channels}`);
|
|
2376
|
-
if (!
|
|
2476
|
+
if (!kn(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
2377
2477
|
}
|
|
2378
|
-
function
|
|
2379
|
-
if (
|
|
2380
|
-
|
|
2478
|
+
function jn(e) {
|
|
2479
|
+
if (yn(e)) {
|
|
2480
|
+
An(e.format);
|
|
2381
2481
|
return;
|
|
2382
2482
|
}
|
|
2383
|
-
if (
|
|
2483
|
+
if (bn(e)) {
|
|
2384
2484
|
if (!e.url.trim()) throw new Q("Audio URL must be non-empty.");
|
|
2385
|
-
if (e.sampleRate !== void 0 && !
|
|
2485
|
+
if (e.sampleRate !== void 0 && !kn(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
2386
2486
|
return;
|
|
2387
2487
|
}
|
|
2388
|
-
if (
|
|
2488
|
+
if (xn(e)) {
|
|
2389
2489
|
if (e.track.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
2390
|
-
if (e.sampleRate !== void 0 && !
|
|
2490
|
+
if (e.sampleRate !== void 0 && !kn(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
2391
2491
|
return;
|
|
2392
2492
|
}
|
|
2393
|
-
if (
|
|
2493
|
+
if (Sn(e)) {
|
|
2394
2494
|
let t = e.encoding.trim().toLowerCase();
|
|
2395
2495
|
if (!t) throw new Q("Encoded audio MIME type is required.");
|
|
2396
2496
|
if (t === "pcm_s16le") throw new Q("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
|
|
2397
|
-
if (e.sampleRate !== void 0 && !
|
|
2497
|
+
if (e.sampleRate !== void 0 && !kn(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
2398
2498
|
return;
|
|
2399
2499
|
}
|
|
2400
2500
|
throw new Q("Unsupported speech.play audio shape.");
|
|
2401
2501
|
}
|
|
2402
|
-
function
|
|
2403
|
-
if (e.format) return
|
|
2502
|
+
function Mn(e) {
|
|
2503
|
+
if (e.format) return An(e.format), e.format;
|
|
2404
2504
|
if (e.track) {
|
|
2405
2505
|
let t = {
|
|
2406
2506
|
encoding: "pcm_s16le",
|
|
2407
2507
|
sampleRate: e.sampleRate ?? 24e3,
|
|
2408
2508
|
channels: 1
|
|
2409
2509
|
};
|
|
2410
|
-
return
|
|
2510
|
+
return An(t), t;
|
|
2411
2511
|
}
|
|
2412
2512
|
throw new Q("createUtterance requires format or track.");
|
|
2413
2513
|
}
|
|
2414
|
-
function
|
|
2514
|
+
function Nn(e) {
|
|
2415
2515
|
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
2416
2516
|
}
|
|
2417
|
-
function
|
|
2517
|
+
function Pn(e) {
|
|
2418
2518
|
return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
|
|
2419
2519
|
}
|
|
2420
2520
|
//#endregion
|
|
2421
2521
|
//#region src/byo/pcm.ts
|
|
2422
|
-
function
|
|
2522
|
+
function Fn(e) {
|
|
2423
2523
|
let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
|
|
2424
2524
|
for (let t = 0; t < e.length; t++) {
|
|
2425
2525
|
let r = Math.max(-1, Math.min(1, e[t]));
|
|
@@ -2429,11 +2529,11 @@ function En(e) {
|
|
|
2429
2529
|
}
|
|
2430
2530
|
//#endregion
|
|
2431
2531
|
//#region src/byo/resample.ts
|
|
2432
|
-
function
|
|
2532
|
+
function In(e, t, n, r, i) {
|
|
2433
2533
|
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
2534
|
return ((a * i + o) * i + s) * i + c;
|
|
2435
2535
|
}
|
|
2436
|
-
function
|
|
2536
|
+
function Ln(e, t) {
|
|
2437
2537
|
if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
|
|
2438
2538
|
if (e === t) return {
|
|
2439
2539
|
fromRate: e,
|
|
@@ -2456,7 +2556,7 @@ function On(e, t) {
|
|
|
2456
2556
|
let a = [];
|
|
2457
2557
|
for (; i + 2 < r.length - 1;) {
|
|
2458
2558
|
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(
|
|
2559
|
+
a.push(In(r[o], r[e], r[s], r[c], t)), i += n;
|
|
2460
2560
|
}
|
|
2461
2561
|
let o = Math.max(0, Math.floor(i) - 1);
|
|
2462
2562
|
return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
|
|
@@ -2468,7 +2568,7 @@ function On(e, t) {
|
|
|
2468
2568
|
}
|
|
2469
2569
|
//#endregion
|
|
2470
2570
|
//#region src/byo/audioCapture.ts
|
|
2471
|
-
var
|
|
2571
|
+
var Rn = "liforma-pcm-capture", zn = `
|
|
2472
2572
|
class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
2473
2573
|
process(inputs) {
|
|
2474
2574
|
const ch = inputs[0] && inputs[0][0];
|
|
@@ -2480,29 +2580,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
|
2480
2580
|
return true;
|
|
2481
2581
|
}
|
|
2482
2582
|
}
|
|
2483
|
-
registerProcessor('${
|
|
2484
|
-
`,
|
|
2485
|
-
function
|
|
2486
|
-
return
|
|
2583
|
+
registerProcessor('${Rn}', LiformaPcmCaptureProcessor);
|
|
2584
|
+
`, Bn = null;
|
|
2585
|
+
function Vn() {
|
|
2586
|
+
return Bn ||= URL.createObjectURL(new Blob([zn], { type: "application/javascript" })), Bn;
|
|
2487
2587
|
}
|
|
2488
|
-
function
|
|
2588
|
+
function Hn() {
|
|
2489
2589
|
return window.AudioContext || window.webkitAudioContext || null;
|
|
2490
2590
|
}
|
|
2491
|
-
async function
|
|
2492
|
-
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o =
|
|
2591
|
+
async function Un(e) {
|
|
2592
|
+
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = Hn();
|
|
2493
2593
|
if (!o) throw Error("Web Audio is required for audio capture");
|
|
2494
2594
|
let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
|
|
2495
2595
|
l.gain.value = 0;
|
|
2496
|
-
let u = s.sampleRate, d =
|
|
2596
|
+
let u = s.sampleRate, d = Ln(u, n), f = !1, p = !1, m = (e) => {
|
|
2497
2597
|
if (f || i && !i()) return;
|
|
2498
2598
|
let t = d.push(e);
|
|
2499
|
-
t.length !== 0 && r(
|
|
2599
|
+
t.length !== 0 && r(Fn(t));
|
|
2500
2600
|
}, h = () => void 0;
|
|
2501
2601
|
return await (async () => {
|
|
2502
2602
|
if (typeof s.audioWorklet?.addModule != "function") return !1;
|
|
2503
2603
|
try {
|
|
2504
|
-
await s.audioWorklet.addModule(
|
|
2505
|
-
let e = new AudioWorkletNode(s,
|
|
2604
|
+
await s.audioWorklet.addModule(Vn());
|
|
2605
|
+
let e = new AudioWorkletNode(s, Rn, {
|
|
2506
2606
|
numberOfInputs: 1,
|
|
2507
2607
|
numberOfOutputs: 1,
|
|
2508
2608
|
outputChannelCount: [1]
|
|
@@ -2552,7 +2652,7 @@ async function Pn(e) {
|
|
|
2552
2652
|
}
|
|
2553
2653
|
//#endregion
|
|
2554
2654
|
//#region src/v2/speech/captureMediaStreamTrack.ts
|
|
2555
|
-
async function
|
|
2655
|
+
async function Wn(e) {
|
|
2556
2656
|
let { track: t, utterance: n, sampleRate: r, signal: i } = e;
|
|
2557
2657
|
if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Q("MediaStreamTrack is not available in this environment.");
|
|
2558
2658
|
if (t.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
@@ -2561,18 +2661,18 @@ async function Fn(e) {
|
|
|
2561
2661
|
s || (s = !0, c?.stop(), c = null);
|
|
2562
2662
|
};
|
|
2563
2663
|
try {
|
|
2564
|
-
c = await
|
|
2664
|
+
c = await Un({
|
|
2565
2665
|
mediaStream: a,
|
|
2566
2666
|
targetSampleRate: r,
|
|
2567
2667
|
shouldSend: () => !s && !i?.aborted,
|
|
2568
2668
|
onPcm: (e) => {
|
|
2569
2669
|
if (s || i?.aborted) return;
|
|
2570
|
-
let t =
|
|
2670
|
+
let t = Nn(e);
|
|
2571
2671
|
o = o.then(async () => {
|
|
2572
2672
|
if (s || i?.aborted) return;
|
|
2573
2673
|
let e = 0;
|
|
2574
2674
|
for (; e < t.byteLength;) {
|
|
2575
|
-
let r = Math.min(e +
|
|
2675
|
+
let r = Math.min(e + wn.MAX_CHUNK_BYTES, t.byteLength);
|
|
2576
2676
|
if ((r - e) % 2 == 1 && --r, r <= e) break;
|
|
2577
2677
|
let i = t.subarray(e, r);
|
|
2578
2678
|
e = r, i.byteLength !== 0 && await n.write(i);
|
|
@@ -2596,10 +2696,10 @@ async function Fn(e) {
|
|
|
2596
2696
|
}
|
|
2597
2697
|
//#endregion
|
|
2598
2698
|
//#region src/v2/speech/speechController.ts
|
|
2599
|
-
async function
|
|
2600
|
-
if (
|
|
2601
|
-
if (
|
|
2602
|
-
let t =
|
|
2699
|
+
async function Gn(e, t) {
|
|
2700
|
+
if (xn(e)) throw new Q("MediaStreamTrack play is handled on the host before embed.");
|
|
2701
|
+
if (yn(e)) {
|
|
2702
|
+
let t = Nn(e.data);
|
|
2603
2703
|
if (t.byteLength & 1) throw new Q("PCM byte length must be even.");
|
|
2604
2704
|
return {
|
|
2605
2705
|
kind: "pcm",
|
|
@@ -2607,17 +2707,17 @@ async function In(e, t) {
|
|
|
2607
2707
|
format: e.format
|
|
2608
2708
|
};
|
|
2609
2709
|
}
|
|
2610
|
-
if (
|
|
2710
|
+
if (bn(e)) return {
|
|
2611
2711
|
kind: "url",
|
|
2612
2712
|
url: e.url.trim(),
|
|
2613
2713
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
2614
2714
|
};
|
|
2615
|
-
if (!
|
|
2715
|
+
if (!Sn(e)) throw new Q("Unsupported speech.play audio shape.");
|
|
2616
2716
|
let n;
|
|
2617
2717
|
if (typeof Blob < "u" && e.data instanceof Blob) {
|
|
2618
2718
|
if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2619
2719
|
n = new Uint8Array(await e.data.arrayBuffer());
|
|
2620
|
-
} else n =
|
|
2720
|
+
} else n = Nn(e.data);
|
|
2621
2721
|
return {
|
|
2622
2722
|
kind: "encoded",
|
|
2623
2723
|
data: n.slice().buffer,
|
|
@@ -2625,10 +2725,10 @@ async function In(e, t) {
|
|
|
2625
2725
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
2626
2726
|
};
|
|
2627
2727
|
}
|
|
2628
|
-
function
|
|
2728
|
+
function Kn() {
|
|
2629
2729
|
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
2730
|
}
|
|
2631
|
-
function
|
|
2731
|
+
function qn(e, t = "completed") {
|
|
2632
2732
|
return {
|
|
2633
2733
|
utteranceId: e.speechId,
|
|
2634
2734
|
characterId: e.characterId,
|
|
@@ -2642,13 +2742,13 @@ function Rn(e, t = "completed") {
|
|
|
2642
2742
|
}
|
|
2643
2743
|
};
|
|
2644
2744
|
}
|
|
2645
|
-
function
|
|
2745
|
+
function Jn(e) {
|
|
2646
2746
|
return e instanceof Error ? e : new Q(String(e));
|
|
2647
2747
|
}
|
|
2648
|
-
function
|
|
2748
|
+
function Yn(e) {
|
|
2649
2749
|
return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
|
|
2650
2750
|
}
|
|
2651
|
-
var
|
|
2751
|
+
var Xn = class {
|
|
2652
2752
|
id;
|
|
2653
2753
|
characterId;
|
|
2654
2754
|
result;
|
|
@@ -2677,29 +2777,29 @@ var Vn = class {
|
|
|
2677
2777
|
queue: e.queue,
|
|
2678
2778
|
...e.transcript === void 0 ? {} : { transcript: e.transcript }
|
|
2679
2779
|
}).catch((e) => {
|
|
2680
|
-
throw this.fail(
|
|
2780
|
+
throw this.fail(Jn(e)), Jn(e);
|
|
2681
2781
|
}), this.signal?.addEventListener("abort", () => {
|
|
2682
2782
|
this.cancel();
|
|
2683
2783
|
}, { once: !0 });
|
|
2684
2784
|
}
|
|
2685
2785
|
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 =
|
|
2786
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new En();
|
|
2787
|
+
let n = Nn(e);
|
|
2688
2788
|
if (n.byteLength & 1) throw new Q("PCM chunk byte length must be even (complete s16 samples).");
|
|
2689
|
-
if (n.byteLength >
|
|
2789
|
+
if (n.byteLength > wn.MAX_CHUNK_BYTES) throw new Q(`PCM chunk exceeds MAX_CHUNK_BYTES (${wn.MAX_CHUNK_BYTES}).`);
|
|
2690
2790
|
if (n.byteLength === 0) return;
|
|
2691
|
-
let r = t?.timeoutMs ??
|
|
2791
|
+
let r = t?.timeoutMs ?? wn.DEFAULT_WRITE_TIMEOUT_MS;
|
|
2692
2792
|
await this.acquireWriteSlot(r);
|
|
2693
2793
|
let i = n.byteLength / 2 / this.sampleRate * 1e3;
|
|
2694
|
-
if (this.bufferedMs + i >
|
|
2794
|
+
if (this.bufferedMs + i > wn.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new Q("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
|
|
2695
2795
|
let a = async () => {
|
|
2696
|
-
if (this.closed || this.settled) throw new
|
|
2796
|
+
if (this.closed || this.settled) throw new En();
|
|
2697
2797
|
let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
|
|
2698
2798
|
utteranceId: this.id,
|
|
2699
2799
|
audio: t.buffer,
|
|
2700
2800
|
byteLength: t.byteLength
|
|
2701
2801
|
}), a = await Promise.race([i, new Promise((e, t) => {
|
|
2702
|
-
setTimeout(() => t(new
|
|
2802
|
+
setTimeout(() => t(new Dn()), r);
|
|
2703
2803
|
})]);
|
|
2704
2804
|
this.bufferedMs = Math.max(0, a.bufferedMs);
|
|
2705
2805
|
}, o = this.writeChain.then(a, a);
|
|
@@ -2711,7 +2811,7 @@ var Vn = class {
|
|
|
2711
2811
|
}
|
|
2712
2812
|
}
|
|
2713
2813
|
async setTranscript(e) {
|
|
2714
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2814
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new En();
|
|
2715
2815
|
await this.requireHost().speechUtteranceSetTranscript({
|
|
2716
2816
|
utteranceId: this.id,
|
|
2717
2817
|
transcript: e
|
|
@@ -2728,7 +2828,7 @@ var Vn = class {
|
|
|
2728
2828
|
});
|
|
2729
2829
|
return this.resolve(t), t;
|
|
2730
2830
|
} catch (e) {
|
|
2731
|
-
let t =
|
|
2831
|
+
let t = Jn(e);
|
|
2732
2832
|
throw this.fail(t), t;
|
|
2733
2833
|
}
|
|
2734
2834
|
}
|
|
@@ -2746,11 +2846,11 @@ var Vn = class {
|
|
|
2746
2846
|
characterId: this.characterId,
|
|
2747
2847
|
status: "cancelled",
|
|
2748
2848
|
durationMs: 0,
|
|
2749
|
-
animation:
|
|
2849
|
+
animation: On("none")
|
|
2750
2850
|
};
|
|
2751
2851
|
return this.resolve(t), t;
|
|
2752
2852
|
} catch (e) {
|
|
2753
|
-
let t =
|
|
2853
|
+
let t = Jn(e);
|
|
2754
2854
|
throw this.fail(t), t;
|
|
2755
2855
|
}
|
|
2756
2856
|
}
|
|
@@ -2763,19 +2863,19 @@ var Vn = class {
|
|
|
2763
2863
|
return e;
|
|
2764
2864
|
}
|
|
2765
2865
|
resolve(e) {
|
|
2766
|
-
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new
|
|
2866
|
+
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new En()));
|
|
2767
2867
|
}
|
|
2768
2868
|
fail(e) {
|
|
2769
2869
|
this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
|
|
2770
2870
|
}
|
|
2771
2871
|
async acquireWriteSlot(e) {
|
|
2772
|
-
if (this.pendingWriteCount <
|
|
2872
|
+
if (this.pendingWriteCount < wn.MAX_PENDING_WRITES) {
|
|
2773
2873
|
this.pendingWriteCount += 1;
|
|
2774
2874
|
return;
|
|
2775
2875
|
}
|
|
2776
2876
|
await new Promise((t, n) => {
|
|
2777
2877
|
let r = setTimeout(() => {
|
|
2778
|
-
n(new
|
|
2878
|
+
n(new Dn());
|
|
2779
2879
|
}, e);
|
|
2780
2880
|
this.pendingWriteWaiters.push({
|
|
2781
2881
|
resolve: () => {
|
|
@@ -2794,13 +2894,13 @@ var Vn = class {
|
|
|
2794
2894
|
for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
|
|
2795
2895
|
}
|
|
2796
2896
|
};
|
|
2797
|
-
function
|
|
2897
|
+
function Zn(e) {
|
|
2798
2898
|
let t = null, n = (t, n) => {
|
|
2799
|
-
if (!e.getCapabilities()[n]) throw new
|
|
2899
|
+
if (!e.getCapabilities()[n]) throw new Tn(t, n);
|
|
2800
2900
|
}, r = {
|
|
2801
2901
|
async speak(r) {
|
|
2802
2902
|
if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
|
|
2803
|
-
let i =
|
|
2903
|
+
let i = Pn(r.queue ?? "append");
|
|
2804
2904
|
i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
|
|
2805
2905
|
let a = e.getIframeHost();
|
|
2806
2906
|
if (!a) throw new Q("Speech session is not attached.");
|
|
@@ -2820,41 +2920,41 @@ function Hn(e) {
|
|
|
2820
2920
|
return;
|
|
2821
2921
|
}
|
|
2822
2922
|
t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
|
|
2823
|
-
t.removeEventListener("abort", s), n(
|
|
2923
|
+
t.removeEventListener("abort", s), n(qn(e, "completed"));
|
|
2824
2924
|
}, (a) => {
|
|
2825
|
-
if (t.removeEventListener("abort", s),
|
|
2925
|
+
if (t.removeEventListener("abort", s), Yn(a)) {
|
|
2826
2926
|
n({
|
|
2827
2927
|
utteranceId: "utt_interrupted",
|
|
2828
2928
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2829
2929
|
status: "interrupted",
|
|
2830
2930
|
durationMs: 0,
|
|
2831
2931
|
transcript: r.text,
|
|
2832
|
-
animation:
|
|
2932
|
+
animation: On("none")
|
|
2833
2933
|
});
|
|
2834
2934
|
return;
|
|
2835
2935
|
}
|
|
2836
|
-
i(
|
|
2936
|
+
i(Jn(a));
|
|
2837
2937
|
});
|
|
2838
2938
|
});
|
|
2839
2939
|
}
|
|
2840
2940
|
try {
|
|
2841
|
-
return
|
|
2941
|
+
return qn(await o, "completed");
|
|
2842
2942
|
} catch (t) {
|
|
2843
|
-
if (
|
|
2943
|
+
if (Yn(t)) return {
|
|
2844
2944
|
utteranceId: "utt_interrupted",
|
|
2845
2945
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2846
2946
|
status: "interrupted",
|
|
2847
2947
|
durationMs: 0,
|
|
2848
2948
|
transcript: r.text,
|
|
2849
|
-
animation:
|
|
2949
|
+
animation: On("none")
|
|
2850
2950
|
};
|
|
2851
|
-
throw
|
|
2951
|
+
throw Jn(t);
|
|
2852
2952
|
}
|
|
2853
2953
|
},
|
|
2854
2954
|
async play(i) {
|
|
2855
|
-
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"),
|
|
2955
|
+
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), jn(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2856
2956
|
let a = i.queue ?? "append";
|
|
2857
|
-
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)),
|
|
2957
|
+
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), xn(i.audio)) {
|
|
2858
2958
|
let e = i.audio.sampleRate ?? 24e3;
|
|
2859
2959
|
return r.createUtterance({
|
|
2860
2960
|
format: {
|
|
@@ -2870,7 +2970,7 @@ function Hn(e) {
|
|
|
2870
2970
|
}
|
|
2871
2971
|
let o = e.getIframeHost();
|
|
2872
2972
|
if (!o) throw new Q("Speech session is not attached.");
|
|
2873
|
-
let s = await
|
|
2973
|
+
let s = await Gn(i.audio, i.signal);
|
|
2874
2974
|
return o.speechPlay({
|
|
2875
2975
|
source: s,
|
|
2876
2976
|
characterId: i.characterId,
|
|
@@ -2882,13 +2982,13 @@ function Hn(e) {
|
|
|
2882
2982
|
},
|
|
2883
2983
|
createUtterance(r) {
|
|
2884
2984
|
e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
|
|
2885
|
-
let i =
|
|
2985
|
+
let i = Mn(r);
|
|
2886
2986
|
if (r.track && r.track.kind !== "audio") throw new Q("createUtterance track must be an audio MediaStreamTrack.");
|
|
2887
2987
|
let a = r.queue ?? "replace-active";
|
|
2888
2988
|
if (a !== "replace-active" && a !== "replace-all") throw new Q("createUtterance queue must be replace-active or replace-all.");
|
|
2889
2989
|
e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
|
|
2890
|
-
let o = new
|
|
2891
|
-
id:
|
|
2990
|
+
let o = new Xn({
|
|
2991
|
+
id: Kn(),
|
|
2892
2992
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2893
2993
|
format: i,
|
|
2894
2994
|
queue: a,
|
|
@@ -2900,7 +3000,7 @@ function Hn(e) {
|
|
|
2900
3000
|
t === o && (t = null);
|
|
2901
3001
|
}), r.track && (async () => {
|
|
2902
3002
|
try {
|
|
2903
|
-
if (await
|
|
3003
|
+
if (await Wn({
|
|
2904
3004
|
track: r.track,
|
|
2905
3005
|
utterance: o,
|
|
2906
3006
|
sampleRate: i.sampleRate,
|
|
@@ -2928,16 +3028,16 @@ function Hn(e) {
|
|
|
2928
3028
|
}
|
|
2929
3029
|
//#endregion
|
|
2930
3030
|
//#region src/v2/types/sessionInteraction.ts
|
|
2931
|
-
function
|
|
3031
|
+
function Qn(e) {
|
|
2932
3032
|
let t = e?.trim();
|
|
2933
3033
|
return t === "full" || t === "face" || t === "medium" ? t : void 0;
|
|
2934
3034
|
}
|
|
2935
3035
|
//#endregion
|
|
2936
3036
|
//#region src/v2/experience.ts
|
|
2937
|
-
function
|
|
3037
|
+
function $n(e) {
|
|
2938
3038
|
return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
|
|
2939
3039
|
}
|
|
2940
|
-
var
|
|
3040
|
+
var er = class e {
|
|
2941
3041
|
bootstrap;
|
|
2942
3042
|
conversationProcessor;
|
|
2943
3043
|
iframeHost = null;
|
|
@@ -2954,19 +3054,20 @@ var Gn = class e {
|
|
|
2954
3054
|
pendingStage = null;
|
|
2955
3055
|
pendingPipBackground = null;
|
|
2956
3056
|
pendingPipShadow = null;
|
|
3057
|
+
pendingTheatre = null;
|
|
2957
3058
|
lastInteraction = null;
|
|
2958
3059
|
closeHandlers = [];
|
|
2959
|
-
eventRegistry =
|
|
3060
|
+
eventRegistry = hn();
|
|
2960
3061
|
readyEnvelope = null;
|
|
2961
3062
|
startedEnvelope = null;
|
|
2962
3063
|
sessionMintedEnvelope = null;
|
|
2963
3064
|
conversationCache = [];
|
|
2964
3065
|
speech;
|
|
2965
3066
|
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 =
|
|
3067
|
+
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 = Zn({
|
|
2967
3068
|
getIframeHost: () => this.iframeHost,
|
|
2968
3069
|
assertSessionStarted: () => this.assertSessionStarted(),
|
|
2969
|
-
getCapabilities: () =>
|
|
3070
|
+
getCapabilities: () => tr(this.resolvedSession),
|
|
2970
3071
|
getActiveCharacterId: () => "character_unknown",
|
|
2971
3072
|
onProcessorInterrupt: () => {
|
|
2972
3073
|
this.processorAbortController?.abort(), this.processorAbortController = null;
|
|
@@ -2987,6 +3088,8 @@ var Gn = class e {
|
|
|
2987
3088
|
embedBaseUrl: t.embedBaseUrl,
|
|
2988
3089
|
debug: t.debug,
|
|
2989
3090
|
speechOnly: t.speechOnly,
|
|
3091
|
+
previewBackground: t.previewBackground,
|
|
3092
|
+
previewForeground: t.previewForeground,
|
|
2990
3093
|
ui: t.ui,
|
|
2991
3094
|
onStart: t.onStart,
|
|
2992
3095
|
onUserTranscript: t.onUserTranscript,
|
|
@@ -3010,6 +3113,8 @@ var Gn = class e {
|
|
|
3010
3113
|
mode: t.mode,
|
|
3011
3114
|
speechInputMode: t.speechInputMode,
|
|
3012
3115
|
speechOnly: t.speechOnly,
|
|
3116
|
+
previewBackground: t.previewBackground,
|
|
3117
|
+
previewForeground: t.previewForeground,
|
|
3013
3118
|
attribution: t.attribution,
|
|
3014
3119
|
alreadyConverted: t.alreadyConverted,
|
|
3015
3120
|
ui: t.ui,
|
|
@@ -3033,6 +3138,8 @@ var Gn = class e {
|
|
|
3033
3138
|
mode: t.mode,
|
|
3034
3139
|
speechInputMode: t.speechInputMode,
|
|
3035
3140
|
speechOnly: t.speechOnly,
|
|
3141
|
+
previewBackground: t.previewBackground,
|
|
3142
|
+
previewForeground: t.previewForeground,
|
|
3036
3143
|
attribution: t.attribution,
|
|
3037
3144
|
alreadyConverted: t.alreadyConverted,
|
|
3038
3145
|
ui: t.ui,
|
|
@@ -3049,7 +3156,7 @@ var Gn = class e {
|
|
|
3049
3156
|
return null;
|
|
3050
3157
|
}
|
|
3051
3158
|
on(e, t) {
|
|
3052
|
-
let n =
|
|
3159
|
+
let n = gn(this.eventRegistry, e, t);
|
|
3053
3160
|
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
3161
|
}
|
|
3055
3162
|
async attach(e) {
|
|
@@ -3063,13 +3170,13 @@ var Gn = class e {
|
|
|
3063
3170
|
if (this.closed) throw Error("Session has ended.");
|
|
3064
3171
|
if (this.attached && this.iframeHost) return this.createPlayerFacade();
|
|
3065
3172
|
this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
|
|
3066
|
-
let t = this.bootstrap.embedBaseUrl ??
|
|
3173
|
+
let t = this.bootstrap.embedBaseUrl ?? cn(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = un(t, n, r ? void 0 : ln(this.bootstrap.backdropId, this.bootstrap.locationId), r ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, $n(e), this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.castSize, e.stage, e.pipBackground, e.pipShadow, r ? void 0 : this.bootstrap.previewBackground, r ? void 0 : this.bootstrap.previewForeground), a = fn(i), o = null, s = new Promise((e) => {
|
|
3067
3174
|
o = e;
|
|
3068
3175
|
}), c = null, l = new Promise((e) => {
|
|
3069
3176
|
c = e;
|
|
3070
|
-
}), u =
|
|
3177
|
+
}), u = nn((e) => {
|
|
3071
3178
|
this.readyEnvelope ||= (this.resolvedSession = e, this.emitWrapped("ready", { session: e }));
|
|
3072
|
-
}), d = this.bootstrap.onUserTranscript, f =
|
|
3179
|
+
}), d = this.bootstrap.onUserTranscript, f = tn({
|
|
3073
3180
|
container: e.container,
|
|
3074
3181
|
src: i,
|
|
3075
3182
|
playerOrigin: a,
|
|
@@ -3132,10 +3239,11 @@ var Gn = class e {
|
|
|
3132
3239
|
onWidgetAudioSettings: (t) => e.onWidgetAudioSettings?.(t),
|
|
3133
3240
|
onWidgetDragStart: (t) => e.onWidgetDragStart?.(t),
|
|
3134
3241
|
onWidgetDragMove: (t) => e.onWidgetDragMove?.(t),
|
|
3135
|
-
onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t)
|
|
3242
|
+
onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t),
|
|
3243
|
+
onTheatreChange: (t) => e.onTheatreChange?.(t)
|
|
3136
3244
|
});
|
|
3137
3245
|
this.iframeHost = f;
|
|
3138
|
-
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(),
|
|
3246
|
+
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), Mt(this.bootstrap.sessionEndpoint, {
|
|
3139
3247
|
experienceId: this.bootstrap.experienceId,
|
|
3140
3248
|
locale: this.bootstrap.locale,
|
|
3141
3249
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
@@ -3147,7 +3255,7 @@ var Gn = class e {
|
|
|
3147
3255
|
attribution: this.bootstrap.attribution,
|
|
3148
3256
|
alreadyConverted: this.bootstrap.alreadyConverted,
|
|
3149
3257
|
signal: this.endpointAbortController.signal
|
|
3150
|
-
})) : this.bootstrap.kind === "public" ?
|
|
3258
|
+
})) : this.bootstrap.kind === "public" ? jt(this.bootstrap.experienceId, {
|
|
3151
3259
|
locale: this.bootstrap.locale,
|
|
3152
3260
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
3153
3261
|
learningLocale: this.bootstrap.learningLocale,
|
|
@@ -3171,7 +3279,7 @@ var Gn = class e {
|
|
|
3171
3279
|
operation: "attach",
|
|
3172
3280
|
message: e instanceof Error ? e.message : String(e),
|
|
3173
3281
|
stack: e instanceof Error ? e.stack : void 0,
|
|
3174
|
-
release:
|
|
3282
|
+
release: rn
|
|
3175
3283
|
});
|
|
3176
3284
|
} catch {}
|
|
3177
3285
|
throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), e;
|
|
@@ -3183,16 +3291,20 @@ var Gn = class e {
|
|
|
3183
3291
|
if (!g) throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), Error("Session Launch response did not include a launch token.");
|
|
3184
3292
|
this.launchToken = g;
|
|
3185
3293
|
let v = _ ?? (this.bootstrap.kind === "launch" ? this.bootstrap.session : void 0);
|
|
3186
|
-
return v && !this.sessionMintedEnvelope && (this.resolvedSession = v, this.sessionMintedEnvelope = this.emitWrapped("sessionMinted", { session: v })), _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" &&
|
|
3294
|
+
return v && !this.sessionMintedEnvelope && (this.resolvedSession = v, this.sessionMintedEnvelope = this.emitWrapped("sessionMinted", { session: v })), _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" && Ct(_), f.postLaunch(g, _, {
|
|
3187
3295
|
startButton: e.startButton,
|
|
3188
3296
|
theme: e.theme,
|
|
3189
3297
|
showFeedback: e.showFeedback,
|
|
3190
|
-
interaction: e.interaction
|
|
3298
|
+
interaction: e.interaction,
|
|
3299
|
+
...e.theatreButton ? { theatreButton: !0 } : {},
|
|
3300
|
+
...e.theatre === void 0 ? {} : { theatre: e.theatre }
|
|
3191
3301
|
}), u.setValue(_)) : f.postLaunch(g, void 0, {
|
|
3192
3302
|
startButton: e.startButton,
|
|
3193
3303
|
theme: e.theme,
|
|
3194
3304
|
showFeedback: e.showFeedback,
|
|
3195
|
-
interaction: e.interaction
|
|
3305
|
+
interaction: e.interaction,
|
|
3306
|
+
...e.theatreButton ? { theatreButton: !0 } : {},
|
|
3307
|
+
...e.theatre === void 0 ? {} : { theatre: e.theatre }
|
|
3196
3308
|
}), await Promise.race([s, new Promise((e, t) => {
|
|
3197
3309
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player loading UI.")), 12e4);
|
|
3198
3310
|
})]).catch((e) => {
|
|
@@ -3203,7 +3315,7 @@ var Gn = class e {
|
|
|
3203
3315
|
operation: "attach",
|
|
3204
3316
|
message: e instanceof Error ? e.message : String(e),
|
|
3205
3317
|
stack: e instanceof Error ? e.stack : void 0,
|
|
3206
|
-
release:
|
|
3318
|
+
release: rn
|
|
3207
3319
|
});
|
|
3208
3320
|
} catch {}
|
|
3209
3321
|
throw e;
|
|
@@ -3217,11 +3329,11 @@ var Gn = class e {
|
|
|
3217
3329
|
operation: "attach",
|
|
3218
3330
|
message: e instanceof Error ? e.message : String(e),
|
|
3219
3331
|
stack: e instanceof Error ? e.stack : void 0,
|
|
3220
|
-
release:
|
|
3332
|
+
release: rn
|
|
3221
3333
|
});
|
|
3222
3334
|
} catch {}
|
|
3223
3335
|
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();
|
|
3336
|
+
}), 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
3337
|
}
|
|
3226
3338
|
async startListening() {
|
|
3227
3339
|
this.assertSessionStarted(), await this.iframeHost.startListening();
|
|
@@ -3235,6 +3347,10 @@ var Gn = class e {
|
|
|
3235
3347
|
getConversation() {
|
|
3236
3348
|
return this.conversationCache;
|
|
3237
3349
|
}
|
|
3350
|
+
setTheatre(e) {
|
|
3351
|
+
if (this.closed) throw Error("Session has ended.");
|
|
3352
|
+
this.pendingTheatre = e, this.iframeHost?.postSetTheatre(e);
|
|
3353
|
+
}
|
|
3238
3354
|
setWidgetChrome(e) {
|
|
3239
3355
|
this.iframeHost?.postWidgetSetChrome(e);
|
|
3240
3356
|
}
|
|
@@ -3245,7 +3361,7 @@ var Gn = class e {
|
|
|
3245
3361
|
this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
|
|
3246
3362
|
}
|
|
3247
3363
|
async setFit(e) {
|
|
3248
|
-
let t =
|
|
3364
|
+
let t = Qn(e);
|
|
3249
3365
|
if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
|
|
3250
3366
|
if (this.closed) throw Error("Session has ended.");
|
|
3251
3367
|
this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
|
|
@@ -3295,7 +3411,7 @@ var Gn = class e {
|
|
|
3295
3411
|
this.close();
|
|
3296
3412
|
}
|
|
3297
3413
|
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,
|
|
3414
|
+
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, vn(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.lastInteraction = null, this.attached = !1);
|
|
3299
3415
|
}
|
|
3300
3416
|
resolveMintInteraction() {
|
|
3301
3417
|
return this.bootstrap.kind === "launch" ? {} : {
|
|
@@ -3307,8 +3423,8 @@ var Gn = class e {
|
|
|
3307
3423
|
return this.resolvedSession?.id ?? "";
|
|
3308
3424
|
}
|
|
3309
3425
|
emitWrapped(e, t) {
|
|
3310
|
-
let n =
|
|
3311
|
-
return
|
|
3426
|
+
let n = mn(e, this.getSessionId(), t);
|
|
3427
|
+
return _n(this.eventRegistry, e, n), n;
|
|
3312
3428
|
}
|
|
3313
3429
|
queueProcessorTurn(e) {
|
|
3314
3430
|
if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
|
|
@@ -3317,7 +3433,7 @@ var Gn = class e {
|
|
|
3317
3433
|
let n = this.processorAbortController.signal;
|
|
3318
3434
|
this.processorChain = this.processorChain.then(async () => {
|
|
3319
3435
|
if (!n.aborted) try {
|
|
3320
|
-
let r = await
|
|
3436
|
+
let r = await Ft(t, {
|
|
3321
3437
|
utteranceId: e.utteranceId,
|
|
3322
3438
|
text: e.text,
|
|
3323
3439
|
conversation: this.conversationCache,
|
|
@@ -3367,7 +3483,7 @@ var Gn = class e {
|
|
|
3367
3483
|
};
|
|
3368
3484
|
}
|
|
3369
3485
|
};
|
|
3370
|
-
function
|
|
3486
|
+
function tr(e) {
|
|
3371
3487
|
return e ? {
|
|
3372
3488
|
textSpeech: e.capabilities.speech.output,
|
|
3373
3489
|
externalSpeechAudio: e.capabilities.speech.externalAudio
|
|
@@ -3378,41 +3494,41 @@ function Kn(e) {
|
|
|
3378
3494
|
}
|
|
3379
3495
|
//#endregion
|
|
3380
3496
|
//#region src/widget/dockGeometry.ts
|
|
3381
|
-
var
|
|
3382
|
-
function
|
|
3497
|
+
var nr = "(min-width: 768px)", rr = 24, ir = .5, ar = 1200, or = .85, sr = 9 / 16;
|
|
3498
|
+
function cr() {
|
|
3383
3499
|
if (typeof window > "u") return 800;
|
|
3384
3500
|
let e = window.screen?.availHeight;
|
|
3385
3501
|
return typeof e == "number" && e > 0 ? e : window.innerHeight;
|
|
3386
3502
|
}
|
|
3387
|
-
function
|
|
3388
|
-
let i = Math.max(160, Math.min(t - n * 2, t *
|
|
3389
|
-
return s > a && (s = a, o = s /
|
|
3503
|
+
function lr(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = rr, r = typeof window < "u" ? cr() : 800) {
|
|
3504
|
+
let i = Math.max(160, Math.min(t - n * 2, t * or)), a = Math.max(120, e - n * 2), o = Math.min(r * ir, ar, i), s = o * sr;
|
|
3505
|
+
return s > a && (s = a, o = s / sr, o > i && (o = i, s = o * sr)), {
|
|
3390
3506
|
width: Math.round(s),
|
|
3391
3507
|
height: Math.round(o)
|
|
3392
3508
|
};
|
|
3393
3509
|
}
|
|
3394
|
-
function
|
|
3510
|
+
function ur(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = rr) {
|
|
3395
3511
|
return {
|
|
3396
3512
|
left: Math.max(r, t - e.width - r),
|
|
3397
3513
|
top: Math.max(r, n - e.height - r)
|
|
3398
3514
|
};
|
|
3399
3515
|
}
|
|
3400
|
-
function
|
|
3516
|
+
function dr(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = rr) {
|
|
3401
3517
|
let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
|
|
3402
3518
|
return {
|
|
3403
3519
|
left: Math.min(Math.max(a, e), o),
|
|
3404
3520
|
top: Math.min(Math.max(a, t), s)
|
|
3405
3521
|
};
|
|
3406
3522
|
}
|
|
3407
|
-
function
|
|
3408
|
-
return e(
|
|
3523
|
+
function fr(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
|
|
3524
|
+
return e(nr).matches;
|
|
3409
3525
|
}
|
|
3410
3526
|
//#endregion
|
|
3411
3527
|
//#region src/widget/mountExperienceWidget.ts
|
|
3412
|
-
function
|
|
3528
|
+
function pr(e) {
|
|
3413
3529
|
return e === "bottom-right" || e === "bottom-left" ? e : "static";
|
|
3414
3530
|
}
|
|
3415
|
-
function
|
|
3531
|
+
function mr(e) {
|
|
3416
3532
|
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
3417
3533
|
let t = typeof e == "string" ? e.trim() : "";
|
|
3418
3534
|
return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
|
|
@@ -3420,10 +3536,10 @@ function ar(e) {
|
|
|
3420
3536
|
function $(e) {
|
|
3421
3537
|
return e === "expanded" || e === "docked";
|
|
3422
3538
|
}
|
|
3423
|
-
var
|
|
3424
|
-
function
|
|
3539
|
+
var hr = "<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>", gr = "<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>", _r = "<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>", vr = "<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>";
|
|
3540
|
+
function yr(e, t, n) {
|
|
3425
3541
|
Ve(ze);
|
|
3426
|
-
let r =
|
|
3542
|
+
let r = he({
|
|
3427
3543
|
galleryThumb: t.galleryThumb,
|
|
3428
3544
|
avatarImage: t.avatarImage,
|
|
3429
3545
|
backgroundImage: t.backgroundImage,
|
|
@@ -3451,7 +3567,7 @@ function ur(e, t, n) {
|
|
|
3451
3567
|
}
|
|
3452
3568
|
return e.replaceChildren(i), n?.parallax === !1 ? () => {} : Re(i);
|
|
3453
3569
|
}
|
|
3454
|
-
function
|
|
3570
|
+
function br(e) {
|
|
3455
3571
|
return e.startButton ? {
|
|
3456
3572
|
...e.startButton,
|
|
3457
3573
|
label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
|
|
@@ -3463,7 +3579,7 @@ function dr(e) {
|
|
|
3463
3579
|
variant: "primary"
|
|
3464
3580
|
};
|
|
3465
3581
|
}
|
|
3466
|
-
function
|
|
3582
|
+
function xr(e) {
|
|
3467
3583
|
let t = !1, n = () => {
|
|
3468
3584
|
t || e();
|
|
3469
3585
|
}, r = () => {
|
|
@@ -3483,12 +3599,12 @@ function fr(e) {
|
|
|
3483
3599
|
t = !0, window.removeEventListener("load", r), i?.();
|
|
3484
3600
|
};
|
|
3485
3601
|
}
|
|
3486
|
-
function
|
|
3487
|
-
|
|
3602
|
+
function Sr(e, t) {
|
|
3603
|
+
et(Qe);
|
|
3488
3604
|
let n = t.experienceId?.trim();
|
|
3489
3605
|
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",
|
|
3606
|
+
let r = t.prefetch ?? "onExpand", i = pr(t.position), a = document.createElement("div");
|
|
3607
|
+
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", mr(t.offset));
|
|
3492
3608
|
let o = document.createElement("button");
|
|
3493
3609
|
o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
|
|
3494
3610
|
let s = document.createElement("div");
|
|
@@ -3508,11 +3624,11 @@ function pr(e, t) {
|
|
|
3508
3624
|
let m = document.createElement("span");
|
|
3509
3625
|
m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
|
|
3510
3626
|
let h = document.createElement("button");
|
|
3511
|
-
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML =
|
|
3627
|
+
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = _r, h.setAttribute("aria-label", "Reduce");
|
|
3512
3628
|
let g = document.createElement("button");
|
|
3513
|
-
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML =
|
|
3629
|
+
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = hr, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
|
|
3514
3630
|
let _ = document.createElement("button");
|
|
3515
|
-
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML =
|
|
3631
|
+
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = gr, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
|
|
3516
3632
|
let v = document.createElement("div");
|
|
3517
3633
|
v.className = "liforma-ew__stage";
|
|
3518
3634
|
let y = document.createElement("div");
|
|
@@ -3520,70 +3636,70 @@ function pr(e, t) {
|
|
|
3520
3636
|
let b = null, x = !1, S = !1, C = !1, w = !1, T = !1, E = !1, D = !1, O = 0, k = "", A = null, ee = null, j = null, M = null, N = null, P = null, F = null, te = 0, I = 0, L = null, ne = !1, re = new AbortController(), ie = t.parallax !== !1, R = () => {
|
|
3521
3637
|
let e = a.dataset.state;
|
|
3522
3638
|
return e === "expanded" || e === "docked" || e === "collapsed" ? e : "collapsed";
|
|
3523
|
-
}, z = () => {
|
|
3524
|
-
j !== null && (clearTimeout(j), j = null);
|
|
3525
3639
|
}, ae = () => {
|
|
3640
|
+
j !== null && (clearTimeout(j), j = null);
|
|
3641
|
+
}, oe = () => {
|
|
3526
3642
|
M !== null && (clearTimeout(M), M = null), a.classList.remove("liforma-ew--layout-settling");
|
|
3527
|
-
},
|
|
3643
|
+
}, z = () => {
|
|
3528
3644
|
for (let e of [
|
|
3529
3645
|
f,
|
|
3530
3646
|
l,
|
|
3531
3647
|
p
|
|
3532
3648
|
]) 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
3649
|
p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging");
|
|
3534
|
-
},
|
|
3650
|
+
}, se = (e, t, n, r) => {
|
|
3535
3651
|
let i = (i) => {
|
|
3536
3652
|
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
3653
|
};
|
|
3538
3654
|
i(f), i(l);
|
|
3539
3655
|
let a = p.offsetWidth || 120;
|
|
3540
3656
|
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
|
-
},
|
|
3657
|
+
}, ce = (e, t) => {
|
|
3542
3658
|
if (R() !== "docked") return;
|
|
3543
|
-
let n =
|
|
3544
|
-
N = r.left, P = r.top,
|
|
3545
|
-
},
|
|
3659
|
+
let n = lr(), r = dr(e - te, t - I, n);
|
|
3660
|
+
N = r.left, P = r.top, se(r.left, r.top, n.width, n.height);
|
|
3661
|
+
}, le = (e, t) => {
|
|
3546
3662
|
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
|
-
},
|
|
3663
|
+
let n = lr(), r = N ?? f.getBoundingClientRect().left, i = P ?? f.getBoundingClientRect().top, a = dr(r + e, i + t, n);
|
|
3664
|
+
N = a.left, P = a.top, se(a.left, a.top, n.width, n.height);
|
|
3665
|
+
}, B = (e) => {
|
|
3666
|
+
L === "toolbar" && (F === null || e.pointerId !== F || (e.preventDefault(), ce(e.clientX, e.clientY)));
|
|
3667
|
+
}, V = (e) => {
|
|
3552
3668
|
if (F === null || e && e.pointerId !== F) return;
|
|
3553
3669
|
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" || !
|
|
3670
|
+
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", B), window.removeEventListener("pointerup", V), window.removeEventListener("pointercancel", V));
|
|
3671
|
+
}, ue = (e, t, n) => {
|
|
3672
|
+
if (S || R() !== "docked" || !fr() || F !== null) return;
|
|
3557
3673
|
F = n, L = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
3558
3674
|
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" || !
|
|
3675
|
+
te = e - r.left, I = t - r.top, ne || (ne = !0, window.addEventListener("pointermove", B), window.addEventListener("pointerup", V), window.addEventListener("pointercancel", V));
|
|
3676
|
+
}, de = (e) => {
|
|
3677
|
+
if (S || R() !== "docked" || !fr() || F !== null) return;
|
|
3562
3678
|
F = e.pointerId, L = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
3563
3679
|
let t = f.getBoundingClientRect();
|
|
3564
3680
|
N = t.left, P = t.top;
|
|
3565
|
-
},
|
|
3566
|
-
L === "player" && (F === null || e.pointerId !== F ||
|
|
3567
|
-
},
|
|
3568
|
-
L === "player" && (F === null || e.pointerId !== F ||
|
|
3569
|
-
},
|
|
3570
|
-
let e =
|
|
3681
|
+
}, fe = (e) => {
|
|
3682
|
+
L === "player" && (F === null || e.pointerId !== F || le(e.dx, e.dy));
|
|
3683
|
+
}, pe = (e) => {
|
|
3684
|
+
L === "player" && (F === null || e.pointerId !== F || V());
|
|
3685
|
+
}, H = () => {
|
|
3686
|
+
let e = fr(), t = R();
|
|
3571
3687
|
if (!e || t !== "expanded" && t !== "docked") {
|
|
3572
3688
|
h.hidden = !0;
|
|
3573
3689
|
return;
|
|
3574
3690
|
}
|
|
3575
|
-
h.hidden = !1, t === "docked" ? (h.innerHTML =
|
|
3576
|
-
},
|
|
3577
|
-
let t =
|
|
3578
|
-
n =
|
|
3579
|
-
},
|
|
3691
|
+
h.hidden = !1, t === "docked" ? (h.innerHTML = vr, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = _r, h.setAttribute("aria-label", "Reduce"));
|
|
3692
|
+
}, me = (e) => {
|
|
3693
|
+
let t = lr(), n = e && N !== null && P !== null ? dr(N, P, t) : ur(t);
|
|
3694
|
+
n = dr(n.left, n.top, t), N = n.left, P = n.top, se(n.left, n.top, t.width, t.height), H();
|
|
3695
|
+
}, he = () => {
|
|
3580
3696
|
a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
|
|
3581
3697
|
requestAnimationFrame(() => {
|
|
3582
3698
|
S || !$(a.dataset.state) || a.classList.add("liforma-ew--session-revealed");
|
|
3583
3699
|
});
|
|
3584
3700
|
});
|
|
3585
|
-
},
|
|
3586
|
-
if (
|
|
3701
|
+
}, ge = (e) => {
|
|
3702
|
+
if (oe(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !D) {
|
|
3587
3703
|
a.classList.remove("liforma-ew--layout-settling");
|
|
3588
3704
|
return;
|
|
3589
3705
|
}
|
|
@@ -3592,44 +3708,44 @@ function pr(e, t) {
|
|
|
3592
3708
|
a.classList.remove("liforma-ew--layout-settling");
|
|
3593
3709
|
return;
|
|
3594
3710
|
}
|
|
3595
|
-
a.classList.remove("liforma-ew--layout-settling"),
|
|
3711
|
+
a.classList.remove("liforma-ew--layout-settling"), he();
|
|
3596
3712
|
}, 220);
|
|
3597
|
-
},
|
|
3598
|
-
|
|
3713
|
+
}, _e = () => (a.classList.add("liforma-ew--session-concealing"), a.classList.remove("liforma-ew--session-revealed"), new Promise((e) => {
|
|
3714
|
+
ae(), j = setTimeout(() => {
|
|
3599
3715
|
j = null, a.classList.remove("liforma-ew--session-concealing"), e();
|
|
3600
3716
|
}, 280);
|
|
3601
|
-
})),
|
|
3717
|
+
})), ve = {
|
|
3602
3718
|
galleryThumb: t.galleryThumb,
|
|
3603
3719
|
avatarImage: t.avatarImage,
|
|
3604
3720
|
backgroundImage: t.backgroundImage,
|
|
3605
3721
|
foregroundImage: t.foregroundImage,
|
|
3606
3722
|
fallbackImage: t.fallbackImage
|
|
3607
|
-
},
|
|
3723
|
+
}, U = (e) => {
|
|
3608
3724
|
if (!e) {
|
|
3609
3725
|
y.hidden = !0, y.textContent = "";
|
|
3610
3726
|
return;
|
|
3611
3727
|
}
|
|
3612
3728
|
y.hidden = !1, y.textContent = e;
|
|
3613
|
-
},
|
|
3729
|
+
}, W = (e) => {
|
|
3614
3730
|
if (!e) {
|
|
3615
3731
|
c.hidden = !0, c.textContent = "";
|
|
3616
3732
|
return;
|
|
3617
3733
|
}
|
|
3618
3734
|
c.hidden = !1, c.textContent = e, s.contains(c) || s.append(c);
|
|
3619
3735
|
}, ye = () => {
|
|
3620
|
-
C = !0, o.disabled = !1,
|
|
3736
|
+
C = !0, o.disabled = !1, W(null), r === "onExpand" && t.onPrefetchReady?.();
|
|
3621
3737
|
}, be = () => {
|
|
3622
3738
|
w = !0, a.dataset.warm = "true", l.hidden = !1, D || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
|
|
3623
3739
|
}, xe = (e) => {
|
|
3624
3740
|
A?.(), A = null;
|
|
3625
|
-
let t =
|
|
3741
|
+
let t = yr(s, e, { parallax: ie });
|
|
3626
3742
|
return t ? (A = t, !0) : !1;
|
|
3627
|
-
},
|
|
3628
|
-
if (xe(
|
|
3743
|
+
}, Se = () => {
|
|
3744
|
+
if (xe(ve)) {
|
|
3629
3745
|
ye();
|
|
3630
3746
|
return;
|
|
3631
3747
|
}
|
|
3632
|
-
|
|
3748
|
+
W("Loading…"), ot(n, { signal: re.signal }).then((e) => {
|
|
3633
3749
|
if (!S) {
|
|
3634
3750
|
if (!xe({ galleryThumb: e.galleryThumb })) throw Error("Experience preview is missing gallery thumb images.");
|
|
3635
3751
|
ye();
|
|
@@ -3637,9 +3753,9 @@ function pr(e, t) {
|
|
|
3637
3753
|
}).catch((e) => {
|
|
3638
3754
|
if (S || re.signal.aborted) return;
|
|
3639
3755
|
let n = e instanceof Error ? e : Error(String(e));
|
|
3640
|
-
|
|
3756
|
+
W("Preview unavailable"), o.disabled = !0, t.onError?.(n), console.error("[ExperienceWidget]", n);
|
|
3641
3757
|
});
|
|
3642
|
-
},
|
|
3758
|
+
}, Ce = () => ({
|
|
3643
3759
|
experienceId: n,
|
|
3644
3760
|
ui: "widget",
|
|
3645
3761
|
...t.sessionEndpoint ? { sessionEndpoint: t.sessionEndpoint } : {},
|
|
@@ -3652,61 +3768,61 @@ function pr(e, t) {
|
|
|
3652
3768
|
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
|
|
3653
3769
|
...t.alreadyConverted?.length ? { alreadyConverted: t.alreadyConverted } : {},
|
|
3654
3770
|
...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
|
|
3655
|
-
}),
|
|
3771
|
+
}), we = () => ({
|
|
3656
3772
|
...t.fit ? { fit: t.fit } : {},
|
|
3657
|
-
startButton:
|
|
3773
|
+
startButton: br(t),
|
|
3658
3774
|
...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback },
|
|
3659
3775
|
...t.interaction ? { interaction: t.interaction } : {}
|
|
3660
|
-
}),
|
|
3661
|
-
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"),
|
|
3776
|
+
}), G = (e = !0) => {
|
|
3777
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), z(), a.dataset.state = "expanded", U(null), typeof document < "u" && (k = document.body.style.overflow, document.body.style.overflow = "hidden"), H(), e && t.onExpanded?.();
|
|
3662
3778
|
}, Te = () => {
|
|
3663
|
-
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked",
|
|
3779
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked", U(null), typeof document < "u" && (document.body.style.overflow = k), me(!0), H(), b?.setWidgetChrome("docked");
|
|
3664
3780
|
}, Ee = (e) => {
|
|
3665
3781
|
e.on("started", () => {
|
|
3666
|
-
S || (D = !0, a.dataset.live = "true",
|
|
3782
|
+
S || (D = !0, a.dataset.live = "true", U(null), t.onStarted?.(), $(a.dataset.state) && he());
|
|
3667
3783
|
}), e.on("feedback", (e) => {
|
|
3668
3784
|
S || t.onFeedback?.(e);
|
|
3669
3785
|
}), e.on("feedbackFailed", (e) => {
|
|
3670
3786
|
S || t.onFeedbackFailed?.(e);
|
|
3671
3787
|
});
|
|
3672
3788
|
}, De = () => {
|
|
3673
|
-
|
|
3789
|
+
oe(), u.hidden = !0, p.hidden = !0, z(), 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), U(null), typeof document < "u" && (document.body.style.overflow = k), H();
|
|
3674
3790
|
}, Oe = () => {
|
|
3675
|
-
|
|
3791
|
+
ae(), oe(), O += 1, x = !1, w = !1, T = !1, E = !1, D = !1;
|
|
3676
3792
|
let e = b;
|
|
3677
3793
|
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
3794
|
}, K = () => {
|
|
3679
3795
|
if (!S && $(a.dataset.state)) {
|
|
3680
|
-
if (
|
|
3796
|
+
if (V(), x = !1, b && E) {
|
|
3681
3797
|
let e = b;
|
|
3682
3798
|
(async () => {
|
|
3683
|
-
D && (await
|
|
3799
|
+
D && (await _e(), S || b !== e) || (w && e.setWidgetChrome("collapsed"), De(), D ? (a.dataset.live = "true", o.tabIndex = 0, o.removeAttribute("aria-hidden"), o.disabled = !1) : w && be(), t.onCollapsed?.(), t.onClose?.());
|
|
3684
3800
|
})();
|
|
3685
3801
|
return;
|
|
3686
3802
|
}
|
|
3687
3803
|
Oe(), De(), t.onCollapsed?.(), t.onClose?.();
|
|
3688
3804
|
}
|
|
3689
3805
|
}, ke = () => {
|
|
3690
|
-
S ||
|
|
3806
|
+
S || fr() && R() === "expanded" && ge(() => {
|
|
3691
3807
|
Te();
|
|
3692
3808
|
});
|
|
3693
3809
|
}, Ae = () => {
|
|
3694
|
-
S || R() === "docked" && (
|
|
3695
|
-
|
|
3810
|
+
S || R() === "docked" && (V(), ge(() => {
|
|
3811
|
+
z(), G(!1), b?.setWidgetChrome("expanded");
|
|
3696
3812
|
}));
|
|
3697
3813
|
}, je = () => {
|
|
3698
|
-
!b || !D || (
|
|
3814
|
+
!b || !D || (ae(), a.classList.remove("liforma-ew--session-revealed"), G(), b.setWidgetChrome("expanded"), x = !1, he());
|
|
3699
3815
|
}, q = () => {
|
|
3700
|
-
!b || !E || D || (
|
|
3816
|
+
!b || !E || D || (ae(), a.classList.remove("liforma-ew--session-revealed"), G(), x = !1, w || b.setWidgetChrome("expanded"));
|
|
3701
3817
|
}, Me = (e) => {
|
|
3702
|
-
S || e !== O && !D || (
|
|
3818
|
+
S || e !== O && !D || (ae(), a.classList.remove("liforma-ew--session-revealed"), G(), x = !1, D && he());
|
|
3703
3819
|
}, J = () => {
|
|
3704
3820
|
if (S || T || w || b || $(a.dataset.state)) return;
|
|
3705
3821
|
T = !0;
|
|
3706
3822
|
let e = O;
|
|
3707
3823
|
l.hidden = !1, (async () => {
|
|
3708
3824
|
try {
|
|
3709
|
-
let t = await
|
|
3825
|
+
let t = await er.startSession(Ce());
|
|
3710
3826
|
if (S || e !== O) {
|
|
3711
3827
|
t.destroy();
|
|
3712
3828
|
return;
|
|
@@ -3714,7 +3830,7 @@ function pr(e, t) {
|
|
|
3714
3830
|
b = t, Ee(t);
|
|
3715
3831
|
let n = await t.attach({
|
|
3716
3832
|
container: l,
|
|
3717
|
-
...
|
|
3833
|
+
...we(),
|
|
3718
3834
|
onWidgetReady: () => {
|
|
3719
3835
|
S || e !== O || (T = !1, E = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") : be());
|
|
3720
3836
|
},
|
|
@@ -3725,16 +3841,16 @@ function pr(e, t) {
|
|
|
3725
3841
|
S || Ie(e);
|
|
3726
3842
|
},
|
|
3727
3843
|
onWidgetDragStart: (e) => {
|
|
3728
|
-
S ||
|
|
3844
|
+
S || de(e);
|
|
3729
3845
|
},
|
|
3730
3846
|
onWidgetDragMove: (e) => {
|
|
3731
|
-
S ||
|
|
3847
|
+
S || fe(e);
|
|
3732
3848
|
},
|
|
3733
3849
|
onWidgetDragEnd: (e) => {
|
|
3734
|
-
S ||
|
|
3850
|
+
S || pe(e);
|
|
3735
3851
|
},
|
|
3736
3852
|
onPlayerStatusChange: (e) => {
|
|
3737
|
-
S || e === "error" && $(a.dataset.state) &&
|
|
3853
|
+
S || e === "error" && $(a.dataset.state) && U("Could not load the experience.");
|
|
3738
3854
|
}
|
|
3739
3855
|
});
|
|
3740
3856
|
if (S || e !== O) {
|
|
@@ -3764,8 +3880,8 @@ function pr(e, t) {
|
|
|
3764
3880
|
let e = ++O;
|
|
3765
3881
|
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
3882
|
try {
|
|
3767
|
-
|
|
3768
|
-
let t = await
|
|
3883
|
+
G();
|
|
3884
|
+
let t = await er.startSession(Ce());
|
|
3769
3885
|
if (S || e !== O) {
|
|
3770
3886
|
t.destroy();
|
|
3771
3887
|
return;
|
|
@@ -3773,21 +3889,21 @@ function pr(e, t) {
|
|
|
3773
3889
|
b = t, Ee(t);
|
|
3774
3890
|
let n = await t.attach({
|
|
3775
3891
|
container: v,
|
|
3776
|
-
...
|
|
3892
|
+
...we(),
|
|
3777
3893
|
onWidgetAudioSettings: (e) => {
|
|
3778
3894
|
S || Ie(e);
|
|
3779
3895
|
},
|
|
3780
3896
|
onWidgetDragStart: (e) => {
|
|
3781
|
-
S ||
|
|
3897
|
+
S || de(e);
|
|
3782
3898
|
},
|
|
3783
3899
|
onWidgetDragMove: (e) => {
|
|
3784
|
-
S ||
|
|
3900
|
+
S || fe(e);
|
|
3785
3901
|
},
|
|
3786
3902
|
onWidgetDragEnd: (e) => {
|
|
3787
|
-
S ||
|
|
3903
|
+
S || pe(e);
|
|
3788
3904
|
},
|
|
3789
3905
|
onPlayerStatusChange: (e) => {
|
|
3790
|
-
S || (e === "error" ?
|
|
3906
|
+
S || (e === "error" ? U("Could not load the experience.") : $(a.dataset.state) && U(null));
|
|
3791
3907
|
}
|
|
3792
3908
|
});
|
|
3793
3909
|
if (S || e !== O) {
|
|
@@ -3800,7 +3916,7 @@ function pr(e, t) {
|
|
|
3800
3916
|
} catch (n) {
|
|
3801
3917
|
if (S || e !== O) return;
|
|
3802
3918
|
let r = n instanceof Error ? n : Error(String(n));
|
|
3803
|
-
|
|
3919
|
+
U(r.message), t.onError?.(r), console.error("[ExperienceWidget]", r);
|
|
3804
3920
|
} finally {
|
|
3805
3921
|
e === O && (x = !1);
|
|
3806
3922
|
}
|
|
@@ -3816,7 +3932,7 @@ function pr(e, t) {
|
|
|
3816
3932
|
return;
|
|
3817
3933
|
}
|
|
3818
3934
|
if (T || b) {
|
|
3819
|
-
|
|
3935
|
+
G();
|
|
3820
3936
|
return;
|
|
3821
3937
|
}
|
|
3822
3938
|
Ne();
|
|
@@ -3832,37 +3948,37 @@ function pr(e, t) {
|
|
|
3832
3948
|
}, Le = (e) => {
|
|
3833
3949
|
e.stopPropagation(), $(a.dataset.state) && b?.toggleAudioSettings();
|
|
3834
3950
|
}, Re = (e) => {
|
|
3835
|
-
R() === "docked" &&
|
|
3951
|
+
R() === "docked" && fr() && (e.target?.closest("button") || (e.preventDefault(), ue(e.clientX, e.clientY, e.pointerId)));
|
|
3836
3952
|
}, ze = (e) => {
|
|
3837
3953
|
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), K());
|
|
3838
3954
|
}, Be = () => {
|
|
3839
3955
|
if (!S) {
|
|
3840
3956
|
if (R() === "docked") {
|
|
3841
|
-
if (!
|
|
3957
|
+
if (!fr()) {
|
|
3842
3958
|
Ae();
|
|
3843
3959
|
return;
|
|
3844
3960
|
}
|
|
3845
|
-
D ?
|
|
3846
|
-
|
|
3847
|
-
}) :
|
|
3961
|
+
D ? ge(() => {
|
|
3962
|
+
me(!0);
|
|
3963
|
+
}) : me(!0);
|
|
3848
3964
|
return;
|
|
3849
3965
|
}
|
|
3850
|
-
|
|
3966
|
+
H();
|
|
3851
3967
|
}
|
|
3852
|
-
}, Ve = typeof window < "u" ? window.matchMedia(
|
|
3968
|
+
}, Ve = typeof window < "u" ? window.matchMedia(nr) : null, He = () => {
|
|
3853
3969
|
if (!S) {
|
|
3854
|
-
if (R() === "docked" && !
|
|
3970
|
+
if (R() === "docked" && !fr()) {
|
|
3855
3971
|
Ae();
|
|
3856
3972
|
return;
|
|
3857
3973
|
}
|
|
3858
|
-
|
|
3974
|
+
H();
|
|
3859
3975
|
}
|
|
3860
3976
|
};
|
|
3861
3977
|
return o.addEventListener("click", Pe), d.addEventListener("click", K), _.addEventListener("click", (e) => {
|
|
3862
3978
|
e.stopPropagation(), K();
|
|
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),
|
|
3979
|
+
}), h.addEventListener("click", Fe), g.addEventListener("click", Le), p.addEventListener("pointerdown", Re), window.addEventListener("keydown", ze), window.addEventListener("resize", Be), Ve?.addEventListener("change", He), Se(), H(), r === "eager" ? queueMicrotask(() => {
|
|
3864
3980
|
S || J();
|
|
3865
|
-
}) : r === "idle" && (ee =
|
|
3981
|
+
}) : r === "idle" && (ee = xr(() => {
|
|
3866
3982
|
S || J();
|
|
3867
3983
|
})), {
|
|
3868
3984
|
root: a,
|
|
@@ -3878,18 +3994,18 @@ function pr(e, t) {
|
|
|
3878
3994
|
J();
|
|
3879
3995
|
},
|
|
3880
3996
|
destroy() {
|
|
3881
|
-
S || (S = !0,
|
|
3997
|
+
S || (S = !0, V(), ee?.(), ee = null, re.abort(), A?.(), A = null, window.removeEventListener("keydown", ze), window.removeEventListener("resize", Be), Ve?.removeEventListener("change", He), Oe(), De(), e.replaceChildren());
|
|
3882
3998
|
}
|
|
3883
3999
|
};
|
|
3884
4000
|
}
|
|
3885
4001
|
//#endregion
|
|
3886
4002
|
//#region src/react/ExperienceWidget.tsx
|
|
3887
|
-
function
|
|
4003
|
+
function Cr(e) {
|
|
3888
4004
|
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
4005
|
return n(() => {
|
|
3890
4006
|
let e = t.current;
|
|
3891
4007
|
if (!e || !r.trim()) return;
|
|
3892
|
-
let n =
|
|
4008
|
+
let n = Sr(e, {
|
|
3893
4009
|
experienceId: r,
|
|
3894
4010
|
alt: i,
|
|
3895
4011
|
galleryThumb: a,
|
|
@@ -3972,6 +4088,6 @@ function mr(e) {
|
|
|
3972
4088
|
});
|
|
3973
4089
|
}
|
|
3974
4090
|
//#endregion
|
|
3975
|
-
export { ne as Experience,
|
|
4091
|
+
export { ne as Experience, Ze as ExperienceThumbnail, Cr as ExperienceWidget };
|
|
3976
4092
|
|
|
3977
4093
|
//# sourceMappingURL=index.js.map
|