@liforma/client 0.4.13 → 0.4.15
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 +18 -0
- package/README.md +4 -4
- package/dist/next/index.js +704 -623
- 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.map +1 -1
- package/dist/next/v2/embed/protocol.d.ts +7 -7
- package/dist/next/v2/embed/protocol.d.ts.map +1 -1
- package/dist/next/v2/experience.d.ts +11 -5
- 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/next/v2/types/sessionLaunch.d.ts +6 -0
- package/dist/next/v2/types/sessionLaunch.d.ts.map +1 -1
- package/dist/npm/index.js +494 -469
- 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.map +1 -1
- package/dist/npm/v2/embed/protocol.d.ts +7 -7
- package/dist/npm/v2/embed/protocol.d.ts.map +1 -1
- package/dist/npm/v2/experience.d.ts +11 -5
- package/dist/npm/v2/experience.d.ts.map +1 -1
- package/dist/npm/v2/index.d.ts +1 -1
- package/dist/npm/v2/index.d.ts.map +1 -1
- package/dist/npm/v2/liforma-experience-thumbnail.d.ts.map +1 -1
- package/dist/npm/v2/npm.d.ts +1 -1
- package/dist/npm/v2/npm.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/npm/v2/types/index.d.ts +1 -1
- package/dist/npm/v2/types/index.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionLaunch.d.ts +6 -0
- package/dist/npm/v2/types/sessionLaunch.d.ts.map +1 -1
- package/dist/react/component/experienceComponentLaunch.d.ts.map +1 -1
- package/dist/react/component/experienceComponentRuntime.d.ts +3 -1
- package/dist/react/component/experienceComponentRuntime.d.ts.map +1 -1
- package/dist/react/component/experienceComponentTypes.d.ts +9 -4
- package/dist/react/component/experienceComponentTypes.d.ts.map +1 -1
- package/dist/react/index.js +733 -640
- 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.map +1 -1
- package/dist/react/v2/embed/protocol.d.ts +7 -7
- package/dist/react/v2/embed/protocol.d.ts.map +1 -1
- package/dist/react/v2/experience.d.ts +11 -5
- 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/react/v2/types/sessionLaunch.d.ts +6 -0
- package/dist/react/v2/types/sessionLaunch.d.ts.map +1 -1
- package/dist/sdk/v2/client.js +3 -3
- package/dist/sdk/v2/client.js.map +1 -1
- package/dist/sdk/v2/thumbnail.js +2 -2
- package/dist/sdk/v2/thumbnail.js.map +1 -1
- package/dist/svelte/Experience.svelte +12 -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,7 +263,9 @@ function P(e = () => ({}), t = () => ({})) {
|
|
|
257
263
|
interaction: d.interaction,
|
|
258
264
|
closeButton: d.closeButton,
|
|
259
265
|
returnUrl: f,
|
|
260
|
-
...d.
|
|
266
|
+
...d.settingsButton === void 0 ? {} : { settingsButton: d.settingsButton },
|
|
267
|
+
...d.theatreButton === void 0 ? {} : { theatreButton: d.theatreButton },
|
|
268
|
+
...d.fullscreenButton === void 0 ? {} : { fullscreenButton: d.fullscreenButton },
|
|
261
269
|
...d.theatre === void 0 ? {} : { theatre: d.theatre },
|
|
262
270
|
onTheatreChange: (e) => t().onTheatreChange?.(e),
|
|
263
271
|
showClose: !!(o().onClose || f || d.closeButton === !0 || d.closeButton && typeof d.closeButton == "object" && d.closeButton.visible !== !1),
|
|
@@ -349,8 +357,8 @@ function L(e, t) {
|
|
|
349
357
|
}
|
|
350
358
|
//#endregion
|
|
351
359
|
//#region src/react/Experience.tsx
|
|
352
|
-
var
|
|
353
|
-
let { returnUrl: c, fit: l, stage: u, pipBackground: p, pipShadow: m, startButton: h, theme: g, showFeedback: y, interaction: b,
|
|
360
|
+
var R = e(function(e, a) {
|
|
361
|
+
let { returnUrl: c, fit: l, stage: u, pipBackground: p, pipShadow: m, startButton: h, theme: g, showFeedback: y, interaction: b, settingsButton: x, theatreButton: S, fullscreenButton: C, theatre: w, onTheatreChange: T, closeButton: E, onReady: D, onStarted: O, onUserTranscript: ee, onUserSpeechStarted: j, onUserSpeechEnded: M, onCharacterSpeechStarted: N, onCharacterSpeechEnded: F, onCharacterFocusChanged: te, onConversationUpdate: I, onMessage: R, onListeningState: ne, onActivityChange: re, onFeedback: z, onFeedbackFailed: ie, onConversationProcessorError: ae, onPlayerStatusChange: B, onStateUpdate: oe, onClose: se, onError: ce } = e, le = o({}), V = o({
|
|
354
362
|
fit: l,
|
|
355
363
|
stage: u,
|
|
356
364
|
pipBackground: p,
|
|
@@ -359,13 +367,15 @@ var ne = e(function(e, a) {
|
|
|
359
367
|
theme: g,
|
|
360
368
|
showFeedback: y,
|
|
361
369
|
interaction: b,
|
|
362
|
-
closeButton:
|
|
370
|
+
closeButton: E,
|
|
363
371
|
returnUrl: c,
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
372
|
+
settingsButton: x,
|
|
373
|
+
theatreButton: S,
|
|
374
|
+
fullscreenButton: C,
|
|
375
|
+
theatre: w,
|
|
376
|
+
onTheatreChange: T
|
|
377
|
+
}), H = o(P(() => le.current, () => V.current)), U = o(null), [ue, de] = s(!1), [W, fe] = s(null), pe = o(null), me = o(null), he = v(e);
|
|
378
|
+
V.current = {
|
|
369
379
|
fit: l,
|
|
370
380
|
stage: u,
|
|
371
381
|
pipBackground: p,
|
|
@@ -374,110 +384,112 @@ var ne = e(function(e, a) {
|
|
|
374
384
|
theme: g,
|
|
375
385
|
showFeedback: y,
|
|
376
386
|
interaction: b,
|
|
377
|
-
closeButton:
|
|
387
|
+
closeButton: E,
|
|
378
388
|
returnUrl: c,
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
389
|
+
settingsButton: x,
|
|
390
|
+
theatreButton: S,
|
|
391
|
+
fullscreenButton: C,
|
|
392
|
+
theatre: w,
|
|
393
|
+
onTheatreChange: T
|
|
394
|
+
}, le.current = {
|
|
395
|
+
onReady: D,
|
|
396
|
+
onStarted: O,
|
|
397
|
+
onUserTranscript: ee,
|
|
398
|
+
onUserSpeechStarted: j,
|
|
399
|
+
onUserSpeechEnded: M,
|
|
400
|
+
onCharacterSpeechStarted: N,
|
|
401
|
+
onCharacterSpeechEnded: F,
|
|
402
|
+
onCharacterFocusChanged: te,
|
|
403
|
+
onConversationUpdate: I,
|
|
404
|
+
onMessage: R,
|
|
405
|
+
onListeningState: ne,
|
|
406
|
+
onActivityChange: re,
|
|
407
|
+
onFeedback: z,
|
|
396
408
|
onFeedbackFailed: ie,
|
|
397
|
-
onConversationProcessorError:
|
|
398
|
-
onPlayerStatusChange:
|
|
399
|
-
onStateUpdate:
|
|
400
|
-
onClose:
|
|
401
|
-
onError:
|
|
402
|
-
};
|
|
403
|
-
let
|
|
404
|
-
|
|
409
|
+
onConversationProcessorError: ae,
|
|
410
|
+
onPlayerStatusChange: B,
|
|
411
|
+
onStateUpdate: oe,
|
|
412
|
+
onClose: se,
|
|
413
|
+
onError: ce
|
|
414
|
+
};
|
|
415
|
+
let ge = t((e) => {
|
|
416
|
+
pe.current = e, de(e !== null);
|
|
405
417
|
}, []);
|
|
406
418
|
return r(a, () => ({
|
|
407
419
|
ready: () => {
|
|
408
|
-
let e =
|
|
420
|
+
let e = U.current;
|
|
409
421
|
return !e || e.destroyed ? Promise.reject(k()) : e.ready.promise;
|
|
410
422
|
},
|
|
411
423
|
started: () => {
|
|
412
|
-
let e =
|
|
424
|
+
let e = U.current;
|
|
413
425
|
return !e || e.destroyed ? Promise.reject(k()) : e.started.promise;
|
|
414
426
|
},
|
|
415
427
|
speech: {
|
|
416
|
-
speak: (e) =>
|
|
417
|
-
play: (e) =>
|
|
428
|
+
speak: (e) => H.current.withSession((t) => t.speech.speak(e)),
|
|
429
|
+
play: (e) => H.current.withSession((t) => t.speech.play(e)),
|
|
418
430
|
createUtterance: (e) => {
|
|
419
|
-
let t =
|
|
431
|
+
let t = H.current.getActiveInstance();
|
|
420
432
|
if (!t) throw Error("Session has not started. Wait for the player start button and the started event before using speech APIs.");
|
|
421
433
|
return t.speech.createUtterance(e);
|
|
422
434
|
},
|
|
423
|
-
interrupt: (e) =>
|
|
435
|
+
interrupt: (e) => H.current.withSession((t) => t.speech.interrupt(e))
|
|
424
436
|
},
|
|
425
|
-
startListening: () =>
|
|
426
|
-
stopListening: () =>
|
|
427
|
-
listenOnce: (e) =>
|
|
428
|
-
getSession: () =>
|
|
429
|
-
getManifest: () =>
|
|
430
|
-
getConversation: () =>
|
|
431
|
-
focusCharacter: (e) =>
|
|
432
|
-
setFit: (e) =>
|
|
433
|
-
setStage: (e) =>
|
|
434
|
-
setPipBackground: (e) =>
|
|
435
|
-
setPipShadow: (e) =>
|
|
437
|
+
startListening: () => H.current.withSession((e) => e.startListening()),
|
|
438
|
+
stopListening: () => H.current.withSession((e) => e.stopListening()),
|
|
439
|
+
listenOnce: (e) => H.current.withSession((t) => t.listenOnce(e)),
|
|
440
|
+
getSession: () => H.current.getActiveInstance()?.getSession() ?? null,
|
|
441
|
+
getManifest: () => H.current.getActiveInstance()?.getManifest() ?? null,
|
|
442
|
+
getConversation: () => H.current.getActiveInstance()?.getConversation() ?? [],
|
|
443
|
+
focusCharacter: (e) => H.current.withSession((t) => t.focusCharacter(e)),
|
|
444
|
+
setFit: (e) => H.current.withSession((t) => t.setFit(e)),
|
|
445
|
+
setStage: (e) => H.current.withSession((t) => t.setStage(e)),
|
|
446
|
+
setPipBackground: (e) => H.current.withSession((t) => t.setPipBackground(e)),
|
|
447
|
+
setPipShadow: (e) => H.current.withSession((t) => t.setPipShadow(e)),
|
|
436
448
|
setTheatre: (e) => {
|
|
437
|
-
|
|
449
|
+
H.current.getActiveInstance()?.setTheatre(e);
|
|
438
450
|
},
|
|
439
|
-
conversion: (e) =>
|
|
440
|
-
engage: () =>
|
|
441
|
-
end: () =>
|
|
451
|
+
conversion: (e) => H.current.withSession((t) => t.conversion(e)),
|
|
452
|
+
engage: () => H.current.withSession((e) => e.engage()),
|
|
453
|
+
end: () => H.current.withSession((e) => e.end())
|
|
442
454
|
}), []), i(() => {
|
|
443
|
-
if (!
|
|
444
|
-
let t =
|
|
455
|
+
if (!ue || !pe.current) return;
|
|
456
|
+
let t = pe.current, n = H.current, r;
|
|
445
457
|
try {
|
|
446
458
|
r = { options: _(e) };
|
|
447
459
|
} catch (e) {
|
|
448
460
|
r = { error: A(e) };
|
|
449
461
|
}
|
|
450
|
-
let i = n.activateGeneration(t, r, c,
|
|
451
|
-
return
|
|
452
|
-
n.cancelGeneration(i),
|
|
462
|
+
let i = n.activateGeneration(t, r, c, fe);
|
|
463
|
+
return U.current = i, () => {
|
|
464
|
+
n.cancelGeneration(i), U.current === i && (U.current = null);
|
|
453
465
|
};
|
|
454
466
|
}, [
|
|
455
|
-
|
|
456
|
-
|
|
467
|
+
ue,
|
|
468
|
+
he,
|
|
457
469
|
c
|
|
458
470
|
]), n(() => {
|
|
459
|
-
let e =
|
|
471
|
+
let e = H.current.getActiveInstance();
|
|
460
472
|
e && e.setFit(l ?? "full");
|
|
461
473
|
}, [l]), n(() => {
|
|
462
|
-
let e =
|
|
474
|
+
let e = H.current.getActiveInstance();
|
|
463
475
|
e && e.setStage(u ?? "fill");
|
|
464
476
|
}, [u]), n(() => {
|
|
465
|
-
let e =
|
|
477
|
+
let e = H.current.getActiveInstance();
|
|
466
478
|
e && e.setPipBackground(p ?? "none");
|
|
467
479
|
}, [p]), n(() => {
|
|
468
480
|
if (m === void 0) return;
|
|
469
|
-
let e =
|
|
481
|
+
let e = H.current.getActiveInstance();
|
|
470
482
|
e && e.setPipShadow(m);
|
|
471
483
|
}, [m]), n(() => {
|
|
472
|
-
if (!
|
|
473
|
-
let e =
|
|
474
|
-
e && e.setTheatre(
|
|
475
|
-
}, [
|
|
476
|
-
let e =
|
|
477
|
-
if (!e || (e.replaceChildren(), !
|
|
478
|
-
let t = L(e,
|
|
484
|
+
if (!S) return;
|
|
485
|
+
let e = H.current.getActiveInstance();
|
|
486
|
+
e && e.setTheatre(w === !0);
|
|
487
|
+
}, [S, w]), n(() => {
|
|
488
|
+
let e = me.current;
|
|
489
|
+
if (!e || (e.replaceChildren(), !W)) return;
|
|
490
|
+
let t = L(e, W);
|
|
479
491
|
return () => t.remove();
|
|
480
|
-
}, [
|
|
492
|
+
}, [W]), /* @__PURE__ */ f("div", {
|
|
481
493
|
className: "liforma-experience-shell",
|
|
482
494
|
style: {
|
|
483
495
|
position: "relative",
|
|
@@ -486,17 +498,17 @@ var ne = e(function(e, a) {
|
|
|
486
498
|
minHeight: "inherit"
|
|
487
499
|
},
|
|
488
500
|
children: [/* @__PURE__ */ d("div", {
|
|
489
|
-
ref:
|
|
501
|
+
ref: me,
|
|
490
502
|
className: "liforma-experience-error-host",
|
|
491
|
-
"aria-hidden":
|
|
503
|
+
"aria-hidden": W ? void 0 : !0,
|
|
492
504
|
style: {
|
|
493
505
|
position: "absolute",
|
|
494
506
|
inset: 0,
|
|
495
507
|
zIndex: 20,
|
|
496
|
-
pointerEvents:
|
|
508
|
+
pointerEvents: W ? "auto" : "none"
|
|
497
509
|
}
|
|
498
510
|
}), /* @__PURE__ */ d("div", {
|
|
499
|
-
ref:
|
|
511
|
+
ref: ge,
|
|
500
512
|
className: "liforma-experience-host",
|
|
501
513
|
style: {
|
|
502
514
|
position: "absolute",
|
|
@@ -508,18 +520,18 @@ var ne = e(function(e, a) {
|
|
|
508
520
|
});
|
|
509
521
|
//#endregion
|
|
510
522
|
//#region src/thumbnail/types.ts
|
|
511
|
-
function
|
|
523
|
+
function ne(e) {
|
|
512
524
|
return e === "face" ? "liforma-et--fit-face" : e === "medium" ? "liforma-et--fit-medium" : "";
|
|
513
525
|
}
|
|
514
526
|
//#endregion
|
|
515
527
|
//#region src/thumbnail/locationPlate.ts
|
|
516
|
-
var
|
|
517
|
-
function R(e, t) {
|
|
518
|
-
return !Number.isFinite(e) || !Number.isFinite(t) || e < 1 || t < 1 || e <= t ? "256x256" : e > 800 || t > 450 ? "1672x941" : "800x450";
|
|
519
|
-
}
|
|
528
|
+
var re = /(-)(\d+x\d+)(\.(?:webp|avif))(\?|$)/i;
|
|
520
529
|
function z(e, t) {
|
|
530
|
+
return !Number.isFinite(e) || !Number.isFinite(t) || e < 1 || t < 1 || e <= t ? "256x256" : t <= 225 ? "400x225" : e > 800 || t > 450 ? "1672x941" : "800x450";
|
|
531
|
+
}
|
|
532
|
+
function ie(e, t) {
|
|
521
533
|
let n = e.trim();
|
|
522
|
-
return n && n.replace(
|
|
534
|
+
return n && n.replace(re, (e, n, r, i, a) => `${n}${t}${i}${a}`);
|
|
523
535
|
}
|
|
524
536
|
function ae(e, t) {
|
|
525
537
|
let n = () => {
|
|
@@ -529,7 +541,7 @@ function ae(e, t) {
|
|
|
529
541
|
let r = new ResizeObserver(n);
|
|
530
542
|
return r.observe(e), () => r.disconnect();
|
|
531
543
|
}
|
|
532
|
-
var B = /-(256x256|400x450|800x450|836x971|1672x941|167x94)$/i;
|
|
544
|
+
var B = /-(256x256|400x225|400x450|800x450|836x971|1672x941|167x94)$/i;
|
|
533
545
|
function oe(e) {
|
|
534
546
|
return e?.trim().replace(/\/$/, "") || "https://cdn.liforma.ai";
|
|
535
547
|
}
|
|
@@ -539,7 +551,7 @@ function se(e) {
|
|
|
539
551
|
function ce(e) {
|
|
540
552
|
return e.startsWith("//") ? `https:${e}` : e;
|
|
541
553
|
}
|
|
542
|
-
function
|
|
554
|
+
function le(e) {
|
|
543
555
|
let t = e.indexOf("?");
|
|
544
556
|
return t === -1 ? {
|
|
545
557
|
pathname: e,
|
|
@@ -549,51 +561,51 @@ function V(e) {
|
|
|
549
561
|
search: e.slice(t)
|
|
550
562
|
};
|
|
551
563
|
}
|
|
552
|
-
function
|
|
564
|
+
function V(e, t, n = "") {
|
|
553
565
|
return `${e}${t.startsWith("/") ? t : `/${t}`}${n}`;
|
|
554
566
|
}
|
|
555
|
-
function
|
|
567
|
+
function H(e, t, n) {
|
|
556
568
|
let r = e.trim();
|
|
557
569
|
if (!r) return r;
|
|
558
570
|
let i = oe(n);
|
|
559
|
-
if (se(r)) return
|
|
560
|
-
let { pathname: a, search: o } =
|
|
571
|
+
if (se(r)) return ie(ce(r), t);
|
|
572
|
+
let { pathname: a, search: o } = le(r.replace(/\\/g, "/")), s = a;
|
|
561
573
|
if (!s.startsWith("/")) s = `/locations/${s.replace(/^locations\//i, "")}`;
|
|
562
|
-
else if (!/^\/locations\//i.test(s)) return /^\/avatars\//i.test(s) ?
|
|
563
|
-
if (/\.webp$/i.test(s) && !B.test(s.replace(/\.webp$/i, ""))) return
|
|
574
|
+
else if (!/^\/locations\//i.test(s)) return /^\/avatars\//i.test(s) ? V(i, s, o) : r;
|
|
575
|
+
if (/\.webp$/i.test(s) && !B.test(s.replace(/\.webp$/i, ""))) return V(i, s, o);
|
|
564
576
|
let c = s.replace(/^\/locations\//i, "").replace(/\.webp$/i, "");
|
|
565
577
|
return c = c.replace(B, ""), `${i}/locations/${c}-${t}.webp${o}`;
|
|
566
578
|
}
|
|
567
|
-
function
|
|
579
|
+
function U(e, t) {
|
|
568
580
|
let n = e.trim();
|
|
569
581
|
if (!n) return n;
|
|
570
582
|
let r = oe(t);
|
|
571
583
|
if (se(n)) return ce(n);
|
|
572
|
-
let { pathname: i, search: a } =
|
|
584
|
+
let { pathname: i, search: a } = le(n.replace(/\\/g, "/")), o = i;
|
|
573
585
|
if (!o.startsWith("/")) if (/^avatars\//i.test(o)) o = `/${o}`;
|
|
574
586
|
else if (/^[^/]+$/.test(o) && !a) return `${r}/avatars/${o}/256/${o}_neutral.webp`;
|
|
575
587
|
else return n;
|
|
576
588
|
if (!/^\/avatars\//i.test(o)) return n;
|
|
577
589
|
let s = o.replace(/^\/avatars\//i, "").replace(/\/+$/, "");
|
|
578
|
-
return s && !s.includes("/") && !a ? `${r}/avatars/${s}/256/${s}_neutral.webp` :
|
|
590
|
+
return s && !s.includes("/") && !a ? `${r}/avatars/${s}/256/${s}_neutral.webp` : V(r, o, a);
|
|
579
591
|
}
|
|
580
592
|
//#endregion
|
|
581
593
|
//#region src/thumbnail/toGalleryThumbUrl.ts
|
|
582
|
-
var
|
|
594
|
+
var ue = /(\/avatars\/[^/]+\/)(\d+)(\/)/i, de = /_CH(\.webp)/i;
|
|
583
595
|
function W(e) {
|
|
584
596
|
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("/");
|
|
585
597
|
}
|
|
586
|
-
function
|
|
598
|
+
function fe(e, t = "256x256", n) {
|
|
587
599
|
let r = e.trim();
|
|
588
600
|
if (!r) return r;
|
|
589
|
-
if (W(r)) return
|
|
590
|
-
let i =
|
|
591
|
-
return i = i.replace(
|
|
601
|
+
if (W(r)) return H(r, t, n);
|
|
602
|
+
let i = U(r, n);
|
|
603
|
+
return i = i.replace(ue, (e, t, n, r) => n === "256" ? `${t}${n}${r}` : `${t}256${r}`), i.replace(de, "_neutral$1");
|
|
592
604
|
}
|
|
593
|
-
function
|
|
605
|
+
function pe(e) {
|
|
594
606
|
let t = e.avatarImage?.trim() || e.galleryThumb?.avatarImage?.trim() || "";
|
|
595
607
|
if (!t) return null;
|
|
596
|
-
let n = e.backgroundImage?.trim() || e.galleryThumb?.backgroundImage?.trim() || "", r = e.foregroundImage?.trim() || e.galleryThumb?.foregroundImage?.trim() || "", i = e.fallbackImage?.trim() || "", a = e.locationPlateSize ?? "256x256", o = oe(e.cdnBaseUrl), s = e.normalize !== !1, c = (e) => !s && /^https?:\/\//i.test(e.trim()) ? e.trim() :
|
|
608
|
+
let n = e.backgroundImage?.trim() || e.galleryThumb?.backgroundImage?.trim() || "", r = e.foregroundImage?.trim() || e.galleryThumb?.foregroundImage?.trim() || "", i = e.fallbackImage?.trim() || "", a = e.locationPlateSize ?? "256x256", o = oe(e.cdnBaseUrl), s = e.normalize !== !1, c = (e) => !s && /^https?:\/\//i.test(e.trim()) ? e.trim() : fe(e, a, o), l = (e) => !s && /^https?:\/\//i.test(e.trim()) ? e.trim() : H(e, a, o);
|
|
597
609
|
return {
|
|
598
610
|
avatarImage: c(t),
|
|
599
611
|
...n ? { backgroundImage: l(n) } : {},
|
|
@@ -603,7 +615,7 @@ function fe(e) {
|
|
|
603
615
|
}
|
|
604
616
|
//#endregion
|
|
605
617
|
//#region src/shims/localStack.ts
|
|
606
|
-
function
|
|
618
|
+
function me() {
|
|
607
619
|
if (globalThis.__LIFORMA_STACK === "local") return !0;
|
|
608
620
|
if (typeof location > "u") return !1;
|
|
609
621
|
try {
|
|
@@ -614,83 +626,83 @@ function pe() {
|
|
|
614
626
|
}
|
|
615
627
|
//#endregion
|
|
616
628
|
//#region src/thumbnail/hostedLaunchUrl.ts
|
|
617
|
-
var
|
|
618
|
-
function
|
|
629
|
+
var he = "https://player.liforma.ai", ge = "http://localhost:3002";
|
|
630
|
+
function _e(e) {
|
|
619
631
|
return e.href?.trim() ? "anchor" : e.hasClickHandler ? "button" : e.experienceId?.trim() ? "anchor" : "presentational";
|
|
620
632
|
}
|
|
621
|
-
function
|
|
633
|
+
function ve(e) {
|
|
622
634
|
let t = e?.trim();
|
|
623
|
-
return t ? t.replace(/\/$/, "") :
|
|
635
|
+
return t ? t.replace(/\/$/, "") : me() ? ge : he;
|
|
624
636
|
}
|
|
625
|
-
function
|
|
626
|
-
let t = e.experienceId.trim(), n =
|
|
637
|
+
function ye(e) {
|
|
638
|
+
let t = e.experienceId.trim(), n = ve(e.playerBaseUrl), r = new URL(`${n}/${encodeURIComponent(t)}`), i = e.returnUrl?.trim();
|
|
627
639
|
return i && r.searchParams.set("returnUrl", i), r.toString();
|
|
628
640
|
}
|
|
629
|
-
function
|
|
641
|
+
function be(e) {
|
|
630
642
|
let t = e.href?.trim();
|
|
631
643
|
if (t) return t;
|
|
632
644
|
let n = e.experienceId?.trim();
|
|
633
645
|
if (!n) return;
|
|
634
646
|
let r = e.returnUrl?.trim();
|
|
635
|
-
return !r && e.useCurrentPageAsReturnUrl && typeof window < "u" && (r = window.location.href),
|
|
647
|
+
return !r && e.useCurrentPageAsReturnUrl && typeof window < "u" && (r = window.location.href), ye({
|
|
636
648
|
experienceId: n,
|
|
637
649
|
...r ? { returnUrl: r } : {},
|
|
638
650
|
playerBaseUrl: e.playerBaseUrl
|
|
639
651
|
});
|
|
640
652
|
}
|
|
641
|
-
function
|
|
653
|
+
function xe() {
|
|
642
654
|
return typeof window > "u" ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
|
|
643
655
|
}
|
|
644
|
-
var
|
|
645
|
-
function
|
|
646
|
-
return
|
|
656
|
+
var Se = 0, Ce = [];
|
|
657
|
+
function we() {
|
|
658
|
+
return xe() ? 4 : Infinity;
|
|
647
659
|
}
|
|
648
|
-
function
|
|
649
|
-
return
|
|
660
|
+
function G() {
|
|
661
|
+
return xe() ? 160 : 0;
|
|
650
662
|
}
|
|
651
|
-
function
|
|
652
|
-
let e =
|
|
653
|
-
for (;
|
|
654
|
-
let e =
|
|
663
|
+
function Te() {
|
|
664
|
+
let e = we();
|
|
665
|
+
for (; Se < e && Ce.length > 0;) {
|
|
666
|
+
let e = Ce.shift();
|
|
655
667
|
if (!e || e.cancelled) continue;
|
|
656
|
-
|
|
657
|
-
let t =
|
|
668
|
+
Se += 1, e.start();
|
|
669
|
+
let t = G();
|
|
658
670
|
if (t <= 0) {
|
|
659
|
-
|
|
671
|
+
Se = Math.max(0, Se - 1);
|
|
660
672
|
continue;
|
|
661
673
|
}
|
|
662
674
|
window.setTimeout(() => {
|
|
663
|
-
|
|
675
|
+
Se = Math.max(0, Se - 1), Te();
|
|
664
676
|
}, t);
|
|
665
677
|
}
|
|
666
678
|
}
|
|
667
|
-
function
|
|
668
|
-
if (!
|
|
679
|
+
function Ee(e) {
|
|
680
|
+
if (!xe()) return e(), () => {};
|
|
669
681
|
let t = {
|
|
670
682
|
start: e,
|
|
671
683
|
cancelled: !1
|
|
672
684
|
};
|
|
673
|
-
return
|
|
685
|
+
return Ce.push(t), Te(), () => {
|
|
674
686
|
t.cancelled = !0;
|
|
675
687
|
};
|
|
676
688
|
}
|
|
677
689
|
//#endregion
|
|
678
690
|
//#region src/thumbnail/lazyLoad.ts
|
|
679
|
-
function
|
|
680
|
-
return
|
|
691
|
+
function De() {
|
|
692
|
+
return xe() ? "96px 0px" : "280px 0px";
|
|
681
693
|
}
|
|
682
|
-
function
|
|
694
|
+
function Oe(e) {
|
|
683
695
|
let t = e.trim().split(/\s+/)[0] ?? "0px", n = Number.parseFloat(t);
|
|
684
696
|
return Number.isFinite(n) ? Math.abs(n) : 280;
|
|
685
697
|
}
|
|
686
|
-
function
|
|
698
|
+
function K(e, t) {
|
|
687
699
|
if (typeof window > "u") return !1;
|
|
688
700
|
let n = e.getBoundingClientRect();
|
|
689
701
|
return n.bottom >= -t && n.top <= window.innerHeight + t;
|
|
690
702
|
}
|
|
691
|
-
function
|
|
692
|
-
let { onVisibleChange: n } = t, r = t.rootMargin ??
|
|
693
|
-
o || (s?.(), s =
|
|
703
|
+
function ke(e, t) {
|
|
704
|
+
let { onVisibleChange: n } = t, r = t.rootMargin ?? De(), i = Oe(r), a = !1, o = !1, s = null, c = () => {
|
|
705
|
+
o || (s?.(), s = Ee(() => {
|
|
694
706
|
s = null, o = !0, n(!0);
|
|
695
707
|
}));
|
|
696
708
|
}, l = (e) => {
|
|
@@ -712,46 +724,46 @@ function Oe(e, t) {
|
|
|
712
724
|
rootMargin: r,
|
|
713
725
|
threshold: 0
|
|
714
726
|
});
|
|
715
|
-
return u.observe(e),
|
|
727
|
+
return u.observe(e), K(e, i) && l(!0), () => {
|
|
716
728
|
s?.(), s = null, u.disconnect();
|
|
717
729
|
};
|
|
718
730
|
}
|
|
719
731
|
//#endregion
|
|
720
732
|
//#region src/thumbnail/scrollParallax.ts
|
|
721
|
-
function
|
|
733
|
+
function Ae() {
|
|
722
734
|
return typeof window > "u" || window.matchMedia("(prefers-reduced-motion: reduce)").matches ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
|
|
723
735
|
}
|
|
724
|
-
function
|
|
736
|
+
function je(e, t) {
|
|
725
737
|
return ((e.top + e.height / 2) / Math.max(t, 1) - .5) * 2;
|
|
726
738
|
}
|
|
727
|
-
var
|
|
739
|
+
var q = /* @__PURE__ */ new Set(), Me = !1, J = 0;
|
|
728
740
|
function Ne() {
|
|
729
|
-
if (
|
|
741
|
+
if (J = 0, q.size === 0 || typeof window > "u") return;
|
|
730
742
|
let e = window.innerHeight;
|
|
731
|
-
for (let t of
|
|
743
|
+
for (let t of q) {
|
|
732
744
|
if (t.pointerActive?.()) continue;
|
|
733
745
|
let n = t.element.getBoundingClientRect();
|
|
734
|
-
n.bottom < -64 || n.top > e + 64 || t.onParallax(
|
|
746
|
+
n.bottom < -64 || n.top > e + 64 || t.onParallax(je(n, e));
|
|
735
747
|
}
|
|
736
748
|
}
|
|
737
749
|
function Pe() {
|
|
738
|
-
|
|
750
|
+
J === 0 && (J = requestAnimationFrame(Ne));
|
|
739
751
|
}
|
|
740
752
|
function Fe() {
|
|
741
|
-
|
|
753
|
+
Me || typeof window > "u" || (Me = !0, window.addEventListener("scroll", Pe, { passive: !0 }), window.addEventListener("resize", Pe, { passive: !0 }));
|
|
742
754
|
}
|
|
743
755
|
function Ie() {
|
|
744
|
-
|
|
756
|
+
q.size > 0 || !Me || typeof window > "u" || (Me = !1, J !== 0 && (cancelAnimationFrame(J), J = 0), window.removeEventListener("scroll", Pe), window.removeEventListener("resize", Pe));
|
|
745
757
|
}
|
|
746
758
|
function Le(e, t) {
|
|
747
|
-
if (!
|
|
759
|
+
if (!Ae()) return () => {};
|
|
748
760
|
let n = {
|
|
749
761
|
element: e,
|
|
750
762
|
onParallax: t.onParallax,
|
|
751
763
|
pointerActive: t.pointerActive
|
|
752
764
|
};
|
|
753
|
-
return
|
|
754
|
-
|
|
765
|
+
return q.add(n), Fe(), n.pointerActive?.() || t.onParallax(je(e.getBoundingClientRect(), window.innerHeight)), () => {
|
|
766
|
+
q.delete(n), Ie();
|
|
755
767
|
};
|
|
756
768
|
}
|
|
757
769
|
//#endregion
|
|
@@ -773,7 +785,7 @@ function Re(e) {
|
|
|
773
785
|
a = !0, e.pointerType === "mouse" && (r = !0), o();
|
|
774
786
|
}, u = () => {
|
|
775
787
|
let s = a;
|
|
776
|
-
a = !1, r = !1, i && s ? (t =
|
|
788
|
+
a = !1, r = !1, i && s ? (t = je(e.getBoundingClientRect(), window.innerHeight), n = 0) : i || (t = 0, n = 0), o();
|
|
777
789
|
}, d = (e) => {
|
|
778
790
|
e.pointerType === "mouse" && (r = !0, o());
|
|
779
791
|
}, f = () => {
|
|
@@ -796,12 +808,47 @@ function Ve(e) {
|
|
|
796
808
|
t.setAttribute("data-liforma-et", ""), t.textContent = e, document.head.appendChild(t), Be = !0;
|
|
797
809
|
}
|
|
798
810
|
//#endregion
|
|
811
|
+
//#region src/thumbnail/plateDelivery.ts
|
|
812
|
+
var He = "data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=", Ue = null;
|
|
813
|
+
function We(e) {
|
|
814
|
+
let t = e.trim();
|
|
815
|
+
if (!t || t.startsWith("blob:") || t.startsWith("data:")) return !1;
|
|
816
|
+
let n = t.split(/[?#]/)[0] ?? t, r = /\/avatars\//i.test(n), i = /\/locations\//i.test(n);
|
|
817
|
+
return !r && !i || /\.depth\.webp$/i.test(n) ? !1 : /\.webp$/i.test(n);
|
|
818
|
+
}
|
|
819
|
+
function Ge(e) {
|
|
820
|
+
if (!We(e)) return null;
|
|
821
|
+
let t = e.search(/[?#]/);
|
|
822
|
+
if (t < 0) return e.replace(/\.webp$/i, ".avif");
|
|
823
|
+
let n = e.slice(0, t), r = e.slice(t);
|
|
824
|
+
return `${n.replace(/\.webp$/i, ".avif")}${r}`;
|
|
825
|
+
}
|
|
826
|
+
function Ke() {
|
|
827
|
+
return typeof Image > "u" ? Promise.resolve(!1) : (Ue ||= new Promise((e) => {
|
|
828
|
+
let t = new Image();
|
|
829
|
+
t.onload = () => e(t.naturalWidth > 0 && t.naturalHeight > 0), t.onerror = () => e(!1), t.src = He;
|
|
830
|
+
}), Ue);
|
|
831
|
+
}
|
|
832
|
+
function qe(e, t) {
|
|
833
|
+
return t ? Ge(e) ?? e : e;
|
|
834
|
+
}
|
|
835
|
+
function Je(e) {
|
|
836
|
+
let t = e.trim(), n = t.search(/[?#]/), r = n < 0 ? t : t.slice(0, n);
|
|
837
|
+
if (!/\.avif$/i.test(r)) return null;
|
|
838
|
+
let i = r.replace(/\.avif$/i, ".webp");
|
|
839
|
+
return n < 0 ? i : `${i}${t.slice(n)}`;
|
|
840
|
+
}
|
|
841
|
+
function Ye(e) {
|
|
842
|
+
let t = e.trim();
|
|
843
|
+
return /-400x225\.(webp|avif)(?:$|[?#])/i.test(t) ? t.replace(/-400x225\.(webp|avif)/i, "-800x450.$1") : null;
|
|
844
|
+
}
|
|
845
|
+
//#endregion
|
|
799
846
|
//#region src/react/ExperienceThumbnail.tsx
|
|
800
|
-
function
|
|
847
|
+
function Xe(e, t) {
|
|
801
848
|
return `${e} liforma-et__media${t ? " liforma-et__media--ready" : ""}`;
|
|
802
849
|
}
|
|
803
|
-
function
|
|
804
|
-
let { galleryThumb: t, avatarImage: r, backgroundImage: i, foregroundImage: c, alt: l, experienceId: p, href: m, target: h, rel: g, onClick: _, returnUrl: v, playerBaseUrl: y, parallax: b = !0, fit: x = "full", lazy: S = !0, className: C = "", fallbackImage: w, normalizeUrls: T = !0, cdnBaseUrl: E } = e, D = o(null), O = o(!1), [k, A] = s(0), [ee, j] = s(0), M =
|
|
850
|
+
function Ze(e) {
|
|
851
|
+
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 = z(k, ee), N = a(() => pe({
|
|
805
852
|
galleryThumb: t,
|
|
806
853
|
avatarImage: r,
|
|
807
854
|
backgroundImage: i,
|
|
@@ -819,15 +866,17 @@ function Ue(e) {
|
|
|
819
866
|
T,
|
|
820
867
|
M,
|
|
821
868
|
E
|
|
822
|
-
]), P =
|
|
869
|
+
]), P = _e({
|
|
823
870
|
href: m,
|
|
824
871
|
hasClickHandler: typeof _ == "function",
|
|
825
872
|
experienceId: p
|
|
826
|
-
}), F = P === "anchor" && !m?.trim() && !!p?.trim(), te = !!N?.backgroundImage, I = b !== !1, [L,
|
|
873
|
+
}), F = P === "anchor" && !m?.trim() && !!p?.trim(), te = !!N?.backgroundImage, I = b !== !1, [L, R] = s(!S), [re, ie] = s(!1), [B, oe] = s(!1), [se, ce] = s(!1), [le, V] = s(!1), [H, U] = s(!1), [ue, de] = s(!1), [W, fe] = s(!1), [me, he] = s(0), [ge, ve] = 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 : "";
|
|
827
874
|
n(() => {
|
|
828
|
-
Ve(ze)
|
|
875
|
+
Ve(ze), Ke().then((e) => {
|
|
876
|
+
ie(e), oe(!0);
|
|
877
|
+
});
|
|
829
878
|
}, []), n(() => {
|
|
830
|
-
|
|
879
|
+
Oe(be({
|
|
831
880
|
href: m,
|
|
832
881
|
experienceId: p,
|
|
833
882
|
returnUrl: v,
|
|
@@ -841,37 +890,37 @@ function Ue(e) {
|
|
|
841
890
|
y,
|
|
842
891
|
F
|
|
843
892
|
]), n(() => {
|
|
844
|
-
|
|
893
|
+
Ce(!1), G(!1), Ee(!1), xe(!1), ce(!1), V(!1), U(!1);
|
|
845
894
|
}, [
|
|
846
895
|
N?.backgroundImage,
|
|
847
896
|
N?.foregroundImage,
|
|
848
|
-
|
|
897
|
+
K
|
|
849
898
|
]), n(() => {
|
|
850
899
|
let e = D.current;
|
|
851
900
|
if (e) return ae(e, (e, t) => {
|
|
852
901
|
A(e), j(t);
|
|
853
902
|
});
|
|
854
|
-
}, [P,
|
|
903
|
+
}, [P, De]), n(() => {
|
|
855
904
|
let e = D.current;
|
|
856
905
|
if (e) {
|
|
857
906
|
if (!S) {
|
|
858
|
-
|
|
907
|
+
R(!0);
|
|
859
908
|
return;
|
|
860
909
|
}
|
|
861
|
-
return
|
|
862
|
-
e &&
|
|
910
|
+
return ke(e, { onVisibleChange: (e) => {
|
|
911
|
+
e && R(!0);
|
|
863
912
|
} });
|
|
864
913
|
}
|
|
865
914
|
}, [
|
|
866
915
|
S,
|
|
867
916
|
N,
|
|
868
917
|
P,
|
|
869
|
-
|
|
918
|
+
De
|
|
870
919
|
]), n(() => {
|
|
871
920
|
let e = D.current;
|
|
872
921
|
if (!(!e || !I)) return Le(e, {
|
|
873
922
|
onParallax: (e) => {
|
|
874
|
-
|
|
923
|
+
fe(!0), O.current || (he(e), ve(0));
|
|
875
924
|
},
|
|
876
925
|
pointerActive: () => O.current
|
|
877
926
|
});
|
|
@@ -879,25 +928,25 @@ function Ue(e) {
|
|
|
879
928
|
I,
|
|
880
929
|
N,
|
|
881
930
|
P,
|
|
882
|
-
|
|
931
|
+
De
|
|
883
932
|
]);
|
|
884
|
-
let
|
|
885
|
-
if (!I ||
|
|
933
|
+
let Ae = (e) => {
|
|
934
|
+
if (!I || W) return;
|
|
886
935
|
let t = e.currentTarget.getBoundingClientRect();
|
|
887
|
-
t.width <= 0 || t.height <= 0 || (
|
|
888
|
-
},
|
|
936
|
+
t.width <= 0 || t.height <= 0 || (he(((e.clientX - t.left) / t.width - .5) * 2), ve(((e.clientY - t.top) / t.height - .5) * 2));
|
|
937
|
+
}, q = (e) => {
|
|
889
938
|
let t = O.current;
|
|
890
|
-
O.current = !1,
|
|
891
|
-
},
|
|
939
|
+
O.current = !1, de(!1), W && t ? (he(je(e.getBoundingClientRect(), window.innerHeight)), ve(0)) : W || (he(0), ve(0));
|
|
940
|
+
}, Me = (e) => {
|
|
892
941
|
if (!I) return;
|
|
893
|
-
O.current = !0, e.pointerType === "mouse" &&
|
|
942
|
+
O.current = !0, e.pointerType === "mouse" && de(!0);
|
|
894
943
|
let t = e.currentTarget, n = () => {
|
|
895
|
-
|
|
944
|
+
q(t), window.removeEventListener("pointerup", n), window.removeEventListener("pointercancel", n);
|
|
896
945
|
};
|
|
897
946
|
window.addEventListener("pointerup", n), window.addEventListener("pointercancel", n);
|
|
898
|
-
},
|
|
947
|
+
}, J = (e) => {
|
|
899
948
|
if (_?.(e), !e.defaultPrevented && F && !v?.trim()) {
|
|
900
|
-
let t =
|
|
949
|
+
let t = be({
|
|
901
950
|
experienceId: p,
|
|
902
951
|
playerBaseUrl: y,
|
|
903
952
|
useCurrentPageAsReturnUrl: !0
|
|
@@ -906,134 +955,153 @@ function Ue(e) {
|
|
|
906
955
|
}
|
|
907
956
|
};
|
|
908
957
|
if (!N) return null;
|
|
909
|
-
let
|
|
958
|
+
let Ne = I && (ue || W), Pe = L && B && (we || Se || Te), Fe = [
|
|
910
959
|
"liforma-et",
|
|
911
960
|
te ? "liforma-et--scene" : "",
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
L && !
|
|
916
|
-
|
|
961
|
+
ne(x),
|
|
962
|
+
Ne ? "liforma-et--parallax" : "",
|
|
963
|
+
W ? "liforma-et--scroll-parallax" : "",
|
|
964
|
+
L && !Pe ? "liforma-et--loading" : "",
|
|
965
|
+
Pe ? "liforma-et--revealed" : "",
|
|
917
966
|
C
|
|
918
|
-
].filter(Boolean).join(" "),
|
|
919
|
-
"--liforma-et-parallax-x":
|
|
920
|
-
"--liforma-et-parallax-y":
|
|
921
|
-
},
|
|
967
|
+
].filter(Boolean).join(" "), Ie = {
|
|
968
|
+
"--liforma-et-parallax-x": me,
|
|
969
|
+
"--liforma-et-parallax-y": ge
|
|
970
|
+
}, Re = (e, t) => {
|
|
922
971
|
e.complete && t(!0);
|
|
923
|
-
},
|
|
972
|
+
}, Be = /* @__PURE__ */ f(u, { children: [
|
|
924
973
|
/* @__PURE__ */ d("span", {
|
|
925
974
|
className: "liforma-et__placeholder",
|
|
926
975
|
"aria-hidden": "true"
|
|
927
976
|
}),
|
|
928
|
-
L && N.backgroundImage ? /* @__PURE__ */ d("img", {
|
|
929
|
-
className:
|
|
930
|
-
src: N.backgroundImage,
|
|
977
|
+
L && B && N.backgroundImage ? /* @__PURE__ */ d("img", {
|
|
978
|
+
className: Xe("liforma-et__background", Se),
|
|
979
|
+
src: qe(N.backgroundImage, re),
|
|
931
980
|
alt: "",
|
|
932
981
|
decoding: "async",
|
|
933
982
|
ref: (e) => {
|
|
934
|
-
e &&
|
|
983
|
+
e && Re(e, Ce);
|
|
935
984
|
},
|
|
936
|
-
onLoad: () =>
|
|
937
|
-
onError: () =>
|
|
985
|
+
onLoad: () => Ce(!0),
|
|
986
|
+
onError: (e) => {
|
|
987
|
+
let t = e.currentTarget, n = Ye(t.src);
|
|
988
|
+
if (n && !se) {
|
|
989
|
+
ce(!0), t.src = n;
|
|
990
|
+
return;
|
|
991
|
+
}
|
|
992
|
+
Ce(!0);
|
|
993
|
+
}
|
|
938
994
|
}) : null,
|
|
939
|
-
L &&
|
|
940
|
-
className:
|
|
941
|
-
src:
|
|
995
|
+
L && B && K ? /* @__PURE__ */ d("img", {
|
|
996
|
+
className: Xe("liforma-et__avatar", we),
|
|
997
|
+
src: qe(K, re),
|
|
942
998
|
alt: "",
|
|
943
999
|
decoding: "async",
|
|
944
1000
|
ref: (e) => {
|
|
945
|
-
e &&
|
|
1001
|
+
e && Re(e, G);
|
|
946
1002
|
},
|
|
947
1003
|
onLoad: () => G(!0),
|
|
948
|
-
onError: () => {
|
|
949
|
-
|
|
1004
|
+
onError: (e) => {
|
|
1005
|
+
let t = e.currentTarget, n = Je(t.src);
|
|
1006
|
+
if (n && !H) {
|
|
1007
|
+
U(!0), t.src = n;
|
|
1008
|
+
return;
|
|
1009
|
+
}
|
|
1010
|
+
N.fallbackImage ? xe(!0) : G(!0);
|
|
950
1011
|
}
|
|
951
1012
|
}) : null,
|
|
952
|
-
L && N.foregroundImage ? /* @__PURE__ */ d("img", {
|
|
953
|
-
className:
|
|
954
|
-
src: N.foregroundImage,
|
|
1013
|
+
L && B && N.foregroundImage ? /* @__PURE__ */ d("img", {
|
|
1014
|
+
className: Xe("liforma-et__foreground", Te),
|
|
1015
|
+
src: qe(N.foregroundImage, re),
|
|
955
1016
|
alt: "",
|
|
956
1017
|
decoding: "async",
|
|
957
1018
|
ref: (e) => {
|
|
958
|
-
e &&
|
|
1019
|
+
e && Re(e, Ee);
|
|
959
1020
|
},
|
|
960
|
-
onLoad: () =>
|
|
961
|
-
onError: () =>
|
|
1021
|
+
onLoad: () => Ee(!0),
|
|
1022
|
+
onError: (e) => {
|
|
1023
|
+
let t = e.currentTarget, n = Ye(t.src);
|
|
1024
|
+
if (n && !le) {
|
|
1025
|
+
V(!0), t.src = n;
|
|
1026
|
+
return;
|
|
1027
|
+
}
|
|
1028
|
+
Ee(!0);
|
|
1029
|
+
}
|
|
962
1030
|
}) : null
|
|
963
|
-
] }),
|
|
964
|
-
onPointerDown:
|
|
965
|
-
onPointerUp: (e) =>
|
|
966
|
-
onPointerCancel: (e) =>
|
|
1031
|
+
] }), He = {
|
|
1032
|
+
onPointerDown: Me,
|
|
1033
|
+
onPointerUp: (e) => q(e.currentTarget),
|
|
1034
|
+
onPointerCancel: (e) => q(e.currentTarget),
|
|
967
1035
|
onPointerEnter: (e) => {
|
|
968
|
-
I && e.pointerType === "mouse" &&
|
|
1036
|
+
I && e.pointerType === "mouse" && de(!0);
|
|
969
1037
|
},
|
|
970
|
-
onPointerMove:
|
|
1038
|
+
onPointerMove: Ae,
|
|
971
1039
|
onPointerLeave: () => {
|
|
972
|
-
O.current || (
|
|
1040
|
+
O.current || (de(!1), W || (he(0), ve(0)));
|
|
973
1041
|
}
|
|
974
|
-
},
|
|
1042
|
+
}, Ue = (e) => {
|
|
975
1043
|
D.current = e;
|
|
976
1044
|
};
|
|
977
|
-
return P === "anchor" &&
|
|
978
|
-
ref:
|
|
979
|
-
className:
|
|
980
|
-
style:
|
|
981
|
-
href:
|
|
1045
|
+
return P === "anchor" && De ? /* @__PURE__ */ d("a", {
|
|
1046
|
+
ref: Ue,
|
|
1047
|
+
className: Fe,
|
|
1048
|
+
style: Ie,
|
|
1049
|
+
href: De,
|
|
982
1050
|
target: h,
|
|
983
1051
|
rel: g,
|
|
984
1052
|
"aria-label": l,
|
|
985
|
-
onClick:
|
|
986
|
-
...
|
|
987
|
-
children:
|
|
1053
|
+
onClick: J,
|
|
1054
|
+
...He,
|
|
1055
|
+
children: Be
|
|
988
1056
|
}) : P === "button" ? /* @__PURE__ */ d("button", {
|
|
989
1057
|
type: "button",
|
|
990
|
-
ref:
|
|
991
|
-
className:
|
|
992
|
-
style:
|
|
1058
|
+
ref: Ue,
|
|
1059
|
+
className: Fe,
|
|
1060
|
+
style: Ie,
|
|
993
1061
|
"aria-label": l,
|
|
994
|
-
onClick:
|
|
995
|
-
...
|
|
996
|
-
children:
|
|
1062
|
+
onClick: J,
|
|
1063
|
+
...He,
|
|
1064
|
+
children: Be
|
|
997
1065
|
}) : /* @__PURE__ */ d("div", {
|
|
998
|
-
ref:
|
|
999
|
-
className:
|
|
1000
|
-
style:
|
|
1066
|
+
ref: Ue,
|
|
1067
|
+
className: Fe,
|
|
1068
|
+
style: Ie,
|
|
1001
1069
|
role: l ? "img" : void 0,
|
|
1002
1070
|
"aria-label": l || void 0,
|
|
1003
1071
|
"aria-hidden": l ? void 0 : !0,
|
|
1004
|
-
...
|
|
1005
|
-
children:
|
|
1072
|
+
...He,
|
|
1073
|
+
children: Be
|
|
1006
1074
|
});
|
|
1007
1075
|
}
|
|
1008
1076
|
//#endregion
|
|
1009
1077
|
//#region src/widget/styles.ts
|
|
1010
|
-
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";
|
|
1011
|
-
function
|
|
1078
|
+
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";
|
|
1079
|
+
function et(e = Qe) {
|
|
1012
1080
|
if (typeof document > "u") return;
|
|
1013
|
-
let t = document.getElementById(
|
|
1081
|
+
let t = document.getElementById($e);
|
|
1014
1082
|
if (t) {
|
|
1015
1083
|
t.textContent = e;
|
|
1016
1084
|
return;
|
|
1017
1085
|
}
|
|
1018
1086
|
let n = document.createElement("style");
|
|
1019
|
-
n.id =
|
|
1087
|
+
n.id = $e, n.textContent = e, document.head.append(n);
|
|
1020
1088
|
}
|
|
1021
1089
|
//#endregion
|
|
1022
1090
|
//#region src/shims/apiBaseUrl.ts
|
|
1023
|
-
var
|
|
1024
|
-
function
|
|
1091
|
+
var tt = "https://api.liforma.ai", nt = "http://localhost:3001";
|
|
1092
|
+
function rt() {
|
|
1025
1093
|
let e = globalThis.__LIFORMA_API_BASE_URL;
|
|
1026
1094
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
1027
1095
|
if (typeof document > "u") return null;
|
|
1028
1096
|
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();
|
|
1029
1097
|
return t ? t.replace(/\/$/, "") : null;
|
|
1030
1098
|
}
|
|
1031
|
-
function
|
|
1032
|
-
return
|
|
1099
|
+
function it() {
|
|
1100
|
+
return rt() || (me() ? nt : tt);
|
|
1033
1101
|
}
|
|
1034
1102
|
//#endregion
|
|
1035
1103
|
//#region src/v2/api/fetchExperiencePreview.ts
|
|
1036
|
-
function
|
|
1104
|
+
function at(e) {
|
|
1037
1105
|
if (!e || typeof e != "object") return null;
|
|
1038
1106
|
let t = e, n = typeof t.avatarImage == "string" ? t.avatarImage.trim() : "";
|
|
1039
1107
|
return n ? {
|
|
@@ -1042,10 +1110,10 @@ function Ze(e) {
|
|
|
1042
1110
|
...typeof t.foregroundImage == "string" && t.foregroundImage.trim() ? { foregroundImage: t.foregroundImage.trim() } : {}
|
|
1043
1111
|
} : null;
|
|
1044
1112
|
}
|
|
1045
|
-
async function
|
|
1113
|
+
async function ot(e, t) {
|
|
1046
1114
|
let n = e.trim();
|
|
1047
1115
|
if (!n) throw Error("Experience preview requires experienceId.");
|
|
1048
|
-
let r = (t?.apiBaseUrl ??
|
|
1116
|
+
let r = (t?.apiBaseUrl ?? it()).replace(/\/$/, ""), i = await fetch(`${r}/v1/experiences/${encodeURIComponent(n)}/preview`, {
|
|
1049
1117
|
method: "GET",
|
|
1050
1118
|
headers: { Accept: "application/json" },
|
|
1051
1119
|
signal: t?.signal
|
|
@@ -1065,7 +1133,7 @@ async function Qe(e, t) {
|
|
|
1065
1133
|
throw Error("Experience preview returned invalid JSON.");
|
|
1066
1134
|
}
|
|
1067
1135
|
if (!a || typeof a != "object") throw Error("Experience preview returned an invalid payload.");
|
|
1068
|
-
let o = a, s = typeof o.experienceId == "string" ? o.experienceId.trim() : n, c = typeof o.title == "string" ? o.title.trim() : "", l =
|
|
1136
|
+
let o = a, s = typeof o.experienceId == "string" ? o.experienceId.trim() : n, c = typeof o.title == "string" ? o.title.trim() : "", l = at(o.galleryThumb);
|
|
1069
1137
|
if (!l) throw Error("Experience preview is missing gallery thumb images.");
|
|
1070
1138
|
return {
|
|
1071
1139
|
experienceId: s || n,
|
|
@@ -1075,7 +1143,7 @@ async function Qe(e, t) {
|
|
|
1075
1143
|
}
|
|
1076
1144
|
//#endregion
|
|
1077
1145
|
//#region src/v2/errors/LiformaError.ts
|
|
1078
|
-
var
|
|
1146
|
+
var st = class extends Error {
|
|
1079
1147
|
code;
|
|
1080
1148
|
requestId;
|
|
1081
1149
|
status;
|
|
@@ -1084,16 +1152,16 @@ var $e = class extends Error {
|
|
|
1084
1152
|
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;
|
|
1085
1153
|
}
|
|
1086
1154
|
};
|
|
1087
|
-
function
|
|
1155
|
+
function ct(e) {
|
|
1088
1156
|
if (!(!e || typeof e != "object" || Array.isArray(e))) return e;
|
|
1089
1157
|
}
|
|
1090
|
-
function
|
|
1158
|
+
function lt(e, t, n) {
|
|
1091
1159
|
let r = n?.get("Liforma-Request-Id")?.trim() || void 0, i;
|
|
1092
1160
|
try {
|
|
1093
1161
|
i = JSON.parse(t);
|
|
1094
1162
|
} catch {}
|
|
1095
|
-
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 } =
|
|
1096
|
-
return new
|
|
1163
|
+
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) ?? {};
|
|
1164
|
+
return new st(u, {
|
|
1097
1165
|
code: l,
|
|
1098
1166
|
requestId: d,
|
|
1099
1167
|
status: e,
|
|
@@ -1102,13 +1170,13 @@ function tt(e, t, n) {
|
|
|
1102
1170
|
}
|
|
1103
1171
|
//#endregion
|
|
1104
1172
|
//#region src/v2/api/captureAttribution.ts
|
|
1105
|
-
var
|
|
1173
|
+
var ut = 128, dt = /[\u0000-\u001f\u007f]/g;
|
|
1106
1174
|
function Y(e) {
|
|
1107
1175
|
if (!e) return;
|
|
1108
|
-
let t = e.replace(
|
|
1109
|
-
if (t) return t.slice(0,
|
|
1176
|
+
let t = e.replace(dt, "").trim();
|
|
1177
|
+
if (t) return t.slice(0, ut);
|
|
1110
1178
|
}
|
|
1111
|
-
function
|
|
1179
|
+
function ft(e) {
|
|
1112
1180
|
let t = new URLSearchParams((e ?? "").startsWith("?") ? (e ?? "").slice(1) : e ?? "");
|
|
1113
1181
|
return {
|
|
1114
1182
|
...Y(t.get("utm_source")) ? { utmSource: Y(t.get("utm_source")) } : {},
|
|
@@ -1118,7 +1186,7 @@ function it(e) {
|
|
|
1118
1186
|
...Y(t.get("utm_term")) ? { utmTerm: Y(t.get("utm_term")) } : {}
|
|
1119
1187
|
};
|
|
1120
1188
|
}
|
|
1121
|
-
function
|
|
1189
|
+
function pt(e) {
|
|
1122
1190
|
if (e === !1) return;
|
|
1123
1191
|
if (e && typeof e == "object") {
|
|
1124
1192
|
let t = {
|
|
@@ -1132,7 +1200,7 @@ function at(e) {
|
|
|
1132
1200
|
return Object.keys(t).length ? t : void 0;
|
|
1133
1201
|
}
|
|
1134
1202
|
if (typeof window > "u") return;
|
|
1135
|
-
let t =
|
|
1203
|
+
let t = ft(window.location?.search), n = Y(document.referrer || void 0), r = {
|
|
1136
1204
|
...t,
|
|
1137
1205
|
...n ? { referrer: n } : {}
|
|
1138
1206
|
};
|
|
@@ -1140,19 +1208,19 @@ function at(e) {
|
|
|
1140
1208
|
}
|
|
1141
1209
|
//#endregion
|
|
1142
1210
|
//#region src/v2/api/sessionEndpointRequest.ts
|
|
1143
|
-
function
|
|
1211
|
+
function mt(e) {
|
|
1144
1212
|
let t = e.locale?.trim();
|
|
1145
1213
|
if (t) return t;
|
|
1146
1214
|
let n = e.language?.trim();
|
|
1147
1215
|
if (n) return n;
|
|
1148
1216
|
if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
|
|
1149
1217
|
}
|
|
1150
|
-
function
|
|
1218
|
+
function ht(e) {
|
|
1151
1219
|
let t = e.secondaryLocale?.trim(), n = e.learningLocale?.trim();
|
|
1152
1220
|
if (t && n && t !== n) throw Error("secondaryLocale and learningLocale disagree; pass only one or make them equal.");
|
|
1153
1221
|
return t || n || void 0;
|
|
1154
1222
|
}
|
|
1155
|
-
function
|
|
1223
|
+
function gt(e, t) {
|
|
1156
1224
|
let n = e.trim();
|
|
1157
1225
|
if (!n) throw Error("sessionEndpoint must not be empty.");
|
|
1158
1226
|
if (typeof location > "u") throw Error("sessionEndpoint is only available in a browser.");
|
|
@@ -1160,7 +1228,7 @@ function ct(e, t) {
|
|
|
1160
1228
|
if (r.origin !== location.origin) throw Error("sessionEndpoint must be same-origin.");
|
|
1161
1229
|
let i = t.experienceId.trim();
|
|
1162
1230
|
if (!i) throw Error("sessionEndpoint requires experienceId.");
|
|
1163
|
-
let a =
|
|
1231
|
+
let a = mt(t), o = ht(t), s = t.idempotencyKey?.trim();
|
|
1164
1232
|
return {
|
|
1165
1233
|
url: r.toString(),
|
|
1166
1234
|
init: {
|
|
@@ -1179,7 +1247,7 @@ function ct(e, t) {
|
|
|
1179
1247
|
...t.speechInputMode ? { speechInputMode: t.speechInputMode } : {},
|
|
1180
1248
|
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
|
|
1181
1249
|
...(() => {
|
|
1182
|
-
let e =
|
|
1250
|
+
let e = pt(t.attribution);
|
|
1183
1251
|
return e ? { attribution: e } : {};
|
|
1184
1252
|
})(),
|
|
1185
1253
|
...t.alreadyConverted?.length ? { alreadyConverted: [...t.alreadyConverted] } : {}
|
|
@@ -1189,16 +1257,19 @@ function ct(e, t) {
|
|
|
1189
1257
|
}
|
|
1190
1258
|
//#endregion
|
|
1191
1259
|
//#region src/v2/types/sessionLaunch.ts
|
|
1192
|
-
function
|
|
1260
|
+
function _t(e, t) {
|
|
1261
|
+
return t === void 0 ? {} : { [e]: t };
|
|
1262
|
+
}
|
|
1263
|
+
function vt(e) {
|
|
1193
1264
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
1194
1265
|
}
|
|
1195
1266
|
function X(e) {
|
|
1196
1267
|
return typeof e == "boolean";
|
|
1197
1268
|
}
|
|
1198
|
-
function
|
|
1199
|
-
if (!
|
|
1269
|
+
function yt(e) {
|
|
1270
|
+
if (!vt(e)) return null;
|
|
1200
1271
|
let t = e.speech, n = e.conversation, r = e.avatar, i = e.tools;
|
|
1201
|
-
return !
|
|
1272
|
+
return !vt(t) || !vt(n) || !vt(r) || !vt(i) || !X(t.input) || !X(t.output) || !X(t.externalAudio) || !X(n.managed) || !X(r.enabled) || !X(i.enabled) ? null : {
|
|
1202
1273
|
speech: {
|
|
1203
1274
|
input: t.input,
|
|
1204
1275
|
output: t.output,
|
|
@@ -1209,8 +1280,8 @@ function ut(e) {
|
|
|
1209
1280
|
tools: { enabled: i.enabled }
|
|
1210
1281
|
};
|
|
1211
1282
|
}
|
|
1212
|
-
function
|
|
1213
|
-
return !
|
|
1283
|
+
function bt(e) {
|
|
1284
|
+
return !vt(e) || !X(e.avatar) || !X(e.speechInput) || !X(e.speechOutput) || !X(e.tools) || !X(e.externalAudio) ? null : {
|
|
1214
1285
|
speech: {
|
|
1215
1286
|
input: e.speechInput,
|
|
1216
1287
|
output: e.speechOutput,
|
|
@@ -1221,12 +1292,12 @@ function dt(e) {
|
|
|
1221
1292
|
tools: { enabled: e.tools }
|
|
1222
1293
|
};
|
|
1223
1294
|
}
|
|
1224
|
-
function
|
|
1225
|
-
return
|
|
1295
|
+
function xt(e) {
|
|
1296
|
+
return yt(e) ?? bt(e);
|
|
1226
1297
|
}
|
|
1227
|
-
function
|
|
1228
|
-
if (!
|
|
1229
|
-
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 =
|
|
1298
|
+
function St(e) {
|
|
1299
|
+
if (!vt(e)) throw Error("Session Launch response is missing session.");
|
|
1300
|
+
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 = xt(e.capabilities), l = Ct(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;
|
|
1230
1301
|
if (!t || !n || !r || !i || !a || !s || !c) throw Error("Session Launch response has an invalid session object.");
|
|
1231
1302
|
return {
|
|
1232
1303
|
id: t,
|
|
@@ -1242,11 +1313,11 @@ function pt(e) {
|
|
|
1242
1313
|
...d ? { createdAt: d } : {}
|
|
1243
1314
|
};
|
|
1244
1315
|
}
|
|
1245
|
-
function
|
|
1316
|
+
function Ct(e) {
|
|
1246
1317
|
if (!Array.isArray(e) || e.length === 0) return;
|
|
1247
1318
|
let t = [];
|
|
1248
1319
|
for (let n of e) {
|
|
1249
|
-
if (!
|
|
1320
|
+
if (!vt(n)) continue;
|
|
1250
1321
|
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() : "";
|
|
1251
1322
|
!e || !r || !i || n.reason !== "voice_unsupported" || t.push({
|
|
1252
1323
|
axis: e,
|
|
@@ -1257,104 +1328,104 @@ function mt(e) {
|
|
|
1257
1328
|
}
|
|
1258
1329
|
return t.length > 0 ? t : void 0;
|
|
1259
1330
|
}
|
|
1260
|
-
function
|
|
1331
|
+
function wt(e) {
|
|
1261
1332
|
let t = e.localeVoiceFallbacks;
|
|
1262
1333
|
if (t?.length) for (let e of t) {
|
|
1263
1334
|
let t = e.axis === "secondaryLocale" ? "secondaryLocale" : "locale";
|
|
1264
1335
|
console.warn(`[liforma] Session ${t} fell back to ${e.resolved} because the voice does not support ${e.requested}.`);
|
|
1265
1336
|
}
|
|
1266
1337
|
}
|
|
1267
|
-
function
|
|
1268
|
-
if (!
|
|
1338
|
+
function Tt(e) {
|
|
1339
|
+
if (!vt(e)) throw Error("Session Launch response must be a JSON object.");
|
|
1269
1340
|
let t = typeof e.launch == "string" ? e.launch.trim() : "";
|
|
1270
1341
|
if (!t) throw Error("Session Launch response is missing launch.");
|
|
1271
|
-
let n =
|
|
1272
|
-
return
|
|
1342
|
+
let n = St(e.session);
|
|
1343
|
+
return wt(n), {
|
|
1273
1344
|
session: n,
|
|
1274
1345
|
launch: t
|
|
1275
1346
|
};
|
|
1276
1347
|
}
|
|
1277
1348
|
//#endregion
|
|
1278
1349
|
//#region src/v2/api/mintPublicSession.ts
|
|
1279
|
-
function
|
|
1350
|
+
function Et() {
|
|
1280
1351
|
try {
|
|
1281
1352
|
if (typeof globalThis.location?.origin == "string" && globalThis.location.origin) return globalThis.location.origin;
|
|
1282
1353
|
} catch {}
|
|
1283
1354
|
}
|
|
1284
|
-
function
|
|
1355
|
+
function Dt(e) {
|
|
1285
1356
|
return e ? e.trim().toUpperCase().replace(/-/g, "_") : "";
|
|
1286
1357
|
}
|
|
1287
|
-
function
|
|
1288
|
-
let n =
|
|
1358
|
+
function Ot(e, t) {
|
|
1359
|
+
let n = Et(), r = Dt(t.code), i = t.message.trim(), a = t.details ?? {};
|
|
1289
1360
|
if (r === "ORIGIN_NOT_ALLOWED" || /^Origin not allowed/i.test(i) && n) {
|
|
1290
1361
|
if (i.includes(e) && i.includes("allowed origin")) return t;
|
|
1291
1362
|
let r = typeof a.origin == "string" && a.origin || n || "(unknown origin)";
|
|
1292
|
-
return new
|
|
1363
|
+
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.`, {
|
|
1293
1364
|
code: "ORIGIN_NOT_ALLOWED",
|
|
1294
1365
|
requestId: t.requestId,
|
|
1295
1366
|
status: t.status,
|
|
1296
1367
|
details: a
|
|
1297
1368
|
});
|
|
1298
1369
|
}
|
|
1299
|
-
return r === "BROWSER_EMBEDS_DISABLED" || /^Browser embeds are not enabled/i.test(i) ? i.includes("Allow public client-only embeds") ? t : new
|
|
1370
|
+
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”.`, {
|
|
1300
1371
|
code: "BROWSER_EMBEDS_DISABLED",
|
|
1301
1372
|
requestId: t.requestId,
|
|
1302
1373
|
status: t.status,
|
|
1303
1374
|
details: a
|
|
1304
|
-
}) : r === "EXPERIENCE_UNAVAILABLE" || /^Experience is not available\.?$/i.test(i) || /^Unknown experience\.?$/i.test(i) ? i.includes("No playable experience found") ? t : new
|
|
1375
|
+
}) : 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.`, {
|
|
1305
1376
|
code: "EXPERIENCE_UNAVAILABLE",
|
|
1306
1377
|
requestId: t.requestId,
|
|
1307
1378
|
status: t.status,
|
|
1308
1379
|
details: a
|
|
1309
1380
|
}) : t;
|
|
1310
1381
|
}
|
|
1311
|
-
function
|
|
1382
|
+
function kt(e) {
|
|
1312
1383
|
let t = e?.locale?.trim();
|
|
1313
1384
|
if (t) return t;
|
|
1314
1385
|
let n = e?.language?.trim();
|
|
1315
1386
|
if (n) return n;
|
|
1316
1387
|
if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
|
|
1317
1388
|
}
|
|
1318
|
-
function
|
|
1389
|
+
function At(e) {
|
|
1319
1390
|
let t = e?.secondaryLocale?.trim(), n = e?.learningLocale?.trim();
|
|
1320
|
-
if (t && n && t !== n) throw new
|
|
1391
|
+
if (t && n && t !== n) throw new st("secondaryLocale and learningLocale disagree; pass only one or make them equal.", { code: "INVALID_BODY" });
|
|
1321
1392
|
return t || n || void 0;
|
|
1322
1393
|
}
|
|
1323
|
-
function
|
|
1324
|
-
let n = { experienceId: e }, r =
|
|
1394
|
+
function jt(e, t) {
|
|
1395
|
+
let n = { experienceId: e }, r = kt(t);
|
|
1325
1396
|
r && (n.locale = r);
|
|
1326
|
-
let i =
|
|
1397
|
+
let i = At(t);
|
|
1327
1398
|
i && (n.secondaryLocale = i), t?.mode && (n.mode = t.mode), t?.speechInputMode && (n.speechInputMode = t.speechInputMode), t?.speechOnly !== void 0 && (n.speechOnly = t.speechOnly);
|
|
1328
|
-
let a =
|
|
1399
|
+
let a = pt(t?.attribution);
|
|
1329
1400
|
return a && (n.attribution = a), t?.alreadyConverted?.length && (n.alreadyConverted = [...t.alreadyConverted]), n;
|
|
1330
1401
|
}
|
|
1331
|
-
async function
|
|
1332
|
-
let n =
|
|
1402
|
+
async function Mt(e, t) {
|
|
1403
|
+
let n = it(), r = t?.idempotencyKey?.trim(), i = await fetch(`${n}/v1/browser-sessions`, {
|
|
1333
1404
|
method: "POST",
|
|
1334
1405
|
headers: {
|
|
1335
1406
|
"Content-Type": "application/json",
|
|
1336
1407
|
...r ? { "Idempotency-Key": r } : {}
|
|
1337
1408
|
},
|
|
1338
|
-
body: JSON.stringify(
|
|
1409
|
+
body: JSON.stringify(jt(e, t))
|
|
1339
1410
|
});
|
|
1340
1411
|
if (!i.ok) {
|
|
1341
1412
|
let t = await i.text();
|
|
1342
|
-
throw
|
|
1413
|
+
throw Ot(e, lt(i.status, t, i.headers));
|
|
1343
1414
|
}
|
|
1344
1415
|
let a;
|
|
1345
1416
|
try {
|
|
1346
1417
|
a = await i.json();
|
|
1347
1418
|
} catch {
|
|
1348
|
-
throw new
|
|
1419
|
+
throw new st("Browser session mint returned invalid JSON.", {
|
|
1349
1420
|
code: "INVALID_RESPONSE",
|
|
1350
1421
|
status: i.status,
|
|
1351
1422
|
requestId: i.headers.get("Liforma-Request-Id") ?? void 0
|
|
1352
1423
|
});
|
|
1353
1424
|
}
|
|
1354
|
-
return
|
|
1425
|
+
return Tt(a);
|
|
1355
1426
|
}
|
|
1356
|
-
async function
|
|
1357
|
-
let n =
|
|
1427
|
+
async function Nt(e, t) {
|
|
1428
|
+
let n = gt(e, t), r = new AbortController(), i = () => r.abort(t.signal?.reason);
|
|
1358
1429
|
t.signal?.aborted ? i() : t.signal?.addEventListener("abort", i, { once: !0 });
|
|
1359
1430
|
let a = globalThis.setTimeout(() => r.abort(new DOMException("Session endpoint timed out.", "TimeoutError")), t.timeoutMs ?? 3e4), o;
|
|
1360
1431
|
try {
|
|
@@ -1367,9 +1438,9 @@ async function wt(e, t) {
|
|
|
1367
1438
|
}
|
|
1368
1439
|
if (!o.ok) {
|
|
1369
1440
|
let e = await o.text();
|
|
1370
|
-
throw
|
|
1441
|
+
throw lt(o.status, e, o.headers);
|
|
1371
1442
|
}
|
|
1372
|
-
if (!o.headers.get("content-type")?.toLowerCase().includes("application/json")) throw new
|
|
1443
|
+
if (!o.headers.get("content-type")?.toLowerCase().includes("application/json")) throw new st("Session endpoint must return a JSON Session Launch response.", {
|
|
1373
1444
|
code: "INVALID_RESPONSE",
|
|
1374
1445
|
status: o.status,
|
|
1375
1446
|
requestId: o.headers.get("Liforma-Request-Id") ?? void 0
|
|
@@ -1378,20 +1449,20 @@ async function wt(e, t) {
|
|
|
1378
1449
|
try {
|
|
1379
1450
|
s = await o.json();
|
|
1380
1451
|
} catch {
|
|
1381
|
-
throw new
|
|
1452
|
+
throw new st("Session endpoint returned invalid JSON.", {
|
|
1382
1453
|
code: "INVALID_RESPONSE",
|
|
1383
1454
|
status: o.status,
|
|
1384
1455
|
requestId: o.headers.get("Liforma-Request-Id") ?? void 0
|
|
1385
1456
|
});
|
|
1386
1457
|
}
|
|
1387
|
-
return
|
|
1458
|
+
return Tt(s);
|
|
1388
1459
|
}
|
|
1389
1460
|
//#endregion
|
|
1390
1461
|
//#region src/v2/conversationProcessor.ts
|
|
1391
|
-
function
|
|
1462
|
+
function Pt(e) {
|
|
1392
1463
|
return typeof e != "object" || !e ? !1 : typeof e[Symbol.asyncIterator] == "function";
|
|
1393
1464
|
}
|
|
1394
|
-
function
|
|
1465
|
+
function Ft(e) {
|
|
1395
1466
|
if (typeof e == "string") {
|
|
1396
1467
|
let t = e.trim();
|
|
1397
1468
|
if (!t) throw Error("conversationProcessor returned empty text.");
|
|
@@ -1405,24 +1476,24 @@ function Et(e) {
|
|
|
1405
1476
|
...e.behavior ? { behavior: e.behavior } : {}
|
|
1406
1477
|
};
|
|
1407
1478
|
}
|
|
1408
|
-
async function
|
|
1479
|
+
async function It(e, t) {
|
|
1409
1480
|
let n = await e(t);
|
|
1410
|
-
return
|
|
1481
|
+
return Pt(n) ? {
|
|
1411
1482
|
kind: "stream",
|
|
1412
1483
|
stream: n
|
|
1413
1484
|
} : {
|
|
1414
1485
|
kind: "complete",
|
|
1415
|
-
speech:
|
|
1486
|
+
speech: Ft(n)
|
|
1416
1487
|
};
|
|
1417
1488
|
}
|
|
1418
1489
|
//#endregion
|
|
1419
1490
|
//#region src/v2/embed/playerReachability.ts
|
|
1420
|
-
var
|
|
1421
|
-
function
|
|
1491
|
+
var Lt = "3002";
|
|
1492
|
+
function Rt(e) {
|
|
1422
1493
|
let t = new URL(e);
|
|
1423
|
-
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 ||
|
|
1494
|
+
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 || Lt}. 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.`;
|
|
1424
1495
|
}
|
|
1425
|
-
async function
|
|
1496
|
+
async function zt(e, t) {
|
|
1426
1497
|
try {
|
|
1427
1498
|
await fetch(e, {
|
|
1428
1499
|
method: "GET",
|
|
@@ -1430,25 +1501,25 @@ async function At(e, t) {
|
|
|
1430
1501
|
signal: AbortSignal.timeout(8e3)
|
|
1431
1502
|
});
|
|
1432
1503
|
} catch {
|
|
1433
|
-
throw Error(
|
|
1504
|
+
throw Error(Rt(t));
|
|
1434
1505
|
}
|
|
1435
1506
|
}
|
|
1436
|
-
function
|
|
1507
|
+
function Bt(e, t, n, r) {
|
|
1437
1508
|
try {
|
|
1438
1509
|
r && r.length > 0 ? e.postMessage(t, n, r) : e.postMessage(t, n);
|
|
1439
1510
|
} catch (e) {
|
|
1440
|
-
throw e instanceof DOMException && e.name === "SecurityError" ? Error(
|
|
1511
|
+
throw e instanceof DOMException && e.name === "SecurityError" ? Error(Rt(n), { cause: e }) : e;
|
|
1441
1512
|
}
|
|
1442
1513
|
}
|
|
1443
|
-
var
|
|
1444
|
-
function
|
|
1445
|
-
return typeof e == "number" &&
|
|
1514
|
+
var Vt = new Set([1, 2]);
|
|
1515
|
+
function Ht(e) {
|
|
1516
|
+
return typeof e == "number" && Vt.has(e);
|
|
1446
1517
|
}
|
|
1447
|
-
var
|
|
1448
|
-
function
|
|
1518
|
+
var Ut = 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("."));
|
|
1519
|
+
function Wt(e) {
|
|
1449
1520
|
if (!e || typeof e != "object") return null;
|
|
1450
1521
|
let t = e;
|
|
1451
|
-
if (!
|
|
1522
|
+
if (!Ht(t.schemaVersion) || !t.type || !Ut.has(t.type)) return null;
|
|
1452
1523
|
if (t.type === "embedReady" || t.type === "widgetReady" || t.type === "widgetExpand" || t.type === "widgetCollapse") return t;
|
|
1453
1524
|
if (t.type === "fullWindow" || t.type === "theatre") {
|
|
1454
1525
|
let e = t.payload;
|
|
@@ -1471,10 +1542,13 @@ function Ft(e) {
|
|
|
1471
1542
|
let n = t.payload;
|
|
1472
1543
|
return !n || typeof n != "object" ? null : t;
|
|
1473
1544
|
}
|
|
1474
|
-
function
|
|
1545
|
+
function Gt(e, t) {
|
|
1546
|
+
return t === void 0 ? {} : { [e]: t };
|
|
1547
|
+
}
|
|
1548
|
+
function Kt(e, t, n) {
|
|
1475
1549
|
let r = e.trim();
|
|
1476
1550
|
if (!r) throw Error("createLaunchMessage requires a non-empty launch string.");
|
|
1477
|
-
let i = n?.startButton, a = n?.theme, o = n?.showFeedback, s = n?.interaction, c = n?.
|
|
1551
|
+
let i = n?.startButton, a = n?.theme, o = n?.showFeedback, s = n?.interaction, c = n?.theatre;
|
|
1478
1552
|
return {
|
|
1479
1553
|
type: "launch",
|
|
1480
1554
|
schemaVersion: 2,
|
|
@@ -1485,32 +1559,34 @@ function It(e, t, n) {
|
|
|
1485
1559
|
...a ? { theme: a } : {},
|
|
1486
1560
|
...o === void 0 ? {} : { showFeedback: o },
|
|
1487
1561
|
...s ? { interaction: s } : {},
|
|
1488
|
-
...
|
|
1489
|
-
...
|
|
1562
|
+
...Gt("settingsButton", n?.settingsButton),
|
|
1563
|
+
...Gt("theatreButton", n?.theatreButton),
|
|
1564
|
+
...Gt("fullscreenButton", n?.fullscreenButton),
|
|
1565
|
+
...c === void 0 ? {} : { theatre: c }
|
|
1490
1566
|
}
|
|
1491
1567
|
};
|
|
1492
1568
|
}
|
|
1493
|
-
function
|
|
1569
|
+
function qt() {
|
|
1494
1570
|
return {
|
|
1495
1571
|
type: "parentHello",
|
|
1496
1572
|
schemaVersion: 2
|
|
1497
1573
|
};
|
|
1498
1574
|
}
|
|
1499
|
-
function
|
|
1575
|
+
function Jt(e) {
|
|
1500
1576
|
return {
|
|
1501
1577
|
type: "widgetSetChrome",
|
|
1502
1578
|
schemaVersion: 2,
|
|
1503
1579
|
payload: { mode: e }
|
|
1504
1580
|
};
|
|
1505
1581
|
}
|
|
1506
|
-
function
|
|
1582
|
+
function Yt() {
|
|
1507
1583
|
return {
|
|
1508
1584
|
type: "widgetToggleAudioSettings",
|
|
1509
1585
|
schemaVersion: 2,
|
|
1510
1586
|
payload: {}
|
|
1511
1587
|
};
|
|
1512
1588
|
}
|
|
1513
|
-
function
|
|
1589
|
+
function Xt(e) {
|
|
1514
1590
|
return {
|
|
1515
1591
|
type: "setTheatre",
|
|
1516
1592
|
schemaVersion: 2,
|
|
@@ -1519,8 +1595,8 @@ function Bt(e) {
|
|
|
1519
1595
|
}
|
|
1520
1596
|
//#endregion
|
|
1521
1597
|
//#region src/v2/embed/fullWindowHost.ts
|
|
1522
|
-
var
|
|
1523
|
-
function
|
|
1598
|
+
var Zt = "2147483000";
|
|
1599
|
+
function Qt(e) {
|
|
1524
1600
|
let { style: t } = e;
|
|
1525
1601
|
return {
|
|
1526
1602
|
position: t.position,
|
|
@@ -1538,11 +1614,11 @@ function Ht(e) {
|
|
|
1538
1614
|
maxHeight: t.maxHeight
|
|
1539
1615
|
};
|
|
1540
1616
|
}
|
|
1541
|
-
function
|
|
1617
|
+
function $t(e) {
|
|
1542
1618
|
let { style: t } = e;
|
|
1543
|
-
t.position = "fixed", t.top = "0", t.right = "0", t.bottom = "0", t.left = "0", t.inset = "0", t.width = "100vw", t.width = "100dvw", t.height = "100vh", t.height = "100dvh", t.zIndex =
|
|
1619
|
+
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 = Zt, t.margin = "0", t.borderRadius = "0", t.maxWidth = "none", t.maxHeight = "none", e.dataset.liformaFullWindow = "1";
|
|
1544
1620
|
}
|
|
1545
|
-
function
|
|
1621
|
+
function en(e, t) {
|
|
1546
1622
|
if (delete e.dataset.liformaFullWindow, !t) {
|
|
1547
1623
|
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 = "";
|
|
1548
1624
|
return;
|
|
@@ -1552,20 +1628,20 @@ function Wt(e, t) {
|
|
|
1552
1628
|
}
|
|
1553
1629
|
//#endregion
|
|
1554
1630
|
//#region src/v2/embed/iframeHost.ts
|
|
1555
|
-
function
|
|
1631
|
+
function tn(e) {
|
|
1556
1632
|
return e;
|
|
1557
1633
|
}
|
|
1558
1634
|
function Z() {
|
|
1559
1635
|
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)}`;
|
|
1560
1636
|
}
|
|
1561
|
-
var
|
|
1562
|
-
function
|
|
1637
|
+
var nn = 3e4;
|
|
1638
|
+
function rn(e) {
|
|
1563
1639
|
let t = e.container;
|
|
1564
1640
|
getComputedStyle(t).position === "static" && (t.style.position = "relative");
|
|
1565
1641
|
let n = document.createElement("iframe");
|
|
1566
|
-
n.src = e.src, n.title = "Liforma experience", n.setAttribute("allow", "microphone; autoplay; clipboard-read; clipboard-write; fullscreen"), n.setAttribute("allowfullscreen", ""), n.style.cssText = e.transparent ? "display:block;position:absolute;inset:0;width:100%;height:100%;border:0;background:transparent;" : "display:block;position:absolute;inset:0;width:100%;height:100%;border:0;background:#030508;", e.transparent && n.setAttribute("allowtransparency", "true");
|
|
1642
|
+
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");
|
|
1567
1643
|
let r = !1, i = !1, a = null, o = null, s = (r) => {
|
|
1568
|
-
i !== r && (i = r, r ? (a =
|
|
1644
|
+
i !== r && (i = r, r ? (a = Qt(n), o = document.body.style.overflow, document.body.append(n), $t(n), document.body.style.overflow = "hidden") : (t.append(n), en(n, a), a = null, o !== null && (document.body.style.overflow = o, o = null)), e.onFullWindowChange?.(r));
|
|
1569
1645
|
}, c = /* @__PURE__ */ new Map(), l = null, u = 0, d = 0, f = [], p = null, m = null, h = new Promise((e, t) => {
|
|
1570
1646
|
p = e, m = t;
|
|
1571
1647
|
}), g = () => {
|
|
@@ -1576,10 +1652,10 @@ function qt(e) {
|
|
|
1576
1652
|
let i = Date.now();
|
|
1577
1653
|
if (d > 0 && i - d < 250) return;
|
|
1578
1654
|
d = i, g();
|
|
1579
|
-
let a =
|
|
1655
|
+
let a = Kt(t.launch, t.session, t.chrome), o = () => {
|
|
1580
1656
|
if (r) return;
|
|
1581
1657
|
let t = n.contentWindow;
|
|
1582
|
-
t &&
|
|
1658
|
+
t && Bt(t, a, e.playerOrigin);
|
|
1583
1659
|
};
|
|
1584
1660
|
o();
|
|
1585
1661
|
for (let e = 1; e <= 12; e += 1) f.push(window.setTimeout(o, e * 75));
|
|
@@ -1587,17 +1663,17 @@ function qt(e) {
|
|
|
1587
1663
|
r || !l || _(l);
|
|
1588
1664
|
}, y = () => {
|
|
1589
1665
|
if (u += 1, u === 1) {
|
|
1590
|
-
|
|
1666
|
+
zt(e.src, e.playerOrigin).then(() => p?.(), (e) => m?.(e instanceof Error ? e : Error(String(e))));
|
|
1591
1667
|
return;
|
|
1592
1668
|
}
|
|
1593
1669
|
d = 0, v();
|
|
1594
1670
|
}, b = () => {
|
|
1595
|
-
u > 0 || m?.(Error(
|
|
1671
|
+
u > 0 || m?.(Error(Rt(e.playerOrigin)));
|
|
1596
1672
|
};
|
|
1597
1673
|
n.addEventListener("load", y), n.addEventListener("error", b);
|
|
1598
1674
|
let x = (t) => {
|
|
1599
1675
|
if (r || t.source !== n.contentWindow || t.origin !== e.playerOrigin) return;
|
|
1600
|
-
let i =
|
|
1676
|
+
let i = Wt(t.data);
|
|
1601
1677
|
if (i) switch (i.type) {
|
|
1602
1678
|
case "close":
|
|
1603
1679
|
e.onClose?.(i.payload);
|
|
@@ -1636,7 +1712,7 @@ function qt(e) {
|
|
|
1636
1712
|
e.onUserSpeechEnded?.(i.payload);
|
|
1637
1713
|
break;
|
|
1638
1714
|
case "modeChange":
|
|
1639
|
-
e.onActivityChange?.(
|
|
1715
|
+
e.onActivityChange?.(tn(i.payload.mode));
|
|
1640
1716
|
break;
|
|
1641
1717
|
case "activityChange":
|
|
1642
1718
|
e.onActivityChange?.(i.payload.activity);
|
|
@@ -1695,8 +1771,8 @@ function qt(e) {
|
|
|
1695
1771
|
let S = (t, i) => {
|
|
1696
1772
|
if (r) return;
|
|
1697
1773
|
let a = n.contentWindow;
|
|
1698
|
-
if (!a) throw Error(
|
|
1699
|
-
|
|
1774
|
+
if (!a) throw Error(Rt(e.playerOrigin));
|
|
1775
|
+
Bt(a, t, e.playerOrigin, i);
|
|
1700
1776
|
}, C = (e, t = 12e4, n) => {
|
|
1701
1777
|
let r = e.type !== "parentHello" && e.payload && "correlationId" in e.payload ? e.payload.correlationId : Z();
|
|
1702
1778
|
return e.type !== "parentHello" && e.payload && "correlationId" in e.payload || e.type !== "parentHello" && e.payload && (e.payload.correlationId = r), new Promise((i, a) => {
|
|
@@ -1713,7 +1789,7 @@ function qt(e) {
|
|
|
1713
1789
|
return h;
|
|
1714
1790
|
},
|
|
1715
1791
|
postParentHello() {
|
|
1716
|
-
S(
|
|
1792
|
+
S(qt());
|
|
1717
1793
|
},
|
|
1718
1794
|
postLaunch(e, t, n) {
|
|
1719
1795
|
r || (l = {
|
|
@@ -1735,13 +1811,13 @@ function qt(e) {
|
|
|
1735
1811
|
throw Error("postManifest is deprecated; use postLaunch with an opaque launch string from SessionLaunchResponse.");
|
|
1736
1812
|
},
|
|
1737
1813
|
postWidgetSetChrome(e) {
|
|
1738
|
-
S(
|
|
1814
|
+
S(Jt(e));
|
|
1739
1815
|
},
|
|
1740
1816
|
postWidgetToggleAudioSettings() {
|
|
1741
|
-
S(
|
|
1817
|
+
S(Yt());
|
|
1742
1818
|
},
|
|
1743
1819
|
postSetTheatre(e) {
|
|
1744
|
-
S(
|
|
1820
|
+
S(Xt(e));
|
|
1745
1821
|
},
|
|
1746
1822
|
speak(e) {
|
|
1747
1823
|
return C({
|
|
@@ -1863,7 +1939,7 @@ function qt(e) {
|
|
|
1863
1939
|
audio: e.audio,
|
|
1864
1940
|
byteLength: e.byteLength
|
|
1865
1941
|
}
|
|
1866
|
-
},
|
|
1942
|
+
}, nn, [e.audio]);
|
|
1867
1943
|
},
|
|
1868
1944
|
speechUtteranceSetTranscript(e) {
|
|
1869
1945
|
return C({
|
|
@@ -2025,7 +2101,7 @@ function qt(e) {
|
|
|
2025
2101
|
}
|
|
2026
2102
|
//#endregion
|
|
2027
2103
|
//#region src/v2/embed/readyGate.ts
|
|
2028
|
-
function
|
|
2104
|
+
function an(e) {
|
|
2029
2105
|
let t, n = !1, r = !1, i = () => {
|
|
2030
2106
|
r || !n || t === void 0 || (r = !0, e(t));
|
|
2031
2107
|
};
|
|
@@ -2040,9 +2116,9 @@ function Jt(e) {
|
|
|
2040
2116
|
}
|
|
2041
2117
|
//#endregion
|
|
2042
2118
|
//#region src/v2/sdkRelease.ts
|
|
2043
|
-
var
|
|
2119
|
+
var on = `sdk@${{
|
|
2044
2120
|
name: "@liforma/client",
|
|
2045
|
-
version: "0.4.
|
|
2121
|
+
version: "0.4.15",
|
|
2046
2122
|
type: "module",
|
|
2047
2123
|
description: "Liforma browser SDK — Experience sessions, speech API, and Svelte embed component.",
|
|
2048
2124
|
license: "MIT",
|
|
@@ -2203,6 +2279,8 @@ var Yt = `sdk@${{
|
|
|
2203
2279
|
"generate:location-discontinuities": "node scripts/generate-location-discontinuities.mjs",
|
|
2204
2280
|
"build:locations": "node scripts/build-locations.mjs",
|
|
2205
2281
|
"publish:locations": "node scripts/publish-locations.mjs",
|
|
2282
|
+
"publish:location-400x225": "node scripts/build-location-400x225.mjs",
|
|
2283
|
+
"test:location-400x225": "node scripts/test-location-400x225.mjs",
|
|
2206
2284
|
"verify:locations": "node scripts/verify-location-sources.mjs",
|
|
2207
2285
|
"publish:models": "node scripts/publish-models.mjs",
|
|
2208
2286
|
"publish:models:krea-int8": "node scripts/_upload-model-prefix.mjs text-to-image/lf-t2i-turbo-int8",
|
|
@@ -2232,6 +2310,7 @@ var Yt = `sdk@${{
|
|
|
2232
2310
|
"preview:test": "npm run build && npm run preview"
|
|
2233
2311
|
},
|
|
2234
2312
|
dependencies: {
|
|
2313
|
+
"@jsquash/avif": "^1.3.0",
|
|
2235
2314
|
"@jsquash/webp": "^1.5.0",
|
|
2236
2315
|
zod: "^4.4.3"
|
|
2237
2316
|
},
|
|
@@ -2261,50 +2340,54 @@ var Yt = `sdk@${{
|
|
|
2261
2340
|
vitest: "^4.1.10",
|
|
2262
2341
|
wrangler: "^4.101.0"
|
|
2263
2342
|
}
|
|
2264
|
-
}.version}`,
|
|
2265
|
-
function
|
|
2343
|
+
}.version}`, sn = "https://player.liforma.ai/embed", cn = "http://localhost:3002/embed";
|
|
2344
|
+
function ln() {
|
|
2266
2345
|
let e = globalThis.__LIFORMA_PLAYER_EMBED_URL;
|
|
2267
2346
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
2268
2347
|
if (typeof document > "u") return null;
|
|
2269
2348
|
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();
|
|
2270
2349
|
return t ? t.replace(/\/$/, "") : null;
|
|
2271
2350
|
}
|
|
2272
|
-
function
|
|
2273
|
-
let e =
|
|
2274
|
-
return e ? e.endsWith("/embed") ? e : `${e}/embed` :
|
|
2351
|
+
function un() {
|
|
2352
|
+
let e = ln();
|
|
2353
|
+
return e ? e.endsWith("/embed") ? e : `${e}/embed` : me() ? cn : sn;
|
|
2275
2354
|
}
|
|
2276
|
-
function
|
|
2355
|
+
function dn(e, t) {
|
|
2277
2356
|
return e?.trim() || t?.trim() || void 0;
|
|
2278
2357
|
}
|
|
2279
|
-
function
|
|
2280
|
-
let
|
|
2281
|
-
|
|
2282
|
-
let
|
|
2283
|
-
|
|
2358
|
+
function fn(e, t, n, r, i, a, o, s, c, l, u, d, f) {
|
|
2359
|
+
let p = (e ?? un()).replace(/\/$/, ""), m = p.endsWith("/embed") ? p : `${p}/embed`, h = new URL(m), g = n?.trim();
|
|
2360
|
+
g && h.searchParams.set("backdropId", g);
|
|
2361
|
+
let _ = r?.trim();
|
|
2362
|
+
_ && h.searchParams.set("avatarId", _);
|
|
2363
|
+
let v = d?.trim();
|
|
2364
|
+
v && h.searchParams.set("previewBg", v);
|
|
2365
|
+
let y = f?.trim();
|
|
2366
|
+
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)), pn(h.toString());
|
|
2284
2367
|
}
|
|
2285
|
-
function
|
|
2368
|
+
function pn(e) {
|
|
2286
2369
|
if (typeof location > "u") return e;
|
|
2287
2370
|
let t = new URL(e);
|
|
2288
2371
|
return t.searchParams.set("parentOrigin", location.origin), t.toString();
|
|
2289
2372
|
}
|
|
2290
|
-
function
|
|
2373
|
+
function mn(e) {
|
|
2291
2374
|
return new URL(e).origin;
|
|
2292
2375
|
}
|
|
2293
2376
|
//#endregion
|
|
2294
2377
|
//#region src/v2/experienceEvents.ts
|
|
2295
|
-
function
|
|
2378
|
+
function hn() {
|
|
2296
2379
|
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)}`;
|
|
2297
2380
|
}
|
|
2298
|
-
function
|
|
2381
|
+
function gn(e, t, n) {
|
|
2299
2382
|
return {
|
|
2300
|
-
id:
|
|
2383
|
+
id: hn(),
|
|
2301
2384
|
type: e,
|
|
2302
2385
|
sessionId: t,
|
|
2303
2386
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2304
2387
|
data: n
|
|
2305
2388
|
};
|
|
2306
2389
|
}
|
|
2307
|
-
function
|
|
2390
|
+
function _n() {
|
|
2308
2391
|
return {
|
|
2309
2392
|
ready: /* @__PURE__ */ new Set(),
|
|
2310
2393
|
started: /* @__PURE__ */ new Set(),
|
|
@@ -2325,39 +2408,39 @@ function sn() {
|
|
|
2325
2408
|
conversationProcessorError: /* @__PURE__ */ new Set()
|
|
2326
2409
|
};
|
|
2327
2410
|
}
|
|
2328
|
-
function
|
|
2411
|
+
function vn(e, t, n) {
|
|
2329
2412
|
return e[t].add(n), () => e[t].delete(n);
|
|
2330
2413
|
}
|
|
2331
|
-
function
|
|
2414
|
+
function yn(e, t, n) {
|
|
2332
2415
|
for (let r of e[t]) r(n);
|
|
2333
2416
|
}
|
|
2334
|
-
function
|
|
2417
|
+
function bn(e) {
|
|
2335
2418
|
for (let t of Object.keys(e)) e[t].clear();
|
|
2336
2419
|
}
|
|
2337
2420
|
//#endregion
|
|
2338
2421
|
//#region src/v2/speech/types.ts
|
|
2339
|
-
function
|
|
2422
|
+
function xn(e) {
|
|
2340
2423
|
return "data" in e && "format" in e && e.format != null && !("track" in e);
|
|
2341
2424
|
}
|
|
2342
|
-
function
|
|
2425
|
+
function Sn(e) {
|
|
2343
2426
|
return "url" in e && typeof e.url == "string";
|
|
2344
2427
|
}
|
|
2345
|
-
function
|
|
2428
|
+
function Cn(e) {
|
|
2346
2429
|
if (!("track" in e)) return !1;
|
|
2347
2430
|
let t = e.track;
|
|
2348
2431
|
return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
|
|
2349
2432
|
}
|
|
2350
|
-
function
|
|
2351
|
-
return !
|
|
2433
|
+
function wn(e) {
|
|
2434
|
+
return !xn(e) && !Sn(e) && !Cn(e) && "encoding" in e && typeof e.encoding == "string";
|
|
2352
2435
|
}
|
|
2353
|
-
var
|
|
2436
|
+
var Tn = [
|
|
2354
2437
|
8e3,
|
|
2355
2438
|
16e3,
|
|
2356
2439
|
22050,
|
|
2357
2440
|
24e3,
|
|
2358
2441
|
44100,
|
|
2359
2442
|
48e3
|
|
2360
|
-
],
|
|
2443
|
+
], En = {
|
|
2361
2444
|
MAX_CHUNK_BYTES: 64 * 1024,
|
|
2362
2445
|
RECOMMENDED_CHUNK_MS_MIN: 20,
|
|
2363
2446
|
RECOMMENDED_CHUNK_MS_MAX: 200,
|
|
@@ -2368,14 +2451,14 @@ var hn = [
|
|
|
2368
2451
|
MAX_UTTERANCE_DURATION_MS: 9e4,
|
|
2369
2452
|
MAX_PENDING_WRITES: 8,
|
|
2370
2453
|
DEFAULT_WRITE_TIMEOUT_MS: 5e3
|
|
2371
|
-
},
|
|
2454
|
+
}, Dn = class extends Error {
|
|
2372
2455
|
operation;
|
|
2373
2456
|
requiredCapability;
|
|
2374
2457
|
name = "UnsupportedSpeechOperationError";
|
|
2375
2458
|
constructor(e, t) {
|
|
2376
2459
|
super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
|
|
2377
2460
|
}
|
|
2378
|
-
},
|
|
2461
|
+
}, On = class extends Error {
|
|
2379
2462
|
name = "SpeechUtteranceClosedError";
|
|
2380
2463
|
constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
|
|
2381
2464
|
super(e);
|
|
@@ -2385,72 +2468,72 @@ var hn = [
|
|
|
2385
2468
|
constructor(e, t) {
|
|
2386
2469
|
super(e, t);
|
|
2387
2470
|
}
|
|
2388
|
-
},
|
|
2471
|
+
}, kn = class extends Error {
|
|
2389
2472
|
name = "SpeechBufferTimeoutError";
|
|
2390
2473
|
constructor(e = "Timed out waiting for speech buffer capacity.") {
|
|
2391
2474
|
super(e);
|
|
2392
2475
|
}
|
|
2393
2476
|
};
|
|
2394
|
-
function
|
|
2477
|
+
function An(e = "none") {
|
|
2395
2478
|
return {
|
|
2396
2479
|
mode: e,
|
|
2397
2480
|
trackedDurationMs: 0,
|
|
2398
2481
|
fallbackDurationMs: 0
|
|
2399
2482
|
};
|
|
2400
2483
|
}
|
|
2401
|
-
function
|
|
2402
|
-
return
|
|
2484
|
+
function jn(e) {
|
|
2485
|
+
return Tn.includes(e);
|
|
2403
2486
|
}
|
|
2404
|
-
function
|
|
2487
|
+
function Mn(e) {
|
|
2405
2488
|
if (e.encoding !== "pcm_s16le") throw new Q(`Unsupported audio encoding: ${e.encoding}`);
|
|
2406
2489
|
if (e.channels !== 1) throw new Q(`Unsupported channel count: ${e.channels}`);
|
|
2407
|
-
if (!
|
|
2490
|
+
if (!jn(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
2408
2491
|
}
|
|
2409
|
-
function
|
|
2410
|
-
if (
|
|
2411
|
-
|
|
2492
|
+
function Nn(e) {
|
|
2493
|
+
if (xn(e)) {
|
|
2494
|
+
Mn(e.format);
|
|
2412
2495
|
return;
|
|
2413
2496
|
}
|
|
2414
|
-
if (
|
|
2497
|
+
if (Sn(e)) {
|
|
2415
2498
|
if (!e.url.trim()) throw new Q("Audio URL must be non-empty.");
|
|
2416
|
-
if (e.sampleRate !== void 0 && !
|
|
2499
|
+
if (e.sampleRate !== void 0 && !jn(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
2417
2500
|
return;
|
|
2418
2501
|
}
|
|
2419
|
-
if (
|
|
2502
|
+
if (Cn(e)) {
|
|
2420
2503
|
if (e.track.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
2421
|
-
if (e.sampleRate !== void 0 && !
|
|
2504
|
+
if (e.sampleRate !== void 0 && !jn(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
2422
2505
|
return;
|
|
2423
2506
|
}
|
|
2424
|
-
if (
|
|
2507
|
+
if (wn(e)) {
|
|
2425
2508
|
let t = e.encoding.trim().toLowerCase();
|
|
2426
2509
|
if (!t) throw new Q("Encoded audio MIME type is required.");
|
|
2427
2510
|
if (t === "pcm_s16le") throw new Q("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
|
|
2428
|
-
if (e.sampleRate !== void 0 && !
|
|
2511
|
+
if (e.sampleRate !== void 0 && !jn(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
2429
2512
|
return;
|
|
2430
2513
|
}
|
|
2431
2514
|
throw new Q("Unsupported speech.play audio shape.");
|
|
2432
2515
|
}
|
|
2433
|
-
function
|
|
2434
|
-
if (e.format) return
|
|
2516
|
+
function Pn(e) {
|
|
2517
|
+
if (e.format) return Mn(e.format), e.format;
|
|
2435
2518
|
if (e.track) {
|
|
2436
2519
|
let t = {
|
|
2437
2520
|
encoding: "pcm_s16le",
|
|
2438
2521
|
sampleRate: e.sampleRate ?? 24e3,
|
|
2439
2522
|
channels: 1
|
|
2440
2523
|
};
|
|
2441
|
-
return
|
|
2524
|
+
return Mn(t), t;
|
|
2442
2525
|
}
|
|
2443
2526
|
throw new Q("createUtterance requires format or track.");
|
|
2444
2527
|
}
|
|
2445
|
-
function
|
|
2528
|
+
function Fn(e) {
|
|
2446
2529
|
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
2447
2530
|
}
|
|
2448
|
-
function
|
|
2531
|
+
function In(e) {
|
|
2449
2532
|
return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
|
|
2450
2533
|
}
|
|
2451
2534
|
//#endregion
|
|
2452
2535
|
//#region src/byo/pcm.ts
|
|
2453
|
-
function
|
|
2536
|
+
function Ln(e) {
|
|
2454
2537
|
let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
|
|
2455
2538
|
for (let t = 0; t < e.length; t++) {
|
|
2456
2539
|
let r = Math.max(-1, Math.min(1, e[t]));
|
|
@@ -2460,11 +2543,11 @@ function Dn(e) {
|
|
|
2460
2543
|
}
|
|
2461
2544
|
//#endregion
|
|
2462
2545
|
//#region src/byo/resample.ts
|
|
2463
|
-
function
|
|
2546
|
+
function Rn(e, t, n, r, i) {
|
|
2464
2547
|
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;
|
|
2465
2548
|
return ((a * i + o) * i + s) * i + c;
|
|
2466
2549
|
}
|
|
2467
|
-
function
|
|
2550
|
+
function zn(e, t) {
|
|
2468
2551
|
if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
|
|
2469
2552
|
if (e === t) return {
|
|
2470
2553
|
fromRate: e,
|
|
@@ -2487,7 +2570,7 @@ function kn(e, t) {
|
|
|
2487
2570
|
let a = [];
|
|
2488
2571
|
for (; i + 2 < r.length - 1;) {
|
|
2489
2572
|
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);
|
|
2490
|
-
a.push(
|
|
2573
|
+
a.push(Rn(r[o], r[e], r[s], r[c], t)), i += n;
|
|
2491
2574
|
}
|
|
2492
2575
|
let o = Math.max(0, Math.floor(i) - 1);
|
|
2493
2576
|
return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
|
|
@@ -2499,7 +2582,7 @@ function kn(e, t) {
|
|
|
2499
2582
|
}
|
|
2500
2583
|
//#endregion
|
|
2501
2584
|
//#region src/byo/audioCapture.ts
|
|
2502
|
-
var
|
|
2585
|
+
var Bn = "liforma-pcm-capture", Vn = `
|
|
2503
2586
|
class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
2504
2587
|
process(inputs) {
|
|
2505
2588
|
const ch = inputs[0] && inputs[0][0];
|
|
@@ -2511,29 +2594,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
|
2511
2594
|
return true;
|
|
2512
2595
|
}
|
|
2513
2596
|
}
|
|
2514
|
-
registerProcessor('${
|
|
2515
|
-
`,
|
|
2516
|
-
function
|
|
2517
|
-
return
|
|
2597
|
+
registerProcessor('${Bn}', LiformaPcmCaptureProcessor);
|
|
2598
|
+
`, Hn = null;
|
|
2599
|
+
function Un() {
|
|
2600
|
+
return Hn ||= URL.createObjectURL(new Blob([Vn], { type: "application/javascript" })), Hn;
|
|
2518
2601
|
}
|
|
2519
|
-
function
|
|
2602
|
+
function Wn() {
|
|
2520
2603
|
return window.AudioContext || window.webkitAudioContext || null;
|
|
2521
2604
|
}
|
|
2522
|
-
async function
|
|
2523
|
-
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o =
|
|
2605
|
+
async function Gn(e) {
|
|
2606
|
+
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = Wn();
|
|
2524
2607
|
if (!o) throw Error("Web Audio is required for audio capture");
|
|
2525
2608
|
let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
|
|
2526
2609
|
l.gain.value = 0;
|
|
2527
|
-
let u = s.sampleRate, d =
|
|
2610
|
+
let u = s.sampleRate, d = zn(u, n), f = !1, p = !1, m = (e) => {
|
|
2528
2611
|
if (f || i && !i()) return;
|
|
2529
2612
|
let t = d.push(e);
|
|
2530
|
-
t.length !== 0 && r(
|
|
2613
|
+
t.length !== 0 && r(Ln(t));
|
|
2531
2614
|
}, h = () => void 0;
|
|
2532
2615
|
return await (async () => {
|
|
2533
2616
|
if (typeof s.audioWorklet?.addModule != "function") return !1;
|
|
2534
2617
|
try {
|
|
2535
|
-
await s.audioWorklet.addModule(
|
|
2536
|
-
let e = new AudioWorkletNode(s,
|
|
2618
|
+
await s.audioWorklet.addModule(Un());
|
|
2619
|
+
let e = new AudioWorkletNode(s, Bn, {
|
|
2537
2620
|
numberOfInputs: 1,
|
|
2538
2621
|
numberOfOutputs: 1,
|
|
2539
2622
|
outputChannelCount: [1]
|
|
@@ -2583,7 +2666,7 @@ async function Fn(e) {
|
|
|
2583
2666
|
}
|
|
2584
2667
|
//#endregion
|
|
2585
2668
|
//#region src/v2/speech/captureMediaStreamTrack.ts
|
|
2586
|
-
async function
|
|
2669
|
+
async function Kn(e) {
|
|
2587
2670
|
let { track: t, utterance: n, sampleRate: r, signal: i } = e;
|
|
2588
2671
|
if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Q("MediaStreamTrack is not available in this environment.");
|
|
2589
2672
|
if (t.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
@@ -2592,18 +2675,18 @@ async function In(e) {
|
|
|
2592
2675
|
s || (s = !0, c?.stop(), c = null);
|
|
2593
2676
|
};
|
|
2594
2677
|
try {
|
|
2595
|
-
c = await
|
|
2678
|
+
c = await Gn({
|
|
2596
2679
|
mediaStream: a,
|
|
2597
2680
|
targetSampleRate: r,
|
|
2598
2681
|
shouldSend: () => !s && !i?.aborted,
|
|
2599
2682
|
onPcm: (e) => {
|
|
2600
2683
|
if (s || i?.aborted) return;
|
|
2601
|
-
let t =
|
|
2684
|
+
let t = Fn(e);
|
|
2602
2685
|
o = o.then(async () => {
|
|
2603
2686
|
if (s || i?.aborted) return;
|
|
2604
2687
|
let e = 0;
|
|
2605
2688
|
for (; e < t.byteLength;) {
|
|
2606
|
-
let r = Math.min(e +
|
|
2689
|
+
let r = Math.min(e + En.MAX_CHUNK_BYTES, t.byteLength);
|
|
2607
2690
|
if ((r - e) % 2 == 1 && --r, r <= e) break;
|
|
2608
2691
|
let i = t.subarray(e, r);
|
|
2609
2692
|
e = r, i.byteLength !== 0 && await n.write(i);
|
|
@@ -2627,10 +2710,10 @@ async function In(e) {
|
|
|
2627
2710
|
}
|
|
2628
2711
|
//#endregion
|
|
2629
2712
|
//#region src/v2/speech/speechController.ts
|
|
2630
|
-
async function
|
|
2631
|
-
if (
|
|
2632
|
-
if (
|
|
2633
|
-
let t =
|
|
2713
|
+
async function qn(e, t) {
|
|
2714
|
+
if (Cn(e)) throw new Q("MediaStreamTrack play is handled on the host before embed.");
|
|
2715
|
+
if (xn(e)) {
|
|
2716
|
+
let t = Fn(e.data);
|
|
2634
2717
|
if (t.byteLength & 1) throw new Q("PCM byte length must be even.");
|
|
2635
2718
|
return {
|
|
2636
2719
|
kind: "pcm",
|
|
@@ -2638,17 +2721,17 @@ async function Ln(e, t) {
|
|
|
2638
2721
|
format: e.format
|
|
2639
2722
|
};
|
|
2640
2723
|
}
|
|
2641
|
-
if (
|
|
2724
|
+
if (Sn(e)) return {
|
|
2642
2725
|
kind: "url",
|
|
2643
2726
|
url: e.url.trim(),
|
|
2644
2727
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
2645
2728
|
};
|
|
2646
|
-
if (!
|
|
2729
|
+
if (!wn(e)) throw new Q("Unsupported speech.play audio shape.");
|
|
2647
2730
|
let n;
|
|
2648
2731
|
if (typeof Blob < "u" && e.data instanceof Blob) {
|
|
2649
2732
|
if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2650
2733
|
n = new Uint8Array(await e.data.arrayBuffer());
|
|
2651
|
-
} else n =
|
|
2734
|
+
} else n = Fn(e.data);
|
|
2652
2735
|
return {
|
|
2653
2736
|
kind: "encoded",
|
|
2654
2737
|
data: n.slice().buffer,
|
|
@@ -2656,10 +2739,10 @@ async function Ln(e, t) {
|
|
|
2656
2739
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
2657
2740
|
};
|
|
2658
2741
|
}
|
|
2659
|
-
function
|
|
2742
|
+
function Jn() {
|
|
2660
2743
|
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)}`;
|
|
2661
2744
|
}
|
|
2662
|
-
function
|
|
2745
|
+
function Yn(e, t = "completed") {
|
|
2663
2746
|
return {
|
|
2664
2747
|
utteranceId: e.speechId,
|
|
2665
2748
|
characterId: e.characterId,
|
|
@@ -2673,13 +2756,13 @@ function zn(e, t = "completed") {
|
|
|
2673
2756
|
}
|
|
2674
2757
|
};
|
|
2675
2758
|
}
|
|
2676
|
-
function
|
|
2759
|
+
function Xn(e) {
|
|
2677
2760
|
return e instanceof Error ? e : new Q(String(e));
|
|
2678
2761
|
}
|
|
2679
|
-
function
|
|
2762
|
+
function Zn(e) {
|
|
2680
2763
|
return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
|
|
2681
2764
|
}
|
|
2682
|
-
var
|
|
2765
|
+
var Qn = class {
|
|
2683
2766
|
id;
|
|
2684
2767
|
characterId;
|
|
2685
2768
|
result;
|
|
@@ -2708,29 +2791,29 @@ var Hn = class {
|
|
|
2708
2791
|
queue: e.queue,
|
|
2709
2792
|
...e.transcript === void 0 ? {} : { transcript: e.transcript }
|
|
2710
2793
|
}).catch((e) => {
|
|
2711
|
-
throw this.fail(
|
|
2794
|
+
throw this.fail(Xn(e)), Xn(e);
|
|
2712
2795
|
}), this.signal?.addEventListener("abort", () => {
|
|
2713
2796
|
this.cancel();
|
|
2714
2797
|
}, { once: !0 });
|
|
2715
2798
|
}
|
|
2716
2799
|
async write(e, t) {
|
|
2717
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2718
|
-
let n =
|
|
2800
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new On();
|
|
2801
|
+
let n = Fn(e);
|
|
2719
2802
|
if (n.byteLength & 1) throw new Q("PCM chunk byte length must be even (complete s16 samples).");
|
|
2720
|
-
if (n.byteLength >
|
|
2803
|
+
if (n.byteLength > En.MAX_CHUNK_BYTES) throw new Q(`PCM chunk exceeds MAX_CHUNK_BYTES (${En.MAX_CHUNK_BYTES}).`);
|
|
2721
2804
|
if (n.byteLength === 0) return;
|
|
2722
|
-
let r = t?.timeoutMs ??
|
|
2805
|
+
let r = t?.timeoutMs ?? En.DEFAULT_WRITE_TIMEOUT_MS;
|
|
2723
2806
|
await this.acquireWriteSlot(r);
|
|
2724
2807
|
let i = n.byteLength / 2 / this.sampleRate * 1e3;
|
|
2725
|
-
if (this.bufferedMs + i >
|
|
2808
|
+
if (this.bufferedMs + i > En.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new Q("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
|
|
2726
2809
|
let a = async () => {
|
|
2727
|
-
if (this.closed || this.settled) throw new
|
|
2810
|
+
if (this.closed || this.settled) throw new On();
|
|
2728
2811
|
let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
|
|
2729
2812
|
utteranceId: this.id,
|
|
2730
2813
|
audio: t.buffer,
|
|
2731
2814
|
byteLength: t.byteLength
|
|
2732
2815
|
}), a = await Promise.race([i, new Promise((e, t) => {
|
|
2733
|
-
setTimeout(() => t(new
|
|
2816
|
+
setTimeout(() => t(new kn()), r);
|
|
2734
2817
|
})]);
|
|
2735
2818
|
this.bufferedMs = Math.max(0, a.bufferedMs);
|
|
2736
2819
|
}, o = this.writeChain.then(a, a);
|
|
@@ -2742,7 +2825,7 @@ var Hn = class {
|
|
|
2742
2825
|
}
|
|
2743
2826
|
}
|
|
2744
2827
|
async setTranscript(e) {
|
|
2745
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2828
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new On();
|
|
2746
2829
|
await this.requireHost().speechUtteranceSetTranscript({
|
|
2747
2830
|
utteranceId: this.id,
|
|
2748
2831
|
transcript: e
|
|
@@ -2759,7 +2842,7 @@ var Hn = class {
|
|
|
2759
2842
|
});
|
|
2760
2843
|
return this.resolve(t), t;
|
|
2761
2844
|
} catch (e) {
|
|
2762
|
-
let t =
|
|
2845
|
+
let t = Xn(e);
|
|
2763
2846
|
throw this.fail(t), t;
|
|
2764
2847
|
}
|
|
2765
2848
|
}
|
|
@@ -2777,11 +2860,11 @@ var Hn = class {
|
|
|
2777
2860
|
characterId: this.characterId,
|
|
2778
2861
|
status: "cancelled",
|
|
2779
2862
|
durationMs: 0,
|
|
2780
|
-
animation:
|
|
2863
|
+
animation: An("none")
|
|
2781
2864
|
};
|
|
2782
2865
|
return this.resolve(t), t;
|
|
2783
2866
|
} catch (e) {
|
|
2784
|
-
let t =
|
|
2867
|
+
let t = Xn(e);
|
|
2785
2868
|
throw this.fail(t), t;
|
|
2786
2869
|
}
|
|
2787
2870
|
}
|
|
@@ -2794,19 +2877,19 @@ var Hn = class {
|
|
|
2794
2877
|
return e;
|
|
2795
2878
|
}
|
|
2796
2879
|
resolve(e) {
|
|
2797
|
-
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new
|
|
2880
|
+
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new On()));
|
|
2798
2881
|
}
|
|
2799
2882
|
fail(e) {
|
|
2800
2883
|
this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
|
|
2801
2884
|
}
|
|
2802
2885
|
async acquireWriteSlot(e) {
|
|
2803
|
-
if (this.pendingWriteCount <
|
|
2886
|
+
if (this.pendingWriteCount < En.MAX_PENDING_WRITES) {
|
|
2804
2887
|
this.pendingWriteCount += 1;
|
|
2805
2888
|
return;
|
|
2806
2889
|
}
|
|
2807
2890
|
await new Promise((t, n) => {
|
|
2808
2891
|
let r = setTimeout(() => {
|
|
2809
|
-
n(new
|
|
2892
|
+
n(new kn());
|
|
2810
2893
|
}, e);
|
|
2811
2894
|
this.pendingWriteWaiters.push({
|
|
2812
2895
|
resolve: () => {
|
|
@@ -2825,13 +2908,13 @@ var Hn = class {
|
|
|
2825
2908
|
for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
|
|
2826
2909
|
}
|
|
2827
2910
|
};
|
|
2828
|
-
function
|
|
2911
|
+
function $n(e) {
|
|
2829
2912
|
let t = null, n = (t, n) => {
|
|
2830
|
-
if (!e.getCapabilities()[n]) throw new
|
|
2913
|
+
if (!e.getCapabilities()[n]) throw new Dn(t, n);
|
|
2831
2914
|
}, r = {
|
|
2832
2915
|
async speak(r) {
|
|
2833
2916
|
if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
|
|
2834
|
-
let i =
|
|
2917
|
+
let i = In(r.queue ?? "append");
|
|
2835
2918
|
i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
|
|
2836
2919
|
let a = e.getIframeHost();
|
|
2837
2920
|
if (!a) throw new Q("Speech session is not attached.");
|
|
@@ -2851,41 +2934,41 @@ function Un(e) {
|
|
|
2851
2934
|
return;
|
|
2852
2935
|
}
|
|
2853
2936
|
t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
|
|
2854
|
-
t.removeEventListener("abort", s), n(
|
|
2937
|
+
t.removeEventListener("abort", s), n(Yn(e, "completed"));
|
|
2855
2938
|
}, (a) => {
|
|
2856
|
-
if (t.removeEventListener("abort", s),
|
|
2939
|
+
if (t.removeEventListener("abort", s), Zn(a)) {
|
|
2857
2940
|
n({
|
|
2858
2941
|
utteranceId: "utt_interrupted",
|
|
2859
2942
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2860
2943
|
status: "interrupted",
|
|
2861
2944
|
durationMs: 0,
|
|
2862
2945
|
transcript: r.text,
|
|
2863
|
-
animation:
|
|
2946
|
+
animation: An("none")
|
|
2864
2947
|
});
|
|
2865
2948
|
return;
|
|
2866
2949
|
}
|
|
2867
|
-
i(
|
|
2950
|
+
i(Xn(a));
|
|
2868
2951
|
});
|
|
2869
2952
|
});
|
|
2870
2953
|
}
|
|
2871
2954
|
try {
|
|
2872
|
-
return
|
|
2955
|
+
return Yn(await o, "completed");
|
|
2873
2956
|
} catch (t) {
|
|
2874
|
-
if (
|
|
2957
|
+
if (Zn(t)) return {
|
|
2875
2958
|
utteranceId: "utt_interrupted",
|
|
2876
2959
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2877
2960
|
status: "interrupted",
|
|
2878
2961
|
durationMs: 0,
|
|
2879
2962
|
transcript: r.text,
|
|
2880
|
-
animation:
|
|
2963
|
+
animation: An("none")
|
|
2881
2964
|
};
|
|
2882
|
-
throw
|
|
2965
|
+
throw Xn(t);
|
|
2883
2966
|
}
|
|
2884
2967
|
},
|
|
2885
2968
|
async play(i) {
|
|
2886
|
-
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"),
|
|
2969
|
+
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), Nn(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2887
2970
|
let a = i.queue ?? "append";
|
|
2888
|
-
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)),
|
|
2971
|
+
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), Cn(i.audio)) {
|
|
2889
2972
|
let e = i.audio.sampleRate ?? 24e3;
|
|
2890
2973
|
return r.createUtterance({
|
|
2891
2974
|
format: {
|
|
@@ -2901,7 +2984,7 @@ function Un(e) {
|
|
|
2901
2984
|
}
|
|
2902
2985
|
let o = e.getIframeHost();
|
|
2903
2986
|
if (!o) throw new Q("Speech session is not attached.");
|
|
2904
|
-
let s = await
|
|
2987
|
+
let s = await qn(i.audio, i.signal);
|
|
2905
2988
|
return o.speechPlay({
|
|
2906
2989
|
source: s,
|
|
2907
2990
|
characterId: i.characterId,
|
|
@@ -2913,13 +2996,13 @@ function Un(e) {
|
|
|
2913
2996
|
},
|
|
2914
2997
|
createUtterance(r) {
|
|
2915
2998
|
e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
|
|
2916
|
-
let i =
|
|
2999
|
+
let i = Pn(r);
|
|
2917
3000
|
if (r.track && r.track.kind !== "audio") throw new Q("createUtterance track must be an audio MediaStreamTrack.");
|
|
2918
3001
|
let a = r.queue ?? "replace-active";
|
|
2919
3002
|
if (a !== "replace-active" && a !== "replace-all") throw new Q("createUtterance queue must be replace-active or replace-all.");
|
|
2920
3003
|
e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
|
|
2921
|
-
let o = new
|
|
2922
|
-
id:
|
|
3004
|
+
let o = new Qn({
|
|
3005
|
+
id: Jn(),
|
|
2923
3006
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2924
3007
|
format: i,
|
|
2925
3008
|
queue: a,
|
|
@@ -2931,7 +3014,7 @@ function Un(e) {
|
|
|
2931
3014
|
t === o && (t = null);
|
|
2932
3015
|
}), r.track && (async () => {
|
|
2933
3016
|
try {
|
|
2934
|
-
if (await
|
|
3017
|
+
if (await Kn({
|
|
2935
3018
|
track: r.track,
|
|
2936
3019
|
utterance: o,
|
|
2937
3020
|
sampleRate: i.sampleRate,
|
|
@@ -2959,16 +3042,16 @@ function Un(e) {
|
|
|
2959
3042
|
}
|
|
2960
3043
|
//#endregion
|
|
2961
3044
|
//#region src/v2/types/sessionInteraction.ts
|
|
2962
|
-
function
|
|
3045
|
+
function er(e) {
|
|
2963
3046
|
let t = e?.trim();
|
|
2964
3047
|
return t === "full" || t === "face" || t === "medium" ? t : void 0;
|
|
2965
3048
|
}
|
|
2966
3049
|
//#endregion
|
|
2967
3050
|
//#region src/v2/experience.ts
|
|
2968
|
-
function
|
|
3051
|
+
function tr(e) {
|
|
2969
3052
|
return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
|
|
2970
3053
|
}
|
|
2971
|
-
var
|
|
3054
|
+
var nr = class e {
|
|
2972
3055
|
bootstrap;
|
|
2973
3056
|
conversationProcessor;
|
|
2974
3057
|
iframeHost = null;
|
|
@@ -2988,17 +3071,17 @@ var Kn = class e {
|
|
|
2988
3071
|
pendingTheatre = null;
|
|
2989
3072
|
lastInteraction = null;
|
|
2990
3073
|
closeHandlers = [];
|
|
2991
|
-
eventRegistry =
|
|
3074
|
+
eventRegistry = _n();
|
|
2992
3075
|
readyEnvelope = null;
|
|
2993
3076
|
startedEnvelope = null;
|
|
2994
3077
|
sessionMintedEnvelope = null;
|
|
2995
3078
|
conversationCache = [];
|
|
2996
3079
|
speech;
|
|
2997
3080
|
constructor(e) {
|
|
2998
|
-
this.bootstrap = e, this.conversationProcessor = e.conversationProcessor ?? null, this.resolvedSession = e.kind === "launch" ? e.session ?? null : null, this.launchToken = e.kind === "launch" ? e.launch : null, this.speech =
|
|
3081
|
+
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 = $n({
|
|
2999
3082
|
getIframeHost: () => this.iframeHost,
|
|
3000
3083
|
assertSessionStarted: () => this.assertSessionStarted(),
|
|
3001
|
-
getCapabilities: () =>
|
|
3084
|
+
getCapabilities: () => rr(this.resolvedSession),
|
|
3002
3085
|
getActiveCharacterId: () => "character_unknown",
|
|
3003
3086
|
onProcessorInterrupt: () => {
|
|
3004
3087
|
this.processorAbortController?.abort(), this.processorAbortController = null;
|
|
@@ -3019,6 +3102,8 @@ var Kn = class e {
|
|
|
3019
3102
|
embedBaseUrl: t.embedBaseUrl,
|
|
3020
3103
|
debug: t.debug,
|
|
3021
3104
|
speechOnly: t.speechOnly,
|
|
3105
|
+
previewBackground: t.previewBackground,
|
|
3106
|
+
previewForeground: t.previewForeground,
|
|
3022
3107
|
ui: t.ui,
|
|
3023
3108
|
onStart: t.onStart,
|
|
3024
3109
|
onUserTranscript: t.onUserTranscript,
|
|
@@ -3042,6 +3127,8 @@ var Kn = class e {
|
|
|
3042
3127
|
mode: t.mode,
|
|
3043
3128
|
speechInputMode: t.speechInputMode,
|
|
3044
3129
|
speechOnly: t.speechOnly,
|
|
3130
|
+
previewBackground: t.previewBackground,
|
|
3131
|
+
previewForeground: t.previewForeground,
|
|
3045
3132
|
attribution: t.attribution,
|
|
3046
3133
|
alreadyConverted: t.alreadyConverted,
|
|
3047
3134
|
ui: t.ui,
|
|
@@ -3065,6 +3152,8 @@ var Kn = class e {
|
|
|
3065
3152
|
mode: t.mode,
|
|
3066
3153
|
speechInputMode: t.speechInputMode,
|
|
3067
3154
|
speechOnly: t.speechOnly,
|
|
3155
|
+
previewBackground: t.previewBackground,
|
|
3156
|
+
previewForeground: t.previewForeground,
|
|
3068
3157
|
attribution: t.attribution,
|
|
3069
3158
|
alreadyConverted: t.alreadyConverted,
|
|
3070
3159
|
ui: t.ui,
|
|
@@ -3081,7 +3170,7 @@ var Kn = class e {
|
|
|
3081
3170
|
return null;
|
|
3082
3171
|
}
|
|
3083
3172
|
on(e, t) {
|
|
3084
|
-
let n =
|
|
3173
|
+
let n = vn(this.eventRegistry, e, t);
|
|
3085
3174
|
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;
|
|
3086
3175
|
}
|
|
3087
3176
|
async attach(e) {
|
|
@@ -3095,13 +3184,13 @@ var Kn = class e {
|
|
|
3095
3184
|
if (this.closed) throw Error("Session has ended.");
|
|
3096
3185
|
if (this.attached && this.iframeHost) return this.createPlayerFacade();
|
|
3097
3186
|
this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
|
|
3098
|
-
let t = this.bootstrap.embedBaseUrl ??
|
|
3187
|
+
let t = this.bootstrap.embedBaseUrl ?? un(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = fn(t, n, r ? void 0 : dn(this.bootstrap.backdropId, this.bootstrap.locationId), r ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, tr(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 = mn(i), o = null, s = new Promise((e) => {
|
|
3099
3188
|
o = e;
|
|
3100
3189
|
}), c = null, l = new Promise((e) => {
|
|
3101
3190
|
c = e;
|
|
3102
|
-
}), u =
|
|
3191
|
+
}), u = an((e) => {
|
|
3103
3192
|
this.readyEnvelope ||= (this.resolvedSession = e, this.emitWrapped("ready", { session: e }));
|
|
3104
|
-
}), d = this.bootstrap.onUserTranscript, f =
|
|
3193
|
+
}), d = this.bootstrap.onUserTranscript, f = rn({
|
|
3105
3194
|
container: e.container,
|
|
3106
3195
|
src: i,
|
|
3107
3196
|
playerOrigin: a,
|
|
@@ -3168,7 +3257,7 @@ var Kn = class e {
|
|
|
3168
3257
|
onTheatreChange: (t) => e.onTheatreChange?.(t)
|
|
3169
3258
|
});
|
|
3170
3259
|
this.iframeHost = f;
|
|
3171
|
-
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(),
|
|
3260
|
+
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), Nt(this.bootstrap.sessionEndpoint, {
|
|
3172
3261
|
experienceId: this.bootstrap.experienceId,
|
|
3173
3262
|
locale: this.bootstrap.locale,
|
|
3174
3263
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
@@ -3180,7 +3269,7 @@ var Kn = class e {
|
|
|
3180
3269
|
attribution: this.bootstrap.attribution,
|
|
3181
3270
|
alreadyConverted: this.bootstrap.alreadyConverted,
|
|
3182
3271
|
signal: this.endpointAbortController.signal
|
|
3183
|
-
})) : this.bootstrap.kind === "public" ?
|
|
3272
|
+
})) : this.bootstrap.kind === "public" ? Mt(this.bootstrap.experienceId, {
|
|
3184
3273
|
locale: this.bootstrap.locale,
|
|
3185
3274
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
3186
3275
|
learningLocale: this.bootstrap.learningLocale,
|
|
@@ -3204,7 +3293,7 @@ var Kn = class e {
|
|
|
3204
3293
|
operation: "attach",
|
|
3205
3294
|
message: e instanceof Error ? e.message : String(e),
|
|
3206
3295
|
stack: e instanceof Error ? e.stack : void 0,
|
|
3207
|
-
release:
|
|
3296
|
+
release: on
|
|
3208
3297
|
});
|
|
3209
3298
|
} catch {}
|
|
3210
3299
|
throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), e;
|
|
@@ -3216,19 +3305,23 @@ var Kn = class e {
|
|
|
3216
3305
|
if (!g) throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), Error("Session Launch response did not include a launch token.");
|
|
3217
3306
|
this.launchToken = g;
|
|
3218
3307
|
let v = _ ?? (this.bootstrap.kind === "launch" ? this.bootstrap.session : void 0);
|
|
3219
|
-
return v && !this.sessionMintedEnvelope && (this.resolvedSession = v, this.sessionMintedEnvelope = this.emitWrapped("sessionMinted", { session: v })), _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" &&
|
|
3308
|
+
return v && !this.sessionMintedEnvelope && (this.resolvedSession = v, this.sessionMintedEnvelope = this.emitWrapped("sessionMinted", { session: v })), _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" && wt(_), f.postLaunch(g, _, {
|
|
3220
3309
|
startButton: e.startButton,
|
|
3221
3310
|
theme: e.theme,
|
|
3222
3311
|
showFeedback: e.showFeedback,
|
|
3223
3312
|
interaction: e.interaction,
|
|
3224
|
-
...e.
|
|
3313
|
+
..._t("settingsButton", e.settingsButton),
|
|
3314
|
+
..._t("theatreButton", e.theatreButton),
|
|
3315
|
+
..._t("fullscreenButton", e.fullscreenButton),
|
|
3225
3316
|
...e.theatre === void 0 ? {} : { theatre: e.theatre }
|
|
3226
3317
|
}), u.setValue(_)) : f.postLaunch(g, void 0, {
|
|
3227
3318
|
startButton: e.startButton,
|
|
3228
3319
|
theme: e.theme,
|
|
3229
3320
|
showFeedback: e.showFeedback,
|
|
3230
3321
|
interaction: e.interaction,
|
|
3231
|
-
...e.
|
|
3322
|
+
..._t("settingsButton", e.settingsButton),
|
|
3323
|
+
..._t("theatreButton", e.theatreButton),
|
|
3324
|
+
..._t("fullscreenButton", e.fullscreenButton),
|
|
3232
3325
|
...e.theatre === void 0 ? {} : { theatre: e.theatre }
|
|
3233
3326
|
}), await Promise.race([s, new Promise((e, t) => {
|
|
3234
3327
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player loading UI.")), 12e4);
|
|
@@ -3240,7 +3333,7 @@ var Kn = class e {
|
|
|
3240
3333
|
operation: "attach",
|
|
3241
3334
|
message: e instanceof Error ? e.message : String(e),
|
|
3242
3335
|
stack: e instanceof Error ? e.stack : void 0,
|
|
3243
|
-
release:
|
|
3336
|
+
release: on
|
|
3244
3337
|
});
|
|
3245
3338
|
} catch {}
|
|
3246
3339
|
throw e;
|
|
@@ -3254,7 +3347,7 @@ var Kn = class e {
|
|
|
3254
3347
|
operation: "attach",
|
|
3255
3348
|
message: e instanceof Error ? e.message : String(e),
|
|
3256
3349
|
stack: e instanceof Error ? e.stack : void 0,
|
|
3257
|
-
release:
|
|
3350
|
+
release: on
|
|
3258
3351
|
});
|
|
3259
3352
|
} catch {}
|
|
3260
3353
|
throw e;
|
|
@@ -3286,7 +3379,7 @@ var Kn = class e {
|
|
|
3286
3379
|
this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
|
|
3287
3380
|
}
|
|
3288
3381
|
async setFit(e) {
|
|
3289
|
-
let t =
|
|
3382
|
+
let t = er(e);
|
|
3290
3383
|
if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
|
|
3291
3384
|
if (this.closed) throw Error("Session has ended.");
|
|
3292
3385
|
this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
|
|
@@ -3336,7 +3429,7 @@ var Kn = class e {
|
|
|
3336
3429
|
this.close();
|
|
3337
3430
|
}
|
|
3338
3431
|
destroy() {
|
|
3339
|
-
this.closed || (this.closed = !0, this.processorAbortController?.abort(), this.processorAbortController = null, this.endpointAbortController?.abort(), this.endpointAbortController = null, this.attachInFlight = null, this.iframeHost?.destroy(), this.iframeHost = null,
|
|
3432
|
+
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, bn(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.lastInteraction = null, this.attached = !1);
|
|
3340
3433
|
}
|
|
3341
3434
|
resolveMintInteraction() {
|
|
3342
3435
|
return this.bootstrap.kind === "launch" ? {} : {
|
|
@@ -3348,8 +3441,8 @@ var Kn = class e {
|
|
|
3348
3441
|
return this.resolvedSession?.id ?? "";
|
|
3349
3442
|
}
|
|
3350
3443
|
emitWrapped(e, t) {
|
|
3351
|
-
let n =
|
|
3352
|
-
return
|
|
3444
|
+
let n = gn(e, this.getSessionId(), t);
|
|
3445
|
+
return yn(this.eventRegistry, e, n), n;
|
|
3353
3446
|
}
|
|
3354
3447
|
queueProcessorTurn(e) {
|
|
3355
3448
|
if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
|
|
@@ -3358,7 +3451,7 @@ var Kn = class e {
|
|
|
3358
3451
|
let n = this.processorAbortController.signal;
|
|
3359
3452
|
this.processorChain = this.processorChain.then(async () => {
|
|
3360
3453
|
if (!n.aborted) try {
|
|
3361
|
-
let r = await
|
|
3454
|
+
let r = await It(t, {
|
|
3362
3455
|
utteranceId: e.utteranceId,
|
|
3363
3456
|
text: e.text,
|
|
3364
3457
|
conversation: this.conversationCache,
|
|
@@ -3408,7 +3501,7 @@ var Kn = class e {
|
|
|
3408
3501
|
};
|
|
3409
3502
|
}
|
|
3410
3503
|
};
|
|
3411
|
-
function
|
|
3504
|
+
function rr(e) {
|
|
3412
3505
|
return e ? {
|
|
3413
3506
|
textSpeech: e.capabilities.speech.output,
|
|
3414
3507
|
externalSpeechAudio: e.capabilities.speech.externalAudio
|
|
@@ -3419,41 +3512,41 @@ function qn(e) {
|
|
|
3419
3512
|
}
|
|
3420
3513
|
//#endregion
|
|
3421
3514
|
//#region src/widget/dockGeometry.ts
|
|
3422
|
-
var
|
|
3423
|
-
function
|
|
3515
|
+
var ir = "(min-width: 768px)", ar = 24, or = .5, sr = 1200, cr = .85, lr = 9 / 16;
|
|
3516
|
+
function ur() {
|
|
3424
3517
|
if (typeof window > "u") return 800;
|
|
3425
3518
|
let e = window.screen?.availHeight;
|
|
3426
3519
|
return typeof e == "number" && e > 0 ? e : window.innerHeight;
|
|
3427
3520
|
}
|
|
3428
|
-
function
|
|
3429
|
-
let i = Math.max(160, Math.min(t - n * 2, t *
|
|
3430
|
-
return s > a && (s = a, o = s /
|
|
3521
|
+
function dr(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = ar, r = typeof window < "u" ? ur() : 800) {
|
|
3522
|
+
let i = Math.max(160, Math.min(t - n * 2, t * cr)), a = Math.max(120, e - n * 2), o = Math.min(r * or, sr, i), s = o * lr;
|
|
3523
|
+
return s > a && (s = a, o = s / lr, o > i && (o = i, s = o * lr)), {
|
|
3431
3524
|
width: Math.round(s),
|
|
3432
3525
|
height: Math.round(o)
|
|
3433
3526
|
};
|
|
3434
3527
|
}
|
|
3435
|
-
function
|
|
3528
|
+
function fr(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = ar) {
|
|
3436
3529
|
return {
|
|
3437
3530
|
left: Math.max(r, t - e.width - r),
|
|
3438
3531
|
top: Math.max(r, n - e.height - r)
|
|
3439
3532
|
};
|
|
3440
3533
|
}
|
|
3441
|
-
function
|
|
3534
|
+
function pr(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = ar) {
|
|
3442
3535
|
let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
|
|
3443
3536
|
return {
|
|
3444
3537
|
left: Math.min(Math.max(a, e), o),
|
|
3445
3538
|
top: Math.min(Math.max(a, t), s)
|
|
3446
3539
|
};
|
|
3447
3540
|
}
|
|
3448
|
-
function
|
|
3449
|
-
return e(
|
|
3541
|
+
function mr(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
|
|
3542
|
+
return e(ir).matches;
|
|
3450
3543
|
}
|
|
3451
3544
|
//#endregion
|
|
3452
3545
|
//#region src/widget/mountExperienceWidget.ts
|
|
3453
|
-
function
|
|
3546
|
+
function hr(e) {
|
|
3454
3547
|
return e === "bottom-right" || e === "bottom-left" ? e : "static";
|
|
3455
3548
|
}
|
|
3456
|
-
function
|
|
3549
|
+
function gr(e) {
|
|
3457
3550
|
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
3458
3551
|
let t = typeof e == "string" ? e.trim() : "";
|
|
3459
3552
|
return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
|
|
@@ -3461,10 +3554,10 @@ function or(e) {
|
|
|
3461
3554
|
function $(e) {
|
|
3462
3555
|
return e === "expanded" || e === "docked";
|
|
3463
3556
|
}
|
|
3464
|
-
var
|
|
3465
|
-
function
|
|
3557
|
+
var _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=\"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>", vr = "<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>", yr = "<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>", br = "<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>";
|
|
3558
|
+
function xr(e, t, n) {
|
|
3466
3559
|
Ve(ze);
|
|
3467
|
-
let r =
|
|
3560
|
+
let r = pe({
|
|
3468
3561
|
galleryThumb: t.galleryThumb,
|
|
3469
3562
|
avatarImage: t.avatarImage,
|
|
3470
3563
|
backgroundImage: t.backgroundImage,
|
|
@@ -3492,7 +3585,7 @@ function dr(e, t, n) {
|
|
|
3492
3585
|
}
|
|
3493
3586
|
return e.replaceChildren(i), n?.parallax === !1 ? () => {} : Re(i);
|
|
3494
3587
|
}
|
|
3495
|
-
function
|
|
3588
|
+
function Sr(e) {
|
|
3496
3589
|
return e.startButton ? {
|
|
3497
3590
|
...e.startButton,
|
|
3498
3591
|
label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
|
|
@@ -3504,7 +3597,7 @@ function fr(e) {
|
|
|
3504
3597
|
variant: "primary"
|
|
3505
3598
|
};
|
|
3506
3599
|
}
|
|
3507
|
-
function
|
|
3600
|
+
function Cr(e) {
|
|
3508
3601
|
let t = !1, n = () => {
|
|
3509
3602
|
t || e();
|
|
3510
3603
|
}, r = () => {
|
|
@@ -3524,12 +3617,12 @@ function pr(e) {
|
|
|
3524
3617
|
t = !0, window.removeEventListener("load", r), i?.();
|
|
3525
3618
|
};
|
|
3526
3619
|
}
|
|
3527
|
-
function
|
|
3528
|
-
|
|
3620
|
+
function wr(e, t) {
|
|
3621
|
+
et(Qe);
|
|
3529
3622
|
let n = t.experienceId?.trim();
|
|
3530
3623
|
if (!n) throw Error("ExperienceWidget requires experienceId.");
|
|
3531
|
-
let r = t.prefetch ?? "onExpand", i =
|
|
3532
|
-
a.className = "liforma-ew", a.dataset.state = "collapsed", a.dataset.prefetch = r, a.dataset.position = i, a.style.setProperty("--liforma-ew-max-w", t.expandedMaxWidth ?? "100%"), a.style.setProperty("--liforma-ew-max-h", t.expandedMaxHeight ?? "100%"), i !== "static" && a.style.setProperty("--liforma-ew-offset",
|
|
3624
|
+
let r = t.prefetch ?? "onExpand", i = hr(t.position), a = document.createElement("div");
|
|
3625
|
+
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", gr(t.offset));
|
|
3533
3626
|
let o = document.createElement("button");
|
|
3534
3627
|
o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
|
|
3535
3628
|
let s = document.createElement("div");
|
|
@@ -3549,19 +3642,19 @@ function mr(e, t) {
|
|
|
3549
3642
|
let m = document.createElement("span");
|
|
3550
3643
|
m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
|
|
3551
3644
|
let h = document.createElement("button");
|
|
3552
|
-
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML =
|
|
3645
|
+
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = yr, h.setAttribute("aria-label", "Reduce");
|
|
3553
3646
|
let g = document.createElement("button");
|
|
3554
|
-
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML =
|
|
3647
|
+
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = _r, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
|
|
3555
3648
|
let _ = document.createElement("button");
|
|
3556
|
-
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML =
|
|
3649
|
+
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = vr, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
|
|
3557
3650
|
let v = document.createElement("div");
|
|
3558
3651
|
v.className = "liforma-ew__stage";
|
|
3559
3652
|
let y = document.createElement("div");
|
|
3560
3653
|
y.className = "liforma-ew__status", y.hidden = !0, f.append(v, y), u.append(d, f), a.append(o, l, u, p), e.replaceChildren(a);
|
|
3561
|
-
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,
|
|
3654
|
+
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, R = !1, ne = new AbortController(), re = t.parallax !== !1, z = () => {
|
|
3562
3655
|
let e = a.dataset.state;
|
|
3563
3656
|
return e === "expanded" || e === "docked" || e === "collapsed" ? e : "collapsed";
|
|
3564
|
-
},
|
|
3657
|
+
}, ie = () => {
|
|
3565
3658
|
j !== null && (clearTimeout(j), j = null);
|
|
3566
3659
|
}, ae = () => {
|
|
3567
3660
|
M !== null && (clearTimeout(M), M = null), a.classList.remove("liforma-ew--layout-settling");
|
|
@@ -3580,50 +3673,50 @@ function mr(e, t) {
|
|
|
3580
3673
|
let a = p.offsetWidth || 120;
|
|
3581
3674
|
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";
|
|
3582
3675
|
}, se = (e, t) => {
|
|
3583
|
-
if (
|
|
3584
|
-
let n =
|
|
3676
|
+
if (z() !== "docked") return;
|
|
3677
|
+
let n = dr(), r = pr(e - te, t - I, n);
|
|
3585
3678
|
N = r.left, P = r.top, oe(r.left, r.top, n.width, n.height);
|
|
3586
3679
|
}, ce = (e, t) => {
|
|
3587
|
-
if (
|
|
3588
|
-
let n =
|
|
3680
|
+
if (z() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
|
|
3681
|
+
let n = dr(), r = N ?? f.getBoundingClientRect().left, i = P ?? f.getBoundingClientRect().top, a = pr(r + e, i + t, n);
|
|
3589
3682
|
N = a.left, P = a.top, oe(a.left, a.top, n.width, n.height);
|
|
3590
|
-
},
|
|
3683
|
+
}, le = (e) => {
|
|
3591
3684
|
L === "toolbar" && (F === null || e.pointerId !== F || (e.preventDefault(), se(e.clientX, e.clientY)));
|
|
3592
|
-
},
|
|
3685
|
+
}, V = (e) => {
|
|
3593
3686
|
if (F === null || e && e.pointerId !== F) return;
|
|
3594
3687
|
let t = L;
|
|
3595
|
-
F = null, L = null, p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging"), t === "toolbar" &&
|
|
3596
|
-
},
|
|
3597
|
-
if (S ||
|
|
3688
|
+
F = null, L = null, p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging"), t === "toolbar" && R && (R = !1, window.removeEventListener("pointermove", le), window.removeEventListener("pointerup", V), window.removeEventListener("pointercancel", V));
|
|
3689
|
+
}, H = (e, t, n) => {
|
|
3690
|
+
if (S || z() !== "docked" || !mr() || F !== null) return;
|
|
3598
3691
|
F = n, L = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
3599
3692
|
let r = f.getBoundingClientRect();
|
|
3600
|
-
te = e - r.left, I = t - r.top,
|
|
3601
|
-
},
|
|
3602
|
-
if (S ||
|
|
3693
|
+
te = e - r.left, I = t - r.top, R || (R = !0, window.addEventListener("pointermove", le), window.addEventListener("pointerup", V), window.addEventListener("pointercancel", V));
|
|
3694
|
+
}, U = (e) => {
|
|
3695
|
+
if (S || z() !== "docked" || !mr() || F !== null) return;
|
|
3603
3696
|
F = e.pointerId, L = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
3604
3697
|
let t = f.getBoundingClientRect();
|
|
3605
3698
|
N = t.left, P = t.top;
|
|
3606
|
-
},
|
|
3699
|
+
}, ue = (e) => {
|
|
3607
3700
|
L === "player" && (F === null || e.pointerId !== F || ce(e.dx, e.dy));
|
|
3608
3701
|
}, de = (e) => {
|
|
3609
|
-
L === "player" && (F === null || e.pointerId !== F ||
|
|
3702
|
+
L === "player" && (F === null || e.pointerId !== F || V());
|
|
3610
3703
|
}, W = () => {
|
|
3611
|
-
let e =
|
|
3704
|
+
let e = mr(), t = z();
|
|
3612
3705
|
if (!e || t !== "expanded" && t !== "docked") {
|
|
3613
3706
|
h.hidden = !0;
|
|
3614
3707
|
return;
|
|
3615
3708
|
}
|
|
3616
|
-
h.hidden = !1, t === "docked" ? (h.innerHTML =
|
|
3617
|
-
},
|
|
3618
|
-
let t =
|
|
3619
|
-
n =
|
|
3620
|
-
},
|
|
3709
|
+
h.hidden = !1, t === "docked" ? (h.innerHTML = br, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = yr, h.setAttribute("aria-label", "Reduce"));
|
|
3710
|
+
}, fe = (e) => {
|
|
3711
|
+
let t = dr(), n = e && N !== null && P !== null ? pr(N, P, t) : fr(t);
|
|
3712
|
+
n = pr(n.left, n.top, t), N = n.left, P = n.top, oe(n.left, n.top, t.width, t.height), W();
|
|
3713
|
+
}, pe = () => {
|
|
3621
3714
|
a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
|
|
3622
3715
|
requestAnimationFrame(() => {
|
|
3623
3716
|
S || !$(a.dataset.state) || a.classList.add("liforma-ew--session-revealed");
|
|
3624
3717
|
});
|
|
3625
3718
|
});
|
|
3626
|
-
},
|
|
3719
|
+
}, me = (e) => {
|
|
3627
3720
|
if (ae(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !D) {
|
|
3628
3721
|
a.classList.remove("liforma-ew--layout-settling");
|
|
3629
3722
|
return;
|
|
@@ -3633,54 +3726,54 @@ function mr(e, t) {
|
|
|
3633
3726
|
a.classList.remove("liforma-ew--layout-settling");
|
|
3634
3727
|
return;
|
|
3635
3728
|
}
|
|
3636
|
-
a.classList.remove("liforma-ew--layout-settling"),
|
|
3729
|
+
a.classList.remove("liforma-ew--layout-settling"), pe();
|
|
3637
3730
|
}, 220);
|
|
3638
|
-
},
|
|
3639
|
-
|
|
3731
|
+
}, he = () => (a.classList.add("liforma-ew--session-concealing"), a.classList.remove("liforma-ew--session-revealed"), new Promise((e) => {
|
|
3732
|
+
ie(), j = setTimeout(() => {
|
|
3640
3733
|
j = null, a.classList.remove("liforma-ew--session-concealing"), e();
|
|
3641
3734
|
}, 280);
|
|
3642
|
-
})),
|
|
3735
|
+
})), ge = {
|
|
3643
3736
|
galleryThumb: t.galleryThumb,
|
|
3644
3737
|
avatarImage: t.avatarImage,
|
|
3645
3738
|
backgroundImage: t.backgroundImage,
|
|
3646
3739
|
foregroundImage: t.foregroundImage,
|
|
3647
3740
|
fallbackImage: t.fallbackImage
|
|
3648
|
-
},
|
|
3741
|
+
}, _e = (e) => {
|
|
3649
3742
|
if (!e) {
|
|
3650
3743
|
y.hidden = !0, y.textContent = "";
|
|
3651
3744
|
return;
|
|
3652
3745
|
}
|
|
3653
3746
|
y.hidden = !1, y.textContent = e;
|
|
3654
|
-
},
|
|
3747
|
+
}, ve = (e) => {
|
|
3655
3748
|
if (!e) {
|
|
3656
3749
|
c.hidden = !0, c.textContent = "";
|
|
3657
3750
|
return;
|
|
3658
3751
|
}
|
|
3659
3752
|
c.hidden = !1, c.textContent = e, s.contains(c) || s.append(c);
|
|
3660
|
-
}, ve = () => {
|
|
3661
|
-
C = !0, o.disabled = !1, _e(null), r === "onExpand" && t.onPrefetchReady?.();
|
|
3662
3753
|
}, ye = () => {
|
|
3754
|
+
C = !0, o.disabled = !1, ve(null), r === "onExpand" && t.onPrefetchReady?.();
|
|
3755
|
+
}, be = () => {
|
|
3663
3756
|
w = !0, a.dataset.warm = "true", l.hidden = !1, D || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
|
|
3664
|
-
},
|
|
3757
|
+
}, xe = (e) => {
|
|
3665
3758
|
A?.(), A = null;
|
|
3666
|
-
let t =
|
|
3759
|
+
let t = xr(s, e, { parallax: re });
|
|
3667
3760
|
return t ? (A = t, !0) : !1;
|
|
3668
|
-
},
|
|
3669
|
-
if (
|
|
3670
|
-
|
|
3761
|
+
}, Se = () => {
|
|
3762
|
+
if (xe(ge)) {
|
|
3763
|
+
ye();
|
|
3671
3764
|
return;
|
|
3672
3765
|
}
|
|
3673
|
-
|
|
3766
|
+
ve("Loading…"), ot(n, { signal: ne.signal }).then((e) => {
|
|
3674
3767
|
if (!S) {
|
|
3675
|
-
if (!
|
|
3676
|
-
|
|
3768
|
+
if (!xe({ galleryThumb: e.galleryThumb })) throw Error("Experience preview is missing gallery thumb images.");
|
|
3769
|
+
ye();
|
|
3677
3770
|
}
|
|
3678
3771
|
}).catch((e) => {
|
|
3679
|
-
if (S ||
|
|
3772
|
+
if (S || ne.signal.aborted) return;
|
|
3680
3773
|
let n = e instanceof Error ? e : Error(String(e));
|
|
3681
|
-
|
|
3774
|
+
ve("Preview unavailable"), o.disabled = !0, t.onError?.(n), console.error("[ExperienceWidget]", n);
|
|
3682
3775
|
});
|
|
3683
|
-
},
|
|
3776
|
+
}, Ce = () => ({
|
|
3684
3777
|
experienceId: n,
|
|
3685
3778
|
ui: "widget",
|
|
3686
3779
|
...t.sessionEndpoint ? { sessionEndpoint: t.sessionEndpoint } : {},
|
|
@@ -3693,89 +3786,89 @@ function mr(e, t) {
|
|
|
3693
3786
|
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
|
|
3694
3787
|
...t.alreadyConverted?.length ? { alreadyConverted: t.alreadyConverted } : {},
|
|
3695
3788
|
...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
|
|
3696
|
-
}),
|
|
3789
|
+
}), we = () => ({
|
|
3697
3790
|
...t.fit ? { fit: t.fit } : {},
|
|
3698
|
-
startButton:
|
|
3791
|
+
startButton: Sr(t),
|
|
3699
3792
|
...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback },
|
|
3700
3793
|
...t.interaction ? { interaction: t.interaction } : {}
|
|
3701
|
-
}),
|
|
3702
|
-
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), B(), a.dataset.state = "expanded",
|
|
3703
|
-
},
|
|
3704
|
-
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked",
|
|
3705
|
-
},
|
|
3794
|
+
}), G = (e = !0) => {
|
|
3795
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), B(), a.dataset.state = "expanded", _e(null), typeof document < "u" && (k = document.body.style.overflow, document.body.style.overflow = "hidden"), W(), e && t.onExpanded?.();
|
|
3796
|
+
}, Te = () => {
|
|
3797
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked", _e(null), typeof document < "u" && (document.body.style.overflow = k), fe(!0), W(), b?.setWidgetChrome("docked");
|
|
3798
|
+
}, Ee = (e) => {
|
|
3706
3799
|
e.on("started", () => {
|
|
3707
|
-
S || (D = !0, a.dataset.live = "true",
|
|
3800
|
+
S || (D = !0, a.dataset.live = "true", _e(null), t.onStarted?.(), $(a.dataset.state) && pe());
|
|
3708
3801
|
}), e.on("feedback", (e) => {
|
|
3709
3802
|
S || t.onFeedback?.(e);
|
|
3710
3803
|
}), e.on("feedbackFailed", (e) => {
|
|
3711
3804
|
S || t.onFeedbackFailed?.(e);
|
|
3712
3805
|
});
|
|
3713
|
-
}, Ee = () => {
|
|
3714
|
-
ae(), u.hidden = !0, p.hidden = !0, B(), a.dataset.state = "collapsed", a.classList.remove("liforma-ew--session-revealed"), a.classList.remove("liforma-ew--session-concealing"), g.setAttribute("aria-pressed", "false"), o.hidden = !1, o.tabIndex = 0, o.removeAttribute("aria-hidden"), C && (o.disabled = !1), ge(null), typeof document < "u" && (document.body.style.overflow = k), W();
|
|
3715
3806
|
}, De = () => {
|
|
3716
|
-
|
|
3807
|
+
ae(), u.hidden = !0, p.hidden = !0, B(), a.dataset.state = "collapsed", a.classList.remove("liforma-ew--session-revealed"), a.classList.remove("liforma-ew--session-concealing"), g.setAttribute("aria-pressed", "false"), o.hidden = !1, o.tabIndex = 0, o.removeAttribute("aria-hidden"), C && (o.disabled = !1), _e(null), typeof document < "u" && (document.body.style.overflow = k), W();
|
|
3808
|
+
}, Oe = () => {
|
|
3809
|
+
ie(), ae(), O += 1, x = !1, w = !1, T = !1, E = !1, D = !1;
|
|
3717
3810
|
let e = b;
|
|
3718
3811
|
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");
|
|
3719
|
-
},
|
|
3812
|
+
}, K = () => {
|
|
3720
3813
|
if (!S && $(a.dataset.state)) {
|
|
3721
|
-
if (
|
|
3814
|
+
if (V(), x = !1, b && E) {
|
|
3722
3815
|
let e = b;
|
|
3723
3816
|
(async () => {
|
|
3724
|
-
D && (await
|
|
3817
|
+
D && (await he(), 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?.());
|
|
3725
3818
|
})();
|
|
3726
3819
|
return;
|
|
3727
3820
|
}
|
|
3728
|
-
|
|
3821
|
+
Oe(), De(), t.onCollapsed?.(), t.onClose?.();
|
|
3729
3822
|
}
|
|
3730
|
-
}, Oe = () => {
|
|
3731
|
-
S || ir() && R() === "expanded" && pe(() => {
|
|
3732
|
-
we();
|
|
3733
|
-
});
|
|
3734
3823
|
}, ke = () => {
|
|
3735
|
-
S ||
|
|
3736
|
-
|
|
3737
|
-
})
|
|
3824
|
+
S || mr() && z() === "expanded" && me(() => {
|
|
3825
|
+
Te();
|
|
3826
|
+
});
|
|
3738
3827
|
}, Ae = () => {
|
|
3739
|
-
|
|
3828
|
+
S || z() === "docked" && (V(), me(() => {
|
|
3829
|
+
B(), G(!1), b?.setWidgetChrome("expanded");
|
|
3830
|
+
}));
|
|
3831
|
+
}, je = () => {
|
|
3832
|
+
!b || !D || (ie(), a.classList.remove("liforma-ew--session-revealed"), G(), b.setWidgetChrome("expanded"), x = !1, pe());
|
|
3833
|
+
}, q = () => {
|
|
3834
|
+
!b || !E || D || (ie(), a.classList.remove("liforma-ew--session-revealed"), G(), x = !1, w || b.setWidgetChrome("expanded"));
|
|
3835
|
+
}, Me = (e) => {
|
|
3836
|
+
S || e !== O && !D || (ie(), a.classList.remove("liforma-ew--session-revealed"), G(), x = !1, D && pe());
|
|
3740
3837
|
}, J = () => {
|
|
3741
|
-
!b || !E || D || (z(), a.classList.remove("liforma-ew--session-revealed"), Ce(), x = !1, w || b.setWidgetChrome("expanded"));
|
|
3742
|
-
}, je = (e) => {
|
|
3743
|
-
S || e !== O && !D || (z(), a.classList.remove("liforma-ew--session-revealed"), Ce(), x = !1, D && fe());
|
|
3744
|
-
}, Me = () => {
|
|
3745
3838
|
if (S || T || w || b || $(a.dataset.state)) return;
|
|
3746
3839
|
T = !0;
|
|
3747
3840
|
let e = O;
|
|
3748
3841
|
l.hidden = !1, (async () => {
|
|
3749
3842
|
try {
|
|
3750
|
-
let t = await
|
|
3843
|
+
let t = await nr.startSession(Ce());
|
|
3751
3844
|
if (S || e !== O) {
|
|
3752
3845
|
t.destroy();
|
|
3753
3846
|
return;
|
|
3754
3847
|
}
|
|
3755
|
-
b = t,
|
|
3848
|
+
b = t, Ee(t);
|
|
3756
3849
|
let n = await t.attach({
|
|
3757
3850
|
container: l,
|
|
3758
|
-
...
|
|
3851
|
+
...we(),
|
|
3759
3852
|
onWidgetReady: () => {
|
|
3760
|
-
S || e !== O || (T = !1, E = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") :
|
|
3853
|
+
S || e !== O || (T = !1, E = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") : be());
|
|
3761
3854
|
},
|
|
3762
3855
|
onWidgetExpand: () => {
|
|
3763
|
-
|
|
3856
|
+
Me(e);
|
|
3764
3857
|
},
|
|
3765
3858
|
onWidgetAudioSettings: (e) => {
|
|
3766
3859
|
S || Ie(e);
|
|
3767
3860
|
},
|
|
3768
3861
|
onWidgetDragStart: (e) => {
|
|
3769
|
-
S ||
|
|
3862
|
+
S || U(e);
|
|
3770
3863
|
},
|
|
3771
3864
|
onWidgetDragMove: (e) => {
|
|
3772
|
-
S ||
|
|
3865
|
+
S || ue(e);
|
|
3773
3866
|
},
|
|
3774
3867
|
onWidgetDragEnd: (e) => {
|
|
3775
3868
|
S || de(e);
|
|
3776
3869
|
},
|
|
3777
3870
|
onPlayerStatusChange: (e) => {
|
|
3778
|
-
S || e === "error" && $(a.dataset.state) &&
|
|
3871
|
+
S || e === "error" && $(a.dataset.state) && _e("Could not load the experience.");
|
|
3779
3872
|
}
|
|
3780
3873
|
});
|
|
3781
3874
|
if (S || e !== O) {
|
|
@@ -3783,7 +3876,7 @@ function mr(e, t) {
|
|
|
3783
3876
|
return;
|
|
3784
3877
|
}
|
|
3785
3878
|
n.on("close", () => {
|
|
3786
|
-
S ||
|
|
3879
|
+
S || K();
|
|
3787
3880
|
});
|
|
3788
3881
|
} catch (n) {
|
|
3789
3882
|
if (S || e !== O) return;
|
|
@@ -3795,40 +3888,40 @@ function mr(e, t) {
|
|
|
3795
3888
|
}, Ne = () => {
|
|
3796
3889
|
if (S || x || !C || $(a.dataset.state)) return;
|
|
3797
3890
|
if (b && D) {
|
|
3798
|
-
|
|
3891
|
+
je();
|
|
3799
3892
|
return;
|
|
3800
3893
|
}
|
|
3801
3894
|
if (b && E) {
|
|
3802
|
-
|
|
3895
|
+
q();
|
|
3803
3896
|
return;
|
|
3804
3897
|
}
|
|
3805
3898
|
let e = ++O;
|
|
3806
3899
|
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 () => {
|
|
3807
3900
|
try {
|
|
3808
|
-
|
|
3809
|
-
let t = await
|
|
3901
|
+
G();
|
|
3902
|
+
let t = await nr.startSession(Ce());
|
|
3810
3903
|
if (S || e !== O) {
|
|
3811
3904
|
t.destroy();
|
|
3812
3905
|
return;
|
|
3813
3906
|
}
|
|
3814
|
-
b = t,
|
|
3907
|
+
b = t, Ee(t);
|
|
3815
3908
|
let n = await t.attach({
|
|
3816
3909
|
container: v,
|
|
3817
|
-
...
|
|
3910
|
+
...we(),
|
|
3818
3911
|
onWidgetAudioSettings: (e) => {
|
|
3819
3912
|
S || Ie(e);
|
|
3820
3913
|
},
|
|
3821
3914
|
onWidgetDragStart: (e) => {
|
|
3822
|
-
S ||
|
|
3915
|
+
S || U(e);
|
|
3823
3916
|
},
|
|
3824
3917
|
onWidgetDragMove: (e) => {
|
|
3825
|
-
S ||
|
|
3918
|
+
S || ue(e);
|
|
3826
3919
|
},
|
|
3827
3920
|
onWidgetDragEnd: (e) => {
|
|
3828
3921
|
S || de(e);
|
|
3829
3922
|
},
|
|
3830
3923
|
onPlayerStatusChange: (e) => {
|
|
3831
|
-
S || (e === "error" ?
|
|
3924
|
+
S || (e === "error" ? _e("Could not load the experience.") : $(a.dataset.state) && _e(null));
|
|
3832
3925
|
}
|
|
3833
3926
|
});
|
|
3834
3927
|
if (S || e !== O) {
|
|
@@ -3836,12 +3929,12 @@ function mr(e, t) {
|
|
|
3836
3929
|
return;
|
|
3837
3930
|
}
|
|
3838
3931
|
E = !0, t.setWidgetChrome("expanded"), n.on("close", () => {
|
|
3839
|
-
S ||
|
|
3932
|
+
S || K();
|
|
3840
3933
|
});
|
|
3841
3934
|
} catch (n) {
|
|
3842
3935
|
if (S || e !== O) return;
|
|
3843
3936
|
let r = n instanceof Error ? n : Error(String(n));
|
|
3844
|
-
|
|
3937
|
+
_e(r.message), t.onError?.(r), console.error("[ExperienceWidget]", r);
|
|
3845
3938
|
} finally {
|
|
3846
3939
|
e === O && (x = !1);
|
|
3847
3940
|
}
|
|
@@ -3849,88 +3942,88 @@ function mr(e, t) {
|
|
|
3849
3942
|
}, Pe = () => {
|
|
3850
3943
|
if (!(S || $(a.dataset.state))) {
|
|
3851
3944
|
if (b && D) {
|
|
3852
|
-
|
|
3945
|
+
je();
|
|
3853
3946
|
return;
|
|
3854
3947
|
}
|
|
3855
3948
|
if (b && E) {
|
|
3856
|
-
|
|
3949
|
+
q();
|
|
3857
3950
|
return;
|
|
3858
3951
|
}
|
|
3859
3952
|
if (T || b) {
|
|
3860
|
-
|
|
3953
|
+
G();
|
|
3861
3954
|
return;
|
|
3862
3955
|
}
|
|
3863
3956
|
Ne();
|
|
3864
3957
|
}
|
|
3865
3958
|
}, Fe = (e) => {
|
|
3866
|
-
if (e.stopPropagation(),
|
|
3867
|
-
|
|
3959
|
+
if (e.stopPropagation(), z() === "expanded") {
|
|
3960
|
+
ke();
|
|
3868
3961
|
return;
|
|
3869
3962
|
}
|
|
3870
|
-
|
|
3963
|
+
z() === "docked" && Ae();
|
|
3871
3964
|
}, Ie = (e) => {
|
|
3872
3965
|
g.setAttribute("aria-pressed", e ? "true" : "false");
|
|
3873
3966
|
}, Le = (e) => {
|
|
3874
3967
|
e.stopPropagation(), $(a.dataset.state) && b?.toggleAudioSettings();
|
|
3875
3968
|
}, Re = (e) => {
|
|
3876
|
-
|
|
3969
|
+
z() === "docked" && mr() && (e.target?.closest("button") || (e.preventDefault(), H(e.clientX, e.clientY, e.pointerId)));
|
|
3877
3970
|
}, ze = (e) => {
|
|
3878
|
-
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(),
|
|
3971
|
+
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), K());
|
|
3879
3972
|
}, Be = () => {
|
|
3880
3973
|
if (!S) {
|
|
3881
|
-
if (
|
|
3882
|
-
if (!
|
|
3883
|
-
|
|
3974
|
+
if (z() === "docked") {
|
|
3975
|
+
if (!mr()) {
|
|
3976
|
+
Ae();
|
|
3884
3977
|
return;
|
|
3885
3978
|
}
|
|
3886
|
-
D ?
|
|
3887
|
-
|
|
3888
|
-
}) :
|
|
3979
|
+
D ? me(() => {
|
|
3980
|
+
fe(!0);
|
|
3981
|
+
}) : fe(!0);
|
|
3889
3982
|
return;
|
|
3890
3983
|
}
|
|
3891
3984
|
W();
|
|
3892
3985
|
}
|
|
3893
|
-
}, Ve = typeof window < "u" ? window.matchMedia(
|
|
3986
|
+
}, Ve = typeof window < "u" ? window.matchMedia(ir) : null, He = () => {
|
|
3894
3987
|
if (!S) {
|
|
3895
|
-
if (
|
|
3896
|
-
|
|
3988
|
+
if (z() === "docked" && !mr()) {
|
|
3989
|
+
Ae();
|
|
3897
3990
|
return;
|
|
3898
3991
|
}
|
|
3899
3992
|
W();
|
|
3900
3993
|
}
|
|
3901
3994
|
};
|
|
3902
|
-
return o.addEventListener("click", Pe), d.addEventListener("click",
|
|
3903
|
-
e.stopPropagation(),
|
|
3904
|
-
}), h.addEventListener("click", Fe), g.addEventListener("click", Le), p.addEventListener("pointerdown", Re), window.addEventListener("keydown", ze), window.addEventListener("resize", Be), Ve?.addEventListener("change", He),
|
|
3905
|
-
S ||
|
|
3906
|
-
}) : r === "idle" && (ee =
|
|
3907
|
-
S ||
|
|
3995
|
+
return o.addEventListener("click", Pe), d.addEventListener("click", K), _.addEventListener("click", (e) => {
|
|
3996
|
+
e.stopPropagation(), K();
|
|
3997
|
+
}), 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(), W(), r === "eager" ? queueMicrotask(() => {
|
|
3998
|
+
S || J();
|
|
3999
|
+
}) : r === "idle" && (ee = Cr(() => {
|
|
4000
|
+
S || J();
|
|
3908
4001
|
})), {
|
|
3909
4002
|
root: a,
|
|
3910
4003
|
expand: Pe,
|
|
3911
|
-
collapse:
|
|
3912
|
-
dock:
|
|
3913
|
-
maximize:
|
|
4004
|
+
collapse: K,
|
|
4005
|
+
dock: ke,
|
|
4006
|
+
maximize: Ae,
|
|
3914
4007
|
prefetch() {
|
|
3915
4008
|
if (r === "onExpand") {
|
|
3916
|
-
|
|
4009
|
+
J();
|
|
3917
4010
|
return;
|
|
3918
4011
|
}
|
|
3919
|
-
|
|
4012
|
+
J();
|
|
3920
4013
|
},
|
|
3921
4014
|
destroy() {
|
|
3922
|
-
S || (S = !0,
|
|
4015
|
+
S || (S = !0, V(), ee?.(), ee = null, ne.abort(), A?.(), A = null, window.removeEventListener("keydown", ze), window.removeEventListener("resize", Be), Ve?.removeEventListener("change", He), Oe(), De(), e.replaceChildren());
|
|
3923
4016
|
}
|
|
3924
4017
|
};
|
|
3925
4018
|
}
|
|
3926
4019
|
//#endregion
|
|
3927
4020
|
//#region src/react/ExperienceWidget.tsx
|
|
3928
|
-
function
|
|
3929
|
-
let t = o(null), { experienceId: r, alt: i, galleryThumb: a, avatarImage: s, backgroundImage: c, foregroundImage: l, fallbackImage: u, prefetch: f = "onExpand", parallax: p = !0, position: m = "static", offset: h, sessionEndpoint: g, locale: _, secondaryLocale: v, learningLocale: y, language: b, mode: x, speechInputMode: S, speechOnly: C, fit: w, embedBaseUrl: T, expandedMaxWidth: E, expandedMaxHeight: D, startButtonLabel: O, startButton: k, showFeedback: A, className: ee = "", onExpanded: j, onCollapsed: M, onStarted: N, onClose: P, onError: F, onPrefetchReady: te, onFeedback: I, onFeedbackFailed: L } = e,
|
|
4021
|
+
function Tr(e) {
|
|
4022
|
+
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, R = m === "bottom-right" || m === "bottom-left";
|
|
3930
4023
|
return n(() => {
|
|
3931
4024
|
let e = t.current;
|
|
3932
4025
|
if (!e || !r.trim()) return;
|
|
3933
|
-
let n =
|
|
4026
|
+
let n = wr(e, {
|
|
3934
4027
|
experienceId: r,
|
|
3935
4028
|
alt: i,
|
|
3936
4029
|
galleryThumb: a,
|
|
@@ -4005,7 +4098,7 @@ function hr(e) {
|
|
|
4005
4098
|
]), /* @__PURE__ */ d("div", {
|
|
4006
4099
|
ref: t,
|
|
4007
4100
|
className: ee,
|
|
4008
|
-
style:
|
|
4101
|
+
style: R ? { display: "contents" } : {
|
|
4009
4102
|
width: "100%",
|
|
4010
4103
|
height: "100%",
|
|
4011
4104
|
minHeight: "inherit"
|
|
@@ -4013,6 +4106,6 @@ function hr(e) {
|
|
|
4013
4106
|
});
|
|
4014
4107
|
}
|
|
4015
4108
|
//#endregion
|
|
4016
|
-
export {
|
|
4109
|
+
export { R as Experience, Ze as ExperienceThumbnail, Tr as ExperienceWidget };
|
|
4017
4110
|
|
|
4018
4111
|
//# sourceMappingURL=index.js.map
|