@liforma/client 0.4.2 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/next/index.js +689 -573
  3. package/dist/next/index.js.map +1 -1
  4. package/dist/next/react/ExperienceThumbnail.d.ts +1 -1
  5. package/dist/next/react/ExperienceThumbnail.d.ts.map +1 -1
  6. package/dist/next/react/ExperienceWidget.d.ts +4 -0
  7. package/dist/next/react/ExperienceWidget.d.ts.map +1 -1
  8. package/dist/next/thumbnail/index.d.ts +1 -0
  9. package/dist/next/thumbnail/index.d.ts.map +1 -1
  10. package/dist/next/thumbnail/styles.d.ts.map +1 -1
  11. package/dist/next/thumbnail/types.d.ts +3 -2
  12. package/dist/next/thumbnail/types.d.ts.map +1 -1
  13. package/dist/next/v2/embed/iframeHost.d.ts +27 -1
  14. package/dist/next/v2/embed/iframeHost.d.ts.map +1 -1
  15. package/dist/next/v2/embed/protocol.d.ts +61 -1
  16. package/dist/next/v2/embed/protocol.d.ts.map +1 -1
  17. package/dist/next/v2/experience.d.ts +24 -2
  18. package/dist/next/v2/experience.d.ts.map +1 -1
  19. package/dist/next/v2/experienceEvents.d.ts +30 -0
  20. package/dist/next/v2/experienceEvents.d.ts.map +1 -1
  21. package/dist/next/v2/shims/embedBaseUrl.d.ts +3 -2
  22. package/dist/next/v2/shims/embedBaseUrl.d.ts.map +1 -1
  23. package/dist/next/v2/types/sessionInteraction.d.ts +3 -1
  24. package/dist/next/v2/types/sessionInteraction.d.ts.map +1 -1
  25. package/dist/next/v2/types/sessionManifest.d.ts +12 -0
  26. package/dist/next/v2/types/sessionManifest.d.ts.map +1 -1
  27. package/dist/next/widget/mountExperienceWidget.d.ts.map +1 -1
  28. package/dist/next/widget/types.d.ts +7 -0
  29. package/dist/next/widget/types.d.ts.map +1 -1
  30. package/dist/npm/index.js +632 -522
  31. package/dist/npm/index.js.map +1 -1
  32. package/dist/npm/thumbnail/index.d.ts +1 -0
  33. package/dist/npm/thumbnail/index.d.ts.map +1 -1
  34. package/dist/npm/thumbnail/styles.d.ts.map +1 -1
  35. package/dist/npm/thumbnail/types.d.ts +3 -2
  36. package/dist/npm/thumbnail/types.d.ts.map +1 -1
  37. package/dist/npm/v2/embed/iframeHost.d.ts +27 -1
  38. package/dist/npm/v2/embed/iframeHost.d.ts.map +1 -1
  39. package/dist/npm/v2/embed/protocol.d.ts +61 -1
  40. package/dist/npm/v2/embed/protocol.d.ts.map +1 -1
  41. package/dist/npm/v2/experience.d.ts +24 -2
  42. package/dist/npm/v2/experience.d.ts.map +1 -1
  43. package/dist/npm/v2/experienceEvents.d.ts +30 -0
  44. package/dist/npm/v2/experienceEvents.d.ts.map +1 -1
  45. package/dist/npm/v2/index.d.ts +1 -1
  46. package/dist/npm/v2/index.d.ts.map +1 -1
  47. package/dist/npm/v2/liforma-experience-thumbnail.d.ts.map +1 -1
  48. package/dist/npm/v2/liforma-experience.d.ts.map +1 -1
  49. package/dist/npm/v2/npm.d.ts +2 -1
  50. package/dist/npm/v2/npm.d.ts.map +1 -1
  51. package/dist/npm/v2/shims/embedBaseUrl.d.ts +3 -2
  52. package/dist/npm/v2/shims/embedBaseUrl.d.ts.map +1 -1
  53. package/dist/npm/v2/speechOnlyManifest.d.ts.map +1 -1
  54. package/dist/npm/v2/types/sessionInteraction.d.ts +3 -1
  55. package/dist/npm/v2/types/sessionInteraction.d.ts.map +1 -1
  56. package/dist/npm/v2/types/sessionManifest.d.ts +12 -0
  57. package/dist/npm/v2/types/sessionManifest.d.ts.map +1 -1
  58. package/dist/npm/v2/types/sessionManifestSchema.d.ts +20 -1
  59. package/dist/npm/v2/types/sessionManifestSchema.d.ts.map +1 -1
  60. package/dist/npm/widget/mountExperienceWidget.d.ts.map +1 -1
  61. package/dist/npm/widget/types.d.ts +7 -0
  62. package/dist/npm/widget/types.d.ts.map +1 -1
  63. package/dist/react/component/experienceComponentLaunch.d.ts.map +1 -1
  64. package/dist/react/component/experienceComponentRuntime.d.ts +4 -0
  65. package/dist/react/component/experienceComponentRuntime.d.ts.map +1 -1
  66. package/dist/react/component/experienceComponentTypes.d.ts +19 -1
  67. package/dist/react/component/experienceComponentTypes.d.ts.map +1 -1
  68. package/dist/react/index.js +768 -629
  69. package/dist/react/index.js.map +1 -1
  70. package/dist/react/react/Experience.d.ts.map +1 -1
  71. package/dist/react/react/ExperienceThumbnail.d.ts +1 -1
  72. package/dist/react/react/ExperienceThumbnail.d.ts.map +1 -1
  73. package/dist/react/react/ExperienceWidget.d.ts +4 -0
  74. package/dist/react/react/ExperienceWidget.d.ts.map +1 -1
  75. package/dist/react/thumbnail/index.d.ts +1 -0
  76. package/dist/react/thumbnail/index.d.ts.map +1 -1
  77. package/dist/react/thumbnail/styles.d.ts.map +1 -1
  78. package/dist/react/thumbnail/types.d.ts +3 -2
  79. package/dist/react/thumbnail/types.d.ts.map +1 -1
  80. package/dist/react/v2/embed/iframeHost.d.ts +27 -1
  81. package/dist/react/v2/embed/iframeHost.d.ts.map +1 -1
  82. package/dist/react/v2/embed/protocol.d.ts +61 -1
  83. package/dist/react/v2/embed/protocol.d.ts.map +1 -1
  84. package/dist/react/v2/experience.d.ts +24 -2
  85. package/dist/react/v2/experience.d.ts.map +1 -1
  86. package/dist/react/v2/experienceEvents.d.ts +30 -0
  87. package/dist/react/v2/experienceEvents.d.ts.map +1 -1
  88. package/dist/react/v2/shims/embedBaseUrl.d.ts +3 -2
  89. package/dist/react/v2/shims/embedBaseUrl.d.ts.map +1 -1
  90. package/dist/react/v2/types/sessionInteraction.d.ts +3 -1
  91. package/dist/react/v2/types/sessionInteraction.d.ts.map +1 -1
  92. package/dist/react/v2/types/sessionManifest.d.ts +12 -0
  93. package/dist/react/v2/types/sessionManifest.d.ts.map +1 -1
  94. package/dist/react/widget/mountExperienceWidget.d.ts.map +1 -1
  95. package/dist/react/widget/types.d.ts +7 -0
  96. package/dist/react/widget/types.d.ts.map +1 -1
  97. package/dist/sdk/v2/client.js +31 -6
  98. package/dist/sdk/v2/client.js.map +1 -1
  99. package/dist/svelte/Experience.svelte +36 -0
  100. package/dist/svelte/Experience.svelte.d.ts +2 -0
  101. package/dist/svelte/ExperienceThumbnail.svelte +3 -2
  102. package/dist/svelte/ExperienceThumbnail.svelte.d.ts +1 -1
  103. package/dist/svelte/ExperienceWidget.svelte +12 -1
  104. package/dist/svelte/ExperienceWidget.svelte.d.ts +3 -0
  105. package/package.json +14 -2
package/dist/npm/index.js CHANGED
@@ -29,28 +29,33 @@ function n(n, r = "/meet") {
29
29
  i?.protocol.startsWith("http") && window.location.assign(i.toString());
30
30
  }
31
31
  //#endregion
32
+ //#region src/thumbnail/types.ts
33
+ function r(e) {
34
+ return e === "face" ? "liforma-et--fit-face" : e === "medium" ? "liforma-et--fit-medium" : "";
35
+ }
36
+ //#endregion
32
37
  //#region src/thumbnail/toGalleryThumbUrl.ts
33
- var r = /(\/avatars\/[^/]+\/)(\d+)(\/)/i, i = /_CH(\.webp)/i, a = /(-)(\d+x\d+)(\.webp)(\?|$)/i;
34
- function o(e) {
38
+ var i = /(\/avatars\/[^/]+\/)(\d+)(\/)/i, a = /_CH(\.webp)/i, o = /(-)(\d+x\d+)(\.webp)(\?|$)/i;
39
+ function s(e) {
35
40
  let t = e.trim();
36
41
  if (!t) return t;
37
- let n = t.replace(r, (e, t, n, r) => n === "256" ? `${t}${n}${r}` : `${t}256${r}`);
38
- return n = n.replace(i, "_neutral$1"), n = n.replace(a, (e, t, n, r, i) => n === "256x256" ? `${t}${n}${r}${i}` : `${t}256x256${r}${i}`), n;
42
+ let n = t.replace(i, (e, t, n, r) => n === "256" ? `${t}${n}${r}` : `${t}256${r}`);
43
+ return n = n.replace(a, "_neutral$1"), n = n.replace(o, (e, t, n, r, i) => n === "256x256" ? `${t}${n}${r}${i}` : `${t}256x256${r}${i}`), n;
39
44
  }
40
- function s(e) {
45
+ function c(e) {
41
46
  let t = e.avatarImage?.trim() || e.galleryThumb?.avatarImage?.trim() || "";
42
47
  if (!t) return null;
43
48
  let n = e.backgroundImage?.trim() || e.galleryThumb?.backgroundImage?.trim() || "", r = e.foregroundImage?.trim() || e.galleryThumb?.foregroundImage?.trim() || "", i = e.fallbackImage?.trim() || "";
44
49
  return {
45
- avatarImage: o(t),
46
- ...n ? { backgroundImage: o(n) } : {},
47
- ...r ? { foregroundImage: o(r) } : {},
48
- ...i ? { fallbackImage: o(i) } : {}
50
+ avatarImage: s(t),
51
+ ...n ? { backgroundImage: s(n) } : {},
52
+ ...r ? { foregroundImage: s(r) } : {},
53
+ ...i ? { fallbackImage: s(i) } : {}
49
54
  };
50
55
  }
51
56
  //#endregion
52
57
  //#region src/shims/localStack.ts
53
- function c() {
58
+ function l() {
54
59
  if (globalThis.__LIFORMA_STACK === "local") return !0;
55
60
  if (typeof location > "u") return !1;
56
61
  try {
@@ -61,83 +66,83 @@ function c() {
61
66
  }
62
67
  //#endregion
63
68
  //#region src/thumbnail/hostedLaunchUrl.ts
64
- var l = "https://player.liforma.ai", u = "http://localhost:3002";
65
- function d(e) {
69
+ var u = "https://player.liforma.ai", d = "http://localhost:3002";
70
+ function f(e) {
66
71
  return e.href?.trim() ? "anchor" : e.hasClickHandler ? "button" : e.experienceId?.trim() ? "anchor" : "presentational";
67
72
  }
68
- function f(e) {
73
+ function p(e) {
69
74
  let t = e?.trim();
70
- return t ? t.replace(/\/$/, "") : c() ? u : l;
75
+ return t ? t.replace(/\/$/, "") : l() ? d : u;
71
76
  }
72
- function p(e) {
73
- let t = e.experienceId.trim(), n = f(e.playerBaseUrl), r = new URL(`${n}/${encodeURIComponent(t)}`), i = e.returnUrl?.trim();
77
+ function m(e) {
78
+ let t = e.experienceId.trim(), n = p(e.playerBaseUrl), r = new URL(`${n}/${encodeURIComponent(t)}`), i = e.returnUrl?.trim();
74
79
  return i && r.searchParams.set("returnUrl", i), r.toString();
75
80
  }
76
- function m(e) {
81
+ function h(e) {
77
82
  let t = e.href?.trim();
78
83
  if (t) return t;
79
84
  let n = e.experienceId?.trim();
80
85
  if (!n) return;
81
86
  let r = e.returnUrl?.trim();
82
- return !r && e.useCurrentPageAsReturnUrl && typeof window < "u" && (r = window.location.href), p({
87
+ return !r && e.useCurrentPageAsReturnUrl && typeof window < "u" && (r = window.location.href), m({
83
88
  experienceId: n,
84
89
  ...r ? { returnUrl: r } : {},
85
90
  playerBaseUrl: e.playerBaseUrl
86
91
  });
87
92
  }
88
- function h() {
93
+ function g() {
89
94
  return typeof window > "u" ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
90
95
  }
91
- var g = 0, _ = [];
92
- function ee() {
93
- return h() ? 4 : Infinity;
96
+ var _ = 0, v = [];
97
+ function y() {
98
+ return g() ? 4 : Infinity;
94
99
  }
95
- function v() {
96
- return h() ? 160 : 0;
100
+ function b() {
101
+ return g() ? 160 : 0;
97
102
  }
98
- function y() {
99
- let e = ee();
100
- for (; g < e && _.length > 0;) {
101
- let e = _.shift();
103
+ function x() {
104
+ let e = y();
105
+ for (; _ < e && v.length > 0;) {
106
+ let e = v.shift();
102
107
  if (!e || e.cancelled) continue;
103
- g += 1, e.start();
104
- let t = v();
108
+ _ += 1, e.start();
109
+ let t = b();
105
110
  if (t <= 0) {
106
- g = Math.max(0, g - 1);
111
+ _ = Math.max(0, _ - 1);
107
112
  continue;
108
113
  }
109
114
  window.setTimeout(() => {
110
- g = Math.max(0, g - 1), y();
115
+ _ = Math.max(0, _ - 1), x();
111
116
  }, t);
112
117
  }
113
118
  }
114
- function b(e) {
115
- if (!h()) return e(), () => {};
119
+ function S(e) {
120
+ if (!g()) return e(), () => {};
116
121
  let t = {
117
122
  start: e,
118
123
  cancelled: !1
119
124
  };
120
- return _.push(t), y(), () => {
125
+ return v.push(t), x(), () => {
121
126
  t.cancelled = !0;
122
127
  };
123
128
  }
124
129
  //#endregion
125
130
  //#region src/thumbnail/lazyLoad.ts
126
- function x() {
127
- return h() ? "96px 0px" : "280px 0px";
131
+ function ee() {
132
+ return g() ? "96px 0px" : "280px 0px";
128
133
  }
129
- function te(e) {
134
+ function C(e) {
130
135
  let t = e.trim().split(/\s+/)[0] ?? "0px", n = Number.parseFloat(t);
131
136
  return Number.isFinite(n) ? Math.abs(n) : 280;
132
137
  }
133
- function S(e, t) {
138
+ function w(e, t) {
134
139
  if (typeof window > "u") return !1;
135
140
  let n = e.getBoundingClientRect();
136
141
  return n.bottom >= -t && n.top <= window.innerHeight + t;
137
142
  }
138
- function C(e, t) {
139
- let { onVisibleChange: n } = t, r = t.rootMargin ?? x(), i = te(r), a = !1, o = !1, s = null, c = () => {
140
- o || (s?.(), s = b(() => {
143
+ function T(e, t) {
144
+ let { onVisibleChange: n } = t, r = t.rootMargin ?? ee(), i = C(r), a = !1, o = !1, s = null, c = () => {
145
+ o || (s?.(), s = S(() => {
141
146
  s = null, o = !0, n(!0);
142
147
  }));
143
148
  }, l = (e) => {
@@ -159,11 +164,11 @@ function C(e, t) {
159
164
  rootMargin: r,
160
165
  threshold: 0
161
166
  });
162
- return u.observe(e), S(e, i) && l(!0), () => {
167
+ return u.observe(e), w(e, i) && l(!0), () => {
163
168
  s?.(), s = null, u.disconnect();
164
169
  };
165
170
  }
166
- function w(e, t) {
171
+ function E(e, t) {
167
172
  let n = () => t();
168
173
  return e.complete ? queueMicrotask(n) : (e.addEventListener("load", n, { once: !0 }), e.addEventListener("error", n, { once: !0 })), () => {
169
174
  e.removeEventListener("load", n), e.removeEventListener("error", n);
@@ -171,40 +176,40 @@ function w(e, t) {
171
176
  }
172
177
  //#endregion
173
178
  //#region src/thumbnail/scrollParallax.ts
174
- function T() {
179
+ function D() {
175
180
  return typeof window > "u" || window.matchMedia("(prefers-reduced-motion: reduce)").matches ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
176
181
  }
177
- function E(e, t) {
182
+ function O(e, t) {
178
183
  return ((e.top + e.height / 2) / Math.max(t, 1) - .5) * 2;
179
184
  }
180
- var D = /* @__PURE__ */ new Set(), O = !1, k = 0;
181
- function A() {
182
- if (k = 0, D.size === 0 || typeof window > "u") return;
185
+ var k = /* @__PURE__ */ new Set(), A = !1, j = 0;
186
+ function M() {
187
+ if (j = 0, k.size === 0 || typeof window > "u") return;
183
188
  let e = window.innerHeight;
184
- for (let t of D) {
189
+ for (let t of k) {
185
190
  if (t.pointerActive?.()) continue;
186
191
  let n = t.element.getBoundingClientRect();
187
- n.bottom < -64 || n.top > e + 64 || t.onParallax(E(n, e));
192
+ n.bottom < -64 || n.top > e + 64 || t.onParallax(O(n, e));
188
193
  }
189
194
  }
190
- function j() {
191
- k === 0 && (k = requestAnimationFrame(A));
195
+ function N() {
196
+ j === 0 && (j = requestAnimationFrame(M));
192
197
  }
193
- function M() {
194
- O || typeof window > "u" || (O = !0, window.addEventListener("scroll", j, { passive: !0 }), window.addEventListener("resize", j, { passive: !0 }));
198
+ function P() {
199
+ A || typeof window > "u" || (A = !0, window.addEventListener("scroll", N, { passive: !0 }), window.addEventListener("resize", N, { passive: !0 }));
195
200
  }
196
- function N() {
197
- D.size > 0 || !O || typeof window > "u" || (O = !1, k !== 0 && (cancelAnimationFrame(k), k = 0), window.removeEventListener("scroll", j), window.removeEventListener("resize", j));
201
+ function F() {
202
+ k.size > 0 || !A || typeof window > "u" || (A = !1, j !== 0 && (cancelAnimationFrame(j), j = 0), window.removeEventListener("scroll", N), window.removeEventListener("resize", N));
198
203
  }
199
- function P(e, t) {
200
- if (!T()) return () => {};
204
+ function te(e, t) {
205
+ if (!D()) return () => {};
201
206
  let n = {
202
207
  element: e,
203
208
  onParallax: t.onParallax,
204
209
  pointerActive: t.pointerActive
205
210
  };
206
- return D.add(n), M(), n.pointerActive?.() || t.onParallax(E(e.getBoundingClientRect(), window.innerHeight)), () => {
207
- D.delete(n), N();
211
+ return k.add(n), P(), n.pointerActive?.() || t.onParallax(O(e.getBoundingClientRect(), window.innerHeight)), () => {
212
+ k.delete(n), F();
208
213
  };
209
214
  }
210
215
  //#endregion
@@ -213,7 +218,7 @@ function ne(e) {
213
218
  let t = 0, n = 0, r = !1, i = !1, a = !1, o = () => {
214
219
  let a = r || i;
215
220
  e.classList.toggle("liforma-et--parallax", a), e.classList.toggle("liforma-et--scroll-parallax", i), e.style.setProperty("--liforma-et-parallax-x", String(t)), e.style.setProperty("--liforma-et-parallax-y", String(n));
216
- }, s = P(e, {
221
+ }, s = te(e, {
217
222
  onParallax: (e) => {
218
223
  i = !0, a || (t = e, n = 0, o());
219
224
  },
@@ -226,7 +231,7 @@ function ne(e) {
226
231
  a = !0, e.pointerType === "mouse" && (r = !0), o();
227
232
  }, u = () => {
228
233
  let s = a;
229
- a = !1, r = !1, i && s ? (t = E(e.getBoundingClientRect(), window.innerHeight), n = 0) : i || (t = 0, n = 0), o();
234
+ a = !1, r = !1, i && s ? (t = O(e.getBoundingClientRect(), window.innerHeight), n = 0) : i || (t = 0, n = 0), o();
230
235
  }, d = (e) => {
231
236
  e.pointerType === "mouse" && (r = !0, o());
232
237
  }, f = () => {
@@ -238,15 +243,15 @@ function ne(e) {
238
243
  }
239
244
  //#endregion
240
245
  //#region src/thumbnail/styles.ts
241
- var re = ".liforma-et {\n --liforma-et-parallax-x: 0;\n --liforma-et-parallax-y: 0;\n --liforma-et-bg-scale: 1;\n --liforma-et-fg-scale: 1;\n --liforma-et-avatar-scale: 1;\n --liforma-et-bg-shift: 0px;\n --liforma-et-fg-shift: 0px;\n --liforma-et-avatar-shift: 0px;\n --liforma-et-reveal-duration: 420ms;\n\n box-sizing: border-box;\n position: relative;\n display: block;\n width: 100%;\n height: 100%;\n min-height: 0;\n margin: 0;\n padding: 0;\n border: 0;\n border-radius: 0.65rem;\n overflow: hidden;\n background: #111;\n color: inherit;\n text-decoration: none;\n cursor: inherit;\n -webkit-tap-highlight-color: transparent;\n}\n\na.liforma-et,\nbutton.liforma-et {\n cursor: pointer;\n}\n\nbutton.liforma-et {\n font: inherit;\n appearance: none;\n}\n\n.liforma-et__placeholder {\n position: absolute;\n inset: 0;\n z-index: 0;\n background:\n radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.06), transparent 58%),\n linear-gradient(180deg, #1a1a1a 0%, #101010 100%);\n opacity: 1;\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n.liforma-et--revealed .liforma-et__placeholder {\n opacity: 0;\n}\n\n.liforma-et__media {\n opacity: 0;\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n.liforma-et__media--ready {\n opacity: 1;\n}\n\n.liforma-et__background {\n position: absolute;\n inset: 0;\n z-index: 1;\n width: 100%;\n height: 100%;\n object-fit: cover;\n object-position: center center;\n transform: translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-bg-shift)),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-bg-shift))\n )\n scale(var(--liforma-et-bg-scale));\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n.liforma-et__avatar {\n position: relative;\n z-index: 2;\n display: block;\n width: 100%;\n height: 100%;\n object-fit: contain;\n object-position: center bottom;\n transform: scale(var(--liforma-et-avatar-scale))\n translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-avatar-shift)),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-avatar-shift))\n );\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n/* Gallery plates are typically square in a square tile — contain vs cover is a no-op\n without a zoom. Scale the whole scene from the upper third so Face matches\n player fit (location + avatar crop together). */\n.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.85;\n --liforma-et-bg-scale: 1.85;\n --liforma-et-fg-scale: 1.85;\n}\n\n.liforma-et--fit-face .liforma-et__avatar,\n.liforma-et--fit-face .liforma-et__background,\n.liforma-et--fit-face .liforma-et__foreground {\n transform-origin: 50% 18%;\n}\n\n.liforma-et--fit-face .liforma-et__avatar {\n object-fit: cover;\n object-position: 50% 18%;\n}\n\n.liforma-et__foreground {\n position: absolute;\n inset: 0;\n z-index: 3;\n width: 100%;\n height: 100%;\n object-fit: cover;\n object-position: center center;\n pointer-events: none;\n transform: translate(\n calc(var(--liforma-et-parallax-x) * var(--liforma-et-fg-shift) * -1),\n calc(var(--liforma-et-parallax-y) * var(--liforma-et-fg-shift) * -1)\n )\n scale(var(--liforma-et-fg-scale));\n transform-origin: center center;\n transition:\n opacity var(--liforma-et-reveal-duration) ease,\n transform 160ms ease;\n}\n\n.liforma-et--parallax {\n --liforma-et-bg-scale: 1.08;\n --liforma-et-fg-scale: 1.05;\n --liforma-et-avatar-scale: 1.08;\n --liforma-et-bg-shift: 10px;\n --liforma-et-fg-shift: 4px;\n --liforma-et-avatar-shift: 4px;\n}\n\n/* Promote layers only while parallax is active — avoids N compositor surfaces on galleries. */\n.liforma-et--parallax .liforma-et__background,\n.liforma-et--parallax .liforma-et__foreground,\n.liforma-et--parallax .liforma-et__avatar {\n will-change: transform;\n}\n\n.liforma-et--parallax.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.95;\n --liforma-et-bg-scale: 1.95;\n --liforma-et-fg-scale: 1.95;\n --liforma-et-avatar-shift: 0px;\n}\n\n.liforma-et--scroll-parallax .liforma-et__background,\n.liforma-et--scroll-parallax .liforma-et__foreground,\n.liforma-et--scroll-parallax .liforma-et__avatar {\n transition: opacity var(--liforma-et-reveal-duration) ease;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .liforma-et {\n --liforma-et-reveal-duration: 0ms;\n }\n\n .liforma-et--parallax {\n --liforma-et-bg-scale: 1;\n --liforma-et-fg-scale: 1;\n --liforma-et-avatar-scale: 1;\n --liforma-et-bg-shift: 0px;\n --liforma-et-fg-shift: 0px;\n --liforma-et-avatar-shift: 0px;\n }\n\n .liforma-et--parallax.liforma-et--fit-face {\n --liforma-et-avatar-scale: 1.85;\n --liforma-et-bg-scale: 1.85;\n --liforma-et-fg-scale: 1.85;\n }\n\n .liforma-et__background,\n .liforma-et__foreground,\n .liforma-et__avatar {\n transition: none;\n }\n}", F = !1;
242
- function I(e) {
243
- if (typeof document > "u" || F) return;
246
+ var I = ".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}", L = !1;
247
+ function re(e) {
248
+ if (typeof document > "u" || L) return;
244
249
  if (document.querySelector("style[data-liforma-et]")) {
245
- F = !0;
250
+ L = !0;
246
251
  return;
247
252
  }
248
253
  let t = document.createElement("style");
249
- t.setAttribute("data-liforma-et", ""), t.textContent = e, document.head.appendChild(t), F = !0;
254
+ t.setAttribute("data-liforma-et", ""), t.textContent = e, document.head.appendChild(t), L = !0;
250
255
  }
251
256
  //#endregion
252
257
  //#region src/widget/styles.ts
@@ -263,8 +268,8 @@ function oe(e = ie) {
263
268
  }
264
269
  //#endregion
265
270
  //#region src/shims/apiBaseUrl.ts
266
- var se = "https://api.liforma.ai", L = "http://localhost:3001";
267
- function R() {
271
+ var R = "https://api.liforma.ai", z = "http://localhost:3001";
272
+ function se() {
268
273
  let e = globalThis.__LIFORMA_API_BASE_URL;
269
274
  if (e?.trim()) return e.trim().replace(/\/$/, "");
270
275
  if (typeof document > "u") return null;
@@ -272,7 +277,7 @@ function R() {
272
277
  return t ? t.replace(/\/$/, "") : null;
273
278
  }
274
279
  function ce() {
275
- return R() || (c() ? L : se);
280
+ return se() || (l() ? z : R);
276
281
  }
277
282
  //#endregion
278
283
  //#region src/v2/api/fetchExperiencePreview.ts
@@ -318,7 +323,7 @@ async function ue(e, t) {
318
323
  }
319
324
  //#endregion
320
325
  //#region src/v2/errors/LiformaError.ts
321
- var z = class extends Error {
326
+ var B = class extends Error {
322
327
  code;
323
328
  requestId;
324
329
  status;
@@ -336,7 +341,7 @@ function fe(e, t, n) {
336
341
  i = JSON.parse(t);
337
342
  } catch {}
338
343
  let a = i?.error && typeof i.error == "object" ? i.error : void 0, o = a?.code ?? i?.code, s = a?.message ?? i?.message, c = a?.requestId ?? i?.requestId ?? r, l = typeof o == "string" && o.trim() ? o.trim() : "HTTP_ERROR", u = typeof s == "string" && s.trim() ? s.trim() : t.trim().slice(0, 500) || `Request failed (${e})`, d = typeof c == "string" && c.trim() ? c.trim() : r, { code: f, message: p, requestId: m, ...h } = de(a) ?? de(i) ?? {};
339
- return new z(u, {
344
+ return new B(u, {
340
345
  code: l,
341
346
  requestId: d,
342
347
  status: e,
@@ -345,14 +350,14 @@ function fe(e, t, n) {
345
350
  }
346
351
  //#endregion
347
352
  //#region src/v2/api/sessionEndpointRequest.ts
348
- function pe(e) {
353
+ function V(e) {
349
354
  let t = e.locale?.trim();
350
355
  if (t) return t;
351
356
  let n = e.language?.trim();
352
357
  if (n) return n;
353
358
  if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
354
359
  }
355
- function B(e) {
360
+ function pe(e) {
356
361
  let t = e.secondaryLocale?.trim(), n = e.learningLocale?.trim();
357
362
  if (t && n && t !== n) throw Error("secondaryLocale and learningLocale disagree; pass only one or make them equal.");
358
363
  return t || n || void 0;
@@ -365,7 +370,7 @@ function me(e, t) {
365
370
  if (r.origin !== location.origin) throw Error("sessionEndpoint must be same-origin.");
366
371
  let i = t.experienceId.trim();
367
372
  if (!i) throw Error("sessionEndpoint requires experienceId.");
368
- let a = pe(t), o = B(t), s = t.idempotencyKey?.trim();
373
+ let a = V(t), o = pe(t), s = t.idempotencyKey?.trim();
369
374
  return {
370
375
  url: r.toString(),
371
376
  init: {
@@ -389,16 +394,16 @@ function me(e, t) {
389
394
  }
390
395
  //#endregion
391
396
  //#region src/v2/types/sessionLaunch.ts
392
- function V(e) {
397
+ function H(e) {
393
398
  return !!e && typeof e == "object" && !Array.isArray(e);
394
399
  }
395
- function H(e) {
400
+ function U(e) {
396
401
  return typeof e == "boolean";
397
402
  }
398
- function he(e) {
399
- if (!V(e)) return null;
403
+ function W(e) {
404
+ if (!H(e)) return null;
400
405
  let t = e.speech, n = e.conversation, r = e.avatar, i = e.tools;
401
- return !V(t) || !V(n) || !V(r) || !V(i) || !H(t.input) || !H(t.output) || !H(t.externalAudio) || !H(n.managed) || !H(r.enabled) || !H(i.enabled) ? null : {
406
+ return !H(t) || !H(n) || !H(r) || !H(i) || !U(t.input) || !U(t.output) || !U(t.externalAudio) || !U(n.managed) || !U(r.enabled) || !U(i.enabled) ? null : {
402
407
  speech: {
403
408
  input: t.input,
404
409
  output: t.output,
@@ -409,8 +414,8 @@ function he(e) {
409
414
  tools: { enabled: i.enabled }
410
415
  };
411
416
  }
412
- function U(e) {
413
- return !V(e) || !H(e.avatar) || !H(e.speechInput) || !H(e.speechOutput) || !H(e.tools) || !H(e.externalAudio) ? null : {
417
+ function he(e) {
418
+ return !H(e) || !U(e.avatar) || !U(e.speechInput) || !U(e.speechOutput) || !U(e.tools) || !U(e.externalAudio) ? null : {
414
419
  speech: {
415
420
  input: e.speechInput,
416
421
  output: e.speechOutput,
@@ -422,10 +427,10 @@ function U(e) {
422
427
  };
423
428
  }
424
429
  function ge(e) {
425
- return he(e) ?? U(e);
430
+ return W(e) ?? he(e);
426
431
  }
427
432
  function _e(e) {
428
- if (!V(e)) throw Error("Session Launch response is missing session.");
433
+ if (!H(e)) throw Error("Session Launch response is missing session.");
429
434
  let t = typeof e.id == "string" ? e.id.trim() : "", n = typeof e.experienceId == "string" ? e.experienceId.trim() : "", r = typeof e.experienceRevisionId == "string" ? e.experienceRevisionId.trim() : "", i = typeof e.expiresAt == "string" ? e.expiresAt.trim() : "", a = typeof e.locale == "string" ? e.locale.trim() : "", o = typeof e.secondaryLocale == "string" && e.secondaryLocale.trim() ? e.secondaryLocale.trim() : void 0, s = e.mode === "conversation" || e.mode === "presenter" ? e.mode : null, c = ge(e.capabilities), l = ve(e.localeVoiceFallbacks), u = e.status === "active" || e.status === "ended" ? e.status : void 0, d = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt.trim() : void 0;
430
435
  if (!t || !n || !r || !i || !a || !s || !c) throw Error("Session Launch response has an invalid session object.");
431
436
  return {
@@ -446,7 +451,7 @@ function ve(e) {
446
451
  if (!Array.isArray(e) || e.length === 0) return;
447
452
  let t = [];
448
453
  for (let n of e) {
449
- if (!V(n)) continue;
454
+ if (!H(n)) continue;
450
455
  let e = n.axis === "locale" || n.axis === "secondaryLocale" ? n.axis : null, r = typeof n.requested == "string" ? n.requested.trim() : "", i = typeof n.resolved == "string" ? n.resolved.trim() : "";
451
456
  !e || !r || !i || n.reason !== "voice_unsupported" || t.push({
452
457
  axis: e,
@@ -464,8 +469,8 @@ function ye(e) {
464
469
  console.warn(`[liforma] Session ${t} fell back to ${e.resolved} because the voice does not support ${e.requested}.`);
465
470
  }
466
471
  }
467
- function be(e) {
468
- if (!V(e)) throw Error("Session Launch response must be a JSON object.");
472
+ function G(e) {
473
+ if (!H(e)) throw Error("Session Launch response must be a JSON object.");
469
474
  let t = typeof e.launch == "string" ? e.launch.trim() : "";
470
475
  if (!t) throw Error("Session Launch response is missing launch.");
471
476
  let n = _e(e.session);
@@ -476,7 +481,7 @@ function be(e) {
476
481
  }
477
482
  //#endregion
478
483
  //#region src/v2/api/mintPublicSession.ts
479
- function W() {
484
+ function be() {
480
485
  try {
481
486
  if (typeof globalThis.location?.origin == "string" && globalThis.location.origin) return globalThis.location.origin;
482
487
  } catch {}
@@ -485,23 +490,23 @@ function xe(e) {
485
490
  return e ? e.trim().toUpperCase().replace(/-/g, "_") : "";
486
491
  }
487
492
  function Se(e, t) {
488
- let n = W(), r = xe(t.code), i = t.message.trim(), a = t.details ?? {};
493
+ let n = be(), r = xe(t.code), i = t.message.trim(), a = t.details ?? {};
489
494
  if (r === "ORIGIN_NOT_ALLOWED" || /^Origin not allowed/i.test(i) && n) {
490
495
  if (i.includes(e) && i.includes("allowed origin")) return t;
491
496
  let r = typeof a.origin == "string" && a.origin || n || "(unknown origin)";
492
- return new z(`Your origin ${r} is not an allowed origin for experience ${e}. If you own this experience, sign in to the Liforma developer portal (app.liforma.ai), open Workspace → Settings → Origins, add ${r} to the list of allowed origins, and ensure “Allow public client-only embeds” is enabled.`, {
497
+ return new B(`Your origin ${r} is not an allowed origin for experience ${e}. If you own this experience, sign in to the Liforma developer portal (app.liforma.ai), open Workspace → Settings → Origins, add ${r} to the list of allowed origins, and ensure “Allow public client-only embeds” is enabled.`, {
493
498
  code: "ORIGIN_NOT_ALLOWED",
494
499
  requestId: t.requestId,
495
500
  status: t.status,
496
501
  details: a
497
502
  });
498
503
  }
499
- return r === "BROWSER_EMBEDS_DISABLED" || /^Browser embeds are not enabled/i.test(i) ? i.includes("Allow public client-only embeds") ? t : new z(`Browser embeds are not enabled for experience ${e}. If you own this experience, sign in to the Liforma developer portal (app.liforma.ai), open Workspace → Settings → Origins, and enable “Allow public client-only embeds”.`, {
504
+ return r === "BROWSER_EMBEDS_DISABLED" || /^Browser embeds are not enabled/i.test(i) ? i.includes("Allow public client-only embeds") ? t : new B(`Browser embeds are not enabled for experience ${e}. If you own this experience, sign in to the Liforma developer portal (app.liforma.ai), open Workspace → Settings → Origins, and enable “Allow public client-only embeds”.`, {
500
505
  code: "BROWSER_EMBEDS_DISABLED",
501
506
  requestId: t.requestId,
502
507
  status: t.status,
503
508
  details: a
504
- }) : r === "EXPERIENCE_UNAVAILABLE" || /^Experience is not available\.?$/i.test(i) || /^Unknown experience\.?$/i.test(i) ? i.includes("No playable experience found") ? t : new z(`No playable experience found for “${e}”. Check that the experience id is correct (it should look like exp_…), and that the experience exists and is published in the Liforma developer portal (app.liforma.ai). Deleted, archived, and unpublished experiences cannot be started from a browser embed.`, {
509
+ }) : r === "EXPERIENCE_UNAVAILABLE" || /^Experience is not available\.?$/i.test(i) || /^Unknown experience\.?$/i.test(i) ? i.includes("No playable experience found") ? t : new B(`No playable experience found for “${e}”. Check that the experience id is correct (it should look like exp_…), and that the experience exists and is published in the Liforma developer portal (app.liforma.ai). Deleted, archived, and unpublished experiences cannot be started from a browser embed.`, {
505
510
  code: "EXPERIENCE_UNAVAILABLE",
506
511
  requestId: t.requestId,
507
512
  status: t.status,
@@ -517,7 +522,7 @@ function Ce(e) {
517
522
  }
518
523
  function we(e) {
519
524
  let t = e?.secondaryLocale?.trim(), n = e?.learningLocale?.trim();
520
- if (t && n && t !== n) throw new z("secondaryLocale and learningLocale disagree; pass only one or make them equal.", { code: "INVALID_BODY" });
525
+ if (t && n && t !== n) throw new B("secondaryLocale and learningLocale disagree; pass only one or make them equal.", { code: "INVALID_BODY" });
521
526
  return t || n || void 0;
522
527
  }
523
528
  function Te(e, t) {
@@ -543,15 +548,15 @@ async function Ee(e, t) {
543
548
  try {
544
549
  a = await i.json();
545
550
  } catch {
546
- throw new z("Browser session mint returned invalid JSON.", {
551
+ throw new B("Browser session mint returned invalid JSON.", {
547
552
  code: "INVALID_RESPONSE",
548
553
  status: i.status,
549
554
  requestId: i.headers.get("Liforma-Request-Id") ?? void 0
550
555
  });
551
556
  }
552
- return be(a);
557
+ return G(a);
553
558
  }
554
- async function De(e, t) {
559
+ async function K(e, t) {
555
560
  let n = me(e, t), r = new AbortController(), i = () => r.abort(t.signal?.reason);
556
561
  t.signal?.aborted ? i() : t.signal?.addEventListener("abort", i, { once: !0 });
557
562
  let a = globalThis.setTimeout(() => r.abort(new DOMException("Session endpoint timed out.", "TimeoutError")), t.timeoutMs ?? 3e4), o;
@@ -567,7 +572,7 @@ async function De(e, t) {
567
572
  let e = await o.text();
568
573
  throw fe(o.status, e, o.headers);
569
574
  }
570
- if (!o.headers.get("content-type")?.toLowerCase().includes("application/json")) throw new z("Session endpoint must return a JSON Session Launch response.", {
575
+ if (!o.headers.get("content-type")?.toLowerCase().includes("application/json")) throw new B("Session endpoint must return a JSON Session Launch response.", {
571
576
  code: "INVALID_RESPONSE",
572
577
  status: o.status,
573
578
  requestId: o.headers.get("Liforma-Request-Id") ?? void 0
@@ -576,17 +581,17 @@ async function De(e, t) {
576
581
  try {
577
582
  s = await o.json();
578
583
  } catch {
579
- throw new z("Session endpoint returned invalid JSON.", {
584
+ throw new B("Session endpoint returned invalid JSON.", {
580
585
  code: "INVALID_RESPONSE",
581
586
  status: o.status,
582
587
  requestId: o.headers.get("Liforma-Request-Id") ?? void 0
583
588
  });
584
589
  }
585
- return be(s);
590
+ return G(s);
586
591
  }
587
592
  //#endregion
588
593
  //#region src/v2/conversationProcessor.ts
589
- function G(e) {
594
+ function De(e) {
590
595
  return typeof e != "object" || !e ? !1 : typeof e[Symbol.asyncIterator] == "function";
591
596
  }
592
597
  function Oe(e) {
@@ -605,7 +610,7 @@ function Oe(e) {
605
610
  }
606
611
  async function ke(e, t) {
607
612
  let n = await e(t);
608
- return G(n) ? {
613
+ return De(n) ? {
609
614
  kind: "stream",
610
615
  stream: n
611
616
  } : {
@@ -616,11 +621,11 @@ async function ke(e, t) {
616
621
  //#endregion
617
622
  //#region src/v2/embed/playerReachability.ts
618
623
  var Ae = "3002";
619
- function K(e) {
624
+ function q(e) {
620
625
  let t = new URL(e);
621
626
  return t.hostname === "localhost" || t.hostname === "127.0.0.1" ? `Cannot connect to the Liforma player at ${e} — nothing is listening on port ${t.port || Ae}. Start the player dev server in player.liforma.ai (npm run dev).` : `Cannot connect to the Liforma player at ${e}. The embed did not load; check your network connection and player URL configuration.`;
622
627
  }
623
- async function q(e, t) {
628
+ async function je(e, t) {
624
629
  try {
625
630
  await fetch(e, {
626
631
  method: "GET",
@@ -628,14 +633,14 @@ async function q(e, t) {
628
633
  signal: AbortSignal.timeout(8e3)
629
634
  });
630
635
  } catch {
631
- throw Error(K(t));
636
+ throw Error(q(t));
632
637
  }
633
638
  }
634
- function je(e, t, n, r) {
639
+ function J(e, t, n, r) {
635
640
  try {
636
641
  r && r.length > 0 ? e.postMessage(t, n, r) : e.postMessage(t, n);
637
642
  } catch (e) {
638
- throw e instanceof DOMException && e.name === "SecurityError" ? Error(K(n), { cause: e }) : e;
643
+ throw e instanceof DOMException && e.name === "SecurityError" ? Error(q(n), { cause: e }) : e;
639
644
  }
640
645
  }
641
646
  var Me = new Set([1, 2]);
@@ -649,14 +654,18 @@ var Pe = new Set([
649
654
  "userTranscript",
650
655
  "characterSpeechStarted",
651
656
  "characterSpeechEnded",
657
+ "characterFocusChanged",
652
658
  "conversationUpdate",
653
659
  "listeningState",
654
660
  "userSpeechStarted",
655
661
  "userSpeechEnded",
656
662
  "modeChange",
657
663
  "activityChange",
664
+ "feedback",
665
+ "feedbackFailed",
658
666
  "message",
659
667
  "started",
668
+ "embedReady",
660
669
  "widgetReady",
661
670
  "widgetExpand",
662
671
  "widgetCollapse",
@@ -669,7 +678,7 @@ function Fe(e) {
669
678
  if (!e || typeof e != "object") return null;
670
679
  let t = e;
671
680
  if (!Ne(t.schemaVersion) || !t.type || !Pe.has(t.type)) return null;
672
- if (t.type === "widgetReady" || t.type === "widgetExpand" || t.type === "widgetCollapse") return t;
681
+ if (t.type === "embedReady" || t.type === "widgetReady" || t.type === "widgetExpand" || t.type === "widgetCollapse") return t;
673
682
  if (t.type === "widgetAudioSettings") {
674
683
  let e = t.payload;
675
684
  return !e || typeof e != "object" || typeof e.open != "boolean" ? null : t;
@@ -684,18 +693,21 @@ function Fe(e) {
684
693
  let { pointerId: n, dx: r, dy: i } = e;
685
694
  return typeof n != "number" || !Number.isFinite(n) || typeof r != "number" || !Number.isFinite(r) || typeof i != "number" || !Number.isFinite(i) ? null : t;
686
695
  }
687
- return !t.payload || typeof t.payload != "object" ? null : t;
696
+ let n = t.payload;
697
+ return !n || typeof n != "object" ? null : t;
688
698
  }
689
699
  function Ie(e, t, n) {
690
700
  let r = e.trim();
691
701
  if (!r) throw Error("createLaunchMessage requires a non-empty launch string.");
702
+ let i = n?.startButton, a = n?.showFeedback;
692
703
  return {
693
704
  type: "launch",
694
705
  schemaVersion: 2,
695
706
  payload: {
696
707
  launch: r,
697
708
  ...t === void 0 ? {} : { session: t },
698
- ...n ? { startButton: n } : {}
709
+ ...i ? { startButton: i } : {},
710
+ ...a === void 0 ? {} : { showFeedback: a }
699
711
  }
700
712
  };
701
713
  }
@@ -724,7 +736,7 @@ function ze() {
724
736
  function Be(e) {
725
737
  return e;
726
738
  }
727
- function J() {
739
+ function Y() {
728
740
  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)}`;
729
741
  }
730
742
  var Ve = 3e4;
@@ -733,16 +745,36 @@ function He(e) {
733
745
  getComputedStyle(t).position === "static" && (t.style.position = "relative");
734
746
  let n = document.createElement("iframe");
735
747
  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");
736
- let r = !1, i = /* @__PURE__ */ new Map(), a = new Promise((t, r) => {
737
- let i = () => {
738
- o(), q(e.src, e.playerOrigin).then(t, r);
739
- }, a = () => {
740
- o(), r(Error(K(e.playerOrigin)));
741
- }, o = () => {
742
- n.removeEventListener("load", i), n.removeEventListener("error", a);
748
+ let r = !1, i = /* @__PURE__ */ new Map(), a = null, o = 0, s = 0, c = [], l = null, u = null, d = new Promise((e, t) => {
749
+ l = e, u = t;
750
+ }), f = () => {
751
+ for (let e of c) window.clearTimeout(e);
752
+ c.length = 0;
753
+ }, p = (t) => {
754
+ if (r) return;
755
+ let i = Date.now();
756
+ if (s > 0 && i - s < 250) return;
757
+ s = i, f();
758
+ let a = Ie(t.launch, t.session, t.chrome), o = () => {
759
+ if (r) return;
760
+ let t = n.contentWindow;
761
+ t && J(t, a, e.playerOrigin);
743
762
  };
744
- n.addEventListener("load", i), n.addEventListener("error", a);
745
- }), o = (t) => {
763
+ o();
764
+ for (let e = 1; e <= 12; e += 1) c.push(window.setTimeout(o, e * 75));
765
+ }, m = () => {
766
+ r || !a || p(a);
767
+ }, h = () => {
768
+ if (o += 1, o === 1) {
769
+ je(e.src, e.playerOrigin).then(() => l?.(), (e) => u?.(e instanceof Error ? e : Error(String(e))));
770
+ return;
771
+ }
772
+ s = 0, m();
773
+ }, g = () => {
774
+ o > 0 || u?.(Error(q(e.playerOrigin)));
775
+ };
776
+ n.addEventListener("load", h), n.addEventListener("error", g);
777
+ let _ = (t) => {
746
778
  if (r || t.source !== n.contentWindow || t.origin !== e.playerOrigin) return;
747
779
  let a = Fe(t.data);
748
780
  if (a) switch (a.type) {
@@ -767,6 +799,9 @@ function He(e) {
767
799
  case "characterSpeechEnded":
768
800
  e.onCharacterSpeechEnded?.(a.payload);
769
801
  break;
802
+ case "characterFocusChanged":
803
+ e.onCharacterFocusChanged?.(a.payload);
804
+ break;
770
805
  case "conversationUpdate":
771
806
  e.onConversationUpdate?.(a.payload.conversation);
772
807
  break;
@@ -785,12 +820,21 @@ function He(e) {
785
820
  case "activityChange":
786
821
  e.onActivityChange?.(a.payload.activity);
787
822
  break;
823
+ case "feedback":
824
+ e.onFeedback?.(a.payload);
825
+ break;
826
+ case "feedbackFailed":
827
+ e.onFeedbackFailed?.(a.payload);
828
+ break;
788
829
  case "message":
789
830
  e.onMessage?.(a.payload);
790
831
  break;
791
832
  case "started":
792
833
  e.onStarted?.(a.payload);
793
834
  break;
835
+ case "embedReady":
836
+ m();
837
+ break;
794
838
  case "widgetReady":
795
839
  e.onWidgetReady?.();
796
840
  break;
@@ -814,42 +858,39 @@ function He(e) {
814
858
  break;
815
859
  }
816
860
  };
817
- if (window.addEventListener("message", o), t.replaceChildren(n), t.clientHeight < 2 && !t.style.minHeight) {
861
+ if (window.addEventListener("message", _), t.replaceChildren(n), t.clientHeight < 2 && !t.style.minHeight) {
818
862
  let e = getComputedStyle(t).minHeight;
819
863
  (e === "0px" || e === "auto") && (t.style.minHeight = "480px");
820
864
  }
821
- let s = (t, i) => {
865
+ let v = (t, i) => {
822
866
  if (r) return;
823
867
  let a = n.contentWindow;
824
- if (!a) throw Error(K(e.playerOrigin));
825
- je(a, t, e.playerOrigin, i);
826
- }, c = (e, t = 12e4, n) => {
827
- let r = e.type !== "parentHello" && e.payload && "correlationId" in e.payload ? e.payload.correlationId : J();
868
+ if (!a) throw Error(q(e.playerOrigin));
869
+ J(a, t, e.playerOrigin, i);
870
+ }, y = (e, t = 12e4, n) => {
871
+ let r = e.type !== "parentHello" && e.payload && "correlationId" in e.payload ? e.payload.correlationId : Y();
828
872
  return e.type !== "parentHello" && e.payload && "correlationId" in e.payload || e.type !== "parentHello" && e.payload && (e.payload.correlationId = r), new Promise((a, o) => {
829
873
  i.set(r, {
830
874
  resolve: (e) => a(e),
831
875
  reject: o
832
- }), s(e, n), setTimeout(() => {
876
+ }), v(e, n), setTimeout(() => {
833
877
  i.has(r) && (i.delete(r), o(/* @__PURE__ */ Error("Timed out waiting for player command result.")));
834
878
  }, t);
835
879
  });
836
880
  };
837
881
  return {
838
882
  waitForLoad() {
839
- return a;
883
+ return d;
840
884
  },
841
885
  postParentHello() {
842
- s(Le());
886
+ v(Le());
843
887
  },
844
- postLaunch(t, i, a) {
845
- if (r) return;
846
- let o = n.contentWindow;
847
- if (!o) throw Error("Liforma embed iframe is not ready.");
848
- let s = Ie(t, i, a), c = () => {
849
- r || je(o, s, e.playerOrigin);
850
- };
851
- c();
852
- for (let e = 1; e <= 12; e += 1) window.setTimeout(c, e * 75);
888
+ postLaunch(e, t, n) {
889
+ r || (a = {
890
+ launch: e,
891
+ session: t,
892
+ chrome: n
893
+ }, s = 0, p(a));
853
894
  },
854
895
  postManifest(e) {
855
896
  if (typeof e == "string") {
@@ -864,17 +905,17 @@ function He(e) {
864
905
  throw Error("postManifest is deprecated; use postLaunch with an opaque launch string from SessionLaunchResponse.");
865
906
  },
866
907
  postWidgetSetChrome(e) {
867
- s(Re(e));
908
+ v(Re(e));
868
909
  },
869
910
  postWidgetToggleAudioSettings() {
870
- s(ze());
911
+ v(ze());
871
912
  },
872
913
  speak(e) {
873
- return c({
914
+ return y({
874
915
  type: "speak",
875
916
  schemaVersion: 2,
876
917
  payload: {
877
- correlationId: J(),
918
+ correlationId: Y(),
878
919
  text: e.text,
879
920
  ...e.characterId ? { characterId: e.characterId } : {},
880
921
  ...e.behavior ? { behavior: e.behavior } : {}
@@ -882,31 +923,31 @@ function He(e) {
882
923
  });
883
924
  },
884
925
  startListening() {
885
- return c({
926
+ return y({
886
927
  type: "startListening",
887
928
  schemaVersion: 2,
888
- payload: { correlationId: J() }
929
+ payload: { correlationId: Y() }
889
930
  });
890
931
  },
891
932
  stopListening() {
892
- return c({
933
+ return y({
893
934
  type: "stopListening",
894
935
  schemaVersion: 2,
895
- payload: { correlationId: J() }
936
+ payload: { correlationId: Y() }
896
937
  });
897
938
  },
898
939
  listenOnce(e) {
899
- return c({
940
+ return y({
900
941
  type: "listenOnce",
901
942
  schemaVersion: 2,
902
943
  payload: {
903
- correlationId: J(),
944
+ correlationId: Y(),
904
945
  ...e?.timeoutMs === void 0 ? {} : { timeoutMs: e.timeoutMs }
905
946
  }
906
947
  });
907
948
  },
908
949
  async speakProcessorStream(e, t) {
909
- let n = J(), r = J(), i = (await c({
950
+ let n = Y(), r = Y(), i = (await y({
910
951
  type: "speakStreamStart",
911
952
  schemaVersion: 2,
912
953
  payload: {
@@ -918,7 +959,7 @@ function He(e) {
918
959
  try {
919
960
  for await (let n of e) {
920
961
  if (t?.signal?.aborted) throw new DOMException("Processor stream aborted.", "AbortError");
921
- n && s({
962
+ n && v({
922
963
  type: "speakStreamChunk",
923
964
  schemaVersion: 2,
924
965
  payload: {
@@ -928,7 +969,7 @@ function He(e) {
928
969
  });
929
970
  }
930
971
  if (t?.signal?.aborted) throw new DOMException("Processor stream aborted.", "AbortError");
931
- return await c({
972
+ return await y({
932
973
  type: "speakStreamEnd",
933
974
  schemaVersion: 2,
934
975
  payload: {
@@ -938,7 +979,7 @@ function He(e) {
938
979
  });
939
980
  } catch (e) {
940
981
  try {
941
- await c({
982
+ await y({
942
983
  type: "speakStreamEnd",
943
984
  schemaVersion: 2,
944
985
  payload: {
@@ -951,8 +992,8 @@ function He(e) {
951
992
  }
952
993
  },
953
994
  speechPlay(e) {
954
- let t = J(), n = [];
955
- return (e.source.kind === "pcm" || e.source.kind === "encoded") && n.push(e.source.data), c({
995
+ let t = Y(), n = [];
996
+ return (e.source.kind === "pcm" || e.source.kind === "encoded") && n.push(e.source.data), y({
956
997
  type: "speechPlay",
957
998
  schemaVersion: 2,
958
999
  payload: {
@@ -966,11 +1007,11 @@ function He(e) {
966
1007
  }, 12e4, n);
967
1008
  },
968
1009
  speechUtteranceBegin(e) {
969
- return c({
1010
+ return y({
970
1011
  type: "speechUtteranceBegin",
971
1012
  schemaVersion: 2,
972
1013
  payload: {
973
- correlationId: J(),
1014
+ correlationId: Y(),
974
1015
  utteranceId: e.utteranceId,
975
1016
  format: e.format,
976
1017
  queue: e.queue,
@@ -980,11 +1021,11 @@ function He(e) {
980
1021
  });
981
1022
  },
982
1023
  speechUtteranceWrite(e) {
983
- return c({
1024
+ return y({
984
1025
  type: "speechUtteranceWrite",
985
1026
  schemaVersion: 2,
986
1027
  payload: {
987
- correlationId: J(),
1028
+ correlationId: Y(),
988
1029
  utteranceId: e.utteranceId,
989
1030
  audio: e.audio,
990
1031
  byteLength: e.byteLength
@@ -992,22 +1033,22 @@ function He(e) {
992
1033
  }, Ve, [e.audio]);
993
1034
  },
994
1035
  speechUtteranceSetTranscript(e) {
995
- return c({
1036
+ return y({
996
1037
  type: "speechUtteranceSetTranscript",
997
1038
  schemaVersion: 2,
998
1039
  payload: {
999
- correlationId: J(),
1040
+ correlationId: Y(),
1000
1041
  utteranceId: e.utteranceId,
1001
1042
  transcript: e.transcript
1002
1043
  }
1003
1044
  });
1004
1045
  },
1005
1046
  speechUtteranceClose(e) {
1006
- return c({
1047
+ return y({
1007
1048
  type: "speechUtteranceClose",
1008
1049
  schemaVersion: 2,
1009
1050
  payload: {
1010
- correlationId: J(),
1051
+ correlationId: Y(),
1011
1052
  utteranceId: e.utteranceId,
1012
1053
  ...e.transcript === void 0 ? {} : { transcript: e.transcript },
1013
1054
  ...e.history ? { history: e.history } : {}
@@ -1015,37 +1056,57 @@ function He(e) {
1015
1056
  });
1016
1057
  },
1017
1058
  speechUtteranceCancel(e) {
1018
- return c({
1059
+ return y({
1019
1060
  type: "speechUtteranceCancel",
1020
1061
  schemaVersion: 2,
1021
1062
  payload: {
1022
- correlationId: J(),
1063
+ correlationId: Y(),
1023
1064
  utteranceId: e.utteranceId
1024
1065
  }
1025
1066
  });
1026
1067
  },
1027
1068
  speechInterrupt(e) {
1028
- return c({
1069
+ return y({
1029
1070
  type: "speechInterrupt",
1030
1071
  schemaVersion: 2,
1031
1072
  payload: {
1032
- correlationId: J(),
1073
+ correlationId: Y(),
1033
1074
  ...e
1034
1075
  }
1035
1076
  });
1036
1077
  },
1037
1078
  getConversation() {
1038
- return c({
1079
+ return y({
1039
1080
  type: "getConversation",
1040
1081
  schemaVersion: 2,
1041
- payload: { correlationId: J() }
1082
+ payload: { correlationId: Y() }
1083
+ });
1084
+ },
1085
+ focusCharacter(e) {
1086
+ return y({
1087
+ type: "focusCharacter",
1088
+ schemaVersion: 2,
1089
+ payload: {
1090
+ correlationId: Y(),
1091
+ characterId: e
1092
+ }
1093
+ });
1094
+ },
1095
+ setFit(e) {
1096
+ return y({
1097
+ type: "setFit",
1098
+ schemaVersion: 2,
1099
+ payload: {
1100
+ correlationId: Y(),
1101
+ fit: e
1102
+ }
1042
1103
  });
1043
1104
  },
1044
1105
  destroy() {
1045
1106
  if (!r) {
1046
1107
  r = !0;
1047
1108
  for (let e of i.values()) e.reject(/* @__PURE__ */ Error("Iframe host destroyed."));
1048
- i.clear(), window.removeEventListener("message", o), n.remove();
1109
+ i.clear(), f(), a = null, n.removeEventListener("load", h), n.removeEventListener("error", g), window.removeEventListener("message", _), n.remove();
1049
1110
  }
1050
1111
  }
1051
1112
  };
@@ -1077,37 +1138,40 @@ function Ke() {
1077
1138
  }
1078
1139
  function qe() {
1079
1140
  let e = Ke();
1080
- return e ? e.endsWith("/embed") ? e : `${e}/embed` : c() ? Ge : We;
1141
+ return e ? e.endsWith("/embed") ? e : `${e}/embed` : l() ? Ge : We;
1142
+ }
1143
+ function Je(e, t) {
1144
+ return e?.trim() || t?.trim() || void 0;
1081
1145
  }
1082
- function Je(e, t, n, r, i, a, o) {
1083
- let s = (e ?? qe()).replace(/\/$/, ""), c = s.endsWith("/embed") ? s : `${s}/embed`, l = new URL(c), u = n?.trim();
1084
- u && l.searchParams.set("locationId", u);
1085
- let d = r?.trim();
1086
- return d && l.searchParams.set("avatarId", d), i === "face" && l.searchParams.set("fit", "face"), a === "widget" && l.searchParams.set("ui", "widget"), o && l.searchParams.set("close", "1"), t && l.searchParams.set("debug", "true"), Ye(l.toString());
1146
+ function Ye(e, t, n, r, i, a, o, s) {
1147
+ let c = (e ?? qe()).replace(/\/$/, ""), l = c.endsWith("/embed") ? c : `${c}/embed`, u = new URL(l), d = n?.trim();
1148
+ d && (u.searchParams.set("backdropId", d), u.searchParams.set("locationId", d));
1149
+ let f = r?.trim();
1150
+ return f && u.searchParams.set("avatarId", f), (i === "face" || i === "medium") && u.searchParams.set("fit", i), a === "widget" && u.searchParams.set("ui", "widget"), o && u.searchParams.set("close", "1"), t && u.searchParams.set("debug", "true"), (s === 2 || s === 3 || s === 4) && u.searchParams.set("cast", String(s)), Xe(u.toString());
1087
1151
  }
1088
- function Ye(e) {
1152
+ function Xe(e) {
1089
1153
  if (typeof location > "u") return e;
1090
1154
  let t = new URL(e);
1091
1155
  return t.searchParams.set("parentOrigin", location.origin), t.toString();
1092
1156
  }
1093
- function Xe(e) {
1157
+ function Ze(e) {
1094
1158
  return new URL(e).origin;
1095
1159
  }
1096
1160
  //#endregion
1097
1161
  //#region src/v2/experienceEvents.ts
1098
- function Ze() {
1162
+ function Qe() {
1099
1163
  return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? `evt_${crypto.randomUUID().replace(/-/g, "").slice(0, 12)}` : `evt_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
1100
1164
  }
1101
- function Qe(e, t, n) {
1165
+ function $e(e, t, n) {
1102
1166
  return {
1103
- id: Ze(),
1167
+ id: Qe(),
1104
1168
  type: e,
1105
1169
  sessionId: t,
1106
1170
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1107
1171
  data: n
1108
1172
  };
1109
1173
  }
1110
- function $e() {
1174
+ function et() {
1111
1175
  return {
1112
1176
  ready: /* @__PURE__ */ new Set(),
1113
1177
  started: /* @__PURE__ */ new Set(),
@@ -1116,46 +1180,49 @@ function $e() {
1116
1180
  userSpeechEnded: /* @__PURE__ */ new Set(),
1117
1181
  characterSpeechStarted: /* @__PURE__ */ new Set(),
1118
1182
  characterSpeechEnded: /* @__PURE__ */ new Set(),
1183
+ characterFocusChanged: /* @__PURE__ */ new Set(),
1119
1184
  conversationUpdate: /* @__PURE__ */ new Set(),
1120
1185
  message: /* @__PURE__ */ new Set(),
1121
1186
  listeningState: /* @__PURE__ */ new Set(),
1122
1187
  activityChange: /* @__PURE__ */ new Set(),
1188
+ feedback: /* @__PURE__ */ new Set(),
1189
+ feedbackFailed: /* @__PURE__ */ new Set(),
1123
1190
  conversationProcessorError: /* @__PURE__ */ new Set()
1124
1191
  };
1125
1192
  }
1126
- function et(e, t, n) {
1193
+ function tt(e, t, n) {
1127
1194
  return e[t].add(n), () => e[t].delete(n);
1128
1195
  }
1129
- function tt(e, t, n) {
1196
+ function nt(e, t, n) {
1130
1197
  for (let r of e[t]) r(n);
1131
1198
  }
1132
- function nt(e) {
1199
+ function rt(e) {
1133
1200
  for (let t of Object.keys(e)) e[t].clear();
1134
1201
  }
1135
1202
  //#endregion
1136
1203
  //#region src/v2/speech/types.ts
1137
- function rt(e) {
1204
+ function it(e) {
1138
1205
  return "data" in e && "format" in e && e.format != null && !("track" in e);
1139
1206
  }
1140
- function it(e) {
1207
+ function at(e) {
1141
1208
  return "url" in e && typeof e.url == "string";
1142
1209
  }
1143
- function at(e) {
1210
+ function ot(e) {
1144
1211
  if (!("track" in e)) return !1;
1145
1212
  let t = e.track;
1146
1213
  return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
1147
1214
  }
1148
- function ot(e) {
1149
- return !rt(e) && !it(e) && !at(e) && "encoding" in e && typeof e.encoding == "string";
1215
+ function st(e) {
1216
+ return !it(e) && !at(e) && !ot(e) && "encoding" in e && typeof e.encoding == "string";
1150
1217
  }
1151
- var st = [
1218
+ var ct = [
1152
1219
  8e3,
1153
1220
  16e3,
1154
1221
  22050,
1155
1222
  24e3,
1156
1223
  44100,
1157
1224
  48e3
1158
- ], Y = {
1225
+ ], X = {
1159
1226
  MAX_CHUNK_BYTES: 64 * 1024,
1160
1227
  RECOMMENDED_CHUNK_MS_MIN: 20,
1161
1228
  RECOMMENDED_CHUNK_MS_MAX: 200,
@@ -1166,89 +1233,89 @@ var st = [
1166
1233
  MAX_UTTERANCE_DURATION_MS: 9e4,
1167
1234
  MAX_PENDING_WRITES: 8,
1168
1235
  DEFAULT_WRITE_TIMEOUT_MS: 5e3
1169
- }, ct = class extends Error {
1236
+ }, lt = class extends Error {
1170
1237
  operation;
1171
1238
  requiredCapability;
1172
1239
  name = "UnsupportedSpeechOperationError";
1173
1240
  constructor(e, t) {
1174
1241
  super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
1175
1242
  }
1176
- }, lt = class extends Error {
1243
+ }, ut = class extends Error {
1177
1244
  name = "SpeechUtteranceClosedError";
1178
1245
  constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
1179
1246
  super(e);
1180
1247
  }
1181
- }, X = class extends Error {
1248
+ }, Z = class extends Error {
1182
1249
  name = "SpeechRuntimeError";
1183
1250
  constructor(e, t) {
1184
1251
  super(e, t);
1185
1252
  }
1186
- }, ut = class extends Error {
1253
+ }, dt = class extends Error {
1187
1254
  name = "SpeechBufferTimeoutError";
1188
1255
  constructor(e = "Timed out waiting for speech buffer capacity.") {
1189
1256
  super(e);
1190
1257
  }
1191
1258
  };
1192
- function dt(e = "none") {
1259
+ function ft(e = "none") {
1193
1260
  return {
1194
1261
  mode: e,
1195
1262
  trackedDurationMs: 0,
1196
1263
  fallbackDurationMs: 0
1197
1264
  };
1198
1265
  }
1199
- function ft(e) {
1200
- return st.includes(e);
1201
- }
1202
1266
  function pt(e) {
1203
- if (e.encoding !== "pcm_s16le") throw new X(`Unsupported audio encoding: ${e.encoding}`);
1204
- if (e.channels !== 1) throw new X(`Unsupported channel count: ${e.channels}`);
1205
- if (!ft(e.sampleRate)) throw new X(`Unsupported sample rate: ${e.sampleRate}`);
1267
+ return ct.includes(e);
1206
1268
  }
1207
1269
  function mt(e) {
1208
- if (rt(e)) {
1209
- pt(e.format);
1210
- return;
1211
- }
1270
+ if (e.encoding !== "pcm_s16le") throw new Z(`Unsupported audio encoding: ${e.encoding}`);
1271
+ if (e.channels !== 1) throw new Z(`Unsupported channel count: ${e.channels}`);
1272
+ if (!pt(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
1273
+ }
1274
+ function ht(e) {
1212
1275
  if (it(e)) {
1213
- if (!e.url.trim()) throw new X("Audio URL must be non-empty.");
1214
- if (e.sampleRate !== void 0 && !ft(e.sampleRate)) throw new X(`Unsupported sample rate: ${e.sampleRate}`);
1276
+ mt(e.format);
1215
1277
  return;
1216
1278
  }
1217
1279
  if (at(e)) {
1218
- if (e.track.kind !== "audio") throw new X("speech.play track must be an audio MediaStreamTrack.");
1219
- if (e.sampleRate !== void 0 && !ft(e.sampleRate)) throw new X(`Unsupported sample rate: ${e.sampleRate}`);
1280
+ if (!e.url.trim()) throw new Z("Audio URL must be non-empty.");
1281
+ if (e.sampleRate !== void 0 && !pt(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
1220
1282
  return;
1221
1283
  }
1222
1284
  if (ot(e)) {
1285
+ if (e.track.kind !== "audio") throw new Z("speech.play track must be an audio MediaStreamTrack.");
1286
+ if (e.sampleRate !== void 0 && !pt(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
1287
+ return;
1288
+ }
1289
+ if (st(e)) {
1223
1290
  let t = e.encoding.trim().toLowerCase();
1224
- if (!t) throw new X("Encoded audio MIME type is required.");
1225
- if (t === "pcm_s16le") throw new X("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
1226
- if (e.sampleRate !== void 0 && !ft(e.sampleRate)) throw new X(`Unsupported sample rate: ${e.sampleRate}`);
1291
+ if (!t) throw new Z("Encoded audio MIME type is required.");
1292
+ if (t === "pcm_s16le") throw new Z("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
1293
+ if (e.sampleRate !== void 0 && !pt(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
1227
1294
  return;
1228
1295
  }
1229
- throw new X("Unsupported speech.play audio shape.");
1296
+ throw new Z("Unsupported speech.play audio shape.");
1230
1297
  }
1231
- function ht(e) {
1232
- if (e.format) return pt(e.format), e.format;
1298
+ function gt(e) {
1299
+ if (e.format) return mt(e.format), e.format;
1233
1300
  if (e.track) {
1234
1301
  let t = {
1235
1302
  encoding: "pcm_s16le",
1236
1303
  sampleRate: e.sampleRate ?? 24e3,
1237
1304
  channels: 1
1238
1305
  };
1239
- return pt(t), t;
1306
+ return mt(t), t;
1240
1307
  }
1241
- throw new X("createUtterance requires format or track.");
1308
+ throw new Z("createUtterance requires format or track.");
1242
1309
  }
1243
- function gt(e) {
1310
+ function _t(e) {
1244
1311
  return e instanceof Uint8Array ? e : new Uint8Array(e);
1245
1312
  }
1246
- function _t(e) {
1313
+ function vt(e) {
1247
1314
  return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
1248
1315
  }
1249
1316
  //#endregion
1250
1317
  //#region src/byo/pcm.ts
1251
- function vt(e) {
1318
+ function yt(e) {
1252
1319
  let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
1253
1320
  for (let t = 0; t < e.length; t++) {
1254
1321
  let r = Math.max(-1, Math.min(1, e[t]));
@@ -1258,11 +1325,11 @@ function vt(e) {
1258
1325
  }
1259
1326
  //#endregion
1260
1327
  //#region src/byo/resample.ts
1261
- function yt(e, t, n, r, i) {
1328
+ function bt(e, t, n, r, i) {
1262
1329
  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;
1263
1330
  return ((a * i + o) * i + s) * i + c;
1264
1331
  }
1265
- function bt(e, t) {
1332
+ function xt(e, t) {
1266
1333
  if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
1267
1334
  if (e === t) return {
1268
1335
  fromRate: e,
@@ -1285,7 +1352,7 @@ function bt(e, t) {
1285
1352
  let a = [];
1286
1353
  for (; i + 2 < r.length - 1;) {
1287
1354
  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);
1288
- a.push(yt(r[o], r[e], r[s], r[c], t)), i += n;
1355
+ a.push(bt(r[o], r[e], r[s], r[c], t)), i += n;
1289
1356
  }
1290
1357
  let o = Math.max(0, Math.floor(i) - 1);
1291
1358
  return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
@@ -1297,7 +1364,7 @@ function bt(e, t) {
1297
1364
  }
1298
1365
  //#endregion
1299
1366
  //#region src/byo/audioCapture.ts
1300
- var xt = "liforma-pcm-capture", St = `
1367
+ var St = "liforma-pcm-capture", Ct = `
1301
1368
  class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
1302
1369
  process(inputs) {
1303
1370
  const ch = inputs[0] && inputs[0][0];
@@ -1309,29 +1376,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
1309
1376
  return true;
1310
1377
  }
1311
1378
  }
1312
- registerProcessor('${xt}', LiformaPcmCaptureProcessor);
1313
- `, Ct = null;
1314
- function wt() {
1315
- return Ct ||= URL.createObjectURL(new Blob([St], { type: "application/javascript" })), Ct;
1316
- }
1379
+ registerProcessor('${St}', LiformaPcmCaptureProcessor);
1380
+ `, wt = null;
1317
1381
  function Tt() {
1382
+ return wt ||= URL.createObjectURL(new Blob([Ct], { type: "application/javascript" })), wt;
1383
+ }
1384
+ function Et() {
1318
1385
  return window.AudioContext || window.webkitAudioContext || null;
1319
1386
  }
1320
- async function Et(e) {
1321
- let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = Tt();
1387
+ async function Dt(e) {
1388
+ let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = Et();
1322
1389
  if (!o) throw Error("Web Audio is required for audio capture");
1323
1390
  let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
1324
1391
  l.gain.value = 0;
1325
- let u = s.sampleRate, d = bt(u, n), f = !1, p = !1, m = (e) => {
1392
+ let u = s.sampleRate, d = xt(u, n), f = !1, p = !1, m = (e) => {
1326
1393
  if (f || i && !i()) return;
1327
1394
  let t = d.push(e);
1328
- t.length !== 0 && r(vt(t));
1395
+ t.length !== 0 && r(yt(t));
1329
1396
  }, h = () => void 0;
1330
1397
  return await (async () => {
1331
1398
  if (typeof s.audioWorklet?.addModule != "function") return !1;
1332
1399
  try {
1333
- await s.audioWorklet.addModule(wt());
1334
- let e = new AudioWorkletNode(s, xt, {
1400
+ await s.audioWorklet.addModule(Tt());
1401
+ let e = new AudioWorkletNode(s, St, {
1335
1402
  numberOfInputs: 1,
1336
1403
  numberOfOutputs: 1,
1337
1404
  outputChannelCount: [1]
@@ -1381,27 +1448,27 @@ async function Et(e) {
1381
1448
  }
1382
1449
  //#endregion
1383
1450
  //#region src/v2/speech/captureMediaStreamTrack.ts
1384
- async function Dt(e) {
1451
+ async function Ot(e) {
1385
1452
  let { track: t, utterance: n, sampleRate: r, signal: i } = e;
1386
- if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new X("MediaStreamTrack is not available in this environment.");
1387
- if (t.kind !== "audio") throw new X("speech.play track must be an audio MediaStreamTrack.");
1453
+ if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Z("MediaStreamTrack is not available in this environment.");
1454
+ if (t.kind !== "audio") throw new Z("speech.play track must be an audio MediaStreamTrack.");
1388
1455
  if (t.readyState === "ended" || i?.aborted) return;
1389
1456
  let a = new MediaStream([t]), o = Promise.resolve(), s = !1, c = null, l = () => {
1390
1457
  s || (s = !0, c?.stop(), c = null);
1391
1458
  };
1392
1459
  try {
1393
- c = await Et({
1460
+ c = await Dt({
1394
1461
  mediaStream: a,
1395
1462
  targetSampleRate: r,
1396
1463
  shouldSend: () => !s && !i?.aborted,
1397
1464
  onPcm: (e) => {
1398
1465
  if (s || i?.aborted) return;
1399
- let t = gt(e);
1466
+ let t = _t(e);
1400
1467
  o = o.then(async () => {
1401
1468
  if (s || i?.aborted) return;
1402
1469
  let e = 0;
1403
1470
  for (; e < t.byteLength;) {
1404
- let r = Math.min(e + Y.MAX_CHUNK_BYTES, t.byteLength);
1471
+ let r = Math.min(e + X.MAX_CHUNK_BYTES, t.byteLength);
1405
1472
  if ((r - e) % 2 == 1 && --r, r <= e) break;
1406
1473
  let i = t.subarray(e, r);
1407
1474
  e = r, i.byteLength !== 0 && await n.write(i);
@@ -1412,7 +1479,7 @@ async function Dt(e) {
1412
1479
  }
1413
1480
  });
1414
1481
  } catch (e) {
1415
- throw l(), new X(`MediaStreamTrack capture failed: ${e instanceof Error ? e.message : String(e)}`);
1482
+ throw l(), new Z(`MediaStreamTrack capture failed: ${e instanceof Error ? e.message : String(e)}`);
1416
1483
  }
1417
1484
  await new Promise((e) => {
1418
1485
  let r = () => {
@@ -1425,28 +1492,28 @@ async function Dt(e) {
1425
1492
  }
1426
1493
  //#endregion
1427
1494
  //#region src/v2/speech/speechController.ts
1428
- async function Ot(e, t) {
1429
- if (at(e)) throw new X("MediaStreamTrack play is handled on the host before embed.");
1430
- if (rt(e)) {
1431
- let t = gt(e.data);
1432
- if (t.byteLength & 1) throw new X("PCM byte length must be even.");
1495
+ async function kt(e, t) {
1496
+ if (ot(e)) throw new Z("MediaStreamTrack play is handled on the host before embed.");
1497
+ if (it(e)) {
1498
+ let t = _t(e.data);
1499
+ if (t.byteLength & 1) throw new Z("PCM byte length must be even.");
1433
1500
  return {
1434
1501
  kind: "pcm",
1435
1502
  data: t.slice().buffer,
1436
1503
  format: e.format
1437
1504
  };
1438
1505
  }
1439
- if (it(e)) return {
1506
+ if (at(e)) return {
1440
1507
  kind: "url",
1441
1508
  url: e.url.trim(),
1442
1509
  ...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
1443
1510
  };
1444
- if (!ot(e)) throw new X("Unsupported speech.play audio shape.");
1511
+ if (!st(e)) throw new Z("Unsupported speech.play audio shape.");
1445
1512
  let n;
1446
1513
  if (typeof Blob < "u" && e.data instanceof Blob) {
1447
1514
  if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
1448
1515
  n = new Uint8Array(await e.data.arrayBuffer());
1449
- } else n = gt(e.data);
1516
+ } else n = _t(e.data);
1450
1517
  return {
1451
1518
  kind: "encoded",
1452
1519
  data: n.slice().buffer,
@@ -1454,10 +1521,10 @@ async function Ot(e, t) {
1454
1521
  ...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
1455
1522
  };
1456
1523
  }
1457
- function kt() {
1524
+ function At() {
1458
1525
  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)}`;
1459
1526
  }
1460
- function At(e, t = "completed") {
1527
+ function jt(e, t = "completed") {
1461
1528
  return {
1462
1529
  utteranceId: e.speechId,
1463
1530
  characterId: e.characterId,
@@ -1471,13 +1538,13 @@ function At(e, t = "completed") {
1471
1538
  }
1472
1539
  };
1473
1540
  }
1474
- function Z(e) {
1475
- return e instanceof Error ? e : new X(String(e));
1541
+ function Mt(e) {
1542
+ return e instanceof Error ? e : new Z(String(e));
1476
1543
  }
1477
- function jt(e) {
1544
+ function Nt(e) {
1478
1545
  return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
1479
1546
  }
1480
- var Mt = class {
1547
+ var Pt = class {
1481
1548
  id;
1482
1549
  characterId;
1483
1550
  result;
@@ -1506,29 +1573,29 @@ var Mt = class {
1506
1573
  queue: e.queue,
1507
1574
  ...e.transcript === void 0 ? {} : { transcript: e.transcript }
1508
1575
  }).catch((e) => {
1509
- throw this.fail(Z(e)), Z(e);
1576
+ throw this.fail(Mt(e)), Mt(e);
1510
1577
  }), this.signal?.addEventListener("abort", () => {
1511
1578
  this.cancel();
1512
1579
  }, { once: !0 });
1513
1580
  }
1514
1581
  async write(e, t) {
1515
- if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new lt();
1516
- let n = gt(e);
1517
- if (n.byteLength & 1) throw new X("PCM chunk byte length must be even (complete s16 samples).");
1518
- if (n.byteLength > Y.MAX_CHUNK_BYTES) throw new X(`PCM chunk exceeds MAX_CHUNK_BYTES (${Y.MAX_CHUNK_BYTES}).`);
1582
+ if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new ut();
1583
+ let n = _t(e);
1584
+ if (n.byteLength & 1) throw new Z("PCM chunk byte length must be even (complete s16 samples).");
1585
+ if (n.byteLength > X.MAX_CHUNK_BYTES) throw new Z(`PCM chunk exceeds MAX_CHUNK_BYTES (${X.MAX_CHUNK_BYTES}).`);
1519
1586
  if (n.byteLength === 0) return;
1520
- let r = t?.timeoutMs ?? Y.DEFAULT_WRITE_TIMEOUT_MS;
1587
+ let r = t?.timeoutMs ?? X.DEFAULT_WRITE_TIMEOUT_MS;
1521
1588
  await this.acquireWriteSlot(r);
1522
1589
  let i = n.byteLength / 2 / this.sampleRate * 1e3;
1523
- if (this.bufferedMs + i > Y.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new X("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
1590
+ if (this.bufferedMs + i > X.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new Z("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
1524
1591
  let a = async () => {
1525
- if (this.closed || this.settled) throw new lt();
1592
+ if (this.closed || this.settled) throw new ut();
1526
1593
  let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
1527
1594
  utteranceId: this.id,
1528
1595
  audio: t.buffer,
1529
1596
  byteLength: t.byteLength
1530
1597
  }), a = await Promise.race([i, new Promise((e, t) => {
1531
- setTimeout(() => t(new ut()), r);
1598
+ setTimeout(() => t(new dt()), r);
1532
1599
  })]);
1533
1600
  this.bufferedMs = Math.max(0, a.bufferedMs);
1534
1601
  }, o = this.writeChain.then(a, a);
@@ -1540,7 +1607,7 @@ var Mt = class {
1540
1607
  }
1541
1608
  }
1542
1609
  async setTranscript(e) {
1543
- if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new lt();
1610
+ if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new ut();
1544
1611
  await this.requireHost().speechUtteranceSetTranscript({
1545
1612
  utteranceId: this.id,
1546
1613
  transcript: e
@@ -1557,7 +1624,7 @@ var Mt = class {
1557
1624
  });
1558
1625
  return this.resolve(t), t;
1559
1626
  } catch (e) {
1560
- let t = Z(e);
1627
+ let t = Mt(e);
1561
1628
  throw this.fail(t), t;
1562
1629
  }
1563
1630
  }
@@ -1575,11 +1642,11 @@ var Mt = class {
1575
1642
  characterId: this.characterId,
1576
1643
  status: "cancelled",
1577
1644
  durationMs: 0,
1578
- animation: dt("none")
1645
+ animation: ft("none")
1579
1646
  };
1580
1647
  return this.resolve(t), t;
1581
1648
  } catch (e) {
1582
- let t = Z(e);
1649
+ let t = Mt(e);
1583
1650
  throw this.fail(t), t;
1584
1651
  }
1585
1652
  }
@@ -1588,23 +1655,23 @@ var Mt = class {
1588
1655
  }
1589
1656
  requireHost() {
1590
1657
  let e = this.host.getIframeHost();
1591
- if (!e) throw new X("Speech session is not attached.");
1658
+ if (!e) throw new Z("Speech session is not attached.");
1592
1659
  return e;
1593
1660
  }
1594
1661
  resolve(e) {
1595
- this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new lt()));
1662
+ this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new ut()));
1596
1663
  }
1597
1664
  fail(e) {
1598
1665
  this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
1599
1666
  }
1600
1667
  async acquireWriteSlot(e) {
1601
- if (this.pendingWriteCount < Y.MAX_PENDING_WRITES) {
1668
+ if (this.pendingWriteCount < X.MAX_PENDING_WRITES) {
1602
1669
  this.pendingWriteCount += 1;
1603
1670
  return;
1604
1671
  }
1605
1672
  await new Promise((t, n) => {
1606
1673
  let r = setTimeout(() => {
1607
- n(new ut());
1674
+ n(new dt());
1608
1675
  }, e);
1609
1676
  this.pendingWriteWaiters.push({
1610
1677
  resolve: () => {
@@ -1623,16 +1690,16 @@ var Mt = class {
1623
1690
  for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
1624
1691
  }
1625
1692
  };
1626
- function Nt(e) {
1693
+ function Ft(e) {
1627
1694
  let t = null, n = (t, n) => {
1628
- if (!e.getCapabilities()[n]) throw new ct(t, n);
1695
+ if (!e.getCapabilities()[n]) throw new lt(t, n);
1629
1696
  }, r = {
1630
1697
  async speak(r) {
1631
1698
  if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
1632
- let i = _t(r.queue ?? "append");
1699
+ let i = vt(r.queue ?? "append");
1633
1700
  i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
1634
1701
  let a = e.getIframeHost();
1635
- if (!a) throw new X("Speech session is not attached.");
1702
+ if (!a) throw new Z("Speech session is not attached.");
1636
1703
  let o = a.speak({
1637
1704
  text: r.text,
1638
1705
  characterId: r.characterId,
@@ -1649,41 +1716,41 @@ function Nt(e) {
1649
1716
  return;
1650
1717
  }
1651
1718
  t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
1652
- t.removeEventListener("abort", s), n(At(e, "completed"));
1719
+ t.removeEventListener("abort", s), n(jt(e, "completed"));
1653
1720
  }, (a) => {
1654
- if (t.removeEventListener("abort", s), jt(a)) {
1721
+ if (t.removeEventListener("abort", s), Nt(a)) {
1655
1722
  n({
1656
1723
  utteranceId: "utt_interrupted",
1657
1724
  characterId: r.characterId ?? e.getActiveCharacterId(),
1658
1725
  status: "interrupted",
1659
1726
  durationMs: 0,
1660
1727
  transcript: r.text,
1661
- animation: dt("none")
1728
+ animation: ft("none")
1662
1729
  });
1663
1730
  return;
1664
1731
  }
1665
- i(Z(a));
1732
+ i(Mt(a));
1666
1733
  });
1667
1734
  });
1668
1735
  }
1669
1736
  try {
1670
- return At(await o, "completed");
1737
+ return jt(await o, "completed");
1671
1738
  } catch (t) {
1672
- if (jt(t)) return {
1739
+ if (Nt(t)) return {
1673
1740
  utteranceId: "utt_interrupted",
1674
1741
  characterId: r.characterId ?? e.getActiveCharacterId(),
1675
1742
  status: "interrupted",
1676
1743
  durationMs: 0,
1677
1744
  transcript: r.text,
1678
- animation: dt("none")
1745
+ animation: ft("none")
1679
1746
  };
1680
- throw Z(t);
1747
+ throw Mt(t);
1681
1748
  }
1682
1749
  },
1683
1750
  async play(i) {
1684
- if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), mt(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
1751
+ if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), ht(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
1685
1752
  let a = i.queue ?? "append";
1686
- if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), at(i.audio)) {
1753
+ if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), ot(i.audio)) {
1687
1754
  let e = i.audio.sampleRate ?? 24e3;
1688
1755
  return r.createUtterance({
1689
1756
  format: {
@@ -1698,8 +1765,8 @@ function Nt(e) {
1698
1765
  }).result;
1699
1766
  }
1700
1767
  let o = e.getIframeHost();
1701
- if (!o) throw new X("Speech session is not attached.");
1702
- let s = await Ot(i.audio, i.signal);
1768
+ if (!o) throw new Z("Speech session is not attached.");
1769
+ let s = await kt(i.audio, i.signal);
1703
1770
  return o.speechPlay({
1704
1771
  source: s,
1705
1772
  characterId: i.characterId,
@@ -1711,13 +1778,13 @@ function Nt(e) {
1711
1778
  },
1712
1779
  createUtterance(r) {
1713
1780
  e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
1714
- let i = ht(r);
1715
- if (r.track && r.track.kind !== "audio") throw new X("createUtterance track must be an audio MediaStreamTrack.");
1781
+ let i = gt(r);
1782
+ if (r.track && r.track.kind !== "audio") throw new Z("createUtterance track must be an audio MediaStreamTrack.");
1716
1783
  let a = r.queue ?? "replace-active";
1717
- if (a !== "replace-active" && a !== "replace-all") throw new X("createUtterance queue must be replace-active or replace-all.");
1784
+ if (a !== "replace-active" && a !== "replace-all") throw new Z("createUtterance queue must be replace-active or replace-all.");
1718
1785
  e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
1719
- let o = new Mt({
1720
- id: kt(),
1786
+ let o = new Pt({
1787
+ id: At(),
1721
1788
  characterId: r.characterId ?? e.getActiveCharacterId(),
1722
1789
  format: i,
1723
1790
  queue: a,
@@ -1729,7 +1796,7 @@ function Nt(e) {
1729
1796
  t === o && (t = null);
1730
1797
  }), r.track && (async () => {
1731
1798
  try {
1732
- if (await Dt({
1799
+ if (await Ot({
1733
1800
  track: r.track,
1734
1801
  utterance: o,
1735
1802
  sampleRate: i.sampleRate,
@@ -1756,11 +1823,17 @@ function Nt(e) {
1756
1823
  return r;
1757
1824
  }
1758
1825
  //#endregion
1826
+ //#region src/v2/types/sessionInteraction.ts
1827
+ function It(e) {
1828
+ let t = e?.trim();
1829
+ return t === "full" || t === "face" || t === "medium" ? t : void 0;
1830
+ }
1831
+ //#endregion
1759
1832
  //#region src/v2/experience.ts
1760
- function Pt(e) {
1833
+ function Lt(e) {
1761
1834
  return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
1762
1835
  }
1763
- var Ft = class e {
1836
+ var Rt = class e {
1764
1837
  bootstrap;
1765
1838
  conversationProcessor;
1766
1839
  iframeHost = null;
@@ -1773,17 +1846,18 @@ var Ft = class e {
1773
1846
  attachReturnUrl = null;
1774
1847
  closed = !1;
1775
1848
  attached = !1;
1849
+ pendingFit = null;
1776
1850
  closeHandlers = [];
1777
- eventRegistry = $e();
1851
+ eventRegistry = et();
1778
1852
  readyEnvelope = null;
1779
1853
  startedEnvelope = null;
1780
1854
  conversationCache = [];
1781
1855
  speech;
1782
1856
  constructor(e) {
1783
- this.bootstrap = e, this.conversationProcessor = e.conversationProcessor ?? null, this.resolvedSession = e.kind === "launch" ? e.session ?? null : null, this.launchToken = e.kind === "launch" ? e.launch : null, this.speech = Nt({
1857
+ this.bootstrap = e, this.conversationProcessor = e.conversationProcessor ?? null, this.resolvedSession = e.kind === "launch" ? e.session ?? null : null, this.launchToken = e.kind === "launch" ? e.launch : null, this.speech = Ft({
1784
1858
  getIframeHost: () => this.iframeHost,
1785
1859
  assertSessionStarted: () => this.assertSessionStarted(),
1786
- getCapabilities: () => It(this.resolvedSession),
1860
+ getCapabilities: () => zt(this.resolvedSession),
1787
1861
  getActiveCharacterId: () => "character_unknown",
1788
1862
  onProcessorInterrupt: () => {
1789
1863
  this.processorAbortController?.abort(), this.processorAbortController = null;
@@ -1798,6 +1872,9 @@ var Ft = class e {
1798
1872
  kind: "launch",
1799
1873
  launch: n,
1800
1874
  session: t.session,
1875
+ backdropId: t.backdropId,
1876
+ locationId: t.locationId,
1877
+ avatarId: t.avatarId,
1801
1878
  embedBaseUrl: t.embedBaseUrl,
1802
1879
  debug: t.debug,
1803
1880
  speechOnly: t.speechOnly,
@@ -1815,8 +1892,10 @@ var Ft = class e {
1815
1892
  secondaryLocale: t.secondaryLocale,
1816
1893
  learningLocale: t.learningLocale,
1817
1894
  language: t.language,
1895
+ backdropId: t.backdropId,
1818
1896
  locationId: t.locationId,
1819
1897
  avatarId: t.avatarId,
1898
+ castSize: t.castSize,
1820
1899
  embedBaseUrl: t.embedBaseUrl,
1821
1900
  debug: t.debug,
1822
1901
  mode: t.mode,
@@ -1834,8 +1913,10 @@ var Ft = class e {
1834
1913
  secondaryLocale: t.secondaryLocale,
1835
1914
  learningLocale: t.learningLocale,
1836
1915
  language: t.language,
1916
+ backdropId: t.backdropId,
1837
1917
  locationId: t.locationId,
1838
1918
  avatarId: t.avatarId,
1919
+ castSize: t.castSize,
1839
1920
  embedBaseUrl: t.embedBaseUrl,
1840
1921
  debug: t.debug,
1841
1922
  mode: t.mode,
@@ -1855,7 +1936,7 @@ var Ft = class e {
1855
1936
  return null;
1856
1937
  }
1857
1938
  on(e, t) {
1858
- let n = et(this.eventRegistry, e, t);
1939
+ let n = tt(this.eventRegistry, e, t);
1859
1940
  return e === "ready" && this.readyEnvelope && queueMicrotask(() => t(this.readyEnvelope)), e === "started" && this.startedEnvelope && queueMicrotask(() => t(this.startedEnvelope)), n;
1860
1941
  }
1861
1942
  async attach(e) {
@@ -1869,7 +1950,7 @@ var Ft = class e {
1869
1950
  if (this.closed) throw Error("Session has ended.");
1870
1951
  if (this.attached && this.iframeHost) return this.createPlayerFacade();
1871
1952
  this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
1872
- let t = this.bootstrap.embedBaseUrl ?? qe(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = Je(t, n, r || this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.locationId, r || this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, Pt(e)), a = Xe(i), o = null, s = new Promise((e) => {
1953
+ let t = this.bootstrap.embedBaseUrl ?? qe(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = Ye(t, n, r ? void 0 : Je(this.bootstrap.backdropId, this.bootstrap.locationId), r ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, Lt(e), this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.castSize), a = Ze(i), o = null, s = new Promise((e) => {
1873
1954
  o = e;
1874
1955
  }), c = null, l = new Promise((e) => {
1875
1956
  c = e;
@@ -1905,12 +1986,21 @@ var Ft = class e {
1905
1986
  onCharacterSpeechEnded: (e) => {
1906
1987
  this.emitWrapped("characterSpeechEnded", e);
1907
1988
  },
1989
+ onCharacterFocusChanged: (e) => {
1990
+ this.emitWrapped("characterFocusChanged", e);
1991
+ },
1908
1992
  onListeningState: (e) => {
1909
1993
  this.emitWrapped("listeningState", e);
1910
1994
  },
1911
1995
  onActivityChange: (e) => {
1912
1996
  this.emitWrapped("activityChange", e);
1913
1997
  },
1998
+ onFeedback: (e) => {
1999
+ this.emitWrapped("feedback", e);
2000
+ },
2001
+ onFeedbackFailed: (e) => {
2002
+ this.emitWrapped("feedbackFailed", e);
2003
+ },
1914
2004
  onMessage: (e) => {
1915
2005
  this.emitWrapped("message", e);
1916
2006
  },
@@ -1929,7 +2019,7 @@ var Ft = class e {
1929
2019
  onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t)
1930
2020
  });
1931
2021
  this.iframeHost = f;
1932
- let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), De(this.bootstrap.sessionEndpoint, {
2022
+ let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), K(this.bootstrap.sessionEndpoint, {
1933
2023
  experienceId: this.bootstrap.experienceId,
1934
2024
  locale: this.bootstrap.locale,
1935
2025
  secondaryLocale: this.bootstrap.secondaryLocale,
@@ -1961,11 +2051,17 @@ var Ft = class e {
1961
2051
  f.postParentHello();
1962
2052
  let g = h?.launch ?? (this.bootstrap.kind === "launch" ? this.bootstrap.launch : null), _ = h?.session ?? (this.bootstrap.kind === "launch" ? this.bootstrap.session : void 0);
1963
2053
  if (!g) throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), Error("Session Launch response did not include a launch token.");
1964
- return this.launchToken = g, _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" && ye(_), f.postLaunch(g, _, e.startButton), u.setValue(_)) : f.postLaunch(g, void 0, e.startButton), await Promise.race([s, new Promise((e, t) => {
2054
+ return this.launchToken = g, _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" && ye(_), f.postLaunch(g, _, {
2055
+ startButton: e.startButton,
2056
+ showFeedback: e.showFeedback
2057
+ }), u.setValue(_)) : f.postLaunch(g, void 0, {
2058
+ startButton: e.startButton,
2059
+ showFeedback: e.showFeedback
2060
+ }), await Promise.race([s, new Promise((e, t) => {
1965
2061
  setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player loading UI.")), 12e4);
1966
2062
  })]), await Promise.race([l, new Promise((e, t) => {
1967
2063
  setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for player ready state.")), 12e4);
1968
- })]), this.attached = !0, this.createPlayerFacade();
2064
+ })]), this.attached = !0, this.pendingFit && await f.setFit(this.pendingFit), this.createPlayerFacade();
1969
2065
  }
1970
2066
  async startListening() {
1971
2067
  this.assertSessionStarted(), await this.iframeHost.startListening();
@@ -1985,6 +2081,15 @@ var Ft = class e {
1985
2081
  toggleAudioSettings() {
1986
2082
  this.iframeHost?.postWidgetToggleAudioSettings();
1987
2083
  }
2084
+ async focusCharacter(e) {
2085
+ this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
2086
+ }
2087
+ async setFit(e) {
2088
+ let t = It(e);
2089
+ if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
2090
+ if (this.closed) throw Error("Session has ended.");
2091
+ this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
2092
+ }
1988
2093
  getLastTurn() {
1989
2094
  if (this.conversationCache.length === 0) return [];
1990
2095
  let e = this.conversationCache[this.conversationCache.length - 1].turnId;
@@ -1994,7 +2099,7 @@ var Ft = class e {
1994
2099
  this.close();
1995
2100
  }
1996
2101
  destroy() {
1997
- this.closed || (this.closed = !0, this.processorAbortController?.abort(), this.processorAbortController = null, this.endpointAbortController?.abort(), this.endpointAbortController = null, this.attachInFlight = null, this.iframeHost?.destroy(), this.iframeHost = null, nt(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.attached = !1);
2102
+ this.closed || (this.closed = !0, this.processorAbortController?.abort(), this.processorAbortController = null, this.endpointAbortController?.abort(), this.endpointAbortController = null, this.attachInFlight = null, this.iframeHost?.destroy(), this.iframeHost = null, rt(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.attached = !1);
1998
2103
  }
1999
2104
  resolveMintInteraction() {
2000
2105
  return this.bootstrap.kind === "launch" ? {} : {
@@ -2006,8 +2111,8 @@ var Ft = class e {
2006
2111
  return this.resolvedSession?.id ?? "";
2007
2112
  }
2008
2113
  emitWrapped(e, t) {
2009
- let n = Qe(e, this.getSessionId(), t);
2010
- return tt(this.eventRegistry, e, n), n;
2114
+ let n = $e(e, this.getSessionId(), t);
2115
+ return nt(this.eventRegistry, e, n), n;
2011
2116
  }
2012
2117
  queueProcessorTurn(e) {
2013
2118
  if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
@@ -2066,7 +2171,7 @@ var Ft = class e {
2066
2171
  };
2067
2172
  }
2068
2173
  };
2069
- function It(e) {
2174
+ function zt(e) {
2070
2175
  return e ? {
2071
2176
  textSpeech: e.capabilities.speech.output,
2072
2177
  externalSpeechAudio: e.capabilities.speech.externalAudio
@@ -2077,26 +2182,26 @@ function It(e) {
2077
2182
  }
2078
2183
  //#endregion
2079
2184
  //#region src/widget/dockGeometry.ts
2080
- var Lt = "(min-width: 768px)", Rt = 24, zt = .5, Bt = 1200, Vt = .85, Ht = 9 / 16;
2081
- function Ut() {
2185
+ var Bt = "(min-width: 768px)", Vt = 24, Ht = .5, Ut = 1200, Wt = .85, Gt = 9 / 16;
2186
+ function Kt() {
2082
2187
  if (typeof window > "u") return 800;
2083
2188
  let e = window.screen?.availHeight;
2084
2189
  return typeof e == "number" && e > 0 ? e : window.innerHeight;
2085
2190
  }
2086
- function Wt(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = Rt, r = typeof window < "u" ? Ut() : 800) {
2087
- let i = Math.max(160, Math.min(t - n * 2, t * Vt)), a = Math.max(120, e - n * 2), o = Math.min(r * zt, Bt, i), s = o * Ht;
2088
- return s > a && (s = a, o = s / Ht, o > i && (o = i, s = o * Ht)), {
2191
+ function qt(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = Vt, r = typeof window < "u" ? Kt() : 800) {
2192
+ let i = Math.max(160, Math.min(t - n * 2, t * Wt)), a = Math.max(120, e - n * 2), o = Math.min(r * Ht, Ut, i), s = o * Gt;
2193
+ return s > a && (s = a, o = s / Gt, o > i && (o = i, s = o * Gt)), {
2089
2194
  width: Math.round(s),
2090
2195
  height: Math.round(o)
2091
2196
  };
2092
2197
  }
2093
- function Gt(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = Rt) {
2198
+ function Jt(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = Vt) {
2094
2199
  return {
2095
2200
  left: Math.max(r, t - e.width - r),
2096
2201
  top: Math.max(r, n - e.height - r)
2097
2202
  };
2098
2203
  }
2099
- function Kt(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = Rt) {
2204
+ function Yt(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = Vt) {
2100
2205
  let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
2101
2206
  return {
2102
2207
  left: Math.min(Math.max(a, e), o),
@@ -2104,14 +2209,14 @@ function Kt(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typ
2104
2209
  };
2105
2210
  }
2106
2211
  function Q(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
2107
- return e(Lt).matches;
2212
+ return e(Bt).matches;
2108
2213
  }
2109
2214
  //#endregion
2110
2215
  //#region src/widget/mountExperienceWidget.ts
2111
- function qt(e) {
2216
+ function Xt(e) {
2112
2217
  return e === "bottom-right" || e === "bottom-left" ? e : "static";
2113
2218
  }
2114
- function Jt(e) {
2219
+ function Zt(e) {
2115
2220
  if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
2116
2221
  let t = typeof e == "string" ? e.trim() : "";
2117
2222
  return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
@@ -2119,10 +2224,10 @@ function Jt(e) {
2119
2224
  function $(e) {
2120
2225
  return e === "expanded" || e === "docked";
2121
2226
  }
2122
- var Yt = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 0 0-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 0 0-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 0 0-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 0 0-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 0 0 1.066-2.573c-.94-1.543.826-3.31 2.37-2.37c1 .608 2.296.07 2.572-1.065\"/><path d=\"M9 12a3 3 0 1 0 6 0a3 3 0 0 0-6 0\"/></svg>", Xt = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\"><path fill=\"currentColor\" d=\"M18.3 5.71a1 1 0 0 0-1.41 0L12 10.59 7.11 5.7A1 1 0 0 0 5.7 7.11L10.59 12l-4.9 4.89a1 1 0 1 0 1.42 1.42L12 13.41l4.89 4.9a1 1 0 0 0 1.42-1.42L13.41 12l4.9-4.89a1 1 0 0 0-.01-1.4Z\"/></svg>", Zt = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M18 10h-4V6m6-2l-6 6m-8 4h4v4m0-4l-6 6\"/></svg>", Qt = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M16 4h4v4m-6 2l6-6M8 20H4v-4m0 4l6-6\"/></svg>";
2123
- function $t(e, t, n) {
2124
- I(re);
2125
- let r = s({
2227
+ var Qt = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"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>", $t = "<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>", en = "<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>", tn = "<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>";
2228
+ function nn(e, t, n) {
2229
+ re(I);
2230
+ let r = c({
2126
2231
  galleryThumb: t.galleryThumb,
2127
2232
  avatarImage: t.avatarImage,
2128
2233
  backgroundImage: t.backgroundImage,
@@ -2141,16 +2246,16 @@ function $t(e, t, n) {
2141
2246
  let e = document.createElement("img");
2142
2247
  e.className = "liforma-et__background liforma-et__media", e.alt = "", e.decoding = "async", e.src = r.backgroundImage, e.addEventListener("load", () => o(e), { once: !0 }), i.append(e);
2143
2248
  }
2144
- let c = document.createElement("img");
2145
- if (c.className = "liforma-et__avatar liforma-et__media", c.alt = "", c.decoding = "async", c.src = r.avatarImage, c.addEventListener("load", () => o(c), { once: !0 }), c.addEventListener("error", () => {
2146
- r.fallbackImage && (c.src = r.fallbackImage);
2147
- }, { once: !0 }), i.append(c), r.foregroundImage) {
2249
+ let s = document.createElement("img");
2250
+ if (s.className = "liforma-et__avatar liforma-et__media", s.alt = "", s.decoding = "async", s.src = r.avatarImage, s.addEventListener("load", () => o(s), { once: !0 }), s.addEventListener("error", () => {
2251
+ r.fallbackImage && (s.src = r.fallbackImage);
2252
+ }, { once: !0 }), i.append(s), r.foregroundImage) {
2148
2253
  let e = document.createElement("img");
2149
2254
  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);
2150
2255
  }
2151
2256
  return e.replaceChildren(i), n?.parallax === !1 ? () => {} : ne(i);
2152
2257
  }
2153
- function en(e) {
2258
+ function rn(e) {
2154
2259
  return e.startButton ? {
2155
2260
  ...e.startButton,
2156
2261
  label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
@@ -2162,7 +2267,7 @@ function en(e) {
2162
2267
  variant: "primary"
2163
2268
  };
2164
2269
  }
2165
- function tn(e) {
2270
+ function an(e) {
2166
2271
  let t = !1, n = () => {
2167
2272
  t || e();
2168
2273
  }, r = () => {
@@ -2182,12 +2287,12 @@ function tn(e) {
2182
2287
  t = !0, window.removeEventListener("load", r), i?.();
2183
2288
  };
2184
2289
  }
2185
- function nn(e, t) {
2290
+ function on(e, t) {
2186
2291
  oe(ie);
2187
2292
  let n = t.experienceId?.trim();
2188
2293
  if (!n) throw Error("ExperienceWidget requires experienceId.");
2189
- let r = t.prefetch ?? "onExpand", i = qt(t.position), a = document.createElement("div");
2190
- a.className = "liforma-ew", a.dataset.state = "collapsed", a.dataset.prefetch = r, a.dataset.position = i, a.style.setProperty("--liforma-ew-max-w", t.expandedMaxWidth ?? "100%"), a.style.setProperty("--liforma-ew-max-h", t.expandedMaxHeight ?? "100%"), i !== "static" && a.style.setProperty("--liforma-ew-offset", Jt(t.offset));
2294
+ let r = t.prefetch ?? "onExpand", i = Xt(t.position), a = document.createElement("div");
2295
+ a.className = "liforma-ew", a.dataset.state = "collapsed", a.dataset.prefetch = r, a.dataset.position = i, a.style.setProperty("--liforma-ew-max-w", t.expandedMaxWidth ?? "100%"), a.style.setProperty("--liforma-ew-max-h", t.expandedMaxHeight ?? "100%"), i !== "static" && a.style.setProperty("--liforma-ew-offset", Zt(t.offset));
2191
2296
  let o = document.createElement("button");
2192
2297
  o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
2193
2298
  let s = document.createElement("div");
@@ -2207,138 +2312,138 @@ function nn(e, t) {
2207
2312
  let m = document.createElement("span");
2208
2313
  m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
2209
2314
  let h = document.createElement("button");
2210
- h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = Zt, h.setAttribute("aria-label", "Reduce");
2315
+ h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = en, h.setAttribute("aria-label", "Reduce");
2211
2316
  let g = document.createElement("button");
2212
- g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = Yt, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
2317
+ g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = Qt, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
2213
2318
  let _ = document.createElement("button");
2214
- _.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = Xt, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
2215
- let ee = document.createElement("div");
2216
- ee.className = "liforma-ew__stage";
2319
+ _.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = $t, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
2217
2320
  let v = document.createElement("div");
2218
- v.className = "liforma-ew__status", v.hidden = !0, f.append(ee, v), u.append(d, f), a.append(o, l, u, p), e.replaceChildren(a);
2219
- let y = null, b = !1, x = !1, te = !1, S = !1, C = !1, w = !1, T = !1, E = 0, D = "", O = null, k = null, A = null, j = null, M = null, N = null, P = null, ne = 0, re = 0, F = null, I = !1, ae = new AbortController(), se = t.parallax !== !1, L = () => {
2321
+ v.className = "liforma-ew__stage";
2322
+ let y = document.createElement("div");
2323
+ y.className = "liforma-ew__status", y.hidden = !0, f.append(v, y), u.append(d, f), a.append(o, l, u, p), e.replaceChildren(a);
2324
+ let b = null, x = !1, S = !1, ee = !1, C = !1, w = !1, T = !1, E = !1, D = 0, O = "", k = null, A = null, j = null, M = null, N = null, P = null, F = null, te = 0, ne = 0, I = null, L = !1, re = new AbortController(), ae = t.parallax !== !1, R = () => {
2220
2325
  let e = a.dataset.state;
2221
2326
  return e === "expanded" || e === "docked" || e === "collapsed" ? e : "collapsed";
2222
- }, R = () => {
2223
- A !== null && (clearTimeout(A), A = null);
2327
+ }, z = () => {
2328
+ j !== null && (clearTimeout(j), j = null);
2329
+ }, se = () => {
2330
+ M !== null && (clearTimeout(M), M = null), a.classList.remove("liforma-ew--layout-settling");
2224
2331
  }, ce = () => {
2225
- j !== null && (clearTimeout(j), j = null), a.classList.remove("liforma-ew--layout-settling");
2226
- }, le = () => {
2227
2332
  for (let e of [
2228
2333
  f,
2229
2334
  l,
2230
2335
  p
2231
2336
  ]) e.style.removeProperty("left"), e.style.removeProperty("top"), e.style.removeProperty("width"), e.style.removeProperty("height"), e.style.removeProperty("right"), e.style.removeProperty("bottom");
2232
2337
  p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging");
2233
- }, z = (e, t, n, r) => {
2338
+ }, le = (e, t, n, r) => {
2234
2339
  let i = (i) => {
2235
2340
  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";
2236
2341
  };
2237
2342
  i(f), i(l);
2238
2343
  let a = p.offsetWidth || 120;
2239
2344
  p.style.left = `${e + n - a - 10}px`, p.style.top = `${t + 10}px`, p.style.right = "auto", p.style.bottom = "auto", p.style.width = "auto", p.style.height = "auto";
2345
+ }, B = (e, t) => {
2346
+ if (R() !== "docked") return;
2347
+ let n = qt(), r = Yt(e - te, t - ne, n);
2348
+ N = r.left, P = r.top, le(r.left, r.top, n.width, n.height);
2240
2349
  }, de = (e, t) => {
2241
- if (L() !== "docked") return;
2242
- let n = Wt(), r = Kt(e - ne, t - re, n);
2243
- M = r.left, N = r.top, z(r.left, r.top, n.width, n.height);
2244
- }, fe = (e, t) => {
2245
- if (L() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
2246
- let n = Wt(), r = M ?? f.getBoundingClientRect().left, i = N ?? f.getBoundingClientRect().top, a = Kt(r + e, i + t, n);
2247
- M = a.left, N = a.top, z(a.left, a.top, n.width, n.height);
2248
- }, pe = (e) => {
2249
- F === "toolbar" && (P === null || e.pointerId !== P || (e.preventDefault(), de(e.clientX, e.clientY)));
2250
- }, B = (e) => {
2251
- if (P === null || e && e.pointerId !== P) return;
2252
- let t = F;
2253
- P = null, F = null, p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging"), t === "toolbar" && I && (I = !1, window.removeEventListener("pointermove", pe), window.removeEventListener("pointerup", B), window.removeEventListener("pointercancel", B));
2254
- }, me = (e, t, n) => {
2255
- if (x || L() !== "docked" || !Q() || P !== null) return;
2256
- P = n, F = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
2257
- let r = f.getBoundingClientRect();
2258
- ne = e - r.left, re = t - r.top, I || (I = !0, window.addEventListener("pointermove", pe), window.addEventListener("pointerup", B), window.addEventListener("pointercancel", B));
2350
+ if (R() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
2351
+ let n = qt(), r = N ?? f.getBoundingClientRect().left, i = P ?? f.getBoundingClientRect().top, a = Yt(r + e, i + t, n);
2352
+ N = a.left, P = a.top, le(a.left, a.top, n.width, n.height);
2353
+ }, fe = (e) => {
2354
+ I === "toolbar" && (F === null || e.pointerId !== F || (e.preventDefault(), B(e.clientX, e.clientY)));
2259
2355
  }, V = (e) => {
2260
- if (x || L() !== "docked" || !Q() || P !== null) return;
2261
- P = e.pointerId, F = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
2356
+ if (F === null || e && e.pointerId !== F) return;
2357
+ let t = I;
2358
+ 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", fe), window.removeEventListener("pointerup", V), window.removeEventListener("pointercancel", V));
2359
+ }, pe = (e, t, n) => {
2360
+ if (S || R() !== "docked" || !Q() || F !== null) return;
2361
+ F = n, I = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
2362
+ let r = f.getBoundingClientRect();
2363
+ te = e - r.left, ne = t - r.top, L || (L = !0, window.addEventListener("pointermove", fe), window.addEventListener("pointerup", V), window.addEventListener("pointercancel", V));
2364
+ }, me = (e) => {
2365
+ if (S || R() !== "docked" || !Q() || F !== null) return;
2366
+ F = e.pointerId, I = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
2262
2367
  let t = f.getBoundingClientRect();
2263
- M = t.left, N = t.top;
2368
+ N = t.left, P = t.top;
2264
2369
  }, H = (e) => {
2265
- F === "player" && (P === null || e.pointerId !== P || fe(e.dx, e.dy));
2266
- }, he = (e) => {
2267
- F === "player" && (P === null || e.pointerId !== P || B());
2268
- }, U = () => {
2269
- let e = Q(), t = L();
2370
+ I === "player" && (F === null || e.pointerId !== F || de(e.dx, e.dy));
2371
+ }, U = (e) => {
2372
+ I === "player" && (F === null || e.pointerId !== F || V());
2373
+ }, W = () => {
2374
+ let e = Q(), t = R();
2270
2375
  if (!e || t !== "expanded" && t !== "docked") {
2271
2376
  h.hidden = !0;
2272
2377
  return;
2273
2378
  }
2274
- h.hidden = !1, t === "docked" ? (h.innerHTML = Qt, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = Zt, h.setAttribute("aria-label", "Reduce"));
2275
- }, ge = (e) => {
2276
- let t = Wt(), n = e && M !== null && N !== null ? Kt(M, N, t) : Gt(t);
2277
- n = Kt(n.left, n.top, t), M = n.left, N = n.top, z(n.left, n.top, t.width, t.height), U();
2278
- }, _e = () => {
2379
+ h.hidden = !1, t === "docked" ? (h.innerHTML = tn, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = en, h.setAttribute("aria-label", "Reduce"));
2380
+ }, he = (e) => {
2381
+ let t = qt(), n = e && N !== null && P !== null ? Yt(N, P, t) : Jt(t);
2382
+ n = Yt(n.left, n.top, t), N = n.left, P = n.top, le(n.left, n.top, t.width, t.height), W();
2383
+ }, ge = () => {
2279
2384
  a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
2280
2385
  requestAnimationFrame(() => {
2281
- x || !$(a.dataset.state) || a.classList.add("liforma-ew--session-revealed");
2386
+ S || !$(a.dataset.state) || a.classList.add("liforma-ew--session-revealed");
2282
2387
  });
2283
2388
  });
2284
- }, ve = (e) => {
2285
- if (ce(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !T) {
2389
+ }, _e = (e) => {
2390
+ if (se(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !E) {
2286
2391
  a.classList.remove("liforma-ew--layout-settling");
2287
2392
  return;
2288
2393
  }
2289
- j = setTimeout(() => {
2290
- if (j = null, x || !$(a.dataset.state)) {
2394
+ M = setTimeout(() => {
2395
+ if (M = null, S || !$(a.dataset.state)) {
2291
2396
  a.classList.remove("liforma-ew--layout-settling");
2292
2397
  return;
2293
2398
  }
2294
- a.classList.remove("liforma-ew--layout-settling"), _e();
2399
+ a.classList.remove("liforma-ew--layout-settling"), ge();
2295
2400
  }, 220);
2296
- }, ye = () => (a.classList.add("liforma-ew--session-concealing"), a.classList.remove("liforma-ew--session-revealed"), new Promise((e) => {
2297
- R(), A = setTimeout(() => {
2298
- A = null, a.classList.remove("liforma-ew--session-concealing"), e();
2401
+ }, ve = () => (a.classList.add("liforma-ew--session-concealing"), a.classList.remove("liforma-ew--session-revealed"), new Promise((e) => {
2402
+ z(), j = setTimeout(() => {
2403
+ j = null, a.classList.remove("liforma-ew--session-concealing"), e();
2299
2404
  }, 280);
2300
- })), be = {
2405
+ })), ye = {
2301
2406
  galleryThumb: t.galleryThumb,
2302
2407
  avatarImage: t.avatarImage,
2303
2408
  backgroundImage: t.backgroundImage,
2304
2409
  foregroundImage: t.foregroundImage,
2305
2410
  fallbackImage: t.fallbackImage
2306
- }, W = (e) => {
2411
+ }, G = (e) => {
2307
2412
  if (!e) {
2308
- v.hidden = !0, v.textContent = "";
2413
+ y.hidden = !0, y.textContent = "";
2309
2414
  return;
2310
2415
  }
2311
- v.hidden = !1, v.textContent = e;
2312
- }, xe = (e) => {
2416
+ y.hidden = !1, y.textContent = e;
2417
+ }, be = (e) => {
2313
2418
  if (!e) {
2314
2419
  c.hidden = !0, c.textContent = "";
2315
2420
  return;
2316
2421
  }
2317
2422
  c.hidden = !1, c.textContent = e, s.contains(c) || s.append(c);
2423
+ }, xe = () => {
2424
+ ee = !0, o.disabled = !1, be(null), r === "onExpand" && t.onPrefetchReady?.();
2318
2425
  }, Se = () => {
2319
- te = !0, o.disabled = !1, xe(null), r === "onExpand" && t.onPrefetchReady?.();
2320
- }, Ce = () => {
2321
- S = !0, a.dataset.warm = "true", l.hidden = !1, T || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
2322
- }, we = (e) => {
2323
- O?.(), O = null;
2324
- let t = $t(s, e, { parallax: se });
2325
- return t ? (O = t, !0) : !1;
2326
- }, Te = () => {
2327
- if (we(be)) {
2328
- Se();
2426
+ C = !0, a.dataset.warm = "true", l.hidden = !1, E || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
2427
+ }, Ce = (e) => {
2428
+ k?.(), k = null;
2429
+ let t = nn(s, e, { parallax: ae });
2430
+ return t ? (k = t, !0) : !1;
2431
+ }, we = () => {
2432
+ if (Ce(ye)) {
2433
+ xe();
2329
2434
  return;
2330
2435
  }
2331
- xe("Loading…"), ue(n, { signal: ae.signal }).then((e) => {
2332
- if (!x) {
2333
- if (!we({ galleryThumb: e.galleryThumb })) throw Error("Experience preview is missing gallery thumb images.");
2334
- Se();
2436
+ be("Loading…"), ue(n, { signal: re.signal }).then((e) => {
2437
+ if (!S) {
2438
+ if (!Ce({ galleryThumb: e.galleryThumb })) throw Error("Experience preview is missing gallery thumb images.");
2439
+ xe();
2335
2440
  }
2336
2441
  }).catch((e) => {
2337
- if (x || ae.signal.aborted) return;
2442
+ if (S || re.signal.aborted) return;
2338
2443
  let n = e instanceof Error ? e : Error(String(e));
2339
- xe("Preview unavailable"), o.disabled = !0, t.onError?.(n), console.error("[ExperienceWidget]", n);
2444
+ be("Preview unavailable"), o.disabled = !0, t.onError?.(n), console.error("[ExperienceWidget]", n);
2340
2445
  });
2341
- }, Ee = () => ({
2446
+ }, Te = () => ({
2342
2447
  experienceId: n,
2343
2448
  ui: "widget",
2344
2449
  ...t.sessionEndpoint ? { sessionEndpoint: t.sessionEndpoint } : {},
@@ -2348,231 +2453,236 @@ function nn(e, t) {
2348
2453
  ...t.speechInputMode ? { speechInputMode: t.speechInputMode } : {},
2349
2454
  ...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
2350
2455
  ...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
2351
- }), De = () => ({
2456
+ }), Ee = () => ({
2352
2457
  ...t.fit ? { fit: t.fit } : {},
2353
- startButton: en(t)
2354
- }), G = (e = !0) => {
2355
- o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), le(), a.dataset.state = "expanded", W(null), typeof document < "u" && (D = document.body.style.overflow, document.body.style.overflow = "hidden"), U(), e && t.onExpanded?.();
2356
- }, Oe = () => {
2357
- o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked", W(null), typeof document < "u" && (document.body.style.overflow = D), ge(!0), U(), y?.setWidgetChrome("docked");
2358
- }, ke = (e) => {
2458
+ startButton: rn(t),
2459
+ ...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback }
2460
+ }), K = (e = !0) => {
2461
+ o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), ce(), a.dataset.state = "expanded", G(null), typeof document < "u" && (O = document.body.style.overflow, document.body.style.overflow = "hidden"), W(), e && t.onExpanded?.();
2462
+ }, De = () => {
2463
+ o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked", G(null), typeof document < "u" && (document.body.style.overflow = O), he(!0), W(), b?.setWidgetChrome("docked");
2464
+ }, Oe = (e) => {
2359
2465
  e.on("started", () => {
2360
- x || (T = !0, a.dataset.live = "true", W(null), t.onStarted?.(), $(a.dataset.state) && _e());
2466
+ S || (E = !0, a.dataset.live = "true", G(null), t.onStarted?.(), $(a.dataset.state) && ge());
2467
+ }), e.on("feedback", (e) => {
2468
+ S || t.onFeedback?.(e);
2469
+ }), e.on("feedbackFailed", (e) => {
2470
+ S || t.onFeedbackFailed?.(e);
2361
2471
  });
2472
+ }, ke = () => {
2473
+ se(), u.hidden = !0, p.hidden = !0, ce(), a.dataset.state = "collapsed", a.classList.remove("liforma-ew--session-revealed"), a.classList.remove("liforma-ew--session-concealing"), g.setAttribute("aria-pressed", "false"), o.hidden = !1, o.tabIndex = 0, o.removeAttribute("aria-hidden"), ee && (o.disabled = !1), G(null), typeof document < "u" && (document.body.style.overflow = O), W();
2362
2474
  }, Ae = () => {
2363
- ce(), u.hidden = !0, p.hidden = !0, le(), a.dataset.state = "collapsed", a.classList.remove("liforma-ew--session-revealed"), a.classList.remove("liforma-ew--session-concealing"), g.setAttribute("aria-pressed", "false"), o.hidden = !1, o.tabIndex = 0, o.removeAttribute("aria-hidden"), te && (o.disabled = !1), W(null), typeof document < "u" && (document.body.style.overflow = D), U();
2364
- }, K = () => {
2365
- R(), ce(), E += 1, b = !1, S = !1, C = !1, w = !1, T = !1;
2366
- let e = y;
2367
- y = null, e?.destroy(), ee.replaceChildren(), l.replaceChildren(), l.hidden = !0, delete a.dataset.warm, delete a.dataset.live, a.classList.remove("liforma-ew--session-revealed");
2475
+ z(), se(), D += 1, x = !1, C = !1, w = !1, T = !1, E = !1;
2476
+ let e = b;
2477
+ 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");
2368
2478
  }, q = () => {
2369
- if (!x && $(a.dataset.state)) {
2370
- if (B(), b = !1, y && w) {
2371
- let e = y;
2479
+ if (!S && $(a.dataset.state)) {
2480
+ if (V(), x = !1, b && T) {
2481
+ let e = b;
2372
2482
  (async () => {
2373
- T && (await ye(), x || y !== e) || (S && e.setWidgetChrome("collapsed"), Ae(), T ? (a.dataset.live = "true", o.tabIndex = 0, o.removeAttribute("aria-hidden"), o.disabled = !1) : S && Ce(), t.onCollapsed?.(), t.onClose?.());
2483
+ E && (await ve(), S || b !== e) || (C && e.setWidgetChrome("collapsed"), ke(), E ? (a.dataset.live = "true", o.tabIndex = 0, o.removeAttribute("aria-hidden"), o.disabled = !1) : C && Se(), t.onCollapsed?.(), t.onClose?.());
2374
2484
  })();
2375
2485
  return;
2376
2486
  }
2377
- K(), Ae(), t.onCollapsed?.(), t.onClose?.();
2487
+ Ae(), ke(), t.onCollapsed?.(), t.onClose?.();
2378
2488
  }
2379
2489
  }, je = () => {
2380
- x || Q() && L() === "expanded" && ve(() => {
2381
- Oe();
2490
+ S || Q() && R() === "expanded" && _e(() => {
2491
+ De();
2382
2492
  });
2383
- }, Me = () => {
2384
- x || L() === "docked" && (B(), ve(() => {
2385
- le(), G(!1), y?.setWidgetChrome("expanded");
2493
+ }, J = () => {
2494
+ S || R() === "docked" && (V(), _e(() => {
2495
+ ce(), K(!1), b?.setWidgetChrome("expanded");
2386
2496
  }));
2497
+ }, Me = () => {
2498
+ !b || !E || (z(), a.classList.remove("liforma-ew--session-revealed"), K(), b.setWidgetChrome("expanded"), x = !1, ge());
2387
2499
  }, Ne = () => {
2388
- !y || !T || (R(), a.classList.remove("liforma-ew--session-revealed"), G(), y.setWidgetChrome("expanded"), b = !1, _e());
2389
- }, Pe = () => {
2390
- !y || !w || T || (R(), a.classList.remove("liforma-ew--session-revealed"), G(), b = !1, S || y.setWidgetChrome("expanded"));
2391
- }, Fe = (e) => {
2392
- x || e !== E && !T || (R(), a.classList.remove("liforma-ew--session-revealed"), G(), b = !1, T && _e());
2393
- }, Ie = () => {
2394
- if (x || C || S || y || $(a.dataset.state)) return;
2395
- C = !0;
2396
- let e = E;
2500
+ !b || !T || E || (z(), a.classList.remove("liforma-ew--session-revealed"), K(), x = !1, C || b.setWidgetChrome("expanded"));
2501
+ }, Pe = (e) => {
2502
+ S || e !== D && !E || (z(), a.classList.remove("liforma-ew--session-revealed"), K(), x = !1, E && ge());
2503
+ }, Fe = () => {
2504
+ if (S || w || C || b || $(a.dataset.state)) return;
2505
+ w = !0;
2506
+ let e = D;
2397
2507
  l.hidden = !1, (async () => {
2398
2508
  try {
2399
- let t = await Ft.startSession(Ee());
2400
- if (x || e !== E) {
2509
+ let t = await Rt.startSession(Te());
2510
+ if (S || e !== D) {
2401
2511
  t.destroy();
2402
2512
  return;
2403
2513
  }
2404
- y = t, ke(t);
2514
+ b = t, Oe(t);
2405
2515
  let n = await t.attach({
2406
2516
  container: l,
2407
- ...De(),
2517
+ ...Ee(),
2408
2518
  onWidgetReady: () => {
2409
- x || e !== E || (C = !1, w = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") : Ce());
2519
+ S || e !== D || (w = !1, T = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") : Se());
2410
2520
  },
2411
2521
  onWidgetExpand: () => {
2412
- Fe(e);
2522
+ Pe(e);
2413
2523
  },
2414
2524
  onWidgetAudioSettings: (e) => {
2415
- x || Be(e);
2525
+ S || ze(e);
2416
2526
  },
2417
2527
  onWidgetDragStart: (e) => {
2418
- x || V(e);
2528
+ S || me(e);
2419
2529
  },
2420
2530
  onWidgetDragMove: (e) => {
2421
- x || H(e);
2531
+ S || H(e);
2422
2532
  },
2423
2533
  onWidgetDragEnd: (e) => {
2424
- x || he(e);
2534
+ S || U(e);
2425
2535
  },
2426
2536
  onPlayerStatusChange: (e) => {
2427
- x || e === "error" && $(a.dataset.state) && W("Could not load the experience.");
2537
+ S || e === "error" && $(a.dataset.state) && G("Could not load the experience.");
2428
2538
  }
2429
2539
  });
2430
- if (x || e !== E) {
2431
- t.destroy(), y === t && (y = null);
2540
+ if (S || e !== D) {
2541
+ t.destroy(), b === t && (b = null);
2432
2542
  return;
2433
2543
  }
2434
2544
  n.on("close", () => {
2435
- x || q();
2545
+ S || q();
2436
2546
  });
2437
2547
  } catch (n) {
2438
- if (x || e !== E) return;
2439
- C = !1, l.hidden = !0, l.replaceChildren(), y = null;
2548
+ if (S || e !== D) return;
2549
+ w = !1, l.hidden = !0, l.replaceChildren(), b = null;
2440
2550
  let r = n instanceof Error ? n : Error(String(n));
2441
2551
  t.onError?.(r), console.error("[ExperienceWidget] warm prefetch failed", r);
2442
2552
  }
2443
2553
  })();
2444
- }, Le = () => {
2445
- if (x || b || !te || $(a.dataset.state)) return;
2446
- if (y && T) {
2447
- Ne();
2554
+ }, Ie = () => {
2555
+ if (S || x || !ee || $(a.dataset.state)) return;
2556
+ if (b && E) {
2557
+ Me();
2448
2558
  return;
2449
2559
  }
2450
- if (y && w) {
2451
- Pe();
2560
+ if (b && T) {
2561
+ Ne();
2452
2562
  return;
2453
2563
  }
2454
- let e = ++E;
2455
- b = !0, S = !1, C = !1, w = !1, T = !1, delete a.dataset.warm, delete a.dataset.live, l.hidden = !0, l.replaceChildren(), y &&= (y.destroy(), null), (async () => {
2564
+ let e = ++D;
2565
+ x = !0, C = !1, w = !1, T = !1, E = !1, delete a.dataset.warm, delete a.dataset.live, l.hidden = !0, l.replaceChildren(), b &&= (b.destroy(), null), (async () => {
2456
2566
  try {
2457
- G();
2458
- let t = await Ft.startSession(Ee());
2459
- if (x || e !== E) {
2567
+ K();
2568
+ let t = await Rt.startSession(Te());
2569
+ if (S || e !== D) {
2460
2570
  t.destroy();
2461
2571
  return;
2462
2572
  }
2463
- y = t, ke(t);
2573
+ b = t, Oe(t);
2464
2574
  let n = await t.attach({
2465
- container: ee,
2466
- ...De(),
2575
+ container: v,
2576
+ ...Ee(),
2467
2577
  onWidgetAudioSettings: (e) => {
2468
- x || Be(e);
2578
+ S || ze(e);
2469
2579
  },
2470
2580
  onWidgetDragStart: (e) => {
2471
- x || V(e);
2581
+ S || me(e);
2472
2582
  },
2473
2583
  onWidgetDragMove: (e) => {
2474
- x || H(e);
2584
+ S || H(e);
2475
2585
  },
2476
2586
  onWidgetDragEnd: (e) => {
2477
- x || he(e);
2587
+ S || U(e);
2478
2588
  },
2479
2589
  onPlayerStatusChange: (e) => {
2480
- x || (e === "error" ? W("Could not load the experience.") : $(a.dataset.state) && W(null));
2590
+ S || (e === "error" ? G("Could not load the experience.") : $(a.dataset.state) && G(null));
2481
2591
  }
2482
2592
  });
2483
- if (x || e !== E) {
2484
- t.destroy(), y === t && (y = null);
2593
+ if (S || e !== D) {
2594
+ t.destroy(), b === t && (b = null);
2485
2595
  return;
2486
2596
  }
2487
- w = !0, t.setWidgetChrome("expanded"), n.on("close", () => {
2488
- x || q();
2597
+ T = !0, t.setWidgetChrome("expanded"), n.on("close", () => {
2598
+ S || q();
2489
2599
  });
2490
2600
  } catch (n) {
2491
- if (x || e !== E) return;
2601
+ if (S || e !== D) return;
2492
2602
  let r = n instanceof Error ? n : Error(String(n));
2493
- W(r.message), t.onError?.(r), console.error("[ExperienceWidget]", r);
2603
+ G(r.message), t.onError?.(r), console.error("[ExperienceWidget]", r);
2494
2604
  } finally {
2495
- e === E && (b = !1);
2605
+ e === D && (x = !1);
2496
2606
  }
2497
2607
  })();
2498
- }, Re = () => {
2499
- if (!(x || $(a.dataset.state))) {
2500
- if (y && T) {
2501
- Ne();
2608
+ }, Le = () => {
2609
+ if (!(S || $(a.dataset.state))) {
2610
+ if (b && E) {
2611
+ Me();
2502
2612
  return;
2503
2613
  }
2504
- if (y && w) {
2505
- Pe();
2614
+ if (b && T) {
2615
+ Ne();
2506
2616
  return;
2507
2617
  }
2508
- if (C || y) {
2509
- G();
2618
+ if (w || b) {
2619
+ K();
2510
2620
  return;
2511
2621
  }
2512
- Le();
2622
+ Ie();
2513
2623
  }
2514
- }, ze = (e) => {
2515
- if (e.stopPropagation(), L() === "expanded") {
2624
+ }, Re = (e) => {
2625
+ if (e.stopPropagation(), R() === "expanded") {
2516
2626
  je();
2517
2627
  return;
2518
2628
  }
2519
- L() === "docked" && Me();
2520
- }, Be = (e) => {
2629
+ R() === "docked" && J();
2630
+ }, ze = (e) => {
2521
2631
  g.setAttribute("aria-pressed", e ? "true" : "false");
2522
- }, J = (e) => {
2523
- e.stopPropagation(), $(a.dataset.state) && y?.toggleAudioSettings();
2632
+ }, Be = (e) => {
2633
+ e.stopPropagation(), $(a.dataset.state) && b?.toggleAudioSettings();
2634
+ }, Y = (e) => {
2635
+ R() === "docked" && Q() && (e.target?.closest("button") || (e.preventDefault(), pe(e.clientX, e.clientY, e.pointerId)));
2524
2636
  }, Ve = (e) => {
2525
- L() === "docked" && Q() && (e.target?.closest("button") || (e.preventDefault(), me(e.clientX, e.clientY, e.pointerId)));
2526
- }, He = (e) => {
2527
2637
  e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), q());
2528
- }, Ue = () => {
2529
- if (!x) {
2530
- if (L() === "docked") {
2638
+ }, He = () => {
2639
+ if (!S) {
2640
+ if (R() === "docked") {
2531
2641
  if (!Q()) {
2532
- Me();
2642
+ J();
2533
2643
  return;
2534
2644
  }
2535
- T ? ve(() => {
2536
- ge(!0);
2537
- }) : ge(!0);
2645
+ E ? _e(() => {
2646
+ he(!0);
2647
+ }) : he(!0);
2538
2648
  return;
2539
2649
  }
2540
- U();
2650
+ W();
2541
2651
  }
2542
- }, We = typeof window < "u" ? window.matchMedia(Lt) : null, Ge = () => {
2543
- if (!x) {
2544
- if (L() === "docked" && !Q()) {
2545
- Me();
2652
+ }, Ue = typeof window < "u" ? window.matchMedia(Bt) : null, We = () => {
2653
+ if (!S) {
2654
+ if (R() === "docked" && !Q()) {
2655
+ J();
2546
2656
  return;
2547
2657
  }
2548
- U();
2658
+ W();
2549
2659
  }
2550
2660
  };
2551
- return o.addEventListener("click", Re), d.addEventListener("click", q), _.addEventListener("click", (e) => {
2661
+ return o.addEventListener("click", Le), d.addEventListener("click", q), _.addEventListener("click", (e) => {
2552
2662
  e.stopPropagation(), q();
2553
- }), h.addEventListener("click", ze), g.addEventListener("click", J), p.addEventListener("pointerdown", Ve), window.addEventListener("keydown", He), window.addEventListener("resize", Ue), We?.addEventListener("change", Ge), Te(), U(), r === "eager" ? queueMicrotask(() => {
2554
- x || Ie();
2555
- }) : r === "idle" && (k = tn(() => {
2556
- x || Ie();
2663
+ }), h.addEventListener("click", Re), g.addEventListener("click", Be), p.addEventListener("pointerdown", Y), window.addEventListener("keydown", Ve), window.addEventListener("resize", He), Ue?.addEventListener("change", We), we(), W(), r === "eager" ? queueMicrotask(() => {
2664
+ S || Fe();
2665
+ }) : r === "idle" && (A = an(() => {
2666
+ S || Fe();
2557
2667
  })), {
2558
2668
  root: a,
2559
- expand: Re,
2669
+ expand: Le,
2560
2670
  collapse: q,
2561
2671
  dock: je,
2562
- maximize: Me,
2672
+ maximize: J,
2563
2673
  prefetch() {
2564
2674
  if (r === "onExpand") {
2565
- Ie();
2675
+ Fe();
2566
2676
  return;
2567
2677
  }
2568
- Ie();
2678
+ Fe();
2569
2679
  },
2570
2680
  destroy() {
2571
- x || (x = !0, B(), k?.(), k = null, ae.abort(), O?.(), O = null, window.removeEventListener("keydown", He), window.removeEventListener("resize", Ue), We?.removeEventListener("change", Ge), K(), Ae(), e.replaceChildren());
2681
+ S || (S = !0, V(), A?.(), A = null, re.abort(), k?.(), k = null, window.removeEventListener("keydown", Ve), window.removeEventListener("resize", He), Ue?.removeEventListener("change", We), Ae(), ke(), e.replaceChildren());
2572
2682
  }
2573
2683
  };
2574
2684
  }
2575
2685
  //#endregion
2576
- export { re as EXPERIENCE_THUMBNAIL_CSS, ie as EXPERIENCE_WIDGET_CSS, Ft as Experience, z as LiformaError, Y as SPEECH_LIMITS, ut as SpeechBufferTimeoutError, X as SpeechRuntimeError, lt as SpeechUtteranceClosedError, ct as UnsupportedSpeechOperationError, w as attachImageReady, C as attachLazyThumb, P as attachScrollLinkedParallax, p as buildHostedLaunchUrl, I as ensureExperienceThumbnailStyles, oe as ensureExperienceWidgetStyles, ue as fetchExperiencePreview, x as getDefaultLazyRootMargin, E as horizontalParallaxFromViewportY, fe as liformaErrorFromResponse, nn as mountExperienceWidget, n as navigateOnExperienceClose, m as resolveThumbnailHref, d as resolveThumbnailInteraction, s as resolveThumbnailLayers, o as toGalleryThumbUrl, ye as warnLocaleVoiceFallbacks };
2686
+ export { I as EXPERIENCE_THUMBNAIL_CSS, ie as EXPERIENCE_WIDGET_CSS, Rt as Experience, B as LiformaError, X as SPEECH_LIMITS, dt as SpeechBufferTimeoutError, Z as SpeechRuntimeError, ut as SpeechUtteranceClosedError, lt as UnsupportedSpeechOperationError, E as attachImageReady, T as attachLazyThumb, te as attachScrollLinkedParallax, m as buildHostedLaunchUrl, re as ensureExperienceThumbnailStyles, oe as ensureExperienceWidgetStyles, ue as fetchExperiencePreview, ee as getDefaultLazyRootMargin, O as horizontalParallaxFromViewportY, fe as liformaErrorFromResponse, on as mountExperienceWidget, n as navigateOnExperienceClose, h as resolveThumbnailHref, f as resolveThumbnailInteraction, c as resolveThumbnailLayers, r as thumbnailFitClass, s as toGalleryThumbUrl, ye as warnLocaleVoiceFallbacks };
2577
2687
 
2578
2688
  //# sourceMappingURL=index.js.map