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