@liforma/client 0.4.2 → 0.4.3
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 +6 -0
- package/dist/next/index.js +681 -573
- package/dist/next/index.js.map +1 -1
- package/dist/next/react/ExperienceThumbnail.d.ts +1 -1
- package/dist/next/react/ExperienceThumbnail.d.ts.map +1 -1
- package/dist/next/react/ExperienceWidget.d.ts +4 -0
- package/dist/next/react/ExperienceWidget.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/styles.d.ts.map +1 -1
- package/dist/next/thumbnail/types.d.ts +3 -2
- package/dist/next/thumbnail/types.d.ts.map +1 -1
- package/dist/next/v2/embed/iframeHost.d.ts +27 -1
- package/dist/next/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/next/v2/embed/protocol.d.ts +61 -1
- package/dist/next/v2/embed/protocol.d.ts.map +1 -1
- package/dist/next/v2/experience.d.ts +16 -2
- package/dist/next/v2/experience.d.ts.map +1 -1
- package/dist/next/v2/experienceEvents.d.ts +25 -0
- package/dist/next/v2/experienceEvents.d.ts.map +1 -1
- package/dist/next/v2/shims/embedBaseUrl.d.ts +1 -1
- package/dist/next/v2/shims/embedBaseUrl.d.ts.map +1 -1
- package/dist/next/v2/types/sessionInteraction.d.ts +3 -1
- package/dist/next/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/next/widget/mountExperienceWidget.d.ts.map +1 -1
- package/dist/next/widget/types.d.ts +7 -0
- package/dist/next/widget/types.d.ts.map +1 -1
- package/dist/npm/index.js +542 -440
- 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/styles.d.ts.map +1 -1
- package/dist/npm/thumbnail/types.d.ts +3 -2
- package/dist/npm/thumbnail/types.d.ts.map +1 -1
- package/dist/npm/v2/embed/iframeHost.d.ts +27 -1
- package/dist/npm/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/npm/v2/embed/protocol.d.ts +61 -1
- package/dist/npm/v2/embed/protocol.d.ts.map +1 -1
- package/dist/npm/v2/experience.d.ts +16 -2
- package/dist/npm/v2/experience.d.ts.map +1 -1
- package/dist/npm/v2/experienceEvents.d.ts +25 -0
- package/dist/npm/v2/experienceEvents.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/liforma-experience.d.ts.map +1 -1
- package/dist/npm/v2/npm.d.ts +2 -1
- package/dist/npm/v2/npm.d.ts.map +1 -1
- package/dist/npm/v2/shims/embedBaseUrl.d.ts +1 -1
- package/dist/npm/v2/shims/embedBaseUrl.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionInteraction.d.ts +3 -1
- package/dist/npm/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionManifestSchema.d.ts +1 -1
- package/dist/npm/v2/types/sessionManifestSchema.d.ts.map +1 -1
- package/dist/npm/widget/mountExperienceWidget.d.ts.map +1 -1
- package/dist/npm/widget/types.d.ts +7 -0
- package/dist/npm/widget/types.d.ts.map +1 -1
- package/dist/react/component/experienceComponentLaunch.d.ts.map +1 -1
- package/dist/react/component/experienceComponentRuntime.d.ts +4 -0
- package/dist/react/component/experienceComponentRuntime.d.ts.map +1 -1
- package/dist/react/component/experienceComponentTypes.d.ts +17 -1
- package/dist/react/component/experienceComponentTypes.d.ts.map +1 -1
- package/dist/react/index.js +761 -636
- 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 +1 -1
- package/dist/react/react/ExperienceThumbnail.d.ts.map +1 -1
- package/dist/react/react/ExperienceWidget.d.ts +4 -0
- package/dist/react/react/ExperienceWidget.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/styles.d.ts.map +1 -1
- package/dist/react/thumbnail/types.d.ts +3 -2
- package/dist/react/thumbnail/types.d.ts.map +1 -1
- package/dist/react/v2/embed/iframeHost.d.ts +27 -1
- package/dist/react/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/react/v2/embed/protocol.d.ts +61 -1
- package/dist/react/v2/embed/protocol.d.ts.map +1 -1
- package/dist/react/v2/experience.d.ts +16 -2
- package/dist/react/v2/experience.d.ts.map +1 -1
- package/dist/react/v2/experienceEvents.d.ts +25 -0
- package/dist/react/v2/experienceEvents.d.ts.map +1 -1
- package/dist/react/v2/shims/embedBaseUrl.d.ts +1 -1
- package/dist/react/v2/shims/embedBaseUrl.d.ts.map +1 -1
- package/dist/react/v2/types/sessionInteraction.d.ts +3 -1
- package/dist/react/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/react/widget/mountExperienceWidget.d.ts.map +1 -1
- package/dist/react/widget/types.d.ts +7 -0
- package/dist/react/widget/types.d.ts.map +1 -1
- package/dist/sdk/v2/client.js +30 -5
- package/dist/sdk/v2/client.js.map +1 -1
- package/dist/svelte/Experience.svelte +29 -0
- package/dist/svelte/Experience.svelte.d.ts +2 -0
- package/dist/svelte/ExperienceThumbnail.svelte +3 -2
- package/dist/svelte/ExperienceThumbnail.svelte.d.ts +1 -1
- package/dist/svelte/ExperienceWidget.svelte +12 -1
- package/dist/svelte/ExperienceWidget.svelte.d.ts +3 -0
- package/package.json +14 -2
package/dist/react/index.js
CHANGED
|
@@ -39,6 +39,7 @@ function _(e) {
|
|
|
39
39
|
language: e.language,
|
|
40
40
|
locationId: e.locationId,
|
|
41
41
|
avatarId: e.avatarId,
|
|
42
|
+
castSize: e.castSize,
|
|
42
43
|
embedBaseUrl: e.embedBaseUrl,
|
|
43
44
|
debug: e.debug,
|
|
44
45
|
mode: e.mode,
|
|
@@ -54,6 +55,7 @@ function _(e) {
|
|
|
54
55
|
language: e.language,
|
|
55
56
|
locationId: e.locationId,
|
|
56
57
|
avatarId: e.avatarId,
|
|
58
|
+
castSize: e.castSize,
|
|
57
59
|
embedBaseUrl: e.embedBaseUrl,
|
|
58
60
|
debug: e.debug,
|
|
59
61
|
mode: e.mode,
|
|
@@ -77,6 +79,7 @@ function v(e) {
|
|
|
77
79
|
e.speechOnly,
|
|
78
80
|
e.avatarId,
|
|
79
81
|
e.locationId,
|
|
82
|
+
e.castSize,
|
|
80
83
|
e.embedBaseUrl,
|
|
81
84
|
e.debug
|
|
82
85
|
]);
|
|
@@ -162,7 +165,7 @@ function j(e, t, n) {
|
|
|
162
165
|
e.destroyed || (e.ready.resolve(t), n().onReady?.(t));
|
|
163
166
|
}), A(e, t, "started", (t) => {
|
|
164
167
|
e.destroyed || (e.started.resolve(t), n().onStarted?.(t));
|
|
165
|
-
}), A(e, t, "userTranscript", (e) => n().onUserTranscript?.(e)), A(e, t, "userSpeechStarted", (e) => n().onUserSpeechStarted?.(e)), A(e, t, "userSpeechEnded", (e) => n().onUserSpeechEnded?.(e)), A(e, t, "characterSpeechStarted", (e) => n().onCharacterSpeechStarted?.(e)), A(e, t, "characterSpeechEnded", (e) => n().onCharacterSpeechEnded?.(e)), A(e, t, "conversationUpdate", (e) => n().onConversationUpdate?.(e)), A(e, t, "message", (e) => n().onMessage?.(e)), A(e, t, "listeningState", (e) => n().onListeningState?.(e)), A(e, t, "activityChange", (e) => n().onActivityChange?.(e)), A(e, t, "conversationProcessorError", (e) => n().onConversationProcessorError?.(e));
|
|
168
|
+
}), A(e, t, "userTranscript", (e) => n().onUserTranscript?.(e)), A(e, t, "userSpeechStarted", (e) => n().onUserSpeechStarted?.(e)), A(e, t, "userSpeechEnded", (e) => n().onUserSpeechEnded?.(e)), A(e, t, "characterSpeechStarted", (e) => n().onCharacterSpeechStarted?.(e)), A(e, t, "characterSpeechEnded", (e) => n().onCharacterSpeechEnded?.(e)), A(e, t, "characterFocusChanged", (e) => n().onCharacterFocusChanged?.(e)), A(e, t, "conversationUpdate", (e) => n().onConversationUpdate?.(e)), A(e, t, "message", (e) => n().onMessage?.(e)), A(e, t, "listeningState", (e) => n().onListeningState?.(e)), A(e, t, "activityChange", (e) => n().onActivityChange?.(e)), A(e, t, "feedback", (e) => n().onFeedback?.(e)), A(e, t, "feedbackFailed", (e) => n().onFeedbackFailed?.(e)), A(e, t, "conversationProcessorError", (e) => n().onConversationProcessorError?.(e));
|
|
166
169
|
}
|
|
167
170
|
function M(e = () => ({}), t = () => ({})) {
|
|
168
171
|
let n = 0, r = null;
|
|
@@ -222,6 +225,7 @@ function M(e = () => ({}), t = () => ({})) {
|
|
|
222
225
|
container: n,
|
|
223
226
|
fit: d.fit,
|
|
224
227
|
startButton: d.startButton,
|
|
228
|
+
showFeedback: d.showFeedback,
|
|
225
229
|
closeButton: d.closeButton,
|
|
226
230
|
returnUrl: f,
|
|
227
231
|
showClose: !!(o().onClose || f || d.closeButton === !0 || d.closeButton && typeof d.closeButton == "object" && d.closeButton.visible !== !1),
|
|
@@ -313,87 +317,97 @@ function te(e, t) {
|
|
|
313
317
|
}
|
|
314
318
|
//#endregion
|
|
315
319
|
//#region src/react/Experience.tsx
|
|
316
|
-
var
|
|
317
|
-
let { returnUrl: c, fit: l, startButton: u,
|
|
320
|
+
var ne = e(function(e, a) {
|
|
321
|
+
let { returnUrl: c, fit: l, startButton: u, showFeedback: p, closeButton: m, onReady: h, onStarted: g, onUserTranscript: y, onUserSpeechStarted: b, onUserSpeechEnded: x, onCharacterSpeechStarted: S, onCharacterSpeechEnded: ee, onCharacterFocusChanged: C, onConversationUpdate: w, onMessage: T, onListeningState: O, onActivityChange: k, onFeedback: A, onFeedbackFailed: j, onConversationProcessorError: N, onPlayerStatusChange: P, onStateUpdate: F, onClose: ne, onError: re } = e, I = o({}), ie = o({
|
|
318
322
|
fit: l,
|
|
319
323
|
startButton: u,
|
|
320
|
-
|
|
324
|
+
showFeedback: p,
|
|
325
|
+
closeButton: m,
|
|
321
326
|
returnUrl: c
|
|
322
|
-
}),
|
|
323
|
-
|
|
327
|
+
}), L = o(M(() => I.current, () => ie.current)), R = o(null), [z, B] = s(!1), [V, ae] = s(null), oe = o(null), se = o(null), ce = v(e);
|
|
328
|
+
ie.current = {
|
|
324
329
|
fit: l,
|
|
325
330
|
startButton: u,
|
|
326
|
-
|
|
331
|
+
showFeedback: p,
|
|
332
|
+
closeButton: m,
|
|
327
333
|
returnUrl: c
|
|
328
|
-
},
|
|
329
|
-
onReady:
|
|
330
|
-
onStarted:
|
|
331
|
-
onUserTranscript:
|
|
332
|
-
onUserSpeechStarted:
|
|
333
|
-
onUserSpeechEnded:
|
|
334
|
-
onCharacterSpeechStarted:
|
|
335
|
-
onCharacterSpeechEnded:
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
334
|
+
}, I.current = {
|
|
335
|
+
onReady: h,
|
|
336
|
+
onStarted: g,
|
|
337
|
+
onUserTranscript: y,
|
|
338
|
+
onUserSpeechStarted: b,
|
|
339
|
+
onUserSpeechEnded: x,
|
|
340
|
+
onCharacterSpeechStarted: S,
|
|
341
|
+
onCharacterSpeechEnded: ee,
|
|
342
|
+
onCharacterFocusChanged: C,
|
|
343
|
+
onConversationUpdate: w,
|
|
344
|
+
onMessage: T,
|
|
345
|
+
onListeningState: O,
|
|
346
|
+
onActivityChange: k,
|
|
347
|
+
onFeedback: A,
|
|
348
|
+
onFeedbackFailed: j,
|
|
349
|
+
onConversationProcessorError: N,
|
|
350
|
+
onPlayerStatusChange: P,
|
|
351
|
+
onStateUpdate: F,
|
|
352
|
+
onClose: ne,
|
|
353
|
+
onError: re
|
|
345
354
|
};
|
|
346
|
-
let
|
|
347
|
-
|
|
355
|
+
let H = t((e) => {
|
|
356
|
+
oe.current = e, B(e !== null);
|
|
348
357
|
}, []);
|
|
349
358
|
return r(a, () => ({
|
|
350
359
|
ready: () => {
|
|
351
|
-
let e =
|
|
360
|
+
let e = R.current;
|
|
352
361
|
return !e || e.destroyed ? Promise.reject(E()) : e.ready.promise;
|
|
353
362
|
},
|
|
354
363
|
started: () => {
|
|
355
|
-
let e =
|
|
364
|
+
let e = R.current;
|
|
356
365
|
return !e || e.destroyed ? Promise.reject(E()) : e.started.promise;
|
|
357
366
|
},
|
|
358
367
|
speech: {
|
|
359
|
-
speak: (e) =>
|
|
360
|
-
play: (e) =>
|
|
368
|
+
speak: (e) => L.current.withSession((t) => t.speech.speak(e)),
|
|
369
|
+
play: (e) => L.current.withSession((t) => t.speech.play(e)),
|
|
361
370
|
createUtterance: (e) => {
|
|
362
|
-
let t =
|
|
371
|
+
let t = L.current.getActiveInstance();
|
|
363
372
|
if (!t) throw Error("Session has not started. Wait for the player start button and the started event before using speech APIs.");
|
|
364
373
|
return t.speech.createUtterance(e);
|
|
365
374
|
},
|
|
366
|
-
interrupt: (e) =>
|
|
375
|
+
interrupt: (e) => L.current.withSession((t) => t.speech.interrupt(e))
|
|
367
376
|
},
|
|
368
|
-
startListening: () =>
|
|
369
|
-
stopListening: () =>
|
|
370
|
-
listenOnce: (e) =>
|
|
371
|
-
getSession: () =>
|
|
372
|
-
getManifest: () =>
|
|
373
|
-
getConversation: () =>
|
|
374
|
-
|
|
377
|
+
startListening: () => L.current.withSession((e) => e.startListening()),
|
|
378
|
+
stopListening: () => L.current.withSession((e) => e.stopListening()),
|
|
379
|
+
listenOnce: (e) => L.current.withSession((t) => t.listenOnce(e)),
|
|
380
|
+
getSession: () => L.current.getActiveInstance()?.getSession() ?? null,
|
|
381
|
+
getManifest: () => L.current.getActiveInstance()?.getManifest() ?? null,
|
|
382
|
+
getConversation: () => L.current.getActiveInstance()?.getConversation() ?? [],
|
|
383
|
+
focusCharacter: (e) => L.current.withSession((t) => t.focusCharacter(e)),
|
|
384
|
+
setFit: (e) => L.current.withSession((t) => t.setFit(e)),
|
|
385
|
+
end: () => L.current.withSession((e) => e.end())
|
|
375
386
|
}), []), i(() => {
|
|
376
|
-
if (!
|
|
377
|
-
let t =
|
|
387
|
+
if (!z || !oe.current) return;
|
|
388
|
+
let t = oe.current, n = L.current, r;
|
|
378
389
|
try {
|
|
379
390
|
r = { options: _(e) };
|
|
380
391
|
} catch (e) {
|
|
381
392
|
r = { error: D(e) };
|
|
382
393
|
}
|
|
383
|
-
let i = n.activateGeneration(t, r, c,
|
|
384
|
-
return
|
|
385
|
-
n.cancelGeneration(i),
|
|
394
|
+
let i = n.activateGeneration(t, r, c, ae);
|
|
395
|
+
return R.current = i, () => {
|
|
396
|
+
n.cancelGeneration(i), R.current === i && (R.current = null);
|
|
386
397
|
};
|
|
387
398
|
}, [
|
|
388
|
-
|
|
389
|
-
|
|
399
|
+
z,
|
|
400
|
+
ce,
|
|
390
401
|
c
|
|
391
402
|
]), n(() => {
|
|
392
|
-
let e =
|
|
393
|
-
|
|
394
|
-
|
|
403
|
+
let e = L.current.getActiveInstance();
|
|
404
|
+
e && e.setFit(l ?? "full");
|
|
405
|
+
}, [l]), n(() => {
|
|
406
|
+
let e = se.current;
|
|
407
|
+
if (!e || (e.replaceChildren(), !V)) return;
|
|
408
|
+
let t = te(e, V);
|
|
395
409
|
return () => t.remove();
|
|
396
|
-
}, [
|
|
410
|
+
}, [V]), /* @__PURE__ */ f("div", {
|
|
397
411
|
className: "liforma-experience-shell",
|
|
398
412
|
style: {
|
|
399
413
|
position: "relative",
|
|
@@ -402,17 +416,17 @@ var I = e(function(e, a) {
|
|
|
402
416
|
minHeight: "inherit"
|
|
403
417
|
},
|
|
404
418
|
children: [/* @__PURE__ */ d("div", {
|
|
405
|
-
ref:
|
|
419
|
+
ref: se,
|
|
406
420
|
className: "liforma-experience-error-host",
|
|
407
|
-
"aria-hidden":
|
|
421
|
+
"aria-hidden": V ? void 0 : !0,
|
|
408
422
|
style: {
|
|
409
423
|
position: "absolute",
|
|
410
424
|
inset: 0,
|
|
411
425
|
zIndex: 20,
|
|
412
|
-
pointerEvents:
|
|
426
|
+
pointerEvents: V ? "auto" : "none"
|
|
413
427
|
}
|
|
414
428
|
}), /* @__PURE__ */ d("div", {
|
|
415
|
-
ref:
|
|
429
|
+
ref: H,
|
|
416
430
|
className: "liforma-experience-host",
|
|
417
431
|
style: {
|
|
418
432
|
position: "absolute",
|
|
@@ -421,27 +435,35 @@ var I = e(function(e, a) {
|
|
|
421
435
|
}
|
|
422
436
|
})]
|
|
423
437
|
});
|
|
424
|
-
})
|
|
425
|
-
|
|
438
|
+
});
|
|
439
|
+
//#endregion
|
|
440
|
+
//#region src/thumbnail/types.ts
|
|
441
|
+
function re(e) {
|
|
442
|
+
return e === "face" ? "liforma-et--fit-face" : e === "medium" ? "liforma-et--fit-medium" : "";
|
|
443
|
+
}
|
|
444
|
+
//#endregion
|
|
445
|
+
//#region src/thumbnail/toGalleryThumbUrl.ts
|
|
446
|
+
var I = /(\/avatars\/[^/]+\/)(\d+)(\/)/i, ie = /_CH(\.webp)/i, L = /(-)(\d+x\d+)(\.webp)(\?|$)/i;
|
|
447
|
+
function R(e) {
|
|
426
448
|
let t = e.trim();
|
|
427
449
|
if (!t) return t;
|
|
428
|
-
let n = t.replace(
|
|
429
|
-
return n = n.replace(
|
|
450
|
+
let n = t.replace(I, (e, t, n, r) => n === "256" ? `${t}${n}${r}` : `${t}256${r}`);
|
|
451
|
+
return n = n.replace(ie, "_neutral$1"), n = n.replace(L, (e, t, n, r, i) => n === "256x256" ? `${t}${n}${r}${i}` : `${t}256x256${r}${i}`), n;
|
|
430
452
|
}
|
|
431
|
-
function
|
|
453
|
+
function z(e) {
|
|
432
454
|
let t = e.avatarImage?.trim() || e.galleryThumb?.avatarImage?.trim() || "";
|
|
433
455
|
if (!t) return null;
|
|
434
456
|
let n = e.backgroundImage?.trim() || e.galleryThumb?.backgroundImage?.trim() || "", r = e.foregroundImage?.trim() || e.galleryThumb?.foregroundImage?.trim() || "", i = e.fallbackImage?.trim() || "";
|
|
435
457
|
return {
|
|
436
|
-
avatarImage:
|
|
437
|
-
...n ? { backgroundImage:
|
|
438
|
-
...r ? { foregroundImage:
|
|
439
|
-
...i ? { fallbackImage:
|
|
458
|
+
avatarImage: R(t),
|
|
459
|
+
...n ? { backgroundImage: R(n) } : {},
|
|
460
|
+
...r ? { foregroundImage: R(r) } : {},
|
|
461
|
+
...i ? { fallbackImage: R(i) } : {}
|
|
440
462
|
};
|
|
441
463
|
}
|
|
442
464
|
//#endregion
|
|
443
465
|
//#region src/shims/localStack.ts
|
|
444
|
-
function
|
|
466
|
+
function B() {
|
|
445
467
|
if (globalThis.__LIFORMA_STACK === "local") return !0;
|
|
446
468
|
if (typeof location > "u") return !1;
|
|
447
469
|
try {
|
|
@@ -452,83 +474,83 @@ function V() {
|
|
|
452
474
|
}
|
|
453
475
|
//#endregion
|
|
454
476
|
//#region src/thumbnail/hostedLaunchUrl.ts
|
|
455
|
-
var
|
|
456
|
-
function
|
|
477
|
+
var V = "https://player.liforma.ai", ae = "http://localhost:3002";
|
|
478
|
+
function oe(e) {
|
|
457
479
|
return e.href?.trim() ? "anchor" : e.hasClickHandler ? "button" : e.experienceId?.trim() ? "anchor" : "presentational";
|
|
458
480
|
}
|
|
459
|
-
function
|
|
481
|
+
function se(e) {
|
|
460
482
|
let t = e?.trim();
|
|
461
|
-
return t ? t.replace(/\/$/, "") :
|
|
483
|
+
return t ? t.replace(/\/$/, "") : B() ? ae : V;
|
|
462
484
|
}
|
|
463
|
-
function
|
|
464
|
-
let t = e.experienceId.trim(), n =
|
|
485
|
+
function ce(e) {
|
|
486
|
+
let t = e.experienceId.trim(), n = se(e.playerBaseUrl), r = new URL(`${n}/${encodeURIComponent(t)}`), i = e.returnUrl?.trim();
|
|
465
487
|
return i && r.searchParams.set("returnUrl", i), r.toString();
|
|
466
488
|
}
|
|
467
|
-
function
|
|
489
|
+
function H(e) {
|
|
468
490
|
let t = e.href?.trim();
|
|
469
491
|
if (t) return t;
|
|
470
492
|
let n = e.experienceId?.trim();
|
|
471
493
|
if (!n) return;
|
|
472
494
|
let r = e.returnUrl?.trim();
|
|
473
|
-
return !r && e.useCurrentPageAsReturnUrl && typeof window < "u" && (r = window.location.href),
|
|
495
|
+
return !r && e.useCurrentPageAsReturnUrl && typeof window < "u" && (r = window.location.href), ce({
|
|
474
496
|
experienceId: n,
|
|
475
497
|
...r ? { returnUrl: r } : {},
|
|
476
498
|
playerBaseUrl: e.playerBaseUrl
|
|
477
499
|
});
|
|
478
500
|
}
|
|
479
|
-
function
|
|
501
|
+
function le() {
|
|
480
502
|
return typeof window > "u" ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
|
|
481
503
|
}
|
|
482
|
-
var
|
|
483
|
-
function
|
|
484
|
-
return
|
|
504
|
+
var U = 0, ue = [];
|
|
505
|
+
function de() {
|
|
506
|
+
return le() ? 4 : Infinity;
|
|
485
507
|
}
|
|
486
|
-
function
|
|
487
|
-
return
|
|
508
|
+
function W() {
|
|
509
|
+
return le() ? 160 : 0;
|
|
488
510
|
}
|
|
489
|
-
function
|
|
490
|
-
let e =
|
|
491
|
-
for (;
|
|
492
|
-
let e =
|
|
511
|
+
function fe() {
|
|
512
|
+
let e = de();
|
|
513
|
+
for (; U < e && ue.length > 0;) {
|
|
514
|
+
let e = ue.shift();
|
|
493
515
|
if (!e || e.cancelled) continue;
|
|
494
|
-
|
|
495
|
-
let t =
|
|
516
|
+
U += 1, e.start();
|
|
517
|
+
let t = W();
|
|
496
518
|
if (t <= 0) {
|
|
497
|
-
|
|
519
|
+
U = Math.max(0, U - 1);
|
|
498
520
|
continue;
|
|
499
521
|
}
|
|
500
522
|
window.setTimeout(() => {
|
|
501
|
-
|
|
523
|
+
U = Math.max(0, U - 1), fe();
|
|
502
524
|
}, t);
|
|
503
525
|
}
|
|
504
526
|
}
|
|
505
|
-
function
|
|
506
|
-
if (!
|
|
527
|
+
function pe(e) {
|
|
528
|
+
if (!le()) return e(), () => {};
|
|
507
529
|
let t = {
|
|
508
530
|
start: e,
|
|
509
531
|
cancelled: !1
|
|
510
532
|
};
|
|
511
|
-
return
|
|
533
|
+
return ue.push(t), fe(), () => {
|
|
512
534
|
t.cancelled = !0;
|
|
513
535
|
};
|
|
514
536
|
}
|
|
515
537
|
//#endregion
|
|
516
538
|
//#region src/thumbnail/lazyLoad.ts
|
|
517
|
-
function
|
|
518
|
-
return
|
|
539
|
+
function me() {
|
|
540
|
+
return le() ? "96px 0px" : "280px 0px";
|
|
519
541
|
}
|
|
520
|
-
function
|
|
542
|
+
function he(e) {
|
|
521
543
|
let t = e.trim().split(/\s+/)[0] ?? "0px", n = Number.parseFloat(t);
|
|
522
544
|
return Number.isFinite(n) ? Math.abs(n) : 280;
|
|
523
545
|
}
|
|
524
|
-
function
|
|
546
|
+
function ge(e, t) {
|
|
525
547
|
if (typeof window > "u") return !1;
|
|
526
548
|
let n = e.getBoundingClientRect();
|
|
527
549
|
return n.bottom >= -t && n.top <= window.innerHeight + t;
|
|
528
550
|
}
|
|
529
|
-
function
|
|
530
|
-
let { onVisibleChange: n } = t, r = t.rootMargin ??
|
|
531
|
-
o || (s?.(), s =
|
|
551
|
+
function _e(e, t) {
|
|
552
|
+
let { onVisibleChange: n } = t, r = t.rootMargin ?? me(), i = he(r), a = !1, o = !1, s = null, c = () => {
|
|
553
|
+
o || (s?.(), s = pe(() => {
|
|
532
554
|
s = null, o = !0, n(!0);
|
|
533
555
|
}));
|
|
534
556
|
}, l = (e) => {
|
|
@@ -550,55 +572,55 @@ function he(e, t) {
|
|
|
550
572
|
rootMargin: r,
|
|
551
573
|
threshold: 0
|
|
552
574
|
});
|
|
553
|
-
return u.observe(e),
|
|
575
|
+
return u.observe(e), ge(e, i) && l(!0), () => {
|
|
554
576
|
s?.(), s = null, u.disconnect();
|
|
555
577
|
};
|
|
556
578
|
}
|
|
557
579
|
//#endregion
|
|
558
580
|
//#region src/thumbnail/scrollParallax.ts
|
|
559
|
-
function
|
|
581
|
+
function ve() {
|
|
560
582
|
return typeof window > "u" || window.matchMedia("(prefers-reduced-motion: reduce)").matches ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
|
|
561
583
|
}
|
|
562
|
-
function
|
|
584
|
+
function ye(e, t) {
|
|
563
585
|
return ((e.top + e.height / 2) / Math.max(t, 1) - .5) * 2;
|
|
564
586
|
}
|
|
565
|
-
var
|
|
566
|
-
function
|
|
567
|
-
if (
|
|
587
|
+
var G = /* @__PURE__ */ new Set(), be = !1, K = 0;
|
|
588
|
+
function xe() {
|
|
589
|
+
if (K = 0, G.size === 0 || typeof window > "u") return;
|
|
568
590
|
let e = window.innerHeight;
|
|
569
|
-
for (let t of
|
|
591
|
+
for (let t of G) {
|
|
570
592
|
if (t.pointerActive?.()) continue;
|
|
571
593
|
let n = t.element.getBoundingClientRect();
|
|
572
|
-
n.bottom < -64 || n.top > e + 64 || t.onParallax(
|
|
594
|
+
n.bottom < -64 || n.top > e + 64 || t.onParallax(ye(n, e));
|
|
573
595
|
}
|
|
574
596
|
}
|
|
575
|
-
function
|
|
576
|
-
|
|
597
|
+
function Se() {
|
|
598
|
+
K === 0 && (K = requestAnimationFrame(xe));
|
|
577
599
|
}
|
|
578
|
-
function
|
|
579
|
-
|
|
600
|
+
function q() {
|
|
601
|
+
be || typeof window > "u" || (be = !0, window.addEventListener("scroll", Se, { passive: !0 }), window.addEventListener("resize", Se, { passive: !0 }));
|
|
580
602
|
}
|
|
581
|
-
function
|
|
582
|
-
|
|
603
|
+
function Ce() {
|
|
604
|
+
G.size > 0 || !be || typeof window > "u" || (be = !1, K !== 0 && (cancelAnimationFrame(K), K = 0), window.removeEventListener("scroll", Se), window.removeEventListener("resize", Se));
|
|
583
605
|
}
|
|
584
|
-
function
|
|
585
|
-
if (!
|
|
606
|
+
function we(e, t) {
|
|
607
|
+
if (!ve()) return () => {};
|
|
586
608
|
let n = {
|
|
587
609
|
element: e,
|
|
588
610
|
onParallax: t.onParallax,
|
|
589
611
|
pointerActive: t.pointerActive
|
|
590
612
|
};
|
|
591
|
-
return
|
|
592
|
-
|
|
613
|
+
return G.add(n), q(), n.pointerActive?.() || t.onParallax(ye(e.getBoundingClientRect(), window.innerHeight)), () => {
|
|
614
|
+
G.delete(n), Ce();
|
|
593
615
|
};
|
|
594
616
|
}
|
|
595
617
|
//#endregion
|
|
596
618
|
//#region src/thumbnail/attachThumbnailParallax.ts
|
|
597
|
-
function
|
|
619
|
+
function Te(e) {
|
|
598
620
|
let t = 0, n = 0, r = !1, i = !1, a = !1, o = () => {
|
|
599
621
|
let a = r || i;
|
|
600
622
|
e.classList.toggle("liforma-et--parallax", a), e.classList.toggle("liforma-et--scroll-parallax", i), e.style.setProperty("--liforma-et-parallax-x", String(t)), e.style.setProperty("--liforma-et-parallax-y", String(n));
|
|
601
|
-
}, s =
|
|
623
|
+
}, s = we(e, {
|
|
602
624
|
onParallax: (e) => {
|
|
603
625
|
i = !0, a || (t = e, n = 0, o());
|
|
604
626
|
},
|
|
@@ -611,7 +633,7 @@ function Ce(e) {
|
|
|
611
633
|
a = !0, e.pointerType === "mouse" && (r = !0), o();
|
|
612
634
|
}, u = () => {
|
|
613
635
|
let s = a;
|
|
614
|
-
a = !1, r = !1, i && s ? (t =
|
|
636
|
+
a = !1, r = !1, i && s ? (t = ye(e.getBoundingClientRect(), window.innerHeight), n = 0) : i || (t = 0, n = 0), o();
|
|
615
637
|
}, d = (e) => {
|
|
616
638
|
e.pointerType === "mouse" && (r = !0, o());
|
|
617
639
|
}, f = () => {
|
|
@@ -623,23 +645,23 @@ function Ce(e) {
|
|
|
623
645
|
}
|
|
624
646
|
//#endregion
|
|
625
647
|
//#region src/thumbnail/styles.ts
|
|
626
|
-
var
|
|
627
|
-
function
|
|
628
|
-
if (typeof document > "u" ||
|
|
648
|
+
var Ee = ".liforma-et {\n --liforma-et-parallax-x: 0;\n --liforma-et-parallax-y: 0;\n --liforma-et-bg-scale: 1;\n --liforma-et-fg-scale: 1;\n --liforma-et-avatar-scale: 1;\n --liforma-et-bg-shift: 0px;\n --liforma-et-fg-shift: 0px;\n --liforma-et-avatar-shift: 0px;\n --liforma-et-reveal-duration: 420ms;\n\n box-sizing: border-box;\n position: relative;\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: 0.65rem;\n overflow: hidden;\n background: #111;\n color: inherit;\n text-decoration: none;\n cursor: inherit;\n -webkit-tap-highlight-color: transparent;\n}\n\na.liforma-et,\nbutton.liforma-et {\n cursor: pointer;\n}\n\nbutton.liforma-et {\n font: inherit;\n appearance: none;\n}\n\n.liforma-et__placeholder {\n position: absolute;\n inset: 0;\n z-index: 0;\n background:\n radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.06), transparent 58%),\n linear-gradient(180deg, #1a1a1a 0%, #101010 100%);\n opacity: 1;\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n.liforma-et--revealed .liforma-et__placeholder {\n opacity: 0;\n}\n\n.liforma-et__media {\n opacity: 0;\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n.liforma-et__media--ready {\n opacity: 1;\n}\n\n.liforma-et__background {\n position: absolute;\n inset: 0;\n z-index: 1;\n width: 100%;\n height: 100%;\n object-fit: cover;\n object-position: center center;\n transform: translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-bg-shift)),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-bg-shift))\n )\n scale(var(--liforma-et-bg-scale));\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n.liforma-et__avatar {\n position: relative;\n z-index: 2;\n display: block;\n width: 100%;\n height: 100%;\n object-fit: contain;\n object-position: center bottom;\n transform: scale(var(--liforma-et-avatar-scale))\n translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-avatar-shift)),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-avatar-shift))\n );\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n/* Gallery plates are typically square in a square tile — contain vs cover is a no-op\n without a zoom. Scale the whole scene from the upper third so Face matches\n player fit (location + avatar crop together). */\n.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.85;\n --liforma-et-bg-scale: 1.85;\n --liforma-et-fg-scale: 1.85;\n}\n\n.liforma-et--fit-face .liforma-et__avatar,\n.liforma-et--fit-face .liforma-et__background,\n.liforma-et--fit-face .liforma-et__foreground {\n transform-origin: 50% 18%;\n}\n\n.liforma-et--fit-face .liforma-et__avatar {\n object-fit: cover;\n object-position: 50% 18%;\n}\n\n/* Bust / medium: less zoom than face so upper chest stays in frame (player 3.75H window). */\n.liforma-et--fit-medium {\n --liforma-et-avatar-scale: 1.35;\n --liforma-et-bg-scale: 1.35;\n --liforma-et-fg-scale: 1.35;\n}\n\n.liforma-et--fit-medium .liforma-et__avatar,\n.liforma-et--fit-medium .liforma-et__background,\n.liforma-et--fit-medium .liforma-et__foreground {\n transform-origin: 50% 28%;\n}\n\n.liforma-et--fit-medium .liforma-et__avatar {\n object-fit: cover;\n object-position: 50% 28%;\n}\n\n.liforma-et__foreground {\n position: absolute;\n inset: 0;\n z-index: 3;\n width: 100%;\n height: 100%;\n object-fit: cover;\n object-position: center center;\n pointer-events: none;\n transform: translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-fg-shift) * -1),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-fg-shift) * -1)\n )\n scale(var(--liforma-et-fg-scale));\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n.liforma-et--parallax {\n --liforma-et-bg-scale: 1.08;\n --liforma-et-fg-scale: 1.05;\n --liforma-et-avatar-scale: 1.08;\n --liforma-et-bg-shift: 10px;\n --liforma-et-fg-shift: 4px;\n --liforma-et-avatar-shift: 4px;\n}\n\n/* Promote layers only while parallax is active — avoids N compositor surfaces on galleries. */\n.liforma-et--parallax .liforma-et__background,\n.liforma-et--parallax .liforma-et__foreground,\n.liforma-et--parallax .liforma-et__avatar {\n will-change: transform;\n}\n\n.liforma-et--parallax.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.95;\n --liforma-et-bg-scale: 1.95;\n --liforma-et-fg-scale: 1.95;\n --liforma-et-avatar-shift: 0px;\n}\n\n.liforma-et--parallax.liforma-et--fit-medium {\n --liforma-et-avatar-scale: 1.42;\n --liforma-et-bg-scale: 1.42;\n --liforma-et-fg-scale: 1.42;\n --liforma-et-avatar-shift: 0px;\n}\n\n.liforma-et--scroll-parallax .liforma-et__background,\n.liforma-et--scroll-parallax .liforma-et__foreground,\n.liforma-et--scroll-parallax .liforma-et__avatar {\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .liforma-et {\n --liforma-et-reveal-duration: 0ms;\n }\n\n .liforma-et--parallax {\n --liforma-et-bg-scale: 1;\n --liforma-et-fg-scale: 1;\n --liforma-et-avatar-scale: 1;\n --liforma-et-bg-shift: 0px;\n --liforma-et-fg-shift: 0px;\n --liforma-et-avatar-shift: 0px;\n }\n\n .liforma-et--parallax.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.85;\n --liforma-et-bg-scale: 1.85;\n --liforma-et-fg-scale: 1.85;\n }\n\n .liforma-et__background,\n .liforma-et__foreground,\n .liforma-et__avatar {\n transition: none;\n }\n}", De = !1;
|
|
649
|
+
function Oe(e) {
|
|
650
|
+
if (typeof document > "u" || De) return;
|
|
629
651
|
if (document.querySelector("style[data-liforma-et]")) {
|
|
630
|
-
|
|
652
|
+
De = !0;
|
|
631
653
|
return;
|
|
632
654
|
}
|
|
633
655
|
let t = document.createElement("style");
|
|
634
|
-
t.setAttribute("data-liforma-et", ""), t.textContent = e, document.head.appendChild(t),
|
|
656
|
+
t.setAttribute("data-liforma-et", ""), t.textContent = e, document.head.appendChild(t), De = !0;
|
|
635
657
|
}
|
|
636
658
|
//#endregion
|
|
637
659
|
//#region src/react/ExperienceThumbnail.tsx
|
|
638
|
-
function
|
|
660
|
+
function ke(e, t) {
|
|
639
661
|
return `${e} liforma-et__media${t ? " liforma-et__media--ready" : ""}`;
|
|
640
662
|
}
|
|
641
|
-
function
|
|
642
|
-
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: ee = "", fallbackImage: C } = e, w = a(() =>
|
|
663
|
+
function Ae(e) {
|
|
664
|
+
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: ee = "", fallbackImage: C } = e, w = a(() => z({
|
|
643
665
|
galleryThumb: t,
|
|
644
666
|
avatarImage: r,
|
|
645
667
|
backgroundImage: i,
|
|
@@ -651,15 +673,15 @@ function Oe(e) {
|
|
|
651
673
|
i,
|
|
652
674
|
c,
|
|
653
675
|
C
|
|
654
|
-
]), T =
|
|
676
|
+
]), T = oe({
|
|
655
677
|
href: m,
|
|
656
678
|
hasClickHandler: typeof _ == "function",
|
|
657
679
|
experienceId: p
|
|
658
|
-
}), E = T === "anchor" && !m?.trim() && !!p?.trim(), D = !!w?.backgroundImage, O = b !== !1, k = o(null), A = o(!1), [j, M] = s(!S), [N, P] = s(!1), [F, te] = s(!1), [
|
|
680
|
+
}), E = T === "anchor" && !m?.trim() && !!p?.trim(), D = !!w?.backgroundImage, O = b !== !1, k = o(null), A = o(!1), [j, M] = s(!S), [N, P] = s(!1), [F, te] = s(!1), [ne, I] = s(0), [ie, L] = s(0), [R, B] = s(!1), [V, ae] = s(!1), [se, ce] = s(!1), [le, U] = s(!1), [ue, de] = s(), W = w ? R && w.fallbackImage ? w.fallbackImage : w.avatarImage : "";
|
|
659
681
|
n(() => {
|
|
660
|
-
Ee
|
|
682
|
+
Oe(Ee);
|
|
661
683
|
}, []), n(() => {
|
|
662
|
-
|
|
684
|
+
de(H({
|
|
663
685
|
href: m,
|
|
664
686
|
experienceId: p,
|
|
665
687
|
returnUrl: v,
|
|
@@ -673,11 +695,11 @@ function Oe(e) {
|
|
|
673
695
|
y,
|
|
674
696
|
E
|
|
675
697
|
]), n(() => {
|
|
676
|
-
|
|
698
|
+
ae(!1), ce(!1), U(!1), B(!1);
|
|
677
699
|
}, [
|
|
678
700
|
w?.backgroundImage,
|
|
679
701
|
w?.foregroundImage,
|
|
680
|
-
|
|
702
|
+
W
|
|
681
703
|
]), n(() => {
|
|
682
704
|
let e = k.current;
|
|
683
705
|
if (e) {
|
|
@@ -685,7 +707,7 @@ function Oe(e) {
|
|
|
685
707
|
M(!0);
|
|
686
708
|
return;
|
|
687
709
|
}
|
|
688
|
-
return
|
|
710
|
+
return _e(e, { onVisibleChange: (e) => {
|
|
689
711
|
e && M(!0);
|
|
690
712
|
} });
|
|
691
713
|
}
|
|
@@ -693,12 +715,12 @@ function Oe(e) {
|
|
|
693
715
|
S,
|
|
694
716
|
w,
|
|
695
717
|
T,
|
|
696
|
-
|
|
718
|
+
ue
|
|
697
719
|
]), n(() => {
|
|
698
720
|
let e = k.current;
|
|
699
|
-
if (!(!e || !O)) return
|
|
721
|
+
if (!(!e || !O)) return we(e, {
|
|
700
722
|
onParallax: (e) => {
|
|
701
|
-
te(!0), A.current || (
|
|
723
|
+
te(!0), A.current || (I(e), L(0));
|
|
702
724
|
},
|
|
703
725
|
pointerActive: () => A.current
|
|
704
726
|
});
|
|
@@ -706,25 +728,25 @@ function Oe(e) {
|
|
|
706
728
|
O,
|
|
707
729
|
w,
|
|
708
730
|
T,
|
|
709
|
-
|
|
731
|
+
ue
|
|
710
732
|
]);
|
|
711
|
-
let
|
|
733
|
+
let fe = (e) => {
|
|
712
734
|
if (!O || F) return;
|
|
713
735
|
let t = e.currentTarget.getBoundingClientRect();
|
|
714
|
-
t.width <= 0 || t.height <= 0 || (
|
|
715
|
-
},
|
|
736
|
+
t.width <= 0 || t.height <= 0 || (I(((e.clientX - t.left) / t.width - .5) * 2), L(((e.clientY - t.top) / t.height - .5) * 2));
|
|
737
|
+
}, pe = (e) => {
|
|
716
738
|
let t = A.current;
|
|
717
|
-
A.current = !1, P(!1), F && t ? (
|
|
718
|
-
},
|
|
739
|
+
A.current = !1, P(!1), F && t ? (I(ye(e.getBoundingClientRect(), window.innerHeight)), L(0)) : F || (I(0), L(0));
|
|
740
|
+
}, me = (e) => {
|
|
719
741
|
if (!O) return;
|
|
720
742
|
A.current = !0, e.pointerType === "mouse" && P(!0);
|
|
721
743
|
let t = e.currentTarget, n = () => {
|
|
722
|
-
|
|
744
|
+
pe(t), window.removeEventListener("pointerup", n), window.removeEventListener("pointercancel", n);
|
|
723
745
|
};
|
|
724
746
|
window.addEventListener("pointerup", n), window.addEventListener("pointercancel", n);
|
|
725
|
-
},
|
|
747
|
+
}, he = (e) => {
|
|
726
748
|
if (_?.(e), !e.defaultPrevented && E && !v?.trim()) {
|
|
727
|
-
let t =
|
|
749
|
+
let t = H({
|
|
728
750
|
experienceId: p,
|
|
729
751
|
playerBaseUrl: y,
|
|
730
752
|
useCurrentPageAsReturnUrl: !0
|
|
@@ -733,134 +755,134 @@ function Oe(e) {
|
|
|
733
755
|
}
|
|
734
756
|
};
|
|
735
757
|
if (!w) return null;
|
|
736
|
-
let
|
|
758
|
+
let ge = O && (N || F), ve = j && (se || V || le), G = [
|
|
737
759
|
"liforma-et",
|
|
738
760
|
D ? "liforma-et--scene" : "",
|
|
739
|
-
x
|
|
740
|
-
|
|
761
|
+
re(x),
|
|
762
|
+
ge ? "liforma-et--parallax" : "",
|
|
741
763
|
F ? "liforma-et--scroll-parallax" : "",
|
|
742
|
-
j && !
|
|
743
|
-
|
|
764
|
+
j && !ve ? "liforma-et--loading" : "",
|
|
765
|
+
ve ? "liforma-et--revealed" : "",
|
|
744
766
|
ee
|
|
745
|
-
].filter(Boolean).join(" "),
|
|
746
|
-
"--liforma-et-parallax-x":
|
|
747
|
-
"--liforma-et-parallax-y":
|
|
748
|
-
},
|
|
767
|
+
].filter(Boolean).join(" "), be = {
|
|
768
|
+
"--liforma-et-parallax-x": ne,
|
|
769
|
+
"--liforma-et-parallax-y": ie
|
|
770
|
+
}, K = (e, t) => {
|
|
749
771
|
e.complete && t(!0);
|
|
750
|
-
},
|
|
772
|
+
}, xe = /* @__PURE__ */ f(u, { children: [
|
|
751
773
|
/* @__PURE__ */ d("span", {
|
|
752
774
|
className: "liforma-et__placeholder",
|
|
753
775
|
"aria-hidden": "true"
|
|
754
776
|
}),
|
|
755
777
|
j && w.backgroundImage ? /* @__PURE__ */ d("img", {
|
|
756
|
-
className:
|
|
778
|
+
className: ke("liforma-et__background", V),
|
|
757
779
|
src: w.backgroundImage,
|
|
758
780
|
alt: "",
|
|
759
781
|
decoding: "async",
|
|
760
782
|
ref: (e) => {
|
|
761
|
-
e &&
|
|
783
|
+
e && K(e, ae);
|
|
762
784
|
},
|
|
763
|
-
onLoad: () =>
|
|
764
|
-
onError: () =>
|
|
785
|
+
onLoad: () => ae(!0),
|
|
786
|
+
onError: () => ae(!0)
|
|
765
787
|
}) : null,
|
|
766
|
-
j &&
|
|
767
|
-
className:
|
|
768
|
-
src:
|
|
788
|
+
j && W ? /* @__PURE__ */ d("img", {
|
|
789
|
+
className: ke("liforma-et__avatar", se),
|
|
790
|
+
src: W,
|
|
769
791
|
alt: "",
|
|
770
792
|
decoding: "async",
|
|
771
793
|
ref: (e) => {
|
|
772
|
-
e &&
|
|
794
|
+
e && K(e, ce);
|
|
773
795
|
},
|
|
774
|
-
onLoad: () =>
|
|
796
|
+
onLoad: () => ce(!0),
|
|
775
797
|
onError: () => {
|
|
776
|
-
w.fallbackImage ?
|
|
798
|
+
w.fallbackImage ? B(!0) : ce(!0);
|
|
777
799
|
}
|
|
778
800
|
}) : null,
|
|
779
801
|
j && w.foregroundImage ? /* @__PURE__ */ d("img", {
|
|
780
|
-
className:
|
|
802
|
+
className: ke("liforma-et__foreground", le),
|
|
781
803
|
src: w.foregroundImage,
|
|
782
804
|
alt: "",
|
|
783
805
|
decoding: "async",
|
|
784
806
|
ref: (e) => {
|
|
785
|
-
e &&
|
|
807
|
+
e && K(e, U);
|
|
786
808
|
},
|
|
787
|
-
onLoad: () =>
|
|
788
|
-
onError: () =>
|
|
809
|
+
onLoad: () => U(!0),
|
|
810
|
+
onError: () => U(!0)
|
|
789
811
|
}) : null
|
|
790
|
-
] }),
|
|
791
|
-
onPointerDown:
|
|
792
|
-
onPointerUp: (e) =>
|
|
793
|
-
onPointerCancel: (e) =>
|
|
812
|
+
] }), Se = {
|
|
813
|
+
onPointerDown: me,
|
|
814
|
+
onPointerUp: (e) => pe(e.currentTarget),
|
|
815
|
+
onPointerCancel: (e) => pe(e.currentTarget),
|
|
794
816
|
onPointerEnter: (e) => {
|
|
795
817
|
O && e.pointerType === "mouse" && P(!0);
|
|
796
818
|
},
|
|
797
|
-
onPointerMove:
|
|
819
|
+
onPointerMove: fe,
|
|
798
820
|
onPointerLeave: () => {
|
|
799
|
-
A.current || (P(!1), F || (
|
|
821
|
+
A.current || (P(!1), F || (I(0), L(0)));
|
|
800
822
|
}
|
|
801
|
-
},
|
|
823
|
+
}, q = (e) => {
|
|
802
824
|
k.current = e;
|
|
803
825
|
};
|
|
804
|
-
return T === "anchor" &&
|
|
805
|
-
ref:
|
|
806
|
-
className:
|
|
807
|
-
style:
|
|
808
|
-
href:
|
|
826
|
+
return T === "anchor" && ue ? /* @__PURE__ */ d("a", {
|
|
827
|
+
ref: q,
|
|
828
|
+
className: G,
|
|
829
|
+
style: be,
|
|
830
|
+
href: ue,
|
|
809
831
|
target: h,
|
|
810
832
|
rel: g,
|
|
811
833
|
"aria-label": l,
|
|
812
|
-
onClick:
|
|
813
|
-
...
|
|
814
|
-
children:
|
|
834
|
+
onClick: he,
|
|
835
|
+
...Se,
|
|
836
|
+
children: xe
|
|
815
837
|
}) : T === "button" ? /* @__PURE__ */ d("button", {
|
|
816
838
|
type: "button",
|
|
817
|
-
ref:
|
|
818
|
-
className:
|
|
819
|
-
style:
|
|
839
|
+
ref: q,
|
|
840
|
+
className: G,
|
|
841
|
+
style: be,
|
|
820
842
|
"aria-label": l,
|
|
821
|
-
onClick:
|
|
822
|
-
...
|
|
823
|
-
children:
|
|
843
|
+
onClick: he,
|
|
844
|
+
...Se,
|
|
845
|
+
children: xe
|
|
824
846
|
}) : /* @__PURE__ */ d("div", {
|
|
825
|
-
ref:
|
|
826
|
-
className:
|
|
827
|
-
style:
|
|
847
|
+
ref: q,
|
|
848
|
+
className: G,
|
|
849
|
+
style: be,
|
|
828
850
|
role: l ? "img" : void 0,
|
|
829
851
|
"aria-label": l || void 0,
|
|
830
852
|
"aria-hidden": l ? void 0 : !0,
|
|
831
|
-
...
|
|
832
|
-
children:
|
|
853
|
+
...Se,
|
|
854
|
+
children: xe
|
|
833
855
|
});
|
|
834
856
|
}
|
|
835
857
|
//#endregion
|
|
836
858
|
//#region src/widget/styles.ts
|
|
837
|
-
var ke = "\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", Ae = "liforma-experience-widget-styles";
|
|
838
|
-
function
|
|
859
|
+
var je = "\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", Me = "liforma-experience-widget-styles";
|
|
860
|
+
function Ne(e = je) {
|
|
839
861
|
if (typeof document > "u") return;
|
|
840
|
-
let t = document.getElementById(
|
|
862
|
+
let t = document.getElementById(Me);
|
|
841
863
|
if (t) {
|
|
842
864
|
t.textContent = e;
|
|
843
865
|
return;
|
|
844
866
|
}
|
|
845
867
|
let n = document.createElement("style");
|
|
846
|
-
n.id =
|
|
868
|
+
n.id = Me, n.textContent = e, document.head.append(n);
|
|
847
869
|
}
|
|
848
870
|
//#endregion
|
|
849
871
|
//#region src/shims/apiBaseUrl.ts
|
|
850
|
-
var
|
|
851
|
-
function
|
|
872
|
+
var Pe = "https://api.liforma.ai", Fe = "http://localhost:3001";
|
|
873
|
+
function Ie() {
|
|
852
874
|
let e = globalThis.__LIFORMA_API_BASE_URL;
|
|
853
875
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
854
876
|
if (typeof document > "u") return null;
|
|
855
877
|
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();
|
|
856
878
|
return t ? t.replace(/\/$/, "") : null;
|
|
857
879
|
}
|
|
858
|
-
function
|
|
859
|
-
return
|
|
880
|
+
function Le() {
|
|
881
|
+
return Ie() || (B() ? Fe : Pe);
|
|
860
882
|
}
|
|
861
883
|
//#endregion
|
|
862
884
|
//#region src/v2/api/fetchExperiencePreview.ts
|
|
863
|
-
function
|
|
885
|
+
function Re(e) {
|
|
864
886
|
if (!e || typeof e != "object") return null;
|
|
865
887
|
let t = e, n = typeof t.avatarImage == "string" ? t.avatarImage.trim() : "";
|
|
866
888
|
return n ? {
|
|
@@ -869,10 +891,10 @@ function Ie(e) {
|
|
|
869
891
|
...typeof t.foregroundImage == "string" && t.foregroundImage.trim() ? { foregroundImage: t.foregroundImage.trim() } : {}
|
|
870
892
|
} : null;
|
|
871
893
|
}
|
|
872
|
-
async function
|
|
894
|
+
async function ze(e, t) {
|
|
873
895
|
let n = e.trim();
|
|
874
896
|
if (!n) throw Error("Experience preview requires experienceId.");
|
|
875
|
-
let r = (t?.apiBaseUrl ??
|
|
897
|
+
let r = (t?.apiBaseUrl ?? Le()).replace(/\/$/, ""), i = await fetch(`${r}/v1/experiences/${encodeURIComponent(n)}/preview`, {
|
|
876
898
|
method: "GET",
|
|
877
899
|
headers: { Accept: "application/json" },
|
|
878
900
|
signal: t?.signal
|
|
@@ -892,7 +914,7 @@ async function Le(e, t) {
|
|
|
892
914
|
throw Error("Experience preview returned invalid JSON.");
|
|
893
915
|
}
|
|
894
916
|
if (!a || typeof a != "object") throw Error("Experience preview returned an invalid payload.");
|
|
895
|
-
let o = a, s = typeof o.experienceId == "string" ? o.experienceId.trim() : n, c = typeof o.title == "string" ? o.title.trim() : "", l =
|
|
917
|
+
let o = a, s = typeof o.experienceId == "string" ? o.experienceId.trim() : n, c = typeof o.title == "string" ? o.title.trim() : "", l = Re(o.galleryThumb);
|
|
896
918
|
if (!l) throw Error("Experience preview is missing gallery thumb images.");
|
|
897
919
|
return {
|
|
898
920
|
experienceId: s || n,
|
|
@@ -902,7 +924,7 @@ async function Le(e, t) {
|
|
|
902
924
|
}
|
|
903
925
|
//#endregion
|
|
904
926
|
//#region src/v2/errors/LiformaError.ts
|
|
905
|
-
var
|
|
927
|
+
var J = class extends Error {
|
|
906
928
|
code;
|
|
907
929
|
requestId;
|
|
908
930
|
status;
|
|
@@ -911,16 +933,16 @@ var Re = class extends Error {
|
|
|
911
933
|
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;
|
|
912
934
|
}
|
|
913
935
|
};
|
|
914
|
-
function
|
|
936
|
+
function Be(e) {
|
|
915
937
|
if (!(!e || typeof e != "object" || Array.isArray(e))) return e;
|
|
916
938
|
}
|
|
917
|
-
function
|
|
939
|
+
function Ve(e, t, n) {
|
|
918
940
|
let r = n?.get("Liforma-Request-Id")?.trim() || void 0, i;
|
|
919
941
|
try {
|
|
920
942
|
i = JSON.parse(t);
|
|
921
943
|
} catch {}
|
|
922
|
-
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 } =
|
|
923
|
-
return new
|
|
944
|
+
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 } = Be(a) ?? Be(i) ?? {};
|
|
945
|
+
return new J(u, {
|
|
924
946
|
code: l,
|
|
925
947
|
requestId: d,
|
|
926
948
|
status: e,
|
|
@@ -929,19 +951,19 @@ function Be(e, t, n) {
|
|
|
929
951
|
}
|
|
930
952
|
//#endregion
|
|
931
953
|
//#region src/v2/api/sessionEndpointRequest.ts
|
|
932
|
-
function
|
|
954
|
+
function He(e) {
|
|
933
955
|
let t = e.locale?.trim();
|
|
934
956
|
if (t) return t;
|
|
935
957
|
let n = e.language?.trim();
|
|
936
958
|
if (n) return n;
|
|
937
959
|
if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
|
|
938
960
|
}
|
|
939
|
-
function
|
|
961
|
+
function Ue(e) {
|
|
940
962
|
let t = e.secondaryLocale?.trim(), n = e.learningLocale?.trim();
|
|
941
963
|
if (t && n && t !== n) throw Error("secondaryLocale and learningLocale disagree; pass only one or make them equal.");
|
|
942
964
|
return t || n || void 0;
|
|
943
965
|
}
|
|
944
|
-
function
|
|
966
|
+
function We(e, t) {
|
|
945
967
|
let n = e.trim();
|
|
946
968
|
if (!n) throw Error("sessionEndpoint must not be empty.");
|
|
947
969
|
if (typeof location > "u") throw Error("sessionEndpoint is only available in a browser.");
|
|
@@ -949,7 +971,7 @@ function Ue(e, t) {
|
|
|
949
971
|
if (r.origin !== location.origin) throw Error("sessionEndpoint must be same-origin.");
|
|
950
972
|
let i = t.experienceId.trim();
|
|
951
973
|
if (!i) throw Error("sessionEndpoint requires experienceId.");
|
|
952
|
-
let a =
|
|
974
|
+
let a = He(t), o = Ue(t), s = t.idempotencyKey?.trim();
|
|
953
975
|
return {
|
|
954
976
|
url: r.toString(),
|
|
955
977
|
init: {
|
|
@@ -979,7 +1001,7 @@ function Y(e) {
|
|
|
979
1001
|
function X(e) {
|
|
980
1002
|
return typeof e == "boolean";
|
|
981
1003
|
}
|
|
982
|
-
function
|
|
1004
|
+
function Ge(e) {
|
|
983
1005
|
if (!Y(e)) return null;
|
|
984
1006
|
let t = e.speech, n = e.conversation, r = e.avatar, i = e.tools;
|
|
985
1007
|
return !Y(t) || !Y(n) || !Y(r) || !Y(i) || !X(t.input) || !X(t.output) || !X(t.externalAudio) || !X(n.managed) || !X(r.enabled) || !X(i.enabled) ? null : {
|
|
@@ -993,7 +1015,7 @@ function We(e) {
|
|
|
993
1015
|
tools: { enabled: i.enabled }
|
|
994
1016
|
};
|
|
995
1017
|
}
|
|
996
|
-
function
|
|
1018
|
+
function Ke(e) {
|
|
997
1019
|
return !Y(e) || !X(e.avatar) || !X(e.speechInput) || !X(e.speechOutput) || !X(e.tools) || !X(e.externalAudio) ? null : {
|
|
998
1020
|
speech: {
|
|
999
1021
|
input: e.speechInput,
|
|
@@ -1005,12 +1027,12 @@ function Ge(e) {
|
|
|
1005
1027
|
tools: { enabled: e.tools }
|
|
1006
1028
|
};
|
|
1007
1029
|
}
|
|
1008
|
-
function Ke(e) {
|
|
1009
|
-
return We(e) ?? Ge(e);
|
|
1010
|
-
}
|
|
1011
1030
|
function qe(e) {
|
|
1031
|
+
return Ge(e) ?? Ke(e);
|
|
1032
|
+
}
|
|
1033
|
+
function Je(e) {
|
|
1012
1034
|
if (!Y(e)) throw Error("Session Launch response is missing session.");
|
|
1013
|
-
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 =
|
|
1035
|
+
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 = qe(e.capabilities), l = Ye(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;
|
|
1014
1036
|
if (!t || !n || !r || !i || !a || !s || !c) throw Error("Session Launch response has an invalid session object.");
|
|
1015
1037
|
return {
|
|
1016
1038
|
id: t,
|
|
@@ -1026,7 +1048,7 @@ function qe(e) {
|
|
|
1026
1048
|
...d ? { createdAt: d } : {}
|
|
1027
1049
|
};
|
|
1028
1050
|
}
|
|
1029
|
-
function
|
|
1051
|
+
function Ye(e) {
|
|
1030
1052
|
if (!Array.isArray(e) || e.length === 0) return;
|
|
1031
1053
|
let t = [];
|
|
1032
1054
|
for (let n of e) {
|
|
@@ -1041,102 +1063,102 @@ function Je(e) {
|
|
|
1041
1063
|
}
|
|
1042
1064
|
return t.length > 0 ? t : void 0;
|
|
1043
1065
|
}
|
|
1044
|
-
function
|
|
1066
|
+
function Xe(e) {
|
|
1045
1067
|
let t = e.localeVoiceFallbacks;
|
|
1046
1068
|
if (t?.length) for (let e of t) {
|
|
1047
1069
|
let t = e.axis === "secondaryLocale" ? "secondaryLocale" : "locale";
|
|
1048
1070
|
console.warn(`[liforma] Session ${t} fell back to ${e.resolved} because the voice does not support ${e.requested}.`);
|
|
1049
1071
|
}
|
|
1050
1072
|
}
|
|
1051
|
-
function
|
|
1073
|
+
function Ze(e) {
|
|
1052
1074
|
if (!Y(e)) throw Error("Session Launch response must be a JSON object.");
|
|
1053
1075
|
let t = typeof e.launch == "string" ? e.launch.trim() : "";
|
|
1054
1076
|
if (!t) throw Error("Session Launch response is missing launch.");
|
|
1055
|
-
let n =
|
|
1056
|
-
return
|
|
1077
|
+
let n = Je(e.session);
|
|
1078
|
+
return Xe(n), {
|
|
1057
1079
|
session: n,
|
|
1058
1080
|
launch: t
|
|
1059
1081
|
};
|
|
1060
1082
|
}
|
|
1061
1083
|
//#endregion
|
|
1062
1084
|
//#region src/v2/api/mintPublicSession.ts
|
|
1063
|
-
function
|
|
1085
|
+
function Qe() {
|
|
1064
1086
|
try {
|
|
1065
1087
|
if (typeof globalThis.location?.origin == "string" && globalThis.location.origin) return globalThis.location.origin;
|
|
1066
1088
|
} catch {}
|
|
1067
1089
|
}
|
|
1068
|
-
function
|
|
1090
|
+
function $e(e) {
|
|
1069
1091
|
return e ? e.trim().toUpperCase().replace(/-/g, "_") : "";
|
|
1070
1092
|
}
|
|
1071
|
-
function
|
|
1072
|
-
let n =
|
|
1093
|
+
function et(e, t) {
|
|
1094
|
+
let n = Qe(), r = $e(t.code), i = t.message.trim(), a = t.details ?? {};
|
|
1073
1095
|
if (r === "ORIGIN_NOT_ALLOWED" || /^Origin not allowed/i.test(i) && n) {
|
|
1074
1096
|
if (i.includes(e) && i.includes("allowed origin")) return t;
|
|
1075
1097
|
let r = typeof a.origin == "string" && a.origin || n || "(unknown origin)";
|
|
1076
|
-
return new
|
|
1098
|
+
return new J(`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.`, {
|
|
1077
1099
|
code: "ORIGIN_NOT_ALLOWED",
|
|
1078
1100
|
requestId: t.requestId,
|
|
1079
1101
|
status: t.status,
|
|
1080
1102
|
details: a
|
|
1081
1103
|
});
|
|
1082
1104
|
}
|
|
1083
|
-
return r === "BROWSER_EMBEDS_DISABLED" || /^Browser embeds are not enabled/i.test(i) ? i.includes("Allow public client-only embeds") ? t : new
|
|
1105
|
+
return r === "BROWSER_EMBEDS_DISABLED" || /^Browser embeds are not enabled/i.test(i) ? i.includes("Allow public client-only embeds") ? t : new J(`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”.`, {
|
|
1084
1106
|
code: "BROWSER_EMBEDS_DISABLED",
|
|
1085
1107
|
requestId: t.requestId,
|
|
1086
1108
|
status: t.status,
|
|
1087
1109
|
details: a
|
|
1088
|
-
}) : r === "EXPERIENCE_UNAVAILABLE" || /^Experience is not available\.?$/i.test(i) || /^Unknown experience\.?$/i.test(i) ? i.includes("No playable experience found") ? t : new
|
|
1110
|
+
}) : r === "EXPERIENCE_UNAVAILABLE" || /^Experience is not available\.?$/i.test(i) || /^Unknown experience\.?$/i.test(i) ? i.includes("No playable experience found") ? t : new J(`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.`, {
|
|
1089
1111
|
code: "EXPERIENCE_UNAVAILABLE",
|
|
1090
1112
|
requestId: t.requestId,
|
|
1091
1113
|
status: t.status,
|
|
1092
1114
|
details: a
|
|
1093
1115
|
}) : t;
|
|
1094
1116
|
}
|
|
1095
|
-
function
|
|
1117
|
+
function tt(e) {
|
|
1096
1118
|
let t = e?.locale?.trim();
|
|
1097
1119
|
if (t) return t;
|
|
1098
1120
|
let n = e?.language?.trim();
|
|
1099
1121
|
if (n) return n;
|
|
1100
1122
|
if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
|
|
1101
1123
|
}
|
|
1102
|
-
function
|
|
1124
|
+
function nt(e) {
|
|
1103
1125
|
let t = e?.secondaryLocale?.trim(), n = e?.learningLocale?.trim();
|
|
1104
|
-
if (t && n && t !== n) throw new
|
|
1126
|
+
if (t && n && t !== n) throw new J("secondaryLocale and learningLocale disagree; pass only one or make them equal.", { code: "INVALID_BODY" });
|
|
1105
1127
|
return t || n || void 0;
|
|
1106
1128
|
}
|
|
1107
|
-
function
|
|
1108
|
-
let n = { experienceId: e }, r =
|
|
1129
|
+
function rt(e, t) {
|
|
1130
|
+
let n = { experienceId: e }, r = tt(t);
|
|
1109
1131
|
r && (n.locale = r);
|
|
1110
|
-
let i =
|
|
1132
|
+
let i = nt(t);
|
|
1111
1133
|
return i && (n.secondaryLocale = i), t?.mode && (n.mode = t.mode), t?.speechInputMode && (n.speechInputMode = t.speechInputMode), t?.speechOnly !== void 0 && (n.speechOnly = t.speechOnly), n;
|
|
1112
1134
|
}
|
|
1113
|
-
async function
|
|
1114
|
-
let n =
|
|
1135
|
+
async function it(e, t) {
|
|
1136
|
+
let n = Le(), r = t?.idempotencyKey?.trim(), i = await fetch(`${n}/v1/browser-sessions`, {
|
|
1115
1137
|
method: "POST",
|
|
1116
1138
|
headers: {
|
|
1117
1139
|
"Content-Type": "application/json",
|
|
1118
1140
|
...r ? { "Idempotency-Key": r } : {}
|
|
1119
1141
|
},
|
|
1120
|
-
body: JSON.stringify(
|
|
1142
|
+
body: JSON.stringify(rt(e, t))
|
|
1121
1143
|
});
|
|
1122
1144
|
if (!i.ok) {
|
|
1123
1145
|
let t = await i.text();
|
|
1124
|
-
throw
|
|
1146
|
+
throw et(e, Ve(i.status, t, i.headers));
|
|
1125
1147
|
}
|
|
1126
1148
|
let a;
|
|
1127
1149
|
try {
|
|
1128
1150
|
a = await i.json();
|
|
1129
1151
|
} catch {
|
|
1130
|
-
throw new
|
|
1152
|
+
throw new J("Browser session mint returned invalid JSON.", {
|
|
1131
1153
|
code: "INVALID_RESPONSE",
|
|
1132
1154
|
status: i.status,
|
|
1133
1155
|
requestId: i.headers.get("Liforma-Request-Id") ?? void 0
|
|
1134
1156
|
});
|
|
1135
1157
|
}
|
|
1136
|
-
return
|
|
1158
|
+
return Ze(a);
|
|
1137
1159
|
}
|
|
1138
|
-
async function
|
|
1139
|
-
let n =
|
|
1160
|
+
async function at(e, t) {
|
|
1161
|
+
let n = We(e, t), r = new AbortController(), i = () => r.abort(t.signal?.reason);
|
|
1140
1162
|
t.signal?.aborted ? i() : t.signal?.addEventListener("abort", i, { once: !0 });
|
|
1141
1163
|
let a = globalThis.setTimeout(() => r.abort(new DOMException("Session endpoint timed out.", "TimeoutError")), t.timeoutMs ?? 3e4), o;
|
|
1142
1164
|
try {
|
|
@@ -1149,9 +1171,9 @@ async function it(e, t) {
|
|
|
1149
1171
|
}
|
|
1150
1172
|
if (!o.ok) {
|
|
1151
1173
|
let e = await o.text();
|
|
1152
|
-
throw
|
|
1174
|
+
throw Ve(o.status, e, o.headers);
|
|
1153
1175
|
}
|
|
1154
|
-
if (!o.headers.get("content-type")?.toLowerCase().includes("application/json")) throw new
|
|
1176
|
+
if (!o.headers.get("content-type")?.toLowerCase().includes("application/json")) throw new J("Session endpoint must return a JSON Session Launch response.", {
|
|
1155
1177
|
code: "INVALID_RESPONSE",
|
|
1156
1178
|
status: o.status,
|
|
1157
1179
|
requestId: o.headers.get("Liforma-Request-Id") ?? void 0
|
|
@@ -1160,20 +1182,20 @@ async function it(e, t) {
|
|
|
1160
1182
|
try {
|
|
1161
1183
|
s = await o.json();
|
|
1162
1184
|
} catch {
|
|
1163
|
-
throw new
|
|
1185
|
+
throw new J("Session endpoint returned invalid JSON.", {
|
|
1164
1186
|
code: "INVALID_RESPONSE",
|
|
1165
1187
|
status: o.status,
|
|
1166
1188
|
requestId: o.headers.get("Liforma-Request-Id") ?? void 0
|
|
1167
1189
|
});
|
|
1168
1190
|
}
|
|
1169
|
-
return
|
|
1191
|
+
return Ze(s);
|
|
1170
1192
|
}
|
|
1171
1193
|
//#endregion
|
|
1172
1194
|
//#region src/v2/conversationProcessor.ts
|
|
1173
|
-
function
|
|
1195
|
+
function ot(e) {
|
|
1174
1196
|
return typeof e != "object" || !e ? !1 : typeof e[Symbol.asyncIterator] == "function";
|
|
1175
1197
|
}
|
|
1176
|
-
function
|
|
1198
|
+
function st(e) {
|
|
1177
1199
|
if (typeof e == "string") {
|
|
1178
1200
|
let t = e.trim();
|
|
1179
1201
|
if (!t) throw Error("conversationProcessor returned empty text.");
|
|
@@ -1187,24 +1209,24 @@ function ot(e) {
|
|
|
1187
1209
|
...e.behavior ? { behavior: e.behavior } : {}
|
|
1188
1210
|
};
|
|
1189
1211
|
}
|
|
1190
|
-
async function
|
|
1212
|
+
async function ct(e, t) {
|
|
1191
1213
|
let n = await e(t);
|
|
1192
|
-
return
|
|
1214
|
+
return ot(n) ? {
|
|
1193
1215
|
kind: "stream",
|
|
1194
1216
|
stream: n
|
|
1195
1217
|
} : {
|
|
1196
1218
|
kind: "complete",
|
|
1197
|
-
speech:
|
|
1219
|
+
speech: st(n)
|
|
1198
1220
|
};
|
|
1199
1221
|
}
|
|
1200
1222
|
//#endregion
|
|
1201
1223
|
//#region src/v2/embed/playerReachability.ts
|
|
1202
|
-
var
|
|
1203
|
-
function
|
|
1224
|
+
var lt = "3002";
|
|
1225
|
+
function ut(e) {
|
|
1204
1226
|
let t = new URL(e);
|
|
1205
|
-
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 ||
|
|
1227
|
+
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.`;
|
|
1206
1228
|
}
|
|
1207
|
-
async function
|
|
1229
|
+
async function dt(e, t) {
|
|
1208
1230
|
try {
|
|
1209
1231
|
await fetch(e, {
|
|
1210
1232
|
method: "GET",
|
|
@@ -1212,35 +1234,39 @@ async function ut(e, t) {
|
|
|
1212
1234
|
signal: AbortSignal.timeout(8e3)
|
|
1213
1235
|
});
|
|
1214
1236
|
} catch {
|
|
1215
|
-
throw Error(
|
|
1237
|
+
throw Error(ut(t));
|
|
1216
1238
|
}
|
|
1217
1239
|
}
|
|
1218
|
-
function
|
|
1240
|
+
function ft(e, t, n, r) {
|
|
1219
1241
|
try {
|
|
1220
1242
|
r && r.length > 0 ? e.postMessage(t, n, r) : e.postMessage(t, n);
|
|
1221
1243
|
} catch (e) {
|
|
1222
|
-
throw e instanceof DOMException && e.name === "SecurityError" ? Error(
|
|
1244
|
+
throw e instanceof DOMException && e.name === "SecurityError" ? Error(ut(n), { cause: e }) : e;
|
|
1223
1245
|
}
|
|
1224
1246
|
}
|
|
1225
|
-
var
|
|
1226
|
-
function
|
|
1227
|
-
return typeof e == "number" &&
|
|
1247
|
+
var pt = new Set([1, 2]);
|
|
1248
|
+
function mt(e) {
|
|
1249
|
+
return typeof e == "number" && pt.has(e);
|
|
1228
1250
|
}
|
|
1229
|
-
var
|
|
1251
|
+
var ht = new Set([
|
|
1230
1252
|
"close",
|
|
1231
1253
|
"stateUpdate",
|
|
1232
1254
|
"commandResult",
|
|
1233
1255
|
"userTranscript",
|
|
1234
1256
|
"characterSpeechStarted",
|
|
1235
1257
|
"characterSpeechEnded",
|
|
1258
|
+
"characterFocusChanged",
|
|
1236
1259
|
"conversationUpdate",
|
|
1237
1260
|
"listeningState",
|
|
1238
1261
|
"userSpeechStarted",
|
|
1239
1262
|
"userSpeechEnded",
|
|
1240
1263
|
"modeChange",
|
|
1241
1264
|
"activityChange",
|
|
1265
|
+
"feedback",
|
|
1266
|
+
"feedbackFailed",
|
|
1242
1267
|
"message",
|
|
1243
1268
|
"started",
|
|
1269
|
+
"embedReady",
|
|
1244
1270
|
"widgetReady",
|
|
1245
1271
|
"widgetExpand",
|
|
1246
1272
|
"widgetCollapse",
|
|
@@ -1249,11 +1275,11 @@ var mt = new Set([
|
|
|
1249
1275
|
"widgetDragMove",
|
|
1250
1276
|
"widgetDragEnd"
|
|
1251
1277
|
]);
|
|
1252
|
-
function
|
|
1278
|
+
function gt(e) {
|
|
1253
1279
|
if (!e || typeof e != "object") return null;
|
|
1254
1280
|
let t = e;
|
|
1255
|
-
if (!
|
|
1256
|
-
if (t.type === "widgetReady" || t.type === "widgetExpand" || t.type === "widgetCollapse") return t;
|
|
1281
|
+
if (!mt(t.schemaVersion) || !t.type || !ht.has(t.type)) return null;
|
|
1282
|
+
if (t.type === "embedReady" || t.type === "widgetReady" || t.type === "widgetExpand" || t.type === "widgetCollapse") return t;
|
|
1257
1283
|
if (t.type === "widgetAudioSettings") {
|
|
1258
1284
|
let e = t.payload;
|
|
1259
1285
|
return !e || typeof e != "object" || typeof e.open != "boolean" ? null : t;
|
|
@@ -1268,35 +1294,38 @@ function ht(e) {
|
|
|
1268
1294
|
let { pointerId: n, dx: r, dy: i } = e;
|
|
1269
1295
|
return typeof n != "number" || !Number.isFinite(n) || typeof r != "number" || !Number.isFinite(r) || typeof i != "number" || !Number.isFinite(i) ? null : t;
|
|
1270
1296
|
}
|
|
1271
|
-
|
|
1297
|
+
let n = t.payload;
|
|
1298
|
+
return !n || typeof n != "object" ? null : t;
|
|
1272
1299
|
}
|
|
1273
|
-
function
|
|
1300
|
+
function _t(e, t, n) {
|
|
1274
1301
|
let r = e.trim();
|
|
1275
1302
|
if (!r) throw Error("createLaunchMessage requires a non-empty launch string.");
|
|
1303
|
+
let i = n?.startButton, a = n?.showFeedback;
|
|
1276
1304
|
return {
|
|
1277
1305
|
type: "launch",
|
|
1278
1306
|
schemaVersion: 2,
|
|
1279
1307
|
payload: {
|
|
1280
1308
|
launch: r,
|
|
1281
1309
|
...t === void 0 ? {} : { session: t },
|
|
1282
|
-
...
|
|
1310
|
+
...i ? { startButton: i } : {},
|
|
1311
|
+
...a === void 0 ? {} : { showFeedback: a }
|
|
1283
1312
|
}
|
|
1284
1313
|
};
|
|
1285
1314
|
}
|
|
1286
|
-
function
|
|
1315
|
+
function vt() {
|
|
1287
1316
|
return {
|
|
1288
1317
|
type: "parentHello",
|
|
1289
1318
|
schemaVersion: 2
|
|
1290
1319
|
};
|
|
1291
1320
|
}
|
|
1292
|
-
function
|
|
1321
|
+
function yt(e) {
|
|
1293
1322
|
return {
|
|
1294
1323
|
type: "widgetSetChrome",
|
|
1295
1324
|
schemaVersion: 2,
|
|
1296
1325
|
payload: { mode: e }
|
|
1297
1326
|
};
|
|
1298
1327
|
}
|
|
1299
|
-
function
|
|
1328
|
+
function bt() {
|
|
1300
1329
|
return {
|
|
1301
1330
|
type: "widgetToggleAudioSettings",
|
|
1302
1331
|
schemaVersion: 2,
|
|
@@ -1305,30 +1334,50 @@ function yt() {
|
|
|
1305
1334
|
}
|
|
1306
1335
|
//#endregion
|
|
1307
1336
|
//#region src/v2/embed/iframeHost.ts
|
|
1308
|
-
function
|
|
1337
|
+
function xt(e) {
|
|
1309
1338
|
return e;
|
|
1310
1339
|
}
|
|
1311
1340
|
function Z() {
|
|
1312
1341
|
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)}`;
|
|
1313
1342
|
}
|
|
1314
|
-
var
|
|
1315
|
-
function
|
|
1343
|
+
var St = 3e4;
|
|
1344
|
+
function Ct(e) {
|
|
1316
1345
|
let t = e.container;
|
|
1317
1346
|
getComputedStyle(t).position === "static" && (t.style.position = "relative");
|
|
1318
1347
|
let n = document.createElement("iframe");
|
|
1319
1348
|
n.src = e.src, n.title = "Liforma experience", n.setAttribute("allow", "microphone; autoplay; clipboard-read; clipboard-write"), n.style.cssText = e.transparent ? "display:block;position:absolute;inset:0;width:100%;height:100%;border:0;background:transparent;" : "display:block;position:absolute;inset:0;width:100%;height:100%;border:0;background:#030508;", e.transparent && n.setAttribute("allowtransparency", "true");
|
|
1320
|
-
let r = !1, i = /* @__PURE__ */ new Map(), a = new Promise((
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1349
|
+
let r = !1, i = /* @__PURE__ */ new Map(), a = null, o = 0, s = 0, c = [], l = null, u = null, d = new Promise((e, t) => {
|
|
1350
|
+
l = e, u = t;
|
|
1351
|
+
}), f = () => {
|
|
1352
|
+
for (let e of c) window.clearTimeout(e);
|
|
1353
|
+
c.length = 0;
|
|
1354
|
+
}, p = (t) => {
|
|
1355
|
+
if (r) return;
|
|
1356
|
+
let i = Date.now();
|
|
1357
|
+
if (s > 0 && i - s < 250) return;
|
|
1358
|
+
s = i, f();
|
|
1359
|
+
let a = _t(t.launch, t.session, t.chrome), o = () => {
|
|
1360
|
+
if (r) return;
|
|
1361
|
+
let t = n.contentWindow;
|
|
1362
|
+
t && ft(t, a, e.playerOrigin);
|
|
1327
1363
|
};
|
|
1328
|
-
|
|
1329
|
-
|
|
1364
|
+
o();
|
|
1365
|
+
for (let e = 1; e <= 12; e += 1) c.push(window.setTimeout(o, e * 75));
|
|
1366
|
+
}, m = () => {
|
|
1367
|
+
r || !a || p(a);
|
|
1368
|
+
}, h = () => {
|
|
1369
|
+
if (o += 1, o === 1) {
|
|
1370
|
+
dt(e.src, e.playerOrigin).then(() => l?.(), (e) => u?.(e instanceof Error ? e : Error(String(e))));
|
|
1371
|
+
return;
|
|
1372
|
+
}
|
|
1373
|
+
s = 0, m();
|
|
1374
|
+
}, g = () => {
|
|
1375
|
+
o > 0 || u?.(Error(ut(e.playerOrigin)));
|
|
1376
|
+
};
|
|
1377
|
+
n.addEventListener("load", h), n.addEventListener("error", g);
|
|
1378
|
+
let _ = (t) => {
|
|
1330
1379
|
if (r || t.source !== n.contentWindow || t.origin !== e.playerOrigin) return;
|
|
1331
|
-
let a =
|
|
1380
|
+
let a = gt(t.data);
|
|
1332
1381
|
if (a) switch (a.type) {
|
|
1333
1382
|
case "close":
|
|
1334
1383
|
e.onClose?.(a.payload);
|
|
@@ -1351,6 +1400,9 @@ function St(e) {
|
|
|
1351
1400
|
case "characterSpeechEnded":
|
|
1352
1401
|
e.onCharacterSpeechEnded?.(a.payload);
|
|
1353
1402
|
break;
|
|
1403
|
+
case "characterFocusChanged":
|
|
1404
|
+
e.onCharacterFocusChanged?.(a.payload);
|
|
1405
|
+
break;
|
|
1354
1406
|
case "conversationUpdate":
|
|
1355
1407
|
e.onConversationUpdate?.(a.payload.conversation);
|
|
1356
1408
|
break;
|
|
@@ -1364,17 +1416,26 @@ function St(e) {
|
|
|
1364
1416
|
e.onUserSpeechEnded?.(a.payload);
|
|
1365
1417
|
break;
|
|
1366
1418
|
case "modeChange":
|
|
1367
|
-
e.onActivityChange?.(
|
|
1419
|
+
e.onActivityChange?.(xt(a.payload.mode));
|
|
1368
1420
|
break;
|
|
1369
1421
|
case "activityChange":
|
|
1370
1422
|
e.onActivityChange?.(a.payload.activity);
|
|
1371
1423
|
break;
|
|
1424
|
+
case "feedback":
|
|
1425
|
+
e.onFeedback?.(a.payload);
|
|
1426
|
+
break;
|
|
1427
|
+
case "feedbackFailed":
|
|
1428
|
+
e.onFeedbackFailed?.(a.payload);
|
|
1429
|
+
break;
|
|
1372
1430
|
case "message":
|
|
1373
1431
|
e.onMessage?.(a.payload);
|
|
1374
1432
|
break;
|
|
1375
1433
|
case "started":
|
|
1376
1434
|
e.onStarted?.(a.payload);
|
|
1377
1435
|
break;
|
|
1436
|
+
case "embedReady":
|
|
1437
|
+
m();
|
|
1438
|
+
break;
|
|
1378
1439
|
case "widgetReady":
|
|
1379
1440
|
e.onWidgetReady?.();
|
|
1380
1441
|
break;
|
|
@@ -1398,42 +1459,39 @@ function St(e) {
|
|
|
1398
1459
|
break;
|
|
1399
1460
|
}
|
|
1400
1461
|
};
|
|
1401
|
-
if (window.addEventListener("message",
|
|
1462
|
+
if (window.addEventListener("message", _), t.replaceChildren(n), t.clientHeight < 2 && !t.style.minHeight) {
|
|
1402
1463
|
let e = getComputedStyle(t).minHeight;
|
|
1403
1464
|
(e === "0px" || e === "auto") && (t.style.minHeight = "480px");
|
|
1404
1465
|
}
|
|
1405
|
-
let
|
|
1466
|
+
let v = (t, i) => {
|
|
1406
1467
|
if (r) return;
|
|
1407
1468
|
let a = n.contentWindow;
|
|
1408
|
-
if (!a) throw Error(
|
|
1409
|
-
|
|
1410
|
-
},
|
|
1469
|
+
if (!a) throw Error(ut(e.playerOrigin));
|
|
1470
|
+
ft(a, t, e.playerOrigin, i);
|
|
1471
|
+
}, y = (e, t = 12e4, n) => {
|
|
1411
1472
|
let r = e.type !== "parentHello" && e.payload && "correlationId" in e.payload ? e.payload.correlationId : Z();
|
|
1412
1473
|
return e.type !== "parentHello" && e.payload && "correlationId" in e.payload || e.type !== "parentHello" && e.payload && (e.payload.correlationId = r), new Promise((a, o) => {
|
|
1413
1474
|
i.set(r, {
|
|
1414
1475
|
resolve: (e) => a(e),
|
|
1415
1476
|
reject: o
|
|
1416
|
-
}),
|
|
1477
|
+
}), v(e, n), setTimeout(() => {
|
|
1417
1478
|
i.has(r) && (i.delete(r), o(/* @__PURE__ */ Error("Timed out waiting for player command result.")));
|
|
1418
1479
|
}, t);
|
|
1419
1480
|
});
|
|
1420
1481
|
};
|
|
1421
1482
|
return {
|
|
1422
1483
|
waitForLoad() {
|
|
1423
|
-
return
|
|
1484
|
+
return d;
|
|
1424
1485
|
},
|
|
1425
1486
|
postParentHello() {
|
|
1426
|
-
|
|
1487
|
+
v(vt());
|
|
1427
1488
|
},
|
|
1428
|
-
postLaunch(
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
};
|
|
1435
|
-
c();
|
|
1436
|
-
for (let e = 1; e <= 12; e += 1) window.setTimeout(c, e * 75);
|
|
1489
|
+
postLaunch(e, t, n) {
|
|
1490
|
+
r || (a = {
|
|
1491
|
+
launch: e,
|
|
1492
|
+
session: t,
|
|
1493
|
+
chrome: n
|
|
1494
|
+
}, s = 0, p(a));
|
|
1437
1495
|
},
|
|
1438
1496
|
postManifest(e) {
|
|
1439
1497
|
if (typeof e == "string") {
|
|
@@ -1448,13 +1506,13 @@ function St(e) {
|
|
|
1448
1506
|
throw Error("postManifest is deprecated; use postLaunch with an opaque launch string from SessionLaunchResponse.");
|
|
1449
1507
|
},
|
|
1450
1508
|
postWidgetSetChrome(e) {
|
|
1451
|
-
|
|
1509
|
+
v(yt(e));
|
|
1452
1510
|
},
|
|
1453
1511
|
postWidgetToggleAudioSettings() {
|
|
1454
|
-
|
|
1512
|
+
v(bt());
|
|
1455
1513
|
},
|
|
1456
1514
|
speak(e) {
|
|
1457
|
-
return
|
|
1515
|
+
return y({
|
|
1458
1516
|
type: "speak",
|
|
1459
1517
|
schemaVersion: 2,
|
|
1460
1518
|
payload: {
|
|
@@ -1466,21 +1524,21 @@ function St(e) {
|
|
|
1466
1524
|
});
|
|
1467
1525
|
},
|
|
1468
1526
|
startListening() {
|
|
1469
|
-
return
|
|
1527
|
+
return y({
|
|
1470
1528
|
type: "startListening",
|
|
1471
1529
|
schemaVersion: 2,
|
|
1472
1530
|
payload: { correlationId: Z() }
|
|
1473
1531
|
});
|
|
1474
1532
|
},
|
|
1475
1533
|
stopListening() {
|
|
1476
|
-
return
|
|
1534
|
+
return y({
|
|
1477
1535
|
type: "stopListening",
|
|
1478
1536
|
schemaVersion: 2,
|
|
1479
1537
|
payload: { correlationId: Z() }
|
|
1480
1538
|
});
|
|
1481
1539
|
},
|
|
1482
1540
|
listenOnce(e) {
|
|
1483
|
-
return
|
|
1541
|
+
return y({
|
|
1484
1542
|
type: "listenOnce",
|
|
1485
1543
|
schemaVersion: 2,
|
|
1486
1544
|
payload: {
|
|
@@ -1490,7 +1548,7 @@ function St(e) {
|
|
|
1490
1548
|
});
|
|
1491
1549
|
},
|
|
1492
1550
|
async speakProcessorStream(e, t) {
|
|
1493
|
-
let n = Z(), r = Z(), i = (await
|
|
1551
|
+
let n = Z(), r = Z(), i = (await y({
|
|
1494
1552
|
type: "speakStreamStart",
|
|
1495
1553
|
schemaVersion: 2,
|
|
1496
1554
|
payload: {
|
|
@@ -1502,7 +1560,7 @@ function St(e) {
|
|
|
1502
1560
|
try {
|
|
1503
1561
|
for await (let n of e) {
|
|
1504
1562
|
if (t?.signal?.aborted) throw new DOMException("Processor stream aborted.", "AbortError");
|
|
1505
|
-
n &&
|
|
1563
|
+
n && v({
|
|
1506
1564
|
type: "speakStreamChunk",
|
|
1507
1565
|
schemaVersion: 2,
|
|
1508
1566
|
payload: {
|
|
@@ -1512,7 +1570,7 @@ function St(e) {
|
|
|
1512
1570
|
});
|
|
1513
1571
|
}
|
|
1514
1572
|
if (t?.signal?.aborted) throw new DOMException("Processor stream aborted.", "AbortError");
|
|
1515
|
-
return await
|
|
1573
|
+
return await y({
|
|
1516
1574
|
type: "speakStreamEnd",
|
|
1517
1575
|
schemaVersion: 2,
|
|
1518
1576
|
payload: {
|
|
@@ -1522,7 +1580,7 @@ function St(e) {
|
|
|
1522
1580
|
});
|
|
1523
1581
|
} catch (e) {
|
|
1524
1582
|
try {
|
|
1525
|
-
await
|
|
1583
|
+
await y({
|
|
1526
1584
|
type: "speakStreamEnd",
|
|
1527
1585
|
schemaVersion: 2,
|
|
1528
1586
|
payload: {
|
|
@@ -1536,7 +1594,7 @@ function St(e) {
|
|
|
1536
1594
|
},
|
|
1537
1595
|
speechPlay(e) {
|
|
1538
1596
|
let t = Z(), n = [];
|
|
1539
|
-
return (e.source.kind === "pcm" || e.source.kind === "encoded") && n.push(e.source.data),
|
|
1597
|
+
return (e.source.kind === "pcm" || e.source.kind === "encoded") && n.push(e.source.data), y({
|
|
1540
1598
|
type: "speechPlay",
|
|
1541
1599
|
schemaVersion: 2,
|
|
1542
1600
|
payload: {
|
|
@@ -1550,7 +1608,7 @@ function St(e) {
|
|
|
1550
1608
|
}, 12e4, n);
|
|
1551
1609
|
},
|
|
1552
1610
|
speechUtteranceBegin(e) {
|
|
1553
|
-
return
|
|
1611
|
+
return y({
|
|
1554
1612
|
type: "speechUtteranceBegin",
|
|
1555
1613
|
schemaVersion: 2,
|
|
1556
1614
|
payload: {
|
|
@@ -1564,7 +1622,7 @@ function St(e) {
|
|
|
1564
1622
|
});
|
|
1565
1623
|
},
|
|
1566
1624
|
speechUtteranceWrite(e) {
|
|
1567
|
-
return
|
|
1625
|
+
return y({
|
|
1568
1626
|
type: "speechUtteranceWrite",
|
|
1569
1627
|
schemaVersion: 2,
|
|
1570
1628
|
payload: {
|
|
@@ -1573,10 +1631,10 @@ function St(e) {
|
|
|
1573
1631
|
audio: e.audio,
|
|
1574
1632
|
byteLength: e.byteLength
|
|
1575
1633
|
}
|
|
1576
|
-
},
|
|
1634
|
+
}, St, [e.audio]);
|
|
1577
1635
|
},
|
|
1578
1636
|
speechUtteranceSetTranscript(e) {
|
|
1579
|
-
return
|
|
1637
|
+
return y({
|
|
1580
1638
|
type: "speechUtteranceSetTranscript",
|
|
1581
1639
|
schemaVersion: 2,
|
|
1582
1640
|
payload: {
|
|
@@ -1587,7 +1645,7 @@ function St(e) {
|
|
|
1587
1645
|
});
|
|
1588
1646
|
},
|
|
1589
1647
|
speechUtteranceClose(e) {
|
|
1590
|
-
return
|
|
1648
|
+
return y({
|
|
1591
1649
|
type: "speechUtteranceClose",
|
|
1592
1650
|
schemaVersion: 2,
|
|
1593
1651
|
payload: {
|
|
@@ -1599,7 +1657,7 @@ function St(e) {
|
|
|
1599
1657
|
});
|
|
1600
1658
|
},
|
|
1601
1659
|
speechUtteranceCancel(e) {
|
|
1602
|
-
return
|
|
1660
|
+
return y({
|
|
1603
1661
|
type: "speechUtteranceCancel",
|
|
1604
1662
|
schemaVersion: 2,
|
|
1605
1663
|
payload: {
|
|
@@ -1609,7 +1667,7 @@ function St(e) {
|
|
|
1609
1667
|
});
|
|
1610
1668
|
},
|
|
1611
1669
|
speechInterrupt(e) {
|
|
1612
|
-
return
|
|
1670
|
+
return y({
|
|
1613
1671
|
type: "speechInterrupt",
|
|
1614
1672
|
schemaVersion: 2,
|
|
1615
1673
|
payload: {
|
|
@@ -1619,24 +1677,44 @@ function St(e) {
|
|
|
1619
1677
|
});
|
|
1620
1678
|
},
|
|
1621
1679
|
getConversation() {
|
|
1622
|
-
return
|
|
1680
|
+
return y({
|
|
1623
1681
|
type: "getConversation",
|
|
1624
1682
|
schemaVersion: 2,
|
|
1625
1683
|
payload: { correlationId: Z() }
|
|
1626
1684
|
});
|
|
1627
1685
|
},
|
|
1686
|
+
focusCharacter(e) {
|
|
1687
|
+
return y({
|
|
1688
|
+
type: "focusCharacter",
|
|
1689
|
+
schemaVersion: 2,
|
|
1690
|
+
payload: {
|
|
1691
|
+
correlationId: Z(),
|
|
1692
|
+
characterId: e
|
|
1693
|
+
}
|
|
1694
|
+
});
|
|
1695
|
+
},
|
|
1696
|
+
setFit(e) {
|
|
1697
|
+
return y({
|
|
1698
|
+
type: "setFit",
|
|
1699
|
+
schemaVersion: 2,
|
|
1700
|
+
payload: {
|
|
1701
|
+
correlationId: Z(),
|
|
1702
|
+
fit: e
|
|
1703
|
+
}
|
|
1704
|
+
});
|
|
1705
|
+
},
|
|
1628
1706
|
destroy() {
|
|
1629
1707
|
if (!r) {
|
|
1630
1708
|
r = !0;
|
|
1631
1709
|
for (let e of i.values()) e.reject(/* @__PURE__ */ Error("Iframe host destroyed."));
|
|
1632
|
-
i.clear(), window.removeEventListener("message",
|
|
1710
|
+
i.clear(), f(), a = null, n.removeEventListener("load", h), n.removeEventListener("error", g), window.removeEventListener("message", _), n.remove();
|
|
1633
1711
|
}
|
|
1634
1712
|
}
|
|
1635
1713
|
};
|
|
1636
1714
|
}
|
|
1637
1715
|
//#endregion
|
|
1638
1716
|
//#region src/v2/embed/readyGate.ts
|
|
1639
|
-
function
|
|
1717
|
+
function wt(e) {
|
|
1640
1718
|
let t, n = !1, r = !1, i = () => {
|
|
1641
1719
|
r || !n || t === void 0 || (r = !0, e(t));
|
|
1642
1720
|
};
|
|
@@ -1651,47 +1729,47 @@ function Ct(e) {
|
|
|
1651
1729
|
}
|
|
1652
1730
|
//#endregion
|
|
1653
1731
|
//#region src/v2/shims/embedBaseUrl.ts
|
|
1654
|
-
var
|
|
1655
|
-
function
|
|
1732
|
+
var Tt = "https://player.liforma.ai/embed", Et = "http://localhost:3002/embed";
|
|
1733
|
+
function Dt() {
|
|
1656
1734
|
let e = globalThis.__LIFORMA_PLAYER_EMBED_URL;
|
|
1657
1735
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
1658
1736
|
if (typeof document > "u") return null;
|
|
1659
1737
|
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();
|
|
1660
1738
|
return t ? t.replace(/\/$/, "") : null;
|
|
1661
1739
|
}
|
|
1662
|
-
function
|
|
1663
|
-
let e =
|
|
1664
|
-
return e ? e.endsWith("/embed") ? e : `${e}/embed` :
|
|
1740
|
+
function Ot() {
|
|
1741
|
+
let e = Dt();
|
|
1742
|
+
return e ? e.endsWith("/embed") ? e : `${e}/embed` : B() ? Et : Tt;
|
|
1665
1743
|
}
|
|
1666
|
-
function
|
|
1667
|
-
let
|
|
1668
|
-
|
|
1669
|
-
let
|
|
1670
|
-
return
|
|
1744
|
+
function kt(e, t, n, r, i, a, o, s) {
|
|
1745
|
+
let c = (e ?? Ot()).replace(/\/$/, ""), l = c.endsWith("/embed") ? c : `${c}/embed`, u = new URL(l), d = n?.trim();
|
|
1746
|
+
d && u.searchParams.set("locationId", d);
|
|
1747
|
+
let f = r?.trim();
|
|
1748
|
+
return f && u.searchParams.set("avatarId", f), (i === "face" || i === "medium") && u.searchParams.set("fit", i), a === "widget" && u.searchParams.set("ui", "widget"), o && u.searchParams.set("close", "1"), t && u.searchParams.set("debug", "true"), (s === 2 || s === 3 || s === 4) && u.searchParams.set("cast", String(s)), At(u.toString());
|
|
1671
1749
|
}
|
|
1672
|
-
function
|
|
1750
|
+
function At(e) {
|
|
1673
1751
|
if (typeof location > "u") return e;
|
|
1674
1752
|
let t = new URL(e);
|
|
1675
1753
|
return t.searchParams.set("parentOrigin", location.origin), t.toString();
|
|
1676
1754
|
}
|
|
1677
|
-
function
|
|
1755
|
+
function jt(e) {
|
|
1678
1756
|
return new URL(e).origin;
|
|
1679
1757
|
}
|
|
1680
1758
|
//#endregion
|
|
1681
1759
|
//#region src/v2/experienceEvents.ts
|
|
1682
|
-
function
|
|
1760
|
+
function Mt() {
|
|
1683
1761
|
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)}`;
|
|
1684
1762
|
}
|
|
1685
|
-
function
|
|
1763
|
+
function Nt(e, t, n) {
|
|
1686
1764
|
return {
|
|
1687
|
-
id:
|
|
1765
|
+
id: Mt(),
|
|
1688
1766
|
type: e,
|
|
1689
1767
|
sessionId: t,
|
|
1690
1768
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1691
1769
|
data: n
|
|
1692
1770
|
};
|
|
1693
1771
|
}
|
|
1694
|
-
function
|
|
1772
|
+
function Pt() {
|
|
1695
1773
|
return {
|
|
1696
1774
|
ready: /* @__PURE__ */ new Set(),
|
|
1697
1775
|
started: /* @__PURE__ */ new Set(),
|
|
@@ -1700,46 +1778,49 @@ function Nt() {
|
|
|
1700
1778
|
userSpeechEnded: /* @__PURE__ */ new Set(),
|
|
1701
1779
|
characterSpeechStarted: /* @__PURE__ */ new Set(),
|
|
1702
1780
|
characterSpeechEnded: /* @__PURE__ */ new Set(),
|
|
1781
|
+
characterFocusChanged: /* @__PURE__ */ new Set(),
|
|
1703
1782
|
conversationUpdate: /* @__PURE__ */ new Set(),
|
|
1704
1783
|
message: /* @__PURE__ */ new Set(),
|
|
1705
1784
|
listeningState: /* @__PURE__ */ new Set(),
|
|
1706
1785
|
activityChange: /* @__PURE__ */ new Set(),
|
|
1786
|
+
feedback: /* @__PURE__ */ new Set(),
|
|
1787
|
+
feedbackFailed: /* @__PURE__ */ new Set(),
|
|
1707
1788
|
conversationProcessorError: /* @__PURE__ */ new Set()
|
|
1708
1789
|
};
|
|
1709
1790
|
}
|
|
1710
|
-
function
|
|
1791
|
+
function Ft(e, t, n) {
|
|
1711
1792
|
return e[t].add(n), () => e[t].delete(n);
|
|
1712
1793
|
}
|
|
1713
|
-
function
|
|
1794
|
+
function It(e, t, n) {
|
|
1714
1795
|
for (let r of e[t]) r(n);
|
|
1715
1796
|
}
|
|
1716
|
-
function
|
|
1797
|
+
function Lt(e) {
|
|
1717
1798
|
for (let t of Object.keys(e)) e[t].clear();
|
|
1718
1799
|
}
|
|
1719
1800
|
//#endregion
|
|
1720
1801
|
//#region src/v2/speech/types.ts
|
|
1721
|
-
function
|
|
1802
|
+
function Rt(e) {
|
|
1722
1803
|
return "data" in e && "format" in e && e.format != null && !("track" in e);
|
|
1723
1804
|
}
|
|
1724
|
-
function
|
|
1805
|
+
function zt(e) {
|
|
1725
1806
|
return "url" in e && typeof e.url == "string";
|
|
1726
1807
|
}
|
|
1727
|
-
function
|
|
1808
|
+
function Bt(e) {
|
|
1728
1809
|
if (!("track" in e)) return !1;
|
|
1729
1810
|
let t = e.track;
|
|
1730
1811
|
return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
|
|
1731
1812
|
}
|
|
1732
|
-
function
|
|
1733
|
-
return !
|
|
1813
|
+
function Vt(e) {
|
|
1814
|
+
return !Rt(e) && !zt(e) && !Bt(e) && "encoding" in e && typeof e.encoding == "string";
|
|
1734
1815
|
}
|
|
1735
|
-
var
|
|
1816
|
+
var Ht = [
|
|
1736
1817
|
8e3,
|
|
1737
1818
|
16e3,
|
|
1738
1819
|
22050,
|
|
1739
1820
|
24e3,
|
|
1740
1821
|
44100,
|
|
1741
1822
|
48e3
|
|
1742
|
-
],
|
|
1823
|
+
], Ut = {
|
|
1743
1824
|
MAX_CHUNK_BYTES: 64 * 1024,
|
|
1744
1825
|
RECOMMENDED_CHUNK_MS_MIN: 20,
|
|
1745
1826
|
RECOMMENDED_CHUNK_MS_MAX: 200,
|
|
@@ -1750,14 +1831,14 @@ var Vt = [
|
|
|
1750
1831
|
MAX_UTTERANCE_DURATION_MS: 9e4,
|
|
1751
1832
|
MAX_PENDING_WRITES: 8,
|
|
1752
1833
|
DEFAULT_WRITE_TIMEOUT_MS: 5e3
|
|
1753
|
-
},
|
|
1834
|
+
}, Wt = class extends Error {
|
|
1754
1835
|
operation;
|
|
1755
1836
|
requiredCapability;
|
|
1756
1837
|
name = "UnsupportedSpeechOperationError";
|
|
1757
1838
|
constructor(e, t) {
|
|
1758
1839
|
super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
|
|
1759
1840
|
}
|
|
1760
|
-
},
|
|
1841
|
+
}, Gt = class extends Error {
|
|
1761
1842
|
name = "SpeechUtteranceClosedError";
|
|
1762
1843
|
constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
|
|
1763
1844
|
super(e);
|
|
@@ -1767,72 +1848,72 @@ var Vt = [
|
|
|
1767
1848
|
constructor(e, t) {
|
|
1768
1849
|
super(e, t);
|
|
1769
1850
|
}
|
|
1770
|
-
},
|
|
1851
|
+
}, Kt = class extends Error {
|
|
1771
1852
|
name = "SpeechBufferTimeoutError";
|
|
1772
1853
|
constructor(e = "Timed out waiting for speech buffer capacity.") {
|
|
1773
1854
|
super(e);
|
|
1774
1855
|
}
|
|
1775
1856
|
};
|
|
1776
|
-
function
|
|
1857
|
+
function qt(e = "none") {
|
|
1777
1858
|
return {
|
|
1778
1859
|
mode: e,
|
|
1779
1860
|
trackedDurationMs: 0,
|
|
1780
1861
|
fallbackDurationMs: 0
|
|
1781
1862
|
};
|
|
1782
1863
|
}
|
|
1783
|
-
function qt(e) {
|
|
1784
|
-
return Vt.includes(e);
|
|
1785
|
-
}
|
|
1786
1864
|
function Jt(e) {
|
|
1865
|
+
return Ht.includes(e);
|
|
1866
|
+
}
|
|
1867
|
+
function Yt(e) {
|
|
1787
1868
|
if (e.encoding !== "pcm_s16le") throw new Q(`Unsupported audio encoding: ${e.encoding}`);
|
|
1788
1869
|
if (e.channels !== 1) throw new Q(`Unsupported channel count: ${e.channels}`);
|
|
1789
|
-
if (!
|
|
1870
|
+
if (!Jt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1790
1871
|
}
|
|
1791
|
-
function
|
|
1792
|
-
if (
|
|
1793
|
-
|
|
1872
|
+
function Xt(e) {
|
|
1873
|
+
if (Rt(e)) {
|
|
1874
|
+
Yt(e.format);
|
|
1794
1875
|
return;
|
|
1795
1876
|
}
|
|
1796
|
-
if (
|
|
1877
|
+
if (zt(e)) {
|
|
1797
1878
|
if (!e.url.trim()) throw new Q("Audio URL must be non-empty.");
|
|
1798
|
-
if (e.sampleRate !== void 0 && !
|
|
1879
|
+
if (e.sampleRate !== void 0 && !Jt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1799
1880
|
return;
|
|
1800
1881
|
}
|
|
1801
|
-
if (
|
|
1882
|
+
if (Bt(e)) {
|
|
1802
1883
|
if (e.track.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
1803
|
-
if (e.sampleRate !== void 0 && !
|
|
1884
|
+
if (e.sampleRate !== void 0 && !Jt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1804
1885
|
return;
|
|
1805
1886
|
}
|
|
1806
|
-
if (
|
|
1887
|
+
if (Vt(e)) {
|
|
1807
1888
|
let t = e.encoding.trim().toLowerCase();
|
|
1808
1889
|
if (!t) throw new Q("Encoded audio MIME type is required.");
|
|
1809
1890
|
if (t === "pcm_s16le") throw new Q("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
|
|
1810
|
-
if (e.sampleRate !== void 0 && !
|
|
1891
|
+
if (e.sampleRate !== void 0 && !Jt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1811
1892
|
return;
|
|
1812
1893
|
}
|
|
1813
1894
|
throw new Q("Unsupported speech.play audio shape.");
|
|
1814
1895
|
}
|
|
1815
|
-
function
|
|
1816
|
-
if (e.format) return
|
|
1896
|
+
function Zt(e) {
|
|
1897
|
+
if (e.format) return Yt(e.format), e.format;
|
|
1817
1898
|
if (e.track) {
|
|
1818
1899
|
let t = {
|
|
1819
1900
|
encoding: "pcm_s16le",
|
|
1820
1901
|
sampleRate: e.sampleRate ?? 24e3,
|
|
1821
1902
|
channels: 1
|
|
1822
1903
|
};
|
|
1823
|
-
return
|
|
1904
|
+
return Yt(t), t;
|
|
1824
1905
|
}
|
|
1825
1906
|
throw new Q("createUtterance requires format or track.");
|
|
1826
1907
|
}
|
|
1827
|
-
function
|
|
1908
|
+
function Qt(e) {
|
|
1828
1909
|
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1829
1910
|
}
|
|
1830
|
-
function
|
|
1911
|
+
function $t(e) {
|
|
1831
1912
|
return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
|
|
1832
1913
|
}
|
|
1833
1914
|
//#endregion
|
|
1834
1915
|
//#region src/byo/pcm.ts
|
|
1835
|
-
function
|
|
1916
|
+
function en(e) {
|
|
1836
1917
|
let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
|
|
1837
1918
|
for (let t = 0; t < e.length; t++) {
|
|
1838
1919
|
let r = Math.max(-1, Math.min(1, e[t]));
|
|
@@ -1842,11 +1923,11 @@ function $t(e) {
|
|
|
1842
1923
|
}
|
|
1843
1924
|
//#endregion
|
|
1844
1925
|
//#region src/byo/resample.ts
|
|
1845
|
-
function
|
|
1926
|
+
function tn(e, t, n, r, i) {
|
|
1846
1927
|
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;
|
|
1847
1928
|
return ((a * i + o) * i + s) * i + c;
|
|
1848
1929
|
}
|
|
1849
|
-
function
|
|
1930
|
+
function nn(e, t) {
|
|
1850
1931
|
if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
|
|
1851
1932
|
if (e === t) return {
|
|
1852
1933
|
fromRate: e,
|
|
@@ -1869,7 +1950,7 @@ function tn(e, t) {
|
|
|
1869
1950
|
let a = [];
|
|
1870
1951
|
for (; i + 2 < r.length - 1;) {
|
|
1871
1952
|
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);
|
|
1872
|
-
a.push(
|
|
1953
|
+
a.push(tn(r[o], r[e], r[s], r[c], t)), i += n;
|
|
1873
1954
|
}
|
|
1874
1955
|
let o = Math.max(0, Math.floor(i) - 1);
|
|
1875
1956
|
return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
|
|
@@ -1881,7 +1962,7 @@ function tn(e, t) {
|
|
|
1881
1962
|
}
|
|
1882
1963
|
//#endregion
|
|
1883
1964
|
//#region src/byo/audioCapture.ts
|
|
1884
|
-
var
|
|
1965
|
+
var rn = "liforma-pcm-capture", an = `
|
|
1885
1966
|
class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
1886
1967
|
process(inputs) {
|
|
1887
1968
|
const ch = inputs[0] && inputs[0][0];
|
|
@@ -1893,29 +1974,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
|
1893
1974
|
return true;
|
|
1894
1975
|
}
|
|
1895
1976
|
}
|
|
1896
|
-
registerProcessor('${
|
|
1897
|
-
`,
|
|
1898
|
-
function on() {
|
|
1899
|
-
return an ||= URL.createObjectURL(new Blob([rn], { type: "application/javascript" })), an;
|
|
1900
|
-
}
|
|
1977
|
+
registerProcessor('${rn}', LiformaPcmCaptureProcessor);
|
|
1978
|
+
`, on = null;
|
|
1901
1979
|
function sn() {
|
|
1980
|
+
return on ||= URL.createObjectURL(new Blob([an], { type: "application/javascript" })), on;
|
|
1981
|
+
}
|
|
1982
|
+
function cn() {
|
|
1902
1983
|
return window.AudioContext || window.webkitAudioContext || null;
|
|
1903
1984
|
}
|
|
1904
|
-
async function
|
|
1905
|
-
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o =
|
|
1985
|
+
async function ln(e) {
|
|
1986
|
+
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = cn();
|
|
1906
1987
|
if (!o) throw Error("Web Audio is required for audio capture");
|
|
1907
1988
|
let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
|
|
1908
1989
|
l.gain.value = 0;
|
|
1909
|
-
let u = s.sampleRate, d =
|
|
1990
|
+
let u = s.sampleRate, d = nn(u, n), f = !1, p = !1, m = (e) => {
|
|
1910
1991
|
if (f || i && !i()) return;
|
|
1911
1992
|
let t = d.push(e);
|
|
1912
|
-
t.length !== 0 && r(
|
|
1993
|
+
t.length !== 0 && r(en(t));
|
|
1913
1994
|
}, h = () => void 0;
|
|
1914
1995
|
return await (async () => {
|
|
1915
1996
|
if (typeof s.audioWorklet?.addModule != "function") return !1;
|
|
1916
1997
|
try {
|
|
1917
|
-
await s.audioWorklet.addModule(
|
|
1918
|
-
let e = new AudioWorkletNode(s,
|
|
1998
|
+
await s.audioWorklet.addModule(sn());
|
|
1999
|
+
let e = new AudioWorkletNode(s, rn, {
|
|
1919
2000
|
numberOfInputs: 1,
|
|
1920
2001
|
numberOfOutputs: 1,
|
|
1921
2002
|
outputChannelCount: [1]
|
|
@@ -1965,7 +2046,7 @@ async function cn(e) {
|
|
|
1965
2046
|
}
|
|
1966
2047
|
//#endregion
|
|
1967
2048
|
//#region src/v2/speech/captureMediaStreamTrack.ts
|
|
1968
|
-
async function
|
|
2049
|
+
async function un(e) {
|
|
1969
2050
|
let { track: t, utterance: n, sampleRate: r, signal: i } = e;
|
|
1970
2051
|
if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Q("MediaStreamTrack is not available in this environment.");
|
|
1971
2052
|
if (t.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
@@ -1974,18 +2055,18 @@ async function ln(e) {
|
|
|
1974
2055
|
s || (s = !0, c?.stop(), c = null);
|
|
1975
2056
|
};
|
|
1976
2057
|
try {
|
|
1977
|
-
c = await
|
|
2058
|
+
c = await ln({
|
|
1978
2059
|
mediaStream: a,
|
|
1979
2060
|
targetSampleRate: r,
|
|
1980
2061
|
shouldSend: () => !s && !i?.aborted,
|
|
1981
2062
|
onPcm: (e) => {
|
|
1982
2063
|
if (s || i?.aborted) return;
|
|
1983
|
-
let t =
|
|
2064
|
+
let t = Qt(e);
|
|
1984
2065
|
o = o.then(async () => {
|
|
1985
2066
|
if (s || i?.aborted) return;
|
|
1986
2067
|
let e = 0;
|
|
1987
2068
|
for (; e < t.byteLength;) {
|
|
1988
|
-
let r = Math.min(e +
|
|
2069
|
+
let r = Math.min(e + Ut.MAX_CHUNK_BYTES, t.byteLength);
|
|
1989
2070
|
if ((r - e) % 2 == 1 && --r, r <= e) break;
|
|
1990
2071
|
let i = t.subarray(e, r);
|
|
1991
2072
|
e = r, i.byteLength !== 0 && await n.write(i);
|
|
@@ -2009,10 +2090,10 @@ async function ln(e) {
|
|
|
2009
2090
|
}
|
|
2010
2091
|
//#endregion
|
|
2011
2092
|
//#region src/v2/speech/speechController.ts
|
|
2012
|
-
async function
|
|
2013
|
-
if (
|
|
2014
|
-
if (
|
|
2015
|
-
let t =
|
|
2093
|
+
async function dn(e, t) {
|
|
2094
|
+
if (Bt(e)) throw new Q("MediaStreamTrack play is handled on the host before embed.");
|
|
2095
|
+
if (Rt(e)) {
|
|
2096
|
+
let t = Qt(e.data);
|
|
2016
2097
|
if (t.byteLength & 1) throw new Q("PCM byte length must be even.");
|
|
2017
2098
|
return {
|
|
2018
2099
|
kind: "pcm",
|
|
@@ -2020,17 +2101,17 @@ async function un(e, t) {
|
|
|
2020
2101
|
format: e.format
|
|
2021
2102
|
};
|
|
2022
2103
|
}
|
|
2023
|
-
if (
|
|
2104
|
+
if (zt(e)) return {
|
|
2024
2105
|
kind: "url",
|
|
2025
2106
|
url: e.url.trim(),
|
|
2026
2107
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
2027
2108
|
};
|
|
2028
|
-
if (!
|
|
2109
|
+
if (!Vt(e)) throw new Q("Unsupported speech.play audio shape.");
|
|
2029
2110
|
let n;
|
|
2030
2111
|
if (typeof Blob < "u" && e.data instanceof Blob) {
|
|
2031
2112
|
if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2032
2113
|
n = new Uint8Array(await e.data.arrayBuffer());
|
|
2033
|
-
} else n =
|
|
2114
|
+
} else n = Qt(e.data);
|
|
2034
2115
|
return {
|
|
2035
2116
|
kind: "encoded",
|
|
2036
2117
|
data: n.slice().buffer,
|
|
@@ -2038,10 +2119,10 @@ async function un(e, t) {
|
|
|
2038
2119
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
2039
2120
|
};
|
|
2040
2121
|
}
|
|
2041
|
-
function
|
|
2122
|
+
function fn() {
|
|
2042
2123
|
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)}`;
|
|
2043
2124
|
}
|
|
2044
|
-
function
|
|
2125
|
+
function pn(e, t = "completed") {
|
|
2045
2126
|
return {
|
|
2046
2127
|
utteranceId: e.speechId,
|
|
2047
2128
|
characterId: e.characterId,
|
|
@@ -2055,13 +2136,13 @@ function fn(e, t = "completed") {
|
|
|
2055
2136
|
}
|
|
2056
2137
|
};
|
|
2057
2138
|
}
|
|
2058
|
-
function
|
|
2139
|
+
function mn(e) {
|
|
2059
2140
|
return e instanceof Error ? e : new Q(String(e));
|
|
2060
2141
|
}
|
|
2061
|
-
function
|
|
2142
|
+
function hn(e) {
|
|
2062
2143
|
return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
|
|
2063
2144
|
}
|
|
2064
|
-
var
|
|
2145
|
+
var gn = class {
|
|
2065
2146
|
id;
|
|
2066
2147
|
characterId;
|
|
2067
2148
|
result;
|
|
@@ -2090,29 +2171,29 @@ var hn = class {
|
|
|
2090
2171
|
queue: e.queue,
|
|
2091
2172
|
...e.transcript === void 0 ? {} : { transcript: e.transcript }
|
|
2092
2173
|
}).catch((e) => {
|
|
2093
|
-
throw this.fail(
|
|
2174
|
+
throw this.fail(mn(e)), mn(e);
|
|
2094
2175
|
}), this.signal?.addEventListener("abort", () => {
|
|
2095
2176
|
this.cancel();
|
|
2096
2177
|
}, { once: !0 });
|
|
2097
2178
|
}
|
|
2098
2179
|
async write(e, t) {
|
|
2099
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2100
|
-
let n =
|
|
2180
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new Gt();
|
|
2181
|
+
let n = Qt(e);
|
|
2101
2182
|
if (n.byteLength & 1) throw new Q("PCM chunk byte length must be even (complete s16 samples).");
|
|
2102
|
-
if (n.byteLength >
|
|
2183
|
+
if (n.byteLength > Ut.MAX_CHUNK_BYTES) throw new Q(`PCM chunk exceeds MAX_CHUNK_BYTES (${Ut.MAX_CHUNK_BYTES}).`);
|
|
2103
2184
|
if (n.byteLength === 0) return;
|
|
2104
|
-
let r = t?.timeoutMs ??
|
|
2185
|
+
let r = t?.timeoutMs ?? Ut.DEFAULT_WRITE_TIMEOUT_MS;
|
|
2105
2186
|
await this.acquireWriteSlot(r);
|
|
2106
2187
|
let i = n.byteLength / 2 / this.sampleRate * 1e3;
|
|
2107
|
-
if (this.bufferedMs + i >
|
|
2188
|
+
if (this.bufferedMs + i > Ut.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new Q("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
|
|
2108
2189
|
let a = async () => {
|
|
2109
|
-
if (this.closed || this.settled) throw new
|
|
2190
|
+
if (this.closed || this.settled) throw new Gt();
|
|
2110
2191
|
let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
|
|
2111
2192
|
utteranceId: this.id,
|
|
2112
2193
|
audio: t.buffer,
|
|
2113
2194
|
byteLength: t.byteLength
|
|
2114
2195
|
}), a = await Promise.race([i, new Promise((e, t) => {
|
|
2115
|
-
setTimeout(() => t(new
|
|
2196
|
+
setTimeout(() => t(new Kt()), r);
|
|
2116
2197
|
})]);
|
|
2117
2198
|
this.bufferedMs = Math.max(0, a.bufferedMs);
|
|
2118
2199
|
}, o = this.writeChain.then(a, a);
|
|
@@ -2124,7 +2205,7 @@ var hn = class {
|
|
|
2124
2205
|
}
|
|
2125
2206
|
}
|
|
2126
2207
|
async setTranscript(e) {
|
|
2127
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2208
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new Gt();
|
|
2128
2209
|
await this.requireHost().speechUtteranceSetTranscript({
|
|
2129
2210
|
utteranceId: this.id,
|
|
2130
2211
|
transcript: e
|
|
@@ -2141,7 +2222,7 @@ var hn = class {
|
|
|
2141
2222
|
});
|
|
2142
2223
|
return this.resolve(t), t;
|
|
2143
2224
|
} catch (e) {
|
|
2144
|
-
let t =
|
|
2225
|
+
let t = mn(e);
|
|
2145
2226
|
throw this.fail(t), t;
|
|
2146
2227
|
}
|
|
2147
2228
|
}
|
|
@@ -2159,11 +2240,11 @@ var hn = class {
|
|
|
2159
2240
|
characterId: this.characterId,
|
|
2160
2241
|
status: "cancelled",
|
|
2161
2242
|
durationMs: 0,
|
|
2162
|
-
animation:
|
|
2243
|
+
animation: qt("none")
|
|
2163
2244
|
};
|
|
2164
2245
|
return this.resolve(t), t;
|
|
2165
2246
|
} catch (e) {
|
|
2166
|
-
let t =
|
|
2247
|
+
let t = mn(e);
|
|
2167
2248
|
throw this.fail(t), t;
|
|
2168
2249
|
}
|
|
2169
2250
|
}
|
|
@@ -2176,19 +2257,19 @@ var hn = class {
|
|
|
2176
2257
|
return e;
|
|
2177
2258
|
}
|
|
2178
2259
|
resolve(e) {
|
|
2179
|
-
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new
|
|
2260
|
+
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new Gt()));
|
|
2180
2261
|
}
|
|
2181
2262
|
fail(e) {
|
|
2182
2263
|
this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
|
|
2183
2264
|
}
|
|
2184
2265
|
async acquireWriteSlot(e) {
|
|
2185
|
-
if (this.pendingWriteCount <
|
|
2266
|
+
if (this.pendingWriteCount < Ut.MAX_PENDING_WRITES) {
|
|
2186
2267
|
this.pendingWriteCount += 1;
|
|
2187
2268
|
return;
|
|
2188
2269
|
}
|
|
2189
2270
|
await new Promise((t, n) => {
|
|
2190
2271
|
let r = setTimeout(() => {
|
|
2191
|
-
n(new
|
|
2272
|
+
n(new Kt());
|
|
2192
2273
|
}, e);
|
|
2193
2274
|
this.pendingWriteWaiters.push({
|
|
2194
2275
|
resolve: () => {
|
|
@@ -2207,13 +2288,13 @@ var hn = class {
|
|
|
2207
2288
|
for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
|
|
2208
2289
|
}
|
|
2209
2290
|
};
|
|
2210
|
-
function
|
|
2291
|
+
function _n(e) {
|
|
2211
2292
|
let t = null, n = (t, n) => {
|
|
2212
|
-
if (!e.getCapabilities()[n]) throw new
|
|
2293
|
+
if (!e.getCapabilities()[n]) throw new Wt(t, n);
|
|
2213
2294
|
}, r = {
|
|
2214
2295
|
async speak(r) {
|
|
2215
2296
|
if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
|
|
2216
|
-
let i =
|
|
2297
|
+
let i = $t(r.queue ?? "append");
|
|
2217
2298
|
i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
|
|
2218
2299
|
let a = e.getIframeHost();
|
|
2219
2300
|
if (!a) throw new Q("Speech session is not attached.");
|
|
@@ -2233,41 +2314,41 @@ function gn(e) {
|
|
|
2233
2314
|
return;
|
|
2234
2315
|
}
|
|
2235
2316
|
t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
|
|
2236
|
-
t.removeEventListener("abort", s), n(
|
|
2317
|
+
t.removeEventListener("abort", s), n(pn(e, "completed"));
|
|
2237
2318
|
}, (a) => {
|
|
2238
|
-
if (t.removeEventListener("abort", s),
|
|
2319
|
+
if (t.removeEventListener("abort", s), hn(a)) {
|
|
2239
2320
|
n({
|
|
2240
2321
|
utteranceId: "utt_interrupted",
|
|
2241
2322
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2242
2323
|
status: "interrupted",
|
|
2243
2324
|
durationMs: 0,
|
|
2244
2325
|
transcript: r.text,
|
|
2245
|
-
animation:
|
|
2326
|
+
animation: qt("none")
|
|
2246
2327
|
});
|
|
2247
2328
|
return;
|
|
2248
2329
|
}
|
|
2249
|
-
i(
|
|
2330
|
+
i(mn(a));
|
|
2250
2331
|
});
|
|
2251
2332
|
});
|
|
2252
2333
|
}
|
|
2253
2334
|
try {
|
|
2254
|
-
return
|
|
2335
|
+
return pn(await o, "completed");
|
|
2255
2336
|
} catch (t) {
|
|
2256
|
-
if (
|
|
2337
|
+
if (hn(t)) return {
|
|
2257
2338
|
utteranceId: "utt_interrupted",
|
|
2258
2339
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2259
2340
|
status: "interrupted",
|
|
2260
2341
|
durationMs: 0,
|
|
2261
2342
|
transcript: r.text,
|
|
2262
|
-
animation:
|
|
2343
|
+
animation: qt("none")
|
|
2263
2344
|
};
|
|
2264
|
-
throw
|
|
2345
|
+
throw mn(t);
|
|
2265
2346
|
}
|
|
2266
2347
|
},
|
|
2267
2348
|
async play(i) {
|
|
2268
|
-
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"),
|
|
2349
|
+
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), Xt(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2269
2350
|
let a = i.queue ?? "append";
|
|
2270
|
-
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)),
|
|
2351
|
+
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), Bt(i.audio)) {
|
|
2271
2352
|
let e = i.audio.sampleRate ?? 24e3;
|
|
2272
2353
|
return r.createUtterance({
|
|
2273
2354
|
format: {
|
|
@@ -2283,7 +2364,7 @@ function gn(e) {
|
|
|
2283
2364
|
}
|
|
2284
2365
|
let o = e.getIframeHost();
|
|
2285
2366
|
if (!o) throw new Q("Speech session is not attached.");
|
|
2286
|
-
let s = await
|
|
2367
|
+
let s = await dn(i.audio, i.signal);
|
|
2287
2368
|
return o.speechPlay({
|
|
2288
2369
|
source: s,
|
|
2289
2370
|
characterId: i.characterId,
|
|
@@ -2295,13 +2376,13 @@ function gn(e) {
|
|
|
2295
2376
|
},
|
|
2296
2377
|
createUtterance(r) {
|
|
2297
2378
|
e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
|
|
2298
|
-
let i =
|
|
2379
|
+
let i = Zt(r);
|
|
2299
2380
|
if (r.track && r.track.kind !== "audio") throw new Q("createUtterance track must be an audio MediaStreamTrack.");
|
|
2300
2381
|
let a = r.queue ?? "replace-active";
|
|
2301
2382
|
if (a !== "replace-active" && a !== "replace-all") throw new Q("createUtterance queue must be replace-active or replace-all.");
|
|
2302
2383
|
e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
|
|
2303
|
-
let o = new
|
|
2304
|
-
id:
|
|
2384
|
+
let o = new gn({
|
|
2385
|
+
id: fn(),
|
|
2305
2386
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2306
2387
|
format: i,
|
|
2307
2388
|
queue: a,
|
|
@@ -2313,7 +2394,7 @@ function gn(e) {
|
|
|
2313
2394
|
t === o && (t = null);
|
|
2314
2395
|
}), r.track && (async () => {
|
|
2315
2396
|
try {
|
|
2316
|
-
if (await
|
|
2397
|
+
if (await un({
|
|
2317
2398
|
track: r.track,
|
|
2318
2399
|
utterance: o,
|
|
2319
2400
|
sampleRate: i.sampleRate,
|
|
@@ -2340,11 +2421,17 @@ function gn(e) {
|
|
|
2340
2421
|
return r;
|
|
2341
2422
|
}
|
|
2342
2423
|
//#endregion
|
|
2424
|
+
//#region src/v2/types/sessionInteraction.ts
|
|
2425
|
+
function vn(e) {
|
|
2426
|
+
let t = e?.trim();
|
|
2427
|
+
return t === "full" || t === "face" || t === "medium" ? t : void 0;
|
|
2428
|
+
}
|
|
2429
|
+
//#endregion
|
|
2343
2430
|
//#region src/v2/experience.ts
|
|
2344
|
-
function
|
|
2431
|
+
function yn(e) {
|
|
2345
2432
|
return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
|
|
2346
2433
|
}
|
|
2347
|
-
var
|
|
2434
|
+
var bn = class e {
|
|
2348
2435
|
bootstrap;
|
|
2349
2436
|
conversationProcessor;
|
|
2350
2437
|
iframeHost = null;
|
|
@@ -2357,17 +2444,18 @@ var vn = class e {
|
|
|
2357
2444
|
attachReturnUrl = null;
|
|
2358
2445
|
closed = !1;
|
|
2359
2446
|
attached = !1;
|
|
2447
|
+
pendingFit = null;
|
|
2360
2448
|
closeHandlers = [];
|
|
2361
|
-
eventRegistry =
|
|
2449
|
+
eventRegistry = Pt();
|
|
2362
2450
|
readyEnvelope = null;
|
|
2363
2451
|
startedEnvelope = null;
|
|
2364
2452
|
conversationCache = [];
|
|
2365
2453
|
speech;
|
|
2366
2454
|
constructor(e) {
|
|
2367
|
-
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 =
|
|
2455
|
+
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({
|
|
2368
2456
|
getIframeHost: () => this.iframeHost,
|
|
2369
2457
|
assertSessionStarted: () => this.assertSessionStarted(),
|
|
2370
|
-
getCapabilities: () =>
|
|
2458
|
+
getCapabilities: () => xn(this.resolvedSession),
|
|
2371
2459
|
getActiveCharacterId: () => "character_unknown",
|
|
2372
2460
|
onProcessorInterrupt: () => {
|
|
2373
2461
|
this.processorAbortController?.abort(), this.processorAbortController = null;
|
|
@@ -2401,6 +2489,7 @@ var vn = class e {
|
|
|
2401
2489
|
language: t.language,
|
|
2402
2490
|
locationId: t.locationId,
|
|
2403
2491
|
avatarId: t.avatarId,
|
|
2492
|
+
castSize: t.castSize,
|
|
2404
2493
|
embedBaseUrl: t.embedBaseUrl,
|
|
2405
2494
|
debug: t.debug,
|
|
2406
2495
|
mode: t.mode,
|
|
@@ -2420,6 +2509,7 @@ var vn = class e {
|
|
|
2420
2509
|
language: t.language,
|
|
2421
2510
|
locationId: t.locationId,
|
|
2422
2511
|
avatarId: t.avatarId,
|
|
2512
|
+
castSize: t.castSize,
|
|
2423
2513
|
embedBaseUrl: t.embedBaseUrl,
|
|
2424
2514
|
debug: t.debug,
|
|
2425
2515
|
mode: t.mode,
|
|
@@ -2439,7 +2529,7 @@ var vn = class e {
|
|
|
2439
2529
|
return null;
|
|
2440
2530
|
}
|
|
2441
2531
|
on(e, t) {
|
|
2442
|
-
let n =
|
|
2532
|
+
let n = Ft(this.eventRegistry, e, t);
|
|
2443
2533
|
return e === "ready" && this.readyEnvelope && queueMicrotask(() => t(this.readyEnvelope)), e === "started" && this.startedEnvelope && queueMicrotask(() => t(this.startedEnvelope)), n;
|
|
2444
2534
|
}
|
|
2445
2535
|
async attach(e) {
|
|
@@ -2453,13 +2543,13 @@ var vn = class e {
|
|
|
2453
2543
|
if (this.closed) throw Error("Session has ended.");
|
|
2454
2544
|
if (this.attached && this.iframeHost) return this.createPlayerFacade();
|
|
2455
2545
|
this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
|
|
2456
|
-
let t = this.bootstrap.embedBaseUrl ??
|
|
2546
|
+
let t = this.bootstrap.embedBaseUrl ?? Ot(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = kt(t, n, r || this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.locationId, r || this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, yn(e), this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.castSize), a = jt(i), o = null, s = new Promise((e) => {
|
|
2457
2547
|
o = e;
|
|
2458
2548
|
}), c = null, l = new Promise((e) => {
|
|
2459
2549
|
c = e;
|
|
2460
|
-
}), u =
|
|
2550
|
+
}), u = wt((e) => {
|
|
2461
2551
|
this.readyEnvelope ||= (this.resolvedSession = e, this.emitWrapped("ready", { session: e }));
|
|
2462
|
-
}), d = this.bootstrap.onUserTranscript, f =
|
|
2552
|
+
}), d = this.bootstrap.onUserTranscript, f = Ct({
|
|
2463
2553
|
container: e.container,
|
|
2464
2554
|
src: i,
|
|
2465
2555
|
playerOrigin: a,
|
|
@@ -2489,12 +2579,21 @@ var vn = class e {
|
|
|
2489
2579
|
onCharacterSpeechEnded: (e) => {
|
|
2490
2580
|
this.emitWrapped("characterSpeechEnded", e);
|
|
2491
2581
|
},
|
|
2582
|
+
onCharacterFocusChanged: (e) => {
|
|
2583
|
+
this.emitWrapped("characterFocusChanged", e);
|
|
2584
|
+
},
|
|
2492
2585
|
onListeningState: (e) => {
|
|
2493
2586
|
this.emitWrapped("listeningState", e);
|
|
2494
2587
|
},
|
|
2495
2588
|
onActivityChange: (e) => {
|
|
2496
2589
|
this.emitWrapped("activityChange", e);
|
|
2497
2590
|
},
|
|
2591
|
+
onFeedback: (e) => {
|
|
2592
|
+
this.emitWrapped("feedback", e);
|
|
2593
|
+
},
|
|
2594
|
+
onFeedbackFailed: (e) => {
|
|
2595
|
+
this.emitWrapped("feedbackFailed", e);
|
|
2596
|
+
},
|
|
2498
2597
|
onMessage: (e) => {
|
|
2499
2598
|
this.emitWrapped("message", e);
|
|
2500
2599
|
},
|
|
@@ -2513,7 +2612,7 @@ var vn = class e {
|
|
|
2513
2612
|
onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t)
|
|
2514
2613
|
});
|
|
2515
2614
|
this.iframeHost = f;
|
|
2516
|
-
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(),
|
|
2615
|
+
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), at(this.bootstrap.sessionEndpoint, {
|
|
2517
2616
|
experienceId: this.bootstrap.experienceId,
|
|
2518
2617
|
locale: this.bootstrap.locale,
|
|
2519
2618
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
@@ -2523,7 +2622,7 @@ var vn = class e {
|
|
|
2523
2622
|
speechInputMode: p.speechInputMode,
|
|
2524
2623
|
speechOnly: this.bootstrap.speechOnly,
|
|
2525
2624
|
signal: this.endpointAbortController.signal
|
|
2526
|
-
})) : this.bootstrap.kind === "public" ?
|
|
2625
|
+
})) : this.bootstrap.kind === "public" ? it(this.bootstrap.experienceId, {
|
|
2527
2626
|
locale: this.bootstrap.locale,
|
|
2528
2627
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
2529
2628
|
learningLocale: this.bootstrap.learningLocale,
|
|
@@ -2545,11 +2644,17 @@ var vn = class e {
|
|
|
2545
2644
|
f.postParentHello();
|
|
2546
2645
|
let g = h?.launch ?? (this.bootstrap.kind === "launch" ? this.bootstrap.launch : null), _ = h?.session ?? (this.bootstrap.kind === "launch" ? this.bootstrap.session : void 0);
|
|
2547
2646
|
if (!g) throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), Error("Session Launch response did not include a launch token.");
|
|
2548
|
-
return this.launchToken = g, _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" &&
|
|
2647
|
+
return this.launchToken = g, _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" && Xe(_), f.postLaunch(g, _, {
|
|
2648
|
+
startButton: e.startButton,
|
|
2649
|
+
showFeedback: e.showFeedback
|
|
2650
|
+
}), u.setValue(_)) : f.postLaunch(g, void 0, {
|
|
2651
|
+
startButton: e.startButton,
|
|
2652
|
+
showFeedback: e.showFeedback
|
|
2653
|
+
}), await Promise.race([s, new Promise((e, t) => {
|
|
2549
2654
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player loading UI.")), 12e4);
|
|
2550
2655
|
})]), await Promise.race([l, new Promise((e, t) => {
|
|
2551
2656
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player ready state.")), 12e4);
|
|
2552
|
-
})]), this.attached = !0, this.createPlayerFacade();
|
|
2657
|
+
})]), this.attached = !0, this.pendingFit && await f.setFit(this.pendingFit), this.createPlayerFacade();
|
|
2553
2658
|
}
|
|
2554
2659
|
async startListening() {
|
|
2555
2660
|
this.assertSessionStarted(), await this.iframeHost.startListening();
|
|
@@ -2569,6 +2674,15 @@ var vn = class e {
|
|
|
2569
2674
|
toggleAudioSettings() {
|
|
2570
2675
|
this.iframeHost?.postWidgetToggleAudioSettings();
|
|
2571
2676
|
}
|
|
2677
|
+
async focusCharacter(e) {
|
|
2678
|
+
this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
|
|
2679
|
+
}
|
|
2680
|
+
async setFit(e) {
|
|
2681
|
+
let t = vn(e);
|
|
2682
|
+
if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
|
|
2683
|
+
if (this.closed) throw Error("Session has ended.");
|
|
2684
|
+
this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
|
|
2685
|
+
}
|
|
2572
2686
|
getLastTurn() {
|
|
2573
2687
|
if (this.conversationCache.length === 0) return [];
|
|
2574
2688
|
let e = this.conversationCache[this.conversationCache.length - 1].turnId;
|
|
@@ -2578,7 +2692,7 @@ var vn = class e {
|
|
|
2578
2692
|
this.close();
|
|
2579
2693
|
}
|
|
2580
2694
|
destroy() {
|
|
2581
|
-
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,
|
|
2695
|
+
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, Lt(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.attached = !1);
|
|
2582
2696
|
}
|
|
2583
2697
|
resolveMintInteraction() {
|
|
2584
2698
|
return this.bootstrap.kind === "launch" ? {} : {
|
|
@@ -2590,8 +2704,8 @@ var vn = class e {
|
|
|
2590
2704
|
return this.resolvedSession?.id ?? "";
|
|
2591
2705
|
}
|
|
2592
2706
|
emitWrapped(e, t) {
|
|
2593
|
-
let n =
|
|
2594
|
-
return
|
|
2707
|
+
let n = Nt(e, this.getSessionId(), t);
|
|
2708
|
+
return It(this.eventRegistry, e, n), n;
|
|
2595
2709
|
}
|
|
2596
2710
|
queueProcessorTurn(e) {
|
|
2597
2711
|
if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
|
|
@@ -2600,7 +2714,7 @@ var vn = class e {
|
|
|
2600
2714
|
let n = this.processorAbortController.signal;
|
|
2601
2715
|
this.processorChain = this.processorChain.then(async () => {
|
|
2602
2716
|
if (!n.aborted) try {
|
|
2603
|
-
let r = await
|
|
2717
|
+
let r = await ct(t, {
|
|
2604
2718
|
utteranceId: e.utteranceId,
|
|
2605
2719
|
text: e.text,
|
|
2606
2720
|
conversation: this.conversationCache,
|
|
@@ -2650,7 +2764,7 @@ var vn = class e {
|
|
|
2650
2764
|
};
|
|
2651
2765
|
}
|
|
2652
2766
|
};
|
|
2653
|
-
function
|
|
2767
|
+
function xn(e) {
|
|
2654
2768
|
return e ? {
|
|
2655
2769
|
textSpeech: e.capabilities.speech.output,
|
|
2656
2770
|
externalSpeechAudio: e.capabilities.speech.externalAudio
|
|
@@ -2661,41 +2775,41 @@ function yn(e) {
|
|
|
2661
2775
|
}
|
|
2662
2776
|
//#endregion
|
|
2663
2777
|
//#region src/widget/dockGeometry.ts
|
|
2664
|
-
var
|
|
2665
|
-
function
|
|
2778
|
+
var Sn = "(min-width: 768px)", Cn = 24, wn = .5, Tn = 1200, En = .85, Dn = 9 / 16;
|
|
2779
|
+
function On() {
|
|
2666
2780
|
if (typeof window > "u") return 800;
|
|
2667
2781
|
let e = window.screen?.availHeight;
|
|
2668
2782
|
return typeof e == "number" && e > 0 ? e : window.innerHeight;
|
|
2669
2783
|
}
|
|
2670
|
-
function
|
|
2671
|
-
let i = Math.max(160, Math.min(t - n * 2, t *
|
|
2672
|
-
return s > a && (s = a, o = s /
|
|
2784
|
+
function kn(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = Cn, r = typeof window < "u" ? On() : 800) {
|
|
2785
|
+
let i = Math.max(160, Math.min(t - n * 2, t * En)), a = Math.max(120, e - n * 2), o = Math.min(r * wn, Tn, i), s = o * Dn;
|
|
2786
|
+
return s > a && (s = a, o = s / Dn, o > i && (o = i, s = o * Dn)), {
|
|
2673
2787
|
width: Math.round(s),
|
|
2674
2788
|
height: Math.round(o)
|
|
2675
2789
|
};
|
|
2676
2790
|
}
|
|
2677
|
-
function
|
|
2791
|
+
function An(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = Cn) {
|
|
2678
2792
|
return {
|
|
2679
2793
|
left: Math.max(r, t - e.width - r),
|
|
2680
2794
|
top: Math.max(r, n - e.height - r)
|
|
2681
2795
|
};
|
|
2682
2796
|
}
|
|
2683
|
-
function
|
|
2797
|
+
function jn(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = Cn) {
|
|
2684
2798
|
let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
|
|
2685
2799
|
return {
|
|
2686
2800
|
left: Math.min(Math.max(a, e), o),
|
|
2687
2801
|
top: Math.min(Math.max(a, t), s)
|
|
2688
2802
|
};
|
|
2689
2803
|
}
|
|
2690
|
-
function
|
|
2691
|
-
return e(
|
|
2804
|
+
function Mn(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
|
|
2805
|
+
return e(Sn).matches;
|
|
2692
2806
|
}
|
|
2693
2807
|
//#endregion
|
|
2694
2808
|
//#region src/widget/mountExperienceWidget.ts
|
|
2695
|
-
function
|
|
2809
|
+
function Nn(e) {
|
|
2696
2810
|
return e === "bottom-right" || e === "bottom-left" ? e : "static";
|
|
2697
2811
|
}
|
|
2698
|
-
function
|
|
2812
|
+
function Pn(e) {
|
|
2699
2813
|
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
2700
2814
|
let t = typeof e == "string" ? e.trim() : "";
|
|
2701
2815
|
return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
|
|
@@ -2703,10 +2817,10 @@ function Mn(e) {
|
|
|
2703
2817
|
function $(e) {
|
|
2704
2818
|
return e === "expanded" || e === "docked";
|
|
2705
2819
|
}
|
|
2706
|
-
var
|
|
2707
|
-
function
|
|
2708
|
-
Ee
|
|
2709
|
-
let r =
|
|
2820
|
+
var Fn = "<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>", In = "<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>", Ln = "<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>", Rn = "<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>";
|
|
2821
|
+
function zn(e, t, n) {
|
|
2822
|
+
Oe(Ee);
|
|
2823
|
+
let r = z({
|
|
2710
2824
|
galleryThumb: t.galleryThumb,
|
|
2711
2825
|
avatarImage: t.avatarImage,
|
|
2712
2826
|
backgroundImage: t.backgroundImage,
|
|
@@ -2732,9 +2846,9 @@ function Ln(e, t, n) {
|
|
|
2732
2846
|
let e = document.createElement("img");
|
|
2733
2847
|
e.className = "liforma-et__foreground liforma-et__media", e.alt = "", e.decoding = "async", e.src = r.foregroundImage, e.addEventListener("load", () => o(e), { once: !0 }), i.append(e);
|
|
2734
2848
|
}
|
|
2735
|
-
return e.replaceChildren(i), n?.parallax === !1 ? () => {} :
|
|
2849
|
+
return e.replaceChildren(i), n?.parallax === !1 ? () => {} : Te(i);
|
|
2736
2850
|
}
|
|
2737
|
-
function
|
|
2851
|
+
function Bn(e) {
|
|
2738
2852
|
return e.startButton ? {
|
|
2739
2853
|
...e.startButton,
|
|
2740
2854
|
label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
|
|
@@ -2746,7 +2860,7 @@ function Rn(e) {
|
|
|
2746
2860
|
variant: "primary"
|
|
2747
2861
|
};
|
|
2748
2862
|
}
|
|
2749
|
-
function
|
|
2863
|
+
function Vn(e) {
|
|
2750
2864
|
let t = !1, n = () => {
|
|
2751
2865
|
t || e();
|
|
2752
2866
|
}, r = () => {
|
|
@@ -2766,12 +2880,12 @@ function zn(e) {
|
|
|
2766
2880
|
t = !0, window.removeEventListener("load", r), i?.();
|
|
2767
2881
|
};
|
|
2768
2882
|
}
|
|
2769
|
-
function
|
|
2770
|
-
je
|
|
2883
|
+
function Hn(e, t) {
|
|
2884
|
+
Ne(je);
|
|
2771
2885
|
let n = t.experienceId?.trim();
|
|
2772
2886
|
if (!n) throw Error("ExperienceWidget requires experienceId.");
|
|
2773
|
-
let r = t.prefetch ?? "onExpand", i =
|
|
2774
|
-
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",
|
|
2887
|
+
let r = t.prefetch ?? "onExpand", i = Nn(t.position), a = document.createElement("div");
|
|
2888
|
+
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", Pn(t.offset));
|
|
2775
2889
|
let o = document.createElement("button");
|
|
2776
2890
|
o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
|
|
2777
2891
|
let s = document.createElement("div");
|
|
@@ -2791,82 +2905,82 @@ function Bn(e, t) {
|
|
|
2791
2905
|
let m = document.createElement("span");
|
|
2792
2906
|
m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
|
|
2793
2907
|
let h = document.createElement("button");
|
|
2794
|
-
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML =
|
|
2908
|
+
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = Ln, h.setAttribute("aria-label", "Reduce");
|
|
2795
2909
|
let g = document.createElement("button");
|
|
2796
|
-
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML =
|
|
2910
|
+
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = Fn, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
|
|
2797
2911
|
let _ = document.createElement("button");
|
|
2798
|
-
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML =
|
|
2912
|
+
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = In, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
|
|
2799
2913
|
let v = document.createElement("div");
|
|
2800
2914
|
v.className = "liforma-ew__stage";
|
|
2801
2915
|
let y = document.createElement("div");
|
|
2802
2916
|
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);
|
|
2803
|
-
let b = null, x = !1, S = !1, ee = !1, C = !1, w = !1, T = !1, E = !1, D = 0, O = "", k = null, A = null, j = null, M = null, N = null, P = null, F = null, te = 0,
|
|
2917
|
+
let b = null, x = !1, S = !1, ee = !1, C = !1, w = !1, T = !1, E = !1, D = 0, O = "", k = null, A = null, j = null, M = null, N = null, P = null, F = null, te = 0, ne = 0, re = null, I = !1, ie = new AbortController(), L = t.parallax !== !1, R = () => {
|
|
2804
2918
|
let e = a.dataset.state;
|
|
2805
2919
|
return e === "expanded" || e === "docked" || e === "collapsed" ? e : "collapsed";
|
|
2806
|
-
},
|
|
2920
|
+
}, z = () => {
|
|
2807
2921
|
j !== null && (clearTimeout(j), j = null);
|
|
2808
|
-
},
|
|
2922
|
+
}, B = () => {
|
|
2809
2923
|
M !== null && (clearTimeout(M), M = null), a.classList.remove("liforma-ew--layout-settling");
|
|
2810
|
-
},
|
|
2924
|
+
}, V = () => {
|
|
2811
2925
|
for (let e of [
|
|
2812
2926
|
f,
|
|
2813
2927
|
l,
|
|
2814
2928
|
p
|
|
2815
2929
|
]) e.style.removeProperty("left"), e.style.removeProperty("top"), e.style.removeProperty("width"), e.style.removeProperty("height"), e.style.removeProperty("right"), e.style.removeProperty("bottom");
|
|
2816
2930
|
p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging");
|
|
2817
|
-
},
|
|
2931
|
+
}, ae = (e, t, n, r) => {
|
|
2818
2932
|
let i = (i) => {
|
|
2819
2933
|
i.style.left = `${e}px`, i.style.top = `${t}px`, i.style.width = `${n}px`, i.style.height = `${r}px`, i.style.right = "auto", i.style.bottom = "auto";
|
|
2820
2934
|
};
|
|
2821
2935
|
i(f), i(l);
|
|
2822
2936
|
let a = p.offsetWidth || 120;
|
|
2823
2937
|
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";
|
|
2824
|
-
}, ae = (e, t) => {
|
|
2825
|
-
if (B() !== "docked") return;
|
|
2826
|
-
let n = Dn(), r = kn(e - te, t - I, n);
|
|
2827
|
-
N = r.left, P = r.top, ie(r.left, r.top, n.width, n.height);
|
|
2828
2938
|
}, oe = (e, t) => {
|
|
2829
|
-
if (
|
|
2830
|
-
let n =
|
|
2831
|
-
N =
|
|
2832
|
-
}, se = (e) => {
|
|
2833
|
-
|
|
2834
|
-
|
|
2939
|
+
if (R() !== "docked") return;
|
|
2940
|
+
let n = kn(), r = jn(e - te, t - ne, n);
|
|
2941
|
+
N = r.left, P = r.top, ae(r.left, r.top, n.width, n.height);
|
|
2942
|
+
}, se = (e, t) => {
|
|
2943
|
+
if (R() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
|
|
2944
|
+
let n = kn(), r = N ?? f.getBoundingClientRect().left, i = P ?? f.getBoundingClientRect().top, a = jn(r + e, i + t, n);
|
|
2945
|
+
N = a.left, P = a.top, ae(a.left, a.top, n.width, n.height);
|
|
2946
|
+
}, ce = (e) => {
|
|
2947
|
+
re === "toolbar" && (F === null || e.pointerId !== F || (e.preventDefault(), oe(e.clientX, e.clientY)));
|
|
2948
|
+
}, H = (e) => {
|
|
2835
2949
|
if (F === null || e && e.pointerId !== F) return;
|
|
2836
|
-
let t =
|
|
2837
|
-
F = null,
|
|
2838
|
-
},
|
|
2839
|
-
if (S ||
|
|
2840
|
-
F = n,
|
|
2950
|
+
let t = re;
|
|
2951
|
+
F = null, re = null, p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging"), t === "toolbar" && I && (I = !1, window.removeEventListener("pointermove", ce), window.removeEventListener("pointerup", H), window.removeEventListener("pointercancel", H));
|
|
2952
|
+
}, le = (e, t, n) => {
|
|
2953
|
+
if (S || R() !== "docked" || !Mn() || F !== null) return;
|
|
2954
|
+
F = n, re = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2841
2955
|
let r = f.getBoundingClientRect();
|
|
2842
|
-
te = e - r.left,
|
|
2843
|
-
},
|
|
2844
|
-
if (S ||
|
|
2845
|
-
F = e.pointerId,
|
|
2956
|
+
te = e - r.left, ne = t - r.top, I || (I = !0, window.addEventListener("pointermove", ce), window.addEventListener("pointerup", H), window.addEventListener("pointercancel", H));
|
|
2957
|
+
}, U = (e) => {
|
|
2958
|
+
if (S || R() !== "docked" || !Mn() || F !== null) return;
|
|
2959
|
+
F = e.pointerId, re = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2846
2960
|
let t = f.getBoundingClientRect();
|
|
2847
2961
|
N = t.left, P = t.top;
|
|
2848
|
-
}, le = (e) => {
|
|
2849
|
-
L === "player" && (F === null || e.pointerId !== F || oe(e.dx, e.dy));
|
|
2850
2962
|
}, ue = (e) => {
|
|
2851
|
-
|
|
2852
|
-
},
|
|
2853
|
-
|
|
2963
|
+
re === "player" && (F === null || e.pointerId !== F || se(e.dx, e.dy));
|
|
2964
|
+
}, de = (e) => {
|
|
2965
|
+
re === "player" && (F === null || e.pointerId !== F || H());
|
|
2966
|
+
}, W = () => {
|
|
2967
|
+
let e = Mn(), t = R();
|
|
2854
2968
|
if (!e || t !== "expanded" && t !== "docked") {
|
|
2855
2969
|
h.hidden = !0;
|
|
2856
2970
|
return;
|
|
2857
2971
|
}
|
|
2858
|
-
h.hidden = !1, t === "docked" ? (h.innerHTML =
|
|
2859
|
-
},
|
|
2860
|
-
let t =
|
|
2861
|
-
n =
|
|
2862
|
-
},
|
|
2972
|
+
h.hidden = !1, t === "docked" ? (h.innerHTML = Rn, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = Ln, h.setAttribute("aria-label", "Reduce"));
|
|
2973
|
+
}, fe = (e) => {
|
|
2974
|
+
let t = kn(), n = e && N !== null && P !== null ? jn(N, P, t) : An(t);
|
|
2975
|
+
n = jn(n.left, n.top, t), N = n.left, P = n.top, ae(n.left, n.top, t.width, t.height), W();
|
|
2976
|
+
}, pe = () => {
|
|
2863
2977
|
a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
|
|
2864
2978
|
requestAnimationFrame(() => {
|
|
2865
2979
|
S || !$(a.dataset.state) || a.classList.add("liforma-ew--session-revealed");
|
|
2866
2980
|
});
|
|
2867
2981
|
});
|
|
2868
|
-
},
|
|
2869
|
-
if (
|
|
2982
|
+
}, me = (e) => {
|
|
2983
|
+
if (B(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !E) {
|
|
2870
2984
|
a.classList.remove("liforma-ew--layout-settling");
|
|
2871
2985
|
return;
|
|
2872
2986
|
}
|
|
@@ -2875,54 +2989,54 @@ function Bn(e, t) {
|
|
|
2875
2989
|
a.classList.remove("liforma-ew--layout-settling");
|
|
2876
2990
|
return;
|
|
2877
2991
|
}
|
|
2878
|
-
a.classList.remove("liforma-ew--layout-settling"),
|
|
2992
|
+
a.classList.remove("liforma-ew--layout-settling"), pe();
|
|
2879
2993
|
}, 220);
|
|
2880
|
-
},
|
|
2881
|
-
|
|
2994
|
+
}, he = () => (a.classList.add("liforma-ew--session-concealing"), a.classList.remove("liforma-ew--session-revealed"), new Promise((e) => {
|
|
2995
|
+
z(), j = setTimeout(() => {
|
|
2882
2996
|
j = null, a.classList.remove("liforma-ew--session-concealing"), e();
|
|
2883
2997
|
}, 280);
|
|
2884
|
-
})),
|
|
2998
|
+
})), ge = {
|
|
2885
2999
|
galleryThumb: t.galleryThumb,
|
|
2886
3000
|
avatarImage: t.avatarImage,
|
|
2887
3001
|
backgroundImage: t.backgroundImage,
|
|
2888
3002
|
foregroundImage: t.foregroundImage,
|
|
2889
3003
|
fallbackImage: t.fallbackImage
|
|
2890
|
-
},
|
|
3004
|
+
}, _e = (e) => {
|
|
2891
3005
|
if (!e) {
|
|
2892
3006
|
y.hidden = !0, y.textContent = "";
|
|
2893
3007
|
return;
|
|
2894
3008
|
}
|
|
2895
3009
|
y.hidden = !1, y.textContent = e;
|
|
2896
|
-
},
|
|
3010
|
+
}, ve = (e) => {
|
|
2897
3011
|
if (!e) {
|
|
2898
3012
|
c.hidden = !0, c.textContent = "";
|
|
2899
3013
|
return;
|
|
2900
3014
|
}
|
|
2901
3015
|
c.hidden = !1, c.textContent = e, s.contains(c) || s.append(c);
|
|
2902
|
-
},
|
|
2903
|
-
ee = !0, o.disabled = !1,
|
|
2904
|
-
},
|
|
3016
|
+
}, ye = () => {
|
|
3017
|
+
ee = !0, o.disabled = !1, ve(null), r === "onExpand" && t.onPrefetchReady?.();
|
|
3018
|
+
}, G = () => {
|
|
2905
3019
|
C = !0, a.dataset.warm = "true", l.hidden = !1, E || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
|
|
2906
|
-
},
|
|
3020
|
+
}, be = (e) => {
|
|
2907
3021
|
k?.(), k = null;
|
|
2908
|
-
let t =
|
|
3022
|
+
let t = zn(s, e, { parallax: L });
|
|
2909
3023
|
return t ? (k = t, !0) : !1;
|
|
2910
|
-
},
|
|
2911
|
-
if (
|
|
2912
|
-
|
|
3024
|
+
}, K = () => {
|
|
3025
|
+
if (be(ge)) {
|
|
3026
|
+
ye();
|
|
2913
3027
|
return;
|
|
2914
3028
|
}
|
|
2915
|
-
|
|
3029
|
+
ve("Loading…"), ze(n, { signal: ie.signal }).then((e) => {
|
|
2916
3030
|
if (!S) {
|
|
2917
|
-
if (!
|
|
2918
|
-
|
|
3031
|
+
if (!be({ galleryThumb: e.galleryThumb })) throw Error("Experience preview is missing gallery thumb images.");
|
|
3032
|
+
ye();
|
|
2919
3033
|
}
|
|
2920
3034
|
}).catch((e) => {
|
|
2921
|
-
if (S ||
|
|
3035
|
+
if (S || ie.signal.aborted) return;
|
|
2922
3036
|
let n = e instanceof Error ? e : Error(String(e));
|
|
2923
|
-
|
|
3037
|
+
ve("Preview unavailable"), o.disabled = !0, t.onError?.(n), console.error("[ExperienceWidget]", n);
|
|
2924
3038
|
});
|
|
2925
|
-
},
|
|
3039
|
+
}, xe = () => ({
|
|
2926
3040
|
experienceId: n,
|
|
2927
3041
|
ui: "widget",
|
|
2928
3042
|
...t.sessionEndpoint ? { sessionEndpoint: t.sessionEndpoint } : {},
|
|
@@ -2932,83 +3046,88 @@ function Bn(e, t) {
|
|
|
2932
3046
|
...t.speechInputMode ? { speechInputMode: t.speechInputMode } : {},
|
|
2933
3047
|
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
|
|
2934
3048
|
...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
|
|
2935
|
-
}),
|
|
3049
|
+
}), Se = () => ({
|
|
2936
3050
|
...t.fit ? { fit: t.fit } : {},
|
|
2937
|
-
startButton:
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
3051
|
+
startButton: Bn(t),
|
|
3052
|
+
...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback }
|
|
3053
|
+
}), q = (e = !0) => {
|
|
3054
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), V(), a.dataset.state = "expanded", _e(null), typeof document < "u" && (O = document.body.style.overflow, document.body.style.overflow = "hidden"), W(), e && t.onExpanded?.();
|
|
3055
|
+
}, Ce = () => {
|
|
3056
|
+
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 = O), fe(!0), W(), b?.setWidgetChrome("docked");
|
|
3057
|
+
}, we = (e) => {
|
|
2943
3058
|
e.on("started", () => {
|
|
2944
|
-
S || (E = !0, a.dataset.live = "true",
|
|
3059
|
+
S || (E = !0, a.dataset.live = "true", _e(null), t.onStarted?.(), $(a.dataset.state) && pe());
|
|
3060
|
+
}), e.on("feedback", (e) => {
|
|
3061
|
+
S || t.onFeedback?.(e);
|
|
3062
|
+
}), e.on("feedbackFailed", (e) => {
|
|
3063
|
+
S || t.onFeedbackFailed?.(e);
|
|
2945
3064
|
});
|
|
2946
|
-
}, we = () => {
|
|
2947
|
-
re(), u.hidden = !0, p.hidden = !0, H(), 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"), ee && (o.disabled = !1), K(null), typeof document < "u" && (document.body.style.overflow = O), G();
|
|
2948
3065
|
}, Te = () => {
|
|
2949
|
-
|
|
3066
|
+
B(), u.hidden = !0, p.hidden = !0, V(), 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"), ee && (o.disabled = !1), _e(null), typeof document < "u" && (document.body.style.overflow = O), W();
|
|
3067
|
+
}, Ee = () => {
|
|
3068
|
+
z(), B(), D += 1, x = !1, C = !1, w = !1, T = !1, E = !1;
|
|
2950
3069
|
let e = b;
|
|
2951
3070
|
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");
|
|
2952
|
-
},
|
|
3071
|
+
}, De = () => {
|
|
2953
3072
|
if (!S && $(a.dataset.state)) {
|
|
2954
|
-
if (
|
|
3073
|
+
if (H(), x = !1, b && T) {
|
|
2955
3074
|
let e = b;
|
|
2956
3075
|
(async () => {
|
|
2957
|
-
E && (await
|
|
3076
|
+
E && (await he(), S || b !== e) || (C && e.setWidgetChrome("collapsed"), Te(), E ? (a.dataset.live = "true", o.tabIndex = 0, o.removeAttribute("aria-hidden"), o.disabled = !1) : C && G(), t.onCollapsed?.(), t.onClose?.());
|
|
2958
3077
|
})();
|
|
2959
3078
|
return;
|
|
2960
3079
|
}
|
|
2961
|
-
|
|
3080
|
+
Ee(), Te(), t.onCollapsed?.(), t.onClose?.();
|
|
2962
3081
|
}
|
|
2963
|
-
}, De = () => {
|
|
2964
|
-
S || An() && B() === "expanded" && pe(() => {
|
|
2965
|
-
Se();
|
|
2966
|
-
});
|
|
2967
3082
|
}, Oe = () => {
|
|
2968
|
-
S ||
|
|
2969
|
-
|
|
3083
|
+
S || Mn() && R() === "expanded" && me(() => {
|
|
3084
|
+
Ce();
|
|
3085
|
+
});
|
|
3086
|
+
}, ke = () => {
|
|
3087
|
+
S || R() === "docked" && (H(), me(() => {
|
|
3088
|
+
V(), q(!1), b?.setWidgetChrome("expanded");
|
|
2970
3089
|
}));
|
|
2971
3090
|
}, Ae = () => {
|
|
2972
|
-
!b || !E || (
|
|
3091
|
+
!b || !E || (z(), a.classList.remove("liforma-ew--session-revealed"), q(), b.setWidgetChrome("expanded"), x = !1, pe());
|
|
2973
3092
|
}, Me = () => {
|
|
2974
|
-
!b || !T || E || (
|
|
2975
|
-
},
|
|
2976
|
-
S || e !== D && !E || (
|
|
2977
|
-
},
|
|
3093
|
+
!b || !T || E || (z(), a.classList.remove("liforma-ew--session-revealed"), q(), x = !1, C || b.setWidgetChrome("expanded"));
|
|
3094
|
+
}, Pe = (e) => {
|
|
3095
|
+
S || e !== D && !E || (z(), a.classList.remove("liforma-ew--session-revealed"), q(), x = !1, E && pe());
|
|
3096
|
+
}, Fe = () => {
|
|
2978
3097
|
if (S || w || C || b || $(a.dataset.state)) return;
|
|
2979
3098
|
w = !0;
|
|
2980
3099
|
let e = D;
|
|
2981
3100
|
l.hidden = !1, (async () => {
|
|
2982
3101
|
try {
|
|
2983
|
-
let t = await
|
|
3102
|
+
let t = await bn.startSession(xe());
|
|
2984
3103
|
if (S || e !== D) {
|
|
2985
3104
|
t.destroy();
|
|
2986
3105
|
return;
|
|
2987
3106
|
}
|
|
2988
|
-
b = t,
|
|
3107
|
+
b = t, we(t);
|
|
2989
3108
|
let n = await t.attach({
|
|
2990
3109
|
container: l,
|
|
2991
|
-
...
|
|
3110
|
+
...Se(),
|
|
2992
3111
|
onWidgetReady: () => {
|
|
2993
|
-
S || e !== D || (w = !1, T = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") :
|
|
3112
|
+
S || e !== D || (w = !1, T = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") : G());
|
|
2994
3113
|
},
|
|
2995
3114
|
onWidgetExpand: () => {
|
|
2996
|
-
|
|
3115
|
+
Pe(e);
|
|
2997
3116
|
},
|
|
2998
3117
|
onWidgetAudioSettings: (e) => {
|
|
2999
|
-
S ||
|
|
3118
|
+
S || J(e);
|
|
3000
3119
|
},
|
|
3001
3120
|
onWidgetDragStart: (e) => {
|
|
3002
|
-
S ||
|
|
3121
|
+
S || U(e);
|
|
3003
3122
|
},
|
|
3004
3123
|
onWidgetDragMove: (e) => {
|
|
3005
|
-
S ||
|
|
3124
|
+
S || ue(e);
|
|
3006
3125
|
},
|
|
3007
3126
|
onWidgetDragEnd: (e) => {
|
|
3008
|
-
S ||
|
|
3127
|
+
S || de(e);
|
|
3009
3128
|
},
|
|
3010
3129
|
onPlayerStatusChange: (e) => {
|
|
3011
|
-
S || e === "error" && $(a.dataset.state) &&
|
|
3130
|
+
S || e === "error" && $(a.dataset.state) && _e("Could not load the experience.");
|
|
3012
3131
|
}
|
|
3013
3132
|
});
|
|
3014
3133
|
if (S || e !== D) {
|
|
@@ -3016,7 +3135,7 @@ function Bn(e, t) {
|
|
|
3016
3135
|
return;
|
|
3017
3136
|
}
|
|
3018
3137
|
n.on("close", () => {
|
|
3019
|
-
S ||
|
|
3138
|
+
S || De();
|
|
3020
3139
|
});
|
|
3021
3140
|
} catch (n) {
|
|
3022
3141
|
if (S || e !== D) return;
|
|
@@ -3025,7 +3144,7 @@ function Bn(e, t) {
|
|
|
3025
3144
|
t.onError?.(r), console.error("[ExperienceWidget] warm prefetch failed", r);
|
|
3026
3145
|
}
|
|
3027
3146
|
})();
|
|
3028
|
-
},
|
|
3147
|
+
}, Ie = () => {
|
|
3029
3148
|
if (S || x || !ee || $(a.dataset.state)) return;
|
|
3030
3149
|
if (b && E) {
|
|
3031
3150
|
Ae();
|
|
@@ -3038,30 +3157,30 @@ function Bn(e, t) {
|
|
|
3038
3157
|
let e = ++D;
|
|
3039
3158
|
x = !0, C = !1, w = !1, T = !1, E = !1, delete a.dataset.warm, delete a.dataset.live, l.hidden = !0, l.replaceChildren(), b &&= (b.destroy(), null), (async () => {
|
|
3040
3159
|
try {
|
|
3041
|
-
|
|
3042
|
-
let t = await
|
|
3160
|
+
q();
|
|
3161
|
+
let t = await bn.startSession(xe());
|
|
3043
3162
|
if (S || e !== D) {
|
|
3044
3163
|
t.destroy();
|
|
3045
3164
|
return;
|
|
3046
3165
|
}
|
|
3047
|
-
b = t,
|
|
3166
|
+
b = t, we(t);
|
|
3048
3167
|
let n = await t.attach({
|
|
3049
3168
|
container: v,
|
|
3050
|
-
...
|
|
3169
|
+
...Se(),
|
|
3051
3170
|
onWidgetAudioSettings: (e) => {
|
|
3052
|
-
S ||
|
|
3171
|
+
S || J(e);
|
|
3053
3172
|
},
|
|
3054
3173
|
onWidgetDragStart: (e) => {
|
|
3055
|
-
S ||
|
|
3174
|
+
S || U(e);
|
|
3056
3175
|
},
|
|
3057
3176
|
onWidgetDragMove: (e) => {
|
|
3058
|
-
S ||
|
|
3177
|
+
S || ue(e);
|
|
3059
3178
|
},
|
|
3060
3179
|
onWidgetDragEnd: (e) => {
|
|
3061
|
-
S ||
|
|
3180
|
+
S || de(e);
|
|
3062
3181
|
},
|
|
3063
3182
|
onPlayerStatusChange: (e) => {
|
|
3064
|
-
S || (e === "error" ?
|
|
3183
|
+
S || (e === "error" ? _e("Could not load the experience.") : $(a.dataset.state) && _e(null));
|
|
3065
3184
|
}
|
|
3066
3185
|
});
|
|
3067
3186
|
if (S || e !== D) {
|
|
@@ -3069,17 +3188,17 @@ function Bn(e, t) {
|
|
|
3069
3188
|
return;
|
|
3070
3189
|
}
|
|
3071
3190
|
T = !0, t.setWidgetChrome("expanded"), n.on("close", () => {
|
|
3072
|
-
S ||
|
|
3191
|
+
S || De();
|
|
3073
3192
|
});
|
|
3074
3193
|
} catch (n) {
|
|
3075
3194
|
if (S || e !== D) return;
|
|
3076
3195
|
let r = n instanceof Error ? n : Error(String(n));
|
|
3077
|
-
|
|
3196
|
+
_e(r.message), t.onError?.(r), console.error("[ExperienceWidget]", r);
|
|
3078
3197
|
} finally {
|
|
3079
3198
|
e === D && (x = !1);
|
|
3080
3199
|
}
|
|
3081
3200
|
})();
|
|
3082
|
-
},
|
|
3201
|
+
}, Le = () => {
|
|
3083
3202
|
if (!(S || $(a.dataset.state))) {
|
|
3084
3203
|
if (b && E) {
|
|
3085
3204
|
Ae();
|
|
@@ -3090,80 +3209,80 @@ function Bn(e, t) {
|
|
|
3090
3209
|
return;
|
|
3091
3210
|
}
|
|
3092
3211
|
if (w || b) {
|
|
3093
|
-
|
|
3212
|
+
q();
|
|
3094
3213
|
return;
|
|
3095
3214
|
}
|
|
3096
|
-
|
|
3215
|
+
Ie();
|
|
3097
3216
|
}
|
|
3098
3217
|
}, Re = (e) => {
|
|
3099
|
-
if (e.stopPropagation(),
|
|
3100
|
-
|
|
3218
|
+
if (e.stopPropagation(), R() === "expanded") {
|
|
3219
|
+
Oe();
|
|
3101
3220
|
return;
|
|
3102
3221
|
}
|
|
3103
|
-
|
|
3104
|
-
},
|
|
3222
|
+
R() === "docked" && ke();
|
|
3223
|
+
}, J = (e) => {
|
|
3105
3224
|
g.setAttribute("aria-pressed", e ? "true" : "false");
|
|
3106
3225
|
}, Be = (e) => {
|
|
3107
3226
|
e.stopPropagation(), $(a.dataset.state) && b?.toggleAudioSettings();
|
|
3108
3227
|
}, Ve = (e) => {
|
|
3109
|
-
|
|
3228
|
+
R() === "docked" && Mn() && (e.target?.closest("button") || (e.preventDefault(), le(e.clientX, e.clientY, e.pointerId)));
|
|
3110
3229
|
}, He = (e) => {
|
|
3111
|
-
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(),
|
|
3230
|
+
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), De());
|
|
3112
3231
|
}, Ue = () => {
|
|
3113
3232
|
if (!S) {
|
|
3114
|
-
if (
|
|
3115
|
-
if (!
|
|
3116
|
-
|
|
3233
|
+
if (R() === "docked") {
|
|
3234
|
+
if (!Mn()) {
|
|
3235
|
+
ke();
|
|
3117
3236
|
return;
|
|
3118
3237
|
}
|
|
3119
|
-
E ?
|
|
3120
|
-
|
|
3121
|
-
}) :
|
|
3238
|
+
E ? me(() => {
|
|
3239
|
+
fe(!0);
|
|
3240
|
+
}) : fe(!0);
|
|
3122
3241
|
return;
|
|
3123
3242
|
}
|
|
3124
|
-
|
|
3243
|
+
W();
|
|
3125
3244
|
}
|
|
3126
|
-
},
|
|
3245
|
+
}, We = typeof window < "u" ? window.matchMedia(Sn) : null, Y = () => {
|
|
3127
3246
|
if (!S) {
|
|
3128
|
-
if (
|
|
3129
|
-
|
|
3247
|
+
if (R() === "docked" && !Mn()) {
|
|
3248
|
+
ke();
|
|
3130
3249
|
return;
|
|
3131
3250
|
}
|
|
3132
|
-
|
|
3251
|
+
W();
|
|
3133
3252
|
}
|
|
3134
3253
|
};
|
|
3135
|
-
return o.addEventListener("click",
|
|
3136
|
-
e.stopPropagation(),
|
|
3137
|
-
}), h.addEventListener("click", Re), g.addEventListener("click", Be), p.addEventListener("pointerdown", Ve), window.addEventListener("keydown", He), window.addEventListener("resize", Ue),
|
|
3138
|
-
S ||
|
|
3139
|
-
}) : r === "idle" && (A =
|
|
3140
|
-
S ||
|
|
3254
|
+
return o.addEventListener("click", Le), d.addEventListener("click", De), _.addEventListener("click", (e) => {
|
|
3255
|
+
e.stopPropagation(), De();
|
|
3256
|
+
}), h.addEventListener("click", Re), g.addEventListener("click", Be), p.addEventListener("pointerdown", Ve), window.addEventListener("keydown", He), window.addEventListener("resize", Ue), We?.addEventListener("change", Y), K(), W(), r === "eager" ? queueMicrotask(() => {
|
|
3257
|
+
S || Fe();
|
|
3258
|
+
}) : r === "idle" && (A = Vn(() => {
|
|
3259
|
+
S || Fe();
|
|
3141
3260
|
})), {
|
|
3142
3261
|
root: a,
|
|
3143
|
-
expand:
|
|
3144
|
-
collapse:
|
|
3145
|
-
dock:
|
|
3146
|
-
maximize:
|
|
3262
|
+
expand: Le,
|
|
3263
|
+
collapse: De,
|
|
3264
|
+
dock: Oe,
|
|
3265
|
+
maximize: ke,
|
|
3147
3266
|
prefetch() {
|
|
3148
3267
|
if (r === "onExpand") {
|
|
3149
|
-
|
|
3268
|
+
Fe();
|
|
3150
3269
|
return;
|
|
3151
3270
|
}
|
|
3152
|
-
|
|
3271
|
+
Fe();
|
|
3153
3272
|
},
|
|
3154
3273
|
destroy() {
|
|
3155
|
-
S || (S = !0,
|
|
3274
|
+
S || (S = !0, H(), A?.(), A = null, ie.abort(), k?.(), k = null, window.removeEventListener("keydown", He), window.removeEventListener("resize", Ue), We?.removeEventListener("change", Y), Ee(), Te(), e.replaceChildren());
|
|
3156
3275
|
}
|
|
3157
3276
|
};
|
|
3158
3277
|
}
|
|
3159
3278
|
//#endregion
|
|
3160
3279
|
//#region src/react/ExperienceWidget.tsx
|
|
3161
|
-
function
|
|
3162
|
-
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, language: _, mode: v, speechInputMode: y, speechOnly: b, fit: x, embedBaseUrl: S, expandedMaxWidth: ee, expandedMaxHeight: C, startButtonLabel: w, startButton: T,
|
|
3280
|
+
function Un(e) {
|
|
3281
|
+
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, language: _, mode: v, speechInputMode: y, speechOnly: b, fit: x, embedBaseUrl: S, expandedMaxWidth: ee, expandedMaxHeight: C, startButtonLabel: w, startButton: T, showFeedback: E, className: D = "", onExpanded: O, onCollapsed: k, onStarted: A, onClose: j, onError: M, onPrefetchReady: N, onFeedback: P, onFeedbackFailed: F } = e, te = m === "bottom-right" || m === "bottom-left";
|
|
3163
3282
|
return n(() => {
|
|
3164
3283
|
let e = t.current;
|
|
3165
3284
|
if (!e || !r.trim()) return;
|
|
3166
|
-
let n =
|
|
3285
|
+
let n = Hn(e, {
|
|
3167
3286
|
experienceId: r,
|
|
3168
3287
|
alt: i,
|
|
3169
3288
|
galleryThumb: a,
|
|
@@ -3186,12 +3305,15 @@ function Vn(e) {
|
|
|
3186
3305
|
expandedMaxHeight: C,
|
|
3187
3306
|
startButtonLabel: w,
|
|
3188
3307
|
startButton: T,
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3308
|
+
showFeedback: E,
|
|
3309
|
+
onFeedback: P,
|
|
3310
|
+
onFeedbackFailed: F,
|
|
3311
|
+
onExpanded: O,
|
|
3312
|
+
onCollapsed: k,
|
|
3313
|
+
onStarted: A,
|
|
3314
|
+
onClose: j,
|
|
3315
|
+
onError: M,
|
|
3316
|
+
onPrefetchReady: N
|
|
3195
3317
|
});
|
|
3196
3318
|
return () => n.destroy();
|
|
3197
3319
|
}, [
|
|
@@ -3217,16 +3339,19 @@ function Vn(e) {
|
|
|
3217
3339
|
C,
|
|
3218
3340
|
w,
|
|
3219
3341
|
T,
|
|
3220
|
-
|
|
3342
|
+
E,
|
|
3343
|
+
P,
|
|
3344
|
+
F,
|
|
3221
3345
|
O,
|
|
3222
3346
|
k,
|
|
3223
3347
|
A,
|
|
3224
3348
|
j,
|
|
3225
|
-
M
|
|
3349
|
+
M,
|
|
3350
|
+
N
|
|
3226
3351
|
]), /* @__PURE__ */ d("div", {
|
|
3227
3352
|
ref: t,
|
|
3228
|
-
className:
|
|
3229
|
-
style:
|
|
3353
|
+
className: D,
|
|
3354
|
+
style: te ? { display: "contents" } : {
|
|
3230
3355
|
width: "100%",
|
|
3231
3356
|
height: "100%",
|
|
3232
3357
|
minHeight: "inherit"
|
|
@@ -3234,6 +3359,6 @@ function Vn(e) {
|
|
|
3234
3359
|
});
|
|
3235
3360
|
}
|
|
3236
3361
|
//#endregion
|
|
3237
|
-
export {
|
|
3362
|
+
export { ne as Experience, Ae as ExperienceThumbnail, Un as ExperienceWidget };
|
|
3238
3363
|
|
|
3239
3364
|
//# sourceMappingURL=index.js.map
|