@liforma/client 0.4.12 → 0.4.13
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 +11 -0
- package/dist/next/index.js +394 -369
- package/dist/next/index.js.map +1 -1
- package/dist/next/thumbnail.js +1 -1
- package/dist/next/thumbnail.js.map +1 -1
- package/dist/next/v2/embed/iframeHost.d.ts +4 -8
- package/dist/next/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/next/v2/embed/protocol.d.ts +29 -2
- package/dist/next/v2/embed/protocol.d.ts.map +1 -1
- package/dist/next/v2/experience.d.ts +11 -0
- package/dist/next/v2/experience.d.ts.map +1 -1
- package/dist/npm/index.js +206 -181
- package/dist/npm/index.js.map +1 -1
- package/dist/npm/thumbnail/index.js +1 -1
- package/dist/npm/thumbnail/index.js.map +1 -1
- package/dist/npm/v2/embed/iframeHost.d.ts +4 -8
- package/dist/npm/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/npm/v2/embed/protocol.d.ts +29 -2
- package/dist/npm/v2/embed/protocol.d.ts.map +1 -1
- package/dist/npm/v2/experience.d.ts +11 -0
- package/dist/npm/v2/experience.d.ts.map +1 -1
- package/dist/react/component/experienceComponentRuntime.d.ts +3 -0
- package/dist/react/component/experienceComponentRuntime.d.ts.map +1 -1
- package/dist/react/component/experienceComponentTypes.d.ts +9 -0
- package/dist/react/component/experienceComponentTypes.d.ts.map +1 -1
- package/dist/react/index.js +514 -473
- package/dist/react/index.js.map +1 -1
- package/dist/react/react/Experience.d.ts.map +1 -1
- package/dist/react/thumbnail.js +1 -1
- package/dist/react/thumbnail.js.map +1 -1
- package/dist/react/v2/embed/iframeHost.d.ts +4 -8
- package/dist/react/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/react/v2/embed/protocol.d.ts +29 -2
- package/dist/react/v2/embed/protocol.d.ts.map +1 -1
- package/dist/react/v2/experience.d.ts +11 -0
- package/dist/react/v2/experience.d.ts.map +1 -1
- package/dist/sdk/v2/client.js +2 -2
- package/dist/sdk/v2/client.js.map +1 -1
- package/dist/sdk/v2/thumbnail.js +1 -1
- package/dist/sdk/v2/thumbnail.js.map +1 -1
- package/dist/svelte/Experience.svelte +22 -0
- package/dist/svelte/Experience.svelte.d.ts +1 -0
- package/package.json +1 -1
package/dist/next/index.js
CHANGED
|
@@ -173,21 +173,21 @@ function j(e, t) {
|
|
|
173
173
|
}
|
|
174
174
|
//#endregion
|
|
175
175
|
//#region src/thumbnail/toGalleryThumbUrl.ts
|
|
176
|
-
var
|
|
177
|
-
function
|
|
176
|
+
var ee = /(\/avatars\/[^/]+\/)(\d+)(\/)/i, te = /_CH(\.webp)/i;
|
|
177
|
+
function M(e) {
|
|
178
178
|
return /\/locations\//i.test(e) || /^locations\//i.test(e) ? !0 : /^https?:\/\//i.test(e) || e.startsWith("//") || /^\/?avatars\//i.test(e) || e.startsWith("/") ? !1 : e.includes("/");
|
|
179
179
|
}
|
|
180
|
-
function
|
|
180
|
+
function N(e, t = "256x256", n) {
|
|
181
181
|
let r = e.trim();
|
|
182
182
|
if (!r) return r;
|
|
183
|
-
if (
|
|
183
|
+
if (M(r)) return A(r, t, n);
|
|
184
184
|
let i = j(r, n);
|
|
185
|
-
return i = i.replace(
|
|
185
|
+
return i = i.replace(ee, (e, t, n, r) => n === "256" ? `${t}${n}${r}` : `${t}256${r}`), i.replace(te, "_neutral$1");
|
|
186
186
|
}
|
|
187
|
-
function
|
|
187
|
+
function P(e) {
|
|
188
188
|
let t = e.avatarImage?.trim() || e.galleryThumb?.avatarImage?.trim() || "";
|
|
189
189
|
if (!t) return null;
|
|
190
|
-
let n = e.backgroundImage?.trim() || e.galleryThumb?.backgroundImage?.trim() || "", r = e.foregroundImage?.trim() || e.galleryThumb?.foregroundImage?.trim() || "", i = e.fallbackImage?.trim() || "", a = e.locationPlateSize ?? "256x256", o = T(e.cdnBaseUrl), s = e.normalize !== !1, c = (e) => !s && /^https?:\/\//i.test(e.trim()) ? e.trim() :
|
|
190
|
+
let n = e.backgroundImage?.trim() || e.galleryThumb?.backgroundImage?.trim() || "", r = e.foregroundImage?.trim() || e.galleryThumb?.foregroundImage?.trim() || "", i = e.fallbackImage?.trim() || "", a = e.locationPlateSize ?? "256x256", o = T(e.cdnBaseUrl), s = e.normalize !== !1, c = (e) => !s && /^https?:\/\//i.test(e.trim()) ? e.trim() : N(e, a, o), l = (e) => !s && /^https?:\/\//i.test(e.trim()) ? e.trim() : A(e, a, o);
|
|
191
191
|
return {
|
|
192
192
|
avatarImage: c(t),
|
|
193
193
|
...n ? { backgroundImage: l(n) } : {},
|
|
@@ -197,7 +197,7 @@ function F(e) {
|
|
|
197
197
|
}
|
|
198
198
|
//#endregion
|
|
199
199
|
//#region src/shims/localStack.ts
|
|
200
|
-
function
|
|
200
|
+
function ne() {
|
|
201
201
|
if (globalThis.__LIFORMA_STACK === "local") return !0;
|
|
202
202
|
if (typeof location > "u") return !1;
|
|
203
203
|
try {
|
|
@@ -208,83 +208,83 @@ function te() {
|
|
|
208
208
|
}
|
|
209
209
|
//#endregion
|
|
210
210
|
//#region src/thumbnail/hostedLaunchUrl.ts
|
|
211
|
-
var
|
|
212
|
-
function
|
|
211
|
+
var F = "https://player.liforma.ai", I = "http://localhost:3002";
|
|
212
|
+
function re(e) {
|
|
213
213
|
return e.href?.trim() ? "anchor" : e.hasClickHandler ? "button" : e.experienceId?.trim() ? "anchor" : "presentational";
|
|
214
214
|
}
|
|
215
|
-
function
|
|
215
|
+
function ie(e) {
|
|
216
216
|
let t = e?.trim();
|
|
217
|
-
return t ? t.replace(/\/$/, "") :
|
|
217
|
+
return t ? t.replace(/\/$/, "") : ne() ? I : F;
|
|
218
218
|
}
|
|
219
|
-
function
|
|
220
|
-
let t = e.experienceId.trim(), n =
|
|
219
|
+
function ae(e) {
|
|
220
|
+
let t = e.experienceId.trim(), n = ie(e.playerBaseUrl), r = new URL(`${n}/${encodeURIComponent(t)}`), i = e.returnUrl?.trim();
|
|
221
221
|
return i && r.searchParams.set("returnUrl", i), r.toString();
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function L(e) {
|
|
224
224
|
let t = e.href?.trim();
|
|
225
225
|
if (t) return t;
|
|
226
226
|
let n = e.experienceId?.trim();
|
|
227
227
|
if (!n) return;
|
|
228
228
|
let r = e.returnUrl?.trim();
|
|
229
|
-
return !r && e.useCurrentPageAsReturnUrl && typeof window < "u" && (r = window.location.href),
|
|
229
|
+
return !r && e.useCurrentPageAsReturnUrl && typeof window < "u" && (r = window.location.href), ae({
|
|
230
230
|
experienceId: n,
|
|
231
231
|
...r ? { returnUrl: r } : {},
|
|
232
232
|
playerBaseUrl: e.playerBaseUrl
|
|
233
233
|
});
|
|
234
234
|
}
|
|
235
|
-
function
|
|
235
|
+
function R() {
|
|
236
236
|
return typeof window > "u" ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
|
|
237
237
|
}
|
|
238
|
-
var
|
|
239
|
-
function oe() {
|
|
240
|
-
return z() ? 4 : Infinity;
|
|
241
|
-
}
|
|
238
|
+
var z = 0, oe = [];
|
|
242
239
|
function se() {
|
|
243
|
-
return
|
|
240
|
+
return R() ? 4 : Infinity;
|
|
244
241
|
}
|
|
245
242
|
function ce() {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
243
|
+
return R() ? 160 : 0;
|
|
244
|
+
}
|
|
245
|
+
function le() {
|
|
246
|
+
let e = se();
|
|
247
|
+
for (; z < e && oe.length > 0;) {
|
|
248
|
+
let e = oe.shift();
|
|
249
249
|
if (!e || e.cancelled) continue;
|
|
250
|
-
|
|
251
|
-
let t =
|
|
250
|
+
z += 1, e.start();
|
|
251
|
+
let t = ce();
|
|
252
252
|
if (t <= 0) {
|
|
253
|
-
|
|
253
|
+
z = Math.max(0, z - 1);
|
|
254
254
|
continue;
|
|
255
255
|
}
|
|
256
256
|
window.setTimeout(() => {
|
|
257
|
-
|
|
257
|
+
z = Math.max(0, z - 1), le();
|
|
258
258
|
}, t);
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
|
-
function
|
|
262
|
-
if (!
|
|
261
|
+
function ue(e) {
|
|
262
|
+
if (!R()) return e(), () => {};
|
|
263
263
|
let t = {
|
|
264
264
|
start: e,
|
|
265
265
|
cancelled: !1
|
|
266
266
|
};
|
|
267
|
-
return
|
|
267
|
+
return oe.push(t), le(), () => {
|
|
268
268
|
t.cancelled = !0;
|
|
269
269
|
};
|
|
270
270
|
}
|
|
271
271
|
//#endregion
|
|
272
272
|
//#region src/thumbnail/lazyLoad.ts
|
|
273
|
-
function
|
|
274
|
-
return
|
|
273
|
+
function B() {
|
|
274
|
+
return R() ? "96px 0px" : "280px 0px";
|
|
275
275
|
}
|
|
276
|
-
function
|
|
276
|
+
function de(e) {
|
|
277
277
|
let t = e.trim().split(/\s+/)[0] ?? "0px", n = Number.parseFloat(t);
|
|
278
278
|
return Number.isFinite(n) ? Math.abs(n) : 280;
|
|
279
279
|
}
|
|
280
|
-
function
|
|
280
|
+
function fe(e, t) {
|
|
281
281
|
if (typeof window > "u") return !1;
|
|
282
282
|
let n = e.getBoundingClientRect();
|
|
283
283
|
return n.bottom >= -t && n.top <= window.innerHeight + t;
|
|
284
284
|
}
|
|
285
|
-
function
|
|
286
|
-
let { onVisibleChange: n } = t, r = t.rootMargin ??
|
|
287
|
-
o || (s?.(), s =
|
|
285
|
+
function pe(e, t) {
|
|
286
|
+
let { onVisibleChange: n } = t, r = t.rootMargin ?? B(), i = de(r), a = !1, o = !1, s = null, c = () => {
|
|
287
|
+
o || (s?.(), s = ue(() => {
|
|
288
288
|
s = null, o = !0, n(!0);
|
|
289
289
|
}));
|
|
290
290
|
}, l = (e) => {
|
|
@@ -306,26 +306,26 @@ function fe(e, t) {
|
|
|
306
306
|
rootMargin: r,
|
|
307
307
|
threshold: 0
|
|
308
308
|
});
|
|
309
|
-
return u.observe(e),
|
|
309
|
+
return u.observe(e), fe(e, i) && l(!0), () => {
|
|
310
310
|
s?.(), s = null, u.disconnect();
|
|
311
311
|
};
|
|
312
312
|
}
|
|
313
313
|
//#endregion
|
|
314
314
|
//#region src/thumbnail/scrollParallax.ts
|
|
315
|
-
function
|
|
315
|
+
function me() {
|
|
316
316
|
return typeof window > "u" || window.matchMedia("(prefers-reduced-motion: reduce)").matches ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
|
|
317
317
|
}
|
|
318
|
-
function
|
|
318
|
+
function V(e, t) {
|
|
319
319
|
return ((e.top + e.height / 2) / Math.max(t, 1) - .5) * 2;
|
|
320
320
|
}
|
|
321
|
-
var
|
|
321
|
+
var H = /* @__PURE__ */ new Set(), U = !1, W = 0;
|
|
322
322
|
function he() {
|
|
323
|
-
if (W = 0,
|
|
323
|
+
if (W = 0, H.size === 0 || typeof window > "u") return;
|
|
324
324
|
let e = window.innerHeight;
|
|
325
|
-
for (let t of
|
|
325
|
+
for (let t of H) {
|
|
326
326
|
if (t.pointerActive?.()) continue;
|
|
327
327
|
let n = t.element.getBoundingClientRect();
|
|
328
|
-
n.bottom < -64 || n.top > e + 64 || t.onParallax(
|
|
328
|
+
n.bottom < -64 || n.top > e + 64 || t.onParallax(V(n, e));
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
331
|
function ge() {
|
|
@@ -335,17 +335,17 @@ function G() {
|
|
|
335
335
|
U || typeof window > "u" || (U = !0, window.addEventListener("scroll", ge, { passive: !0 }), window.addEventListener("resize", ge, { passive: !0 }));
|
|
336
336
|
}
|
|
337
337
|
function _e() {
|
|
338
|
-
|
|
338
|
+
H.size > 0 || !U || typeof window > "u" || (U = !1, W !== 0 && (cancelAnimationFrame(W), W = 0), window.removeEventListener("scroll", ge), window.removeEventListener("resize", ge));
|
|
339
339
|
}
|
|
340
340
|
function ve(e, t) {
|
|
341
|
-
if (!
|
|
341
|
+
if (!me()) return () => {};
|
|
342
342
|
let n = {
|
|
343
343
|
element: e,
|
|
344
344
|
onParallax: t.onParallax,
|
|
345
345
|
pointerActive: t.pointerActive
|
|
346
346
|
};
|
|
347
|
-
return
|
|
348
|
-
|
|
347
|
+
return H.add(n), G(), n.pointerActive?.() || t.onParallax(V(e.getBoundingClientRect(), window.innerHeight)), () => {
|
|
348
|
+
H.delete(n), _e();
|
|
349
349
|
};
|
|
350
350
|
}
|
|
351
351
|
//#endregion
|
|
@@ -367,7 +367,7 @@ function ye(e) {
|
|
|
367
367
|
a = !0, e.pointerType === "mouse" && (r = !0), o();
|
|
368
368
|
}, u = () => {
|
|
369
369
|
let s = a;
|
|
370
|
-
a = !1, r = !1, i && s ? (t =
|
|
370
|
+
a = !1, r = !1, i && s ? (t = V(e.getBoundingClientRect(), window.innerHeight), n = 0) : i || (t = 0, n = 0), o();
|
|
371
371
|
}, d = (e) => {
|
|
372
372
|
e.pointerType === "mouse" && (r = !0, o());
|
|
373
373
|
}, f = () => {
|
|
@@ -379,7 +379,7 @@ function ye(e) {
|
|
|
379
379
|
}
|
|
380
380
|
//#endregion
|
|
381
381
|
//#region src/thumbnail/styles.ts
|
|
382
|
-
var be = ":host {\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n}\n\n.liforma-et {\n --liforma-et-parallax-x: 0;\n --liforma-et-parallax-y: 0;\n --liforma-et-bg-scale: 1;\n --liforma-et-fg-scale: 1;\n --liforma-et-avatar-scale: 1;\n --liforma-et-bg-shift: 0px;\n --liforma-et-fg-shift: 0px;\n --liforma-et-avatar-shift: 0px;\n --liforma-et-reveal-duration: 420ms;\n\n box-sizing: border-box;\n position: relative;\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: 0
|
|
382
|
+
var be = ":host {\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n}\n\n.liforma-et {\n --liforma-et-parallax-x: 0;\n --liforma-et-parallax-y: 0;\n --liforma-et-bg-scale: 1;\n --liforma-et-fg-scale: 1;\n --liforma-et-avatar-scale: 1;\n --liforma-et-bg-shift: 0px;\n --liforma-et-fg-shift: 0px;\n --liforma-et-avatar-shift: 0px;\n --liforma-et-reveal-duration: 420ms;\n\n box-sizing: border-box;\n position: relative;\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: 0;\n overflow: hidden;\n background: #111;\n color: inherit;\n text-decoration: none;\n cursor: inherit;\n -webkit-tap-highlight-color: transparent;\n}\n\na.liforma-et,\nbutton.liforma-et {\n cursor: pointer;\n}\n\nbutton.liforma-et {\n font: inherit;\n appearance: none;\n}\n\n.liforma-et__placeholder {\n position: absolute;\n inset: 0;\n z-index: 0;\n background:\n radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.06), transparent 58%),\n linear-gradient(180deg, #1a1a1a 0%, #101010 100%);\n opacity: 1;\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n.liforma-et--revealed .liforma-et__placeholder {\n opacity: 0;\n}\n\n.liforma-et__media {\n opacity: 0;\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n.liforma-et__media--ready {\n opacity: 1;\n}\n\n.liforma-et__background {\n position: absolute;\n inset: 0;\n z-index: 1;\n width: 100%;\n height: 100%;\n object-fit: cover;\n object-position: center center;\n transform: translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-bg-shift)),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-bg-shift))\n )\n scale(var(--liforma-et-bg-scale));\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n.liforma-et__avatar {\n position: relative;\n z-index: 2;\n display: block;\n width: 100%;\n height: 100%;\n object-fit: contain;\n object-position: center bottom;\n transform: scale(var(--liforma-et-avatar-scale))\n translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-avatar-shift)),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-avatar-shift))\n );\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n/* Gallery plates are typically square in a square tile — contain vs cover is a no-op\n without a zoom. Scale the whole scene from the upper third so Face matches\n player fit (location + avatar crop together). */\n.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.85;\n --liforma-et-bg-scale: 1.85;\n --liforma-et-fg-scale: 1.85;\n}\n\n.liforma-et--fit-face .liforma-et__avatar,\n.liforma-et--fit-face .liforma-et__background,\n.liforma-et--fit-face .liforma-et__foreground {\n transform-origin: 50% 18%;\n}\n\n.liforma-et--fit-face .liforma-et__avatar {\n object-fit: cover;\n object-position: 50% 18%;\n}\n\n/* Bust / medium: less zoom than face so upper chest stays in frame (player 3.75H window). */\n.liforma-et--fit-medium {\n --liforma-et-avatar-scale: 1.35;\n --liforma-et-bg-scale: 1.35;\n --liforma-et-fg-scale: 1.35;\n}\n\n.liforma-et--fit-medium .liforma-et__avatar,\n.liforma-et--fit-medium .liforma-et__background,\n.liforma-et--fit-medium .liforma-et__foreground {\n transform-origin: 50% 28%;\n}\n\n.liforma-et--fit-medium .liforma-et__avatar {\n object-fit: cover;\n object-position: 50% 28%;\n}\n\n.liforma-et__foreground {\n position: absolute;\n inset: 0;\n z-index: 3;\n width: 100%;\n height: 100%;\n object-fit: cover;\n object-position: center center;\n pointer-events: none;\n transform: translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-fg-shift) * -1),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-fg-shift) * -1)\n )\n scale(var(--liforma-et-fg-scale));\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n.liforma-et--parallax {\n --liforma-et-bg-scale: 1.08;\n --liforma-et-fg-scale: 1.05;\n --liforma-et-avatar-scale: 1.08;\n --liforma-et-bg-shift: 10px;\n --liforma-et-fg-shift: 4px;\n --liforma-et-avatar-shift: 4px;\n}\n\n/* Promote layers only while parallax is active — avoids N compositor surfaces on galleries. */\n.liforma-et--parallax .liforma-et__background,\n.liforma-et--parallax .liforma-et__foreground,\n.liforma-et--parallax .liforma-et__avatar {\n will-change: transform;\n}\n\n.liforma-et--parallax.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.95;\n --liforma-et-bg-scale: 1.95;\n --liforma-et-fg-scale: 1.95;\n --liforma-et-avatar-shift: 0px;\n}\n\n.liforma-et--parallax.liforma-et--fit-medium {\n --liforma-et-avatar-scale: 1.42;\n --liforma-et-bg-scale: 1.42;\n --liforma-et-fg-scale: 1.42;\n --liforma-et-avatar-shift: 0px;\n}\n\n.liforma-et--scroll-parallax .liforma-et__background,\n.liforma-et--scroll-parallax .liforma-et__foreground,\n.liforma-et--scroll-parallax .liforma-et__avatar {\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .liforma-et {\n --liforma-et-reveal-duration: 0ms;\n }\n\n .liforma-et--parallax {\n --liforma-et-bg-scale: 1;\n --liforma-et-fg-scale: 1;\n --liforma-et-avatar-scale: 1;\n --liforma-et-bg-shift: 0px;\n --liforma-et-fg-shift: 0px;\n --liforma-et-avatar-shift: 0px;\n }\n\n .liforma-et--parallax.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.85;\n --liforma-et-bg-scale: 1.85;\n --liforma-et-fg-scale: 1.85;\n }\n\n .liforma-et__background,\n .liforma-et__foreground,\n .liforma-et__avatar {\n transition: none;\n }\n}", xe = !1;
|
|
383
383
|
function Se(e) {
|
|
384
384
|
if (typeof document > "u" || xe) return;
|
|
385
385
|
if (document.querySelector("style[data-liforma-et]")) {
|
|
@@ -395,14 +395,14 @@ function Ce(e, t) {
|
|
|
395
395
|
return `${e} liforma-et__media${t ? " liforma-et__media--ready" : ""}`;
|
|
396
396
|
}
|
|
397
397
|
function we(s) {
|
|
398
|
-
let { galleryThumb: c, avatarImage: l, backgroundImage: u, foregroundImage: d, alt: f, experienceId: p, href: m, target: h, rel: g, onClick: _, returnUrl: v, playerBaseUrl: b, parallax: S = !0, fit: w = "full", lazy: T = !0, className: E = "", fallbackImage: D, normalizeUrls: O = !0, cdnBaseUrl: k } = s, A = n(null), j = n(!1), [
|
|
398
|
+
let { galleryThumb: c, avatarImage: l, backgroundImage: u, foregroundImage: d, alt: f, experienceId: p, href: m, target: h, rel: g, onClick: _, returnUrl: v, playerBaseUrl: b, parallax: S = !0, fit: w = "full", lazy: T = !0, className: E = "", fallbackImage: D, normalizeUrls: O = !0, cdnBaseUrl: k } = s, A = n(null), j = n(!1), [ee, te] = r(0), [M, N] = r(0), ne = x(ee, M), F = t(() => P({
|
|
399
399
|
galleryThumb: c,
|
|
400
400
|
avatarImage: l,
|
|
401
401
|
backgroundImage: u,
|
|
402
402
|
foregroundImage: d,
|
|
403
403
|
fallbackImage: D,
|
|
404
404
|
normalize: O,
|
|
405
|
-
locationPlateSize:
|
|
405
|
+
locationPlateSize: ne,
|
|
406
406
|
cdnBaseUrl: k
|
|
407
407
|
}), [
|
|
408
408
|
c,
|
|
@@ -411,87 +411,87 @@ function we(s) {
|
|
|
411
411
|
d,
|
|
412
412
|
D,
|
|
413
413
|
O,
|
|
414
|
-
|
|
414
|
+
ne,
|
|
415
415
|
k
|
|
416
|
-
]),
|
|
416
|
+
]), I = re({
|
|
417
417
|
href: m,
|
|
418
418
|
hasClickHandler: typeof _ == "function",
|
|
419
419
|
experienceId: p
|
|
420
|
-
}),
|
|
420
|
+
}), ie = I === "anchor" && !m?.trim() && !!p?.trim(), ae = !!F?.backgroundImage, R = S !== !1, [z, oe] = r(!T), [se, ce] = r(!1), [le, ue] = r(!1), [B, de] = r(0), [fe, me] = r(0), [H, U] = r(!1), [W, he] = r(!1), [ge, G] = r(!1), [_e, ye] = r(!1), [xe, we] = r(), Te = F ? H && F.fallbackImage ? F.fallbackImage : F.avatarImage : "";
|
|
421
421
|
e(() => {
|
|
422
422
|
Se(be);
|
|
423
423
|
}, []), e(() => {
|
|
424
|
-
we(
|
|
424
|
+
we(L({
|
|
425
425
|
href: m,
|
|
426
426
|
experienceId: p,
|
|
427
427
|
returnUrl: v,
|
|
428
428
|
playerBaseUrl: b,
|
|
429
|
-
useCurrentPageAsReturnUrl:
|
|
429
|
+
useCurrentPageAsReturnUrl: ie && !v?.trim()
|
|
430
430
|
}));
|
|
431
431
|
}, [
|
|
432
432
|
m,
|
|
433
433
|
p,
|
|
434
434
|
v,
|
|
435
435
|
b,
|
|
436
|
-
|
|
436
|
+
ie
|
|
437
437
|
]), e(() => {
|
|
438
438
|
he(!1), G(!1), ye(!1), U(!1);
|
|
439
439
|
}, [
|
|
440
|
-
|
|
441
|
-
|
|
440
|
+
F?.backgroundImage,
|
|
441
|
+
F?.foregroundImage,
|
|
442
442
|
Te
|
|
443
443
|
]), e(() => {
|
|
444
444
|
let e = A.current;
|
|
445
445
|
if (e) return C(e, (e, t) => {
|
|
446
|
-
|
|
446
|
+
te(e), N(t);
|
|
447
447
|
});
|
|
448
|
-
}, [
|
|
448
|
+
}, [I, xe]), e(() => {
|
|
449
449
|
let e = A.current;
|
|
450
450
|
if (e) {
|
|
451
451
|
if (!T) {
|
|
452
|
-
|
|
452
|
+
oe(!0);
|
|
453
453
|
return;
|
|
454
454
|
}
|
|
455
|
-
return
|
|
456
|
-
e &&
|
|
455
|
+
return pe(e, { onVisibleChange: (e) => {
|
|
456
|
+
e && oe(!0);
|
|
457
457
|
} });
|
|
458
458
|
}
|
|
459
459
|
}, [
|
|
460
460
|
T,
|
|
461
|
+
F,
|
|
461
462
|
I,
|
|
462
|
-
L,
|
|
463
463
|
xe
|
|
464
464
|
]), e(() => {
|
|
465
465
|
let e = A.current;
|
|
466
|
-
if (!(!e || !
|
|
466
|
+
if (!(!e || !R)) return ve(e, {
|
|
467
467
|
onParallax: (e) => {
|
|
468
|
-
|
|
468
|
+
ue(!0), j.current || (de(e), me(0));
|
|
469
469
|
},
|
|
470
470
|
pointerActive: () => j.current
|
|
471
471
|
});
|
|
472
472
|
}, [
|
|
473
|
-
|
|
473
|
+
R,
|
|
474
|
+
F,
|
|
474
475
|
I,
|
|
475
|
-
L,
|
|
476
476
|
xe
|
|
477
477
|
]);
|
|
478
478
|
let Ee = (e) => {
|
|
479
|
-
if (!
|
|
479
|
+
if (!R || le) return;
|
|
480
480
|
let t = e.currentTarget.getBoundingClientRect();
|
|
481
|
-
t.width <= 0 || t.height <= 0 || (
|
|
481
|
+
t.width <= 0 || t.height <= 0 || (de(((e.clientX - t.left) / t.width - .5) * 2), me(((e.clientY - t.top) / t.height - .5) * 2));
|
|
482
482
|
}, De = (e) => {
|
|
483
483
|
let t = j.current;
|
|
484
|
-
j.current = !1,
|
|
484
|
+
j.current = !1, ce(!1), le && t ? (de(V(e.getBoundingClientRect(), window.innerHeight)), me(0)) : le || (de(0), me(0));
|
|
485
485
|
}, Oe = (e) => {
|
|
486
|
-
if (!
|
|
487
|
-
j.current = !0, e.pointerType === "mouse" &&
|
|
486
|
+
if (!R) return;
|
|
487
|
+
j.current = !0, e.pointerType === "mouse" && ce(!0);
|
|
488
488
|
let t = e.currentTarget, n = () => {
|
|
489
489
|
De(t), window.removeEventListener("pointerup", n), window.removeEventListener("pointercancel", n);
|
|
490
490
|
};
|
|
491
491
|
window.addEventListener("pointerup", n), window.addEventListener("pointercancel", n);
|
|
492
492
|
}, ke = (e) => {
|
|
493
|
-
if (_?.(e), !e.defaultPrevented &&
|
|
494
|
-
let t =
|
|
493
|
+
if (_?.(e), !e.defaultPrevented && ie && !v?.trim()) {
|
|
494
|
+
let t = L({
|
|
495
495
|
experienceId: p,
|
|
496
496
|
playerBaseUrl: b,
|
|
497
497
|
useCurrentPageAsReturnUrl: !0
|
|
@@ -499,19 +499,19 @@ function we(s) {
|
|
|
499
499
|
t && e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && (e.preventDefault(), window.location.assign(t));
|
|
500
500
|
}
|
|
501
501
|
};
|
|
502
|
-
if (!
|
|
503
|
-
let Ae =
|
|
502
|
+
if (!F) return null;
|
|
503
|
+
let Ae = R && (se || le), K = z && (ge || W || _e), je = [
|
|
504
504
|
"liforma-et",
|
|
505
|
-
|
|
505
|
+
ae ? "liforma-et--scene" : "",
|
|
506
506
|
y(w),
|
|
507
507
|
Ae ? "liforma-et--parallax" : "",
|
|
508
|
-
|
|
509
|
-
|
|
508
|
+
le ? "liforma-et--scroll-parallax" : "",
|
|
509
|
+
z && !K ? "liforma-et--loading" : "",
|
|
510
510
|
K ? "liforma-et--revealed" : "",
|
|
511
511
|
E
|
|
512
512
|
].filter(Boolean).join(" "), Me = {
|
|
513
|
-
"--liforma-et-parallax-x":
|
|
514
|
-
"--liforma-et-parallax-y":
|
|
513
|
+
"--liforma-et-parallax-x": B,
|
|
514
|
+
"--liforma-et-parallax-y": fe
|
|
515
515
|
}, q = (e, t) => {
|
|
516
516
|
e.complete && t(!0);
|
|
517
517
|
}, Ne = /* @__PURE__ */ o(i, { children: [
|
|
@@ -519,9 +519,9 @@ function we(s) {
|
|
|
519
519
|
className: "liforma-et__placeholder",
|
|
520
520
|
"aria-hidden": "true"
|
|
521
521
|
}),
|
|
522
|
-
|
|
522
|
+
z && F.backgroundImage ? /* @__PURE__ */ a("img", {
|
|
523
523
|
className: Ce("liforma-et__background", W),
|
|
524
|
-
src:
|
|
524
|
+
src: F.backgroundImage,
|
|
525
525
|
alt: "",
|
|
526
526
|
decoding: "async",
|
|
527
527
|
ref: (e) => {
|
|
@@ -530,7 +530,7 @@ function we(s) {
|
|
|
530
530
|
onLoad: () => he(!0),
|
|
531
531
|
onError: () => he(!0)
|
|
532
532
|
}) : null,
|
|
533
|
-
|
|
533
|
+
z && Te ? /* @__PURE__ */ a("img", {
|
|
534
534
|
className: Ce("liforma-et__avatar", ge),
|
|
535
535
|
src: Te,
|
|
536
536
|
alt: "",
|
|
@@ -540,12 +540,12 @@ function we(s) {
|
|
|
540
540
|
},
|
|
541
541
|
onLoad: () => G(!0),
|
|
542
542
|
onError: () => {
|
|
543
|
-
|
|
543
|
+
F.fallbackImage ? U(!0) : G(!0);
|
|
544
544
|
}
|
|
545
545
|
}) : null,
|
|
546
|
-
|
|
546
|
+
z && F.foregroundImage ? /* @__PURE__ */ a("img", {
|
|
547
547
|
className: Ce("liforma-et__foreground", _e),
|
|
548
|
-
src:
|
|
548
|
+
src: F.foregroundImage,
|
|
549
549
|
alt: "",
|
|
550
550
|
decoding: "async",
|
|
551
551
|
ref: (e) => {
|
|
@@ -559,16 +559,16 @@ function we(s) {
|
|
|
559
559
|
onPointerUp: (e) => De(e.currentTarget),
|
|
560
560
|
onPointerCancel: (e) => De(e.currentTarget),
|
|
561
561
|
onPointerEnter: (e) => {
|
|
562
|
-
|
|
562
|
+
R && e.pointerType === "mouse" && ce(!0);
|
|
563
563
|
},
|
|
564
564
|
onPointerMove: Ee,
|
|
565
565
|
onPointerLeave: () => {
|
|
566
|
-
j.current || (
|
|
566
|
+
j.current || (ce(!1), le || (de(0), me(0)));
|
|
567
567
|
}
|
|
568
568
|
}, Fe = (e) => {
|
|
569
569
|
A.current = e;
|
|
570
570
|
};
|
|
571
|
-
return
|
|
571
|
+
return I === "anchor" && xe ? /* @__PURE__ */ a("a", {
|
|
572
572
|
ref: Fe,
|
|
573
573
|
className: je,
|
|
574
574
|
style: Me,
|
|
@@ -579,7 +579,7 @@ function we(s) {
|
|
|
579
579
|
onClick: ke,
|
|
580
580
|
...Pe,
|
|
581
581
|
children: Ne
|
|
582
|
-
}) :
|
|
582
|
+
}) : I === "button" ? /* @__PURE__ */ a("button", {
|
|
583
583
|
type: "button",
|
|
584
584
|
ref: Fe,
|
|
585
585
|
className: je,
|
|
@@ -623,7 +623,7 @@ function Ae() {
|
|
|
623
623
|
return t ? t.replace(/\/$/, "") : null;
|
|
624
624
|
}
|
|
625
625
|
function K() {
|
|
626
|
-
return Ae() || (
|
|
626
|
+
return Ae() || (ne() ? ke : Oe);
|
|
627
627
|
}
|
|
628
628
|
//#endregion
|
|
629
629
|
//#region src/v2/api/fetchExperiencePreview.ts
|
|
@@ -1038,13 +1038,13 @@ var ut = new Set([1, 2]);
|
|
|
1038
1038
|
function dt(e) {
|
|
1039
1039
|
return typeof e == "number" && ut.has(e);
|
|
1040
1040
|
}
|
|
1041
|
-
var ft = 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.interactionChange".split("."));
|
|
1041
|
+
var ft = new Set(/* @__PURE__ */ "close.stateUpdate.commandResult.userTranscript.characterSpeechStarted.characterSpeechEnded.characterFocusChanged.conversationUpdate.listeningState.userSpeechStarted.userSpeechEnded.modeChange.activityChange.feedback.feedbackFailed.message.started.embedReady.widgetReady.widgetExpand.widgetCollapse.widgetAudioSettings.widgetDragStart.widgetDragMove.widgetDragEnd.fullWindow.theatre.interactionChange".split("."));
|
|
1042
1042
|
function pt(e) {
|
|
1043
1043
|
if (!e || typeof e != "object") return null;
|
|
1044
1044
|
let t = e;
|
|
1045
1045
|
if (!dt(t.schemaVersion) || !t.type || !ft.has(t.type)) return null;
|
|
1046
1046
|
if (t.type === "embedReady" || t.type === "widgetReady" || t.type === "widgetExpand" || t.type === "widgetCollapse") return t;
|
|
1047
|
-
if (t.type === "fullWindow") {
|
|
1047
|
+
if (t.type === "fullWindow" || t.type === "theatre") {
|
|
1048
1048
|
let e = t.payload;
|
|
1049
1049
|
return !e || typeof e != "object" || typeof e.active != "boolean" ? null : t;
|
|
1050
1050
|
}
|
|
@@ -1068,7 +1068,7 @@ function pt(e) {
|
|
|
1068
1068
|
function mt(e, t, n) {
|
|
1069
1069
|
let r = e.trim();
|
|
1070
1070
|
if (!r) throw Error("createLaunchMessage requires a non-empty launch string.");
|
|
1071
|
-
let i = n?.startButton, a = n?.theme, o = n?.showFeedback, s = n?.interaction;
|
|
1071
|
+
let i = n?.startButton, a = n?.theme, o = n?.showFeedback, s = n?.interaction, c = n?.theatreButton, l = n?.theatre;
|
|
1072
1072
|
return {
|
|
1073
1073
|
type: "launch",
|
|
1074
1074
|
schemaVersion: 2,
|
|
@@ -1078,7 +1078,9 @@ function mt(e, t, n) {
|
|
|
1078
1078
|
...i ? { startButton: i } : {},
|
|
1079
1079
|
...a ? { theme: a } : {},
|
|
1080
1080
|
...o === void 0 ? {} : { showFeedback: o },
|
|
1081
|
-
...s ? { interaction: s } : {}
|
|
1081
|
+
...s ? { interaction: s } : {},
|
|
1082
|
+
...c ? { theatreButton: !0 } : {},
|
|
1083
|
+
...l === void 0 ? {} : { theatre: l }
|
|
1082
1084
|
}
|
|
1083
1085
|
};
|
|
1084
1086
|
}
|
|
@@ -1102,10 +1104,17 @@ function _t() {
|
|
|
1102
1104
|
payload: {}
|
|
1103
1105
|
};
|
|
1104
1106
|
}
|
|
1107
|
+
function vt(e) {
|
|
1108
|
+
return {
|
|
1109
|
+
type: "setTheatre",
|
|
1110
|
+
schemaVersion: 2,
|
|
1111
|
+
payload: { active: e }
|
|
1112
|
+
};
|
|
1113
|
+
}
|
|
1105
1114
|
//#endregion
|
|
1106
1115
|
//#region src/v2/embed/fullWindowHost.ts
|
|
1107
|
-
var
|
|
1108
|
-
function
|
|
1116
|
+
var yt = "2147483000";
|
|
1117
|
+
function bt(e) {
|
|
1109
1118
|
let { style: t } = e;
|
|
1110
1119
|
return {
|
|
1111
1120
|
position: t.position,
|
|
@@ -1123,11 +1132,11 @@ function yt(e) {
|
|
|
1123
1132
|
maxHeight: t.maxHeight
|
|
1124
1133
|
};
|
|
1125
1134
|
}
|
|
1126
|
-
function
|
|
1135
|
+
function xt(e) {
|
|
1127
1136
|
let { style: t } = e;
|
|
1128
|
-
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 =
|
|
1137
|
+
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 = yt, t.margin = "0", t.borderRadius = "0", t.maxWidth = "none", t.maxHeight = "none", e.dataset.liformaFullWindow = "1";
|
|
1129
1138
|
}
|
|
1130
|
-
function
|
|
1139
|
+
function St(e, t) {
|
|
1131
1140
|
if (delete e.dataset.liformaFullWindow, !t) {
|
|
1132
1141
|
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 = "";
|
|
1133
1142
|
return;
|
|
@@ -1137,20 +1146,20 @@ function xt(e, t) {
|
|
|
1137
1146
|
}
|
|
1138
1147
|
//#endregion
|
|
1139
1148
|
//#region src/v2/embed/iframeHost.ts
|
|
1140
|
-
function
|
|
1149
|
+
function Ct(e) {
|
|
1141
1150
|
return e;
|
|
1142
1151
|
}
|
|
1143
1152
|
function Z() {
|
|
1144
1153
|
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)}`;
|
|
1145
1154
|
}
|
|
1146
|
-
var
|
|
1147
|
-
function
|
|
1155
|
+
var wt = 3e4;
|
|
1156
|
+
function Tt(e) {
|
|
1148
1157
|
let t = e.container;
|
|
1149
1158
|
getComputedStyle(t).position === "static" && (t.style.position = "relative");
|
|
1150
1159
|
let n = document.createElement("iframe");
|
|
1151
|
-
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");
|
|
1152
|
-
let r = !1, i = !1, a = null, o =
|
|
1153
|
-
i !==
|
|
1160
|
+
n.src = e.src, n.title = "Liforma experience", n.setAttribute("allow", "microphone; autoplay; clipboard-read; clipboard-write; fullscreen"), n.setAttribute("allowfullscreen", ""), n.style.cssText = e.transparent ? "display:block;position:absolute;inset:0;width:100%;height:100%;border:0;background:transparent;" : "display:block;position:absolute;inset:0;width:100%;height:100%;border:0;background:#030508;", e.transparent && n.setAttribute("allowtransparency", "true");
|
|
1161
|
+
let r = !1, i = !1, a = null, o = null, s = (r) => {
|
|
1162
|
+
i !== r && (i = r, r ? (a = bt(n), o = document.body.style.overflow, document.body.append(n), xt(n), document.body.style.overflow = "hidden") : (t.append(n), St(n, a), a = null, o !== null && (document.body.style.overflow = o, o = null)), e.onFullWindowChange?.(r));
|
|
1154
1163
|
}, c = /* @__PURE__ */ new Map(), l = null, u = 0, d = 0, f = [], p = null, m = null, h = new Promise((e, t) => {
|
|
1155
1164
|
p = e, m = t;
|
|
1156
1165
|
}), g = () => {
|
|
@@ -1221,7 +1230,7 @@ function wt(e) {
|
|
|
1221
1230
|
e.onUserSpeechEnded?.(i.payload);
|
|
1222
1231
|
break;
|
|
1223
1232
|
case "modeChange":
|
|
1224
|
-
e.onActivityChange?.(
|
|
1233
|
+
e.onActivityChange?.(Ct(i.payload.mode));
|
|
1225
1234
|
break;
|
|
1226
1235
|
case "activityChange":
|
|
1227
1236
|
e.onActivityChange?.(i.payload.activity);
|
|
@@ -1265,6 +1274,9 @@ function wt(e) {
|
|
|
1265
1274
|
case "fullWindow":
|
|
1266
1275
|
s(i.payload.active);
|
|
1267
1276
|
break;
|
|
1277
|
+
case "theatre":
|
|
1278
|
+
e.onTheatreChange?.(i.payload.active);
|
|
1279
|
+
break;
|
|
1268
1280
|
case "interactionChange":
|
|
1269
1281
|
e.onInteractionChange?.(i.payload.interaction);
|
|
1270
1282
|
break;
|
|
@@ -1322,6 +1334,9 @@ function wt(e) {
|
|
|
1322
1334
|
postWidgetToggleAudioSettings() {
|
|
1323
1335
|
S(_t());
|
|
1324
1336
|
},
|
|
1337
|
+
postSetTheatre(e) {
|
|
1338
|
+
S(vt(e));
|
|
1339
|
+
},
|
|
1325
1340
|
speak(e) {
|
|
1326
1341
|
return C({
|
|
1327
1342
|
type: "speak",
|
|
@@ -1442,7 +1457,7 @@ function wt(e) {
|
|
|
1442
1457
|
audio: e.audio,
|
|
1443
1458
|
byteLength: e.byteLength
|
|
1444
1459
|
}
|
|
1445
|
-
},
|
|
1460
|
+
}, wt, [e.audio]);
|
|
1446
1461
|
},
|
|
1447
1462
|
speechUtteranceSetTranscript(e) {
|
|
1448
1463
|
return C({
|
|
@@ -1604,7 +1619,7 @@ function wt(e) {
|
|
|
1604
1619
|
}
|
|
1605
1620
|
//#endregion
|
|
1606
1621
|
//#region src/v2/embed/readyGate.ts
|
|
1607
|
-
function
|
|
1622
|
+
function Et(e) {
|
|
1608
1623
|
let t, n = !1, r = !1, i = () => {
|
|
1609
1624
|
r || !n || t === void 0 || (r = !0, e(t));
|
|
1610
1625
|
};
|
|
@@ -1619,9 +1634,9 @@ function Tt(e) {
|
|
|
1619
1634
|
}
|
|
1620
1635
|
//#endregion
|
|
1621
1636
|
//#region src/v2/sdkRelease.ts
|
|
1622
|
-
var
|
|
1637
|
+
var Dt = `sdk@${{
|
|
1623
1638
|
name: "@liforma/client",
|
|
1624
|
-
version: "0.4.
|
|
1639
|
+
version: "0.4.13",
|
|
1625
1640
|
type: "module",
|
|
1626
1641
|
description: "Liforma browser SDK — Experience sessions, speech API, and Svelte embed component.",
|
|
1627
1642
|
license: "MIT",
|
|
@@ -1840,50 +1855,50 @@ var Et = `sdk@${{
|
|
|
1840
1855
|
vitest: "^4.1.10",
|
|
1841
1856
|
wrangler: "^4.101.0"
|
|
1842
1857
|
}
|
|
1843
|
-
}.version}`,
|
|
1844
|
-
function
|
|
1858
|
+
}.version}`, Ot = "https://player.liforma.ai/embed", kt = "http://localhost:3002/embed";
|
|
1859
|
+
function At() {
|
|
1845
1860
|
let e = globalThis.__LIFORMA_PLAYER_EMBED_URL;
|
|
1846
1861
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
1847
1862
|
if (typeof document > "u") return null;
|
|
1848
1863
|
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();
|
|
1849
1864
|
return t ? t.replace(/\/$/, "") : null;
|
|
1850
1865
|
}
|
|
1851
|
-
function
|
|
1852
|
-
let e =
|
|
1853
|
-
return e ? e.endsWith("/embed") ? e : `${e}/embed` :
|
|
1866
|
+
function jt() {
|
|
1867
|
+
let e = At();
|
|
1868
|
+
return e ? e.endsWith("/embed") ? e : `${e}/embed` : ne() ? kt : Ot;
|
|
1854
1869
|
}
|
|
1855
|
-
function
|
|
1870
|
+
function Mt(e, t) {
|
|
1856
1871
|
return e?.trim() || t?.trim() || void 0;
|
|
1857
1872
|
}
|
|
1858
|
-
function
|
|
1859
|
-
let d = (e ??
|
|
1873
|
+
function Nt(e, t, n, r, i, a, o, s, c, l, u) {
|
|
1874
|
+
let d = (e ?? jt()).replace(/\/$/, ""), f = d.endsWith("/embed") ? d : `${d}/embed`, p = new URL(f), m = n?.trim();
|
|
1860
1875
|
m && p.searchParams.set("backdropId", m);
|
|
1861
1876
|
let h = r?.trim();
|
|
1862
|
-
return h && p.searchParams.set("avatarId", h), (i === "face" || i === "medium") && p.searchParams.set("fit", i), c === "pip" && p.searchParams.set("stage", "pip"), l === "set" && p.searchParams.set("pipBackground", "set"), u === !1 && p.searchParams.set("pipShadow", "0"), a === "widget" && p.searchParams.set("ui", "widget"), o && p.searchParams.set("close", "1"), t && p.searchParams.set("debug", "true"), (s === 2 || s === 3 || s === 4) && p.searchParams.set("cast", String(s)),
|
|
1877
|
+
return h && p.searchParams.set("avatarId", h), (i === "face" || i === "medium") && p.searchParams.set("fit", i), c === "pip" && p.searchParams.set("stage", "pip"), l === "set" && p.searchParams.set("pipBackground", "set"), u === !1 && p.searchParams.set("pipShadow", "0"), a === "widget" && p.searchParams.set("ui", "widget"), o && p.searchParams.set("close", "1"), t && p.searchParams.set("debug", "true"), (s === 2 || s === 3 || s === 4) && p.searchParams.set("cast", String(s)), Pt(p.toString());
|
|
1863
1878
|
}
|
|
1864
|
-
function
|
|
1879
|
+
function Pt(e) {
|
|
1865
1880
|
if (typeof location > "u") return e;
|
|
1866
1881
|
let t = new URL(e);
|
|
1867
1882
|
return t.searchParams.set("parentOrigin", location.origin), t.toString();
|
|
1868
1883
|
}
|
|
1869
|
-
function
|
|
1884
|
+
function Ft(e) {
|
|
1870
1885
|
return new URL(e).origin;
|
|
1871
1886
|
}
|
|
1872
1887
|
//#endregion
|
|
1873
1888
|
//#region src/v2/experienceEvents.ts
|
|
1874
|
-
function
|
|
1889
|
+
function It() {
|
|
1875
1890
|
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)}`;
|
|
1876
1891
|
}
|
|
1877
|
-
function
|
|
1892
|
+
function Lt(e, t, n) {
|
|
1878
1893
|
return {
|
|
1879
|
-
id:
|
|
1894
|
+
id: It(),
|
|
1880
1895
|
type: e,
|
|
1881
1896
|
sessionId: t,
|
|
1882
1897
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1883
1898
|
data: n
|
|
1884
1899
|
};
|
|
1885
1900
|
}
|
|
1886
|
-
function
|
|
1901
|
+
function Rt() {
|
|
1887
1902
|
return {
|
|
1888
1903
|
ready: /* @__PURE__ */ new Set(),
|
|
1889
1904
|
started: /* @__PURE__ */ new Set(),
|
|
@@ -1904,39 +1919,39 @@ function Lt() {
|
|
|
1904
1919
|
conversationProcessorError: /* @__PURE__ */ new Set()
|
|
1905
1920
|
};
|
|
1906
1921
|
}
|
|
1907
|
-
function
|
|
1922
|
+
function zt(e, t, n) {
|
|
1908
1923
|
return e[t].add(n), () => e[t].delete(n);
|
|
1909
1924
|
}
|
|
1910
|
-
function
|
|
1925
|
+
function Bt(e, t, n) {
|
|
1911
1926
|
for (let r of e[t]) r(n);
|
|
1912
1927
|
}
|
|
1913
|
-
function
|
|
1928
|
+
function Vt(e) {
|
|
1914
1929
|
for (let t of Object.keys(e)) e[t].clear();
|
|
1915
1930
|
}
|
|
1916
1931
|
//#endregion
|
|
1917
1932
|
//#region src/v2/speech/types.ts
|
|
1918
|
-
function
|
|
1933
|
+
function Ht(e) {
|
|
1919
1934
|
return "data" in e && "format" in e && e.format != null && !("track" in e);
|
|
1920
1935
|
}
|
|
1921
|
-
function
|
|
1936
|
+
function Ut(e) {
|
|
1922
1937
|
return "url" in e && typeof e.url == "string";
|
|
1923
1938
|
}
|
|
1924
|
-
function
|
|
1939
|
+
function Wt(e) {
|
|
1925
1940
|
if (!("track" in e)) return !1;
|
|
1926
1941
|
let t = e.track;
|
|
1927
1942
|
return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
|
|
1928
1943
|
}
|
|
1929
|
-
function
|
|
1930
|
-
return !
|
|
1944
|
+
function Gt(e) {
|
|
1945
|
+
return !Ht(e) && !Ut(e) && !Wt(e) && "encoding" in e && typeof e.encoding == "string";
|
|
1931
1946
|
}
|
|
1932
|
-
var
|
|
1947
|
+
var Kt = [
|
|
1933
1948
|
8e3,
|
|
1934
1949
|
16e3,
|
|
1935
1950
|
22050,
|
|
1936
1951
|
24e3,
|
|
1937
1952
|
44100,
|
|
1938
1953
|
48e3
|
|
1939
|
-
],
|
|
1954
|
+
], qt = {
|
|
1940
1955
|
MAX_CHUNK_BYTES: 64 * 1024,
|
|
1941
1956
|
RECOMMENDED_CHUNK_MS_MIN: 20,
|
|
1942
1957
|
RECOMMENDED_CHUNK_MS_MAX: 200,
|
|
@@ -1947,14 +1962,14 @@ var Gt = [
|
|
|
1947
1962
|
MAX_UTTERANCE_DURATION_MS: 9e4,
|
|
1948
1963
|
MAX_PENDING_WRITES: 8,
|
|
1949
1964
|
DEFAULT_WRITE_TIMEOUT_MS: 5e3
|
|
1950
|
-
},
|
|
1965
|
+
}, Jt = class extends Error {
|
|
1951
1966
|
operation;
|
|
1952
1967
|
requiredCapability;
|
|
1953
1968
|
name = "UnsupportedSpeechOperationError";
|
|
1954
1969
|
constructor(e, t) {
|
|
1955
1970
|
super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
|
|
1956
1971
|
}
|
|
1957
|
-
},
|
|
1972
|
+
}, Yt = class extends Error {
|
|
1958
1973
|
name = "SpeechUtteranceClosedError";
|
|
1959
1974
|
constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
|
|
1960
1975
|
super(e);
|
|
@@ -1964,72 +1979,72 @@ var Gt = [
|
|
|
1964
1979
|
constructor(e, t) {
|
|
1965
1980
|
super(e, t);
|
|
1966
1981
|
}
|
|
1967
|
-
},
|
|
1982
|
+
}, Xt = class extends Error {
|
|
1968
1983
|
name = "SpeechBufferTimeoutError";
|
|
1969
1984
|
constructor(e = "Timed out waiting for speech buffer capacity.") {
|
|
1970
1985
|
super(e);
|
|
1971
1986
|
}
|
|
1972
1987
|
};
|
|
1973
|
-
function
|
|
1988
|
+
function Zt(e = "none") {
|
|
1974
1989
|
return {
|
|
1975
1990
|
mode: e,
|
|
1976
1991
|
trackedDurationMs: 0,
|
|
1977
1992
|
fallbackDurationMs: 0
|
|
1978
1993
|
};
|
|
1979
1994
|
}
|
|
1980
|
-
function Zt(e) {
|
|
1981
|
-
return Gt.includes(e);
|
|
1982
|
-
}
|
|
1983
1995
|
function Qt(e) {
|
|
1996
|
+
return Kt.includes(e);
|
|
1997
|
+
}
|
|
1998
|
+
function $t(e) {
|
|
1984
1999
|
if (e.encoding !== "pcm_s16le") throw new Q(`Unsupported audio encoding: ${e.encoding}`);
|
|
1985
2000
|
if (e.channels !== 1) throw new Q(`Unsupported channel count: ${e.channels}`);
|
|
1986
|
-
if (!
|
|
2001
|
+
if (!Qt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1987
2002
|
}
|
|
1988
|
-
function
|
|
1989
|
-
if (
|
|
1990
|
-
|
|
2003
|
+
function en(e) {
|
|
2004
|
+
if (Ht(e)) {
|
|
2005
|
+
$t(e.format);
|
|
1991
2006
|
return;
|
|
1992
2007
|
}
|
|
1993
|
-
if (
|
|
2008
|
+
if (Ut(e)) {
|
|
1994
2009
|
if (!e.url.trim()) throw new Q("Audio URL must be non-empty.");
|
|
1995
|
-
if (e.sampleRate !== void 0 && !
|
|
2010
|
+
if (e.sampleRate !== void 0 && !Qt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1996
2011
|
return;
|
|
1997
2012
|
}
|
|
1998
|
-
if (
|
|
2013
|
+
if (Wt(e)) {
|
|
1999
2014
|
if (e.track.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
2000
|
-
if (e.sampleRate !== void 0 && !
|
|
2015
|
+
if (e.sampleRate !== void 0 && !Qt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
2001
2016
|
return;
|
|
2002
2017
|
}
|
|
2003
|
-
if (
|
|
2018
|
+
if (Gt(e)) {
|
|
2004
2019
|
let t = e.encoding.trim().toLowerCase();
|
|
2005
2020
|
if (!t) throw new Q("Encoded audio MIME type is required.");
|
|
2006
2021
|
if (t === "pcm_s16le") throw new Q("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
|
|
2007
|
-
if (e.sampleRate !== void 0 && !
|
|
2022
|
+
if (e.sampleRate !== void 0 && !Qt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
2008
2023
|
return;
|
|
2009
2024
|
}
|
|
2010
2025
|
throw new Q("Unsupported speech.play audio shape.");
|
|
2011
2026
|
}
|
|
2012
|
-
function
|
|
2013
|
-
if (e.format) return
|
|
2027
|
+
function tn(e) {
|
|
2028
|
+
if (e.format) return $t(e.format), e.format;
|
|
2014
2029
|
if (e.track) {
|
|
2015
2030
|
let t = {
|
|
2016
2031
|
encoding: "pcm_s16le",
|
|
2017
2032
|
sampleRate: e.sampleRate ?? 24e3,
|
|
2018
2033
|
channels: 1
|
|
2019
2034
|
};
|
|
2020
|
-
return
|
|
2035
|
+
return $t(t), t;
|
|
2021
2036
|
}
|
|
2022
2037
|
throw new Q("createUtterance requires format or track.");
|
|
2023
2038
|
}
|
|
2024
|
-
function
|
|
2039
|
+
function nn(e) {
|
|
2025
2040
|
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
2026
2041
|
}
|
|
2027
|
-
function
|
|
2042
|
+
function rn(e) {
|
|
2028
2043
|
return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
|
|
2029
2044
|
}
|
|
2030
2045
|
//#endregion
|
|
2031
2046
|
//#region src/byo/pcm.ts
|
|
2032
|
-
function
|
|
2047
|
+
function an(e) {
|
|
2033
2048
|
let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
|
|
2034
2049
|
for (let t = 0; t < e.length; t++) {
|
|
2035
2050
|
let r = Math.max(-1, Math.min(1, e[t]));
|
|
@@ -2039,11 +2054,11 @@ function rn(e) {
|
|
|
2039
2054
|
}
|
|
2040
2055
|
//#endregion
|
|
2041
2056
|
//#region src/byo/resample.ts
|
|
2042
|
-
function
|
|
2057
|
+
function on(e, t, n, r, i) {
|
|
2043
2058
|
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;
|
|
2044
2059
|
return ((a * i + o) * i + s) * i + c;
|
|
2045
2060
|
}
|
|
2046
|
-
function
|
|
2061
|
+
function sn(e, t) {
|
|
2047
2062
|
if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
|
|
2048
2063
|
if (e === t) return {
|
|
2049
2064
|
fromRate: e,
|
|
@@ -2066,7 +2081,7 @@ function on(e, t) {
|
|
|
2066
2081
|
let a = [];
|
|
2067
2082
|
for (; i + 2 < r.length - 1;) {
|
|
2068
2083
|
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);
|
|
2069
|
-
a.push(
|
|
2084
|
+
a.push(on(r[o], r[e], r[s], r[c], t)), i += n;
|
|
2070
2085
|
}
|
|
2071
2086
|
let o = Math.max(0, Math.floor(i) - 1);
|
|
2072
2087
|
return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
|
|
@@ -2078,7 +2093,7 @@ function on(e, t) {
|
|
|
2078
2093
|
}
|
|
2079
2094
|
//#endregion
|
|
2080
2095
|
//#region src/byo/audioCapture.ts
|
|
2081
|
-
var
|
|
2096
|
+
var cn = "liforma-pcm-capture", ln = `
|
|
2082
2097
|
class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
2083
2098
|
process(inputs) {
|
|
2084
2099
|
const ch = inputs[0] && inputs[0][0];
|
|
@@ -2090,29 +2105,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
|
2090
2105
|
return true;
|
|
2091
2106
|
}
|
|
2092
2107
|
}
|
|
2093
|
-
registerProcessor('${
|
|
2094
|
-
`,
|
|
2095
|
-
function un() {
|
|
2096
|
-
return ln ||= URL.createObjectURL(new Blob([cn], { type: "application/javascript" })), ln;
|
|
2097
|
-
}
|
|
2108
|
+
registerProcessor('${cn}', LiformaPcmCaptureProcessor);
|
|
2109
|
+
`, un = null;
|
|
2098
2110
|
function dn() {
|
|
2111
|
+
return un ||= URL.createObjectURL(new Blob([ln], { type: "application/javascript" })), un;
|
|
2112
|
+
}
|
|
2113
|
+
function fn() {
|
|
2099
2114
|
return window.AudioContext || window.webkitAudioContext || null;
|
|
2100
2115
|
}
|
|
2101
|
-
async function
|
|
2102
|
-
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o =
|
|
2116
|
+
async function pn(e) {
|
|
2117
|
+
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = fn();
|
|
2103
2118
|
if (!o) throw Error("Web Audio is required for audio capture");
|
|
2104
2119
|
let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
|
|
2105
2120
|
l.gain.value = 0;
|
|
2106
|
-
let u = s.sampleRate, d =
|
|
2121
|
+
let u = s.sampleRate, d = sn(u, n), f = !1, p = !1, m = (e) => {
|
|
2107
2122
|
if (f || i && !i()) return;
|
|
2108
2123
|
let t = d.push(e);
|
|
2109
|
-
t.length !== 0 && r(
|
|
2124
|
+
t.length !== 0 && r(an(t));
|
|
2110
2125
|
}, h = () => void 0;
|
|
2111
2126
|
return await (async () => {
|
|
2112
2127
|
if (typeof s.audioWorklet?.addModule != "function") return !1;
|
|
2113
2128
|
try {
|
|
2114
|
-
await s.audioWorklet.addModule(
|
|
2115
|
-
let e = new AudioWorkletNode(s,
|
|
2129
|
+
await s.audioWorklet.addModule(dn());
|
|
2130
|
+
let e = new AudioWorkletNode(s, cn, {
|
|
2116
2131
|
numberOfInputs: 1,
|
|
2117
2132
|
numberOfOutputs: 1,
|
|
2118
2133
|
outputChannelCount: [1]
|
|
@@ -2162,7 +2177,7 @@ async function fn(e) {
|
|
|
2162
2177
|
}
|
|
2163
2178
|
//#endregion
|
|
2164
2179
|
//#region src/v2/speech/captureMediaStreamTrack.ts
|
|
2165
|
-
async function
|
|
2180
|
+
async function mn(e) {
|
|
2166
2181
|
let { track: t, utterance: n, sampleRate: r, signal: i } = e;
|
|
2167
2182
|
if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Q("MediaStreamTrack is not available in this environment.");
|
|
2168
2183
|
if (t.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
@@ -2171,18 +2186,18 @@ async function pn(e) {
|
|
|
2171
2186
|
s || (s = !0, c?.stop(), c = null);
|
|
2172
2187
|
};
|
|
2173
2188
|
try {
|
|
2174
|
-
c = await
|
|
2189
|
+
c = await pn({
|
|
2175
2190
|
mediaStream: a,
|
|
2176
2191
|
targetSampleRate: r,
|
|
2177
2192
|
shouldSend: () => !s && !i?.aborted,
|
|
2178
2193
|
onPcm: (e) => {
|
|
2179
2194
|
if (s || i?.aborted) return;
|
|
2180
|
-
let t =
|
|
2195
|
+
let t = nn(e);
|
|
2181
2196
|
o = o.then(async () => {
|
|
2182
2197
|
if (s || i?.aborted) return;
|
|
2183
2198
|
let e = 0;
|
|
2184
2199
|
for (; e < t.byteLength;) {
|
|
2185
|
-
let r = Math.min(e +
|
|
2200
|
+
let r = Math.min(e + qt.MAX_CHUNK_BYTES, t.byteLength);
|
|
2186
2201
|
if ((r - e) % 2 == 1 && --r, r <= e) break;
|
|
2187
2202
|
let i = t.subarray(e, r);
|
|
2188
2203
|
e = r, i.byteLength !== 0 && await n.write(i);
|
|
@@ -2206,10 +2221,10 @@ async function pn(e) {
|
|
|
2206
2221
|
}
|
|
2207
2222
|
//#endregion
|
|
2208
2223
|
//#region src/v2/speech/speechController.ts
|
|
2209
|
-
async function
|
|
2210
|
-
if (
|
|
2211
|
-
if (
|
|
2212
|
-
let t =
|
|
2224
|
+
async function hn(e, t) {
|
|
2225
|
+
if (Wt(e)) throw new Q("MediaStreamTrack play is handled on the host before embed.");
|
|
2226
|
+
if (Ht(e)) {
|
|
2227
|
+
let t = nn(e.data);
|
|
2213
2228
|
if (t.byteLength & 1) throw new Q("PCM byte length must be even.");
|
|
2214
2229
|
return {
|
|
2215
2230
|
kind: "pcm",
|
|
@@ -2217,17 +2232,17 @@ async function mn(e, t) {
|
|
|
2217
2232
|
format: e.format
|
|
2218
2233
|
};
|
|
2219
2234
|
}
|
|
2220
|
-
if (
|
|
2235
|
+
if (Ut(e)) return {
|
|
2221
2236
|
kind: "url",
|
|
2222
2237
|
url: e.url.trim(),
|
|
2223
2238
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
2224
2239
|
};
|
|
2225
|
-
if (!
|
|
2240
|
+
if (!Gt(e)) throw new Q("Unsupported speech.play audio shape.");
|
|
2226
2241
|
let n;
|
|
2227
2242
|
if (typeof Blob < "u" && e.data instanceof Blob) {
|
|
2228
2243
|
if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2229
2244
|
n = new Uint8Array(await e.data.arrayBuffer());
|
|
2230
|
-
} else n =
|
|
2245
|
+
} else n = nn(e.data);
|
|
2231
2246
|
return {
|
|
2232
2247
|
kind: "encoded",
|
|
2233
2248
|
data: n.slice().buffer,
|
|
@@ -2235,10 +2250,10 @@ async function mn(e, t) {
|
|
|
2235
2250
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
2236
2251
|
};
|
|
2237
2252
|
}
|
|
2238
|
-
function
|
|
2253
|
+
function gn() {
|
|
2239
2254
|
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)}`;
|
|
2240
2255
|
}
|
|
2241
|
-
function
|
|
2256
|
+
function _n(e, t = "completed") {
|
|
2242
2257
|
return {
|
|
2243
2258
|
utteranceId: e.speechId,
|
|
2244
2259
|
characterId: e.characterId,
|
|
@@ -2252,13 +2267,13 @@ function gn(e, t = "completed") {
|
|
|
2252
2267
|
}
|
|
2253
2268
|
};
|
|
2254
2269
|
}
|
|
2255
|
-
function
|
|
2270
|
+
function vn(e) {
|
|
2256
2271
|
return e instanceof Error ? e : new Q(String(e));
|
|
2257
2272
|
}
|
|
2258
|
-
function
|
|
2273
|
+
function yn(e) {
|
|
2259
2274
|
return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
|
|
2260
2275
|
}
|
|
2261
|
-
var
|
|
2276
|
+
var bn = class {
|
|
2262
2277
|
id;
|
|
2263
2278
|
characterId;
|
|
2264
2279
|
result;
|
|
@@ -2287,29 +2302,29 @@ var yn = class {
|
|
|
2287
2302
|
queue: e.queue,
|
|
2288
2303
|
...e.transcript === void 0 ? {} : { transcript: e.transcript }
|
|
2289
2304
|
}).catch((e) => {
|
|
2290
|
-
throw this.fail(
|
|
2305
|
+
throw this.fail(vn(e)), vn(e);
|
|
2291
2306
|
}), this.signal?.addEventListener("abort", () => {
|
|
2292
2307
|
this.cancel();
|
|
2293
2308
|
}, { once: !0 });
|
|
2294
2309
|
}
|
|
2295
2310
|
async write(e, t) {
|
|
2296
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2297
|
-
let n =
|
|
2311
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new Yt();
|
|
2312
|
+
let n = nn(e);
|
|
2298
2313
|
if (n.byteLength & 1) throw new Q("PCM chunk byte length must be even (complete s16 samples).");
|
|
2299
|
-
if (n.byteLength >
|
|
2314
|
+
if (n.byteLength > qt.MAX_CHUNK_BYTES) throw new Q(`PCM chunk exceeds MAX_CHUNK_BYTES (${qt.MAX_CHUNK_BYTES}).`);
|
|
2300
2315
|
if (n.byteLength === 0) return;
|
|
2301
|
-
let r = t?.timeoutMs ??
|
|
2316
|
+
let r = t?.timeoutMs ?? qt.DEFAULT_WRITE_TIMEOUT_MS;
|
|
2302
2317
|
await this.acquireWriteSlot(r);
|
|
2303
2318
|
let i = n.byteLength / 2 / this.sampleRate * 1e3;
|
|
2304
|
-
if (this.bufferedMs + i >
|
|
2319
|
+
if (this.bufferedMs + i > qt.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new Q("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
|
|
2305
2320
|
let a = async () => {
|
|
2306
|
-
if (this.closed || this.settled) throw new
|
|
2321
|
+
if (this.closed || this.settled) throw new Yt();
|
|
2307
2322
|
let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
|
|
2308
2323
|
utteranceId: this.id,
|
|
2309
2324
|
audio: t.buffer,
|
|
2310
2325
|
byteLength: t.byteLength
|
|
2311
2326
|
}), a = await Promise.race([i, new Promise((e, t) => {
|
|
2312
|
-
setTimeout(() => t(new
|
|
2327
|
+
setTimeout(() => t(new Xt()), r);
|
|
2313
2328
|
})]);
|
|
2314
2329
|
this.bufferedMs = Math.max(0, a.bufferedMs);
|
|
2315
2330
|
}, o = this.writeChain.then(a, a);
|
|
@@ -2321,7 +2336,7 @@ var yn = class {
|
|
|
2321
2336
|
}
|
|
2322
2337
|
}
|
|
2323
2338
|
async setTranscript(e) {
|
|
2324
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
2339
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new Yt();
|
|
2325
2340
|
await this.requireHost().speechUtteranceSetTranscript({
|
|
2326
2341
|
utteranceId: this.id,
|
|
2327
2342
|
transcript: e
|
|
@@ -2338,7 +2353,7 @@ var yn = class {
|
|
|
2338
2353
|
});
|
|
2339
2354
|
return this.resolve(t), t;
|
|
2340
2355
|
} catch (e) {
|
|
2341
|
-
let t =
|
|
2356
|
+
let t = vn(e);
|
|
2342
2357
|
throw this.fail(t), t;
|
|
2343
2358
|
}
|
|
2344
2359
|
}
|
|
@@ -2356,11 +2371,11 @@ var yn = class {
|
|
|
2356
2371
|
characterId: this.characterId,
|
|
2357
2372
|
status: "cancelled",
|
|
2358
2373
|
durationMs: 0,
|
|
2359
|
-
animation:
|
|
2374
|
+
animation: Zt("none")
|
|
2360
2375
|
};
|
|
2361
2376
|
return this.resolve(t), t;
|
|
2362
2377
|
} catch (e) {
|
|
2363
|
-
let t =
|
|
2378
|
+
let t = vn(e);
|
|
2364
2379
|
throw this.fail(t), t;
|
|
2365
2380
|
}
|
|
2366
2381
|
}
|
|
@@ -2373,19 +2388,19 @@ var yn = class {
|
|
|
2373
2388
|
return e;
|
|
2374
2389
|
}
|
|
2375
2390
|
resolve(e) {
|
|
2376
|
-
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new
|
|
2391
|
+
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new Yt()));
|
|
2377
2392
|
}
|
|
2378
2393
|
fail(e) {
|
|
2379
2394
|
this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
|
|
2380
2395
|
}
|
|
2381
2396
|
async acquireWriteSlot(e) {
|
|
2382
|
-
if (this.pendingWriteCount <
|
|
2397
|
+
if (this.pendingWriteCount < qt.MAX_PENDING_WRITES) {
|
|
2383
2398
|
this.pendingWriteCount += 1;
|
|
2384
2399
|
return;
|
|
2385
2400
|
}
|
|
2386
2401
|
await new Promise((t, n) => {
|
|
2387
2402
|
let r = setTimeout(() => {
|
|
2388
|
-
n(new
|
|
2403
|
+
n(new Xt());
|
|
2389
2404
|
}, e);
|
|
2390
2405
|
this.pendingWriteWaiters.push({
|
|
2391
2406
|
resolve: () => {
|
|
@@ -2404,13 +2419,13 @@ var yn = class {
|
|
|
2404
2419
|
for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
|
|
2405
2420
|
}
|
|
2406
2421
|
};
|
|
2407
|
-
function
|
|
2422
|
+
function xn(e) {
|
|
2408
2423
|
let t = null, n = (t, n) => {
|
|
2409
|
-
if (!e.getCapabilities()[n]) throw new
|
|
2424
|
+
if (!e.getCapabilities()[n]) throw new Jt(t, n);
|
|
2410
2425
|
}, r = {
|
|
2411
2426
|
async speak(r) {
|
|
2412
2427
|
if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
|
|
2413
|
-
let i =
|
|
2428
|
+
let i = rn(r.queue ?? "append");
|
|
2414
2429
|
i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
|
|
2415
2430
|
let a = e.getIframeHost();
|
|
2416
2431
|
if (!a) throw new Q("Speech session is not attached.");
|
|
@@ -2430,41 +2445,41 @@ function bn(e) {
|
|
|
2430
2445
|
return;
|
|
2431
2446
|
}
|
|
2432
2447
|
t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
|
|
2433
|
-
t.removeEventListener("abort", s), n(
|
|
2448
|
+
t.removeEventListener("abort", s), n(_n(e, "completed"));
|
|
2434
2449
|
}, (a) => {
|
|
2435
|
-
if (t.removeEventListener("abort", s),
|
|
2450
|
+
if (t.removeEventListener("abort", s), yn(a)) {
|
|
2436
2451
|
n({
|
|
2437
2452
|
utteranceId: "utt_interrupted",
|
|
2438
2453
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2439
2454
|
status: "interrupted",
|
|
2440
2455
|
durationMs: 0,
|
|
2441
2456
|
transcript: r.text,
|
|
2442
|
-
animation:
|
|
2457
|
+
animation: Zt("none")
|
|
2443
2458
|
});
|
|
2444
2459
|
return;
|
|
2445
2460
|
}
|
|
2446
|
-
i(
|
|
2461
|
+
i(vn(a));
|
|
2447
2462
|
});
|
|
2448
2463
|
});
|
|
2449
2464
|
}
|
|
2450
2465
|
try {
|
|
2451
|
-
return
|
|
2466
|
+
return _n(await o, "completed");
|
|
2452
2467
|
} catch (t) {
|
|
2453
|
-
if (
|
|
2468
|
+
if (yn(t)) return {
|
|
2454
2469
|
utteranceId: "utt_interrupted",
|
|
2455
2470
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2456
2471
|
status: "interrupted",
|
|
2457
2472
|
durationMs: 0,
|
|
2458
2473
|
transcript: r.text,
|
|
2459
|
-
animation:
|
|
2474
|
+
animation: Zt("none")
|
|
2460
2475
|
};
|
|
2461
|
-
throw
|
|
2476
|
+
throw vn(t);
|
|
2462
2477
|
}
|
|
2463
2478
|
},
|
|
2464
2479
|
async play(i) {
|
|
2465
|
-
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"),
|
|
2480
|
+
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), en(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
2466
2481
|
let a = i.queue ?? "append";
|
|
2467
|
-
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)),
|
|
2482
|
+
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), Wt(i.audio)) {
|
|
2468
2483
|
let e = i.audio.sampleRate ?? 24e3;
|
|
2469
2484
|
return r.createUtterance({
|
|
2470
2485
|
format: {
|
|
@@ -2480,7 +2495,7 @@ function bn(e) {
|
|
|
2480
2495
|
}
|
|
2481
2496
|
let o = e.getIframeHost();
|
|
2482
2497
|
if (!o) throw new Q("Speech session is not attached.");
|
|
2483
|
-
let s = await
|
|
2498
|
+
let s = await hn(i.audio, i.signal);
|
|
2484
2499
|
return o.speechPlay({
|
|
2485
2500
|
source: s,
|
|
2486
2501
|
characterId: i.characterId,
|
|
@@ -2492,13 +2507,13 @@ function bn(e) {
|
|
|
2492
2507
|
},
|
|
2493
2508
|
createUtterance(r) {
|
|
2494
2509
|
e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
|
|
2495
|
-
let i =
|
|
2510
|
+
let i = tn(r);
|
|
2496
2511
|
if (r.track && r.track.kind !== "audio") throw new Q("createUtterance track must be an audio MediaStreamTrack.");
|
|
2497
2512
|
let a = r.queue ?? "replace-active";
|
|
2498
2513
|
if (a !== "replace-active" && a !== "replace-all") throw new Q("createUtterance queue must be replace-active or replace-all.");
|
|
2499
2514
|
e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
|
|
2500
|
-
let o = new
|
|
2501
|
-
id:
|
|
2515
|
+
let o = new bn({
|
|
2516
|
+
id: gn(),
|
|
2502
2517
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
2503
2518
|
format: i,
|
|
2504
2519
|
queue: a,
|
|
@@ -2510,7 +2525,7 @@ function bn(e) {
|
|
|
2510
2525
|
t === o && (t = null);
|
|
2511
2526
|
}), r.track && (async () => {
|
|
2512
2527
|
try {
|
|
2513
|
-
if (await
|
|
2528
|
+
if (await mn({
|
|
2514
2529
|
track: r.track,
|
|
2515
2530
|
utterance: o,
|
|
2516
2531
|
sampleRate: i.sampleRate,
|
|
@@ -2538,16 +2553,16 @@ function bn(e) {
|
|
|
2538
2553
|
}
|
|
2539
2554
|
//#endregion
|
|
2540
2555
|
//#region src/v2/types/sessionInteraction.ts
|
|
2541
|
-
function
|
|
2556
|
+
function Sn(e) {
|
|
2542
2557
|
let t = e?.trim();
|
|
2543
2558
|
return t === "full" || t === "face" || t === "medium" ? t : void 0;
|
|
2544
2559
|
}
|
|
2545
2560
|
//#endregion
|
|
2546
2561
|
//#region src/v2/experience.ts
|
|
2547
|
-
function
|
|
2562
|
+
function Cn(e) {
|
|
2548
2563
|
return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
|
|
2549
2564
|
}
|
|
2550
|
-
var
|
|
2565
|
+
var wn = class e {
|
|
2551
2566
|
bootstrap;
|
|
2552
2567
|
conversationProcessor;
|
|
2553
2568
|
iframeHost = null;
|
|
@@ -2564,19 +2579,20 @@ var Cn = class e {
|
|
|
2564
2579
|
pendingStage = null;
|
|
2565
2580
|
pendingPipBackground = null;
|
|
2566
2581
|
pendingPipShadow = null;
|
|
2582
|
+
pendingTheatre = null;
|
|
2567
2583
|
lastInteraction = null;
|
|
2568
2584
|
closeHandlers = [];
|
|
2569
|
-
eventRegistry =
|
|
2585
|
+
eventRegistry = Rt();
|
|
2570
2586
|
readyEnvelope = null;
|
|
2571
2587
|
startedEnvelope = null;
|
|
2572
2588
|
sessionMintedEnvelope = null;
|
|
2573
2589
|
conversationCache = [];
|
|
2574
2590
|
speech;
|
|
2575
2591
|
constructor(e) {
|
|
2576
|
-
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 =
|
|
2592
|
+
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 = xn({
|
|
2577
2593
|
getIframeHost: () => this.iframeHost,
|
|
2578
2594
|
assertSessionStarted: () => this.assertSessionStarted(),
|
|
2579
|
-
getCapabilities: () =>
|
|
2595
|
+
getCapabilities: () => Tn(this.resolvedSession),
|
|
2580
2596
|
getActiveCharacterId: () => "character_unknown",
|
|
2581
2597
|
onProcessorInterrupt: () => {
|
|
2582
2598
|
this.processorAbortController?.abort(), this.processorAbortController = null;
|
|
@@ -2659,7 +2675,7 @@ var Cn = class e {
|
|
|
2659
2675
|
return null;
|
|
2660
2676
|
}
|
|
2661
2677
|
on(e, t) {
|
|
2662
|
-
let n =
|
|
2678
|
+
let n = zt(this.eventRegistry, e, t);
|
|
2663
2679
|
return e === "ready" && this.readyEnvelope && queueMicrotask(() => t(this.readyEnvelope)), e === "started" && this.startedEnvelope && queueMicrotask(() => t(this.startedEnvelope)), e === "sessionMinted" && this.sessionMintedEnvelope && queueMicrotask(() => t(this.sessionMintedEnvelope)), n;
|
|
2664
2680
|
}
|
|
2665
2681
|
async attach(e) {
|
|
@@ -2673,13 +2689,13 @@ var Cn = class e {
|
|
|
2673
2689
|
if (this.closed) throw Error("Session has ended.");
|
|
2674
2690
|
if (this.attached && this.iframeHost) return this.createPlayerFacade();
|
|
2675
2691
|
this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
|
|
2676
|
-
let t = this.bootstrap.embedBaseUrl ??
|
|
2692
|
+
let t = this.bootstrap.embedBaseUrl ?? jt(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = Nt(t, n, r ? void 0 : Mt(this.bootstrap.backdropId, this.bootstrap.locationId), r ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, Cn(e), this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.castSize, e.stage, e.pipBackground, e.pipShadow), a = Ft(i), o = null, s = new Promise((e) => {
|
|
2677
2693
|
o = e;
|
|
2678
2694
|
}), c = null, l = new Promise((e) => {
|
|
2679
2695
|
c = e;
|
|
2680
|
-
}), u =
|
|
2696
|
+
}), u = Et((e) => {
|
|
2681
2697
|
this.readyEnvelope ||= (this.resolvedSession = e, this.emitWrapped("ready", { session: e }));
|
|
2682
|
-
}), d = this.bootstrap.onUserTranscript, f =
|
|
2698
|
+
}), d = this.bootstrap.onUserTranscript, f = Tt({
|
|
2683
2699
|
container: e.container,
|
|
2684
2700
|
src: i,
|
|
2685
2701
|
playerOrigin: a,
|
|
@@ -2742,7 +2758,8 @@ var Cn = class e {
|
|
|
2742
2758
|
onWidgetAudioSettings: (t) => e.onWidgetAudioSettings?.(t),
|
|
2743
2759
|
onWidgetDragStart: (t) => e.onWidgetDragStart?.(t),
|
|
2744
2760
|
onWidgetDragMove: (t) => e.onWidgetDragMove?.(t),
|
|
2745
|
-
onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t)
|
|
2761
|
+
onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t),
|
|
2762
|
+
onTheatreChange: (t) => e.onTheatreChange?.(t)
|
|
2746
2763
|
});
|
|
2747
2764
|
this.iframeHost = f;
|
|
2748
2765
|
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), nt(this.bootstrap.sessionEndpoint, {
|
|
@@ -2781,7 +2798,7 @@ var Cn = class e {
|
|
|
2781
2798
|
operation: "attach",
|
|
2782
2799
|
message: e instanceof Error ? e.message : String(e),
|
|
2783
2800
|
stack: e instanceof Error ? e.stack : void 0,
|
|
2784
|
-
release:
|
|
2801
|
+
release: Dt
|
|
2785
2802
|
});
|
|
2786
2803
|
} catch {}
|
|
2787
2804
|
throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), e;
|
|
@@ -2797,12 +2814,16 @@ var Cn = class e {
|
|
|
2797
2814
|
startButton: e.startButton,
|
|
2798
2815
|
theme: e.theme,
|
|
2799
2816
|
showFeedback: e.showFeedback,
|
|
2800
|
-
interaction: e.interaction
|
|
2817
|
+
interaction: e.interaction,
|
|
2818
|
+
...e.theatreButton ? { theatreButton: !0 } : {},
|
|
2819
|
+
...e.theatre === void 0 ? {} : { theatre: e.theatre }
|
|
2801
2820
|
}), u.setValue(_)) : f.postLaunch(g, void 0, {
|
|
2802
2821
|
startButton: e.startButton,
|
|
2803
2822
|
theme: e.theme,
|
|
2804
2823
|
showFeedback: e.showFeedback,
|
|
2805
|
-
interaction: e.interaction
|
|
2824
|
+
interaction: e.interaction,
|
|
2825
|
+
...e.theatreButton ? { theatreButton: !0 } : {},
|
|
2826
|
+
...e.theatre === void 0 ? {} : { theatre: e.theatre }
|
|
2806
2827
|
}), await Promise.race([s, new Promise((e, t) => {
|
|
2807
2828
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player loading UI.")), 12e4);
|
|
2808
2829
|
})]).catch((e) => {
|
|
@@ -2813,7 +2834,7 @@ var Cn = class e {
|
|
|
2813
2834
|
operation: "attach",
|
|
2814
2835
|
message: e instanceof Error ? e.message : String(e),
|
|
2815
2836
|
stack: e instanceof Error ? e.stack : void 0,
|
|
2816
|
-
release:
|
|
2837
|
+
release: Dt
|
|
2817
2838
|
});
|
|
2818
2839
|
} catch {}
|
|
2819
2840
|
throw e;
|
|
@@ -2827,11 +2848,11 @@ var Cn = class e {
|
|
|
2827
2848
|
operation: "attach",
|
|
2828
2849
|
message: e instanceof Error ? e.message : String(e),
|
|
2829
2850
|
stack: e instanceof Error ? e.stack : void 0,
|
|
2830
|
-
release:
|
|
2851
|
+
release: Dt
|
|
2831
2852
|
});
|
|
2832
2853
|
} catch {}
|
|
2833
2854
|
throw e;
|
|
2834
|
-
}), this.attached = !0, this.pendingFit && await f.setFit(this.pendingFit), this.pendingStage && await f.setStage(this.pendingStage), this.pendingPipBackground && await f.setPipBackground(this.pendingPipBackground), this.pendingPipShadow !== null && await f.setPipShadow(this.pendingPipShadow), this.createPlayerFacade();
|
|
2855
|
+
}), this.attached = !0, this.pendingFit && await f.setFit(this.pendingFit), this.pendingStage && await f.setStage(this.pendingStage), this.pendingPipBackground && await f.setPipBackground(this.pendingPipBackground), this.pendingPipShadow !== null && await f.setPipShadow(this.pendingPipShadow), this.pendingTheatre !== null && f.postSetTheatre(this.pendingTheatre), this.createPlayerFacade();
|
|
2835
2856
|
}
|
|
2836
2857
|
async startListening() {
|
|
2837
2858
|
this.assertSessionStarted(), await this.iframeHost.startListening();
|
|
@@ -2845,6 +2866,10 @@ var Cn = class e {
|
|
|
2845
2866
|
getConversation() {
|
|
2846
2867
|
return this.conversationCache;
|
|
2847
2868
|
}
|
|
2869
|
+
setTheatre(e) {
|
|
2870
|
+
if (this.closed) throw Error("Session has ended.");
|
|
2871
|
+
this.pendingTheatre = e, this.iframeHost?.postSetTheatre(e);
|
|
2872
|
+
}
|
|
2848
2873
|
setWidgetChrome(e) {
|
|
2849
2874
|
this.iframeHost?.postWidgetSetChrome(e);
|
|
2850
2875
|
}
|
|
@@ -2855,7 +2880,7 @@ var Cn = class e {
|
|
|
2855
2880
|
this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
|
|
2856
2881
|
}
|
|
2857
2882
|
async setFit(e) {
|
|
2858
|
-
let t =
|
|
2883
|
+
let t = Sn(e);
|
|
2859
2884
|
if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
|
|
2860
2885
|
if (this.closed) throw Error("Session has ended.");
|
|
2861
2886
|
this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
|
|
@@ -2905,7 +2930,7 @@ var Cn = class e {
|
|
|
2905
2930
|
this.close();
|
|
2906
2931
|
}
|
|
2907
2932
|
destroy() {
|
|
2908
|
-
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,
|
|
2933
|
+
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, Vt(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.lastInteraction = null, this.attached = !1);
|
|
2909
2934
|
}
|
|
2910
2935
|
resolveMintInteraction() {
|
|
2911
2936
|
return this.bootstrap.kind === "launch" ? {} : {
|
|
@@ -2917,8 +2942,8 @@ var Cn = class e {
|
|
|
2917
2942
|
return this.resolvedSession?.id ?? "";
|
|
2918
2943
|
}
|
|
2919
2944
|
emitWrapped(e, t) {
|
|
2920
|
-
let n =
|
|
2921
|
-
return
|
|
2945
|
+
let n = Lt(e, this.getSessionId(), t);
|
|
2946
|
+
return Bt(this.eventRegistry, e, n), n;
|
|
2922
2947
|
}
|
|
2923
2948
|
queueProcessorTurn(e) {
|
|
2924
2949
|
if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
|
|
@@ -2977,7 +3002,7 @@ var Cn = class e {
|
|
|
2977
3002
|
};
|
|
2978
3003
|
}
|
|
2979
3004
|
};
|
|
2980
|
-
function
|
|
3005
|
+
function Tn(e) {
|
|
2981
3006
|
return e ? {
|
|
2982
3007
|
textSpeech: e.capabilities.speech.output,
|
|
2983
3008
|
externalSpeechAudio: e.capabilities.speech.externalAudio
|
|
@@ -2988,41 +3013,41 @@ function wn(e) {
|
|
|
2988
3013
|
}
|
|
2989
3014
|
//#endregion
|
|
2990
3015
|
//#region src/widget/dockGeometry.ts
|
|
2991
|
-
var
|
|
2992
|
-
function
|
|
3016
|
+
var En = "(min-width: 768px)", Dn = 24, On = .5, kn = 1200, An = .85, jn = 9 / 16;
|
|
3017
|
+
function Mn() {
|
|
2993
3018
|
if (typeof window > "u") return 800;
|
|
2994
3019
|
let e = window.screen?.availHeight;
|
|
2995
3020
|
return typeof e == "number" && e > 0 ? e : window.innerHeight;
|
|
2996
3021
|
}
|
|
2997
|
-
function
|
|
2998
|
-
let i = Math.max(160, Math.min(t - n * 2, t *
|
|
2999
|
-
return s > a && (s = a, o = s /
|
|
3022
|
+
function Nn(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = Dn, r = typeof window < "u" ? Mn() : 800) {
|
|
3023
|
+
let i = Math.max(160, Math.min(t - n * 2, t * An)), a = Math.max(120, e - n * 2), o = Math.min(r * On, kn, i), s = o * jn;
|
|
3024
|
+
return s > a && (s = a, o = s / jn, o > i && (o = i, s = o * jn)), {
|
|
3000
3025
|
width: Math.round(s),
|
|
3001
3026
|
height: Math.round(o)
|
|
3002
3027
|
};
|
|
3003
3028
|
}
|
|
3004
|
-
function
|
|
3029
|
+
function Pn(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = Dn) {
|
|
3005
3030
|
return {
|
|
3006
3031
|
left: Math.max(r, t - e.width - r),
|
|
3007
3032
|
top: Math.max(r, n - e.height - r)
|
|
3008
3033
|
};
|
|
3009
3034
|
}
|
|
3010
|
-
function
|
|
3035
|
+
function Fn(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = Dn) {
|
|
3011
3036
|
let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
|
|
3012
3037
|
return {
|
|
3013
3038
|
left: Math.min(Math.max(a, e), o),
|
|
3014
3039
|
top: Math.min(Math.max(a, t), s)
|
|
3015
3040
|
};
|
|
3016
3041
|
}
|
|
3017
|
-
function
|
|
3018
|
-
return e(
|
|
3042
|
+
function In(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
|
|
3043
|
+
return e(En).matches;
|
|
3019
3044
|
}
|
|
3020
3045
|
//#endregion
|
|
3021
3046
|
//#region src/widget/mountExperienceWidget.ts
|
|
3022
|
-
function
|
|
3047
|
+
function Ln(e) {
|
|
3023
3048
|
return e === "bottom-right" || e === "bottom-left" ? e : "static";
|
|
3024
3049
|
}
|
|
3025
|
-
function
|
|
3050
|
+
function Rn(e) {
|
|
3026
3051
|
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
3027
3052
|
let t = typeof e == "string" ? e.trim() : "";
|
|
3028
3053
|
return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
|
|
@@ -3030,10 +3055,10 @@ function Ln(e) {
|
|
|
3030
3055
|
function $(e) {
|
|
3031
3056
|
return e === "expanded" || e === "docked";
|
|
3032
3057
|
}
|
|
3033
|
-
var
|
|
3034
|
-
function
|
|
3058
|
+
var zn = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"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>", Bn = "<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>", Vn = "<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>", Hn = "<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>";
|
|
3059
|
+
function Un(e, t, n) {
|
|
3035
3060
|
Se(be);
|
|
3036
|
-
let r =
|
|
3061
|
+
let r = P({
|
|
3037
3062
|
galleryThumb: t.galleryThumb,
|
|
3038
3063
|
avatarImage: t.avatarImage,
|
|
3039
3064
|
backgroundImage: t.backgroundImage,
|
|
@@ -3061,7 +3086,7 @@ function Hn(e, t, n) {
|
|
|
3061
3086
|
}
|
|
3062
3087
|
return e.replaceChildren(i), n?.parallax === !1 ? () => {} : ye(i);
|
|
3063
3088
|
}
|
|
3064
|
-
function
|
|
3089
|
+
function Wn(e) {
|
|
3065
3090
|
return e.startButton ? {
|
|
3066
3091
|
...e.startButton,
|
|
3067
3092
|
label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
|
|
@@ -3073,7 +3098,7 @@ function Un(e) {
|
|
|
3073
3098
|
variant: "primary"
|
|
3074
3099
|
};
|
|
3075
3100
|
}
|
|
3076
|
-
function
|
|
3101
|
+
function Gn(e) {
|
|
3077
3102
|
let t = !1, n = () => {
|
|
3078
3103
|
t || e();
|
|
3079
3104
|
}, r = () => {
|
|
@@ -3093,12 +3118,12 @@ function Wn(e) {
|
|
|
3093
3118
|
t = !0, window.removeEventListener("load", r), i?.();
|
|
3094
3119
|
};
|
|
3095
3120
|
}
|
|
3096
|
-
function
|
|
3121
|
+
function Kn(e, t) {
|
|
3097
3122
|
De(Te);
|
|
3098
3123
|
let n = t.experienceId?.trim();
|
|
3099
3124
|
if (!n) throw Error("ExperienceWidget requires experienceId.");
|
|
3100
|
-
let r = t.prefetch ?? "onExpand", i =
|
|
3101
|
-
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",
|
|
3125
|
+
let r = t.prefetch ?? "onExpand", i = Ln(t.position), a = document.createElement("div");
|
|
3126
|
+
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", Rn(t.offset));
|
|
3102
3127
|
let o = document.createElement("button");
|
|
3103
3128
|
o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
|
|
3104
3129
|
let s = document.createElement("div");
|
|
@@ -3118,74 +3143,74 @@ function Gn(e, t) {
|
|
|
3118
3143
|
let m = document.createElement("span");
|
|
3119
3144
|
m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
|
|
3120
3145
|
let h = document.createElement("button");
|
|
3121
|
-
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML =
|
|
3146
|
+
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = Vn, h.setAttribute("aria-label", "Reduce");
|
|
3122
3147
|
let g = document.createElement("button");
|
|
3123
|
-
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML =
|
|
3148
|
+
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = zn, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
|
|
3124
3149
|
let _ = document.createElement("button");
|
|
3125
|
-
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML =
|
|
3150
|
+
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = Bn, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
|
|
3126
3151
|
let v = document.createElement("div");
|
|
3127
3152
|
v.className = "liforma-ew__stage";
|
|
3128
3153
|
let y = document.createElement("div");
|
|
3129
3154
|
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);
|
|
3130
|
-
let b = null, x = !1, S = !1, C = !1, w = !1, T = !1, E = !1, D = !1, O = 0, k = "", A = null, j = null,
|
|
3155
|
+
let b = null, x = !1, S = !1, C = !1, w = !1, T = !1, E = !1, D = !1, O = 0, k = "", A = null, j = null, ee = null, te = null, M = null, N = null, P = null, ne = 0, F = 0, I = null, re = !1, ie = new AbortController(), ae = t.parallax !== !1, L = () => {
|
|
3131
3156
|
let e = a.dataset.state;
|
|
3132
3157
|
return e === "expanded" || e === "docked" || e === "collapsed" ? e : "collapsed";
|
|
3158
|
+
}, R = () => {
|
|
3159
|
+
ee !== null && (clearTimeout(ee), ee = null);
|
|
3133
3160
|
}, z = () => {
|
|
3134
|
-
|
|
3135
|
-
},
|
|
3136
|
-
ee !== null && (clearTimeout(ee), ee = null), a.classList.remove("liforma-ew--layout-settling");
|
|
3137
|
-
}, ae = () => {
|
|
3161
|
+
te !== null && (clearTimeout(te), te = null), a.classList.remove("liforma-ew--layout-settling");
|
|
3162
|
+
}, oe = () => {
|
|
3138
3163
|
for (let e of [
|
|
3139
3164
|
f,
|
|
3140
3165
|
l,
|
|
3141
3166
|
p
|
|
3142
3167
|
]) e.style.removeProperty("left"), e.style.removeProperty("top"), e.style.removeProperty("width"), e.style.removeProperty("height"), e.style.removeProperty("right"), e.style.removeProperty("bottom");
|
|
3143
3168
|
p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging");
|
|
3144
|
-
},
|
|
3169
|
+
}, se = (e, t, n, r) => {
|
|
3145
3170
|
let i = (i) => {
|
|
3146
3171
|
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";
|
|
3147
3172
|
};
|
|
3148
3173
|
i(f), i(l);
|
|
3149
3174
|
let a = p.offsetWidth || 120;
|
|
3150
3175
|
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";
|
|
3151
|
-
}, se = (e, t) => {
|
|
3152
|
-
if (R() !== "docked") return;
|
|
3153
|
-
let n = Mn(), r = Pn(e - te, t - I, n);
|
|
3154
|
-
N = r.left, P = r.top, oe(r.left, r.top, n.width, n.height);
|
|
3155
3176
|
}, ce = (e, t) => {
|
|
3156
|
-
if (
|
|
3157
|
-
let n =
|
|
3158
|
-
|
|
3159
|
-
}, le = (e) => {
|
|
3160
|
-
L
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
},
|
|
3166
|
-
if (
|
|
3167
|
-
|
|
3177
|
+
if (L() !== "docked") return;
|
|
3178
|
+
let n = Nn(), r = Fn(e - ne, t - F, n);
|
|
3179
|
+
M = r.left, N = r.top, se(r.left, r.top, n.width, n.height);
|
|
3180
|
+
}, le = (e, t) => {
|
|
3181
|
+
if (L() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
|
|
3182
|
+
let n = Nn(), r = M ?? f.getBoundingClientRect().left, i = N ?? f.getBoundingClientRect().top, a = Fn(r + e, i + t, n);
|
|
3183
|
+
M = a.left, N = a.top, se(a.left, a.top, n.width, n.height);
|
|
3184
|
+
}, ue = (e) => {
|
|
3185
|
+
I === "toolbar" && (P === null || e.pointerId !== P || (e.preventDefault(), ce(e.clientX, e.clientY)));
|
|
3186
|
+
}, B = (e) => {
|
|
3187
|
+
if (P === null || e && e.pointerId !== P) return;
|
|
3188
|
+
let t = I;
|
|
3189
|
+
P = null, I = null, p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging"), t === "toolbar" && re && (re = !1, window.removeEventListener("pointermove", ue), window.removeEventListener("pointerup", B), window.removeEventListener("pointercancel", B));
|
|
3190
|
+
}, de = (e, t, n) => {
|
|
3191
|
+
if (S || L() !== "docked" || !In() || P !== null) return;
|
|
3192
|
+
P = n, I = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
3168
3193
|
let r = f.getBoundingClientRect();
|
|
3169
|
-
|
|
3170
|
-
}, de = (e) => {
|
|
3171
|
-
if (S || R() !== "docked" || !Fn() || F !== null) return;
|
|
3172
|
-
F = e.pointerId, L = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
3173
|
-
let t = f.getBoundingClientRect();
|
|
3174
|
-
N = t.left, P = t.top;
|
|
3194
|
+
ne = e - r.left, F = t - r.top, re || (re = !0, window.addEventListener("pointermove", ue), window.addEventListener("pointerup", B), window.addEventListener("pointercancel", B));
|
|
3175
3195
|
}, fe = (e) => {
|
|
3176
|
-
L
|
|
3196
|
+
if (S || L() !== "docked" || !In() || P !== null) return;
|
|
3197
|
+
P = e.pointerId, I = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
3198
|
+
let t = f.getBoundingClientRect();
|
|
3199
|
+
M = t.left, N = t.top;
|
|
3177
3200
|
}, pe = (e) => {
|
|
3178
|
-
|
|
3179
|
-
},
|
|
3180
|
-
|
|
3201
|
+
I === "player" && (P === null || e.pointerId !== P || le(e.dx, e.dy));
|
|
3202
|
+
}, me = (e) => {
|
|
3203
|
+
I === "player" && (P === null || e.pointerId !== P || B());
|
|
3204
|
+
}, V = () => {
|
|
3205
|
+
let e = In(), t = L();
|
|
3181
3206
|
if (!e || t !== "expanded" && t !== "docked") {
|
|
3182
3207
|
h.hidden = !0;
|
|
3183
3208
|
return;
|
|
3184
3209
|
}
|
|
3185
|
-
h.hidden = !1, t === "docked" ? (h.innerHTML =
|
|
3186
|
-
},
|
|
3187
|
-
let t =
|
|
3188
|
-
n =
|
|
3210
|
+
h.hidden = !1, t === "docked" ? (h.innerHTML = Hn, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = Vn, h.setAttribute("aria-label", "Reduce"));
|
|
3211
|
+
}, H = (e) => {
|
|
3212
|
+
let t = Nn(), n = e && M !== null && N !== null ? Fn(M, N, t) : Pn(t);
|
|
3213
|
+
n = Fn(n.left, n.top, t), M = n.left, N = n.top, se(n.left, n.top, t.width, t.height), V();
|
|
3189
3214
|
}, U = () => {
|
|
3190
3215
|
a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
|
|
3191
3216
|
requestAnimationFrame(() => {
|
|
@@ -3193,20 +3218,20 @@ function Gn(e, t) {
|
|
|
3193
3218
|
});
|
|
3194
3219
|
});
|
|
3195
3220
|
}, W = (e) => {
|
|
3196
|
-
if (
|
|
3221
|
+
if (z(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !D) {
|
|
3197
3222
|
a.classList.remove("liforma-ew--layout-settling");
|
|
3198
3223
|
return;
|
|
3199
3224
|
}
|
|
3200
|
-
|
|
3201
|
-
if (
|
|
3225
|
+
te = setTimeout(() => {
|
|
3226
|
+
if (te = null, S || !$(a.dataset.state)) {
|
|
3202
3227
|
a.classList.remove("liforma-ew--layout-settling");
|
|
3203
3228
|
return;
|
|
3204
3229
|
}
|
|
3205
3230
|
a.classList.remove("liforma-ew--layout-settling"), U();
|
|
3206
3231
|
}, 220);
|
|
3207
3232
|
}, he = () => (a.classList.add("liforma-ew--session-concealing"), a.classList.remove("liforma-ew--session-revealed"), new Promise((e) => {
|
|
3208
|
-
|
|
3209
|
-
|
|
3233
|
+
R(), ee = setTimeout(() => {
|
|
3234
|
+
ee = null, a.classList.remove("liforma-ew--session-concealing"), e();
|
|
3210
3235
|
}, 280);
|
|
3211
3236
|
})), ge = {
|
|
3212
3237
|
galleryThumb: t.galleryThumb,
|
|
@@ -3232,20 +3257,20 @@ function Gn(e, t) {
|
|
|
3232
3257
|
w = !0, a.dataset.warm = "true", l.hidden = !1, D || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
|
|
3233
3258
|
}, be = (e) => {
|
|
3234
3259
|
A?.(), A = null;
|
|
3235
|
-
let t =
|
|
3260
|
+
let t = Un(s, e, { parallax: ae });
|
|
3236
3261
|
return t ? (A = t, !0) : !1;
|
|
3237
3262
|
}, xe = () => {
|
|
3238
3263
|
if (be(ge)) {
|
|
3239
3264
|
ve();
|
|
3240
3265
|
return;
|
|
3241
3266
|
}
|
|
3242
|
-
_e("Loading…"), Me(n, { signal:
|
|
3267
|
+
_e("Loading…"), Me(n, { signal: ie.signal }).then((e) => {
|
|
3243
3268
|
if (!S) {
|
|
3244
3269
|
if (!be({ galleryThumb: e.galleryThumb })) throw Error("Experience preview is missing gallery thumb images.");
|
|
3245
3270
|
ve();
|
|
3246
3271
|
}
|
|
3247
3272
|
}).catch((e) => {
|
|
3248
|
-
if (S ||
|
|
3273
|
+
if (S || ie.signal.aborted) return;
|
|
3249
3274
|
let n = e instanceof Error ? e : Error(String(e));
|
|
3250
3275
|
_e("Preview unavailable"), o.disabled = !0, t.onError?.(n), console.error("[ExperienceWidget]", n);
|
|
3251
3276
|
});
|
|
@@ -3264,13 +3289,13 @@ function Gn(e, t) {
|
|
|
3264
3289
|
...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
|
|
3265
3290
|
}), Ce = () => ({
|
|
3266
3291
|
...t.fit ? { fit: t.fit } : {},
|
|
3267
|
-
startButton:
|
|
3292
|
+
startButton: Wn(t),
|
|
3268
3293
|
...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback },
|
|
3269
3294
|
...t.interaction ? { interaction: t.interaction } : {}
|
|
3270
3295
|
}), we = (e = !0) => {
|
|
3271
|
-
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"),
|
|
3296
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), oe(), a.dataset.state = "expanded", G(null), typeof document < "u" && (k = document.body.style.overflow, document.body.style.overflow = "hidden"), V(), e && t.onExpanded?.();
|
|
3272
3297
|
}, Ee = () => {
|
|
3273
|
-
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked", G(null), typeof document < "u" && (document.body.style.overflow = k),
|
|
3298
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked", G(null), typeof document < "u" && (document.body.style.overflow = k), H(!0), V(), b?.setWidgetChrome("docked");
|
|
3274
3299
|
}, Oe = (e) => {
|
|
3275
3300
|
e.on("started", () => {
|
|
3276
3301
|
S || (D = !0, a.dataset.live = "true", G(null), t.onStarted?.(), $(a.dataset.state) && U());
|
|
@@ -3280,14 +3305,14 @@ function Gn(e, t) {
|
|
|
3280
3305
|
S || t.onFeedbackFailed?.(e);
|
|
3281
3306
|
});
|
|
3282
3307
|
}, ke = () => {
|
|
3283
|
-
|
|
3308
|
+
z(), u.hidden = !0, p.hidden = !0, oe(), 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), G(null), typeof document < "u" && (document.body.style.overflow = k), V();
|
|
3284
3309
|
}, Ae = () => {
|
|
3285
|
-
|
|
3310
|
+
R(), z(), O += 1, x = !1, w = !1, T = !1, E = !1, D = !1;
|
|
3286
3311
|
let e = b;
|
|
3287
3312
|
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");
|
|
3288
3313
|
}, K = () => {
|
|
3289
3314
|
if (!S && $(a.dataset.state)) {
|
|
3290
|
-
if (
|
|
3315
|
+
if (B(), x = !1, b && E) {
|
|
3291
3316
|
let e = b;
|
|
3292
3317
|
(async () => {
|
|
3293
3318
|
D && (await he(), S || b !== e) || (w && e.setWidgetChrome("collapsed"), ke(), D ? (a.dataset.live = "true", o.tabIndex = 0, o.removeAttribute("aria-hidden"), o.disabled = !1) : w && ye(), t.onCollapsed?.(), t.onClose?.());
|
|
@@ -3297,26 +3322,26 @@ function Gn(e, t) {
|
|
|
3297
3322
|
Ae(), ke(), t.onCollapsed?.(), t.onClose?.();
|
|
3298
3323
|
}
|
|
3299
3324
|
}, je = () => {
|
|
3300
|
-
S ||
|
|
3325
|
+
S || In() && L() === "expanded" && W(() => {
|
|
3301
3326
|
Ee();
|
|
3302
3327
|
});
|
|
3303
3328
|
}, q = () => {
|
|
3304
|
-
S ||
|
|
3305
|
-
|
|
3329
|
+
S || L() === "docked" && (B(), W(() => {
|
|
3330
|
+
oe(), we(!1), b?.setWidgetChrome("expanded");
|
|
3306
3331
|
}));
|
|
3307
3332
|
}, Ne = () => {
|
|
3308
|
-
!b || !D || (
|
|
3333
|
+
!b || !D || (R(), a.classList.remove("liforma-ew--session-revealed"), we(), b.setWidgetChrome("expanded"), x = !1, U());
|
|
3309
3334
|
}, Pe = () => {
|
|
3310
|
-
!b || !E || D || (
|
|
3335
|
+
!b || !E || D || (R(), a.classList.remove("liforma-ew--session-revealed"), we(), x = !1, w || b.setWidgetChrome("expanded"));
|
|
3311
3336
|
}, Fe = (e) => {
|
|
3312
|
-
S || e !== O && !D || (
|
|
3337
|
+
S || e !== O && !D || (R(), a.classList.remove("liforma-ew--session-revealed"), we(), x = !1, D && U());
|
|
3313
3338
|
}, Ie = () => {
|
|
3314
3339
|
if (S || T || w || b || $(a.dataset.state)) return;
|
|
3315
3340
|
T = !0;
|
|
3316
3341
|
let e = O;
|
|
3317
3342
|
l.hidden = !1, (async () => {
|
|
3318
3343
|
try {
|
|
3319
|
-
let t = await
|
|
3344
|
+
let t = await wn.startSession(Se());
|
|
3320
3345
|
if (S || e !== O) {
|
|
3321
3346
|
t.destroy();
|
|
3322
3347
|
return;
|
|
@@ -3335,13 +3360,13 @@ function Gn(e, t) {
|
|
|
3335
3360
|
S || ze(e);
|
|
3336
3361
|
},
|
|
3337
3362
|
onWidgetDragStart: (e) => {
|
|
3338
|
-
S ||
|
|
3363
|
+
S || fe(e);
|
|
3339
3364
|
},
|
|
3340
3365
|
onWidgetDragMove: (e) => {
|
|
3341
|
-
S ||
|
|
3366
|
+
S || pe(e);
|
|
3342
3367
|
},
|
|
3343
3368
|
onWidgetDragEnd: (e) => {
|
|
3344
|
-
S ||
|
|
3369
|
+
S || me(e);
|
|
3345
3370
|
},
|
|
3346
3371
|
onPlayerStatusChange: (e) => {
|
|
3347
3372
|
S || e === "error" && $(a.dataset.state) && G("Could not load the experience.");
|
|
@@ -3375,7 +3400,7 @@ function Gn(e, t) {
|
|
|
3375
3400
|
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 () => {
|
|
3376
3401
|
try {
|
|
3377
3402
|
we();
|
|
3378
|
-
let t = await
|
|
3403
|
+
let t = await wn.startSession(Se());
|
|
3379
3404
|
if (S || e !== O) {
|
|
3380
3405
|
t.destroy();
|
|
3381
3406
|
return;
|
|
@@ -3388,13 +3413,13 @@ function Gn(e, t) {
|
|
|
3388
3413
|
S || ze(e);
|
|
3389
3414
|
},
|
|
3390
3415
|
onWidgetDragStart: (e) => {
|
|
3391
|
-
S ||
|
|
3416
|
+
S || fe(e);
|
|
3392
3417
|
},
|
|
3393
3418
|
onWidgetDragMove: (e) => {
|
|
3394
|
-
S ||
|
|
3419
|
+
S || pe(e);
|
|
3395
3420
|
},
|
|
3396
3421
|
onWidgetDragEnd: (e) => {
|
|
3397
|
-
S ||
|
|
3422
|
+
S || me(e);
|
|
3398
3423
|
},
|
|
3399
3424
|
onPlayerStatusChange: (e) => {
|
|
3400
3425
|
S || (e === "error" ? G("Could not load the experience.") : $(a.dataset.state) && G(null));
|
|
@@ -3432,47 +3457,47 @@ function Gn(e, t) {
|
|
|
3432
3457
|
J();
|
|
3433
3458
|
}
|
|
3434
3459
|
}, Re = (e) => {
|
|
3435
|
-
if (e.stopPropagation(),
|
|
3460
|
+
if (e.stopPropagation(), L() === "expanded") {
|
|
3436
3461
|
je();
|
|
3437
3462
|
return;
|
|
3438
3463
|
}
|
|
3439
|
-
|
|
3464
|
+
L() === "docked" && q();
|
|
3440
3465
|
}, ze = (e) => {
|
|
3441
3466
|
g.setAttribute("aria-pressed", e ? "true" : "false");
|
|
3442
3467
|
}, Be = (e) => {
|
|
3443
3468
|
e.stopPropagation(), $(a.dataset.state) && b?.toggleAudioSettings();
|
|
3444
3469
|
}, Ve = (e) => {
|
|
3445
|
-
|
|
3470
|
+
L() === "docked" && In() && (e.target?.closest("button") || (e.preventDefault(), de(e.clientX, e.clientY, e.pointerId)));
|
|
3446
3471
|
}, Y = (e) => {
|
|
3447
3472
|
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), K());
|
|
3448
3473
|
}, X = () => {
|
|
3449
3474
|
if (!S) {
|
|
3450
|
-
if (
|
|
3451
|
-
if (!
|
|
3475
|
+
if (L() === "docked") {
|
|
3476
|
+
if (!In()) {
|
|
3452
3477
|
q();
|
|
3453
3478
|
return;
|
|
3454
3479
|
}
|
|
3455
3480
|
D ? W(() => {
|
|
3456
|
-
|
|
3457
|
-
}) :
|
|
3481
|
+
H(!0);
|
|
3482
|
+
}) : H(!0);
|
|
3458
3483
|
return;
|
|
3459
3484
|
}
|
|
3460
|
-
|
|
3485
|
+
V();
|
|
3461
3486
|
}
|
|
3462
|
-
}, He = typeof window < "u" ? window.matchMedia(
|
|
3487
|
+
}, He = typeof window < "u" ? window.matchMedia(En) : null, Ue = () => {
|
|
3463
3488
|
if (!S) {
|
|
3464
|
-
if (
|
|
3489
|
+
if (L() === "docked" && !In()) {
|
|
3465
3490
|
q();
|
|
3466
3491
|
return;
|
|
3467
3492
|
}
|
|
3468
|
-
|
|
3493
|
+
V();
|
|
3469
3494
|
}
|
|
3470
3495
|
};
|
|
3471
3496
|
return o.addEventListener("click", Le), d.addEventListener("click", K), _.addEventListener("click", (e) => {
|
|
3472
3497
|
e.stopPropagation(), K();
|
|
3473
|
-
}), h.addEventListener("click", Re), g.addEventListener("click", Be), p.addEventListener("pointerdown", Ve), window.addEventListener("keydown", Y), window.addEventListener("resize", X), He?.addEventListener("change", Ue), xe(),
|
|
3498
|
+
}), h.addEventListener("click", Re), g.addEventListener("click", Be), p.addEventListener("pointerdown", Ve), window.addEventListener("keydown", Y), window.addEventListener("resize", X), He?.addEventListener("change", Ue), xe(), V(), r === "eager" ? queueMicrotask(() => {
|
|
3474
3499
|
S || Ie();
|
|
3475
|
-
}) : r === "idle" && (j =
|
|
3500
|
+
}) : r === "idle" && (j = Gn(() => {
|
|
3476
3501
|
S || Ie();
|
|
3477
3502
|
})), {
|
|
3478
3503
|
root: a,
|
|
@@ -3488,18 +3513,18 @@ function Gn(e, t) {
|
|
|
3488
3513
|
Ie();
|
|
3489
3514
|
},
|
|
3490
3515
|
destroy() {
|
|
3491
|
-
S || (S = !0,
|
|
3516
|
+
S || (S = !0, B(), j?.(), j = null, ie.abort(), A?.(), A = null, window.removeEventListener("keydown", Y), window.removeEventListener("resize", X), He?.removeEventListener("change", Ue), Ae(), ke(), e.replaceChildren());
|
|
3492
3517
|
}
|
|
3493
3518
|
};
|
|
3494
3519
|
}
|
|
3495
3520
|
//#endregion
|
|
3496
3521
|
//#region src/react/ExperienceWidget.tsx
|
|
3497
|
-
function
|
|
3498
|
-
let r = n(null), { experienceId: i, alt: o, galleryThumb: s, avatarImage: c, backgroundImage: l, foregroundImage: u, fallbackImage: d, prefetch: f = "onExpand", parallax: p = !0, position: m = "static", offset: h, sessionEndpoint: g, locale: _, secondaryLocale: v, learningLocale: y, language: b, mode: x, speechInputMode: S, speechOnly: C, fit: w, embedBaseUrl: T, expandedMaxWidth: E, expandedMaxHeight: D, startButtonLabel: O, startButton: k, showFeedback: A, className: j = "", onExpanded:
|
|
3522
|
+
function qn(t) {
|
|
3523
|
+
let r = n(null), { experienceId: i, alt: o, galleryThumb: s, avatarImage: c, backgroundImage: l, foregroundImage: u, fallbackImage: d, prefetch: f = "onExpand", parallax: p = !0, position: m = "static", offset: h, sessionEndpoint: g, locale: _, secondaryLocale: v, learningLocale: y, language: b, mode: x, speechInputMode: S, speechOnly: C, fit: w, embedBaseUrl: T, expandedMaxWidth: E, expandedMaxHeight: D, startButtonLabel: O, startButton: k, showFeedback: A, className: j = "", onExpanded: ee, onCollapsed: te, onStarted: M, onClose: N, onError: P, onPrefetchReady: ne, onFeedback: F, onFeedbackFailed: I } = t, re = m === "bottom-right" || m === "bottom-left";
|
|
3499
3524
|
return e(() => {
|
|
3500
3525
|
let e = r.current;
|
|
3501
3526
|
if (!e || !i.trim()) return;
|
|
3502
|
-
let t =
|
|
3527
|
+
let t = Kn(e, {
|
|
3503
3528
|
experienceId: i,
|
|
3504
3529
|
alt: o,
|
|
3505
3530
|
galleryThumb: s,
|
|
@@ -3526,14 +3551,14 @@ function Kn(t) {
|
|
|
3526
3551
|
startButtonLabel: O,
|
|
3527
3552
|
startButton: k,
|
|
3528
3553
|
showFeedback: A,
|
|
3529
|
-
onFeedback:
|
|
3530
|
-
onFeedbackFailed:
|
|
3531
|
-
onExpanded:
|
|
3532
|
-
onCollapsed:
|
|
3533
|
-
onStarted:
|
|
3534
|
-
onClose:
|
|
3535
|
-
onError:
|
|
3536
|
-
onPrefetchReady:
|
|
3554
|
+
onFeedback: F,
|
|
3555
|
+
onFeedbackFailed: I,
|
|
3556
|
+
onExpanded: ee,
|
|
3557
|
+
onCollapsed: te,
|
|
3558
|
+
onStarted: M,
|
|
3559
|
+
onClose: N,
|
|
3560
|
+
onError: P,
|
|
3561
|
+
onPrefetchReady: ne
|
|
3537
3562
|
});
|
|
3538
3563
|
return () => t.destroy();
|
|
3539
3564
|
}, [
|
|
@@ -3563,18 +3588,18 @@ function Kn(t) {
|
|
|
3563
3588
|
O,
|
|
3564
3589
|
k,
|
|
3565
3590
|
A,
|
|
3591
|
+
F,
|
|
3566
3592
|
I,
|
|
3567
|
-
L,
|
|
3568
|
-
M,
|
|
3569
3593
|
ee,
|
|
3594
|
+
te,
|
|
3595
|
+
M,
|
|
3570
3596
|
N,
|
|
3571
3597
|
P,
|
|
3572
|
-
|
|
3573
|
-
te
|
|
3598
|
+
ne
|
|
3574
3599
|
]), /* @__PURE__ */ a("div", {
|
|
3575
3600
|
ref: r,
|
|
3576
3601
|
className: j,
|
|
3577
|
-
style:
|
|
3602
|
+
style: re ? { display: "contents" } : {
|
|
3578
3603
|
width: "100%",
|
|
3579
3604
|
height: "100%",
|
|
3580
3605
|
minHeight: "inherit"
|
|
@@ -3583,11 +3608,11 @@ function Kn(t) {
|
|
|
3583
3608
|
}
|
|
3584
3609
|
//#endregion
|
|
3585
3610
|
//#region src/next/index.ts
|
|
3586
|
-
function
|
|
3611
|
+
function Jn(e = {}) {
|
|
3587
3612
|
let t = v(e);
|
|
3588
3613
|
return { POST: ({ request: e }) => t(e) };
|
|
3589
3614
|
}
|
|
3590
3615
|
//#endregion
|
|
3591
|
-
export { we as ExperienceThumbnail,
|
|
3616
|
+
export { we as ExperienceThumbnail, qn as ExperienceWidget, v as createLiformaSessionRouteHandler, Jn as createLiformaSvelteKitSessionHandler };
|
|
3592
3617
|
|
|
3593
3618
|
//# sourceMappingURL=index.js.map
|