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