@opengeni/react 1.4.0 → 1.4.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 (218) hide show
  1. package/README.md +8 -0
  2. package/dist/accounts.js +2 -0
  3. package/dist/accounts.js.map +1 -1
  4. package/dist/artifacts-document.js +5 -4
  5. package/dist/artifacts-presentation.js +5 -4
  6. package/dist/artifacts-spreadsheet.js +4 -3
  7. package/dist/artifacts.js +14 -13
  8. package/dist/artifacts.js.map +1 -1
  9. package/dist/browser-viewer-5EEAS3IU.js +17 -0
  10. package/dist/chat-interactive-block-ZFHOKTMS.js +12 -0
  11. package/dist/{chunk-WEHMPOXK.js → chunk-2DDJ6YH6.js} +3 -1
  12. package/dist/{chunk-WEHMPOXK.js.map → chunk-2DDJ6YH6.js.map} +1 -1
  13. package/dist/{chunk-C5X5AJXK.js → chunk-2HVLQ26H.js} +5 -4
  14. package/dist/{chunk-C5X5AJXK.js.map → chunk-2HVLQ26H.js.map} +1 -1
  15. package/dist/{chunk-HDJWDK7W.js → chunk-2OQA3CPB.js} +300 -166
  16. package/dist/{chunk-HDJWDK7W.js.map → chunk-2OQA3CPB.js.map} +1 -1
  17. package/dist/{chunk-A4UJB2MM.js → chunk-32CGLXW2.js} +4 -3
  18. package/dist/{chunk-A4UJB2MM.js.map → chunk-32CGLXW2.js.map} +1 -1
  19. package/dist/{chunk-5CVXZA3Y.js → chunk-45NUOSXQ.js} +3 -2
  20. package/dist/{chunk-5CVXZA3Y.js.map → chunk-45NUOSXQ.js.map} +1 -1
  21. package/dist/{chunk-WUISZ3WU.js → chunk-53KJBGPZ.js} +5 -4
  22. package/dist/{chunk-WUISZ3WU.js.map → chunk-53KJBGPZ.js.map} +1 -1
  23. package/dist/{chunk-MBMPHOMA.js → chunk-55DXD22O.js} +3 -2
  24. package/dist/{chunk-MBMPHOMA.js.map → chunk-55DXD22O.js.map} +1 -1
  25. package/dist/{chunk-JT4JW7BC.js → chunk-5I4VRWBB.js} +3 -1
  26. package/dist/{chunk-JT4JW7BC.js.map → chunk-5I4VRWBB.js.map} +1 -1
  27. package/dist/{chunk-UK4TINKT.js → chunk-B27E3V37.js} +3 -1
  28. package/dist/{chunk-UK4TINKT.js.map → chunk-B27E3V37.js.map} +1 -1
  29. package/dist/{chunk-J6DBS4T3.js → chunk-BNKV5ZLF.js} +5 -4
  30. package/dist/{chunk-J6DBS4T3.js.map → chunk-BNKV5ZLF.js.map} +1 -1
  31. package/dist/{chunk-YM2DE7BQ.js → chunk-C5BF4L26.js} +13 -12
  32. package/dist/{chunk-YM2DE7BQ.js.map → chunk-C5BF4L26.js.map} +1 -1
  33. package/dist/{chunk-YBXQDQFX.js → chunk-C7CMD56T.js} +6 -5
  34. package/dist/{chunk-YBXQDQFX.js.map → chunk-C7CMD56T.js.map} +1 -1
  35. package/dist/{chunk-UGLEYEMP.js → chunk-CM7LVUKC.js} +3 -1
  36. package/dist/{chunk-UGLEYEMP.js.map → chunk-CM7LVUKC.js.map} +1 -1
  37. package/dist/{chunk-JVYQRRC4.js → chunk-CVYCLFMH.js} +3 -1
  38. package/dist/{chunk-JVYQRRC4.js.map → chunk-CVYCLFMH.js.map} +1 -1
  39. package/dist/{chunk-LJ2UTJJE.js → chunk-EAOSEIXB.js} +182 -97
  40. package/dist/chunk-EAOSEIXB.js.map +1 -0
  41. package/dist/{chunk-Y2PRMYLC.js → chunk-G3U2A6GS.js} +3 -2
  42. package/dist/{chunk-Y2PRMYLC.js.map → chunk-G3U2A6GS.js.map} +1 -1
  43. package/dist/{chunk-WZMYFJD3.js → chunk-G6YRCIYJ.js} +16 -7
  44. package/dist/{chunk-WZMYFJD3.js.map → chunk-G6YRCIYJ.js.map} +1 -1
  45. package/dist/{chunk-B3V6TG77.js → chunk-GC3PH6N7.js} +3 -1
  46. package/dist/{chunk-B3V6TG77.js.map → chunk-GC3PH6N7.js.map} +1 -1
  47. package/dist/{chunk-CJUO7J5Z.js → chunk-HXYOSSQO.js} +3 -2
  48. package/dist/{chunk-CJUO7J5Z.js.map → chunk-HXYOSSQO.js.map} +1 -1
  49. package/dist/{chunk-GYVRFZDY.js → chunk-I6OY3MWC.js} +310 -115
  50. package/dist/chunk-I6OY3MWC.js.map +1 -0
  51. package/dist/{chunk-BRM6FVZA.js → chunk-IEE7WCLN.js} +4 -3
  52. package/dist/{chunk-BRM6FVZA.js.map → chunk-IEE7WCLN.js.map} +1 -1
  53. package/dist/{chunk-DYWBUX5Q.js → chunk-IMSUVYQB.js} +6 -5
  54. package/dist/{chunk-DYWBUX5Q.js.map → chunk-IMSUVYQB.js.map} +1 -1
  55. package/dist/{chunk-LN6TCXD3.js → chunk-IUHHPMAX.js} +184 -48
  56. package/dist/chunk-IUHHPMAX.js.map +1 -0
  57. package/dist/{chunk-SGKD2OCN.js → chunk-IYQCWGU5.js} +6 -5
  58. package/dist/{chunk-SGKD2OCN.js.map → chunk-IYQCWGU5.js.map} +1 -1
  59. package/dist/{chunk-J2QWVSQY.js → chunk-JH7V627O.js} +8 -7
  60. package/dist/{chunk-J2QWVSQY.js.map → chunk-JH7V627O.js.map} +1 -1
  61. package/dist/{chunk-EESD3PY3.js → chunk-JHTIMBOL.js} +6 -5
  62. package/dist/{chunk-EESD3PY3.js.map → chunk-JHTIMBOL.js.map} +1 -1
  63. package/dist/{chunk-LNIRAOA3.js → chunk-L2J3PU7A.js} +7 -6
  64. package/dist/{chunk-LNIRAOA3.js.map → chunk-L2J3PU7A.js.map} +1 -1
  65. package/dist/{chunk-ZYRGEKWS.js → chunk-LJUMYUBO.js} +3 -1
  66. package/dist/{chunk-ZYRGEKWS.js.map → chunk-LJUMYUBO.js.map} +1 -1
  67. package/dist/{chunk-4RVYOY4O.js → chunk-LSW2OJVV.js} +4 -3
  68. package/dist/{chunk-4RVYOY4O.js.map → chunk-LSW2OJVV.js.map} +1 -1
  69. package/dist/{chunk-UTRTG6LH.js → chunk-LVS3MH5T.js} +3 -1
  70. package/dist/{chunk-UTRTG6LH.js.map → chunk-LVS3MH5T.js.map} +1 -1
  71. package/dist/chunk-M357MHH3.js +2 -0
  72. package/dist/{chunk-WRHIZYZF.js → chunk-MEQM4LI3.js} +6 -5
  73. package/dist/{chunk-WRHIZYZF.js.map → chunk-MEQM4LI3.js.map} +1 -1
  74. package/dist/chunk-NX4ADH73.js +14 -0
  75. package/dist/chunk-NX4ADH73.js.map +1 -0
  76. package/dist/{chunk-XCHWDJ22.js → chunk-OGTTUYNT.js} +3 -1
  77. package/dist/{chunk-XCHWDJ22.js.map → chunk-OGTTUYNT.js.map} +1 -1
  78. package/dist/{chunk-GIMRELBW.js → chunk-OYQQJL3J.js} +3 -1
  79. package/dist/{chunk-GIMRELBW.js.map → chunk-OYQQJL3J.js.map} +1 -1
  80. package/dist/{chunk-RSI7XYXL.js → chunk-PBCZL4JP.js} +6 -5
  81. package/dist/{chunk-RSI7XYXL.js.map → chunk-PBCZL4JP.js.map} +1 -1
  82. package/dist/{chunk-I7IWRQLN.js → chunk-PHBFJCEU.js} +17 -11
  83. package/dist/chunk-PHBFJCEU.js.map +1 -0
  84. package/dist/{chunk-3CTRFMAK.js → chunk-PKCAYHDC.js} +5 -4
  85. package/dist/{chunk-3CTRFMAK.js.map → chunk-PKCAYHDC.js.map} +1 -1
  86. package/dist/{chunk-K3HQAKQX.js → chunk-PMV53IMM.js} +3 -1
  87. package/dist/{chunk-K3HQAKQX.js.map → chunk-PMV53IMM.js.map} +1 -1
  88. package/dist/{chunk-YQEAA6LT.js → chunk-QHUE7E4N.js} +3 -2
  89. package/dist/{chunk-YQEAA6LT.js.map → chunk-QHUE7E4N.js.map} +1 -1
  90. package/dist/{chunk-OA6HFRQP.js → chunk-QMMCJGFI.js} +4 -3
  91. package/dist/{chunk-OA6HFRQP.js.map → chunk-QMMCJGFI.js.map} +1 -1
  92. package/dist/{chunk-YV4L3ILF.js → chunk-QV3DJVRZ.js} +3 -1
  93. package/dist/{chunk-YV4L3ILF.js.map → chunk-QV3DJVRZ.js.map} +1 -1
  94. package/dist/{chunk-447JLCBU.js → chunk-S2QH6EZ5.js} +3 -1
  95. package/dist/{chunk-447JLCBU.js.map → chunk-S2QH6EZ5.js.map} +1 -1
  96. package/dist/{chunk-PNY3JKBJ.js → chunk-SFH43JT2.js} +5 -4
  97. package/dist/{chunk-PNY3JKBJ.js.map → chunk-SFH43JT2.js.map} +1 -1
  98. package/dist/{chunk-AWZLIMKX.js → chunk-T46QZH3E.js} +3 -1
  99. package/dist/{chunk-AWZLIMKX.js.map → chunk-T46QZH3E.js.map} +1 -1
  100. package/dist/{chunk-5J4FOW6Q.js → chunk-TNEZNMSN.js} +3 -1
  101. package/dist/{chunk-5J4FOW6Q.js.map → chunk-TNEZNMSN.js.map} +1 -1
  102. package/dist/{chunk-22KP6LR5.js → chunk-TXS65BB2.js} +3 -1
  103. package/dist/{chunk-22KP6LR5.js.map → chunk-TXS65BB2.js.map} +1 -1
  104. package/dist/{chunk-H5X55XH7.js → chunk-UDPH5SLV.js} +4 -3
  105. package/dist/{chunk-H5X55XH7.js.map → chunk-UDPH5SLV.js.map} +1 -1
  106. package/dist/{chunk-VZTQ73XT.js → chunk-XEA5BCMA.js} +3 -1
  107. package/dist/{chunk-VZTQ73XT.js.map → chunk-XEA5BCMA.js.map} +1 -1
  108. package/dist/{chunk-5F4WR7X7.js → chunk-XS67YG5R.js} +3 -1
  109. package/dist/{chunk-5F4WR7X7.js.map → chunk-XS67YG5R.js.map} +1 -1
  110. package/dist/{chunk-TKOTKRWY.js → chunk-XTD7TZHW.js} +3 -1
  111. package/dist/{chunk-TKOTKRWY.js.map → chunk-XTD7TZHW.js.map} +1 -1
  112. package/dist/{chunk-A2PI6UMY.js → chunk-YSRBFJMQ.js} +3 -1
  113. package/dist/{chunk-A2PI6UMY.js.map → chunk-YSRBFJMQ.js.map} +1 -1
  114. package/dist/chunk-YVFRBXST.js +1420 -0
  115. package/dist/chunk-YVFRBXST.js.map +1 -0
  116. package/dist/{chunk-SCOTPE2I.js → chunk-YYLBXXTE.js} +3 -1
  117. package/dist/{chunk-SCOTPE2I.js.map → chunk-YYLBXXTE.js.map} +1 -1
  118. package/dist/{chunk-RHREZ7BO.js → chunk-ZUWF4NF7.js} +3 -1
  119. package/dist/{chunk-RHREZ7BO.js.map → chunk-ZUWF4NF7.js.map} +1 -1
  120. package/dist/clipboard.js +3 -2
  121. package/dist/components/composer-transcription-control.d.ts +4 -0
  122. package/dist/components/session-conversation.d.ts +6 -0
  123. package/dist/composer-voice-events.d.ts +8 -0
  124. package/dist/composer.js +15 -13
  125. package/dist/computer-viewer-ELNLZGHI.js +20 -0
  126. package/dist/connect.js +15 -12
  127. package/dist/connect.js.map +1 -1
  128. package/dist/desktop.js +6 -5
  129. package/dist/desktop.js.map +1 -1
  130. package/dist/diffs.js +2 -1
  131. package/dist/diffs.js.map +1 -1
  132. package/dist/editor.js +4 -3
  133. package/dist/editor.js.map +1 -1
  134. package/dist/embedded-voice-NIL4RDX3.js +69 -0
  135. package/dist/embedded-voice-NIL4RDX3.js.map +1 -0
  136. package/dist/{fleet-decision-row-YZ3ZKWMM.js → fleet-decision-row-SI63O5V4.js} +3 -1
  137. package/dist/{fleet-decision-row-YZ3ZKWMM.js.map → fleet-decision-row-SI63O5V4.js.map} +1 -1
  138. package/dist/hooks/use-client-config-flags.d.ts +6 -0
  139. package/dist/hooks/use-computer-session.d.ts +2 -0
  140. package/dist/hooks/use-realtime-voice-models.d.ts +9 -0
  141. package/dist/hooks/use-voice-input.d.ts +8 -1
  142. package/dist/index.js +47 -45
  143. package/dist/index.js.map +1 -1
  144. package/dist/interaction.js +14 -13
  145. package/dist/interaction.js.map +1 -1
  146. package/dist/{latest-question-GPYM2JNU.js → latest-question-2POFPYNB.js} +5 -4
  147. package/dist/{latest-question-GPYM2JNU.js.map → latest-question-2POFPYNB.js.map} +1 -1
  148. package/dist/machines.js +8 -7
  149. package/dist/{markdown-table-layout-QXSLK4BY.js → markdown-table-layout-DQ4DRNVT.js} +3 -1
  150. package/dist/{markdown-table-layout-QXSLK4BY.js.map → markdown-table-layout-DQ4DRNVT.js.map} +1 -1
  151. package/dist/model-policy-picker-menu-WRNSRFQC.js +15 -0
  152. package/dist/model-policy.js +2 -1
  153. package/dist/{noto-sans-arabic-loader-IA2T4X2A.js → noto-sans-arabic-loader-XSH2KYWJ.js} +3 -1
  154. package/dist/{noto-sans-arabic-loader-IA2T4X2A.js.map → noto-sans-arabic-loader-XSH2KYWJ.js.map} +1 -1
  155. package/dist/{noto-sans-jp-loader.generated-HFGLYBR3.js → noto-sans-jp-loader.generated-MR5L6V7K.js} +3 -1
  156. package/dist/{noto-sans-jp-loader.generated-HFGLYBR3.js.map → noto-sans-jp-loader.generated-MR5L6V7K.js.map} +1 -1
  157. package/dist/{platform-activity-row-627BFZ46.js → platform-activity-row-PJJVATTZ.js} +3 -1
  158. package/dist/{platform-activity-row-627BFZ46.js.map → platform-activity-row-PJJVATTZ.js.map} +1 -1
  159. package/dist/{queue-surface-implementation-ZHFI5JBP.js → queue-surface-implementation-67FS7FUI.js} +10 -9
  160. package/dist/{queue-surface-implementation-ZHFI5JBP.js.map → queue-surface-implementation-67FS7FUI.js.map} +1 -1
  161. package/dist/realtime/embedded-voice.d.ts +20 -0
  162. package/dist/realtime.js +22 -1353
  163. package/dist/realtime.js.map +1 -1
  164. package/dist/sandbox-files-34CJJNOY.js +21 -0
  165. package/dist/session-ui.js +32 -30
  166. package/dist/session-ui.js.map +1 -1
  167. package/dist/session.js +10 -9
  168. package/dist/sites.js +2 -1
  169. package/dist/terminal.js +6 -5
  170. package/dist/terminal.js.map +1 -1
  171. package/dist/{timeline-annotation-markers-GNDHTGBD.js → timeline-annotation-markers-U3G66KUD.js} +5 -4
  172. package/dist/{timeline-annotation-markers-GNDHTGBD.js.map → timeline-annotation-markers-U3G66KUD.js.map} +1 -1
  173. package/dist/{timeline-annotation-selection-DMLMM2TX.js → timeline-annotation-selection-BI7QTPTZ.js} +4 -3
  174. package/dist/{timeline-annotation-selection-DMLMM2TX.js.map → timeline-annotation-selection-BI7QTPTZ.js.map} +1 -1
  175. package/dist/{timeline-annotations-dialog-ELRDBHTS.js → timeline-annotations-dialog-FOMHSDTE.js} +7 -6
  176. package/dist/{timeline-annotations-dialog-ELRDBHTS.js.map → timeline-annotations-dialog-FOMHSDTE.js.map} +1 -1
  177. package/dist/usage.js +6 -5
  178. package/dist/usage.js.map +1 -1
  179. package/dist/voice-recording-owner.d.ts +7 -0
  180. package/package.json +3 -3
  181. package/src/components/composer-transcription-control.tsx +109 -27
  182. package/src/components/computer-viewer.tsx +139 -30
  183. package/src/components/markdown.tsx +7 -2
  184. package/src/components/message-timeline.tsx +10 -1
  185. package/src/components/session-conversation.tsx +44 -0
  186. package/src/components/session-list.tsx +1 -1
  187. package/src/components/session-proxy-scope.tsx +26 -5
  188. package/src/composer-voice-events.ts +12 -0
  189. package/src/connection-discovery.tsx +4 -1
  190. package/src/hooks/use-browser-session.ts +445 -168
  191. package/src/hooks/use-client-config-flags.ts +8 -0
  192. package/src/hooks/use-computer-session.ts +334 -98
  193. package/src/hooks/use-goal.ts +12 -1
  194. package/src/hooks/use-realtime-voice-models.ts +67 -0
  195. package/src/hooks/use-voice-input.ts +109 -18
  196. package/src/realtime/embedded-voice.tsx +81 -0
  197. package/src/realtime/realtime-control.tsx +82 -17
  198. package/src/voice-recording-owner.ts +22 -0
  199. package/styles/compiled.css +77 -18
  200. package/styles/index.css +49 -0
  201. package/styles/responsive.css +61 -4
  202. package/styles/session-capability.css +1 -1
  203. package/dist/browser-viewer-SHYKQRNX.js +0 -16
  204. package/dist/chat-interactive-block-UGBTNB3L.js +0 -11
  205. package/dist/chunk-GYVRFZDY.js.map +0 -1
  206. package/dist/chunk-I7IWRQLN.js.map +0 -1
  207. package/dist/chunk-IWIDV7SB.js +0 -1
  208. package/dist/chunk-LJ2UTJJE.js.map +0 -1
  209. package/dist/chunk-LN6TCXD3.js.map +0 -1
  210. package/dist/computer-viewer-6SRGWRUX.js +0 -19
  211. package/dist/model-policy-picker-menu-DXHUL73H.js +0 -14
  212. package/dist/sandbox-files-GORZOUUJ.js +0 -20
  213. /package/dist/{browser-viewer-SHYKQRNX.js.map → browser-viewer-5EEAS3IU.js.map} +0 -0
  214. /package/dist/{chat-interactive-block-UGBTNB3L.js.map → chat-interactive-block-ZFHOKTMS.js.map} +0 -0
  215. /package/dist/{chunk-IWIDV7SB.js.map → chunk-M357MHH3.js.map} +0 -0
  216. /package/dist/{computer-viewer-6SRGWRUX.js.map → computer-viewer-ELNLZGHI.js.map} +0 -0
  217. /package/dist/{model-policy-picker-menu-DXHUL73H.js.map → model-policy-picker-menu-WRNSRFQC.js.map} +0 -0
  218. /package/dist/{sandbox-files-GORZOUUJ.js.map → sandbox-files-34CJJNOY.js.map} +0 -0
@@ -0,0 +1,1420 @@
1
+ "use client";
2
+ import {
3
+ COMPOSER_VOICE_INPUT_START_EVENT,
4
+ composerVoiceEventScope
5
+ } from "./chunk-NX4ADH73.js";
6
+ import {
7
+ BillingClassMark,
8
+ PickerAnimatedPage,
9
+ PickerBackHeader,
10
+ PickerNavRow
11
+ } from "./chunk-L2J3PU7A.js";
12
+ import {
13
+ MENU_CHECK_CLASS,
14
+ MENU_CHEVRON_CLASS,
15
+ MENU_ITEM_CLASS,
16
+ MENU_SEPARATOR_CLASS,
17
+ MENU_SURFACE_CLASS
18
+ } from "./chunk-PMV53IMM.js";
19
+ import {
20
+ usePortalTokenSource,
21
+ usePortalTokenStyle
22
+ } from "./chunk-XEA5BCMA.js";
23
+ import {
24
+ useEmbeddedRealtimeSession
25
+ } from "./chunk-XTD7TZHW.js";
26
+ import {
27
+ cn
28
+ } from "./chunk-TXS65BB2.js";
29
+
30
+ // src/realtime/realtime-control.tsx
31
+ import {
32
+ hasStoredSessionRealtimeOwnerProof,
33
+ projectSessionRealtimeLifecycle
34
+ } from "@opengeni/sdk/realtime";
35
+ import {
36
+ AudioLinesIcon,
37
+ CheckIcon,
38
+ ChevronDownIcon,
39
+ CircleAlertIcon,
40
+ LoaderCircleIcon,
41
+ MicIcon,
42
+ MicOffIcon,
43
+ RotateCcwIcon,
44
+ SquareIcon,
45
+ Volume2Icon,
46
+ VolumeXIcon,
47
+ XIcon
48
+ } from "lucide-react";
49
+ import { AnimatePresence, motion, useReducedMotion } from "motion/react";
50
+ import {
51
+ useCallback,
52
+ useEffect,
53
+ useMemo,
54
+ useRef,
55
+ useState
56
+ } from "react";
57
+
58
+ // src/realtime/dropdown-menu.tsx
59
+ import { ChevronRightIcon } from "lucide-react";
60
+ import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui";
61
+ import { createContext, useContext } from "react";
62
+ import { jsx, jsxs } from "react/jsx-runtime";
63
+ var MENU_MOTION_CLASS = "data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95";
64
+ var DropdownMenuSourceContext = createContext(null);
65
+ function assignRef(ref, value) {
66
+ if (typeof ref === "function") ref(value);
67
+ else if (ref) ref.current = value;
68
+ }
69
+ function DropdownMenu(props) {
70
+ const source = usePortalTokenSource();
71
+ return /* @__PURE__ */ jsx(DropdownMenuSourceContext.Provider, { value: source, children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.Root, { "data-slot": "dropdown-menu", ...props }) });
72
+ }
73
+ function DropdownMenuTrigger({
74
+ ref,
75
+ ...props
76
+ }) {
77
+ const sourceRef = useContext(DropdownMenuSourceContext);
78
+ return /* @__PURE__ */ jsx(
79
+ DropdownMenuPrimitive.Trigger,
80
+ {
81
+ "data-slot": "dropdown-menu-trigger",
82
+ ref: (node) => {
83
+ sourceRef?.ref(node);
84
+ assignRef(ref, node);
85
+ },
86
+ ...props
87
+ }
88
+ );
89
+ }
90
+ function DropdownMenuContent({
91
+ className,
92
+ sideOffset = 4,
93
+ style,
94
+ ...props
95
+ }) {
96
+ const source = useContext(DropdownMenuSourceContext);
97
+ const portalStyle = usePortalTokenStyle(source?.source ?? null);
98
+ return /* @__PURE__ */ jsx(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx(
99
+ DropdownMenuPrimitive.Content,
100
+ {
101
+ "data-slot": "dropdown-menu-content",
102
+ sideOffset,
103
+ className: cn(
104
+ "og-root z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto",
105
+ MENU_SURFACE_CLASS,
106
+ MENU_MOTION_CLASS,
107
+ className
108
+ ),
109
+ style: { ...portalStyle, ...style },
110
+ ...props
111
+ }
112
+ ) });
113
+ }
114
+ function DropdownMenuItem({
115
+ className,
116
+ inset,
117
+ variant = "default",
118
+ ...props
119
+ }) {
120
+ return /* @__PURE__ */ jsx(
121
+ DropdownMenuPrimitive.Item,
122
+ {
123
+ "data-slot": "dropdown-menu-item",
124
+ "data-inset": inset,
125
+ "data-variant": variant,
126
+ className: cn(MENU_ITEM_CLASS, "data-[inset]:pl-9", className),
127
+ ...props
128
+ }
129
+ );
130
+ }
131
+ function DropdownMenuSeparator({
132
+ className,
133
+ ...props
134
+ }) {
135
+ return /* @__PURE__ */ jsx(
136
+ DropdownMenuPrimitive.Separator,
137
+ {
138
+ "data-slot": "dropdown-menu-separator",
139
+ className: cn(MENU_SEPARATOR_CLASS, className),
140
+ ...props
141
+ }
142
+ );
143
+ }
144
+ function DropdownMenuSub(props) {
145
+ return /* @__PURE__ */ jsx(DropdownMenuPrimitive.Sub, { "data-slot": "dropdown-menu-sub", ...props });
146
+ }
147
+ function DropdownMenuSubTrigger({
148
+ className,
149
+ inset,
150
+ children,
151
+ ...props
152
+ }) {
153
+ return /* @__PURE__ */ jsxs(
154
+ DropdownMenuPrimitive.SubTrigger,
155
+ {
156
+ "data-slot": "dropdown-menu-sub-trigger",
157
+ "data-inset": inset,
158
+ className: cn(MENU_ITEM_CLASS, "data-[inset]:pl-9", className),
159
+ ...props,
160
+ children: [
161
+ children,
162
+ /* @__PURE__ */ jsx(ChevronRightIcon, { "aria-hidden": "true", className: cn(MENU_CHEVRON_CLASS, "ml-auto") })
163
+ ]
164
+ }
165
+ );
166
+ }
167
+ function DropdownMenuSubContent({
168
+ className,
169
+ style,
170
+ ...props
171
+ }) {
172
+ const source = useContext(DropdownMenuSourceContext);
173
+ const portalStyle = usePortalTokenStyle(source?.source ?? null);
174
+ return /* @__PURE__ */ jsx(
175
+ DropdownMenuPrimitive.SubContent,
176
+ {
177
+ "data-slot": "dropdown-menu-sub-content",
178
+ className: cn(
179
+ "og-root z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden",
180
+ MENU_SURFACE_CLASS,
181
+ MENU_MOTION_CLASS,
182
+ className
183
+ ),
184
+ style: { ...portalStyle, ...style },
185
+ ...props
186
+ }
187
+ );
188
+ }
189
+
190
+ // src/realtime/realtime-control.tsx
191
+ import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
192
+ function realtimeRefusalLabel(code) {
193
+ switch (code) {
194
+ case "insufficient_credits":
195
+ return "Credits needed";
196
+ case "allowance_exhausted":
197
+ case "monthly_model_cost_limit":
198
+ return "Usage limit reached";
199
+ case "realtime_voice_unavailable":
200
+ return "Voice unavailable";
201
+ default:
202
+ return null;
203
+ }
204
+ }
205
+ var CODEX_LIVE_MODEL = {
206
+ id: "gpt-live-1-boulder-alpha",
207
+ label: "Codex Live",
208
+ provider: "Connected Codex",
209
+ description: "Deep session integration",
210
+ available: false,
211
+ unavailableReason: "Connect Codex to use this voice model",
212
+ recommended: false
213
+ };
214
+ var REALTIME_MODEL_PROVIDERS = [
215
+ "OpenGeni",
216
+ "Connected Codex",
217
+ "Connected SuperGrok",
218
+ "Your Gateway"
219
+ ];
220
+ var REALTIME_PROVIDER_META = {
221
+ // The wire value keeps its historical spelling; the product name is Opengeni.
222
+ OpenGeni: { billingClass: "opengeni_credits", label: "Opengeni", hint: "Uses Opengeni credits" },
223
+ "Connected Codex": {
224
+ billingClass: "codex_subscription",
225
+ label: "Connected Codex",
226
+ hint: "ChatGPT / Codex plan"
227
+ },
228
+ "Connected SuperGrok": {
229
+ billingClass: "supergrok_subscription",
230
+ label: "Connected SuperGrok",
231
+ hint: "SuperGrok / xAI plan"
232
+ },
233
+ "Your Gateway": {
234
+ billingClass: "byok",
235
+ label: "Your Gateway",
236
+ hint: "Billed to your AI Gateway"
237
+ }
238
+ };
239
+ function realtimeProviderLabel(provider) {
240
+ return provider === "OpenGeni" ? "Opengeni" : provider;
241
+ }
242
+ var REALTIME_MODEL_STORAGE_PREFIX = "opengeni:realtime-model";
243
+ var REALTIME_MODEL_CATALOG_CACHE_TTL_MS = 6e4;
244
+ var REALTIME_MODEL_CATALOG_CACHE_MAX_WORKSPACES = 64;
245
+ var realtimeModelCatalogCache = /* @__PURE__ */ new WeakMap();
246
+ function realtimeModelFallback(codexConnected) {
247
+ return [
248
+ {
249
+ ...CODEX_LIVE_MODEL,
250
+ available: codexConnected,
251
+ unavailableReason: codexConnected ? null : CODEX_LIVE_MODEL.unavailableReason
252
+ }
253
+ ];
254
+ }
255
+ function realtimeModelCatalogCacheFor(client) {
256
+ const existing = realtimeModelCatalogCache.get(client);
257
+ if (existing) return existing;
258
+ const created = /* @__PURE__ */ new Map();
259
+ realtimeModelCatalogCache.set(client, created);
260
+ return created;
261
+ }
262
+ function readCachedRealtimeModelCatalog(client, workspaceId, now = Date.now()) {
263
+ const cache = realtimeModelCatalogCache.get(client);
264
+ const entry = cache?.get(workspaceId);
265
+ if (!entry || entry.state === "loading") return null;
266
+ if (entry.expiresAt > now) return entry.models;
267
+ cache?.delete(workspaceId);
268
+ return null;
269
+ }
270
+ function pruneRealtimeModelCatalogCache(cache, now) {
271
+ for (const [workspaceId, entry] of cache) {
272
+ if (entry.state === "ready" && entry.expiresAt <= now) cache.delete(workspaceId);
273
+ }
274
+ while (cache.size >= REALTIME_MODEL_CATALOG_CACHE_MAX_WORKSPACES) {
275
+ const oldestWorkspaceId = cache.keys().next().value;
276
+ if (oldestWorkspaceId === void 0) return;
277
+ cache.delete(oldestWorkspaceId);
278
+ }
279
+ }
280
+ function loadRealtimeModelCatalog(client, workspaceId, signal) {
281
+ const load = client.getWorkspaceRealtimeModelCatalog;
282
+ if (!load) return null;
283
+ if (signal?.aborted) {
284
+ return Promise.reject(signal.reason ?? new DOMException("Request aborted", "AbortError"));
285
+ }
286
+ const now = Date.now();
287
+ const cache = realtimeModelCatalogCacheFor(client);
288
+ const entry = cache.get(workspaceId);
289
+ if (entry?.state === "loading" && !entry.controller.signal.aborted) {
290
+ return consumeRealtimeModelCatalog(entry, signal);
291
+ }
292
+ if (entry?.state === "ready" && entry.expiresAt > now) return Promise.resolve(entry.models);
293
+ if (entry) cache.delete(workspaceId);
294
+ pruneRealtimeModelCatalogCache(cache, now);
295
+ const controller = new AbortController();
296
+ const promise = load.call(client, workspaceId, { signal: controller.signal }).then((response) => response.models.map(toRealtimeModelOption)).then((models) => {
297
+ const current = cache.get(workspaceId);
298
+ if (current?.state === "loading" && current.promise === promise) {
299
+ cache.delete(workspaceId);
300
+ cache.set(workspaceId, {
301
+ state: "ready",
302
+ models,
303
+ expiresAt: Date.now() + REALTIME_MODEL_CATALOG_CACHE_TTL_MS
304
+ });
305
+ }
306
+ return models;
307
+ }).catch((error) => {
308
+ const current = cache.get(workspaceId);
309
+ if (current?.state === "loading" && current.promise === promise) cache.delete(workspaceId);
310
+ throw error;
311
+ });
312
+ const loading = {
313
+ state: "loading",
314
+ promise,
315
+ controller,
316
+ consumers: 0
317
+ };
318
+ cache.set(workspaceId, loading);
319
+ return consumeRealtimeModelCatalog(loading, signal);
320
+ }
321
+ function consumeRealtimeModelCatalog(entry, signal) {
322
+ entry.consumers += 1;
323
+ return new Promise((resolve, reject) => {
324
+ let released = false;
325
+ const release = (abandoned) => {
326
+ if (released) return;
327
+ released = true;
328
+ entry.consumers = Math.max(0, entry.consumers - 1);
329
+ if (abandoned && entry.consumers === 0) {
330
+ entry.controller.abort(
331
+ signal?.reason ?? new DOMException("Request abandoned", "AbortError")
332
+ );
333
+ }
334
+ };
335
+ const onAbort = () => {
336
+ release(true);
337
+ reject(signal?.reason ?? new DOMException("Request aborted", "AbortError"));
338
+ };
339
+ signal?.addEventListener("abort", onAbort, { once: true });
340
+ void entry.promise.then(resolve, reject).finally(() => {
341
+ signal?.removeEventListener("abort", onAbort);
342
+ release(false);
343
+ });
344
+ });
345
+ }
346
+ function codexRealtimeAdmissionAllowed(input) {
347
+ return codexRealtimeAdmissionBlocker(input) === null;
348
+ }
349
+ function codexRealtimeAdmissionBlocker(input) {
350
+ if (input.sessionStatus === "cancelled") return "This session was cancelled.";
351
+ if (input.controlState !== "active") return "Resume this session before starting voice.";
352
+ if (input.settlement !== null) return "Wait for the current session transition to finish.";
353
+ if (!input.codexConnected) return "Connect Codex to use this voice model.";
354
+ if (input.lifecycleActive) return "Voice is already active for this session.";
355
+ return null;
356
+ }
357
+ function useSessionRealtime(options) {
358
+ const { client, workspaceId } = useEmbeddedRealtimeSession({
359
+ client: options.client,
360
+ workspaceId: options.workspaceId
361
+ });
362
+ const model = options.model ?? CODEX_LIVE_MODEL.id;
363
+ const audioRef = useRef(null);
364
+ const controllerRef = useRef(null);
365
+ const controllerModelRef = useRef(null);
366
+ const modelContextProviderRef = useRef(options.getModelContext);
367
+ modelContextProviderRef.current = options.getModelContext;
368
+ const [snapshot, setSnapshot] = useState(() => ({
369
+ status: hasStoredSessionRealtimeOwnerProof({
370
+ workspaceId,
371
+ sessionId: options.sessionId,
372
+ model
373
+ }) ? "recovering" : "idle",
374
+ realtimeId: null,
375
+ mode: null,
376
+ bridge: null,
377
+ microphone: "inactive",
378
+ inputMuted: false,
379
+ audibleOutput: "inactive",
380
+ outputMuted: false,
381
+ connectionGeneration: 0,
382
+ reconnectAttempt: 0,
383
+ diagnostic: null,
384
+ error: null
385
+ }));
386
+ const lifecycle = useMemo(
387
+ () => projectSessionRealtimeLifecycle(options.events),
388
+ [options.events]
389
+ );
390
+ const lifecycleRef = useRef(lifecycle);
391
+ const eventsReadyRef = useRef(options.eventsReady);
392
+ lifecycleRef.current = lifecycle;
393
+ eventsReadyRef.current = options.eventsReady;
394
+ const lifecycleActive = sessionRealtimeLifecycleIsActive(lifecycle);
395
+ useEffect(() => {
396
+ let disposed = false;
397
+ let controller = null;
398
+ let unsubscribe = null;
399
+ void import("@opengeni/sdk/realtime").then(({ createSessionRealtimeController }) => {
400
+ if (disposed) return;
401
+ const controllerFactory = options.controllerFactory ?? createSessionRealtimeController;
402
+ controller = controllerFactory({
403
+ client,
404
+ workspaceId,
405
+ sessionId: options.sessionId,
406
+ ...audioRef.current ? { remoteAudio: audioRef.current } : {},
407
+ model,
408
+ getModelContext: () => modelContextProviderRef.current?.()
409
+ });
410
+ controllerRef.current = controller;
411
+ controllerModelRef.current = model;
412
+ unsubscribe = controller.subscribe(setSnapshot);
413
+ if (eventsReadyRef.current) {
414
+ void controller.observeLifecycle(lifecycleRef.current).catch(() => void 0);
415
+ }
416
+ }).catch((error) => {
417
+ if (disposed) return;
418
+ setSnapshot({
419
+ status: "error",
420
+ realtimeId: null,
421
+ mode: null,
422
+ bridge: null,
423
+ microphone: "inactive",
424
+ inputMuted: false,
425
+ audibleOutput: "inactive",
426
+ outputMuted: false,
427
+ connectionGeneration: 0,
428
+ reconnectAttempt: 0,
429
+ diagnostic: {
430
+ kind: "negotiation_failure",
431
+ message: error instanceof Error ? error.message : "Codex realtime controller failed to load",
432
+ recoverable: false,
433
+ connectionGeneration: 0,
434
+ attempt: 0
435
+ },
436
+ error: error instanceof Error ? error.message : "Codex realtime controller failed to load"
437
+ });
438
+ });
439
+ return () => {
440
+ disposed = true;
441
+ unsubscribe?.();
442
+ controller?.close();
443
+ if (controllerRef.current === controller) {
444
+ controllerRef.current = null;
445
+ controllerModelRef.current = null;
446
+ }
447
+ };
448
+ }, [client, model, options.controllerFactory, options.sessionId, workspaceId]);
449
+ useEffect(() => {
450
+ if (!options.eventsReady) return;
451
+ void controllerRef.current?.observeLifecycle(lifecycle).catch(() => void 0);
452
+ }, [lifecycle, options.eventsReady]);
453
+ const start = useCallback(async () => {
454
+ const controller = controllerRef.current;
455
+ if (!controller || controllerModelRef.current !== model) {
456
+ throw new Error("The selected voice model is still preparing");
457
+ }
458
+ await controller.start();
459
+ }, [model]);
460
+ const stop = useCallback(async () => {
461
+ await controllerRef.current?.stop();
462
+ }, []);
463
+ const retry = useCallback(async () => {
464
+ await controllerRef.current?.retry();
465
+ }, []);
466
+ const retryAudibleOutput = useCallback(async () => {
467
+ await controllerRef.current?.retryAudibleOutput();
468
+ }, []);
469
+ const setInputMuted = useCallback((muted) => {
470
+ controllerRef.current?.setInputMuted(muted);
471
+ }, []);
472
+ const setOutputMuted = useCallback((muted) => {
473
+ controllerRef.current?.setOutputMuted(muted);
474
+ }, []);
475
+ const admissionInput = {
476
+ sessionStatus: options.sessionStatus,
477
+ controlState: options.effectiveControl.state,
478
+ settlement: options.effectiveControl.settlement,
479
+ codexConnected: options.modelAvailable ?? options.codexConnected,
480
+ lifecycleActive
481
+ };
482
+ const admissionBlocker = options.modelAvailable === false ? options.modelUnavailableReason ?? "This voice model is unavailable." : codexRealtimeAdmissionBlocker(admissionInput);
483
+ const canStart = controllerRef.current !== null && controllerModelRef.current === model && ["idle", "error"].includes(snapshot.status) && admissionBlocker === null;
484
+ return {
485
+ snapshot,
486
+ lifecycleActive,
487
+ canStart,
488
+ admissionBlocker,
489
+ codexConnected: options.codexConnected,
490
+ audioRef,
491
+ start,
492
+ stop,
493
+ retry,
494
+ retryAudibleOutput,
495
+ setInputMuted,
496
+ setOutputMuted
497
+ };
498
+ }
499
+ function sessionRealtimeLifecycleIsActive(lifecycle) {
500
+ if (lifecycle?.state !== "active") return false;
501
+ const leaseExpiresAt = Date.parse(lifecycle.leaseExpiresAt);
502
+ return !Number.isFinite(leaseExpiresAt) || leaseExpiresAt > Date.now();
503
+ }
504
+ function SessionRealtimeControl(props) {
505
+ const lifecycle = useMemo(() => projectSessionRealtimeLifecycle(props.events), [props.events]);
506
+ const lifecycleActive = sessionRealtimeLifecycleIsActive(lifecycle);
507
+ const selection = useRealtimeModelSelection({
508
+ client: props.client,
509
+ workspaceId: props.workspaceId,
510
+ codexConnected: props.codexConnected,
511
+ activeModel: lifecycleActive && lifecycle?.state === "active" ? lifecycle.model : null
512
+ });
513
+ const selectedModel = selection.selectedModel;
514
+ const realtime = useSessionRealtime({
515
+ ...props,
516
+ model: selectedModel.id,
517
+ modelAvailable: selectedModel.available,
518
+ modelUnavailableReason: selectedModel.unavailableReason
519
+ });
520
+ const autostartModelRef = useRef(props.realtimeAutostartModel ?? null);
521
+ const autostartStartedRef = useRef(false);
522
+ const { models, selectedModel: selectedRealtimeModel, selectModel } = selection;
523
+ const { canStart, start } = realtime;
524
+ const onRealtimeAutostartConsumed = props.onRealtimeAutostartConsumed;
525
+ const onVoiceActiveChange = props.onVoiceActiveChange;
526
+ const voiceActive = realtime.snapshot.mode?.state === "active";
527
+ useEffect(() => {
528
+ onVoiceActiveChange?.(voiceActive);
529
+ }, [onVoiceActiveChange, voiceActive]);
530
+ useEffect(() => {
531
+ const pending = autostartModelRef.current;
532
+ if (!pending || autostartStartedRef.current || lifecycleActive) return;
533
+ const available = models.some((model) => model.id === pending && model.available);
534
+ if (!available) return;
535
+ if (selectedRealtimeModel.id !== pending) {
536
+ selectModel(pending);
537
+ return;
538
+ }
539
+ if (!canStart) return;
540
+ autostartStartedRef.current = true;
541
+ const consume = () => {
542
+ autostartModelRef.current = null;
543
+ onRealtimeAutostartConsumed?.();
544
+ };
545
+ void start().then(consume, consume);
546
+ }, [
547
+ canStart,
548
+ lifecycleActive,
549
+ models,
550
+ props.sessionId,
551
+ props.workspaceId,
552
+ onRealtimeAutostartConsumed,
553
+ selectModel,
554
+ selectedRealtimeModel.id,
555
+ start
556
+ ]);
557
+ return /* @__PURE__ */ jsx2(
558
+ RealtimeVoiceControl,
559
+ {
560
+ snapshot: realtime.snapshot,
561
+ canStart: realtime.canStart,
562
+ admissionBlocker: realtime.admissionBlocker,
563
+ modelAvailable: selectedModel.available,
564
+ menuSide: "top",
565
+ modelMenu: props.modelMenu ?? "split",
566
+ showDiagnostics: props.showDiagnostics,
567
+ audioRef: realtime.audioRef,
568
+ selectedModel,
569
+ models: selection.models,
570
+ onSelectModel: realtime.lifecycleActive ? void 0 : selection.selectModel,
571
+ onStart: realtime.start,
572
+ onStop: realtime.stop,
573
+ onRetry: realtime.retry,
574
+ onRetryAudibleOutput: realtime.retryAudibleOutput,
575
+ onSetInputMuted: realtime.setInputMuted,
576
+ onSetOutputMuted: realtime.setOutputMuted
577
+ }
578
+ );
579
+ }
580
+ function fallbackRealtimeModelId(models) {
581
+ return models.find((model) => model.available)?.id ?? models.find((model) => model.unavailableCode)?.id ?? CODEX_LIVE_MODEL.id;
582
+ }
583
+ function useRealtimeModelSelection(options) {
584
+ const { client, workspaceId } = useEmbeddedRealtimeSession({
585
+ client: options.client,
586
+ workspaceId: options.workspaceId
587
+ });
588
+ const activeModel = options.activeModel;
589
+ const initialCachedCatalog = readCachedRealtimeModelCatalog(client, workspaceId);
590
+ const [catalog, setCatalog] = useState(
591
+ () => initialCachedCatalog ?? realtimeModelFallback(options.codexConnected)
592
+ );
593
+ const catalogScopeRef = useRef({
594
+ client,
595
+ workspaceId,
596
+ source: initialCachedCatalog ? "cache" : "fallback"
597
+ });
598
+ const [selectedModelId, setSelectedModelId] = useState(() => {
599
+ const preferred = readRealtimeModelPreference(workspaceId) ?? CODEX_LIVE_MODEL.id;
600
+ if (!initialCachedCatalog) return preferred;
601
+ if (initialCachedCatalog.some((model) => model.id === preferred && model.available)) {
602
+ return preferred;
603
+ }
604
+ return fallbackRealtimeModelId(initialCachedCatalog);
605
+ });
606
+ useEffect(() => {
607
+ let disposed = false;
608
+ const requestAbort = new AbortController();
609
+ const applyCatalog = (models) => {
610
+ catalogScopeRef.current = { client, workspaceId, source: "cache" };
611
+ setCatalog(models);
612
+ setSelectedModelId((current) => {
613
+ if (models.some((model) => model.id === current && model.available)) return current;
614
+ return fallbackRealtimeModelId(models);
615
+ });
616
+ };
617
+ const cached = readCachedRealtimeModelCatalog(client, workspaceId);
618
+ if (cached) {
619
+ const scope = catalogScopeRef.current;
620
+ if (scope.client !== client || scope.workspaceId !== workspaceId || scope.source !== "cache") {
621
+ applyCatalog(cached);
622
+ }
623
+ return;
624
+ }
625
+ const loading = loadRealtimeModelCatalog(client, workspaceId, requestAbort.signal);
626
+ if (!loading) return;
627
+ void loading.then((models) => {
628
+ if (disposed) return;
629
+ applyCatalog(models);
630
+ }).catch(() => void 0);
631
+ return () => {
632
+ disposed = true;
633
+ requestAbort.abort();
634
+ };
635
+ }, [client, workspaceId]);
636
+ useEffect(() => {
637
+ if (activeModel) setSelectedModelId(activeModel);
638
+ }, [activeModel]);
639
+ const selectedModel = catalog.find((model) => model.id === selectedModelId) ?? {
640
+ ...CODEX_LIVE_MODEL,
641
+ available: options.codexConnected,
642
+ unavailableReason: options.codexConnected ? null : CODEX_LIVE_MODEL.unavailableReason
643
+ };
644
+ const selectModel = useCallback(
645
+ (value) => {
646
+ const model = catalog.find((candidate) => candidate.id === value);
647
+ if (!model || !model.available || activeModel) return;
648
+ setSelectedModelId(model.id);
649
+ writeRealtimeModelPreference(workspaceId, model.id);
650
+ },
651
+ [activeModel, catalog, workspaceId]
652
+ );
653
+ return { models: catalog, selectedModel, selectModel };
654
+ }
655
+ var IDLE_REALTIME_SNAPSHOT = {
656
+ status: "idle",
657
+ realtimeId: null,
658
+ mode: null,
659
+ bridge: null,
660
+ microphone: "inactive",
661
+ inputMuted: false,
662
+ audibleOutput: "inactive",
663
+ outputMuted: false,
664
+ connectionGeneration: 0,
665
+ reconnectAttempt: 0,
666
+ diagnostic: null,
667
+ error: null
668
+ };
669
+ function NewSessionRealtimeControl(props) {
670
+ if (props.models && props.selectedModel && props.onSelectModel) {
671
+ return /* @__PURE__ */ jsx2(
672
+ NewSessionRealtimeControlView,
673
+ {
674
+ ...props,
675
+ selection: {
676
+ models: props.models,
677
+ selectedModel: props.selectedModel,
678
+ selectModel: props.onSelectModel
679
+ }
680
+ }
681
+ );
682
+ }
683
+ return /* @__PURE__ */ jsx2(NewSessionRealtimeControlWithInternalSelection, { ...props });
684
+ }
685
+ function NewSessionRealtimeControlWithInternalSelection(props) {
686
+ const selection = useRealtimeModelSelection({
687
+ client: props.client,
688
+ workspaceId: props.workspaceId,
689
+ codexConnected: props.codexConnected
690
+ });
691
+ return /* @__PURE__ */ jsx2(NewSessionRealtimeControlView, { ...props, selection });
692
+ }
693
+ function NewSessionRealtimeControlView(props) {
694
+ const selection = props.selection;
695
+ const audioRef = useRef(null);
696
+ const [starting, setStarting] = useState(false);
697
+ const [error, setError] = useState(null);
698
+ const snapshot = useMemo(
699
+ () => starting ? { ...IDLE_REALTIME_SNAPSHOT, status: "starting" } : error ? { ...IDLE_REALTIME_SNAPSHOT, status: "error", error } : IDLE_REALTIME_SNAPSHOT,
700
+ [error, starting]
701
+ );
702
+ const canStart = selection.selectedModel.available && props.disabled !== true && !starting;
703
+ const onStart = props.onStart;
704
+ const selectedModelId = selection.selectedModel.id;
705
+ const start = useCallback(async () => {
706
+ if (!canStart) return;
707
+ setStarting(true);
708
+ setError(null);
709
+ try {
710
+ const started = await onStart(selectedModelId);
711
+ if (!started) setError("The voice session could not be created.");
712
+ } catch (cause) {
713
+ setError(cause instanceof Error ? cause.message : String(cause));
714
+ } finally {
715
+ setStarting(false);
716
+ }
717
+ }, [canStart, onStart, selectedModelId]);
718
+ return /* @__PURE__ */ jsx2(
719
+ RealtimeVoiceControl,
720
+ {
721
+ snapshot,
722
+ canStart,
723
+ admissionBlocker: selection.selectedModel.unavailableReason ?? props.disabledReason ?? null,
724
+ modelAvailable: selection.selectedModel.available,
725
+ selectionDisabled: starting,
726
+ menuSide: "bottom",
727
+ modelMenu: props.modelMenu ?? "split",
728
+ showDiagnostics: false,
729
+ audioRef,
730
+ selectedModel: selection.selectedModel,
731
+ models: selection.models,
732
+ onSelectModel: selection.selectModel,
733
+ onStart: start,
734
+ onStop: async () => void 0,
735
+ onRetry: start,
736
+ onRetryAudibleOutput: async () => void 0,
737
+ onSetInputMuted: () => void 0,
738
+ onSetOutputMuted: () => void 0
739
+ }
740
+ );
741
+ }
742
+ function RealtimeVoiceControl(props) {
743
+ const reduceMotion = useReducedMotion();
744
+ const selectedModel = props.selectedModel ?? {
745
+ ...CODEX_LIVE_MODEL,
746
+ available: props.modelAvailable,
747
+ unavailableReason: props.modelAvailable ? null : CODEX_LIVE_MODEL.unavailableReason
748
+ };
749
+ const models = props.models ?? [selectedModel];
750
+ const status = statusContent(
751
+ props.snapshot,
752
+ props.modelAvailable,
753
+ props.canStart,
754
+ props.admissionBlocker ?? null,
755
+ selectedModel.label,
756
+ selectedModel.unavailableCode ?? null
757
+ );
758
+ const modeOwned = props.snapshot.mode?.state === "active";
759
+ const retryConnection = modeOwned && props.snapshot.status !== "stopping" && props.snapshot.status !== "active" && props.snapshot.diagnostic?.recoverable === true;
760
+ const audioBlocked = props.snapshot.audibleOutput === "blocked" && !props.snapshot.outputMuted;
761
+ const startFailed = props.snapshot.status === "error" && !modeOwned;
762
+ const failureText = status.label === "Voice unavailable" ? status.detail : `${status.label}. ${status.detail}`;
763
+ const mainDisabled = props.snapshot.status === "stopping" || props.snapshot.status === "lost_owner" || !modeOwned && !props.canStart || props.snapshot.status === "starting" && !modeOwned;
764
+ const mainLabel = audioBlocked ? "Resume voice audio" : retryConnection ? "Retry voice connection" : modeOwned ? "End voice conversation" : !props.canStart && status.phase === "unavailable" ? `${status.label}: ${status.detail}` : startFailed ? `Try voice again with ${selectedModel.label}` : `Start voice with ${selectedModel.label}`;
765
+ const runMainAction = audioBlocked ? props.onRetryAudibleOutput : retryConnection ? props.onRetry : modeOwned ? props.onStop : props.onStart;
766
+ const diagnosticsVisible = props.showDiagnostics ?? false;
767
+ const modelMenu = props.modelMenu ?? "split";
768
+ const showAttachedModelMenu = modelMenu === "split" || modelMenu === "split-desktop";
769
+ const desktopOnlyModelMenu = modelMenu === "split-desktop";
770
+ const [pickerOpen, setPickerOpen] = useState(false);
771
+ const [pickerProvider, setPickerProvider] = useState(
772
+ selectedModel.provider
773
+ );
774
+ const [pickerDirection, setPickerDirection] = useState(1);
775
+ const [failureDismissed, setFailureDismissed] = useState(false);
776
+ useEffect(() => {
777
+ if (!startFailed) setFailureDismissed(false);
778
+ }, [startFailed]);
779
+ const rootRef = useRef(null);
780
+ useEffect(() => {
781
+ if (!startFailed) return;
782
+ const scope = composerVoiceEventScope(rootRef.current);
783
+ if (!scope) return;
784
+ const dismiss = () => setFailureDismissed(true);
785
+ scope.addEventListener(COMPOSER_VOICE_INPUT_START_EVENT, dismiss);
786
+ return () => scope.removeEventListener(COMPOSER_VOICE_INPUT_START_EVENT, dismiss);
787
+ }, [startFailed]);
788
+ useEffect(() => {
789
+ if (!pickerOpen) setPickerProvider(selectedModel.provider);
790
+ }, [pickerOpen, selectedModel.provider]);
791
+ return /* @__PURE__ */ jsxs2(
792
+ "div",
793
+ {
794
+ ref: rootRef,
795
+ role: "group",
796
+ "aria-label": "Realtime voice",
797
+ "data-picker-side": props.menuSide ?? "top",
798
+ "data-model-menu": modelMenu,
799
+ className: "og-realtime-control inline-flex shrink-0 items-center",
800
+ children: [
801
+ /* @__PURE__ */ jsx2("audio", { ref: props.audioRef, autoPlay: true, className: "hidden", "aria-hidden": "true" }),
802
+ /* @__PURE__ */ jsx2(RealtimeComposerGlow, { phase: status.phase, reduceMotion: reduceMotion === true }),
803
+ /* @__PURE__ */ jsx2(AnimatePresence, { initial: false, children: modeOwned ? /* @__PURE__ */ jsx2(
804
+ motion.div,
805
+ {
806
+ "data-testid": "realtime-mute-controls",
807
+ initial: reduceMotion ? false : { opacity: 0, width: 0 },
808
+ animate: {
809
+ opacity: 1,
810
+ width: "auto",
811
+ transition: reduceMotion ? { duration: 0 } : { delay: 0.3, duration: 0.48, ease: [0.22, 1, 0.36, 1] }
812
+ },
813
+ ...reduceMotion ? {} : {
814
+ exit: {
815
+ opacity: 0,
816
+ width: 0,
817
+ transition: { duration: 0.28, ease: [0.4, 0, 1, 1] }
818
+ }
819
+ },
820
+ className: cn(
821
+ "inline-flex shrink-0 items-center overflow-hidden",
822
+ props.muteControlsClassName
823
+ ),
824
+ children: /* @__PURE__ */ jsxs2(
825
+ motion.div,
826
+ {
827
+ className: "inline-flex items-center gap-0.5 pr-1",
828
+ initial: reduceMotion ? false : { x: 18, opacity: 0 },
829
+ animate: {
830
+ x: 0,
831
+ opacity: 1,
832
+ transition: reduceMotion ? { duration: 0 } : {
833
+ delay: 0.32,
834
+ type: "spring",
835
+ stiffness: 320,
836
+ damping: 30,
837
+ mass: 0.8
838
+ }
839
+ },
840
+ ...reduceMotion ? {} : {
841
+ exit: {
842
+ x: 14,
843
+ opacity: 0,
844
+ transition: { duration: 0.22, ease: [0.4, 0, 1, 1] }
845
+ }
846
+ },
847
+ children: [
848
+ /* @__PURE__ */ jsx2(
849
+ RealtimeMuteButton,
850
+ {
851
+ muted: props.snapshot.inputMuted,
852
+ kind: "microphone",
853
+ reduceMotion: reduceMotion === true,
854
+ enterDelay: reduceMotion ? 0 : 0.34,
855
+ onToggle: () => props.onSetInputMuted(!props.snapshot.inputMuted)
856
+ }
857
+ ),
858
+ /* @__PURE__ */ jsx2(
859
+ RealtimeMuteButton,
860
+ {
861
+ muted: props.snapshot.outputMuted,
862
+ kind: "output",
863
+ reduceMotion: reduceMotion === true,
864
+ enterDelay: reduceMotion ? 0 : 0.4,
865
+ onToggle: () => props.onSetOutputMuted(!props.snapshot.outputMuted)
866
+ }
867
+ )
868
+ ]
869
+ }
870
+ )
871
+ },
872
+ "realtime-mute-controls"
873
+ ) : null }),
874
+ startFailed && !failureDismissed ? /* @__PURE__ */ jsxs2(
875
+ "button",
876
+ {
877
+ type: "button",
878
+ "data-realtime-attention": "",
879
+ "data-testid": "realtime-failure-reason",
880
+ title: "Dismiss",
881
+ "aria-label": `Dismiss: ${failureText}`,
882
+ onClick: () => setFailureDismissed(true),
883
+ className: "og-realtime-failure mr-1.5 inline-flex min-w-0 items-center gap-1 rounded-og-sm text-right text-og-xs leading-tight text-og-status-failed outline-hidden focus-visible:ring-2 focus-visible:ring-og-accent/45",
884
+ children: [
885
+ /* @__PURE__ */ jsx2("span", { className: "og-realtime-failure-label line-clamp-2 max-w-56", children: failureText }),
886
+ /* @__PURE__ */ jsx2(XIcon, { className: "size-3 shrink-0 opacity-70", "aria-hidden": true })
887
+ ]
888
+ }
889
+ ) : null,
890
+ /* @__PURE__ */ jsxs2("div", { className: "inline-flex shrink-0 items-center", children: [
891
+ /* @__PURE__ */ jsx2(
892
+ motion.button,
893
+ {
894
+ type: "button",
895
+ "data-testid": "realtime-primary-action",
896
+ "data-phase": status.phase,
897
+ "aria-label": mainLabel,
898
+ "aria-pressed": modeOwned,
899
+ title: mainLabel,
900
+ disabled: mainDisabled,
901
+ ...reduceMotion ? {} : { whileTap: { scale: 0.92 } },
902
+ transition: { type: "spring", stiffness: 520, damping: 30 },
903
+ onClick: () => void runMainAction().catch(() => void 0),
904
+ className: cn(
905
+ // Match transcription mic: ghost icon when idle; filled only when live.
906
+ // Public contract: coarse pointers keep a 44px target; split menu uses
907
+ // left-only rounding at `sm+` where the chevron attaches.
908
+ "og-realtime-primary relative inline-flex size-8 items-center justify-center outline-hidden",
909
+ "rounded-og-md transition-[background-color,border-color,color,box-shadow] duration-200 ease-og-out",
910
+ "focus-visible:z-10 focus-visible:ring-2 focus-visible:ring-og-accent/45",
911
+ "disabled:cursor-not-allowed disabled:opacity-45 pointer-coarse:size-11",
912
+ showAttachedModelMenu && (desktopOnlyModelMenu ? "sm:rounded-l-og-md sm:rounded-r-none" : "rounded-l-og-md rounded-r-none"),
913
+ voiceButtonTone(status.phase)
914
+ ),
915
+ children: /* @__PURE__ */ jsx2(
916
+ RealtimeActionGlyph,
917
+ {
918
+ phase: status.phase,
919
+ audioBlocked,
920
+ reduceMotion: reduceMotion === true
921
+ }
922
+ )
923
+ }
924
+ ),
925
+ showAttachedModelMenu ? /* @__PURE__ */ jsxs2(DropdownMenu, { open: pickerOpen, onOpenChange: setPickerOpen, children: [
926
+ /* @__PURE__ */ jsx2(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx2(
927
+ "button",
928
+ {
929
+ type: "button",
930
+ "aria-label": "Choose voice model and options",
931
+ title: `Voice model: ${selectedModel.label}`,
932
+ disabled: props.selectionDisabled,
933
+ className: cn(
934
+ // Keep the split trigger compact on desktop while preserving a
935
+ // full 44px mobile target independent of pointer-media support.
936
+ "og-realtime-model-trigger inline-flex h-11 w-11 items-center justify-center rounded-r-og-md outline-hidden sm:h-8 sm:w-6",
937
+ "transition-[background-color,border-color,color] duration-200 ease-og-out",
938
+ "focus-visible:z-10 focus-visible:ring-2 focus-visible:ring-og-accent/45",
939
+ desktopOnlyModelMenu && "hidden sm:inline-flex",
940
+ voiceChevronTone(status.phase)
941
+ ),
942
+ children: /* @__PURE__ */ jsx2(ChevronDownIcon, { className: "size-3", "aria-hidden": true })
943
+ }
944
+ ) }),
945
+ /* @__PURE__ */ jsxs2(
946
+ DropdownMenuContent,
947
+ {
948
+ side: props.menuSide ?? "top",
949
+ align: "end",
950
+ sideOffset: 8,
951
+ collisionPadding: 12,
952
+ className: "og-realtime-menu flex w-72 max-h-[min(20rem,var(--radix-dropdown-menu-content-available-height))] flex-col overflow-hidden",
953
+ onCloseAutoFocus: (event) => event.preventDefault(),
954
+ children: [
955
+ /* @__PURE__ */ jsx2("div", { className: "min-h-0 flex-1 overflow-y-auto overscroll-contain", children: /* @__PURE__ */ jsx2(
956
+ RealtimeModelPickerMenu,
957
+ {
958
+ models,
959
+ selectedModel,
960
+ provider: pickerProvider,
961
+ direction: pickerDirection,
962
+ disabled: props.selectionDisabled === true || props.snapshot.mode?.state === "active",
963
+ onProviderChange: (provider, direction) => {
964
+ setPickerDirection(direction);
965
+ setPickerProvider(provider);
966
+ },
967
+ onSelect: (modelId) => {
968
+ props.onSelectModel?.(modelId);
969
+ setPickerOpen(false);
970
+ }
971
+ }
972
+ ) }),
973
+ status.phase !== "idle" && // Say it once: the selected model's row already carries its reason.
974
+ !(status.phase === "unavailable" && pickerProvider === selectedModel.provider && selectedModel.unavailableReason === status.detail) ? /* @__PURE__ */ jsxs2(Fragment, { children: [
975
+ /* @__PURE__ */ jsx2(DropdownMenuSeparator, {}),
976
+ /* @__PURE__ */ jsxs2("div", { className: "px-2.5 py-2", role: "status", "aria-live": "polite", children: [
977
+ /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2 text-og-sm font-medium text-og-fg", children: [
978
+ /* @__PURE__ */ jsx2(
979
+ RealtimeStatusDot,
980
+ {
981
+ phase: status.phase,
982
+ reduceMotion: reduceMotion === true
983
+ }
984
+ ),
985
+ status.label
986
+ ] }),
987
+ /* @__PURE__ */ jsx2("p", { className: "mt-1 text-og-xs leading-5 text-og-fg-subtle", children: status.detail })
988
+ ] })
989
+ ] }) : null,
990
+ audioBlocked ? /* @__PURE__ */ jsxs2(
991
+ DropdownMenuItem,
992
+ {
993
+ onSelect: () => void props.onRetryAudibleOutput().catch(() => void 0),
994
+ children: [
995
+ /* @__PURE__ */ jsx2(Volume2Icon, {}),
996
+ "Resume audio"
997
+ ]
998
+ }
999
+ ) : null,
1000
+ retryConnection ? /* @__PURE__ */ jsxs2(DropdownMenuItem, { onSelect: () => void props.onRetry().catch(() => void 0), children: [
1001
+ /* @__PURE__ */ jsx2(RotateCcwIcon, {}),
1002
+ "Retry connection"
1003
+ ] }) : null,
1004
+ modeOwned && props.snapshot.status !== "lost_owner" ? /* @__PURE__ */ jsxs2(
1005
+ DropdownMenuItem,
1006
+ {
1007
+ variant: "destructive",
1008
+ disabled: props.snapshot.status === "stopping",
1009
+ onSelect: () => void props.onStop().catch(() => void 0),
1010
+ children: [
1011
+ /* @__PURE__ */ jsx2(SquareIcon, {}),
1012
+ "End voice conversation"
1013
+ ]
1014
+ }
1015
+ ) : null,
1016
+ diagnosticsVisible ? /* @__PURE__ */ jsx2(RealtimeDiagnosticsMenu, { snapshot: props.snapshot }) : null
1017
+ ]
1018
+ }
1019
+ )
1020
+ ] }) : null
1021
+ ] }),
1022
+ /* @__PURE__ */ jsxs2("span", { className: "sr-only", role: "status", "aria-live": "polite", children: [
1023
+ status.label,
1024
+ ". ",
1025
+ status.detail
1026
+ ] }),
1027
+ props.snapshot.error ? /* @__PURE__ */ jsx2("span", { className: "sr-only", role: "alert", children: props.snapshot.error }) : null
1028
+ ]
1029
+ }
1030
+ );
1031
+ }
1032
+ function RealtimeVoiceModelPanel(props) {
1033
+ const [provider, setProvider] = useState(null);
1034
+ const [direction, setDirection] = useState(1);
1035
+ return /* @__PURE__ */ jsxs2("div", { className: "flex min-h-0 flex-1 flex-col", "data-testid": "realtime-voice-model-panel", children: [
1036
+ /* @__PURE__ */ jsxs2("div", { className: "flex min-h-10 shrink-0 items-center gap-2 border-b border-og-border px-2 pb-2", children: [
1037
+ props.leading,
1038
+ /* @__PURE__ */ jsx2("div", { className: "min-w-0 flex-1 text-og-menu font-medium text-og-fg", children: "Voice model" })
1039
+ ] }),
1040
+ /* @__PURE__ */ jsxs2("div", { className: "min-h-0 flex-1 overflow-y-auto overscroll-contain p-2", children: [
1041
+ /* @__PURE__ */ jsx2("p", { className: "mb-3 text-og-control text-og-fg-muted", children: "Used when you start a voice conversation." }),
1042
+ /* @__PURE__ */ jsx2(
1043
+ RealtimeModelPickerMenu,
1044
+ {
1045
+ models: props.models,
1046
+ selectedModel: props.selectedModel,
1047
+ provider,
1048
+ direction,
1049
+ disabled: props.disabled === true,
1050
+ onProviderChange: (next, nextDirection) => {
1051
+ setDirection(nextDirection);
1052
+ setProvider(next);
1053
+ },
1054
+ onSelect: props.onSelect
1055
+ }
1056
+ )
1057
+ ] })
1058
+ ] });
1059
+ }
1060
+ function RealtimeMuteButton(props) {
1061
+ const microphone = props.kind === "microphone";
1062
+ const label = microphone ? props.muted ? "Unmute microphone" : "Mute microphone" : props.muted ? "Unmute voice audio" : "Mute voice audio";
1063
+ const Icon = microphone ? props.muted ? MicOffIcon : MicIcon : props.muted ? VolumeXIcon : Volume2Icon;
1064
+ return /* @__PURE__ */ jsx2(
1065
+ motion.button,
1066
+ {
1067
+ type: "button",
1068
+ "aria-label": label,
1069
+ "aria-pressed": props.muted,
1070
+ title: label,
1071
+ initial: props.reduceMotion ? false : { scale: 0.72, opacity: 0 },
1072
+ animate: { scale: 1, opacity: 1 },
1073
+ transition: {
1074
+ delay: props.enterDelay ?? 0,
1075
+ type: "spring",
1076
+ stiffness: 420,
1077
+ damping: 26,
1078
+ mass: 0.7
1079
+ },
1080
+ ...props.reduceMotion ? {} : { whileTap: { scale: 0.92 } },
1081
+ onClick: props.onToggle,
1082
+ className: cn(
1083
+ "inline-flex size-8 shrink-0 items-center justify-center rounded-og-md outline-hidden",
1084
+ "transition-[background-color,border-color,color] duration-150 ease-og-out",
1085
+ "focus-visible:ring-2 focus-visible:ring-og-accent/45 pointer-coarse:size-11",
1086
+ props.muted ? "border border-og-accent/35 bg-og-accent-soft text-og-accent" : "text-og-fg-muted hover:bg-og-surface-2 hover:text-og-fg"
1087
+ ),
1088
+ children: /* @__PURE__ */ jsx2(Icon, { className: "size-3.5", "aria-hidden": true })
1089
+ }
1090
+ );
1091
+ }
1092
+ function RealtimeModelPickerMenu(props) {
1093
+ const providers = REALTIME_MODEL_PROVIDERS.filter(
1094
+ (provider) => props.models.some((model) => model.provider === provider)
1095
+ );
1096
+ const pageKey = props.provider ? `voice-models:${props.provider}` : "voice-providers";
1097
+ const body = props.provider ? /* @__PURE__ */ jsxs2("div", { "data-testid": "realtime-model-picker-models", children: [
1098
+ /* @__PURE__ */ jsx2(
1099
+ PickerBackHeader,
1100
+ {
1101
+ label: realtimeProviderLabel(props.provider),
1102
+ icon: /* @__PURE__ */ jsx2(
1103
+ BillingClassMark,
1104
+ {
1105
+ billingClass: REALTIME_PROVIDER_META[props.provider].billingClass,
1106
+ "aria-label": ""
1107
+ }
1108
+ ),
1109
+ onBack: () => props.onProviderChange(null, -1)
1110
+ }
1111
+ ),
1112
+ /* @__PURE__ */ jsx2("div", { className: "flex flex-col gap-0.5", children: props.models.filter((model) => model.provider === props.provider).map((model) => {
1113
+ const selected = model.id === props.selectedModel.id;
1114
+ return /* @__PURE__ */ jsx2(
1115
+ PickerNavRow,
1116
+ {
1117
+ label: model.label,
1118
+ hint: model.unavailableReason ?? (model.recommended ? `Recommended \xB7 ${model.description}` : model.description),
1119
+ disabled: props.disabled || !model.available,
1120
+ title: model.unavailableReason ?? model.description,
1121
+ active: selected,
1122
+ showChevron: false,
1123
+ trailing: selected ? /* @__PURE__ */ jsx2(CheckIcon, { className: MENU_CHECK_CLASS, "aria-hidden": true }) : void 0,
1124
+ testId: `realtime-model-choice-${model.id}`,
1125
+ onClick: () => props.onSelect(model.id)
1126
+ },
1127
+ model.id
1128
+ );
1129
+ }) })
1130
+ ] }) : /* @__PURE__ */ jsx2("div", { className: "flex flex-col gap-0.5", "data-testid": "realtime-model-picker-providers", children: providers.map((provider) => {
1131
+ const meta = REALTIME_PROVIDER_META[provider];
1132
+ return /* @__PURE__ */ jsx2(
1133
+ PickerNavRow,
1134
+ {
1135
+ label: realtimeProviderLabel(provider),
1136
+ hint: meta.hint,
1137
+ icon: /* @__PURE__ */ jsx2(BillingClassMark, { billingClass: meta.billingClass, "aria-label": "" }),
1138
+ active: props.selectedModel.provider === provider,
1139
+ testId: `realtime-model-provider-${meta.billingClass}`,
1140
+ onClick: () => props.onProviderChange(provider, 1)
1141
+ },
1142
+ provider
1143
+ );
1144
+ }) });
1145
+ return /* @__PURE__ */ jsx2("div", { className: "relative overflow-hidden", "data-testid": "realtime-model-picker-menu", children: /* @__PURE__ */ jsx2(PickerAnimatedPage, { pageKey, direction: props.direction, children: body }) });
1146
+ }
1147
+ function RealtimeDiagnosticsMenu({ snapshot }) {
1148
+ const bridge = snapshot.bridge;
1149
+ const rows = [
1150
+ ["controller", snapshot.status],
1151
+ ["microphone", snapshot.microphone],
1152
+ ["microphone muted", String(snapshot.inputMuted)],
1153
+ ["audio", snapshot.audibleOutput],
1154
+ ["audio muted", String(snapshot.outputMuted)],
1155
+ ["generation", String(snapshot.connectionGeneration)],
1156
+ ["reconnect attempt", String(snapshot.reconnectAttempt)],
1157
+ ["mode", snapshot.mode?.state ?? "none"],
1158
+ ["mode version", snapshot.mode ? String(snapshot.mode.version) : "\u2014"],
1159
+ ["connection epoch", snapshot.mode ? String(snapshot.mode.connectionEpoch) : "\u2014"],
1160
+ ["provider started", bridge ? String(bridge.providerStarted) : "false"],
1161
+ ["provider speaking", bridge ? String(bridge.speaking) : "false"],
1162
+ ["delegation", bridge?.activeDelegationId ? "active" : "none"],
1163
+ ["pending durable events", bridge ? String(bridge.pendingInbound) : "0"],
1164
+ ["pending bytes", bridge ? String(bridge.pendingInboundBytes) : "0"],
1165
+ ["client ack", bridge?.clientAckThroughSequence?.toString() ?? "\u2014"],
1166
+ ["ignored provider events", bridge ? String(bridge.ignoredEventCount) : "0"],
1167
+ ["last ignored event", bridge?.lastIgnoredEventType ?? "none"],
1168
+ ["bridge error", bridge?.lastError ?? "none"],
1169
+ ["diagnostic", snapshot.diagnostic?.kind ?? "none"]
1170
+ ];
1171
+ return /* @__PURE__ */ jsxs2(Fragment, { children: [
1172
+ /* @__PURE__ */ jsx2(DropdownMenuSeparator, {}),
1173
+ /* @__PURE__ */ jsxs2(DropdownMenuSub, { children: [
1174
+ /* @__PURE__ */ jsx2(DropdownMenuSubTrigger, { className: "text-og-fg-muted", children: "Realtime diagnostics" }),
1175
+ /* @__PURE__ */ jsx2(DropdownMenuSubContent, { className: "max-h-80 w-72 overflow-y-auto", children: rows.map(([label, value]) => /* @__PURE__ */ jsxs2(
1176
+ DropdownMenuItem,
1177
+ {
1178
+ disabled: true,
1179
+ className: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)] gap-3 rounded-og-md font-mono text-[11px] opacity-100",
1180
+ children: [
1181
+ /* @__PURE__ */ jsx2("span", { className: "truncate text-og-fg-subtle", children: label }),
1182
+ /* @__PURE__ */ jsx2("span", { className: "truncate text-right text-og-fg", children: value })
1183
+ ]
1184
+ },
1185
+ label
1186
+ )) })
1187
+ ] })
1188
+ ] });
1189
+ }
1190
+ function statusContent(snapshot, modelAvailable, canStart, admissionBlocker, modelLabel, unavailableCode = null) {
1191
+ if (snapshot.audibleOutput === "blocked" && !snapshot.outputMuted) {
1192
+ return {
1193
+ phase: "blocked",
1194
+ label: "Audio output blocked",
1195
+ detail: "Resume audio to hear the existing voice connection."
1196
+ };
1197
+ }
1198
+ switch (snapshot.status) {
1199
+ case "starting":
1200
+ return {
1201
+ phase: "connecting",
1202
+ label: "Connecting\u2026",
1203
+ detail: "Preparing your microphone and live voice."
1204
+ };
1205
+ case "active":
1206
+ return snapshot.bridge?.speaking ? {
1207
+ phase: "speaking",
1208
+ label: "Speaking",
1209
+ detail: "Interrupt naturally whenever you want."
1210
+ } : {
1211
+ phase: "listening",
1212
+ label: "Listening",
1213
+ detail: "Voice and typed messages share this session."
1214
+ };
1215
+ case "stopping":
1216
+ return {
1217
+ phase: "stopping",
1218
+ label: "Ending voice\u2026",
1219
+ detail: "Saving the remaining conversation context."
1220
+ };
1221
+ case "recovering":
1222
+ return {
1223
+ phase: "reconnecting",
1224
+ label: "Reconnecting\u2026",
1225
+ detail: snapshot.error ?? "Keeping this voice conversation connected."
1226
+ };
1227
+ case "lost_owner":
1228
+ return {
1229
+ phase: "elsewhere",
1230
+ label: "Voice active elsewhere",
1231
+ detail: "Return to the browser that started it, or wait for that connection to expire."
1232
+ };
1233
+ case "error":
1234
+ if (snapshot.refusal) {
1235
+ return {
1236
+ phase: "unavailable",
1237
+ label: realtimeRefusalLabel(snapshot.refusal.code) ?? "Voice unavailable",
1238
+ detail: snapshot.refusal.message
1239
+ };
1240
+ }
1241
+ return {
1242
+ phase: "error",
1243
+ label: "Voice unavailable",
1244
+ detail: snapshot.error ?? "The connection could not be started."
1245
+ };
1246
+ case "idle":
1247
+ if (!modelAvailable) {
1248
+ return {
1249
+ phase: "unavailable",
1250
+ label: realtimeRefusalLabel(unavailableCode) ?? "Voice model unavailable",
1251
+ detail: admissionBlocker ?? "Choose another voice model."
1252
+ };
1253
+ }
1254
+ if (!canStart && admissionBlocker) {
1255
+ return {
1256
+ phase: "unavailable",
1257
+ label: "Voice unavailable",
1258
+ detail: admissionBlocker
1259
+ };
1260
+ }
1261
+ return {
1262
+ phase: "idle",
1263
+ label: "Start voice",
1264
+ detail: `Talk live with ${modelLabel}.`
1265
+ };
1266
+ }
1267
+ }
1268
+ function RealtimeComposerGlow(props) {
1269
+ const visible = [
1270
+ "connecting",
1271
+ "listening",
1272
+ "speaking",
1273
+ "reconnecting",
1274
+ "blocked",
1275
+ "error",
1276
+ "stopping"
1277
+ ].includes(props.phase);
1278
+ return /* @__PURE__ */ jsx2(AnimatePresence, { initial: false, children: visible ? /* @__PURE__ */ jsx2(
1279
+ motion.span,
1280
+ {
1281
+ "aria-hidden": true,
1282
+ initial: { opacity: 0 },
1283
+ animate: props.reduceMotion ? { opacity: 0.48 } : props.phase === "speaking" ? { opacity: [0.42, 0.82, 0.52] } : props.phase === "listening" ? { opacity: [0.34, 0.62, 0.42] } : { opacity: [0.28, 0.58, 0.28] },
1284
+ exit: { opacity: 0 },
1285
+ transition: props.reduceMotion ? { duration: 0.12 } : {
1286
+ duration: props.phase === "speaking" ? 1.15 : 2.1,
1287
+ ease: "easeInOut",
1288
+ repeat: Number.POSITIVE_INFINITY
1289
+ },
1290
+ className: cn(
1291
+ "pointer-events-none absolute -inset-px z-[1] rounded-og-lg ring-1 ring-inset shadow-og-glow",
1292
+ props.phase === "speaking" ? "ring-og-status-running/50" : props.phase === "blocked" || props.phase === "error" ? "ring-og-status-waiting/45" : "ring-og-accent/45"
1293
+ )
1294
+ },
1295
+ props.phase
1296
+ ) : null });
1297
+ }
1298
+ function RealtimeActionGlyph(props) {
1299
+ if (["connecting", "reconnecting", "stopping"].includes(props.phase)) {
1300
+ return /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-3.5 animate-og-spin", "aria-hidden": true });
1301
+ }
1302
+ if (props.phase === "blocked") {
1303
+ return props.audioBlocked ? /* @__PURE__ */ jsx2(Volume2Icon, { className: "size-3.5", "aria-hidden": true }) : /* @__PURE__ */ jsx2(CircleAlertIcon, { className: "size-3.5", "aria-hidden": true });
1304
+ }
1305
+ if (props.phase === "error" || props.phase === "elsewhere" || props.phase === "unavailable") {
1306
+ return /* @__PURE__ */ jsx2(CircleAlertIcon, { className: "size-3.5", "aria-hidden": true });
1307
+ }
1308
+ if (props.phase === "listening" || props.phase === "speaking") {
1309
+ return /* @__PURE__ */ jsxs2("span", { className: "relative inline-flex size-4 items-center justify-center", children: [
1310
+ !props.reduceMotion ? /* @__PURE__ */ jsx2(
1311
+ motion.span,
1312
+ {
1313
+ "aria-hidden": true,
1314
+ className: "absolute inset-0 rounded-full border border-current",
1315
+ animate: { opacity: [0.65, 0], scale: [0.65, 1.45] },
1316
+ transition: {
1317
+ duration: props.phase === "speaking" ? 0.9 : 1.5,
1318
+ ease: "easeOut",
1319
+ repeat: Number.POSITIVE_INFINITY
1320
+ }
1321
+ }
1322
+ ) : null,
1323
+ /* @__PURE__ */ jsx2(SquareIcon, { className: "relative size-2.5 fill-current", "aria-hidden": true })
1324
+ ] });
1325
+ }
1326
+ return /* @__PURE__ */ jsx2(AudioLinesIcon, { className: "size-4", "aria-hidden": true });
1327
+ }
1328
+ function RealtimeStatusDot(props) {
1329
+ const live = props.phase === "listening" || props.phase === "speaking";
1330
+ return /* @__PURE__ */ jsxs2("span", { className: "relative inline-flex size-2 shrink-0", "aria-hidden": true, children: [
1331
+ live && !props.reduceMotion ? /* @__PURE__ */ jsx2(
1332
+ motion.span,
1333
+ {
1334
+ className: "absolute inset-0 rounded-full bg-og-status-running",
1335
+ animate: { opacity: [0.45, 0], scale: [1, 2.2] },
1336
+ transition: {
1337
+ duration: 1.4,
1338
+ ease: "easeOut",
1339
+ repeat: Number.POSITIVE_INFINITY
1340
+ }
1341
+ }
1342
+ ) : null,
1343
+ /* @__PURE__ */ jsx2(
1344
+ "span",
1345
+ {
1346
+ className: cn(
1347
+ "relative size-2 rounded-full",
1348
+ live ? "bg-og-status-running" : props.phase === "blocked" || props.phase === "error" ? "bg-og-status-waiting" : props.phase === "elsewhere" || props.phase === "unavailable" ? "bg-og-fg-subtle" : "bg-og-accent"
1349
+ )
1350
+ }
1351
+ )
1352
+ ] });
1353
+ }
1354
+ function voiceButtonTone(phase) {
1355
+ if (phase === "listening" || phase === "speaking") {
1356
+ return "border border-og-primary-border bg-og-primary text-og-primary-fg hover:bg-og-primary-hover";
1357
+ }
1358
+ if (phase === "blocked" || phase === "error") {
1359
+ return "border border-og-status-waiting/35 bg-og-status-waiting/10 text-og-status-waiting hover:bg-og-status-waiting/15";
1360
+ }
1361
+ if (phase === "connecting" || phase === "reconnecting" || phase === "stopping") {
1362
+ return "border border-og-accent/35 bg-og-accent-soft text-og-accent";
1363
+ }
1364
+ return "text-og-fg-muted hover:bg-og-surface-2 hover:text-og-fg";
1365
+ }
1366
+ function voiceChevronTone(phase) {
1367
+ if (phase === "listening" || phase === "speaking") {
1368
+ return "border border-l-0 border-og-primary-border bg-og-primary text-og-primary-fg hover:bg-og-primary-hover";
1369
+ }
1370
+ if (phase === "blocked" || phase === "error") {
1371
+ return "border border-l-0 border-og-status-waiting/35 bg-og-status-waiting/10 text-og-status-waiting hover:bg-og-status-waiting/15";
1372
+ }
1373
+ if (phase === "connecting" || phase === "reconnecting" || phase === "stopping") {
1374
+ return "border border-l-0 border-og-accent/35 bg-og-accent-soft text-og-accent";
1375
+ }
1376
+ return "text-og-fg-muted hover:bg-og-surface-2 hover:text-og-fg";
1377
+ }
1378
+ function toRealtimeModelOption(model) {
1379
+ return { ...model };
1380
+ }
1381
+ function readRealtimeModelPreference(workspaceId) {
1382
+ if (typeof localStorage === "undefined") return null;
1383
+ try {
1384
+ const value = localStorage.getItem(`${REALTIME_MODEL_STORAGE_PREFIX}:${workspaceId}`);
1385
+ return isRealtimeModel(value) ? value : null;
1386
+ } catch {
1387
+ return null;
1388
+ }
1389
+ }
1390
+ function writeRealtimeModelPreference(workspaceId, model) {
1391
+ if (typeof localStorage === "undefined") return;
1392
+ try {
1393
+ localStorage.setItem(`${REALTIME_MODEL_STORAGE_PREFIX}:${workspaceId}`, model);
1394
+ } catch {
1395
+ }
1396
+ }
1397
+ function isRealtimeModel(value) {
1398
+ return value === "opengeni-azure/gpt-live-1" || value === "gpt-live-1-boulder-alpha" || value === "opengeni-gateway/openai/gpt-realtime-2.1" || value === "opengeni-gateway/openai/gpt-realtime-mini" || value === "opengeni-gateway/xai/grok-voice-think-fast-2.0" || value === "supergrok/grok-voice-think-fast-2.0" || value === "workspace-gateway/openai/gpt-realtime-2.1" || value === "workspace-gateway/openai/gpt-realtime-mini" || value === "workspace-gateway/xai/grok-voice-think-fast-2.0";
1399
+ }
1400
+ var useSessionCodexRealtime = useSessionRealtime;
1401
+ var useWorkspaceRealtimeModelSelection = useRealtimeModelSelection;
1402
+ var SessionCodexRealtimeControl = SessionRealtimeControl;
1403
+ var CodexRealtimeControl = RealtimeVoiceControl;
1404
+
1405
+ export {
1406
+ codexRealtimeAdmissionAllowed,
1407
+ codexRealtimeAdmissionBlocker,
1408
+ useSessionRealtime,
1409
+ SessionRealtimeControl,
1410
+ useRealtimeModelSelection,
1411
+ NewSessionRealtimeControl,
1412
+ RealtimeVoiceControl,
1413
+ RealtimeVoiceModelPanel,
1414
+ RealtimeModelPickerMenu,
1415
+ useSessionCodexRealtime,
1416
+ useWorkspaceRealtimeModelSelection,
1417
+ SessionCodexRealtimeControl,
1418
+ CodexRealtimeControl
1419
+ };
1420
+ //# sourceMappingURL=chunk-YVFRBXST.js.map