@liforma/client 0.4.1 → 0.4.3

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