@liforma/client 0.4.2 → 0.4.4
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 +18 -0
- package/dist/next/index.js +689 -573
- package/dist/next/index.js.map +1 -1
- package/dist/next/react/ExperienceThumbnail.d.ts +1 -1
- package/dist/next/react/ExperienceThumbnail.d.ts.map +1 -1
- package/dist/next/react/ExperienceWidget.d.ts +4 -0
- package/dist/next/react/ExperienceWidget.d.ts.map +1 -1
- package/dist/next/thumbnail/index.d.ts +1 -0
- package/dist/next/thumbnail/index.d.ts.map +1 -1
- package/dist/next/thumbnail/styles.d.ts.map +1 -1
- package/dist/next/thumbnail/types.d.ts +3 -2
- package/dist/next/thumbnail/types.d.ts.map +1 -1
- package/dist/next/v2/embed/iframeHost.d.ts +27 -1
- package/dist/next/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/next/v2/embed/protocol.d.ts +61 -1
- package/dist/next/v2/embed/protocol.d.ts.map +1 -1
- package/dist/next/v2/experience.d.ts +24 -2
- package/dist/next/v2/experience.d.ts.map +1 -1
- package/dist/next/v2/experienceEvents.d.ts +30 -0
- package/dist/next/v2/experienceEvents.d.ts.map +1 -1
- package/dist/next/v2/shims/embedBaseUrl.d.ts +3 -2
- package/dist/next/v2/shims/embedBaseUrl.d.ts.map +1 -1
- package/dist/next/v2/types/sessionInteraction.d.ts +3 -1
- package/dist/next/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/next/v2/types/sessionManifest.d.ts +12 -0
- package/dist/next/v2/types/sessionManifest.d.ts.map +1 -1
- package/dist/next/widget/mountExperienceWidget.d.ts.map +1 -1
- package/dist/next/widget/types.d.ts +7 -0
- package/dist/next/widget/types.d.ts.map +1 -1
- package/dist/npm/index.js +632 -522
- package/dist/npm/index.js.map +1 -1
- package/dist/npm/thumbnail/index.d.ts +1 -0
- package/dist/npm/thumbnail/index.d.ts.map +1 -1
- package/dist/npm/thumbnail/styles.d.ts.map +1 -1
- package/dist/npm/thumbnail/types.d.ts +3 -2
- package/dist/npm/thumbnail/types.d.ts.map +1 -1
- package/dist/npm/v2/embed/iframeHost.d.ts +27 -1
- package/dist/npm/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/npm/v2/embed/protocol.d.ts +61 -1
- package/dist/npm/v2/embed/protocol.d.ts.map +1 -1
- package/dist/npm/v2/experience.d.ts +24 -2
- package/dist/npm/v2/experience.d.ts.map +1 -1
- package/dist/npm/v2/experienceEvents.d.ts +30 -0
- package/dist/npm/v2/experienceEvents.d.ts.map +1 -1
- package/dist/npm/v2/index.d.ts +1 -1
- package/dist/npm/v2/index.d.ts.map +1 -1
- package/dist/npm/v2/liforma-experience-thumbnail.d.ts.map +1 -1
- package/dist/npm/v2/liforma-experience.d.ts.map +1 -1
- package/dist/npm/v2/npm.d.ts +2 -1
- package/dist/npm/v2/npm.d.ts.map +1 -1
- package/dist/npm/v2/shims/embedBaseUrl.d.ts +3 -2
- package/dist/npm/v2/shims/embedBaseUrl.d.ts.map +1 -1
- package/dist/npm/v2/speechOnlyManifest.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionInteraction.d.ts +3 -1
- package/dist/npm/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionManifest.d.ts +12 -0
- package/dist/npm/v2/types/sessionManifest.d.ts.map +1 -1
- package/dist/npm/v2/types/sessionManifestSchema.d.ts +20 -1
- package/dist/npm/v2/types/sessionManifestSchema.d.ts.map +1 -1
- package/dist/npm/widget/mountExperienceWidget.d.ts.map +1 -1
- package/dist/npm/widget/types.d.ts +7 -0
- package/dist/npm/widget/types.d.ts.map +1 -1
- package/dist/react/component/experienceComponentLaunch.d.ts.map +1 -1
- package/dist/react/component/experienceComponentRuntime.d.ts +4 -0
- package/dist/react/component/experienceComponentRuntime.d.ts.map +1 -1
- package/dist/react/component/experienceComponentTypes.d.ts +19 -1
- package/dist/react/component/experienceComponentTypes.d.ts.map +1 -1
- package/dist/react/index.js +768 -629
- 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 -1
- package/dist/react/react/ExperienceThumbnail.d.ts.map +1 -1
- package/dist/react/react/ExperienceWidget.d.ts +4 -0
- package/dist/react/react/ExperienceWidget.d.ts.map +1 -1
- package/dist/react/thumbnail/index.d.ts +1 -0
- package/dist/react/thumbnail/index.d.ts.map +1 -1
- package/dist/react/thumbnail/styles.d.ts.map +1 -1
- package/dist/react/thumbnail/types.d.ts +3 -2
- package/dist/react/thumbnail/types.d.ts.map +1 -1
- package/dist/react/v2/embed/iframeHost.d.ts +27 -1
- package/dist/react/v2/embed/iframeHost.d.ts.map +1 -1
- package/dist/react/v2/embed/protocol.d.ts +61 -1
- package/dist/react/v2/embed/protocol.d.ts.map +1 -1
- package/dist/react/v2/experience.d.ts +24 -2
- package/dist/react/v2/experience.d.ts.map +1 -1
- package/dist/react/v2/experienceEvents.d.ts +30 -0
- package/dist/react/v2/experienceEvents.d.ts.map +1 -1
- package/dist/react/v2/shims/embedBaseUrl.d.ts +3 -2
- package/dist/react/v2/shims/embedBaseUrl.d.ts.map +1 -1
- package/dist/react/v2/types/sessionInteraction.d.ts +3 -1
- package/dist/react/v2/types/sessionInteraction.d.ts.map +1 -1
- package/dist/react/v2/types/sessionManifest.d.ts +12 -0
- package/dist/react/v2/types/sessionManifest.d.ts.map +1 -1
- package/dist/react/widget/mountExperienceWidget.d.ts.map +1 -1
- package/dist/react/widget/types.d.ts +7 -0
- package/dist/react/widget/types.d.ts.map +1 -1
- package/dist/sdk/v2/client.js +31 -6
- package/dist/sdk/v2/client.js.map +1 -1
- package/dist/svelte/Experience.svelte +36 -0
- package/dist/svelte/Experience.svelte.d.ts +2 -0
- package/dist/svelte/ExperienceThumbnail.svelte +3 -2
- package/dist/svelte/ExperienceThumbnail.svelte.d.ts +1 -1
- package/dist/svelte/ExperienceWidget.svelte +12 -1
- package/dist/svelte/ExperienceWidget.svelte.d.ts +3 -0
- package/package.json +14 -2
package/dist/next/index.js
CHANGED
|
@@ -87,28 +87,33 @@ function v(e = {}) {
|
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
//#endregion
|
|
90
|
+
//#region src/thumbnail/types.ts
|
|
91
|
+
function y(e) {
|
|
92
|
+
return e === "face" ? "liforma-et--fit-face" : e === "medium" ? "liforma-et--fit-medium" : "";
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
90
95
|
//#region src/thumbnail/toGalleryThumbUrl.ts
|
|
91
|
-
var
|
|
92
|
-
function
|
|
96
|
+
var b = /(\/avatars\/[^/]+\/)(\d+)(\/)/i, x = /_CH(\.webp)/i, S = /(-)(\d+x\d+)(\.webp)(\?|$)/i;
|
|
97
|
+
function C(e) {
|
|
93
98
|
let t = e.trim();
|
|
94
99
|
if (!t) return t;
|
|
95
|
-
let n = t.replace(
|
|
96
|
-
return n = n.replace(
|
|
100
|
+
let n = t.replace(b, (e, t, n, r) => n === "256" ? `${t}${n}${r}` : `${t}256${r}`);
|
|
101
|
+
return n = n.replace(x, "_neutral$1"), n = n.replace(S, (e, t, n, r, i) => n === "256x256" ? `${t}${n}${r}${i}` : `${t}256x256${r}${i}`), n;
|
|
97
102
|
}
|
|
98
|
-
function
|
|
103
|
+
function w(e) {
|
|
99
104
|
let t = e.avatarImage?.trim() || e.galleryThumb?.avatarImage?.trim() || "";
|
|
100
105
|
if (!t) return null;
|
|
101
106
|
let n = e.backgroundImage?.trim() || e.galleryThumb?.backgroundImage?.trim() || "", r = e.foregroundImage?.trim() || e.galleryThumb?.foregroundImage?.trim() || "", i = e.fallbackImage?.trim() || "";
|
|
102
107
|
return {
|
|
103
|
-
avatarImage:
|
|
104
|
-
...n ? { backgroundImage:
|
|
105
|
-
...r ? { foregroundImage:
|
|
106
|
-
...i ? { fallbackImage:
|
|
108
|
+
avatarImage: C(t),
|
|
109
|
+
...n ? { backgroundImage: C(n) } : {},
|
|
110
|
+
...r ? { foregroundImage: C(r) } : {},
|
|
111
|
+
...i ? { fallbackImage: C(i) } : {}
|
|
107
112
|
};
|
|
108
113
|
}
|
|
109
114
|
//#endregion
|
|
110
115
|
//#region src/shims/localStack.ts
|
|
111
|
-
function
|
|
116
|
+
function T() {
|
|
112
117
|
if (globalThis.__LIFORMA_STACK === "local") return !0;
|
|
113
118
|
if (typeof location > "u") return !1;
|
|
114
119
|
try {
|
|
@@ -119,83 +124,83 @@ function C() {
|
|
|
119
124
|
}
|
|
120
125
|
//#endregion
|
|
121
126
|
//#region src/thumbnail/hostedLaunchUrl.ts
|
|
122
|
-
var
|
|
123
|
-
function
|
|
127
|
+
var E = "https://player.liforma.ai", D = "http://localhost:3002";
|
|
128
|
+
function O(e) {
|
|
124
129
|
return e.href?.trim() ? "anchor" : e.hasClickHandler ? "button" : e.experienceId?.trim() ? "anchor" : "presentational";
|
|
125
130
|
}
|
|
126
|
-
function
|
|
131
|
+
function k(e) {
|
|
127
132
|
let t = e?.trim();
|
|
128
|
-
return t ? t.replace(/\/$/, "") :
|
|
133
|
+
return t ? t.replace(/\/$/, "") : T() ? D : E;
|
|
129
134
|
}
|
|
130
|
-
function
|
|
131
|
-
let t = e.experienceId.trim(), n =
|
|
135
|
+
function A(e) {
|
|
136
|
+
let t = e.experienceId.trim(), n = k(e.playerBaseUrl), r = new URL(`${n}/${encodeURIComponent(t)}`), i = e.returnUrl?.trim();
|
|
132
137
|
return i && r.searchParams.set("returnUrl", i), r.toString();
|
|
133
138
|
}
|
|
134
|
-
function
|
|
139
|
+
function ee(e) {
|
|
135
140
|
let t = e.href?.trim();
|
|
136
141
|
if (t) return t;
|
|
137
142
|
let n = e.experienceId?.trim();
|
|
138
143
|
if (!n) return;
|
|
139
144
|
let r = e.returnUrl?.trim();
|
|
140
|
-
return !r && e.useCurrentPageAsReturnUrl && typeof window < "u" && (r = window.location.href),
|
|
145
|
+
return !r && e.useCurrentPageAsReturnUrl && typeof window < "u" && (r = window.location.href), A({
|
|
141
146
|
experienceId: n,
|
|
142
147
|
...r ? { returnUrl: r } : {},
|
|
143
148
|
playerBaseUrl: e.playerBaseUrl
|
|
144
149
|
});
|
|
145
150
|
}
|
|
146
|
-
function
|
|
151
|
+
function j() {
|
|
147
152
|
return typeof window > "u" ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
|
|
148
153
|
}
|
|
149
|
-
var
|
|
150
|
-
function N() {
|
|
151
|
-
return A() ? 4 : Infinity;
|
|
152
|
-
}
|
|
154
|
+
var M = 0, N = [];
|
|
153
155
|
function P() {
|
|
154
|
-
return
|
|
156
|
+
return j() ? 4 : Infinity;
|
|
155
157
|
}
|
|
156
158
|
function F() {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
159
|
+
return j() ? 160 : 0;
|
|
160
|
+
}
|
|
161
|
+
function te() {
|
|
162
|
+
let e = P();
|
|
163
|
+
for (; M < e && N.length > 0;) {
|
|
164
|
+
let e = N.shift();
|
|
160
165
|
if (!e || e.cancelled) continue;
|
|
161
|
-
|
|
162
|
-
let t =
|
|
166
|
+
M += 1, e.start();
|
|
167
|
+
let t = F();
|
|
163
168
|
if (t <= 0) {
|
|
164
|
-
|
|
169
|
+
M = Math.max(0, M - 1);
|
|
165
170
|
continue;
|
|
166
171
|
}
|
|
167
172
|
window.setTimeout(() => {
|
|
168
|
-
|
|
173
|
+
M = Math.max(0, M - 1), te();
|
|
169
174
|
}, t);
|
|
170
175
|
}
|
|
171
176
|
}
|
|
172
|
-
function
|
|
173
|
-
if (!
|
|
177
|
+
function ne(e) {
|
|
178
|
+
if (!j()) return e(), () => {};
|
|
174
179
|
let t = {
|
|
175
180
|
start: e,
|
|
176
181
|
cancelled: !1
|
|
177
182
|
};
|
|
178
|
-
return
|
|
183
|
+
return N.push(t), te(), () => {
|
|
179
184
|
t.cancelled = !0;
|
|
180
185
|
};
|
|
181
186
|
}
|
|
182
187
|
//#endregion
|
|
183
188
|
//#region src/thumbnail/lazyLoad.ts
|
|
184
189
|
function I() {
|
|
185
|
-
return
|
|
190
|
+
return j() ? "96px 0px" : "280px 0px";
|
|
186
191
|
}
|
|
187
192
|
function L(e) {
|
|
188
193
|
let t = e.trim().split(/\s+/)[0] ?? "0px", n = Number.parseFloat(t);
|
|
189
194
|
return Number.isFinite(n) ? Math.abs(n) : 280;
|
|
190
195
|
}
|
|
191
|
-
function
|
|
196
|
+
function re(e, t) {
|
|
192
197
|
if (typeof window > "u") return !1;
|
|
193
198
|
let n = e.getBoundingClientRect();
|
|
194
199
|
return n.bottom >= -t && n.top <= window.innerHeight + t;
|
|
195
200
|
}
|
|
196
|
-
function
|
|
201
|
+
function ie(e, t) {
|
|
197
202
|
let { onVisibleChange: n } = t, r = t.rootMargin ?? I(), i = L(r), a = !1, o = !1, s = null, c = () => {
|
|
198
|
-
o || (s?.(), s =
|
|
203
|
+
o || (s?.(), s = ne(() => {
|
|
199
204
|
s = null, o = !0, n(!0);
|
|
200
205
|
}));
|
|
201
206
|
}, l = (e) => {
|
|
@@ -217,55 +222,55 @@ function re(e, t) {
|
|
|
217
222
|
rootMargin: r,
|
|
218
223
|
threshold: 0
|
|
219
224
|
});
|
|
220
|
-
return u.observe(e),
|
|
225
|
+
return u.observe(e), re(e, i) && l(!0), () => {
|
|
221
226
|
s?.(), s = null, u.disconnect();
|
|
222
227
|
};
|
|
223
228
|
}
|
|
224
229
|
//#endregion
|
|
225
230
|
//#region src/thumbnail/scrollParallax.ts
|
|
226
|
-
function
|
|
231
|
+
function R() {
|
|
227
232
|
return typeof window > "u" || window.matchMedia("(prefers-reduced-motion: reduce)").matches ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
|
|
228
233
|
}
|
|
229
|
-
function
|
|
234
|
+
function z(e, t) {
|
|
230
235
|
return ((e.top + e.height / 2) / Math.max(t, 1) - .5) * 2;
|
|
231
236
|
}
|
|
232
|
-
var
|
|
233
|
-
function
|
|
234
|
-
if (V = 0,
|
|
237
|
+
var B = /* @__PURE__ */ new Set(), ae = !1, V = 0;
|
|
238
|
+
function oe() {
|
|
239
|
+
if (V = 0, B.size === 0 || typeof window > "u") return;
|
|
235
240
|
let e = window.innerHeight;
|
|
236
|
-
for (let t of
|
|
241
|
+
for (let t of B) {
|
|
237
242
|
if (t.pointerActive?.()) continue;
|
|
238
243
|
let n = t.element.getBoundingClientRect();
|
|
239
|
-
n.bottom < -64 || n.top > e + 64 || t.onParallax(
|
|
244
|
+
n.bottom < -64 || n.top > e + 64 || t.onParallax(z(n, e));
|
|
240
245
|
}
|
|
241
246
|
}
|
|
242
|
-
function oe() {
|
|
243
|
-
V === 0 && (V = requestAnimationFrame(ae));
|
|
244
|
-
}
|
|
245
247
|
function se() {
|
|
246
|
-
|
|
248
|
+
V === 0 && (V = requestAnimationFrame(oe));
|
|
247
249
|
}
|
|
248
250
|
function ce() {
|
|
249
|
-
|
|
251
|
+
ae || typeof window > "u" || (ae = !0, window.addEventListener("scroll", se, { passive: !0 }), window.addEventListener("resize", se, { passive: !0 }));
|
|
252
|
+
}
|
|
253
|
+
function H() {
|
|
254
|
+
B.size > 0 || !ae || typeof window > "u" || (ae = !1, V !== 0 && (cancelAnimationFrame(V), V = 0), window.removeEventListener("scroll", se), window.removeEventListener("resize", se));
|
|
250
255
|
}
|
|
251
|
-
function
|
|
252
|
-
if (!
|
|
256
|
+
function le(e, t) {
|
|
257
|
+
if (!R()) return () => {};
|
|
253
258
|
let n = {
|
|
254
259
|
element: e,
|
|
255
260
|
onParallax: t.onParallax,
|
|
256
261
|
pointerActive: t.pointerActive
|
|
257
262
|
};
|
|
258
|
-
return
|
|
259
|
-
|
|
263
|
+
return B.add(n), ce(), n.pointerActive?.() || t.onParallax(z(e.getBoundingClientRect(), window.innerHeight)), () => {
|
|
264
|
+
B.delete(n), H();
|
|
260
265
|
};
|
|
261
266
|
}
|
|
262
267
|
//#endregion
|
|
263
268
|
//#region src/thumbnail/attachThumbnailParallax.ts
|
|
264
|
-
function
|
|
269
|
+
function ue(e) {
|
|
265
270
|
let t = 0, n = 0, r = !1, i = !1, a = !1, o = () => {
|
|
266
271
|
let a = r || i;
|
|
267
272
|
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));
|
|
268
|
-
}, s =
|
|
273
|
+
}, s = le(e, {
|
|
269
274
|
onParallax: (e) => {
|
|
270
275
|
i = !0, a || (t = e, n = 0, o());
|
|
271
276
|
},
|
|
@@ -278,7 +283,7 @@ function le(e) {
|
|
|
278
283
|
a = !0, e.pointerType === "mouse" && (r = !0), o();
|
|
279
284
|
}, u = () => {
|
|
280
285
|
let s = a;
|
|
281
|
-
a = !1, r = !1, i && s ? (t =
|
|
286
|
+
a = !1, r = !1, i && s ? (t = z(e.getBoundingClientRect(), window.innerHeight), n = 0) : i || (t = 0, n = 0), o();
|
|
282
287
|
}, d = (e) => {
|
|
283
288
|
e.pointerType === "mouse" && (r = !0, o());
|
|
284
289
|
}, f = () => {
|
|
@@ -290,8 +295,8 @@ function le(e) {
|
|
|
290
295
|
}
|
|
291
296
|
//#endregion
|
|
292
297
|
//#region src/thumbnail/styles.ts
|
|
293
|
-
var
|
|
294
|
-
function
|
|
298
|
+
var de = ".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/* Bust / medium: less zoom than face so upper chest stays in frame (player 3.75H window). */\n.liforma-et--fit-medium {\n --liforma-et-avatar-scale: 1.35;\n --liforma-et-bg-scale: 1.35;\n --liforma-et-fg-scale: 1.35;\n}\n\n.liforma-et--fit-medium .liforma-et__avatar,\n.liforma-et--fit-medium .liforma-et__background,\n.liforma-et--fit-medium .liforma-et__foreground {\n transform-origin: 50% 28%;\n}\n\n.liforma-et--fit-medium .liforma-et__avatar {\n object-fit: cover;\n object-position: 50% 28%;\n}\n\n.liforma-et__foreground {\n position: absolute;\n inset: 0;\n z-index: 3;\n width: 100%;\n height: 100%;\n object-fit: cover;\n object-position: center center;\n pointer-events: none;\n transform: translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-fg-shift) * -1),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-fg-shift) * -1)\n )\n scale(var(--liforma-et-fg-scale));\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n.liforma-et--parallax {\n --liforma-et-bg-scale: 1.08;\n --liforma-et-fg-scale: 1.05;\n --liforma-et-avatar-scale: 1.08;\n --liforma-et-bg-shift: 10px;\n --liforma-et-fg-shift: 4px;\n --liforma-et-avatar-shift: 4px;\n}\n\n/* Promote layers only while parallax is active — avoids N compositor surfaces on galleries. */\n.liforma-et--parallax .liforma-et__background,\n.liforma-et--parallax .liforma-et__foreground,\n.liforma-et--parallax .liforma-et__avatar {\n will-change: transform;\n}\n\n.liforma-et--parallax.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.95;\n --liforma-et-bg-scale: 1.95;\n --liforma-et-fg-scale: 1.95;\n --liforma-et-avatar-shift: 0px;\n}\n\n.liforma-et--parallax.liforma-et--fit-medium {\n --liforma-et-avatar-scale: 1.42;\n --liforma-et-bg-scale: 1.42;\n --liforma-et-fg-scale: 1.42;\n --liforma-et-avatar-shift: 0px;\n}\n\n.liforma-et--scroll-parallax .liforma-et__background,\n.liforma-et--scroll-parallax .liforma-et__foreground,\n.liforma-et--scroll-parallax .liforma-et__avatar {\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .liforma-et {\n --liforma-et-reveal-duration: 0ms;\n }\n\n .liforma-et--parallax {\n --liforma-et-bg-scale: 1;\n --liforma-et-fg-scale: 1;\n --liforma-et-avatar-scale: 1;\n --liforma-et-bg-shift: 0px;\n --liforma-et-fg-shift: 0px;\n --liforma-et-avatar-shift: 0px;\n }\n\n .liforma-et--parallax.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.85;\n --liforma-et-bg-scale: 1.85;\n --liforma-et-fg-scale: 1.85;\n }\n\n .liforma-et__background,\n .liforma-et__foreground,\n .liforma-et__avatar {\n transition: none;\n }\n}", U = !1;
|
|
299
|
+
function W(e) {
|
|
295
300
|
if (typeof document > "u" || U) return;
|
|
296
301
|
if (document.querySelector("style[data-liforma-et]")) {
|
|
297
302
|
U = !0;
|
|
@@ -302,207 +307,207 @@ function de(e) {
|
|
|
302
307
|
}
|
|
303
308
|
//#endregion
|
|
304
309
|
//#region src/react/ExperienceThumbnail.tsx
|
|
305
|
-
function
|
|
310
|
+
function fe(e, t) {
|
|
306
311
|
return `${e} liforma-et__media${t ? " liforma-et__media--ready" : ""}`;
|
|
307
312
|
}
|
|
308
|
-
function
|
|
309
|
-
let { galleryThumb: c, avatarImage: l, backgroundImage: u, foregroundImage: d, alt: f, experienceId: p, href: m, target: h, rel: g, onClick: _, returnUrl: v, playerBaseUrl:
|
|
313
|
+
function pe(s) {
|
|
314
|
+
let { galleryThumb: c, avatarImage: l, backgroundImage: u, foregroundImage: d, alt: f, experienceId: p, href: m, target: h, rel: g, onClick: _, returnUrl: v, playerBaseUrl: b, parallax: x = !0, fit: S = "full", lazy: C = !0, className: T = "", fallbackImage: E } = s, D = t(() => w({
|
|
310
315
|
galleryThumb: c,
|
|
311
316
|
avatarImage: l,
|
|
312
317
|
backgroundImage: u,
|
|
313
318
|
foregroundImage: d,
|
|
314
|
-
fallbackImage:
|
|
319
|
+
fallbackImage: E
|
|
315
320
|
}), [
|
|
316
321
|
c,
|
|
317
322
|
l,
|
|
318
323
|
u,
|
|
319
324
|
d,
|
|
320
|
-
|
|
321
|
-
]),
|
|
325
|
+
E
|
|
326
|
+
]), k = O({
|
|
322
327
|
href: m,
|
|
323
328
|
hasClickHandler: typeof _ == "function",
|
|
324
329
|
experienceId: p
|
|
325
|
-
}),
|
|
330
|
+
}), A = k === "anchor" && !m?.trim() && !!p?.trim(), j = !!D?.backgroundImage, M = x !== !1, N = n(null), P = n(!1), [F, te] = r(!C), [ne, I] = r(!1), [L, re] = r(!1), [R, B] = r(0), [ae, V] = r(0), [oe, se] = r(!1), [ce, H] = r(!1), [ue, U] = r(!1), [pe, me] = r(!1), [G, he] = r(), ge = D ? oe && D.fallbackImage ? D.fallbackImage : D.avatarImage : "";
|
|
326
331
|
e(() => {
|
|
327
|
-
de
|
|
332
|
+
W(de);
|
|
328
333
|
}, []), e(() => {
|
|
329
|
-
|
|
334
|
+
he(ee({
|
|
330
335
|
href: m,
|
|
331
336
|
experienceId: p,
|
|
332
337
|
returnUrl: v,
|
|
333
|
-
playerBaseUrl:
|
|
334
|
-
useCurrentPageAsReturnUrl:
|
|
338
|
+
playerBaseUrl: b,
|
|
339
|
+
useCurrentPageAsReturnUrl: A && !v?.trim()
|
|
335
340
|
}));
|
|
336
341
|
}, [
|
|
337
342
|
m,
|
|
338
343
|
p,
|
|
339
344
|
v,
|
|
340
|
-
|
|
341
|
-
|
|
345
|
+
b,
|
|
346
|
+
A
|
|
342
347
|
]), e(() => {
|
|
343
|
-
|
|
348
|
+
H(!1), U(!1), me(!1), se(!1);
|
|
344
349
|
}, [
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
350
|
+
D?.backgroundImage,
|
|
351
|
+
D?.foregroundImage,
|
|
352
|
+
ge
|
|
348
353
|
]), e(() => {
|
|
349
|
-
let e =
|
|
354
|
+
let e = N.current;
|
|
350
355
|
if (e) {
|
|
351
|
-
if (!
|
|
352
|
-
|
|
356
|
+
if (!C) {
|
|
357
|
+
te(!0);
|
|
353
358
|
return;
|
|
354
359
|
}
|
|
355
|
-
return
|
|
356
|
-
e &&
|
|
360
|
+
return ie(e, { onVisibleChange: (e) => {
|
|
361
|
+
e && te(!0);
|
|
357
362
|
} });
|
|
358
363
|
}
|
|
359
364
|
}, [
|
|
360
|
-
|
|
361
|
-
T,
|
|
365
|
+
C,
|
|
362
366
|
D,
|
|
367
|
+
k,
|
|
363
368
|
G
|
|
364
369
|
]), e(() => {
|
|
365
|
-
let e =
|
|
366
|
-
if (!(!e || !
|
|
370
|
+
let e = N.current;
|
|
371
|
+
if (!(!e || !M)) return le(e, {
|
|
367
372
|
onParallax: (e) => {
|
|
368
|
-
|
|
373
|
+
re(!0), P.current || (B(e), V(0));
|
|
369
374
|
},
|
|
370
|
-
pointerActive: () =>
|
|
375
|
+
pointerActive: () => P.current
|
|
371
376
|
});
|
|
372
377
|
}, [
|
|
373
|
-
|
|
374
|
-
T,
|
|
378
|
+
M,
|
|
375
379
|
D,
|
|
380
|
+
k,
|
|
376
381
|
G
|
|
377
382
|
]);
|
|
378
|
-
let
|
|
379
|
-
if (!
|
|
383
|
+
let _e = (e) => {
|
|
384
|
+
if (!M || L) return;
|
|
380
385
|
let t = e.currentTarget.getBoundingClientRect();
|
|
381
|
-
t.width <= 0 || t.height <= 0 || (
|
|
382
|
-
},
|
|
383
|
-
let t =
|
|
384
|
-
|
|
385
|
-
},
|
|
386
|
-
if (!
|
|
387
|
-
|
|
386
|
+
t.width <= 0 || t.height <= 0 || (B(((e.clientX - t.left) / t.width - .5) * 2), V(((e.clientY - t.top) / t.height - .5) * 2));
|
|
387
|
+
}, K = (e) => {
|
|
388
|
+
let t = P.current;
|
|
389
|
+
P.current = !1, I(!1), L && t ? (B(z(e.getBoundingClientRect(), window.innerHeight)), V(0)) : L || (B(0), V(0));
|
|
390
|
+
}, ve = (e) => {
|
|
391
|
+
if (!M) return;
|
|
392
|
+
P.current = !0, e.pointerType === "mouse" && I(!0);
|
|
388
393
|
let t = e.currentTarget, n = () => {
|
|
389
|
-
|
|
394
|
+
K(t), window.removeEventListener("pointerup", n), window.removeEventListener("pointercancel", n);
|
|
390
395
|
};
|
|
391
396
|
window.addEventListener("pointerup", n), window.addEventListener("pointercancel", n);
|
|
392
|
-
},
|
|
393
|
-
if (_?.(e), !e.defaultPrevented &&
|
|
394
|
-
let t =
|
|
397
|
+
}, ye = (e) => {
|
|
398
|
+
if (_?.(e), !e.defaultPrevented && A && !v?.trim()) {
|
|
399
|
+
let t = ee({
|
|
395
400
|
experienceId: p,
|
|
396
|
-
playerBaseUrl:
|
|
401
|
+
playerBaseUrl: b,
|
|
397
402
|
useCurrentPageAsReturnUrl: !0
|
|
398
403
|
});
|
|
399
404
|
t && e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && (e.preventDefault(), window.location.assign(t));
|
|
400
405
|
}
|
|
401
406
|
};
|
|
402
|
-
if (!
|
|
403
|
-
let
|
|
407
|
+
if (!D) return null;
|
|
408
|
+
let be = M && (ne || L), q = F && (ue || ce || pe), xe = [
|
|
404
409
|
"liforma-et",
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
410
|
+
j ? "liforma-et--scene" : "",
|
|
411
|
+
y(S),
|
|
412
|
+
be ? "liforma-et--parallax" : "",
|
|
408
413
|
L ? "liforma-et--scroll-parallax" : "",
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
].filter(Boolean).join(" "),
|
|
413
|
-
"--liforma-et-parallax-x":
|
|
414
|
-
"--liforma-et-parallax-y":
|
|
415
|
-
},
|
|
414
|
+
F && !q ? "liforma-et--loading" : "",
|
|
415
|
+
q ? "liforma-et--revealed" : "",
|
|
416
|
+
T
|
|
417
|
+
].filter(Boolean).join(" "), Se = {
|
|
418
|
+
"--liforma-et-parallax-x": R,
|
|
419
|
+
"--liforma-et-parallax-y": ae
|
|
420
|
+
}, Ce = (e, t) => {
|
|
416
421
|
e.complete && t(!0);
|
|
417
|
-
},
|
|
422
|
+
}, we = /* @__PURE__ */ o(i, { children: [
|
|
418
423
|
/* @__PURE__ */ a("span", {
|
|
419
424
|
className: "liforma-et__placeholder",
|
|
420
425
|
"aria-hidden": "true"
|
|
421
426
|
}),
|
|
422
|
-
|
|
423
|
-
className:
|
|
424
|
-
src:
|
|
427
|
+
F && D.backgroundImage ? /* @__PURE__ */ a("img", {
|
|
428
|
+
className: fe("liforma-et__background", ce),
|
|
429
|
+
src: D.backgroundImage,
|
|
425
430
|
alt: "",
|
|
426
431
|
decoding: "async",
|
|
427
432
|
ref: (e) => {
|
|
428
|
-
e &&
|
|
433
|
+
e && Ce(e, H);
|
|
429
434
|
},
|
|
430
|
-
onLoad: () =>
|
|
431
|
-
onError: () =>
|
|
435
|
+
onLoad: () => H(!0),
|
|
436
|
+
onError: () => H(!0)
|
|
432
437
|
}) : null,
|
|
433
|
-
|
|
434
|
-
className:
|
|
435
|
-
src:
|
|
438
|
+
F && ge ? /* @__PURE__ */ a("img", {
|
|
439
|
+
className: fe("liforma-et__avatar", ue),
|
|
440
|
+
src: ge,
|
|
436
441
|
alt: "",
|
|
437
442
|
decoding: "async",
|
|
438
443
|
ref: (e) => {
|
|
439
|
-
e &&
|
|
444
|
+
e && Ce(e, U);
|
|
440
445
|
},
|
|
441
446
|
onLoad: () => U(!0),
|
|
442
447
|
onError: () => {
|
|
443
|
-
|
|
448
|
+
D.fallbackImage ? se(!0) : U(!0);
|
|
444
449
|
}
|
|
445
450
|
}) : null,
|
|
446
|
-
|
|
447
|
-
className:
|
|
448
|
-
src:
|
|
451
|
+
F && D.foregroundImage ? /* @__PURE__ */ a("img", {
|
|
452
|
+
className: fe("liforma-et__foreground", pe),
|
|
453
|
+
src: D.foregroundImage,
|
|
449
454
|
alt: "",
|
|
450
455
|
decoding: "async",
|
|
451
456
|
ref: (e) => {
|
|
452
|
-
e &&
|
|
457
|
+
e && Ce(e, me);
|
|
453
458
|
},
|
|
454
|
-
onLoad: () =>
|
|
455
|
-
onError: () =>
|
|
459
|
+
onLoad: () => me(!0),
|
|
460
|
+
onError: () => me(!0)
|
|
456
461
|
}) : null
|
|
457
|
-
] }),
|
|
458
|
-
onPointerDown:
|
|
459
|
-
onPointerUp: (e) =>
|
|
460
|
-
onPointerCancel: (e) =>
|
|
462
|
+
] }), J = {
|
|
463
|
+
onPointerDown: ve,
|
|
464
|
+
onPointerUp: (e) => K(e.currentTarget),
|
|
465
|
+
onPointerCancel: (e) => K(e.currentTarget),
|
|
461
466
|
onPointerEnter: (e) => {
|
|
462
|
-
|
|
467
|
+
M && e.pointerType === "mouse" && I(!0);
|
|
463
468
|
},
|
|
464
|
-
onPointerMove:
|
|
469
|
+
onPointerMove: _e,
|
|
465
470
|
onPointerLeave: () => {
|
|
466
|
-
|
|
471
|
+
P.current || (I(!1), L || (B(0), V(0)));
|
|
467
472
|
}
|
|
468
473
|
}, Y = (e) => {
|
|
469
|
-
|
|
474
|
+
N.current = e;
|
|
470
475
|
};
|
|
471
|
-
return
|
|
476
|
+
return k === "anchor" && G ? /* @__PURE__ */ a("a", {
|
|
472
477
|
ref: Y,
|
|
473
|
-
className:
|
|
474
|
-
style:
|
|
478
|
+
className: xe,
|
|
479
|
+
style: Se,
|
|
475
480
|
href: G,
|
|
476
481
|
target: h,
|
|
477
482
|
rel: g,
|
|
478
483
|
"aria-label": f,
|
|
479
|
-
onClick:
|
|
480
|
-
...
|
|
481
|
-
children:
|
|
482
|
-
}) :
|
|
484
|
+
onClick: ye,
|
|
485
|
+
...J,
|
|
486
|
+
children: we
|
|
487
|
+
}) : k === "button" ? /* @__PURE__ */ a("button", {
|
|
483
488
|
type: "button",
|
|
484
489
|
ref: Y,
|
|
485
|
-
className:
|
|
486
|
-
style:
|
|
490
|
+
className: xe,
|
|
491
|
+
style: Se,
|
|
487
492
|
"aria-label": f,
|
|
488
|
-
onClick:
|
|
489
|
-
...
|
|
490
|
-
children:
|
|
493
|
+
onClick: ye,
|
|
494
|
+
...J,
|
|
495
|
+
children: we
|
|
491
496
|
}) : /* @__PURE__ */ a("div", {
|
|
492
497
|
ref: Y,
|
|
493
|
-
className:
|
|
494
|
-
style:
|
|
498
|
+
className: xe,
|
|
499
|
+
style: Se,
|
|
495
500
|
role: f ? "img" : void 0,
|
|
496
501
|
"aria-label": f || void 0,
|
|
497
502
|
"aria-hidden": f ? void 0 : !0,
|
|
498
|
-
...
|
|
499
|
-
children:
|
|
503
|
+
...J,
|
|
504
|
+
children: we
|
|
500
505
|
});
|
|
501
506
|
}
|
|
502
507
|
//#endregion
|
|
503
508
|
//#region src/widget/styles.ts
|
|
504
|
-
var pe = "\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", G = "liforma-experience-widget-styles";
|
|
505
|
-
function
|
|
509
|
+
var me = "\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", G = "liforma-experience-widget-styles";
|
|
510
|
+
function he(e = me) {
|
|
506
511
|
if (typeof document > "u") return;
|
|
507
512
|
let t = document.getElementById(G);
|
|
508
513
|
if (t) {
|
|
@@ -514,20 +519,20 @@ function me(e = pe) {
|
|
|
514
519
|
}
|
|
515
520
|
//#endregion
|
|
516
521
|
//#region src/shims/apiBaseUrl.ts
|
|
517
|
-
var
|
|
518
|
-
function
|
|
522
|
+
var ge = "https://api.liforma.ai", _e = "http://localhost:3001";
|
|
523
|
+
function K() {
|
|
519
524
|
let e = globalThis.__LIFORMA_API_BASE_URL;
|
|
520
525
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
521
526
|
if (typeof document > "u") return null;
|
|
522
527
|
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();
|
|
523
528
|
return t ? t.replace(/\/$/, "") : null;
|
|
524
529
|
}
|
|
525
|
-
function
|
|
526
|
-
return
|
|
530
|
+
function ve() {
|
|
531
|
+
return K() || (T() ? _e : ge);
|
|
527
532
|
}
|
|
528
533
|
//#endregion
|
|
529
534
|
//#region src/v2/api/fetchExperiencePreview.ts
|
|
530
|
-
function
|
|
535
|
+
function ye(e) {
|
|
531
536
|
if (!e || typeof e != "object") return null;
|
|
532
537
|
let t = e, n = typeof t.avatarImage == "string" ? t.avatarImage.trim() : "";
|
|
533
538
|
return n ? {
|
|
@@ -536,10 +541,10 @@ function _e(e) {
|
|
|
536
541
|
...typeof t.foregroundImage == "string" && t.foregroundImage.trim() ? { foregroundImage: t.foregroundImage.trim() } : {}
|
|
537
542
|
} : null;
|
|
538
543
|
}
|
|
539
|
-
async function
|
|
544
|
+
async function be(e, t) {
|
|
540
545
|
let n = e.trim();
|
|
541
546
|
if (!n) throw Error("Experience preview requires experienceId.");
|
|
542
|
-
let r = (t?.apiBaseUrl ??
|
|
547
|
+
let r = (t?.apiBaseUrl ?? ve()).replace(/\/$/, ""), i = await fetch(`${r}/v1/experiences/${encodeURIComponent(n)}/preview`, {
|
|
543
548
|
method: "GET",
|
|
544
549
|
headers: { Accept: "application/json" },
|
|
545
550
|
signal: t?.signal
|
|
@@ -559,7 +564,7 @@ async function ve(e, t) {
|
|
|
559
564
|
throw Error("Experience preview returned invalid JSON.");
|
|
560
565
|
}
|
|
561
566
|
if (!a || typeof a != "object") throw Error("Experience preview returned an invalid payload.");
|
|
562
|
-
let o = a, s = typeof o.experienceId == "string" ? o.experienceId.trim() : n, c = typeof o.title == "string" ? o.title.trim() : "", l =
|
|
567
|
+
let o = a, s = typeof o.experienceId == "string" ? o.experienceId.trim() : n, c = typeof o.title == "string" ? o.title.trim() : "", l = ye(o.galleryThumb);
|
|
563
568
|
if (!l) throw Error("Experience preview is missing gallery thumb images.");
|
|
564
569
|
return {
|
|
565
570
|
experienceId: s || n,
|
|
@@ -569,7 +574,7 @@ async function ve(e, t) {
|
|
|
569
574
|
}
|
|
570
575
|
//#endregion
|
|
571
576
|
//#region src/v2/errors/LiformaError.ts
|
|
572
|
-
var
|
|
577
|
+
var q = class extends Error {
|
|
573
578
|
code;
|
|
574
579
|
requestId;
|
|
575
580
|
status;
|
|
@@ -578,16 +583,16 @@ var J = class extends Error {
|
|
|
578
583
|
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;
|
|
579
584
|
}
|
|
580
585
|
};
|
|
581
|
-
function
|
|
586
|
+
function xe(e) {
|
|
582
587
|
if (!(!e || typeof e != "object" || Array.isArray(e))) return e;
|
|
583
588
|
}
|
|
584
|
-
function
|
|
589
|
+
function Se(e, t, n) {
|
|
585
590
|
let r = n?.get("Liforma-Request-Id")?.trim() || void 0, i;
|
|
586
591
|
try {
|
|
587
592
|
i = JSON.parse(t);
|
|
588
593
|
} catch {}
|
|
589
|
-
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 } =
|
|
590
|
-
return new
|
|
594
|
+
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 } = xe(a) ?? xe(i) ?? {};
|
|
595
|
+
return new q(u, {
|
|
591
596
|
code: l,
|
|
592
597
|
requestId: d,
|
|
593
598
|
status: e,
|
|
@@ -596,19 +601,19 @@ function be(e, t, n) {
|
|
|
596
601
|
}
|
|
597
602
|
//#endregion
|
|
598
603
|
//#region src/v2/api/sessionEndpointRequest.ts
|
|
599
|
-
function
|
|
604
|
+
function Ce(e) {
|
|
600
605
|
let t = e.locale?.trim();
|
|
601
606
|
if (t) return t;
|
|
602
607
|
let n = e.language?.trim();
|
|
603
608
|
if (n) return n;
|
|
604
609
|
if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
|
|
605
610
|
}
|
|
606
|
-
function
|
|
611
|
+
function we(e) {
|
|
607
612
|
let t = e.secondaryLocale?.trim(), n = e.learningLocale?.trim();
|
|
608
613
|
if (t && n && t !== n) throw Error("secondaryLocale and learningLocale disagree; pass only one or make them equal.");
|
|
609
614
|
return t || n || void 0;
|
|
610
615
|
}
|
|
611
|
-
function
|
|
616
|
+
function J(e, t) {
|
|
612
617
|
let n = e.trim();
|
|
613
618
|
if (!n) throw Error("sessionEndpoint must not be empty.");
|
|
614
619
|
if (typeof location > "u") throw Error("sessionEndpoint is only available in a browser.");
|
|
@@ -616,7 +621,7 @@ function Ce(e, t) {
|
|
|
616
621
|
if (r.origin !== location.origin) throw Error("sessionEndpoint must be same-origin.");
|
|
617
622
|
let i = t.experienceId.trim();
|
|
618
623
|
if (!i) throw Error("sessionEndpoint requires experienceId.");
|
|
619
|
-
let a =
|
|
624
|
+
let a = Ce(t), o = we(t), s = t.idempotencyKey?.trim();
|
|
620
625
|
return {
|
|
621
626
|
url: r.toString(),
|
|
622
627
|
init: {
|
|
@@ -646,7 +651,7 @@ function Y(e) {
|
|
|
646
651
|
function X(e) {
|
|
647
652
|
return typeof e == "boolean";
|
|
648
653
|
}
|
|
649
|
-
function
|
|
654
|
+
function Te(e) {
|
|
650
655
|
if (!Y(e)) return null;
|
|
651
656
|
let t = e.speech, n = e.conversation, r = e.avatar, i = e.tools;
|
|
652
657
|
return !Y(t) || !Y(n) || !Y(r) || !Y(i) || !X(t.input) || !X(t.output) || !X(t.externalAudio) || !X(n.managed) || !X(r.enabled) || !X(i.enabled) ? null : {
|
|
@@ -660,7 +665,7 @@ function we(e) {
|
|
|
660
665
|
tools: { enabled: i.enabled }
|
|
661
666
|
};
|
|
662
667
|
}
|
|
663
|
-
function
|
|
668
|
+
function Ee(e) {
|
|
664
669
|
return !Y(e) || !X(e.avatar) || !X(e.speechInput) || !X(e.speechOutput) || !X(e.tools) || !X(e.externalAudio) ? null : {
|
|
665
670
|
speech: {
|
|
666
671
|
input: e.speechInput,
|
|
@@ -672,12 +677,12 @@ function Te(e) {
|
|
|
672
677
|
tools: { enabled: e.tools }
|
|
673
678
|
};
|
|
674
679
|
}
|
|
675
|
-
function Ee(e) {
|
|
676
|
-
return we(e) ?? Te(e);
|
|
677
|
-
}
|
|
678
680
|
function De(e) {
|
|
681
|
+
return Te(e) ?? Ee(e);
|
|
682
|
+
}
|
|
683
|
+
function Oe(e) {
|
|
679
684
|
if (!Y(e)) throw Error("Session Launch response is missing session.");
|
|
680
|
-
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 =
|
|
685
|
+
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 = De(e.capabilities), l = ke(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;
|
|
681
686
|
if (!t || !n || !r || !i || !a || !s || !c) throw Error("Session Launch response has an invalid session object.");
|
|
682
687
|
return {
|
|
683
688
|
id: t,
|
|
@@ -693,7 +698,7 @@ function De(e) {
|
|
|
693
698
|
...d ? { createdAt: d } : {}
|
|
694
699
|
};
|
|
695
700
|
}
|
|
696
|
-
function
|
|
701
|
+
function ke(e) {
|
|
697
702
|
if (!Array.isArray(e) || e.length === 0) return;
|
|
698
703
|
let t = [];
|
|
699
704
|
for (let n of e) {
|
|
@@ -708,102 +713,102 @@ function Oe(e) {
|
|
|
708
713
|
}
|
|
709
714
|
return t.length > 0 ? t : void 0;
|
|
710
715
|
}
|
|
711
|
-
function
|
|
716
|
+
function Ae(e) {
|
|
712
717
|
let t = e.localeVoiceFallbacks;
|
|
713
718
|
if (t?.length) for (let e of t) {
|
|
714
719
|
let t = e.axis === "secondaryLocale" ? "secondaryLocale" : "locale";
|
|
715
720
|
console.warn(`[liforma] Session ${t} fell back to ${e.resolved} because the voice does not support ${e.requested}.`);
|
|
716
721
|
}
|
|
717
722
|
}
|
|
718
|
-
function
|
|
723
|
+
function je(e) {
|
|
719
724
|
if (!Y(e)) throw Error("Session Launch response must be a JSON object.");
|
|
720
725
|
let t = typeof e.launch == "string" ? e.launch.trim() : "";
|
|
721
726
|
if (!t) throw Error("Session Launch response is missing launch.");
|
|
722
|
-
let n =
|
|
723
|
-
return
|
|
727
|
+
let n = Oe(e.session);
|
|
728
|
+
return Ae(n), {
|
|
724
729
|
session: n,
|
|
725
730
|
launch: t
|
|
726
731
|
};
|
|
727
732
|
}
|
|
728
733
|
//#endregion
|
|
729
734
|
//#region src/v2/api/mintPublicSession.ts
|
|
730
|
-
function
|
|
735
|
+
function Me() {
|
|
731
736
|
try {
|
|
732
737
|
if (typeof globalThis.location?.origin == "string" && globalThis.location.origin) return globalThis.location.origin;
|
|
733
738
|
} catch {}
|
|
734
739
|
}
|
|
735
|
-
function
|
|
740
|
+
function Ne(e) {
|
|
736
741
|
return e ? e.trim().toUpperCase().replace(/-/g, "_") : "";
|
|
737
742
|
}
|
|
738
|
-
function
|
|
739
|
-
let n =
|
|
743
|
+
function Pe(e, t) {
|
|
744
|
+
let n = Me(), r = Ne(t.code), i = t.message.trim(), a = t.details ?? {};
|
|
740
745
|
if (r === "ORIGIN_NOT_ALLOWED" || /^Origin not allowed/i.test(i) && n) {
|
|
741
746
|
if (i.includes(e) && i.includes("allowed origin")) return t;
|
|
742
747
|
let r = typeof a.origin == "string" && a.origin || n || "(unknown origin)";
|
|
743
|
-
return new
|
|
748
|
+
return new q(`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.`, {
|
|
744
749
|
code: "ORIGIN_NOT_ALLOWED",
|
|
745
750
|
requestId: t.requestId,
|
|
746
751
|
status: t.status,
|
|
747
752
|
details: a
|
|
748
753
|
});
|
|
749
754
|
}
|
|
750
|
-
return r === "BROWSER_EMBEDS_DISABLED" || /^Browser embeds are not enabled/i.test(i) ? i.includes("Allow public client-only embeds") ? t : new
|
|
755
|
+
return r === "BROWSER_EMBEDS_DISABLED" || /^Browser embeds are not enabled/i.test(i) ? i.includes("Allow public client-only embeds") ? t : new q(`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”.`, {
|
|
751
756
|
code: "BROWSER_EMBEDS_DISABLED",
|
|
752
757
|
requestId: t.requestId,
|
|
753
758
|
status: t.status,
|
|
754
759
|
details: a
|
|
755
|
-
}) : r === "EXPERIENCE_UNAVAILABLE" || /^Experience is not available\.?$/i.test(i) || /^Unknown experience\.?$/i.test(i) ? i.includes("No playable experience found") ? t : new
|
|
760
|
+
}) : r === "EXPERIENCE_UNAVAILABLE" || /^Experience is not available\.?$/i.test(i) || /^Unknown experience\.?$/i.test(i) ? i.includes("No playable experience found") ? t : new q(`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.`, {
|
|
756
761
|
code: "EXPERIENCE_UNAVAILABLE",
|
|
757
762
|
requestId: t.requestId,
|
|
758
763
|
status: t.status,
|
|
759
764
|
details: a
|
|
760
765
|
}) : t;
|
|
761
766
|
}
|
|
762
|
-
function
|
|
767
|
+
function Fe(e) {
|
|
763
768
|
let t = e?.locale?.trim();
|
|
764
769
|
if (t) return t;
|
|
765
770
|
let n = e?.language?.trim();
|
|
766
771
|
if (n) return n;
|
|
767
772
|
if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
|
|
768
773
|
}
|
|
769
|
-
function
|
|
774
|
+
function Ie(e) {
|
|
770
775
|
let t = e?.secondaryLocale?.trim(), n = e?.learningLocale?.trim();
|
|
771
|
-
if (t && n && t !== n) throw new
|
|
776
|
+
if (t && n && t !== n) throw new q("secondaryLocale and learningLocale disagree; pass only one or make them equal.", { code: "INVALID_BODY" });
|
|
772
777
|
return t || n || void 0;
|
|
773
778
|
}
|
|
774
|
-
function
|
|
775
|
-
let n = { experienceId: e }, r =
|
|
779
|
+
function Le(e, t) {
|
|
780
|
+
let n = { experienceId: e }, r = Fe(t);
|
|
776
781
|
r && (n.locale = r);
|
|
777
|
-
let i =
|
|
782
|
+
let i = Ie(t);
|
|
778
783
|
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;
|
|
779
784
|
}
|
|
780
|
-
async function
|
|
781
|
-
let n =
|
|
785
|
+
async function Re(e, t) {
|
|
786
|
+
let n = ve(), r = t?.idempotencyKey?.trim(), i = await fetch(`${n}/v1/browser-sessions`, {
|
|
782
787
|
method: "POST",
|
|
783
788
|
headers: {
|
|
784
789
|
"Content-Type": "application/json",
|
|
785
790
|
...r ? { "Idempotency-Key": r } : {}
|
|
786
791
|
},
|
|
787
|
-
body: JSON.stringify(
|
|
792
|
+
body: JSON.stringify(Le(e, t))
|
|
788
793
|
});
|
|
789
794
|
if (!i.ok) {
|
|
790
795
|
let t = await i.text();
|
|
791
|
-
throw
|
|
796
|
+
throw Pe(e, Se(i.status, t, i.headers));
|
|
792
797
|
}
|
|
793
798
|
let a;
|
|
794
799
|
try {
|
|
795
800
|
a = await i.json();
|
|
796
801
|
} catch {
|
|
797
|
-
throw new
|
|
802
|
+
throw new q("Browser session mint returned invalid JSON.", {
|
|
798
803
|
code: "INVALID_RESPONSE",
|
|
799
804
|
status: i.status,
|
|
800
805
|
requestId: i.headers.get("Liforma-Request-Id") ?? void 0
|
|
801
806
|
});
|
|
802
807
|
}
|
|
803
|
-
return
|
|
808
|
+
return je(a);
|
|
804
809
|
}
|
|
805
|
-
async function
|
|
806
|
-
let n =
|
|
810
|
+
async function ze(e, t) {
|
|
811
|
+
let n = J(e, t), r = new AbortController(), i = () => r.abort(t.signal?.reason);
|
|
807
812
|
t.signal?.aborted ? i() : t.signal?.addEventListener("abort", i, { once: !0 });
|
|
808
813
|
let a = globalThis.setTimeout(() => r.abort(new DOMException("Session endpoint timed out.", "TimeoutError")), t.timeoutMs ?? 3e4), o;
|
|
809
814
|
try {
|
|
@@ -816,9 +821,9 @@ async function Re(e, t) {
|
|
|
816
821
|
}
|
|
817
822
|
if (!o.ok) {
|
|
818
823
|
let e = await o.text();
|
|
819
|
-
throw
|
|
824
|
+
throw Se(o.status, e, o.headers);
|
|
820
825
|
}
|
|
821
|
-
if (!o.headers.get("content-type")?.toLowerCase().includes("application/json")) throw new
|
|
826
|
+
if (!o.headers.get("content-type")?.toLowerCase().includes("application/json")) throw new q("Session endpoint must return a JSON Session Launch response.", {
|
|
822
827
|
code: "INVALID_RESPONSE",
|
|
823
828
|
status: o.status,
|
|
824
829
|
requestId: o.headers.get("Liforma-Request-Id") ?? void 0
|
|
@@ -827,20 +832,20 @@ async function Re(e, t) {
|
|
|
827
832
|
try {
|
|
828
833
|
s = await o.json();
|
|
829
834
|
} catch {
|
|
830
|
-
throw new
|
|
835
|
+
throw new q("Session endpoint returned invalid JSON.", {
|
|
831
836
|
code: "INVALID_RESPONSE",
|
|
832
837
|
status: o.status,
|
|
833
838
|
requestId: o.headers.get("Liforma-Request-Id") ?? void 0
|
|
834
839
|
});
|
|
835
840
|
}
|
|
836
|
-
return
|
|
841
|
+
return je(s);
|
|
837
842
|
}
|
|
838
843
|
//#endregion
|
|
839
844
|
//#region src/v2/conversationProcessor.ts
|
|
840
|
-
function
|
|
845
|
+
function Be(e) {
|
|
841
846
|
return typeof e != "object" || !e ? !1 : typeof e[Symbol.asyncIterator] == "function";
|
|
842
847
|
}
|
|
843
|
-
function
|
|
848
|
+
function Ve(e) {
|
|
844
849
|
if (typeof e == "string") {
|
|
845
850
|
let t = e.trim();
|
|
846
851
|
if (!t) throw Error("conversationProcessor returned empty text.");
|
|
@@ -854,24 +859,24 @@ function Be(e) {
|
|
|
854
859
|
...e.behavior ? { behavior: e.behavior } : {}
|
|
855
860
|
};
|
|
856
861
|
}
|
|
857
|
-
async function
|
|
862
|
+
async function He(e, t) {
|
|
858
863
|
let n = await e(t);
|
|
859
|
-
return
|
|
864
|
+
return Be(n) ? {
|
|
860
865
|
kind: "stream",
|
|
861
866
|
stream: n
|
|
862
867
|
} : {
|
|
863
868
|
kind: "complete",
|
|
864
|
-
speech:
|
|
869
|
+
speech: Ve(n)
|
|
865
870
|
};
|
|
866
871
|
}
|
|
867
872
|
//#endregion
|
|
868
873
|
//#region src/v2/embed/playerReachability.ts
|
|
869
|
-
var
|
|
870
|
-
function
|
|
874
|
+
var Ue = "3002";
|
|
875
|
+
function We(e) {
|
|
871
876
|
let t = new URL(e);
|
|
872
|
-
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 ||
|
|
877
|
+
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 || Ue}. 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.`;
|
|
873
878
|
}
|
|
874
|
-
async function
|
|
879
|
+
async function Ge(e, t) {
|
|
875
880
|
try {
|
|
876
881
|
await fetch(e, {
|
|
877
882
|
method: "GET",
|
|
@@ -879,35 +884,39 @@ async function We(e, t) {
|
|
|
879
884
|
signal: AbortSignal.timeout(8e3)
|
|
880
885
|
});
|
|
881
886
|
} catch {
|
|
882
|
-
throw Error(
|
|
887
|
+
throw Error(We(t));
|
|
883
888
|
}
|
|
884
889
|
}
|
|
885
|
-
function
|
|
890
|
+
function Ke(e, t, n, r) {
|
|
886
891
|
try {
|
|
887
892
|
r && r.length > 0 ? e.postMessage(t, n, r) : e.postMessage(t, n);
|
|
888
893
|
} catch (e) {
|
|
889
|
-
throw e instanceof DOMException && e.name === "SecurityError" ? Error(
|
|
894
|
+
throw e instanceof DOMException && e.name === "SecurityError" ? Error(We(n), { cause: e }) : e;
|
|
890
895
|
}
|
|
891
896
|
}
|
|
892
|
-
var
|
|
893
|
-
function
|
|
894
|
-
return typeof e == "number" &&
|
|
897
|
+
var qe = new Set([1, 2]);
|
|
898
|
+
function Je(e) {
|
|
899
|
+
return typeof e == "number" && qe.has(e);
|
|
895
900
|
}
|
|
896
|
-
var
|
|
901
|
+
var Ye = new Set([
|
|
897
902
|
"close",
|
|
898
903
|
"stateUpdate",
|
|
899
904
|
"commandResult",
|
|
900
905
|
"userTranscript",
|
|
901
906
|
"characterSpeechStarted",
|
|
902
907
|
"characterSpeechEnded",
|
|
908
|
+
"characterFocusChanged",
|
|
903
909
|
"conversationUpdate",
|
|
904
910
|
"listeningState",
|
|
905
911
|
"userSpeechStarted",
|
|
906
912
|
"userSpeechEnded",
|
|
907
913
|
"modeChange",
|
|
908
914
|
"activityChange",
|
|
915
|
+
"feedback",
|
|
916
|
+
"feedbackFailed",
|
|
909
917
|
"message",
|
|
910
918
|
"started",
|
|
919
|
+
"embedReady",
|
|
911
920
|
"widgetReady",
|
|
912
921
|
"widgetExpand",
|
|
913
922
|
"widgetCollapse",
|
|
@@ -916,11 +925,11 @@ var Je = new Set([
|
|
|
916
925
|
"widgetDragMove",
|
|
917
926
|
"widgetDragEnd"
|
|
918
927
|
]);
|
|
919
|
-
function
|
|
928
|
+
function Xe(e) {
|
|
920
929
|
if (!e || typeof e != "object") return null;
|
|
921
930
|
let t = e;
|
|
922
|
-
if (!
|
|
923
|
-
if (t.type === "widgetReady" || t.type === "widgetExpand" || t.type === "widgetCollapse") return t;
|
|
931
|
+
if (!Je(t.schemaVersion) || !t.type || !Ye.has(t.type)) return null;
|
|
932
|
+
if (t.type === "embedReady" || t.type === "widgetReady" || t.type === "widgetExpand" || t.type === "widgetCollapse") return t;
|
|
924
933
|
if (t.type === "widgetAudioSettings") {
|
|
925
934
|
let e = t.payload;
|
|
926
935
|
return !e || typeof e != "object" || typeof e.open != "boolean" ? null : t;
|
|
@@ -935,35 +944,38 @@ function Ye(e) {
|
|
|
935
944
|
let { pointerId: n, dx: r, dy: i } = e;
|
|
936
945
|
return typeof n != "number" || !Number.isFinite(n) || typeof r != "number" || !Number.isFinite(r) || typeof i != "number" || !Number.isFinite(i) ? null : t;
|
|
937
946
|
}
|
|
938
|
-
|
|
947
|
+
let n = t.payload;
|
|
948
|
+
return !n || typeof n != "object" ? null : t;
|
|
939
949
|
}
|
|
940
|
-
function
|
|
950
|
+
function Ze(e, t, n) {
|
|
941
951
|
let r = e.trim();
|
|
942
952
|
if (!r) throw Error("createLaunchMessage requires a non-empty launch string.");
|
|
953
|
+
let i = n?.startButton, a = n?.showFeedback;
|
|
943
954
|
return {
|
|
944
955
|
type: "launch",
|
|
945
956
|
schemaVersion: 2,
|
|
946
957
|
payload: {
|
|
947
958
|
launch: r,
|
|
948
959
|
...t === void 0 ? {} : { session: t },
|
|
949
|
-
...
|
|
960
|
+
...i ? { startButton: i } : {},
|
|
961
|
+
...a === void 0 ? {} : { showFeedback: a }
|
|
950
962
|
}
|
|
951
963
|
};
|
|
952
964
|
}
|
|
953
|
-
function
|
|
965
|
+
function Qe() {
|
|
954
966
|
return {
|
|
955
967
|
type: "parentHello",
|
|
956
968
|
schemaVersion: 2
|
|
957
969
|
};
|
|
958
970
|
}
|
|
959
|
-
function
|
|
971
|
+
function $e(e) {
|
|
960
972
|
return {
|
|
961
973
|
type: "widgetSetChrome",
|
|
962
974
|
schemaVersion: 2,
|
|
963
975
|
payload: { mode: e }
|
|
964
976
|
};
|
|
965
977
|
}
|
|
966
|
-
function
|
|
978
|
+
function et() {
|
|
967
979
|
return {
|
|
968
980
|
type: "widgetToggleAudioSettings",
|
|
969
981
|
schemaVersion: 2,
|
|
@@ -972,30 +984,50 @@ function $e() {
|
|
|
972
984
|
}
|
|
973
985
|
//#endregion
|
|
974
986
|
//#region src/v2/embed/iframeHost.ts
|
|
975
|
-
function
|
|
987
|
+
function tt(e) {
|
|
976
988
|
return e;
|
|
977
989
|
}
|
|
978
990
|
function Z() {
|
|
979
991
|
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)}`;
|
|
980
992
|
}
|
|
981
|
-
var
|
|
982
|
-
function
|
|
993
|
+
var nt = 3e4;
|
|
994
|
+
function rt(e) {
|
|
983
995
|
let t = e.container;
|
|
984
996
|
getComputedStyle(t).position === "static" && (t.style.position = "relative");
|
|
985
997
|
let n = document.createElement("iframe");
|
|
986
998
|
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");
|
|
987
|
-
let r = !1, i = /* @__PURE__ */ new Map(), a = new Promise((
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
999
|
+
let r = !1, i = /* @__PURE__ */ new Map(), a = null, o = 0, s = 0, c = [], l = null, u = null, d = new Promise((e, t) => {
|
|
1000
|
+
l = e, u = t;
|
|
1001
|
+
}), f = () => {
|
|
1002
|
+
for (let e of c) window.clearTimeout(e);
|
|
1003
|
+
c.length = 0;
|
|
1004
|
+
}, p = (t) => {
|
|
1005
|
+
if (r) return;
|
|
1006
|
+
let i = Date.now();
|
|
1007
|
+
if (s > 0 && i - s < 250) return;
|
|
1008
|
+
s = i, f();
|
|
1009
|
+
let a = Ze(t.launch, t.session, t.chrome), o = () => {
|
|
1010
|
+
if (r) return;
|
|
1011
|
+
let t = n.contentWindow;
|
|
1012
|
+
t && Ke(t, a, e.playerOrigin);
|
|
994
1013
|
};
|
|
995
|
-
|
|
996
|
-
|
|
1014
|
+
o();
|
|
1015
|
+
for (let e = 1; e <= 12; e += 1) c.push(window.setTimeout(o, e * 75));
|
|
1016
|
+
}, m = () => {
|
|
1017
|
+
r || !a || p(a);
|
|
1018
|
+
}, h = () => {
|
|
1019
|
+
if (o += 1, o === 1) {
|
|
1020
|
+
Ge(e.src, e.playerOrigin).then(() => l?.(), (e) => u?.(e instanceof Error ? e : Error(String(e))));
|
|
1021
|
+
return;
|
|
1022
|
+
}
|
|
1023
|
+
s = 0, m();
|
|
1024
|
+
}, g = () => {
|
|
1025
|
+
o > 0 || u?.(Error(We(e.playerOrigin)));
|
|
1026
|
+
};
|
|
1027
|
+
n.addEventListener("load", h), n.addEventListener("error", g);
|
|
1028
|
+
let _ = (t) => {
|
|
997
1029
|
if (r || t.source !== n.contentWindow || t.origin !== e.playerOrigin) return;
|
|
998
|
-
let a =
|
|
1030
|
+
let a = Xe(t.data);
|
|
999
1031
|
if (a) switch (a.type) {
|
|
1000
1032
|
case "close":
|
|
1001
1033
|
e.onClose?.(a.payload);
|
|
@@ -1018,6 +1050,9 @@ function nt(e) {
|
|
|
1018
1050
|
case "characterSpeechEnded":
|
|
1019
1051
|
e.onCharacterSpeechEnded?.(a.payload);
|
|
1020
1052
|
break;
|
|
1053
|
+
case "characterFocusChanged":
|
|
1054
|
+
e.onCharacterFocusChanged?.(a.payload);
|
|
1055
|
+
break;
|
|
1021
1056
|
case "conversationUpdate":
|
|
1022
1057
|
e.onConversationUpdate?.(a.payload.conversation);
|
|
1023
1058
|
break;
|
|
@@ -1031,17 +1066,26 @@ function nt(e) {
|
|
|
1031
1066
|
e.onUserSpeechEnded?.(a.payload);
|
|
1032
1067
|
break;
|
|
1033
1068
|
case "modeChange":
|
|
1034
|
-
e.onActivityChange?.(
|
|
1069
|
+
e.onActivityChange?.(tt(a.payload.mode));
|
|
1035
1070
|
break;
|
|
1036
1071
|
case "activityChange":
|
|
1037
1072
|
e.onActivityChange?.(a.payload.activity);
|
|
1038
1073
|
break;
|
|
1074
|
+
case "feedback":
|
|
1075
|
+
e.onFeedback?.(a.payload);
|
|
1076
|
+
break;
|
|
1077
|
+
case "feedbackFailed":
|
|
1078
|
+
e.onFeedbackFailed?.(a.payload);
|
|
1079
|
+
break;
|
|
1039
1080
|
case "message":
|
|
1040
1081
|
e.onMessage?.(a.payload);
|
|
1041
1082
|
break;
|
|
1042
1083
|
case "started":
|
|
1043
1084
|
e.onStarted?.(a.payload);
|
|
1044
1085
|
break;
|
|
1086
|
+
case "embedReady":
|
|
1087
|
+
m();
|
|
1088
|
+
break;
|
|
1045
1089
|
case "widgetReady":
|
|
1046
1090
|
e.onWidgetReady?.();
|
|
1047
1091
|
break;
|
|
@@ -1065,42 +1109,39 @@ function nt(e) {
|
|
|
1065
1109
|
break;
|
|
1066
1110
|
}
|
|
1067
1111
|
};
|
|
1068
|
-
if (window.addEventListener("message",
|
|
1112
|
+
if (window.addEventListener("message", _), t.replaceChildren(n), t.clientHeight < 2 && !t.style.minHeight) {
|
|
1069
1113
|
let e = getComputedStyle(t).minHeight;
|
|
1070
1114
|
(e === "0px" || e === "auto") && (t.style.minHeight = "480px");
|
|
1071
1115
|
}
|
|
1072
|
-
let
|
|
1116
|
+
let v = (t, i) => {
|
|
1073
1117
|
if (r) return;
|
|
1074
1118
|
let a = n.contentWindow;
|
|
1075
|
-
if (!a) throw Error(
|
|
1076
|
-
|
|
1077
|
-
},
|
|
1119
|
+
if (!a) throw Error(We(e.playerOrigin));
|
|
1120
|
+
Ke(a, t, e.playerOrigin, i);
|
|
1121
|
+
}, y = (e, t = 12e4, n) => {
|
|
1078
1122
|
let r = e.type !== "parentHello" && e.payload && "correlationId" in e.payload ? e.payload.correlationId : Z();
|
|
1079
1123
|
return e.type !== "parentHello" && e.payload && "correlationId" in e.payload || e.type !== "parentHello" && e.payload && (e.payload.correlationId = r), new Promise((a, o) => {
|
|
1080
1124
|
i.set(r, {
|
|
1081
1125
|
resolve: (e) => a(e),
|
|
1082
1126
|
reject: o
|
|
1083
|
-
}),
|
|
1127
|
+
}), v(e, n), setTimeout(() => {
|
|
1084
1128
|
i.has(r) && (i.delete(r), o(/* @__PURE__ */ Error("Timed out waiting for player command result.")));
|
|
1085
1129
|
}, t);
|
|
1086
1130
|
});
|
|
1087
1131
|
};
|
|
1088
1132
|
return {
|
|
1089
1133
|
waitForLoad() {
|
|
1090
|
-
return
|
|
1134
|
+
return d;
|
|
1091
1135
|
},
|
|
1092
1136
|
postParentHello() {
|
|
1093
|
-
|
|
1137
|
+
v(Qe());
|
|
1094
1138
|
},
|
|
1095
|
-
postLaunch(
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
};
|
|
1102
|
-
c();
|
|
1103
|
-
for (let e = 1; e <= 12; e += 1) window.setTimeout(c, e * 75);
|
|
1139
|
+
postLaunch(e, t, n) {
|
|
1140
|
+
r || (a = {
|
|
1141
|
+
launch: e,
|
|
1142
|
+
session: t,
|
|
1143
|
+
chrome: n
|
|
1144
|
+
}, s = 0, p(a));
|
|
1104
1145
|
},
|
|
1105
1146
|
postManifest(e) {
|
|
1106
1147
|
if (typeof e == "string") {
|
|
@@ -1115,13 +1156,13 @@ function nt(e) {
|
|
|
1115
1156
|
throw Error("postManifest is deprecated; use postLaunch with an opaque launch string from SessionLaunchResponse.");
|
|
1116
1157
|
},
|
|
1117
1158
|
postWidgetSetChrome(e) {
|
|
1118
|
-
|
|
1159
|
+
v($e(e));
|
|
1119
1160
|
},
|
|
1120
1161
|
postWidgetToggleAudioSettings() {
|
|
1121
|
-
|
|
1162
|
+
v(et());
|
|
1122
1163
|
},
|
|
1123
1164
|
speak(e) {
|
|
1124
|
-
return
|
|
1165
|
+
return y({
|
|
1125
1166
|
type: "speak",
|
|
1126
1167
|
schemaVersion: 2,
|
|
1127
1168
|
payload: {
|
|
@@ -1133,21 +1174,21 @@ function nt(e) {
|
|
|
1133
1174
|
});
|
|
1134
1175
|
},
|
|
1135
1176
|
startListening() {
|
|
1136
|
-
return
|
|
1177
|
+
return y({
|
|
1137
1178
|
type: "startListening",
|
|
1138
1179
|
schemaVersion: 2,
|
|
1139
1180
|
payload: { correlationId: Z() }
|
|
1140
1181
|
});
|
|
1141
1182
|
},
|
|
1142
1183
|
stopListening() {
|
|
1143
|
-
return
|
|
1184
|
+
return y({
|
|
1144
1185
|
type: "stopListening",
|
|
1145
1186
|
schemaVersion: 2,
|
|
1146
1187
|
payload: { correlationId: Z() }
|
|
1147
1188
|
});
|
|
1148
1189
|
},
|
|
1149
1190
|
listenOnce(e) {
|
|
1150
|
-
return
|
|
1191
|
+
return y({
|
|
1151
1192
|
type: "listenOnce",
|
|
1152
1193
|
schemaVersion: 2,
|
|
1153
1194
|
payload: {
|
|
@@ -1157,7 +1198,7 @@ function nt(e) {
|
|
|
1157
1198
|
});
|
|
1158
1199
|
},
|
|
1159
1200
|
async speakProcessorStream(e, t) {
|
|
1160
|
-
let n = Z(), r = Z(), i = (await
|
|
1201
|
+
let n = Z(), r = Z(), i = (await y({
|
|
1161
1202
|
type: "speakStreamStart",
|
|
1162
1203
|
schemaVersion: 2,
|
|
1163
1204
|
payload: {
|
|
@@ -1169,7 +1210,7 @@ function nt(e) {
|
|
|
1169
1210
|
try {
|
|
1170
1211
|
for await (let n of e) {
|
|
1171
1212
|
if (t?.signal?.aborted) throw new DOMException("Processor stream aborted.", "AbortError");
|
|
1172
|
-
n &&
|
|
1213
|
+
n && v({
|
|
1173
1214
|
type: "speakStreamChunk",
|
|
1174
1215
|
schemaVersion: 2,
|
|
1175
1216
|
payload: {
|
|
@@ -1179,7 +1220,7 @@ function nt(e) {
|
|
|
1179
1220
|
});
|
|
1180
1221
|
}
|
|
1181
1222
|
if (t?.signal?.aborted) throw new DOMException("Processor stream aborted.", "AbortError");
|
|
1182
|
-
return await
|
|
1223
|
+
return await y({
|
|
1183
1224
|
type: "speakStreamEnd",
|
|
1184
1225
|
schemaVersion: 2,
|
|
1185
1226
|
payload: {
|
|
@@ -1189,7 +1230,7 @@ function nt(e) {
|
|
|
1189
1230
|
});
|
|
1190
1231
|
} catch (e) {
|
|
1191
1232
|
try {
|
|
1192
|
-
await
|
|
1233
|
+
await y({
|
|
1193
1234
|
type: "speakStreamEnd",
|
|
1194
1235
|
schemaVersion: 2,
|
|
1195
1236
|
payload: {
|
|
@@ -1203,7 +1244,7 @@ function nt(e) {
|
|
|
1203
1244
|
},
|
|
1204
1245
|
speechPlay(e) {
|
|
1205
1246
|
let t = Z(), n = [];
|
|
1206
|
-
return (e.source.kind === "pcm" || e.source.kind === "encoded") && n.push(e.source.data),
|
|
1247
|
+
return (e.source.kind === "pcm" || e.source.kind === "encoded") && n.push(e.source.data), y({
|
|
1207
1248
|
type: "speechPlay",
|
|
1208
1249
|
schemaVersion: 2,
|
|
1209
1250
|
payload: {
|
|
@@ -1217,7 +1258,7 @@ function nt(e) {
|
|
|
1217
1258
|
}, 12e4, n);
|
|
1218
1259
|
},
|
|
1219
1260
|
speechUtteranceBegin(e) {
|
|
1220
|
-
return
|
|
1261
|
+
return y({
|
|
1221
1262
|
type: "speechUtteranceBegin",
|
|
1222
1263
|
schemaVersion: 2,
|
|
1223
1264
|
payload: {
|
|
@@ -1231,7 +1272,7 @@ function nt(e) {
|
|
|
1231
1272
|
});
|
|
1232
1273
|
},
|
|
1233
1274
|
speechUtteranceWrite(e) {
|
|
1234
|
-
return
|
|
1275
|
+
return y({
|
|
1235
1276
|
type: "speechUtteranceWrite",
|
|
1236
1277
|
schemaVersion: 2,
|
|
1237
1278
|
payload: {
|
|
@@ -1240,10 +1281,10 @@ function nt(e) {
|
|
|
1240
1281
|
audio: e.audio,
|
|
1241
1282
|
byteLength: e.byteLength
|
|
1242
1283
|
}
|
|
1243
|
-
},
|
|
1284
|
+
}, nt, [e.audio]);
|
|
1244
1285
|
},
|
|
1245
1286
|
speechUtteranceSetTranscript(e) {
|
|
1246
|
-
return
|
|
1287
|
+
return y({
|
|
1247
1288
|
type: "speechUtteranceSetTranscript",
|
|
1248
1289
|
schemaVersion: 2,
|
|
1249
1290
|
payload: {
|
|
@@ -1254,7 +1295,7 @@ function nt(e) {
|
|
|
1254
1295
|
});
|
|
1255
1296
|
},
|
|
1256
1297
|
speechUtteranceClose(e) {
|
|
1257
|
-
return
|
|
1298
|
+
return y({
|
|
1258
1299
|
type: "speechUtteranceClose",
|
|
1259
1300
|
schemaVersion: 2,
|
|
1260
1301
|
payload: {
|
|
@@ -1266,7 +1307,7 @@ function nt(e) {
|
|
|
1266
1307
|
});
|
|
1267
1308
|
},
|
|
1268
1309
|
speechUtteranceCancel(e) {
|
|
1269
|
-
return
|
|
1310
|
+
return y({
|
|
1270
1311
|
type: "speechUtteranceCancel",
|
|
1271
1312
|
schemaVersion: 2,
|
|
1272
1313
|
payload: {
|
|
@@ -1276,7 +1317,7 @@ function nt(e) {
|
|
|
1276
1317
|
});
|
|
1277
1318
|
},
|
|
1278
1319
|
speechInterrupt(e) {
|
|
1279
|
-
return
|
|
1320
|
+
return y({
|
|
1280
1321
|
type: "speechInterrupt",
|
|
1281
1322
|
schemaVersion: 2,
|
|
1282
1323
|
payload: {
|
|
@@ -1286,24 +1327,44 @@ function nt(e) {
|
|
|
1286
1327
|
});
|
|
1287
1328
|
},
|
|
1288
1329
|
getConversation() {
|
|
1289
|
-
return
|
|
1330
|
+
return y({
|
|
1290
1331
|
type: "getConversation",
|
|
1291
1332
|
schemaVersion: 2,
|
|
1292
1333
|
payload: { correlationId: Z() }
|
|
1293
1334
|
});
|
|
1294
1335
|
},
|
|
1336
|
+
focusCharacter(e) {
|
|
1337
|
+
return y({
|
|
1338
|
+
type: "focusCharacter",
|
|
1339
|
+
schemaVersion: 2,
|
|
1340
|
+
payload: {
|
|
1341
|
+
correlationId: Z(),
|
|
1342
|
+
characterId: e
|
|
1343
|
+
}
|
|
1344
|
+
});
|
|
1345
|
+
},
|
|
1346
|
+
setFit(e) {
|
|
1347
|
+
return y({
|
|
1348
|
+
type: "setFit",
|
|
1349
|
+
schemaVersion: 2,
|
|
1350
|
+
payload: {
|
|
1351
|
+
correlationId: Z(),
|
|
1352
|
+
fit: e
|
|
1353
|
+
}
|
|
1354
|
+
});
|
|
1355
|
+
},
|
|
1295
1356
|
destroy() {
|
|
1296
1357
|
if (!r) {
|
|
1297
1358
|
r = !0;
|
|
1298
1359
|
for (let e of i.values()) e.reject(/* @__PURE__ */ Error("Iframe host destroyed."));
|
|
1299
|
-
i.clear(), window.removeEventListener("message",
|
|
1360
|
+
i.clear(), f(), a = null, n.removeEventListener("load", h), n.removeEventListener("error", g), window.removeEventListener("message", _), n.remove();
|
|
1300
1361
|
}
|
|
1301
1362
|
}
|
|
1302
1363
|
};
|
|
1303
1364
|
}
|
|
1304
1365
|
//#endregion
|
|
1305
1366
|
//#region src/v2/embed/readyGate.ts
|
|
1306
|
-
function
|
|
1367
|
+
function it(e) {
|
|
1307
1368
|
let t, n = !1, r = !1, i = () => {
|
|
1308
1369
|
r || !n || t === void 0 || (r = !0, e(t));
|
|
1309
1370
|
};
|
|
@@ -1318,47 +1379,50 @@ function rt(e) {
|
|
|
1318
1379
|
}
|
|
1319
1380
|
//#endregion
|
|
1320
1381
|
//#region src/v2/shims/embedBaseUrl.ts
|
|
1321
|
-
var
|
|
1322
|
-
function
|
|
1382
|
+
var at = "https://player.liforma.ai/embed", ot = "http://localhost:3002/embed";
|
|
1383
|
+
function st() {
|
|
1323
1384
|
let e = globalThis.__LIFORMA_PLAYER_EMBED_URL;
|
|
1324
1385
|
if (e?.trim()) return e.trim().replace(/\/$/, "");
|
|
1325
1386
|
if (typeof document > "u") return null;
|
|
1326
1387
|
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();
|
|
1327
1388
|
return t ? t.replace(/\/$/, "") : null;
|
|
1328
1389
|
}
|
|
1329
|
-
function
|
|
1330
|
-
let e =
|
|
1331
|
-
return e ? e.endsWith("/embed") ? e : `${e}/embed` :
|
|
1390
|
+
function ct() {
|
|
1391
|
+
let e = st();
|
|
1392
|
+
return e ? e.endsWith("/embed") ? e : `${e}/embed` : T() ? ot : at;
|
|
1393
|
+
}
|
|
1394
|
+
function lt(e, t) {
|
|
1395
|
+
return e?.trim() || t?.trim() || void 0;
|
|
1332
1396
|
}
|
|
1333
|
-
function
|
|
1334
|
-
let
|
|
1335
|
-
|
|
1336
|
-
let
|
|
1337
|
-
return
|
|
1397
|
+
function ut(e, t, n, r, i, a, o, s) {
|
|
1398
|
+
let c = (e ?? ct()).replace(/\/$/, ""), l = c.endsWith("/embed") ? c : `${c}/embed`, u = new URL(l), d = n?.trim();
|
|
1399
|
+
d && (u.searchParams.set("backdropId", d), u.searchParams.set("locationId", d));
|
|
1400
|
+
let f = r?.trim();
|
|
1401
|
+
return f && u.searchParams.set("avatarId", f), (i === "face" || i === "medium") && u.searchParams.set("fit", i), a === "widget" && u.searchParams.set("ui", "widget"), o && u.searchParams.set("close", "1"), t && u.searchParams.set("debug", "true"), (s === 2 || s === 3 || s === 4) && u.searchParams.set("cast", String(s)), dt(u.toString());
|
|
1338
1402
|
}
|
|
1339
|
-
function
|
|
1403
|
+
function dt(e) {
|
|
1340
1404
|
if (typeof location > "u") return e;
|
|
1341
1405
|
let t = new URL(e);
|
|
1342
1406
|
return t.searchParams.set("parentOrigin", location.origin), t.toString();
|
|
1343
1407
|
}
|
|
1344
|
-
function
|
|
1408
|
+
function ft(e) {
|
|
1345
1409
|
return new URL(e).origin;
|
|
1346
1410
|
}
|
|
1347
1411
|
//#endregion
|
|
1348
1412
|
//#region src/v2/experienceEvents.ts
|
|
1349
|
-
function
|
|
1413
|
+
function pt() {
|
|
1350
1414
|
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)}`;
|
|
1351
1415
|
}
|
|
1352
|
-
function
|
|
1416
|
+
function mt(e, t, n) {
|
|
1353
1417
|
return {
|
|
1354
|
-
id:
|
|
1418
|
+
id: pt(),
|
|
1355
1419
|
type: e,
|
|
1356
1420
|
sessionId: t,
|
|
1357
1421
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1358
1422
|
data: n
|
|
1359
1423
|
};
|
|
1360
1424
|
}
|
|
1361
|
-
function
|
|
1425
|
+
function ht() {
|
|
1362
1426
|
return {
|
|
1363
1427
|
ready: /* @__PURE__ */ new Set(),
|
|
1364
1428
|
started: /* @__PURE__ */ new Set(),
|
|
@@ -1367,46 +1431,49 @@ function pt() {
|
|
|
1367
1431
|
userSpeechEnded: /* @__PURE__ */ new Set(),
|
|
1368
1432
|
characterSpeechStarted: /* @__PURE__ */ new Set(),
|
|
1369
1433
|
characterSpeechEnded: /* @__PURE__ */ new Set(),
|
|
1434
|
+
characterFocusChanged: /* @__PURE__ */ new Set(),
|
|
1370
1435
|
conversationUpdate: /* @__PURE__ */ new Set(),
|
|
1371
1436
|
message: /* @__PURE__ */ new Set(),
|
|
1372
1437
|
listeningState: /* @__PURE__ */ new Set(),
|
|
1373
1438
|
activityChange: /* @__PURE__ */ new Set(),
|
|
1439
|
+
feedback: /* @__PURE__ */ new Set(),
|
|
1440
|
+
feedbackFailed: /* @__PURE__ */ new Set(),
|
|
1374
1441
|
conversationProcessorError: /* @__PURE__ */ new Set()
|
|
1375
1442
|
};
|
|
1376
1443
|
}
|
|
1377
|
-
function
|
|
1444
|
+
function gt(e, t, n) {
|
|
1378
1445
|
return e[t].add(n), () => e[t].delete(n);
|
|
1379
1446
|
}
|
|
1380
|
-
function
|
|
1447
|
+
function _t(e, t, n) {
|
|
1381
1448
|
for (let r of e[t]) r(n);
|
|
1382
1449
|
}
|
|
1383
|
-
function
|
|
1450
|
+
function vt(e) {
|
|
1384
1451
|
for (let t of Object.keys(e)) e[t].clear();
|
|
1385
1452
|
}
|
|
1386
1453
|
//#endregion
|
|
1387
1454
|
//#region src/v2/speech/types.ts
|
|
1388
|
-
function
|
|
1455
|
+
function yt(e) {
|
|
1389
1456
|
return "data" in e && "format" in e && e.format != null && !("track" in e);
|
|
1390
1457
|
}
|
|
1391
|
-
function
|
|
1458
|
+
function bt(e) {
|
|
1392
1459
|
return "url" in e && typeof e.url == "string";
|
|
1393
1460
|
}
|
|
1394
|
-
function
|
|
1461
|
+
function xt(e) {
|
|
1395
1462
|
if (!("track" in e)) return !1;
|
|
1396
1463
|
let t = e.track;
|
|
1397
1464
|
return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
|
|
1398
1465
|
}
|
|
1399
|
-
function
|
|
1400
|
-
return !
|
|
1466
|
+
function St(e) {
|
|
1467
|
+
return !yt(e) && !bt(e) && !xt(e) && "encoding" in e && typeof e.encoding == "string";
|
|
1401
1468
|
}
|
|
1402
|
-
var
|
|
1469
|
+
var Ct = [
|
|
1403
1470
|
8e3,
|
|
1404
1471
|
16e3,
|
|
1405
1472
|
22050,
|
|
1406
1473
|
24e3,
|
|
1407
1474
|
44100,
|
|
1408
1475
|
48e3
|
|
1409
|
-
],
|
|
1476
|
+
], wt = {
|
|
1410
1477
|
MAX_CHUNK_BYTES: 64 * 1024,
|
|
1411
1478
|
RECOMMENDED_CHUNK_MS_MIN: 20,
|
|
1412
1479
|
RECOMMENDED_CHUNK_MS_MAX: 200,
|
|
@@ -1417,14 +1484,14 @@ var xt = [
|
|
|
1417
1484
|
MAX_UTTERANCE_DURATION_MS: 9e4,
|
|
1418
1485
|
MAX_PENDING_WRITES: 8,
|
|
1419
1486
|
DEFAULT_WRITE_TIMEOUT_MS: 5e3
|
|
1420
|
-
},
|
|
1487
|
+
}, Tt = class extends Error {
|
|
1421
1488
|
operation;
|
|
1422
1489
|
requiredCapability;
|
|
1423
1490
|
name = "UnsupportedSpeechOperationError";
|
|
1424
1491
|
constructor(e, t) {
|
|
1425
1492
|
super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
|
|
1426
1493
|
}
|
|
1427
|
-
},
|
|
1494
|
+
}, Et = class extends Error {
|
|
1428
1495
|
name = "SpeechUtteranceClosedError";
|
|
1429
1496
|
constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
|
|
1430
1497
|
super(e);
|
|
@@ -1434,72 +1501,72 @@ var xt = [
|
|
|
1434
1501
|
constructor(e, t) {
|
|
1435
1502
|
super(e, t);
|
|
1436
1503
|
}
|
|
1437
|
-
},
|
|
1504
|
+
}, Dt = class extends Error {
|
|
1438
1505
|
name = "SpeechBufferTimeoutError";
|
|
1439
1506
|
constructor(e = "Timed out waiting for speech buffer capacity.") {
|
|
1440
1507
|
super(e);
|
|
1441
1508
|
}
|
|
1442
1509
|
};
|
|
1443
|
-
function
|
|
1510
|
+
function Ot(e = "none") {
|
|
1444
1511
|
return {
|
|
1445
1512
|
mode: e,
|
|
1446
1513
|
trackedDurationMs: 0,
|
|
1447
1514
|
fallbackDurationMs: 0
|
|
1448
1515
|
};
|
|
1449
1516
|
}
|
|
1450
|
-
function
|
|
1451
|
-
return
|
|
1517
|
+
function kt(e) {
|
|
1518
|
+
return Ct.includes(e);
|
|
1452
1519
|
}
|
|
1453
|
-
function
|
|
1520
|
+
function At(e) {
|
|
1454
1521
|
if (e.encoding !== "pcm_s16le") throw new Q(`Unsupported audio encoding: ${e.encoding}`);
|
|
1455
1522
|
if (e.channels !== 1) throw new Q(`Unsupported channel count: ${e.channels}`);
|
|
1456
|
-
if (!
|
|
1523
|
+
if (!kt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1457
1524
|
}
|
|
1458
|
-
function
|
|
1459
|
-
if (
|
|
1460
|
-
|
|
1525
|
+
function jt(e) {
|
|
1526
|
+
if (yt(e)) {
|
|
1527
|
+
At(e.format);
|
|
1461
1528
|
return;
|
|
1462
1529
|
}
|
|
1463
|
-
if (
|
|
1530
|
+
if (bt(e)) {
|
|
1464
1531
|
if (!e.url.trim()) throw new Q("Audio URL must be non-empty.");
|
|
1465
|
-
if (e.sampleRate !== void 0 && !
|
|
1532
|
+
if (e.sampleRate !== void 0 && !kt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1466
1533
|
return;
|
|
1467
1534
|
}
|
|
1468
|
-
if (
|
|
1535
|
+
if (xt(e)) {
|
|
1469
1536
|
if (e.track.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
1470
|
-
if (e.sampleRate !== void 0 && !
|
|
1537
|
+
if (e.sampleRate !== void 0 && !kt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1471
1538
|
return;
|
|
1472
1539
|
}
|
|
1473
|
-
if (
|
|
1540
|
+
if (St(e)) {
|
|
1474
1541
|
let t = e.encoding.trim().toLowerCase();
|
|
1475
1542
|
if (!t) throw new Q("Encoded audio MIME type is required.");
|
|
1476
1543
|
if (t === "pcm_s16le") throw new Q("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
|
|
1477
|
-
if (e.sampleRate !== void 0 && !
|
|
1544
|
+
if (e.sampleRate !== void 0 && !kt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1478
1545
|
return;
|
|
1479
1546
|
}
|
|
1480
1547
|
throw new Q("Unsupported speech.play audio shape.");
|
|
1481
1548
|
}
|
|
1482
|
-
function
|
|
1483
|
-
if (e.format) return
|
|
1549
|
+
function Mt(e) {
|
|
1550
|
+
if (e.format) return At(e.format), e.format;
|
|
1484
1551
|
if (e.track) {
|
|
1485
1552
|
let t = {
|
|
1486
1553
|
encoding: "pcm_s16le",
|
|
1487
1554
|
sampleRate: e.sampleRate ?? 24e3,
|
|
1488
1555
|
channels: 1
|
|
1489
1556
|
};
|
|
1490
|
-
return
|
|
1557
|
+
return At(t), t;
|
|
1491
1558
|
}
|
|
1492
1559
|
throw new Q("createUtterance requires format or track.");
|
|
1493
1560
|
}
|
|
1494
|
-
function
|
|
1561
|
+
function Nt(e) {
|
|
1495
1562
|
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1496
1563
|
}
|
|
1497
|
-
function
|
|
1564
|
+
function Pt(e) {
|
|
1498
1565
|
return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
|
|
1499
1566
|
}
|
|
1500
1567
|
//#endregion
|
|
1501
1568
|
//#region src/byo/pcm.ts
|
|
1502
|
-
function
|
|
1569
|
+
function Ft(e) {
|
|
1503
1570
|
let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
|
|
1504
1571
|
for (let t = 0; t < e.length; t++) {
|
|
1505
1572
|
let r = Math.max(-1, Math.min(1, e[t]));
|
|
@@ -1509,11 +1576,11 @@ function Nt(e) {
|
|
|
1509
1576
|
}
|
|
1510
1577
|
//#endregion
|
|
1511
1578
|
//#region src/byo/resample.ts
|
|
1512
|
-
function
|
|
1579
|
+
function It(e, t, n, r, i) {
|
|
1513
1580
|
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;
|
|
1514
1581
|
return ((a * i + o) * i + s) * i + c;
|
|
1515
1582
|
}
|
|
1516
|
-
function
|
|
1583
|
+
function Lt(e, t) {
|
|
1517
1584
|
if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
|
|
1518
1585
|
if (e === t) return {
|
|
1519
1586
|
fromRate: e,
|
|
@@ -1536,7 +1603,7 @@ function Ft(e, t) {
|
|
|
1536
1603
|
let a = [];
|
|
1537
1604
|
for (; i + 2 < r.length - 1;) {
|
|
1538
1605
|
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);
|
|
1539
|
-
a.push(
|
|
1606
|
+
a.push(It(r[o], r[e], r[s], r[c], t)), i += n;
|
|
1540
1607
|
}
|
|
1541
1608
|
let o = Math.max(0, Math.floor(i) - 1);
|
|
1542
1609
|
return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
|
|
@@ -1548,7 +1615,7 @@ function Ft(e, t) {
|
|
|
1548
1615
|
}
|
|
1549
1616
|
//#endregion
|
|
1550
1617
|
//#region src/byo/audioCapture.ts
|
|
1551
|
-
var
|
|
1618
|
+
var Rt = "liforma-pcm-capture", zt = `
|
|
1552
1619
|
class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
1553
1620
|
process(inputs) {
|
|
1554
1621
|
const ch = inputs[0] && inputs[0][0];
|
|
@@ -1560,29 +1627,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
|
1560
1627
|
return true;
|
|
1561
1628
|
}
|
|
1562
1629
|
}
|
|
1563
|
-
registerProcessor('${
|
|
1564
|
-
`,
|
|
1565
|
-
function
|
|
1566
|
-
return
|
|
1630
|
+
registerProcessor('${Rt}', LiformaPcmCaptureProcessor);
|
|
1631
|
+
`, Bt = null;
|
|
1632
|
+
function Vt() {
|
|
1633
|
+
return Bt ||= URL.createObjectURL(new Blob([zt], { type: "application/javascript" })), Bt;
|
|
1567
1634
|
}
|
|
1568
|
-
function
|
|
1635
|
+
function Ht() {
|
|
1569
1636
|
return window.AudioContext || window.webkitAudioContext || null;
|
|
1570
1637
|
}
|
|
1571
|
-
async function
|
|
1572
|
-
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o =
|
|
1638
|
+
async function Ut(e) {
|
|
1639
|
+
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = Ht();
|
|
1573
1640
|
if (!o) throw Error("Web Audio is required for audio capture");
|
|
1574
1641
|
let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
|
|
1575
1642
|
l.gain.value = 0;
|
|
1576
|
-
let u = s.sampleRate, d =
|
|
1643
|
+
let u = s.sampleRate, d = Lt(u, n), f = !1, p = !1, m = (e) => {
|
|
1577
1644
|
if (f || i && !i()) return;
|
|
1578
1645
|
let t = d.push(e);
|
|
1579
|
-
t.length !== 0 && r(
|
|
1646
|
+
t.length !== 0 && r(Ft(t));
|
|
1580
1647
|
}, h = () => void 0;
|
|
1581
1648
|
return await (async () => {
|
|
1582
1649
|
if (typeof s.audioWorklet?.addModule != "function") return !1;
|
|
1583
1650
|
try {
|
|
1584
|
-
await s.audioWorklet.addModule(
|
|
1585
|
-
let e = new AudioWorkletNode(s,
|
|
1651
|
+
await s.audioWorklet.addModule(Vt());
|
|
1652
|
+
let e = new AudioWorkletNode(s, Rt, {
|
|
1586
1653
|
numberOfInputs: 1,
|
|
1587
1654
|
numberOfOutputs: 1,
|
|
1588
1655
|
outputChannelCount: [1]
|
|
@@ -1632,7 +1699,7 @@ async function Vt(e) {
|
|
|
1632
1699
|
}
|
|
1633
1700
|
//#endregion
|
|
1634
1701
|
//#region src/v2/speech/captureMediaStreamTrack.ts
|
|
1635
|
-
async function
|
|
1702
|
+
async function Wt(e) {
|
|
1636
1703
|
let { track: t, utterance: n, sampleRate: r, signal: i } = e;
|
|
1637
1704
|
if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Q("MediaStreamTrack is not available in this environment.");
|
|
1638
1705
|
if (t.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
@@ -1641,18 +1708,18 @@ async function Ht(e) {
|
|
|
1641
1708
|
s || (s = !0, c?.stop(), c = null);
|
|
1642
1709
|
};
|
|
1643
1710
|
try {
|
|
1644
|
-
c = await
|
|
1711
|
+
c = await Ut({
|
|
1645
1712
|
mediaStream: a,
|
|
1646
1713
|
targetSampleRate: r,
|
|
1647
1714
|
shouldSend: () => !s && !i?.aborted,
|
|
1648
1715
|
onPcm: (e) => {
|
|
1649
1716
|
if (s || i?.aborted) return;
|
|
1650
|
-
let t =
|
|
1717
|
+
let t = Nt(e);
|
|
1651
1718
|
o = o.then(async () => {
|
|
1652
1719
|
if (s || i?.aborted) return;
|
|
1653
1720
|
let e = 0;
|
|
1654
1721
|
for (; e < t.byteLength;) {
|
|
1655
|
-
let r = Math.min(e +
|
|
1722
|
+
let r = Math.min(e + wt.MAX_CHUNK_BYTES, t.byteLength);
|
|
1656
1723
|
if ((r - e) % 2 == 1 && --r, r <= e) break;
|
|
1657
1724
|
let i = t.subarray(e, r);
|
|
1658
1725
|
e = r, i.byteLength !== 0 && await n.write(i);
|
|
@@ -1676,10 +1743,10 @@ async function Ht(e) {
|
|
|
1676
1743
|
}
|
|
1677
1744
|
//#endregion
|
|
1678
1745
|
//#region src/v2/speech/speechController.ts
|
|
1679
|
-
async function
|
|
1680
|
-
if (
|
|
1681
|
-
if (
|
|
1682
|
-
let t =
|
|
1746
|
+
async function Gt(e, t) {
|
|
1747
|
+
if (xt(e)) throw new Q("MediaStreamTrack play is handled on the host before embed.");
|
|
1748
|
+
if (yt(e)) {
|
|
1749
|
+
let t = Nt(e.data);
|
|
1683
1750
|
if (t.byteLength & 1) throw new Q("PCM byte length must be even.");
|
|
1684
1751
|
return {
|
|
1685
1752
|
kind: "pcm",
|
|
@@ -1687,17 +1754,17 @@ async function Ut(e, t) {
|
|
|
1687
1754
|
format: e.format
|
|
1688
1755
|
};
|
|
1689
1756
|
}
|
|
1690
|
-
if (
|
|
1757
|
+
if (bt(e)) return {
|
|
1691
1758
|
kind: "url",
|
|
1692
1759
|
url: e.url.trim(),
|
|
1693
1760
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
1694
1761
|
};
|
|
1695
|
-
if (!
|
|
1762
|
+
if (!St(e)) throw new Q("Unsupported speech.play audio shape.");
|
|
1696
1763
|
let n;
|
|
1697
1764
|
if (typeof Blob < "u" && e.data instanceof Blob) {
|
|
1698
1765
|
if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
1699
1766
|
n = new Uint8Array(await e.data.arrayBuffer());
|
|
1700
|
-
} else n =
|
|
1767
|
+
} else n = Nt(e.data);
|
|
1701
1768
|
return {
|
|
1702
1769
|
kind: "encoded",
|
|
1703
1770
|
data: n.slice().buffer,
|
|
@@ -1705,10 +1772,10 @@ async function Ut(e, t) {
|
|
|
1705
1772
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
1706
1773
|
};
|
|
1707
1774
|
}
|
|
1708
|
-
function
|
|
1775
|
+
function Kt() {
|
|
1709
1776
|
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)}`;
|
|
1710
1777
|
}
|
|
1711
|
-
function
|
|
1778
|
+
function qt(e, t = "completed") {
|
|
1712
1779
|
return {
|
|
1713
1780
|
utteranceId: e.speechId,
|
|
1714
1781
|
characterId: e.characterId,
|
|
@@ -1722,13 +1789,13 @@ function Gt(e, t = "completed") {
|
|
|
1722
1789
|
}
|
|
1723
1790
|
};
|
|
1724
1791
|
}
|
|
1725
|
-
function
|
|
1792
|
+
function Jt(e) {
|
|
1726
1793
|
return e instanceof Error ? e : new Q(String(e));
|
|
1727
1794
|
}
|
|
1728
|
-
function
|
|
1795
|
+
function Yt(e) {
|
|
1729
1796
|
return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
|
|
1730
1797
|
}
|
|
1731
|
-
var
|
|
1798
|
+
var Xt = class {
|
|
1732
1799
|
id;
|
|
1733
1800
|
characterId;
|
|
1734
1801
|
result;
|
|
@@ -1757,29 +1824,29 @@ var Jt = class {
|
|
|
1757
1824
|
queue: e.queue,
|
|
1758
1825
|
...e.transcript === void 0 ? {} : { transcript: e.transcript }
|
|
1759
1826
|
}).catch((e) => {
|
|
1760
|
-
throw this.fail(
|
|
1827
|
+
throw this.fail(Jt(e)), Jt(e);
|
|
1761
1828
|
}), this.signal?.addEventListener("abort", () => {
|
|
1762
1829
|
this.cancel();
|
|
1763
1830
|
}, { once: !0 });
|
|
1764
1831
|
}
|
|
1765
1832
|
async write(e, t) {
|
|
1766
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
1767
|
-
let n =
|
|
1833
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new Et();
|
|
1834
|
+
let n = Nt(e);
|
|
1768
1835
|
if (n.byteLength & 1) throw new Q("PCM chunk byte length must be even (complete s16 samples).");
|
|
1769
|
-
if (n.byteLength >
|
|
1836
|
+
if (n.byteLength > wt.MAX_CHUNK_BYTES) throw new Q(`PCM chunk exceeds MAX_CHUNK_BYTES (${wt.MAX_CHUNK_BYTES}).`);
|
|
1770
1837
|
if (n.byteLength === 0) return;
|
|
1771
|
-
let r = t?.timeoutMs ??
|
|
1838
|
+
let r = t?.timeoutMs ?? wt.DEFAULT_WRITE_TIMEOUT_MS;
|
|
1772
1839
|
await this.acquireWriteSlot(r);
|
|
1773
1840
|
let i = n.byteLength / 2 / this.sampleRate * 1e3;
|
|
1774
|
-
if (this.bufferedMs + i >
|
|
1841
|
+
if (this.bufferedMs + i > wt.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new Q("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
|
|
1775
1842
|
let a = async () => {
|
|
1776
|
-
if (this.closed || this.settled) throw new
|
|
1843
|
+
if (this.closed || this.settled) throw new Et();
|
|
1777
1844
|
let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
|
|
1778
1845
|
utteranceId: this.id,
|
|
1779
1846
|
audio: t.buffer,
|
|
1780
1847
|
byteLength: t.byteLength
|
|
1781
1848
|
}), a = await Promise.race([i, new Promise((e, t) => {
|
|
1782
|
-
setTimeout(() => t(new
|
|
1849
|
+
setTimeout(() => t(new Dt()), r);
|
|
1783
1850
|
})]);
|
|
1784
1851
|
this.bufferedMs = Math.max(0, a.bufferedMs);
|
|
1785
1852
|
}, o = this.writeChain.then(a, a);
|
|
@@ -1791,7 +1858,7 @@ var Jt = class {
|
|
|
1791
1858
|
}
|
|
1792
1859
|
}
|
|
1793
1860
|
async setTranscript(e) {
|
|
1794
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
1861
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new Et();
|
|
1795
1862
|
await this.requireHost().speechUtteranceSetTranscript({
|
|
1796
1863
|
utteranceId: this.id,
|
|
1797
1864
|
transcript: e
|
|
@@ -1808,7 +1875,7 @@ var Jt = class {
|
|
|
1808
1875
|
});
|
|
1809
1876
|
return this.resolve(t), t;
|
|
1810
1877
|
} catch (e) {
|
|
1811
|
-
let t =
|
|
1878
|
+
let t = Jt(e);
|
|
1812
1879
|
throw this.fail(t), t;
|
|
1813
1880
|
}
|
|
1814
1881
|
}
|
|
@@ -1826,11 +1893,11 @@ var Jt = class {
|
|
|
1826
1893
|
characterId: this.characterId,
|
|
1827
1894
|
status: "cancelled",
|
|
1828
1895
|
durationMs: 0,
|
|
1829
|
-
animation:
|
|
1896
|
+
animation: Ot("none")
|
|
1830
1897
|
};
|
|
1831
1898
|
return this.resolve(t), t;
|
|
1832
1899
|
} catch (e) {
|
|
1833
|
-
let t =
|
|
1900
|
+
let t = Jt(e);
|
|
1834
1901
|
throw this.fail(t), t;
|
|
1835
1902
|
}
|
|
1836
1903
|
}
|
|
@@ -1843,19 +1910,19 @@ var Jt = class {
|
|
|
1843
1910
|
return e;
|
|
1844
1911
|
}
|
|
1845
1912
|
resolve(e) {
|
|
1846
|
-
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new
|
|
1913
|
+
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new Et()));
|
|
1847
1914
|
}
|
|
1848
1915
|
fail(e) {
|
|
1849
1916
|
this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
|
|
1850
1917
|
}
|
|
1851
1918
|
async acquireWriteSlot(e) {
|
|
1852
|
-
if (this.pendingWriteCount <
|
|
1919
|
+
if (this.pendingWriteCount < wt.MAX_PENDING_WRITES) {
|
|
1853
1920
|
this.pendingWriteCount += 1;
|
|
1854
1921
|
return;
|
|
1855
1922
|
}
|
|
1856
1923
|
await new Promise((t, n) => {
|
|
1857
1924
|
let r = setTimeout(() => {
|
|
1858
|
-
n(new
|
|
1925
|
+
n(new Dt());
|
|
1859
1926
|
}, e);
|
|
1860
1927
|
this.pendingWriteWaiters.push({
|
|
1861
1928
|
resolve: () => {
|
|
@@ -1874,13 +1941,13 @@ var Jt = class {
|
|
|
1874
1941
|
for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
|
|
1875
1942
|
}
|
|
1876
1943
|
};
|
|
1877
|
-
function
|
|
1944
|
+
function Zt(e) {
|
|
1878
1945
|
let t = null, n = (t, n) => {
|
|
1879
|
-
if (!e.getCapabilities()[n]) throw new
|
|
1946
|
+
if (!e.getCapabilities()[n]) throw new Tt(t, n);
|
|
1880
1947
|
}, r = {
|
|
1881
1948
|
async speak(r) {
|
|
1882
1949
|
if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
|
|
1883
|
-
let i =
|
|
1950
|
+
let i = Pt(r.queue ?? "append");
|
|
1884
1951
|
i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
|
|
1885
1952
|
let a = e.getIframeHost();
|
|
1886
1953
|
if (!a) throw new Q("Speech session is not attached.");
|
|
@@ -1900,41 +1967,41 @@ function Yt(e) {
|
|
|
1900
1967
|
return;
|
|
1901
1968
|
}
|
|
1902
1969
|
t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
|
|
1903
|
-
t.removeEventListener("abort", s), n(
|
|
1970
|
+
t.removeEventListener("abort", s), n(qt(e, "completed"));
|
|
1904
1971
|
}, (a) => {
|
|
1905
|
-
if (t.removeEventListener("abort", s),
|
|
1972
|
+
if (t.removeEventListener("abort", s), Yt(a)) {
|
|
1906
1973
|
n({
|
|
1907
1974
|
utteranceId: "utt_interrupted",
|
|
1908
1975
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
1909
1976
|
status: "interrupted",
|
|
1910
1977
|
durationMs: 0,
|
|
1911
1978
|
transcript: r.text,
|
|
1912
|
-
animation:
|
|
1979
|
+
animation: Ot("none")
|
|
1913
1980
|
});
|
|
1914
1981
|
return;
|
|
1915
1982
|
}
|
|
1916
|
-
i(
|
|
1983
|
+
i(Jt(a));
|
|
1917
1984
|
});
|
|
1918
1985
|
});
|
|
1919
1986
|
}
|
|
1920
1987
|
try {
|
|
1921
|
-
return
|
|
1988
|
+
return qt(await o, "completed");
|
|
1922
1989
|
} catch (t) {
|
|
1923
|
-
if (
|
|
1990
|
+
if (Yt(t)) return {
|
|
1924
1991
|
utteranceId: "utt_interrupted",
|
|
1925
1992
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
1926
1993
|
status: "interrupted",
|
|
1927
1994
|
durationMs: 0,
|
|
1928
1995
|
transcript: r.text,
|
|
1929
|
-
animation:
|
|
1996
|
+
animation: Ot("none")
|
|
1930
1997
|
};
|
|
1931
|
-
throw
|
|
1998
|
+
throw Jt(t);
|
|
1932
1999
|
}
|
|
1933
2000
|
},
|
|
1934
2001
|
async play(i) {
|
|
1935
|
-
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"),
|
|
2002
|
+
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), jt(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
1936
2003
|
let a = i.queue ?? "append";
|
|
1937
|
-
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)),
|
|
2004
|
+
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), xt(i.audio)) {
|
|
1938
2005
|
let e = i.audio.sampleRate ?? 24e3;
|
|
1939
2006
|
return r.createUtterance({
|
|
1940
2007
|
format: {
|
|
@@ -1950,7 +2017,7 @@ function Yt(e) {
|
|
|
1950
2017
|
}
|
|
1951
2018
|
let o = e.getIframeHost();
|
|
1952
2019
|
if (!o) throw new Q("Speech session is not attached.");
|
|
1953
|
-
let s = await
|
|
2020
|
+
let s = await Gt(i.audio, i.signal);
|
|
1954
2021
|
return o.speechPlay({
|
|
1955
2022
|
source: s,
|
|
1956
2023
|
characterId: i.characterId,
|
|
@@ -1962,13 +2029,13 @@ function Yt(e) {
|
|
|
1962
2029
|
},
|
|
1963
2030
|
createUtterance(r) {
|
|
1964
2031
|
e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
|
|
1965
|
-
let i =
|
|
2032
|
+
let i = Mt(r);
|
|
1966
2033
|
if (r.track && r.track.kind !== "audio") throw new Q("createUtterance track must be an audio MediaStreamTrack.");
|
|
1967
2034
|
let a = r.queue ?? "replace-active";
|
|
1968
2035
|
if (a !== "replace-active" && a !== "replace-all") throw new Q("createUtterance queue must be replace-active or replace-all.");
|
|
1969
2036
|
e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
|
|
1970
|
-
let o = new
|
|
1971
|
-
id:
|
|
2037
|
+
let o = new Xt({
|
|
2038
|
+
id: Kt(),
|
|
1972
2039
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
1973
2040
|
format: i,
|
|
1974
2041
|
queue: a,
|
|
@@ -1980,7 +2047,7 @@ function Yt(e) {
|
|
|
1980
2047
|
t === o && (t = null);
|
|
1981
2048
|
}), r.track && (async () => {
|
|
1982
2049
|
try {
|
|
1983
|
-
if (await
|
|
2050
|
+
if (await Wt({
|
|
1984
2051
|
track: r.track,
|
|
1985
2052
|
utterance: o,
|
|
1986
2053
|
sampleRate: i.sampleRate,
|
|
@@ -2007,11 +2074,17 @@ function Yt(e) {
|
|
|
2007
2074
|
return r;
|
|
2008
2075
|
}
|
|
2009
2076
|
//#endregion
|
|
2077
|
+
//#region src/v2/types/sessionInteraction.ts
|
|
2078
|
+
function Qt(e) {
|
|
2079
|
+
let t = e?.trim();
|
|
2080
|
+
return t === "full" || t === "face" || t === "medium" ? t : void 0;
|
|
2081
|
+
}
|
|
2082
|
+
//#endregion
|
|
2010
2083
|
//#region src/v2/experience.ts
|
|
2011
|
-
function
|
|
2084
|
+
function $t(e) {
|
|
2012
2085
|
return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
|
|
2013
2086
|
}
|
|
2014
|
-
var
|
|
2087
|
+
var en = class e {
|
|
2015
2088
|
bootstrap;
|
|
2016
2089
|
conversationProcessor;
|
|
2017
2090
|
iframeHost = null;
|
|
@@ -2024,17 +2097,18 @@ var Zt = class e {
|
|
|
2024
2097
|
attachReturnUrl = null;
|
|
2025
2098
|
closed = !1;
|
|
2026
2099
|
attached = !1;
|
|
2100
|
+
pendingFit = null;
|
|
2027
2101
|
closeHandlers = [];
|
|
2028
|
-
eventRegistry =
|
|
2102
|
+
eventRegistry = ht();
|
|
2029
2103
|
readyEnvelope = null;
|
|
2030
2104
|
startedEnvelope = null;
|
|
2031
2105
|
conversationCache = [];
|
|
2032
2106
|
speech;
|
|
2033
2107
|
constructor(e) {
|
|
2034
|
-
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 =
|
|
2108
|
+
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 = Zt({
|
|
2035
2109
|
getIframeHost: () => this.iframeHost,
|
|
2036
2110
|
assertSessionStarted: () => this.assertSessionStarted(),
|
|
2037
|
-
getCapabilities: () =>
|
|
2111
|
+
getCapabilities: () => tn(this.resolvedSession),
|
|
2038
2112
|
getActiveCharacterId: () => "character_unknown",
|
|
2039
2113
|
onProcessorInterrupt: () => {
|
|
2040
2114
|
this.processorAbortController?.abort(), this.processorAbortController = null;
|
|
@@ -2049,6 +2123,9 @@ var Zt = class e {
|
|
|
2049
2123
|
kind: "launch",
|
|
2050
2124
|
launch: n,
|
|
2051
2125
|
session: t.session,
|
|
2126
|
+
backdropId: t.backdropId,
|
|
2127
|
+
locationId: t.locationId,
|
|
2128
|
+
avatarId: t.avatarId,
|
|
2052
2129
|
embedBaseUrl: t.embedBaseUrl,
|
|
2053
2130
|
debug: t.debug,
|
|
2054
2131
|
speechOnly: t.speechOnly,
|
|
@@ -2066,8 +2143,10 @@ var Zt = class e {
|
|
|
2066
2143
|
secondaryLocale: t.secondaryLocale,
|
|
2067
2144
|
learningLocale: t.learningLocale,
|
|
2068
2145
|
language: t.language,
|
|
2146
|
+
backdropId: t.backdropId,
|
|
2069
2147
|
locationId: t.locationId,
|
|
2070
2148
|
avatarId: t.avatarId,
|
|
2149
|
+
castSize: t.castSize,
|
|
2071
2150
|
embedBaseUrl: t.embedBaseUrl,
|
|
2072
2151
|
debug: t.debug,
|
|
2073
2152
|
mode: t.mode,
|
|
@@ -2085,8 +2164,10 @@ var Zt = class e {
|
|
|
2085
2164
|
secondaryLocale: t.secondaryLocale,
|
|
2086
2165
|
learningLocale: t.learningLocale,
|
|
2087
2166
|
language: t.language,
|
|
2167
|
+
backdropId: t.backdropId,
|
|
2088
2168
|
locationId: t.locationId,
|
|
2089
2169
|
avatarId: t.avatarId,
|
|
2170
|
+
castSize: t.castSize,
|
|
2090
2171
|
embedBaseUrl: t.embedBaseUrl,
|
|
2091
2172
|
debug: t.debug,
|
|
2092
2173
|
mode: t.mode,
|
|
@@ -2106,7 +2187,7 @@ var Zt = class e {
|
|
|
2106
2187
|
return null;
|
|
2107
2188
|
}
|
|
2108
2189
|
on(e, t) {
|
|
2109
|
-
let n =
|
|
2190
|
+
let n = gt(this.eventRegistry, e, t);
|
|
2110
2191
|
return e === "ready" && this.readyEnvelope && queueMicrotask(() => t(this.readyEnvelope)), e === "started" && this.startedEnvelope && queueMicrotask(() => t(this.startedEnvelope)), n;
|
|
2111
2192
|
}
|
|
2112
2193
|
async attach(e) {
|
|
@@ -2120,13 +2201,13 @@ var Zt = class e {
|
|
|
2120
2201
|
if (this.closed) throw Error("Session has ended.");
|
|
2121
2202
|
if (this.attached && this.iframeHost) return this.createPlayerFacade();
|
|
2122
2203
|
this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
|
|
2123
|
-
let t = this.bootstrap.embedBaseUrl ??
|
|
2204
|
+
let t = this.bootstrap.embedBaseUrl ?? ct(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = ut(t, n, r ? void 0 : lt(this.bootstrap.backdropId, this.bootstrap.locationId), r ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, $t(e), this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.castSize), a = ft(i), o = null, s = new Promise((e) => {
|
|
2124
2205
|
o = e;
|
|
2125
2206
|
}), c = null, l = new Promise((e) => {
|
|
2126
2207
|
c = e;
|
|
2127
|
-
}), u =
|
|
2208
|
+
}), u = it((e) => {
|
|
2128
2209
|
this.readyEnvelope ||= (this.resolvedSession = e, this.emitWrapped("ready", { session: e }));
|
|
2129
|
-
}), d = this.bootstrap.onUserTranscript, f =
|
|
2210
|
+
}), d = this.bootstrap.onUserTranscript, f = rt({
|
|
2130
2211
|
container: e.container,
|
|
2131
2212
|
src: i,
|
|
2132
2213
|
playerOrigin: a,
|
|
@@ -2156,12 +2237,21 @@ var Zt = class e {
|
|
|
2156
2237
|
onCharacterSpeechEnded: (e) => {
|
|
2157
2238
|
this.emitWrapped("characterSpeechEnded", e);
|
|
2158
2239
|
},
|
|
2240
|
+
onCharacterFocusChanged: (e) => {
|
|
2241
|
+
this.emitWrapped("characterFocusChanged", e);
|
|
2242
|
+
},
|
|
2159
2243
|
onListeningState: (e) => {
|
|
2160
2244
|
this.emitWrapped("listeningState", e);
|
|
2161
2245
|
},
|
|
2162
2246
|
onActivityChange: (e) => {
|
|
2163
2247
|
this.emitWrapped("activityChange", e);
|
|
2164
2248
|
},
|
|
2249
|
+
onFeedback: (e) => {
|
|
2250
|
+
this.emitWrapped("feedback", e);
|
|
2251
|
+
},
|
|
2252
|
+
onFeedbackFailed: (e) => {
|
|
2253
|
+
this.emitWrapped("feedbackFailed", e);
|
|
2254
|
+
},
|
|
2165
2255
|
onMessage: (e) => {
|
|
2166
2256
|
this.emitWrapped("message", e);
|
|
2167
2257
|
},
|
|
@@ -2180,7 +2270,7 @@ var Zt = class e {
|
|
|
2180
2270
|
onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t)
|
|
2181
2271
|
});
|
|
2182
2272
|
this.iframeHost = f;
|
|
2183
|
-
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(),
|
|
2273
|
+
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), ze(this.bootstrap.sessionEndpoint, {
|
|
2184
2274
|
experienceId: this.bootstrap.experienceId,
|
|
2185
2275
|
locale: this.bootstrap.locale,
|
|
2186
2276
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
@@ -2190,7 +2280,7 @@ var Zt = class e {
|
|
|
2190
2280
|
speechInputMode: p.speechInputMode,
|
|
2191
2281
|
speechOnly: this.bootstrap.speechOnly,
|
|
2192
2282
|
signal: this.endpointAbortController.signal
|
|
2193
|
-
})) : this.bootstrap.kind === "public" ?
|
|
2283
|
+
})) : this.bootstrap.kind === "public" ? Re(this.bootstrap.experienceId, {
|
|
2194
2284
|
locale: this.bootstrap.locale,
|
|
2195
2285
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
2196
2286
|
learningLocale: this.bootstrap.learningLocale,
|
|
@@ -2212,11 +2302,17 @@ var Zt = class e {
|
|
|
2212
2302
|
f.postParentHello();
|
|
2213
2303
|
let g = h?.launch ?? (this.bootstrap.kind === "launch" ? this.bootstrap.launch : null), _ = h?.session ?? (this.bootstrap.kind === "launch" ? this.bootstrap.session : void 0);
|
|
2214
2304
|
if (!g) throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), Error("Session Launch response did not include a launch token.");
|
|
2215
|
-
return this.launchToken = g, _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" &&
|
|
2305
|
+
return this.launchToken = g, _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" && Ae(_), f.postLaunch(g, _, {
|
|
2306
|
+
startButton: e.startButton,
|
|
2307
|
+
showFeedback: e.showFeedback
|
|
2308
|
+
}), u.setValue(_)) : f.postLaunch(g, void 0, {
|
|
2309
|
+
startButton: e.startButton,
|
|
2310
|
+
showFeedback: e.showFeedback
|
|
2311
|
+
}), await Promise.race([s, new Promise((e, t) => {
|
|
2216
2312
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player loading UI.")), 12e4);
|
|
2217
2313
|
})]), await Promise.race([l, new Promise((e, t) => {
|
|
2218
2314
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player ready state.")), 12e4);
|
|
2219
|
-
})]), this.attached = !0, this.createPlayerFacade();
|
|
2315
|
+
})]), this.attached = !0, this.pendingFit && await f.setFit(this.pendingFit), this.createPlayerFacade();
|
|
2220
2316
|
}
|
|
2221
2317
|
async startListening() {
|
|
2222
2318
|
this.assertSessionStarted(), await this.iframeHost.startListening();
|
|
@@ -2236,6 +2332,15 @@ var Zt = class e {
|
|
|
2236
2332
|
toggleAudioSettings() {
|
|
2237
2333
|
this.iframeHost?.postWidgetToggleAudioSettings();
|
|
2238
2334
|
}
|
|
2335
|
+
async focusCharacter(e) {
|
|
2336
|
+
this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
|
|
2337
|
+
}
|
|
2338
|
+
async setFit(e) {
|
|
2339
|
+
let t = Qt(e);
|
|
2340
|
+
if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
|
|
2341
|
+
if (this.closed) throw Error("Session has ended.");
|
|
2342
|
+
this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
|
|
2343
|
+
}
|
|
2239
2344
|
getLastTurn() {
|
|
2240
2345
|
if (this.conversationCache.length === 0) return [];
|
|
2241
2346
|
let e = this.conversationCache[this.conversationCache.length - 1].turnId;
|
|
@@ -2245,7 +2350,7 @@ var Zt = class e {
|
|
|
2245
2350
|
this.close();
|
|
2246
2351
|
}
|
|
2247
2352
|
destroy() {
|
|
2248
|
-
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,
|
|
2353
|
+
this.closed || (this.closed = !0, this.processorAbortController?.abort(), this.processorAbortController = null, this.endpointAbortController?.abort(), this.endpointAbortController = null, this.attachInFlight = null, this.iframeHost?.destroy(), this.iframeHost = null, vt(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.attached = !1);
|
|
2249
2354
|
}
|
|
2250
2355
|
resolveMintInteraction() {
|
|
2251
2356
|
return this.bootstrap.kind === "launch" ? {} : {
|
|
@@ -2257,8 +2362,8 @@ var Zt = class e {
|
|
|
2257
2362
|
return this.resolvedSession?.id ?? "";
|
|
2258
2363
|
}
|
|
2259
2364
|
emitWrapped(e, t) {
|
|
2260
|
-
let n =
|
|
2261
|
-
return
|
|
2365
|
+
let n = mt(e, this.getSessionId(), t);
|
|
2366
|
+
return _t(this.eventRegistry, e, n), n;
|
|
2262
2367
|
}
|
|
2263
2368
|
queueProcessorTurn(e) {
|
|
2264
2369
|
if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
|
|
@@ -2267,7 +2372,7 @@ var Zt = class e {
|
|
|
2267
2372
|
let n = this.processorAbortController.signal;
|
|
2268
2373
|
this.processorChain = this.processorChain.then(async () => {
|
|
2269
2374
|
if (!n.aborted) try {
|
|
2270
|
-
let r = await
|
|
2375
|
+
let r = await He(t, {
|
|
2271
2376
|
utteranceId: e.utteranceId,
|
|
2272
2377
|
text: e.text,
|
|
2273
2378
|
conversation: this.conversationCache,
|
|
@@ -2317,7 +2422,7 @@ var Zt = class e {
|
|
|
2317
2422
|
};
|
|
2318
2423
|
}
|
|
2319
2424
|
};
|
|
2320
|
-
function
|
|
2425
|
+
function tn(e) {
|
|
2321
2426
|
return e ? {
|
|
2322
2427
|
textSpeech: e.capabilities.speech.output,
|
|
2323
2428
|
externalSpeechAudio: e.capabilities.speech.externalAudio
|
|
@@ -2328,41 +2433,41 @@ function Qt(e) {
|
|
|
2328
2433
|
}
|
|
2329
2434
|
//#endregion
|
|
2330
2435
|
//#region src/widget/dockGeometry.ts
|
|
2331
|
-
var
|
|
2332
|
-
function
|
|
2436
|
+
var nn = "(min-width: 768px)", rn = 24, an = .5, on = 1200, sn = .85, cn = 9 / 16;
|
|
2437
|
+
function ln() {
|
|
2333
2438
|
if (typeof window > "u") return 800;
|
|
2334
2439
|
let e = window.screen?.availHeight;
|
|
2335
2440
|
return typeof e == "number" && e > 0 ? e : window.innerHeight;
|
|
2336
2441
|
}
|
|
2337
|
-
function
|
|
2338
|
-
let i = Math.max(160, Math.min(t - n * 2, t *
|
|
2339
|
-
return s > a && (s = a, o = s /
|
|
2442
|
+
function un(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = rn, r = typeof window < "u" ? ln() : 800) {
|
|
2443
|
+
let i = Math.max(160, Math.min(t - n * 2, t * sn)), a = Math.max(120, e - n * 2), o = Math.min(r * an, on, i), s = o * cn;
|
|
2444
|
+
return s > a && (s = a, o = s / cn, o > i && (o = i, s = o * cn)), {
|
|
2340
2445
|
width: Math.round(s),
|
|
2341
2446
|
height: Math.round(o)
|
|
2342
2447
|
};
|
|
2343
2448
|
}
|
|
2344
|
-
function
|
|
2449
|
+
function dn(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = rn) {
|
|
2345
2450
|
return {
|
|
2346
2451
|
left: Math.max(r, t - e.width - r),
|
|
2347
2452
|
top: Math.max(r, n - e.height - r)
|
|
2348
2453
|
};
|
|
2349
2454
|
}
|
|
2350
|
-
function
|
|
2455
|
+
function fn(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = rn) {
|
|
2351
2456
|
let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
|
|
2352
2457
|
return {
|
|
2353
2458
|
left: Math.min(Math.max(a, e), o),
|
|
2354
2459
|
top: Math.min(Math.max(a, t), s)
|
|
2355
2460
|
};
|
|
2356
2461
|
}
|
|
2357
|
-
function
|
|
2358
|
-
return e(
|
|
2462
|
+
function pn(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
|
|
2463
|
+
return e(nn).matches;
|
|
2359
2464
|
}
|
|
2360
2465
|
//#endregion
|
|
2361
2466
|
//#region src/widget/mountExperienceWidget.ts
|
|
2362
|
-
function
|
|
2467
|
+
function mn(e) {
|
|
2363
2468
|
return e === "bottom-right" || e === "bottom-left" ? e : "static";
|
|
2364
2469
|
}
|
|
2365
|
-
function
|
|
2470
|
+
function hn(e) {
|
|
2366
2471
|
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
2367
2472
|
let t = typeof e == "string" ? e.trim() : "";
|
|
2368
2473
|
return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
|
|
@@ -2370,10 +2475,10 @@ function fn(e) {
|
|
|
2370
2475
|
function $(e) {
|
|
2371
2476
|
return e === "expanded" || e === "docked";
|
|
2372
2477
|
}
|
|
2373
|
-
var
|
|
2374
|
-
function
|
|
2375
|
-
de
|
|
2376
|
-
let r =
|
|
2478
|
+
var gn = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 0 0-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 0 0-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 0 0-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 0 0-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 0 0 1.066-2.573c-.94-1.543.826-3.31 2.37-2.37c1 .608 2.296.07 2.572-1.065\"/><path d=\"M9 12a3 3 0 1 0 6 0a3 3 0 0 0-6 0\"/></svg>", _n = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\"><path fill=\"currentColor\" d=\"M18.3 5.71a1 1 0 0 0-1.41 0L12 10.59 7.11 5.7A1 1 0 0 0 5.7 7.11L10.59 12l-4.9 4.89a1 1 0 1 0 1.42 1.42L12 13.41l4.89 4.9a1 1 0 0 0 1.42-1.42L13.41 12l4.9-4.89a1 1 0 0 0-.01-1.4Z\"/></svg>", vn = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M18 10h-4V6m6-2l-6 6m-8 4h4v4m0-4l-6 6\"/></svg>", yn = "<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>";
|
|
2479
|
+
function bn(e, t, n) {
|
|
2480
|
+
W(de);
|
|
2481
|
+
let r = w({
|
|
2377
2482
|
galleryThumb: t.galleryThumb,
|
|
2378
2483
|
avatarImage: t.avatarImage,
|
|
2379
2484
|
backgroundImage: t.backgroundImage,
|
|
@@ -2399,9 +2504,9 @@ function _n(e, t, n) {
|
|
|
2399
2504
|
let e = document.createElement("img");
|
|
2400
2505
|
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);
|
|
2401
2506
|
}
|
|
2402
|
-
return e.replaceChildren(i), n?.parallax === !1 ? () => {} :
|
|
2507
|
+
return e.replaceChildren(i), n?.parallax === !1 ? () => {} : ue(i);
|
|
2403
2508
|
}
|
|
2404
|
-
function
|
|
2509
|
+
function xn(e) {
|
|
2405
2510
|
return e.startButton ? {
|
|
2406
2511
|
...e.startButton,
|
|
2407
2512
|
label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
|
|
@@ -2413,7 +2518,7 @@ function vn(e) {
|
|
|
2413
2518
|
variant: "primary"
|
|
2414
2519
|
};
|
|
2415
2520
|
}
|
|
2416
|
-
function
|
|
2521
|
+
function Sn(e) {
|
|
2417
2522
|
let t = !1, n = () => {
|
|
2418
2523
|
t || e();
|
|
2419
2524
|
}, r = () => {
|
|
@@ -2433,12 +2538,12 @@ function yn(e) {
|
|
|
2433
2538
|
t = !0, window.removeEventListener("load", r), i?.();
|
|
2434
2539
|
};
|
|
2435
2540
|
}
|
|
2436
|
-
function
|
|
2437
|
-
me
|
|
2541
|
+
function Cn(e, t) {
|
|
2542
|
+
he(me);
|
|
2438
2543
|
let n = t.experienceId?.trim();
|
|
2439
2544
|
if (!n) throw Error("ExperienceWidget requires experienceId.");
|
|
2440
|
-
let r = t.prefetch ?? "onExpand", i =
|
|
2441
|
-
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",
|
|
2545
|
+
let r = t.prefetch ?? "onExpand", i = mn(t.position), a = document.createElement("div");
|
|
2546
|
+
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", hn(t.offset));
|
|
2442
2547
|
let o = document.createElement("button");
|
|
2443
2548
|
o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
|
|
2444
2549
|
let s = document.createElement("div");
|
|
@@ -2458,30 +2563,30 @@ function bn(e, t) {
|
|
|
2458
2563
|
let m = document.createElement("span");
|
|
2459
2564
|
m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
|
|
2460
2565
|
let h = document.createElement("button");
|
|
2461
|
-
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML =
|
|
2566
|
+
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = vn, h.setAttribute("aria-label", "Reduce");
|
|
2462
2567
|
let g = document.createElement("button");
|
|
2463
|
-
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML =
|
|
2568
|
+
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = gn, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
|
|
2464
2569
|
let _ = document.createElement("button");
|
|
2465
|
-
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML =
|
|
2570
|
+
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = _n, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
|
|
2466
2571
|
let v = document.createElement("div");
|
|
2467
2572
|
v.className = "liforma-ew__stage";
|
|
2468
2573
|
let y = document.createElement("div");
|
|
2469
2574
|
y.className = "liforma-ew__status", y.hidden = !0, f.append(v, y), u.append(d, f), a.append(o, l, u, p), e.replaceChildren(a);
|
|
2470
|
-
let b = null, x = !1, S = !1,
|
|
2575
|
+
let b = null, x = !1, S = !1, C = !1, w = !1, T = !1, E = !1, D = !1, O = 0, k = "", A = null, ee = null, j = null, M = null, N = null, P = null, F = null, te = 0, ne = 0, I = null, L = !1, re = new AbortController(), ie = t.parallax !== !1, R = () => {
|
|
2471
2576
|
let e = a.dataset.state;
|
|
2472
2577
|
return e === "expanded" || e === "docked" || e === "collapsed" ? e : "collapsed";
|
|
2473
2578
|
}, z = () => {
|
|
2474
2579
|
j !== null && (clearTimeout(j), j = null);
|
|
2475
2580
|
}, B = () => {
|
|
2476
2581
|
M !== null && (clearTimeout(M), M = null), a.classList.remove("liforma-ew--layout-settling");
|
|
2477
|
-
},
|
|
2582
|
+
}, ae = () => {
|
|
2478
2583
|
for (let e of [
|
|
2479
2584
|
f,
|
|
2480
2585
|
l,
|
|
2481
2586
|
p
|
|
2482
2587
|
]) e.style.removeProperty("left"), e.style.removeProperty("top"), e.style.removeProperty("width"), e.style.removeProperty("height"), e.style.removeProperty("right"), e.style.removeProperty("bottom");
|
|
2483
2588
|
p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging");
|
|
2484
|
-
},
|
|
2589
|
+
}, V = (e, t, n, r) => {
|
|
2485
2590
|
let i = (i) => {
|
|
2486
2591
|
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";
|
|
2487
2592
|
};
|
|
@@ -2490,50 +2595,50 @@ function bn(e, t) {
|
|
|
2490
2595
|
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";
|
|
2491
2596
|
}, oe = (e, t) => {
|
|
2492
2597
|
if (R() !== "docked") return;
|
|
2493
|
-
let n =
|
|
2494
|
-
N = r.left, P = r.top,
|
|
2598
|
+
let n = un(), r = fn(e - te, t - ne, n);
|
|
2599
|
+
N = r.left, P = r.top, V(r.left, r.top, n.width, n.height);
|
|
2495
2600
|
}, se = (e, t) => {
|
|
2496
2601
|
if (R() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
|
|
2497
|
-
let n =
|
|
2498
|
-
N = a.left, P = a.top,
|
|
2602
|
+
let n = un(), r = N ?? f.getBoundingClientRect().left, i = P ?? f.getBoundingClientRect().top, a = fn(r + e, i + t, n);
|
|
2603
|
+
N = a.left, P = a.top, V(a.left, a.top, n.width, n.height);
|
|
2499
2604
|
}, ce = (e) => {
|
|
2500
|
-
|
|
2605
|
+
I === "toolbar" && (F === null || e.pointerId !== F || (e.preventDefault(), oe(e.clientX, e.clientY)));
|
|
2501
2606
|
}, H = (e) => {
|
|
2502
2607
|
if (F === null || e && e.pointerId !== F) return;
|
|
2503
|
-
let t =
|
|
2504
|
-
F = null,
|
|
2608
|
+
let t = I;
|
|
2609
|
+
F = null, I = null, p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging"), t === "toolbar" && L && (L = !1, window.removeEventListener("pointermove", ce), window.removeEventListener("pointerup", H), window.removeEventListener("pointercancel", H));
|
|
2505
2610
|
}, le = (e, t, n) => {
|
|
2506
|
-
if (S || R() !== "docked" || !
|
|
2507
|
-
F = n,
|
|
2611
|
+
if (S || R() !== "docked" || !pn() || F !== null) return;
|
|
2612
|
+
F = n, I = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2508
2613
|
let r = f.getBoundingClientRect();
|
|
2509
|
-
te = e - r.left,
|
|
2614
|
+
te = e - r.left, ne = t - r.top, L || (L = !0, window.addEventListener("pointermove", ce), window.addEventListener("pointerup", H), window.addEventListener("pointercancel", H));
|
|
2510
2615
|
}, ue = (e) => {
|
|
2511
|
-
if (S || R() !== "docked" || !
|
|
2512
|
-
F = e.pointerId,
|
|
2616
|
+
if (S || R() !== "docked" || !pn() || F !== null) return;
|
|
2617
|
+
F = e.pointerId, I = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2513
2618
|
let t = f.getBoundingClientRect();
|
|
2514
2619
|
N = t.left, P = t.top;
|
|
2515
|
-
}, U = (e) => {
|
|
2516
|
-
L === "player" && (F === null || e.pointerId !== F || se(e.dx, e.dy));
|
|
2517
2620
|
}, de = (e) => {
|
|
2518
|
-
|
|
2621
|
+
I === "player" && (F === null || e.pointerId !== F || se(e.dx, e.dy));
|
|
2622
|
+
}, U = (e) => {
|
|
2623
|
+
I === "player" && (F === null || e.pointerId !== F || H());
|
|
2519
2624
|
}, W = () => {
|
|
2520
|
-
let e =
|
|
2625
|
+
let e = pn(), t = R();
|
|
2521
2626
|
if (!e || t !== "expanded" && t !== "docked") {
|
|
2522
2627
|
h.hidden = !0;
|
|
2523
2628
|
return;
|
|
2524
2629
|
}
|
|
2525
|
-
h.hidden = !1, t === "docked" ? (h.innerHTML =
|
|
2630
|
+
h.hidden = !1, t === "docked" ? (h.innerHTML = yn, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = vn, h.setAttribute("aria-label", "Reduce"));
|
|
2526
2631
|
}, fe = (e) => {
|
|
2527
|
-
let t =
|
|
2528
|
-
n =
|
|
2529
|
-
},
|
|
2632
|
+
let t = un(), n = e && N !== null && P !== null ? fn(N, P, t) : dn(t);
|
|
2633
|
+
n = fn(n.left, n.top, t), N = n.left, P = n.top, V(n.left, n.top, t.width, t.height), W();
|
|
2634
|
+
}, pe = () => {
|
|
2530
2635
|
a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
|
|
2531
2636
|
requestAnimationFrame(() => {
|
|
2532
2637
|
S || !$(a.dataset.state) || a.classList.add("liforma-ew--session-revealed");
|
|
2533
2638
|
});
|
|
2534
2639
|
});
|
|
2535
|
-
},
|
|
2536
|
-
if (B(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !
|
|
2640
|
+
}, G = (e) => {
|
|
2641
|
+
if (B(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !D) {
|
|
2537
2642
|
a.classList.remove("liforma-ew--layout-settling");
|
|
2538
2643
|
return;
|
|
2539
2644
|
}
|
|
@@ -2542,54 +2647,54 @@ function bn(e, t) {
|
|
|
2542
2647
|
a.classList.remove("liforma-ew--layout-settling");
|
|
2543
2648
|
return;
|
|
2544
2649
|
}
|
|
2545
|
-
a.classList.remove("liforma-ew--layout-settling"),
|
|
2650
|
+
a.classList.remove("liforma-ew--layout-settling"), pe();
|
|
2546
2651
|
}, 220);
|
|
2547
|
-
},
|
|
2652
|
+
}, ge = () => (a.classList.add("liforma-ew--session-concealing"), a.classList.remove("liforma-ew--session-revealed"), new Promise((e) => {
|
|
2548
2653
|
z(), j = setTimeout(() => {
|
|
2549
2654
|
j = null, a.classList.remove("liforma-ew--session-concealing"), e();
|
|
2550
2655
|
}, 280);
|
|
2551
|
-
})),
|
|
2656
|
+
})), _e = {
|
|
2552
2657
|
galleryThumb: t.galleryThumb,
|
|
2553
2658
|
avatarImage: t.avatarImage,
|
|
2554
2659
|
backgroundImage: t.backgroundImage,
|
|
2555
2660
|
foregroundImage: t.foregroundImage,
|
|
2556
2661
|
fallbackImage: t.fallbackImage
|
|
2557
|
-
},
|
|
2662
|
+
}, K = (e) => {
|
|
2558
2663
|
if (!e) {
|
|
2559
2664
|
y.hidden = !0, y.textContent = "";
|
|
2560
2665
|
return;
|
|
2561
2666
|
}
|
|
2562
2667
|
y.hidden = !1, y.textContent = e;
|
|
2563
|
-
},
|
|
2668
|
+
}, ve = (e) => {
|
|
2564
2669
|
if (!e) {
|
|
2565
2670
|
c.hidden = !0, c.textContent = "";
|
|
2566
2671
|
return;
|
|
2567
2672
|
}
|
|
2568
2673
|
c.hidden = !1, c.textContent = e, s.contains(c) || s.append(c);
|
|
2569
|
-
}, J = () => {
|
|
2570
|
-
ee = !0, o.disabled = !1, _e(null), r === "onExpand" && t.onPrefetchReady?.();
|
|
2571
2674
|
}, ye = () => {
|
|
2572
|
-
C = !0,
|
|
2573
|
-
},
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2675
|
+
C = !0, o.disabled = !1, ve(null), r === "onExpand" && t.onPrefetchReady?.();
|
|
2676
|
+
}, q = () => {
|
|
2677
|
+
w = !0, a.dataset.warm = "true", l.hidden = !1, D || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
|
|
2678
|
+
}, xe = (e) => {
|
|
2679
|
+
A?.(), A = null;
|
|
2680
|
+
let t = bn(s, e, { parallax: ie });
|
|
2681
|
+
return t ? (A = t, !0) : !1;
|
|
2682
|
+
}, Se = () => {
|
|
2683
|
+
if (xe(_e)) {
|
|
2684
|
+
ye();
|
|
2580
2685
|
return;
|
|
2581
2686
|
}
|
|
2582
|
-
|
|
2687
|
+
ve("Loading…"), be(n, { signal: re.signal }).then((e) => {
|
|
2583
2688
|
if (!S) {
|
|
2584
|
-
if (!
|
|
2585
|
-
|
|
2689
|
+
if (!xe({ galleryThumb: e.galleryThumb })) throw Error("Experience preview is missing gallery thumb images.");
|
|
2690
|
+
ye();
|
|
2586
2691
|
}
|
|
2587
2692
|
}).catch((e) => {
|
|
2588
2693
|
if (S || re.signal.aborted) return;
|
|
2589
2694
|
let n = e instanceof Error ? e : Error(String(e));
|
|
2590
|
-
|
|
2695
|
+
ve("Preview unavailable"), o.disabled = !0, t.onError?.(n), console.error("[ExperienceWidget]", n);
|
|
2591
2696
|
});
|
|
2592
|
-
},
|
|
2697
|
+
}, Ce = () => ({
|
|
2593
2698
|
experienceId: n,
|
|
2594
2699
|
ui: "widget",
|
|
2595
2700
|
...t.sessionEndpoint ? { sessionEndpoint: t.sessionEndpoint } : {},
|
|
@@ -2599,65 +2704,70 @@ function bn(e, t) {
|
|
|
2599
2704
|
...t.speechInputMode ? { speechInputMode: t.speechInputMode } : {},
|
|
2600
2705
|
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
|
|
2601
2706
|
...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
|
|
2602
|
-
}),
|
|
2707
|
+
}), we = () => ({
|
|
2603
2708
|
...t.fit ? { fit: t.fit } : {},
|
|
2604
|
-
startButton:
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2709
|
+
startButton: xn(t),
|
|
2710
|
+
...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback }
|
|
2711
|
+
}), J = (e = !0) => {
|
|
2712
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), ae(), a.dataset.state = "expanded", K(null), typeof document < "u" && (k = document.body.style.overflow, document.body.style.overflow = "hidden"), W(), e && t.onExpanded?.();
|
|
2713
|
+
}, Y = () => {
|
|
2714
|
+
o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked", K(null), typeof document < "u" && (document.body.style.overflow = k), fe(!0), W(), b?.setWidgetChrome("docked");
|
|
2715
|
+
}, X = (e) => {
|
|
2610
2716
|
e.on("started", () => {
|
|
2611
|
-
S || (
|
|
2717
|
+
S || (D = !0, a.dataset.live = "true", K(null), t.onStarted?.(), $(a.dataset.state) && pe());
|
|
2718
|
+
}), e.on("feedback", (e) => {
|
|
2719
|
+
S || t.onFeedback?.(e);
|
|
2720
|
+
}), e.on("feedbackFailed", (e) => {
|
|
2721
|
+
S || t.onFeedbackFailed?.(e);
|
|
2612
2722
|
});
|
|
2613
2723
|
}, Te = () => {
|
|
2614
|
-
B(), u.hidden = !0, p.hidden = !0,
|
|
2724
|
+
B(), u.hidden = !0, p.hidden = !0, ae(), a.dataset.state = "collapsed", a.classList.remove("liforma-ew--session-revealed"), a.classList.remove("liforma-ew--session-concealing"), g.setAttribute("aria-pressed", "false"), o.hidden = !1, o.tabIndex = 0, o.removeAttribute("aria-hidden"), C && (o.disabled = !1), K(null), typeof document < "u" && (document.body.style.overflow = k), W();
|
|
2615
2725
|
}, Ee = () => {
|
|
2616
|
-
z(), B(),
|
|
2726
|
+
z(), B(), O += 1, x = !1, w = !1, T = !1, E = !1, D = !1;
|
|
2617
2727
|
let e = b;
|
|
2618
2728
|
b = null, e?.destroy(), v.replaceChildren(), l.replaceChildren(), l.hidden = !0, delete a.dataset.warm, delete a.dataset.live, a.classList.remove("liforma-ew--session-revealed");
|
|
2619
2729
|
}, De = () => {
|
|
2620
2730
|
if (!S && $(a.dataset.state)) {
|
|
2621
|
-
if (H(), x = !1, b &&
|
|
2731
|
+
if (H(), x = !1, b && E) {
|
|
2622
2732
|
let e = b;
|
|
2623
2733
|
(async () => {
|
|
2624
|
-
|
|
2734
|
+
D && (await ge(), S || b !== e) || (w && e.setWidgetChrome("collapsed"), Te(), D ? (a.dataset.live = "true", o.tabIndex = 0, o.removeAttribute("aria-hidden"), o.disabled = !1) : w && q(), t.onCollapsed?.(), t.onClose?.());
|
|
2625
2735
|
})();
|
|
2626
2736
|
return;
|
|
2627
2737
|
}
|
|
2628
2738
|
Ee(), Te(), t.onCollapsed?.(), t.onClose?.();
|
|
2629
2739
|
}
|
|
2630
2740
|
}, Oe = () => {
|
|
2631
|
-
S ||
|
|
2632
|
-
|
|
2741
|
+
S || pn() && R() === "expanded" && G(() => {
|
|
2742
|
+
Y();
|
|
2633
2743
|
});
|
|
2634
2744
|
}, ke = () => {
|
|
2635
|
-
S || R() === "docked" && (H(),
|
|
2636
|
-
|
|
2745
|
+
S || R() === "docked" && (H(), G(() => {
|
|
2746
|
+
ae(), J(!1), b?.setWidgetChrome("expanded");
|
|
2637
2747
|
}));
|
|
2638
2748
|
}, Ae = () => {
|
|
2639
|
-
!b || !
|
|
2749
|
+
!b || !D || (z(), a.classList.remove("liforma-ew--session-revealed"), J(), b.setWidgetChrome("expanded"), x = !1, pe());
|
|
2640
2750
|
}, je = () => {
|
|
2641
|
-
!b || !
|
|
2751
|
+
!b || !E || D || (z(), a.classList.remove("liforma-ew--session-revealed"), J(), x = !1, w || b.setWidgetChrome("expanded"));
|
|
2642
2752
|
}, Me = (e) => {
|
|
2643
|
-
S || e !==
|
|
2753
|
+
S || e !== O && !D || (z(), a.classList.remove("liforma-ew--session-revealed"), J(), x = !1, D && pe());
|
|
2644
2754
|
}, Ne = () => {
|
|
2645
|
-
if (S ||
|
|
2646
|
-
|
|
2647
|
-
let e =
|
|
2755
|
+
if (S || T || w || b || $(a.dataset.state)) return;
|
|
2756
|
+
T = !0;
|
|
2757
|
+
let e = O;
|
|
2648
2758
|
l.hidden = !1, (async () => {
|
|
2649
2759
|
try {
|
|
2650
|
-
let t = await
|
|
2651
|
-
if (S || e !==
|
|
2760
|
+
let t = await en.startSession(Ce());
|
|
2761
|
+
if (S || e !== O) {
|
|
2652
2762
|
t.destroy();
|
|
2653
2763
|
return;
|
|
2654
2764
|
}
|
|
2655
|
-
b = t,
|
|
2765
|
+
b = t, X(t);
|
|
2656
2766
|
let n = await t.attach({
|
|
2657
2767
|
container: l,
|
|
2658
|
-
...
|
|
2768
|
+
...we(),
|
|
2659
2769
|
onWidgetReady: () => {
|
|
2660
|
-
S || e !==
|
|
2770
|
+
S || e !== O || (T = !1, E = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") : q());
|
|
2661
2771
|
},
|
|
2662
2772
|
onWidgetExpand: () => {
|
|
2663
2773
|
Me(e);
|
|
@@ -2669,16 +2779,16 @@ function bn(e, t) {
|
|
|
2669
2779
|
S || ue(e);
|
|
2670
2780
|
},
|
|
2671
2781
|
onWidgetDragMove: (e) => {
|
|
2672
|
-
S ||
|
|
2782
|
+
S || de(e);
|
|
2673
2783
|
},
|
|
2674
2784
|
onWidgetDragEnd: (e) => {
|
|
2675
|
-
S ||
|
|
2785
|
+
S || U(e);
|
|
2676
2786
|
},
|
|
2677
2787
|
onPlayerStatusChange: (e) => {
|
|
2678
|
-
S || e === "error" && $(a.dataset.state) &&
|
|
2788
|
+
S || e === "error" && $(a.dataset.state) && K("Could not load the experience.");
|
|
2679
2789
|
}
|
|
2680
2790
|
});
|
|
2681
|
-
if (S || e !==
|
|
2791
|
+
if (S || e !== O) {
|
|
2682
2792
|
t.destroy(), b === t && (b = null);
|
|
2683
2793
|
return;
|
|
2684
2794
|
}
|
|
@@ -2686,35 +2796,35 @@ function bn(e, t) {
|
|
|
2686
2796
|
S || De();
|
|
2687
2797
|
});
|
|
2688
2798
|
} catch (n) {
|
|
2689
|
-
if (S || e !==
|
|
2690
|
-
|
|
2799
|
+
if (S || e !== O) return;
|
|
2800
|
+
T = !1, l.hidden = !0, l.replaceChildren(), b = null;
|
|
2691
2801
|
let r = n instanceof Error ? n : Error(String(n));
|
|
2692
2802
|
t.onError?.(r), console.error("[ExperienceWidget] warm prefetch failed", r);
|
|
2693
2803
|
}
|
|
2694
2804
|
})();
|
|
2695
2805
|
}, Pe = () => {
|
|
2696
|
-
if (S || x || !
|
|
2697
|
-
if (b &&
|
|
2806
|
+
if (S || x || !C || $(a.dataset.state)) return;
|
|
2807
|
+
if (b && D) {
|
|
2698
2808
|
Ae();
|
|
2699
2809
|
return;
|
|
2700
2810
|
}
|
|
2701
|
-
if (b &&
|
|
2811
|
+
if (b && E) {
|
|
2702
2812
|
je();
|
|
2703
2813
|
return;
|
|
2704
2814
|
}
|
|
2705
|
-
let e = ++
|
|
2706
|
-
x = !0,
|
|
2815
|
+
let e = ++O;
|
|
2816
|
+
x = !0, w = !1, T = !1, E = !1, D = !1, delete a.dataset.warm, delete a.dataset.live, l.hidden = !0, l.replaceChildren(), b &&= (b.destroy(), null), (async () => {
|
|
2707
2817
|
try {
|
|
2708
|
-
|
|
2709
|
-
let t = await
|
|
2710
|
-
if (S || e !==
|
|
2818
|
+
J();
|
|
2819
|
+
let t = await en.startSession(Ce());
|
|
2820
|
+
if (S || e !== O) {
|
|
2711
2821
|
t.destroy();
|
|
2712
2822
|
return;
|
|
2713
2823
|
}
|
|
2714
|
-
b = t,
|
|
2824
|
+
b = t, X(t);
|
|
2715
2825
|
let n = await t.attach({
|
|
2716
2826
|
container: v,
|
|
2717
|
-
...
|
|
2827
|
+
...we(),
|
|
2718
2828
|
onWidgetAudioSettings: (e) => {
|
|
2719
2829
|
S || Le(e);
|
|
2720
2830
|
},
|
|
@@ -2722,42 +2832,42 @@ function bn(e, t) {
|
|
|
2722
2832
|
S || ue(e);
|
|
2723
2833
|
},
|
|
2724
2834
|
onWidgetDragMove: (e) => {
|
|
2725
|
-
S ||
|
|
2835
|
+
S || de(e);
|
|
2726
2836
|
},
|
|
2727
2837
|
onWidgetDragEnd: (e) => {
|
|
2728
|
-
S ||
|
|
2838
|
+
S || U(e);
|
|
2729
2839
|
},
|
|
2730
2840
|
onPlayerStatusChange: (e) => {
|
|
2731
|
-
S || (e === "error" ?
|
|
2841
|
+
S || (e === "error" ? K("Could not load the experience.") : $(a.dataset.state) && K(null));
|
|
2732
2842
|
}
|
|
2733
2843
|
});
|
|
2734
|
-
if (S || e !==
|
|
2844
|
+
if (S || e !== O) {
|
|
2735
2845
|
t.destroy(), b === t && (b = null);
|
|
2736
2846
|
return;
|
|
2737
2847
|
}
|
|
2738
|
-
|
|
2848
|
+
E = !0, t.setWidgetChrome("expanded"), n.on("close", () => {
|
|
2739
2849
|
S || De();
|
|
2740
2850
|
});
|
|
2741
2851
|
} catch (n) {
|
|
2742
|
-
if (S || e !==
|
|
2852
|
+
if (S || e !== O) return;
|
|
2743
2853
|
let r = n instanceof Error ? n : Error(String(n));
|
|
2744
|
-
|
|
2854
|
+
K(r.message), t.onError?.(r), console.error("[ExperienceWidget]", r);
|
|
2745
2855
|
} finally {
|
|
2746
|
-
e ===
|
|
2856
|
+
e === O && (x = !1);
|
|
2747
2857
|
}
|
|
2748
2858
|
})();
|
|
2749
2859
|
}, Fe = () => {
|
|
2750
2860
|
if (!(S || $(a.dataset.state))) {
|
|
2751
|
-
if (b &&
|
|
2861
|
+
if (b && D) {
|
|
2752
2862
|
Ae();
|
|
2753
2863
|
return;
|
|
2754
2864
|
}
|
|
2755
|
-
if (b &&
|
|
2865
|
+
if (b && E) {
|
|
2756
2866
|
je();
|
|
2757
2867
|
return;
|
|
2758
2868
|
}
|
|
2759
|
-
if (
|
|
2760
|
-
|
|
2869
|
+
if (T || b) {
|
|
2870
|
+
J();
|
|
2761
2871
|
return;
|
|
2762
2872
|
}
|
|
2763
2873
|
Pe();
|
|
@@ -2773,26 +2883,26 @@ function bn(e, t) {
|
|
|
2773
2883
|
}, Re = (e) => {
|
|
2774
2884
|
e.stopPropagation(), $(a.dataset.state) && b?.toggleAudioSettings();
|
|
2775
2885
|
}, ze = (e) => {
|
|
2776
|
-
R() === "docked" &&
|
|
2886
|
+
R() === "docked" && pn() && (e.target?.closest("button") || (e.preventDefault(), le(e.clientX, e.clientY, e.pointerId)));
|
|
2777
2887
|
}, Be = (e) => {
|
|
2778
2888
|
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), De());
|
|
2779
2889
|
}, Ve = () => {
|
|
2780
2890
|
if (!S) {
|
|
2781
2891
|
if (R() === "docked") {
|
|
2782
|
-
if (!
|
|
2892
|
+
if (!pn()) {
|
|
2783
2893
|
ke();
|
|
2784
2894
|
return;
|
|
2785
2895
|
}
|
|
2786
|
-
|
|
2896
|
+
D ? G(() => {
|
|
2787
2897
|
fe(!0);
|
|
2788
2898
|
}) : fe(!0);
|
|
2789
2899
|
return;
|
|
2790
2900
|
}
|
|
2791
2901
|
W();
|
|
2792
2902
|
}
|
|
2793
|
-
}, He = typeof window < "u" ? window.matchMedia(
|
|
2903
|
+
}, He = typeof window < "u" ? window.matchMedia(nn) : null, Ue = () => {
|
|
2794
2904
|
if (!S) {
|
|
2795
|
-
if (R() === "docked" && !
|
|
2905
|
+
if (R() === "docked" && !pn()) {
|
|
2796
2906
|
ke();
|
|
2797
2907
|
return;
|
|
2798
2908
|
}
|
|
@@ -2801,9 +2911,9 @@ function bn(e, t) {
|
|
|
2801
2911
|
};
|
|
2802
2912
|
return o.addEventListener("click", Fe), d.addEventListener("click", De), _.addEventListener("click", (e) => {
|
|
2803
2913
|
e.stopPropagation(), De();
|
|
2804
|
-
}), h.addEventListener("click", Ie), g.addEventListener("click", Re), p.addEventListener("pointerdown", ze), window.addEventListener("keydown", Be), window.addEventListener("resize", Ve), He?.addEventListener("change", Ue),
|
|
2914
|
+
}), h.addEventListener("click", Ie), g.addEventListener("click", Re), p.addEventListener("pointerdown", ze), window.addEventListener("keydown", Be), window.addEventListener("resize", Ve), He?.addEventListener("change", Ue), Se(), W(), r === "eager" ? queueMicrotask(() => {
|
|
2805
2915
|
S || Ne();
|
|
2806
|
-
}) : r === "idle" && (
|
|
2916
|
+
}) : r === "idle" && (ee = Sn(() => {
|
|
2807
2917
|
S || Ne();
|
|
2808
2918
|
})), {
|
|
2809
2919
|
root: a,
|
|
@@ -2819,18 +2929,18 @@ function bn(e, t) {
|
|
|
2819
2929
|
Ne();
|
|
2820
2930
|
},
|
|
2821
2931
|
destroy() {
|
|
2822
|
-
S || (S = !0, H(),
|
|
2932
|
+
S || (S = !0, H(), ee?.(), ee = null, re.abort(), A?.(), A = null, window.removeEventListener("keydown", Be), window.removeEventListener("resize", Ve), He?.removeEventListener("change", Ue), Ee(), Te(), e.replaceChildren());
|
|
2823
2933
|
}
|
|
2824
2934
|
};
|
|
2825
2935
|
}
|
|
2826
2936
|
//#endregion
|
|
2827
2937
|
//#region src/react/ExperienceWidget.tsx
|
|
2828
|
-
function
|
|
2829
|
-
let r = n(null), { experienceId: i, alt: o, galleryThumb: s, avatarImage: c, backgroundImage: l, foregroundImage: u, fallbackImage: d, prefetch: f = "onExpand", parallax: p = !0, position: m = "static", offset: h, sessionEndpoint: g, language: _, mode: v, speechInputMode: y, speechOnly: b, fit: x, embedBaseUrl: S, expandedMaxWidth:
|
|
2938
|
+
function wn(t) {
|
|
2939
|
+
let r = n(null), { experienceId: i, alt: o, galleryThumb: s, avatarImage: c, backgroundImage: l, foregroundImage: u, fallbackImage: d, prefetch: f = "onExpand", parallax: p = !0, position: m = "static", offset: h, sessionEndpoint: g, language: _, mode: v, speechInputMode: y, speechOnly: b, fit: x, embedBaseUrl: S, expandedMaxWidth: C, expandedMaxHeight: w, startButtonLabel: T, startButton: E, showFeedback: D, className: O = "", onExpanded: k, onCollapsed: A, onStarted: ee, onClose: j, onError: M, onPrefetchReady: N, onFeedback: P, onFeedbackFailed: F } = t, te = m === "bottom-right" || m === "bottom-left";
|
|
2830
2940
|
return e(() => {
|
|
2831
2941
|
let e = r.current;
|
|
2832
2942
|
if (!e || !i.trim()) return;
|
|
2833
|
-
let t =
|
|
2943
|
+
let t = Cn(e, {
|
|
2834
2944
|
experienceId: i,
|
|
2835
2945
|
alt: o,
|
|
2836
2946
|
galleryThumb: s,
|
|
@@ -2849,16 +2959,19 @@ function xn(t) {
|
|
|
2849
2959
|
speechOnly: b,
|
|
2850
2960
|
fit: x,
|
|
2851
2961
|
embedBaseUrl: S,
|
|
2852
|
-
expandedMaxWidth:
|
|
2853
|
-
expandedMaxHeight:
|
|
2854
|
-
startButtonLabel:
|
|
2855
|
-
startButton:
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2962
|
+
expandedMaxWidth: C,
|
|
2963
|
+
expandedMaxHeight: w,
|
|
2964
|
+
startButtonLabel: T,
|
|
2965
|
+
startButton: E,
|
|
2966
|
+
showFeedback: D,
|
|
2967
|
+
onFeedback: P,
|
|
2968
|
+
onFeedbackFailed: F,
|
|
2969
|
+
onExpanded: k,
|
|
2970
|
+
onCollapsed: A,
|
|
2971
|
+
onStarted: ee,
|
|
2972
|
+
onClose: j,
|
|
2973
|
+
onError: M,
|
|
2974
|
+
onPrefetchReady: N
|
|
2862
2975
|
});
|
|
2863
2976
|
return () => t.destroy();
|
|
2864
2977
|
}, [
|
|
@@ -2880,20 +2993,23 @@ function xn(t) {
|
|
|
2880
2993
|
b,
|
|
2881
2994
|
x,
|
|
2882
2995
|
S,
|
|
2883
|
-
ee,
|
|
2884
2996
|
C,
|
|
2885
2997
|
w,
|
|
2886
2998
|
T,
|
|
2999
|
+
E,
|
|
2887
3000
|
D,
|
|
2888
|
-
|
|
3001
|
+
P,
|
|
3002
|
+
F,
|
|
2889
3003
|
k,
|
|
2890
3004
|
A,
|
|
3005
|
+
ee,
|
|
2891
3006
|
j,
|
|
2892
|
-
M
|
|
3007
|
+
M,
|
|
3008
|
+
N
|
|
2893
3009
|
]), /* @__PURE__ */ a("div", {
|
|
2894
3010
|
ref: r,
|
|
2895
|
-
className:
|
|
2896
|
-
style:
|
|
3011
|
+
className: O,
|
|
3012
|
+
style: te ? { display: "contents" } : {
|
|
2897
3013
|
width: "100%",
|
|
2898
3014
|
height: "100%",
|
|
2899
3015
|
minHeight: "inherit"
|
|
@@ -2901,6 +3017,6 @@ function xn(t) {
|
|
|
2901
3017
|
});
|
|
2902
3018
|
}
|
|
2903
3019
|
//#endregion
|
|
2904
|
-
export {
|
|
3020
|
+
export { pe as ExperienceThumbnail, wn as ExperienceWidget, v as createLiformaSessionRouteHandler };
|
|
2905
3021
|
|
|
2906
3022
|
//# sourceMappingURL=index.js.map
|