@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
@@ -1,9 +1,9 @@
1
1
  import { AvatarNotReadyError as e, LiveKitAvatarTransport as t } from "./avatarTransport.js";
2
2
  import { createAvatarTransportPort as n } from "./avatarTransportPort.js";
3
3
  import { createAvatarReplyOutputs as r } from "./avatarReplyOutputs.js";
4
- import { AvatarApiError as i, avatarAvailabilityRefusal as a, avatarRefusalFor as o } from "./avatarSessionClient.js";
4
+ import { AvatarApiError as i, avatarAvailabilityRefusal as a, avatarMinutesRefusal as o, avatarRefusalFor as s } from "./avatarSessionClient.js";
5
5
  //#region src/shared/assistant/avatar/live/liveAvatarController.ts
6
- var s = 12e4, c = 1e4, l = 8e3, ee = 5e3, u = 2e4, te = 1e3, d = {
6
+ var c = 12e4, l = 1e4, u = 8e3, ee = 5e3, d = 2e4, f = 15e3, te = 2, ne = 5, p = 6e3, m = 1e3, re = {
7
7
  voiceLive: !1,
8
8
  offered: !1,
9
9
  tabOpen: !1,
@@ -19,9 +19,14 @@ var s = 12e4, c = 1e4, l = 8e3, ee = 5e3, u = 2e4, te = 1e3, d = {
19
19
  budgetScope: null,
20
20
  notice: null,
21
21
  audioBlocked: !1,
22
- videoReady: !1
22
+ videoReady: !1,
23
+ minutes: null,
24
+ minutesReason: null,
25
+ sessionMinutes: null,
26
+ sessionEndsAt: null,
27
+ purchase: "idle"
23
28
  };
24
- function f(e) {
29
+ function ie(e) {
25
30
  switch (e) {
26
31
  case "permission_revoked": return {
27
32
  problem: "unavailable",
@@ -57,88 +62,97 @@ function f(e) {
57
62
  };
58
63
  }
59
64
  }
60
- var p = new Set(["playback-blocked", "needs-hosted-voice"]), m = {
65
+ var ae = new Set(["playback-blocked", "needs-hosted-voice"]), oe = {
61
66
  problem: "unavailable",
62
67
  hide: !0
63
- };
64
- function h(s) {
65
- let { scheduler: c, preferences: l } = s, u = s.idleMs ?? 12e4, te = s.endBeforeDeadlineMs ?? 1e4, h = s.connectTimeoutMs ?? 2e4, g = s.requestTimeoutMs ?? 8e3, _ = {
66
- ...d,
67
- tabOffered: s.browserSupported()
68
- }, v = /* @__PURE__ */ new Set(), y = !1, b = null, x = 0, S = !1, C = !1, w = 0, T = null, E = null, D = [], O = 0, k = !1, A = "user", j = !1, M = !1, N = null, P = null, F = null, I = null, L = !1;
69
- function R(e) {
68
+ }, se = new Set([
69
+ "minutes-exhausted",
70
+ "minutes-in-use",
71
+ "minutes-in-use-self",
72
+ "minutes-unavailable"
73
+ ]), ce = new Set([
74
+ "minutes-exhausted",
75
+ "minutes-in-use",
76
+ "minutes-in-use-self"
77
+ ]);
78
+ function h(c) {
79
+ let { scheduler: l, preferences: u } = c, d = c.idleMs ?? 12e4, te = c.endBeforeDeadlineMs ?? 1e4, ne = c.connectTimeoutMs ?? 2e4, m = c.requestTimeoutMs ?? 8e3, h = {
80
+ ...re,
81
+ tabOffered: c.browserSupported()
82
+ }, g = /* @__PURE__ */ new Set(), _ = !1, le = null, ue = 0, v = !1, y = !1, b = 0, x = null, S = null, C = [], de = 0, fe = !1, pe = "user", w = !1, T = !1, E = null, D = null, O = null, k = null, A = !1, me = 0, j = 0, M = null, N = !1, P = !1, F = null, I = null, L = 0, R = 0, he = !1, z = 0, B = null, V = !1;
83
+ function H(e) {
70
84
  try {
71
- s.onLog?.(e);
85
+ c.onLog?.(e);
72
86
  } catch {}
73
87
  }
74
- function z() {
75
- return !y && s.browserSupported();
88
+ function ge() {
89
+ return !_ && c.browserSupported();
76
90
  }
77
- function ne(e, t) {
78
- return (e || t) && z();
91
+ function _e(e, t) {
92
+ return (e || t) && ge();
79
93
  }
80
- function B() {
81
- return _.retryAt !== null && s.now() < _.retryAt;
94
+ function U() {
95
+ return h.retryAt !== null && c.now() < h.retryAt;
82
96
  }
83
- function V(e) {
97
+ function W(e) {
84
98
  let t = {
85
- ..._,
99
+ ...h,
86
100
  ...e
87
101
  };
88
- e.problem !== void 0 && e.problem !== _.problem && (e.retryAt === void 0 && (t.retryAt = null), e.budgetScope === void 0 && (t.budgetScope = null));
102
+ e.problem !== void 0 && e.problem !== h.problem && (e.retryAt === void 0 && (t.retryAt = null), e.budgetScope === void 0 && (t.budgetScope = null), e.minutesReason === void 0 && (t.minutesReason = null));
89
103
  let n = {
90
104
  ...t,
91
- offered: ne(t.voiceLive, t.tabOpen),
92
- tabOffered: z(),
93
- heldByVoice: M && t.voiceLive
105
+ offered: _e(t.voiceLive, t.tabOpen),
106
+ tabOffered: ge(),
107
+ heldByVoice: T && t.voiceLive
94
108
  };
95
- if (!Object.keys(n).every((e) => n[e] === _[e])) {
96
- n.retryAt !== _.retryAt && (I?.(), I = null), _ = n;
97
- for (let e of [...v]) try {
109
+ if (!Object.keys(n).every((e) => n[e] === h[e])) {
110
+ n.retryAt !== h.retryAt && (k?.(), k = null), h = n;
111
+ for (let e of [...g]) try {
98
112
  e();
99
113
  } catch {}
100
114
  }
101
115
  }
102
- function H() {
103
- return k && !j ? "voice_end" : "user";
116
+ function ve() {
117
+ return fe && !w ? "voice_end" : "user";
104
118
  }
105
- function U() {
106
- l.getState().avatarEnabled !== S && l.setAvatarEnabled(S);
119
+ function G() {
120
+ u.getState().avatarEnabled !== v && u.setAvatarEnabled(v);
107
121
  }
108
- let re = {
122
+ let ye = {
109
123
  positionSec: null,
110
124
  synthetic: !0,
111
125
  rpc: "none"
112
- }, W = r({
126
+ }, K = r({
113
127
  port: {
114
- isActive: () => E !== null && E.port.isActive(),
115
- isAudioBlocked: () => E?.port.isAudioBlocked() ?? !1,
116
- connectionId: () => E?.port.connectionId() ?? 0,
117
- isMeterHealthy: () => E?.port.isMeterHealthy() ?? !1,
118
- isMeterAudible: () => E?.port.isMeterAudible() ?? !1,
119
- openSegment: () => E ? E.port.openSegment() : Promise.reject(new e("connection")),
120
- clearBuffer: (e) => E ? E.port.clearBuffer(e) : Promise.resolve(re),
121
- setOutputMuted: (e) => E?.port.setOutputMuted(e),
122
- subscribe: (e) => E ? E.port.subscribe(e) : () => void 0
128
+ isActive: () => S !== null && S.port.isActive(),
129
+ isAudioBlocked: () => S?.port.isAudioBlocked() ?? !1,
130
+ connectionId: () => S?.port.connectionId() ?? 0,
131
+ isMeterHealthy: () => S?.port.isMeterHealthy() ?? !1,
132
+ isMeterAudible: () => S?.port.isMeterAudible() ?? !1,
133
+ openSegment: () => S ? S.port.openSegment() : Promise.reject(new e("connection")),
134
+ clearBuffer: (e) => S ? S.port.clearBuffer(e) : Promise.resolve(ye),
135
+ setOutputMuted: (e) => S?.port.setOutputMuted(e),
136
+ subscribe: (e) => S ? S.port.subscribe(e) : () => void 0
123
137
  },
124
- scheduler: c,
125
- decode: s.decode,
126
- ...s.trackerConfig ? { trackerConfig: s.trackerConfig } : {},
127
- ...s.maxDrainMs === void 0 ? {} : { maxDrainMs: s.maxDrainMs },
128
- ...s.stallMs === void 0 ? {} : { stallMs: s.stallMs },
138
+ scheduler: l,
139
+ decode: c.decode,
140
+ ...c.trackerConfig ? { trackerConfig: c.trackerConfig } : {},
141
+ ...c.maxDrainMs === void 0 ? {} : { maxDrainMs: c.maxDrainMs },
142
+ ...c.stallMs === void 0 ? {} : { stallMs: c.stallMs },
129
143
  onNotice: (e) => {
130
- switch (R({
144
+ switch (H({
131
145
  event: "notice",
132
146
  notice: e
133
147
  }), e.kind) {
134
148
  case "interrupted":
135
- V({ notice: "interrupted" });
149
+ W({ notice: "interrupted" });
136
150
  return;
137
151
  case "voice-fallback":
138
- S && V({ notice: "voice-only" });
152
+ v && W({ notice: "voice-only" });
139
153
  return;
140
154
  case "audio-blocked":
141
- V({
155
+ W({
142
156
  audioBlocked: !0,
143
157
  problem: "playback-blocked"
144
158
  });
@@ -148,28 +162,31 @@ function h(s) {
148
162
  },
149
163
  onActivity: (e) => {
150
164
  if (e) {
151
- P?.(), P = null;
165
+ D?.(), D = null;
152
166
  return;
153
167
  }
154
- if (C) {
155
- K("user", { notice: "time-limit" });
168
+ if (y) {
169
+ q("user", { notice: be() });
156
170
  return;
157
171
  }
158
- G();
172
+ xe();
159
173
  }
160
174
  });
161
- function G() {
162
- P?.(), P = null, _.phase === "ready" && (P = c.setTimeout(() => {
163
- P = null, _.phase === "ready" && !W.isBusy() && K("idle", {});
164
- }, u));
175
+ function be() {
176
+ return he ? "minutes-ended" : "time-limit";
177
+ }
178
+ function xe() {
179
+ D?.(), D = null, h.phase === "ready" && (D = l.setTimeout(() => {
180
+ D = null, h.phase === "ready" && !K.isBusy() && q("idle", {});
181
+ }, d));
165
182
  }
166
- function ie() {
167
- P?.(), P = null, F?.(), F = null;
183
+ function Se() {
184
+ D?.(), D = null, O?.(), O = null;
168
185
  }
169
- function ae() {
170
- W.leave();
171
- let e = E;
172
- if (E = null, e !== null) {
186
+ function Ce() {
187
+ K.leave();
188
+ let e = S;
189
+ if (S = null, e !== null) {
173
190
  if (e.unsubscribe?.(), e.meter !== null) {
174
191
  if (e.meterAudible) {
175
192
  e.meterAudible = !1;
@@ -177,153 +194,246 @@ function h(s) {
177
194
  }
178
195
  e.meter.stop();
179
196
  }
180
- e.videoTrack?.detach(), e.transport.dispose(), e.audioElement !== null && s.releaseAudioElement(e.audioElement);
197
+ e.videoTrack?.detach(), e.transport.dispose(), e.audioElement !== null && c.releaseAudioElement(e.audioElement);
181
198
  }
182
199
  }
183
- function K(e, t) {
184
- w += 1, A = e, S = !1, C = !1, M = !1, N = null, ae(), ie();
185
- let n = T;
186
- T = null, U(), n !== null && (R({
187
- event: "session-ended",
188
- reason: e
189
- }), s.client()?.end(n, {
190
- reason: e,
191
- keepalive: t.keepalive === !0
192
- }).catch(() => void 0)), V({
200
+ function q(e, t) {
201
+ b += 1, pe = e, v = !1, y = !1, T = !1, E = null, he = !1, Ce(), Se();
202
+ let n = x;
203
+ if (x = null, G(), n !== null) {
204
+ H({
205
+ event: "session-ended",
206
+ reason: e
207
+ });
208
+ let r = c.client(), i = () => ze(e);
209
+ r?.end(n, {
210
+ reason: e,
211
+ keepalive: t.keepalive === !0
212
+ }).then(i, i);
213
+ }
214
+ W({
193
215
  phase: "off",
194
216
  closing: !1,
195
217
  audioBlocked: !1,
196
218
  videoReady: !1,
197
- ...t.problem === void 0 ? _.problem !== null && p.has(_.problem) ? { problem: null } : {} : { problem: t.problem },
219
+ sessionMinutes: null,
220
+ sessionEndsAt: null,
221
+ ...t.problem === void 0 ? h.problem !== null && ae.has(h.problem) ? { problem: null } : {} : { problem: t.problem },
198
222
  ...t.notice === void 0 ? {} : { notice: t.notice }
199
223
  });
200
224
  }
201
- function q(e) {
202
- let t = o(e);
203
- t.hide && (y = !0), e instanceof i && R({
225
+ function we(e) {
226
+ let t = s(e);
227
+ t.hide && (_ = !0), e instanceof i && H({
204
228
  event: "refused",
205
229
  status: e.status,
206
230
  code: e.code
207
- }), S = !1, M = !1, N = null, U();
208
- let n = t.retryAfterSeconds !== void 0 && t.retryAfterSeconds > 0 ? t.retryAfterSeconds * 1e3 : 0, r = n > 0 ? s.now() + n : null;
209
- return V({
231
+ }), v = !1, T = !1, E = null, G();
232
+ let n = t.retryAfterSeconds !== void 0 && t.retryAfterSeconds > 0 ? t.retryAfterSeconds * 1e3 : 0, r = n > 0 ? c.now() + n : null;
233
+ return W({
210
234
  phase: "off",
211
235
  problem: t.problem,
212
236
  retryAt: r,
213
- budgetScope: t.scope ?? null
214
- }), r !== null && _.retryAt === r && (I = c.setTimeout(() => {
215
- I = null, J(r);
216
- }, n)), t;
237
+ budgetScope: t.scope ?? null,
238
+ minutesReason: t.minutesReason ?? null
239
+ }), r !== null && h.retryAt === r && (k = l.setTimeout(() => {
240
+ k = null, Te(r);
241
+ }, n)), t.problem !== null && se.has(t.problem) && X(!0), t;
217
242
  }
218
- function J(e) {
219
- _.retryAt === e && V({
243
+ function Te(e) {
244
+ h.retryAt === e && W({
220
245
  problem: null,
221
246
  retryAt: null
222
247
  });
223
248
  }
224
- function Y() {
225
- let e = _.retryAt;
226
- L || e === null || B() || J(e);
249
+ function Ee() {
250
+ let e = h.retryAt;
251
+ A || e === null || U() || Te(e);
227
252
  }
228
- function X(e = m) {
229
- e.hide && (y = !0), S = !1, M = !1, N = null, U(), V({
253
+ function J(e = oe) {
254
+ e.hide && (_ = !0), v = !1, T = !1, E = null, G(), Pe(), W({
230
255
  phase: "off",
231
256
  problem: e.problem,
232
257
  retryAt: null,
233
- avatars: []
258
+ avatars: [],
259
+ minutes: null,
260
+ minutesReason: null
261
+ });
262
+ }
263
+ function De(e) {
264
+ E = null, W({
265
+ phase: "off",
266
+ problem: e.problem,
267
+ retryAt: null,
268
+ minutesReason: e.minutesReason ?? null
269
+ });
270
+ }
271
+ function Oe() {
272
+ return M = l.now(), me += 1, me;
273
+ }
274
+ function ke(e) {
275
+ return e <= j ? !1 : (j = e, !0);
276
+ }
277
+ function Ae(e, t) {
278
+ return ke(e) ? { minutes: t } : {};
279
+ }
280
+ function je(e, t) {
281
+ if (!ke(e)) return {};
282
+ let { problem: n } = h;
283
+ if (!(n !== null && ce.has(n) && h.retryAt === null && h.minutesReason !== "ZERO_SESSION_LIMIT")) return { minutes: t };
284
+ let r = o(t);
285
+ return {
286
+ minutes: t,
287
+ problem: r?.problem ?? null,
288
+ minutesReason: r?.minutesReason ?? null
289
+ };
290
+ }
291
+ function Me() {
292
+ return c.isPageVisible?.() ?? !0;
293
+ }
294
+ function Ne() {
295
+ F?.(), F = null, I = null;
296
+ }
297
+ function Y() {
298
+ z += 1, B?.(), B = null, h.purchase !== "idle" && W({ purchase: "idle" });
299
+ }
300
+ function Pe() {
301
+ j = me, P = !1, L = 0, Ne(), Y();
302
+ }
303
+ function Fe() {
304
+ return !A && h.minutes !== null && h.offered && (h.phase === "off" || h.phase === "choosing");
305
+ }
306
+ function X(e) {
307
+ if (e && (L = 0), !Fe() || !Me()) return;
308
+ if (N) {
309
+ P = !0;
310
+ return;
311
+ }
312
+ let t = l.now(), n = Math.max(M === null ? t : M + f, R);
313
+ if (t < n) {
314
+ Ie(n);
315
+ return;
316
+ }
317
+ let r = c.client();
318
+ r !== null && Re(r);
319
+ }
320
+ function Ie(e) {
321
+ F !== null && I !== null && I <= e || (Ne(), I = e, F = l.setTimeout(() => {
322
+ F = null, I = null, X(!1);
323
+ }, e - l.now()));
324
+ }
325
+ function Le(e) {
326
+ return !(e instanceof i) || e.status !== 429 ? !1 : (R = Math.max(R, l.now() + Math.max(0, e.retryAfterSeconds ?? 0) * 1e3), !0);
327
+ }
328
+ function Re(e) {
329
+ let t = Oe();
330
+ N = !0, Z((t) => e.availability(t)).then((e) => {
331
+ A || (L = 0, W(je(t, e.available ? e.minutes ?? null : null)));
332
+ }, (e) => {
333
+ A || Le(e) && t > j && L < 2 && (L += 1, P = !0);
334
+ }).finally(() => {
335
+ N = !1, P && (P = !1, X(!1));
234
336
  });
235
337
  }
236
- function oe(e) {
338
+ function ze(e) {
339
+ e === "workspace_switch" || e === "page_hide" || X(!0);
340
+ }
341
+ function Be(e) {
237
342
  switch (e.type) {
238
343
  case "audioPlayback":
239
- e.canPlay ? _.problem === "playback-blocked" ? V({
344
+ e.canPlay ? h.problem === "playback-blocked" ? W({
240
345
  audioBlocked: !1,
241
346
  problem: null
242
- }) : V({ audioBlocked: !1 }) : V({
347
+ }) : W({ audioBlocked: !1 }) : W({
243
348
  audioBlocked: !0,
244
349
  problem: "playback-blocked"
245
350
  });
246
351
  return;
247
352
  case "avatarLeft":
248
353
  case "disconnected":
249
- se();
354
+ Ve();
250
355
  return;
251
356
  default: return;
252
357
  }
253
358
  }
254
- async function se() {
255
- let e = T;
256
- if (e === null || _.phase === "ending" || _.phase === "off") return;
257
- let t = w;
258
- V({ phase: "ending" });
359
+ async function Ve() {
360
+ let e = x;
361
+ if (e === null || h.phase === "ending" || h.phase === "off") return;
362
+ let t = b;
363
+ W({ phase: "ending" });
259
364
  let n = null, r = !1;
260
365
  try {
261
- let t = s.client(), i = t === null ? void 0 : await le((n) => t.status(e, n));
366
+ let t = c.client(), i = t === null ? void 0 : await Z((n) => t.status(e, n));
262
367
  n = i?.endedReason ?? null, r = i !== void 0 && [
263
368
  "ended",
264
369
  "failed",
265
370
  "canceled"
266
371
  ].includes(i.state);
267
372
  } catch {}
268
- if (w !== t) return;
269
- let i = f(n);
270
- i.hide && (y = !0), r && (T = null, R({
373
+ if (b !== t) return;
374
+ let i = ie(n);
375
+ i.hide && (_ = !0), r && (x = null, H({
271
376
  event: "session-ended",
272
377
  reason: "server"
273
- })), K("client_error", i);
378
+ }));
379
+ let a = i.notice === "time-limit" ? be() : i.notice;
380
+ q("client_error", {
381
+ problem: i.problem,
382
+ notice: a
383
+ }), r && ze("client_error");
274
384
  }
275
- async function ce(e, r) {
276
- let i = s.client();
385
+ async function He(e, r) {
386
+ let i = c.client();
277
387
  if (i === null) {
278
- X();
388
+ J();
279
389
  return;
280
390
  }
281
- let a = ++w;
282
- V({
391
+ let a = ++b;
392
+ W({
283
393
  phase: "starting",
284
394
  problem: null,
285
395
  notice: null
286
396
  });
287
397
  let o;
288
398
  try {
289
- o = await s.openRoom();
399
+ o = await c.openRoom();
290
400
  } catch {
291
- w === a && X();
401
+ b === a && J();
292
402
  return;
293
403
  }
294
- let l = () => {
404
+ let s = () => {
295
405
  o.disconnect().catch(() => void 0);
296
406
  };
297
- if (w !== a) {
298
- l();
407
+ if (b !== a) {
408
+ s();
299
409
  return;
300
410
  }
301
- let u = c.now(), d;
411
+ let u = l.now(), d;
302
412
  try {
303
413
  d = await i.create({
304
414
  avatarId: e,
305
415
  consentVersion: r,
306
- idempotencyKey: s.newIdempotencyKey()
416
+ idempotencyKey: c.newIdempotencyKey()
307
417
  });
308
418
  } catch (e) {
309
- if (l(), w !== a) return;
310
- q(e).showDisclosure && (b = null, $.requestOn({ start: !1 }));
419
+ if (s(), b !== a) return;
420
+ we(e).showDisclosure && (le = null, $.requestOn({ start: !1 }));
311
421
  return;
312
422
  }
313
- if (w !== a) {
314
- l(), i.end(d.sessionId, { reason: A === "voice_end" ? "voice_end" : "user" }).catch(() => void 0);
423
+ if (b !== a) {
424
+ s(), i.end(d.sessionId, { reason: pe === "voice_end" ? "voice_end" : "user" }).catch(() => void 0);
315
425
  return;
316
426
  }
317
- T = d.sessionId, V({ phase: "connecting" });
427
+ x = d.sessionId, W({ phase: "connecting" });
318
428
  let f = new t({
319
429
  room: o,
320
430
  avatarIdentity: d.avatarIdentity,
321
- scheduler: c,
322
- ...s.readinessProbe === void 0 ? {} : { readinessProbe: s.readinessProbe }
431
+ scheduler: l,
432
+ ...c.readinessProbe === void 0 ? {} : { readinessProbe: c.readinessProbe }
323
433
  }), p = /* @__PURE__ */ new Set(), m = {
324
434
  session: d,
325
435
  transport: f,
326
- audioElement: s.createAudioElement(),
436
+ audioElement: c.createAudioElement(),
327
437
  meter: null,
328
438
  meterAudible: !1,
329
439
  meterListeners: p,
@@ -331,22 +441,22 @@ function h(s) {
331
441
  unsubscribe: null,
332
442
  port: n({
333
443
  transport: f,
334
- isEnabled: () => S && !C,
444
+ isEnabled: () => v && !y,
335
445
  subscribeMeter: (e) => (p.add(e), () => {
336
446
  p.delete(e);
337
447
  }),
338
448
  isMeterHealthy: () => m.meter?.isRunning() ?? !1
339
449
  })
340
450
  };
341
- E = m, m.unsubscribe = f.subscribe(oe);
451
+ S = m, m.unsubscribe = f.subscribe(Be);
342
452
  try {
343
- await ue(f.connect({
453
+ await Ue(f.connect({
344
454
  url: d.livekitUrl,
345
455
  token: d.participantToken,
346
456
  audioElement: m.audioElement,
347
457
  onAvatarAudio: (e) => {
348
458
  if (!(e.mediaStreamTrack === null || m.meter !== null)) try {
349
- m.meter = s.startMeter(e.mediaStreamTrack, (e) => {
459
+ m.meter = c.startMeter(e.mediaStreamTrack, (e) => {
350
460
  m.meterAudible = e;
351
461
  for (let t of [...p]) t(e);
352
462
  });
@@ -356,35 +466,38 @@ function h(s) {
356
466
  },
357
467
  onAvatarVideo: (e) => {
358
468
  m.videoTrack = e;
359
- let t = Z();
360
- t !== null && e.attach(t), E === m && V({ videoReady: !0 });
469
+ let t = We();
470
+ t !== null && e.attach(t), S === m && W({ videoReady: !0 });
361
471
  }
362
- }), h);
472
+ }), ne);
363
473
  } catch (e) {
364
- if (w !== a) return;
365
- R({
474
+ if (b !== a) return;
475
+ H({
366
476
  event: "connect-failed",
367
477
  error: e instanceof Error ? e.name : "error"
368
- }), K("client_error", { problem: "connection" });
478
+ }), q("client_error", { problem: "connection" });
369
479
  return;
370
480
  }
371
- if (w !== a || E !== m) return;
372
- V({
481
+ if (b !== a || S !== m) return;
482
+ let re = d.maxSessionSeconds === void 0 ? ue : d.maxSessionSeconds * 1e3, ie = re > 0 ? u + re - ee - l.now() : d.endsAt - c.now();
483
+ he = d.minutes?.limitedByBalance === !0, W({
373
484
  phase: "ready",
374
485
  audioBlocked: f.audioBlocked,
375
- ...f.audioBlocked ? { problem: "playback-blocked" } : {}
376
- }), G();
377
- let g = x > 0 ? u + x - ee - c.now() : d.endsAt - s.now(), _ = Math.max(0, g - te);
378
- F = c.setTimeout(() => {
379
- F = null, w === a && (C = !0, V({ closing: !0 }), W.isBusy() || K("user", { notice: "time-limit" }));
380
- }, _);
381
- }
382
- function le(t) {
486
+ ...f.audioBlocked ? { problem: "playback-blocked" } : {},
487
+ sessionMinutes: d.minutes ?? null,
488
+ sessionEndsAt: d.maxSessionSeconds === void 0 ? null : c.now() + ie
489
+ }), xe();
490
+ let ae = Math.max(0, ie - te);
491
+ O = l.setTimeout(() => {
492
+ O = null, b === a && (y = !0, W({ closing: !0 }), K.isBusy() || q("user", { notice: be() }));
493
+ }, ae);
494
+ }
495
+ function Z(t) {
383
496
  let n = new AbortController();
384
497
  return new Promise((r, i) => {
385
- let a = c.setTimeout(() => {
498
+ let a = l.setTimeout(() => {
386
499
  n.abort(), i(new e("connection"));
387
- }, g);
500
+ }, m);
388
501
  t(n.signal).then((e) => {
389
502
  a(), r(e);
390
503
  }, (e) => {
@@ -392,9 +505,9 @@ function h(s) {
392
505
  });
393
506
  });
394
507
  }
395
- function ue(t, n) {
508
+ function Ue(t, n) {
396
509
  return new Promise((r, i) => {
397
- let a = c.setTimeout(() => i(new e("connection")), n);
510
+ let a = l.setTimeout(() => i(new e("connection")), n);
398
511
  t.then((e) => {
399
512
  a(), r(e);
400
513
  }, (e) => {
@@ -402,192 +515,240 @@ function h(s) {
402
515
  });
403
516
  });
404
517
  }
405
- function Z() {
406
- return D[D.length - 1] ?? null;
518
+ function We() {
519
+ return C[C.length - 1] ?? null;
407
520
  }
408
- function de(e) {
409
- let t = D.indexOf(e);
521
+ function Ge(e) {
522
+ let t = C.indexOf(e);
410
523
  if (t === -1) return;
411
- let n = t === D.length - 1;
412
- D.splice(t, 1);
413
- let r = E?.videoTrack ?? null;
524
+ let n = t === C.length - 1;
525
+ C.splice(t, 1);
526
+ let r = S?.videoTrack ?? null;
414
527
  if (!n || r === null) return;
415
528
  r.detach();
416
- let i = Z();
529
+ let i = We();
417
530
  i !== null && r.attach(i);
418
531
  }
419
532
  let Q = [];
420
- Q.push(l.subscribe(() => {
421
- let e = l.getState().avatarEnabled;
422
- if (e !== S) {
533
+ Q.push(u.subscribe(() => {
534
+ let e = u.getState().avatarEnabled;
535
+ if (e !== v) {
423
536
  if (e) {
424
- l.setAvatarEnabled(!1);
537
+ u.setAvatarEnabled(!1);
425
538
  return;
426
539
  }
427
- _.phase !== "off" && _.phase !== "checking" && _.phase !== "choosing" ? K(H(), {}) : S = !1;
540
+ h.phase !== "off" && h.phase !== "checking" && h.phase !== "choosing" ? q(ve(), {}) : v = !1;
428
541
  }
429
- })), s.subscribeWorkspaceChange && Q.push(s.subscribeWorkspaceChange(() => {
430
- if (y = !1, _.phase === "off" ? V({
542
+ })), c.subscribeWorkspaceChange && Q.push(c.subscribeWorkspaceChange(() => {
543
+ if (_ = !1, Pe(), h.phase === "off" ? W({
431
544
  problem: null,
432
545
  avatars: [],
433
- consentVersion: null
434
- }) : (K("workspace_switch", { problem: null }), V({
546
+ consentVersion: null,
547
+ minutes: null
548
+ }) : (q("workspace_switch", { problem: null }), W({
435
549
  avatars: [],
436
- consentVersion: null
437
- })), j) {
438
- let e = w;
439
- c.setTimeout(() => {
440
- j && w === e && $.requestOn({ start: !1 });
550
+ consentVersion: null,
551
+ minutes: null
552
+ })), w) {
553
+ let e = b;
554
+ l.setTimeout(() => {
555
+ w && b === e && $.requestOn({ start: !1 });
441
556
  }, 0);
442
557
  }
443
- })), s.subscribePageHide && Q.push(s.subscribePageHide(() => {
444
- (T !== null || _.phase !== "off") && K("page_hide", { keepalive: !0 });
445
- })), s.subscribePageShow && Q.push(s.subscribePageShow(Y));
558
+ })), c.subscribePageHide && Q.push(c.subscribePageHide(() => {
559
+ (x !== null || h.phase !== "off") && q("page_hide", { keepalive: !0 });
560
+ })), c.subscribePageVisible && Q.push(c.subscribePageVisible(() => {
561
+ N || X(!0);
562
+ })), c.subscribePageShow && Q.push(c.subscribePageShow(Ee));
446
563
  let $ = {
447
564
  subscribe(e) {
448
- return v.add(e), () => {
449
- v.delete(e);
565
+ return g.add(e), () => {
566
+ g.delete(e);
450
567
  };
451
568
  },
452
- getSnapshot: () => _,
569
+ getSnapshot: () => h,
453
570
  setVoiceLive(e) {
454
- if (k = !e, e) {
455
- V({
571
+ if (fe = !e, e) {
572
+ W({
456
573
  voiceLive: !0,
457
- problem: y || j && B() ? _.problem : null,
574
+ problem: _ || w && U() ? h.problem : null,
458
575
  notice: null
459
576
  });
460
577
  return;
461
578
  }
462
- if (M = !1, j) {
463
- V({ voiceLive: !1 });
579
+ if (T = !1, w) {
580
+ W({ voiceLive: !1 });
464
581
  return;
465
582
  }
466
- (T !== null || _.phase !== "off") && (_.phase === "checking" || _.phase === "choosing" ? (w += 1, V({ phase: "off" })) : K("voice_end", {})), V({
583
+ (x !== null || h.phase !== "off") && (h.phase === "checking" || h.phase === "choosing" ? (b += 1, W({ phase: "off" })) : q("voice_end", {})), W({
467
584
  voiceLive: !1,
468
585
  notice: null
469
586
  });
470
587
  },
471
588
  requestOn(e = {}) {
472
- if (L || !_.offered || _.phase !== "off") return;
589
+ if (A || !h.offered || h.phase !== "off") return;
473
590
  let t = e.start === void 0 ? "auto" : e.start ? "start" : "choose";
474
- if (t === "start" && B()) return;
475
- let n = e.avatarId ?? _.selectedAvatarId, r = _.consentVersion, i = s.client();
591
+ if (t === "start" && U()) return;
592
+ let n = e.avatarId ?? h.selectedAvatarId, r = h.consentVersion, i = c.client();
476
593
  if (i === null) {
477
- X();
594
+ J();
478
595
  return;
479
596
  }
480
- t === "start" && (N = c.now());
481
- let o = ++w;
482
- V({
597
+ t === "start" && (E = l.now());
598
+ let o = ++b, s = Oe();
599
+ P = !1, Ne(), W({
483
600
  phase: "checking",
484
- problem: B() ? _.problem : null,
601
+ problem: U() ? h.problem : null,
485
602
  notice: null
486
- }), le((e) => i.availability(e)).then((e) => {
487
- if (w !== o) return;
603
+ }), Z((e) => i.availability(e)).then((e) => {
604
+ if (b !== o) return;
488
605
  if (!e.available) {
489
- X(a(e.reason));
606
+ J(a(e.reason));
490
607
  return;
491
608
  }
492
- x = e.maxSessionSeconds * 1e3;
493
- let i = t === "start" && n !== null && e.avatars.includes(n), s = l.getState().avatarId, c = i ? n : s !== null && e.avatars.includes(s) ? s : e.avatars[0] ?? null;
494
- switch (V({
609
+ ue = e.maxSessionSeconds * 1e3;
610
+ let i = t === "start" && n !== null && e.avatars.includes(n), c = u.getState().avatarId, l = i ? n : c !== null && e.avatars.includes(c) ? c : e.avatars[0] ?? null;
611
+ switch (W({
495
612
  phase: "choosing",
496
613
  avatars: e.avatars,
497
- selectedAvatarId: c,
498
- consentVersion: e.consentVersion
614
+ selectedAvatarId: l,
615
+ consentVersion: e.consentVersion,
616
+ ...Ae(s, e.minutes ?? null)
499
617
  }), t) {
500
618
  case "auto":
501
- b === e.consentVersion && e.avatars.length === 1 && $.confirm();
619
+ le === e.consentVersion && e.avatars.length === 1 && $.confirm();
502
620
  return;
503
621
  case "start":
504
- i && r === e.consentVersion ? $.confirm() : N = null;
622
+ i && r === e.consentVersion ? $.confirm() : E = null;
505
623
  return;
506
624
  case "choose": return;
507
625
  }
508
626
  }, (e) => {
509
- w === o && q(e);
627
+ Le(e), b === o && we(e);
510
628
  });
511
629
  },
512
630
  confirm() {
513
- if (_.phase !== "choosing" || !(_.voiceLive || j) || B()) return;
514
- let e = _.selectedAvatarId, t = _.consentVersion;
515
- e === null || t === null || (b = t, l.setAvatarId(e), S = !0, M = !j, j && (N ??= c.now()), U(), ce(e, t));
631
+ if (h.phase !== "choosing" || !(h.voiceLive || w) || U()) return;
632
+ let e = o(h.minutes);
633
+ if (e !== null) {
634
+ De(e);
635
+ return;
636
+ }
637
+ let t = h.selectedAvatarId, n = h.consentVersion;
638
+ t === null || n === null || (le = n, u.setAvatarId(t), v = !0, T = !w, w && (E ??= l.now()), G(), He(t, n));
516
639
  },
517
- recheckRetry: Y,
640
+ recheckRetry: Ee,
518
641
  cancelChoice() {
519
- _.phase === "choosing" && (w += 1, N = null, V({ phase: "off" }));
642
+ h.phase === "choosing" && (b += 1, E = null, W({ phase: "off" }));
643
+ },
644
+ refreshMinutes() {
645
+ X(!0);
646
+ },
647
+ checkMinutesPurchase() {
648
+ if (A || h.minutes === null) return;
649
+ let e = c.client();
650
+ if (e === null) return;
651
+ Y();
652
+ let t = z, n = l.now(), r = M === null ? n : Math.max(n, M + p), i = h.minutes.balance?.availableMinutes ?? 0, a = 0;
653
+ W({ purchase: "checking" });
654
+ let o = () => {
655
+ if (B = null, t !== z) return;
656
+ a += 1;
657
+ let n = a >= 5;
658
+ if (h.phase !== "off" && h.phase !== "choosing" && h.phase !== "checking") {
659
+ Y();
660
+ return;
661
+ }
662
+ if (n || (B = l.setTimeout(o, r + a * p - l.now())), !Me() || h.phase === "checking" || N || V || l.now() < R) {
663
+ n && Y();
664
+ return;
665
+ }
666
+ V = !0;
667
+ let s = Oe();
668
+ Z((t) => e.availability(t)).then((e) => {
669
+ if (V = !1, A) return;
670
+ let r = e.available ? e.minutes ?? null : null;
671
+ W(je(s, r)), t === z && ((r?.balance?.availableMinutes ?? 0) > i || n) && Y();
672
+ }, (e) => {
673
+ V = !1, !A && (Le(e), t === z && n && Y());
674
+ });
675
+ };
676
+ r > n ? B = l.setTimeout(o, r - n) : o();
520
677
  },
521
678
  setTabOpen(e) {
522
- if (L || e === j) return;
523
- if (j = e, e) {
524
- V({ tabOpen: !0 }), _.phase === "checking" && (w += 1, V({ phase: "off" }), $.requestOn({ start: !1 }));
679
+ if (A || e === w) return;
680
+ if (w = e, e) {
681
+ if (W({ tabOpen: !0 }), h.phase === "checking") {
682
+ b += 1, W({ phase: "off" }), $.requestOn({ start: !1 });
683
+ return;
684
+ }
685
+ X(!0);
525
686
  return;
526
687
  }
527
- N = null;
528
- let t = _.phase;
688
+ E = null;
689
+ let t = h.phase;
529
690
  if (t === "checking" || t === "choosing") {
530
- w += 1, V({
691
+ b += 1, W({
531
692
  tabOpen: !1,
532
693
  phase: "off"
533
694
  });
534
695
  return;
535
696
  }
536
- (T !== null || t !== "off") && !_.heldByVoice && K("user", {}), V({ tabOpen: !1 });
697
+ (x !== null || t !== "off") && !h.heldByVoice && q("user", {}), W({ tabOpen: !1 });
537
698
  },
538
699
  selectAvatar(e) {
539
- _.avatars.includes(e) && V({ selectedAvatarId: e });
700
+ h.avatars.includes(e) && W({ selectedAvatarId: e });
540
701
  },
541
702
  switchOff() {
542
- let { phase: e } = _;
543
- if (!(j && N !== null && (e === "checking" || e === "starting" || e === "connecting") && c.now() - N < 1e3)) {
703
+ let { phase: e } = h;
704
+ if (!(w && E !== null && (e === "checking" || e === "starting" || e === "connecting") && l.now() - E < 1e3)) {
544
705
  if (e === "checking" || e === "choosing") {
545
- w += 1, N = null, V({ phase: "off" });
706
+ b += 1, E = null, W({ phase: "off" });
546
707
  return;
547
708
  }
548
- if (e === "off" && !S) {
549
- U();
709
+ if (e === "off" && !v) {
710
+ G();
550
711
  return;
551
712
  }
552
- K(H(), {});
713
+ q(ve(), {});
553
714
  }
554
715
  },
555
716
  resumeAudio() {
556
- let e = E;
717
+ let e = S;
557
718
  e !== null && (e.transport.resumeAudio().catch(() => void 0), e.meter?.resume().catch(() => void 0));
558
719
  },
559
720
  setStageMounted(e) {
560
- O = Math.max(0, O + (e ? 1 : -1));
721
+ de = Math.max(0, de + (e ? 1 : -1));
561
722
  },
562
723
  attachVideo(e) {
563
724
  if (e === null) {
564
- let e = Z();
565
- e !== null && de(e);
725
+ let e = We();
726
+ e !== null && Ge(e);
566
727
  return;
567
728
  }
568
- let t = D.indexOf(e);
569
- t !== -1 && D.splice(t, 1), D.push(e);
570
- let n = E?.videoTrack ?? null;
571
- return n !== null && (n.detach(), n.attach(e)), () => de(e);
729
+ let t = C.indexOf(e);
730
+ t !== -1 && C.splice(t, 1), C.push(e);
731
+ let n = S?.videoTrack ?? null;
732
+ return n !== null && (n.detach(), n.attach(e)), () => Ge(e);
572
733
  },
573
734
  route(e, t) {
574
- if (_.phase !== "ready" || C || !S || O === 0 || E === null || E.port.isAudioBlocked() || e.fallback === !1) return "speakers";
735
+ if (h.phase !== "ready" || y || !v || de === 0 || S === null || S.port.isAudioBlocked() || e.fallback === !1) return "speakers";
575
736
  let n = e.voice;
576
- return n !== null && n.source !== "hosted" || !t.listVoices().some((e) => e.source === "hosted") ? (R({
737
+ return n !== null && n.source !== "hosted" || !t.listVoices().some((e) => e.source === "hosted") ? (H({
577
738
  event: "notice",
578
739
  notice: { kind: "needs-hosted-voice" }
579
- }), V({ problem: "needs-hosted-voice" }), "speakers") : (_.problem === "needs-hosted-voice" && V({ problem: null }), "avatar");
740
+ }), W({ problem: "needs-hosted-voice" }), "speakers") : (h.problem === "needs-hosted-voice" && W({ problem: null }), "avatar");
580
741
  },
581
- createOutput: () => W.createOutput(),
742
+ createOutput: () => K.createOutput(),
582
743
  dispose() {
583
- if (!L) {
584
- L = !0, (T !== null || _.phase !== "off") && K("user", {}), I?.(), I = null;
744
+ if (!A) {
745
+ A = !0, (x !== null || h.phase !== "off") && q("user", {}), k?.(), k = null, Ne(), z += 1, B?.(), B = null;
585
746
  for (let e of Q.splice(0)) e();
586
- v.clear();
747
+ g.clear();
587
748
  }
588
749
  }
589
750
  };
590
751
  return $;
591
752
  }
592
753
  //#endregion
593
- export { u as LIVE_AVATAR_CONNECT_TIMEOUT_MS, c as LIVE_AVATAR_END_BEFORE_DEADLINE_MS, s as LIVE_AVATAR_IDLE_MS, l as LIVE_AVATAR_REQUEST_TIMEOUT_MS, te as LIVE_AVATAR_TAB_OFF_GUARD_MS, h as createLiveAvatarController };
754
+ export { d as LIVE_AVATAR_CONNECT_TIMEOUT_MS, l as LIVE_AVATAR_END_BEFORE_DEADLINE_MS, c as LIVE_AVATAR_IDLE_MS, te as LIVE_AVATAR_MINUTES_BUSY_RETRIES, f as LIVE_AVATAR_MINUTES_REFRESH_MS, ne as LIVE_AVATAR_PURCHASE_POLLS, p as LIVE_AVATAR_PURCHASE_POLL_MS, u as LIVE_AVATAR_REQUEST_TIMEOUT_MS, m as LIVE_AVATAR_TAB_OFF_GUARD_MS, h as createLiveAvatarController };