@air-jam/sdk 0.1.4 → 0.9.1

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 (357) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +627 -57
  3. package/dist/agent-tooling-BSMGBix9.d.cts +123 -0
  4. package/dist/agent-tooling-BSMGBix9.d.ts +123 -0
  5. package/dist/agent-tooling.cjs +83 -0
  6. package/dist/agent-tooling.cjs.map +1 -0
  7. package/dist/agent-tooling.d.cts +2 -0
  8. package/dist/agent-tooling.d.ts +2 -0
  9. package/dist/agent-tooling.js +17 -0
  10. package/dist/agent-tooling.js.map +1 -0
  11. package/dist/arcade/bridge/controller.cjs +749 -0
  12. package/dist/arcade/bridge/controller.cjs.map +1 -0
  13. package/dist/arcade/bridge/controller.d.cts +85 -0
  14. package/dist/arcade/bridge/controller.d.ts +85 -0
  15. package/dist/arcade/bridge/controller.js +33 -0
  16. package/dist/arcade/bridge/controller.js.map +1 -0
  17. package/dist/arcade/bridge/host.cjs +421 -0
  18. package/dist/arcade/bridge/host.cjs.map +1 -0
  19. package/dist/arcade/bridge/host.d.cts +73 -0
  20. package/dist/arcade/bridge/host.d.ts +73 -0
  21. package/dist/arcade/bridge/host.js +25 -0
  22. package/dist/arcade/bridge/host.js.map +1 -0
  23. package/dist/arcade/bridge/iframe.cjs +453 -0
  24. package/dist/arcade/bridge/iframe.cjs.map +1 -0
  25. package/dist/arcade/bridge/iframe.d.cts +80 -0
  26. package/dist/arcade/bridge/iframe.d.ts +80 -0
  27. package/dist/arcade/bridge/iframe.js +28 -0
  28. package/dist/arcade/bridge/iframe.js.map +1 -0
  29. package/dist/arcade/bridge.cjs +1067 -0
  30. package/dist/arcade/bridge.cjs.map +1 -0
  31. package/dist/arcade/bridge.d.cts +11 -0
  32. package/dist/arcade/bridge.d.ts +11 -0
  33. package/dist/arcade/bridge.js +76 -0
  34. package/dist/arcade/bridge.js.map +1 -0
  35. package/dist/arcade/host.cjs +481 -0
  36. package/dist/arcade/host.cjs.map +1 -0
  37. package/dist/arcade/host.d.cts +19 -0
  38. package/dist/arcade/host.d.ts +19 -0
  39. package/dist/arcade/host.js +14 -0
  40. package/dist/arcade/host.js.map +1 -0
  41. package/dist/arcade/surface.cjs +113 -0
  42. package/dist/arcade/surface.cjs.map +1 -0
  43. package/dist/arcade/surface.d.cts +14 -0
  44. package/dist/arcade/surface.d.ts +14 -0
  45. package/dist/arcade/surface.js +27 -0
  46. package/dist/arcade/surface.js.map +1 -0
  47. package/dist/arcade/url.cjs +544 -0
  48. package/dist/arcade/url.cjs.map +1 -0
  49. package/dist/arcade/url.d.cts +68 -0
  50. package/dist/arcade/url.d.ts +68 -0
  51. package/dist/arcade/url.js +29 -0
  52. package/dist/arcade/url.js.map +1 -0
  53. package/dist/arcade-runtime-url-BW-MUAOY.d.cts +28 -0
  54. package/dist/arcade-runtime-url-l8qj01Pg.d.ts +28 -0
  55. package/dist/arcade-surface-identity-CQxDpn_w.d.cts +16 -0
  56. package/dist/arcade-surface-identity-CQxDpn_w.d.ts +16 -0
  57. package/dist/arcade.cjs +1737 -0
  58. package/dist/arcade.cjs.map +1 -0
  59. package/dist/arcade.d.cts +18 -0
  60. package/dist/arcade.d.ts +18 -0
  61. package/dist/arcade.js +123 -0
  62. package/dist/arcade.js.map +1 -0
  63. package/dist/capabilities.cjs +39 -0
  64. package/dist/capabilities.cjs.map +1 -0
  65. package/dist/capabilities.d.cts +31 -0
  66. package/dist/capabilities.d.ts +31 -0
  67. package/dist/capabilities.js +12 -0
  68. package/dist/capabilities.js.map +1 -0
  69. package/dist/chunk-32NYL7XI.js +539 -0
  70. package/dist/chunk-32NYL7XI.js.map +1 -0
  71. package/dist/chunk-3USU7GY2.js +54 -0
  72. package/dist/chunk-3USU7GY2.js.map +1 -0
  73. package/dist/chunk-7UXSWCZZ.js +32 -0
  74. package/dist/chunk-7UXSWCZZ.js.map +1 -0
  75. package/dist/chunk-BE6Z4SIT.js +65 -0
  76. package/dist/chunk-BE6Z4SIT.js.map +1 -0
  77. package/dist/chunk-CABEUV65.js +184 -0
  78. package/dist/chunk-CABEUV65.js.map +1 -0
  79. package/dist/chunk-CEJ5RFSG.js +288 -0
  80. package/dist/chunk-CEJ5RFSG.js.map +1 -0
  81. package/dist/chunk-EDRQIOCV.js +25 -0
  82. package/dist/chunk-EDRQIOCV.js.map +1 -0
  83. package/dist/chunk-EVZJA6RN.js +140 -0
  84. package/dist/chunk-EVZJA6RN.js.map +1 -0
  85. package/dist/chunk-FAT2KJ3K.js +238 -0
  86. package/dist/chunk-FAT2KJ3K.js.map +1 -0
  87. package/dist/chunk-IKKDONQL.js +1 -0
  88. package/dist/chunk-IKKDONQL.js.map +1 -0
  89. package/dist/chunk-JEHV5C2X.js +249 -0
  90. package/dist/chunk-JEHV5C2X.js.map +1 -0
  91. package/dist/chunk-JO2HR5PV.js +43 -0
  92. package/dist/chunk-JO2HR5PV.js.map +1 -0
  93. package/dist/chunk-JTF47B56.js +1 -0
  94. package/dist/chunk-JTF47B56.js.map +1 -0
  95. package/dist/chunk-KXAFI5OP.js +193 -0
  96. package/dist/chunk-KXAFI5OP.js.map +1 -0
  97. package/dist/chunk-LIXPF4P6.js +22 -0
  98. package/dist/chunk-LIXPF4P6.js.map +1 -0
  99. package/dist/chunk-MPDMJIX5.js +1 -0
  100. package/dist/chunk-MPDMJIX5.js.map +1 -0
  101. package/dist/chunk-NCL6WJCL.js +91 -0
  102. package/dist/chunk-NCL6WJCL.js.map +1 -0
  103. package/dist/chunk-NUJBMV3O.js +1435 -0
  104. package/dist/chunk-NUJBMV3O.js.map +1 -0
  105. package/dist/chunk-TGRTEWYV.js +195 -0
  106. package/dist/chunk-TGRTEWYV.js.map +1 -0
  107. package/dist/chunk-UWJOIVON.js +369 -0
  108. package/dist/chunk-UWJOIVON.js.map +1 -0
  109. package/dist/chunk-VKBMZHMQ.js +216 -0
  110. package/dist/chunk-VKBMZHMQ.js.map +1 -0
  111. package/dist/chunk-W2VK36RO.js +11 -0
  112. package/dist/chunk-W2VK36RO.js.map +1 -0
  113. package/dist/chunk-W3YA5BWR.js +126 -0
  114. package/dist/chunk-W3YA5BWR.js.map +1 -0
  115. package/dist/chunk-X24K52DG.js +12 -0
  116. package/dist/chunk-X24K52DG.js.map +1 -0
  117. package/dist/chunk-YXHH3MQT.js +230 -0
  118. package/dist/chunk-YXHH3MQT.js.map +1 -0
  119. package/dist/chunk-ZLPL2R3R.js +183 -0
  120. package/dist/chunk-ZLPL2R3R.js.map +1 -0
  121. package/dist/chunk-ZTQ5SP4H.js +9 -0
  122. package/dist/chunk-ZTQ5SP4H.js.map +1 -0
  123. package/dist/controller-Bod8YYr1.d.cts +172 -0
  124. package/dist/controller-DxVchfiA.d.ts +172 -0
  125. package/dist/dev-log-events-CVAM29hx.d.cts +123 -0
  126. package/dist/dev-log-events-CVAM29hx.d.ts +123 -0
  127. package/dist/handshake-CC_LrK5g.d.cts +31 -0
  128. package/dist/handshake-CC_LrK5g.d.ts +31 -0
  129. package/dist/host-8hmq_Sgc.d.cts +109 -0
  130. package/dist/host-Cw-N6e-5.d.ts +109 -0
  131. package/dist/index.cjs +8730 -3426
  132. package/dist/index.cjs.map +1 -1
  133. package/dist/index.d.cts +676 -1070
  134. package/dist/index.d.ts +676 -1070
  135. package/dist/index.js +4892 -3196
  136. package/dist/index.js.map +1 -1
  137. package/dist/metadata.cjs +114 -0
  138. package/dist/metadata.cjs.map +1 -0
  139. package/dist/metadata.d.cts +95 -0
  140. package/dist/metadata.d.ts +95 -0
  141. package/dist/metadata.js +83 -0
  142. package/dist/metadata.js.map +1 -0
  143. package/dist/notices-CnGaaS8B.d.ts +38 -0
  144. package/dist/notices-NyDM5Mtz.d.cts +38 -0
  145. package/dist/platform-machine.cjs +425 -0
  146. package/dist/platform-machine.cjs.map +1 -0
  147. package/dist/platform-machine.d.cts +1183 -0
  148. package/dist/platform-machine.d.ts +1183 -0
  149. package/dist/platform-machine.js +309 -0
  150. package/dist/platform-machine.js.map +1 -0
  151. package/dist/platform-settings-cuor3i11.d.cts +48 -0
  152. package/dist/platform-settings-cuor3i11.d.ts +48 -0
  153. package/dist/prefabs.cjs +36 -0
  154. package/dist/prefabs.cjs.map +1 -0
  155. package/dist/prefabs.d.cts +49 -0
  156. package/dist/prefabs.d.ts +49 -0
  157. package/dist/prefabs.js +8 -0
  158. package/dist/prefabs.js.map +1 -0
  159. package/dist/preview.cjs +2620 -0
  160. package/dist/preview.cjs.map +1 -0
  161. package/dist/preview.d.cts +155 -0
  162. package/dist/preview.d.ts +155 -0
  163. package/dist/preview.js +1671 -0
  164. package/dist/preview.js.map +1 -0
  165. package/dist/protocol.cjs +621 -54
  166. package/dist/protocol.cjs.map +1 -1
  167. package/dist/protocol.d.cts +76 -240
  168. package/dist/protocol.d.ts +76 -240
  169. package/dist/protocol.js +100 -2
  170. package/dist/protocol.js.map +1 -1
  171. package/dist/realtime-client-Cu8yVJFw.d.cts +15 -0
  172. package/dist/realtime-client-Cu8yVJFw.d.ts +15 -0
  173. package/dist/release.cjs +143 -0
  174. package/dist/release.cjs.map +1 -0
  175. package/dist/release.d.cts +64 -0
  176. package/dist/release.d.ts +64 -0
  177. package/dist/release.js +43 -0
  178. package/dist/release.js.map +1 -0
  179. package/dist/runtime-topology.cjs +405 -0
  180. package/dist/runtime-topology.cjs.map +1 -0
  181. package/dist/runtime-topology.d.cts +59 -0
  182. package/dist/runtime-topology.d.ts +59 -0
  183. package/dist/runtime-topology.js +31 -0
  184. package/dist/runtime-topology.js.map +1 -0
  185. package/dist/standard-match-phase-BucA5dYo.d.ts +44 -0
  186. package/dist/standard-match-phase-U2ra8J-0.d.cts +44 -0
  187. package/dist/sync-B6QsNrXz.d.cts +125 -0
  188. package/dist/sync-B6QsNrXz.d.ts +125 -0
  189. package/dist/ui.cjs +3061 -0
  190. package/dist/ui.cjs.map +1 -0
  191. package/dist/ui.d.cts +320 -0
  192. package/dist/ui.d.ts +320 -0
  193. package/dist/ui.js +1719 -0
  194. package/dist/ui.js.map +1 -0
  195. package/dist/url-policy-C89zxgw9.d.cts +9 -0
  196. package/dist/url-policy-C89zxgw9.d.ts +9 -0
  197. package/package.json +155 -10
  198. package/src/agent/agent-action.ts +304 -0
  199. package/src/agent/agent-contract.ts +180 -0
  200. package/src/agent-tooling.ts +20 -0
  201. package/src/arcade/bridge/controller.ts +15 -0
  202. package/src/arcade/bridge/host.ts +12 -0
  203. package/src/arcade/bridge/iframe.ts +61 -0
  204. package/src/arcade/bridge.ts +3 -0
  205. package/src/arcade/host.ts +1 -0
  206. package/src/arcade/surface.ts +4 -0
  207. package/src/arcade/url.ts +60 -0
  208. package/src/arcade.ts +4 -0
  209. package/src/audio/audio-manager.ts +162 -171
  210. package/src/audio/hooks.tsx +218 -97
  211. package/src/audio/index.ts +1 -1
  212. package/src/audio/music.tsx +139 -0
  213. package/src/capabilities/manifest.ts +71 -0
  214. package/src/capabilities.ts +12 -0
  215. package/src/components/connection-status-pill.tsx +55 -0
  216. package/src/components/controller-player-name-field.tsx +119 -0
  217. package/src/components/controller-primary-action.tsx +58 -0
  218. package/src/components/host-mute-button.tsx +49 -0
  219. package/src/components/join-qr-overlay.tsx +133 -0
  220. package/src/components/join-url-action-buttons.tsx +95 -0
  221. package/src/components/join-url-controls.tsx +58 -0
  222. package/src/components/join-url-field.tsx +52 -0
  223. package/src/components/lifecycle-action-group.tsx +129 -0
  224. package/src/components/player-avatar-strip.tsx +65 -0
  225. package/src/components/player-avatar.tsx +42 -13
  226. package/src/components/room-qr-code.tsx +125 -0
  227. package/src/components/runtime-shell-header.tsx +37 -0
  228. package/src/components/shell-classes.ts +19 -0
  229. package/src/components/surface-orientation-layout.ts +60 -0
  230. package/src/components/surface-viewport-layout.ts +268 -0
  231. package/src/components/surface-viewport.tsx +314 -0
  232. package/src/components/ui/button.tsx +4 -6
  233. package/src/components/ui/slider.tsx +1 -1
  234. package/src/components/volume-controls.tsx +65 -6
  235. package/src/context/air-jam-context.tsx +209 -161
  236. package/src/context/index.ts +2 -2
  237. package/src/context/session-providers.tsx +77 -0
  238. package/src/context/session-scope.ts +64 -0
  239. package/src/context/socket-manager.ts +6 -24
  240. package/src/contracts/v2/bridge.ts +261 -0
  241. package/src/contracts/v2/handshake.ts +40 -0
  242. package/src/contracts/v2/index.ts +2 -0
  243. package/src/dev/browser-log-sink.ts +912 -0
  244. package/src/diagnostics.ts +128 -0
  245. package/src/events.ts +7 -34
  246. package/src/hooks/internal/use-controller-runtime-api.ts +875 -0
  247. package/src/hooks/internal/use-host-runtime-api.ts +1051 -0
  248. package/src/hooks/internal/use-runtime-control-contract.ts +15 -0
  249. package/src/hooks/internal/use-runtime-inspection-contract.ts +16 -0
  250. package/src/hooks/internal/use-runtime-observability-contract.ts +24 -0
  251. package/src/hooks/use-air-jam-controller.ts +155 -475
  252. package/src/hooks/use-air-jam-host.ts +156 -485
  253. package/src/hooks/use-connection-status.ts +8 -0
  254. package/src/hooks/use-controller-lifecycle-intents.ts +27 -0
  255. package/src/hooks/use-controller-lifecycle-permissions.ts +36 -0
  256. package/src/hooks/use-controller-shell-status.ts +40 -0
  257. package/src/hooks/use-controller-tick.ts +65 -0
  258. package/src/hooks/use-controller-toasts.ts +116 -0
  259. package/src/hooks/use-get-input.ts +8 -5
  260. package/src/hooks/use-host-arcade-restore.ts +30 -0
  261. package/src/hooks/use-host-join-controls.ts +152 -0
  262. package/src/hooks/use-host-tick.ts +171 -0
  263. package/src/hooks/use-input-writer.ts +83 -0
  264. package/src/hooks/use-lifecycle-action-group-model.ts +98 -0
  265. package/src/hooks/use-players.ts +12 -0
  266. package/src/hooks/use-room.ts +22 -0
  267. package/src/hooks/use-send-signal.ts +6 -2
  268. package/src/index.ts +205 -31
  269. package/src/internal/input-manager.ts +195 -215
  270. package/src/lifecycle/index.ts +9 -0
  271. package/src/lifecycle/standard-match-phase.ts +32 -0
  272. package/src/metadata/manifest.ts +152 -0
  273. package/src/metadata.ts +12 -0
  274. package/src/platform-machine.ts +475 -0
  275. package/src/prefabs/types.ts +82 -0
  276. package/src/prefabs.ts +12 -0
  277. package/src/preview/host-workspace.tsx +59 -0
  278. package/src/preview/identity.ts +66 -0
  279. package/src/preview/layout.ts +223 -0
  280. package/src/preview/manager.ts +577 -0
  281. package/src/preview/messages.ts +26 -0
  282. package/src/preview/ownership.ts +81 -0
  283. package/src/preview/url.ts +117 -0
  284. package/src/preview/window.tsx +490 -0
  285. package/src/preview/workspace.tsx +678 -0
  286. package/src/preview.ts +42 -0
  287. package/src/protocol/arcade-platform-actions.ts +29 -0
  288. package/src/protocol/controller.ts +187 -0
  289. package/src/protocol/core.ts +23 -0
  290. package/src/protocol/dev-log-events.ts +222 -0
  291. package/src/protocol/errors.ts +21 -0
  292. package/src/protocol/host-grant.ts +185 -0
  293. package/src/protocol/host.ts +138 -0
  294. package/src/protocol/notices.ts +43 -0
  295. package/src/protocol/signals.ts +38 -0
  296. package/src/protocol/socket-events.ts +154 -0
  297. package/src/protocol/sync.ts +121 -0
  298. package/src/protocol/url-policy.ts +63 -0
  299. package/src/protocol.ts +12 -386
  300. package/src/qrcode.d.ts +16 -0
  301. package/src/release.ts +99 -0
  302. package/src/runtime/air-jam-config.ts +287 -0
  303. package/src/runtime/air-jam-error-boundary.tsx +672 -0
  304. package/src/runtime/arcade-bridge-request-surface.ts +15 -0
  305. package/src/runtime/arcade-runtime-url.ts +95 -0
  306. package/src/runtime/arcade-surface-identity.ts +16 -0
  307. package/src/runtime/contracts/control.ts +68 -0
  308. package/src/runtime/contracts/inspection.ts +165 -0
  309. package/src/runtime/contracts/observability.ts +94 -0
  310. package/src/runtime/controller-bridge.ts +451 -0
  311. package/src/runtime/controller-identity.ts +132 -0
  312. package/src/runtime/controller-presentation.ts +24 -0
  313. package/src/runtime/controller-realtime-client.ts +591 -0
  314. package/src/runtime/create-air-jam-app.tsx +260 -0
  315. package/src/runtime/dev-runtime-events.ts +36 -0
  316. package/src/runtime/embedded-runtime-adapters.ts +68 -0
  317. package/src/runtime/host-bridge.ts +388 -0
  318. package/src/runtime/host-realtime-client.ts +550 -0
  319. package/src/runtime/iframe-bridge.ts +135 -0
  320. package/src/runtime/realtime-client.ts +20 -0
  321. package/src/runtime/router-basename.ts +25 -0
  322. package/src/runtime/runtime-owner-contexts.tsx +4 -0
  323. package/src/runtime/runtime-session-params.ts +169 -0
  324. package/src/runtime/sdk-version.ts +6 -0
  325. package/src/runtime/session-runtimes.tsx +188 -0
  326. package/src/runtime/validate-arcade-bridge-attach.ts +14 -0
  327. package/src/runtime-control.ts +10 -0
  328. package/src/runtime-inspection.ts +14 -0
  329. package/src/runtime-observability.ts +9 -0
  330. package/src/runtime-topology.ts +569 -0
  331. package/src/settings/platform-settings-bridge.ts +336 -0
  332. package/src/settings/platform-settings-runtime.tsx +387 -0
  333. package/src/settings/platform-settings.ts +288 -0
  334. package/src/state/connection-store.ts +80 -12
  335. package/src/store/air-jam-store-domain-constants.ts +4 -0
  336. package/src/store/create-air-jam-store.ts +1094 -227
  337. package/src/styles.css +4 -38
  338. package/src/ui.ts +29 -0
  339. package/src/utils/is-rpc-serializable.ts +56 -0
  340. package/src/utils/player-avatar-url.ts +48 -0
  341. package/src/utils/url-builder.ts +7 -0
  342. package/dist/.tsbuildinfo +0 -1
  343. package/dist/chunk-B5DURUWT.js +0 -80
  344. package/dist/chunk-B5DURUWT.js.map +0 -1
  345. package/src/AirJamClient.ts +0 -224
  346. package/src/audio/volume-store.ts +0 -124
  347. package/src/components/controller-shell.tsx +0 -346
  348. package/src/components/host-shell.tsx +0 -520
  349. package/src/components/qr-scanner-dialog.tsx +0 -373
  350. package/src/components/ui/alert.tsx +0 -66
  351. package/src/components/ui/avatar.tsx +0 -46
  352. package/src/components/ui/badge.tsx +0 -47
  353. package/src/components/ui/card.tsx +0 -92
  354. package/src/components/ui/dialog.tsx +0 -122
  355. package/src/components/ui/tabs.tsx +0 -64
  356. package/src/hooks/use-air-jam-shell.ts +0 -379
  357. package/src/hooks/use-fullscreen.ts +0 -108
package/dist/ui.js ADDED
@@ -0,0 +1,1719 @@
1
+ import {
2
+ readEmbeddedControllerRuntimeParams,
3
+ useAirJamController
4
+ } from "./chunk-CABEUV65.js";
5
+ import {
6
+ createControllerPresentationSyncMessage
7
+ } from "./chunk-VKBMZHMQ.js";
8
+ import "./chunk-X24K52DG.js";
9
+ import {
10
+ Button,
11
+ Slider,
12
+ buttonVariants,
13
+ cn,
14
+ shellFieldClassName,
15
+ shellHeaderClassName,
16
+ shellHelperTextClassName,
17
+ shellLabelClassName,
18
+ shellPanelClassName,
19
+ shellUtilityButtonClassName
20
+ } from "./chunk-EVZJA6RN.js";
21
+ import {
22
+ usePlatformAudioSettings
23
+ } from "./chunk-CEJ5RFSG.js";
24
+ import "./chunk-FAT2KJ3K.js";
25
+ import "./chunk-JEHV5C2X.js";
26
+ import {
27
+ useSessionScope
28
+ } from "./chunk-NUJBMV3O.js";
29
+ import "./chunk-LIXPF4P6.js";
30
+ import "./chunk-ZLPL2R3R.js";
31
+ import "./chunk-32NYL7XI.js";
32
+ import "./chunk-W2VK36RO.js";
33
+ import "./chunk-UWJOIVON.js";
34
+ import "./chunk-3USU7GY2.js";
35
+ import "./chunk-BE6Z4SIT.js";
36
+
37
+ // src/components/connection-status-pill.tsx
38
+ import { jsx, jsxs } from "react/jsx-runtime";
39
+ var statusLabelByConnection = {
40
+ connected: "Live",
41
+ connecting: "Syncing",
42
+ reconnecting: "Syncing",
43
+ disconnected: "Offline",
44
+ idle: "Idle"
45
+ };
46
+ var statusToneByConnection = {
47
+ connected: "border-emerald-400/18 bg-emerald-400/8 text-emerald-50",
48
+ connecting: "border-amber-400/18 bg-amber-400/8 text-amber-50",
49
+ reconnecting: "border-amber-400/18 bg-amber-400/8 text-amber-50",
50
+ disconnected: "border-rose-400/18 bg-rose-400/8 text-rose-50",
51
+ idle: "border-white/10 bg-white/[0.05] text-white/78"
52
+ };
53
+ var statusDotToneByConnection = {
54
+ connected: "bg-emerald-300",
55
+ connecting: "bg-amber-300",
56
+ reconnecting: "bg-amber-300",
57
+ disconnected: "bg-rose-300",
58
+ idle: "bg-white/45"
59
+ };
60
+ var ConnectionStatusPill = ({
61
+ status,
62
+ className
63
+ }) => {
64
+ return /* @__PURE__ */ jsxs(
65
+ "span",
66
+ {
67
+ className: cn(
68
+ "inline-flex shrink-0 items-center gap-1.5 rounded-full border px-2.5 py-1 text-[0.625rem] font-semibold tracking-[0.16em] uppercase",
69
+ statusToneByConnection[status],
70
+ className
71
+ ),
72
+ children: [
73
+ /* @__PURE__ */ jsx(
74
+ "span",
75
+ {
76
+ className: cn(
77
+ "h-1.5 w-1.5 shrink-0 rounded-full",
78
+ statusDotToneByConnection[status]
79
+ ),
80
+ "aria-hidden": true
81
+ }
82
+ ),
83
+ statusLabelByConnection[status]
84
+ ]
85
+ }
86
+ );
87
+ };
88
+
89
+ // src/components/controller-player-name-field.tsx
90
+ import { useCallback, useEffect, useRef, useState } from "react";
91
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
92
+ var LABEL_MAX = 24;
93
+ var DEFAULT_DEBOUNCE_MS = 400;
94
+ var ControllerPlayerNameField = ({
95
+ fieldLabel = "Your name",
96
+ className,
97
+ labelClassName,
98
+ inputClassName,
99
+ debounceMs = DEFAULT_DEBOUNCE_MS
100
+ }) => {
101
+ const controller = useAirJamController();
102
+ const [local, setLocal] = useState("");
103
+ const inputRef = useRef(null);
104
+ const debounceTimerRef = useRef(null);
105
+ const nextPlayerLabel = controller.selfPlayer?.label?.trim() ?? "";
106
+ useEffect(() => {
107
+ if (inputRef.current === document.activeElement) {
108
+ return;
109
+ }
110
+ setLocal(nextPlayerLabel);
111
+ }, [controller.controllerId, nextPlayerLabel]);
112
+ useEffect(
113
+ () => () => {
114
+ if (debounceTimerRef.current !== null) {
115
+ clearTimeout(debounceTimerRef.current);
116
+ }
117
+ },
118
+ []
119
+ );
120
+ const pushRoomName = useCallback(
121
+ (raw) => {
122
+ const trimmed = raw.trim().slice(0, LABEL_MAX);
123
+ if (trimmed.length < 1) {
124
+ return;
125
+ }
126
+ controller.setNickname(trimmed);
127
+ void controller.updatePlayerProfile({ label: trimmed });
128
+ },
129
+ [controller]
130
+ );
131
+ const schedulePush = useCallback(
132
+ (raw) => {
133
+ if (debounceTimerRef.current !== null) {
134
+ clearTimeout(debounceTimerRef.current);
135
+ }
136
+ debounceTimerRef.current = setTimeout(() => {
137
+ debounceTimerRef.current = null;
138
+ pushRoomName(raw);
139
+ }, debounceMs);
140
+ },
141
+ [debounceMs, pushRoomName]
142
+ );
143
+ const connected = controller.connectionStatus === "connected";
144
+ return /* @__PURE__ */ jsxs2("div", { className: cn("min-w-0", className), children: [
145
+ /* @__PURE__ */ jsx2(
146
+ "label",
147
+ {
148
+ className: cn("mb-1 block", labelClassName),
149
+ htmlFor: "airjam-controller-player-name",
150
+ children: fieldLabel
151
+ }
152
+ ),
153
+ /* @__PURE__ */ jsx2(
154
+ "input",
155
+ {
156
+ ref: inputRef,
157
+ id: "airjam-controller-player-name",
158
+ type: "text",
159
+ name: "airjam-controller-player-name",
160
+ autoComplete: "nickname",
161
+ enterKeyHint: "done",
162
+ maxLength: LABEL_MAX,
163
+ disabled: !connected,
164
+ value: local,
165
+ placeholder: connected ? "Enter name" : "Connect to edit",
166
+ className: cn(inputClassName),
167
+ onChange: (event) => {
168
+ const next = event.target.value.slice(0, LABEL_MAX);
169
+ setLocal(next);
170
+ schedulePush(next);
171
+ },
172
+ onBlur: () => {
173
+ if (debounceTimerRef.current !== null) {
174
+ clearTimeout(debounceTimerRef.current);
175
+ debounceTimerRef.current = null;
176
+ }
177
+ const trimmed = local.trim();
178
+ if (trimmed.length < 1) {
179
+ setLocal(nextPlayerLabel);
180
+ return;
181
+ }
182
+ pushRoomName(local);
183
+ }
184
+ }
185
+ )
186
+ ] });
187
+ };
188
+
189
+ // src/components/controller-primary-action.tsx
190
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
191
+ var ControllerPrimaryAction = ({
192
+ label,
193
+ helper,
194
+ icon,
195
+ disabled,
196
+ onPress,
197
+ testId,
198
+ className,
199
+ buttonClassName
200
+ }) => {
201
+ return /* @__PURE__ */ jsx3("div", { className: cn("mt-auto pt-3", className), children: /* @__PURE__ */ jsxs3(
202
+ Button,
203
+ {
204
+ type: "button",
205
+ onClick: onPress,
206
+ disabled,
207
+ "data-testid": testId,
208
+ "aria-label": label,
209
+ title: label,
210
+ className: cn(
211
+ "flex h-auto min-h-18 w-full items-center justify-between rounded-[1.5rem] border border-white/15 px-5 py-4 text-left shadow-lg",
212
+ buttonClassName
213
+ ),
214
+ children: [
215
+ /* @__PURE__ */ jsxs3("div", { className: "min-w-0", children: [
216
+ /* @__PURE__ */ jsx3("div", { className: "truncate text-base font-black tracking-[0.12em] uppercase sm:text-lg", children: label }),
217
+ helper ? /* @__PURE__ */ jsx3("div", { className: "mt-1 text-sm/5 font-medium tracking-normal normal-case opacity-80", children: helper }) : null
218
+ ] }),
219
+ icon ? /* @__PURE__ */ jsx3("div", { className: "ml-4 flex shrink-0 items-center justify-center", children: icon }) : null
220
+ ]
221
+ }
222
+ ) });
223
+ };
224
+
225
+ // src/components/host-mute-button.tsx
226
+ import { Volume2, VolumeX } from "lucide-react";
227
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
228
+ function HostMuteButton({
229
+ muted,
230
+ onToggle,
231
+ className,
232
+ labelClassName,
233
+ mutedLabel = "Unmute",
234
+ unmutedLabel = "Mute"
235
+ }) {
236
+ const label = muted ? mutedLabel : unmutedLabel;
237
+ return /* @__PURE__ */ jsxs4(
238
+ Button,
239
+ {
240
+ type: "button",
241
+ variant: "ghost",
242
+ size: "sm",
243
+ onClick: onToggle,
244
+ "aria-pressed": muted,
245
+ "aria-label": label,
246
+ title: label,
247
+ className: cn(
248
+ "rounded-full border border-white/25 bg-black/35 px-3 text-white backdrop-blur-sm hover:bg-black/55",
249
+ className
250
+ ),
251
+ children: [
252
+ muted ? /* @__PURE__ */ jsx4(VolumeX, { className: "size-4" }) : /* @__PURE__ */ jsx4(Volume2, { className: "size-4" }),
253
+ /* @__PURE__ */ jsx4(
254
+ "span",
255
+ {
256
+ className: cn(
257
+ "text-[11px] font-semibold tracking-[0.16em] uppercase",
258
+ labelClassName
259
+ ),
260
+ children: label
261
+ }
262
+ )
263
+ ]
264
+ }
265
+ );
266
+ }
267
+
268
+ // src/components/join-qr-overlay.tsx
269
+ import { useEffect as useEffect3 } from "react";
270
+
271
+ // src/components/room-qr-code.tsx
272
+ import { toDataURL } from "qrcode";
273
+ import { useEffect as useEffect2, useState as useState2 } from "react";
274
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
275
+ var RoomQrCode = ({
276
+ value,
277
+ size = 180,
278
+ padding = 1,
279
+ foregroundColor = "#111111",
280
+ backgroundColor = "#ffffff",
281
+ errorCorrectionLevel = "M",
282
+ className = "",
283
+ style,
284
+ alt = "Room join QR code"
285
+ }) => {
286
+ const trimmed = value.trim();
287
+ const qrKey = `${trimmed}\0${size}\0${padding}\0${foregroundColor}\0${backgroundColor}\0${errorCorrectionLevel}`;
288
+ const [qrState, setQrState] = useState2({
289
+ key: null,
290
+ dataUrl: null,
291
+ error: false
292
+ });
293
+ useEffect2(() => {
294
+ if (!trimmed) {
295
+ return;
296
+ }
297
+ let cancelled = false;
298
+ void toDataURL(trimmed, {
299
+ width: size,
300
+ margin: padding,
301
+ errorCorrectionLevel,
302
+ color: {
303
+ dark: foregroundColor,
304
+ light: backgroundColor
305
+ }
306
+ }).then((nextUrl) => {
307
+ if (!cancelled) {
308
+ setQrState({
309
+ key: qrKey,
310
+ dataUrl: nextUrl,
311
+ error: false
312
+ });
313
+ }
314
+ }).catch(() => {
315
+ if (!cancelled) {
316
+ setQrState({
317
+ key: qrKey,
318
+ dataUrl: null,
319
+ error: true
320
+ });
321
+ }
322
+ });
323
+ return () => {
324
+ cancelled = true;
325
+ };
326
+ }, [
327
+ backgroundColor,
328
+ errorCorrectionLevel,
329
+ foregroundColor,
330
+ padding,
331
+ size,
332
+ qrKey,
333
+ trimmed
334
+ ]);
335
+ const imageSrc = trimmed && qrState.key === qrKey && qrState.dataUrl ? qrState.dataUrl : null;
336
+ const isLoading = !!trimmed && qrState.key !== qrKey;
337
+ const isUnavailable = !trimmed || qrState.key === qrKey && qrState.error;
338
+ return /* @__PURE__ */ jsx5(
339
+ "div",
340
+ {
341
+ className,
342
+ style: {
343
+ width: size,
344
+ height: size,
345
+ ...style
346
+ },
347
+ "aria-live": "polite",
348
+ "aria-label": alt,
349
+ children: imageSrc ? /* @__PURE__ */ jsx5(
350
+ "img",
351
+ {
352
+ src: imageSrc,
353
+ alt,
354
+ width: size,
355
+ height: size,
356
+ className: "h-full w-full rounded-md object-cover"
357
+ }
358
+ ) : isLoading ? /* @__PURE__ */ jsxs5("div", { className: "flex h-full w-full flex-col items-center justify-center gap-2 rounded-md bg-black/15 text-xs text-white/70", children: [
359
+ /* @__PURE__ */ jsx5("span", { className: "h-5 w-5 animate-spin rounded-full border-2 border-white/20 border-t-white/80" }),
360
+ /* @__PURE__ */ jsx5("span", { children: "Generating QR\u2026" })
361
+ ] }) : /* @__PURE__ */ jsx5("div", { className: "flex h-full w-full items-center justify-center rounded-md bg-black/15 text-xs text-white/70", children: isUnavailable ? "QR unavailable" : "Generating QR\u2026" })
362
+ }
363
+ );
364
+ };
365
+
366
+ // src/components/join-qr-overlay.tsx
367
+ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
368
+ var JoinQrOverlay = ({
369
+ open,
370
+ value,
371
+ roomId,
372
+ onClose,
373
+ title = "Scan to join",
374
+ description = "Scan with your phone to connect as a controller.",
375
+ className,
376
+ panelClassName,
377
+ qrClassName,
378
+ size = 440
379
+ }) => {
380
+ const joinUrlValue = value?.trim() ?? "";
381
+ const hasJoinUrl = joinUrlValue.length > 0;
382
+ useEffect3(() => {
383
+ if (!open || typeof window === "undefined") {
384
+ return;
385
+ }
386
+ const handleKeyDown = (event) => {
387
+ if (event.key === "Escape") {
388
+ onClose?.();
389
+ }
390
+ };
391
+ window.addEventListener("keydown", handleKeyDown);
392
+ return () => {
393
+ window.removeEventListener("keydown", handleKeyDown);
394
+ };
395
+ }, [onClose, open]);
396
+ if (!open) {
397
+ return null;
398
+ }
399
+ const handlePanelClick = (event) => {
400
+ event.stopPropagation();
401
+ };
402
+ return /* @__PURE__ */ jsx6(
403
+ "div",
404
+ {
405
+ role: "dialog",
406
+ "aria-modal": "true",
407
+ "aria-label": roomId ? `Join room ${roomId}` : title,
408
+ className: cn(
409
+ "absolute inset-0 z-50 flex items-center justify-center bg-black/82 px-6 py-8 backdrop-blur-md",
410
+ className
411
+ ),
412
+ onClick: onClose,
413
+ children: /* @__PURE__ */ jsxs6(
414
+ "div",
415
+ {
416
+ className: cn(
417
+ "flex w-full max-w-xl flex-col items-center gap-6 px-6 py-7 text-center",
418
+ shellPanelClassName,
419
+ panelClassName
420
+ ),
421
+ onClick: handlePanelClick,
422
+ children: [
423
+ /* @__PURE__ */ jsxs6("div", { className: "space-y-1", children: [
424
+ /* @__PURE__ */ jsx6("p", { className: "text-[0.6875rem] font-semibold tracking-[0.22em] text-white/52 uppercase", children: title }),
425
+ roomId ? /* @__PURE__ */ jsx6("p", { className: "text-3xl font-semibold tracking-[0.12em] text-white uppercase tabular-nums", children: roomId }) : null
426
+ ] }),
427
+ hasJoinUrl ? /* @__PURE__ */ jsx6(
428
+ RoomQrCode,
429
+ {
430
+ value: joinUrlValue,
431
+ size,
432
+ padding: 2,
433
+ foregroundColor: "#111827",
434
+ backgroundColor: "#ffffff",
435
+ className: cn("rounded-xl bg-white shadow-sm", qrClassName),
436
+ style: {
437
+ width: "min(72vw, 26rem)",
438
+ height: "auto",
439
+ aspectRatio: "1 / 1"
440
+ },
441
+ alt: roomId ? `QR code to join room ${roomId}` : "QR code to join as a controller"
442
+ }
443
+ ) : /* @__PURE__ */ jsx6("div", { className: "flex w-full max-w-[26rem] items-center justify-center rounded-xl border border-white/12 bg-white/6 px-5 py-10 text-sm leading-6 text-white/68", children: "Join URL unavailable right now." }),
444
+ /* @__PURE__ */ jsx6("p", { className: "max-w-md text-sm leading-6 text-white/68", children: description }),
445
+ /* @__PURE__ */ jsx6(
446
+ Button,
447
+ {
448
+ type: "button",
449
+ variant: "outline",
450
+ onClick: onClose,
451
+ className: cn("rounded-2xl px-5", shellUtilityButtonClassName),
452
+ children: "Close"
453
+ }
454
+ )
455
+ ]
456
+ }
457
+ )
458
+ }
459
+ );
460
+ };
461
+
462
+ // src/components/join-url-action-buttons.tsx
463
+ import { Check, Copy, ExternalLink, QrCode } from "lucide-react";
464
+ import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
465
+ var JoinUrlActionButtons = ({
466
+ hasValue,
467
+ copied = false,
468
+ onCopy,
469
+ onOpen,
470
+ qrVisible = false,
471
+ onToggleQr,
472
+ className,
473
+ buttonClassName
474
+ }) => {
475
+ const showsQrButton = typeof onToggleQr === "function";
476
+ return /* @__PURE__ */ jsxs7(
477
+ "div",
478
+ {
479
+ className: cn(
480
+ "grid w-full gap-2",
481
+ showsQrButton ? "grid-cols-3" : "grid-cols-2",
482
+ className
483
+ ),
484
+ children: [
485
+ /* @__PURE__ */ jsxs7(
486
+ Button,
487
+ {
488
+ type: "button",
489
+ variant: "outline",
490
+ disabled: !hasValue || !onCopy,
491
+ onClick: onCopy,
492
+ "aria-label": copied ? "Copied join link" : "Copy join link",
493
+ title: copied ? "Copied" : "Copy join link",
494
+ className: cn(
495
+ "h-11 min-w-0 justify-center rounded-2xl px-3 text-sm",
496
+ shellUtilityButtonClassName,
497
+ buttonClassName
498
+ ),
499
+ children: [
500
+ copied ? /* @__PURE__ */ jsx7(Check, { className: "h-4 w-4", "aria-hidden": true }) : /* @__PURE__ */ jsx7(Copy, { className: "h-4 w-4", "aria-hidden": true }),
501
+ /* @__PURE__ */ jsx7("span", { className: "truncate", children: copied ? "Copied" : "Copy" })
502
+ ]
503
+ }
504
+ ),
505
+ /* @__PURE__ */ jsxs7(
506
+ Button,
507
+ {
508
+ type: "button",
509
+ variant: "outline",
510
+ disabled: !hasValue || !onOpen,
511
+ onClick: onOpen,
512
+ "aria-label": "Open join link",
513
+ title: "Open join link",
514
+ className: cn(
515
+ "h-11 min-w-0 justify-center rounded-2xl px-3 text-sm",
516
+ shellUtilityButtonClassName,
517
+ buttonClassName
518
+ ),
519
+ children: [
520
+ /* @__PURE__ */ jsx7(ExternalLink, { className: "h-4 w-4", "aria-hidden": true }),
521
+ /* @__PURE__ */ jsx7("span", { className: "truncate", children: "New tab" })
522
+ ]
523
+ }
524
+ ),
525
+ showsQrButton ? /* @__PURE__ */ jsxs7(
526
+ Button,
527
+ {
528
+ type: "button",
529
+ variant: "outline",
530
+ disabled: !hasValue,
531
+ "aria-pressed": qrVisible,
532
+ onClick: onToggleQr,
533
+ "aria-label": qrVisible ? "Hide join QR" : "Show join QR",
534
+ title: qrVisible ? "Hide join QR" : "Show join QR",
535
+ className: cn(
536
+ "h-11 min-w-0 justify-center rounded-2xl px-3 text-sm",
537
+ shellUtilityButtonClassName,
538
+ buttonClassName
539
+ ),
540
+ children: [
541
+ /* @__PURE__ */ jsx7(QrCode, { className: "h-4 w-4", "aria-hidden": true }),
542
+ /* @__PURE__ */ jsx7("span", { className: "truncate", children: qrVisible ? "Hide QR" : "QR code" })
543
+ ]
544
+ }
545
+ ) : null
546
+ ]
547
+ }
548
+ );
549
+ };
550
+
551
+ // src/components/join-url-field.tsx
552
+ import { useId } from "react";
553
+ import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
554
+ var JoinUrlField = ({
555
+ value,
556
+ label = "Controller link",
557
+ helperText,
558
+ className,
559
+ inputClassName,
560
+ inputId,
561
+ inputName = "airjam-controller-link"
562
+ }) => {
563
+ const hasValue = Boolean(value && value.trim().length > 0);
564
+ const generatedInputId = useId();
565
+ const resolvedInputId = inputId ?? generatedInputId;
566
+ return /* @__PURE__ */ jsxs8("div", { className: cn("space-y-2.5", className), children: [
567
+ /* @__PURE__ */ jsx8("label", { className: shellLabelClassName, htmlFor: resolvedInputId, children: label }),
568
+ /* @__PURE__ */ jsx8(
569
+ "input",
570
+ {
571
+ id: resolvedInputId,
572
+ name: inputName,
573
+ type: "text",
574
+ readOnly: true,
575
+ value: value ?? "",
576
+ placeholder: hasValue ? void 0 : "Generating join link...",
577
+ "aria-label": typeof label === "string" ? label : "Controller join link",
578
+ className: cn(shellFieldClassName, inputClassName)
579
+ }
580
+ ),
581
+ helperText ? /* @__PURE__ */ jsx8("div", { className: shellHelperTextClassName, children: helperText }) : null
582
+ ] });
583
+ };
584
+
585
+ // src/components/join-url-controls.tsx
586
+ import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
587
+ var JoinUrlControls = ({
588
+ value,
589
+ label = "Controller link",
590
+ helperText,
591
+ copied = false,
592
+ onCopy,
593
+ onOpen,
594
+ qrVisible = false,
595
+ onToggleQr,
596
+ className,
597
+ inputClassName,
598
+ buttonClassName
599
+ }) => {
600
+ const hasValue = Boolean(value && value.trim().length > 0);
601
+ return /* @__PURE__ */ jsx9("div", { className: cn("w-full space-y-3", className), children: /* @__PURE__ */ jsxs9("div", { className: "flex flex-col gap-3", children: [
602
+ /* @__PURE__ */ jsx9(
603
+ JoinUrlField,
604
+ {
605
+ value,
606
+ label,
607
+ helperText,
608
+ className: "w-full min-w-0",
609
+ inputClassName
610
+ }
611
+ ),
612
+ /* @__PURE__ */ jsx9(
613
+ JoinUrlActionButtons,
614
+ {
615
+ hasValue,
616
+ copied,
617
+ onCopy,
618
+ onOpen,
619
+ qrVisible,
620
+ onToggleQr,
621
+ className: "w-full",
622
+ buttonClassName
623
+ }
624
+ )
625
+ ] }) });
626
+ };
627
+
628
+ // src/components/lifecycle-action-group.tsx
629
+ import { House, Pause, Play, RotateCcw } from "lucide-react";
630
+
631
+ // src/hooks/use-lifecycle-action-group-model.ts
632
+ var useLifecycleActionGroupModel = ({
633
+ phase,
634
+ runtimeState,
635
+ canInteract = true,
636
+ onStart,
637
+ onTogglePause,
638
+ onBackToLobby,
639
+ onRestart,
640
+ startLabel = "Start",
641
+ restartLabel = "Restart",
642
+ backLabel = "Back to Lobby",
643
+ pauseLabel = "Pause",
644
+ resumeLabel = "Resume"
645
+ }) => {
646
+ const isPaused = runtimeState === "paused";
647
+ const actions = [];
648
+ if (phase === "lobby" && onStart) {
649
+ actions.push({
650
+ kind: "start",
651
+ label: startLabel,
652
+ disabled: !canInteract,
653
+ tone: "primary",
654
+ onPress: onStart
655
+ });
656
+ }
657
+ if (phase === "playing" && onTogglePause) {
658
+ actions.push({
659
+ kind: "pause-toggle",
660
+ label: isPaused ? resumeLabel : pauseLabel,
661
+ disabled: !canInteract,
662
+ tone: "secondary",
663
+ onPress: onTogglePause
664
+ });
665
+ }
666
+ if (phase === "ended" && (onRestart || onStart)) {
667
+ actions.push({
668
+ kind: "restart",
669
+ label: restartLabel,
670
+ disabled: !canInteract,
671
+ tone: "primary",
672
+ onPress: onRestart ?? onStart
673
+ });
674
+ }
675
+ if (phase !== "lobby" && onBackToLobby) {
676
+ actions.push({
677
+ kind: "back-to-lobby",
678
+ label: backLabel,
679
+ disabled: !canInteract,
680
+ tone: "secondary",
681
+ onPress: onBackToLobby
682
+ });
683
+ }
684
+ return { isPaused, actions };
685
+ };
686
+
687
+ // src/components/lifecycle-action-group.tsx
688
+ import { jsx as jsx10 } from "react/jsx-runtime";
689
+ var LifecycleActionGroup = ({
690
+ phase,
691
+ runtimeState,
692
+ canInteract = true,
693
+ onStart,
694
+ onTogglePause,
695
+ onBackToLobby,
696
+ onRestart,
697
+ startLabel = "Start",
698
+ restartLabel = "Restart",
699
+ backLabel = "Back to Lobby",
700
+ presentation = "pill",
701
+ visibleKinds,
702
+ className,
703
+ buttonClassName
704
+ }) => {
705
+ const { actions: allActions } = useLifecycleActionGroupModel({
706
+ phase,
707
+ runtimeState,
708
+ canInteract,
709
+ onStart,
710
+ onTogglePause,
711
+ onBackToLobby,
712
+ onRestart,
713
+ startLabel,
714
+ restartLabel,
715
+ backLabel
716
+ });
717
+ const actions = visibleKinds ? allActions.filter((action) => visibleKinds.includes(action.kind)) : allActions;
718
+ if (actions.length === 0) {
719
+ return null;
720
+ }
721
+ const renderIcon = (kind, label) => {
722
+ switch (kind) {
723
+ case "start":
724
+ return /* @__PURE__ */ jsx10(Play, { "aria-hidden": true, className: "size-4.5" });
725
+ case "pause-toggle":
726
+ return label.toLowerCase() === "resume" ? /* @__PURE__ */ jsx10(Play, { "aria-hidden": true, className: "size-4.5" }) : /* @__PURE__ */ jsx10(Pause, { "aria-hidden": true, className: "size-4.5" });
727
+ case "restart":
728
+ return /* @__PURE__ */ jsx10(RotateCcw, { "aria-hidden": true, className: "size-4.5" });
729
+ case "back-to-lobby":
730
+ return /* @__PURE__ */ jsx10(House, { "aria-hidden": true, className: "size-4.5" });
731
+ }
732
+ };
733
+ return /* @__PURE__ */ jsx10(
734
+ "div",
735
+ {
736
+ className: cn(
737
+ "flex min-w-0 flex-nowrap items-center justify-end gap-1.5 overflow-x-auto",
738
+ className
739
+ ),
740
+ children: actions.map((action) => /* @__PURE__ */ jsx10(
741
+ Button,
742
+ {
743
+ type: "button",
744
+ variant: presentation === "icon" ? action.tone === "primary" ? "secondary" : "ghost" : action.tone === "primary" ? "default" : "outline",
745
+ size: presentation === "icon" ? "icon-sm" : void 0,
746
+ onClick: action.onPress,
747
+ disabled: action.disabled,
748
+ "aria-label": action.label,
749
+ title: action.label,
750
+ className: cn(
751
+ presentation === "icon" ? action.tone === "primary" ? "size-9 shrink-0 rounded-full border border-white/20 bg-white text-black hover:bg-white/90 sm:size-10" : "size-9 shrink-0 rounded-full border border-white/12 bg-white/6 text-white hover:bg-white/12 sm:size-10" : action.tone === "primary" ? "h-8 shrink-0 rounded-full border border-white/15 bg-white px-3 py-0 text-[9px] font-semibold tracking-[0.12em] whitespace-nowrap text-black uppercase hover:bg-white/90 sm:h-9 sm:px-4 sm:text-[10px] sm:tracking-[0.16em]" : "h-8 shrink-0 rounded-full border-white/15 bg-white/5 px-3 py-0 text-[9px] font-semibold tracking-[0.12em] whitespace-nowrap text-white uppercase hover:bg-white/10 sm:h-9 sm:px-4 sm:text-[10px] sm:tracking-[0.16em]",
752
+ buttonClassName
753
+ ),
754
+ children: presentation === "icon" ? renderIcon(action.kind, action.label) : action.label
755
+ },
756
+ action.kind
757
+ ))
758
+ }
759
+ );
760
+ };
761
+
762
+ // src/components/player-avatar.tsx
763
+ import { Bot } from "lucide-react";
764
+
765
+ // src/utils/player-avatar-url.ts
766
+ var DIEBEAR_ADVENTURER_NEUTRAL_SVG_BASE = "https://api.dicebear.com/9.x/adventurer-neutral/svg";
767
+ var AIRJAM_DEFAULT_AVATAR_SEEDS = [
768
+ "Aiko",
769
+ "Brayden",
770
+ "Caleb",
771
+ "Dylan",
772
+ "Emery",
773
+ "Finley",
774
+ "Grayson",
775
+ "Harper"
776
+ ];
777
+ var resolvePlayerAvatarSeed = (player) => {
778
+ const raw = player.avatarId?.trim();
779
+ if (!raw) {
780
+ return player.id;
781
+ }
782
+ const match = /^aj-(\d+)$/.exec(raw);
783
+ if (match) {
784
+ const index = Number(match[1]) - 1;
785
+ if (index >= 0 && index < AIRJAM_DEFAULT_AVATAR_SEEDS.length) {
786
+ return AIRJAM_DEFAULT_AVATAR_SEEDS[index];
787
+ }
788
+ }
789
+ return raw;
790
+ };
791
+ var getDiceBearAdventurerNeutralUrl = (seed) => `${DIEBEAR_ADVENTURER_NEUTRAL_SVG_BASE}?seed=${encodeURIComponent(seed)}`;
792
+ var getPlayerAvatarImageUrl = (player) => getDiceBearAdventurerNeutralUrl(resolvePlayerAvatarSeed(player));
793
+
794
+ // src/components/player-avatar.tsx
795
+ import { jsx as jsx11 } from "react/jsx-runtime";
796
+ var hexToRgba = (hex, opacity) => {
797
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
798
+ if (!result) return `rgba(0, 0, 0, ${opacity})`;
799
+ const r = parseInt(result[1], 16);
800
+ const g = parseInt(result[2], 16);
801
+ const b = parseInt(result[3], 16);
802
+ return `rgba(${r}, ${g}, ${b}, ${opacity})`;
803
+ };
804
+ var PlayerAvatar = ({
805
+ player,
806
+ isBot = false,
807
+ size = "md",
808
+ className = ""
809
+ }) => {
810
+ const accentColor = player.color || "hsl(var(--border))";
811
+ const sizeClasses = {
812
+ sm: "h-9 w-9 border-2",
813
+ md: "h-12 w-12 border-4",
814
+ lg: "h-16 w-16 border-4"
815
+ };
816
+ const shadowStyles = {
817
+ sm: player.color ? `inset 0 0 4px rgba(0, 0, 0, 0.2), 0 0 8px ${hexToRgba(player.color, 0.4)}` : "inset 0 0 4px rgba(0, 0, 0, 0.2)",
818
+ md: player.color ? `inset 0 0 10px rgba(0, 0, 0, 0.4), 0 0 20px ${hexToRgba(player.color, 0.6)}, 0 0 10px ${hexToRgba(player.color, 0.8)}` : "inset 0 0 10px rgba(0, 0, 0, 0.4), 0 0 20px hsl(var(--border) / 0.5)",
819
+ lg: player.color ? `inset 0 0 12px rgba(0, 0, 0, 0.4), 0 0 24px ${hexToRgba(player.color, 0.6)}, 0 0 12px ${hexToRgba(player.color, 0.8)}` : "inset 0 0 12px rgba(0, 0, 0, 0.4), 0 0 24px hsl(var(--border) / 0.5)"
820
+ };
821
+ const iconSizeClasses = {
822
+ sm: "h-4 w-4",
823
+ md: "h-5 w-5",
824
+ lg: "h-6 w-6"
825
+ };
826
+ const shellClassName = cn(
827
+ "shrink-0 rounded-full shadow-lg",
828
+ sizeClasses[size],
829
+ className
830
+ );
831
+ if (isBot) {
832
+ return /* @__PURE__ */ jsx11(
833
+ "div",
834
+ {
835
+ role: "img",
836
+ "aria-label": player.label,
837
+ className: cn(
838
+ "bg-secondary/40 flex items-center justify-center",
839
+ shellClassName
840
+ ),
841
+ style: {
842
+ borderColor: accentColor,
843
+ color: accentColor,
844
+ boxShadow: shadowStyles[size]
845
+ },
846
+ children: /* @__PURE__ */ jsx11(Bot, { "aria-hidden": "true", className: iconSizeClasses[size] })
847
+ }
848
+ );
849
+ }
850
+ return /* @__PURE__ */ jsx11(
851
+ "img",
852
+ {
853
+ src: getPlayerAvatarImageUrl(player),
854
+ alt: player.label,
855
+ className: cn("bg-secondary/30", shellClassName),
856
+ style: {
857
+ borderColor: accentColor,
858
+ boxShadow: shadowStyles[size]
859
+ }
860
+ }
861
+ );
862
+ };
863
+
864
+ // src/components/player-avatar-strip.tsx
865
+ import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
866
+ var overflowSizeClasses = {
867
+ sm: "h-9 w-9 min-h-9 min-w-9 text-[0.625rem]",
868
+ md: "h-12 w-12 min-h-12 min-w-12 text-[11px]",
869
+ lg: "h-16 w-16 min-h-16 min-w-16 text-xs"
870
+ };
871
+ var PlayerAvatarStrip = ({
872
+ players,
873
+ maxVisible = 4,
874
+ size = "sm",
875
+ className,
876
+ avatarClassName = "",
877
+ overflowBadgeClassName = ""
878
+ }) => {
879
+ const visible = players.slice(0, maxVisible);
880
+ const overflow = Math.max(0, players.length - maxVisible);
881
+ return /* @__PURE__ */ jsxs10("div", { className: cn("flex items-center -space-x-2", className), children: [
882
+ visible.map((player) => /* @__PURE__ */ jsx12(
883
+ PlayerAvatar,
884
+ {
885
+ player,
886
+ size,
887
+ className: avatarClassName
888
+ },
889
+ player.id
890
+ )),
891
+ overflow > 0 && /* @__PURE__ */ jsxs10(
892
+ "div",
893
+ {
894
+ className: cn(
895
+ "bg-secondary/50 text-foreground flex shrink-0 items-center justify-center rounded-full border-2 border-[hsl(var(--border))] font-semibold tabular-nums shadow-sm",
896
+ overflowSizeClasses[size],
897
+ overflowBadgeClassName
898
+ ),
899
+ "aria-label": `${overflow} more players`,
900
+ children: [
901
+ "+",
902
+ overflow
903
+ ]
904
+ }
905
+ )
906
+ ] });
907
+ };
908
+
909
+ // src/components/runtime-shell-header.tsx
910
+ import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
911
+ var RuntimeShellHeader = ({
912
+ connectionStatus,
913
+ leftSlot,
914
+ rightSlot,
915
+ className
916
+ }) => {
917
+ return /* @__PURE__ */ jsxs11(
918
+ "header",
919
+ {
920
+ className: cn(
921
+ "flex min-h-16 items-center gap-2.5 px-3 py-2.5 sm:px-4",
922
+ shellHeaderClassName,
923
+ className
924
+ ),
925
+ children: [
926
+ /* @__PURE__ */ jsx13("div", { className: "min-w-0 flex-1", children: leftSlot }),
927
+ /* @__PURE__ */ jsxs11("div", { className: "flex shrink-0 items-center gap-2.5", children: [
928
+ /* @__PURE__ */ jsx13(ConnectionStatusPill, { status: connectionStatus }),
929
+ rightSlot ? /* @__PURE__ */ jsx13("div", { className: "flex items-center justify-end", children: rightSlot }) : null
930
+ ] })
931
+ ]
932
+ }
933
+ );
934
+ };
935
+
936
+ // src/components/surface-viewport.tsx
937
+ import { useEffect as useEffect4, useMemo, useRef as useRef2, useState as useState3 } from "react";
938
+
939
+ // src/runtime/controller-presentation.ts
940
+ var publishEmbeddedControllerPresentation = (orientation) => {
941
+ if (typeof window === "undefined" || window.parent === window) {
942
+ return;
943
+ }
944
+ const runtimeParams = readEmbeddedControllerRuntimeParams();
945
+ if (!runtimeParams) {
946
+ return;
947
+ }
948
+ window.parent.postMessage(
949
+ createControllerPresentationSyncMessage({
950
+ orientation,
951
+ arcadeSurface: runtimeParams.arcadeSurface
952
+ }),
953
+ runtimeParams.topology.embedParentOrigin ?? "*"
954
+ );
955
+ };
956
+
957
+ // src/components/surface-orientation-layout.ts
958
+ var AIRJAM_SAFE_AREA_TOP = "env(safe-area-inset-top, 0px)";
959
+ var AIRJAM_SAFE_AREA_RIGHT = "env(safe-area-inset-right, 0px)";
960
+ var AIRJAM_SAFE_AREA_BOTTOM = "env(safe-area-inset-bottom, 0px)";
961
+ var AIRJAM_SAFE_AREA_LEFT = "env(safe-area-inset-left, 0px)";
962
+ var AIRJAM_SAFE_VIEWPORT_WIDTH = `calc(100dvw - ${AIRJAM_SAFE_AREA_LEFT} - ${AIRJAM_SAFE_AREA_RIGHT})`;
963
+ var AIRJAM_SAFE_VIEWPORT_HEIGHT = `calc(100dvh - ${AIRJAM_SAFE_AREA_TOP} - ${AIRJAM_SAFE_AREA_BOTTOM})`;
964
+ var createSurfaceViewportOuterStyle = () => ({
965
+ ["--airjam-safe-area-top"]: AIRJAM_SAFE_AREA_TOP,
966
+ ["--airjam-safe-area-right"]: AIRJAM_SAFE_AREA_RIGHT,
967
+ ["--airjam-safe-area-bottom"]: AIRJAM_SAFE_AREA_BOTTOM,
968
+ ["--airjam-safe-area-left"]: AIRJAM_SAFE_AREA_LEFT,
969
+ ["--airjam-safe-viewport-width"]: AIRJAM_SAFE_VIEWPORT_WIDTH,
970
+ ["--airjam-safe-viewport-height"]: AIRJAM_SAFE_VIEWPORT_HEIGHT
971
+ });
972
+ var resolveForcedOrientationFrameStyle = (desired, needsRotation) => {
973
+ if (!needsRotation) {
974
+ return {
975
+ position: "absolute",
976
+ top: AIRJAM_SAFE_AREA_TOP,
977
+ left: AIRJAM_SAFE_AREA_LEFT,
978
+ width: AIRJAM_SAFE_VIEWPORT_WIDTH,
979
+ height: AIRJAM_SAFE_VIEWPORT_HEIGHT,
980
+ overflow: "hidden"
981
+ };
982
+ }
983
+ if (desired === "landscape") {
984
+ return {
985
+ position: "absolute",
986
+ top: AIRJAM_SAFE_AREA_TOP,
987
+ left: AIRJAM_SAFE_AREA_LEFT,
988
+ width: AIRJAM_SAFE_VIEWPORT_HEIGHT,
989
+ height: AIRJAM_SAFE_VIEWPORT_WIDTH,
990
+ overflow: "hidden",
991
+ transformOrigin: "top left",
992
+ transform: `translateX(${AIRJAM_SAFE_VIEWPORT_WIDTH}) rotate(90deg)`
993
+ };
994
+ }
995
+ return {
996
+ position: "absolute",
997
+ top: AIRJAM_SAFE_AREA_TOP,
998
+ left: AIRJAM_SAFE_AREA_LEFT,
999
+ width: AIRJAM_SAFE_VIEWPORT_HEIGHT,
1000
+ height: AIRJAM_SAFE_VIEWPORT_WIDTH,
1001
+ overflow: "hidden",
1002
+ transformOrigin: "top left",
1003
+ transform: `translateY(${AIRJAM_SAFE_VIEWPORT_HEIGHT}) rotate(-90deg)`
1004
+ };
1005
+ };
1006
+
1007
+ // src/components/surface-viewport-layout.ts
1008
+ var CONTROLLER_REFERENCE_SIZE = {
1009
+ portrait: {
1010
+ width: 412,
1011
+ height: 915
1012
+ },
1013
+ landscape: {
1014
+ width: 915,
1015
+ height: 412
1016
+ }
1017
+ };
1018
+ var HOST_REFERENCE_SIZE = {
1019
+ portrait: {
1020
+ width: 900,
1021
+ height: 1600
1022
+ },
1023
+ landscape: {
1024
+ width: 1600,
1025
+ height: 900
1026
+ }
1027
+ };
1028
+ var resolveSurfaceViewportScopeReferenceSize = (sessionScope) => {
1029
+ if (sessionScope === "controller") {
1030
+ return CONTROLLER_REFERENCE_SIZE;
1031
+ }
1032
+ if (sessionScope === "host") {
1033
+ return HOST_REFERENCE_SIZE;
1034
+ }
1035
+ return null;
1036
+ };
1037
+ var resolveSurfaceViewportReferenceSize = ({
1038
+ sessionScope,
1039
+ designWidth,
1040
+ designHeight,
1041
+ orientation,
1042
+ availableWidth,
1043
+ availableHeight
1044
+ }) => {
1045
+ if (typeof designWidth === "number" && Number.isFinite(designWidth) && designWidth > 0 && typeof designHeight === "number" && Number.isFinite(designHeight) && designHeight > 0) {
1046
+ return {
1047
+ width: designWidth,
1048
+ height: designHeight
1049
+ };
1050
+ }
1051
+ const scopedReferenceSize = resolveSurfaceViewportScopeReferenceSize(sessionScope);
1052
+ if (scopedReferenceSize) {
1053
+ return scopedReferenceSize[orientation];
1054
+ }
1055
+ return {
1056
+ width: Math.max(availableWidth, 1),
1057
+ height: Math.max(availableHeight, 1)
1058
+ };
1059
+ };
1060
+ var SURFACE_VIEWPORT_TEXT_SIZE_BASES = {
1061
+ xs: "0.75rem",
1062
+ sm: "0.875rem",
1063
+ base: "1rem",
1064
+ lg: "1.125rem",
1065
+ xl: "1.25rem",
1066
+ "2xl": "1.5rem",
1067
+ "3xl": "1.875rem",
1068
+ "4xl": "2.25rem",
1069
+ "5xl": "3rem",
1070
+ "6xl": "3.75rem",
1071
+ "7xl": "4.5rem",
1072
+ "8xl": "6rem",
1073
+ "9xl": "8rem"
1074
+ };
1075
+ var SURFACE_VIEWPORT_CONTAINER_BASES = {
1076
+ "3xs": "16rem",
1077
+ "2xs": "18rem",
1078
+ xs: "20rem",
1079
+ sm: "24rem",
1080
+ md: "28rem",
1081
+ lg: "32rem",
1082
+ xl: "36rem",
1083
+ "2xl": "42rem",
1084
+ "3xl": "48rem",
1085
+ "4xl": "56rem",
1086
+ "5xl": "64rem",
1087
+ "6xl": "72rem",
1088
+ "7xl": "80rem"
1089
+ };
1090
+ var SURFACE_VIEWPORT_RADIUS_BASES = {
1091
+ xs: "0.125rem",
1092
+ sm: "0.375rem",
1093
+ md: "0.5rem",
1094
+ lg: "0.625rem",
1095
+ xl: "0.875rem",
1096
+ "2xl": "1rem",
1097
+ "3xl": "1.5rem",
1098
+ "4xl": "2rem"
1099
+ };
1100
+ var resolveSurfaceViewportAvailableSize = ({
1101
+ safeViewportWidth,
1102
+ safeViewportHeight,
1103
+ orientation,
1104
+ needsRotation
1105
+ }) => {
1106
+ if (!orientation || !needsRotation) {
1107
+ return {
1108
+ width: safeViewportWidth,
1109
+ height: safeViewportHeight
1110
+ };
1111
+ }
1112
+ return {
1113
+ width: safeViewportHeight,
1114
+ height: safeViewportWidth
1115
+ };
1116
+ };
1117
+ var resolveSurfaceViewportScale = ({
1118
+ availableWidth,
1119
+ availableHeight,
1120
+ referenceWidth,
1121
+ referenceHeight,
1122
+ scaleMode = "fit",
1123
+ uiScaleMultiplier = 1,
1124
+ minScale,
1125
+ maxScale
1126
+ }) => {
1127
+ const safeAvailableWidth = Math.max(availableWidth, 1);
1128
+ const safeAvailableHeight = Math.max(availableHeight, 1);
1129
+ const safeReferenceWidth = Math.max(referenceWidth, 1);
1130
+ const safeReferenceHeight = Math.max(referenceHeight, 1);
1131
+ const widthScale = safeAvailableWidth / safeReferenceWidth;
1132
+ const heightScale = safeAvailableHeight / safeReferenceHeight;
1133
+ const baseScale = scaleMode === "width" ? widthScale : scaleMode === "height" ? heightScale : Math.min(widthScale, heightScale);
1134
+ let scale = baseScale * uiScaleMultiplier;
1135
+ if (typeof minScale === "number" && Number.isFinite(minScale)) {
1136
+ scale = Math.max(scale, minScale);
1137
+ }
1138
+ if (typeof maxScale === "number" && Number.isFinite(maxScale)) {
1139
+ scale = Math.min(scale, maxScale);
1140
+ }
1141
+ return scale;
1142
+ };
1143
+ var createScaledVariableValue = (baseValue) => `calc(${baseValue} * var(--airjam-ui-scale))`;
1144
+ var createSurfaceViewportScaleStyle = ({
1145
+ scale,
1146
+ referenceWidth,
1147
+ referenceHeight
1148
+ }) => {
1149
+ const style = {
1150
+ position: "relative",
1151
+ width: "100%",
1152
+ height: "100%",
1153
+ overflow: "hidden",
1154
+ fontSize: createScaledVariableValue("1rem"),
1155
+ "--airjam-ui-scale": String(scale),
1156
+ "--airjam-ui-rem": createScaledVariableValue("1rem"),
1157
+ "--airjam-reference-width": `${referenceWidth}px`,
1158
+ "--airjam-reference-height": `${referenceHeight}px`,
1159
+ "--spacing": createScaledVariableValue("0.25rem"),
1160
+ "--radius": createScaledVariableValue("0.625rem")
1161
+ };
1162
+ for (const [name, baseValue] of Object.entries(
1163
+ SURFACE_VIEWPORT_TEXT_SIZE_BASES
1164
+ )) {
1165
+ style[`--text-${name}`] = createScaledVariableValue(baseValue);
1166
+ }
1167
+ for (const [name, baseValue] of Object.entries(
1168
+ SURFACE_VIEWPORT_CONTAINER_BASES
1169
+ )) {
1170
+ style[`--container-${name}`] = createScaledVariableValue(baseValue);
1171
+ }
1172
+ for (const [name, baseValue] of Object.entries(
1173
+ SURFACE_VIEWPORT_RADIUS_BASES
1174
+ )) {
1175
+ style[`--radius-${name}`] = createScaledVariableValue(baseValue);
1176
+ }
1177
+ return style;
1178
+ };
1179
+
1180
+ // src/components/surface-viewport.tsx
1181
+ import { jsx as jsx14 } from "react/jsx-runtime";
1182
+ var readLayoutViewportSize = () => {
1183
+ if (typeof window === "undefined") {
1184
+ return { width: 0, height: 0 };
1185
+ }
1186
+ return {
1187
+ width: window.innerWidth,
1188
+ height: window.innerHeight
1189
+ };
1190
+ };
1191
+ var isTextEntryElement = (element) => {
1192
+ if (!element) {
1193
+ return false;
1194
+ }
1195
+ if (element instanceof HTMLTextAreaElement) {
1196
+ return true;
1197
+ }
1198
+ if (element instanceof HTMLInputElement) {
1199
+ return ![
1200
+ "button",
1201
+ "checkbox",
1202
+ "color",
1203
+ "file",
1204
+ "hidden",
1205
+ "image",
1206
+ "radio",
1207
+ "range",
1208
+ "reset",
1209
+ "submit"
1210
+ ].includes(element.type);
1211
+ }
1212
+ return element instanceof HTMLElement && element.isContentEditable;
1213
+ };
1214
+ var isKeyboardResize = (previous, next) => {
1215
+ if (!previous || typeof document === "undefined") {
1216
+ return false;
1217
+ }
1218
+ if (!isTextEntryElement(document.activeElement)) {
1219
+ return false;
1220
+ }
1221
+ const sameWidth = Math.abs(previous.width - next.width) <= 2;
1222
+ const heightShrank = next.height < previous.height;
1223
+ return sameWidth && heightShrank;
1224
+ };
1225
+ var getOrientation = ({
1226
+ width,
1227
+ height
1228
+ }) => {
1229
+ if (typeof window !== "undefined") {
1230
+ if (window.matchMedia) {
1231
+ if (window.matchMedia("(orientation: portrait)").matches) {
1232
+ return "portrait";
1233
+ }
1234
+ if (window.matchMedia("(orientation: landscape)").matches) {
1235
+ return "landscape";
1236
+ }
1237
+ }
1238
+ if (window.screen?.orientation?.type) {
1239
+ if (window.screen.orientation.type.startsWith("portrait")) {
1240
+ return "portrait";
1241
+ }
1242
+ if (window.screen.orientation.type.startsWith("landscape")) {
1243
+ return "landscape";
1244
+ }
1245
+ }
1246
+ }
1247
+ if (width > 0 && height > 0) {
1248
+ return width >= height ? "landscape" : "portrait";
1249
+ }
1250
+ return width >= height ? "landscape" : "portrait";
1251
+ };
1252
+ var SurfaceViewport = ({
1253
+ children,
1254
+ orientation,
1255
+ lockOnGesture = true,
1256
+ className,
1257
+ contentClassName,
1258
+ style,
1259
+ designWidth,
1260
+ designHeight,
1261
+ uiScaleMultiplier,
1262
+ minScale,
1263
+ maxScale
1264
+ }) => {
1265
+ const [viewport, setViewport] = useState3(null);
1266
+ const viewportRef = useRef2(null);
1267
+ const sessionScope = useSessionScope();
1268
+ useEffect4(() => {
1269
+ if (typeof window === "undefined") {
1270
+ return;
1271
+ }
1272
+ const updateViewport = () => {
1273
+ const nextViewport = readLayoutViewportSize();
1274
+ if (isKeyboardResize(viewportRef.current, nextViewport)) {
1275
+ return;
1276
+ }
1277
+ viewportRef.current = nextViewport;
1278
+ setViewport(nextViewport);
1279
+ };
1280
+ updateViewport();
1281
+ window.addEventListener("resize", updateViewport);
1282
+ window.visualViewport?.addEventListener("resize", updateViewport);
1283
+ window.addEventListener("orientationchange", updateViewport);
1284
+ return () => {
1285
+ window.removeEventListener("resize", updateViewport);
1286
+ window.visualViewport?.removeEventListener("resize", updateViewport);
1287
+ window.removeEventListener("orientationchange", updateViewport);
1288
+ };
1289
+ }, []);
1290
+ useEffect4(() => {
1291
+ if (typeof window === "undefined" || !orientation || !lockOnGesture) {
1292
+ return;
1293
+ }
1294
+ const tryLock = () => {
1295
+ if (!("orientation" in screen)) {
1296
+ return;
1297
+ }
1298
+ const screenOrientation = screen.orientation;
1299
+ if (!screenOrientation?.lock) {
1300
+ return;
1301
+ }
1302
+ void screenOrientation.lock(orientation).catch(() => {
1303
+ });
1304
+ };
1305
+ const onFirstGesture = () => {
1306
+ tryLock();
1307
+ window.removeEventListener("pointerdown", onFirstGesture, true);
1308
+ };
1309
+ window.addEventListener("pointerdown", onFirstGesture, true);
1310
+ return () => {
1311
+ window.removeEventListener("pointerdown", onFirstGesture, true);
1312
+ };
1313
+ }, [orientation, lockOnGesture]);
1314
+ useEffect4(() => {
1315
+ if (!orientation || sessionScope !== "controller") {
1316
+ return;
1317
+ }
1318
+ publishEmbeddedControllerPresentation(orientation);
1319
+ }, [orientation, sessionScope]);
1320
+ const currentOrientation = viewport ? getOrientation(viewport) : "portrait";
1321
+ const effectiveOrientation = orientation ?? currentOrientation;
1322
+ const needsRotation = orientation ? currentOrientation !== orientation : false;
1323
+ const shellStyle = useMemo(
1324
+ () => orientation ? resolveForcedOrientationFrameStyle(orientation, needsRotation) : resolveForcedOrientationFrameStyle(effectiveOrientation, false),
1325
+ [effectiveOrientation, needsRotation, orientation]
1326
+ );
1327
+ const availableSize = useMemo(
1328
+ () => resolveSurfaceViewportAvailableSize({
1329
+ safeViewportWidth: viewport?.width ?? 0,
1330
+ safeViewportHeight: viewport?.height ?? 0,
1331
+ orientation,
1332
+ needsRotation
1333
+ }),
1334
+ [needsRotation, orientation, viewport]
1335
+ );
1336
+ const referenceSize = useMemo(
1337
+ () => resolveSurfaceViewportReferenceSize({
1338
+ sessionScope,
1339
+ designWidth,
1340
+ designHeight,
1341
+ orientation: effectiveOrientation,
1342
+ availableWidth: availableSize.width,
1343
+ availableHeight: availableSize.height
1344
+ }),
1345
+ [
1346
+ availableSize.height,
1347
+ availableSize.width,
1348
+ designHeight,
1349
+ designWidth,
1350
+ effectiveOrientation,
1351
+ sessionScope
1352
+ ]
1353
+ );
1354
+ const scale = useMemo(() => {
1355
+ const scaleMode = sessionScope === "controller" ? effectiveOrientation === "portrait" ? "width" : "height" : "fit";
1356
+ return resolveSurfaceViewportScale({
1357
+ availableWidth: availableSize.width,
1358
+ availableHeight: availableSize.height,
1359
+ referenceWidth: referenceSize.width,
1360
+ referenceHeight: referenceSize.height,
1361
+ scaleMode,
1362
+ uiScaleMultiplier,
1363
+ minScale,
1364
+ maxScale
1365
+ });
1366
+ }, [
1367
+ availableSize.height,
1368
+ availableSize.width,
1369
+ effectiveOrientation,
1370
+ maxScale,
1371
+ minScale,
1372
+ referenceSize.height,
1373
+ referenceSize.width,
1374
+ sessionScope,
1375
+ uiScaleMultiplier
1376
+ ]);
1377
+ return /* @__PURE__ */ jsx14(
1378
+ "div",
1379
+ {
1380
+ className: cn("fixed inset-0 overflow-hidden", className),
1381
+ style: {
1382
+ ...createSurfaceViewportOuterStyle(),
1383
+ ...style
1384
+ },
1385
+ children: /* @__PURE__ */ jsx14("div", { style: shellStyle, children: /* @__PURE__ */ jsx14(
1386
+ "div",
1387
+ {
1388
+ className: cn("h-full w-full overflow-hidden", contentClassName),
1389
+ "data-airjam-surface-viewport": "true",
1390
+ style: createSurfaceViewportScaleStyle({
1391
+ scale,
1392
+ referenceWidth: referenceSize.width,
1393
+ referenceHeight: referenceSize.height
1394
+ }),
1395
+ children: /* @__PURE__ */ jsx14("div", { className: "h-full w-full", "data-airjam-surface-root": "true", children })
1396
+ }
1397
+ ) })
1398
+ }
1399
+ );
1400
+ };
1401
+
1402
+ // src/components/volume-controls.tsx
1403
+ import { Headphones, Music, Volume2 as Volume22 } from "lucide-react";
1404
+ import { jsx as jsx15, jsxs as jsxs12 } from "react/jsx-runtime";
1405
+ function VolumeControls(props) {
1406
+ if (props.values) {
1407
+ return /* @__PURE__ */ jsx15(ControlledVolumeControls, { ...props });
1408
+ }
1409
+ return /* @__PURE__ */ jsx15(OwnedVolumeControls, { ...props });
1410
+ }
1411
+ function OwnedVolumeControls({ className, compact }) {
1412
+ const {
1413
+ masterVolume,
1414
+ musicVolume,
1415
+ sfxVolume,
1416
+ setMasterVolume,
1417
+ setMusicVolume,
1418
+ setSfxVolume
1419
+ } = usePlatformAudioSettings();
1420
+ return /* @__PURE__ */ jsx15(
1421
+ ControlledVolumeControls,
1422
+ {
1423
+ className,
1424
+ compact,
1425
+ values: { masterVolume, musicVolume, sfxVolume },
1426
+ onMasterVolumeChange: setMasterVolume,
1427
+ onMusicVolumeChange: setMusicVolume,
1428
+ onSfxVolumeChange: setSfxVolume,
1429
+ readOnly: false
1430
+ }
1431
+ );
1432
+ }
1433
+ function ControlledVolumeControls({
1434
+ className,
1435
+ compact,
1436
+ values,
1437
+ readOnly = false,
1438
+ onMasterVolumeChange,
1439
+ onMusicVolumeChange,
1440
+ onSfxVolumeChange
1441
+ }) {
1442
+ if (!values) {
1443
+ throw new Error("ControlledVolumeControls requires values");
1444
+ }
1445
+ const { masterVolume, musicVolume, sfxVolume } = values;
1446
+ return /* @__PURE__ */ jsxs12("div", { className: cn("flex flex-col gap-3", compact && "gap-1", className), children: [
1447
+ /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-2", children: [
1448
+ /* @__PURE__ */ jsx15(Volume22, { className: "text-muted-foreground h-4 w-4" }),
1449
+ /* @__PURE__ */ jsx15("span", { className: "text-sm font-medium", children: "Volume" })
1450
+ ] }),
1451
+ /* @__PURE__ */ jsxs12("div", { className: "space-y-1.5", children: [
1452
+ /* @__PURE__ */ jsxs12("div", { className: "flex items-center justify-between", children: [
1453
+ /* @__PURE__ */ jsx15("label", { className: "text-muted-foreground text-xs", children: "Master" }),
1454
+ /* @__PURE__ */ jsxs12("span", { className: "text-muted-foreground font-mono text-xs", children: [
1455
+ Math.round(masterVolume * 100),
1456
+ "%"
1457
+ ] })
1458
+ ] }),
1459
+ /* @__PURE__ */ jsx15(
1460
+ Slider,
1461
+ {
1462
+ "data-testid": "platform-settings-master-volume",
1463
+ value: [masterVolume * 100],
1464
+ onValueChange: (sliderValues) => onMasterVolumeChange?.(sliderValues[0] / 100),
1465
+ min: 0,
1466
+ max: 100,
1467
+ step: 1,
1468
+ className: "w-full",
1469
+ "aria-label": "Master volume",
1470
+ disabled: readOnly
1471
+ }
1472
+ )
1473
+ ] }),
1474
+ /* @__PURE__ */ jsxs12("div", { className: "space-y-1.5", children: [
1475
+ /* @__PURE__ */ jsxs12("div", { className: "flex items-center justify-between", children: [
1476
+ /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-1.5", children: [
1477
+ /* @__PURE__ */ jsx15(Music, { className: "text-muted-foreground h-3 w-3" }),
1478
+ /* @__PURE__ */ jsx15("label", { className: "text-muted-foreground text-xs", children: "Music" })
1479
+ ] }),
1480
+ /* @__PURE__ */ jsxs12("span", { className: "text-muted-foreground font-mono text-xs", children: [
1481
+ Math.round(musicVolume * 100),
1482
+ "%"
1483
+ ] })
1484
+ ] }),
1485
+ /* @__PURE__ */ jsx15(
1486
+ Slider,
1487
+ {
1488
+ "data-testid": "platform-settings-music-volume",
1489
+ value: [musicVolume * 100],
1490
+ onValueChange: (sliderValues) => onMusicVolumeChange?.(sliderValues[0] / 100),
1491
+ min: 0,
1492
+ max: 100,
1493
+ step: 1,
1494
+ className: "w-full",
1495
+ "aria-label": "Music volume",
1496
+ disabled: readOnly
1497
+ }
1498
+ )
1499
+ ] }),
1500
+ /* @__PURE__ */ jsxs12("div", { className: "space-y-1.5", children: [
1501
+ /* @__PURE__ */ jsxs12("div", { className: "flex items-center justify-between", children: [
1502
+ /* @__PURE__ */ jsxs12("div", { className: "flex items-center gap-1.5", children: [
1503
+ /* @__PURE__ */ jsx15(Headphones, { className: "text-muted-foreground h-3 w-3" }),
1504
+ /* @__PURE__ */ jsx15("label", { className: "text-muted-foreground text-xs", children: "SFX" })
1505
+ ] }),
1506
+ /* @__PURE__ */ jsxs12("span", { className: "text-muted-foreground font-mono text-xs", children: [
1507
+ Math.round(sfxVolume * 100),
1508
+ "%"
1509
+ ] })
1510
+ ] }),
1511
+ /* @__PURE__ */ jsx15(
1512
+ Slider,
1513
+ {
1514
+ "data-testid": "platform-settings-sfx-volume",
1515
+ value: [sfxVolume * 100],
1516
+ onValueChange: (sliderValues) => onSfxVolumeChange?.(sliderValues[0] / 100),
1517
+ min: 0,
1518
+ max: 100,
1519
+ step: 1,
1520
+ className: "w-full",
1521
+ "aria-label": "SFX volume",
1522
+ disabled: readOnly
1523
+ }
1524
+ )
1525
+ ] })
1526
+ ] });
1527
+ }
1528
+
1529
+ // src/hooks/use-controller-lifecycle-intents.ts
1530
+ var useControllerLifecycleIntents = ({
1531
+ onStart,
1532
+ onTogglePause,
1533
+ onBackToLobby,
1534
+ onRestart
1535
+ }) => {
1536
+ return {
1537
+ onStart,
1538
+ onTogglePause,
1539
+ onBackToLobby,
1540
+ onRestart
1541
+ };
1542
+ };
1543
+
1544
+ // src/hooks/use-controller-lifecycle-permissions.ts
1545
+ var useControllerLifecyclePermissions = ({
1546
+ phase,
1547
+ canStartMatch = false,
1548
+ canSendSystemCommand = false
1549
+ }) => {
1550
+ const canStart = phase === "lobby" && canStartMatch;
1551
+ const canPauseToggle = phase === "playing" && canSendSystemCommand;
1552
+ const canRestart = phase === "ended" && canSendSystemCommand;
1553
+ const canBackToLobby = phase !== "lobby" && canSendSystemCommand;
1554
+ const canInteractForPhase = phase === "lobby" ? canStart : canSendSystemCommand;
1555
+ return {
1556
+ canStart,
1557
+ canPauseToggle,
1558
+ canRestart,
1559
+ canBackToLobby,
1560
+ canInteractForPhase
1561
+ };
1562
+ };
1563
+
1564
+ // src/hooks/use-controller-shell-status.ts
1565
+ var useControllerShellStatus = ({
1566
+ roomId,
1567
+ connectionStatus,
1568
+ playerLabel,
1569
+ fallbackLabel = "Controller",
1570
+ roomFallback = "----"
1571
+ }) => {
1572
+ const trimmedLabel = playerLabel?.trim() ?? "";
1573
+ const displayName = trimmedLabel || fallbackLabel;
1574
+ const roomDisplay = roomId ?? roomFallback;
1575
+ const identityInitial = displayName.charAt(0).toUpperCase() || "M";
1576
+ return {
1577
+ connectionStatus,
1578
+ displayName,
1579
+ roomDisplay,
1580
+ roomLine: `Room ${roomDisplay}`,
1581
+ hasIdentity: trimmedLabel.length > 0,
1582
+ identityInitial
1583
+ };
1584
+ };
1585
+
1586
+ // src/hooks/use-host-join-controls.ts
1587
+ import { useCallback as useCallback2, useEffect as useEffect5, useMemo as useMemo2, useRef as useRef3, useState as useState4 } from "react";
1588
+ var copyTextToClipboard = async (text) => {
1589
+ if (!text) {
1590
+ return false;
1591
+ }
1592
+ try {
1593
+ if (typeof navigator !== "undefined" && navigator.clipboard && typeof navigator.clipboard.writeText === "function") {
1594
+ await navigator.clipboard.writeText(text);
1595
+ return true;
1596
+ }
1597
+ } catch {
1598
+ }
1599
+ if (typeof document === "undefined") {
1600
+ return false;
1601
+ }
1602
+ const fallbackField = document.createElement("textarea");
1603
+ fallbackField.value = text;
1604
+ fallbackField.style.position = "fixed";
1605
+ fallbackField.style.opacity = "0";
1606
+ document.body.appendChild(fallbackField);
1607
+ fallbackField.select();
1608
+ try {
1609
+ return document.execCommand("copy");
1610
+ } catch {
1611
+ return false;
1612
+ } finally {
1613
+ document.body.removeChild(fallbackField);
1614
+ }
1615
+ };
1616
+ var useHostJoinControls = ({
1617
+ joinUrl,
1618
+ canStartMatch = false,
1619
+ onStartMatch,
1620
+ copiedDurationMs = 1800
1621
+ }) => {
1622
+ const [copied, setCopied] = useState4(false);
1623
+ const [joinQrVisible, setJoinQrVisible] = useState4(false);
1624
+ const resetTimerRef = useRef3(null);
1625
+ const joinUrlValue = useMemo2(() => joinUrl ?? "", [joinUrl]);
1626
+ const hasJoinUrl = joinUrlValue.length > 0;
1627
+ useEffect5(() => {
1628
+ if (!hasJoinUrl) {
1629
+ setJoinQrVisible(false);
1630
+ }
1631
+ }, [hasJoinUrl]);
1632
+ const handleCopy = useCallback2(async () => {
1633
+ if (!joinUrlValue) {
1634
+ return;
1635
+ }
1636
+ const copiedSuccessfully = await copyTextToClipboard(joinUrlValue);
1637
+ if (!copiedSuccessfully || typeof window === "undefined") {
1638
+ return;
1639
+ }
1640
+ setCopied(true);
1641
+ if (resetTimerRef.current !== null) {
1642
+ window.clearTimeout(resetTimerRef.current);
1643
+ }
1644
+ resetTimerRef.current = window.setTimeout(() => {
1645
+ setCopied(false);
1646
+ resetTimerRef.current = null;
1647
+ }, copiedDurationMs);
1648
+ }, [copiedDurationMs, joinUrlValue]);
1649
+ const handleOpen = useCallback2(() => {
1650
+ if (!joinUrlValue || typeof window === "undefined") {
1651
+ return;
1652
+ }
1653
+ window.open(joinUrlValue, "_blank", "noopener,noreferrer");
1654
+ }, [joinUrlValue]);
1655
+ const showJoinQr = useCallback2(() => {
1656
+ if (!hasJoinUrl) {
1657
+ return;
1658
+ }
1659
+ setJoinQrVisible(true);
1660
+ }, [hasJoinUrl]);
1661
+ const hideJoinQr = useCallback2(() => {
1662
+ setJoinQrVisible(false);
1663
+ }, []);
1664
+ const toggleJoinQr = useCallback2(() => {
1665
+ if (!hasJoinUrl) {
1666
+ return;
1667
+ }
1668
+ setJoinQrVisible((current) => !current);
1669
+ }, [hasJoinUrl]);
1670
+ const handleStart = useCallback2(() => {
1671
+ if (!canStartMatch) {
1672
+ return;
1673
+ }
1674
+ onStartMatch?.();
1675
+ }, [canStartMatch, onStartMatch]);
1676
+ return {
1677
+ joinUrlValue,
1678
+ hasJoinUrl,
1679
+ copied,
1680
+ joinQrVisible,
1681
+ canStartMatch,
1682
+ handleCopy,
1683
+ handleOpen,
1684
+ showJoinQr,
1685
+ hideJoinQr,
1686
+ toggleJoinQr,
1687
+ handleStart
1688
+ };
1689
+ };
1690
+ export {
1691
+ AIRJAM_DEFAULT_AVATAR_SEEDS,
1692
+ Button,
1693
+ ConnectionStatusPill,
1694
+ ControllerPlayerNameField,
1695
+ ControllerPrimaryAction,
1696
+ HostMuteButton,
1697
+ JoinQrOverlay,
1698
+ JoinUrlActionButtons,
1699
+ JoinUrlControls,
1700
+ JoinUrlField,
1701
+ LifecycleActionGroup,
1702
+ PlayerAvatar,
1703
+ PlayerAvatarStrip,
1704
+ RoomQrCode,
1705
+ RuntimeShellHeader,
1706
+ Slider,
1707
+ SurfaceViewport,
1708
+ VolumeControls,
1709
+ buttonVariants,
1710
+ getDiceBearAdventurerNeutralUrl,
1711
+ getPlayerAvatarImageUrl,
1712
+ resolvePlayerAvatarSeed,
1713
+ useControllerLifecycleIntents,
1714
+ useControllerLifecyclePermissions,
1715
+ useControllerShellStatus,
1716
+ useHostJoinControls,
1717
+ useLifecycleActionGroupModel
1718
+ };
1719
+ //# sourceMappingURL=ui.js.map