@air-jam/sdk 0.1.3 → 0.9.0

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