@liforma/client 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/next/index.js +676 -565
- package/dist/next/index.js.map +1 -1
- package/dist/next/next/createLiformaSessionRouteHandler.d.ts +0 -1
- package/dist/next/next/createLiformaSessionRouteHandler.d.ts.map +1 -1
- package/dist/next/react/ExperienceThumbnail.d.ts +1 -0
- package/dist/next/react/ExperienceThumbnail.d.ts.map +1 -1
- package/dist/next/thumbnail/styles.d.ts.map +1 -1
- package/dist/next/thumbnail/toGalleryThumbUrl.d.ts.map +1 -1
- package/dist/next/thumbnail/types.d.ts +2 -0
- package/dist/next/thumbnail/types.d.ts.map +1 -1
- package/dist/next/v2/api/mintPublicSession.d.ts +2 -2
- package/dist/next/v2/api/mintPublicSession.d.ts.map +1 -1
- package/dist/next/v2/api/sessionEndpointRequest.d.ts +2 -2
- package/dist/next/v2/api/sessionEndpointRequest.d.ts.map +1 -1
- package/dist/next/v2/embed/iframeHost.d.ts +1 -3
- package/dist/next/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/next/v2/errors/LiformaError.d.ts +23 -0
- package/dist/next/v2/errors/LiformaError.d.ts.map +1 -0
- package/dist/next/v2/experience.d.ts +7 -9
- package/dist/next/v2/experience.d.ts.map +1 -1
- package/dist/next/v2/experienceEvents.d.ts +21 -15
- package/dist/next/v2/experienceEvents.d.ts.map +1 -1
- package/dist/next/v2/types/sessionLaunch.d.ts +28 -5
- package/dist/next/v2/types/sessionLaunch.d.ts.map +1 -1
- package/dist/next/v2/types/sessionManifest.d.ts +8 -0
- package/dist/next/v2/types/sessionManifest.d.ts.map +1 -1
- package/dist/next/widget/mountExperienceWidget.d.ts.map +1 -1
- package/dist/npm/index.js +585 -472
- package/dist/npm/index.js.map +1 -1
- package/dist/npm/thumbnail/styles.d.ts.map +1 -1
- package/dist/npm/thumbnail/toGalleryThumbUrl.d.ts.map +1 -1
- package/dist/npm/thumbnail/types.d.ts +2 -0
- package/dist/npm/thumbnail/types.d.ts.map +1 -1
- package/dist/npm/v2/api/mintPublicSession.d.ts +2 -2
- package/dist/npm/v2/api/mintPublicSession.d.ts.map +1 -1
- package/dist/npm/v2/api/sessionEndpointRequest.d.ts +2 -2
- package/dist/npm/v2/api/sessionEndpointRequest.d.ts.map +1 -1
- package/dist/npm/v2/embed/iframeHost.d.ts +1 -3
- package/dist/npm/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/npm/v2/errors/LiformaError.d.ts +23 -0
- package/dist/npm/v2/errors/LiformaError.d.ts.map +1 -0
- package/dist/npm/v2/experience.d.ts +7 -9
- package/dist/npm/v2/experience.d.ts.map +1 -1
- package/dist/npm/v2/experienceEvents.d.ts +21 -15
- package/dist/npm/v2/experienceEvents.d.ts.map +1 -1
- package/dist/npm/v2/index.d.ts +4 -2
- package/dist/npm/v2/index.d.ts.map +1 -1
- package/dist/npm/v2/liforma-experience-thumbnail.d.ts.map +1 -1
- package/dist/npm/v2/liforma-experience-widget.d.ts.map +1 -1
- package/dist/npm/v2/npm.d.ts +5 -3
- package/dist/npm/v2/npm.d.ts.map +1 -1
- package/dist/npm/v2/types/index.d.ts +2 -2
- package/dist/npm/v2/types/index.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionLaunch.d.ts +28 -5
- package/dist/npm/v2/types/sessionLaunch.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionManifest.d.ts +8 -0
- package/dist/npm/v2/types/sessionManifest.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionManifestSchema.d.ts +7 -0
- package/dist/npm/v2/types/sessionManifestSchema.d.ts.map +1 -1
- package/dist/npm/widget/mountExperienceWidget.d.ts.map +1 -1
- package/dist/react/component/experienceComponentLaunch.d.ts.map +1 -1
- package/dist/react/component/experienceComponentRuntime.d.ts +0 -2
- package/dist/react/component/experienceComponentRuntime.d.ts.map +1 -1
- package/dist/react/component/experienceComponentTypes.d.ts +1 -5
- package/dist/react/component/experienceComponentTypes.d.ts.map +1 -1
- package/dist/react/index.js +775 -665
- package/dist/react/index.js.map +1 -1
- package/dist/react/react/Experience.d.ts.map +1 -1
- package/dist/react/react/ExperienceThumbnail.d.ts +1 -0
- package/dist/react/react/ExperienceThumbnail.d.ts.map +1 -1
- package/dist/react/thumbnail/styles.d.ts.map +1 -1
- package/dist/react/thumbnail/toGalleryThumbUrl.d.ts.map +1 -1
- package/dist/react/thumbnail/types.d.ts +2 -0
- package/dist/react/thumbnail/types.d.ts.map +1 -1
- package/dist/react/v2/api/mintPublicSession.d.ts +2 -2
- package/dist/react/v2/api/mintPublicSession.d.ts.map +1 -1
- package/dist/react/v2/api/sessionEndpointRequest.d.ts +2 -2
- package/dist/react/v2/api/sessionEndpointRequest.d.ts.map +1 -1
- package/dist/react/v2/embed/iframeHost.d.ts +1 -3
- package/dist/react/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/react/v2/errors/LiformaError.d.ts +23 -0
- package/dist/react/v2/errors/LiformaError.d.ts.map +1 -0
- package/dist/react/v2/experience.d.ts +7 -9
- package/dist/react/v2/experience.d.ts.map +1 -1
- package/dist/react/v2/experienceEvents.d.ts +21 -15
- package/dist/react/v2/experienceEvents.d.ts.map +1 -1
- package/dist/react/v2/types/sessionLaunch.d.ts +28 -5
- package/dist/react/v2/types/sessionLaunch.d.ts.map +1 -1
- package/dist/react/v2/types/sessionManifest.d.ts +8 -0
- package/dist/react/v2/types/sessionManifest.d.ts.map +1 -1
- package/dist/react/widget/mountExperienceWidget.d.ts.map +1 -1
- package/dist/sdk/v2/client.js +36 -13
- package/dist/sdk/v2/client.js.map +1 -1
- package/dist/svelte/Experience.svelte +0 -6
- package/dist/svelte/ExperienceThumbnail.svelte +8 -1
- package/dist/svelte/ExperienceThumbnail.svelte.d.ts +1 -0
- package/package.json +3 -1
package/dist/npm/index.js
CHANGED
|
@@ -30,27 +30,27 @@ function n(n, r = "/meet") {
|
|
|
30
30
|
}
|
|
31
31
|
//#endregion
|
|
32
32
|
//#region src/thumbnail/toGalleryThumbUrl.ts
|
|
33
|
-
var r = /(\/avatars\/[^/]+\/)(\d+)(\/)/i, i = /(-)(\d+x\d+)(\.webp)(\?|$)/i;
|
|
34
|
-
function
|
|
33
|
+
var r = /(\/avatars\/[^/]+\/)(\d+)(\/)/i, i = /_CH(\.webp)/i, a = /(-)(\d+x\d+)(\.webp)(\?|$)/i;
|
|
34
|
+
function o(e) {
|
|
35
35
|
let t = e.trim();
|
|
36
36
|
if (!t) return t;
|
|
37
37
|
let n = t.replace(r, (e, t, n, r) => n === "256" ? `${t}${n}${r}` : `${t}256${r}`);
|
|
38
|
-
return n = n.replace(i, (e, t, n, r, i) => n === "256x256" ? `${t}${n}${r}${i}` : `${t}256x256${r}${i}`), n;
|
|
38
|
+
return n = n.replace(i, "_neutral$1"), n = n.replace(a, (e, t, n, r, i) => n === "256x256" ? `${t}${n}${r}${i}` : `${t}256x256${r}${i}`), n;
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function s(e) {
|
|
41
41
|
let t = e.avatarImage?.trim() || e.galleryThumb?.avatarImage?.trim() || "";
|
|
42
42
|
if (!t) return null;
|
|
43
43
|
let n = e.backgroundImage?.trim() || e.galleryThumb?.backgroundImage?.trim() || "", r = e.foregroundImage?.trim() || e.galleryThumb?.foregroundImage?.trim() || "", i = e.fallbackImage?.trim() || "";
|
|
44
44
|
return {
|
|
45
|
-
avatarImage:
|
|
46
|
-
...n ? { backgroundImage:
|
|
47
|
-
...r ? { foregroundImage:
|
|
48
|
-
...i ? { fallbackImage:
|
|
45
|
+
avatarImage: o(t),
|
|
46
|
+
...n ? { backgroundImage: o(n) } : {},
|
|
47
|
+
...r ? { foregroundImage: o(r) } : {},
|
|
48
|
+
...i ? { fallbackImage: o(i) } : {}
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
//#endregion
|
|
52
52
|
//#region src/shims/localStack.ts
|
|
53
|
-
function
|
|
53
|
+
function c() {
|
|
54
54
|
if (globalThis.__LIFORMA_STACK === "local") return !0;
|
|
55
55
|
if (typeof location > "u") return !1;
|
|
56
56
|
try {
|
|
@@ -61,83 +61,83 @@ function s() {
|
|
|
61
61
|
}
|
|
62
62
|
//#endregion
|
|
63
63
|
//#region src/thumbnail/hostedLaunchUrl.ts
|
|
64
|
-
var
|
|
65
|
-
function
|
|
64
|
+
var l = "https://player.liforma.ai", u = "http://localhost:3002";
|
|
65
|
+
function d(e) {
|
|
66
66
|
return e.href?.trim() ? "anchor" : e.hasClickHandler ? "button" : e.experienceId?.trim() ? "anchor" : "presentational";
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function f(e) {
|
|
69
69
|
let t = e?.trim();
|
|
70
|
-
return t ? t.replace(/\/$/, "") :
|
|
70
|
+
return t ? t.replace(/\/$/, "") : c() ? u : l;
|
|
71
71
|
}
|
|
72
|
-
function
|
|
73
|
-
let t = e.experienceId.trim(), n =
|
|
72
|
+
function p(e) {
|
|
73
|
+
let t = e.experienceId.trim(), n = f(e.playerBaseUrl), r = new URL(`${n}/${encodeURIComponent(t)}`), i = e.returnUrl?.trim();
|
|
74
74
|
return i && r.searchParams.set("returnUrl", i), r.toString();
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function m(e) {
|
|
77
77
|
let t = e.href?.trim();
|
|
78
78
|
if (t) return t;
|
|
79
79
|
let n = e.experienceId?.trim();
|
|
80
80
|
if (!n) return;
|
|
81
81
|
let r = e.returnUrl?.trim();
|
|
82
|
-
return !r && e.useCurrentPageAsReturnUrl && typeof window < "u" && (r = window.location.href),
|
|
82
|
+
return !r && e.useCurrentPageAsReturnUrl && typeof window < "u" && (r = window.location.href), p({
|
|
83
83
|
experienceId: n,
|
|
84
84
|
...r ? { returnUrl: r } : {},
|
|
85
85
|
playerBaseUrl: e.playerBaseUrl
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function h() {
|
|
89
89
|
return typeof window > "u" ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
|
|
90
90
|
}
|
|
91
|
-
var
|
|
92
|
-
function _() {
|
|
93
|
-
return m() ? 4 : Infinity;
|
|
94
|
-
}
|
|
91
|
+
var g = 0, _ = [];
|
|
95
92
|
function ee() {
|
|
96
|
-
return
|
|
93
|
+
return h() ? 4 : Infinity;
|
|
97
94
|
}
|
|
98
95
|
function v() {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
96
|
+
return h() ? 160 : 0;
|
|
97
|
+
}
|
|
98
|
+
function y() {
|
|
99
|
+
let e = ee();
|
|
100
|
+
for (; g < e && _.length > 0;) {
|
|
101
|
+
let e = _.shift();
|
|
102
102
|
if (!e || e.cancelled) continue;
|
|
103
|
-
|
|
104
|
-
let t =
|
|
103
|
+
g += 1, e.start();
|
|
104
|
+
let t = v();
|
|
105
105
|
if (t <= 0) {
|
|
106
|
-
|
|
106
|
+
g = Math.max(0, g - 1);
|
|
107
107
|
continue;
|
|
108
108
|
}
|
|
109
109
|
window.setTimeout(() => {
|
|
110
|
-
|
|
110
|
+
g = Math.max(0, g - 1), y();
|
|
111
111
|
}, t);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
function
|
|
115
|
-
if (!
|
|
114
|
+
function b(e) {
|
|
115
|
+
if (!h()) return e(), () => {};
|
|
116
116
|
let t = {
|
|
117
117
|
start: e,
|
|
118
118
|
cancelled: !1
|
|
119
119
|
};
|
|
120
|
-
return
|
|
120
|
+
return _.push(t), y(), () => {
|
|
121
121
|
t.cancelled = !0;
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
//#endregion
|
|
125
125
|
//#region src/thumbnail/lazyLoad.ts
|
|
126
|
-
function
|
|
127
|
-
return
|
|
126
|
+
function x() {
|
|
127
|
+
return h() ? "96px 0px" : "280px 0px";
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function te(e) {
|
|
130
130
|
let t = e.trim().split(/\s+/)[0] ?? "0px", n = Number.parseFloat(t);
|
|
131
131
|
return Number.isFinite(n) ? Math.abs(n) : 280;
|
|
132
132
|
}
|
|
133
|
-
function
|
|
133
|
+
function S(e, t) {
|
|
134
134
|
if (typeof window > "u") return !1;
|
|
135
135
|
let n = e.getBoundingClientRect();
|
|
136
136
|
return n.bottom >= -t && n.top <= window.innerHeight + t;
|
|
137
137
|
}
|
|
138
|
-
function
|
|
139
|
-
let { onVisibleChange: n } = t, r = t.rootMargin ??
|
|
140
|
-
o || (s?.(), s =
|
|
138
|
+
function C(e, t) {
|
|
139
|
+
let { onVisibleChange: n } = t, r = t.rootMargin ?? x(), i = te(r), a = !1, o = !1, s = null, c = () => {
|
|
140
|
+
o || (s?.(), s = b(() => {
|
|
141
141
|
s = null, o = !0, n(!0);
|
|
142
142
|
}));
|
|
143
143
|
}, l = (e) => {
|
|
@@ -159,11 +159,11 @@ function S(e, t) {
|
|
|
159
159
|
rootMargin: r,
|
|
160
160
|
threshold: 0
|
|
161
161
|
});
|
|
162
|
-
return u.observe(e),
|
|
162
|
+
return u.observe(e), S(e, i) && l(!0), () => {
|
|
163
163
|
s?.(), s = null, u.disconnect();
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
|
-
function
|
|
166
|
+
function w(e, t) {
|
|
167
167
|
let n = () => t();
|
|
168
168
|
return e.complete ? queueMicrotask(n) : (e.addEventListener("load", n, { once: !0 }), e.addEventListener("error", n, { once: !0 })), () => {
|
|
169
169
|
e.removeEventListener("load", n), e.removeEventListener("error", n);
|
|
@@ -171,49 +171,49 @@ function C(e, t) {
|
|
|
171
171
|
}
|
|
172
172
|
//#endregion
|
|
173
173
|
//#region src/thumbnail/scrollParallax.ts
|
|
174
|
-
function
|
|
174
|
+
function T() {
|
|
175
175
|
return typeof window > "u" || window.matchMedia("(prefers-reduced-motion: reduce)").matches ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
|
|
176
176
|
}
|
|
177
|
-
function
|
|
177
|
+
function E(e, t) {
|
|
178
178
|
return ((e.top + e.height / 2) / Math.max(t, 1) - .5) * 2;
|
|
179
179
|
}
|
|
180
|
-
var
|
|
181
|
-
function
|
|
182
|
-
if (
|
|
180
|
+
var D = /* @__PURE__ */ new Set(), O = !1, k = 0;
|
|
181
|
+
function A() {
|
|
182
|
+
if (k = 0, D.size === 0 || typeof window > "u") return;
|
|
183
183
|
let e = window.innerHeight;
|
|
184
|
-
for (let t of
|
|
184
|
+
for (let t of D) {
|
|
185
185
|
if (t.pointerActive?.()) continue;
|
|
186
186
|
let n = t.element.getBoundingClientRect();
|
|
187
|
-
n.bottom < -64 || n.top > e + 64 || t.onParallax(
|
|
187
|
+
n.bottom < -64 || n.top > e + 64 || t.onParallax(E(n, e));
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
-
function
|
|
191
|
-
|
|
190
|
+
function j() {
|
|
191
|
+
k === 0 && (k = requestAnimationFrame(A));
|
|
192
192
|
}
|
|
193
|
-
function
|
|
194
|
-
|
|
193
|
+
function M() {
|
|
194
|
+
O || typeof window > "u" || (O = !0, window.addEventListener("scroll", j, { passive: !0 }), window.addEventListener("resize", j, { passive: !0 }));
|
|
195
195
|
}
|
|
196
|
-
function
|
|
197
|
-
|
|
196
|
+
function N() {
|
|
197
|
+
D.size > 0 || !O || typeof window > "u" || (O = !1, k !== 0 && (cancelAnimationFrame(k), k = 0), window.removeEventListener("scroll", j), window.removeEventListener("resize", j));
|
|
198
198
|
}
|
|
199
|
-
function
|
|
200
|
-
if (!
|
|
199
|
+
function P(e, t) {
|
|
200
|
+
if (!T()) return () => {};
|
|
201
201
|
let n = {
|
|
202
202
|
element: e,
|
|
203
203
|
onParallax: t.onParallax,
|
|
204
204
|
pointerActive: t.pointerActive
|
|
205
205
|
};
|
|
206
|
-
return
|
|
207
|
-
|
|
206
|
+
return D.add(n), M(), n.pointerActive?.() || t.onParallax(E(e.getBoundingClientRect(), window.innerHeight)), () => {
|
|
207
|
+
D.delete(n), N();
|
|
208
208
|
};
|
|
209
209
|
}
|
|
210
210
|
//#endregion
|
|
211
211
|
//#region src/thumbnail/attachThumbnailParallax.ts
|
|
212
|
-
function
|
|
212
|
+
function ne(e) {
|
|
213
213
|
let t = 0, n = 0, r = !1, i = !1, a = !1, o = () => {
|
|
214
214
|
let a = r || i;
|
|
215
215
|
e.classList.toggle("liforma-et--parallax", a), e.classList.toggle("liforma-et--scroll-parallax", i), e.style.setProperty("--liforma-et-parallax-x", String(t)), e.style.setProperty("--liforma-et-parallax-y", String(n));
|
|
216
|
-
}, s =
|
|
216
|
+
}, s = P(e, {
|
|
217
217
|
onParallax: (e) => {
|
|
218
218
|
i = !0, a || (t = e, n = 0, o());
|
|
219
219
|
},
|
|
@@ -226,7 +226,7 @@ function N(e) {
|
|
|
226
226
|
a = !0, e.pointerType === "mouse" && (r = !0), o();
|
|
227
227
|
}, u = () => {
|
|
228
228
|
let s = a;
|
|
229
|
-
a = !1, r = !1, i && s ? (t =
|
|
229
|
+
a = !1, r = !1, i && s ? (t = E(e.getBoundingClientRect(), window.innerHeight), n = 0) : i || (t = 0, n = 0), o();
|
|
230
230
|
}, d = (e) => {
|
|
231
231
|
e.pointerType === "mouse" && (r = !0, o());
|
|
232
232
|
}, f = () => {
|
|
@@ -238,45 +238,45 @@ function N(e) {
|
|
|
238
238
|
}
|
|
239
239
|
//#endregion
|
|
240
240
|
//#region src/thumbnail/styles.ts
|
|
241
|
-
var re = ".liforma-et {\n --liforma-et-parallax-x: 0;\n --liforma-et-parallax-y: 0;\n --liforma-et-bg-scale: 1;\n --liforma-et-fg-scale: 1;\n --liforma-et-avatar-scale: 1;\n --liforma-et-bg-shift: 0px;\n --liforma-et-fg-shift: 0px;\n --liforma-et-avatar-shift: 0px;\n --liforma-et-reveal-duration: 420ms;\n\n box-sizing: border-box;\n position: relative;\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: 0.65rem;\n overflow: hidden;\n background: #111;\n color: inherit;\n text-decoration: none;\n cursor: inherit;\n -webkit-tap-highlight-color: transparent;\n}\n\na.liforma-et,\nbutton.liforma-et {\n cursor: pointer;\n}\n\nbutton.liforma-et {\n font: inherit;\n appearance: none;\n}\n\n.liforma-et__placeholder {\n position: absolute;\n inset: 0;\n z-index: 0;\n background:\n radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.06), transparent 58%),\n linear-gradient(180deg, #1a1a1a 0%, #101010 100%);\n opacity: 1;\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n.liforma-et--revealed .liforma-et__placeholder {\n opacity: 0;\n}\n\n.liforma-et__media {\n opacity: 0;\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n.liforma-et__media--ready {\n opacity: 1;\n}\n\n.liforma-et__background {\n position: absolute;\n inset: 0;\n z-index: 1;\n width: 100%;\n height: 100%;\n object-fit: cover;\n object-position: center center;\n transform: translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-bg-shift)),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-bg-shift))\n )\n scale(var(--liforma-et-bg-scale));\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n.liforma-et__avatar {\n position: relative;\n z-index: 2;\n display: block;\n width: 100%;\n height: 100%;\n object-fit:
|
|
242
|
-
function
|
|
243
|
-
if (typeof document > "u" ||
|
|
241
|
+
var re = ".liforma-et {\n --liforma-et-parallax-x: 0;\n --liforma-et-parallax-y: 0;\n --liforma-et-bg-scale: 1;\n --liforma-et-fg-scale: 1;\n --liforma-et-avatar-scale: 1;\n --liforma-et-bg-shift: 0px;\n --liforma-et-fg-shift: 0px;\n --liforma-et-avatar-shift: 0px;\n --liforma-et-reveal-duration: 420ms;\n\n box-sizing: border-box;\n position: relative;\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: 0.65rem;\n overflow: hidden;\n background: #111;\n color: inherit;\n text-decoration: none;\n cursor: inherit;\n -webkit-tap-highlight-color: transparent;\n}\n\na.liforma-et,\nbutton.liforma-et {\n cursor: pointer;\n}\n\nbutton.liforma-et {\n font: inherit;\n appearance: none;\n}\n\n.liforma-et__placeholder {\n position: absolute;\n inset: 0;\n z-index: 0;\n background:\n radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.06), transparent 58%),\n linear-gradient(180deg, #1a1a1a 0%, #101010 100%);\n opacity: 1;\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n.liforma-et--revealed .liforma-et__placeholder {\n opacity: 0;\n}\n\n.liforma-et__media {\n opacity: 0;\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n.liforma-et__media--ready {\n opacity: 1;\n}\n\n.liforma-et__background {\n position: absolute;\n inset: 0;\n z-index: 1;\n width: 100%;\n height: 100%;\n object-fit: cover;\n object-position: center center;\n transform: translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-bg-shift)),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-bg-shift))\n )\n scale(var(--liforma-et-bg-scale));\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n.liforma-et__avatar {\n position: relative;\n z-index: 2;\n display: block;\n width: 100%;\n height: 100%;\n object-fit: contain;\n object-position: center bottom;\n transform: scale(var(--liforma-et-avatar-scale))\n translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-avatar-shift)),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-avatar-shift))\n );\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n/* Gallery plates are typically square in a square tile — contain vs cover is a no-op\n without a zoom. Scale the whole scene from the upper third so Face matches\n player fit (location + avatar crop together). */\n.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.85;\n --liforma-et-bg-scale: 1.85;\n --liforma-et-fg-scale: 1.85;\n}\n\n.liforma-et--fit-face .liforma-et__avatar,\n.liforma-et--fit-face .liforma-et__background,\n.liforma-et--fit-face .liforma-et__foreground {\n transform-origin: 50% 18%;\n}\n\n.liforma-et--fit-face .liforma-et__avatar {\n object-fit: cover;\n object-position: 50% 18%;\n}\n\n.liforma-et__foreground {\n position: absolute;\n inset: 0;\n z-index: 3;\n width: 100%;\n height: 100%;\n object-fit: cover;\n object-position: center center;\n pointer-events: none;\n transform: translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-fg-shift) * -1),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-fg-shift) * -1)\n )\n scale(var(--liforma-et-fg-scale));\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n.liforma-et--parallax {\n --liforma-et-bg-scale: 1.08;\n --liforma-et-fg-scale: 1.05;\n --liforma-et-avatar-scale: 1.08;\n --liforma-et-bg-shift: 10px;\n --liforma-et-fg-shift: 4px;\n --liforma-et-avatar-shift: 4px;\n}\n\n/* Promote layers only while parallax is active — avoids N compositor surfaces on galleries. */\n.liforma-et--parallax .liforma-et__background,\n.liforma-et--parallax .liforma-et__foreground,\n.liforma-et--parallax .liforma-et__avatar {\n will-change: transform;\n}\n\n.liforma-et--parallax.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.95;\n --liforma-et-bg-scale: 1.95;\n --liforma-et-fg-scale: 1.95;\n --liforma-et-avatar-shift: 0px;\n}\n\n.liforma-et--scroll-parallax .liforma-et__background,\n.liforma-et--scroll-parallax .liforma-et__foreground,\n.liforma-et--scroll-parallax .liforma-et__avatar {\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .liforma-et {\n --liforma-et-reveal-duration: 0ms;\n }\n\n .liforma-et--parallax {\n --liforma-et-bg-scale: 1;\n --liforma-et-fg-scale: 1;\n --liforma-et-avatar-scale: 1;\n --liforma-et-bg-shift: 0px;\n --liforma-et-fg-shift: 0px;\n --liforma-et-avatar-shift: 0px;\n }\n\n .liforma-et--parallax.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.85;\n --liforma-et-bg-scale: 1.85;\n --liforma-et-fg-scale: 1.85;\n }\n\n .liforma-et__background,\n .liforma-et__foreground,\n .liforma-et__avatar {\n transition: none;\n }\n}", F = !1;
|
|
242
|
+
function I(e) {
|
|
243
|
+
if (typeof document > "u" || F) return;
|
|
244
244
|
if (document.querySelector("style[data-liforma-et]")) {
|
|
245
|
-
|
|
245
|
+
F = !0;
|
|
246
246
|
return;
|
|
247
247
|
}
|
|
248
248
|
let t = document.createElement("style");
|
|
249
|
-
t.setAttribute("data-liforma-et", ""), t.textContent = e, document.head.appendChild(t),
|
|
249
|
+
t.setAttribute("data-liforma-et", ""), t.textContent = e, document.head.appendChild(t), F = !0;
|
|
250
250
|
}
|
|
251
251
|
//#endregion
|
|
252
252
|
//#region src/widget/styles.ts
|
|
253
|
-
var ie = "\n.liforma-ew {\n box-sizing: border-box;\n position: relative;\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 0;\n padding: 0;\n border: 0;\n}\n\n/* Optional self-positioned FAB (position=bottom-right|bottom-left).\n * Cap at 50vmin so small phones don't get an oversized thumb (desktop 224px stays). */\n.liforma-ew[data-position='bottom-right'],\n.liforma-ew[data-position='bottom-left'] {\n position: fixed;\n width: min(var(--liforma-ew-fab-size, 224px), 50vmin);\n height: min(var(--liforma-ew-fab-size, 224px), 50vmin);\n bottom: var(--liforma-ew-offset, 16px);\n z-index: 2147482900;\n}\n\n.liforma-ew[data-position='bottom-right'] {\n right: var(--liforma-ew-offset, 16px);\n left: auto;\n}\n\n.liforma-ew[data-position='bottom-left'] {\n left: var(--liforma-ew-offset, 16px);\n right: auto;\n}\n\n/* While open, collapse the FAB box so a corner hole / thumb never remains. */\n.liforma-ew[data-position='bottom-right'][data-state='expanded'],\n.liforma-ew[data-position='bottom-right'][data-state='docked'],\n.liforma-ew[data-position='bottom-left'][data-state='expanded'],\n.liforma-ew[data-position='bottom-left'][data-state='docked'] {\n width: 0;\n height: 0;\n min-width: 0;\n min-height: 0;\n overflow: visible;\n pointer-events: none;\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__warm,\n.liforma-ew[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-state='expanded'] .liforma-ew__overlay,\n.liforma-ew[data-state='expanded'] .liforma-ew__toolbar,\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar {\n pointer-events: auto;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__overlay {\n pointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel {\n pointer-events: auto;\n}\n\n.liforma-ew__hit {\n box-sizing: border-box;\n display: block;\n width: 100%;\n height: 100%;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n cursor: pointer;\n font: inherit;\n appearance: none;\n -webkit-tap-highlight-color: transparent;\n transform: scale(1);\n transform-origin: center center;\n transition:\n transform 180ms ease,\n filter 180ms ease;\n will-change: transform;\n}\n\n/* Author display must not defeat the HTML hidden attribute. */\n.liforma-ew__hit[hidden] {\n display: none !important;\n}\n\n.liforma-ew__hit:focus-visible {\n outline: 2px solid #5b8def;\n outline-offset: 3px;\n border-radius: 0.75rem;\n}\n\n@media (hover: hover) and (pointer: fine) {\n /* Scale the thumb whenever the collapsed FAB is hovered — including via the warm iframe hit layer. */\n .liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover,\n .liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-ew__hit {\n transform: scale(1.06);\n }\n\n .liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover .liforma-et,\n .liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-et {\n box-shadow: 0 12px 36px rgba(0, 0, 0, 0.34);\n }\n}\n\n.liforma-ew__face {\n width: 100%;\n height: 100%;\n min-height: 0;\n position: relative;\n}\n\n.liforma-ew__face-status {\n position: absolute;\n inset: 0;\n z-index: 1;\n display: grid;\n place-items: center;\n padding: 0.5rem;\n text-align: center;\n font: 600 0.75rem/1.3 system-ui, sans-serif;\n color: #e8ecf4;\n background: rgba(10, 12, 18, 0.72);\n border-radius: 0.75rem;\n pointer-events: none;\n}\n\n.liforma-ew__face-status[hidden] {\n display: none !important;\n}\n\n.liforma-ew__hit:disabled {\n cursor: default;\n opacity: 0.85;\n}\n\n.liforma-ew__face .liforma-et {\n border-radius: 0.75rem;\n box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);\n transition: box-shadow 180ms ease;\n}\n\n.liforma-ew__warm {\n box-sizing: border-box;\n position: absolute;\n inset: 0;\n z-index: 2;\n border-radius: 0.75rem;\n overflow: hidden;\n background: transparent;\n pointer-events: none;\n opacity: 1;\n transition: opacity 1000ms ease;\n}\n\n/*\n * Collapsed: keep the warm iframe as an invisible hit target only.\n * Painting it over the thumb causes a “ghost enlarge” (face scales under a static iframe).\n */\n.liforma-ew[data-state='collapsed'] .liforma-ew__warm {\n opacity: 0;\n transition: none;\n}\n\n.liforma-ew[data-warm='true'] .liforma-ew__warm {\n pointer-events: auto;\n}\n\n.liforma-ew[data-warm='true']:not([data-live='true']) .liforma-ew__hit {\n pointer-events: none;\n}\n\n.liforma-ew[data-live='true'][data-state='collapsed'] .liforma-ew__hit {\n pointer-events: auto;\n}\n\n.liforma-ew[data-live='true'] .liforma-ew__warm,\n.liforma-ew[data-live='true'] .liforma-ew__stage {\n /* Hidden under the thumb / until post-resize fade-in (matches cold avatar reveal). */\n opacity: 0;\n}\n\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='expanded'] .liforma-ew__warm,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='expanded'] .liforma-ew__stage,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='docked'] .liforma-ew__stage {\n opacity: 1;\n}\n\n.liforma-ew--session-concealing .liforma-ew__warm,\n.liforma-ew--session-concealing .liforma-ew__stage {\n transition-duration: 280ms;\n}\n\n/* Instant hide while dock/maximize geometry settles (player morph resize ~160ms). */\n.liforma-ew--layout-settling .liforma-ew__warm,\n.liforma-ew--layout-settling .liforma-ew__stage {\n opacity: 0 !important;\n transition: none !important;\n}\n\n.liforma-ew[data-live='true'][data-state='collapsed'] .liforma-ew__warm {\n /* Keep the live iframe under the thumb; FAB click resumes the shell. */\n pointer-events: none;\n opacity: 0;\n /* Instant hide when collapsed so the FAB never shows a resized live mesh. */\n transition: none;\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__warm {\n position: fixed;\n /* Match overlay panel inset so the warm iframe fills the conversation shell. */\n inset: clamp(12px, 3vw, 28px);\n z-index: 2147483001;\n width: auto;\n height: auto;\n border-radius: 16px;\n pointer-events: auto;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__warm {\n position: fixed;\n inset: auto;\n z-index: 2147483001;\n border-radius: 16px;\n pointer-events: auto;\n /* left/top/width/height set inline from dock geometry */\n}\n\n.liforma-ew__toolbar {\n display: none;\n position: fixed;\n z-index: 2147483002;\n pointer-events: auto;\n box-sizing: border-box;\n align-items: center;\n gap: 0.35rem;\n padding: 0.35rem 0.4rem;\n border-radius: 999px;\n background: rgba(12, 14, 20, 0.72);\n backdrop-filter: blur(8px);\n -webkit-backdrop-filter: blur(8px);\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__toolbar {\n display: flex;\n top: calc(clamp(12px, 3vw, 28px) + 10px);\n right: calc(clamp(12px, 3vw, 28px) + 10px);\n left: auto;\n cursor: default;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar {\n display: flex;\n /* left/top set inline to track the panel; strip remains a drag handle */\n cursor: grab;\n touch-action: none;\n user-select: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel,\n.liforma-ew[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-state='docked'] .liforma-ew__stage {\n /* Player also reports surface drags via postMessage when docked. */\n cursor: grab;\n touch-action: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar.liforma-ew__toolbar--dragging,\n.liforma-ew--dock-dragging,\n.liforma-ew--dock-dragging .liforma-ew__toolbar,\n.liforma-ew--dock-dragging .liforma-ew__panel,\n.liforma-ew--dock-dragging .liforma-ew__warm,\n.liforma-ew--dock-dragging .liforma-ew__stage {\n cursor: grabbing;\n}\n\n\n.liforma-ew__toolbar[hidden] {\n display: none !important;\n}\n\n.liforma-ew__icon-btn {\n appearance: none;\n box-sizing: border-box;\n display: inline-grid;\n place-items: center;\n width: 2rem;\n height: 2rem;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: 999px;\n color: #f5f7fb;\n background: transparent;\n cursor: pointer;\n}\n\n.liforma-ew__icon-btn:hover {\n background: rgba(255, 255, 255, 0.12);\n}\n\n.liforma-ew__icon-btn[aria-pressed='true'] {\n background: rgba(255, 255, 255, 0.2);\n}\n\n.liforma-ew__icon-btn:focus-visible {\n outline: 2px solid #5b8def;\n outline-offset: 2px;\n}\n\n.liforma-ew__icon-btn svg {\n width: 1.05rem;\n height: 1.05rem;\n display: block;\n}\n\n.liforma-ew__drag-grip {\n display: none;\n width: 0.85rem;\n height: 1.25rem;\n margin: 0 0.15rem 0 0.25rem;\n background:\n radial-gradient(circle, currentColor 1.1px, transparent 1.2px) 0 0 / 0.35rem 0.35rem,\n radial-gradient(circle, currentColor 1.1px, transparent 1.2px) 0.35rem 0 / 0.35rem 0.35rem;\n background-repeat: repeat-y;\n opacity: 0.55;\n color: #f5f7fb;\n pointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__drag-grip {\n display: block;\n}\n\n.liforma-ew__dock-toggle[hidden] {\n display: none !important;\n}\n\n.liforma-ew__overlay {\n position: fixed;\n inset: 0;\n z-index: 2147483000;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: clamp(12px, 3vw, 28px);\n box-sizing: border-box;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__overlay {\n padding: 0;\n align-items: stretch;\n justify-content: stretch;\n pointer-events: none;\n background: transparent;\n}\n\n.liforma-ew__overlay[hidden] {\n display: none !important;\n}\n\n.liforma-ew__backdrop {\n position: absolute;\n inset: 0;\n border: 0;\n padding: 0;\n margin: 0;\n background: rgba(6, 8, 14, 0.62);\n cursor: pointer;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__backdrop {\n display: none !important;\n}\n\n.liforma-ew__panel {\n position: relative;\n z-index: 1;\n display: flex;\n flex-direction: column;\n /* Fill the overlay so player loading / start UI centers in the visible window. */\n width: var(--liforma-ew-max-w, 100%);\n height: var(--liforma-ew-max-h, 100%);\n max-width: 100%;\n max-height: 100%;\n border-radius: 16px;\n overflow: hidden;\n background: #030508;\n box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);\n /* Warm iframe sits above as a sibling; keep panel as chrome shell. */\n pointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel {\n position: fixed;\n inset: auto;\n max-width: none;\n max-height: none;\n pointer-events: auto;\n /* left/top/width/height set inline from dock geometry */\n}\n\n.liforma-ew:not([data-warm='true']) .liforma-ew__panel {\n pointer-events: auto;\n}\n\n.liforma-ew__stage {\n position: relative;\n flex: 1;\n min-height: 0;\n width: 100%;\n height: 100%;\n background: #030508;\n opacity: 1;\n transition: opacity 1000ms ease;\n}\n\n.liforma-ew__status {\n position: absolute;\n inset: 0;\n z-index: 1;\n display: grid;\n place-items: center;\n padding: 1.5rem;\n text-align: center;\n color: #d7dde8;\n font: 500 0.9375rem/1.45 system-ui, sans-serif;\n background: rgba(3, 5, 8, 0.92);\n pointer-events: none;\n}\n\n.liforma-ew__status[hidden] {\n display: none !important;\n}\n\n/* Mobile expanded: ~90% viewport, no reduce control. */\n@media (max-width: 767px) {\n .liforma-ew[data-state='expanded'] .liforma-ew__overlay {\n padding: 5vh 5vw;\n }\n\n .liforma-ew[data-state='expanded'] .liforma-ew__panel {\n width: 90vw;\n height: 90vh;\n max-width: 90vw;\n max-height: 90vh;\n }\n\n .liforma-ew[data-state='expanded'] .liforma-ew__warm {\n inset: 5vh 5vw;\n }\n\n .liforma-ew[data-state='expanded'] .liforma-ew__toolbar {\n top: calc(5vh + 10px);\n right: calc(5vw + 10px);\n }\n\n .liforma-ew__dock-toggle {\n display: none !important;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .liforma-ew__hit {\n transition: none;\n will-change: auto;\n }\n\n .liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover,\n .liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-ew__hit {\n transform: none;\n }\n\n .liforma-ew__face .liforma-et {\n box-shadow: none;\n transition: none;\n }\n\n .liforma-ew__warm,\n .liforma-ew__stage {\n transition: none;\n }\n}\n", I = "liforma-experience-widget-styles";
|
|
254
|
-
function
|
|
253
|
+
var ie = "\n.liforma-ew {\n box-sizing: border-box;\n position: relative;\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 0;\n padding: 0;\n border: 0;\n}\n\n/* Optional self-positioned FAB (position=bottom-right|bottom-left).\n * Cap at 50vmin so small phones don't get an oversized thumb (desktop 224px stays). */\n.liforma-ew[data-position='bottom-right'],\n.liforma-ew[data-position='bottom-left'] {\n position: fixed;\n width: min(var(--liforma-ew-fab-size, 224px), 50vmin);\n height: min(var(--liforma-ew-fab-size, 224px), 50vmin);\n bottom: var(--liforma-ew-offset, 16px);\n z-index: 2147482900;\n}\n\n.liforma-ew[data-position='bottom-right'] {\n right: var(--liforma-ew-offset, 16px);\n left: auto;\n}\n\n.liforma-ew[data-position='bottom-left'] {\n left: var(--liforma-ew-offset, 16px);\n right: auto;\n}\n\n/* While open, collapse the FAB box so a corner hole / thumb never remains. */\n.liforma-ew[data-position='bottom-right'][data-state='expanded'],\n.liforma-ew[data-position='bottom-right'][data-state='docked'],\n.liforma-ew[data-position='bottom-left'][data-state='expanded'],\n.liforma-ew[data-position='bottom-left'][data-state='docked'] {\n width: 0;\n height: 0;\n min-width: 0;\n min-height: 0;\n overflow: visible;\n pointer-events: none;\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__warm,\n.liforma-ew[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-state='expanded'] .liforma-ew__overlay,\n.liforma-ew[data-state='expanded'] .liforma-ew__toolbar,\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar {\n pointer-events: auto;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__overlay {\n pointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel {\n pointer-events: auto;\n}\n\n.liforma-ew__hit {\n box-sizing: border-box;\n display: block;\n width: 100%;\n height: 100%;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n cursor: pointer;\n font: inherit;\n appearance: none;\n -webkit-tap-highlight-color: transparent;\n transform: scale(1);\n transform-origin: center center;\n transition:\n transform 180ms ease,\n filter 180ms ease;\n will-change: transform;\n}\n\n/* Author display must not defeat the HTML hidden attribute. */\n.liforma-ew__hit[hidden] {\n display: none !important;\n}\n\n.liforma-ew__hit:focus-visible {\n outline: 2px solid #5b8def;\n outline-offset: 3px;\n border-radius: 0.75rem;\n}\n\n@media (hover: hover) and (pointer: fine) {\n /* Scale the thumb whenever the collapsed FAB is hovered — including via the warm iframe hit layer. */\n .liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover,\n .liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-ew__hit {\n transform: scale(1.06);\n }\n\n .liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover .liforma-et,\n .liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-et {\n box-shadow: 0 12px 36px rgba(0, 0, 0, 0.34);\n }\n}\n\n.liforma-ew__face {\n width: 100%;\n height: 100%;\n min-height: 0;\n position: relative;\n}\n\n.liforma-ew__face-status {\n position: absolute;\n inset: 0;\n z-index: 1;\n display: grid;\n place-items: center;\n padding: 0.5rem;\n text-align: center;\n font: 600 0.75rem/1.3 system-ui, sans-serif;\n color: #e8ecf4;\n background: rgba(10, 12, 18, 0.72);\n border-radius: 0.75rem;\n pointer-events: none;\n}\n\n.liforma-ew__face-status[hidden] {\n display: none !important;\n}\n\n.liforma-ew__hit:disabled {\n cursor: default;\n opacity: 0.85;\n}\n\n.liforma-ew__face .liforma-et {\n border-radius: 0.75rem;\n box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);\n transition: box-shadow 180ms ease;\n}\n\n.liforma-ew__warm {\n box-sizing: border-box;\n position: absolute;\n inset: 0;\n z-index: 2;\n border-radius: 0.75rem;\n overflow: hidden;\n background: transparent;\n pointer-events: none;\n opacity: 1;\n transition: opacity 1000ms ease;\n}\n\n/*\n * Collapsed: keep the warm iframe as an invisible hit target only.\n * Painting it over the thumb causes a “ghost enlarge” (face scales under a static iframe).\n */\n.liforma-ew[data-state='collapsed'] .liforma-ew__warm {\n opacity: 0;\n transition: none;\n}\n\n.liforma-ew[data-warm='true'] .liforma-ew__warm {\n pointer-events: auto;\n}\n\n.liforma-ew[data-warm='true']:not([data-live='true']) .liforma-ew__hit {\n pointer-events: none;\n}\n\n.liforma-ew[data-live='true'][data-state='collapsed'] .liforma-ew__hit {\n pointer-events: auto;\n}\n\n.liforma-ew[data-live='true'] .liforma-ew__warm,\n.liforma-ew[data-live='true'] .liforma-ew__stage {\n /* Hidden under the thumb / until post-resize fade-in (matches cold avatar reveal). */\n opacity: 0;\n}\n\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='expanded'] .liforma-ew__warm,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='expanded'] .liforma-ew__stage,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-live='true'].liforma-ew--session-revealed[data-state='docked'] .liforma-ew__stage {\n opacity: 1;\n}\n\n.liforma-ew--session-concealing .liforma-ew__warm,\n.liforma-ew--session-concealing .liforma-ew__stage {\n transition-duration: 280ms;\n}\n\n/* Instant hide while dock/maximize geometry settles (player morph resize ~160ms). */\n.liforma-ew--layout-settling .liforma-ew__warm,\n.liforma-ew--layout-settling .liforma-ew__stage {\n opacity: 0 !important;\n transition: none !important;\n}\n\n.liforma-ew[data-live='true'][data-state='collapsed'] .liforma-ew__warm {\n /* Keep the live iframe under the thumb; FAB click resumes the shell. */\n pointer-events: none;\n opacity: 0;\n /* Instant hide when collapsed so the FAB never shows a resized live mesh. */\n transition: none;\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__warm {\n position: fixed;\n /* Match overlay panel inset so the warm iframe fills the conversation shell. */\n inset: clamp(12px, 3vw, 28px);\n z-index: 2147483001;\n width: auto;\n height: auto;\n border-radius: 16px;\n pointer-events: auto;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__warm {\n position: fixed;\n inset: auto;\n z-index: 2147483001;\n border-radius: 16px;\n pointer-events: auto;\n /* left/top/width/height set inline from dock geometry */\n}\n\n.liforma-ew__toolbar {\n display: none;\n position: fixed;\n z-index: 2147483002;\n pointer-events: auto;\n box-sizing: border-box;\n align-items: center;\n gap: 0.35rem;\n padding: 0.35rem 0.4rem;\n border-radius: 999px;\n background: rgba(12, 14, 20, 0.72);\n backdrop-filter: blur(8px);\n -webkit-backdrop-filter: blur(8px);\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);\n}\n\n.liforma-ew[data-state='expanded'] .liforma-ew__toolbar {\n display: flex;\n top: calc(clamp(12px, 3vw, 28px) + 10px);\n right: calc(clamp(12px, 3vw, 28px) + 10px);\n left: auto;\n cursor: default;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar {\n display: flex;\n /* left/top set inline to track the panel; strip remains a drag handle */\n cursor: grab;\n touch-action: none;\n user-select: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel,\n.liforma-ew[data-state='docked'] .liforma-ew__warm,\n.liforma-ew[data-state='docked'] .liforma-ew__stage {\n /* Player also reports surface drags via postMessage when docked. */\n cursor: grab;\n touch-action: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__toolbar.liforma-ew__toolbar--dragging,\n.liforma-ew--dock-dragging,\n.liforma-ew--dock-dragging .liforma-ew__toolbar,\n.liforma-ew--dock-dragging .liforma-ew__panel,\n.liforma-ew--dock-dragging .liforma-ew__warm,\n.liforma-ew--dock-dragging .liforma-ew__stage {\n cursor: grabbing;\n}\n\n\n.liforma-ew__toolbar[hidden] {\n display: none !important;\n}\n\n.liforma-ew__icon-btn {\n appearance: none;\n box-sizing: border-box;\n display: inline-grid;\n place-items: center;\n width: 2rem;\n height: 2rem;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: 999px;\n color: #f5f7fb;\n background: transparent;\n cursor: pointer;\n}\n\n.liforma-ew__icon-btn:hover {\n background: rgba(255, 255, 255, 0.12);\n}\n\n.liforma-ew__icon-btn[aria-pressed='true'] {\n background: rgba(255, 255, 255, 0.2);\n}\n\n.liforma-ew__icon-btn:focus-visible {\n outline: 2px solid #5b8def;\n outline-offset: 2px;\n}\n\n.liforma-ew__icon-btn svg {\n width: 1.05rem;\n height: 1.05rem;\n display: block;\n}\n\n.liforma-ew__drag-grip {\n display: none;\n width: 0.85rem;\n height: 1.25rem;\n margin: 0 0.15rem 0 0.25rem;\n background:\n radial-gradient(circle, currentColor 1.1px, transparent 1.2px) 0 0 / 0.35rem 0.35rem,\n radial-gradient(circle, currentColor 1.1px, transparent 1.2px) 0.35rem 0 / 0.35rem 0.35rem;\n background-repeat: repeat-y;\n opacity: 0.55;\n color: #f5f7fb;\n pointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__drag-grip {\n display: block;\n}\n\n.liforma-ew__dock-toggle[hidden] {\n display: none !important;\n}\n\n.liforma-ew__overlay {\n position: fixed;\n inset: 0;\n z-index: 2147483000;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: clamp(12px, 3vw, 28px);\n box-sizing: border-box;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__overlay {\n padding: 0;\n align-items: stretch;\n justify-content: stretch;\n pointer-events: none;\n background: transparent;\n}\n\n.liforma-ew__overlay[hidden] {\n display: none !important;\n}\n\n.liforma-ew__backdrop {\n position: absolute;\n inset: 0;\n border: 0;\n padding: 0;\n margin: 0;\n background: rgba(6, 8, 14, 0.62);\n cursor: pointer;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__backdrop {\n display: none !important;\n}\n\n.liforma-ew__panel {\n position: relative;\n z-index: 1;\n display: flex;\n flex-direction: column;\n /* Fill the overlay so player loading / start UI centers in the visible window. */\n width: var(--liforma-ew-max-w, 100%);\n height: var(--liforma-ew-max-h, 100%);\n max-width: 100%;\n max-height: 100%;\n border-radius: 16px;\n overflow: hidden;\n background: #030508;\n box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);\n /* Warm iframe sits above as a sibling; keep panel as chrome shell. */\n pointer-events: none;\n}\n\n.liforma-ew[data-state='docked'] .liforma-ew__panel {\n position: fixed;\n inset: auto;\n max-width: none;\n max-height: none;\n pointer-events: auto;\n /* left/top/width/height set inline from dock geometry */\n}\n\n.liforma-ew:not([data-warm='true']) .liforma-ew__panel {\n pointer-events: auto;\n}\n\n.liforma-ew__stage {\n position: relative;\n flex: 1;\n min-height: 0;\n width: 100%;\n height: 100%;\n background: #030508;\n opacity: 1;\n transition: opacity 1000ms ease;\n}\n\n.liforma-ew__status {\n position: absolute;\n inset: 0;\n z-index: 1;\n display: grid;\n place-items: center;\n padding: 1.5rem;\n text-align: center;\n color: #d7dde8;\n font: 500 0.9375rem/1.45 system-ui, sans-serif;\n background: rgba(3, 5, 8, 0.92);\n pointer-events: none;\n}\n\n.liforma-ew__status[hidden] {\n display: none !important;\n}\n\n/* Mobile expanded: ~90% viewport, no reduce control. */\n@media (max-width: 767px) {\n .liforma-ew[data-state='expanded'] .liforma-ew__overlay {\n padding: 5vh 5vw;\n }\n\n .liforma-ew[data-state='expanded'] .liforma-ew__panel {\n width: 90vw;\n height: 90vh;\n max-width: 90vw;\n max-height: 90vh;\n }\n\n .liforma-ew[data-state='expanded'] .liforma-ew__warm {\n inset: 5vh 5vw;\n }\n\n .liforma-ew[data-state='expanded'] .liforma-ew__toolbar {\n top: calc(5vh + 10px);\n right: calc(5vw + 10px);\n }\n\n .liforma-ew__dock-toggle {\n display: none !important;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .liforma-ew__hit {\n transition: none;\n will-change: auto;\n }\n\n .liforma-ew[data-state='collapsed'] .liforma-ew__hit:not(:disabled):hover,\n .liforma-ew[data-state='collapsed']:has(.liforma-ew__warm:hover) .liforma-ew__hit {\n transform: none;\n }\n\n .liforma-ew__face .liforma-et {\n box-shadow: none;\n transition: none;\n }\n\n .liforma-ew__warm,\n .liforma-ew__stage {\n transition: none;\n }\n}\n", ae = "liforma-experience-widget-styles";
|
|
254
|
+
function oe(e = ie) {
|
|
255
255
|
if (typeof document > "u") return;
|
|
256
|
-
let t = document.getElementById(
|
|
256
|
+
let t = document.getElementById(ae);
|
|
257
257
|
if (t) {
|
|
258
258
|
t.textContent = e;
|
|
259
259
|
return;
|
|
260
260
|
}
|
|
261
261
|
let n = document.createElement("style");
|
|
262
|
-
n.id =
|
|
262
|
+
n.id = ae, n.textContent = e, document.head.append(n);
|
|
263
263
|
}
|
|
264
264
|
//#endregion
|
|
265
265
|
//#region src/shims/apiBaseUrl.ts
|
|
266
|
-
var
|
|
267
|
-
function
|
|
266
|
+
var se = "https://api.liforma.ai", L = "http://localhost:3001";
|
|
267
|
+
function R() {
|
|
268
268
|
let e = globalThis.__LIFORMA_API_BASE_URL;
|
|
269
269
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
270
270
|
if (typeof document > "u") return null;
|
|
271
271
|
let t = (document.querySelector("script[data-liforma-sdk][src*=\"client.js\"]") ?? document.querySelector("script[src*=\"/sdk/v2/client.js\"]"))?.getAttribute("data-api-base-url")?.trim();
|
|
272
272
|
return t ? t.replace(/\/$/, "") : null;
|
|
273
273
|
}
|
|
274
|
-
function
|
|
275
|
-
return
|
|
274
|
+
function ce() {
|
|
275
|
+
return R() || (c() ? L : se);
|
|
276
276
|
}
|
|
277
277
|
//#endregion
|
|
278
278
|
//#region src/v2/api/fetchExperiencePreview.ts
|
|
279
|
-
function
|
|
279
|
+
function le(e) {
|
|
280
280
|
if (!e || typeof e != "object") return null;
|
|
281
281
|
let t = e, n = typeof t.avatarImage == "string" ? t.avatarImage.trim() : "";
|
|
282
282
|
return n ? {
|
|
@@ -285,10 +285,10 @@ function ce(e) {
|
|
|
285
285
|
...typeof t.foregroundImage == "string" && t.foregroundImage.trim() ? { foregroundImage: t.foregroundImage.trim() } : {}
|
|
286
286
|
} : null;
|
|
287
287
|
}
|
|
288
|
-
async function
|
|
288
|
+
async function ue(e, t) {
|
|
289
289
|
let n = e.trim();
|
|
290
290
|
if (!n) throw Error("Experience preview requires experienceId.");
|
|
291
|
-
let r = (t?.apiBaseUrl ??
|
|
291
|
+
let r = (t?.apiBaseUrl ?? ce()).replace(/\/$/, ""), i = await fetch(`${r}/v1/experiences/${encodeURIComponent(n)}/preview`, {
|
|
292
292
|
method: "GET",
|
|
293
293
|
headers: { Accept: "application/json" },
|
|
294
294
|
signal: t?.signal
|
|
@@ -308,7 +308,7 @@ async function le(e, t) {
|
|
|
308
308
|
throw Error("Experience preview returned invalid JSON.");
|
|
309
309
|
}
|
|
310
310
|
if (!a || typeof a != "object") throw Error("Experience preview returned an invalid payload.");
|
|
311
|
-
let o = a, s = typeof o.experienceId == "string" ? o.experienceId.trim() : n, c = typeof o.title == "string" ? o.title.trim() : "", l =
|
|
311
|
+
let o = a, s = typeof o.experienceId == "string" ? o.experienceId.trim() : n, c = typeof o.title == "string" ? o.title.trim() : "", l = le(o.galleryThumb);
|
|
312
312
|
if (!l) throw Error("Experience preview is missing gallery thumb images.");
|
|
313
313
|
return {
|
|
314
314
|
experienceId: s || n,
|
|
@@ -317,20 +317,47 @@ async function le(e, t) {
|
|
|
317
317
|
};
|
|
318
318
|
}
|
|
319
319
|
//#endregion
|
|
320
|
+
//#region src/v2/errors/LiformaError.ts
|
|
321
|
+
var z = class extends Error {
|
|
322
|
+
code;
|
|
323
|
+
requestId;
|
|
324
|
+
status;
|
|
325
|
+
details;
|
|
326
|
+
constructor(e, t) {
|
|
327
|
+
super(e, t?.cause === void 0 ? void 0 : { cause: t.cause }), this.name = "LiformaError", this.code = t?.code?.trim() || "UNKNOWN", this.requestId = t?.requestId?.trim() || void 0, this.status = t?.status, this.details = t?.details;
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
function de(e) {
|
|
331
|
+
if (!(!e || typeof e != "object" || Array.isArray(e))) return e;
|
|
332
|
+
}
|
|
333
|
+
function fe(e, t, n) {
|
|
334
|
+
let r = n?.get("Liforma-Request-Id")?.trim() || void 0, i;
|
|
335
|
+
try {
|
|
336
|
+
i = JSON.parse(t);
|
|
337
|
+
} catch {}
|
|
338
|
+
let a = i?.error && typeof i.error == "object" ? i.error : void 0, o = a?.code ?? i?.code, s = a?.message ?? i?.message, c = a?.requestId ?? i?.requestId ?? r, l = typeof o == "string" && o.trim() ? o.trim() : "HTTP_ERROR", u = typeof s == "string" && s.trim() ? s.trim() : t.trim().slice(0, 500) || `Request failed (${e})`, d = typeof c == "string" && c.trim() ? c.trim() : r, { code: f, message: p, requestId: m, ...h } = de(a) ?? de(i) ?? {};
|
|
339
|
+
return new z(u, {
|
|
340
|
+
code: l,
|
|
341
|
+
requestId: d,
|
|
342
|
+
status: e,
|
|
343
|
+
details: Object.keys(h).length > 0 ? h : void 0
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
//#endregion
|
|
320
347
|
//#region src/v2/api/sessionEndpointRequest.ts
|
|
321
|
-
function
|
|
348
|
+
function pe(e) {
|
|
322
349
|
let t = e.locale?.trim();
|
|
323
350
|
if (t) return t;
|
|
324
351
|
let n = e.language?.trim();
|
|
325
352
|
if (n) return n;
|
|
326
353
|
if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
|
|
327
354
|
}
|
|
328
|
-
function
|
|
355
|
+
function B(e) {
|
|
329
356
|
let t = e.secondaryLocale?.trim(), n = e.learningLocale?.trim();
|
|
330
357
|
if (t && n && t !== n) throw Error("secondaryLocale and learningLocale disagree; pass only one or make them equal.");
|
|
331
358
|
return t || n || void 0;
|
|
332
359
|
}
|
|
333
|
-
function
|
|
360
|
+
function me(e, t) {
|
|
334
361
|
let n = e.trim();
|
|
335
362
|
if (!n) throw Error("sessionEndpoint must not be empty.");
|
|
336
363
|
if (typeof location > "u") throw Error("sessionEndpoint is only available in a browser.");
|
|
@@ -338,7 +365,7 @@ function fe(e, t) {
|
|
|
338
365
|
if (r.origin !== location.origin) throw Error("sessionEndpoint must be same-origin.");
|
|
339
366
|
let i = t.experienceId.trim();
|
|
340
367
|
if (!i) throw Error("sessionEndpoint requires experienceId.");
|
|
341
|
-
let a =
|
|
368
|
+
let a = pe(t), o = B(t), s = t.idempotencyKey?.trim();
|
|
342
369
|
return {
|
|
343
370
|
url: r.toString(),
|
|
344
371
|
init: {
|
|
@@ -346,14 +373,14 @@ function fe(e, t) {
|
|
|
346
373
|
credentials: "same-origin",
|
|
347
374
|
headers: {
|
|
348
375
|
Accept: "application/json",
|
|
349
|
-
"Content-Type": "application/json"
|
|
376
|
+
"Content-Type": "application/json",
|
|
377
|
+
...s ? { "Idempotency-Key": s } : {}
|
|
350
378
|
},
|
|
351
379
|
body: JSON.stringify({
|
|
352
380
|
experienceId: i,
|
|
353
381
|
...a ? { locale: a } : {},
|
|
354
382
|
...o ? { secondaryLocale: o } : {},
|
|
355
383
|
...t.mode ? { mode: t.mode } : {},
|
|
356
|
-
...t.responseMode ? { responseMode: t.responseMode } : {},
|
|
357
384
|
...t.speechInputMode ? { speechInputMode: t.speechInputMode } : {},
|
|
358
385
|
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly }
|
|
359
386
|
})
|
|
@@ -362,24 +389,44 @@ function fe(e, t) {
|
|
|
362
389
|
}
|
|
363
390
|
//#endregion
|
|
364
391
|
//#region src/v2/types/sessionLaunch.ts
|
|
365
|
-
function
|
|
392
|
+
function V(e) {
|
|
366
393
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
367
394
|
}
|
|
368
|
-
function
|
|
395
|
+
function H(e) {
|
|
369
396
|
return typeof e == "boolean";
|
|
370
397
|
}
|
|
371
|
-
function
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
398
|
+
function he(e) {
|
|
399
|
+
if (!V(e)) return null;
|
|
400
|
+
let t = e.speech, n = e.conversation, r = e.avatar, i = e.tools;
|
|
401
|
+
return !V(t) || !V(n) || !V(r) || !V(i) || !H(t.input) || !H(t.output) || !H(t.externalAudio) || !H(n.managed) || !H(r.enabled) || !H(i.enabled) ? null : {
|
|
402
|
+
speech: {
|
|
403
|
+
input: t.input,
|
|
404
|
+
output: t.output,
|
|
405
|
+
externalAudio: t.externalAudio
|
|
406
|
+
},
|
|
407
|
+
conversation: { managed: n.managed },
|
|
408
|
+
avatar: { enabled: r.enabled },
|
|
409
|
+
tools: { enabled: i.enabled }
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
function U(e) {
|
|
413
|
+
return !V(e) || !H(e.avatar) || !H(e.speechInput) || !H(e.speechOutput) || !H(e.tools) || !H(e.externalAudio) ? null : {
|
|
414
|
+
speech: {
|
|
415
|
+
input: e.speechInput,
|
|
416
|
+
output: e.speechOutput,
|
|
417
|
+
externalAudio: e.externalAudio
|
|
418
|
+
},
|
|
419
|
+
conversation: { managed: !0 },
|
|
420
|
+
avatar: { enabled: e.avatar },
|
|
421
|
+
tools: { enabled: e.tools }
|
|
378
422
|
};
|
|
379
423
|
}
|
|
380
|
-
function
|
|
381
|
-
|
|
382
|
-
|
|
424
|
+
function ge(e) {
|
|
425
|
+
return he(e) ?? U(e);
|
|
426
|
+
}
|
|
427
|
+
function _e(e) {
|
|
428
|
+
if (!V(e)) throw Error("Session Launch response is missing session.");
|
|
429
|
+
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 = ge(e.capabilities), l = ve(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;
|
|
383
430
|
if (!t || !n || !r || !i || !a || !s || !c) throw Error("Session Launch response has an invalid session object.");
|
|
384
431
|
return {
|
|
385
432
|
id: t,
|
|
@@ -389,76 +436,123 @@ function me(e) {
|
|
|
389
436
|
locale: a,
|
|
390
437
|
...o ? { secondaryLocale: o } : {},
|
|
391
438
|
mode: s,
|
|
392
|
-
capabilities: c
|
|
439
|
+
capabilities: c,
|
|
440
|
+
...l ? { localeVoiceFallbacks: l } : {},
|
|
441
|
+
...u ? { status: u } : {},
|
|
442
|
+
...d ? { createdAt: d } : {}
|
|
393
443
|
};
|
|
394
444
|
}
|
|
395
|
-
function
|
|
396
|
-
if (!
|
|
445
|
+
function ve(e) {
|
|
446
|
+
if (!Array.isArray(e) || e.length === 0) return;
|
|
447
|
+
let t = [];
|
|
448
|
+
for (let n of e) {
|
|
449
|
+
if (!V(n)) continue;
|
|
450
|
+
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() : "";
|
|
451
|
+
!e || !r || !i || n.reason !== "voice_unsupported" || t.push({
|
|
452
|
+
axis: e,
|
|
453
|
+
requested: r,
|
|
454
|
+
resolved: i,
|
|
455
|
+
reason: "voice_unsupported"
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
return t.length > 0 ? t : void 0;
|
|
459
|
+
}
|
|
460
|
+
function ye(e) {
|
|
461
|
+
let t = e.localeVoiceFallbacks;
|
|
462
|
+
if (t?.length) for (let e of t) {
|
|
463
|
+
let t = e.axis === "secondaryLocale" ? "secondaryLocale" : "locale";
|
|
464
|
+
console.warn(`[liforma] Session ${t} fell back to ${e.resolved} because the voice does not support ${e.requested}.`);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
function be(e) {
|
|
468
|
+
if (!V(e)) throw Error("Session Launch response must be a JSON object.");
|
|
397
469
|
let t = typeof e.launch == "string" ? e.launch.trim() : "";
|
|
398
470
|
if (!t) throw Error("Session Launch response is missing launch.");
|
|
399
|
-
|
|
400
|
-
|
|
471
|
+
let n = _e(e.session);
|
|
472
|
+
return ye(n), {
|
|
473
|
+
session: n,
|
|
401
474
|
launch: t
|
|
402
475
|
};
|
|
403
476
|
}
|
|
404
477
|
//#endregion
|
|
405
478
|
//#region src/v2/api/mintPublicSession.ts
|
|
406
|
-
function
|
|
479
|
+
function W() {
|
|
407
480
|
try {
|
|
408
481
|
if (typeof globalThis.location?.origin == "string" && globalThis.location.origin) return globalThis.location.origin;
|
|
409
482
|
} catch {}
|
|
410
483
|
}
|
|
411
|
-
function
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
484
|
+
function xe(e) {
|
|
485
|
+
return e ? e.trim().toUpperCase().replace(/-/g, "_") : "";
|
|
486
|
+
}
|
|
487
|
+
function Se(e, t) {
|
|
488
|
+
let n = W(), r = xe(t.code), i = t.message.trim(), a = t.details ?? {};
|
|
489
|
+
if (r === "ORIGIN_NOT_ALLOWED" || /^Origin not allowed/i.test(i) && n) {
|
|
490
|
+
if (i.includes(e) && i.includes("allowed origin")) return t;
|
|
491
|
+
let r = typeof a.origin == "string" && a.origin || n || "(unknown origin)";
|
|
492
|
+
return new z(`Your origin ${r} is not an allowed origin for experience ${e}. If you own this experience, sign in to the Liforma developer portal (app.liforma.ai), open Workspace → Settings → Origins, add ${r} to the list of allowed origins, and ensure “Allow public client-only embeds” is enabled.`, {
|
|
493
|
+
code: "ORIGIN_NOT_ALLOWED",
|
|
494
|
+
requestId: t.requestId,
|
|
495
|
+
status: t.status,
|
|
496
|
+
details: a
|
|
497
|
+
});
|
|
421
498
|
}
|
|
422
|
-
return
|
|
423
|
-
|
|
424
|
-
|
|
499
|
+
return r === "BROWSER_EMBEDS_DISABLED" || /^Browser embeds are not enabled/i.test(i) ? i.includes("Allow public client-only embeds") ? t : new z(`Browser embeds are not enabled for experience ${e}. If you own this experience, sign in to the Liforma developer portal (app.liforma.ai), open Workspace → Settings → Origins, and enable “Allow public client-only embeds”.`, {
|
|
500
|
+
code: "BROWSER_EMBEDS_DISABLED",
|
|
501
|
+
requestId: t.requestId,
|
|
502
|
+
status: t.status,
|
|
503
|
+
details: a
|
|
504
|
+
}) : r === "EXPERIENCE_UNAVAILABLE" || /^Experience is not available\.?$/i.test(i) || /^Unknown experience\.?$/i.test(i) ? i.includes("No playable experience found") ? t : new z(`No playable experience found for “${e}”. Check that the experience id is correct (it should look like exp_…), and that the experience exists and is published in the Liforma developer portal (app.liforma.ai). Deleted, archived, and unpublished experiences cannot be started from a browser embed.`, {
|
|
505
|
+
code: "EXPERIENCE_UNAVAILABLE",
|
|
506
|
+
requestId: t.requestId,
|
|
507
|
+
status: t.status,
|
|
508
|
+
details: a
|
|
509
|
+
}) : t;
|
|
510
|
+
}
|
|
511
|
+
function Ce(e) {
|
|
425
512
|
let t = e?.locale?.trim();
|
|
426
513
|
if (t) return t;
|
|
427
514
|
let n = e?.language?.trim();
|
|
428
515
|
if (n) return n;
|
|
429
516
|
if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
|
|
430
517
|
}
|
|
431
|
-
function
|
|
518
|
+
function we(e) {
|
|
432
519
|
let t = e?.secondaryLocale?.trim(), n = e?.learningLocale?.trim();
|
|
433
|
-
if (t && n && t !== n) throw
|
|
520
|
+
if (t && n && t !== n) throw new z("secondaryLocale and learningLocale disagree; pass only one or make them equal.", { code: "INVALID_BODY" });
|
|
434
521
|
return t || n || void 0;
|
|
435
522
|
}
|
|
436
|
-
function
|
|
437
|
-
let n = { experienceId: e }, r =
|
|
523
|
+
function Te(e, t) {
|
|
524
|
+
let n = { experienceId: e }, r = Ce(t);
|
|
438
525
|
r && (n.locale = r);
|
|
439
|
-
let i =
|
|
440
|
-
return i && (n.secondaryLocale = i), t?.mode && (n.mode = t.mode), t?.
|
|
526
|
+
let i = we(t);
|
|
527
|
+
return i && (n.secondaryLocale = i), t?.mode && (n.mode = t.mode), t?.speechInputMode && (n.speechInputMode = t.speechInputMode), t?.speechOnly !== void 0 && (n.speechOnly = t.speechOnly), n;
|
|
441
528
|
}
|
|
442
|
-
async function
|
|
443
|
-
let n =
|
|
529
|
+
async function Ee(e, t) {
|
|
530
|
+
let n = ce(), r = t?.idempotencyKey?.trim(), i = await fetch(`${n}/v1/browser-sessions`, {
|
|
444
531
|
method: "POST",
|
|
445
|
-
headers: {
|
|
446
|
-
|
|
532
|
+
headers: {
|
|
533
|
+
"Content-Type": "application/json",
|
|
534
|
+
...r ? { "Idempotency-Key": r } : {}
|
|
535
|
+
},
|
|
536
|
+
body: JSON.stringify(Te(e, t))
|
|
447
537
|
});
|
|
448
|
-
if (!
|
|
449
|
-
let t = await
|
|
450
|
-
throw
|
|
538
|
+
if (!i.ok) {
|
|
539
|
+
let t = await i.text();
|
|
540
|
+
throw Se(e, fe(i.status, t, i.headers));
|
|
451
541
|
}
|
|
452
|
-
let
|
|
542
|
+
let a;
|
|
453
543
|
try {
|
|
454
|
-
|
|
544
|
+
a = await i.json();
|
|
455
545
|
} catch {
|
|
456
|
-
throw
|
|
546
|
+
throw new z("Browser session mint returned invalid JSON.", {
|
|
547
|
+
code: "INVALID_RESPONSE",
|
|
548
|
+
status: i.status,
|
|
549
|
+
requestId: i.headers.get("Liforma-Request-Id") ?? void 0
|
|
550
|
+
});
|
|
457
551
|
}
|
|
458
|
-
return
|
|
552
|
+
return be(a);
|
|
459
553
|
}
|
|
460
|
-
async function
|
|
461
|
-
let n =
|
|
554
|
+
async function De(e, t) {
|
|
555
|
+
let n = me(e, t), r = new AbortController(), i = () => r.abort(t.signal?.reason);
|
|
462
556
|
t.signal?.aborted ? i() : t.signal?.addEventListener("abort", i, { once: !0 });
|
|
463
557
|
let a = globalThis.setTimeout(() => r.abort(new DOMException("Session endpoint timed out.", "TimeoutError")), t.timeoutMs ?? 3e4), o;
|
|
464
558
|
try {
|
|
@@ -470,28 +564,32 @@ async function be(e, t) {
|
|
|
470
564
|
globalThis.clearTimeout(a), t.signal?.removeEventListener("abort", i);
|
|
471
565
|
}
|
|
472
566
|
if (!o.ok) {
|
|
473
|
-
let e = await o.text()
|
|
474
|
-
|
|
475
|
-
let n = JSON.parse(e);
|
|
476
|
-
n.message && (t = n.message);
|
|
477
|
-
} catch {}
|
|
478
|
-
throw Error(t);
|
|
567
|
+
let e = await o.text();
|
|
568
|
+
throw fe(o.status, e, o.headers);
|
|
479
569
|
}
|
|
480
|
-
if (!o.headers.get("content-type")?.toLowerCase().includes("application/json")) throw
|
|
570
|
+
if (!o.headers.get("content-type")?.toLowerCase().includes("application/json")) throw new z("Session endpoint must return a JSON Session Launch response.", {
|
|
571
|
+
code: "INVALID_RESPONSE",
|
|
572
|
+
status: o.status,
|
|
573
|
+
requestId: o.headers.get("Liforma-Request-Id") ?? void 0
|
|
574
|
+
});
|
|
481
575
|
let s;
|
|
482
576
|
try {
|
|
483
577
|
s = await o.json();
|
|
484
578
|
} catch {
|
|
485
|
-
throw
|
|
579
|
+
throw new z("Session endpoint returned invalid JSON.", {
|
|
580
|
+
code: "INVALID_RESPONSE",
|
|
581
|
+
status: o.status,
|
|
582
|
+
requestId: o.headers.get("Liforma-Request-Id") ?? void 0
|
|
583
|
+
});
|
|
486
584
|
}
|
|
487
|
-
return
|
|
585
|
+
return be(s);
|
|
488
586
|
}
|
|
489
587
|
//#endregion
|
|
490
588
|
//#region src/v2/conversationProcessor.ts
|
|
491
|
-
function
|
|
589
|
+
function G(e) {
|
|
492
590
|
return typeof e != "object" || !e ? !1 : typeof e[Symbol.asyncIterator] == "function";
|
|
493
591
|
}
|
|
494
|
-
function
|
|
592
|
+
function Oe(e) {
|
|
495
593
|
if (typeof e == "string") {
|
|
496
594
|
let t = e.trim();
|
|
497
595
|
if (!t) throw Error("conversationProcessor returned empty text.");
|
|
@@ -505,24 +603,24 @@ function U(e) {
|
|
|
505
603
|
...e.behavior ? { behavior: e.behavior } : {}
|
|
506
604
|
};
|
|
507
605
|
}
|
|
508
|
-
async function
|
|
606
|
+
async function ke(e, t) {
|
|
509
607
|
let n = await e(t);
|
|
510
|
-
return
|
|
608
|
+
return G(n) ? {
|
|
511
609
|
kind: "stream",
|
|
512
610
|
stream: n
|
|
513
611
|
} : {
|
|
514
612
|
kind: "complete",
|
|
515
|
-
speech:
|
|
613
|
+
speech: Oe(n)
|
|
516
614
|
};
|
|
517
615
|
}
|
|
518
616
|
//#endregion
|
|
519
617
|
//#region src/v2/embed/playerReachability.ts
|
|
520
|
-
var
|
|
521
|
-
function
|
|
618
|
+
var Ae = "3002";
|
|
619
|
+
function K(e) {
|
|
522
620
|
let t = new URL(e);
|
|
523
|
-
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 ||
|
|
621
|
+
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 || Ae}. 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.`;
|
|
524
622
|
}
|
|
525
|
-
async function
|
|
623
|
+
async function q(e, t) {
|
|
526
624
|
try {
|
|
527
625
|
await fetch(e, {
|
|
528
626
|
method: "GET",
|
|
@@ -530,21 +628,21 @@ async function we(e, t) {
|
|
|
530
628
|
signal: AbortSignal.timeout(8e3)
|
|
531
629
|
});
|
|
532
630
|
} catch {
|
|
533
|
-
throw Error(
|
|
631
|
+
throw Error(K(t));
|
|
534
632
|
}
|
|
535
633
|
}
|
|
536
|
-
function
|
|
634
|
+
function je(e, t, n, r) {
|
|
537
635
|
try {
|
|
538
636
|
r && r.length > 0 ? e.postMessage(t, n, r) : e.postMessage(t, n);
|
|
539
637
|
} catch (e) {
|
|
540
|
-
throw e instanceof DOMException && e.name === "SecurityError" ? Error(
|
|
638
|
+
throw e instanceof DOMException && e.name === "SecurityError" ? Error(K(n), { cause: e }) : e;
|
|
541
639
|
}
|
|
542
640
|
}
|
|
543
|
-
var
|
|
544
|
-
function
|
|
545
|
-
return typeof e == "number" &&
|
|
641
|
+
var Me = new Set([1, 2]);
|
|
642
|
+
function Ne(e) {
|
|
643
|
+
return typeof e == "number" && Me.has(e);
|
|
546
644
|
}
|
|
547
|
-
var
|
|
645
|
+
var Pe = new Set([
|
|
548
646
|
"close",
|
|
549
647
|
"stateUpdate",
|
|
550
648
|
"commandResult",
|
|
@@ -567,10 +665,10 @@ var G = new Set([
|
|
|
567
665
|
"widgetDragMove",
|
|
568
666
|
"widgetDragEnd"
|
|
569
667
|
]);
|
|
570
|
-
function
|
|
668
|
+
function Fe(e) {
|
|
571
669
|
if (!e || typeof e != "object") return null;
|
|
572
670
|
let t = e;
|
|
573
|
-
if (!
|
|
671
|
+
if (!Ne(t.schemaVersion) || !t.type || !Pe.has(t.type)) return null;
|
|
574
672
|
if (t.type === "widgetReady" || t.type === "widgetExpand" || t.type === "widgetCollapse") return t;
|
|
575
673
|
if (t.type === "widgetAudioSettings") {
|
|
576
674
|
let e = t.payload;
|
|
@@ -588,7 +686,7 @@ function Oe(e) {
|
|
|
588
686
|
}
|
|
589
687
|
return !t.payload || typeof t.payload != "object" ? null : t;
|
|
590
688
|
}
|
|
591
|
-
function
|
|
689
|
+
function Ie(e, t, n) {
|
|
592
690
|
let r = e.trim();
|
|
593
691
|
if (!r) throw Error("createLaunchMessage requires a non-empty launch string.");
|
|
594
692
|
return {
|
|
@@ -601,20 +699,20 @@ function ke(e, t, n) {
|
|
|
601
699
|
}
|
|
602
700
|
};
|
|
603
701
|
}
|
|
604
|
-
function
|
|
702
|
+
function Le() {
|
|
605
703
|
return {
|
|
606
704
|
type: "parentHello",
|
|
607
705
|
schemaVersion: 2
|
|
608
706
|
};
|
|
609
707
|
}
|
|
610
|
-
function
|
|
708
|
+
function Re(e) {
|
|
611
709
|
return {
|
|
612
710
|
type: "widgetSetChrome",
|
|
613
711
|
schemaVersion: 2,
|
|
614
712
|
payload: { mode: e }
|
|
615
713
|
};
|
|
616
714
|
}
|
|
617
|
-
function
|
|
715
|
+
function ze() {
|
|
618
716
|
return {
|
|
619
717
|
type: "widgetToggleAudioSettings",
|
|
620
718
|
schemaVersion: 2,
|
|
@@ -623,30 +721,30 @@ function K() {
|
|
|
623
721
|
}
|
|
624
722
|
//#endregion
|
|
625
723
|
//#region src/v2/embed/iframeHost.ts
|
|
626
|
-
function
|
|
724
|
+
function Be(e) {
|
|
627
725
|
return e;
|
|
628
726
|
}
|
|
629
|
-
function
|
|
727
|
+
function J() {
|
|
630
728
|
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)}`;
|
|
631
729
|
}
|
|
632
|
-
var
|
|
633
|
-
function
|
|
730
|
+
var Ve = 3e4;
|
|
731
|
+
function He(e) {
|
|
634
732
|
let t = e.container;
|
|
635
733
|
getComputedStyle(t).position === "static" && (t.style.position = "relative");
|
|
636
734
|
let n = document.createElement("iframe");
|
|
637
735
|
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");
|
|
638
736
|
let r = !1, i = /* @__PURE__ */ new Map(), a = new Promise((t, r) => {
|
|
639
737
|
let i = () => {
|
|
640
|
-
o(),
|
|
738
|
+
o(), q(e.src, e.playerOrigin).then(t, r);
|
|
641
739
|
}, a = () => {
|
|
642
|
-
o(), r(Error(
|
|
740
|
+
o(), r(Error(K(e.playerOrigin)));
|
|
643
741
|
}, o = () => {
|
|
644
742
|
n.removeEventListener("load", i), n.removeEventListener("error", a);
|
|
645
743
|
};
|
|
646
744
|
n.addEventListener("load", i), n.addEventListener("error", a);
|
|
647
745
|
}), o = (t) => {
|
|
648
746
|
if (r || t.source !== n.contentWindow || t.origin !== e.playerOrigin) return;
|
|
649
|
-
let a =
|
|
747
|
+
let a = Fe(t.data);
|
|
650
748
|
if (a) switch (a.type) {
|
|
651
749
|
case "close":
|
|
652
750
|
e.onClose?.(a.payload);
|
|
@@ -682,10 +780,10 @@ function Pe(e) {
|
|
|
682
780
|
e.onUserSpeechEnded?.(a.payload);
|
|
683
781
|
break;
|
|
684
782
|
case "modeChange":
|
|
685
|
-
e.onActivityChange?.(
|
|
783
|
+
e.onActivityChange?.(Be(a.payload.mode));
|
|
686
784
|
break;
|
|
687
785
|
case "activityChange":
|
|
688
|
-
e.onActivityChange?.(a.payload.activity)
|
|
786
|
+
e.onActivityChange?.(a.payload.activity);
|
|
689
787
|
break;
|
|
690
788
|
case "message":
|
|
691
789
|
e.onMessage?.(a.payload);
|
|
@@ -723,10 +821,10 @@ function Pe(e) {
|
|
|
723
821
|
let s = (t, i) => {
|
|
724
822
|
if (r) return;
|
|
725
823
|
let a = n.contentWindow;
|
|
726
|
-
if (!a) throw Error(
|
|
727
|
-
|
|
824
|
+
if (!a) throw Error(K(e.playerOrigin));
|
|
825
|
+
je(a, t, e.playerOrigin, i);
|
|
728
826
|
}, c = (e, t = 12e4, n) => {
|
|
729
|
-
let r = e.type !== "parentHello" && e.payload && "correlationId" in e.payload ? e.payload.correlationId :
|
|
827
|
+
let r = e.type !== "parentHello" && e.payload && "correlationId" in e.payload ? e.payload.correlationId : J();
|
|
730
828
|
return e.type !== "parentHello" && e.payload && "correlationId" in e.payload || e.type !== "parentHello" && e.payload && (e.payload.correlationId = r), new Promise((a, o) => {
|
|
731
829
|
i.set(r, {
|
|
732
830
|
resolve: (e) => a(e),
|
|
@@ -741,14 +839,14 @@ function Pe(e) {
|
|
|
741
839
|
return a;
|
|
742
840
|
},
|
|
743
841
|
postParentHello() {
|
|
744
|
-
s(
|
|
842
|
+
s(Le());
|
|
745
843
|
},
|
|
746
844
|
postLaunch(t, i, a) {
|
|
747
845
|
if (r) return;
|
|
748
846
|
let o = n.contentWindow;
|
|
749
847
|
if (!o) throw Error("Liforma embed iframe is not ready.");
|
|
750
|
-
let s =
|
|
751
|
-
r ||
|
|
848
|
+
let s = Ie(t, i, a), c = () => {
|
|
849
|
+
r || je(o, s, e.playerOrigin);
|
|
752
850
|
};
|
|
753
851
|
c();
|
|
754
852
|
for (let e = 1; e <= 12; e += 1) window.setTimeout(c, e * 75);
|
|
@@ -766,17 +864,17 @@ function Pe(e) {
|
|
|
766
864
|
throw Error("postManifest is deprecated; use postLaunch with an opaque launch string from SessionLaunchResponse.");
|
|
767
865
|
},
|
|
768
866
|
postWidgetSetChrome(e) {
|
|
769
|
-
s(
|
|
867
|
+
s(Re(e));
|
|
770
868
|
},
|
|
771
869
|
postWidgetToggleAudioSettings() {
|
|
772
|
-
s(
|
|
870
|
+
s(ze());
|
|
773
871
|
},
|
|
774
872
|
speak(e) {
|
|
775
873
|
return c({
|
|
776
874
|
type: "speak",
|
|
777
875
|
schemaVersion: 2,
|
|
778
876
|
payload: {
|
|
779
|
-
correlationId:
|
|
877
|
+
correlationId: J(),
|
|
780
878
|
text: e.text,
|
|
781
879
|
...e.characterId ? { characterId: e.characterId } : {},
|
|
782
880
|
...e.behavior ? { behavior: e.behavior } : {}
|
|
@@ -787,14 +885,14 @@ function Pe(e) {
|
|
|
787
885
|
return c({
|
|
788
886
|
type: "startListening",
|
|
789
887
|
schemaVersion: 2,
|
|
790
|
-
payload: { correlationId:
|
|
888
|
+
payload: { correlationId: J() }
|
|
791
889
|
});
|
|
792
890
|
},
|
|
793
891
|
stopListening() {
|
|
794
892
|
return c({
|
|
795
893
|
type: "stopListening",
|
|
796
894
|
schemaVersion: 2,
|
|
797
|
-
payload: { correlationId:
|
|
895
|
+
payload: { correlationId: J() }
|
|
798
896
|
});
|
|
799
897
|
},
|
|
800
898
|
listenOnce(e) {
|
|
@@ -802,13 +900,13 @@ function Pe(e) {
|
|
|
802
900
|
type: "listenOnce",
|
|
803
901
|
schemaVersion: 2,
|
|
804
902
|
payload: {
|
|
805
|
-
correlationId:
|
|
903
|
+
correlationId: J(),
|
|
806
904
|
...e?.timeoutMs === void 0 ? {} : { timeoutMs: e.timeoutMs }
|
|
807
905
|
}
|
|
808
906
|
});
|
|
809
907
|
},
|
|
810
908
|
async speakProcessorStream(e, t) {
|
|
811
|
-
let n =
|
|
909
|
+
let n = J(), r = J(), i = (await c({
|
|
812
910
|
type: "speakStreamStart",
|
|
813
911
|
schemaVersion: 2,
|
|
814
912
|
payload: {
|
|
@@ -853,7 +951,7 @@ function Pe(e) {
|
|
|
853
951
|
}
|
|
854
952
|
},
|
|
855
953
|
speechPlay(e) {
|
|
856
|
-
let t =
|
|
954
|
+
let t = J(), n = [];
|
|
857
955
|
return (e.source.kind === "pcm" || e.source.kind === "encoded") && n.push(e.source.data), c({
|
|
858
956
|
type: "speechPlay",
|
|
859
957
|
schemaVersion: 2,
|
|
@@ -872,7 +970,7 @@ function Pe(e) {
|
|
|
872
970
|
type: "speechUtteranceBegin",
|
|
873
971
|
schemaVersion: 2,
|
|
874
972
|
payload: {
|
|
875
|
-
correlationId:
|
|
973
|
+
correlationId: J(),
|
|
876
974
|
utteranceId: e.utteranceId,
|
|
877
975
|
format: e.format,
|
|
878
976
|
queue: e.queue,
|
|
@@ -886,19 +984,19 @@ function Pe(e) {
|
|
|
886
984
|
type: "speechUtteranceWrite",
|
|
887
985
|
schemaVersion: 2,
|
|
888
986
|
payload: {
|
|
889
|
-
correlationId:
|
|
987
|
+
correlationId: J(),
|
|
890
988
|
utteranceId: e.utteranceId,
|
|
891
989
|
audio: e.audio,
|
|
892
990
|
byteLength: e.byteLength
|
|
893
991
|
}
|
|
894
|
-
},
|
|
992
|
+
}, Ve, [e.audio]);
|
|
895
993
|
},
|
|
896
994
|
speechUtteranceSetTranscript(e) {
|
|
897
995
|
return c({
|
|
898
996
|
type: "speechUtteranceSetTranscript",
|
|
899
997
|
schemaVersion: 2,
|
|
900
998
|
payload: {
|
|
901
|
-
correlationId:
|
|
999
|
+
correlationId: J(),
|
|
902
1000
|
utteranceId: e.utteranceId,
|
|
903
1001
|
transcript: e.transcript
|
|
904
1002
|
}
|
|
@@ -909,7 +1007,7 @@ function Pe(e) {
|
|
|
909
1007
|
type: "speechUtteranceClose",
|
|
910
1008
|
schemaVersion: 2,
|
|
911
1009
|
payload: {
|
|
912
|
-
correlationId:
|
|
1010
|
+
correlationId: J(),
|
|
913
1011
|
utteranceId: e.utteranceId,
|
|
914
1012
|
...e.transcript === void 0 ? {} : { transcript: e.transcript },
|
|
915
1013
|
...e.history ? { history: e.history } : {}
|
|
@@ -921,7 +1019,7 @@ function Pe(e) {
|
|
|
921
1019
|
type: "speechUtteranceCancel",
|
|
922
1020
|
schemaVersion: 2,
|
|
923
1021
|
payload: {
|
|
924
|
-
correlationId:
|
|
1022
|
+
correlationId: J(),
|
|
925
1023
|
utteranceId: e.utteranceId
|
|
926
1024
|
}
|
|
927
1025
|
});
|
|
@@ -931,7 +1029,7 @@ function Pe(e) {
|
|
|
931
1029
|
type: "speechInterrupt",
|
|
932
1030
|
schemaVersion: 2,
|
|
933
1031
|
payload: {
|
|
934
|
-
correlationId:
|
|
1032
|
+
correlationId: J(),
|
|
935
1033
|
...e
|
|
936
1034
|
}
|
|
937
1035
|
});
|
|
@@ -940,7 +1038,7 @@ function Pe(e) {
|
|
|
940
1038
|
return c({
|
|
941
1039
|
type: "getConversation",
|
|
942
1040
|
schemaVersion: 2,
|
|
943
|
-
payload: { correlationId:
|
|
1041
|
+
payload: { correlationId: J() }
|
|
944
1042
|
});
|
|
945
1043
|
},
|
|
946
1044
|
destroy() {
|
|
@@ -954,7 +1052,7 @@ function Pe(e) {
|
|
|
954
1052
|
}
|
|
955
1053
|
//#endregion
|
|
956
1054
|
//#region src/v2/embed/readyGate.ts
|
|
957
|
-
function
|
|
1055
|
+
function Ue(e) {
|
|
958
1056
|
let t, n = !1, r = !1, i = () => {
|
|
959
1057
|
r || !n || t === void 0 || (r = !0, e(t));
|
|
960
1058
|
};
|
|
@@ -969,35 +1067,47 @@ function Fe(e) {
|
|
|
969
1067
|
}
|
|
970
1068
|
//#endregion
|
|
971
1069
|
//#region src/v2/shims/embedBaseUrl.ts
|
|
972
|
-
var
|
|
973
|
-
function
|
|
1070
|
+
var We = "https://player.liforma.ai/embed", Ge = "http://localhost:3002/embed";
|
|
1071
|
+
function Ke() {
|
|
974
1072
|
let e = globalThis.__LIFORMA_PLAYER_EMBED_URL;
|
|
975
1073
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
976
1074
|
if (typeof document > "u") return null;
|
|
977
1075
|
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();
|
|
978
1076
|
return t ? t.replace(/\/$/, "") : null;
|
|
979
1077
|
}
|
|
980
|
-
function
|
|
981
|
-
let e =
|
|
982
|
-
return e ? e.endsWith("/embed") ? e : `${e}/embed` :
|
|
1078
|
+
function qe() {
|
|
1079
|
+
let e = Ke();
|
|
1080
|
+
return e ? e.endsWith("/embed") ? e : `${e}/embed` : c() ? Ge : We;
|
|
983
1081
|
}
|
|
984
|
-
function
|
|
985
|
-
let s = (e ??
|
|
1082
|
+
function Je(e, t, n, r, i, a, o) {
|
|
1083
|
+
let s = (e ?? qe()).replace(/\/$/, ""), c = s.endsWith("/embed") ? s : `${s}/embed`, l = new URL(c), u = n?.trim();
|
|
986
1084
|
u && l.searchParams.set("locationId", u);
|
|
987
1085
|
let d = r?.trim();
|
|
988
|
-
return d && l.searchParams.set("avatarId", d), i === "face" && l.searchParams.set("fit", "face"), a === "widget" && l.searchParams.set("ui", "widget"), o && l.searchParams.set("close", "1"), t && l.searchParams.set("debug", "true"),
|
|
1086
|
+
return d && l.searchParams.set("avatarId", d), i === "face" && l.searchParams.set("fit", "face"), a === "widget" && l.searchParams.set("ui", "widget"), o && l.searchParams.set("close", "1"), t && l.searchParams.set("debug", "true"), Ye(l.toString());
|
|
989
1087
|
}
|
|
990
|
-
function
|
|
1088
|
+
function Ye(e) {
|
|
991
1089
|
if (typeof location > "u") return e;
|
|
992
1090
|
let t = new URL(e);
|
|
993
1091
|
return t.searchParams.set("parentOrigin", location.origin), t.toString();
|
|
994
1092
|
}
|
|
995
|
-
function
|
|
1093
|
+
function Xe(e) {
|
|
996
1094
|
return new URL(e).origin;
|
|
997
1095
|
}
|
|
998
1096
|
//#endregion
|
|
999
1097
|
//#region src/v2/experienceEvents.ts
|
|
1000
|
-
function
|
|
1098
|
+
function Ze() {
|
|
1099
|
+
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)}`;
|
|
1100
|
+
}
|
|
1101
|
+
function Qe(e, t, n) {
|
|
1102
|
+
return {
|
|
1103
|
+
id: Ze(),
|
|
1104
|
+
type: e,
|
|
1105
|
+
sessionId: t,
|
|
1106
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1107
|
+
data: n
|
|
1108
|
+
};
|
|
1109
|
+
}
|
|
1110
|
+
function $e() {
|
|
1001
1111
|
return {
|
|
1002
1112
|
ready: /* @__PURE__ */ new Set(),
|
|
1003
1113
|
started: /* @__PURE__ */ new Set(),
|
|
@@ -1010,36 +1120,35 @@ function Ue() {
|
|
|
1010
1120
|
message: /* @__PURE__ */ new Set(),
|
|
1011
1121
|
listeningState: /* @__PURE__ */ new Set(),
|
|
1012
1122
|
activityChange: /* @__PURE__ */ new Set(),
|
|
1013
|
-
modeChange: /* @__PURE__ */ new Set(),
|
|
1014
1123
|
conversationProcessorError: /* @__PURE__ */ new Set()
|
|
1015
1124
|
};
|
|
1016
1125
|
}
|
|
1017
|
-
function
|
|
1126
|
+
function et(e, t, n) {
|
|
1018
1127
|
return e[t].add(n), () => e[t].delete(n);
|
|
1019
1128
|
}
|
|
1020
|
-
function
|
|
1129
|
+
function tt(e, t, n) {
|
|
1021
1130
|
for (let r of e[t]) r(n);
|
|
1022
1131
|
}
|
|
1023
|
-
function
|
|
1132
|
+
function nt(e) {
|
|
1024
1133
|
for (let t of Object.keys(e)) e[t].clear();
|
|
1025
1134
|
}
|
|
1026
1135
|
//#endregion
|
|
1027
1136
|
//#region src/v2/speech/types.ts
|
|
1028
|
-
function
|
|
1137
|
+
function rt(e) {
|
|
1029
1138
|
return "data" in e && "format" in e && e.format != null && !("track" in e);
|
|
1030
1139
|
}
|
|
1031
|
-
function
|
|
1140
|
+
function it(e) {
|
|
1032
1141
|
return "url" in e && typeof e.url == "string";
|
|
1033
1142
|
}
|
|
1034
|
-
function
|
|
1143
|
+
function at(e) {
|
|
1035
1144
|
if (!("track" in e)) return !1;
|
|
1036
1145
|
let t = e.track;
|
|
1037
1146
|
return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
|
|
1038
1147
|
}
|
|
1039
|
-
function
|
|
1040
|
-
return !
|
|
1148
|
+
function ot(e) {
|
|
1149
|
+
return !rt(e) && !it(e) && !at(e) && "encoding" in e && typeof e.encoding == "string";
|
|
1041
1150
|
}
|
|
1042
|
-
var
|
|
1151
|
+
var st = [
|
|
1043
1152
|
8e3,
|
|
1044
1153
|
16e3,
|
|
1045
1154
|
22050,
|
|
@@ -1057,14 +1166,14 @@ var Xe = [
|
|
|
1057
1166
|
MAX_UTTERANCE_DURATION_MS: 9e4,
|
|
1058
1167
|
MAX_PENDING_WRITES: 8,
|
|
1059
1168
|
DEFAULT_WRITE_TIMEOUT_MS: 5e3
|
|
1060
|
-
},
|
|
1169
|
+
}, ct = class extends Error {
|
|
1061
1170
|
operation;
|
|
1062
1171
|
requiredCapability;
|
|
1063
1172
|
name = "UnsupportedSpeechOperationError";
|
|
1064
1173
|
constructor(e, t) {
|
|
1065
1174
|
super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
|
|
1066
1175
|
}
|
|
1067
|
-
},
|
|
1176
|
+
}, lt = class extends Error {
|
|
1068
1177
|
name = "SpeechUtteranceClosedError";
|
|
1069
1178
|
constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
|
|
1070
1179
|
super(e);
|
|
@@ -1074,72 +1183,72 @@ var Xe = [
|
|
|
1074
1183
|
constructor(e, t) {
|
|
1075
1184
|
super(e, t);
|
|
1076
1185
|
}
|
|
1077
|
-
},
|
|
1186
|
+
}, ut = class extends Error {
|
|
1078
1187
|
name = "SpeechBufferTimeoutError";
|
|
1079
1188
|
constructor(e = "Timed out waiting for speech buffer capacity.") {
|
|
1080
1189
|
super(e);
|
|
1081
1190
|
}
|
|
1082
1191
|
};
|
|
1083
|
-
function
|
|
1192
|
+
function dt(e = "none") {
|
|
1084
1193
|
return {
|
|
1085
1194
|
mode: e,
|
|
1086
1195
|
trackedDurationMs: 0,
|
|
1087
1196
|
fallbackDurationMs: 0
|
|
1088
1197
|
};
|
|
1089
1198
|
}
|
|
1090
|
-
function
|
|
1091
|
-
return
|
|
1199
|
+
function ft(e) {
|
|
1200
|
+
return st.includes(e);
|
|
1092
1201
|
}
|
|
1093
|
-
function
|
|
1202
|
+
function pt(e) {
|
|
1094
1203
|
if (e.encoding !== "pcm_s16le") throw new X(`Unsupported audio encoding: ${e.encoding}`);
|
|
1095
1204
|
if (e.channels !== 1) throw new X(`Unsupported channel count: ${e.channels}`);
|
|
1096
|
-
if (!
|
|
1205
|
+
if (!ft(e.sampleRate)) throw new X(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1097
1206
|
}
|
|
1098
|
-
function
|
|
1099
|
-
if (
|
|
1100
|
-
|
|
1207
|
+
function mt(e) {
|
|
1208
|
+
if (rt(e)) {
|
|
1209
|
+
pt(e.format);
|
|
1101
1210
|
return;
|
|
1102
1211
|
}
|
|
1103
|
-
if (
|
|
1212
|
+
if (it(e)) {
|
|
1104
1213
|
if (!e.url.trim()) throw new X("Audio URL must be non-empty.");
|
|
1105
|
-
if (e.sampleRate !== void 0 && !
|
|
1214
|
+
if (e.sampleRate !== void 0 && !ft(e.sampleRate)) throw new X(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1106
1215
|
return;
|
|
1107
1216
|
}
|
|
1108
|
-
if (
|
|
1217
|
+
if (at(e)) {
|
|
1109
1218
|
if (e.track.kind !== "audio") throw new X("speech.play track must be an audio MediaStreamTrack.");
|
|
1110
|
-
if (e.sampleRate !== void 0 && !
|
|
1219
|
+
if (e.sampleRate !== void 0 && !ft(e.sampleRate)) throw new X(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1111
1220
|
return;
|
|
1112
1221
|
}
|
|
1113
|
-
if (
|
|
1222
|
+
if (ot(e)) {
|
|
1114
1223
|
let t = e.encoding.trim().toLowerCase();
|
|
1115
1224
|
if (!t) throw new X("Encoded audio MIME type is required.");
|
|
1116
1225
|
if (t === "pcm_s16le") throw new X("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
|
|
1117
|
-
if (e.sampleRate !== void 0 && !
|
|
1226
|
+
if (e.sampleRate !== void 0 && !ft(e.sampleRate)) throw new X(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1118
1227
|
return;
|
|
1119
1228
|
}
|
|
1120
1229
|
throw new X("Unsupported speech.play audio shape.");
|
|
1121
1230
|
}
|
|
1122
|
-
function
|
|
1123
|
-
if (e.format) return
|
|
1231
|
+
function ht(e) {
|
|
1232
|
+
if (e.format) return pt(e.format), e.format;
|
|
1124
1233
|
if (e.track) {
|
|
1125
1234
|
let t = {
|
|
1126
1235
|
encoding: "pcm_s16le",
|
|
1127
1236
|
sampleRate: e.sampleRate ?? 24e3,
|
|
1128
1237
|
channels: 1
|
|
1129
1238
|
};
|
|
1130
|
-
return
|
|
1239
|
+
return pt(t), t;
|
|
1131
1240
|
}
|
|
1132
1241
|
throw new X("createUtterance requires format or track.");
|
|
1133
1242
|
}
|
|
1134
|
-
function
|
|
1243
|
+
function gt(e) {
|
|
1135
1244
|
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1136
1245
|
}
|
|
1137
|
-
function
|
|
1246
|
+
function _t(e) {
|
|
1138
1247
|
return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
|
|
1139
1248
|
}
|
|
1140
1249
|
//#endregion
|
|
1141
1250
|
//#region src/byo/pcm.ts
|
|
1142
|
-
function
|
|
1251
|
+
function vt(e) {
|
|
1143
1252
|
let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
|
|
1144
1253
|
for (let t = 0; t < e.length; t++) {
|
|
1145
1254
|
let r = Math.max(-1, Math.min(1, e[t]));
|
|
@@ -1149,11 +1258,11 @@ function st(e) {
|
|
|
1149
1258
|
}
|
|
1150
1259
|
//#endregion
|
|
1151
1260
|
//#region src/byo/resample.ts
|
|
1152
|
-
function
|
|
1261
|
+
function yt(e, t, n, r, i) {
|
|
1153
1262
|
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;
|
|
1154
1263
|
return ((a * i + o) * i + s) * i + c;
|
|
1155
1264
|
}
|
|
1156
|
-
function
|
|
1265
|
+
function bt(e, t) {
|
|
1157
1266
|
if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
|
|
1158
1267
|
if (e === t) return {
|
|
1159
1268
|
fromRate: e,
|
|
@@ -1176,7 +1285,7 @@ function lt(e, t) {
|
|
|
1176
1285
|
let a = [];
|
|
1177
1286
|
for (; i + 2 < r.length - 1;) {
|
|
1178
1287
|
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);
|
|
1179
|
-
a.push(
|
|
1288
|
+
a.push(yt(r[o], r[e], r[s], r[c], t)), i += n;
|
|
1180
1289
|
}
|
|
1181
1290
|
let o = Math.max(0, Math.floor(i) - 1);
|
|
1182
1291
|
return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
|
|
@@ -1188,7 +1297,7 @@ function lt(e, t) {
|
|
|
1188
1297
|
}
|
|
1189
1298
|
//#endregion
|
|
1190
1299
|
//#region src/byo/audioCapture.ts
|
|
1191
|
-
var
|
|
1300
|
+
var xt = "liforma-pcm-capture", St = `
|
|
1192
1301
|
class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
1193
1302
|
process(inputs) {
|
|
1194
1303
|
const ch = inputs[0] && inputs[0][0];
|
|
@@ -1200,29 +1309,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
|
1200
1309
|
return true;
|
|
1201
1310
|
}
|
|
1202
1311
|
}
|
|
1203
|
-
registerProcessor('${
|
|
1204
|
-
`,
|
|
1205
|
-
function
|
|
1206
|
-
return
|
|
1312
|
+
registerProcessor('${xt}', LiformaPcmCaptureProcessor);
|
|
1313
|
+
`, Ct = null;
|
|
1314
|
+
function wt() {
|
|
1315
|
+
return Ct ||= URL.createObjectURL(new Blob([St], { type: "application/javascript" })), Ct;
|
|
1207
1316
|
}
|
|
1208
|
-
function
|
|
1317
|
+
function Tt() {
|
|
1209
1318
|
return window.AudioContext || window.webkitAudioContext || null;
|
|
1210
1319
|
}
|
|
1211
|
-
async function
|
|
1212
|
-
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o =
|
|
1320
|
+
async function Et(e) {
|
|
1321
|
+
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = Tt();
|
|
1213
1322
|
if (!o) throw Error("Web Audio is required for audio capture");
|
|
1214
1323
|
let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
|
|
1215
1324
|
l.gain.value = 0;
|
|
1216
|
-
let u = s.sampleRate, d =
|
|
1325
|
+
let u = s.sampleRate, d = bt(u, n), f = !1, p = !1, m = (e) => {
|
|
1217
1326
|
if (f || i && !i()) return;
|
|
1218
1327
|
let t = d.push(e);
|
|
1219
|
-
t.length !== 0 && r(
|
|
1328
|
+
t.length !== 0 && r(vt(t));
|
|
1220
1329
|
}, h = () => void 0;
|
|
1221
1330
|
return await (async () => {
|
|
1222
1331
|
if (typeof s.audioWorklet?.addModule != "function") return !1;
|
|
1223
1332
|
try {
|
|
1224
|
-
await s.audioWorklet.addModule(
|
|
1225
|
-
let e = new AudioWorkletNode(s,
|
|
1333
|
+
await s.audioWorklet.addModule(wt());
|
|
1334
|
+
let e = new AudioWorkletNode(s, xt, {
|
|
1226
1335
|
numberOfInputs: 1,
|
|
1227
1336
|
numberOfOutputs: 1,
|
|
1228
1337
|
outputChannelCount: [1]
|
|
@@ -1272,7 +1381,7 @@ async function ht(e) {
|
|
|
1272
1381
|
}
|
|
1273
1382
|
//#endregion
|
|
1274
1383
|
//#region src/v2/speech/captureMediaStreamTrack.ts
|
|
1275
|
-
async function
|
|
1384
|
+
async function Dt(e) {
|
|
1276
1385
|
let { track: t, utterance: n, sampleRate: r, signal: i } = e;
|
|
1277
1386
|
if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new X("MediaStreamTrack is not available in this environment.");
|
|
1278
1387
|
if (t.kind !== "audio") throw new X("speech.play track must be an audio MediaStreamTrack.");
|
|
@@ -1281,13 +1390,13 @@ async function gt(e) {
|
|
|
1281
1390
|
s || (s = !0, c?.stop(), c = null);
|
|
1282
1391
|
};
|
|
1283
1392
|
try {
|
|
1284
|
-
c = await
|
|
1393
|
+
c = await Et({
|
|
1285
1394
|
mediaStream: a,
|
|
1286
1395
|
targetSampleRate: r,
|
|
1287
1396
|
shouldSend: () => !s && !i?.aborted,
|
|
1288
1397
|
onPcm: (e) => {
|
|
1289
1398
|
if (s || i?.aborted) return;
|
|
1290
|
-
let t =
|
|
1399
|
+
let t = gt(e);
|
|
1291
1400
|
o = o.then(async () => {
|
|
1292
1401
|
if (s || i?.aborted) return;
|
|
1293
1402
|
let e = 0;
|
|
@@ -1316,10 +1425,10 @@ async function gt(e) {
|
|
|
1316
1425
|
}
|
|
1317
1426
|
//#endregion
|
|
1318
1427
|
//#region src/v2/speech/speechController.ts
|
|
1319
|
-
async function
|
|
1320
|
-
if (
|
|
1321
|
-
if (
|
|
1322
|
-
let t =
|
|
1428
|
+
async function Ot(e, t) {
|
|
1429
|
+
if (at(e)) throw new X("MediaStreamTrack play is handled on the host before embed.");
|
|
1430
|
+
if (rt(e)) {
|
|
1431
|
+
let t = gt(e.data);
|
|
1323
1432
|
if (t.byteLength & 1) throw new X("PCM byte length must be even.");
|
|
1324
1433
|
return {
|
|
1325
1434
|
kind: "pcm",
|
|
@@ -1327,17 +1436,17 @@ async function _t(e, t) {
|
|
|
1327
1436
|
format: e.format
|
|
1328
1437
|
};
|
|
1329
1438
|
}
|
|
1330
|
-
if (
|
|
1439
|
+
if (it(e)) return {
|
|
1331
1440
|
kind: "url",
|
|
1332
1441
|
url: e.url.trim(),
|
|
1333
1442
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
1334
1443
|
};
|
|
1335
|
-
if (!
|
|
1444
|
+
if (!ot(e)) throw new X("Unsupported speech.play audio shape.");
|
|
1336
1445
|
let n;
|
|
1337
1446
|
if (typeof Blob < "u" && e.data instanceof Blob) {
|
|
1338
1447
|
if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
1339
1448
|
n = new Uint8Array(await e.data.arrayBuffer());
|
|
1340
|
-
} else n =
|
|
1449
|
+
} else n = gt(e.data);
|
|
1341
1450
|
return {
|
|
1342
1451
|
kind: "encoded",
|
|
1343
1452
|
data: n.slice().buffer,
|
|
@@ -1345,10 +1454,10 @@ async function _t(e, t) {
|
|
|
1345
1454
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
1346
1455
|
};
|
|
1347
1456
|
}
|
|
1348
|
-
function
|
|
1457
|
+
function kt() {
|
|
1349
1458
|
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)}`;
|
|
1350
1459
|
}
|
|
1351
|
-
function
|
|
1460
|
+
function At(e, t = "completed") {
|
|
1352
1461
|
return {
|
|
1353
1462
|
utteranceId: e.speechId,
|
|
1354
1463
|
characterId: e.characterId,
|
|
@@ -1365,10 +1474,10 @@ function yt(e, t = "completed") {
|
|
|
1365
1474
|
function Z(e) {
|
|
1366
1475
|
return e instanceof Error ? e : new X(String(e));
|
|
1367
1476
|
}
|
|
1368
|
-
function
|
|
1477
|
+
function jt(e) {
|
|
1369
1478
|
return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
|
|
1370
1479
|
}
|
|
1371
|
-
var
|
|
1480
|
+
var Mt = class {
|
|
1372
1481
|
id;
|
|
1373
1482
|
characterId;
|
|
1374
1483
|
result;
|
|
@@ -1403,8 +1512,8 @@ var xt = class {
|
|
|
1403
1512
|
}, { once: !0 });
|
|
1404
1513
|
}
|
|
1405
1514
|
async write(e, t) {
|
|
1406
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
1407
|
-
let n =
|
|
1515
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new lt();
|
|
1516
|
+
let n = gt(e);
|
|
1408
1517
|
if (n.byteLength & 1) throw new X("PCM chunk byte length must be even (complete s16 samples).");
|
|
1409
1518
|
if (n.byteLength > Y.MAX_CHUNK_BYTES) throw new X(`PCM chunk exceeds MAX_CHUNK_BYTES (${Y.MAX_CHUNK_BYTES}).`);
|
|
1410
1519
|
if (n.byteLength === 0) return;
|
|
@@ -1413,13 +1522,13 @@ var xt = class {
|
|
|
1413
1522
|
let i = n.byteLength / 2 / this.sampleRate * 1e3;
|
|
1414
1523
|
if (this.bufferedMs + i > Y.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new X("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
|
|
1415
1524
|
let a = async () => {
|
|
1416
|
-
if (this.closed || this.settled) throw new
|
|
1525
|
+
if (this.closed || this.settled) throw new lt();
|
|
1417
1526
|
let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
|
|
1418
1527
|
utteranceId: this.id,
|
|
1419
1528
|
audio: t.buffer,
|
|
1420
1529
|
byteLength: t.byteLength
|
|
1421
1530
|
}), a = await Promise.race([i, new Promise((e, t) => {
|
|
1422
|
-
setTimeout(() => t(new
|
|
1531
|
+
setTimeout(() => t(new ut()), r);
|
|
1423
1532
|
})]);
|
|
1424
1533
|
this.bufferedMs = Math.max(0, a.bufferedMs);
|
|
1425
1534
|
}, o = this.writeChain.then(a, a);
|
|
@@ -1431,7 +1540,7 @@ var xt = class {
|
|
|
1431
1540
|
}
|
|
1432
1541
|
}
|
|
1433
1542
|
async setTranscript(e) {
|
|
1434
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
1543
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new lt();
|
|
1435
1544
|
await this.requireHost().speechUtteranceSetTranscript({
|
|
1436
1545
|
utteranceId: this.id,
|
|
1437
1546
|
transcript: e
|
|
@@ -1466,7 +1575,7 @@ var xt = class {
|
|
|
1466
1575
|
characterId: this.characterId,
|
|
1467
1576
|
status: "cancelled",
|
|
1468
1577
|
durationMs: 0,
|
|
1469
|
-
animation:
|
|
1578
|
+
animation: dt("none")
|
|
1470
1579
|
};
|
|
1471
1580
|
return this.resolve(t), t;
|
|
1472
1581
|
} catch (e) {
|
|
@@ -1483,7 +1592,7 @@ var xt = class {
|
|
|
1483
1592
|
return e;
|
|
1484
1593
|
}
|
|
1485
1594
|
resolve(e) {
|
|
1486
|
-
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new
|
|
1595
|
+
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new lt()));
|
|
1487
1596
|
}
|
|
1488
1597
|
fail(e) {
|
|
1489
1598
|
this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
|
|
@@ -1495,7 +1604,7 @@ var xt = class {
|
|
|
1495
1604
|
}
|
|
1496
1605
|
await new Promise((t, n) => {
|
|
1497
1606
|
let r = setTimeout(() => {
|
|
1498
|
-
n(new
|
|
1607
|
+
n(new ut());
|
|
1499
1608
|
}, e);
|
|
1500
1609
|
this.pendingWriteWaiters.push({
|
|
1501
1610
|
resolve: () => {
|
|
@@ -1514,13 +1623,13 @@ var xt = class {
|
|
|
1514
1623
|
for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
|
|
1515
1624
|
}
|
|
1516
1625
|
};
|
|
1517
|
-
function
|
|
1626
|
+
function Nt(e) {
|
|
1518
1627
|
let t = null, n = (t, n) => {
|
|
1519
|
-
if (!e.getCapabilities()[n]) throw new
|
|
1628
|
+
if (!e.getCapabilities()[n]) throw new ct(t, n);
|
|
1520
1629
|
}, r = {
|
|
1521
1630
|
async speak(r) {
|
|
1522
1631
|
if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
|
|
1523
|
-
let i =
|
|
1632
|
+
let i = _t(r.queue ?? "append");
|
|
1524
1633
|
i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
|
|
1525
1634
|
let a = e.getIframeHost();
|
|
1526
1635
|
if (!a) throw new X("Speech session is not attached.");
|
|
@@ -1540,16 +1649,16 @@ function St(e) {
|
|
|
1540
1649
|
return;
|
|
1541
1650
|
}
|
|
1542
1651
|
t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
|
|
1543
|
-
t.removeEventListener("abort", s), n(
|
|
1652
|
+
t.removeEventListener("abort", s), n(At(e, "completed"));
|
|
1544
1653
|
}, (a) => {
|
|
1545
|
-
if (t.removeEventListener("abort", s),
|
|
1654
|
+
if (t.removeEventListener("abort", s), jt(a)) {
|
|
1546
1655
|
n({
|
|
1547
1656
|
utteranceId: "utt_interrupted",
|
|
1548
1657
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
1549
1658
|
status: "interrupted",
|
|
1550
1659
|
durationMs: 0,
|
|
1551
1660
|
transcript: r.text,
|
|
1552
|
-
animation:
|
|
1661
|
+
animation: dt("none")
|
|
1553
1662
|
});
|
|
1554
1663
|
return;
|
|
1555
1664
|
}
|
|
@@ -1558,23 +1667,23 @@ function St(e) {
|
|
|
1558
1667
|
});
|
|
1559
1668
|
}
|
|
1560
1669
|
try {
|
|
1561
|
-
return
|
|
1670
|
+
return At(await o, "completed");
|
|
1562
1671
|
} catch (t) {
|
|
1563
|
-
if (
|
|
1672
|
+
if (jt(t)) return {
|
|
1564
1673
|
utteranceId: "utt_interrupted",
|
|
1565
1674
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
1566
1675
|
status: "interrupted",
|
|
1567
1676
|
durationMs: 0,
|
|
1568
1677
|
transcript: r.text,
|
|
1569
|
-
animation:
|
|
1678
|
+
animation: dt("none")
|
|
1570
1679
|
};
|
|
1571
1680
|
throw Z(t);
|
|
1572
1681
|
}
|
|
1573
1682
|
},
|
|
1574
1683
|
async play(i) {
|
|
1575
|
-
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"),
|
|
1684
|
+
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), mt(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
1576
1685
|
let a = i.queue ?? "append";
|
|
1577
|
-
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)),
|
|
1686
|
+
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), at(i.audio)) {
|
|
1578
1687
|
let e = i.audio.sampleRate ?? 24e3;
|
|
1579
1688
|
return r.createUtterance({
|
|
1580
1689
|
format: {
|
|
@@ -1590,7 +1699,7 @@ function St(e) {
|
|
|
1590
1699
|
}
|
|
1591
1700
|
let o = e.getIframeHost();
|
|
1592
1701
|
if (!o) throw new X("Speech session is not attached.");
|
|
1593
|
-
let s = await
|
|
1702
|
+
let s = await Ot(i.audio, i.signal);
|
|
1594
1703
|
return o.speechPlay({
|
|
1595
1704
|
source: s,
|
|
1596
1705
|
characterId: i.characterId,
|
|
@@ -1602,13 +1711,13 @@ function St(e) {
|
|
|
1602
1711
|
},
|
|
1603
1712
|
createUtterance(r) {
|
|
1604
1713
|
e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
|
|
1605
|
-
let i =
|
|
1714
|
+
let i = ht(r);
|
|
1606
1715
|
if (r.track && r.track.kind !== "audio") throw new X("createUtterance track must be an audio MediaStreamTrack.");
|
|
1607
1716
|
let a = r.queue ?? "replace-active";
|
|
1608
1717
|
if (a !== "replace-active" && a !== "replace-all") throw new X("createUtterance queue must be replace-active or replace-all.");
|
|
1609
1718
|
e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
|
|
1610
|
-
let o = new
|
|
1611
|
-
id:
|
|
1719
|
+
let o = new Mt({
|
|
1720
|
+
id: kt(),
|
|
1612
1721
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
1613
1722
|
format: i,
|
|
1614
1723
|
queue: a,
|
|
@@ -1620,7 +1729,7 @@ function St(e) {
|
|
|
1620
1729
|
t === o && (t = null);
|
|
1621
1730
|
}), r.track && (async () => {
|
|
1622
1731
|
try {
|
|
1623
|
-
if (await
|
|
1732
|
+
if (await Dt({
|
|
1624
1733
|
track: r.track,
|
|
1625
1734
|
utterance: o,
|
|
1626
1735
|
sampleRate: i.sampleRate,
|
|
@@ -1648,10 +1757,10 @@ function St(e) {
|
|
|
1648
1757
|
}
|
|
1649
1758
|
//#endregion
|
|
1650
1759
|
//#region src/v2/experience.ts
|
|
1651
|
-
function
|
|
1760
|
+
function Pt(e) {
|
|
1652
1761
|
return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
|
|
1653
1762
|
}
|
|
1654
|
-
var
|
|
1763
|
+
var Ft = class e {
|
|
1655
1764
|
bootstrap;
|
|
1656
1765
|
conversationProcessor;
|
|
1657
1766
|
iframeHost = null;
|
|
@@ -1665,16 +1774,16 @@ var wt = class e {
|
|
|
1665
1774
|
closed = !1;
|
|
1666
1775
|
attached = !1;
|
|
1667
1776
|
closeHandlers = [];
|
|
1668
|
-
eventRegistry =
|
|
1669
|
-
|
|
1670
|
-
|
|
1777
|
+
eventRegistry = $e();
|
|
1778
|
+
readyEnvelope = null;
|
|
1779
|
+
startedEnvelope = null;
|
|
1671
1780
|
conversationCache = [];
|
|
1672
1781
|
speech;
|
|
1673
1782
|
constructor(e) {
|
|
1674
|
-
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 =
|
|
1783
|
+
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 = Nt({
|
|
1675
1784
|
getIframeHost: () => this.iframeHost,
|
|
1676
1785
|
assertSessionStarted: () => this.assertSessionStarted(),
|
|
1677
|
-
getCapabilities: () =>
|
|
1786
|
+
getCapabilities: () => It(this.resolvedSession),
|
|
1678
1787
|
getActiveCharacterId: () => "character_unknown",
|
|
1679
1788
|
onProcessorInterrupt: () => {
|
|
1680
1789
|
this.processorAbortController?.abort(), this.processorAbortController = null;
|
|
@@ -1711,7 +1820,6 @@ var wt = class e {
|
|
|
1711
1820
|
embedBaseUrl: t.embedBaseUrl,
|
|
1712
1821
|
debug: t.debug,
|
|
1713
1822
|
mode: t.mode,
|
|
1714
|
-
responseMode: t.responseMode,
|
|
1715
1823
|
speechInputMode: t.speechInputMode,
|
|
1716
1824
|
speechOnly: t.speechOnly,
|
|
1717
1825
|
ui: t.ui,
|
|
@@ -1731,7 +1839,6 @@ var wt = class e {
|
|
|
1731
1839
|
embedBaseUrl: t.embedBaseUrl,
|
|
1732
1840
|
debug: t.debug,
|
|
1733
1841
|
mode: t.mode,
|
|
1734
|
-
responseMode: t.responseMode,
|
|
1735
1842
|
speechInputMode: t.speechInputMode,
|
|
1736
1843
|
speechOnly: t.speechOnly,
|
|
1737
1844
|
ui: t.ui,
|
|
@@ -1748,8 +1855,8 @@ var wt = class e {
|
|
|
1748
1855
|
return null;
|
|
1749
1856
|
}
|
|
1750
1857
|
on(e, t) {
|
|
1751
|
-
let n =
|
|
1752
|
-
return e === "ready" && this.
|
|
1858
|
+
let n = et(this.eventRegistry, e, t);
|
|
1859
|
+
return e === "ready" && this.readyEnvelope && queueMicrotask(() => t(this.readyEnvelope)), e === "started" && this.startedEnvelope && queueMicrotask(() => t(this.startedEnvelope)), n;
|
|
1753
1860
|
}
|
|
1754
1861
|
async attach(e) {
|
|
1755
1862
|
if (this.closed) throw Error("Session has ended.");
|
|
@@ -1762,13 +1869,13 @@ var wt = class e {
|
|
|
1762
1869
|
if (this.closed) throw Error("Session has ended.");
|
|
1763
1870
|
if (this.attached && this.iframeHost) return this.createPlayerFacade();
|
|
1764
1871
|
this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
|
|
1765
|
-
let t = this.bootstrap.embedBaseUrl ??
|
|
1872
|
+
let t = this.bootstrap.embedBaseUrl ?? qe(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = Je(t, n, r || this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.locationId, r || this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, Pt(e)), a = Xe(i), o = null, s = new Promise((e) => {
|
|
1766
1873
|
o = e;
|
|
1767
1874
|
}), c = null, l = new Promise((e) => {
|
|
1768
1875
|
c = e;
|
|
1769
|
-
}), u =
|
|
1770
|
-
this.
|
|
1771
|
-
}), d = this.bootstrap.onUserTranscript, f =
|
|
1876
|
+
}), u = Ue((e) => {
|
|
1877
|
+
this.readyEnvelope ||= (this.resolvedSession = e, this.emitWrapped("ready", { session: e }));
|
|
1878
|
+
}), d = this.bootstrap.onUserTranscript, f = He({
|
|
1772
1879
|
container: e.container,
|
|
1773
1880
|
src: i,
|
|
1774
1881
|
playerOrigin: a,
|
|
@@ -1784,34 +1891,34 @@ var wt = class e {
|
|
|
1784
1891
|
e.onPlayerStatusChange?.(t), e.onStateUpdate?.(t), t === "loading" && o && (o(), o = null), t === "ready" && c && (c(), c = null), t === "ready" && u.markReady();
|
|
1785
1892
|
},
|
|
1786
1893
|
onUserTranscript: (e) => {
|
|
1787
|
-
|
|
1894
|
+
this.emitWrapped("userTranscript", e), d?.(e), this.queueProcessorTurn(e);
|
|
1788
1895
|
},
|
|
1789
1896
|
onUserSpeechStarted: (e) => {
|
|
1790
|
-
|
|
1897
|
+
this.emitWrapped("userSpeechStarted", e);
|
|
1791
1898
|
},
|
|
1792
1899
|
onUserSpeechEnded: (e) => {
|
|
1793
|
-
|
|
1900
|
+
this.emitWrapped("userSpeechEnded", e);
|
|
1794
1901
|
},
|
|
1795
1902
|
onCharacterSpeechStarted: (e) => {
|
|
1796
|
-
|
|
1903
|
+
this.emitWrapped("characterSpeechStarted", e);
|
|
1797
1904
|
},
|
|
1798
1905
|
onCharacterSpeechEnded: (e) => {
|
|
1799
|
-
|
|
1906
|
+
this.emitWrapped("characterSpeechEnded", e);
|
|
1800
1907
|
},
|
|
1801
1908
|
onListeningState: (e) => {
|
|
1802
|
-
|
|
1909
|
+
this.emitWrapped("listeningState", e);
|
|
1803
1910
|
},
|
|
1804
1911
|
onActivityChange: (e) => {
|
|
1805
|
-
|
|
1912
|
+
this.emitWrapped("activityChange", e);
|
|
1806
1913
|
},
|
|
1807
1914
|
onMessage: (e) => {
|
|
1808
|
-
|
|
1915
|
+
this.emitWrapped("message", e);
|
|
1809
1916
|
},
|
|
1810
1917
|
onStarted: (e) => {
|
|
1811
|
-
this.
|
|
1918
|
+
this.startedEnvelope || (this.startedEnvelope = this.emitWrapped("started", e), this.bootstrap.onStart?.(e));
|
|
1812
1919
|
},
|
|
1813
1920
|
onConversationUpdate: (e) => {
|
|
1814
|
-
this.conversationCache = e,
|
|
1921
|
+
this.conversationCache = e, this.emitWrapped("conversationUpdate", e);
|
|
1815
1922
|
},
|
|
1816
1923
|
onWidgetReady: () => e.onWidgetReady?.(),
|
|
1817
1924
|
onWidgetExpand: () => e.onWidgetExpand?.(),
|
|
@@ -1822,24 +1929,22 @@ var wt = class e {
|
|
|
1822
1929
|
onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t)
|
|
1823
1930
|
});
|
|
1824
1931
|
this.iframeHost = f;
|
|
1825
|
-
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(),
|
|
1932
|
+
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), De(this.bootstrap.sessionEndpoint, {
|
|
1826
1933
|
experienceId: this.bootstrap.experienceId,
|
|
1827
1934
|
locale: this.bootstrap.locale,
|
|
1828
1935
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
1829
1936
|
learningLocale: this.bootstrap.learningLocale,
|
|
1830
1937
|
language: this.bootstrap.language,
|
|
1831
1938
|
mode: p.mode,
|
|
1832
|
-
responseMode: p.responseMode,
|
|
1833
1939
|
speechInputMode: p.speechInputMode,
|
|
1834
1940
|
speechOnly: this.bootstrap.speechOnly,
|
|
1835
1941
|
signal: this.endpointAbortController.signal
|
|
1836
|
-
})) : this.bootstrap.kind === "public" ?
|
|
1942
|
+
})) : this.bootstrap.kind === "public" ? Ee(this.bootstrap.experienceId, {
|
|
1837
1943
|
locale: this.bootstrap.locale,
|
|
1838
1944
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
1839
1945
|
learningLocale: this.bootstrap.learningLocale,
|
|
1840
1946
|
language: this.bootstrap.language,
|
|
1841
1947
|
mode: p.mode,
|
|
1842
|
-
responseMode: p.responseMode,
|
|
1843
1948
|
speechInputMode: p.speechInputMode,
|
|
1844
1949
|
speechOnly: this.bootstrap.speechOnly
|
|
1845
1950
|
}) : Promise.resolve(this.bootstrap.session ? {
|
|
@@ -1856,7 +1961,7 @@ var wt = class e {
|
|
|
1856
1961
|
f.postParentHello();
|
|
1857
1962
|
let g = h?.launch ?? (this.bootstrap.kind === "launch" ? this.bootstrap.launch : null), _ = h?.session ?? (this.bootstrap.kind === "launch" ? this.bootstrap.session : void 0);
|
|
1858
1963
|
if (!g) throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), Error("Session Launch response did not include a launch token.");
|
|
1859
|
-
return this.launchToken = g, _ ? (this.resolvedSession = _, f.postLaunch(g, _, e.startButton), u.setValue(_)) : f.postLaunch(g, void 0, e.startButton), await Promise.race([s, new Promise((e, t) => {
|
|
1964
|
+
return this.launchToken = g, _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" && ye(_), f.postLaunch(g, _, e.startButton), u.setValue(_)) : f.postLaunch(g, void 0, e.startButton), await Promise.race([s, new Promise((e, t) => {
|
|
1860
1965
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player loading UI.")), 12e4);
|
|
1861
1966
|
})]), await Promise.race([l, new Promise((e, t) => {
|
|
1862
1967
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player ready state.")), 12e4);
|
|
@@ -1889,17 +1994,21 @@ var wt = class e {
|
|
|
1889
1994
|
this.close();
|
|
1890
1995
|
}
|
|
1891
1996
|
destroy() {
|
|
1892
|
-
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,
|
|
1997
|
+
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, nt(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.attached = !1);
|
|
1893
1998
|
}
|
|
1894
1999
|
resolveMintInteraction() {
|
|
1895
|
-
|
|
1896
|
-
let e = this.conversationProcessor !== null;
|
|
1897
|
-
return {
|
|
2000
|
+
return this.bootstrap.kind === "launch" ? {} : {
|
|
1898
2001
|
mode: this.bootstrap.mode,
|
|
1899
|
-
responseMode: e ? "custom" : this.bootstrap.responseMode,
|
|
1900
2002
|
speechInputMode: this.bootstrap.speechInputMode
|
|
1901
2003
|
};
|
|
1902
2004
|
}
|
|
2005
|
+
getSessionId() {
|
|
2006
|
+
return this.resolvedSession?.id ?? "";
|
|
2007
|
+
}
|
|
2008
|
+
emitWrapped(e, t) {
|
|
2009
|
+
let n = Qe(e, this.getSessionId(), t);
|
|
2010
|
+
return tt(this.eventRegistry, e, n), n;
|
|
2011
|
+
}
|
|
1903
2012
|
queueProcessorTurn(e) {
|
|
1904
2013
|
if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
|
|
1905
2014
|
let t = this.conversationProcessor;
|
|
@@ -1907,7 +2016,7 @@ var wt = class e {
|
|
|
1907
2016
|
let n = this.processorAbortController.signal;
|
|
1908
2017
|
this.processorChain = this.processorChain.then(async () => {
|
|
1909
2018
|
if (!n.aborted) try {
|
|
1910
|
-
let r = await
|
|
2019
|
+
let r = await ke(t, {
|
|
1911
2020
|
utteranceId: e.utteranceId,
|
|
1912
2021
|
text: e.text,
|
|
1913
2022
|
conversation: this.conversationCache,
|
|
@@ -1927,7 +2036,7 @@ var wt = class e {
|
|
|
1927
2036
|
} catch (t) {
|
|
1928
2037
|
if (n.aborted) return;
|
|
1929
2038
|
let r = t instanceof Error ? t.message : String(t);
|
|
1930
|
-
|
|
2039
|
+
this.emitWrapped("conversationProcessorError", {
|
|
1931
2040
|
utteranceId: e.utteranceId,
|
|
1932
2041
|
message: r
|
|
1933
2042
|
});
|
|
@@ -1938,7 +2047,7 @@ var wt = class e {
|
|
|
1938
2047
|
if (!this.attached || !this.iframeHost) throw Error("Call Experience.attach() before using speech APIs.");
|
|
1939
2048
|
}
|
|
1940
2049
|
assertSessionStarted() {
|
|
1941
|
-
if (this.assertAttached(), !this.
|
|
2050
|
+
if (this.assertAttached(), !this.startedEnvelope) throw Error("Session has not started. Wait for the player start button and the started event before using speak() or listening APIs.");
|
|
1942
2051
|
}
|
|
1943
2052
|
close() {
|
|
1944
2053
|
this.closed || (this.closed = !0, this.endpointAbortController?.abort(), this.endpointAbortController = null, this.attachInFlight = null, this.iframeHost?.destroy(), this.iframeHost = null, this.attached = !1);
|
|
@@ -1957,10 +2066,10 @@ var wt = class e {
|
|
|
1957
2066
|
};
|
|
1958
2067
|
}
|
|
1959
2068
|
};
|
|
1960
|
-
function
|
|
2069
|
+
function It(e) {
|
|
1961
2070
|
return e ? {
|
|
1962
|
-
textSpeech: e.capabilities.
|
|
1963
|
-
externalSpeechAudio: e.capabilities.externalAudio
|
|
2071
|
+
textSpeech: e.capabilities.speech.output,
|
|
2072
|
+
externalSpeechAudio: e.capabilities.speech.externalAudio
|
|
1964
2073
|
} : {
|
|
1965
2074
|
textSpeech: !0,
|
|
1966
2075
|
externalSpeechAudio: !0
|
|
@@ -1968,26 +2077,26 @@ function Tt(e) {
|
|
|
1968
2077
|
}
|
|
1969
2078
|
//#endregion
|
|
1970
2079
|
//#region src/widget/dockGeometry.ts
|
|
1971
|
-
var
|
|
1972
|
-
function
|
|
2080
|
+
var Lt = "(min-width: 768px)", Rt = 24, zt = .5, Bt = 1200, Vt = .85, Ht = 9 / 16;
|
|
2081
|
+
function Ut() {
|
|
1973
2082
|
if (typeof window > "u") return 800;
|
|
1974
2083
|
let e = window.screen?.availHeight;
|
|
1975
2084
|
return typeof e == "number" && e > 0 ? e : window.innerHeight;
|
|
1976
2085
|
}
|
|
1977
|
-
function
|
|
1978
|
-
let i = Math.max(160, Math.min(t - n * 2, t *
|
|
1979
|
-
return s > a && (s = a, o = s /
|
|
2086
|
+
function Wt(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = Rt, r = typeof window < "u" ? Ut() : 800) {
|
|
2087
|
+
let i = Math.max(160, Math.min(t - n * 2, t * Vt)), a = Math.max(120, e - n * 2), o = Math.min(r * zt, Bt, i), s = o * Ht;
|
|
2088
|
+
return s > a && (s = a, o = s / Ht, o > i && (o = i, s = o * Ht)), {
|
|
1980
2089
|
width: Math.round(s),
|
|
1981
2090
|
height: Math.round(o)
|
|
1982
2091
|
};
|
|
1983
2092
|
}
|
|
1984
|
-
function
|
|
2093
|
+
function Gt(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = Rt) {
|
|
1985
2094
|
return {
|
|
1986
2095
|
left: Math.max(r, t - e.width - r),
|
|
1987
2096
|
top: Math.max(r, n - e.height - r)
|
|
1988
2097
|
};
|
|
1989
2098
|
}
|
|
1990
|
-
function
|
|
2099
|
+
function Kt(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = Rt) {
|
|
1991
2100
|
let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
|
|
1992
2101
|
return {
|
|
1993
2102
|
left: Math.min(Math.max(a, e), o),
|
|
@@ -1995,14 +2104,14 @@ function Ft(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typ
|
|
|
1995
2104
|
};
|
|
1996
2105
|
}
|
|
1997
2106
|
function Q(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
|
|
1998
|
-
return e(
|
|
2107
|
+
return e(Lt).matches;
|
|
1999
2108
|
}
|
|
2000
2109
|
//#endregion
|
|
2001
2110
|
//#region src/widget/mountExperienceWidget.ts
|
|
2002
|
-
function
|
|
2111
|
+
function qt(e) {
|
|
2003
2112
|
return e === "bottom-right" || e === "bottom-left" ? e : "static";
|
|
2004
2113
|
}
|
|
2005
|
-
function
|
|
2114
|
+
function Jt(e) {
|
|
2006
2115
|
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
2007
2116
|
let t = typeof e == "string" ? e.trim() : "";
|
|
2008
2117
|
return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
|
|
@@ -2010,10 +2119,10 @@ function Lt(e) {
|
|
|
2010
2119
|
function $(e) {
|
|
2011
2120
|
return e === "expanded" || e === "docked";
|
|
2012
2121
|
}
|
|
2013
|
-
var
|
|
2014
|
-
function
|
|
2015
|
-
|
|
2016
|
-
let r =
|
|
2122
|
+
var Yt = "<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>", Xt = "<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>", Zt = "<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>", Qt = "<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>";
|
|
2123
|
+
function $t(e, t, n) {
|
|
2124
|
+
I(re);
|
|
2125
|
+
let r = s({
|
|
2017
2126
|
galleryThumb: t.galleryThumb,
|
|
2018
2127
|
avatarImage: t.avatarImage,
|
|
2019
2128
|
backgroundImage: t.backgroundImage,
|
|
@@ -2025,23 +2134,23 @@ function Ht(e, t, n) {
|
|
|
2025
2134
|
i.className = `liforma-et${r.backgroundImage ? " liforma-et--scene" : ""} liforma-et--revealed`, i.setAttribute("aria-hidden", "true");
|
|
2026
2135
|
let a = document.createElement("span");
|
|
2027
2136
|
a.className = "liforma-et__placeholder", a.setAttribute("aria-hidden", "true"), i.append(a);
|
|
2028
|
-
let
|
|
2137
|
+
let o = (e) => {
|
|
2029
2138
|
e.classList.add("liforma-et__media--ready");
|
|
2030
2139
|
};
|
|
2031
2140
|
if (r.backgroundImage) {
|
|
2032
2141
|
let e = document.createElement("img");
|
|
2033
|
-
e.className = "liforma-et__background liforma-et__media", e.alt = "", e.decoding = "async", e.src = r.backgroundImage, e.addEventListener("load", () =>
|
|
2142
|
+
e.className = "liforma-et__background liforma-et__media", e.alt = "", e.decoding = "async", e.src = r.backgroundImage, e.addEventListener("load", () => o(e), { once: !0 }), i.append(e);
|
|
2034
2143
|
}
|
|
2035
2144
|
let c = document.createElement("img");
|
|
2036
|
-
if (c.className = "liforma-et__avatar liforma-et__media", c.alt = "", c.decoding = "async", c.src = r.avatarImage, c.addEventListener("load", () =>
|
|
2145
|
+
if (c.className = "liforma-et__avatar liforma-et__media", c.alt = "", c.decoding = "async", c.src = r.avatarImage, c.addEventListener("load", () => o(c), { once: !0 }), c.addEventListener("error", () => {
|
|
2037
2146
|
r.fallbackImage && (c.src = r.fallbackImage);
|
|
2038
2147
|
}, { once: !0 }), i.append(c), r.foregroundImage) {
|
|
2039
2148
|
let e = document.createElement("img");
|
|
2040
|
-
e.className = "liforma-et__foreground liforma-et__media", e.alt = "", e.decoding = "async", e.src = r.foregroundImage, e.addEventListener("load", () =>
|
|
2149
|
+
e.className = "liforma-et__foreground liforma-et__media", e.alt = "", e.decoding = "async", e.src = r.foregroundImage, e.addEventListener("load", () => o(e), { once: !0 }), i.append(e);
|
|
2041
2150
|
}
|
|
2042
|
-
return e.replaceChildren(i), n?.parallax === !1 ? () => {} :
|
|
2151
|
+
return e.replaceChildren(i), n?.parallax === !1 ? () => {} : ne(i);
|
|
2043
2152
|
}
|
|
2044
|
-
function
|
|
2153
|
+
function en(e) {
|
|
2045
2154
|
return e.startButton ? {
|
|
2046
2155
|
...e.startButton,
|
|
2047
2156
|
label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
|
|
@@ -2053,7 +2162,7 @@ function Ut(e) {
|
|
|
2053
2162
|
variant: "primary"
|
|
2054
2163
|
};
|
|
2055
2164
|
}
|
|
2056
|
-
function
|
|
2165
|
+
function tn(e) {
|
|
2057
2166
|
let t = !1, n = () => {
|
|
2058
2167
|
t || e();
|
|
2059
2168
|
}, r = () => {
|
|
@@ -2073,12 +2182,12 @@ function Wt(e) {
|
|
|
2073
2182
|
t = !0, window.removeEventListener("load", r), i?.();
|
|
2074
2183
|
};
|
|
2075
2184
|
}
|
|
2076
|
-
function
|
|
2077
|
-
|
|
2185
|
+
function nn(e, t) {
|
|
2186
|
+
oe(ie);
|
|
2078
2187
|
let n = t.experienceId?.trim();
|
|
2079
2188
|
if (!n) throw Error("ExperienceWidget requires experienceId.");
|
|
2080
|
-
let r = t.prefetch ?? "onExpand", i =
|
|
2081
|
-
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",
|
|
2189
|
+
let r = t.prefetch ?? "onExpand", i = qt(t.position), a = document.createElement("div");
|
|
2190
|
+
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", Jt(t.offset));
|
|
2082
2191
|
let o = document.createElement("button");
|
|
2083
2192
|
o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
|
|
2084
2193
|
let s = document.createElement("div");
|
|
@@ -2098,136 +2207,136 @@ function Gt(e, t) {
|
|
|
2098
2207
|
let m = document.createElement("span");
|
|
2099
2208
|
m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
|
|
2100
2209
|
let h = document.createElement("button");
|
|
2101
|
-
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML =
|
|
2210
|
+
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = Zt, h.setAttribute("aria-label", "Reduce");
|
|
2102
2211
|
let g = document.createElement("button");
|
|
2103
|
-
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML =
|
|
2212
|
+
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = Yt, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
|
|
2104
2213
|
let _ = document.createElement("button");
|
|
2105
|
-
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML =
|
|
2214
|
+
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = Xt, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
|
|
2106
2215
|
let ee = document.createElement("div");
|
|
2107
2216
|
ee.className = "liforma-ew__stage";
|
|
2108
2217
|
let v = document.createElement("div");
|
|
2109
2218
|
v.className = "liforma-ew__status", v.hidden = !0, f.append(ee, v), u.append(d, f), a.append(o, l, u, p), e.replaceChildren(a);
|
|
2110
|
-
let y = null, b = !1, x = !1, te = !1, S = !1, C = !1, w = !1, T = !1, E = 0, D = "", O = null,
|
|
2219
|
+
let y = null, b = !1, x = !1, te = !1, S = !1, C = !1, w = !1, T = !1, E = 0, D = "", O = null, k = null, A = null, j = null, M = null, N = null, P = null, ne = 0, re = 0, F = null, I = !1, ae = new AbortController(), se = t.parallax !== !1, L = () => {
|
|
2111
2220
|
let e = a.dataset.state;
|
|
2112
2221
|
return e === "expanded" || e === "docked" || e === "collapsed" ? e : "collapsed";
|
|
2113
2222
|
}, R = () => {
|
|
2114
|
-
|
|
2223
|
+
A !== null && (clearTimeout(A), A = null);
|
|
2115
2224
|
}, ce = () => {
|
|
2116
|
-
|
|
2117
|
-
},
|
|
2225
|
+
j !== null && (clearTimeout(j), j = null), a.classList.remove("liforma-ew--layout-settling");
|
|
2226
|
+
}, le = () => {
|
|
2118
2227
|
for (let e of [
|
|
2119
2228
|
f,
|
|
2120
2229
|
l,
|
|
2121
2230
|
p
|
|
2122
2231
|
]) e.style.removeProperty("left"), e.style.removeProperty("top"), e.style.removeProperty("width"), e.style.removeProperty("height"), e.style.removeProperty("right"), e.style.removeProperty("bottom");
|
|
2123
2232
|
p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging");
|
|
2124
|
-
},
|
|
2233
|
+
}, z = (e, t, n, r) => {
|
|
2125
2234
|
let i = (i) => {
|
|
2126
2235
|
i.style.left = `${e}px`, i.style.top = `${t}px`, i.style.width = `${n}px`, i.style.height = `${r}px`, i.style.right = "auto", i.style.bottom = "auto";
|
|
2127
2236
|
};
|
|
2128
2237
|
i(f), i(l);
|
|
2129
2238
|
let a = p.offsetWidth || 120;
|
|
2130
2239
|
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";
|
|
2131
|
-
},
|
|
2240
|
+
}, de = (e, t) => {
|
|
2132
2241
|
if (L() !== "docked") return;
|
|
2133
|
-
let n =
|
|
2134
|
-
|
|
2135
|
-
},
|
|
2242
|
+
let n = Wt(), r = Kt(e - ne, t - re, n);
|
|
2243
|
+
M = r.left, N = r.top, z(r.left, r.top, n.width, n.height);
|
|
2244
|
+
}, fe = (e, t) => {
|
|
2136
2245
|
if (L() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
|
|
2137
|
-
let n =
|
|
2138
|
-
|
|
2139
|
-
},
|
|
2140
|
-
F === "toolbar" && (
|
|
2246
|
+
let n = Wt(), r = M ?? f.getBoundingClientRect().left, i = N ?? f.getBoundingClientRect().top, a = Kt(r + e, i + t, n);
|
|
2247
|
+
M = a.left, N = a.top, z(a.left, a.top, n.width, n.height);
|
|
2248
|
+
}, pe = (e) => {
|
|
2249
|
+
F === "toolbar" && (P === null || e.pointerId !== P || (e.preventDefault(), de(e.clientX, e.clientY)));
|
|
2141
2250
|
}, B = (e) => {
|
|
2142
|
-
if (
|
|
2251
|
+
if (P === null || e && e.pointerId !== P) return;
|
|
2143
2252
|
let t = F;
|
|
2144
|
-
|
|
2253
|
+
P = null, F = null, p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging"), t === "toolbar" && I && (I = !1, window.removeEventListener("pointermove", pe), window.removeEventListener("pointerup", B), window.removeEventListener("pointercancel", B));
|
|
2145
2254
|
}, me = (e, t, n) => {
|
|
2146
|
-
if (x || L() !== "docked" || !Q() ||
|
|
2147
|
-
|
|
2255
|
+
if (x || L() !== "docked" || !Q() || P !== null) return;
|
|
2256
|
+
P = n, F = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2148
2257
|
let r = f.getBoundingClientRect();
|
|
2149
|
-
|
|
2150
|
-
},
|
|
2151
|
-
if (x || L() !== "docked" || !Q() ||
|
|
2152
|
-
|
|
2258
|
+
ne = e - r.left, re = t - r.top, I || (I = !0, window.addEventListener("pointermove", pe), window.addEventListener("pointerup", B), window.addEventListener("pointercancel", B));
|
|
2259
|
+
}, V = (e) => {
|
|
2260
|
+
if (x || L() !== "docked" || !Q() || P !== null) return;
|
|
2261
|
+
P = e.pointerId, F = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2153
2262
|
let t = f.getBoundingClientRect();
|
|
2154
|
-
|
|
2155
|
-
},
|
|
2156
|
-
F === "player" && (
|
|
2157
|
-
},
|
|
2158
|
-
F === "player" && (
|
|
2159
|
-
},
|
|
2263
|
+
M = t.left, N = t.top;
|
|
2264
|
+
}, H = (e) => {
|
|
2265
|
+
F === "player" && (P === null || e.pointerId !== P || fe(e.dx, e.dy));
|
|
2266
|
+
}, he = (e) => {
|
|
2267
|
+
F === "player" && (P === null || e.pointerId !== P || B());
|
|
2268
|
+
}, U = () => {
|
|
2160
2269
|
let e = Q(), t = L();
|
|
2161
2270
|
if (!e || t !== "expanded" && t !== "docked") {
|
|
2162
2271
|
h.hidden = !0;
|
|
2163
2272
|
return;
|
|
2164
2273
|
}
|
|
2165
|
-
h.hidden = !1, t === "docked" ? (h.innerHTML =
|
|
2166
|
-
},
|
|
2167
|
-
let t =
|
|
2168
|
-
n =
|
|
2169
|
-
},
|
|
2274
|
+
h.hidden = !1, t === "docked" ? (h.innerHTML = Qt, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = Zt, h.setAttribute("aria-label", "Reduce"));
|
|
2275
|
+
}, ge = (e) => {
|
|
2276
|
+
let t = Wt(), n = e && M !== null && N !== null ? Kt(M, N, t) : Gt(t);
|
|
2277
|
+
n = Kt(n.left, n.top, t), M = n.left, N = n.top, z(n.left, n.top, t.width, t.height), U();
|
|
2278
|
+
}, _e = () => {
|
|
2170
2279
|
a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
|
|
2171
2280
|
requestAnimationFrame(() => {
|
|
2172
2281
|
x || !$(a.dataset.state) || a.classList.add("liforma-ew--session-revealed");
|
|
2173
2282
|
});
|
|
2174
2283
|
});
|
|
2175
|
-
},
|
|
2284
|
+
}, ve = (e) => {
|
|
2176
2285
|
if (ce(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !T) {
|
|
2177
2286
|
a.classList.remove("liforma-ew--layout-settling");
|
|
2178
2287
|
return;
|
|
2179
2288
|
}
|
|
2180
|
-
|
|
2181
|
-
if (
|
|
2289
|
+
j = setTimeout(() => {
|
|
2290
|
+
if (j = null, x || !$(a.dataset.state)) {
|
|
2182
2291
|
a.classList.remove("liforma-ew--layout-settling");
|
|
2183
2292
|
return;
|
|
2184
2293
|
}
|
|
2185
|
-
a.classList.remove("liforma-ew--layout-settling"),
|
|
2294
|
+
a.classList.remove("liforma-ew--layout-settling"), _e();
|
|
2186
2295
|
}, 220);
|
|
2187
|
-
},
|
|
2188
|
-
R(),
|
|
2189
|
-
|
|
2296
|
+
}, ye = () => (a.classList.add("liforma-ew--session-concealing"), a.classList.remove("liforma-ew--session-revealed"), new Promise((e) => {
|
|
2297
|
+
R(), A = setTimeout(() => {
|
|
2298
|
+
A = null, a.classList.remove("liforma-ew--session-concealing"), e();
|
|
2190
2299
|
}, 280);
|
|
2191
|
-
})),
|
|
2300
|
+
})), be = {
|
|
2192
2301
|
galleryThumb: t.galleryThumb,
|
|
2193
2302
|
avatarImage: t.avatarImage,
|
|
2194
2303
|
backgroundImage: t.backgroundImage,
|
|
2195
2304
|
foregroundImage: t.foregroundImage,
|
|
2196
2305
|
fallbackImage: t.fallbackImage
|
|
2197
|
-
},
|
|
2306
|
+
}, W = (e) => {
|
|
2198
2307
|
if (!e) {
|
|
2199
2308
|
v.hidden = !0, v.textContent = "";
|
|
2200
2309
|
return;
|
|
2201
2310
|
}
|
|
2202
2311
|
v.hidden = !1, v.textContent = e;
|
|
2203
|
-
},
|
|
2312
|
+
}, xe = (e) => {
|
|
2204
2313
|
if (!e) {
|
|
2205
2314
|
c.hidden = !0, c.textContent = "";
|
|
2206
2315
|
return;
|
|
2207
2316
|
}
|
|
2208
2317
|
c.hidden = !1, c.textContent = e, s.contains(c) || s.append(c);
|
|
2318
|
+
}, Se = () => {
|
|
2319
|
+
te = !0, o.disabled = !1, xe(null), r === "onExpand" && t.onPrefetchReady?.();
|
|
2209
2320
|
}, Ce = () => {
|
|
2210
|
-
te = !0, o.disabled = !1, Se(null), r === "onExpand" && t.onPrefetchReady?.();
|
|
2211
|
-
}, W = () => {
|
|
2212
2321
|
S = !0, a.dataset.warm = "true", l.hidden = !1, T || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
|
|
2213
2322
|
}, we = (e) => {
|
|
2214
2323
|
O?.(), O = null;
|
|
2215
|
-
let t =
|
|
2324
|
+
let t = $t(s, e, { parallax: se });
|
|
2216
2325
|
return t ? (O = t, !0) : !1;
|
|
2217
2326
|
}, Te = () => {
|
|
2218
|
-
if (we(
|
|
2219
|
-
|
|
2327
|
+
if (we(be)) {
|
|
2328
|
+
Se();
|
|
2220
2329
|
return;
|
|
2221
2330
|
}
|
|
2222
|
-
|
|
2331
|
+
xe("Loading…"), ue(n, { signal: ae.signal }).then((e) => {
|
|
2223
2332
|
if (!x) {
|
|
2224
2333
|
if (!we({ galleryThumb: e.galleryThumb })) throw Error("Experience preview is missing gallery thumb images.");
|
|
2225
|
-
|
|
2334
|
+
Se();
|
|
2226
2335
|
}
|
|
2227
2336
|
}).catch((e) => {
|
|
2228
|
-
if (x ||
|
|
2337
|
+
if (x || ae.signal.aborted) return;
|
|
2229
2338
|
let n = e instanceof Error ? e : Error(String(e));
|
|
2230
|
-
|
|
2339
|
+
xe("Preview unavailable"), o.disabled = !0, t.onError?.(n), console.error("[ExperienceWidget]", n);
|
|
2231
2340
|
});
|
|
2232
2341
|
}, Ee = () => ({
|
|
2233
2342
|
experienceId: n,
|
|
@@ -2241,53 +2350,53 @@ function Gt(e, t) {
|
|
|
2241
2350
|
...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
|
|
2242
2351
|
}), De = () => ({
|
|
2243
2352
|
...t.fit ? { fit: t.fit } : {},
|
|
2244
|
-
startButton:
|
|
2353
|
+
startButton: en(t)
|
|
2245
2354
|
}), G = (e = !0) => {
|
|
2246
|
-
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"),
|
|
2355
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), le(), a.dataset.state = "expanded", W(null), typeof document < "u" && (D = document.body.style.overflow, document.body.style.overflow = "hidden"), U(), e && t.onExpanded?.();
|
|
2247
2356
|
}, Oe = () => {
|
|
2248
|
-
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked",
|
|
2357
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked", W(null), typeof document < "u" && (document.body.style.overflow = D), ge(!0), U(), y?.setWidgetChrome("docked");
|
|
2249
2358
|
}, ke = (e) => {
|
|
2250
2359
|
e.on("started", () => {
|
|
2251
|
-
x || (T = !0, a.dataset.live = "true",
|
|
2360
|
+
x || (T = !0, a.dataset.live = "true", W(null), t.onStarted?.(), $(a.dataset.state) && _e());
|
|
2252
2361
|
});
|
|
2253
2362
|
}, Ae = () => {
|
|
2254
|
-
ce(), u.hidden = !0, p.hidden = !0,
|
|
2255
|
-
},
|
|
2363
|
+
ce(), u.hidden = !0, p.hidden = !0, le(), 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"), te && (o.disabled = !1), W(null), typeof document < "u" && (document.body.style.overflow = D), U();
|
|
2364
|
+
}, K = () => {
|
|
2256
2365
|
R(), ce(), E += 1, b = !1, S = !1, C = !1, w = !1, T = !1;
|
|
2257
2366
|
let e = y;
|
|
2258
2367
|
y = null, e?.destroy(), ee.replaceChildren(), l.replaceChildren(), l.hidden = !0, delete a.dataset.warm, delete a.dataset.live, a.classList.remove("liforma-ew--session-revealed");
|
|
2259
|
-
},
|
|
2368
|
+
}, q = () => {
|
|
2260
2369
|
if (!x && $(a.dataset.state)) {
|
|
2261
2370
|
if (B(), b = !1, y && w) {
|
|
2262
2371
|
let e = y;
|
|
2263
2372
|
(async () => {
|
|
2264
|
-
T && (await
|
|
2373
|
+
T && (await ye(), x || y !== e) || (S && e.setWidgetChrome("collapsed"), Ae(), T ? (a.dataset.live = "true", o.tabIndex = 0, o.removeAttribute("aria-hidden"), o.disabled = !1) : S && Ce(), t.onCollapsed?.(), t.onClose?.());
|
|
2265
2374
|
})();
|
|
2266
2375
|
return;
|
|
2267
2376
|
}
|
|
2268
|
-
|
|
2377
|
+
K(), Ae(), t.onCollapsed?.(), t.onClose?.();
|
|
2269
2378
|
}
|
|
2270
|
-
},
|
|
2271
|
-
x || Q() && L() === "expanded" &&
|
|
2379
|
+
}, je = () => {
|
|
2380
|
+
x || Q() && L() === "expanded" && ve(() => {
|
|
2272
2381
|
Oe();
|
|
2273
2382
|
});
|
|
2274
|
-
},
|
|
2275
|
-
x || L() === "docked" && (B(),
|
|
2276
|
-
|
|
2383
|
+
}, Me = () => {
|
|
2384
|
+
x || L() === "docked" && (B(), ve(() => {
|
|
2385
|
+
le(), G(!1), y?.setWidgetChrome("expanded");
|
|
2277
2386
|
}));
|
|
2278
2387
|
}, Ne = () => {
|
|
2279
|
-
!y || !T || (R(), a.classList.remove("liforma-ew--session-revealed"), G(), y.setWidgetChrome("expanded"), b = !1,
|
|
2388
|
+
!y || !T || (R(), a.classList.remove("liforma-ew--session-revealed"), G(), y.setWidgetChrome("expanded"), b = !1, _e());
|
|
2280
2389
|
}, Pe = () => {
|
|
2281
|
-
!y || !w || T || (R(), a.classList.remove("liforma-ew--session-revealed"), G(), b = !1, S
|
|
2390
|
+
!y || !w || T || (R(), a.classList.remove("liforma-ew--session-revealed"), G(), b = !1, S || y.setWidgetChrome("expanded"));
|
|
2282
2391
|
}, Fe = (e) => {
|
|
2283
|
-
x || e !== E && !T || (R(), a.classList.remove("liforma-ew--session-revealed"), G(), b = !1,
|
|
2392
|
+
x || e !== E && !T || (R(), a.classList.remove("liforma-ew--session-revealed"), G(), b = !1, T && _e());
|
|
2284
2393
|
}, Ie = () => {
|
|
2285
2394
|
if (x || C || S || y || $(a.dataset.state)) return;
|
|
2286
2395
|
C = !0;
|
|
2287
2396
|
let e = E;
|
|
2288
2397
|
l.hidden = !1, (async () => {
|
|
2289
2398
|
try {
|
|
2290
|
-
let t = await
|
|
2399
|
+
let t = await Ft.startSession(Ee());
|
|
2291
2400
|
if (x || e !== E) {
|
|
2292
2401
|
t.destroy();
|
|
2293
2402
|
return;
|
|
@@ -2297,7 +2406,7 @@ function Gt(e, t) {
|
|
|
2297
2406
|
container: l,
|
|
2298
2407
|
...De(),
|
|
2299
2408
|
onWidgetReady: () => {
|
|
2300
|
-
x || e !== E || (C = !1, w = !0,
|
|
2409
|
+
x || e !== E || (C = !1, w = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") : Ce());
|
|
2301
2410
|
},
|
|
2302
2411
|
onWidgetExpand: () => {
|
|
2303
2412
|
Fe(e);
|
|
@@ -2306,24 +2415,24 @@ function Gt(e, t) {
|
|
|
2306
2415
|
x || Be(e);
|
|
2307
2416
|
},
|
|
2308
2417
|
onWidgetDragStart: (e) => {
|
|
2309
|
-
x ||
|
|
2418
|
+
x || V(e);
|
|
2310
2419
|
},
|
|
2311
2420
|
onWidgetDragMove: (e) => {
|
|
2312
|
-
x ||
|
|
2421
|
+
x || H(e);
|
|
2313
2422
|
},
|
|
2314
2423
|
onWidgetDragEnd: (e) => {
|
|
2315
|
-
x ||
|
|
2424
|
+
x || he(e);
|
|
2316
2425
|
},
|
|
2317
2426
|
onPlayerStatusChange: (e) => {
|
|
2318
|
-
x || e === "error" && $(a.dataset.state) &&
|
|
2427
|
+
x || e === "error" && $(a.dataset.state) && W("Could not load the experience.");
|
|
2319
2428
|
}
|
|
2320
2429
|
});
|
|
2321
2430
|
if (x || e !== E) {
|
|
2322
2431
|
t.destroy(), y === t && (y = null);
|
|
2323
2432
|
return;
|
|
2324
2433
|
}
|
|
2325
|
-
|
|
2326
|
-
x ||
|
|
2434
|
+
n.on("close", () => {
|
|
2435
|
+
x || q();
|
|
2327
2436
|
});
|
|
2328
2437
|
} catch (n) {
|
|
2329
2438
|
if (x || e !== E) return;
|
|
@@ -2346,7 +2455,7 @@ function Gt(e, t) {
|
|
|
2346
2455
|
b = !0, S = !1, C = !1, w = !1, T = !1, delete a.dataset.warm, delete a.dataset.live, l.hidden = !0, l.replaceChildren(), y &&= (y.destroy(), null), (async () => {
|
|
2347
2456
|
try {
|
|
2348
2457
|
G();
|
|
2349
|
-
let t = await
|
|
2458
|
+
let t = await Ft.startSession(Ee());
|
|
2350
2459
|
if (x || e !== E) {
|
|
2351
2460
|
t.destroy();
|
|
2352
2461
|
return;
|
|
@@ -2359,29 +2468,29 @@ function Gt(e, t) {
|
|
|
2359
2468
|
x || Be(e);
|
|
2360
2469
|
},
|
|
2361
2470
|
onWidgetDragStart: (e) => {
|
|
2362
|
-
x ||
|
|
2471
|
+
x || V(e);
|
|
2363
2472
|
},
|
|
2364
2473
|
onWidgetDragMove: (e) => {
|
|
2365
|
-
x ||
|
|
2474
|
+
x || H(e);
|
|
2366
2475
|
},
|
|
2367
2476
|
onWidgetDragEnd: (e) => {
|
|
2368
|
-
x ||
|
|
2477
|
+
x || he(e);
|
|
2369
2478
|
},
|
|
2370
2479
|
onPlayerStatusChange: (e) => {
|
|
2371
|
-
x || (e === "error" ?
|
|
2480
|
+
x || (e === "error" ? W("Could not load the experience.") : $(a.dataset.state) && W(null));
|
|
2372
2481
|
}
|
|
2373
2482
|
});
|
|
2374
2483
|
if (x || e !== E) {
|
|
2375
2484
|
t.destroy(), y === t && (y = null);
|
|
2376
2485
|
return;
|
|
2377
2486
|
}
|
|
2378
|
-
w = !0, n.on("close", () => {
|
|
2379
|
-
x ||
|
|
2487
|
+
w = !0, t.setWidgetChrome("expanded"), n.on("close", () => {
|
|
2488
|
+
x || q();
|
|
2380
2489
|
});
|
|
2381
2490
|
} catch (n) {
|
|
2382
2491
|
if (x || e !== E) return;
|
|
2383
2492
|
let r = n instanceof Error ? n : Error(String(n));
|
|
2384
|
-
|
|
2493
|
+
W(r.message), t.onError?.(r), console.error("[ExperienceWidget]", r);
|
|
2385
2494
|
} finally {
|
|
2386
2495
|
e === E && (b = !1);
|
|
2387
2496
|
}
|
|
@@ -2396,57 +2505,61 @@ function Gt(e, t) {
|
|
|
2396
2505
|
Pe();
|
|
2397
2506
|
return;
|
|
2398
2507
|
}
|
|
2508
|
+
if (C || y) {
|
|
2509
|
+
G();
|
|
2510
|
+
return;
|
|
2511
|
+
}
|
|
2399
2512
|
Le();
|
|
2400
2513
|
}
|
|
2401
2514
|
}, ze = (e) => {
|
|
2402
2515
|
if (e.stopPropagation(), L() === "expanded") {
|
|
2403
|
-
|
|
2516
|
+
je();
|
|
2404
2517
|
return;
|
|
2405
2518
|
}
|
|
2406
|
-
L() === "docked" &&
|
|
2519
|
+
L() === "docked" && Me();
|
|
2407
2520
|
}, Be = (e) => {
|
|
2408
2521
|
g.setAttribute("aria-pressed", e ? "true" : "false");
|
|
2409
|
-
},
|
|
2522
|
+
}, J = (e) => {
|
|
2410
2523
|
e.stopPropagation(), $(a.dataset.state) && y?.toggleAudioSettings();
|
|
2411
|
-
},
|
|
2524
|
+
}, Ve = (e) => {
|
|
2412
2525
|
L() === "docked" && Q() && (e.target?.closest("button") || (e.preventDefault(), me(e.clientX, e.clientY, e.pointerId)));
|
|
2413
|
-
},
|
|
2414
|
-
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(),
|
|
2415
|
-
},
|
|
2526
|
+
}, He = (e) => {
|
|
2527
|
+
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), q());
|
|
2528
|
+
}, Ue = () => {
|
|
2416
2529
|
if (!x) {
|
|
2417
2530
|
if (L() === "docked") {
|
|
2418
2531
|
if (!Q()) {
|
|
2419
|
-
|
|
2532
|
+
Me();
|
|
2420
2533
|
return;
|
|
2421
2534
|
}
|
|
2422
|
-
T ?
|
|
2423
|
-
|
|
2424
|
-
}) :
|
|
2535
|
+
T ? ve(() => {
|
|
2536
|
+
ge(!0);
|
|
2537
|
+
}) : ge(!0);
|
|
2425
2538
|
return;
|
|
2426
2539
|
}
|
|
2427
|
-
|
|
2540
|
+
U();
|
|
2428
2541
|
}
|
|
2429
|
-
},
|
|
2542
|
+
}, We = typeof window < "u" ? window.matchMedia(Lt) : null, Ge = () => {
|
|
2430
2543
|
if (!x) {
|
|
2431
2544
|
if (L() === "docked" && !Q()) {
|
|
2432
|
-
|
|
2545
|
+
Me();
|
|
2433
2546
|
return;
|
|
2434
2547
|
}
|
|
2435
|
-
|
|
2548
|
+
U();
|
|
2436
2549
|
}
|
|
2437
2550
|
};
|
|
2438
|
-
return o.addEventListener("click", Re), d.addEventListener("click",
|
|
2439
|
-
e.stopPropagation(),
|
|
2440
|
-
}), h.addEventListener("click", ze), g.addEventListener("click",
|
|
2551
|
+
return o.addEventListener("click", Re), d.addEventListener("click", q), _.addEventListener("click", (e) => {
|
|
2552
|
+
e.stopPropagation(), q();
|
|
2553
|
+
}), h.addEventListener("click", ze), g.addEventListener("click", J), p.addEventListener("pointerdown", Ve), window.addEventListener("keydown", He), window.addEventListener("resize", Ue), We?.addEventListener("change", Ge), Te(), U(), r === "eager" ? queueMicrotask(() => {
|
|
2441
2554
|
x || Ie();
|
|
2442
|
-
}) : r === "idle" && (
|
|
2555
|
+
}) : r === "idle" && (k = tn(() => {
|
|
2443
2556
|
x || Ie();
|
|
2444
2557
|
})), {
|
|
2445
2558
|
root: a,
|
|
2446
2559
|
expand: Re,
|
|
2447
|
-
collapse:
|
|
2448
|
-
dock:
|
|
2449
|
-
maximize:
|
|
2560
|
+
collapse: q,
|
|
2561
|
+
dock: je,
|
|
2562
|
+
maximize: Me,
|
|
2450
2563
|
prefetch() {
|
|
2451
2564
|
if (r === "onExpand") {
|
|
2452
2565
|
Ie();
|
|
@@ -2455,11 +2568,11 @@ function Gt(e, t) {
|
|
|
2455
2568
|
Ie();
|
|
2456
2569
|
},
|
|
2457
2570
|
destroy() {
|
|
2458
|
-
x || (x = !0, B(),
|
|
2571
|
+
x || (x = !0, B(), k?.(), k = null, ae.abort(), O?.(), O = null, window.removeEventListener("keydown", He), window.removeEventListener("resize", Ue), We?.removeEventListener("change", Ge), K(), Ae(), e.replaceChildren());
|
|
2459
2572
|
}
|
|
2460
2573
|
};
|
|
2461
2574
|
}
|
|
2462
2575
|
//#endregion
|
|
2463
|
-
export { re as EXPERIENCE_THUMBNAIL_CSS, ie as EXPERIENCE_WIDGET_CSS,
|
|
2576
|
+
export { re as EXPERIENCE_THUMBNAIL_CSS, ie as EXPERIENCE_WIDGET_CSS, Ft as Experience, z as LiformaError, Y as SPEECH_LIMITS, ut as SpeechBufferTimeoutError, X as SpeechRuntimeError, lt as SpeechUtteranceClosedError, ct as UnsupportedSpeechOperationError, w as attachImageReady, C as attachLazyThumb, P as attachScrollLinkedParallax, p as buildHostedLaunchUrl, I as ensureExperienceThumbnailStyles, oe as ensureExperienceWidgetStyles, ue as fetchExperiencePreview, x as getDefaultLazyRootMargin, E as horizontalParallaxFromViewportY, fe as liformaErrorFromResponse, nn as mountExperienceWidget, n as navigateOnExperienceClose, m as resolveThumbnailHref, d as resolveThumbnailInteraction, s as resolveThumbnailLayers, o as toGalleryThumbUrl, ye as warnLocaleVoiceFallbacks };
|
|
2464
2577
|
|
|
2465
2578
|
//# sourceMappingURL=index.js.map
|