@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
package/dist/npm/index.js CHANGED
@@ -128,20 +128,20 @@ function S(e) {
128
128
  }
129
129
  //#endregion
130
130
  //#region src/thumbnail/lazyLoad.ts
131
- function ee() {
131
+ function C() {
132
132
  return g() ? "96px 0px" : "280px 0px";
133
133
  }
134
- function C(e) {
134
+ function w(e) {
135
135
  let t = e.trim().split(/\s+/)[0] ?? "0px", n = Number.parseFloat(t);
136
136
  return Number.isFinite(n) ? Math.abs(n) : 280;
137
137
  }
138
- function w(e, t) {
138
+ function T(e, t) {
139
139
  if (typeof window > "u") return !1;
140
140
  let n = e.getBoundingClientRect();
141
141
  return n.bottom >= -t && n.top <= window.innerHeight + t;
142
142
  }
143
- function T(e, t) {
144
- let { onVisibleChange: n } = t, r = t.rootMargin ?? ee(), i = C(r), a = !1, o = !1, s = null, c = () => {
143
+ function E(e, t) {
144
+ let { onVisibleChange: n } = t, r = t.rootMargin ?? C(), i = w(r), a = !1, o = !1, s = null, c = () => {
145
145
  o || (s?.(), s = S(() => {
146
146
  s = null, o = !0, n(!0);
147
147
  }));
@@ -164,11 +164,11 @@ function T(e, t) {
164
164
  rootMargin: r,
165
165
  threshold: 0
166
166
  });
167
- return u.observe(e), w(e, i) && l(!0), () => {
167
+ return u.observe(e), T(e, i) && l(!0), () => {
168
168
  s?.(), s = null, u.disconnect();
169
169
  };
170
170
  }
171
- function E(e, t) {
171
+ function D(e, t) {
172
172
  let n = () => t();
173
173
  return e.complete ? queueMicrotask(n) : (e.addEventListener("load", n, { once: !0 }), e.addEventListener("error", n, { once: !0 })), () => {
174
174
  e.removeEventListener("load", n), e.removeEventListener("error", n);
@@ -176,40 +176,40 @@ function E(e, t) {
176
176
  }
177
177
  //#endregion
178
178
  //#region src/thumbnail/scrollParallax.ts
179
- function D() {
179
+ function O() {
180
180
  return typeof window > "u" || window.matchMedia("(prefers-reduced-motion: reduce)").matches ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
181
181
  }
182
- function O(e, t) {
182
+ function k(e, t) {
183
183
  return ((e.top + e.height / 2) / Math.max(t, 1) - .5) * 2;
184
184
  }
185
- var k = /* @__PURE__ */ new Set(), A = !1, j = 0;
186
- function M() {
187
- if (j = 0, k.size === 0 || typeof window > "u") return;
185
+ var A = /* @__PURE__ */ new Set(), j = !1, M = 0;
186
+ function ee() {
187
+ if (M = 0, A.size === 0 || typeof window > "u") return;
188
188
  let e = window.innerHeight;
189
- for (let t of k) {
189
+ for (let t of A) {
190
190
  if (t.pointerActive?.()) continue;
191
191
  let n = t.element.getBoundingClientRect();
192
- n.bottom < -64 || n.top > e + 64 || t.onParallax(O(n, e));
192
+ n.bottom < -64 || n.top > e + 64 || t.onParallax(k(n, e));
193
193
  }
194
194
  }
195
195
  function N() {
196
- j === 0 && (j = requestAnimationFrame(M));
196
+ M === 0 && (M = requestAnimationFrame(ee));
197
197
  }
198
198
  function P() {
199
- A || typeof window > "u" || (A = !0, window.addEventListener("scroll", N, { passive: !0 }), window.addEventListener("resize", N, { passive: !0 }));
199
+ j || typeof window > "u" || (j = !0, window.addEventListener("scroll", N, { passive: !0 }), window.addEventListener("resize", N, { passive: !0 }));
200
200
  }
201
201
  function F() {
202
- k.size > 0 || !A || typeof window > "u" || (A = !1, j !== 0 && (cancelAnimationFrame(j), j = 0), window.removeEventListener("scroll", N), window.removeEventListener("resize", N));
202
+ A.size > 0 || !j || typeof window > "u" || (j = !1, M !== 0 && (cancelAnimationFrame(M), M = 0), window.removeEventListener("scroll", N), window.removeEventListener("resize", N));
203
203
  }
204
204
  function te(e, t) {
205
- if (!D()) return () => {};
205
+ if (!O()) return () => {};
206
206
  let n = {
207
207
  element: e,
208
208
  onParallax: t.onParallax,
209
209
  pointerActive: t.pointerActive
210
210
  };
211
- return k.add(n), P(), n.pointerActive?.() || t.onParallax(O(e.getBoundingClientRect(), window.innerHeight)), () => {
212
- k.delete(n), F();
211
+ return A.add(n), P(), n.pointerActive?.() || t.onParallax(k(e.getBoundingClientRect(), window.innerHeight)), () => {
212
+ A.delete(n), F();
213
213
  };
214
214
  }
215
215
  //#endregion
@@ -231,7 +231,7 @@ function ne(e) {
231
231
  a = !0, e.pointerType === "mouse" && (r = !0), o();
232
232
  }, u = () => {
233
233
  let s = a;
234
- a = !1, r = !1, i && s ? (t = O(e.getBoundingClientRect(), window.innerHeight), n = 0) : i || (t = 0, n = 0), o();
234
+ a = !1, r = !1, i && s ? (t = k(e.getBoundingClientRect(), window.innerHeight), n = 0) : i || (t = 0, n = 0), o();
235
235
  }, d = (e) => {
236
236
  e.pointerType === "mouse" && (r = !0, o());
237
237
  }, f = () => {
@@ -349,20 +349,58 @@ function fe(e, t, n) {
349
349
  });
350
350
  }
351
351
  //#endregion
352
+ //#region src/v2/api/captureAttribution.ts
353
+ var V = 128, pe = /[\u0000-\u001f\u007f]/g;
354
+ function H(e) {
355
+ if (!e) return;
356
+ let t = e.replace(pe, "").trim();
357
+ if (t) return t.slice(0, V);
358
+ }
359
+ function me(e) {
360
+ let t = new URLSearchParams((e ?? "").startsWith("?") ? (e ?? "").slice(1) : e ?? "");
361
+ return {
362
+ ...H(t.get("utm_source")) ? { utmSource: H(t.get("utm_source")) } : {},
363
+ ...H(t.get("utm_medium")) ? { utmMedium: H(t.get("utm_medium")) } : {},
364
+ ...H(t.get("utm_campaign")) ? { utmCampaign: H(t.get("utm_campaign")) } : {},
365
+ ...H(t.get("utm_content")) ? { utmContent: H(t.get("utm_content")) } : {},
366
+ ...H(t.get("utm_term")) ? { utmTerm: H(t.get("utm_term")) } : {}
367
+ };
368
+ }
369
+ function he(e) {
370
+ if (e === !1) return;
371
+ if (e && typeof e == "object") {
372
+ let t = {
373
+ ...H(e.utmSource) ? { utmSource: H(e.utmSource) } : {},
374
+ ...H(e.utmMedium) ? { utmMedium: H(e.utmMedium) } : {},
375
+ ...H(e.utmCampaign) ? { utmCampaign: H(e.utmCampaign) } : {},
376
+ ...H(e.utmContent) ? { utmContent: H(e.utmContent) } : {},
377
+ ...H(e.utmTerm) ? { utmTerm: H(e.utmTerm) } : {},
378
+ ...H(e.referrer) ? { referrer: H(e.referrer) } : {}
379
+ };
380
+ return Object.keys(t).length ? t : void 0;
381
+ }
382
+ if (typeof window > "u") return;
383
+ let t = me(window.location?.search), n = H(document.referrer || void 0), r = {
384
+ ...t,
385
+ ...n ? { referrer: n } : {}
386
+ };
387
+ return Object.keys(r).length ? r : void 0;
388
+ }
389
+ //#endregion
352
390
  //#region src/v2/api/sessionEndpointRequest.ts
353
- function V(e) {
391
+ function U(e) {
354
392
  let t = e.locale?.trim();
355
393
  if (t) return t;
356
394
  let n = e.language?.trim();
357
395
  if (n) return n;
358
396
  if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
359
397
  }
360
- function pe(e) {
398
+ function ge(e) {
361
399
  let t = e.secondaryLocale?.trim(), n = e.learningLocale?.trim();
362
400
  if (t && n && t !== n) throw Error("secondaryLocale and learningLocale disagree; pass only one or make them equal.");
363
401
  return t || n || void 0;
364
402
  }
365
- function me(e, t) {
403
+ function _e(e, t) {
366
404
  let n = e.trim();
367
405
  if (!n) throw Error("sessionEndpoint must not be empty.");
368
406
  if (typeof location > "u") throw Error("sessionEndpoint is only available in a browser.");
@@ -370,7 +408,7 @@ function me(e, t) {
370
408
  if (r.origin !== location.origin) throw Error("sessionEndpoint must be same-origin.");
371
409
  let i = t.experienceId.trim();
372
410
  if (!i) throw Error("sessionEndpoint requires experienceId.");
373
- let a = V(t), o = pe(t), s = t.idempotencyKey?.trim();
411
+ let a = U(t), o = ge(t), s = t.idempotencyKey?.trim();
374
412
  return {
375
413
  url: r.toString(),
376
414
  init: {
@@ -387,23 +425,27 @@ function me(e, t) {
387
425
  ...o ? { secondaryLocale: o } : {},
388
426
  ...t.mode ? { mode: t.mode } : {},
389
427
  ...t.speechInputMode ? { speechInputMode: t.speechInputMode } : {},
390
- ...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly }
428
+ ...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
429
+ ...(() => {
430
+ let e = he(t.attribution);
431
+ return e ? { attribution: e } : {};
432
+ })()
391
433
  })
392
434
  }
393
435
  };
394
436
  }
395
437
  //#endregion
396
438
  //#region src/v2/types/sessionLaunch.ts
397
- function H(e) {
439
+ function W(e) {
398
440
  return !!e && typeof e == "object" && !Array.isArray(e);
399
441
  }
400
- function U(e) {
442
+ function G(e) {
401
443
  return typeof e == "boolean";
402
444
  }
403
- function W(e) {
404
- if (!H(e)) return null;
445
+ function ve(e) {
446
+ if (!W(e)) return null;
405
447
  let t = e.speech, n = e.conversation, r = e.avatar, i = e.tools;
406
- return !H(t) || !H(n) || !H(r) || !H(i) || !U(t.input) || !U(t.output) || !U(t.externalAudio) || !U(n.managed) || !U(r.enabled) || !U(i.enabled) ? null : {
448
+ return !W(t) || !W(n) || !W(r) || !W(i) || !G(t.input) || !G(t.output) || !G(t.externalAudio) || !G(n.managed) || !G(r.enabled) || !G(i.enabled) ? null : {
407
449
  speech: {
408
450
  input: t.input,
409
451
  output: t.output,
@@ -414,8 +456,8 @@ function W(e) {
414
456
  tools: { enabled: i.enabled }
415
457
  };
416
458
  }
417
- function he(e) {
418
- return !H(e) || !U(e.avatar) || !U(e.speechInput) || !U(e.speechOutput) || !U(e.tools) || !U(e.externalAudio) ? null : {
459
+ function K(e) {
460
+ return !W(e) || !G(e.avatar) || !G(e.speechInput) || !G(e.speechOutput) || !G(e.tools) || !G(e.externalAudio) ? null : {
419
461
  speech: {
420
462
  input: e.speechInput,
421
463
  output: e.speechOutput,
@@ -426,12 +468,12 @@ function he(e) {
426
468
  tools: { enabled: e.tools }
427
469
  };
428
470
  }
429
- function ge(e) {
430
- return W(e) ?? he(e);
471
+ function ye(e) {
472
+ return ve(e) ?? K(e);
431
473
  }
432
- function _e(e) {
433
- if (!H(e)) throw Error("Session Launch response is missing session.");
434
- let t = typeof e.id == "string" ? e.id.trim() : "", n = typeof e.experienceId == "string" ? e.experienceId.trim() : "", r = typeof e.experienceRevisionId == "string" ? e.experienceRevisionId.trim() : "", i = typeof e.expiresAt == "string" ? e.expiresAt.trim() : "", a = typeof e.locale == "string" ? e.locale.trim() : "", o = typeof e.secondaryLocale == "string" && e.secondaryLocale.trim() ? e.secondaryLocale.trim() : void 0, s = e.mode === "conversation" || e.mode === "presenter" ? e.mode : null, c = ge(e.capabilities), l = ve(e.localeVoiceFallbacks), u = e.status === "active" || e.status === "ended" ? e.status : void 0, d = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt.trim() : void 0;
474
+ function be(e) {
475
+ if (!W(e)) throw Error("Session Launch response is missing session.");
476
+ 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 = ye(e.capabilities), l = xe(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;
435
477
  if (!t || !n || !r || !i || !a || !s || !c) throw Error("Session Launch response has an invalid session object.");
436
478
  return {
437
479
  id: t,
@@ -447,11 +489,11 @@ function _e(e) {
447
489
  ...d ? { createdAt: d } : {}
448
490
  };
449
491
  }
450
- function ve(e) {
492
+ function xe(e) {
451
493
  if (!Array.isArray(e) || e.length === 0) return;
452
494
  let t = [];
453
495
  for (let n of e) {
454
- if (!H(n)) continue;
496
+ if (!W(n)) continue;
455
497
  let e = n.axis === "locale" || n.axis === "secondaryLocale" ? n.axis : null, r = typeof n.requested == "string" ? n.requested.trim() : "", i = typeof n.resolved == "string" ? n.resolved.trim() : "";
456
498
  !e || !r || !i || n.reason !== "voice_unsupported" || t.push({
457
499
  axis: e,
@@ -462,35 +504,35 @@ function ve(e) {
462
504
  }
463
505
  return t.length > 0 ? t : void 0;
464
506
  }
465
- function ye(e) {
507
+ function Se(e) {
466
508
  let t = e.localeVoiceFallbacks;
467
509
  if (t?.length) for (let e of t) {
468
510
  let t = e.axis === "secondaryLocale" ? "secondaryLocale" : "locale";
469
511
  console.warn(`[liforma] Session ${t} fell back to ${e.resolved} because the voice does not support ${e.requested}.`);
470
512
  }
471
513
  }
472
- function G(e) {
473
- if (!H(e)) throw Error("Session Launch response must be a JSON object.");
514
+ function Ce(e) {
515
+ if (!W(e)) throw Error("Session Launch response must be a JSON object.");
474
516
  let t = typeof e.launch == "string" ? e.launch.trim() : "";
475
517
  if (!t) throw Error("Session Launch response is missing launch.");
476
- let n = _e(e.session);
477
- return ye(n), {
518
+ let n = be(e.session);
519
+ return Se(n), {
478
520
  session: n,
479
521
  launch: t
480
522
  };
481
523
  }
482
524
  //#endregion
483
525
  //#region src/v2/api/mintPublicSession.ts
484
- function be() {
526
+ function we() {
485
527
  try {
486
528
  if (typeof globalThis.location?.origin == "string" && globalThis.location.origin) return globalThis.location.origin;
487
529
  } catch {}
488
530
  }
489
- function xe(e) {
531
+ function Te(e) {
490
532
  return e ? e.trim().toUpperCase().replace(/-/g, "_") : "";
491
533
  }
492
- function Se(e, t) {
493
- let n = be(), r = xe(t.code), i = t.message.trim(), a = t.details ?? {};
534
+ function q(e, t) {
535
+ let n = we(), r = Te(t.code), i = t.message.trim(), a = t.details ?? {};
494
536
  if (r === "ORIGIN_NOT_ALLOWED" || /^Origin not allowed/i.test(i) && n) {
495
537
  if (i.includes(e) && i.includes("allowed origin")) return t;
496
538
  let r = typeof a.origin == "string" && a.origin || n || "(unknown origin)";
@@ -513,36 +555,38 @@ function Se(e, t) {
513
555
  details: a
514
556
  }) : t;
515
557
  }
516
- function Ce(e) {
558
+ function Ee(e) {
517
559
  let t = e?.locale?.trim();
518
560
  if (t) return t;
519
561
  let n = e?.language?.trim();
520
562
  if (n) return n;
521
563
  if (typeof navigator < "u" && navigator.language?.trim()) return navigator.language.trim();
522
564
  }
523
- function we(e) {
565
+ function De(e) {
524
566
  let t = e?.secondaryLocale?.trim(), n = e?.learningLocale?.trim();
525
567
  if (t && n && t !== n) throw new B("secondaryLocale and learningLocale disagree; pass only one or make them equal.", { code: "INVALID_BODY" });
526
568
  return t || n || void 0;
527
569
  }
528
- function Te(e, t) {
529
- let n = { experienceId: e }, r = Ce(t);
570
+ function Oe(e, t) {
571
+ let n = { experienceId: e }, r = Ee(t);
530
572
  r && (n.locale = r);
531
- let i = we(t);
532
- return i && (n.secondaryLocale = i), t?.mode && (n.mode = t.mode), t?.speechInputMode && (n.speechInputMode = t.speechInputMode), t?.speechOnly !== void 0 && (n.speechOnly = t.speechOnly), n;
573
+ let i = De(t);
574
+ i && (n.secondaryLocale = i), t?.mode && (n.mode = t.mode), t?.speechInputMode && (n.speechInputMode = t.speechInputMode), t?.speechOnly !== void 0 && (n.speechOnly = t.speechOnly);
575
+ let a = he(t?.attribution);
576
+ return a && (n.attribution = a), n;
533
577
  }
534
- async function Ee(e, t) {
578
+ async function ke(e, t) {
535
579
  let n = ce(), r = t?.idempotencyKey?.trim(), i = await fetch(`${n}/v1/browser-sessions`, {
536
580
  method: "POST",
537
581
  headers: {
538
582
  "Content-Type": "application/json",
539
583
  ...r ? { "Idempotency-Key": r } : {}
540
584
  },
541
- body: JSON.stringify(Te(e, t))
585
+ body: JSON.stringify(Oe(e, t))
542
586
  });
543
587
  if (!i.ok) {
544
588
  let t = await i.text();
545
- throw Se(e, fe(i.status, t, i.headers));
589
+ throw q(e, fe(i.status, t, i.headers));
546
590
  }
547
591
  let a;
548
592
  try {
@@ -554,10 +598,10 @@ async function Ee(e, t) {
554
598
  requestId: i.headers.get("Liforma-Request-Id") ?? void 0
555
599
  });
556
600
  }
557
- return G(a);
601
+ return Ce(a);
558
602
  }
559
- async function K(e, t) {
560
- let n = me(e, t), r = new AbortController(), i = () => r.abort(t.signal?.reason);
603
+ async function J(e, t) {
604
+ let n = _e(e, t), r = new AbortController(), i = () => r.abort(t.signal?.reason);
561
605
  t.signal?.aborted ? i() : t.signal?.addEventListener("abort", i, { once: !0 });
562
606
  let a = globalThis.setTimeout(() => r.abort(new DOMException("Session endpoint timed out.", "TimeoutError")), t.timeoutMs ?? 3e4), o;
563
607
  try {
@@ -587,14 +631,14 @@ async function K(e, t) {
587
631
  requestId: o.headers.get("Liforma-Request-Id") ?? void 0
588
632
  });
589
633
  }
590
- return G(s);
634
+ return Ce(s);
591
635
  }
592
636
  //#endregion
593
637
  //#region src/v2/conversationProcessor.ts
594
- function De(e) {
638
+ function Ae(e) {
595
639
  return typeof e != "object" || !e ? !1 : typeof e[Symbol.asyncIterator] == "function";
596
640
  }
597
- function Oe(e) {
641
+ function je(e) {
598
642
  if (typeof e == "string") {
599
643
  let t = e.trim();
600
644
  if (!t) throw Error("conversationProcessor returned empty text.");
@@ -608,24 +652,24 @@ function Oe(e) {
608
652
  ...e.behavior ? { behavior: e.behavior } : {}
609
653
  };
610
654
  }
611
- async function ke(e, t) {
655
+ async function Me(e, t) {
612
656
  let n = await e(t);
613
- return De(n) ? {
657
+ return Ae(n) ? {
614
658
  kind: "stream",
615
659
  stream: n
616
660
  } : {
617
661
  kind: "complete",
618
- speech: Oe(n)
662
+ speech: je(n)
619
663
  };
620
664
  }
621
665
  //#endregion
622
666
  //#region src/v2/embed/playerReachability.ts
623
- var Ae = "3002";
624
- function q(e) {
667
+ var Ne = "3002";
668
+ function Pe(e) {
625
669
  let t = new URL(e);
626
- return t.hostname === "localhost" || t.hostname === "127.0.0.1" ? `Cannot connect to the Liforma player at ${e} — nothing is listening on port ${t.port || Ae}. Start the player dev server in player.liforma.ai (npm run dev).` : `Cannot connect to the Liforma player at ${e}. The embed did not load; check your network connection and player URL configuration.`;
670
+ 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 || Ne}. 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.`;
627
671
  }
628
- async function je(e, t) {
672
+ async function Fe(e, t) {
629
673
  try {
630
674
  await fetch(e, {
631
675
  method: "GET",
@@ -633,52 +677,30 @@ async function je(e, t) {
633
677
  signal: AbortSignal.timeout(8e3)
634
678
  });
635
679
  } catch {
636
- throw Error(q(t));
680
+ throw Error(Pe(t));
637
681
  }
638
682
  }
639
- function J(e, t, n, r) {
683
+ function Ie(e, t, n, r) {
640
684
  try {
641
685
  r && r.length > 0 ? e.postMessage(t, n, r) : e.postMessage(t, n);
642
686
  } catch (e) {
643
- throw e instanceof DOMException && e.name === "SecurityError" ? Error(q(n), { cause: e }) : e;
644
- }
645
- }
646
- var Me = new Set([1, 2]);
647
- function Ne(e) {
648
- return typeof e == "number" && Me.has(e);
649
- }
650
- var Pe = new Set([
651
- "close",
652
- "stateUpdate",
653
- "commandResult",
654
- "userTranscript",
655
- "characterSpeechStarted",
656
- "characterSpeechEnded",
657
- "characterFocusChanged",
658
- "conversationUpdate",
659
- "listeningState",
660
- "userSpeechStarted",
661
- "userSpeechEnded",
662
- "modeChange",
663
- "activityChange",
664
- "feedback",
665
- "feedbackFailed",
666
- "message",
667
- "started",
668
- "embedReady",
669
- "widgetReady",
670
- "widgetExpand",
671
- "widgetCollapse",
672
- "widgetAudioSettings",
673
- "widgetDragStart",
674
- "widgetDragMove",
675
- "widgetDragEnd"
676
- ]);
677
- function Fe(e) {
687
+ throw e instanceof DOMException && e.name === "SecurityError" ? Error(Pe(n), { cause: e }) : e;
688
+ }
689
+ }
690
+ var Le = new Set([1, 2]);
691
+ function Re(e) {
692
+ return typeof e == "number" && Le.has(e);
693
+ }
694
+ var ze = 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("."));
695
+ function Be(e) {
678
696
  if (!e || typeof e != "object") return null;
679
697
  let t = e;
680
- if (!Ne(t.schemaVersion) || !t.type || !Pe.has(t.type)) return null;
698
+ if (!Re(t.schemaVersion) || !t.type || !ze.has(t.type)) return null;
681
699
  if (t.type === "embedReady" || t.type === "widgetReady" || t.type === "widgetExpand" || t.type === "widgetCollapse") return t;
700
+ if (t.type === "fullWindow") {
701
+ let e = t.payload;
702
+ return !e || typeof e != "object" || typeof e.active != "boolean" ? null : t;
703
+ }
682
704
  if (t.type === "widgetAudioSettings") {
683
705
  let e = t.payload;
684
706
  return !e || typeof e != "object" || typeof e.open != "boolean" ? null : t;
@@ -696,7 +718,7 @@ function Fe(e) {
696
718
  let n = t.payload;
697
719
  return !n || typeof n != "object" ? null : t;
698
720
  }
699
- function Ie(e, t, n) {
721
+ function Ve(e, t, n) {
700
722
  let r = e.trim();
701
723
  if (!r) throw Error("createLaunchMessage requires a non-empty launch string.");
702
724
  let i = n?.startButton, a = n?.showFeedback;
@@ -711,20 +733,20 @@ function Ie(e, t, n) {
711
733
  }
712
734
  };
713
735
  }
714
- function Le() {
736
+ function He() {
715
737
  return {
716
738
  type: "parentHello",
717
739
  schemaVersion: 2
718
740
  };
719
741
  }
720
- function Re(e) {
742
+ function Ue(e) {
721
743
  return {
722
744
  type: "widgetSetChrome",
723
745
  schemaVersion: 2,
724
746
  payload: { mode: e }
725
747
  };
726
748
  }
727
- function ze() {
749
+ function We() {
728
750
  return {
729
751
  type: "widgetToggleAudioSettings",
730
752
  schemaVersion: 2,
@@ -732,108 +754,143 @@ function ze() {
732
754
  };
733
755
  }
734
756
  //#endregion
757
+ //#region src/v2/embed/fullWindowHost.ts
758
+ var Ge = "2147483000";
759
+ function Ke(e) {
760
+ let { style: t } = e;
761
+ return {
762
+ position: t.position,
763
+ top: t.top,
764
+ right: t.right,
765
+ bottom: t.bottom,
766
+ left: t.left,
767
+ inset: t.inset,
768
+ width: t.width,
769
+ height: t.height,
770
+ zIndex: t.zIndex,
771
+ margin: t.margin,
772
+ borderRadius: t.borderRadius,
773
+ maxWidth: t.maxWidth,
774
+ maxHeight: t.maxHeight
775
+ };
776
+ }
777
+ function qe(e) {
778
+ let { style: t } = e;
779
+ 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 = Ge, t.margin = "0", t.borderRadius = "0", t.maxWidth = "none", t.maxHeight = "none", e.dataset.liformaFullWindow = "1";
780
+ }
781
+ function Je(e, t) {
782
+ if (delete e.dataset.liformaFullWindow, !t) {
783
+ 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 = "";
784
+ return;
785
+ }
786
+ let { style: n } = e;
787
+ 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;
788
+ }
789
+ //#endregion
735
790
  //#region src/v2/embed/iframeHost.ts
736
- function Be(e) {
791
+ function Ye(e) {
737
792
  return e;
738
793
  }
739
794
  function Y() {
740
795
  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)}`;
741
796
  }
742
- var Ve = 3e4;
743
- function He(e) {
797
+ var Xe = 3e4;
798
+ function Ze(e) {
744
799
  let t = e.container;
745
800
  getComputedStyle(t).position === "static" && (t.style.position = "relative");
746
801
  let n = document.createElement("iframe");
747
802
  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");
748
- let r = !1, i = /* @__PURE__ */ new Map(), a = null, o = 0, s = 0, c = [], l = null, u = null, d = new Promise((e, t) => {
749
- l = e, u = t;
750
- }), f = () => {
751
- for (let e of c) window.clearTimeout(e);
752
- c.length = 0;
753
- }, p = (t) => {
803
+ let r = !1, i = !1, a = null, o = t.closest(".liforma-experience-shell") instanceof HTMLElement ? t.closest(".liforma-experience-shell") : t, s = (t) => {
804
+ i !== t && (i = t, t ? (a = Ke(o), qe(o)) : (Je(o, a), a = null), e.onFullWindowChange?.(t));
805
+ }, c = /* @__PURE__ */ new Map(), l = null, u = 0, d = 0, f = [], p = null, m = null, h = new Promise((e, t) => {
806
+ p = e, m = t;
807
+ }), g = () => {
808
+ for (let e of f) window.clearTimeout(e);
809
+ f.length = 0;
810
+ }, _ = (t) => {
754
811
  if (r) return;
755
812
  let i = Date.now();
756
- if (s > 0 && i - s < 250) return;
757
- s = i, f();
758
- let a = Ie(t.launch, t.session, t.chrome), o = () => {
813
+ if (d > 0 && i - d < 250) return;
814
+ d = i, g();
815
+ let a = Ve(t.launch, t.session, t.chrome), o = () => {
759
816
  if (r) return;
760
817
  let t = n.contentWindow;
761
- t && J(t, a, e.playerOrigin);
818
+ t && Ie(t, a, e.playerOrigin);
762
819
  };
763
820
  o();
764
- for (let e = 1; e <= 12; e += 1) c.push(window.setTimeout(o, e * 75));
765
- }, m = () => {
766
- r || !a || p(a);
767
- }, h = () => {
768
- if (o += 1, o === 1) {
769
- je(e.src, e.playerOrigin).then(() => l?.(), (e) => u?.(e instanceof Error ? e : Error(String(e))));
821
+ for (let e = 1; e <= 12; e += 1) f.push(window.setTimeout(o, e * 75));
822
+ }, v = () => {
823
+ r || !l || _(l);
824
+ }, y = () => {
825
+ if (u += 1, u === 1) {
826
+ Fe(e.src, e.playerOrigin).then(() => p?.(), (e) => m?.(e instanceof Error ? e : Error(String(e))));
770
827
  return;
771
828
  }
772
- s = 0, m();
773
- }, g = () => {
774
- o > 0 || u?.(Error(q(e.playerOrigin)));
829
+ d = 0, v();
830
+ }, b = () => {
831
+ u > 0 || m?.(Error(Pe(e.playerOrigin)));
775
832
  };
776
- n.addEventListener("load", h), n.addEventListener("error", g);
777
- let _ = (t) => {
833
+ n.addEventListener("load", y), n.addEventListener("error", b);
834
+ let x = (t) => {
778
835
  if (r || t.source !== n.contentWindow || t.origin !== e.playerOrigin) return;
779
- let a = Fe(t.data);
780
- if (a) switch (a.type) {
836
+ let i = Be(t.data);
837
+ if (i) switch (i.type) {
781
838
  case "close":
782
- e.onClose?.(a.payload);
839
+ e.onClose?.(i.payload);
783
840
  break;
784
841
  case "stateUpdate":
785
- e.onPlayerStatusChange?.(a.payload.state), e.onStateUpdate?.(a.payload.state);
842
+ e.onPlayerStatusChange?.(i.payload.state), e.onStateUpdate?.(i.payload.state);
786
843
  break;
787
844
  case "commandResult": {
788
- let e = i.get(a.payload.correlationId);
845
+ let e = c.get(i.payload.correlationId);
789
846
  if (!e) return;
790
- i.delete(a.payload.correlationId), a.payload.ok ? e.resolve(a.payload.result) : e.reject(Error(a.payload.error ?? "Command failed."));
847
+ c.delete(i.payload.correlationId), i.payload.ok ? e.resolve(i.payload.result) : e.reject(Error(i.payload.error ?? "Command failed."));
791
848
  break;
792
849
  }
793
850
  case "userTranscript":
794
- e.onUserTranscript?.(a.payload);
851
+ e.onUserTranscript?.(i.payload);
795
852
  break;
796
853
  case "characterSpeechStarted":
797
- e.onCharacterSpeechStarted?.(a.payload);
854
+ e.onCharacterSpeechStarted?.(i.payload);
798
855
  break;
799
856
  case "characterSpeechEnded":
800
- e.onCharacterSpeechEnded?.(a.payload);
857
+ e.onCharacterSpeechEnded?.(i.payload);
801
858
  break;
802
859
  case "characterFocusChanged":
803
- e.onCharacterFocusChanged?.(a.payload);
860
+ e.onCharacterFocusChanged?.(i.payload);
804
861
  break;
805
862
  case "conversationUpdate":
806
- e.onConversationUpdate?.(a.payload.conversation);
863
+ e.onConversationUpdate?.(i.payload.conversation);
807
864
  break;
808
865
  case "listeningState":
809
- e.onListeningState?.(a.payload.listening);
866
+ e.onListeningState?.(i.payload.listening);
810
867
  break;
811
868
  case "userSpeechStarted":
812
- e.onUserSpeechStarted?.(a.payload);
869
+ e.onUserSpeechStarted?.(i.payload);
813
870
  break;
814
871
  case "userSpeechEnded":
815
- e.onUserSpeechEnded?.(a.payload);
872
+ e.onUserSpeechEnded?.(i.payload);
816
873
  break;
817
874
  case "modeChange":
818
- e.onActivityChange?.(Be(a.payload.mode));
875
+ e.onActivityChange?.(Ye(i.payload.mode));
819
876
  break;
820
877
  case "activityChange":
821
- e.onActivityChange?.(a.payload.activity);
878
+ e.onActivityChange?.(i.payload.activity);
822
879
  break;
823
880
  case "feedback":
824
- e.onFeedback?.(a.payload);
881
+ e.onFeedback?.(i.payload);
825
882
  break;
826
883
  case "feedbackFailed":
827
- e.onFeedbackFailed?.(a.payload);
884
+ e.onFeedbackFailed?.(i.payload);
828
885
  break;
829
886
  case "message":
830
- e.onMessage?.(a.payload);
887
+ e.onMessage?.(i.payload);
831
888
  break;
832
889
  case "started":
833
- e.onStarted?.(a.payload);
890
+ e.onStarted?.(i.payload);
834
891
  break;
835
892
  case "embedReady":
836
- m();
893
+ v();
837
894
  break;
838
895
  case "widgetReady":
839
896
  e.onWidgetReady?.();
@@ -845,52 +902,55 @@ function He(e) {
845
902
  e.onWidgetCollapse?.();
846
903
  break;
847
904
  case "widgetAudioSettings":
848
- e.onWidgetAudioSettings?.(a.payload.open);
905
+ e.onWidgetAudioSettings?.(i.payload.open);
849
906
  break;
850
907
  case "widgetDragStart":
851
- e.onWidgetDragStart?.(a.payload);
908
+ e.onWidgetDragStart?.(i.payload);
852
909
  break;
853
910
  case "widgetDragMove":
854
- e.onWidgetDragMove?.(a.payload);
911
+ e.onWidgetDragMove?.(i.payload);
855
912
  break;
856
913
  case "widgetDragEnd":
857
- e.onWidgetDragEnd?.(a.payload);
914
+ e.onWidgetDragEnd?.(i.payload);
915
+ break;
916
+ case "fullWindow":
917
+ s(i.payload.active);
858
918
  break;
859
919
  }
860
920
  };
861
- if (window.addEventListener("message", _), t.replaceChildren(n), t.clientHeight < 2 && !t.style.minHeight) {
921
+ if (window.addEventListener("message", x), t.replaceChildren(n), t.clientHeight < 2 && !t.style.minHeight) {
862
922
  let e = getComputedStyle(t).minHeight;
863
923
  (e === "0px" || e === "auto") && (t.style.minHeight = "480px");
864
924
  }
865
- let v = (t, i) => {
925
+ let S = (t, i) => {
866
926
  if (r) return;
867
927
  let a = n.contentWindow;
868
- if (!a) throw Error(q(e.playerOrigin));
869
- J(a, t, e.playerOrigin, i);
870
- }, y = (e, t = 12e4, n) => {
928
+ if (!a) throw Error(Pe(e.playerOrigin));
929
+ Ie(a, t, e.playerOrigin, i);
930
+ }, C = (e, t = 12e4, n) => {
871
931
  let r = e.type !== "parentHello" && e.payload && "correlationId" in e.payload ? e.payload.correlationId : Y();
872
- return e.type !== "parentHello" && e.payload && "correlationId" in e.payload || e.type !== "parentHello" && e.payload && (e.payload.correlationId = r), new Promise((a, o) => {
873
- i.set(r, {
874
- resolve: (e) => a(e),
875
- reject: o
876
- }), v(e, n), setTimeout(() => {
877
- i.has(r) && (i.delete(r), o(/* @__PURE__ */ Error("Timed out waiting for player command result.")));
932
+ return e.type !== "parentHello" && e.payload && "correlationId" in e.payload || e.type !== "parentHello" && e.payload && (e.payload.correlationId = r), new Promise((i, a) => {
933
+ c.set(r, {
934
+ resolve: (e) => i(e),
935
+ reject: a
936
+ }), S(e, n), setTimeout(() => {
937
+ c.has(r) && (c.delete(r), a(/* @__PURE__ */ Error("Timed out waiting for player command result.")));
878
938
  }, t);
879
939
  });
880
940
  };
881
941
  return {
882
942
  waitForLoad() {
883
- return d;
943
+ return h;
884
944
  },
885
945
  postParentHello() {
886
- v(Le());
946
+ S(He());
887
947
  },
888
948
  postLaunch(e, t, n) {
889
- r || (a = {
949
+ r || (l = {
890
950
  launch: e,
891
951
  session: t,
892
952
  chrome: n
893
- }, s = 0, p(a));
953
+ }, d = 0, _(l));
894
954
  },
895
955
  postManifest(e) {
896
956
  if (typeof e == "string") {
@@ -905,13 +965,13 @@ function He(e) {
905
965
  throw Error("postManifest is deprecated; use postLaunch with an opaque launch string from SessionLaunchResponse.");
906
966
  },
907
967
  postWidgetSetChrome(e) {
908
- v(Re(e));
968
+ S(Ue(e));
909
969
  },
910
970
  postWidgetToggleAudioSettings() {
911
- v(ze());
971
+ S(We());
912
972
  },
913
973
  speak(e) {
914
- return y({
974
+ return C({
915
975
  type: "speak",
916
976
  schemaVersion: 2,
917
977
  payload: {
@@ -923,21 +983,21 @@ function He(e) {
923
983
  });
924
984
  },
925
985
  startListening() {
926
- return y({
986
+ return C({
927
987
  type: "startListening",
928
988
  schemaVersion: 2,
929
989
  payload: { correlationId: Y() }
930
990
  });
931
991
  },
932
992
  stopListening() {
933
- return y({
993
+ return C({
934
994
  type: "stopListening",
935
995
  schemaVersion: 2,
936
996
  payload: { correlationId: Y() }
937
997
  });
938
998
  },
939
999
  listenOnce(e) {
940
- return y({
1000
+ return C({
941
1001
  type: "listenOnce",
942
1002
  schemaVersion: 2,
943
1003
  payload: {
@@ -947,7 +1007,7 @@ function He(e) {
947
1007
  });
948
1008
  },
949
1009
  async speakProcessorStream(e, t) {
950
- let n = Y(), r = Y(), i = (await y({
1010
+ let n = Y(), r = Y(), i = (await C({
951
1011
  type: "speakStreamStart",
952
1012
  schemaVersion: 2,
953
1013
  payload: {
@@ -959,7 +1019,7 @@ function He(e) {
959
1019
  try {
960
1020
  for await (let n of e) {
961
1021
  if (t?.signal?.aborted) throw new DOMException("Processor stream aborted.", "AbortError");
962
- n && v({
1022
+ n && S({
963
1023
  type: "speakStreamChunk",
964
1024
  schemaVersion: 2,
965
1025
  payload: {
@@ -969,7 +1029,7 @@ function He(e) {
969
1029
  });
970
1030
  }
971
1031
  if (t?.signal?.aborted) throw new DOMException("Processor stream aborted.", "AbortError");
972
- return await y({
1032
+ return await C({
973
1033
  type: "speakStreamEnd",
974
1034
  schemaVersion: 2,
975
1035
  payload: {
@@ -979,7 +1039,7 @@ function He(e) {
979
1039
  });
980
1040
  } catch (e) {
981
1041
  try {
982
- await y({
1042
+ await C({
983
1043
  type: "speakStreamEnd",
984
1044
  schemaVersion: 2,
985
1045
  payload: {
@@ -993,7 +1053,7 @@ function He(e) {
993
1053
  },
994
1054
  speechPlay(e) {
995
1055
  let t = Y(), n = [];
996
- return (e.source.kind === "pcm" || e.source.kind === "encoded") && n.push(e.source.data), y({
1056
+ return (e.source.kind === "pcm" || e.source.kind === "encoded") && n.push(e.source.data), C({
997
1057
  type: "speechPlay",
998
1058
  schemaVersion: 2,
999
1059
  payload: {
@@ -1007,7 +1067,7 @@ function He(e) {
1007
1067
  }, 12e4, n);
1008
1068
  },
1009
1069
  speechUtteranceBegin(e) {
1010
- return y({
1070
+ return C({
1011
1071
  type: "speechUtteranceBegin",
1012
1072
  schemaVersion: 2,
1013
1073
  payload: {
@@ -1021,7 +1081,7 @@ function He(e) {
1021
1081
  });
1022
1082
  },
1023
1083
  speechUtteranceWrite(e) {
1024
- return y({
1084
+ return C({
1025
1085
  type: "speechUtteranceWrite",
1026
1086
  schemaVersion: 2,
1027
1087
  payload: {
@@ -1030,10 +1090,10 @@ function He(e) {
1030
1090
  audio: e.audio,
1031
1091
  byteLength: e.byteLength
1032
1092
  }
1033
- }, Ve, [e.audio]);
1093
+ }, Xe, [e.audio]);
1034
1094
  },
1035
1095
  speechUtteranceSetTranscript(e) {
1036
- return y({
1096
+ return C({
1037
1097
  type: "speechUtteranceSetTranscript",
1038
1098
  schemaVersion: 2,
1039
1099
  payload: {
@@ -1044,7 +1104,7 @@ function He(e) {
1044
1104
  });
1045
1105
  },
1046
1106
  speechUtteranceClose(e) {
1047
- return y({
1107
+ return C({
1048
1108
  type: "speechUtteranceClose",
1049
1109
  schemaVersion: 2,
1050
1110
  payload: {
@@ -1056,7 +1116,7 @@ function He(e) {
1056
1116
  });
1057
1117
  },
1058
1118
  speechUtteranceCancel(e) {
1059
- return y({
1119
+ return C({
1060
1120
  type: "speechUtteranceCancel",
1061
1121
  schemaVersion: 2,
1062
1122
  payload: {
@@ -1066,7 +1126,7 @@ function He(e) {
1066
1126
  });
1067
1127
  },
1068
1128
  speechInterrupt(e) {
1069
- return y({
1129
+ return C({
1070
1130
  type: "speechInterrupt",
1071
1131
  schemaVersion: 2,
1072
1132
  payload: {
@@ -1076,14 +1136,14 @@ function He(e) {
1076
1136
  });
1077
1137
  },
1078
1138
  getConversation() {
1079
- return y({
1139
+ return C({
1080
1140
  type: "getConversation",
1081
1141
  schemaVersion: 2,
1082
1142
  payload: { correlationId: Y() }
1083
1143
  });
1084
1144
  },
1085
1145
  focusCharacter(e) {
1086
- return y({
1146
+ return C({
1087
1147
  type: "focusCharacter",
1088
1148
  schemaVersion: 2,
1089
1149
  payload: {
@@ -1093,7 +1153,7 @@ function He(e) {
1093
1153
  });
1094
1154
  },
1095
1155
  setFit(e) {
1096
- return y({
1156
+ return C({
1097
1157
  type: "setFit",
1098
1158
  schemaVersion: 2,
1099
1159
  payload: {
@@ -1102,18 +1162,28 @@ function He(e) {
1102
1162
  }
1103
1163
  });
1104
1164
  },
1165
+ conversion(e) {
1166
+ return C({
1167
+ type: "conversion",
1168
+ schemaVersion: 2,
1169
+ payload: {
1170
+ correlationId: Y(),
1171
+ key: e
1172
+ }
1173
+ });
1174
+ },
1105
1175
  destroy() {
1106
1176
  if (!r) {
1107
- r = !0;
1108
- for (let e of i.values()) e.reject(/* @__PURE__ */ Error("Iframe host destroyed."));
1109
- i.clear(), f(), a = null, n.removeEventListener("load", h), n.removeEventListener("error", g), window.removeEventListener("message", _), n.remove();
1177
+ r = !0, i && s(!1);
1178
+ for (let e of c.values()) e.reject(/* @__PURE__ */ Error("Iframe host destroyed."));
1179
+ c.clear(), g(), l = null, n.removeEventListener("load", y), n.removeEventListener("error", b), window.removeEventListener("message", x), n.remove();
1110
1180
  }
1111
1181
  }
1112
1182
  };
1113
1183
  }
1114
1184
  //#endregion
1115
1185
  //#region src/v2/embed/readyGate.ts
1116
- function Ue(e) {
1186
+ function Qe(e) {
1117
1187
  let t, n = !1, r = !1, i = () => {
1118
1188
  r || !n || t === void 0 || (r = !0, e(t));
1119
1189
  };
@@ -1128,47 +1198,50 @@ function Ue(e) {
1128
1198
  }
1129
1199
  //#endregion
1130
1200
  //#region src/v2/shims/embedBaseUrl.ts
1131
- var We = "https://player.liforma.ai/embed", Ge = "http://localhost:3002/embed";
1132
- function Ke() {
1201
+ var $e = "https://player.liforma.ai/embed", et = "http://localhost:3002/embed";
1202
+ function tt() {
1133
1203
  let e = globalThis.__LIFORMA_PLAYER_EMBED_URL;
1134
1204
  if (e?.trim()) return e.trim().replace(/\/$/, "");
1135
1205
  if (typeof document > "u") return null;
1136
1206
  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();
1137
1207
  return t ? t.replace(/\/$/, "") : null;
1138
1208
  }
1139
- function qe() {
1140
- let e = Ke();
1141
- return e ? e.endsWith("/embed") ? e : `${e}/embed` : l() ? Ge : We;
1209
+ function nt() {
1210
+ let e = tt();
1211
+ return e ? e.endsWith("/embed") ? e : `${e}/embed` : l() ? et : $e;
1142
1212
  }
1143
- function Je(e, t, n, r, i, a, o, s) {
1144
- let c = (e ?? qe()).replace(/\/$/, ""), l = c.endsWith("/embed") ? c : `${c}/embed`, u = new URL(l), d = n?.trim();
1145
- d && u.searchParams.set("locationId", d);
1213
+ function rt(e, t) {
1214
+ return e?.trim() || t?.trim() || void 0;
1215
+ }
1216
+ function it(e, t, n, r, i, a, o, s) {
1217
+ let c = (e ?? nt()).replace(/\/$/, ""), l = c.endsWith("/embed") ? c : `${c}/embed`, u = new URL(l), d = n?.trim();
1218
+ d && (u.searchParams.set("backdropId", d), u.searchParams.set("locationId", d));
1146
1219
  let f = r?.trim();
1147
- return f && u.searchParams.set("avatarId", f), (i === "face" || i === "medium") && u.searchParams.set("fit", i), a === "widget" && u.searchParams.set("ui", "widget"), o && u.searchParams.set("close", "1"), t && u.searchParams.set("debug", "true"), (s === 2 || s === 3 || s === 4) && u.searchParams.set("cast", String(s)), Ye(u.toString());
1220
+ 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());
1148
1221
  }
1149
- function Ye(e) {
1222
+ function at(e) {
1150
1223
  if (typeof location > "u") return e;
1151
1224
  let t = new URL(e);
1152
1225
  return t.searchParams.set("parentOrigin", location.origin), t.toString();
1153
1226
  }
1154
- function Xe(e) {
1227
+ function ot(e) {
1155
1228
  return new URL(e).origin;
1156
1229
  }
1157
1230
  //#endregion
1158
1231
  //#region src/v2/experienceEvents.ts
1159
- function Ze() {
1232
+ function st() {
1160
1233
  return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? `evt_${crypto.randomUUID().replace(/-/g, "").slice(0, 12)}` : `evt_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
1161
1234
  }
1162
- function Qe(e, t, n) {
1235
+ function ct(e, t, n) {
1163
1236
  return {
1164
- id: Ze(),
1237
+ id: st(),
1165
1238
  type: e,
1166
1239
  sessionId: t,
1167
1240
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1168
1241
  data: n
1169
1242
  };
1170
1243
  }
1171
- function $e() {
1244
+ function lt() {
1172
1245
  return {
1173
1246
  ready: /* @__PURE__ */ new Set(),
1174
1247
  started: /* @__PURE__ */ new Set(),
@@ -1187,32 +1260,32 @@ function $e() {
1187
1260
  conversationProcessorError: /* @__PURE__ */ new Set()
1188
1261
  };
1189
1262
  }
1190
- function et(e, t, n) {
1263
+ function ut(e, t, n) {
1191
1264
  return e[t].add(n), () => e[t].delete(n);
1192
1265
  }
1193
- function tt(e, t, n) {
1266
+ function dt(e, t, n) {
1194
1267
  for (let r of e[t]) r(n);
1195
1268
  }
1196
- function nt(e) {
1269
+ function ft(e) {
1197
1270
  for (let t of Object.keys(e)) e[t].clear();
1198
1271
  }
1199
1272
  //#endregion
1200
1273
  //#region src/v2/speech/types.ts
1201
- function rt(e) {
1274
+ function pt(e) {
1202
1275
  return "data" in e && "format" in e && e.format != null && !("track" in e);
1203
1276
  }
1204
- function it(e) {
1277
+ function mt(e) {
1205
1278
  return "url" in e && typeof e.url == "string";
1206
1279
  }
1207
- function at(e) {
1280
+ function ht(e) {
1208
1281
  if (!("track" in e)) return !1;
1209
1282
  let t = e.track;
1210
1283
  return typeof t != "object" || !t ? !1 : typeof MediaStreamTrack < "u" && t instanceof MediaStreamTrack ? !0 : "kind" in t && "readyState" in t;
1211
1284
  }
1212
- function ot(e) {
1213
- return !rt(e) && !it(e) && !at(e) && "encoding" in e && typeof e.encoding == "string";
1285
+ function gt(e) {
1286
+ return !pt(e) && !mt(e) && !ht(e) && "encoding" in e && typeof e.encoding == "string";
1214
1287
  }
1215
- var st = [
1288
+ var _t = [
1216
1289
  8e3,
1217
1290
  16e3,
1218
1291
  22050,
@@ -1230,14 +1303,14 @@ var st = [
1230
1303
  MAX_UTTERANCE_DURATION_MS: 9e4,
1231
1304
  MAX_PENDING_WRITES: 8,
1232
1305
  DEFAULT_WRITE_TIMEOUT_MS: 5e3
1233
- }, ct = class extends Error {
1306
+ }, vt = class extends Error {
1234
1307
  operation;
1235
1308
  requiredCapability;
1236
1309
  name = "UnsupportedSpeechOperationError";
1237
1310
  constructor(e, t) {
1238
1311
  super(`Speech operation "${e}" requires capability "${t}".`), this.operation = e, this.requiredCapability = t;
1239
1312
  }
1240
- }, lt = class extends Error {
1313
+ }, yt = class extends Error {
1241
1314
  name = "SpeechUtteranceClosedError";
1242
1315
  constructor(e = "Cannot write to a closed or cancelled speech utterance.") {
1243
1316
  super(e);
@@ -1247,72 +1320,72 @@ var st = [
1247
1320
  constructor(e, t) {
1248
1321
  super(e, t);
1249
1322
  }
1250
- }, ut = class extends Error {
1323
+ }, bt = class extends Error {
1251
1324
  name = "SpeechBufferTimeoutError";
1252
1325
  constructor(e = "Timed out waiting for speech buffer capacity.") {
1253
1326
  super(e);
1254
1327
  }
1255
1328
  };
1256
- function dt(e = "none") {
1329
+ function xt(e = "none") {
1257
1330
  return {
1258
1331
  mode: e,
1259
1332
  trackedDurationMs: 0,
1260
1333
  fallbackDurationMs: 0
1261
1334
  };
1262
1335
  }
1263
- function ft(e) {
1264
- return st.includes(e);
1336
+ function St(e) {
1337
+ return _t.includes(e);
1265
1338
  }
1266
- function pt(e) {
1339
+ function Ct(e) {
1267
1340
  if (e.encoding !== "pcm_s16le") throw new Z(`Unsupported audio encoding: ${e.encoding}`);
1268
1341
  if (e.channels !== 1) throw new Z(`Unsupported channel count: ${e.channels}`);
1269
- if (!ft(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
1342
+ if (!St(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
1270
1343
  }
1271
- function mt(e) {
1272
- if (rt(e)) {
1273
- pt(e.format);
1344
+ function wt(e) {
1345
+ if (pt(e)) {
1346
+ Ct(e.format);
1274
1347
  return;
1275
1348
  }
1276
- if (it(e)) {
1349
+ if (mt(e)) {
1277
1350
  if (!e.url.trim()) throw new Z("Audio URL must be non-empty.");
1278
- if (e.sampleRate !== void 0 && !ft(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
1351
+ if (e.sampleRate !== void 0 && !St(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
1279
1352
  return;
1280
1353
  }
1281
- if (at(e)) {
1354
+ if (ht(e)) {
1282
1355
  if (e.track.kind !== "audio") throw new Z("speech.play track must be an audio MediaStreamTrack.");
1283
- if (e.sampleRate !== void 0 && !ft(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
1356
+ if (e.sampleRate !== void 0 && !St(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
1284
1357
  return;
1285
1358
  }
1286
- if (ot(e)) {
1359
+ if (gt(e)) {
1287
1360
  let t = e.encoding.trim().toLowerCase();
1288
1361
  if (!t) throw new Z("Encoded audio MIME type is required.");
1289
1362
  if (t === "pcm_s16le") throw new Z("Use format: { encoding: \"pcm_s16le\", … } for raw PCM.");
1290
- if (e.sampleRate !== void 0 && !ft(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
1363
+ if (e.sampleRate !== void 0 && !St(e.sampleRate)) throw new Z(`Unsupported sample rate: ${e.sampleRate}`);
1291
1364
  return;
1292
1365
  }
1293
1366
  throw new Z("Unsupported speech.play audio shape.");
1294
1367
  }
1295
- function ht(e) {
1296
- if (e.format) return pt(e.format), e.format;
1368
+ function Tt(e) {
1369
+ if (e.format) return Ct(e.format), e.format;
1297
1370
  if (e.track) {
1298
1371
  let t = {
1299
1372
  encoding: "pcm_s16le",
1300
1373
  sampleRate: e.sampleRate ?? 24e3,
1301
1374
  channels: 1
1302
1375
  };
1303
- return pt(t), t;
1376
+ return Ct(t), t;
1304
1377
  }
1305
1378
  throw new Z("createUtterance requires format or track.");
1306
1379
  }
1307
- function gt(e) {
1380
+ function Et(e) {
1308
1381
  return e instanceof Uint8Array ? e : new Uint8Array(e);
1309
1382
  }
1310
- function _t(e) {
1383
+ function Dt(e) {
1311
1384
  return e === "replace-active" || e === "replace-all" ? "interrupt" : "enqueue";
1312
1385
  }
1313
1386
  //#endregion
1314
1387
  //#region src/byo/pcm.ts
1315
- function vt(e) {
1388
+ function Ot(e) {
1316
1389
  let t = new Uint8Array(e.length * 2), n = new DataView(t.buffer);
1317
1390
  for (let t = 0; t < e.length; t++) {
1318
1391
  let r = Math.max(-1, Math.min(1, e[t]));
@@ -1322,11 +1395,11 @@ function vt(e) {
1322
1395
  }
1323
1396
  //#endregion
1324
1397
  //#region src/byo/resample.ts
1325
- function yt(e, t, n, r, i) {
1398
+ function kt(e, t, n, r, i) {
1326
1399
  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;
1327
1400
  return ((a * i + o) * i + s) * i + c;
1328
1401
  }
1329
- function bt(e, t) {
1402
+ function At(e, t) {
1330
1403
  if (!(e > 0) || !(t > 0)) throw Error("Resampler rates must be positive");
1331
1404
  if (e === t) return {
1332
1405
  fromRate: e,
@@ -1349,7 +1422,7 @@ function bt(e, t) {
1349
1422
  let a = [];
1350
1423
  for (; i + 2 < r.length - 1;) {
1351
1424
  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);
1352
- a.push(yt(r[o], r[e], r[s], r[c], t)), i += n;
1425
+ a.push(kt(r[o], r[e], r[s], r[c], t)), i += n;
1353
1426
  }
1354
1427
  let o = Math.max(0, Math.floor(i) - 1);
1355
1428
  return o > 0 && (r = r.subarray(o), i -= o), a.length ? Float32Array.from(a) : new Float32Array();
@@ -1361,7 +1434,7 @@ function bt(e, t) {
1361
1434
  }
1362
1435
  //#endregion
1363
1436
  //#region src/byo/audioCapture.ts
1364
- var xt = "liforma-pcm-capture", St = `
1437
+ var jt = "liforma-pcm-capture", Mt = `
1365
1438
  class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
1366
1439
  process(inputs) {
1367
1440
  const ch = inputs[0] && inputs[0][0];
@@ -1373,29 +1446,29 @@ class LiformaPcmCaptureProcessor extends AudioWorkletProcessor {
1373
1446
  return true;
1374
1447
  }
1375
1448
  }
1376
- registerProcessor('${xt}', LiformaPcmCaptureProcessor);
1377
- `, Ct = null;
1378
- function wt() {
1379
- return Ct ||= URL.createObjectURL(new Blob([St], { type: "application/javascript" })), Ct;
1449
+ registerProcessor('${jt}', LiformaPcmCaptureProcessor);
1450
+ `, Nt = null;
1451
+ function Pt() {
1452
+ return Nt ||= URL.createObjectURL(new Blob([Mt], { type: "application/javascript" })), Nt;
1380
1453
  }
1381
- function Tt() {
1454
+ function Ft() {
1382
1455
  return window.AudioContext || window.webkitAudioContext || null;
1383
1456
  }
1384
- async function Et(e) {
1385
- let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = Tt();
1457
+ async function It(e) {
1458
+ let { mediaStream: t, targetSampleRate: n, onPcm: r, shouldSend: i, onLog: a } = e, o = Ft();
1386
1459
  if (!o) throw Error("Web Audio is required for audio capture");
1387
1460
  let s = new o(), c = s.createMediaStreamSource(t), l = s.createGain();
1388
1461
  l.gain.value = 0;
1389
- let u = s.sampleRate, d = bt(u, n), f = !1, p = !1, m = (e) => {
1462
+ let u = s.sampleRate, d = At(u, n), f = !1, p = !1, m = (e) => {
1390
1463
  if (f || i && !i()) return;
1391
1464
  let t = d.push(e);
1392
- t.length !== 0 && r(vt(t));
1465
+ t.length !== 0 && r(Ot(t));
1393
1466
  }, h = () => void 0;
1394
1467
  return await (async () => {
1395
1468
  if (typeof s.audioWorklet?.addModule != "function") return !1;
1396
1469
  try {
1397
- await s.audioWorklet.addModule(wt());
1398
- let e = new AudioWorkletNode(s, xt, {
1470
+ await s.audioWorklet.addModule(Pt());
1471
+ let e = new AudioWorkletNode(s, jt, {
1399
1472
  numberOfInputs: 1,
1400
1473
  numberOfOutputs: 1,
1401
1474
  outputChannelCount: [1]
@@ -1445,7 +1518,7 @@ async function Et(e) {
1445
1518
  }
1446
1519
  //#endregion
1447
1520
  //#region src/v2/speech/captureMediaStreamTrack.ts
1448
- async function Dt(e) {
1521
+ async function Lt(e) {
1449
1522
  let { track: t, utterance: n, sampleRate: r, signal: i } = e;
1450
1523
  if (typeof MediaStreamTrack > "u" || !(t instanceof MediaStreamTrack)) throw new Z("MediaStreamTrack is not available in this environment.");
1451
1524
  if (t.kind !== "audio") throw new Z("speech.play track must be an audio MediaStreamTrack.");
@@ -1454,13 +1527,13 @@ async function Dt(e) {
1454
1527
  s || (s = !0, c?.stop(), c = null);
1455
1528
  };
1456
1529
  try {
1457
- c = await Et({
1530
+ c = await It({
1458
1531
  mediaStream: a,
1459
1532
  targetSampleRate: r,
1460
1533
  shouldSend: () => !s && !i?.aborted,
1461
1534
  onPcm: (e) => {
1462
1535
  if (s || i?.aborted) return;
1463
- let t = gt(e);
1536
+ let t = Et(e);
1464
1537
  o = o.then(async () => {
1465
1538
  if (s || i?.aborted) return;
1466
1539
  let e = 0;
@@ -1489,10 +1562,10 @@ async function Dt(e) {
1489
1562
  }
1490
1563
  //#endregion
1491
1564
  //#region src/v2/speech/speechController.ts
1492
- async function Ot(e, t) {
1493
- if (at(e)) throw new Z("MediaStreamTrack play is handled on the host before embed.");
1494
- if (rt(e)) {
1495
- let t = gt(e.data);
1565
+ async function Rt(e, t) {
1566
+ if (ht(e)) throw new Z("MediaStreamTrack play is handled on the host before embed.");
1567
+ if (pt(e)) {
1568
+ let t = Et(e.data);
1496
1569
  if (t.byteLength & 1) throw new Z("PCM byte length must be even.");
1497
1570
  return {
1498
1571
  kind: "pcm",
@@ -1500,17 +1573,17 @@ async function Ot(e, t) {
1500
1573
  format: e.format
1501
1574
  };
1502
1575
  }
1503
- if (it(e)) return {
1576
+ if (mt(e)) return {
1504
1577
  kind: "url",
1505
1578
  url: e.url.trim(),
1506
1579
  ...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
1507
1580
  };
1508
- if (!ot(e)) throw new Z("Unsupported speech.play audio shape.");
1581
+ if (!gt(e)) throw new Z("Unsupported speech.play audio shape.");
1509
1582
  let n;
1510
1583
  if (typeof Blob < "u" && e.data instanceof Blob) {
1511
1584
  if (t?.aborted) throw new DOMException("Play aborted.", "AbortError");
1512
1585
  n = new Uint8Array(await e.data.arrayBuffer());
1513
- } else n = gt(e.data);
1586
+ } else n = Et(e.data);
1514
1587
  return {
1515
1588
  kind: "encoded",
1516
1589
  data: n.slice().buffer,
@@ -1518,10 +1591,10 @@ async function Ot(e, t) {
1518
1591
  ...e.sampleRate === void 0 ? {} : { sampleRate: e.sampleRate }
1519
1592
  };
1520
1593
  }
1521
- function kt() {
1594
+ function zt() {
1522
1595
  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)}`;
1523
1596
  }
1524
- function At(e, t = "completed") {
1597
+ function Bt(e, t = "completed") {
1525
1598
  return {
1526
1599
  utteranceId: e.speechId,
1527
1600
  characterId: e.characterId,
@@ -1535,13 +1608,13 @@ function At(e, t = "completed") {
1535
1608
  }
1536
1609
  };
1537
1610
  }
1538
- function jt(e) {
1611
+ function Vt(e) {
1539
1612
  return e instanceof Error ? e : new Z(String(e));
1540
1613
  }
1541
- function Mt(e) {
1614
+ function Ht(e) {
1542
1615
  return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
1543
1616
  }
1544
- var Nt = class {
1617
+ var Ut = class {
1545
1618
  id;
1546
1619
  characterId;
1547
1620
  result;
@@ -1570,14 +1643,14 @@ var Nt = class {
1570
1643
  queue: e.queue,
1571
1644
  ...e.transcript === void 0 ? {} : { transcript: e.transcript }
1572
1645
  }).catch((e) => {
1573
- throw this.fail(jt(e)), jt(e);
1646
+ throw this.fail(Vt(e)), Vt(e);
1574
1647
  }), this.signal?.addEventListener("abort", () => {
1575
1648
  this.cancel();
1576
1649
  }, { once: !0 });
1577
1650
  }
1578
1651
  async write(e, t) {
1579
- if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new lt();
1580
- let n = gt(e);
1652
+ if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new yt();
1653
+ let n = Et(e);
1581
1654
  if (n.byteLength & 1) throw new Z("PCM chunk byte length must be even (complete s16 samples).");
1582
1655
  if (n.byteLength > X.MAX_CHUNK_BYTES) throw new Z(`PCM chunk exceeds MAX_CHUNK_BYTES (${X.MAX_CHUNK_BYTES}).`);
1583
1656
  if (n.byteLength === 0) return;
@@ -1586,13 +1659,13 @@ var Nt = class {
1586
1659
  let i = n.byteLength / 2 / this.sampleRate * 1e3;
1587
1660
  if (this.bufferedMs + i > X.MAX_UTTERANCE_DURATION_MS) throw this.releaseWriteSlot(), new Z("Utterance exceeds MAX_UTTERANCE_DURATION_MS.");
1588
1661
  let a = async () => {
1589
- if (this.closed || this.settled) throw new lt();
1662
+ if (this.closed || this.settled) throw new yt();
1590
1663
  let e = this.requireHost(), t = n.slice(), i = e.speechUtteranceWrite({
1591
1664
  utteranceId: this.id,
1592
1665
  audio: t.buffer,
1593
1666
  byteLength: t.byteLength
1594
1667
  }), a = await Promise.race([i, new Promise((e, t) => {
1595
- setTimeout(() => t(new ut()), r);
1668
+ setTimeout(() => t(new bt()), r);
1596
1669
  })]);
1597
1670
  this.bufferedMs = Math.max(0, a.bufferedMs);
1598
1671
  }, o = this.writeChain.then(a, a);
@@ -1604,7 +1677,7 @@ var Nt = class {
1604
1677
  }
1605
1678
  }
1606
1679
  async setTranscript(e) {
1607
- if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new lt();
1680
+ if (this.closed || this.settled || (await this.beginPromise.catch(() => void 0), this.closed || this.settled)) throw new yt();
1608
1681
  await this.requireHost().speechUtteranceSetTranscript({
1609
1682
  utteranceId: this.id,
1610
1683
  transcript: e
@@ -1621,7 +1694,7 @@ var Nt = class {
1621
1694
  });
1622
1695
  return this.resolve(t), t;
1623
1696
  } catch (e) {
1624
- let t = jt(e);
1697
+ let t = Vt(e);
1625
1698
  throw this.fail(t), t;
1626
1699
  }
1627
1700
  }
@@ -1639,11 +1712,11 @@ var Nt = class {
1639
1712
  characterId: this.characterId,
1640
1713
  status: "cancelled",
1641
1714
  durationMs: 0,
1642
- animation: dt("none")
1715
+ animation: xt("none")
1643
1716
  };
1644
1717
  return this.resolve(t), t;
1645
1718
  } catch (e) {
1646
- let t = jt(e);
1719
+ let t = Vt(e);
1647
1720
  throw this.fail(t), t;
1648
1721
  }
1649
1722
  }
@@ -1656,7 +1729,7 @@ var Nt = class {
1656
1729
  return e;
1657
1730
  }
1658
1731
  resolve(e) {
1659
- this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new lt()));
1732
+ this.settled || (this.settled = !0, this.settleResolve(Object.freeze(e)), this.flushWriteWaiters(new yt()));
1660
1733
  }
1661
1734
  fail(e) {
1662
1735
  this.settled || (this.settled = !0, this.settleReject(e), this.flushWriteWaiters(e));
@@ -1668,7 +1741,7 @@ var Nt = class {
1668
1741
  }
1669
1742
  await new Promise((t, n) => {
1670
1743
  let r = setTimeout(() => {
1671
- n(new ut());
1744
+ n(new bt());
1672
1745
  }, e);
1673
1746
  this.pendingWriteWaiters.push({
1674
1747
  resolve: () => {
@@ -1687,13 +1760,13 @@ var Nt = class {
1687
1760
  for (; this.pendingWriteWaiters.length > 0;) this.pendingWriteWaiters.shift()?.reject(e);
1688
1761
  }
1689
1762
  };
1690
- function Pt(e) {
1763
+ function Wt(e) {
1691
1764
  let t = null, n = (t, n) => {
1692
- if (!e.getCapabilities()[n]) throw new ct(t, n);
1765
+ if (!e.getCapabilities()[n]) throw new vt(t, n);
1693
1766
  }, r = {
1694
1767
  async speak(r) {
1695
1768
  if (e.assertSessionStarted(), n("speak", "textSpeech"), r.signal?.aborted) throw new DOMException("Speak aborted.", "AbortError");
1696
- let i = _t(r.queue ?? "append");
1769
+ let i = Dt(r.queue ?? "append");
1697
1770
  i === "interrupt" && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null));
1698
1771
  let a = e.getIframeHost();
1699
1772
  if (!a) throw new Z("Speech session is not attached.");
@@ -1713,41 +1786,41 @@ function Pt(e) {
1713
1786
  return;
1714
1787
  }
1715
1788
  t.addEventListener("abort", s, { once: !0 }), o.then((e) => {
1716
- t.removeEventListener("abort", s), n(At(e, "completed"));
1789
+ t.removeEventListener("abort", s), n(Bt(e, "completed"));
1717
1790
  }, (a) => {
1718
- if (t.removeEventListener("abort", s), Mt(a)) {
1791
+ if (t.removeEventListener("abort", s), Ht(a)) {
1719
1792
  n({
1720
1793
  utteranceId: "utt_interrupted",
1721
1794
  characterId: r.characterId ?? e.getActiveCharacterId(),
1722
1795
  status: "interrupted",
1723
1796
  durationMs: 0,
1724
1797
  transcript: r.text,
1725
- animation: dt("none")
1798
+ animation: xt("none")
1726
1799
  });
1727
1800
  return;
1728
1801
  }
1729
- i(jt(a));
1802
+ i(Vt(a));
1730
1803
  });
1731
1804
  });
1732
1805
  }
1733
1806
  try {
1734
- return At(await o, "completed");
1807
+ return Bt(await o, "completed");
1735
1808
  } catch (t) {
1736
- if (Mt(t)) return {
1809
+ if (Ht(t)) return {
1737
1810
  utteranceId: "utt_interrupted",
1738
1811
  characterId: r.characterId ?? e.getActiveCharacterId(),
1739
1812
  status: "interrupted",
1740
1813
  durationMs: 0,
1741
1814
  transcript: r.text,
1742
- animation: dt("none")
1815
+ animation: xt("none")
1743
1816
  };
1744
- throw jt(t);
1817
+ throw Vt(t);
1745
1818
  }
1746
1819
  },
1747
1820
  async play(i) {
1748
- if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), mt(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
1821
+ if (e.assertSessionStarted(), n("play", "externalSpeechAudio"), wt(i.audio), i.signal?.aborted) throw new DOMException("Play aborted.", "AbortError");
1749
1822
  let a = i.queue ?? "append";
1750
- if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), at(i.audio)) {
1823
+ if ((a === "replace-active" || a === "replace-all") && (e.onProcessorInterrupt?.(), t &&= (t.cancel(), null)), ht(i.audio)) {
1751
1824
  let e = i.audio.sampleRate ?? 24e3;
1752
1825
  return r.createUtterance({
1753
1826
  format: {
@@ -1763,7 +1836,7 @@ function Pt(e) {
1763
1836
  }
1764
1837
  let o = e.getIframeHost();
1765
1838
  if (!o) throw new Z("Speech session is not attached.");
1766
- let s = await Ot(i.audio, i.signal);
1839
+ let s = await Rt(i.audio, i.signal);
1767
1840
  return o.speechPlay({
1768
1841
  source: s,
1769
1842
  characterId: i.characterId,
@@ -1775,13 +1848,13 @@ function Pt(e) {
1775
1848
  },
1776
1849
  createUtterance(r) {
1777
1850
  e.assertSessionStarted(), n("createUtterance", "externalSpeechAudio");
1778
- let i = ht(r);
1851
+ let i = Tt(r);
1779
1852
  if (r.track && r.track.kind !== "audio") throw new Z("createUtterance track must be an audio MediaStreamTrack.");
1780
1853
  let a = r.queue ?? "replace-active";
1781
1854
  if (a !== "replace-active" && a !== "replace-all") throw new Z("createUtterance queue must be replace-active or replace-all.");
1782
1855
  e.onProcessorInterrupt?.(), t &&= (t.cancel(), null);
1783
- let o = new Nt({
1784
- id: kt(),
1856
+ let o = new Ut({
1857
+ id: zt(),
1785
1858
  characterId: r.characterId ?? e.getActiveCharacterId(),
1786
1859
  format: i,
1787
1860
  queue: a,
@@ -1793,7 +1866,7 @@ function Pt(e) {
1793
1866
  t === o && (t = null);
1794
1867
  }), r.track && (async () => {
1795
1868
  try {
1796
- if (await Dt({
1869
+ if (await Lt({
1797
1870
  track: r.track,
1798
1871
  utterance: o,
1799
1872
  sampleRate: i.sampleRate,
@@ -1821,16 +1894,16 @@ function Pt(e) {
1821
1894
  }
1822
1895
  //#endregion
1823
1896
  //#region src/v2/types/sessionInteraction.ts
1824
- function Ft(e) {
1897
+ function Gt(e) {
1825
1898
  let t = e?.trim();
1826
1899
  return t === "full" || t === "face" || t === "medium" ? t : void 0;
1827
1900
  }
1828
1901
  //#endregion
1829
1902
  //#region src/v2/experience.ts
1830
- function It(e) {
1903
+ function Kt(e) {
1831
1904
  return !!(e.showClose === !0 || e.returnUrl?.trim() || e.closeButton === !0 || e.closeButton && typeof e.closeButton == "object" && e.closeButton.visible !== !1);
1832
1905
  }
1833
- var Lt = class e {
1906
+ var qt = class e {
1834
1907
  bootstrap;
1835
1908
  conversationProcessor;
1836
1909
  iframeHost = null;
@@ -1845,16 +1918,16 @@ var Lt = class e {
1845
1918
  attached = !1;
1846
1919
  pendingFit = null;
1847
1920
  closeHandlers = [];
1848
- eventRegistry = $e();
1921
+ eventRegistry = lt();
1849
1922
  readyEnvelope = null;
1850
1923
  startedEnvelope = null;
1851
1924
  conversationCache = [];
1852
1925
  speech;
1853
1926
  constructor(e) {
1854
- this.bootstrap = e, this.conversationProcessor = e.conversationProcessor ?? null, this.resolvedSession = e.kind === "launch" ? e.session ?? null : null, this.launchToken = e.kind === "launch" ? e.launch : null, this.speech = Pt({
1927
+ 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 = Wt({
1855
1928
  getIframeHost: () => this.iframeHost,
1856
1929
  assertSessionStarted: () => this.assertSessionStarted(),
1857
- getCapabilities: () => Rt(this.resolvedSession),
1930
+ getCapabilities: () => Jt(this.resolvedSession),
1858
1931
  getActiveCharacterId: () => "character_unknown",
1859
1932
  onProcessorInterrupt: () => {
1860
1933
  this.processorAbortController?.abort(), this.processorAbortController = null;
@@ -1869,6 +1942,9 @@ var Lt = class e {
1869
1942
  kind: "launch",
1870
1943
  launch: n,
1871
1944
  session: t.session,
1945
+ backdropId: t.backdropId,
1946
+ locationId: t.locationId,
1947
+ avatarId: t.avatarId,
1872
1948
  embedBaseUrl: t.embedBaseUrl,
1873
1949
  debug: t.debug,
1874
1950
  speechOnly: t.speechOnly,
@@ -1886,6 +1962,7 @@ var Lt = class e {
1886
1962
  secondaryLocale: t.secondaryLocale,
1887
1963
  learningLocale: t.learningLocale,
1888
1964
  language: t.language,
1965
+ backdropId: t.backdropId,
1889
1966
  locationId: t.locationId,
1890
1967
  avatarId: t.avatarId,
1891
1968
  castSize: t.castSize,
@@ -1894,6 +1971,7 @@ var Lt = class e {
1894
1971
  mode: t.mode,
1895
1972
  speechInputMode: t.speechInputMode,
1896
1973
  speechOnly: t.speechOnly,
1974
+ attribution: t.attribution,
1897
1975
  ui: t.ui,
1898
1976
  onStart: t.onStart,
1899
1977
  onUserTranscript: t.onUserTranscript,
@@ -1906,6 +1984,7 @@ var Lt = class e {
1906
1984
  secondaryLocale: t.secondaryLocale,
1907
1985
  learningLocale: t.learningLocale,
1908
1986
  language: t.language,
1987
+ backdropId: t.backdropId,
1909
1988
  locationId: t.locationId,
1910
1989
  avatarId: t.avatarId,
1911
1990
  castSize: t.castSize,
@@ -1914,6 +1993,7 @@ var Lt = class e {
1914
1993
  mode: t.mode,
1915
1994
  speechInputMode: t.speechInputMode,
1916
1995
  speechOnly: t.speechOnly,
1996
+ attribution: t.attribution,
1917
1997
  ui: t.ui,
1918
1998
  onStart: t.onStart,
1919
1999
  onUserTranscript: t.onUserTranscript,
@@ -1928,7 +2008,7 @@ var Lt = class e {
1928
2008
  return null;
1929
2009
  }
1930
2010
  on(e, t) {
1931
- let n = et(this.eventRegistry, e, t);
2011
+ let n = ut(this.eventRegistry, e, t);
1932
2012
  return e === "ready" && this.readyEnvelope && queueMicrotask(() => t(this.readyEnvelope)), e === "started" && this.startedEnvelope && queueMicrotask(() => t(this.startedEnvelope)), n;
1933
2013
  }
1934
2014
  async attach(e) {
@@ -1942,13 +2022,13 @@ var Lt = class e {
1942
2022
  if (this.closed) throw Error("Session has ended.");
1943
2023
  if (this.attached && this.iframeHost) return this.createPlayerFacade();
1944
2024
  this.iframeHost &&= (this.iframeHost.destroy(), null), this.attachReturnUrl = e.returnUrl?.trim() || null;
1945
- let t = this.bootstrap.embedBaseUrl ?? qe(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = Je(t, n, r || this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.locationId, r || this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, It(e), this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.castSize), a = Xe(i), o = null, s = new Promise((e) => {
2025
+ let t = this.bootstrap.embedBaseUrl ?? nt(), n = this.bootstrap.debug === !0, r = this.bootstrap.speechOnly === !0, i = it(t, n, r ? void 0 : rt(this.bootstrap.backdropId, this.bootstrap.locationId), r ? void 0 : this.bootstrap.avatarId, e.fit, this.bootstrap.ui, Kt(e), this.bootstrap.kind === "launch" ? void 0 : this.bootstrap.castSize), a = ot(i), o = null, s = new Promise((e) => {
1946
2026
  o = e;
1947
2027
  }), c = null, l = new Promise((e) => {
1948
2028
  c = e;
1949
- }), u = Ue((e) => {
2029
+ }), u = Qe((e) => {
1950
2030
  this.readyEnvelope ||= (this.resolvedSession = e, this.emitWrapped("ready", { session: e }));
1951
- }), d = this.bootstrap.onUserTranscript, f = He({
2031
+ }), d = this.bootstrap.onUserTranscript, f = Ze({
1952
2032
  container: e.container,
1953
2033
  src: i,
1954
2034
  playerOrigin: a,
@@ -2011,7 +2091,7 @@ var Lt = class e {
2011
2091
  onWidgetDragEnd: (t) => e.onWidgetDragEnd?.(t)
2012
2092
  });
2013
2093
  this.iframeHost = f;
2014
- let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), K(this.bootstrap.sessionEndpoint, {
2094
+ let p = this.resolveMintInteraction(), m = this.bootstrap.kind === "sessionEndpoint" ? (this.endpointAbortController = new AbortController(), J(this.bootstrap.sessionEndpoint, {
2015
2095
  experienceId: this.bootstrap.experienceId,
2016
2096
  locale: this.bootstrap.locale,
2017
2097
  secondaryLocale: this.bootstrap.secondaryLocale,
@@ -2020,15 +2100,17 @@ var Lt = class e {
2020
2100
  mode: p.mode,
2021
2101
  speechInputMode: p.speechInputMode,
2022
2102
  speechOnly: this.bootstrap.speechOnly,
2103
+ attribution: this.bootstrap.attribution,
2023
2104
  signal: this.endpointAbortController.signal
2024
- })) : this.bootstrap.kind === "public" ? Ee(this.bootstrap.experienceId, {
2105
+ })) : this.bootstrap.kind === "public" ? ke(this.bootstrap.experienceId, {
2025
2106
  locale: this.bootstrap.locale,
2026
2107
  secondaryLocale: this.bootstrap.secondaryLocale,
2027
2108
  learningLocale: this.bootstrap.learningLocale,
2028
2109
  language: this.bootstrap.language,
2029
2110
  mode: p.mode,
2030
2111
  speechInputMode: p.speechInputMode,
2031
- speechOnly: this.bootstrap.speechOnly
2112
+ speechOnly: this.bootstrap.speechOnly,
2113
+ attribution: this.bootstrap.attribution
2032
2114
  }) : Promise.resolve(this.bootstrap.session ? {
2033
2115
  session: this.bootstrap.session,
2034
2116
  launch: this.bootstrap.launch
@@ -2043,7 +2125,7 @@ var Lt = class e {
2043
2125
  f.postParentHello();
2044
2126
  let g = h?.launch ?? (this.bootstrap.kind === "launch" ? this.bootstrap.launch : null), _ = h?.session ?? (this.bootstrap.kind === "launch" ? this.bootstrap.session : void 0);
2045
2127
  if (!g) throw f.destroy(), this.iframeHost === f && (this.iframeHost = null), Error("Session Launch response did not include a launch token.");
2046
- return this.launchToken = g, _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" && ye(_), f.postLaunch(g, _, {
2128
+ return this.launchToken = g, _ ? (this.resolvedSession = _, this.bootstrap.kind === "launch" && Se(_), f.postLaunch(g, _, {
2047
2129
  startButton: e.startButton,
2048
2130
  showFeedback: e.showFeedback
2049
2131
  }), u.setValue(_)) : f.postLaunch(g, void 0, {
@@ -2077,11 +2159,16 @@ var Lt = class e {
2077
2159
  this.assertSessionStarted(), await this.iframeHost.focusCharacter(e);
2078
2160
  }
2079
2161
  async setFit(e) {
2080
- let t = Ft(e);
2162
+ let t = Gt(e);
2081
2163
  if (!t) throw Error("setFit requires \"full\", \"medium\", or \"face\".");
2082
2164
  if (this.closed) throw Error("Session has ended.");
2083
2165
  this.pendingFit = t, !(!this.attached || !this.iframeHost) && await this.iframeHost.setFit(t);
2084
2166
  }
2167
+ async conversion(e) {
2168
+ if (this.closed) throw Error("Session has ended.");
2169
+ if (!this.iframeHost) throw Error("conversion() requires attach() first.");
2170
+ await this.iframeHost.conversion(e);
2171
+ }
2085
2172
  getLastTurn() {
2086
2173
  if (this.conversationCache.length === 0) return [];
2087
2174
  let e = this.conversationCache[this.conversationCache.length - 1].turnId;
@@ -2091,7 +2178,7 @@ var Lt = class e {
2091
2178
  this.close();
2092
2179
  }
2093
2180
  destroy() {
2094
- this.closed || (this.closed = !0, this.processorAbortController?.abort(), this.processorAbortController = null, this.endpointAbortController?.abort(), this.endpointAbortController = null, this.attachInFlight = null, this.iframeHost?.destroy(), this.iframeHost = null, nt(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.attached = !1);
2181
+ 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, ft(this.eventRegistry), this.readyEnvelope = null, this.startedEnvelope = null, this.closeHandlers.length = 0, this.attached = !1);
2095
2182
  }
2096
2183
  resolveMintInteraction() {
2097
2184
  return this.bootstrap.kind === "launch" ? {} : {
@@ -2103,8 +2190,8 @@ var Lt = class e {
2103
2190
  return this.resolvedSession?.id ?? "";
2104
2191
  }
2105
2192
  emitWrapped(e, t) {
2106
- let n = Qe(e, this.getSessionId(), t);
2107
- return tt(this.eventRegistry, e, n), n;
2193
+ let n = ct(e, this.getSessionId(), t);
2194
+ return dt(this.eventRegistry, e, n), n;
2108
2195
  }
2109
2196
  queueProcessorTurn(e) {
2110
2197
  if (!e.isFinal || !e.text.trim() || !this.conversationProcessor) return;
@@ -2113,7 +2200,7 @@ var Lt = class e {
2113
2200
  let n = this.processorAbortController.signal;
2114
2201
  this.processorChain = this.processorChain.then(async () => {
2115
2202
  if (!n.aborted) try {
2116
- let r = await ke(t, {
2203
+ let r = await Me(t, {
2117
2204
  utteranceId: e.utteranceId,
2118
2205
  text: e.text,
2119
2206
  conversation: this.conversationCache,
@@ -2163,7 +2250,7 @@ var Lt = class e {
2163
2250
  };
2164
2251
  }
2165
2252
  };
2166
- function Rt(e) {
2253
+ function Jt(e) {
2167
2254
  return e ? {
2168
2255
  textSpeech: e.capabilities.speech.output,
2169
2256
  externalSpeechAudio: e.capabilities.speech.externalAudio
@@ -2174,26 +2261,26 @@ function Rt(e) {
2174
2261
  }
2175
2262
  //#endregion
2176
2263
  //#region src/widget/dockGeometry.ts
2177
- var zt = "(min-width: 768px)", Bt = 24, Vt = .5, Ht = 1200, Ut = .85, Wt = 9 / 16;
2178
- function Gt() {
2264
+ var Yt = "(min-width: 768px)", Xt = 24, Zt = .5, Qt = 1200, $t = .85, en = 9 / 16;
2265
+ function tn() {
2179
2266
  if (typeof window > "u") return 800;
2180
2267
  let e = window.screen?.availHeight;
2181
2268
  return typeof e == "number" && e > 0 ? e : window.innerHeight;
2182
2269
  }
2183
- function Kt(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = Bt, r = typeof window < "u" ? Gt() : 800) {
2184
- let i = Math.max(160, Math.min(t - n * 2, t * Ut)), a = Math.max(120, e - n * 2), o = Math.min(r * Vt, Ht, i), s = o * Wt;
2185
- return s > a && (s = a, o = s / Wt, o > i && (o = i, s = o * Wt)), {
2270
+ function nn(e = typeof window < "u" ? window.innerWidth : 1280, t = typeof window < "u" ? window.innerHeight : 800, n = Xt, r = typeof window < "u" ? tn() : 800) {
2271
+ let i = Math.max(160, Math.min(t - n * 2, t * $t)), a = Math.max(120, e - n * 2), o = Math.min(r * Zt, Qt, i), s = o * en;
2272
+ return s > a && (s = a, o = s / en, o > i && (o = i, s = o * en)), {
2186
2273
  width: Math.round(s),
2187
2274
  height: Math.round(o)
2188
2275
  };
2189
2276
  }
2190
- function qt(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = Bt) {
2277
+ function rn(e, t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800, r = Xt) {
2191
2278
  return {
2192
2279
  left: Math.max(r, t - e.width - r),
2193
2280
  top: Math.max(r, n - e.height - r)
2194
2281
  };
2195
2282
  }
2196
- function Jt(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = Bt) {
2283
+ function an(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typeof window < "u" ? window.innerHeight : 800, a = Xt) {
2197
2284
  let o = Math.max(a, r - n.width - a), s = Math.max(a, i - n.height - a);
2198
2285
  return {
2199
2286
  left: Math.min(Math.max(a, e), o),
@@ -2201,14 +2288,14 @@ function Jt(e, t, n, r = typeof window < "u" ? window.innerWidth : 1280, i = typ
2201
2288
  };
2202
2289
  }
2203
2290
  function Q(e = typeof window < "u" ? window.matchMedia.bind(window) : () => ({ matches: !0 })) {
2204
- return e(zt).matches;
2291
+ return e(Yt).matches;
2205
2292
  }
2206
2293
  //#endregion
2207
2294
  //#region src/widget/mountExperienceWidget.ts
2208
- function Yt(e) {
2295
+ function on(e) {
2209
2296
  return e === "bottom-right" || e === "bottom-left" ? e : "static";
2210
2297
  }
2211
- function Xt(e) {
2298
+ function sn(e) {
2212
2299
  if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
2213
2300
  let t = typeof e == "string" ? e.trim() : "";
2214
2301
  return t ? /^\d+(\.\d+)?$/.test(t) ? `${t}px` : t : "16px";
@@ -2216,8 +2303,8 @@ function Xt(e) {
2216
2303
  function $(e) {
2217
2304
  return e === "expanded" || e === "docked";
2218
2305
  }
2219
- var Zt = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 0 0-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 0 0-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 0 0-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 0 0-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 0 0 1.066-2.573c-.94-1.543.826-3.31 2.37-2.37c1 .608 2.296.07 2.572-1.065\"/><path d=\"M9 12a3 3 0 1 0 6 0a3 3 0 0 0-6 0\"/></svg>", Qt = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\"><path fill=\"currentColor\" d=\"M18.3 5.71a1 1 0 0 0-1.41 0L12 10.59 7.11 5.7A1 1 0 0 0 5.7 7.11L10.59 12l-4.9 4.89a1 1 0 1 0 1.42 1.42L12 13.41l4.89 4.9a1 1 0 0 0 1.42-1.42L13.41 12l4.9-4.89a1 1 0 0 0-.01-1.4Z\"/></svg>", $t = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M18 10h-4V6m6-2l-6 6m-8 4h4v4m0-4l-6 6\"/></svg>", en = "<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M16 4h4v4m-6 2l6-6M8 20H4v-4m0 4l6-6\"/></svg>";
2220
- function tn(e, t, n) {
2306
+ var cn = "<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>", ln = "<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>", un = "<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>", dn = "<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>";
2307
+ function fn(e, t, n) {
2221
2308
  re(I);
2222
2309
  let r = c({
2223
2310
  galleryThumb: t.galleryThumb,
@@ -2247,7 +2334,7 @@ function tn(e, t, n) {
2247
2334
  }
2248
2335
  return e.replaceChildren(i), n?.parallax === !1 ? () => {} : ne(i);
2249
2336
  }
2250
- function nn(e) {
2337
+ function pn(e) {
2251
2338
  return e.startButton ? {
2252
2339
  ...e.startButton,
2253
2340
  label: e.startButton.label ?? e.startButtonLabel ?? "Tap to talk",
@@ -2259,7 +2346,7 @@ function nn(e) {
2259
2346
  variant: "primary"
2260
2347
  };
2261
2348
  }
2262
- function rn(e) {
2349
+ function mn(e) {
2263
2350
  let t = !1, n = () => {
2264
2351
  t || e();
2265
2352
  }, r = () => {
@@ -2279,12 +2366,12 @@ function rn(e) {
2279
2366
  t = !0, window.removeEventListener("load", r), i?.();
2280
2367
  };
2281
2368
  }
2282
- function an(e, t) {
2369
+ function hn(e, t) {
2283
2370
  oe(ie);
2284
2371
  let n = t.experienceId?.trim();
2285
2372
  if (!n) throw Error("ExperienceWidget requires experienceId.");
2286
- let r = t.prefetch ?? "onExpand", i = Yt(t.position), a = document.createElement("div");
2287
- a.className = "liforma-ew", a.dataset.state = "collapsed", a.dataset.prefetch = r, a.dataset.position = i, a.style.setProperty("--liforma-ew-max-w", t.expandedMaxWidth ?? "100%"), a.style.setProperty("--liforma-ew-max-h", t.expandedMaxHeight ?? "100%"), i !== "static" && a.style.setProperty("--liforma-ew-offset", Xt(t.offset));
2373
+ let r = t.prefetch ?? "onExpand", i = on(t.position), a = document.createElement("div");
2374
+ 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", sn(t.offset));
2288
2375
  let o = document.createElement("button");
2289
2376
  o.type = "button", o.className = "liforma-ew__hit", o.setAttribute("aria-label", t.alt), o.disabled = !0;
2290
2377
  let s = document.createElement("div");
@@ -2304,22 +2391,22 @@ function an(e, t) {
2304
2391
  let m = document.createElement("span");
2305
2392
  m.className = "liforma-ew__drag-grip", m.setAttribute("aria-hidden", "true");
2306
2393
  let h = document.createElement("button");
2307
- h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = $t, h.setAttribute("aria-label", "Reduce");
2394
+ h.type = "button", h.className = "liforma-ew__icon-btn liforma-ew__dock-toggle", h.innerHTML = un, h.setAttribute("aria-label", "Reduce");
2308
2395
  let g = document.createElement("button");
2309
- g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = Zt, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
2396
+ g.type = "button", g.className = "liforma-ew__icon-btn liforma-ew__settings", g.innerHTML = cn, g.setAttribute("aria-label", "Audio settings"), g.setAttribute("aria-pressed", "false");
2310
2397
  let _ = document.createElement("button");
2311
- _.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = Qt, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
2398
+ _.type = "button", _.className = "liforma-ew__icon-btn liforma-ew__close", _.innerHTML = ln, _.setAttribute("aria-label", "Close"), p.append(m, h, g, _);
2312
2399
  let v = document.createElement("div");
2313
2400
  v.className = "liforma-ew__stage";
2314
2401
  let y = document.createElement("div");
2315
2402
  y.className = "liforma-ew__status", y.hidden = !0, f.append(v, y), u.append(d, f), a.append(o, l, u, p), e.replaceChildren(a);
2316
- let b = null, x = !1, S = !1, ee = !1, C = !1, w = !1, T = !1, E = !1, D = 0, O = "", k = null, A = null, j = null, M = null, N = null, P = null, F = null, te = 0, ne = 0, I = null, L = !1, re = new AbortController(), ae = t.parallax !== !1, R = () => {
2403
+ 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, ee = null, N = null, P = null, F = null, te = 0, ne = 0, I = null, L = !1, re = new AbortController(), ae = t.parallax !== !1, R = () => {
2317
2404
  let e = a.dataset.state;
2318
2405
  return e === "expanded" || e === "docked" || e === "collapsed" ? e : "collapsed";
2319
2406
  }, z = () => {
2320
- j !== null && (clearTimeout(j), j = null);
2407
+ M !== null && (clearTimeout(M), M = null);
2321
2408
  }, se = () => {
2322
- M !== null && (clearTimeout(M), M = null), a.classList.remove("liforma-ew--layout-settling");
2409
+ ee !== null && (clearTimeout(ee), ee = null), a.classList.remove("liforma-ew--layout-settling");
2323
2410
  }, ce = () => {
2324
2411
  for (let e of [
2325
2412
  f,
@@ -2336,11 +2423,11 @@ function an(e, t) {
2336
2423
  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";
2337
2424
  }, B = (e, t) => {
2338
2425
  if (R() !== "docked") return;
2339
- let n = Kt(), r = Jt(e - te, t - ne, n);
2426
+ let n = nn(), r = an(e - te, t - ne, n);
2340
2427
  N = r.left, P = r.top, le(r.left, r.top, n.width, n.height);
2341
2428
  }, de = (e, t) => {
2342
2429
  if (R() !== "docked" || !Number.isFinite(e) || !Number.isFinite(t) || e === 0 && t === 0) return;
2343
- let n = Kt(), r = N ?? f.getBoundingClientRect().left, i = P ?? f.getBoundingClientRect().top, a = Jt(r + e, i + t, n);
2430
+ let n = nn(), r = N ?? f.getBoundingClientRect().left, i = P ?? f.getBoundingClientRect().top, a = an(r + e, i + t, n);
2344
2431
  N = a.left, P = a.top, le(a.left, a.top, n.width, n.height);
2345
2432
  }, fe = (e) => {
2346
2433
  I === "toolbar" && (F === null || e.pointerId !== F || (e.preventDefault(), B(e.clientX, e.clientY)));
@@ -2353,89 +2440,89 @@ function an(e, t) {
2353
2440
  F = n, I = "toolbar", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
2354
2441
  let r = f.getBoundingClientRect();
2355
2442
  te = e - r.left, ne = t - r.top, L || (L = !0, window.addEventListener("pointermove", fe), window.addEventListener("pointerup", V), window.addEventListener("pointercancel", V));
2356
- }, me = (e) => {
2443
+ }, H = (e) => {
2357
2444
  if (S || R() !== "docked" || !Q() || F !== null) return;
2358
2445
  F = e.pointerId, I = "player", p.classList.add("liforma-ew__toolbar--dragging"), a.classList.add("liforma-ew--dock-dragging");
2359
2446
  let t = f.getBoundingClientRect();
2360
2447
  N = t.left, P = t.top;
2361
- }, H = (e) => {
2448
+ }, me = (e) => {
2362
2449
  I === "player" && (F === null || e.pointerId !== F || de(e.dx, e.dy));
2363
- }, U = (e) => {
2450
+ }, he = (e) => {
2364
2451
  I === "player" && (F === null || e.pointerId !== F || V());
2365
- }, W = () => {
2452
+ }, U = () => {
2366
2453
  let e = Q(), t = R();
2367
2454
  if (!e || t !== "expanded" && t !== "docked") {
2368
2455
  h.hidden = !0;
2369
2456
  return;
2370
2457
  }
2371
- h.hidden = !1, t === "docked" ? (h.innerHTML = en, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = $t, h.setAttribute("aria-label", "Reduce"));
2372
- }, he = (e) => {
2373
- let t = Kt(), n = e && N !== null && P !== null ? Jt(N, P, t) : qt(t);
2374
- n = Jt(n.left, n.top, t), N = n.left, P = n.top, le(n.left, n.top, t.width, t.height), W();
2375
- }, ge = () => {
2458
+ h.hidden = !1, t === "docked" ? (h.innerHTML = dn, h.setAttribute("aria-label", "Maximize")) : (h.innerHTML = un, h.setAttribute("aria-label", "Reduce"));
2459
+ }, ge = (e) => {
2460
+ let t = nn(), n = e && N !== null && P !== null ? an(N, P, t) : rn(t);
2461
+ n = an(n.left, n.top, t), N = n.left, P = n.top, le(n.left, n.top, t.width, t.height), U();
2462
+ }, _e = () => {
2376
2463
  a.classList.remove("liforma-ew--session-revealed"), requestAnimationFrame(() => {
2377
2464
  requestAnimationFrame(() => {
2378
2465
  S || !$(a.dataset.state) || a.classList.add("liforma-ew--session-revealed");
2379
2466
  });
2380
2467
  });
2381
- }, _e = (e) => {
2382
- if (se(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !E) {
2468
+ }, W = (e) => {
2469
+ if (se(), a.classList.remove("liforma-ew--session-revealed"), a.classList.add("liforma-ew--layout-settling"), e(), !D) {
2383
2470
  a.classList.remove("liforma-ew--layout-settling");
2384
2471
  return;
2385
2472
  }
2386
- M = setTimeout(() => {
2387
- if (M = null, S || !$(a.dataset.state)) {
2473
+ ee = setTimeout(() => {
2474
+ if (ee = null, S || !$(a.dataset.state)) {
2388
2475
  a.classList.remove("liforma-ew--layout-settling");
2389
2476
  return;
2390
2477
  }
2391
- a.classList.remove("liforma-ew--layout-settling"), ge();
2478
+ a.classList.remove("liforma-ew--layout-settling"), _e();
2392
2479
  }, 220);
2393
- }, ve = () => (a.classList.add("liforma-ew--session-concealing"), a.classList.remove("liforma-ew--session-revealed"), new Promise((e) => {
2394
- z(), j = setTimeout(() => {
2395
- j = null, a.classList.remove("liforma-ew--session-concealing"), e();
2480
+ }, G = () => (a.classList.add("liforma-ew--session-concealing"), a.classList.remove("liforma-ew--session-revealed"), new Promise((e) => {
2481
+ z(), M = setTimeout(() => {
2482
+ M = null, a.classList.remove("liforma-ew--session-concealing"), e();
2396
2483
  }, 280);
2397
- })), ye = {
2484
+ })), ve = {
2398
2485
  galleryThumb: t.galleryThumb,
2399
2486
  avatarImage: t.avatarImage,
2400
2487
  backgroundImage: t.backgroundImage,
2401
2488
  foregroundImage: t.foregroundImage,
2402
2489
  fallbackImage: t.fallbackImage
2403
- }, G = (e) => {
2490
+ }, K = (e) => {
2404
2491
  if (!e) {
2405
2492
  y.hidden = !0, y.textContent = "";
2406
2493
  return;
2407
2494
  }
2408
2495
  y.hidden = !1, y.textContent = e;
2409
- }, be = (e) => {
2496
+ }, ye = (e) => {
2410
2497
  if (!e) {
2411
2498
  c.hidden = !0, c.textContent = "";
2412
2499
  return;
2413
2500
  }
2414
2501
  c.hidden = !1, c.textContent = e, s.contains(c) || s.append(c);
2502
+ }, be = () => {
2503
+ C = !0, o.disabled = !1, ye(null), r === "onExpand" && t.onPrefetchReady?.();
2415
2504
  }, xe = () => {
2416
- ee = !0, o.disabled = !1, be(null), r === "onExpand" && t.onPrefetchReady?.();
2417
- }, Se = () => {
2418
- C = !0, a.dataset.warm = "true", l.hidden = !1, E || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
2419
- }, Ce = (e) => {
2420
- k?.(), k = null;
2421
- let t = tn(s, e, { parallax: ae });
2422
- return t ? (k = t, !0) : !1;
2423
- }, we = () => {
2424
- if (Ce(ye)) {
2425
- xe();
2505
+ w = !0, a.dataset.warm = "true", l.hidden = !1, D || (o.tabIndex = -1, o.setAttribute("aria-hidden", "true")), t.onPrefetchReady?.();
2506
+ }, Se = (e) => {
2507
+ A?.(), A = null;
2508
+ let t = fn(s, e, { parallax: ae });
2509
+ return t ? (A = t, !0) : !1;
2510
+ }, Ce = () => {
2511
+ if (Se(ve)) {
2512
+ be();
2426
2513
  return;
2427
2514
  }
2428
- be("Loading…"), ue(n, { signal: re.signal }).then((e) => {
2515
+ ye("Loading…"), ue(n, { signal: re.signal }).then((e) => {
2429
2516
  if (!S) {
2430
- if (!Ce({ galleryThumb: e.galleryThumb })) throw Error("Experience preview is missing gallery thumb images.");
2431
- xe();
2517
+ if (!Se({ galleryThumb: e.galleryThumb })) throw Error("Experience preview is missing gallery thumb images.");
2518
+ be();
2432
2519
  }
2433
2520
  }).catch((e) => {
2434
2521
  if (S || re.signal.aborted) return;
2435
2522
  let n = e instanceof Error ? e : Error(String(e));
2436
- be("Preview unavailable"), o.disabled = !0, t.onError?.(n), console.error("[ExperienceWidget]", n);
2523
+ ye("Preview unavailable"), o.disabled = !0, t.onError?.(n), console.error("[ExperienceWidget]", n);
2437
2524
  });
2438
- }, Te = () => ({
2525
+ }, we = () => ({
2439
2526
  experienceId: n,
2440
2527
  ui: "widget",
2441
2528
  ...t.sessionEndpoint ? { sessionEndpoint: t.sessionEndpoint } : {},
@@ -2445,70 +2532,70 @@ function an(e, t) {
2445
2532
  ...t.speechInputMode ? { speechInputMode: t.speechInputMode } : {},
2446
2533
  ...t.speechOnly === void 0 ? {} : { speechOnly: t.speechOnly },
2447
2534
  ...t.embedBaseUrl ? { embedBaseUrl: t.embedBaseUrl } : {}
2448
- }), Ee = () => ({
2535
+ }), Te = () => ({
2449
2536
  ...t.fit ? { fit: t.fit } : {},
2450
- startButton: nn(t),
2537
+ startButton: pn(t),
2451
2538
  ...t.showFeedback === void 0 ? {} : { showFeedback: t.showFeedback }
2452
- }), K = (e = !0) => {
2453
- o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), ce(), a.dataset.state = "expanded", G(null), typeof document < "u" && (O = document.body.style.overflow, document.body.style.overflow = "hidden"), W(), e && t.onExpanded?.();
2454
- }, De = () => {
2455
- o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked", G(null), typeof document < "u" && (document.body.style.overflow = O), he(!0), W(), b?.setWidgetChrome("docked");
2456
- }, Oe = (e) => {
2539
+ }), q = (e = !0) => {
2540
+ o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "true"), ce(), a.dataset.state = "expanded", K(null), typeof document < "u" && (k = document.body.style.overflow, document.body.style.overflow = "hidden"), U(), e && t.onExpanded?.();
2541
+ }, Ee = () => {
2542
+ o.hidden = !0, u.hidden = !1, p.hidden = !1, u.setAttribute("aria-modal", "false"), a.dataset.state = "docked", K(null), typeof document < "u" && (document.body.style.overflow = k), ge(!0), U(), b?.setWidgetChrome("docked");
2543
+ }, De = (e) => {
2457
2544
  e.on("started", () => {
2458
- S || (E = !0, a.dataset.live = "true", G(null), t.onStarted?.(), $(a.dataset.state) && ge());
2545
+ S || (D = !0, a.dataset.live = "true", K(null), t.onStarted?.(), $(a.dataset.state) && _e());
2459
2546
  }), e.on("feedback", (e) => {
2460
2547
  S || t.onFeedback?.(e);
2461
2548
  }), e.on("feedbackFailed", (e) => {
2462
2549
  S || t.onFeedbackFailed?.(e);
2463
2550
  });
2551
+ }, Oe = () => {
2552
+ se(), u.hidden = !0, p.hidden = !0, ce(), a.dataset.state = "collapsed", a.classList.remove("liforma-ew--session-revealed"), a.classList.remove("liforma-ew--session-concealing"), g.setAttribute("aria-pressed", "false"), o.hidden = !1, o.tabIndex = 0, o.removeAttribute("aria-hidden"), C && (o.disabled = !1), K(null), typeof document < "u" && (document.body.style.overflow = k), U();
2464
2553
  }, ke = () => {
2465
- se(), u.hidden = !0, p.hidden = !0, ce(), a.dataset.state = "collapsed", a.classList.remove("liforma-ew--session-revealed"), a.classList.remove("liforma-ew--session-concealing"), g.setAttribute("aria-pressed", "false"), o.hidden = !1, o.tabIndex = 0, o.removeAttribute("aria-hidden"), ee && (o.disabled = !1), G(null), typeof document < "u" && (document.body.style.overflow = O), W();
2466
- }, Ae = () => {
2467
- z(), se(), D += 1, x = !1, C = !1, w = !1, T = !1, E = !1;
2554
+ z(), se(), O += 1, x = !1, w = !1, T = !1, E = !1, D = !1;
2468
2555
  let e = b;
2469
2556
  b = null, e?.destroy(), v.replaceChildren(), l.replaceChildren(), l.hidden = !0, delete a.dataset.warm, delete a.dataset.live, a.classList.remove("liforma-ew--session-revealed");
2470
- }, q = () => {
2557
+ }, J = () => {
2471
2558
  if (!S && $(a.dataset.state)) {
2472
- if (V(), x = !1, b && T) {
2559
+ if (V(), x = !1, b && E) {
2473
2560
  let e = b;
2474
2561
  (async () => {
2475
- E && (await ve(), S || b !== e) || (C && e.setWidgetChrome("collapsed"), ke(), E ? (a.dataset.live = "true", o.tabIndex = 0, o.removeAttribute("aria-hidden"), o.disabled = !1) : C && Se(), t.onCollapsed?.(), t.onClose?.());
2562
+ D && (await G(), S || b !== e) || (w && e.setWidgetChrome("collapsed"), Oe(), D ? (a.dataset.live = "true", o.tabIndex = 0, o.removeAttribute("aria-hidden"), o.disabled = !1) : w && xe(), t.onCollapsed?.(), t.onClose?.());
2476
2563
  })();
2477
2564
  return;
2478
2565
  }
2479
- Ae(), ke(), t.onCollapsed?.(), t.onClose?.();
2566
+ ke(), Oe(), t.onCollapsed?.(), t.onClose?.();
2480
2567
  }
2481
- }, je = () => {
2482
- S || Q() && R() === "expanded" && _e(() => {
2483
- De();
2568
+ }, Ae = () => {
2569
+ S || Q() && R() === "expanded" && W(() => {
2570
+ Ee();
2484
2571
  });
2485
- }, J = () => {
2486
- S || R() === "docked" && (V(), _e(() => {
2487
- ce(), K(!1), b?.setWidgetChrome("expanded");
2572
+ }, je = () => {
2573
+ S || R() === "docked" && (V(), W(() => {
2574
+ ce(), q(!1), b?.setWidgetChrome("expanded");
2488
2575
  }));
2489
2576
  }, Me = () => {
2490
- !b || !E || (z(), a.classList.remove("liforma-ew--session-revealed"), K(), b.setWidgetChrome("expanded"), x = !1, ge());
2577
+ !b || !D || (z(), a.classList.remove("liforma-ew--session-revealed"), q(), b.setWidgetChrome("expanded"), x = !1, _e());
2491
2578
  }, Ne = () => {
2492
- !b || !T || E || (z(), a.classList.remove("liforma-ew--session-revealed"), K(), x = !1, C || b.setWidgetChrome("expanded"));
2579
+ !b || !E || D || (z(), a.classList.remove("liforma-ew--session-revealed"), q(), x = !1, w || b.setWidgetChrome("expanded"));
2493
2580
  }, Pe = (e) => {
2494
- S || e !== D && !E || (z(), a.classList.remove("liforma-ew--session-revealed"), K(), x = !1, E && ge());
2581
+ S || e !== O && !D || (z(), a.classList.remove("liforma-ew--session-revealed"), q(), x = !1, D && _e());
2495
2582
  }, Fe = () => {
2496
- if (S || w || C || b || $(a.dataset.state)) return;
2497
- w = !0;
2498
- let e = D;
2583
+ if (S || T || w || b || $(a.dataset.state)) return;
2584
+ T = !0;
2585
+ let e = O;
2499
2586
  l.hidden = !1, (async () => {
2500
2587
  try {
2501
- let t = await Lt.startSession(Te());
2502
- if (S || e !== D) {
2588
+ let t = await qt.startSession(we());
2589
+ if (S || e !== O) {
2503
2590
  t.destroy();
2504
2591
  return;
2505
2592
  }
2506
- b = t, Oe(t);
2593
+ b = t, De(t);
2507
2594
  let n = await t.attach({
2508
2595
  container: l,
2509
- ...Ee(),
2596
+ ...Te(),
2510
2597
  onWidgetReady: () => {
2511
- S || e !== D || (w = !1, T = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") : Se());
2598
+ S || e !== O || (T = !1, E = !0, $(a.dataset.state) ? t.setWidgetChrome("expanded") : xe());
2512
2599
  },
2513
2600
  onWidgetExpand: () => {
2514
2601
  Pe(e);
@@ -2517,151 +2604,151 @@ function an(e, t) {
2517
2604
  S || ze(e);
2518
2605
  },
2519
2606
  onWidgetDragStart: (e) => {
2520
- S || me(e);
2607
+ S || H(e);
2521
2608
  },
2522
2609
  onWidgetDragMove: (e) => {
2523
- S || H(e);
2610
+ S || me(e);
2524
2611
  },
2525
2612
  onWidgetDragEnd: (e) => {
2526
- S || U(e);
2613
+ S || he(e);
2527
2614
  },
2528
2615
  onPlayerStatusChange: (e) => {
2529
- S || e === "error" && $(a.dataset.state) && G("Could not load the experience.");
2616
+ S || e === "error" && $(a.dataset.state) && K("Could not load the experience.");
2530
2617
  }
2531
2618
  });
2532
- if (S || e !== D) {
2619
+ if (S || e !== O) {
2533
2620
  t.destroy(), b === t && (b = null);
2534
2621
  return;
2535
2622
  }
2536
2623
  n.on("close", () => {
2537
- S || q();
2624
+ S || J();
2538
2625
  });
2539
2626
  } catch (n) {
2540
- if (S || e !== D) return;
2541
- w = !1, l.hidden = !0, l.replaceChildren(), b = null;
2627
+ if (S || e !== O) return;
2628
+ T = !1, l.hidden = !0, l.replaceChildren(), b = null;
2542
2629
  let r = n instanceof Error ? n : Error(String(n));
2543
2630
  t.onError?.(r), console.error("[ExperienceWidget] warm prefetch failed", r);
2544
2631
  }
2545
2632
  })();
2546
2633
  }, Ie = () => {
2547
- if (S || x || !ee || $(a.dataset.state)) return;
2548
- if (b && E) {
2634
+ if (S || x || !C || $(a.dataset.state)) return;
2635
+ if (b && D) {
2549
2636
  Me();
2550
2637
  return;
2551
2638
  }
2552
- if (b && T) {
2639
+ if (b && E) {
2553
2640
  Ne();
2554
2641
  return;
2555
2642
  }
2556
- let e = ++D;
2557
- x = !0, C = !1, w = !1, T = !1, E = !1, delete a.dataset.warm, delete a.dataset.live, l.hidden = !0, l.replaceChildren(), b &&= (b.destroy(), null), (async () => {
2643
+ let e = ++O;
2644
+ 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 () => {
2558
2645
  try {
2559
- K();
2560
- let t = await Lt.startSession(Te());
2561
- if (S || e !== D) {
2646
+ q();
2647
+ let t = await qt.startSession(we());
2648
+ if (S || e !== O) {
2562
2649
  t.destroy();
2563
2650
  return;
2564
2651
  }
2565
- b = t, Oe(t);
2652
+ b = t, De(t);
2566
2653
  let n = await t.attach({
2567
2654
  container: v,
2568
- ...Ee(),
2655
+ ...Te(),
2569
2656
  onWidgetAudioSettings: (e) => {
2570
2657
  S || ze(e);
2571
2658
  },
2572
2659
  onWidgetDragStart: (e) => {
2573
- S || me(e);
2660
+ S || H(e);
2574
2661
  },
2575
2662
  onWidgetDragMove: (e) => {
2576
- S || H(e);
2663
+ S || me(e);
2577
2664
  },
2578
2665
  onWidgetDragEnd: (e) => {
2579
- S || U(e);
2666
+ S || he(e);
2580
2667
  },
2581
2668
  onPlayerStatusChange: (e) => {
2582
- S || (e === "error" ? G("Could not load the experience.") : $(a.dataset.state) && G(null));
2669
+ S || (e === "error" ? K("Could not load the experience.") : $(a.dataset.state) && K(null));
2583
2670
  }
2584
2671
  });
2585
- if (S || e !== D) {
2672
+ if (S || e !== O) {
2586
2673
  t.destroy(), b === t && (b = null);
2587
2674
  return;
2588
2675
  }
2589
- T = !0, t.setWidgetChrome("expanded"), n.on("close", () => {
2590
- S || q();
2676
+ E = !0, t.setWidgetChrome("expanded"), n.on("close", () => {
2677
+ S || J();
2591
2678
  });
2592
2679
  } catch (n) {
2593
- if (S || e !== D) return;
2680
+ if (S || e !== O) return;
2594
2681
  let r = n instanceof Error ? n : Error(String(n));
2595
- G(r.message), t.onError?.(r), console.error("[ExperienceWidget]", r);
2682
+ K(r.message), t.onError?.(r), console.error("[ExperienceWidget]", r);
2596
2683
  } finally {
2597
- e === D && (x = !1);
2684
+ e === O && (x = !1);
2598
2685
  }
2599
2686
  })();
2600
2687
  }, Le = () => {
2601
2688
  if (!(S || $(a.dataset.state))) {
2602
- if (b && E) {
2689
+ if (b && D) {
2603
2690
  Me();
2604
2691
  return;
2605
2692
  }
2606
- if (b && T) {
2693
+ if (b && E) {
2607
2694
  Ne();
2608
2695
  return;
2609
2696
  }
2610
- if (w || b) {
2611
- K();
2697
+ if (T || b) {
2698
+ q();
2612
2699
  return;
2613
2700
  }
2614
2701
  Ie();
2615
2702
  }
2616
2703
  }, Re = (e) => {
2617
2704
  if (e.stopPropagation(), R() === "expanded") {
2618
- je();
2705
+ Ae();
2619
2706
  return;
2620
2707
  }
2621
- R() === "docked" && J();
2708
+ R() === "docked" && je();
2622
2709
  }, ze = (e) => {
2623
2710
  g.setAttribute("aria-pressed", e ? "true" : "false");
2624
2711
  }, Be = (e) => {
2625
2712
  e.stopPropagation(), $(a.dataset.state) && b?.toggleAudioSettings();
2626
- }, Y = (e) => {
2627
- R() === "docked" && Q() && (e.target?.closest("button") || (e.preventDefault(), pe(e.clientX, e.clientY, e.pointerId)));
2628
2713
  }, Ve = (e) => {
2629
- e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), q());
2630
- }, He = () => {
2714
+ R() === "docked" && Q() && (e.target?.closest("button") || (e.preventDefault(), pe(e.clientX, e.clientY, e.pointerId)));
2715
+ }, He = (e) => {
2716
+ e.key === "Escape" && $(a.dataset.state) && (e.preventDefault(), J());
2717
+ }, Ue = () => {
2631
2718
  if (!S) {
2632
2719
  if (R() === "docked") {
2633
2720
  if (!Q()) {
2634
- J();
2721
+ je();
2635
2722
  return;
2636
2723
  }
2637
- E ? _e(() => {
2638
- he(!0);
2639
- }) : he(!0);
2724
+ D ? W(() => {
2725
+ ge(!0);
2726
+ }) : ge(!0);
2640
2727
  return;
2641
2728
  }
2642
- W();
2729
+ U();
2643
2730
  }
2644
- }, Ue = typeof window < "u" ? window.matchMedia(zt) : null, We = () => {
2731
+ }, We = typeof window < "u" ? window.matchMedia(Yt) : null, Ge = () => {
2645
2732
  if (!S) {
2646
2733
  if (R() === "docked" && !Q()) {
2647
- J();
2734
+ je();
2648
2735
  return;
2649
2736
  }
2650
- W();
2737
+ U();
2651
2738
  }
2652
2739
  };
2653
- return o.addEventListener("click", Le), d.addEventListener("click", q), _.addEventListener("click", (e) => {
2654
- e.stopPropagation(), q();
2655
- }), h.addEventListener("click", Re), g.addEventListener("click", Be), p.addEventListener("pointerdown", Y), window.addEventListener("keydown", Ve), window.addEventListener("resize", He), Ue?.addEventListener("change", We), we(), W(), r === "eager" ? queueMicrotask(() => {
2740
+ return o.addEventListener("click", Le), d.addEventListener("click", J), _.addEventListener("click", (e) => {
2741
+ e.stopPropagation(), J();
2742
+ }), h.addEventListener("click", Re), g.addEventListener("click", Be), p.addEventListener("pointerdown", Ve), window.addEventListener("keydown", He), window.addEventListener("resize", Ue), We?.addEventListener("change", Ge), Ce(), U(), r === "eager" ? queueMicrotask(() => {
2656
2743
  S || Fe();
2657
- }) : r === "idle" && (A = rn(() => {
2744
+ }) : r === "idle" && (j = mn(() => {
2658
2745
  S || Fe();
2659
2746
  })), {
2660
2747
  root: a,
2661
2748
  expand: Le,
2662
- collapse: q,
2663
- dock: je,
2664
- maximize: J,
2749
+ collapse: J,
2750
+ dock: Ae,
2751
+ maximize: je,
2665
2752
  prefetch() {
2666
2753
  if (r === "onExpand") {
2667
2754
  Fe();
@@ -2670,11 +2757,11 @@ function an(e, t) {
2670
2757
  Fe();
2671
2758
  },
2672
2759
  destroy() {
2673
- S || (S = !0, V(), A?.(), A = null, re.abort(), k?.(), k = null, window.removeEventListener("keydown", Ve), window.removeEventListener("resize", He), Ue?.removeEventListener("change", We), Ae(), ke(), e.replaceChildren());
2760
+ S || (S = !0, V(), j?.(), j = null, re.abort(), A?.(), A = null, window.removeEventListener("keydown", He), window.removeEventListener("resize", Ue), We?.removeEventListener("change", Ge), ke(), Oe(), e.replaceChildren());
2674
2761
  }
2675
2762
  };
2676
2763
  }
2677
2764
  //#endregion
2678
- export { I as EXPERIENCE_THUMBNAIL_CSS, ie as EXPERIENCE_WIDGET_CSS, Lt as Experience, B as LiformaError, X as SPEECH_LIMITS, ut as SpeechBufferTimeoutError, Z as SpeechRuntimeError, lt as SpeechUtteranceClosedError, ct as UnsupportedSpeechOperationError, E as attachImageReady, T as attachLazyThumb, te as attachScrollLinkedParallax, m as buildHostedLaunchUrl, re as ensureExperienceThumbnailStyles, oe as ensureExperienceWidgetStyles, ue as fetchExperiencePreview, ee as getDefaultLazyRootMargin, O as horizontalParallaxFromViewportY, fe as liformaErrorFromResponse, an as mountExperienceWidget, n as navigateOnExperienceClose, h as resolveThumbnailHref, f as resolveThumbnailInteraction, c as resolveThumbnailLayers, r as thumbnailFitClass, s as toGalleryThumbUrl, ye as warnLocaleVoiceFallbacks };
2765
+ export { I as EXPERIENCE_THUMBNAIL_CSS, ie as EXPERIENCE_WIDGET_CSS, qt as Experience, B as LiformaError, X as SPEECH_LIMITS, bt as SpeechBufferTimeoutError, Z as SpeechRuntimeError, yt as SpeechUtteranceClosedError, vt as UnsupportedSpeechOperationError, D as attachImageReady, E as attachLazyThumb, te as attachScrollLinkedParallax, m as buildHostedLaunchUrl, re as ensureExperienceThumbnailStyles, oe as ensureExperienceWidgetStyles, ue as fetchExperiencePreview, C as getDefaultLazyRootMargin, k as horizontalParallaxFromViewportY, fe as liformaErrorFromResponse, hn as mountExperienceWidget, n as navigateOnExperienceClose, h as resolveThumbnailHref, f as resolveThumbnailInteraction, c as resolveThumbnailLayers, r as thumbnailFitClass, s as toGalleryThumbUrl, Se as warnLocaleVoiceFallbacks };
2679
2766
 
2680
2767
  //# sourceMappingURL=index.js.map