@liforma/client 0.4.4 → 0.4.5
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 +12 -0
- package/dist/next/index.js +462 -377
- package/dist/next/index.js.map +1 -1
- package/dist/next/next/createLiformaSessionRouteHandler.d.ts +8 -0
- package/dist/next/next/createLiformaSessionRouteHandler.d.ts.map +1 -1
- package/dist/next/next/index.d.ts +8 -1
- package/dist/next/next/index.d.ts.map +1 -1
- package/dist/next/v2/api/captureAttribution.d.ts +10 -0
- package/dist/next/v2/api/captureAttribution.d.ts.map +1 -0
- package/dist/next/v2/api/mintPublicSession.d.ts +1 -0
- package/dist/next/v2/api/mintPublicSession.d.ts.map +1 -1
- package/dist/next/v2/api/sessionEndpointRequest.d.ts +1 -0
- package/dist/next/v2/api/sessionEndpointRequest.d.ts.map +1 -1
- package/dist/next/v2/embed/fullWindowHost.d.ts +20 -0
- package/dist/next/v2/embed/fullWindowHost.d.ts.map +1 -0
- package/dist/next/v2/embed/iframeHost.d.ts +2 -0
- package/dist/next/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/next/v2/embed/protocol.d.ts +14 -0
- package/dist/next/v2/embed/protocol.d.ts.map +1 -1
- package/dist/next/v2/experience.d.ts +8 -1
- package/dist/next/v2/experience.d.ts.map +1 -1
- package/dist/next/v2/types/sessionInteraction.d.ts +19 -0
- package/dist/next/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/npm/index.js +554 -475
- package/dist/npm/index.js.map +1 -1
- package/dist/npm/v2/api/captureAttribution.d.ts +10 -0
- package/dist/npm/v2/api/captureAttribution.d.ts.map +1 -0
- package/dist/npm/v2/api/mintPublicSession.d.ts +1 -0
- package/dist/npm/v2/api/mintPublicSession.d.ts.map +1 -1
- package/dist/npm/v2/api/sessionEndpointRequest.d.ts +1 -0
- package/dist/npm/v2/api/sessionEndpointRequest.d.ts.map +1 -1
- package/dist/npm/v2/embed/fullWindowHost.d.ts +20 -0
- package/dist/npm/v2/embed/fullWindowHost.d.ts.map +1 -0
- package/dist/npm/v2/embed/iframeHost.d.ts +2 -0
- package/dist/npm/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/npm/v2/embed/protocol.d.ts +14 -0
- package/dist/npm/v2/embed/protocol.d.ts.map +1 -1
- package/dist/npm/v2/experience.d.ts +8 -1
- package/dist/npm/v2/experience.d.ts.map +1 -1
- package/dist/npm/v2/index.d.ts +1 -1
- package/dist/npm/v2/index.d.ts.map +1 -1
- package/dist/npm/v2/npm.d.ts +2 -1
- package/dist/npm/v2/npm.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionInteraction.d.ts +19 -0
- package/dist/npm/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionManifestSchema.d.ts +9 -0
- package/dist/npm/v2/types/sessionManifestSchema.d.ts.map +1 -1
- package/dist/react/component/experienceComponentLaunch.d.ts.map +1 -1
- package/dist/react/component/experienceComponentTypes.d.ts +2 -0
- package/dist/react/component/experienceComponentTypes.d.ts.map +1 -1
- package/dist/react/index.js +671 -588
- package/dist/react/index.js.map +1 -1
- package/dist/react/react/Experience.d.ts.map +1 -1
- package/dist/react/v2/api/captureAttribution.d.ts +10 -0
- package/dist/react/v2/api/captureAttribution.d.ts.map +1 -0
- package/dist/react/v2/api/mintPublicSession.d.ts +1 -0
- package/dist/react/v2/api/mintPublicSession.d.ts.map +1 -1
- package/dist/react/v2/api/sessionEndpointRequest.d.ts +1 -0
- package/dist/react/v2/api/sessionEndpointRequest.d.ts.map +1 -1
- package/dist/react/v2/embed/fullWindowHost.d.ts +20 -0
- package/dist/react/v2/embed/fullWindowHost.d.ts.map +1 -0
- package/dist/react/v2/embed/iframeHost.d.ts +2 -0
- package/dist/react/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/react/v2/embed/protocol.d.ts +14 -0
- package/dist/react/v2/embed/protocol.d.ts.map +1 -1
- package/dist/react/v2/experience.d.ts +8 -1
- package/dist/react/v2/experience.d.ts.map +1 -1
- package/dist/react/v2/types/sessionInteraction.d.ts +19 -0
- package/dist/react/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/sdk/v2/client.js +6 -6
- package/dist/sdk/v2/client.js.map +1 -1
- package/dist/svelte/Experience.svelte +8 -0
- package/dist/svelte/Experience.svelte.d.ts +1 -0
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -49,6 +49,7 @@ function _(e) {
|
|
|
49
49
|
mode: e.mode,
|
|
50
50
|
speechInputMode: e.speechInputMode,
|
|
51
51
|
speechOnly: e.speechOnly,
|
|
52
|
+
attribution: e.attribution,
|
|
52
53
|
conversationProcessor: e.conversationProcessor
|
|
53
54
|
};
|
|
54
55
|
if (e.experienceId) return {
|
|
@@ -66,6 +67,7 @@ function _(e) {
|
|
|
66
67
|
mode: e.mode,
|
|
67
68
|
speechInputMode: e.speechInputMode,
|
|
68
69
|
speechOnly: e.speechOnly,
|
|
70
|
+
attribution: e.attribution,
|
|
69
71
|
conversationProcessor: e.conversationProcessor
|
|
70
72
|
};
|
|
71
73
|
throw Error("Experience requires experienceId, sessionEndpoint, or launch.");
|
|
@@ -82,6 +84,7 @@ function v(e) {
|
|
|
82
84
|
e.speechInputMode,
|
|
83
85
|
e.conversationProcessor ? g(e.conversationProcessor) : 0,
|
|
84
86
|
e.speechOnly,
|
|
87
|
+
e.attribution === !1 ? !1 : e.attribution,
|
|
85
88
|
e.avatarId,
|
|
86
89
|
e.backdropId,
|
|
87
90
|
e.locationId,
|
|
@@ -101,14 +104,14 @@ function S() {
|
|
|
101
104
|
if (typeof globalThis.location?.origin == "string" && globalThis.location.origin) return globalThis.location.origin;
|
|
102
105
|
} catch {}
|
|
103
106
|
}
|
|
104
|
-
function
|
|
107
|
+
function C(e) {
|
|
105
108
|
return y.exec(e)?.[1];
|
|
106
109
|
}
|
|
107
|
-
function
|
|
110
|
+
function w(e) {
|
|
108
111
|
return b.exec(e)?.[1];
|
|
109
112
|
}
|
|
110
|
-
function
|
|
111
|
-
let n = x(e).trim() || "Unknown error", r = t?.experienceId?.trim() ||
|
|
113
|
+
function T(e, t) {
|
|
114
|
+
let n = x(e).trim() || "Unknown error", r = t?.experienceId?.trim() || C(n) || void 0, i = t?.origin?.trim() || w(n) || S() || void 0;
|
|
112
115
|
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) ? {
|
|
113
116
|
kind: "not_found",
|
|
114
117
|
title: "The application tried to load an avatar experience that doesn’t exist.",
|
|
@@ -141,7 +144,7 @@ function w(e, t) {
|
|
|
141
144
|
}
|
|
142
145
|
//#endregion
|
|
143
146
|
//#region src/component/experienceComponentRuntime.ts
|
|
144
|
-
function
|
|
147
|
+
function E() {
|
|
145
148
|
let e, t, n = new Promise((n, r) => {
|
|
146
149
|
e = n, t = r;
|
|
147
150
|
});
|
|
@@ -151,29 +154,29 @@ function T() {
|
|
|
151
154
|
reject: t
|
|
152
155
|
};
|
|
153
156
|
}
|
|
154
|
-
function
|
|
157
|
+
function D() {
|
|
155
158
|
return new DOMException("Aborted", "AbortError");
|
|
156
159
|
}
|
|
157
|
-
function
|
|
160
|
+
function O(e) {
|
|
158
161
|
return e instanceof DOMException || e instanceof Error ? e : Error(String(e));
|
|
159
162
|
}
|
|
160
|
-
function
|
|
163
|
+
function k(e) {
|
|
161
164
|
return e instanceof DOMException && e.name === "AbortError";
|
|
162
165
|
}
|
|
163
|
-
function
|
|
166
|
+
function A(e) {
|
|
164
167
|
!e.instance || e.instanceDestroyed || (e.instanceDestroyed = !0, e.instance.destroy());
|
|
165
168
|
}
|
|
166
|
-
function
|
|
169
|
+
function j(e, t, n, r) {
|
|
167
170
|
e.unsubscribers.push(t.on(n, r));
|
|
168
171
|
}
|
|
169
|
-
function
|
|
170
|
-
|
|
172
|
+
function M(e, t, n) {
|
|
173
|
+
j(e, t, "ready", (t) => {
|
|
171
174
|
e.destroyed || (e.ready.resolve(t), n().onReady?.(t));
|
|
172
|
-
}),
|
|
175
|
+
}), j(e, t, "started", (t) => {
|
|
173
176
|
e.destroyed || (e.started.resolve(t), n().onStarted?.(t));
|
|
174
|
-
}),
|
|
177
|
+
}), j(e, t, "userTranscript", (e) => n().onUserTranscript?.(e)), j(e, t, "userSpeechStarted", (e) => n().onUserSpeechStarted?.(e)), j(e, t, "userSpeechEnded", (e) => n().onUserSpeechEnded?.(e)), j(e, t, "characterSpeechStarted", (e) => n().onCharacterSpeechStarted?.(e)), j(e, t, "characterSpeechEnded", (e) => n().onCharacterSpeechEnded?.(e)), j(e, t, "characterFocusChanged", (e) => n().onCharacterFocusChanged?.(e)), j(e, t, "conversationUpdate", (e) => n().onConversationUpdate?.(e)), j(e, t, "message", (e) => n().onMessage?.(e)), j(e, t, "listeningState", (e) => n().onListeningState?.(e)), j(e, t, "activityChange", (e) => n().onActivityChange?.(e)), j(e, t, "feedback", (e) => n().onFeedback?.(e)), j(e, t, "feedbackFailed", (e) => n().onFeedbackFailed?.(e)), j(e, t, "conversationProcessorError", (e) => n().onConversationProcessorError?.(e));
|
|
175
178
|
}
|
|
176
|
-
function
|
|
179
|
+
function N(e = () => ({}), t = () => ({})) {
|
|
177
180
|
let n = 0, r = null;
|
|
178
181
|
function i(e) {
|
|
179
182
|
if (e) {
|
|
@@ -188,22 +191,22 @@ function M(e = () => ({}), t = () => ({})) {
|
|
|
188
191
|
}
|
|
189
192
|
}
|
|
190
193
|
function a(e, t, n, a, o = !1, s) {
|
|
191
|
-
let c =
|
|
192
|
-
return !
|
|
194
|
+
let c = O(e);
|
|
195
|
+
return !k(c) && r === t && !t.destroyed && (o && a?.(T(c, { experienceId: i(s) })), t.reportedErrors.has(c) || (t.reportedErrors.add(c), console.error("[Experience]", c), n.onError?.(c))), c;
|
|
193
196
|
}
|
|
194
197
|
function o() {
|
|
195
|
-
if (!r || r.destroyed) throw
|
|
198
|
+
if (!r || r.destroyed) throw D();
|
|
196
199
|
return r;
|
|
197
200
|
}
|
|
198
201
|
function s(e) {
|
|
199
|
-
if (e.destroyed || r !== e) throw
|
|
202
|
+
if (e.destroyed || r !== e) throw D();
|
|
200
203
|
}
|
|
201
204
|
function u() {
|
|
202
205
|
return {
|
|
203
206
|
id: ++n,
|
|
204
|
-
session:
|
|
205
|
-
ready:
|
|
206
|
-
started:
|
|
207
|
+
session: E(),
|
|
208
|
+
ready: E(),
|
|
209
|
+
started: E(),
|
|
207
210
|
unsubscribers: [],
|
|
208
211
|
reportedErrors: /* @__PURE__ */ new Set(),
|
|
209
212
|
instance: null,
|
|
@@ -214,19 +217,19 @@ function M(e = () => ({}), t = () => ({})) {
|
|
|
214
217
|
function d(e) {
|
|
215
218
|
if (e.destroyed) return;
|
|
216
219
|
e.destroyed = !0;
|
|
217
|
-
let t =
|
|
220
|
+
let t = D();
|
|
218
221
|
e.session.reject(t), e.ready.reject(t), e.started.reject(t);
|
|
219
222
|
for (let t of e.unsubscribers.splice(0)) t();
|
|
220
|
-
|
|
223
|
+
A(e), r === e && (r = null);
|
|
221
224
|
}
|
|
222
225
|
async function f(e, n, i, o, u, d) {
|
|
223
226
|
try {
|
|
224
227
|
let a = await c.startSession(i);
|
|
225
228
|
if (e.instance = a, e.destroyed || r !== e) {
|
|
226
|
-
|
|
229
|
+
A(e);
|
|
227
230
|
return;
|
|
228
231
|
}
|
|
229
|
-
|
|
232
|
+
M(e, a, o);
|
|
230
233
|
let d = t(), f = d.returnUrl?.trim() || u?.trim(), p = await a.attach({
|
|
231
234
|
container: n,
|
|
232
235
|
fit: d.fit,
|
|
@@ -253,7 +256,7 @@ function M(e = () => ({}), t = () => ({})) {
|
|
|
253
256
|
});
|
|
254
257
|
} catch (t) {
|
|
255
258
|
let n = a(t, e, o(), d, !0, i);
|
|
256
|
-
e.session.reject(n), e.ready.reject(n), e.started.reject(n),
|
|
259
|
+
e.session.reject(n), e.ready.reject(n), e.started.reject(n), A(e);
|
|
257
260
|
}
|
|
258
261
|
}
|
|
259
262
|
function p(t, n, i, o) {
|
|
@@ -283,17 +286,17 @@ function M(e = () => ({}), t = () => ({})) {
|
|
|
283
286
|
}
|
|
284
287
|
//#endregion
|
|
285
288
|
//#region src/svelte/experienceLoadErrorStyles.ts
|
|
286
|
-
var
|
|
287
|
-
function
|
|
289
|
+
var P = "liforma-experience-load-error-styles";
|
|
290
|
+
function F() {
|
|
288
291
|
if (typeof document > "u" || document.getElementById("liforma-experience-load-error-styles")) return;
|
|
289
292
|
let e = document.createElement("style");
|
|
290
|
-
e.id =
|
|
293
|
+
e.id = P, e.textContent = I, document.head.append(e);
|
|
291
294
|
}
|
|
292
|
-
var
|
|
295
|
+
var I = "\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";
|
|
293
296
|
//#endregion
|
|
294
297
|
//#region src/svelte/experienceLoadErrorOverlay.ts
|
|
295
|
-
function
|
|
296
|
-
|
|
298
|
+
function ee(e, t) {
|
|
299
|
+
F();
|
|
297
300
|
let n = t, r = !1, i = document.createElement("div");
|
|
298
301
|
i.className = "liforma-loading-screen liforma-loading-screen-absolute", i.setAttribute("role", "alert"), i.setAttribute("aria-live", "assertive");
|
|
299
302
|
let a = document.createElement("div");
|
|
@@ -323,14 +326,14 @@ function te(e, t) {
|
|
|
323
326
|
}
|
|
324
327
|
//#endregion
|
|
325
328
|
//#region src/react/Experience.tsx
|
|
326
|
-
var
|
|
327
|
-
let { returnUrl: c, fit: l, startButton: u, showFeedback: p, closeButton: m, onReady: h, onStarted: g, onUserTranscript: y, onUserSpeechStarted: b, onUserSpeechEnded: x, onCharacterSpeechStarted: S, onCharacterSpeechEnded:
|
|
329
|
+
var te = e(function(e, a) {
|
|
330
|
+
let { returnUrl: c, fit: l, startButton: u, showFeedback: p, closeButton: m, onReady: h, onStarted: g, onUserTranscript: y, onUserSpeechStarted: b, onUserSpeechEnded: x, onCharacterSpeechStarted: S, onCharacterSpeechEnded: C, onCharacterFocusChanged: w, onConversationUpdate: T, onMessage: E, onListeningState: k, onActivityChange: A, onFeedback: j, onFeedbackFailed: M, onConversationProcessorError: P, onPlayerStatusChange: F, onStateUpdate: I, onClose: te, onError: ne } = e, L = o({}), re = o({
|
|
328
331
|
fit: l,
|
|
329
332
|
startButton: u,
|
|
330
333
|
showFeedback: p,
|
|
331
334
|
closeButton: m,
|
|
332
335
|
returnUrl: c
|
|
333
|
-
}), R = o(
|
|
336
|
+
}), R = o(N(() => L.current, () => re.current)), z = o(null), [ie, ae] = s(!1), [B, V] = s(null), oe = o(null), se = o(null), ce = v(e);
|
|
334
337
|
re.current = {
|
|
335
338
|
fit: l,
|
|
336
339
|
startButton: u,
|
|
@@ -344,31 +347,31 @@ var ne = e(function(e, a) {
|
|
|
344
347
|
onUserSpeechStarted: b,
|
|
345
348
|
onUserSpeechEnded: x,
|
|
346
349
|
onCharacterSpeechStarted: S,
|
|
347
|
-
onCharacterSpeechEnded:
|
|
348
|
-
onCharacterFocusChanged:
|
|
349
|
-
onConversationUpdate:
|
|
350
|
-
onMessage:
|
|
351
|
-
onListeningState:
|
|
352
|
-
onActivityChange:
|
|
353
|
-
onFeedback:
|
|
354
|
-
onFeedbackFailed:
|
|
355
|
-
onConversationProcessorError:
|
|
356
|
-
onPlayerStatusChange:
|
|
357
|
-
onStateUpdate:
|
|
358
|
-
onClose:
|
|
359
|
-
onError:
|
|
350
|
+
onCharacterSpeechEnded: C,
|
|
351
|
+
onCharacterFocusChanged: w,
|
|
352
|
+
onConversationUpdate: T,
|
|
353
|
+
onMessage: E,
|
|
354
|
+
onListeningState: k,
|
|
355
|
+
onActivityChange: A,
|
|
356
|
+
onFeedback: j,
|
|
357
|
+
onFeedbackFailed: M,
|
|
358
|
+
onConversationProcessorError: P,
|
|
359
|
+
onPlayerStatusChange: F,
|
|
360
|
+
onStateUpdate: I,
|
|
361
|
+
onClose: te,
|
|
362
|
+
onError: ne
|
|
360
363
|
};
|
|
361
|
-
let
|
|
362
|
-
|
|
364
|
+
let H = t((e) => {
|
|
365
|
+
oe.current = e, ae(e !== null);
|
|
363
366
|
}, []);
|
|
364
367
|
return r(a, () => ({
|
|
365
368
|
ready: () => {
|
|
366
369
|
let e = z.current;
|
|
367
|
-
return !e || e.destroyed ? Promise.reject(
|
|
370
|
+
return !e || e.destroyed ? Promise.reject(D()) : e.ready.promise;
|
|
368
371
|
},
|
|
369
372
|
started: () => {
|
|
370
373
|
let e = z.current;
|
|
371
|
-
return !e || e.destroyed ? Promise.reject(
|
|
374
|
+
return !e || e.destroyed ? Promise.reject(D()) : e.started.promise;
|
|
372
375
|
},
|
|
373
376
|
speech: {
|
|
374
377
|
speak: (e) => R.current.withSession((t) => t.speech.speak(e)),
|
|
@@ -388,30 +391,31 @@ var ne = e(function(e, a) {
|
|
|
388
391
|
getConversation: () => R.current.getActiveInstance()?.getConversation() ?? [],
|
|
389
392
|
focusCharacter: (e) => R.current.withSession((t) => t.focusCharacter(e)),
|
|
390
393
|
setFit: (e) => R.current.withSession((t) => t.setFit(e)),
|
|
394
|
+
conversion: (e) => R.current.withSession((t) => t.conversion(e)),
|
|
391
395
|
end: () => R.current.withSession((e) => e.end())
|
|
392
396
|
}), []), i(() => {
|
|
393
|
-
if (!ie || !
|
|
394
|
-
let t =
|
|
397
|
+
if (!ie || !oe.current) return;
|
|
398
|
+
let t = oe.current, n = R.current, r;
|
|
395
399
|
try {
|
|
396
400
|
r = { options: _(e) };
|
|
397
401
|
} catch (e) {
|
|
398
|
-
r = { error:
|
|
402
|
+
r = { error: O(e) };
|
|
399
403
|
}
|
|
400
|
-
let i = n.activateGeneration(t, r, c,
|
|
404
|
+
let i = n.activateGeneration(t, r, c, V);
|
|
401
405
|
return z.current = i, () => {
|
|
402
406
|
n.cancelGeneration(i), z.current === i && (z.current = null);
|
|
403
407
|
};
|
|
404
408
|
}, [
|
|
405
409
|
ie,
|
|
406
|
-
|
|
410
|
+
ce,
|
|
407
411
|
c
|
|
408
412
|
]), n(() => {
|
|
409
413
|
let e = R.current.getActiveInstance();
|
|
410
414
|
e && e.setFit(l ?? "full");
|
|
411
415
|
}, [l]), n(() => {
|
|
412
|
-
let e =
|
|
416
|
+
let e = se.current;
|
|
413
417
|
if (!e || (e.replaceChildren(), !B)) return;
|
|
414
|
-
let t =
|
|
418
|
+
let t = ee(e, B);
|
|
415
419
|
return () => t.remove();
|
|
416
420
|
}, [B]), /* @__PURE__ */ f("div", {
|
|
417
421
|
className: "liforma-experience-shell",
|
|
@@ -422,7 +426,7 @@ var ne = e(function(e, a) {
|
|
|
422
426
|
minHeight: "inherit"
|
|
423
427
|
},
|
|
424
428
|
children: [/* @__PURE__ */ d("div", {
|
|
425
|
-
ref:
|
|
429
|
+
ref: se,
|
|
426
430
|
className: "liforma-experience-error-host",
|
|
427
431
|
"aria-hidden": B ? void 0 : !0,
|
|
428
432
|
style: {
|
|
@@ -432,7 +436,7 @@ var ne = e(function(e, a) {
|
|
|
432
436
|
pointerEvents: B ? "auto" : "none"
|
|
433
437
|
}
|
|
434
438
|
}), /* @__PURE__ */ d("div", {
|
|
435
|
-
ref:
|
|
439
|
+
ref: H,
|
|
436
440
|
className: "liforma-experience-host",
|
|
437
441
|
style: {
|
|
438
442
|
position: "absolute",
|
|
@@ -444,7 +448,7 @@ var ne = e(function(e, a) {
|
|
|
444
448
|
});
|
|
445
449
|
//#endregion
|
|
446
450
|
//#region src/thumbnail/types.ts
|
|
447
|
-
function
|
|
451
|
+
function ne(e) {
|
|
448
452
|
return e === "face" ? "liforma-et--fit-face" : e === "medium" ? "liforma-et--fit-medium" : "";
|
|
449
453
|
}
|
|
450
454
|
//#endregion
|
|
@@ -480,70 +484,70 @@ function ae() {
|
|
|
480
484
|
}
|
|
481
485
|
//#endregion
|
|
482
486
|
//#region src/thumbnail/hostedLaunchUrl.ts
|
|
483
|
-
var B = "https://player.liforma.ai",
|
|
484
|
-
function
|
|
487
|
+
var B = "https://player.liforma.ai", V = "http://localhost:3002";
|
|
488
|
+
function oe(e) {
|
|
485
489
|
return e.href?.trim() ? "anchor" : e.hasClickHandler ? "button" : e.experienceId?.trim() ? "anchor" : "presentational";
|
|
486
490
|
}
|
|
487
|
-
function
|
|
491
|
+
function se(e) {
|
|
488
492
|
let t = e?.trim();
|
|
489
|
-
return t ? t.replace(/\/$/, "") : ae() ?
|
|
493
|
+
return t ? t.replace(/\/$/, "") : ae() ? V : B;
|
|
490
494
|
}
|
|
491
|
-
function
|
|
492
|
-
let t = e.experienceId.trim(), n =
|
|
495
|
+
function ce(e) {
|
|
496
|
+
let t = e.experienceId.trim(), n = se(e.playerBaseUrl), r = new URL(`${n}/${encodeURIComponent(t)}`), i = e.returnUrl?.trim();
|
|
493
497
|
return i && r.searchParams.set("returnUrl", i), r.toString();
|
|
494
498
|
}
|
|
495
|
-
function
|
|
499
|
+
function H(e) {
|
|
496
500
|
let t = e.href?.trim();
|
|
497
501
|
if (t) return t;
|
|
498
502
|
let n = e.experienceId?.trim();
|
|
499
503
|
if (!n) return;
|
|
500
504
|
let r = e.returnUrl?.trim();
|
|
501
|
-
return !r && e.useCurrentPageAsReturnUrl && typeof window < "u" && (r = window.location.href),
|
|
505
|
+
return !r && e.useCurrentPageAsReturnUrl && typeof window < "u" && (r = window.location.href), ce({
|
|
502
506
|
experienceId: n,
|
|
503
507
|
...r ? { returnUrl: r } : {},
|
|
504
508
|
playerBaseUrl: e.playerBaseUrl
|
|
505
509
|
});
|
|
506
510
|
}
|
|
507
|
-
function
|
|
511
|
+
function le() {
|
|
508
512
|
return typeof window > "u" ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
|
|
509
513
|
}
|
|
510
|
-
var
|
|
514
|
+
var U = 0, ue = [];
|
|
511
515
|
function de() {
|
|
512
|
-
return
|
|
516
|
+
return le() ? 4 : Infinity;
|
|
513
517
|
}
|
|
514
518
|
function W() {
|
|
515
|
-
return
|
|
519
|
+
return le() ? 160 : 0;
|
|
516
520
|
}
|
|
517
521
|
function fe() {
|
|
518
522
|
let e = de();
|
|
519
|
-
for (;
|
|
520
|
-
let e =
|
|
523
|
+
for (; U < e && ue.length > 0;) {
|
|
524
|
+
let e = ue.shift();
|
|
521
525
|
if (!e || e.cancelled) continue;
|
|
522
|
-
|
|
526
|
+
U += 1, e.start();
|
|
523
527
|
let t = W();
|
|
524
528
|
if (t <= 0) {
|
|
525
|
-
|
|
529
|
+
U = Math.max(0, U - 1);
|
|
526
530
|
continue;
|
|
527
531
|
}
|
|
528
532
|
window.setTimeout(() => {
|
|
529
|
-
|
|
533
|
+
U = Math.max(0, U - 1), fe();
|
|
530
534
|
}, t);
|
|
531
535
|
}
|
|
532
536
|
}
|
|
533
537
|
function pe(e) {
|
|
534
|
-
if (!
|
|
538
|
+
if (!le()) return e(), () => {};
|
|
535
539
|
let t = {
|
|
536
540
|
start: e,
|
|
537
541
|
cancelled: !1
|
|
538
542
|
};
|
|
539
|
-
return
|
|
543
|
+
return ue.push(t), fe(), () => {
|
|
540
544
|
t.cancelled = !0;
|
|
541
545
|
};
|
|
542
546
|
}
|
|
543
547
|
//#endregion
|
|
544
548
|
//#region src/thumbnail/lazyLoad.ts
|
|
545
549
|
function me() {
|
|
546
|
-
return
|
|
550
|
+
return le() ? "96px 0px" : "280px 0px";
|
|
547
551
|
}
|
|
548
552
|
function he(e) {
|
|
549
553
|
let t = e.trim().split(/\s+/)[0] ?? "0px", n = Number.parseFloat(t);
|
|
@@ -667,92 +671,92 @@ function ke(e, t) {
|
|
|
667
671
|
return `${e} liforma-et__media${t ? " liforma-et__media--ready" : ""}`;
|
|
668
672
|
}
|
|
669
673
|
function Ae(e) {
|
|
670
|
-
let { galleryThumb: t, avatarImage: r, backgroundImage: i, foregroundImage: c, alt: l, experienceId: p, href: m, target: h, rel: g, onClick: _, returnUrl: v, playerBaseUrl: y, parallax: b = !0, fit: x = "full", lazy: S = !0, className:
|
|
674
|
+
let { galleryThumb: t, avatarImage: r, backgroundImage: i, foregroundImage: c, alt: l, experienceId: p, href: m, target: h, rel: g, onClick: _, returnUrl: v, playerBaseUrl: y, parallax: b = !0, fit: x = "full", lazy: S = !0, className: C = "", fallbackImage: w } = e, T = a(() => ie({
|
|
671
675
|
galleryThumb: t,
|
|
672
676
|
avatarImage: r,
|
|
673
677
|
backgroundImage: i,
|
|
674
678
|
foregroundImage: c,
|
|
675
|
-
fallbackImage:
|
|
679
|
+
fallbackImage: w
|
|
676
680
|
}), [
|
|
677
681
|
t,
|
|
678
682
|
r,
|
|
679
683
|
i,
|
|
680
684
|
c,
|
|
681
|
-
|
|
682
|
-
]),
|
|
685
|
+
w
|
|
686
|
+
]), E = oe({
|
|
683
687
|
href: m,
|
|
684
688
|
hasClickHandler: typeof _ == "function",
|
|
685
689
|
experienceId: p
|
|
686
|
-
}),
|
|
690
|
+
}), D = E === "anchor" && !m?.trim() && !!p?.trim(), O = !!T?.backgroundImage, k = b !== !1, A = o(null), j = o(!1), [M, N] = s(!S), [P, F] = s(!1), [I, ee] = s(!1), [te, L] = s(0), [re, R] = s(0), [z, ae] = s(!1), [B, V] = s(!1), [se, ce] = s(!1), [le, U] = s(!1), [ue, de] = s(), W = T ? z && T.fallbackImage ? T.fallbackImage : T.avatarImage : "";
|
|
687
691
|
n(() => {
|
|
688
692
|
Oe(Ee);
|
|
689
693
|
}, []), n(() => {
|
|
690
|
-
de(
|
|
694
|
+
de(H({
|
|
691
695
|
href: m,
|
|
692
696
|
experienceId: p,
|
|
693
697
|
returnUrl: v,
|
|
694
698
|
playerBaseUrl: y,
|
|
695
|
-
useCurrentPageAsReturnUrl:
|
|
699
|
+
useCurrentPageAsReturnUrl: D && !v?.trim()
|
|
696
700
|
}));
|
|
697
701
|
}, [
|
|
698
702
|
m,
|
|
699
703
|
p,
|
|
700
704
|
v,
|
|
701
705
|
y,
|
|
702
|
-
|
|
706
|
+
D
|
|
703
707
|
]), n(() => {
|
|
704
|
-
|
|
708
|
+
V(!1), ce(!1), U(!1), ae(!1);
|
|
705
709
|
}, [
|
|
706
|
-
|
|
707
|
-
|
|
710
|
+
T?.backgroundImage,
|
|
711
|
+
T?.foregroundImage,
|
|
708
712
|
W
|
|
709
713
|
]), n(() => {
|
|
710
|
-
let e =
|
|
714
|
+
let e = A.current;
|
|
711
715
|
if (e) {
|
|
712
716
|
if (!S) {
|
|
713
|
-
|
|
717
|
+
N(!0);
|
|
714
718
|
return;
|
|
715
719
|
}
|
|
716
720
|
return _e(e, { onVisibleChange: (e) => {
|
|
717
|
-
e &&
|
|
721
|
+
e && N(!0);
|
|
718
722
|
} });
|
|
719
723
|
}
|
|
720
724
|
}, [
|
|
721
725
|
S,
|
|
722
|
-
w,
|
|
723
726
|
T,
|
|
724
|
-
|
|
727
|
+
E,
|
|
728
|
+
ue
|
|
725
729
|
]), n(() => {
|
|
726
|
-
let e =
|
|
727
|
-
if (!(!e || !
|
|
730
|
+
let e = A.current;
|
|
731
|
+
if (!(!e || !k)) return we(e, {
|
|
728
732
|
onParallax: (e) => {
|
|
729
|
-
|
|
733
|
+
ee(!0), j.current || (L(e), R(0));
|
|
730
734
|
},
|
|
731
|
-
pointerActive: () =>
|
|
735
|
+
pointerActive: () => j.current
|
|
732
736
|
});
|
|
733
737
|
}, [
|
|
734
|
-
|
|
735
|
-
w,
|
|
738
|
+
k,
|
|
736
739
|
T,
|
|
737
|
-
|
|
740
|
+
E,
|
|
741
|
+
ue
|
|
738
742
|
]);
|
|
739
743
|
let fe = (e) => {
|
|
740
|
-
if (!
|
|
744
|
+
if (!k || I) return;
|
|
741
745
|
let t = e.currentTarget.getBoundingClientRect();
|
|
742
746
|
t.width <= 0 || t.height <= 0 || (L(((e.clientX - t.left) / t.width - .5) * 2), R(((e.clientY - t.top) / t.height - .5) * 2));
|
|
743
747
|
}, pe = (e) => {
|
|
744
|
-
let t =
|
|
745
|
-
|
|
748
|
+
let t = j.current;
|
|
749
|
+
j.current = !1, F(!1), I && t ? (L(ye(e.getBoundingClientRect(), window.innerHeight)), R(0)) : I || (L(0), R(0));
|
|
746
750
|
}, me = (e) => {
|
|
747
|
-
if (!
|
|
748
|
-
|
|
751
|
+
if (!k) return;
|
|
752
|
+
j.current = !0, e.pointerType === "mouse" && F(!0);
|
|
749
753
|
let t = e.currentTarget, n = () => {
|
|
750
754
|
pe(t), window.removeEventListener("pointerup", n), window.removeEventListener("pointercancel", n);
|
|
751
755
|
};
|
|
752
756
|
window.addEventListener("pointerup", n), window.addEventListener("pointercancel", n);
|
|
753
757
|
}, he = (e) => {
|
|
754
|
-
if (_?.(e), !e.defaultPrevented &&
|
|
755
|
-
let t =
|
|
758
|
+
if (_?.(e), !e.defaultPrevented && D && !v?.trim()) {
|
|
759
|
+
let t = H({
|
|
756
760
|
experienceId: p,
|
|
757
761
|
playerBaseUrl: y,
|
|
758
762
|
useCurrentPageAsReturnUrl: !0
|
|
@@ -760,18 +764,18 @@ function Ae(e) {
|
|
|
760
764
|
t && e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && (e.preventDefault(), window.location.assign(t));
|
|
761
765
|
}
|
|
762
766
|
};
|
|
763
|
-
if (!
|
|
764
|
-
let ge =
|
|
767
|
+
if (!T) return null;
|
|
768
|
+
let ge = k && (P || I), ve = M && (se || B || le), G = [
|
|
765
769
|
"liforma-et",
|
|
766
|
-
|
|
767
|
-
|
|
770
|
+
O ? "liforma-et--scene" : "",
|
|
771
|
+
ne(x),
|
|
768
772
|
ge ? "liforma-et--parallax" : "",
|
|
769
|
-
|
|
770
|
-
|
|
773
|
+
I ? "liforma-et--scroll-parallax" : "",
|
|
774
|
+
M && !ve ? "liforma-et--loading" : "",
|
|
771
775
|
ve ? "liforma-et--revealed" : "",
|
|
772
|
-
|
|
776
|
+
C
|
|
773
777
|
].filter(Boolean).join(" "), be = {
|
|
774
|
-
"--liforma-et-parallax-x":
|
|
778
|
+
"--liforma-et-parallax-x": te,
|
|
775
779
|
"--liforma-et-parallax-y": re
|
|
776
780
|
}, K = (e, t) => {
|
|
777
781
|
e.complete && t(!0);
|
|
@@ -780,67 +784,67 @@ function Ae(e) {
|
|
|
780
784
|
className: "liforma-et__placeholder",
|
|
781
785
|
"aria-hidden": "true"
|
|
782
786
|
}),
|
|
783
|
-
|
|
787
|
+
M && T.backgroundImage ? /* @__PURE__ */ d("img", {
|
|
784
788
|
className: ke("liforma-et__background", B),
|
|
785
|
-
src:
|
|
789
|
+
src: T.backgroundImage,
|
|
786
790
|
alt: "",
|
|
787
791
|
decoding: "async",
|
|
788
792
|
ref: (e) => {
|
|
789
|
-
e && K(e,
|
|
793
|
+
e && K(e, V);
|
|
790
794
|
},
|
|
791
|
-
onLoad: () =>
|
|
792
|
-
onError: () =>
|
|
795
|
+
onLoad: () => V(!0),
|
|
796
|
+
onError: () => V(!0)
|
|
793
797
|
}) : null,
|
|
794
|
-
|
|
795
|
-
className: ke("liforma-et__avatar",
|
|
798
|
+
M && W ? /* @__PURE__ */ d("img", {
|
|
799
|
+
className: ke("liforma-et__avatar", se),
|
|
796
800
|
src: W,
|
|
797
801
|
alt: "",
|
|
798
802
|
decoding: "async",
|
|
799
803
|
ref: (e) => {
|
|
800
|
-
e && K(e,
|
|
804
|
+
e && K(e, ce);
|
|
801
805
|
},
|
|
802
|
-
onLoad: () =>
|
|
806
|
+
onLoad: () => ce(!0),
|
|
803
807
|
onError: () => {
|
|
804
|
-
|
|
808
|
+
T.fallbackImage ? ae(!0) : ce(!0);
|
|
805
809
|
}
|
|
806
810
|
}) : null,
|
|
807
|
-
|
|
808
|
-
className: ke("liforma-et__foreground",
|
|
809
|
-
src:
|
|
811
|
+
M && T.foregroundImage ? /* @__PURE__ */ d("img", {
|
|
812
|
+
className: ke("liforma-et__foreground", le),
|
|
813
|
+
src: T.foregroundImage,
|
|
810
814
|
alt: "",
|
|
811
815
|
decoding: "async",
|
|
812
816
|
ref: (e) => {
|
|
813
|
-
e && K(e,
|
|
817
|
+
e && K(e, U);
|
|
814
818
|
},
|
|
815
|
-
onLoad: () =>
|
|
816
|
-
onError: () =>
|
|
819
|
+
onLoad: () => U(!0),
|
|
820
|
+
onError: () => U(!0)
|
|
817
821
|
}) : null
|
|
818
822
|
] }), Se = {
|
|
819
823
|
onPointerDown: me,
|
|
820
824
|
onPointerUp: (e) => pe(e.currentTarget),
|
|
821
825
|
onPointerCancel: (e) => pe(e.currentTarget),
|
|
822
826
|
onPointerEnter: (e) => {
|
|
823
|
-
|
|
827
|
+
k && e.pointerType === "mouse" && F(!0);
|
|
824
828
|
},
|
|
825
829
|
onPointerMove: fe,
|
|
826
830
|
onPointerLeave: () => {
|
|
827
|
-
|
|
831
|
+
j.current || (F(!1), I || (L(0), R(0)));
|
|
828
832
|
}
|
|
829
833
|
}, q = (e) => {
|
|
830
|
-
|
|
834
|
+
A.current = e;
|
|
831
835
|
};
|
|
832
|
-
return
|
|
836
|
+
return E === "anchor" && ue ? /* @__PURE__ */ d("a", {
|
|
833
837
|
ref: q,
|
|
834
838
|
className: G,
|
|
835
839
|
style: be,
|
|
836
|
-
href:
|
|
840
|
+
href: ue,
|
|
837
841
|
target: h,
|
|
838
842
|
rel: g,
|
|
839
843
|
"aria-label": l,
|
|
840
844
|
onClick: he,
|
|
841
845
|
...Se,
|
|
842
846
|
children: xe
|
|
843
|
-
}) :
|
|
847
|
+
}) : E === "button" ? /* @__PURE__ */ d("button", {
|
|
844
848
|
type: "button",
|
|
845
849
|
ref: q,
|
|
846
850
|
className: G,
|
|
@@ -956,20 +960,58 @@ function Ve(e, t, n) {
|
|
|
956
960
|
});
|
|
957
961
|
}
|
|
958
962
|
//#endregion
|
|
963
|
+
//#region src/v2/api/captureAttribution.ts
|
|
964
|
+
var He = 128, Ue = /[\u0000-\u001f\u007f]/g;
|
|
965
|
+
function Y(e) {
|
|
966
|
+
if (!e) return;
|
|
967
|
+
let t = e.replace(Ue, "").trim();
|
|
968
|
+
if (t) return t.slice(0, He);
|
|
969
|
+
}
|
|
970
|
+
function We(e) {
|
|
971
|
+
let t = new URLSearchParams((e ?? "").startsWith("?") ? (e ?? "").slice(1) : e ?? "");
|
|
972
|
+
return {
|
|
973
|
+
...Y(t.get("utm_source")) ? { utmSource: Y(t.get("utm_source")) } : {},
|
|
974
|
+
...Y(t.get("utm_medium")) ? { utmMedium: Y(t.get("utm_medium")) } : {},
|
|
975
|
+
...Y(t.get("utm_campaign")) ? { utmCampaign: Y(t.get("utm_campaign")) } : {},
|
|
976
|
+
...Y(t.get("utm_content")) ? { utmContent: Y(t.get("utm_content")) } : {},
|
|
977
|
+
...Y(t.get("utm_term")) ? { utmTerm: Y(t.get("utm_term")) } : {}
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
function Ge(e) {
|
|
981
|
+
if (e === !1) return;
|
|
982
|
+
if (e && typeof e == "object") {
|
|
983
|
+
let t = {
|
|
984
|
+
...Y(e.utmSource) ? { utmSource: Y(e.utmSource) } : {},
|
|
985
|
+
...Y(e.utmMedium) ? { utmMedium: Y(e.utmMedium) } : {},
|
|
986
|
+
...Y(e.utmCampaign) ? { utmCampaign: Y(e.utmCampaign) } : {},
|
|
987
|
+
...Y(e.utmContent) ? { utmContent: Y(e.utmContent) } : {},
|
|
988
|
+
...Y(e.utmTerm) ? { utmTerm: Y(e.utmTerm) } : {},
|
|
989
|
+
...Y(e.referrer) ? { referrer: Y(e.referrer) } : {}
|
|
990
|
+
};
|
|
991
|
+
return Object.keys(t).length ? t : void 0;
|
|
992
|
+
}
|
|
993
|
+
if (typeof window > "u") return;
|
|
994
|
+
let t = We(window.location?.search), n = Y(document.referrer || void 0), r = {
|
|
995
|
+
...t,
|
|
996
|
+
...n ? { referrer: n } : {}
|
|
997
|
+
};
|
|
998
|
+
return Object.keys(r).length ? r : void 0;
|
|
999
|
+
}
|
|
1000
|
+
//#endregion
|
|
959
1001
|
//#region src/v2/api/sessionEndpointRequest.ts
|
|
960
|
-
function
|
|
1002
|
+
function Ke(e) {
|
|
961
1003
|
let t = e.locale?.trim();
|
|
962
1004
|
if (t) return t;
|
|
963
1005
|
let n = e.language?.trim();
|
|
964
1006
|
if (n) return n;
|
|
965
1007
|
if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
|
|
966
1008
|
}
|
|
967
|
-
function
|
|
1009
|
+
function qe(e) {
|
|
968
1010
|
let t = e.secondaryLocale?.trim(), n = e.learningLocale?.trim();
|
|
969
1011
|
if (t && n && t !== n) throw Error("secondaryLocale and learningLocale disagree; pass only one or make them equal.");
|
|
970
1012
|
return t || n || void 0;
|
|
971
1013
|
}
|
|
972
|
-
function
|
|
1014
|
+
function Je(e, t) {
|
|
973
1015
|
let n = e.trim();
|
|
974
1016
|
if (!n) throw Error("sessionEndpoint must not be empty.");
|
|
975
1017
|
if (typeof location > "u") throw Error("sessionEndpoint is only available in a browser.");
|
|
@@ -977,7 +1019,7 @@ function We(e, t) {
|
|
|
977
1019
|
if (r.origin !== location.origin) throw Error("sessionEndpoint must be same-origin.");
|
|
978
1020
|
let i = t.experienceId.trim();
|
|
979
1021
|
if (!i) throw Error("sessionEndpoint requires experienceId.");
|
|
980
|
-
let a =
|
|
1022
|
+
let a = Ke(t), o = qe(t), s = t.idempotencyKey?.trim();
|
|
981
1023
|
return {
|
|
982
1024
|
url: r.toString(),
|
|
983
1025
|
init: {
|
|
@@ -994,23 +1036,27 @@ function We(e, t) {
|
|
|
994
1036
|
...o ? { secondaryLocale: o } : {},
|
|
995
1037
|
...t.mode ? { mode: t.mode } : {},
|
|
996
1038
|
...t.speechInputMode ? { speechInputMode: t.speechInputMode } : {},
|
|
997
|
-
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly }
|
|
1039
|
+
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
|
|
1040
|
+
...(() => {
|
|
1041
|
+
let e = Ge(t.attribution);
|
|
1042
|
+
return e ? { attribution: e } : {};
|
|
1043
|
+
})()
|
|
998
1044
|
})
|
|
999
1045
|
}
|
|
1000
1046
|
};
|
|
1001
1047
|
}
|
|
1002
1048
|
//#endregion
|
|
1003
1049
|
//#region src/v2/types/sessionLaunch.ts
|
|
1004
|
-
function
|
|
1050
|
+
function Ye(e) {
|
|
1005
1051
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
1006
1052
|
}
|
|
1007
1053
|
function X(e) {
|
|
1008
1054
|
return typeof e == "boolean";
|
|
1009
1055
|
}
|
|
1010
|
-
function
|
|
1011
|
-
if (!
|
|
1056
|
+
function Xe(e) {
|
|
1057
|
+
if (!Ye(e)) return null;
|
|
1012
1058
|
let t = e.speech, n = e.conversation, r = e.avatar, i = e.tools;
|
|
1013
|
-
return !
|
|
1059
|
+
return !Ye(t) || !Ye(n) || !Ye(r) || !Ye(i) || !X(t.input) || !X(t.output) || !X(t.externalAudio) || !X(n.managed) || !X(r.enabled) || !X(i.enabled) ? null : {
|
|
1014
1060
|
speech: {
|
|
1015
1061
|
input: t.input,
|
|
1016
1062
|
output: t.output,
|
|
@@ -1021,8 +1067,8 @@ function Ge(e) {
|
|
|
1021
1067
|
tools: { enabled: i.enabled }
|
|
1022
1068
|
};
|
|
1023
1069
|
}
|
|
1024
|
-
function
|
|
1025
|
-
return !
|
|
1070
|
+
function Ze(e) {
|
|
1071
|
+
return !Ye(e) || !X(e.avatar) || !X(e.speechInput) || !X(e.speechOutput) || !X(e.tools) || !X(e.externalAudio) ? null : {
|
|
1026
1072
|
speech: {
|
|
1027
1073
|
input: e.speechInput,
|
|
1028
1074
|
output: e.speechOutput,
|
|
@@ -1033,12 +1079,12 @@ function Ke(e) {
|
|
|
1033
1079
|
tools: { enabled: e.tools }
|
|
1034
1080
|
};
|
|
1035
1081
|
}
|
|
1036
|
-
function
|
|
1037
|
-
return
|
|
1082
|
+
function Qe(e) {
|
|
1083
|
+
return Xe(e) ?? Ze(e);
|
|
1038
1084
|
}
|
|
1039
|
-
function
|
|
1040
|
-
if (!
|
|
1041
|
-
let t = typeof e.id == "string" ? e.id.trim() : "", n = typeof e.experienceId == "string" ? e.experienceId.trim() : "", r = typeof e.experienceRevisionId == "string" ? e.experienceRevisionId.trim() : "", i = typeof e.expiresAt == "string" ? e.expiresAt.trim() : "", a = typeof e.locale == "string" ? e.locale.trim() : "", o = typeof e.secondaryLocale == "string" && e.secondaryLocale.trim() ? e.secondaryLocale.trim() : void 0, s = e.mode === "conversation" || e.mode === "presenter" ? e.mode : null, c =
|
|
1085
|
+
function $e(e) {
|
|
1086
|
+
if (!Ye(e)) throw Error("Session Launch response is missing session.");
|
|
1087
|
+
let t = typeof e.id == "string" ? e.id.trim() : "", n = typeof e.experienceId == "string" ? e.experienceId.trim() : "", r = typeof e.experienceRevisionId == "string" ? e.experienceRevisionId.trim() : "", i = typeof e.expiresAt == "string" ? e.expiresAt.trim() : "", a = typeof e.locale == "string" ? e.locale.trim() : "", o = typeof e.secondaryLocale == "string" && e.secondaryLocale.trim() ? e.secondaryLocale.trim() : void 0, s = e.mode === "conversation" || e.mode === "presenter" ? e.mode : null, c = Qe(e.capabilities), l = et(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;
|
|
1042
1088
|
if (!t || !n || !r || !i || !a || !s || !c) throw Error("Session Launch response has an invalid session object.");
|
|
1043
1089
|
return {
|
|
1044
1090
|
id: t,
|
|
@@ -1054,11 +1100,11 @@ function Je(e) {
|
|
|
1054
1100
|
...d ? { createdAt: d } : {}
|
|
1055
1101
|
};
|
|
1056
1102
|
}
|
|
1057
|
-
function
|
|
1103
|
+
function et(e) {
|
|
1058
1104
|
if (!Array.isArray(e) || e.length === 0) return;
|
|
1059
1105
|
let t = [];
|
|
1060
1106
|
for (let n of e) {
|
|
1061
|
-
if (!
|
|
1107
|
+
if (!Ye(n)) continue;
|
|
1062
1108
|
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() : "";
|
|
1063
1109
|
!e || !r || !i || n.reason !== "voice_unsupported" || t.push({
|
|
1064
1110
|
axis: e,
|
|
@@ -1069,35 +1115,35 @@ function Ye(e) {
|
|
|
1069
1115
|
}
|
|
1070
1116
|
return t.length > 0 ? t : void 0;
|
|
1071
1117
|
}
|
|
1072
|
-
function
|
|
1118
|
+
function tt(e) {
|
|
1073
1119
|
let t = e.localeVoiceFallbacks;
|
|
1074
1120
|
if (t?.length) for (let e of t) {
|
|
1075
1121
|
let t = e.axis === "secondaryLocale" ? "secondaryLocale" : "locale";
|
|
1076
1122
|
console.warn(`[liforma] Session ${t} fell back to ${e.resolved} because the voice does not support ${e.requested}.`);
|
|
1077
1123
|
}
|
|
1078
1124
|
}
|
|
1079
|
-
function
|
|
1080
|
-
if (!
|
|
1125
|
+
function nt(e) {
|
|
1126
|
+
if (!Ye(e)) throw Error("Session Launch response must be a JSON object.");
|
|
1081
1127
|
let t = typeof e.launch == "string" ? e.launch.trim() : "";
|
|
1082
1128
|
if (!t) throw Error("Session Launch response is missing launch.");
|
|
1083
|
-
let n =
|
|
1084
|
-
return
|
|
1129
|
+
let n = $e(e.session);
|
|
1130
|
+
return tt(n), {
|
|
1085
1131
|
session: n,
|
|
1086
1132
|
launch: t
|
|
1087
1133
|
};
|
|
1088
1134
|
}
|
|
1089
1135
|
//#endregion
|
|
1090
1136
|
//#region src/v2/api/mintPublicSession.ts
|
|
1091
|
-
function
|
|
1137
|
+
function rt() {
|
|
1092
1138
|
try {
|
|
1093
1139
|
if (typeof globalThis.location?.origin == "string" && globalThis.location.origin) return globalThis.location.origin;
|
|
1094
1140
|
} catch {}
|
|
1095
1141
|
}
|
|
1096
|
-
function
|
|
1142
|
+
function it(e) {
|
|
1097
1143
|
return e ? e.trim().toUpperCase().replace(/-/g, "_") : "";
|
|
1098
1144
|
}
|
|
1099
|
-
function
|
|
1100
|
-
let n =
|
|
1145
|
+
function at(e, t) {
|
|
1146
|
+
let n = rt(), r = it(t.code), i = t.message.trim(), a = t.details ?? {};
|
|
1101
1147
|
if (r === "ORIGIN_NOT_ALLOWED" || /^Origin not allowed/i.test(i) && n) {
|
|
1102
1148
|
if (i.includes(e) && i.includes("allowed origin")) return t;
|
|
1103
1149
|
let r = typeof a.origin == "string" && a.origin || n || "(unknown origin)";
|
|
@@ -1120,36 +1166,38 @@ function et(e, t) {
|
|
|
1120
1166
|
details: a
|
|
1121
1167
|
}) : t;
|
|
1122
1168
|
}
|
|
1123
|
-
function
|
|
1169
|
+
function ot(e) {
|
|
1124
1170
|
let t = e?.locale?.trim();
|
|
1125
1171
|
if (t) return t;
|
|
1126
1172
|
let n = e?.language?.trim();
|
|
1127
1173
|
if (n) return n;
|
|
1128
1174
|
if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
|
|
1129
1175
|
}
|
|
1130
|
-
function
|
|
1176
|
+
function st(e) {
|
|
1131
1177
|
let t = e?.secondaryLocale?.trim(), n = e?.learningLocale?.trim();
|
|
1132
1178
|
if (t && n && t !== n) throw new J("secondaryLocale and learningLocale disagree; pass only one or make them equal.", { code: "INVALID_BODY" });
|
|
1133
1179
|
return t || n || void 0;
|
|
1134
1180
|
}
|
|
1135
|
-
function
|
|
1136
|
-
let n = { experienceId: e }, r =
|
|
1181
|
+
function ct(e, t) {
|
|
1182
|
+
let n = { experienceId: e }, r = ot(t);
|
|
1137
1183
|
r && (n.locale = r);
|
|
1138
|
-
let i =
|
|
1139
|
-
|
|
1184
|
+
let i = st(t);
|
|
1185
|
+
i && (n.secondaryLocale = i), t?.mode && (n.mode = t.mode), t?.speechInputMode && (n.speechInputMode = t.speechInputMode), t?.speechOnly !== void 0 && (n.speechOnly = t.speechOnly);
|
|
1186
|
+
let a = Ge(t?.attribution);
|
|
1187
|
+
return a && (n.attribution = a), n;
|
|
1140
1188
|
}
|
|
1141
|
-
async function
|
|
1189
|
+
async function lt(e, t) {
|
|
1142
1190
|
let n = Le(), r = t?.idempotencyKey?.trim(), i = await fetch(`${n}/v1/browser-sessions`, {
|
|
1143
1191
|
method: "POST",
|
|
1144
1192
|
headers: {
|
|
1145
1193
|
"Content-Type": "application/json",
|
|
1146
1194
|
...r ? { "Idempotency-Key": r } : {}
|
|
1147
1195
|
},
|
|
1148
|
-
body: JSON.stringify(
|
|
1196
|
+
body: JSON.stringify(ct(e, t))
|
|
1149
1197
|
});
|
|
1150
1198
|
if (!i.ok) {
|
|
1151
1199
|
let t = await i.text();
|
|
1152
|
-
throw
|
|
1200
|
+
throw at(e, Ve(i.status, t, i.headers));
|
|
1153
1201
|
}
|
|
1154
1202
|
let a;
|
|
1155
1203
|
try {
|
|
@@ -1161,10 +1209,10 @@ async function it(e, t) {
|
|
|
1161
1209
|
requestId: i.headers.get("Liforma-Request-Id") ?? void 0
|
|
1162
1210
|
});
|
|
1163
1211
|
}
|
|
1164
|
-
return
|
|
1212
|
+
return nt(a);
|
|
1165
1213
|
}
|
|
1166
|
-
async function
|
|
1167
|
-
let n =
|
|
1214
|
+
async function ut(e, t) {
|
|
1215
|
+
let n = Je(e, t), r = new AbortController(), i = () => r.abort(t.signal?.reason);
|
|
1168
1216
|
t.signal?.aborted ? i() : t.signal?.addEventListener("abort", i, { once: !0 });
|
|
1169
1217
|
let a = globalThis.setTimeout(() => r.abort(new DOMException("Session endpoint timed out.", "TimeoutError")), t.timeoutMs ?? 3e4), o;
|
|
1170
1218
|
try {
|
|
@@ -1194,14 +1242,14 @@ async function at(e, t) {
|
|
|
1194
1242
|
requestId: o.headers.get("Liforma-Request-Id") ?? void 0
|
|
1195
1243
|
});
|
|
1196
1244
|
}
|
|
1197
|
-
return
|
|
1245
|
+
return nt(s);
|
|
1198
1246
|
}
|
|
1199
1247
|
//#endregion
|
|
1200
1248
|
//#region src/v2/conversationProcessor.ts
|
|
1201
|
-
function
|
|
1249
|
+
function dt(e) {
|
|
1202
1250
|
return typeof e != "object" || !e ? !1 : typeof e[Symbol.asyncIterator] == "function";
|
|
1203
1251
|
}
|
|
1204
|
-
function
|
|
1252
|
+
function ft(e) {
|
|
1205
1253
|
if (typeof e == "string") {
|
|
1206
1254
|
let t = e.trim();
|
|
1207
1255
|
if (!t) throw Error("conversationProcessor returned empty text.");
|
|
@@ -1215,24 +1263,24 @@ function st(e) {
|
|
|
1215
1263
|
...e.behavior ? { behavior: e.behavior } : {}
|
|
1216
1264
|
};
|
|
1217
1265
|
}
|
|
1218
|
-
async function
|
|
1266
|
+
async function pt(e, t) {
|
|
1219
1267
|
let n = await e(t);
|
|
1220
|
-
return
|
|
1268
|
+
return dt(n) ? {
|
|
1221
1269
|
kind: "stream",
|
|
1222
1270
|
stream: n
|
|
1223
1271
|
} : {
|
|
1224
1272
|
kind: "complete",
|
|
1225
|
-
speech:
|
|
1273
|
+
speech: ft(n)
|
|
1226
1274
|
};
|
|
1227
1275
|
}
|
|
1228
1276
|
//#endregion
|
|
1229
1277
|
//#region src/v2/embed/playerReachability.ts
|
|
1230
|
-
var
|
|
1231
|
-
function
|
|
1278
|
+
var mt = "3002";
|
|
1279
|
+
function ht(e) {
|
|
1232
1280
|
let t = new URL(e);
|
|
1233
|
-
return t.hostname === "localhost" || t.hostname === "127.0.0.1" ? `Cannot connect to the Liforma player at ${e} — nothing is listening on port ${t.port ||
|
|
1281
|
+
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 || mt}. 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.`;
|
|
1234
1282
|
}
|
|
1235
|
-
async function
|
|
1283
|
+
async function gt(e, t) {
|
|
1236
1284
|
try {
|
|
1237
1285
|
await fetch(e, {
|
|
1238
1286
|
method: "GET",
|
|
@@ -1240,52 +1288,30 @@ async function dt(e, t) {
|
|
|
1240
1288
|
signal: AbortSignal.timeout(8e3)
|
|
1241
1289
|
});
|
|
1242
1290
|
} catch {
|
|
1243
|
-
throw Error(
|
|
1291
|
+
throw Error(ht(t));
|
|
1244
1292
|
}
|
|
1245
1293
|
}
|
|
1246
|
-
function
|
|
1294
|
+
function _t(e, t, n, r) {
|
|
1247
1295
|
try {
|
|
1248
1296
|
r && r.length > 0 ? e.postMessage(t, n, r) : e.postMessage(t, n);
|
|
1249
1297
|
} catch (e) {
|
|
1250
|
-
throw e instanceof DOMException && e.name === "SecurityError" ? Error(
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
var
|
|
1254
|
-
function
|
|
1255
|
-
return typeof e == "number" &&
|
|
1256
|
-
}
|
|
1257
|
-
var
|
|
1258
|
-
|
|
1259
|
-
"stateUpdate",
|
|
1260
|
-
"commandResult",
|
|
1261
|
-
"userTranscript",
|
|
1262
|
-
"characterSpeechStarted",
|
|
1263
|
-
"characterSpeechEnded",
|
|
1264
|
-
"characterFocusChanged",
|
|
1265
|
-
"conversationUpdate",
|
|
1266
|
-
"listeningState",
|
|
1267
|
-
"userSpeechStarted",
|
|
1268
|
-
"userSpeechEnded",
|
|
1269
|
-
"modeChange",
|
|
1270
|
-
"activityChange",
|
|
1271
|
-
"feedback",
|
|
1272
|
-
"feedbackFailed",
|
|
1273
|
-
"message",
|
|
1274
|
-
"started",
|
|
1275
|
-
"embedReady",
|
|
1276
|
-
"widgetReady",
|
|
1277
|
-
"widgetExpand",
|
|
1278
|
-
"widgetCollapse",
|
|
1279
|
-
"widgetAudioSettings",
|
|
1280
|
-
"widgetDragStart",
|
|
1281
|
-
"widgetDragMove",
|
|
1282
|
-
"widgetDragEnd"
|
|
1283
|
-
]);
|
|
1284
|
-
function gt(e) {
|
|
1298
|
+
throw e instanceof DOMException && e.name === "SecurityError" ? Error(ht(n), { cause: e }) : e;
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
var vt = new Set([1, 2]);
|
|
1302
|
+
function yt(e) {
|
|
1303
|
+
return typeof e == "number" && vt.has(e);
|
|
1304
|
+
}
|
|
1305
|
+
var bt = new Set(/* @__PURE__ */ "close.stateUpdate.commandResult.userTranscript.characterSpeechStarted.characterSpeechEnded.characterFocusChanged.conversationUpdate.listeningState.userSpeechStarted.userSpeechEnded.modeChange.activityChange.feedback.feedbackFailed.message.started.embedReady.widgetReady.widgetExpand.widgetCollapse.widgetAudioSettings.widgetDragStart.widgetDragMove.widgetDragEnd.fullWindow".split("."));
|
|
1306
|
+
function xt(e) {
|
|
1285
1307
|
if (!e || typeof e != "object") return null;
|
|
1286
1308
|
let t = e;
|
|
1287
|
-
if (!
|
|
1309
|
+
if (!yt(t.schemaVersion) || !t.type || !bt.has(t.type)) return null;
|
|
1288
1310
|
if (t.type === "embedReady" || t.type === "widgetReady" || t.type === "widgetExpand" || t.type === "widgetCollapse") return t;
|
|
1311
|
+
if (t.type === "fullWindow") {
|
|
1312
|
+
let e = t.payload;
|
|
1313
|
+
return !e || typeof e != "object" || typeof e.active != "boolean" ? null : t;
|
|
1314
|
+
}
|
|
1289
1315
|
if (t.type === "widgetAudioSettings") {
|
|
1290
1316
|
let e = t.payload;
|
|
1291
1317
|
return !e || typeof e != "object" || typeof e.open != "boolean" ? null : t;
|
|
@@ -1303,7 +1329,7 @@ function gt(e) {
|
|
|
1303
1329
|
let n = t.payload;
|
|
1304
1330
|
return !n || typeof n != "object" ? null : t;
|
|
1305
1331
|
}
|
|
1306
|
-
function
|
|
1332
|
+
function St(e, t, n) {
|
|
1307
1333
|
let r = e.trim();
|
|
1308
1334
|
if (!r) throw Error("createLaunchMessage requires a non-empty launch string.");
|
|
1309
1335
|
let i = n?.startButton, a = n?.showFeedback;
|
|
@@ -1318,20 +1344,20 @@ function _t(e, t, n) {
|
|
|
1318
1344
|
}
|
|
1319
1345
|
};
|
|
1320
1346
|
}
|
|
1321
|
-
function
|
|
1347
|
+
function Ct() {
|
|
1322
1348
|
return {
|
|
1323
1349
|
type: "parentHello",
|
|
1324
1350
|
schemaVersion: 2
|
|
1325
1351
|
};
|
|
1326
1352
|
}
|
|
1327
|
-
function
|
|
1353
|
+
function wt(e) {
|
|
1328
1354
|
return {
|
|
1329
1355
|
type: "widgetSetChrome",
|
|
1330
1356
|
schemaVersion: 2,
|
|
1331
1357
|
payload: { mode: e }
|
|
1332
1358
|
};
|
|
1333
1359
|
}
|
|
1334
|
-
function
|
|
1360
|
+
function Tt() {
|
|
1335
1361
|
return {
|
|
1336
1362
|
type: "widgetToggleAudioSettings",
|
|
1337
1363
|
schemaVersion: 2,
|
|
@@ -1339,108 +1365,143 @@ function bt() {
|
|
|
1339
1365
|
};
|
|
1340
1366
|
}
|
|
1341
1367
|
//#endregion
|
|
1368
|
+
//#region src/v2/embed/fullWindowHost.ts
|
|
1369
|
+
var Et = "2147483000";
|
|
1370
|
+
function Dt(e) {
|
|
1371
|
+
let { style: t } = e;
|
|
1372
|
+
return {
|
|
1373
|
+
position: t.position,
|
|
1374
|
+
top: t.top,
|
|
1375
|
+
right: t.right,
|
|
1376
|
+
bottom: t.bottom,
|
|
1377
|
+
left: t.left,
|
|
1378
|
+
inset: t.inset,
|
|
1379
|
+
width: t.width,
|
|
1380
|
+
height: t.height,
|
|
1381
|
+
zIndex: t.zIndex,
|
|
1382
|
+
margin: t.margin,
|
|
1383
|
+
borderRadius: t.borderRadius,
|
|
1384
|
+
maxWidth: t.maxWidth,
|
|
1385
|
+
maxHeight: t.maxHeight
|
|
1386
|
+
};
|
|
1387
|
+
}
|
|
1388
|
+
function Ot(e) {
|
|
1389
|
+
let { style: t } = e;
|
|
1390
|
+
t.position = "fixed", t.top = "0", t.right = "0", t.bottom = "0", t.left = "0", t.inset = "0", t.width = "100vw", t.width = "100dvw", t.height = "100vh", t.height = "100dvh", t.zIndex = Et, t.margin = "0", t.borderRadius = "0", t.maxWidth = "none", t.maxHeight = "none", e.dataset.liformaFullWindow = "1";
|
|
1391
|
+
}
|
|
1392
|
+
function kt(e, t) {
|
|
1393
|
+
if (delete e.dataset.liformaFullWindow, !t) {
|
|
1394
|
+
e.style.position = "", e.style.top = "", e.style.right = "", e.style.bottom = "", e.style.left = "", e.style.inset = "", e.style.width = "", e.style.height = "", e.style.zIndex = "", e.style.margin = "", e.style.borderRadius = "", e.style.maxWidth = "", e.style.maxHeight = "";
|
|
1395
|
+
return;
|
|
1396
|
+
}
|
|
1397
|
+
let { style: n } = e;
|
|
1398
|
+
n.position = t.position, n.top = t.top, n.right = t.right, n.bottom = t.bottom, n.left = t.left, n.inset = t.inset, n.width = t.width, n.height = t.height, n.zIndex = t.zIndex, n.margin = t.margin, n.borderRadius = t.borderRadius, n.maxWidth = t.maxWidth, n.maxHeight = t.maxHeight;
|
|
1399
|
+
}
|
|
1400
|
+
//#endregion
|
|
1342
1401
|
//#region src/v2/embed/iframeHost.ts
|
|
1343
|
-
function
|
|
1402
|
+
function At(e) {
|
|
1344
1403
|
return e;
|
|
1345
1404
|
}
|
|
1346
1405
|
function Z() {
|
|
1347
1406
|
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)}`;
|
|
1348
1407
|
}
|
|
1349
|
-
var
|
|
1350
|
-
function
|
|
1408
|
+
var jt = 3e4;
|
|
1409
|
+
function Mt(e) {
|
|
1351
1410
|
let t = e.container;
|
|
1352
1411
|
getComputedStyle(t).position === "static" && (t.style.position = "relative");
|
|
1353
1412
|
let n = document.createElement("iframe");
|
|
1354
1413
|
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");
|
|
1355
|
-
let r = !1, i =
|
|
1356
|
-
|
|
1357
|
-
}), f = () => {
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1414
|
+
let r = !1, i = !1, a = null, o = t.closest(".liforma-experience-shell") instanceof HTMLElement ? t.closest(".liforma-experience-shell") : t, s = (t) => {
|
|
1415
|
+
i !== t && (i = t, t ? (a = Dt(o), Ot(o)) : (kt(o, a), a = null), e.onFullWindowChange?.(t));
|
|
1416
|
+
}, c = /* @__PURE__ */ new Map(), l = null, u = 0, d = 0, f = [], p = null, m = null, h = new Promise((e, t) => {
|
|
1417
|
+
p = e, m = t;
|
|
1418
|
+
}), g = () => {
|
|
1419
|
+
for (let e of f) window.clearTimeout(e);
|
|
1420
|
+
f.length = 0;
|
|
1421
|
+
}, _ = (t) => {
|
|
1361
1422
|
if (r) return;
|
|
1362
1423
|
let i = Date.now();
|
|
1363
|
-
if (
|
|
1364
|
-
|
|
1365
|
-
let a =
|
|
1424
|
+
if (d > 0 && i - d < 250) return;
|
|
1425
|
+
d = i, g();
|
|
1426
|
+
let a = St(t.launch, t.session, t.chrome), o = () => {
|
|
1366
1427
|
if (r) return;
|
|
1367
1428
|
let t = n.contentWindow;
|
|
1368
|
-
t &&
|
|
1429
|
+
t && _t(t, a, e.playerOrigin);
|
|
1369
1430
|
};
|
|
1370
1431
|
o();
|
|
1371
|
-
for (let e = 1; e <= 12; e += 1)
|
|
1372
|
-
},
|
|
1373
|
-
r || !
|
|
1374
|
-
},
|
|
1375
|
-
if (
|
|
1376
|
-
|
|
1432
|
+
for (let e = 1; e <= 12; e += 1) f.push(window.setTimeout(o, e * 75));
|
|
1433
|
+
}, v = () => {
|
|
1434
|
+
r || !l || _(l);
|
|
1435
|
+
}, y = () => {
|
|
1436
|
+
if (u += 1, u === 1) {
|
|
1437
|
+
gt(e.src, e.playerOrigin).then(() => p?.(), (e) => m?.(e instanceof Error ? e : Error(String(e))));
|
|
1377
1438
|
return;
|
|
1378
1439
|
}
|
|
1379
|
-
|
|
1380
|
-
},
|
|
1381
|
-
|
|
1440
|
+
d = 0, v();
|
|
1441
|
+
}, b = () => {
|
|
1442
|
+
u > 0 || m?.(Error(ht(e.playerOrigin)));
|
|
1382
1443
|
};
|
|
1383
|
-
n.addEventListener("load",
|
|
1384
|
-
let
|
|
1444
|
+
n.addEventListener("load", y), n.addEventListener("error", b);
|
|
1445
|
+
let x = (t) => {
|
|
1385
1446
|
if (r || t.source !== n.contentWindow || t.origin !== e.playerOrigin) return;
|
|
1386
|
-
let
|
|
1387
|
-
if (
|
|
1447
|
+
let i = xt(t.data);
|
|
1448
|
+
if (i) switch (i.type) {
|
|
1388
1449
|
case "close":
|
|
1389
|
-
e.onClose?.(
|
|
1450
|
+
e.onClose?.(i.payload);
|
|
1390
1451
|
break;
|
|
1391
1452
|
case "stateUpdate":
|
|
1392
|
-
e.onPlayerStatusChange?.(
|
|
1453
|
+
e.onPlayerStatusChange?.(i.payload.state), e.onStateUpdate?.(i.payload.state);
|
|
1393
1454
|
break;
|
|
1394
1455
|
case "commandResult": {
|
|
1395
|
-
let e =
|
|
1456
|
+
let e = c.get(i.payload.correlationId);
|
|
1396
1457
|
if (!e) return;
|
|
1397
|
-
|
|
1458
|
+
c.delete(i.payload.correlationId), i.payload.ok ? e.resolve(i.payload.result) : e.reject(Error(i.payload.error ?? "Command failed."));
|
|
1398
1459
|
break;
|
|
1399
1460
|
}
|
|
1400
1461
|
case "userTranscript":
|
|
1401
|
-
e.onUserTranscript?.(
|
|
1462
|
+
e.onUserTranscript?.(i.payload);
|
|
1402
1463
|
break;
|
|
1403
1464
|
case "characterSpeechStarted":
|
|
1404
|
-
e.onCharacterSpeechStarted?.(
|
|
1465
|
+
e.onCharacterSpeechStarted?.(i.payload);
|
|
1405
1466
|
break;
|
|
1406
1467
|
case "characterSpeechEnded":
|
|
1407
|
-
e.onCharacterSpeechEnded?.(
|
|
1468
|
+
e.onCharacterSpeechEnded?.(i.payload);
|
|
1408
1469
|
break;
|
|
1409
1470
|
case "characterFocusChanged":
|
|
1410
|
-
e.onCharacterFocusChanged?.(
|
|
1471
|
+
e.onCharacterFocusChanged?.(i.payload);
|
|
1411
1472
|
break;
|
|
1412
1473
|
case "conversationUpdate":
|
|
1413
|
-
e.onConversationUpdate?.(
|
|
1474
|
+
e.onConversationUpdate?.(i.payload.conversation);
|
|
1414
1475
|
break;
|
|
1415
1476
|
case "listeningState":
|
|
1416
|
-
e.onListeningState?.(
|
|
1477
|
+
e.onListeningState?.(i.payload.listening);
|
|
1417
1478
|
break;
|
|
1418
1479
|
case "userSpeechStarted":
|
|
1419
|
-
e.onUserSpeechStarted?.(
|
|
1480
|
+
e.onUserSpeechStarted?.(i.payload);
|
|
1420
1481
|
break;
|
|
1421
1482
|
case "userSpeechEnded":
|
|
1422
|
-
e.onUserSpeechEnded?.(
|
|
1483
|
+
e.onUserSpeechEnded?.(i.payload);
|
|
1423
1484
|
break;
|
|
1424
1485
|
case "modeChange":
|
|
1425
|
-
e.onActivityChange?.(
|
|
1486
|
+
e.onActivityChange?.(At(i.payload.mode));
|
|
1426
1487
|
break;
|
|
1427
1488
|
case "activityChange":
|
|
1428
|
-
e.onActivityChange?.(
|
|
1489
|
+
e.onActivityChange?.(i.payload.activity);
|
|
1429
1490
|
break;
|
|
1430
1491
|
case "feedback":
|
|
1431
|
-
e.onFeedback?.(
|
|
1492
|
+
e.onFeedback?.(i.payload);
|
|
1432
1493
|
break;
|
|
1433
1494
|
case "feedbackFailed":
|
|
1434
|
-
e.onFeedbackFailed?.(
|
|
1495
|
+
e.onFeedbackFailed?.(i.payload);
|
|
1435
1496
|
break;
|
|
1436
1497
|
case "message":
|
|
1437
|
-
e.onMessage?.(
|
|
1498
|
+
e.onMessage?.(i.payload);
|
|
1438
1499
|
break;
|
|
1439
1500
|
case "started":
|
|
1440
|
-
e.onStarted?.(
|
|
1501
|
+
e.onStarted?.(i.payload);
|
|
1441
1502
|
break;
|
|
1442
1503
|
case "embedReady":
|
|
1443
|
-
|
|
1504
|
+
v();
|
|
1444
1505
|
break;
|
|
1445
1506
|
case "widgetReady":
|
|
1446
1507
|
e.onWidgetReady?.();
|
|
@@ -1452,52 +1513,55 @@ function Ct(e) {
|
|
|
1452
1513
|
e.onWidgetCollapse?.();
|
|
1453
1514
|
break;
|
|
1454
1515
|
case "widgetAudioSettings":
|
|
1455
|
-
e.onWidgetAudioSettings?.(
|
|
1516
|
+
e.onWidgetAudioSettings?.(i.payload.open);
|
|
1456
1517
|
break;
|
|
1457
1518
|
case "widgetDragStart":
|
|
1458
|
-
e.onWidgetDragStart?.(
|
|
1519
|
+
e.onWidgetDragStart?.(i.payload);
|
|
1459
1520
|
break;
|
|
1460
1521
|
case "widgetDragMove":
|
|
1461
|
-
e.onWidgetDragMove?.(
|
|
1522
|
+
e.onWidgetDragMove?.(i.payload);
|
|
1462
1523
|
break;
|
|
1463
1524
|
case "widgetDragEnd":
|
|
1464
|
-
e.onWidgetDragEnd?.(
|
|
1525
|
+
e.onWidgetDragEnd?.(i.payload);
|
|
1526
|
+
break;
|
|
1527
|
+
case "fullWindow":
|
|
1528
|
+
s(i.payload.active);
|
|
1465
1529
|
break;
|
|
1466
1530
|
}
|
|
1467
1531
|
};
|
|
1468
|
-
if (window.addEventListener("message",
|
|
1532
|
+
if (window.addEventListener("message", x), t.replaceChildren(n), t.clientHeight < 2 && !t.style.minHeight) {
|
|
1469
1533
|
let e = getComputedStyle(t).minHeight;
|
|
1470
1534
|
(e === "0px" || e === "auto") && (t.style.minHeight = "480px");
|
|
1471
1535
|
}
|
|
1472
|
-
let
|
|
1536
|
+
let S = (t, i) => {
|
|
1473
1537
|
if (r) return;
|
|
1474
1538
|
let a = n.contentWindow;
|
|
1475
|
-
if (!a) throw Error(
|
|
1476
|
-
|
|
1477
|
-
},
|
|
1539
|
+
if (!a) throw Error(ht(e.playerOrigin));
|
|
1540
|
+
_t(a, t, e.playerOrigin, i);
|
|
1541
|
+
}, C = (e, t = 12e4, n) => {
|
|
1478
1542
|
let r = e.type !== "parentHello" && e.payload && "correlationId" in e.payload ? e.payload.correlationId : Z();
|
|
1479
|
-
return e.type !== "parentHello" && e.payload && "correlationId" in e.payload || e.type !== "parentHello" && e.payload && (e.payload.correlationId = r), new Promise((
|
|
1480
|
-
|
|
1481
|
-
resolve: (e) =>
|
|
1482
|
-
reject:
|
|
1483
|
-
}),
|
|
1484
|
-
|
|
1543
|
+
return e.type !== "parentHello" && e.payload && "correlationId" in e.payload || e.type !== "parentHello" && e.payload && (e.payload.correlationId = r), new Promise((i, a) => {
|
|
1544
|
+
c.set(r, {
|
|
1545
|
+
resolve: (e) => i(e),
|
|
1546
|
+
reject: a
|
|
1547
|
+
}), S(e, n), setTimeout(() => {
|
|
1548
|
+
c.has(r) && (c.delete(r), a(/* @__PURE__ */ Error("Timed out waiting for player command result.")));
|
|
1485
1549
|
}, t);
|
|
1486
1550
|
});
|
|
1487
1551
|
};
|
|
1488
1552
|
return {
|
|
1489
1553
|
waitForLoad() {
|
|
1490
|
-
return
|
|
1554
|
+
return h;
|
|
1491
1555
|
},
|
|
1492
1556
|
postParentHello() {
|
|
1493
|
-
|
|
1557
|
+
S(Ct());
|
|
1494
1558
|
},
|
|
1495
1559
|
postLaunch(e, t, n) {
|
|
1496
|
-
r || (
|
|
1560
|
+
r || (l = {
|
|
1497
1561
|
launch: e,
|
|
1498
1562
|
session: t,
|
|
1499
1563
|
chrome: n
|
|
1500
|
-
},
|
|
1564
|
+
}, d = 0, _(l));
|
|
1501
1565
|
},
|
|
1502
1566
|
postManifest(e) {
|
|
1503
1567
|
if (typeof e == "string") {
|
|
@@ -1512,13 +1576,13 @@ function Ct(e) {
|
|
|
1512
1576
|
throw Error("postManifest is deprecated; use postLaunch with an opaque launch string from SessionLaunchResponse.");
|
|
1513
1577
|
},
|
|
1514
1578
|
postWidgetSetChrome(e) {
|
|
1515
|
-
|
|
1579
|
+
S(wt(e));
|
|
1516
1580
|
},
|
|
1517
1581
|
postWidgetToggleAudioSettings() {
|
|
1518
|
-
|
|
1582
|
+
S(Tt());
|
|
1519
1583
|
},
|
|
1520
1584
|
speak(e) {
|
|
1521
|
-
return
|
|
1585
|
+
return C({
|
|
1522
1586
|
type: "speak",
|
|
1523
1587
|
schemaVersion: 2,
|
|
1524
1588
|
payload: {
|
|
@@ -1530,21 +1594,21 @@ function Ct(e) {
|
|
|
1530
1594
|
});
|
|
1531
1595
|
},
|
|
1532
1596
|
startListening() {
|
|
1533
|
-
return
|
|
1597
|
+
return C({
|
|
1534
1598
|
type: "startListening",
|
|
1535
1599
|
schemaVersion: 2,
|
|
1536
1600
|
payload: { correlationId: Z() }
|
|
1537
1601
|
});
|
|
1538
1602
|
},
|
|
1539
1603
|
stopListening() {
|
|
1540
|
-
return
|
|
1604
|
+
return C({
|
|
1541
1605
|
type: "stopListening",
|
|
1542
1606
|
schemaVersion: 2,
|
|
1543
1607
|
payload: { correlationId: Z() }
|
|
1544
1608
|
});
|
|
1545
1609
|
},
|
|
1546
1610
|
listenOnce(e) {
|
|
1547
|
-
return
|
|
1611
|
+
return C({
|
|
1548
1612
|
type: "listenOnce",
|
|
1549
1613
|
schemaVersion: 2,
|
|
1550
1614
|
payload: {
|
|
@@ -1554,7 +1618,7 @@ function Ct(e) {
|
|
|
1554
1618
|
});
|
|
1555
1619
|
},
|
|
1556
1620
|
async speakProcessorStream(e, t) {
|
|
1557
|
-
let n = Z(), r = Z(), i = (await
|
|
1621
|
+
let n = Z(), r = Z(), i = (await C({
|
|
1558
1622
|
type: "speakStreamStart",
|
|
1559
1623
|
schemaVersion: 2,
|
|
1560
1624
|
payload: {
|
|
@@ -1566,7 +1630,7 @@ function Ct(e) {
|
|
|
1566
1630
|
try {
|
|
1567
1631
|
for await (let n of e) {
|
|
1568
1632
|
if (t?.signal?.aborted) throw new DOMException("Processor stream aborted.", "AbortError");
|
|
1569
|
-
n &&
|
|
1633
|
+
n && S({
|
|
1570
1634
|
type: "speakStreamChunk",
|
|
1571
1635
|
schemaVersion: 2,
|
|
1572
1636
|
payload: {
|
|
@@ -1576,7 +1640,7 @@ function Ct(e) {
|
|
|
1576
1640
|
});
|
|
1577
1641
|
}
|
|
1578
1642
|
if (t?.signal?.aborted) throw new DOMException("Processor stream aborted.", "AbortError");
|
|
1579
|
-
return await
|
|
1643
|
+
return await C({
|
|
1580
1644
|
type: "speakStreamEnd",
|
|
1581
1645
|
schemaVersion: 2,
|
|
1582
1646
|
payload: {
|
|
@@ -1586,7 +1650,7 @@ function Ct(e) {
|
|
|
1586
1650
|
});
|
|
1587
1651
|
} catch (e) {
|
|
1588
1652
|
try {
|
|
1589
|
-
await
|
|
1653
|
+
await C({
|
|
1590
1654
|
type: "speakStreamEnd",
|
|
1591
1655
|
schemaVersion: 2,
|
|
1592
1656
|
payload: {
|
|
@@ -1600,7 +1664,7 @@ function Ct(e) {
|
|
|
1600
1664
|
},
|
|
1601
1665
|
speechPlay(e) {
|
|
1602
1666
|
let t = Z(), n = [];
|
|
1603
|
-
return (e.source.kind === "pcm" || e.source.kind === "encoded") && n.push(e.source.data),
|
|
1667
|
+
return (e.source.kind === "pcm" || e.source.kind === "encoded") && n.push(e.source.data), C({
|
|
1604
1668
|
type: "speechPlay",
|
|
1605
1669
|
schemaVersion: 2,
|
|
1606
1670
|
payload: {
|
|
@@ -1614,7 +1678,7 @@ function Ct(e) {
|
|
|
1614
1678
|
}, 12e4, n);
|
|
1615
1679
|
},
|
|
1616
1680
|
speechUtteranceBegin(e) {
|
|
1617
|
-
return
|
|
1681
|
+
return C({
|
|
1618
1682
|
type: "speechUtteranceBegin",
|
|
1619
1683
|
schemaVersion: 2,
|
|
1620
1684
|
payload: {
|
|
@@ -1628,7 +1692,7 @@ function Ct(e) {
|
|
|
1628
1692
|
});
|
|
1629
1693
|
},
|
|
1630
1694
|
speechUtteranceWrite(e) {
|
|
1631
|
-
return
|
|
1695
|
+
return C({
|
|
1632
1696
|
type: "speechUtteranceWrite",
|
|
1633
1697
|
schemaVersion: 2,
|
|
1634
1698
|
payload: {
|
|
@@ -1637,10 +1701,10 @@ function Ct(e) {
|
|
|
1637
1701
|
audio: e.audio,
|
|
1638
1702
|
byteLength: e.byteLength
|
|
1639
1703
|
}
|
|
1640
|
-
},
|
|
1704
|
+
}, jt, [e.audio]);
|
|
1641
1705
|
},
|
|
1642
1706
|
speechUtteranceSetTranscript(e) {
|
|
1643
|
-
return
|
|
1707
|
+
return C({
|
|
1644
1708
|
type: "speechUtteranceSetTranscript",
|
|
1645
1709
|
schemaVersion: 2,
|
|
1646
1710
|
payload: {
|
|
@@ -1651,7 +1715,7 @@ function Ct(e) {
|
|
|
1651
1715
|
});
|
|
1652
1716
|
},
|
|
1653
1717
|
speechUtteranceClose(e) {
|
|
1654
|
-
return
|
|
1718
|
+
return C({
|
|
1655
1719
|
type: "speechUtteranceClose",
|
|
1656
1720
|
schemaVersion: 2,
|
|
1657
1721
|
payload: {
|
|
@@ -1663,7 +1727,7 @@ function Ct(e) {
|
|
|
1663
1727
|
});
|
|
1664
1728
|
},
|
|
1665
1729
|
speechUtteranceCancel(e) {
|
|
1666
|
-
return
|
|
1730
|
+
return C({
|
|
1667
1731
|
type: "speechUtteranceCancel",
|
|
1668
1732
|
schemaVersion: 2,
|
|
1669
1733
|
payload: {
|
|
@@ -1673,7 +1737,7 @@ function Ct(e) {
|
|
|
1673
1737
|
});
|
|
1674
1738
|
},
|
|
1675
1739
|
speechInterrupt(e) {
|
|
1676
|
-
return
|
|
1740
|
+
return C({
|
|
1677
1741
|
type: "speechInterrupt",
|
|
1678
1742
|
schemaVersion: 2,
|
|
1679
1743
|
payload: {
|
|
@@ -1683,14 +1747,14 @@ function Ct(e) {
|
|
|
1683
1747
|
});
|
|
1684
1748
|
},
|
|
1685
1749
|
getConversation() {
|
|
1686
|
-
return
|
|
1750
|
+
return C({
|
|
1687
1751
|
type: "getConversation",
|
|
1688
1752
|
schemaVersion: 2,
|
|
1689
1753
|
payload: { correlationId: Z() }
|
|
1690
1754
|
});
|
|
1691
1755
|
},
|
|
1692
1756
|
focusCharacter(e) {
|
|
1693
|
-
return
|
|
1757
|
+
return C({
|
|
1694
1758
|
type: "focusCharacter",
|
|
1695
1759
|
schemaVersion: 2,
|
|
1696
1760
|
payload: {
|
|
@@ -1700,7 +1764,7 @@ function Ct(e) {
|
|
|
1700
1764
|
});
|
|
1701
1765
|
},
|
|
1702
1766
|
setFit(e) {
|
|
1703
|
-
return
|
|
1767
|
+
return C({
|
|
1704
1768
|
type: "setFit",
|
|
1705
1769
|
schemaVersion: 2,
|
|
1706
1770
|
payload: {
|
|
@@ -1709,18 +1773,28 @@ function Ct(e) {
|
|
|
1709
1773
|
}
|
|
1710
1774
|
});
|
|
1711
1775
|
},
|
|
1776
|
+
conversion(e) {
|
|
1777
|
+
return C({
|
|
1778
|
+
type: "conversion",
|
|
1779
|
+
schemaVersion: 2,
|
|
1780
|
+
payload: {
|
|
1781
|
+
correlationId: Z(),
|
|
1782
|
+
key: e
|
|
1783
|
+
}
|
|
1784
|
+
});
|
|
1785
|
+
},
|
|
1712
1786
|
destroy() {
|
|
1713
1787
|
if (!r) {
|
|
1714
|
-
r = !0;
|
|
1715
|
-
for (let e of
|
|
1716
|
-
|
|
1788
|
+
r = !0, i && s(!1);
|
|
1789
|
+
for (let e of c.values()) e.reject(/* @__PURE__ */ Error("Iframe host destroyed."));
|
|
1790
|
+
c.clear(), g(), l = null, n.removeEventListener("load", y), n.removeEventListener("error", b), window.removeEventListener("message", x), n.remove();
|
|
1717
1791
|
}
|
|
1718
1792
|
}
|
|
1719
1793
|
};
|
|
1720
1794
|
}
|
|
1721
1795
|
//#endregion
|
|
1722
1796
|
//#region src/v2/embed/readyGate.ts
|
|
1723
|
-
function
|
|
1797
|
+
function Nt(e) {
|
|
1724
1798
|
let t, n = !1, r = !1, i = () => {
|
|
1725
1799
|
r || !n || t === void 0 || (r = !0, e(t));
|
|
1726
1800
|
};
|
|
@@ -1735,50 +1809,50 @@ function wt(e) {
|
|
|
1735
1809
|
}
|
|
1736
1810
|
//#endregion
|
|
1737
1811
|
//#region src/v2/shims/embedBaseUrl.ts
|
|
1738
|
-
var
|
|
1739
|
-
function
|
|
1812
|
+
var Pt = "https://player.liforma.ai/embed", Ft = "http://localhost:3002/embed";
|
|
1813
|
+
function It() {
|
|
1740
1814
|
let e = globalThis.__LIFORMA_PLAYER_EMBED_URL;
|
|
1741
1815
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
1742
1816
|
if (typeof document > "u") return null;
|
|
1743
1817
|
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();
|
|
1744
1818
|
return t ? t.replace(/\/$/, "") : null;
|
|
1745
1819
|
}
|
|
1746
|
-
function
|
|
1747
|
-
let e =
|
|
1748
|
-
return e ? e.endsWith("/embed") ? e : `${e}/embed` : ae() ?
|
|
1820
|
+
function Lt() {
|
|
1821
|
+
let e = It();
|
|
1822
|
+
return e ? e.endsWith("/embed") ? e : `${e}/embed` : ae() ? Ft : Pt;
|
|
1749
1823
|
}
|
|
1750
|
-
function
|
|
1824
|
+
function Rt(e, t) {
|
|
1751
1825
|
return e?.trim() || t?.trim() || void 0;
|
|
1752
1826
|
}
|
|
1753
|
-
function
|
|
1754
|
-
let c = (e ??
|
|
1827
|
+
function zt(e, t, n, r, i, a, o, s) {
|
|
1828
|
+
let c = (e ?? Lt()).replace(/\/$/, ""), l = c.endsWith("/embed") ? c : `${c}/embed`, u = new URL(l), d = n?.trim();
|
|
1755
1829
|
d && (u.searchParams.set("backdropId", d), u.searchParams.set("locationId", d));
|
|
1756
1830
|
let f = r?.trim();
|
|
1757
|
-
return f && u.searchParams.set("avatarId", f), (i === "face" || i === "medium") && u.searchParams.set("fit", i), a === "widget" && u.searchParams.set("ui", "widget"), o && u.searchParams.set("close", "1"), t && u.searchParams.set("debug", "true"), (s === 2 || s === 3 || s === 4) && u.searchParams.set("cast", String(s)),
|
|
1831
|
+
return f && u.searchParams.set("avatarId", f), (i === "face" || i === "medium") && u.searchParams.set("fit", i), a === "widget" && u.searchParams.set("ui", "widget"), o && u.searchParams.set("close", "1"), t && u.searchParams.set("debug", "true"), (s === 2 || s === 3 || s === 4) && u.searchParams.set("cast", String(s)), Bt(u.toString());
|
|
1758
1832
|
}
|
|
1759
|
-
function
|
|
1833
|
+
function Bt(e) {
|
|
1760
1834
|
if (typeof location > "u") return e;
|
|
1761
1835
|
let t = new URL(e);
|
|
1762
1836
|
return t.searchParams.set("parentOrigin", location.origin), t.toString();
|
|
1763
1837
|
}
|
|
1764
|
-
function
|
|
1838
|
+
function Vt(e) {
|
|
1765
1839
|
return new URL(e).origin;
|
|
1766
1840
|
}
|
|
1767
1841
|
//#endregion
|
|
1768
1842
|
//#region src/v2/experienceEvents.ts
|
|
1769
|
-
function
|
|
1843
|
+
function Ht() {
|
|
1770
1844
|
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)}`;
|
|
1771
1845
|
}
|
|
1772
|
-
function
|
|
1846
|
+
function Ut(e, t, n) {
|
|
1773
1847
|
return {
|
|
1774
|
-
id:
|
|
1848
|
+
id: Ht(),
|
|
1775
1849
|
type: e,
|
|
1776
1850
|
sessionId: t,
|
|
1777
1851
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1778
1852
|
data: n
|
|
1779
1853
|
};
|
|
1780
1854
|
}
|
|
1781
|
-
function
|
|
1855
|
+
function Wt() {
|
|
1782
1856
|
return {
|
|
1783
1857
|
ready: /* @__PURE__ */ new Set(),
|
|
1784
1858
|
started: /* @__PURE__ */ new Set(),
|
|
@@ -1797,39 +1871,39 @@ function Ft() {
|
|
|
1797
1871
|
conversationProcessorError: /* @__PURE__ */ new Set()
|
|
1798
1872
|
};
|
|
1799
1873
|
}
|
|
1800
|
-
function
|
|
1874
|
+
function Gt(e, t, n) {
|
|
1801
1875
|
return e[t].add(n), () => e[t].delete(n);
|
|
1802
1876
|
}
|
|
1803
|
-
function
|
|
1877
|
+
function Kt(e, t, n) {
|
|
1804
1878
|
for (let r of e[t]) r(n);
|
|
1805
1879
|
}
|
|
1806
|
-
function
|
|
1880
|
+
function qt(e) {
|
|
1807
1881
|
for (let t of Object.keys(e)) e[t].clear();
|
|
1808
1882
|
}
|
|
1809
1883
|
//#endregion
|
|
1810
1884
|
//#region src/v2/speech/types.ts
|
|
1811
|
-
function
|
|
1885
|
+
function Jt(e) {
|
|
1812
1886
|
return "data" in e && "format" in e && e.format != null && !("track" in e);
|
|
1813
1887
|
}
|
|
1814
|
-
function
|
|
1888
|
+
function Yt(e) {
|
|
1815
1889
|
return "url" in e && typeof e.url == "string";
|
|
1816
1890
|
}
|
|
1817
|
-
function
|
|
1891
|
+
function Xt(e) {
|
|
1818
1892
|
if (!("track" in e)) return !1;
|
|
1819
1893
|
let t = e.track;
|
|
1820
1894
|
return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
|
|
1821
1895
|
}
|
|
1822
|
-
function
|
|
1823
|
-
return !
|
|
1896
|
+
function Zt(e) {
|
|
1897
|
+
return !Jt(e) && !Yt(e) && !Xt(e) && "encoding" in e && typeof e.encoding == "string";
|
|
1824
1898
|
}
|
|
1825
|
-
var
|
|
1899
|
+
var Qt = [
|
|
1826
1900
|
8e3,
|
|
1827
1901
|
16e3,
|
|
1828
1902
|
22050,
|
|
1829
1903
|
24e3,
|
|
1830
1904
|
44100,
|
|
1831
1905
|
48e3
|
|
1832
|
-
],
|
|
1906
|
+
], $t = {
|
|
1833
1907
|
MAX_CHUNK_BYTES: 64 * 1024,
|
|
1834
1908
|
RECOMMENDED_CHUNK_MS_MIN: 20,
|
|
1835
1909
|
RECOMMENDED_CHUNK_MS_MAX: 200,
|
|
@@ -1840,14 +1914,14 @@ var Ut = [
|
|
|
1840
1914
|
MAX_UTTERANCE_DURATION_MS: 9e4,
|
|
1841
1915
|
MAX_PENDING_WRITES: 8,
|
|
1842
1916
|
DEFAULT_WRITE_TIMEOUT_MS: 5e3
|
|
1843
|
-
},
|
|
1917
|
+
}, en = class extends Error {
|
|
1844
1918
|
operation;
|
|
1845
1919
|
requiredCapability;
|
|
1846
1920
|
name = "UnsupportedSpeechOperationError";
|
|
1847
1921
|
constructor(e, t) {
|
|
1848
1922
|
super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
|
|
1849
1923
|
}
|
|
1850
|
-
},
|
|
1924
|
+
}, tn = class extends Error {
|
|
1851
1925
|
name = "SpeechUtteranceClosedError";
|
|
1852
1926
|
constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
|
|
1853
1927
|
super(e);
|
|
@@ -1857,72 +1931,72 @@ var Ut = [
|
|
|
1857
1931
|
constructor(e, t) {
|
|
1858
1932
|
super(e, t);
|
|
1859
1933
|
}
|
|
1860
|
-
},
|
|
1934
|
+
}, nn = class extends Error {
|
|
1861
1935
|
name = "SpeechBufferTimeoutError";
|
|
1862
1936
|
constructor(e = "Timed out waiting for speech buffer capacity.") {
|
|
1863
1937
|
super(e);
|
|
1864
1938
|
}
|
|
1865
1939
|
};
|
|
1866
|
-
function
|
|
1940
|
+
function rn(e = "none") {
|
|
1867
1941
|
return {
|
|
1868
1942
|
mode: e,
|
|
1869
1943
|
trackedDurationMs: 0,
|
|
1870
1944
|
fallbackDurationMs: 0
|
|
1871
1945
|
};
|
|
1872
1946
|
}
|
|
1873
|
-
function
|
|
1874
|
-
return
|
|
1947
|
+
function an(e) {
|
|
1948
|
+
return Qt.includes(e);
|
|
1875
1949
|
}
|
|
1876
|
-
function
|
|
1950
|
+
function on(e) {
|
|
1877
1951
|
if (e.encoding !== "pcm_s16le") throw new Q(`Unsupported audio encoding: ${e.encoding}`);
|
|
1878
1952
|
if (e.channels !== 1) throw new Q(`Unsupported channel count: ${e.channels}`);
|
|
1879
|
-
if (!
|
|
1953
|
+
if (!an(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1880
1954
|
}
|
|
1881
|
-
function
|
|
1882
|
-
if (
|
|
1883
|
-
|
|
1955
|
+
function sn(e) {
|
|
1956
|
+
if (Jt(e)) {
|
|
1957
|
+
on(e.format);
|
|
1884
1958
|
return;
|
|
1885
1959
|
}
|
|
1886
|
-
if (
|
|
1960
|
+
if (Yt(e)) {
|
|
1887
1961
|
if (!e.url.trim()) throw new Q("Audio URL must be non-empty.");
|
|
1888
|
-
if (e.sampleRate !== void 0 && !
|
|
1962
|
+
if (e.sampleRate !== void 0 && !an(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1889
1963
|
return;
|
|
1890
1964
|
}
|
|
1891
|
-
if (
|
|
1965
|
+
if (Xt(e)) {
|
|
1892
1966
|
if (e.track.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
1893
|
-
if (e.sampleRate !== void 0 && !
|
|
1967
|
+
if (e.sampleRate !== void 0 && !an(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1894
1968
|
return;
|
|
1895
1969
|
}
|
|
1896
|
-
if (
|
|
1970
|
+
if (Zt(e)) {
|
|
1897
1971
|
let t = e.encoding.trim().toLowerCase();
|
|
1898
1972
|
if (!t) throw new Q("Encoded audio MIME type is required.");
|
|
1899
1973
|
if (t === "pcm_s16le") throw new Q("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
|
|
1900
|
-
if (e.sampleRate !== void 0 && !
|
|
1974
|
+
if (e.sampleRate !== void 0 && !an(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1901
1975
|
return;
|
|
1902
1976
|
}
|
|
1903
1977
|
throw new Q("Unsupported speech.play audio shape.");
|
|
1904
1978
|
}
|
|
1905
|
-
function
|
|
1906
|
-
if (e.format) return
|
|
1979
|
+
function cn(e) {
|
|
1980
|
+
if (e.format) return on(e.format), e.format;
|
|
1907
1981
|
if (e.track) {
|
|
1908
1982
|
let t = {
|
|
1909
1983
|
encoding: "pcm_s16le",
|
|
1910
1984
|
sampleRate: e.sampleRate ?? 24e3,
|
|
1911
1985
|
channels: 1
|
|
1912
1986
|
};
|
|
1913
|
-
return
|
|
1987
|
+
return on(t), t;
|
|
1914
1988
|
}
|
|
1915
1989
|
throw new Q("createUtterance requires format or track.");
|
|
1916
1990
|
}
|
|
1917
|
-
function
|
|
1991
|
+
function ln(e) {
|
|
1918
1992
|
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1919
1993
|
}
|
|
1920
|
-
function
|
|
1994
|
+
function un(e) {
|
|
1921
1995
|
return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
|
|
1922
1996
|
}
|
|
1923
1997
|
//#endregion
|
|
1924
1998
|
//#region src/byo/pcm.ts
|
|
1925
|
-
function
|
|
1999
|
+
function dn(e) {
|
|
1926
2000
|
let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
|
|
1927
2001
|
for (let t = 0; t < e.length; t++) {
|
|
1928
2002
|
let r = Math.max(-1, Math.min(1, e[t]));
|
|
@@ -1932,11 +2006,11 @@ function tn(e) {
|
|
|
1932
2006
|
}
|
|
1933
2007
|
//#endregion
|
|
1934
2008
|
//#region src/byo/resample.ts
|
|
1935
|
-
function
|
|
2009
|
+
function fn(e, t, n, r, i) {
|
|
1936
2010
|
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;
|
|
1937
2011
|
return ((a * i + o) * i + s) * i + c;
|
|
1938
2012
|
}
|
|
1939
|
-
function
|
|
2013
|
+
function pn(e, t) {
|
|
1940
2014
|
if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
|
|
1941
2015
|
if (e === t) return {
|
|
1942
2016
|
fromRate: e,
|
|
@@ -1959,7 +2033,7 @@ function rn(e, t) {
|
|
|
1959
2033
|
let a = [];
|
|
1960
2034
|
for (; i + 2 < r.length - 1;) {
|
|
1961
2035
|
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);
|
|
1962
|
-
a.push(
|
|
2036
|
+
a.push(fn(r[o], r[e], r[s], r[c], t)), i += n;
|
|
1963
2037
|
}
|
|
1964
2038
|
let o = Math.max(0, Math.floor(i) - 1);
|
|
1965
2039
|
return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
|
|
@@ -1971,7 +2045,7 @@ function rn(e, t) {
|
|
|
1971
2045
|
}
|
|
1972
2046
|
//#endregion
|
|
1973
2047
|
//#region src/byo/audioCapture.ts
|
|
1974
|
-
var
|
|
2048
|
+
var mn = "liforma-pcm-capture", hn = `
|
|
1975
2049
|
class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
1976
2050
|
process(inputs) {
|
|
1977
2051
|
const ch = inputs[0] && inputs[0][0];
|
|
@@ -1983,29 +2057,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
|
1983
2057
|
return true;
|
|
1984
2058
|
}
|
|
1985
2059
|
}
|
|
1986
|
-
registerProcessor('${
|
|
1987
|
-
`,
|
|
1988
|
-
function
|
|
1989
|
-
return
|
|
2060
|
+
registerProcessor('${mn}', LiformaPcmCaptureProcessor);
|
|
2061
|
+
`, gn = null;
|
|
2062
|
+
function _n() {
|
|
2063
|
+
return gn ||= URL.createObjectURL(new Blob([hn], { type: "application/javascript" })), gn;
|
|
1990
2064
|
}
|
|
1991
|
-
function
|
|
2065
|
+
function vn() {
|
|
1992
2066
|
return window.AudioContext || window.webkitAudioContext || null;
|
|
1993
2067
|
}
|
|
1994
|
-
async function
|
|
1995
|
-
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o =
|
|
2068
|
+
async function yn(e) {
|
|
2069
|
+
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = vn();
|
|
1996
2070
|
if (!o) throw Error("Web Audio is required for audio capture");
|
|
1997
2071
|
let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
|
|
1998
2072
|
l.gain.value = 0;
|
|
1999
|
-
let u = s.sampleRate, d =
|
|
2073
|
+
let u = s.sampleRate, d = pn(u, n), f = !1, p = !1, m = (e) => {
|
|
2000
2074
|
if (f || i && !i()) return;
|
|
2001
2075
|
let t = d.push(e);
|
|
2002
|
-
t.length !== 0 && r(
|
|
2076
|
+
t.length !== 0 && r(dn(t));
|
|
2003
2077
|
}, h = () => void 0;
|
|
2004
2078
|
return await (async () => {
|
|
2005
2079
|
if (typeof s.audioWorklet?.addModule != "function") return !1;
|
|
2006
2080
|
try {
|
|
2007
|
-
await s.audioWorklet.addModule(
|
|
2008
|
-
let e = new AudioWorkletNode(s,
|
|
2081
|
+
await s.audioWorklet.addModule(_n());
|
|
2082
|
+
let e = new AudioWorkletNode(s, mn, {
|
|
2009
2083
|
numberOfInputs: 1,
|
|
2010
2084
|
numberOfOutputs: 1,
|
|
2011
2085
|
outputChannelCount: [1]
|
|
@@ -2055,7 +2129,7 @@ async function un(e) {
|
|
|
2055
2129
|
}
|
|
2056
2130
|
//#endregion
|
|
2057
2131
|
//#region src/v2/speech/captureMediaStreamTrack.ts
|
|
2058
|
-
async function
|
|
2132
|
+
async function bn(e) {
|
|
2059
2133
|
let { track: t, utterance: n, sampleRate: r, signal: i } = e;
|
|
2060
2134
|
if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Q("MediaStreamTrack is not available in this environment.");
|
|
2061
2135
|
if (t.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
@@ -2064,18 +2138,18 @@ async function dn(e) {
|
|
|
2064
2138
|
s || (s = !0, c?.stop(), c = null);
|
|
2065
2139
|
};
|
|
2066
2140
|
try {
|
|
2067
|
-
c = await
|
|
2141
|
+
c = await yn({
|
|
2068
2142
|
mediaStream: a,
|
|
2069
2143
|
targetSampleRate: r,
|
|
2070
2144
|
shouldSend: () => !s && !i?.aborted,
|
|
2071
2145
|
onPcm: (e) => {
|
|
2072
2146
|
if (s || i?.aborted) return;
|
|
2073
|
-
let t =
|
|
2147
|
+
let t = ln(e);
|
|
2074
2148
|
o = o.then(async () => {
|
|
2075
2149
|
if (s || i?.aborted) return;
|
|
2076
2150
|
let e = 0;
|
|
2077
2151
|
for (; e < t.byteLength;) {
|
|
2078
|
-
let r = Math.min(e +
|
|
2152
|
+
let r = Math.min(e + $t.MAX_CHUNK_BYTES, t.byteLength);
|
|
2079
2153
|
if ((r - e) % 2 == 1 && --r, r <= e) break;
|
|
2080
2154
|
let i = t.subarray(e, r);
|
|
2081
2155
|
e = r, i.byteLength !== 0 && await n.write(i);
|
|
@@ -2099,10 +2173,10 @@ async function dn(e) {
|
|
|
2099
2173
|
}
|
|
2100
2174
|
//#endregion
|
|
2101
2175
|
//#region src/v2/speech/speechController.ts
|
|
2102
|
-
async function
|
|
2103
|
-
if (
|
|
2104
|
-
if (
|
|
2105
|
-
let t =
|
|
2176
|
+
async function xn(e, t) {
|
|
2177
|
+
if (Xt(e)) throw new Q("MediaStreamTrack play is handled on the host before embed.");
|
|
2178
|
+
if (Jt(e)) {
|
|
2179
|
+
let t = ln(e.data);
|
|
2106
2180
|
if (t.byteLength & 1) throw new Q("PCM byte length must be even.");
|
|
2107
2181
|
return {
|
|
2108
2182
|
kind: "pcm",
|
|
@@ -2110,17 +2184,17 @@ async function fn(e, t) {
|
|
|
2110
2184
|
format: e.format
|
|
2111
2185
|
};
|
|
2112
2186
|
}
|
|
2113
|
-
if (
|
|
2187
|
+
if (Yt(e)) return {
|
|
2114
2188
|
kind: "url",
|
|
2115
2189
|
url: e.url.trim(),
|
|
2116
2190
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
2117
2191
|
};
|
|
2118
|
-
if (!
|
|
2192
|
+
if (!Zt(e)) throw new Q("Unsupported speech.play audio shape.");
|
|
2119
2193
|
let n;
|
|
2120
2194
|
if (typeof Blob < "u" && e.data instanceof Blob) {
|
|
2121
2195
|
if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2122
2196
|
n = new Uint8Array(await e.data.arrayBuffer());
|
|
2123
|
-
} else n =
|
|
2197
|
+
} else n = ln(e.data);
|
|
2124
2198
|
return {
|
|
2125
2199
|
kind: "encoded",
|
|
2126
2200
|
data: n.slice().buffer,
|
|
@@ -2128,10 +2202,10 @@ async function fn(e, t) {
|
|
|
2128
2202
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
2129
2203
|
};
|
|
2130
2204
|
}
|
|
2131
|
-
function
|
|
2205
|
+
function Sn() {
|
|
2132
2206
|
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)}`;
|
|
2133
2207
|
}
|
|
2134
|
-
function
|
|
2208
|
+
function Cn(e, t = "completed") {
|
|
2135
2209
|
return {
|
|
2136
2210
|
utteranceId: e.speechId,
|
|
2137
2211
|
characterId: e.characterId,
|
|
@@ -2145,13 +2219,13 @@ function mn(e, t = "completed") {
|
|
|
2145
2219
|
}
|
|
2146
2220
|
};
|
|
2147
2221
|
}
|
|
2148
|
-
function
|
|
2222
|
+
function wn(e) {
|
|
2149
2223
|
return e instanceof Error ? e : new Q(String(e));
|
|
2150
2224
|
}
|
|
2151
|
-
function
|
|
2225
|
+
function Tn(e) {
|
|
2152
2226
|
return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
|
|
2153
2227
|
}
|
|
2154
|
-
var
|
|
2228
|
+
var En = class {
|
|
2155
2229
|
id;
|
|
2156
2230
|
characterId;
|
|
2157
2231
|
result;
|
|
@@ -2180,29 +2254,29 @@ var _n = class {
|
|
|
2180
2254
|
queue: e.queue,
|
|
2181
2255
|
...e.transcript === void 0 ? {} : { transcript: e.transcript }
|
|
2182
2256
|
}).catch((e) => {
|
|
2183
|
-
throw this.fail(
|
|
2257
|
+
throw this.fail(wn(e)), wn(e);
|
|
2184
2258
|
}), this.signal?.addEventListener("abort", () => {
|
|
2185
2259
|
this.cancel();
|
|
2186
2260
|
}, { once: !0 });
|
|
2187
2261
|
}
|
|
2188
2262
|
async write(e, t) {
|
|
2189
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2190
|
-
let n =
|
|
2263
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new tn();
|
|
2264
|
+
let n = ln(e);
|
|
2191
2265
|
if (n.byteLength & 1) throw new Q("PCM chunk byte length must be even (complete s16 samples).");
|
|
2192
|
-
if (n.byteLength >
|
|
2266
|
+
if (n.byteLength > $t.MAX_CHUNK_BYTES) throw new Q(`PCM chunk exceeds MAX_CHUNK_BYTES (${$t.MAX_CHUNK_BYTES}).`);
|
|
2193
2267
|
if (n.byteLength === 0) return;
|
|
2194
|
-
let r = t?.timeoutMs ??
|
|
2268
|
+
let r = t?.timeoutMs ?? $t.DEFAULT_WRITE_TIMEOUT_MS;
|
|
2195
2269
|
await this.acquireWriteSlot(r);
|
|
2196
2270
|
let i = n.byteLength / 2 / this.sampleRate * 1e3;
|
|
2197
|
-
if (this.bufferedMs + i >
|
|
2271
|
+
if (this.bufferedMs + i > $t.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new Q("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
|
|
2198
2272
|
let a = async () => {
|
|
2199
|
-
if (this.closed || this.settled) throw new
|
|
2273
|
+
if (this.closed || this.settled) throw new tn();
|
|
2200
2274
|
let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
|
|
2201
2275
|
utteranceId: this.id,
|
|
2202
2276
|
audio: t.buffer,
|
|
2203
2277
|
byteLength: t.byteLength
|
|
2204
2278
|
}), a = await Promise.race([i, new Promise((e, t) => {
|
|
2205
|
-
setTimeout(() => t(new
|
|
2279
|
+
setTimeout(() => t(new nn()), r);
|
|
2206
2280
|
})]);
|
|
2207
2281
|
this.bufferedMs = Math.max(0, a.bufferedMs);
|
|
2208
2282
|
}, o = this.writeChain.then(a, a);
|
|
@@ -2214,7 +2288,7 @@ var _n = class {
|
|
|
2214
2288
|
}
|
|
2215
2289
|
}
|
|
2216
2290
|
async setTranscript(e) {
|
|
2217
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2291
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new tn();
|
|
2218
2292
|
await this.requireHost().speechUtteranceSetTranscript({
|
|
2219
2293
|
utteranceId: this.id,
|
|
2220
2294
|
transcript: e
|
|
@@ -2231,7 +2305,7 @@ var _n = class {
|
|
|
2231
2305
|
});
|
|
2232
2306
|
return this.resolve(t), t;
|
|
2233
2307
|
} catch (e) {
|
|
2234
|
-
let t =
|
|
2308
|
+
let t = wn(e);
|
|
2235
2309
|
throw this.fail(t), t;
|
|
2236
2310
|
}
|
|
2237
2311
|
}
|
|
@@ -2249,11 +2323,11 @@ var _n = class {
|
|
|
2249
2323
|
characterId: this.characterId,
|
|
2250
2324
|
status: "cancelled",
|
|
2251
2325
|
durationMs: 0,
|
|
2252
|
-
animation:
|
|
2326
|
+
animation: rn("none")
|
|
2253
2327
|
};
|
|
2254
2328
|
return this.resolve(t), t;
|
|
2255
2329
|
} catch (e) {
|
|
2256
|
-
let t =
|
|
2330
|
+
let t = wn(e);
|
|
2257
2331
|
throw this.fail(t), t;
|
|
2258
2332
|
}
|
|
2259
2333
|
}
|
|
@@ -2266,19 +2340,19 @@ var _n = class {
|
|
|
2266
2340
|
return e;
|
|
2267
2341
|
}
|
|
2268
2342
|
resolve(e) {
|
|
2269
|
-
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new
|
|
2343
|
+
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new tn()));
|
|
2270
2344
|
}
|
|
2271
2345
|
fail(e) {
|
|
2272
2346
|
this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
|
|
2273
2347
|
}
|
|
2274
2348
|
async acquireWriteSlot(e) {
|
|
2275
|
-
if (this.pendingWriteCount <
|
|
2349
|
+
if (this.pendingWriteCount < $t.MAX_PENDING_WRITES) {
|
|
2276
2350
|
this.pendingWriteCount += 1;
|
|
2277
2351
|
return;
|
|
2278
2352
|
}
|
|
2279
2353
|
await new Promise((t, n) => {
|
|
2280
2354
|
let r = setTimeout(() => {
|
|
2281
|
-
n(new
|
|
2355
|
+
n(new nn());
|
|
2282
2356
|
}, e);
|
|
2283
2357
|
this.pendingWriteWaiters.push({
|
|
2284
2358
|
resolve: () => {
|
|
@@ -2297,13 +2371,13 @@ var _n = class {
|
|
|
2297
2371
|
for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
|
|
2298
2372
|
}
|
|
2299
2373
|
};
|
|
2300
|
-
function
|
|
2374
|
+
function Dn(e) {
|
|
2301
2375
|
let t = null, n = (t, n) => {
|
|
2302
|
-
if (!e.getCapabilities()[n]) throw new
|
|
2376
|
+
if (!e.getCapabilities()[n]) throw new en(t, n);
|
|
2303
2377
|
}, r = {
|
|
2304
2378
|
async speak(r) {
|
|
2305
2379
|
if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
|
|
2306
|
-
let i =
|
|
2380
|
+
let i = un(r.queue ?? "append");
|
|
2307
2381
|
i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
|
|
2308
2382
|
let a = e.getIframeHost();
|
|
2309
2383
|
if (!a) throw new Q("Speech session is not attached.");
|
|
@@ -2323,41 +2397,41 @@ function vn(e) {
|
|
|
2323
2397
|
return;
|
|
2324
2398
|
}
|
|
2325
2399
|
t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
|
|
2326
|
-
t.removeEventListener("abort", s), n(
|
|
2400
|
+
t.removeEventListener("abort", s), n(Cn(e, "completed"));
|
|
2327
2401
|
}, (a) => {
|
|
2328
|
-
if (t.removeEventListener("abort", s),
|
|
2402
|
+
if (t.removeEventListener("abort", s), Tn(a)) {
|
|
2329
2403
|
n({
|
|
2330
2404
|
utteranceId: "utt_interrupted",
|
|
2331
2405
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2332
2406
|
status: "interrupted",
|
|
2333
2407
|
durationMs: 0,
|
|
2334
2408
|
transcript: r.text,
|
|
2335
|
-
animation:
|
|
2409
|
+
animation: rn("none")
|
|
2336
2410
|
});
|
|
2337
2411
|
return;
|
|
2338
2412
|
}
|
|
2339
|
-
i(
|
|
2413
|
+
i(wn(a));
|
|
2340
2414
|
});
|
|
2341
2415
|
});
|
|
2342
2416
|
}
|
|
2343
2417
|
try {
|
|
2344
|
-
return
|
|
2418
|
+
return Cn(await o, "completed");
|
|
2345
2419
|
} catch (t) {
|
|
2346
|
-
if (
|
|
2420
|
+
if (Tn(t)) return {
|
|
2347
2421
|
utteranceId: "utt_interrupted",
|
|
2348
2422
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2349
2423
|
status: "interrupted",
|
|
2350
2424
|
durationMs: 0,
|
|
2351
2425
|
transcript: r.text,
|
|
2352
|
-
animation:
|
|
2426
|
+
animation: rn("none")
|
|
2353
2427
|
};
|
|
2354
|
-
throw
|
|
2428
|
+
throw wn(t);
|
|
2355
2429
|
}
|
|
2356
2430
|
},
|
|
2357
2431
|
async play(i) {
|
|
2358
|
-
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"),
|
|
2432
|
+
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), sn(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2359
2433
|
let a = i.queue ?? "append";
|
|
2360
|
-
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)),
|
|
2434
|
+
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), Xt(i.audio)) {
|
|
2361
2435
|
let e = i.audio.sampleRate ?? 24e3;
|
|
2362
2436
|
return r.createUtterance({
|
|
2363
2437
|
format: {
|
|
@@ -2373,7 +2447,7 @@ function vn(e) {
|
|
|
2373
2447
|
}
|
|
2374
2448
|
let o = e.getIframeHost();
|
|
2375
2449
|
if (!o) throw new Q("Speech session is not attached.");
|
|
2376
|
-
let s = await
|
|
2450
|
+
let s = await xn(i.audio, i.signal);
|
|
2377
2451
|
return o.speechPlay({
|
|
2378
2452
|
source: s,
|
|
2379
2453
|
characterId: i.characterId,
|
|
@@ -2385,13 +2459,13 @@ function vn(e) {
|
|
|
2385
2459
|
},
|
|
2386
2460
|
createUtterance(r) {
|
|
2387
2461
|
e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
|
|
2388
|
-
let i =
|
|
2462
|
+
let i = cn(r);
|
|
2389
2463
|
if (r.track && r.track.kind !== "audio") throw new Q("createUtterance track must be an audio MediaStreamTrack.");
|
|
2390
2464
|
let a = r.queue ?? "replace-active";
|
|
2391
2465
|
if (a !== "replace-active" && a !== "replace-all") throw new Q("createUtterance queue must be replace-active or replace-all.");
|
|
2392
2466
|
e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
|
|
2393
|
-
let o = new
|
|
2394
|
-
id:
|
|
2467
|
+
let o = new En({
|
|
2468
|
+
id: Sn(),
|
|
2395
2469
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2396
2470
|
format: i,
|
|
2397
2471
|
queue: a,
|
|
@@ -2403,7 +2477,7 @@ function vn(e) {
|
|
|
2403
2477
|
t === o && (t = null);
|
|
2404
2478
|
}), r.track && (async () => {
|
|
2405
2479
|
try {
|
|
2406
|
-
if (await
|
|
2480
|
+
if (await bn({
|
|
2407
2481
|
track: r.track,
|
|
2408
2482
|
utterance: o,
|
|
2409
2483
|
sampleRate: i.sampleRate,
|
|
@@ -2431,16 +2505,16 @@ function vn(e) {
|
|
|
2431
2505
|
}
|
|
2432
2506
|
//#endregion
|
|
2433
2507
|
//#region src/v2/types/sessionInteraction.ts
|
|
2434
|
-
function
|
|
2508
|
+
function On(e) {
|
|
2435
2509
|
let t = e?.trim();
|
|
2436
2510
|
return t === "full" || t === "face" || t === "medium" ? t : void 0;
|
|
2437
2511
|
}
|
|
2438
2512
|
//#endregion
|
|
2439
2513
|
//#region src/v2/experience.ts
|
|
2440
|
-
function
|
|
2514
|
+
function kn(e) {
|
|
2441
2515
|
return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
|
|
2442
2516
|
}
|
|
2443
|
-
var
|
|
2517
|
+
var An = class e {
|
|
2444
2518
|
bootstrap;
|
|
2445
2519
|
conversationProcessor;
|
|
2446
2520
|
iframeHost = null;
|
|
@@ -2455,16 +2529,16 @@ var xn = class e {
|
|
|
2455
2529
|
attached = !1;
|
|
2456
2530
|
pendingFit = null;
|
|
2457
2531
|
closeHandlers = [];
|
|
2458
|
-
eventRegistry =
|
|
2532
|
+
eventRegistry = Wt();
|
|
2459
2533
|
readyEnvelope = null;
|
|
2460
2534
|
startedEnvelope = null;
|
|
2461
2535
|
conversationCache = [];
|
|
2462
2536
|
speech;
|
|
2463
2537
|
constructor(e) {
|
|
2464
|
-
this.bootstrap = e, this.conversationProcessor = e.conversationProcessor ?? null, this.resolvedSession = e.kind === "launch" ? e.session ?? null : null, this.launchToken = e.kind === "launch" ? e.launch : null, this.speech =
|
|
2538
|
+
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 = Dn({
|
|
2465
2539
|
getIframeHost: () => this.iframeHost,
|
|
2466
2540
|
assertSessionStarted: () => this.assertSessionStarted(),
|
|
2467
|
-
getCapabilities: () =>
|
|
2541
|
+
getCapabilities: () => jn(this.resolvedSession),
|
|
2468
2542
|
getActiveCharacterId: () => "character_unknown",
|
|
2469
2543
|
onProcessorInterrupt: () => {
|
|
2470
2544
|
this.processorAbortController?.abort(), this.processorAbortController = null;
|
|
@@ -2508,6 +2582,7 @@ var xn = class e {
|
|
|
2508
2582
|
mode: t.mode,
|
|
2509
2583
|
speechInputMode: t.speechInputMode,
|
|
2510
2584
|
speechOnly: t.speechOnly,
|
|
2585
|
+
attribution: t.attribution,
|
|
2511
2586
|
ui: t.ui,
|
|
2512
2587
|
onStart: t.onStart,
|
|
2513
2588
|
onUserTranscript: t.onUserTranscript,
|
|
@@ -2529,6 +2604,7 @@ var xn = class e {
|
|
|
2529
2604
|
mode: t.mode,
|
|
2530
2605
|
speechInputMode: t.speechInputMode,
|
|
2531
2606
|
speechOnly: t.speechOnly,
|
|
2607
|
+
attribution: t.attribution,
|
|
2532
2608
|
ui: t.ui,
|
|
2533
2609
|
onStart: t.onStart,
|
|
2534
2610
|
onUserTranscript: t.onUserTranscript,
|
|
@@ -2543,7 +2619,7 @@ var xn = class e {
|
|
|
2543
2619
|
return null;
|
|
2544
2620
|
}
|
|
2545
2621
|
on(e, t) {
|
|
2546
|
-
let n =
|
|
2622
|
+
let n = Gt(this.eventRegistry, e, t);
|
|
2547
2623
|
return e === "ready" && this.readyEnvelope && queueMicrotask(() => t(this.readyEnvelope)), e === "started" && this.startedEnvelope && queueMicrotask(() => t(this.startedEnvelope)), n;
|
|
2548
2624
|
}
|
|
2549
2625
|
async attach(e) {
|
|
@@ -2557,13 +2633,13 @@ var xn = class e {
|
|
|
2557
2633
|
if (this.closed) throw Error("Session has ended.");
|
|
2558
2634
|
if (this.attached && this.iframeHost) return this.createPlayerFacade();
|
|
2559
2635
|
this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
|
|
2560
|
-
let t = this.bootstrap.embedBaseUrl ??
|
|
2636
|
+
let t = this.bootstrap.embedBaseUrl ?? Lt(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = zt(t, n, r ? void 0 : Rt(this.bootstrap.backdropId, this.bootstrap.locationId), r ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, kn(e), this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.castSize), a = Vt(i), o = null, s = new Promise((e) => {
|
|
2561
2637
|
o = e;
|
|
2562
2638
|
}), c = null, l = new Promise((e) => {
|
|
2563
2639
|
c = e;
|
|
2564
|
-
}), u =
|
|
2640
|
+
}), u = Nt((e) => {
|
|
2565
2641
|
this.readyEnvelope ||= (this.resolvedSession = e, this.emitWrapped("ready", { session: e }));
|
|
2566
|
-
}), d = this.bootstrap.onUserTranscript, f =
|
|
2642
|
+
}), d = this.bootstrap.onUserTranscript, f = Mt({
|
|
2567
2643
|
container: e.container,
|
|
2568
2644
|
src: i,
|
|
2569
2645
|
playerOrigin: a,
|
|
@@ -2626,7 +2702,7 @@ var xn = class e {
|
|
|
2626
2702
|
onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t)
|
|
2627
2703
|
});
|
|
2628
2704
|
this.iframeHost = f;
|
|
2629
|
-
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(),
|
|
2705
|
+
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), ut(this.bootstrap.sessionEndpoint, {
|
|
2630
2706
|
experienceId: this.bootstrap.experienceId,
|
|
2631
2707
|
locale: this.bootstrap.locale,
|
|
2632
2708
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
@@ -2635,15 +2711,17 @@ var xn = class e {
|
|
|
2635
2711
|
mode: p.mode,
|
|
2636
2712
|
speechInputMode: p.speechInputMode,
|
|
2637
2713
|
speechOnly: this.bootstrap.speechOnly,
|
|
2714
|
+
attribution: this.bootstrap.attribution,
|
|
2638
2715
|
signal: this.endpointAbortController.signal
|
|
2639
|
-
})) : this.bootstrap.kind === "public" ?
|
|
2716
|
+
})) : this.bootstrap.kind === "public" ? lt(this.bootstrap.experienceId, {
|
|
2640
2717
|
locale: this.bootstrap.locale,
|
|
2641
2718
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
2642
2719
|
learningLocale: this.bootstrap.learningLocale,
|
|
2643
2720
|
language: this.bootstrap.language,
|
|
2644
2721
|
mode: p.mode,
|
|
2645
2722
|
speechInputMode: p.speechInputMode,
|
|
2646
|
-
speechOnly: this.bootstrap.speechOnly
|
|
2723
|
+
speechOnly: this.bootstrap.speechOnly,
|
|
2724
|
+
attribution: this.bootstrap.attribution
|
|
2647
2725
|
}) : Promise.resolve(this.bootstrap.session ? {
|
|
2648
2726
|
session: this.bootstrap.session,
|
|
2649
2727
|
launch: this.bootstrap.launch
|
|
@@ -2658,7 +2736,7 @@ var xn = class e {
|
|
|
2658
2736
|
f.postParentHello();
|
|
2659
2737
|
let g = h?.launch ?? (this.bootstrap.kind === "launch" ? this.bootstrap.launch : null), _ = h?.session ?? (this.bootstrap.kind === "launch" ? this.bootstrap.session : void 0);
|
|
2660
2738
|
if (!g) throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), Error("Session Launch response did not include a launch token.");
|
|
2661
|
-
return this.launchToken = g, _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" &&
|
|
2739
|
+
return this.launchToken = g, _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" && tt(_), f.postLaunch(g, _, {
|
|
2662
2740
|
startButton: e.startButton,
|
|
2663
2741
|
showFeedback: e.showFeedback
|
|
2664
2742
|
}), u.setValue(_)) : f.postLaunch(g, void 0, {
|
|
@@ -2692,11 +2770,16 @@ var xn = class e {
|
|
|
2692
2770
|
this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
|
|
2693
2771
|
}
|
|
2694
2772
|
async setFit(e) {
|
|
2695
|
-
let t =
|
|
2773
|
+
let t = On(e);
|
|
2696
2774
|
if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
|
|
2697
2775
|
if (this.closed) throw Error("Session has ended.");
|
|
2698
2776
|
this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
|
|
2699
2777
|
}
|
|
2778
|
+
async conversion(e) {
|
|
2779
|
+
if (this.closed) throw Error("Session has ended.");
|
|
2780
|
+
if (!this.iframeHost) throw Error("conversion() requires attach() first.");
|
|
2781
|
+
await this.iframeHost.conversion(e);
|
|
2782
|
+
}
|
|
2700
2783
|
getLastTurn() {
|
|
2701
2784
|
if (this.conversationCache.length === 0) return [];
|
|
2702
2785
|
let e = this.conversationCache[this.conversationCache.length - 1].turnId;
|
|
@@ -2706,7 +2789,7 @@ var xn = class e {
|
|
|
2706
2789
|
this.close();
|
|
2707
2790
|
}
|
|
2708
2791
|
destroy() {
|
|
2709
|
-
this.closed || (this.closed = !0, this.processorAbortController?.abort(), this.processorAbortController = null, this.endpointAbortController?.abort(), this.endpointAbortController = null, this.attachInFlight = null, this.iframeHost?.destroy(), this.iframeHost = null,
|
|
2792
|
+
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, qt(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.attached = !1);
|
|
2710
2793
|
}
|
|
2711
2794
|
resolveMintInteraction() {
|
|
2712
2795
|
return this.bootstrap.kind === "launch" ? {} : {
|
|
@@ -2718,8 +2801,8 @@ var xn = class e {
|
|
|
2718
2801
|
return this.resolvedSession?.id ?? "";
|
|
2719
2802
|
}
|
|
2720
2803
|
emitWrapped(e, t) {
|
|
2721
|
-
let n =
|
|
2722
|
-
return
|
|
2804
|
+
let n = Ut(e, this.getSessionId(), t);
|
|
2805
|
+
return Kt(this.eventRegistry, e, n), n;
|
|
2723
2806
|
}
|
|
2724
2807
|
queueProcessorTurn(e) {
|
|
2725
2808
|
if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
|
|
@@ -2728,7 +2811,7 @@ var xn = class e {
|
|
|
2728
2811
|
let n = this.processorAbortController.signal;
|
|
2729
2812
|
this.processorChain = this.processorChain.then(async () => {
|
|
2730
2813
|
if (!n.aborted) try {
|
|
2731
|
-
let r = await
|
|
2814
|
+
let r = await pt(t, {
|
|
2732
2815
|
utteranceId: e.utteranceId,
|
|
2733
2816
|
text: e.text,
|
|
2734
2817
|
conversation: this.conversationCache,
|
|
@@ -2778,7 +2861,7 @@ var xn = class e {
|
|
|
2778
2861
|
};
|
|
2779
2862
|
}
|
|
2780
2863
|
};
|
|
2781
|
-
function
|
|
2864
|
+
function jn(e) {
|
|
2782
2865
|
return e ? {
|
|
2783
2866
|
textSpeech: e.capabilities.speech.output,
|
|
2784
2867
|
externalSpeechAudio: e.capabilities.speech.externalAudio
|
|
@@ -2789,41 +2872,41 @@ function Sn(e) {
|
|
|
2789
2872
|
}
|
|
2790
2873
|
//#endregion
|
|
2791
2874
|
//#region src/widget/dockGeometry.ts
|
|
2792
|
-
var
|
|
2793
|
-
function
|
|
2875
|
+
var Mn = "(min-width: 768px)", Nn = 24, Pn = .5, Fn = 1200, In = .85, Ln = 9 / 16;
|
|
2876
|
+
function Rn() {
|
|
2794
2877
|
if (typeof window > "u") return 800;
|
|
2795
2878
|
let e = window.screen?.availHeight;
|
|
2796
2879
|
return typeof e == "number" && e > 0 ? e : window.innerHeight;
|
|
2797
2880
|
}
|
|
2798
|
-
function
|
|
2799
|
-
let i = Math.max(160, Math.min(t - n * 2, t *
|
|
2800
|
-
return s > a && (s = a, o = s /
|
|
2881
|
+
function zn(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = Nn, r = typeof window < "u" ? Rn() : 800) {
|
|
2882
|
+
let i = Math.max(160, Math.min(t - n * 2, t * In)), a = Math.max(120, e - n * 2), o = Math.min(r * Pn, Fn, i), s = o * Ln;
|
|
2883
|
+
return s > a && (s = a, o = s / Ln, o > i && (o = i, s = o * Ln)), {
|
|
2801
2884
|
width: Math.round(s),
|
|
2802
2885
|
height: Math.round(o)
|
|
2803
2886
|
};
|
|
2804
2887
|
}
|
|
2805
|
-
function
|
|
2888
|
+
function Bn(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = Nn) {
|
|
2806
2889
|
return {
|
|
2807
2890
|
left: Math.max(r, t - e.width - r),
|
|
2808
2891
|
top: Math.max(r, n - e.height - r)
|
|
2809
2892
|
};
|
|
2810
2893
|
}
|
|
2811
|
-
function
|
|
2894
|
+
function Vn(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = Nn) {
|
|
2812
2895
|
let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
|
|
2813
2896
|
return {
|
|
2814
2897
|
left: Math.min(Math.max(a, e), o),
|
|
2815
2898
|
top: Math.min(Math.max(a, t), s)
|
|
2816
2899
|
};
|
|
2817
2900
|
}
|
|
2818
|
-
function
|
|
2819
|
-
return e(
|
|
2901
|
+
function Hn(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
|
|
2902
|
+
return e(Mn).matches;
|
|
2820
2903
|
}
|
|
2821
2904
|
//#endregion
|
|
2822
2905
|
//#region src/widget/mountExperienceWidget.ts
|
|
2823
|
-
function
|
|
2906
|
+
function Un(e) {
|
|
2824
2907
|
return e === "bottom-right" || e === "bottom-left" ? e : "static";
|
|
2825
2908
|
}
|
|
2826
|
-
function
|
|
2909
|
+
function Wn(e) {
|
|
2827
2910
|
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
2828
2911
|
let t = typeof e == "string" ? e.trim() : "";
|
|
2829
2912
|
return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
|
|
@@ -2831,8 +2914,8 @@ function Fn(e) {
|
|
|
2831
2914
|
function $(e) {
|
|
2832
2915
|
return e === "expanded" || e === "docked";
|
|
2833
2916
|
}
|
|
2834
|
-
var
|
|
2835
|
-
function
|
|
2917
|
+
var Gn = "<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>", Kn = "<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>", qn = "<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>", Jn = "<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>";
|
|
2918
|
+
function Yn(e, t, n) {
|
|
2836
2919
|
Oe(Ee);
|
|
2837
2920
|
let r = ie({
|
|
2838
2921
|
galleryThumb: t.galleryThumb,
|
|
@@ -2862,7 +2945,7 @@ function Bn(e, t, n) {
|
|
|
2862
2945
|
}
|
|
2863
2946
|
return e.replaceChildren(i), n?.parallax === !1 ? () => {} : Te(i);
|
|
2864
2947
|
}
|
|
2865
|
-
function
|
|
2948
|
+
function Xn(e) {
|
|
2866
2949
|
return e.startButton ? {
|
|
2867
2950
|
...e.startButton,
|
|
2868
2951
|
label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
|
|
@@ -2874,7 +2957,7 @@ function Vn(e) {
|
|
|
2874
2957
|
variant: "primary"
|
|
2875
2958
|
};
|
|
2876
2959
|
}
|
|
2877
|
-
function
|
|
2960
|
+
function Zn(e) {
|
|
2878
2961
|
let t = !1, n = () => {
|
|
2879
2962
|
t || e();
|
|
2880
2963
|
}, r = () => {
|
|
@@ -2894,12 +2977,12 @@ function Hn(e) {
|
|
|
2894
2977
|
t = !0, window.removeEventListener("load", r), i?.();
|
|
2895
2978
|
};
|
|
2896
2979
|
}
|
|
2897
|
-
function
|
|
2980
|
+
function Qn(e, t) {
|
|
2898
2981
|
Ne(je);
|
|
2899
2982
|
let n = t.experienceId?.trim();
|
|
2900
2983
|
if (!n) throw Error("ExperienceWidget requires experienceId.");
|
|
2901
|
-
let r = t.prefetch ?? "onExpand", i =
|
|
2902
|
-
a.className = "liforma-ew", a.dataset.state = "collapsed", a.dataset.prefetch = r, a.dataset.position = i, a.style.setProperty("--liforma-ew-max-w", t.expandedMaxWidth ?? "100%"), a.style.setProperty("--liforma-ew-max-h", t.expandedMaxHeight ?? "100%"), i !== "static" && a.style.setProperty("--liforma-ew-offset",
|
|
2984
|
+
let r = t.prefetch ?? "onExpand", i = Un(t.position), a = document.createElement("div");
|
|
2985
|
+
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", Wn(t.offset));
|
|
2903
2986
|
let o = document.createElement("button");
|
|
2904
2987
|
o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
|
|
2905
2988
|
let s = document.createElement("div");
|
|
@@ -2919,22 +3002,22 @@ function Un(e, t) {
|
|
|
2919
3002
|
let m = document.createElement("span");
|
|
2920
3003
|
m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
|
|
2921
3004
|
let h = document.createElement("button");
|
|
2922
|
-
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML =
|
|
3005
|
+
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = qn, h.setAttribute("aria-label", "Reduce");
|
|
2923
3006
|
let g = document.createElement("button");
|
|
2924
|
-
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML =
|
|
3007
|
+
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = Gn, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
|
|
2925
3008
|
let _ = document.createElement("button");
|
|
2926
|
-
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML =
|
|
3009
|
+
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = Kn, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
|
|
2927
3010
|
let v = document.createElement("div");
|
|
2928
3011
|
v.className = "liforma-ew__stage";
|
|
2929
3012
|
let y = document.createElement("div");
|
|
2930
3013
|
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);
|
|
2931
|
-
let b = null, x = !1, S = !1,
|
|
3014
|
+
let b = null, x = !1, S = !1, C = !1, w = !1, T = !1, E = !1, D = !1, O = 0, k = "", A = null, j = null, M = null, N = null, P = null, F = null, I = null, ee = 0, te = 0, ne = null, L = !1, re = new AbortController(), R = t.parallax !== !1, z = () => {
|
|
2932
3015
|
let e = a.dataset.state;
|
|
2933
3016
|
return e === "expanded" || e === "docked" || e === "collapsed" ? e : "collapsed";
|
|
2934
3017
|
}, ie = () => {
|
|
2935
|
-
|
|
3018
|
+
M !== null && (clearTimeout(M), M = null);
|
|
2936
3019
|
}, ae = () => {
|
|
2937
|
-
|
|
3020
|
+
N !== null && (clearTimeout(N), N = null), a.classList.remove("liforma-ew--layout-settling");
|
|
2938
3021
|
}, B = () => {
|
|
2939
3022
|
for (let e of [
|
|
2940
3023
|
f,
|
|
@@ -2942,51 +3025,51 @@ function Un(e, t) {
|
|
|
2942
3025
|
p
|
|
2943
3026
|
]) e.style.removeProperty("left"), e.style.removeProperty("top"), e.style.removeProperty("width"), e.style.removeProperty("height"), e.style.removeProperty("right"), e.style.removeProperty("bottom");
|
|
2944
3027
|
p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging");
|
|
2945
|
-
},
|
|
3028
|
+
}, V = (e, t, n, r) => {
|
|
2946
3029
|
let i = (i) => {
|
|
2947
3030
|
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";
|
|
2948
3031
|
};
|
|
2949
3032
|
i(f), i(l);
|
|
2950
3033
|
let a = p.offsetWidth || 120;
|
|
2951
3034
|
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";
|
|
2952
|
-
},
|
|
3035
|
+
}, oe = (e, t) => {
|
|
2953
3036
|
if (z() !== "docked") return;
|
|
2954
|
-
let n =
|
|
2955
|
-
|
|
2956
|
-
},
|
|
3037
|
+
let n = zn(), r = Vn(e - ee, t - te, n);
|
|
3038
|
+
P = r.left, F = r.top, V(r.left, r.top, n.width, n.height);
|
|
3039
|
+
}, se = (e, t) => {
|
|
2957
3040
|
if (z() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
|
|
2958
|
-
let n =
|
|
2959
|
-
|
|
2960
|
-
},
|
|
2961
|
-
|
|
2962
|
-
}, V = (e) => {
|
|
2963
|
-
if (F === null || e && e.pointerId !== F) return;
|
|
2964
|
-
let t = I;
|
|
2965
|
-
F = null, I = null, p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging"), t === "toolbar" && L && (L = !1, window.removeEventListener("pointermove", le), window.removeEventListener("pointerup", V), window.removeEventListener("pointercancel", V));
|
|
2966
|
-
}, ue = (e, t, n) => {
|
|
2967
|
-
if (S || z() !== "docked" || !Nn() || F !== null) return;
|
|
2968
|
-
F = n, I = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2969
|
-
let r = f.getBoundingClientRect();
|
|
2970
|
-
te = e - r.left, ne = t - r.top, L || (L = !0, window.addEventListener("pointermove", le), window.addEventListener("pointerup", V), window.addEventListener("pointercancel", V));
|
|
3041
|
+
let n = zn(), r = P ?? f.getBoundingClientRect().left, i = F ?? f.getBoundingClientRect().top, a = Vn(r + e, i + t, n);
|
|
3042
|
+
P = a.left, F = a.top, V(a.left, a.top, n.width, n.height);
|
|
3043
|
+
}, ce = (e) => {
|
|
3044
|
+
ne === "toolbar" && (I === null || e.pointerId !== I || (e.preventDefault(), oe(e.clientX, e.clientY)));
|
|
2971
3045
|
}, H = (e) => {
|
|
2972
|
-
if (
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
3046
|
+
if (I === null || e && e.pointerId !== I) return;
|
|
3047
|
+
let t = ne;
|
|
3048
|
+
I = null, ne = null, p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging"), t === "toolbar" && L && (L = !1, window.removeEventListener("pointermove", ce), window.removeEventListener("pointerup", H), window.removeEventListener("pointercancel", H));
|
|
3049
|
+
}, le = (e, t, n) => {
|
|
3050
|
+
if (S || z() !== "docked" || !Hn() || I !== null) return;
|
|
3051
|
+
I = n, ne = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
3052
|
+
let r = f.getBoundingClientRect();
|
|
3053
|
+
ee = e - r.left, te = t - r.top, L || (L = !0, window.addEventListener("pointermove", ce), window.addEventListener("pointerup", H), window.addEventListener("pointercancel", H));
|
|
2976
3054
|
}, U = (e) => {
|
|
2977
|
-
|
|
3055
|
+
if (S || z() !== "docked" || !Hn() || I !== null) return;
|
|
3056
|
+
I = e.pointerId, ne = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
3057
|
+
let t = f.getBoundingClientRect();
|
|
3058
|
+
P = t.left, F = t.top;
|
|
3059
|
+
}, ue = (e) => {
|
|
3060
|
+
ne === "player" && (I === null || e.pointerId !== I || se(e.dx, e.dy));
|
|
2978
3061
|
}, de = (e) => {
|
|
2979
|
-
|
|
3062
|
+
ne === "player" && (I === null || e.pointerId !== I || H());
|
|
2980
3063
|
}, W = () => {
|
|
2981
|
-
let e =
|
|
3064
|
+
let e = Hn(), t = z();
|
|
2982
3065
|
if (!e || t !== "expanded" && t !== "docked") {
|
|
2983
3066
|
h.hidden = !0;
|
|
2984
3067
|
return;
|
|
2985
3068
|
}
|
|
2986
|
-
h.hidden = !1, t === "docked" ? (h.innerHTML =
|
|
3069
|
+
h.hidden = !1, t === "docked" ? (h.innerHTML = Jn, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = qn, h.setAttribute("aria-label", "Reduce"));
|
|
2987
3070
|
}, fe = (e) => {
|
|
2988
|
-
let t =
|
|
2989
|
-
n =
|
|
3071
|
+
let t = zn(), n = e && P !== null && F !== null ? Vn(P, F, t) : Bn(t);
|
|
3072
|
+
n = Vn(n.left, n.top, t), P = n.left, F = n.top, V(n.left, n.top, t.width, t.height), W();
|
|
2990
3073
|
}, pe = () => {
|
|
2991
3074
|
a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
|
|
2992
3075
|
requestAnimationFrame(() => {
|
|
@@ -2994,20 +3077,20 @@ function Un(e, t) {
|
|
|
2994
3077
|
});
|
|
2995
3078
|
});
|
|
2996
3079
|
}, me = (e) => {
|
|
2997
|
-
if (ae(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !
|
|
3080
|
+
if (ae(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !D) {
|
|
2998
3081
|
a.classList.remove("liforma-ew--layout-settling");
|
|
2999
3082
|
return;
|
|
3000
3083
|
}
|
|
3001
|
-
|
|
3002
|
-
if (
|
|
3084
|
+
N = setTimeout(() => {
|
|
3085
|
+
if (N = null, S || !$(a.dataset.state)) {
|
|
3003
3086
|
a.classList.remove("liforma-ew--layout-settling");
|
|
3004
3087
|
return;
|
|
3005
3088
|
}
|
|
3006
3089
|
a.classList.remove("liforma-ew--layout-settling"), pe();
|
|
3007
3090
|
}, 220);
|
|
3008
3091
|
}, he = () => (a.classList.add("liforma-ew--session-concealing"), a.classList.remove("liforma-ew--session-revealed"), new Promise((e) => {
|
|
3009
|
-
ie(),
|
|
3010
|
-
|
|
3092
|
+
ie(), M = setTimeout(() => {
|
|
3093
|
+
M = null, a.classList.remove("liforma-ew--session-concealing"), e();
|
|
3011
3094
|
}, 280);
|
|
3012
3095
|
})), ge = {
|
|
3013
3096
|
galleryThumb: t.galleryThumb,
|
|
@@ -3028,13 +3111,13 @@ function Un(e, t) {
|
|
|
3028
3111
|
}
|
|
3029
3112
|
c.hidden = !1, c.textContent = e, s.contains(c) || s.append(c);
|
|
3030
3113
|
}, ye = () => {
|
|
3031
|
-
|
|
3114
|
+
C = !0, o.disabled = !1, ve(null), r === "onExpand" && t.onPrefetchReady?.();
|
|
3032
3115
|
}, G = () => {
|
|
3033
|
-
|
|
3116
|
+
w = !0, a.dataset.warm = "true", l.hidden = !1, D || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
|
|
3034
3117
|
}, be = (e) => {
|
|
3035
|
-
|
|
3036
|
-
let t =
|
|
3037
|
-
return t ? (
|
|
3118
|
+
A?.(), A = null;
|
|
3119
|
+
let t = Yn(s, e, { parallax: R });
|
|
3120
|
+
return t ? (A = t, !0) : !1;
|
|
3038
3121
|
}, K = () => {
|
|
3039
3122
|
if (be(ge)) {
|
|
3040
3123
|
ye();
|
|
@@ -3062,59 +3145,59 @@ function Un(e, t) {
|
|
|
3062
3145
|
...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
|
|
3063
3146
|
}), Se = () => ({
|
|
3064
3147
|
...t.fit ? { fit: t.fit } : {},
|
|
3065
|
-
startButton:
|
|
3148
|
+
startButton: Xn(t),
|
|
3066
3149
|
...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback }
|
|
3067
3150
|
}), q = (e = !0) => {
|
|
3068
|
-
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), B(), a.dataset.state = "expanded", _e(null), typeof document < "u" && (
|
|
3151
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), B(), a.dataset.state = "expanded", _e(null), typeof document < "u" && (k = document.body.style.overflow, document.body.style.overflow = "hidden"), W(), e && t.onExpanded?.();
|
|
3069
3152
|
}, Ce = () => {
|
|
3070
|
-
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked", _e(null), typeof document < "u" && (document.body.style.overflow =
|
|
3153
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked", _e(null), typeof document < "u" && (document.body.style.overflow = k), fe(!0), W(), b?.setWidgetChrome("docked");
|
|
3071
3154
|
}, we = (e) => {
|
|
3072
3155
|
e.on("started", () => {
|
|
3073
|
-
S || (
|
|
3156
|
+
S || (D = !0, a.dataset.live = "true", _e(null), t.onStarted?.(), $(a.dataset.state) && pe());
|
|
3074
3157
|
}), e.on("feedback", (e) => {
|
|
3075
3158
|
S || t.onFeedback?.(e);
|
|
3076
3159
|
}), e.on("feedbackFailed", (e) => {
|
|
3077
3160
|
S || t.onFeedbackFailed?.(e);
|
|
3078
3161
|
});
|
|
3079
3162
|
}, Te = () => {
|
|
3080
|
-
ae(), u.hidden = !0, p.hidden = !0, B(), a.dataset.state = "collapsed", a.classList.remove("liforma-ew--session-revealed"), a.classList.remove("liforma-ew--session-concealing"), g.setAttribute("aria-pressed", "false"), o.hidden = !1, o.tabIndex = 0, o.removeAttribute("aria-hidden"),
|
|
3163
|
+
ae(), u.hidden = !0, p.hidden = !0, B(), a.dataset.state = "collapsed", a.classList.remove("liforma-ew--session-revealed"), a.classList.remove("liforma-ew--session-concealing"), g.setAttribute("aria-pressed", "false"), o.hidden = !1, o.tabIndex = 0, o.removeAttribute("aria-hidden"), C && (o.disabled = !1), _e(null), typeof document < "u" && (document.body.style.overflow = k), W();
|
|
3081
3164
|
}, Ee = () => {
|
|
3082
|
-
ie(), ae(),
|
|
3165
|
+
ie(), ae(), O += 1, x = !1, w = !1, T = !1, E = !1, D = !1;
|
|
3083
3166
|
let e = b;
|
|
3084
3167
|
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");
|
|
3085
3168
|
}, De = () => {
|
|
3086
3169
|
if (!S && $(a.dataset.state)) {
|
|
3087
|
-
if (
|
|
3170
|
+
if (H(), x = !1, b && E) {
|
|
3088
3171
|
let e = b;
|
|
3089
3172
|
(async () => {
|
|
3090
|
-
|
|
3173
|
+
D && (await he(), S || b !== e) || (w && e.setWidgetChrome("collapsed"), Te(), D ? (a.dataset.live = "true", o.tabIndex = 0, o.removeAttribute("aria-hidden"), o.disabled = !1) : w && G(), t.onCollapsed?.(), t.onClose?.());
|
|
3091
3174
|
})();
|
|
3092
3175
|
return;
|
|
3093
3176
|
}
|
|
3094
3177
|
Ee(), Te(), t.onCollapsed?.(), t.onClose?.();
|
|
3095
3178
|
}
|
|
3096
3179
|
}, Oe = () => {
|
|
3097
|
-
S ||
|
|
3180
|
+
S || Hn() && z() === "expanded" && me(() => {
|
|
3098
3181
|
Ce();
|
|
3099
3182
|
});
|
|
3100
3183
|
}, ke = () => {
|
|
3101
|
-
S || z() === "docked" && (
|
|
3184
|
+
S || z() === "docked" && (H(), me(() => {
|
|
3102
3185
|
B(), q(!1), b?.setWidgetChrome("expanded");
|
|
3103
3186
|
}));
|
|
3104
3187
|
}, Ae = () => {
|
|
3105
|
-
!b || !
|
|
3188
|
+
!b || !D || (ie(), a.classList.remove("liforma-ew--session-revealed"), q(), b.setWidgetChrome("expanded"), x = !1, pe());
|
|
3106
3189
|
}, Me = () => {
|
|
3107
|
-
!b || !
|
|
3190
|
+
!b || !E || D || (ie(), a.classList.remove("liforma-ew--session-revealed"), q(), x = !1, w || b.setWidgetChrome("expanded"));
|
|
3108
3191
|
}, Pe = (e) => {
|
|
3109
|
-
S || e !==
|
|
3192
|
+
S || e !== O && !D || (ie(), a.classList.remove("liforma-ew--session-revealed"), q(), x = !1, D && pe());
|
|
3110
3193
|
}, Fe = () => {
|
|
3111
|
-
if (S ||
|
|
3112
|
-
|
|
3113
|
-
let e =
|
|
3194
|
+
if (S || T || w || b || $(a.dataset.state)) return;
|
|
3195
|
+
T = !0;
|
|
3196
|
+
let e = O;
|
|
3114
3197
|
l.hidden = !1, (async () => {
|
|
3115
3198
|
try {
|
|
3116
|
-
let t = await
|
|
3117
|
-
if (S || e !==
|
|
3199
|
+
let t = await An.startSession(xe());
|
|
3200
|
+
if (S || e !== O) {
|
|
3118
3201
|
t.destroy();
|
|
3119
3202
|
return;
|
|
3120
3203
|
}
|
|
@@ -3123,7 +3206,7 @@ function Un(e, t) {
|
|
|
3123
3206
|
container: l,
|
|
3124
3207
|
...Se(),
|
|
3125
3208
|
onWidgetReady: () => {
|
|
3126
|
-
S || e !==
|
|
3209
|
+
S || e !== O || (T = !1, E = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") : G());
|
|
3127
3210
|
},
|
|
3128
3211
|
onWidgetExpand: () => {
|
|
3129
3212
|
Pe(e);
|
|
@@ -3132,10 +3215,10 @@ function Un(e, t) {
|
|
|
3132
3215
|
S || J(e);
|
|
3133
3216
|
},
|
|
3134
3217
|
onWidgetDragStart: (e) => {
|
|
3135
|
-
S ||
|
|
3218
|
+
S || U(e);
|
|
3136
3219
|
},
|
|
3137
3220
|
onWidgetDragMove: (e) => {
|
|
3138
|
-
S ||
|
|
3221
|
+
S || ue(e);
|
|
3139
3222
|
},
|
|
3140
3223
|
onWidgetDragEnd: (e) => {
|
|
3141
3224
|
S || de(e);
|
|
@@ -3144,7 +3227,7 @@ function Un(e, t) {
|
|
|
3144
3227
|
S || e === "error" && $(a.dataset.state) && _e("Could not load the experience.");
|
|
3145
3228
|
}
|
|
3146
3229
|
});
|
|
3147
|
-
if (S || e !==
|
|
3230
|
+
if (S || e !== O) {
|
|
3148
3231
|
t.destroy(), b === t && (b = null);
|
|
3149
3232
|
return;
|
|
3150
3233
|
}
|
|
@@ -3152,28 +3235,28 @@ function Un(e, t) {
|
|
|
3152
3235
|
S || De();
|
|
3153
3236
|
});
|
|
3154
3237
|
} catch (n) {
|
|
3155
|
-
if (S || e !==
|
|
3156
|
-
|
|
3238
|
+
if (S || e !== O) return;
|
|
3239
|
+
T = !1, l.hidden = !0, l.replaceChildren(), b = null;
|
|
3157
3240
|
let r = n instanceof Error ? n : Error(String(n));
|
|
3158
3241
|
t.onError?.(r), console.error("[ExperienceWidget] warm prefetch failed", r);
|
|
3159
3242
|
}
|
|
3160
3243
|
})();
|
|
3161
3244
|
}, Ie = () => {
|
|
3162
|
-
if (S || x || !
|
|
3163
|
-
if (b &&
|
|
3245
|
+
if (S || x || !C || $(a.dataset.state)) return;
|
|
3246
|
+
if (b && D) {
|
|
3164
3247
|
Ae();
|
|
3165
3248
|
return;
|
|
3166
3249
|
}
|
|
3167
|
-
if (b &&
|
|
3250
|
+
if (b && E) {
|
|
3168
3251
|
Me();
|
|
3169
3252
|
return;
|
|
3170
3253
|
}
|
|
3171
|
-
let e = ++
|
|
3172
|
-
x = !0,
|
|
3254
|
+
let e = ++O;
|
|
3255
|
+
x = !0, w = !1, T = !1, E = !1, D = !1, delete a.dataset.warm, delete a.dataset.live, l.hidden = !0, l.replaceChildren(), b &&= (b.destroy(), null), (async () => {
|
|
3173
3256
|
try {
|
|
3174
3257
|
q();
|
|
3175
|
-
let t = await
|
|
3176
|
-
if (S || e !==
|
|
3258
|
+
let t = await An.startSession(xe());
|
|
3259
|
+
if (S || e !== O) {
|
|
3177
3260
|
t.destroy();
|
|
3178
3261
|
return;
|
|
3179
3262
|
}
|
|
@@ -3185,10 +3268,10 @@ function Un(e, t) {
|
|
|
3185
3268
|
S || J(e);
|
|
3186
3269
|
},
|
|
3187
3270
|
onWidgetDragStart: (e) => {
|
|
3188
|
-
S ||
|
|
3271
|
+
S || U(e);
|
|
3189
3272
|
},
|
|
3190
3273
|
onWidgetDragMove: (e) => {
|
|
3191
|
-
S ||
|
|
3274
|
+
S || ue(e);
|
|
3192
3275
|
},
|
|
3193
3276
|
onWidgetDragEnd: (e) => {
|
|
3194
3277
|
S || de(e);
|
|
@@ -3197,32 +3280,32 @@ function Un(e, t) {
|
|
|
3197
3280
|
S || (e === "error" ? _e("Could not load the experience.") : $(a.dataset.state) && _e(null));
|
|
3198
3281
|
}
|
|
3199
3282
|
});
|
|
3200
|
-
if (S || e !==
|
|
3283
|
+
if (S || e !== O) {
|
|
3201
3284
|
t.destroy(), b === t && (b = null);
|
|
3202
3285
|
return;
|
|
3203
3286
|
}
|
|
3204
|
-
|
|
3287
|
+
E = !0, t.setWidgetChrome("expanded"), n.on("close", () => {
|
|
3205
3288
|
S || De();
|
|
3206
3289
|
});
|
|
3207
3290
|
} catch (n) {
|
|
3208
|
-
if (S || e !==
|
|
3291
|
+
if (S || e !== O) return;
|
|
3209
3292
|
let r = n instanceof Error ? n : Error(String(n));
|
|
3210
3293
|
_e(r.message), t.onError?.(r), console.error("[ExperienceWidget]", r);
|
|
3211
3294
|
} finally {
|
|
3212
|
-
e ===
|
|
3295
|
+
e === O && (x = !1);
|
|
3213
3296
|
}
|
|
3214
3297
|
})();
|
|
3215
3298
|
}, Le = () => {
|
|
3216
3299
|
if (!(S || $(a.dataset.state))) {
|
|
3217
|
-
if (b &&
|
|
3300
|
+
if (b && D) {
|
|
3218
3301
|
Ae();
|
|
3219
3302
|
return;
|
|
3220
3303
|
}
|
|
3221
|
-
if (b &&
|
|
3304
|
+
if (b && E) {
|
|
3222
3305
|
Me();
|
|
3223
3306
|
return;
|
|
3224
3307
|
}
|
|
3225
|
-
if (
|
|
3308
|
+
if (T || b) {
|
|
3226
3309
|
q();
|
|
3227
3310
|
return;
|
|
3228
3311
|
}
|
|
@@ -3239,26 +3322,26 @@ function Un(e, t) {
|
|
|
3239
3322
|
}, Be = (e) => {
|
|
3240
3323
|
e.stopPropagation(), $(a.dataset.state) && b?.toggleAudioSettings();
|
|
3241
3324
|
}, Ve = (e) => {
|
|
3242
|
-
z() === "docked" &&
|
|
3325
|
+
z() === "docked" && Hn() && (e.target?.closest("button") || (e.preventDefault(), le(e.clientX, e.clientY, e.pointerId)));
|
|
3243
3326
|
}, He = (e) => {
|
|
3244
3327
|
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), De());
|
|
3245
3328
|
}, Ue = () => {
|
|
3246
3329
|
if (!S) {
|
|
3247
3330
|
if (z() === "docked") {
|
|
3248
|
-
if (!
|
|
3331
|
+
if (!Hn()) {
|
|
3249
3332
|
ke();
|
|
3250
3333
|
return;
|
|
3251
3334
|
}
|
|
3252
|
-
|
|
3335
|
+
D ? me(() => {
|
|
3253
3336
|
fe(!0);
|
|
3254
3337
|
}) : fe(!0);
|
|
3255
3338
|
return;
|
|
3256
3339
|
}
|
|
3257
3340
|
W();
|
|
3258
3341
|
}
|
|
3259
|
-
},
|
|
3342
|
+
}, Y = typeof window < "u" ? window.matchMedia(Mn) : null, We = () => {
|
|
3260
3343
|
if (!S) {
|
|
3261
|
-
if (z() === "docked" && !
|
|
3344
|
+
if (z() === "docked" && !Hn()) {
|
|
3262
3345
|
ke();
|
|
3263
3346
|
return;
|
|
3264
3347
|
}
|
|
@@ -3267,9 +3350,9 @@ function Un(e, t) {
|
|
|
3267
3350
|
};
|
|
3268
3351
|
return o.addEventListener("click", Le), d.addEventListener("click", De), _.addEventListener("click", (e) => {
|
|
3269
3352
|
e.stopPropagation(), De();
|
|
3270
|
-
}), h.addEventListener("click", Re), g.addEventListener("click", Be), p.addEventListener("pointerdown", Ve), window.addEventListener("keydown", He), window.addEventListener("resize", Ue),
|
|
3353
|
+
}), h.addEventListener("click", Re), g.addEventListener("click", Be), p.addEventListener("pointerdown", Ve), window.addEventListener("keydown", He), window.addEventListener("resize", Ue), Y?.addEventListener("change", We), K(), W(), r === "eager" ? queueMicrotask(() => {
|
|
3271
3354
|
S || Fe();
|
|
3272
|
-
}) : r === "idle" && (
|
|
3355
|
+
}) : r === "idle" && (j = Zn(() => {
|
|
3273
3356
|
S || Fe();
|
|
3274
3357
|
})), {
|
|
3275
3358
|
root: a,
|
|
@@ -3285,18 +3368,18 @@ function Un(e, t) {
|
|
|
3285
3368
|
Fe();
|
|
3286
3369
|
},
|
|
3287
3370
|
destroy() {
|
|
3288
|
-
S || (S = !0,
|
|
3371
|
+
S || (S = !0, H(), j?.(), j = null, re.abort(), A?.(), A = null, window.removeEventListener("keydown", He), window.removeEventListener("resize", Ue), Y?.removeEventListener("change", We), Ee(), Te(), e.replaceChildren());
|
|
3289
3372
|
}
|
|
3290
3373
|
};
|
|
3291
3374
|
}
|
|
3292
3375
|
//#endregion
|
|
3293
3376
|
//#region src/react/ExperienceWidget.tsx
|
|
3294
|
-
function
|
|
3295
|
-
let t = o(null), { experienceId: r, alt: i, galleryThumb: a, avatarImage: s, backgroundImage: c, foregroundImage: l, fallbackImage: u, prefetch: f = "onExpand", parallax: p = !0, position: m = "static", offset: h, sessionEndpoint: g, language: _, mode: v, speechInputMode: y, speechOnly: b, fit: x, embedBaseUrl: S, expandedMaxWidth:
|
|
3377
|
+
function $n(e) {
|
|
3378
|
+
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: C, expandedMaxHeight: w, startButtonLabel: T, startButton: E, showFeedback: D, className: O = "", onExpanded: k, onCollapsed: A, onStarted: j, onClose: M, onError: N, onPrefetchReady: P, onFeedback: F, onFeedbackFailed: I } = e, ee = m === "bottom-right" || m === "bottom-left";
|
|
3296
3379
|
return n(() => {
|
|
3297
3380
|
let e = t.current;
|
|
3298
3381
|
if (!e || !r.trim()) return;
|
|
3299
|
-
let n =
|
|
3382
|
+
let n = Qn(e, {
|
|
3300
3383
|
experienceId: r,
|
|
3301
3384
|
alt: i,
|
|
3302
3385
|
galleryThumb: a,
|
|
@@ -3315,19 +3398,19 @@ function Wn(e) {
|
|
|
3315
3398
|
speechOnly: b,
|
|
3316
3399
|
fit: x,
|
|
3317
3400
|
embedBaseUrl: S,
|
|
3318
|
-
expandedMaxWidth:
|
|
3319
|
-
expandedMaxHeight:
|
|
3320
|
-
startButtonLabel:
|
|
3321
|
-
startButton:
|
|
3322
|
-
showFeedback:
|
|
3323
|
-
onFeedback:
|
|
3324
|
-
onFeedbackFailed:
|
|
3325
|
-
onExpanded:
|
|
3326
|
-
onCollapsed:
|
|
3327
|
-
onStarted:
|
|
3328
|
-
onClose:
|
|
3329
|
-
onError:
|
|
3330
|
-
onPrefetchReady:
|
|
3401
|
+
expandedMaxWidth: C,
|
|
3402
|
+
expandedMaxHeight: w,
|
|
3403
|
+
startButtonLabel: T,
|
|
3404
|
+
startButton: E,
|
|
3405
|
+
showFeedback: D,
|
|
3406
|
+
onFeedback: F,
|
|
3407
|
+
onFeedbackFailed: I,
|
|
3408
|
+
onExpanded: k,
|
|
3409
|
+
onCollapsed: A,
|
|
3410
|
+
onStarted: j,
|
|
3411
|
+
onClose: M,
|
|
3412
|
+
onError: N,
|
|
3413
|
+
onPrefetchReady: P
|
|
3331
3414
|
});
|
|
3332
3415
|
return () => n.destroy();
|
|
3333
3416
|
}, [
|
|
@@ -3349,23 +3432,23 @@ function Wn(e) {
|
|
|
3349
3432
|
b,
|
|
3350
3433
|
x,
|
|
3351
3434
|
S,
|
|
3352
|
-
ee,
|
|
3353
3435
|
C,
|
|
3354
3436
|
w,
|
|
3355
3437
|
T,
|
|
3356
3438
|
E,
|
|
3357
|
-
|
|
3439
|
+
D,
|
|
3358
3440
|
F,
|
|
3359
|
-
|
|
3441
|
+
I,
|
|
3360
3442
|
k,
|
|
3361
3443
|
A,
|
|
3362
3444
|
j,
|
|
3363
3445
|
M,
|
|
3364
|
-
N
|
|
3446
|
+
N,
|
|
3447
|
+
P
|
|
3365
3448
|
]), /* @__PURE__ */ d("div", {
|
|
3366
3449
|
ref: t,
|
|
3367
|
-
className:
|
|
3368
|
-
style:
|
|
3450
|
+
className: O,
|
|
3451
|
+
style: ee ? { display: "contents" } : {
|
|
3369
3452
|
width: "100%",
|
|
3370
3453
|
height: "100%",
|
|
3371
3454
|
minHeight: "inherit"
|
|
@@ -3373,6 +3456,6 @@ function Wn(e) {
|
|
|
3373
3456
|
});
|
|
3374
3457
|
}
|
|
3375
3458
|
//#endregion
|
|
3376
|
-
export {
|
|
3459
|
+
export { te as Experience, Ae as ExperienceThumbnail, $n as ExperienceWidget };
|
|
3377
3460
|
|
|
3378
3461
|
//# sourceMappingURL=index.js.map
|