@liforma/client 0.4.4 → 0.4.6
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 +24 -0
- package/dist/next/index.js +467 -379
- package/dist/next/index.js.map +1 -1
- package/dist/next/next/createLiformaSessionRouteHandler.d.ts +8 -0
- package/dist/next/next/createLiformaSessionRouteHandler.d.ts.map +1 -1
- package/dist/next/next/index.d.ts +8 -1
- package/dist/next/next/index.d.ts.map +1 -1
- package/dist/next/v2/api/captureAttribution.d.ts +10 -0
- package/dist/next/v2/api/captureAttribution.d.ts.map +1 -0
- package/dist/next/v2/api/mintPublicSession.d.ts +1 -0
- package/dist/next/v2/api/mintPublicSession.d.ts.map +1 -1
- package/dist/next/v2/api/sessionEndpointRequest.d.ts +1 -0
- package/dist/next/v2/api/sessionEndpointRequest.d.ts.map +1 -1
- package/dist/next/v2/embed/fullWindowHost.d.ts +20 -0
- package/dist/next/v2/embed/fullWindowHost.d.ts.map +1 -0
- package/dist/next/v2/embed/iframeHost.d.ts +4 -1
- package/dist/next/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/next/v2/embed/protocol.d.ts +18 -1
- package/dist/next/v2/embed/protocol.d.ts.map +1 -1
- package/dist/next/v2/experience.d.ts +14 -2
- package/dist/next/v2/experience.d.ts.map +1 -1
- package/dist/next/v2/types/sessionInteraction.d.ts +49 -0
- package/dist/next/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/npm/index.js +559 -477
- package/dist/npm/index.js.map +1 -1
- package/dist/npm/v2/api/captureAttribution.d.ts +10 -0
- package/dist/npm/v2/api/captureAttribution.d.ts.map +1 -0
- package/dist/npm/v2/api/mintPublicSession.d.ts +1 -0
- package/dist/npm/v2/api/mintPublicSession.d.ts.map +1 -1
- package/dist/npm/v2/api/sessionEndpointRequest.d.ts +1 -0
- package/dist/npm/v2/api/sessionEndpointRequest.d.ts.map +1 -1
- package/dist/npm/v2/embed/fullWindowHost.d.ts +20 -0
- package/dist/npm/v2/embed/fullWindowHost.d.ts.map +1 -0
- package/dist/npm/v2/embed/iframeHost.d.ts +4 -1
- package/dist/npm/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/npm/v2/embed/protocol.d.ts +18 -1
- package/dist/npm/v2/embed/protocol.d.ts.map +1 -1
- package/dist/npm/v2/experience.d.ts +14 -2
- package/dist/npm/v2/experience.d.ts.map +1 -1
- package/dist/npm/v2/index.d.ts +1 -1
- package/dist/npm/v2/index.d.ts.map +1 -1
- package/dist/npm/v2/npm.d.ts +2 -1
- package/dist/npm/v2/npm.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionInteraction.d.ts +49 -0
- package/dist/npm/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionManifestSchema.d.ts +9 -0
- package/dist/npm/v2/types/sessionManifestSchema.d.ts.map +1 -1
- package/dist/react/component/experienceComponentLaunch.d.ts.map +1 -1
- package/dist/react/component/experienceComponentRuntime.d.ts +1 -0
- package/dist/react/component/experienceComponentRuntime.d.ts.map +1 -1
- package/dist/react/component/experienceComponentTypes.d.ts +7 -0
- package/dist/react/component/experienceComponentTypes.d.ts.map +1 -1
- package/dist/react/index.js +710 -621
- package/dist/react/index.js.map +1 -1
- package/dist/react/react/Experience.d.ts.map +1 -1
- package/dist/react/v2/api/captureAttribution.d.ts +10 -0
- package/dist/react/v2/api/captureAttribution.d.ts.map +1 -0
- package/dist/react/v2/api/mintPublicSession.d.ts +1 -0
- package/dist/react/v2/api/mintPublicSession.d.ts.map +1 -1
- package/dist/react/v2/api/sessionEndpointRequest.d.ts +1 -0
- package/dist/react/v2/api/sessionEndpointRequest.d.ts.map +1 -1
- package/dist/react/v2/embed/fullWindowHost.d.ts +20 -0
- package/dist/react/v2/embed/fullWindowHost.d.ts.map +1 -0
- package/dist/react/v2/embed/iframeHost.d.ts +4 -1
- package/dist/react/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/react/v2/embed/protocol.d.ts +18 -1
- package/dist/react/v2/embed/protocol.d.ts.map +1 -1
- package/dist/react/v2/experience.d.ts +14 -2
- package/dist/react/v2/experience.d.ts.map +1 -1
- package/dist/react/v2/types/sessionInteraction.d.ts +49 -0
- package/dist/react/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/sdk/v2/client.js +6 -6
- package/dist/sdk/v2/client.js.map +1 -1
- package/dist/svelte/Experience.svelte +10 -0
- package/dist/svelte/Experience.svelte.d.ts +1 -0
- package/package.json +1 -1
package/dist/npm/index.js
CHANGED
|
@@ -128,20 +128,20 @@ function S(e) {
|
|
|
128
128
|
}
|
|
129
129
|
//#endregion
|
|
130
130
|
//#region src/thumbnail/lazyLoad.ts
|
|
131
|
-
function
|
|
131
|
+
function C() {
|
|
132
132
|
return g() ? "96px 0px" : "280px 0px";
|
|
133
133
|
}
|
|
134
|
-
function
|
|
134
|
+
function w(e) {
|
|
135
135
|
let t = e.trim().split(/\s+/)[0] ?? "0px", n = Number.parseFloat(t);
|
|
136
136
|
return Number.isFinite(n) ? Math.abs(n) : 280;
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function T(e, t) {
|
|
139
139
|
if (typeof window > "u") return !1;
|
|
140
140
|
let n = e.getBoundingClientRect();
|
|
141
141
|
return n.bottom >= -t && n.top <= window.innerHeight + t;
|
|
142
142
|
}
|
|
143
|
-
function
|
|
144
|
-
let { onVisibleChange: n } = t, r = t.rootMargin ??
|
|
143
|
+
function E(e, t) {
|
|
144
|
+
let { onVisibleChange: n } = t, r = t.rootMargin ?? C(), i = w(r), a = !1, o = !1, s = null, c = () => {
|
|
145
145
|
o || (s?.(), s = S(() => {
|
|
146
146
|
s = null, o = !0, n(!0);
|
|
147
147
|
}));
|
|
@@ -164,11 +164,11 @@ function T(e, t) {
|
|
|
164
164
|
rootMargin: r,
|
|
165
165
|
threshold: 0
|
|
166
166
|
});
|
|
167
|
-
return u.observe(e),
|
|
167
|
+
return u.observe(e), T(e, i) && l(!0), () => {
|
|
168
168
|
s?.(), s = null, u.disconnect();
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
|
-
function
|
|
171
|
+
function D(e, t) {
|
|
172
172
|
let n = () => t();
|
|
173
173
|
return e.complete ? queueMicrotask(n) : (e.addEventListener("load", n, { once: !0 }), e.addEventListener("error", n, { once: !0 })), () => {
|
|
174
174
|
e.removeEventListener("load", n), e.removeEventListener("error", n);
|
|
@@ -176,40 +176,40 @@ function E(e, t) {
|
|
|
176
176
|
}
|
|
177
177
|
//#endregion
|
|
178
178
|
//#region src/thumbnail/scrollParallax.ts
|
|
179
|
-
function
|
|
179
|
+
function O() {
|
|
180
180
|
return typeof window > "u" || window.matchMedia("(prefers-reduced-motion: reduce)").matches ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
|
|
181
181
|
}
|
|
182
|
-
function
|
|
182
|
+
function k(e, t) {
|
|
183
183
|
return ((e.top + e.height / 2) / Math.max(t, 1) - .5) * 2;
|
|
184
184
|
}
|
|
185
|
-
var
|
|
186
|
-
function
|
|
187
|
-
if (
|
|
185
|
+
var A = /* @__PURE__ */ new Set(), j = !1, M = 0;
|
|
186
|
+
function ee() {
|
|
187
|
+
if (M = 0, A.size === 0 || typeof window > "u") return;
|
|
188
188
|
let e = window.innerHeight;
|
|
189
|
-
for (let t of
|
|
189
|
+
for (let t of A) {
|
|
190
190
|
if (t.pointerActive?.()) continue;
|
|
191
191
|
let n = t.element.getBoundingClientRect();
|
|
192
|
-
n.bottom < -64 || n.top > e + 64 || t.onParallax(
|
|
192
|
+
n.bottom < -64 || n.top > e + 64 || t.onParallax(k(n, e));
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
function N() {
|
|
196
|
-
|
|
196
|
+
M === 0 && (M = requestAnimationFrame(ee));
|
|
197
197
|
}
|
|
198
198
|
function P() {
|
|
199
|
-
|
|
199
|
+
j || typeof window > "u" || (j = !0, window.addEventListener("scroll", N, { passive: !0 }), window.addEventListener("resize", N, { passive: !0 }));
|
|
200
200
|
}
|
|
201
201
|
function F() {
|
|
202
|
-
|
|
202
|
+
A.size > 0 || !j || typeof window > "u" || (j = !1, M !== 0 && (cancelAnimationFrame(M), M = 0), window.removeEventListener("scroll", N), window.removeEventListener("resize", N));
|
|
203
203
|
}
|
|
204
204
|
function te(e, t) {
|
|
205
|
-
if (!
|
|
205
|
+
if (!O()) return () => {};
|
|
206
206
|
let n = {
|
|
207
207
|
element: e,
|
|
208
208
|
onParallax: t.onParallax,
|
|
209
209
|
pointerActive: t.pointerActive
|
|
210
210
|
};
|
|
211
|
-
return
|
|
212
|
-
|
|
211
|
+
return A.add(n), P(), n.pointerActive?.() || t.onParallax(k(e.getBoundingClientRect(), window.innerHeight)), () => {
|
|
212
|
+
A.delete(n), F();
|
|
213
213
|
};
|
|
214
214
|
}
|
|
215
215
|
//#endregion
|
|
@@ -231,7 +231,7 @@ function ne(e) {
|
|
|
231
231
|
a = !0, e.pointerType === "mouse" && (r = !0), o();
|
|
232
232
|
}, u = () => {
|
|
233
233
|
let s = a;
|
|
234
|
-
a = !1, r = !1, i && s ? (t =
|
|
234
|
+
a = !1, r = !1, i && s ? (t = k(e.getBoundingClientRect(), window.innerHeight), n = 0) : i || (t = 0, n = 0), o();
|
|
235
235
|
}, d = (e) => {
|
|
236
236
|
e.pointerType === "mouse" && (r = !0, o());
|
|
237
237
|
}, f = () => {
|
|
@@ -349,20 +349,58 @@ function fe(e, t, n) {
|
|
|
349
349
|
});
|
|
350
350
|
}
|
|
351
351
|
//#endregion
|
|
352
|
+
//#region src/v2/api/captureAttribution.ts
|
|
353
|
+
var V = 128, pe = /[\u0000-\u001f\u007f]/g;
|
|
354
|
+
function H(e) {
|
|
355
|
+
if (!e) return;
|
|
356
|
+
let t = e.replace(pe, "").trim();
|
|
357
|
+
if (t) return t.slice(0, V);
|
|
358
|
+
}
|
|
359
|
+
function me(e) {
|
|
360
|
+
let t = new URLSearchParams((e ?? "").startsWith("?") ? (e ?? "").slice(1) : e ?? "");
|
|
361
|
+
return {
|
|
362
|
+
...H(t.get("utm_source")) ? { utmSource: H(t.get("utm_source")) } : {},
|
|
363
|
+
...H(t.get("utm_medium")) ? { utmMedium: H(t.get("utm_medium")) } : {},
|
|
364
|
+
...H(t.get("utm_campaign")) ? { utmCampaign: H(t.get("utm_campaign")) } : {},
|
|
365
|
+
...H(t.get("utm_content")) ? { utmContent: H(t.get("utm_content")) } : {},
|
|
366
|
+
...H(t.get("utm_term")) ? { utmTerm: H(t.get("utm_term")) } : {}
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
function he(e) {
|
|
370
|
+
if (e === !1) return;
|
|
371
|
+
if (e && typeof e == "object") {
|
|
372
|
+
let t = {
|
|
373
|
+
...H(e.utmSource) ? { utmSource: H(e.utmSource) } : {},
|
|
374
|
+
...H(e.utmMedium) ? { utmMedium: H(e.utmMedium) } : {},
|
|
375
|
+
...H(e.utmCampaign) ? { utmCampaign: H(e.utmCampaign) } : {},
|
|
376
|
+
...H(e.utmContent) ? { utmContent: H(e.utmContent) } : {},
|
|
377
|
+
...H(e.utmTerm) ? { utmTerm: H(e.utmTerm) } : {},
|
|
378
|
+
...H(e.referrer) ? { referrer: H(e.referrer) } : {}
|
|
379
|
+
};
|
|
380
|
+
return Object.keys(t).length ? t : void 0;
|
|
381
|
+
}
|
|
382
|
+
if (typeof window > "u") return;
|
|
383
|
+
let t = me(window.location?.search), n = H(document.referrer || void 0), r = {
|
|
384
|
+
...t,
|
|
385
|
+
...n ? { referrer: n } : {}
|
|
386
|
+
};
|
|
387
|
+
return Object.keys(r).length ? r : void 0;
|
|
388
|
+
}
|
|
389
|
+
//#endregion
|
|
352
390
|
//#region src/v2/api/sessionEndpointRequest.ts
|
|
353
|
-
function
|
|
391
|
+
function U(e) {
|
|
354
392
|
let t = e.locale?.trim();
|
|
355
393
|
if (t) return t;
|
|
356
394
|
let n = e.language?.trim();
|
|
357
395
|
if (n) return n;
|
|
358
396
|
if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
|
|
359
397
|
}
|
|
360
|
-
function
|
|
398
|
+
function ge(e) {
|
|
361
399
|
let t = e.secondaryLocale?.trim(), n = e.learningLocale?.trim();
|
|
362
400
|
if (t && n && t !== n) throw Error("secondaryLocale and learningLocale disagree; pass only one or make them equal.");
|
|
363
401
|
return t || n || void 0;
|
|
364
402
|
}
|
|
365
|
-
function
|
|
403
|
+
function _e(e, t) {
|
|
366
404
|
let n = e.trim();
|
|
367
405
|
if (!n) throw Error("sessionEndpoint must not be empty.");
|
|
368
406
|
if (typeof location > "u") throw Error("sessionEndpoint is only available in a browser.");
|
|
@@ -370,7 +408,7 @@ function me(e, t) {
|
|
|
370
408
|
if (r.origin !== location.origin) throw Error("sessionEndpoint must be same-origin.");
|
|
371
409
|
let i = t.experienceId.trim();
|
|
372
410
|
if (!i) throw Error("sessionEndpoint requires experienceId.");
|
|
373
|
-
let a =
|
|
411
|
+
let a = U(t), o = ge(t), s = t.idempotencyKey?.trim();
|
|
374
412
|
return {
|
|
375
413
|
url: r.toString(),
|
|
376
414
|
init: {
|
|
@@ -387,23 +425,27 @@ function me(e, t) {
|
|
|
387
425
|
...o ? { secondaryLocale: o } : {},
|
|
388
426
|
...t.mode ? { mode: t.mode } : {},
|
|
389
427
|
...t.speechInputMode ? { speechInputMode: t.speechInputMode } : {},
|
|
390
|
-
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly }
|
|
428
|
+
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
|
|
429
|
+
...(() => {
|
|
430
|
+
let e = he(t.attribution);
|
|
431
|
+
return e ? { attribution: e } : {};
|
|
432
|
+
})()
|
|
391
433
|
})
|
|
392
434
|
}
|
|
393
435
|
};
|
|
394
436
|
}
|
|
395
437
|
//#endregion
|
|
396
438
|
//#region src/v2/types/sessionLaunch.ts
|
|
397
|
-
function
|
|
439
|
+
function W(e) {
|
|
398
440
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
399
441
|
}
|
|
400
|
-
function
|
|
442
|
+
function G(e) {
|
|
401
443
|
return typeof e == "boolean";
|
|
402
444
|
}
|
|
403
|
-
function
|
|
404
|
-
if (!
|
|
445
|
+
function ve(e) {
|
|
446
|
+
if (!W(e)) return null;
|
|
405
447
|
let t = e.speech, n = e.conversation, r = e.avatar, i = e.tools;
|
|
406
|
-
return !
|
|
448
|
+
return !W(t) || !W(n) || !W(r) || !W(i) || !G(t.input) || !G(t.output) || !G(t.externalAudio) || !G(n.managed) || !G(r.enabled) || !G(i.enabled) ? null : {
|
|
407
449
|
speech: {
|
|
408
450
|
input: t.input,
|
|
409
451
|
output: t.output,
|
|
@@ -414,8 +456,8 @@ function W(e) {
|
|
|
414
456
|
tools: { enabled: i.enabled }
|
|
415
457
|
};
|
|
416
458
|
}
|
|
417
|
-
function
|
|
418
|
-
return !
|
|
459
|
+
function K(e) {
|
|
460
|
+
return !W(e) || !G(e.avatar) || !G(e.speechInput) || !G(e.speechOutput) || !G(e.tools) || !G(e.externalAudio) ? null : {
|
|
419
461
|
speech: {
|
|
420
462
|
input: e.speechInput,
|
|
421
463
|
output: e.speechOutput,
|
|
@@ -426,12 +468,12 @@ function he(e) {
|
|
|
426
468
|
tools: { enabled: e.tools }
|
|
427
469
|
};
|
|
428
470
|
}
|
|
429
|
-
function
|
|
430
|
-
return
|
|
471
|
+
function ye(e) {
|
|
472
|
+
return ve(e) ?? K(e);
|
|
431
473
|
}
|
|
432
|
-
function
|
|
433
|
-
if (!
|
|
434
|
-
let t = typeof e.id == "string" ? e.id.trim() : "", n = typeof e.experienceId == "string" ? e.experienceId.trim() : "", r = typeof e.experienceRevisionId == "string" ? e.experienceRevisionId.trim() : "", i = typeof e.expiresAt == "string" ? e.expiresAt.trim() : "", a = typeof e.locale == "string" ? e.locale.trim() : "", o = typeof e.secondaryLocale == "string" && e.secondaryLocale.trim() ? e.secondaryLocale.trim() : void 0, s = e.mode === "conversation" || e.mode === "presenter" ? e.mode : null, c =
|
|
474
|
+
function be(e) {
|
|
475
|
+
if (!W(e)) throw Error("Session Launch response is missing session.");
|
|
476
|
+
let t = typeof e.id == "string" ? e.id.trim() : "", n = typeof e.experienceId == "string" ? e.experienceId.trim() : "", r = typeof e.experienceRevisionId == "string" ? e.experienceRevisionId.trim() : "", i = typeof e.expiresAt == "string" ? e.expiresAt.trim() : "", a = typeof e.locale == "string" ? e.locale.trim() : "", o = typeof e.secondaryLocale == "string" && e.secondaryLocale.trim() ? e.secondaryLocale.trim() : void 0, s = e.mode === "conversation" || e.mode === "presenter" ? e.mode : null, c = ye(e.capabilities), l = xe(e.localeVoiceFallbacks), u = e.status === "active" || e.status === "ended" ? e.status : void 0, d = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt.trim() : void 0;
|
|
435
477
|
if (!t || !n || !r || !i || !a || !s || !c) throw Error("Session Launch response has an invalid session object.");
|
|
436
478
|
return {
|
|
437
479
|
id: t,
|
|
@@ -447,11 +489,11 @@ function _e(e) {
|
|
|
447
489
|
...d ? { createdAt: d } : {}
|
|
448
490
|
};
|
|
449
491
|
}
|
|
450
|
-
function
|
|
492
|
+
function xe(e) {
|
|
451
493
|
if (!Array.isArray(e) || e.length === 0) return;
|
|
452
494
|
let t = [];
|
|
453
495
|
for (let n of e) {
|
|
454
|
-
if (!
|
|
496
|
+
if (!W(n)) continue;
|
|
455
497
|
let e = n.axis === "locale" || n.axis === "secondaryLocale" ? n.axis : null, r = typeof n.requested == "string" ? n.requested.trim() : "", i = typeof n.resolved == "string" ? n.resolved.trim() : "";
|
|
456
498
|
!e || !r || !i || n.reason !== "voice_unsupported" || t.push({
|
|
457
499
|
axis: e,
|
|
@@ -462,35 +504,35 @@ function ve(e) {
|
|
|
462
504
|
}
|
|
463
505
|
return t.length > 0 ? t : void 0;
|
|
464
506
|
}
|
|
465
|
-
function
|
|
507
|
+
function Se(e) {
|
|
466
508
|
let t = e.localeVoiceFallbacks;
|
|
467
509
|
if (t?.length) for (let e of t) {
|
|
468
510
|
let t = e.axis === "secondaryLocale" ? "secondaryLocale" : "locale";
|
|
469
511
|
console.warn(`[liforma] Session ${t} fell back to ${e.resolved} because the voice does not support ${e.requested}.`);
|
|
470
512
|
}
|
|
471
513
|
}
|
|
472
|
-
function
|
|
473
|
-
if (!
|
|
514
|
+
function Ce(e) {
|
|
515
|
+
if (!W(e)) throw Error("Session Launch response must be a JSON object.");
|
|
474
516
|
let t = typeof e.launch == "string" ? e.launch.trim() : "";
|
|
475
517
|
if (!t) throw Error("Session Launch response is missing launch.");
|
|
476
|
-
let n =
|
|
477
|
-
return
|
|
518
|
+
let n = be(e.session);
|
|
519
|
+
return Se(n), {
|
|
478
520
|
session: n,
|
|
479
521
|
launch: t
|
|
480
522
|
};
|
|
481
523
|
}
|
|
482
524
|
//#endregion
|
|
483
525
|
//#region src/v2/api/mintPublicSession.ts
|
|
484
|
-
function
|
|
526
|
+
function we() {
|
|
485
527
|
try {
|
|
486
528
|
if (typeof globalThis.location?.origin == "string" && globalThis.location.origin) return globalThis.location.origin;
|
|
487
529
|
} catch {}
|
|
488
530
|
}
|
|
489
|
-
function
|
|
531
|
+
function Te(e) {
|
|
490
532
|
return e ? e.trim().toUpperCase().replace(/-/g, "_") : "";
|
|
491
533
|
}
|
|
492
|
-
function
|
|
493
|
-
let n =
|
|
534
|
+
function q(e, t) {
|
|
535
|
+
let n = we(), r = Te(t.code), i = t.message.trim(), a = t.details ?? {};
|
|
494
536
|
if (r === "ORIGIN_NOT_ALLOWED" || /^Origin not allowed/i.test(i) && n) {
|
|
495
537
|
if (i.includes(e) && i.includes("allowed origin")) return t;
|
|
496
538
|
let r = typeof a.origin == "string" && a.origin || n || "(unknown origin)";
|
|
@@ -513,36 +555,38 @@ function Se(e, t) {
|
|
|
513
555
|
details: a
|
|
514
556
|
}) : t;
|
|
515
557
|
}
|
|
516
|
-
function
|
|
558
|
+
function Ee(e) {
|
|
517
559
|
let t = e?.locale?.trim();
|
|
518
560
|
if (t) return t;
|
|
519
561
|
let n = e?.language?.trim();
|
|
520
562
|
if (n) return n;
|
|
521
563
|
if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
|
|
522
564
|
}
|
|
523
|
-
function
|
|
565
|
+
function De(e) {
|
|
524
566
|
let t = e?.secondaryLocale?.trim(), n = e?.learningLocale?.trim();
|
|
525
567
|
if (t && n && t !== n) throw new B("secondaryLocale and learningLocale disagree; pass only one or make them equal.", { code: "INVALID_BODY" });
|
|
526
568
|
return t || n || void 0;
|
|
527
569
|
}
|
|
528
|
-
function
|
|
529
|
-
let n = { experienceId: e }, r =
|
|
570
|
+
function Oe(e, t) {
|
|
571
|
+
let n = { experienceId: e }, r = Ee(t);
|
|
530
572
|
r && (n.locale = r);
|
|
531
|
-
let i =
|
|
532
|
-
|
|
573
|
+
let i = De(t);
|
|
574
|
+
i && (n.secondaryLocale = i), t?.mode && (n.mode = t.mode), t?.speechInputMode && (n.speechInputMode = t.speechInputMode), t?.speechOnly !== void 0 && (n.speechOnly = t.speechOnly);
|
|
575
|
+
let a = he(t?.attribution);
|
|
576
|
+
return a && (n.attribution = a), n;
|
|
533
577
|
}
|
|
534
|
-
async function
|
|
578
|
+
async function ke(e, t) {
|
|
535
579
|
let n = ce(), r = t?.idempotencyKey?.trim(), i = await fetch(`${n}/v1/browser-sessions`, {
|
|
536
580
|
method: "POST",
|
|
537
581
|
headers: {
|
|
538
582
|
"Content-Type": "application/json",
|
|
539
583
|
...r ? { "Idempotency-Key": r } : {}
|
|
540
584
|
},
|
|
541
|
-
body: JSON.stringify(
|
|
585
|
+
body: JSON.stringify(Oe(e, t))
|
|
542
586
|
});
|
|
543
587
|
if (!i.ok) {
|
|
544
588
|
let t = await i.text();
|
|
545
|
-
throw
|
|
589
|
+
throw q(e, fe(i.status, t, i.headers));
|
|
546
590
|
}
|
|
547
591
|
let a;
|
|
548
592
|
try {
|
|
@@ -554,10 +598,10 @@ async function Ee(e, t) {
|
|
|
554
598
|
requestId: i.headers.get("Liforma-Request-Id") ?? void 0
|
|
555
599
|
});
|
|
556
600
|
}
|
|
557
|
-
return
|
|
601
|
+
return Ce(a);
|
|
558
602
|
}
|
|
559
|
-
async function
|
|
560
|
-
let n =
|
|
603
|
+
async function J(e, t) {
|
|
604
|
+
let n = _e(e, t), r = new AbortController(), i = () => r.abort(t.signal?.reason);
|
|
561
605
|
t.signal?.aborted ? i() : t.signal?.addEventListener("abort", i, { once: !0 });
|
|
562
606
|
let a = globalThis.setTimeout(() => r.abort(new DOMException("Session endpoint timed out.", "TimeoutError")), t.timeoutMs ?? 3e4), o;
|
|
563
607
|
try {
|
|
@@ -587,14 +631,14 @@ async function K(e, t) {
|
|
|
587
631
|
requestId: o.headers.get("Liforma-Request-Id") ?? void 0
|
|
588
632
|
});
|
|
589
633
|
}
|
|
590
|
-
return
|
|
634
|
+
return Ce(s);
|
|
591
635
|
}
|
|
592
636
|
//#endregion
|
|
593
637
|
//#region src/v2/conversationProcessor.ts
|
|
594
|
-
function
|
|
638
|
+
function Ae(e) {
|
|
595
639
|
return typeof e != "object" || !e ? !1 : typeof e[Symbol.asyncIterator] == "function";
|
|
596
640
|
}
|
|
597
|
-
function
|
|
641
|
+
function je(e) {
|
|
598
642
|
if (typeof e == "string") {
|
|
599
643
|
let t = e.trim();
|
|
600
644
|
if (!t) throw Error("conversationProcessor returned empty text.");
|
|
@@ -608,24 +652,24 @@ function Oe(e) {
|
|
|
608
652
|
...e.behavior ? { behavior: e.behavior } : {}
|
|
609
653
|
};
|
|
610
654
|
}
|
|
611
|
-
async function
|
|
655
|
+
async function Me(e, t) {
|
|
612
656
|
let n = await e(t);
|
|
613
|
-
return
|
|
657
|
+
return Ae(n) ? {
|
|
614
658
|
kind: "stream",
|
|
615
659
|
stream: n
|
|
616
660
|
} : {
|
|
617
661
|
kind: "complete",
|
|
618
|
-
speech:
|
|
662
|
+
speech: je(n)
|
|
619
663
|
};
|
|
620
664
|
}
|
|
621
665
|
//#endregion
|
|
622
666
|
//#region src/v2/embed/playerReachability.ts
|
|
623
|
-
var
|
|
624
|
-
function
|
|
667
|
+
var Ne = "3002";
|
|
668
|
+
function Pe(e) {
|
|
625
669
|
let t = new URL(e);
|
|
626
|
-
return t.hostname === "localhost" || t.hostname === "127.0.0.1" ? `Cannot connect to the Liforma player at ${e} — nothing is listening on port ${t.port ||
|
|
670
|
+
return t.hostname === "localhost" || t.hostname === "127.0.0.1" ? `Cannot connect to the Liforma player at ${e} — nothing is listening on port ${t.port || Ne}. Start the player dev server in player.liforma.ai (npm run dev).` : `Cannot connect to the Liforma player at ${e}. The embed did not load; check your network connection and player URL configuration.`;
|
|
627
671
|
}
|
|
628
|
-
async function
|
|
672
|
+
async function Fe(e, t) {
|
|
629
673
|
try {
|
|
630
674
|
await fetch(e, {
|
|
631
675
|
method: "GET",
|
|
@@ -633,52 +677,30 @@ async function je(e, t) {
|
|
|
633
677
|
signal: AbortSignal.timeout(8e3)
|
|
634
678
|
});
|
|
635
679
|
} catch {
|
|
636
|
-
throw Error(
|
|
680
|
+
throw Error(Pe(t));
|
|
637
681
|
}
|
|
638
682
|
}
|
|
639
|
-
function
|
|
683
|
+
function Ie(e, t, n, r) {
|
|
640
684
|
try {
|
|
641
685
|
r && r.length > 0 ? e.postMessage(t, n, r) : e.postMessage(t, n);
|
|
642
686
|
} catch (e) {
|
|
643
|
-
throw e instanceof DOMException && e.name === "SecurityError" ? Error(
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
var
|
|
647
|
-
function
|
|
648
|
-
return typeof e == "number" &&
|
|
649
|
-
}
|
|
650
|
-
var
|
|
651
|
-
|
|
652
|
-
"stateUpdate",
|
|
653
|
-
"commandResult",
|
|
654
|
-
"userTranscript",
|
|
655
|
-
"characterSpeechStarted",
|
|
656
|
-
"characterSpeechEnded",
|
|
657
|
-
"characterFocusChanged",
|
|
658
|
-
"conversationUpdate",
|
|
659
|
-
"listeningState",
|
|
660
|
-
"userSpeechStarted",
|
|
661
|
-
"userSpeechEnded",
|
|
662
|
-
"modeChange",
|
|
663
|
-
"activityChange",
|
|
664
|
-
"feedback",
|
|
665
|
-
"feedbackFailed",
|
|
666
|
-
"message",
|
|
667
|
-
"started",
|
|
668
|
-
"embedReady",
|
|
669
|
-
"widgetReady",
|
|
670
|
-
"widgetExpand",
|
|
671
|
-
"widgetCollapse",
|
|
672
|
-
"widgetAudioSettings",
|
|
673
|
-
"widgetDragStart",
|
|
674
|
-
"widgetDragMove",
|
|
675
|
-
"widgetDragEnd"
|
|
676
|
-
]);
|
|
677
|
-
function Fe(e) {
|
|
687
|
+
throw e instanceof DOMException && e.name === "SecurityError" ? Error(Pe(n), { cause: e }) : e;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
var Le = new Set([1, 2]);
|
|
691
|
+
function Re(e) {
|
|
692
|
+
return typeof e == "number" && Le.has(e);
|
|
693
|
+
}
|
|
694
|
+
var ze = new Set(/* @__PURE__ */ "close.stateUpdate.commandResult.userTranscript.characterSpeechStarted.characterSpeechEnded.characterFocusChanged.conversationUpdate.listeningState.userSpeechStarted.userSpeechEnded.modeChange.activityChange.feedback.feedbackFailed.message.started.embedReady.widgetReady.widgetExpand.widgetCollapse.widgetAudioSettings.widgetDragStart.widgetDragMove.widgetDragEnd.fullWindow".split("."));
|
|
695
|
+
function Be(e) {
|
|
678
696
|
if (!e || typeof e != "object") return null;
|
|
679
697
|
let t = e;
|
|
680
|
-
if (!
|
|
698
|
+
if (!Re(t.schemaVersion) || !t.type || !ze.has(t.type)) return null;
|
|
681
699
|
if (t.type === "embedReady" || t.type === "widgetReady" || t.type === "widgetExpand" || t.type === "widgetCollapse") return t;
|
|
700
|
+
if (t.type === "fullWindow") {
|
|
701
|
+
let e = t.payload;
|
|
702
|
+
return !e || typeof e != "object" || typeof e.active != "boolean" ? null : t;
|
|
703
|
+
}
|
|
682
704
|
if (t.type === "widgetAudioSettings") {
|
|
683
705
|
let e = t.payload;
|
|
684
706
|
return !e || typeof e != "object" || typeof e.open != "boolean" ? null : t;
|
|
@@ -696,10 +718,10 @@ function Fe(e) {
|
|
|
696
718
|
let n = t.payload;
|
|
697
719
|
return !n || typeof n != "object" ? null : t;
|
|
698
720
|
}
|
|
699
|
-
function
|
|
721
|
+
function Ve(e, t, n) {
|
|
700
722
|
let r = e.trim();
|
|
701
723
|
if (!r) throw Error("createLaunchMessage requires a non-empty launch string.");
|
|
702
|
-
let i = n?.startButton, a = n?.showFeedback;
|
|
724
|
+
let i = n?.startButton, a = n?.theme, o = n?.showFeedback;
|
|
703
725
|
return {
|
|
704
726
|
type: "launch",
|
|
705
727
|
schemaVersion: 2,
|
|
@@ -707,24 +729,25 @@ function Ie(e, t, n) {
|
|
|
707
729
|
launch: r,
|
|
708
730
|
...t === void 0 ? {} : { session: t },
|
|
709
731
|
...i ? { startButton: i } : {},
|
|
710
|
-
...a
|
|
732
|
+
...a ? { theme: a } : {},
|
|
733
|
+
...o === void 0 ? {} : { showFeedback: o }
|
|
711
734
|
}
|
|
712
735
|
};
|
|
713
736
|
}
|
|
714
|
-
function
|
|
737
|
+
function He() {
|
|
715
738
|
return {
|
|
716
739
|
type: "parentHello",
|
|
717
740
|
schemaVersion: 2
|
|
718
741
|
};
|
|
719
742
|
}
|
|
720
|
-
function
|
|
743
|
+
function Ue(e) {
|
|
721
744
|
return {
|
|
722
745
|
type: "widgetSetChrome",
|
|
723
746
|
schemaVersion: 2,
|
|
724
747
|
payload: { mode: e }
|
|
725
748
|
};
|
|
726
749
|
}
|
|
727
|
-
function
|
|
750
|
+
function We() {
|
|
728
751
|
return {
|
|
729
752
|
type: "widgetToggleAudioSettings",
|
|
730
753
|
schemaVersion: 2,
|
|
@@ -732,108 +755,143 @@ function ze() {
|
|
|
732
755
|
};
|
|
733
756
|
}
|
|
734
757
|
//#endregion
|
|
758
|
+
//#region src/v2/embed/fullWindowHost.ts
|
|
759
|
+
var Ge = "2147483000";
|
|
760
|
+
function Ke(e) {
|
|
761
|
+
let { style: t } = e;
|
|
762
|
+
return {
|
|
763
|
+
position: t.position,
|
|
764
|
+
top: t.top,
|
|
765
|
+
right: t.right,
|
|
766
|
+
bottom: t.bottom,
|
|
767
|
+
left: t.left,
|
|
768
|
+
inset: t.inset,
|
|
769
|
+
width: t.width,
|
|
770
|
+
height: t.height,
|
|
771
|
+
zIndex: t.zIndex,
|
|
772
|
+
margin: t.margin,
|
|
773
|
+
borderRadius: t.borderRadius,
|
|
774
|
+
maxWidth: t.maxWidth,
|
|
775
|
+
maxHeight: t.maxHeight
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
function qe(e) {
|
|
779
|
+
let { style: t } = e;
|
|
780
|
+
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 = Ge, t.margin = "0", t.borderRadius = "0", t.maxWidth = "none", t.maxHeight = "none", e.dataset.liformaFullWindow = "1";
|
|
781
|
+
}
|
|
782
|
+
function Je(e, t) {
|
|
783
|
+
if (delete e.dataset.liformaFullWindow, !t) {
|
|
784
|
+
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 = "";
|
|
785
|
+
return;
|
|
786
|
+
}
|
|
787
|
+
let { style: n } = e;
|
|
788
|
+
n.position = t.position, n.top = t.top, n.right = t.right, n.bottom = t.bottom, n.left = t.left, n.inset = t.inset, n.width = t.width, n.height = t.height, n.zIndex = t.zIndex, n.margin = t.margin, n.borderRadius = t.borderRadius, n.maxWidth = t.maxWidth, n.maxHeight = t.maxHeight;
|
|
789
|
+
}
|
|
790
|
+
//#endregion
|
|
735
791
|
//#region src/v2/embed/iframeHost.ts
|
|
736
|
-
function
|
|
792
|
+
function Ye(e) {
|
|
737
793
|
return e;
|
|
738
794
|
}
|
|
739
795
|
function Y() {
|
|
740
796
|
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)}`;
|
|
741
797
|
}
|
|
742
|
-
var
|
|
743
|
-
function
|
|
798
|
+
var Xe = 3e4;
|
|
799
|
+
function Ze(e) {
|
|
744
800
|
let t = e.container;
|
|
745
801
|
getComputedStyle(t).position === "static" && (t.style.position = "relative");
|
|
746
802
|
let n = document.createElement("iframe");
|
|
747
803
|
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");
|
|
748
|
-
let r = !1, i =
|
|
749
|
-
|
|
750
|
-
}), f = () => {
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
804
|
+
let r = !1, i = !1, a = null, o = t.closest(".liforma-experience-shell") instanceof HTMLElement ? t.closest(".liforma-experience-shell") : t, s = (t) => {
|
|
805
|
+
i !== t && (i = t, t ? (a = Ke(o), qe(o)) : (Je(o, a), a = null), e.onFullWindowChange?.(t));
|
|
806
|
+
}, c = /* @__PURE__ */ new Map(), l = null, u = 0, d = 0, f = [], p = null, m = null, h = new Promise((e, t) => {
|
|
807
|
+
p = e, m = t;
|
|
808
|
+
}), g = () => {
|
|
809
|
+
for (let e of f) window.clearTimeout(e);
|
|
810
|
+
f.length = 0;
|
|
811
|
+
}, _ = (t) => {
|
|
754
812
|
if (r) return;
|
|
755
813
|
let i = Date.now();
|
|
756
|
-
if (
|
|
757
|
-
|
|
758
|
-
let a =
|
|
814
|
+
if (d > 0 && i - d < 250) return;
|
|
815
|
+
d = i, g();
|
|
816
|
+
let a = Ve(t.launch, t.session, t.chrome), o = () => {
|
|
759
817
|
if (r) return;
|
|
760
818
|
let t = n.contentWindow;
|
|
761
|
-
t &&
|
|
819
|
+
t && Ie(t, a, e.playerOrigin);
|
|
762
820
|
};
|
|
763
821
|
o();
|
|
764
|
-
for (let e = 1; e <= 12; e += 1)
|
|
765
|
-
},
|
|
766
|
-
r || !
|
|
767
|
-
},
|
|
768
|
-
if (
|
|
769
|
-
|
|
822
|
+
for (let e = 1; e <= 12; e += 1) f.push(window.setTimeout(o, e * 75));
|
|
823
|
+
}, v = () => {
|
|
824
|
+
r || !l || _(l);
|
|
825
|
+
}, y = () => {
|
|
826
|
+
if (u += 1, u === 1) {
|
|
827
|
+
Fe(e.src, e.playerOrigin).then(() => p?.(), (e) => m?.(e instanceof Error ? e : Error(String(e))));
|
|
770
828
|
return;
|
|
771
829
|
}
|
|
772
|
-
|
|
773
|
-
},
|
|
774
|
-
|
|
830
|
+
d = 0, v();
|
|
831
|
+
}, b = () => {
|
|
832
|
+
u > 0 || m?.(Error(Pe(e.playerOrigin)));
|
|
775
833
|
};
|
|
776
|
-
n.addEventListener("load",
|
|
777
|
-
let
|
|
834
|
+
n.addEventListener("load", y), n.addEventListener("error", b);
|
|
835
|
+
let x = (t) => {
|
|
778
836
|
if (r || t.source !== n.contentWindow || t.origin !== e.playerOrigin) return;
|
|
779
|
-
let
|
|
780
|
-
if (
|
|
837
|
+
let i = Be(t.data);
|
|
838
|
+
if (i) switch (i.type) {
|
|
781
839
|
case "close":
|
|
782
|
-
e.onClose?.(
|
|
840
|
+
e.onClose?.(i.payload);
|
|
783
841
|
break;
|
|
784
842
|
case "stateUpdate":
|
|
785
|
-
e.onPlayerStatusChange?.(
|
|
843
|
+
e.onPlayerStatusChange?.(i.payload.state), e.onStateUpdate?.(i.payload.state);
|
|
786
844
|
break;
|
|
787
845
|
case "commandResult": {
|
|
788
|
-
let e =
|
|
846
|
+
let e = c.get(i.payload.correlationId);
|
|
789
847
|
if (!e) return;
|
|
790
|
-
|
|
848
|
+
c.delete(i.payload.correlationId), i.payload.ok ? e.resolve(i.payload.result) : e.reject(Error(i.payload.error ?? "Command failed."));
|
|
791
849
|
break;
|
|
792
850
|
}
|
|
793
851
|
case "userTranscript":
|
|
794
|
-
e.onUserTranscript?.(
|
|
852
|
+
e.onUserTranscript?.(i.payload);
|
|
795
853
|
break;
|
|
796
854
|
case "characterSpeechStarted":
|
|
797
|
-
e.onCharacterSpeechStarted?.(
|
|
855
|
+
e.onCharacterSpeechStarted?.(i.payload);
|
|
798
856
|
break;
|
|
799
857
|
case "characterSpeechEnded":
|
|
800
|
-
e.onCharacterSpeechEnded?.(
|
|
858
|
+
e.onCharacterSpeechEnded?.(i.payload);
|
|
801
859
|
break;
|
|
802
860
|
case "characterFocusChanged":
|
|
803
|
-
e.onCharacterFocusChanged?.(
|
|
861
|
+
e.onCharacterFocusChanged?.(i.payload);
|
|
804
862
|
break;
|
|
805
863
|
case "conversationUpdate":
|
|
806
|
-
e.onConversationUpdate?.(
|
|
864
|
+
e.onConversationUpdate?.(i.payload.conversation);
|
|
807
865
|
break;
|
|
808
866
|
case "listeningState":
|
|
809
|
-
e.onListeningState?.(
|
|
867
|
+
e.onListeningState?.(i.payload.listening);
|
|
810
868
|
break;
|
|
811
869
|
case "userSpeechStarted":
|
|
812
|
-
e.onUserSpeechStarted?.(
|
|
870
|
+
e.onUserSpeechStarted?.(i.payload);
|
|
813
871
|
break;
|
|
814
872
|
case "userSpeechEnded":
|
|
815
|
-
e.onUserSpeechEnded?.(
|
|
873
|
+
e.onUserSpeechEnded?.(i.payload);
|
|
816
874
|
break;
|
|
817
875
|
case "modeChange":
|
|
818
|
-
e.onActivityChange?.(
|
|
876
|
+
e.onActivityChange?.(Ye(i.payload.mode));
|
|
819
877
|
break;
|
|
820
878
|
case "activityChange":
|
|
821
|
-
e.onActivityChange?.(
|
|
879
|
+
e.onActivityChange?.(i.payload.activity);
|
|
822
880
|
break;
|
|
823
881
|
case "feedback":
|
|
824
|
-
e.onFeedback?.(
|
|
882
|
+
e.onFeedback?.(i.payload);
|
|
825
883
|
break;
|
|
826
884
|
case "feedbackFailed":
|
|
827
|
-
e.onFeedbackFailed?.(
|
|
885
|
+
e.onFeedbackFailed?.(i.payload);
|
|
828
886
|
break;
|
|
829
887
|
case "message":
|
|
830
|
-
e.onMessage?.(
|
|
888
|
+
e.onMessage?.(i.payload);
|
|
831
889
|
break;
|
|
832
890
|
case "started":
|
|
833
|
-
e.onStarted?.(
|
|
891
|
+
e.onStarted?.(i.payload);
|
|
834
892
|
break;
|
|
835
893
|
case "embedReady":
|
|
836
|
-
|
|
894
|
+
v();
|
|
837
895
|
break;
|
|
838
896
|
case "widgetReady":
|
|
839
897
|
e.onWidgetReady?.();
|
|
@@ -845,52 +903,55 @@ function He(e) {
|
|
|
845
903
|
e.onWidgetCollapse?.();
|
|
846
904
|
break;
|
|
847
905
|
case "widgetAudioSettings":
|
|
848
|
-
e.onWidgetAudioSettings?.(
|
|
906
|
+
e.onWidgetAudioSettings?.(i.payload.open);
|
|
849
907
|
break;
|
|
850
908
|
case "widgetDragStart":
|
|
851
|
-
e.onWidgetDragStart?.(
|
|
909
|
+
e.onWidgetDragStart?.(i.payload);
|
|
852
910
|
break;
|
|
853
911
|
case "widgetDragMove":
|
|
854
|
-
e.onWidgetDragMove?.(
|
|
912
|
+
e.onWidgetDragMove?.(i.payload);
|
|
855
913
|
break;
|
|
856
914
|
case "widgetDragEnd":
|
|
857
|
-
e.onWidgetDragEnd?.(
|
|
915
|
+
e.onWidgetDragEnd?.(i.payload);
|
|
916
|
+
break;
|
|
917
|
+
case "fullWindow":
|
|
918
|
+
s(i.payload.active);
|
|
858
919
|
break;
|
|
859
920
|
}
|
|
860
921
|
};
|
|
861
|
-
if (window.addEventListener("message",
|
|
922
|
+
if (window.addEventListener("message", x), t.replaceChildren(n), t.clientHeight < 2 && !t.style.minHeight) {
|
|
862
923
|
let e = getComputedStyle(t).minHeight;
|
|
863
924
|
(e === "0px" || e === "auto") && (t.style.minHeight = "480px");
|
|
864
925
|
}
|
|
865
|
-
let
|
|
926
|
+
let S = (t, i) => {
|
|
866
927
|
if (r) return;
|
|
867
928
|
let a = n.contentWindow;
|
|
868
|
-
if (!a) throw Error(
|
|
869
|
-
|
|
870
|
-
},
|
|
929
|
+
if (!a) throw Error(Pe(e.playerOrigin));
|
|
930
|
+
Ie(a, t, e.playerOrigin, i);
|
|
931
|
+
}, C = (e, t = 12e4, n) => {
|
|
871
932
|
let r = e.type !== "parentHello" && e.payload && "correlationId" in e.payload ? e.payload.correlationId : Y();
|
|
872
|
-
return e.type !== "parentHello" && e.payload && "correlationId" in e.payload || e.type !== "parentHello" && e.payload && (e.payload.correlationId = r), new Promise((
|
|
873
|
-
|
|
874
|
-
resolve: (e) =>
|
|
875
|
-
reject:
|
|
876
|
-
}),
|
|
877
|
-
|
|
933
|
+
return e.type !== "parentHello" && e.payload && "correlationId" in e.payload || e.type !== "parentHello" && e.payload && (e.payload.correlationId = r), new Promise((i, a) => {
|
|
934
|
+
c.set(r, {
|
|
935
|
+
resolve: (e) => i(e),
|
|
936
|
+
reject: a
|
|
937
|
+
}), S(e, n), setTimeout(() => {
|
|
938
|
+
c.has(r) && (c.delete(r), a(/* @__PURE__ */ Error("Timed out waiting for player command result.")));
|
|
878
939
|
}, t);
|
|
879
940
|
});
|
|
880
941
|
};
|
|
881
942
|
return {
|
|
882
943
|
waitForLoad() {
|
|
883
|
-
return
|
|
944
|
+
return h;
|
|
884
945
|
},
|
|
885
946
|
postParentHello() {
|
|
886
|
-
|
|
947
|
+
S(He());
|
|
887
948
|
},
|
|
888
949
|
postLaunch(e, t, n) {
|
|
889
|
-
r || (
|
|
950
|
+
r || (l = {
|
|
890
951
|
launch: e,
|
|
891
952
|
session: t,
|
|
892
953
|
chrome: n
|
|
893
|
-
},
|
|
954
|
+
}, d = 0, _(l));
|
|
894
955
|
},
|
|
895
956
|
postManifest(e) {
|
|
896
957
|
if (typeof e == "string") {
|
|
@@ -905,13 +966,13 @@ function He(e) {
|
|
|
905
966
|
throw Error("postManifest is deprecated; use postLaunch with an opaque launch string from SessionLaunchResponse.");
|
|
906
967
|
},
|
|
907
968
|
postWidgetSetChrome(e) {
|
|
908
|
-
|
|
969
|
+
S(Ue(e));
|
|
909
970
|
},
|
|
910
971
|
postWidgetToggleAudioSettings() {
|
|
911
|
-
|
|
972
|
+
S(We());
|
|
912
973
|
},
|
|
913
974
|
speak(e) {
|
|
914
|
-
return
|
|
975
|
+
return C({
|
|
915
976
|
type: "speak",
|
|
916
977
|
schemaVersion: 2,
|
|
917
978
|
payload: {
|
|
@@ -923,21 +984,21 @@ function He(e) {
|
|
|
923
984
|
});
|
|
924
985
|
},
|
|
925
986
|
startListening() {
|
|
926
|
-
return
|
|
987
|
+
return C({
|
|
927
988
|
type: "startListening",
|
|
928
989
|
schemaVersion: 2,
|
|
929
990
|
payload: { correlationId: Y() }
|
|
930
991
|
});
|
|
931
992
|
},
|
|
932
993
|
stopListening() {
|
|
933
|
-
return
|
|
994
|
+
return C({
|
|
934
995
|
type: "stopListening",
|
|
935
996
|
schemaVersion: 2,
|
|
936
997
|
payload: { correlationId: Y() }
|
|
937
998
|
});
|
|
938
999
|
},
|
|
939
1000
|
listenOnce(e) {
|
|
940
|
-
return
|
|
1001
|
+
return C({
|
|
941
1002
|
type: "listenOnce",
|
|
942
1003
|
schemaVersion: 2,
|
|
943
1004
|
payload: {
|
|
@@ -947,7 +1008,7 @@ function He(e) {
|
|
|
947
1008
|
});
|
|
948
1009
|
},
|
|
949
1010
|
async speakProcessorStream(e, t) {
|
|
950
|
-
let n = Y(), r = Y(), i = (await
|
|
1011
|
+
let n = Y(), r = Y(), i = (await C({
|
|
951
1012
|
type: "speakStreamStart",
|
|
952
1013
|
schemaVersion: 2,
|
|
953
1014
|
payload: {
|
|
@@ -959,7 +1020,7 @@ function He(e) {
|
|
|
959
1020
|
try {
|
|
960
1021
|
for await (let n of e) {
|
|
961
1022
|
if (t?.signal?.aborted) throw new DOMException("Processor stream aborted.", "AbortError");
|
|
962
|
-
n &&
|
|
1023
|
+
n && S({
|
|
963
1024
|
type: "speakStreamChunk",
|
|
964
1025
|
schemaVersion: 2,
|
|
965
1026
|
payload: {
|
|
@@ -969,7 +1030,7 @@ function He(e) {
|
|
|
969
1030
|
});
|
|
970
1031
|
}
|
|
971
1032
|
if (t?.signal?.aborted) throw new DOMException("Processor stream aborted.", "AbortError");
|
|
972
|
-
return await
|
|
1033
|
+
return await C({
|
|
973
1034
|
type: "speakStreamEnd",
|
|
974
1035
|
schemaVersion: 2,
|
|
975
1036
|
payload: {
|
|
@@ -979,7 +1040,7 @@ function He(e) {
|
|
|
979
1040
|
});
|
|
980
1041
|
} catch (e) {
|
|
981
1042
|
try {
|
|
982
|
-
await
|
|
1043
|
+
await C({
|
|
983
1044
|
type: "speakStreamEnd",
|
|
984
1045
|
schemaVersion: 2,
|
|
985
1046
|
payload: {
|
|
@@ -993,7 +1054,7 @@ function He(e) {
|
|
|
993
1054
|
},
|
|
994
1055
|
speechPlay(e) {
|
|
995
1056
|
let t = Y(), n = [];
|
|
996
|
-
return (e.source.kind === "pcm" || e.source.kind === "encoded") && n.push(e.source.data),
|
|
1057
|
+
return (e.source.kind === "pcm" || e.source.kind === "encoded") && n.push(e.source.data), C({
|
|
997
1058
|
type: "speechPlay",
|
|
998
1059
|
schemaVersion: 2,
|
|
999
1060
|
payload: {
|
|
@@ -1007,7 +1068,7 @@ function He(e) {
|
|
|
1007
1068
|
}, 12e4, n);
|
|
1008
1069
|
},
|
|
1009
1070
|
speechUtteranceBegin(e) {
|
|
1010
|
-
return
|
|
1071
|
+
return C({
|
|
1011
1072
|
type: "speechUtteranceBegin",
|
|
1012
1073
|
schemaVersion: 2,
|
|
1013
1074
|
payload: {
|
|
@@ -1021,7 +1082,7 @@ function He(e) {
|
|
|
1021
1082
|
});
|
|
1022
1083
|
},
|
|
1023
1084
|
speechUtteranceWrite(e) {
|
|
1024
|
-
return
|
|
1085
|
+
return C({
|
|
1025
1086
|
type: "speechUtteranceWrite",
|
|
1026
1087
|
schemaVersion: 2,
|
|
1027
1088
|
payload: {
|
|
@@ -1030,10 +1091,10 @@ function He(e) {
|
|
|
1030
1091
|
audio: e.audio,
|
|
1031
1092
|
byteLength: e.byteLength
|
|
1032
1093
|
}
|
|
1033
|
-
},
|
|
1094
|
+
}, Xe, [e.audio]);
|
|
1034
1095
|
},
|
|
1035
1096
|
speechUtteranceSetTranscript(e) {
|
|
1036
|
-
return
|
|
1097
|
+
return C({
|
|
1037
1098
|
type: "speechUtteranceSetTranscript",
|
|
1038
1099
|
schemaVersion: 2,
|
|
1039
1100
|
payload: {
|
|
@@ -1044,7 +1105,7 @@ function He(e) {
|
|
|
1044
1105
|
});
|
|
1045
1106
|
},
|
|
1046
1107
|
speechUtteranceClose(e) {
|
|
1047
|
-
return
|
|
1108
|
+
return C({
|
|
1048
1109
|
type: "speechUtteranceClose",
|
|
1049
1110
|
schemaVersion: 2,
|
|
1050
1111
|
payload: {
|
|
@@ -1056,7 +1117,7 @@ function He(e) {
|
|
|
1056
1117
|
});
|
|
1057
1118
|
},
|
|
1058
1119
|
speechUtteranceCancel(e) {
|
|
1059
|
-
return
|
|
1120
|
+
return C({
|
|
1060
1121
|
type: "speechUtteranceCancel",
|
|
1061
1122
|
schemaVersion: 2,
|
|
1062
1123
|
payload: {
|
|
@@ -1066,7 +1127,7 @@ function He(e) {
|
|
|
1066
1127
|
});
|
|
1067
1128
|
},
|
|
1068
1129
|
speechInterrupt(e) {
|
|
1069
|
-
return
|
|
1130
|
+
return C({
|
|
1070
1131
|
type: "speechInterrupt",
|
|
1071
1132
|
schemaVersion: 2,
|
|
1072
1133
|
payload: {
|
|
@@ -1076,14 +1137,14 @@ function He(e) {
|
|
|
1076
1137
|
});
|
|
1077
1138
|
},
|
|
1078
1139
|
getConversation() {
|
|
1079
|
-
return
|
|
1140
|
+
return C({
|
|
1080
1141
|
type: "getConversation",
|
|
1081
1142
|
schemaVersion: 2,
|
|
1082
1143
|
payload: { correlationId: Y() }
|
|
1083
1144
|
});
|
|
1084
1145
|
},
|
|
1085
1146
|
focusCharacter(e) {
|
|
1086
|
-
return
|
|
1147
|
+
return C({
|
|
1087
1148
|
type: "focusCharacter",
|
|
1088
1149
|
schemaVersion: 2,
|
|
1089
1150
|
payload: {
|
|
@@ -1093,7 +1154,7 @@ function He(e) {
|
|
|
1093
1154
|
});
|
|
1094
1155
|
},
|
|
1095
1156
|
setFit(e) {
|
|
1096
|
-
return
|
|
1157
|
+
return C({
|
|
1097
1158
|
type: "setFit",
|
|
1098
1159
|
schemaVersion: 2,
|
|
1099
1160
|
payload: {
|
|
@@ -1102,18 +1163,28 @@ function He(e) {
|
|
|
1102
1163
|
}
|
|
1103
1164
|
});
|
|
1104
1165
|
},
|
|
1166
|
+
conversion(e) {
|
|
1167
|
+
return C({
|
|
1168
|
+
type: "conversion",
|
|
1169
|
+
schemaVersion: 2,
|
|
1170
|
+
payload: {
|
|
1171
|
+
correlationId: Y(),
|
|
1172
|
+
key: e
|
|
1173
|
+
}
|
|
1174
|
+
});
|
|
1175
|
+
},
|
|
1105
1176
|
destroy() {
|
|
1106
1177
|
if (!r) {
|
|
1107
|
-
r = !0;
|
|
1108
|
-
for (let e of
|
|
1109
|
-
|
|
1178
|
+
r = !0, i && s(!1);
|
|
1179
|
+
for (let e of c.values()) e.reject(/* @__PURE__ */ Error("Iframe host destroyed."));
|
|
1180
|
+
c.clear(), g(), l = null, n.removeEventListener("load", y), n.removeEventListener("error", b), window.removeEventListener("message", x), n.remove();
|
|
1110
1181
|
}
|
|
1111
1182
|
}
|
|
1112
1183
|
};
|
|
1113
1184
|
}
|
|
1114
1185
|
//#endregion
|
|
1115
1186
|
//#region src/v2/embed/readyGate.ts
|
|
1116
|
-
function
|
|
1187
|
+
function Qe(e) {
|
|
1117
1188
|
let t, n = !1, r = !1, i = () => {
|
|
1118
1189
|
r || !n || t === void 0 || (r = !0, e(t));
|
|
1119
1190
|
};
|
|
@@ -1128,50 +1199,50 @@ function Ue(e) {
|
|
|
1128
1199
|
}
|
|
1129
1200
|
//#endregion
|
|
1130
1201
|
//#region src/v2/shims/embedBaseUrl.ts
|
|
1131
|
-
var
|
|
1132
|
-
function
|
|
1202
|
+
var $e = "https://player.liforma.ai/embed", et = "http://localhost:3002/embed";
|
|
1203
|
+
function tt() {
|
|
1133
1204
|
let e = globalThis.__LIFORMA_PLAYER_EMBED_URL;
|
|
1134
1205
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
1135
1206
|
if (typeof document > "u") return null;
|
|
1136
1207
|
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();
|
|
1137
1208
|
return t ? t.replace(/\/$/, "") : null;
|
|
1138
1209
|
}
|
|
1139
|
-
function
|
|
1140
|
-
let e =
|
|
1141
|
-
return e ? e.endsWith("/embed") ? e : `${e}/embed` : l() ?
|
|
1210
|
+
function nt() {
|
|
1211
|
+
let e = tt();
|
|
1212
|
+
return e ? e.endsWith("/embed") ? e : `${e}/embed` : l() ? et : $e;
|
|
1142
1213
|
}
|
|
1143
|
-
function
|
|
1214
|
+
function rt(e, t) {
|
|
1144
1215
|
return e?.trim() || t?.trim() || void 0;
|
|
1145
1216
|
}
|
|
1146
|
-
function
|
|
1147
|
-
let c = (e ??
|
|
1217
|
+
function it(e, t, n, r, i, a, o, s) {
|
|
1218
|
+
let c = (e ?? nt()).replace(/\/$/, ""), l = c.endsWith("/embed") ? c : `${c}/embed`, u = new URL(l), d = n?.trim();
|
|
1148
1219
|
d && (u.searchParams.set("backdropId", d), u.searchParams.set("locationId", d));
|
|
1149
1220
|
let f = r?.trim();
|
|
1150
|
-
return f && u.searchParams.set("avatarId", f), (i === "face" || i === "medium") && u.searchParams.set("fit", i), a === "widget" && u.searchParams.set("ui", "widget"), o && u.searchParams.set("close", "1"), t && u.searchParams.set("debug", "true"), (s === 2 || s === 3 || s === 4) && u.searchParams.set("cast", String(s)),
|
|
1221
|
+
return f && u.searchParams.set("avatarId", f), (i === "face" || i === "medium") && u.searchParams.set("fit", i), a === "widget" && u.searchParams.set("ui", "widget"), o && u.searchParams.set("close", "1"), t && u.searchParams.set("debug", "true"), (s === 2 || s === 3 || s === 4) && u.searchParams.set("cast", String(s)), at(u.toString());
|
|
1151
1222
|
}
|
|
1152
|
-
function
|
|
1223
|
+
function at(e) {
|
|
1153
1224
|
if (typeof location > "u") return e;
|
|
1154
1225
|
let t = new URL(e);
|
|
1155
1226
|
return t.searchParams.set("parentOrigin", location.origin), t.toString();
|
|
1156
1227
|
}
|
|
1157
|
-
function
|
|
1228
|
+
function ot(e) {
|
|
1158
1229
|
return new URL(e).origin;
|
|
1159
1230
|
}
|
|
1160
1231
|
//#endregion
|
|
1161
1232
|
//#region src/v2/experienceEvents.ts
|
|
1162
|
-
function
|
|
1233
|
+
function st() {
|
|
1163
1234
|
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)}`;
|
|
1164
1235
|
}
|
|
1165
|
-
function
|
|
1236
|
+
function ct(e, t, n) {
|
|
1166
1237
|
return {
|
|
1167
|
-
id:
|
|
1238
|
+
id: st(),
|
|
1168
1239
|
type: e,
|
|
1169
1240
|
sessionId: t,
|
|
1170
1241
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1171
1242
|
data: n
|
|
1172
1243
|
};
|
|
1173
1244
|
}
|
|
1174
|
-
function
|
|
1245
|
+
function lt() {
|
|
1175
1246
|
return {
|
|
1176
1247
|
ready: /* @__PURE__ */ new Set(),
|
|
1177
1248
|
started: /* @__PURE__ */ new Set(),
|
|
@@ -1190,32 +1261,32 @@ function et() {
|
|
|
1190
1261
|
conversationProcessorError: /* @__PURE__ */ new Set()
|
|
1191
1262
|
};
|
|
1192
1263
|
}
|
|
1193
|
-
function
|
|
1264
|
+
function ut(e, t, n) {
|
|
1194
1265
|
return e[t].add(n), () => e[t].delete(n);
|
|
1195
1266
|
}
|
|
1196
|
-
function
|
|
1267
|
+
function dt(e, t, n) {
|
|
1197
1268
|
for (let r of e[t]) r(n);
|
|
1198
1269
|
}
|
|
1199
|
-
function
|
|
1270
|
+
function ft(e) {
|
|
1200
1271
|
for (let t of Object.keys(e)) e[t].clear();
|
|
1201
1272
|
}
|
|
1202
1273
|
//#endregion
|
|
1203
1274
|
//#region src/v2/speech/types.ts
|
|
1204
|
-
function
|
|
1275
|
+
function pt(e) {
|
|
1205
1276
|
return "data" in e && "format" in e && e.format != null && !("track" in e);
|
|
1206
1277
|
}
|
|
1207
|
-
function
|
|
1278
|
+
function mt(e) {
|
|
1208
1279
|
return "url" in e && typeof e.url == "string";
|
|
1209
1280
|
}
|
|
1210
|
-
function
|
|
1281
|
+
function ht(e) {
|
|
1211
1282
|
if (!("track" in e)) return !1;
|
|
1212
1283
|
let t = e.track;
|
|
1213
1284
|
return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
|
|
1214
1285
|
}
|
|
1215
|
-
function
|
|
1216
|
-
return !
|
|
1286
|
+
function gt(e) {
|
|
1287
|
+
return !pt(e) && !mt(e) && !ht(e) && "encoding" in e && typeof e.encoding == "string";
|
|
1217
1288
|
}
|
|
1218
|
-
var
|
|
1289
|
+
var _t = [
|
|
1219
1290
|
8e3,
|
|
1220
1291
|
16e3,
|
|
1221
1292
|
22050,
|
|
@@ -1233,14 +1304,14 @@ var ct = [
|
|
|
1233
1304
|
MAX_UTTERANCE_DURATION_MS: 9e4,
|
|
1234
1305
|
MAX_PENDING_WRITES: 8,
|
|
1235
1306
|
DEFAULT_WRITE_TIMEOUT_MS: 5e3
|
|
1236
|
-
},
|
|
1307
|
+
}, vt = class extends Error {
|
|
1237
1308
|
operation;
|
|
1238
1309
|
requiredCapability;
|
|
1239
1310
|
name = "UnsupportedSpeechOperationError";
|
|
1240
1311
|
constructor(e, t) {
|
|
1241
1312
|
super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
|
|
1242
1313
|
}
|
|
1243
|
-
},
|
|
1314
|
+
}, yt = class extends Error {
|
|
1244
1315
|
name = "SpeechUtteranceClosedError";
|
|
1245
1316
|
constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
|
|
1246
1317
|
super(e);
|
|
@@ -1250,72 +1321,72 @@ var ct = [
|
|
|
1250
1321
|
constructor(e, t) {
|
|
1251
1322
|
super(e, t);
|
|
1252
1323
|
}
|
|
1253
|
-
},
|
|
1324
|
+
}, bt = class extends Error {
|
|
1254
1325
|
name = "SpeechBufferTimeoutError";
|
|
1255
1326
|
constructor(e = "Timed out waiting for speech buffer capacity.") {
|
|
1256
1327
|
super(e);
|
|
1257
1328
|
}
|
|
1258
1329
|
};
|
|
1259
|
-
function
|
|
1330
|
+
function xt(e = "none") {
|
|
1260
1331
|
return {
|
|
1261
1332
|
mode: e,
|
|
1262
1333
|
trackedDurationMs: 0,
|
|
1263
1334
|
fallbackDurationMs: 0
|
|
1264
1335
|
};
|
|
1265
1336
|
}
|
|
1266
|
-
function
|
|
1267
|
-
return
|
|
1337
|
+
function St(e) {
|
|
1338
|
+
return _t.includes(e);
|
|
1268
1339
|
}
|
|
1269
|
-
function
|
|
1340
|
+
function Ct(e) {
|
|
1270
1341
|
if (e.encoding !== "pcm_s16le") throw new Z(`Unsupported audio encoding: ${e.encoding}`);
|
|
1271
1342
|
if (e.channels !== 1) throw new Z(`Unsupported channel count: ${e.channels}`);
|
|
1272
|
-
if (!
|
|
1343
|
+
if (!St(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1273
1344
|
}
|
|
1274
|
-
function
|
|
1275
|
-
if (
|
|
1276
|
-
|
|
1345
|
+
function wt(e) {
|
|
1346
|
+
if (pt(e)) {
|
|
1347
|
+
Ct(e.format);
|
|
1277
1348
|
return;
|
|
1278
1349
|
}
|
|
1279
|
-
if (
|
|
1350
|
+
if (mt(e)) {
|
|
1280
1351
|
if (!e.url.trim()) throw new Z("Audio URL must be non-empty.");
|
|
1281
|
-
if (e.sampleRate !== void 0 && !
|
|
1352
|
+
if (e.sampleRate !== void 0 && !St(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1282
1353
|
return;
|
|
1283
1354
|
}
|
|
1284
|
-
if (
|
|
1355
|
+
if (ht(e)) {
|
|
1285
1356
|
if (e.track.kind !== "audio") throw new Z("speech.play track must be an audio MediaStreamTrack.");
|
|
1286
|
-
if (e.sampleRate !== void 0 && !
|
|
1357
|
+
if (e.sampleRate !== void 0 && !St(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1287
1358
|
return;
|
|
1288
1359
|
}
|
|
1289
|
-
if (
|
|
1360
|
+
if (gt(e)) {
|
|
1290
1361
|
let t = e.encoding.trim().toLowerCase();
|
|
1291
1362
|
if (!t) throw new Z("Encoded audio MIME type is required.");
|
|
1292
1363
|
if (t === "pcm_s16le") throw new Z("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
|
|
1293
|
-
if (e.sampleRate !== void 0 && !
|
|
1364
|
+
if (e.sampleRate !== void 0 && !St(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1294
1365
|
return;
|
|
1295
1366
|
}
|
|
1296
1367
|
throw new Z("Unsupported speech.play audio shape.");
|
|
1297
1368
|
}
|
|
1298
|
-
function
|
|
1299
|
-
if (e.format) return
|
|
1369
|
+
function Tt(e) {
|
|
1370
|
+
if (e.format) return Ct(e.format), e.format;
|
|
1300
1371
|
if (e.track) {
|
|
1301
1372
|
let t = {
|
|
1302
1373
|
encoding: "pcm_s16le",
|
|
1303
1374
|
sampleRate: e.sampleRate ?? 24e3,
|
|
1304
1375
|
channels: 1
|
|
1305
1376
|
};
|
|
1306
|
-
return
|
|
1377
|
+
return Ct(t), t;
|
|
1307
1378
|
}
|
|
1308
1379
|
throw new Z("createUtterance requires format or track.");
|
|
1309
1380
|
}
|
|
1310
|
-
function
|
|
1381
|
+
function Et(e) {
|
|
1311
1382
|
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1312
1383
|
}
|
|
1313
|
-
function
|
|
1384
|
+
function Dt(e) {
|
|
1314
1385
|
return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
|
|
1315
1386
|
}
|
|
1316
1387
|
//#endregion
|
|
1317
1388
|
//#region src/byo/pcm.ts
|
|
1318
|
-
function
|
|
1389
|
+
function Ot(e) {
|
|
1319
1390
|
let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
|
|
1320
1391
|
for (let t = 0; t < e.length; t++) {
|
|
1321
1392
|
let r = Math.max(-1, Math.min(1, e[t]));
|
|
@@ -1325,11 +1396,11 @@ function yt(e) {
|
|
|
1325
1396
|
}
|
|
1326
1397
|
//#endregion
|
|
1327
1398
|
//#region src/byo/resample.ts
|
|
1328
|
-
function
|
|
1399
|
+
function kt(e, t, n, r, i) {
|
|
1329
1400
|
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;
|
|
1330
1401
|
return ((a * i + o) * i + s) * i + c;
|
|
1331
1402
|
}
|
|
1332
|
-
function
|
|
1403
|
+
function At(e, t) {
|
|
1333
1404
|
if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
|
|
1334
1405
|
if (e === t) return {
|
|
1335
1406
|
fromRate: e,
|
|
@@ -1352,7 +1423,7 @@ function xt(e, t) {
|
|
|
1352
1423
|
let a = [];
|
|
1353
1424
|
for (; i + 2 < r.length - 1;) {
|
|
1354
1425
|
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);
|
|
1355
|
-
a.push(
|
|
1426
|
+
a.push(kt(r[o], r[e], r[s], r[c], t)), i += n;
|
|
1356
1427
|
}
|
|
1357
1428
|
let o = Math.max(0, Math.floor(i) - 1);
|
|
1358
1429
|
return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
|
|
@@ -1364,7 +1435,7 @@ function xt(e, t) {
|
|
|
1364
1435
|
}
|
|
1365
1436
|
//#endregion
|
|
1366
1437
|
//#region src/byo/audioCapture.ts
|
|
1367
|
-
var
|
|
1438
|
+
var jt = "liforma-pcm-capture", Mt = `
|
|
1368
1439
|
class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
1369
1440
|
process(inputs) {
|
|
1370
1441
|
const ch = inputs[0] && inputs[0][0];
|
|
@@ -1376,29 +1447,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
|
1376
1447
|
return true;
|
|
1377
1448
|
}
|
|
1378
1449
|
}
|
|
1379
|
-
registerProcessor('${
|
|
1380
|
-
`,
|
|
1381
|
-
function
|
|
1382
|
-
return
|
|
1450
|
+
registerProcessor('${jt}', LiformaPcmCaptureProcessor);
|
|
1451
|
+
`, Nt = null;
|
|
1452
|
+
function Pt() {
|
|
1453
|
+
return Nt ||= URL.createObjectURL(new Blob([Mt], { type: "application/javascript" })), Nt;
|
|
1383
1454
|
}
|
|
1384
|
-
function
|
|
1455
|
+
function Ft() {
|
|
1385
1456
|
return window.AudioContext || window.webkitAudioContext || null;
|
|
1386
1457
|
}
|
|
1387
|
-
async function
|
|
1388
|
-
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o =
|
|
1458
|
+
async function It(e) {
|
|
1459
|
+
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = Ft();
|
|
1389
1460
|
if (!o) throw Error("Web Audio is required for audio capture");
|
|
1390
1461
|
let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
|
|
1391
1462
|
l.gain.value = 0;
|
|
1392
|
-
let u = s.sampleRate, d =
|
|
1463
|
+
let u = s.sampleRate, d = At(u, n), f = !1, p = !1, m = (e) => {
|
|
1393
1464
|
if (f || i && !i()) return;
|
|
1394
1465
|
let t = d.push(e);
|
|
1395
|
-
t.length !== 0 && r(
|
|
1466
|
+
t.length !== 0 && r(Ot(t));
|
|
1396
1467
|
}, h = () => void 0;
|
|
1397
1468
|
return await (async () => {
|
|
1398
1469
|
if (typeof s.audioWorklet?.addModule != "function") return !1;
|
|
1399
1470
|
try {
|
|
1400
|
-
await s.audioWorklet.addModule(
|
|
1401
|
-
let e = new AudioWorkletNode(s,
|
|
1471
|
+
await s.audioWorklet.addModule(Pt());
|
|
1472
|
+
let e = new AudioWorkletNode(s, jt, {
|
|
1402
1473
|
numberOfInputs: 1,
|
|
1403
1474
|
numberOfOutputs: 1,
|
|
1404
1475
|
outputChannelCount: [1]
|
|
@@ -1448,7 +1519,7 @@ async function Dt(e) {
|
|
|
1448
1519
|
}
|
|
1449
1520
|
//#endregion
|
|
1450
1521
|
//#region src/v2/speech/captureMediaStreamTrack.ts
|
|
1451
|
-
async function
|
|
1522
|
+
async function Lt(e) {
|
|
1452
1523
|
let { track: t, utterance: n, sampleRate: r, signal: i } = e;
|
|
1453
1524
|
if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Z("MediaStreamTrack is not available in this environment.");
|
|
1454
1525
|
if (t.kind !== "audio") throw new Z("speech.play track must be an audio MediaStreamTrack.");
|
|
@@ -1457,13 +1528,13 @@ async function Ot(e) {
|
|
|
1457
1528
|
s || (s = !0, c?.stop(), c = null);
|
|
1458
1529
|
};
|
|
1459
1530
|
try {
|
|
1460
|
-
c = await
|
|
1531
|
+
c = await It({
|
|
1461
1532
|
mediaStream: a,
|
|
1462
1533
|
targetSampleRate: r,
|
|
1463
1534
|
shouldSend: () => !s && !i?.aborted,
|
|
1464
1535
|
onPcm: (e) => {
|
|
1465
1536
|
if (s || i?.aborted) return;
|
|
1466
|
-
let t =
|
|
1537
|
+
let t = Et(e);
|
|
1467
1538
|
o = o.then(async () => {
|
|
1468
1539
|
if (s || i?.aborted) return;
|
|
1469
1540
|
let e = 0;
|
|
@@ -1492,10 +1563,10 @@ async function Ot(e) {
|
|
|
1492
1563
|
}
|
|
1493
1564
|
//#endregion
|
|
1494
1565
|
//#region src/v2/speech/speechController.ts
|
|
1495
|
-
async function
|
|
1496
|
-
if (
|
|
1497
|
-
if (
|
|
1498
|
-
let t =
|
|
1566
|
+
async function Rt(e, t) {
|
|
1567
|
+
if (ht(e)) throw new Z("MediaStreamTrack play is handled on the host before embed.");
|
|
1568
|
+
if (pt(e)) {
|
|
1569
|
+
let t = Et(e.data);
|
|
1499
1570
|
if (t.byteLength & 1) throw new Z("PCM byte length must be even.");
|
|
1500
1571
|
return {
|
|
1501
1572
|
kind: "pcm",
|
|
@@ -1503,17 +1574,17 @@ async function kt(e, t) {
|
|
|
1503
1574
|
format: e.format
|
|
1504
1575
|
};
|
|
1505
1576
|
}
|
|
1506
|
-
if (
|
|
1577
|
+
if (mt(e)) return {
|
|
1507
1578
|
kind: "url",
|
|
1508
1579
|
url: e.url.trim(),
|
|
1509
1580
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
1510
1581
|
};
|
|
1511
|
-
if (!
|
|
1582
|
+
if (!gt(e)) throw new Z("Unsupported speech.play audio shape.");
|
|
1512
1583
|
let n;
|
|
1513
1584
|
if (typeof Blob < "u" && e.data instanceof Blob) {
|
|
1514
1585
|
if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
1515
1586
|
n = new Uint8Array(await e.data.arrayBuffer());
|
|
1516
|
-
} else n =
|
|
1587
|
+
} else n = Et(e.data);
|
|
1517
1588
|
return {
|
|
1518
1589
|
kind: "encoded",
|
|
1519
1590
|
data: n.slice().buffer,
|
|
@@ -1521,10 +1592,10 @@ async function kt(e, t) {
|
|
|
1521
1592
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
1522
1593
|
};
|
|
1523
1594
|
}
|
|
1524
|
-
function
|
|
1595
|
+
function zt() {
|
|
1525
1596
|
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)}`;
|
|
1526
1597
|
}
|
|
1527
|
-
function
|
|
1598
|
+
function Bt(e, t = "completed") {
|
|
1528
1599
|
return {
|
|
1529
1600
|
utteranceId: e.speechId,
|
|
1530
1601
|
characterId: e.characterId,
|
|
@@ -1538,13 +1609,13 @@ function jt(e, t = "completed") {
|
|
|
1538
1609
|
}
|
|
1539
1610
|
};
|
|
1540
1611
|
}
|
|
1541
|
-
function
|
|
1612
|
+
function Vt(e) {
|
|
1542
1613
|
return e instanceof Error ? e : new Z(String(e));
|
|
1543
1614
|
}
|
|
1544
|
-
function
|
|
1615
|
+
function Ht(e) {
|
|
1545
1616
|
return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
|
|
1546
1617
|
}
|
|
1547
|
-
var
|
|
1618
|
+
var Ut = class {
|
|
1548
1619
|
id;
|
|
1549
1620
|
characterId;
|
|
1550
1621
|
result;
|
|
@@ -1573,14 +1644,14 @@ var Pt = class {
|
|
|
1573
1644
|
queue: e.queue,
|
|
1574
1645
|
...e.transcript === void 0 ? {} : { transcript: e.transcript }
|
|
1575
1646
|
}).catch((e) => {
|
|
1576
|
-
throw this.fail(
|
|
1647
|
+
throw this.fail(Vt(e)), Vt(e);
|
|
1577
1648
|
}), this.signal?.addEventListener("abort", () => {
|
|
1578
1649
|
this.cancel();
|
|
1579
1650
|
}, { once: !0 });
|
|
1580
1651
|
}
|
|
1581
1652
|
async write(e, t) {
|
|
1582
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
1583
|
-
let n =
|
|
1653
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new yt();
|
|
1654
|
+
let n = Et(e);
|
|
1584
1655
|
if (n.byteLength & 1) throw new Z("PCM chunk byte length must be even (complete s16 samples).");
|
|
1585
1656
|
if (n.byteLength > X.MAX_CHUNK_BYTES) throw new Z(`PCM chunk exceeds MAX_CHUNK_BYTES (${X.MAX_CHUNK_BYTES}).`);
|
|
1586
1657
|
if (n.byteLength === 0) return;
|
|
@@ -1589,13 +1660,13 @@ var Pt = class {
|
|
|
1589
1660
|
let i = n.byteLength / 2 / this.sampleRate * 1e3;
|
|
1590
1661
|
if (this.bufferedMs + i > X.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new Z("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
|
|
1591
1662
|
let a = async () => {
|
|
1592
|
-
if (this.closed || this.settled) throw new
|
|
1663
|
+
if (this.closed || this.settled) throw new yt();
|
|
1593
1664
|
let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
|
|
1594
1665
|
utteranceId: this.id,
|
|
1595
1666
|
audio: t.buffer,
|
|
1596
1667
|
byteLength: t.byteLength
|
|
1597
1668
|
}), a = await Promise.race([i, new Promise((e, t) => {
|
|
1598
|
-
setTimeout(() => t(new
|
|
1669
|
+
setTimeout(() => t(new bt()), r);
|
|
1599
1670
|
})]);
|
|
1600
1671
|
this.bufferedMs = Math.max(0, a.bufferedMs);
|
|
1601
1672
|
}, o = this.writeChain.then(a, a);
|
|
@@ -1607,7 +1678,7 @@ var Pt = class {
|
|
|
1607
1678
|
}
|
|
1608
1679
|
}
|
|
1609
1680
|
async setTranscript(e) {
|
|
1610
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
1681
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new yt();
|
|
1611
1682
|
await this.requireHost().speechUtteranceSetTranscript({
|
|
1612
1683
|
utteranceId: this.id,
|
|
1613
1684
|
transcript: e
|
|
@@ -1624,7 +1695,7 @@ var Pt = class {
|
|
|
1624
1695
|
});
|
|
1625
1696
|
return this.resolve(t), t;
|
|
1626
1697
|
} catch (e) {
|
|
1627
|
-
let t =
|
|
1698
|
+
let t = Vt(e);
|
|
1628
1699
|
throw this.fail(t), t;
|
|
1629
1700
|
}
|
|
1630
1701
|
}
|
|
@@ -1642,11 +1713,11 @@ var Pt = class {
|
|
|
1642
1713
|
characterId: this.characterId,
|
|
1643
1714
|
status: "cancelled",
|
|
1644
1715
|
durationMs: 0,
|
|
1645
|
-
animation:
|
|
1716
|
+
animation: xt("none")
|
|
1646
1717
|
};
|
|
1647
1718
|
return this.resolve(t), t;
|
|
1648
1719
|
} catch (e) {
|
|
1649
|
-
let t =
|
|
1720
|
+
let t = Vt(e);
|
|
1650
1721
|
throw this.fail(t), t;
|
|
1651
1722
|
}
|
|
1652
1723
|
}
|
|
@@ -1659,7 +1730,7 @@ var Pt = class {
|
|
|
1659
1730
|
return e;
|
|
1660
1731
|
}
|
|
1661
1732
|
resolve(e) {
|
|
1662
|
-
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new
|
|
1733
|
+
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new yt()));
|
|
1663
1734
|
}
|
|
1664
1735
|
fail(e) {
|
|
1665
1736
|
this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
|
|
@@ -1671,7 +1742,7 @@ var Pt = class {
|
|
|
1671
1742
|
}
|
|
1672
1743
|
await new Promise((t, n) => {
|
|
1673
1744
|
let r = setTimeout(() => {
|
|
1674
|
-
n(new
|
|
1745
|
+
n(new bt());
|
|
1675
1746
|
}, e);
|
|
1676
1747
|
this.pendingWriteWaiters.push({
|
|
1677
1748
|
resolve: () => {
|
|
@@ -1690,13 +1761,13 @@ var Pt = class {
|
|
|
1690
1761
|
for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
|
|
1691
1762
|
}
|
|
1692
1763
|
};
|
|
1693
|
-
function
|
|
1764
|
+
function Wt(e) {
|
|
1694
1765
|
let t = null, n = (t, n) => {
|
|
1695
|
-
if (!e.getCapabilities()[n]) throw new
|
|
1766
|
+
if (!e.getCapabilities()[n]) throw new vt(t, n);
|
|
1696
1767
|
}, r = {
|
|
1697
1768
|
async speak(r) {
|
|
1698
1769
|
if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
|
|
1699
|
-
let i =
|
|
1770
|
+
let i = Dt(r.queue ?? "append");
|
|
1700
1771
|
i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
|
|
1701
1772
|
let a = e.getIframeHost();
|
|
1702
1773
|
if (!a) throw new Z("Speech session is not attached.");
|
|
@@ -1716,41 +1787,41 @@ function Ft(e) {
|
|
|
1716
1787
|
return;
|
|
1717
1788
|
}
|
|
1718
1789
|
t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
|
|
1719
|
-
t.removeEventListener("abort", s), n(
|
|
1790
|
+
t.removeEventListener("abort", s), n(Bt(e, "completed"));
|
|
1720
1791
|
}, (a) => {
|
|
1721
|
-
if (t.removeEventListener("abort", s),
|
|
1792
|
+
if (t.removeEventListener("abort", s), Ht(a)) {
|
|
1722
1793
|
n({
|
|
1723
1794
|
utteranceId: "utt_interrupted",
|
|
1724
1795
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
1725
1796
|
status: "interrupted",
|
|
1726
1797
|
durationMs: 0,
|
|
1727
1798
|
transcript: r.text,
|
|
1728
|
-
animation:
|
|
1799
|
+
animation: xt("none")
|
|
1729
1800
|
});
|
|
1730
1801
|
return;
|
|
1731
1802
|
}
|
|
1732
|
-
i(
|
|
1803
|
+
i(Vt(a));
|
|
1733
1804
|
});
|
|
1734
1805
|
});
|
|
1735
1806
|
}
|
|
1736
1807
|
try {
|
|
1737
|
-
return
|
|
1808
|
+
return Bt(await o, "completed");
|
|
1738
1809
|
} catch (t) {
|
|
1739
|
-
if (
|
|
1810
|
+
if (Ht(t)) return {
|
|
1740
1811
|
utteranceId: "utt_interrupted",
|
|
1741
1812
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
1742
1813
|
status: "interrupted",
|
|
1743
1814
|
durationMs: 0,
|
|
1744
1815
|
transcript: r.text,
|
|
1745
|
-
animation:
|
|
1816
|
+
animation: xt("none")
|
|
1746
1817
|
};
|
|
1747
|
-
throw
|
|
1818
|
+
throw Vt(t);
|
|
1748
1819
|
}
|
|
1749
1820
|
},
|
|
1750
1821
|
async play(i) {
|
|
1751
|
-
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"),
|
|
1822
|
+
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), wt(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
1752
1823
|
let a = i.queue ?? "append";
|
|
1753
|
-
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)),
|
|
1824
|
+
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), ht(i.audio)) {
|
|
1754
1825
|
let e = i.audio.sampleRate ?? 24e3;
|
|
1755
1826
|
return r.createUtterance({
|
|
1756
1827
|
format: {
|
|
@@ -1766,7 +1837,7 @@ function Ft(e) {
|
|
|
1766
1837
|
}
|
|
1767
1838
|
let o = e.getIframeHost();
|
|
1768
1839
|
if (!o) throw new Z("Speech session is not attached.");
|
|
1769
|
-
let s = await
|
|
1840
|
+
let s = await Rt(i.audio, i.signal);
|
|
1770
1841
|
return o.speechPlay({
|
|
1771
1842
|
source: s,
|
|
1772
1843
|
characterId: i.characterId,
|
|
@@ -1778,13 +1849,13 @@ function Ft(e) {
|
|
|
1778
1849
|
},
|
|
1779
1850
|
createUtterance(r) {
|
|
1780
1851
|
e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
|
|
1781
|
-
let i =
|
|
1852
|
+
let i = Tt(r);
|
|
1782
1853
|
if (r.track && r.track.kind !== "audio") throw new Z("createUtterance track must be an audio MediaStreamTrack.");
|
|
1783
1854
|
let a = r.queue ?? "replace-active";
|
|
1784
1855
|
if (a !== "replace-active" && a !== "replace-all") throw new Z("createUtterance queue must be replace-active or replace-all.");
|
|
1785
1856
|
e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
|
|
1786
|
-
let o = new
|
|
1787
|
-
id:
|
|
1857
|
+
let o = new Ut({
|
|
1858
|
+
id: zt(),
|
|
1788
1859
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
1789
1860
|
format: i,
|
|
1790
1861
|
queue: a,
|
|
@@ -1796,7 +1867,7 @@ function Ft(e) {
|
|
|
1796
1867
|
t === o && (t = null);
|
|
1797
1868
|
}), r.track && (async () => {
|
|
1798
1869
|
try {
|
|
1799
|
-
if (await
|
|
1870
|
+
if (await Lt({
|
|
1800
1871
|
track: r.track,
|
|
1801
1872
|
utterance: o,
|
|
1802
1873
|
sampleRate: i.sampleRate,
|
|
@@ -1824,16 +1895,16 @@ function Ft(e) {
|
|
|
1824
1895
|
}
|
|
1825
1896
|
//#endregion
|
|
1826
1897
|
//#region src/v2/types/sessionInteraction.ts
|
|
1827
|
-
function
|
|
1898
|
+
function Gt(e) {
|
|
1828
1899
|
let t = e?.trim();
|
|
1829
1900
|
return t === "full" || t === "face" || t === "medium" ? t : void 0;
|
|
1830
1901
|
}
|
|
1831
1902
|
//#endregion
|
|
1832
1903
|
//#region src/v2/experience.ts
|
|
1833
|
-
function
|
|
1904
|
+
function Kt(e) {
|
|
1834
1905
|
return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
|
|
1835
1906
|
}
|
|
1836
|
-
var
|
|
1907
|
+
var qt = class e {
|
|
1837
1908
|
bootstrap;
|
|
1838
1909
|
conversationProcessor;
|
|
1839
1910
|
iframeHost = null;
|
|
@@ -1848,16 +1919,16 @@ var Rt = class e {
|
|
|
1848
1919
|
attached = !1;
|
|
1849
1920
|
pendingFit = null;
|
|
1850
1921
|
closeHandlers = [];
|
|
1851
|
-
eventRegistry =
|
|
1922
|
+
eventRegistry = lt();
|
|
1852
1923
|
readyEnvelope = null;
|
|
1853
1924
|
startedEnvelope = null;
|
|
1854
1925
|
conversationCache = [];
|
|
1855
1926
|
speech;
|
|
1856
1927
|
constructor(e) {
|
|
1857
|
-
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 =
|
|
1928
|
+
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 = Wt({
|
|
1858
1929
|
getIframeHost: () => this.iframeHost,
|
|
1859
1930
|
assertSessionStarted: () => this.assertSessionStarted(),
|
|
1860
|
-
getCapabilities: () =>
|
|
1931
|
+
getCapabilities: () => Jt(this.resolvedSession),
|
|
1861
1932
|
getActiveCharacterId: () => "character_unknown",
|
|
1862
1933
|
onProcessorInterrupt: () => {
|
|
1863
1934
|
this.processorAbortController?.abort(), this.processorAbortController = null;
|
|
@@ -1901,6 +1972,7 @@ var Rt = class e {
|
|
|
1901
1972
|
mode: t.mode,
|
|
1902
1973
|
speechInputMode: t.speechInputMode,
|
|
1903
1974
|
speechOnly: t.speechOnly,
|
|
1975
|
+
attribution: t.attribution,
|
|
1904
1976
|
ui: t.ui,
|
|
1905
1977
|
onStart: t.onStart,
|
|
1906
1978
|
onUserTranscript: t.onUserTranscript,
|
|
@@ -1922,6 +1994,7 @@ var Rt = class e {
|
|
|
1922
1994
|
mode: t.mode,
|
|
1923
1995
|
speechInputMode: t.speechInputMode,
|
|
1924
1996
|
speechOnly: t.speechOnly,
|
|
1997
|
+
attribution: t.attribution,
|
|
1925
1998
|
ui: t.ui,
|
|
1926
1999
|
onStart: t.onStart,
|
|
1927
2000
|
onUserTranscript: t.onUserTranscript,
|
|
@@ -1936,7 +2009,7 @@ var Rt = class e {
|
|
|
1936
2009
|
return null;
|
|
1937
2010
|
}
|
|
1938
2011
|
on(e, t) {
|
|
1939
|
-
let n =
|
|
2012
|
+
let n = ut(this.eventRegistry, e, t);
|
|
1940
2013
|
return e === "ready" && this.readyEnvelope && queueMicrotask(() => t(this.readyEnvelope)), e === "started" && this.startedEnvelope && queueMicrotask(() => t(this.startedEnvelope)), n;
|
|
1941
2014
|
}
|
|
1942
2015
|
async attach(e) {
|
|
@@ -1950,13 +2023,13 @@ var Rt = class e {
|
|
|
1950
2023
|
if (this.closed) throw Error("Session has ended.");
|
|
1951
2024
|
if (this.attached && this.iframeHost) return this.createPlayerFacade();
|
|
1952
2025
|
this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
|
|
1953
|
-
let t = this.bootstrap.embedBaseUrl ??
|
|
2026
|
+
let t = this.bootstrap.embedBaseUrl ?? nt(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = it(t, n, r ? void 0 : rt(this.bootstrap.backdropId, this.bootstrap.locationId), r ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, Kt(e), this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.castSize), a = ot(i), o = null, s = new Promise((e) => {
|
|
1954
2027
|
o = e;
|
|
1955
2028
|
}), c = null, l = new Promise((e) => {
|
|
1956
2029
|
c = e;
|
|
1957
|
-
}), u =
|
|
2030
|
+
}), u = Qe((e) => {
|
|
1958
2031
|
this.readyEnvelope ||= (this.resolvedSession = e, this.emitWrapped("ready", { session: e }));
|
|
1959
|
-
}), d = this.bootstrap.onUserTranscript, f =
|
|
2032
|
+
}), d = this.bootstrap.onUserTranscript, f = Ze({
|
|
1960
2033
|
container: e.container,
|
|
1961
2034
|
src: i,
|
|
1962
2035
|
playerOrigin: a,
|
|
@@ -2019,7 +2092,7 @@ var Rt = class e {
|
|
|
2019
2092
|
onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t)
|
|
2020
2093
|
});
|
|
2021
2094
|
this.iframeHost = f;
|
|
2022
|
-
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(),
|
|
2095
|
+
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), J(this.bootstrap.sessionEndpoint, {
|
|
2023
2096
|
experienceId: this.bootstrap.experienceId,
|
|
2024
2097
|
locale: this.bootstrap.locale,
|
|
2025
2098
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
@@ -2028,15 +2101,17 @@ var Rt = class e {
|
|
|
2028
2101
|
mode: p.mode,
|
|
2029
2102
|
speechInputMode: p.speechInputMode,
|
|
2030
2103
|
speechOnly: this.bootstrap.speechOnly,
|
|
2104
|
+
attribution: this.bootstrap.attribution,
|
|
2031
2105
|
signal: this.endpointAbortController.signal
|
|
2032
|
-
})) : this.bootstrap.kind === "public" ?
|
|
2106
|
+
})) : this.bootstrap.kind === "public" ? ke(this.bootstrap.experienceId, {
|
|
2033
2107
|
locale: this.bootstrap.locale,
|
|
2034
2108
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
2035
2109
|
learningLocale: this.bootstrap.learningLocale,
|
|
2036
2110
|
language: this.bootstrap.language,
|
|
2037
2111
|
mode: p.mode,
|
|
2038
2112
|
speechInputMode: p.speechInputMode,
|
|
2039
|
-
speechOnly: this.bootstrap.speechOnly
|
|
2113
|
+
speechOnly: this.bootstrap.speechOnly,
|
|
2114
|
+
attribution: this.bootstrap.attribution
|
|
2040
2115
|
}) : Promise.resolve(this.bootstrap.session ? {
|
|
2041
2116
|
session: this.bootstrap.session,
|
|
2042
2117
|
launch: this.bootstrap.launch
|
|
@@ -2051,11 +2126,13 @@ var Rt = class e {
|
|
|
2051
2126
|
f.postParentHello();
|
|
2052
2127
|
let g = h?.launch ?? (this.bootstrap.kind === "launch" ? this.bootstrap.launch : null), _ = h?.session ?? (this.bootstrap.kind === "launch" ? this.bootstrap.session : void 0);
|
|
2053
2128
|
if (!g) throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), Error("Session Launch response did not include a launch token.");
|
|
2054
|
-
return this.launchToken = g, _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" &&
|
|
2129
|
+
return this.launchToken = g, _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" && Se(_), f.postLaunch(g, _, {
|
|
2055
2130
|
startButton: e.startButton,
|
|
2131
|
+
theme: e.theme,
|
|
2056
2132
|
showFeedback: e.showFeedback
|
|
2057
2133
|
}), u.setValue(_)) : f.postLaunch(g, void 0, {
|
|
2058
2134
|
startButton: e.startButton,
|
|
2135
|
+
theme: e.theme,
|
|
2059
2136
|
showFeedback: e.showFeedback
|
|
2060
2137
|
}), await Promise.race([s, new Promise((e, t) => {
|
|
2061
2138
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player loading UI.")), 12e4);
|
|
@@ -2085,11 +2162,16 @@ var Rt = class e {
|
|
|
2085
2162
|
this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
|
|
2086
2163
|
}
|
|
2087
2164
|
async setFit(e) {
|
|
2088
|
-
let t =
|
|
2165
|
+
let t = Gt(e);
|
|
2089
2166
|
if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
|
|
2090
2167
|
if (this.closed) throw Error("Session has ended.");
|
|
2091
2168
|
this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
|
|
2092
2169
|
}
|
|
2170
|
+
async conversion(e) {
|
|
2171
|
+
if (this.closed) throw Error("Session has ended.");
|
|
2172
|
+
if (!this.iframeHost) throw Error("conversion() requires attach() first.");
|
|
2173
|
+
await this.iframeHost.conversion(e);
|
|
2174
|
+
}
|
|
2093
2175
|
getLastTurn() {
|
|
2094
2176
|
if (this.conversationCache.length === 0) return [];
|
|
2095
2177
|
let e = this.conversationCache[this.conversationCache.length - 1].turnId;
|
|
@@ -2099,7 +2181,7 @@ var Rt = class e {
|
|
|
2099
2181
|
this.close();
|
|
2100
2182
|
}
|
|
2101
2183
|
destroy() {
|
|
2102
|
-
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,
|
|
2184
|
+
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, ft(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.attached = !1);
|
|
2103
2185
|
}
|
|
2104
2186
|
resolveMintInteraction() {
|
|
2105
2187
|
return this.bootstrap.kind === "launch" ? {} : {
|
|
@@ -2111,8 +2193,8 @@ var Rt = class e {
|
|
|
2111
2193
|
return this.resolvedSession?.id ?? "";
|
|
2112
2194
|
}
|
|
2113
2195
|
emitWrapped(e, t) {
|
|
2114
|
-
let n =
|
|
2115
|
-
return
|
|
2196
|
+
let n = ct(e, this.getSessionId(), t);
|
|
2197
|
+
return dt(this.eventRegistry, e, n), n;
|
|
2116
2198
|
}
|
|
2117
2199
|
queueProcessorTurn(e) {
|
|
2118
2200
|
if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
|
|
@@ -2121,7 +2203,7 @@ var Rt = class e {
|
|
|
2121
2203
|
let n = this.processorAbortController.signal;
|
|
2122
2204
|
this.processorChain = this.processorChain.then(async () => {
|
|
2123
2205
|
if (!n.aborted) try {
|
|
2124
|
-
let r = await
|
|
2206
|
+
let r = await Me(t, {
|
|
2125
2207
|
utteranceId: e.utteranceId,
|
|
2126
2208
|
text: e.text,
|
|
2127
2209
|
conversation: this.conversationCache,
|
|
@@ -2171,7 +2253,7 @@ var Rt = class e {
|
|
|
2171
2253
|
};
|
|
2172
2254
|
}
|
|
2173
2255
|
};
|
|
2174
|
-
function
|
|
2256
|
+
function Jt(e) {
|
|
2175
2257
|
return e ? {
|
|
2176
2258
|
textSpeech: e.capabilities.speech.output,
|
|
2177
2259
|
externalSpeechAudio: e.capabilities.speech.externalAudio
|
|
@@ -2182,26 +2264,26 @@ function zt(e) {
|
|
|
2182
2264
|
}
|
|
2183
2265
|
//#endregion
|
|
2184
2266
|
//#region src/widget/dockGeometry.ts
|
|
2185
|
-
var
|
|
2186
|
-
function
|
|
2267
|
+
var Yt = "(min-width: 768px)", Xt = 24, Zt = .5, Qt = 1200, $t = .85, en = 9 / 16;
|
|
2268
|
+
function tn() {
|
|
2187
2269
|
if (typeof window > "u") return 800;
|
|
2188
2270
|
let e = window.screen?.availHeight;
|
|
2189
2271
|
return typeof e == "number" && e > 0 ? e : window.innerHeight;
|
|
2190
2272
|
}
|
|
2191
|
-
function
|
|
2192
|
-
let i = Math.max(160, Math.min(t - n * 2, t *
|
|
2193
|
-
return s > a && (s = a, o = s /
|
|
2273
|
+
function nn(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = Xt, r = typeof window < "u" ? tn() : 800) {
|
|
2274
|
+
let i = Math.max(160, Math.min(t - n * 2, t * $t)), a = Math.max(120, e - n * 2), o = Math.min(r * Zt, Qt, i), s = o * en;
|
|
2275
|
+
return s > a && (s = a, o = s / en, o > i && (o = i, s = o * en)), {
|
|
2194
2276
|
width: Math.round(s),
|
|
2195
2277
|
height: Math.round(o)
|
|
2196
2278
|
};
|
|
2197
2279
|
}
|
|
2198
|
-
function
|
|
2280
|
+
function rn(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = Xt) {
|
|
2199
2281
|
return {
|
|
2200
2282
|
left: Math.max(r, t - e.width - r),
|
|
2201
2283
|
top: Math.max(r, n - e.height - r)
|
|
2202
2284
|
};
|
|
2203
2285
|
}
|
|
2204
|
-
function
|
|
2286
|
+
function an(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = Xt) {
|
|
2205
2287
|
let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
|
|
2206
2288
|
return {
|
|
2207
2289
|
left: Math.min(Math.max(a, e), o),
|
|
@@ -2209,14 +2291,14 @@ function Yt(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typ
|
|
|
2209
2291
|
};
|
|
2210
2292
|
}
|
|
2211
2293
|
function Q(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
|
|
2212
|
-
return e(
|
|
2294
|
+
return e(Yt).matches;
|
|
2213
2295
|
}
|
|
2214
2296
|
//#endregion
|
|
2215
2297
|
//#region src/widget/mountExperienceWidget.ts
|
|
2216
|
-
function
|
|
2298
|
+
function on(e) {
|
|
2217
2299
|
return e === "bottom-right" || e === "bottom-left" ? e : "static";
|
|
2218
2300
|
}
|
|
2219
|
-
function
|
|
2301
|
+
function sn(e) {
|
|
2220
2302
|
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
2221
2303
|
let t = typeof e == "string" ? e.trim() : "";
|
|
2222
2304
|
return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
|
|
@@ -2224,8 +2306,8 @@ function Zt(e) {
|
|
|
2224
2306
|
function $(e) {
|
|
2225
2307
|
return e === "expanded" || e === "docked";
|
|
2226
2308
|
}
|
|
2227
|
-
var
|
|
2228
|
-
function
|
|
2309
|
+
var cn = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 0 0-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 0 0-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 0 0-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 0 0-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 0 0 1.066-2.573c-.94-1.543.826-3.31 2.37-2.37c1 .608 2.296.07 2.572-1.065\"/><path d=\"M9 12a3 3 0 1 0 6 0a3 3 0 0 0-6 0\"/></svg>", ln = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\"><path fill=\"currentColor\" d=\"M18.3 5.71a1 1 0 0 0-1.41 0L12 10.59 7.11 5.7A1 1 0 0 0 5.7 7.11L10.59 12l-4.9 4.89a1 1 0 1 0 1.42 1.42L12 13.41l4.89 4.9a1 1 0 0 0 1.42-1.42L13.41 12l4.9-4.89a1 1 0 0 0-.01-1.4Z\"/></svg>", un = "<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>", dn = "<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>";
|
|
2310
|
+
function fn(e, t, n) {
|
|
2229
2311
|
re(I);
|
|
2230
2312
|
let r = c({
|
|
2231
2313
|
galleryThumb: t.galleryThumb,
|
|
@@ -2255,7 +2337,7 @@ function nn(e, t, n) {
|
|
|
2255
2337
|
}
|
|
2256
2338
|
return e.replaceChildren(i), n?.parallax === !1 ? () => {} : ne(i);
|
|
2257
2339
|
}
|
|
2258
|
-
function
|
|
2340
|
+
function pn(e) {
|
|
2259
2341
|
return e.startButton ? {
|
|
2260
2342
|
...e.startButton,
|
|
2261
2343
|
label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
|
|
@@ -2267,7 +2349,7 @@ function rn(e) {
|
|
|
2267
2349
|
variant: "primary"
|
|
2268
2350
|
};
|
|
2269
2351
|
}
|
|
2270
|
-
function
|
|
2352
|
+
function mn(e) {
|
|
2271
2353
|
let t = !1, n = () => {
|
|
2272
2354
|
t || e();
|
|
2273
2355
|
}, r = () => {
|
|
@@ -2287,12 +2369,12 @@ function an(e) {
|
|
|
2287
2369
|
t = !0, window.removeEventListener("load", r), i?.();
|
|
2288
2370
|
};
|
|
2289
2371
|
}
|
|
2290
|
-
function
|
|
2372
|
+
function hn(e, t) {
|
|
2291
2373
|
oe(ie);
|
|
2292
2374
|
let n = t.experienceId?.trim();
|
|
2293
2375
|
if (!n) throw Error("ExperienceWidget requires experienceId.");
|
|
2294
|
-
let r = t.prefetch ?? "onExpand", i =
|
|
2295
|
-
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",
|
|
2376
|
+
let r = t.prefetch ?? "onExpand", i = on(t.position), a = document.createElement("div");
|
|
2377
|
+
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", sn(t.offset));
|
|
2296
2378
|
let o = document.createElement("button");
|
|
2297
2379
|
o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
|
|
2298
2380
|
let s = document.createElement("div");
|
|
@@ -2312,22 +2394,22 @@ function on(e, t) {
|
|
|
2312
2394
|
let m = document.createElement("span");
|
|
2313
2395
|
m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
|
|
2314
2396
|
let h = document.createElement("button");
|
|
2315
|
-
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML =
|
|
2397
|
+
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = un, h.setAttribute("aria-label", "Reduce");
|
|
2316
2398
|
let g = document.createElement("button");
|
|
2317
|
-
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML =
|
|
2399
|
+
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = cn, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
|
|
2318
2400
|
let _ = document.createElement("button");
|
|
2319
|
-
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML =
|
|
2401
|
+
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = ln, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
|
|
2320
2402
|
let v = document.createElement("div");
|
|
2321
2403
|
v.className = "liforma-ew__stage";
|
|
2322
2404
|
let y = document.createElement("div");
|
|
2323
2405
|
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);
|
|
2324
|
-
let b = null, x = !1, S = !1,
|
|
2406
|
+
let b = null, x = !1, S = !1, C = !1, w = !1, T = !1, E = !1, D = !1, O = 0, k = "", A = null, j = null, M = null, ee = null, N = null, P = null, F = null, te = 0, ne = 0, I = null, L = !1, re = new AbortController(), ae = t.parallax !== !1, R = () => {
|
|
2325
2407
|
let e = a.dataset.state;
|
|
2326
2408
|
return e === "expanded" || e === "docked" || e === "collapsed" ? e : "collapsed";
|
|
2327
2409
|
}, z = () => {
|
|
2328
|
-
|
|
2410
|
+
M !== null && (clearTimeout(M), M = null);
|
|
2329
2411
|
}, se = () => {
|
|
2330
|
-
|
|
2412
|
+
ee !== null && (clearTimeout(ee), ee = null), a.classList.remove("liforma-ew--layout-settling");
|
|
2331
2413
|
}, ce = () => {
|
|
2332
2414
|
for (let e of [
|
|
2333
2415
|
f,
|
|
@@ -2344,11 +2426,11 @@ function on(e, t) {
|
|
|
2344
2426
|
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";
|
|
2345
2427
|
}, B = (e, t) => {
|
|
2346
2428
|
if (R() !== "docked") return;
|
|
2347
|
-
let n =
|
|
2429
|
+
let n = nn(), r = an(e - te, t - ne, n);
|
|
2348
2430
|
N = r.left, P = r.top, le(r.left, r.top, n.width, n.height);
|
|
2349
2431
|
}, de = (e, t) => {
|
|
2350
2432
|
if (R() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
|
|
2351
|
-
let n =
|
|
2433
|
+
let n = nn(), r = N ?? f.getBoundingClientRect().left, i = P ?? f.getBoundingClientRect().top, a = an(r + e, i + t, n);
|
|
2352
2434
|
N = a.left, P = a.top, le(a.left, a.top, n.width, n.height);
|
|
2353
2435
|
}, fe = (e) => {
|
|
2354
2436
|
I === "toolbar" && (F === null || e.pointerId !== F || (e.preventDefault(), B(e.clientX, e.clientY)));
|
|
@@ -2361,89 +2443,89 @@ function on(e, t) {
|
|
|
2361
2443
|
F = n, I = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2362
2444
|
let r = f.getBoundingClientRect();
|
|
2363
2445
|
te = e - r.left, ne = t - r.top, L || (L = !0, window.addEventListener("pointermove", fe), window.addEventListener("pointerup", V), window.addEventListener("pointercancel", V));
|
|
2364
|
-
},
|
|
2446
|
+
}, H = (e) => {
|
|
2365
2447
|
if (S || R() !== "docked" || !Q() || F !== null) return;
|
|
2366
2448
|
F = e.pointerId, I = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2367
2449
|
let t = f.getBoundingClientRect();
|
|
2368
2450
|
N = t.left, P = t.top;
|
|
2369
|
-
},
|
|
2451
|
+
}, me = (e) => {
|
|
2370
2452
|
I === "player" && (F === null || e.pointerId !== F || de(e.dx, e.dy));
|
|
2371
|
-
},
|
|
2453
|
+
}, he = (e) => {
|
|
2372
2454
|
I === "player" && (F === null || e.pointerId !== F || V());
|
|
2373
|
-
},
|
|
2455
|
+
}, U = () => {
|
|
2374
2456
|
let e = Q(), t = R();
|
|
2375
2457
|
if (!e || t !== "expanded" && t !== "docked") {
|
|
2376
2458
|
h.hidden = !0;
|
|
2377
2459
|
return;
|
|
2378
2460
|
}
|
|
2379
|
-
h.hidden = !1, t === "docked" ? (h.innerHTML =
|
|
2380
|
-
},
|
|
2381
|
-
let t =
|
|
2382
|
-
n =
|
|
2383
|
-
},
|
|
2461
|
+
h.hidden = !1, t === "docked" ? (h.innerHTML = dn, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = un, h.setAttribute("aria-label", "Reduce"));
|
|
2462
|
+
}, ge = (e) => {
|
|
2463
|
+
let t = nn(), n = e && N !== null && P !== null ? an(N, P, t) : rn(t);
|
|
2464
|
+
n = an(n.left, n.top, t), N = n.left, P = n.top, le(n.left, n.top, t.width, t.height), U();
|
|
2465
|
+
}, _e = () => {
|
|
2384
2466
|
a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
|
|
2385
2467
|
requestAnimationFrame(() => {
|
|
2386
2468
|
S || !$(a.dataset.state) || a.classList.add("liforma-ew--session-revealed");
|
|
2387
2469
|
});
|
|
2388
2470
|
});
|
|
2389
|
-
},
|
|
2390
|
-
if (se(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !
|
|
2471
|
+
}, W = (e) => {
|
|
2472
|
+
if (se(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !D) {
|
|
2391
2473
|
a.classList.remove("liforma-ew--layout-settling");
|
|
2392
2474
|
return;
|
|
2393
2475
|
}
|
|
2394
|
-
|
|
2395
|
-
if (
|
|
2476
|
+
ee = setTimeout(() => {
|
|
2477
|
+
if (ee = null, S || !$(a.dataset.state)) {
|
|
2396
2478
|
a.classList.remove("liforma-ew--layout-settling");
|
|
2397
2479
|
return;
|
|
2398
2480
|
}
|
|
2399
|
-
a.classList.remove("liforma-ew--layout-settling"),
|
|
2481
|
+
a.classList.remove("liforma-ew--layout-settling"), _e();
|
|
2400
2482
|
}, 220);
|
|
2401
|
-
},
|
|
2402
|
-
z(),
|
|
2403
|
-
|
|
2483
|
+
}, G = () => (a.classList.add("liforma-ew--session-concealing"), a.classList.remove("liforma-ew--session-revealed"), new Promise((e) => {
|
|
2484
|
+
z(), M = setTimeout(() => {
|
|
2485
|
+
M = null, a.classList.remove("liforma-ew--session-concealing"), e();
|
|
2404
2486
|
}, 280);
|
|
2405
|
-
})),
|
|
2487
|
+
})), ve = {
|
|
2406
2488
|
galleryThumb: t.galleryThumb,
|
|
2407
2489
|
avatarImage: t.avatarImage,
|
|
2408
2490
|
backgroundImage: t.backgroundImage,
|
|
2409
2491
|
foregroundImage: t.foregroundImage,
|
|
2410
2492
|
fallbackImage: t.fallbackImage
|
|
2411
|
-
},
|
|
2493
|
+
}, K = (e) => {
|
|
2412
2494
|
if (!e) {
|
|
2413
2495
|
y.hidden = !0, y.textContent = "";
|
|
2414
2496
|
return;
|
|
2415
2497
|
}
|
|
2416
2498
|
y.hidden = !1, y.textContent = e;
|
|
2417
|
-
},
|
|
2499
|
+
}, ye = (e) => {
|
|
2418
2500
|
if (!e) {
|
|
2419
2501
|
c.hidden = !0, c.textContent = "";
|
|
2420
2502
|
return;
|
|
2421
2503
|
}
|
|
2422
2504
|
c.hidden = !1, c.textContent = e, s.contains(c) || s.append(c);
|
|
2505
|
+
}, be = () => {
|
|
2506
|
+
C = !0, o.disabled = !1, ye(null), r === "onExpand" && t.onPrefetchReady?.();
|
|
2423
2507
|
}, xe = () => {
|
|
2424
|
-
|
|
2425
|
-
}, Se = () => {
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
if (Ce(ye)) {
|
|
2433
|
-
xe();
|
|
2508
|
+
w = !0, a.dataset.warm = "true", l.hidden = !1, D || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
|
|
2509
|
+
}, Se = (e) => {
|
|
2510
|
+
A?.(), A = null;
|
|
2511
|
+
let t = fn(s, e, { parallax: ae });
|
|
2512
|
+
return t ? (A = t, !0) : !1;
|
|
2513
|
+
}, Ce = () => {
|
|
2514
|
+
if (Se(ve)) {
|
|
2515
|
+
be();
|
|
2434
2516
|
return;
|
|
2435
2517
|
}
|
|
2436
|
-
|
|
2518
|
+
ye("Loading…"), ue(n, { signal: re.signal }).then((e) => {
|
|
2437
2519
|
if (!S) {
|
|
2438
|
-
if (!
|
|
2439
|
-
|
|
2520
|
+
if (!Se({ galleryThumb: e.galleryThumb })) throw Error("Experience preview is missing gallery thumb images.");
|
|
2521
|
+
be();
|
|
2440
2522
|
}
|
|
2441
2523
|
}).catch((e) => {
|
|
2442
2524
|
if (S || re.signal.aborted) return;
|
|
2443
2525
|
let n = e instanceof Error ? e : Error(String(e));
|
|
2444
|
-
|
|
2526
|
+
ye("Preview unavailable"), o.disabled = !0, t.onError?.(n), console.error("[ExperienceWidget]", n);
|
|
2445
2527
|
});
|
|
2446
|
-
},
|
|
2528
|
+
}, we = () => ({
|
|
2447
2529
|
experienceId: n,
|
|
2448
2530
|
ui: "widget",
|
|
2449
2531
|
...t.sessionEndpoint ? { sessionEndpoint: t.sessionEndpoint } : {},
|
|
@@ -2453,70 +2535,70 @@ function on(e, t) {
|
|
|
2453
2535
|
...t.speechInputMode ? { speechInputMode: t.speechInputMode } : {},
|
|
2454
2536
|
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
|
|
2455
2537
|
...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
|
|
2456
|
-
}),
|
|
2538
|
+
}), Te = () => ({
|
|
2457
2539
|
...t.fit ? { fit: t.fit } : {},
|
|
2458
|
-
startButton:
|
|
2540
|
+
startButton: pn(t),
|
|
2459
2541
|
...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback }
|
|
2460
|
-
}),
|
|
2461
|
-
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), ce(), a.dataset.state = "expanded",
|
|
2462
|
-
},
|
|
2463
|
-
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked",
|
|
2464
|
-
},
|
|
2542
|
+
}), q = (e = !0) => {
|
|
2543
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), ce(), a.dataset.state = "expanded", K(null), typeof document < "u" && (k = document.body.style.overflow, document.body.style.overflow = "hidden"), U(), e && t.onExpanded?.();
|
|
2544
|
+
}, Ee = () => {
|
|
2545
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked", K(null), typeof document < "u" && (document.body.style.overflow = k), ge(!0), U(), b?.setWidgetChrome("docked");
|
|
2546
|
+
}, De = (e) => {
|
|
2465
2547
|
e.on("started", () => {
|
|
2466
|
-
S || (
|
|
2548
|
+
S || (D = !0, a.dataset.live = "true", K(null), t.onStarted?.(), $(a.dataset.state) && _e());
|
|
2467
2549
|
}), e.on("feedback", (e) => {
|
|
2468
2550
|
S || t.onFeedback?.(e);
|
|
2469
2551
|
}), e.on("feedbackFailed", (e) => {
|
|
2470
2552
|
S || t.onFeedbackFailed?.(e);
|
|
2471
2553
|
});
|
|
2554
|
+
}, Oe = () => {
|
|
2555
|
+
se(), u.hidden = !0, p.hidden = !0, ce(), 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), K(null), typeof document < "u" && (document.body.style.overflow = k), U();
|
|
2472
2556
|
}, ke = () => {
|
|
2473
|
-
|
|
2474
|
-
}, Ae = () => {
|
|
2475
|
-
z(), se(), D += 1, x = !1, C = !1, w = !1, T = !1, E = !1;
|
|
2557
|
+
z(), se(), O += 1, x = !1, w = !1, T = !1, E = !1, D = !1;
|
|
2476
2558
|
let e = b;
|
|
2477
2559
|
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");
|
|
2478
|
-
},
|
|
2560
|
+
}, J = () => {
|
|
2479
2561
|
if (!S && $(a.dataset.state)) {
|
|
2480
|
-
if (V(), x = !1, b &&
|
|
2562
|
+
if (V(), x = !1, b && E) {
|
|
2481
2563
|
let e = b;
|
|
2482
2564
|
(async () => {
|
|
2483
|
-
|
|
2565
|
+
D && (await G(), S || b !== e) || (w && e.setWidgetChrome("collapsed"), Oe(), D ? (a.dataset.live = "true", o.tabIndex = 0, o.removeAttribute("aria-hidden"), o.disabled = !1) : w && xe(), t.onCollapsed?.(), t.onClose?.());
|
|
2484
2566
|
})();
|
|
2485
2567
|
return;
|
|
2486
2568
|
}
|
|
2487
|
-
|
|
2569
|
+
ke(), Oe(), t.onCollapsed?.(), t.onClose?.();
|
|
2488
2570
|
}
|
|
2489
|
-
},
|
|
2490
|
-
S || Q() && R() === "expanded" &&
|
|
2491
|
-
|
|
2571
|
+
}, Ae = () => {
|
|
2572
|
+
S || Q() && R() === "expanded" && W(() => {
|
|
2573
|
+
Ee();
|
|
2492
2574
|
});
|
|
2493
|
-
},
|
|
2494
|
-
S || R() === "docked" && (V(),
|
|
2495
|
-
ce(),
|
|
2575
|
+
}, je = () => {
|
|
2576
|
+
S || R() === "docked" && (V(), W(() => {
|
|
2577
|
+
ce(), q(!1), b?.setWidgetChrome("expanded");
|
|
2496
2578
|
}));
|
|
2497
2579
|
}, Me = () => {
|
|
2498
|
-
!b || !
|
|
2580
|
+
!b || !D || (z(), a.classList.remove("liforma-ew--session-revealed"), q(), b.setWidgetChrome("expanded"), x = !1, _e());
|
|
2499
2581
|
}, Ne = () => {
|
|
2500
|
-
!b || !
|
|
2582
|
+
!b || !E || D || (z(), a.classList.remove("liforma-ew--session-revealed"), q(), x = !1, w || b.setWidgetChrome("expanded"));
|
|
2501
2583
|
}, Pe = (e) => {
|
|
2502
|
-
S || e !==
|
|
2584
|
+
S || e !== O && !D || (z(), a.classList.remove("liforma-ew--session-revealed"), q(), x = !1, D && _e());
|
|
2503
2585
|
}, Fe = () => {
|
|
2504
|
-
if (S ||
|
|
2505
|
-
|
|
2506
|
-
let e =
|
|
2586
|
+
if (S || T || w || b || $(a.dataset.state)) return;
|
|
2587
|
+
T = !0;
|
|
2588
|
+
let e = O;
|
|
2507
2589
|
l.hidden = !1, (async () => {
|
|
2508
2590
|
try {
|
|
2509
|
-
let t = await
|
|
2510
|
-
if (S || e !==
|
|
2591
|
+
let t = await qt.startSession(we());
|
|
2592
|
+
if (S || e !== O) {
|
|
2511
2593
|
t.destroy();
|
|
2512
2594
|
return;
|
|
2513
2595
|
}
|
|
2514
|
-
b = t,
|
|
2596
|
+
b = t, De(t);
|
|
2515
2597
|
let n = await t.attach({
|
|
2516
2598
|
container: l,
|
|
2517
|
-
...
|
|
2599
|
+
...Te(),
|
|
2518
2600
|
onWidgetReady: () => {
|
|
2519
|
-
S || e !==
|
|
2601
|
+
S || e !== O || (T = !1, E = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") : xe());
|
|
2520
2602
|
},
|
|
2521
2603
|
onWidgetExpand: () => {
|
|
2522
2604
|
Pe(e);
|
|
@@ -2525,151 +2607,151 @@ function on(e, t) {
|
|
|
2525
2607
|
S || ze(e);
|
|
2526
2608
|
},
|
|
2527
2609
|
onWidgetDragStart: (e) => {
|
|
2528
|
-
S ||
|
|
2610
|
+
S || H(e);
|
|
2529
2611
|
},
|
|
2530
2612
|
onWidgetDragMove: (e) => {
|
|
2531
|
-
S ||
|
|
2613
|
+
S || me(e);
|
|
2532
2614
|
},
|
|
2533
2615
|
onWidgetDragEnd: (e) => {
|
|
2534
|
-
S ||
|
|
2616
|
+
S || he(e);
|
|
2535
2617
|
},
|
|
2536
2618
|
onPlayerStatusChange: (e) => {
|
|
2537
|
-
S || e === "error" && $(a.dataset.state) &&
|
|
2619
|
+
S || e === "error" && $(a.dataset.state) && K("Could not load the experience.");
|
|
2538
2620
|
}
|
|
2539
2621
|
});
|
|
2540
|
-
if (S || e !==
|
|
2622
|
+
if (S || e !== O) {
|
|
2541
2623
|
t.destroy(), b === t && (b = null);
|
|
2542
2624
|
return;
|
|
2543
2625
|
}
|
|
2544
2626
|
n.on("close", () => {
|
|
2545
|
-
S ||
|
|
2627
|
+
S || J();
|
|
2546
2628
|
});
|
|
2547
2629
|
} catch (n) {
|
|
2548
|
-
if (S || e !==
|
|
2549
|
-
|
|
2630
|
+
if (S || e !== O) return;
|
|
2631
|
+
T = !1, l.hidden = !0, l.replaceChildren(), b = null;
|
|
2550
2632
|
let r = n instanceof Error ? n : Error(String(n));
|
|
2551
2633
|
t.onError?.(r), console.error("[ExperienceWidget] warm prefetch failed", r);
|
|
2552
2634
|
}
|
|
2553
2635
|
})();
|
|
2554
2636
|
}, Ie = () => {
|
|
2555
|
-
if (S || x || !
|
|
2556
|
-
if (b &&
|
|
2637
|
+
if (S || x || !C || $(a.dataset.state)) return;
|
|
2638
|
+
if (b && D) {
|
|
2557
2639
|
Me();
|
|
2558
2640
|
return;
|
|
2559
2641
|
}
|
|
2560
|
-
if (b &&
|
|
2642
|
+
if (b && E) {
|
|
2561
2643
|
Ne();
|
|
2562
2644
|
return;
|
|
2563
2645
|
}
|
|
2564
|
-
let e = ++
|
|
2565
|
-
x = !0,
|
|
2646
|
+
let e = ++O;
|
|
2647
|
+
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 () => {
|
|
2566
2648
|
try {
|
|
2567
|
-
|
|
2568
|
-
let t = await
|
|
2569
|
-
if (S || e !==
|
|
2649
|
+
q();
|
|
2650
|
+
let t = await qt.startSession(we());
|
|
2651
|
+
if (S || e !== O) {
|
|
2570
2652
|
t.destroy();
|
|
2571
2653
|
return;
|
|
2572
2654
|
}
|
|
2573
|
-
b = t,
|
|
2655
|
+
b = t, De(t);
|
|
2574
2656
|
let n = await t.attach({
|
|
2575
2657
|
container: v,
|
|
2576
|
-
...
|
|
2658
|
+
...Te(),
|
|
2577
2659
|
onWidgetAudioSettings: (e) => {
|
|
2578
2660
|
S || ze(e);
|
|
2579
2661
|
},
|
|
2580
2662
|
onWidgetDragStart: (e) => {
|
|
2581
|
-
S ||
|
|
2663
|
+
S || H(e);
|
|
2582
2664
|
},
|
|
2583
2665
|
onWidgetDragMove: (e) => {
|
|
2584
|
-
S ||
|
|
2666
|
+
S || me(e);
|
|
2585
2667
|
},
|
|
2586
2668
|
onWidgetDragEnd: (e) => {
|
|
2587
|
-
S ||
|
|
2669
|
+
S || he(e);
|
|
2588
2670
|
},
|
|
2589
2671
|
onPlayerStatusChange: (e) => {
|
|
2590
|
-
S || (e === "error" ?
|
|
2672
|
+
S || (e === "error" ? K("Could not load the experience.") : $(a.dataset.state) && K(null));
|
|
2591
2673
|
}
|
|
2592
2674
|
});
|
|
2593
|
-
if (S || e !==
|
|
2675
|
+
if (S || e !== O) {
|
|
2594
2676
|
t.destroy(), b === t && (b = null);
|
|
2595
2677
|
return;
|
|
2596
2678
|
}
|
|
2597
|
-
|
|
2598
|
-
S ||
|
|
2679
|
+
E = !0, t.setWidgetChrome("expanded"), n.on("close", () => {
|
|
2680
|
+
S || J();
|
|
2599
2681
|
});
|
|
2600
2682
|
} catch (n) {
|
|
2601
|
-
if (S || e !==
|
|
2683
|
+
if (S || e !== O) return;
|
|
2602
2684
|
let r = n instanceof Error ? n : Error(String(n));
|
|
2603
|
-
|
|
2685
|
+
K(r.message), t.onError?.(r), console.error("[ExperienceWidget]", r);
|
|
2604
2686
|
} finally {
|
|
2605
|
-
e ===
|
|
2687
|
+
e === O && (x = !1);
|
|
2606
2688
|
}
|
|
2607
2689
|
})();
|
|
2608
2690
|
}, Le = () => {
|
|
2609
2691
|
if (!(S || $(a.dataset.state))) {
|
|
2610
|
-
if (b &&
|
|
2692
|
+
if (b && D) {
|
|
2611
2693
|
Me();
|
|
2612
2694
|
return;
|
|
2613
2695
|
}
|
|
2614
|
-
if (b &&
|
|
2696
|
+
if (b && E) {
|
|
2615
2697
|
Ne();
|
|
2616
2698
|
return;
|
|
2617
2699
|
}
|
|
2618
|
-
if (
|
|
2619
|
-
|
|
2700
|
+
if (T || b) {
|
|
2701
|
+
q();
|
|
2620
2702
|
return;
|
|
2621
2703
|
}
|
|
2622
2704
|
Ie();
|
|
2623
2705
|
}
|
|
2624
2706
|
}, Re = (e) => {
|
|
2625
2707
|
if (e.stopPropagation(), R() === "expanded") {
|
|
2626
|
-
|
|
2708
|
+
Ae();
|
|
2627
2709
|
return;
|
|
2628
2710
|
}
|
|
2629
|
-
R() === "docked" &&
|
|
2711
|
+
R() === "docked" && je();
|
|
2630
2712
|
}, ze = (e) => {
|
|
2631
2713
|
g.setAttribute("aria-pressed", e ? "true" : "false");
|
|
2632
2714
|
}, Be = (e) => {
|
|
2633
2715
|
e.stopPropagation(), $(a.dataset.state) && b?.toggleAudioSettings();
|
|
2634
|
-
}, Y = (e) => {
|
|
2635
|
-
R() === "docked" && Q() && (e.target?.closest("button") || (e.preventDefault(), pe(e.clientX, e.clientY, e.pointerId)));
|
|
2636
2716
|
}, Ve = (e) => {
|
|
2637
|
-
|
|
2638
|
-
}, He = () => {
|
|
2717
|
+
R() === "docked" && Q() && (e.target?.closest("button") || (e.preventDefault(), pe(e.clientX, e.clientY, e.pointerId)));
|
|
2718
|
+
}, He = (e) => {
|
|
2719
|
+
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), J());
|
|
2720
|
+
}, Ue = () => {
|
|
2639
2721
|
if (!S) {
|
|
2640
2722
|
if (R() === "docked") {
|
|
2641
2723
|
if (!Q()) {
|
|
2642
|
-
|
|
2724
|
+
je();
|
|
2643
2725
|
return;
|
|
2644
2726
|
}
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
}) :
|
|
2727
|
+
D ? W(() => {
|
|
2728
|
+
ge(!0);
|
|
2729
|
+
}) : ge(!0);
|
|
2648
2730
|
return;
|
|
2649
2731
|
}
|
|
2650
|
-
|
|
2732
|
+
U();
|
|
2651
2733
|
}
|
|
2652
|
-
},
|
|
2734
|
+
}, We = typeof window < "u" ? window.matchMedia(Yt) : null, Ge = () => {
|
|
2653
2735
|
if (!S) {
|
|
2654
2736
|
if (R() === "docked" && !Q()) {
|
|
2655
|
-
|
|
2737
|
+
je();
|
|
2656
2738
|
return;
|
|
2657
2739
|
}
|
|
2658
|
-
|
|
2740
|
+
U();
|
|
2659
2741
|
}
|
|
2660
2742
|
};
|
|
2661
|
-
return o.addEventListener("click", Le), d.addEventListener("click",
|
|
2662
|
-
e.stopPropagation(),
|
|
2663
|
-
}), h.addEventListener("click", Re), g.addEventListener("click", Be), p.addEventListener("pointerdown",
|
|
2743
|
+
return o.addEventListener("click", Le), d.addEventListener("click", J), _.addEventListener("click", (e) => {
|
|
2744
|
+
e.stopPropagation(), J();
|
|
2745
|
+
}), h.addEventListener("click", Re), g.addEventListener("click", Be), p.addEventListener("pointerdown", Ve), window.addEventListener("keydown", He), window.addEventListener("resize", Ue), We?.addEventListener("change", Ge), Ce(), U(), r === "eager" ? queueMicrotask(() => {
|
|
2664
2746
|
S || Fe();
|
|
2665
|
-
}) : r === "idle" && (
|
|
2747
|
+
}) : r === "idle" && (j = mn(() => {
|
|
2666
2748
|
S || Fe();
|
|
2667
2749
|
})), {
|
|
2668
2750
|
root: a,
|
|
2669
2751
|
expand: Le,
|
|
2670
|
-
collapse:
|
|
2671
|
-
dock:
|
|
2672
|
-
maximize:
|
|
2752
|
+
collapse: J,
|
|
2753
|
+
dock: Ae,
|
|
2754
|
+
maximize: je,
|
|
2673
2755
|
prefetch() {
|
|
2674
2756
|
if (r === "onExpand") {
|
|
2675
2757
|
Fe();
|
|
@@ -2678,11 +2760,11 @@ function on(e, t) {
|
|
|
2678
2760
|
Fe();
|
|
2679
2761
|
},
|
|
2680
2762
|
destroy() {
|
|
2681
|
-
S || (S = !0, V(),
|
|
2763
|
+
S || (S = !0, V(), j?.(), j = null, re.abort(), A?.(), A = null, window.removeEventListener("keydown", He), window.removeEventListener("resize", Ue), We?.removeEventListener("change", Ge), ke(), Oe(), e.replaceChildren());
|
|
2682
2764
|
}
|
|
2683
2765
|
};
|
|
2684
2766
|
}
|
|
2685
2767
|
//#endregion
|
|
2686
|
-
export { I as EXPERIENCE_THUMBNAIL_CSS, ie as EXPERIENCE_WIDGET_CSS,
|
|
2768
|
+
export { I as EXPERIENCE_THUMBNAIL_CSS, ie as EXPERIENCE_WIDGET_CSS, qt as Experience, B as LiformaError, X as SPEECH_LIMITS, bt as SpeechBufferTimeoutError, Z as SpeechRuntimeError, yt as SpeechUtteranceClosedError, vt as UnsupportedSpeechOperationError, D as attachImageReady, E as attachLazyThumb, te as attachScrollLinkedParallax, m as buildHostedLaunchUrl, re as ensureExperienceThumbnailStyles, oe as ensureExperienceWidgetStyles, ue as fetchExperiencePreview, C as getDefaultLazyRootMargin, k as horizontalParallaxFromViewportY, fe as liformaErrorFromResponse, hn as mountExperienceWidget, n as navigateOnExperienceClose, h as resolveThumbnailHref, f as resolveThumbnailInteraction, c as resolveThumbnailLayers, r as thumbnailFitClass, s as toGalleryThumbUrl, Se as warnLocaleVoiceFallbacks };
|
|
2687
2769
|
|
|
2688
2770
|
//# sourceMappingURL=index.js.map
|