@liforma/client 0.4.2 → 0.4.3
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 +6 -0
- package/dist/next/index.js +681 -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 +16 -2
- package/dist/next/v2/experience.d.ts.map +1 -1
- package/dist/next/v2/experienceEvents.d.ts +25 -0
- package/dist/next/v2/experienceEvents.d.ts.map +1 -1
- package/dist/next/v2/shims/embedBaseUrl.d.ts +1 -1
- 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/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 +542 -440
- 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 +16 -2
- package/dist/npm/v2/experience.d.ts.map +1 -1
- package/dist/npm/v2/experienceEvents.d.ts +25 -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 +1 -1
- package/dist/npm/v2/shims/embedBaseUrl.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/sessionManifestSchema.d.ts +1 -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 +17 -1
- package/dist/react/component/experienceComponentTypes.d.ts.map +1 -1
- package/dist/react/index.js +761 -636
- 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 +16 -2
- package/dist/react/v2/experience.d.ts.map +1 -1
- package/dist/react/v2/experienceEvents.d.ts +25 -0
- package/dist/react/v2/experienceEvents.d.ts.map +1 -1
- package/dist/react/v2/shims/embedBaseUrl.d.ts +1 -1
- 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/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 +30 -5
- package/dist/sdk/v2/client.js.map +1 -1
- package/dist/svelte/Experience.svelte +29 -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 }));
|
|
250
252
|
}
|
|
251
|
-
function H(
|
|
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));
|
|
255
|
+
}
|
|
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,47 @@ 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;
|
|
1332
1393
|
}
|
|
1333
|
-
function
|
|
1334
|
-
let
|
|
1335
|
-
|
|
1336
|
-
let
|
|
1337
|
-
return
|
|
1394
|
+
function lt(e, t, n, r, i, a, o, s) {
|
|
1395
|
+
let c = (e ?? ct()).replace(/\/$/, ""), l = c.endsWith("/embed") ? c : `${c}/embed`, u = new URL(l), d = n?.trim();
|
|
1396
|
+
d && u.searchParams.set("locationId", d);
|
|
1397
|
+
let f = r?.trim();
|
|
1398
|
+
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)), ut(u.toString());
|
|
1338
1399
|
}
|
|
1339
|
-
function
|
|
1400
|
+
function ut(e) {
|
|
1340
1401
|
if (typeof location > "u") return e;
|
|
1341
1402
|
let t = new URL(e);
|
|
1342
1403
|
return t.searchParams.set("parentOrigin", location.origin), t.toString();
|
|
1343
1404
|
}
|
|
1344
|
-
function
|
|
1405
|
+
function dt(e) {
|
|
1345
1406
|
return new URL(e).origin;
|
|
1346
1407
|
}
|
|
1347
1408
|
//#endregion
|
|
1348
1409
|
//#region src/v2/experienceEvents.ts
|
|
1349
|
-
function
|
|
1410
|
+
function ft() {
|
|
1350
1411
|
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
1412
|
}
|
|
1352
|
-
function
|
|
1413
|
+
function pt(e, t, n) {
|
|
1353
1414
|
return {
|
|
1354
|
-
id:
|
|
1415
|
+
id: ft(),
|
|
1355
1416
|
type: e,
|
|
1356
1417
|
sessionId: t,
|
|
1357
1418
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1358
1419
|
data: n
|
|
1359
1420
|
};
|
|
1360
1421
|
}
|
|
1361
|
-
function
|
|
1422
|
+
function mt() {
|
|
1362
1423
|
return {
|
|
1363
1424
|
ready: /* @__PURE__ */ new Set(),
|
|
1364
1425
|
started: /* @__PURE__ */ new Set(),
|
|
@@ -1367,46 +1428,49 @@ function pt() {
|
|
|
1367
1428
|
userSpeechEnded: /* @__PURE__ */ new Set(),
|
|
1368
1429
|
characterSpeechStarted: /* @__PURE__ */ new Set(),
|
|
1369
1430
|
characterSpeechEnded: /* @__PURE__ */ new Set(),
|
|
1431
|
+
characterFocusChanged: /* @__PURE__ */ new Set(),
|
|
1370
1432
|
conversationUpdate: /* @__PURE__ */ new Set(),
|
|
1371
1433
|
message: /* @__PURE__ */ new Set(),
|
|
1372
1434
|
listeningState: /* @__PURE__ */ new Set(),
|
|
1373
1435
|
activityChange: /* @__PURE__ */ new Set(),
|
|
1436
|
+
feedback: /* @__PURE__ */ new Set(),
|
|
1437
|
+
feedbackFailed: /* @__PURE__ */ new Set(),
|
|
1374
1438
|
conversationProcessorError: /* @__PURE__ */ new Set()
|
|
1375
1439
|
};
|
|
1376
1440
|
}
|
|
1377
|
-
function
|
|
1441
|
+
function ht(e, t, n) {
|
|
1378
1442
|
return e[t].add(n), () => e[t].delete(n);
|
|
1379
1443
|
}
|
|
1380
|
-
function
|
|
1444
|
+
function gt(e, t, n) {
|
|
1381
1445
|
for (let r of e[t]) r(n);
|
|
1382
1446
|
}
|
|
1383
|
-
function
|
|
1447
|
+
function _t(e) {
|
|
1384
1448
|
for (let t of Object.keys(e)) e[t].clear();
|
|
1385
1449
|
}
|
|
1386
1450
|
//#endregion
|
|
1387
1451
|
//#region src/v2/speech/types.ts
|
|
1388
|
-
function
|
|
1452
|
+
function vt(e) {
|
|
1389
1453
|
return "data" in e && "format" in e && e.format != null && !("track" in e);
|
|
1390
1454
|
}
|
|
1391
|
-
function
|
|
1455
|
+
function yt(e) {
|
|
1392
1456
|
return "url" in e && typeof e.url == "string";
|
|
1393
1457
|
}
|
|
1394
|
-
function
|
|
1458
|
+
function bt(e) {
|
|
1395
1459
|
if (!("track" in e)) return !1;
|
|
1396
1460
|
let t = e.track;
|
|
1397
1461
|
return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
|
|
1398
1462
|
}
|
|
1399
|
-
function
|
|
1400
|
-
return !
|
|
1463
|
+
function xt(e) {
|
|
1464
|
+
return !vt(e) && !yt(e) && !bt(e) && "encoding" in e && typeof e.encoding == "string";
|
|
1401
1465
|
}
|
|
1402
|
-
var
|
|
1466
|
+
var St = [
|
|
1403
1467
|
8e3,
|
|
1404
1468
|
16e3,
|
|
1405
1469
|
22050,
|
|
1406
1470
|
24e3,
|
|
1407
1471
|
44100,
|
|
1408
1472
|
48e3
|
|
1409
|
-
],
|
|
1473
|
+
], Ct = {
|
|
1410
1474
|
MAX_CHUNK_BYTES: 64 * 1024,
|
|
1411
1475
|
RECOMMENDED_CHUNK_MS_MIN: 20,
|
|
1412
1476
|
RECOMMENDED_CHUNK_MS_MAX: 200,
|
|
@@ -1417,14 +1481,14 @@ var xt = [
|
|
|
1417
1481
|
MAX_UTTERANCE_DURATION_MS: 9e4,
|
|
1418
1482
|
MAX_PENDING_WRITES: 8,
|
|
1419
1483
|
DEFAULT_WRITE_TIMEOUT_MS: 5e3
|
|
1420
|
-
},
|
|
1484
|
+
}, wt = class extends Error {
|
|
1421
1485
|
operation;
|
|
1422
1486
|
requiredCapability;
|
|
1423
1487
|
name = "UnsupportedSpeechOperationError";
|
|
1424
1488
|
constructor(e, t) {
|
|
1425
1489
|
super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
|
|
1426
1490
|
}
|
|
1427
|
-
},
|
|
1491
|
+
}, Tt = class extends Error {
|
|
1428
1492
|
name = "SpeechUtteranceClosedError";
|
|
1429
1493
|
constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
|
|
1430
1494
|
super(e);
|
|
@@ -1434,72 +1498,72 @@ var xt = [
|
|
|
1434
1498
|
constructor(e, t) {
|
|
1435
1499
|
super(e, t);
|
|
1436
1500
|
}
|
|
1437
|
-
},
|
|
1501
|
+
}, Et = class extends Error {
|
|
1438
1502
|
name = "SpeechBufferTimeoutError";
|
|
1439
1503
|
constructor(e = "Timed out waiting for speech buffer capacity.") {
|
|
1440
1504
|
super(e);
|
|
1441
1505
|
}
|
|
1442
1506
|
};
|
|
1443
|
-
function
|
|
1507
|
+
function Dt(e = "none") {
|
|
1444
1508
|
return {
|
|
1445
1509
|
mode: e,
|
|
1446
1510
|
trackedDurationMs: 0,
|
|
1447
1511
|
fallbackDurationMs: 0
|
|
1448
1512
|
};
|
|
1449
1513
|
}
|
|
1450
|
-
function Dt(e) {
|
|
1451
|
-
return xt.includes(e);
|
|
1452
|
-
}
|
|
1453
1514
|
function Ot(e) {
|
|
1515
|
+
return St.includes(e);
|
|
1516
|
+
}
|
|
1517
|
+
function kt(e) {
|
|
1454
1518
|
if (e.encoding !== "pcm_s16le") throw new Q(`Unsupported audio encoding: ${e.encoding}`);
|
|
1455
1519
|
if (e.channels !== 1) throw new Q(`Unsupported channel count: ${e.channels}`);
|
|
1456
|
-
if (!
|
|
1520
|
+
if (!Ot(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1457
1521
|
}
|
|
1458
|
-
function
|
|
1459
|
-
if (
|
|
1460
|
-
|
|
1522
|
+
function At(e) {
|
|
1523
|
+
if (vt(e)) {
|
|
1524
|
+
kt(e.format);
|
|
1461
1525
|
return;
|
|
1462
1526
|
}
|
|
1463
|
-
if (
|
|
1527
|
+
if (yt(e)) {
|
|
1464
1528
|
if (!e.url.trim()) throw new Q("Audio URL must be non-empty.");
|
|
1465
|
-
if (e.sampleRate !== void 0 && !
|
|
1529
|
+
if (e.sampleRate !== void 0 && !Ot(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1466
1530
|
return;
|
|
1467
1531
|
}
|
|
1468
|
-
if (
|
|
1532
|
+
if (bt(e)) {
|
|
1469
1533
|
if (e.track.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
1470
|
-
if (e.sampleRate !== void 0 && !
|
|
1534
|
+
if (e.sampleRate !== void 0 && !Ot(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1471
1535
|
return;
|
|
1472
1536
|
}
|
|
1473
|
-
if (
|
|
1537
|
+
if (xt(e)) {
|
|
1474
1538
|
let t = e.encoding.trim().toLowerCase();
|
|
1475
1539
|
if (!t) throw new Q("Encoded audio MIME type is required.");
|
|
1476
1540
|
if (t === "pcm_s16le") throw new Q("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
|
|
1477
|
-
if (e.sampleRate !== void 0 && !
|
|
1541
|
+
if (e.sampleRate !== void 0 && !Ot(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
|
|
1478
1542
|
return;
|
|
1479
1543
|
}
|
|
1480
1544
|
throw new Q("Unsupported speech.play audio shape.");
|
|
1481
1545
|
}
|
|
1482
|
-
function
|
|
1483
|
-
if (e.format) return
|
|
1546
|
+
function jt(e) {
|
|
1547
|
+
if (e.format) return kt(e.format), e.format;
|
|
1484
1548
|
if (e.track) {
|
|
1485
1549
|
let t = {
|
|
1486
1550
|
encoding: "pcm_s16le",
|
|
1487
1551
|
sampleRate: e.sampleRate ?? 24e3,
|
|
1488
1552
|
channels: 1
|
|
1489
1553
|
};
|
|
1490
|
-
return
|
|
1554
|
+
return kt(t), t;
|
|
1491
1555
|
}
|
|
1492
1556
|
throw new Q("createUtterance requires format or track.");
|
|
1493
1557
|
}
|
|
1494
|
-
function
|
|
1558
|
+
function Mt(e) {
|
|
1495
1559
|
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1496
1560
|
}
|
|
1497
|
-
function
|
|
1561
|
+
function Nt(e) {
|
|
1498
1562
|
return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
|
|
1499
1563
|
}
|
|
1500
1564
|
//#endregion
|
|
1501
1565
|
//#region src/byo/pcm.ts
|
|
1502
|
-
function
|
|
1566
|
+
function Pt(e) {
|
|
1503
1567
|
let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
|
|
1504
1568
|
for (let t = 0; t < e.length; t++) {
|
|
1505
1569
|
let r = Math.max(-1, Math.min(1, e[t]));
|
|
@@ -1509,11 +1573,11 @@ function Nt(e) {
|
|
|
1509
1573
|
}
|
|
1510
1574
|
//#endregion
|
|
1511
1575
|
//#region src/byo/resample.ts
|
|
1512
|
-
function
|
|
1576
|
+
function Ft(e, t, n, r, i) {
|
|
1513
1577
|
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
1578
|
return ((a * i + o) * i + s) * i + c;
|
|
1515
1579
|
}
|
|
1516
|
-
function
|
|
1580
|
+
function It(e, t) {
|
|
1517
1581
|
if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
|
|
1518
1582
|
if (e === t) return {
|
|
1519
1583
|
fromRate: e,
|
|
@@ -1536,7 +1600,7 @@ function Ft(e, t) {
|
|
|
1536
1600
|
let a = [];
|
|
1537
1601
|
for (; i + 2 < r.length - 1;) {
|
|
1538
1602
|
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(
|
|
1603
|
+
a.push(Ft(r[o], r[e], r[s], r[c], t)), i += n;
|
|
1540
1604
|
}
|
|
1541
1605
|
let o = Math.max(0, Math.floor(i) - 1);
|
|
1542
1606
|
return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
|
|
@@ -1548,7 +1612,7 @@ function Ft(e, t) {
|
|
|
1548
1612
|
}
|
|
1549
1613
|
//#endregion
|
|
1550
1614
|
//#region src/byo/audioCapture.ts
|
|
1551
|
-
var
|
|
1615
|
+
var Lt = "liforma-pcm-capture", Rt = `
|
|
1552
1616
|
class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
1553
1617
|
process(inputs) {
|
|
1554
1618
|
const ch = inputs[0] && inputs[0][0];
|
|
@@ -1560,29 +1624,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
|
|
|
1560
1624
|
return true;
|
|
1561
1625
|
}
|
|
1562
1626
|
}
|
|
1563
|
-
registerProcessor('${
|
|
1564
|
-
`,
|
|
1565
|
-
function zt() {
|
|
1566
|
-
return Rt ||= URL.createObjectURL(new Blob([Lt], { type: "application/javascript" })), Rt;
|
|
1567
|
-
}
|
|
1627
|
+
registerProcessor('${Lt}', LiformaPcmCaptureProcessor);
|
|
1628
|
+
`, zt = null;
|
|
1568
1629
|
function Bt() {
|
|
1630
|
+
return zt ||= URL.createObjectURL(new Blob([Rt], { type: "application/javascript" })), zt;
|
|
1631
|
+
}
|
|
1632
|
+
function Vt() {
|
|
1569
1633
|
return window.AudioContext || window.webkitAudioContext || null;
|
|
1570
1634
|
}
|
|
1571
|
-
async function
|
|
1572
|
-
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o =
|
|
1635
|
+
async function Ht(e) {
|
|
1636
|
+
let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = Vt();
|
|
1573
1637
|
if (!o) throw Error("Web Audio is required for audio capture");
|
|
1574
1638
|
let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
|
|
1575
1639
|
l.gain.value = 0;
|
|
1576
|
-
let u = s.sampleRate, d =
|
|
1640
|
+
let u = s.sampleRate, d = It(u, n), f = !1, p = !1, m = (e) => {
|
|
1577
1641
|
if (f || i && !i()) return;
|
|
1578
1642
|
let t = d.push(e);
|
|
1579
|
-
t.length !== 0 && r(
|
|
1643
|
+
t.length !== 0 && r(Pt(t));
|
|
1580
1644
|
}, h = () => void 0;
|
|
1581
1645
|
return await (async () => {
|
|
1582
1646
|
if (typeof s.audioWorklet?.addModule != "function") return !1;
|
|
1583
1647
|
try {
|
|
1584
|
-
await s.audioWorklet.addModule(
|
|
1585
|
-
let e = new AudioWorkletNode(s,
|
|
1648
|
+
await s.audioWorklet.addModule(Bt());
|
|
1649
|
+
let e = new AudioWorkletNode(s, Lt, {
|
|
1586
1650
|
numberOfInputs: 1,
|
|
1587
1651
|
numberOfOutputs: 1,
|
|
1588
1652
|
outputChannelCount: [1]
|
|
@@ -1632,7 +1696,7 @@ async function Vt(e) {
|
|
|
1632
1696
|
}
|
|
1633
1697
|
//#endregion
|
|
1634
1698
|
//#region src/v2/speech/captureMediaStreamTrack.ts
|
|
1635
|
-
async function
|
|
1699
|
+
async function Ut(e) {
|
|
1636
1700
|
let { track: t, utterance: n, sampleRate: r, signal: i } = e;
|
|
1637
1701
|
if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Q("MediaStreamTrack is not available in this environment.");
|
|
1638
1702
|
if (t.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
|
|
@@ -1641,18 +1705,18 @@ async function Ht(e) {
|
|
|
1641
1705
|
s || (s = !0, c?.stop(), c = null);
|
|
1642
1706
|
};
|
|
1643
1707
|
try {
|
|
1644
|
-
c = await
|
|
1708
|
+
c = await Ht({
|
|
1645
1709
|
mediaStream: a,
|
|
1646
1710
|
targetSampleRate: r,
|
|
1647
1711
|
shouldSend: () => !s && !i?.aborted,
|
|
1648
1712
|
onPcm: (e) => {
|
|
1649
1713
|
if (s || i?.aborted) return;
|
|
1650
|
-
let t =
|
|
1714
|
+
let t = Mt(e);
|
|
1651
1715
|
o = o.then(async () => {
|
|
1652
1716
|
if (s || i?.aborted) return;
|
|
1653
1717
|
let e = 0;
|
|
1654
1718
|
for (; e < t.byteLength;) {
|
|
1655
|
-
let r = Math.min(e +
|
|
1719
|
+
let r = Math.min(e + Ct.MAX_CHUNK_BYTES, t.byteLength);
|
|
1656
1720
|
if ((r - e) % 2 == 1 && --r, r <= e) break;
|
|
1657
1721
|
let i = t.subarray(e, r);
|
|
1658
1722
|
e = r, i.byteLength !== 0 && await n.write(i);
|
|
@@ -1676,10 +1740,10 @@ async function Ht(e) {
|
|
|
1676
1740
|
}
|
|
1677
1741
|
//#endregion
|
|
1678
1742
|
//#region src/v2/speech/speechController.ts
|
|
1679
|
-
async function
|
|
1680
|
-
if (
|
|
1681
|
-
if (
|
|
1682
|
-
let t =
|
|
1743
|
+
async function Wt(e, t) {
|
|
1744
|
+
if (bt(e)) throw new Q("MediaStreamTrack play is handled on the host before embed.");
|
|
1745
|
+
if (vt(e)) {
|
|
1746
|
+
let t = Mt(e.data);
|
|
1683
1747
|
if (t.byteLength & 1) throw new Q("PCM byte length must be even.");
|
|
1684
1748
|
return {
|
|
1685
1749
|
kind: "pcm",
|
|
@@ -1687,17 +1751,17 @@ async function Ut(e, t) {
|
|
|
1687
1751
|
format: e.format
|
|
1688
1752
|
};
|
|
1689
1753
|
}
|
|
1690
|
-
if (
|
|
1754
|
+
if (yt(e)) return {
|
|
1691
1755
|
kind: "url",
|
|
1692
1756
|
url: e.url.trim(),
|
|
1693
1757
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
1694
1758
|
};
|
|
1695
|
-
if (!
|
|
1759
|
+
if (!xt(e)) throw new Q("Unsupported speech.play audio shape.");
|
|
1696
1760
|
let n;
|
|
1697
1761
|
if (typeof Blob < "u" && e.data instanceof Blob) {
|
|
1698
1762
|
if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
1699
1763
|
n = new Uint8Array(await e.data.arrayBuffer());
|
|
1700
|
-
} else n =
|
|
1764
|
+
} else n = Mt(e.data);
|
|
1701
1765
|
return {
|
|
1702
1766
|
kind: "encoded",
|
|
1703
1767
|
data: n.slice().buffer,
|
|
@@ -1705,10 +1769,10 @@ async function Ut(e, t) {
|
|
|
1705
1769
|
...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
|
|
1706
1770
|
};
|
|
1707
1771
|
}
|
|
1708
|
-
function
|
|
1772
|
+
function Gt() {
|
|
1709
1773
|
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
1774
|
}
|
|
1711
|
-
function
|
|
1775
|
+
function Kt(e, t = "completed") {
|
|
1712
1776
|
return {
|
|
1713
1777
|
utteranceId: e.speechId,
|
|
1714
1778
|
characterId: e.characterId,
|
|
@@ -1722,13 +1786,13 @@ function Gt(e, t = "completed") {
|
|
|
1722
1786
|
}
|
|
1723
1787
|
};
|
|
1724
1788
|
}
|
|
1725
|
-
function
|
|
1789
|
+
function qt(e) {
|
|
1726
1790
|
return e instanceof Error ? e : new Q(String(e));
|
|
1727
1791
|
}
|
|
1728
|
-
function
|
|
1792
|
+
function Jt(e) {
|
|
1729
1793
|
return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
|
|
1730
1794
|
}
|
|
1731
|
-
var
|
|
1795
|
+
var Yt = class {
|
|
1732
1796
|
id;
|
|
1733
1797
|
characterId;
|
|
1734
1798
|
result;
|
|
@@ -1757,29 +1821,29 @@ var Jt = class {
|
|
|
1757
1821
|
queue: e.queue,
|
|
1758
1822
|
...e.transcript === void 0 ? {} : { transcript: e.transcript }
|
|
1759
1823
|
}).catch((e) => {
|
|
1760
|
-
throw this.fail(
|
|
1824
|
+
throw this.fail(qt(e)), qt(e);
|
|
1761
1825
|
}), this.signal?.addEventListener("abort", () => {
|
|
1762
1826
|
this.cancel();
|
|
1763
1827
|
}, { once: !0 });
|
|
1764
1828
|
}
|
|
1765
1829
|
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 =
|
|
1830
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new Tt();
|
|
1831
|
+
let n = Mt(e);
|
|
1768
1832
|
if (n.byteLength & 1) throw new Q("PCM chunk byte length must be even (complete s16 samples).");
|
|
1769
|
-
if (n.byteLength >
|
|
1833
|
+
if (n.byteLength > Ct.MAX_CHUNK_BYTES) throw new Q(`PCM chunk exceeds MAX_CHUNK_BYTES (${Ct.MAX_CHUNK_BYTES}).`);
|
|
1770
1834
|
if (n.byteLength === 0) return;
|
|
1771
|
-
let r = t?.timeoutMs ??
|
|
1835
|
+
let r = t?.timeoutMs ?? Ct.DEFAULT_WRITE_TIMEOUT_MS;
|
|
1772
1836
|
await this.acquireWriteSlot(r);
|
|
1773
1837
|
let i = n.byteLength / 2 / this.sampleRate * 1e3;
|
|
1774
|
-
if (this.bufferedMs + i >
|
|
1838
|
+
if (this.bufferedMs + i > Ct.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new Q("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
|
|
1775
1839
|
let a = async () => {
|
|
1776
|
-
if (this.closed || this.settled) throw new
|
|
1840
|
+
if (this.closed || this.settled) throw new Tt();
|
|
1777
1841
|
let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
|
|
1778
1842
|
utteranceId: this.id,
|
|
1779
1843
|
audio: t.buffer,
|
|
1780
1844
|
byteLength: t.byteLength
|
|
1781
1845
|
}), a = await Promise.race([i, new Promise((e, t) => {
|
|
1782
|
-
setTimeout(() => t(new
|
|
1846
|
+
setTimeout(() => t(new Et()), r);
|
|
1783
1847
|
})]);
|
|
1784
1848
|
this.bufferedMs = Math.max(0, a.bufferedMs);
|
|
1785
1849
|
}, o = this.writeChain.then(a, a);
|
|
@@ -1791,7 +1855,7 @@ var Jt = class {
|
|
|
1791
1855
|
}
|
|
1792
1856
|
}
|
|
1793
1857
|
async setTranscript(e) {
|
|
1794
|
-
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new
|
|
1858
|
+
if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new Tt();
|
|
1795
1859
|
await this.requireHost().speechUtteranceSetTranscript({
|
|
1796
1860
|
utteranceId: this.id,
|
|
1797
1861
|
transcript: e
|
|
@@ -1808,7 +1872,7 @@ var Jt = class {
|
|
|
1808
1872
|
});
|
|
1809
1873
|
return this.resolve(t), t;
|
|
1810
1874
|
} catch (e) {
|
|
1811
|
-
let t =
|
|
1875
|
+
let t = qt(e);
|
|
1812
1876
|
throw this.fail(t), t;
|
|
1813
1877
|
}
|
|
1814
1878
|
}
|
|
@@ -1826,11 +1890,11 @@ var Jt = class {
|
|
|
1826
1890
|
characterId: this.characterId,
|
|
1827
1891
|
status: "cancelled",
|
|
1828
1892
|
durationMs: 0,
|
|
1829
|
-
animation:
|
|
1893
|
+
animation: Dt("none")
|
|
1830
1894
|
};
|
|
1831
1895
|
return this.resolve(t), t;
|
|
1832
1896
|
} catch (e) {
|
|
1833
|
-
let t =
|
|
1897
|
+
let t = qt(e);
|
|
1834
1898
|
throw this.fail(t), t;
|
|
1835
1899
|
}
|
|
1836
1900
|
}
|
|
@@ -1843,19 +1907,19 @@ var Jt = class {
|
|
|
1843
1907
|
return e;
|
|
1844
1908
|
}
|
|
1845
1909
|
resolve(e) {
|
|
1846
|
-
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new
|
|
1910
|
+
this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new Tt()));
|
|
1847
1911
|
}
|
|
1848
1912
|
fail(e) {
|
|
1849
1913
|
this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
|
|
1850
1914
|
}
|
|
1851
1915
|
async acquireWriteSlot(e) {
|
|
1852
|
-
if (this.pendingWriteCount <
|
|
1916
|
+
if (this.pendingWriteCount < Ct.MAX_PENDING_WRITES) {
|
|
1853
1917
|
this.pendingWriteCount += 1;
|
|
1854
1918
|
return;
|
|
1855
1919
|
}
|
|
1856
1920
|
await new Promise((t, n) => {
|
|
1857
1921
|
let r = setTimeout(() => {
|
|
1858
|
-
n(new
|
|
1922
|
+
n(new Et());
|
|
1859
1923
|
}, e);
|
|
1860
1924
|
this.pendingWriteWaiters.push({
|
|
1861
1925
|
resolve: () => {
|
|
@@ -1874,13 +1938,13 @@ var Jt = class {
|
|
|
1874
1938
|
for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
|
|
1875
1939
|
}
|
|
1876
1940
|
};
|
|
1877
|
-
function
|
|
1941
|
+
function Xt(e) {
|
|
1878
1942
|
let t = null, n = (t, n) => {
|
|
1879
|
-
if (!e.getCapabilities()[n]) throw new
|
|
1943
|
+
if (!e.getCapabilities()[n]) throw new wt(t, n);
|
|
1880
1944
|
}, r = {
|
|
1881
1945
|
async speak(r) {
|
|
1882
1946
|
if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
|
|
1883
|
-
let i =
|
|
1947
|
+
let i = Nt(r.queue ?? "append");
|
|
1884
1948
|
i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
|
|
1885
1949
|
let a = e.getIframeHost();
|
|
1886
1950
|
if (!a) throw new Q("Speech session is not attached.");
|
|
@@ -1900,41 +1964,41 @@ function Yt(e) {
|
|
|
1900
1964
|
return;
|
|
1901
1965
|
}
|
|
1902
1966
|
t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
|
|
1903
|
-
t.removeEventListener("abort", s), n(
|
|
1967
|
+
t.removeEventListener("abort", s), n(Kt(e, "completed"));
|
|
1904
1968
|
}, (a) => {
|
|
1905
|
-
if (t.removeEventListener("abort", s),
|
|
1969
|
+
if (t.removeEventListener("abort", s), Jt(a)) {
|
|
1906
1970
|
n({
|
|
1907
1971
|
utteranceId: "utt_interrupted",
|
|
1908
1972
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
1909
1973
|
status: "interrupted",
|
|
1910
1974
|
durationMs: 0,
|
|
1911
1975
|
transcript: r.text,
|
|
1912
|
-
animation:
|
|
1976
|
+
animation: Dt("none")
|
|
1913
1977
|
});
|
|
1914
1978
|
return;
|
|
1915
1979
|
}
|
|
1916
|
-
i(
|
|
1980
|
+
i(qt(a));
|
|
1917
1981
|
});
|
|
1918
1982
|
});
|
|
1919
1983
|
}
|
|
1920
1984
|
try {
|
|
1921
|
-
return
|
|
1985
|
+
return Kt(await o, "completed");
|
|
1922
1986
|
} catch (t) {
|
|
1923
|
-
if (
|
|
1987
|
+
if (Jt(t)) return {
|
|
1924
1988
|
utteranceId: "utt_interrupted",
|
|
1925
1989
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
1926
1990
|
status: "interrupted",
|
|
1927
1991
|
durationMs: 0,
|
|
1928
1992
|
transcript: r.text,
|
|
1929
|
-
animation:
|
|
1993
|
+
animation: Dt("none")
|
|
1930
1994
|
};
|
|
1931
|
-
throw
|
|
1995
|
+
throw qt(t);
|
|
1932
1996
|
}
|
|
1933
1997
|
},
|
|
1934
1998
|
async play(i) {
|
|
1935
|
-
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"),
|
|
1999
|
+
if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), At(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
|
|
1936
2000
|
let a = i.queue ?? "append";
|
|
1937
|
-
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)),
|
|
2001
|
+
if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), bt(i.audio)) {
|
|
1938
2002
|
let e = i.audio.sampleRate ?? 24e3;
|
|
1939
2003
|
return r.createUtterance({
|
|
1940
2004
|
format: {
|
|
@@ -1950,7 +2014,7 @@ function Yt(e) {
|
|
|
1950
2014
|
}
|
|
1951
2015
|
let o = e.getIframeHost();
|
|
1952
2016
|
if (!o) throw new Q("Speech session is not attached.");
|
|
1953
|
-
let s = await
|
|
2017
|
+
let s = await Wt(i.audio, i.signal);
|
|
1954
2018
|
return o.speechPlay({
|
|
1955
2019
|
source: s,
|
|
1956
2020
|
characterId: i.characterId,
|
|
@@ -1962,13 +2026,13 @@ function Yt(e) {
|
|
|
1962
2026
|
},
|
|
1963
2027
|
createUtterance(r) {
|
|
1964
2028
|
e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
|
|
1965
|
-
let i =
|
|
2029
|
+
let i = jt(r);
|
|
1966
2030
|
if (r.track && r.track.kind !== "audio") throw new Q("createUtterance track must be an audio MediaStreamTrack.");
|
|
1967
2031
|
let a = r.queue ?? "replace-active";
|
|
1968
2032
|
if (a !== "replace-active" && a !== "replace-all") throw new Q("createUtterance queue must be replace-active or replace-all.");
|
|
1969
2033
|
e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
|
|
1970
|
-
let o = new
|
|
1971
|
-
id:
|
|
2034
|
+
let o = new Yt({
|
|
2035
|
+
id: Gt(),
|
|
1972
2036
|
characterId: r.characterId ?? e.getActiveCharacterId(),
|
|
1973
2037
|
format: i,
|
|
1974
2038
|
queue: a,
|
|
@@ -1980,7 +2044,7 @@ function Yt(e) {
|
|
|
1980
2044
|
t === o && (t = null);
|
|
1981
2045
|
}), r.track && (async () => {
|
|
1982
2046
|
try {
|
|
1983
|
-
if (await
|
|
2047
|
+
if (await Ut({
|
|
1984
2048
|
track: r.track,
|
|
1985
2049
|
utterance: o,
|
|
1986
2050
|
sampleRate: i.sampleRate,
|
|
@@ -2007,11 +2071,17 @@ function Yt(e) {
|
|
|
2007
2071
|
return r;
|
|
2008
2072
|
}
|
|
2009
2073
|
//#endregion
|
|
2074
|
+
//#region src/v2/types/sessionInteraction.ts
|
|
2075
|
+
function Zt(e) {
|
|
2076
|
+
let t = e?.trim();
|
|
2077
|
+
return t === "full" || t === "face" || t === "medium" ? t : void 0;
|
|
2078
|
+
}
|
|
2079
|
+
//#endregion
|
|
2010
2080
|
//#region src/v2/experience.ts
|
|
2011
|
-
function
|
|
2081
|
+
function Qt(e) {
|
|
2012
2082
|
return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
|
|
2013
2083
|
}
|
|
2014
|
-
var
|
|
2084
|
+
var $t = class e {
|
|
2015
2085
|
bootstrap;
|
|
2016
2086
|
conversationProcessor;
|
|
2017
2087
|
iframeHost = null;
|
|
@@ -2024,17 +2094,18 @@ var Zt = class e {
|
|
|
2024
2094
|
attachReturnUrl = null;
|
|
2025
2095
|
closed = !1;
|
|
2026
2096
|
attached = !1;
|
|
2097
|
+
pendingFit = null;
|
|
2027
2098
|
closeHandlers = [];
|
|
2028
|
-
eventRegistry =
|
|
2099
|
+
eventRegistry = mt();
|
|
2029
2100
|
readyEnvelope = null;
|
|
2030
2101
|
startedEnvelope = null;
|
|
2031
2102
|
conversationCache = [];
|
|
2032
2103
|
speech;
|
|
2033
2104
|
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 =
|
|
2105
|
+
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 = Xt({
|
|
2035
2106
|
getIframeHost: () => this.iframeHost,
|
|
2036
2107
|
assertSessionStarted: () => this.assertSessionStarted(),
|
|
2037
|
-
getCapabilities: () =>
|
|
2108
|
+
getCapabilities: () => en(this.resolvedSession),
|
|
2038
2109
|
getActiveCharacterId: () => "character_unknown",
|
|
2039
2110
|
onProcessorInterrupt: () => {
|
|
2040
2111
|
this.processorAbortController?.abort(), this.processorAbortController = null;
|
|
@@ -2068,6 +2139,7 @@ var Zt = class e {
|
|
|
2068
2139
|
language: t.language,
|
|
2069
2140
|
locationId: t.locationId,
|
|
2070
2141
|
avatarId: t.avatarId,
|
|
2142
|
+
castSize: t.castSize,
|
|
2071
2143
|
embedBaseUrl: t.embedBaseUrl,
|
|
2072
2144
|
debug: t.debug,
|
|
2073
2145
|
mode: t.mode,
|
|
@@ -2087,6 +2159,7 @@ var Zt = class e {
|
|
|
2087
2159
|
language: t.language,
|
|
2088
2160
|
locationId: t.locationId,
|
|
2089
2161
|
avatarId: t.avatarId,
|
|
2162
|
+
castSize: t.castSize,
|
|
2090
2163
|
embedBaseUrl: t.embedBaseUrl,
|
|
2091
2164
|
debug: t.debug,
|
|
2092
2165
|
mode: t.mode,
|
|
@@ -2106,7 +2179,7 @@ var Zt = class e {
|
|
|
2106
2179
|
return null;
|
|
2107
2180
|
}
|
|
2108
2181
|
on(e, t) {
|
|
2109
|
-
let n =
|
|
2182
|
+
let n = ht(this.eventRegistry, e, t);
|
|
2110
2183
|
return e === "ready" && this.readyEnvelope && queueMicrotask(() => t(this.readyEnvelope)), e === "started" && this.startedEnvelope && queueMicrotask(() => t(this.startedEnvelope)), n;
|
|
2111
2184
|
}
|
|
2112
2185
|
async attach(e) {
|
|
@@ -2120,13 +2193,13 @@ var Zt = class e {
|
|
|
2120
2193
|
if (this.closed) throw Error("Session has ended.");
|
|
2121
2194
|
if (this.attached && this.iframeHost) return this.createPlayerFacade();
|
|
2122
2195
|
this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
|
|
2123
|
-
let t = this.bootstrap.embedBaseUrl ??
|
|
2196
|
+
let t = this.bootstrap.embedBaseUrl ?? ct(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = lt(t, n, r || this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.locationId, r || this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, Qt(e), this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.castSize), a = dt(i), o = null, s = new Promise((e) => {
|
|
2124
2197
|
o = e;
|
|
2125
2198
|
}), c = null, l = new Promise((e) => {
|
|
2126
2199
|
c = e;
|
|
2127
|
-
}), u =
|
|
2200
|
+
}), u = it((e) => {
|
|
2128
2201
|
this.readyEnvelope ||= (this.resolvedSession = e, this.emitWrapped("ready", { session: e }));
|
|
2129
|
-
}), d = this.bootstrap.onUserTranscript, f =
|
|
2202
|
+
}), d = this.bootstrap.onUserTranscript, f = rt({
|
|
2130
2203
|
container: e.container,
|
|
2131
2204
|
src: i,
|
|
2132
2205
|
playerOrigin: a,
|
|
@@ -2156,12 +2229,21 @@ var Zt = class e {
|
|
|
2156
2229
|
onCharacterSpeechEnded: (e) => {
|
|
2157
2230
|
this.emitWrapped("characterSpeechEnded", e);
|
|
2158
2231
|
},
|
|
2232
|
+
onCharacterFocusChanged: (e) => {
|
|
2233
|
+
this.emitWrapped("characterFocusChanged", e);
|
|
2234
|
+
},
|
|
2159
2235
|
onListeningState: (e) => {
|
|
2160
2236
|
this.emitWrapped("listeningState", e);
|
|
2161
2237
|
},
|
|
2162
2238
|
onActivityChange: (e) => {
|
|
2163
2239
|
this.emitWrapped("activityChange", e);
|
|
2164
2240
|
},
|
|
2241
|
+
onFeedback: (e) => {
|
|
2242
|
+
this.emitWrapped("feedback", e);
|
|
2243
|
+
},
|
|
2244
|
+
onFeedbackFailed: (e) => {
|
|
2245
|
+
this.emitWrapped("feedbackFailed", e);
|
|
2246
|
+
},
|
|
2165
2247
|
onMessage: (e) => {
|
|
2166
2248
|
this.emitWrapped("message", e);
|
|
2167
2249
|
},
|
|
@@ -2180,7 +2262,7 @@ var Zt = class e {
|
|
|
2180
2262
|
onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t)
|
|
2181
2263
|
});
|
|
2182
2264
|
this.iframeHost = f;
|
|
2183
|
-
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(),
|
|
2265
|
+
let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), ze(this.bootstrap.sessionEndpoint, {
|
|
2184
2266
|
experienceId: this.bootstrap.experienceId,
|
|
2185
2267
|
locale: this.bootstrap.locale,
|
|
2186
2268
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
@@ -2190,7 +2272,7 @@ var Zt = class e {
|
|
|
2190
2272
|
speechInputMode: p.speechInputMode,
|
|
2191
2273
|
speechOnly: this.bootstrap.speechOnly,
|
|
2192
2274
|
signal: this.endpointAbortController.signal
|
|
2193
|
-
})) : this.bootstrap.kind === "public" ?
|
|
2275
|
+
})) : this.bootstrap.kind === "public" ? Re(this.bootstrap.experienceId, {
|
|
2194
2276
|
locale: this.bootstrap.locale,
|
|
2195
2277
|
secondaryLocale: this.bootstrap.secondaryLocale,
|
|
2196
2278
|
learningLocale: this.bootstrap.learningLocale,
|
|
@@ -2212,11 +2294,17 @@ var Zt = class e {
|
|
|
2212
2294
|
f.postParentHello();
|
|
2213
2295
|
let g = h?.launch ?? (this.bootstrap.kind === "launch" ? this.bootstrap.launch : null), _ = h?.session ?? (this.bootstrap.kind === "launch" ? this.bootstrap.session : void 0);
|
|
2214
2296
|
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" &&
|
|
2297
|
+
return this.launchToken = g, _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" && Ae(_), f.postLaunch(g, _, {
|
|
2298
|
+
startButton: e.startButton,
|
|
2299
|
+
showFeedback: e.showFeedback
|
|
2300
|
+
}), u.setValue(_)) : f.postLaunch(g, void 0, {
|
|
2301
|
+
startButton: e.startButton,
|
|
2302
|
+
showFeedback: e.showFeedback
|
|
2303
|
+
}), await Promise.race([s, new Promise((e, t) => {
|
|
2216
2304
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player loading UI.")), 12e4);
|
|
2217
2305
|
})]), await Promise.race([l, new Promise((e, t) => {
|
|
2218
2306
|
setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player ready state.")), 12e4);
|
|
2219
|
-
})]), this.attached = !0, this.createPlayerFacade();
|
|
2307
|
+
})]), this.attached = !0, this.pendingFit && await f.setFit(this.pendingFit), this.createPlayerFacade();
|
|
2220
2308
|
}
|
|
2221
2309
|
async startListening() {
|
|
2222
2310
|
this.assertSessionStarted(), await this.iframeHost.startListening();
|
|
@@ -2236,6 +2324,15 @@ var Zt = class e {
|
|
|
2236
2324
|
toggleAudioSettings() {
|
|
2237
2325
|
this.iframeHost?.postWidgetToggleAudioSettings();
|
|
2238
2326
|
}
|
|
2327
|
+
async focusCharacter(e) {
|
|
2328
|
+
this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
|
|
2329
|
+
}
|
|
2330
|
+
async setFit(e) {
|
|
2331
|
+
let t = Zt(e);
|
|
2332
|
+
if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
|
|
2333
|
+
if (this.closed) throw Error("Session has ended.");
|
|
2334
|
+
this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
|
|
2335
|
+
}
|
|
2239
2336
|
getLastTurn() {
|
|
2240
2337
|
if (this.conversationCache.length === 0) return [];
|
|
2241
2338
|
let e = this.conversationCache[this.conversationCache.length - 1].turnId;
|
|
@@ -2245,7 +2342,7 @@ var Zt = class e {
|
|
|
2245
2342
|
this.close();
|
|
2246
2343
|
}
|
|
2247
2344
|
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,
|
|
2345
|
+
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, _t(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.attached = !1);
|
|
2249
2346
|
}
|
|
2250
2347
|
resolveMintInteraction() {
|
|
2251
2348
|
return this.bootstrap.kind === "launch" ? {} : {
|
|
@@ -2257,8 +2354,8 @@ var Zt = class e {
|
|
|
2257
2354
|
return this.resolvedSession?.id ?? "";
|
|
2258
2355
|
}
|
|
2259
2356
|
emitWrapped(e, t) {
|
|
2260
|
-
let n =
|
|
2261
|
-
return
|
|
2357
|
+
let n = pt(e, this.getSessionId(), t);
|
|
2358
|
+
return gt(this.eventRegistry, e, n), n;
|
|
2262
2359
|
}
|
|
2263
2360
|
queueProcessorTurn(e) {
|
|
2264
2361
|
if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
|
|
@@ -2267,7 +2364,7 @@ var Zt = class e {
|
|
|
2267
2364
|
let n = this.processorAbortController.signal;
|
|
2268
2365
|
this.processorChain = this.processorChain.then(async () => {
|
|
2269
2366
|
if (!n.aborted) try {
|
|
2270
|
-
let r = await
|
|
2367
|
+
let r = await He(t, {
|
|
2271
2368
|
utteranceId: e.utteranceId,
|
|
2272
2369
|
text: e.text,
|
|
2273
2370
|
conversation: this.conversationCache,
|
|
@@ -2317,7 +2414,7 @@ var Zt = class e {
|
|
|
2317
2414
|
};
|
|
2318
2415
|
}
|
|
2319
2416
|
};
|
|
2320
|
-
function
|
|
2417
|
+
function en(e) {
|
|
2321
2418
|
return e ? {
|
|
2322
2419
|
textSpeech: e.capabilities.speech.output,
|
|
2323
2420
|
externalSpeechAudio: e.capabilities.speech.externalAudio
|
|
@@ -2328,41 +2425,41 @@ function Qt(e) {
|
|
|
2328
2425
|
}
|
|
2329
2426
|
//#endregion
|
|
2330
2427
|
//#region src/widget/dockGeometry.ts
|
|
2331
|
-
var
|
|
2332
|
-
function
|
|
2428
|
+
var tn = "(min-width: 768px)", nn = 24, rn = .5, an = 1200, on = .85, sn = 9 / 16;
|
|
2429
|
+
function cn() {
|
|
2333
2430
|
if (typeof window > "u") return 800;
|
|
2334
2431
|
let e = window.screen?.availHeight;
|
|
2335
2432
|
return typeof e == "number" && e > 0 ? e : window.innerHeight;
|
|
2336
2433
|
}
|
|
2337
|
-
function
|
|
2338
|
-
let i = Math.max(160, Math.min(t - n * 2, t *
|
|
2339
|
-
return s > a && (s = a, o = s /
|
|
2434
|
+
function ln(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = nn, r = typeof window < "u" ? cn() : 800) {
|
|
2435
|
+
let i = Math.max(160, Math.min(t - n * 2, t * on)), a = Math.max(120, e - n * 2), o = Math.min(r * rn, an, i), s = o * sn;
|
|
2436
|
+
return s > a && (s = a, o = s / sn, o > i && (o = i, s = o * sn)), {
|
|
2340
2437
|
width: Math.round(s),
|
|
2341
2438
|
height: Math.round(o)
|
|
2342
2439
|
};
|
|
2343
2440
|
}
|
|
2344
|
-
function
|
|
2441
|
+
function un(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = nn) {
|
|
2345
2442
|
return {
|
|
2346
2443
|
left: Math.max(r, t - e.width - r),
|
|
2347
2444
|
top: Math.max(r, n - e.height - r)
|
|
2348
2445
|
};
|
|
2349
2446
|
}
|
|
2350
|
-
function
|
|
2447
|
+
function dn(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = nn) {
|
|
2351
2448
|
let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
|
|
2352
2449
|
return {
|
|
2353
2450
|
left: Math.min(Math.max(a, e), o),
|
|
2354
2451
|
top: Math.min(Math.max(a, t), s)
|
|
2355
2452
|
};
|
|
2356
2453
|
}
|
|
2357
|
-
function
|
|
2358
|
-
return e(
|
|
2454
|
+
function fn(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
|
|
2455
|
+
return e(tn).matches;
|
|
2359
2456
|
}
|
|
2360
2457
|
//#endregion
|
|
2361
2458
|
//#region src/widget/mountExperienceWidget.ts
|
|
2362
|
-
function
|
|
2459
|
+
function pn(e) {
|
|
2363
2460
|
return e === "bottom-right" || e === "bottom-left" ? e : "static";
|
|
2364
2461
|
}
|
|
2365
|
-
function
|
|
2462
|
+
function mn(e) {
|
|
2366
2463
|
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
2367
2464
|
let t = typeof e == "string" ? e.trim() : "";
|
|
2368
2465
|
return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
|
|
@@ -2370,10 +2467,10 @@ function fn(e) {
|
|
|
2370
2467
|
function $(e) {
|
|
2371
2468
|
return e === "expanded" || e === "docked";
|
|
2372
2469
|
}
|
|
2373
|
-
var
|
|
2374
|
-
function
|
|
2375
|
-
de
|
|
2376
|
-
let r =
|
|
2470
|
+
var hn = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"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>", gn = "<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>", _n = "<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>", 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=\"M16 4h4v4m-6 2l6-6M8 20H4v-4m0 4l6-6\"/></svg>";
|
|
2471
|
+
function yn(e, t, n) {
|
|
2472
|
+
W(de);
|
|
2473
|
+
let r = w({
|
|
2377
2474
|
galleryThumb: t.galleryThumb,
|
|
2378
2475
|
avatarImage: t.avatarImage,
|
|
2379
2476
|
backgroundImage: t.backgroundImage,
|
|
@@ -2399,9 +2496,9 @@ function _n(e, t, n) {
|
|
|
2399
2496
|
let e = document.createElement("img");
|
|
2400
2497
|
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
2498
|
}
|
|
2402
|
-
return e.replaceChildren(i), n?.parallax === !1 ? () => {} :
|
|
2499
|
+
return e.replaceChildren(i), n?.parallax === !1 ? () => {} : ue(i);
|
|
2403
2500
|
}
|
|
2404
|
-
function
|
|
2501
|
+
function bn(e) {
|
|
2405
2502
|
return e.startButton ? {
|
|
2406
2503
|
...e.startButton,
|
|
2407
2504
|
label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
|
|
@@ -2413,7 +2510,7 @@ function vn(e) {
|
|
|
2413
2510
|
variant: "primary"
|
|
2414
2511
|
};
|
|
2415
2512
|
}
|
|
2416
|
-
function
|
|
2513
|
+
function xn(e) {
|
|
2417
2514
|
let t = !1, n = () => {
|
|
2418
2515
|
t || e();
|
|
2419
2516
|
}, r = () => {
|
|
@@ -2433,12 +2530,12 @@ function yn(e) {
|
|
|
2433
2530
|
t = !0, window.removeEventListener("load", r), i?.();
|
|
2434
2531
|
};
|
|
2435
2532
|
}
|
|
2436
|
-
function
|
|
2437
|
-
me
|
|
2533
|
+
function Sn(e, t) {
|
|
2534
|
+
he(me);
|
|
2438
2535
|
let n = t.experienceId?.trim();
|
|
2439
2536
|
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",
|
|
2537
|
+
let r = t.prefetch ?? "onExpand", i = pn(t.position), a = document.createElement("div");
|
|
2538
|
+
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", mn(t.offset));
|
|
2442
2539
|
let o = document.createElement("button");
|
|
2443
2540
|
o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
|
|
2444
2541
|
let s = document.createElement("div");
|
|
@@ -2458,30 +2555,30 @@ function bn(e, t) {
|
|
|
2458
2555
|
let m = document.createElement("span");
|
|
2459
2556
|
m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
|
|
2460
2557
|
let h = document.createElement("button");
|
|
2461
|
-
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML =
|
|
2558
|
+
h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = _n, h.setAttribute("aria-label", "Reduce");
|
|
2462
2559
|
let g = document.createElement("button");
|
|
2463
|
-
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML =
|
|
2560
|
+
g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = hn, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
|
|
2464
2561
|
let _ = document.createElement("button");
|
|
2465
|
-
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML =
|
|
2562
|
+
_.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = gn, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
|
|
2466
2563
|
let v = document.createElement("div");
|
|
2467
2564
|
v.className = "liforma-ew__stage";
|
|
2468
2565
|
let y = document.createElement("div");
|
|
2469
2566
|
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,
|
|
2567
|
+
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
2568
|
let e = a.dataset.state;
|
|
2472
2569
|
return e === "expanded" || e === "docked" || e === "collapsed" ? e : "collapsed";
|
|
2473
2570
|
}, z = () => {
|
|
2474
2571
|
j !== null && (clearTimeout(j), j = null);
|
|
2475
2572
|
}, B = () => {
|
|
2476
2573
|
M !== null && (clearTimeout(M), M = null), a.classList.remove("liforma-ew--layout-settling");
|
|
2477
|
-
},
|
|
2574
|
+
}, ae = () => {
|
|
2478
2575
|
for (let e of [
|
|
2479
2576
|
f,
|
|
2480
2577
|
l,
|
|
2481
2578
|
p
|
|
2482
2579
|
]) 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
2580
|
p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging");
|
|
2484
|
-
},
|
|
2581
|
+
}, V = (e, t, n, r) => {
|
|
2485
2582
|
let i = (i) => {
|
|
2486
2583
|
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
2584
|
};
|
|
@@ -2490,50 +2587,50 @@ function bn(e, t) {
|
|
|
2490
2587
|
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
2588
|
}, oe = (e, t) => {
|
|
2492
2589
|
if (R() !== "docked") return;
|
|
2493
|
-
let n =
|
|
2494
|
-
N = r.left, P = r.top,
|
|
2590
|
+
let n = ln(), r = dn(e - te, t - ne, n);
|
|
2591
|
+
N = r.left, P = r.top, V(r.left, r.top, n.width, n.height);
|
|
2495
2592
|
}, se = (e, t) => {
|
|
2496
2593
|
if (R() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
|
|
2497
|
-
let n =
|
|
2498
|
-
N = a.left, P = a.top,
|
|
2594
|
+
let n = ln(), r = N ?? f.getBoundingClientRect().left, i = P ?? f.getBoundingClientRect().top, a = dn(r + e, i + t, n);
|
|
2595
|
+
N = a.left, P = a.top, V(a.left, a.top, n.width, n.height);
|
|
2499
2596
|
}, ce = (e) => {
|
|
2500
|
-
|
|
2597
|
+
I === "toolbar" && (F === null || e.pointerId !== F || (e.preventDefault(), oe(e.clientX, e.clientY)));
|
|
2501
2598
|
}, H = (e) => {
|
|
2502
2599
|
if (F === null || e && e.pointerId !== F) return;
|
|
2503
|
-
let t =
|
|
2504
|
-
F = null,
|
|
2600
|
+
let t = I;
|
|
2601
|
+
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
2602
|
}, le = (e, t, n) => {
|
|
2506
|
-
if (S || R() !== "docked" || !
|
|
2507
|
-
F = n,
|
|
2603
|
+
if (S || R() !== "docked" || !fn() || F !== null) return;
|
|
2604
|
+
F = n, I = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2508
2605
|
let r = f.getBoundingClientRect();
|
|
2509
|
-
te = e - r.left,
|
|
2606
|
+
te = e - r.left, ne = t - r.top, L || (L = !0, window.addEventListener("pointermove", ce), window.addEventListener("pointerup", H), window.addEventListener("pointercancel", H));
|
|
2510
2607
|
}, ue = (e) => {
|
|
2511
|
-
if (S || R() !== "docked" || !
|
|
2512
|
-
F = e.pointerId,
|
|
2608
|
+
if (S || R() !== "docked" || !fn() || F !== null) return;
|
|
2609
|
+
F = e.pointerId, I = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
|
|
2513
2610
|
let t = f.getBoundingClientRect();
|
|
2514
2611
|
N = t.left, P = t.top;
|
|
2515
|
-
}, U = (e) => {
|
|
2516
|
-
L === "player" && (F === null || e.pointerId !== F || se(e.dx, e.dy));
|
|
2517
2612
|
}, de = (e) => {
|
|
2518
|
-
|
|
2613
|
+
I === "player" && (F === null || e.pointerId !== F || se(e.dx, e.dy));
|
|
2614
|
+
}, U = (e) => {
|
|
2615
|
+
I === "player" && (F === null || e.pointerId !== F || H());
|
|
2519
2616
|
}, W = () => {
|
|
2520
|
-
let e =
|
|
2617
|
+
let e = fn(), t = R();
|
|
2521
2618
|
if (!e || t !== "expanded" && t !== "docked") {
|
|
2522
2619
|
h.hidden = !0;
|
|
2523
2620
|
return;
|
|
2524
2621
|
}
|
|
2525
|
-
h.hidden = !1, t === "docked" ? (h.innerHTML =
|
|
2622
|
+
h.hidden = !1, t === "docked" ? (h.innerHTML = vn, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = _n, h.setAttribute("aria-label", "Reduce"));
|
|
2526
2623
|
}, fe = (e) => {
|
|
2527
|
-
let t =
|
|
2528
|
-
n =
|
|
2529
|
-
},
|
|
2624
|
+
let t = ln(), n = e && N !== null && P !== null ? dn(N, P, t) : un(t);
|
|
2625
|
+
n = dn(n.left, n.top, t), N = n.left, P = n.top, V(n.left, n.top, t.width, t.height), W();
|
|
2626
|
+
}, pe = () => {
|
|
2530
2627
|
a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
|
|
2531
2628
|
requestAnimationFrame(() => {
|
|
2532
2629
|
S || !$(a.dataset.state) || a.classList.add("liforma-ew--session-revealed");
|
|
2533
2630
|
});
|
|
2534
2631
|
});
|
|
2535
|
-
},
|
|
2536
|
-
if (B(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !
|
|
2632
|
+
}, G = (e) => {
|
|
2633
|
+
if (B(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !D) {
|
|
2537
2634
|
a.classList.remove("liforma-ew--layout-settling");
|
|
2538
2635
|
return;
|
|
2539
2636
|
}
|
|
@@ -2542,54 +2639,54 @@ function bn(e, t) {
|
|
|
2542
2639
|
a.classList.remove("liforma-ew--layout-settling");
|
|
2543
2640
|
return;
|
|
2544
2641
|
}
|
|
2545
|
-
a.classList.remove("liforma-ew--layout-settling"),
|
|
2642
|
+
a.classList.remove("liforma-ew--layout-settling"), pe();
|
|
2546
2643
|
}, 220);
|
|
2547
|
-
},
|
|
2644
|
+
}, ge = () => (a.classList.add("liforma-ew--session-concealing"), a.classList.remove("liforma-ew--session-revealed"), new Promise((e) => {
|
|
2548
2645
|
z(), j = setTimeout(() => {
|
|
2549
2646
|
j = null, a.classList.remove("liforma-ew--session-concealing"), e();
|
|
2550
2647
|
}, 280);
|
|
2551
|
-
})),
|
|
2648
|
+
})), _e = {
|
|
2552
2649
|
galleryThumb: t.galleryThumb,
|
|
2553
2650
|
avatarImage: t.avatarImage,
|
|
2554
2651
|
backgroundImage: t.backgroundImage,
|
|
2555
2652
|
foregroundImage: t.foregroundImage,
|
|
2556
2653
|
fallbackImage: t.fallbackImage
|
|
2557
|
-
},
|
|
2654
|
+
}, K = (e) => {
|
|
2558
2655
|
if (!e) {
|
|
2559
2656
|
y.hidden = !0, y.textContent = "";
|
|
2560
2657
|
return;
|
|
2561
2658
|
}
|
|
2562
2659
|
y.hidden = !1, y.textContent = e;
|
|
2563
|
-
},
|
|
2660
|
+
}, ve = (e) => {
|
|
2564
2661
|
if (!e) {
|
|
2565
2662
|
c.hidden = !0, c.textContent = "";
|
|
2566
2663
|
return;
|
|
2567
2664
|
}
|
|
2568
2665
|
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
2666
|
}, ye = () => {
|
|
2572
|
-
C = !0,
|
|
2573
|
-
},
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2667
|
+
C = !0, o.disabled = !1, ve(null), r === "onExpand" && t.onPrefetchReady?.();
|
|
2668
|
+
}, q = () => {
|
|
2669
|
+
w = !0, a.dataset.warm = "true", l.hidden = !1, D || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
|
|
2670
|
+
}, xe = (e) => {
|
|
2671
|
+
A?.(), A = null;
|
|
2672
|
+
let t = yn(s, e, { parallax: ie });
|
|
2673
|
+
return t ? (A = t, !0) : !1;
|
|
2674
|
+
}, Se = () => {
|
|
2675
|
+
if (xe(_e)) {
|
|
2676
|
+
ye();
|
|
2580
2677
|
return;
|
|
2581
2678
|
}
|
|
2582
|
-
|
|
2679
|
+
ve("Loading…"), be(n, { signal: re.signal }).then((e) => {
|
|
2583
2680
|
if (!S) {
|
|
2584
|
-
if (!
|
|
2585
|
-
|
|
2681
|
+
if (!xe({ galleryThumb: e.galleryThumb })) throw Error("Experience preview is missing gallery thumb images.");
|
|
2682
|
+
ye();
|
|
2586
2683
|
}
|
|
2587
2684
|
}).catch((e) => {
|
|
2588
2685
|
if (S || re.signal.aborted) return;
|
|
2589
2686
|
let n = e instanceof Error ? e : Error(String(e));
|
|
2590
|
-
|
|
2687
|
+
ve("Preview unavailable"), o.disabled = !0, t.onError?.(n), console.error("[ExperienceWidget]", n);
|
|
2591
2688
|
});
|
|
2592
|
-
},
|
|
2689
|
+
}, Ce = () => ({
|
|
2593
2690
|
experienceId: n,
|
|
2594
2691
|
ui: "widget",
|
|
2595
2692
|
...t.sessionEndpoint ? { sessionEndpoint: t.sessionEndpoint } : {},
|
|
@@ -2599,65 +2696,70 @@ function bn(e, t) {
|
|
|
2599
2696
|
...t.speechInputMode ? { speechInputMode: t.speechInputMode } : {},
|
|
2600
2697
|
...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
|
|
2601
2698
|
...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
|
|
2602
|
-
}),
|
|
2699
|
+
}), we = () => ({
|
|
2603
2700
|
...t.fit ? { fit: t.fit } : {},
|
|
2604
|
-
startButton:
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2701
|
+
startButton: bn(t),
|
|
2702
|
+
...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback }
|
|
2703
|
+
}), J = (e = !0) => {
|
|
2704
|
+
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?.();
|
|
2705
|
+
}, Y = () => {
|
|
2706
|
+
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");
|
|
2707
|
+
}, X = (e) => {
|
|
2610
2708
|
e.on("started", () => {
|
|
2611
|
-
S || (
|
|
2709
|
+
S || (D = !0, a.dataset.live = "true", K(null), t.onStarted?.(), $(a.dataset.state) && pe());
|
|
2710
|
+
}), e.on("feedback", (e) => {
|
|
2711
|
+
S || t.onFeedback?.(e);
|
|
2712
|
+
}), e.on("feedbackFailed", (e) => {
|
|
2713
|
+
S || t.onFeedbackFailed?.(e);
|
|
2612
2714
|
});
|
|
2613
2715
|
}, Te = () => {
|
|
2614
|
-
B(), u.hidden = !0, p.hidden = !0,
|
|
2716
|
+
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
2717
|
}, Ee = () => {
|
|
2616
|
-
z(), B(),
|
|
2718
|
+
z(), B(), O += 1, x = !1, w = !1, T = !1, E = !1, D = !1;
|
|
2617
2719
|
let e = b;
|
|
2618
2720
|
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
2721
|
}, De = () => {
|
|
2620
2722
|
if (!S && $(a.dataset.state)) {
|
|
2621
|
-
if (H(), x = !1, b &&
|
|
2723
|
+
if (H(), x = !1, b && E) {
|
|
2622
2724
|
let e = b;
|
|
2623
2725
|
(async () => {
|
|
2624
|
-
|
|
2726
|
+
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
2727
|
})();
|
|
2626
2728
|
return;
|
|
2627
2729
|
}
|
|
2628
2730
|
Ee(), Te(), t.onCollapsed?.(), t.onClose?.();
|
|
2629
2731
|
}
|
|
2630
2732
|
}, Oe = () => {
|
|
2631
|
-
S ||
|
|
2632
|
-
|
|
2733
|
+
S || fn() && R() === "expanded" && G(() => {
|
|
2734
|
+
Y();
|
|
2633
2735
|
});
|
|
2634
2736
|
}, ke = () => {
|
|
2635
|
-
S || R() === "docked" && (H(),
|
|
2636
|
-
|
|
2737
|
+
S || R() === "docked" && (H(), G(() => {
|
|
2738
|
+
ae(), J(!1), b?.setWidgetChrome("expanded");
|
|
2637
2739
|
}));
|
|
2638
2740
|
}, Ae = () => {
|
|
2639
|
-
!b || !
|
|
2741
|
+
!b || !D || (z(), a.classList.remove("liforma-ew--session-revealed"), J(), b.setWidgetChrome("expanded"), x = !1, pe());
|
|
2640
2742
|
}, je = () => {
|
|
2641
|
-
!b || !
|
|
2743
|
+
!b || !E || D || (z(), a.classList.remove("liforma-ew--session-revealed"), J(), x = !1, w || b.setWidgetChrome("expanded"));
|
|
2642
2744
|
}, Me = (e) => {
|
|
2643
|
-
S || e !==
|
|
2745
|
+
S || e !== O && !D || (z(), a.classList.remove("liforma-ew--session-revealed"), J(), x = !1, D && pe());
|
|
2644
2746
|
}, Ne = () => {
|
|
2645
|
-
if (S ||
|
|
2646
|
-
|
|
2647
|
-
let e =
|
|
2747
|
+
if (S || T || w || b || $(a.dataset.state)) return;
|
|
2748
|
+
T = !0;
|
|
2749
|
+
let e = O;
|
|
2648
2750
|
l.hidden = !1, (async () => {
|
|
2649
2751
|
try {
|
|
2650
|
-
let t = await
|
|
2651
|
-
if (S || e !==
|
|
2752
|
+
let t = await $t.startSession(Ce());
|
|
2753
|
+
if (S || e !== O) {
|
|
2652
2754
|
t.destroy();
|
|
2653
2755
|
return;
|
|
2654
2756
|
}
|
|
2655
|
-
b = t,
|
|
2757
|
+
b = t, X(t);
|
|
2656
2758
|
let n = await t.attach({
|
|
2657
2759
|
container: l,
|
|
2658
|
-
...
|
|
2760
|
+
...we(),
|
|
2659
2761
|
onWidgetReady: () => {
|
|
2660
|
-
S || e !==
|
|
2762
|
+
S || e !== O || (T = !1, E = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") : q());
|
|
2661
2763
|
},
|
|
2662
2764
|
onWidgetExpand: () => {
|
|
2663
2765
|
Me(e);
|
|
@@ -2669,16 +2771,16 @@ function bn(e, t) {
|
|
|
2669
2771
|
S || ue(e);
|
|
2670
2772
|
},
|
|
2671
2773
|
onWidgetDragMove: (e) => {
|
|
2672
|
-
S ||
|
|
2774
|
+
S || de(e);
|
|
2673
2775
|
},
|
|
2674
2776
|
onWidgetDragEnd: (e) => {
|
|
2675
|
-
S ||
|
|
2777
|
+
S || U(e);
|
|
2676
2778
|
},
|
|
2677
2779
|
onPlayerStatusChange: (e) => {
|
|
2678
|
-
S || e === "error" && $(a.dataset.state) &&
|
|
2780
|
+
S || e === "error" && $(a.dataset.state) && K("Could not load the experience.");
|
|
2679
2781
|
}
|
|
2680
2782
|
});
|
|
2681
|
-
if (S || e !==
|
|
2783
|
+
if (S || e !== O) {
|
|
2682
2784
|
t.destroy(), b === t && (b = null);
|
|
2683
2785
|
return;
|
|
2684
2786
|
}
|
|
@@ -2686,35 +2788,35 @@ function bn(e, t) {
|
|
|
2686
2788
|
S || De();
|
|
2687
2789
|
});
|
|
2688
2790
|
} catch (n) {
|
|
2689
|
-
if (S || e !==
|
|
2690
|
-
|
|
2791
|
+
if (S || e !== O) return;
|
|
2792
|
+
T = !1, l.hidden = !0, l.replaceChildren(), b = null;
|
|
2691
2793
|
let r = n instanceof Error ? n : Error(String(n));
|
|
2692
2794
|
t.onError?.(r), console.error("[ExperienceWidget] warm prefetch failed", r);
|
|
2693
2795
|
}
|
|
2694
2796
|
})();
|
|
2695
2797
|
}, Pe = () => {
|
|
2696
|
-
if (S || x || !
|
|
2697
|
-
if (b &&
|
|
2798
|
+
if (S || x || !C || $(a.dataset.state)) return;
|
|
2799
|
+
if (b && D) {
|
|
2698
2800
|
Ae();
|
|
2699
2801
|
return;
|
|
2700
2802
|
}
|
|
2701
|
-
if (b &&
|
|
2803
|
+
if (b && E) {
|
|
2702
2804
|
je();
|
|
2703
2805
|
return;
|
|
2704
2806
|
}
|
|
2705
|
-
let e = ++
|
|
2706
|
-
x = !0,
|
|
2807
|
+
let e = ++O;
|
|
2808
|
+
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
2809
|
try {
|
|
2708
|
-
|
|
2709
|
-
let t = await
|
|
2710
|
-
if (S || e !==
|
|
2810
|
+
J();
|
|
2811
|
+
let t = await $t.startSession(Ce());
|
|
2812
|
+
if (S || e !== O) {
|
|
2711
2813
|
t.destroy();
|
|
2712
2814
|
return;
|
|
2713
2815
|
}
|
|
2714
|
-
b = t,
|
|
2816
|
+
b = t, X(t);
|
|
2715
2817
|
let n = await t.attach({
|
|
2716
2818
|
container: v,
|
|
2717
|
-
...
|
|
2819
|
+
...we(),
|
|
2718
2820
|
onWidgetAudioSettings: (e) => {
|
|
2719
2821
|
S || Le(e);
|
|
2720
2822
|
},
|
|
@@ -2722,42 +2824,42 @@ function bn(e, t) {
|
|
|
2722
2824
|
S || ue(e);
|
|
2723
2825
|
},
|
|
2724
2826
|
onWidgetDragMove: (e) => {
|
|
2725
|
-
S ||
|
|
2827
|
+
S || de(e);
|
|
2726
2828
|
},
|
|
2727
2829
|
onWidgetDragEnd: (e) => {
|
|
2728
|
-
S ||
|
|
2830
|
+
S || U(e);
|
|
2729
2831
|
},
|
|
2730
2832
|
onPlayerStatusChange: (e) => {
|
|
2731
|
-
S || (e === "error" ?
|
|
2833
|
+
S || (e === "error" ? K("Could not load the experience.") : $(a.dataset.state) && K(null));
|
|
2732
2834
|
}
|
|
2733
2835
|
});
|
|
2734
|
-
if (S || e !==
|
|
2836
|
+
if (S || e !== O) {
|
|
2735
2837
|
t.destroy(), b === t && (b = null);
|
|
2736
2838
|
return;
|
|
2737
2839
|
}
|
|
2738
|
-
|
|
2840
|
+
E = !0, t.setWidgetChrome("expanded"), n.on("close", () => {
|
|
2739
2841
|
S || De();
|
|
2740
2842
|
});
|
|
2741
2843
|
} catch (n) {
|
|
2742
|
-
if (S || e !==
|
|
2844
|
+
if (S || e !== O) return;
|
|
2743
2845
|
let r = n instanceof Error ? n : Error(String(n));
|
|
2744
|
-
|
|
2846
|
+
K(r.message), t.onError?.(r), console.error("[ExperienceWidget]", r);
|
|
2745
2847
|
} finally {
|
|
2746
|
-
e ===
|
|
2848
|
+
e === O && (x = !1);
|
|
2747
2849
|
}
|
|
2748
2850
|
})();
|
|
2749
2851
|
}, Fe = () => {
|
|
2750
2852
|
if (!(S || $(a.dataset.state))) {
|
|
2751
|
-
if (b &&
|
|
2853
|
+
if (b && D) {
|
|
2752
2854
|
Ae();
|
|
2753
2855
|
return;
|
|
2754
2856
|
}
|
|
2755
|
-
if (b &&
|
|
2857
|
+
if (b && E) {
|
|
2756
2858
|
je();
|
|
2757
2859
|
return;
|
|
2758
2860
|
}
|
|
2759
|
-
if (
|
|
2760
|
-
|
|
2861
|
+
if (T || b) {
|
|
2862
|
+
J();
|
|
2761
2863
|
return;
|
|
2762
2864
|
}
|
|
2763
2865
|
Pe();
|
|
@@ -2773,26 +2875,26 @@ function bn(e, t) {
|
|
|
2773
2875
|
}, Re = (e) => {
|
|
2774
2876
|
e.stopPropagation(), $(a.dataset.state) && b?.toggleAudioSettings();
|
|
2775
2877
|
}, ze = (e) => {
|
|
2776
|
-
R() === "docked" &&
|
|
2878
|
+
R() === "docked" && fn() && (e.target?.closest("button") || (e.preventDefault(), le(e.clientX, e.clientY, e.pointerId)));
|
|
2777
2879
|
}, Be = (e) => {
|
|
2778
2880
|
e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), De());
|
|
2779
2881
|
}, Ve = () => {
|
|
2780
2882
|
if (!S) {
|
|
2781
2883
|
if (R() === "docked") {
|
|
2782
|
-
if (!
|
|
2884
|
+
if (!fn()) {
|
|
2783
2885
|
ke();
|
|
2784
2886
|
return;
|
|
2785
2887
|
}
|
|
2786
|
-
|
|
2888
|
+
D ? G(() => {
|
|
2787
2889
|
fe(!0);
|
|
2788
2890
|
}) : fe(!0);
|
|
2789
2891
|
return;
|
|
2790
2892
|
}
|
|
2791
2893
|
W();
|
|
2792
2894
|
}
|
|
2793
|
-
}, He = typeof window < "u" ? window.matchMedia(
|
|
2895
|
+
}, He = typeof window < "u" ? window.matchMedia(tn) : null, Ue = () => {
|
|
2794
2896
|
if (!S) {
|
|
2795
|
-
if (R() === "docked" && !
|
|
2897
|
+
if (R() === "docked" && !fn()) {
|
|
2796
2898
|
ke();
|
|
2797
2899
|
return;
|
|
2798
2900
|
}
|
|
@@ -2801,9 +2903,9 @@ function bn(e, t) {
|
|
|
2801
2903
|
};
|
|
2802
2904
|
return o.addEventListener("click", Fe), d.addEventListener("click", De), _.addEventListener("click", (e) => {
|
|
2803
2905
|
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),
|
|
2906
|
+
}), 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
2907
|
S || Ne();
|
|
2806
|
-
}) : r === "idle" && (
|
|
2908
|
+
}) : r === "idle" && (ee = xn(() => {
|
|
2807
2909
|
S || Ne();
|
|
2808
2910
|
})), {
|
|
2809
2911
|
root: a,
|
|
@@ -2819,18 +2921,18 @@ function bn(e, t) {
|
|
|
2819
2921
|
Ne();
|
|
2820
2922
|
},
|
|
2821
2923
|
destroy() {
|
|
2822
|
-
S || (S = !0, H(),
|
|
2924
|
+
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
2925
|
}
|
|
2824
2926
|
};
|
|
2825
2927
|
}
|
|
2826
2928
|
//#endregion
|
|
2827
2929
|
//#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:
|
|
2930
|
+
function Cn(t) {
|
|
2931
|
+
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
2932
|
return e(() => {
|
|
2831
2933
|
let e = r.current;
|
|
2832
2934
|
if (!e || !i.trim()) return;
|
|
2833
|
-
let t =
|
|
2935
|
+
let t = Sn(e, {
|
|
2834
2936
|
experienceId: i,
|
|
2835
2937
|
alt: o,
|
|
2836
2938
|
galleryThumb: s,
|
|
@@ -2849,16 +2951,19 @@ function xn(t) {
|
|
|
2849
2951
|
speechOnly: b,
|
|
2850
2952
|
fit: x,
|
|
2851
2953
|
embedBaseUrl: S,
|
|
2852
|
-
expandedMaxWidth:
|
|
2853
|
-
expandedMaxHeight:
|
|
2854
|
-
startButtonLabel:
|
|
2855
|
-
startButton:
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2954
|
+
expandedMaxWidth: C,
|
|
2955
|
+
expandedMaxHeight: w,
|
|
2956
|
+
startButtonLabel: T,
|
|
2957
|
+
startButton: E,
|
|
2958
|
+
showFeedback: D,
|
|
2959
|
+
onFeedback: P,
|
|
2960
|
+
onFeedbackFailed: F,
|
|
2961
|
+
onExpanded: k,
|
|
2962
|
+
onCollapsed: A,
|
|
2963
|
+
onStarted: ee,
|
|
2964
|
+
onClose: j,
|
|
2965
|
+
onError: M,
|
|
2966
|
+
onPrefetchReady: N
|
|
2862
2967
|
});
|
|
2863
2968
|
return () => t.destroy();
|
|
2864
2969
|
}, [
|
|
@@ -2880,20 +2985,23 @@ function xn(t) {
|
|
|
2880
2985
|
b,
|
|
2881
2986
|
x,
|
|
2882
2987
|
S,
|
|
2883
|
-
ee,
|
|
2884
2988
|
C,
|
|
2885
2989
|
w,
|
|
2886
2990
|
T,
|
|
2991
|
+
E,
|
|
2887
2992
|
D,
|
|
2888
|
-
|
|
2993
|
+
P,
|
|
2994
|
+
F,
|
|
2889
2995
|
k,
|
|
2890
2996
|
A,
|
|
2997
|
+
ee,
|
|
2891
2998
|
j,
|
|
2892
|
-
M
|
|
2999
|
+
M,
|
|
3000
|
+
N
|
|
2893
3001
|
]), /* @__PURE__ */ a("div", {
|
|
2894
3002
|
ref: r,
|
|
2895
|
-
className:
|
|
2896
|
-
style:
|
|
3003
|
+
className: O,
|
|
3004
|
+
style: te ? { display: "contents" } : {
|
|
2897
3005
|
width: "100%",
|
|
2898
3006
|
height: "100%",
|
|
2899
3007
|
minHeight: "inherit"
|
|
@@ -2901,6 +3009,6 @@ function xn(t) {
|
|
|
2901
3009
|
});
|
|
2902
3010
|
}
|
|
2903
3011
|
//#endregion
|
|
2904
|
-
export {
|
|
3012
|
+
export { pe as ExperienceThumbnail, Cn as ExperienceWidget, v as createLiformaSessionRouteHandler };
|
|
2905
3013
|
|
|
2906
3014
|
//# sourceMappingURL=index.js.map
|