@liforma/client 0.4.3 → 0.4.5

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 (93) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/next/index.js +470 -377
  3. package/dist/next/index.js.map +1 -1
  4. package/dist/next/next/createLiformaSessionRouteHandler.d.ts +8 -0
  5. package/dist/next/next/createLiformaSessionRouteHandler.d.ts.map +1 -1
  6. package/dist/next/next/index.d.ts +8 -1
  7. package/dist/next/next/index.d.ts.map +1 -1
  8. package/dist/next/v2/api/captureAttribution.d.ts +10 -0
  9. package/dist/next/v2/api/captureAttribution.d.ts.map +1 -0
  10. package/dist/next/v2/api/mintPublicSession.d.ts +1 -0
  11. package/dist/next/v2/api/mintPublicSession.d.ts.map +1 -1
  12. package/dist/next/v2/api/sessionEndpointRequest.d.ts +1 -0
  13. package/dist/next/v2/api/sessionEndpointRequest.d.ts.map +1 -1
  14. package/dist/next/v2/embed/fullWindowHost.d.ts +20 -0
  15. package/dist/next/v2/embed/fullWindowHost.d.ts.map +1 -0
  16. package/dist/next/v2/embed/iframeHost.d.ts +2 -0
  17. package/dist/next/v2/embed/iframeHost.d.ts.map +1 -1
  18. package/dist/next/v2/embed/protocol.d.ts +14 -0
  19. package/dist/next/v2/embed/protocol.d.ts.map +1 -1
  20. package/dist/next/v2/experience.d.ts +16 -1
  21. package/dist/next/v2/experience.d.ts.map +1 -1
  22. package/dist/next/v2/experienceEvents.d.ts +5 -0
  23. package/dist/next/v2/experienceEvents.d.ts.map +1 -1
  24. package/dist/next/v2/shims/embedBaseUrl.d.ts +3 -2
  25. package/dist/next/v2/shims/embedBaseUrl.d.ts.map +1 -1
  26. package/dist/next/v2/types/sessionInteraction.d.ts +19 -0
  27. package/dist/next/v2/types/sessionInteraction.d.ts.map +1 -1
  28. package/dist/next/v2/types/sessionManifest.d.ts +12 -0
  29. package/dist/next/v2/types/sessionManifest.d.ts.map +1 -1
  30. package/dist/npm/index.js +562 -475
  31. package/dist/npm/index.js.map +1 -1
  32. package/dist/npm/v2/api/captureAttribution.d.ts +10 -0
  33. package/dist/npm/v2/api/captureAttribution.d.ts.map +1 -0
  34. package/dist/npm/v2/api/mintPublicSession.d.ts +1 -0
  35. package/dist/npm/v2/api/mintPublicSession.d.ts.map +1 -1
  36. package/dist/npm/v2/api/sessionEndpointRequest.d.ts +1 -0
  37. package/dist/npm/v2/api/sessionEndpointRequest.d.ts.map +1 -1
  38. package/dist/npm/v2/embed/fullWindowHost.d.ts +20 -0
  39. package/dist/npm/v2/embed/fullWindowHost.d.ts.map +1 -0
  40. package/dist/npm/v2/embed/iframeHost.d.ts +2 -0
  41. package/dist/npm/v2/embed/iframeHost.d.ts.map +1 -1
  42. package/dist/npm/v2/embed/protocol.d.ts +14 -0
  43. package/dist/npm/v2/embed/protocol.d.ts.map +1 -1
  44. package/dist/npm/v2/experience.d.ts +16 -1
  45. package/dist/npm/v2/experience.d.ts.map +1 -1
  46. package/dist/npm/v2/experienceEvents.d.ts +5 -0
  47. package/dist/npm/v2/experienceEvents.d.ts.map +1 -1
  48. package/dist/npm/v2/index.d.ts +1 -1
  49. package/dist/npm/v2/index.d.ts.map +1 -1
  50. package/dist/npm/v2/npm.d.ts +2 -1
  51. package/dist/npm/v2/npm.d.ts.map +1 -1
  52. package/dist/npm/v2/shims/embedBaseUrl.d.ts +3 -2
  53. package/dist/npm/v2/shims/embedBaseUrl.d.ts.map +1 -1
  54. package/dist/npm/v2/speechOnlyManifest.d.ts.map +1 -1
  55. package/dist/npm/v2/types/sessionInteraction.d.ts +19 -0
  56. package/dist/npm/v2/types/sessionInteraction.d.ts.map +1 -1
  57. package/dist/npm/v2/types/sessionManifest.d.ts +12 -0
  58. package/dist/npm/v2/types/sessionManifest.d.ts.map +1 -1
  59. package/dist/npm/v2/types/sessionManifestSchema.d.ts +28 -0
  60. package/dist/npm/v2/types/sessionManifestSchema.d.ts.map +1 -1
  61. package/dist/react/component/experienceComponentLaunch.d.ts.map +1 -1
  62. package/dist/react/component/experienceComponentTypes.d.ts +4 -0
  63. package/dist/react/component/experienceComponentTypes.d.ts.map +1 -1
  64. package/dist/react/index.js +689 -592
  65. package/dist/react/index.js.map +1 -1
  66. package/dist/react/react/Experience.d.ts.map +1 -1
  67. package/dist/react/v2/api/captureAttribution.d.ts +10 -0
  68. package/dist/react/v2/api/captureAttribution.d.ts.map +1 -0
  69. package/dist/react/v2/api/mintPublicSession.d.ts +1 -0
  70. package/dist/react/v2/api/mintPublicSession.d.ts.map +1 -1
  71. package/dist/react/v2/api/sessionEndpointRequest.d.ts +1 -0
  72. package/dist/react/v2/api/sessionEndpointRequest.d.ts.map +1 -1
  73. package/dist/react/v2/embed/fullWindowHost.d.ts +20 -0
  74. package/dist/react/v2/embed/fullWindowHost.d.ts.map +1 -0
  75. package/dist/react/v2/embed/iframeHost.d.ts +2 -0
  76. package/dist/react/v2/embed/iframeHost.d.ts.map +1 -1
  77. package/dist/react/v2/embed/protocol.d.ts +14 -0
  78. package/dist/react/v2/embed/protocol.d.ts.map +1 -1
  79. package/dist/react/v2/experience.d.ts +16 -1
  80. package/dist/react/v2/experience.d.ts.map +1 -1
  81. package/dist/react/v2/experienceEvents.d.ts +5 -0
  82. package/dist/react/v2/experienceEvents.d.ts.map +1 -1
  83. package/dist/react/v2/shims/embedBaseUrl.d.ts +3 -2
  84. package/dist/react/v2/shims/embedBaseUrl.d.ts.map +1 -1
  85. package/dist/react/v2/types/sessionInteraction.d.ts +19 -0
  86. package/dist/react/v2/types/sessionInteraction.d.ts.map +1 -1
  87. package/dist/react/v2/types/sessionManifest.d.ts +12 -0
  88. package/dist/react/v2/types/sessionManifest.d.ts.map +1 -1
  89. package/dist/sdk/v2/client.js +6 -6
  90. package/dist/sdk/v2/client.js.map +1 -1
  91. package/dist/svelte/Experience.svelte +15 -0
  92. package/dist/svelte/Experience.svelte.d.ts +1 -0
  93. package/package.json +1 -1
@@ -25,6 +25,9 @@ function _(e) {
25
25
  if (n && e.launch) return {
26
26
  launch: e.launch,
27
27
  session: e.session,
28
+ backdropId: e.backdropId,
29
+ locationId: e.locationId,
30
+ avatarId: e.avatarId,
28
31
  embedBaseUrl: e.embedBaseUrl,
29
32
  debug: e.debug,
30
33
  speechOnly: e.speechOnly,
@@ -37,6 +40,7 @@ function _(e) {
37
40
  secondaryLocale: e.secondaryLocale,
38
41
  learningLocale: e.learningLocale,
39
42
  language: e.language,
43
+ backdropId: e.backdropId,
40
44
  locationId: e.locationId,
41
45
  avatarId: e.avatarId,
42
46
  castSize: e.castSize,
@@ -45,6 +49,7 @@ function _(e) {
45
49
  mode: e.mode,
46
50
  speechInputMode: e.speechInputMode,
47
51
  speechOnly: e.speechOnly,
52
+ attribution: e.attribution,
48
53
  conversationProcessor: e.conversationProcessor
49
54
  };
50
55
  if (e.experienceId) return {
@@ -53,6 +58,7 @@ function _(e) {
53
58
  secondaryLocale: e.secondaryLocale,
54
59
  learningLocale: e.learningLocale,
55
60
  language: e.language,
61
+ backdropId: e.backdropId,
56
62
  locationId: e.locationId,
57
63
  avatarId: e.avatarId,
58
64
  castSize: e.castSize,
@@ -61,6 +67,7 @@ function _(e) {
61
67
  mode: e.mode,
62
68
  speechInputMode: e.speechInputMode,
63
69
  speechOnly: e.speechOnly,
70
+ attribution: e.attribution,
64
71
  conversationProcessor: e.conversationProcessor
65
72
  };
66
73
  throw Error("Experience requires experienceId, sessionEndpoint, or launch.");
@@ -77,7 +84,9 @@ function v(e) {
77
84
  e.speechInputMode,
78
85
  e.conversationProcessor ? g(e.conversationProcessor) : 0,
79
86
  e.speechOnly,
87
+ e.attribution === !1 ? !1 : e.attribution,
80
88
  e.avatarId,
89
+ e.backdropId,
81
90
  e.locationId,
82
91
  e.castSize,
83
92
  e.embedBaseUrl,
@@ -95,14 +104,14 @@ function S() {
95
104
  if (typeof globalThis.location?.origin == "string" && globalThis.location.origin) return globalThis.location.origin;
96
105
  } catch {}
97
106
  }
98
- function ee(e) {
107
+ function C(e) {
99
108
  return y.exec(e)?.[1];
100
109
  }
101
- function C(e) {
110
+ function w(e) {
102
111
  return b.exec(e)?.[1];
103
112
  }
104
- function w(e, t) {
105
- let n = x(e).trim() || "Unknown error", r = t?.experienceId?.trim() || ee(n) || void 0, i = t?.origin?.trim() || C(n) || S() || void 0;
113
+ function T(e, t) {
114
+ let n = x(e).trim() || "Unknown error", r = t?.experienceId?.trim() || C(n) || void 0, i = t?.origin?.trim() || w(n) || S() || void 0;
106
115
  return /No playable experience found/i.test(n) || /^Experience is not available\.?$/i.test(n) || /^Unknown experience\.?$/i.test(n) || /experience_unavailable/i.test(n) ? {
107
116
  kind: "not_found",
108
117
  title: "The application tried to load an avatar experience that doesn’t exist.",
@@ -135,7 +144,7 @@ function w(e, t) {
135
144
  }
136
145
  //#endregion
137
146
  //#region src/component/experienceComponentRuntime.ts
138
- function T() {
147
+ function E() {
139
148
  let e, t, n = new Promise((n, r) => {
140
149
  e = n, t = r;
141
150
  });
@@ -145,29 +154,29 @@ function T() {
145
154
  reject: t
146
155
  };
147
156
  }
148
- function E() {
157
+ function D() {
149
158
  return new DOMException("Aborted", "AbortError");
150
159
  }
151
- function D(e) {
160
+ function O(e) {
152
161
  return e instanceof DOMException || e instanceof Error ? e : Error(String(e));
153
162
  }
154
- function O(e) {
163
+ function k(e) {
155
164
  return e instanceof DOMException && e.name === "AbortError";
156
165
  }
157
- function k(e) {
166
+ function A(e) {
158
167
  !e.instance || e.instanceDestroyed || (e.instanceDestroyed = !0, e.instance.destroy());
159
168
  }
160
- function A(e, t, n, r) {
169
+ function j(e, t, n, r) {
161
170
  e.unsubscribers.push(t.on(n, r));
162
171
  }
163
- function j(e, t, n) {
164
- A(e, t, "ready", (t) => {
172
+ function M(e, t, n) {
173
+ j(e, t, "ready", (t) => {
165
174
  e.destroyed || (e.ready.resolve(t), n().onReady?.(t));
166
- }), A(e, t, "started", (t) => {
175
+ }), j(e, t, "started", (t) => {
167
176
  e.destroyed || (e.started.resolve(t), n().onStarted?.(t));
168
- }), A(e, t, "userTranscript", (e) => n().onUserTranscript?.(e)), A(e, t, "userSpeechStarted", (e) => n().onUserSpeechStarted?.(e)), A(e, t, "userSpeechEnded", (e) => n().onUserSpeechEnded?.(e)), A(e, t, "characterSpeechStarted", (e) => n().onCharacterSpeechStarted?.(e)), A(e, t, "characterSpeechEnded", (e) => n().onCharacterSpeechEnded?.(e)), A(e, t, "characterFocusChanged", (e) => n().onCharacterFocusChanged?.(e)), A(e, t, "conversationUpdate", (e) => n().onConversationUpdate?.(e)), A(e, t, "message", (e) => n().onMessage?.(e)), A(e, t, "listeningState", (e) => n().onListeningState?.(e)), A(e, t, "activityChange", (e) => n().onActivityChange?.(e)), A(e, t, "feedback", (e) => n().onFeedback?.(e)), A(e, t, "feedbackFailed", (e) => n().onFeedbackFailed?.(e)), A(e, t, "conversationProcessorError", (e) => n().onConversationProcessorError?.(e));
177
+ }), j(e, t, "userTranscript", (e) => n().onUserTranscript?.(e)), j(e, t, "userSpeechStarted", (e) => n().onUserSpeechStarted?.(e)), j(e, t, "userSpeechEnded", (e) => n().onUserSpeechEnded?.(e)), j(e, t, "characterSpeechStarted", (e) => n().onCharacterSpeechStarted?.(e)), j(e, t, "characterSpeechEnded", (e) => n().onCharacterSpeechEnded?.(e)), j(e, t, "characterFocusChanged", (e) => n().onCharacterFocusChanged?.(e)), j(e, t, "conversationUpdate", (e) => n().onConversationUpdate?.(e)), j(e, t, "message", (e) => n().onMessage?.(e)), j(e, t, "listeningState", (e) => n().onListeningState?.(e)), j(e, t, "activityChange", (e) => n().onActivityChange?.(e)), j(e, t, "feedback", (e) => n().onFeedback?.(e)), j(e, t, "feedbackFailed", (e) => n().onFeedbackFailed?.(e)), j(e, t, "conversationProcessorError", (e) => n().onConversationProcessorError?.(e));
169
178
  }
170
- function M(e = () => ({}), t = () => ({})) {
179
+ function N(e = () => ({}), t = () => ({})) {
171
180
  let n = 0, r = null;
172
181
  function i(e) {
173
182
  if (e) {
@@ -182,22 +191,22 @@ function M(e = () => ({}), t = () => ({})) {
182
191
  }
183
192
  }
184
193
  function a(e, t, n, a, o = !1, s) {
185
- let c = D(e);
186
- return !O(c) && r === t && !t.destroyed && (o && a?.(w(c, { experienceId: i(s) })), t.reportedErrors.has(c) || (t.reportedErrors.add(c), console.error("[Experience]", c), n.onError?.(c))), c;
194
+ let c = O(e);
195
+ return !k(c) && r === t && !t.destroyed && (o && a?.(T(c, { experienceId: i(s) })), t.reportedErrors.has(c) || (t.reportedErrors.add(c), console.error("[Experience]", c), n.onError?.(c))), c;
187
196
  }
188
197
  function o() {
189
- if (!r || r.destroyed) throw E();
198
+ if (!r || r.destroyed) throw D();
190
199
  return r;
191
200
  }
192
201
  function s(e) {
193
- if (e.destroyed || r !== e) throw E();
202
+ if (e.destroyed || r !== e) throw D();
194
203
  }
195
204
  function u() {
196
205
  return {
197
206
  id: ++n,
198
- session: T(),
199
- ready: T(),
200
- started: T(),
207
+ session: E(),
208
+ ready: E(),
209
+ started: E(),
201
210
  unsubscribers: [],
202
211
  reportedErrors: /* @__PURE__ */ new Set(),
203
212
  instance: null,
@@ -208,19 +217,19 @@ function M(e = () => ({}), t = () => ({})) {
208
217
  function d(e) {
209
218
  if (e.destroyed) return;
210
219
  e.destroyed = !0;
211
- let t = E();
220
+ let t = D();
212
221
  e.session.reject(t), e.ready.reject(t), e.started.reject(t);
213
222
  for (let t of e.unsubscribers.splice(0)) t();
214
- k(e), r === e && (r = null);
223
+ A(e), r === e && (r = null);
215
224
  }
216
225
  async function f(e, n, i, o, u, d) {
217
226
  try {
218
227
  let a = await c.startSession(i);
219
228
  if (e.instance = a, e.destroyed || r !== e) {
220
- k(e);
229
+ A(e);
221
230
  return;
222
231
  }
223
- j(e, a, o);
232
+ M(e, a, o);
224
233
  let d = t(), f = d.returnUrl?.trim() || u?.trim(), p = await a.attach({
225
234
  container: n,
226
235
  fit: d.fit,
@@ -247,7 +256,7 @@ function M(e = () => ({}), t = () => ({})) {
247
256
  });
248
257
  } catch (t) {
249
258
  let n = a(t, e, o(), d, !0, i);
250
- e.session.reject(n), e.ready.reject(n), e.started.reject(n), k(e);
259
+ e.session.reject(n), e.ready.reject(n), e.started.reject(n), A(e);
251
260
  }
252
261
  }
253
262
  function p(t, n, i, o) {
@@ -277,17 +286,17 @@ function M(e = () => ({}), t = () => ({})) {
277
286
  }
278
287
  //#endregion
279
288
  //#region src/svelte/experienceLoadErrorStyles.ts
280
- var N = "liforma-experience-load-error-styles";
281
- function P() {
289
+ var P = "liforma-experience-load-error-styles";
290
+ function F() {
282
291
  if (typeof document > "u" || document.getElementById("liforma-experience-load-error-styles")) return;
283
292
  let e = document.createElement("style");
284
- e.id = N, e.textContent = F, document.head.append(e);
293
+ e.id = P, e.textContent = I, document.head.append(e);
285
294
  }
286
- var F = "\n .liforma-loading-screen {\n inset: 0;\n z-index: 20;\n box-sizing: border-box;\n overflow-x: clip;\n width: 100%;\n height: 100%;\n max-width: 100vw;\n background:\n radial-gradient(circle at 50% 60%, rgba(79, 126, 196, 0.18), transparent 38%),\n #030508;\n font-family: system-ui, -apple-system, sans-serif;\n color: #e8f0ff;\n text-align: center;\n }\n .liforma-loading-screen-absolute {\n position: absolute;\n }\n .liforma-loading-card {\n position: absolute;\n left: 50%;\n top: 60%;\n transform: translate(-50%, -50%);\n width: min(22rem, calc(100% - 2.5rem));\n max-width: calc(100% - max(1.25rem, env(safe-area-inset-left, 0px)) - max(1.25rem, env(safe-area-inset-right, 0px)));\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n box-shadow: none;\n }\n .liforma-loading-card-error {\n display: block;\n text-align: center;\n padding: 1rem 1.05rem;\n border-radius: 14px;\n border: 1px solid rgba(255, 154, 154, 0.28);\n background:\n linear-gradient(180deg, rgba(21, 29, 42, 0.92), rgba(9, 13, 20, 0.92));\n }\n .liforma-loading-kicker {\n margin: 0 0 0.18rem;\n color: #8ba4c5;\n font-size: 0.68rem;\n font-weight: 700;\n text-transform: uppercase;\n letter-spacing: 0.08em;\n }\n .liforma-loading-error {\n margin: 0;\n max-width: 28rem;\n color: #ffb4b4;\n font-size: 0.92rem;\n line-height: 1.4;\n }\n .liforma-loading-error-title {\n margin: 0;\n color: #f6ebe8;\n font-size: 0.98rem;\n font-weight: 650;\n line-height: 1.35;\n }\n .liforma-loading-error-advanced {\n margin: 0.85rem 0 0;\n padding: 0;\n border: 0;\n background: transparent;\n color: #9eb7d8;\n font: inherit;\n font-size: 0.78rem;\n font-weight: 650;\n letter-spacing: 0.02em;\n text-decoration: underline;\n text-underline-offset: 0.18em;\n cursor: pointer;\n }\n .liforma-loading-error-advanced:hover,\n .liforma-loading-error-advanced:focus-visible {\n color: #d7e6ff;\n outline: none;\n }\n .liforma-loading-error-detail {\n margin: 0.7rem 0 0;\n padding: 0.65rem 0.7rem;\n border-radius: 10px;\n border: 1px solid rgba(158, 191, 255, 0.16);\n background: rgba(3, 5, 8, 0.45);\n color: #c6d4e8;\n font-size: 0.78rem;\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n line-height: 1.4;\n text-align: left;\n word-break: break-word;\n }\n .liforma-loading-error-detail[hidden] {\n display: none;\n }\n";
295
+ var I = "\n .liforma-loading-screen {\n inset: 0;\n z-index: 20;\n box-sizing: border-box;\n overflow-x: clip;\n width: 100%;\n height: 100%;\n max-width: 100vw;\n background:\n radial-gradient(circle at 50% 60%, rgba(79, 126, 196, 0.18), transparent 38%),\n #030508;\n font-family: system-ui, -apple-system, sans-serif;\n color: #e8f0ff;\n text-align: center;\n }\n .liforma-loading-screen-absolute {\n position: absolute;\n }\n .liforma-loading-card {\n position: absolute;\n left: 50%;\n top: 60%;\n transform: translate(-50%, -50%);\n width: min(22rem, calc(100% - 2.5rem));\n max-width: calc(100% - max(1.25rem, env(safe-area-inset-left, 0px)) - max(1.25rem, env(safe-area-inset-right, 0px)));\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n box-shadow: none;\n }\n .liforma-loading-card-error {\n display: block;\n text-align: center;\n padding: 1rem 1.05rem;\n border-radius: 14px;\n border: 1px solid rgba(255, 154, 154, 0.28);\n background:\n linear-gradient(180deg, rgba(21, 29, 42, 0.92), rgba(9, 13, 20, 0.92));\n }\n .liforma-loading-kicker {\n margin: 0 0 0.18rem;\n color: #8ba4c5;\n font-size: 0.68rem;\n font-weight: 700;\n text-transform: uppercase;\n letter-spacing: 0.08em;\n }\n .liforma-loading-error {\n margin: 0;\n max-width: 28rem;\n color: #ffb4b4;\n font-size: 0.92rem;\n line-height: 1.4;\n }\n .liforma-loading-error-title {\n margin: 0;\n color: #f6ebe8;\n font-size: 0.98rem;\n font-weight: 650;\n line-height: 1.35;\n }\n .liforma-loading-error-advanced {\n margin: 0.85rem 0 0;\n padding: 0;\n border: 0;\n background: transparent;\n color: #9eb7d8;\n font: inherit;\n font-size: 0.78rem;\n font-weight: 650;\n letter-spacing: 0.02em;\n text-decoration: underline;\n text-underline-offset: 0.18em;\n cursor: pointer;\n }\n .liforma-loading-error-advanced:hover,\n .liforma-loading-error-advanced:focus-visible {\n color: #d7e6ff;\n outline: none;\n }\n .liforma-loading-error-detail {\n margin: 0.7rem 0 0;\n padding: 0.65rem 0.7rem;\n border-radius: 10px;\n border: 1px solid rgba(158, 191, 255, 0.16);\n background: rgba(3, 5, 8, 0.45);\n color: #c6d4e8;\n font-size: 0.78rem;\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n line-height: 1.4;\n text-align: left;\n word-break: break-word;\n }\n .liforma-loading-error-detail[hidden] {\n display: none;\n }\n";
287
296
  //#endregion
288
297
  //#region src/svelte/experienceLoadErrorOverlay.ts
289
- function te(e, t) {
290
- P();
298
+ function ee(e, t) {
299
+ F();
291
300
  let n = t, r = !1, i = document.createElement("div");
292
301
  i.className = "liforma-loading-screen liforma-loading-screen-absolute", i.setAttribute("role", "alert"), i.setAttribute("aria-live", "assertive");
293
302
  let a = document.createElement("div");
@@ -317,97 +326,98 @@ function te(e, t) {
317
326
  }
318
327
  //#endregion
319
328
  //#region src/react/Experience.tsx
320
- var ne = e(function(e, a) {
321
- let { returnUrl: c, fit: l, startButton: u, showFeedback: p, closeButton: m, onReady: h, onStarted: g, onUserTranscript: y, onUserSpeechStarted: b, onUserSpeechEnded: x, onCharacterSpeechStarted: S, onCharacterSpeechEnded: ee, onCharacterFocusChanged: C, onConversationUpdate: w, onMessage: T, onListeningState: O, onActivityChange: k, onFeedback: A, onFeedbackFailed: j, onConversationProcessorError: N, onPlayerStatusChange: P, onStateUpdate: F, onClose: ne, onError: re } = e, I = o({}), ie = o({
329
+ var te = e(function(e, a) {
330
+ let { returnUrl: c, fit: l, startButton: u, showFeedback: p, closeButton: m, onReady: h, onStarted: g, onUserTranscript: y, onUserSpeechStarted: b, onUserSpeechEnded: x, onCharacterSpeechStarted: S, onCharacterSpeechEnded: C, onCharacterFocusChanged: w, onConversationUpdate: T, onMessage: E, onListeningState: k, onActivityChange: A, onFeedback: j, onFeedbackFailed: M, onConversationProcessorError: P, onPlayerStatusChange: F, onStateUpdate: I, onClose: te, onError: ne } = e, L = o({}), re = o({
322
331
  fit: l,
323
332
  startButton: u,
324
333
  showFeedback: p,
325
334
  closeButton: m,
326
335
  returnUrl: c
327
- }), L = o(M(() => I.current, () => ie.current)), R = o(null), [z, B] = s(!1), [V, ae] = s(null), oe = o(null), se = o(null), ce = v(e);
328
- ie.current = {
336
+ }), R = o(N(() => L.current, () => re.current)), z = o(null), [ie, ae] = s(!1), [B, V] = s(null), oe = o(null), se = o(null), ce = v(e);
337
+ re.current = {
329
338
  fit: l,
330
339
  startButton: u,
331
340
  showFeedback: p,
332
341
  closeButton: m,
333
342
  returnUrl: c
334
- }, I.current = {
343
+ }, L.current = {
335
344
  onReady: h,
336
345
  onStarted: g,
337
346
  onUserTranscript: y,
338
347
  onUserSpeechStarted: b,
339
348
  onUserSpeechEnded: x,
340
349
  onCharacterSpeechStarted: S,
341
- onCharacterSpeechEnded: ee,
342
- onCharacterFocusChanged: C,
343
- onConversationUpdate: w,
344
- onMessage: T,
345
- onListeningState: O,
346
- onActivityChange: k,
347
- onFeedback: A,
348
- onFeedbackFailed: j,
349
- onConversationProcessorError: N,
350
- onPlayerStatusChange: P,
351
- onStateUpdate: F,
352
- onClose: ne,
353
- onError: re
350
+ onCharacterSpeechEnded: C,
351
+ onCharacterFocusChanged: w,
352
+ onConversationUpdate: T,
353
+ onMessage: E,
354
+ onListeningState: k,
355
+ onActivityChange: A,
356
+ onFeedback: j,
357
+ onFeedbackFailed: M,
358
+ onConversationProcessorError: P,
359
+ onPlayerStatusChange: F,
360
+ onStateUpdate: I,
361
+ onClose: te,
362
+ onError: ne
354
363
  };
355
364
  let H = t((e) => {
356
- oe.current = e, B(e !== null);
365
+ oe.current = e, ae(e !== null);
357
366
  }, []);
358
367
  return r(a, () => ({
359
368
  ready: () => {
360
- let e = R.current;
361
- return !e || e.destroyed ? Promise.reject(E()) : e.ready.promise;
369
+ let e = z.current;
370
+ return !e || e.destroyed ? Promise.reject(D()) : e.ready.promise;
362
371
  },
363
372
  started: () => {
364
- let e = R.current;
365
- return !e || e.destroyed ? Promise.reject(E()) : e.started.promise;
373
+ let e = z.current;
374
+ return !e || e.destroyed ? Promise.reject(D()) : e.started.promise;
366
375
  },
367
376
  speech: {
368
- speak: (e) => L.current.withSession((t) => t.speech.speak(e)),
369
- play: (e) => L.current.withSession((t) => t.speech.play(e)),
377
+ speak: (e) => R.current.withSession((t) => t.speech.speak(e)),
378
+ play: (e) => R.current.withSession((t) => t.speech.play(e)),
370
379
  createUtterance: (e) => {
371
- let t = L.current.getActiveInstance();
380
+ let t = R.current.getActiveInstance();
372
381
  if (!t) throw Error("Session has not started. Wait for the player start button and the started event before using speech APIs.");
373
382
  return t.speech.createUtterance(e);
374
383
  },
375
- interrupt: (e) => L.current.withSession((t) => t.speech.interrupt(e))
384
+ interrupt: (e) => R.current.withSession((t) => t.speech.interrupt(e))
376
385
  },
377
- startListening: () => L.current.withSession((e) => e.startListening()),
378
- stopListening: () => L.current.withSession((e) => e.stopListening()),
379
- listenOnce: (e) => L.current.withSession((t) => t.listenOnce(e)),
380
- getSession: () => L.current.getActiveInstance()?.getSession() ?? null,
381
- getManifest: () => L.current.getActiveInstance()?.getManifest() ?? null,
382
- getConversation: () => L.current.getActiveInstance()?.getConversation() ?? [],
383
- focusCharacter: (e) => L.current.withSession((t) => t.focusCharacter(e)),
384
- setFit: (e) => L.current.withSession((t) => t.setFit(e)),
385
- end: () => L.current.withSession((e) => e.end())
386
+ startListening: () => R.current.withSession((e) => e.startListening()),
387
+ stopListening: () => R.current.withSession((e) => e.stopListening()),
388
+ listenOnce: (e) => R.current.withSession((t) => t.listenOnce(e)),
389
+ getSession: () => R.current.getActiveInstance()?.getSession() ?? null,
390
+ getManifest: () => R.current.getActiveInstance()?.getManifest() ?? null,
391
+ getConversation: () => R.current.getActiveInstance()?.getConversation() ?? [],
392
+ focusCharacter: (e) => R.current.withSession((t) => t.focusCharacter(e)),
393
+ setFit: (e) => R.current.withSession((t) => t.setFit(e)),
394
+ conversion: (e) => R.current.withSession((t) => t.conversion(e)),
395
+ end: () => R.current.withSession((e) => e.end())
386
396
  }), []), i(() => {
387
- if (!z || !oe.current) return;
388
- let t = oe.current, n = L.current, r;
397
+ if (!ie || !oe.current) return;
398
+ let t = oe.current, n = R.current, r;
389
399
  try {
390
400
  r = { options: _(e) };
391
401
  } catch (e) {
392
- r = { error: D(e) };
402
+ r = { error: O(e) };
393
403
  }
394
- let i = n.activateGeneration(t, r, c, ae);
395
- return R.current = i, () => {
396
- n.cancelGeneration(i), R.current === i && (R.current = null);
404
+ let i = n.activateGeneration(t, r, c, V);
405
+ return z.current = i, () => {
406
+ n.cancelGeneration(i), z.current === i && (z.current = null);
397
407
  };
398
408
  }, [
399
- z,
409
+ ie,
400
410
  ce,
401
411
  c
402
412
  ]), n(() => {
403
- let e = L.current.getActiveInstance();
413
+ let e = R.current.getActiveInstance();
404
414
  e && e.setFit(l ?? "full");
405
415
  }, [l]), n(() => {
406
416
  let e = se.current;
407
- if (!e || (e.replaceChildren(), !V)) return;
408
- let t = te(e, V);
417
+ if (!e || (e.replaceChildren(), !B)) return;
418
+ let t = ee(e, B);
409
419
  return () => t.remove();
410
- }, [V]), /* @__PURE__ */ f("div", {
420
+ }, [B]), /* @__PURE__ */ f("div", {
411
421
  className: "liforma-experience-shell",
412
422
  style: {
413
423
  position: "relative",
@@ -418,12 +428,12 @@ var ne = e(function(e, a) {
418
428
  children: [/* @__PURE__ */ d("div", {
419
429
  ref: se,
420
430
  className: "liforma-experience-error-host",
421
- "aria-hidden": V ? void 0 : !0,
431
+ "aria-hidden": B ? void 0 : !0,
422
432
  style: {
423
433
  position: "absolute",
424
434
  inset: 0,
425
435
  zIndex: 20,
426
- pointerEvents: V ? "auto" : "none"
436
+ pointerEvents: B ? "auto" : "none"
427
437
  }
428
438
  }), /* @__PURE__ */ d("div", {
429
439
  ref: H,
@@ -438,32 +448,32 @@ var ne = e(function(e, a) {
438
448
  });
439
449
  //#endregion
440
450
  //#region src/thumbnail/types.ts
441
- function re(e) {
451
+ function ne(e) {
442
452
  return e === "face" ? "liforma-et--fit-face" : e === "medium" ? "liforma-et--fit-medium" : "";
443
453
  }
444
454
  //#endregion
445
455
  //#region src/thumbnail/toGalleryThumbUrl.ts
446
- var I = /(\/avatars\/[^/]+\/)(\d+)(\/)/i, ie = /_CH(\.webp)/i, L = /(-)(\d+x\d+)(\.webp)(\?|$)/i;
447
- function R(e) {
456
+ var L = /(\/avatars\/[^/]+\/)(\d+)(\/)/i, re = /_CH(\.webp)/i, R = /(-)(\d+x\d+)(\.webp)(\?|$)/i;
457
+ function z(e) {
448
458
  let t = e.trim();
449
459
  if (!t) return t;
450
- let n = t.replace(I, (e, t, n, r) => n === "256" ? `${t}${n}${r}` : `${t}256${r}`);
451
- return n = n.replace(ie, "_neutral$1"), n = n.replace(L, (e, t, n, r, i) => n === "256x256" ? `${t}${n}${r}${i}` : `${t}256x256${r}${i}`), n;
460
+ let n = t.replace(L, (e, t, n, r) => n === "256" ? `${t}${n}${r}` : `${t}256${r}`);
461
+ return n = n.replace(re, "_neutral$1"), n = n.replace(R, (e, t, n, r, i) => n === "256x256" ? `${t}${n}${r}${i}` : `${t}256x256${r}${i}`), n;
452
462
  }
453
- function z(e) {
463
+ function ie(e) {
454
464
  let t = e.avatarImage?.trim() || e.galleryThumb?.avatarImage?.trim() || "";
455
465
  if (!t) return null;
456
466
  let n = e.backgroundImage?.trim() || e.galleryThumb?.backgroundImage?.trim() || "", r = e.foregroundImage?.trim() || e.galleryThumb?.foregroundImage?.trim() || "", i = e.fallbackImage?.trim() || "";
457
467
  return {
458
- avatarImage: R(t),
459
- ...n ? { backgroundImage: R(n) } : {},
460
- ...r ? { foregroundImage: R(r) } : {},
461
- ...i ? { fallbackImage: R(i) } : {}
468
+ avatarImage: z(t),
469
+ ...n ? { backgroundImage: z(n) } : {},
470
+ ...r ? { foregroundImage: z(r) } : {},
471
+ ...i ? { fallbackImage: z(i) } : {}
462
472
  };
463
473
  }
464
474
  //#endregion
465
475
  //#region src/shims/localStack.ts
466
- function B() {
476
+ function ae() {
467
477
  if (globalThis.__LIFORMA_STACK === "local") return !0;
468
478
  if (typeof location > "u") return !1;
469
479
  try {
@@ -474,13 +484,13 @@ function B() {
474
484
  }
475
485
  //#endregion
476
486
  //#region src/thumbnail/hostedLaunchUrl.ts
477
- var V = "https://player.liforma.ai", ae = "http://localhost:3002";
487
+ var B = "https://player.liforma.ai", V = "http://localhost:3002";
478
488
  function oe(e) {
479
489
  return e.href?.trim() ? "anchor" : e.hasClickHandler ? "button" : e.experienceId?.trim() ? "anchor" : "presentational";
480
490
  }
481
491
  function se(e) {
482
492
  let t = e?.trim();
483
- return t ? t.replace(/\/$/, "") : B() ? ae : V;
493
+ return t ? t.replace(/\/$/, "") : ae() ? V : B;
484
494
  }
485
495
  function ce(e) {
486
496
  let t = e.experienceId.trim(), n = se(e.playerBaseUrl), r = new URL(`${n}/${encodeURIComponent(t)}`), i = e.returnUrl?.trim();
@@ -661,23 +671,23 @@ function ke(e, t) {
661
671
  return `${e} liforma-et__media${t ? " liforma-et__media--ready" : ""}`;
662
672
  }
663
673
  function Ae(e) {
664
- let { galleryThumb: t, avatarImage: r, backgroundImage: i, foregroundImage: c, alt: l, experienceId: p, href: m, target: h, rel: g, onClick: _, returnUrl: v, playerBaseUrl: y, parallax: b = !0, fit: x = "full", lazy: S = !0, className: ee = "", fallbackImage: C } = e, w = a(() => z({
674
+ let { galleryThumb: t, avatarImage: r, backgroundImage: i, foregroundImage: c, alt: l, experienceId: p, href: m, target: h, rel: g, onClick: _, returnUrl: v, playerBaseUrl: y, parallax: b = !0, fit: x = "full", lazy: S = !0, className: C = "", fallbackImage: w } = e, T = a(() => ie({
665
675
  galleryThumb: t,
666
676
  avatarImage: r,
667
677
  backgroundImage: i,
668
678
  foregroundImage: c,
669
- fallbackImage: C
679
+ fallbackImage: w
670
680
  }), [
671
681
  t,
672
682
  r,
673
683
  i,
674
684
  c,
675
- C
676
- ]), T = oe({
685
+ w
686
+ ]), E = oe({
677
687
  href: m,
678
688
  hasClickHandler: typeof _ == "function",
679
689
  experienceId: p
680
- }), E = T === "anchor" && !m?.trim() && !!p?.trim(), D = !!w?.backgroundImage, O = b !== !1, k = o(null), A = o(!1), [j, M] = s(!S), [N, P] = s(!1), [F, te] = s(!1), [ne, I] = s(0), [ie, L] = s(0), [R, B] = s(!1), [V, ae] = s(!1), [se, ce] = s(!1), [le, U] = s(!1), [ue, de] = s(), W = w ? R && w.fallbackImage ? w.fallbackImage : w.avatarImage : "";
690
+ }), D = E === "anchor" && !m?.trim() && !!p?.trim(), O = !!T?.backgroundImage, k = b !== !1, A = o(null), j = o(!1), [M, N] = s(!S), [P, F] = s(!1), [I, ee] = s(!1), [te, L] = s(0), [re, R] = s(0), [z, ae] = s(!1), [B, V] = s(!1), [se, ce] = s(!1), [le, U] = s(!1), [ue, de] = s(), W = T ? z && T.fallbackImage ? T.fallbackImage : T.avatarImage : "";
681
691
  n(() => {
682
692
  Oe(Ee);
683
693
  }, []), n(() => {
@@ -686,66 +696,66 @@ function Ae(e) {
686
696
  experienceId: p,
687
697
  returnUrl: v,
688
698
  playerBaseUrl: y,
689
- useCurrentPageAsReturnUrl: E && !v?.trim()
699
+ useCurrentPageAsReturnUrl: D && !v?.trim()
690
700
  }));
691
701
  }, [
692
702
  m,
693
703
  p,
694
704
  v,
695
705
  y,
696
- E
706
+ D
697
707
  ]), n(() => {
698
- ae(!1), ce(!1), U(!1), B(!1);
708
+ V(!1), ce(!1), U(!1), ae(!1);
699
709
  }, [
700
- w?.backgroundImage,
701
- w?.foregroundImage,
710
+ T?.backgroundImage,
711
+ T?.foregroundImage,
702
712
  W
703
713
  ]), n(() => {
704
- let e = k.current;
714
+ let e = A.current;
705
715
  if (e) {
706
716
  if (!S) {
707
- M(!0);
717
+ N(!0);
708
718
  return;
709
719
  }
710
720
  return _e(e, { onVisibleChange: (e) => {
711
- e && M(!0);
721
+ e && N(!0);
712
722
  } });
713
723
  }
714
724
  }, [
715
725
  S,
716
- w,
717
726
  T,
727
+ E,
718
728
  ue
719
729
  ]), n(() => {
720
- let e = k.current;
721
- if (!(!e || !O)) return we(e, {
730
+ let e = A.current;
731
+ if (!(!e || !k)) return we(e, {
722
732
  onParallax: (e) => {
723
- te(!0), A.current || (I(e), L(0));
733
+ ee(!0), j.current || (L(e), R(0));
724
734
  },
725
- pointerActive: () => A.current
735
+ pointerActive: () => j.current
726
736
  });
727
737
  }, [
728
- O,
729
- w,
738
+ k,
730
739
  T,
740
+ E,
731
741
  ue
732
742
  ]);
733
743
  let fe = (e) => {
734
- if (!O || F) return;
744
+ if (!k || I) return;
735
745
  let t = e.currentTarget.getBoundingClientRect();
736
- t.width <= 0 || t.height <= 0 || (I(((e.clientX - t.left) / t.width - .5) * 2), L(((e.clientY - t.top) / t.height - .5) * 2));
746
+ t.width <= 0 || t.height <= 0 || (L(((e.clientX - t.left) / t.width - .5) * 2), R(((e.clientY - t.top) / t.height - .5) * 2));
737
747
  }, pe = (e) => {
738
- let t = A.current;
739
- A.current = !1, P(!1), F && t ? (I(ye(e.getBoundingClientRect(), window.innerHeight)), L(0)) : F || (I(0), L(0));
748
+ let t = j.current;
749
+ j.current = !1, F(!1), I && t ? (L(ye(e.getBoundingClientRect(), window.innerHeight)), R(0)) : I || (L(0), R(0));
740
750
  }, me = (e) => {
741
- if (!O) return;
742
- A.current = !0, e.pointerType === "mouse" && P(!0);
751
+ if (!k) return;
752
+ j.current = !0, e.pointerType === "mouse" && F(!0);
743
753
  let t = e.currentTarget, n = () => {
744
754
  pe(t), window.removeEventListener("pointerup", n), window.removeEventListener("pointercancel", n);
745
755
  };
746
756
  window.addEventListener("pointerup", n), window.addEventListener("pointercancel", n);
747
757
  }, he = (e) => {
748
- if (_?.(e), !e.defaultPrevented && E && !v?.trim()) {
758
+ if (_?.(e), !e.defaultPrevented && D && !v?.trim()) {
749
759
  let t = H({
750
760
  experienceId: p,
751
761
  playerBaseUrl: y,
@@ -754,19 +764,19 @@ function Ae(e) {
754
764
  t && e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && (e.preventDefault(), window.location.assign(t));
755
765
  }
756
766
  };
757
- if (!w) return null;
758
- let ge = O && (N || F), ve = j && (se || V || le), G = [
767
+ if (!T) return null;
768
+ let ge = k && (P || I), ve = M && (se || B || le), G = [
759
769
  "liforma-et",
760
- D ? "liforma-et--scene" : "",
761
- re(x),
770
+ O ? "liforma-et--scene" : "",
771
+ ne(x),
762
772
  ge ? "liforma-et--parallax" : "",
763
- F ? "liforma-et--scroll-parallax" : "",
764
- j && !ve ? "liforma-et--loading" : "",
773
+ I ? "liforma-et--scroll-parallax" : "",
774
+ M && !ve ? "liforma-et--loading" : "",
765
775
  ve ? "liforma-et--revealed" : "",
766
- ee
776
+ C
767
777
  ].filter(Boolean).join(" "), be = {
768
- "--liforma-et-parallax-x": ne,
769
- "--liforma-et-parallax-y": ie
778
+ "--liforma-et-parallax-x": te,
779
+ "--liforma-et-parallax-y": re
770
780
  }, K = (e, t) => {
771
781
  e.complete && t(!0);
772
782
  }, xe = /* @__PURE__ */ f(u, { children: [
@@ -774,18 +784,18 @@ function Ae(e) {
774
784
  className: "liforma-et__placeholder",
775
785
  "aria-hidden": "true"
776
786
  }),
777
- j && w.backgroundImage ? /* @__PURE__ */ d("img", {
778
- className: ke("liforma-et__background", V),
779
- src: w.backgroundImage,
787
+ M && T.backgroundImage ? /* @__PURE__ */ d("img", {
788
+ className: ke("liforma-et__background", B),
789
+ src: T.backgroundImage,
780
790
  alt: "",
781
791
  decoding: "async",
782
792
  ref: (e) => {
783
- e && K(e, ae);
793
+ e && K(e, V);
784
794
  },
785
- onLoad: () => ae(!0),
786
- onError: () => ae(!0)
795
+ onLoad: () => V(!0),
796
+ onError: () => V(!0)
787
797
  }) : null,
788
- j && W ? /* @__PURE__ */ d("img", {
798
+ M && W ? /* @__PURE__ */ d("img", {
789
799
  className: ke("liforma-et__avatar", se),
790
800
  src: W,
791
801
  alt: "",
@@ -795,12 +805,12 @@ function Ae(e) {
795
805
  },
796
806
  onLoad: () => ce(!0),
797
807
  onError: () => {
798
- w.fallbackImage ? B(!0) : ce(!0);
808
+ T.fallbackImage ? ae(!0) : ce(!0);
799
809
  }
800
810
  }) : null,
801
- j && w.foregroundImage ? /* @__PURE__ */ d("img", {
811
+ M && T.foregroundImage ? /* @__PURE__ */ d("img", {
802
812
  className: ke("liforma-et__foreground", le),
803
- src: w.foregroundImage,
813
+ src: T.foregroundImage,
804
814
  alt: "",
805
815
  decoding: "async",
806
816
  ref: (e) => {
@@ -814,16 +824,16 @@ function Ae(e) {
814
824
  onPointerUp: (e) => pe(e.currentTarget),
815
825
  onPointerCancel: (e) => pe(e.currentTarget),
816
826
  onPointerEnter: (e) => {
817
- O && e.pointerType === "mouse" && P(!0);
827
+ k && e.pointerType === "mouse" && F(!0);
818
828
  },
819
829
  onPointerMove: fe,
820
830
  onPointerLeave: () => {
821
- A.current || (P(!1), F || (I(0), L(0)));
831
+ j.current || (F(!1), I || (L(0), R(0)));
822
832
  }
823
833
  }, q = (e) => {
824
- k.current = e;
834
+ A.current = e;
825
835
  };
826
- return T === "anchor" && ue ? /* @__PURE__ */ d("a", {
836
+ return E === "anchor" && ue ? /* @__PURE__ */ d("a", {
827
837
  ref: q,
828
838
  className: G,
829
839
  style: be,
@@ -834,7 +844,7 @@ function Ae(e) {
834
844
  onClick: he,
835
845
  ...Se,
836
846
  children: xe
837
- }) : T === "button" ? /* @__PURE__ */ d("button", {
847
+ }) : E === "button" ? /* @__PURE__ */ d("button", {
838
848
  type: "button",
839
849
  ref: q,
840
850
  className: G,
@@ -878,7 +888,7 @@ function Ie() {
878
888
  return t ? t.replace(/\/$/, "") : null;
879
889
  }
880
890
  function Le() {
881
- return Ie() || (B() ? Fe : Pe);
891
+ return Ie() || (ae() ? Fe : Pe);
882
892
  }
883
893
  //#endregion
884
894
  //#region src/v2/api/fetchExperiencePreview.ts
@@ -950,20 +960,58 @@ function Ve(e, t, n) {
950
960
  });
951
961
  }
952
962
  //#endregion
963
+ //#region src/v2/api/captureAttribution.ts
964
+ var He = 128, Ue = /[\u0000-\u001f\u007f]/g;
965
+ function Y(e) {
966
+ if (!e) return;
967
+ let t = e.replace(Ue, "").trim();
968
+ if (t) return t.slice(0, He);
969
+ }
970
+ function We(e) {
971
+ let t = new URLSearchParams((e ?? "").startsWith("?") ? (e ?? "").slice(1) : e ?? "");
972
+ return {
973
+ ...Y(t.get("utm_source")) ? { utmSource: Y(t.get("utm_source")) } : {},
974
+ ...Y(t.get("utm_medium")) ? { utmMedium: Y(t.get("utm_medium")) } : {},
975
+ ...Y(t.get("utm_campaign")) ? { utmCampaign: Y(t.get("utm_campaign")) } : {},
976
+ ...Y(t.get("utm_content")) ? { utmContent: Y(t.get("utm_content")) } : {},
977
+ ...Y(t.get("utm_term")) ? { utmTerm: Y(t.get("utm_term")) } : {}
978
+ };
979
+ }
980
+ function Ge(e) {
981
+ if (e === !1) return;
982
+ if (e && typeof e == "object") {
983
+ let t = {
984
+ ...Y(e.utmSource) ? { utmSource: Y(e.utmSource) } : {},
985
+ ...Y(e.utmMedium) ? { utmMedium: Y(e.utmMedium) } : {},
986
+ ...Y(e.utmCampaign) ? { utmCampaign: Y(e.utmCampaign) } : {},
987
+ ...Y(e.utmContent) ? { utmContent: Y(e.utmContent) } : {},
988
+ ...Y(e.utmTerm) ? { utmTerm: Y(e.utmTerm) } : {},
989
+ ...Y(e.referrer) ? { referrer: Y(e.referrer) } : {}
990
+ };
991
+ return Object.keys(t).length ? t : void 0;
992
+ }
993
+ if (typeof window > "u") return;
994
+ let t = We(window.location?.search), n = Y(document.referrer || void 0), r = {
995
+ ...t,
996
+ ...n ? { referrer: n } : {}
997
+ };
998
+ return Object.keys(r).length ? r : void 0;
999
+ }
1000
+ //#endregion
953
1001
  //#region src/v2/api/sessionEndpointRequest.ts
954
- function He(e) {
1002
+ function Ke(e) {
955
1003
  let t = e.locale?.trim();
956
1004
  if (t) return t;
957
1005
  let n = e.language?.trim();
958
1006
  if (n) return n;
959
1007
  if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
960
1008
  }
961
- function Ue(e) {
1009
+ function qe(e) {
962
1010
  let t = e.secondaryLocale?.trim(), n = e.learningLocale?.trim();
963
1011
  if (t && n && t !== n) throw Error("secondaryLocale and learningLocale disagree; pass only one or make them equal.");
964
1012
  return t || n || void 0;
965
1013
  }
966
- function We(e, t) {
1014
+ function Je(e, t) {
967
1015
  let n = e.trim();
968
1016
  if (!n) throw Error("sessionEndpoint must not be empty.");
969
1017
  if (typeof location > "u") throw Error("sessionEndpoint is only available in a browser.");
@@ -971,7 +1019,7 @@ function We(e, t) {
971
1019
  if (r.origin !== location.origin) throw Error("sessionEndpoint must be same-origin.");
972
1020
  let i = t.experienceId.trim();
973
1021
  if (!i) throw Error("sessionEndpoint requires experienceId.");
974
- let a = He(t), o = Ue(t), s = t.idempotencyKey?.trim();
1022
+ let a = Ke(t), o = qe(t), s = t.idempotencyKey?.trim();
975
1023
  return {
976
1024
  url: r.toString(),
977
1025
  init: {
@@ -988,23 +1036,27 @@ function We(e, t) {
988
1036
  ...o ? { secondaryLocale: o } : {},
989
1037
  ...t.mode ? { mode: t.mode } : {},
990
1038
  ...t.speechInputMode ? { speechInputMode: t.speechInputMode } : {},
991
- ...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly }
1039
+ ...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
1040
+ ...(() => {
1041
+ let e = Ge(t.attribution);
1042
+ return e ? { attribution: e } : {};
1043
+ })()
992
1044
  })
993
1045
  }
994
1046
  };
995
1047
  }
996
1048
  //#endregion
997
1049
  //#region src/v2/types/sessionLaunch.ts
998
- function Y(e) {
1050
+ function Ye(e) {
999
1051
  return !!e && typeof e == "object" && !Array.isArray(e);
1000
1052
  }
1001
1053
  function X(e) {
1002
1054
  return typeof e == "boolean";
1003
1055
  }
1004
- function Ge(e) {
1005
- if (!Y(e)) return null;
1056
+ function Xe(e) {
1057
+ if (!Ye(e)) return null;
1006
1058
  let t = e.speech, n = e.conversation, r = e.avatar, i = e.tools;
1007
- return !Y(t) || !Y(n) || !Y(r) || !Y(i) || !X(t.input) || !X(t.output) || !X(t.externalAudio) || !X(n.managed) || !X(r.enabled) || !X(i.enabled) ? null : {
1059
+ return !Ye(t) || !Ye(n) || !Ye(r) || !Ye(i) || !X(t.input) || !X(t.output) || !X(t.externalAudio) || !X(n.managed) || !X(r.enabled) || !X(i.enabled) ? null : {
1008
1060
  speech: {
1009
1061
  input: t.input,
1010
1062
  output: t.output,
@@ -1015,8 +1067,8 @@ function Ge(e) {
1015
1067
  tools: { enabled: i.enabled }
1016
1068
  };
1017
1069
  }
1018
- function Ke(e) {
1019
- return !Y(e) || !X(e.avatar) || !X(e.speechInput) || !X(e.speechOutput) || !X(e.tools) || !X(e.externalAudio) ? null : {
1070
+ function Ze(e) {
1071
+ return !Ye(e) || !X(e.avatar) || !X(e.speechInput) || !X(e.speechOutput) || !X(e.tools) || !X(e.externalAudio) ? null : {
1020
1072
  speech: {
1021
1073
  input: e.speechInput,
1022
1074
  output: e.speechOutput,
@@ -1027,12 +1079,12 @@ function Ke(e) {
1027
1079
  tools: { enabled: e.tools }
1028
1080
  };
1029
1081
  }
1030
- function qe(e) {
1031
- return Ge(e) ?? Ke(e);
1082
+ function Qe(e) {
1083
+ return Xe(e) ?? Ze(e);
1032
1084
  }
1033
- function Je(e) {
1034
- if (!Y(e)) throw Error("Session Launch response is missing session.");
1035
- 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 = qe(e.capabilities), l = Ye(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;
1085
+ function $e(e) {
1086
+ if (!Ye(e)) throw Error("Session Launch response is missing session.");
1087
+ 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 = Qe(e.capabilities), l = et(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;
1036
1088
  if (!t || !n || !r || !i || !a || !s || !c) throw Error("Session Launch response has an invalid session object.");
1037
1089
  return {
1038
1090
  id: t,
@@ -1048,11 +1100,11 @@ function Je(e) {
1048
1100
  ...d ? { createdAt: d } : {}
1049
1101
  };
1050
1102
  }
1051
- function Ye(e) {
1103
+ function et(e) {
1052
1104
  if (!Array.isArray(e) || e.length === 0) return;
1053
1105
  let t = [];
1054
1106
  for (let n of e) {
1055
- if (!Y(n)) continue;
1107
+ if (!Ye(n)) continue;
1056
1108
  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() : "";
1057
1109
  !e || !r || !i || n.reason !== "voice_unsupported" || t.push({
1058
1110
  axis: e,
@@ -1063,35 +1115,35 @@ function Ye(e) {
1063
1115
  }
1064
1116
  return t.length > 0 ? t : void 0;
1065
1117
  }
1066
- function Xe(e) {
1118
+ function tt(e) {
1067
1119
  let t = e.localeVoiceFallbacks;
1068
1120
  if (t?.length) for (let e of t) {
1069
1121
  let t = e.axis === "secondaryLocale" ? "secondaryLocale" : "locale";
1070
1122
  console.warn(`[liforma] Session ${t} fell back to ${e.resolved} because the voice does not support ${e.requested}.`);
1071
1123
  }
1072
1124
  }
1073
- function Ze(e) {
1074
- if (!Y(e)) throw Error("Session Launch response must be a JSON object.");
1125
+ function nt(e) {
1126
+ if (!Ye(e)) throw Error("Session Launch response must be a JSON object.");
1075
1127
  let t = typeof e.launch == "string" ? e.launch.trim() : "";
1076
1128
  if (!t) throw Error("Session Launch response is missing launch.");
1077
- let n = Je(e.session);
1078
- return Xe(n), {
1129
+ let n = $e(e.session);
1130
+ return tt(n), {
1079
1131
  session: n,
1080
1132
  launch: t
1081
1133
  };
1082
1134
  }
1083
1135
  //#endregion
1084
1136
  //#region src/v2/api/mintPublicSession.ts
1085
- function Qe() {
1137
+ function rt() {
1086
1138
  try {
1087
1139
  if (typeof globalThis.location?.origin == "string" && globalThis.location.origin) return globalThis.location.origin;
1088
1140
  } catch {}
1089
1141
  }
1090
- function $e(e) {
1142
+ function it(e) {
1091
1143
  return e ? e.trim().toUpperCase().replace(/-/g, "_") : "";
1092
1144
  }
1093
- function et(e, t) {
1094
- let n = Qe(), r = $e(t.code), i = t.message.trim(), a = t.details ?? {};
1145
+ function at(e, t) {
1146
+ let n = rt(), r = it(t.code), i = t.message.trim(), a = t.details ?? {};
1095
1147
  if (r === "ORIGIN_NOT_ALLOWED" || /^Origin not allowed/i.test(i) && n) {
1096
1148
  if (i.includes(e) && i.includes("allowed origin")) return t;
1097
1149
  let r = typeof a.origin == "string" && a.origin || n || "(unknown origin)";
@@ -1114,36 +1166,38 @@ function et(e, t) {
1114
1166
  details: a
1115
1167
  }) : t;
1116
1168
  }
1117
- function tt(e) {
1169
+ function ot(e) {
1118
1170
  let t = e?.locale?.trim();
1119
1171
  if (t) return t;
1120
1172
  let n = e?.language?.trim();
1121
1173
  if (n) return n;
1122
1174
  if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
1123
1175
  }
1124
- function nt(e) {
1176
+ function st(e) {
1125
1177
  let t = e?.secondaryLocale?.trim(), n = e?.learningLocale?.trim();
1126
1178
  if (t && n && t !== n) throw new J("secondaryLocale and learningLocale disagree; pass only one or make them equal.", { code: "INVALID_BODY" });
1127
1179
  return t || n || void 0;
1128
1180
  }
1129
- function rt(e, t) {
1130
- let n = { experienceId: e }, r = tt(t);
1181
+ function ct(e, t) {
1182
+ let n = { experienceId: e }, r = ot(t);
1131
1183
  r && (n.locale = r);
1132
- let i = nt(t);
1133
- 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;
1184
+ let i = st(t);
1185
+ i && (n.secondaryLocale = i), t?.mode && (n.mode = t.mode), t?.speechInputMode && (n.speechInputMode = t.speechInputMode), t?.speechOnly !== void 0 && (n.speechOnly = t.speechOnly);
1186
+ let a = Ge(t?.attribution);
1187
+ return a && (n.attribution = a), n;
1134
1188
  }
1135
- async function it(e, t) {
1189
+ async function lt(e, t) {
1136
1190
  let n = Le(), r = t?.idempotencyKey?.trim(), i = await fetch(`${n}/v1/browser-sessions`, {
1137
1191
  method: "POST",
1138
1192
  headers: {
1139
1193
  "Content-Type": "application/json",
1140
1194
  ...r ? { "Idempotency-Key": r } : {}
1141
1195
  },
1142
- body: JSON.stringify(rt(e, t))
1196
+ body: JSON.stringify(ct(e, t))
1143
1197
  });
1144
1198
  if (!i.ok) {
1145
1199
  let t = await i.text();
1146
- throw et(e, Ve(i.status, t, i.headers));
1200
+ throw at(e, Ve(i.status, t, i.headers));
1147
1201
  }
1148
1202
  let a;
1149
1203
  try {
@@ -1155,10 +1209,10 @@ async function it(e, t) {
1155
1209
  requestId: i.headers.get("Liforma-Request-Id") ?? void 0
1156
1210
  });
1157
1211
  }
1158
- return Ze(a);
1212
+ return nt(a);
1159
1213
  }
1160
- async function at(e, t) {
1161
- let n = We(e, t), r = new AbortController(), i = () => r.abort(t.signal?.reason);
1214
+ async function ut(e, t) {
1215
+ let n = Je(e, t), r = new AbortController(), i = () => r.abort(t.signal?.reason);
1162
1216
  t.signal?.aborted ? i() : t.signal?.addEventListener("abort", i, { once: !0 });
1163
1217
  let a = globalThis.setTimeout(() => r.abort(new DOMException("Session endpoint timed out.", "TimeoutError")), t.timeoutMs ?? 3e4), o;
1164
1218
  try {
@@ -1188,14 +1242,14 @@ async function at(e, t) {
1188
1242
  requestId: o.headers.get("Liforma-Request-Id") ?? void 0
1189
1243
  });
1190
1244
  }
1191
- return Ze(s);
1245
+ return nt(s);
1192
1246
  }
1193
1247
  //#endregion
1194
1248
  //#region src/v2/conversationProcessor.ts
1195
- function ot(e) {
1249
+ function dt(e) {
1196
1250
  return typeof e != "object" || !e ? !1 : typeof e[Symbol.asyncIterator] == "function";
1197
1251
  }
1198
- function st(e) {
1252
+ function ft(e) {
1199
1253
  if (typeof e == "string") {
1200
1254
  let t = e.trim();
1201
1255
  if (!t) throw Error("conversationProcessor returned empty text.");
@@ -1209,24 +1263,24 @@ function st(e) {
1209
1263
  ...e.behavior ? { behavior: e.behavior } : {}
1210
1264
  };
1211
1265
  }
1212
- async function ct(e, t) {
1266
+ async function pt(e, t) {
1213
1267
  let n = await e(t);
1214
- return ot(n) ? {
1268
+ return dt(n) ? {
1215
1269
  kind: "stream",
1216
1270
  stream: n
1217
1271
  } : {
1218
1272
  kind: "complete",
1219
- speech: st(n)
1273
+ speech: ft(n)
1220
1274
  };
1221
1275
  }
1222
1276
  //#endregion
1223
1277
  //#region src/v2/embed/playerReachability.ts
1224
- var lt = "3002";
1225
- function ut(e) {
1278
+ var mt = "3002";
1279
+ function ht(e) {
1226
1280
  let t = new URL(e);
1227
- 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 || lt}. 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.`;
1281
+ 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 || mt}. 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.`;
1228
1282
  }
1229
- async function dt(e, t) {
1283
+ async function gt(e, t) {
1230
1284
  try {
1231
1285
  await fetch(e, {
1232
1286
  method: "GET",
@@ -1234,52 +1288,30 @@ async function dt(e, t) {
1234
1288
  signal: AbortSignal.timeout(8e3)
1235
1289
  });
1236
1290
  } catch {
1237
- throw Error(ut(t));
1291
+ throw Error(ht(t));
1238
1292
  }
1239
1293
  }
1240
- function ft(e, t, n, r) {
1294
+ function _t(e, t, n, r) {
1241
1295
  try {
1242
1296
  r && r.length > 0 ? e.postMessage(t, n, r) : e.postMessage(t, n);
1243
1297
  } catch (e) {
1244
- throw e instanceof DOMException && e.name === "SecurityError" ? Error(ut(n), { cause: e }) : e;
1245
- }
1246
- }
1247
- var pt = new Set([1, 2]);
1248
- function mt(e) {
1249
- return typeof e == "number" && pt.has(e);
1250
- }
1251
- var ht = new Set([
1252
- "close",
1253
- "stateUpdate",
1254
- "commandResult",
1255
- "userTranscript",
1256
- "characterSpeechStarted",
1257
- "characterSpeechEnded",
1258
- "characterFocusChanged",
1259
- "conversationUpdate",
1260
- "listeningState",
1261
- "userSpeechStarted",
1262
- "userSpeechEnded",
1263
- "modeChange",
1264
- "activityChange",
1265
- "feedback",
1266
- "feedbackFailed",
1267
- "message",
1268
- "started",
1269
- "embedReady",
1270
- "widgetReady",
1271
- "widgetExpand",
1272
- "widgetCollapse",
1273
- "widgetAudioSettings",
1274
- "widgetDragStart",
1275
- "widgetDragMove",
1276
- "widgetDragEnd"
1277
- ]);
1278
- function gt(e) {
1298
+ throw e instanceof DOMException && e.name === "SecurityError" ? Error(ht(n), { cause: e }) : e;
1299
+ }
1300
+ }
1301
+ var vt = new Set([1, 2]);
1302
+ function yt(e) {
1303
+ return typeof e == "number" && vt.has(e);
1304
+ }
1305
+ var bt = new Set(/* @__PURE__ */ "close.stateUpdate.commandResult.userTranscript.characterSpeechStarted.characterSpeechEnded.characterFocusChanged.conversationUpdate.listeningState.userSpeechStarted.userSpeechEnded.modeChange.activityChange.feedback.feedbackFailed.message.started.embedReady.widgetReady.widgetExpand.widgetCollapse.widgetAudioSettings.widgetDragStart.widgetDragMove.widgetDragEnd.fullWindow".split("."));
1306
+ function xt(e) {
1279
1307
  if (!e || typeof e != "object") return null;
1280
1308
  let t = e;
1281
- if (!mt(t.schemaVersion) || !t.type || !ht.has(t.type)) return null;
1309
+ if (!yt(t.schemaVersion) || !t.type || !bt.has(t.type)) return null;
1282
1310
  if (t.type === "embedReady" || t.type === "widgetReady" || t.type === "widgetExpand" || t.type === "widgetCollapse") return t;
1311
+ if (t.type === "fullWindow") {
1312
+ let e = t.payload;
1313
+ return !e || typeof e != "object" || typeof e.active != "boolean" ? null : t;
1314
+ }
1283
1315
  if (t.type === "widgetAudioSettings") {
1284
1316
  let e = t.payload;
1285
1317
  return !e || typeof e != "object" || typeof e.open != "boolean" ? null : t;
@@ -1297,7 +1329,7 @@ function gt(e) {
1297
1329
  let n = t.payload;
1298
1330
  return !n || typeof n != "object" ? null : t;
1299
1331
  }
1300
- function _t(e, t, n) {
1332
+ function St(e, t, n) {
1301
1333
  let r = e.trim();
1302
1334
  if (!r) throw Error("createLaunchMessage requires a non-empty launch string.");
1303
1335
  let i = n?.startButton, a = n?.showFeedback;
@@ -1312,20 +1344,20 @@ function _t(e, t, n) {
1312
1344
  }
1313
1345
  };
1314
1346
  }
1315
- function vt() {
1347
+ function Ct() {
1316
1348
  return {
1317
1349
  type: "parentHello",
1318
1350
  schemaVersion: 2
1319
1351
  };
1320
1352
  }
1321
- function yt(e) {
1353
+ function wt(e) {
1322
1354
  return {
1323
1355
  type: "widgetSetChrome",
1324
1356
  schemaVersion: 2,
1325
1357
  payload: { mode: e }
1326
1358
  };
1327
1359
  }
1328
- function bt() {
1360
+ function Tt() {
1329
1361
  return {
1330
1362
  type: "widgetToggleAudioSettings",
1331
1363
  schemaVersion: 2,
@@ -1333,108 +1365,143 @@ function bt() {
1333
1365
  };
1334
1366
  }
1335
1367
  //#endregion
1368
+ //#region src/v2/embed/fullWindowHost.ts
1369
+ var Et = "2147483000";
1370
+ function Dt(e) {
1371
+ let { style: t } = e;
1372
+ return {
1373
+ position: t.position,
1374
+ top: t.top,
1375
+ right: t.right,
1376
+ bottom: t.bottom,
1377
+ left: t.left,
1378
+ inset: t.inset,
1379
+ width: t.width,
1380
+ height: t.height,
1381
+ zIndex: t.zIndex,
1382
+ margin: t.margin,
1383
+ borderRadius: t.borderRadius,
1384
+ maxWidth: t.maxWidth,
1385
+ maxHeight: t.maxHeight
1386
+ };
1387
+ }
1388
+ function Ot(e) {
1389
+ let { style: t } = e;
1390
+ t.position = "fixed", t.top = "0", t.right = "0", t.bottom = "0", t.left = "0", t.inset = "0", t.width = "100vw", t.width = "100dvw", t.height = "100vh", t.height = "100dvh", t.zIndex = Et, t.margin = "0", t.borderRadius = "0", t.maxWidth = "none", t.maxHeight = "none", e.dataset.liformaFullWindow = "1";
1391
+ }
1392
+ function kt(e, t) {
1393
+ if (delete e.dataset.liformaFullWindow, !t) {
1394
+ e.style.position = "", e.style.top = "", e.style.right = "", e.style.bottom = "", e.style.left = "", e.style.inset = "", e.style.width = "", e.style.height = "", e.style.zIndex = "", e.style.margin = "", e.style.borderRadius = "", e.style.maxWidth = "", e.style.maxHeight = "";
1395
+ return;
1396
+ }
1397
+ let { style: n } = e;
1398
+ n.position = t.position, n.top = t.top, n.right = t.right, n.bottom = t.bottom, n.left = t.left, n.inset = t.inset, n.width = t.width, n.height = t.height, n.zIndex = t.zIndex, n.margin = t.margin, n.borderRadius = t.borderRadius, n.maxWidth = t.maxWidth, n.maxHeight = t.maxHeight;
1399
+ }
1400
+ //#endregion
1336
1401
  //#region src/v2/embed/iframeHost.ts
1337
- function xt(e) {
1402
+ function At(e) {
1338
1403
  return e;
1339
1404
  }
1340
1405
  function Z() {
1341
1406
  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)}`;
1342
1407
  }
1343
- var St = 3e4;
1344
- function Ct(e) {
1408
+ var jt = 3e4;
1409
+ function Mt(e) {
1345
1410
  let t = e.container;
1346
1411
  getComputedStyle(t).position === "static" && (t.style.position = "relative");
1347
1412
  let n = document.createElement("iframe");
1348
1413
  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");
1349
- let r = !1, i = /* @__PURE__ */ new Map(), a = null, o = 0, s = 0, c = [], l = null, u = null, d = new Promise((e, t) => {
1350
- l = e, u = t;
1351
- }), f = () => {
1352
- for (let e of c) window.clearTimeout(e);
1353
- c.length = 0;
1354
- }, p = (t) => {
1414
+ let r = !1, i = !1, a = null, o = t.closest(".liforma-experience-shell") instanceof HTMLElement ? t.closest(".liforma-experience-shell") : t, s = (t) => {
1415
+ i !== t && (i = t, t ? (a = Dt(o), Ot(o)) : (kt(o, a), a = null), e.onFullWindowChange?.(t));
1416
+ }, c = /* @__PURE__ */ new Map(), l = null, u = 0, d = 0, f = [], p = null, m = null, h = new Promise((e, t) => {
1417
+ p = e, m = t;
1418
+ }), g = () => {
1419
+ for (let e of f) window.clearTimeout(e);
1420
+ f.length = 0;
1421
+ }, _ = (t) => {
1355
1422
  if (r) return;
1356
1423
  let i = Date.now();
1357
- if (s > 0 && i - s < 250) return;
1358
- s = i, f();
1359
- let a = _t(t.launch, t.session, t.chrome), o = () => {
1424
+ if (d > 0 && i - d < 250) return;
1425
+ d = i, g();
1426
+ let a = St(t.launch, t.session, t.chrome), o = () => {
1360
1427
  if (r) return;
1361
1428
  let t = n.contentWindow;
1362
- t && ft(t, a, e.playerOrigin);
1429
+ t && _t(t, a, e.playerOrigin);
1363
1430
  };
1364
1431
  o();
1365
- for (let e = 1; e <= 12; e += 1) c.push(window.setTimeout(o, e * 75));
1366
- }, m = () => {
1367
- r || !a || p(a);
1368
- }, h = () => {
1369
- if (o += 1, o === 1) {
1370
- dt(e.src, e.playerOrigin).then(() => l?.(), (e) => u?.(e instanceof Error ? e : Error(String(e))));
1432
+ for (let e = 1; e <= 12; e += 1) f.push(window.setTimeout(o, e * 75));
1433
+ }, v = () => {
1434
+ r || !l || _(l);
1435
+ }, y = () => {
1436
+ if (u += 1, u === 1) {
1437
+ gt(e.src, e.playerOrigin).then(() => p?.(), (e) => m?.(e instanceof Error ? e : Error(String(e))));
1371
1438
  return;
1372
1439
  }
1373
- s = 0, m();
1374
- }, g = () => {
1375
- o > 0 || u?.(Error(ut(e.playerOrigin)));
1440
+ d = 0, v();
1441
+ }, b = () => {
1442
+ u > 0 || m?.(Error(ht(e.playerOrigin)));
1376
1443
  };
1377
- n.addEventListener("load", h), n.addEventListener("error", g);
1378
- let _ = (t) => {
1444
+ n.addEventListener("load", y), n.addEventListener("error", b);
1445
+ let x = (t) => {
1379
1446
  if (r || t.source !== n.contentWindow || t.origin !== e.playerOrigin) return;
1380
- let a = gt(t.data);
1381
- if (a) switch (a.type) {
1447
+ let i = xt(t.data);
1448
+ if (i) switch (i.type) {
1382
1449
  case "close":
1383
- e.onClose?.(a.payload);
1450
+ e.onClose?.(i.payload);
1384
1451
  break;
1385
1452
  case "stateUpdate":
1386
- e.onPlayerStatusChange?.(a.payload.state), e.onStateUpdate?.(a.payload.state);
1453
+ e.onPlayerStatusChange?.(i.payload.state), e.onStateUpdate?.(i.payload.state);
1387
1454
  break;
1388
1455
  case "commandResult": {
1389
- let e = i.get(a.payload.correlationId);
1456
+ let e = c.get(i.payload.correlationId);
1390
1457
  if (!e) return;
1391
- i.delete(a.payload.correlationId), a.payload.ok ? e.resolve(a.payload.result) : e.reject(Error(a.payload.error ?? "Command failed."));
1458
+ c.delete(i.payload.correlationId), i.payload.ok ? e.resolve(i.payload.result) : e.reject(Error(i.payload.error ?? "Command failed."));
1392
1459
  break;
1393
1460
  }
1394
1461
  case "userTranscript":
1395
- e.onUserTranscript?.(a.payload);
1462
+ e.onUserTranscript?.(i.payload);
1396
1463
  break;
1397
1464
  case "characterSpeechStarted":
1398
- e.onCharacterSpeechStarted?.(a.payload);
1465
+ e.onCharacterSpeechStarted?.(i.payload);
1399
1466
  break;
1400
1467
  case "characterSpeechEnded":
1401
- e.onCharacterSpeechEnded?.(a.payload);
1468
+ e.onCharacterSpeechEnded?.(i.payload);
1402
1469
  break;
1403
1470
  case "characterFocusChanged":
1404
- e.onCharacterFocusChanged?.(a.payload);
1471
+ e.onCharacterFocusChanged?.(i.payload);
1405
1472
  break;
1406
1473
  case "conversationUpdate":
1407
- e.onConversationUpdate?.(a.payload.conversation);
1474
+ e.onConversationUpdate?.(i.payload.conversation);
1408
1475
  break;
1409
1476
  case "listeningState":
1410
- e.onListeningState?.(a.payload.listening);
1477
+ e.onListeningState?.(i.payload.listening);
1411
1478
  break;
1412
1479
  case "userSpeechStarted":
1413
- e.onUserSpeechStarted?.(a.payload);
1480
+ e.onUserSpeechStarted?.(i.payload);
1414
1481
  break;
1415
1482
  case "userSpeechEnded":
1416
- e.onUserSpeechEnded?.(a.payload);
1483
+ e.onUserSpeechEnded?.(i.payload);
1417
1484
  break;
1418
1485
  case "modeChange":
1419
- e.onActivityChange?.(xt(a.payload.mode));
1486
+ e.onActivityChange?.(At(i.payload.mode));
1420
1487
  break;
1421
1488
  case "activityChange":
1422
- e.onActivityChange?.(a.payload.activity);
1489
+ e.onActivityChange?.(i.payload.activity);
1423
1490
  break;
1424
1491
  case "feedback":
1425
- e.onFeedback?.(a.payload);
1492
+ e.onFeedback?.(i.payload);
1426
1493
  break;
1427
1494
  case "feedbackFailed":
1428
- e.onFeedbackFailed?.(a.payload);
1495
+ e.onFeedbackFailed?.(i.payload);
1429
1496
  break;
1430
1497
  case "message":
1431
- e.onMessage?.(a.payload);
1498
+ e.onMessage?.(i.payload);
1432
1499
  break;
1433
1500
  case "started":
1434
- e.onStarted?.(a.payload);
1501
+ e.onStarted?.(i.payload);
1435
1502
  break;
1436
1503
  case "embedReady":
1437
- m();
1504
+ v();
1438
1505
  break;
1439
1506
  case "widgetReady":
1440
1507
  e.onWidgetReady?.();
@@ -1446,52 +1513,55 @@ function Ct(e) {
1446
1513
  e.onWidgetCollapse?.();
1447
1514
  break;
1448
1515
  case "widgetAudioSettings":
1449
- e.onWidgetAudioSettings?.(a.payload.open);
1516
+ e.onWidgetAudioSettings?.(i.payload.open);
1450
1517
  break;
1451
1518
  case "widgetDragStart":
1452
- e.onWidgetDragStart?.(a.payload);
1519
+ e.onWidgetDragStart?.(i.payload);
1453
1520
  break;
1454
1521
  case "widgetDragMove":
1455
- e.onWidgetDragMove?.(a.payload);
1522
+ e.onWidgetDragMove?.(i.payload);
1456
1523
  break;
1457
1524
  case "widgetDragEnd":
1458
- e.onWidgetDragEnd?.(a.payload);
1525
+ e.onWidgetDragEnd?.(i.payload);
1526
+ break;
1527
+ case "fullWindow":
1528
+ s(i.payload.active);
1459
1529
  break;
1460
1530
  }
1461
1531
  };
1462
- if (window.addEventListener("message", _), t.replaceChildren(n), t.clientHeight < 2 && !t.style.minHeight) {
1532
+ if (window.addEventListener("message", x), t.replaceChildren(n), t.clientHeight < 2 && !t.style.minHeight) {
1463
1533
  let e = getComputedStyle(t).minHeight;
1464
1534
  (e === "0px" || e === "auto") && (t.style.minHeight = "480px");
1465
1535
  }
1466
- let v = (t, i) => {
1536
+ let S = (t, i) => {
1467
1537
  if (r) return;
1468
1538
  let a = n.contentWindow;
1469
- if (!a) throw Error(ut(e.playerOrigin));
1470
- ft(a, t, e.playerOrigin, i);
1471
- }, y = (e, t = 12e4, n) => {
1539
+ if (!a) throw Error(ht(e.playerOrigin));
1540
+ _t(a, t, e.playerOrigin, i);
1541
+ }, C = (e, t = 12e4, n) => {
1472
1542
  let r = e.type !== "parentHello" && e.payload && "correlationId" in e.payload ? e.payload.correlationId : Z();
1473
- return e.type !== "parentHello" && e.payload && "correlationId" in e.payload || e.type !== "parentHello" && e.payload && (e.payload.correlationId = r), new Promise((a, o) => {
1474
- i.set(r, {
1475
- resolve: (e) => a(e),
1476
- reject: o
1477
- }), v(e, n), setTimeout(() => {
1478
- i.has(r) && (i.delete(r), o(/* @__PURE__ */ Error("Timed out waiting for player command result.")));
1543
+ return e.type !== "parentHello" && e.payload && "correlationId" in e.payload || e.type !== "parentHello" && e.payload && (e.payload.correlationId = r), new Promise((i, a) => {
1544
+ c.set(r, {
1545
+ resolve: (e) => i(e),
1546
+ reject: a
1547
+ }), S(e, n), setTimeout(() => {
1548
+ c.has(r) && (c.delete(r), a(/* @__PURE__ */ Error("Timed out waiting for player command result.")));
1479
1549
  }, t);
1480
1550
  });
1481
1551
  };
1482
1552
  return {
1483
1553
  waitForLoad() {
1484
- return d;
1554
+ return h;
1485
1555
  },
1486
1556
  postParentHello() {
1487
- v(vt());
1557
+ S(Ct());
1488
1558
  },
1489
1559
  postLaunch(e, t, n) {
1490
- r || (a = {
1560
+ r || (l = {
1491
1561
  launch: e,
1492
1562
  session: t,
1493
1563
  chrome: n
1494
- }, s = 0, p(a));
1564
+ }, d = 0, _(l));
1495
1565
  },
1496
1566
  postManifest(e) {
1497
1567
  if (typeof e == "string") {
@@ -1506,13 +1576,13 @@ function Ct(e) {
1506
1576
  throw Error("postManifest is deprecated; use postLaunch with an opaque launch string from SessionLaunchResponse.");
1507
1577
  },
1508
1578
  postWidgetSetChrome(e) {
1509
- v(yt(e));
1579
+ S(wt(e));
1510
1580
  },
1511
1581
  postWidgetToggleAudioSettings() {
1512
- v(bt());
1582
+ S(Tt());
1513
1583
  },
1514
1584
  speak(e) {
1515
- return y({
1585
+ return C({
1516
1586
  type: "speak",
1517
1587
  schemaVersion: 2,
1518
1588
  payload: {
@@ -1524,21 +1594,21 @@ function Ct(e) {
1524
1594
  });
1525
1595
  },
1526
1596
  startListening() {
1527
- return y({
1597
+ return C({
1528
1598
  type: "startListening",
1529
1599
  schemaVersion: 2,
1530
1600
  payload: { correlationId: Z() }
1531
1601
  });
1532
1602
  },
1533
1603
  stopListening() {
1534
- return y({
1604
+ return C({
1535
1605
  type: "stopListening",
1536
1606
  schemaVersion: 2,
1537
1607
  payload: { correlationId: Z() }
1538
1608
  });
1539
1609
  },
1540
1610
  listenOnce(e) {
1541
- return y({
1611
+ return C({
1542
1612
  type: "listenOnce",
1543
1613
  schemaVersion: 2,
1544
1614
  payload: {
@@ -1548,7 +1618,7 @@ function Ct(e) {
1548
1618
  });
1549
1619
  },
1550
1620
  async speakProcessorStream(e, t) {
1551
- let n = Z(), r = Z(), i = (await y({
1621
+ let n = Z(), r = Z(), i = (await C({
1552
1622
  type: "speakStreamStart",
1553
1623
  schemaVersion: 2,
1554
1624
  payload: {
@@ -1560,7 +1630,7 @@ function Ct(e) {
1560
1630
  try {
1561
1631
  for await (let n of e) {
1562
1632
  if (t?.signal?.aborted) throw new DOMException("Processor stream aborted.", "AbortError");
1563
- n && v({
1633
+ n && S({
1564
1634
  type: "speakStreamChunk",
1565
1635
  schemaVersion: 2,
1566
1636
  payload: {
@@ -1570,7 +1640,7 @@ function Ct(e) {
1570
1640
  });
1571
1641
  }
1572
1642
  if (t?.signal?.aborted) throw new DOMException("Processor stream aborted.", "AbortError");
1573
- return await y({
1643
+ return await C({
1574
1644
  type: "speakStreamEnd",
1575
1645
  schemaVersion: 2,
1576
1646
  payload: {
@@ -1580,7 +1650,7 @@ function Ct(e) {
1580
1650
  });
1581
1651
  } catch (e) {
1582
1652
  try {
1583
- await y({
1653
+ await C({
1584
1654
  type: "speakStreamEnd",
1585
1655
  schemaVersion: 2,
1586
1656
  payload: {
@@ -1594,7 +1664,7 @@ function Ct(e) {
1594
1664
  },
1595
1665
  speechPlay(e) {
1596
1666
  let t = Z(), n = [];
1597
- return (e.source.kind === "pcm" || e.source.kind === "encoded") && n.push(e.source.data), y({
1667
+ return (e.source.kind === "pcm" || e.source.kind === "encoded") && n.push(e.source.data), C({
1598
1668
  type: "speechPlay",
1599
1669
  schemaVersion: 2,
1600
1670
  payload: {
@@ -1608,7 +1678,7 @@ function Ct(e) {
1608
1678
  }, 12e4, n);
1609
1679
  },
1610
1680
  speechUtteranceBegin(e) {
1611
- return y({
1681
+ return C({
1612
1682
  type: "speechUtteranceBegin",
1613
1683
  schemaVersion: 2,
1614
1684
  payload: {
@@ -1622,7 +1692,7 @@ function Ct(e) {
1622
1692
  });
1623
1693
  },
1624
1694
  speechUtteranceWrite(e) {
1625
- return y({
1695
+ return C({
1626
1696
  type: "speechUtteranceWrite",
1627
1697
  schemaVersion: 2,
1628
1698
  payload: {
@@ -1631,10 +1701,10 @@ function Ct(e) {
1631
1701
  audio: e.audio,
1632
1702
  byteLength: e.byteLength
1633
1703
  }
1634
- }, St, [e.audio]);
1704
+ }, jt, [e.audio]);
1635
1705
  },
1636
1706
  speechUtteranceSetTranscript(e) {
1637
- return y({
1707
+ return C({
1638
1708
  type: "speechUtteranceSetTranscript",
1639
1709
  schemaVersion: 2,
1640
1710
  payload: {
@@ -1645,7 +1715,7 @@ function Ct(e) {
1645
1715
  });
1646
1716
  },
1647
1717
  speechUtteranceClose(e) {
1648
- return y({
1718
+ return C({
1649
1719
  type: "speechUtteranceClose",
1650
1720
  schemaVersion: 2,
1651
1721
  payload: {
@@ -1657,7 +1727,7 @@ function Ct(e) {
1657
1727
  });
1658
1728
  },
1659
1729
  speechUtteranceCancel(e) {
1660
- return y({
1730
+ return C({
1661
1731
  type: "speechUtteranceCancel",
1662
1732
  schemaVersion: 2,
1663
1733
  payload: {
@@ -1667,7 +1737,7 @@ function Ct(e) {
1667
1737
  });
1668
1738
  },
1669
1739
  speechInterrupt(e) {
1670
- return y({
1740
+ return C({
1671
1741
  type: "speechInterrupt",
1672
1742
  schemaVersion: 2,
1673
1743
  payload: {
@@ -1677,14 +1747,14 @@ function Ct(e) {
1677
1747
  });
1678
1748
  },
1679
1749
  getConversation() {
1680
- return y({
1750
+ return C({
1681
1751
  type: "getConversation",
1682
1752
  schemaVersion: 2,
1683
1753
  payload: { correlationId: Z() }
1684
1754
  });
1685
1755
  },
1686
1756
  focusCharacter(e) {
1687
- return y({
1757
+ return C({
1688
1758
  type: "focusCharacter",
1689
1759
  schemaVersion: 2,
1690
1760
  payload: {
@@ -1694,7 +1764,7 @@ function Ct(e) {
1694
1764
  });
1695
1765
  },
1696
1766
  setFit(e) {
1697
- return y({
1767
+ return C({
1698
1768
  type: "setFit",
1699
1769
  schemaVersion: 2,
1700
1770
  payload: {
@@ -1703,18 +1773,28 @@ function Ct(e) {
1703
1773
  }
1704
1774
  });
1705
1775
  },
1776
+ conversion(e) {
1777
+ return C({
1778
+ type: "conversion",
1779
+ schemaVersion: 2,
1780
+ payload: {
1781
+ correlationId: Z(),
1782
+ key: e
1783
+ }
1784
+ });
1785
+ },
1706
1786
  destroy() {
1707
1787
  if (!r) {
1708
- r = !0;
1709
- for (let e of i.values()) e.reject(/* @__PURE__ */ Error("Iframe host destroyed."));
1710
- i.clear(), f(), a = null, n.removeEventListener("load", h), n.removeEventListener("error", g), window.removeEventListener("message", _), n.remove();
1788
+ r = !0, i && s(!1);
1789
+ for (let e of c.values()) e.reject(/* @__PURE__ */ Error("Iframe host destroyed."));
1790
+ c.clear(), g(), l = null, n.removeEventListener("load", y), n.removeEventListener("error", b), window.removeEventListener("message", x), n.remove();
1711
1791
  }
1712
1792
  }
1713
1793
  };
1714
1794
  }
1715
1795
  //#endregion
1716
1796
  //#region src/v2/embed/readyGate.ts
1717
- function wt(e) {
1797
+ function Nt(e) {
1718
1798
  let t, n = !1, r = !1, i = () => {
1719
1799
  r || !n || t === void 0 || (r = !0, e(t));
1720
1800
  };
@@ -1729,47 +1809,50 @@ function wt(e) {
1729
1809
  }
1730
1810
  //#endregion
1731
1811
  //#region src/v2/shims/embedBaseUrl.ts
1732
- var Tt = "https://player.liforma.ai/embed", Et = "http://localhost:3002/embed";
1733
- function Dt() {
1812
+ var Pt = "https://player.liforma.ai/embed", Ft = "http://localhost:3002/embed";
1813
+ function It() {
1734
1814
  let e = globalThis.__LIFORMA_PLAYER_EMBED_URL;
1735
1815
  if (e?.trim()) return e.trim().replace(/\/$/, "");
1736
1816
  if (typeof document > "u") return null;
1737
1817
  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();
1738
1818
  return t ? t.replace(/\/$/, "") : null;
1739
1819
  }
1740
- function Ot() {
1741
- let e = Dt();
1742
- return e ? e.endsWith("/embed") ? e : `${e}/embed` : B() ? Et : Tt;
1820
+ function Lt() {
1821
+ let e = It();
1822
+ return e ? e.endsWith("/embed") ? e : `${e}/embed` : ae() ? Ft : Pt;
1743
1823
  }
1744
- function kt(e, t, n, r, i, a, o, s) {
1745
- let c = (e ?? Ot()).replace(/\/$/, ""), l = c.endsWith("/embed") ? c : `${c}/embed`, u = new URL(l), d = n?.trim();
1746
- d && u.searchParams.set("locationId", d);
1824
+ function Rt(e, t) {
1825
+ return e?.trim() || t?.trim() || void 0;
1826
+ }
1827
+ function zt(e, t, n, r, i, a, o, s) {
1828
+ let c = (e ?? Lt()).replace(/\/$/, ""), l = c.endsWith("/embed") ? c : `${c}/embed`, u = new URL(l), d = n?.trim();
1829
+ d && (u.searchParams.set("backdropId", d), u.searchParams.set("locationId", d));
1747
1830
  let f = r?.trim();
1748
- 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)), At(u.toString());
1831
+ 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)), Bt(u.toString());
1749
1832
  }
1750
- function At(e) {
1833
+ function Bt(e) {
1751
1834
  if (typeof location > "u") return e;
1752
1835
  let t = new URL(e);
1753
1836
  return t.searchParams.set("parentOrigin", location.origin), t.toString();
1754
1837
  }
1755
- function jt(e) {
1838
+ function Vt(e) {
1756
1839
  return new URL(e).origin;
1757
1840
  }
1758
1841
  //#endregion
1759
1842
  //#region src/v2/experienceEvents.ts
1760
- function Mt() {
1843
+ function Ht() {
1761
1844
  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)}`;
1762
1845
  }
1763
- function Nt(e, t, n) {
1846
+ function Ut(e, t, n) {
1764
1847
  return {
1765
- id: Mt(),
1848
+ id: Ht(),
1766
1849
  type: e,
1767
1850
  sessionId: t,
1768
1851
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1769
1852
  data: n
1770
1853
  };
1771
1854
  }
1772
- function Pt() {
1855
+ function Wt() {
1773
1856
  return {
1774
1857
  ready: /* @__PURE__ */ new Set(),
1775
1858
  started: /* @__PURE__ */ new Set(),
@@ -1788,39 +1871,39 @@ function Pt() {
1788
1871
  conversationProcessorError: /* @__PURE__ */ new Set()
1789
1872
  };
1790
1873
  }
1791
- function Ft(e, t, n) {
1874
+ function Gt(e, t, n) {
1792
1875
  return e[t].add(n), () => e[t].delete(n);
1793
1876
  }
1794
- function It(e, t, n) {
1877
+ function Kt(e, t, n) {
1795
1878
  for (let r of e[t]) r(n);
1796
1879
  }
1797
- function Lt(e) {
1880
+ function qt(e) {
1798
1881
  for (let t of Object.keys(e)) e[t].clear();
1799
1882
  }
1800
1883
  //#endregion
1801
1884
  //#region src/v2/speech/types.ts
1802
- function Rt(e) {
1885
+ function Jt(e) {
1803
1886
  return "data" in e && "format" in e && e.format != null && !("track" in e);
1804
1887
  }
1805
- function zt(e) {
1888
+ function Yt(e) {
1806
1889
  return "url" in e && typeof e.url == "string";
1807
1890
  }
1808
- function Bt(e) {
1891
+ function Xt(e) {
1809
1892
  if (!("track" in e)) return !1;
1810
1893
  let t = e.track;
1811
1894
  return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
1812
1895
  }
1813
- function Vt(e) {
1814
- return !Rt(e) && !zt(e) && !Bt(e) && "encoding" in e && typeof e.encoding == "string";
1896
+ function Zt(e) {
1897
+ return !Jt(e) && !Yt(e) && !Xt(e) && "encoding" in e && typeof e.encoding == "string";
1815
1898
  }
1816
- var Ht = [
1899
+ var Qt = [
1817
1900
  8e3,
1818
1901
  16e3,
1819
1902
  22050,
1820
1903
  24e3,
1821
1904
  44100,
1822
1905
  48e3
1823
- ], Ut = {
1906
+ ], $t = {
1824
1907
  MAX_CHUNK_BYTES: 64 * 1024,
1825
1908
  RECOMMENDED_CHUNK_MS_MIN: 20,
1826
1909
  RECOMMENDED_CHUNK_MS_MAX: 200,
@@ -1831,14 +1914,14 @@ var Ht = [
1831
1914
  MAX_UTTERANCE_DURATION_MS: 9e4,
1832
1915
  MAX_PENDING_WRITES: 8,
1833
1916
  DEFAULT_WRITE_TIMEOUT_MS: 5e3
1834
- }, Wt = class extends Error {
1917
+ }, en = class extends Error {
1835
1918
  operation;
1836
1919
  requiredCapability;
1837
1920
  name = "UnsupportedSpeechOperationError";
1838
1921
  constructor(e, t) {
1839
1922
  super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
1840
1923
  }
1841
- }, Gt = class extends Error {
1924
+ }, tn = class extends Error {
1842
1925
  name = "SpeechUtteranceClosedError";
1843
1926
  constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
1844
1927
  super(e);
@@ -1848,72 +1931,72 @@ var Ht = [
1848
1931
  constructor(e, t) {
1849
1932
  super(e, t);
1850
1933
  }
1851
- }, Kt = class extends Error {
1934
+ }, nn = class extends Error {
1852
1935
  name = "SpeechBufferTimeoutError";
1853
1936
  constructor(e = "Timed out waiting for speech buffer capacity.") {
1854
1937
  super(e);
1855
1938
  }
1856
1939
  };
1857
- function qt(e = "none") {
1940
+ function rn(e = "none") {
1858
1941
  return {
1859
1942
  mode: e,
1860
1943
  trackedDurationMs: 0,
1861
1944
  fallbackDurationMs: 0
1862
1945
  };
1863
1946
  }
1864
- function Jt(e) {
1865
- return Ht.includes(e);
1947
+ function an(e) {
1948
+ return Qt.includes(e);
1866
1949
  }
1867
- function Yt(e) {
1950
+ function on(e) {
1868
1951
  if (e.encoding !== "pcm_s16le") throw new Q(`Unsupported audio encoding: ${e.encoding}`);
1869
1952
  if (e.channels !== 1) throw new Q(`Unsupported channel count: ${e.channels}`);
1870
- if (!Jt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
1953
+ if (!an(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
1871
1954
  }
1872
- function Xt(e) {
1873
- if (Rt(e)) {
1874
- Yt(e.format);
1955
+ function sn(e) {
1956
+ if (Jt(e)) {
1957
+ on(e.format);
1875
1958
  return;
1876
1959
  }
1877
- if (zt(e)) {
1960
+ if (Yt(e)) {
1878
1961
  if (!e.url.trim()) throw new Q("Audio URL must be non-empty.");
1879
- if (e.sampleRate !== void 0 && !Jt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
1962
+ if (e.sampleRate !== void 0 && !an(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
1880
1963
  return;
1881
1964
  }
1882
- if (Bt(e)) {
1965
+ if (Xt(e)) {
1883
1966
  if (e.track.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
1884
- if (e.sampleRate !== void 0 && !Jt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
1967
+ if (e.sampleRate !== void 0 && !an(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
1885
1968
  return;
1886
1969
  }
1887
- if (Vt(e)) {
1970
+ if (Zt(e)) {
1888
1971
  let t = e.encoding.trim().toLowerCase();
1889
1972
  if (!t) throw new Q("Encoded audio MIME type is required.");
1890
1973
  if (t === "pcm_s16le") throw new Q("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
1891
- if (e.sampleRate !== void 0 && !Jt(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
1974
+ if (e.sampleRate !== void 0 && !an(e.sampleRate)) throw new Q(`Unsupported sample rate: ${e.sampleRate}`);
1892
1975
  return;
1893
1976
  }
1894
1977
  throw new Q("Unsupported speech.play audio shape.");
1895
1978
  }
1896
- function Zt(e) {
1897
- if (e.format) return Yt(e.format), e.format;
1979
+ function cn(e) {
1980
+ if (e.format) return on(e.format), e.format;
1898
1981
  if (e.track) {
1899
1982
  let t = {
1900
1983
  encoding: "pcm_s16le",
1901
1984
  sampleRate: e.sampleRate ?? 24e3,
1902
1985
  channels: 1
1903
1986
  };
1904
- return Yt(t), t;
1987
+ return on(t), t;
1905
1988
  }
1906
1989
  throw new Q("createUtterance requires format or track.");
1907
1990
  }
1908
- function Qt(e) {
1991
+ function ln(e) {
1909
1992
  return e instanceof Uint8Array ? e : new Uint8Array(e);
1910
1993
  }
1911
- function $t(e) {
1994
+ function un(e) {
1912
1995
  return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
1913
1996
  }
1914
1997
  //#endregion
1915
1998
  //#region src/byo/pcm.ts
1916
- function en(e) {
1999
+ function dn(e) {
1917
2000
  let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
1918
2001
  for (let t = 0; t < e.length; t++) {
1919
2002
  let r = Math.max(-1, Math.min(1, e[t]));
@@ -1923,11 +2006,11 @@ function en(e) {
1923
2006
  }
1924
2007
  //#endregion
1925
2008
  //#region src/byo/resample.ts
1926
- function tn(e, t, n, r, i) {
2009
+ function fn(e, t, n, r, i) {
1927
2010
  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;
1928
2011
  return ((a * i + o) * i + s) * i + c;
1929
2012
  }
1930
- function nn(e, t) {
2013
+ function pn(e, t) {
1931
2014
  if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
1932
2015
  if (e === t) return {
1933
2016
  fromRate: e,
@@ -1950,7 +2033,7 @@ function nn(e, t) {
1950
2033
  let a = [];
1951
2034
  for (; i + 2 < r.length - 1;) {
1952
2035
  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);
1953
- a.push(tn(r[o], r[e], r[s], r[c], t)), i += n;
2036
+ a.push(fn(r[o], r[e], r[s], r[c], t)), i += n;
1954
2037
  }
1955
2038
  let o = Math.max(0, Math.floor(i) - 1);
1956
2039
  return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
@@ -1962,7 +2045,7 @@ function nn(e, t) {
1962
2045
  }
1963
2046
  //#endregion
1964
2047
  //#region src/byo/audioCapture.ts
1965
- var rn = "liforma-pcm-capture", an = `
2048
+ var mn = "liforma-pcm-capture", hn = `
1966
2049
  class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
1967
2050
  process(inputs) {
1968
2051
  const ch = inputs[0] && inputs[0][0];
@@ -1974,29 +2057,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
1974
2057
  return true;
1975
2058
  }
1976
2059
  }
1977
- registerProcessor('${rn}', LiformaPcmCaptureProcessor);
1978
- `, on = null;
1979
- function sn() {
1980
- return on ||= URL.createObjectURL(new Blob([an], { type: "application/javascript" })), on;
2060
+ registerProcessor('${mn}', LiformaPcmCaptureProcessor);
2061
+ `, gn = null;
2062
+ function _n() {
2063
+ return gn ||= URL.createObjectURL(new Blob([hn], { type: "application/javascript" })), gn;
1981
2064
  }
1982
- function cn() {
2065
+ function vn() {
1983
2066
  return window.AudioContext || window.webkitAudioContext || null;
1984
2067
  }
1985
- async function ln(e) {
1986
- let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = cn();
2068
+ async function yn(e) {
2069
+ let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = vn();
1987
2070
  if (!o) throw Error("Web Audio is required for audio capture");
1988
2071
  let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
1989
2072
  l.gain.value = 0;
1990
- let u = s.sampleRate, d = nn(u, n), f = !1, p = !1, m = (e) => {
2073
+ let u = s.sampleRate, d = pn(u, n), f = !1, p = !1, m = (e) => {
1991
2074
  if (f || i && !i()) return;
1992
2075
  let t = d.push(e);
1993
- t.length !== 0 && r(en(t));
2076
+ t.length !== 0 && r(dn(t));
1994
2077
  }, h = () => void 0;
1995
2078
  return await (async () => {
1996
2079
  if (typeof s.audioWorklet?.addModule != "function") return !1;
1997
2080
  try {
1998
- await s.audioWorklet.addModule(sn());
1999
- let e = new AudioWorkletNode(s, rn, {
2081
+ await s.audioWorklet.addModule(_n());
2082
+ let e = new AudioWorkletNode(s, mn, {
2000
2083
  numberOfInputs: 1,
2001
2084
  numberOfOutputs: 1,
2002
2085
  outputChannelCount: [1]
@@ -2046,7 +2129,7 @@ async function ln(e) {
2046
2129
  }
2047
2130
  //#endregion
2048
2131
  //#region src/v2/speech/captureMediaStreamTrack.ts
2049
- async function un(e) {
2132
+ async function bn(e) {
2050
2133
  let { track: t, utterance: n, sampleRate: r, signal: i } = e;
2051
2134
  if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Q("MediaStreamTrack is not available in this environment.");
2052
2135
  if (t.kind !== "audio") throw new Q("speech.play track must be an audio MediaStreamTrack.");
@@ -2055,18 +2138,18 @@ async function un(e) {
2055
2138
  s || (s = !0, c?.stop(), c = null);
2056
2139
  };
2057
2140
  try {
2058
- c = await ln({
2141
+ c = await yn({
2059
2142
  mediaStream: a,
2060
2143
  targetSampleRate: r,
2061
2144
  shouldSend: () => !s && !i?.aborted,
2062
2145
  onPcm: (e) => {
2063
2146
  if (s || i?.aborted) return;
2064
- let t = Qt(e);
2147
+ let t = ln(e);
2065
2148
  o = o.then(async () => {
2066
2149
  if (s || i?.aborted) return;
2067
2150
  let e = 0;
2068
2151
  for (; e < t.byteLength;) {
2069
- let r = Math.min(e + Ut.MAX_CHUNK_BYTES, t.byteLength);
2152
+ let r = Math.min(e + $t.MAX_CHUNK_BYTES, t.byteLength);
2070
2153
  if ((r - e) % 2 == 1 && --r, r <= e) break;
2071
2154
  let i = t.subarray(e, r);
2072
2155
  e = r, i.byteLength !== 0 && await n.write(i);
@@ -2090,10 +2173,10 @@ async function un(e) {
2090
2173
  }
2091
2174
  //#endregion
2092
2175
  //#region src/v2/speech/speechController.ts
2093
- async function dn(e, t) {
2094
- if (Bt(e)) throw new Q("MediaStreamTrack play is handled on the host before embed.");
2095
- if (Rt(e)) {
2096
- let t = Qt(e.data);
2176
+ async function xn(e, t) {
2177
+ if (Xt(e)) throw new Q("MediaStreamTrack play is handled on the host before embed.");
2178
+ if (Jt(e)) {
2179
+ let t = ln(e.data);
2097
2180
  if (t.byteLength & 1) throw new Q("PCM byte length must be even.");
2098
2181
  return {
2099
2182
  kind: "pcm",
@@ -2101,17 +2184,17 @@ async function dn(e, t) {
2101
2184
  format: e.format
2102
2185
  };
2103
2186
  }
2104
- if (zt(e)) return {
2187
+ if (Yt(e)) return {
2105
2188
  kind: "url",
2106
2189
  url: e.url.trim(),
2107
2190
  ...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
2108
2191
  };
2109
- if (!Vt(e)) throw new Q("Unsupported speech.play audio shape.");
2192
+ if (!Zt(e)) throw new Q("Unsupported speech.play audio shape.");
2110
2193
  let n;
2111
2194
  if (typeof Blob < "u" && e.data instanceof Blob) {
2112
2195
  if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
2113
2196
  n = new Uint8Array(await e.data.arrayBuffer());
2114
- } else n = Qt(e.data);
2197
+ } else n = ln(e.data);
2115
2198
  return {
2116
2199
  kind: "encoded",
2117
2200
  data: n.slice().buffer,
@@ -2119,10 +2202,10 @@ async function dn(e, t) {
2119
2202
  ...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
2120
2203
  };
2121
2204
  }
2122
- function fn() {
2205
+ function Sn() {
2123
2206
  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)}`;
2124
2207
  }
2125
- function pn(e, t = "completed") {
2208
+ function Cn(e, t = "completed") {
2126
2209
  return {
2127
2210
  utteranceId: e.speechId,
2128
2211
  characterId: e.characterId,
@@ -2136,13 +2219,13 @@ function pn(e, t = "completed") {
2136
2219
  }
2137
2220
  };
2138
2221
  }
2139
- function mn(e) {
2222
+ function wn(e) {
2140
2223
  return e instanceof Error ? e : new Q(String(e));
2141
2224
  }
2142
- function hn(e) {
2225
+ function Tn(e) {
2143
2226
  return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
2144
2227
  }
2145
- var gn = class {
2228
+ var En = class {
2146
2229
  id;
2147
2230
  characterId;
2148
2231
  result;
@@ -2171,29 +2254,29 @@ var gn = class {
2171
2254
  queue: e.queue,
2172
2255
  ...e.transcript === void 0 ? {} : { transcript: e.transcript }
2173
2256
  }).catch((e) => {
2174
- throw this.fail(mn(e)), mn(e);
2257
+ throw this.fail(wn(e)), wn(e);
2175
2258
  }), this.signal?.addEventListener("abort", () => {
2176
2259
  this.cancel();
2177
2260
  }, { once: !0 });
2178
2261
  }
2179
2262
  async write(e, t) {
2180
- if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new Gt();
2181
- let n = Qt(e);
2263
+ if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new tn();
2264
+ let n = ln(e);
2182
2265
  if (n.byteLength & 1) throw new Q("PCM chunk byte length must be even (complete s16 samples).");
2183
- if (n.byteLength > Ut.MAX_CHUNK_BYTES) throw new Q(`PCM chunk exceeds MAX_CHUNK_BYTES (${Ut.MAX_CHUNK_BYTES}).`);
2266
+ if (n.byteLength > $t.MAX_CHUNK_BYTES) throw new Q(`PCM chunk exceeds MAX_CHUNK_BYTES (${$t.MAX_CHUNK_BYTES}).`);
2184
2267
  if (n.byteLength === 0) return;
2185
- let r = t?.timeoutMs ?? Ut.DEFAULT_WRITE_TIMEOUT_MS;
2268
+ let r = t?.timeoutMs ?? $t.DEFAULT_WRITE_TIMEOUT_MS;
2186
2269
  await this.acquireWriteSlot(r);
2187
2270
  let i = n.byteLength / 2 / this.sampleRate * 1e3;
2188
- if (this.bufferedMs + i > Ut.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new Q("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
2271
+ if (this.bufferedMs + i > $t.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new Q("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
2189
2272
  let a = async () => {
2190
- if (this.closed || this.settled) throw new Gt();
2273
+ if (this.closed || this.settled) throw new tn();
2191
2274
  let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
2192
2275
  utteranceId: this.id,
2193
2276
  audio: t.buffer,
2194
2277
  byteLength: t.byteLength
2195
2278
  }), a = await Promise.race([i, new Promise((e, t) => {
2196
- setTimeout(() => t(new Kt()), r);
2279
+ setTimeout(() => t(new nn()), r);
2197
2280
  })]);
2198
2281
  this.bufferedMs = Math.max(0, a.bufferedMs);
2199
2282
  }, o = this.writeChain.then(a, a);
@@ -2205,7 +2288,7 @@ var gn = class {
2205
2288
  }
2206
2289
  }
2207
2290
  async setTranscript(e) {
2208
- if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new Gt();
2291
+ if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new tn();
2209
2292
  await this.requireHost().speechUtteranceSetTranscript({
2210
2293
  utteranceId: this.id,
2211
2294
  transcript: e
@@ -2222,7 +2305,7 @@ var gn = class {
2222
2305
  });
2223
2306
  return this.resolve(t), t;
2224
2307
  } catch (e) {
2225
- let t = mn(e);
2308
+ let t = wn(e);
2226
2309
  throw this.fail(t), t;
2227
2310
  }
2228
2311
  }
@@ -2240,11 +2323,11 @@ var gn = class {
2240
2323
  characterId: this.characterId,
2241
2324
  status: "cancelled",
2242
2325
  durationMs: 0,
2243
- animation: qt("none")
2326
+ animation: rn("none")
2244
2327
  };
2245
2328
  return this.resolve(t), t;
2246
2329
  } catch (e) {
2247
- let t = mn(e);
2330
+ let t = wn(e);
2248
2331
  throw this.fail(t), t;
2249
2332
  }
2250
2333
  }
@@ -2257,19 +2340,19 @@ var gn = class {
2257
2340
  return e;
2258
2341
  }
2259
2342
  resolve(e) {
2260
- this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new Gt()));
2343
+ this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new tn()));
2261
2344
  }
2262
2345
  fail(e) {
2263
2346
  this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
2264
2347
  }
2265
2348
  async acquireWriteSlot(e) {
2266
- if (this.pendingWriteCount < Ut.MAX_PENDING_WRITES) {
2349
+ if (this.pendingWriteCount < $t.MAX_PENDING_WRITES) {
2267
2350
  this.pendingWriteCount += 1;
2268
2351
  return;
2269
2352
  }
2270
2353
  await new Promise((t, n) => {
2271
2354
  let r = setTimeout(() => {
2272
- n(new Kt());
2355
+ n(new nn());
2273
2356
  }, e);
2274
2357
  this.pendingWriteWaiters.push({
2275
2358
  resolve: () => {
@@ -2288,13 +2371,13 @@ var gn = class {
2288
2371
  for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
2289
2372
  }
2290
2373
  };
2291
- function _n(e) {
2374
+ function Dn(e) {
2292
2375
  let t = null, n = (t, n) => {
2293
- if (!e.getCapabilities()[n]) throw new Wt(t, n);
2376
+ if (!e.getCapabilities()[n]) throw new en(t, n);
2294
2377
  }, r = {
2295
2378
  async speak(r) {
2296
2379
  if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
2297
- let i = $t(r.queue ?? "append");
2380
+ let i = un(r.queue ?? "append");
2298
2381
  i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
2299
2382
  let a = e.getIframeHost();
2300
2383
  if (!a) throw new Q("Speech session is not attached.");
@@ -2314,41 +2397,41 @@ function _n(e) {
2314
2397
  return;
2315
2398
  }
2316
2399
  t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
2317
- t.removeEventListener("abort", s), n(pn(e, "completed"));
2400
+ t.removeEventListener("abort", s), n(Cn(e, "completed"));
2318
2401
  }, (a) => {
2319
- if (t.removeEventListener("abort", s), hn(a)) {
2402
+ if (t.removeEventListener("abort", s), Tn(a)) {
2320
2403
  n({
2321
2404
  utteranceId: "utt_interrupted",
2322
2405
  characterId: r.characterId ?? e.getActiveCharacterId(),
2323
2406
  status: "interrupted",
2324
2407
  durationMs: 0,
2325
2408
  transcript: r.text,
2326
- animation: qt("none")
2409
+ animation: rn("none")
2327
2410
  });
2328
2411
  return;
2329
2412
  }
2330
- i(mn(a));
2413
+ i(wn(a));
2331
2414
  });
2332
2415
  });
2333
2416
  }
2334
2417
  try {
2335
- return pn(await o, "completed");
2418
+ return Cn(await o, "completed");
2336
2419
  } catch (t) {
2337
- if (hn(t)) return {
2420
+ if (Tn(t)) return {
2338
2421
  utteranceId: "utt_interrupted",
2339
2422
  characterId: r.characterId ?? e.getActiveCharacterId(),
2340
2423
  status: "interrupted",
2341
2424
  durationMs: 0,
2342
2425
  transcript: r.text,
2343
- animation: qt("none")
2426
+ animation: rn("none")
2344
2427
  };
2345
- throw mn(t);
2428
+ throw wn(t);
2346
2429
  }
2347
2430
  },
2348
2431
  async play(i) {
2349
- if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), Xt(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
2432
+ if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), sn(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
2350
2433
  let a = i.queue ?? "append";
2351
- if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), Bt(i.audio)) {
2434
+ if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), Xt(i.audio)) {
2352
2435
  let e = i.audio.sampleRate ?? 24e3;
2353
2436
  return r.createUtterance({
2354
2437
  format: {
@@ -2364,7 +2447,7 @@ function _n(e) {
2364
2447
  }
2365
2448
  let o = e.getIframeHost();
2366
2449
  if (!o) throw new Q("Speech session is not attached.");
2367
- let s = await dn(i.audio, i.signal);
2450
+ let s = await xn(i.audio, i.signal);
2368
2451
  return o.speechPlay({
2369
2452
  source: s,
2370
2453
  characterId: i.characterId,
@@ -2376,13 +2459,13 @@ function _n(e) {
2376
2459
  },
2377
2460
  createUtterance(r) {
2378
2461
  e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
2379
- let i = Zt(r);
2462
+ let i = cn(r);
2380
2463
  if (r.track && r.track.kind !== "audio") throw new Q("createUtterance track must be an audio MediaStreamTrack.");
2381
2464
  let a = r.queue ?? "replace-active";
2382
2465
  if (a !== "replace-active" && a !== "replace-all") throw new Q("createUtterance queue must be replace-active or replace-all.");
2383
2466
  e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
2384
- let o = new gn({
2385
- id: fn(),
2467
+ let o = new En({
2468
+ id: Sn(),
2386
2469
  characterId: r.characterId ?? e.getActiveCharacterId(),
2387
2470
  format: i,
2388
2471
  queue: a,
@@ -2394,7 +2477,7 @@ function _n(e) {
2394
2477
  t === o && (t = null);
2395
2478
  }), r.track && (async () => {
2396
2479
  try {
2397
- if (await un({
2480
+ if (await bn({
2398
2481
  track: r.track,
2399
2482
  utterance: o,
2400
2483
  sampleRate: i.sampleRate,
@@ -2422,16 +2505,16 @@ function _n(e) {
2422
2505
  }
2423
2506
  //#endregion
2424
2507
  //#region src/v2/types/sessionInteraction.ts
2425
- function vn(e) {
2508
+ function On(e) {
2426
2509
  let t = e?.trim();
2427
2510
  return t === "full" || t === "face" || t === "medium" ? t : void 0;
2428
2511
  }
2429
2512
  //#endregion
2430
2513
  //#region src/v2/experience.ts
2431
- function yn(e) {
2514
+ function kn(e) {
2432
2515
  return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
2433
2516
  }
2434
- var bn = class e {
2517
+ var An = class e {
2435
2518
  bootstrap;
2436
2519
  conversationProcessor;
2437
2520
  iframeHost = null;
@@ -2446,16 +2529,16 @@ var bn = class e {
2446
2529
  attached = !1;
2447
2530
  pendingFit = null;
2448
2531
  closeHandlers = [];
2449
- eventRegistry = Pt();
2532
+ eventRegistry = Wt();
2450
2533
  readyEnvelope = null;
2451
2534
  startedEnvelope = null;
2452
2535
  conversationCache = [];
2453
2536
  speech;
2454
2537
  constructor(e) {
2455
- 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 = _n({
2538
+ 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 = Dn({
2456
2539
  getIframeHost: () => this.iframeHost,
2457
2540
  assertSessionStarted: () => this.assertSessionStarted(),
2458
- getCapabilities: () => xn(this.resolvedSession),
2541
+ getCapabilities: () => jn(this.resolvedSession),
2459
2542
  getActiveCharacterId: () => "character_unknown",
2460
2543
  onProcessorInterrupt: () => {
2461
2544
  this.processorAbortController?.abort(), this.processorAbortController = null;
@@ -2470,6 +2553,9 @@ var bn = class e {
2470
2553
  kind: "launch",
2471
2554
  launch: n,
2472
2555
  session: t.session,
2556
+ backdropId: t.backdropId,
2557
+ locationId: t.locationId,
2558
+ avatarId: t.avatarId,
2473
2559
  embedBaseUrl: t.embedBaseUrl,
2474
2560
  debug: t.debug,
2475
2561
  speechOnly: t.speechOnly,
@@ -2487,6 +2573,7 @@ var bn = class e {
2487
2573
  secondaryLocale: t.secondaryLocale,
2488
2574
  learningLocale: t.learningLocale,
2489
2575
  language: t.language,
2576
+ backdropId: t.backdropId,
2490
2577
  locationId: t.locationId,
2491
2578
  avatarId: t.avatarId,
2492
2579
  castSize: t.castSize,
@@ -2495,6 +2582,7 @@ var bn = class e {
2495
2582
  mode: t.mode,
2496
2583
  speechInputMode: t.speechInputMode,
2497
2584
  speechOnly: t.speechOnly,
2585
+ attribution: t.attribution,
2498
2586
  ui: t.ui,
2499
2587
  onStart: t.onStart,
2500
2588
  onUserTranscript: t.onUserTranscript,
@@ -2507,6 +2595,7 @@ var bn = class e {
2507
2595
  secondaryLocale: t.secondaryLocale,
2508
2596
  learningLocale: t.learningLocale,
2509
2597
  language: t.language,
2598
+ backdropId: t.backdropId,
2510
2599
  locationId: t.locationId,
2511
2600
  avatarId: t.avatarId,
2512
2601
  castSize: t.castSize,
@@ -2515,6 +2604,7 @@ var bn = class e {
2515
2604
  mode: t.mode,
2516
2605
  speechInputMode: t.speechInputMode,
2517
2606
  speechOnly: t.speechOnly,
2607
+ attribution: t.attribution,
2518
2608
  ui: t.ui,
2519
2609
  onStart: t.onStart,
2520
2610
  onUserTranscript: t.onUserTranscript,
@@ -2529,7 +2619,7 @@ var bn = class e {
2529
2619
  return null;
2530
2620
  }
2531
2621
  on(e, t) {
2532
- let n = Ft(this.eventRegistry, e, t);
2622
+ let n = Gt(this.eventRegistry, e, t);
2533
2623
  return e === "ready" && this.readyEnvelope && queueMicrotask(() => t(this.readyEnvelope)), e === "started" && this.startedEnvelope && queueMicrotask(() => t(this.startedEnvelope)), n;
2534
2624
  }
2535
2625
  async attach(e) {
@@ -2543,13 +2633,13 @@ var bn = class e {
2543
2633
  if (this.closed) throw Error("Session has ended.");
2544
2634
  if (this.attached && this.iframeHost) return this.createPlayerFacade();
2545
2635
  this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
2546
- let t = this.bootstrap.embedBaseUrl ?? Ot(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = kt(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, yn(e), this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.castSize), a = jt(i), o = null, s = new Promise((e) => {
2636
+ let t = this.bootstrap.embedBaseUrl ?? Lt(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = zt(t, n, r ? void 0 : Rt(this.bootstrap.backdropId, this.bootstrap.locationId), r ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, kn(e), this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.castSize), a = Vt(i), o = null, s = new Promise((e) => {
2547
2637
  o = e;
2548
2638
  }), c = null, l = new Promise((e) => {
2549
2639
  c = e;
2550
- }), u = wt((e) => {
2640
+ }), u = Nt((e) => {
2551
2641
  this.readyEnvelope ||= (this.resolvedSession = e, this.emitWrapped("ready", { session: e }));
2552
- }), d = this.bootstrap.onUserTranscript, f = Ct({
2642
+ }), d = this.bootstrap.onUserTranscript, f = Mt({
2553
2643
  container: e.container,
2554
2644
  src: i,
2555
2645
  playerOrigin: a,
@@ -2612,7 +2702,7 @@ var bn = class e {
2612
2702
  onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t)
2613
2703
  });
2614
2704
  this.iframeHost = f;
2615
- let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), at(this.bootstrap.sessionEndpoint, {
2705
+ let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), ut(this.bootstrap.sessionEndpoint, {
2616
2706
  experienceId: this.bootstrap.experienceId,
2617
2707
  locale: this.bootstrap.locale,
2618
2708
  secondaryLocale: this.bootstrap.secondaryLocale,
@@ -2621,15 +2711,17 @@ var bn = class e {
2621
2711
  mode: p.mode,
2622
2712
  speechInputMode: p.speechInputMode,
2623
2713
  speechOnly: this.bootstrap.speechOnly,
2714
+ attribution: this.bootstrap.attribution,
2624
2715
  signal: this.endpointAbortController.signal
2625
- })) : this.bootstrap.kind === "public" ? it(this.bootstrap.experienceId, {
2716
+ })) : this.bootstrap.kind === "public" ? lt(this.bootstrap.experienceId, {
2626
2717
  locale: this.bootstrap.locale,
2627
2718
  secondaryLocale: this.bootstrap.secondaryLocale,
2628
2719
  learningLocale: this.bootstrap.learningLocale,
2629
2720
  language: this.bootstrap.language,
2630
2721
  mode: p.mode,
2631
2722
  speechInputMode: p.speechInputMode,
2632
- speechOnly: this.bootstrap.speechOnly
2723
+ speechOnly: this.bootstrap.speechOnly,
2724
+ attribution: this.bootstrap.attribution
2633
2725
  }) : Promise.resolve(this.bootstrap.session ? {
2634
2726
  session: this.bootstrap.session,
2635
2727
  launch: this.bootstrap.launch
@@ -2644,7 +2736,7 @@ var bn = class e {
2644
2736
  f.postParentHello();
2645
2737
  let g = h?.launch ?? (this.bootstrap.kind === "launch" ? this.bootstrap.launch : null), _ = h?.session ?? (this.bootstrap.kind === "launch" ? this.bootstrap.session : void 0);
2646
2738
  if (!g) throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), Error("Session Launch response did not include a launch token.");
2647
- return this.launchToken = g, _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" && Xe(_), f.postLaunch(g, _, {
2739
+ return this.launchToken = g, _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" && tt(_), f.postLaunch(g, _, {
2648
2740
  startButton: e.startButton,
2649
2741
  showFeedback: e.showFeedback
2650
2742
  }), u.setValue(_)) : f.postLaunch(g, void 0, {
@@ -2678,11 +2770,16 @@ var bn = class e {
2678
2770
  this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
2679
2771
  }
2680
2772
  async setFit(e) {
2681
- let t = vn(e);
2773
+ let t = On(e);
2682
2774
  if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
2683
2775
  if (this.closed) throw Error("Session has ended.");
2684
2776
  this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
2685
2777
  }
2778
+ async conversion(e) {
2779
+ if (this.closed) throw Error("Session has ended.");
2780
+ if (!this.iframeHost) throw Error("conversion() requires attach() first.");
2781
+ await this.iframeHost.conversion(e);
2782
+ }
2686
2783
  getLastTurn() {
2687
2784
  if (this.conversationCache.length === 0) return [];
2688
2785
  let e = this.conversationCache[this.conversationCache.length - 1].turnId;
@@ -2692,7 +2789,7 @@ var bn = class e {
2692
2789
  this.close();
2693
2790
  }
2694
2791
  destroy() {
2695
- 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, Lt(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.attached = !1);
2792
+ 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, qt(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.attached = !1);
2696
2793
  }
2697
2794
  resolveMintInteraction() {
2698
2795
  return this.bootstrap.kind === "launch" ? {} : {
@@ -2704,8 +2801,8 @@ var bn = class e {
2704
2801
  return this.resolvedSession?.id ?? "";
2705
2802
  }
2706
2803
  emitWrapped(e, t) {
2707
- let n = Nt(e, this.getSessionId(), t);
2708
- return It(this.eventRegistry, e, n), n;
2804
+ let n = Ut(e, this.getSessionId(), t);
2805
+ return Kt(this.eventRegistry, e, n), n;
2709
2806
  }
2710
2807
  queueProcessorTurn(e) {
2711
2808
  if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
@@ -2714,7 +2811,7 @@ var bn = class e {
2714
2811
  let n = this.processorAbortController.signal;
2715
2812
  this.processorChain = this.processorChain.then(async () => {
2716
2813
  if (!n.aborted) try {
2717
- let r = await ct(t, {
2814
+ let r = await pt(t, {
2718
2815
  utteranceId: e.utteranceId,
2719
2816
  text: e.text,
2720
2817
  conversation: this.conversationCache,
@@ -2764,7 +2861,7 @@ var bn = class e {
2764
2861
  };
2765
2862
  }
2766
2863
  };
2767
- function xn(e) {
2864
+ function jn(e) {
2768
2865
  return e ? {
2769
2866
  textSpeech: e.capabilities.speech.output,
2770
2867
  externalSpeechAudio: e.capabilities.speech.externalAudio
@@ -2775,41 +2872,41 @@ function xn(e) {
2775
2872
  }
2776
2873
  //#endregion
2777
2874
  //#region src/widget/dockGeometry.ts
2778
- var Sn = "(min-width: 768px)", Cn = 24, wn = .5, Tn = 1200, En = .85, Dn = 9 / 16;
2779
- function On() {
2875
+ var Mn = "(min-width: 768px)", Nn = 24, Pn = .5, Fn = 1200, In = .85, Ln = 9 / 16;
2876
+ function Rn() {
2780
2877
  if (typeof window > "u") return 800;
2781
2878
  let e = window.screen?.availHeight;
2782
2879
  return typeof e == "number" && e > 0 ? e : window.innerHeight;
2783
2880
  }
2784
- function kn(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = Cn, r = typeof window < "u" ? On() : 800) {
2785
- let i = Math.max(160, Math.min(t - n * 2, t * En)), a = Math.max(120, e - n * 2), o = Math.min(r * wn, Tn, i), s = o * Dn;
2786
- return s > a && (s = a, o = s / Dn, o > i && (o = i, s = o * Dn)), {
2881
+ function zn(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = Nn, r = typeof window < "u" ? Rn() : 800) {
2882
+ let i = Math.max(160, Math.min(t - n * 2, t * In)), a = Math.max(120, e - n * 2), o = Math.min(r * Pn, Fn, i), s = o * Ln;
2883
+ return s > a && (s = a, o = s / Ln, o > i && (o = i, s = o * Ln)), {
2787
2884
  width: Math.round(s),
2788
2885
  height: Math.round(o)
2789
2886
  };
2790
2887
  }
2791
- function An(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = Cn) {
2888
+ function Bn(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = Nn) {
2792
2889
  return {
2793
2890
  left: Math.max(r, t - e.width - r),
2794
2891
  top: Math.max(r, n - e.height - r)
2795
2892
  };
2796
2893
  }
2797
- function jn(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = Cn) {
2894
+ function Vn(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = Nn) {
2798
2895
  let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
2799
2896
  return {
2800
2897
  left: Math.min(Math.max(a, e), o),
2801
2898
  top: Math.min(Math.max(a, t), s)
2802
2899
  };
2803
2900
  }
2804
- function Mn(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
2805
- return e(Sn).matches;
2901
+ function Hn(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
2902
+ return e(Mn).matches;
2806
2903
  }
2807
2904
  //#endregion
2808
2905
  //#region src/widget/mountExperienceWidget.ts
2809
- function Nn(e) {
2906
+ function Un(e) {
2810
2907
  return e === "bottom-right" || e === "bottom-left" ? e : "static";
2811
2908
  }
2812
- function Pn(e) {
2909
+ function Wn(e) {
2813
2910
  if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
2814
2911
  let t = typeof e == "string" ? e.trim() : "";
2815
2912
  return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
@@ -2817,10 +2914,10 @@ function Pn(e) {
2817
2914
  function $(e) {
2818
2915
  return e === "expanded" || e === "docked";
2819
2916
  }
2820
- var Fn = "<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>", In = "<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>", Ln = "<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>", Rn = "<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>";
2821
- function zn(e, t, n) {
2917
+ var Gn = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 0 0-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 0 0-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 0 0-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 0 0-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 0 0 1.066-2.573c-.94-1.543.826-3.31 2.37-2.37c1 .608 2.296.07 2.572-1.065\"/><path d=\"M9 12a3 3 0 1 0 6 0a3 3 0 0 0-6 0\"/></svg>", Kn = "<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>", qn = "<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>", Jn = "<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>";
2918
+ function Yn(e, t, n) {
2822
2919
  Oe(Ee);
2823
- let r = z({
2920
+ let r = ie({
2824
2921
  galleryThumb: t.galleryThumb,
2825
2922
  avatarImage: t.avatarImage,
2826
2923
  backgroundImage: t.backgroundImage,
@@ -2848,7 +2945,7 @@ function zn(e, t, n) {
2848
2945
  }
2849
2946
  return e.replaceChildren(i), n?.parallax === !1 ? () => {} : Te(i);
2850
2947
  }
2851
- function Bn(e) {
2948
+ function Xn(e) {
2852
2949
  return e.startButton ? {
2853
2950
  ...e.startButton,
2854
2951
  label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
@@ -2860,7 +2957,7 @@ function Bn(e) {
2860
2957
  variant: "primary"
2861
2958
  };
2862
2959
  }
2863
- function Vn(e) {
2960
+ function Zn(e) {
2864
2961
  let t = !1, n = () => {
2865
2962
  t || e();
2866
2963
  }, r = () => {
@@ -2880,12 +2977,12 @@ function Vn(e) {
2880
2977
  t = !0, window.removeEventListener("load", r), i?.();
2881
2978
  };
2882
2979
  }
2883
- function Hn(e, t) {
2980
+ function Qn(e, t) {
2884
2981
  Ne(je);
2885
2982
  let n = t.experienceId?.trim();
2886
2983
  if (!n) throw Error("ExperienceWidget requires experienceId.");
2887
- let r = t.prefetch ?? "onExpand", i = Nn(t.position), a = document.createElement("div");
2888
- 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", Pn(t.offset));
2984
+ let r = t.prefetch ?? "onExpand", i = Un(t.position), a = document.createElement("div");
2985
+ 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", Wn(t.offset));
2889
2986
  let o = document.createElement("button");
2890
2987
  o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
2891
2988
  let s = document.createElement("div");
@@ -2905,30 +3002,30 @@ function Hn(e, t) {
2905
3002
  let m = document.createElement("span");
2906
3003
  m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
2907
3004
  let h = document.createElement("button");
2908
- h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = Ln, h.setAttribute("aria-label", "Reduce");
3005
+ h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = qn, h.setAttribute("aria-label", "Reduce");
2909
3006
  let g = document.createElement("button");
2910
- g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = Fn, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
3007
+ g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = Gn, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
2911
3008
  let _ = document.createElement("button");
2912
- _.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = In, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
3009
+ _.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = Kn, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
2913
3010
  let v = document.createElement("div");
2914
3011
  v.className = "liforma-ew__stage";
2915
3012
  let y = document.createElement("div");
2916
3013
  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);
2917
- 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, re = null, I = !1, ie = new AbortController(), L = t.parallax !== !1, R = () => {
3014
+ let b = null, x = !1, S = !1, C = !1, w = !1, T = !1, E = !1, D = !1, O = 0, k = "", A = null, j = null, M = null, N = null, P = null, F = null, I = null, ee = 0, te = 0, ne = null, L = !1, re = new AbortController(), R = t.parallax !== !1, z = () => {
2918
3015
  let e = a.dataset.state;
2919
3016
  return e === "expanded" || e === "docked" || e === "collapsed" ? e : "collapsed";
2920
- }, z = () => {
2921
- j !== null && (clearTimeout(j), j = null);
3017
+ }, ie = () => {
3018
+ M !== null && (clearTimeout(M), M = null);
3019
+ }, ae = () => {
3020
+ N !== null && (clearTimeout(N), N = null), a.classList.remove("liforma-ew--layout-settling");
2922
3021
  }, B = () => {
2923
- M !== null && (clearTimeout(M), M = null), a.classList.remove("liforma-ew--layout-settling");
2924
- }, V = () => {
2925
3022
  for (let e of [
2926
3023
  f,
2927
3024
  l,
2928
3025
  p
2929
3026
  ]) e.style.removeProperty("left"), e.style.removeProperty("top"), e.style.removeProperty("width"), e.style.removeProperty("height"), e.style.removeProperty("right"), e.style.removeProperty("bottom");
2930
3027
  p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging");
2931
- }, ae = (e, t, n, r) => {
3028
+ }, V = (e, t, n, r) => {
2932
3029
  let i = (i) => {
2933
3030
  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";
2934
3031
  };
@@ -2936,43 +3033,43 @@ function Hn(e, t) {
2936
3033
  let a = p.offsetWidth || 120;
2937
3034
  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";
2938
3035
  }, oe = (e, t) => {
2939
- if (R() !== "docked") return;
2940
- let n = kn(), r = jn(e - te, t - ne, n);
2941
- N = r.left, P = r.top, ae(r.left, r.top, n.width, n.height);
3036
+ if (z() !== "docked") return;
3037
+ let n = zn(), r = Vn(e - ee, t - te, n);
3038
+ P = r.left, F = r.top, V(r.left, r.top, n.width, n.height);
2942
3039
  }, se = (e, t) => {
2943
- if (R() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
2944
- let n = kn(), r = N ?? f.getBoundingClientRect().left, i = P ?? f.getBoundingClientRect().top, a = jn(r + e, i + t, n);
2945
- N = a.left, P = a.top, ae(a.left, a.top, n.width, n.height);
3040
+ if (z() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
3041
+ let n = zn(), r = P ?? f.getBoundingClientRect().left, i = F ?? f.getBoundingClientRect().top, a = Vn(r + e, i + t, n);
3042
+ P = a.left, F = a.top, V(a.left, a.top, n.width, n.height);
2946
3043
  }, ce = (e) => {
2947
- re === "toolbar" && (F === null || e.pointerId !== F || (e.preventDefault(), oe(e.clientX, e.clientY)));
3044
+ ne === "toolbar" && (I === null || e.pointerId !== I || (e.preventDefault(), oe(e.clientX, e.clientY)));
2948
3045
  }, H = (e) => {
2949
- if (F === null || e && e.pointerId !== F) return;
2950
- let t = re;
2951
- F = null, re = null, p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging"), t === "toolbar" && I && (I = !1, window.removeEventListener("pointermove", ce), window.removeEventListener("pointerup", H), window.removeEventListener("pointercancel", H));
3046
+ if (I === null || e && e.pointerId !== I) return;
3047
+ let t = ne;
3048
+ I = null, ne = null, p.classList.remove("liforma-ew__toolbar--dragging"), a.classList.remove("liforma-ew--dock-dragging"), t === "toolbar" && L && (L = !1, window.removeEventListener("pointermove", ce), window.removeEventListener("pointerup", H), window.removeEventListener("pointercancel", H));
2952
3049
  }, le = (e, t, n) => {
2953
- if (S || R() !== "docked" || !Mn() || F !== null) return;
2954
- F = n, re = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
3050
+ if (S || z() !== "docked" || !Hn() || I !== null) return;
3051
+ I = n, ne = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
2955
3052
  let r = f.getBoundingClientRect();
2956
- te = e - r.left, ne = t - r.top, I || (I = !0, window.addEventListener("pointermove", ce), window.addEventListener("pointerup", H), window.addEventListener("pointercancel", H));
3053
+ ee = e - r.left, te = t - r.top, L || (L = !0, window.addEventListener("pointermove", ce), window.addEventListener("pointerup", H), window.addEventListener("pointercancel", H));
2957
3054
  }, U = (e) => {
2958
- if (S || R() !== "docked" || !Mn() || F !== null) return;
2959
- F = e.pointerId, re = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
3055
+ if (S || z() !== "docked" || !Hn() || I !== null) return;
3056
+ I = e.pointerId, ne = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
2960
3057
  let t = f.getBoundingClientRect();
2961
- N = t.left, P = t.top;
3058
+ P = t.left, F = t.top;
2962
3059
  }, ue = (e) => {
2963
- re === "player" && (F === null || e.pointerId !== F || se(e.dx, e.dy));
3060
+ ne === "player" && (I === null || e.pointerId !== I || se(e.dx, e.dy));
2964
3061
  }, de = (e) => {
2965
- re === "player" && (F === null || e.pointerId !== F || H());
3062
+ ne === "player" && (I === null || e.pointerId !== I || H());
2966
3063
  }, W = () => {
2967
- let e = Mn(), t = R();
3064
+ let e = Hn(), t = z();
2968
3065
  if (!e || t !== "expanded" && t !== "docked") {
2969
3066
  h.hidden = !0;
2970
3067
  return;
2971
3068
  }
2972
- h.hidden = !1, t === "docked" ? (h.innerHTML = Rn, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = Ln, h.setAttribute("aria-label", "Reduce"));
3069
+ h.hidden = !1, t === "docked" ? (h.innerHTML = Jn, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = qn, h.setAttribute("aria-label", "Reduce"));
2973
3070
  }, fe = (e) => {
2974
- let t = kn(), n = e && N !== null && P !== null ? jn(N, P, t) : An(t);
2975
- n = jn(n.left, n.top, t), N = n.left, P = n.top, ae(n.left, n.top, t.width, t.height), W();
3071
+ let t = zn(), n = e && P !== null && F !== null ? Vn(P, F, t) : Bn(t);
3072
+ n = Vn(n.left, n.top, t), P = n.left, F = n.top, V(n.left, n.top, t.width, t.height), W();
2976
3073
  }, pe = () => {
2977
3074
  a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
2978
3075
  requestAnimationFrame(() => {
@@ -2980,20 +3077,20 @@ function Hn(e, t) {
2980
3077
  });
2981
3078
  });
2982
3079
  }, me = (e) => {
2983
- if (B(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !E) {
3080
+ if (ae(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !D) {
2984
3081
  a.classList.remove("liforma-ew--layout-settling");
2985
3082
  return;
2986
3083
  }
2987
- M = setTimeout(() => {
2988
- if (M = null, S || !$(a.dataset.state)) {
3084
+ N = setTimeout(() => {
3085
+ if (N = null, S || !$(a.dataset.state)) {
2989
3086
  a.classList.remove("liforma-ew--layout-settling");
2990
3087
  return;
2991
3088
  }
2992
3089
  a.classList.remove("liforma-ew--layout-settling"), pe();
2993
3090
  }, 220);
2994
3091
  }, he = () => (a.classList.add("liforma-ew--session-concealing"), a.classList.remove("liforma-ew--session-revealed"), new Promise((e) => {
2995
- z(), j = setTimeout(() => {
2996
- j = null, a.classList.remove("liforma-ew--session-concealing"), e();
3092
+ ie(), M = setTimeout(() => {
3093
+ M = null, a.classList.remove("liforma-ew--session-concealing"), e();
2997
3094
  }, 280);
2998
3095
  })), ge = {
2999
3096
  galleryThumb: t.galleryThumb,
@@ -3014,25 +3111,25 @@ function Hn(e, t) {
3014
3111
  }
3015
3112
  c.hidden = !1, c.textContent = e, s.contains(c) || s.append(c);
3016
3113
  }, ye = () => {
3017
- ee = !0, o.disabled = !1, ve(null), r === "onExpand" && t.onPrefetchReady?.();
3114
+ C = !0, o.disabled = !1, ve(null), r === "onExpand" && t.onPrefetchReady?.();
3018
3115
  }, G = () => {
3019
- C = !0, a.dataset.warm = "true", l.hidden = !1, E || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
3116
+ w = !0, a.dataset.warm = "true", l.hidden = !1, D || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
3020
3117
  }, be = (e) => {
3021
- k?.(), k = null;
3022
- let t = zn(s, e, { parallax: L });
3023
- return t ? (k = t, !0) : !1;
3118
+ A?.(), A = null;
3119
+ let t = Yn(s, e, { parallax: R });
3120
+ return t ? (A = t, !0) : !1;
3024
3121
  }, K = () => {
3025
3122
  if (be(ge)) {
3026
3123
  ye();
3027
3124
  return;
3028
3125
  }
3029
- ve("Loading…"), ze(n, { signal: ie.signal }).then((e) => {
3126
+ ve("Loading…"), ze(n, { signal: re.signal }).then((e) => {
3030
3127
  if (!S) {
3031
3128
  if (!be({ galleryThumb: e.galleryThumb })) throw Error("Experience preview is missing gallery thumb images.");
3032
3129
  ye();
3033
3130
  }
3034
3131
  }).catch((e) => {
3035
- if (S || ie.signal.aborted) return;
3132
+ if (S || re.signal.aborted) return;
3036
3133
  let n = e instanceof Error ? e : Error(String(e));
3037
3134
  ve("Preview unavailable"), o.disabled = !0, t.onError?.(n), console.error("[ExperienceWidget]", n);
3038
3135
  });
@@ -3048,59 +3145,59 @@ function Hn(e, t) {
3048
3145
  ...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
3049
3146
  }), Se = () => ({
3050
3147
  ...t.fit ? { fit: t.fit } : {},
3051
- startButton: Bn(t),
3148
+ startButton: Xn(t),
3052
3149
  ...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback }
3053
3150
  }), q = (e = !0) => {
3054
- o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), V(), a.dataset.state = "expanded", _e(null), typeof document < "u" && (O = document.body.style.overflow, document.body.style.overflow = "hidden"), W(), e && t.onExpanded?.();
3151
+ o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), B(), a.dataset.state = "expanded", _e(null), typeof document < "u" && (k = document.body.style.overflow, document.body.style.overflow = "hidden"), W(), e && t.onExpanded?.();
3055
3152
  }, Ce = () => {
3056
- o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked", _e(null), typeof document < "u" && (document.body.style.overflow = O), fe(!0), W(), b?.setWidgetChrome("docked");
3153
+ o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked", _e(null), typeof document < "u" && (document.body.style.overflow = k), fe(!0), W(), b?.setWidgetChrome("docked");
3057
3154
  }, we = (e) => {
3058
3155
  e.on("started", () => {
3059
- S || (E = !0, a.dataset.live = "true", _e(null), t.onStarted?.(), $(a.dataset.state) && pe());
3156
+ S || (D = !0, a.dataset.live = "true", _e(null), t.onStarted?.(), $(a.dataset.state) && pe());
3060
3157
  }), e.on("feedback", (e) => {
3061
3158
  S || t.onFeedback?.(e);
3062
3159
  }), e.on("feedbackFailed", (e) => {
3063
3160
  S || t.onFeedbackFailed?.(e);
3064
3161
  });
3065
3162
  }, Te = () => {
3066
- B(), u.hidden = !0, p.hidden = !0, V(), 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), _e(null), typeof document < "u" && (document.body.style.overflow = O), W();
3163
+ ae(), u.hidden = !0, p.hidden = !0, B(), a.dataset.state = "collapsed", a.classList.remove("liforma-ew--session-revealed"), a.classList.remove("liforma-ew--session-concealing"), g.setAttribute("aria-pressed", "false"), o.hidden = !1, o.tabIndex = 0, o.removeAttribute("aria-hidden"), C && (o.disabled = !1), _e(null), typeof document < "u" && (document.body.style.overflow = k), W();
3067
3164
  }, Ee = () => {
3068
- z(), B(), D += 1, x = !1, C = !1, w = !1, T = !1, E = !1;
3165
+ ie(), ae(), O += 1, x = !1, w = !1, T = !1, E = !1, D = !1;
3069
3166
  let e = b;
3070
3167
  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");
3071
3168
  }, De = () => {
3072
3169
  if (!S && $(a.dataset.state)) {
3073
- if (H(), x = !1, b && T) {
3170
+ if (H(), x = !1, b && E) {
3074
3171
  let e = b;
3075
3172
  (async () => {
3076
- E && (await he(), S || b !== e) || (C && e.setWidgetChrome("collapsed"), Te(), E ? (a.dataset.live = "true", o.tabIndex = 0, o.removeAttribute("aria-hidden"), o.disabled = !1) : C && G(), t.onCollapsed?.(), t.onClose?.());
3173
+ D && (await he(), S || b !== e) || (w && e.setWidgetChrome("collapsed"), Te(), D ? (a.dataset.live = "true", o.tabIndex = 0, o.removeAttribute("aria-hidden"), o.disabled = !1) : w && G(), t.onCollapsed?.(), t.onClose?.());
3077
3174
  })();
3078
3175
  return;
3079
3176
  }
3080
3177
  Ee(), Te(), t.onCollapsed?.(), t.onClose?.();
3081
3178
  }
3082
3179
  }, Oe = () => {
3083
- S || Mn() && R() === "expanded" && me(() => {
3180
+ S || Hn() && z() === "expanded" && me(() => {
3084
3181
  Ce();
3085
3182
  });
3086
3183
  }, ke = () => {
3087
- S || R() === "docked" && (H(), me(() => {
3088
- V(), q(!1), b?.setWidgetChrome("expanded");
3184
+ S || z() === "docked" && (H(), me(() => {
3185
+ B(), q(!1), b?.setWidgetChrome("expanded");
3089
3186
  }));
3090
3187
  }, Ae = () => {
3091
- !b || !E || (z(), a.classList.remove("liforma-ew--session-revealed"), q(), b.setWidgetChrome("expanded"), x = !1, pe());
3188
+ !b || !D || (ie(), a.classList.remove("liforma-ew--session-revealed"), q(), b.setWidgetChrome("expanded"), x = !1, pe());
3092
3189
  }, Me = () => {
3093
- !b || !T || E || (z(), a.classList.remove("liforma-ew--session-revealed"), q(), x = !1, C || b.setWidgetChrome("expanded"));
3190
+ !b || !E || D || (ie(), a.classList.remove("liforma-ew--session-revealed"), q(), x = !1, w || b.setWidgetChrome("expanded"));
3094
3191
  }, Pe = (e) => {
3095
- S || e !== D && !E || (z(), a.classList.remove("liforma-ew--session-revealed"), q(), x = !1, E && pe());
3192
+ S || e !== O && !D || (ie(), a.classList.remove("liforma-ew--session-revealed"), q(), x = !1, D && pe());
3096
3193
  }, Fe = () => {
3097
- if (S || w || C || b || $(a.dataset.state)) return;
3098
- w = !0;
3099
- let e = D;
3194
+ if (S || T || w || b || $(a.dataset.state)) return;
3195
+ T = !0;
3196
+ let e = O;
3100
3197
  l.hidden = !1, (async () => {
3101
3198
  try {
3102
- let t = await bn.startSession(xe());
3103
- if (S || e !== D) {
3199
+ let t = await An.startSession(xe());
3200
+ if (S || e !== O) {
3104
3201
  t.destroy();
3105
3202
  return;
3106
3203
  }
@@ -3109,7 +3206,7 @@ function Hn(e, t) {
3109
3206
  container: l,
3110
3207
  ...Se(),
3111
3208
  onWidgetReady: () => {
3112
- S || e !== D || (w = !1, T = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") : G());
3209
+ S || e !== O || (T = !1, E = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") : G());
3113
3210
  },
3114
3211
  onWidgetExpand: () => {
3115
3212
  Pe(e);
@@ -3130,7 +3227,7 @@ function Hn(e, t) {
3130
3227
  S || e === "error" && $(a.dataset.state) && _e("Could not load the experience.");
3131
3228
  }
3132
3229
  });
3133
- if (S || e !== D) {
3230
+ if (S || e !== O) {
3134
3231
  t.destroy(), b === t && (b = null);
3135
3232
  return;
3136
3233
  }
@@ -3138,28 +3235,28 @@ function Hn(e, t) {
3138
3235
  S || De();
3139
3236
  });
3140
3237
  } catch (n) {
3141
- if (S || e !== D) return;
3142
- w = !1, l.hidden = !0, l.replaceChildren(), b = null;
3238
+ if (S || e !== O) return;
3239
+ T = !1, l.hidden = !0, l.replaceChildren(), b = null;
3143
3240
  let r = n instanceof Error ? n : Error(String(n));
3144
3241
  t.onError?.(r), console.error("[ExperienceWidget] warm prefetch failed", r);
3145
3242
  }
3146
3243
  })();
3147
3244
  }, Ie = () => {
3148
- if (S || x || !ee || $(a.dataset.state)) return;
3149
- if (b && E) {
3245
+ if (S || x || !C || $(a.dataset.state)) return;
3246
+ if (b && D) {
3150
3247
  Ae();
3151
3248
  return;
3152
3249
  }
3153
- if (b && T) {
3250
+ if (b && E) {
3154
3251
  Me();
3155
3252
  return;
3156
3253
  }
3157
- let e = ++D;
3158
- 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 () => {
3254
+ let e = ++O;
3255
+ x = !0, w = !1, T = !1, E = !1, D = !1, delete a.dataset.warm, delete a.dataset.live, l.hidden = !0, l.replaceChildren(), b &&= (b.destroy(), null), (async () => {
3159
3256
  try {
3160
3257
  q();
3161
- let t = await bn.startSession(xe());
3162
- if (S || e !== D) {
3258
+ let t = await An.startSession(xe());
3259
+ if (S || e !== O) {
3163
3260
  t.destroy();
3164
3261
  return;
3165
3262
  }
@@ -3183,68 +3280,68 @@ function Hn(e, t) {
3183
3280
  S || (e === "error" ? _e("Could not load the experience.") : $(a.dataset.state) && _e(null));
3184
3281
  }
3185
3282
  });
3186
- if (S || e !== D) {
3283
+ if (S || e !== O) {
3187
3284
  t.destroy(), b === t && (b = null);
3188
3285
  return;
3189
3286
  }
3190
- T = !0, t.setWidgetChrome("expanded"), n.on("close", () => {
3287
+ E = !0, t.setWidgetChrome("expanded"), n.on("close", () => {
3191
3288
  S || De();
3192
3289
  });
3193
3290
  } catch (n) {
3194
- if (S || e !== D) return;
3291
+ if (S || e !== O) return;
3195
3292
  let r = n instanceof Error ? n : Error(String(n));
3196
3293
  _e(r.message), t.onError?.(r), console.error("[ExperienceWidget]", r);
3197
3294
  } finally {
3198
- e === D && (x = !1);
3295
+ e === O && (x = !1);
3199
3296
  }
3200
3297
  })();
3201
3298
  }, Le = () => {
3202
3299
  if (!(S || $(a.dataset.state))) {
3203
- if (b && E) {
3300
+ if (b && D) {
3204
3301
  Ae();
3205
3302
  return;
3206
3303
  }
3207
- if (b && T) {
3304
+ if (b && E) {
3208
3305
  Me();
3209
3306
  return;
3210
3307
  }
3211
- if (w || b) {
3308
+ if (T || b) {
3212
3309
  q();
3213
3310
  return;
3214
3311
  }
3215
3312
  Ie();
3216
3313
  }
3217
3314
  }, Re = (e) => {
3218
- if (e.stopPropagation(), R() === "expanded") {
3315
+ if (e.stopPropagation(), z() === "expanded") {
3219
3316
  Oe();
3220
3317
  return;
3221
3318
  }
3222
- R() === "docked" && ke();
3319
+ z() === "docked" && ke();
3223
3320
  }, J = (e) => {
3224
3321
  g.setAttribute("aria-pressed", e ? "true" : "false");
3225
3322
  }, Be = (e) => {
3226
3323
  e.stopPropagation(), $(a.dataset.state) && b?.toggleAudioSettings();
3227
3324
  }, Ve = (e) => {
3228
- R() === "docked" && Mn() && (e.target?.closest("button") || (e.preventDefault(), le(e.clientX, e.clientY, e.pointerId)));
3325
+ z() === "docked" && Hn() && (e.target?.closest("button") || (e.preventDefault(), le(e.clientX, e.clientY, e.pointerId)));
3229
3326
  }, He = (e) => {
3230
3327
  e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), De());
3231
3328
  }, Ue = () => {
3232
3329
  if (!S) {
3233
- if (R() === "docked") {
3234
- if (!Mn()) {
3330
+ if (z() === "docked") {
3331
+ if (!Hn()) {
3235
3332
  ke();
3236
3333
  return;
3237
3334
  }
3238
- E ? me(() => {
3335
+ D ? me(() => {
3239
3336
  fe(!0);
3240
3337
  }) : fe(!0);
3241
3338
  return;
3242
3339
  }
3243
3340
  W();
3244
3341
  }
3245
- }, We = typeof window < "u" ? window.matchMedia(Sn) : null, Y = () => {
3342
+ }, Y = typeof window < "u" ? window.matchMedia(Mn) : null, We = () => {
3246
3343
  if (!S) {
3247
- if (R() === "docked" && !Mn()) {
3344
+ if (z() === "docked" && !Hn()) {
3248
3345
  ke();
3249
3346
  return;
3250
3347
  }
@@ -3253,9 +3350,9 @@ function Hn(e, t) {
3253
3350
  };
3254
3351
  return o.addEventListener("click", Le), d.addEventListener("click", De), _.addEventListener("click", (e) => {
3255
3352
  e.stopPropagation(), De();
3256
- }), h.addEventListener("click", Re), g.addEventListener("click", Be), p.addEventListener("pointerdown", Ve), window.addEventListener("keydown", He), window.addEventListener("resize", Ue), We?.addEventListener("change", Y), K(), W(), r === "eager" ? queueMicrotask(() => {
3353
+ }), h.addEventListener("click", Re), g.addEventListener("click", Be), p.addEventListener("pointerdown", Ve), window.addEventListener("keydown", He), window.addEventListener("resize", Ue), Y?.addEventListener("change", We), K(), W(), r === "eager" ? queueMicrotask(() => {
3257
3354
  S || Fe();
3258
- }) : r === "idle" && (A = Vn(() => {
3355
+ }) : r === "idle" && (j = Zn(() => {
3259
3356
  S || Fe();
3260
3357
  })), {
3261
3358
  root: a,
@@ -3271,18 +3368,18 @@ function Hn(e, t) {
3271
3368
  Fe();
3272
3369
  },
3273
3370
  destroy() {
3274
- S || (S = !0, H(), A?.(), A = null, ie.abort(), k?.(), k = null, window.removeEventListener("keydown", He), window.removeEventListener("resize", Ue), We?.removeEventListener("change", Y), Ee(), Te(), e.replaceChildren());
3371
+ S || (S = !0, H(), j?.(), j = null, re.abort(), A?.(), A = null, window.removeEventListener("keydown", He), window.removeEventListener("resize", Ue), Y?.removeEventListener("change", We), Ee(), Te(), e.replaceChildren());
3275
3372
  }
3276
3373
  };
3277
3374
  }
3278
3375
  //#endregion
3279
3376
  //#region src/react/ExperienceWidget.tsx
3280
- function Un(e) {
3281
- let t = o(null), { experienceId: r, alt: i, galleryThumb: a, avatarImage: s, backgroundImage: c, foregroundImage: l, fallbackImage: u, prefetch: f = "onExpand", parallax: p = !0, position: m = "static", offset: h, sessionEndpoint: g, language: _, mode: v, speechInputMode: y, speechOnly: b, fit: x, embedBaseUrl: S, expandedMaxWidth: ee, expandedMaxHeight: C, startButtonLabel: w, startButton: T, showFeedback: E, className: D = "", onExpanded: O, onCollapsed: k, onStarted: A, onClose: j, onError: M, onPrefetchReady: N, onFeedback: P, onFeedbackFailed: F } = e, te = m === "bottom-right" || m === "bottom-left";
3377
+ function $n(e) {
3378
+ let t = o(null), { experienceId: r, alt: i, galleryThumb: a, avatarImage: s, backgroundImage: c, foregroundImage: l, fallbackImage: u, prefetch: f = "onExpand", parallax: p = !0, position: m = "static", offset: h, sessionEndpoint: g, language: _, mode: v, speechInputMode: y, speechOnly: b, fit: x, embedBaseUrl: S, expandedMaxWidth: C, expandedMaxHeight: w, startButtonLabel: T, startButton: E, showFeedback: D, className: O = "", onExpanded: k, onCollapsed: A, onStarted: j, onClose: M, onError: N, onPrefetchReady: P, onFeedback: F, onFeedbackFailed: I } = e, ee = m === "bottom-right" || m === "bottom-left";
3282
3379
  return n(() => {
3283
3380
  let e = t.current;
3284
3381
  if (!e || !r.trim()) return;
3285
- let n = Hn(e, {
3382
+ let n = Qn(e, {
3286
3383
  experienceId: r,
3287
3384
  alt: i,
3288
3385
  galleryThumb: a,
@@ -3301,19 +3398,19 @@ function Un(e) {
3301
3398
  speechOnly: b,
3302
3399
  fit: x,
3303
3400
  embedBaseUrl: S,
3304
- expandedMaxWidth: ee,
3305
- expandedMaxHeight: C,
3306
- startButtonLabel: w,
3307
- startButton: T,
3308
- showFeedback: E,
3309
- onFeedback: P,
3310
- onFeedbackFailed: F,
3311
- onExpanded: O,
3312
- onCollapsed: k,
3313
- onStarted: A,
3314
- onClose: j,
3315
- onError: M,
3316
- onPrefetchReady: N
3401
+ expandedMaxWidth: C,
3402
+ expandedMaxHeight: w,
3403
+ startButtonLabel: T,
3404
+ startButton: E,
3405
+ showFeedback: D,
3406
+ onFeedback: F,
3407
+ onFeedbackFailed: I,
3408
+ onExpanded: k,
3409
+ onCollapsed: A,
3410
+ onStarted: j,
3411
+ onClose: M,
3412
+ onError: N,
3413
+ onPrefetchReady: P
3317
3414
  });
3318
3415
  return () => n.destroy();
3319
3416
  }, [
@@ -3335,23 +3432,23 @@ function Un(e) {
3335
3432
  b,
3336
3433
  x,
3337
3434
  S,
3338
- ee,
3339
3435
  C,
3340
3436
  w,
3341
3437
  T,
3342
3438
  E,
3343
- P,
3439
+ D,
3344
3440
  F,
3345
- O,
3441
+ I,
3346
3442
  k,
3347
3443
  A,
3348
3444
  j,
3349
3445
  M,
3350
- N
3446
+ N,
3447
+ P
3351
3448
  ]), /* @__PURE__ */ d("div", {
3352
3449
  ref: t,
3353
- className: D,
3354
- style: te ? { display: "contents" } : {
3450
+ className: O,
3451
+ style: ee ? { display: "contents" } : {
3355
3452
  width: "100%",
3356
3453
  height: "100%",
3357
3454
  minHeight: "inherit"
@@ -3359,6 +3456,6 @@ function Un(e) {
3359
3456
  });
3360
3457
  }
3361
3458
  //#endregion
3362
- export { ne as Experience, Ae as ExperienceThumbnail, Un as ExperienceWidget };
3459
+ export { te as Experience, Ae as ExperienceThumbnail, $n as ExperienceWidget };
3363
3460
 
3364
3461
  //# sourceMappingURL=index.js.map