@burdenoff/fe-libs 2026.1024.2 → 2026.1024.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/dist/chrome/FooterBar.d.ts +1 -1
  2. package/dist/chrome/NativePageTransition.d.ts +1 -1
  3. package/dist/chrome/ProductPickerSheet.js +42 -42
  4. package/dist/chrome/ProductSwitcher.d.ts +8 -0
  5. package/dist/chrome/ProductSwitcher.js +83 -72
  6. package/dist/chrome/index.d.ts +9 -9
  7. package/dist/chrome/swipe/swipeMath.d.ts +1 -1
  8. package/dist/shared/assistant/api.d.ts +3 -3
  9. package/dist/shared/assistant/appControls/grammar.d.ts +21 -21
  10. package/dist/shared/assistant/appControls/languageReply.d.ts +1 -1
  11. package/dist/shared/assistant/appControls/names.d.ts +3 -3
  12. package/dist/shared/assistant/appControls/pageAdapters.d.ts +5 -5
  13. package/dist/shared/assistant/appControls/plan.d.ts +38 -38
  14. package/dist/shared/assistant/appControls/types.d.ts +15 -15
  15. package/dist/shared/assistant/appControls/useAssistantControl.d.ts +1 -1
  16. package/dist/shared/assistant/attachmentSources.d.ts +2 -2
  17. package/dist/shared/assistant/attachments.d.ts +5 -5
  18. package/dist/shared/assistant/autoRouting.d.ts +6 -6
  19. package/dist/shared/assistant/avatar/live/LiveAvatarMinutes.d.ts +24 -0
  20. package/dist/shared/assistant/avatar/live/LiveAvatarMinutes.js +161 -0
  21. package/dist/shared/assistant/avatar/live/LiveAvatarStage.js +95 -73
  22. package/dist/shared/assistant/avatar/live/LiveAvatarTabView.d.ts +6 -0
  23. package/dist/shared/assistant/avatar/live/LiveAvatarTabView.js +195 -171
  24. package/dist/shared/assistant/avatar/live/avatarSessionClient.d.ts +77 -1
  25. package/dist/shared/assistant/avatar/live/avatarSessionClient.js +193 -72
  26. package/dist/shared/assistant/avatar/live/createLiveAvatarSeam.d.ts +14 -1
  27. package/dist/shared/assistant/avatar/live/createLiveAvatarSeam.js +65 -40
  28. package/dist/shared/assistant/avatar/live/liveAvatarController.d.ts +64 -2
  29. package/dist/shared/assistant/avatar/live/liveAvatarController.js +403 -242
  30. package/dist/shared/assistant/avatar/live/liveAvatarMinutesView.d.ts +127 -0
  31. package/dist/shared/assistant/avatar/live/liveAvatarMinutesView.js +168 -0
  32. package/dist/shared/assistant/avatar/live/liveAvatarStatus.d.ts +3 -0
  33. package/dist/shared/assistant/avatar/live/liveAvatarStatus.js +11 -7
  34. package/dist/shared/assistant/avatar/useAvatarCopy.d.ts +127 -2
  35. package/dist/shared/assistant/avatar/useAvatarCopy.js +116 -7
  36. package/dist/shared/assistant/conversation.d.ts +20 -20
  37. package/dist/shared/assistant/displayContent.d.ts +4 -4
  38. package/dist/shared/assistant/documentText.d.ts +3 -3
  39. package/dist/shared/assistant/exportConversation.d.ts +1 -1
  40. package/dist/shared/assistant/history/historyControls.d.ts +4 -4
  41. package/dist/shared/assistant/history/historyErrors.d.ts +3 -3
  42. package/dist/shared/assistant/history/historyList.d.ts +5 -5
  43. package/dist/shared/assistant/history/historyMerge.d.ts +4 -4
  44. package/dist/shared/assistant/history/historyOperations.d.ts +1 -1
  45. package/dist/shared/assistant/history/historySearch.d.ts +5 -5
  46. package/dist/shared/assistant/history/historyStatus.d.ts +1 -1
  47. package/dist/shared/assistant/history/historyTypes.d.ts +12 -12
  48. package/dist/shared/assistant/history/profileBoundStorage.d.ts +2 -2
  49. package/dist/shared/assistant/i18n.d.ts +1 -1
  50. package/dist/shared/assistant/i18nManifest.d.ts +566 -535
  51. package/dist/shared/assistant/i18nManifest.js +55 -24
  52. package/dist/shared/assistant/index.d.ts +2 -0
  53. package/dist/shared/assistant/liveDeltas.d.ts +1 -1
  54. package/dist/shared/assistant/liveOverlay.d.ts +1 -1
  55. package/dist/shared/assistant/localUiCommandCopy.d.ts +1 -1
  56. package/dist/shared/assistant/localUiCommands.d.ts +22 -22
  57. package/dist/shared/assistant/localeCommands/engine.d.ts +5 -5
  58. package/dist/shared/assistant/localeCommands/evaluate.d.ts +8 -8
  59. package/dist/shared/assistant/localeCommands/fold.d.ts +2 -2
  60. package/dist/shared/assistant/localeCommands/frames.d.ts +3 -3
  61. package/dist/shared/assistant/localeCommands/gate.d.ts +3 -3
  62. package/dist/shared/assistant/localeCommands/languageNames.d.ts +1 -1
  63. package/dist/shared/assistant/localeCommands/normalise.d.ts +1 -1
  64. package/dist/shared/assistant/localeCommands/types.d.ts +4 -4
  65. package/dist/shared/assistant/modeCapabilities.d.ts +1 -1
  66. package/dist/shared/assistant/modeCopy.d.ts +2 -2
  67. package/dist/shared/assistant/permissionError.d.ts +2 -2
  68. package/dist/shared/assistant/preview/surfaceState.d.ts +1 -1
  69. package/dist/shared/assistant/preview/types.d.ts +5 -5
  70. package/dist/shared/assistant/preview/writeActionResults.d.ts +1 -1
  71. package/dist/shared/assistant/prewarm.d.ts +5 -5
  72. package/dist/shared/assistant/quota.d.ts +2 -2
  73. package/dist/shared/assistant/sandboxReadiness.d.ts +2 -2
  74. package/dist/shared/assistant/speech/speechFeed.d.ts +3 -3
  75. package/dist/shared/assistant/turnOutcome.d.ts +2 -2
  76. package/dist/shared/assistant/turnProgress.d.ts +1 -1
  77. package/dist/shared/assistant/turnState.d.ts +1 -1
  78. package/dist/shared/assistant/turnStream.d.ts +3 -3
  79. package/dist/shared/assistant/turnTimeline.d.ts +13 -13
  80. package/dist/shared/assistant/turnTimingReport.d.ts +1 -1
  81. package/dist/shared/assistant/turnTimingReporter.d.ts +3 -3
  82. package/dist/shared/assistant/ui/AssistantAvatarTabs.d.ts +1 -1
  83. package/dist/shared/assistant/ui/AssistantChatArea.js +17 -17
  84. package/dist/shared/assistant/ui/AssistantHistoryNotices.d.ts +1 -1
  85. package/dist/shared/assistant/ui/AssistantMarkdownRenderer.d.ts +5 -2
  86. package/dist/shared/assistant/ui/AssistantToolActivity.d.ts +1 -1
  87. package/dist/shared/assistant/ui/AssistantUiOfferLink.d.ts +2 -2
  88. package/dist/shared/assistant/ui/AssistantWriteConfirmDialog.d.ts +3 -3
  89. package/dist/shared/assistant/ui/assistantLiveAvatarSeam.d.ts +10 -2
  90. package/dist/shared/assistant/ui/avatar/AssistantAvatarTab.js +78 -76
  91. package/dist/shared/assistant/ui/avatar/avatarAskGate.d.ts +2 -0
  92. package/dist/shared/assistant/ui/avatar/avatarAskGate.js +1 -0
  93. package/dist/shared/assistant/ui/composer/AssistantAttachmentButton.d.ts +1 -1
  94. package/dist/shared/assistant/ui/composer/AssistantConnectSourceItem.d.ts +1 -1
  95. package/dist/shared/assistant/ui/leaveConfirmFocus.d.ts +1 -1
  96. package/dist/shared/assistant/ui/leaveConfirmNavigate.d.ts +3 -3
  97. package/dist/shared/assistant/ui/panelOverlays.d.ts +5 -5
  98. package/dist/shared/assistant/ui/useVoiceSession.d.ts +5 -5
  99. package/dist/shared/assistant/ui/useWriteProposalConfirm.d.ts +4 -4
  100. package/dist/shared/assistant/ui/useWriteProposals.d.ts +2 -2
  101. package/dist/shared/assistant/ui/voice/AssistantVoiceSession.d.ts +1 -1
  102. package/dist/shared/assistant/ui/voice/VoiceCaption.d.ts +1 -1
  103. package/dist/shared/assistant/ui/voice/VoiceWaveform.d.ts +1 -1
  104. package/dist/shared/assistant/ui/voice/voiceSessionEscape.d.ts +2 -2
  105. package/dist/shared/assistant/ui/voice/voiceStartGate.d.ts +6 -6
  106. package/dist/shared/assistant/ui/writeProposalPresentation.d.ts +1 -1
  107. package/dist/shared/assistant/uiActions/actOnResolve.d.ts +5 -5
  108. package/dist/shared/assistant/uiActions/assistantHref.d.ts +2 -2
  109. package/dist/shared/assistant/uiActions/backStack.d.ts +1 -1
  110. package/dist/shared/assistant/uiActions/deixis.d.ts +3 -3
  111. package/dist/shared/assistant/uiActions/entityRoutes.d.ts +1 -1
  112. package/dist/shared/assistant/uiActions/navigationOutcome.d.ts +8 -8
  113. package/dist/shared/assistant/uiActions/offerYesOnSurface.d.ts +1 -1
  114. package/dist/shared/assistant/uiActions/resolveTarget.d.ts +2 -2
  115. package/dist/shared/assistant/uiActions/uiOffers.d.ts +5 -5
  116. package/dist/shared/assistant/usageReporting.d.ts +2 -2
  117. package/dist/shared/assistant/useWorkspaceWriteAccess.d.ts +1 -1
  118. package/dist/shared/assistant/voice/affirmations.d.ts +1 -1
  119. package/dist/shared/assistant/voice/handsFree.d.ts +3 -3
  120. package/dist/shared/assistant/voice/handsfree/bargeIn.d.ts +5 -5
  121. package/dist/shared/assistant/voice/handsfree/echoGate.d.ts +6 -6
  122. package/dist/shared/assistant/voice/handsfree/handsFreeController.d.ts +7 -7
  123. package/dist/shared/assistant/voice/handsfree/handsFreeSetting.d.ts +2 -2
  124. package/dist/shared/assistant/voice/handsfree/micCapture.d.ts +1 -1
  125. package/dist/shared/assistant/voice/handsfree/playbackReference.d.ts +1 -1
  126. package/dist/shared/assistant/voice/handsfree/sttTransport.d.ts +3 -3
  127. package/dist/shared/assistant/voice/handsfree/useHandsFreeInterrupt.d.ts +4 -4
  128. package/dist/shared/assistant/voice/handsfree/vad.d.ts +1 -1
  129. package/dist/shared/assistant/voice/speechPlayback.d.ts +7 -7
  130. package/dist/shared/assistant/voice/useVoiceInput.d.ts +1 -1
  131. package/dist/shared/assistant/voice/voiceReopen.d.ts +8 -8
  132. package/dist/shared/assistant/writeConfirmSeam.d.ts +1 -1
  133. package/dist/shared/assistant/writeModeConsent.d.ts +7 -7
  134. package/dist/shared/assistant/writeProposalDiscovery.d.ts +3 -3
  135. package/dist/shared/assistant/writeProposalErrorCopy.d.ts +1 -1
  136. package/dist/shared/assistant/writeProposals.d.ts +23 -23
  137. package/dist/shared/assistant/writeReplyBinder.d.ts +11 -11
  138. package/dist/shared/assistant/writeReplySend.d.ts +7 -7
  139. package/dist/shared/components/LandingOrDashboardRedirect.d.ts +18 -3
  140. package/dist/shared/components/LandingOrDashboardRedirect.js +58 -28
  141. package/dist/shared/components/index.d.ts +2 -1
  142. package/dist/shared/events/index.d.ts +2 -1
  143. package/dist/shared/hooks/shell/globalSearchError.d.ts +2 -2
  144. package/dist/shared/navigation/productSwitchHandoff.d.ts +45 -0
  145. package/dist/shared/navigation/productSwitchHandoff.js +27 -0
  146. package/dist/shared/navigation/unsavedChanges.d.ts +1 -1
  147. package/dist/shared/utils/index.d.ts +3 -3
  148. package/dist/shared-assistant.js +227 -225
  149. package/dist/shared-components.js +7 -6
  150. package/dist/shared.js +71 -70
  151. package/package.json +3 -2
@@ -23,16 +23,34 @@ var o = [
23
23
  "person",
24
24
  "workspace",
25
25
  "everyone"
26
- ], c = class extends Error {
26
+ ], c = 2, l = [
27
+ "AVAILABLE",
28
+ "IN_USE",
29
+ "EXHAUSTED",
30
+ "UNAVAILABLE"
31
+ ], u = [
32
+ "FREE_CEILING",
33
+ "ZERO_SESSION_LIMIT",
34
+ "NOT_INCLUDED",
35
+ "OWN_SESSION"
36
+ ], d = {
37
+ IN_USE: ["OWN_SESSION"],
38
+ EXHAUSTED: ["FREE_CEILING", "NOT_INCLUDED"]
39
+ }, f = [
40
+ "FREE_CEILING",
41
+ "ZERO_SESSION_LIMIT",
42
+ "NOT_INCLUDED"
43
+ ], p = class extends Error {
27
44
  status;
28
45
  code;
29
46
  retryAfterSeconds;
30
47
  scope;
31
- constructor(e, t, n, r = null) {
32
- super(`avatar api ${e} ${t}`), this.status = e, this.code = t, this.retryAfterSeconds = n, this.scope = r, this.name = "AvatarApiError";
48
+ minutesReason;
49
+ constructor(e, t, n, r = null, i = null) {
50
+ super(`avatar api ${e} ${t}`), this.status = e, this.code = t, this.retryAfterSeconds = n, this.scope = r, this.minutesReason = i, this.name = "AvatarApiError";
33
51
  }
34
52
  };
35
- function l(e = globalThis.crypto) {
53
+ function m(e = globalThis.crypto) {
36
54
  if (e && typeof e.randomUUID == "function") return e.randomUUID();
37
55
  let t = new Uint8Array(16);
38
56
  if (e && typeof e.getRandomValues == "function") e.getRandomValues(t);
@@ -41,43 +59,96 @@ function l(e = globalThis.crypto) {
41
59
  let n = [...t].map((e) => e.toString(16).padStart(2, "0")).join("");
42
60
  return `${n.slice(0, 8)}-${n.slice(8, 12)}-${n.slice(12, 16)}-${n.slice(16, 20)}-${n.slice(20)}`;
43
61
  }
44
- function u(e) {
62
+ function h(e) {
45
63
  return typeof e == "object" && !!e && !Array.isArray(e);
46
64
  }
47
- function d(e, t) {
65
+ function g(e, t) {
48
66
  let n = e.headers.get("retry-after"), r = n === null || n.trim() === "" ? NaN : Number(n);
49
67
  if (Number.isFinite(r) && r >= 0) return r;
50
- let i = u(t) && u(t.error) ? Number(t.error.retryAfterSeconds) : NaN;
68
+ let i = h(t) && h(t.error) ? Number(t.error.retryAfterSeconds) : NaN;
51
69
  return Number.isFinite(i) && i >= 0 ? i : null;
52
70
  }
53
- async function f(e) {
71
+ async function _(e) {
54
72
  try {
55
73
  return await e.json();
56
74
  } catch {
57
75
  return null;
58
76
  }
59
77
  }
60
- function p(e, t) {
61
- if (e !== "budget_exhausted" || !u(t) || !u(t.error)) return null;
78
+ function v(e, t) {
79
+ if (e !== "budget_exhausted" || !h(t) || !h(t.error)) return null;
62
80
  let { scope: n } = t.error;
63
81
  return s.find((e) => e === n) ?? null;
64
82
  }
65
- async function m(e) {
66
- let t = await f(e), n = u(t) && u(t.error) && typeof t.error.code == "string" ? t.error.code : "http_error";
67
- return new c(e.status, n, d(e, t), p(n, t));
83
+ async function y(e) {
84
+ let t = await _(e), n = h(t) && h(t.error) && typeof t.error.code == "string" ? t.error.code : "http_error", r = n === "minutes_exhausted" && h(t) && h(t.error) ? b(t.error.reason, f) : null;
85
+ return new p(e.status, n, g(e, t), v(n, t), r);
68
86
  }
69
- function h(e) {
70
- if (!u(e) || typeof e.available != "boolean") throw new c(200, "invalid_response", null);
71
- let t = Array.isArray(e.avatars) ? e.avatars.flatMap((e) => u(e) && typeof e.id == "string" && r.test(e.id) ? [e.id] : []) : [], n = o.find((t) => t === e.reason) ?? null, i = typeof e.consentVersion == "string" ? e.consentVersion : "", a = typeof e.maxSessionSeconds == "number" && Number.isFinite(e.maxSessionSeconds) ? e.maxSessionSeconds : 0, s = e.available && t.length > 0 && i !== "" && a > 0;
87
+ function b(e, t) {
88
+ return t.find((t) => t === e) ?? null;
89
+ }
90
+ function x(e) {
91
+ return typeof e == "number" && Number.isSafeInteger(e) && e >= 0 ? e : null;
92
+ }
93
+ function S(e) {
94
+ return e === null ? null : x(e) ?? void 0;
95
+ }
96
+ function C(e) {
97
+ if (typeof e != "string" || !/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(e)) return null;
98
+ let t = Date.parse(e);
99
+ return Number.isFinite(t) && new Date(t).toISOString() === e ? t : null;
100
+ }
101
+ function w(e) {
102
+ let t = x(e.availableMinutes), n = x(e.heldMinutes), r = x(e.freeMinutesPerMonth), i = x(e.freeRemaining), a = x(e.planMinutesPerMonth), o = x(e.planRemaining), s = x(e.carriedRemaining), c = S(e.personFreeCeiling), l = S(e.personFreeRemaining), u = C(e.resetsAt), { morePlanCreditsAvailable: d } = e;
103
+ return t === null || n === null || r === null || i === null || a === null || o === null || s === null || c === void 0 || l === void 0 || u === null || typeof d != "boolean" ? null : {
104
+ availableMinutes: t,
105
+ heldMinutes: n,
106
+ freeMinutesPerMonth: r,
107
+ freeRemaining: i,
108
+ planMinutesPerMonth: a,
109
+ planRemaining: o,
110
+ carriedRemaining: s,
111
+ personFreeCeiling: c,
112
+ personFreeRemaining: l,
113
+ resetsAt: u,
114
+ morePlanCreditsAvailable: d
115
+ };
116
+ }
117
+ function T(e) {
118
+ if (!h(e) || e.version !== 2) return null;
119
+ let t = l.find((t) => t === e.state);
120
+ if (t === void 0) return null;
121
+ let n = null;
122
+ if (t !== "UNAVAILABLE" && (n = w(e), n === null || (t === "AVAILABLE" ? n.availableMinutes < 1 : n.availableMinutes !== 0))) return null;
123
+ let r = e.staleSeconds;
124
+ return {
125
+ state: t,
126
+ reason: b(e.reason, d[t] ?? []),
127
+ balance: n,
128
+ staleSeconds: typeof r == "number" && Number.isSafeInteger(r) && r >= 20 && r <= 120 ? r : null
129
+ };
130
+ }
131
+ function E(e) {
132
+ if (!h(e)) return null;
133
+ let t = x(e.reserved);
134
+ return t === null || t < 1 || typeof e.limitedByBalance != "boolean" ? null : {
135
+ reserved: t,
136
+ limitedByBalance: e.limitedByBalance
137
+ };
138
+ }
139
+ function D(e) {
140
+ if (!h(e) || typeof e.available != "boolean") throw new p(200, "invalid_response", null);
141
+ let t = Array.isArray(e.avatars) ? e.avatars.flatMap((e) => h(e) && typeof e.id == "string" && r.test(e.id) ? [e.id] : []) : [], n = o.find((t) => t === e.reason) ?? null, i = typeof e.consentVersion == "string" ? e.consentVersion : "", a = typeof e.maxSessionSeconds == "number" && Number.isFinite(e.maxSessionSeconds) ? e.maxSessionSeconds : 0, s = e.available && t.length > 0 && i !== "" && a > 0, c = T(e.minutes);
72
142
  return {
73
143
  available: s,
74
144
  reason: s ? null : n ?? "not_enabled",
75
145
  avatars: t,
76
146
  consentVersion: i,
77
- maxSessionSeconds: a
147
+ maxSessionSeconds: a,
148
+ ...c === null ? {} : { minutes: c }
78
149
  };
79
150
  }
80
- function g(e) {
151
+ function O(e) {
81
152
  try {
82
153
  let n = new URL(e);
83
154
  return n.protocol === "wss:" ? !0 : n.protocol === "ws:" && t.has(n.hostname.toLowerCase());
@@ -85,20 +156,23 @@ function g(e) {
85
156
  return !1;
86
157
  }
87
158
  }
88
- function _(e) {
89
- if (!u(e)) throw new c(201, "invalid_response", null);
90
- let { sessionId: t, livekitUrl: r, participantToken: i, avatarIdentity: a, connectBy: o, endsAt: s } = e, l = typeof o == "string" ? Date.parse(o) : NaN, d = typeof s == "string" ? Date.parse(s) : NaN;
91
- if (typeof t != "string" || !n.test(t) || typeof r != "string" || !g(r) || typeof i != "string" || i === "" || typeof a != "string" || a === "" || !Number.isFinite(l) || !Number.isFinite(d)) throw new c(201, "invalid_response", null);
159
+ function k(e) {
160
+ if (!h(e)) throw new p(201, "invalid_response", null);
161
+ let { sessionId: t, livekitUrl: r, participantToken: i, avatarIdentity: a, connectBy: o, endsAt: s } = e, c = typeof o == "string" ? Date.parse(o) : NaN, l = typeof s == "string" ? Date.parse(s) : NaN;
162
+ if (typeof t != "string" || !n.test(t) || typeof r != "string" || !O(r) || typeof i != "string" || i === "" || typeof a != "string" || a === "" || !Number.isFinite(c) || !Number.isFinite(l)) throw new p(201, "invalid_response", null);
163
+ let { maxSessionSeconds: u } = e, d = typeof u == "number" && Number.isSafeInteger(u) && u > 0 ? u : null, f = E(e.minutes);
92
164
  return {
93
165
  sessionId: t,
94
166
  livekitUrl: r,
95
167
  participantToken: i,
96
168
  avatarIdentity: a,
97
- connectBy: l,
98
- endsAt: d
169
+ connectBy: c,
170
+ endsAt: l,
171
+ ...d === null ? {} : { maxSessionSeconds: d },
172
+ ...f === null ? {} : { minutes: f }
99
173
  };
100
174
  }
101
- var v = [
175
+ var A = [
102
176
  "starting",
103
177
  "ready",
104
178
  "ending",
@@ -106,22 +180,22 @@ var v = [
106
180
  "failed",
107
181
  "canceled"
108
182
  ];
109
- function y(e, t) {
110
- if (!u(e) || !v.includes(e.state)) throw new c(200, "invalid_response", null);
183
+ function j(e, t) {
184
+ if (!h(e) || !A.includes(e.state)) throw new p(200, "invalid_response", null);
111
185
  return {
112
186
  sessionId: t,
113
187
  state: e.state,
114
188
  endedReason: typeof e.endedReason == "string" ? e.endedReason : null
115
189
  };
116
190
  }
117
- var b = (e) => new Promise((t) => {
191
+ var M = (e) => new Promise((t) => {
118
192
  setTimeout(t, e);
119
193
  });
120
- function x(e) {
121
- let t = e.fetchImpl ?? ((e, t) => fetch(e, t)), a = e.sleep ?? b, o = e.now ?? (() => Date.now()), s = e.startInProgressBudgetMs ?? 15e3, l = e.baseUrl.replace(/\/+$/, "");
122
- async function u(t, n = null) {
194
+ function N(e) {
195
+ let t = e.fetchImpl ?? ((e, t) => fetch(e, t)), a = e.sleep ?? M, o = e.now ?? (() => Date.now()), s = e.startInProgressBudgetMs ?? 15e3, c = e.baseUrl.replace(/\/+$/, "");
196
+ async function l(t, n = null) {
123
197
  let r = e.getAuthorization();
124
- if (!r) throw new c(401, "unauthenticated", null);
198
+ if (!r) throw new p(401, "unauthenticated", null);
125
199
  let i = { authorization: r };
126
200
  if (t) {
127
201
  let t = await e.getWorkspaceAuthorization(n === null ? { fresh: !1 } : {
@@ -133,7 +207,7 @@ function x(e) {
133
207
  }
134
208
  return i;
135
209
  }
136
- async function d(e, n) {
210
+ async function u(e, n) {
137
211
  try {
138
212
  return await t(e, {
139
213
  ...n,
@@ -142,20 +216,20 @@ function x(e) {
142
216
  redirect: "error"
143
217
  });
144
218
  } catch (e) {
145
- throw n.signal?.aborted ? e : new c(0, "network", null);
219
+ throw n.signal?.aborted ? e : new p(0, "network", null);
146
220
  }
147
221
  }
148
222
  return {
149
223
  async availability(e) {
150
224
  let t = null;
151
225
  for (;;) {
152
- let n = await u(!0, t), r = await d(`${l}/availability`, {
226
+ let n = await l(!0, t), r = await u(`${c}/availability`, {
153
227
  method: "GET",
154
228
  headers: n,
155
229
  signal: e
156
230
  });
157
- if (r.ok) return h(await f(r));
158
- let i = await m(r);
231
+ if (r.ok) return D(await _(r));
232
+ let i = await y(r);
159
233
  if (r.status === 401 && t === null) {
160
234
  t = {
161
235
  error: i,
@@ -167,16 +241,16 @@ function x(e) {
167
241
  }
168
242
  },
169
243
  async create(e, t) {
170
- if (!r.test(e.avatarId) || !i.test(e.idempotencyKey)) throw new c(400, "invalid_request", null);
244
+ if (!r.test(e.avatarId) || !i.test(e.idempotencyKey)) throw new p(400, "invalid_request", null);
171
245
  let n = JSON.stringify({
172
246
  avatarId: e.avatarId,
173
247
  consentVersion: e.consentVersion
174
- }), p = o(), h = null, g = !1, v = !1, y = null;
248
+ }), d = o(), f = null, m = !1, h = !1, g = null;
175
249
  for (;;) {
176
- let r = await u(!0, h);
177
- if (h = null, y !== null && o() - p > s) throw y;
178
- if (r["x-workspace-authorization"] === void 0) throw new c(403, "workspace_context_required", null);
179
- let i = await d(`${l}/sessions`, {
250
+ let r = await l(!0, f);
251
+ if (f = null, g !== null && o() - d > s) throw g;
252
+ if (r["x-workspace-authorization"] === void 0) throw new p(403, "workspace_context_required", null);
253
+ let i = await u(`${c}/sessions`, {
180
254
  method: "POST",
181
255
  headers: {
182
256
  ...r,
@@ -186,41 +260,41 @@ function x(e) {
186
260
  body: n,
187
261
  signal: t
188
262
  });
189
- if (i.status === 201) return _(await f(i));
190
- let b = await m(i);
191
- if (i.status === 401 && !g) {
192
- g = !0, h = {
193
- error: b,
263
+ if (i.status === 201) return k(await _(i));
264
+ let v = await y(i);
265
+ if (i.status === 401 && !m) {
266
+ m = !0, f = {
267
+ error: v,
194
268
  workspace: r["x-workspace-authorization"]
195
269
  };
196
270
  continue;
197
271
  }
198
- if (i.status === 409 && b.code === "start_in_progress") {
199
- let e = Math.max(250, (b.retryAfterSeconds ?? 1) * 1e3);
200
- if (o() - p + e > s || (await a(e), t?.aborted)) throw b;
201
- y = b;
272
+ if (i.status === 409 && v.code === "start_in_progress") {
273
+ let e = Math.max(250, (v.retryAfterSeconds ?? 1) * 1e3);
274
+ if (o() - d + e > s || (await a(e), t?.aborted)) throw v;
275
+ g = v;
202
276
  continue;
203
277
  }
204
- if (i.status === 502 && !v) {
205
- v = !0;
278
+ if (i.status === 502 && !h) {
279
+ h = !0;
206
280
  continue;
207
281
  }
208
- throw b;
282
+ throw v;
209
283
  }
210
284
  },
211
285
  async status(e, t) {
212
- if (!n.test(e)) throw new c(400, "invalid_request", null);
213
- let r = await u(!1), i = await d(`${l}/sessions/${e}`, {
286
+ if (!n.test(e)) throw new p(400, "invalid_request", null);
287
+ let r = await l(!1), i = await u(`${c}/sessions/${e}`, {
214
288
  method: "GET",
215
289
  headers: r,
216
290
  signal: t
217
291
  });
218
- if (!i.ok) throw await m(i);
219
- return y(await f(i), e);
292
+ if (!i.ok) throw await y(i);
293
+ return j(await _(i), e);
220
294
  },
221
295
  async end(e, { reason: t, keepalive: r = !1 }) {
222
- if (!n.test(e)) throw new c(400, "invalid_request", null);
223
- let i = await u(!1), a = await d(`${l}/sessions/${e}/end`, {
296
+ if (!n.test(e)) throw new p(400, "invalid_request", null);
297
+ let i = await l(!1), a = await u(`${c}/sessions/${e}/end`, {
224
298
  method: "POST",
225
299
  headers: {
226
300
  ...i,
@@ -229,28 +303,34 @@ function x(e) {
229
303
  body: JSON.stringify({ reason: t }),
230
304
  keepalive: r
231
305
  });
232
- if (!a.ok) throw await m(a);
233
- return y(await f(a), e);
306
+ if (!a.ok) throw await y(a);
307
+ return j(await _(a), e);
234
308
  }
235
309
  };
236
310
  }
237
- var S = new Set([
311
+ var P = new Set([
238
312
  "capacity",
239
313
  "rate-limited",
240
- "budget-exhausted"
314
+ "budget-exhausted",
315
+ "minutes-in-use",
316
+ "minutes-in-use-self",
317
+ "minutes-unavailable"
241
318
  ]);
242
- function C(e) {
243
- if (!(e instanceof c)) return {
319
+ function F(e) {
320
+ return e.problem === null ? !1 : P.has(e.problem) ? !0 : e.problem === "minutes-exhausted" && e.minutesReason === "ZERO_SESSION_LIMIT";
321
+ }
322
+ function I(e) {
323
+ if (!(e instanceof p)) return {
244
324
  problem: "connection",
245
325
  hide: !1
246
326
  };
247
- let t = w(e);
248
- return t.problem !== null && S.has(t.problem) && e.retryAfterSeconds !== null ? {
327
+ let t = L(e);
328
+ return F(t) && e.retryAfterSeconds !== null ? {
249
329
  ...t,
250
330
  retryAfterSeconds: e.retryAfterSeconds
251
331
  } : t;
252
332
  }
253
- function w(e) {
333
+ function L(e) {
254
334
  if (e.status === 0) return {
255
335
  problem: "connection",
256
336
  hide: !1
@@ -312,6 +392,26 @@ function w(e) {
312
392
  hide: !1,
313
393
  scope: e.scope
314
394
  };
395
+ case "minutes_exhausted": return e.minutesReason === null ? {
396
+ problem: "minutes-exhausted",
397
+ hide: !1
398
+ } : {
399
+ problem: "minutes-exhausted",
400
+ hide: !1,
401
+ minutesReason: e.minutesReason
402
+ };
403
+ case "minutes_in_use": return {
404
+ problem: "minutes-in-use",
405
+ hide: !1
406
+ };
407
+ case "minutes_in_use_self": return {
408
+ problem: "minutes-in-use-self",
409
+ hide: !1
410
+ };
411
+ case "minutes_unavailable": return {
412
+ problem: "minutes-unavailable",
413
+ hide: !1
414
+ };
315
415
  case "avatar_unavailable": return {
316
416
  problem: "unavailable",
317
417
  hide: !1
@@ -345,7 +445,7 @@ function w(e) {
345
445
  };
346
446
  }
347
447
  }
348
- function T(e) {
448
+ function R(e) {
349
449
  return e === "unavailable" ? {
350
450
  problem: "capacity",
351
451
  hide: !1
@@ -354,5 +454,26 @@ function T(e) {
354
454
  hide: !0
355
455
  };
356
456
  }
457
+ function z(e) {
458
+ if (e == null) return null;
459
+ switch (e.state) {
460
+ case "EXHAUSTED": return e.reason === null ? {
461
+ problem: "minutes-exhausted",
462
+ hide: !1
463
+ } : {
464
+ problem: "minutes-exhausted",
465
+ hide: !1,
466
+ minutesReason: e.reason
467
+ };
468
+ case "IN_USE": return e.reason === "OWN_SESSION" ? {
469
+ problem: "minutes-in-use-self",
470
+ hide: !1
471
+ } : {
472
+ problem: "minutes-in-use",
473
+ hide: !1
474
+ };
475
+ default: return null;
476
+ }
477
+ }
357
478
  //#endregion
358
- export { e as AVATAR_API_PATH, c as AvatarApiError, a as avatarApiBaseFromTtsEndpoint, T as avatarAvailabilityRefusal, l as avatarIdempotencyKey, C as avatarRefusalFor, x as createAvatarSessionClient };
479
+ export { e as AVATAR_API_PATH, c as AVATAR_MINUTES_CONTRACT_VERSION, u as AVATAR_MINUTES_REASONS, l as AVATAR_MINUTES_STATES, p as AvatarApiError, a as avatarApiBaseFromTtsEndpoint, R as avatarAvailabilityRefusal, m as avatarIdempotencyKey, z as avatarMinutesRefusal, I as avatarRefusalFor, N as createAvatarSessionClient };
@@ -7,6 +7,7 @@ import { AvatarRoom, AvatarScheduler } from './avatarPorts';
7
7
  import { AvatarSessionClient } from './avatarSessionClient';
8
8
  import { LiveAvatarVoiceStore } from './LiveAvatarTabView';
9
9
  import { LiveAvatarController, LiveAvatarControllerDeps, LiveAvatarLogEvent, LiveAvatarPreferences } from './liveAvatarController';
10
+ import { LiveAvatarMinutesPurchase } from './liveAvatarMinutesView';
10
11
  export interface LiveAvatarSeamOptions {
11
12
  /** Display names for the avatar ids the server offers (it sends ids only); without one the chooser numbers them. */
12
13
  readonly avatarNames?: Readonly<Record<string, string>>;
@@ -33,6 +34,18 @@ export interface LiveAvatarSeamOptions {
33
34
  * person's stored choice always wins.
34
35
  */
35
36
  readonly defaultAvatarVoiceMode?: AvatarVoiceDefault;
37
+ /**
38
+ * ★ BOFF-9446: whether this person may buy a plan (`access`, the host's purchase check, which follows `billing:create` on the
39
+ * organization's billing account): fe-libs cannot import billing. The Avatar tab asks it only where "See plans" could be offered (none
40
+ * left, or running low, while the server says a plan with more credits exists), and opens the app's plans page with the panel's own
41
+ * navigator (`onNavigate`), never by itself. Absent: nobody is offered "See plans" in the tab, and a person who has run out is told to
42
+ * ask their billing administrator about a plan with more avatar credits. Only `canPurchase` is read. Copied once, here: a host that
43
+ * changes its object later changes nothing.
44
+ *
45
+ * The host knows its own routes, so it says when the person comes back: from any billing page, `controller.refreshMinutes()`; from a
46
+ * plan checkout, `controller.checkMinutesPurchase()` (the tab then says "Checking your plan…" while it checks).
47
+ */
48
+ readonly minutesPurchase?: LiveAvatarMinutesPurchase;
36
49
  readonly onLog?: (event: LiveAvatarLogEvent) => void;
37
50
  /** Overrides, for tests and for hosts with their own plumbing. Each defaults to the assistant's own. */
38
51
  readonly client?: () => AvatarSessionClient | null;
@@ -45,7 +58,7 @@ export interface LiveAvatarSeamOptions {
45
58
  readonly avatarVoiceStore?: LiveAvatarVoiceStore;
46
59
  readonly scheduler?: AvatarScheduler;
47
60
  readonly browserSupported?: () => boolean;
48
- readonly controller?: Partial<Pick<LiveAvatarControllerDeps, 'createAudioElement' | 'releaseAudioElement' | 'startMeter' | 'decode' | 'now' | 'newIdempotencyKey' | 'subscribeWorkspaceChange' | 'subscribePageHide' | 'subscribePageShow' | 'idleMs' | 'endBeforeDeadlineMs' | 'connectTimeoutMs' | 'trackerConfig' | 'maxDrainMs' | 'stallMs' | 'readinessProbe'>>;
61
+ readonly controller?: Partial<Pick<LiveAvatarControllerDeps, 'createAudioElement' | 'releaseAudioElement' | 'startMeter' | 'decode' | 'now' | 'newIdempotencyKey' | 'subscribeWorkspaceChange' | 'subscribePageHide' | 'isPageVisible' | 'subscribePageVisible' | 'subscribePageShow' | 'idleMs' | 'endBeforeDeadlineMs' | 'connectTimeoutMs' | 'trackerConfig' | 'maxDrainMs' | 'stallMs' | 'readinessProbe'>>;
49
62
  }
50
63
  /** The seam, plus what a host or a test may need of it. */
51
64
  export interface LiveAvatarSeamHandle extends AssistantLiveAvatarSeam {
@@ -90,15 +90,37 @@ function A(e, t) {
90
90
  cancel: () => e.cancel()
91
91
  };
92
92
  }
93
- function j() {
93
+ function j(e) {
94
+ if (e === void 0) return;
95
+ let { access: t } = e;
96
+ return { access: () => t.call(e) };
97
+ }
98
+ function M() {
94
99
  if (typeof document > "u") return null;
95
100
  let e = document.createElement("audio");
96
101
  return e.autoplay = !0, e.hidden = !0, e.setAttribute("data-testid", "assistant-live-avatar-audio"), document.body.appendChild(e), e;
97
102
  }
98
- function M(e) {
103
+ function N(e) {
99
104
  if (!(typeof window > "u")) return (t) => (window.addEventListener(e, t), () => window.removeEventListener(e, t));
100
105
  }
101
- function N() {
106
+ function P() {
107
+ if (typeof document > "u" || typeof document.addEventListener != "function") return;
108
+ let e = () => document.visibilityState !== "hidden";
109
+ return {
110
+ isVisible: e,
111
+ onShown: (t) => {
112
+ let n = () => {
113
+ e() && t();
114
+ }, r = (n) => {
115
+ "persisted" in n && n.persisted === !0 && e() && t();
116
+ }, i = typeof window < "u" && typeof window.addEventListener == "function" ? window : void 0;
117
+ return document.addEventListener("visibilitychange", n), i?.addEventListener("pageshow", r), () => {
118
+ document.removeEventListener("visibilitychange", n), i?.removeEventListener("pageshow", r);
119
+ };
120
+ }
121
+ };
122
+ }
123
+ function F() {
102
124
  if (!(typeof window > "u" || typeof document > "u")) return (e) => {
103
125
  let t = window, n = document, r = () => {
104
126
  n.visibilityState === "visible" && e();
@@ -108,24 +130,26 @@ function N() {
108
130
  };
109
131
  };
110
132
  }
111
- function P(e = {}) {
112
- let t = e.preferences ?? O, n = e.controller ?? {}, r = n.subscribeWorkspaceChange ?? M("burdenoff:workspace-changed"), i = n.subscribePageHide ?? M("pagehide"), a = n.subscribePageShow ?? N(), o = n.now ?? (() => Date.now()), u = p({
133
+ function I(e = {}) {
134
+ let t = e.preferences ?? O, n = e.controller ?? {}, r = n.subscribeWorkspaceChange ?? N("burdenoff:workspace-changed"), i = n.subscribePageHide ?? N("pagehide"), a = P(), o = n.isPageVisible ?? a?.isVisible, u = n.subscribePageVisible ?? a?.onShown, f = n.subscribePageShow ?? F(), T = n.now ?? (() => Date.now()), E = p({
113
135
  client: e.client ?? D(),
114
136
  openRoom: e.openRoom ?? m,
115
137
  scheduler: e.scheduler ?? s,
116
138
  preferences: t,
117
139
  decode: n.decode ?? ((e, t) => l(e, { signal: t })),
118
- createAudioElement: n.createAudioElement ?? j,
140
+ createAudioElement: n.createAudioElement ?? M,
119
141
  releaseAudioElement: n.releaseAudioElement ?? ((e) => {
120
142
  e.srcObject = null, e.remove();
121
143
  }),
122
144
  startMeter: n.startMeter ?? ((e, t) => typeof MediaStream > "u" ? null : c(new MediaStream([e]), t)),
123
145
  browserSupported: e.browserSupported ?? (() => w()),
124
- now: o,
146
+ now: T,
125
147
  newIdempotencyKey: n.newIdempotencyKey ?? (() => d()),
126
148
  ...r ? { subscribeWorkspaceChange: r } : {},
127
149
  ...i ? { subscribePageHide: i } : {},
128
- ...a ? { subscribePageShow: a } : {},
150
+ ...o ? { isPageVisible: o } : {},
151
+ ...u ? { subscribePageVisible: u } : {},
152
+ ...f ? { subscribePageShow: f } : {},
129
153
  ...n.idleMs === void 0 ? {} : { idleMs: n.idleMs },
130
154
  ...n.endBeforeDeadlineMs === void 0 ? {} : { endBeforeDeadlineMs: n.endBeforeDeadlineMs },
131
155
  ...n.connectTimeoutMs === void 0 ? {} : { connectTimeoutMs: n.connectTimeoutMs },
@@ -134,34 +158,34 @@ function P(e = {}) {
134
158
  ...n.stallMs === void 0 ? {} : { stallMs: n.stallMs },
135
159
  ...n.readinessProbe === void 0 ? {} : { readinessProbe: n.readinessProbe },
136
160
  ...e.onLog ? { onLog: e.onLog } : {}
137
- }), f = b(e.avatarVoices), T = e.avatarImages === void 0 ? null : _(e.avatarImages), E = e.avatarVoiceStore ?? k, P = () => E.getState(), F = (n, r) => {
138
- let i = v(P(), {
139
- avatarVoices: f,
161
+ }), I = b(e.avatarVoices), L = e.avatarImages === void 0 ? null : _(e.avatarImages), R = e.avatarVoiceStore ?? k, z = () => R.getState(), B = j(e.minutesPurchase), V = (n, r) => {
162
+ let i = v(z(), {
163
+ avatarVoices: I,
140
164
  avatarId: t.getState().avatarId,
141
165
  ...e.defaultAvatarVoiceMode ? { hostDefault: e.defaultAvatarVoiceMode } : {}
142
166
  });
143
167
  return i === null ? null : y(i, n, r.listVoices());
144
- }, I = (e, t) => {
168
+ }, H = (e, t) => {
145
169
  let n = {
146
170
  ...e,
147
171
  voice: t
148
172
  };
149
- return n.audioOutput = x(u.createOutput(), () => {
173
+ return n.audioOutput = x(E.createOutput(), () => {
150
174
  n.voice = e.voice;
151
- }, (e) => u.subscribe(() => {
152
- u.getSnapshot().phase !== "ready" && e();
175
+ }, (e) => E.subscribe(() => {
176
+ E.getSnapshot().phase !== "ready" && e();
153
177
  })), n;
154
178
  };
155
179
  return {
156
180
  decorateSpeechEngine: (e) => {
157
181
  let t = (t) => {
158
- let n = F(t.lang, e), r = n === null ? t : {
182
+ let n = V(t.lang, e), r = n === null ? t : {
159
183
  ...t,
160
184
  voice: n
161
185
  };
162
186
  return {
163
187
  voice: n,
164
- target: u.route(r, e)
188
+ target: E.route(r, e)
165
189
  };
166
190
  }, n = null, r = () => {
167
191
  let e = n;
@@ -169,12 +193,12 @@ function P(e = {}) {
169
193
  }, i = (t, r, i) => {
170
194
  let a = !0, o = !1, s = () => void 0, c = () => {
171
195
  a && (a = !1, n === c && (n = null), s());
172
- }, l = () => o ? !1 : (o = !0, c(), !0), d = () => {
196
+ }, l = () => o ? !1 : (o = !0, c(), !0), u = () => {
173
197
  !a || !l() || (e.cancel(), i?.onError?.("output-left"));
174
198
  };
175
- s = u.subscribe(() => {
176
- u.getSnapshot().phase !== "ready" && d();
177
- }), n = c, r.audioOutput &&= A(r.audioOutput, d), r.fallback = !1, e.speak(t, r, {
199
+ s = E.subscribe(() => {
200
+ E.getSnapshot().phase !== "ready" && u();
201
+ }), n = c, r.audioOutput &&= A(r.audioOutput, u), r.fallback = !1, e.speak(t, r, {
178
202
  ...i,
179
203
  onEnd: () => {
180
204
  l() && i?.onEnd?.();
@@ -203,8 +227,8 @@ function P(e = {}) {
203
227
  }
204
228
  let l = s === null ? {
205
229
  ...a,
206
- audioOutput: u.createOutput()
207
- } : I(a, s);
230
+ audioOutput: E.createOutput()
231
+ } : H(a, s);
208
232
  if (a.avatarOnly === !0) {
209
233
  i(n, l, o);
210
234
  return;
@@ -217,7 +241,7 @@ function P(e = {}) {
217
241
  };
218
242
  },
219
243
  Stage: ({ expanded: t, fallback: n }) => /* @__PURE__ */ C(g, {
220
- controller: u,
244
+ controller: E,
221
245
  expanded: t,
222
246
  fallback: n,
223
247
  ...e.avatarNames ? { avatarNames: e.avatarNames } : {}
@@ -225,33 +249,34 @@ function P(e = {}) {
225
249
  enabled: {
226
250
  subscribe: (e) => t.subscribe(e),
227
251
  getSnapshot: () => t.getState().avatarEnabled,
228
- switchOff: () => u.switchOff(),
229
- voiceLive: (e) => u.setVoiceLive(e)
252
+ switchOff: () => E.switchOff(),
253
+ voiceLive: (e) => E.setVoiceLive(e)
230
254
  },
231
255
  tab: {
232
256
  offered: {
233
- subscribe: (e) => u.subscribe(e),
234
- getSnapshot: () => u.getSnapshot().tabOffered
257
+ subscribe: (e) => E.subscribe(e),
258
+ getSnapshot: () => E.getSnapshot().tabOffered
235
259
  },
236
260
  ask: {
237
- subscribe: (e) => u.subscribe(e),
238
- getSnapshot: () => h(u.getSnapshot(), o())
261
+ subscribe: (e) => E.subscribe(e),
262
+ getSnapshot: () => h(E.getSnapshot(), T())
239
263
  },
240
- setOpen: (e) => u.setTabOpen(e),
241
- heldByVoice: () => u.getSnapshot().heldByVoice,
264
+ setOpen: (e) => E.setTabOpen(e),
265
+ heldByVoice: () => E.getSnapshot().heldByVoice,
242
266
  View: (t) => /* @__PURE__ */ C(S, {
243
267
  ...t,
244
- controller: u,
245
- avatarVoices: f,
246
- voiceStore: E,
268
+ controller: E,
269
+ avatarVoices: I,
270
+ voiceStore: R,
247
271
  ...e.avatarNames ? { avatarNames: e.avatarNames } : {},
248
- ...T ? { avatarImages: T } : {},
249
- ...e.defaultAvatarVoiceMode ? { defaultAvatarVoiceMode: e.defaultAvatarVoiceMode } : {}
272
+ ...L ? { avatarImages: L } : {},
273
+ ...e.defaultAvatarVoiceMode ? { defaultAvatarVoiceMode: e.defaultAvatarVoiceMode } : {},
274
+ ...B ? { minutesPurchase: B } : {}
250
275
  })
251
276
  },
252
- controller: u,
253
- dispose: () => u.dispose()
277
+ controller: E,
278
+ dispose: () => E.dispose()
254
279
  };
255
280
  }
256
281
  //#endregion
257
- export { P as createLiveAvatarSeam, w as isLiveAvatarBrowserSupported, T as liveAvatarAuthorization, E as liveAvatarWorkspaceAuthorization };
282
+ export { I as createLiveAvatarSeam, w as isLiveAvatarBrowserSupported, T as liveAvatarAuthorization, E as liveAvatarWorkspaceAuthorization };